@dexterai/x402 3.3.0 → 3.3.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 +66 -8
- package/dist/adapters/index.d.cts +2 -3
- package/dist/adapters/index.d.ts +2 -3
- package/dist/batch-settlement/index.cjs +1 -1
- package/dist/batch-settlement/index.d.cts +5 -81
- package/dist/batch-settlement/index.d.ts +5 -81
- package/dist/batch-settlement/index.js +1 -1
- package/dist/batch-settlement/seller/index.cjs +1 -0
- package/dist/batch-settlement/seller/index.d.cts +17 -0
- package/dist/batch-settlement/seller/index.d.ts +17 -0
- package/dist/batch-settlement/seller/index.js +1 -0
- package/dist/client/index.d.cts +3 -5
- package/dist/client/index.d.ts +3 -5
- package/dist/react/index.d.cts +4 -5
- package/dist/react/index.d.ts +4 -5
- package/dist/server/index.cjs +16 -16
- package/dist/server/index.d.cts +20 -30
- package/dist/server/index.d.ts +20 -30
- package/dist/server/index.js +16 -16
- package/dist/{sponsored-access-4wVjCYrH.d.ts → sponsored-access-B2UCVgj3.d.cts} +1 -2
- package/dist/{sponsored-access-BEufXQ6c.d.cts → sponsored-access-B2USBiVp.d.ts} +1 -2
- package/dist/types-BBhXpBwI.d.cts +60 -0
- package/dist/types-BIINnfB4.d.ts +142 -0
- package/dist/types-Bbt_SDZE.d.cts +142 -0
- package/dist/types-CwK4mPWV.d.ts +60 -0
- package/dist/{types-HFS_C6RX.d.ts → types-IqnDBsjL.d.cts} +226 -2
- package/dist/{types-B3kS1y_t.d.cts → types-IqnDBsjL.d.ts} +226 -2
- package/package.json +8 -2
- package/dist/types-Bcsi5jQb.d.cts +0 -227
- package/dist/types-Bcsi5jQb.d.ts +0 -227
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dexterai/x402",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.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, SKALE.",
|
|
5
5
|
"author": "Dexter",
|
|
6
6
|
"license": "MIT",
|
|
@@ -35,6 +35,11 @@
|
|
|
35
35
|
"types": "./dist/batch-settlement/index.d.ts",
|
|
36
36
|
"import": "./dist/batch-settlement/index.js",
|
|
37
37
|
"require": "./dist/batch-settlement/index.cjs"
|
|
38
|
+
},
|
|
39
|
+
"./batch-settlement/seller": {
|
|
40
|
+
"types": "./dist/batch-settlement/seller/index.d.ts",
|
|
41
|
+
"import": "./dist/batch-settlement/seller/index.js",
|
|
42
|
+
"require": "./dist/batch-settlement/seller/index.cjs"
|
|
38
43
|
}
|
|
39
44
|
},
|
|
40
45
|
"files": [
|
|
@@ -57,7 +62,7 @@
|
|
|
57
62
|
},
|
|
58
63
|
"dependencies": {
|
|
59
64
|
"@dexterai/x402-ads-types": "^0.2.0",
|
|
60
|
-
"@dexterai/x402-core": "^1.
|
|
65
|
+
"@dexterai/x402-core": "^1.4.0",
|
|
61
66
|
"@solana/spl-token": "^0.4.9",
|
|
62
67
|
"@solana/web3.js": "^1.98.0",
|
|
63
68
|
"@x402/core": "^2.12.0",
|
|
@@ -70,6 +75,7 @@
|
|
|
70
75
|
"@types/react": "^18.0.0",
|
|
71
76
|
"bs58": "^6.0.0",
|
|
72
77
|
"ethers": "^6.13.0",
|
|
78
|
+
"express": "^5.2.1",
|
|
73
79
|
"react": "^18.0.0",
|
|
74
80
|
"stripe": "^20.3.1",
|
|
75
81
|
"tsup": "^8.3.5",
|
|
@@ -1,227 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* x402 v2 SDK — Shared Types
|
|
3
|
-
*
|
|
4
|
-
* Chain-agnostic types for x402 v2 payments.
|
|
5
|
-
* Works with Solana, Base, and any future x402-compatible networks.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Context passed to a PayToProvider function.
|
|
10
|
-
* Contains request-scoped information for dynamic address resolution.
|
|
11
|
-
*/
|
|
12
|
-
interface PayToContext {
|
|
13
|
-
/** The PAYMENT-SIGNATURE header value (present on retry/verify, undefined on initial 402) */
|
|
14
|
-
paymentHeader?: string;
|
|
15
|
-
/** Amount in atomic units (e.g., '10000' for 0.01 USDC) */
|
|
16
|
-
amountAtomic?: string;
|
|
17
|
-
/** The resource URL being accessed */
|
|
18
|
-
resourceUrl?: string;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Optional defaults a PayToProvider can advertise for auto-configuration.
|
|
22
|
-
* Attached as `_x402Defaults` on the provider function.
|
|
23
|
-
*/
|
|
24
|
-
interface PayToProviderDefaults {
|
|
25
|
-
/** Default CAIP-2 network (e.g., 'eip155:8453' for Base) */
|
|
26
|
-
network?: string;
|
|
27
|
-
/** Default facilitator URL */
|
|
28
|
-
facilitatorUrl?: string;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* A function that dynamically resolves a payment address.
|
|
32
|
-
* Used for providers like Stripe that generate per-request deposit addresses.
|
|
33
|
-
*
|
|
34
|
-
* @example
|
|
35
|
-
* ```typescript
|
|
36
|
-
* import { stripePayTo } from '@dexterai/x402/server';
|
|
37
|
-
*
|
|
38
|
-
* const provider = stripePayTo(process.env.STRIPE_SECRET_KEY);
|
|
39
|
-
* const address = await provider({ amountAtomic: '10000' });
|
|
40
|
-
* ```
|
|
41
|
-
*/
|
|
42
|
-
type PayToProvider = ((context: PayToContext) => Promise<string>) & {
|
|
43
|
-
/** Auto-configuration defaults (set by provider factories like stripePayTo) */
|
|
44
|
-
_x402Defaults?: PayToProviderDefaults;
|
|
45
|
-
};
|
|
46
|
-
/**
|
|
47
|
-
* Resource info included in payment requirements
|
|
48
|
-
*/
|
|
49
|
-
interface ResourceInfo {
|
|
50
|
-
/** Resource URL */
|
|
51
|
-
url: string;
|
|
52
|
-
/** Human-readable description */
|
|
53
|
-
description?: string;
|
|
54
|
-
/** MIME type of the resource */
|
|
55
|
-
mimeType?: string;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Extra fields in payment requirements
|
|
59
|
-
* Chain-specific fields may vary
|
|
60
|
-
*/
|
|
61
|
-
interface AcceptsExtra {
|
|
62
|
-
/** Facilitator address that pays tx fees (required for Solana) */
|
|
63
|
-
feePayer?: string;
|
|
64
|
-
/** Token decimals (optional - defaults to 6 for USDC) */
|
|
65
|
-
decimals?: number;
|
|
66
|
-
/** EIP-712: Token name (EVM only) */
|
|
67
|
-
name?: string;
|
|
68
|
-
/** EIP-712: Token version (EVM only) */
|
|
69
|
-
version?: string;
|
|
70
|
-
/**
|
|
71
|
-
* batch-settlement: on-chain authorizer that the escrow channel pays into.
|
|
72
|
-
* Provided by the facilitator's batch-settlement kind. EVM only.
|
|
73
|
-
*/
|
|
74
|
-
receiverAuthorizer?: string;
|
|
75
|
-
/** Additional chain-specific fields */
|
|
76
|
-
[key: string]: unknown;
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* A single payment option in the accepts array
|
|
80
|
-
*/
|
|
81
|
-
interface PaymentAccept {
|
|
82
|
-
/** x402 version (1 or 2, defaults to 2 if not specified) */
|
|
83
|
-
x402Version?: 1 | 2;
|
|
84
|
-
/**
|
|
85
|
-
* Payment scheme: 'exact' for EIP-3009 chains, 'exact-approval' for
|
|
86
|
-
* approval-based chains like BSC, 'batch-settlement' for the EVM
|
|
87
|
-
* escrow-channel batching scheme (discrete API purchases, gas-amortized).
|
|
88
|
-
*/
|
|
89
|
-
scheme: 'exact' | 'exact-approval' | 'batch-settlement';
|
|
90
|
-
/** CAIP-2 network identifier (v1: 'solana', v2: 'solana:5eykt...') */
|
|
91
|
-
network: string;
|
|
92
|
-
/** Payment amount in atomic units (x402 v2 spec field) */
|
|
93
|
-
amount: string;
|
|
94
|
-
/** @deprecated v1 field — use `amount` instead. Kept for backwards compatibility with v1 data. */
|
|
95
|
-
maxAmountRequired?: string;
|
|
96
|
-
/** Token address */
|
|
97
|
-
asset: string;
|
|
98
|
-
/** Seller's address to receive payment */
|
|
99
|
-
payTo: string;
|
|
100
|
-
/** Maximum seconds until payment expires */
|
|
101
|
-
maxTimeoutSeconds: number;
|
|
102
|
-
/** Chain-specific extra data */
|
|
103
|
-
extra?: AcceptsExtra;
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Full PaymentRequired structure (sent in PAYMENT-REQUIRED header)
|
|
107
|
-
*/
|
|
108
|
-
interface PaymentRequired {
|
|
109
|
-
/** x402 version (always 2) */
|
|
110
|
-
x402Version: 2;
|
|
111
|
-
/** Resource being accessed */
|
|
112
|
-
resource: ResourceInfo;
|
|
113
|
-
/** Available payment options */
|
|
114
|
-
accepts: PaymentAccept[];
|
|
115
|
-
/** Optional error message */
|
|
116
|
-
error?: string;
|
|
117
|
-
/** Protocol extensions */
|
|
118
|
-
extensions?: Record<string, unknown>;
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* Response from /verify endpoint
|
|
122
|
-
*/
|
|
123
|
-
interface VerifyResponse {
|
|
124
|
-
/** Whether the payment is valid */
|
|
125
|
-
isValid: boolean;
|
|
126
|
-
/** Reason for invalidity (if invalid) */
|
|
127
|
-
invalidReason?: string;
|
|
128
|
-
/** Payer address */
|
|
129
|
-
payer?: string;
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* Response from /settle endpoint
|
|
133
|
-
*/
|
|
134
|
-
interface SettleResponse {
|
|
135
|
-
/** Whether settlement succeeded */
|
|
136
|
-
success: boolean;
|
|
137
|
-
/** Transaction signature/hash */
|
|
138
|
-
transaction?: string;
|
|
139
|
-
/** Network the payment was made on */
|
|
140
|
-
network: string;
|
|
141
|
-
/** Error reason (if failed) */
|
|
142
|
-
errorReason?: string;
|
|
143
|
-
/** Error code (if failed) */
|
|
144
|
-
errorCode?: string;
|
|
145
|
-
/** Payer address */
|
|
146
|
-
payer?: string;
|
|
147
|
-
/** Protocol extensions returned by the facilitator (e.g., sponsored-access recommendations) */
|
|
148
|
-
extensions?: Record<string, unknown>;
|
|
149
|
-
}
|
|
150
|
-
/**
|
|
151
|
-
* A single access pass tier offered by a seller
|
|
152
|
-
*/
|
|
153
|
-
interface AccessPassTier {
|
|
154
|
-
/** Tier ID (e.g., '1h', '24h') */
|
|
155
|
-
id: string;
|
|
156
|
-
/** Human-readable label (e.g., '1 hour') */
|
|
157
|
-
label: string;
|
|
158
|
-
/** Duration in seconds */
|
|
159
|
-
seconds: number;
|
|
160
|
-
/** Price in USD (e.g., '0.50') */
|
|
161
|
-
price: string;
|
|
162
|
-
/** Price in atomic units (e.g., '500000') */
|
|
163
|
-
priceAtomic: string;
|
|
164
|
-
}
|
|
165
|
-
/**
|
|
166
|
-
* Access pass info returned in X-ACCESS-PASS-TIERS header
|
|
167
|
-
*/
|
|
168
|
-
interface AccessPassInfo {
|
|
169
|
-
/** Available tiers (if tier-based pricing) */
|
|
170
|
-
tiers?: AccessPassTier[];
|
|
171
|
-
/** Rate per hour in USD (if custom duration pricing) */
|
|
172
|
-
ratePerHour?: string;
|
|
173
|
-
/** Pass issuer identifier */
|
|
174
|
-
issuer?: string;
|
|
175
|
-
}
|
|
176
|
-
/**
|
|
177
|
-
* JWT claims inside an access pass token
|
|
178
|
-
*/
|
|
179
|
-
interface AccessPassClaims {
|
|
180
|
-
/** Subject — always 'x402-access-pass' */
|
|
181
|
-
sub: string;
|
|
182
|
-
/** Tier ID or 'custom' */
|
|
183
|
-
tier: string;
|
|
184
|
-
/** Duration in seconds */
|
|
185
|
-
duration: number;
|
|
186
|
-
/** Issued at (unix seconds) */
|
|
187
|
-
iat: number;
|
|
188
|
-
/** Expires at (unix seconds) */
|
|
189
|
-
exp: number;
|
|
190
|
-
/** Payer wallet address */
|
|
191
|
-
payer: string;
|
|
192
|
-
/** Network used for payment */
|
|
193
|
-
network: string;
|
|
194
|
-
/** Issuer identifier */
|
|
195
|
-
iss: string;
|
|
196
|
-
}
|
|
197
|
-
/**
|
|
198
|
-
* Client-side access pass configuration
|
|
199
|
-
*/
|
|
200
|
-
interface AccessPassClientConfig {
|
|
201
|
-
/** Enable access pass mode (default: true when this config is present) */
|
|
202
|
-
enabled?: boolean;
|
|
203
|
-
/** Preferred tier ID (e.g., '1h') — pick this tier if available */
|
|
204
|
-
preferTier?: string;
|
|
205
|
-
/** Preferred custom duration in seconds (e.g., 3600) */
|
|
206
|
-
preferDuration?: number;
|
|
207
|
-
/** Maximum amount willing to spend in USD (e.g., '2.00') */
|
|
208
|
-
maxSpend?: string;
|
|
209
|
-
/** Auto-renew expired passes (default: true) */
|
|
210
|
-
autoRenew?: boolean;
|
|
211
|
-
}
|
|
212
|
-
/**
|
|
213
|
-
* SDK error codes
|
|
214
|
-
*/
|
|
215
|
-
type X402ErrorCode = 'missing_payment_required_header' | 'invalid_payment_required' | 'unsupported_network' | 'no_matching_payment_option' | 'missing_fee_payer' | 'missing_decimals' | 'missing_amount' | 'amount_exceeds_max' | 'insufficient_balance' | 'wallet_missing_sign_transaction' | 'wallet_not_connected' | 'wallet_disconnected' | 'user_rejected_signature' | 'transaction_build_failed' | 'payment_rejected' | 'rpc_timeout' | 'facilitator_timeout' | 'invalid_payment_signature' | 'facilitator_verify_failed' | 'facilitator_settle_failed' | 'facilitator_request_failed' | 'no_matching_requirement' | 'access_pass_expired' | 'access_pass_invalid' | 'access_pass_tier_not_found' | 'access_pass_exceeds_max_spend';
|
|
216
|
-
/**
|
|
217
|
-
* Custom error class for x402 operations
|
|
218
|
-
*/
|
|
219
|
-
declare class X402Error extends Error {
|
|
220
|
-
/** Error code for programmatic handling */
|
|
221
|
-
code: X402ErrorCode;
|
|
222
|
-
/** Additional error details */
|
|
223
|
-
details?: unknown;
|
|
224
|
-
constructor(code: X402ErrorCode, message: string, details?: unknown);
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
export { type AccessPassClientConfig as A, type PaymentAccept as P, type SettleResponse as S, type VerifyResponse as V, X402Error as X, type AccessPassTier as a, type AccessPassInfo as b, type PayToProvider as c, type PaymentRequired as d, type PayToContext as e, type PayToProviderDefaults as f, type AccessPassClaims as g };
|
package/dist/types-Bcsi5jQb.d.ts
DELETED
|
@@ -1,227 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* x402 v2 SDK — Shared Types
|
|
3
|
-
*
|
|
4
|
-
* Chain-agnostic types for x402 v2 payments.
|
|
5
|
-
* Works with Solana, Base, and any future x402-compatible networks.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Context passed to a PayToProvider function.
|
|
10
|
-
* Contains request-scoped information for dynamic address resolution.
|
|
11
|
-
*/
|
|
12
|
-
interface PayToContext {
|
|
13
|
-
/** The PAYMENT-SIGNATURE header value (present on retry/verify, undefined on initial 402) */
|
|
14
|
-
paymentHeader?: string;
|
|
15
|
-
/** Amount in atomic units (e.g., '10000' for 0.01 USDC) */
|
|
16
|
-
amountAtomic?: string;
|
|
17
|
-
/** The resource URL being accessed */
|
|
18
|
-
resourceUrl?: string;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Optional defaults a PayToProvider can advertise for auto-configuration.
|
|
22
|
-
* Attached as `_x402Defaults` on the provider function.
|
|
23
|
-
*/
|
|
24
|
-
interface PayToProviderDefaults {
|
|
25
|
-
/** Default CAIP-2 network (e.g., 'eip155:8453' for Base) */
|
|
26
|
-
network?: string;
|
|
27
|
-
/** Default facilitator URL */
|
|
28
|
-
facilitatorUrl?: string;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* A function that dynamically resolves a payment address.
|
|
32
|
-
* Used for providers like Stripe that generate per-request deposit addresses.
|
|
33
|
-
*
|
|
34
|
-
* @example
|
|
35
|
-
* ```typescript
|
|
36
|
-
* import { stripePayTo } from '@dexterai/x402/server';
|
|
37
|
-
*
|
|
38
|
-
* const provider = stripePayTo(process.env.STRIPE_SECRET_KEY);
|
|
39
|
-
* const address = await provider({ amountAtomic: '10000' });
|
|
40
|
-
* ```
|
|
41
|
-
*/
|
|
42
|
-
type PayToProvider = ((context: PayToContext) => Promise<string>) & {
|
|
43
|
-
/** Auto-configuration defaults (set by provider factories like stripePayTo) */
|
|
44
|
-
_x402Defaults?: PayToProviderDefaults;
|
|
45
|
-
};
|
|
46
|
-
/**
|
|
47
|
-
* Resource info included in payment requirements
|
|
48
|
-
*/
|
|
49
|
-
interface ResourceInfo {
|
|
50
|
-
/** Resource URL */
|
|
51
|
-
url: string;
|
|
52
|
-
/** Human-readable description */
|
|
53
|
-
description?: string;
|
|
54
|
-
/** MIME type of the resource */
|
|
55
|
-
mimeType?: string;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Extra fields in payment requirements
|
|
59
|
-
* Chain-specific fields may vary
|
|
60
|
-
*/
|
|
61
|
-
interface AcceptsExtra {
|
|
62
|
-
/** Facilitator address that pays tx fees (required for Solana) */
|
|
63
|
-
feePayer?: string;
|
|
64
|
-
/** Token decimals (optional - defaults to 6 for USDC) */
|
|
65
|
-
decimals?: number;
|
|
66
|
-
/** EIP-712: Token name (EVM only) */
|
|
67
|
-
name?: string;
|
|
68
|
-
/** EIP-712: Token version (EVM only) */
|
|
69
|
-
version?: string;
|
|
70
|
-
/**
|
|
71
|
-
* batch-settlement: on-chain authorizer that the escrow channel pays into.
|
|
72
|
-
* Provided by the facilitator's batch-settlement kind. EVM only.
|
|
73
|
-
*/
|
|
74
|
-
receiverAuthorizer?: string;
|
|
75
|
-
/** Additional chain-specific fields */
|
|
76
|
-
[key: string]: unknown;
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* A single payment option in the accepts array
|
|
80
|
-
*/
|
|
81
|
-
interface PaymentAccept {
|
|
82
|
-
/** x402 version (1 or 2, defaults to 2 if not specified) */
|
|
83
|
-
x402Version?: 1 | 2;
|
|
84
|
-
/**
|
|
85
|
-
* Payment scheme: 'exact' for EIP-3009 chains, 'exact-approval' for
|
|
86
|
-
* approval-based chains like BSC, 'batch-settlement' for the EVM
|
|
87
|
-
* escrow-channel batching scheme (discrete API purchases, gas-amortized).
|
|
88
|
-
*/
|
|
89
|
-
scheme: 'exact' | 'exact-approval' | 'batch-settlement';
|
|
90
|
-
/** CAIP-2 network identifier (v1: 'solana', v2: 'solana:5eykt...') */
|
|
91
|
-
network: string;
|
|
92
|
-
/** Payment amount in atomic units (x402 v2 spec field) */
|
|
93
|
-
amount: string;
|
|
94
|
-
/** @deprecated v1 field — use `amount` instead. Kept for backwards compatibility with v1 data. */
|
|
95
|
-
maxAmountRequired?: string;
|
|
96
|
-
/** Token address */
|
|
97
|
-
asset: string;
|
|
98
|
-
/** Seller's address to receive payment */
|
|
99
|
-
payTo: string;
|
|
100
|
-
/** Maximum seconds until payment expires */
|
|
101
|
-
maxTimeoutSeconds: number;
|
|
102
|
-
/** Chain-specific extra data */
|
|
103
|
-
extra?: AcceptsExtra;
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Full PaymentRequired structure (sent in PAYMENT-REQUIRED header)
|
|
107
|
-
*/
|
|
108
|
-
interface PaymentRequired {
|
|
109
|
-
/** x402 version (always 2) */
|
|
110
|
-
x402Version: 2;
|
|
111
|
-
/** Resource being accessed */
|
|
112
|
-
resource: ResourceInfo;
|
|
113
|
-
/** Available payment options */
|
|
114
|
-
accepts: PaymentAccept[];
|
|
115
|
-
/** Optional error message */
|
|
116
|
-
error?: string;
|
|
117
|
-
/** Protocol extensions */
|
|
118
|
-
extensions?: Record<string, unknown>;
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* Response from /verify endpoint
|
|
122
|
-
*/
|
|
123
|
-
interface VerifyResponse {
|
|
124
|
-
/** Whether the payment is valid */
|
|
125
|
-
isValid: boolean;
|
|
126
|
-
/** Reason for invalidity (if invalid) */
|
|
127
|
-
invalidReason?: string;
|
|
128
|
-
/** Payer address */
|
|
129
|
-
payer?: string;
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* Response from /settle endpoint
|
|
133
|
-
*/
|
|
134
|
-
interface SettleResponse {
|
|
135
|
-
/** Whether settlement succeeded */
|
|
136
|
-
success: boolean;
|
|
137
|
-
/** Transaction signature/hash */
|
|
138
|
-
transaction?: string;
|
|
139
|
-
/** Network the payment was made on */
|
|
140
|
-
network: string;
|
|
141
|
-
/** Error reason (if failed) */
|
|
142
|
-
errorReason?: string;
|
|
143
|
-
/** Error code (if failed) */
|
|
144
|
-
errorCode?: string;
|
|
145
|
-
/** Payer address */
|
|
146
|
-
payer?: string;
|
|
147
|
-
/** Protocol extensions returned by the facilitator (e.g., sponsored-access recommendations) */
|
|
148
|
-
extensions?: Record<string, unknown>;
|
|
149
|
-
}
|
|
150
|
-
/**
|
|
151
|
-
* A single access pass tier offered by a seller
|
|
152
|
-
*/
|
|
153
|
-
interface AccessPassTier {
|
|
154
|
-
/** Tier ID (e.g., '1h', '24h') */
|
|
155
|
-
id: string;
|
|
156
|
-
/** Human-readable label (e.g., '1 hour') */
|
|
157
|
-
label: string;
|
|
158
|
-
/** Duration in seconds */
|
|
159
|
-
seconds: number;
|
|
160
|
-
/** Price in USD (e.g., '0.50') */
|
|
161
|
-
price: string;
|
|
162
|
-
/** Price in atomic units (e.g., '500000') */
|
|
163
|
-
priceAtomic: string;
|
|
164
|
-
}
|
|
165
|
-
/**
|
|
166
|
-
* Access pass info returned in X-ACCESS-PASS-TIERS header
|
|
167
|
-
*/
|
|
168
|
-
interface AccessPassInfo {
|
|
169
|
-
/** Available tiers (if tier-based pricing) */
|
|
170
|
-
tiers?: AccessPassTier[];
|
|
171
|
-
/** Rate per hour in USD (if custom duration pricing) */
|
|
172
|
-
ratePerHour?: string;
|
|
173
|
-
/** Pass issuer identifier */
|
|
174
|
-
issuer?: string;
|
|
175
|
-
}
|
|
176
|
-
/**
|
|
177
|
-
* JWT claims inside an access pass token
|
|
178
|
-
*/
|
|
179
|
-
interface AccessPassClaims {
|
|
180
|
-
/** Subject — always 'x402-access-pass' */
|
|
181
|
-
sub: string;
|
|
182
|
-
/** Tier ID or 'custom' */
|
|
183
|
-
tier: string;
|
|
184
|
-
/** Duration in seconds */
|
|
185
|
-
duration: number;
|
|
186
|
-
/** Issued at (unix seconds) */
|
|
187
|
-
iat: number;
|
|
188
|
-
/** Expires at (unix seconds) */
|
|
189
|
-
exp: number;
|
|
190
|
-
/** Payer wallet address */
|
|
191
|
-
payer: string;
|
|
192
|
-
/** Network used for payment */
|
|
193
|
-
network: string;
|
|
194
|
-
/** Issuer identifier */
|
|
195
|
-
iss: string;
|
|
196
|
-
}
|
|
197
|
-
/**
|
|
198
|
-
* Client-side access pass configuration
|
|
199
|
-
*/
|
|
200
|
-
interface AccessPassClientConfig {
|
|
201
|
-
/** Enable access pass mode (default: true when this config is present) */
|
|
202
|
-
enabled?: boolean;
|
|
203
|
-
/** Preferred tier ID (e.g., '1h') — pick this tier if available */
|
|
204
|
-
preferTier?: string;
|
|
205
|
-
/** Preferred custom duration in seconds (e.g., 3600) */
|
|
206
|
-
preferDuration?: number;
|
|
207
|
-
/** Maximum amount willing to spend in USD (e.g., '2.00') */
|
|
208
|
-
maxSpend?: string;
|
|
209
|
-
/** Auto-renew expired passes (default: true) */
|
|
210
|
-
autoRenew?: boolean;
|
|
211
|
-
}
|
|
212
|
-
/**
|
|
213
|
-
* SDK error codes
|
|
214
|
-
*/
|
|
215
|
-
type X402ErrorCode = 'missing_payment_required_header' | 'invalid_payment_required' | 'unsupported_network' | 'no_matching_payment_option' | 'missing_fee_payer' | 'missing_decimals' | 'missing_amount' | 'amount_exceeds_max' | 'insufficient_balance' | 'wallet_missing_sign_transaction' | 'wallet_not_connected' | 'wallet_disconnected' | 'user_rejected_signature' | 'transaction_build_failed' | 'payment_rejected' | 'rpc_timeout' | 'facilitator_timeout' | 'invalid_payment_signature' | 'facilitator_verify_failed' | 'facilitator_settle_failed' | 'facilitator_request_failed' | 'no_matching_requirement' | 'access_pass_expired' | 'access_pass_invalid' | 'access_pass_tier_not_found' | 'access_pass_exceeds_max_spend';
|
|
216
|
-
/**
|
|
217
|
-
* Custom error class for x402 operations
|
|
218
|
-
*/
|
|
219
|
-
declare class X402Error extends Error {
|
|
220
|
-
/** Error code for programmatic handling */
|
|
221
|
-
code: X402ErrorCode;
|
|
222
|
-
/** Additional error details */
|
|
223
|
-
details?: unknown;
|
|
224
|
-
constructor(code: X402ErrorCode, message: string, details?: unknown);
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
export { type AccessPassClientConfig as A, type PaymentAccept as P, type SettleResponse as S, type VerifyResponse as V, X402Error as X, type AccessPassTier as a, type AccessPassInfo as b, type PayToProvider as c, type PaymentRequired as d, type PayToContext as e, type PayToProviderDefaults as f, type AccessPassClaims as g };
|