feat: extend extract_payment_signer to MPP credentials - #25
Merged
Conversation
Adds an `authorization_header` kwarg to the public signer helper. When
supplied, decodes the `Authorization: Payment <base64>` header inline
(no `mpp._parsing` dependency) and reads `source` or `challenge.source`
as a `did:pkh:eip155:<chain>:<addr>` / `did:pkh:solana:<genesis>:<addr>`
DID. Returns `{address, network}` matching the existing x402 path.
The positional x402 arg keeps the existing signature; merchants who only
care about x402 see no change. Merchants who previously imported
`mpp._parsing.parse_authorization` to recover the MPP signer can now use
the public helper.
Tests lock 11 cross-language MPP fixtures (top-level source, nested
challenge.source, defensive paths: non-dict JSON, non-did:pkh source,
unknown family, malformed address, malformed base64, bearer scheme,
empty token, empty string). Parametrized so multiple drifts surface
independently. Adds x402 defensive coverage (JSON array, null payload,
string payload).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
authorization_headerkwarg toextract_payment_signer. DecodesAuthorization: Payment <base64>inline (nompp._parsingdep) and readssourceorchallenge.sourceas adid:pkh:eip155:<chain>:<addr>/did:pkh:solana:<genesis>:<addr>DID.{address, network}matching the existing x402 path.Cross-language note
Python's MPP path requires a spec-compliant
did:pkhsource field. Credentials that rely on the Solana TransferChecked-authority fallback (extracting the signer from a signed-tx payload via@solana/kit) are only recoverable by the Node sibling. Production MPP clients emitdid:pkhsource, so this is a non-issue for spec-compliant traffic.Tests
challenge.source, defensive paths (non-dict JSON, non-did:pkh source, unknown family, malformed address, malformed base64, bearer scheme, empty token, empty string).pytest.mark.parametrizeso multiple drifts surface independently.Test plan
uv run pytest tests/test_payment_signer.py— 29 tests passuv run pytest— full suite 963 pass / 3 skip, coverage 95.14%uv run ruff check,uv run ruff format --check,uv run ty check— green🤖 Generated with Claude Code