@dexterai/x402 6.0.0-rc.5 → 6.0.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/CHANGELOG.md +63 -0
- package/README.md +5 -1
- package/REFERENCE.md +33 -3
- package/dist/adapters/index.cjs +1 -1
- package/dist/adapters/index.d.cts +3 -2
- package/dist/adapters/index.d.ts +3 -2
- package/dist/adapters/index.js +1 -1
- package/dist/batch-settlement/index.cjs +1 -1
- package/dist/batch-settlement/index.d.cts +4 -3
- package/dist/batch-settlement/index.d.ts +4 -3
- package/dist/batch-settlement/index.js +1 -1
- package/dist/batch-settlement/seller/index.cjs +1 -1
- package/dist/batch-settlement/seller/index.d.cts +5 -4
- package/dist/batch-settlement/seller/index.d.ts +5 -4
- package/dist/batch-settlement/seller/index.js +1 -1
- package/dist/client/index.cjs +1 -1
- package/dist/client/index.d.cts +7 -4
- package/dist/client/index.d.ts +7 -4
- package/dist/client/index.js +1 -1
- package/dist/mcp/index.cjs +1 -0
- package/dist/mcp/index.d.cts +183 -0
- package/dist/mcp/index.d.ts +183 -0
- package/dist/mcp/index.js +1 -0
- 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 -4
- package/dist/server/index.d.ts +5 -4
- package/dist/server/index.js +1 -1
- package/dist/sponsored-access-ByM3apeR.d.cts +69 -0
- package/dist/sponsored-access-ByM3apeR.d.ts +69 -0
- package/dist/tab/adapters/solana/index.cjs +1 -1
- package/dist/tab/adapters/solana/index.js +1 -1
- package/dist/tab/index.cjs +4 -4
- package/dist/tab/index.d.cts +4 -2
- package/dist/tab/index.d.ts +4 -2
- package/dist/tab/index.js +5 -5
- package/dist/tab/seller/index.cjs +7 -7
- package/dist/tab/seller/index.js +1 -1
- package/dist/types-8Q38sHOi.d.cts +237 -0
- package/dist/types-8Q38sHOi.d.ts +237 -0
- package/dist/{types-BvQpNtFw.d.cts → types-B4JCwkHH.d.cts} +2 -236
- package/dist/{types-DwVhPqOZ.d.ts → types-BOEYu6ya.d.cts} +4 -2
- package/dist/{types-CkcNYx1Q.d.ts → types-BdUPQzXu.d.ts} +1 -1
- package/dist/{types-JpkrtFbZ.d.cts → types-CTYEYNZO.d.cts} +1 -1
- package/dist/{types-BbvuPNXl.d.cts → types-DhCxPFgg.d.ts} +4 -2
- package/dist/{types-BvQpNtFw.d.ts → types-Ds9IUnXG.d.ts} +2 -236
- package/dist/{types-CBQKKFxJ.d.cts → types-G6MIMJjK.d.cts} +19 -5
- package/dist/{types-CHQzNDR6.d.ts → types-zImyINj3.d.ts} +19 -5
- package/dist/x402-client-Cil4Tmqy.d.cts +93 -0
- package/dist/x402-client-Cil4Tmqy.d.ts +93 -0
- package/docs/mcp.md +98 -0
- package/examples/mcp-paid-tool.ts +39 -0
- package/package.json +16 -10
- package/dist/x402-client-B8zdDeat.d.cts +0 -146
- package/dist/x402-client-B8zdDeat.d.ts +0 -146
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createMcpFacilitatorProcessor, createPaidMcpTool,
|
|
3
|
+
type McpPaymentStore,
|
|
4
|
+
} from '@dexterai/x402/mcp';
|
|
5
|
+
|
|
6
|
+
interface CustomerContext { accountId?: string }
|
|
7
|
+
|
|
8
|
+
/** Supply the application's existing durable store and report execution. */
|
|
9
|
+
export function createReportTool(dependencies: {
|
|
10
|
+
sellerAddress: string;
|
|
11
|
+
store: McpPaymentStore;
|
|
12
|
+
requireAccount(context: CustomerContext): Promise<string>;
|
|
13
|
+
buildReport(arguments_: Record<string, unknown>, paymentId: string): Promise<{
|
|
14
|
+
summary: string;
|
|
15
|
+
sources: string[];
|
|
16
|
+
}>;
|
|
17
|
+
}) {
|
|
18
|
+
return createPaidMcpTool<CustomerContext>({
|
|
19
|
+
name: 'report',
|
|
20
|
+
serviceScope: 'reports.example/customer-reports',
|
|
21
|
+
requirements: {
|
|
22
|
+
x402Version: 2,
|
|
23
|
+
resource: { url: 'mcp://reports.example/tools/report', mimeType: 'application/json' },
|
|
24
|
+
accepts: [{
|
|
25
|
+
scheme: 'exact', network: 'eip155:8453', amount: '10000',
|
|
26
|
+
asset: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',
|
|
27
|
+
payTo: dependencies.sellerAddress, maxTimeoutSeconds: 60,
|
|
28
|
+
extra: { name: 'USD Coin', version: '2' },
|
|
29
|
+
}],
|
|
30
|
+
},
|
|
31
|
+
payments: createMcpFacilitatorProcessor({ networks: ['eip155:8453'] }),
|
|
32
|
+
store: dependencies.store,
|
|
33
|
+
authorize: (_request, context) => dependencies.requireAccount(context),
|
|
34
|
+
execute: async (request, { paymentId }) => {
|
|
35
|
+
const report = await dependencies.buildReport(request.arguments ?? {}, paymentId);
|
|
36
|
+
return { content: [{ type: 'text', text: report.summary }], structuredContent: report };
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
}
|
package/package.json
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dexterai/x402",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.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",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"exports": {
|
|
9
|
+
"./mcp": {
|
|
10
|
+
"types": "./dist/mcp/index.d.ts",
|
|
11
|
+
"import": "./dist/mcp/index.js",
|
|
12
|
+
"require": "./dist/mcp/index.cjs"
|
|
13
|
+
},
|
|
9
14
|
"./client": {
|
|
10
15
|
"types": "./dist/client/index.d.ts",
|
|
11
16
|
"import": "./dist/client/index.js",
|
|
@@ -62,6 +67,8 @@
|
|
|
62
67
|
"README.md",
|
|
63
68
|
"REFERENCE.md",
|
|
64
69
|
"CHANGELOG.md",
|
|
70
|
+
"docs/mcp.md",
|
|
71
|
+
"examples/mcp-paid-tool.ts",
|
|
65
72
|
"LICENSE",
|
|
66
73
|
"assets/*.svg"
|
|
67
74
|
],
|
|
@@ -73,10 +80,7 @@
|
|
|
73
80
|
"test:watch": "vitest",
|
|
74
81
|
"test:real": "echo 'Real payment tests require funded wallets. Run: npx tsx test/real-payment-solana.ts'",
|
|
75
82
|
"prepublishOnly": "npm run build",
|
|
76
|
-
"
|
|
77
|
-
"release:minor": "npm version minor && npm publish --access public",
|
|
78
|
-
"release:major": "npm version major && npm publish --access public",
|
|
79
|
-
"release:next": "npm publish --access public --tag next"
|
|
83
|
+
"verify:tab:package": "node scripts/verify-packed-tab.mjs"
|
|
80
84
|
},
|
|
81
85
|
"dependencies": {
|
|
82
86
|
"@dexterai/x402-ads-types": "^0.2.0",
|
|
@@ -85,18 +89,20 @@
|
|
|
85
89
|
"@noble/hashes": "^1.8.0",
|
|
86
90
|
"@solana/spl-token": "^0.4.9",
|
|
87
91
|
"@solana/web3.js": "^1.98.0",
|
|
88
|
-
"@x402/core": "2.
|
|
89
|
-
"@x402/evm": "2.
|
|
90
|
-
"@x402/extensions": "2.
|
|
92
|
+
"@x402/core": "2.26.0",
|
|
93
|
+
"@x402/evm": "2.26.0",
|
|
94
|
+
"@x402/extensions": "2.26.0",
|
|
91
95
|
"bs58": "^6.0.0",
|
|
92
96
|
"tweetnacl": "^1.0.3"
|
|
93
97
|
},
|
|
94
98
|
"devDependencies": {
|
|
95
|
-
"@dexterai/vault": "0.43.
|
|
99
|
+
"@dexterai/vault": "0.43.4",
|
|
100
|
+
"@modelcontextprotocol/sdk": "1.30.0",
|
|
96
101
|
"@types/aws-lambda": "^8.10.161",
|
|
97
102
|
"@types/express": "^5.0.6",
|
|
98
103
|
"@types/node": "^22.10.0",
|
|
99
104
|
"@types/react": "^18.0.0",
|
|
105
|
+
"@x402/mcp": "2.26.0",
|
|
100
106
|
"ethers": "^6.13.0",
|
|
101
107
|
"express": "^5.2.1",
|
|
102
108
|
"react": "^18.0.0",
|
|
@@ -106,7 +112,7 @@
|
|
|
106
112
|
"vitest": "^2.1.8"
|
|
107
113
|
},
|
|
108
114
|
"peerDependencies": {
|
|
109
|
-
"@dexterai/vault": "0.43.
|
|
115
|
+
"@dexterai/vault": "0.43.4",
|
|
110
116
|
"@solana/wallet-adapter-base": "^0.9.0",
|
|
111
117
|
"react": "^18.0.0 || ^19.0.0",
|
|
112
118
|
"stripe": "^20.0.0",
|
|
@@ -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 };
|