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