@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
|
@@ -67,6 +67,75 @@ interface AdapterDescriptor {
|
|
|
67
67
|
readonly unsupported?: readonly string[];
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
+
interface CommerceReceipt {
|
|
71
|
+
readonly id: string;
|
|
72
|
+
readonly requestId: string;
|
|
73
|
+
/** Optional for compatibility with rows written before 2.5.0 */
|
|
74
|
+
readonly transactionId?: string;
|
|
75
|
+
readonly resourceId: string;
|
|
76
|
+
/** Absent for free resources */
|
|
77
|
+
readonly payment?: PaymentResult;
|
|
78
|
+
/**
|
|
79
|
+
* Present only when the resource required authorization. A method and a digest,
|
|
80
|
+
* so the receipt records that consent existed without storing the proof.
|
|
81
|
+
*/
|
|
82
|
+
readonly authorization?: AuthorizationRecord;
|
|
83
|
+
readonly deliveredAt: IsoTimestamp;
|
|
84
|
+
readonly backendStatus: number;
|
|
85
|
+
readonly durationMs?: number;
|
|
86
|
+
readonly protocol?: string;
|
|
87
|
+
/** Non-secret summary only, never a sensitive backend body */
|
|
88
|
+
readonly metadata?: Readonly<Record<string, unknown>>;
|
|
89
|
+
}
|
|
90
|
+
/** Record of a single payment authorization seen by the gateway */
|
|
91
|
+
interface PaymentAttempt {
|
|
92
|
+
readonly id: string;
|
|
93
|
+
readonly requestId: string;
|
|
94
|
+
/** Optional for compatibility with rows written before 2.5.0 */
|
|
95
|
+
readonly transactionId?: string;
|
|
96
|
+
readonly resourceId: string;
|
|
97
|
+
readonly provider: string;
|
|
98
|
+
/** Unique across the store; see `PaymentResult.replayKey` */
|
|
99
|
+
readonly replayKey: string;
|
|
100
|
+
/**
|
|
101
|
+
* State of the authorization, as far as the gateway can prove it.
|
|
102
|
+
*
|
|
103
|
+
* `settlement-uncertain` means settlement was attempted and no verdict came
|
|
104
|
+
* back (RPC timeout, dropped connection, a facilitator that accepted the
|
|
105
|
+
* transfer and lost the response). The transfer may or may not have
|
|
106
|
+
* happened, so the attempt is unresolved rather than terminal and needs
|
|
107
|
+
* evidence from the chain, not a retry. `externalReference` holds the
|
|
108
|
+
* broadcast transaction hash when one is known.
|
|
109
|
+
*
|
|
110
|
+
* The execution pipeline never writes `failed`: a throw out of `settle()`
|
|
111
|
+
* never proves that nothing moved. It stays in the union because existing
|
|
112
|
+
* databases hold rows with that status.
|
|
113
|
+
*/
|
|
114
|
+
readonly status: 'reserved' | 'verified' | 'settled' | 'rejected' | 'failed' | 'settlement-uncertain';
|
|
115
|
+
readonly amount: string;
|
|
116
|
+
readonly currency: string;
|
|
117
|
+
readonly payer?: string;
|
|
118
|
+
readonly payee?: string;
|
|
119
|
+
readonly externalReference?: string;
|
|
120
|
+
readonly rejectionReason?: string;
|
|
121
|
+
/** Records how an unresolved attempt became `settled` or `rejected` after its request ended */
|
|
122
|
+
readonly resolution?: PaymentAttemptResolution;
|
|
123
|
+
readonly createdAt: IsoTimestamp;
|
|
124
|
+
readonly updatedAt: IsoTimestamp;
|
|
125
|
+
}
|
|
126
|
+
/** Who resolved an attempt, manually or by reconciliation, and why */
|
|
127
|
+
interface PaymentAttemptResolution {
|
|
128
|
+
readonly method: 'reconcile' | 'manual';
|
|
129
|
+
/** Caller-supplied identity; the admin token does not identify an individual */
|
|
130
|
+
readonly actor: string;
|
|
131
|
+
readonly reason: string;
|
|
132
|
+
readonly at: IsoTimestamp;
|
|
133
|
+
/** For `manual`, an unverified reference supplied by the operator */
|
|
134
|
+
readonly externalReference?: string;
|
|
135
|
+
/** Public chain facts only */
|
|
136
|
+
readonly evidence?: Readonly<Record<string, unknown>>;
|
|
137
|
+
}
|
|
138
|
+
|
|
70
139
|
/** HTTP methods a backend handler may use */
|
|
71
140
|
type BackendMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
72
141
|
/**
|
|
@@ -157,6 +226,13 @@ interface ResourceRegistry {
|
|
|
157
226
|
* EVM-specific type may appear in this file.
|
|
158
227
|
*/
|
|
159
228
|
|
|
229
|
+
/**
|
|
230
|
+
* `PaymentResult.metadata` key for public coordinates returned by `verify`
|
|
231
|
+
* for later provider reconciliation. Core must store the value unchanged and
|
|
232
|
+
* interpret only `expiresAt`. Never include signatures, payloads or
|
|
233
|
+
* transaction bytes. Experimental: may change in a minor release.
|
|
234
|
+
*/
|
|
235
|
+
declare const RECONCILIATION_METADATA_KEY = "reconciliation";
|
|
160
236
|
/**
|
|
161
237
|
* Provider-native payment challenge, opaque to core. For x402 the `accepts`
|
|
162
238
|
* entries are x402 `PaymentRequirements` objects, passed to protocol adapters
|
|
@@ -229,7 +305,9 @@ interface PaymentResult {
|
|
|
229
305
|
* The pipeline reserves this key before settlement and rejects a second
|
|
230
306
|
* request presenting it with `PAYMENT_REPLAYED`. Providers must derive it
|
|
231
307
|
* only from the authorization (payer, nonce, asset, network), so the same
|
|
232
|
-
* authorization always maps to the same key.
|
|
308
|
+
* authorization always maps to the same key. A `rejected` result may also
|
|
309
|
+
* carry it so a store lookup can identify an unfinished attempt even when
|
|
310
|
+
* verification rejects the proof because its transfer has landed.
|
|
233
311
|
*/
|
|
234
312
|
readonly replayKey?: string;
|
|
235
313
|
/** Machine-readable rejection reason when status is `rejected` */
|
|
@@ -263,6 +341,30 @@ interface PaymentVerificationContext {
|
|
|
263
341
|
interface PaymentSettlementContext extends PaymentVerificationContext {
|
|
264
342
|
readonly verification: PaymentResult;
|
|
265
343
|
}
|
|
344
|
+
/** Input to {@link PaymentProvider.reconcile}. Experimental: may change in a minor release */
|
|
345
|
+
interface PaymentReconciliationContext {
|
|
346
|
+
readonly attempt: PaymentAttempt;
|
|
347
|
+
/** Coordinates from `verify`; optional for compatibility with pre-2.5.0 attempts */
|
|
348
|
+
readonly locator?: Readonly<Record<string, unknown>>;
|
|
349
|
+
readonly now: IsoTimestamp;
|
|
350
|
+
}
|
|
351
|
+
/** Chain evidence for resolving an attempt. Experimental: may change in a minor release */
|
|
352
|
+
interface PaymentReconciliationResult {
|
|
353
|
+
/**
|
|
354
|
+
* Report `settled` only with a final transfer record for this authorization.
|
|
355
|
+
* Report `not-settled` only when a state read proves it unused after it can
|
|
356
|
+
* no longer land; missing logs or receipts are insufficient. Otherwise,
|
|
357
|
+
* report `unknown`.
|
|
358
|
+
*/
|
|
359
|
+
readonly outcome: 'settled' | 'not-settled' | 'unknown';
|
|
360
|
+
/** A machine-readable token, such as `not_final` */
|
|
361
|
+
readonly reason: string;
|
|
362
|
+
readonly externalReference?: string;
|
|
363
|
+
/** Public chain facts only */
|
|
364
|
+
readonly evidence?: Readonly<Record<string, unknown>>;
|
|
365
|
+
/** For `unknown`, the earliest time a different answer is possible, if known */
|
|
366
|
+
readonly retryAfter?: IsoTimestamp;
|
|
367
|
+
}
|
|
266
368
|
/**
|
|
267
369
|
* Contract every payment rail implements. Implementations must be
|
|
268
370
|
* non-custodial: they orchestrate an external payment protocol and never hold
|
|
@@ -296,25 +398,126 @@ interface PaymentProvider {
|
|
|
296
398
|
* returned result; the pipeline records any throw as settlement-uncertain.
|
|
297
399
|
*/
|
|
298
400
|
settle(context: PaymentSettlementContext): Promise<PaymentResult>;
|
|
401
|
+
/**
|
|
402
|
+
* Read chain evidence for an attempt with an unknown outcome. Implementations
|
|
403
|
+
* must not write, broadcast or call a facilitator. Providers without this
|
|
404
|
+
* hook require manual resolution. Experimental: may change in a minor release.
|
|
405
|
+
*/
|
|
406
|
+
reconcile?(context: PaymentReconciliationContext): Promise<PaymentReconciliationResult>;
|
|
299
407
|
health(): Promise<AdapterHealth>;
|
|
300
408
|
}
|
|
301
409
|
|
|
302
410
|
/**
|
|
303
|
-
*
|
|
304
|
-
* a pino instance that satisfies this shape.
|
|
411
|
+
* Canonical authorization model. FROZEN CONTRACT.
|
|
305
412
|
*
|
|
306
|
-
*
|
|
307
|
-
*
|
|
413
|
+
* Payment proves that funds moved; authorization proves that the human behind
|
|
414
|
+
* the agent approved this exact purchase. A valid authorization gates
|
|
415
|
+
* settlement but never unlocks a paid resource on its own and never moves
|
|
416
|
+
* money, so a resource that requires one still needs a payment proof.
|
|
417
|
+
*
|
|
418
|
+
* Core decides that a resource requires authorization and when the pipeline
|
|
419
|
+
* checks it. Authorization providers decide how a submission is parsed,
|
|
420
|
+
* verified and bound to the purchase. No AP2, SD-JWT or JWT type may appear in
|
|
421
|
+
* this file.
|
|
308
422
|
*/
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
423
|
+
|
|
424
|
+
/**
|
|
425
|
+
* Opaque authorization proof supplied by the buyer's client. Over HTTP it
|
|
426
|
+
* arrives as base64url JSON in the `Agent-Authorization` header; over MCP and
|
|
427
|
+
* A2A it is the same `{ method, payload }` object in the reserved
|
|
428
|
+
* `_authorization` input field.
|
|
429
|
+
*
|
|
430
|
+
* `payload` is kept byte for byte from the wire. It may hold signed or
|
|
431
|
+
* encoding-sensitive provider data, so transport adapters must not normalize
|
|
432
|
+
* it.
|
|
433
|
+
*/
|
|
434
|
+
interface AuthorizationSubmission {
|
|
435
|
+
readonly method: AuthorizationMethodName;
|
|
436
|
+
readonly payload: string;
|
|
437
|
+
}
|
|
438
|
+
/**
|
|
439
|
+
* What a buyer must present, advertised with the payment challenge so a client
|
|
440
|
+
* learns before it pays that a payment proof alone will not do. The gateway
|
|
441
|
+
* never issues the authorization; it names the method, the spec version it
|
|
442
|
+
* verifies against and the payload profile it expects.
|
|
443
|
+
*/
|
|
444
|
+
interface AuthorizationRequirement {
|
|
445
|
+
readonly method: AuthorizationMethodName;
|
|
446
|
+
readonly version: string;
|
|
447
|
+
readonly profile?: string;
|
|
448
|
+
}
|
|
449
|
+
/**
|
|
450
|
+
* Safe audit identity of an authorization, fit for a receipt. `reference` is a
|
|
451
|
+
* digest, because a receipt outlives its request and a stored proof would be a
|
|
452
|
+
* spendable secret at rest.
|
|
453
|
+
*/
|
|
454
|
+
interface AuthorizationRecord {
|
|
455
|
+
readonly method: AuthorizationMethodName;
|
|
456
|
+
readonly reference: string;
|
|
457
|
+
/** Safe audit summary only. Never the proof, its disclosures, or PII */
|
|
458
|
+
readonly metadata?: Readonly<Record<string, unknown>>;
|
|
459
|
+
}
|
|
460
|
+
/**
|
|
461
|
+
* A verified, reserved authorization. `reservationId` is the handle the
|
|
462
|
+
* pipeline consumes, releases or marks uncertain once the payment resolves. It
|
|
463
|
+
* stays out of `AuthorizationRecord` because a handle is not an audit fact.
|
|
464
|
+
*/
|
|
465
|
+
interface AuthorizationVerification extends AuthorizationRecord {
|
|
466
|
+
readonly status: 'verified';
|
|
467
|
+
readonly reservationId: string;
|
|
468
|
+
}
|
|
469
|
+
/** Input to {@link AuthorizationProvider.verifyAndReserve} */
|
|
470
|
+
interface AuthorizationVerificationContext {
|
|
471
|
+
readonly requestId: string;
|
|
472
|
+
readonly resourceId: string;
|
|
473
|
+
/**
|
|
474
|
+
* The validated resource input with reserved fields stripped: the same value
|
|
475
|
+
* the merchant backend is called with. A provider that binds a proof to the
|
|
476
|
+
* request hashes it, so it excludes `_payment`, `_authorization`, the request
|
|
477
|
+
* id and transport metadata.
|
|
478
|
+
*/
|
|
479
|
+
readonly input: unknown;
|
|
480
|
+
readonly submission: AuthorizationSubmission;
|
|
481
|
+
/** The resolved price and destination the proof must match */
|
|
482
|
+
readonly requirement: PaymentRequirement;
|
|
483
|
+
}
|
|
484
|
+
/** Input to {@link AuthorizationProvider.consume}, `release` and `markUncertain` */
|
|
485
|
+
interface AuthorizationFinalizeContext {
|
|
486
|
+
readonly requestId: string;
|
|
487
|
+
readonly resourceId: string;
|
|
488
|
+
}
|
|
489
|
+
/**
|
|
490
|
+
* Contract every authorization method implements.
|
|
491
|
+
*
|
|
492
|
+
* The lifecycle straddles settlement: a proof is reserved before funds move, so
|
|
493
|
+
* a replay cannot race it, and its fate is known only afterwards. A reservation
|
|
494
|
+
* is released only after a failure that provably moved no money. Anything
|
|
495
|
+
* ambiguous is marked uncertain, because a proof handed back after a settlement
|
|
496
|
+
* that may have landed can be spent twice.
|
|
497
|
+
*/
|
|
498
|
+
interface AuthorizationProvider {
|
|
499
|
+
readonly name: AuthorizationMethodName;
|
|
500
|
+
readonly descriptor: AdapterDescriptor;
|
|
501
|
+
/** What a buyer must present, advertised with the payment challenge */
|
|
502
|
+
readonly requirement: AuthorizationRequirement;
|
|
503
|
+
/**
|
|
504
|
+
* Verify a submission against the resolved purchase and atomically reserve it
|
|
505
|
+
* against reuse. Throws a `CommerceError` with an `AUTHORIZATION_*` code,
|
|
506
|
+
* never a payment code; a verifier or store outage is
|
|
507
|
+
* `AUTHORIZATION_PROVIDER_UNAVAILABLE`, not the buyer's fault.
|
|
508
|
+
*/
|
|
509
|
+
verifyAndReserve(context: AuthorizationVerificationContext): Promise<AuthorizationVerification>;
|
|
510
|
+
/** Mark a reservation permanently spent. Called after settlement succeeds */
|
|
511
|
+
consume(reservationId: string, context: AuthorizationFinalizeContext): Promise<void>;
|
|
512
|
+
/** Return a reservation to unused. Only for failures that moved no funds */
|
|
513
|
+
release(reservationId: string, context: AuthorizationFinalizeContext): Promise<void>;
|
|
514
|
+
/**
|
|
515
|
+
* Settlement threw, so whether funds moved is unknown: neither spend the
|
|
516
|
+
* reservation nor hand it back, and flag it for an operator
|
|
517
|
+
*/
|
|
518
|
+
markUncertain(reservationId: string, context: AuthorizationFinalizeContext): Promise<void>;
|
|
519
|
+
health(): Promise<AdapterHealth>;
|
|
315
520
|
}
|
|
316
|
-
/** A logger that discards everything */
|
|
317
|
-
declare const NOOP_LOGGER: Logger;
|
|
318
521
|
|
|
319
522
|
interface Clock {
|
|
320
523
|
now(): Date;
|
|
@@ -328,5 +531,5 @@ interface IdGenerator {
|
|
|
328
531
|
}
|
|
329
532
|
declare const systemClock: Clock;
|
|
330
533
|
|
|
331
|
-
export {
|
|
332
|
-
export type {
|
|
534
|
+
export { RECONCILIATION_METADATA_KEY as L, systemClock as M, DEFAULT_BACKEND_TIMEOUT_MS as q, PAYMENT_METHOD_NAMES as r, PROTOCOL_NAMES as s };
|
|
535
|
+
export type { AuthorizationProvider as A, BackendHandler as B, Clock as C, DecimalAmount as D, PaymentResult as E, PaymentSettlementContext as F, PaymentVerificationContext as G, Pricing as H, IsoTimestamp as I, JsonSchema as J, ProtocolName as K, PaymentMethodName as P, ResourceRegistry as R, AuthorizationRequirement as a, CommerceResource as b, PaymentSubmission as c, AuthorizationSubmission as d, PaymentProvider as e, IdGenerator as f, AdapterDescriptor as g, AdapterHealth as h, AdapterHealthComponent as i, AuthorizationFinalizeContext as j, AuthorizationMethodName as k, AuthorizationRecord as l, AuthorizationVerification as m, AuthorizationVerificationContext as n, BackendMethod as o, CommerceReceipt as p, PaymentAttempt as t, PaymentAttemptResolution as u, PaymentChallenge as v, PaymentContext as w, PaymentReconciliationContext as x, PaymentReconciliationResult as y, PaymentRequirement as z };
|
|
@@ -0,0 +1,372 @@
|
|
|
1
|
+
import { k as AuthorizationMethodName, I as IsoTimestamp, K as ProtocolName, l as AuthorizationRecord, t as PaymentAttempt, p as CommerceReceipt, u as PaymentAttemptResolution, g as AdapterDescriptor, h as AdapterHealth } from './runtime-B-kARa2f.js';
|
|
2
|
+
import { A as AuthorizationHoldState, a as CommerceEvent, P as PersistenceFailure, c as Transaction, e as TransactionState } from './transaction-Dv0UFGg5.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Protocol-neutral records for the receipt store's optional methods:
|
|
6
|
+
* idempotency claims, authorization holds and pending tasks. Adapters and
|
|
7
|
+
* authorization providers map their own data to these types at their boundaries.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/** Experimental: may change in a minor release */
|
|
11
|
+
interface IdempotencyScope {
|
|
12
|
+
/** The gateway's public base URL, which survives a credential rotation */
|
|
13
|
+
readonly deployment: string;
|
|
14
|
+
/** The concrete endpoint path, so a client may reuse one key across operations */
|
|
15
|
+
readonly endpoint: string;
|
|
16
|
+
readonly key: string;
|
|
17
|
+
}
|
|
18
|
+
/** Result of claiming an idempotency key. Experimental: may change in a minor release */
|
|
19
|
+
type IdempotencyClaim =
|
|
20
|
+
/** The caller owns the key and must perform the operation */
|
|
21
|
+
{
|
|
22
|
+
readonly kind: 'reserved';
|
|
23
|
+
}
|
|
24
|
+
/** Same fingerprint; an earlier claim is still in flight */
|
|
25
|
+
| {
|
|
26
|
+
readonly kind: 'in-flight';
|
|
27
|
+
}
|
|
28
|
+
/** Same fingerprint; an earlier attempt's outcome is unknown */
|
|
29
|
+
| {
|
|
30
|
+
readonly kind: 'unresolved';
|
|
31
|
+
}
|
|
32
|
+
/** A different fingerprint, regardless of the claim's state */
|
|
33
|
+
| {
|
|
34
|
+
readonly kind: 'conflict';
|
|
35
|
+
}
|
|
36
|
+
/** Same fingerprint; replay the stored response */
|
|
37
|
+
| {
|
|
38
|
+
readonly kind: 'replay';
|
|
39
|
+
readonly status: number;
|
|
40
|
+
readonly body: unknown;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* An idempotency claim's outcome. `body` must be JSON-serializable.
|
|
44
|
+
* Experimental: may change in a minor release.
|
|
45
|
+
*/
|
|
46
|
+
type IdempotencyUpdate =
|
|
47
|
+
/** Store the response for later claims with the same fingerprint to replay */
|
|
48
|
+
{
|
|
49
|
+
readonly kind: 'completed';
|
|
50
|
+
readonly status: number;
|
|
51
|
+
readonly body: unknown;
|
|
52
|
+
}
|
|
53
|
+
/** Keep the claim without a response and refuse retries: the operation may have run */
|
|
54
|
+
| {
|
|
55
|
+
readonly kind: 'unresolved';
|
|
56
|
+
}
|
|
57
|
+
/** Delete only if no backend call ran or the backend deduplicates by this key */
|
|
58
|
+
| {
|
|
59
|
+
readonly kind: 'released';
|
|
60
|
+
};
|
|
61
|
+
/** Experimental: may change in a minor release */
|
|
62
|
+
interface AuthorizationHoldReservation {
|
|
63
|
+
readonly method: AuthorizationMethodName;
|
|
64
|
+
/** Identifies one authorization, unique across the store. AP2: the issuer-signed token's digest */
|
|
65
|
+
readonly reference: string;
|
|
66
|
+
/** Identifies a binding with at most one unreleased hold. AP2: the checkout JWT's `jti` */
|
|
67
|
+
readonly bindingReference: string;
|
|
68
|
+
readonly resourceId: string;
|
|
69
|
+
readonly requestId: string;
|
|
70
|
+
/** Non-secret operator identifiers, such as issuers; never presentations or signatures */
|
|
71
|
+
readonly metadata?: Readonly<Record<string, string>>;
|
|
72
|
+
}
|
|
73
|
+
/** Experimental: may change in a minor release */
|
|
74
|
+
type AuthorizationHoldResult = {
|
|
75
|
+
readonly kind: 'reserved';
|
|
76
|
+
}
|
|
77
|
+
/** The reference or its binding is already held; refuse the authorization */
|
|
78
|
+
| {
|
|
79
|
+
readonly kind: 'replayed';
|
|
80
|
+
readonly state: AuthorizationHoldState;
|
|
81
|
+
};
|
|
82
|
+
/** Experimental: may change in a minor release */
|
|
83
|
+
interface AuthorizationHold extends AuthorizationHoldReservation {
|
|
84
|
+
readonly state: AuthorizationHoldState;
|
|
85
|
+
readonly createdAt: IsoTimestamp;
|
|
86
|
+
readonly updatedAt: IsoTimestamp;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* A purchase awaiting its payment message. Experimental: may change in a
|
|
90
|
+
* minor release.
|
|
91
|
+
*/
|
|
92
|
+
interface PendingTask {
|
|
93
|
+
/** Unique across the store */
|
|
94
|
+
readonly id: string;
|
|
95
|
+
readonly protocol: ProtocolName;
|
|
96
|
+
readonly resourceId: string;
|
|
97
|
+
/**
|
|
98
|
+
* JSON-serializable purchase input with reserved fields removed. Must not
|
|
99
|
+
* contain payment proofs or authorization presentations.
|
|
100
|
+
*/
|
|
101
|
+
readonly input: Readonly<Record<string, unknown>>;
|
|
102
|
+
/** JSON-serializable data that only the adapter interprets */
|
|
103
|
+
readonly adapterData?: Readonly<Record<string, unknown>>;
|
|
104
|
+
/** Set and bounded by the caller */
|
|
105
|
+
readonly expiresAt: IsoTimestamp;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Persistence boundary for receipts, events and payment attempts, implemented
|
|
110
|
+
* by src/storage/receipts. Core depends only on this interface, never on
|
|
111
|
+
* SQLite.
|
|
112
|
+
*/
|
|
113
|
+
|
|
114
|
+
interface PaymentAttemptReservation {
|
|
115
|
+
readonly requestId: string;
|
|
116
|
+
readonly resourceId: string;
|
|
117
|
+
readonly provider: string;
|
|
118
|
+
/** Must be unique across the store; see `PaymentResult.replayKey` */
|
|
119
|
+
readonly replayKey: string;
|
|
120
|
+
readonly amount: string;
|
|
121
|
+
readonly currency: string;
|
|
122
|
+
readonly payer?: string;
|
|
123
|
+
readonly payee?: string;
|
|
124
|
+
/**
|
|
125
|
+
* Reclaim this `replayKey` if the same `provider` rejected it, which
|
|
126
|
+
* settled nothing. Set only for rails whose authorizations remain reusable
|
|
127
|
+
* until settled.
|
|
128
|
+
*/
|
|
129
|
+
readonly reclaimRejected?: boolean;
|
|
130
|
+
/**
|
|
131
|
+
* Journal data to write atomically with the reservation. Stores without
|
|
132
|
+
* journal support ignore it.
|
|
133
|
+
*/
|
|
134
|
+
readonly transaction?: NewTransaction;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Data for a journal row opened with a replay reservation. Journal stores
|
|
138
|
+
* must initialize an included authorization hold as `reserved`. The reservation
|
|
139
|
+
* supplies the request, resource, provider, replay key, amount, currency and
|
|
140
|
+
* payee.
|
|
141
|
+
*/
|
|
142
|
+
interface NewTransaction {
|
|
143
|
+
readonly id: string;
|
|
144
|
+
readonly protocol: ProtocolName;
|
|
145
|
+
readonly network?: string;
|
|
146
|
+
readonly asset?: string;
|
|
147
|
+
readonly locator?: Readonly<Record<string, unknown>>;
|
|
148
|
+
readonly expiresAt?: IsoTimestamp;
|
|
149
|
+
readonly authorization?: AuthorizationRecord & {
|
|
150
|
+
readonly reservationId: string;
|
|
151
|
+
};
|
|
152
|
+
readonly inputDigest?: string;
|
|
153
|
+
readonly configDigest: string;
|
|
154
|
+
}
|
|
155
|
+
/** A journal update after replay reservation */
|
|
156
|
+
type TransactionStep = {
|
|
157
|
+
readonly transactionId: string;
|
|
158
|
+
readonly at: IsoTimestamp;
|
|
159
|
+
} & ({
|
|
160
|
+
readonly kind: 'settling';
|
|
161
|
+
} | {
|
|
162
|
+
readonly kind: 'hold';
|
|
163
|
+
readonly hold: AuthorizationHoldState;
|
|
164
|
+
} | {
|
|
165
|
+
readonly kind: 'backend-dispatched';
|
|
166
|
+
readonly deadlineAt: IsoTimestamp;
|
|
167
|
+
} | {
|
|
168
|
+
readonly kind: 'backend-result';
|
|
169
|
+
readonly status: number;
|
|
170
|
+
readonly errorCode?: string;
|
|
171
|
+
} | {
|
|
172
|
+
readonly kind: 'receipt';
|
|
173
|
+
readonly receiptId: string;
|
|
174
|
+
} | {
|
|
175
|
+
readonly kind: 'completed';
|
|
176
|
+
readonly persistenceFailures?: readonly PersistenceFailure[];
|
|
177
|
+
});
|
|
178
|
+
interface TransactionListOptions extends ListOptions {
|
|
179
|
+
/** Opaque cursor from a previous page's `nextCursor` */
|
|
180
|
+
readonly cursor?: string;
|
|
181
|
+
readonly state?: TransactionState;
|
|
182
|
+
/** When true, exclude `delivered` and `payment-failed` states */
|
|
183
|
+
readonly unresolved?: boolean;
|
|
184
|
+
/** When true, filter for `reserved` or `uncertain` authorization holds */
|
|
185
|
+
readonly pendingHold?: boolean;
|
|
186
|
+
}
|
|
187
|
+
/** Transactions in newest-first order */
|
|
188
|
+
interface TransactionPage {
|
|
189
|
+
readonly transactions: readonly Transaction[];
|
|
190
|
+
/**
|
|
191
|
+
* Continue with this cursor even when filtering returns fewer than `limit`
|
|
192
|
+
* transactions, including an empty page. Pagination ends when it is absent.
|
|
193
|
+
*/
|
|
194
|
+
readonly nextCursor?: string;
|
|
195
|
+
}
|
|
196
|
+
interface PaymentAttemptResolveRequest {
|
|
197
|
+
readonly attemptId: string;
|
|
198
|
+
/** Update only if the attempt still has this status and no resolution */
|
|
199
|
+
readonly expectedStatus: PaymentAttempt['status'];
|
|
200
|
+
readonly status: 'settled' | 'rejected';
|
|
201
|
+
readonly rejectionReason?: string;
|
|
202
|
+
readonly resolution: PaymentAttemptResolution;
|
|
203
|
+
}
|
|
204
|
+
interface PaymentAttemptUpdate {
|
|
205
|
+
readonly replayKey: string;
|
|
206
|
+
readonly status: PaymentAttempt['status'];
|
|
207
|
+
readonly externalReference?: string;
|
|
208
|
+
readonly rejectionReason?: string;
|
|
209
|
+
}
|
|
210
|
+
interface ListOptions {
|
|
211
|
+
readonly limit?: number;
|
|
212
|
+
readonly requestId?: string;
|
|
213
|
+
}
|
|
214
|
+
interface ReceiptListOptions extends ListOptions {
|
|
215
|
+
/**
|
|
216
|
+
* When true, return only receipts counted by {@link ReceiptStore.countUndeliveredReceipts}.
|
|
217
|
+
* Stores ignoring this flag also return delivered receipts.
|
|
218
|
+
*/
|
|
219
|
+
readonly undelivered?: boolean;
|
|
220
|
+
}
|
|
221
|
+
interface PaymentAttemptListOptions extends ListOptions {
|
|
222
|
+
/**
|
|
223
|
+
* When true, return only attempts counted by {@link ReceiptStore.countUncertainPaymentAttempts}.
|
|
224
|
+
* Stores that ignore this flag do not filter by settlement status.
|
|
225
|
+
*/
|
|
226
|
+
readonly uncertain?: boolean;
|
|
227
|
+
}
|
|
228
|
+
interface ReceiptStore {
|
|
229
|
+
init(): Promise<void>;
|
|
230
|
+
/** Append a canonical event. Must not throw into the caller's flow */
|
|
231
|
+
appendEvent(event: CommerceEvent): Promise<void>;
|
|
232
|
+
/**
|
|
233
|
+
* Atomically reserve a payment authorization before settlement. If its
|
|
234
|
+
* `replayKey` is already reserved, throws `CommerceError('PAYMENT_REPLAYED')`
|
|
235
|
+
* with the existing attempt's `PaymentAttempt.status` in
|
|
236
|
+
* `details.attemptStatus` when available.
|
|
237
|
+
*
|
|
238
|
+
* With `reclaimRejected`, replace the same provider's `rejected` attempt,
|
|
239
|
+
* which settled nothing. Only one concurrent claim can replace it with the
|
|
240
|
+
* new reservation.
|
|
241
|
+
*/
|
|
242
|
+
reservePaymentAttempt(reservation: PaymentAttemptReservation): Promise<PaymentAttempt>;
|
|
243
|
+
/** Must not change an attempt that has a resolution; the SQLite store throws `STORAGE_ERROR` */
|
|
244
|
+
updatePaymentAttempt(update: PaymentAttemptUpdate): Promise<void>;
|
|
245
|
+
saveReceipt(receipt: CommerceReceipt): Promise<void>;
|
|
246
|
+
getReceipt(id: string): Promise<CommerceReceipt | undefined>;
|
|
247
|
+
listReceipts(options?: ReceiptListOptions): Promise<readonly CommerceReceipt[]>;
|
|
248
|
+
/**
|
|
249
|
+
* Total receipts held. `listReceipts` clamps every page, so counting a list's
|
|
250
|
+
* length would stop at the clamp.
|
|
251
|
+
*/
|
|
252
|
+
countReceipts(): Promise<number>;
|
|
253
|
+
/**
|
|
254
|
+
* Receipts whose delivery failed: `backendStatus` outside 2xx, including 0
|
|
255
|
+
* when no status is known. Counted rather than listed for the same reason as
|
|
256
|
+
* {@link countReceipts}.
|
|
257
|
+
*
|
|
258
|
+
* In practice this is "paid but undelivered": the pipeline writes a receipt
|
|
259
|
+
* for a failed delivery only after a settled payment, so a free resource
|
|
260
|
+
* whose backend fails leaves no row here. It is the row a merchant must
|
|
261
|
+
* notice, because settlement is final and the gateway issues no refunds.
|
|
262
|
+
*/
|
|
263
|
+
countUndeliveredReceipts(): Promise<number>;
|
|
264
|
+
/**
|
|
265
|
+
* Counts `settlement-uncertain` and legacy `failed` payment attempts.
|
|
266
|
+
* Funds may have moved, but the pipeline withholds delivery and writes no
|
|
267
|
+
* receipt for an uncertain settlement. {@link countUndeliveredReceipts}
|
|
268
|
+
* therefore misses these attempts. Reconcile them on chain using
|
|
269
|
+
* `externalReference` when it holds a transaction hash.
|
|
270
|
+
*/
|
|
271
|
+
countUncertainPaymentAttempts(): Promise<number>;
|
|
272
|
+
listEvents(options?: ListOptions): Promise<readonly CommerceEvent[]>;
|
|
273
|
+
listPaymentAttempts(options?: PaymentAttemptListOptions): Promise<readonly PaymentAttempt[]>;
|
|
274
|
+
/**
|
|
275
|
+
* Record a journal step. Journal methods are optional for compatibility with
|
|
276
|
+
* stores that do not support the journal. Implementations must also recompute
|
|
277
|
+
* a transaction's cached state atomically with payment-attempt updates.
|
|
278
|
+
*/
|
|
279
|
+
recordTransactionStep?(step: TransactionStep): Promise<void>;
|
|
280
|
+
getTransaction?(id: string): Promise<Transaction | undefined>;
|
|
281
|
+
listTransactions?(options?: TransactionListOptions): Promise<TransactionPage>;
|
|
282
|
+
getPaymentAttempt?(id: string): Promise<PaymentAttempt | undefined>;
|
|
283
|
+
/**
|
|
284
|
+
* Returns the current attempt holding `replayKey`, excluding attempts
|
|
285
|
+
* replaced by a reclaim. If a rejected proof carries this key, the pipeline
|
|
286
|
+
* uses the lookup to return `PAYMENT_REPLAYED` while its attempt is unfinished.
|
|
287
|
+
* Experimental: may change in a minor release.
|
|
288
|
+
*/
|
|
289
|
+
findPaymentAttemptByReplayKey?(replayKey: string): Promise<PaymentAttempt | undefined>;
|
|
290
|
+
/**
|
|
291
|
+
* Compare-and-set: return `false` without writing if the attempt's status
|
|
292
|
+
* differs from `expectedStatus` or it already has a resolution
|
|
293
|
+
*/
|
|
294
|
+
resolvePaymentAttempt?(request: PaymentAttemptResolveRequest): Promise<boolean>;
|
|
295
|
+
/**
|
|
296
|
+
* Idempotency claims for protocol adapters. A store must implement all three
|
|
297
|
+
* methods or none. Experimental: may change in a minor release.
|
|
298
|
+
*
|
|
299
|
+
* Atomically claim `scope` after deleting `completed` claims whose
|
|
300
|
+
* `expiresAt` has passed. Other states do not expire. Return `reserved` for
|
|
301
|
+
* a new scope, or `conflict` for a different `fingerprint`, regardless of
|
|
302
|
+
* the existing claim's state.
|
|
303
|
+
*/
|
|
304
|
+
claimIdempotencyKey?(scope: IdempotencyScope, fingerprint: string, expiresAt: IsoTimestamp): Promise<IdempotencyClaim>;
|
|
305
|
+
/** Record a claim's outcome. Experimental: may change in a minor release */
|
|
306
|
+
updateIdempotencyKey?(scope: IdempotencyScope, update: IdempotencyUpdate): Promise<void>;
|
|
307
|
+
/**
|
|
308
|
+
* Call at startup before accepting claims. Mark every `in-flight` claim
|
|
309
|
+
* `unresolved`, or delete them if `release` is true. Return the number
|
|
310
|
+
* changed. Assumes one gateway per store. Experimental: may change in a
|
|
311
|
+
* minor release.
|
|
312
|
+
*/
|
|
313
|
+
recoverIdempotencyKeys?(options: {
|
|
314
|
+
readonly release: boolean;
|
|
315
|
+
}): Promise<number>;
|
|
316
|
+
/**
|
|
317
|
+
* Authorization holds for authorization providers. A store must implement
|
|
318
|
+
* all four methods or none. Experimental: may change in a minor release.
|
|
319
|
+
*
|
|
320
|
+
* Atomically reserve a hold. Return `replayed` with the existing holder's
|
|
321
|
+
* state if this reference, or another with the same `bindingReference`, is
|
|
322
|
+
* not `released`. A released reference can be reserved again by the new
|
|
323
|
+
* `requestId`.
|
|
324
|
+
*/
|
|
325
|
+
reserveAuthorizationHold?(reservation: AuthorizationHoldReservation): Promise<AuthorizationHoldResult>;
|
|
326
|
+
/**
|
|
327
|
+
* Move a `reserved` or `uncertain` hold to `to`. This method leaves
|
|
328
|
+
* `consumed` and `released` holds unchanged. When supplied, `requestId`
|
|
329
|
+
* restricts changes to that request's hold. Return true when the hold is
|
|
330
|
+
* in `to`, including on repeated calls. If `requestId` no longer holds the
|
|
331
|
+
* reference, leave the current hold unchanged and return true only when
|
|
332
|
+
* `to` is `released`. Return false otherwise. Experimental: may change in
|
|
333
|
+
* a minor release.
|
|
334
|
+
*/
|
|
335
|
+
transitionAuthorizationHold?(reference: string, to: Exclude<AuthorizationHoldState, 'reserved'>, requestId?: string): Promise<boolean>;
|
|
336
|
+
/** Experimental: may change in a minor release */
|
|
337
|
+
getAuthorizationHoldState?(reference: string): Promise<AuthorizationHoldState | undefined>;
|
|
338
|
+
/**
|
|
339
|
+
* List `reserved` holds last updated before `updatedBefore`, oldest first,
|
|
340
|
+
* whose request has no current or replaced payment attempt. The pipeline
|
|
341
|
+
* reserves an attempt before settlement, so after the request ends it cannot
|
|
342
|
+
* settle a payment for such a hold. Experimental: may change in a minor
|
|
343
|
+
* release.
|
|
344
|
+
*/
|
|
345
|
+
listOrphanAuthorizationHolds?(options: {
|
|
346
|
+
readonly updatedBefore: IsoTimestamp;
|
|
347
|
+
readonly limit?: number;
|
|
348
|
+
}): Promise<readonly AuthorizationHold[]>;
|
|
349
|
+
/**
|
|
350
|
+
* Pending tasks for protocol adapters. A store must implement all three
|
|
351
|
+
* methods or none. Experimental: may change in a minor release.
|
|
352
|
+
*
|
|
353
|
+
* Delete expired tasks, then store `task`, replacing any task with the same
|
|
354
|
+
* ID. Return false without storing when `maxTasks` unexpired tasks exist.
|
|
355
|
+
*/
|
|
356
|
+
putPendingTask?(task: PendingTask, options: {
|
|
357
|
+
readonly maxTasks: number;
|
|
358
|
+
}): Promise<boolean>;
|
|
359
|
+
/** Return undefined for a missing or expired task. Experimental: may change in a minor release */
|
|
360
|
+
getPendingTask?(id: string): Promise<PendingTask | undefined>;
|
|
361
|
+
/**
|
|
362
|
+
* Atomically delete and return the task. Return undefined if it has expired
|
|
363
|
+
* or a concurrent or earlier call already took it. Experimental: may change
|
|
364
|
+
* in a minor release.
|
|
365
|
+
*/
|
|
366
|
+
takePendingTask?(id: string): Promise<PendingTask | undefined>;
|
|
367
|
+
readonly descriptor: AdapterDescriptor;
|
|
368
|
+
health(): Promise<AdapterHealth>;
|
|
369
|
+
close(): Promise<void>;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
export type { AuthorizationHold as A, IdempotencyClaim as I, ListOptions as L, NewTransaction as N, PaymentAttemptListOptions as P, ReceiptStore as R, TransactionListOptions as T, AuthorizationHoldReservation as a, AuthorizationHoldResult as b, IdempotencyScope as c, IdempotencyUpdate as d, PaymentAttemptReservation as e, PaymentAttemptResolveRequest as f, PaymentAttemptUpdate as g, PendingTask as h, ReceiptListOptions as i, TransactionPage as j, TransactionStep as k };
|