@devlab.group/agent-commerce 2.6.0 → 2.7.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 +17 -12
- package/dist/ap2.d.ts +1 -1
- package/dist/ap2.js +5 -5
- package/dist/{chunk-ES3V6ECS.js → chunk-77HLISG4.js} +3 -2
- package/dist/chunk-77HLISG4.js.map +1 -0
- package/dist/{chunk-5ZYXBCDX.js → chunk-D7FPSGUQ.js} +25 -4
- package/dist/chunk-D7FPSGUQ.js.map +1 -0
- package/dist/{chunk-G3EYYHKF.js → chunk-DJRWYDKJ.js} +3 -3
- package/dist/{chunk-G3EYYHKF.js.map → chunk-DJRWYDKJ.js.map} +1 -1
- package/dist/{chunk-M6MQ3FYS.js → chunk-EMKITGVV.js} +4 -4
- package/dist/chunk-EMKITGVV.js.map +1 -0
- package/dist/chunk-IWXVQYG5.js +6 -0
- package/dist/chunk-IWXVQYG5.js.map +1 -0
- package/dist/chunk-O3ACF45K.js +8 -0
- package/dist/{chunk-M6BSXXTF.js.map → chunk-O3ACF45K.js.map} +1 -1
- package/dist/{chunk-M6WW6QIT.js → chunk-WDD2ZUR3.js} +5 -3
- package/dist/chunk-WDD2ZUR3.js.map +1 -0
- package/dist/{chunk-M52FBNJX.js → chunk-YHNTTMED.js} +6 -4
- package/dist/chunk-YHNTTMED.js.map +1 -0
- package/dist/{chunk-DRLBML7Z.js → chunk-ZSIUZPNB.js} +175 -74
- package/dist/chunk-ZSIUZPNB.js.map +1 -0
- package/dist/cli/{ap2-2YMYA2H6.js → ap2-5FFGSW6F.js} +10 -11
- package/dist/cli/ap2-5FFGSW6F.js.map +1 -0
- package/dist/cli/{chunk-5K4XEAZV.js → chunk-3IEXJ7I3.js} +25 -4
- package/dist/cli/chunk-3IEXJ7I3.js.map +1 -0
- package/dist/cli/{chunk-VJH6RYRK.js → chunk-3NVJAQRO.js} +3 -3
- package/dist/cli/{chunk-VJH6RYRK.js.map → chunk-3NVJAQRO.js.map} +1 -1
- package/dist/cli/{chunk-GET3CZGR.js → chunk-55AI6CLW.js} +6 -4
- package/dist/cli/chunk-55AI6CLW.js.map +1 -0
- package/dist/cli/{chunk-YOF7IK4V.js → chunk-5K2JDM4G.js} +177 -76
- package/dist/cli/chunk-5K2JDM4G.js.map +1 -0
- package/dist/cli/{chunk-NSYSMDQN.js → chunk-5TID36YG.js} +57 -29
- package/dist/cli/chunk-5TID36YG.js.map +1 -0
- package/dist/cli/{chunk-3NOMLMJW.js → chunk-66NTYSXI.js} +3 -3
- package/dist/cli/{chunk-3NOMLMJW.js.map → chunk-66NTYSXI.js.map} +1 -1
- package/dist/cli/{chunk-VJ4EO4LE.js → chunk-6EBDOH37.js} +3 -3
- package/dist/cli/{chunk-VJ4EO4LE.js.map → chunk-6EBDOH37.js.map} +1 -1
- package/dist/cli/{chunk-YWG2ZN3L.js → chunk-AGQ4U7IN.js} +5 -5
- package/dist/cli/chunk-AGQ4U7IN.js.map +1 -0
- package/dist/cli/chunk-APC5BTQM.js +6 -0
- package/dist/cli/chunk-APC5BTQM.js.map +1 -0
- package/dist/cli/{chunk-SYQLJXIU.js → chunk-C5YISPT6.js} +3 -3
- package/dist/cli/chunk-C5YISPT6.js.map +1 -0
- package/dist/cli/chunk-DKWO6LLX.js +34 -0
- package/dist/cli/chunk-DKWO6LLX.js.map +1 -0
- package/dist/cli/{chunk-SPAYKVUP.js → chunk-FL4HPCD4.js} +3 -2
- package/dist/cli/chunk-FL4HPCD4.js.map +1 -0
- package/dist/cli/{chunk-3EQBCFZY.js → chunk-H7EBJ4I3.js} +3 -3
- package/dist/cli/{chunk-3EQBCFZY.js.map → chunk-H7EBJ4I3.js.map} +1 -1
- package/dist/cli/{chunk-PTL7SNOI.js → chunk-OETKXDGA.js} +467 -122
- package/dist/cli/chunk-OETKXDGA.js.map +1 -0
- package/dist/cli/{chunk-DHFMIBPG.js → chunk-PLHPKXAT.js} +6 -6
- package/dist/cli/{chunk-DHFMIBPG.js.map → chunk-PLHPKXAT.js.map} +1 -1
- package/dist/cli/{chunk-TFV3K6YS.js → chunk-VSSSU4AU.js} +3 -3
- package/dist/cli/{chunk-TFV3K6YS.js.map → chunk-VSSSU4AU.js.map} +1 -1
- package/dist/cli/chunk-ZCW56PZ3.js +8 -0
- package/dist/cli/{chunk-4KLYFXMW.js.map → chunk-ZCW56PZ3.js.map} +1 -1
- package/dist/cli/{chunk-AZL7RPFU.js → chunk-ZFVQWOGG.js} +64 -16
- package/dist/cli/chunk-ZFVQWOGG.js.map +1 -0
- package/dist/cli/config-WT5HHDRR.js +13 -0
- package/dist/cli/{config-3K65QJ22.js.map → config-WT5HHDRR.js.map} +1 -1
- package/dist/cli/index.js +51 -37
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/{mcp-6F64A7KE.js → mcp-HHGNOUKE.js} +7 -7
- package/dist/cli/{mcp-6F64A7KE.js.map → mcp-HHGNOUKE.js.map} +1 -1
- package/dist/cli/payment-providers-EWXZFBIE.js +6 -0
- package/dist/cli/{payment-providers-2ITS6KNR.js.map → payment-providers-EWXZFBIE.js.map} +1 -1
- package/dist/cli/{provider-5BGG5YKQ.js → provider-XUPLYNQ7.js} +9 -9
- package/dist/cli/{provider-5BGG5YKQ.js.map → provider-XUPLYNQ7.js.map} +1 -1
- package/dist/cli/receipts-3DSV4DIK.js +9 -0
- package/dist/cli/{receipts-I4IIE7U6.js.map → receipts-3DSV4DIK.js.map} +1 -1
- package/dist/cli/reconcile-GS25MQ42.js +4 -0
- package/dist/cli/{reconcile-55WNCSFC.js.map → reconcile-GS25MQ42.js.map} +1 -1
- package/dist/cli/{run-2P6ZGFUE.js → run-7KLKW3HE.js} +107 -35
- package/dist/cli/run-7KLKW3HE.js.map +1 -0
- package/dist/cli/{x402-4LPIIELI.js → x402-HP4E3QET.js} +11 -10
- package/dist/cli/x402-HP4E3QET.js.map +1 -0
- package/dist/{guardrails-CX_jYXvZ.d.ts → guardrails-CeyLS1ou.d.ts} +2 -2
- package/dist/index.d.ts +23 -13
- package/dist/index.js +660 -170
- package/dist/index.js.map +1 -1
- package/dist/mcp.d.ts +2 -2
- package/dist/mcp.js +4 -4
- package/dist/mpp.js +5 -5
- package/dist/{protocol-adapter-1WbtM3xG.d.ts → protocol-adapter-DdFL5LBU.d.ts} +12 -2
- package/dist/{runtime-B-kARa2f.d.ts → runtime-BmaSp2Ce.d.ts} +31 -3
- package/dist/{store-kIIMpUA-.d.ts → store-BVvMzpuV.d.ts} +25 -8
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +156 -2
- package/dist/testing.js.map +1 -1
- package/dist/{transaction-Dv0UFGg5.d.ts → transaction-BXXJltZ-.d.ts} +1 -1
- package/dist/x402.d.ts +7 -2
- package/dist/x402.js +7 -6
- package/dist/x402.js.map +1 -1
- package/package.json +13 -29
- package/dist/chunk-5ZYXBCDX.js.map +0 -1
- package/dist/chunk-DRLBML7Z.js.map +0 -1
- package/dist/chunk-ES3V6ECS.js.map +0 -1
- package/dist/chunk-M52FBNJX.js.map +0 -1
- package/dist/chunk-M6BSXXTF.js +0 -8
- package/dist/chunk-M6MQ3FYS.js.map +0 -1
- package/dist/chunk-M6WW6QIT.js.map +0 -1
- package/dist/cli/ap2-2YMYA2H6.js.map +0 -1
- package/dist/cli/chunk-4KLYFXMW.js +0 -8
- package/dist/cli/chunk-5K4XEAZV.js.map +0 -1
- package/dist/cli/chunk-6R6WJ4FD.js +0 -18
- package/dist/cli/chunk-6R6WJ4FD.js.map +0 -1
- package/dist/cli/chunk-AZL7RPFU.js.map +0 -1
- package/dist/cli/chunk-FHCFR2GS.js +0 -17
- package/dist/cli/chunk-FHCFR2GS.js.map +0 -1
- package/dist/cli/chunk-GET3CZGR.js.map +0 -1
- package/dist/cli/chunk-NSYSMDQN.js.map +0 -1
- package/dist/cli/chunk-PTL7SNOI.js.map +0 -1
- package/dist/cli/chunk-SPAYKVUP.js.map +0 -1
- package/dist/cli/chunk-SYQLJXIU.js.map +0 -1
- package/dist/cli/chunk-YOF7IK4V.js.map +0 -1
- package/dist/cli/chunk-YWG2ZN3L.js.map +0 -1
- package/dist/cli/config-3K65QJ22.js +0 -12
- package/dist/cli/payment-providers-2ITS6KNR.js +0 -6
- package/dist/cli/receipts-I4IIE7U6.js +0 -8
- package/dist/cli/reconcile-55WNCSFC.js +0 -4
- package/dist/cli/run-2P6ZGFUE.js.map +0 -1
- package/dist/cli/x402-4LPIIELI.js.map +0 -1
|
@@ -1,10 +1,10 @@
|
|
|
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-5K2JDM4G.js';
|
|
2
|
+
export { createX402PaymentProvider } from './chunk-5K2JDM4G.js';
|
|
3
|
+
import './chunk-AGQ4U7IN.js';
|
|
4
|
+
export { SUPPORTED_NETWORK_IDS } from './chunk-66NTYSXI.js';
|
|
5
|
+
import './chunk-ZCW56PZ3.js';
|
|
6
|
+
import './chunk-55AI6CLW.js';
|
|
7
|
+
import { CommerceError } from './chunk-C5YISPT6.js';
|
|
8
8
|
import './chunk-663ALDZA.js';
|
|
9
9
|
import './chunk-3M6U7ILB.js';
|
|
10
10
|
import { PaymentRequirementsV2Schema } from '@x402/core/schemas';
|
|
@@ -82,7 +82,8 @@ async function createPaymentProof(options) {
|
|
|
82
82
|
validBefore: validBefore.toString(),
|
|
83
83
|
nonce
|
|
84
84
|
}
|
|
85
|
-
}
|
|
85
|
+
},
|
|
86
|
+
...options.extensions !== void 0 ? { extensions: { ...options.extensions } } : {}
|
|
86
87
|
};
|
|
87
88
|
return Buffer.from(JSON.stringify(payload), "utf8").toString("base64");
|
|
88
89
|
}
|
|
@@ -93,5 +94,5 @@ function randomNonce() {
|
|
|
93
94
|
}
|
|
94
95
|
|
|
95
96
|
export { createPaymentProof };
|
|
96
|
-
//# sourceMappingURL=x402-
|
|
97
|
-
//# sourceMappingURL=x402-
|
|
97
|
+
//# sourceMappingURL=x402-HP4E3QET.js.map
|
|
98
|
+
//# sourceMappingURL=x402-HP4E3QET.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/payments/x402/client.ts"],"names":[],"mappings":"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","file":"x402-HP4E3QET.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 /**\n * `PaymentPayload.extensions`, sent outside the signature. Echo the challenge's\n * declarations; for `payment-identifier`, add the buyer's `id` to `info`.\n */\n readonly extensions?: 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 ...(options.extensions !== undefined ? { extensions: { ...options.extensions } } : {}),\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"]}
|
|
@@ -12,8 +12,8 @@ type X402PaymentFlow = (typeof X402_PAYMENT_FLOWS)[number];
|
|
|
12
12
|
* - `none`: send no credential; use it when the facilitator accepts
|
|
13
13
|
* anonymous requests.
|
|
14
14
|
* - `bearer`: send a static token; no extra peer package is needed.
|
|
15
|
-
* - `cdp`: Coinbase Developer Platform. The
|
|
16
|
-
*
|
|
15
|
+
* - `cdp`: Coinbase Developer Platform. The gateway signs a fresh JWT per
|
|
16
|
+
* request with the API key; no extra peer package is needed.
|
|
17
17
|
*
|
|
18
18
|
* Any other auth type is refused at config load.
|
|
19
19
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { Ap2AuthorizationConfig } from './ap2.js';
|
|
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-
|
|
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-
|
|
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-BmaSp2Ce.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-BmaSp2Ce.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
|
-
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-
|
|
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-
|
|
9
|
-
export { C as CanonicalRequest, c as ExecutionOutcome, i as isHttpProtocolAdapter } from './protocol-adapter-
|
|
10
|
-
import { R as ReceiptStore } from './store-
|
|
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-
|
|
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-BXXJltZ-.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-DdFL5LBU.js';
|
|
9
|
+
export { C as CanonicalRequest, c as ExecutionOutcome, i as isHttpProtocolAdapter } from './protocol-adapter-DdFL5LBU.js';
|
|
10
|
+
import { R as ReceiptStore } from './store-BVvMzpuV.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-BVvMzpuV.js';
|
|
12
12
|
import { L as Logger } from './logger-CllGwQ8i.js';
|
|
13
13
|
export { N as NOOP_LOGGER } from './logger-CllGwQ8i.js';
|
|
14
14
|
import { FastifyInstance } from 'fastify';
|
|
@@ -26,7 +26,7 @@ type CommerceErrorCode = (typeof COMMERCE_ERROR_CODES)[number];
|
|
|
26
26
|
* 4xx or 5xx status, never to a delivery.
|
|
27
27
|
*/
|
|
28
28
|
declare const COMMERCE_ERROR_HTTP_STATUS: Readonly<Record<CommerceErrorCode, number>>;
|
|
29
|
-
/** Codes for which a client may reasonably retry the same request */
|
|
29
|
+
/** Codes for which a client may reasonably retry the same request, by default */
|
|
30
30
|
declare const RETRYABLE_ERROR_CODES: ReadonlySet<CommerceErrorCode>;
|
|
31
31
|
|
|
32
32
|
interface CommerceErrorOptions {
|
|
@@ -37,6 +37,8 @@ interface CommerceErrorOptions {
|
|
|
37
37
|
readonly resourceId?: string;
|
|
38
38
|
/** Override the default HTTP status for this code */
|
|
39
39
|
readonly httpStatus?: number;
|
|
40
|
+
/** Override the code's default retryability for this error instance */
|
|
41
|
+
readonly retryable?: boolean;
|
|
40
42
|
}
|
|
41
43
|
/** Serializable wire form of a CommerceError */
|
|
42
44
|
interface CommerceErrorInfo {
|
|
@@ -222,6 +224,11 @@ interface DeliverySummary {
|
|
|
222
224
|
readonly externalReference?: string;
|
|
223
225
|
readonly network?: string;
|
|
224
226
|
};
|
|
227
|
+
/**
|
|
228
|
+
* True when this request reuses a stored response without another charge.
|
|
229
|
+
* Experimental: may change in a minor release.
|
|
230
|
+
*/
|
|
231
|
+
readonly redelivered?: boolean;
|
|
225
232
|
}
|
|
226
233
|
/** Build the payer-facing summary of a delivered outcome */
|
|
227
234
|
declare function toDeliverySummary(outcome: DeliveredOutcome): DeliverySummary;
|
|
@@ -277,10 +284,11 @@ interface BackendRequest {
|
|
|
277
284
|
* `requestId`, which is fresh per call and would make every retry look like
|
|
278
285
|
* new work.
|
|
279
286
|
*
|
|
280
|
-
* An adapter
|
|
281
|
-
*
|
|
282
|
-
*
|
|
283
|
-
*
|
|
287
|
+
* An adapter may supply this key, or the pipeline may derive it when
|
|
288
|
+
* `idempotency.merchantKey` is true. The value must survive client retries,
|
|
289
|
+
* reconnects and gateway restarts. An adapter's key takes precedence.
|
|
290
|
+
* The HTTP executor sends it as the `Idempotency-Key` header, replacing one
|
|
291
|
+
* set in `BackendHandler.headers`; when absent, the executor adds none.
|
|
284
292
|
*/
|
|
285
293
|
readonly idempotencyKey?: string;
|
|
286
294
|
/**
|
|
@@ -730,8 +738,10 @@ interface SqliteReceiptStoreSummary {
|
|
|
730
738
|
* current or archived payment attempt
|
|
731
739
|
*/
|
|
732
740
|
readonly orphanHolds: number;
|
|
733
|
-
/**
|
|
741
|
+
/** Unresolved claims whose endpoints do not start with `payment:` */
|
|
734
742
|
readonly unresolvedIdempotencyKeys: number;
|
|
743
|
+
/** Unresolved claims whose endpoints start with `payment:` */
|
|
744
|
+
readonly unresolvedPaymentKeys: number;
|
|
735
745
|
readonly unexpiredPendingTasks: number;
|
|
736
746
|
readonly legacyImports: readonly SqliteLegacyImport[];
|
|
737
747
|
/**
|