@devlab.group/agent-commerce 2.7.1 → 2.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (121) hide show
  1. package/README.md +72 -24
  2. package/dist/ap2.d.ts +3 -11
  3. package/dist/ap2.js +96 -27
  4. package/dist/ap2.js.map +1 -1
  5. package/dist/{chunk-77HLISG4.js → chunk-2PVRHMVT.js} +14 -10
  6. package/dist/chunk-2PVRHMVT.js.map +1 -0
  7. package/dist/chunk-ENK63GKR.js +22 -0
  8. package/dist/chunk-ENK63GKR.js.map +1 -0
  9. package/dist/{chunk-YHNTTMED.js → chunk-MDOGXTZD.js} +2 -2
  10. package/dist/chunk-MDOGXTZD.js.map +1 -0
  11. package/dist/chunk-MNI6APE6.js +64 -0
  12. package/dist/chunk-MNI6APE6.js.map +1 -0
  13. package/dist/{chunk-5VW32JPV.js → chunk-QZW5YL3G.js} +160 -41
  14. package/dist/chunk-QZW5YL3G.js.map +1 -0
  15. package/dist/{chunk-DJRWYDKJ.js → chunk-RXYGC7A3.js} +3 -3
  16. package/dist/{chunk-DJRWYDKJ.js.map → chunk-RXYGC7A3.js.map} +1 -1
  17. package/dist/{chunk-5AO5N2XY.js → chunk-VHS6MGXJ.js} +621 -4
  18. package/dist/chunk-VHS6MGXJ.js.map +1 -0
  19. package/dist/cli/{ap2-NTYL7H4I.js → ap2-GYKFGE66.js} +35 -8
  20. package/dist/cli/ap2-GYKFGE66.js.map +1 -0
  21. package/dist/cli/chunk-2PO65227.js +619 -0
  22. package/dist/cli/chunk-2PO65227.js.map +1 -0
  23. package/dist/cli/{chunk-GBBG66O6.js → chunk-3PGFOEVJ.js} +132 -103
  24. package/dist/cli/chunk-3PGFOEVJ.js.map +1 -0
  25. package/dist/cli/chunk-4YZULHX2.js +64 -0
  26. package/dist/cli/chunk-4YZULHX2.js.map +1 -0
  27. package/dist/cli/chunk-526C4KZA.js +93 -0
  28. package/dist/cli/chunk-526C4KZA.js.map +1 -0
  29. package/dist/cli/{chunk-FETTSOMT.js → chunk-5CH5VFC6.js} +139 -4
  30. package/dist/cli/chunk-5CH5VFC6.js.map +1 -0
  31. package/dist/cli/chunk-6BWEHQPJ.js +215 -0
  32. package/dist/cli/chunk-6BWEHQPJ.js.map +1 -0
  33. package/dist/cli/chunk-GISJ73ML.js +20 -0
  34. package/dist/cli/chunk-GISJ73ML.js.map +1 -0
  35. package/dist/cli/chunk-MASLG557.js +26 -0
  36. package/dist/cli/chunk-MASLG557.js.map +1 -0
  37. package/dist/cli/chunk-RQ7W3NA5.js +143 -0
  38. package/dist/cli/chunk-RQ7W3NA5.js.map +1 -0
  39. package/dist/cli/chunk-RWBUHDU7.js +48 -0
  40. package/dist/cli/chunk-RWBUHDU7.js.map +1 -0
  41. package/dist/cli/chunk-SAAT2XFX.js +8 -0
  42. package/dist/cli/{chunk-2M2RF3CT.js.map → chunk-SAAT2XFX.js.map} +1 -1
  43. package/dist/cli/{chunk-MBPOKPQM.js → chunk-SYXLQ5BS.js} +7 -5
  44. package/dist/cli/chunk-SYXLQ5BS.js.map +1 -0
  45. package/dist/cli/{chunk-FL4HPCD4.js → chunk-THH7Y3OO.js} +3 -35
  46. package/dist/cli/chunk-THH7Y3OO.js.map +1 -0
  47. package/dist/cli/{chunk-55AI6CLW.js → chunk-USIXWAXZ.js} +2 -2
  48. package/dist/cli/chunk-USIXWAXZ.js.map +1 -0
  49. package/dist/cli/{chunk-EVCIEKHN.js → chunk-VWQMSWDF.js} +141 -42
  50. package/dist/cli/chunk-VWQMSWDF.js.map +1 -0
  51. package/dist/cli/{chunk-OETKXDGA.js → chunk-WFIR374D.js} +89 -272
  52. package/dist/cli/chunk-WFIR374D.js.map +1 -0
  53. package/dist/cli/{chunk-A42BCWZ2.js → chunk-YXXPZFWC.js} +4 -4
  54. package/dist/cli/{chunk-A42BCWZ2.js.map → chunk-YXXPZFWC.js.map} +1 -1
  55. package/dist/cli/config-JWMHWVRT.js +14 -0
  56. package/dist/cli/{config-ODN4IEMZ.js.map → config-JWMHWVRT.js.map} +1 -1
  57. package/dist/cli/index.js +363 -84
  58. package/dist/cli/index.js.map +1 -1
  59. package/dist/cli/{mcp-V27OKTOV.js → mcp-OW5GY7TT.js} +84 -45
  60. package/dist/cli/mcp-OW5GY7TT.js.map +1 -0
  61. package/dist/cli/payment-providers-QL2BJYMD.js +6 -0
  62. package/dist/cli/{payment-providers-SUATT75K.js.map → payment-providers-QL2BJYMD.js.map} +1 -1
  63. package/dist/cli/{provider-C3QDAXMR.js → provider-3A2LVEQS.js} +145 -23
  64. package/dist/cli/provider-3A2LVEQS.js.map +1 -0
  65. package/dist/cli/receipts-FQUFGEQD.js +9 -0
  66. package/dist/cli/{receipts-ZS3VZ2D4.js.map → receipts-FQUFGEQD.js.map} +1 -1
  67. package/dist/cli/{run-WYFZUO5D.js → run-KF5OQYPL.js} +97 -66
  68. package/dist/cli/run-KF5OQYPL.js.map +1 -0
  69. package/dist/cli/{x402-UGLZ3LA7.js → x402-5A7CVCIJ.js} +12 -8
  70. package/dist/cli/x402-5A7CVCIJ.js.map +1 -0
  71. package/dist/index.d.ts +36 -12
  72. package/dist/index.js +345 -397
  73. package/dist/index.js.map +1 -1
  74. package/dist/mcp.d.ts +2 -2
  75. package/dist/mcp.js +80 -42
  76. package/dist/mcp.js.map +1 -1
  77. package/dist/mpp.d.ts +3 -2
  78. package/dist/mpp.js +139 -20
  79. package/dist/mpp.js.map +1 -1
  80. package/dist/{protocol-adapter-DdFL5LBU.d.ts → protocol-adapter-D6JH_kk-.d.ts} +2 -2
  81. package/dist/{runtime-BmaSp2Ce.d.ts → runtime-D8u6lYfx.d.ts} +10 -0
  82. package/dist/{store-DQwbKhnc.d.ts → store-BzgwHOPu.d.ts} +2 -2
  83. package/dist/testing.d.ts +1 -1
  84. package/dist/testing.js +1 -1
  85. package/dist/{transaction-BXXJltZ-.d.ts → transaction-F9ZvhokH.d.ts} +1 -1
  86. package/dist/types-Dl27vhEc.d.ts +167 -0
  87. package/dist/x402.d.ts +7 -110
  88. package/dist/x402.js +6 -5
  89. package/dist/x402.js.map +1 -1
  90. package/package.json +3 -1
  91. package/dist/chunk-5AO5N2XY.js.map +0 -1
  92. package/dist/chunk-5VW32JPV.js.map +0 -1
  93. package/dist/chunk-77HLISG4.js.map +0 -1
  94. package/dist/chunk-IGXQMAKM.js +0 -8
  95. package/dist/chunk-IGXQMAKM.js.map +0 -1
  96. package/dist/chunk-YHNTTMED.js.map +0 -1
  97. package/dist/cli/ap2-NTYL7H4I.js.map +0 -1
  98. package/dist/cli/chunk-2M2RF3CT.js +0 -8
  99. package/dist/cli/chunk-3NVJAQRO.js +0 -119
  100. package/dist/cli/chunk-3NVJAQRO.js.map +0 -1
  101. package/dist/cli/chunk-55AI6CLW.js.map +0 -1
  102. package/dist/cli/chunk-66NTYSXI.js +0 -277
  103. package/dist/cli/chunk-66NTYSXI.js.map +0 -1
  104. package/dist/cli/chunk-EVCIEKHN.js.map +0 -1
  105. package/dist/cli/chunk-FETTSOMT.js.map +0 -1
  106. package/dist/cli/chunk-FL4HPCD4.js.map +0 -1
  107. package/dist/cli/chunk-GBBG66O6.js.map +0 -1
  108. package/dist/cli/chunk-H7EBJ4I3.js +0 -53
  109. package/dist/cli/chunk-H7EBJ4I3.js.map +0 -1
  110. package/dist/cli/chunk-MBPOKPQM.js.map +0 -1
  111. package/dist/cli/chunk-OETKXDGA.js.map +0 -1
  112. package/dist/cli/chunk-TPC4EJLT.js +0 -11
  113. package/dist/cli/chunk-TPC4EJLT.js.map +0 -1
  114. package/dist/cli/config-ODN4IEMZ.js +0 -13
  115. package/dist/cli/mcp-V27OKTOV.js.map +0 -1
  116. package/dist/cli/payment-providers-SUATT75K.js +0 -6
  117. package/dist/cli/provider-C3QDAXMR.js.map +0 -1
  118. package/dist/cli/receipts-ZS3VZ2D4.js +0 -9
  119. package/dist/cli/run-WYFZUO5D.js.map +0 -1
  120. package/dist/cli/x402-UGLZ3LA7.js.map +0 -1
  121. package/dist/networks-DDHYJLcg.d.ts +0 -39
package/dist/mpp.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/payments/mpp/descriptor.ts","../src/payments/mpp/credential.ts","../src/payments/mpp/options.ts","../src/payments/mpp/provider.ts"],"names":["isAddress","getAddress"],"mappings":";;;;;;;;;;;;;;;;AAYO,IAAM,cAAA,GAAoC;AAAA,EAC/C,IAAA,EAAM,KAAA;AAAA,EACN,IAAA,EAAM,SAAA;AAAA,EACN,qBAAA,EAAuB,eAAA;AAAA,EACvB,aAAA,EAAe,kBAAA;AAAA,EACf,YAAA,EAAc;AAAA,IACZ,CAAA,OAAA,EAAU,YAAY,MAAM,CAAA,CAAA;AAAA,IAC5B,CAAA,OAAA,EAAU,YAAY,MAAM,CAAA,CAAA;AAAA,IAC5B,CAAA,WAAA,EAAc,YAAY,cAAc,CAAA,CAAA;AAAA,IACxC,UAAA;AAAA,IACA,GAAG,YAAA,CAAa,GAAA,CAAI,CAAC,OAAA,KAAY,CAAA,QAAA,EAAW,OAAO,CAAA,CAAE,CAAA;AAAA,IACrD,CAAA,MAAA,EAAS,YAAY,WAAW,CAAA,CAAA;AAAA,IAChC,sBAAA;AAAA,IACA,oBAAA;AAAA,IACA,cAAA;AAAA,IACA,iBAAA;AAAA;AAAA,IAEA;AAAA,GACF;AAAA;AAAA,EAEA,MAAA,EAAQ,cAAA;AAAA,EACR,WAAA,EAAa;AAAA;AAAA,IAEX,wBAAA;AAAA;AAAA,IAEA,oBAAA;AAAA,IACA,wBAAA;AAAA,IACA,iBAAA;AAAA;AAAA,IAEA,QAAA;AAAA,IACA,qBAAA;AAAA;AAAA,IAEA,cAAA;AAAA,IACA;AAAA;AAEJ;ACtCA,IAAM,oBAAA,GAA+D;AAAA,EACnE,CAAC,6CAA6C,aAAa,CAAA;AAAA,EAC3D,CAAC,wCAAwC,mBAAmB,CAAA;AAAA,EAC5D,CAAC,sCAAsC,6BAA6B,CAAA;AAAA,EACpE,CAAC,iCAAiC,uBA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SAAA,IAAa,OAAA,CAAQ,iBAAA,KAAsB,QAAW,OAAO,MAAA;AAGpF,IAAA,MAAM,MAAA,GAAqE;AAAA,MACzE,QAAQ,WAAA,CAAY,MAAA;AAAA,MACpB,WAAW,OAAA,CAAQ,iBAAA;AAAA,MACnB,MAAA,EAAQ,SAAA;AAAA,MACR,SAAA,EAAW,OAAA,CAAQ,SAAA,IAAa,KAAA,CAAM,MAAA,EAAO;AAAA,MAC7C,WAAA,EAAa,WAAW,SAAA,CAAU,EAAA;AAAA,MAClC;AAAA,KACF;AACA,IAAA,MAAM,OAAA,GAAU,OAAA,CAAQ,IAAA,CAAK,MAAM,CAAA;AACnC,IAAA,OAAO,EAAE,GAAG,MAAA,EAAQ,QAAA,EAAU,EAAE,GAAG,OAAA,CAAQ,QAAA,EAAU,OAAA,EAAS,OAAA,CAAQ,SAAA,CAAU,OAAO,GAAE,EAAE;AAAA,EAC7F;AAEA,EAAA,SAAS,MAAA,GAAiC;AACxC,IAAA,OAAO,WAAW,MAAA,EAAO;AAAA,EAC3B;AAIA,EAAA,MAAM,SAAA,GAAY,UAAA,CAAW,SAAA,EAAW,IAAA,CAAK,UAAU,CAAA;AACvD,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,KAAA;AAAA,IACN,UAAA,EAAY,cAAA;AAAA,IACZ,iBAAA;AAAA,IACA,MAAA;AAAA,IACA,MAAA;AAAA,IACA,GAAI,SAAA,KAAc,MAAA,GAAY,EAAE,SAAA,KAAc,EAAC;AAAA,IAC/C;AAAA,GACF;AACF","file":"mpp.js","sourcesContent":["/**\n * Describes the MPP profile and its unsupported variants.\n *\n * The protocol name alone cannot identify a compatible intent, method and\n * extension set, so the descriptor lists both the target and its gaps.\n *\n * Importing the descriptor does not load `mppx`.\n */\nimport type { AdapterDescriptor } from '../../core/public-types';\nimport { PACKAGE_VERSION } from '../../version';\nimport { MPP_NETWORKS, MPP_PROFILE, MPP_SUPPORTED_SPEC } from './constants';\n\nexport const MPP_DESCRIPTOR: AdapterDescriptor = {\n name: 'mpp',\n kind: 'payment',\n implementationVersion: PACKAGE_VERSION,\n supportedSpec: MPP_SUPPORTED_SPEC,\n capabilities: [\n `intent=${MPP_PROFILE.intent}`,\n `method=${MPP_PROFILE.method}`,\n `credential=${MPP_PROFILE.credentialType}`,\n 'eip-3009',\n ...MPP_NETWORKS.map((network) => `network=${network}`),\n `asset=${MPP_PROFILE.assetSymbol}`,\n 'verify-before-settle',\n 'authorization-flow',\n 'upfront-flow',\n 'payment-receipt',\n // HTTP request bodies only; MCP and A2A carry the proof in the body\n 'challenge-digest-binding',\n ],\n // The pinned specs are drafts and mppx is pre-1.0; the wire format may change\n status: 'experimental',\n unsupported: [\n // Name other methods as a class instead of maintaining a second list\n 'methods other than evm',\n // This profile supports only the EIP-3009 `authorization` credential\n 'credential=permit2',\n 'credential=transaction',\n 'credential=hash',\n // The draft allows splits only with permit2 credentials\n 'splits',\n 'intent=subscription',\n // A separate EVM draft, not an option of charge\n 'evm sessions',\n 'discovery extension',\n ],\n};\n","// Reading an MPP credential: its decoding, its binding to the challenge, and the x402 proof it carries\nimport { type Challenge, Credential, Errors, PaymentRequest } from 'mppx';\nimport type { Types } from 'mppx/evm';\nimport { getAddress, isAddress } from 'viem';\nimport type { PaymentRequirement, PaymentSubmission } from '../../core';\n\n// mppx reports a verification failure only as message text. The pinned\n// release's wording maps to stable reasons, and the tests cover every entry;\n// unmapped text becomes `authorization_invalid`.\nconst VERIFICATION_REASONS: readonly (readonly [string, string])[] = [\n ['EVM authorization challenge hash mismatch', 'wrong_nonce'],\n ['EVM authorization signature mismatch', 'invalid_signature'],\n ['EVM authorization is not valid yet', 'authorization_not_yet_valid'],\n ['EVM authorization has expired', 'authorization_expired'],\n ['EVM authorization source mismatch', 'source_mismatch'],\n ['EVM authorization amount mismatch', 'wrong_amount'],\n ['EVM authorization recipient mismatch', 'wrong_recipient'],\n];\n\nexport function verificationReason(error: unknown): string {\n if (error instanceof Errors.PaymentExpiredError) return 'challenge_expired';\n if (error instanceof Errors.InvalidPayloadError) return 'invalid_payload';\n if (error instanceof Errors.InvalidChallengeError) return 'invalid_challenge';\n if (error instanceof Errors.VerificationFailedError) {\n const match = VERIFICATION_REASONS.find(([text]) => error.message.includes(text));\n if (match) return match[1];\n }\n return 'authorization_invalid';\n}\n\n// Accept the HTTP `Authorization: Payment ...` value or a JSON credential\n// from MCP `_meta`. Serialize the object for mppx deserialization\nexport function decodeCredential(payload: string): Credential.Credential {\n const serialized = payload.trimStart().startsWith('{')\n ? Credential.serialize(JSON.parse(payload) as Credential.Credential)\n : payload;\n return Credential.deserialize(serialized);\n}\n\n// Compares the echoed challenge with the one issued for this request. Both\n// carry a valid HMAC by now, so any difference means the credential answers a\n// challenge issued for other terms. The final comparison catches a difference\n// in any request field the named checks do not cover.\nexport function bindingMismatch(\n echoed: Challenge.Challenge,\n issued: Challenge.Challenge,\n resourceId: string,\n): string | undefined {\n if (echoed.realm !== issued.realm) return 'wrong_realm';\n if (echoed.method !== issued.method || echoed.intent !== issued.intent) {\n return 'unsupported_method';\n }\n // Only the encoded `opaque` survives the credential round trip, not `meta`,\n // so compare it with the encoding of this resource's binding\n if (echoed.opaque !== PaymentRequest.serialize({ resource: resourceId })) {\n return 'wrong_resource';\n }\n // `issued` was built for the request carrying this credential, so a\n // different body, or none, fails here. A challenge without a digest binds\n // no body, as the core draft reads it.\n if (echoed.digest !== undefined && echoed.digest !== issued.digest) {\n return 'body_digest_mismatch';\n }\n const got = echoed.request as ChargeRequest;\n const want = issued.request as ChargeRequest;\n if (got.amount !== want.amount) return 'wrong_amount';\n if (!sameAddress(got.recipient, want.recipient)) return 'wrong_recipient';\n if (got.methodDetails?.chainId !== want.methodDetails?.chainId) return 'wrong_network';\n if (!sameAddress(got.currency, want.currency)) return 'wrong_asset';\n if (canonical(got.methodDetails) !== canonical(want.methodDetails)) {\n return 'unsupported_credential';\n }\n if (canonical(got) !== canonical(want)) return 'wrong_terms';\n return undefined;\n}\n\n// Rewrap the MPP authorization as the x402 `exact` payload expected by settlement\nexport function toX402Submission(\n x402Requirement: PaymentRequirement,\n authorization: Types.AuthorizationPayload,\n): PaymentSubmission {\n const { signature, from, to, value, validAfter, validBefore, nonce } = authorization;\n const payment = {\n x402Version: 2,\n accepted: x402Requirement.challenge.accepts[0],\n payload: { signature, authorization: { from, to, value, validAfter, validBefore, nonce } },\n };\n return { method: 'x402', payload: Buffer.from(JSON.stringify(payment)).toString('base64') };\n}\n\ninterface ChargeRequest {\n readonly amount?: string;\n readonly currency?: string;\n readonly recipient?: string;\n readonly methodDetails?: { readonly chainId?: number };\n}\n\n// The encoding mppx binds into the challenge HMAC, so key order cannot\n// produce a false mismatch\nfunction canonical(value: object | undefined): string {\n return value === undefined ? '' : PaymentRequest.serialize(value as PaymentRequest.Request);\n}\n\nexport function sameAddress(a: string | undefined, b: string | undefined): boolean {\n return a !== undefined && b !== undefined && isAddress(a) && isAddress(b)\n ? getAddress(a) === getAddress(b)\n : false;\n}\n","// The MPP provider's options, checked once at construction\nimport { isAddress } from 'viem';\nimport { type Clock, CommerceError, type IdGenerator, type Logger } from '../../core';\nimport type { X402FacilitatorConfig } from '../x402/guardrails';\nimport type { X402PaymentFlow } from '../x402/payment-flow';\nimport { isMppNetwork, MPP_MIN_CHALLENGE_SECRET_LENGTH, MPP_NETWORKS } from './constants';\n\n/** Whether the token contract has recorded `nonce` as used by `payer` */\nexport type NonceUsedReader = (payer: `0x${string}`, nonce: `0x${string}`) => Promise<boolean>;\n\nexport interface MppProviderOptions {\n /** Merchant-controlled settlement destination. Never gateway-owned */\n readonly recipient: `0x${string}`;\n /** EIP-3009 token the charge is paid in */\n readonly asset: `0x${string}`;\n /** EIP-712 domain name of the asset, e.g. 'USDC' or 'MockUSDC' */\n readonly assetName: string;\n /** EIP-712 domain version of the asset, e.g. '2' */\n readonly assetVersion: string;\n /** Value of each challenge's `realm`, such as the gateway's host */\n readonly realm: string;\n /** Key that binds each challenge to this gateway. Never logged or published */\n readonly challengeSecret: string;\n /** RPC endpoint of the settlement chain */\n readonly rpcUrl: string;\n /** The x402 facilitator that verifies and broadcasts the authorization */\n readonly facilitator: X402FacilitatorConfig;\n /** Must be `true` before anything settles on a mainnet. Never a default */\n readonly allowMainnet?: boolean;\n /** Required on mainnet when facilitator auth is `none` */\n readonly allowUnauthenticatedFacilitator?: boolean;\n readonly logger?: Logger;\n /**\n * Seconds a challenge stays valid, 300 by default. The mppx client signs its\n * authorization to expire at the same moment.\n */\n readonly challengeTtlSeconds?: number;\n /**\n * CAIP-2 network: `eip155:31337` (local Anvil), `eip155:84532` (Base\n * Sepolia, the default) or `eip155:8453` (Base)\n */\n readonly network?: string;\n /**\n * Same flow values as x402. The default, `upfront`, settles before the\n * backend; `authorization` settles after it\n */\n readonly paymentFlow?: X402PaymentFlow;\n /** Per-resource overrides of `paymentFlow`, keyed by resource id */\n readonly resourcePaymentFlows?: Readonly<Record<string, X402PaymentFlow>>;\n readonly clock?: Clock;\n readonly ids?: IdGenerator;\n}\n\nexport function configInvalid(message: string): CommerceError {\n return new CommerceError('CONFIG_INVALID', message);\n}\n\nexport type MppChallengeOptions = Omit<\n MppProviderOptions,\n 'rpcUrl' | 'facilitator' | 'allowMainnet' | 'allowUnauthenticatedFacilitator' | 'logger'\n>;\n\nexport function validateOptions(options: MppChallengeOptions): void {\n if (!isAddress(options.recipient)) throw configInvalid('MPP recipient is not an EVM address');\n if (!isAddress(options.asset)) throw configInvalid('MPP asset is not an EVM address');\n if (options.assetName.length === 0 || options.assetVersion.length === 0) {\n throw configInvalid('MPP asset needs its EIP-712 domain name and version');\n }\n // mppx refuses CR or LF in the quoted realm parameter, so checking here fails\n // at construction instead of on every challenge\n if (options.realm.length === 0 || /[\\r\\n]/.test(options.realm)) {\n throw configInvalid('MPP realm must be a non-empty single-line string');\n }\n if (options.challengeSecret.length < MPP_MIN_CHALLENGE_SECRET_LENGTH) {\n throw configInvalid(\n `MPP challenge secret must have length at least ${MPP_MIN_CHALLENGE_SECRET_LENGTH}`,\n );\n }\n const ttl = options.challengeTtlSeconds;\n if (ttl !== undefined && (!Number.isInteger(ttl) || ttl <= 0)) {\n throw configInvalid('MPP challenge TTL must be a positive whole number of seconds');\n }\n if (options.network !== undefined && !isMppNetwork(options.network)) {\n throw configInvalid(`MPP network must be one of ${MPP_NETWORKS.join(', ')}`);\n }\n}\n","/**\n * MPP payment provider for the `charge` intent, the `evm` method and the\n * EIP-3009 `authorization` credential.\n *\n * It issues challenges and verifies credentials without moving funds: local\n * checks first, then a read-only check by an x402 facilitator. Settlement hands\n * the same signed authorization to that facilitator through an internal x402\n * provider built from these options. The MPP layer adds no signing key.\n *\n * Under the default `upfront` flow settlement precedes the backend call; under\n * `authorization` it follows a successful one. The drafts require a confirmed\n * transaction before a `Payment-Receipt`.\n */\nimport { PERMIT2_ADDRESS } from '@x402/evm';\nimport { Challenge, type Credential, Method, Receipt } from 'mppx';\nimport { Methods, type Types } from 'mppx/evm';\nimport { charge } from 'mppx/evm/server';\nimport { createPublicClient, getAddress, http, parseAbi } from 'viem';\nimport {\n type AdapterHealth,\n CommerceError,\n type PaymentContext,\n type PaymentProvider,\n type PaymentRequirement,\n type PaymentResult,\n type PaymentSettlementContext,\n type PaymentVerificationContext,\n RECONCILIATION_METADATA_KEY,\n systemClock,\n} from '../../core';\nimport { SETTLE_AFTER_BACKEND_METADATA_KEY } from '../../core/execution/settlement-order';\nimport { parseCanonicalAmount } from '../x402/amount';\nimport { eip3009Locator } from '../x402/locator';\nimport { createX402PaymentProvider, DEFAULT_IDS } from '../x402/provider';\nimport { computeReplayKey } from '../x402/replay-key';\nimport {\n MPP_DEFAULT_NETWORK,\n MPP_DEFAULT_PAYMENT_FLOW,\n MPP_PROFILE,\n MPP_SPEC_DRAFTS,\n} from './constants';\nimport {\n bindingMismatch,\n decodeCredential,\n sameAddress,\n toX402Submission,\n verificationReason,\n} from './credential';\nimport { MPP_DESCRIPTOR } from './descriptor';\nimport {\n configInvalid,\n type MppChallengeOptions,\n type MppProviderOptions,\n type NonceUsedReader,\n validateOptions,\n} from './options';\nimport { CONTENT_DIGEST_METADATA_KEY } from './transport';\n\nconst DEFAULT_CHALLENGE_TTL_SECONDS = 300;\n\n// The x402 SDK's verify reason for an EIP-3009 nonce already spent on chain\nconst NONCE_ALREADY_USED = 'invalid_exact_evm_nonce_already_used';\n\nconst AUTHORIZATION_STATE_ABI = parseAbi([\n 'function authorizationState(address authorizer, bytes32 nonce) view returns (bool)',\n]);\n\nconst NONCE_READ_TIMEOUT_MS = 5_000;\n\nexport function createMppPaymentProvider(options: MppProviderOptions): PaymentProvider {\n const { rpcUrl, facilitator, allowMainnet, allowUnauthenticatedFacilitator, logger, ...rest } =\n options;\n // Checked first so a bad MPP option is reported as one, not as an x402 error\n validateOptions(rest);\n // Built from the same terms, and never registered as a rail, so an MPP-only\n // deployment needs no x402 configuration\n const settlement = createX402PaymentProvider({\n network: options.network ?? MPP_DEFAULT_NETWORK,\n rpcUrl,\n asset: options.asset,\n assetName: options.assetName,\n assetVersion: options.assetVersion,\n assetDecimals: MPP_PROFILE.assetDecimals,\n payTo: options.recipient,\n facilitator,\n ...(allowMainnet !== undefined ? { allowMainnet } : {}),\n ...(allowUnauthenticatedFacilitator !== undefined ? { allowUnauthenticatedFacilitator } : {}),\n ...(logger !== undefined ? { logger } : {}),\n ...(options.clock !== undefined ? { clock: options.clock } : {}),\n });\n // One attempt: the read only names the reason for a refusal already decided\n const chain = createPublicClient({\n transport: http(rpcUrl, { timeout: NONCE_READ_TIMEOUT_MS, retryCount: 0 }),\n });\n const nonceUsed: NonceUsedReader = (payer, nonce) =>\n chain.readContract({\n address: options.asset,\n abi: AUTHORIZATION_STATE_ABI,\n functionName: 'authorizationState',\n args: [payer, nonce],\n });\n return createMppProviderWithSettlement(rest, settlement, nonceUsed);\n}\n\n/**\n * Internal seam: tests inject a settlement provider and the nonce reader. Not\n * exported from the `./mpp` entry.\n */\nexport function createMppProviderWithSettlement(\n options: MppChallengeOptions,\n settlement: PaymentProvider,\n nonceUsed?: NonceUsedReader,\n): PaymentProvider {\n validateOptions(options);\n if (settlement.name !== 'x402') {\n throw configInvalid('MPP settlement must be an x402 payment provider');\n }\n const network = options.network ?? MPP_DEFAULT_NETWORK;\n const chainId = Number(network.split(':')[1]);\n const clock = options.clock ?? systemClock;\n const ttlSeconds = options.challengeTtlSeconds ?? DEFAULT_CHALLENGE_TTL_SECONDS;\n const recipient = getAddress(options.recipient);\n const asset = getAddress(options.asset);\n const ids = options.ids ?? DEFAULT_IDS;\n // The settlement provider's terms are fixed at construction, so one passing\n // check covers every later challenge\n let settlementTermsChecked = false;\n\n // charge() requires a callback even though this provider never invokes the\n // mppx broadcast path. Settlement is delegated to the x402 provider.\n const method = charge({\n currency: asset,\n recipient,\n chainId,\n decimals: MPP_PROFILE.assetDecimals,\n authorization: { name: options.assetName, version: options.assetVersion },\n settle: async () => {\n throw new CommerceError('INTERNAL_ERROR', 'MPP direct broadcast is disabled');\n },\n });\n\n function rejected(\n requirement: PaymentRequirement,\n reason: string,\n replayKey?: string,\n ): PaymentResult {\n return {\n status: 'rejected',\n provider: 'mpp',\n amount: requirement.amount,\n currency: requirement.currency,\n network,\n asset,\n rejectionReason: reason,\n ...(replayKey !== undefined ? { replayKey } : {}),\n };\n }\n\n // Derive a replay key from the unverified payer and nonce, omitting it if\n // those fields cannot form a key. Rejections carry it so the pipeline can\n // detect an unfinished attempt when a transfer lands or a challenge expires\n // after an uncertain settlement.\n function claimedReplayKey(credential: Credential.Credential): string | undefined {\n const { from, nonce } = (credential.payload ?? {}) as { from?: unknown; nonce?: unknown };\n if (typeof from !== 'string' || typeof nonce !== 'string') return undefined;\n try {\n return computeReplayKey({\n chainId,\n asset,\n from: getAddress(from),\n nonce: nonce as `0x${string}`,\n });\n } catch {\n return undefined;\n }\n }\n\n async function createRequirement(context: PaymentContext): Promise<PaymentRequirement> {\n if (context.currency !== MPP_PROFILE.assetSymbol) {\n throw configInvalid(\n `Resource \"${context.resource.id}\" is priced in ${context.currency}, but MPP charges ${MPP_PROFILE.assetSymbol}`,\n );\n }\n // Strict parse first: mppx converts with viem's parseUnits, which rounds\n // excess precision instead of refusing it\n if (parseCanonicalAmount(context.amount, MPP_PROFILE.assetDecimals) <= 0n) {\n throw new CommerceError('PAYMENT_INVALID', `Amount \"${context.amount}\" must be above zero`, {\n details: { amount: context.amount },\n });\n }\n // Reject a mismatched settlement requirement before the buyer signs\n if (!settlementTermsChecked) {\n await settlementRequirement(context);\n settlementTermsChecked = true;\n }\n const paymentFlow =\n options.resourcePaymentFlows?.[context.resource.id] ??\n options.paymentFlow ??\n MPP_DEFAULT_PAYMENT_FLOW;\n // mppx signs `validBefore` at this expiry. Under `authorization`, the\n // backend must finish before then for settlement to proceed.\n const expires = new Date(clock.now().getTime() + ttlSeconds * 1000);\n const digest = context.metadata?.[CONTENT_DIGEST_METADATA_KEY];\n const challenge = Challenge.fromMethod(Methods.charge, {\n secretKey: options.challengeSecret,\n realm: options.realm,\n expires,\n // Present for an HTTP request with a body. MCP and A2A carry the proof\n // in the body itself, so their challenges bind none.\n ...(typeof digest === 'string' ? { digest } : {}),\n // Bound by the challenge HMAC, so a challenge for one resource cannot pay\n // for another at the same price\n meta: { resource: context.resource.id },\n request: {\n amount: context.amount,\n currency: asset,\n recipient,\n chainId,\n decimals: MPP_PROFILE.assetDecimals,\n credentialTypes: [MPP_PROFILE.credentialType],\n // Required by draft-evm-charge-00 for every credential type\n permit2Address: PERMIT2_ADDRESS,\n },\n });\n return {\n id: ids.next('payreq'),\n requestId: context.requestId,\n resourceId: context.resource.id,\n provider: 'mpp',\n amount: context.amount,\n currency: context.currency,\n destination: recipient,\n network,\n asset,\n expiresAt: expires.toISOString(),\n challenge: {\n provider: 'mpp',\n version: MPP_SPEC_DRAFTS.core,\n accepts: [challenge],\n // Build both carrier forms here because the HTTP route and MCP\n // adapter cannot import mppx: a header value for HTTP and challenge\n // objects for MCP\n envelope: { wwwAuthenticate: Challenge.serialize(challenge), challenges: [challenge] },\n },\n metadata: { [SETTLE_AFTER_BACKEND_METADATA_KEY]: paymentFlow === 'authorization' },\n };\n }\n\n async function verify(context: PaymentVerificationContext): Promise<PaymentResult> {\n const { requirement, resource, submission } = context;\n if (requirement.provider !== 'mpp' || requirement.challenge.provider !== 'mpp') {\n return rejected(requirement, 'wrong_provider');\n }\n const issued = requirement.challenge.accepts[0] as Challenge.Challenge | undefined;\n if (!issued) return rejected(requirement, 'missing_challenge');\n\n let credential: Credential.Credential;\n try {\n credential = decodeCredential(submission.payload);\n } catch {\n return rejected(requirement, 'malformed_credential');\n }\n const echoed = credential.challenge;\n const claimedKey = claimedReplayKey(credential);\n const refused = (reason: string) => rejected(requirement, reason, claimedKey);\n\n // A valid HMAC means this gateway issued the challenge, not that it was\n // issued for this resource and price. The binding checks below close that gap.\n if (!Challenge.verify(echoed, { secretKey: options.challengeSecret })) {\n return refused('challenge_not_issued');\n }\n const binding = bindingMismatch(echoed, issued, resource.id);\n if (binding) return refused(binding);\n if (!echoed.expires || new Date(echoed.expires).getTime() <= clock.now().getTime()) {\n return refused('challenge_expired');\n }\n if ((credential.payload as { type?: unknown } | null)?.type !== MPP_PROFILE.credentialType) {\n return refused('unsupported_credential');\n }\n\n // Local checks only: signature recovery, nonce == challenge hash, the\n // validity window and payload terms. With no network call involved, any\n // failure here is a verdict on the credential, not an outage.\n let payer: `0x${string}`;\n try {\n const validation = await Method.validateCredential([method], credential);\n payer = getAddress((validation.details as { payer: string }).payer);\n } catch (error) {\n return refused(verificationReason(error));\n }\n\n const authorization = credential.payload as Types.AuthorizationPayload;\n // validateCredential proved it equals the 32-byte challenge hash\n const nonce = authorization.nonce as `0x${string}`;\n // Match x402's key so the same authorization collides across both rails\n const replayKey = computeReplayKey({ chainId, asset, from: payer, nonce });\n\n // The facilitator check runs before the pipeline reserves the replay key,\n // so an outage throws the x402 provider's retryable error and uses up\n // nothing, and a refusal is an ordinary rejection\n const x402Verification = await settlement.verify(await toX402Context(context, authorization));\n if (x402Verification.status !== 'verified') {\n // A spent challenge-hash nonce means the challenge was used. Check\n // the token when the facilitator reports only a simulation failure;\n // keep its reason if the token read fails.\n const reason = x402Verification.rejectionReason;\n const spent =\n reason === NONCE_ALREADY_USED ||\n ((await nonceUsed?.(payer, nonce).catch(() => false)) ?? false);\n return rejected(\n requirement,\n spent ? 'challenge_already_used' : (reason ?? 'settlement_rejected'),\n replayKey,\n );\n }\n // A different key would settle an authorization the pipeline did not reserve\n if (x402Verification.replayKey !== replayKey) {\n return rejected(requirement, 'settlement_mismatch', replayKey);\n }\n\n return {\n status: 'verified',\n provider: 'mpp',\n payer,\n payee: recipient,\n amount: requirement.amount,\n currency: requirement.currency,\n network,\n asset,\n replayKey,\n // Share x402's locator builder so both rails identify the same authorization\n metadata: { [RECONCILIATION_METADATA_KEY]: eip3009Locator(network, asset, authorization) },\n };\n }\n\n // The same payment as an x402 requirement and `exact` submission\n async function toX402Context(\n context: PaymentVerificationContext,\n authorization: Types.AuthorizationPayload,\n ): Promise<PaymentVerificationContext> {\n const { requestId, requirement, resource } = context;\n const x402Requirement = await settlementRequirement({\n requestId,\n resource,\n amount: requirement.amount,\n currency: requirement.currency,\n requestedAt: clock.nowIso(),\n });\n return {\n requestId,\n resource,\n requirement: x402Requirement,\n submission: toX402Submission(x402Requirement, authorization),\n };\n }\n\n async function settlementRequirement(context: PaymentContext): Promise<PaymentRequirement> {\n const x402 = await settlement.createRequirement(context);\n const extra = (x402.challenge.accepts[0]?.['extra'] ?? {}) as Record<string, unknown>;\n if (\n x402.network !== network ||\n !sameAddress(x402.asset, asset) ||\n !sameAddress(x402.destination, recipient) ||\n extra['name'] !== options.assetName ||\n extra['version'] !== options.assetVersion\n ) {\n throw configInvalid(\n 'MPP settlement provider must use the same network, asset, EIP-712 domain and recipient',\n );\n }\n return x402;\n }\n\n async function settle(context: PaymentSettlementContext): Promise<PaymentResult> {\n const { requestId, requirement, resource, submission, verification } = context;\n if (verification.status !== 'verified' || verification.replayKey === undefined) {\n throw new CommerceError(\n 'PAYMENT_INVALID',\n 'MPP settle() called without a successful verify()',\n );\n }\n\n // verify() already ran the facilitator check, and the facilitator checks\n // again before broadcasting. A throw may follow a broadcast, so it\n // propagates and the pipeline marks the payment uncertain.\n const credential = decodeCredential(submission.payload);\n const authorization = credential.payload as Types.AuthorizationPayload;\n const settled = await settlement.settle({\n ...(await toX402Context({ requestId, requirement, resource, submission }, authorization)),\n verification: { ...verification, provider: 'x402' },\n });\n const result: PaymentResult = {\n ...settled,\n provider: 'mpp',\n amount: requirement.amount,\n currency: requirement.currency,\n replayKey: verification.replayKey,\n };\n if (settled.status !== 'settled' || settled.externalReference === undefined) return result;\n // Include the EVM method's `challengeId` and `chainId` in the receipt\n // sent through the HTTP `Payment-Receipt` header\n const fields: Receipt.Receipt & { challengeId: string; chainId: number } = {\n method: MPP_PROFILE.method,\n reference: settled.externalReference,\n status: 'success',\n timestamp: settled.settledAt ?? clock.nowIso(),\n challengeId: credential.challenge.id,\n chainId,\n };\n const receipt = Receipt.from(fields);\n return { ...result, metadata: { ...settled.metadata, receipt: Receipt.serialize(receipt) } };\n }\n\n function health(): Promise<AdapterHealth> {\n return settlement.health();\n }\n\n // Reuse the settlement provider's reconciliation for the credential's\n // EIP-3009 authorization\n const reconcile = settlement.reconcile?.bind(settlement);\n return {\n name: 'mpp',\n descriptor: MPP_DESCRIPTOR,\n createRequirement,\n verify,\n settle,\n ...(reconcile !== undefined ? { reconcile } : {}),\n health,\n };\n}\n\nexport type { MppProviderOptions, NonceUsedReader } from './options';\n"]}
1
+ {"version":3,"sources":["../src/support/mpp.json","../src/payments/mpp/descriptor.ts","../src/payments/mpp/credential.ts","../src/payments/mpp/options.ts","../src/payments/mpp/provider.ts"],"names":["isAddress","getAddress"],"mappings":";;;;;;;;;;;;;;;;;AAAA,IAAA,WAAA,GAAA;AAAA,EACE,IAAA,EAAQ,KAAA;AAAA,EACR,IAAA,EAAQ,SAAA;AAAA,EACR,KAAA,EAAS,KAAA;AAAA,EACT,MAAA,EAAU,cA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G,OAAA,CAAQ,QAAA,EAAU,OAAA,EAAS,OAAA,CAAQ,SAAA,CAAU,OAAO,GAAE,EAAE;AAAA,EAC7F;AAEA,EAAA,SAAS,MAAA,GAAiC;AACxC,IAAA,OAAO,WAAW,MAAA,EAAO;AAAA,EAC3B;AAIA,EAAA,MAAM,SAAA,GAAY,UAAA,CAAW,SAAA,EAAW,IAAA,CAAK,UAAU,CAAA;AACvD,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,KAAA;AAAA,IACN,UAAA,EAAY,cAAA;AAAA,IACZ,iBAAA;AAAA,IACA,MAAA;AAAA,IACA,MAAA;AAAA,IACA,GAAI,SAAA,KAAc,MAAA,GAAY,EAAE,SAAA,KAAc,EAAC;AAAA,IAC/C;AAAA,GACF;AACF","file":"mpp.js","sourcesContent":["{\n \"name\": \"mpp\",\n \"kind\": \"payment\",\n \"title\": \"MPP\",\n \"status\": \"experimental\",\n \"role\": \"Payment rail, carried by HTTP, MCP and A2A.\",\n \"subset\": \"`charge`/`evm`/EIP-3009 with USDC on Base Sepolia and Base, over HTTP, MCP and A2A\",\n \"spec\": {\n \"revisions\": [\n \"draft-httpauth-payment-01\",\n \"draft-payment-intent-charge-00\",\n \"draft-evm-charge-00\"\n ],\n \"display\": \"drafts at `tempoxyz/mpp-specs@806fdb8`\",\n \"source\": {\n \"repo\": \"tempoxyz/mpp-specs\",\n \"commit\": \"806fdb8b8c92cda5c84b8660558921b6bbeef7e0\"\n },\n \"stable\": false,\n \"statement\": \"Internet-Drafts are draft documents valid for a maximum of six months and may be updated, replaced, or obsoleted by other documents at any time.\",\n \"checked\": \"2026-11-17\"\n },\n \"packages\": [{ \"name\": \"mppx\", \"use\": \"runtime\" }],\n \"artifacts\": [],\n \"features\": [\n { \"name\": \"intent=charge\", \"status\": \"experimental\" },\n { \"name\": \"method=evm\", \"status\": \"experimental\" },\n { \"name\": \"credential=authorization\", \"status\": \"experimental\" },\n { \"name\": \"eip-3009\", \"status\": \"experimental\" },\n { \"name\": \"network=eip155:31337\", \"status\": \"experimental\" },\n { \"name\": \"network=eip155:84532\", \"status\": \"experimental\" },\n { \"name\": \"network=eip155:8453\", \"status\": \"experimental\" },\n { \"name\": \"asset=USDC\", \"status\": \"experimental\" },\n { \"name\": \"verify-before-settle\", \"status\": \"experimental\" },\n { \"name\": \"authorization-flow\", \"status\": \"experimental\" },\n { \"name\": \"upfront-flow\", \"status\": \"experimental\" },\n { \"name\": \"payment-receipt\", \"status\": \"experimental\" },\n { \"name\": \"challenge-digest-binding\", \"status\": \"experimental\" }\n ],\n \"exclusions\": [\n { \"name\": \"methods other than evm\" },\n {\n \"name\": \"credential=permit2\",\n \"note\": \"The profile accepts only the EIP-3009 authorization credential.\"\n },\n { \"name\": \"credential=transaction\" },\n { \"name\": \"credential=hash\" },\n { \"name\": \"splits\", \"note\": \"The draft allows splits only with `permit2` credentials.\" },\n { \"name\": \"intent=subscription\" },\n { \"name\": \"evm sessions\", \"note\": \"A separate EVM draft, not an option of charge.\" },\n { \"name\": \"discovery extension\" }\n ],\n \"deviations\": [\n {\n \"summary\": \"The EIP-3009 nonce is keccak256 of `JSON.stringify([id, realm])`, as `mppx` 0.13 derives it, not of `abi.encodePacked(id, realm)`; a credential using the draft's nonce fails with `wrong_nonce`.\",\n \"spec\": \"draft-evm-charge-00\",\n \"tests\": [\"tests/unit/payments-mpp/provider.test.ts\"]\n },\n {\n \"summary\": \"Over MCP, payment errors are tool results with `isError` and the challenges in `_meta`, not the JSON-RPC errors the draft maps them to (-32042, -32043, -32602 and -32603).\",\n \"spec\": \"draft-payment-transport-mcp-00\",\n \"tests\": [\"tests/integration/mcp-payment-bindings.test.ts\"]\n },\n {\n \"summary\": \"An unpaid request that gets a 402 also stores a `resource.requested` event beside the challenge.\",\n \"spec\": \"draft-httpauth-payment-01 §11.4\",\n \"tests\": [\"tests/unit/core/execution/pipeline.test.ts\"]\n },\n {\n \"summary\": \"A credential whose attempt is reserved or settlement-uncertain gets 409 without a fresh challenge, because a second challenge could lead to a second payment.\",\n \"spec\": \"draft-httpauth-payment-01 §4.2; draft-evm-charge-00\",\n \"tests\": [\"tests/integration/mpp-carriers.test.ts\"]\n },\n {\n \"summary\": \"With `paymentFlow: authorization`, the backend runs before the transfer, which the charge intent counts as partial access before payment. The default, `upfront`, settles first.\",\n \"spec\": \"draft-payment-intent-charge-00\",\n \"tests\": [\"tests/e2e/payment/mpp-settlement.e2e.test.ts\"]\n }\n ],\n \"combinations\": [\n {\n \"surface\": \"http\",\n \"method\": \"mpp\",\n \"level\": \"e2e\",\n \"evidence\": \"tests/e2e/payment/mpp-settlement.e2e.test.ts\"\n },\n {\n \"surface\": \"http\",\n \"method\": \"mpp\",\n \"authorization\": \"ap2\",\n \"level\": \"e2e\",\n \"evidence\": \"tests/e2e/authorization/ap2-mpp.e2e.test.ts\"\n },\n {\n \"surface\": \"mcp\",\n \"method\": \"mpp\",\n \"level\": \"integration\",\n \"evidence\": \"tests/integration/mcp-payment-bindings.test.ts\"\n },\n {\n \"surface\": \"a2a\",\n \"method\": \"mpp\",\n \"level\": \"integration\",\n \"evidence\": \"tests/integration/mpp-carriers.test.ts\"\n },\n {\n \"surface\": \"http\",\n \"method\": \"mpp\",\n \"level\": \"testnet\",\n \"evidence\": \"tests/testnet/mpp-base-sepolia.smoke.test.ts\"\n },\n {\n \"surface\": \"http\",\n \"method\": \"mpp\",\n \"level\": \"mainnet\",\n \"evidence\": \"tests/mainnet/mpp-base.smoke.test.ts\"\n }\n ],\n \"gaps\": [\n {\n \"requirement\": \"Each challenge id is single-use (charge intent); two payers can each settle against one challenge\",\n \"state\": \"open\"\n },\n {\n \"requirement\": \"Payment-Receipt only after an on-chain receipt with a matching Transfer log; the gateway trusts the facilitator's settle result\",\n \"state\": \"open\"\n }\n ],\n \"docs\": [\"docs/protocols/mpp.md\"]\n}\n","/**\n * Describes the MPP profile and its unsupported variants.\n *\n * The descriptor identifies the intent, method, extensions and unsupported\n * variants needed to assess compatibility. Status and unsupported variants\n * come from `src/support/mpp.json`.\n *\n * Importing the descriptor does not load `mppx`.\n */\nimport type { AdapterDescriptor } from '../../core/public-types';\nimport { descriptorStatus, exclusionNames } from '../../support/claims';\nimport record from '../../support/mpp.json' with { type: 'json' };\nimport { PACKAGE_VERSION } from '../../version';\nimport { MPP_NETWORKS, MPP_PROFILE, MPP_SUPPORTED_SPEC } from './constants';\n\nexport const MPP_DESCRIPTOR: AdapterDescriptor = {\n name: 'mpp',\n kind: 'payment',\n implementationVersion: PACKAGE_VERSION,\n supportedSpec: MPP_SUPPORTED_SPEC,\n capabilities: [\n `intent=${MPP_PROFILE.intent}`,\n `method=${MPP_PROFILE.method}`,\n `credential=${MPP_PROFILE.credentialType}`,\n 'eip-3009',\n ...MPP_NETWORKS.map((network) => `network=${network}`),\n `asset=${MPP_PROFILE.assetSymbol}`,\n 'verify-before-settle',\n 'authorization-flow',\n 'upfront-flow',\n 'payment-receipt',\n // HTTP request bodies only; MCP and A2A carry the proof in the body\n 'challenge-digest-binding',\n ],\n status: descriptorStatus(record),\n unsupported: exclusionNames(record),\n};\n","// Reading an MPP credential: its decoding, its binding to the challenge, and the x402 proof it carries\nimport { type Challenge, Credential, Errors, PaymentRequest } from 'mppx';\nimport type { Types } from 'mppx/evm';\nimport { getAddress, isAddress } from 'viem';\nimport type { PaymentRequirement, PaymentSubmission } from '../../core';\n\n// mppx reports a verification failure only as message text. The pinned\n// release's wording maps to stable reasons, and the tests cover every entry;\n// unmapped text becomes `authorization_invalid`.\nconst VERIFICATION_REASONS: readonly (readonly [string, string])[] = [\n ['EVM authorization challenge hash mismatch', 'wrong_nonce'],\n ['EVM authorization signature mismatch', 'invalid_signature'],\n ['EVM authorization is not valid yet', 'authorization_not_yet_valid'],\n ['EVM authorization has expired', 'authorization_expired'],\n ['EVM authorization source mismatch', 'source_mismatch'],\n ['EVM authorization amount mismatch', 'wrong_amount'],\n ['EVM authorization recipient mismatch', 'wrong_recipient'],\n];\n\nexport function verificationReason(error: unknown): string {\n if (error instanceof Errors.PaymentExpiredError) return 'challenge_expired';\n if (error instanceof Errors.InvalidPayloadError) return 'invalid_payload';\n if (error instanceof Errors.InvalidChallengeError) return 'invalid_challenge';\n if (error instanceof Errors.VerificationFailedError) {\n const match = VERIFICATION_REASONS.find(([text]) => error.message.includes(text));\n if (match) return match[1];\n }\n return 'authorization_invalid';\n}\n\n// Accept the HTTP `Authorization: Payment ...` value or a JSON credential\n// from MCP `_meta`. Serialize the object for mppx deserialization\nexport function decodeCredential(payload: string): Credential.Credential {\n const serialized = payload.trimStart().startsWith('{')\n ? Credential.serialize(JSON.parse(payload) as Credential.Credential)\n : payload;\n return Credential.deserialize(serialized);\n}\n\n// Compares the echoed challenge with the one issued for this request. Both\n// carry a valid HMAC by now, so any difference means the credential answers a\n// challenge issued for other terms. The final comparison catches a difference\n// in any request field the named checks do not cover.\nexport function bindingMismatch(\n echoed: Challenge.Challenge,\n issued: Challenge.Challenge,\n resourceId: string,\n): string | undefined {\n if (echoed.realm !== issued.realm) return 'wrong_realm';\n if (echoed.method !== issued.method || echoed.intent !== issued.intent) {\n return 'unsupported_method';\n }\n // Only the encoded `opaque` survives the credential round trip, not `meta`,\n // so compare it with the encoding of this resource's binding\n if (echoed.opaque !== PaymentRequest.serialize({ resource: resourceId })) {\n return 'wrong_resource';\n }\n // `issued` was built for the request carrying this credential, so a\n // different body, or none, fails here. A challenge without a digest binds\n // no body, as the core draft reads it.\n if (echoed.digest !== undefined && echoed.digest !== issued.digest) {\n return 'body_digest_mismatch';\n }\n const got = echoed.request as ChargeRequest;\n const want = issued.request as ChargeRequest;\n if (got.amount !== want.amount) return 'wrong_amount';\n if (!sameAddress(got.recipient, want.recipient)) return 'wrong_recipient';\n if (got.methodDetails?.chainId !== want.methodDetails?.chainId) return 'wrong_network';\n if (!sameAddress(got.currency, want.currency)) return 'wrong_asset';\n if (canonical(got.methodDetails) !== canonical(want.methodDetails)) {\n return 'unsupported_credential';\n }\n if (canonical(got) !== canonical(want)) return 'wrong_terms';\n return undefined;\n}\n\n// Rewrap the MPP authorization as the x402 `exact` payload expected by settlement\nexport function toX402Submission(\n x402Requirement: PaymentRequirement,\n authorization: Types.AuthorizationPayload,\n): PaymentSubmission {\n const { signature, from, to, value, validAfter, validBefore, nonce } = authorization;\n const payment = {\n x402Version: 2,\n accepted: x402Requirement.challenge.accepts[0],\n payload: { signature, authorization: { from, to, value, validAfter, validBefore, nonce } },\n };\n return { method: 'x402', payload: Buffer.from(JSON.stringify(payment)).toString('base64') };\n}\n\ninterface ChargeRequest {\n readonly amount?: string;\n readonly currency?: string;\n readonly recipient?: string;\n readonly methodDetails?: { readonly chainId?: number };\n}\n\n// The encoding mppx binds into the challenge HMAC, so key order cannot\n// produce a false mismatch\nfunction canonical(value: object | undefined): string {\n return value === undefined ? '' : PaymentRequest.serialize(value as PaymentRequest.Request);\n}\n\nexport function sameAddress(a: string | undefined, b: string | undefined): boolean {\n return a !== undefined && b !== undefined && isAddress(a) && isAddress(b)\n ? getAddress(a) === getAddress(b)\n : false;\n}\n","// The MPP provider's options, checked once at construction\nimport { isAddress } from 'viem';\nimport { type Clock, CommerceError, type IdGenerator, type Logger } from '../../core';\nimport type { X402FacilitatorConfig } from '../x402/guardrails';\nimport type { X402PaymentFlow } from '../x402/payment-flow';\nimport { isMppNetwork, MPP_MIN_CHALLENGE_SECRET_LENGTH, MPP_NETWORKS } from './constants';\n\n/** Whether the token contract has recorded `nonce` as used by `payer` */\nexport type NonceUsedReader = (payer: `0x${string}`, nonce: `0x${string}`) => Promise<boolean>;\n\nexport interface MppProviderOptions {\n /** Merchant-controlled settlement destination. Never gateway-owned */\n readonly recipient: `0x${string}`;\n /** EIP-3009 token the charge is paid in */\n readonly asset: `0x${string}`;\n /** EIP-712 domain name of the asset, e.g. 'USDC' or 'MockUSDC' */\n readonly assetName: string;\n /** EIP-712 domain version of the asset, e.g. '2' */\n readonly assetVersion: string;\n /** Value of each challenge's `realm`, such as the gateway's host */\n readonly realm: string;\n /** Key that binds each challenge to this gateway. Never logged or published */\n readonly challengeSecret: string;\n /** RPC endpoint of the settlement chain */\n readonly rpcUrl: string;\n /** The x402 facilitator that verifies and broadcasts the authorization */\n readonly facilitator: X402FacilitatorConfig;\n /** Must be `true` before anything settles on a mainnet. Never a default */\n readonly allowMainnet?: boolean;\n /** Required on mainnet when facilitator auth is `none` */\n readonly allowUnauthenticatedFacilitator?: boolean;\n readonly logger?: Logger;\n /**\n * Seconds a challenge stays valid, 300 by default. The mppx client signs its\n * authorization to expire at the same moment.\n */\n readonly challengeTtlSeconds?: number;\n /**\n * CAIP-2 network: `eip155:31337` (local Anvil), `eip155:84532` (Base\n * Sepolia, the default) or `eip155:8453` (Base)\n */\n readonly network?: string;\n /**\n * Same flow values as x402. The default, `upfront`, settles before the\n * backend; `authorization` settles after it\n */\n readonly paymentFlow?: X402PaymentFlow;\n /** Per-resource overrides of `paymentFlow`, keyed by resource id */\n readonly resourcePaymentFlows?: Readonly<Record<string, X402PaymentFlow>>;\n readonly clock?: Clock;\n readonly ids?: IdGenerator;\n}\n\nexport function configInvalid(message: string): CommerceError {\n return new CommerceError('CONFIG_INVALID', message);\n}\n\nexport type MppChallengeOptions = Omit<\n MppProviderOptions,\n 'rpcUrl' | 'facilitator' | 'allowMainnet' | 'allowUnauthenticatedFacilitator' | 'logger'\n>;\n\nexport function validateOptions(options: MppChallengeOptions): void {\n if (!isAddress(options.recipient)) throw configInvalid('MPP recipient is not an EVM address');\n if (!isAddress(options.asset)) throw configInvalid('MPP asset is not an EVM address');\n if (options.assetName.length === 0 || options.assetVersion.length === 0) {\n throw configInvalid('MPP asset needs its EIP-712 domain name and version');\n }\n // mppx refuses CR or LF in the quoted realm parameter, so checking here fails\n // at construction instead of on every challenge\n if (options.realm.length === 0 || /[\\r\\n]/.test(options.realm)) {\n throw configInvalid('MPP realm must be a non-empty single-line string');\n }\n if (options.challengeSecret.length < MPP_MIN_CHALLENGE_SECRET_LENGTH) {\n throw configInvalid(\n `MPP challenge secret must have length at least ${MPP_MIN_CHALLENGE_SECRET_LENGTH}`,\n );\n }\n const ttl = options.challengeTtlSeconds;\n if (ttl !== undefined && (!Number.isInteger(ttl) || ttl <= 0)) {\n throw configInvalid('MPP challenge TTL must be a positive whole number of seconds');\n }\n if (options.network !== undefined && !isMppNetwork(options.network)) {\n throw configInvalid(`MPP network must be one of ${MPP_NETWORKS.join(', ')}`);\n }\n}\n","/**\n * MPP payment provider for the `charge` intent, the `evm` method and the\n * EIP-3009 `authorization` credential.\n *\n * It issues challenges and verifies credentials without moving funds: local\n * checks first, then a read-only check by an x402 facilitator. Settlement hands\n * the same signed authorization to that facilitator through an internal x402\n * provider built from these options. The MPP layer adds no signing key.\n *\n * Under the default `upfront` flow settlement precedes the backend call; under\n * `authorization` it follows a successful one. The drafts require a confirmed\n * transaction before a `Payment-Receipt`.\n */\nimport { PERMIT2_ADDRESS } from '@x402/evm';\nimport { Challenge, type Credential, Method, Receipt } from 'mppx';\nimport { Methods, type Types } from 'mppx/evm';\nimport { charge } from 'mppx/evm/server';\nimport { createPublicClient, getAddress, http, parseAbi } from 'viem';\nimport {\n type AdapterHealth,\n CommerceError,\n type PaymentContext,\n type PaymentProvider,\n type PaymentRequirement,\n type PaymentResult,\n type PaymentSettlementContext,\n type PaymentVerificationContext,\n RECONCILIATION_METADATA_KEY,\n systemClock,\n} from '../../core';\nimport { SETTLE_AFTER_BACKEND_METADATA_KEY } from '../../core/execution/settlement-order';\nimport { parseCanonicalAmount } from '../x402/amount';\nimport { eip3009Locator } from '../x402/locator';\nimport { createX402PaymentProvider, DEFAULT_IDS } from '../x402/provider';\nimport { computeReplayKey } from '../x402/replay-key';\nimport {\n MPP_DEFAULT_NETWORK,\n MPP_DEFAULT_PAYMENT_FLOW,\n MPP_PROFILE,\n MPP_SPEC_DRAFTS,\n} from './constants';\nimport {\n bindingMismatch,\n decodeCredential,\n sameAddress,\n toX402Submission,\n verificationReason,\n} from './credential';\nimport { MPP_DESCRIPTOR } from './descriptor';\nimport {\n configInvalid,\n type MppChallengeOptions,\n type MppProviderOptions,\n type NonceUsedReader,\n validateOptions,\n} from './options';\nimport { CONTENT_DIGEST_METADATA_KEY } from './transport';\n\nconst DEFAULT_CHALLENGE_TTL_SECONDS = 300;\n\n// The x402 SDK's verify reason for an EIP-3009 nonce already spent on chain\nconst NONCE_ALREADY_USED = 'invalid_exact_evm_nonce_already_used';\n\nconst AUTHORIZATION_STATE_ABI = parseAbi([\n 'function authorizationState(address authorizer, bytes32 nonce) view returns (bool)',\n]);\n\nconst NONCE_READ_TIMEOUT_MS = 5_000;\n\nexport function createMppPaymentProvider(options: MppProviderOptions): PaymentProvider {\n const { rpcUrl, facilitator, allowMainnet, allowUnauthenticatedFacilitator, logger, ...rest } =\n options;\n // Checked first so a bad MPP option is reported as one, not as an x402 error\n validateOptions(rest);\n // Built from the same terms, and never registered as a rail, so an MPP-only\n // deployment needs no x402 configuration\n const settlement = createX402PaymentProvider({\n network: options.network ?? MPP_DEFAULT_NETWORK,\n rpcUrl,\n asset: options.asset,\n assetName: options.assetName,\n assetVersion: options.assetVersion,\n assetDecimals: MPP_PROFILE.assetDecimals,\n payTo: options.recipient,\n facilitator,\n ...(allowMainnet !== undefined ? { allowMainnet } : {}),\n ...(allowUnauthenticatedFacilitator !== undefined ? { allowUnauthenticatedFacilitator } : {}),\n ...(logger !== undefined ? { logger } : {}),\n ...(options.clock !== undefined ? { clock: options.clock } : {}),\n });\n // One attempt: the read only names the reason for a refusal already decided\n const chain = createPublicClient({\n transport: http(rpcUrl, { timeout: NONCE_READ_TIMEOUT_MS, retryCount: 0 }),\n });\n const nonceUsed: NonceUsedReader = (payer, nonce) =>\n chain.readContract({\n address: options.asset,\n abi: AUTHORIZATION_STATE_ABI,\n functionName: 'authorizationState',\n args: [payer, nonce],\n });\n return createMppProviderWithSettlement(rest, settlement, nonceUsed);\n}\n\n/**\n * Internal seam: tests inject a settlement provider and the nonce reader. Not\n * exported from the `./mpp` entry.\n */\nexport function createMppProviderWithSettlement(\n options: MppChallengeOptions,\n settlement: PaymentProvider,\n nonceUsed?: NonceUsedReader,\n): PaymentProvider {\n validateOptions(options);\n if (settlement.name !== 'x402') {\n throw configInvalid('MPP settlement must be an x402 payment provider');\n }\n const network = options.network ?? MPP_DEFAULT_NETWORK;\n const chainId = Number(network.split(':')[1]);\n const clock = options.clock ?? systemClock;\n const ttlSeconds = options.challengeTtlSeconds ?? DEFAULT_CHALLENGE_TTL_SECONDS;\n const recipient = getAddress(options.recipient);\n const asset = getAddress(options.asset);\n const ids = options.ids ?? DEFAULT_IDS;\n // The settlement provider's terms are fixed at construction, so one passing\n // check covers every later challenge\n let settlementTermsChecked = false;\n\n // charge() requires a callback even though this provider never invokes the\n // mppx broadcast path. Settlement is delegated to the x402 provider.\n const method = charge({\n currency: asset,\n recipient,\n chainId,\n decimals: MPP_PROFILE.assetDecimals,\n authorization: { name: options.assetName, version: options.assetVersion },\n settle: async () => {\n throw new CommerceError('INTERNAL_ERROR', 'MPP direct broadcast is disabled');\n },\n });\n\n function rejected(\n requirement: PaymentRequirement,\n reason: string,\n replayKey?: string,\n ): PaymentResult {\n return {\n status: 'rejected',\n provider: 'mpp',\n amount: requirement.amount,\n currency: requirement.currency,\n network,\n asset,\n rejectionReason: reason,\n ...(replayKey !== undefined ? { replayKey } : {}),\n };\n }\n\n // Derive a replay key from the unverified payer and nonce, omitting it if\n // those fields cannot form a key. Rejections carry it so the pipeline can\n // detect an unfinished attempt when a transfer lands or a challenge expires\n // after an uncertain settlement.\n function claimedReplayKey(credential: Credential.Credential): string | undefined {\n const { from, nonce } = (credential.payload ?? {}) as { from?: unknown; nonce?: unknown };\n if (typeof from !== 'string' || typeof nonce !== 'string') return undefined;\n try {\n return computeReplayKey({\n chainId,\n asset,\n from: getAddress(from),\n nonce: nonce as `0x${string}`,\n });\n } catch {\n return undefined;\n }\n }\n\n async function createRequirement(context: PaymentContext): Promise<PaymentRequirement> {\n if (context.currency !== MPP_PROFILE.assetSymbol) {\n throw configInvalid(\n `Resource \"${context.resource.id}\" is priced in ${context.currency}, but MPP charges ${MPP_PROFILE.assetSymbol}`,\n );\n }\n // Strict parse first: mppx converts with viem's parseUnits, which rounds\n // excess precision instead of refusing it\n if (parseCanonicalAmount(context.amount, MPP_PROFILE.assetDecimals) <= 0n) {\n throw new CommerceError('PAYMENT_INVALID', `Amount \"${context.amount}\" must be above zero`, {\n details: { amount: context.amount },\n });\n }\n // Reject a mismatched settlement requirement before the buyer signs\n if (!settlementTermsChecked) {\n await settlementRequirement(context);\n settlementTermsChecked = true;\n }\n const paymentFlow =\n options.resourcePaymentFlows?.[context.resource.id] ??\n options.paymentFlow ??\n MPP_DEFAULT_PAYMENT_FLOW;\n // mppx signs `validBefore` at this expiry. Under `authorization`, the\n // backend must finish before then for settlement to proceed.\n const expires = new Date(clock.now().getTime() + ttlSeconds * 1000);\n const digest = context.metadata?.[CONTENT_DIGEST_METADATA_KEY];\n const challenge = Challenge.fromMethod(Methods.charge, {\n secretKey: options.challengeSecret,\n realm: options.realm,\n expires,\n // Present for an HTTP request with a body. MCP and A2A carry the proof\n // in the body itself, so their challenges bind none.\n ...(typeof digest === 'string' ? { digest } : {}),\n // Bound by the challenge HMAC, so a challenge for one resource cannot pay\n // for another at the same price\n meta: { resource: context.resource.id },\n request: {\n amount: context.amount,\n currency: asset,\n recipient,\n chainId,\n decimals: MPP_PROFILE.assetDecimals,\n credentialTypes: [MPP_PROFILE.credentialType],\n // Required by draft-evm-charge-00 for every credential type\n permit2Address: PERMIT2_ADDRESS,\n },\n });\n return {\n id: ids.next('payreq'),\n requestId: context.requestId,\n resourceId: context.resource.id,\n provider: 'mpp',\n amount: context.amount,\n currency: context.currency,\n destination: recipient,\n network,\n asset,\n expiresAt: expires.toISOString(),\n challenge: {\n provider: 'mpp',\n version: MPP_SPEC_DRAFTS.core,\n accepts: [challenge],\n // Build both carrier forms here because the HTTP route and MCP\n // adapter cannot import mppx: a header value for HTTP and challenge\n // objects for MCP\n envelope: { wwwAuthenticate: Challenge.serialize(challenge), challenges: [challenge] },\n },\n metadata: { [SETTLE_AFTER_BACKEND_METADATA_KEY]: paymentFlow === 'authorization' },\n };\n }\n\n async function verify(context: PaymentVerificationContext): Promise<PaymentResult> {\n const { requirement, resource, submission } = context;\n if (requirement.provider !== 'mpp' || requirement.challenge.provider !== 'mpp') {\n return rejected(requirement, 'wrong_provider');\n }\n const issued = requirement.challenge.accepts[0] as Challenge.Challenge | undefined;\n if (!issued) return rejected(requirement, 'missing_challenge');\n\n let credential: Credential.Credential;\n try {\n credential = decodeCredential(submission.payload);\n } catch {\n return rejected(requirement, 'malformed_credential');\n }\n const echoed = credential.challenge;\n const claimedKey = claimedReplayKey(credential);\n const refused = (reason: string) => rejected(requirement, reason, claimedKey);\n\n // A valid HMAC means this gateway issued the challenge, not that it was\n // issued for this resource and price. The binding checks below close that gap.\n if (!Challenge.verify(echoed, { secretKey: options.challengeSecret })) {\n return refused('challenge_not_issued');\n }\n const binding = bindingMismatch(echoed, issued, resource.id);\n if (binding) return refused(binding);\n if (!echoed.expires || new Date(echoed.expires).getTime() <= clock.now().getTime()) {\n return refused('challenge_expired');\n }\n if ((credential.payload as { type?: unknown } | null)?.type !== MPP_PROFILE.credentialType) {\n return refused('unsupported_credential');\n }\n\n // Local checks only: signature recovery, nonce == challenge hash, the\n // validity window and payload terms. With no network call involved, any\n // failure here is a verdict on the credential, not an outage.\n let payer: `0x${string}`;\n try {\n const validation = await Method.validateCredential([method], credential);\n payer = getAddress((validation.details as { payer: string }).payer);\n } catch (error) {\n return refused(verificationReason(error));\n }\n\n const authorization = credential.payload as Types.AuthorizationPayload;\n // validateCredential proved it equals the 32-byte challenge hash\n const nonce = authorization.nonce as `0x${string}`;\n // Match x402's key so the same authorization collides across both rails\n const replayKey = computeReplayKey({ chainId, asset, from: payer, nonce });\n\n // The facilitator check runs before the pipeline reserves the replay key,\n // so an outage throws the x402 provider's retryable error and uses up\n // nothing, and a refusal is an ordinary rejection\n const x402Verification = await settlement.verify(await toX402Context(context, authorization));\n if (x402Verification.status !== 'verified') {\n // A spent challenge-hash nonce means the challenge was used. Check\n // the token when the facilitator reports only a simulation failure;\n // keep its reason if the token read fails.\n const reason = x402Verification.rejectionReason;\n const spent =\n reason === NONCE_ALREADY_USED ||\n ((await nonceUsed?.(payer, nonce).catch(() => false)) ?? false);\n return rejected(\n requirement,\n spent ? 'challenge_already_used' : (reason ?? 'settlement_rejected'),\n replayKey,\n );\n }\n // A different key would settle an authorization the pipeline did not reserve\n if (x402Verification.replayKey !== replayKey) {\n return rejected(requirement, 'settlement_mismatch', replayKey);\n }\n\n return {\n status: 'verified',\n provider: 'mpp',\n payer,\n payee: recipient,\n amount: requirement.amount,\n currency: requirement.currency,\n network,\n asset,\n replayKey,\n // Share x402's locator builder so both rails identify the same authorization\n metadata: { [RECONCILIATION_METADATA_KEY]: eip3009Locator(network, asset, authorization) },\n };\n }\n\n // The same payment as an x402 requirement and `exact` submission\n async function toX402Context(\n context: PaymentVerificationContext,\n authorization: Types.AuthorizationPayload,\n ): Promise<PaymentVerificationContext> {\n const { requestId, requirement, resource } = context;\n const x402Requirement = await settlementRequirement({\n requestId,\n resource,\n amount: requirement.amount,\n currency: requirement.currency,\n requestedAt: clock.nowIso(),\n });\n return {\n requestId,\n resource,\n requirement: x402Requirement,\n submission: toX402Submission(x402Requirement, authorization),\n };\n }\n\n async function settlementRequirement(context: PaymentContext): Promise<PaymentRequirement> {\n const x402 = await settlement.createRequirement(context);\n const extra = (x402.challenge.accepts[0]?.['extra'] ?? {}) as Record<string, unknown>;\n if (\n x402.network !== network ||\n !sameAddress(x402.asset, asset) ||\n !sameAddress(x402.destination, recipient) ||\n extra['name'] !== options.assetName ||\n extra['version'] !== options.assetVersion\n ) {\n throw configInvalid(\n 'MPP settlement provider must use the same network, asset, EIP-712 domain and recipient',\n );\n }\n return x402;\n }\n\n async function settle(context: PaymentSettlementContext): Promise<PaymentResult> {\n const { requestId, requirement, resource, submission, verification } = context;\n if (verification.status !== 'verified' || verification.replayKey === undefined) {\n throw new CommerceError(\n 'PAYMENT_INVALID',\n 'MPP settle() called without a successful verify()',\n );\n }\n\n // verify() already ran the facilitator check, and the facilitator checks\n // again before broadcasting. A throw may follow a broadcast, so it\n // propagates and the pipeline marks the payment uncertain.\n const credential = decodeCredential(submission.payload);\n const authorization = credential.payload as Types.AuthorizationPayload;\n const settled = await settlement.settle({\n ...(await toX402Context({ requestId, requirement, resource, submission }, authorization)),\n verification: { ...verification, provider: 'x402' },\n });\n const result: PaymentResult = {\n ...settled,\n provider: 'mpp',\n amount: requirement.amount,\n currency: requirement.currency,\n replayKey: verification.replayKey,\n };\n if (settled.status !== 'settled' || settled.externalReference === undefined) return result;\n // Include the EVM method's `challengeId` and `chainId` in the receipt\n // sent through the HTTP `Payment-Receipt` header\n const fields: Receipt.Receipt & { challengeId: string; chainId: number } = {\n method: MPP_PROFILE.method,\n reference: settled.externalReference,\n status: 'success',\n timestamp: settled.settledAt ?? clock.nowIso(),\n challengeId: credential.challenge.id,\n chainId,\n };\n const receipt = Receipt.from(fields);\n return { ...result, metadata: { ...settled.metadata, receipt: Receipt.serialize(receipt) } };\n }\n\n function health(): Promise<AdapterHealth> {\n return settlement.health();\n }\n\n // Reuse the settlement provider's reconciliation for the credential's\n // EIP-3009 authorization\n const reconcile = settlement.reconcile?.bind(settlement);\n return {\n name: 'mpp',\n descriptor: MPP_DESCRIPTOR,\n createRequirement,\n verify,\n settle,\n ...(reconcile !== undefined ? { reconcile } : {}),\n health,\n };\n}\n\nexport type { MppProviderOptions, NonceUsedReader } from './options';\n"]}
@@ -1,6 +1,6 @@
1
1
  import { IncomingMessage, ServerResponse } from 'node:http';
2
- import { K as ProtocolName, c as PaymentSubmission, d as AuthorizationSubmission, I as IsoTimestamp, E as PaymentResult, p as CommerceReceipt, z as PaymentRequirement, a as AuthorizationRequirement, g as AdapterDescriptor, R as ResourceRegistry, C as Clock, f as IdGenerator, h as AdapterHealth } from './runtime-BmaSp2Ce.js';
3
- import { P as PersistenceFailure, E as EventSink } from './transaction-BXXJltZ-.js';
2
+ import { K as ProtocolName, c as PaymentSubmission, d as AuthorizationSubmission, I as IsoTimestamp, E as PaymentResult, p as CommerceReceipt, z as PaymentRequirement, a as AuthorizationRequirement, g as AdapterDescriptor, R as ResourceRegistry, C as Clock, f as IdGenerator, h as AdapterHealth } from './runtime-D8u6lYfx.js';
3
+ import { P as PersistenceFailure, E as EventSink } from './transaction-F9ZvhokH.js';
4
4
  import { L as Logger } from './logger-CllGwQ8i.js';
5
5
 
6
6
  /**
@@ -52,6 +52,11 @@ interface AdapterHealth {
52
52
  interface AdapterHealthComponent {
53
53
  readonly name: string;
54
54
  readonly status: 'pass' | 'warn' | 'fail';
55
+ /**
56
+ * Marks a probe that received no response; `status` does not describe the
57
+ * target's health in this case. Experimental: may change in a minor release.
58
+ */
59
+ readonly undetermined?: 'unreachable';
55
60
  }
56
61
  /** Describes an adapter's supported surface for diagnostics */
57
62
  interface AdapterDescriptor {
@@ -345,6 +350,11 @@ interface PaymentContext {
345
350
  * challenge to the input but must not send it to a third party.
346
351
  */
347
352
  readonly input?: unknown;
353
+ /**
354
+ * The request's protocol, set by the pipeline on each createRequirement call.
355
+ * Experimental: may change in a minor release.
356
+ */
357
+ readonly protocol?: ProtocolName;
348
358
  readonly metadata?: Readonly<Record<string, unknown>>;
349
359
  }
350
360
  /** Input to {@link PaymentProvider.verify} */
@@ -1,5 +1,5 @@
1
- import { k as AuthorizationMethodName, I as IsoTimestamp, K as ProtocolName, l as AuthorizationRecord, t as PaymentAttempt, p as CommerceReceipt, u as PaymentAttemptResolution, g as AdapterDescriptor, h as AdapterHealth } from './runtime-BmaSp2Ce.js';
2
- import { A as AuthorizationHoldState, a as CommerceEvent, P as PersistenceFailure, c as Transaction, e as TransactionState } from './transaction-BXXJltZ-.js';
1
+ import { k as AuthorizationMethodName, I as IsoTimestamp, K as ProtocolName, l as AuthorizationRecord, t as PaymentAttempt, p as CommerceReceipt, u as PaymentAttemptResolution, g as AdapterDescriptor, h as AdapterHealth } from './runtime-D8u6lYfx.js';
2
+ import { A as AuthorizationHoldState, a as CommerceEvent, P as PersistenceFailure, c as Transaction, e as TransactionState } from './transaction-F9ZvhokH.js';
3
3
 
4
4
  /**
5
5
  * Protocol-neutral records for the receipt store's optional methods:
package/dist/testing.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Clock } from './index.js';
2
2
  import { ReceiptStore } from './index.js';
3
- import './transaction-BXXJltZ-.js';
3
+ import './transaction-F9ZvhokH.js';
4
4
 
5
5
  /**
6
6
  * Receipt store conformance cases for use with any test runner. Each case has
package/dist/testing.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { PAYMENT_KEY_ENDPOINT_PREFIX } from './chunk-IWXVQYG5.js';
2
2
  import { STORE_METHOD_GROUPS } from './chunk-WDD2ZUR3.js';
3
- import { transactionState } from './chunk-YHNTTMED.js';
3
+ import { transactionState } from './chunk-MDOGXTZD.js';
4
4
  import './chunk-2CJNA7MS.js';
5
5
  import assert2 from 'assert/strict';
6
6
 
@@ -1,4 +1,4 @@
1
- import { I as IsoTimestamp, K as ProtocolName, P as PaymentMethodName, t as PaymentAttempt, D as DecimalAmount, l as AuthorizationRecord } from './runtime-BmaSp2Ce.js';
1
+ import { I as IsoTimestamp, K as ProtocolName, P as PaymentMethodName, t as PaymentAttempt, D as DecimalAmount, l as AuthorizationRecord } from './runtime-D8u6lYfx.js';
2
2
 
3
3
  /**
4
4
  * Canonical commerce events. FROZEN CONTRACT. Every event in one flow shares
@@ -0,0 +1,167 @@
1
+ import { C as Clock, f as IdGenerator, e as PaymentProvider } from './runtime-D8u6lYfx.js';
2
+ import { L as Logger } from './logger-CllGwQ8i.js';
3
+ import { X as X402PaymentFlow, a as X402FacilitatorConfig } from './guardrails-CeyLS1ou.js';
4
+
5
+ type NetworkKind = 'testnet' | 'mainnet';
6
+ /** An EVM network the x402 provider can settle on */
7
+ interface NetworkProfile {
8
+ /** CAIP-2 identifier, e.g. `eip155:84532` */
9
+ readonly id: string;
10
+ /** Signed into the buyer's EIP-712 domain */
11
+ readonly chainId: number;
12
+ readonly displayName: string;
13
+ readonly kind: NetworkKind;
14
+ /** The local Anvil dev chain, where the in-process facilitator runs */
15
+ readonly local?: boolean;
16
+ /**
17
+ * Default USDC deployment and EIP-712 domain. EVM offers may name another
18
+ * token; the local chain has no default and requires explicit token metadata.
19
+ *
20
+ * `name` is the signed EIP-712 domain name, not the symbol, and deployments
21
+ * differ: `"USDC"` on Base Sepolia, `"USD Coin"` on Base.
22
+ */
23
+ readonly canonicalAsset?: {
24
+ readonly symbol: string;
25
+ readonly address: string;
26
+ readonly name: string;
27
+ readonly version: string;
28
+ readonly decimals: number;
29
+ };
30
+ }
31
+ /** A merchant-declared EVM network, from `payments.x402.networks` */
32
+ interface CustomNetworkDeclaration {
33
+ readonly kind: NetworkKind;
34
+ readonly displayName: string;
35
+ }
36
+ type CustomNetworks = Readonly<Record<string, CustomNetworkDeclaration>>;
37
+ /** The built-in EVM networks the x402 provider settles on without a declaration */
38
+ declare const SUPPORTED_NETWORK_IDS: readonly string[];
39
+ /** What a deployment is: the local dev chain, or a public testnet or mainnet */
40
+ type DeploymentMode = 'local' | 'testnet' | 'mainnet';
41
+
42
+ /** EIP-3009 `transferWithAuthorization`, or Permit2 with a prior token allowance */
43
+ type X402AssetTransferMethod = 'eip3009' | 'permit2';
44
+
45
+ /** Experimental. One surface's `extensions.bazaar` value */
46
+ interface BazaarExtension {
47
+ readonly info: Readonly<Record<string, unknown>>;
48
+ readonly schema: Readonly<Record<string, unknown>>;
49
+ }
50
+ /** Supported Bazaar metadata surfaces */
51
+ type BazaarSurface = 'http' | 'mcp';
52
+
53
+ /** A single offer and the settings every offer shares */
54
+ interface X402ProviderOptions extends X402OfferOptions {
55
+ readonly maxTimeoutSeconds?: number;
56
+ /**
57
+ * When the payment settles relative to the backend call. Defaults to
58
+ * `authorization`, the x402 default: settle only after the backend succeeds.
59
+ * `upfront` settles before the backend call.
60
+ */
61
+ readonly paymentFlow?: X402PaymentFlow;
62
+ /** Per-resource overrides of `paymentFlow`, keyed by resource id */
63
+ readonly resourcePaymentFlows?: Readonly<Record<string, X402PaymentFlow>>;
64
+ /**
65
+ * The media type each resource's challenge declares as `resource.mimeType`,
66
+ * keyed by resource id. Defaults to `application/json`.
67
+ */
68
+ readonly resourceMimeTypes?: Readonly<Record<string, string>>;
69
+ /**
70
+ * Experimental. Maps resource ids and HTTP/MCP surfaces to the challenge's
71
+ * `extensions.bazaar` value. Omitted when the encoded HTTP challenge's
72
+ * `PAYMENT-REQUIRED` value plus its proof reserve exceeds 8 KiB.
73
+ * Verify and settle send it and the challenge's `resource` to a remote
74
+ * facilitator that lists `bazaar` in `/supported`.
75
+ */
76
+ readonly resourceBazaar?: Readonly<Record<string, Readonly<Partial<Record<BazaarSurface, BazaarExtension>>>>>;
77
+ /**
78
+ * Experimental. Maps resource ids and request surfaces to the public
79
+ * `resource.url` used in their challenges. Requests without a surface,
80
+ * ACP requests and missing entries use `resource://agent-commerce/...`.
81
+ */
82
+ readonly resourceUrls?: Readonly<Record<string, Readonly<Partial<Record<'http' | 'mcp' | 'a2a', string>>>>>;
83
+ /**
84
+ * Which facilitator verifies and broadcasts. `local` runs one in this process
85
+ * against a dev chain, and its `signerPrivateKey` pays gas there, usually
86
+ * an Anvil well-known key (LOCAL DEVELOPMENT ONLY - DO NOT FUND). `remote`
87
+ * calls an HTTP facilitator, and the gateway then holds no signing key.
88
+ */
89
+ readonly facilitator: X402FacilitatorConfig;
90
+ /** Must be `true` before anything settles on a mainnet. Never a default */
91
+ readonly allowMainnet?: boolean;
92
+ /** Required on mainnet when facilitator auth is `none` */
93
+ readonly allowUnauthenticatedFacilitator?: boolean;
94
+ /**
95
+ * Offer overrides by resource id, sharing the provider's facilitator and
96
+ * settings. Each list replaces the provider's offers for that resource.
97
+ */
98
+ readonly resourceOffers?: Readonly<Record<string, readonly X402OfferOptions[]>>;
99
+ /**
100
+ * Custom EVM networks keyed by CAIP-2 ID; `network` may select one, and
101
+ * its `kind` determines mainnet guardrails
102
+ */
103
+ readonly customNetworks?: CustomNetworks;
104
+ /**
105
+ * Experimental. Signs an ERC-8409 quote for each EVM offer when the request
106
+ * data can be canonicalized. Use a dedicated key that holds no funds.
107
+ * Never use a merchant's or buyer's wallet key.
108
+ */
109
+ readonly quote?: {
110
+ readonly signerPrivateKey: string;
111
+ };
112
+ readonly logger?: Logger;
113
+ readonly clock?: Clock;
114
+ readonly ids?: IdGenerator;
115
+ }
116
+ /** x402 payment provider with optional public quote metadata */
117
+ interface X402PaymentProvider extends PaymentProvider {
118
+ /**
119
+ * Experimental. Present when ERC-8409 quote signing is enabled.
120
+ * Publishes the issuer address for signature checks, the request scheme and
121
+ * the key under `PaymentRequired.extensions`.
122
+ */
123
+ readonly quote?: {
124
+ readonly issuer: `0x${string}`;
125
+ readonly requestScheme: string;
126
+ readonly extension: string;
127
+ };
128
+ }
129
+ /** Settlement network, token and merchant payee for one offer */
130
+ interface X402OfferOptions {
131
+ /**
132
+ * CAIP-2 network identifier, e.g. `eip155:8453`. An EVM chain id it carries
133
+ * is part of the EIP-712 domain the buyer signs, so it is read from this
134
+ * value rather than defaulted.
135
+ */
136
+ readonly network: string;
137
+ /** RPC endpoint of that network, for health checks and a local facilitator */
138
+ readonly rpcUrl: string;
139
+ /** ERC-20 contract or Solana mint used for settlement */
140
+ readonly asset: string;
141
+ /** EIP-712 domain name of the asset, e.g. 'USDC'; required for EIP-3009 */
142
+ readonly assetName?: string;
143
+ /** EIP-712 domain version of the asset, e.g. '2'; required for EIP-3009 */
144
+ readonly assetVersion?: string;
145
+ readonly assetDecimals: number;
146
+ /**
147
+ * Merchant-controlled settlement destination, never a gateway-owned wallet.
148
+ * On Solana it is the wallet; the transfer goes to its token account.
149
+ */
150
+ readonly payTo: string;
151
+ /**
152
+ * EVM only: `eip3009` (the default) or `permit2`. A Permit2 buyer approves
153
+ * the Permit2 contract for the token beforehand; the gateway never sends
154
+ * approvals.
155
+ */
156
+ readonly assetTransferMethod?: X402AssetTransferMethod;
157
+ }
158
+ /**
159
+ * Offers for each paid resource, using one facilitator. The proof selects
160
+ * the offer the buyer pays.
161
+ */
162
+ interface X402MultiOfferProviderOptions extends Omit<X402ProviderOptions, keyof X402OfferOptions> {
163
+ readonly offers: readonly X402OfferOptions[];
164
+ }
165
+
166
+ export { SUPPORTED_NETWORK_IDS as S };
167
+ export type { CustomNetworks as C, DeploymentMode as D, NetworkProfile as N, X402ProviderOptions as X, X402MultiOfferProviderOptions as a, X402PaymentProvider as b, X402AssetTransferMethod as c, X402OfferOptions as d };
package/dist/x402.d.ts CHANGED
@@ -1,9 +1,8 @@
1
- import { X as X402PaymentFlow, a as X402FacilitatorConfig } from './guardrails-CeyLS1ou.js';
2
- export { F as FacilitatorAuth } from './guardrails-CeyLS1ou.js';
3
- import { C as CustomNetworks } from './networks-DDHYJLcg.js';
4
- export { D as DeploymentMode, N as NetworkProfile, S as SUPPORTED_NETWORK_IDS } from './networks-DDHYJLcg.js';
5
- import { Clock, IdGenerator, PaymentProvider } from './index.js';
6
- import { Logger } from './index.js';
1
+ export { F as FacilitatorAuth, a as X402FacilitatorConfig, X as X402PaymentFlow } from './guardrails-CeyLS1ou.js';
2
+ import { X as X402ProviderOptions, a as X402MultiOfferProviderOptions, b as X402PaymentProvider } from './types-Dl27vhEc.js';
3
+ export { D as DeploymentMode, N as NetworkProfile, S as SUPPORTED_NETWORK_IDS, c as X402AssetTransferMethod, d as X402OfferOptions } from './types-Dl27vhEc.js';
4
+ import './runtime-D8u6lYfx.js';
5
+ import './logger-CllGwQ8i.js';
7
6
 
8
7
  /**
9
8
  * Client-side payment helper: builds and EIP-712-signs an x402 v2 `exact`/EVM
@@ -38,109 +37,7 @@ interface CreatePaymentProofOptions {
38
37
  /** Returns the base64 `PAYMENT-SIGNATURE` value to send back to the gateway */
39
38
  declare function createPaymentProof(options: CreatePaymentProofOptions): Promise<string>;
40
39
 
41
- /** EIP-3009 `transferWithAuthorization`, or Permit2 with a prior token allowance */
42
- type X402AssetTransferMethod = 'eip3009' | 'permit2';
43
-
44
- /** A single offer and the settings every offer shares */
45
- interface X402ProviderOptions extends X402OfferOptions {
46
- readonly maxTimeoutSeconds?: number;
47
- /**
48
- * When the payment settles relative to the backend call. Defaults to
49
- * `authorization`, the x402 default: settle only after the backend succeeds.
50
- * `upfront` settles before the backend call.
51
- */
52
- readonly paymentFlow?: X402PaymentFlow;
53
- /** Per-resource overrides of `paymentFlow`, keyed by resource id */
54
- readonly resourcePaymentFlows?: Readonly<Record<string, X402PaymentFlow>>;
55
- /**
56
- * The media type each resource's challenge declares as `resource.mimeType`,
57
- * keyed by resource id. Defaults to `application/json`.
58
- */
59
- readonly resourceMimeTypes?: Readonly<Record<string, string>>;
60
- /**
61
- * Which facilitator verifies and broadcasts. `local` runs one in this process
62
- * against a dev chain, and its `signerPrivateKey` pays gas there, usually
63
- * an Anvil well-known key (LOCAL DEVELOPMENT ONLY - DO NOT FUND). `remote`
64
- * calls an HTTP facilitator, and the gateway then holds no signing key.
65
- */
66
- readonly facilitator: X402FacilitatorConfig;
67
- /** Must be `true` before anything settles on a mainnet. Never a default */
68
- readonly allowMainnet?: boolean;
69
- /** Required on mainnet when facilitator auth is `none` */
70
- readonly allowUnauthenticatedFacilitator?: boolean;
71
- /**
72
- * Offer overrides by resource id, sharing the provider's facilitator and
73
- * settings. Each list replaces the provider's offers for that resource.
74
- */
75
- readonly resourceOffers?: Readonly<Record<string, readonly X402OfferOptions[]>>;
76
- /**
77
- * Custom EVM networks keyed by CAIP-2 ID; `network` may select one, and
78
- * its `kind` determines mainnet guardrails
79
- */
80
- readonly customNetworks?: CustomNetworks;
81
- /**
82
- * Experimental. Signs an ERC-8409 quote for each EVM offer when the request
83
- * data can be canonicalized. Use a dedicated key that holds no funds.
84
- * Never use a merchant's or buyer's wallet key.
85
- */
86
- readonly quote?: {
87
- readonly signerPrivateKey: string;
88
- };
89
- readonly logger?: Logger;
90
- readonly clock?: Clock;
91
- readonly ids?: IdGenerator;
92
- }
93
- /** x402 payment provider with optional public quote metadata */
94
- interface X402PaymentProvider extends PaymentProvider {
95
- /**
96
- * Experimental. Present when ERC-8409 quote signing is enabled.
97
- * Publishes the issuer address for signature checks, the request scheme and
98
- * the key under `PaymentRequired.extensions`.
99
- */
100
- readonly quote?: {
101
- readonly issuer: `0x${string}`;
102
- readonly requestScheme: string;
103
- readonly extension: string;
104
- };
105
- }
106
- /** Settlement network, token and merchant payee for one offer */
107
- interface X402OfferOptions {
108
- /**
109
- * CAIP-2 network identifier, e.g. `eip155:8453`. An EVM chain id it carries
110
- * is part of the EIP-712 domain the buyer signs, so it is read from this
111
- * value rather than defaulted.
112
- */
113
- readonly network: string;
114
- /** RPC endpoint of that network, for health checks and a local facilitator */
115
- readonly rpcUrl: string;
116
- /** ERC-20 contract or Solana mint used for settlement */
117
- readonly asset: string;
118
- /** EIP-712 domain name of the asset, e.g. 'USDC'; required for EIP-3009 */
119
- readonly assetName?: string;
120
- /** EIP-712 domain version of the asset, e.g. '2'; required for EIP-3009 */
121
- readonly assetVersion?: string;
122
- readonly assetDecimals: number;
123
- /**
124
- * Merchant-controlled settlement destination, never a gateway-owned wallet.
125
- * On Solana it is the wallet; the transfer goes to its token account.
126
- */
127
- readonly payTo: string;
128
- /**
129
- * EVM only: `eip3009` (the default) or `permit2`. A Permit2 buyer approves
130
- * the Permit2 contract for the token beforehand; the gateway never sends
131
- * approvals.
132
- */
133
- readonly assetTransferMethod?: X402AssetTransferMethod;
134
- }
135
- /**
136
- * Offers for each paid resource, using one facilitator. The proof selects
137
- * the offer the buyer pays.
138
- */
139
- interface X402MultiOfferProviderOptions extends Omit<X402ProviderOptions, keyof X402OfferOptions> {
140
- readonly offers: readonly X402OfferOptions[];
141
- }
142
-
143
40
  declare function createX402PaymentProvider(options: X402ProviderOptions | X402MultiOfferProviderOptions): X402PaymentProvider;
144
41
 
145
- export { X402FacilitatorConfig, X402PaymentFlow, createPaymentProof, createX402PaymentProvider, createX402PaymentProvider as x402 };
146
- export type { CreatePaymentProofOptions, X402AssetTransferMethod, X402MultiOfferProviderOptions, X402OfferOptions, X402PaymentProvider, X402ProviderOptions };
42
+ export { X402MultiOfferProviderOptions, X402PaymentProvider, X402ProviderOptions, createPaymentProof, createX402PaymentProvider, createX402PaymentProvider as x402 };
43
+ export type { CreatePaymentProofOptions };
package/dist/x402.js CHANGED
@@ -1,8 +1,9 @@
1
- import { chainIdFromCaip2 } from './chunk-5VW32JPV.js';
2
- export { createX402PaymentProvider, createX402PaymentProvider as x402 } from './chunk-5VW32JPV.js';
3
- export { SUPPORTED_NETWORK_IDS } from './chunk-5AO5N2XY.js';
4
- import './chunk-IGXQMAKM.js';
5
- import { CommerceError } from './chunk-YHNTTMED.js';
1
+ import { chainIdFromCaip2 } from './chunk-QZW5YL3G.js';
2
+ export { createX402PaymentProvider, createX402PaymentProvider as x402 } from './chunk-QZW5YL3G.js';
3
+ export { SUPPORTED_NETWORK_IDS } from './chunk-VHS6MGXJ.js';
4
+ import './chunk-MNI6APE6.js';
5
+ import './chunk-ENK63GKR.js';
6
+ import { CommerceError } from './chunk-MDOGXTZD.js';
6
7
  import './chunk-GA3O2A7R.js';
7
8
  import './chunk-2CJNA7MS.js';
8
9
  import { PaymentRequirementsV2Schema } from '@x402/core/schemas';