@wtflabs/x402 0.0.1-beta.0 → 0.0.1-beta.10

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 (84) hide show
  1. package/dist/cjs/client/index.d.ts +1 -1
  2. package/dist/cjs/client/index.js +7 -2
  3. package/dist/cjs/client/index.js.map +1 -1
  4. package/dist/cjs/facilitator/index.d.ts +1 -1
  5. package/dist/cjs/facilitator/index.js +444 -87
  6. package/dist/cjs/facilitator/index.js.map +1 -1
  7. package/dist/cjs/index.d.ts +1 -1
  8. package/dist/cjs/index.js +445 -88
  9. package/dist/cjs/index.js.map +1 -1
  10. package/dist/cjs/{middleware-Brgsx32F.d.ts → middleware-nzDe-TDJ.d.ts} +1 -1
  11. package/dist/cjs/paywall/index.d.ts +1 -1
  12. package/dist/cjs/schemes/index.d.ts +81 -9
  13. package/dist/cjs/schemes/index.js +633 -100
  14. package/dist/cjs/schemes/index.js.map +1 -1
  15. package/dist/cjs/shared/index.d.ts +2 -2
  16. package/dist/cjs/shared/index.js +6 -1
  17. package/dist/cjs/shared/index.js.map +1 -1
  18. package/dist/cjs/types/index.d.ts +93 -4
  19. package/dist/cjs/types/index.js +64 -1
  20. package/dist/cjs/types/index.js.map +1 -1
  21. package/dist/cjs/verify/index.d.ts +2 -2
  22. package/dist/cjs/verify/index.js +6 -1
  23. package/dist/cjs/verify/index.js.map +1 -1
  24. package/dist/cjs/{x402Specs-CYq5tSY1.d.ts → x402Specs-BtRXj67U.d.ts} +43 -10
  25. package/dist/esm/{chunk-34YNR4LY.mjs → chunk-KABV25HJ.mjs} +3 -3
  26. package/dist/esm/{chunk-LGXWNXCO.mjs → chunk-LXLCF4IW.mjs} +3 -3
  27. package/dist/esm/{chunk-UCBE7FDY.mjs → chunk-NPWDNT2P.mjs} +67 -2
  28. package/dist/esm/chunk-NPWDNT2P.mjs.map +1 -0
  29. package/dist/esm/{chunk-RX2JKK4O.mjs → chunk-VTLJOZXM.mjs} +3 -3
  30. package/dist/esm/chunk-VTLJOZXM.mjs.map +1 -0
  31. package/dist/esm/{chunk-57UEJN5U.mjs → chunk-XGQBEMP7.mjs} +589 -103
  32. package/dist/esm/chunk-XGQBEMP7.mjs.map +1 -0
  33. package/dist/esm/client/index.d.mts +64 -0
  34. package/dist/esm/client/index.mjs +3 -3
  35. package/dist/esm/config-CFBSAuxW.d.mts +10 -0
  36. package/dist/esm/config-Dfuvno71.d.mts +19 -0
  37. package/dist/esm/facilitator/index.d.mts +42 -0
  38. package/dist/esm/facilitator/index.mjs +4 -4
  39. package/dist/esm/index.d.mts +16 -0
  40. package/dist/esm/index.mjs +5 -5
  41. package/dist/{cjs/middleware-6_1ApcJn.d.ts → esm/middleware-DSDucaQ5.d.mts} +3 -3
  42. package/dist/{cjs/network-RtNddYQk.d.ts → esm/network-FrFmmiyj.d.mts} +3 -3
  43. package/dist/esm/paywall/index.d.mts +30 -0
  44. package/dist/{cjs/rpc-Ca8eHCWz.d.ts → esm/rpc-DyKXu0SX.d.mts} +1 -1
  45. package/dist/esm/schemes/index.d.mts +605 -0
  46. package/dist/esm/schemes/index.mjs +3 -3
  47. package/dist/esm/shared/evm/index.d.mts +71 -0
  48. package/dist/esm/shared/index.d.mts +182 -0
  49. package/dist/esm/shared/index.mjs +1 -1
  50. package/dist/esm/types/index.d.mts +1604 -0
  51. package/dist/esm/types/index.mjs +1 -1
  52. package/dist/esm/verify/index.d.mts +7 -0
  53. package/dist/esm/verify/index.mjs +1 -1
  54. package/dist/esm/wallet-BTqCm9Zp.d.mts +27 -0
  55. package/dist/esm/wallet-KorGgbAj.d.mts +88 -0
  56. package/dist/{cjs/wallet-BRWfOM5D.d.ts → esm/wallet-SJKJpUgQ.d.mts} +54 -40
  57. package/dist/{cjs/x402Specs-qUBCpcuz.d.ts → esm/x402Specs-BtRXj67U.d.mts} +73 -10
  58. package/package.json +15 -15
  59. package/dist/cjs/middleware-B_ewwsQp.d.ts +0 -93
  60. package/dist/cjs/middleware-BwfW7mAs.d.ts +0 -93
  61. package/dist/cjs/middleware-CQb61c1k.d.ts +0 -93
  62. package/dist/cjs/middleware-DB9lqy9f.d.ts +0 -93
  63. package/dist/cjs/middleware-DcHctwQV.d.ts +0 -93
  64. package/dist/cjs/middleware-De0jD3Bp.d.ts +0 -93
  65. package/dist/cjs/middleware-HoFOmpgv.d.ts +0 -93
  66. package/dist/cjs/middleware-Y8AiAfYw.d.ts +0 -93
  67. package/dist/cjs/middleware-pnres9YM.d.ts +0 -93
  68. package/dist/cjs/wallet-BYRAGtOB.d.ts +0 -153
  69. package/dist/cjs/wallet-BmEtlgEf.d.ts +0 -48
  70. package/dist/cjs/wallet-CNOAmyZ6.d.ts +0 -48
  71. package/dist/cjs/wallet-D1SoxFTw.d.ts +0 -48
  72. package/dist/cjs/wallet-SJ-hbjm9.d.ts +0 -153
  73. package/dist/cjs/wallet-ecnda4Aj.d.ts +0 -48
  74. package/dist/cjs/wallet-gP8Qoi-c.d.ts +0 -74
  75. package/dist/cjs/x402Specs-B7InXo2L.d.ts +0 -1065
  76. package/dist/cjs/x402Specs-BLH3j34O.d.ts +0 -1696
  77. package/dist/cjs/x402Specs-C7LipAZg.d.ts +0 -1715
  78. package/dist/cjs/x402Specs-CeajqonG.d.ts +0 -1696
  79. package/dist/cjs/x402Specs-qMujgEV5.d.ts +0 -1715
  80. package/dist/esm/chunk-57UEJN5U.mjs.map +0 -1
  81. package/dist/esm/chunk-RX2JKK4O.mjs.map +0 -1
  82. package/dist/esm/chunk-UCBE7FDY.mjs.map +0 -1
  83. /package/dist/esm/{chunk-34YNR4LY.mjs.map → chunk-KABV25HJ.mjs.map} +0 -0
  84. /package/dist/esm/{chunk-LGXWNXCO.mjs.map → chunk-LXLCF4IW.mjs.map} +0 -0
@@ -0,0 +1,605 @@
1
+ import { Address, Transport, Chain, LocalAccount, Hex, Account, PublicClient } from 'viem';
2
+ import { S as SignerWallet, C as ConnectedClient } from '../wallet-SJKJpUgQ.mjs';
3
+ import { P as PaymentRequirements, p as UnsignedEip3009PaymentPayload, o as Eip3009PaymentPayload, e as ExactEvmPayloadAuthorization, J as VerifyResponse, S as SettleResponse, r as UnsignedPermitPaymentPayload, q as PermitPaymentPayload, g as PermitEvmPayloadAuthorization, u as UnsignedPermit2PaymentPayload, t as Permit2PaymentPayload, i as Permit2EvmPayloadAuthorization, a as PaymentPayload, b as ErrorReasons, E as ExactSvmPayload } from '../x402Specs-BtRXj67U.mjs';
4
+ import { X as X402Config } from '../config-Dfuvno71.mjs';
5
+ import { KeyPairSigner, signTransaction, RpcDevnet, SolanaRpcApiDevnet, RpcMainnet, SolanaRpcApiMainnet, SendTransactionApi, CompilableTransactionMessage, Instruction, AccountLookupMeta, AccountMeta } from '@solana/kit';
6
+ import { b as getRpcSubscriptions } from '../rpc-DyKXu0SX.mjs';
7
+ import * as _solana_program_token from '@solana-program/token';
8
+ import { parseTransferCheckedInstruction } from '@solana-program/token-2022';
9
+ import 'viem/chains';
10
+ import 'zod';
11
+ import '../network-FrFmmiyj.mjs';
12
+
13
+ /**
14
+ * Prepares an unsigned EIP-3009 payment header with the given sender address and payment requirements.
15
+ *
16
+ * @param from - The sender's address from which the payment will be made
17
+ * @param x402Version - The version of the X402 protocol to use
18
+ * @param paymentRequirements - The payment requirements containing scheme and network information
19
+ * @returns An unsigned EIP-3009 payment payload containing authorization details
20
+ */
21
+ declare function preparePaymentHeader$2(from: Address, x402Version: number, paymentRequirements: PaymentRequirements): UnsignedEip3009PaymentPayload;
22
+ /**
23
+ * Signs an EIP-3009 payment header using the provided client and payment requirements.
24
+ *
25
+ * @param client - The signer wallet instance used to sign the payment header
26
+ * @param paymentRequirements - The payment requirements containing scheme and network information
27
+ * @param unsignedPaymentHeader - The unsigned EIP-3009 payment payload to be signed
28
+ * @returns A promise that resolves to the signed EIP-3009 payment payload
29
+ */
30
+ declare function signPaymentHeader$2<transport extends Transport, chain extends Chain>(client: SignerWallet<chain, transport> | LocalAccount, paymentRequirements: PaymentRequirements, unsignedPaymentHeader: UnsignedEip3009PaymentPayload): Promise<Eip3009PaymentPayload>;
31
+ /**
32
+ * Creates a complete EIP-3009 payment payload by preparing and signing a payment header.
33
+ *
34
+ * @param client - The signer wallet instance used to create and sign the payment
35
+ * @param x402Version - The version of the X402 protocol to use
36
+ * @param paymentRequirements - The payment requirements containing scheme and network information
37
+ * @returns A promise that resolves to the complete signed EIP-3009 payment payload
38
+ */
39
+ declare function createPayment$2<transport extends Transport, chain extends Chain>(client: SignerWallet<chain, transport> | LocalAccount, x402Version: number, paymentRequirements: PaymentRequirements): Promise<Eip3009PaymentPayload>;
40
+ /**
41
+ * Creates and encodes an EIP-3009 payment header for the given client and payment requirements.
42
+ *
43
+ * @param client - The signer wallet instance used to create the payment header
44
+ * @param x402Version - The version of the X402 protocol to use
45
+ * @param paymentRequirements - The payment requirements containing scheme and network information
46
+ * @returns A promise that resolves to the encoded EIP-3009 payment header string
47
+ */
48
+ declare function createPaymentHeader$3(client: SignerWallet | LocalAccount, x402Version: number, paymentRequirements: PaymentRequirements): Promise<string>;
49
+
50
+ /**
51
+ * Signs an EIP-3009 authorization for USDC transfer
52
+ *
53
+ * @param walletClient - The wallet client that will sign the authorization
54
+ * @param params - The authorization parameters containing transfer details
55
+ * @param params.from - The address tokens will be transferred from
56
+ * @param params.to - The address tokens will be transferred to
57
+ * @param params.value - The amount of USDC tokens to transfer (in base units)
58
+ * @param params.validAfter - Unix timestamp after which the authorization becomes valid
59
+ * @param params.validBefore - Unix timestamp before which the authorization is valid
60
+ * @param params.nonce - Random 32-byte nonce to prevent replay attacks
61
+ * @param paymentRequirements - The payment requirements containing asset and network information
62
+ * @param paymentRequirements.asset - The address of the USDC contract
63
+ * @param paymentRequirements.network - The network where the USDC contract exists
64
+ * @param paymentRequirements.extra - The extra information containing the name and version of the ERC20 contract
65
+ * @returns The signature for the authorization
66
+ */
67
+ declare function signAuthorization<transport extends Transport, chain extends Chain>(walletClient: SignerWallet<chain, transport> | LocalAccount, { from, to, value, validAfter, validBefore, nonce }: ExactEvmPayloadAuthorization, { asset, network, extra }: PaymentRequirements): Promise<{
68
+ signature: Hex;
69
+ }>;
70
+ /**
71
+ * Generates a random 32-byte nonce for use in authorization signatures
72
+ *
73
+ * @returns A random 32-byte nonce as a hex string
74
+ */
75
+ declare function createNonce(): Hex;
76
+
77
+ /**
78
+ * Verifies an EIP-3009 payment payload against the required payment details
79
+ *
80
+ * This function performs several verification steps:
81
+ * - Verifies protocol version compatibility
82
+ * - Validates the permit signature
83
+ * - Confirms USDC contract address is correct for the chain
84
+ * - Checks permit deadline is sufficiently in the future
85
+ * - Verifies client has sufficient USDC balance
86
+ * - Ensures payment amount meets required minimum
87
+ *
88
+ * @param client - The public client used for blockchain interactions
89
+ * @param payload - The signed payment payload containing transfer parameters and signature
90
+ * @param paymentRequirements - The payment requirements that the payload must satisfy
91
+ * @returns A ValidPaymentRequest indicating if the payment is valid and any invalidation reason
92
+ */
93
+ declare function verify$4<transport extends Transport, chain extends Chain, account extends Account | undefined>(client: ConnectedClient<transport, chain, account>, payload: Eip3009PaymentPayload, paymentRequirements: PaymentRequirements): Promise<VerifyResponse>;
94
+ /**
95
+ * Settles an EIP-3009 payment by executing a USDC transferWithAuthorization transaction
96
+ *
97
+ * This function executes the actual USDC transfer using the signed authorization from the user.
98
+ * The facilitator wallet submits the transaction but does not need to hold or transfer any tokens itself.
99
+ *
100
+ * @param wallet - The facilitator wallet that will submit the transaction
101
+ * @param paymentPayload - The signed payment payload containing the transfer parameters and signature
102
+ * @param paymentRequirements - The original payment details that were used to create the payload
103
+ * @returns A PaymentExecutionResponse containing the transaction status and hash
104
+ */
105
+ declare function settle$4<transport extends Transport, chain extends Chain>(wallet: SignerWallet<chain, transport>, paymentPayload: Eip3009PaymentPayload, paymentRequirements: PaymentRequirements): Promise<SettleResponse>;
106
+
107
+ declare const index$5_createNonce: typeof createNonce;
108
+ declare const index$5_signAuthorization: typeof signAuthorization;
109
+ declare namespace index$5 {
110
+ export { index$5_createNonce as createNonce, createPayment$2 as createPayment, createPaymentHeader$3 as createPaymentHeader, preparePaymentHeader$2 as preparePaymentHeader, settle$4 as settle, index$5_signAuthorization as signAuthorization, signPaymentHeader$2 as signPaymentHeader, verify$4 as verify };
111
+ }
112
+
113
+ /**
114
+ * Prepares an unsigned EIP-2612 Permit payment header
115
+ *
116
+ * @param from - The token owner's address
117
+ * @param x402Version - The version of the X402 protocol to use
118
+ * @param paymentRequirements - The payment requirements containing scheme and network information
119
+ * @returns An unsigned Permit payment payload containing permit authorization details
120
+ */
121
+ declare function preparePaymentHeader$1(from: Address, x402Version: number, paymentRequirements: PaymentRequirements): UnsignedPermitPaymentPayload;
122
+ /**
123
+ * Signs a Permit payment header using the provided client and payment requirements.
124
+ *
125
+ * @param client - The signer wallet instance used to sign the permit
126
+ * @param paymentRequirements - The payment requirements containing scheme and network information
127
+ * @param unsignedPaymentHeader - The unsigned Permit payment payload to be signed
128
+ * @returns A promise that resolves to the signed Permit payment payload
129
+ */
130
+ declare function signPaymentHeader$1<transport extends Transport, chain extends Chain>(client: SignerWallet<chain, transport> | LocalAccount, paymentRequirements: PaymentRequirements, unsignedPaymentHeader: UnsignedPermitPaymentPayload): Promise<PermitPaymentPayload>;
131
+ /**
132
+ * Creates a complete Permit payment payload by preparing and signing a payment header.
133
+ *
134
+ * @param client - The signer wallet instance used to create and sign the payment
135
+ * @param x402Version - The version of the X402 protocol to use
136
+ * @param paymentRequirements - The payment requirements containing scheme and network information
137
+ * @returns A promise that resolves to the complete signed Permit payment payload
138
+ */
139
+ declare function createPayment$1<transport extends Transport, chain extends Chain>(client: SignerWallet<chain, transport> | LocalAccount, x402Version: number, paymentRequirements: PaymentRequirements): Promise<PermitPaymentPayload>;
140
+ /**
141
+ * Creates and encodes a Permit payment header for the given client and payment requirements.
142
+ *
143
+ * @param client - The signer wallet instance used to create the payment header
144
+ * @param x402Version - The version of the X402 protocol to use
145
+ * @param paymentRequirements - The payment requirements containing scheme and network information
146
+ * @returns A promise that resolves to the encoded payment header string
147
+ */
148
+ declare function createPaymentHeader$2(client: SignerWallet | LocalAccount, x402Version: number, paymentRequirements: PaymentRequirements): Promise<string>;
149
+
150
+ /**
151
+ * Signs an EIP-2612 Permit authorization for ERC20 approval
152
+ *
153
+ * @param walletClient - The wallet client that will sign the permit
154
+ * @param params - The permit parameters
155
+ * @param params.owner - The address of the token owner
156
+ * @param params.spender - The address authorized to spend tokens
157
+ * @param params.value - The amount of tokens to approve (in base units)
158
+ * @param params.deadline - Unix timestamp after which the permit is no longer valid
159
+ * @param paymentRequirements - The payment requirements containing asset and network information
160
+ * @param paymentRequirements.asset - The address of the ERC20 token contract
161
+ * @param paymentRequirements.network - The network where the token exists
162
+ * @returns The signature and nonce for the permit
163
+ */
164
+ declare function signPermit<transport extends Transport, chain extends Chain>(walletClient: SignerWallet<chain, transport> | LocalAccount, { owner, spender, value, deadline }: Omit<PermitEvmPayloadAuthorization, "nonce">, { asset, network }: PaymentRequirements): Promise<{
165
+ signature: Hex;
166
+ nonce: string;
167
+ }>;
168
+ /**
169
+ * Helper function to split signature into v, r, s components
170
+ * Required for calling the permit function on-chain
171
+ *
172
+ * @param signature - The signature to split
173
+ * @returns The v, r, s components of the signature
174
+ */
175
+ declare function splitSignature(signature: Hex): {
176
+ v: number;
177
+ r: Hex;
178
+ s: Hex;
179
+ };
180
+
181
+ /**
182
+ * Verifies an EIP-2612 Permit payment payload
183
+ *
184
+ * @param client - The public client used for blockchain interactions
185
+ * @param payload - The signed payment payload containing permit parameters and signature
186
+ * @param paymentRequirements - The payment requirements that the payload must satisfy
187
+ * @returns A VerifyResponse indicating if the payment is valid and any invalidation reason
188
+ */
189
+ declare function verify$3<transport extends Transport, chain extends Chain, account extends Account | undefined>(client: ConnectedClient<transport, chain, account>, payload: PermitPaymentPayload, paymentRequirements: PaymentRequirements): Promise<VerifyResponse>;
190
+ /**
191
+ * Settles an EIP-2612 Permit payment by calling permit() then transferFrom()
192
+ *
193
+ * @param wallet - The facilitator wallet that will execute the permit and transfer
194
+ * @param paymentPayload - The signed payment payload containing permit parameters and signature
195
+ * @param paymentRequirements - The payment requirements
196
+ * @returns A SettleResponse containing the transaction status and hash
197
+ */
198
+ declare function settle$3<transport extends Transport, chain extends Chain>(wallet: SignerWallet<chain, transport>, paymentPayload: PermitPaymentPayload, paymentRequirements: PaymentRequirements): Promise<SettleResponse>;
199
+
200
+ declare const index$4_signPermit: typeof signPermit;
201
+ declare const index$4_splitSignature: typeof splitSignature;
202
+ declare namespace index$4 {
203
+ export { createPayment$1 as createPayment, createPaymentHeader$2 as createPaymentHeader, preparePaymentHeader$1 as preparePaymentHeader, settle$3 as settle, signPaymentHeader$1 as signPaymentHeader, index$4_signPermit as signPermit, index$4_splitSignature as splitSignature, verify$3 as verify };
204
+ }
205
+
206
+ /**
207
+ * Prepares an unsigned Permit2 payment header with witness support
208
+ *
209
+ * By default, this function enables witness mode which binds the recipient address
210
+ * to the signature, preventing the facilitator from changing the payment destination.
211
+ *
212
+ * @param from - The token owner's address
213
+ * @param x402Version - The version of the X402 protocol to use
214
+ * @param paymentRequirements - The payment requirements containing scheme and network information
215
+ * @returns An unsigned Permit2 payment payload containing permit2 authorization details with witness
216
+ */
217
+ declare function preparePaymentHeader(from: Address, x402Version: number, paymentRequirements: PaymentRequirements): UnsignedPermit2PaymentPayload;
218
+ /**
219
+ * Signs a Permit2 payment header using the provided client and payment requirements.
220
+ *
221
+ * Supports both witness and non-witness modes based on the presence of the `to` field
222
+ * in the unsigned payment header.
223
+ *
224
+ * @param client - The signer wallet instance used to sign the permit2
225
+ * @param paymentRequirements - The payment requirements containing scheme and network information
226
+ * @param unsignedPaymentHeader - The unsigned Permit2 payment payload to be signed
227
+ * @returns A promise that resolves to the signed Permit2 payment payload
228
+ */
229
+ declare function signPaymentHeader<transport extends Transport, chain extends Chain>(client: SignerWallet<chain, transport> | LocalAccount, paymentRequirements: PaymentRequirements, unsignedPaymentHeader: UnsignedPermit2PaymentPayload): Promise<Permit2PaymentPayload>;
230
+ /**
231
+ * Creates a complete Permit2 payment payload by preparing and signing a payment header.
232
+ *
233
+ * @param client - The signer wallet instance used to create and sign the payment
234
+ * @param x402Version - The version of the X402 protocol to use
235
+ * @param paymentRequirements - The payment requirements containing scheme and network information
236
+ * @returns A promise that resolves to the complete signed Permit2 payment payload
237
+ */
238
+ declare function createPayment<transport extends Transport, chain extends Chain>(client: SignerWallet<chain, transport> | LocalAccount, x402Version: number, paymentRequirements: PaymentRequirements): Promise<Permit2PaymentPayload>;
239
+ /**
240
+ * Creates and encodes a Permit2 payment header for the given client and payment requirements.
241
+ *
242
+ * @param client - The signer wallet instance used to create the payment header
243
+ * @param x402Version - The version of the X402 protocol to use
244
+ * @param paymentRequirements - The payment requirements containing scheme and network information
245
+ * @returns A promise that resolves to the encoded payment header string
246
+ */
247
+ declare function createPaymentHeader$1(client: SignerWallet | LocalAccount, x402Version: number, paymentRequirements: PaymentRequirements): Promise<string>;
248
+
249
+ /**
250
+ * Signs a Permit2 authorization (PermitTransferFrom or PermitWitnessTransferFrom)
251
+ *
252
+ * Automatically detects witness mode based on the presence of the `to` field.
253
+ * - If `to` is provided: Uses PermitWitnessTransferFrom (binds recipient to signature)
254
+ * - If `to` is omitted: Uses PermitTransferFrom (legacy mode)
255
+ *
256
+ * @param walletClient - The wallet client that will sign the permit
257
+ * @param params - The permit2 parameters
258
+ * @param params.owner - The address of the token owner
259
+ * @param params.spender - The address authorized to transfer tokens
260
+ * @param params.token - The address of the token to transfer
261
+ * @param params.amount - The amount of tokens to transfer (in base units)
262
+ * @param params.deadline - Unix timestamp after which the permit is no longer valid
263
+ * @param params.to - Optional recipient address for witness mode
264
+ * @param paymentRequirements - The payment requirements containing network information
265
+ * @param paymentRequirements.network - The network where the token exists
266
+ * @returns The signature and nonce for the permit2
267
+ */
268
+ declare function signPermit2<transport extends Transport, chain extends Chain>(walletClient: SignerWallet<chain, transport> | LocalAccount, { owner, spender, token, amount, deadline, to }: Omit<Permit2EvmPayloadAuthorization, "nonce">, { network }: PaymentRequirements): Promise<{
269
+ signature: Hex;
270
+ nonce: string;
271
+ }>;
272
+ /**
273
+ * Generates a unique nonce for Permit2 SignatureTransfer
274
+ * Uses timestamp-based approach with nonceBitmap verification
275
+ *
276
+ * @param walletClient - The wallet client used to check nonce bitmap
277
+ * @param ownerAddress - The address of the token owner
278
+ * @returns A unique nonce for the permit2 authorization
279
+ */
280
+ declare function createPermit2Nonce<transport extends Transport, chain extends Chain>(walletClient: SignerWallet<chain, transport> | LocalAccount, ownerAddress: `0x${string}`): Promise<bigint>;
281
+
282
+ /**
283
+ * Verifies a Permit2 payment payload (with or without witness)
284
+ *
285
+ * Supports both witness and non-witness modes:
286
+ * - Witness mode: Verifies that the recipient address is bound to the signature
287
+ * - Non-witness mode: Uses standard PermitTransferFrom verification
288
+ *
289
+ * @param client - The public client used for blockchain interactions
290
+ * @param payload - The signed payment payload containing permit2 parameters and signature
291
+ * @param paymentRequirements - The payment requirements that the payload must satisfy
292
+ * @returns A VerifyResponse indicating if the payment is valid and any invalidation reason
293
+ */
294
+ declare function verify$2<transport extends Transport, chain extends Chain, account extends Account | undefined>(client: ConnectedClient<transport, chain, account>, payload: Permit2PaymentPayload, paymentRequirements: PaymentRequirements): Promise<VerifyResponse>;
295
+ /**
296
+ * Settles a Permit2 payment by calling permitTransferFrom() or permitWitnessTransferFrom()
297
+ *
298
+ * Automatically selects the appropriate function based on whether the payment includes
299
+ * a witness (recipient address binding).
300
+ *
301
+ * @param wallet - The facilitator wallet that will execute the permit transfer
302
+ * @param paymentPayload - The signed payment payload containing permit2 parameters and signature
303
+ * @param paymentRequirements - The payment requirements
304
+ * @returns A SettleResponse containing the transaction status and hash
305
+ */
306
+ declare function settle$2<transport extends Transport, chain extends Chain>(wallet: SignerWallet<chain, transport>, paymentPayload: Permit2PaymentPayload, paymentRequirements: PaymentRequirements): Promise<SettleResponse>;
307
+
308
+ declare const index$3_createPayment: typeof createPayment;
309
+ declare const index$3_createPermit2Nonce: typeof createPermit2Nonce;
310
+ declare const index$3_preparePaymentHeader: typeof preparePaymentHeader;
311
+ declare const index$3_signPaymentHeader: typeof signPaymentHeader;
312
+ declare const index$3_signPermit2: typeof signPermit2;
313
+ declare namespace index$3 {
314
+ export { index$3_createPayment as createPayment, createPaymentHeader$1 as createPaymentHeader, index$3_createPermit2Nonce as createPermit2Nonce, index$3_preparePaymentHeader as preparePaymentHeader, settle$2 as settle, index$3_signPaymentHeader as signPaymentHeader, index$3_signPermit2 as signPermit2, verify$2 as verify };
315
+ }
316
+
317
+ /**
318
+ * Encodes a payment payload into a base64 string, ensuring bigint values are properly stringified
319
+ *
320
+ * @param payment - The payment payload to encode
321
+ * @returns A base64 encoded string representation of the payment payload
322
+ */
323
+ declare function encodePayment(payment: PaymentPayload): string;
324
+ /**
325
+ * Decodes a base64 encoded payment string back into a PaymentPayload object
326
+ *
327
+ * @param payment - The base64 encoded payment string to decode
328
+ * @returns The decoded and validated PaymentPayload object
329
+ */
330
+ declare function decodePayment(payment: string): PaymentPayload;
331
+
332
+ /**
333
+ * Token 信息
334
+ */
335
+ interface TokenInfo {
336
+ name: string;
337
+ version: string;
338
+ }
339
+ /**
340
+ * 支持的支付方式
341
+ */
342
+ type PaymentMethod = "eip3009" | "permit" | "permit2" | "permit2-witness";
343
+ /**
344
+ * 检测结果
345
+ */
346
+ interface TokenPaymentCapabilities {
347
+ address: string;
348
+ supportedMethods: PaymentMethod[];
349
+ details: {
350
+ hasEIP3009: boolean;
351
+ hasPermit: boolean;
352
+ hasPermit2Approval: boolean;
353
+ };
354
+ }
355
+ /**
356
+ * detect the payment methods supported by the token
357
+ *
358
+ * @param tokenAddress - token address
359
+ * @param client - viem PublicClient
360
+ * @returns the payment capabilities of the token
361
+ */
362
+ declare function detectTokenPaymentMethods(tokenAddress: string, client: PublicClient): Promise<TokenPaymentCapabilities>;
363
+ /**
364
+ * get the recommended payment method for the token
365
+ *
366
+ * @param tokenAddress - token address
367
+ * @param client - viem PublicClient
368
+ * @returns the recommended payment method
369
+ */
370
+ declare function getRecommendedPaymentMethod(tokenAddress: string, client: PublicClient): Promise<"eip3009" | "permit" | "permit2" | null>;
371
+ /**
372
+ * get the name and version information of the token (for EIP-712 signing)
373
+ *
374
+ * @param tokenAddress - token address
375
+ * @param client - viem PublicClient
376
+ * @returns the name and version information of the token
377
+ */
378
+ declare function getTokenInfo(tokenAddress: string, client: PublicClient): Promise<TokenInfo>;
379
+
380
+ /**
381
+ * Unified verify function that routes to the appropriate authorization type handler
382
+ *
383
+ * @param client - The public client used for blockchain interactions
384
+ * @param payload - The signed payment payload
385
+ * @param paymentRequirements - The payment requirements that the payload must satisfy
386
+ * @returns A VerifyResponse indicating if the payment is valid
387
+ */
388
+ declare function verify$1<transport extends Transport, chain extends Chain, account extends Account | undefined>(client: ConnectedClient<transport, chain, account>, payload: PaymentPayload, paymentRequirements: PaymentRequirements): Promise<VerifyResponse>;
389
+ /**
390
+ * Unified settle function that routes to the appropriate authorization type handler
391
+ *
392
+ * @param wallet - The facilitator wallet that will execute the transaction
393
+ * @param paymentPayload - The signed payment payload
394
+ * @param paymentRequirements - The payment requirements
395
+ * @returns A SettleResponse containing the transaction status and hash
396
+ */
397
+ declare function settle$1<transport extends Transport, chain extends Chain>(wallet: SignerWallet<chain, transport>, paymentPayload: PaymentPayload, paymentRequirements: PaymentRequirements): Promise<SettleResponse>;
398
+
399
+ type index$2_PaymentMethod = PaymentMethod;
400
+ type index$2_TokenInfo = TokenInfo;
401
+ type index$2_TokenPaymentCapabilities = TokenPaymentCapabilities;
402
+ declare const index$2_decodePayment: typeof decodePayment;
403
+ declare const index$2_detectTokenPaymentMethods: typeof detectTokenPaymentMethods;
404
+ declare const index$2_encodePayment: typeof encodePayment;
405
+ declare const index$2_getRecommendedPaymentMethod: typeof getRecommendedPaymentMethod;
406
+ declare const index$2_getTokenInfo: typeof getTokenInfo;
407
+ declare namespace index$2 {
408
+ export { type index$2_PaymentMethod as PaymentMethod, type index$2_TokenInfo as TokenInfo, type index$2_TokenPaymentCapabilities as TokenPaymentCapabilities, index$2_decodePayment as decodePayment, index$2_detectTokenPaymentMethods as detectTokenPaymentMethods, index$5 as eip3009, index$2_encodePayment as encodePayment, index$2_getRecommendedPaymentMethod as getRecommendedPaymentMethod, index$2_getTokenInfo as getTokenInfo, index$4 as permit, index$3 as permit2, settle$1 as settle, verify$1 as verify };
409
+ }
410
+
411
+ /**
412
+ * Settle the payment payload against the payment requirements.
413
+ * TODO: handle durable nonce lifetime transactions
414
+ *
415
+ * @param signer - The signer that will sign the transaction
416
+ * @param payload - The payment payload to settle
417
+ * @param paymentRequirements - The payment requirements to settle against
418
+ * @param config - Optional configuration for X402 operations (e.g., custom RPC URLs)
419
+ * @returns A SettleResponse indicating if the payment is settled and any error reason
420
+ */
421
+ declare function settle(signer: KeyPairSigner, payload: PaymentPayload, paymentRequirements: PaymentRequirements, config?: X402Config): Promise<SettleResponse>;
422
+ /**
423
+ * Send a signed transaction to the RPC.
424
+ * TODO: should this be moved to the shared/svm/rpc.ts file?
425
+ *
426
+ * @param signedTransaction - The signed transaction to send
427
+ * @param rpc - The RPC client to use to send the transaction
428
+ * @param sendTxConfig - The configuration for the transaction send
429
+ * @returns The signature of the sent transaction
430
+ */
431
+ declare function sendSignedTransaction(signedTransaction: Awaited<ReturnType<typeof signTransaction>>, rpc: RpcDevnet<SolanaRpcApiDevnet> | RpcMainnet<SolanaRpcApiMainnet>, sendTxConfig?: Parameters<SendTransactionApi["sendTransaction"]>[1]): Promise<string>;
432
+ /**
433
+ * Confirm a signed transaction.
434
+ * TODO: can some of this be refactored to be moved to the shared/svm/rpc.ts file?
435
+ * TODO: should the commitment and the timeout be passed in as parameters?
436
+ *
437
+ * @param signedTransaction - The signed transaction to confirm
438
+ * @param rpc - The RPC client to use to confirm the transaction
439
+ * @param rpcSubscriptions - The RPC subscriptions to use to confirm the transaction
440
+ * @returns The success and signature of the confirmed transaction
441
+ */
442
+ declare function confirmSignedTransaction(signedTransaction: Awaited<ReturnType<typeof signTransaction>>, rpc: RpcDevnet<SolanaRpcApiDevnet> | RpcMainnet<SolanaRpcApiMainnet>, rpcSubscriptions: ReturnType<typeof getRpcSubscriptions>): Promise<{
443
+ success: boolean;
444
+ errorReason?: (typeof ErrorReasons)[number];
445
+ signature: string;
446
+ }>;
447
+ /**
448
+ * Send and confirm a signed transaction.
449
+ *
450
+ * @param signedTransaction - The signed transaction to send and confirm
451
+ * @param rpc - The RPC client to use to send and confirm the transaction
452
+ * @param rpcSubscriptions - The RPC subscriptions to use to send and confirm the transaction
453
+ * @returns The success and signature of the confirmed transaction
454
+ */
455
+ declare function sendAndConfirmSignedTransaction(signedTransaction: Awaited<ReturnType<typeof signTransaction>>, rpc: RpcDevnet<SolanaRpcApiDevnet> | RpcMainnet<SolanaRpcApiMainnet>, rpcSubscriptions: ReturnType<typeof getRpcSubscriptions>): Promise<{
456
+ success: boolean;
457
+ errorReason?: (typeof ErrorReasons)[number];
458
+ signature: string;
459
+ }>;
460
+
461
+ /**
462
+ * Verify the payment payload against the payment requirements.
463
+ *
464
+ * @param signer - The signer that will sign and simulate the transaction
465
+ * @param payload - The payment payload to verify
466
+ * @param paymentRequirements - The payment requirements to verify against
467
+ * @param config - Optional configuration for X402 operations (e.g., custom RPC URLs)
468
+ * @returns A VerifyResponse indicating if the payment is valid and any invalidation reason
469
+ */
470
+ declare function verify(signer: KeyPairSigner, payload: PaymentPayload, paymentRequirements: PaymentRequirements, config?: X402Config): Promise<VerifyResponse>;
471
+ /**
472
+ * Verify that the scheme and network are supported.
473
+ *
474
+ * @param payload - The payment payload to verify
475
+ * @param paymentRequirements - The payment requirements to verify against
476
+ */
477
+ declare function verifySchemesAndNetworks(payload: PaymentPayload, paymentRequirements: PaymentRequirements): void;
478
+ /**
479
+ * Perform transaction introspection to validate the transaction structure and transfer details.
480
+ * This function handles decoding the transaction, validating the transfer instruction,
481
+ * and verifying all transfer details against the payment requirements.
482
+ *
483
+ * @param svmPayload - The SVM payload containing the transaction
484
+ * @param paymentRequirements - The payment requirements to verify against
485
+ * @param config - Optional configuration for X402 operations (e.g., custom RPC URLs)
486
+ */
487
+ declare function transactionIntrospection(svmPayload: ExactSvmPayload, paymentRequirements: PaymentRequirements, config?: X402Config): Promise<void>;
488
+ /**
489
+ * Verify that the transaction contains the expected instructions.
490
+ *
491
+ * @param transactionMessage - The transaction message to verify
492
+ * @param paymentRequirements - The payment requirements to verify against
493
+ * @param rpc - The RPC client to use for verifying account existence
494
+ * @throws Error if the transaction does not contain the expected instructions
495
+ */
496
+ declare function verifyTransactionInstructions(transactionMessage: CompilableTransactionMessage, paymentRequirements: PaymentRequirements, rpc: RpcDevnet<SolanaRpcApiDevnet> | RpcMainnet<SolanaRpcApiMainnet>): Promise<void>;
497
+ /**
498
+ * Verify that the compute limit instruction is valid.
499
+ *
500
+ * @param instruction - The compute limit instruction to verify
501
+ * @throws Error if the compute limit instruction is invalid
502
+ */
503
+ declare function verifyComputeLimitInstruction(instruction: Instruction<string, readonly (AccountLookupMeta<string, string> | AccountMeta<string>)[]>): void;
504
+ /**
505
+ * Verify that the compute price instruction is valid.
506
+ * This function throws an error if the compute unit price is greater than 5 lamports,
507
+ * to protect the facilitator against gas fee abuse from the client.
508
+ *
509
+ * @param instruction - The compute price instruction to verify
510
+ * @throws Error if the compute price instruction is invalid
511
+ */
512
+ declare function verifyComputePriceInstruction(instruction: Instruction<string, readonly (AccountLookupMeta<string, string> | AccountMeta<string>)[]>): void;
513
+ /**
514
+ * Verify that the create ATA instruction is valid.
515
+ *
516
+ * @param instruction - The create ATA instruction to verify
517
+ * @param paymentRequirements - The payment requirements to verify against
518
+ * @throws Error if the create ATA instruction is invalid
519
+ */
520
+ declare function verifyCreateATAInstruction(instruction: Instruction<string, readonly (AccountLookupMeta<string, string> | AccountMeta<string>)[]>, paymentRequirements: PaymentRequirements): void;
521
+ /**
522
+ * Verify that the transfer instruction is valid.
523
+ *
524
+ * @param instruction - The transfer instruction to verify
525
+ * @param paymentRequirements - The payment requirements to verify against
526
+ * @param {object} options - The options for the verification of the transfer instruction
527
+ * @param {boolean} options.txHasCreateDestATAInstruction - Whether the transaction has a create destination ATA instruction
528
+ * @param rpc - The RPC client to use for verifying account existence
529
+ * @throws Error if the transfer instruction is invalid
530
+ */
531
+ declare function verifyTransferInstruction(instruction: Instruction<string, readonly (AccountLookupMeta<string, string> | AccountMeta<string>)[]>, paymentRequirements: PaymentRequirements, { txHasCreateDestATAInstruction }: {
532
+ txHasCreateDestATAInstruction: boolean;
533
+ }, rpc: RpcDevnet<SolanaRpcApiDevnet> | RpcMainnet<SolanaRpcApiMainnet>): Promise<void>;
534
+ /**
535
+ * Verify that the transfer checked instruction is valid.
536
+ *
537
+ * @param parsedInstruction - The parsed transfer checked instruction to verify
538
+ * @param paymentRequirements - The payment requirements to verify against
539
+ * @param {object} options - The options for the verification of the transfer checked instruction
540
+ * @param {boolean} options.txHasCreateDestATAInstruction - Whether the transaction has a create destination ATA instruction
541
+ * @param rpc - The RPC client to use for verifying account existence
542
+ * @throws Error if the transfer checked instruction is invalid
543
+ */
544
+ declare function verifyTransferCheckedInstruction(parsedInstruction: ReturnType<typeof parseTransferCheckedInstruction>, paymentRequirements: PaymentRequirements, { txHasCreateDestATAInstruction }: {
545
+ txHasCreateDestATAInstruction: boolean;
546
+ }, rpc: RpcDevnet<SolanaRpcApiDevnet> | RpcMainnet<SolanaRpcApiMainnet>): Promise<void>;
547
+ /**
548
+ * Inspect the decompiled transaction message to make sure that it is a valid
549
+ * transfer instruction.
550
+ *
551
+ * @param instruction - The instruction to get the transfer instruction from
552
+ * @returns The validated transfer instruction
553
+ * @throws Error if the instruction is not a valid transfer checked instruction
554
+ */
555
+ declare function getValidatedTransferCheckedInstruction(instruction: Instruction<string, readonly (AccountLookupMeta<string, string> | AccountMeta<string>)[]>): _solana_program_token.ParsedTransferCheckedInstruction<string, readonly (AccountLookupMeta<string, string> | AccountMeta<string>)[]>;
556
+
557
+ /**
558
+ * Creates and encodes a payment header for the given client and payment requirements.
559
+ *
560
+ * @param client - The signer instance used to create the payment header
561
+ * @param x402Version - The version of the X402 protocol to use
562
+ * @param paymentRequirements - The payment requirements containing scheme and network information
563
+ * @param config - Optional configuration for X402 operations (e.g., custom RPC URLs)
564
+ * @returns A promise that resolves to a base64 encoded payment header string
565
+ */
566
+ declare function createPaymentHeader(client: KeyPairSigner, x402Version: number, paymentRequirements: PaymentRequirements, config?: X402Config): Promise<string>;
567
+ /**
568
+ * Creates and signs a payment for the given client and payment requirements.
569
+ *
570
+ * @param client - The signer instance used to create and sign the payment tx
571
+ * @param x402Version - The version of the X402 protocol to use
572
+ * @param paymentRequirements - The payment requirements
573
+ * @param config - Optional configuration for X402 operations (e.g., custom RPC URLs)
574
+ * @returns A promise that resolves to a payment payload containing a base64 encoded solana token transfer tx
575
+ */
576
+ declare function createAndSignPayment(client: KeyPairSigner, x402Version: number, paymentRequirements: PaymentRequirements, config?: X402Config): Promise<PaymentPayload>;
577
+
578
+ declare const index$1_confirmSignedTransaction: typeof confirmSignedTransaction;
579
+ declare const index$1_createAndSignPayment: typeof createAndSignPayment;
580
+ declare const index$1_createPaymentHeader: typeof createPaymentHeader;
581
+ declare const index$1_getValidatedTransferCheckedInstruction: typeof getValidatedTransferCheckedInstruction;
582
+ declare const index$1_sendAndConfirmSignedTransaction: typeof sendAndConfirmSignedTransaction;
583
+ declare const index$1_sendSignedTransaction: typeof sendSignedTransaction;
584
+ declare const index$1_settle: typeof settle;
585
+ declare const index$1_transactionIntrospection: typeof transactionIntrospection;
586
+ declare const index$1_verify: typeof verify;
587
+ declare const index$1_verifyComputeLimitInstruction: typeof verifyComputeLimitInstruction;
588
+ declare const index$1_verifyComputePriceInstruction: typeof verifyComputePriceInstruction;
589
+ declare const index$1_verifyCreateATAInstruction: typeof verifyCreateATAInstruction;
590
+ declare const index$1_verifySchemesAndNetworks: typeof verifySchemesAndNetworks;
591
+ declare const index$1_verifyTransactionInstructions: typeof verifyTransactionInstructions;
592
+ declare const index$1_verifyTransferCheckedInstruction: typeof verifyTransferCheckedInstruction;
593
+ declare const index$1_verifyTransferInstruction: typeof verifyTransferInstruction;
594
+ declare namespace index$1 {
595
+ export { index$1_confirmSignedTransaction as confirmSignedTransaction, index$1_createAndSignPayment as createAndSignPayment, index$1_createPaymentHeader as createPaymentHeader, index$1_getValidatedTransferCheckedInstruction as getValidatedTransferCheckedInstruction, index$1_sendAndConfirmSignedTransaction as sendAndConfirmSignedTransaction, index$1_sendSignedTransaction as sendSignedTransaction, index$1_settle as settle, index$1_transactionIntrospection as transactionIntrospection, index$1_verify as verify, index$1_verifyComputeLimitInstruction as verifyComputeLimitInstruction, index$1_verifyComputePriceInstruction as verifyComputePriceInstruction, index$1_verifyCreateATAInstruction as verifyCreateATAInstruction, index$1_verifySchemesAndNetworks as verifySchemesAndNetworks, index$1_verifyTransactionInstructions as verifyTransactionInstructions, index$1_verifyTransferCheckedInstruction as verifyTransferCheckedInstruction, index$1_verifyTransferInstruction as verifyTransferInstruction };
596
+ }
597
+
598
+ declare const SCHEME = "exact";
599
+
600
+ declare const index_SCHEME: typeof SCHEME;
601
+ declare namespace index {
602
+ export { index_SCHEME as SCHEME, index$2 as evm, index$1 as svm };
603
+ }
604
+
605
+ export { decodePayment, encodePayment, index as exact };
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  exact_exports
3
- } from "../chunk-57UEJN5U.mjs";
3
+ } from "../chunk-XGQBEMP7.mjs";
4
4
  import {
5
5
  decodePayment,
6
6
  encodePayment
7
- } from "../chunk-RX2JKK4O.mjs";
8
- import "../chunk-UCBE7FDY.mjs";
7
+ } from "../chunk-VTLJOZXM.mjs";
8
+ import "../chunk-NPWDNT2P.mjs";
9
9
  import "../chunk-5LTKIVOA.mjs";
10
10
  import "../chunk-AQQR4PXH.mjs";
11
11
  export {