@t402/extensions 2.4.0 → 2.6.0

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 (42) hide show
  1. package/dist/cjs/bazaar/index.d.ts +1 -1
  2. package/dist/cjs/eip2612-gas-sponsoring/index.d.ts +337 -0
  3. package/dist/cjs/eip2612-gas-sponsoring/index.js +314 -0
  4. package/dist/cjs/eip2612-gas-sponsoring/index.js.map +1 -0
  5. package/dist/cjs/erc20-approval-gas-sponsoring/index.d.ts +316 -0
  6. package/dist/cjs/erc20-approval-gas-sponsoring/index.js +264 -0
  7. package/dist/cjs/erc20-approval-gas-sponsoring/index.js.map +1 -0
  8. package/dist/cjs/{index-DYNleT-u.d.ts → index-Mk5Ypp8M.d.ts} +2 -2
  9. package/dist/cjs/index.d.ts +4 -1
  10. package/dist/cjs/index.js +650 -0
  11. package/dist/cjs/index.js.map +1 -1
  12. package/dist/cjs/payment-id/index.d.ts +142 -0
  13. package/dist/cjs/payment-id/index.js +101 -0
  14. package/dist/cjs/payment-id/index.js.map +1 -0
  15. package/dist/cjs/sign-in-with-x/index.d.ts +2 -1
  16. package/dist/cjs/sign-in-with-x/index.js +55 -0
  17. package/dist/cjs/sign-in-with-x/index.js.map +1 -1
  18. package/dist/esm/bazaar/index.d.mts +1 -1
  19. package/dist/esm/chunk-OAWKCEAR.mjs +226 -0
  20. package/dist/esm/chunk-OAWKCEAR.mjs.map +1 -0
  21. package/dist/esm/chunk-S36A7YLQ.mjs +70 -0
  22. package/dist/esm/chunk-S36A7YLQ.mjs.map +1 -0
  23. package/dist/esm/chunk-VINC22RD.mjs +278 -0
  24. package/dist/esm/chunk-VINC22RD.mjs.map +1 -0
  25. package/dist/esm/{chunk-J3ZMNCIA.mjs → chunk-YKZ5P2JW.mjs} +56 -1
  26. package/dist/esm/chunk-YKZ5P2JW.mjs.map +1 -0
  27. package/dist/esm/eip2612-gas-sponsoring/index.d.mts +337 -0
  28. package/dist/esm/eip2612-gas-sponsoring/index.mjs +27 -0
  29. package/dist/esm/eip2612-gas-sponsoring/index.mjs.map +1 -0
  30. package/dist/esm/erc20-approval-gas-sponsoring/index.d.mts +316 -0
  31. package/dist/esm/erc20-approval-gas-sponsoring/index.mjs +31 -0
  32. package/dist/esm/erc20-approval-gas-sponsoring/index.mjs.map +1 -0
  33. package/dist/esm/{index-DYNleT-u.d.mts → index-Mk5Ypp8M.d.mts} +2 -2
  34. package/dist/esm/index.d.mts +4 -1
  35. package/dist/esm/index.mjs +67 -1
  36. package/dist/esm/payment-id/index.d.mts +142 -0
  37. package/dist/esm/payment-id/index.mjs +17 -0
  38. package/dist/esm/payment-id/index.mjs.map +1 -0
  39. package/dist/esm/sign-in-with-x/index.d.mts +2 -1
  40. package/dist/esm/sign-in-with-x/index.mjs +1 -1
  41. package/package.json +53 -16
  42. package/dist/esm/chunk-J3ZMNCIA.mjs.map +0 -1
@@ -0,0 +1,316 @@
1
+ /**
2
+ * ERC-20 Approval Gas Sponsoring Extension Type Definitions
3
+ *
4
+ * ERC-20 approve()-based gas sponsoring for the t402 payment protocol.
5
+ * For tokens WITHOUT EIP-2612 permit support, the client signs an offline
6
+ * approve() transaction and the facilitator broadcasts it on their behalf.
7
+ */
8
+ /**
9
+ * Information provided by server about ERC-20 approval gas sponsoring availability.
10
+ */
11
+ interface ERC20ApprovalGasSponsorExtensionInfo {
12
+ /** CAIP-2 network identifiers where gas sponsoring is available */
13
+ sponsoredNetworks: string[];
14
+ /** Maximum token amount (in base units) the sponsor will cover per approval */
15
+ maxAmount: string;
16
+ /** Address of the sponsor/facilitator that will submit transactions */
17
+ sponsorAddress: string;
18
+ /** Optional Permit2 proxy address for advanced settlement flows */
19
+ permit2Address?: string;
20
+ /** Whether atomic batch execution is required (e.g., via Multicall3) */
21
+ requiresAtomicBatch: boolean;
22
+ }
23
+ /**
24
+ * ERC-20 approval gas sponsor extension declaration for server responses.
25
+ */
26
+ interface ERC20ApprovalGasSponsorExtension {
27
+ /** Extension information */
28
+ info: ERC20ApprovalGasSponsorExtensionInfo;
29
+ /** JSON Schema for validation */
30
+ schema: object;
31
+ }
32
+ /**
33
+ * Complete ERC-20 approval gas sponsor payload from client.
34
+ */
35
+ interface ERC20ApprovalGasSponsorPayload {
36
+ /** CAIP-2 network identifier (must be in sponsoredNetworks) */
37
+ network: string;
38
+ /** Client wallet address that signed the transaction */
39
+ from: string;
40
+ /** ERC-20 token contract address */
41
+ asset: string;
42
+ /** Approval amount in base units */
43
+ amount: string;
44
+ /** Raw signed approve() transaction (hex-encoded with 0x prefix) */
45
+ signedApprovalTx: string;
46
+ /** Chain ID for replay protection */
47
+ chainId: number;
48
+ /** Client's account nonce (if known) */
49
+ nonce?: number;
50
+ }
51
+ /**
52
+ * Options for declaring ERC-20 approval gas sponsor extension on server.
53
+ */
54
+ interface DeclareERC20ApprovalGasSponsorOptions {
55
+ /** CAIP-2 network identifiers where gas sponsoring is available */
56
+ sponsoredNetworks: string[];
57
+ /** Maximum token amount (in base units) the sponsor will cover per approval */
58
+ maxAmount: string;
59
+ /** Address of the sponsor/facilitator */
60
+ sponsorAddress: string;
61
+ /** Optional Permit2 proxy address */
62
+ permit2Address?: string;
63
+ /** Whether atomic batch execution is required (defaults to false) */
64
+ requiresAtomicBatch?: boolean;
65
+ }
66
+ /**
67
+ * Options for validating ERC-20 approval gas sponsor payloads.
68
+ */
69
+ interface ValidateERC20ApprovalGasSponsorOptions {
70
+ /** Expected chain IDs per CAIP-2 network (e.g., { "eip155:8453": 8453 }) */
71
+ expectedChainIds?: Record<string, number>;
72
+ }
73
+ /**
74
+ * Result of ERC-20 approval gas sponsor payload validation.
75
+ */
76
+ interface ERC20ApprovalGasSponsorValidationResult {
77
+ /** Whether the payload is valid */
78
+ valid: boolean;
79
+ /** Error message if invalid */
80
+ error?: string;
81
+ }
82
+ /**
83
+ * Parameters for creating an ERC-20 approval gas sponsor payload.
84
+ */
85
+ interface CreateERC20ApprovalParams {
86
+ /** CAIP-2 network identifier */
87
+ network: string;
88
+ /** Client wallet address */
89
+ from: string;
90
+ /** ERC-20 token contract address */
91
+ asset: string;
92
+ /** Approval amount in base units */
93
+ amount: string;
94
+ /** Raw signed approve() transaction (hex-encoded) */
95
+ signedApprovalTx: string;
96
+ /** Chain ID for replay protection */
97
+ chainId: number;
98
+ /** Client's account nonce (if known) */
99
+ nonce?: number;
100
+ }
101
+
102
+ /**
103
+ * ERC-20 Approval Gas Sponsoring Extension Server-Side Implementation
104
+ *
105
+ * Provides functions for servers to declare gas sponsoring requirements,
106
+ * parse client headers, and validate approval payloads.
107
+ */
108
+
109
+ /**
110
+ * Declares an ERC-20 approval gas sponsor extension for server responses.
111
+ *
112
+ * @param options - Extension declaration options
113
+ * @returns Gas sponsor extension object ready for response
114
+ *
115
+ * @example
116
+ * ```typescript
117
+ * const extension = declareERC20ApprovalGasSponsorExtension({
118
+ * sponsoredNetworks: ["eip155:8453", "eip155:42161"],
119
+ * maxAmount: "1000000000",
120
+ * sponsorAddress: "0xFacilitator...",
121
+ * requiresAtomicBatch: true,
122
+ * });
123
+ * ```
124
+ */
125
+ declare function declareERC20ApprovalGasSponsorExtension(options: DeclareERC20ApprovalGasSponsorOptions): ERC20ApprovalGasSponsorExtension;
126
+ /**
127
+ * Parses an ERC-20 approval gas sponsor header from client request.
128
+ *
129
+ * The header format is base64-encoded JSON.
130
+ *
131
+ * @param header - Base64-encoded gas sponsor header value
132
+ * @returns Parsed gas sponsor payload
133
+ * @throws Error if header is invalid
134
+ *
135
+ * @example
136
+ * ```typescript
137
+ * const payload = parseERC20ApprovalGasSponsorHeader(
138
+ * request.headers['x-t402-erc20-approval-gas-sponsoring']
139
+ * );
140
+ * ```
141
+ */
142
+ declare function parseERC20ApprovalGasSponsorHeader(header: string): ERC20ApprovalGasSponsorPayload;
143
+ /**
144
+ * Validates an ERC-20 approval gas sponsor payload against server extension info.
145
+ *
146
+ * @param payload - The gas sponsor payload from the client
147
+ * @param extensionInfo - The server's gas sponsor extension info
148
+ * @param options - Validation options
149
+ * @returns Validation result
150
+ *
151
+ * @example
152
+ * ```typescript
153
+ * const result = validateERC20ApprovalGasSponsorPayload(payload, extension.info);
154
+ * if (!result.valid) {
155
+ * throw new Error(result.error);
156
+ * }
157
+ * ```
158
+ */
159
+ declare function validateERC20ApprovalGasSponsorPayload(payload: ERC20ApprovalGasSponsorPayload, extensionInfo: ERC20ApprovalGasSponsorExtensionInfo, options?: ValidateERC20ApprovalGasSponsorOptions): ERC20ApprovalGasSponsorValidationResult;
160
+
161
+ /**
162
+ * ERC-20 Approval Gas Sponsoring Extension Client-Side Implementation
163
+ *
164
+ * Provides functions for clients to construct ERC-20 approve() calldata
165
+ * and encode gas sponsor payloads for transmission.
166
+ */
167
+
168
+ /**
169
+ * Extension key for ERC-20 approval gas sponsoring in payment requirements.
170
+ */
171
+ declare const ERC20_APPROVAL_GAS_SPONSOR_EXTENSION_KEY = "erc20ApprovalGasSponsoring";
172
+ /**
173
+ * HTTP header name for ERC-20 approval gas sponsor payload.
174
+ */
175
+ declare const ERC20_APPROVAL_GAS_SPONSOR_HEADER_NAME = "X-T402-ERC20-Approval-Gas-Sponsoring";
176
+ /**
177
+ * ERC-20 approve(address,uint256) function selector.
178
+ */
179
+ declare const APPROVE_FUNCTION_SELECTOR = "0x095ea7b3";
180
+ /**
181
+ * Encodes ERC-20 approve(address spender, uint256 amount) calldata.
182
+ *
183
+ * @param spender - The spender address to approve
184
+ * @param amount - The approval amount in base units
185
+ * @returns Hex-encoded calldata with 0x prefix
186
+ *
187
+ * @example
188
+ * ```typescript
189
+ * const calldata = encodeApproveCalldata("0xFacilitator...", "1000000");
190
+ * // Returns "0x095ea7b3" + abi-encoded args
191
+ * ```
192
+ */
193
+ declare function encodeApproveCalldata(spender: string, amount: string): string;
194
+ /**
195
+ * Creates an ERC-20 approval gas sponsor payload from params and extension info.
196
+ *
197
+ * @param info - The server's extension info
198
+ * @param params - The approval parameters
199
+ * @returns Gas sponsor payload ready for header encoding
200
+ *
201
+ * @example
202
+ * ```typescript
203
+ * const payload = createERC20ApprovalGasSponsorPayload(extensionInfo, {
204
+ * network: "eip155:8453",
205
+ * from: wallet.address,
206
+ * asset: "0xUSDT...",
207
+ * amount: "1000000",
208
+ * signedApprovalTx: signedTx,
209
+ * chainId: 8453,
210
+ * });
211
+ * ```
212
+ */
213
+ declare function createERC20ApprovalGasSponsorPayload(_info: ERC20ApprovalGasSponsorExtensionInfo, params: CreateERC20ApprovalParams): ERC20ApprovalGasSponsorPayload;
214
+ /**
215
+ * Encodes an ERC-20 approval gas sponsor payload for transmission in HTTP header.
216
+ *
217
+ * @param payload - The gas sponsor payload to encode
218
+ * @returns Base64-encoded JSON string
219
+ *
220
+ * @example
221
+ * ```typescript
222
+ * const header = encodeERC20ApprovalGasSponsorHeader(payload);
223
+ * fetch(url, {
224
+ * headers: { [ERC20_APPROVAL_GAS_SPONSOR_HEADER_NAME]: header }
225
+ * });
226
+ * ```
227
+ */
228
+ declare function encodeERC20ApprovalGasSponsorHeader(payload: ERC20ApprovalGasSponsorPayload): string;
229
+
230
+ /**
231
+ * ERC-20 Approval Gas Sponsoring Extension Facilitator-Side Implementation
232
+ *
233
+ * Provides functions for facilitators to extract approval data from payment
234
+ * extensions, validate the signed approve() transaction, and prepare for
235
+ * on-chain submission.
236
+ */
237
+
238
+ /**
239
+ * Extracts the ERC-20 approval gas sponsor payload from payment extensions.
240
+ *
241
+ * @param extensions - The extensions map from a PaymentPayload
242
+ * @returns The gas sponsor payload if present, or null
243
+ *
244
+ * @example
245
+ * ```typescript
246
+ * const approval = extractERC20ApprovalGasSponsorPayload(paymentPayload.extensions);
247
+ * if (approval) {
248
+ * // Validate and broadcast the approval tx, then settle
249
+ * }
250
+ * ```
251
+ */
252
+ declare function extractERC20ApprovalGasSponsorPayload(extensions: Record<string, unknown> | undefined): ERC20ApprovalGasSponsorPayload | null;
253
+ /**
254
+ * Processes and validates an ERC-20 approval payload for the facilitator.
255
+ *
256
+ * Combines extraction validation with approve() function selector verification.
257
+ * Checks that the signed transaction data contains the correct approve() selector
258
+ * and that the approval amount matches the declared amount.
259
+ *
260
+ * @param payload - The ERC-20 approval gas sponsor payload
261
+ * @param extensionInfo - The server's gas sponsor extension info
262
+ * @returns Validation result
263
+ *
264
+ * @example
265
+ * ```typescript
266
+ * const result = processERC20ApprovalPayload(payload, extensionInfo);
267
+ * if (result.valid) {
268
+ * // Safe to broadcast the approval tx and settle
269
+ * }
270
+ * ```
271
+ */
272
+ declare function processERC20ApprovalPayload(payload: ERC20ApprovalGasSponsorPayload, extensionInfo: ERC20ApprovalGasSponsorExtensionInfo): ERC20ApprovalGasSponsorValidationResult;
273
+ /**
274
+ * Validates and extracts the ERC-20 approval gas sponsor payload in one step.
275
+ *
276
+ * This is a convenience function for facilitators that combines extraction
277
+ * and validation against the server's extension info.
278
+ *
279
+ * @param extensions - The extensions map from a PaymentPayload
280
+ * @param extensionInfo - The server's gas sponsor extension info
281
+ * @returns Validation result with the extracted payload if valid
282
+ *
283
+ * @example
284
+ * ```typescript
285
+ * const result = validateAndExtractApproval(
286
+ * paymentPayload.extensions,
287
+ * extensionInfo
288
+ * );
289
+ * if (result.valid && result.payload) {
290
+ * // Broadcast approval tx, then settle
291
+ * }
292
+ * ```
293
+ */
294
+ declare function validateAndExtractApproval(extensions: Record<string, unknown> | undefined, extensionInfo: ERC20ApprovalGasSponsorExtensionInfo): ERC20ApprovalGasSponsorValidationResult & {
295
+ payload?: ERC20ApprovalGasSponsorPayload;
296
+ };
297
+ /**
298
+ * Decodes the approve() calldata from a hex string to extract spender and amount.
299
+ *
300
+ * @param calldata - Hex-encoded approve() calldata (with or without 0x prefix)
301
+ * @returns Decoded spender and amount, or null if not valid approve() calldata
302
+ *
303
+ * @example
304
+ * ```typescript
305
+ * const decoded = decodeApproveCalldata("0x095ea7b3...");
306
+ * if (decoded) {
307
+ * console.log(decoded.spender, decoded.amount);
308
+ * }
309
+ * ```
310
+ */
311
+ declare function decodeApproveCalldata(calldata: string): {
312
+ spender: string;
313
+ amount: string;
314
+ } | null;
315
+
316
+ export { APPROVE_FUNCTION_SELECTOR, type CreateERC20ApprovalParams, type DeclareERC20ApprovalGasSponsorOptions, type ERC20ApprovalGasSponsorExtension, type ERC20ApprovalGasSponsorExtensionInfo, type ERC20ApprovalGasSponsorPayload, type ERC20ApprovalGasSponsorValidationResult, ERC20_APPROVAL_GAS_SPONSOR_EXTENSION_KEY, ERC20_APPROVAL_GAS_SPONSOR_HEADER_NAME, type ValidateERC20ApprovalGasSponsorOptions, createERC20ApprovalGasSponsorPayload, declareERC20ApprovalGasSponsorExtension, decodeApproveCalldata, encodeApproveCalldata, encodeERC20ApprovalGasSponsorHeader, extractERC20ApprovalGasSponsorPayload, parseERC20ApprovalGasSponsorHeader, processERC20ApprovalPayload, validateAndExtractApproval, validateERC20ApprovalGasSponsorPayload };
@@ -0,0 +1,31 @@
1
+ import {
2
+ APPROVE_FUNCTION_SELECTOR,
3
+ ERC20_APPROVAL_GAS_SPONSOR_EXTENSION_KEY,
4
+ ERC20_APPROVAL_GAS_SPONSOR_HEADER_NAME,
5
+ createERC20ApprovalGasSponsorPayload,
6
+ declareERC20ApprovalGasSponsorExtension,
7
+ decodeApproveCalldata,
8
+ encodeApproveCalldata,
9
+ encodeERC20ApprovalGasSponsorHeader,
10
+ extractERC20ApprovalGasSponsorPayload,
11
+ parseERC20ApprovalGasSponsorHeader,
12
+ processERC20ApprovalPayload,
13
+ validateAndExtractApproval,
14
+ validateERC20ApprovalGasSponsorPayload
15
+ } from "../chunk-OAWKCEAR.mjs";
16
+ export {
17
+ APPROVE_FUNCTION_SELECTOR,
18
+ ERC20_APPROVAL_GAS_SPONSOR_EXTENSION_KEY,
19
+ ERC20_APPROVAL_GAS_SPONSOR_HEADER_NAME,
20
+ createERC20ApprovalGasSponsorPayload,
21
+ declareERC20ApprovalGasSponsorExtension,
22
+ decodeApproveCalldata,
23
+ encodeApproveCalldata,
24
+ encodeERC20ApprovalGasSponsorHeader,
25
+ extractERC20ApprovalGasSponsorPayload,
26
+ parseERC20ApprovalGasSponsorHeader,
27
+ processERC20ApprovalPayload,
28
+ validateAndExtractApproval,
29
+ validateERC20ApprovalGasSponsorPayload
30
+ };
31
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,4 +1,4 @@
1
- import { QueryParamMethods, BodyMethods, HTTPFacilitatorClient } from '@t402/core/http';
1
+ import { BodyMethods, QueryParamMethods, HTTPFacilitatorClient } from '@t402/core/http';
2
2
  import { ResourceServerExtension, PaymentPayload, PaymentRequirements, PaymentRequirementsV1 } from '@t402/core/types';
3
3
 
4
4
  /**
@@ -544,4 +544,4 @@ interface BazaarClientExtension {
544
544
  */
545
545
  declare function withBazaar<T extends HTTPFacilitatorClient>(client: T): WithExtensions<T, BazaarClientExtension>;
546
546
 
547
- export { type BodyDiscoveryInfo as B, type DiscoveryInfo as D, type ListDiscoveryResourcesParams as L, type QueryDiscoveryInfo as Q, type ValidationResult as V, type WithExtensions as W, type QueryDiscoveryExtension as a, bazaarResourceServerExtension as b, type BodyDiscoveryExtension as c, type DiscoveryExtension as d, BAZAAR as e, declareDiscoveryExtension as f, extractDiscoveryInfo as g, extractDiscoveryInfoFromExtension as h, validateAndExtract as i, extractDiscoveryInfoV1 as j, isDiscoverableV1 as k, extractResourceMetadataV1 as l, type BazaarClientExtension as m, type DiscoveryResource as n, type DiscoveryResourcesResponse as o, validateDiscoveryExtension as v, withBazaar as w };
547
+ export { BAZAAR as B, type DiscoveryExtension as D, type ListDiscoveryResourcesParams as L, type QueryDiscoveryExtension as Q, type ValidationResult as V, type WithExtensions as W, type BazaarClientExtension as a, type BodyDiscoveryExtension as b, type BodyDiscoveryInfo as c, type DiscoveryInfo as d, type DiscoveryResource as e, type DiscoveryResourcesResponse as f, type QueryDiscoveryInfo as g, bazaarResourceServerExtension as h, declareDiscoveryExtension as i, extractDiscoveryInfo as j, extractDiscoveryInfoFromExtension as k, extractDiscoveryInfoV1 as l, extractResourceMetadataV1 as m, isDiscoverableV1 as n, validateDiscoveryExtension as o, validateAndExtract as v, withBazaar as w };
@@ -1,4 +1,7 @@
1
- export { e as BAZAAR, m as BazaarClientExtension, c as BodyDiscoveryExtension, B as BodyDiscoveryInfo, d as DiscoveryExtension, D as DiscoveryInfo, n as DiscoveryResource, o as DiscoveryResourcesResponse, L as ListDiscoveryResourcesParams, a as QueryDiscoveryExtension, Q as QueryDiscoveryInfo, V as ValidationResult, W as WithExtensions, b as bazaarResourceServerExtension, f as declareDiscoveryExtension, g as extractDiscoveryInfo, h as extractDiscoveryInfoFromExtension, j as extractDiscoveryInfoV1, l as extractResourceMetadataV1, k as isDiscoverableV1, i as validateAndExtract, v as validateDiscoveryExtension, w as withBazaar } from './index-DYNleT-u.mjs';
1
+ export { B as BAZAAR, a as BazaarClientExtension, b as BodyDiscoveryExtension, c as BodyDiscoveryInfo, D as DiscoveryExtension, d as DiscoveryInfo, e as DiscoveryResource, f as DiscoveryResourcesResponse, L as ListDiscoveryResourcesParams, Q as QueryDiscoveryExtension, g as QueryDiscoveryInfo, V as ValidationResult, W as WithExtensions, h as bazaarResourceServerExtension, i as declareDiscoveryExtension, j as extractDiscoveryInfo, k as extractDiscoveryInfoFromExtension, l as extractDiscoveryInfoV1, m as extractResourceMetadataV1, n as isDiscoverableV1, v as validateAndExtract, o as validateDiscoveryExtension, w as withBazaar } from './index-Mk5Ypp8M.mjs';
2
2
  export { DeclareSIWxOptions, SIWX_EXTENSION_KEY, SIWX_HEADER_NAME, SIWxExtension, SIWxExtensionInfo, SIWxPayload, SIWxSigner, SIWxValidationResult, SIWxVerificationResult, SignatureScheme, ValidateSIWxOptions, VerifySIWxOptions, constructMessage, createSIWxMessage, createSIWxPayload, createSIWxTypedData, declareSIWxExtension, encodeSIWxHeader, hashMessage, parseSIWxHeader, signSIWxMessage, validateSIWxMessage, verifyEIP6492Signature, verifySIWxSignature } from './sign-in-with-x/index.mjs';
3
+ export { DeclarePaymentIdOptions, PAYMENT_ID_EXTENSION_KEY, PaymentIdExtension, PaymentIdExtensionInfo, PaymentIdPayload, createPaymentIdPayload, declarePaymentIdExtension, encodePaymentIdHeader, parsePaymentIdPayload, validatePaymentId } from './payment-id/index.mjs';
4
+ export { CreatePermitParams, DeclareEip2612GasSponsorOptions, EIP2612_GAS_SPONSOR_EXTENSION_KEY, EIP2612_GAS_SPONSOR_HEADER_NAME, Eip2612GasSponsorExtension, Eip2612GasSponsorExtensionInfo, Eip2612GasSponsorPayload, Eip2612GasSponsorValidationResult, PermitSigner, ValidateEip2612GasSponsorOptions, buildPermitCallData, createEip2612GasSponsorPayload, createPermitSignature, declareEip2612GasSponsorExtension, encodeEip2612GasSponsorHeader, extractEip2612GasSponsorPayload, parseEip2612GasSponsorHeader, validateAndExtractPermit, validateEip2612GasSponsorPayload } from './eip2612-gas-sponsoring/index.mjs';
5
+ export { APPROVE_FUNCTION_SELECTOR, CreateERC20ApprovalParams, DeclareERC20ApprovalGasSponsorOptions, ERC20ApprovalGasSponsorExtension, ERC20ApprovalGasSponsorExtensionInfo, ERC20ApprovalGasSponsorPayload, ERC20ApprovalGasSponsorValidationResult, ERC20_APPROVAL_GAS_SPONSOR_EXTENSION_KEY, ERC20_APPROVAL_GAS_SPONSOR_HEADER_NAME, ValidateERC20ApprovalGasSponsorOptions, createERC20ApprovalGasSponsorPayload, declareERC20ApprovalGasSponsorExtension, decodeApproveCalldata, encodeApproveCalldata, encodeERC20ApprovalGasSponsorHeader, extractERC20ApprovalGasSponsorPayload, parseERC20ApprovalGasSponsorHeader, processERC20ApprovalPayload, validateAndExtractApproval, validateERC20ApprovalGasSponsorPayload } from './erc20-approval-gas-sponsoring/index.mjs';
3
6
  import '@t402/core/http';
4
7
  import '@t402/core/types';
@@ -26,29 +26,95 @@ import {
26
26
  validateSIWxMessage,
27
27
  verifyEIP6492Signature,
28
28
  verifySIWxSignature
29
- } from "./chunk-J3ZMNCIA.mjs";
29
+ } from "./chunk-YKZ5P2JW.mjs";
30
+ import {
31
+ PAYMENT_ID_EXTENSION_KEY,
32
+ createPaymentIdPayload,
33
+ declarePaymentIdExtension,
34
+ encodePaymentIdHeader,
35
+ parsePaymentIdPayload,
36
+ validatePaymentId
37
+ } from "./chunk-S36A7YLQ.mjs";
38
+ import {
39
+ EIP2612_GAS_SPONSOR_EXTENSION_KEY,
40
+ EIP2612_GAS_SPONSOR_HEADER_NAME,
41
+ buildPermitCallData,
42
+ createEip2612GasSponsorPayload,
43
+ createPermitSignature,
44
+ declareEip2612GasSponsorExtension,
45
+ encodeEip2612GasSponsorHeader,
46
+ extractEip2612GasSponsorPayload,
47
+ parseEip2612GasSponsorHeader,
48
+ validateAndExtractPermit,
49
+ validateEip2612GasSponsorPayload
50
+ } from "./chunk-VINC22RD.mjs";
51
+ import {
52
+ APPROVE_FUNCTION_SELECTOR,
53
+ ERC20_APPROVAL_GAS_SPONSOR_EXTENSION_KEY,
54
+ ERC20_APPROVAL_GAS_SPONSOR_HEADER_NAME,
55
+ createERC20ApprovalGasSponsorPayload,
56
+ declareERC20ApprovalGasSponsorExtension,
57
+ decodeApproveCalldata,
58
+ encodeApproveCalldata,
59
+ encodeERC20ApprovalGasSponsorHeader,
60
+ extractERC20ApprovalGasSponsorPayload,
61
+ parseERC20ApprovalGasSponsorHeader,
62
+ processERC20ApprovalPayload,
63
+ validateAndExtractApproval,
64
+ validateERC20ApprovalGasSponsorPayload
65
+ } from "./chunk-OAWKCEAR.mjs";
30
66
  export {
67
+ APPROVE_FUNCTION_SELECTOR,
31
68
  BAZAAR,
69
+ EIP2612_GAS_SPONSOR_EXTENSION_KEY,
70
+ EIP2612_GAS_SPONSOR_HEADER_NAME,
71
+ ERC20_APPROVAL_GAS_SPONSOR_EXTENSION_KEY,
72
+ ERC20_APPROVAL_GAS_SPONSOR_HEADER_NAME,
73
+ PAYMENT_ID_EXTENSION_KEY,
32
74
  SIWX_EXTENSION_KEY,
33
75
  SIWX_HEADER_NAME,
34
76
  bazaarResourceServerExtension,
77
+ buildPermitCallData,
35
78
  constructMessage,
79
+ createERC20ApprovalGasSponsorPayload,
80
+ createEip2612GasSponsorPayload,
81
+ createPaymentIdPayload,
82
+ createPermitSignature,
36
83
  createSIWxMessage,
37
84
  createSIWxPayload,
38
85
  createSIWxTypedData,
39
86
  declareDiscoveryExtension,
87
+ declareERC20ApprovalGasSponsorExtension,
88
+ declareEip2612GasSponsorExtension,
89
+ declarePaymentIdExtension,
40
90
  declareSIWxExtension,
91
+ decodeApproveCalldata,
92
+ encodeApproveCalldata,
93
+ encodeERC20ApprovalGasSponsorHeader,
94
+ encodeEip2612GasSponsorHeader,
95
+ encodePaymentIdHeader,
41
96
  encodeSIWxHeader,
42
97
  extractDiscoveryInfo,
43
98
  extractDiscoveryInfoFromExtension,
44
99
  extractDiscoveryInfoV1,
100
+ extractERC20ApprovalGasSponsorPayload,
101
+ extractEip2612GasSponsorPayload,
45
102
  extractResourceMetadataV1,
46
103
  hashMessage,
47
104
  isDiscoverableV1,
105
+ parseERC20ApprovalGasSponsorHeader,
106
+ parseEip2612GasSponsorHeader,
107
+ parsePaymentIdPayload,
48
108
  parseSIWxHeader,
109
+ processERC20ApprovalPayload,
49
110
  signSIWxMessage,
50
111
  validateAndExtract,
112
+ validateAndExtractApproval,
113
+ validateAndExtractPermit,
51
114
  validateDiscoveryExtension,
115
+ validateERC20ApprovalGasSponsorPayload,
116
+ validateEip2612GasSponsorPayload,
117
+ validatePaymentId,
52
118
  validateSIWxMessage,
53
119
  verifyEIP6492Signature,
54
120
  verifySIWxSignature,
@@ -0,0 +1,142 @@
1
+ /**
2
+ * Payment ID Extension Type Definitions
3
+ *
4
+ * Allows servers to attach unique identifiers to payments for
5
+ * correlation, idempotency, and audit trails.
6
+ */
7
+ /**
8
+ * Extension key for payment ID in requirements/payload extensions.
9
+ */
10
+ declare const PAYMENT_ID_EXTENSION_KEY = "paymentId";
11
+ /**
12
+ * Information provided by server about the payment identifier.
13
+ */
14
+ interface PaymentIdExtensionInfo {
15
+ /** Unique payment identifier (UUID v4) */
16
+ id: string;
17
+ /** Optional idempotency key for replay protection */
18
+ idempotencyKey?: string;
19
+ /** Optional payment group for batching */
20
+ groupId?: string;
21
+ /** Optional metadata */
22
+ metadata?: Record<string, string>;
23
+ }
24
+ /**
25
+ * Payment ID extension declaration for server responses.
26
+ */
27
+ interface PaymentIdExtension {
28
+ /** Extension information */
29
+ info: PaymentIdExtensionInfo;
30
+ /** JSON Schema for validation */
31
+ schema: object;
32
+ }
33
+ /**
34
+ * Payment ID payload echoed back by the client.
35
+ */
36
+ interface PaymentIdPayload {
37
+ /** Payment ID echoed back from requirements */
38
+ id: string;
39
+ /** Optional client-generated correlation ID */
40
+ clientId?: string;
41
+ }
42
+ /**
43
+ * Options for declaring a payment ID extension.
44
+ */
45
+ interface DeclarePaymentIdOptions {
46
+ /** Custom payment ID (defaults to crypto.randomUUID()) */
47
+ id?: string;
48
+ /** Optional idempotency key for replay protection */
49
+ idempotencyKey?: string;
50
+ /** Optional payment group for batching */
51
+ groupId?: string;
52
+ /** Optional metadata */
53
+ metadata?: Record<string, string>;
54
+ }
55
+
56
+ /**
57
+ * Payment ID Extension Server-Side Implementation
58
+ *
59
+ * Provides functions for servers to declare payment ID requirements,
60
+ * parse client payloads, and validate payment IDs.
61
+ */
62
+
63
+ /**
64
+ * Declares a payment ID extension for server responses.
65
+ *
66
+ * @param options - Optional configuration for the payment ID
67
+ * @returns Payment ID extension object ready for response
68
+ *
69
+ * @example
70
+ * ```typescript
71
+ * const extension = declarePaymentIdExtension();
72
+ * // Include in PaymentRequired response extensions:
73
+ * // extensions: { [PAYMENT_ID_EXTENSION_KEY]: extension }
74
+ * ```
75
+ */
76
+ declare function declarePaymentIdExtension(options?: DeclarePaymentIdOptions): PaymentIdExtension;
77
+ /**
78
+ * Parses a payment ID payload from client request extensions.
79
+ *
80
+ * @param extensions - Extensions object from the payment payload
81
+ * @returns Parsed payment ID payload, or null if not present
82
+ * @throws Error if payload is present but invalid
83
+ *
84
+ * @example
85
+ * ```typescript
86
+ * const payload = parsePaymentIdPayload(paymentPayload.extensions);
87
+ * if (payload) {
88
+ * console.log("Payment ID:", payload.id);
89
+ * }
90
+ * ```
91
+ */
92
+ declare function parsePaymentIdPayload(extensions?: Record<string, unknown>): PaymentIdPayload | null;
93
+ /**
94
+ * Validates that a client's payment ID payload matches the expected extension.
95
+ *
96
+ * @param payload - The client's payment ID payload
97
+ * @param expected - The expected payment ID from the server extension
98
+ * @returns True if the payment ID matches
99
+ *
100
+ * @example
101
+ * ```typescript
102
+ * const isValid = validatePaymentId(clientPayload, serverExtension.info);
103
+ * if (!isValid) {
104
+ * throw new Error("Payment ID mismatch");
105
+ * }
106
+ * ```
107
+ */
108
+ declare function validatePaymentId(payload: PaymentIdPayload, expected: PaymentIdExtensionInfo): boolean;
109
+
110
+ /**
111
+ * Payment ID Extension Client-Side Implementation
112
+ *
113
+ * Provides functions for clients to echo payment IDs back to servers.
114
+ */
115
+
116
+ /**
117
+ * Creates a payment ID payload from a server extension.
118
+ *
119
+ * Reads the payment ID from requirements and echoes it back.
120
+ *
121
+ * @param extension - Payment ID extension from server's 402 response
122
+ * @param clientId - Optional client-generated correlation ID
123
+ * @returns Payment ID payload for inclusion in payment extensions
124
+ *
125
+ * @example
126
+ * ```typescript
127
+ * const extension = paymentRequirements.extensions?.paymentId;
128
+ * const payload = createPaymentIdPayload(extension, "my-correlation-id");
129
+ * // Include in payment payload extensions:
130
+ * // extensions: { [PAYMENT_ID_EXTENSION_KEY]: payload }
131
+ * ```
132
+ */
133
+ declare function createPaymentIdPayload(extension: PaymentIdExtension, clientId?: string): PaymentIdPayload;
134
+ /**
135
+ * Encodes a payment ID payload for header-based transport.
136
+ *
137
+ * @param payload - The payment ID payload to encode
138
+ * @returns Base64-encoded JSON string
139
+ */
140
+ declare function encodePaymentIdHeader(payload: PaymentIdPayload): string;
141
+
142
+ export { type DeclarePaymentIdOptions, PAYMENT_ID_EXTENSION_KEY, type PaymentIdExtension, type PaymentIdExtensionInfo, type PaymentIdPayload, createPaymentIdPayload, declarePaymentIdExtension, encodePaymentIdHeader, parsePaymentIdPayload, validatePaymentId };
@@ -0,0 +1,17 @@
1
+ import {
2
+ PAYMENT_ID_EXTENSION_KEY,
3
+ createPaymentIdPayload,
4
+ declarePaymentIdExtension,
5
+ encodePaymentIdHeader,
6
+ parsePaymentIdPayload,
7
+ validatePaymentId
8
+ } from "../chunk-S36A7YLQ.mjs";
9
+ export {
10
+ PAYMENT_ID_EXTENSION_KEY,
11
+ createPaymentIdPayload,
12
+ declarePaymentIdExtension,
13
+ encodePaymentIdHeader,
14
+ parsePaymentIdPayload,
15
+ validatePaymentId
16
+ };
17
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -201,7 +201,8 @@ declare function validateSIWxMessage(message: SIWxPayload, expectedResourceUri:
201
201
  /**
202
202
  * Verifies a SIWx signature.
203
203
  *
204
- * Supports EIP-191 personal signatures for EVM chains, Ed25519 for Solana/Stellar,
204
+ * Supports EIP-191 personal signatures for EVM chains, Ed25519 for Solana/Stellar/TON,
205
+ * TRON secp256k1 with base58check addresses,
205
206
  * and can optionally verify smart wallet signatures via EIP-1271/6492.
206
207
  *
207
208
  * @param message - The SIWx payload to verify
@@ -13,7 +13,7 @@ import {
13
13
  validateSIWxMessage,
14
14
  verifyEIP6492Signature,
15
15
  verifySIWxSignature
16
- } from "../chunk-J3ZMNCIA.mjs";
16
+ } from "../chunk-YKZ5P2JW.mjs";
17
17
  export {
18
18
  SIWX_EXTENSION_KEY,
19
19
  SIWX_HEADER_NAME,