feat: add x402 exact support#474
Conversation
commit: |
9cc0f6e to
d9b9454
Compare
|
Source-readback note on the new x402 exact flow: I think the server currently verifies the paid What I’m seeing:
That seems to allow a signed payment payload produced from one route challenge to be submitted to a different route with the same amount / asset / network / payTo / transfer metadata. The facilitator can still validate and settle the token transfer, but the server-side check has lost the x402 resource binding before release of content. A low-friction patch would be to check this in No wallet signing, payment headers, paid calls, or live facilitator calls were used for this pass. |
|
Re-checked commit Local repro I ran after building generated assets: corepack pnpm install --frozen-lockfile
corepack pnpm build
node --import tsx - <<'TS'
# Constructed an x402 exact route, replayed a PAYMENT-SIGNATURE from https://example.com/a against https://example.com/b, and asserted:
# {"crossResourceStatus":402,"sameResourceStatus":200,"verifyCalls":1}
TSI also tried the repo test runner for |
|
CI note from the failing runtime shard: the remaining failure looks like test fixture drift from the resource-binding fix, not the resource check itself. The failing test is const paymentRequired = x402_Header.decodePaymentRequired(...)
const credential = x402PaymentSignature(paymentRequired.accepts[0]!)But No additional live/payment calls used; this is just CI log + source readback. |
|
Final re-check at I do not have another blocker from this no-payment pass. No wallet signing, live payment headers, paid calls, or facilitator network calls used. |
Summary
Added x402 exact support with self-owned core types for v2 exact EVM payments, known USDC currencies, x402-specific header codecs, multiplexed HTTP client transport, server transports, and public
x402.exacthelpers.Motivation
Exposing a simple interface over the most common x402 method makes it easier for existing MPP users to add x402 support with minimal dependancies and a tighter security model
Examples
Existing server with Tempo MPP and x402:
Hono with Tempo MPP and x402:
Multiple payment methods on a single endpoint:
Main public interface:
x402.exact({ config: { currency, facilitator, recipient, decimals?, maxTimeoutSeconds?, network?, transfer?, asset?, payTo? } })mppx.x402.exact({ amount, resource? }), whereamountis a display-unit string like Tempomppx.compose([mppx.tempo.charge, { amount }], [mppx.x402.exact, { amount }])to serve multiple payment methods from one endpointx402.exact({ account, currencies?, maxAmount?, maxAtomicAmount?, networks?, decimals?, assets? })x402.assets.base.USDC,x402.assets.baseSepolia.USDC,x402.assets.define(...)