@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.
Files changed (80) hide show
  1. package/README.md +19 -17
  2. package/dist/challenge/index.d.mts +26 -2
  3. package/dist/challenge/index.d.ts +26 -2
  4. package/dist/challenge/index.js +14 -5
  5. package/dist/challenge/index.js.map +1 -1
  6. package/dist/challenge/index.mjs +14 -5
  7. package/dist/challenge/index.mjs.map +1 -1
  8. package/dist/{checkout-McfNpZJf.d.ts → checkout-C4RD7M0Z.d.ts} +46 -13
  9. package/dist/{checkout-o17dIxHi.d.mts → checkout-CzB9f_jf.d.mts} +46 -13
  10. package/dist/core.d.mts +20 -9
  11. package/dist/core.d.ts +20 -9
  12. package/dist/core.js +35 -24
  13. package/dist/core.js.map +1 -1
  14. package/dist/core.mjs +35 -24
  15. package/dist/core.mjs.map +1 -1
  16. package/dist/discovery/index.d.mts +17 -2
  17. package/dist/discovery/index.d.ts +17 -2
  18. package/dist/discovery/index.js +36 -12
  19. package/dist/discovery/index.js.map +1 -1
  20. package/dist/discovery/index.mjs +35 -12
  21. package/dist/discovery/index.mjs.map +1 -1
  22. package/dist/{gate-CWP10xPQ.d.mts → gate-D2RP6bZg.d.ts} +109 -141
  23. package/dist/{gate-CWP10xPQ.d.ts → gate-GCXy4FHI.d.mts} +109 -141
  24. package/dist/identity/express.d.mts +3 -1
  25. package/dist/identity/express.d.ts +3 -1
  26. package/dist/identity/express.js +164 -55
  27. package/dist/identity/express.js.map +1 -1
  28. package/dist/identity/express.mjs +164 -55
  29. package/dist/identity/express.mjs.map +1 -1
  30. package/dist/identity/fastify.d.mts +3 -1
  31. package/dist/identity/fastify.d.ts +3 -1
  32. package/dist/identity/fastify.js +171 -57
  33. package/dist/identity/fastify.js.map +1 -1
  34. package/dist/identity/fastify.mjs +171 -57
  35. package/dist/identity/fastify.mjs.map +1 -1
  36. package/dist/identity/hono.d.mts +3 -1
  37. package/dist/identity/hono.d.ts +3 -1
  38. package/dist/identity/hono.js +159 -59
  39. package/dist/identity/hono.js.map +1 -1
  40. package/dist/identity/hono.mjs +159 -59
  41. package/dist/identity/hono.mjs.map +1 -1
  42. package/dist/identity/nextjs.d.mts +3 -1
  43. package/dist/identity/nextjs.d.ts +3 -1
  44. package/dist/identity/nextjs.js +153 -56
  45. package/dist/identity/nextjs.js.map +1 -1
  46. package/dist/identity/nextjs.mjs +153 -56
  47. package/dist/identity/nextjs.mjs.map +1 -1
  48. package/dist/identity/policy.d.mts +21 -2
  49. package/dist/identity/policy.d.ts +21 -2
  50. package/dist/identity/policy.js +22 -1
  51. package/dist/identity/policy.js.map +1 -1
  52. package/dist/identity/policy.mjs +21 -1
  53. package/dist/identity/policy.mjs.map +1 -1
  54. package/dist/identity/web.d.mts +3 -1
  55. package/dist/identity/web.d.ts +3 -1
  56. package/dist/identity/web.js +153 -56
  57. package/dist/identity/web.js.map +1 -1
  58. package/dist/identity/web.mjs +153 -56
  59. package/dist/identity/web.mjs.map +1 -1
  60. package/dist/index.d.mts +55 -10
  61. package/dist/index.d.ts +55 -10
  62. package/dist/index.js +2211 -500
  63. package/dist/index.js.map +1 -1
  64. package/dist/index.mjs +2203 -500
  65. package/dist/index.mjs.map +1 -1
  66. package/dist/payment/index.d.mts +1 -1
  67. package/dist/payment/index.d.ts +1 -1
  68. package/dist/payment/index.js +10 -2
  69. package/dist/payment/index.js.map +1 -1
  70. package/dist/payment/index.mjs +10 -2
  71. package/dist/payment/index.mjs.map +1 -1
  72. package/dist/stripe-multichain/index.js +1614 -266
  73. package/dist/stripe-multichain/index.js.map +1 -1
  74. package/dist/stripe-multichain/index.mjs +1614 -266
  75. package/dist/stripe-multichain/index.mjs.map +1 -1
  76. package/dist/types-D1slMt0H.d.mts +137 -0
  77. package/dist/types-D1slMt0H.d.ts +137 -0
  78. package/dist/{wwwauthenticate-CVaGUMjU.d.mts → wwwauthenticate-Dgm-_af9.d.mts} +11 -1
  79. package/dist/{wwwauthenticate-CVaGUMjU.d.ts → wwwauthenticate-Dgm-_af9.d.ts} +11 -1
  80. package/package.json +23 -18
@@ -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
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
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
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
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)
@@ -99,7 +108,7 @@ var init_Errors = __esm({
99
108
  const docsBaseUrl = options.docsOrigin ?? _BaseError.prototype.docsOrigin;
100
109
  const docs = `${docsBaseUrl}${docsPath ?? ""}`;
101
110
  const showVersion = Boolean(options.version ?? _BaseError.prototype.showVersion);
102
- const version3 = options.version ?? _BaseError.prototype.version;
111
+ const version4 = options.version ?? _BaseError.prototype.version;
103
112
  const message = [
104
113
  shortMessage || "An error occurred.",
105
114
  ...options.metaMessages ? ["", ...options.metaMessages] : [],
@@ -107,7 +116,7 @@ var init_Errors = __esm({
107
116
  "",
108
117
  details ? `Details: ${details}` : void 0,
109
118
  docsPath ? `See: ${docs}` : void 0,
110
- showVersion ? `Version: ${version3}` : void 0
119
+ showVersion ? `Version: ${version4}` : void 0
111
120
  ] : []
112
121
  ].filter((x) => typeof x === "string").join("\n");
113
122
  super(message, options.cause ? { cause: options.cause } : void 0);
@@ -172,7 +181,7 @@ var init_Errors = __esm({
172
181
  this.docsPath = docsPath;
173
182
  this.shortMessage = shortMessage;
174
183
  this.showVersion = showVersion;
175
- this.version = version3;
184
+ this.version = version4;
176
185
  }
177
186
  walk(fn) {
178
187
  return walk(this, fn);
@@ -302,16 +311,16 @@ var init_hmac = __esm({
302
311
  this.blockLen = this.iHash.blockLen;
303
312
  this.outputLen = this.iHash.outputLen;
304
313
  const blockLen = this.blockLen;
305
- const pad3 = new Uint8Array(blockLen);
306
- pad3.set(key.length > blockLen ? hash3.create().update(key).digest() : key);
307
- for (let i = 0; i < pad3.length; i++)
308
- pad3[i] ^= 54;
309
- this.iHash.update(pad3);
314
+ const pad4 = new Uint8Array(blockLen);
315
+ pad4.set(key.length > blockLen ? hash3.create().update(key).digest() : key);
316
+ for (let i = 0; i < pad4.length; i++)
317
+ pad4[i] ^= 54;
318
+ this.iHash.update(pad4);
310
319
  this.oHash = hash3.create();
311
- for (let i = 0; i < pad3.length; i++)
312
- pad3[i] ^= 54 ^ 92;
313
- this.oHash.update(pad3);
314
- clean(pad3);
320
+ for (let i = 0; i < pad4.length; i++)
321
+ pad4[i] ^= 54 ^ 92;
322
+ this.oHash.update(pad4);
323
+ clean(pad4);
315
324
  }
316
325
  update(buf) {
317
326
  aexists(this);
@@ -1050,19 +1059,19 @@ function charCodeToBase16(char) {
1050
1059
  return void 0;
1051
1060
  }
1052
1061
  function pad(bytes, options = {}) {
1053
- const { dir, size: size3 = 32 } = options;
1054
- if (size3 === 0)
1062
+ const { dir, size: size4 = 32 } = options;
1063
+ if (size4 === 0)
1055
1064
  return bytes;
1056
- if (bytes.length > size3)
1065
+ if (bytes.length > size4)
1057
1066
  throw new SizeExceedsPaddingSizeError({
1058
1067
  size: bytes.length,
1059
- targetSize: size3,
1068
+ targetSize: size4,
1060
1069
  type: "Bytes"
1061
1070
  });
1062
- const paddedBytes = new Uint8Array(size3);
1063
- for (let i = 0; i < size3; i++) {
1071
+ const paddedBytes = new Uint8Array(size4);
1072
+ for (let i = 0; i < size4; i++) {
1064
1073
  const padEnd = dir === "right";
1065
- paddedBytes[padEnd ? i : size3 - i - 1] = bytes[padEnd ? i : bytes.length - i - 1];
1074
+ paddedBytes[padEnd ? i : size4 - i - 1] = bytes[padEnd ? i : bytes.length - i - 1];
1066
1075
  }
1067
1076
  return paddedBytes;
1068
1077
  }
@@ -1121,17 +1130,17 @@ function assertEndOffset2(value, start, end) {
1121
1130
  }
1122
1131
  }
1123
1132
  function pad2(hex_, options = {}) {
1124
- const { dir, size: size3 = 32 } = options;
1125
- if (size3 === 0)
1133
+ const { dir, size: size4 = 32 } = options;
1134
+ if (size4 === 0)
1126
1135
  return hex_;
1127
1136
  const hex3 = hex_.replace("0x", "");
1128
- if (hex3.length > size3 * 2)
1137
+ if (hex3.length > size4 * 2)
1129
1138
  throw new SizeExceedsPaddingSizeError2({
1130
1139
  size: Math.ceil(hex3.length / 2),
1131
- targetSize: size3,
1140
+ targetSize: size4,
1132
1141
  type: "Hex"
1133
1142
  });
1134
- return `0x${hex3[dir === "right" ? "padEnd" : "padStart"](size3 * 2, "0")}`;
1143
+ return `0x${hex3[dir === "right" ? "padEnd" : "padStart"](size4 * 2, "0")}`;
1135
1144
  }
1136
1145
  function trim2(value, options = {}) {
1137
1146
  const { dir = "left" } = options;
@@ -1288,14 +1297,14 @@ function fromBytes(value, options = {}) {
1288
1297
  return hex3;
1289
1298
  }
1290
1299
  function fromNumber(value, options = {}) {
1291
- const { signed, size: size3 } = options;
1300
+ const { signed, size: size4 } = options;
1292
1301
  const value_ = BigInt(value);
1293
1302
  let maxValue;
1294
- if (size3) {
1303
+ if (size4) {
1295
1304
  if (signed)
1296
- maxValue = (1n << BigInt(size3) * 8n - 1n) - 1n;
1305
+ maxValue = (1n << BigInt(size4) * 8n - 1n) - 1n;
1297
1306
  else
1298
- maxValue = 2n ** (BigInt(size3) * 8n) - 1n;
1307
+ maxValue = 2n ** (BigInt(size4) * 8n) - 1n;
1299
1308
  } else if (typeof value === "number") {
1300
1309
  maxValue = BigInt(Number.MAX_SAFE_INTEGER);
1301
1310
  }
@@ -1306,14 +1315,14 @@ function fromNumber(value, options = {}) {
1306
1315
  max: maxValue ? `${maxValue}${suffix}` : void 0,
1307
1316
  min: `${minValue}${suffix}`,
1308
1317
  signed,
1309
- size: size3,
1318
+ size: size4,
1310
1319
  value: `${value}${suffix}`
1311
1320
  });
1312
1321
  }
1313
- const stringValue = (signed && value_ < 0 ? BigInt.asUintN(size3 * 8, BigInt(value_)) : value_).toString(16);
1322
+ const stringValue = (signed && value_ < 0 ? BigInt.asUintN(size4 * 8, BigInt(value_)) : value_).toString(16);
1314
1323
  const hex3 = `0x${stringValue}`;
1315
- if (size3)
1316
- return padLeft(hex3, size3);
1324
+ if (size4)
1325
+ return padLeft(hex3, size4);
1317
1326
  return hex3;
1318
1327
  }
1319
1328
  function fromString(value, options = {}) {
@@ -1322,11 +1331,11 @@ function fromString(value, options = {}) {
1322
1331
  function isEqual(hexA, hexB) {
1323
1332
  return equalBytes(fromHex(hexA), fromHex(hexB));
1324
1333
  }
1325
- function padLeft(value, size3) {
1326
- return pad2(value, { dir: "left", size: size3 });
1334
+ function padLeft(value, size4) {
1335
+ return pad2(value, { dir: "left", size: size4 });
1327
1336
  }
1328
- function padRight(value, size3) {
1329
- return pad2(value, { dir: "right", size: size3 });
1337
+ function padRight(value, size4) {
1338
+ return pad2(value, { dir: "right", size: size4 });
1330
1339
  }
1331
1340
  function random2(length) {
1332
1341
  return fromBytes(random(length));
@@ -1355,8 +1364,8 @@ function toBigInt(hex3, options = {}) {
1355
1364
  const value = BigInt(hex3);
1356
1365
  if (!signed)
1357
1366
  return value;
1358
- const size3 = (hex3.length - 2) / 2;
1359
- const max_unsigned = (1n << BigInt(size3) * 8n) - 1n;
1367
+ const size4 = (hex3.length - 2) / 2;
1368
+ const max_unsigned = (1n << BigInt(size4) * 8n) - 1n;
1360
1369
  const max_signed = max_unsigned >> 1n;
1361
1370
  if (value <= max_signed)
1362
1371
  return value;
@@ -1376,16 +1385,16 @@ function toBytes2(hex3, options = {}) {
1376
1385
  return fromHex(hex3, options);
1377
1386
  }
1378
1387
  function toNumber(hex3, options = {}) {
1379
- const { signed, size: size3 } = options;
1380
- if (!signed && !size3)
1388
+ const { signed, size: size4 } = options;
1389
+ if (!signed && !size4)
1381
1390
  return Number(hex3);
1382
1391
  return Number(toBigInt(hex3, options));
1383
1392
  }
1384
1393
  function toString(hex3, options = {}) {
1385
- const { size: size3 } = options;
1394
+ const { size: size4 } = options;
1386
1395
  let bytes = fromHex(hex3);
1387
- if (size3) {
1388
- assertSize(bytes, size3);
1396
+ if (size4) {
1397
+ assertSize(bytes, size4);
1389
1398
  bytes = trimRight(bytes);
1390
1399
  }
1391
1400
  return new TextDecoder().decode(bytes);
@@ -1412,8 +1421,8 @@ var init_Hex = __esm({
1412
1421
  encoder = /* @__PURE__ */ new TextEncoder();
1413
1422
  hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_v, i) => i.toString(16).padStart(2, "0"));
1414
1423
  IntegerOutOfRangeError = class extends BaseError {
1415
- constructor({ max, min, signed, size: size3, value }) {
1416
- super(`Number \`${value}\` is not in safe${size3 ? ` ${size3 * 8}-bit` : ""}${signed ? " signed" : " unsigned"} integer range ${max ? `(\`${min}\` to \`${max}\`)` : `(above \`${min}\`)`}`);
1424
+ constructor({ max, min, signed, size: size4, value }) {
1425
+ super(`Number \`${value}\` is not in safe${size4 ? ` ${size4 * 8}-bit` : ""}${signed ? " signed" : " unsigned"} integer range ${max ? `(\`${min}\` to \`${max}\`)` : `(above \`${min}\`)`}`);
1417
1426
  Object.defineProperty(this, "name", {
1418
1427
  enumerable: true,
1419
1428
  configurable: true,
@@ -1490,8 +1499,8 @@ var init_Hex = __esm({
1490
1499
  }
1491
1500
  };
1492
1501
  SliceOffsetOutOfBoundsError2 = class extends BaseError {
1493
- constructor({ offset, position, size: size3 }) {
1494
- super(`Slice ${position === "start" ? "starting" : "ending"} at offset \`${offset}\` is out-of-bounds (size: \`${size3}\`).`);
1502
+ constructor({ offset, position, size: size4 }) {
1503
+ super(`Slice ${position === "start" ? "starting" : "ending"} at offset \`${offset}\` is out-of-bounds (size: \`${size4}\`).`);
1495
1504
  Object.defineProperty(this, "name", {
1496
1505
  enumerable: true,
1497
1506
  configurable: true,
@@ -1501,8 +1510,8 @@ var init_Hex = __esm({
1501
1510
  }
1502
1511
  };
1503
1512
  SizeExceedsPaddingSizeError2 = class extends BaseError {
1504
- constructor({ size: size3, targetSize, type }) {
1505
- super(`${type.charAt(0).toUpperCase()}${type.slice(1).toLowerCase()} size (\`${size3}\`) exceeds padding size (\`${targetSize}\`).`);
1513
+ constructor({ size: size4, targetSize, type }) {
1514
+ super(`${type.charAt(0).toUpperCase()}${type.slice(1).toLowerCase()} size (\`${size4}\`) exceeds padding size (\`${targetSize}\`).`);
1506
1515
  Object.defineProperty(this, "name", {
1507
1516
  enumerable: true,
1508
1517
  configurable: true,
@@ -1581,21 +1590,21 @@ function fromArray(value) {
1581
1590
  return value instanceof Uint8Array ? value : new Uint8Array(value);
1582
1591
  }
1583
1592
  function fromBoolean2(value, options = {}) {
1584
- const { size: size3 } = options;
1593
+ const { size: size4 } = options;
1585
1594
  const bytes = new Uint8Array(1);
1586
1595
  bytes[0] = Number(value);
1587
- if (typeof size3 === "number") {
1588
- assertSize(bytes, size3);
1589
- return padLeft2(bytes, size3);
1596
+ if (typeof size4 === "number") {
1597
+ assertSize(bytes, size4);
1598
+ return padLeft2(bytes, size4);
1590
1599
  }
1591
1600
  return bytes;
1592
1601
  }
1593
1602
  function fromHex(value, options = {}) {
1594
- const { size: size3 } = options;
1603
+ const { size: size4 } = options;
1595
1604
  let hex3 = value;
1596
- if (size3) {
1597
- assertSize2(value, size3);
1598
- hex3 = padRight(value, size3);
1605
+ if (size4) {
1606
+ assertSize2(value, size4);
1607
+ hex3 = padRight(value, size4);
1599
1608
  }
1600
1609
  let hexString = hex3.slice(2);
1601
1610
  if (hexString.length % 2)
@@ -1617,22 +1626,22 @@ function fromNumber2(value, options) {
1617
1626
  return fromHex(hex3);
1618
1627
  }
1619
1628
  function fromString2(value, options = {}) {
1620
- const { size: size3 } = options;
1629
+ const { size: size4 } = options;
1621
1630
  const bytes = encoder2.encode(value);
1622
- if (typeof size3 === "number") {
1623
- assertSize(bytes, size3);
1624
- return padRight2(bytes, size3);
1631
+ if (typeof size4 === "number") {
1632
+ assertSize(bytes, size4);
1633
+ return padRight2(bytes, size4);
1625
1634
  }
1626
1635
  return bytes;
1627
1636
  }
1628
1637
  function isEqual2(bytesA, bytesB) {
1629
1638
  return equalBytes(bytesA, bytesB);
1630
1639
  }
1631
- function padLeft2(value, size3) {
1632
- return pad(value, { dir: "left", size: size3 });
1640
+ function padLeft2(value, size4) {
1641
+ return pad(value, { dir: "left", size: size4 });
1633
1642
  }
1634
- function padRight2(value, size3) {
1635
- return pad(value, { dir: "right", size: size3 });
1643
+ function padRight2(value, size4) {
1644
+ return pad(value, { dir: "right", size: size4 });
1636
1645
  }
1637
1646
  function random(length) {
1638
1647
  return crypto.getRandomValues(new Uint8Array(length));
@@ -1649,17 +1658,17 @@ function slice2(value, start, end, options = {}) {
1649
1658
  return value_;
1650
1659
  }
1651
1660
  function toBigInt2(bytes, options = {}) {
1652
- const { size: size3 } = options;
1653
- if (typeof size3 !== "undefined")
1654
- assertSize(bytes, size3);
1661
+ const { size: size4 } = options;
1662
+ if (typeof size4 !== "undefined")
1663
+ assertSize(bytes, size4);
1655
1664
  const hex3 = fromBytes(bytes, options);
1656
1665
  return toBigInt(hex3, options);
1657
1666
  }
1658
1667
  function toBoolean2(bytes, options = {}) {
1659
- const { size: size3 } = options;
1668
+ const { size: size4 } = options;
1660
1669
  let bytes_ = bytes;
1661
- if (typeof size3 !== "undefined") {
1662
- assertSize(bytes_, size3);
1670
+ if (typeof size4 !== "undefined") {
1671
+ assertSize(bytes_, size4);
1663
1672
  bytes_ = trimLeft2(bytes_);
1664
1673
  }
1665
1674
  if (bytes_.length > 1 || bytes_[0] > 1)
@@ -1670,17 +1679,17 @@ function toHex(value, options = {}) {
1670
1679
  return fromBytes(value, options);
1671
1680
  }
1672
1681
  function toNumber2(bytes, options = {}) {
1673
- const { size: size3 } = options;
1674
- if (typeof size3 !== "undefined")
1675
- assertSize(bytes, size3);
1682
+ const { size: size4 } = options;
1683
+ if (typeof size4 !== "undefined")
1684
+ assertSize(bytes, size4);
1676
1685
  const hex3 = fromBytes(bytes, options);
1677
1686
  return toNumber(hex3, options);
1678
1687
  }
1679
1688
  function toString2(bytes, options = {}) {
1680
- const { size: size3 } = options;
1689
+ const { size: size4 } = options;
1681
1690
  let bytes_ = bytes;
1682
- if (typeof size3 !== "undefined") {
1683
- assertSize(bytes_, size3);
1691
+ if (typeof size4 !== "undefined") {
1692
+ assertSize(bytes_, size4);
1684
1693
  bytes_ = trimRight(bytes_);
1685
1694
  }
1686
1695
  return decoder.decode(bytes_);
@@ -1751,8 +1760,8 @@ var init_Bytes = __esm({
1751
1760
  }
1752
1761
  };
1753
1762
  SliceOffsetOutOfBoundsError = class extends BaseError {
1754
- constructor({ offset, position, size: size3 }) {
1755
- super(`Slice ${position === "start" ? "starting" : "ending"} at offset \`${offset}\` is out-of-bounds (size: \`${size3}\`).`);
1763
+ constructor({ offset, position, size: size4 }) {
1764
+ super(`Slice ${position === "start" ? "starting" : "ending"} at offset \`${offset}\` is out-of-bounds (size: \`${size4}\`).`);
1756
1765
  Object.defineProperty(this, "name", {
1757
1766
  enumerable: true,
1758
1767
  configurable: true,
@@ -1762,8 +1771,8 @@ var init_Bytes = __esm({
1762
1771
  }
1763
1772
  };
1764
1773
  SizeExceedsPaddingSizeError = class extends BaseError {
1765
- constructor({ size: size3, targetSize, type }) {
1766
- super(`${type.charAt(0).toUpperCase()}${type.slice(1).toLowerCase()} size (\`${size3}\`) exceeds padding size (\`${targetSize}\`).`);
1774
+ constructor({ size: size4, targetSize, type }) {
1775
+ super(`${type.charAt(0).toUpperCase()}${type.slice(1).toLowerCase()} size (\`${size4}\`) exceeds padding size (\`${targetSize}\`).`);
1767
1776
  Object.defineProperty(this, "name", {
1768
1777
  enumerable: true,
1769
1778
  configurable: true,
@@ -1833,7 +1842,7 @@ var init_lru = __esm({
1833
1842
  "node_modules/ox/_esm/core/internal/lru.js"() {
1834
1843
  "use strict";
1835
1844
  LruMap = class extends Map {
1836
- constructor(size3) {
1845
+ constructor(size4) {
1837
1846
  super();
1838
1847
  Object.defineProperty(this, "maxSize", {
1839
1848
  enumerable: true,
@@ -1841,7 +1850,7 @@ var init_lru = __esm({
1841
1850
  writable: true,
1842
1851
  value: void 0
1843
1852
  });
1844
- this.maxSize = size3;
1853
+ this.maxSize = size4;
1845
1854
  }
1846
1855
  get(key) {
1847
1856
  const value = super.get(key);
@@ -1902,11 +1911,11 @@ function assert3(value, options = {}) {
1902
1911
  });
1903
1912
  }
1904
1913
  }
1905
- function checksum2(address2) {
1906
- if (checksum.has(address2))
1907
- return checksum.get(address2);
1908
- assert3(address2, { strict: false });
1909
- const hexAddress = address2.substring(2).toLowerCase();
1914
+ function checksum2(address3) {
1915
+ if (checksum.has(address3))
1916
+ return checksum.get(address3);
1917
+ assert3(address3, { strict: false });
1918
+ const hexAddress = address3.substring(2).toLowerCase();
1910
1919
  const hash3 = keccak256(fromString2(hexAddress), { as: "Bytes" });
1911
1920
  const characters = hexAddress.split("");
1912
1921
  for (let i = 0; i < 40; i += 2) {
@@ -1918,7 +1927,7 @@ function checksum2(address2) {
1918
1927
  }
1919
1928
  }
1920
1929
  const result = `0x${characters.join("")}`;
1921
- checksum.set(address2, result);
1930
+ checksum.set(address3, result);
1922
1931
  return result;
1923
1932
  }
1924
1933
  var addressRegex, InvalidAddressError, InvalidInputError, InvalidChecksumError;
@@ -1931,8 +1940,8 @@ var init_Address = __esm({
1931
1940
  init_Hash();
1932
1941
  addressRegex = /^0x[a-fA-F0-9]{40}$/;
1933
1942
  InvalidAddressError = class extends BaseError {
1934
- constructor({ address: address2, cause }) {
1935
- super(`Address "${address2}" is invalid.`, {
1943
+ constructor({ address: address3, cause }) {
1944
+ super(`Address "${address3}" is invalid.`, {
1936
1945
  cause
1937
1946
  });
1938
1947
  Object.defineProperty(this, "name", {
@@ -2108,9 +2117,9 @@ var init_AbiParameters = __esm({
2108
2117
  (function(encodePacked2) {
2109
2118
  function encode2(type, value, isArray = false) {
2110
2119
  if (type === "address") {
2111
- const address2 = value;
2112
- assert3(address2);
2113
- return padLeft(address2.toLowerCase(), isArray ? 32 : 0);
2120
+ const address3 = value;
2121
+ assert3(address3);
2122
+ return padLeft(address3.toLowerCase(), isArray ? 32 : 0);
2114
2123
  }
2115
2124
  if (type === "string")
2116
2125
  return fromString(value);
@@ -2121,18 +2130,18 @@ var init_AbiParameters = __esm({
2121
2130
  const intMatch = type.match(integerRegex);
2122
2131
  if (intMatch) {
2123
2132
  const [_type, baseType, bits = "256"] = intMatch;
2124
- const size3 = Number.parseInt(bits, 10) / 8;
2133
+ const size4 = Number.parseInt(bits, 10) / 8;
2125
2134
  return fromNumber(value, {
2126
- size: isArray ? 32 : size3,
2135
+ size: isArray ? 32 : size4,
2127
2136
  signed: baseType === "int"
2128
2137
  });
2129
2138
  }
2130
2139
  const bytesMatch = type.match(bytesRegex);
2131
2140
  if (bytesMatch) {
2132
- const [_type, size3] = bytesMatch;
2133
- if (Number.parseInt(size3, 10) !== (value.length - 2) / 2)
2141
+ const [_type, size4] = bytesMatch;
2142
+ if (Number.parseInt(size4, 10) !== (value.length - 2) / 2)
2134
2143
  throw new BytesSizeMismatchError({
2135
- expectedSize: Number.parseInt(size3, 10),
2144
+ expectedSize: Number.parseInt(size4, 10),
2136
2145
  value
2137
2146
  });
2138
2147
  return padRight(value, isArray ? 32 : 0);
@@ -2287,7 +2296,7 @@ __export(Base64_exports, {
2287
2296
  toString: () => toString3
2288
2297
  });
2289
2298
  function fromBytes2(value, options = {}) {
2290
- const { pad: pad3 = true, url: url2 = false } = options;
2299
+ const { pad: pad4 = true, url: url2 = false } = options;
2291
2300
  const encoded = new Uint8Array(Math.ceil(value.length / 3) * 4);
2292
2301
  for (let i = 0, j = 0; j < value.length; i += 4, j += 3) {
2293
2302
  const y = (value[j] << 16) + (value[j + 1] << 8) + (value[j + 2] | 0);
@@ -2299,9 +2308,9 @@ function fromBytes2(value, options = {}) {
2299
2308
  const k = value.length % 3;
2300
2309
  const end = Math.floor(value.length / 3) * 4 + (k && k + 1);
2301
2310
  let base643 = decoder2.decode(new Uint8Array(encoded.buffer, 0, end));
2302
- if (pad3 && k === 1)
2311
+ if (pad4 && k === 1)
2303
2312
  base643 += "==";
2304
- if (pad3 && k === 2)
2313
+ if (pad4 && k === 2)
2305
2314
  base643 += "=";
2306
2315
  if (url2)
2307
2316
  base643 = base643.replaceAll("+", "-").replaceAll("/", "_");
@@ -2315,8 +2324,8 @@ function fromString3(value, options = {}) {
2315
2324
  }
2316
2325
  function toBytes3(value) {
2317
2326
  const base643 = value.replace(/=+$/, "");
2318
- const size3 = base643.length;
2319
- const decoded = new Uint8Array(size3 + 3);
2327
+ const size4 = base643.length;
2328
+ const decoded = new Uint8Array(size4 + 3);
2320
2329
  encoder3.encodeInto(base643 + "===", decoded);
2321
2330
  for (let i = 0, j = 0; i < base643.length; i += 4, j += 3) {
2322
2331
  const x = (characterToInteger[decoded[i]] << 18) + (characterToInteger[decoded[i + 1]] << 12) + (characterToInteger[decoded[i + 2]] << 6) + characterToInteger[decoded[i + 3]];
@@ -2324,7 +2333,7 @@ function toBytes3(value) {
2324
2333
  decoded[j + 1] = x >> 8 & 255;
2325
2334
  decoded[j + 2] = x & 255;
2326
2335
  }
2327
- const decodedSize = (size3 >> 2) * 3 + (size3 % 4 && size3 % 4 - 1);
2336
+ const decodedSize = (size4 >> 2) * 3 + (size4 % 4 && size4 % 4 - 1);
2328
2337
  return new Uint8Array(decoded.buffer, 0, decodedSize);
2329
2338
  }
2330
2339
  function toHex2(value) {
@@ -2606,8 +2615,8 @@ var init_Cbor = __esm({
2606
2615
  }
2607
2616
  };
2608
2617
  StringTooLargeError = class extends BaseError {
2609
- constructor({ size: size3 }) {
2610
- super(`String length exceeds maximum (4294967295): ${size3}`);
2618
+ constructor({ size: size4 }) {
2619
+ super(`String length exceeds maximum (4294967295): ${size4}`);
2611
2620
  Object.defineProperty(this, "name", {
2612
2621
  enumerable: true,
2613
2622
  configurable: true,
@@ -2617,8 +2626,8 @@ var init_Cbor = __esm({
2617
2626
  }
2618
2627
  };
2619
2628
  ArrayTooLargeError = class extends BaseError {
2620
- constructor({ size: size3 }) {
2621
- super(`Array length exceeds maximum (4294967295): ${size3}`);
2629
+ constructor({ size: size4 }) {
2630
+ super(`Array length exceeds maximum (4294967295): ${size4}`);
2622
2631
  Object.defineProperty(this, "name", {
2623
2632
  enumerable: true,
2624
2633
  configurable: true,
@@ -2628,8 +2637,8 @@ var init_Cbor = __esm({
2628
2637
  }
2629
2638
  };
2630
2639
  ObjectTooLargeError = class extends BaseError {
2631
- constructor({ size: size3 }) {
2632
- super(`Object size exceeds maximum (4294967295): ${size3}`);
2640
+ constructor({ size: size4 }) {
2641
+ super(`Object size exceeds maximum (4294967295): ${size4}`);
2633
2642
  Object.defineProperty(this, "name", {
2634
2643
  enumerable: true,
2635
2644
  configurable: true,
@@ -2639,8 +2648,8 @@ var init_Cbor = __esm({
2639
2648
  }
2640
2649
  };
2641
2650
  ByteStringTooLargeError = class extends BaseError {
2642
- constructor({ size: size3 }) {
2643
- super(`Byte string length exceeds maximum (4294967295): ${size3}`);
2651
+ constructor({ size: size4 }) {
2652
+ super(`Byte string length exceeds maximum (4294967295): ${size4}`);
2644
2653
  Object.defineProperty(this, "name", {
2645
2654
  enumerable: true,
2646
2655
  configurable: true,
@@ -2705,37 +2714,37 @@ var init_Cbor = __esm({
2705
2714
  };
2706
2715
  throw new NumberTooLargeError({ number: value.toString(10) });
2707
2716
  }
2708
- const positiveNumber = -1 - value;
2717
+ const positiveNumber2 = -1 - value;
2709
2718
  if (value >= -24)
2710
2719
  return {
2711
2720
  length: 1,
2712
- encode: (cursor) => cursor.pushUint8(32 + positiveNumber)
2721
+ encode: (cursor) => cursor.pushUint8(32 + positiveNumber2)
2713
2722
  };
2714
- if (positiveNumber <= 255)
2723
+ if (positiveNumber2 <= 255)
2715
2724
  return {
2716
2725
  length: 2,
2717
2726
  // 1 byte prefix + 1 byte uint8
2718
2727
  encode: (cursor) => {
2719
2728
  cursor.pushUint8(56);
2720
- cursor.pushUint8(positiveNumber);
2729
+ cursor.pushUint8(positiveNumber2);
2721
2730
  }
2722
2731
  };
2723
- if (positiveNumber <= 65535)
2732
+ if (positiveNumber2 <= 65535)
2724
2733
  return {
2725
2734
  length: 3,
2726
2735
  // 1 byte prefix + 2 bytes uint16
2727
2736
  encode: (cursor) => {
2728
2737
  cursor.pushUint8(57);
2729
- cursor.pushUint16(positiveNumber);
2738
+ cursor.pushUint16(positiveNumber2);
2730
2739
  }
2731
2740
  };
2732
- if (positiveNumber <= 4294967295)
2741
+ if (positiveNumber2 <= 4294967295)
2733
2742
  return {
2734
2743
  length: 5,
2735
2744
  // 1 byte prefix + 4 bytes uint32
2736
2745
  encode: (cursor) => {
2737
2746
  cursor.pushUint8(58);
2738
- cursor.pushUint32(positiveNumber);
2747
+ cursor.pushUint32(positiveNumber2);
2739
2748
  }
2740
2749
  };
2741
2750
  throw new NumberTooLargeError({ number: value.toString(10) });
@@ -2743,142 +2752,142 @@ var init_Cbor = __esm({
2743
2752
  getEncodable2.number = number4;
2744
2753
  function string4(value) {
2745
2754
  const encoded = fromString2(value);
2746
- const size3 = encoded.length;
2747
- if (size3 <= 23)
2755
+ const size4 = encoded.length;
2756
+ if (size4 <= 23)
2748
2757
  return {
2749
- length: 1 + size3,
2758
+ length: 1 + size4,
2750
2759
  // 1 byte prefix + size bytes
2751
2760
  encode(cursor) {
2752
- cursor.pushUint8(96 + size3);
2753
- if (size3 > 0)
2761
+ cursor.pushUint8(96 + size4);
2762
+ if (size4 > 0)
2754
2763
  cursor.pushBytes(encoded);
2755
2764
  }
2756
2765
  };
2757
- if (size3 <= 255)
2766
+ if (size4 <= 255)
2758
2767
  return {
2759
- length: 2 + size3,
2768
+ length: 2 + size4,
2760
2769
  // 1 byte prefix + 1 byte uint8 + size bytes
2761
2770
  encode(cursor) {
2762
2771
  cursor.pushUint8(120);
2763
- cursor.pushUint8(size3);
2772
+ cursor.pushUint8(size4);
2764
2773
  cursor.pushBytes(encoded);
2765
2774
  }
2766
2775
  };
2767
- if (size3 <= 65535)
2776
+ if (size4 <= 65535)
2768
2777
  return {
2769
- length: 3 + size3,
2778
+ length: 3 + size4,
2770
2779
  // 1 byte prefix + 2 bytes uint16 + size bytes
2771
2780
  encode(cursor) {
2772
2781
  cursor.pushUint8(121);
2773
- cursor.pushUint16(size3);
2782
+ cursor.pushUint16(size4);
2774
2783
  cursor.pushBytes(encoded);
2775
2784
  }
2776
2785
  };
2777
- if (size3 <= 4294967295)
2786
+ if (size4 <= 4294967295)
2778
2787
  return {
2779
- length: 5 + size3,
2788
+ length: 5 + size4,
2780
2789
  // 1 byte prefix + 4 bytes uint32 + size bytes
2781
2790
  encode(cursor) {
2782
2791
  cursor.pushUint8(122);
2783
- cursor.pushUint32(size3);
2792
+ cursor.pushUint32(size4);
2784
2793
  cursor.pushBytes(encoded);
2785
2794
  }
2786
2795
  };
2787
- throw new StringTooLargeError({ size: size3 });
2796
+ throw new StringTooLargeError({ size: size4 });
2788
2797
  }
2789
2798
  getEncodable2.string = string4;
2790
2799
  function array2(value) {
2791
2800
  const items = value.map((item) => getEncodable2(item));
2792
2801
  const bodyLength = items.reduce((acc, item) => acc + item.length, 0);
2793
- const size3 = value.length;
2794
- if (size3 <= 23)
2802
+ const size4 = value.length;
2803
+ if (size4 <= 23)
2795
2804
  return {
2796
2805
  length: 1 + bodyLength,
2797
2806
  // 1 byte prefix + body length
2798
2807
  encode(cursor) {
2799
- cursor.pushUint8(128 + size3);
2808
+ cursor.pushUint8(128 + size4);
2800
2809
  for (const item of items)
2801
2810
  item.encode(cursor);
2802
2811
  }
2803
2812
  };
2804
- if (size3 <= 255)
2813
+ if (size4 <= 255)
2805
2814
  return {
2806
2815
  length: 2 + bodyLength,
2807
2816
  // 1 byte prefix + 1 byte uint8 + body length
2808
2817
  encode(cursor) {
2809
2818
  cursor.pushUint8(152);
2810
- cursor.pushUint8(size3);
2819
+ cursor.pushUint8(size4);
2811
2820
  for (const item of items)
2812
2821
  item.encode(cursor);
2813
2822
  }
2814
2823
  };
2815
- if (size3 <= 65535)
2824
+ if (size4 <= 65535)
2816
2825
  return {
2817
2826
  length: 3 + bodyLength,
2818
2827
  // 1 byte prefix + 2 bytes uint16 + body length
2819
2828
  encode(cursor) {
2820
2829
  cursor.pushUint8(153);
2821
- cursor.pushUint16(size3);
2830
+ cursor.pushUint16(size4);
2822
2831
  for (const item of items)
2823
2832
  item.encode(cursor);
2824
2833
  }
2825
2834
  };
2826
- if (size3 <= 4294967295)
2835
+ if (size4 <= 4294967295)
2827
2836
  return {
2828
2837
  length: 5 + bodyLength,
2829
2838
  // 1 byte prefix + 4 bytes uint32 + body length
2830
2839
  encode(cursor) {
2831
2840
  cursor.pushUint8(154);
2832
- cursor.pushUint32(size3);
2841
+ cursor.pushUint32(size4);
2833
2842
  for (const item of items)
2834
2843
  item.encode(cursor);
2835
2844
  }
2836
2845
  };
2837
- throw new ArrayTooLargeError({ size: size3 });
2846
+ throw new ArrayTooLargeError({ size: size4 });
2838
2847
  }
2839
2848
  getEncodable2.array = array2;
2840
2849
  function byteString(value) {
2841
- const size3 = value.byteLength;
2842
- if (size3 <= 23)
2850
+ const size4 = value.byteLength;
2851
+ if (size4 <= 23)
2843
2852
  return {
2844
- length: 1 + size3,
2853
+ length: 1 + size4,
2845
2854
  // 1 byte prefix + size bytes
2846
2855
  encode(cursor) {
2847
- cursor.pushUint8(64 + size3);
2856
+ cursor.pushUint8(64 + size4);
2848
2857
  cursor.pushBytes(value);
2849
2858
  }
2850
2859
  };
2851
- if (size3 <= 255)
2860
+ if (size4 <= 255)
2852
2861
  return {
2853
- length: 2 + size3,
2862
+ length: 2 + size4,
2854
2863
  // 1 byte prefix + 1 byte uint8 + size bytes
2855
2864
  encode(cursor) {
2856
2865
  cursor.pushUint8(88);
2857
- cursor.pushUint8(size3);
2866
+ cursor.pushUint8(size4);
2858
2867
  cursor.pushBytes(value);
2859
2868
  }
2860
2869
  };
2861
- if (size3 <= 65535)
2870
+ if (size4 <= 65535)
2862
2871
  return {
2863
- length: 3 + size3,
2872
+ length: 3 + size4,
2864
2873
  // 1 byte prefix + 2 bytes uint16 + size bytes
2865
2874
  encode(cursor) {
2866
2875
  cursor.pushUint8(89);
2867
- cursor.pushUint16(size3);
2876
+ cursor.pushUint16(size4);
2868
2877
  cursor.pushBytes(value);
2869
2878
  }
2870
2879
  };
2871
- if (size3 <= 4294967295)
2880
+ if (size4 <= 4294967295)
2872
2881
  return {
2873
- length: 5 + size3,
2882
+ length: 5 + size4,
2874
2883
  // 1 byte prefix + 4 bytes uint32 + size bytes
2875
2884
  encode(cursor) {
2876
2885
  cursor.pushUint8(90);
2877
- cursor.pushUint32(size3);
2886
+ cursor.pushUint32(size4);
2878
2887
  cursor.pushBytes(value);
2879
2888
  }
2880
2889
  };
2881
- throw new ByteStringTooLargeError({ size: size3 });
2890
+ throw new ByteStringTooLargeError({ size: size4 });
2882
2891
  }
2883
2892
  getEncodable2.byteString = byteString;
2884
2893
  function object2(value) {
@@ -2888,59 +2897,59 @@ var init_Cbor = __esm({
2888
2897
  value: getEncodable2(value[key])
2889
2898
  }));
2890
2899
  const bodyLength = entries.reduce((acc, entry) => acc + entry.key.length + entry.value.length, 0);
2891
- const size3 = keys.length;
2892
- if (size3 <= 23)
2900
+ const size4 = keys.length;
2901
+ if (size4 <= 23)
2893
2902
  return {
2894
2903
  length: 1 + bodyLength,
2895
2904
  // 1 byte prefix + body length
2896
2905
  encode(cursor) {
2897
- cursor.pushUint8(160 + size3);
2906
+ cursor.pushUint8(160 + size4);
2898
2907
  for (const entry of entries) {
2899
2908
  entry.key.encode(cursor);
2900
2909
  entry.value.encode(cursor);
2901
2910
  }
2902
2911
  }
2903
2912
  };
2904
- if (size3 <= 255)
2913
+ if (size4 <= 255)
2905
2914
  return {
2906
2915
  length: 2 + bodyLength,
2907
2916
  // 1 byte prefix + 1 byte uint8 + body length
2908
2917
  encode(cursor) {
2909
2918
  cursor.pushUint8(184);
2910
- cursor.pushUint8(size3);
2919
+ cursor.pushUint8(size4);
2911
2920
  for (const entry of entries) {
2912
2921
  entry.key.encode(cursor);
2913
2922
  entry.value.encode(cursor);
2914
2923
  }
2915
2924
  }
2916
2925
  };
2917
- if (size3 <= 65535)
2926
+ if (size4 <= 65535)
2918
2927
  return {
2919
2928
  length: 3 + bodyLength,
2920
2929
  // 1 byte prefix + 2 bytes uint16 + body length
2921
2930
  encode(cursor) {
2922
2931
  cursor.pushUint8(185);
2923
- cursor.pushUint16(size3);
2932
+ cursor.pushUint16(size4);
2924
2933
  for (const entry of entries) {
2925
2934
  entry.key.encode(cursor);
2926
2935
  entry.value.encode(cursor);
2927
2936
  }
2928
2937
  }
2929
2938
  };
2930
- if (size3 <= 4294967295)
2939
+ if (size4 <= 4294967295)
2931
2940
  return {
2932
2941
  length: 5 + bodyLength,
2933
2942
  // 1 byte prefix + 4 bytes uint32 + body length
2934
2943
  encode(cursor) {
2935
2944
  cursor.pushUint8(186);
2936
- cursor.pushUint32(size3);
2945
+ cursor.pushUint32(size4);
2937
2946
  for (const entry of entries) {
2938
2947
  entry.key.encode(cursor);
2939
2948
  entry.value.encode(cursor);
2940
2949
  }
2941
2950
  }
2942
2951
  };
2943
- throw new ObjectTooLargeError({ size: size3 });
2952
+ throw new ObjectTooLargeError({ size: size4 });
2944
2953
  }
2945
2954
  getEncodable2.object = object2;
2946
2955
  function map2(value) {
@@ -2948,55 +2957,55 @@ var init_Cbor = __esm({
2948
2957
  for (const [k, v] of value)
2949
2958
  entries.push({ key: getEncodable2(k), value: getEncodable2(v) });
2950
2959
  const bodyLength = entries.reduce((acc, entry) => acc + entry.key.length + entry.value.length, 0);
2951
- const size3 = value.size;
2952
- if (size3 <= 23)
2960
+ const size4 = value.size;
2961
+ if (size4 <= 23)
2953
2962
  return {
2954
2963
  length: 1 + bodyLength,
2955
2964
  encode(cursor) {
2956
- cursor.pushUint8(160 + size3);
2965
+ cursor.pushUint8(160 + size4);
2957
2966
  for (const entry of entries) {
2958
2967
  entry.key.encode(cursor);
2959
2968
  entry.value.encode(cursor);
2960
2969
  }
2961
2970
  }
2962
2971
  };
2963
- if (size3 <= 255)
2972
+ if (size4 <= 255)
2964
2973
  return {
2965
2974
  length: 2 + bodyLength,
2966
2975
  encode(cursor) {
2967
2976
  cursor.pushUint8(184);
2968
- cursor.pushUint8(size3);
2977
+ cursor.pushUint8(size4);
2969
2978
  for (const entry of entries) {
2970
2979
  entry.key.encode(cursor);
2971
2980
  entry.value.encode(cursor);
2972
2981
  }
2973
2982
  }
2974
2983
  };
2975
- if (size3 <= 65535)
2984
+ if (size4 <= 65535)
2976
2985
  return {
2977
2986
  length: 3 + bodyLength,
2978
2987
  encode(cursor) {
2979
2988
  cursor.pushUint8(185);
2980
- cursor.pushUint16(size3);
2989
+ cursor.pushUint16(size4);
2981
2990
  for (const entry of entries) {
2982
2991
  entry.key.encode(cursor);
2983
2992
  entry.value.encode(cursor);
2984
2993
  }
2985
2994
  }
2986
2995
  };
2987
- if (size3 <= 4294967295)
2996
+ if (size4 <= 4294967295)
2988
2997
  return {
2989
2998
  length: 5 + bodyLength,
2990
2999
  encode(cursor) {
2991
3000
  cursor.pushUint8(186);
2992
- cursor.pushUint32(size3);
3001
+ cursor.pushUint32(size4);
2993
3002
  for (const entry of entries) {
2994
3003
  entry.key.encode(cursor);
2995
3004
  entry.value.encode(cursor);
2996
3005
  }
2997
3006
  }
2998
3007
  };
2999
- throw new ObjectTooLargeError({ size: size3 });
3008
+ throw new ObjectTooLargeError({ size: size4 });
3000
3009
  }
3001
3010
  getEncodable2.map = map2;
3002
3011
  })(getEncodable || (getEncodable = {}));
@@ -4432,6 +4441,60 @@ var init_BodyDigest = __esm({
4432
4441
  }
4433
4442
  });
4434
4443
 
4444
+ // node_modules/mppx/dist/Constants.js
4445
+ var Constants_exports = {};
4446
+ __export(Constants_exports, {
4447
+ Headers: () => Headers,
4448
+ Intents: () => Intents,
4449
+ MethodDetailKeys: () => MethodDetailKeys,
4450
+ Methods: () => Methods,
4451
+ Schemes: () => Schemes,
4452
+ SessionProtocols: () => SessionProtocols,
4453
+ getMethodDetail: () => getMethodDetail
4454
+ });
4455
+ function getMethodDetail(methodDetails, key) {
4456
+ if (!methodDetails || typeof methodDetails !== "object")
4457
+ return void 0;
4458
+ return methodDetails[key];
4459
+ }
4460
+ var Headers, Schemes, Methods, Intents, MethodDetailKeys, SessionProtocols;
4461
+ var init_Constants = __esm({
4462
+ "node_modules/mppx/dist/Constants.js"() {
4463
+ "use strict";
4464
+ Headers = {
4465
+ acceptPayment: "Accept-Payment",
4466
+ authorization: "Authorization",
4467
+ paymentReceipt: "Payment-Receipt",
4468
+ paymentSession: "Payment-Session",
4469
+ paymentSessionSnapshot: "Payment-Session-Snapshot",
4470
+ wwwAuthenticate: "WWW-Authenticate"
4471
+ };
4472
+ Schemes = {
4473
+ payment: "Payment"
4474
+ };
4475
+ Methods = {
4476
+ evm: "evm",
4477
+ stripe: "stripe",
4478
+ tempo: "tempo"
4479
+ };
4480
+ Intents = {
4481
+ charge: "charge",
4482
+ session: "session",
4483
+ subscription: "subscription"
4484
+ };
4485
+ MethodDetailKeys = {
4486
+ sessionProtocol: "sessionProtocol",
4487
+ sessionSnapshot: "sessionSnapshot"
4488
+ };
4489
+ SessionProtocols = {
4490
+ /** Legacy contract-backed Tempo session protocol. */
4491
+ v1: "v1",
4492
+ /** TIP-1034 precompile-backed Tempo session protocol. */
4493
+ v2: "v2"
4494
+ };
4495
+ }
4496
+ });
4497
+
4435
4498
  // node_modules/mppx/dist/PaymentRequest.js
4436
4499
  var PaymentRequest_exports = {};
4437
4500
  __export(PaymentRequest_exports, {
@@ -5594,10 +5657,10 @@ var init_regexes = __esm({
5594
5657
  duration = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;
5595
5658
  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)?)??$/;
5596
5659
  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})$/;
5597
- uuid = (version3) => {
5598
- if (!version3)
5660
+ uuid = (version4) => {
5661
+ if (!version4)
5599
5662
  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)$/;
5600
- return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${version3}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`);
5663
+ 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})$`);
5601
5664
  };
5602
5665
  uuid4 = /* @__PURE__ */ uuid(4);
5603
5666
  uuid6 = /* @__PURE__ */ uuid(6);
@@ -5886,8 +5949,8 @@ var init_checks = __esm({
5886
5949
  });
5887
5950
  inst._zod.check = (payload) => {
5888
5951
  const input = payload.value;
5889
- const size3 = input.size;
5890
- if (size3 <= def.maximum)
5952
+ const size4 = input.size;
5953
+ if (size4 <= def.maximum)
5891
5954
  return;
5892
5955
  payload.issues.push({
5893
5956
  origin: getSizableOrigin(input),
@@ -5914,8 +5977,8 @@ var init_checks = __esm({
5914
5977
  });
5915
5978
  inst._zod.check = (payload) => {
5916
5979
  const input = payload.value;
5917
- const size3 = input.size;
5918
- if (size3 >= def.minimum)
5980
+ const size4 = input.size;
5981
+ if (size4 >= def.minimum)
5919
5982
  return;
5920
5983
  payload.issues.push({
5921
5984
  origin: getSizableOrigin(input),
@@ -5943,10 +6006,10 @@ var init_checks = __esm({
5943
6006
  });
5944
6007
  inst._zod.check = (payload) => {
5945
6008
  const input = payload.value;
5946
- const size3 = input.size;
5947
- if (size3 === def.size)
6009
+ const size4 = input.size;
6010
+ if (size4 === def.size)
5948
6011
  return;
5949
- const tooBig = size3 > def.size;
6012
+ const tooBig = size4 > def.size;
5950
6013
  payload.issues.push({
5951
6014
  origin: getSizableOrigin(input),
5952
6015
  ...tooBig ? { code: "too_big", maximum: def.size } : { code: "too_small", minimum: def.size },
@@ -6995,7 +7058,7 @@ var init_schemas = __esm({
6995
7058
  try {
6996
7059
  if (parts.length !== 2)
6997
7060
  throw new Error();
6998
- const [address2, prefix] = parts;
7061
+ const [address3, prefix] = parts;
6999
7062
  if (!prefix)
7000
7063
  throw new Error();
7001
7064
  const prefixNum = Number(prefix);
@@ -7003,7 +7066,7 @@ var init_schemas = __esm({
7003
7066
  throw new Error();
7004
7067
  if (prefixNum < 0 || prefixNum > 128)
7005
7068
  throw new Error();
7006
- new URL(`http://[${address2}]`);
7069
+ new URL(`http://[${address3}]`);
7007
7070
  } catch {
7008
7071
  payload.issues.push({
7009
7072
  code: "invalid_format",
@@ -15356,11 +15419,11 @@ function _minSize(minimum, params) {
15356
15419
  });
15357
15420
  }
15358
15421
  // @__NO_SIDE_EFFECTS__
15359
- function _size(size3, params) {
15422
+ function _size(size4, params) {
15360
15423
  return new $ZodCheckSizeEquals({
15361
15424
  check: "size_equals",
15362
15425
  ...normalizeParams(params),
15363
- size: size3
15426
+ size: size4
15364
15427
  });
15365
15428
  }
15366
15429
  // @__NO_SIDE_EFFECTS__
@@ -18774,7 +18837,7 @@ function fromMethod2(method, parameters) {
18774
18837
  const { description, digest, expires, id, meta: meta4, realm, secretKey } = parameters;
18775
18838
  const request = fromMethod(method, parameters.request);
18776
18839
  return from4({
18777
- ...id ? { id } : { secretKey },
18840
+ ...id !== void 0 ? { id } : { secretKey },
18778
18841
  realm,
18779
18842
  method: methodName,
18780
18843
  intent,
@@ -18787,23 +18850,28 @@ function fromMethod2(method, parameters) {
18787
18850
  }
18788
18851
  function serialize2(challenge) {
18789
18852
  const parts = [
18790
- `id="${challenge.id}"`,
18791
- `realm="${challenge.realm}"`,
18792
- `method="${challenge.method}"`,
18793
- `intent="${challenge.intent}"`,
18794
- `request="${serialize(challenge.request)}"`
18853
+ authParam("id", challenge.id),
18854
+ authParam("realm", challenge.realm),
18855
+ authParam("method", challenge.method),
18856
+ authParam("intent", challenge.intent),
18857
+ authParam("request", serialize(challenge.request))
18795
18858
  ];
18796
18859
  if (challenge.description !== void 0)
18797
- parts.push(`description="${challenge.description}"`);
18860
+ parts.push(authParam("description", challenge.description));
18798
18861
  if (challenge.digest !== void 0)
18799
- parts.push(`digest="${challenge.digest}"`);
18862
+ parts.push(authParam("digest", challenge.digest));
18800
18863
  if (challenge.expires !== void 0)
18801
- parts.push(`expires="${challenge.expires}"`);
18864
+ parts.push(authParam("expires", challenge.expires));
18802
18865
  if (challenge.opaque !== void 0)
18803
- parts.push(`opaque="${challenge.opaque}"`);
18866
+ parts.push(authParam("opaque", challenge.opaque));
18804
18867
  else if (challenge.meta !== void 0)
18805
- parts.push(`opaque="${serialize(challenge.meta)}"`);
18806
- return `Payment ${parts.join(", ")}`;
18868
+ parts.push(authParam("opaque", serialize(challenge.meta)));
18869
+ return `${Schemes.payment} ${parts.join(", ")}`;
18870
+ }
18871
+ function authParam(name, value) {
18872
+ if (/[\r\n]/.test(value))
18873
+ throw new Error("Invalid quoted-string value.");
18874
+ return `${name}="${value.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`;
18807
18875
  }
18808
18876
  function deserialize2(value, options) {
18809
18877
  const params = extractPaymentAuthParams(value);
@@ -18813,6 +18881,8 @@ function deserialize2(value, options) {
18813
18881
  const { request, opaque, ...rest } = result;
18814
18882
  if (!request)
18815
18883
  throw new Error("Missing request parameter.");
18884
+ if (request.length > maxRequestParameterLength)
18885
+ throw new Error("Request parameter too large.");
18816
18886
  if (rest.method && !/^[a-z][a-z0-9:_-]*$/.test(rest.method))
18817
18887
  throw new Error(`Invalid method: "${rest.method}". Must be lowercase per spec.`);
18818
18888
  return from4({
@@ -18822,7 +18892,7 @@ function deserialize2(value, options) {
18822
18892
  }, options);
18823
18893
  }
18824
18894
  function extractPaymentAuthParams(header) {
18825
- const token = "Payment";
18895
+ const token = Schemes.payment;
18826
18896
  let inQuotes = false;
18827
18897
  let escaped = false;
18828
18898
  for (let i = 0; i < header.length; i++) {
@@ -18891,23 +18961,30 @@ function readAuthParamValue(input, start) {
18891
18961
  }
18892
18962
  function readQuotedAuthParamValue(input, start) {
18893
18963
  let i = start;
18894
- let value = "";
18895
18964
  let escaped = false;
18965
+ let segmentStart = start;
18966
+ let parts;
18896
18967
  while (i < input.length) {
18897
18968
  const char = input[i];
18898
18969
  i++;
18899
18970
  if (escaped) {
18900
- value += char;
18971
+ parts ??= [];
18972
+ parts.push(char);
18973
+ segmentStart = i;
18901
18974
  escaped = false;
18902
18975
  continue;
18903
18976
  }
18904
18977
  if (char === "\\") {
18978
+ parts ??= [];
18979
+ parts.push(input.slice(segmentStart, i - 1));
18980
+ segmentStart = i;
18905
18981
  escaped = true;
18906
18982
  continue;
18907
18983
  }
18908
- if (char === '"')
18984
+ if (char === '"') {
18985
+ const value = parts ? [...parts, input.slice(segmentStart, i - 1)].join("") : input.slice(start, i - 1);
18909
18986
  return [value, i];
18910
- value += char;
18987
+ }
18911
18988
  }
18912
18989
  throw new Error("Unterminated quoted-string.");
18913
18990
  }
@@ -18918,9 +18995,9 @@ function startsWithSchemeToken(value, index, token) {
18918
18995
  return Boolean(next && /\s/.test(next));
18919
18996
  }
18920
18997
  function fromHeaders(headers, options) {
18921
- const header = headers.get("WWW-Authenticate");
18998
+ const header = headers.get(Headers.wwwAuthenticate);
18922
18999
  if (!header)
18923
- throw new Error("Missing WWW-Authenticate header.");
19000
+ throw new Error(`Missing ${Headers.wwwAuthenticate} header.`);
18924
19001
  return deserialize2(header, options);
18925
19002
  }
18926
19003
  function fromResponse(response, options) {
@@ -18934,14 +19011,15 @@ function fromResponseList(response, options) {
18934
19011
  return fromHeadersList(response.headers, options);
18935
19012
  }
18936
19013
  function fromHeadersList(headers, options) {
18937
- const header = headers.get("WWW-Authenticate");
19014
+ const header = headers.get(Headers.wwwAuthenticate);
18938
19015
  if (!header)
18939
- throw new Error("Missing WWW-Authenticate header.");
19016
+ throw new Error(`Missing ${Headers.wwwAuthenticate} header.`);
18940
19017
  return deserializeList(header, options);
18941
19018
  }
18942
19019
  function deserializeList(value, options) {
18943
19020
  const starts = [];
18944
- for (const match of value.matchAll(/Payment\s+/gi)) {
19021
+ const schemePattern = new RegExp(`${Schemes.payment}\\s+`, "gi");
19022
+ for (const match of value.matchAll(schemePattern)) {
18945
19023
  starts.push(match.index);
18946
19024
  }
18947
19025
  if (starts.length === 0)
@@ -18977,14 +19055,16 @@ function computeId(challenge, options) {
18977
19055
  const mac3 = Hash_exports.hmac256(key, data, { as: "Bytes" });
18978
19056
  return Base64_exports.fromBytes(mac3, { url: true, pad: false });
18979
19057
  }
18980
- var Schema;
19058
+ var maxRequestParameterLength, Schema;
18981
19059
  var init_Challenge = __esm({
18982
19060
  "node_modules/mppx/dist/Challenge.js"() {
18983
19061
  "use strict";
18984
19062
  init_esm2();
19063
+ init_Constants();
18985
19064
  init_constantTimeEqual();
18986
19065
  init_PaymentRequest();
18987
19066
  init_zod();
19067
+ maxRequestParameterLength = 16 * 1024;
18988
19068
  Schema = object({
18989
19069
  /** Optional human-readable description of the payment. */
18990
19070
  description: optional(string2()),
@@ -18993,7 +19073,7 @@ var init_Challenge = __esm({
18993
19073
  /** Optional expiration timestamp (ISO 8601). */
18994
19074
  expires: optional(datetime3()),
18995
19075
  /** Unique challenge identifier (HMAC-bound). */
18996
- id: string2(),
19076
+ id: string2().check(_minLength(1)),
18997
19077
  /** Intent type (e.g., "charge", "session"). */
18998
19078
  intent: string2(),
18999
19079
  /** Payment method (e.g., "tempo", "stripe"). */
@@ -19023,7 +19103,7 @@ __export(Credential_exports, {
19023
19103
  serialize: () => serialize3
19024
19104
  });
19025
19105
  function deserialize3(value) {
19026
- const prefixMatch = value.match(/^Payment\s+(.+)$/i);
19106
+ const prefixMatch = value.match(new RegExp(`^${Schemes.payment}\\s+(.+)$`, "i"));
19027
19107
  if (!prefixMatch?.[1])
19028
19108
  throw new MissingPaymentSchemeError();
19029
19109
  try {
@@ -19072,7 +19152,7 @@ function from5(parameters) {
19072
19152
  };
19073
19153
  }
19074
19154
  function fromRequest(request) {
19075
- const header = request.headers.get("Authorization");
19155
+ const header = request.headers.get(Headers.authorization);
19076
19156
  if (!header)
19077
19157
  throw new MissingAuthorizationHeaderError();
19078
19158
  const payment = extractPaymentScheme(header);
@@ -19094,11 +19174,11 @@ function serialize3(credential) {
19094
19174
  };
19095
19175
  const json2 = JSON.stringify(wire);
19096
19176
  const encoded = Base64_exports.fromString(json2, { pad: false, url: true });
19097
- return `Payment ${encoded}`;
19177
+ return `${Schemes.payment} ${encoded}`;
19098
19178
  }
19099
19179
  function extractPaymentScheme(header) {
19100
- const schemes = header.split(",").map((s) => s.trim());
19101
- return schemes.find((s) => /^Payment\s+/i.test(s)) ?? null;
19180
+ const schemes2 = header.split(",").map((s) => s.trim());
19181
+ return schemes2.find((s) => new RegExp(`^${Schemes.payment}\\s+`, "i").test(s)) ?? null;
19102
19182
  }
19103
19183
  var MissingAuthorizationHeaderError, MissingPaymentSchemeError, InvalidCredentialEncodingError;
19104
19184
  var init_Credential = __esm({
@@ -19106,6 +19186,7 @@ var init_Credential = __esm({
19106
19186
  "use strict";
19107
19187
  init_esm2();
19108
19188
  init_Challenge();
19189
+ init_Constants();
19109
19190
  init_PaymentRequest();
19110
19191
  MissingAuthorizationHeaderError = class extends Error {
19111
19192
  name = "MissingAuthorizationHeaderError";
@@ -19136,6 +19217,7 @@ __export(Errors_exports2, {
19136
19217
  ChannelClosedError: () => ChannelClosedError,
19137
19218
  ChannelNotFoundError: () => ChannelNotFoundError,
19138
19219
  DeltaTooSmallError: () => DeltaTooSmallError,
19220
+ Hints: () => Hints,
19139
19221
  InsufficientBalanceError: () => InsufficientBalanceError,
19140
19222
  InvalidChallengeError: () => InvalidChallengeError,
19141
19223
  InvalidPayloadError: () => InvalidPayloadError,
@@ -19150,13 +19232,20 @@ __export(Errors_exports2, {
19150
19232
  SignerMismatchError: () => SignerMismatchError,
19151
19233
  VerificationFailedError: () => VerificationFailedError
19152
19234
  });
19153
- var PaymentError, MalformedCredentialError, InvalidChallengeError, VerificationFailedError, PaymentActionRequiredError, PaymentExpiredError, PaymentRequiredError, InvalidPayloadError, BadRequestError, PaymentInsufficientError, PaymentMethodUnsupportedError, InsufficientBalanceError, InvalidSignatureError, SignerMismatchError, AmountExceedsDepositError, DeltaTooSmallError, ChannelNotFoundError, ChannelClosedError;
19235
+ var Hints, PaymentError, MalformedCredentialError, InvalidChallengeError, VerificationFailedError, PaymentActionRequiredError, PaymentExpiredError, PaymentRequiredError, InvalidPayloadError, BadRequestError, PaymentInsufficientError, PaymentMethodUnsupportedError, InsufficientBalanceError, InvalidSignatureError, SignerMismatchError, AmountExceedsDepositError, DeltaTooSmallError, ChannelNotFoundError, ChannelClosedError;
19154
19236
  var init_Errors2 = __esm({
19155
19237
  "node_modules/mppx/dist/Errors.js"() {
19156
19238
  "use strict";
19239
+ Hints = {
19240
+ 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",
19241
+ 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",
19242
+ 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"
19243
+ };
19157
19244
  PaymentError = class extends Error {
19158
19245
  /** HTTP status code. */
19159
19246
  status = 402;
19247
+ /** Actionable hint for resolving the error (RFC 9457 extension member). */
19248
+ hint;
19160
19249
  /** Converts the error to RFC 9457 Problem Details format. */
19161
19250
  toProblemDetails(challengeId) {
19162
19251
  return {
@@ -19164,6 +19253,7 @@ var init_Errors2 = __esm({
19164
19253
  title: this.title,
19165
19254
  status: this.status,
19166
19255
  detail: this.message,
19256
+ ...this.hint && { hint: this.hint },
19167
19257
  ...challengeId && { challengeId }
19168
19258
  };
19169
19259
  }
@@ -19173,6 +19263,7 @@ var init_Errors2 = __esm({
19173
19263
  title = "Malformed Credential";
19174
19264
  status = 402;
19175
19265
  type = "https://paymentauth.org/problems/malformed-credential";
19266
+ hint = Hints.malformedCredential;
19176
19267
  constructor(options = {}) {
19177
19268
  const { reason } = options;
19178
19269
  super(reason ? `Credential is malformed: ${reason}.` : "Credential is malformed.");
@@ -19221,6 +19312,7 @@ var init_Errors2 = __esm({
19221
19312
  name = "PaymentRequiredError";
19222
19313
  title = "Payment Required";
19223
19314
  type = "https://paymentauth.org/problems/payment-required";
19315
+ hint = Hints.paymentRequired;
19224
19316
  constructor(options = {}) {
19225
19317
  const { description } = options;
19226
19318
  const parts = ["Payment is required"];
@@ -19262,6 +19354,7 @@ var init_Errors2 = __esm({
19262
19354
  title = "Method Unsupported";
19263
19355
  status = 400;
19264
19356
  type = "https://paymentauth.org/problems/method-unsupported";
19357
+ hint = Hints.methodUnsupported;
19265
19358
  constructor(options = {}) {
19266
19359
  const { method } = options;
19267
19360
  super(method ? `Payment method "${method}" is not supported.` : "Payment method is not supported.");
@@ -19394,22 +19487,750 @@ var init_Expires = __esm({
19394
19487
  }
19395
19488
  });
19396
19489
 
19397
- // node_modules/mppx/dist/Mcp.js
19398
- var Mcp_exports = {};
19399
- __export(Mcp_exports, {
19400
- credentialMetaKey: () => credentialMetaKey,
19401
- paymentRequiredCode: () => paymentRequiredCode,
19402
- paymentVerificationFailedCode: () => paymentVerificationFailedCode,
19403
- receiptMetaKey: () => receiptMetaKey
19490
+ // node_modules/viem/_esm/utils/data/isHex.js
19491
+ function isHex(value, { strict = true } = {}) {
19492
+ if (!value)
19493
+ return false;
19494
+ if (typeof value !== "string")
19495
+ return false;
19496
+ return strict ? /^0x[0-9a-fA-F]*$/.test(value) : value.startsWith("0x");
19497
+ }
19498
+ var init_isHex = __esm({
19499
+ "node_modules/viem/_esm/utils/data/isHex.js"() {
19500
+ "use strict";
19501
+ }
19404
19502
  });
19405
- var paymentRequiredCode, paymentVerificationFailedCode, credentialMetaKey, receiptMetaKey;
19406
- var init_Mcp = __esm({
19407
- "node_modules/mppx/dist/Mcp.js"() {
19503
+
19504
+ // node_modules/viem/_esm/utils/data/size.js
19505
+ function size3(value) {
19506
+ if (isHex(value, { strict: false }))
19507
+ return Math.ceil((value.length - 2) / 2);
19508
+ return value.length;
19509
+ }
19510
+ var init_size = __esm({
19511
+ "node_modules/viem/_esm/utils/data/size.js"() {
19408
19512
  "use strict";
19409
- paymentRequiredCode = -32042;
19410
- paymentVerificationFailedCode = -32043;
19411
- credentialMetaKey = "org.paymentauth/credential";
19412
- receiptMetaKey = "org.paymentauth/receipt";
19513
+ init_isHex();
19514
+ }
19515
+ });
19516
+
19517
+ // node_modules/viem/_esm/errors/version.js
19518
+ var version3;
19519
+ var init_version2 = __esm({
19520
+ "node_modules/viem/_esm/errors/version.js"() {
19521
+ "use strict";
19522
+ version3 = "2.54.4";
19523
+ }
19524
+ });
19525
+
19526
+ // node_modules/viem/_esm/errors/base.js
19527
+ function walk2(err, fn) {
19528
+ if (fn?.(err))
19529
+ return err;
19530
+ if (err && typeof err === "object" && "cause" in err && err.cause !== void 0)
19531
+ return walk2(err.cause, fn);
19532
+ return fn ? null : err;
19533
+ }
19534
+ var errorConfig, BaseError3;
19535
+ var init_base = __esm({
19536
+ "node_modules/viem/_esm/errors/base.js"() {
19537
+ "use strict";
19538
+ init_version2();
19539
+ errorConfig = {
19540
+ getDocsUrl: ({ docsBaseUrl, docsPath = "", docsSlug }) => docsPath ? `${docsBaseUrl ?? "https://viem.sh"}${docsPath}${docsSlug ? `#${docsSlug}` : ""}` : void 0,
19541
+ version: `viem@${version3}`
19542
+ };
19543
+ BaseError3 = class _BaseError extends Error {
19544
+ constructor(shortMessage, args = {}) {
19545
+ const details = (() => {
19546
+ if (args.cause instanceof _BaseError)
19547
+ return args.cause.details;
19548
+ if (args.cause?.message)
19549
+ return args.cause.message;
19550
+ return args.details;
19551
+ })();
19552
+ const docsPath = (() => {
19553
+ if (args.cause instanceof _BaseError)
19554
+ return args.cause.docsPath || args.docsPath;
19555
+ return args.docsPath;
19556
+ })();
19557
+ const docsUrl = errorConfig.getDocsUrl?.({ ...args, docsPath });
19558
+ const message = [
19559
+ shortMessage || "An error occurred.",
19560
+ "",
19561
+ ...args.metaMessages ? [...args.metaMessages, ""] : [],
19562
+ ...docsUrl ? [`Docs: ${docsUrl}`] : [],
19563
+ ...details ? [`Details: ${details}`] : [],
19564
+ ...errorConfig.version ? [`Version: ${errorConfig.version}`] : []
19565
+ ].join("\n");
19566
+ super(message, args.cause ? { cause: args.cause } : void 0);
19567
+ Object.defineProperty(this, "details", {
19568
+ enumerable: true,
19569
+ configurable: true,
19570
+ writable: true,
19571
+ value: void 0
19572
+ });
19573
+ Object.defineProperty(this, "docsPath", {
19574
+ enumerable: true,
19575
+ configurable: true,
19576
+ writable: true,
19577
+ value: void 0
19578
+ });
19579
+ Object.defineProperty(this, "metaMessages", {
19580
+ enumerable: true,
19581
+ configurable: true,
19582
+ writable: true,
19583
+ value: void 0
19584
+ });
19585
+ Object.defineProperty(this, "shortMessage", {
19586
+ enumerable: true,
19587
+ configurable: true,
19588
+ writable: true,
19589
+ value: void 0
19590
+ });
19591
+ Object.defineProperty(this, "version", {
19592
+ enumerable: true,
19593
+ configurable: true,
19594
+ writable: true,
19595
+ value: void 0
19596
+ });
19597
+ Object.defineProperty(this, "name", {
19598
+ enumerable: true,
19599
+ configurable: true,
19600
+ writable: true,
19601
+ value: "BaseError"
19602
+ });
19603
+ this.details = details;
19604
+ this.docsPath = docsPath;
19605
+ this.metaMessages = args.metaMessages;
19606
+ this.name = args.name ?? this.name;
19607
+ this.shortMessage = shortMessage;
19608
+ this.version = version3;
19609
+ }
19610
+ walk(fn) {
19611
+ return walk2(this, fn);
19612
+ }
19613
+ };
19614
+ }
19615
+ });
19616
+
19617
+ // node_modules/viem/_esm/errors/data.js
19618
+ var SizeExceedsPaddingSizeError3;
19619
+ var init_data = __esm({
19620
+ "node_modules/viem/_esm/errors/data.js"() {
19621
+ "use strict";
19622
+ init_base();
19623
+ SizeExceedsPaddingSizeError3 = class extends BaseError3 {
19624
+ constructor({ size: size4, targetSize, type }) {
19625
+ super(`${type.charAt(0).toUpperCase()}${type.slice(1).toLowerCase()} size (${size4}) exceeds padding size (${targetSize}).`, { name: "SizeExceedsPaddingSizeError" });
19626
+ }
19627
+ };
19628
+ }
19629
+ });
19630
+
19631
+ // node_modules/viem/_esm/utils/data/pad.js
19632
+ function pad3(hexOrBytes, { dir, size: size4 = 32 } = {}) {
19633
+ if (typeof hexOrBytes === "string")
19634
+ return padHex(hexOrBytes, { dir, size: size4 });
19635
+ return padBytes(hexOrBytes, { dir, size: size4 });
19636
+ }
19637
+ function padHex(hex_, { dir, size: size4 = 32 } = {}) {
19638
+ if (size4 === null)
19639
+ return hex_;
19640
+ const hex3 = hex_.replace("0x", "");
19641
+ if (hex3.length > size4 * 2)
19642
+ throw new SizeExceedsPaddingSizeError3({
19643
+ size: Math.ceil(hex3.length / 2),
19644
+ targetSize: size4,
19645
+ type: "hex"
19646
+ });
19647
+ return `0x${hex3[dir === "right" ? "padEnd" : "padStart"](size4 * 2, "0")}`;
19648
+ }
19649
+ function padBytes(bytes, { dir, size: size4 = 32 } = {}) {
19650
+ if (size4 === null)
19651
+ return bytes;
19652
+ if (bytes.length > size4)
19653
+ throw new SizeExceedsPaddingSizeError3({
19654
+ size: bytes.length,
19655
+ targetSize: size4,
19656
+ type: "bytes"
19657
+ });
19658
+ const paddedBytes = new Uint8Array(size4);
19659
+ for (let i = 0; i < size4; i++) {
19660
+ const padEnd = dir === "right";
19661
+ paddedBytes[padEnd ? i : size4 - i - 1] = bytes[padEnd ? i : bytes.length - i - 1];
19662
+ }
19663
+ return paddedBytes;
19664
+ }
19665
+ var init_pad = __esm({
19666
+ "node_modules/viem/_esm/utils/data/pad.js"() {
19667
+ "use strict";
19668
+ init_data();
19669
+ }
19670
+ });
19671
+
19672
+ // node_modules/viem/_esm/errors/encoding.js
19673
+ var IntegerOutOfRangeError2, SizeOverflowError3;
19674
+ var init_encoding = __esm({
19675
+ "node_modules/viem/_esm/errors/encoding.js"() {
19676
+ "use strict";
19677
+ init_base();
19678
+ IntegerOutOfRangeError2 = class extends BaseError3 {
19679
+ constructor({ max, min, signed, size: size4, value }) {
19680
+ super(`Number "${value}" is not in safe ${size4 ? `${size4 * 8}-bit ${signed ? "signed" : "unsigned"} ` : ""}integer range ${max ? `(${min} to ${max})` : `(above ${min})`}`, { name: "IntegerOutOfRangeError" });
19681
+ }
19682
+ };
19683
+ SizeOverflowError3 = class extends BaseError3 {
19684
+ constructor({ givenSize, maxSize }) {
19685
+ super(`Size cannot exceed ${maxSize} bytes. Given size: ${givenSize} bytes.`, { name: "SizeOverflowError" });
19686
+ }
19687
+ };
19688
+ }
19689
+ });
19690
+
19691
+ // node_modules/viem/_esm/utils/encoding/fromHex.js
19692
+ function assertSize3(hexOrBytes, { size: size4 }) {
19693
+ if (size3(hexOrBytes) > size4)
19694
+ throw new SizeOverflowError3({
19695
+ givenSize: size3(hexOrBytes),
19696
+ maxSize: size4
19697
+ });
19698
+ }
19699
+ var init_fromHex = __esm({
19700
+ "node_modules/viem/_esm/utils/encoding/fromHex.js"() {
19701
+ "use strict";
19702
+ init_encoding();
19703
+ init_size();
19704
+ }
19705
+ });
19706
+
19707
+ // node_modules/viem/_esm/utils/encoding/toHex.js
19708
+ function toHex3(value, opts = {}) {
19709
+ if (typeof value === "number" || typeof value === "bigint")
19710
+ return numberToHex(value, opts);
19711
+ if (typeof value === "string") {
19712
+ return stringToHex(value, opts);
19713
+ }
19714
+ if (typeof value === "boolean")
19715
+ return boolToHex(value, opts);
19716
+ return bytesToHex(value, opts);
19717
+ }
19718
+ function boolToHex(value, opts = {}) {
19719
+ const hex3 = `0x${Number(value)}`;
19720
+ if (typeof opts.size === "number") {
19721
+ assertSize3(hex3, { size: opts.size });
19722
+ return pad3(hex3, { size: opts.size });
19723
+ }
19724
+ return hex3;
19725
+ }
19726
+ function bytesToHex(value, opts = {}) {
19727
+ let string4 = "";
19728
+ for (let i = 0; i < value.length; i++) {
19729
+ string4 += hexes2[value[i]];
19730
+ }
19731
+ const hex3 = `0x${string4}`;
19732
+ if (typeof opts.size === "number") {
19733
+ assertSize3(hex3, { size: opts.size });
19734
+ return pad3(hex3, { dir: "right", size: opts.size });
19735
+ }
19736
+ return hex3;
19737
+ }
19738
+ function numberToHex(value_, opts = {}) {
19739
+ const { signed, size: size4 } = opts;
19740
+ const value = BigInt(value_);
19741
+ let maxValue;
19742
+ if (size4) {
19743
+ if (signed)
19744
+ maxValue = (1n << BigInt(size4) * 8n - 1n) - 1n;
19745
+ else
19746
+ maxValue = 2n ** (BigInt(size4) * 8n) - 1n;
19747
+ } else if (typeof value_ === "number") {
19748
+ maxValue = BigInt(Number.MAX_SAFE_INTEGER);
19749
+ }
19750
+ const minValue = typeof maxValue === "bigint" && signed ? -maxValue - 1n : 0;
19751
+ if (maxValue && value > maxValue || value < minValue) {
19752
+ const suffix = typeof value_ === "bigint" ? "n" : "";
19753
+ throw new IntegerOutOfRangeError2({
19754
+ max: maxValue ? `${maxValue}${suffix}` : void 0,
19755
+ min: `${minValue}${suffix}`,
19756
+ signed,
19757
+ size: size4,
19758
+ value: `${value_}${suffix}`
19759
+ });
19760
+ }
19761
+ const hex3 = `0x${(signed && value < 0 ? (1n << BigInt(size4 * 8)) + BigInt(value) : value).toString(16)}`;
19762
+ if (size4)
19763
+ return pad3(hex3, { size: size4 });
19764
+ return hex3;
19765
+ }
19766
+ function stringToHex(value_, opts = {}) {
19767
+ const value = encoder4.encode(value_);
19768
+ return bytesToHex(value, opts);
19769
+ }
19770
+ var hexes2, encoder4;
19771
+ var init_toHex = __esm({
19772
+ "node_modules/viem/_esm/utils/encoding/toHex.js"() {
19773
+ "use strict";
19774
+ init_encoding();
19775
+ init_pad();
19776
+ init_fromHex();
19777
+ hexes2 = /* @__PURE__ */ Array.from({ length: 256 }, (_v, i) => i.toString(16).padStart(2, "0"));
19778
+ encoder4 = /* @__PURE__ */ new TextEncoder();
19779
+ }
19780
+ });
19781
+
19782
+ // node_modules/viem/_esm/utils/encoding/toBytes.js
19783
+ function toBytes4(value, opts = {}) {
19784
+ if (typeof value === "number" || typeof value === "bigint")
19785
+ return numberToBytes(value, opts);
19786
+ if (typeof value === "boolean")
19787
+ return boolToBytes(value, opts);
19788
+ if (isHex(value))
19789
+ return hexToBytes(value, opts);
19790
+ return stringToBytes(value, opts);
19791
+ }
19792
+ function boolToBytes(value, opts = {}) {
19793
+ const bytes = new Uint8Array(1);
19794
+ bytes[0] = Number(value);
19795
+ if (typeof opts.size === "number") {
19796
+ assertSize3(bytes, { size: opts.size });
19797
+ return pad3(bytes, { size: opts.size });
19798
+ }
19799
+ return bytes;
19800
+ }
19801
+ function charCodeToBase162(char) {
19802
+ if (char >= charCodeMap2.zero && char <= charCodeMap2.nine)
19803
+ return char - charCodeMap2.zero;
19804
+ if (char >= charCodeMap2.A && char <= charCodeMap2.F)
19805
+ return char - (charCodeMap2.A - 10);
19806
+ if (char >= charCodeMap2.a && char <= charCodeMap2.f)
19807
+ return char - (charCodeMap2.a - 10);
19808
+ return void 0;
19809
+ }
19810
+ function hexToBytes(hex_, opts = {}) {
19811
+ let hex3 = hex_;
19812
+ if (opts.size) {
19813
+ assertSize3(hex3, { size: opts.size });
19814
+ hex3 = pad3(hex3, { dir: "right", size: opts.size });
19815
+ }
19816
+ let hexString = hex3.slice(2);
19817
+ if (hexString.length % 2)
19818
+ hexString = `0${hexString}`;
19819
+ const length = hexString.length / 2;
19820
+ const bytes = new Uint8Array(length);
19821
+ for (let index = 0, j = 0; index < length; index++) {
19822
+ const nibbleLeft = charCodeToBase162(hexString.charCodeAt(j++));
19823
+ const nibbleRight = charCodeToBase162(hexString.charCodeAt(j++));
19824
+ if (nibbleLeft === void 0 || nibbleRight === void 0) {
19825
+ throw new BaseError3(`Invalid byte sequence ("${hexString[j - 2]}${hexString[j - 1]}" in "${hexString}").`);
19826
+ }
19827
+ bytes[index] = nibbleLeft * 16 + nibbleRight;
19828
+ }
19829
+ return bytes;
19830
+ }
19831
+ function numberToBytes(value, opts) {
19832
+ const hex3 = numberToHex(value, opts);
19833
+ return hexToBytes(hex3);
19834
+ }
19835
+ function stringToBytes(value, opts = {}) {
19836
+ const bytes = encoder5.encode(value);
19837
+ if (typeof opts.size === "number") {
19838
+ assertSize3(bytes, { size: opts.size });
19839
+ return pad3(bytes, { dir: "right", size: opts.size });
19840
+ }
19841
+ return bytes;
19842
+ }
19843
+ var encoder5, charCodeMap2;
19844
+ var init_toBytes = __esm({
19845
+ "node_modules/viem/_esm/utils/encoding/toBytes.js"() {
19846
+ "use strict";
19847
+ init_base();
19848
+ init_isHex();
19849
+ init_pad();
19850
+ init_fromHex();
19851
+ init_toHex();
19852
+ encoder5 = /* @__PURE__ */ new TextEncoder();
19853
+ charCodeMap2 = {
19854
+ zero: 48,
19855
+ nine: 57,
19856
+ A: 65,
19857
+ F: 70,
19858
+ a: 97,
19859
+ f: 102
19860
+ };
19861
+ }
19862
+ });
19863
+
19864
+ // node_modules/viem/_esm/utils/hash/keccak256.js
19865
+ function keccak2562(value, to_) {
19866
+ const to = to_ || "hex";
19867
+ const bytes = keccak_256(isHex(value, { strict: false }) ? toBytes4(value) : value);
19868
+ if (to === "bytes")
19869
+ return bytes;
19870
+ return toHex3(bytes);
19871
+ }
19872
+ var init_keccak256 = __esm({
19873
+ "node_modules/viem/_esm/utils/hash/keccak256.js"() {
19874
+ "use strict";
19875
+ init_sha3();
19876
+ init_isHex();
19877
+ init_toBytes();
19878
+ init_toHex();
19879
+ }
19880
+ });
19881
+
19882
+ // node_modules/viem/_esm/errors/address.js
19883
+ var InvalidAddressError2;
19884
+ var init_address = __esm({
19885
+ "node_modules/viem/_esm/errors/address.js"() {
19886
+ "use strict";
19887
+ init_base();
19888
+ InvalidAddressError2 = class extends BaseError3 {
19889
+ constructor({ address: address3 }) {
19890
+ super(`Address "${address3}" is invalid.`, {
19891
+ metaMessages: [
19892
+ "- Address must be a hex value of 20 bytes (40 hex characters).",
19893
+ "- Address must match its checksum counterpart."
19894
+ ],
19895
+ name: "InvalidAddressError"
19896
+ });
19897
+ }
19898
+ };
19899
+ }
19900
+ });
19901
+
19902
+ // node_modules/viem/_esm/utils/lru.js
19903
+ var LruMap2;
19904
+ var init_lru2 = __esm({
19905
+ "node_modules/viem/_esm/utils/lru.js"() {
19906
+ "use strict";
19907
+ LruMap2 = class extends Map {
19908
+ constructor(size4) {
19909
+ super();
19910
+ Object.defineProperty(this, "maxSize", {
19911
+ enumerable: true,
19912
+ configurable: true,
19913
+ writable: true,
19914
+ value: void 0
19915
+ });
19916
+ this.maxSize = size4;
19917
+ }
19918
+ get(key) {
19919
+ const value = super.get(key);
19920
+ if (super.has(key)) {
19921
+ super.delete(key);
19922
+ super.set(key, value);
19923
+ }
19924
+ return value;
19925
+ }
19926
+ set(key, value) {
19927
+ if (super.has(key))
19928
+ super.delete(key);
19929
+ super.set(key, value);
19930
+ if (this.maxSize && this.size > this.maxSize) {
19931
+ const firstKey = super.keys().next().value;
19932
+ if (firstKey !== void 0)
19933
+ super.delete(firstKey);
19934
+ }
19935
+ return this;
19936
+ }
19937
+ };
19938
+ }
19939
+ });
19940
+
19941
+ // node_modules/viem/_esm/utils/address/getAddress.js
19942
+ function checksumAddress(address_, chainId) {
19943
+ if (checksumAddressCache.has(`${address_}.${chainId}`))
19944
+ return checksumAddressCache.get(`${address_}.${chainId}`);
19945
+ const hexAddress = chainId ? `${chainId}${address_.toLowerCase()}` : address_.substring(2).toLowerCase();
19946
+ const hash3 = keccak2562(stringToBytes(hexAddress), "bytes");
19947
+ const address3 = (chainId ? hexAddress.substring(`${chainId}0x`.length) : hexAddress).split("");
19948
+ for (let i = 0; i < 40; i += 2) {
19949
+ if (hash3[i >> 1] >> 4 >= 8 && address3[i]) {
19950
+ address3[i] = address3[i].toUpperCase();
19951
+ }
19952
+ if ((hash3[i >> 1] & 15) >= 8 && address3[i + 1]) {
19953
+ address3[i + 1] = address3[i + 1].toUpperCase();
19954
+ }
19955
+ }
19956
+ const result = `0x${address3.join("")}`;
19957
+ checksumAddressCache.set(`${address_}.${chainId}`, result);
19958
+ return result;
19959
+ }
19960
+ function getAddress(address3, chainId) {
19961
+ if (!isAddress(address3, { strict: false }))
19962
+ throw new InvalidAddressError2({ address: address3 });
19963
+ return checksumAddress(address3, chainId);
19964
+ }
19965
+ var checksumAddressCache;
19966
+ var init_getAddress = __esm({
19967
+ "node_modules/viem/_esm/utils/address/getAddress.js"() {
19968
+ "use strict";
19969
+ init_address();
19970
+ init_toBytes();
19971
+ init_keccak256();
19972
+ init_lru2();
19973
+ init_isAddress();
19974
+ checksumAddressCache = /* @__PURE__ */ new LruMap2(8192);
19975
+ }
19976
+ });
19977
+
19978
+ // node_modules/viem/_esm/utils/address/isAddress.js
19979
+ function isAddress(address3, options) {
19980
+ const { strict = true } = options ?? {};
19981
+ const cacheKey = `${address3}.${strict}`;
19982
+ if (isAddressCache.has(cacheKey))
19983
+ return isAddressCache.get(cacheKey);
19984
+ const result = (() => {
19985
+ if (!addressRegex2.test(address3))
19986
+ return false;
19987
+ if (address3.toLowerCase() === address3)
19988
+ return true;
19989
+ if (strict)
19990
+ return checksumAddress(address3) === address3;
19991
+ return true;
19992
+ })();
19993
+ isAddressCache.set(cacheKey, result);
19994
+ return result;
19995
+ }
19996
+ var addressRegex2, isAddressCache;
19997
+ var init_isAddress = __esm({
19998
+ "node_modules/viem/_esm/utils/address/isAddress.js"() {
19999
+ "use strict";
20000
+ init_lru2();
20001
+ init_getAddress();
20002
+ addressRegex2 = /^0x[a-fA-F0-9]{40}$/;
20003
+ isAddressCache = /* @__PURE__ */ new LruMap2(8192);
20004
+ }
20005
+ });
20006
+
20007
+ // node_modules/viem/_esm/errors/unit.js
20008
+ var InvalidDecimalNumberError;
20009
+ var init_unit = __esm({
20010
+ "node_modules/viem/_esm/errors/unit.js"() {
20011
+ "use strict";
20012
+ init_base();
20013
+ InvalidDecimalNumberError = class extends BaseError3 {
20014
+ constructor({ value }) {
20015
+ super(`Number \`${value}\` is not a valid decimal number.`, {
20016
+ name: "InvalidDecimalNumberError"
20017
+ });
20018
+ }
20019
+ };
20020
+ }
20021
+ });
20022
+
20023
+ // node_modules/viem/_esm/utils/unit/parseUnits.js
20024
+ function parseUnits(value, decimals) {
20025
+ if (!/^(-?)([0-9]*)\.?([0-9]*)$/.test(value))
20026
+ throw new InvalidDecimalNumberError({ value });
20027
+ let [integer2, fraction = "0"] = value.split(".");
20028
+ const negative = integer2.startsWith("-");
20029
+ if (negative)
20030
+ integer2 = integer2.slice(1);
20031
+ fraction = fraction.replace(/(0+)$/, "");
20032
+ if (decimals === 0) {
20033
+ if (Math.round(Number(`.${fraction}`)) === 1)
20034
+ integer2 = `${BigInt(integer2) + 1n}`;
20035
+ fraction = "";
20036
+ } else if (fraction.length > decimals) {
20037
+ const [left, unit, right] = [
20038
+ fraction.slice(0, decimals - 1),
20039
+ fraction.slice(decimals - 1, decimals),
20040
+ fraction.slice(decimals)
20041
+ ];
20042
+ const rounded = Math.round(Number(`${unit}.${right}`));
20043
+ if (rounded > 9)
20044
+ fraction = `${BigInt(left) + BigInt(1)}0`.padStart(left.length + 1, "0");
20045
+ else
20046
+ fraction = `${left}${rounded}`;
20047
+ if (fraction.length > decimals) {
20048
+ fraction = fraction.slice(1);
20049
+ integer2 = `${BigInt(integer2) + 1n}`;
20050
+ }
20051
+ fraction = fraction.slice(0, decimals);
20052
+ } else {
20053
+ fraction = fraction.padEnd(decimals, "0");
20054
+ }
20055
+ return BigInt(`${negative ? "-" : ""}${integer2}${fraction}`);
20056
+ }
20057
+ var init_parseUnits = __esm({
20058
+ "node_modules/viem/_esm/utils/unit/parseUnits.js"() {
20059
+ "use strict";
20060
+ init_unit();
20061
+ }
20062
+ });
20063
+
20064
+ // node_modules/viem/_esm/index.js
20065
+ var init_esm3 = __esm({
20066
+ "node_modules/viem/_esm/index.js"() {
20067
+ "use strict";
20068
+ init_getAddress();
20069
+ init_parseUnits();
20070
+ }
20071
+ });
20072
+
20073
+ // node_modules/mppx/dist/x402/Assets.js
20074
+ var Assets_exports = {};
20075
+ __export(Assets_exports, {
20076
+ base: () => base,
20077
+ baseSepolia: () => baseSepolia,
20078
+ define: () => define,
20079
+ fromToken: () => fromToken,
20080
+ isAsset: () => isAsset,
20081
+ isRawAddress: () => isRawAddress,
20082
+ isToken: () => isToken,
20083
+ matches: () => matches,
20084
+ resolve: () => resolve,
20085
+ toChainId: () => toChainId,
20086
+ toNetwork: () => toNetwork
20087
+ });
20088
+ function define(parameters) {
20089
+ return {
20090
+ [knownAsset]: true,
20091
+ address: parameters.address,
20092
+ decimals: parameters.decimals,
20093
+ network: parameters.network,
20094
+ transfer: parameters.transfer
20095
+ };
20096
+ }
20097
+ function fromToken(token, parameters) {
20098
+ const resolved = token(parameters.chainId);
20099
+ return define({
20100
+ address: resolved.address,
20101
+ decimals: resolved.decimals,
20102
+ network: toNetwork(parameters.chainId),
20103
+ transfer: withTokenDefaults(parameters.transfer, resolved)
20104
+ });
20105
+ }
20106
+ function isAsset(value) {
20107
+ if (typeof value !== "object" || value === null)
20108
+ return false;
20109
+ return value[knownAsset] === true;
20110
+ }
20111
+ function isToken(value) {
20112
+ return typeof value === "function" && typeof value.addresses === "object" && typeof value.decimals === "number";
20113
+ }
20114
+ function isRawAddress(currency) {
20115
+ return typeof currency === "string";
20116
+ }
20117
+ function resolve(currency, network) {
20118
+ if (isAsset(currency)) {
20119
+ if (currency.network !== network)
20120
+ return void 0;
20121
+ return {
20122
+ address: currency.address,
20123
+ decimals: currency.decimals,
20124
+ transfer: currency.transfer
20125
+ };
20126
+ }
20127
+ if (isToken(currency)) {
20128
+ const address3 = currency.addresses[toChainId(network)];
20129
+ if (!address3)
20130
+ return void 0;
20131
+ return {
20132
+ address: address3,
20133
+ decimals: currency.decimals,
20134
+ name: currency.name
20135
+ };
20136
+ }
20137
+ return {
20138
+ address: currency
20139
+ };
20140
+ }
20141
+ function matches(currency, acceptedCurrency, network) {
20142
+ const resolved = resolve(currency, network);
20143
+ if (!resolved)
20144
+ return false;
20145
+ return getAddress(resolved.address) === getAddress(acceptedCurrency);
20146
+ }
20147
+ function toNetwork(chainId) {
20148
+ return `eip155:${chainId}`;
20149
+ }
20150
+ function toChainId(network) {
20151
+ return Number(network.slice("eip155:".length));
20152
+ }
20153
+ function withTokenDefaults(transfer, token) {
20154
+ if (transfer.type !== "eip3009")
20155
+ return transfer;
20156
+ if (transfer.name)
20157
+ return { ...transfer, name: transfer.name };
20158
+ if (!token.name)
20159
+ throw new Error("EIP-3009 token assets require a token name.");
20160
+ return {
20161
+ ...transfer,
20162
+ name: token.name
20163
+ };
20164
+ }
20165
+ var knownAsset, base, baseSepolia;
20166
+ var init_Assets = __esm({
20167
+ "node_modules/mppx/dist/x402/Assets.js"() {
20168
+ "use strict";
20169
+ init_esm3();
20170
+ knownAsset = /* @__PURE__ */ Symbol("mppx.x402.asset");
20171
+ base = {
20172
+ USDC: define({
20173
+ address: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
20174
+ decimals: 6,
20175
+ network: "eip155:8453",
20176
+ transfer: {
20177
+ // USDC's EIP-712 domain name differs between Base and Base Sepolia.
20178
+ name: "USD Coin",
20179
+ type: "eip3009",
20180
+ version: "2"
20181
+ }
20182
+ })
20183
+ };
20184
+ baseSepolia = {
20185
+ USDC: define({
20186
+ address: "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
20187
+ decimals: 6,
20188
+ network: "eip155:84532",
20189
+ transfer: {
20190
+ // Base Sepolia test USDC signs with the shorter EIP-712 domain name.
20191
+ name: "USDC",
20192
+ type: "eip3009",
20193
+ version: "2"
20194
+ }
20195
+ })
20196
+ };
20197
+ }
20198
+ });
20199
+
20200
+ // node_modules/mppx/dist/evm/Assets.js
20201
+ var Assets_exports2 = {};
20202
+ __export(Assets_exports2, {
20203
+ base: () => base,
20204
+ baseSepolia: () => baseSepolia,
20205
+ define: () => define,
20206
+ fromToken: () => fromToken,
20207
+ isAsset: () => isAsset,
20208
+ isRawAddress: () => isRawAddress,
20209
+ isToken: () => isToken,
20210
+ matches: () => matches,
20211
+ resolve: () => resolve,
20212
+ toChainId: () => toChainId,
20213
+ toNetwork: () => toNetwork
20214
+ });
20215
+ var init_Assets2 = __esm({
20216
+ "node_modules/mppx/dist/evm/Assets.js"() {
20217
+ "use strict";
20218
+ init_Assets();
20219
+ }
20220
+ });
20221
+
20222
+ // node_modules/mppx/dist/evm/Chains.js
20223
+ var Chains_exports = {};
20224
+ __export(Chains_exports, {
20225
+ base: () => base2,
20226
+ baseSepolia: () => baseSepolia2
20227
+ });
20228
+ var base2, baseSepolia2;
20229
+ var init_Chains = __esm({
20230
+ "node_modules/mppx/dist/evm/Chains.js"() {
20231
+ "use strict";
20232
+ base2 = 8453;
20233
+ baseSepolia2 = 84532;
19413
20234
  }
19414
20235
  });
19415
20236
 
@@ -19424,21 +20245,24 @@ function from6(method) {
19424
20245
  return method;
19425
20246
  }
19426
20247
  function toClient(method, options) {
19427
- const { context, createCredential } = options;
20248
+ const { canHandleChallenge, context, createCredential } = options;
19428
20249
  return {
19429
20250
  ...method,
20251
+ canHandleChallenge,
19430
20252
  context,
19431
20253
  createCredential
19432
20254
  };
19433
20255
  }
19434
20256
  function toServer(method, options) {
19435
- const { authorize, defaults, extensions, html, request, respond, stableBinding, transport, verify: verify3 } = options;
20257
+ const { alias, authorize, defaults, extensions, html, preflight, request, respond, stableBinding, transport, verify: verify3 } = options;
19436
20258
  return {
19437
20259
  ...method,
20260
+ alias,
19438
20261
  authorize,
19439
20262
  defaults,
19440
20263
  extensions,
19441
20264
  html,
20265
+ preflight,
19442
20266
  request,
19443
20267
  respond,
19444
20268
  stableBinding,
@@ -19452,6 +20276,218 @@ var init_Method = __esm({
19452
20276
  }
19453
20277
  });
19454
20278
 
20279
+ // node_modules/mppx/dist/evm/Types.js
20280
+ var Types_exports = {};
20281
+ __export(Types_exports, {
20282
+ AuthorizationConfigSchema: () => AuthorizationConfigSchema,
20283
+ AuthorizationPayloadSchema: () => AuthorizationPayloadSchema,
20284
+ ChargePayloadSchema: () => ChargePayloadSchema,
20285
+ ChargeRequestInputSchema: () => ChargeRequestInputSchema,
20286
+ ChargeRequestSchema: () => ChargeRequestSchema,
20287
+ MethodDetailsSchema: () => MethodDetailsSchema,
20288
+ authorizationDomain: () => authorizationDomain,
20289
+ authorizationTypes: () => authorizationTypes,
20290
+ challengeHash: () => challengeHash,
20291
+ chargeIntent: () => chargeIntent,
20292
+ credentialTypes: () => credentialTypes,
20293
+ eip3009: () => eip3009,
20294
+ evmNetworkPrefix: () => evmNetworkPrefix,
20295
+ networkOf: () => networkOf,
20296
+ paymentMethod: () => paymentMethod,
20297
+ toSource: () => toSource
20298
+ });
20299
+ function authorizationDomain(parameters) {
20300
+ return {
20301
+ chainId: parameters.chainId,
20302
+ name: parameters.authorization.name,
20303
+ verifyingContract: parameters.currency,
20304
+ version: parameters.authorization.version
20305
+ };
20306
+ }
20307
+ function challengeHash(challenge) {
20308
+ return Hash_exports.keccak256(Bytes_exports.fromString(`${challenge.id}${challenge.realm}`), {
20309
+ as: "Hex"
20310
+ });
20311
+ }
20312
+ function networkOf(chainId) {
20313
+ return `${evmNetworkPrefix}${chainId}`;
20314
+ }
20315
+ function toSource(parameters) {
20316
+ return `did:pkh:eip155:${parameters.chainId}:${parameters.address}`;
20317
+ }
20318
+ var paymentMethod, chargeIntent, evmNetworkPrefix, eip3009, credentialTypes, atomicAmount, AuthorizationConfigSchema, MethodDetailsSchema, ChargeRequestSchema, ChargeRequestInputSchema, AuthorizationPayloadSchema, ChargePayloadSchema, authorizationTypes;
20319
+ var init_Types = __esm({
20320
+ "node_modules/mppx/dist/evm/Types.js"() {
20321
+ "use strict";
20322
+ init_esm2();
20323
+ init_zod();
20324
+ paymentMethod = "evm";
20325
+ chargeIntent = "charge";
20326
+ evmNetworkPrefix = "eip155:";
20327
+ eip3009 = "eip3009";
20328
+ credentialTypes = ["authorization"];
20329
+ atomicAmount = string2().check(_regex(/^\d+$/, "Invalid atomic amount"));
20330
+ AuthorizationConfigSchema = object({
20331
+ name: string2().check(_minLength(1)),
20332
+ version: string2().check(_minLength(1))
20333
+ });
20334
+ MethodDetailsSchema = object({
20335
+ chainId: number2(),
20336
+ credentialTypes: optional(array(_enum2(credentialTypes)).check(_minLength(1))),
20337
+ decimals: optional(number2()),
20338
+ permit2Address: optional(address()),
20339
+ splits: optional(array(object({
20340
+ amount: atomicAmount,
20341
+ recipient: address()
20342
+ })))
20343
+ });
20344
+ ChargeRequestSchema = object({
20345
+ amount: atomicAmount,
20346
+ currency: address(),
20347
+ description: optional(string2()),
20348
+ externalId: optional(string2()),
20349
+ methodDetails: MethodDetailsSchema,
20350
+ recipient: address()
20351
+ });
20352
+ ChargeRequestInputSchema = object({
20353
+ amount: amount(),
20354
+ chainId: number2(),
20355
+ currency: address(),
20356
+ credentialTypes: optional(array(_enum2(credentialTypes)).check(_minLength(1))),
20357
+ decimals: number2(),
20358
+ description: optional(string2()),
20359
+ externalId: optional(string2()),
20360
+ permit2Address: optional(address()),
20361
+ recipient: address(),
20362
+ splits: optional(array(object({
20363
+ amount: atomicAmount,
20364
+ recipient: address()
20365
+ })))
20366
+ });
20367
+ AuthorizationPayloadSchema = object({
20368
+ from: address(),
20369
+ nonce: hash2(),
20370
+ signature: signature(),
20371
+ to: address(),
20372
+ type: literal("authorization"),
20373
+ validAfter: atomicAmount,
20374
+ validBefore: atomicAmount,
20375
+ value: atomicAmount
20376
+ });
20377
+ ChargePayloadSchema = AuthorizationPayloadSchema;
20378
+ authorizationTypes = {
20379
+ TransferWithAuthorization: [
20380
+ { name: "from", type: "address" },
20381
+ { name: "to", type: "address" },
20382
+ { name: "value", type: "uint256" },
20383
+ { name: "validAfter", type: "uint256" },
20384
+ { name: "validBefore", type: "uint256" },
20385
+ { name: "nonce", type: "bytes32" }
20386
+ ]
20387
+ };
20388
+ }
20389
+ });
20390
+
20391
+ // node_modules/mppx/dist/evm/Methods.js
20392
+ var Methods_exports = {};
20393
+ __export(Methods_exports, {
20394
+ charge: () => charge
20395
+ });
20396
+ var charge;
20397
+ var init_Methods = __esm({
20398
+ "node_modules/mppx/dist/evm/Methods.js"() {
20399
+ "use strict";
20400
+ init_esm3();
20401
+ init_Method();
20402
+ init_zod();
20403
+ init_Types();
20404
+ charge = from6({
20405
+ name: paymentMethod,
20406
+ intent: chargeIntent,
20407
+ schema: {
20408
+ credential: {
20409
+ payload: ChargePayloadSchema
20410
+ },
20411
+ request: pipe(ChargeRequestInputSchema, transform(({ amount: amount2, chainId, credentialTypes: credentialTypes2 = ["authorization"], currency, decimals, permit2Address, recipient, splits, ...request }) => ({
20412
+ ...request,
20413
+ amount: parseUnits(amount2, decimals).toString(),
20414
+ currency: getAddress(currency),
20415
+ methodDetails: {
20416
+ chainId,
20417
+ credentialTypes: credentialTypes2,
20418
+ decimals,
20419
+ ...permit2Address ? { permit2Address: getAddress(permit2Address) } : {},
20420
+ ...splits ? { splits } : {}
20421
+ },
20422
+ recipient: getAddress(recipient)
20423
+ })))
20424
+ }
20425
+ });
20426
+ }
20427
+ });
20428
+
20429
+ // node_modules/mppx/dist/evm/index.js
20430
+ var evm_exports = {};
20431
+ __export(evm_exports, {
20432
+ Assets: () => Assets_exports2,
20433
+ AuthorizationConfigSchema: () => AuthorizationConfigSchema,
20434
+ AuthorizationPayloadSchema: () => AuthorizationPayloadSchema,
20435
+ Chains: () => Chains_exports,
20436
+ ChargePayloadSchema: () => ChargePayloadSchema,
20437
+ ChargeRequestInputSchema: () => ChargeRequestInputSchema,
20438
+ ChargeRequestSchema: () => ChargeRequestSchema,
20439
+ MethodDetailsSchema: () => MethodDetailsSchema,
20440
+ Methods: () => Methods_exports,
20441
+ Types: () => Types_exports,
20442
+ assets: () => Assets_exports2,
20443
+ authorizationDomain: () => authorizationDomain,
20444
+ authorizationTypes: () => authorizationTypes,
20445
+ chains: () => Chains_exports,
20446
+ challengeHash: () => challengeHash,
20447
+ charge: () => charge,
20448
+ chargeIntent: () => chargeIntent,
20449
+ credentialTypes: () => credentialTypes,
20450
+ eip3009: () => eip3009,
20451
+ evmNetworkPrefix: () => evmNetworkPrefix,
20452
+ networkOf: () => networkOf,
20453
+ paymentMethod: () => paymentMethod,
20454
+ toSource: () => toSource
20455
+ });
20456
+ var init_evm = __esm({
20457
+ "node_modules/mppx/dist/evm/index.js"() {
20458
+ "use strict";
20459
+ init_Assets2();
20460
+ init_Chains();
20461
+ init_Methods();
20462
+ init_Types();
20463
+ init_Assets2();
20464
+ init_Chains();
20465
+ init_Methods();
20466
+ init_Types();
20467
+ }
20468
+ });
20469
+
20470
+ // node_modules/mppx/dist/Mcp.js
20471
+ var Mcp_exports = {};
20472
+ __export(Mcp_exports, {
20473
+ credentialMetaKey: () => credentialMetaKey,
20474
+ paymentRequiredCode: () => paymentRequiredCode,
20475
+ paymentRequiredMetaKey: () => paymentRequiredMetaKey,
20476
+ paymentVerificationFailedCode: () => paymentVerificationFailedCode,
20477
+ receiptMetaKey: () => receiptMetaKey
20478
+ });
20479
+ var paymentRequiredCode, paymentVerificationFailedCode, credentialMetaKey, paymentRequiredMetaKey, receiptMetaKey;
20480
+ var init_Mcp = __esm({
20481
+ "node_modules/mppx/dist/Mcp.js"() {
20482
+ "use strict";
20483
+ paymentRequiredCode = -32042;
20484
+ paymentVerificationFailedCode = -32043;
20485
+ credentialMetaKey = "org.paymentauth/credential";
20486
+ paymentRequiredMetaKey = "org.paymentauth/payment-required";
20487
+ receiptMetaKey = "org.paymentauth/receipt";
20488
+ }
20489
+ });
20490
+
19455
20491
  // node_modules/mppx/dist/Receipt.js
19456
20492
  var Receipt_exports = {};
19457
20493
  __export(Receipt_exports, {
@@ -19473,9 +20509,9 @@ function serialize4(receipt) {
19473
20509
  return Base64_exports.fromString(json2, { pad: false, url: true });
19474
20510
  }
19475
20511
  function fromResponse2(response) {
19476
- const header = response.headers.get("Payment-Receipt");
20512
+ const header = response.headers.get(Headers.paymentReceipt);
19477
20513
  if (!header)
19478
- throw new Error("Missing Payment-Receipt header.");
20514
+ throw new Error(`Missing ${Headers.paymentReceipt} header.`);
19479
20515
  return deserialize4(header);
19480
20516
  }
19481
20517
  var Schema2;
@@ -19483,6 +20519,7 @@ var init_Receipt = __esm({
19483
20519
  "node_modules/mppx/dist/Receipt.js"() {
19484
20520
  "use strict";
19485
20521
  init_esm2();
20522
+ init_Constants();
19486
20523
  init_zod();
19487
20524
  Schema2 = object({
19488
20525
  /** Payment method used (e.g., "tempo", "stripe"). */
@@ -19510,8 +20547,37 @@ __export(Store_exports, {
19510
20547
  redis: () => redis,
19511
20548
  upstash: () => upstash
19512
20549
  });
19513
- function from8(store) {
19514
- return store;
20550
+ function from8(store, options) {
20551
+ return withKeyPrefix(store, options?.keyPrefix);
20552
+ }
20553
+ function withKeyPrefix(store, keyPrefix = "") {
20554
+ if (!keyPrefix)
20555
+ return store;
20556
+ const cached2 = keyPrefixCache.get(store)?.get(keyPrefix);
20557
+ if (cached2)
20558
+ return cached2;
20559
+ const backing = store;
20560
+ const prefixedKey = (key) => `${keyPrefix}${key}`;
20561
+ const prefixed = from8({
20562
+ async get(key) {
20563
+ return backing.get(prefixedKey(key));
20564
+ },
20565
+ async put(key, value) {
20566
+ await backing.put(prefixedKey(key), value);
20567
+ },
20568
+ async delete(key) {
20569
+ await backing.delete(prefixedKey(key));
20570
+ },
20571
+ ..."update" in store ? {
20572
+ async update(key, fn) {
20573
+ return store.update(prefixedKey(key), fn);
20574
+ }
20575
+ } : {}
20576
+ });
20577
+ const cachedByPrefix = keyPrefixCache.get(store) ?? /* @__PURE__ */ new Map();
20578
+ cachedByPrefix.set(keyPrefix, prefixed);
20579
+ keyPrefixCache.set(store, cachedByPrefix);
20580
+ return prefixed;
19515
20581
  }
19516
20582
  function wrapJsonUpdate(update) {
19517
20583
  if (!update)
@@ -19528,7 +20594,7 @@ function wrapJsonUpdate(update) {
19528
20594
  }
19529
20595
  };
19530
20596
  }
19531
- function cloudflare(kv) {
20597
+ function cloudflare(kv, options) {
19532
20598
  return from8({
19533
20599
  async get(key) {
19534
20600
  const raw = await kv.get(key);
@@ -19543,9 +20609,9 @@ function cloudflare(kv) {
19543
20609
  await kv.delete(key);
19544
20610
  },
19545
20611
  ...wrapJsonUpdate(kv.update)
19546
- });
20612
+ }, options);
19547
20613
  }
19548
- function memory() {
20614
+ function memory(options) {
19549
20615
  const store = /* @__PURE__ */ new Map();
19550
20616
  return from8({
19551
20617
  async get(key) {
@@ -19569,9 +20635,9 @@ function memory() {
19569
20635
  store.delete(key);
19570
20636
  return change.result;
19571
20637
  }
19572
- });
20638
+ }, options);
19573
20639
  }
19574
- function redis(client) {
20640
+ function redis(client, options) {
19575
20641
  return from8({
19576
20642
  async get(key) {
19577
20643
  const raw = await client.get(key);
@@ -19586,9 +20652,9 @@ function redis(client) {
19586
20652
  await client.del(key);
19587
20653
  },
19588
20654
  ...wrapJsonUpdate(client.update)
19589
- });
20655
+ }, options);
19590
20656
  }
19591
- function upstash(redis2) {
20657
+ function upstash(redis2, options) {
19592
20658
  return from8({
19593
20659
  async get(key) {
19594
20660
  return await redis2.get(key);
@@ -19602,12 +20668,288 @@ function upstash(redis2) {
19602
20668
  ...redis2.update ? {
19603
20669
  update: redis2.update
19604
20670
  } : {}
19605
- });
20671
+ }, options);
19606
20672
  }
20673
+ var keyPrefixCache;
19607
20674
  var init_Store = __esm({
19608
20675
  "node_modules/mppx/dist/Store.js"() {
19609
20676
  "use strict";
19610
20677
  init_esm2();
20678
+ keyPrefixCache = /* @__PURE__ */ new WeakMap();
20679
+ }
20680
+ });
20681
+
20682
+ // node_modules/mppx/dist/internal/HeaderCodec.js
20683
+ function createJson(schema) {
20684
+ return {
20685
+ encode(value) {
20686
+ return Base64_exports.fromString(JSON.stringify(schema.parse(value)));
20687
+ },
20688
+ decode(value) {
20689
+ try {
20690
+ return schema.parse(JSON.parse(Base64_exports.toString(value)));
20691
+ } catch {
20692
+ throw new InvalidJsonHeaderError();
20693
+ }
20694
+ }
20695
+ };
20696
+ }
20697
+ var InvalidJsonHeaderError;
20698
+ var init_HeaderCodec = __esm({
20699
+ "node_modules/mppx/dist/internal/HeaderCodec.js"() {
20700
+ "use strict";
20701
+ init_esm2();
20702
+ InvalidJsonHeaderError = class extends Error {
20703
+ name = "InvalidJsonHeaderError";
20704
+ constructor() {
20705
+ super("Invalid base64 JSON header.");
20706
+ }
20707
+ };
20708
+ }
20709
+ });
20710
+
20711
+ // node_modules/mppx/dist/x402/Types.js
20712
+ var Types_exports2 = {};
20713
+ __export(Types_exports2, {
20714
+ ExactEip3009PayloadSchema: () => ExactEip3009PayloadSchema,
20715
+ ExactPayloadSchema: () => ExactPayloadSchema,
20716
+ ExactPermit2PayloadSchema: () => ExactPermit2PayloadSchema,
20717
+ ExactTransferSchema: () => ExactTransferSchema,
20718
+ ExtensionSchema: () => ExtensionSchema,
20719
+ ExtensionsSchema: () => ExtensionsSchema,
20720
+ PaymentPayloadSchema: () => PaymentPayloadSchema,
20721
+ PaymentRequiredSchema: () => PaymentRequiredSchema,
20722
+ PaymentRequirementsSchema: () => PaymentRequirementsSchema,
20723
+ ResourceInfoSchema: () => ResourceInfoSchema,
20724
+ SettleResponseSchema: () => SettleResponseSchema,
20725
+ VerifyResponseSchema: () => VerifyResponseSchema,
20726
+ assetTransferMethods: () => assetTransferMethods,
20727
+ evmNetworkPrefix: () => evmNetworkPrefix2,
20728
+ exactIntent: () => exactIntent,
20729
+ paymentMethod: () => paymentMethod2,
20730
+ paymentRequiredHeader: () => paymentRequiredHeader,
20731
+ paymentResponseHeader: () => paymentResponseHeader,
20732
+ paymentSignatureHeader: () => paymentSignatureHeader,
20733
+ schemes: () => schemes,
20734
+ syntheticChallengeIdPrefix: () => syntheticChallengeIdPrefix,
20735
+ toPaymentRequirements: () => toPaymentRequirements,
20736
+ versions: () => versions
20737
+ });
20738
+ function toPaymentRequirements(request) {
20739
+ const { extensions: _extensions, resource: _resource, ...paymentRequirements } = request;
20740
+ return PaymentRequirementsSchema.parse(paymentRequirements);
20741
+ }
20742
+ 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;
20743
+ var init_Types2 = __esm({
20744
+ "node_modules/mppx/dist/x402/Types.js"() {
20745
+ "use strict";
20746
+ init_zod();
20747
+ versions = [2];
20748
+ paymentMethod2 = "evm";
20749
+ exactIntent = "charge";
20750
+ schemes = ["exact"];
20751
+ assetTransferMethods = ["eip3009", "permit2"];
20752
+ evmNetworkPrefix2 = "eip155:";
20753
+ syntheticChallengeIdPrefix = "x402:";
20754
+ paymentRequiredHeader = "PAYMENT-REQUIRED";
20755
+ paymentSignatureHeader = "PAYMENT-SIGNATURE";
20756
+ paymentResponseHeader = "PAYMENT-RESPONSE";
20757
+ nonEmptyString = string2().check(_minLength(1));
20758
+ positiveNumber = number2().check(refine((value) => value > 0, "Must be positive"));
20759
+ atomicAmount2 = string2().check(_regex(/^\d+$/, "Invalid atomic amount"));
20760
+ address2 = address();
20761
+ evmNetwork = string2().check(_regex(new RegExp(`^${evmNetworkPrefix2}\\d+$`), "Invalid EVM CAIP-2 network"));
20762
+ ResourceInfoSchema = object({
20763
+ description: optional(string2()),
20764
+ iconUrl: optional(string2()),
20765
+ mimeType: optional(string2()),
20766
+ serviceName: optional(string2()),
20767
+ tags: optional(array(string2())),
20768
+ url: nonEmptyString
20769
+ });
20770
+ ExactTransferSchema = discriminatedUnion("type", [
20771
+ object({
20772
+ name: nonEmptyString,
20773
+ type: literal("eip3009"),
20774
+ version: nonEmptyString
20775
+ }),
20776
+ object({
20777
+ name: optional(string2()),
20778
+ type: literal("permit2"),
20779
+ version: optional(string2())
20780
+ })
20781
+ ]);
20782
+ PaymentRequirementsSchema = object({
20783
+ amount: atomicAmount2,
20784
+ asset: nonEmptyString,
20785
+ extra: optional(record(string2(), unknown())),
20786
+ maxTimeoutSeconds: positiveNumber,
20787
+ network: evmNetwork,
20788
+ payTo: nonEmptyString,
20789
+ scheme: _enum2(schemes)
20790
+ });
20791
+ ExtensionSchema = object({
20792
+ info: record(string2(), unknown()),
20793
+ schema: record(string2(), unknown())
20794
+ });
20795
+ ExtensionsSchema = record(string2(), ExtensionSchema);
20796
+ PaymentRequiredSchema = object({
20797
+ accepts: array(PaymentRequirementsSchema).check(_minLength(1)),
20798
+ error: optional(string2()),
20799
+ extensions: optional(ExtensionsSchema),
20800
+ resource: ResourceInfoSchema,
20801
+ x402Version: literal(2)
20802
+ });
20803
+ ExactEip3009PayloadSchema = object({
20804
+ authorization: object({
20805
+ from: address2,
20806
+ nonce: hash2(),
20807
+ to: address2,
20808
+ validAfter: atomicAmount2,
20809
+ validBefore: atomicAmount2,
20810
+ value: atomicAmount2
20811
+ }),
20812
+ signature: signature()
20813
+ });
20814
+ ExactPermit2PayloadSchema = object({
20815
+ permit2Authorization: object({
20816
+ deadline: atomicAmount2,
20817
+ from: address2,
20818
+ nonce: atomicAmount2,
20819
+ permitted: object({
20820
+ amount: atomicAmount2,
20821
+ token: address2
20822
+ }),
20823
+ spender: address2,
20824
+ witness: object({
20825
+ to: address2,
20826
+ validAfter: atomicAmount2
20827
+ })
20828
+ }),
20829
+ signature: signature()
20830
+ });
20831
+ ExactPayloadSchema = union([ExactEip3009PayloadSchema, ExactPermit2PayloadSchema]);
20832
+ PaymentPayloadSchema = object({
20833
+ accepted: PaymentRequirementsSchema,
20834
+ extensions: optional(ExtensionsSchema),
20835
+ payload: ExactPayloadSchema,
20836
+ resource: optional(ResourceInfoSchema),
20837
+ x402Version: literal(2)
20838
+ });
20839
+ VerifyResponseSchema = object({
20840
+ extensions: optional(ExtensionsSchema),
20841
+ extra: optional(record(string2(), unknown())),
20842
+ invalidMessage: optional(string2()),
20843
+ invalidReason: optional(string2()),
20844
+ isValid: boolean2(),
20845
+ payer: optional(string2())
20846
+ });
20847
+ SettleResponseSchema = object({
20848
+ amount: optional(atomicAmount2),
20849
+ errorMessage: optional(string2()),
20850
+ errorReason: optional(string2()),
20851
+ extensions: optional(ExtensionsSchema),
20852
+ extra: optional(record(string2(), unknown())),
20853
+ network: nonEmptyString,
20854
+ payer: optional(string2()),
20855
+ success: boolean2(),
20856
+ transaction: string2()
20857
+ });
20858
+ }
20859
+ });
20860
+
20861
+ // node_modules/mppx/dist/x402/Header.js
20862
+ var Header_exports = {};
20863
+ __export(Header_exports, {
20864
+ decodePaymentRequired: () => decodePaymentRequired,
20865
+ decodePaymentRequiredEnvelope: () => decodePaymentRequiredEnvelope,
20866
+ decodePaymentResponse: () => decodePaymentResponse,
20867
+ decodePaymentSignature: () => decodePaymentSignature,
20868
+ encodePaymentRequired: () => encodePaymentRequired,
20869
+ encodePaymentResponse: () => encodePaymentResponse,
20870
+ encodePaymentSignature: () => encodePaymentSignature
20871
+ });
20872
+ function decodePaymentRequiredEnvelope(value) {
20873
+ try {
20874
+ const parsed = JSON.parse(Base64_exports.toString(value));
20875
+ return parsePaymentRequiredEnvelope(parsed);
20876
+ } catch {
20877
+ throw new InvalidJsonHeaderError();
20878
+ }
20879
+ }
20880
+ var paymentRequired, paymentSignature, paymentResponse, encodePaymentRequired, decodePaymentRequired, encodePaymentSignature, decodePaymentSignature, encodePaymentResponse, decodePaymentResponse, parsePaymentRequiredEnvelope;
20881
+ var init_Header = __esm({
20882
+ "node_modules/mppx/dist/x402/Header.js"() {
20883
+ "use strict";
20884
+ init_esm2();
20885
+ init_HeaderCodec();
20886
+ init_Types2();
20887
+ paymentRequired = createJson(PaymentRequiredSchema);
20888
+ paymentSignature = createJson(PaymentPayloadSchema);
20889
+ paymentResponse = createJson(SettleResponseSchema);
20890
+ encodePaymentRequired = paymentRequired.encode;
20891
+ decodePaymentRequired = paymentRequired.decode;
20892
+ encodePaymentSignature = paymentSignature.encode;
20893
+ decodePaymentSignature = paymentSignature.decode;
20894
+ encodePaymentResponse = paymentResponse.encode;
20895
+ decodePaymentResponse = paymentResponse.decode;
20896
+ parsePaymentRequiredEnvelope = (value) => {
20897
+ if (!value || typeof value !== "object" || Array.isArray(value))
20898
+ throw new InvalidJsonHeaderError();
20899
+ const record2 = value;
20900
+ if (record2.x402Version !== 2 || !Array.isArray(record2.accepts))
20901
+ throw new InvalidJsonHeaderError();
20902
+ const resource = ResourceInfoSchema.parse(record2.resource);
20903
+ const extensions = record2.extensions === void 0 ? void 0 : ExtensionsSchema.parse(record2.extensions);
20904
+ return {
20905
+ accepts: record2.accepts,
20906
+ ...extensions ? { extensions } : {},
20907
+ resource,
20908
+ x402Version: 2
20909
+ };
20910
+ };
20911
+ }
20912
+ });
20913
+
20914
+ // node_modules/mppx/dist/x402/index.js
20915
+ var x402_exports = {};
20916
+ __export(x402_exports, {
20917
+ Assets: () => Assets_exports,
20918
+ ExactEip3009PayloadSchema: () => ExactEip3009PayloadSchema,
20919
+ ExactPayloadSchema: () => ExactPayloadSchema,
20920
+ ExactPermit2PayloadSchema: () => ExactPermit2PayloadSchema,
20921
+ ExactTransferSchema: () => ExactTransferSchema,
20922
+ ExtensionSchema: () => ExtensionSchema,
20923
+ ExtensionsSchema: () => ExtensionsSchema,
20924
+ Header: () => Header_exports,
20925
+ PaymentPayloadSchema: () => PaymentPayloadSchema,
20926
+ PaymentRequiredSchema: () => PaymentRequiredSchema,
20927
+ PaymentRequirementsSchema: () => PaymentRequirementsSchema,
20928
+ ResourceInfoSchema: () => ResourceInfoSchema,
20929
+ SettleResponseSchema: () => SettleResponseSchema,
20930
+ Types: () => Types_exports2,
20931
+ VerifyResponseSchema: () => VerifyResponseSchema,
20932
+ assetTransferMethods: () => assetTransferMethods,
20933
+ assets: () => Assets_exports,
20934
+ evmNetworkPrefix: () => evmNetworkPrefix2,
20935
+ exactIntent: () => exactIntent,
20936
+ paymentMethod: () => paymentMethod2,
20937
+ paymentRequiredHeader: () => paymentRequiredHeader,
20938
+ paymentResponseHeader: () => paymentResponseHeader,
20939
+ paymentSignatureHeader: () => paymentSignatureHeader,
20940
+ schemes: () => schemes,
20941
+ syntheticChallengeIdPrefix: () => syntheticChallengeIdPrefix,
20942
+ toPaymentRequirements: () => toPaymentRequirements,
20943
+ versions: () => versions
20944
+ });
20945
+ var init_x402 = __esm({
20946
+ "node_modules/mppx/dist/x402/index.js"() {
20947
+ "use strict";
20948
+ init_Assets();
20949
+ init_Header();
20950
+ init_Types2();
20951
+ init_Assets();
20952
+ init_Types2();
19611
20953
  }
19612
20954
  });
19613
20955
 
@@ -19616,6 +20958,7 @@ var dist_exports = {};
19616
20958
  __export(dist_exports, {
19617
20959
  BodyDigest: () => BodyDigest_exports,
19618
20960
  Challenge: () => Challenge_exports,
20961
+ Constants: () => Constants_exports,
19619
20962
  Credential: () => Credential_exports,
19620
20963
  Errors: () => Errors_exports2,
19621
20964
  Expires: () => Expires_exports,
@@ -19624,6 +20967,8 @@ __export(dist_exports, {
19624
20967
  PaymentRequest: () => PaymentRequest_exports,
19625
20968
  Receipt: () => Receipt_exports,
19626
20969
  Store: () => Store_exports,
20970
+ evm: () => evm_exports,
20971
+ x402: () => x402_exports,
19627
20972
  z: () => zod_exports
19628
20973
  });
19629
20974
  var init_dist2 = __esm({
@@ -19631,14 +20976,17 @@ var init_dist2 = __esm({
19631
20976
  "use strict";
19632
20977
  init_BodyDigest();
19633
20978
  init_Challenge();
20979
+ init_Constants();
19634
20980
  init_Credential();
19635
20981
  init_Errors2();
19636
20982
  init_Expires();
20983
+ init_evm();
19637
20984
  init_Mcp();
19638
20985
  init_Method();
19639
20986
  init_PaymentRequest();
19640
20987
  init_Receipt();
19641
20988
  init_Store();
20989
+ init_x402();
19642
20990
  init_zod();
19643
20991
  }
19644
20992
  });
@@ -19775,12 +21123,12 @@ async function mintAndCache(opts) {
19775
21123
  ...opts.metadata ? { metadata: opts.metadata } : {},
19776
21124
  ...idempotencyKey ? { idempotencyKey } : {}
19777
21125
  });
19778
- for (const address2 of Object.values(depositAddresses)) {
19779
- await opts.piCache.cacheAddress(address2);
19780
- opts.piCache.cachePaymentIntent(address2, paymentIntentId);
21126
+ for (const address3 of Object.values(depositAddresses)) {
21127
+ await opts.piCache.cacheAddress(address3);
21128
+ opts.piCache.cachePaymentIntent(address3, paymentIntentId);
19781
21129
  }
19782
- for (const address2 of Object.values(staticRecipients)) {
19783
- await opts.piCache.cacheAddress(address2);
21130
+ for (const address3 of Object.values(staticRecipients)) {
21131
+ await opts.piCache.cacheAddress(address3);
19784
21132
  }
19785
21133
  const merged = { ...depositAddresses, ...staticRecipients };
19786
21134
  opts.piCache.cacheNetworkAddresses(paymentIntentId, merged);
@@ -19949,19 +21297,19 @@ function createPiCache({
19949
21297
  }, 6e4);
19950
21298
  if (typeof evict.unref === "function") evict.unref();
19951
21299
  return {
19952
- async cacheAddress(address2) {
21300
+ async cacheAddress(address3) {
19953
21301
  const r = await getRedis();
19954
- if (r) await r.set(`${keyPrefix}${address2}`, "1", "EX", ttlSeconds).catch(() => {
21302
+ if (r) await r.set(`${keyPrefix}${address3}`, "1", "EX", ttlSeconds).catch(() => {
19955
21303
  });
19956
- addrMemCache.set(address2, Date.now() + ttlSeconds * 1e3);
21304
+ addrMemCache.set(address3, Date.now() + ttlSeconds * 1e3);
19957
21305
  },
19958
- async hasAddress(address2) {
21306
+ async hasAddress(address3) {
19959
21307
  const r = await getRedis();
19960
21308
  if (r) {
19961
- const val = await r.get(`${keyPrefix}${address2}`).catch(() => null);
21309
+ const val = await r.get(`${keyPrefix}${address3}`).catch(() => null);
19962
21310
  if (val) return true;
19963
21311
  }
19964
- const expiry = addrMemCache.get(address2);
21312
+ const expiry = addrMemCache.get(address3);
19965
21313
  return !!expiry && expiry > Date.now();
19966
21314
  },
19967
21315
  cachePaymentIntent(depositAddress, paymentIntentId) {