Repository navigation
fix(x402): authenticate explicit payment requests - #3
Open
AkshatGada wants to merge 1 commit into
Open
AkshatGada wants to merge 1 commit into
AkshatGada wants to merge 1 commit into
Conversation
Author
|
@kmjones1979, with |
AkshatGada
marked this pull request as ready for review
October 18, 2026 23:22
This branch has not been deployed
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.
Calling
client.x402.withPayment()immediately aftercreateClient({ apiKey })can send the protected secret GET before user-key authentication finishes or without exchanging an agent key. Its direct fetches also omit configured DPoP/runtime headers and reuse the original Bearer token after payment signing.Route both requests through the existing authenticated
rawRequest()transport. Each attempt now waits for authentication, refreshes eligible agent tokens, and builds current headers. Explicit signer selection, payment amount/payload semantics, one paid retry, and resource response envelopes are preserved without activating automatic payment.Failed agent-token exchanges now reject through the shared transport before dispatch, matching other authenticated resources. The existing user-key exchange failure handling is unchanged.
Testing
On Node 22.23.3:
1claw-openapi-specchecked out alongside the SDK as current CI requires.HTTP, payment signatures, and DPoP generation are mocked in the regression tests. These checks cover request construction and control flow; no live authentication, payment settlement, or server-side DPoP acceptance was tested.