@devlab.group/agent-commerce 2.3.0 → 2.4.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 (60) hide show
  1. package/README.md +17 -13
  2. package/dist/ap2.d.ts +6 -5
  3. package/dist/ap2.js +3 -3
  4. package/dist/{authorization-CMkIuAkO.d.ts → authorization-DjAecwuW.d.ts} +1 -1
  5. package/dist/{chunk-XVU46YAH.js → chunk-4OEXK3YG.js} +4 -4
  6. package/dist/{chunk-XVU46YAH.js.map → chunk-4OEXK3YG.js.map} +1 -1
  7. package/dist/{chunk-4ZSE5DCH.js → chunk-6WACRJVT.js} +3 -3
  8. package/dist/{chunk-4ZSE5DCH.js.map → chunk-6WACRJVT.js.map} +1 -1
  9. package/dist/{chunk-Q5TII32R.js → chunk-AITMDXKW.js} +3 -3
  10. package/dist/{chunk-Q5TII32R.js.map → chunk-AITMDXKW.js.map} +1 -1
  11. package/dist/{chunk-TNS7U5Q4.js → chunk-WUIAUAA7.js} +200 -8
  12. package/dist/chunk-WUIAUAA7.js.map +1 -0
  13. package/dist/cli/{ap2-GINAXBFV.js → ap2-QDHPRSTF.js} +3 -3
  14. package/dist/cli/{ap2-GINAXBFV.js.map → ap2-QDHPRSTF.js.map} +1 -1
  15. package/dist/cli/{chunk-BR7CMJOE.js → chunk-AZDWFVDW.js} +200 -8
  16. package/dist/cli/chunk-AZDWFVDW.js.map +1 -0
  17. package/dist/cli/{chunk-KABFUZ6L.js → chunk-DCMW67JM.js} +4 -4
  18. package/dist/cli/{chunk-KABFUZ6L.js.map → chunk-DCMW67JM.js.map} +1 -1
  19. package/dist/cli/{chunk-55N55KL4.js → chunk-G2JEY7MB.js} +22 -6
  20. package/dist/cli/chunk-G2JEY7MB.js.map +1 -0
  21. package/dist/cli/{chunk-2LN5PO5I.js → chunk-PIMFPCNZ.js} +3 -2
  22. package/dist/cli/chunk-PIMFPCNZ.js.map +1 -0
  23. package/dist/cli/chunk-UXB65XCS.js +8 -0
  24. package/dist/cli/{chunk-DYHVNKRB.js.map → chunk-UXB65XCS.js.map} +1 -1
  25. package/dist/cli/{chunk-KTV52MCU.js → chunk-WYOGIANL.js} +3 -3
  26. package/dist/cli/{chunk-KTV52MCU.js.map → chunk-WYOGIANL.js.map} +1 -1
  27. package/dist/cli/{config-ZOFHJ5FB.js → config-UI4EDG4L.js} +5 -5
  28. package/dist/cli/{config-ZOFHJ5FB.js.map → config-UI4EDG4L.js.map} +1 -1
  29. package/dist/cli/index.js +87 -8
  30. package/dist/cli/index.js.map +1 -1
  31. package/dist/cli/{mcp-V3BNRUWL.js → mcp-26LJMN4N.js} +3 -3
  32. package/dist/cli/{mcp-V3BNRUWL.js.map → mcp-26LJMN4N.js.map} +1 -1
  33. package/dist/cli/{provider-BTIFALIT.js → provider-Z4OJNAYI.js} +5 -5
  34. package/dist/cli/{provider-BTIFALIT.js.map → provider-Z4OJNAYI.js.map} +1 -1
  35. package/dist/cli/{run-DS2KXUTW.js → run-TEPYJUHG.js} +23 -12
  36. package/dist/cli/run-TEPYJUHG.js.map +1 -0
  37. package/dist/cli/{x402-YTKFNWVQ.js → x402-BMVONZKA.js} +6 -6
  38. package/dist/cli/{x402-YTKFNWVQ.js.map → x402-BMVONZKA.js.map} +1 -1
  39. package/dist/{constants-nackLItD.d.ts → constants-BG22tE8S.d.ts} +2 -1
  40. package/dist/index.d.ts +19 -11
  41. package/dist/index.js +32 -7
  42. package/dist/index.js.map +1 -1
  43. package/dist/mcp.d.ts +5 -4
  44. package/dist/mcp.js +1 -1
  45. package/dist/mpp.d.ts +5 -4
  46. package/dist/mpp.js +3 -3
  47. package/dist/{networks-DTWRlj-K.d.ts → networks-DDHYJLcg.d.ts} +2 -1
  48. package/dist/{protocol-adapter-CfxU8Z2T.d.ts → protocol-adapter-C9odYl6l.d.ts} +4 -3
  49. package/dist/{runtime-7vLNYvmU.d.ts → runtime-Cl_BLVZV.d.ts} +8 -1
  50. package/dist/{types-CVw6Sf46.d.ts → types-j7MnUXYN.d.ts} +2 -1
  51. package/dist/x402.d.ts +27 -18
  52. package/dist/x402.js +4 -4
  53. package/package.json +6 -6
  54. package/dist/chunk-TNS7U5Q4.js.map +0 -1
  55. package/dist/cli/chunk-2LN5PO5I.js.map +0 -1
  56. package/dist/cli/chunk-55N55KL4.js.map +0 -1
  57. package/dist/cli/chunk-BR7CMJOE.js.map +0 -1
  58. package/dist/cli/chunk-DYHVNKRB.js +0 -8
  59. package/dist/cli/index.d.ts +0 -1
  60. package/dist/cli/run-DS2KXUTW.js.map +0 -1
@@ -1,9 +1,9 @@
1
- import { chainIdFromCaip2 } from './chunk-BR7CMJOE.js';
2
- export { createX402PaymentProvider } from './chunk-BR7CMJOE.js';
3
- import './chunk-KTV52MCU.js';
1
+ import { chainIdFromCaip2 } from './chunk-AZDWFVDW.js';
2
+ export { createX402PaymentProvider } from './chunk-AZDWFVDW.js';
3
+ import './chunk-WYOGIANL.js';
4
4
  export { SUPPORTED_NETWORK_IDS } from './chunk-OZ4LAWBK.js';
5
5
  import './chunk-OSTCU6ZK.js';
6
- import './chunk-DYHVNKRB.js';
6
+ import './chunk-UXB65XCS.js';
7
7
  import { CommerceError } from './chunk-QQ3WY5L3.js';
8
8
  import './chunk-3M6U7ILB.js';
9
9
  import { PaymentRequirementsV2Schema } from '@x402/core/schemas';
@@ -92,5 +92,5 @@ function randomNonce() {
92
92
  }
93
93
 
94
94
  export { createPaymentProof };
95
- //# sourceMappingURL=x402-YTKFNWVQ.js.map
96
- //# sourceMappingURL=x402-YTKFNWVQ.js.map
95
+ //# sourceMappingURL=x402-BMVONZKA.js.map
96
+ //# sourceMappingURL=x402-BMVONZKA.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/payments/x402/client.ts"],"names":[],"mappings":";;;;;;;;;;;;AAkCA,IAAM,YAAA,GAAe,CAAA;AAErB,IAAM,iCAAA,GAAoC;AAAA,EACxC,yBAAA,EAA2B;AAAA,IACzB,EAAE,IAAA,EAAM,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b,QAAA,EAAU,YAAA;AAAA,IACV,OAAA,EAAS;AAAA,MACP,SAAA;AAAA,MACA,aAAA,EAAe;AAAA,QACb,MAAM,OAAA,CAAQ,OAAA;AAAA,QACd,EAAA;AAAA,QACA,KAAA,EAAO,MAAM,QAAA,EAAS;AAAA,QACtB,UAAA,EAAY,WAAW,QAAA,EAAS;AAAA,QAChC,WAAA,EAAa,YAAY,QAAA,EAAS;AAAA,QAClC;AAAA;AACF;AACF,GACF;AAEA,EAAA,OAAO,MAAA,CAAO,KAAK,IAAA,CAAK,SAAA,CAAU,OAAO,CAAA,EAAG,MAAM,CAAA,CAAE,QAAA,CAAS,QAAQ,CAAA;AACvE;AAEA,SAAS,WAAA,GAA6B;AACpC,EAAA,MAAM,KAAA,GAAQ,IAAI,UAAA,CAAW,EAAE,CAAA;AAC/B,EAAA,MAAA,CAAO,gBAAgB,KAAK,CAAA;AAC5B,EAAA,OAAO,MAAM,KAAK,CAAA;AACpB","file":"x402-YTKFNWVQ.js","sourcesContent":["/**\n * Client-side payment helper: builds and EIP-712-signs an x402 v2 `exact`/EVM\n * authorization on the buyer's side. The demo buyer agent and the test suites\n * use it, and the `/x402` entry exports it. The gateway never calls it and\n * never holds a buyer key.\n *\n * It signs directly rather than through the SDK's `x402Client` because of\n * `overrides`: negative tests need deliberately wrong authorizations that a\n * conforming client will not produce. The x402 settlement E2E suite also\n * settles a payment built by `x402Client` itself to cover interoperability.\n */\n\nimport { PaymentRequirementsV2Schema } from '@x402/core/schemas';\nimport type { PaymentPayload, PaymentRequirements } from '@x402/core/types';\nimport { getAddress, toHex } from 'viem';\nimport { privateKeyToAccount } from 'viem/accounts';\nimport { CommerceError } from '../../core';\nimport { chainIdFromCaip2 } from './chain';\n\nexport interface CreatePaymentProofOptions {\n /** The buyer's private key. It signs locally and is never sent anywhere */\n readonly buyerPrivateKey: `0x${string}`;\n /** One entry from PaymentRequiredEnvelope.payment.accepts, verbatim */\n readonly accepts: Readonly<Record<string, unknown>>;\n /** For negative tests only: a wrong amount, recipient, nonce or validity window */\n readonly overrides?: {\n readonly value?: string;\n readonly payTo?: string;\n readonly nonce?: `0x${string}`;\n readonly validBefore?: number;\n readonly validAfter?: number;\n };\n}\n\nconst X402_VERSION = 2;\n\nconst TRANSFER_WITH_AUTHORIZATION_TYPES = {\n TransferWithAuthorization: [\n { name: 'from', type: 'address' },\n { name: 'to', type: 'address' },\n { name: 'value', type: 'uint256' },\n { name: 'validAfter', type: 'uint256' },\n { name: 'validBefore', type: 'uint256' },\n { name: 'nonce', type: 'bytes32' },\n ],\n} as const;\n\n/** Returns the base64 `PAYMENT-SIGNATURE` value to send back to the gateway */\nexport async function createPaymentProof(options: CreatePaymentProofOptions): Promise<string> {\n const requirements = PaymentRequirementsV2Schema.parse(options.accepts);\n const method = requirements.extra?.['assetTransferMethod'];\n if (method !== undefined && method !== 'eip3009') {\n throw new CommerceError(\n 'INPUT_INVALID',\n `createPaymentProof: signs EIP-3009 only, and this offer uses \"${String(method)}\"; sign it with the SDK's x402Client`,\n );\n }\n if (\n !requirements.extra ||\n typeof requirements.extra['name'] !== 'string' ||\n typeof requirements.extra['version'] !== 'string'\n ) {\n throw new CommerceError(\n 'INPUT_INVALID',\n 'createPaymentProof: payment requirement is missing extra.name/extra.version, so the EIP-712 domain cannot be built',\n );\n }\n\n const chainId = chainIdFromCaip2(requirements.network);\n if (chainId === undefined) {\n throw new CommerceError(\n 'INPUT_INVALID',\n `createPaymentProof: network \"${requirements.network}\" is not a CAIP-2 eip155 identifier, so there is no chain id to sign against`,\n );\n }\n\n const account = privateKeyToAccount(options.buyerPrivateKey);\n\n const nonce = options.overrides?.nonce ?? randomNonce();\n const nowSeconds = Math.floor(Date.now() / 1000);\n // 0, as in the SDK's own v2 client: nothing here wants the authorization\n // delayed\n const validAfter = options.overrides?.validAfter ?? 0;\n const validBefore = options.overrides?.validBefore ?? nowSeconds + requirements.maxTimeoutSeconds;\n const to = getAddress((options.overrides?.payTo ?? requirements.payTo) as `0x${string}`);\n const value = BigInt(options.overrides?.value ?? requirements.amount);\n\n const signature = await account.signTypedData({\n domain: {\n name: requirements.extra['name'],\n version: requirements.extra['version'],\n chainId,\n verifyingContract: getAddress(requirements.asset as `0x${string}`),\n },\n types: TRANSFER_WITH_AUTHORIZATION_TYPES,\n primaryType: 'TransferWithAuthorization',\n message: {\n from: account.address,\n to,\n value,\n validAfter: BigInt(validAfter),\n validBefore: BigInt(validBefore),\n nonce,\n },\n });\n\n // v2 echoes the chosen requirement back as `accepted` so a stateless\n // facilitator knows which offer was taken. The gateway verifies against its\n // own copy.\n const payload: PaymentPayload = {\n x402Version: X402_VERSION,\n accepted: requirements as PaymentRequirements,\n payload: {\n signature,\n authorization: {\n from: account.address,\n to,\n value: value.toString(),\n validAfter: validAfter.toString(),\n validBefore: validBefore.toString(),\n nonce,\n },\n },\n };\n\n return Buffer.from(JSON.stringify(payload), 'utf8').toString('base64');\n}\n\nfunction randomNonce(): `0x${string}` {\n const bytes = new Uint8Array(32);\n crypto.getRandomValues(bytes);\n return toHex(bytes);\n}\n"]}
1
+ {"version":3,"sources":["../../src/payments/x402/client.ts"],"names":[],"mappings":";;;;;;;;;;;;AAkCA,IAAM,YAAA,GAAe,CAAA;AAErB,IAAM,iCAAA,GAAoC;AAAA,EACxC,yBAAA,EAA2B;AAAA,IACzB,EAAE,IAAA,EAAM,MAAA,EAAQ,IAAA,EAAM,SAAA,EAAU;AAAA,IAChC,EAAE,IAAA,EAAM,IAAA,EAAM,IAAA,EAAM,SAAA,EAAU;AAAA,IAC9B,EAAE,IAAA,EAAM,OAAA,EAAS,IAAA,EAAM,SAAA,EAAU;AAAA,IACjC,EAAE,IAAA,EAAM,YAAA,EAAc,IAAA,EAAM,SAAA,EAAU;AAAA,IACtC,EAAE,IAAA,EAAM,aAAA,EAAe,IAAA,EAAM,SAAA,EAAU;AAAA,IACvC,EAAE,IAAA,EAAM,OAAA,EAAS,IAAA,EAAM,SAAA;AAAU;AAErC,CAAA;AAGA,eAAsB,m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CAAS,QAAQ,CAAA;AACvE;AAEA,SAAS,WAAA,GAA6B;AACpC,EAAA,MAAM,KAAA,GAAQ,IAAI,UAAA,CAAW,EAAE,CAAA;AAC/B,EAAA,MAAA,CAAO,gBAAgB,KAAK,CAAA;AAC5B,EAAA,OAAO,MAAM,KAAK,CAAA;AACpB","file":"x402-BMVONZKA.js","sourcesContent":["/**\n * Client-side payment helper: builds and EIP-712-signs an x402 v2 `exact`/EVM\n * authorization on the buyer's side. The demo buyer agent and the test suites\n * use it, and the `/x402` entry exports it. The gateway never calls it and\n * never holds a buyer key.\n *\n * It signs directly rather than through the SDK's `x402Client` because of\n * `overrides`: negative tests need deliberately wrong authorizations that a\n * conforming client will not produce. The x402 settlement E2E suite also\n * settles a payment built by `x402Client` itself to cover interoperability.\n */\n\nimport { PaymentRequirementsV2Schema } from '@x402/core/schemas';\nimport type { PaymentPayload, PaymentRequirements } from '@x402/core/types';\nimport { getAddress, toHex } from 'viem';\nimport { privateKeyToAccount } from 'viem/accounts';\nimport { CommerceError } from '../../core';\nimport { chainIdFromCaip2 } from './chain';\n\nexport interface CreatePaymentProofOptions {\n /** The buyer's private key. It signs locally and is never sent anywhere */\n readonly buyerPrivateKey: `0x${string}`;\n /** One entry from PaymentRequiredEnvelope.payment.accepts, verbatim */\n readonly accepts: Readonly<Record<string, unknown>>;\n /** For negative tests only: a wrong amount, recipient, nonce or validity window */\n readonly overrides?: {\n readonly value?: string;\n readonly payTo?: string;\n readonly nonce?: `0x${string}`;\n readonly validBefore?: number;\n readonly validAfter?: number;\n };\n}\n\nconst X402_VERSION = 2;\n\nconst TRANSFER_WITH_AUTHORIZATION_TYPES = {\n TransferWithAuthorization: [\n { name: 'from', type: 'address' },\n { name: 'to', type: 'address' },\n { name: 'value', type: 'uint256' },\n { name: 'validAfter', type: 'uint256' },\n { name: 'validBefore', type: 'uint256' },\n { name: 'nonce', type: 'bytes32' },\n ],\n} as const;\n\n/** Returns the base64 `PAYMENT-SIGNATURE` value to send back to the gateway */\nexport async function createPaymentProof(options: CreatePaymentProofOptions): Promise<string> {\n const requirements = PaymentRequirementsV2Schema.parse(options.accepts);\n const method = requirements.extra?.['assetTransferMethod'];\n if (method !== undefined && method !== 'eip3009') {\n throw new CommerceError(\n 'INPUT_INVALID',\n `createPaymentProof: signs EIP-3009 only, and this offer uses \"${String(method)}\"; sign it with the SDK's x402Client`,\n );\n }\n if (\n !requirements.extra ||\n typeof requirements.extra['name'] !== 'string' ||\n typeof requirements.extra['version'] !== 'string'\n ) {\n throw new CommerceError(\n 'INPUT_INVALID',\n 'createPaymentProof: payment requirement is missing extra.name/extra.version, so the EIP-712 domain cannot be built',\n );\n }\n\n const chainId = chainIdFromCaip2(requirements.network);\n if (chainId === undefined) {\n throw new CommerceError(\n 'INPUT_INVALID',\n `createPaymentProof: network \"${requirements.network}\" is not a CAIP-2 eip155 identifier, so there is no chain id to sign against`,\n );\n }\n\n const account = privateKeyToAccount(options.buyerPrivateKey);\n\n const nonce = options.overrides?.nonce ?? randomNonce();\n const nowSeconds = Math.floor(Date.now() / 1000);\n // 0, as in the SDK's own v2 client: nothing here wants the authorization\n // delayed\n const validAfter = options.overrides?.validAfter ?? 0;\n const validBefore = options.overrides?.validBefore ?? nowSeconds + requirements.maxTimeoutSeconds;\n const to = getAddress((options.overrides?.payTo ?? requirements.payTo) as `0x${string}`);\n const value = BigInt(options.overrides?.value ?? requirements.amount);\n\n const signature = await account.signTypedData({\n domain: {\n name: requirements.extra['name'],\n version: requirements.extra['version'],\n chainId,\n verifyingContract: getAddress(requirements.asset as `0x${string}`),\n },\n types: TRANSFER_WITH_AUTHORIZATION_TYPES,\n primaryType: 'TransferWithAuthorization',\n message: {\n from: account.address,\n to,\n value,\n validAfter: BigInt(validAfter),\n validBefore: BigInt(validBefore),\n nonce,\n },\n });\n\n // v2 echoes the chosen requirement back as `accepted` so a stateless\n // facilitator knows which offer was taken. The gateway verifies against its\n // own copy.\n const payload: PaymentPayload = {\n x402Version: X402_VERSION,\n accepted: requirements as PaymentRequirements,\n payload: {\n signature,\n authorization: {\n from: account.address,\n to,\n value: value.toString(),\n validAfter: validAfter.toString(),\n validBefore: validBefore.toString(),\n nonce,\n },\n },\n };\n\n return Buffer.from(JSON.stringify(payload), 'utf8').toString('base64');\n}\n\nfunction randomNonce(): `0x${string}` {\n const bytes = new Uint8Array(32);\n crypto.getRandomValues(bytes);\n return toHex(bytes);\n}\n"]}
@@ -46,4 +46,5 @@ type MppNetwork = (typeof MPP_NETWORKS)[number];
46
46
  /** Compact descriptor value naming the core draft, intent and method */
47
47
  declare const MPP_SUPPORTED_SPEC: string;
48
48
 
49
- export { type MppNetwork as M, MPPX_VERSION as a, MPP_PROFILE as b, MPP_SPEC_COMMIT as c, MPP_SPEC_DRAFTS as d, MPP_SPEC_REPOSITORY as e, MPP_SUPPORTED_SPEC as f };
49
+ export { MPPX_VERSION as a, MPP_PROFILE as b, MPP_SPEC_COMMIT as c, MPP_SPEC_DRAFTS as d, MPP_SPEC_REPOSITORY as e, MPP_SUPPORTED_SPEC as f };
50
+ export type { MppNetwork as M };
package/dist/index.d.ts CHANGED
@@ -1,13 +1,13 @@
1
- import { f as Ap2AuthorizationConfig } from './types-CVw6Sf46.js';
2
- import { I as IsoTimestamp, D as DecimalAmount, P as PaymentMethodName, a as CommerceResource, b as PaymentSubmission, B as BackendHandler, A as AdapterDescriptor, c as AdapterHealth, R as ResourceRegistry, d as PaymentProvider, L as Logger, C as Clock, e as IdGenerator } from './runtime-7vLNYvmU.js';
3
- export { f as AdapterHealthComponent, g as AuthorizationMethodName, h as BackendMethod, i as DEFAULT_BACKEND_TIMEOUT_MS, J as JsonSchema, N as NOOP_LOGGER, j as PAYMENT_METHOD_NAMES, k as PROTOCOL_NAMES, l as PaymentChallenge, m as PaymentContext, n as PaymentRequirement, o as PaymentResult, p as PaymentSettlementContext, q as PaymentVerificationContext, r as Pricing, s as ProtocolName, t as systemClock } from './runtime-7vLNYvmU.js';
4
- import { M as MppNetwork } from './constants-nackLItD.js';
5
- import { X as X402PaymentFlow, a as X402FacilitatorConfig } from './guardrails-CX_jYXvZ.js';
6
- import { C as CustomNetworks } from './networks-DTWRlj-K.js';
7
- import { a as AuthorizationRequirement, b as AuthorizationSubmission, A as AuthorizationProvider } from './authorization-CMkIuAkO.js';
8
- export { c as AuthorizationFinalizeContext, d as AuthorizationRecord, e as AuthorizationVerification, f as AuthorizationVerificationContext } from './authorization-CMkIuAkO.js';
9
- import { D as DeliveredOutcome, P as PaymentRequiredOutcome, C as CommerceEvent, a as PaymentAttempt, b as CommerceReceipt, E as ExecutionPipeline, c as ProtocolAdapter, H as HttpProtocolAdapter, A as AdapterHttpRoute, d as ProtocolAdapterContext } from './protocol-adapter-CfxU8Z2T.js';
10
- export { e as COMMERCE_EVENT_TYPES, f as CanonicalRequest, g as CommerceEventType, h as EventSink, i as ExecutionOutcome, j as isHttpProtocolAdapter } from './protocol-adapter-CfxU8Z2T.js';
1
+ import { Ap2AuthorizationConfig } from './ap2.js';
2
+ import { I as IsoTimestamp, D as DecimalAmount, P as PaymentMethodName, a as CommerceResource, b as PaymentSubmission, B as BackendHandler, A as AdapterDescriptor, c as AdapterHealth, R as ResourceRegistry, d as PaymentProvider, L as Logger, C as Clock, e as IdGenerator } from './runtime-Cl_BLVZV.js';
3
+ export { f as AdapterHealthComponent, g as AuthorizationMethodName, h as BackendMethod, i as DEFAULT_BACKEND_TIMEOUT_MS, J as JsonSchema, N as NOOP_LOGGER, j as PAYMENT_METHOD_NAMES, k as PROTOCOL_NAMES, l as PaymentChallenge, m as PaymentContext, n as PaymentRequirement, o as PaymentResult, p as PaymentSettlementContext, q as PaymentVerificationContext, r as Pricing, s as ProtocolName, t as systemClock } from './runtime-Cl_BLVZV.js';
4
+ import { M as MppNetwork } from './constants-BG22tE8S.js';
5
+ import { X402PaymentFlow, X402FacilitatorConfig } from './x402.js';
6
+ import { C as CustomNetworks } from './networks-DDHYJLcg.js';
7
+ import { a as AuthorizationRequirement, b as AuthorizationSubmission, A as AuthorizationProvider } from './authorization-DjAecwuW.js';
8
+ export { c as AuthorizationFinalizeContext, d as AuthorizationRecord, e as AuthorizationVerification, f as AuthorizationVerificationContext } from './authorization-DjAecwuW.js';
9
+ import { D as DeliveredOutcome, P as PaymentRequiredOutcome, C as CommerceEvent, a as PaymentAttempt, b as CommerceReceipt, E as ExecutionPipeline, c as ProtocolAdapter, H as HttpProtocolAdapter, A as AdapterHttpRoute, d as ProtocolAdapterContext } from './protocol-adapter-C9odYl6l.js';
10
+ export { e as COMMERCE_EVENT_TYPES, f as CanonicalRequest, g as CommerceEventType, h as EventSink, i as ExecutionOutcome, j as isHttpProtocolAdapter } from './protocol-adapter-C9odYl6l.js';
11
11
  import { FastifyInstance } from 'fastify';
12
12
  import { IncomingMessage, ServerResponse } from 'node:http';
13
13
 
@@ -535,6 +535,13 @@ interface GatewayConfig {
535
535
  * Absent when no resource overrides its offers.
536
536
  */
537
537
  readonly resourceOptions?: Readonly<Record<string, readonly X402OptionConfig[]>>;
538
+ /**
539
+ * Experimental ERC-8409 quotes. Config loading includes this field only
540
+ * when `quote.enabled` is true. The signing key must not hold funds.
541
+ */
542
+ readonly quote?: {
543
+ readonly signerPrivateKey: string;
544
+ };
538
545
  };
539
546
  readonly mpp?: {
540
547
  readonly enabled: boolean;
@@ -740,4 +747,5 @@ interface SqliteReceiptStoreOptions {
740
747
  }
741
748
  declare function createSqliteReceiptStore(options: SqliteReceiptStoreOptions): ReceiptStore;
742
749
 
743
- export { A2A_AGENT_CARD_PATH, A2A_PROTOCOL_VERSION, A2A_SPEC_VERSION, type A2aAdapterOptions, ACP_API_VERSION, ACP_SPEC_VERSION, ACP_WELL_KNOWN_PATH, AUTHORIZATION_HEADER, AUTHORIZATION_INPUT_FIELD, type AcpAdapterOptions, AdapterDescriptor, AdapterHealth, AdapterHttpRoute, AuthorizationProvider, AuthorizationRequirement, AuthorizationSubmission, type BackendExecutor, BackendHandler, type BackendRequest, type BackendResponse, COMMERCE_ERROR_CODES, COMMERCE_ERROR_HTTP_STATUS, Clock, CommerceError, type CommerceErrorCode, type CommerceErrorInfo, type CommerceErrorOptions, CommerceEvent, CommerceReceipt, CommerceResource, DELIVERY_SUMMARY_META_KEY, DecimalAmount, DeliveredOutcome, type DeliverySummary, type ErrorEnvelope, ExecutionPipeline, type GatewayConfig, type GatewayInstance, type GatewayOptions, HttpProtocolAdapter, IdGenerator, IsoTimestamp, type ListOptions, Logger, MAX_AUTHORIZATION_HEADER_BYTES, PAYMENT_HEADER, PAYMENT_INPUT_FIELD, PAYMENT_REQUIRED_HEADER, PAYMENT_RESPONSE_HEADER, PaymentAttempt, type PaymentAttemptListOptions, type PaymentAttemptReservation, type PaymentAttemptUpdate, PaymentMethodName, PaymentProvider, type PaymentRequiredEnvelope, PaymentRequiredOutcome, PaymentSubmission, ProtocolAdapter, ProtocolAdapterContext, RESERVED_INPUT_FIELDS, RETRYABLE_ERROR_CODES, type ReceiptListOptions, type ReceiptStore, ResourceRegistry, createA2aAdapter, createAcpAdapter, createGateway, createSqliteReceiptStore, extractReservedInputFields, isCommerceError, isPaymentRequiredEnvelope, loadConfig, parseAuthorizationHeader, parseAuthorizationSubmission, parseConfig, createSqliteReceiptStore as receipts, toCommerceError, toDeliverySummary, toErrorEnvelope, toPaymentRequiredEnvelope };
750
+ export { A2A_AGENT_CARD_PATH, A2A_PROTOCOL_VERSION, A2A_SPEC_VERSION, ACP_API_VERSION, ACP_SPEC_VERSION, ACP_WELL_KNOWN_PATH, AUTHORIZATION_HEADER, AUTHORIZATION_INPUT_FIELD, AdapterDescriptor, AdapterHealth, AdapterHttpRoute, AuthorizationProvider, AuthorizationRequirement, AuthorizationSubmission, BackendHandler, COMMERCE_ERROR_CODES, COMMERCE_ERROR_HTTP_STATUS, Clock, CommerceError, CommerceEvent, CommerceReceipt, CommerceResource, DELIVERY_SUMMARY_META_KEY, DecimalAmount, DeliveredOutcome, ExecutionPipeline, HttpProtocolAdapter, IdGenerator, IsoTimestamp, Logger, MAX_AUTHORIZATION_HEADER_BYTES, PAYMENT_HEADER, PAYMENT_INPUT_FIELD, PAYMENT_REQUIRED_HEADER, PAYMENT_RESPONSE_HEADER, PaymentAttempt, PaymentMethodName, PaymentProvider, PaymentRequiredOutcome, PaymentSubmission, ProtocolAdapter, ProtocolAdapterContext, RESERVED_INPUT_FIELDS, RETRYABLE_ERROR_CODES, ResourceRegistry, createA2aAdapter, createAcpAdapter, createGateway, createSqliteReceiptStore, extractReservedInputFields, isCommerceError, isPaymentRequiredEnvelope, loadConfig, parseAuthorizationHeader, parseAuthorizationSubmission, parseConfig, createSqliteReceiptStore as receipts, toCommerceError, toDeliverySummary, toErrorEnvelope, toPaymentRequiredEnvelope };
751
+ export type { A2aAdapterOptions, AcpAdapterOptions, BackendExecutor, BackendRequest, BackendResponse, CommerceErrorCode, CommerceErrorInfo, CommerceErrorOptions, DeliverySummary, ErrorEnvelope, GatewayConfig, GatewayInstance, GatewayOptions, ListOptions, PaymentAttemptListOptions, PaymentAttemptReservation, PaymentAttemptUpdate, PaymentRequiredEnvelope, ReceiptListOptions, ReceiptStore };
package/dist/index.js CHANGED
@@ -1,10 +1,10 @@
1
- import { openSqliteDatabase, AP2_SPEC_VERSION, AP2_MODES, AP2_DEFAULT_CLOCK_SKEW_SECONDS, AP2_JWK_MEMBERS, AP2_KEY_TYPE, AP2_SIGNING_ALGORITHM, AP2_JWK_CURVE, AP2_JWK_COORDINATE_BYTES, AP2_MAX_CLOCK_SKEW_SECONDS } from './chunk-4ZSE5DCH.js';
1
+ import { openSqliteDatabase, AP2_SPEC_VERSION, AP2_MODES, AP2_DEFAULT_CLOCK_SKEW_SECONDS, AP2_JWK_MEMBERS, AP2_KEY_TYPE, AP2_SIGNING_ALGORITHM, AP2_JWK_CURVE, AP2_JWK_COORDINATE_BYTES, AP2_MAX_CLOCK_SKEW_SECONDS } from './chunk-6WACRJVT.js';
2
2
  import { readCappedBody, createBearerCheck, MCP_TOOL_NAME_PATTERN, settlementResponse, joinUrl, settlementResponseFromDetails, settlementFailure, x402ErrorCode, x402RefusalStatus } from './chunk-ES3V6ECS.js';
3
3
  import { MPP_DEFAULT_NETWORK, isMppNetwork, MPP_NETWORKS, MPP_DEFAULT_PAYMENT_FLOW, MPP_MIN_CHALLENGE_SECRET_LENGTH, MPP_PROFILE } from './chunk-6Z2H53CG.js';
4
4
  import { contentDigest, CONTENT_DIGEST_METADATA_KEY, mppProblem, mppProblemDetail } from './chunk-5ZYXBCDX.js';
5
- import { X402_PAYMENT_FLOWS, validateCustomNetworks, findX402Network, X402_DEFAULT_PAYMENT_FLOW, resolveX402Deployment, SETTLE_AFTER_BACKEND_METADATA_KEY, resolveDeploymentMode, requireX402Network, resolveX402Option, isEvmAddress, isEvmZeroAddress, x402OfferName, REUSE_REJECTED_AUTHORIZATION_METADATA_KEY } from './chunk-XVU46YAH.js';
6
- import { RESERVED_INPUT_FIELDS, PROTOCOL_NAMES, PAYMENT_METHOD_NAMES, PAYMENT_HEADER, AUTHORIZATION_HEADER, CommerceError, systemClock, NOOP_LOGGER, PACKAGE_VERSION, toCommerceError, DEFAULT_BACKEND_TIMEOUT_MS, isCommerceError, describeError, isHttpProtocolAdapter, toLogInfo, extractReservedInputFields, parseAuthorizationHeader, toPaymentRequiredEnvelope, PAYMENT_REQUIRED_HEADER, PAYMENT_RESPONSE_HEADER, toErrorEnvelope, DELIVERY_SUMMARY_META_KEY, toDeliverySummary, PAYMENT_INPUT_FIELD, AUTHORIZATION_INPUT_FIELD, parseAuthorizationSubmission } from './chunk-Q5TII32R.js';
7
- export { AUTHORIZATION_HEADER, AUTHORIZATION_INPUT_FIELD, COMMERCE_ERROR_CODES, COMMERCE_ERROR_HTTP_STATUS, COMMERCE_EVENT_TYPES, CommerceError, DEFAULT_BACKEND_TIMEOUT_MS, DELIVERY_SUMMARY_META_KEY, MAX_AUTHORIZATION_HEADER_BYTES, NOOP_LOGGER, PAYMENT_HEADER, PAYMENT_INPUT_FIELD, PAYMENT_METHOD_NAMES, PAYMENT_REQUIRED_HEADER, PAYMENT_RESPONSE_HEADER, PROTOCOL_NAMES, RESERVED_INPUT_FIELDS, RETRYABLE_ERROR_CODES, extractReservedInputFields, isCommerceError, isHttpProtocolAdapter, isPaymentRequiredEnvelope, parseAuthorizationHeader, parseAuthorizationSubmission, systemClock, toCommerceError, toDeliverySummary, toErrorEnvelope, toPaymentRequiredEnvelope } from './chunk-Q5TII32R.js';
5
+ import { X402_PAYMENT_FLOWS, validateCustomNetworks, findX402Network, X402_DEFAULT_PAYMENT_FLOW, resolveX402Deployment, SETTLE_AFTER_BACKEND_METADATA_KEY, resolveDeploymentMode, requireX402Network, resolveX402Option, isEvmAddress, isEvmZeroAddress, x402OfferName, REUSE_REJECTED_AUTHORIZATION_METADATA_KEY } from './chunk-4OEXK3YG.js';
6
+ import { RESERVED_INPUT_FIELDS, PROTOCOL_NAMES, PAYMENT_METHOD_NAMES, PAYMENT_HEADER, AUTHORIZATION_HEADER, CommerceError, systemClock, NOOP_LOGGER, PACKAGE_VERSION, toCommerceError, DEFAULT_BACKEND_TIMEOUT_MS, isCommerceError, describeError, isHttpProtocolAdapter, toLogInfo, extractReservedInputFields, parseAuthorizationHeader, toPaymentRequiredEnvelope, PAYMENT_REQUIRED_HEADER, PAYMENT_RESPONSE_HEADER, toErrorEnvelope, DELIVERY_SUMMARY_META_KEY, toDeliverySummary, PAYMENT_INPUT_FIELD, AUTHORIZATION_INPUT_FIELD, parseAuthorizationSubmission } from './chunk-AITMDXKW.js';
7
+ export { AUTHORIZATION_HEADER, AUTHORIZATION_INPUT_FIELD, COMMERCE_ERROR_CODES, COMMERCE_ERROR_HTTP_STATUS, COMMERCE_EVENT_TYPES, CommerceError, DEFAULT_BACKEND_TIMEOUT_MS, DELIVERY_SUMMARY_META_KEY, MAX_AUTHORIZATION_HEADER_BYTES, NOOP_LOGGER, PAYMENT_HEADER, PAYMENT_INPUT_FIELD, PAYMENT_METHOD_NAMES, PAYMENT_REQUIRED_HEADER, PAYMENT_RESPONSE_HEADER, PROTOCOL_NAMES, RESERVED_INPUT_FIELDS, RETRYABLE_ERROR_CODES, extractReservedInputFields, isCommerceError, isHttpProtocolAdapter, isPaymentRequiredEnvelope, parseAuthorizationHeader, parseAuthorizationSubmission, systemClock, toCommerceError, toDeliverySummary, toErrorEnvelope, toPaymentRequiredEnvelope } from './chunk-AITMDXKW.js';
8
8
  import { isRecord } from './chunk-2CJNA7MS.js';
9
9
  import { promises, accessSync, constants } from 'fs';
10
10
  import * as path from 'path';
@@ -725,6 +725,16 @@ function normalizeX402(raw, resources) {
725
725
  const resourceOptions = Object.fromEntries(
726
726
  Object.entries(resourceTerms).map(([id, terms]) => [id, terms.options])
727
727
  );
728
+ let quote;
729
+ if (raw.quote !== void 0 && toBoolean(raw.quote.enabled, `${at}.quote.enabled`)) {
730
+ if (raw.quote.signerPrivateKey === void 0) {
731
+ throw x402Invalid(
732
+ `${at}.quote.signerPrivateKey is required when quotes are enabled`,
733
+ `${at}.quote.signerPrivateKey`
734
+ );
735
+ }
736
+ quote = { signerPrivateKey: raw.quote.signerPrivateKey };
737
+ }
728
738
  const config = {
729
739
  enabled: toBoolean(raw.enabled, `${at}.enabled`),
730
740
  ...first,
@@ -735,7 +745,8 @@ function normalizeX402(raw, resources) {
735
745
  ...allowUnauthenticatedFacilitator !== void 0 ? { allowUnauthenticatedFacilitator } : {},
736
746
  ...networks !== void 0 ? { networks } : {},
737
747
  options,
738
- ...Object.keys(resourceOptions).length > 0 ? { resourceOptions } : {}
748
+ ...Object.keys(resourceOptions).length > 0 ? { resourceOptions } : {},
749
+ ...quote !== void 0 ? { quote } : {}
739
750
  };
740
751
  return { config, ...rail, resources: resourceTerms };
741
752
  }
@@ -1023,7 +1034,12 @@ var X402Schema = z.object({
1023
1034
  // Real funds. Never defaulted; see src/payments/x402/guardrails.ts
1024
1035
  allowMainnet: BooleanOrString.optional(),
1025
1036
  // Accepts credential-free facilitator access on mainnet. Never defaulted
1026
- allowUnauthenticatedFacilitator: BooleanOrString.optional()
1037
+ allowUnauthenticatedFacilitator: BooleanOrString.optional(),
1038
+ // Experimental ERC-8409 quotes; signing a quote transfers no funds
1039
+ quote: z.object({
1040
+ enabled: BooleanOrString,
1041
+ signerPrivateKey: z.string().min(1).optional()
1042
+ }).strict().optional()
1027
1043
  }).strict();
1028
1044
  var MppSchema = z.object({
1029
1045
  enabled: BooleanOrString,
@@ -1720,6 +1736,7 @@ function createPaymentAdmission(ctx, authorizeAndReserve) {
1720
1736
  amount: pricing.amount,
1721
1737
  currency: pricing.currency,
1722
1738
  requestedAt: options.clock.nowIso(),
1739
+ input: validInput,
1723
1740
  // Transport facts a rail may bind into its challenge, such as a body digest
1724
1741
  ...request.metadata !== void 0 ? { metadata: request.metadata } : {}
1725
1742
  });
@@ -3623,6 +3640,12 @@ function publicOffer(option, statuses) {
3623
3640
  function flowOverrides(flows) {
3624
3641
  return flows !== void 0 && Object.keys(flows).length > 0 ? { resourcePaymentFlows: flows } : {};
3625
3642
  }
3643
+ function publicQuote(providers) {
3644
+ const x402 = providers.find((provider) => provider.name === "x402");
3645
+ if (x402?.quote === void 0) return void 0;
3646
+ const { issuer, requestScheme, extension } = x402.quote;
3647
+ return { issuer, requestScheme, extension, status: "experimental" };
3648
+ }
3626
3649
  function buildWellKnownDocument(options) {
3627
3650
  const adapters = options.adapters.map(({ descriptor, health }) => ({
3628
3651
  ...descriptor,
@@ -3633,6 +3656,7 @@ function buildWellKnownDocument(options) {
3633
3656
  const offerStatuses = new Map(
3634
3657
  (x402Health?.components ?? []).map((component) => [component.name, component.status])
3635
3658
  );
3659
+ const quote = publicQuote(options.paymentProviders);
3636
3660
  return {
3637
3661
  gateway: {
3638
3662
  implementationVersion: PACKAGE_VERSION,
@@ -3672,7 +3696,8 @@ function buildWellKnownDocument(options) {
3672
3696
  list.map((option) => publicOffer(option, offerStatuses))
3673
3697
  ])
3674
3698
  )
3675
- } : {}
3699
+ } : {},
3700
+ ...quote !== void 0 ? { quote } : {}
3676
3701
  }
3677
3702
  } : {},
3678
3703
  ...mpp !== void 0 ? {