@dexterai/x402 6.0.0 → 6.0.2

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.
Files changed (46) hide show
  1. package/CHANGELOG.md +36 -10
  2. package/dist/adapters/index.cjs +1 -1
  3. package/dist/adapters/index.d.cts +3 -3
  4. package/dist/adapters/index.d.ts +3 -3
  5. package/dist/adapters/index.js +1 -1
  6. package/dist/batch-settlement/index.d.cts +4 -4
  7. package/dist/batch-settlement/index.d.ts +4 -4
  8. package/dist/batch-settlement/seller/index.d.cts +5 -5
  9. package/dist/batch-settlement/seller/index.d.ts +5 -5
  10. package/dist/client/index.cjs +1 -1
  11. package/dist/client/index.d.cts +7 -6
  12. package/dist/client/index.d.ts +7 -6
  13. package/dist/client/index.js +1 -1
  14. package/dist/mcp/index.cjs +1 -1
  15. package/dist/mcp/index.d.cts +1 -1
  16. package/dist/mcp/index.d.ts +1 -1
  17. package/dist/mcp/index.js +1 -1
  18. package/dist/react/index.cjs +1 -1
  19. package/dist/react/index.d.cts +4 -4
  20. package/dist/react/index.d.ts +4 -4
  21. package/dist/react/index.js +1 -1
  22. package/dist/server/index.cjs +1 -1
  23. package/dist/server/index.d.cts +5 -5
  24. package/dist/server/index.d.ts +5 -5
  25. package/dist/server/index.js +1 -1
  26. package/dist/sponsored-access-ByM3apeR.d.cts +69 -0
  27. package/dist/sponsored-access-ByM3apeR.d.ts +69 -0
  28. package/dist/tab/index.cjs +4 -4
  29. package/dist/tab/index.d.cts +4 -3
  30. package/dist/tab/index.d.ts +4 -3
  31. package/dist/tab/index.js +5 -5
  32. package/dist/{types-DolSK-3d.d.cts → types-8Q38sHOi.d.cts} +1 -1
  33. package/dist/{types-DolSK-3d.d.ts → types-8Q38sHOi.d.ts} +1 -1
  34. package/dist/{types-CRs5sEcb.d.cts → types-B4JCwkHH.d.cts} +1 -1
  35. package/dist/{types-DGVtb7cl.d.cts → types-BOEYu6ya.d.cts} +1 -1
  36. package/dist/{types-C6IbRTpi.d.ts → types-BdUPQzXu.d.ts} +1 -1
  37. package/dist/{types-RauRuMb7.d.cts → types-CTYEYNZO.d.cts} +1 -1
  38. package/dist/{types-DjDjuUc6.d.ts → types-DhCxPFgg.d.ts} +1 -1
  39. package/dist/{types-C08JT9MG.d.ts → types-Ds9IUnXG.d.ts} +1 -1
  40. package/dist/{types-Cyyl3Cw_.d.cts → types-G6MIMJjK.d.cts} +19 -5
  41. package/dist/{types-BvK5UjA9.d.ts → types-zImyINj3.d.ts} +19 -5
  42. package/dist/x402-client-Cil4Tmqy.d.cts +93 -0
  43. package/dist/x402-client-Cil4Tmqy.d.ts +93 -0
  44. package/package.json +2 -2
  45. package/dist/x402-client-B8zdDeat.d.cts +0 -146
  46. package/dist/x402-client-B8zdDeat.d.ts +0 -146
@@ -1,5 +1,6 @@
1
- import { W as WalletSet } from './types-C08JT9MG.js';
1
+ import { W as WalletSet } from './types-Ds9IUnXG.js';
2
2
  import { T as Tab } from './types-D0IFR4Ro.js';
3
+ import { P as PaymentReceipt } from './x402-client-Cil4Tmqy.js';
3
4
 
4
5
  /**
5
6
  * Shared contract for the x402 version seam. Both the v1 and v2 strategy
@@ -34,6 +35,8 @@ interface PaymentChallenge {
34
35
  x402Version: 1 | 2;
35
36
  options: ChallengeOption[];
36
37
  resourceUrl?: string;
38
+ /** Extension requirements advertised by the merchant. */
39
+ extensions?: Record<string, unknown>;
37
40
  }
38
41
  /**
39
42
  * Result of a paid fetch. Never throws for an expected failure.
@@ -67,6 +70,8 @@ type PayResult = {
67
70
  amountPaid: string;
68
71
  network: NetworkRef;
69
72
  txSignature?: string;
73
+ /** Merchant settlement evidence, when a receipt was returned. */
74
+ paymentReceipt?: PaymentReceipt;
70
75
  } | {
71
76
  ok: true;
72
77
  paid: false;
@@ -80,18 +85,27 @@ type PayResult = {
80
85
  /** The merchant ACCEPTED the payment shape but their own settlement
81
86
  * failed (their facilitator errored). Not our payload — a
82
87
  * merchant-side defect. `detail` carries their verbatim error. */
83
- | 'settlement_failed' | 'no_payment_options'
88
+ | 'settlement_failed'
89
+ /** Settlement succeeded, but the merchant returned an unsuccessful HTTP
90
+ * response. Recover the same result; another authorization can charge again. */
91
+ | 'delivery_failed' | 'no_payment_options'
84
92
  /** No payment was sent before the deadline — the unpaid probe (or
85
93
  * build/sign) ran past the pre-payment timeout. No money moved;
86
94
  * safe to retry. */
87
95
  | 'timeout'
88
- /** The payment authorization WAS sent to the merchant, the merchant
89
- * did not respond before the deadline, and settlement could not be
90
- * confirmed. The payment MAY have settled on-chain. DO NOT
96
+ /** The payment authorization WAS sent, but settlement could not be
97
+ * confirmed: the response may be absent, pending, malformed or
98
+ * inconsistent with the dispatched payment. It MAY have settled. DO NOT
91
99
  * blind-retry — a retry signs a fresh authorization and can pay
92
100
  * again. `detail` explains the state. */
93
101
  | 'payment_unconfirmed' | 'budget_exceeded' | 'error';
94
102
  detail?: string;
103
+ /** Original response, retained even when HTTP succeeded but settlement did not. */
104
+ response?: Response;
105
+ /** Transaction identifier reported by the merchant; not proof of settlement. */
106
+ txSignature?: string;
107
+ /** Saved settlement evidence for recovery of this same payment. */
108
+ paymentReceipt?: PaymentReceipt;
95
109
  };
96
110
 
97
111
  /** Options for a paid fetch. */
@@ -0,0 +1,93 @@
1
+ /**
2
+ * x402 v2 Client
3
+ *
4
+ * `createX402Client`, `X402Client`, and `X402ClientConfig` are
5
+ * @deprecated — slated for removal in `@dexterai/x402` 5.0 (~6 months out;
6
+ * longer cycle than the 4.0 batch because there are real consumers). Use
7
+ * `payAndFetch` from `@dexterai/x402/client` instead — it's the version-
8
+ * agnostic 2026+ client with a discriminated-union return type. The
9
+ * `getPaymentReceipt` helper and `PaymentReceipt` type in this file are NOT
10
+ * deprecated; they continue to support receipt-reading on any paid response.
11
+ *
12
+ * Chain-agnostic client for x402 v2 payments.
13
+ * Automatically detects 402 responses, finds a matching payment option,
14
+ * builds the transaction with the appropriate chain adapter, and retries.
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * import { createX402Client } from '@dexterai/x402/client';
19
+ * import { createSolanaAdapter, createEvmAdapter } from '@dexterai/x402/adapters';
20
+ *
21
+ * const client = createX402Client({
22
+ * adapters: [createSolanaAdapter(), createEvmAdapter()],
23
+ * wallets: {
24
+ * solana: solanaWallet,
25
+ * evm: evmWallet,
26
+ * },
27
+ * });
28
+ *
29
+ * const response = await client.fetch(url);
30
+ * ```
31
+ */
32
+
33
+ /**
34
+ * Settlement evidence attached to a response after payment dispatch.
35
+ * Access via `getPaymentReceipt(response)`.
36
+ */
37
+ interface PaymentReceipt {
38
+ /** Whether settlement succeeded */
39
+ success?: boolean;
40
+ /** Transaction signature/hash */
41
+ transaction?: string;
42
+ /** CAIP-2 network */
43
+ network?: string;
44
+ /** Payer address */
45
+ payer?: string;
46
+ /** Protocol extensions (e.g., sponsored-access recommendations) */
47
+ extensions?: Record<string, unknown>;
48
+ /** Merchant-reported settlement error. This alone does not prove no debit occurred. */
49
+ errorReason?: string;
50
+ errorCode?: string;
51
+ errorMessage?: string;
52
+ /** Interpretation of the receipt for the exact dispatched requirements. */
53
+ settlementStatus?: 'settled' | 'pending' | 'failed' | 'unconfirmed';
54
+ /** Amount authorized for this attempt, whether or not settlement is confirmed. */
55
+ attemptedAmountAtomic?: string;
56
+ /**
57
+ * Amount actually paid, in atomic units (e.g. '10000' for 0.01 USDC).
58
+ * Set from the dispatched requirement only when the matching receipt reports
59
+ * successful settlement. An unknown outcome exposes attemptedAmountAtomic.
60
+ */
61
+ amountAtomic?: string;
62
+ /**
63
+ * Decimals of the paid asset, so `amountAtomic` can be converted to a human
64
+ * amount: `Number(amountAtomic) / 10 ** assetDecimals`.
65
+ */
66
+ assetDecimals?: number;
67
+ }
68
+ /**
69
+ * Get the x402 payment receipt from a response, or undefined if none.
70
+ */
71
+ declare function getPaymentReceipt(response: Response): PaymentReceipt | undefined;
72
+ interface PaymentReceiptAttempt {
73
+ network: string;
74
+ amountAtomic: string;
75
+ assetDecimals?: number;
76
+ }
77
+ /** Capture a dispatched payment's response without consuming its body or issuing another request. */
78
+ declare function capturePaymentReceipt(response: Response, attempt: PaymentReceiptAttempt): PaymentReceipt;
79
+ /**
80
+ * x402 Client interface
81
+ *
82
+ * @deprecated Slated for removal in `@dexterai/x402` 5.0. Use `payAndFetch`
83
+ * directly instead of constructing a client object.
84
+ */
85
+ interface X402Client {
86
+ /**
87
+ * Fetch with automatic x402 payment handling.
88
+ * If the server returns 402, handles payment automatically and retries.
89
+ */
90
+ fetch(input: string | URL | Request, init?: RequestInit): Promise<Response>;
91
+ }
92
+
93
+ export { type PaymentReceipt as P, type X402Client as X, type PaymentReceiptAttempt as a, capturePaymentReceipt as c, getPaymentReceipt as g };
@@ -0,0 +1,93 @@
1
+ /**
2
+ * x402 v2 Client
3
+ *
4
+ * `createX402Client`, `X402Client`, and `X402ClientConfig` are
5
+ * @deprecated — slated for removal in `@dexterai/x402` 5.0 (~6 months out;
6
+ * longer cycle than the 4.0 batch because there are real consumers). Use
7
+ * `payAndFetch` from `@dexterai/x402/client` instead — it's the version-
8
+ * agnostic 2026+ client with a discriminated-union return type. The
9
+ * `getPaymentReceipt` helper and `PaymentReceipt` type in this file are NOT
10
+ * deprecated; they continue to support receipt-reading on any paid response.
11
+ *
12
+ * Chain-agnostic client for x402 v2 payments.
13
+ * Automatically detects 402 responses, finds a matching payment option,
14
+ * builds the transaction with the appropriate chain adapter, and retries.
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * import { createX402Client } from '@dexterai/x402/client';
19
+ * import { createSolanaAdapter, createEvmAdapter } from '@dexterai/x402/adapters';
20
+ *
21
+ * const client = createX402Client({
22
+ * adapters: [createSolanaAdapter(), createEvmAdapter()],
23
+ * wallets: {
24
+ * solana: solanaWallet,
25
+ * evm: evmWallet,
26
+ * },
27
+ * });
28
+ *
29
+ * const response = await client.fetch(url);
30
+ * ```
31
+ */
32
+
33
+ /**
34
+ * Settlement evidence attached to a response after payment dispatch.
35
+ * Access via `getPaymentReceipt(response)`.
36
+ */
37
+ interface PaymentReceipt {
38
+ /** Whether settlement succeeded */
39
+ success?: boolean;
40
+ /** Transaction signature/hash */
41
+ transaction?: string;
42
+ /** CAIP-2 network */
43
+ network?: string;
44
+ /** Payer address */
45
+ payer?: string;
46
+ /** Protocol extensions (e.g., sponsored-access recommendations) */
47
+ extensions?: Record<string, unknown>;
48
+ /** Merchant-reported settlement error. This alone does not prove no debit occurred. */
49
+ errorReason?: string;
50
+ errorCode?: string;
51
+ errorMessage?: string;
52
+ /** Interpretation of the receipt for the exact dispatched requirements. */
53
+ settlementStatus?: 'settled' | 'pending' | 'failed' | 'unconfirmed';
54
+ /** Amount authorized for this attempt, whether or not settlement is confirmed. */
55
+ attemptedAmountAtomic?: string;
56
+ /**
57
+ * Amount actually paid, in atomic units (e.g. '10000' for 0.01 USDC).
58
+ * Set from the dispatched requirement only when the matching receipt reports
59
+ * successful settlement. An unknown outcome exposes attemptedAmountAtomic.
60
+ */
61
+ amountAtomic?: string;
62
+ /**
63
+ * Decimals of the paid asset, so `amountAtomic` can be converted to a human
64
+ * amount: `Number(amountAtomic) / 10 ** assetDecimals`.
65
+ */
66
+ assetDecimals?: number;
67
+ }
68
+ /**
69
+ * Get the x402 payment receipt from a response, or undefined if none.
70
+ */
71
+ declare function getPaymentReceipt(response: Response): PaymentReceipt | undefined;
72
+ interface PaymentReceiptAttempt {
73
+ network: string;
74
+ amountAtomic: string;
75
+ assetDecimals?: number;
76
+ }
77
+ /** Capture a dispatched payment's response without consuming its body or issuing another request. */
78
+ declare function capturePaymentReceipt(response: Response, attempt: PaymentReceiptAttempt): PaymentReceipt;
79
+ /**
80
+ * x402 Client interface
81
+ *
82
+ * @deprecated Slated for removal in `@dexterai/x402` 5.0. Use `payAndFetch`
83
+ * directly instead of constructing a client object.
84
+ */
85
+ interface X402Client {
86
+ /**
87
+ * Fetch with automatic x402 payment handling.
88
+ * If the server returns 402, handles payment automatically and retries.
89
+ */
90
+ fetch(input: string | URL | Request, init?: RequestInit): Promise<Response>;
91
+ }
92
+
93
+ export { type PaymentReceipt as P, type X402Client as X, type PaymentReceiptAttempt as a, capturePaymentReceipt as c, getPaymentReceipt as g };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dexterai/x402",
3
- "version": "6.0.0",
3
+ "version": "6.0.2",
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",
@@ -84,7 +84,7 @@
84
84
  },
85
85
  "dependencies": {
86
86
  "@dexterai/x402-ads-types": "^0.2.0",
87
- "@dexterai/x402-core": "^1.4.0",
87
+ "@dexterai/x402-core": "^1.5.2",
88
88
  "@noble/curves": "^1.9.7",
89
89
  "@noble/hashes": "^1.8.0",
90
90
  "@solana/spl-token": "^0.4.9",
@@ -1,146 +0,0 @@
1
- import { SponsoredAccessSettlementInfo, SponsoredRecommendation } from '@dexterai/x402-ads-types';
2
-
3
- /**
4
- * Sponsored Access (Ads for Agents) — Client Helpers
5
- *
6
- * Extract sponsored recommendations from x402 payment receipts and
7
- * fire impression beacons to confirm delivery to the ad network.
8
- *
9
- * Recommendations are injected by the facilitator after settlement
10
- * via the `extensions["sponsored-access"]` field. Publishers who enable
11
- * `sponsoredAccess: true` in their middleware also inject them into
12
- * the JSON response body as `_x402_sponsored`.
13
- *
14
- * @example
15
- * ```typescript
16
- * import { wrapFetch, getSponsoredRecommendations, fireImpressionBeacon } from '@dexterai/x402/client';
17
- *
18
- * const x402Fetch = wrapFetch(fetch, { walletPrivateKey: key });
19
- * const response = await x402Fetch('https://api.example.com/data');
20
- *
21
- * const recs = getSponsoredRecommendations(response);
22
- * if (recs) {
23
- * console.log('Sponsored:', recs.map(r => `${r.sponsor}: ${r.description}`));
24
- * await fireImpressionBeacon(response); // Confirm delivery to ad network
25
- * }
26
- * ```
27
- */
28
-
29
- /**
30
- * Extract the full sponsored-access extension data from a payment receipt.
31
- * Returns undefined if no sponsored-access extension is present.
32
- */
33
- declare function getSponsoredAccessInfo(response: Response): SponsoredAccessSettlementInfo | undefined;
34
- /**
35
- * Extract sponsored recommendations from an x402 payment response.
36
- * Returns the recommendations array, or undefined if none present.
37
- *
38
- * @example
39
- * ```typescript
40
- * const recs = getSponsoredRecommendations(response);
41
- * if (recs) {
42
- * for (const rec of recs) {
43
- * console.log(`${rec.sponsor}: ${rec.description} — ${rec.resourceUrl}`);
44
- * }
45
- * }
46
- * ```
47
- */
48
- declare function getSponsoredRecommendations(response: Response): SponsoredRecommendation[] | undefined;
49
- /**
50
- * Fire the impression beacon to confirm recommendation delivery to the ad network.
51
- * This is a fire-and-forget GET request — failures are silently ignored.
52
- *
53
- * Call this after you've read the recommendations to help the ad network
54
- * track delivery rates and verify impressions.
55
- *
56
- * @returns true if the beacon was fired (regardless of response), false if no beacon URL
57
- *
58
- * @example
59
- * ```typescript
60
- * const recs = getSponsoredRecommendations(response);
61
- * if (recs) {
62
- * // Process recommendations...
63
- * await fireImpressionBeacon(response);
64
- * }
65
- * ```
66
- */
67
- declare function fireImpressionBeacon(response: Response): Promise<boolean>;
68
-
69
- /**
70
- * x402 v2 Client
71
- *
72
- * `createX402Client`, `X402Client`, and `X402ClientConfig` are
73
- * @deprecated — slated for removal in `@dexterai/x402` 5.0 (~6 months out;
74
- * longer cycle than the 4.0 batch because there are real consumers). Use
75
- * `payAndFetch` from `@dexterai/x402/client` instead — it's the version-
76
- * agnostic 2026+ client with a discriminated-union return type. The
77
- * `getPaymentReceipt` helper and `PaymentReceipt` type in this file are NOT
78
- * deprecated; they continue to support receipt-reading on any paid response.
79
- *
80
- * Chain-agnostic client for x402 v2 payments.
81
- * Automatically detects 402 responses, finds a matching payment option,
82
- * builds the transaction with the appropriate chain adapter, and retries.
83
- *
84
- * @example
85
- * ```typescript
86
- * import { createX402Client } from '@dexterai/x402/client';
87
- * import { createSolanaAdapter, createEvmAdapter } from '@dexterai/x402/adapters';
88
- *
89
- * const client = createX402Client({
90
- * adapters: [createSolanaAdapter(), createEvmAdapter()],
91
- * wallets: {
92
- * solana: solanaWallet,
93
- * evm: evmWallet,
94
- * },
95
- * });
96
- *
97
- * const response = await client.fetch(url);
98
- * ```
99
- */
100
-
101
- /**
102
- * Payment receipt attached to a successful x402 response.
103
- * Access via `getPaymentReceipt(response)`.
104
- */
105
- interface PaymentReceipt {
106
- /** Whether settlement succeeded */
107
- success?: boolean;
108
- /** Transaction signature/hash */
109
- transaction?: string;
110
- /** CAIP-2 network */
111
- network?: string;
112
- /** Payer address */
113
- payer?: string;
114
- /** Protocol extensions (e.g., sponsored-access recommendations) */
115
- extensions?: Record<string, unknown>;
116
- /**
117
- * Amount actually paid, in atomic units (e.g. '10000' for 0.01 USDC).
118
- * Sourced from the payment requirement the client settled — the facilitator's
119
- * PAYMENT-RESPONSE receipt does not echo the amount, so the client records it.
120
- */
121
- amountAtomic?: string;
122
- /**
123
- * Decimals of the paid asset, so `amountAtomic` can be converted to a human
124
- * amount: `Number(amountAtomic) / 10 ** assetDecimals`.
125
- */
126
- assetDecimals?: number;
127
- }
128
- /**
129
- * Get the x402 payment receipt from a response, or undefined if none.
130
- */
131
- declare function getPaymentReceipt(response: Response): PaymentReceipt | undefined;
132
- /**
133
- * x402 Client interface
134
- *
135
- * @deprecated Slated for removal in `@dexterai/x402` 5.0. Use `payAndFetch`
136
- * directly instead of constructing a client object.
137
- */
138
- interface X402Client {
139
- /**
140
- * Fetch with automatic x402 payment handling.
141
- * If the server returns 402, handles payment automatically and retries.
142
- */
143
- fetch(input: string | URL | Request, init?: RequestInit): Promise<Response>;
144
- }
145
-
146
- export { type PaymentReceipt as P, type X402Client as X, getSponsoredAccessInfo as a, getSponsoredRecommendations as b, fireImpressionBeacon as f, getPaymentReceipt as g };
@@ -1,146 +0,0 @@
1
- import { SponsoredAccessSettlementInfo, SponsoredRecommendation } from '@dexterai/x402-ads-types';
2
-
3
- /**
4
- * Sponsored Access (Ads for Agents) — Client Helpers
5
- *
6
- * Extract sponsored recommendations from x402 payment receipts and
7
- * fire impression beacons to confirm delivery to the ad network.
8
- *
9
- * Recommendations are injected by the facilitator after settlement
10
- * via the `extensions["sponsored-access"]` field. Publishers who enable
11
- * `sponsoredAccess: true` in their middleware also inject them into
12
- * the JSON response body as `_x402_sponsored`.
13
- *
14
- * @example
15
- * ```typescript
16
- * import { wrapFetch, getSponsoredRecommendations, fireImpressionBeacon } from '@dexterai/x402/client';
17
- *
18
- * const x402Fetch = wrapFetch(fetch, { walletPrivateKey: key });
19
- * const response = await x402Fetch('https://api.example.com/data');
20
- *
21
- * const recs = getSponsoredRecommendations(response);
22
- * if (recs) {
23
- * console.log('Sponsored:', recs.map(r => `${r.sponsor}: ${r.description}`));
24
- * await fireImpressionBeacon(response); // Confirm delivery to ad network
25
- * }
26
- * ```
27
- */
28
-
29
- /**
30
- * Extract the full sponsored-access extension data from a payment receipt.
31
- * Returns undefined if no sponsored-access extension is present.
32
- */
33
- declare function getSponsoredAccessInfo(response: Response): SponsoredAccessSettlementInfo | undefined;
34
- /**
35
- * Extract sponsored recommendations from an x402 payment response.
36
- * Returns the recommendations array, or undefined if none present.
37
- *
38
- * @example
39
- * ```typescript
40
- * const recs = getSponsoredRecommendations(response);
41
- * if (recs) {
42
- * for (const rec of recs) {
43
- * console.log(`${rec.sponsor}: ${rec.description} — ${rec.resourceUrl}`);
44
- * }
45
- * }
46
- * ```
47
- */
48
- declare function getSponsoredRecommendations(response: Response): SponsoredRecommendation[] | undefined;
49
- /**
50
- * Fire the impression beacon to confirm recommendation delivery to the ad network.
51
- * This is a fire-and-forget GET request — failures are silently ignored.
52
- *
53
- * Call this after you've read the recommendations to help the ad network
54
- * track delivery rates and verify impressions.
55
- *
56
- * @returns true if the beacon was fired (regardless of response), false if no beacon URL
57
- *
58
- * @example
59
- * ```typescript
60
- * const recs = getSponsoredRecommendations(response);
61
- * if (recs) {
62
- * // Process recommendations...
63
- * await fireImpressionBeacon(response);
64
- * }
65
- * ```
66
- */
67
- declare function fireImpressionBeacon(response: Response): Promise<boolean>;
68
-
69
- /**
70
- * x402 v2 Client
71
- *
72
- * `createX402Client`, `X402Client`, and `X402ClientConfig` are
73
- * @deprecated — slated for removal in `@dexterai/x402` 5.0 (~6 months out;
74
- * longer cycle than the 4.0 batch because there are real consumers). Use
75
- * `payAndFetch` from `@dexterai/x402/client` instead — it's the version-
76
- * agnostic 2026+ client with a discriminated-union return type. The
77
- * `getPaymentReceipt` helper and `PaymentReceipt` type in this file are NOT
78
- * deprecated; they continue to support receipt-reading on any paid response.
79
- *
80
- * Chain-agnostic client for x402 v2 payments.
81
- * Automatically detects 402 responses, finds a matching payment option,
82
- * builds the transaction with the appropriate chain adapter, and retries.
83
- *
84
- * @example
85
- * ```typescript
86
- * import { createX402Client } from '@dexterai/x402/client';
87
- * import { createSolanaAdapter, createEvmAdapter } from '@dexterai/x402/adapters';
88
- *
89
- * const client = createX402Client({
90
- * adapters: [createSolanaAdapter(), createEvmAdapter()],
91
- * wallets: {
92
- * solana: solanaWallet,
93
- * evm: evmWallet,
94
- * },
95
- * });
96
- *
97
- * const response = await client.fetch(url);
98
- * ```
99
- */
100
-
101
- /**
102
- * Payment receipt attached to a successful x402 response.
103
- * Access via `getPaymentReceipt(response)`.
104
- */
105
- interface PaymentReceipt {
106
- /** Whether settlement succeeded */
107
- success?: boolean;
108
- /** Transaction signature/hash */
109
- transaction?: string;
110
- /** CAIP-2 network */
111
- network?: string;
112
- /** Payer address */
113
- payer?: string;
114
- /** Protocol extensions (e.g., sponsored-access recommendations) */
115
- extensions?: Record<string, unknown>;
116
- /**
117
- * Amount actually paid, in atomic units (e.g. '10000' for 0.01 USDC).
118
- * Sourced from the payment requirement the client settled — the facilitator's
119
- * PAYMENT-RESPONSE receipt does not echo the amount, so the client records it.
120
- */
121
- amountAtomic?: string;
122
- /**
123
- * Decimals of the paid asset, so `amountAtomic` can be converted to a human
124
- * amount: `Number(amountAtomic) / 10 ** assetDecimals`.
125
- */
126
- assetDecimals?: number;
127
- }
128
- /**
129
- * Get the x402 payment receipt from a response, or undefined if none.
130
- */
131
- declare function getPaymentReceipt(response: Response): PaymentReceipt | undefined;
132
- /**
133
- * x402 Client interface
134
- *
135
- * @deprecated Slated for removal in `@dexterai/x402` 5.0. Use `payAndFetch`
136
- * directly instead of constructing a client object.
137
- */
138
- interface X402Client {
139
- /**
140
- * Fetch with automatic x402 payment handling.
141
- * If the server returns 402, handles payment automatically and retries.
142
- */
143
- fetch(input: string | URL | Request, init?: RequestInit): Promise<Response>;
144
- }
145
-
146
- export { type PaymentReceipt as P, type X402Client as X, getSponsoredAccessInfo as a, getSponsoredRecommendations as b, fireImpressionBeacon as f, getPaymentReceipt as g };