Skip to content

feat: extend extract_payment_signer to MPP credentials - #25

Merged
vvillait88 merged 1 commit into
mainfrom
tec-302-signer-mpp
May 14, 2026
Merged

feat: extend extract_payment_signer to MPP credentials#25
vvillait88 merged 1 commit into
mainfrom
tec-302-signer-mpp

Conversation

@vvillait88

Copy link
Copy Markdown
Contributor

Summary

  • Adds an authorization_header kwarg to extract_payment_signer. Decodes Authorization: Payment <base64> inline (no mpp._parsing dep) 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.
  • Positional x402 arg unchanged — merchants who only call the helper with x402 see no change.

Cross-language note

Python's MPP path requires a spec-compliant did:pkh source 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 emit did:pkh source, so this is a non-issue for spec-compliant traffic.

Tests

  • 11-fixture corpus locked as the cross-language contract: 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 via pytest.mark.parametrize so multiple drifts surface independently.
  • Adds x402 defensive coverage (JSON array, null payload, string payload).
  • Asserts x402 takes precedence when both headers are supplied; case-insensitive Payment scheme.

Test plan

  • uv run pytest tests/test_payment_signer.py — 29 tests pass
  • uv 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

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>
@vvillait88
vvillait88 merged commit ad860f1 into main May 14, 2026
7 checks passed
@vvillait88
vvillait88 deleted the tec-302-signer-mpp branch May 14, 2026 15:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant