@wasit-dev/core 0.5.0 → 0.7.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.
- package/README.md +12 -4
- package/dist/catalogue.d.ts +10 -0
- package/dist/catalogue.js +59 -3
- package/dist/check.d.ts +21 -0
- package/dist/check.js +27 -8
- package/dist/index.d.ts +5 -3
- package/dist/index.js +5 -2
- package/dist/mpp/charge.d.ts +23 -2
- package/dist/mpp/charge.js +93 -105
- package/dist/settlement.d.ts +93 -0
- package/dist/settlement.js +220 -0
- package/dist/x402/chains/evm.d.ts +65 -0
- package/dist/x402/chains/evm.js +234 -0
- package/dist/x402/chains/index.d.ts +10 -0
- package/dist/x402/chains/index.js +17 -0
- package/dist/x402/chains/stellar.d.ts +31 -0
- package/dist/x402/chains/stellar.js +153 -0
- package/dist/x402/chains/svm.d.ts +69 -0
- package/dist/x402/chains/svm.js +333 -0
- package/dist/x402/chains/types.d.ts +84 -0
- package/dist/x402/chains/types.js +10 -0
- package/dist/x402/chains/wait.d.ts +36 -0
- package/dist/x402/chains/wait.js +42 -0
- package/dist/x402/requirements.d.ts +45 -0
- package/dist/x402/requirements.js +326 -0
- package/dist/x402/simulator.d.ts +41 -2
- package/dist/x402/simulator.js +576 -165
- package/package.json +12 -7
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The payment terms an x402 challenge advertises, and the rules X402-04 and
|
|
3
|
+
* X402-05 hold them to.
|
|
4
|
+
*
|
|
5
|
+
* Split from the HTTP calls in simulator.ts so the rules can be exercised
|
|
6
|
+
* without a network. Nothing here is specific to one chain: x402 v2 names the
|
|
7
|
+
* network of every payment option with a CAIP-2 identifier, and a challenge
|
|
8
|
+
* may offer several options on several chains at once.
|
|
9
|
+
*/
|
|
10
|
+
import { skipped } from "../check.js";
|
|
11
|
+
function asRecord(value) {
|
|
12
|
+
return typeof value === "object" && value !== null
|
|
13
|
+
? value
|
|
14
|
+
: undefined;
|
|
15
|
+
}
|
|
16
|
+
function nonEmptyString(value) {
|
|
17
|
+
return typeof value === "string" && value.length > 0;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Every payment option a challenge offers, in order.
|
|
21
|
+
*
|
|
22
|
+
* x402 v2 nests the payment terms inside `accepts[]`. Each entry is a separate
|
|
23
|
+
* option, typically one per network or asset, so each is checked on its own:
|
|
24
|
+
* judging only the first would pass a challenge whose other options are broken,
|
|
25
|
+
* and fail one whose first option is on a chain the reader did not expect.
|
|
26
|
+
* An entry that is not an object is kept as `undefined`, so it reads as an
|
|
27
|
+
* option with every field missing rather than disappearing from the count.
|
|
28
|
+
*/
|
|
29
|
+
export function acceptsOf(payload) {
|
|
30
|
+
const accepts = asRecord(payload)?.["accepts"];
|
|
31
|
+
return Array.isArray(accepts) ? accepts.map(asRecord) : undefined;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The fields every payment option must carry, per protocol version (x402 v2
|
|
35
|
+
* spec 5.1.2; v1 spec 5.1).
|
|
36
|
+
*
|
|
37
|
+
* x402 v2 renamed `maxAmountRequired` to `amount` and moved `resource` and
|
|
38
|
+
* `description` out of the option. Checking for whichever price name happens
|
|
39
|
+
* to be present would hide a real conformance failure: a service advertising
|
|
40
|
+
* `x402Version: 2` while emitting the v1 field name is not conformant to the
|
|
41
|
+
* version it claims.
|
|
42
|
+
*/
|
|
43
|
+
const REQUIRED_FIELDS = {
|
|
44
|
+
2: ["scheme", "network", "amount", "asset", "payTo", "maxTimeoutSeconds"],
|
|
45
|
+
1: [
|
|
46
|
+
"scheme",
|
|
47
|
+
"network",
|
|
48
|
+
"maxAmountRequired",
|
|
49
|
+
"asset",
|
|
50
|
+
"payTo",
|
|
51
|
+
"resource",
|
|
52
|
+
"description",
|
|
53
|
+
"maxTimeoutSeconds",
|
|
54
|
+
],
|
|
55
|
+
};
|
|
56
|
+
const PRICE_FIELD = { 1: "maxAmountRequired", 2: "amount" };
|
|
57
|
+
/** One sentence per missing field, saying what to put there. */
|
|
58
|
+
const FIELD_FIXES = {
|
|
59
|
+
scheme: 'Add `scheme`, e.g. "exact": clients pick a payment option by its scheme.',
|
|
60
|
+
network: "Add `network` as a CAIP-2 id, e.g. stellar:testnet or eip155:84532.",
|
|
61
|
+
amount: 'Add `amount`: the price in the token\'s smallest unit, as a string (e.g. "10000").',
|
|
62
|
+
maxAmountRequired: "Add `maxAmountRequired`: the price in the token's smallest unit, as a string.",
|
|
63
|
+
asset: "Add `asset`: the address of the token the client pays in.",
|
|
64
|
+
payTo: "Add `payTo`: the address that receives the payment.",
|
|
65
|
+
resource: "Add `resource`: the URL of the paid resource.",
|
|
66
|
+
description: "Add `description`: a human-readable description of the resource.",
|
|
67
|
+
maxTimeoutSeconds: "Add `maxTimeoutSeconds`: the seconds a client has to complete payment.",
|
|
68
|
+
};
|
|
69
|
+
/** Said once whenever a field is missing: the usual cause is a hand-built 402. */
|
|
70
|
+
const SDK_NOTE = "The official x402 server SDK fills every required field, maxTimeoutSeconds defaulting to 300.";
|
|
71
|
+
function isSupportedVersion(value) {
|
|
72
|
+
return value === 1 || value === 2;
|
|
73
|
+
}
|
|
74
|
+
/** Names one option in a report: unprefixed when it is the only one. */
|
|
75
|
+
function optionLabel(index, count) {
|
|
76
|
+
return count === 1 ? "" : `accepts[${index}]: `;
|
|
77
|
+
}
|
|
78
|
+
function describeValue(value) {
|
|
79
|
+
return typeof value === "object" ? "an object" : `${typeof value} ${JSON.stringify(value)}`;
|
|
80
|
+
}
|
|
81
|
+
/** What is wrong with one payment option's fields, or undefined if nothing is. */
|
|
82
|
+
function fieldProblem(accept, version) {
|
|
83
|
+
const expected = PRICE_FIELD[version];
|
|
84
|
+
const wrongVersionField = version === 2 ? "maxAmountRequired" : "amount";
|
|
85
|
+
// A v2 challenge carrying the v1 field name is a specific, actionable
|
|
86
|
+
// failure — say which name was found and which one the version requires,
|
|
87
|
+
// rather than reporting the price as simply absent.
|
|
88
|
+
if (!nonEmptyString(accept?.[expected]) && accept?.[wrongVersionField] !== undefined) {
|
|
89
|
+
return {
|
|
90
|
+
detail: `Challenge advertises x402Version ${version} but carries ` +
|
|
91
|
+
`\`${wrongVersionField}\`, which is the v${version === 2 ? 1 : 2} field ` +
|
|
92
|
+
`name. v${version} requires \`${expected}\`.`,
|
|
93
|
+
fixes: [
|
|
94
|
+
`Rename \`${wrongVersionField}\` to \`${expected}\`, which is what v${version} ` +
|
|
95
|
+
`calls the price, or advertise x402Version ${version === 2 ? 1 : 2} if the ` +
|
|
96
|
+
`service speaks that version.`,
|
|
97
|
+
],
|
|
98
|
+
missing: false,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
const missing = [];
|
|
102
|
+
const wrongType = [];
|
|
103
|
+
for (const field of REQUIRED_FIELDS[version]) {
|
|
104
|
+
const value = accept?.[field];
|
|
105
|
+
if (value === undefined || value === null || value === "") {
|
|
106
|
+
missing.push(field);
|
|
107
|
+
}
|
|
108
|
+
else if (field === "maxTimeoutSeconds") {
|
|
109
|
+
// A zero or negative timeout leaves the client no time to pay.
|
|
110
|
+
if (typeof value !== "number" || !Number.isFinite(value) || value <= 0) {
|
|
111
|
+
wrongType.push(`maxTimeoutSeconds must be a positive number of seconds (got ${describeValue(value)})`);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
else if (typeof value !== "string") {
|
|
115
|
+
wrongType.push(`${field} must be a string (got ${describeValue(value)})`);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
if (missing.length === 0 && wrongType.length === 0)
|
|
119
|
+
return undefined;
|
|
120
|
+
const detail = [
|
|
121
|
+
missing.length > 0 ? `Missing: ${missing.join(", ")}.` : undefined,
|
|
122
|
+
wrongType.length > 0 ? `Wrong type: ${wrongType.join("; ")}.` : undefined,
|
|
123
|
+
]
|
|
124
|
+
.filter((part) => part !== undefined)
|
|
125
|
+
.join(" ");
|
|
126
|
+
const fixes = [
|
|
127
|
+
...missing.map((field) => FIELD_FIXES[field]),
|
|
128
|
+
...(wrongType.length > 0
|
|
129
|
+
? [
|
|
130
|
+
"Send each field with the type the spec gives it: strings for amounts " +
|
|
131
|
+
"and addresses, a number for maxTimeoutSeconds.",
|
|
132
|
+
]
|
|
133
|
+
: []),
|
|
134
|
+
];
|
|
135
|
+
return { detail, fixes, missing: missing.length > 0 };
|
|
136
|
+
}
|
|
137
|
+
/** X402-04: every payment option must carry the fields its version requires. */
|
|
138
|
+
export function checkRequiredFields(payload) {
|
|
139
|
+
const id = "X402-04";
|
|
140
|
+
const name = "Required Fields Present";
|
|
141
|
+
const version = asRecord(payload)?.["x402Version"];
|
|
142
|
+
if (!isSupportedVersion(version)) {
|
|
143
|
+
return {
|
|
144
|
+
id,
|
|
145
|
+
name,
|
|
146
|
+
pass: false,
|
|
147
|
+
detail: `Challenge advertises x402Version ${JSON.stringify(version)}, which is ` +
|
|
148
|
+
`neither 1 nor 2. The payment terms use different field names per ` +
|
|
149
|
+
`version, so they cannot be checked against an unknown one.`,
|
|
150
|
+
hint: "Set `x402Version` to 2, the current protocol version, and use its field names.",
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
const accepts = acceptsOf(payload);
|
|
154
|
+
if (accepts === undefined || accepts.length === 0) {
|
|
155
|
+
return {
|
|
156
|
+
id,
|
|
157
|
+
name,
|
|
158
|
+
pass: false,
|
|
159
|
+
detail: "Challenge offers no payment options: `accepts` is missing or empty, so " +
|
|
160
|
+
`there is no price, network or payTo to read.`,
|
|
161
|
+
hint: "List at least one payment option in `accepts`, each with " +
|
|
162
|
+
`${REQUIRED_FIELDS[version].join(", ")}.`,
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
const problems = accepts
|
|
166
|
+
.map((accept, index) => {
|
|
167
|
+
const problem = fieldProblem(accept, version);
|
|
168
|
+
return problem === undefined
|
|
169
|
+
? undefined
|
|
170
|
+
: { ...problem, detail: optionLabel(index, accepts.length) + problem.detail };
|
|
171
|
+
})
|
|
172
|
+
.filter((problem) => problem !== undefined);
|
|
173
|
+
if (problems.length > 0) {
|
|
174
|
+
const fixes = [
|
|
175
|
+
...new Set([
|
|
176
|
+
...problems.flatMap((problem) => problem.fixes),
|
|
177
|
+
...(problems.some((problem) => problem.missing) ? [SDK_NOTE] : []),
|
|
178
|
+
]),
|
|
179
|
+
];
|
|
180
|
+
return {
|
|
181
|
+
id,
|
|
182
|
+
name,
|
|
183
|
+
pass: false,
|
|
184
|
+
detail: problems.map((problem) => problem.detail).join(" "),
|
|
185
|
+
hint: fixes.join(" "),
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
return {
|
|
189
|
+
id,
|
|
190
|
+
name,
|
|
191
|
+
pass: true,
|
|
192
|
+
detail: accepts.length === 1
|
|
193
|
+
? `All required v${version} fields present.`
|
|
194
|
+
: `All required v${version} fields present in each of the ` +
|
|
195
|
+
`${accepts.length} payment options.`,
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
/** CAIP-2: `namespace:reference`, with the character sets the standard fixes. */
|
|
199
|
+
const CAIP2 = /^([-a-z0-9]{3,8}):([-_a-zA-Z0-9]{1,32})$/;
|
|
200
|
+
/** Base58 (bitcoin alphabet): no 0, O, I or l. */
|
|
201
|
+
const BASE58_32 = /^[1-9A-HJ-NP-Za-km-z]{32}$/;
|
|
202
|
+
const CAIP2_EXAMPLES = "stellar:testnet, eip155:84532 (Base Sepolia) or " +
|
|
203
|
+
"solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1 (Solana devnet)";
|
|
204
|
+
/** `eip155:0x14a34` is a common slip: `eth_chainId` returns hex. */
|
|
205
|
+
function eip155Fix(reference) {
|
|
206
|
+
if (/^0x[0-9a-f]+$/i.test(reference)) {
|
|
207
|
+
return `Write the chain id in base 10: eip155:${BigInt(reference).toString()}.`;
|
|
208
|
+
}
|
|
209
|
+
return "Use the chain id in base 10, as eth_chainId returns it converted from hex (Base Sepolia is eip155:84532).";
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Reference rules for the namespaces whose CAIP-2 definition fixes them.
|
|
213
|
+
* Each returns what is wrong with a reference, or undefined when it is right.
|
|
214
|
+
*
|
|
215
|
+
* - stellar: the namespace knows exactly two networks.
|
|
216
|
+
* - eip155: the EIP-155 chain id, in base 10 (`eth_chainId` returns hex,
|
|
217
|
+
* which the namespace converts).
|
|
218
|
+
* - solana: the first 32 characters of the base58 genesis hash.
|
|
219
|
+
*
|
|
220
|
+
* Sources: ChainAgnostic/namespaces `stellar`, `eip155`, `solana` caip2.md.
|
|
221
|
+
*/
|
|
222
|
+
const NAMESPACE_RULES = {
|
|
223
|
+
stellar: (reference) => reference === "testnet" || reference === "pubnet"
|
|
224
|
+
? undefined
|
|
225
|
+
: {
|
|
226
|
+
reason: `"stellar:${reference}" does not match stellar:testnet or stellar:pubnet, ` +
|
|
227
|
+
`the only Stellar networks CAIP-2 defines.`,
|
|
228
|
+
fix: "Use stellar:testnet or stellar:pubnet.",
|
|
229
|
+
},
|
|
230
|
+
eip155: (reference) => /^[1-9][0-9]*$/.test(reference)
|
|
231
|
+
? undefined
|
|
232
|
+
: {
|
|
233
|
+
reason: `"eip155:${reference}" does not carry an EIP-155 chain id in base 10, ` +
|
|
234
|
+
`which the eip155 namespace requires (Base Sepolia is eip155:84532).`,
|
|
235
|
+
fix: eip155Fix(reference),
|
|
236
|
+
},
|
|
237
|
+
solana: (reference) => BASE58_32.test(reference)
|
|
238
|
+
? undefined
|
|
239
|
+
: {
|
|
240
|
+
reason: `"solana:${reference}" is not the first 32 characters of a base58 ` +
|
|
241
|
+
`genesis hash, which the solana namespace requires (devnet is ` +
|
|
242
|
+
`solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1).`,
|
|
243
|
+
fix: "Use the first 32 characters of the cluster's genesis hash (RPC " +
|
|
244
|
+
"getGenesisHash): solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1 for devnet, " +
|
|
245
|
+
"solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp for mainnet.",
|
|
246
|
+
},
|
|
247
|
+
};
|
|
248
|
+
/**
|
|
249
|
+
* Validates one network identifier against CAIP-2, which x402 v2 requires,
|
|
250
|
+
* and against its namespace's own rules where Wasit knows them.
|
|
251
|
+
*
|
|
252
|
+
* A well-formed identifier in a namespace Wasit has no rules for is valid:
|
|
253
|
+
* x402 v2 asks for CAIP-2 and nothing more, and even encourages non-blockchain
|
|
254
|
+
* networks to follow it (`ach:us`). Failing it would report Wasit's own
|
|
255
|
+
* ignorance as the target's defect.
|
|
256
|
+
*/
|
|
257
|
+
export function validateNetwork(network) {
|
|
258
|
+
const match = CAIP2.exec(network);
|
|
259
|
+
if (match === null) {
|
|
260
|
+
return {
|
|
261
|
+
valid: false,
|
|
262
|
+
reason: `"${network}" is not a CAIP-2 identifier (namespace:reference, e.g. ` +
|
|
263
|
+
`stellar:testnet or eip155:84532), which x402 v2 requires.`,
|
|
264
|
+
fix: `Use the network's CAIP-2 id, namespace:reference, such as ${CAIP2_EXAMPLES}.`,
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
const namespace = match[1];
|
|
268
|
+
const rule = NAMESPACE_RULES[namespace];
|
|
269
|
+
if (rule === undefined)
|
|
270
|
+
return { valid: true, namespace, known: false };
|
|
271
|
+
const problem = rule(match[2]);
|
|
272
|
+
return problem === undefined
|
|
273
|
+
? { valid: true, namespace, known: true }
|
|
274
|
+
: { valid: false, ...problem };
|
|
275
|
+
}
|
|
276
|
+
/** X402-05: every advertised network identifier must be CAIP-2. */
|
|
277
|
+
export function checkNetworkIdentifier(payload) {
|
|
278
|
+
const id = "X402-05";
|
|
279
|
+
const name = "Network Identifier Valid";
|
|
280
|
+
const accepts = acceptsOf(payload) ?? [];
|
|
281
|
+
const advertised = accepts
|
|
282
|
+
.map((accept, index) => ({ index, network: accept?.["network"] }))
|
|
283
|
+
.filter((entry) => nonEmptyString(entry.network));
|
|
284
|
+
// Absent is X402-04's finding, not a second one: report it there only.
|
|
285
|
+
if (advertised.length === 0) {
|
|
286
|
+
return skipped(id, name, "the challenge carries no network field to validate (see X402-04).");
|
|
287
|
+
}
|
|
288
|
+
const v1 = asRecord(payload)?.["x402Version"] === 1;
|
|
289
|
+
const verdicts = advertised.map((entry) => ({ ...entry, verdict: validateNetwork(entry.network) }));
|
|
290
|
+
const invalid = verdicts.filter((entry) => !entry.verdict.valid);
|
|
291
|
+
if (invalid.length > 0) {
|
|
292
|
+
const problems = invalid.map((entry) => entry.verdict);
|
|
293
|
+
const reasons = invalid.map((entry, i) => optionLabel(entry.index, accepts.length) + problems[i].reason);
|
|
294
|
+
// x402 v1 named networks plainly ("base-sepolia"); saying so turns a bare
|
|
295
|
+
// FAIL into the one change that fixes it.
|
|
296
|
+
const v1Note = v1 ? " x402 v1 used plain names; v2 requires CAIP-2." : "";
|
|
297
|
+
return {
|
|
298
|
+
id,
|
|
299
|
+
name,
|
|
300
|
+
pass: false,
|
|
301
|
+
detail: reasons.join(" ") + v1Note,
|
|
302
|
+
hint: [...new Set(problems.map((problem) => problem.fix))].join(" "),
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
const unknownNamespaces = [
|
|
306
|
+
...new Set(verdicts
|
|
307
|
+
.map((entry) => entry.verdict)
|
|
308
|
+
.filter((verdict) => verdict.valid && !verdict.known)
|
|
309
|
+
.map((verdict) => verdict.namespace)),
|
|
310
|
+
];
|
|
311
|
+
const unknownNote = unknownNamespaces.length === 0
|
|
312
|
+
? ""
|
|
313
|
+
: ` Wasit has no further rules for the ${unknownNamespaces
|
|
314
|
+
.map((namespace) => `"${namespace}"`)
|
|
315
|
+
.join(", ")} namespace${unknownNamespaces.length === 1 ? "" : "s"}, ` +
|
|
316
|
+
`so only the CAIP-2 format was checked there.`;
|
|
317
|
+
const networks = advertised.map((entry) => entry.network);
|
|
318
|
+
return {
|
|
319
|
+
id,
|
|
320
|
+
name,
|
|
321
|
+
pass: true,
|
|
322
|
+
detail: (networks.length === 1
|
|
323
|
+
? `Network identifier "${networks[0]}" is valid.`
|
|
324
|
+
: `Network identifiers are valid: ${networks.join(", ")}.`) + unknownNote,
|
|
325
|
+
};
|
|
326
|
+
}
|
package/dist/x402/simulator.d.ts
CHANGED
|
@@ -43,16 +43,55 @@ export declare function readV1BodyChallenge(body: string): Record<string, unknow
|
|
|
43
43
|
* be evaluated, so one broken challenge produces one finding.
|
|
44
44
|
*/
|
|
45
45
|
export declare function runX402ReadChecks(options: X402SimulatorOptions): Promise<CheckResult[]>;
|
|
46
|
+
import { type PaymentChain } from "./chains/index.js";
|
|
47
|
+
export { corruptAuthSignature } from "./chains/stellar.js";
|
|
46
48
|
export interface X402PaymentCheckOptions extends RequestShape {
|
|
47
49
|
readonly target: string;
|
|
48
50
|
readonly network: string;
|
|
49
51
|
readonly payerSecretKey: string;
|
|
52
|
+
/** Overrides the default RPC endpoint used to verify settlement. */
|
|
53
|
+
readonly rpcUrl?: string;
|
|
50
54
|
/** See {@link X402SimulatorOptions.onResult} — same contract. */
|
|
51
55
|
readonly onResult?: (result: CheckResult) => void;
|
|
52
56
|
}
|
|
53
57
|
/**
|
|
54
|
-
*
|
|
58
|
+
* Reads the settlement a paid response reports, before anything is looked up.
|
|
55
59
|
*
|
|
56
|
-
*
|
|
60
|
+
* Takes the header decoder rather than the response so the rules can be
|
|
61
|
+
* exercised without a network. `readSettlement` throws when the response
|
|
62
|
+
* carries no `PAYMENT-RESPONSE` header, as `x402HTTPClient` does.
|
|
63
|
+
*/
|
|
64
|
+
export declare function readSettlementReference(status: number, readSettlement: () => {
|
|
65
|
+
readonly success: boolean;
|
|
66
|
+
readonly transaction?: string;
|
|
67
|
+
readonly errorReason?: string;
|
|
68
|
+
}, chain?: PaymentChain): {
|
|
69
|
+
readonly reference: string;
|
|
70
|
+
} | {
|
|
71
|
+
readonly failure: string;
|
|
72
|
+
readonly hint: string;
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* X402-07's verdict from the status a corrupted payment drew. Split out so
|
|
76
|
+
* the verdict can be tested without building a payment.
|
|
77
|
+
*/
|
|
78
|
+
export declare function signatureRejectionVerdict(status: number, reason?: string): CheckResult;
|
|
79
|
+
/** X402-08's verdict from the status the replayed payment drew. */
|
|
80
|
+
export declare function replayVerdict(status: number, reason?: string): CheckResult;
|
|
81
|
+
/** X402-09's verdict from the status the underpaid payment drew. */
|
|
82
|
+
export declare function underpaymentVerdict(status: number, offered: bigint, advertised: bigint, reason?: string): CheckResult;
|
|
83
|
+
/** X402-10's verdict from the status the expired payment drew. */
|
|
84
|
+
export declare function expiredVerdict(status: number, reason?: string): CheckResult;
|
|
85
|
+
/**
|
|
86
|
+
* Every check `runX402PaymentChecks` reports, in order. Front ends that list
|
|
87
|
+
* checks before a run use it, so a read-only run never shows these as pending.
|
|
88
|
+
*/
|
|
89
|
+
export declare const X402_PAYMENT_CHECK_IDS: readonly string[];
|
|
90
|
+
/**
|
|
91
|
+
* Runs X402-06 through X402-10 against a target.
|
|
92
|
+
*
|
|
93
|
+
* X402-06 settles a real payment. The negative checks send payments the
|
|
94
|
+
* target must refuse; a target that accepts the underpaid one may settle it.
|
|
95
|
+
* See docs/CHECKS.md.
|
|
57
96
|
*/
|
|
58
97
|
export declare function runX402PaymentChecks(options: X402PaymentCheckOptions): Promise<CheckResult[]>;
|