@dexterai/x402 5.4.2 → 6.0.0-rc.1
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 +19 -4
- package/REFERENCE.md +81 -8
- package/dist/adapters/index.d.cts +3 -3
- package/dist/adapters/index.d.ts +3 -3
- package/dist/batch-settlement/index.d.cts +3 -3
- package/dist/batch-settlement/index.d.ts +3 -3
- package/dist/batch-settlement/seller/index.d.cts +4 -4
- package/dist/batch-settlement/seller/index.d.ts +4 -4
- package/dist/client/index.cjs +1 -1
- package/dist/client/index.d.cts +6 -6
- package/dist/client/index.d.ts +6 -6
- package/dist/client/index.js +1 -1
- package/dist/{constants-Icc4CXNG.d.cts → constants-BLvApMMl.d.cts} +1 -1
- package/dist/{constants-Icc4CXNG.d.ts → constants-BLvApMMl.d.ts} +1 -1
- package/dist/react/index.cjs +1 -1
- package/dist/react/index.d.cts +4 -4
- package/dist/react/index.d.ts +4 -4
- package/dist/react/index.js +1 -1
- package/dist/server/index.cjs +1 -1
- package/dist/server/index.d.cts +5 -5
- package/dist/server/index.d.ts +5 -5
- package/dist/server/index.js +1 -1
- package/dist/{sessions-BG2OYLBi.d.cts → sessions-rPdO1CgK.d.cts} +35 -3
- package/dist/{sessions-BG2OYLBi.d.ts → sessions-rPdO1CgK.d.ts} +35 -3
- package/dist/tab/adapters/solana/index.cjs +1 -1
- package/dist/tab/adapters/solana/index.d.cts +181 -26
- package/dist/tab/adapters/solana/index.d.ts +181 -26
- package/dist/tab/adapters/solana/index.js +1 -1
- package/dist/tab/index.cjs +5 -5
- package/dist/tab/index.d.cts +126 -21
- package/dist/tab/index.d.ts +126 -21
- package/dist/tab/index.js +4 -4
- package/dist/tab/seller/index.cjs +4 -4
- package/dist/tab/seller/index.d.cts +34 -26
- package/dist/tab/seller/index.d.ts +34 -26
- package/dist/tab/seller/index.js +4 -4
- package/dist/{types-BdS_uvNs.d.cts → types-BbvuPNXl.d.cts} +2 -2
- package/dist/{types-xQu1U4xk.d.cts → types-BvQpNtFw.d.cts} +9 -1
- package/dist/{types-xQu1U4xk.d.ts → types-BvQpNtFw.d.ts} +9 -1
- package/dist/{types-DY8xKheW.d.ts → types-CkcNYx1Q.d.ts} +2 -2
- package/dist/{types-Co5YYhVB.d.ts → types-CwLPKV8T.d.ts} +3 -3
- package/dist/{types-CZHPdVkg.d.cts → types-DnhCOjDx.d.cts} +3 -3
- package/dist/{types-_wdHzVG-.d.ts → types-DwVhPqOZ.d.ts} +2 -2
- package/dist/{types-WMqs5xII.d.cts → types-JpkrtFbZ.d.cts} +2 -2
- package/dist/{types-CSuISjXA.d.cts → types-OHNNM1J2.d.cts} +122 -7
- package/dist/{types-CSuISjXA.d.ts → types-OHNNM1J2.d.ts} +122 -7
- package/dist/utils/index.d.cts +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/{x402-client-BQKDeNxq.d.cts → x402-client-B8zdDeat.d.cts} +2 -2
- package/dist/{x402-client-BQKDeNxq.d.ts → x402-client-B8zdDeat.d.ts} +2 -2
- package/package.json +7 -6
|
@@ -25,10 +25,17 @@ interface VaultAdapter {
|
|
|
25
25
|
swigAddress: string;
|
|
26
26
|
/** Program/contract account holding the OTS gate state. */
|
|
27
27
|
vaultPda: string;
|
|
28
|
+
/**
|
|
29
|
+
* Voucher generation this adapter issues. V6 requires `2` for buyer-side
|
|
30
|
+
* open/recovery. The `1` discriminator remains only so a historical adapter
|
|
31
|
+
* is rejected explicitly instead of being mistaken for V2 or silently
|
|
32
|
+
* falling through after an obligation may exist.
|
|
33
|
+
*/
|
|
34
|
+
readonly sessionVoucherVersion: 1 | 2;
|
|
28
35
|
/**
|
|
29
36
|
* Use the ROOT signer (passkey) to authorize a fresh session key. This is
|
|
30
|
-
* the only call that prompts the user
|
|
31
|
-
*
|
|
37
|
+
* the only call that prompts the user. V7 live replacement binds retirement
|
|
38
|
+
* and replacement into one ceremony. Returns a
|
|
32
39
|
* session that can be passed to `signWithSession` freely until the scope's
|
|
33
40
|
* cap or expiry is reached.
|
|
34
41
|
*
|
|
@@ -54,7 +61,90 @@ interface VaultAdapter {
|
|
|
54
61
|
* facilitator settles via `settle_voucher(amount, increment: false)`.
|
|
55
62
|
*/
|
|
56
63
|
signCloseTab(session: SessionKey, channelId: string, cumulativeAmount: AtomicAmount): Promise<Uint8Array>;
|
|
64
|
+
/**
|
|
65
|
+
* V2-only independent postcondition check. The reservation provider returns
|
|
66
|
+
* a voucher-bound receipt; the adapter must then prove the corresponding
|
|
67
|
+
* finalized on-chain reservation and authority-signed voucher-binding Memo
|
|
68
|
+
* from its own chain connection before the voucher may leave this process.
|
|
69
|
+
* V1 adapters omit this method.
|
|
70
|
+
*/
|
|
71
|
+
verifyFinalVoucherV2Reservation?: VerifyFinalVoucherV2Reservation;
|
|
72
|
+
}
|
|
73
|
+
/** Exact durable release fence for a buyer-signed FINAL V2 voucher. */
|
|
74
|
+
interface FinalVoucherV2ReservationInput {
|
|
75
|
+
network: TabNetworkId;
|
|
76
|
+
programId: string;
|
|
77
|
+
buyerSwigAddress: string;
|
|
78
|
+
vaultPda: string;
|
|
79
|
+
sessionPda: string;
|
|
80
|
+
seller: string;
|
|
81
|
+
channelId: string;
|
|
82
|
+
sessionNonce: number;
|
|
83
|
+
reservationAmountAtomic: AtomicAmount;
|
|
84
|
+
previousCumulativeAtomic: AtomicAmount;
|
|
85
|
+
/** SHA-256 of the canonical complete voucher identity. */
|
|
86
|
+
voucherDigest: string;
|
|
87
|
+
/** SDK retry identity. Exact-byte retries retain this value; provider
|
|
88
|
+
* lifecycle and receipt identities remain provider-owned and distinct. */
|
|
89
|
+
idempotencyKey: string;
|
|
90
|
+
voucher: SignedVoucher;
|
|
57
91
|
}
|
|
92
|
+
/**
|
|
93
|
+
* Provider attestation returned only after its durable transaction lifecycle
|
|
94
|
+
* has finalized the exact reservation and read back the exact post-state.
|
|
95
|
+
* The SDK validates every voucher/session field and the VaultAdapter proves
|
|
96
|
+
* both the reservation and its authority-signed voucher-binding Memo from the
|
|
97
|
+
* transaction itself; this is deliberately not a boolean ack.
|
|
98
|
+
*/
|
|
99
|
+
interface FinalVoucherV2ReservationReceipt {
|
|
100
|
+
contract: 'dexter-native-tab-open-receipt/v1' | 'dexter-native-tab-open-receipt/v2';
|
|
101
|
+
operationId: string;
|
|
102
|
+
callerOperationId: string;
|
|
103
|
+
network: string;
|
|
104
|
+
transaction: string;
|
|
105
|
+
/** FINAL vouchers are released only after the exact reservation transaction
|
|
106
|
+
* reaches Solana finalized commitment. A merely confirmed fork is not a
|
|
107
|
+
* durable capacity guarantee. */
|
|
108
|
+
commitment: 'finalized';
|
|
109
|
+
confirmationSlot: number;
|
|
110
|
+
postStateSlot: number;
|
|
111
|
+
buyerSwigAddress: string;
|
|
112
|
+
vaultPda: string;
|
|
113
|
+
sessionPda: string;
|
|
114
|
+
seller: string;
|
|
115
|
+
channelId: string;
|
|
116
|
+
sessionPublicKey: string;
|
|
117
|
+
voucherDigest: string;
|
|
118
|
+
cumulativeAmountAtomic: string;
|
|
119
|
+
sequenceNumber: number;
|
|
120
|
+
providerReceiptId: string;
|
|
121
|
+
reservationAmountAtomic: string;
|
|
122
|
+
pendingVoucherCountBefore: number;
|
|
123
|
+
pendingVoucherCountAfter: number;
|
|
124
|
+
currentOutstandingBeforeAtomic: '0';
|
|
125
|
+
currentOutstandingAfterAtomic: string;
|
|
126
|
+
rootOperationId?: string;
|
|
127
|
+
generation?: number;
|
|
128
|
+
predecessorCallerOperationId?: string;
|
|
129
|
+
predecessorLifecycleOperationId?: string;
|
|
130
|
+
predecessorReleaseDigest?: string;
|
|
131
|
+
stableReservationId?: string;
|
|
132
|
+
economicEffectDigest?: string;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Voucher released by a live Tab handle. Historical V1 vouchers omit the
|
|
136
|
+
* receipt. Every V2 voucher carries the complete provider receipt that the
|
|
137
|
+
* buyer already verified before release; sellers still treat that receipt as
|
|
138
|
+
* untrusted evidence and independently prove its finalized transaction.
|
|
139
|
+
*
|
|
140
|
+
* This extends the existing SignedVoucher shape so existing callers that only
|
|
141
|
+
* consume the four signed fields remain source-compatible.
|
|
142
|
+
*/
|
|
143
|
+
interface TabSignedVoucher extends SignedVoucher {
|
|
144
|
+
readonly reservationReceipt?: FinalVoucherV2ReservationReceipt;
|
|
145
|
+
}
|
|
146
|
+
type ReserveFinalVoucherV2 = (input: FinalVoucherV2ReservationInput) => Promise<FinalVoucherV2ReservationReceipt>;
|
|
147
|
+
type VerifyFinalVoucherV2Reservation = (input: FinalVoucherV2ReservationInput, receipt: FinalVoucherV2ReservationReceipt) => Promise<void>;
|
|
58
148
|
/**
|
|
59
149
|
* Live-session policy for `authorizeSession` / `openTab` (K-T4e).
|
|
60
150
|
*
|
|
@@ -69,8 +159,7 @@ interface VaultAdapter {
|
|
|
69
159
|
* (`tab.close()` — or POST its last signed voucher to `/tab/settle`) and
|
|
70
160
|
* retries, or acknowledges the replace explicitly.
|
|
71
161
|
* - `'replace'`: compose the ATOMIC same-transaction
|
|
72
|
-
* [secp(
|
|
73
|
-
* left sessionless mid-flow. Costs a second passkey ceremony. Value
|
|
162
|
+
* [secp(replace), replace] so the buyer is never left sessionless. Value
|
|
74
163
|
* already settled or crystallized into LockedClaims survives the replace;
|
|
75
164
|
* anything signed beyond the frontier is voided.
|
|
76
165
|
*/
|
|
@@ -106,6 +195,14 @@ interface TabState {
|
|
|
106
195
|
interface Tab {
|
|
107
196
|
/** Deterministic channel id derived from buyer/seller/scope/salt. */
|
|
108
197
|
readonly channelId: string;
|
|
198
|
+
/**
|
|
199
|
+
* Voucher contract used by this live handle. V2 FINAL vouchers are fenced
|
|
200
|
+
* by a durable reservation and therefore may never fall through to another
|
|
201
|
+
* payment rail after an indeterminate signing/reservation error.
|
|
202
|
+
*
|
|
203
|
+
* Required in v6. An absent generation is not safely equivalent to V1.
|
|
204
|
+
*/
|
|
205
|
+
readonly voucherVersion: 1 | 2;
|
|
109
206
|
/** Which network the underlying vault lives on. */
|
|
110
207
|
readonly network: TabNetworkId;
|
|
111
208
|
/**
|
|
@@ -124,7 +221,7 @@ interface Tab {
|
|
|
124
221
|
* Same counter, same scope enforcement as stream() — throws
|
|
125
222
|
* SessionScopeExceededError past the cap.
|
|
126
223
|
*/
|
|
127
|
-
signNextVoucher(incrementAtomic: AtomicAmount): Promise<
|
|
224
|
+
signNextVoucher(incrementAtomic: AtomicAmount): Promise<TabSignedVoucher>;
|
|
128
225
|
/**
|
|
129
226
|
* Streamed paid request. Returns an async iterable of chunks. Voucher
|
|
130
227
|
* signing is internal: the seller demands a fresh session-signed voucher
|
|
@@ -179,7 +276,7 @@ interface OpenTabOptions {
|
|
|
179
276
|
vault: VaultAdapter;
|
|
180
277
|
/** CAIP-2-style network the vault lives on; cross-checked against vault.network. */
|
|
181
278
|
network: TabNetworkId;
|
|
182
|
-
/** Seller's
|
|
279
|
+
/** Seller's base58 Solana public key for the counterparty binding. */
|
|
183
280
|
seller: string;
|
|
184
281
|
/** Max amount per voucher — caps how aggressive a single charge can be. */
|
|
185
282
|
perUnitCap: HumanAmount;
|
|
@@ -203,6 +300,12 @@ interface OpenTabOptions {
|
|
|
203
300
|
* See {@link AuthorizeSessionOptions}.
|
|
204
301
|
*/
|
|
205
302
|
onLiveSession?: 'error' | 'replace';
|
|
303
|
+
/**
|
|
304
|
+
* Required by V2-capable adapters. The callback must durably persist and
|
|
305
|
+
* establish the exact FINAL voucher reservation before resolving. It must
|
|
306
|
+
* be idempotent for identical voucher bytes; a timeout is retried exactly.
|
|
307
|
+
*/
|
|
308
|
+
reserveFinalVoucherV2?: ReserveFinalVoucherV2;
|
|
206
309
|
}
|
|
207
310
|
/**
|
|
208
311
|
* Options for `resumeTab` — open a handle to a tab that was opened by a
|
|
@@ -227,6 +330,18 @@ declare class UnsupportedNetworkError extends Error {
|
|
|
227
330
|
readonly network: string;
|
|
228
331
|
constructor(network: string);
|
|
229
332
|
}
|
|
333
|
+
/**
|
|
334
|
+
* Thrown before buyer-side I/O when v6 is asked to open or reconstruct a
|
|
335
|
+
* historical V1 tab. The coupled v6 facilitator has no compatible V1 arming
|
|
336
|
+
* endpoint and the Vault-wide pending counter cannot prove which historical
|
|
337
|
+
* session owns an existing reservation. Seller-side verification of already
|
|
338
|
+
* issued V1 vouchers remains available so those obligations can be settled.
|
|
339
|
+
*/
|
|
340
|
+
declare class HistoricalV1MigrationRequiredError extends Error {
|
|
341
|
+
readonly surface: 'armTabOpen' | 'openTab' | 'tabFromGrant';
|
|
342
|
+
readonly code = "native_tab_v1_migration_required";
|
|
343
|
+
constructor(surface: 'armTabOpen' | 'openTab' | 'tabFromGrant');
|
|
344
|
+
}
|
|
230
345
|
/** Thrown by a buyer call when the session-key cap or expiry would be exceeded. */
|
|
231
346
|
declare class SessionScopeExceededError extends Error {
|
|
232
347
|
readonly reason: 'cap_exceeded' | 'expired' | 'wrong_counterparty';
|
|
@@ -277,4 +392,4 @@ declare class LiveSessionExistsError extends Error {
|
|
|
277
392
|
constructor(details: LiveSessionDetails);
|
|
278
393
|
}
|
|
279
394
|
|
|
280
|
-
export { type AuthorizeSessionOptions as A, type LiveSessionDetails as L, type OpenTabOptions as O, type ResumeTabOptions as R, SessionScopeExceededError as S, type Tab as T, UnsupportedNetworkError as U, type
|
|
395
|
+
export { type AuthorizeSessionOptions as A, type FinalVoucherV2ReservationInput as F, HistoricalV1MigrationRequiredError as H, type LiveSessionDetails as L, type OpenTabOptions as O, type ResumeTabOptions as R, SessionScopeExceededError as S, type Tab as T, UnsupportedNetworkError as U, type VerifyFinalVoucherV2Reservation as V, type FinalVoucherV2ReservationReceipt as a, type VaultAdapter as b, LiveSessionExistsError as c, type TabSignedVoucher as d, type ReserveFinalVoucherV2 as e, type TabCloseResult as f, TabClosedError as g, type TabState as h };
|
package/dist/utils/index.d.cts
CHANGED
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SponsoredAccessSettlementInfo, SponsoredRecommendation } from '@dexterai/x402-ads-types';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Sponsored Access (Ads for Agents) — Client Helpers
|
|
@@ -143,4 +143,4 @@ interface X402Client {
|
|
|
143
143
|
fetch(input: string | URL | Request, init?: RequestInit): Promise<Response>;
|
|
144
144
|
}
|
|
145
145
|
|
|
146
|
-
export { type PaymentReceipt as P, type X402Client as X, getSponsoredAccessInfo as a,
|
|
146
|
+
export { type PaymentReceipt as P, type X402Client as X, getSponsoredAccessInfo as a, getSponsoredRecommendations as b, fireImpressionBeacon as f, getPaymentReceipt as g };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SponsoredAccessSettlementInfo, SponsoredRecommendation } from '@dexterai/x402-ads-types';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Sponsored Access (Ads for Agents) — Client Helpers
|
|
@@ -143,4 +143,4 @@ interface X402Client {
|
|
|
143
143
|
fetch(input: string | URL | Request, init?: RequestInit): Promise<Response>;
|
|
144
144
|
}
|
|
145
145
|
|
|
146
|
-
export { type PaymentReceipt as P, type X402Client as X, getSponsoredAccessInfo as a,
|
|
146
|
+
export { type PaymentReceipt as P, type X402Client as X, getSponsoredAccessInfo as a, getSponsoredRecommendations as b, fireImpressionBeacon as f, getPaymentReceipt as g };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dexterai/x402",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.0-rc.1",
|
|
4
4
|
"description": "Full-stack x402 SDK - add paid API monetization to any endpoint. Express middleware, React hooks, Access Pass, dynamic pricing. Solana, Base, Polygon, Arbitrum, Optimism, Avalanche, World Chain, Monad, Robinhood Chain, SKALE.",
|
|
5
5
|
"author": "Dexter",
|
|
6
6
|
"license": "MIT",
|
|
@@ -74,7 +74,8 @@
|
|
|
74
74
|
"prepublishOnly": "npm run build",
|
|
75
75
|
"release": "npm version patch && npm publish --access public",
|
|
76
76
|
"release:minor": "npm version minor && npm publish --access public",
|
|
77
|
-
"release:major": "npm version major && npm publish --access public"
|
|
77
|
+
"release:major": "npm version major && npm publish --access public",
|
|
78
|
+
"release:next": "npm publish --access public --tag next"
|
|
78
79
|
},
|
|
79
80
|
"dependencies": {
|
|
80
81
|
"@dexterai/x402-ads-types": "^0.2.0",
|
|
@@ -86,15 +87,15 @@
|
|
|
86
87
|
"@x402/core": "2.12.0",
|
|
87
88
|
"@x402/evm": "2.12.0",
|
|
88
89
|
"@x402/extensions": "2.12.0",
|
|
90
|
+
"bs58": "^6.0.0",
|
|
89
91
|
"tweetnacl": "^1.0.3"
|
|
90
92
|
},
|
|
91
93
|
"devDependencies": {
|
|
92
|
-
"@dexterai/vault": "
|
|
94
|
+
"@dexterai/vault": "0.43.2",
|
|
93
95
|
"@types/aws-lambda": "^8.10.161",
|
|
94
96
|
"@types/express": "^5.0.6",
|
|
95
97
|
"@types/node": "^22.10.0",
|
|
96
98
|
"@types/react": "^18.0.0",
|
|
97
|
-
"bs58": "^6.0.0",
|
|
98
99
|
"ethers": "^6.13.0",
|
|
99
100
|
"express": "^5.2.1",
|
|
100
101
|
"react": "^18.0.0",
|
|
@@ -104,7 +105,7 @@
|
|
|
104
105
|
"vitest": "^2.1.8"
|
|
105
106
|
},
|
|
106
107
|
"peerDependencies": {
|
|
107
|
-
"@dexterai/vault": "
|
|
108
|
+
"@dexterai/vault": "0.43.2",
|
|
108
109
|
"@solana/wallet-adapter-base": "^0.9.0",
|
|
109
110
|
"react": "^18.0.0 || ^19.0.0",
|
|
110
111
|
"stripe": "^20.0.0",
|
|
@@ -129,7 +130,7 @@
|
|
|
129
130
|
}
|
|
130
131
|
},
|
|
131
132
|
"engines": {
|
|
132
|
-
"node": ">=
|
|
133
|
+
"node": ">=22"
|
|
133
134
|
},
|
|
134
135
|
"keywords": [
|
|
135
136
|
"x402",
|