fix(x402): strip extensions/resource from paymentPayload before facilitator (parity with node 2.7.5) - #92
Merged
Conversation
…litator call
Mirrors node-commerce 2.7.5. x402 clients echo the 402 challenge's `extensions`
(Bazaar input schema) + `resource` into the payload alongside the signed
`payload` + `accepted`. The Coinbase facilitator's /x402/verify validates the
payment payload against its x402V2PaymentPayload schema, which is
{x402Version, payload, accepted} and admits neither extensions nor resource:
their presence makes the payload match no union branch and settle fails
("must match one of [x402V2PaymentPayload, x402V1PaymentPayload]"). Routes with
a large echoed schema fail while small ones slip through.
process_x402_settle now runs strip_unsigned_x402_payload_fields before coercing
to the typed model whose model_dump reaches the facilitator, dropping only
extensions + resource and keeping accepted (which CDP requires, and which
verify_x402_request reads for network/payTo). Confirmed against the live CDP
facilitator: the stripped accepted-nested payload passes schema and reaches
signature verify. Bump to 2.5.10.
Co-Authored-By: Claude Opus 4.8 <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.
Parity with node-commerce 2.7.5
x402 clients echo the 402 challenge's
extensions(Bazaar input schema) +resourceinto the payload alongside the signedpayload+accepted. The Coinbase facilitator's/x402/verifyvalidates the payment payload against itsx402V2PaymentPayloadschema, which is{ x402Version, payload, accepted }and admits neitherextensionsnorresource: their presence makes the payload match no union branch (must match one of [x402V2PaymentPayload, x402V1PaymentPayload]) and settle fails. Routes with a large echoed Bazaar schema fail while small ones slip through.Fix
process_x402_settlenow runsstrip_unsigned_x402_payload_fieldsbefore coercing to the typed model whosemodel_dump(by_alias, exclude_none)reaches the facilitator, dropping onlyextensions+resourceand keepingaccepted(which CDP requires, and whichverify_x402_requestreads for network/payTo). Neither stripped block is part of the EIP-3009 signature.Confirmed against the live CDP facilitator: the stripped accepted-nested payload passes schema and reaches signature verify; a flat
{ x402Version, scheme, network, payload }is rejected withrequires 'accepted'.Tests
Unit: drop-both / keep-accepted, unchanged-when-absent (same object), single-field strip, non-dict passthrough. Integration:
process_x402_settleforwards a payload to BOTH verify and settle withacceptedkept andextensions/resourcegone.Full suite green (1840 passed, 95.36% coverage), ruff + ty clean.
🤖 Generated with Claude Code