x402check 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1857 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +465 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.ts +465 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.iife.js +5 -0
- package/dist/index.js +1831 -0
- package/dist/index.js.map +1 -0
- package/package.json +55 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,465 @@
|
|
|
1
|
+
//#region src/types/config.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Type definitions for all x402 config formats
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Config format discriminator
|
|
7
|
+
*/
|
|
8
|
+
type ConfigFormat = 'v2' | 'v1' | 'unknown';
|
|
9
|
+
/**
|
|
10
|
+
* HTTP resource definition
|
|
11
|
+
*/
|
|
12
|
+
interface Resource {
|
|
13
|
+
url: string;
|
|
14
|
+
method?: string | undefined;
|
|
15
|
+
headers?: Record<string, string> | undefined;
|
|
16
|
+
body?: string | undefined;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* V2 accepts array entry
|
|
20
|
+
*/
|
|
21
|
+
interface AcceptsEntry {
|
|
22
|
+
scheme: string;
|
|
23
|
+
network: string;
|
|
24
|
+
amount: string;
|
|
25
|
+
asset: string;
|
|
26
|
+
payTo: string;
|
|
27
|
+
maxTimeoutSeconds?: number | undefined;
|
|
28
|
+
extra?: Record<string, unknown> | undefined;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* x402 v2 config shape
|
|
32
|
+
*/
|
|
33
|
+
interface V2Config {
|
|
34
|
+
x402Version: 2;
|
|
35
|
+
accepts: AcceptsEntry[];
|
|
36
|
+
resource: Resource;
|
|
37
|
+
error?: string | undefined;
|
|
38
|
+
extensions?: Record<string, unknown> | undefined;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* V1 accepts array entry (different field names from v2)
|
|
42
|
+
*/
|
|
43
|
+
interface V1AcceptsEntry {
|
|
44
|
+
scheme: string;
|
|
45
|
+
network: string;
|
|
46
|
+
maxAmountRequired: string;
|
|
47
|
+
asset: string;
|
|
48
|
+
payTo: string;
|
|
49
|
+
maxTimeoutSeconds?: number | undefined;
|
|
50
|
+
extra?: Record<string, unknown> | undefined;
|
|
51
|
+
resource?: Resource | undefined;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* x402 v1 config shape
|
|
55
|
+
*/
|
|
56
|
+
interface V1Config {
|
|
57
|
+
x402Version: 1;
|
|
58
|
+
accepts: V1AcceptsEntry[];
|
|
59
|
+
error?: string | undefined;
|
|
60
|
+
extensions?: Record<string, unknown> | undefined;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Normalized config output (canonical v2 shape)
|
|
64
|
+
*/
|
|
65
|
+
interface NormalizedConfig {
|
|
66
|
+
x402Version: 2;
|
|
67
|
+
accepts: AcceptsEntry[];
|
|
68
|
+
resource?: Resource | undefined;
|
|
69
|
+
error?: string | undefined;
|
|
70
|
+
extensions?: Record<string, unknown> | undefined;
|
|
71
|
+
}
|
|
72
|
+
//#endregion
|
|
73
|
+
//#region src/types/errors.d.ts
|
|
74
|
+
/**
|
|
75
|
+
* Error and warning code vocabulary for x402check
|
|
76
|
+
*/
|
|
77
|
+
declare const ErrorCode: {
|
|
78
|
+
readonly INVALID_JSON: "INVALID_JSON";
|
|
79
|
+
readonly NOT_OBJECT: "NOT_OBJECT";
|
|
80
|
+
readonly UNKNOWN_FORMAT: "UNKNOWN_FORMAT";
|
|
81
|
+
readonly MISSING_VERSION: "MISSING_VERSION";
|
|
82
|
+
readonly INVALID_VERSION: "INVALID_VERSION";
|
|
83
|
+
readonly MISSING_ACCEPTS: "MISSING_ACCEPTS";
|
|
84
|
+
readonly EMPTY_ACCEPTS: "EMPTY_ACCEPTS";
|
|
85
|
+
readonly INVALID_ACCEPTS: "INVALID_ACCEPTS";
|
|
86
|
+
readonly MISSING_SCHEME: "MISSING_SCHEME";
|
|
87
|
+
readonly MISSING_NETWORK: "MISSING_NETWORK";
|
|
88
|
+
readonly INVALID_NETWORK_FORMAT: "INVALID_NETWORK_FORMAT";
|
|
89
|
+
readonly MISSING_AMOUNT: "MISSING_AMOUNT";
|
|
90
|
+
readonly INVALID_AMOUNT: "INVALID_AMOUNT";
|
|
91
|
+
readonly ZERO_AMOUNT: "ZERO_AMOUNT";
|
|
92
|
+
readonly MISSING_ASSET: "MISSING_ASSET";
|
|
93
|
+
readonly MISSING_PAY_TO: "MISSING_PAY_TO";
|
|
94
|
+
readonly MISSING_RESOURCE: "MISSING_RESOURCE";
|
|
95
|
+
readonly INVALID_URL: "INVALID_URL";
|
|
96
|
+
readonly INVALID_TIMEOUT: "INVALID_TIMEOUT";
|
|
97
|
+
readonly INVALID_EVM_ADDRESS: "INVALID_EVM_ADDRESS";
|
|
98
|
+
readonly BAD_EVM_CHECKSUM: "BAD_EVM_CHECKSUM";
|
|
99
|
+
readonly NO_EVM_CHECKSUM: "NO_EVM_CHECKSUM";
|
|
100
|
+
readonly INVALID_SOLANA_ADDRESS: "INVALID_SOLANA_ADDRESS";
|
|
101
|
+
readonly ADDRESS_NETWORK_MISMATCH: "ADDRESS_NETWORK_MISMATCH";
|
|
102
|
+
readonly UNKNOWN_NETWORK: "UNKNOWN_NETWORK";
|
|
103
|
+
readonly UNKNOWN_ASSET: "UNKNOWN_ASSET";
|
|
104
|
+
readonly LEGACY_FORMAT: "LEGACY_FORMAT";
|
|
105
|
+
readonly MISSING_MAX_TIMEOUT: "MISSING_MAX_TIMEOUT";
|
|
106
|
+
};
|
|
107
|
+
type ErrorCode = typeof ErrorCode[keyof typeof ErrorCode];
|
|
108
|
+
/**
|
|
109
|
+
* Human-readable error messages for all error codes
|
|
110
|
+
*/
|
|
111
|
+
declare const ErrorMessages: {
|
|
112
|
+
INVALID_JSON: string;
|
|
113
|
+
NOT_OBJECT: string;
|
|
114
|
+
UNKNOWN_FORMAT: string;
|
|
115
|
+
MISSING_VERSION: string;
|
|
116
|
+
INVALID_VERSION: string;
|
|
117
|
+
MISSING_ACCEPTS: string;
|
|
118
|
+
EMPTY_ACCEPTS: string;
|
|
119
|
+
INVALID_ACCEPTS: string;
|
|
120
|
+
MISSING_SCHEME: string;
|
|
121
|
+
MISSING_NETWORK: string;
|
|
122
|
+
INVALID_NETWORK_FORMAT: string;
|
|
123
|
+
MISSING_AMOUNT: string;
|
|
124
|
+
INVALID_AMOUNT: string;
|
|
125
|
+
ZERO_AMOUNT: string;
|
|
126
|
+
MISSING_ASSET: string;
|
|
127
|
+
MISSING_PAY_TO: string;
|
|
128
|
+
MISSING_RESOURCE: string;
|
|
129
|
+
INVALID_URL: string;
|
|
130
|
+
INVALID_TIMEOUT: string;
|
|
131
|
+
INVALID_EVM_ADDRESS: string;
|
|
132
|
+
BAD_EVM_CHECKSUM: string;
|
|
133
|
+
NO_EVM_CHECKSUM: string;
|
|
134
|
+
INVALID_SOLANA_ADDRESS: string;
|
|
135
|
+
ADDRESS_NETWORK_MISMATCH: string;
|
|
136
|
+
UNKNOWN_NETWORK: string;
|
|
137
|
+
UNKNOWN_ASSET: string;
|
|
138
|
+
LEGACY_FORMAT: string;
|
|
139
|
+
MISSING_MAX_TIMEOUT: string;
|
|
140
|
+
};
|
|
141
|
+
//#endregion
|
|
142
|
+
//#region src/types/validation.d.ts
|
|
143
|
+
/**
|
|
144
|
+
* Issue severity level
|
|
145
|
+
*/
|
|
146
|
+
type Severity = 'error' | 'warning';
|
|
147
|
+
/**
|
|
148
|
+
* Validation issue detail
|
|
149
|
+
*/
|
|
150
|
+
interface ValidationIssue {
|
|
151
|
+
code: ErrorCode;
|
|
152
|
+
field: string;
|
|
153
|
+
message: string;
|
|
154
|
+
severity: Severity;
|
|
155
|
+
fix?: string | undefined;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Validation result with errors, warnings, and normalized config
|
|
159
|
+
*/
|
|
160
|
+
interface ValidationResult {
|
|
161
|
+
valid: boolean;
|
|
162
|
+
version: ConfigFormat;
|
|
163
|
+
errors: ValidationIssue[];
|
|
164
|
+
warnings: ValidationIssue[];
|
|
165
|
+
normalized: NormalizedConfig | null;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Parsed input result (for parseInput utility)
|
|
169
|
+
*/
|
|
170
|
+
interface ParsedInput {
|
|
171
|
+
parsed: unknown;
|
|
172
|
+
error?: ValidationIssue | undefined;
|
|
173
|
+
}
|
|
174
|
+
//#endregion
|
|
175
|
+
//#region src/types/parse-input.d.ts
|
|
176
|
+
/**
|
|
177
|
+
* Parse input that may be either a JSON string or an object
|
|
178
|
+
* API-04: Accept string | object
|
|
179
|
+
*/
|
|
180
|
+
declare function parseInput(input: string | object): ParsedInput;
|
|
181
|
+
//#endregion
|
|
182
|
+
//#region src/registries/networks.d.ts
|
|
183
|
+
type NetworkType = 'evm' | 'solana' | 'stellar' | 'aptos';
|
|
184
|
+
interface NetworkInfo {
|
|
185
|
+
name: string;
|
|
186
|
+
type: NetworkType;
|
|
187
|
+
testnet: boolean;
|
|
188
|
+
}
|
|
189
|
+
declare const CAIP2_REGEX: RegExp;
|
|
190
|
+
declare const KNOWN_NETWORKS: {
|
|
191
|
+
readonly 'eip155:8453': {
|
|
192
|
+
readonly name: "Base";
|
|
193
|
+
readonly type: "evm";
|
|
194
|
+
readonly testnet: false;
|
|
195
|
+
};
|
|
196
|
+
readonly 'eip155:84532': {
|
|
197
|
+
readonly name: "Base Sepolia";
|
|
198
|
+
readonly type: "evm";
|
|
199
|
+
readonly testnet: true;
|
|
200
|
+
};
|
|
201
|
+
readonly 'eip155:43114': {
|
|
202
|
+
readonly name: "Avalanche C-Chain";
|
|
203
|
+
readonly type: "evm";
|
|
204
|
+
readonly testnet: false;
|
|
205
|
+
};
|
|
206
|
+
readonly 'eip155:43113': {
|
|
207
|
+
readonly name: "Avalanche Fuji";
|
|
208
|
+
readonly type: "evm";
|
|
209
|
+
readonly testnet: true;
|
|
210
|
+
};
|
|
211
|
+
readonly 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp': {
|
|
212
|
+
readonly name: "Solana Mainnet";
|
|
213
|
+
readonly type: "solana";
|
|
214
|
+
readonly testnet: false;
|
|
215
|
+
};
|
|
216
|
+
readonly 'solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1': {
|
|
217
|
+
readonly name: "Solana Devnet";
|
|
218
|
+
readonly type: "solana";
|
|
219
|
+
readonly testnet: true;
|
|
220
|
+
};
|
|
221
|
+
readonly 'solana:4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z': {
|
|
222
|
+
readonly name: "Solana Testnet";
|
|
223
|
+
readonly type: "solana";
|
|
224
|
+
readonly testnet: true;
|
|
225
|
+
};
|
|
226
|
+
readonly 'stellar:pubnet': {
|
|
227
|
+
readonly name: "Stellar Mainnet";
|
|
228
|
+
readonly type: "stellar";
|
|
229
|
+
readonly testnet: false;
|
|
230
|
+
};
|
|
231
|
+
readonly 'stellar:testnet': {
|
|
232
|
+
readonly name: "Stellar Testnet";
|
|
233
|
+
readonly type: "stellar";
|
|
234
|
+
readonly testnet: true;
|
|
235
|
+
};
|
|
236
|
+
readonly 'aptos:1': {
|
|
237
|
+
readonly name: "Aptos Mainnet";
|
|
238
|
+
readonly type: "aptos";
|
|
239
|
+
readonly testnet: false;
|
|
240
|
+
};
|
|
241
|
+
readonly 'aptos:2': {
|
|
242
|
+
readonly name: "Aptos Testnet";
|
|
243
|
+
readonly type: "aptos";
|
|
244
|
+
readonly testnet: true;
|
|
245
|
+
};
|
|
246
|
+
};
|
|
247
|
+
declare function isValidCaip2(value: string): boolean;
|
|
248
|
+
declare function isKnownNetwork(caip2: string): boolean;
|
|
249
|
+
declare function getNetworkInfo(caip2: string): NetworkInfo | undefined;
|
|
250
|
+
declare function getNetworkNamespace(caip2: string): string | undefined;
|
|
251
|
+
//#endregion
|
|
252
|
+
//#region src/registries/assets.d.ts
|
|
253
|
+
interface AssetInfo {
|
|
254
|
+
symbol: string;
|
|
255
|
+
name: string;
|
|
256
|
+
decimals: number;
|
|
257
|
+
}
|
|
258
|
+
declare const KNOWN_ASSETS: {
|
|
259
|
+
readonly 'eip155:8453': {
|
|
260
|
+
readonly '0x833589fcd6edb6e08f4c7c32d4f71b54bda02913': {
|
|
261
|
+
readonly symbol: "USDC";
|
|
262
|
+
readonly name: "USD Coin";
|
|
263
|
+
readonly decimals: 6;
|
|
264
|
+
};
|
|
265
|
+
};
|
|
266
|
+
readonly 'eip155:84532': {
|
|
267
|
+
readonly '0x036cbd53842c5426634e7929541ec2318f3dcf7e': {
|
|
268
|
+
readonly symbol: "USDC";
|
|
269
|
+
readonly name: "USD Coin";
|
|
270
|
+
readonly decimals: 6;
|
|
271
|
+
};
|
|
272
|
+
};
|
|
273
|
+
readonly 'eip155:43114': {
|
|
274
|
+
readonly '0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e': {
|
|
275
|
+
readonly symbol: "USDC";
|
|
276
|
+
readonly name: "USD Coin";
|
|
277
|
+
readonly decimals: 6;
|
|
278
|
+
};
|
|
279
|
+
};
|
|
280
|
+
readonly 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp': {
|
|
281
|
+
readonly EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v: {
|
|
282
|
+
readonly symbol: "USDC";
|
|
283
|
+
readonly name: "USD Coin";
|
|
284
|
+
readonly decimals: 6;
|
|
285
|
+
};
|
|
286
|
+
};
|
|
287
|
+
};
|
|
288
|
+
declare function isKnownAsset(network: string, address: string): boolean;
|
|
289
|
+
declare function getAssetInfo(network: string, address: string): AssetInfo | undefined;
|
|
290
|
+
//#endregion
|
|
291
|
+
//#region src/registries/simple-names.d.ts
|
|
292
|
+
declare const SIMPLE_NAME_TO_CAIP2: {
|
|
293
|
+
readonly base: "eip155:8453";
|
|
294
|
+
readonly 'base-sepolia': "eip155:84532";
|
|
295
|
+
readonly base_sepolia: "eip155:84532";
|
|
296
|
+
readonly avalanche: "eip155:43114";
|
|
297
|
+
readonly 'avalanche-fuji': "eip155:43113";
|
|
298
|
+
readonly solana: "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp";
|
|
299
|
+
readonly 'solana-devnet': "solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1";
|
|
300
|
+
readonly 'solana-testnet': "solana:4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z";
|
|
301
|
+
readonly stellar: "stellar:pubnet";
|
|
302
|
+
readonly 'stellar-testnet': "stellar:testnet";
|
|
303
|
+
readonly aptos: "aptos:1";
|
|
304
|
+
};
|
|
305
|
+
declare function getCanonicalNetwork(name: string): string | undefined;
|
|
306
|
+
//#endregion
|
|
307
|
+
//#region src/detection/detect.d.ts
|
|
308
|
+
/**
|
|
309
|
+
* Detect the format of an x402 config
|
|
310
|
+
*
|
|
311
|
+
* @param input - JSON string or parsed object
|
|
312
|
+
* @returns ConfigFormat literal: 'v2' | 'v1' | 'unknown'
|
|
313
|
+
*
|
|
314
|
+
* Detection requires x402Version field:
|
|
315
|
+
* 1. v2: accepts array + x402Version: 2
|
|
316
|
+
* 2. v1: accepts array + x402Version: 1
|
|
317
|
+
* 3. unknown: anything else (including versionless configs)
|
|
318
|
+
*/
|
|
319
|
+
declare function detect(input: string | object): ConfigFormat;
|
|
320
|
+
//#endregion
|
|
321
|
+
//#region src/detection/normalize.d.ts
|
|
322
|
+
/**
|
|
323
|
+
* Normalize any x402 config format to canonical v2 shape
|
|
324
|
+
*
|
|
325
|
+
* @param input - JSON string or parsed object
|
|
326
|
+
* @returns NormalizedConfig or null if format is unknown/invalid
|
|
327
|
+
*
|
|
328
|
+
* Normalization rules:
|
|
329
|
+
* - v2: Pass through with new object (FMT-07)
|
|
330
|
+
* - v1: Map maxAmountRequired → amount, lift per-entry resource (FMT-06)
|
|
331
|
+
* - unknown: Return null
|
|
332
|
+
*
|
|
333
|
+
* All transformations preserve extensions and extra fields (FMT-08)
|
|
334
|
+
*/
|
|
335
|
+
declare function normalize(input: string | object): NormalizedConfig | null;
|
|
336
|
+
//#endregion
|
|
337
|
+
//#region src/crypto/keccak256.d.ts
|
|
338
|
+
/**
|
|
339
|
+
* Keccak-256 hash function wrapper
|
|
340
|
+
* Uses @noble/hashes for audited, tree-shakeable implementation
|
|
341
|
+
*/
|
|
342
|
+
/**
|
|
343
|
+
* Compute Keccak-256 hash (NOT SHA-3)
|
|
344
|
+
*
|
|
345
|
+
* @param input - String or Uint8Array to hash
|
|
346
|
+
* @returns Lowercase hex string (64 chars, no 0x prefix)
|
|
347
|
+
*/
|
|
348
|
+
declare function keccak256(input: string | Uint8Array): string;
|
|
349
|
+
//#endregion
|
|
350
|
+
//#region src/crypto/base58.d.ts
|
|
351
|
+
/**
|
|
352
|
+
* Base58 decoder wrapper
|
|
353
|
+
* Uses @scure/base for audited, tree-shakeable implementation
|
|
354
|
+
*/
|
|
355
|
+
/**
|
|
356
|
+
* Decode a Base58-encoded string to bytes
|
|
357
|
+
*
|
|
358
|
+
* Preserves leading zero bytes (represented as leading '1' characters)
|
|
359
|
+
*
|
|
360
|
+
* @param input - Base58 string
|
|
361
|
+
* @returns Decoded bytes
|
|
362
|
+
* @throws Error if input contains invalid Base58 characters
|
|
363
|
+
*/
|
|
364
|
+
declare function decodeBase58(input: string): Uint8Array;
|
|
365
|
+
//#endregion
|
|
366
|
+
//#region src/crypto/eip55.d.ts
|
|
367
|
+
/**
|
|
368
|
+
* EIP-55 mixed-case checksum address encoding
|
|
369
|
+
* Spec: https://eips.ethereum.org/EIPS/eip-55
|
|
370
|
+
*/
|
|
371
|
+
/**
|
|
372
|
+
* Convert an Ethereum address to EIP-55 checksummed format
|
|
373
|
+
*
|
|
374
|
+
* @param address - 42-character hex address (0x-prefixed)
|
|
375
|
+
* @returns Checksummed address with mixed case
|
|
376
|
+
*/
|
|
377
|
+
declare function toChecksumAddress(address: string): string;
|
|
378
|
+
/**
|
|
379
|
+
* Check if an address has valid EIP-55 checksum
|
|
380
|
+
*
|
|
381
|
+
* Returns false for all-lowercase or all-uppercase addresses
|
|
382
|
+
* (these are valid formats but do not match their checksummed version)
|
|
383
|
+
*
|
|
384
|
+
* @param address - Address to validate
|
|
385
|
+
* @returns True if checksum is valid
|
|
386
|
+
*/
|
|
387
|
+
declare function isValidChecksum(address: string): boolean;
|
|
388
|
+
//#endregion
|
|
389
|
+
//#region src/validation/evm-address.d.ts
|
|
390
|
+
/**
|
|
391
|
+
* Validate an EVM address format and checksum
|
|
392
|
+
*
|
|
393
|
+
* Returns errors for invalid format, warnings for checksum issues
|
|
394
|
+
*
|
|
395
|
+
* @param address - Address to validate
|
|
396
|
+
* @param field - Field path for error reporting
|
|
397
|
+
* @returns Array of validation issues (empty if valid)
|
|
398
|
+
*/
|
|
399
|
+
declare function validateEvmAddress(address: string, field: string): ValidationIssue[];
|
|
400
|
+
//#endregion
|
|
401
|
+
//#region src/validation/solana-address.d.ts
|
|
402
|
+
/**
|
|
403
|
+
* Validate a Solana address (Base58 encoded public key)
|
|
404
|
+
*
|
|
405
|
+
* Checks Base58 format and verifies decoded length is exactly 32 bytes
|
|
406
|
+
*
|
|
407
|
+
* @param address - Address to validate
|
|
408
|
+
* @param field - Field path for error reporting
|
|
409
|
+
* @returns Array of validation issues (empty if valid)
|
|
410
|
+
*/
|
|
411
|
+
declare function validateSolanaAddress(address: string, field: string): ValidationIssue[];
|
|
412
|
+
//#endregion
|
|
413
|
+
//#region src/validation/address.d.ts
|
|
414
|
+
/**
|
|
415
|
+
* Validate an address for a specific network
|
|
416
|
+
*
|
|
417
|
+
* Dispatches to appropriate chain-specific validator based on CAIP-2 namespace:
|
|
418
|
+
* - eip155:* → EVM address validation
|
|
419
|
+
* - solana:* → Solana address validation
|
|
420
|
+
* - stellar:*, aptos:* → Accept any string (deep validation deferred)
|
|
421
|
+
* - Unknown namespaces → Accept any string (registry warnings handled elsewhere)
|
|
422
|
+
*
|
|
423
|
+
* Cross-chain mismatches are caught naturally by dispatch:
|
|
424
|
+
* - EVM address (0x...) on Solana network → fails Solana Base58 validation
|
|
425
|
+
* - Solana address on EVM network → fails EVM 0x-prefix validation
|
|
426
|
+
*
|
|
427
|
+
* @param address - Address to validate
|
|
428
|
+
* @param network - CAIP-2 network identifier
|
|
429
|
+
* @param field - Field path for error reporting
|
|
430
|
+
* @returns Array of validation issues (empty if valid)
|
|
431
|
+
*/
|
|
432
|
+
declare function validateAddress(address: string, network: string, field: string): ValidationIssue[];
|
|
433
|
+
//#endregion
|
|
434
|
+
//#region src/validation/orchestrator.d.ts
|
|
435
|
+
/**
|
|
436
|
+
* Options for the validate() orchestrator
|
|
437
|
+
*/
|
|
438
|
+
interface ValidationOptions {
|
|
439
|
+
/** When true, all warnings are promoted to errors */
|
|
440
|
+
strict?: boolean | undefined;
|
|
441
|
+
}
|
|
442
|
+
/**
|
|
443
|
+
* Validate an x402 config through the full pipeline.
|
|
444
|
+
*
|
|
445
|
+
* Takes any input (JSON string or object), runs it through:
|
|
446
|
+
* 1. Structure validation (parse, object check, format detection)
|
|
447
|
+
* 2. Normalization to canonical v2 shape
|
|
448
|
+
* 3. Version, accepts, resource validation
|
|
449
|
+
* 4. Per-entry field, network, asset, amount, timeout, address validation
|
|
450
|
+
* 5. Legacy format warnings
|
|
451
|
+
* 6. Strict mode promotion (warnings -> errors)
|
|
452
|
+
*
|
|
453
|
+
* NEVER throws -- all invalid inputs produce structured error results.
|
|
454
|
+
*
|
|
455
|
+
* @param input - JSON string or parsed object to validate
|
|
456
|
+
* @param options - Validation options (e.g. strict mode)
|
|
457
|
+
* @returns Structured validation result
|
|
458
|
+
*/
|
|
459
|
+
declare function validate(input: string | object, options?: ValidationOptions | undefined): ValidationResult;
|
|
460
|
+
//#endregion
|
|
461
|
+
//#region src/index.d.ts
|
|
462
|
+
declare const VERSION: "0.0.1";
|
|
463
|
+
//#endregion
|
|
464
|
+
export { AcceptsEntry, AssetInfo, CAIP2_REGEX, ConfigFormat, ErrorCode, ErrorMessages, KNOWN_ASSETS, KNOWN_NETWORKS, NetworkInfo, NetworkType, NormalizedConfig, ParsedInput, Resource, SIMPLE_NAME_TO_CAIP2, Severity, V1AcceptsEntry, V1Config, V2Config, VERSION, ValidationIssue, type ValidationOptions, ValidationResult, decodeBase58, detect, getAssetInfo, getCanonicalNetwork, getNetworkInfo, getNetworkNamespace, isKnownAsset, isKnownNetwork, isValidCaip2, isValidChecksum, keccak256, normalize, parseInput, toChecksumAddress, validate, validateAddress, validateEvmAddress, validateSolanaAddress };
|
|
465
|
+
//# sourceMappingURL=index.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/types/config.ts","../src/types/errors.ts","../src/types/validation.ts","../src/types/parse-input.ts","../src/registries/networks.ts","../src/registries/assets.ts","../src/registries/simple-names.ts","../src/detection/detect.ts","../src/detection/normalize.ts","../src/crypto/keccak256.ts","../src/crypto/base58.ts","../src/crypto/eip55.ts","../src/validation/evm-address.ts","../src/validation/solana-address.ts","../src/validation/address.ts","../src/validation/orchestrator.ts","../src/index.ts"],"mappings":";;AAOA;;;;;KAAY,YAAA;;;;UAKK,QAAA;EACf,GAAA;EACA,MAAA;EACA,OAAA,GAAU,MAAA;EACV,IAAA;AAAA;;AAMF;;UAAiB,YAAA;EACf,MAAA;EACA,OAAA;EACA,MAAA;EACA,KAAA;EACA,KAAA;EACA,iBAAA;EACA,KAAA,GAAQ,MAAA;AAAA;;;;UAMO,QAAA;EACf,WAAA;EACA,OAAA,EAAS,YAAA;EACT,QAAA,EAAU,QAAA;EACV,KAAA;EACA,UAAA,GAAa,MAAA;AAAA;;;;UAME,cAAA;EACf,MAAA;EACA,OAAA;EACA,iBAAA;EACA,KAAA;EACA,KAAA;EACA,iBAAA;EACA,KAAA,GAAQ,MAAA;EACR,QAAA,GAAW,QAAA;AAAA;;;;UAMI,QAAA;EACf,WAAA;EACA,OAAA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