@devlab.group/agent-commerce 2.4.1 → 2.6.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.
- package/README.md +168 -16
- package/dist/ap2.d.ts +42 -17
- package/dist/ap2.js +83 -27
- package/dist/ap2.js.map +1 -1
- package/dist/{chunk-CXWC5LWM.js → chunk-DRLBML7Z.js} +661 -75
- package/dist/chunk-DRLBML7Z.js.map +1 -0
- package/dist/{chunk-WZW5ORZH.js → chunk-G3EYYHKF.js} +3 -3
- package/dist/{chunk-WZW5ORZH.js.map → chunk-G3EYYHKF.js.map} +1 -1
- package/dist/chunk-GA3O2A7R.js +92 -0
- package/dist/chunk-GA3O2A7R.js.map +1 -0
- package/dist/{chunk-DTKU3Z2M.js → chunk-M52FBNJX.js} +36 -5
- package/dist/chunk-M52FBNJX.js.map +1 -0
- package/dist/chunk-M6BSXXTF.js +8 -0
- package/dist/chunk-M6BSXXTF.js.map +1 -0
- package/dist/{chunk-QPV3EGJO.js → chunk-M6MQ3FYS.js} +25 -4
- package/dist/chunk-M6MQ3FYS.js.map +1 -0
- package/dist/chunk-M6WW6QIT.js +18 -0
- package/dist/chunk-M6WW6QIT.js.map +1 -0
- package/dist/cli/{ap2-GWSP4LYY.js → ap2-2YMYA2H6.js} +85 -29
- package/dist/cli/ap2-2YMYA2H6.js.map +1 -0
- package/dist/cli/{chunk-OZ4LAWBK.js → chunk-3NOMLMJW.js} +29 -8
- package/dist/cli/chunk-3NOMLMJW.js.map +1 -0
- package/dist/cli/chunk-4KLYFXMW.js +8 -0
- package/dist/cli/{chunk-ITWNSS2B.js.map → chunk-4KLYFXMW.js.map} +1 -1
- package/dist/cli/chunk-663ALDZA.js +92 -0
- package/dist/cli/chunk-663ALDZA.js.map +1 -0
- package/dist/cli/chunk-6R6WJ4FD.js +18 -0
- package/dist/cli/chunk-6R6WJ4FD.js.map +1 -0
- package/dist/cli/{chunk-G2JEY7MB.js → chunk-AZL7RPFU.js} +39 -33
- package/dist/cli/chunk-AZL7RPFU.js.map +1 -0
- package/dist/cli/chunk-DHFMIBPG.js +107 -0
- package/dist/cli/chunk-DHFMIBPG.js.map +1 -0
- package/dist/cli/{chunk-QQ3WY5L3.js → chunk-GET3CZGR.js} +36 -104
- package/dist/cli/chunk-GET3CZGR.js.map +1 -0
- package/dist/cli/chunk-NSYSMDQN.js +1544 -0
- package/dist/cli/chunk-NSYSMDQN.js.map +1 -0
- package/dist/cli/{chunk-PIMFPCNZ.js → chunk-PTL7SNOI.js} +313 -138
- package/dist/cli/chunk-PTL7SNOI.js.map +1 -0
- package/dist/cli/chunk-SYQLJXIU.js +105 -0
- package/dist/cli/chunk-SYQLJXIU.js.map +1 -0
- package/dist/cli/chunk-TFV3K6YS.js +373 -0
- package/dist/cli/chunk-TFV3K6YS.js.map +1 -0
- package/dist/cli/{chunk-3MGAJ5FX.js → chunk-VJ4EO4LE.js} +3 -3
- package/dist/cli/{chunk-3MGAJ5FX.js.map → chunk-VJ4EO4LE.js.map} +1 -1
- package/dist/cli/chunk-VJH6RYRK.js +119 -0
- package/dist/cli/chunk-VJH6RYRK.js.map +1 -0
- package/dist/cli/{chunk-TNMLDPUO.js → chunk-YOF7IK4V.js} +663 -77
- package/dist/cli/chunk-YOF7IK4V.js.map +1 -0
- package/dist/cli/{chunk-WYOGIANL.js → chunk-YWG2ZN3L.js} +4 -4
- package/dist/cli/{chunk-WYOGIANL.js.map → chunk-YWG2ZN3L.js.map} +1 -1
- package/dist/cli/config-3K65QJ22.js +12 -0
- package/dist/cli/{config-UI4EDG4L.js.map → config-3K65QJ22.js.map} +1 -1
- package/dist/cli/index.js +753 -212
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/{mcp-PGBRWZVA.js → mcp-6F64A7KE.js} +5 -4
- package/dist/cli/mcp-6F64A7KE.js.map +1 -0
- package/dist/cli/{near-5AY3HWYF.js → near-U6365VFX.js} +15 -4
- package/dist/cli/near-U6365VFX.js.map +1 -0
- package/dist/cli/payment-providers-2ITS6KNR.js +6 -0
- package/dist/cli/payment-providers-2ITS6KNR.js.map +1 -0
- package/dist/cli/{provider-I2ESL6RS.js → provider-5BGG5YKQ.js} +53 -24
- package/dist/cli/provider-5BGG5YKQ.js.map +1 -0
- package/dist/cli/receipts-I4IIE7U6.js +8 -0
- package/dist/cli/receipts-I4IIE7U6.js.map +1 -0
- package/dist/cli/reconcile-55WNCSFC.js +4 -0
- package/dist/cli/reconcile-55WNCSFC.js.map +1 -0
- package/dist/cli/{run-JK4ERPJV.js → run-2P6ZGFUE.js} +356 -173
- package/dist/cli/run-2P6ZGFUE.js.map +1 -0
- package/dist/cli/svm-KDSPDFJG.js +48 -0
- package/dist/cli/svm-KDSPDFJG.js.map +1 -0
- package/dist/cli/{x402-7WBFZQXV.js → x402-4LPIIELI.js} +10 -9
- package/dist/cli/x402-4LPIIELI.js.map +1 -0
- package/dist/index.d.ts +116 -113
- package/dist/index.js +1928 -351
- package/dist/index.js.map +1 -1
- package/dist/logger-CllGwQ8i.d.ts +19 -0
- package/dist/mcp.d.ts +3 -2
- package/dist/mcp.js +2 -1
- package/dist/mcp.js.map +1 -1
- package/dist/mpp.d.ts +2 -1
- package/dist/mpp.js +48 -19
- package/dist/mpp.js.map +1 -1
- package/dist/{near-D6C42VPE.js → near-FH7HPZV3.js} +15 -4
- package/dist/near-FH7HPZV3.js.map +1 -0
- package/dist/{protocol-adapter-C9odYl6l.d.ts → protocol-adapter-1WbtM3xG.d.ts} +12 -85
- package/dist/{runtime-Cl_BLVZV.d.ts → runtime-B-kARa2f.d.ts} +218 -15
- package/dist/store-kIIMpUA-.d.ts +372 -0
- package/dist/svm-KNC3PHMS.js +48 -0
- package/dist/svm-KNC3PHMS.js.map +1 -0
- package/dist/testing.d.ts +51 -0
- package/dist/testing.js +1896 -0
- package/dist/testing.js.map +1 -0
- package/dist/transaction-Dv0UFGg5.d.ts +129 -0
- package/dist/{types-j7MnUXYN.d.ts → types-DWqjz81-.d.ts} +5 -2
- package/dist/x402.d.ts +2 -1
- package/dist/x402.js +6 -5
- package/dist/x402.js.map +1 -1
- package/package.json +5 -1
- package/dist/authorization-DjAecwuW.d.ts +0 -115
- package/dist/chunk-CXWC5LWM.js.map +0 -1
- package/dist/chunk-DTKU3Z2M.js.map +0 -1
- package/dist/chunk-KA2AX5FH.js +0 -44
- package/dist/chunk-KA2AX5FH.js.map +0 -1
- package/dist/chunk-QPV3EGJO.js.map +0 -1
- package/dist/cli/ap2-GWSP4LYY.js.map +0 -1
- package/dist/cli/chunk-G2JEY7MB.js.map +0 -1
- package/dist/cli/chunk-GJIMDMYT.js +0 -639
- package/dist/cli/chunk-GJIMDMYT.js.map +0 -1
- package/dist/cli/chunk-ITWNSS2B.js +0 -8
- package/dist/cli/chunk-OSTCU6ZK.js +0 -44
- package/dist/cli/chunk-OSTCU6ZK.js.map +0 -1
- package/dist/cli/chunk-OZ4LAWBK.js.map +0 -1
- package/dist/cli/chunk-PIMFPCNZ.js.map +0 -1
- package/dist/cli/chunk-QQ3WY5L3.js.map +0 -1
- package/dist/cli/chunk-TNMLDPUO.js.map +0 -1
- package/dist/cli/config-UI4EDG4L.js +0 -11
- package/dist/cli/mcp-PGBRWZVA.js.map +0 -1
- package/dist/cli/near-5AY3HWYF.js.map +0 -1
- package/dist/cli/provider-I2ESL6RS.js.map +0 -1
- package/dist/cli/run-JK4ERPJV.js.map +0 -1
- package/dist/cli/svm-3MMYFPC7.js +0 -33
- package/dist/cli/svm-3MMYFPC7.js.map +0 -1
- package/dist/cli/x402-7WBFZQXV.js.map +0 -1
- package/dist/near-D6C42VPE.js.map +0 -1
- package/dist/svm-QEUAUNPQ.js +0 -33
- package/dist/svm-QEUAUNPQ.js.map +0 -1
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { LOCATOR_VERSION, computeSvmReplayKey } from './chunk-663ALDZA.js';
|
|
2
|
+
import { isRecord } from './chunk-3M6U7ILB.js';
|
|
3
|
+
import { getAddressEncoder, getProgramDerivedAddress, address, getCompiledTransactionMessageDecoder } from '@solana/kit';
|
|
4
|
+
import { decodeTransactionFromPayload, transactionMessageHash } from '@x402/svm';
|
|
5
|
+
|
|
6
|
+
var MAX_TRANSACTION_BASE64 = 1644;
|
|
7
|
+
var ASSOCIATED_TOKEN_PROGRAM = "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL";
|
|
8
|
+
async function associatedTokenAccount(owner, mint, tokenProgram) {
|
|
9
|
+
const encoder = getAddressEncoder();
|
|
10
|
+
const [account] = await getProgramDerivedAddress({
|
|
11
|
+
programAddress: address(ASSOCIATED_TOKEN_PROGRAM),
|
|
12
|
+
seeds: [owner, tokenProgram, mint].map((key) => encoder.encode(address(key)))
|
|
13
|
+
});
|
|
14
|
+
return account;
|
|
15
|
+
}
|
|
16
|
+
function inspectSvmPayload(payload, network) {
|
|
17
|
+
if (!isRecord(payload)) return "invalid_exact_svm_payload_transaction";
|
|
18
|
+
const transaction = payload["transaction"];
|
|
19
|
+
if (typeof transaction !== "string" || transaction.length > MAX_TRANSACTION_BASE64) {
|
|
20
|
+
return "invalid_exact_svm_payload_transaction";
|
|
21
|
+
}
|
|
22
|
+
let messageHash;
|
|
23
|
+
let recentBlockhash;
|
|
24
|
+
try {
|
|
25
|
+
const decoded = decodeTransactionFromPayload({ transaction });
|
|
26
|
+
messageHash = transactionMessageHash(decoded);
|
|
27
|
+
recentBlockhash = getCompiledTransactionMessageDecoder().decode(
|
|
28
|
+
decoded.messageBytes
|
|
29
|
+
).lifetimeToken;
|
|
30
|
+
} catch {
|
|
31
|
+
return "invalid_exact_svm_payload_transaction_could_not_be_decoded";
|
|
32
|
+
}
|
|
33
|
+
return {
|
|
34
|
+
replayKey: computeSvmReplayKey({ network, messageHash }),
|
|
35
|
+
locator: { v: LOCATOR_VERSION, network, messageHash, recentBlockhash }
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
function messageHashOf(transaction) {
|
|
39
|
+
try {
|
|
40
|
+
return transactionMessageHash(decodeTransactionFromPayload({ transaction }));
|
|
41
|
+
} catch {
|
|
42
|
+
return void 0;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export { associatedTokenAccount, inspectSvmPayload, messageHashOf };
|
|
47
|
+
//# sourceMappingURL=svm-KDSPDFJG.js.map
|
|
48
|
+
//# sourceMappingURL=svm-KDSPDFJG.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/payments/x402/svm.ts"],"names":[],"mappings":";;;;;AAsBA,IAAM,sBAAA,GAAyB,IAAA;AAE/B,IAAM,wBAAA,GAA2B,8CAAA;AAMjC,eAAsB,sBAAA,CACpB,KAAA,EACA,IAAA,EACA,YAAA,EACiB;AACjB,EAAA,MAAM,UAAU,iBAAA,EAAkB;AAClC,EAAA,MAAM,CAAC,OAAO,CAAA,GAAI,MAAM,wBAAA,CAAyB;AAAA,IAC/C,cAAA,EAAgB,QAAQ,wBAAwB,CAAA;AAAA,IAChD,KAAA,EAAO,CAAC,KAAA,EAAO,YAAA,EAAc,IAAI,CAAA,CAAE,GAAA,CAAI,CAAC,GAAA,KAAQ,OAAA,CAAQ,MAAA,CAAO,OAAA,CAAQ,GAAG,CAAC,CAAC;AAAA,GAC7E,CAAA;AACD,EAAA,OAAO,OAAA;AACT;AAOO,SAAS,iBAAA,CACd,SACA,OAAA,EAC8F;AAC9F,EAAA,IAAI,CAAC,QAAA,CAAS,OAAO,CAAA,EAAG,OAAO,uCAAA;AAC/B,EAAA,MAAM,WAAA,GAAc,QAAQ,aAAa,CAAA;AACzC,EAAA,IAAI,OAAO,WAAA,KAAgB,QAAA,IAAY,WAAA,CAAY,SAAS,sBAAA,EAAwB;AAClF,IAAA,OAAO,uCAAA;AAAA,EACT;AACA,EAAA,IAAI,WAAA;AACJ,EAAA,IAAI,eAAA;AACJ,EAAA,IAAI;AACF,IAAA,MAAM,OAAA,GAAU,4BAAA,CAA6B,EAAE,WAAA,EAAa,CAAA;AAC5D,IAAA,WAAA,GAAc,uBAAuB,OAAO,CAAA;AAC5C,IAAA,eAAA,GAAkB,sCAAqC,CAAE,MAAA;AAAA,MACvD,OAAA,CAAQ;AAAA,KACV,CAAE,aAAA;AAAA,EACJ,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,4DAAA;AAAA,EACT;AACA,EAAA,OAAO;AAAA,IACL,SAAA,EAAW,mBAAA,CAAoB,EAAE,OAAA,EAAS,aAAa,CAAA;AAAA,IACvD,SAAS,EAAE,CAAA,EAAG,eAAA,EAAiB,OAAA,EAAS,aAAa,eAAA;AAAgB,GACvE;AACF;AAMO,SAAS,cAAc,WAAA,EAAyC;AACrE,EAAA,IAAI;AACF,IAAA,OAAO,sBAAA,CAAuB,4BAAA,CAA6B,EAAE,WAAA,EAAa,CAAC,CAAA;AAAA,EAC7E,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,MAAA;AAAA,EACT;AACF","file":"svm-KDSPDFJG.js","sourcesContent":["/**\n * Solana `exact` payload inspection with bounded decoding, replay identity and\n * reconciliation coordinates. The provider loads this module, including its\n * `@x402/svm` and `@solana/kit` imports, when a Solana offer is configured.\n *\n * The facilitator checks the transaction itself: the fee payer, signatures,\n * instruction layout, mint, recipient token account and amount, and a\n * simulation. Its smart-wallet path accepts layouts the gateway could not\n * parse, so the gateway does not read the transfer.\n */\nimport {\n address,\n getAddressEncoder,\n getCompiledTransactionMessageDecoder,\n getProgramDerivedAddress,\n} from '@solana/kit';\nimport { decodeTransactionFromPayload, transactionMessageHash } from '@x402/svm';\nimport { isRecord } from '../../core/is-record';\nimport { LOCATOR_VERSION } from './locator';\nimport { computeSvmReplayKey } from './replay-key';\n\n// A Solana transaction fits a 1232-byte packet, which is 1644 base64 characters\nconst MAX_TRANSACTION_BASE64 = 1644;\n\nconst ASSOCIATED_TOKEN_PROGRAM = 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL';\n\n/**\n * The associated token account of `owner` for `mint`, where the SDK client\n * sends a Solana `exact` payment. Its transaction cannot create the account.\n */\nexport async function associatedTokenAccount(\n owner: string,\n mint: string,\n tokenProgram: string,\n): Promise<string> {\n const encoder = getAddressEncoder();\n const [account] = await getProgramDerivedAddress({\n programAddress: address(ASSOCIATED_TOKEN_PROGRAM),\n seeds: [owner, tokenProgram, mint].map((key) => encoder.encode(address(key))),\n });\n return account;\n}\n\n/**\n * Returns the Solana `exact` replay key and locator, or an SDK refusal reason\n * for a missing, oversized or undecodable transaction. The provider adds the\n * payer from the facilitator's verdict when a usable address is available.\n */\nexport function inspectSvmPayload(\n payload: unknown,\n network: string,\n): { readonly replayKey: string; readonly locator: Readonly<Record<string, unknown>> } | string {\n if (!isRecord(payload)) return 'invalid_exact_svm_payload_transaction';\n const transaction = payload['transaction'];\n if (typeof transaction !== 'string' || transaction.length > MAX_TRANSACTION_BASE64) {\n return 'invalid_exact_svm_payload_transaction';\n }\n let messageHash: string;\n let recentBlockhash: string;\n try {\n const decoded = decodeTransactionFromPayload({ transaction });\n messageHash = transactionMessageHash(decoded);\n recentBlockhash = getCompiledTransactionMessageDecoder().decode(\n decoded.messageBytes,\n ).lifetimeToken;\n } catch {\n return 'invalid_exact_svm_payload_transaction_could_not_be_decoded';\n }\n return {\n replayKey: computeSvmReplayKey({ network, messageHash }),\n locator: { v: LOCATOR_VERSION, network, messageHash, recentBlockhash },\n };\n}\n\n/**\n * Returns the message hash of base64 transaction bytes using the same decoder\n * as payment inspection, or undefined if decoding or hashing fails\n */\nexport function messageHashOf(transaction: string): string | undefined {\n try {\n return transactionMessageHash(decodeTransactionFromPayload({ transaction }));\n } catch {\n return undefined;\n }\n}\n"]}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { chainIdFromCaip2 } from './chunk-
|
|
2
|
-
export { createX402PaymentProvider } from './chunk-
|
|
3
|
-
import './chunk-
|
|
4
|
-
export { SUPPORTED_NETWORK_IDS } from './chunk-
|
|
5
|
-
import './chunk-
|
|
6
|
-
import './chunk-
|
|
7
|
-
import { CommerceError } from './chunk-
|
|
1
|
+
import { chainIdFromCaip2 } from './chunk-YOF7IK4V.js';
|
|
2
|
+
export { createX402PaymentProvider } from './chunk-YOF7IK4V.js';
|
|
3
|
+
import './chunk-YWG2ZN3L.js';
|
|
4
|
+
export { SUPPORTED_NETWORK_IDS } from './chunk-3NOMLMJW.js';
|
|
5
|
+
import './chunk-4KLYFXMW.js';
|
|
6
|
+
import './chunk-GET3CZGR.js';
|
|
7
|
+
import { CommerceError } from './chunk-SYQLJXIU.js';
|
|
8
|
+
import './chunk-663ALDZA.js';
|
|
8
9
|
import './chunk-3M6U7ILB.js';
|
|
9
10
|
import { PaymentRequirementsV2Schema } from '@x402/core/schemas';
|
|
10
11
|
import { getAddress, toHex } from 'viem';
|
|
@@ -92,5 +93,5 @@ function randomNonce() {
|
|
|
92
93
|
}
|
|
93
94
|
|
|
94
95
|
export { createPaymentProof };
|
|
95
|
-
//# sourceMappingURL=x402-
|
|
96
|
-
//# sourceMappingURL=x402-
|
|
96
|
+
//# sourceMappingURL=x402-4LPIIELI.js.map
|
|
97
|
+
//# sourceMappingURL=x402-4LPIIELI.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/payments/x402/client.ts"],"names":[],"mappings":"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","file":"x402-4LPIIELI.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"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { Ap2AuthorizationConfig } from './ap2.js';
|
|
2
|
-
import { I as IsoTimestamp, D as DecimalAmount, P as PaymentMethodName, a as
|
|
3
|
-
export {
|
|
2
|
+
import { I as IsoTimestamp, D as DecimalAmount, P as PaymentMethodName, a as AuthorizationRequirement, b as CommerceResource, c as PaymentSubmission, d as AuthorizationSubmission, B as BackendHandler, R as ResourceRegistry, e as PaymentProvider, A as AuthorizationProvider, C as Clock, f as IdGenerator, g as AdapterDescriptor, h as AdapterHealth } from './runtime-B-kARa2f.js';
|
|
3
|
+
export { i as AdapterHealthComponent, j as AuthorizationFinalizeContext, k as AuthorizationMethodName, l as AuthorizationRecord, m as AuthorizationVerification, n as AuthorizationVerificationContext, o as BackendMethod, p as CommerceReceipt, q as DEFAULT_BACKEND_TIMEOUT_MS, J as JsonSchema, r as PAYMENT_METHOD_NAMES, s as PROTOCOL_NAMES, t as PaymentAttempt, u as PaymentAttemptResolution, v as PaymentChallenge, w as PaymentContext, x as PaymentReconciliationContext, y as PaymentReconciliationResult, z as PaymentRequirement, E as PaymentResult, F as PaymentSettlementContext, G as PaymentVerificationContext, H as Pricing, K as ProtocolName, L as RECONCILIATION_METADATA_KEY, M as systemClock } from './runtime-B-kARa2f.js';
|
|
4
4
|
import { M as MppNetwork } from './constants-BG22tE8S.js';
|
|
5
5
|
import { X402PaymentFlow, X402FacilitatorConfig } from './x402.js';
|
|
6
6
|
import { C as CustomNetworks } from './networks-DDHYJLcg.js';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
export { A as AuthorizationHoldState, C as COMMERCE_EVENT_TYPES, a as CommerceEvent, b as CommerceEventType, E as EventSink, P as PersistenceFailure, T as TRANSACTION_STATES, c as Transaction, d as TransactionFacts, e as TransactionState, t as transactionState } from './transaction-Dv0UFGg5.js';
|
|
8
|
+
import { D as DeliveredOutcome, P as PaymentRequiredOutcome, E as ExecutionPipeline, a as ProtocolAdapter, H as HttpProtocolAdapter, A as AdapterHttpRoute, b as ProtocolAdapterContext } from './protocol-adapter-1WbtM3xG.js';
|
|
9
|
+
export { C as CanonicalRequest, c as ExecutionOutcome, i as isHttpProtocolAdapter } from './protocol-adapter-1WbtM3xG.js';
|
|
10
|
+
import { R as ReceiptStore } from './store-kIIMpUA-.js';
|
|
11
|
+
export { A as AuthorizationHold, a as AuthorizationHoldReservation, b as AuthorizationHoldResult, I as IdempotencyClaim, c as IdempotencyScope, d as IdempotencyUpdate, L as ListOptions, N as NewTransaction, P as PaymentAttemptListOptions, e as PaymentAttemptReservation, f as PaymentAttemptResolveRequest, g as PaymentAttemptUpdate, h as PendingTask, i as ReceiptListOptions, T as TransactionListOptions, j as TransactionPage, k as TransactionStep } from './store-kIIMpUA-.js';
|
|
12
|
+
import { L as Logger } from './logger-CllGwQ8i.js';
|
|
13
|
+
export { N as NOOP_LOGGER } from './logger-CllGwQ8i.js';
|
|
11
14
|
import { FastifyInstance } from 'fastify';
|
|
12
15
|
import { IncomingMessage, ServerResponse } from 'node:http';
|
|
13
16
|
|
|
@@ -154,13 +157,19 @@ interface PaymentRequiredEnvelope {
|
|
|
154
157
|
readonly amount: DecimalAmount;
|
|
155
158
|
readonly currency: string;
|
|
156
159
|
/**
|
|
157
|
-
* @deprecated Read
|
|
158
|
-
*
|
|
160
|
+
* @deprecated Read `accepts`: x402 offers use `payTo`; MPP challenges use
|
|
161
|
+
* `request.recipient`. Omitted for multi-offer x402 challenges.
|
|
159
162
|
*/
|
|
160
163
|
readonly destination?: string;
|
|
161
|
-
/**
|
|
164
|
+
/**
|
|
165
|
+
* @deprecated Read `accepts`: x402 offers use `network`; MPP challenges use
|
|
166
|
+
* the numeric `request.methodDetails.chainId`
|
|
167
|
+
*/
|
|
162
168
|
readonly network?: string;
|
|
163
|
-
/**
|
|
169
|
+
/**
|
|
170
|
+
* @deprecated Read `accepts`: x402 offers use `asset`; MPP challenges use
|
|
171
|
+
* `request.currency`
|
|
172
|
+
*/
|
|
164
173
|
readonly asset?: string;
|
|
165
174
|
readonly expiresAt?: IsoTimestamp;
|
|
166
175
|
/** Provider-native requirement objects, passed through verbatim */
|
|
@@ -202,6 +211,8 @@ interface DeliverySummary {
|
|
|
202
211
|
readonly requestId: string;
|
|
203
212
|
readonly resourceId: string;
|
|
204
213
|
readonly receiptId: string;
|
|
214
|
+
/** `false` marks a failed receipt write; do not treat `receiptId` as proof of persistence */
|
|
215
|
+
readonly receiptCommitted?: false;
|
|
205
216
|
readonly deliveredAt: IsoTimestamp;
|
|
206
217
|
readonly payment?: {
|
|
207
218
|
readonly status: 'verified' | 'settled' | 'rejected';
|
|
@@ -296,103 +307,6 @@ interface BackendExecutor {
|
|
|
296
307
|
call(handler: BackendHandler, request: BackendRequest): Promise<BackendResponse>;
|
|
297
308
|
}
|
|
298
309
|
|
|
299
|
-
/**
|
|
300
|
-
* Persistence boundary for receipts, events and payment attempts, implemented
|
|
301
|
-
* by src/storage/receipts. Core depends only on this interface, never on
|
|
302
|
-
* SQLite.
|
|
303
|
-
*/
|
|
304
|
-
|
|
305
|
-
interface PaymentAttemptReservation {
|
|
306
|
-
readonly requestId: string;
|
|
307
|
-
readonly resourceId: string;
|
|
308
|
-
readonly provider: string;
|
|
309
|
-
/** Must be unique across the store; see `PaymentResult.replayKey` */
|
|
310
|
-
readonly replayKey: string;
|
|
311
|
-
readonly amount: string;
|
|
312
|
-
readonly currency: string;
|
|
313
|
-
readonly payer?: string;
|
|
314
|
-
readonly payee?: string;
|
|
315
|
-
/**
|
|
316
|
-
* Reclaim this `replayKey` if the same `provider` rejected it, which
|
|
317
|
-
* settled nothing. Set only for rails whose authorizations remain reusable
|
|
318
|
-
* until settled.
|
|
319
|
-
*/
|
|
320
|
-
readonly reclaimRejected?: boolean;
|
|
321
|
-
}
|
|
322
|
-
interface PaymentAttemptUpdate {
|
|
323
|
-
readonly replayKey: string;
|
|
324
|
-
readonly status: PaymentAttempt['status'];
|
|
325
|
-
readonly externalReference?: string;
|
|
326
|
-
readonly rejectionReason?: string;
|
|
327
|
-
}
|
|
328
|
-
interface ListOptions {
|
|
329
|
-
readonly limit?: number;
|
|
330
|
-
readonly requestId?: string;
|
|
331
|
-
}
|
|
332
|
-
interface ReceiptListOptions extends ListOptions {
|
|
333
|
-
/**
|
|
334
|
-
* When true, return only receipts counted by {@link ReceiptStore.countUndeliveredReceipts}.
|
|
335
|
-
* Stores ignoring this flag also return delivered receipts.
|
|
336
|
-
*/
|
|
337
|
-
readonly undelivered?: boolean;
|
|
338
|
-
}
|
|
339
|
-
interface PaymentAttemptListOptions extends ListOptions {
|
|
340
|
-
/**
|
|
341
|
-
* When true, return only attempts counted by {@link ReceiptStore.countUncertainPaymentAttempts}.
|
|
342
|
-
* Stores that ignore this flag do not filter by settlement status.
|
|
343
|
-
*/
|
|
344
|
-
readonly uncertain?: boolean;
|
|
345
|
-
}
|
|
346
|
-
interface ReceiptStore {
|
|
347
|
-
init(): Promise<void>;
|
|
348
|
-
/** Append a canonical event. Must not throw into the caller's flow */
|
|
349
|
-
appendEvent(event: CommerceEvent): Promise<void>;
|
|
350
|
-
/**
|
|
351
|
-
* Atomically reserve a payment authorization before settlement. If its
|
|
352
|
-
* `replayKey` is already reserved, throws `CommerceError('PAYMENT_REPLAYED')`
|
|
353
|
-
* with the existing attempt's `PaymentAttempt.status` in
|
|
354
|
-
* `details.attemptStatus` when available.
|
|
355
|
-
*
|
|
356
|
-
* With `reclaimRejected`, replace the same provider's `rejected` attempt,
|
|
357
|
-
* which settled nothing. Only one concurrent claim can replace it with the
|
|
358
|
-
* new reservation.
|
|
359
|
-
*/
|
|
360
|
-
reservePaymentAttempt(reservation: PaymentAttemptReservation): Promise<PaymentAttempt>;
|
|
361
|
-
updatePaymentAttempt(update: PaymentAttemptUpdate): Promise<void>;
|
|
362
|
-
saveReceipt(receipt: CommerceReceipt): Promise<void>;
|
|
363
|
-
getReceipt(id: string): Promise<CommerceReceipt | undefined>;
|
|
364
|
-
listReceipts(options?: ReceiptListOptions): Promise<readonly CommerceReceipt[]>;
|
|
365
|
-
/**
|
|
366
|
-
* Total receipts held. `listReceipts` clamps every page, so counting a list's
|
|
367
|
-
* length would stop at the clamp.
|
|
368
|
-
*/
|
|
369
|
-
countReceipts(): Promise<number>;
|
|
370
|
-
/**
|
|
371
|
-
* Receipts whose delivery failed: `backendStatus` outside 2xx, including 0
|
|
372
|
-
* when no status is known. Counted rather than listed for the same reason as
|
|
373
|
-
* {@link countReceipts}.
|
|
374
|
-
*
|
|
375
|
-
* In practice this is "paid but undelivered": the pipeline writes a receipt
|
|
376
|
-
* for a failed delivery only after a settled payment, so a free resource
|
|
377
|
-
* whose backend fails leaves no row here. It is the row a merchant must
|
|
378
|
-
* notice, because settlement is final and the gateway issues no refunds.
|
|
379
|
-
*/
|
|
380
|
-
countUndeliveredReceipts(): Promise<number>;
|
|
381
|
-
/**
|
|
382
|
-
* Counts `settlement-uncertain` and legacy `failed` payment attempts.
|
|
383
|
-
* Funds may have moved, but the pipeline withholds delivery and writes no
|
|
384
|
-
* receipt for an uncertain settlement. {@link countUndeliveredReceipts}
|
|
385
|
-
* therefore misses these attempts. Reconcile them on chain using
|
|
386
|
-
* `externalReference` when it holds a transaction hash.
|
|
387
|
-
*/
|
|
388
|
-
countUncertainPaymentAttempts(): Promise<number>;
|
|
389
|
-
listEvents(options?: ListOptions): Promise<readonly CommerceEvent[]>;
|
|
390
|
-
listPaymentAttempts(options?: PaymentAttemptListOptions): Promise<readonly PaymentAttempt[]>;
|
|
391
|
-
readonly descriptor: AdapterDescriptor;
|
|
392
|
-
health(): Promise<AdapterHealth>;
|
|
393
|
-
close(): Promise<void>;
|
|
394
|
-
}
|
|
395
|
-
|
|
396
310
|
/**
|
|
397
311
|
* ACP protocol constants shared by the config layer and the adapter.
|
|
398
312
|
*
|
|
@@ -442,7 +356,11 @@ type AcpProtocolConfig = {
|
|
|
442
356
|
readonly token: string;
|
|
443
357
|
};
|
|
444
358
|
readonly idempotency: {
|
|
445
|
-
|
|
359
|
+
/**
|
|
360
|
+
* Legacy file for CLI import or an ACP adapter's file fallback.
|
|
361
|
+
* @deprecated Use the receipt store; removal of this key is planned for 3.0.0.
|
|
362
|
+
*/
|
|
363
|
+
readonly path?: string;
|
|
446
364
|
readonly retentionHours: number;
|
|
447
365
|
readonly merchantIdempotent: boolean;
|
|
448
366
|
};
|
|
@@ -597,6 +515,10 @@ interface GatewayInstance {
|
|
|
597
515
|
listen(): Promise<{
|
|
598
516
|
url: string;
|
|
599
517
|
}>;
|
|
518
|
+
/**
|
|
519
|
+
* Stops accepting connections and drains in-flight requests before stopping
|
|
520
|
+
* adapters, then resolves when both are done.
|
|
521
|
+
*/
|
|
600
522
|
close(): Promise<void>;
|
|
601
523
|
/** Fastify instance, for `.inject()` in tests */
|
|
602
524
|
readonly server: FastifyInstance;
|
|
@@ -610,6 +532,12 @@ interface A2aAdapterOptions {
|
|
|
610
532
|
readonly agentDescription?: string;
|
|
611
533
|
/** Version published on the card. Defaults to this package's version */
|
|
612
534
|
readonly agentVersion?: string;
|
|
535
|
+
/**
|
|
536
|
+
* Stores x402 tasks awaiting payment when all pending-task methods are
|
|
537
|
+
* present. Durable stores can preserve unexpired tasks across restarts;
|
|
538
|
+
* otherwise tasks stay in memory. The adapter never closes this store.
|
|
539
|
+
*/
|
|
540
|
+
readonly store?: ReceiptStore;
|
|
613
541
|
}
|
|
614
542
|
declare class A2aProtocolAdapter implements HttpProtocolAdapter {
|
|
615
543
|
readonly name: "a2a";
|
|
@@ -619,6 +547,7 @@ declare class A2aProtocolAdapter implements HttpProtocolAdapter {
|
|
|
619
547
|
private readonly agentName;
|
|
620
548
|
private readonly agentDescription;
|
|
621
549
|
private readonly agentVersion;
|
|
550
|
+
private readonly store;
|
|
622
551
|
private context;
|
|
623
552
|
private started;
|
|
624
553
|
private skillsById;
|
|
@@ -687,9 +616,19 @@ interface AcpAdapterOptions {
|
|
|
687
616
|
readonly token: string;
|
|
688
617
|
/** Which canonical resource implements each ACP checkout operation */
|
|
689
618
|
readonly operations: Readonly<Record<AcpCheckoutOperation, string>>;
|
|
690
|
-
/**
|
|
619
|
+
/**
|
|
620
|
+
* Holds checkout idempotency claims when it implements the idempotency
|
|
621
|
+
* methods. The adapter never closes it.
|
|
622
|
+
*/
|
|
623
|
+
readonly store?: ReceiptStore;
|
|
624
|
+
/** How long checkout idempotency records are kept, and the file fallback */
|
|
691
625
|
readonly idempotency: {
|
|
692
|
-
|
|
626
|
+
/**
|
|
627
|
+
* Required when no suitable `store` is supplied; the adapter opens and
|
|
628
|
+
* closes this fallback file itself.
|
|
629
|
+
* @deprecated Pass a receipt store. Configured gateways use this path for legacy import.
|
|
630
|
+
*/
|
|
631
|
+
readonly path?: string;
|
|
693
632
|
readonly retentionHours: number;
|
|
694
633
|
/**
|
|
695
634
|
* Declare that the merchant deduplicates by the derived `Idempotency-Key`.
|
|
@@ -713,13 +652,16 @@ declare class AcpProtocolAdapter implements HttpProtocolAdapter {
|
|
|
713
652
|
*/
|
|
714
653
|
private deployment;
|
|
715
654
|
private readonly discoveryMetadata;
|
|
655
|
+
private readonly store;
|
|
716
656
|
private idempotency;
|
|
657
|
+
private fileStore;
|
|
717
658
|
private resources;
|
|
718
659
|
private context;
|
|
719
660
|
private started;
|
|
720
661
|
private discovery;
|
|
721
662
|
constructor(options: AcpAdapterOptions);
|
|
722
663
|
start(context: ProtocolAdapterContext): Promise<void>;
|
|
664
|
+
private openIdempotency;
|
|
723
665
|
/** `GET /.well-known/acp.json`: public, unauthenticated, cacheable */
|
|
724
666
|
handleDiscovery(req: IncomingMessage, res: ServerResponse): Promise<void>;
|
|
725
667
|
/** `<mountPath>/checkout_sessions...`: the five stable checkout routes */
|
|
@@ -738,14 +680,75 @@ declare class AcpProtocolAdapter implements HttpProtocolAdapter {
|
|
|
738
680
|
}
|
|
739
681
|
declare function createAcpAdapter(options: AcpAdapterOptions): AcpProtocolAdapter;
|
|
740
682
|
|
|
683
|
+
/** Deprecated store files to import. Experimental: through 2.x only */
|
|
684
|
+
interface LegacyStoreOptions {
|
|
685
|
+
/** Deprecated `authorization.ap2.replay.path` */
|
|
686
|
+
readonly ap2Replay?: string;
|
|
687
|
+
/** Deprecated `protocols.acp.idempotency.path` */
|
|
688
|
+
readonly acpIdempotency?: string;
|
|
689
|
+
/**
|
|
690
|
+
* Enabled features whose missing legacy history must be checked. Without a
|
|
691
|
+
* recorded import or prior check, `init()` rejects an unset key or missing
|
|
692
|
+
* file when the receipt database shows past use. `:memory:` explicitly
|
|
693
|
+
* declares that no legacy file was retained. A passed check with no file
|
|
694
|
+
* is recorded so later starts can omit the key.
|
|
695
|
+
*/
|
|
696
|
+
readonly enabled?: {
|
|
697
|
+
readonly ap2?: boolean;
|
|
698
|
+
readonly acp?: boolean;
|
|
699
|
+
};
|
|
700
|
+
}
|
|
701
|
+
/** A deprecated store file's name in `legacy_imports` */
|
|
702
|
+
type LegacySource = 'ap2-replay' | 'acp-idempotency';
|
|
703
|
+
|
|
741
704
|
interface SqliteReceiptStoreOptions {
|
|
742
705
|
/** File path, or ':memory:' for tests. Parent directory is created if missing */
|
|
743
706
|
readonly path: string;
|
|
744
707
|
readonly logger?: Logger;
|
|
745
708
|
readonly clock?: Clock;
|
|
746
709
|
readonly ids?: IdGenerator;
|
|
710
|
+
/**
|
|
711
|
+
* Deprecated store files for `init()` to import and write-lock until
|
|
712
|
+
* `close()`. Imports are recorded once per source. Experimental: may change
|
|
713
|
+
* in a minor release.
|
|
714
|
+
*/
|
|
715
|
+
readonly legacyStores?: LegacyStoreOptions;
|
|
716
|
+
}
|
|
717
|
+
/** Recorded import from a deprecated store file */
|
|
718
|
+
interface SqliteLegacyImport {
|
|
719
|
+
readonly source: string;
|
|
720
|
+
readonly path: string;
|
|
721
|
+
readonly rows: number;
|
|
722
|
+
readonly importedAt: IsoTimestamp;
|
|
723
|
+
}
|
|
724
|
+
/** Diagnostic counts for `doctor`. Experimental: may change in a minor release */
|
|
725
|
+
interface SqliteReceiptStoreSummary {
|
|
726
|
+
/** Unresolved transactions by state, derived when read */
|
|
727
|
+
readonly unresolvedTransactions: Readonly<Record<string, number>>;
|
|
728
|
+
/**
|
|
729
|
+
* `reserved` holds last updated before the age cutoff whose request has no
|
|
730
|
+
* current or archived payment attempt
|
|
731
|
+
*/
|
|
732
|
+
readonly orphanHolds: number;
|
|
733
|
+
/** Claims recorded as `unresolved` */
|
|
734
|
+
readonly unresolvedIdempotencyKeys: number;
|
|
735
|
+
readonly unexpiredPendingTasks: number;
|
|
736
|
+
readonly legacyImports: readonly SqliteLegacyImport[];
|
|
737
|
+
/**
|
|
738
|
+
* Sources with past-use evidence and no recorded import or prior check.
|
|
739
|
+
* When enabled, these features cannot start with an unset key or missing
|
|
740
|
+
* legacy file unless the loss of that history is explicitly accepted.
|
|
741
|
+
*/
|
|
742
|
+
readonly missingLegacyImports: readonly LegacySource[];
|
|
743
|
+
}
|
|
744
|
+
/** Implements every optional `ReceiptStore` method */
|
|
745
|
+
interface SqliteReceiptStore extends Required<ReceiptStore> {
|
|
746
|
+
/** Experimental: may change in a minor release */
|
|
747
|
+
summary(options: {
|
|
748
|
+
readonly orphanHoldMinAgeMs: number;
|
|
749
|
+
}): Promise<SqliteReceiptStoreSummary>;
|
|
747
750
|
}
|
|
748
|
-
declare function createSqliteReceiptStore(options: SqliteReceiptStoreOptions):
|
|
751
|
+
declare function createSqliteReceiptStore(options: SqliteReceiptStoreOptions): SqliteReceiptStore;
|
|
749
752
|
|
|
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,
|
|
751
|
-
export type { A2aAdapterOptions, AcpAdapterOptions, BackendExecutor, BackendRequest, BackendResponse, CommerceErrorCode, CommerceErrorInfo, CommerceErrorOptions, DeliverySummary, ErrorEnvelope, GatewayConfig, GatewayInstance, GatewayOptions,
|
|
753
|
+
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, 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, PaymentMethodName, PaymentProvider, PaymentRequiredOutcome, PaymentSubmission, ProtocolAdapter, ProtocolAdapterContext, RESERVED_INPUT_FIELDS, RETRYABLE_ERROR_CODES, ReceiptStore, ResourceRegistry, createA2aAdapter, createAcpAdapter, createGateway, createSqliteReceiptStore, extractReservedInputFields, isCommerceError, isPaymentRequiredEnvelope, loadConfig, parseAuthorizationHeader, parseAuthorizationSubmission, parseConfig, createSqliteReceiptStore as receipts, toCommerceError, toDeliverySummary, toErrorEnvelope, toPaymentRequiredEnvelope };
|
|
754
|
+
export type { A2aAdapterOptions, AcpAdapterOptions, BackendExecutor, BackendRequest, BackendResponse, CommerceErrorCode, CommerceErrorInfo, CommerceErrorOptions, DeliverySummary, ErrorEnvelope, GatewayConfig, GatewayInstance, GatewayOptions, PaymentRequiredEnvelope };
|