@devlab.group/agent-commerce 2.5.0 → 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 +63 -11
- package/dist/ap2.d.ts +19 -6
- package/dist/ap2.js +56 -18
- package/dist/ap2.js.map +1 -1
- package/dist/{chunk-FKQK5XZA.js → chunk-DRLBML7Z.js} +13 -11
- package/dist/chunk-DRLBML7Z.js.map +1 -0
- package/dist/{chunk-VUCMBGUR.js → chunk-G3EYYHKF.js} +3 -3
- package/dist/{chunk-VUCMBGUR.js.map → chunk-G3EYYHKF.js.map} +1 -1
- package/dist/{chunk-3OTCFFFT.js → chunk-M52FBNJX.js} +3 -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-4K7FIBJM.js → chunk-M6MQ3FYS.js} +3 -3
- package/dist/{chunk-4K7FIBJM.js.map → chunk-M6MQ3FYS.js.map} +1 -1
- package/dist/chunk-M6WW6QIT.js +18 -0
- package/dist/chunk-M6WW6QIT.js.map +1 -0
- package/dist/cli/{ap2-YAPLERSC.js → ap2-2YMYA2H6.js} +57 -20
- package/dist/cli/ap2-2YMYA2H6.js.map +1 -0
- package/dist/cli/{chunk-5R7DM5LM.js → chunk-3NOMLMJW.js} +26 -26
- package/dist/cli/chunk-3NOMLMJW.js.map +1 -0
- package/dist/cli/chunk-4KLYFXMW.js +8 -0
- package/dist/cli/{chunk-M7NXVRU5.js.map → chunk-4KLYFXMW.js.map} +1 -1
- package/dist/cli/chunk-6R6WJ4FD.js +18 -0
- package/dist/cli/chunk-6R6WJ4FD.js.map +1 -0
- package/dist/cli/{chunk-2J2IQQ4X.js → chunk-AZL7RPFU.js} +37 -32
- package/dist/cli/chunk-AZL7RPFU.js.map +1 -0
- package/dist/cli/{chunk-JFVRG2HH.js → chunk-DHFMIBPG.js} +7 -7
- package/dist/cli/chunk-DHFMIBPG.js.map +1 -0
- package/dist/cli/{chunk-IDY2735M.js → chunk-GET3CZGR.js} +2 -2
- package/dist/cli/chunk-GET3CZGR.js.map +1 -0
- package/dist/cli/{chunk-QLUCNPRT.js → chunk-NSYSMDQN.js} +831 -169
- package/dist/cli/chunk-NSYSMDQN.js.map +1 -0
- package/dist/cli/{chunk-Z34UMZBB.js → chunk-PTL7SNOI.js} +83 -57
- package/dist/cli/chunk-PTL7SNOI.js.map +1 -0
- package/dist/cli/{chunk-2UPPX3FJ.js → chunk-TFV3K6YS.js} +75 -13
- package/dist/cli/chunk-TFV3K6YS.js.map +1 -0
- package/dist/cli/{chunk-NIU5EMSB.js → chunk-VJH6RYRK.js} +5 -5
- package/dist/cli/{chunk-NIU5EMSB.js.map → chunk-VJH6RYRK.js.map} +1 -1
- package/dist/cli/{chunk-QA2OPHBF.js → chunk-YOF7IK4V.js} +14 -13
- package/dist/cli/chunk-YOF7IK4V.js.map +1 -0
- package/dist/cli/{chunk-4H2QLHQI.js → chunk-YWG2ZN3L.js} +3 -3
- package/dist/cli/{chunk-4H2QLHQI.js.map → chunk-YWG2ZN3L.js.map} +1 -1
- package/dist/cli/config-3K65QJ22.js +12 -0
- package/dist/cli/{config-BWFMN2ZB.js.map → config-3K65QJ22.js.map} +1 -1
- package/dist/cli/index.js +524 -230
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/{mcp-KZEMXLHR.js → mcp-6F64A7KE.js} +4 -4
- package/dist/cli/{mcp-KZEMXLHR.js.map → mcp-6F64A7KE.js.map} +1 -1
- package/dist/cli/payment-providers-2ITS6KNR.js +6 -0
- package/dist/cli/{payment-providers-SZL36H3Y.js.map → payment-providers-2ITS6KNR.js.map} +1 -1
- package/dist/cli/{provider-6TKB5ADJ.js → provider-5BGG5YKQ.js} +34 -16
- package/dist/cli/provider-5BGG5YKQ.js.map +1 -0
- package/dist/cli/receipts-I4IIE7U6.js +8 -0
- package/dist/cli/{receipts-ZGLJWMQG.js.map → receipts-I4IIE7U6.js.map} +1 -1
- package/dist/cli/reconcile-55WNCSFC.js +4 -0
- package/dist/cli/{reconcile-IC22MJD5.js.map → reconcile-55WNCSFC.js.map} +1 -1
- package/dist/cli/{run-ZTYPQI4D.js → run-2P6ZGFUE.js} +220 -73
- package/dist/cli/run-2P6ZGFUE.js.map +1 -0
- package/dist/cli/{x402-WLYBLODI.js → x402-4LPIIELI.js} +8 -8
- package/dist/cli/{x402-WLYBLODI.js.map → x402-4LPIIELI.js.map} +1 -1
- package/dist/index.d.ts +104 -201
- package/dist/index.js +1048 -262
- package/dist/index.js.map +1 -1
- package/dist/logger-CllGwQ8i.d.ts +19 -0
- package/dist/mcp.d.ts +3 -1
- package/dist/mcp.js +2 -1
- package/dist/mcp.js.map +1 -1
- package/dist/mpp.d.ts +2 -1
- package/dist/mpp.js +31 -12
- package/dist/mpp.js.map +1 -1
- package/dist/{protocol-adapter-DEXpdp8m.d.ts → protocol-adapter-1WbtM3xG.d.ts} +5 -132
- package/dist/{runtime-Dz2fSO-P.d.ts → runtime-B-kARa2f.d.ts} +5 -20
- package/dist/store-kIIMpUA-.d.ts +372 -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 +5 -4
- package/dist/x402.js.map +1 -1
- package/package.json +5 -1
- package/dist/chunk-3OTCFFFT.js.map +0 -1
- package/dist/chunk-FKQK5XZA.js.map +0 -1
- package/dist/cli/ap2-YAPLERSC.js.map +0 -1
- package/dist/cli/chunk-2J2IQQ4X.js.map +0 -1
- package/dist/cli/chunk-2UPPX3FJ.js.map +0 -1
- package/dist/cli/chunk-5R7DM5LM.js.map +0 -1
- package/dist/cli/chunk-IDY2735M.js.map +0 -1
- package/dist/cli/chunk-JFVRG2HH.js.map +0 -1
- package/dist/cli/chunk-M7NXVRU5.js +0 -8
- package/dist/cli/chunk-QA2OPHBF.js.map +0 -1
- package/dist/cli/chunk-QLUCNPRT.js.map +0 -1
- package/dist/cli/chunk-Z34UMZBB.js.map +0 -1
- package/dist/cli/config-BWFMN2ZB.js +0 -12
- package/dist/cli/payment-providers-SZL36H3Y.js +0 -6
- package/dist/cli/provider-6TKB5ADJ.js.map +0 -1
- package/dist/cli/receipts-ZGLJWMQG.js +0 -8
- package/dist/cli/reconcile-IC22MJD5.js +0 -4
- package/dist/cli/run-ZTYPQI4D.js.map +0 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { chainIdFromCaip2 } from './chunk-
|
|
2
|
-
export { createX402PaymentProvider } from './chunk-
|
|
3
|
-
import './chunk-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import './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
7
|
import { CommerceError } from './chunk-SYQLJXIU.js';
|
|
8
8
|
import './chunk-663ALDZA.js';
|
|
9
9
|
import './chunk-3M6U7ILB.js';
|
|
@@ -93,5 +93,5 @@ function randomNonce() {
|
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
export { createPaymentProof };
|
|
96
|
-
//# sourceMappingURL=x402-
|
|
97
|
-
//# sourceMappingURL=x402-
|
|
96
|
+
//# sourceMappingURL=x402-4LPIIELI.js.map
|
|
97
|
+
//# sourceMappingURL=x402-4LPIIELI.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/payments/x402/client.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAkCA,IAAM,YAAA,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A,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-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,11 +1,16 @@
|
|
|
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,
|
|
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
|
-
|
|
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';
|
|
9
14
|
import { FastifyInstance } from 'fastify';
|
|
10
15
|
import { IncomingMessage, ServerResponse } from 'node:http';
|
|
11
16
|
|
|
@@ -302,197 +307,6 @@ interface BackendExecutor {
|
|
|
302
307
|
call(handler: BackendHandler, request: BackendRequest): Promise<BackendResponse>;
|
|
303
308
|
}
|
|
304
309
|
|
|
305
|
-
/**
|
|
306
|
-
* Persistence boundary for receipts, events and payment attempts, implemented
|
|
307
|
-
* by src/storage/receipts. Core depends only on this interface, never on
|
|
308
|
-
* SQLite.
|
|
309
|
-
*/
|
|
310
|
-
|
|
311
|
-
interface PaymentAttemptReservation {
|
|
312
|
-
readonly requestId: string;
|
|
313
|
-
readonly resourceId: string;
|
|
314
|
-
readonly provider: string;
|
|
315
|
-
/** Must be unique across the store; see `PaymentResult.replayKey` */
|
|
316
|
-
readonly replayKey: string;
|
|
317
|
-
readonly amount: string;
|
|
318
|
-
readonly currency: string;
|
|
319
|
-
readonly payer?: string;
|
|
320
|
-
readonly payee?: string;
|
|
321
|
-
/**
|
|
322
|
-
* Reclaim this `replayKey` if the same `provider` rejected it, which
|
|
323
|
-
* settled nothing. Set only for rails whose authorizations remain reusable
|
|
324
|
-
* until settled.
|
|
325
|
-
*/
|
|
326
|
-
readonly reclaimRejected?: boolean;
|
|
327
|
-
/**
|
|
328
|
-
* Journal data to write atomically with the reservation. Stores without
|
|
329
|
-
* journal support ignore it.
|
|
330
|
-
*/
|
|
331
|
-
readonly transaction?: NewTransaction;
|
|
332
|
-
}
|
|
333
|
-
/**
|
|
334
|
-
* Data for a journal row opened with a replay reservation. Journal stores
|
|
335
|
-
* must initialize an included authorization hold as `reserved`. The reservation
|
|
336
|
-
* supplies the request, resource, provider, replay key, amount, currency and
|
|
337
|
-
* payee. Experimental: may change in a minor release.
|
|
338
|
-
*/
|
|
339
|
-
interface NewTransaction {
|
|
340
|
-
readonly id: string;
|
|
341
|
-
readonly protocol: ProtocolName;
|
|
342
|
-
readonly network?: string;
|
|
343
|
-
readonly asset?: string;
|
|
344
|
-
readonly locator?: Readonly<Record<string, unknown>>;
|
|
345
|
-
readonly expiresAt?: IsoTimestamp;
|
|
346
|
-
readonly authorization?: AuthorizationRecord & {
|
|
347
|
-
readonly reservationId: string;
|
|
348
|
-
};
|
|
349
|
-
readonly inputDigest?: string;
|
|
350
|
-
readonly configDigest: string;
|
|
351
|
-
}
|
|
352
|
-
/**
|
|
353
|
-
* A journal update after replay reservation. Experimental: may change in a
|
|
354
|
-
* minor release.
|
|
355
|
-
*/
|
|
356
|
-
type TransactionStep = {
|
|
357
|
-
readonly transactionId: string;
|
|
358
|
-
readonly at: IsoTimestamp;
|
|
359
|
-
} & ({
|
|
360
|
-
readonly kind: 'settling';
|
|
361
|
-
} | {
|
|
362
|
-
readonly kind: 'hold';
|
|
363
|
-
readonly hold: AuthorizationHoldState;
|
|
364
|
-
} | {
|
|
365
|
-
readonly kind: 'backend-dispatched';
|
|
366
|
-
readonly deadlineAt: IsoTimestamp;
|
|
367
|
-
} | {
|
|
368
|
-
readonly kind: 'backend-result';
|
|
369
|
-
readonly status: number;
|
|
370
|
-
readonly errorCode?: string;
|
|
371
|
-
} | {
|
|
372
|
-
readonly kind: 'receipt';
|
|
373
|
-
readonly receiptId: string;
|
|
374
|
-
} | {
|
|
375
|
-
readonly kind: 'completed';
|
|
376
|
-
readonly persistenceFailures?: readonly PersistenceFailure[];
|
|
377
|
-
});
|
|
378
|
-
/** Experimental: may change in a minor release */
|
|
379
|
-
interface TransactionListOptions extends ListOptions {
|
|
380
|
-
/** Opaque cursor from a previous page's `nextCursor` */
|
|
381
|
-
readonly cursor?: string;
|
|
382
|
-
readonly state?: TransactionState;
|
|
383
|
-
/** When true, exclude `delivered` and `payment-failed` states */
|
|
384
|
-
readonly unresolved?: boolean;
|
|
385
|
-
/** When true, filter for `reserved` or `uncertain` authorization holds */
|
|
386
|
-
readonly pendingHold?: boolean;
|
|
387
|
-
}
|
|
388
|
-
/** Transactions in newest-first order. Experimental: may change in a minor release */
|
|
389
|
-
interface TransactionPage {
|
|
390
|
-
readonly transactions: readonly Transaction[];
|
|
391
|
-
/**
|
|
392
|
-
* Continue with this cursor even when filtering returns fewer than `limit`
|
|
393
|
-
* transactions, including an empty page. Pagination ends when it is absent.
|
|
394
|
-
*/
|
|
395
|
-
readonly nextCursor?: string;
|
|
396
|
-
}
|
|
397
|
-
/** Experimental: may change in a minor release */
|
|
398
|
-
interface PaymentAttemptResolveRequest {
|
|
399
|
-
readonly attemptId: string;
|
|
400
|
-
/** Update only if the attempt still has this status and no resolution */
|
|
401
|
-
readonly expectedStatus: PaymentAttempt['status'];
|
|
402
|
-
readonly status: 'settled' | 'rejected';
|
|
403
|
-
readonly rejectionReason?: string;
|
|
404
|
-
readonly resolution: PaymentAttemptResolution;
|
|
405
|
-
}
|
|
406
|
-
interface PaymentAttemptUpdate {
|
|
407
|
-
readonly replayKey: string;
|
|
408
|
-
readonly status: PaymentAttempt['status'];
|
|
409
|
-
readonly externalReference?: string;
|
|
410
|
-
readonly rejectionReason?: string;
|
|
411
|
-
}
|
|
412
|
-
interface ListOptions {
|
|
413
|
-
readonly limit?: number;
|
|
414
|
-
readonly requestId?: string;
|
|
415
|
-
}
|
|
416
|
-
interface ReceiptListOptions extends ListOptions {
|
|
417
|
-
/**
|
|
418
|
-
* When true, return only receipts counted by {@link ReceiptStore.countUndeliveredReceipts}.
|
|
419
|
-
* Stores ignoring this flag also return delivered receipts.
|
|
420
|
-
*/
|
|
421
|
-
readonly undelivered?: boolean;
|
|
422
|
-
}
|
|
423
|
-
interface PaymentAttemptListOptions extends ListOptions {
|
|
424
|
-
/**
|
|
425
|
-
* When true, return only attempts counted by {@link ReceiptStore.countUncertainPaymentAttempts}.
|
|
426
|
-
* Stores that ignore this flag do not filter by settlement status.
|
|
427
|
-
*/
|
|
428
|
-
readonly uncertain?: boolean;
|
|
429
|
-
}
|
|
430
|
-
interface ReceiptStore {
|
|
431
|
-
init(): Promise<void>;
|
|
432
|
-
/** Append a canonical event. Must not throw into the caller's flow */
|
|
433
|
-
appendEvent(event: CommerceEvent): Promise<void>;
|
|
434
|
-
/**
|
|
435
|
-
* Atomically reserve a payment authorization before settlement. If its
|
|
436
|
-
* `replayKey` is already reserved, throws `CommerceError('PAYMENT_REPLAYED')`
|
|
437
|
-
* with the existing attempt's `PaymentAttempt.status` in
|
|
438
|
-
* `details.attemptStatus` when available.
|
|
439
|
-
*
|
|
440
|
-
* With `reclaimRejected`, replace the same provider's `rejected` attempt,
|
|
441
|
-
* which settled nothing. Only one concurrent claim can replace it with the
|
|
442
|
-
* new reservation.
|
|
443
|
-
*/
|
|
444
|
-
reservePaymentAttempt(reservation: PaymentAttemptReservation): Promise<PaymentAttempt>;
|
|
445
|
-
/** Must not change an attempt that has a resolution; the SQLite store throws `STORAGE_ERROR` */
|
|
446
|
-
updatePaymentAttempt(update: PaymentAttemptUpdate): Promise<void>;
|
|
447
|
-
saveReceipt(receipt: CommerceReceipt): Promise<void>;
|
|
448
|
-
getReceipt(id: string): Promise<CommerceReceipt | undefined>;
|
|
449
|
-
listReceipts(options?: ReceiptListOptions): Promise<readonly CommerceReceipt[]>;
|
|
450
|
-
/**
|
|
451
|
-
* Total receipts held. `listReceipts` clamps every page, so counting a list's
|
|
452
|
-
* length would stop at the clamp.
|
|
453
|
-
*/
|
|
454
|
-
countReceipts(): Promise<number>;
|
|
455
|
-
/**
|
|
456
|
-
* Receipts whose delivery failed: `backendStatus` outside 2xx, including 0
|
|
457
|
-
* when no status is known. Counted rather than listed for the same reason as
|
|
458
|
-
* {@link countReceipts}.
|
|
459
|
-
*
|
|
460
|
-
* In practice this is "paid but undelivered": the pipeline writes a receipt
|
|
461
|
-
* for a failed delivery only after a settled payment, so a free resource
|
|
462
|
-
* whose backend fails leaves no row here. It is the row a merchant must
|
|
463
|
-
* notice, because settlement is final and the gateway issues no refunds.
|
|
464
|
-
*/
|
|
465
|
-
countUndeliveredReceipts(): Promise<number>;
|
|
466
|
-
/**
|
|
467
|
-
* Counts `settlement-uncertain` and legacy `failed` payment attempts.
|
|
468
|
-
* Funds may have moved, but the pipeline withholds delivery and writes no
|
|
469
|
-
* receipt for an uncertain settlement. {@link countUndeliveredReceipts}
|
|
470
|
-
* therefore misses these attempts. Reconcile them on chain using
|
|
471
|
-
* `externalReference` when it holds a transaction hash.
|
|
472
|
-
*/
|
|
473
|
-
countUncertainPaymentAttempts(): Promise<number>;
|
|
474
|
-
listEvents(options?: ListOptions): Promise<readonly CommerceEvent[]>;
|
|
475
|
-
listPaymentAttempts(options?: PaymentAttemptListOptions): Promise<readonly PaymentAttempt[]>;
|
|
476
|
-
/**
|
|
477
|
-
* Record a journal step. Journal methods are optional for compatibility with
|
|
478
|
-
* stores that do not support the journal. Implementations must also recompute
|
|
479
|
-
* a transaction's cached state atomically with payment-attempt updates.
|
|
480
|
-
* Experimental: may change in a minor release.
|
|
481
|
-
*/
|
|
482
|
-
recordTransactionStep?(step: TransactionStep): Promise<void>;
|
|
483
|
-
getTransaction?(id: string): Promise<Transaction | undefined>;
|
|
484
|
-
listTransactions?(options?: TransactionListOptions): Promise<TransactionPage>;
|
|
485
|
-
getPaymentAttempt?(id: string): Promise<PaymentAttempt | undefined>;
|
|
486
|
-
/**
|
|
487
|
-
* Compare-and-set: return `false` without writing if the attempt's status
|
|
488
|
-
* differs from `expectedStatus` or it already has a resolution
|
|
489
|
-
*/
|
|
490
|
-
resolvePaymentAttempt?(request: PaymentAttemptResolveRequest): Promise<boolean>;
|
|
491
|
-
readonly descriptor: AdapterDescriptor;
|
|
492
|
-
health(): Promise<AdapterHealth>;
|
|
493
|
-
close(): Promise<void>;
|
|
494
|
-
}
|
|
495
|
-
|
|
496
310
|
/**
|
|
497
311
|
* ACP protocol constants shared by the config layer and the adapter.
|
|
498
312
|
*
|
|
@@ -542,7 +356,11 @@ type AcpProtocolConfig = {
|
|
|
542
356
|
readonly token: string;
|
|
543
357
|
};
|
|
544
358
|
readonly idempotency: {
|
|
545
|
-
|
|
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;
|
|
546
364
|
readonly retentionHours: number;
|
|
547
365
|
readonly merchantIdempotent: boolean;
|
|
548
366
|
};
|
|
@@ -697,6 +515,10 @@ interface GatewayInstance {
|
|
|
697
515
|
listen(): Promise<{
|
|
698
516
|
url: string;
|
|
699
517
|
}>;
|
|
518
|
+
/**
|
|
519
|
+
* Stops accepting connections and drains in-flight requests before stopping
|
|
520
|
+
* adapters, then resolves when both are done.
|
|
521
|
+
*/
|
|
700
522
|
close(): Promise<void>;
|
|
701
523
|
/** Fastify instance, for `.inject()` in tests */
|
|
702
524
|
readonly server: FastifyInstance;
|
|
@@ -710,6 +532,12 @@ interface A2aAdapterOptions {
|
|
|
710
532
|
readonly agentDescription?: string;
|
|
711
533
|
/** Version published on the card. Defaults to this package's version */
|
|
712
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;
|
|
713
541
|
}
|
|
714
542
|
declare class A2aProtocolAdapter implements HttpProtocolAdapter {
|
|
715
543
|
readonly name: "a2a";
|
|
@@ -719,6 +547,7 @@ declare class A2aProtocolAdapter implements HttpProtocolAdapter {
|
|
|
719
547
|
private readonly agentName;
|
|
720
548
|
private readonly agentDescription;
|
|
721
549
|
private readonly agentVersion;
|
|
550
|
+
private readonly store;
|
|
722
551
|
private context;
|
|
723
552
|
private started;
|
|
724
553
|
private skillsById;
|
|
@@ -787,9 +616,19 @@ interface AcpAdapterOptions {
|
|
|
787
616
|
readonly token: string;
|
|
788
617
|
/** Which canonical resource implements each ACP checkout operation */
|
|
789
618
|
readonly operations: Readonly<Record<AcpCheckoutOperation, string>>;
|
|
790
|
-
/**
|
|
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 */
|
|
791
625
|
readonly idempotency: {
|
|
792
|
-
|
|
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;
|
|
793
632
|
readonly retentionHours: number;
|
|
794
633
|
/**
|
|
795
634
|
* Declare that the merchant deduplicates by the derived `Idempotency-Key`.
|
|
@@ -813,13 +652,16 @@ declare class AcpProtocolAdapter implements HttpProtocolAdapter {
|
|
|
813
652
|
*/
|
|
814
653
|
private deployment;
|
|
815
654
|
private readonly discoveryMetadata;
|
|
655
|
+
private readonly store;
|
|
816
656
|
private idempotency;
|
|
657
|
+
private fileStore;
|
|
817
658
|
private resources;
|
|
818
659
|
private context;
|
|
819
660
|
private started;
|
|
820
661
|
private discovery;
|
|
821
662
|
constructor(options: AcpAdapterOptions);
|
|
822
663
|
start(context: ProtocolAdapterContext): Promise<void>;
|
|
664
|
+
private openIdempotency;
|
|
823
665
|
/** `GET /.well-known/acp.json`: public, unauthenticated, cacheable */
|
|
824
666
|
handleDiscovery(req: IncomingMessage, res: ServerResponse): Promise<void>;
|
|
825
667
|
/** `<mountPath>/checkout_sessions...`: the five stable checkout routes */
|
|
@@ -838,14 +680,75 @@ declare class AcpProtocolAdapter implements HttpProtocolAdapter {
|
|
|
838
680
|
}
|
|
839
681
|
declare function createAcpAdapter(options: AcpAdapterOptions): AcpProtocolAdapter;
|
|
840
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
|
+
|
|
841
704
|
interface SqliteReceiptStoreOptions {
|
|
842
705
|
/** File path, or ':memory:' for tests. Parent directory is created if missing */
|
|
843
706
|
readonly path: string;
|
|
844
707
|
readonly logger?: Logger;
|
|
845
708
|
readonly clock?: Clock;
|
|
846
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>;
|
|
847
750
|
}
|
|
848
|
-
declare function createSqliteReceiptStore(options: SqliteReceiptStoreOptions):
|
|
751
|
+
declare function createSqliteReceiptStore(options: SqliteReceiptStoreOptions): SqliteReceiptStore;
|
|
849
752
|
|
|
850
|
-
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,
|
|
851
|
-
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 };
|