@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
package/dist/tab/index.d.cts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { O as OpenTabOptions, T as Tab, R as ResumeTabOptions,
|
|
2
|
-
export { A as AuthorizeSessionOptions, L as LiveSessionDetails,
|
|
3
|
-
import {
|
|
1
|
+
import { O as OpenTabOptions, T as Tab, R as ResumeTabOptions, d as TabSignedVoucher, a as FinalVoucherV2ReservationReceipt, F as FinalVoucherV2ReservationInput, e as ReserveFinalVoucherV2, b as VaultAdapter } from '../types-OHNNM1J2.cjs';
|
|
2
|
+
export { A as AuthorizeSessionOptions, H as HistoricalV1MigrationRequiredError, L as LiveSessionDetails, c as LiveSessionExistsError, S as SessionScopeExceededError, f as TabCloseResult, g as TabClosedError, h as TabState, U as UnsupportedNetworkError, V as VerifyFinalVoucherV2Reservation } from '../types-OHNNM1J2.cjs';
|
|
3
|
+
import { AtomicAmount, HumanAmount, SignedVoucher } from '@dexterai/vault/types';
|
|
4
4
|
export { AtomicAmount, HumanAmount, SessionKey, SessionScope, SignedVoucher, TabNetworkId, VoucherPayload } from '@dexterai/vault/types';
|
|
5
5
|
import { PublicKey, Connection } from '@solana/web3.js';
|
|
6
6
|
import { ApprovedSpendGrantParams } from '@dexterai/vault/grant';
|
|
7
7
|
export { ApprovedSpendGrantParams } from '@dexterai/vault/grant';
|
|
8
|
-
import {
|
|
9
|
-
export { SessionRegisterMessageArgs, SessionRevokeMessageArgs, VoucherPayloadBytes, buildVoucherMessage, sessionRegisterMessage, sessionRevokeMessage, voucherPayloadMessage } from '@dexterai/vault/messages';
|
|
8
|
+
import { b as PayResult } from '../types-DnhCOjDx.cjs';
|
|
9
|
+
export { SessionRegisterMessageArgs, SessionReplaceV1MessageArgs, SessionRevokeMessageArgs, VoucherPayloadBytes, buildVoucherMessage, finalVoucherV2Sequence, sessionRegisterMessage, sessionReplaceV1Message, sessionRevokeMessage, sessionVoucherV2AuthorizationNonce, sessionVoucherV2Nonce, voucherPayloadMessage, voucherV2SequenceOrdinal } from '@dexterai/vault/messages';
|
|
10
10
|
export { BuildRegisterSessionKeyArgs, BuildRevokeSessionKeyArgs, buildRegisterSessionKeyInstruction, buildRevokeSessionKeyInstruction } from '@dexterai/vault/instructions';
|
|
11
11
|
export { buildSecp256r1VerifyInstruction } from '@dexterai/vault/precompile';
|
|
12
12
|
export { DEXTER_VAULT_PROGRAM_ID, INSTRUCTIONS_SYSVAR_ID, SECP256R1_PROGRAM_ID } from '@dexterai/vault/constants';
|
|
13
|
-
export { d as deriveChannelId, g as generateSessionKeypair, m as makeSessionKey, p as parseAtomic,
|
|
14
|
-
import '../types-
|
|
13
|
+
export { S as SignContextBoundFinalVoucherV2Input, a as SignContextBoundFinalVoucherV2Result, d as deriveChannelId, g as generateSessionKeypair, m as makeSessionKey, p as parseAtomic, s as scopeCapAtomic, b as signContextBoundFinalVoucherV2, c as signVoucher } from '../sessions-rPdO1CgK.cjs';
|
|
14
|
+
import '../types-BvQpNtFw.cjs';
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* The `Tab` runtime — the live object returned by `openTab()`.
|
|
@@ -39,24 +39,98 @@ declare function humanToAtomic(human: HumanAmount, decimals?: number): AtomicAmo
|
|
|
39
39
|
declare function atomicToHuman(atomic: AtomicAmount, decimals?: number): HumanAmount;
|
|
40
40
|
/**
|
|
41
41
|
* Serialize a signed voucher to the `X-Tab-Voucher` header value:
|
|
42
|
-
* base64-encoded JSON with hex-encoded byte fields.
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
42
|
+
* base64-encoded JSON with hex-encoded byte fields. V2 additionally carries
|
|
43
|
+
* the complete reservation receipt that was independently verified before the
|
|
44
|
+
* voucher left the buyer. The receipt is an untrusted transaction locator at
|
|
45
|
+
* the seller; it never replaces the seller's own finalized chain proof.
|
|
46
|
+
*
|
|
47
|
+
* This is THE wire encoding the seller middleware and the facilitator's
|
|
48
|
+
* `/tab/settle` endpoint both parse — `stream()` uses it, and `payAndFetch`
|
|
49
|
+
* uses it to pay a `tab`-scheme accepts entry directly.
|
|
46
50
|
*/
|
|
47
|
-
declare function voucherToHeader(signed: SignedVoucher): string;
|
|
51
|
+
declare function voucherToHeader(signed: SignedVoucher | TabSignedVoucher, reservationReceipt?: FinalVoucherV2ReservationReceipt): string;
|
|
48
52
|
/**
|
|
49
53
|
* Arm drain-protection for a freshly-registered tab via the facilitator's
|
|
50
54
|
* /tab/open. THROWS if protection cannot be confirmed — a tab that is not
|
|
51
55
|
* drain-protected must never be returned to the caller.
|
|
52
56
|
*/
|
|
53
|
-
|
|
57
|
+
/**
|
|
58
|
+
* @deprecated V6 has no buyer-side V1 arming route. This retained symbol is a
|
|
59
|
+
* deterministic migration fence for callers compiled against the old helper;
|
|
60
|
+
* it performs no fetch, signing, or chain action.
|
|
61
|
+
*/
|
|
62
|
+
declare function armTabOpen(_facilitatorUrl: string, _buyerSwigAddress: string, _maxAmountAtomic: bigint, _network: string, _counterparty: string): Promise<{
|
|
54
63
|
armed: true;
|
|
55
64
|
signature: string;
|
|
56
65
|
}>;
|
|
57
66
|
declare function openTab(options: OpenTabOptions): Promise<Tab>;
|
|
58
67
|
declare function resumeTab(_options: ResumeTabOptions): Promise<Tab>;
|
|
59
68
|
|
|
69
|
+
/** Canonical network carried by the managed native-Tab transaction record. */
|
|
70
|
+
declare const FINAL_VOUCHER_V2_SOLANA_MAINNET_CAIP2 = "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp";
|
|
71
|
+
/** Domain for the authority-signed transaction binding. Changing any bound
|
|
72
|
+
* field requires a new domain/version rather than silently changing bytes. */
|
|
73
|
+
declare const FINAL_VOUCHER_V2_RESERVATION_BINDING_DOMAIN = "dexter-native-tab-v2-reservation/v1";
|
|
74
|
+
/** UTF-8 prefix stored by the SPL Memo instruction. */
|
|
75
|
+
declare const FINAL_VOUCHER_V2_RESERVATION_MEMO_PREFIX = "dexter-native-tab-v2-reservation/v1:";
|
|
76
|
+
/** Shared economic identity committed by the authority-signed Memo. This is
|
|
77
|
+
* intentionally independent of provider lifecycle IDs and SDK retry keys so
|
|
78
|
+
* the SDK and facilitator can derive identical bytes from their common facts. */
|
|
79
|
+
interface FinalVoucherV2ReservationBindingIdentity {
|
|
80
|
+
network: string;
|
|
81
|
+
programId: string;
|
|
82
|
+
buyerSwigAddress: string;
|
|
83
|
+
vaultPda: string;
|
|
84
|
+
sessionPda: string;
|
|
85
|
+
seller: string;
|
|
86
|
+
channelId: string;
|
|
87
|
+
sessionNonce: number;
|
|
88
|
+
reservationAmountAtomic: string;
|
|
89
|
+
previousCumulativeAtomic: string;
|
|
90
|
+
voucherDigest: string;
|
|
91
|
+
cumulativeAmountAtomic: string;
|
|
92
|
+
sequenceNumber: number;
|
|
93
|
+
}
|
|
94
|
+
/** Normalize the SDK's historical Solana alias to the CAIP-2 value persisted
|
|
95
|
+
* by the managed facilitator. No other alias is accepted by this contract. */
|
|
96
|
+
declare function canonicalFinalVoucherV2ReservationNetwork(network: string): string;
|
|
97
|
+
/**
|
|
98
|
+
* Byte-for-byte mirror of the facilitator's voucher identity digest. It binds
|
|
99
|
+
* the complete signed voucher, not merely its amount or local counter.
|
|
100
|
+
*/
|
|
101
|
+
declare function finalVoucherV2Digest(voucher: SignedVoucher): string;
|
|
102
|
+
declare function finalVoucherV2ReservationIdentity(voucher: SignedVoucher): {
|
|
103
|
+
voucherDigest: string;
|
|
104
|
+
idempotencyKey: string;
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* Low-level cross-system digest over the shared reservation identity. This
|
|
108
|
+
* helper exists so transaction builders and verifiers can lock byte-for-byte
|
|
109
|
+
* parity without manufacturing a SignedVoucher for an already-derived digest.
|
|
110
|
+
*/
|
|
111
|
+
declare function finalVoucherV2ReservationBindingDigestFromIdentity(identity: FinalVoucherV2ReservationBindingIdentity): string;
|
|
112
|
+
/**
|
|
113
|
+
* Digest that must be carried by the same Dexter-authority-signed Solana
|
|
114
|
+
* transaction as the exact `settle_voucher(increment=true)` reservation.
|
|
115
|
+
*
|
|
116
|
+
* The Vault instruction binds the on-chain amount and account identities. This
|
|
117
|
+
* separate domain binds that economic effect to the complete FINAL voucher and
|
|
118
|
+
* shared economic identity. Provider lifecycle, receipt, and retry identifiers
|
|
119
|
+
* are deliberately excluded. The digest is computed locally from the voucher
|
|
120
|
+
* bytes; a provider-supplied `voucherDigest` is never trusted as the source of
|
|
121
|
+
* this transaction binding.
|
|
122
|
+
*/
|
|
123
|
+
declare function finalVoucherV2ReservationBindingDigest(input: FinalVoucherV2ReservationInput): string;
|
|
124
|
+
/** Exact UTF-8 SPL Memo payload required in the reservation transaction. */
|
|
125
|
+
declare function finalVoucherV2ReservationMemo(input: FinalVoucherV2ReservationInput): string;
|
|
126
|
+
/**
|
|
127
|
+
* Validate the provider's immutable voucher-bound receipt before asking the
|
|
128
|
+
* chain adapter to prove the post-state independently. A receipt is evidence
|
|
129
|
+
* of the provider's durable lifecycle record; it is not a substitute for the
|
|
130
|
+
* adapter's chain read.
|
|
131
|
+
*/
|
|
132
|
+
declare function assertFinalVoucherV2ReservationReceipt(input: FinalVoucherV2ReservationInput, receipt: FinalVoucherV2ReservationReceipt): void;
|
|
133
|
+
|
|
60
134
|
/**
|
|
61
135
|
* tabFromGrant — open a buyer-side Tab from a GRANTED session key.
|
|
62
136
|
*
|
|
@@ -81,8 +155,11 @@ declare function resumeTab(_options: ResumeTabOptions): Promise<Tab>;
|
|
|
81
155
|
* odometer starts there so the first voucher strictly exceeds everything
|
|
82
156
|
* the chain has already terminally counted. The chain is the durable
|
|
83
157
|
* counter; there is no local state store to lose.
|
|
84
|
-
* -
|
|
85
|
-
*
|
|
158
|
+
* - a context-bound V2 reservation fence before every newly issued FINAL
|
|
159
|
+
* voucher. Historical low-bit V1 grants are rejected before I/O: the v6
|
|
160
|
+
* facilitator has no compatible buyer-side V1 arming/recovery endpoint.
|
|
161
|
+
* Seller-side V1 verification remains available for obligations that were
|
|
162
|
+
* already issued under the deployment that originally opened them.
|
|
86
163
|
*
|
|
87
164
|
* CUSTODY NOTE — why this constructor may hold a session secret when
|
|
88
165
|
* `resumeTab` refuses to: the passkey path's "session keys are memory-only"
|
|
@@ -154,20 +231,31 @@ interface TabFromGrantOptions {
|
|
|
154
231
|
*/
|
|
155
232
|
sellerUrl?: string;
|
|
156
233
|
/**
|
|
157
|
-
* The buyer's Swig STATE address (`vault.swig_address`)
|
|
158
|
-
*
|
|
159
|
-
* one extra RPC read, never a guess.
|
|
234
|
+
* The buyer's Swig STATE address (`vault.swig_address`) bound into the exact
|
|
235
|
+
* V2 reservation request and receipt. When omitted it is read from the
|
|
236
|
+
* on-chain vault account — one extra RPC read, never a guess.
|
|
160
237
|
*/
|
|
161
238
|
swigAddress?: string;
|
|
162
239
|
/** Facilitator base URL. Default: DEFAULT_FACILITATOR_URL (https://x402.dexter.cash). */
|
|
163
240
|
facilitatorUrl?: string;
|
|
164
241
|
/** Vault program id override (test/devnet). Default: DEXTER_VAULT_PROGRAM_ID. */
|
|
165
242
|
programId?: PublicKey;
|
|
243
|
+
/**
|
|
244
|
+
* Required for every context-bound V2 grant. Called with the exact FINAL
|
|
245
|
+
* voucher before it can be returned to merchant-facing code. The
|
|
246
|
+
* implementation must durably persist and establish that voucher's exact
|
|
247
|
+
* on-chain reservation, be idempotent for identical bytes, and resolve only
|
|
248
|
+
* after authoritative finalization. Low-bit V1 grants are rejected before
|
|
249
|
+
* this seam or any external I/O because v6 cannot reconstruct their arming
|
|
250
|
+
* identity safely.
|
|
251
|
+
*/
|
|
252
|
+
reserveFinalVoucherV2?: ReserveFinalVoucherV2;
|
|
166
253
|
}
|
|
167
254
|
/**
|
|
168
255
|
* Construct a live `Tab` from a granted session key. Fail-loud at every step:
|
|
169
|
-
* key/params mismatch, dead or drifted on-chain session, exhausted cap, and
|
|
170
|
-
*
|
|
256
|
+
* key/params mismatch, dead or drifted on-chain session, exhausted cap, and a
|
|
257
|
+
* missing exact V2 reservation fence all THROW — an invalid tab is never
|
|
258
|
+
* returned.
|
|
171
259
|
*/
|
|
172
260
|
declare function tabFromGrant(options: TabFromGrantOptions): Promise<Tab>;
|
|
173
261
|
|
|
@@ -179,6 +267,11 @@ interface TabOffer {
|
|
|
179
267
|
asset: string;
|
|
180
268
|
/** CAIP-2 network from the challenge (x402 v2 form). */
|
|
181
269
|
networkCaip2: string;
|
|
270
|
+
/** Preserved verbatim from accepts[].extra for policy-aware callers. */
|
|
271
|
+
voucherHeader?: string;
|
|
272
|
+
registrationEncoding?: string;
|
|
273
|
+
termsVersion?: string;
|
|
274
|
+
acceptanceRule?: string;
|
|
182
275
|
resourceUrl?: string;
|
|
183
276
|
}
|
|
184
277
|
type TabOfferResult = {
|
|
@@ -206,6 +299,16 @@ type TabOfferResult = {
|
|
|
206
299
|
*/
|
|
207
300
|
declare function resolveTabOffer(url: string, init?: RequestInit, fetchImpl?: typeof fetch): Promise<TabOfferResult>;
|
|
208
301
|
|
|
302
|
+
/**
|
|
303
|
+
* Hosted-v1 commercial semantics advertised by the default Tab scheme.
|
|
304
|
+
* A different refund/dispute or delivery rule requires a new terms version;
|
|
305
|
+
* callers must never reinterpret these strings in place.
|
|
306
|
+
*/
|
|
307
|
+
declare const HOSTED_TAB_TERMS_VERSION: "dexter-tab-hosted-pay-before-delivery/v1";
|
|
308
|
+
declare const HOSTED_TAB_ACCEPTANCE_RULE: "pay_before_delivery_seller_2xx";
|
|
309
|
+
declare const HOSTED_TAB_VOUCHER_HEADER: "x-tab-voucher";
|
|
310
|
+
declare const HOSTED_TAB_REGISTRATION_ENCODING: "base64(188-byte sessionRegisterMessage)";
|
|
311
|
+
|
|
209
312
|
/**
|
|
210
313
|
* Step-3a buyer orchestration: pay a URL through a tab with ZERO seller
|
|
211
314
|
* knowledge. Resolution + lifecycle only — composes resolveTabOffer,
|
|
@@ -238,6 +341,8 @@ interface PayUrlWithTabOptions {
|
|
|
238
341
|
* `OpenTabOptions.onLiveSession` (K-T4e).
|
|
239
342
|
*/
|
|
240
343
|
onLiveSession?: 'error' | 'replace';
|
|
344
|
+
/** Exact V2 reservation fence forwarded to openTab. */
|
|
345
|
+
reserveFinalVoucherV2?: ReserveFinalVoucherV2;
|
|
241
346
|
/**
|
|
242
347
|
* Open-tab registry keyed by counterparty base58. Pass the SAME Map across
|
|
243
348
|
* calls to reuse one open tab per seller instead of re-registering
|
|
@@ -313,4 +418,4 @@ interface ResolveTabTermsOptions {
|
|
|
313
418
|
*/
|
|
314
419
|
declare function resolveTabTerms(url: string, init?: RequestInit, opts?: ResolveTabTermsOptions): Promise<TabTermsResult>;
|
|
315
420
|
|
|
316
|
-
export { DEFAULT_FACILITATOR_URL, OpenTabOptions, type PayUrlWithTabOptions, type PayUrlWithTabResult, type ResolveTabTermsOptions, ResumeTabOptions, Tab, type TabFromGrantOptions, type TabOffer, type TabOfferResult, type TabTerms, type TabTermsResult, VaultAdapter, armTabOpen, atomicToHuman, humanToAtomic, openTab, payUrlWithTab, resolveTabOffer, resolveTabTerms, resumeTab, tabFromGrant, voucherToHeader };
|
|
421
|
+
export { DEFAULT_FACILITATOR_URL, FINAL_VOUCHER_V2_RESERVATION_BINDING_DOMAIN, FINAL_VOUCHER_V2_RESERVATION_MEMO_PREFIX, FINAL_VOUCHER_V2_SOLANA_MAINNET_CAIP2, type FinalVoucherV2ReservationBindingIdentity, FinalVoucherV2ReservationInput, FinalVoucherV2ReservationReceipt, HOSTED_TAB_ACCEPTANCE_RULE, HOSTED_TAB_REGISTRATION_ENCODING, HOSTED_TAB_TERMS_VERSION, HOSTED_TAB_VOUCHER_HEADER, OpenTabOptions, type PayUrlWithTabOptions, type PayUrlWithTabResult, ReserveFinalVoucherV2, type ResolveTabTermsOptions, ResumeTabOptions, Tab, type TabFromGrantOptions, type TabOffer, type TabOfferResult, TabSignedVoucher, type TabTerms, type TabTermsResult, VaultAdapter, armTabOpen, assertFinalVoucherV2ReservationReceipt, atomicToHuman, canonicalFinalVoucherV2ReservationNetwork, finalVoucherV2Digest, finalVoucherV2ReservationBindingDigest, finalVoucherV2ReservationBindingDigestFromIdentity, finalVoucherV2ReservationIdentity, finalVoucherV2ReservationMemo, humanToAtomic, openTab, payUrlWithTab, resolveTabOffer, resolveTabTerms, resumeTab, tabFromGrant, voucherToHeader };
|
package/dist/tab/index.d.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { O as OpenTabOptions, T as Tab, R as ResumeTabOptions,
|
|
2
|
-
export { A as AuthorizeSessionOptions, L as LiveSessionDetails,
|
|
3
|
-
import {
|
|
1
|
+
import { O as OpenTabOptions, T as Tab, R as ResumeTabOptions, d as TabSignedVoucher, a as FinalVoucherV2ReservationReceipt, F as FinalVoucherV2ReservationInput, e as ReserveFinalVoucherV2, b as VaultAdapter } from '../types-OHNNM1J2.js';
|
|
2
|
+
export { A as AuthorizeSessionOptions, H as HistoricalV1MigrationRequiredError, L as LiveSessionDetails, c as LiveSessionExistsError, S as SessionScopeExceededError, f as TabCloseResult, g as TabClosedError, h as TabState, U as UnsupportedNetworkError, V as VerifyFinalVoucherV2Reservation } from '../types-OHNNM1J2.js';
|
|
3
|
+
import { AtomicAmount, HumanAmount, SignedVoucher } from '@dexterai/vault/types';
|
|
4
4
|
export { AtomicAmount, HumanAmount, SessionKey, SessionScope, SignedVoucher, TabNetworkId, VoucherPayload } from '@dexterai/vault/types';
|
|
5
5
|
import { PublicKey, Connection } from '@solana/web3.js';
|
|
6
6
|
import { ApprovedSpendGrantParams } from '@dexterai/vault/grant';
|
|
7
7
|
export { ApprovedSpendGrantParams } from '@dexterai/vault/grant';
|
|
8
|
-
import {
|
|
9
|
-
export { SessionRegisterMessageArgs, SessionRevokeMessageArgs, VoucherPayloadBytes, buildVoucherMessage, sessionRegisterMessage, sessionRevokeMessage, voucherPayloadMessage } from '@dexterai/vault/messages';
|
|
8
|
+
import { b as PayResult } from '../types-CwLPKV8T.js';
|
|
9
|
+
export { SessionRegisterMessageArgs, SessionReplaceV1MessageArgs, SessionRevokeMessageArgs, VoucherPayloadBytes, buildVoucherMessage, finalVoucherV2Sequence, sessionRegisterMessage, sessionReplaceV1Message, sessionRevokeMessage, sessionVoucherV2AuthorizationNonce, sessionVoucherV2Nonce, voucherPayloadMessage, voucherV2SequenceOrdinal } from '@dexterai/vault/messages';
|
|
10
10
|
export { BuildRegisterSessionKeyArgs, BuildRevokeSessionKeyArgs, buildRegisterSessionKeyInstruction, buildRevokeSessionKeyInstruction } from '@dexterai/vault/instructions';
|
|
11
11
|
export { buildSecp256r1VerifyInstruction } from '@dexterai/vault/precompile';
|
|
12
12
|
export { DEXTER_VAULT_PROGRAM_ID, INSTRUCTIONS_SYSVAR_ID, SECP256R1_PROGRAM_ID } from '@dexterai/vault/constants';
|
|
13
|
-
export { d as deriveChannelId, g as generateSessionKeypair, m as makeSessionKey, p as parseAtomic,
|
|
14
|
-
import '../types-
|
|
13
|
+
export { S as SignContextBoundFinalVoucherV2Input, a as SignContextBoundFinalVoucherV2Result, d as deriveChannelId, g as generateSessionKeypair, m as makeSessionKey, p as parseAtomic, s as scopeCapAtomic, b as signContextBoundFinalVoucherV2, c as signVoucher } from '../sessions-rPdO1CgK.js';
|
|
14
|
+
import '../types-BvQpNtFw.js';
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* The `Tab` runtime — the live object returned by `openTab()`.
|
|
@@ -39,24 +39,98 @@ declare function humanToAtomic(human: HumanAmount, decimals?: number): AtomicAmo
|
|
|
39
39
|
declare function atomicToHuman(atomic: AtomicAmount, decimals?: number): HumanAmount;
|
|
40
40
|
/**
|
|
41
41
|
* Serialize a signed voucher to the `X-Tab-Voucher` header value:
|
|
42
|
-
* base64-encoded JSON with hex-encoded byte fields.
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
42
|
+
* base64-encoded JSON with hex-encoded byte fields. V2 additionally carries
|
|
43
|
+
* the complete reservation receipt that was independently verified before the
|
|
44
|
+
* voucher left the buyer. The receipt is an untrusted transaction locator at
|
|
45
|
+
* the seller; it never replaces the seller's own finalized chain proof.
|
|
46
|
+
*
|
|
47
|
+
* This is THE wire encoding the seller middleware and the facilitator's
|
|
48
|
+
* `/tab/settle` endpoint both parse — `stream()` uses it, and `payAndFetch`
|
|
49
|
+
* uses it to pay a `tab`-scheme accepts entry directly.
|
|
46
50
|
*/
|
|
47
|
-
declare function voucherToHeader(signed: SignedVoucher): string;
|
|
51
|
+
declare function voucherToHeader(signed: SignedVoucher | TabSignedVoucher, reservationReceipt?: FinalVoucherV2ReservationReceipt): string;
|
|
48
52
|
/**
|
|
49
53
|
* Arm drain-protection for a freshly-registered tab via the facilitator's
|
|
50
54
|
* /tab/open. THROWS if protection cannot be confirmed — a tab that is not
|
|
51
55
|
* drain-protected must never be returned to the caller.
|
|
52
56
|
*/
|
|
53
|
-
|
|
57
|
+
/**
|
|
58
|
+
* @deprecated V6 has no buyer-side V1 arming route. This retained symbol is a
|
|
59
|
+
* deterministic migration fence for callers compiled against the old helper;
|
|
60
|
+
* it performs no fetch, signing, or chain action.
|
|
61
|
+
*/
|
|
62
|
+
declare function armTabOpen(_facilitatorUrl: string, _buyerSwigAddress: string, _maxAmountAtomic: bigint, _network: string, _counterparty: string): Promise<{
|
|
54
63
|
armed: true;
|
|
55
64
|
signature: string;
|
|
56
65
|
}>;
|
|
57
66
|
declare function openTab(options: OpenTabOptions): Promise<Tab>;
|
|
58
67
|
declare function resumeTab(_options: ResumeTabOptions): Promise<Tab>;
|
|
59
68
|
|
|
69
|
+
/** Canonical network carried by the managed native-Tab transaction record. */
|
|
70
|
+
declare const FINAL_VOUCHER_V2_SOLANA_MAINNET_CAIP2 = "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp";
|
|
71
|
+
/** Domain for the authority-signed transaction binding. Changing any bound
|
|
72
|
+
* field requires a new domain/version rather than silently changing bytes. */
|
|
73
|
+
declare const FINAL_VOUCHER_V2_RESERVATION_BINDING_DOMAIN = "dexter-native-tab-v2-reservation/v1";
|
|
74
|
+
/** UTF-8 prefix stored by the SPL Memo instruction. */
|
|
75
|
+
declare const FINAL_VOUCHER_V2_RESERVATION_MEMO_PREFIX = "dexter-native-tab-v2-reservation/v1:";
|
|
76
|
+
/** Shared economic identity committed by the authority-signed Memo. This is
|
|
77
|
+
* intentionally independent of provider lifecycle IDs and SDK retry keys so
|
|
78
|
+
* the SDK and facilitator can derive identical bytes from their common facts. */
|
|
79
|
+
interface FinalVoucherV2ReservationBindingIdentity {
|
|
80
|
+
network: string;
|
|
81
|
+
programId: string;
|
|
82
|
+
buyerSwigAddress: string;
|
|
83
|
+
vaultPda: string;
|
|
84
|
+
sessionPda: string;
|
|
85
|
+
seller: string;
|
|
86
|
+
channelId: string;
|
|
87
|
+
sessionNonce: number;
|
|
88
|
+
reservationAmountAtomic: string;
|
|
89
|
+
previousCumulativeAtomic: string;
|
|
90
|
+
voucherDigest: string;
|
|
91
|
+
cumulativeAmountAtomic: string;
|
|
92
|
+
sequenceNumber: number;
|
|
93
|
+
}
|
|
94
|
+
/** Normalize the SDK's historical Solana alias to the CAIP-2 value persisted
|
|
95
|
+
* by the managed facilitator. No other alias is accepted by this contract. */
|
|
96
|
+
declare function canonicalFinalVoucherV2ReservationNetwork(network: string): string;
|
|
97
|
+
/**
|
|
98
|
+
* Byte-for-byte mirror of the facilitator's voucher identity digest. It binds
|
|
99
|
+
* the complete signed voucher, not merely its amount or local counter.
|
|
100
|
+
*/
|
|
101
|
+
declare function finalVoucherV2Digest(voucher: SignedVoucher): string;
|
|
102
|
+
declare function finalVoucherV2ReservationIdentity(voucher: SignedVoucher): {
|
|
103
|
+
voucherDigest: string;
|
|
104
|
+
idempotencyKey: string;
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* Low-level cross-system digest over the shared reservation identity. This
|
|
108
|
+
* helper exists so transaction builders and verifiers can lock byte-for-byte
|
|
109
|
+
* parity without manufacturing a SignedVoucher for an already-derived digest.
|
|
110
|
+
*/
|
|
111
|
+
declare function finalVoucherV2ReservationBindingDigestFromIdentity(identity: FinalVoucherV2ReservationBindingIdentity): string;
|
|
112
|
+
/**
|
|
113
|
+
* Digest that must be carried by the same Dexter-authority-signed Solana
|
|
114
|
+
* transaction as the exact `settle_voucher(increment=true)` reservation.
|
|
115
|
+
*
|
|
116
|
+
* The Vault instruction binds the on-chain amount and account identities. This
|
|
117
|
+
* separate domain binds that economic effect to the complete FINAL voucher and
|
|
118
|
+
* shared economic identity. Provider lifecycle, receipt, and retry identifiers
|
|
119
|
+
* are deliberately excluded. The digest is computed locally from the voucher
|
|
120
|
+
* bytes; a provider-supplied `voucherDigest` is never trusted as the source of
|
|
121
|
+
* this transaction binding.
|
|
122
|
+
*/
|
|
123
|
+
declare function finalVoucherV2ReservationBindingDigest(input: FinalVoucherV2ReservationInput): string;
|
|
124
|
+
/** Exact UTF-8 SPL Memo payload required in the reservation transaction. */
|
|
125
|
+
declare function finalVoucherV2ReservationMemo(input: FinalVoucherV2ReservationInput): string;
|
|
126
|
+
/**
|
|
127
|
+
* Validate the provider's immutable voucher-bound receipt before asking the
|
|
128
|
+
* chain adapter to prove the post-state independently. A receipt is evidence
|
|
129
|
+
* of the provider's durable lifecycle record; it is not a substitute for the
|
|
130
|
+
* adapter's chain read.
|
|
131
|
+
*/
|
|
132
|
+
declare function assertFinalVoucherV2ReservationReceipt(input: FinalVoucherV2ReservationInput, receipt: FinalVoucherV2ReservationReceipt): void;
|
|
133
|
+
|
|
60
134
|
/**
|
|
61
135
|
* tabFromGrant — open a buyer-side Tab from a GRANTED session key.
|
|
62
136
|
*
|
|
@@ -81,8 +155,11 @@ declare function resumeTab(_options: ResumeTabOptions): Promise<Tab>;
|
|
|
81
155
|
* odometer starts there so the first voucher strictly exceeds everything
|
|
82
156
|
* the chain has already terminally counted. The chain is the durable
|
|
83
157
|
* counter; there is no local state store to lose.
|
|
84
|
-
* -
|
|
85
|
-
*
|
|
158
|
+
* - a context-bound V2 reservation fence before every newly issued FINAL
|
|
159
|
+
* voucher. Historical low-bit V1 grants are rejected before I/O: the v6
|
|
160
|
+
* facilitator has no compatible buyer-side V1 arming/recovery endpoint.
|
|
161
|
+
* Seller-side V1 verification remains available for obligations that were
|
|
162
|
+
* already issued under the deployment that originally opened them.
|
|
86
163
|
*
|
|
87
164
|
* CUSTODY NOTE — why this constructor may hold a session secret when
|
|
88
165
|
* `resumeTab` refuses to: the passkey path's "session keys are memory-only"
|
|
@@ -154,20 +231,31 @@ interface TabFromGrantOptions {
|
|
|
154
231
|
*/
|
|
155
232
|
sellerUrl?: string;
|
|
156
233
|
/**
|
|
157
|
-
* The buyer's Swig STATE address (`vault.swig_address`)
|
|
158
|
-
*
|
|
159
|
-
* one extra RPC read, never a guess.
|
|
234
|
+
* The buyer's Swig STATE address (`vault.swig_address`) bound into the exact
|
|
235
|
+
* V2 reservation request and receipt. When omitted it is read from the
|
|
236
|
+
* on-chain vault account — one extra RPC read, never a guess.
|
|
160
237
|
*/
|
|
161
238
|
swigAddress?: string;
|
|
162
239
|
/** Facilitator base URL. Default: DEFAULT_FACILITATOR_URL (https://x402.dexter.cash). */
|
|
163
240
|
facilitatorUrl?: string;
|
|
164
241
|
/** Vault program id override (test/devnet). Default: DEXTER_VAULT_PROGRAM_ID. */
|
|
165
242
|
programId?: PublicKey;
|
|
243
|
+
/**
|
|
244
|
+
* Required for every context-bound V2 grant. Called with the exact FINAL
|
|
245
|
+
* voucher before it can be returned to merchant-facing code. The
|
|
246
|
+
* implementation must durably persist and establish that voucher's exact
|
|
247
|
+
* on-chain reservation, be idempotent for identical bytes, and resolve only
|
|
248
|
+
* after authoritative finalization. Low-bit V1 grants are rejected before
|
|
249
|
+
* this seam or any external I/O because v6 cannot reconstruct their arming
|
|
250
|
+
* identity safely.
|
|
251
|
+
*/
|
|
252
|
+
reserveFinalVoucherV2?: ReserveFinalVoucherV2;
|
|
166
253
|
}
|
|
167
254
|
/**
|
|
168
255
|
* Construct a live `Tab` from a granted session key. Fail-loud at every step:
|
|
169
|
-
* key/params mismatch, dead or drifted on-chain session, exhausted cap, and
|
|
170
|
-
*
|
|
256
|
+
* key/params mismatch, dead or drifted on-chain session, exhausted cap, and a
|
|
257
|
+
* missing exact V2 reservation fence all THROW — an invalid tab is never
|
|
258
|
+
* returned.
|
|
171
259
|
*/
|
|
172
260
|
declare function tabFromGrant(options: TabFromGrantOptions): Promise<Tab>;
|
|
173
261
|
|
|
@@ -179,6 +267,11 @@ interface TabOffer {
|
|
|
179
267
|
asset: string;
|
|
180
268
|
/** CAIP-2 network from the challenge (x402 v2 form). */
|
|
181
269
|
networkCaip2: string;
|
|
270
|
+
/** Preserved verbatim from accepts[].extra for policy-aware callers. */
|
|
271
|
+
voucherHeader?: string;
|
|
272
|
+
registrationEncoding?: string;
|
|
273
|
+
termsVersion?: string;
|
|
274
|
+
acceptanceRule?: string;
|
|
182
275
|
resourceUrl?: string;
|
|
183
276
|
}
|
|
184
277
|
type TabOfferResult = {
|
|
@@ -206,6 +299,16 @@ type TabOfferResult = {
|
|
|
206
299
|
*/
|
|
207
300
|
declare function resolveTabOffer(url: string, init?: RequestInit, fetchImpl?: typeof fetch): Promise<TabOfferResult>;
|
|
208
301
|
|
|
302
|
+
/**
|
|
303
|
+
* Hosted-v1 commercial semantics advertised by the default Tab scheme.
|
|
304
|
+
* A different refund/dispute or delivery rule requires a new terms version;
|
|
305
|
+
* callers must never reinterpret these strings in place.
|
|
306
|
+
*/
|
|
307
|
+
declare const HOSTED_TAB_TERMS_VERSION: "dexter-tab-hosted-pay-before-delivery/v1";
|
|
308
|
+
declare const HOSTED_TAB_ACCEPTANCE_RULE: "pay_before_delivery_seller_2xx";
|
|
309
|
+
declare const HOSTED_TAB_VOUCHER_HEADER: "x-tab-voucher";
|
|
310
|
+
declare const HOSTED_TAB_REGISTRATION_ENCODING: "base64(188-byte sessionRegisterMessage)";
|
|
311
|
+
|
|
209
312
|
/**
|
|
210
313
|
* Step-3a buyer orchestration: pay a URL through a tab with ZERO seller
|
|
211
314
|
* knowledge. Resolution + lifecycle only — composes resolveTabOffer,
|
|
@@ -238,6 +341,8 @@ interface PayUrlWithTabOptions {
|
|
|
238
341
|
* `OpenTabOptions.onLiveSession` (K-T4e).
|
|
239
342
|
*/
|
|
240
343
|
onLiveSession?: 'error' | 'replace';
|
|
344
|
+
/** Exact V2 reservation fence forwarded to openTab. */
|
|
345
|
+
reserveFinalVoucherV2?: ReserveFinalVoucherV2;
|
|
241
346
|
/**
|
|
242
347
|
* Open-tab registry keyed by counterparty base58. Pass the SAME Map across
|
|
243
348
|
* calls to reuse one open tab per seller instead of re-registering
|
|
@@ -313,4 +418,4 @@ interface ResolveTabTermsOptions {
|
|
|
313
418
|
*/
|
|
314
419
|
declare function resolveTabTerms(url: string, init?: RequestInit, opts?: ResolveTabTermsOptions): Promise<TabTermsResult>;
|
|
315
420
|
|
|
316
|
-
export { DEFAULT_FACILITATOR_URL, OpenTabOptions, type PayUrlWithTabOptions, type PayUrlWithTabResult, type ResolveTabTermsOptions, ResumeTabOptions, Tab, type TabFromGrantOptions, type TabOffer, type TabOfferResult, type TabTerms, type TabTermsResult, VaultAdapter, armTabOpen, atomicToHuman, humanToAtomic, openTab, payUrlWithTab, resolveTabOffer, resolveTabTerms, resumeTab, tabFromGrant, voucherToHeader };
|
|
421
|
+
export { DEFAULT_FACILITATOR_URL, FINAL_VOUCHER_V2_RESERVATION_BINDING_DOMAIN, FINAL_VOUCHER_V2_RESERVATION_MEMO_PREFIX, FINAL_VOUCHER_V2_SOLANA_MAINNET_CAIP2, type FinalVoucherV2ReservationBindingIdentity, FinalVoucherV2ReservationInput, FinalVoucherV2ReservationReceipt, HOSTED_TAB_ACCEPTANCE_RULE, HOSTED_TAB_REGISTRATION_ENCODING, HOSTED_TAB_TERMS_VERSION, HOSTED_TAB_VOUCHER_HEADER, OpenTabOptions, type PayUrlWithTabOptions, type PayUrlWithTabResult, ReserveFinalVoucherV2, type ResolveTabTermsOptions, ResumeTabOptions, Tab, type TabFromGrantOptions, type TabOffer, type TabOfferResult, TabSignedVoucher, type TabTerms, type TabTermsResult, VaultAdapter, armTabOpen, assertFinalVoucherV2ReservationReceipt, atomicToHuman, canonicalFinalVoucherV2ReservationNetwork, finalVoucherV2Digest, finalVoucherV2ReservationBindingDigest, finalVoucherV2ReservationBindingDigestFromIdentity, finalVoucherV2ReservationIdentity, finalVoucherV2ReservationMemo, humanToAtomic, openTab, payUrlWithTab, resolveTabOffer, resolveTabTerms, resumeTab, tabFromGrant, voucherToHeader };
|