@agent-score/commerce 2.5.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.
- package/README.md +19 -17
- package/dist/challenge/index.d.mts +26 -2
- package/dist/challenge/index.d.ts +26 -2
- package/dist/challenge/index.js +14 -5
- package/dist/challenge/index.js.map +1 -1
- package/dist/challenge/index.mjs +14 -5
- package/dist/challenge/index.mjs.map +1 -1
- package/dist/{checkout-McfNpZJf.d.ts → checkout-C4RD7M0Z.d.ts} +46 -13
- package/dist/{checkout-o17dIxHi.d.mts → checkout-CzB9f_jf.d.mts} +46 -13
- package/dist/core.d.mts +20 -9
- package/dist/core.d.ts +20 -9
- package/dist/core.js +35 -24
- package/dist/core.js.map +1 -1
- package/dist/core.mjs +35 -24
- package/dist/core.mjs.map +1 -1
- package/dist/discovery/index.d.mts +17 -2
- package/dist/discovery/index.d.ts +17 -2
- package/dist/discovery/index.js +36 -12
- package/dist/discovery/index.js.map +1 -1
- package/dist/discovery/index.mjs +35 -12
- package/dist/discovery/index.mjs.map +1 -1
- package/dist/{gate-CWP10xPQ.d.mts → gate-D2RP6bZg.d.ts} +109 -141
- package/dist/{gate-CWP10xPQ.d.ts → gate-GCXy4FHI.d.mts} +109 -141
- package/dist/identity/express.d.mts +3 -1
- package/dist/identity/express.d.ts +3 -1
- package/dist/identity/express.js +164 -55
- package/dist/identity/express.js.map +1 -1
- package/dist/identity/express.mjs +164 -55
- package/dist/identity/express.mjs.map +1 -1
- package/dist/identity/fastify.d.mts +3 -1
- package/dist/identity/fastify.d.ts +3 -1
- package/dist/identity/fastify.js +171 -57
- package/dist/identity/fastify.js.map +1 -1
- package/dist/identity/fastify.mjs +171 -57
- package/dist/identity/fastify.mjs.map +1 -1
- package/dist/identity/hono.d.mts +3 -1
- package/dist/identity/hono.d.ts +3 -1
- package/dist/identity/hono.js +159 -59
- package/dist/identity/hono.js.map +1 -1
- package/dist/identity/hono.mjs +159 -59
- package/dist/identity/hono.mjs.map +1 -1
- package/dist/identity/nextjs.d.mts +3 -1
- package/dist/identity/nextjs.d.ts +3 -1
- package/dist/identity/nextjs.js +153 -56
- package/dist/identity/nextjs.js.map +1 -1
- package/dist/identity/nextjs.mjs +153 -56
- package/dist/identity/nextjs.mjs.map +1 -1
- package/dist/identity/policy.d.mts +21 -2
- package/dist/identity/policy.d.ts +21 -2
- package/dist/identity/policy.js +22 -1
- package/dist/identity/policy.js.map +1 -1
- package/dist/identity/policy.mjs +21 -1
- package/dist/identity/policy.mjs.map +1 -1
- package/dist/identity/web.d.mts +3 -1
- package/dist/identity/web.d.ts +3 -1
- package/dist/identity/web.js +153 -56
- package/dist/identity/web.js.map +1 -1
- package/dist/identity/web.mjs +153 -56
- package/dist/identity/web.mjs.map +1 -1
- package/dist/index.d.mts +55 -10
- package/dist/index.d.ts +55 -10
- package/dist/index.js +2211 -500
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2203 -500
- package/dist/index.mjs.map +1 -1
- package/dist/payment/index.d.mts +1 -1
- package/dist/payment/index.d.ts +1 -1
- package/dist/payment/index.js +10 -2
- package/dist/payment/index.js.map +1 -1
- package/dist/payment/index.mjs +10 -2
- package/dist/payment/index.mjs.map +1 -1
- package/dist/stripe-multichain/index.js +1614 -266
- package/dist/stripe-multichain/index.js.map +1 -1
- package/dist/stripe-multichain/index.mjs +1614 -266
- package/dist/stripe-multichain/index.mjs.map +1 -1
- package/dist/types-D1slMt0H.d.mts +137 -0
- package/dist/types-D1slMt0H.d.ts +137 -0
- package/dist/{wwwauthenticate-CVaGUMjU.d.mts → wwwauthenticate-Dgm-_af9.d.mts} +11 -1
- package/dist/{wwwauthenticate-CVaGUMjU.d.ts → wwwauthenticate-Dgm-_af9.d.ts} +11 -1
- package/package.json +23 -18
package/dist/index.mjs
CHANGED
|
@@ -4,11 +4,20 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
5
|
var __getProtoOf = Object.getPrototypeOf;
|
|
6
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __esm = (fn, res) => function __init() {
|
|
8
|
-
|
|
7
|
+
var __esm = (fn, res, err) => function __init() {
|
|
8
|
+
if (err) throw err[0];
|
|
9
|
+
try {
|
|
10
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
11
|
+
} catch (e) {
|
|
12
|
+
throw err = [e], e;
|
|
13
|
+
}
|
|
9
14
|
};
|
|
10
15
|
var __commonJS = (cb, mod) => function __require() {
|
|
11
|
-
|
|
16
|
+
try {
|
|
17
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
18
|
+
} catch (e) {
|
|
19
|
+
throw mod = 0, e;
|
|
20
|
+
}
|
|
12
21
|
};
|
|
13
22
|
var __export = (target, all) => {
|
|
14
23
|
for (var name in all)
|
|
@@ -191,7 +200,7 @@ function mppPaymentHandler({
|
|
|
191
200
|
networks: networks2
|
|
192
201
|
}) {
|
|
193
202
|
return {
|
|
194
|
-
"
|
|
203
|
+
"com.agentscore.payment.mpp": [{
|
|
195
204
|
id: "mpp",
|
|
196
205
|
version: HANDLER_VERSION,
|
|
197
206
|
spec: `${SPEC_BASE}/mpp`,
|
|
@@ -212,7 +221,7 @@ function x402PaymentHandler({
|
|
|
212
221
|
networks: networks2
|
|
213
222
|
}) {
|
|
214
223
|
return {
|
|
215
|
-
"
|
|
224
|
+
"com.agentscore.payment.x402": [{
|
|
216
225
|
id: "x402",
|
|
217
226
|
version: HANDLER_VERSION,
|
|
218
227
|
spec: `${SPEC_BASE}/x402`,
|
|
@@ -225,7 +234,7 @@ function stripeSptPaymentHandler({
|
|
|
225
234
|
spec
|
|
226
235
|
}) {
|
|
227
236
|
return {
|
|
228
|
-
"
|
|
237
|
+
"com.agentscore.payment.stripe_spt": [{
|
|
229
238
|
id: "stripe-spt",
|
|
230
239
|
version: HANDLER_VERSION,
|
|
231
240
|
spec: `${SPEC_BASE}/stripe_spt`,
|
|
@@ -243,10 +252,10 @@ var init_ucp = __esm({
|
|
|
243
252
|
fromJWK: ucpSigningKeyFromJWKImpl
|
|
244
253
|
};
|
|
245
254
|
DEFAULT_VERSION = "2026-04-08";
|
|
246
|
-
AGENTSCORE_CAPABILITY_NAME = "
|
|
255
|
+
AGENTSCORE_CAPABILITY_NAME = "com.agentscore.identity";
|
|
247
256
|
AGENTSCORE_CAPABILITY_VERSION = "2026-04-08";
|
|
248
|
-
AGENTSCORE_DEFAULT_SPEC_URL = "https://agentscore.
|
|
249
|
-
AGENTSCORE_DEFAULT_SCHEMA_URL = "https://agentscore.
|
|
257
|
+
AGENTSCORE_DEFAULT_SPEC_URL = "https://www.agentscore.com/specification/identity";
|
|
258
|
+
AGENTSCORE_DEFAULT_SCHEMA_URL = "https://www.agentscore.com/schemas/ucp/com-agentscore-identity-v1.json";
|
|
250
259
|
AGENTSCORE_EXTENDS = ["dev.ucp.shopping.checkout", "dev.ucp.shopping.cart"];
|
|
251
260
|
RESERVED_TOP_LEVEL = /* @__PURE__ */ new Set([
|
|
252
261
|
"ucp",
|
|
@@ -269,8 +278,8 @@ var init_ucp = __esm({
|
|
|
269
278
|
]);
|
|
270
279
|
AGENTSCORE_UCP_CAPABILITY = AGENTSCORE_CAPABILITY_NAME;
|
|
271
280
|
HANDLER_VERSION = "2026-04-08";
|
|
272
|
-
SPEC_BASE = "https://agentscore.
|
|
273
|
-
SCHEMA_BASE = "https://agentscore.
|
|
281
|
+
SPEC_BASE = "https://www.agentscore.com/specification/payment-handlers";
|
|
282
|
+
SCHEMA_BASE = "https://www.agentscore.com/schemas/payment-handlers";
|
|
274
283
|
CAIP2_TO_UCP_NETWORK = {
|
|
275
284
|
"eip155:8453": "base-8453",
|
|
276
285
|
"eip155:84532": "base-84532",
|
|
@@ -482,12 +491,12 @@ async function verifyUCPProfile(profile, jwks) {
|
|
|
482
491
|
`UCP signature header kid must be a non-empty string; got ${kid === void 0 ? "undefined" : typeof kid}.`
|
|
483
492
|
);
|
|
484
493
|
}
|
|
485
|
-
const
|
|
494
|
+
const matches2 = jwks.keys.filter(
|
|
486
495
|
(k) => k != null && typeof k === "object" && k.kid === kid
|
|
487
496
|
);
|
|
488
|
-
if (
|
|
489
|
-
if (
|
|
490
|
-
const matchedKey =
|
|
497
|
+
if (matches2.length === 0) throw new UCPVerificationError("kid_not_found", `No JWK in JWKS matching kid=${JSON.stringify(kid)}.`);
|
|
498
|
+
if (matches2.length > 1) throw new UCPVerificationError("duplicate_kid", `JWKS contains ${matches2.length} keys with kid=${JSON.stringify(kid)}; expected exactly one.`);
|
|
499
|
+
const matchedKey = matches2[0];
|
|
491
500
|
if (matchedKey.use != null && matchedKey.use !== "sig") {
|
|
492
501
|
throw new UCPVerificationError("unusable_key", `JWK with kid=${kid} has use=${JSON.stringify(matchedKey.use)}; expected "sig".`);
|
|
493
502
|
}
|
|
@@ -497,7 +506,7 @@ async function verifyUCPProfile(profile, jwks) {
|
|
|
497
506
|
`JWK alg ${JSON.stringify(matchedKey.alg)} does not match JWS header alg ${JSON.stringify(h.alg)}.`
|
|
498
507
|
);
|
|
499
508
|
}
|
|
500
|
-
return jose.importJWK(
|
|
509
|
+
return jose.importJWK(matches2[0], h.alg);
|
|
501
510
|
}
|
|
502
511
|
);
|
|
503
512
|
signedPayload = verified.payload;
|
|
@@ -726,7 +735,7 @@ var init_Errors = __esm({
|
|
|
726
735
|
const docsBaseUrl = options.docsOrigin ?? _BaseError.prototype.docsOrigin;
|
|
727
736
|
const docs = `${docsBaseUrl}${docsPath ?? ""}`;
|
|
728
737
|
const showVersion = Boolean(options.version ?? _BaseError.prototype.showVersion);
|
|
729
|
-
const
|
|
738
|
+
const version4 = options.version ?? _BaseError.prototype.version;
|
|
730
739
|
const message = [
|
|
731
740
|
shortMessage || "An error occurred.",
|
|
732
741
|
...options.metaMessages ? ["", ...options.metaMessages] : [],
|
|
@@ -734,7 +743,7 @@ var init_Errors = __esm({
|
|
|
734
743
|
"",
|
|
735
744
|
details ? `Details: ${details}` : void 0,
|
|
736
745
|
docsPath ? `See: ${docs}` : void 0,
|
|
737
|
-
showVersion ? `Version: ${
|
|
746
|
+
showVersion ? `Version: ${version4}` : void 0
|
|
738
747
|
] : []
|
|
739
748
|
].filter((x) => typeof x === "string").join("\n");
|
|
740
749
|
super(message, options.cause ? { cause: options.cause } : void 0);
|
|
@@ -799,7 +808,7 @@ var init_Errors = __esm({
|
|
|
799
808
|
this.docsPath = docsPath;
|
|
800
809
|
this.shortMessage = shortMessage;
|
|
801
810
|
this.showVersion = showVersion;
|
|
802
|
-
this.version =
|
|
811
|
+
this.version = version4;
|
|
803
812
|
}
|
|
804
813
|
walk(fn) {
|
|
805
814
|
return walk(this, fn);
|
|
@@ -929,16 +938,16 @@ var init_hmac = __esm({
|
|
|
929
938
|
this.blockLen = this.iHash.blockLen;
|
|
930
939
|
this.outputLen = this.iHash.outputLen;
|
|
931
940
|
const blockLen = this.blockLen;
|
|
932
|
-
const
|
|
933
|
-
|
|
934
|
-
for (let i = 0; i <
|
|
935
|
-
|
|
936
|
-
this.iHash.update(
|
|
941
|
+
const pad4 = new Uint8Array(blockLen);
|
|
942
|
+
pad4.set(key.length > blockLen ? hash3.create().update(key).digest() : key);
|
|
943
|
+
for (let i = 0; i < pad4.length; i++)
|
|
944
|
+
pad4[i] ^= 54;
|
|
945
|
+
this.iHash.update(pad4);
|
|
937
946
|
this.oHash = hash3.create();
|
|
938
|
-
for (let i = 0; i <
|
|
939
|
-
|
|
940
|
-
this.oHash.update(
|
|
941
|
-
clean(
|
|
947
|
+
for (let i = 0; i < pad4.length; i++)
|
|
948
|
+
pad4[i] ^= 54 ^ 92;
|
|
949
|
+
this.oHash.update(pad4);
|
|
950
|
+
clean(pad4);
|
|
942
951
|
}
|
|
943
952
|
update(buf) {
|
|
944
953
|
aexists(this);
|
|
@@ -1677,19 +1686,19 @@ function charCodeToBase16(char) {
|
|
|
1677
1686
|
return void 0;
|
|
1678
1687
|
}
|
|
1679
1688
|
function pad(bytes, options = {}) {
|
|
1680
|
-
const { dir, size:
|
|
1681
|
-
if (
|
|
1689
|
+
const { dir, size: size4 = 32 } = options;
|
|
1690
|
+
if (size4 === 0)
|
|
1682
1691
|
return bytes;
|
|
1683
|
-
if (bytes.length >
|
|
1692
|
+
if (bytes.length > size4)
|
|
1684
1693
|
throw new SizeExceedsPaddingSizeError({
|
|
1685
1694
|
size: bytes.length,
|
|
1686
|
-
targetSize:
|
|
1695
|
+
targetSize: size4,
|
|
1687
1696
|
type: "Bytes"
|
|
1688
1697
|
});
|
|
1689
|
-
const paddedBytes = new Uint8Array(
|
|
1690
|
-
for (let i = 0; i <
|
|
1698
|
+
const paddedBytes = new Uint8Array(size4);
|
|
1699
|
+
for (let i = 0; i < size4; i++) {
|
|
1691
1700
|
const padEnd = dir === "right";
|
|
1692
|
-
paddedBytes[padEnd ? i :
|
|
1701
|
+
paddedBytes[padEnd ? i : size4 - i - 1] = bytes[padEnd ? i : bytes.length - i - 1];
|
|
1693
1702
|
}
|
|
1694
1703
|
return paddedBytes;
|
|
1695
1704
|
}
|
|
@@ -1748,17 +1757,17 @@ function assertEndOffset2(value, start, end) {
|
|
|
1748
1757
|
}
|
|
1749
1758
|
}
|
|
1750
1759
|
function pad2(hex_, options = {}) {
|
|
1751
|
-
const { dir, size:
|
|
1752
|
-
if (
|
|
1760
|
+
const { dir, size: size4 = 32 } = options;
|
|
1761
|
+
if (size4 === 0)
|
|
1753
1762
|
return hex_;
|
|
1754
1763
|
const hex3 = hex_.replace("0x", "");
|
|
1755
|
-
if (hex3.length >
|
|
1764
|
+
if (hex3.length > size4 * 2)
|
|
1756
1765
|
throw new SizeExceedsPaddingSizeError2({
|
|
1757
1766
|
size: Math.ceil(hex3.length / 2),
|
|
1758
|
-
targetSize:
|
|
1767
|
+
targetSize: size4,
|
|
1759
1768
|
type: "Hex"
|
|
1760
1769
|
});
|
|
1761
|
-
return `0x${hex3[dir === "right" ? "padEnd" : "padStart"](
|
|
1770
|
+
return `0x${hex3[dir === "right" ? "padEnd" : "padStart"](size4 * 2, "0")}`;
|
|
1762
1771
|
}
|
|
1763
1772
|
function trim2(value, options = {}) {
|
|
1764
1773
|
const { dir = "left" } = options;
|
|
@@ -1915,14 +1924,14 @@ function fromBytes(value, options = {}) {
|
|
|
1915
1924
|
return hex3;
|
|
1916
1925
|
}
|
|
1917
1926
|
function fromNumber(value, options = {}) {
|
|
1918
|
-
const { signed, size:
|
|
1927
|
+
const { signed, size: size4 } = options;
|
|
1919
1928
|
const value_ = BigInt(value);
|
|
1920
1929
|
let maxValue;
|
|
1921
|
-
if (
|
|
1930
|
+
if (size4) {
|
|
1922
1931
|
if (signed)
|
|
1923
|
-
maxValue = (1n << BigInt(
|
|
1932
|
+
maxValue = (1n << BigInt(size4) * 8n - 1n) - 1n;
|
|
1924
1933
|
else
|
|
1925
|
-
maxValue = 2n ** (BigInt(
|
|
1934
|
+
maxValue = 2n ** (BigInt(size4) * 8n) - 1n;
|
|
1926
1935
|
} else if (typeof value === "number") {
|
|
1927
1936
|
maxValue = BigInt(Number.MAX_SAFE_INTEGER);
|
|
1928
1937
|
}
|
|
@@ -1933,14 +1942,14 @@ function fromNumber(value, options = {}) {
|
|
|
1933
1942
|
max: maxValue ? `${maxValue}${suffix}` : void 0,
|
|
1934
1943
|
min: `${minValue}${suffix}`,
|
|
1935
1944
|
signed,
|
|
1936
|
-
size:
|
|
1945
|
+
size: size4,
|
|
1937
1946
|
value: `${value}${suffix}`
|
|
1938
1947
|
});
|
|
1939
1948
|
}
|
|
1940
|
-
const stringValue = (signed && value_ < 0 ? BigInt.asUintN(
|
|
1949
|
+
const stringValue = (signed && value_ < 0 ? BigInt.asUintN(size4 * 8, BigInt(value_)) : value_).toString(16);
|
|
1941
1950
|
const hex3 = `0x${stringValue}`;
|
|
1942
|
-
if (
|
|
1943
|
-
return padLeft(hex3,
|
|
1951
|
+
if (size4)
|
|
1952
|
+
return padLeft(hex3, size4);
|
|
1944
1953
|
return hex3;
|
|
1945
1954
|
}
|
|
1946
1955
|
function fromString(value, options = {}) {
|
|
@@ -1949,11 +1958,11 @@ function fromString(value, options = {}) {
|
|
|
1949
1958
|
function isEqual(hexA, hexB) {
|
|
1950
1959
|
return equalBytes(fromHex(hexA), fromHex(hexB));
|
|
1951
1960
|
}
|
|
1952
|
-
function padLeft(value,
|
|
1953
|
-
return pad2(value, { dir: "left", size:
|
|
1961
|
+
function padLeft(value, size4) {
|
|
1962
|
+
return pad2(value, { dir: "left", size: size4 });
|
|
1954
1963
|
}
|
|
1955
|
-
function padRight(value,
|
|
1956
|
-
return pad2(value, { dir: "right", size:
|
|
1964
|
+
function padRight(value, size4) {
|
|
1965
|
+
return pad2(value, { dir: "right", size: size4 });
|
|
1957
1966
|
}
|
|
1958
1967
|
function random2(length) {
|
|
1959
1968
|
return fromBytes(random(length));
|
|
@@ -1982,8 +1991,8 @@ function toBigInt(hex3, options = {}) {
|
|
|
1982
1991
|
const value = BigInt(hex3);
|
|
1983
1992
|
if (!signed)
|
|
1984
1993
|
return value;
|
|
1985
|
-
const
|
|
1986
|
-
const max_unsigned = (1n << BigInt(
|
|
1994
|
+
const size4 = (hex3.length - 2) / 2;
|
|
1995
|
+
const max_unsigned = (1n << BigInt(size4) * 8n) - 1n;
|
|
1987
1996
|
const max_signed = max_unsigned >> 1n;
|
|
1988
1997
|
if (value <= max_signed)
|
|
1989
1998
|
return value;
|
|
@@ -2003,16 +2012,16 @@ function toBytes2(hex3, options = {}) {
|
|
|
2003
2012
|
return fromHex(hex3, options);
|
|
2004
2013
|
}
|
|
2005
2014
|
function toNumber(hex3, options = {}) {
|
|
2006
|
-
const { signed, size:
|
|
2007
|
-
if (!signed && !
|
|
2015
|
+
const { signed, size: size4 } = options;
|
|
2016
|
+
if (!signed && !size4)
|
|
2008
2017
|
return Number(hex3);
|
|
2009
2018
|
return Number(toBigInt(hex3, options));
|
|
2010
2019
|
}
|
|
2011
2020
|
function toString(hex3, options = {}) {
|
|
2012
|
-
const { size:
|
|
2021
|
+
const { size: size4 } = options;
|
|
2013
2022
|
let bytes = fromHex(hex3);
|
|
2014
|
-
if (
|
|
2015
|
-
assertSize(bytes,
|
|
2023
|
+
if (size4) {
|
|
2024
|
+
assertSize(bytes, size4);
|
|
2016
2025
|
bytes = trimRight(bytes);
|
|
2017
2026
|
}
|
|
2018
2027
|
return new TextDecoder().decode(bytes);
|
|
@@ -2039,8 +2048,8 @@ var init_Hex = __esm({
|
|
|
2039
2048
|
encoder = /* @__PURE__ */ new TextEncoder();
|
|
2040
2049
|
hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_v, i) => i.toString(16).padStart(2, "0"));
|
|
2041
2050
|
IntegerOutOfRangeError = class extends BaseError {
|
|
2042
|
-
constructor({ max, min, signed, size:
|
|
2043
|
-
super(`Number \`${value}\` is not in safe${
|
|
2051
|
+
constructor({ max, min, signed, size: size4, value }) {
|
|
2052
|
+
super(`Number \`${value}\` is not in safe${size4 ? ` ${size4 * 8}-bit` : ""}${signed ? " signed" : " unsigned"} integer range ${max ? `(\`${min}\` to \`${max}\`)` : `(above \`${min}\`)`}`);
|
|
2044
2053
|
Object.defineProperty(this, "name", {
|
|
2045
2054
|
enumerable: true,
|
|
2046
2055
|
configurable: true,
|
|
@@ -2117,8 +2126,8 @@ var init_Hex = __esm({
|
|
|
2117
2126
|
}
|
|
2118
2127
|
};
|
|
2119
2128
|
SliceOffsetOutOfBoundsError2 = class extends BaseError {
|
|
2120
|
-
constructor({ offset, position, size:
|
|
2121
|
-
super(`Slice ${position === "start" ? "starting" : "ending"} at offset \`${offset}\` is out-of-bounds (size: \`${
|
|
2129
|
+
constructor({ offset, position, size: size4 }) {
|
|
2130
|
+
super(`Slice ${position === "start" ? "starting" : "ending"} at offset \`${offset}\` is out-of-bounds (size: \`${size4}\`).`);
|
|
2122
2131
|
Object.defineProperty(this, "name", {
|
|
2123
2132
|
enumerable: true,
|
|
2124
2133
|
configurable: true,
|
|
@@ -2128,8 +2137,8 @@ var init_Hex = __esm({
|
|
|
2128
2137
|
}
|
|
2129
2138
|
};
|
|
2130
2139
|
SizeExceedsPaddingSizeError2 = class extends BaseError {
|
|
2131
|
-
constructor({ size:
|
|
2132
|
-
super(`${type.charAt(0).toUpperCase()}${type.slice(1).toLowerCase()} size (\`${
|
|
2140
|
+
constructor({ size: size4, targetSize, type }) {
|
|
2141
|
+
super(`${type.charAt(0).toUpperCase()}${type.slice(1).toLowerCase()} size (\`${size4}\`) exceeds padding size (\`${targetSize}\`).`);
|
|
2133
2142
|
Object.defineProperty(this, "name", {
|
|
2134
2143
|
enumerable: true,
|
|
2135
2144
|
configurable: true,
|
|
@@ -2208,21 +2217,21 @@ function fromArray(value) {
|
|
|
2208
2217
|
return value instanceof Uint8Array ? value : new Uint8Array(value);
|
|
2209
2218
|
}
|
|
2210
2219
|
function fromBoolean2(value, options = {}) {
|
|
2211
|
-
const { size:
|
|
2220
|
+
const { size: size4 } = options;
|
|
2212
2221
|
const bytes = new Uint8Array(1);
|
|
2213
2222
|
bytes[0] = Number(value);
|
|
2214
|
-
if (typeof
|
|
2215
|
-
assertSize(bytes,
|
|
2216
|
-
return padLeft2(bytes,
|
|
2223
|
+
if (typeof size4 === "number") {
|
|
2224
|
+
assertSize(bytes, size4);
|
|
2225
|
+
return padLeft2(bytes, size4);
|
|
2217
2226
|
}
|
|
2218
2227
|
return bytes;
|
|
2219
2228
|
}
|
|
2220
2229
|
function fromHex(value, options = {}) {
|
|
2221
|
-
const { size:
|
|
2230
|
+
const { size: size4 } = options;
|
|
2222
2231
|
let hex3 = value;
|
|
2223
|
-
if (
|
|
2224
|
-
assertSize2(value,
|
|
2225
|
-
hex3 = padRight(value,
|
|
2232
|
+
if (size4) {
|
|
2233
|
+
assertSize2(value, size4);
|
|
2234
|
+
hex3 = padRight(value, size4);
|
|
2226
2235
|
}
|
|
2227
2236
|
let hexString = hex3.slice(2);
|
|
2228
2237
|
if (hexString.length % 2)
|
|
@@ -2244,22 +2253,22 @@ function fromNumber2(value, options) {
|
|
|
2244
2253
|
return fromHex(hex3);
|
|
2245
2254
|
}
|
|
2246
2255
|
function fromString2(value, options = {}) {
|
|
2247
|
-
const { size:
|
|
2256
|
+
const { size: size4 } = options;
|
|
2248
2257
|
const bytes = encoder2.encode(value);
|
|
2249
|
-
if (typeof
|
|
2250
|
-
assertSize(bytes,
|
|
2251
|
-
return padRight2(bytes,
|
|
2258
|
+
if (typeof size4 === "number") {
|
|
2259
|
+
assertSize(bytes, size4);
|
|
2260
|
+
return padRight2(bytes, size4);
|
|
2252
2261
|
}
|
|
2253
2262
|
return bytes;
|
|
2254
2263
|
}
|
|
2255
2264
|
function isEqual2(bytesA, bytesB) {
|
|
2256
2265
|
return equalBytes(bytesA, bytesB);
|
|
2257
2266
|
}
|
|
2258
|
-
function padLeft2(value,
|
|
2259
|
-
return pad(value, { dir: "left", size:
|
|
2267
|
+
function padLeft2(value, size4) {
|
|
2268
|
+
return pad(value, { dir: "left", size: size4 });
|
|
2260
2269
|
}
|
|
2261
|
-
function padRight2(value,
|
|
2262
|
-
return pad(value, { dir: "right", size:
|
|
2270
|
+
function padRight2(value, size4) {
|
|
2271
|
+
return pad(value, { dir: "right", size: size4 });
|
|
2263
2272
|
}
|
|
2264
2273
|
function random(length) {
|
|
2265
2274
|
return crypto.getRandomValues(new Uint8Array(length));
|
|
@@ -2276,17 +2285,17 @@ function slice2(value, start, end, options = {}) {
|
|
|
2276
2285
|
return value_;
|
|
2277
2286
|
}
|
|
2278
2287
|
function toBigInt2(bytes, options = {}) {
|
|
2279
|
-
const { size:
|
|
2280
|
-
if (typeof
|
|
2281
|
-
assertSize(bytes,
|
|
2288
|
+
const { size: size4 } = options;
|
|
2289
|
+
if (typeof size4 !== "undefined")
|
|
2290
|
+
assertSize(bytes, size4);
|
|
2282
2291
|
const hex3 = fromBytes(bytes, options);
|
|
2283
2292
|
return toBigInt(hex3, options);
|
|
2284
2293
|
}
|
|
2285
2294
|
function toBoolean2(bytes, options = {}) {
|
|
2286
|
-
const { size:
|
|
2295
|
+
const { size: size4 } = options;
|
|
2287
2296
|
let bytes_ = bytes;
|
|
2288
|
-
if (typeof
|
|
2289
|
-
assertSize(bytes_,
|
|
2297
|
+
if (typeof size4 !== "undefined") {
|
|
2298
|
+
assertSize(bytes_, size4);
|
|
2290
2299
|
bytes_ = trimLeft2(bytes_);
|
|
2291
2300
|
}
|
|
2292
2301
|
if (bytes_.length > 1 || bytes_[0] > 1)
|
|
@@ -2297,17 +2306,17 @@ function toHex(value, options = {}) {
|
|
|
2297
2306
|
return fromBytes(value, options);
|
|
2298
2307
|
}
|
|
2299
2308
|
function toNumber2(bytes, options = {}) {
|
|
2300
|
-
const { size:
|
|
2301
|
-
if (typeof
|
|
2302
|
-
assertSize(bytes,
|
|
2309
|
+
const { size: size4 } = options;
|
|
2310
|
+
if (typeof size4 !== "undefined")
|
|
2311
|
+
assertSize(bytes, size4);
|
|
2303
2312
|
const hex3 = fromBytes(bytes, options);
|
|
2304
2313
|
return toNumber(hex3, options);
|
|
2305
2314
|
}
|
|
2306
2315
|
function toString2(bytes, options = {}) {
|
|
2307
|
-
const { size:
|
|
2316
|
+
const { size: size4 } = options;
|
|
2308
2317
|
let bytes_ = bytes;
|
|
2309
|
-
if (typeof
|
|
2310
|
-
assertSize(bytes_,
|
|
2318
|
+
if (typeof size4 !== "undefined") {
|
|
2319
|
+
assertSize(bytes_, size4);
|
|
2311
2320
|
bytes_ = trimRight(bytes_);
|
|
2312
2321
|
}
|
|
2313
2322
|
return decoder.decode(bytes_);
|
|
@@ -2378,8 +2387,8 @@ var init_Bytes = __esm({
|
|
|
2378
2387
|
}
|
|
2379
2388
|
};
|
|
2380
2389
|
SliceOffsetOutOfBoundsError = class extends BaseError {
|
|
2381
|
-
constructor({ offset, position, size:
|
|
2382
|
-
super(`Slice ${position === "start" ? "starting" : "ending"} at offset \`${offset}\` is out-of-bounds (size: \`${
|
|
2390
|
+
constructor({ offset, position, size: size4 }) {
|
|
2391
|
+
super(`Slice ${position === "start" ? "starting" : "ending"} at offset \`${offset}\` is out-of-bounds (size: \`${size4}\`).`);
|
|
2383
2392
|
Object.defineProperty(this, "name", {
|
|
2384
2393
|
enumerable: true,
|
|
2385
2394
|
configurable: true,
|
|
@@ -2389,8 +2398,8 @@ var init_Bytes = __esm({
|
|
|
2389
2398
|
}
|
|
2390
2399
|
};
|
|
2391
2400
|
SizeExceedsPaddingSizeError = class extends BaseError {
|
|
2392
|
-
constructor({ size:
|
|
2393
|
-
super(`${type.charAt(0).toUpperCase()}${type.slice(1).toLowerCase()} size (\`${
|
|
2401
|
+
constructor({ size: size4, targetSize, type }) {
|
|
2402
|
+
super(`${type.charAt(0).toUpperCase()}${type.slice(1).toLowerCase()} size (\`${size4}\`) exceeds padding size (\`${targetSize}\`).`);
|
|
2394
2403
|
Object.defineProperty(this, "name", {
|
|
2395
2404
|
enumerable: true,
|
|
2396
2405
|
configurable: true,
|
|
@@ -2460,7 +2469,7 @@ var init_lru = __esm({
|
|
|
2460
2469
|
"node_modules/ox/_esm/core/internal/lru.js"() {
|
|
2461
2470
|
"use strict";
|
|
2462
2471
|
LruMap = class extends Map {
|
|
2463
|
-
constructor(
|
|
2472
|
+
constructor(size4) {
|
|
2464
2473
|
super();
|
|
2465
2474
|
Object.defineProperty(this, "maxSize", {
|
|
2466
2475
|
enumerable: true,
|
|
@@ -2468,7 +2477,7 @@ var init_lru = __esm({
|
|
|
2468
2477
|
writable: true,
|
|
2469
2478
|
value: void 0
|
|
2470
2479
|
});
|
|
2471
|
-
this.maxSize =
|
|
2480
|
+
this.maxSize = size4;
|
|
2472
2481
|
}
|
|
2473
2482
|
get(key) {
|
|
2474
2483
|
const value = super.get(key);
|
|
@@ -2529,11 +2538,11 @@ function assert3(value, options = {}) {
|
|
|
2529
2538
|
});
|
|
2530
2539
|
}
|
|
2531
2540
|
}
|
|
2532
|
-
function checksum2(
|
|
2533
|
-
if (checksum.has(
|
|
2534
|
-
return checksum.get(
|
|
2535
|
-
assert3(
|
|
2536
|
-
const hexAddress =
|
|
2541
|
+
function checksum2(address3) {
|
|
2542
|
+
if (checksum.has(address3))
|
|
2543
|
+
return checksum.get(address3);
|
|
2544
|
+
assert3(address3, { strict: false });
|
|
2545
|
+
const hexAddress = address3.substring(2).toLowerCase();
|
|
2537
2546
|
const hash3 = keccak256(fromString2(hexAddress), { as: "Bytes" });
|
|
2538
2547
|
const characters = hexAddress.split("");
|
|
2539
2548
|
for (let i = 0; i < 40; i += 2) {
|
|
@@ -2545,7 +2554,7 @@ function checksum2(address2) {
|
|
|
2545
2554
|
}
|
|
2546
2555
|
}
|
|
2547
2556
|
const result = `0x${characters.join("")}`;
|
|
2548
|
-
checksum.set(
|
|
2557
|
+
checksum.set(address3, result);
|
|
2549
2558
|
return result;
|
|
2550
2559
|
}
|
|
2551
2560
|
var addressRegex, InvalidAddressError, InvalidInputError, InvalidChecksumError;
|
|
@@ -2558,8 +2567,8 @@ var init_Address = __esm({
|
|
|
2558
2567
|
init_Hash();
|
|
2559
2568
|
addressRegex = /^0x[a-fA-F0-9]{40}$/;
|
|
2560
2569
|
InvalidAddressError = class extends BaseError {
|
|
2561
|
-
constructor({ address:
|
|
2562
|
-
super(`Address "${
|
|
2570
|
+
constructor({ address: address3, cause }) {
|
|
2571
|
+
super(`Address "${address3}" is invalid.`, {
|
|
2563
2572
|
cause
|
|
2564
2573
|
});
|
|
2565
2574
|
Object.defineProperty(this, "name", {
|
|
@@ -2735,9 +2744,9 @@ var init_AbiParameters = __esm({
|
|
|
2735
2744
|
(function(encodePacked2) {
|
|
2736
2745
|
function encode2(type, value, isArray = false) {
|
|
2737
2746
|
if (type === "address") {
|
|
2738
|
-
const
|
|
2739
|
-
assert3(
|
|
2740
|
-
return padLeft(
|
|
2747
|
+
const address3 = value;
|
|
2748
|
+
assert3(address3);
|
|
2749
|
+
return padLeft(address3.toLowerCase(), isArray ? 32 : 0);
|
|
2741
2750
|
}
|
|
2742
2751
|
if (type === "string")
|
|
2743
2752
|
return fromString(value);
|
|
@@ -2748,18 +2757,18 @@ var init_AbiParameters = __esm({
|
|
|
2748
2757
|
const intMatch = type.match(integerRegex);
|
|
2749
2758
|
if (intMatch) {
|
|
2750
2759
|
const [_type, baseType, bits = "256"] = intMatch;
|
|
2751
|
-
const
|
|
2760
|
+
const size4 = Number.parseInt(bits, 10) / 8;
|
|
2752
2761
|
return fromNumber(value, {
|
|
2753
|
-
size: isArray ? 32 :
|
|
2762
|
+
size: isArray ? 32 : size4,
|
|
2754
2763
|
signed: baseType === "int"
|
|
2755
2764
|
});
|
|
2756
2765
|
}
|
|
2757
2766
|
const bytesMatch = type.match(bytesRegex);
|
|
2758
2767
|
if (bytesMatch) {
|
|
2759
|
-
const [_type,
|
|
2760
|
-
if (Number.parseInt(
|
|
2768
|
+
const [_type, size4] = bytesMatch;
|
|
2769
|
+
if (Number.parseInt(size4, 10) !== (value.length - 2) / 2)
|
|
2761
2770
|
throw new BytesSizeMismatchError({
|
|
2762
|
-
expectedSize: Number.parseInt(
|
|
2771
|
+
expectedSize: Number.parseInt(size4, 10),
|
|
2763
2772
|
value
|
|
2764
2773
|
});
|
|
2765
2774
|
return padRight(value, isArray ? 32 : 0);
|
|
@@ -2914,7 +2923,7 @@ __export(Base64_exports, {
|
|
|
2914
2923
|
toString: () => toString3
|
|
2915
2924
|
});
|
|
2916
2925
|
function fromBytes2(value, options = {}) {
|
|
2917
|
-
const { pad:
|
|
2926
|
+
const { pad: pad4 = true, url: url2 = false } = options;
|
|
2918
2927
|
const encoded = new Uint8Array(Math.ceil(value.length / 3) * 4);
|
|
2919
2928
|
for (let i = 0, j = 0; j < value.length; i += 4, j += 3) {
|
|
2920
2929
|
const y = (value[j] << 16) + (value[j + 1] << 8) + (value[j + 2] | 0);
|
|
@@ -2926,9 +2935,9 @@ function fromBytes2(value, options = {}) {
|
|
|
2926
2935
|
const k = value.length % 3;
|
|
2927
2936
|
const end = Math.floor(value.length / 3) * 4 + (k && k + 1);
|
|
2928
2937
|
let base643 = decoder2.decode(new Uint8Array(encoded.buffer, 0, end));
|
|
2929
|
-
if (
|
|
2938
|
+
if (pad4 && k === 1)
|
|
2930
2939
|
base643 += "==";
|
|
2931
|
-
if (
|
|
2940
|
+
if (pad4 && k === 2)
|
|
2932
2941
|
base643 += "=";
|
|
2933
2942
|
if (url2)
|
|
2934
2943
|
base643 = base643.replaceAll("+", "-").replaceAll("/", "_");
|
|
@@ -2942,8 +2951,8 @@ function fromString3(value, options = {}) {
|
|
|
2942
2951
|
}
|
|
2943
2952
|
function toBytes3(value) {
|
|
2944
2953
|
const base643 = value.replace(/=+$/, "");
|
|
2945
|
-
const
|
|
2946
|
-
const decoded = new Uint8Array(
|
|
2954
|
+
const size4 = base643.length;
|
|
2955
|
+
const decoded = new Uint8Array(size4 + 3);
|
|
2947
2956
|
encoder3.encodeInto(base643 + "===", decoded);
|
|
2948
2957
|
for (let i = 0, j = 0; i < base643.length; i += 4, j += 3) {
|
|
2949
2958
|
const x = (characterToInteger[decoded[i]] << 18) + (characterToInteger[decoded[i + 1]] << 12) + (characterToInteger[decoded[i + 2]] << 6) + characterToInteger[decoded[i + 3]];
|
|
@@ -2951,7 +2960,7 @@ function toBytes3(value) {
|
|
|
2951
2960
|
decoded[j + 1] = x >> 8 & 255;
|
|
2952
2961
|
decoded[j + 2] = x & 255;
|
|
2953
2962
|
}
|
|
2954
|
-
const decodedSize = (
|
|
2963
|
+
const decodedSize = (size4 >> 2) * 3 + (size4 % 4 && size4 % 4 - 1);
|
|
2955
2964
|
return new Uint8Array(decoded.buffer, 0, decodedSize);
|
|
2956
2965
|
}
|
|
2957
2966
|
function toHex2(value) {
|
|
@@ -3233,8 +3242,8 @@ var init_Cbor = __esm({
|
|
|
3233
3242
|
}
|
|
3234
3243
|
};
|
|
3235
3244
|
StringTooLargeError = class extends BaseError {
|
|
3236
|
-
constructor({ size:
|
|
3237
|
-
super(`String length exceeds maximum (4294967295): ${
|
|
3245
|
+
constructor({ size: size4 }) {
|
|
3246
|
+
super(`String length exceeds maximum (4294967295): ${size4}`);
|
|
3238
3247
|
Object.defineProperty(this, "name", {
|
|
3239
3248
|
enumerable: true,
|
|
3240
3249
|
configurable: true,
|
|
@@ -3244,8 +3253,8 @@ var init_Cbor = __esm({
|
|
|
3244
3253
|
}
|
|
3245
3254
|
};
|
|
3246
3255
|
ArrayTooLargeError = class extends BaseError {
|
|
3247
|
-
constructor({ size:
|
|
3248
|
-
super(`Array length exceeds maximum (4294967295): ${
|
|
3256
|
+
constructor({ size: size4 }) {
|
|
3257
|
+
super(`Array length exceeds maximum (4294967295): ${size4}`);
|
|
3249
3258
|
Object.defineProperty(this, "name", {
|
|
3250
3259
|
enumerable: true,
|
|
3251
3260
|
configurable: true,
|
|
@@ -3255,8 +3264,8 @@ var init_Cbor = __esm({
|
|
|
3255
3264
|
}
|
|
3256
3265
|
};
|
|
3257
3266
|
ObjectTooLargeError = class extends BaseError {
|
|
3258
|
-
constructor({ size:
|
|
3259
|
-
super(`Object size exceeds maximum (4294967295): ${
|
|
3267
|
+
constructor({ size: size4 }) {
|
|
3268
|
+
super(`Object size exceeds maximum (4294967295): ${size4}`);
|
|
3260
3269
|
Object.defineProperty(this, "name", {
|
|
3261
3270
|
enumerable: true,
|
|
3262
3271
|
configurable: true,
|
|
@@ -3266,8 +3275,8 @@ var init_Cbor = __esm({
|
|
|
3266
3275
|
}
|
|
3267
3276
|
};
|
|
3268
3277
|
ByteStringTooLargeError = class extends BaseError {
|
|
3269
|
-
constructor({ size:
|
|
3270
|
-
super(`Byte string length exceeds maximum (4294967295): ${
|
|
3278
|
+
constructor({ size: size4 }) {
|
|
3279
|
+
super(`Byte string length exceeds maximum (4294967295): ${size4}`);
|
|
3271
3280
|
Object.defineProperty(this, "name", {
|
|
3272
3281
|
enumerable: true,
|
|
3273
3282
|
configurable: true,
|
|
@@ -3332,37 +3341,37 @@ var init_Cbor = __esm({
|
|
|
3332
3341
|
};
|
|
3333
3342
|
throw new NumberTooLargeError({ number: value.toString(10) });
|
|
3334
3343
|
}
|
|
3335
|
-
const
|
|
3344
|
+
const positiveNumber2 = -1 - value;
|
|
3336
3345
|
if (value >= -24)
|
|
3337
3346
|
return {
|
|
3338
3347
|
length: 1,
|
|
3339
|
-
encode: (cursor) => cursor.pushUint8(32 +
|
|
3348
|
+
encode: (cursor) => cursor.pushUint8(32 + positiveNumber2)
|
|
3340
3349
|
};
|
|
3341
|
-
if (
|
|
3350
|
+
if (positiveNumber2 <= 255)
|
|
3342
3351
|
return {
|
|
3343
3352
|
length: 2,
|
|
3344
3353
|
// 1 byte prefix + 1 byte uint8
|
|
3345
3354
|
encode: (cursor) => {
|
|
3346
3355
|
cursor.pushUint8(56);
|
|
3347
|
-
cursor.pushUint8(
|
|
3356
|
+
cursor.pushUint8(positiveNumber2);
|
|
3348
3357
|
}
|
|
3349
3358
|
};
|
|
3350
|
-
if (
|
|
3359
|
+
if (positiveNumber2 <= 65535)
|
|
3351
3360
|
return {
|
|
3352
3361
|
length: 3,
|
|
3353
3362
|
// 1 byte prefix + 2 bytes uint16
|
|
3354
3363
|
encode: (cursor) => {
|
|
3355
3364
|
cursor.pushUint8(57);
|
|
3356
|
-
cursor.pushUint16(
|
|
3365
|
+
cursor.pushUint16(positiveNumber2);
|
|
3357
3366
|
}
|
|
3358
3367
|
};
|
|
3359
|
-
if (
|
|
3368
|
+
if (positiveNumber2 <= 4294967295)
|
|
3360
3369
|
return {
|
|
3361
3370
|
length: 5,
|
|
3362
3371
|
// 1 byte prefix + 4 bytes uint32
|
|
3363
3372
|
encode: (cursor) => {
|
|
3364
3373
|
cursor.pushUint8(58);
|
|
3365
|
-
cursor.pushUint32(
|
|
3374
|
+
cursor.pushUint32(positiveNumber2);
|
|
3366
3375
|
}
|
|
3367
3376
|
};
|
|
3368
3377
|
throw new NumberTooLargeError({ number: value.toString(10) });
|
|
@@ -3370,142 +3379,142 @@ var init_Cbor = __esm({
|
|
|
3370
3379
|
getEncodable2.number = number4;
|
|
3371
3380
|
function string4(value) {
|
|
3372
3381
|
const encoded = fromString2(value);
|
|
3373
|
-
const
|
|
3374
|
-
if (
|
|
3382
|
+
const size4 = encoded.length;
|
|
3383
|
+
if (size4 <= 23)
|
|
3375
3384
|
return {
|
|
3376
|
-
length: 1 +
|
|
3385
|
+
length: 1 + size4,
|
|
3377
3386
|
// 1 byte prefix + size bytes
|
|
3378
3387
|
encode(cursor) {
|
|
3379
|
-
cursor.pushUint8(96 +
|
|
3380
|
-
if (
|
|
3388
|
+
cursor.pushUint8(96 + size4);
|
|
3389
|
+
if (size4 > 0)
|
|
3381
3390
|
cursor.pushBytes(encoded);
|
|
3382
3391
|
}
|
|
3383
3392
|
};
|
|
3384
|
-
if (
|
|
3393
|
+
if (size4 <= 255)
|
|
3385
3394
|
return {
|
|
3386
|
-
length: 2 +
|
|
3395
|
+
length: 2 + size4,
|
|
3387
3396
|
// 1 byte prefix + 1 byte uint8 + size bytes
|
|
3388
3397
|
encode(cursor) {
|
|
3389
3398
|
cursor.pushUint8(120);
|
|
3390
|
-
cursor.pushUint8(
|
|
3399
|
+
cursor.pushUint8(size4);
|
|
3391
3400
|
cursor.pushBytes(encoded);
|
|
3392
3401
|
}
|
|
3393
3402
|
};
|
|
3394
|
-
if (
|
|
3403
|
+
if (size4 <= 65535)
|
|
3395
3404
|
return {
|
|
3396
|
-
length: 3 +
|
|
3405
|
+
length: 3 + size4,
|
|
3397
3406
|
// 1 byte prefix + 2 bytes uint16 + size bytes
|
|
3398
3407
|
encode(cursor) {
|
|
3399
3408
|
cursor.pushUint8(121);
|
|
3400
|
-
cursor.pushUint16(
|
|
3409
|
+
cursor.pushUint16(size4);
|
|
3401
3410
|
cursor.pushBytes(encoded);
|
|
3402
3411
|
}
|
|
3403
3412
|
};
|
|
3404
|
-
if (
|
|
3413
|
+
if (size4 <= 4294967295)
|
|
3405
3414
|
return {
|
|
3406
|
-
length: 5 +
|
|
3415
|
+
length: 5 + size4,
|
|
3407
3416
|
// 1 byte prefix + 4 bytes uint32 + size bytes
|
|
3408
3417
|
encode(cursor) {
|
|
3409
3418
|
cursor.pushUint8(122);
|
|
3410
|
-
cursor.pushUint32(
|
|
3419
|
+
cursor.pushUint32(size4);
|
|
3411
3420
|
cursor.pushBytes(encoded);
|
|
3412
3421
|
}
|
|
3413
3422
|
};
|
|
3414
|
-
throw new StringTooLargeError({ size:
|
|
3423
|
+
throw new StringTooLargeError({ size: size4 });
|
|
3415
3424
|
}
|
|
3416
3425
|
getEncodable2.string = string4;
|
|
3417
3426
|
function array2(value) {
|
|
3418
3427
|
const items = value.map((item) => getEncodable2(item));
|
|
3419
3428
|
const bodyLength = items.reduce((acc, item) => acc + item.length, 0);
|
|
3420
|
-
const
|
|
3421
|
-
if (
|
|
3429
|
+
const size4 = value.length;
|
|
3430
|
+
if (size4 <= 23)
|
|
3422
3431
|
return {
|
|
3423
3432
|
length: 1 + bodyLength,
|
|
3424
3433
|
// 1 byte prefix + body length
|
|
3425
3434
|
encode(cursor) {
|
|
3426
|
-
cursor.pushUint8(128 +
|
|
3435
|
+
cursor.pushUint8(128 + size4);
|
|
3427
3436
|
for (const item of items)
|
|
3428
3437
|
item.encode(cursor);
|
|
3429
3438
|
}
|
|
3430
3439
|
};
|
|
3431
|
-
if (
|
|
3440
|
+
if (size4 <= 255)
|
|
3432
3441
|
return {
|
|
3433
3442
|
length: 2 + bodyLength,
|
|
3434
3443
|
// 1 byte prefix + 1 byte uint8 + body length
|
|
3435
3444
|
encode(cursor) {
|
|
3436
3445
|
cursor.pushUint8(152);
|
|
3437
|
-
cursor.pushUint8(
|
|
3446
|
+
cursor.pushUint8(size4);
|
|
3438
3447
|
for (const item of items)
|
|
3439
3448
|
item.encode(cursor);
|
|
3440
3449
|
}
|
|
3441
3450
|
};
|
|
3442
|
-
if (
|
|
3451
|
+
if (size4 <= 65535)
|
|
3443
3452
|
return {
|
|
3444
3453
|
length: 3 + bodyLength,
|
|
3445
3454
|
// 1 byte prefix + 2 bytes uint16 + body length
|
|
3446
3455
|
encode(cursor) {
|
|
3447
3456
|
cursor.pushUint8(153);
|
|
3448
|
-
cursor.pushUint16(
|
|
3457
|
+
cursor.pushUint16(size4);
|
|
3449
3458
|
for (const item of items)
|
|
3450
3459
|
item.encode(cursor);
|
|
3451
3460
|
}
|
|
3452
3461
|
};
|
|
3453
|
-
if (
|
|
3462
|
+
if (size4 <= 4294967295)
|
|
3454
3463
|
return {
|
|
3455
3464
|
length: 5 + bodyLength,
|
|
3456
3465
|
// 1 byte prefix + 4 bytes uint32 + body length
|
|
3457
3466
|
encode(cursor) {
|
|
3458
3467
|
cursor.pushUint8(154);
|
|
3459
|
-
cursor.pushUint32(
|
|
3468
|
+
cursor.pushUint32(size4);
|
|
3460
3469
|
for (const item of items)
|
|
3461
3470
|
item.encode(cursor);
|
|
3462
3471
|
}
|
|
3463
3472
|
};
|
|
3464
|
-
throw new ArrayTooLargeError({ size:
|
|
3473
|
+
throw new ArrayTooLargeError({ size: size4 });
|
|
3465
3474
|
}
|
|
3466
3475
|
getEncodable2.array = array2;
|
|
3467
3476
|
function byteString(value) {
|
|
3468
|
-
const
|
|
3469
|
-
if (
|
|
3477
|
+
const size4 = value.byteLength;
|
|
3478
|
+
if (size4 <= 23)
|
|
3470
3479
|
return {
|
|
3471
|
-
length: 1 +
|
|
3480
|
+
length: 1 + size4,
|
|
3472
3481
|
// 1 byte prefix + size bytes
|
|
3473
3482
|
encode(cursor) {
|
|
3474
|
-
cursor.pushUint8(64 +
|
|
3483
|
+
cursor.pushUint8(64 + size4);
|
|
3475
3484
|
cursor.pushBytes(value);
|
|
3476
3485
|
}
|
|
3477
3486
|
};
|
|
3478
|
-
if (
|
|
3487
|
+
if (size4 <= 255)
|
|
3479
3488
|
return {
|
|
3480
|
-
length: 2 +
|
|
3489
|
+
length: 2 + size4,
|
|
3481
3490
|
// 1 byte prefix + 1 byte uint8 + size bytes
|
|
3482
3491
|
encode(cursor) {
|
|
3483
3492
|
cursor.pushUint8(88);
|
|
3484
|
-
cursor.pushUint8(
|
|
3493
|
+
cursor.pushUint8(size4);
|
|
3485
3494
|
cursor.pushBytes(value);
|
|
3486
3495
|
}
|
|
3487
3496
|
};
|
|
3488
|
-
if (
|
|
3497
|
+
if (size4 <= 65535)
|
|
3489
3498
|
return {
|
|
3490
|
-
length: 3 +
|
|
3499
|
+
length: 3 + size4,
|
|
3491
3500
|
// 1 byte prefix + 2 bytes uint16 + size bytes
|
|
3492
3501
|
encode(cursor) {
|
|
3493
3502
|
cursor.pushUint8(89);
|
|
3494
|
-
cursor.pushUint16(
|
|
3503
|
+
cursor.pushUint16(size4);
|
|
3495
3504
|
cursor.pushBytes(value);
|
|
3496
3505
|
}
|
|
3497
3506
|
};
|
|
3498
|
-
if (
|
|
3507
|
+
if (size4 <= 4294967295)
|
|
3499
3508
|
return {
|
|
3500
|
-
length: 5 +
|
|
3509
|
+
length: 5 + size4,
|
|
3501
3510
|
// 1 byte prefix + 4 bytes uint32 + size bytes
|
|
3502
3511
|
encode(cursor) {
|
|
3503
3512
|
cursor.pushUint8(90);
|
|
3504
|
-
cursor.pushUint32(
|
|
3513
|
+
cursor.pushUint32(size4);
|
|
3505
3514
|
cursor.pushBytes(value);
|
|
3506
3515
|
}
|
|
3507
3516
|
};
|
|
3508
|
-
throw new ByteStringTooLargeError({ size:
|
|
3517
|
+
throw new ByteStringTooLargeError({ size: size4 });
|
|
3509
3518
|
}
|
|
3510
3519
|
getEncodable2.byteString = byteString;
|
|
3511
3520
|
function object2(value) {
|
|
@@ -3515,59 +3524,59 @@ var init_Cbor = __esm({
|
|
|
3515
3524
|
value: getEncodable2(value[key])
|
|
3516
3525
|
}));
|
|
3517
3526
|
const bodyLength = entries.reduce((acc, entry) => acc + entry.key.length + entry.value.length, 0);
|
|
3518
|
-
const
|
|
3519
|
-
if (
|
|
3527
|
+
const size4 = keys.length;
|
|
3528
|
+
if (size4 <= 23)
|
|
3520
3529
|
return {
|
|
3521
3530
|
length: 1 + bodyLength,
|
|
3522
3531
|
// 1 byte prefix + body length
|
|
3523
3532
|
encode(cursor) {
|
|
3524
|
-
cursor.pushUint8(160 +
|
|
3533
|
+
cursor.pushUint8(160 + size4);
|
|
3525
3534
|
for (const entry of entries) {
|
|
3526
3535
|
entry.key.encode(cursor);
|
|
3527
3536
|
entry.value.encode(cursor);
|
|
3528
3537
|
}
|
|
3529
3538
|
}
|
|
3530
3539
|
};
|
|
3531
|
-
if (
|
|
3540
|
+
if (size4 <= 255)
|
|
3532
3541
|
return {
|
|
3533
3542
|
length: 2 + bodyLength,
|
|
3534
3543
|
// 1 byte prefix + 1 byte uint8 + body length
|
|
3535
3544
|
encode(cursor) {
|
|
3536
3545
|
cursor.pushUint8(184);
|
|
3537
|
-
cursor.pushUint8(
|
|
3546
|
+
cursor.pushUint8(size4);
|
|
3538
3547
|
for (const entry of entries) {
|
|
3539
3548
|
entry.key.encode(cursor);
|
|
3540
3549
|
entry.value.encode(cursor);
|
|
3541
3550
|
}
|
|
3542
3551
|
}
|
|
3543
3552
|
};
|
|
3544
|
-
if (
|
|
3553
|
+
if (size4 <= 65535)
|
|
3545
3554
|
return {
|
|
3546
3555
|
length: 3 + bodyLength,
|
|
3547
3556
|
// 1 byte prefix + 2 bytes uint16 + body length
|
|
3548
3557
|
encode(cursor) {
|
|
3549
3558
|
cursor.pushUint8(185);
|
|
3550
|
-
cursor.pushUint16(
|
|
3559
|
+
cursor.pushUint16(size4);
|
|
3551
3560
|
for (const entry of entries) {
|
|
3552
3561
|
entry.key.encode(cursor);
|
|
3553
3562
|
entry.value.encode(cursor);
|
|
3554
3563
|
}
|
|
3555
3564
|
}
|
|
3556
3565
|
};
|
|
3557
|
-
if (
|
|
3566
|
+
if (size4 <= 4294967295)
|
|
3558
3567
|
return {
|
|
3559
3568
|
length: 5 + bodyLength,
|
|
3560
3569
|
// 1 byte prefix + 4 bytes uint32 + body length
|
|
3561
3570
|
encode(cursor) {
|
|
3562
3571
|
cursor.pushUint8(186);
|
|
3563
|
-
cursor.pushUint32(
|
|
3572
|
+
cursor.pushUint32(size4);
|
|
3564
3573
|
for (const entry of entries) {
|
|
3565
3574
|
entry.key.encode(cursor);
|
|
3566
3575
|
entry.value.encode(cursor);
|
|
3567
3576
|
}
|
|
3568
3577
|
}
|
|
3569
3578
|
};
|
|
3570
|
-
throw new ObjectTooLargeError({ size:
|
|
3579
|
+
throw new ObjectTooLargeError({ size: size4 });
|
|
3571
3580
|
}
|
|
3572
3581
|
getEncodable2.object = object2;
|
|
3573
3582
|
function map2(value) {
|
|
@@ -3575,55 +3584,55 @@ var init_Cbor = __esm({
|
|
|
3575
3584
|
for (const [k, v] of value)
|
|
3576
3585
|
entries.push({ key: getEncodable2(k), value: getEncodable2(v) });
|
|
3577
3586
|
const bodyLength = entries.reduce((acc, entry) => acc + entry.key.length + entry.value.length, 0);
|
|
3578
|
-
const
|
|
3579
|
-
if (
|
|
3587
|
+
const size4 = value.size;
|
|
3588
|
+
if (size4 <= 23)
|
|
3580
3589
|
return {
|
|
3581
3590
|
length: 1 + bodyLength,
|
|
3582
3591
|
encode(cursor) {
|
|
3583
|
-
cursor.pushUint8(160 +
|
|
3592
|
+
cursor.pushUint8(160 + size4);
|
|
3584
3593
|
for (const entry of entries) {
|
|
3585
3594
|
entry.key.encode(cursor);
|
|
3586
3595
|
entry.value.encode(cursor);
|
|
3587
3596
|
}
|
|
3588
3597
|
}
|
|
3589
3598
|
};
|
|
3590
|
-
if (
|
|
3599
|
+
if (size4 <= 255)
|
|
3591
3600
|
return {
|
|
3592
3601
|
length: 2 + bodyLength,
|
|
3593
3602
|
encode(cursor) {
|
|
3594
3603
|
cursor.pushUint8(184);
|
|
3595
|
-
cursor.pushUint8(
|
|
3604
|
+
cursor.pushUint8(size4);
|
|
3596
3605
|
for (const entry of entries) {
|
|
3597
3606
|
entry.key.encode(cursor);
|
|
3598
3607
|
entry.value.encode(cursor);
|
|
3599
3608
|
}
|
|
3600
3609
|
}
|
|
3601
3610
|
};
|
|
3602
|
-
if (
|
|
3611
|
+
if (size4 <= 65535)
|
|
3603
3612
|
return {
|
|
3604
3613
|
length: 3 + bodyLength,
|
|
3605
3614
|
encode(cursor) {
|
|
3606
3615
|
cursor.pushUint8(185);
|
|
3607
|
-
cursor.pushUint16(
|
|
3616
|
+
cursor.pushUint16(size4);
|
|
3608
3617
|
for (const entry of entries) {
|
|
3609
3618
|
entry.key.encode(cursor);
|
|
3610
3619
|
entry.value.encode(cursor);
|
|
3611
3620
|
}
|
|
3612
3621
|
}
|
|
3613
3622
|
};
|
|
3614
|
-
if (
|
|
3623
|
+
if (size4 <= 4294967295)
|
|
3615
3624
|
return {
|
|
3616
3625
|
length: 5 + bodyLength,
|
|
3617
3626
|
encode(cursor) {
|
|
3618
3627
|
cursor.pushUint8(186);
|
|
3619
|
-
cursor.pushUint32(
|
|
3628
|
+
cursor.pushUint32(size4);
|
|
3620
3629
|
for (const entry of entries) {
|
|
3621
3630
|
entry.key.encode(cursor);
|
|
3622
3631
|
entry.value.encode(cursor);
|
|
3623
3632
|
}
|
|
3624
3633
|
}
|
|
3625
3634
|
};
|
|
3626
|
-
throw new ObjectTooLargeError({ size:
|
|
3635
|
+
throw new ObjectTooLargeError({ size: size4 });
|
|
3627
3636
|
}
|
|
3628
3637
|
getEncodable2.map = map2;
|
|
3629
3638
|
})(getEncodable || (getEncodable = {}));
|
|
@@ -5059,6 +5068,60 @@ var init_BodyDigest = __esm({
|
|
|
5059
5068
|
}
|
|
5060
5069
|
});
|
|
5061
5070
|
|
|
5071
|
+
// node_modules/mppx/dist/Constants.js
|
|
5072
|
+
var Constants_exports = {};
|
|
5073
|
+
__export(Constants_exports, {
|
|
5074
|
+
Headers: () => Headers2,
|
|
5075
|
+
Intents: () => Intents,
|
|
5076
|
+
MethodDetailKeys: () => MethodDetailKeys,
|
|
5077
|
+
Methods: () => Methods,
|
|
5078
|
+
Schemes: () => Schemes,
|
|
5079
|
+
SessionProtocols: () => SessionProtocols,
|
|
5080
|
+
getMethodDetail: () => getMethodDetail
|
|
5081
|
+
});
|
|
5082
|
+
function getMethodDetail(methodDetails, key) {
|
|
5083
|
+
if (!methodDetails || typeof methodDetails !== "object")
|
|
5084
|
+
return void 0;
|
|
5085
|
+
return methodDetails[key];
|
|
5086
|
+
}
|
|
5087
|
+
var Headers2, Schemes, Methods, Intents, MethodDetailKeys, SessionProtocols;
|
|
5088
|
+
var init_Constants = __esm({
|
|
5089
|
+
"node_modules/mppx/dist/Constants.js"() {
|
|
5090
|
+
"use strict";
|
|
5091
|
+
Headers2 = {
|
|
5092
|
+
acceptPayment: "Accept-Payment",
|
|
5093
|
+
authorization: "Authorization",
|
|
5094
|
+
paymentReceipt: "Payment-Receipt",
|
|
5095
|
+
paymentSession: "Payment-Session",
|
|
5096
|
+
paymentSessionSnapshot: "Payment-Session-Snapshot",
|
|
5097
|
+
wwwAuthenticate: "WWW-Authenticate"
|
|
5098
|
+
};
|
|
5099
|
+
Schemes = {
|
|
5100
|
+
payment: "Payment"
|
|
5101
|
+
};
|
|
5102
|
+
Methods = {
|
|
5103
|
+
evm: "evm",
|
|
5104
|
+
stripe: "stripe",
|
|
5105
|
+
tempo: "tempo"
|
|
5106
|
+
};
|
|
5107
|
+
Intents = {
|
|
5108
|
+
charge: "charge",
|
|
5109
|
+
session: "session",
|
|
5110
|
+
subscription: "subscription"
|
|
5111
|
+
};
|
|
5112
|
+
MethodDetailKeys = {
|
|
5113
|
+
sessionProtocol: "sessionProtocol",
|
|
5114
|
+
sessionSnapshot: "sessionSnapshot"
|
|
5115
|
+
};
|
|
5116
|
+
SessionProtocols = {
|
|
5117
|
+
/** Legacy contract-backed Tempo session protocol. */
|
|
5118
|
+
v1: "v1",
|
|
5119
|
+
/** TIP-1034 precompile-backed Tempo session protocol. */
|
|
5120
|
+
v2: "v2"
|
|
5121
|
+
};
|
|
5122
|
+
}
|
|
5123
|
+
});
|
|
5124
|
+
|
|
5062
5125
|
// node_modules/mppx/dist/PaymentRequest.js
|
|
5063
5126
|
var PaymentRequest_exports = {};
|
|
5064
5127
|
__export(PaymentRequest_exports, {
|
|
@@ -6221,10 +6284,10 @@ var init_regexes = __esm({
|
|
|
6221
6284
|
duration = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;
|
|
6222
6285
|
extendedDuration = /^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/;
|
|
6223
6286
|
guid = /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/;
|
|
6224
|
-
uuid = (
|
|
6225
|
-
if (!
|
|
6287
|
+
uuid = (version4) => {
|
|
6288
|
+
if (!version4)
|
|
6226
6289
|
return /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;
|
|
6227
|
-
return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${
|
|
6290
|
+
return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${version4}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`);
|
|
6228
6291
|
};
|
|
6229
6292
|
uuid4 = /* @__PURE__ */ uuid(4);
|
|
6230
6293
|
uuid6 = /* @__PURE__ */ uuid(6);
|
|
@@ -6513,8 +6576,8 @@ var init_checks = __esm({
|
|
|
6513
6576
|
});
|
|
6514
6577
|
inst._zod.check = (payload) => {
|
|
6515
6578
|
const input = payload.value;
|
|
6516
|
-
const
|
|
6517
|
-
if (
|
|
6579
|
+
const size4 = input.size;
|
|
6580
|
+
if (size4 <= def.maximum)
|
|
6518
6581
|
return;
|
|
6519
6582
|
payload.issues.push({
|
|
6520
6583
|
origin: getSizableOrigin(input),
|
|
@@ -6541,8 +6604,8 @@ var init_checks = __esm({
|
|
|
6541
6604
|
});
|
|
6542
6605
|
inst._zod.check = (payload) => {
|
|
6543
6606
|
const input = payload.value;
|
|
6544
|
-
const
|
|
6545
|
-
if (
|
|
6607
|
+
const size4 = input.size;
|
|
6608
|
+
if (size4 >= def.minimum)
|
|
6546
6609
|
return;
|
|
6547
6610
|
payload.issues.push({
|
|
6548
6611
|
origin: getSizableOrigin(input),
|
|
@@ -6570,10 +6633,10 @@ var init_checks = __esm({
|
|
|
6570
6633
|
});
|
|
6571
6634
|
inst._zod.check = (payload) => {
|
|
6572
6635
|
const input = payload.value;
|
|
6573
|
-
const
|
|
6574
|
-
if (
|
|
6636
|
+
const size4 = input.size;
|
|
6637
|
+
if (size4 === def.size)
|
|
6575
6638
|
return;
|
|
6576
|
-
const tooBig =
|
|
6639
|
+
const tooBig = size4 > def.size;
|
|
6577
6640
|
payload.issues.push({
|
|
6578
6641
|
origin: getSizableOrigin(input),
|
|
6579
6642
|
...tooBig ? { code: "too_big", maximum: def.size } : { code: "too_small", minimum: def.size },
|
|
@@ -7622,7 +7685,7 @@ var init_schemas = __esm({
|
|
|
7622
7685
|
try {
|
|
7623
7686
|
if (parts.length !== 2)
|
|
7624
7687
|
throw new Error();
|
|
7625
|
-
const [
|
|
7688
|
+
const [address3, prefix] = parts;
|
|
7626
7689
|
if (!prefix)
|
|
7627
7690
|
throw new Error();
|
|
7628
7691
|
const prefixNum = Number(prefix);
|
|
@@ -7630,7 +7693,7 @@ var init_schemas = __esm({
|
|
|
7630
7693
|
throw new Error();
|
|
7631
7694
|
if (prefixNum < 0 || prefixNum > 128)
|
|
7632
7695
|
throw new Error();
|
|
7633
|
-
new URL(`http://[${
|
|
7696
|
+
new URL(`http://[${address3}]`);
|
|
7634
7697
|
} catch {
|
|
7635
7698
|
payload.issues.push({
|
|
7636
7699
|
code: "invalid_format",
|
|
@@ -15983,11 +16046,11 @@ function _minSize(minimum, params) {
|
|
|
15983
16046
|
});
|
|
15984
16047
|
}
|
|
15985
16048
|
// @__NO_SIDE_EFFECTS__
|
|
15986
|
-
function _size(
|
|
16049
|
+
function _size(size4, params) {
|
|
15987
16050
|
return new $ZodCheckSizeEquals({
|
|
15988
16051
|
check: "size_equals",
|
|
15989
16052
|
...normalizeParams(params),
|
|
15990
|
-
size:
|
|
16053
|
+
size: size4
|
|
15991
16054
|
});
|
|
15992
16055
|
}
|
|
15993
16056
|
// @__NO_SIDE_EFFECTS__
|
|
@@ -19401,7 +19464,7 @@ function fromMethod2(method, parameters) {
|
|
|
19401
19464
|
const { description, digest, expires, id, meta: meta4, realm, secretKey } = parameters;
|
|
19402
19465
|
const request = fromMethod(method, parameters.request);
|
|
19403
19466
|
return from4({
|
|
19404
|
-
...id ? { id } : { secretKey },
|
|
19467
|
+
...id !== void 0 ? { id } : { secretKey },
|
|
19405
19468
|
realm,
|
|
19406
19469
|
method: methodName,
|
|
19407
19470
|
intent,
|
|
@@ -19414,23 +19477,28 @@ function fromMethod2(method, parameters) {
|
|
|
19414
19477
|
}
|
|
19415
19478
|
function serialize2(challenge) {
|
|
19416
19479
|
const parts = [
|
|
19417
|
-
|
|
19418
|
-
|
|
19419
|
-
|
|
19420
|
-
|
|
19421
|
-
|
|
19480
|
+
authParam("id", challenge.id),
|
|
19481
|
+
authParam("realm", challenge.realm),
|
|
19482
|
+
authParam("method", challenge.method),
|
|
19483
|
+
authParam("intent", challenge.intent),
|
|
19484
|
+
authParam("request", serialize(challenge.request))
|
|
19422
19485
|
];
|
|
19423
19486
|
if (challenge.description !== void 0)
|
|
19424
|
-
parts.push(
|
|
19487
|
+
parts.push(authParam("description", challenge.description));
|
|
19425
19488
|
if (challenge.digest !== void 0)
|
|
19426
|
-
parts.push(
|
|
19489
|
+
parts.push(authParam("digest", challenge.digest));
|
|
19427
19490
|
if (challenge.expires !== void 0)
|
|
19428
|
-
parts.push(
|
|
19491
|
+
parts.push(authParam("expires", challenge.expires));
|
|
19429
19492
|
if (challenge.opaque !== void 0)
|
|
19430
|
-
parts.push(
|
|
19493
|
+
parts.push(authParam("opaque", challenge.opaque));
|
|
19431
19494
|
else if (challenge.meta !== void 0)
|
|
19432
|
-
parts.push(
|
|
19433
|
-
return
|
|
19495
|
+
parts.push(authParam("opaque", serialize(challenge.meta)));
|
|
19496
|
+
return `${Schemes.payment} ${parts.join(", ")}`;
|
|
19497
|
+
}
|
|
19498
|
+
function authParam(name, value) {
|
|
19499
|
+
if (/[\r\n]/.test(value))
|
|
19500
|
+
throw new Error("Invalid quoted-string value.");
|
|
19501
|
+
return `${name}="${value.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`;
|
|
19434
19502
|
}
|
|
19435
19503
|
function deserialize2(value, options) {
|
|
19436
19504
|
const params = extractPaymentAuthParams(value);
|
|
@@ -19440,6 +19508,8 @@ function deserialize2(value, options) {
|
|
|
19440
19508
|
const { request, opaque, ...rest } = result;
|
|
19441
19509
|
if (!request)
|
|
19442
19510
|
throw new Error("Missing request parameter.");
|
|
19511
|
+
if (request.length > maxRequestParameterLength)
|
|
19512
|
+
throw new Error("Request parameter too large.");
|
|
19443
19513
|
if (rest.method && !/^[a-z][a-z0-9:_-]*$/.test(rest.method))
|
|
19444
19514
|
throw new Error(`Invalid method: "${rest.method}". Must be lowercase per spec.`);
|
|
19445
19515
|
return from4({
|
|
@@ -19449,7 +19519,7 @@ function deserialize2(value, options) {
|
|
|
19449
19519
|
}, options);
|
|
19450
19520
|
}
|
|
19451
19521
|
function extractPaymentAuthParams(header) {
|
|
19452
|
-
const token =
|
|
19522
|
+
const token = Schemes.payment;
|
|
19453
19523
|
let inQuotes = false;
|
|
19454
19524
|
let escaped = false;
|
|
19455
19525
|
for (let i = 0; i < header.length; i++) {
|
|
@@ -19518,23 +19588,30 @@ function readAuthParamValue(input, start) {
|
|
|
19518
19588
|
}
|
|
19519
19589
|
function readQuotedAuthParamValue(input, start) {
|
|
19520
19590
|
let i = start;
|
|
19521
|
-
let value = "";
|
|
19522
19591
|
let escaped = false;
|
|
19592
|
+
let segmentStart = start;
|
|
19593
|
+
let parts;
|
|
19523
19594
|
while (i < input.length) {
|
|
19524
19595
|
const char = input[i];
|
|
19525
19596
|
i++;
|
|
19526
19597
|
if (escaped) {
|
|
19527
|
-
|
|
19598
|
+
parts ??= [];
|
|
19599
|
+
parts.push(char);
|
|
19600
|
+
segmentStart = i;
|
|
19528
19601
|
escaped = false;
|
|
19529
19602
|
continue;
|
|
19530
19603
|
}
|
|
19531
19604
|
if (char === "\\") {
|
|
19605
|
+
parts ??= [];
|
|
19606
|
+
parts.push(input.slice(segmentStart, i - 1));
|
|
19607
|
+
segmentStart = i;
|
|
19532
19608
|
escaped = true;
|
|
19533
19609
|
continue;
|
|
19534
19610
|
}
|
|
19535
|
-
if (char === '"')
|
|
19611
|
+
if (char === '"') {
|
|
19612
|
+
const value = parts ? [...parts, input.slice(segmentStart, i - 1)].join("") : input.slice(start, i - 1);
|
|
19536
19613
|
return [value, i];
|
|
19537
|
-
|
|
19614
|
+
}
|
|
19538
19615
|
}
|
|
19539
19616
|
throw new Error("Unterminated quoted-string.");
|
|
19540
19617
|
}
|
|
@@ -19545,9 +19622,9 @@ function startsWithSchemeToken(value, index, token) {
|
|
|
19545
19622
|
return Boolean(next && /\s/.test(next));
|
|
19546
19623
|
}
|
|
19547
19624
|
function fromHeaders(headers, options) {
|
|
19548
|
-
const header = headers.get(
|
|
19625
|
+
const header = headers.get(Headers2.wwwAuthenticate);
|
|
19549
19626
|
if (!header)
|
|
19550
|
-
throw new Error(
|
|
19627
|
+
throw new Error(`Missing ${Headers2.wwwAuthenticate} header.`);
|
|
19551
19628
|
return deserialize2(header, options);
|
|
19552
19629
|
}
|
|
19553
19630
|
function fromResponse(response, options) {
|
|
@@ -19561,14 +19638,15 @@ function fromResponseList(response, options) {
|
|
|
19561
19638
|
return fromHeadersList(response.headers, options);
|
|
19562
19639
|
}
|
|
19563
19640
|
function fromHeadersList(headers, options) {
|
|
19564
|
-
const header = headers.get(
|
|
19641
|
+
const header = headers.get(Headers2.wwwAuthenticate);
|
|
19565
19642
|
if (!header)
|
|
19566
|
-
throw new Error(
|
|
19643
|
+
throw new Error(`Missing ${Headers2.wwwAuthenticate} header.`);
|
|
19567
19644
|
return deserializeList(header, options);
|
|
19568
19645
|
}
|
|
19569
19646
|
function deserializeList(value, options) {
|
|
19570
19647
|
const starts = [];
|
|
19571
|
-
|
|
19648
|
+
const schemePattern = new RegExp(`${Schemes.payment}\\s+`, "gi");
|
|
19649
|
+
for (const match of value.matchAll(schemePattern)) {
|
|
19572
19650
|
starts.push(match.index);
|
|
19573
19651
|
}
|
|
19574
19652
|
if (starts.length === 0)
|
|
@@ -19604,14 +19682,16 @@ function computeId(challenge, options) {
|
|
|
19604
19682
|
const mac3 = Hash_exports.hmac256(key, data, { as: "Bytes" });
|
|
19605
19683
|
return Base64_exports.fromBytes(mac3, { url: true, pad: false });
|
|
19606
19684
|
}
|
|
19607
|
-
var Schema;
|
|
19685
|
+
var maxRequestParameterLength, Schema;
|
|
19608
19686
|
var init_Challenge = __esm({
|
|
19609
19687
|
"node_modules/mppx/dist/Challenge.js"() {
|
|
19610
19688
|
"use strict";
|
|
19611
19689
|
init_esm2();
|
|
19690
|
+
init_Constants();
|
|
19612
19691
|
init_constantTimeEqual();
|
|
19613
19692
|
init_PaymentRequest();
|
|
19614
19693
|
init_zod();
|
|
19694
|
+
maxRequestParameterLength = 16 * 1024;
|
|
19615
19695
|
Schema = object({
|
|
19616
19696
|
/** Optional human-readable description of the payment. */
|
|
19617
19697
|
description: optional(string2()),
|
|
@@ -19620,7 +19700,7 @@ var init_Challenge = __esm({
|
|
|
19620
19700
|
/** Optional expiration timestamp (ISO 8601). */
|
|
19621
19701
|
expires: optional(datetime3()),
|
|
19622
19702
|
/** Unique challenge identifier (HMAC-bound). */
|
|
19623
|
-
id: string2(),
|
|
19703
|
+
id: string2().check(_minLength(1)),
|
|
19624
19704
|
/** Intent type (e.g., "charge", "session"). */
|
|
19625
19705
|
intent: string2(),
|
|
19626
19706
|
/** Payment method (e.g., "tempo", "stripe"). */
|
|
@@ -19650,7 +19730,7 @@ __export(Credential_exports, {
|
|
|
19650
19730
|
serialize: () => serialize3
|
|
19651
19731
|
});
|
|
19652
19732
|
function deserialize3(value) {
|
|
19653
|
-
const prefixMatch = value.match(
|
|
19733
|
+
const prefixMatch = value.match(new RegExp(`^${Schemes.payment}\\s+(.+)$`, "i"));
|
|
19654
19734
|
if (!prefixMatch?.[1])
|
|
19655
19735
|
throw new MissingPaymentSchemeError();
|
|
19656
19736
|
try {
|
|
@@ -19699,7 +19779,7 @@ function from5(parameters) {
|
|
|
19699
19779
|
};
|
|
19700
19780
|
}
|
|
19701
19781
|
function fromRequest(request) {
|
|
19702
|
-
const header = request.headers.get(
|
|
19782
|
+
const header = request.headers.get(Headers2.authorization);
|
|
19703
19783
|
if (!header)
|
|
19704
19784
|
throw new MissingAuthorizationHeaderError();
|
|
19705
19785
|
const payment = extractPaymentScheme(header);
|
|
@@ -19721,11 +19801,11 @@ function serialize3(credential) {
|
|
|
19721
19801
|
};
|
|
19722
19802
|
const json2 = JSON.stringify(wire);
|
|
19723
19803
|
const encoded = Base64_exports.fromString(json2, { pad: false, url: true });
|
|
19724
|
-
return
|
|
19804
|
+
return `${Schemes.payment} ${encoded}`;
|
|
19725
19805
|
}
|
|
19726
19806
|
function extractPaymentScheme(header) {
|
|
19727
|
-
const
|
|
19728
|
-
return
|
|
19807
|
+
const schemes2 = header.split(",").map((s) => s.trim());
|
|
19808
|
+
return schemes2.find((s) => new RegExp(`^${Schemes.payment}\\s+`, "i").test(s)) ?? null;
|
|
19729
19809
|
}
|
|
19730
19810
|
var MissingAuthorizationHeaderError, MissingPaymentSchemeError, InvalidCredentialEncodingError;
|
|
19731
19811
|
var init_Credential = __esm({
|
|
@@ -19733,6 +19813,7 @@ var init_Credential = __esm({
|
|
|
19733
19813
|
"use strict";
|
|
19734
19814
|
init_esm2();
|
|
19735
19815
|
init_Challenge();
|
|
19816
|
+
init_Constants();
|
|
19736
19817
|
init_PaymentRequest();
|
|
19737
19818
|
MissingAuthorizationHeaderError = class extends Error {
|
|
19738
19819
|
name = "MissingAuthorizationHeaderError";
|
|
@@ -19763,6 +19844,7 @@ __export(Errors_exports2, {
|
|
|
19763
19844
|
ChannelClosedError: () => ChannelClosedError,
|
|
19764
19845
|
ChannelNotFoundError: () => ChannelNotFoundError,
|
|
19765
19846
|
DeltaTooSmallError: () => DeltaTooSmallError,
|
|
19847
|
+
Hints: () => Hints,
|
|
19766
19848
|
InsufficientBalanceError: () => InsufficientBalanceError,
|
|
19767
19849
|
InvalidChallengeError: () => InvalidChallengeError,
|
|
19768
19850
|
InvalidPayloadError: () => InvalidPayloadError,
|
|
@@ -19777,13 +19859,20 @@ __export(Errors_exports2, {
|
|
|
19777
19859
|
SignerMismatchError: () => SignerMismatchError,
|
|
19778
19860
|
VerificationFailedError: () => VerificationFailedError
|
|
19779
19861
|
});
|
|
19780
|
-
var PaymentError, MalformedCredentialError, InvalidChallengeError, VerificationFailedError, PaymentActionRequiredError, PaymentExpiredError, PaymentRequiredError2, InvalidPayloadError, BadRequestError, PaymentInsufficientError, PaymentMethodUnsupportedError, InsufficientBalanceError, InvalidSignatureError, SignerMismatchError, AmountExceedsDepositError, DeltaTooSmallError, ChannelNotFoundError, ChannelClosedError;
|
|
19862
|
+
var Hints, PaymentError, MalformedCredentialError, InvalidChallengeError, VerificationFailedError, PaymentActionRequiredError, PaymentExpiredError, PaymentRequiredError2, InvalidPayloadError, BadRequestError, PaymentInsufficientError, PaymentMethodUnsupportedError, InsufficientBalanceError, InvalidSignatureError, SignerMismatchError, AmountExceedsDepositError, DeltaTooSmallError, ChannelNotFoundError, ChannelClosedError;
|
|
19781
19863
|
var init_Errors2 = __esm({
|
|
19782
19864
|
"node_modules/mppx/dist/Errors.js"() {
|
|
19783
19865
|
"use strict";
|
|
19866
|
+
Hints = {
|
|
19867
|
+
paymentRequired: "Use a supported wallet to pay for this resource using one of the supported payment methods returned in the WWW-Authenticate header. See https://mpp.dev/tools/wallet.md",
|
|
19868
|
+
malformedCredential: "Use a supported wallet to construct valid credentials for one of the supported payment methods returned in the WWW-Authenticate header. See https://mpp.dev/tools/wallet.md",
|
|
19869
|
+
methodUnsupported: "Use a supported wallet to pay for this resource using one of the supported payment methods returned in the WWW-Authenticate header. See https://mpp.dev/tools/wallet.md"
|
|
19870
|
+
};
|
|
19784
19871
|
PaymentError = class extends Error {
|
|
19785
19872
|
/** HTTP status code. */
|
|
19786
19873
|
status = 402;
|
|
19874
|
+
/** Actionable hint for resolving the error (RFC 9457 extension member). */
|
|
19875
|
+
hint;
|
|
19787
19876
|
/** Converts the error to RFC 9457 Problem Details format. */
|
|
19788
19877
|
toProblemDetails(challengeId) {
|
|
19789
19878
|
return {
|
|
@@ -19791,6 +19880,7 @@ var init_Errors2 = __esm({
|
|
|
19791
19880
|
title: this.title,
|
|
19792
19881
|
status: this.status,
|
|
19793
19882
|
detail: this.message,
|
|
19883
|
+
...this.hint && { hint: this.hint },
|
|
19794
19884
|
...challengeId && { challengeId }
|
|
19795
19885
|
};
|
|
19796
19886
|
}
|
|
@@ -19800,6 +19890,7 @@ var init_Errors2 = __esm({
|
|
|
19800
19890
|
title = "Malformed Credential";
|
|
19801
19891
|
status = 402;
|
|
19802
19892
|
type = "https://paymentauth.org/problems/malformed-credential";
|
|
19893
|
+
hint = Hints.malformedCredential;
|
|
19803
19894
|
constructor(options = {}) {
|
|
19804
19895
|
const { reason } = options;
|
|
19805
19896
|
super(reason ? `Credential is malformed: ${reason}.` : "Credential is malformed.");
|
|
@@ -19848,6 +19939,7 @@ var init_Errors2 = __esm({
|
|
|
19848
19939
|
name = "PaymentRequiredError";
|
|
19849
19940
|
title = "Payment Required";
|
|
19850
19941
|
type = "https://paymentauth.org/problems/payment-required";
|
|
19942
|
+
hint = Hints.paymentRequired;
|
|
19851
19943
|
constructor(options = {}) {
|
|
19852
19944
|
const { description } = options;
|
|
19853
19945
|
const parts = ["Payment is required"];
|
|
@@ -19889,6 +19981,7 @@ var init_Errors2 = __esm({
|
|
|
19889
19981
|
title = "Method Unsupported";
|
|
19890
19982
|
status = 400;
|
|
19891
19983
|
type = "https://paymentauth.org/problems/method-unsupported";
|
|
19984
|
+
hint = Hints.methodUnsupported;
|
|
19892
19985
|
constructor(options = {}) {
|
|
19893
19986
|
const { method } = options;
|
|
19894
19987
|
super(method ? `Payment method "${method}" is not supported.` : "Payment method is not supported.");
|
|
@@ -20021,147 +20114,1120 @@ var init_Expires = __esm({
|
|
|
20021
20114
|
}
|
|
20022
20115
|
});
|
|
20023
20116
|
|
|
20024
|
-
// node_modules/
|
|
20025
|
-
|
|
20026
|
-
|
|
20027
|
-
|
|
20028
|
-
|
|
20029
|
-
|
|
20030
|
-
|
|
20117
|
+
// node_modules/viem/_esm/utils/data/isHex.js
|
|
20118
|
+
function isHex(value, { strict = true } = {}) {
|
|
20119
|
+
if (!value)
|
|
20120
|
+
return false;
|
|
20121
|
+
if (typeof value !== "string")
|
|
20122
|
+
return false;
|
|
20123
|
+
return strict ? /^0x[0-9a-fA-F]*$/.test(value) : value.startsWith("0x");
|
|
20124
|
+
}
|
|
20125
|
+
var init_isHex = __esm({
|
|
20126
|
+
"node_modules/viem/_esm/utils/data/isHex.js"() {
|
|
20127
|
+
"use strict";
|
|
20128
|
+
}
|
|
20031
20129
|
});
|
|
20032
|
-
|
|
20033
|
-
|
|
20034
|
-
|
|
20130
|
+
|
|
20131
|
+
// node_modules/viem/_esm/utils/data/size.js
|
|
20132
|
+
function size3(value) {
|
|
20133
|
+
if (isHex(value, { strict: false }))
|
|
20134
|
+
return Math.ceil((value.length - 2) / 2);
|
|
20135
|
+
return value.length;
|
|
20136
|
+
}
|
|
20137
|
+
var init_size = __esm({
|
|
20138
|
+
"node_modules/viem/_esm/utils/data/size.js"() {
|
|
20035
20139
|
"use strict";
|
|
20036
|
-
|
|
20037
|
-
paymentVerificationFailedCode = -32043;
|
|
20038
|
-
credentialMetaKey = "org.paymentauth/credential";
|
|
20039
|
-
receiptMetaKey = "org.paymentauth/receipt";
|
|
20140
|
+
init_isHex();
|
|
20040
20141
|
}
|
|
20041
20142
|
});
|
|
20042
20143
|
|
|
20043
|
-
// node_modules/
|
|
20044
|
-
var
|
|
20045
|
-
|
|
20046
|
-
|
|
20047
|
-
|
|
20048
|
-
|
|
20144
|
+
// node_modules/viem/_esm/errors/version.js
|
|
20145
|
+
var version3;
|
|
20146
|
+
var init_version2 = __esm({
|
|
20147
|
+
"node_modules/viem/_esm/errors/version.js"() {
|
|
20148
|
+
"use strict";
|
|
20149
|
+
version3 = "2.54.4";
|
|
20150
|
+
}
|
|
20049
20151
|
});
|
|
20050
|
-
|
|
20051
|
-
|
|
20152
|
+
|
|
20153
|
+
// node_modules/viem/_esm/errors/base.js
|
|
20154
|
+
function walk2(err, fn) {
|
|
20155
|
+
if (fn?.(err))
|
|
20156
|
+
return err;
|
|
20157
|
+
if (err && typeof err === "object" && "cause" in err && err.cause !== void 0)
|
|
20158
|
+
return walk2(err.cause, fn);
|
|
20159
|
+
return fn ? null : err;
|
|
20052
20160
|
}
|
|
20053
|
-
|
|
20054
|
-
|
|
20055
|
-
|
|
20056
|
-
|
|
20057
|
-
|
|
20058
|
-
|
|
20059
|
-
|
|
20161
|
+
var errorConfig, BaseError3;
|
|
20162
|
+
var init_base = __esm({
|
|
20163
|
+
"node_modules/viem/_esm/errors/base.js"() {
|
|
20164
|
+
"use strict";
|
|
20165
|
+
init_version2();
|
|
20166
|
+
errorConfig = {
|
|
20167
|
+
getDocsUrl: ({ docsBaseUrl, docsPath = "", docsSlug }) => docsPath ? `${docsBaseUrl ?? "https://viem.sh"}${docsPath}${docsSlug ? `#${docsSlug}` : ""}` : void 0,
|
|
20168
|
+
version: `viem@${version3}`
|
|
20169
|
+
};
|
|
20170
|
+
BaseError3 = class _BaseError extends Error {
|
|
20171
|
+
constructor(shortMessage, args = {}) {
|
|
20172
|
+
const details = (() => {
|
|
20173
|
+
if (args.cause instanceof _BaseError)
|
|
20174
|
+
return args.cause.details;
|
|
20175
|
+
if (args.cause?.message)
|
|
20176
|
+
return args.cause.message;
|
|
20177
|
+
return args.details;
|
|
20178
|
+
})();
|
|
20179
|
+
const docsPath = (() => {
|
|
20180
|
+
if (args.cause instanceof _BaseError)
|
|
20181
|
+
return args.cause.docsPath || args.docsPath;
|
|
20182
|
+
return args.docsPath;
|
|
20183
|
+
})();
|
|
20184
|
+
const docsUrl = errorConfig.getDocsUrl?.({ ...args, docsPath });
|
|
20185
|
+
const message = [
|
|
20186
|
+
shortMessage || "An error occurred.",
|
|
20187
|
+
"",
|
|
20188
|
+
...args.metaMessages ? [...args.metaMessages, ""] : [],
|
|
20189
|
+
...docsUrl ? [`Docs: ${docsUrl}`] : [],
|
|
20190
|
+
...details ? [`Details: ${details}`] : [],
|
|
20191
|
+
...errorConfig.version ? [`Version: ${errorConfig.version}`] : []
|
|
20192
|
+
].join("\n");
|
|
20193
|
+
super(message, args.cause ? { cause: args.cause } : void 0);
|
|
20194
|
+
Object.defineProperty(this, "details", {
|
|
20195
|
+
enumerable: true,
|
|
20196
|
+
configurable: true,
|
|
20197
|
+
writable: true,
|
|
20198
|
+
value: void 0
|
|
20199
|
+
});
|
|
20200
|
+
Object.defineProperty(this, "docsPath", {
|
|
20201
|
+
enumerable: true,
|
|
20202
|
+
configurable: true,
|
|
20203
|
+
writable: true,
|
|
20204
|
+
value: void 0
|
|
20205
|
+
});
|
|
20206
|
+
Object.defineProperty(this, "metaMessages", {
|
|
20207
|
+
enumerable: true,
|
|
20208
|
+
configurable: true,
|
|
20209
|
+
writable: true,
|
|
20210
|
+
value: void 0
|
|
20211
|
+
});
|
|
20212
|
+
Object.defineProperty(this, "shortMessage", {
|
|
20213
|
+
enumerable: true,
|
|
20214
|
+
configurable: true,
|
|
20215
|
+
writable: true,
|
|
20216
|
+
value: void 0
|
|
20217
|
+
});
|
|
20218
|
+
Object.defineProperty(this, "version", {
|
|
20219
|
+
enumerable: true,
|
|
20220
|
+
configurable: true,
|
|
20221
|
+
writable: true,
|
|
20222
|
+
value: void 0
|
|
20223
|
+
});
|
|
20224
|
+
Object.defineProperty(this, "name", {
|
|
20225
|
+
enumerable: true,
|
|
20226
|
+
configurable: true,
|
|
20227
|
+
writable: true,
|
|
20228
|
+
value: "BaseError"
|
|
20229
|
+
});
|
|
20230
|
+
this.details = details;
|
|
20231
|
+
this.docsPath = docsPath;
|
|
20232
|
+
this.metaMessages = args.metaMessages;
|
|
20233
|
+
this.name = args.name ?? this.name;
|
|
20234
|
+
this.shortMessage = shortMessage;
|
|
20235
|
+
this.version = version3;
|
|
20236
|
+
}
|
|
20237
|
+
walk(fn) {
|
|
20238
|
+
return walk2(this, fn);
|
|
20239
|
+
}
|
|
20240
|
+
};
|
|
20241
|
+
}
|
|
20242
|
+
});
|
|
20243
|
+
|
|
20244
|
+
// node_modules/viem/_esm/errors/data.js
|
|
20245
|
+
var SizeExceedsPaddingSizeError3;
|
|
20246
|
+
var init_data = __esm({
|
|
20247
|
+
"node_modules/viem/_esm/errors/data.js"() {
|
|
20248
|
+
"use strict";
|
|
20249
|
+
init_base();
|
|
20250
|
+
SizeExceedsPaddingSizeError3 = class extends BaseError3 {
|
|
20251
|
+
constructor({ size: size4, targetSize, type }) {
|
|
20252
|
+
super(`${type.charAt(0).toUpperCase()}${type.slice(1).toLowerCase()} size (${size4}) exceeds padding size (${targetSize}).`, { name: "SizeExceedsPaddingSizeError" });
|
|
20253
|
+
}
|
|
20254
|
+
};
|
|
20255
|
+
}
|
|
20256
|
+
});
|
|
20257
|
+
|
|
20258
|
+
// node_modules/viem/_esm/utils/data/pad.js
|
|
20259
|
+
function pad3(hexOrBytes, { dir, size: size4 = 32 } = {}) {
|
|
20260
|
+
if (typeof hexOrBytes === "string")
|
|
20261
|
+
return padHex(hexOrBytes, { dir, size: size4 });
|
|
20262
|
+
return padBytes(hexOrBytes, { dir, size: size4 });
|
|
20060
20263
|
}
|
|
20061
|
-
function
|
|
20062
|
-
|
|
20063
|
-
|
|
20064
|
-
|
|
20065
|
-
|
|
20066
|
-
|
|
20067
|
-
|
|
20068
|
-
|
|
20069
|
-
|
|
20070
|
-
|
|
20071
|
-
|
|
20072
|
-
transport,
|
|
20073
|
-
verify: verify3
|
|
20074
|
-
};
|
|
20264
|
+
function padHex(hex_, { dir, size: size4 = 32 } = {}) {
|
|
20265
|
+
if (size4 === null)
|
|
20266
|
+
return hex_;
|
|
20267
|
+
const hex3 = hex_.replace("0x", "");
|
|
20268
|
+
if (hex3.length > size4 * 2)
|
|
20269
|
+
throw new SizeExceedsPaddingSizeError3({
|
|
20270
|
+
size: Math.ceil(hex3.length / 2),
|
|
20271
|
+
targetSize: size4,
|
|
20272
|
+
type: "hex"
|
|
20273
|
+
});
|
|
20274
|
+
return `0x${hex3[dir === "right" ? "padEnd" : "padStart"](size4 * 2, "0")}`;
|
|
20075
20275
|
}
|
|
20076
|
-
|
|
20077
|
-
|
|
20276
|
+
function padBytes(bytes, { dir, size: size4 = 32 } = {}) {
|
|
20277
|
+
if (size4 === null)
|
|
20278
|
+
return bytes;
|
|
20279
|
+
if (bytes.length > size4)
|
|
20280
|
+
throw new SizeExceedsPaddingSizeError3({
|
|
20281
|
+
size: bytes.length,
|
|
20282
|
+
targetSize: size4,
|
|
20283
|
+
type: "bytes"
|
|
20284
|
+
});
|
|
20285
|
+
const paddedBytes = new Uint8Array(size4);
|
|
20286
|
+
for (let i = 0; i < size4; i++) {
|
|
20287
|
+
const padEnd = dir === "right";
|
|
20288
|
+
paddedBytes[padEnd ? i : size4 - i - 1] = bytes[padEnd ? i : bytes.length - i - 1];
|
|
20289
|
+
}
|
|
20290
|
+
return paddedBytes;
|
|
20291
|
+
}
|
|
20292
|
+
var init_pad = __esm({
|
|
20293
|
+
"node_modules/viem/_esm/utils/data/pad.js"() {
|
|
20078
20294
|
"use strict";
|
|
20295
|
+
init_data();
|
|
20079
20296
|
}
|
|
20080
20297
|
});
|
|
20081
20298
|
|
|
20082
|
-
// node_modules/
|
|
20083
|
-
var
|
|
20084
|
-
|
|
20085
|
-
|
|
20086
|
-
|
|
20087
|
-
|
|
20088
|
-
|
|
20089
|
-
|
|
20299
|
+
// node_modules/viem/_esm/errors/encoding.js
|
|
20300
|
+
var IntegerOutOfRangeError2, SizeOverflowError3;
|
|
20301
|
+
var init_encoding = __esm({
|
|
20302
|
+
"node_modules/viem/_esm/errors/encoding.js"() {
|
|
20303
|
+
"use strict";
|
|
20304
|
+
init_base();
|
|
20305
|
+
IntegerOutOfRangeError2 = class extends BaseError3 {
|
|
20306
|
+
constructor({ max, min, signed, size: size4, value }) {
|
|
20307
|
+
super(`Number "${value}" is not in safe ${size4 ? `${size4 * 8}-bit ${signed ? "signed" : "unsigned"} ` : ""}integer range ${max ? `(${min} to ${max})` : `(above ${min})`}`, { name: "IntegerOutOfRangeError" });
|
|
20308
|
+
}
|
|
20309
|
+
};
|
|
20310
|
+
SizeOverflowError3 = class extends BaseError3 {
|
|
20311
|
+
constructor({ givenSize, maxSize }) {
|
|
20312
|
+
super(`Size cannot exceed ${maxSize} bytes. Given size: ${givenSize} bytes.`, { name: "SizeOverflowError" });
|
|
20313
|
+
}
|
|
20314
|
+
};
|
|
20315
|
+
}
|
|
20090
20316
|
});
|
|
20091
|
-
|
|
20092
|
-
|
|
20093
|
-
|
|
20317
|
+
|
|
20318
|
+
// node_modules/viem/_esm/utils/encoding/fromHex.js
|
|
20319
|
+
function assertSize3(hexOrBytes, { size: size4 }) {
|
|
20320
|
+
if (size3(hexOrBytes) > size4)
|
|
20321
|
+
throw new SizeOverflowError3({
|
|
20322
|
+
givenSize: size3(hexOrBytes),
|
|
20323
|
+
maxSize: size4
|
|
20324
|
+
});
|
|
20094
20325
|
}
|
|
20095
|
-
|
|
20096
|
-
|
|
20326
|
+
var init_fromHex = __esm({
|
|
20327
|
+
"node_modules/viem/_esm/utils/encoding/fromHex.js"() {
|
|
20328
|
+
"use strict";
|
|
20329
|
+
init_encoding();
|
|
20330
|
+
init_size();
|
|
20331
|
+
}
|
|
20332
|
+
});
|
|
20333
|
+
|
|
20334
|
+
// node_modules/viem/_esm/utils/encoding/toHex.js
|
|
20335
|
+
function toHex3(value, opts = {}) {
|
|
20336
|
+
if (typeof value === "number" || typeof value === "bigint")
|
|
20337
|
+
return numberToHex(value, opts);
|
|
20338
|
+
if (typeof value === "string") {
|
|
20339
|
+
return stringToHex(value, opts);
|
|
20340
|
+
}
|
|
20341
|
+
if (typeof value === "boolean")
|
|
20342
|
+
return boolToHex(value, opts);
|
|
20343
|
+
return bytesToHex(value, opts);
|
|
20097
20344
|
}
|
|
20098
|
-
function
|
|
20099
|
-
const
|
|
20100
|
-
|
|
20345
|
+
function boolToHex(value, opts = {}) {
|
|
20346
|
+
const hex3 = `0x${Number(value)}`;
|
|
20347
|
+
if (typeof opts.size === "number") {
|
|
20348
|
+
assertSize3(hex3, { size: opts.size });
|
|
20349
|
+
return pad3(hex3, { size: opts.size });
|
|
20350
|
+
}
|
|
20351
|
+
return hex3;
|
|
20101
20352
|
}
|
|
20102
|
-
function
|
|
20103
|
-
|
|
20104
|
-
|
|
20105
|
-
|
|
20106
|
-
|
|
20353
|
+
function bytesToHex(value, opts = {}) {
|
|
20354
|
+
let string4 = "";
|
|
20355
|
+
for (let i = 0; i < value.length; i++) {
|
|
20356
|
+
string4 += hexes2[value[i]];
|
|
20357
|
+
}
|
|
20358
|
+
const hex3 = `0x${string4}`;
|
|
20359
|
+
if (typeof opts.size === "number") {
|
|
20360
|
+
assertSize3(hex3, { size: opts.size });
|
|
20361
|
+
return pad3(hex3, { dir: "right", size: opts.size });
|
|
20362
|
+
}
|
|
20363
|
+
return hex3;
|
|
20107
20364
|
}
|
|
20108
|
-
|
|
20109
|
-
|
|
20110
|
-
|
|
20111
|
-
|
|
20112
|
-
|
|
20113
|
-
|
|
20114
|
-
|
|
20115
|
-
|
|
20116
|
-
|
|
20117
|
-
|
|
20118
|
-
|
|
20119
|
-
|
|
20120
|
-
|
|
20121
|
-
|
|
20122
|
-
|
|
20123
|
-
|
|
20124
|
-
|
|
20125
|
-
|
|
20126
|
-
|
|
20365
|
+
function numberToHex(value_, opts = {}) {
|
|
20366
|
+
const { signed, size: size4 } = opts;
|
|
20367
|
+
const value = BigInt(value_);
|
|
20368
|
+
let maxValue;
|
|
20369
|
+
if (size4) {
|
|
20370
|
+
if (signed)
|
|
20371
|
+
maxValue = (1n << BigInt(size4) * 8n - 1n) - 1n;
|
|
20372
|
+
else
|
|
20373
|
+
maxValue = 2n ** (BigInt(size4) * 8n) - 1n;
|
|
20374
|
+
} else if (typeof value_ === "number") {
|
|
20375
|
+
maxValue = BigInt(Number.MAX_SAFE_INTEGER);
|
|
20376
|
+
}
|
|
20377
|
+
const minValue = typeof maxValue === "bigint" && signed ? -maxValue - 1n : 0;
|
|
20378
|
+
if (maxValue && value > maxValue || value < minValue) {
|
|
20379
|
+
const suffix = typeof value_ === "bigint" ? "n" : "";
|
|
20380
|
+
throw new IntegerOutOfRangeError2({
|
|
20381
|
+
max: maxValue ? `${maxValue}${suffix}` : void 0,
|
|
20382
|
+
min: `${minValue}${suffix}`,
|
|
20383
|
+
signed,
|
|
20384
|
+
size: size4,
|
|
20385
|
+
value: `${value_}${suffix}`
|
|
20127
20386
|
});
|
|
20128
20387
|
}
|
|
20388
|
+
const hex3 = `0x${(signed && value < 0 ? (1n << BigInt(size4 * 8)) + BigInt(value) : value).toString(16)}`;
|
|
20389
|
+
if (size4)
|
|
20390
|
+
return pad3(hex3, { size: size4 });
|
|
20391
|
+
return hex3;
|
|
20392
|
+
}
|
|
20393
|
+
function stringToHex(value_, opts = {}) {
|
|
20394
|
+
const value = encoder4.encode(value_);
|
|
20395
|
+
return bytesToHex(value, opts);
|
|
20396
|
+
}
|
|
20397
|
+
var hexes2, encoder4;
|
|
20398
|
+
var init_toHex = __esm({
|
|
20399
|
+
"node_modules/viem/_esm/utils/encoding/toHex.js"() {
|
|
20400
|
+
"use strict";
|
|
20401
|
+
init_encoding();
|
|
20402
|
+
init_pad();
|
|
20403
|
+
init_fromHex();
|
|
20404
|
+
hexes2 = /* @__PURE__ */ Array.from({ length: 256 }, (_v, i) => i.toString(16).padStart(2, "0"));
|
|
20405
|
+
encoder4 = /* @__PURE__ */ new TextEncoder();
|
|
20406
|
+
}
|
|
20129
20407
|
});
|
|
20130
20408
|
|
|
20131
|
-
// node_modules/
|
|
20132
|
-
|
|
20133
|
-
|
|
20134
|
-
|
|
20135
|
-
|
|
20136
|
-
|
|
20137
|
-
|
|
20138
|
-
|
|
20139
|
-
|
|
20140
|
-
function from8(store) {
|
|
20141
|
-
return store;
|
|
20409
|
+
// node_modules/viem/_esm/utils/encoding/toBytes.js
|
|
20410
|
+
function toBytes4(value, opts = {}) {
|
|
20411
|
+
if (typeof value === "number" || typeof value === "bigint")
|
|
20412
|
+
return numberToBytes(value, opts);
|
|
20413
|
+
if (typeof value === "boolean")
|
|
20414
|
+
return boolToBytes(value, opts);
|
|
20415
|
+
if (isHex(value))
|
|
20416
|
+
return hexToBytes(value, opts);
|
|
20417
|
+
return stringToBytes(value, opts);
|
|
20142
20418
|
}
|
|
20143
|
-
function
|
|
20144
|
-
|
|
20145
|
-
|
|
20146
|
-
|
|
20147
|
-
|
|
20148
|
-
|
|
20149
|
-
|
|
20150
|
-
|
|
20151
|
-
if (change.op !== "set")
|
|
20152
|
-
return change;
|
|
20153
|
-
return { ...change, value: Json_exports.stringify(change.value) };
|
|
20154
|
-
});
|
|
20155
|
-
}
|
|
20156
|
-
};
|
|
20419
|
+
function boolToBytes(value, opts = {}) {
|
|
20420
|
+
const bytes = new Uint8Array(1);
|
|
20421
|
+
bytes[0] = Number(value);
|
|
20422
|
+
if (typeof opts.size === "number") {
|
|
20423
|
+
assertSize3(bytes, { size: opts.size });
|
|
20424
|
+
return pad3(bytes, { size: opts.size });
|
|
20425
|
+
}
|
|
20426
|
+
return bytes;
|
|
20157
20427
|
}
|
|
20158
|
-
function
|
|
20159
|
-
|
|
20160
|
-
|
|
20161
|
-
|
|
20162
|
-
|
|
20163
|
-
|
|
20164
|
-
|
|
20428
|
+
function charCodeToBase162(char) {
|
|
20429
|
+
if (char >= charCodeMap2.zero && char <= charCodeMap2.nine)
|
|
20430
|
+
return char - charCodeMap2.zero;
|
|
20431
|
+
if (char >= charCodeMap2.A && char <= charCodeMap2.F)
|
|
20432
|
+
return char - (charCodeMap2.A - 10);
|
|
20433
|
+
if (char >= charCodeMap2.a && char <= charCodeMap2.f)
|
|
20434
|
+
return char - (charCodeMap2.a - 10);
|
|
20435
|
+
return void 0;
|
|
20436
|
+
}
|
|
20437
|
+
function hexToBytes(hex_, opts = {}) {
|
|
20438
|
+
let hex3 = hex_;
|
|
20439
|
+
if (opts.size) {
|
|
20440
|
+
assertSize3(hex3, { size: opts.size });
|
|
20441
|
+
hex3 = pad3(hex3, { dir: "right", size: opts.size });
|
|
20442
|
+
}
|
|
20443
|
+
let hexString = hex3.slice(2);
|
|
20444
|
+
if (hexString.length % 2)
|
|
20445
|
+
hexString = `0${hexString}`;
|
|
20446
|
+
const length = hexString.length / 2;
|
|
20447
|
+
const bytes = new Uint8Array(length);
|
|
20448
|
+
for (let index = 0, j = 0; index < length; index++) {
|
|
20449
|
+
const nibbleLeft = charCodeToBase162(hexString.charCodeAt(j++));
|
|
20450
|
+
const nibbleRight = charCodeToBase162(hexString.charCodeAt(j++));
|
|
20451
|
+
if (nibbleLeft === void 0 || nibbleRight === void 0) {
|
|
20452
|
+
throw new BaseError3(`Invalid byte sequence ("${hexString[j - 2]}${hexString[j - 1]}" in "${hexString}").`);
|
|
20453
|
+
}
|
|
20454
|
+
bytes[index] = nibbleLeft * 16 + nibbleRight;
|
|
20455
|
+
}
|
|
20456
|
+
return bytes;
|
|
20457
|
+
}
|
|
20458
|
+
function numberToBytes(value, opts) {
|
|
20459
|
+
const hex3 = numberToHex(value, opts);
|
|
20460
|
+
return hexToBytes(hex3);
|
|
20461
|
+
}
|
|
20462
|
+
function stringToBytes(value, opts = {}) {
|
|
20463
|
+
const bytes = encoder5.encode(value);
|
|
20464
|
+
if (typeof opts.size === "number") {
|
|
20465
|
+
assertSize3(bytes, { size: opts.size });
|
|
20466
|
+
return pad3(bytes, { dir: "right", size: opts.size });
|
|
20467
|
+
}
|
|
20468
|
+
return bytes;
|
|
20469
|
+
}
|
|
20470
|
+
var encoder5, charCodeMap2;
|
|
20471
|
+
var init_toBytes = __esm({
|
|
20472
|
+
"node_modules/viem/_esm/utils/encoding/toBytes.js"() {
|
|
20473
|
+
"use strict";
|
|
20474
|
+
init_base();
|
|
20475
|
+
init_isHex();
|
|
20476
|
+
init_pad();
|
|
20477
|
+
init_fromHex();
|
|
20478
|
+
init_toHex();
|
|
20479
|
+
encoder5 = /* @__PURE__ */ new TextEncoder();
|
|
20480
|
+
charCodeMap2 = {
|
|
20481
|
+
zero: 48,
|
|
20482
|
+
nine: 57,
|
|
20483
|
+
A: 65,
|
|
20484
|
+
F: 70,
|
|
20485
|
+
a: 97,
|
|
20486
|
+
f: 102
|
|
20487
|
+
};
|
|
20488
|
+
}
|
|
20489
|
+
});
|
|
20490
|
+
|
|
20491
|
+
// node_modules/viem/_esm/utils/hash/keccak256.js
|
|
20492
|
+
function keccak2562(value, to_) {
|
|
20493
|
+
const to = to_ || "hex";
|
|
20494
|
+
const bytes = keccak_256(isHex(value, { strict: false }) ? toBytes4(value) : value);
|
|
20495
|
+
if (to === "bytes")
|
|
20496
|
+
return bytes;
|
|
20497
|
+
return toHex3(bytes);
|
|
20498
|
+
}
|
|
20499
|
+
var init_keccak256 = __esm({
|
|
20500
|
+
"node_modules/viem/_esm/utils/hash/keccak256.js"() {
|
|
20501
|
+
"use strict";
|
|
20502
|
+
init_sha3();
|
|
20503
|
+
init_isHex();
|
|
20504
|
+
init_toBytes();
|
|
20505
|
+
init_toHex();
|
|
20506
|
+
}
|
|
20507
|
+
});
|
|
20508
|
+
|
|
20509
|
+
// node_modules/viem/_esm/errors/address.js
|
|
20510
|
+
var InvalidAddressError2;
|
|
20511
|
+
var init_address = __esm({
|
|
20512
|
+
"node_modules/viem/_esm/errors/address.js"() {
|
|
20513
|
+
"use strict";
|
|
20514
|
+
init_base();
|
|
20515
|
+
InvalidAddressError2 = class extends BaseError3 {
|
|
20516
|
+
constructor({ address: address3 }) {
|
|
20517
|
+
super(`Address "${address3}" is invalid.`, {
|
|
20518
|
+
metaMessages: [
|
|
20519
|
+
"- Address must be a hex value of 20 bytes (40 hex characters).",
|
|
20520
|
+
"- Address must match its checksum counterpart."
|
|
20521
|
+
],
|
|
20522
|
+
name: "InvalidAddressError"
|
|
20523
|
+
});
|
|
20524
|
+
}
|
|
20525
|
+
};
|
|
20526
|
+
}
|
|
20527
|
+
});
|
|
20528
|
+
|
|
20529
|
+
// node_modules/viem/_esm/utils/lru.js
|
|
20530
|
+
var LruMap2;
|
|
20531
|
+
var init_lru2 = __esm({
|
|
20532
|
+
"node_modules/viem/_esm/utils/lru.js"() {
|
|
20533
|
+
"use strict";
|
|
20534
|
+
LruMap2 = class extends Map {
|
|
20535
|
+
constructor(size4) {
|
|
20536
|
+
super();
|
|
20537
|
+
Object.defineProperty(this, "maxSize", {
|
|
20538
|
+
enumerable: true,
|
|
20539
|
+
configurable: true,
|
|
20540
|
+
writable: true,
|
|
20541
|
+
value: void 0
|
|
20542
|
+
});
|
|
20543
|
+
this.maxSize = size4;
|
|
20544
|
+
}
|
|
20545
|
+
get(key) {
|
|
20546
|
+
const value = super.get(key);
|
|
20547
|
+
if (super.has(key)) {
|
|
20548
|
+
super.delete(key);
|
|
20549
|
+
super.set(key, value);
|
|
20550
|
+
}
|
|
20551
|
+
return value;
|
|
20552
|
+
}
|
|
20553
|
+
set(key, value) {
|
|
20554
|
+
if (super.has(key))
|
|
20555
|
+
super.delete(key);
|
|
20556
|
+
super.set(key, value);
|
|
20557
|
+
if (this.maxSize && this.size > this.maxSize) {
|
|
20558
|
+
const firstKey = super.keys().next().value;
|
|
20559
|
+
if (firstKey !== void 0)
|
|
20560
|
+
super.delete(firstKey);
|
|
20561
|
+
}
|
|
20562
|
+
return this;
|
|
20563
|
+
}
|
|
20564
|
+
};
|
|
20565
|
+
}
|
|
20566
|
+
});
|
|
20567
|
+
|
|
20568
|
+
// node_modules/viem/_esm/utils/address/getAddress.js
|
|
20569
|
+
function checksumAddress(address_, chainId) {
|
|
20570
|
+
if (checksumAddressCache.has(`${address_}.${chainId}`))
|
|
20571
|
+
return checksumAddressCache.get(`${address_}.${chainId}`);
|
|
20572
|
+
const hexAddress = chainId ? `${chainId}${address_.toLowerCase()}` : address_.substring(2).toLowerCase();
|
|
20573
|
+
const hash3 = keccak2562(stringToBytes(hexAddress), "bytes");
|
|
20574
|
+
const address3 = (chainId ? hexAddress.substring(`${chainId}0x`.length) : hexAddress).split("");
|
|
20575
|
+
for (let i = 0; i < 40; i += 2) {
|
|
20576
|
+
if (hash3[i >> 1] >> 4 >= 8 && address3[i]) {
|
|
20577
|
+
address3[i] = address3[i].toUpperCase();
|
|
20578
|
+
}
|
|
20579
|
+
if ((hash3[i >> 1] & 15) >= 8 && address3[i + 1]) {
|
|
20580
|
+
address3[i + 1] = address3[i + 1].toUpperCase();
|
|
20581
|
+
}
|
|
20582
|
+
}
|
|
20583
|
+
const result = `0x${address3.join("")}`;
|
|
20584
|
+
checksumAddressCache.set(`${address_}.${chainId}`, result);
|
|
20585
|
+
return result;
|
|
20586
|
+
}
|
|
20587
|
+
function getAddress(address3, chainId) {
|
|
20588
|
+
if (!isAddress(address3, { strict: false }))
|
|
20589
|
+
throw new InvalidAddressError2({ address: address3 });
|
|
20590
|
+
return checksumAddress(address3, chainId);
|
|
20591
|
+
}
|
|
20592
|
+
var checksumAddressCache;
|
|
20593
|
+
var init_getAddress = __esm({
|
|
20594
|
+
"node_modules/viem/_esm/utils/address/getAddress.js"() {
|
|
20595
|
+
"use strict";
|
|
20596
|
+
init_address();
|
|
20597
|
+
init_toBytes();
|
|
20598
|
+
init_keccak256();
|
|
20599
|
+
init_lru2();
|
|
20600
|
+
init_isAddress();
|
|
20601
|
+
checksumAddressCache = /* @__PURE__ */ new LruMap2(8192);
|
|
20602
|
+
}
|
|
20603
|
+
});
|
|
20604
|
+
|
|
20605
|
+
// node_modules/viem/_esm/utils/address/isAddress.js
|
|
20606
|
+
function isAddress(address3, options) {
|
|
20607
|
+
const { strict = true } = options ?? {};
|
|
20608
|
+
const cacheKey2 = `${address3}.${strict}`;
|
|
20609
|
+
if (isAddressCache.has(cacheKey2))
|
|
20610
|
+
return isAddressCache.get(cacheKey2);
|
|
20611
|
+
const result = (() => {
|
|
20612
|
+
if (!addressRegex2.test(address3))
|
|
20613
|
+
return false;
|
|
20614
|
+
if (address3.toLowerCase() === address3)
|
|
20615
|
+
return true;
|
|
20616
|
+
if (strict)
|
|
20617
|
+
return checksumAddress(address3) === address3;
|
|
20618
|
+
return true;
|
|
20619
|
+
})();
|
|
20620
|
+
isAddressCache.set(cacheKey2, result);
|
|
20621
|
+
return result;
|
|
20622
|
+
}
|
|
20623
|
+
var addressRegex2, isAddressCache;
|
|
20624
|
+
var init_isAddress = __esm({
|
|
20625
|
+
"node_modules/viem/_esm/utils/address/isAddress.js"() {
|
|
20626
|
+
"use strict";
|
|
20627
|
+
init_lru2();
|
|
20628
|
+
init_getAddress();
|
|
20629
|
+
addressRegex2 = /^0x[a-fA-F0-9]{40}$/;
|
|
20630
|
+
isAddressCache = /* @__PURE__ */ new LruMap2(8192);
|
|
20631
|
+
}
|
|
20632
|
+
});
|
|
20633
|
+
|
|
20634
|
+
// node_modules/viem/_esm/errors/unit.js
|
|
20635
|
+
var InvalidDecimalNumberError;
|
|
20636
|
+
var init_unit = __esm({
|
|
20637
|
+
"node_modules/viem/_esm/errors/unit.js"() {
|
|
20638
|
+
"use strict";
|
|
20639
|
+
init_base();
|
|
20640
|
+
InvalidDecimalNumberError = class extends BaseError3 {
|
|
20641
|
+
constructor({ value }) {
|
|
20642
|
+
super(`Number \`${value}\` is not a valid decimal number.`, {
|
|
20643
|
+
name: "InvalidDecimalNumberError"
|
|
20644
|
+
});
|
|
20645
|
+
}
|
|
20646
|
+
};
|
|
20647
|
+
}
|
|
20648
|
+
});
|
|
20649
|
+
|
|
20650
|
+
// node_modules/viem/_esm/utils/unit/parseUnits.js
|
|
20651
|
+
function parseUnits(value, decimals) {
|
|
20652
|
+
if (!/^(-?)([0-9]*)\.?([0-9]*)$/.test(value))
|
|
20653
|
+
throw new InvalidDecimalNumberError({ value });
|
|
20654
|
+
let [integer2, fraction = "0"] = value.split(".");
|
|
20655
|
+
const negative = integer2.startsWith("-");
|
|
20656
|
+
if (negative)
|
|
20657
|
+
integer2 = integer2.slice(1);
|
|
20658
|
+
fraction = fraction.replace(/(0+)$/, "");
|
|
20659
|
+
if (decimals === 0) {
|
|
20660
|
+
if (Math.round(Number(`.${fraction}`)) === 1)
|
|
20661
|
+
integer2 = `${BigInt(integer2) + 1n}`;
|
|
20662
|
+
fraction = "";
|
|
20663
|
+
} else if (fraction.length > decimals) {
|
|
20664
|
+
const [left, unit, right] = [
|
|
20665
|
+
fraction.slice(0, decimals - 1),
|
|
20666
|
+
fraction.slice(decimals - 1, decimals),
|
|
20667
|
+
fraction.slice(decimals)
|
|
20668
|
+
];
|
|
20669
|
+
const rounded = Math.round(Number(`${unit}.${right}`));
|
|
20670
|
+
if (rounded > 9)
|
|
20671
|
+
fraction = `${BigInt(left) + BigInt(1)}0`.padStart(left.length + 1, "0");
|
|
20672
|
+
else
|
|
20673
|
+
fraction = `${left}${rounded}`;
|
|
20674
|
+
if (fraction.length > decimals) {
|
|
20675
|
+
fraction = fraction.slice(1);
|
|
20676
|
+
integer2 = `${BigInt(integer2) + 1n}`;
|
|
20677
|
+
}
|
|
20678
|
+
fraction = fraction.slice(0, decimals);
|
|
20679
|
+
} else {
|
|
20680
|
+
fraction = fraction.padEnd(decimals, "0");
|
|
20681
|
+
}
|
|
20682
|
+
return BigInt(`${negative ? "-" : ""}${integer2}${fraction}`);
|
|
20683
|
+
}
|
|
20684
|
+
var init_parseUnits = __esm({
|
|
20685
|
+
"node_modules/viem/_esm/utils/unit/parseUnits.js"() {
|
|
20686
|
+
"use strict";
|
|
20687
|
+
init_unit();
|
|
20688
|
+
}
|
|
20689
|
+
});
|
|
20690
|
+
|
|
20691
|
+
// node_modules/viem/_esm/index.js
|
|
20692
|
+
var init_esm3 = __esm({
|
|
20693
|
+
"node_modules/viem/_esm/index.js"() {
|
|
20694
|
+
"use strict";
|
|
20695
|
+
init_getAddress();
|
|
20696
|
+
init_parseUnits();
|
|
20697
|
+
}
|
|
20698
|
+
});
|
|
20699
|
+
|
|
20700
|
+
// node_modules/mppx/dist/x402/Assets.js
|
|
20701
|
+
var Assets_exports = {};
|
|
20702
|
+
__export(Assets_exports, {
|
|
20703
|
+
base: () => base,
|
|
20704
|
+
baseSepolia: () => baseSepolia,
|
|
20705
|
+
define: () => define,
|
|
20706
|
+
fromToken: () => fromToken,
|
|
20707
|
+
isAsset: () => isAsset,
|
|
20708
|
+
isRawAddress: () => isRawAddress,
|
|
20709
|
+
isToken: () => isToken,
|
|
20710
|
+
matches: () => matches,
|
|
20711
|
+
resolve: () => resolve,
|
|
20712
|
+
toChainId: () => toChainId,
|
|
20713
|
+
toNetwork: () => toNetwork
|
|
20714
|
+
});
|
|
20715
|
+
function define(parameters) {
|
|
20716
|
+
return {
|
|
20717
|
+
[knownAsset]: true,
|
|
20718
|
+
address: parameters.address,
|
|
20719
|
+
decimals: parameters.decimals,
|
|
20720
|
+
network: parameters.network,
|
|
20721
|
+
transfer: parameters.transfer
|
|
20722
|
+
};
|
|
20723
|
+
}
|
|
20724
|
+
function fromToken(token, parameters) {
|
|
20725
|
+
const resolved = token(parameters.chainId);
|
|
20726
|
+
return define({
|
|
20727
|
+
address: resolved.address,
|
|
20728
|
+
decimals: resolved.decimals,
|
|
20729
|
+
network: toNetwork(parameters.chainId),
|
|
20730
|
+
transfer: withTokenDefaults(parameters.transfer, resolved)
|
|
20731
|
+
});
|
|
20732
|
+
}
|
|
20733
|
+
function isAsset(value) {
|
|
20734
|
+
if (typeof value !== "object" || value === null)
|
|
20735
|
+
return false;
|
|
20736
|
+
return value[knownAsset] === true;
|
|
20737
|
+
}
|
|
20738
|
+
function isToken(value) {
|
|
20739
|
+
return typeof value === "function" && typeof value.addresses === "object" && typeof value.decimals === "number";
|
|
20740
|
+
}
|
|
20741
|
+
function isRawAddress(currency) {
|
|
20742
|
+
return typeof currency === "string";
|
|
20743
|
+
}
|
|
20744
|
+
function resolve(currency, network) {
|
|
20745
|
+
if (isAsset(currency)) {
|
|
20746
|
+
if (currency.network !== network)
|
|
20747
|
+
return void 0;
|
|
20748
|
+
return {
|
|
20749
|
+
address: currency.address,
|
|
20750
|
+
decimals: currency.decimals,
|
|
20751
|
+
transfer: currency.transfer
|
|
20752
|
+
};
|
|
20753
|
+
}
|
|
20754
|
+
if (isToken(currency)) {
|
|
20755
|
+
const address3 = currency.addresses[toChainId(network)];
|
|
20756
|
+
if (!address3)
|
|
20757
|
+
return void 0;
|
|
20758
|
+
return {
|
|
20759
|
+
address: address3,
|
|
20760
|
+
decimals: currency.decimals,
|
|
20761
|
+
name: currency.name
|
|
20762
|
+
};
|
|
20763
|
+
}
|
|
20764
|
+
return {
|
|
20765
|
+
address: currency
|
|
20766
|
+
};
|
|
20767
|
+
}
|
|
20768
|
+
function matches(currency, acceptedCurrency, network) {
|
|
20769
|
+
const resolved = resolve(currency, network);
|
|
20770
|
+
if (!resolved)
|
|
20771
|
+
return false;
|
|
20772
|
+
return getAddress(resolved.address) === getAddress(acceptedCurrency);
|
|
20773
|
+
}
|
|
20774
|
+
function toNetwork(chainId) {
|
|
20775
|
+
return `eip155:${chainId}`;
|
|
20776
|
+
}
|
|
20777
|
+
function toChainId(network) {
|
|
20778
|
+
return Number(network.slice("eip155:".length));
|
|
20779
|
+
}
|
|
20780
|
+
function withTokenDefaults(transfer, token) {
|
|
20781
|
+
if (transfer.type !== "eip3009")
|
|
20782
|
+
return transfer;
|
|
20783
|
+
if (transfer.name)
|
|
20784
|
+
return { ...transfer, name: transfer.name };
|
|
20785
|
+
if (!token.name)
|
|
20786
|
+
throw new Error("EIP-3009 token assets require a token name.");
|
|
20787
|
+
return {
|
|
20788
|
+
...transfer,
|
|
20789
|
+
name: token.name
|
|
20790
|
+
};
|
|
20791
|
+
}
|
|
20792
|
+
var knownAsset, base, baseSepolia;
|
|
20793
|
+
var init_Assets = __esm({
|
|
20794
|
+
"node_modules/mppx/dist/x402/Assets.js"() {
|
|
20795
|
+
"use strict";
|
|
20796
|
+
init_esm3();
|
|
20797
|
+
knownAsset = /* @__PURE__ */ Symbol("mppx.x402.asset");
|
|
20798
|
+
base = {
|
|
20799
|
+
USDC: define({
|
|
20800
|
+
address: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
|
|
20801
|
+
decimals: 6,
|
|
20802
|
+
network: "eip155:8453",
|
|
20803
|
+
transfer: {
|
|
20804
|
+
// USDC's EIP-712 domain name differs between Base and Base Sepolia.
|
|
20805
|
+
name: "USD Coin",
|
|
20806
|
+
type: "eip3009",
|
|
20807
|
+
version: "2"
|
|
20808
|
+
}
|
|
20809
|
+
})
|
|
20810
|
+
};
|
|
20811
|
+
baseSepolia = {
|
|
20812
|
+
USDC: define({
|
|
20813
|
+
address: "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
|
|
20814
|
+
decimals: 6,
|
|
20815
|
+
network: "eip155:84532",
|
|
20816
|
+
transfer: {
|
|
20817
|
+
// Base Sepolia test USDC signs with the shorter EIP-712 domain name.
|
|
20818
|
+
name: "USDC",
|
|
20819
|
+
type: "eip3009",
|
|
20820
|
+
version: "2"
|
|
20821
|
+
}
|
|
20822
|
+
})
|
|
20823
|
+
};
|
|
20824
|
+
}
|
|
20825
|
+
});
|
|
20826
|
+
|
|
20827
|
+
// node_modules/mppx/dist/evm/Assets.js
|
|
20828
|
+
var Assets_exports2 = {};
|
|
20829
|
+
__export(Assets_exports2, {
|
|
20830
|
+
base: () => base,
|
|
20831
|
+
baseSepolia: () => baseSepolia,
|
|
20832
|
+
define: () => define,
|
|
20833
|
+
fromToken: () => fromToken,
|
|
20834
|
+
isAsset: () => isAsset,
|
|
20835
|
+
isRawAddress: () => isRawAddress,
|
|
20836
|
+
isToken: () => isToken,
|
|
20837
|
+
matches: () => matches,
|
|
20838
|
+
resolve: () => resolve,
|
|
20839
|
+
toChainId: () => toChainId,
|
|
20840
|
+
toNetwork: () => toNetwork
|
|
20841
|
+
});
|
|
20842
|
+
var init_Assets2 = __esm({
|
|
20843
|
+
"node_modules/mppx/dist/evm/Assets.js"() {
|
|
20844
|
+
"use strict";
|
|
20845
|
+
init_Assets();
|
|
20846
|
+
}
|
|
20847
|
+
});
|
|
20848
|
+
|
|
20849
|
+
// node_modules/mppx/dist/evm/Chains.js
|
|
20850
|
+
var Chains_exports = {};
|
|
20851
|
+
__export(Chains_exports, {
|
|
20852
|
+
base: () => base2,
|
|
20853
|
+
baseSepolia: () => baseSepolia2
|
|
20854
|
+
});
|
|
20855
|
+
var base2, baseSepolia2;
|
|
20856
|
+
var init_Chains = __esm({
|
|
20857
|
+
"node_modules/mppx/dist/evm/Chains.js"() {
|
|
20858
|
+
"use strict";
|
|
20859
|
+
base2 = 8453;
|
|
20860
|
+
baseSepolia2 = 84532;
|
|
20861
|
+
}
|
|
20862
|
+
});
|
|
20863
|
+
|
|
20864
|
+
// node_modules/mppx/dist/Method.js
|
|
20865
|
+
var Method_exports = {};
|
|
20866
|
+
__export(Method_exports, {
|
|
20867
|
+
from: () => from6,
|
|
20868
|
+
toClient: () => toClient,
|
|
20869
|
+
toServer: () => toServer
|
|
20870
|
+
});
|
|
20871
|
+
function from6(method) {
|
|
20872
|
+
return method;
|
|
20873
|
+
}
|
|
20874
|
+
function toClient(method, options) {
|
|
20875
|
+
const { canHandleChallenge, context, createCredential } = options;
|
|
20876
|
+
return {
|
|
20877
|
+
...method,
|
|
20878
|
+
canHandleChallenge,
|
|
20879
|
+
context,
|
|
20880
|
+
createCredential
|
|
20881
|
+
};
|
|
20882
|
+
}
|
|
20883
|
+
function toServer(method, options) {
|
|
20884
|
+
const { alias, authorize, defaults, extensions, html, preflight, request, respond, stableBinding, transport, verify: verify3 } = options;
|
|
20885
|
+
return {
|
|
20886
|
+
...method,
|
|
20887
|
+
alias,
|
|
20888
|
+
authorize,
|
|
20889
|
+
defaults,
|
|
20890
|
+
extensions,
|
|
20891
|
+
html,
|
|
20892
|
+
preflight,
|
|
20893
|
+
request,
|
|
20894
|
+
respond,
|
|
20895
|
+
stableBinding,
|
|
20896
|
+
transport,
|
|
20897
|
+
verify: verify3
|
|
20898
|
+
};
|
|
20899
|
+
}
|
|
20900
|
+
var init_Method = __esm({
|
|
20901
|
+
"node_modules/mppx/dist/Method.js"() {
|
|
20902
|
+
"use strict";
|
|
20903
|
+
}
|
|
20904
|
+
});
|
|
20905
|
+
|
|
20906
|
+
// node_modules/mppx/dist/evm/Types.js
|
|
20907
|
+
var Types_exports = {};
|
|
20908
|
+
__export(Types_exports, {
|
|
20909
|
+
AuthorizationConfigSchema: () => AuthorizationConfigSchema,
|
|
20910
|
+
AuthorizationPayloadSchema: () => AuthorizationPayloadSchema,
|
|
20911
|
+
ChargePayloadSchema: () => ChargePayloadSchema,
|
|
20912
|
+
ChargeRequestInputSchema: () => ChargeRequestInputSchema,
|
|
20913
|
+
ChargeRequestSchema: () => ChargeRequestSchema,
|
|
20914
|
+
MethodDetailsSchema: () => MethodDetailsSchema,
|
|
20915
|
+
authorizationDomain: () => authorizationDomain,
|
|
20916
|
+
authorizationTypes: () => authorizationTypes,
|
|
20917
|
+
challengeHash: () => challengeHash,
|
|
20918
|
+
chargeIntent: () => chargeIntent,
|
|
20919
|
+
credentialTypes: () => credentialTypes,
|
|
20920
|
+
eip3009: () => eip3009,
|
|
20921
|
+
evmNetworkPrefix: () => evmNetworkPrefix,
|
|
20922
|
+
networkOf: () => networkOf,
|
|
20923
|
+
paymentMethod: () => paymentMethod,
|
|
20924
|
+
toSource: () => toSource
|
|
20925
|
+
});
|
|
20926
|
+
function authorizationDomain(parameters) {
|
|
20927
|
+
return {
|
|
20928
|
+
chainId: parameters.chainId,
|
|
20929
|
+
name: parameters.authorization.name,
|
|
20930
|
+
verifyingContract: parameters.currency,
|
|
20931
|
+
version: parameters.authorization.version
|
|
20932
|
+
};
|
|
20933
|
+
}
|
|
20934
|
+
function challengeHash(challenge) {
|
|
20935
|
+
return Hash_exports.keccak256(Bytes_exports.fromString(`${challenge.id}${challenge.realm}`), {
|
|
20936
|
+
as: "Hex"
|
|
20937
|
+
});
|
|
20938
|
+
}
|
|
20939
|
+
function networkOf(chainId) {
|
|
20940
|
+
return `${evmNetworkPrefix}${chainId}`;
|
|
20941
|
+
}
|
|
20942
|
+
function toSource(parameters) {
|
|
20943
|
+
return `did:pkh:eip155:${parameters.chainId}:${parameters.address}`;
|
|
20944
|
+
}
|
|
20945
|
+
var paymentMethod, chargeIntent, evmNetworkPrefix, eip3009, credentialTypes, atomicAmount, AuthorizationConfigSchema, MethodDetailsSchema, ChargeRequestSchema, ChargeRequestInputSchema, AuthorizationPayloadSchema, ChargePayloadSchema, authorizationTypes;
|
|
20946
|
+
var init_Types = __esm({
|
|
20947
|
+
"node_modules/mppx/dist/evm/Types.js"() {
|
|
20948
|
+
"use strict";
|
|
20949
|
+
init_esm2();
|
|
20950
|
+
init_zod();
|
|
20951
|
+
paymentMethod = "evm";
|
|
20952
|
+
chargeIntent = "charge";
|
|
20953
|
+
evmNetworkPrefix = "eip155:";
|
|
20954
|
+
eip3009 = "eip3009";
|
|
20955
|
+
credentialTypes = ["authorization"];
|
|
20956
|
+
atomicAmount = string2().check(_regex(/^\d+$/, "Invalid atomic amount"));
|
|
20957
|
+
AuthorizationConfigSchema = object({
|
|
20958
|
+
name: string2().check(_minLength(1)),
|
|
20959
|
+
version: string2().check(_minLength(1))
|
|
20960
|
+
});
|
|
20961
|
+
MethodDetailsSchema = object({
|
|
20962
|
+
chainId: number2(),
|
|
20963
|
+
credentialTypes: optional(array(_enum2(credentialTypes)).check(_minLength(1))),
|
|
20964
|
+
decimals: optional(number2()),
|
|
20965
|
+
permit2Address: optional(address()),
|
|
20966
|
+
splits: optional(array(object({
|
|
20967
|
+
amount: atomicAmount,
|
|
20968
|
+
recipient: address()
|
|
20969
|
+
})))
|
|
20970
|
+
});
|
|
20971
|
+
ChargeRequestSchema = object({
|
|
20972
|
+
amount: atomicAmount,
|
|
20973
|
+
currency: address(),
|
|
20974
|
+
description: optional(string2()),
|
|
20975
|
+
externalId: optional(string2()),
|
|
20976
|
+
methodDetails: MethodDetailsSchema,
|
|
20977
|
+
recipient: address()
|
|
20978
|
+
});
|
|
20979
|
+
ChargeRequestInputSchema = object({
|
|
20980
|
+
amount: amount(),
|
|
20981
|
+
chainId: number2(),
|
|
20982
|
+
currency: address(),
|
|
20983
|
+
credentialTypes: optional(array(_enum2(credentialTypes)).check(_minLength(1))),
|
|
20984
|
+
decimals: number2(),
|
|
20985
|
+
description: optional(string2()),
|
|
20986
|
+
externalId: optional(string2()),
|
|
20987
|
+
permit2Address: optional(address()),
|
|
20988
|
+
recipient: address(),
|
|
20989
|
+
splits: optional(array(object({
|
|
20990
|
+
amount: atomicAmount,
|
|
20991
|
+
recipient: address()
|
|
20992
|
+
})))
|
|
20993
|
+
});
|
|
20994
|
+
AuthorizationPayloadSchema = object({
|
|
20995
|
+
from: address(),
|
|
20996
|
+
nonce: hash2(),
|
|
20997
|
+
signature: signature(),
|
|
20998
|
+
to: address(),
|
|
20999
|
+
type: literal("authorization"),
|
|
21000
|
+
validAfter: atomicAmount,
|
|
21001
|
+
validBefore: atomicAmount,
|
|
21002
|
+
value: atomicAmount
|
|
21003
|
+
});
|
|
21004
|
+
ChargePayloadSchema = AuthorizationPayloadSchema;
|
|
21005
|
+
authorizationTypes = {
|
|
21006
|
+
TransferWithAuthorization: [
|
|
21007
|
+
{ name: "from", type: "address" },
|
|
21008
|
+
{ name: "to", type: "address" },
|
|
21009
|
+
{ name: "value", type: "uint256" },
|
|
21010
|
+
{ name: "validAfter", type: "uint256" },
|
|
21011
|
+
{ name: "validBefore", type: "uint256" },
|
|
21012
|
+
{ name: "nonce", type: "bytes32" }
|
|
21013
|
+
]
|
|
21014
|
+
};
|
|
21015
|
+
}
|
|
21016
|
+
});
|
|
21017
|
+
|
|
21018
|
+
// node_modules/mppx/dist/evm/Methods.js
|
|
21019
|
+
var Methods_exports = {};
|
|
21020
|
+
__export(Methods_exports, {
|
|
21021
|
+
charge: () => charge
|
|
21022
|
+
});
|
|
21023
|
+
var charge;
|
|
21024
|
+
var init_Methods = __esm({
|
|
21025
|
+
"node_modules/mppx/dist/evm/Methods.js"() {
|
|
21026
|
+
"use strict";
|
|
21027
|
+
init_esm3();
|
|
21028
|
+
init_Method();
|
|
21029
|
+
init_zod();
|
|
21030
|
+
init_Types();
|
|
21031
|
+
charge = from6({
|
|
21032
|
+
name: paymentMethod,
|
|
21033
|
+
intent: chargeIntent,
|
|
21034
|
+
schema: {
|
|
21035
|
+
credential: {
|
|
21036
|
+
payload: ChargePayloadSchema
|
|
21037
|
+
},
|
|
21038
|
+
request: pipe(ChargeRequestInputSchema, transform(({ amount: amount2, chainId, credentialTypes: credentialTypes2 = ["authorization"], currency, decimals, permit2Address, recipient, splits, ...request }) => ({
|
|
21039
|
+
...request,
|
|
21040
|
+
amount: parseUnits(amount2, decimals).toString(),
|
|
21041
|
+
currency: getAddress(currency),
|
|
21042
|
+
methodDetails: {
|
|
21043
|
+
chainId,
|
|
21044
|
+
credentialTypes: credentialTypes2,
|
|
21045
|
+
decimals,
|
|
21046
|
+
...permit2Address ? { permit2Address: getAddress(permit2Address) } : {},
|
|
21047
|
+
...splits ? { splits } : {}
|
|
21048
|
+
},
|
|
21049
|
+
recipient: getAddress(recipient)
|
|
21050
|
+
})))
|
|
21051
|
+
}
|
|
21052
|
+
});
|
|
21053
|
+
}
|
|
21054
|
+
});
|
|
21055
|
+
|
|
21056
|
+
// node_modules/mppx/dist/evm/index.js
|
|
21057
|
+
var evm_exports = {};
|
|
21058
|
+
__export(evm_exports, {
|
|
21059
|
+
Assets: () => Assets_exports2,
|
|
21060
|
+
AuthorizationConfigSchema: () => AuthorizationConfigSchema,
|
|
21061
|
+
AuthorizationPayloadSchema: () => AuthorizationPayloadSchema,
|
|
21062
|
+
Chains: () => Chains_exports,
|
|
21063
|
+
ChargePayloadSchema: () => ChargePayloadSchema,
|
|
21064
|
+
ChargeRequestInputSchema: () => ChargeRequestInputSchema,
|
|
21065
|
+
ChargeRequestSchema: () => ChargeRequestSchema,
|
|
21066
|
+
MethodDetailsSchema: () => MethodDetailsSchema,
|
|
21067
|
+
Methods: () => Methods_exports,
|
|
21068
|
+
Types: () => Types_exports,
|
|
21069
|
+
assets: () => Assets_exports2,
|
|
21070
|
+
authorizationDomain: () => authorizationDomain,
|
|
21071
|
+
authorizationTypes: () => authorizationTypes,
|
|
21072
|
+
chains: () => Chains_exports,
|
|
21073
|
+
challengeHash: () => challengeHash,
|
|
21074
|
+
charge: () => charge,
|
|
21075
|
+
chargeIntent: () => chargeIntent,
|
|
21076
|
+
credentialTypes: () => credentialTypes,
|
|
21077
|
+
eip3009: () => eip3009,
|
|
21078
|
+
evmNetworkPrefix: () => evmNetworkPrefix,
|
|
21079
|
+
networkOf: () => networkOf,
|
|
21080
|
+
paymentMethod: () => paymentMethod,
|
|
21081
|
+
toSource: () => toSource
|
|
21082
|
+
});
|
|
21083
|
+
var init_evm = __esm({
|
|
21084
|
+
"node_modules/mppx/dist/evm/index.js"() {
|
|
21085
|
+
"use strict";
|
|
21086
|
+
init_Assets2();
|
|
21087
|
+
init_Chains();
|
|
21088
|
+
init_Methods();
|
|
21089
|
+
init_Types();
|
|
21090
|
+
init_Assets2();
|
|
21091
|
+
init_Chains();
|
|
21092
|
+
init_Methods();
|
|
21093
|
+
init_Types();
|
|
21094
|
+
}
|
|
21095
|
+
});
|
|
21096
|
+
|
|
21097
|
+
// node_modules/mppx/dist/Mcp.js
|
|
21098
|
+
var Mcp_exports = {};
|
|
21099
|
+
__export(Mcp_exports, {
|
|
21100
|
+
credentialMetaKey: () => credentialMetaKey,
|
|
21101
|
+
paymentRequiredCode: () => paymentRequiredCode,
|
|
21102
|
+
paymentRequiredMetaKey: () => paymentRequiredMetaKey,
|
|
21103
|
+
paymentVerificationFailedCode: () => paymentVerificationFailedCode,
|
|
21104
|
+
receiptMetaKey: () => receiptMetaKey
|
|
21105
|
+
});
|
|
21106
|
+
var paymentRequiredCode, paymentVerificationFailedCode, credentialMetaKey, paymentRequiredMetaKey, receiptMetaKey;
|
|
21107
|
+
var init_Mcp = __esm({
|
|
21108
|
+
"node_modules/mppx/dist/Mcp.js"() {
|
|
21109
|
+
"use strict";
|
|
21110
|
+
paymentRequiredCode = -32042;
|
|
21111
|
+
paymentVerificationFailedCode = -32043;
|
|
21112
|
+
credentialMetaKey = "org.paymentauth/credential";
|
|
21113
|
+
paymentRequiredMetaKey = "org.paymentauth/payment-required";
|
|
21114
|
+
receiptMetaKey = "org.paymentauth/receipt";
|
|
21115
|
+
}
|
|
21116
|
+
});
|
|
21117
|
+
|
|
21118
|
+
// node_modules/mppx/dist/Receipt.js
|
|
21119
|
+
var Receipt_exports = {};
|
|
21120
|
+
__export(Receipt_exports, {
|
|
21121
|
+
Schema: () => Schema2,
|
|
21122
|
+
deserialize: () => deserialize4,
|
|
21123
|
+
from: () => from7,
|
|
21124
|
+
fromResponse: () => fromResponse2,
|
|
21125
|
+
serialize: () => serialize4
|
|
21126
|
+
});
|
|
21127
|
+
function deserialize4(encoded) {
|
|
21128
|
+
const json2 = Base64_exports.toString(encoded);
|
|
21129
|
+
return from7(JSON.parse(json2));
|
|
21130
|
+
}
|
|
21131
|
+
function from7(parameters) {
|
|
21132
|
+
return Schema2.parse(parameters);
|
|
21133
|
+
}
|
|
21134
|
+
function serialize4(receipt) {
|
|
21135
|
+
const json2 = JSON.stringify(receipt);
|
|
21136
|
+
return Base64_exports.fromString(json2, { pad: false, url: true });
|
|
21137
|
+
}
|
|
21138
|
+
function fromResponse2(response) {
|
|
21139
|
+
const header = response.headers.get(Headers2.paymentReceipt);
|
|
21140
|
+
if (!header)
|
|
21141
|
+
throw new Error(`Missing ${Headers2.paymentReceipt} header.`);
|
|
21142
|
+
return deserialize4(header);
|
|
21143
|
+
}
|
|
21144
|
+
var Schema2;
|
|
21145
|
+
var init_Receipt = __esm({
|
|
21146
|
+
"node_modules/mppx/dist/Receipt.js"() {
|
|
21147
|
+
"use strict";
|
|
21148
|
+
init_esm2();
|
|
21149
|
+
init_Constants();
|
|
21150
|
+
init_zod();
|
|
21151
|
+
Schema2 = object({
|
|
21152
|
+
/** Payment method used (e.g., "tempo", "stripe"). */
|
|
21153
|
+
method: string2(),
|
|
21154
|
+
/** Method-specific reference (e.g., transaction hash). */
|
|
21155
|
+
reference: string2(),
|
|
21156
|
+
/** Optional external reference ID echoed from the credential payload. */
|
|
21157
|
+
externalId: optional(string2()),
|
|
21158
|
+
/** Optional server-issued subscription identifier for recurring payments. */
|
|
21159
|
+
subscriptionId: optional(string2()),
|
|
21160
|
+
/** Payment status. Always "success" — failures use 402 + Problem Details. */
|
|
21161
|
+
status: literal("success"),
|
|
21162
|
+
/** RFC 3339 settlement timestamp. */
|
|
21163
|
+
timestamp: datetime3()
|
|
21164
|
+
});
|
|
21165
|
+
}
|
|
21166
|
+
});
|
|
21167
|
+
|
|
21168
|
+
// node_modules/mppx/dist/Store.js
|
|
21169
|
+
var Store_exports = {};
|
|
21170
|
+
__export(Store_exports, {
|
|
21171
|
+
cloudflare: () => cloudflare,
|
|
21172
|
+
from: () => from8,
|
|
21173
|
+
memory: () => memory,
|
|
21174
|
+
redis: () => redis,
|
|
21175
|
+
upstash: () => upstash
|
|
21176
|
+
});
|
|
21177
|
+
function from8(store, options) {
|
|
21178
|
+
return withKeyPrefix(store, options?.keyPrefix);
|
|
21179
|
+
}
|
|
21180
|
+
function withKeyPrefix(store, keyPrefix = "") {
|
|
21181
|
+
if (!keyPrefix)
|
|
21182
|
+
return store;
|
|
21183
|
+
const cached2 = keyPrefixCache.get(store)?.get(keyPrefix);
|
|
21184
|
+
if (cached2)
|
|
21185
|
+
return cached2;
|
|
21186
|
+
const backing = store;
|
|
21187
|
+
const prefixedKey = (key) => `${keyPrefix}${key}`;
|
|
21188
|
+
const prefixed = from8({
|
|
21189
|
+
async get(key) {
|
|
21190
|
+
return backing.get(prefixedKey(key));
|
|
21191
|
+
},
|
|
21192
|
+
async put(key, value) {
|
|
21193
|
+
await backing.put(prefixedKey(key), value);
|
|
21194
|
+
},
|
|
21195
|
+
async delete(key) {
|
|
21196
|
+
await backing.delete(prefixedKey(key));
|
|
21197
|
+
},
|
|
21198
|
+
..."update" in store ? {
|
|
21199
|
+
async update(key, fn) {
|
|
21200
|
+
return store.update(prefixedKey(key), fn);
|
|
21201
|
+
}
|
|
21202
|
+
} : {}
|
|
21203
|
+
});
|
|
21204
|
+
const cachedByPrefix = keyPrefixCache.get(store) ?? /* @__PURE__ */ new Map();
|
|
21205
|
+
cachedByPrefix.set(keyPrefix, prefixed);
|
|
21206
|
+
keyPrefixCache.set(store, cachedByPrefix);
|
|
21207
|
+
return prefixed;
|
|
21208
|
+
}
|
|
21209
|
+
function wrapJsonUpdate(update) {
|
|
21210
|
+
if (!update)
|
|
21211
|
+
return {};
|
|
21212
|
+
return {
|
|
21213
|
+
async update(key, fn) {
|
|
21214
|
+
return update(key, (current) => {
|
|
21215
|
+
const parsed = current == null ? null : Json_exports.parse(current);
|
|
21216
|
+
const change = fn(parsed);
|
|
21217
|
+
if (change.op !== "set")
|
|
21218
|
+
return change;
|
|
21219
|
+
return { ...change, value: Json_exports.stringify(change.value) };
|
|
21220
|
+
});
|
|
21221
|
+
}
|
|
21222
|
+
};
|
|
21223
|
+
}
|
|
21224
|
+
function cloudflare(kv, options) {
|
|
21225
|
+
return from8({
|
|
21226
|
+
async get(key) {
|
|
21227
|
+
const raw = await kv.get(key);
|
|
21228
|
+
if (raw == null)
|
|
21229
|
+
return null;
|
|
21230
|
+
return Json_exports.parse(raw);
|
|
20165
21231
|
},
|
|
20166
21232
|
async put(key, value) {
|
|
20167
21233
|
await kv.put(key, Json_exports.stringify(value));
|
|
@@ -20170,9 +21236,9 @@ function cloudflare(kv) {
|
|
|
20170
21236
|
await kv.delete(key);
|
|
20171
21237
|
},
|
|
20172
21238
|
...wrapJsonUpdate(kv.update)
|
|
20173
|
-
});
|
|
21239
|
+
}, options);
|
|
20174
21240
|
}
|
|
20175
|
-
function memory() {
|
|
21241
|
+
function memory(options) {
|
|
20176
21242
|
const store = /* @__PURE__ */ new Map();
|
|
20177
21243
|
return from8({
|
|
20178
21244
|
async get(key) {
|
|
@@ -20196,9 +21262,9 @@ function memory() {
|
|
|
20196
21262
|
store.delete(key);
|
|
20197
21263
|
return change.result;
|
|
20198
21264
|
}
|
|
20199
|
-
});
|
|
21265
|
+
}, options);
|
|
20200
21266
|
}
|
|
20201
|
-
function redis(client) {
|
|
21267
|
+
function redis(client, options) {
|
|
20202
21268
|
return from8({
|
|
20203
21269
|
async get(key) {
|
|
20204
21270
|
const raw = await client.get(key);
|
|
@@ -20213,9 +21279,9 @@ function redis(client) {
|
|
|
20213
21279
|
await client.del(key);
|
|
20214
21280
|
},
|
|
20215
21281
|
...wrapJsonUpdate(client.update)
|
|
20216
|
-
});
|
|
21282
|
+
}, options);
|
|
20217
21283
|
}
|
|
20218
|
-
function upstash(redis2) {
|
|
21284
|
+
function upstash(redis2, options) {
|
|
20219
21285
|
return from8({
|
|
20220
21286
|
async get(key) {
|
|
20221
21287
|
return await redis2.get(key);
|
|
@@ -20229,12 +21295,288 @@ function upstash(redis2) {
|
|
|
20229
21295
|
...redis2.update ? {
|
|
20230
21296
|
update: redis2.update
|
|
20231
21297
|
} : {}
|
|
20232
|
-
});
|
|
21298
|
+
}, options);
|
|
20233
21299
|
}
|
|
21300
|
+
var keyPrefixCache;
|
|
20234
21301
|
var init_Store = __esm({
|
|
20235
21302
|
"node_modules/mppx/dist/Store.js"() {
|
|
20236
21303
|
"use strict";
|
|
20237
21304
|
init_esm2();
|
|
21305
|
+
keyPrefixCache = /* @__PURE__ */ new WeakMap();
|
|
21306
|
+
}
|
|
21307
|
+
});
|
|
21308
|
+
|
|
21309
|
+
// node_modules/mppx/dist/internal/HeaderCodec.js
|
|
21310
|
+
function createJson(schema) {
|
|
21311
|
+
return {
|
|
21312
|
+
encode(value) {
|
|
21313
|
+
return Base64_exports.fromString(JSON.stringify(schema.parse(value)));
|
|
21314
|
+
},
|
|
21315
|
+
decode(value) {
|
|
21316
|
+
try {
|
|
21317
|
+
return schema.parse(JSON.parse(Base64_exports.toString(value)));
|
|
21318
|
+
} catch {
|
|
21319
|
+
throw new InvalidJsonHeaderError();
|
|
21320
|
+
}
|
|
21321
|
+
}
|
|
21322
|
+
};
|
|
21323
|
+
}
|
|
21324
|
+
var InvalidJsonHeaderError;
|
|
21325
|
+
var init_HeaderCodec = __esm({
|
|
21326
|
+
"node_modules/mppx/dist/internal/HeaderCodec.js"() {
|
|
21327
|
+
"use strict";
|
|
21328
|
+
init_esm2();
|
|
21329
|
+
InvalidJsonHeaderError = class extends Error {
|
|
21330
|
+
name = "InvalidJsonHeaderError";
|
|
21331
|
+
constructor() {
|
|
21332
|
+
super("Invalid base64 JSON header.");
|
|
21333
|
+
}
|
|
21334
|
+
};
|
|
21335
|
+
}
|
|
21336
|
+
});
|
|
21337
|
+
|
|
21338
|
+
// node_modules/mppx/dist/x402/Types.js
|
|
21339
|
+
var Types_exports2 = {};
|
|
21340
|
+
__export(Types_exports2, {
|
|
21341
|
+
ExactEip3009PayloadSchema: () => ExactEip3009PayloadSchema,
|
|
21342
|
+
ExactPayloadSchema: () => ExactPayloadSchema,
|
|
21343
|
+
ExactPermit2PayloadSchema: () => ExactPermit2PayloadSchema,
|
|
21344
|
+
ExactTransferSchema: () => ExactTransferSchema,
|
|
21345
|
+
ExtensionSchema: () => ExtensionSchema,
|
|
21346
|
+
ExtensionsSchema: () => ExtensionsSchema,
|
|
21347
|
+
PaymentPayloadSchema: () => PaymentPayloadSchema,
|
|
21348
|
+
PaymentRequiredSchema: () => PaymentRequiredSchema,
|
|
21349
|
+
PaymentRequirementsSchema: () => PaymentRequirementsSchema,
|
|
21350
|
+
ResourceInfoSchema: () => ResourceInfoSchema,
|
|
21351
|
+
SettleResponseSchema: () => SettleResponseSchema,
|
|
21352
|
+
VerifyResponseSchema: () => VerifyResponseSchema,
|
|
21353
|
+
assetTransferMethods: () => assetTransferMethods,
|
|
21354
|
+
evmNetworkPrefix: () => evmNetworkPrefix2,
|
|
21355
|
+
exactIntent: () => exactIntent,
|
|
21356
|
+
paymentMethod: () => paymentMethod2,
|
|
21357
|
+
paymentRequiredHeader: () => paymentRequiredHeader,
|
|
21358
|
+
paymentResponseHeader: () => paymentResponseHeader,
|
|
21359
|
+
paymentSignatureHeader: () => paymentSignatureHeader,
|
|
21360
|
+
schemes: () => schemes,
|
|
21361
|
+
syntheticChallengeIdPrefix: () => syntheticChallengeIdPrefix,
|
|
21362
|
+
toPaymentRequirements: () => toPaymentRequirements,
|
|
21363
|
+
versions: () => versions
|
|
21364
|
+
});
|
|
21365
|
+
function toPaymentRequirements(request) {
|
|
21366
|
+
const { extensions: _extensions, resource: _resource, ...paymentRequirements } = request;
|
|
21367
|
+
return PaymentRequirementsSchema.parse(paymentRequirements);
|
|
21368
|
+
}
|
|
21369
|
+
var versions, paymentMethod2, exactIntent, schemes, assetTransferMethods, evmNetworkPrefix2, syntheticChallengeIdPrefix, paymentRequiredHeader, paymentSignatureHeader, paymentResponseHeader, nonEmptyString, positiveNumber, atomicAmount2, address2, evmNetwork, ResourceInfoSchema, ExactTransferSchema, PaymentRequirementsSchema, ExtensionSchema, ExtensionsSchema, PaymentRequiredSchema, ExactEip3009PayloadSchema, ExactPermit2PayloadSchema, ExactPayloadSchema, PaymentPayloadSchema, VerifyResponseSchema, SettleResponseSchema;
|
|
21370
|
+
var init_Types2 = __esm({
|
|
21371
|
+
"node_modules/mppx/dist/x402/Types.js"() {
|
|
21372
|
+
"use strict";
|
|
21373
|
+
init_zod();
|
|
21374
|
+
versions = [2];
|
|
21375
|
+
paymentMethod2 = "evm";
|
|
21376
|
+
exactIntent = "charge";
|
|
21377
|
+
schemes = ["exact"];
|
|
21378
|
+
assetTransferMethods = ["eip3009", "permit2"];
|
|
21379
|
+
evmNetworkPrefix2 = "eip155:";
|
|
21380
|
+
syntheticChallengeIdPrefix = "x402:";
|
|
21381
|
+
paymentRequiredHeader = "PAYMENT-REQUIRED";
|
|
21382
|
+
paymentSignatureHeader = "PAYMENT-SIGNATURE";
|
|
21383
|
+
paymentResponseHeader = "PAYMENT-RESPONSE";
|
|
21384
|
+
nonEmptyString = string2().check(_minLength(1));
|
|
21385
|
+
positiveNumber = number2().check(refine((value) => value > 0, "Must be positive"));
|
|
21386
|
+
atomicAmount2 = string2().check(_regex(/^\d+$/, "Invalid atomic amount"));
|
|
21387
|
+
address2 = address();
|
|
21388
|
+
evmNetwork = string2().check(_regex(new RegExp(`^${evmNetworkPrefix2}\\d+$`), "Invalid EVM CAIP-2 network"));
|
|
21389
|
+
ResourceInfoSchema = object({
|
|
21390
|
+
description: optional(string2()),
|
|
21391
|
+
iconUrl: optional(string2()),
|
|
21392
|
+
mimeType: optional(string2()),
|
|
21393
|
+
serviceName: optional(string2()),
|
|
21394
|
+
tags: optional(array(string2())),
|
|
21395
|
+
url: nonEmptyString
|
|
21396
|
+
});
|
|
21397
|
+
ExactTransferSchema = discriminatedUnion("type", [
|
|
21398
|
+
object({
|
|
21399
|
+
name: nonEmptyString,
|
|
21400
|
+
type: literal("eip3009"),
|
|
21401
|
+
version: nonEmptyString
|
|
21402
|
+
}),
|
|
21403
|
+
object({
|
|
21404
|
+
name: optional(string2()),
|
|
21405
|
+
type: literal("permit2"),
|
|
21406
|
+
version: optional(string2())
|
|
21407
|
+
})
|
|
21408
|
+
]);
|
|
21409
|
+
PaymentRequirementsSchema = object({
|
|
21410
|
+
amount: atomicAmount2,
|
|
21411
|
+
asset: nonEmptyString,
|
|
21412
|
+
extra: optional(record(string2(), unknown())),
|
|
21413
|
+
maxTimeoutSeconds: positiveNumber,
|
|
21414
|
+
network: evmNetwork,
|
|
21415
|
+
payTo: nonEmptyString,
|
|
21416
|
+
scheme: _enum2(schemes)
|
|
21417
|
+
});
|
|
21418
|
+
ExtensionSchema = object({
|
|
21419
|
+
info: record(string2(), unknown()),
|
|
21420
|
+
schema: record(string2(), unknown())
|
|
21421
|
+
});
|
|
21422
|
+
ExtensionsSchema = record(string2(), ExtensionSchema);
|
|
21423
|
+
PaymentRequiredSchema = object({
|
|
21424
|
+
accepts: array(PaymentRequirementsSchema).check(_minLength(1)),
|
|
21425
|
+
error: optional(string2()),
|
|
21426
|
+
extensions: optional(ExtensionsSchema),
|
|
21427
|
+
resource: ResourceInfoSchema,
|
|
21428
|
+
x402Version: literal(2)
|
|
21429
|
+
});
|
|
21430
|
+
ExactEip3009PayloadSchema = object({
|
|
21431
|
+
authorization: object({
|
|
21432
|
+
from: address2,
|
|
21433
|
+
nonce: hash2(),
|
|
21434
|
+
to: address2,
|
|
21435
|
+
validAfter: atomicAmount2,
|
|
21436
|
+
validBefore: atomicAmount2,
|
|
21437
|
+
value: atomicAmount2
|
|
21438
|
+
}),
|
|
21439
|
+
signature: signature()
|
|
21440
|
+
});
|
|
21441
|
+
ExactPermit2PayloadSchema = object({
|
|
21442
|
+
permit2Authorization: object({
|
|
21443
|
+
deadline: atomicAmount2,
|
|
21444
|
+
from: address2,
|
|
21445
|
+
nonce: atomicAmount2,
|
|
21446
|
+
permitted: object({
|
|
21447
|
+
amount: atomicAmount2,
|
|
21448
|
+
token: address2
|
|
21449
|
+
}),
|
|
21450
|
+
spender: address2,
|
|
21451
|
+
witness: object({
|
|
21452
|
+
to: address2,
|
|
21453
|
+
validAfter: atomicAmount2
|
|
21454
|
+
})
|
|
21455
|
+
}),
|
|
21456
|
+
signature: signature()
|
|
21457
|
+
});
|
|
21458
|
+
ExactPayloadSchema = union([ExactEip3009PayloadSchema, ExactPermit2PayloadSchema]);
|
|
21459
|
+
PaymentPayloadSchema = object({
|
|
21460
|
+
accepted: PaymentRequirementsSchema,
|
|
21461
|
+
extensions: optional(ExtensionsSchema),
|
|
21462
|
+
payload: ExactPayloadSchema,
|
|
21463
|
+
resource: optional(ResourceInfoSchema),
|
|
21464
|
+
x402Version: literal(2)
|
|
21465
|
+
});
|
|
21466
|
+
VerifyResponseSchema = object({
|
|
21467
|
+
extensions: optional(ExtensionsSchema),
|
|
21468
|
+
extra: optional(record(string2(), unknown())),
|
|
21469
|
+
invalidMessage: optional(string2()),
|
|
21470
|
+
invalidReason: optional(string2()),
|
|
21471
|
+
isValid: boolean2(),
|
|
21472
|
+
payer: optional(string2())
|
|
21473
|
+
});
|
|
21474
|
+
SettleResponseSchema = object({
|
|
21475
|
+
amount: optional(atomicAmount2),
|
|
21476
|
+
errorMessage: optional(string2()),
|
|
21477
|
+
errorReason: optional(string2()),
|
|
21478
|
+
extensions: optional(ExtensionsSchema),
|
|
21479
|
+
extra: optional(record(string2(), unknown())),
|
|
21480
|
+
network: nonEmptyString,
|
|
21481
|
+
payer: optional(string2()),
|
|
21482
|
+
success: boolean2(),
|
|
21483
|
+
transaction: string2()
|
|
21484
|
+
});
|
|
21485
|
+
}
|
|
21486
|
+
});
|
|
21487
|
+
|
|
21488
|
+
// node_modules/mppx/dist/x402/Header.js
|
|
21489
|
+
var Header_exports = {};
|
|
21490
|
+
__export(Header_exports, {
|
|
21491
|
+
decodePaymentRequired: () => decodePaymentRequired,
|
|
21492
|
+
decodePaymentRequiredEnvelope: () => decodePaymentRequiredEnvelope,
|
|
21493
|
+
decodePaymentResponse: () => decodePaymentResponse,
|
|
21494
|
+
decodePaymentSignature: () => decodePaymentSignature,
|
|
21495
|
+
encodePaymentRequired: () => encodePaymentRequired,
|
|
21496
|
+
encodePaymentResponse: () => encodePaymentResponse,
|
|
21497
|
+
encodePaymentSignature: () => encodePaymentSignature
|
|
21498
|
+
});
|
|
21499
|
+
function decodePaymentRequiredEnvelope(value) {
|
|
21500
|
+
try {
|
|
21501
|
+
const parsed = JSON.parse(Base64_exports.toString(value));
|
|
21502
|
+
return parsePaymentRequiredEnvelope(parsed);
|
|
21503
|
+
} catch {
|
|
21504
|
+
throw new InvalidJsonHeaderError();
|
|
21505
|
+
}
|
|
21506
|
+
}
|
|
21507
|
+
var paymentRequired, paymentSignature, paymentResponse, encodePaymentRequired, decodePaymentRequired, encodePaymentSignature, decodePaymentSignature, encodePaymentResponse, decodePaymentResponse, parsePaymentRequiredEnvelope;
|
|
21508
|
+
var init_Header = __esm({
|
|
21509
|
+
"node_modules/mppx/dist/x402/Header.js"() {
|
|
21510
|
+
"use strict";
|
|
21511
|
+
init_esm2();
|
|
21512
|
+
init_HeaderCodec();
|
|
21513
|
+
init_Types2();
|
|
21514
|
+
paymentRequired = createJson(PaymentRequiredSchema);
|
|
21515
|
+
paymentSignature = createJson(PaymentPayloadSchema);
|
|
21516
|
+
paymentResponse = createJson(SettleResponseSchema);
|
|
21517
|
+
encodePaymentRequired = paymentRequired.encode;
|
|
21518
|
+
decodePaymentRequired = paymentRequired.decode;
|
|
21519
|
+
encodePaymentSignature = paymentSignature.encode;
|
|
21520
|
+
decodePaymentSignature = paymentSignature.decode;
|
|
21521
|
+
encodePaymentResponse = paymentResponse.encode;
|
|
21522
|
+
decodePaymentResponse = paymentResponse.decode;
|
|
21523
|
+
parsePaymentRequiredEnvelope = (value) => {
|
|
21524
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
21525
|
+
throw new InvalidJsonHeaderError();
|
|
21526
|
+
const record2 = value;
|
|
21527
|
+
if (record2.x402Version !== 2 || !Array.isArray(record2.accepts))
|
|
21528
|
+
throw new InvalidJsonHeaderError();
|
|
21529
|
+
const resource = ResourceInfoSchema.parse(record2.resource);
|
|
21530
|
+
const extensions = record2.extensions === void 0 ? void 0 : ExtensionsSchema.parse(record2.extensions);
|
|
21531
|
+
return {
|
|
21532
|
+
accepts: record2.accepts,
|
|
21533
|
+
...extensions ? { extensions } : {},
|
|
21534
|
+
resource,
|
|
21535
|
+
x402Version: 2
|
|
21536
|
+
};
|
|
21537
|
+
};
|
|
21538
|
+
}
|
|
21539
|
+
});
|
|
21540
|
+
|
|
21541
|
+
// node_modules/mppx/dist/x402/index.js
|
|
21542
|
+
var x402_exports = {};
|
|
21543
|
+
__export(x402_exports, {
|
|
21544
|
+
Assets: () => Assets_exports,
|
|
21545
|
+
ExactEip3009PayloadSchema: () => ExactEip3009PayloadSchema,
|
|
21546
|
+
ExactPayloadSchema: () => ExactPayloadSchema,
|
|
21547
|
+
ExactPermit2PayloadSchema: () => ExactPermit2PayloadSchema,
|
|
21548
|
+
ExactTransferSchema: () => ExactTransferSchema,
|
|
21549
|
+
ExtensionSchema: () => ExtensionSchema,
|
|
21550
|
+
ExtensionsSchema: () => ExtensionsSchema,
|
|
21551
|
+
Header: () => Header_exports,
|
|
21552
|
+
PaymentPayloadSchema: () => PaymentPayloadSchema,
|
|
21553
|
+
PaymentRequiredSchema: () => PaymentRequiredSchema,
|
|
21554
|
+
PaymentRequirementsSchema: () => PaymentRequirementsSchema,
|
|
21555
|
+
ResourceInfoSchema: () => ResourceInfoSchema,
|
|
21556
|
+
SettleResponseSchema: () => SettleResponseSchema,
|
|
21557
|
+
Types: () => Types_exports2,
|
|
21558
|
+
VerifyResponseSchema: () => VerifyResponseSchema,
|
|
21559
|
+
assetTransferMethods: () => assetTransferMethods,
|
|
21560
|
+
assets: () => Assets_exports,
|
|
21561
|
+
evmNetworkPrefix: () => evmNetworkPrefix2,
|
|
21562
|
+
exactIntent: () => exactIntent,
|
|
21563
|
+
paymentMethod: () => paymentMethod2,
|
|
21564
|
+
paymentRequiredHeader: () => paymentRequiredHeader,
|
|
21565
|
+
paymentResponseHeader: () => paymentResponseHeader,
|
|
21566
|
+
paymentSignatureHeader: () => paymentSignatureHeader,
|
|
21567
|
+
schemes: () => schemes,
|
|
21568
|
+
syntheticChallengeIdPrefix: () => syntheticChallengeIdPrefix,
|
|
21569
|
+
toPaymentRequirements: () => toPaymentRequirements,
|
|
21570
|
+
versions: () => versions
|
|
21571
|
+
});
|
|
21572
|
+
var init_x402 = __esm({
|
|
21573
|
+
"node_modules/mppx/dist/x402/index.js"() {
|
|
21574
|
+
"use strict";
|
|
21575
|
+
init_Assets();
|
|
21576
|
+
init_Header();
|
|
21577
|
+
init_Types2();
|
|
21578
|
+
init_Assets();
|
|
21579
|
+
init_Types2();
|
|
20238
21580
|
}
|
|
20239
21581
|
});
|
|
20240
21582
|
|
|
@@ -20243,6 +21585,7 @@ var dist_exports = {};
|
|
|
20243
21585
|
__export(dist_exports, {
|
|
20244
21586
|
BodyDigest: () => BodyDigest_exports,
|
|
20245
21587
|
Challenge: () => Challenge_exports,
|
|
21588
|
+
Constants: () => Constants_exports,
|
|
20246
21589
|
Credential: () => Credential_exports,
|
|
20247
21590
|
Errors: () => Errors_exports2,
|
|
20248
21591
|
Expires: () => Expires_exports,
|
|
@@ -20251,6 +21594,8 @@ __export(dist_exports, {
|
|
|
20251
21594
|
PaymentRequest: () => PaymentRequest_exports,
|
|
20252
21595
|
Receipt: () => Receipt_exports,
|
|
20253
21596
|
Store: () => Store_exports,
|
|
21597
|
+
evm: () => evm_exports,
|
|
21598
|
+
x402: () => x402_exports,
|
|
20254
21599
|
z: () => zod_exports
|
|
20255
21600
|
});
|
|
20256
21601
|
var init_dist2 = __esm({
|
|
@@ -20258,14 +21603,17 @@ var init_dist2 = __esm({
|
|
|
20258
21603
|
"use strict";
|
|
20259
21604
|
init_BodyDigest();
|
|
20260
21605
|
init_Challenge();
|
|
21606
|
+
init_Constants();
|
|
20261
21607
|
init_Credential();
|
|
20262
21608
|
init_Errors2();
|
|
20263
21609
|
init_Expires();
|
|
21610
|
+
init_evm();
|
|
20264
21611
|
init_Mcp();
|
|
20265
21612
|
init_Method();
|
|
20266
21613
|
init_PaymentRequest();
|
|
20267
21614
|
init_Receipt();
|
|
20268
21615
|
init_Store();
|
|
21616
|
+
init_x402();
|
|
20269
21617
|
init_zod();
|
|
20270
21618
|
}
|
|
20271
21619
|
});
|
|
@@ -20293,12 +21641,20 @@ var init_usdc = __esm({
|
|
|
20293
21641
|
});
|
|
20294
21642
|
|
|
20295
21643
|
// src/payment/wwwauthenticate.ts
|
|
20296
|
-
function
|
|
21644
|
+
function paymentRequiredHeader2({
|
|
20297
21645
|
x402Version,
|
|
20298
21646
|
accepts,
|
|
20299
|
-
resource
|
|
21647
|
+
resource,
|
|
21648
|
+
extensions
|
|
20300
21649
|
}) {
|
|
20301
|
-
return Buffer.from(
|
|
21650
|
+
return Buffer.from(
|
|
21651
|
+
JSON.stringify({
|
|
21652
|
+
x402Version,
|
|
21653
|
+
accepts,
|
|
21654
|
+
...resource ? { resource } : {},
|
|
21655
|
+
...extensions && Object.keys(extensions).length > 0 ? { extensions } : {}
|
|
21656
|
+
})
|
|
21657
|
+
).toString("base64");
|
|
20302
21658
|
}
|
|
20303
21659
|
var init_wwwauthenticate = __esm({
|
|
20304
21660
|
"src/payment/wwwauthenticate.ts"() {
|
|
@@ -20593,7 +21949,7 @@ function buildDiscoveryProbeResponse(opts) {
|
|
|
20593
21949
|
if (opts.x402Sample) {
|
|
20594
21950
|
const x402Version = opts.x402Sample.version ?? 2;
|
|
20595
21951
|
const sampleAccepts = opts.x402Sample.accepts ?? (opts.x402Sample.networks ?? []).map((n) => sampleX402AcceptForNetwork(n, opts.x402Sample.amountAtomic ?? "1000000")).filter((e) => e !== null);
|
|
20596
|
-
headers["payment-required"] =
|
|
21952
|
+
headers["payment-required"] = paymentRequiredHeader2({
|
|
20597
21953
|
x402Version,
|
|
20598
21954
|
accepts: sampleAccepts,
|
|
20599
21955
|
...opts.x402Sample.resourceUrl ? { resource: { url: opts.x402Sample.resourceUrl, mimeType: "application/json" } } : {}
|
|
@@ -20882,7 +22238,7 @@ function buildSignerMismatchBody({
|
|
|
20882
22238
|
learnMoreUrl
|
|
20883
22239
|
}) {
|
|
20884
22240
|
if (result.kind === "pass") return null;
|
|
20885
|
-
const learnMoreUrlResolved = learnMoreUrl ?? "https://docs.agentscore.
|
|
22241
|
+
const learnMoreUrlResolved = learnMoreUrl ?? "https://docs.agentscore.com/guides/agent-identity";
|
|
20886
22242
|
if (result.kind === "wallet_signer_mismatch") {
|
|
20887
22243
|
const linkedWallets = result.linkedWallets ?? [];
|
|
20888
22244
|
const userMessageResolved = userMessage ?? (linkedWallets.length > 0 ? `Sign the payment with one of the wallets linked to this operator: ${linkedWallets.join(", ")}. Then retry.` : "Sign the payment with the same wallet you claimed via X-Wallet-Address, or switch to X-Operator-Token for rail-independent identity.");
|
|
@@ -20932,7 +22288,7 @@ function verificationAgentInstructions({
|
|
|
20932
22288
|
extra
|
|
20933
22289
|
} = {}) {
|
|
20934
22290
|
const baseSteps = [
|
|
20935
|
-
"Present the verify_url directly to the user \u2014 it is a complete, ready-to-open URL with the session token already embedded (e.g. https://agentscore.
|
|
22291
|
+
"Present the verify_url directly to the user \u2014 it is a complete, ready-to-open URL with the session token already embedded (e.g. https://www.agentscore.com/verify?session=sess_...). Do NOT modify or construct the URL yourself.",
|
|
20936
22292
|
`Immediately begin polling poll_url every ${pollIntervalSeconds} seconds with header X-Poll-Secret set to poll_secret. The user will complete verification in their browser while you poll in the background.`,
|
|
20937
22293
|
"The user visits the URL, signs in, completes identity verification (photo ID + selfie via Stripe Identity), and closes the tab. They do NOT need to copy or paste anything back to you.",
|
|
20938
22294
|
'When your poll returns status "verified", extract operator_token from the response. This is a one-time value \u2014 save it immediately. Subsequent polls return status "consumed" without the token.',
|
|
@@ -20981,7 +22337,7 @@ var IDENTITY_VERIFICATION_REQUIRED_FALLBACK_INSTRUCTIONS = JSON.stringify({
|
|
|
20981
22337
|
var API_ERROR_INSTRUCTIONS = JSON.stringify({
|
|
20982
22338
|
action: "retry_with_backoff",
|
|
20983
22339
|
steps: [
|
|
20984
|
-
"Verification is temporarily unavailable. Retry the request after 5
|
|
22340
|
+
"Verification is temporarily unavailable. Retry the request after 5-30 seconds with exponential backoff.",
|
|
20985
22341
|
"This is NOT a compliance denial \u2014 the user does not need to re-verify their identity. Send the same identity headers (X-Wallet-Address or X-Operator-Token) on retry.",
|
|
20986
22342
|
"If the request continues to fail after 3+ retries (~60 seconds total), surface the error to the user with the merchant's support contact."
|
|
20987
22343
|
],
|
|
@@ -21084,12 +22440,12 @@ function denialReasonToBody(reason) {
|
|
|
21084
22440
|
|
|
21085
22441
|
// src/address.ts
|
|
21086
22442
|
var SOLANA_BASE58_RE = /^[1-9A-HJ-NP-Za-km-z]{32,44}$/;
|
|
21087
|
-
var isSolanaAddress = (
|
|
21088
|
-
var normalizeAddress = (
|
|
21089
|
-
if (isSolanaAddress(
|
|
21090
|
-
return
|
|
22443
|
+
var isSolanaAddress = (address3) => SOLANA_BASE58_RE.test(address3) && !address3.startsWith("0x");
|
|
22444
|
+
var normalizeAddress = (address3) => {
|
|
22445
|
+
if (isSolanaAddress(address3)) {
|
|
22446
|
+
return address3;
|
|
21091
22447
|
}
|
|
21092
|
-
return
|
|
22448
|
+
return address3.toLowerCase();
|
|
21093
22449
|
};
|
|
21094
22450
|
|
|
21095
22451
|
// src/cache.ts
|
|
@@ -21148,7 +22504,7 @@ function stripTrailingSlashes(s) {
|
|
|
21148
22504
|
while (end > 0 && s.charCodeAt(end - 1) === 47) end--;
|
|
21149
22505
|
return end === s.length ? s : s.slice(0, end);
|
|
21150
22506
|
}
|
|
21151
|
-
var CANONICAL_AGENTSCORE_API = "https://api.agentscore.
|
|
22507
|
+
var CANONICAL_AGENTSCORE_API = "https://api.agentscore.com";
|
|
21152
22508
|
var WALLET_SIGNER_MISMATCH_INSTRUCTIONS = JSON.stringify({
|
|
21153
22509
|
action: "resign_or_switch_to_operator_token",
|
|
21154
22510
|
steps: [
|
|
@@ -21180,7 +22536,7 @@ function buildAgentMemoryHint(aipTrustedIssuers) {
|
|
|
21180
22536
|
return {
|
|
21181
22537
|
save_for_future_agentscore_gates: true,
|
|
21182
22538
|
pattern_summary: "AgentScore is a cross-merchant identity substrate for agent commerce. Any endpoint that returns 403 missing_identity / identity_verification_required or 402 challenges referencing AgentScore uses the same identity system. One KYC works across all AgentScore merchants \u2014 no re-verification per site. Save this pattern (and the endpoints below) to persistent memory so future AgentScore encounters skip the cold-start session flow.",
|
|
21183
|
-
quickstart: "https://docs.agentscore.
|
|
22539
|
+
quickstart: "https://docs.agentscore.com/guides/agent-identity",
|
|
21184
22540
|
identity_check_endpoint: `${api}/v1/credentials`,
|
|
21185
22541
|
identity_paths: {
|
|
21186
22542
|
wallet: "If paying from a crypto wallet you have used before on any AgentScore merchant, send `X-Wallet-Address: 0x...`. Shortest path; no token lifecycle to manage.",
|
|
@@ -21197,7 +22553,7 @@ function buildAgentMemoryHint(aipTrustedIssuers) {
|
|
|
21197
22553
|
}
|
|
21198
22554
|
function createAgentScoreCore(options) {
|
|
21199
22555
|
if (!options.apiKey) {
|
|
21200
|
-
throw new Error("AgentScore API key is required. Get one at https://agentscore.
|
|
22556
|
+
throw new Error("AgentScore API key is required. Get one at https://www.agentscore.com/sign-up");
|
|
21201
22557
|
}
|
|
21202
22558
|
const {
|
|
21203
22559
|
apiKey,
|
|
@@ -21208,7 +22564,7 @@ function createAgentScoreCore(options) {
|
|
|
21208
22564
|
allowedJurisdictions,
|
|
21209
22565
|
failOpen = false,
|
|
21210
22566
|
cacheSeconds = 300,
|
|
21211
|
-
baseUrl: rawBaseUrl = "https://api.agentscore.
|
|
22567
|
+
baseUrl: rawBaseUrl = "https://api.agentscore.com",
|
|
21212
22568
|
chain: gateChain,
|
|
21213
22569
|
userAgent,
|
|
21214
22570
|
createSessionOnMissing,
|
|
@@ -21216,7 +22572,7 @@ function createAgentScoreCore(options) {
|
|
|
21216
22572
|
} = options;
|
|
21217
22573
|
const baseUrl = stripTrailingSlashes(rawBaseUrl);
|
|
21218
22574
|
const agentMemoryHint = buildAgentMemoryHint(aipTrustedIssuers);
|
|
21219
|
-
const defaultUa = `@agent-score/commerce@${"2.
|
|
22575
|
+
const defaultUa = `@agent-score/commerce@${"2.6.0"}`;
|
|
21220
22576
|
const userAgentHeader = userAgent ? `${userAgent} (${defaultUa})` : defaultUa;
|
|
21221
22577
|
const sdk = new AgentScore({ apiKey, baseUrl, userAgent: userAgentHeader });
|
|
21222
22578
|
const sessionSdkCache = /* @__PURE__ */ new Map();
|
|
@@ -21234,7 +22590,6 @@ function createAgentScoreCore(options) {
|
|
|
21234
22590
|
return s;
|
|
21235
22591
|
}
|
|
21236
22592
|
const cache = new TTLCache(cacheSeconds * 1e3);
|
|
21237
|
-
const lastSignerRaw = /* @__PURE__ */ new Map();
|
|
21238
22593
|
async function tryMintSessionDenial(ctx) {
|
|
21239
22594
|
if (!createSessionOnMissing) return void 0;
|
|
21240
22595
|
try {
|
|
@@ -21306,7 +22661,7 @@ function createAgentScoreCore(options) {
|
|
|
21306
22661
|
...aipStep,
|
|
21307
22662
|
"If you have a wallet AND this merchant accepts a wallet-signing rail (Tempo MPP or x402 \u2014 see openapi.json x-payment-info): send X-Wallet-Address and retry. If the wallet is already linked to an AgentScore operator (via prior SIWE claim or prior captureWallet), this passes in one round trip. If the wallet is unlinked or the account has no KYC, the 403 will include a verify_url \u2014 share it with the user to claim the wallet + complete KYC, then retry.",
|
|
21308
22663
|
"If step 1 is denied or you already have a stored operator_token (valid + not expired): send X-Operator-Token: opc_... and retry.",
|
|
21309
|
-
"If neither applies: retry with NO identity header. Merchants that auto-create verification sessions (most AgentScore merchants do) return verify_url + session_id + poll_secret in the 403 body \u2014 share verify_url with the user, then poll poll_url every 5s with the X-Poll-Secret header until status=verified (the poll returns a one-time operator_token). If the retry returns the same bare 403, this merchant does not support self-service session bootstrapping \u2014 direct the user to https://agentscore.
|
|
22664
|
+
"If neither applies: retry with NO identity header. Merchants that auto-create verification sessions (most AgentScore merchants do) return verify_url + session_id + poll_secret in the 403 body \u2014 share verify_url with the user, then poll poll_url every 5s with the X-Poll-Secret header until status=verified (the poll returns a one-time operator_token). If the retry returns the same bare 403, this merchant does not support self-service session bootstrapping \u2014 direct the user to https://www.agentscore.com/sign-up to create an AgentScore identity and mint an operator_token from their dashboard (https://www.agentscore.com/dashboard/verify). The user hands the opc_... to you, and you retry with X-Operator-Token."
|
|
21310
22665
|
],
|
|
21311
22666
|
user_message: "Try X-Wallet-Address first if you have a wallet and the merchant accepts Tempo/x402; fall back to a stored X-Operator-Token, then to the session/verify flow described in agent_memory.bootstrap."
|
|
21312
22667
|
});
|
|
@@ -21319,21 +22674,26 @@ function createAgentScoreCore(options) {
|
|
|
21319
22674
|
}
|
|
21320
22675
|
};
|
|
21321
22676
|
}
|
|
21322
|
-
const
|
|
22677
|
+
const identityKey = identity.aipToken ? `aip:${createHash("sha256").update(identity.aipToken).digest("hex")}` : identity.operatorToken?.toLowerCase() ?? (identity.address ? normalizeAddress(identity.address) : "");
|
|
22678
|
+
const cacheKey2 = signer ? JSON.stringify([identityKey, signer.network, normalizeAddress(signer.address)]) : JSON.stringify([identityKey]);
|
|
21323
22679
|
const cached2 = cache.get(cacheKey2);
|
|
21324
22680
|
if (cached2) {
|
|
22681
|
+
const cachedVerdict = cached2.raw ? buildSignerVerdict(identity, cached2.raw) : void 0;
|
|
21325
22682
|
if (cached2.allow) {
|
|
21326
22683
|
const cachedRaw = cached2.raw;
|
|
21327
22684
|
const cachedQuota = cachedRaw?.quota;
|
|
21328
22685
|
return {
|
|
21329
22686
|
kind: "allow",
|
|
21330
22687
|
data: cachedRaw,
|
|
21331
|
-
...cachedQuota !== void 0 && { quota: cachedQuota }
|
|
22688
|
+
...cachedQuota !== void 0 && { quota: cachedQuota },
|
|
22689
|
+
...cachedVerdict !== void 0 && { signerVerdict: cachedVerdict }
|
|
21332
22690
|
};
|
|
21333
22691
|
}
|
|
21334
22692
|
if (isFixableDenial(cached2.reasons)) {
|
|
21335
22693
|
const sessionReason = await tryMintSessionDenial(ctx);
|
|
21336
|
-
if (sessionReason)
|
|
22694
|
+
if (sessionReason) {
|
|
22695
|
+
return { kind: "deny", reason: sessionReason, ...cachedVerdict !== void 0 && { signerVerdict: cachedVerdict } };
|
|
22696
|
+
}
|
|
21337
22697
|
}
|
|
21338
22698
|
return {
|
|
21339
22699
|
kind: "deny",
|
|
@@ -21343,7 +22703,8 @@ function createAgentScoreCore(options) {
|
|
|
21343
22703
|
reasons: cached2.reasons,
|
|
21344
22704
|
verify_url: cached2.raw?.verify_url,
|
|
21345
22705
|
data: cached2.raw
|
|
21346
|
-
}
|
|
22706
|
+
},
|
|
22707
|
+
...cachedVerdict !== void 0 && { signerVerdict: cachedVerdict }
|
|
21347
22708
|
};
|
|
21348
22709
|
}
|
|
21349
22710
|
const policy = {};
|
|
@@ -21364,7 +22725,10 @@ function createAgentScoreCore(options) {
|
|
|
21364
22725
|
// regardless of policy.require_sanctions_clear (which gates the separate NAME screen).
|
|
21365
22726
|
...signer && { signer: { address: signer.address, network: signer.network } }
|
|
21366
22727
|
};
|
|
21367
|
-
|
|
22728
|
+
if (identity.aipToken !== void 0 && identity.aipSignature === void 0) {
|
|
22729
|
+
throw new Error("AgentScoreCore.evaluate: aipToken requires aipSignature (RFC 9421 proof-of-possession material).");
|
|
22730
|
+
}
|
|
22731
|
+
const result = identity.aipToken !== void 0 && identity.aipSignature !== void 0 ? await sdk.assess(null, { ...opts, aipToken: identity.aipToken, aipSignature: identity.aipSignature }) : identity.address ? await sdk.assess(identity.address, { ...opts, operatorToken: identity.operatorToken }) : await sdk.assess(null, { ...opts, operatorToken: identity.operatorToken });
|
|
21368
22732
|
data = result;
|
|
21369
22733
|
} catch (err) {
|
|
21370
22734
|
if (err instanceof PaymentRequiredError) {
|
|
@@ -21435,20 +22799,21 @@ function createAgentScoreCore(options) {
|
|
|
21435
22799
|
const decisionReasons = data.decision_reasons ?? [];
|
|
21436
22800
|
const allow = decision === "allow" || decision == null;
|
|
21437
22801
|
cache.set(cacheKey2, { allow, decision: decision ?? void 0, reasons: decisionReasons, raw: data });
|
|
21438
|
-
|
|
21439
|
-
lastSignerRaw.set(normalizeAddress(identity.address), data);
|
|
21440
|
-
}
|
|
22802
|
+
const signerVerdict = buildSignerVerdict(identity, data);
|
|
21441
22803
|
if (allow) {
|
|
21442
22804
|
const quota = data.quota;
|
|
21443
22805
|
return {
|
|
21444
22806
|
kind: "allow",
|
|
21445
22807
|
data,
|
|
21446
|
-
...quota !== void 0 && { quota }
|
|
22808
|
+
...quota !== void 0 && { quota },
|
|
22809
|
+
...signerVerdict !== void 0 && { signerVerdict }
|
|
21447
22810
|
};
|
|
21448
22811
|
}
|
|
21449
22812
|
if (isFixableDenial(decisionReasons)) {
|
|
21450
22813
|
const sessionReason = await tryMintSessionDenial(ctx);
|
|
21451
|
-
if (sessionReason)
|
|
22814
|
+
if (sessionReason) {
|
|
22815
|
+
return { kind: "deny", reason: sessionReason, ...signerVerdict !== void 0 && { signerVerdict } };
|
|
22816
|
+
}
|
|
21452
22817
|
}
|
|
21453
22818
|
return {
|
|
21454
22819
|
kind: "deny",
|
|
@@ -21458,7 +22823,8 @@ function createAgentScoreCore(options) {
|
|
|
21458
22823
|
reasons: decisionReasons,
|
|
21459
22824
|
verify_url: data.verify_url,
|
|
21460
22825
|
data
|
|
21461
|
-
}
|
|
22826
|
+
},
|
|
22827
|
+
...signerVerdict !== void 0 && { signerVerdict }
|
|
21462
22828
|
};
|
|
21463
22829
|
}
|
|
21464
22830
|
async function captureWallet(options2) {
|
|
@@ -21500,20 +22866,21 @@ function createAgentScoreCore(options) {
|
|
|
21500
22866
|
agentInstructions: sm.agent_instructions ?? WALLET_SIGNER_MISMATCH_INSTRUCTIONS
|
|
21501
22867
|
};
|
|
21502
22868
|
}
|
|
21503
|
-
function
|
|
21504
|
-
|
|
21505
|
-
|
|
21506
|
-
|
|
22869
|
+
function buildSignerVerdict(identity, raw) {
|
|
22870
|
+
if (identity.address === void 0 || identity.operatorToken !== void 0 || identity.aipToken !== void 0) {
|
|
22871
|
+
return void 0;
|
|
22872
|
+
}
|
|
21507
22873
|
const rawMatch = raw.signer_match;
|
|
21508
22874
|
const rawSanctions = raw.signer_sanctions;
|
|
21509
22875
|
if (!rawMatch && !rawSanctions) return void 0;
|
|
22876
|
+
const claimedNorm = normalizeAddress(identity.address);
|
|
21510
22877
|
const signerNorm = rawMatch?.actual_signer ?? claimedNorm;
|
|
21511
22878
|
return {
|
|
21512
22879
|
signer_match: rawMatch ? projectSignerMatch(rawMatch, claimedNorm, signerNorm) : null,
|
|
21513
22880
|
signer_sanctions: rawSanctions ?? null
|
|
21514
22881
|
};
|
|
21515
22882
|
}
|
|
21516
|
-
return { evaluate, captureWallet
|
|
22883
|
+
return { evaluate, captureWallet };
|
|
21517
22884
|
}
|
|
21518
22885
|
|
|
21519
22886
|
// src/_headers.ts
|
|
@@ -21625,6 +22992,7 @@ var DEFAULT_TRANSPORT = "JSONRPC";
|
|
|
21625
22992
|
var DEFAULT_INPUT_MODE = "application/json";
|
|
21626
22993
|
var DEFAULT_OUTPUT_MODE = "application/json";
|
|
21627
22994
|
var UCP_A2A_EXTENSION_URI = "https://ucp.dev/2026-04-08/specification/reference";
|
|
22995
|
+
var AIP_A2A_EXTENSION_URI = "https://www.agentscore.com/.well-known/agent-identity";
|
|
21628
22996
|
function ucpA2AExtension(capabilities = {}, options = {}) {
|
|
21629
22997
|
return {
|
|
21630
22998
|
uri: UCP_A2A_EXTENSION_URI,
|
|
@@ -21633,6 +23001,20 @@ function ucpA2AExtension(capabilities = {}, options = {}) {
|
|
|
21633
23001
|
params: { capabilities }
|
|
21634
23002
|
};
|
|
21635
23003
|
}
|
|
23004
|
+
function aipA2AExtension(opts = {}) {
|
|
23005
|
+
return {
|
|
23006
|
+
uri: AIP_A2A_EXTENSION_URI,
|
|
23007
|
+
description: "AIP support: present an Agent Identity Token (JWT) in an Agent-Identity header plus an RFC 9421 HTTP Message Signature (over @method @authority @path agent-identity) proving possession of the token-bound cnf key. `agentscore-pay pay --identity aip` attaches it automatically.",
|
|
23008
|
+
required: opts.required ?? false,
|
|
23009
|
+
params: {
|
|
23010
|
+
header: "Agent-Identity",
|
|
23011
|
+
signature: "RFC 9421",
|
|
23012
|
+
...opts.trustedIssuers !== void 0 && opts.trustedIssuers.length > 0 && { trusted_issuers: opts.trustedIssuers },
|
|
23013
|
+
...opts.requiredTrustLevel !== void 0 && { required_trust_level: opts.requiredTrustLevel },
|
|
23014
|
+
...opts.requiredAmr !== void 0 && opts.requiredAmr.length > 0 && { required_amr: opts.requiredAmr }
|
|
23015
|
+
}
|
|
23016
|
+
};
|
|
23017
|
+
}
|
|
21636
23018
|
function buildA2AAgentCard(input) {
|
|
21637
23019
|
if (!input.skills || input.skills.length === 0) {
|
|
21638
23020
|
throw new Error(
|
|
@@ -21699,26 +23081,45 @@ var CheckoutValidationError = class extends Error {
|
|
|
21699
23081
|
};
|
|
21700
23082
|
|
|
21701
23083
|
// src/identity/policy.ts
|
|
21702
|
-
function buildGateFromPolicy(policy,
|
|
23084
|
+
function buildGateFromPolicy(policy, base3) {
|
|
21703
23085
|
if (!policy || !policy.enforcement) return null;
|
|
21704
23086
|
return {
|
|
21705
|
-
apiKey:
|
|
21706
|
-
...
|
|
23087
|
+
apiKey: base3.apiKey,
|
|
23088
|
+
...base3.baseUrl !== void 0 && { baseUrl: base3.baseUrl },
|
|
21707
23089
|
...policy.requireKyc !== void 0 && { requireKyc: policy.requireKyc },
|
|
21708
23090
|
...policy.requireSanctionsClear !== void 0 && {
|
|
21709
23091
|
requireSanctionsClear: policy.requireSanctionsClear
|
|
21710
23092
|
},
|
|
21711
23093
|
...policy.minAge !== void 0 && { minAge: policy.minAge },
|
|
23094
|
+
...policy.blockedJurisdictions !== void 0 && {
|
|
23095
|
+
blockedJurisdictions: [...policy.blockedJurisdictions]
|
|
23096
|
+
},
|
|
21712
23097
|
...policy.allowedJurisdictions !== void 0 && {
|
|
21713
23098
|
allowedJurisdictions: [...policy.allowedJurisdictions]
|
|
21714
23099
|
}
|
|
21715
23100
|
};
|
|
21716
23101
|
}
|
|
23102
|
+
var SANCTIONS_DENIAL_REASONS = /* @__PURE__ */ new Set([
|
|
23103
|
+
"sanctions_flagged",
|
|
23104
|
+
"sanctions_check_unavailable"
|
|
23105
|
+
]);
|
|
23106
|
+
function isSanctionsDenial(body) {
|
|
23107
|
+
if (!body || typeof body !== "object") return false;
|
|
23108
|
+
for (const key of ["reasons", "decision_reasons"]) {
|
|
23109
|
+
const raw = body[key];
|
|
23110
|
+
if (Array.isArray(raw) && raw.some((r) => typeof r === "string" && SANCTIONS_DENIAL_REASONS.has(r))) {
|
|
23111
|
+
return true;
|
|
23112
|
+
}
|
|
23113
|
+
}
|
|
23114
|
+
const error51 = body.error;
|
|
23115
|
+
const code = error51 && typeof error51 === "object" ? error51.code : void 0;
|
|
23116
|
+
return typeof code === "string" && SANCTIONS_DENIAL_REASONS.has(code);
|
|
23117
|
+
}
|
|
21717
23118
|
async function runGateWithEnforcement(enforcement, runGate) {
|
|
21718
23119
|
if (!runGate || !enforcement) return { status: "anonymous" };
|
|
21719
23120
|
const outcome = await runGate();
|
|
21720
23121
|
if (outcome.ok) return { status: "verified" };
|
|
21721
|
-
if (enforcement === "hard") {
|
|
23122
|
+
if (enforcement === "hard" || isSanctionsDenial(outcome.body)) {
|
|
21722
23123
|
return {
|
|
21723
23124
|
status: "denied",
|
|
21724
23125
|
denialStatus: outcome.status,
|
|
@@ -21808,7 +23209,7 @@ function extractOwnerScope(input) {
|
|
|
21808
23209
|
const walletAddress = readHeader(headers, "x-wallet-address");
|
|
21809
23210
|
const operatorToken = readHeader(headers, "x-operator-token");
|
|
21810
23211
|
return {
|
|
21811
|
-
...walletAddress ? { walletAddress } : {},
|
|
23212
|
+
...walletAddress ? { walletAddress: normalizeAddress(walletAddress) } : {},
|
|
21812
23213
|
...operatorToken ? { operatorTokenHash: hashOperatorToken(operatorToken) } : {}
|
|
21813
23214
|
};
|
|
21814
23215
|
}
|
|
@@ -21878,6 +23279,7 @@ var bytesToB64 = (bytes) => {
|
|
|
21878
23279
|
var AIP_COVERED_COMPONENTS = ["@method", "@authority", "@path", "agent-identity"];
|
|
21879
23280
|
var AIP_SIGNATURE_TAG = "agent-identity";
|
|
21880
23281
|
var DEFAULT_MAX_SKEW_SECONDS = 60;
|
|
23282
|
+
var MAX_POP_WINDOW_SECONDS = 120;
|
|
21881
23283
|
var normalizeAuthority = (authority) => {
|
|
21882
23284
|
const lower = authority.trim().toLowerCase();
|
|
21883
23285
|
const colon = lower.lastIndexOf(":");
|
|
@@ -21928,7 +23330,7 @@ var serializeParams = (p) => {
|
|
|
21928
23330
|
}
|
|
21929
23331
|
return parts.map((s) => `;${s}`).join("");
|
|
21930
23332
|
};
|
|
21931
|
-
var buildSignatureBase = (params, input) => {
|
|
23333
|
+
var buildSignatureBase = (params, input, rawSignatureParams) => {
|
|
21932
23334
|
const lines = [];
|
|
21933
23335
|
for (const name of params.components) {
|
|
21934
23336
|
const value = componentValue(name, input);
|
|
@@ -21937,7 +23339,7 @@ var buildSignatureBase = (params, input) => {
|
|
|
21937
23339
|
}
|
|
21938
23340
|
lines.push(`"${name}": ${value}`);
|
|
21939
23341
|
}
|
|
21940
|
-
const paramsValue = serializeComponentList(params.components) + serializeParams(params);
|
|
23342
|
+
const paramsValue = rawSignatureParams ?? serializeComponentList(params.components) + serializeParams(params);
|
|
21941
23343
|
lines.push(`"@signature-params": ${paramsValue}`);
|
|
21942
23344
|
return lines.join("\n");
|
|
21943
23345
|
};
|
|
@@ -21956,19 +23358,12 @@ var parseSignatureInput = (header, tag = AIP_SIGNATURE_TAG) => {
|
|
|
21956
23358
|
}
|
|
21957
23359
|
const parsed = members.map((m) => {
|
|
21958
23360
|
const params = parseInnerListMember(m.value);
|
|
21959
|
-
return params ? { label: m.label, params } : null;
|
|
23361
|
+
return params ? { label: m.label, params, rawParams: m.value } : null;
|
|
21960
23362
|
}).filter((x) => x !== null);
|
|
21961
23363
|
if (parsed.length === 0) {
|
|
21962
23364
|
return null;
|
|
21963
23365
|
}
|
|
21964
|
-
|
|
21965
|
-
if (tagged) {
|
|
21966
|
-
return tagged;
|
|
21967
|
-
}
|
|
21968
|
-
if (parsed.length === 1 && parsed[0].params.tag === void 0) {
|
|
21969
|
-
return parsed[0];
|
|
21970
|
-
}
|
|
21971
|
-
return null;
|
|
23366
|
+
return parsed.find((p) => p.params.tag === tag) ?? null;
|
|
21972
23367
|
};
|
|
21973
23368
|
var parseSignatureValue = (header, label) => {
|
|
21974
23369
|
const members = splitDictionary(header);
|
|
@@ -22082,7 +23477,7 @@ var verifyMessageSignature = async (input) => {
|
|
|
22082
23477
|
if (!selected) {
|
|
22083
23478
|
return { ok: false, reason: "no_aip_signature" };
|
|
22084
23479
|
}
|
|
22085
|
-
const { label, params } = selected;
|
|
23480
|
+
const { label, params, rawParams } = selected;
|
|
22086
23481
|
if (params.alg !== void 0 && !["ed25519", "eddsa"].includes(params.alg.toLowerCase())) {
|
|
22087
23482
|
return { ok: false, reason: "unsupported_alg" };
|
|
22088
23483
|
}
|
|
@@ -22091,12 +23486,21 @@ var verifyMessageSignature = async (input) => {
|
|
|
22091
23486
|
return { ok: false, reason: "missing_covered_component" };
|
|
22092
23487
|
}
|
|
22093
23488
|
}
|
|
23489
|
+
if (params.created === void 0) {
|
|
23490
|
+
return { ok: false, reason: "created_missing" };
|
|
23491
|
+
}
|
|
23492
|
+
if (params.expires === void 0) {
|
|
23493
|
+
return { ok: false, reason: "expires_missing" };
|
|
23494
|
+
}
|
|
23495
|
+
if (params.expires < params.created || params.expires - params.created > MAX_POP_WINDOW_SECONDS) {
|
|
23496
|
+
return { ok: false, reason: "pop_window_too_long" };
|
|
23497
|
+
}
|
|
22094
23498
|
const now = input.now ?? Math.floor(Date.now() / 1e3);
|
|
22095
23499
|
const skew = input.maxSkewSeconds ?? DEFAULT_MAX_SKEW_SECONDS;
|
|
22096
|
-
if (params.created
|
|
23500
|
+
if (params.created > now + skew) {
|
|
22097
23501
|
return { ok: false, reason: "created_in_future" };
|
|
22098
23502
|
}
|
|
22099
|
-
if (params.expires
|
|
23503
|
+
if (params.expires < now - skew) {
|
|
22100
23504
|
return { ok: false, reason: "expired" };
|
|
22101
23505
|
}
|
|
22102
23506
|
if (!params.keyid) {
|
|
@@ -22119,15 +23523,15 @@ var verifyMessageSignature = async (input) => {
|
|
|
22119
23523
|
if (!sig) {
|
|
22120
23524
|
return { ok: false, reason: "malformed_signature" };
|
|
22121
23525
|
}
|
|
22122
|
-
let
|
|
23526
|
+
let base3;
|
|
22123
23527
|
try {
|
|
22124
|
-
|
|
23528
|
+
base3 = buildSignatureBase(params, {
|
|
22125
23529
|
method: input.method,
|
|
22126
23530
|
authority: input.authority,
|
|
22127
23531
|
path: input.path,
|
|
22128
23532
|
agentIdentity: input.agentIdentity,
|
|
22129
23533
|
extra: input.extraComponents
|
|
22130
|
-
});
|
|
23534
|
+
}, rawParams);
|
|
22131
23535
|
} catch (err) {
|
|
22132
23536
|
if (err instanceof MissingComponentError) {
|
|
22133
23537
|
return { ok: false, reason: "missing_covered_component" };
|
|
@@ -22144,7 +23548,7 @@ var verifyMessageSignature = async (input) => {
|
|
|
22144
23548
|
{ name: "Ed25519" },
|
|
22145
23549
|
key,
|
|
22146
23550
|
sig,
|
|
22147
|
-
new TextEncoder().encode(
|
|
23551
|
+
new TextEncoder().encode(base3)
|
|
22148
23552
|
);
|
|
22149
23553
|
} catch {
|
|
22150
23554
|
return { ok: false, reason: "signature_invalid" };
|
|
@@ -22163,7 +23567,7 @@ var signMessage = async (input) => {
|
|
|
22163
23567
|
keyid,
|
|
22164
23568
|
tag: AIP_SIGNATURE_TAG
|
|
22165
23569
|
};
|
|
22166
|
-
const
|
|
23570
|
+
const base3 = buildSignatureBase(params, {
|
|
22167
23571
|
method: input.method,
|
|
22168
23572
|
authority: input.authority,
|
|
22169
23573
|
path: input.path,
|
|
@@ -22177,7 +23581,7 @@ var signMessage = async (input) => {
|
|
|
22177
23581
|
const sigBytes = await subtle.sign(
|
|
22178
23582
|
"Ed25519",
|
|
22179
23583
|
key,
|
|
22180
|
-
new TextEncoder().encode(
|
|
23584
|
+
new TextEncoder().encode(base3)
|
|
22181
23585
|
);
|
|
22182
23586
|
const b64 = bytesToB64(new Uint8Array(sigBytes));
|
|
22183
23587
|
const signatureInput = `${label}=${serializeComponentList(components)}${serializeParams(params)}`;
|
|
@@ -22233,6 +23637,8 @@ var verifyAit = async (ctx, opts) => {
|
|
|
22233
23637
|
if (!ctx.signatureInput || !ctx.signature) {
|
|
22234
23638
|
return { ok: false, reason: "pop_signature_missing" };
|
|
22235
23639
|
}
|
|
23640
|
+
const signatureInput = ctx.signatureInput;
|
|
23641
|
+
const signature2 = ctx.signature;
|
|
22236
23642
|
let lastFailure = "malformed_token";
|
|
22237
23643
|
for (const raw of ctx.agentIdentityHeaders) {
|
|
22238
23644
|
const token = stripBearer(raw);
|
|
@@ -22271,7 +23677,7 @@ var verifyAit = async (ctx, opts) => {
|
|
|
22271
23677
|
// Pin the signature algorithm allowlist (RFC 8725 §3.1) — also rejects `alg:none`. Without
|
|
22272
23678
|
// this, jose accepts whatever alg the resolved JWK supports, so a trusted IdP publishing a
|
|
22273
23679
|
// non-Ed25519 (e.g. RSA/EC) `use:sig` key would let an attacker present an RS256/ES256
|
|
22274
|
-
// token that verifies. Matches the server-side allowlist in
|
|
23680
|
+
// token that verifies. Matches the server-side allowlist in the AgentScore API verifier.
|
|
22275
23681
|
algorithms: AIT_SIGNING_ALGS,
|
|
22276
23682
|
clockTolerance: jwtClockTolerance,
|
|
22277
23683
|
currentDate: opts.now !== void 0 ? new Date(opts.now * 1e3) : void 0
|
|
@@ -22285,13 +23691,20 @@ var verifyAit = async (ctx, opts) => {
|
|
|
22285
23691
|
lastFailure = "expired_token";
|
|
22286
23692
|
continue;
|
|
22287
23693
|
}
|
|
23694
|
+
if (claims.exp - claims.iat > (opts.maxLifetimeSeconds ?? 300)) {
|
|
23695
|
+
lastFailure = "expired_token";
|
|
23696
|
+
continue;
|
|
23697
|
+
}
|
|
22288
23698
|
const popResult = await verifyMessageSignature({
|
|
22289
23699
|
method: ctx.method,
|
|
22290
23700
|
authority: ctx.authority,
|
|
22291
23701
|
path: ctx.path,
|
|
22292
|
-
|
|
22293
|
-
|
|
22294
|
-
|
|
23702
|
+
// The agent-identity covered component is the BARE AIT (a Bearer prefix, if present, is
|
|
23703
|
+
// transport that `stripBearer` removed above). Verify over `token`, not `raw`, so the edge and
|
|
23704
|
+
// the API — which verifies over the forwarded bare aip_token — reconstruct the identical base.
|
|
23705
|
+
agentIdentity: token,
|
|
23706
|
+
signatureInput,
|
|
23707
|
+
signature: signature2,
|
|
22295
23708
|
cnfJwk: claims.cnf.jwk,
|
|
22296
23709
|
now: opts.now,
|
|
22297
23710
|
maxSkewSeconds: opts.maxSkewSeconds
|
|
@@ -22300,7 +23713,22 @@ var verifyAit = async (ctx, opts) => {
|
|
|
22300
23713
|
lastFailure = "pop_signature_invalid";
|
|
22301
23714
|
continue;
|
|
22302
23715
|
}
|
|
22303
|
-
return {
|
|
23716
|
+
return {
|
|
23717
|
+
ok: true,
|
|
23718
|
+
ait: {
|
|
23719
|
+
payload: claims,
|
|
23720
|
+
iss: claims.iss,
|
|
23721
|
+
cnfJwk: claims.cnf.jwk,
|
|
23722
|
+
token,
|
|
23723
|
+
signatureMaterial: {
|
|
23724
|
+
method: ctx.method,
|
|
23725
|
+
authority: ctx.authority,
|
|
23726
|
+
path: ctx.path,
|
|
23727
|
+
signature_input: signatureInput,
|
|
23728
|
+
signature: signature2
|
|
23729
|
+
}
|
|
23730
|
+
}
|
|
23731
|
+
};
|
|
22304
23732
|
}
|
|
22305
23733
|
return { ok: false, reason: lastFailure };
|
|
22306
23734
|
};
|
|
@@ -22321,11 +23749,11 @@ var readAgentIdentityHeaders = (headers) => {
|
|
|
22321
23749
|
return raw.split(",").map((s) => s.trim()).filter((s) => s.length > 0);
|
|
22322
23750
|
};
|
|
22323
23751
|
var deriveAuthority = (req, url2) => req.headers.get("host") ?? url2.host;
|
|
22324
|
-
var buildVerifyContextFromRequest = (req) => {
|
|
23752
|
+
var buildVerifyContextFromRequest = (req, authority) => {
|
|
22325
23753
|
const url2 = new URL(req.url);
|
|
22326
23754
|
return {
|
|
22327
23755
|
method: req.method,
|
|
22328
|
-
authority: deriveAuthority(req, url2),
|
|
23756
|
+
authority: authority ?? deriveAuthority(req, url2),
|
|
22329
23757
|
path: url2.pathname,
|
|
22330
23758
|
agentIdentityHeaders: readAgentIdentityHeaders(req.headers),
|
|
22331
23759
|
signatureInput: req.headers.get("signature-input"),
|
|
@@ -22350,7 +23778,12 @@ var buildVerifyContextFromParts = (parts) => {
|
|
|
22350
23778
|
const host = parts.authority ?? readNodeHeader(parts.headers, "host") ?? "";
|
|
22351
23779
|
let path;
|
|
22352
23780
|
try {
|
|
22353
|
-
|
|
23781
|
+
if (/^[a-z][a-z0-9+.-]*:\/\//i.test(parts.url)) {
|
|
23782
|
+
path = new URL(parts.url).pathname;
|
|
23783
|
+
} else {
|
|
23784
|
+
const target = parts.url.startsWith("/") ? parts.url : `/${parts.url}`;
|
|
23785
|
+
path = new URL(`http://${host || "localhost"}${target}`).pathname;
|
|
23786
|
+
}
|
|
22354
23787
|
} catch {
|
|
22355
23788
|
const q = parts.url.indexOf("?");
|
|
22356
23789
|
path = q === -1 ? parts.url : parts.url.slice(0, q);
|
|
@@ -22370,8 +23803,12 @@ var verifyFromContext = async (ctx, opts) => {
|
|
|
22370
23803
|
const result = await verifyAit(ctx, { jwks: opts.jwks, now: opts.now, maxSkewSeconds: opts.maxSkewSeconds });
|
|
22371
23804
|
return result.ok ? { ok: true, ait: result.ait } : { ok: false, failure: result.reason };
|
|
22372
23805
|
};
|
|
22373
|
-
var
|
|
22374
|
-
|
|
23806
|
+
var partsWithAuthority = (parts, opts) => {
|
|
23807
|
+
const authority = parts.authority ?? opts.authority;
|
|
23808
|
+
return authority !== void 0 ? { ...parts, authority } : parts;
|
|
23809
|
+
};
|
|
23810
|
+
var verifyAitRequest = (req, opts) => verifyFromContext(buildVerifyContextFromRequest(req, opts.authority), opts);
|
|
23811
|
+
var verifyAitParts = (parts, opts) => verifyFromContext(buildVerifyContextFromParts(partsWithAuthority(parts, opts)), opts);
|
|
22375
23812
|
var aipErrorCode = (failure) => {
|
|
22376
23813
|
switch (failure) {
|
|
22377
23814
|
case "no_token":
|
|
@@ -22428,21 +23865,116 @@ var aipErrorDetail = (failure) => {
|
|
|
22428
23865
|
return "Token verification failed.";
|
|
22429
23866
|
}
|
|
22430
23867
|
};
|
|
22431
|
-
var buildAipErrorBody = (failure) => {
|
|
23868
|
+
var buildAipErrorBody = (failure, requirements) => {
|
|
22432
23869
|
const code = aipErrorCode(failure);
|
|
22433
|
-
|
|
23870
|
+
const body = {
|
|
22434
23871
|
type: `urn:aip:error:${code}`,
|
|
22435
23872
|
title: code.replace(/_/g, " "),
|
|
22436
23873
|
status: aipErrorStatus(failure),
|
|
22437
23874
|
detail: aipErrorDetail(failure)
|
|
22438
23875
|
};
|
|
23876
|
+
if (requirements) {
|
|
23877
|
+
if (code === "untrusted_issuer" && requirements.trustedIssuers?.length) {
|
|
23878
|
+
body.trusted_issuers = requirements.trustedIssuers;
|
|
23879
|
+
}
|
|
23880
|
+
if (code === "insufficient_claims") {
|
|
23881
|
+
if (requirements.requiredClaims?.length) body.required_claims = requirements.requiredClaims;
|
|
23882
|
+
if (requirements.requiredTrustLevel !== void 0) body.required_trust_level = requirements.requiredTrustLevel;
|
|
23883
|
+
if (requirements.requiredAmr?.length) body.required_amr = requirements.requiredAmr;
|
|
23884
|
+
}
|
|
23885
|
+
}
|
|
23886
|
+
return body;
|
|
23887
|
+
};
|
|
23888
|
+
var aipPolicyDenyCode = (code) => {
|
|
23889
|
+
switch (code) {
|
|
23890
|
+
case "token_expired":
|
|
23891
|
+
return { code: "expired_token", status: 401 };
|
|
23892
|
+
case "invalid_credential":
|
|
23893
|
+
return { code: "invalid_signature", status: 401 };
|
|
23894
|
+
case "api_error":
|
|
23895
|
+
return { code: "idp_unavailable", status: 503 };
|
|
23896
|
+
default:
|
|
23897
|
+
return { code: "insufficient_claims", status: 403 };
|
|
23898
|
+
}
|
|
23899
|
+
};
|
|
23900
|
+
var buildAipPolicyDenyBody = (code, reasons, body, requirements) => {
|
|
23901
|
+
const spec = aipPolicyDenyCode(code);
|
|
23902
|
+
const reasonList = reasons ?? [];
|
|
23903
|
+
const detail = spec.code === "insufficient_claims" ? reasonList.length > 0 ? `The Agent Identity Token did not attest a passing value for the required compliance claim(s). AgentScore decision: ${code} (${reasonList.join(", ")}).` : `The Agent Identity Token did not satisfy the merchant's compliance policy. AgentScore decision: ${code}.` : `AgentScore decision: ${code}.`;
|
|
23904
|
+
const superset = {
|
|
23905
|
+
type: `urn:aip:error:${spec.code}`,
|
|
23906
|
+
title: spec.code.replace(/_/g, " "),
|
|
23907
|
+
status: spec.status,
|
|
23908
|
+
detail
|
|
23909
|
+
};
|
|
23910
|
+
if (requirements && spec.code === "insufficient_claims") {
|
|
23911
|
+
if (requirements.requiredClaims?.length) superset.required_claims = requirements.requiredClaims;
|
|
23912
|
+
if (requirements.requiredTrustLevel !== void 0) superset.required_trust_level = requirements.requiredTrustLevel;
|
|
23913
|
+
if (requirements.requiredAmr?.length) superset.required_amr = requirements.requiredAmr;
|
|
23914
|
+
}
|
|
23915
|
+
const { type: _type, title: _title, status: _status, detail: _detail, ...rest } = body;
|
|
23916
|
+
return { ...superset, ...rest };
|
|
23917
|
+
};
|
|
23918
|
+
var TRUST_RANK = { autonomous: 0, human_present: 1, human_confirmed: 2 };
|
|
23919
|
+
var checkTrustRequirements = (payload, requiredTrustLevel, requiredAmr) => {
|
|
23920
|
+
if (requiredTrustLevel !== void 0) {
|
|
23921
|
+
const have = TRUST_RANK[payload.trust_level ?? "autonomous"] ?? 0;
|
|
23922
|
+
const need = TRUST_RANK[requiredTrustLevel] ?? 0;
|
|
23923
|
+
if (have < need) {
|
|
23924
|
+
return `This endpoint requires trust_level '${requiredTrustLevel}'; the token asserts '${payload.trust_level ?? "autonomous"}'. Re-mint an AIT at the required trust level (human confirmation).`;
|
|
23925
|
+
}
|
|
23926
|
+
}
|
|
23927
|
+
if (requiredAmr !== void 0 && requiredAmr.length > 0) {
|
|
23928
|
+
const amr = Array.isArray(payload.auth?.amr) ? payload.auth.amr : [];
|
|
23929
|
+
if (!amr.some((m) => requiredAmr.includes(m))) {
|
|
23930
|
+
return `This endpoint requires an authentication method in [${requiredAmr.join(", ")}]; the token carries [${amr.join(", ") || "none"}].`;
|
|
23931
|
+
}
|
|
23932
|
+
}
|
|
23933
|
+
return null;
|
|
23934
|
+
};
|
|
23935
|
+
var buildAipWeakAuthBody = (opts) => ({
|
|
23936
|
+
type: "urn:aip:error:weak_auth",
|
|
23937
|
+
title: "weak auth",
|
|
23938
|
+
status: 403,
|
|
23939
|
+
detail: opts.detail,
|
|
23940
|
+
...opts.requiredTrustLevel !== void 0 && { required_trust_level: opts.requiredTrustLevel },
|
|
23941
|
+
...opts.requiredAmr !== void 0 && opts.requiredAmr.length > 0 && { required_amr: opts.requiredAmr },
|
|
23942
|
+
...opts.trustedIssuers !== void 0 && opts.trustedIssuers.length > 0 && { trusted_issuers: opts.trustedIssuers }
|
|
23943
|
+
});
|
|
23944
|
+
var requirementsFromOptions = (opts) => ({
|
|
23945
|
+
...opts.trustedIssuers !== void 0 && { trustedIssuers: opts.trustedIssuers },
|
|
23946
|
+
...opts.requiredClaims !== void 0 && { requiredClaims: opts.requiredClaims },
|
|
23947
|
+
...opts.requireTrustLevel !== void 0 && { requiredTrustLevel: opts.requireTrustLevel },
|
|
23948
|
+
...opts.requireAmr !== void 0 && { requiredAmr: opts.requireAmr }
|
|
23949
|
+
});
|
|
23950
|
+
var evaluateFromContext = async (ctx, opts) => {
|
|
23951
|
+
const result = await verifyAit(ctx, { jwks: opts.jwks, now: opts.now, maxSkewSeconds: opts.maxSkewSeconds });
|
|
23952
|
+
if (!result.ok) {
|
|
23953
|
+
return { ok: false, body: buildAipErrorBody(result.reason, requirementsFromOptions(opts)) };
|
|
23954
|
+
}
|
|
23955
|
+
const weak = checkTrustRequirements(result.ait.payload, opts.requireTrustLevel, opts.requireAmr);
|
|
23956
|
+
if (weak !== null) {
|
|
23957
|
+
return {
|
|
23958
|
+
ok: false,
|
|
23959
|
+
body: buildAipWeakAuthBody({
|
|
23960
|
+
detail: weak,
|
|
23961
|
+
...opts.requireTrustLevel !== void 0 && { requiredTrustLevel: opts.requireTrustLevel },
|
|
23962
|
+
...opts.requireAmr !== void 0 && { requiredAmr: opts.requireAmr },
|
|
23963
|
+
...opts.trustedIssuers !== void 0 && { trustedIssuers: opts.trustedIssuers }
|
|
23964
|
+
})
|
|
23965
|
+
};
|
|
23966
|
+
}
|
|
23967
|
+
return { ok: true, ait: result.ait };
|
|
22439
23968
|
};
|
|
23969
|
+
var evaluateAipRequest = (req, opts) => evaluateFromContext(buildVerifyContextFromRequest(req, opts.authority), opts);
|
|
23970
|
+
var evaluateAipParts = (parts, opts) => evaluateFromContext(buildVerifyContextFromParts(partsWithAuthority(parts, opts)), opts);
|
|
22440
23971
|
|
|
22441
23972
|
// src/aip/jwks.ts
|
|
22442
23973
|
var JWKS_WELL_KNOWN_PATH = "/.well-known/agent-identity/jwks.json";
|
|
22443
23974
|
var HARD_MAX_CACHE_SECONDS = 86400;
|
|
22444
23975
|
var DEFAULT_CACHE_SECONDS = 300;
|
|
22445
|
-
var
|
|
23976
|
+
var REFETCH_COOLDOWN_MS = 3e4;
|
|
23977
|
+
var AGENTSCORE_CANONICAL_ISSUER = "https://www.agentscore.com";
|
|
22446
23978
|
var canonicalizeIssuer = (iss) => {
|
|
22447
23979
|
let url2;
|
|
22448
23980
|
try {
|
|
@@ -22481,6 +24013,12 @@ var JwksCache = class {
|
|
|
22481
24013
|
now;
|
|
22482
24014
|
userAgent;
|
|
22483
24015
|
cache = /* @__PURE__ */ new Map();
|
|
24016
|
+
/** Per-issuer in-flight refresh promise — coalesces concurrent refreshes to ONE upstream fetch.
|
|
24017
|
+
* Without it, a concurrent burst of distinct-kid lookups on a cold/expired cache each call
|
|
24018
|
+
* `refresh()` before any has populated the cache → N parallel JWKS GETs (refetch amplification).
|
|
24019
|
+
* The cooldown only suppresses SEQUENTIAL refetches; single-flight suppresses CONCURRENT ones.
|
|
24020
|
+
* Entry is cleared in a `finally` once the fetch settles. */
|
|
24021
|
+
inflight = /* @__PURE__ */ new Map();
|
|
22484
24022
|
constructor(opts) {
|
|
22485
24023
|
this.trusted = new Set(
|
|
22486
24024
|
[AGENTSCORE_CANONICAL_ISSUER, ...opts.trustedIssuers ?? []].map(canonicalizeIssuer).filter((s) => s !== null)
|
|
@@ -22512,13 +24050,21 @@ var JwksCache = class {
|
|
|
22512
24050
|
if (hit2) {
|
|
22513
24051
|
return { ok: true, key: hit2 };
|
|
22514
24052
|
}
|
|
24053
|
+
if (this.now() < cached2.cooldownUntil) {
|
|
24054
|
+
return { ok: false, reason: "key_not_found" };
|
|
24055
|
+
}
|
|
24056
|
+
} else if (cached2 && this.now() < cached2.cooldownUntil) {
|
|
24057
|
+
return { ok: false, reason: cached2.lastFailure ?? "key_not_found" };
|
|
22515
24058
|
}
|
|
22516
24059
|
const refreshed = await this.refresh(canon);
|
|
22517
24060
|
if (!refreshed.ok) {
|
|
22518
24061
|
return refreshed;
|
|
22519
24062
|
}
|
|
22520
24063
|
const hit = this.select(refreshed.keys, kid);
|
|
22521
|
-
|
|
24064
|
+
if (hit) {
|
|
24065
|
+
return { ok: true, key: hit };
|
|
24066
|
+
}
|
|
24067
|
+
return { ok: false, reason: "key_not_found" };
|
|
22522
24068
|
}
|
|
22523
24069
|
select(keys, kid) {
|
|
22524
24070
|
const candidates = signingKeys(keys);
|
|
@@ -22531,31 +24077,68 @@ var JwksCache = class {
|
|
|
22531
24077
|
}
|
|
22532
24078
|
return candidates.length === 1 ? candidates[0] : void 0;
|
|
22533
24079
|
}
|
|
24080
|
+
/**
|
|
24081
|
+
* Refresh the cached key set for `canonIssuer`, coalescing concurrent callers onto a single
|
|
24082
|
+
* upstream fetch (single-flight). The first caller for an issuer with no in-flight refresh kicks
|
|
24083
|
+
* off the fetch and registers the promise; concurrent callers await that same promise instead of
|
|
24084
|
+
* issuing their own GET. The entry is cleared once the fetch settles so the NEXT cold/expired
|
|
24085
|
+
* lookup can refresh again.
|
|
24086
|
+
*/
|
|
22534
24087
|
async refresh(canonIssuer) {
|
|
24088
|
+
const existing = this.inflight.get(canonIssuer);
|
|
24089
|
+
if (existing !== void 0) {
|
|
24090
|
+
return existing;
|
|
24091
|
+
}
|
|
24092
|
+
const promise2 = this.fetchAndCache(canonIssuer).finally(() => {
|
|
24093
|
+
this.inflight.delete(canonIssuer);
|
|
24094
|
+
});
|
|
24095
|
+
this.inflight.set(canonIssuer, promise2);
|
|
24096
|
+
return promise2;
|
|
24097
|
+
}
|
|
24098
|
+
async fetchAndCache(canonIssuer) {
|
|
22535
24099
|
const url2 = `${canonIssuer}${JWKS_WELL_KNOWN_PATH}`;
|
|
22536
24100
|
let res;
|
|
22537
24101
|
try {
|
|
22538
24102
|
res = await this.fetchImpl(url2, { headers: { "User-Agent": this.userAgent, Accept: "application/jwk-set+json, application/json" } });
|
|
22539
24103
|
} catch {
|
|
22540
|
-
return
|
|
24104
|
+
return this.stampFailure(canonIssuer, "fetch_failed");
|
|
22541
24105
|
}
|
|
22542
24106
|
if (!res.ok) {
|
|
22543
|
-
return
|
|
24107
|
+
return this.stampFailure(canonIssuer, "fetch_failed");
|
|
22544
24108
|
}
|
|
22545
24109
|
let body;
|
|
22546
24110
|
try {
|
|
22547
24111
|
body = await res.json();
|
|
22548
24112
|
} catch {
|
|
22549
|
-
return
|
|
24113
|
+
return this.stampFailure(canonIssuer, "malformed_jwks");
|
|
22550
24114
|
}
|
|
22551
24115
|
if (typeof body !== "object" || body === null || !Array.isArray(body.keys)) {
|
|
22552
|
-
return
|
|
24116
|
+
return this.stampFailure(canonIssuer, "malformed_jwks");
|
|
22553
24117
|
}
|
|
22554
24118
|
const keys = body.keys;
|
|
22555
24119
|
const ttlSeconds = resolveCacheSeconds(res.headers.get("cache-control"));
|
|
22556
|
-
|
|
24120
|
+
const now = this.now();
|
|
24121
|
+
this.cache.set(canonIssuer, {
|
|
24122
|
+
keys,
|
|
24123
|
+
expiresAt: now + ttlSeconds * 1e3,
|
|
24124
|
+
cooldownUntil: now + REFETCH_COOLDOWN_MS
|
|
24125
|
+
});
|
|
22557
24126
|
return { ok: true, keys };
|
|
22558
24127
|
}
|
|
24128
|
+
/** Stamp the per-issuer refetch cooldown on a FAILED fetch attempt (the negative cache). Any
|
|
24129
|
+
* previously cached keys + expiry are preserved — a failed kid-miss refetch must not nuke a
|
|
24130
|
+
* still-fresh key set; only the cooldown and failure reason are updated. */
|
|
24131
|
+
stampFailure(canonIssuer, reason) {
|
|
24132
|
+
const now = this.now();
|
|
24133
|
+
const prev = this.cache.get(canonIssuer);
|
|
24134
|
+
this.cache.set(canonIssuer, {
|
|
24135
|
+
keys: prev?.keys ?? [],
|
|
24136
|
+
expiresAt: prev?.expiresAt ?? now,
|
|
24137
|
+
cooldownUntil: now + REFETCH_COOLDOWN_MS,
|
|
24138
|
+
lastFailure: reason
|
|
24139
|
+
});
|
|
24140
|
+
return { ok: false, reason };
|
|
24141
|
+
}
|
|
22559
24142
|
};
|
|
22560
24143
|
|
|
22561
24144
|
// src/payment/rail_spec.ts
|
|
@@ -22740,6 +24323,7 @@ function build402Body({
|
|
|
22740
24323
|
if (x402) {
|
|
22741
24324
|
body.x402Version = x402.version ?? 2;
|
|
22742
24325
|
body.accepts = x402.accepts;
|
|
24326
|
+
if (x402.resource !== void 0) body.resource = x402.resource;
|
|
22743
24327
|
if (x402.extensions !== void 0 && Object.keys(x402.extensions).length > 0) {
|
|
22744
24328
|
body.extensions = x402.extensions;
|
|
22745
24329
|
}
|
|
@@ -22915,7 +24499,7 @@ function respond402({
|
|
|
22915
24499
|
const headers = normalizeHeadersToLowercase(mppxChallengeHeaders);
|
|
22916
24500
|
headers["content-type"] = "application/json";
|
|
22917
24501
|
if (x402) {
|
|
22918
|
-
headers["payment-required"] =
|
|
24502
|
+
headers["payment-required"] = paymentRequiredHeader2(x402);
|
|
22919
24503
|
}
|
|
22920
24504
|
return { body, headers, status: 402 };
|
|
22921
24505
|
}
|
|
@@ -22939,6 +24523,29 @@ function buildValidationError({
|
|
|
22939
24523
|
return body;
|
|
22940
24524
|
}
|
|
22941
24525
|
|
|
24526
|
+
// src/discovery/bazaar.ts
|
|
24527
|
+
async function enrichBazaarDiscoveryExtensions(extensions, request) {
|
|
24528
|
+
if (extensions === void 0) return extensions;
|
|
24529
|
+
const bazaar = await dynamicImport("@x402/extensions/bazaar");
|
|
24530
|
+
const ext = bazaar?.bazaarResourceServerExtension;
|
|
24531
|
+
if (!ext?.key || typeof ext.enrichDeclaration !== "function") return extensions;
|
|
24532
|
+
const declaration = extensions[ext.key];
|
|
24533
|
+
if (declaration === void 0) return extensions;
|
|
24534
|
+
const transportContext = {
|
|
24535
|
+
method: request.method,
|
|
24536
|
+
adapter: { getPath: () => request.path },
|
|
24537
|
+
routePattern: request.path
|
|
24538
|
+
};
|
|
24539
|
+
return { ...extensions, [ext.key]: ext.enrichDeclaration(declaration, transportContext) };
|
|
24540
|
+
}
|
|
24541
|
+
async function dynamicImport(moduleName) {
|
|
24542
|
+
try {
|
|
24543
|
+
return await import(moduleName);
|
|
24544
|
+
} catch {
|
|
24545
|
+
return null;
|
|
24546
|
+
}
|
|
24547
|
+
}
|
|
24548
|
+
|
|
22942
24549
|
// src/payment/constants.ts
|
|
22943
24550
|
var STRIPE_MIN_CHARGE_USD = 0.5;
|
|
22944
24551
|
|
|
@@ -22995,7 +24602,7 @@ async function createMppxServer({
|
|
|
22995
24602
|
methods: extraMethods,
|
|
22996
24603
|
secretKey
|
|
22997
24604
|
}) {
|
|
22998
|
-
const mppx = await
|
|
24605
|
+
const mppx = await dynamicImport2("mppx/server");
|
|
22999
24606
|
if (!mppx?.Mppx?.create) {
|
|
23000
24607
|
throw new Error("mppx not installed \u2014 `npm install mppx` to use createMppxServer.");
|
|
23001
24608
|
}
|
|
@@ -23050,7 +24657,7 @@ async function registerTempoSession(mppx, spec) {
|
|
|
23050
24657
|
});
|
|
23051
24658
|
}
|
|
23052
24659
|
async function registerSolana(spec) {
|
|
23053
|
-
const solanaMpp = await
|
|
24660
|
+
const solanaMpp = await dynamicImport2("@solana/mpp/server");
|
|
23054
24661
|
if (!solanaMpp?.charge) {
|
|
23055
24662
|
throw new Error(
|
|
23056
24663
|
"@solana/mpp not installed \u2014 `npm install @solana/mpp @solana/kit` to use the solana rail."
|
|
@@ -23089,7 +24696,7 @@ async function registerStripe(spec) {
|
|
|
23089
24696
|
paymentMethodTypes: spec.paymentMethodTypes
|
|
23090
24697
|
});
|
|
23091
24698
|
}
|
|
23092
|
-
async function
|
|
24699
|
+
async function dynamicImport2(moduleName) {
|
|
23093
24700
|
try {
|
|
23094
24701
|
return await import(moduleName);
|
|
23095
24702
|
} catch {
|
|
@@ -23166,7 +24773,7 @@ function registerX402SchemesV1V2(server, network, scheme) {
|
|
|
23166
24773
|
|
|
23167
24774
|
// src/payment/x402_server.ts
|
|
23168
24775
|
async function createX402Server(opts = {}) {
|
|
23169
|
-
const x402Core = await
|
|
24776
|
+
const x402Core = await dynamicImport3("@x402/core/server") ?? null;
|
|
23170
24777
|
if (!x402Core) {
|
|
23171
24778
|
throw new Error(
|
|
23172
24779
|
"@x402/core not installed \u2014 `npm install @x402/core` to use createX402Server."
|
|
@@ -23175,7 +24782,7 @@ async function createX402Server(opts = {}) {
|
|
|
23175
24782
|
let facilitator;
|
|
23176
24783
|
const facilitatorChoice = opts.facilitator ?? (process.env.CDP_API_KEY_ID && process.env.CDP_API_KEY_SECRET ? "coinbase" : "http");
|
|
23177
24784
|
if (facilitatorChoice === "coinbase") {
|
|
23178
|
-
const cb = await
|
|
24785
|
+
const cb = await dynamicImport3("@coinbase/x402");
|
|
23179
24786
|
if (!cb?.facilitator) {
|
|
23180
24787
|
throw new Error(
|
|
23181
24788
|
'@coinbase/x402 not installed \u2014 `npm install @coinbase/x402` for facilitator: "coinbase".'
|
|
@@ -23196,13 +24803,13 @@ async function createX402Server(opts = {}) {
|
|
|
23196
24803
|
const baseRail = isUpto ? rail.slice(0, -5) : rail;
|
|
23197
24804
|
const network = baseRail === "x402-base-mainnet" ? networks.base.mainnet.caip2 : networks.base.sepolia.caip2;
|
|
23198
24805
|
if (isUpto) {
|
|
23199
|
-
evmUptoModule ??= await
|
|
24806
|
+
evmUptoModule ??= await dynamicImport3("@x402/evm/upto/server");
|
|
23200
24807
|
if (!evmUptoModule?.UptoEvmScheme) {
|
|
23201
24808
|
throw new Error("@x402/evm not installed \u2014 `npm install @x402/evm` for x402 base upto rails.");
|
|
23202
24809
|
}
|
|
23203
24810
|
registerX402SchemesV1V2(server, network, new evmUptoModule.UptoEvmScheme());
|
|
23204
24811
|
} else {
|
|
23205
|
-
evmExactModule ??= await
|
|
24812
|
+
evmExactModule ??= await dynamicImport3("@x402/evm/exact/server");
|
|
23206
24813
|
if (!evmExactModule?.ExactEvmScheme) {
|
|
23207
24814
|
throw new Error("@x402/evm not installed \u2014 `npm install @x402/evm` for x402 base rails.");
|
|
23208
24815
|
}
|
|
@@ -23214,7 +24821,7 @@ async function createX402Server(opts = {}) {
|
|
|
23214
24821
|
registerX402SchemesV1V2(server, network, scheme);
|
|
23215
24822
|
}
|
|
23216
24823
|
if (opts.bazaar) {
|
|
23217
|
-
const bazaar = await
|
|
24824
|
+
const bazaar = await dynamicImport3("@x402/extensions/bazaar");
|
|
23218
24825
|
if (!bazaar?.bazaarResourceServerExtension) {
|
|
23219
24826
|
throw new Error(
|
|
23220
24827
|
"@x402/extensions not installed \u2014 `npm install @x402/extensions` for bazaar discovery."
|
|
@@ -23240,7 +24847,7 @@ async function buildX402AcceptsFor402(server, opts) {
|
|
|
23240
24847
|
);
|
|
23241
24848
|
return Array.isArray(requirements) ? requirements : [];
|
|
23242
24849
|
}
|
|
23243
|
-
async function
|
|
24850
|
+
async function dynamicImport3(moduleName) {
|
|
23244
24851
|
try {
|
|
23245
24852
|
return await import(moduleName);
|
|
23246
24853
|
} catch {
|
|
@@ -23417,12 +25024,12 @@ async function processX402Settle({
|
|
|
23417
25024
|
enrichedExt,
|
|
23418
25025
|
resolvedTransportContext
|
|
23419
25026
|
);
|
|
23420
|
-
const
|
|
25027
|
+
const paymentResponseHeader2 = settleResult ? Buffer.from(JSON.stringify(settleResult)).toString("base64") : void 0;
|
|
23421
25028
|
return {
|
|
23422
25029
|
success: true,
|
|
23423
25030
|
matchedRequirement,
|
|
23424
25031
|
settleResult,
|
|
23425
|
-
paymentResponseHeader,
|
|
25032
|
+
paymentResponseHeader: paymentResponseHeader2,
|
|
23426
25033
|
verifyResult
|
|
23427
25034
|
};
|
|
23428
25035
|
} catch (err) {
|
|
@@ -23664,6 +25271,19 @@ function isStripeRailSpec2(s) {
|
|
|
23664
25271
|
function isTempoSessionRailSpec3(s) {
|
|
23665
25272
|
return "escrowContract" in s && "store" in s;
|
|
23666
25273
|
}
|
|
25274
|
+
function staticRecipient2(r) {
|
|
25275
|
+
return typeof r === "string" && r.length > 0 ? r : null;
|
|
25276
|
+
}
|
|
25277
|
+
function collectStaticX402Recipients(rails2) {
|
|
25278
|
+
const out = /* @__PURE__ */ new Set();
|
|
25279
|
+
for (const spec of Object.values(rails2)) {
|
|
25280
|
+
if (isStripeRailSpec2(spec) || isTempoSessionRailSpec3(spec)) continue;
|
|
25281
|
+
if (!isEvmNetwork(spec)) continue;
|
|
25282
|
+
const recipient = staticRecipient2(spec.recipient);
|
|
25283
|
+
if (recipient !== null) out.add(recipient.toLowerCase());
|
|
25284
|
+
}
|
|
25285
|
+
return out;
|
|
25286
|
+
}
|
|
23667
25287
|
function specRailKey(spec) {
|
|
23668
25288
|
if (isStripeRailSpec2(spec)) return "stripe";
|
|
23669
25289
|
if (isTempoSessionRailSpec3(spec)) return "tempo_mpp";
|
|
@@ -23762,6 +25382,16 @@ function buildAipTrustedIssuers(externalIssuers) {
|
|
|
23762
25382
|
function aipTrustedIssuerSet(cfg) {
|
|
23763
25383
|
return buildAipTrustedIssuers(cfg.trustedIssuers);
|
|
23764
25384
|
}
|
|
25385
|
+
function aipRequiredClaims(policy) {
|
|
25386
|
+
const claims = [];
|
|
25387
|
+
if (policy.requireKyc) claims.push("id_verified");
|
|
25388
|
+
if (policy.requireSanctionsClear) claims.push("sanctions_clear");
|
|
25389
|
+
if (policy.minAge != null) claims.push(`age_over_${policy.minAge}`);
|
|
25390
|
+
if (policy.blockedJurisdictions !== void 0 || policy.allowedJurisdictions !== void 0) {
|
|
25391
|
+
claims.push("jurisdiction");
|
|
25392
|
+
}
|
|
25393
|
+
return claims;
|
|
25394
|
+
}
|
|
23765
25395
|
function resolveIssuerPolicy(issuerPolicies, iss) {
|
|
23766
25396
|
const target = canonicalizeIssuer(iss);
|
|
23767
25397
|
if (target === null) return void 0;
|
|
@@ -23782,9 +25412,14 @@ var Checkout = class {
|
|
|
23782
25412
|
mintReferenceId;
|
|
23783
25413
|
onSettled;
|
|
23784
25414
|
isCachedAddress;
|
|
25415
|
+
/** Lowercased static recipient addresses for the x402-base rail(s). When the merchant
|
|
25416
|
+
* configured a static recipient and supplied no `isCachedAddress`, the gate binds the
|
|
25417
|
+
* agent-supplied `payTo` to this set (anti funds-drain). Empty for pure per-order minting. */
|
|
25418
|
+
x402StaticRecipients;
|
|
23785
25419
|
zeroSettleCarveOut;
|
|
23786
25420
|
gate;
|
|
23787
25421
|
discoveryExtensions;
|
|
25422
|
+
resourceInfo;
|
|
23788
25423
|
discoveryProbe;
|
|
23789
25424
|
_x402ServerGetter;
|
|
23790
25425
|
/** Lazily-built JWKS cache for AIP verification, shared across requests so issuer keys
|
|
@@ -23861,9 +25496,11 @@ var Checkout = class {
|
|
|
23861
25496
|
this.mintReferenceId = opts.mintReferenceId;
|
|
23862
25497
|
this.onSettled = opts.onSettled;
|
|
23863
25498
|
this.isCachedAddress = opts.isCachedAddress;
|
|
25499
|
+
this.x402StaticRecipients = collectStaticX402Recipients(opts.rails);
|
|
23864
25500
|
this.zeroSettleCarveOut = opts.zeroSettleCarveOut ?? false;
|
|
23865
25501
|
this.gate = opts.gate;
|
|
23866
25502
|
this.discoveryExtensions = opts.discoveryExtensions;
|
|
25503
|
+
this.resourceInfo = opts.resourceInfo;
|
|
23867
25504
|
this.discoveryProbe = opts.discoveryProbe;
|
|
23868
25505
|
}
|
|
23869
25506
|
/** Canonical `RailKey` list derived from the configured rails dict. Each
|
|
@@ -24088,6 +25725,7 @@ var Checkout = class {
|
|
|
24088
25725
|
const operatorToken = headers["x-operator-token"];
|
|
24089
25726
|
let aipToken;
|
|
24090
25727
|
let aipIssuer;
|
|
25728
|
+
let aipSignature;
|
|
24091
25729
|
if (gate.aip !== void 0 && hasAgentIdentityHeaderNode(headers)) {
|
|
24092
25730
|
const aipResult = await verifyAitParts(
|
|
24093
25731
|
{
|
|
@@ -24102,7 +25740,11 @@ var Checkout = class {
|
|
|
24102
25740
|
}
|
|
24103
25741
|
);
|
|
24104
25742
|
if (!aipResult.ok) {
|
|
24105
|
-
const body2 = buildAipErrorBody(aipResult.failure
|
|
25743
|
+
const body2 = buildAipErrorBody(aipResult.failure, {
|
|
25744
|
+
trustedIssuers: aipTrustedIssuerSet(gate.aip),
|
|
25745
|
+
...gate.aip.requireTrustLevel !== void 0 && { requiredTrustLevel: gate.aip.requireTrustLevel },
|
|
25746
|
+
...gate.aip.requireAmr !== void 0 && { requiredAmr: gate.aip.requireAmr }
|
|
25747
|
+
});
|
|
24106
25748
|
return {
|
|
24107
25749
|
status: body2.status,
|
|
24108
25750
|
body: body2,
|
|
@@ -24116,6 +25758,17 @@ var Checkout = class {
|
|
|
24116
25758
|
}
|
|
24117
25759
|
aipToken = aipResult.ait.token;
|
|
24118
25760
|
aipIssuer = aipResult.ait.iss;
|
|
25761
|
+
aipSignature = aipResult.ait.signatureMaterial;
|
|
25762
|
+
const weakAuthDetail = checkTrustRequirements(aipResult.ait.payload, gate.aip.requireTrustLevel, gate.aip.requireAmr);
|
|
25763
|
+
if (weakAuthDetail) {
|
|
25764
|
+
const body2 = buildAipWeakAuthBody({
|
|
25765
|
+
detail: weakAuthDetail,
|
|
25766
|
+
...gate.aip.requireTrustLevel !== void 0 && { requiredTrustLevel: gate.aip.requireTrustLevel },
|
|
25767
|
+
...gate.aip.requireAmr !== void 0 && { requiredAmr: gate.aip.requireAmr },
|
|
25768
|
+
trustedIssuers: aipTrustedIssuerSet(gate.aip)
|
|
25769
|
+
});
|
|
25770
|
+
return { status: 403, body: body2, headers: { "content-type": "application/problem+json" } };
|
|
25771
|
+
}
|
|
24119
25772
|
}
|
|
24120
25773
|
const issuerPolicy = aipIssuer !== void 0 && gate.aip?.issuerPolicies !== void 0 ? resolveIssuerPolicy(gate.aip.issuerPolicies, aipIssuer) : void 0;
|
|
24121
25774
|
const effPolicy = issuerPolicy ?? {
|
|
@@ -24146,7 +25799,7 @@ var Checkout = class {
|
|
|
24146
25799
|
let policyOverride;
|
|
24147
25800
|
if (gate.perRequestPolicy !== void 0) {
|
|
24148
25801
|
policyOverride = await gate.perRequestPolicy(ctx);
|
|
24149
|
-
if (policyOverride === null) return
|
|
25802
|
+
if (policyOverride === null) return this.runWalletSanctionsOnly(ctx);
|
|
24150
25803
|
}
|
|
24151
25804
|
const coreOpts = {
|
|
24152
25805
|
apiKey: gate.apiKey,
|
|
@@ -24180,7 +25833,7 @@ var Checkout = class {
|
|
|
24180
25833
|
...policyOverride ?? {}
|
|
24181
25834
|
};
|
|
24182
25835
|
const core = createAgentScoreCore(coreOpts);
|
|
24183
|
-
const identity = aipToken !== void 0 ? { aipToken } : walletAddress !== void 0 || operatorToken !== void 0 ? {
|
|
25836
|
+
const identity = aipToken !== void 0 ? { aipToken, ...aipSignature !== void 0 && { aipSignature } } : walletAddress !== void 0 || operatorToken !== void 0 ? {
|
|
24184
25837
|
...walletAddress !== void 0 && { address: walletAddress },
|
|
24185
25838
|
...operatorToken !== void 0 && { operatorToken }
|
|
24186
25839
|
} : void 0;
|
|
@@ -24200,8 +25853,7 @@ var Checkout = class {
|
|
|
24200
25853
|
};
|
|
24201
25854
|
}
|
|
24202
25855
|
if (aipToken === void 0 && walletAddress !== void 0) {
|
|
24203
|
-
const
|
|
24204
|
-
const sm = verdict?.signer_match;
|
|
25856
|
+
const sm = outcome.signerVerdict?.signer_match;
|
|
24205
25857
|
if (sm && sm.kind !== "pass") {
|
|
24206
25858
|
const reason2 = sm.kind === "wallet_auth_requires_wallet_signing" ? {
|
|
24207
25859
|
code: "wallet_auth_requires_wallet_signing",
|
|
@@ -24232,6 +25884,19 @@ var Checkout = class {
|
|
|
24232
25884
|
if (custom2 !== null) return custom2;
|
|
24233
25885
|
}
|
|
24234
25886
|
const body = denialReasonToBody(reason);
|
|
25887
|
+
if (aipToken !== void 0) {
|
|
25888
|
+
const superset = buildAipPolicyDenyBody(reason.code, reason.reasons, body, {
|
|
25889
|
+
trustedIssuers: gate.aip !== void 0 ? aipTrustedIssuerSet(gate.aip) : void 0,
|
|
25890
|
+
requiredClaims: aipRequiredClaims(effPolicy),
|
|
25891
|
+
...gate.aip?.requireTrustLevel !== void 0 && { requiredTrustLevel: gate.aip.requireTrustLevel },
|
|
25892
|
+
...gate.aip?.requireAmr !== void 0 && { requiredAmr: gate.aip.requireAmr }
|
|
25893
|
+
});
|
|
25894
|
+
return {
|
|
25895
|
+
status: superset.status,
|
|
25896
|
+
body: superset,
|
|
25897
|
+
headers: { "content-type": "application/problem+json" }
|
|
25898
|
+
};
|
|
25899
|
+
}
|
|
24235
25900
|
const status = reason.code === "token_expired" || reason.code === "invalid_credential" ? 401 : reason.code === "api_error" ? 503 : 403;
|
|
24236
25901
|
return { status, body };
|
|
24237
25902
|
}
|
|
@@ -24247,7 +25912,7 @@ var Checkout = class {
|
|
|
24247
25912
|
* - `AGENTSCORE_API_KEY` — required. No key → one-time warning + skip
|
|
24248
25913
|
* (dev/testnet pattern; production should always configure a key).
|
|
24249
25914
|
* - `AGENTSCORE_BASE_URL` — optional override for staging/dev API
|
|
24250
|
-
* (e.g. `https://api
|
|
25915
|
+
* (e.g. `https://api.staging.example` or `http://localhost:3002`).
|
|
24251
25916
|
*
|
|
24252
25917
|
* Stripe SPT (no extractable wallet signer) → skip silently; Stripe runs
|
|
24253
25918
|
* its own OFAC screen on the buyer's Stripe account at customer creation.
|
|
@@ -24260,7 +25925,7 @@ var Checkout = class {
|
|
|
24260
25925
|
* clean buyer is just bad UX).
|
|
24261
25926
|
*/
|
|
24262
25927
|
async runWalletSanctionsOnly(ctx) {
|
|
24263
|
-
const apiKey = process.env.AGENTSCORE_API_KEY;
|
|
25928
|
+
const apiKey = this.gate?.apiKey ?? process.env.AGENTSCORE_API_KEY;
|
|
24264
25929
|
if (!apiKey) {
|
|
24265
25930
|
warnMissingApiKeyOnce("checkout");
|
|
24266
25931
|
return null;
|
|
@@ -24289,8 +25954,7 @@ var Checkout = class {
|
|
|
24289
25954
|
}
|
|
24290
25955
|
async handleZeroSettle(ctx, rail) {
|
|
24291
25956
|
if (!this.zeroSettleCarveOut || ctx.pricing === null) return null;
|
|
24292
|
-
|
|
24293
|
-
if (cents !== 0) return null;
|
|
25957
|
+
if (ctx.pricing.amountUsd !== 0) return null;
|
|
24294
25958
|
const headers = normalizeHeadersToLowercase(ctx.request.headers);
|
|
24295
25959
|
let zero;
|
|
24296
25960
|
if (rail === "x402-base") {
|
|
@@ -24331,9 +25995,16 @@ var Checkout = class {
|
|
|
24331
25995
|
ctx.recipients = { ...await this.mintRecipients(ctx) };
|
|
24332
25996
|
return ctx.recipients;
|
|
24333
25997
|
}
|
|
24334
|
-
async asyncIsCachedAddress(
|
|
24335
|
-
if (this.isCachedAddress
|
|
24336
|
-
|
|
25998
|
+
async asyncIsCachedAddress(address3, ctx) {
|
|
25999
|
+
if (this.isCachedAddress !== void 0) return Promise.resolve(this.isCachedAddress(address3));
|
|
26000
|
+
const minted = ctx?.recipients["x402_base"];
|
|
26001
|
+
if (minted !== void 0 && minted.length > 0) {
|
|
26002
|
+
return address3.toLowerCase() === minted.toLowerCase();
|
|
26003
|
+
}
|
|
26004
|
+
if (this.x402StaticRecipients.size > 0) {
|
|
26005
|
+
return this.x402StaticRecipients.has(address3.toLowerCase());
|
|
26006
|
+
}
|
|
26007
|
+
return true;
|
|
24337
26008
|
}
|
|
24338
26009
|
async handleX402(ctx) {
|
|
24339
26010
|
const x402Server = await this.getX402Server();
|
|
@@ -24346,7 +26017,7 @@ var Checkout = class {
|
|
|
24346
26017
|
});
|
|
24347
26018
|
const verified = await verifyX402Request({
|
|
24348
26019
|
request: fakeRequest,
|
|
24349
|
-
isCachedAddress: this.asyncIsCachedAddress
|
|
26020
|
+
isCachedAddress: (addr) => this.asyncIsCachedAddress(addr, ctx),
|
|
24350
26021
|
acceptedNetwork: this.x402BaseNetwork
|
|
24351
26022
|
});
|
|
24352
26023
|
if (!verified.ok) {
|
|
@@ -24370,7 +26041,7 @@ var Checkout = class {
|
|
|
24370
26041
|
maxTimeoutSeconds: 300
|
|
24371
26042
|
},
|
|
24372
26043
|
resourceMeta: {
|
|
24373
|
-
url: ctx.request
|
|
26044
|
+
url: resolveResourceUrl(ctx.request),
|
|
24374
26045
|
description: "Agent purchase via x402",
|
|
24375
26046
|
mimeType: "application/json"
|
|
24376
26047
|
}
|
|
@@ -24528,13 +26199,29 @@ var Checkout = class {
|
|
|
24528
26199
|
payTo: recipient,
|
|
24529
26200
|
maxTimeoutSeconds: 300
|
|
24530
26201
|
});
|
|
24531
|
-
x402Resource = {
|
|
26202
|
+
x402Resource = {
|
|
26203
|
+
url: resolveResourceUrl(ctx.request),
|
|
26204
|
+
mimeType: "application/json",
|
|
26205
|
+
...this.resourceInfo?.description !== void 0 && { description: this.resourceInfo.description },
|
|
26206
|
+
...this.resourceInfo?.serviceName !== void 0 && { serviceName: this.resourceInfo.serviceName },
|
|
26207
|
+
...this.resourceInfo?.tags !== void 0 && { tags: this.resourceInfo.tags },
|
|
26208
|
+
...this.resourceInfo?.iconUrl !== void 0 && { iconUrl: this.resourceInfo.iconUrl }
|
|
26209
|
+
};
|
|
24532
26210
|
} catch {
|
|
24533
26211
|
x402Accepts = [];
|
|
24534
26212
|
}
|
|
24535
26213
|
}
|
|
24536
26214
|
}
|
|
24537
26215
|
const identityMetadata = resolveIdentityMetadata(ctx);
|
|
26216
|
+
let requestPath = ctx.request.url;
|
|
26217
|
+
try {
|
|
26218
|
+
requestPath = new URL(resolveResourceUrl(ctx.request)).pathname;
|
|
26219
|
+
} catch {
|
|
26220
|
+
}
|
|
26221
|
+
const enrichedExtensions = await enrichBazaarDiscoveryExtensions(this.discoveryExtensions, {
|
|
26222
|
+
method: ctx.request.method,
|
|
26223
|
+
path: requestPath
|
|
26224
|
+
});
|
|
24538
26225
|
const body = build402Body({
|
|
24539
26226
|
acceptedMethods: accepted,
|
|
24540
26227
|
agentInstructions: buildAgentInstructions({ howToPay }),
|
|
@@ -24556,7 +26243,8 @@ var Checkout = class {
|
|
|
24556
26243
|
...x402Accepts.length > 0 ? {
|
|
24557
26244
|
x402: {
|
|
24558
26245
|
accepts: x402Accepts,
|
|
24559
|
-
...
|
|
26246
|
+
...x402Resource ? { resource: x402Resource } : {},
|
|
26247
|
+
...enrichedExtensions !== void 0 && Object.keys(enrichedExtensions).length > 0 ? { extensions: enrichedExtensions } : {}
|
|
24560
26248
|
}
|
|
24561
26249
|
} : {}
|
|
24562
26250
|
});
|
|
@@ -24565,7 +26253,8 @@ var Checkout = class {
|
|
|
24565
26253
|
x402Block = {
|
|
24566
26254
|
x402Version: 2,
|
|
24567
26255
|
accepts: x402Accepts,
|
|
24568
|
-
...x402Resource ? { resource: x402Resource } : {}
|
|
26256
|
+
...x402Resource ? { resource: x402Resource } : {},
|
|
26257
|
+
...enrichedExtensions !== void 0 && Object.keys(enrichedExtensions).length > 0 ? { extensions: enrichedExtensions } : {}
|
|
24569
26258
|
};
|
|
24570
26259
|
}
|
|
24571
26260
|
const respond = respond402({
|
|
@@ -24643,11 +26332,18 @@ function validationResponseNextjs(input) {
|
|
|
24643
26332
|
function validationResponseWeb(input) {
|
|
24644
26333
|
return validationResponseHono(input);
|
|
24645
26334
|
}
|
|
24646
|
-
function
|
|
24647
|
-
|
|
24648
|
-
|
|
24649
|
-
|
|
24650
|
-
|
|
26335
|
+
function resolveResourceUrl(request) {
|
|
26336
|
+
const fwd = request.headers["x-forwarded-proto"] ?? request.headers["X-Forwarded-Proto"];
|
|
26337
|
+
const proto = typeof fwd === "string" ? fwd.split(",")[0]?.trim() : void 0;
|
|
26338
|
+
if (proto) {
|
|
26339
|
+
try {
|
|
26340
|
+
const u = new URL(request.url);
|
|
26341
|
+
u.protocol = `${proto}:`;
|
|
26342
|
+
return u.toString();
|
|
26343
|
+
} catch {
|
|
26344
|
+
}
|
|
26345
|
+
}
|
|
26346
|
+
return request.url;
|
|
24651
26347
|
}
|
|
24652
26348
|
function stripContentType(headers) {
|
|
24653
26349
|
const out = {};
|
|
@@ -24656,6 +26352,12 @@ function stripContentType(headers) {
|
|
|
24656
26352
|
}
|
|
24657
26353
|
return out;
|
|
24658
26354
|
}
|
|
26355
|
+
function explicitContentType(headers) {
|
|
26356
|
+
for (const [k, v] of Object.entries(headers)) {
|
|
26357
|
+
if (k.toLowerCase() === "content-type") return v;
|
|
26358
|
+
}
|
|
26359
|
+
return void 0;
|
|
26360
|
+
}
|
|
24659
26361
|
function headersToRecord(h) {
|
|
24660
26362
|
if (h === void 0) return {};
|
|
24661
26363
|
if (h instanceof Headers) {
|
|
@@ -24675,10 +26377,7 @@ Checkout.prototype.handleHono = async function(c, body) {
|
|
|
24675
26377
|
try {
|
|
24676
26378
|
parsedBody = await c.req.json();
|
|
24677
26379
|
} catch {
|
|
24678
|
-
|
|
24679
|
-
status: 400,
|
|
24680
|
-
headers: { "Content-Type": "application/json" }
|
|
24681
|
-
});
|
|
26380
|
+
parsedBody = {};
|
|
24682
26381
|
}
|
|
24683
26382
|
}
|
|
24684
26383
|
const rawHeaders = c.req.header();
|
|
@@ -24693,16 +26392,11 @@ Checkout.prototype.handleHono = async function(c, body) {
|
|
|
24693
26392
|
});
|
|
24694
26393
|
return new Response(JSON.stringify(result.body), {
|
|
24695
26394
|
status: result.status,
|
|
24696
|
-
headers: { "Content-Type": "application/json", ...stripContentType(result.headers) }
|
|
26395
|
+
headers: { "Content-Type": explicitContentType(result.headers) ?? "application/json", ...stripContentType(result.headers) }
|
|
24697
26396
|
});
|
|
24698
26397
|
};
|
|
24699
26398
|
Checkout.prototype.handleExpress = async function(req, res, body) {
|
|
24700
|
-
const parsedBody = body ?? (typeof req.body === "object" && req.body !== null ? req.body :
|
|
24701
|
-
if (parsedBody === null) {
|
|
24702
|
-
res.status(400);
|
|
24703
|
-
res.json(invalidBodyEnvelope());
|
|
24704
|
-
return;
|
|
24705
|
-
}
|
|
26399
|
+
const parsedBody = body ?? (typeof req.body === "object" && req.body !== null ? req.body : {});
|
|
24706
26400
|
const headers = {};
|
|
24707
26401
|
for (const [k, v] of Object.entries(req.headers)) {
|
|
24708
26402
|
if (typeof v === "string") headers[k] = v;
|
|
@@ -24718,15 +26412,13 @@ Checkout.prototype.handleExpress = async function(req, res, body) {
|
|
|
24718
26412
|
raw: req
|
|
24719
26413
|
});
|
|
24720
26414
|
for (const [k, v] of Object.entries(stripContentType(result.headers))) res.setHeader(k, v);
|
|
26415
|
+
const ct = explicitContentType(result.headers);
|
|
26416
|
+
if (ct !== void 0) res.setHeader("Content-Type", ct);
|
|
24721
26417
|
res.status(result.status);
|
|
24722
26418
|
res.json(result.body);
|
|
24723
26419
|
};
|
|
24724
26420
|
Checkout.prototype.handleFastify = async function(request, reply, body) {
|
|
24725
|
-
const parsedBody = body ?? (typeof request.body === "object" && request.body !== null ? request.body :
|
|
24726
|
-
if (parsedBody === null) {
|
|
24727
|
-
reply.code(400);
|
|
24728
|
-
return reply.send(invalidBodyEnvelope());
|
|
24729
|
-
}
|
|
26421
|
+
const parsedBody = body ?? (typeof request.body === "object" && request.body !== null ? request.body : {});
|
|
24730
26422
|
const headers = {};
|
|
24731
26423
|
for (const [k, v] of Object.entries(request.headers)) {
|
|
24732
26424
|
if (typeof v === "string") headers[k] = v;
|
|
@@ -24742,6 +26434,11 @@ Checkout.prototype.handleFastify = async function(request, reply, body) {
|
|
|
24742
26434
|
});
|
|
24743
26435
|
for (const [k, v] of Object.entries(stripContentType(result.headers))) reply.header(k, v);
|
|
24744
26436
|
reply.code(result.status);
|
|
26437
|
+
const ct = explicitContentType(result.headers);
|
|
26438
|
+
if (ct !== void 0) {
|
|
26439
|
+
reply.header("content-type", ct);
|
|
26440
|
+
return reply.send(JSON.stringify(result.body));
|
|
26441
|
+
}
|
|
24745
26442
|
return reply.send(result.body);
|
|
24746
26443
|
};
|
|
24747
26444
|
Checkout.prototype.handleNextjs = async function(request, body) {
|
|
@@ -24752,10 +26449,7 @@ Checkout.prototype.handleNextjs = async function(request, body) {
|
|
|
24752
26449
|
try {
|
|
24753
26450
|
parsedBody = await request.json();
|
|
24754
26451
|
} catch {
|
|
24755
|
-
|
|
24756
|
-
status: 400,
|
|
24757
|
-
headers: { "Content-Type": "application/json" }
|
|
24758
|
-
});
|
|
26452
|
+
parsedBody = {};
|
|
24759
26453
|
}
|
|
24760
26454
|
}
|
|
24761
26455
|
const headers = {};
|
|
@@ -24772,7 +26466,7 @@ Checkout.prototype.handleNextjs = async function(request, body) {
|
|
|
24772
26466
|
});
|
|
24773
26467
|
return new Response(JSON.stringify(result.body), {
|
|
24774
26468
|
status: result.status,
|
|
24775
|
-
headers: { "Content-Type": "application/json", ...stripContentType(result.headers) }
|
|
26469
|
+
headers: { "Content-Type": explicitContentType(result.headers) ?? "application/json", ...stripContentType(result.headers) }
|
|
24776
26470
|
});
|
|
24777
26471
|
};
|
|
24778
26472
|
Checkout.prototype.handleWeb = Checkout.prototype.handleNextjs;
|
|
@@ -25245,7 +26939,7 @@ function computeFirstCheckout(opts) {
|
|
|
25245
26939
|
for (const [k, v] of Object.entries(mppChallengeHeaders)) headers.set(k, v);
|
|
25246
26940
|
headers.set(
|
|
25247
26941
|
"PAYMENT-REQUIRED",
|
|
25248
|
-
|
|
26942
|
+
paymentRequiredHeader2({ x402Version: 2, accepts: accepted, resource: { url: opts.url } })
|
|
25249
26943
|
);
|
|
25250
26944
|
return new Response(JSON.stringify(body402), { status: 402, headers });
|
|
25251
26945
|
}
|
|
@@ -25280,9 +26974,10 @@ function computeFirstCheckout(opts) {
|
|
|
25280
26974
|
);
|
|
25281
26975
|
}
|
|
25282
26976
|
async function handleX402Settle(req, referenceId, cachedBody, priceCents, recipients) {
|
|
26977
|
+
const expectedPayTo = recipients.x402_base?.toLowerCase();
|
|
25283
26978
|
const verified = await verifyX402Request({
|
|
25284
26979
|
request: req,
|
|
25285
|
-
isCachedAddress: async () =>
|
|
26980
|
+
isCachedAddress: async (addr) => expectedPayTo === void 0 || addr.toLowerCase() === expectedPayTo,
|
|
25286
26981
|
acceptedNetwork: opts.rails.x402_base?.network ?? "eip155:8453"
|
|
25287
26982
|
});
|
|
25288
26983
|
if (!verified.ok) {
|
|
@@ -25614,6 +27309,7 @@ export {
|
|
|
25614
27309
|
AGENTSCORE_CANONICAL_ISSUER,
|
|
25615
27310
|
AGENTSCORE_UCP_CAPABILITY,
|
|
25616
27311
|
AGENT_IDENTITY_HEADER,
|
|
27312
|
+
AIP_A2A_EXTENSION_URI,
|
|
25617
27313
|
AIP_COVERED_COMPONENTS,
|
|
25618
27314
|
AIP_SIGNATURE_TAG,
|
|
25619
27315
|
Checkout,
|
|
@@ -25622,15 +27318,18 @@ export {
|
|
|
25622
27318
|
HARD_MAX_CACHE_SECONDS,
|
|
25623
27319
|
JWKS_WELL_KNOWN_PATH,
|
|
25624
27320
|
JwksCache,
|
|
27321
|
+
MAX_POP_WINDOW_SECONDS,
|
|
25625
27322
|
UCPSigningKey,
|
|
25626
27323
|
UCPVerificationError,
|
|
25627
27324
|
UCP_A2A_EXTENSION_URI,
|
|
27325
|
+
aipA2AExtension,
|
|
25628
27326
|
aipErrorCode,
|
|
25629
27327
|
aipErrorStatus,
|
|
25630
27328
|
buildA2AAgentCard,
|
|
25631
27329
|
buildAgentMemoryHint,
|
|
25632
27330
|
buildAipErrorBody,
|
|
25633
27331
|
buildAipTrustedIssuers,
|
|
27332
|
+
buildAipWeakAuthBody,
|
|
25634
27333
|
buildContactSupportNextSteps,
|
|
25635
27334
|
buildDefaultCheckoutRails,
|
|
25636
27335
|
buildGateFromPolicy,
|
|
@@ -25641,12 +27340,15 @@ export {
|
|
|
25641
27340
|
buildVerificationRequiredBody,
|
|
25642
27341
|
buildVerifyContextFromRequest,
|
|
25643
27342
|
canonicalizeIssuer,
|
|
27343
|
+
checkTrustRequirements,
|
|
25644
27344
|
computeFirstCheckout,
|
|
25645
27345
|
createDefaultOnDenied,
|
|
25646
27346
|
createQuoteCache,
|
|
25647
27347
|
defaultReadOnlyOnDenied,
|
|
25648
27348
|
denialReasonStatus,
|
|
25649
27349
|
denialReasonToBody,
|
|
27350
|
+
evaluateAipParts,
|
|
27351
|
+
evaluateAipRequest,
|
|
25650
27352
|
extractOwnerScope,
|
|
25651
27353
|
extractPaymentSigner,
|
|
25652
27354
|
extractPaymentSignerFromAuth,
|
|
@@ -25667,6 +27369,7 @@ export {
|
|
|
25667
27369
|
loadUCPSigningKeyFromEnv,
|
|
25668
27370
|
makeMppxComposeHook,
|
|
25669
27371
|
mppPaymentHandler,
|
|
27372
|
+
normalizeAddress,
|
|
25670
27373
|
pricingResult,
|
|
25671
27374
|
readX402PaymentHeader,
|
|
25672
27375
|
runGateWithEnforcement,
|