@piprail/sdk 2.15.0 → 2.16.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 (35) hide show
  1. package/CHANGELOG.md +260 -0
  2. package/README.md +2 -2
  3. package/dist/{algorand-CSEUTWNW.js → algorand-25FMBCT3.js} +13 -4
  4. package/dist/{algorand-I2O24RSM.cjs → algorand-Q3TUQLPK.cjs} +49 -40
  5. package/dist/{aptos-J7QGCWNW.js → aptos-SBV6SGDP.js} +3 -3
  6. package/dist/{aptos-GA5AEYYL.cjs → aptos-VBJONBFY.cjs} +36 -36
  7. package/dist/chunk-2CX7XRZK.js +649 -0
  8. package/dist/chunk-C52H5TYB.js +474 -0
  9. package/dist/chunk-OXEFPLZA.cjs +474 -0
  10. package/dist/{chunk-3FR22M3O.cjs → chunk-QONQSZHJ.cjs} +2 -2
  11. package/dist/{chunk-3ZWM3DKM.js → chunk-QU25LSVS.js} +2 -2
  12. package/dist/chunk-V2IJ5HUW.cjs +649 -0
  13. package/dist/index.cjs +507 -1347
  14. package/dist/index.d.cts +39 -6
  15. package/dist/index.d.ts +39 -6
  16. package/dist/index.js +192 -1032
  17. package/dist/{ledger-uFtXlIHY.d.cts → ledger-Crc1bZox.d.cts} +164 -10
  18. package/dist/{ledger-uFtXlIHY.d.ts → ledger-Crc1bZox.d.ts} +164 -10
  19. package/dist/{near-NDQLGI4U.cjs → near-5LTTDU6G.cjs} +27 -27
  20. package/dist/{near-YA4Y4IGC.js → near-OLKCMTBI.js} +1 -1
  21. package/dist/node.d.cts +2 -2
  22. package/dist/node.d.ts +2 -2
  23. package/dist/{solana-OU6IUMQM.cjs → solana-AI2G7V33.cjs} +73 -52
  24. package/dist/{solana-MB6G3OA5.js → solana-HTKDRTD3.js} +32 -11
  25. package/dist/{stellar-RSNVOIKL.cjs → stellar-E2KWEV2E.cjs} +20 -20
  26. package/dist/{stellar-WDWSYOED.js → stellar-EUFZLX6J.js} +1 -1
  27. package/dist/{sui-GVSFNNJX.js → sui-KCIITCYH.js} +6 -2
  28. package/dist/{sui-MVC46BFJ.cjs → sui-Q3NJOJZS.cjs} +21 -17
  29. package/dist/{ton-MYOI3U3H.cjs → ton-J7TQWRN4.cjs} +16 -16
  30. package/dist/{ton-EJMGM3YI.js → ton-WH2JVQOO.js} +1 -1
  31. package/dist/{tron-VAPVMGJK.js → tron-FXBXDNEY.js} +1 -1
  32. package/dist/{tron-42X5N4GQ.cjs → tron-HIPMOX7S.cjs} +25 -25
  33. package/dist/{xrpl-Q2UWPCTJ.js → xrpl-RUOB37QH.js} +283 -5
  34. package/dist/{xrpl-MGUBUNSZ.cjs → xrpl-SVVS445B.cjs} +312 -34
  35. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -32,7 +32,60 @@ var _chunkCQQI5IJXcjs = require('./chunk-CQQI5IJX.cjs');
32
32
 
33
33
 
34
34
 
35
- var _chunk3FR22M3Ocjs = require('./chunk-3FR22M3O.cjs');
35
+
36
+
37
+
38
+
39
+
40
+
41
+
42
+
43
+ var _chunkOXEFPLZAcjs = require('./chunk-OXEFPLZA.cjs');
44
+
45
+
46
+
47
+
48
+
49
+
50
+
51
+
52
+
53
+
54
+
55
+
56
+
57
+
58
+
59
+ var _chunkV2IJ5HUWcjs = require('./chunk-V2IJ5HUW.cjs');
60
+
61
+
62
+
63
+
64
+
65
+
66
+
67
+
68
+
69
+
70
+
71
+
72
+
73
+
74
+
75
+
76
+
77
+
78
+
79
+
80
+
81
+
82
+
83
+
84
+
85
+
86
+
87
+
88
+ var _chunkQONQSZHJcjs = require('./chunk-QONQSZHJ.cjs');
36
89
 
37
90
  // src/drivers/registry.ts
38
91
  var byFamily = /* @__PURE__ */ new Map();
@@ -61,13 +114,13 @@ function resolveNetwork(opts) {
61
114
  const family = familyForChain(opts.chain);
62
115
  const driver = byFamily.get(family);
63
116
  if (!driver) {
64
- throw new (0, _chunk3FR22M3Ocjs.UnsupportedNetworkError)(
117
+ throw new (0, _chunkQONQSZHJcjs.UnsupportedNetworkError)(
65
118
  `No driver registered for the "${family}" family \u2014 it may not be mounted yet (use the async resolveNetwork()).`
66
119
  );
67
120
  }
68
121
  const net = driver.resolve(opts);
69
122
  if (!net) {
70
- throw new (0, _chunk3FR22M3Ocjs.UnsupportedNetworkError)(
123
+ throw new (0, _chunkQONQSZHJcjs.UnsupportedNetworkError)(
71
124
  `The ${family} driver didn't recognise this chain input.`
72
125
  );
73
126
  }
@@ -332,12 +385,12 @@ function resolveChain(input, rpcUrlOverride) {
332
385
 
333
386
  var _accounts = require('viem/accounts');
334
387
  function createWalletAdapter(config, resolved) {
335
- _chunk3FR22M3Ocjs.assertNoLegacyWalletKey.call(void 0, config, "EVM");
388
+ _chunkQONQSZHJcjs.assertNoLegacyWalletKey.call(void 0, config, "EVM");
336
389
  if ("key" in config) {
337
390
  const key = config.key;
338
391
  if (typeof key !== "string" || !/^0x[0-9a-fA-F]{64}$/.test(key)) {
339
392
  const hint = typeof key === "string" && !key.startsWith("0x") ? " (got a non-0x string \u2014 a base58/seed key belongs to another family; pass { key } as the EVM chain's 0x\u2026 hex secret)." : " (expected 0x followed by 64 hex characters).";
340
- throw new (0, _chunk3FR22M3Ocjs.WrongFamilyError)(
393
+ throw new (0, _chunkQONQSZHJcjs.WrongFamilyError)(
341
394
  `chain is EVM; the wallet { key } is not a valid 0x\u2026 32-byte hex private key${hint}`
342
395
  );
343
396
  }
@@ -345,7 +398,7 @@ function createWalletAdapter(config, resolved) {
345
398
  try {
346
399
  account = _accounts.privateKeyToAccount.call(void 0, key);
347
400
  } catch (err) {
348
- throw new (0, _chunk3FR22M3Ocjs.WrongFamilyError)(
401
+ throw new (0, _chunkQONQSZHJcjs.WrongFamilyError)(
349
402
  `chain is EVM; the wallet { key } is not a valid 0x\u2026 32-byte hex private key: ${err instanceof Error ? err.message : String(err)}.`
350
403
  );
351
404
  }
@@ -355,12 +408,12 @@ function createWalletAdapter(config, resolved) {
355
408
  }
356
409
  const wc = config.walletClient;
357
410
  if (!wc.account) {
358
- throw new (0, _chunk3FR22M3Ocjs.WrongFamilyError)(
411
+ throw new (0, _chunkQONQSZHJcjs.WrongFamilyError)(
359
412
  "chain is EVM; the provided walletClient has no attached account. Use `createWalletClient({ account, chain, transport })`, or pass { key }."
360
413
  );
361
414
  }
362
415
  if (wc.chain && wc.chain.id !== resolved.chainId) {
363
- throw new (0, _chunk3FR22M3Ocjs.WrongChainError)(
416
+ throw new (0, _chunkQONQSZHJcjs.WrongChainError)(
364
417
  `PipRailClient: walletClient is on chain ${wc.chain.id} but the SDK was configured with chain ${resolved.chainId}. They must match.`
365
418
  );
366
419
  }
@@ -690,7 +743,7 @@ async function payExactEvm(input) {
690
743
  code = void 0;
691
744
  }
692
745
  if (code && code !== "0x") {
693
- throw new (0, _chunk3FR22M3Ocjs.UnsupportedSchemeError)(
746
+ throw new (0, _chunkQONQSZHJcjs.UnsupportedSchemeError)(
694
747
  `exact buyer rail requires an EOA signer; ${account.address} is a contract / EIP-1271 / EIP-7702-delegated account (no recoverable ECDSA signature). Pay via onchain-proof.`
695
748
  );
696
749
  }
@@ -700,13 +753,13 @@ async function payExactEvm(input) {
700
753
  domain = await readExactDomain(publicClient, accept.asset);
701
754
  }
702
755
  if (!domain) {
703
- throw new (0, _chunk3FR22M3Ocjs.UnsupportedSchemeError)(
756
+ throw new (0, _chunkQONQSZHJcjs.UnsupportedSchemeError)(
704
757
  `exact: couldn't derive the EIP-712 domain for ${accept.asset} on ${accept.network}. Either it isn't an EIP-3009 token (USDT needs Permit2; native/plain ERC-20 aren't exact-payable) \u2014 pay via onchain-proof \u2014 OR your RPC couldn't read it (transient): if the gate advertised eip3009, pass a reliable rpcUrl and retry.`
705
758
  );
706
759
  }
707
760
  const g = globalThis.crypto;
708
761
  if (!_optionalChain([g, 'optionalAccess', _5 => _5.getRandomValues])) {
709
- throw new (0, _chunk3FR22M3Ocjs.UnsupportedSchemeError)(
762
+ throw new (0, _chunkQONQSZHJcjs.UnsupportedSchemeError)(
710
763
  "this runtime lacks Web Crypto (globalThis.crypto.getRandomValues); the exact rail needs a CSPRNG nonce."
711
764
  );
712
765
  }
@@ -896,8 +949,8 @@ async function verifyAndSettleExactEvm(input) {
896
949
  try {
897
950
  recovered = await _viem.recoverTypedDataAddress.call(void 0, {
898
951
  domain: {
899
- name: accept.extra.name,
900
- version: accept.extra.version,
952
+ name: _optionalChain([accept, 'access', _8 => _8.extra, 'optionalAccess', _9 => _9.name]),
953
+ version: _optionalChain([accept, 'access', _10 => _10.extra, 'optionalAccess', _11 => _11.version]),
901
954
  chainId: chain.id,
902
955
  verifyingContract: token
903
956
  },
@@ -963,19 +1016,19 @@ async function verifyAndSettleExactEvm(input) {
963
1016
  args: writeArgs
964
1017
  });
965
1018
  } catch (err) {
966
- throw new (0, _chunk3FR22M3Ocjs.SettlementError)(
1019
+ throw new (0, _chunkQONQSZHJcjs.SettlementError)(
967
1020
  `exact settle: the merchant relayer failed to broadcast transferWithAuthorization (${shorten(err instanceof Error ? err.message : String(err))}). The payer's authorization is still valid and unused \u2014 fund/fix the relayer and the payer can retry.`,
968
1021
  { cause: err }
969
1022
  );
970
1023
  }
971
1024
  try {
972
- const confirmations = _nullishCoalesce(accept.extra.minConfirmations, () => ( 1));
1025
+ const confirmations = _nullishCoalesce(_optionalChain([accept, 'access', _12 => _12.extra, 'optionalAccess', _13 => _13.minConfirmations]), () => ( 1));
973
1026
  const receipt = await publicClient.waitForTransactionReceipt({ hash: txHash, confirmations });
974
1027
  if (receipt.status !== "success") {
975
1028
  return { ok: false, error: "tx_reverted", detail: `Settlement tx ${txHash} reverted on-chain.` };
976
1029
  }
977
1030
  } catch (err) {
978
- throw new (0, _chunk3FR22M3Ocjs.SettlementError)(
1031
+ throw new (0, _chunkQONQSZHJcjs.SettlementError)(
979
1032
  `exact settle: broadcast ${txHash} but couldn't confirm it (${shorten(err instanceof Error ? err.message : String(err))}).`,
980
1033
  { cause: err }
981
1034
  );
@@ -1105,8 +1158,8 @@ function shorten2(msg) {
1105
1158
  }
1106
1159
  function randomPermit2Nonce() {
1107
1160
  const g = globalThis.crypto;
1108
- if (!_optionalChain([g, 'optionalAccess', _8 => _8.getRandomValues])) {
1109
- throw new (0, _chunk3FR22M3Ocjs.UnsupportedSchemeError)(
1161
+ if (!_optionalChain([g, 'optionalAccess', _14 => _14.getRandomValues])) {
1162
+ throw new (0, _chunkQONQSZHJcjs.UnsupportedSchemeError)(
1110
1163
  "this runtime lacks Web Crypto (globalThis.crypto.getRandomValues); the permit2 rail needs a CSPRNG nonce."
1111
1164
  );
1112
1165
  }
@@ -1125,7 +1178,7 @@ async function ensurePermit2Allowance(input) {
1125
1178
  args: [account.address, PERMIT2_ADDRESS]
1126
1179
  });
1127
1180
  } catch (err) {
1128
- throw new (0, _chunk3FR22M3Ocjs.UnsupportedSchemeError)(
1181
+ throw new (0, _chunkQONQSZHJcjs.UnsupportedSchemeError)(
1129
1182
  `permit2: couldn't read the Permit2 allowance for ${token} (${shorten2(err instanceof Error ? err.message : String(err))}).`
1130
1183
  );
1131
1184
  }
@@ -1142,7 +1195,7 @@ async function ensurePermit2Allowance(input) {
1142
1195
  await publicClient.waitForTransactionReceipt({ hash, confirmations: 1 });
1143
1196
  return hash;
1144
1197
  } catch (err) {
1145
- throw _nullishCoalesce(_chunk3FR22M3Ocjs.toInsufficientFundsError.call(void 0, err), () => ( new (0, _chunk3FR22M3Ocjs.SettlementError)(
1198
+ throw _nullishCoalesce(_chunkQONQSZHJcjs.toInsufficientFundsError.call(void 0, err), () => ( new (0, _chunkQONQSZHJcjs.SettlementError)(
1146
1199
  `permit2: the one-time Permit2 approval for ${token} failed to broadcast (${shorten2(err instanceof Error ? err.message : String(err))}).`,
1147
1200
  { cause: err }
1148
1201
  )));
@@ -1157,7 +1210,7 @@ async function payPermit2Evm(input) {
1157
1210
  code = void 0;
1158
1211
  }
1159
1212
  if (code && code !== "0x") {
1160
- throw new (0, _chunk3FR22M3Ocjs.UnsupportedSchemeError)(
1213
+ throw new (0, _chunkQONQSZHJcjs.UnsupportedSchemeError)(
1161
1214
  `permit2 buyer rail requires an EOA signer; ${account.address} is a contract / EIP-1271 / EIP-7702-delegated account. Pay via onchain-proof.`
1162
1215
  );
1163
1216
  }
@@ -1332,19 +1385,19 @@ async function verifyAndSettlePermit2Evm(input) {
1332
1385
  args: settleArgs
1333
1386
  });
1334
1387
  } catch (err) {
1335
- throw new (0, _chunk3FR22M3Ocjs.SettlementError)(
1388
+ throw new (0, _chunkQONQSZHJcjs.SettlementError)(
1336
1389
  `permit2 settle: the merchant relayer failed to broadcast the proxy settle (${shorten2(err instanceof Error ? err.message : String(err))}). The payer's signature is still valid and its nonce unused \u2014 fund/fix the relayer and the payer can retry.`,
1337
1390
  { cause: err }
1338
1391
  );
1339
1392
  }
1340
1393
  try {
1341
- const confirmations = _nullishCoalesce(accept.extra.minConfirmations, () => ( 1));
1394
+ const confirmations = _nullishCoalesce(_optionalChain([accept, 'access', _15 => _15.extra, 'optionalAccess', _16 => _16.minConfirmations]), () => ( 1));
1342
1395
  const receipt = await publicClient.waitForTransactionReceipt({ hash: txHash, confirmations });
1343
1396
  if (receipt.status !== "success") {
1344
1397
  return { ok: false, error: "tx_reverted", detail: `Settlement tx ${txHash} reverted on-chain.` };
1345
1398
  }
1346
1399
  } catch (err) {
1347
- throw new (0, _chunk3FR22M3Ocjs.SettlementError)(
1400
+ throw new (0, _chunkQONQSZHJcjs.SettlementError)(
1348
1401
  `permit2 settle: broadcast ${txHash} but couldn't confirm it (${shorten2(err instanceof Error ? err.message : String(err))}).`,
1349
1402
  { cause: err }
1350
1403
  );
@@ -1441,8 +1494,8 @@ function shorten3(msg) {
1441
1494
  }
1442
1495
  function randomPermit2Nonce2() {
1443
1496
  const g = globalThis.crypto;
1444
- if (!_optionalChain([g, 'optionalAccess', _9 => _9.getRandomValues])) {
1445
- throw new (0, _chunk3FR22M3Ocjs.UnsupportedSchemeError)(
1497
+ if (!_optionalChain([g, 'optionalAccess', _17 => _17.getRandomValues])) {
1498
+ throw new (0, _chunkQONQSZHJcjs.UnsupportedSchemeError)(
1446
1499
  "this runtime lacks Web Crypto (globalThis.crypto.getRandomValues); the upto rail needs a CSPRNG nonce."
1447
1500
  );
1448
1501
  }
@@ -1459,13 +1512,13 @@ async function payUptoEvm(input) {
1459
1512
  code = void 0;
1460
1513
  }
1461
1514
  if (code && code !== "0x") {
1462
- throw new (0, _chunk3FR22M3Ocjs.UnsupportedSchemeError)(
1515
+ throw new (0, _chunkQONQSZHJcjs.UnsupportedSchemeError)(
1463
1516
  `upto buyer rail requires an EOA signer; ${account.address} is a contract / EIP-1271 / EIP-7702-delegated account. Pay via onchain-proof.`
1464
1517
  );
1465
1518
  }
1466
- const facilitatorAddress = _optionalChain([accept, 'access', _10 => _10.extra, 'optionalAccess', _11 => _11.facilitatorAddress]);
1519
+ const facilitatorAddress = _optionalChain([accept, 'access', _18 => _18.extra, 'optionalAccess', _19 => _19.facilitatorAddress]);
1467
1520
  if (typeof facilitatorAddress !== "string" || facilitatorAddress.length === 0) {
1468
- throw new (0, _chunk3FR22M3Ocjs.UnsupportedSchemeError)(
1521
+ throw new (0, _chunkQONQSZHJcjs.UnsupportedSchemeError)(
1469
1522
  `upto: the rail carries no extra.facilitatorAddress to bind into witness.facilitator \u2014 refusing to sign.`
1470
1523
  );
1471
1524
  }
@@ -1686,7 +1739,7 @@ async function verifyAndSettleUptoEvm(input) {
1686
1739
  args: settleArgs
1687
1740
  });
1688
1741
  } catch (err) {
1689
- throw new (0, _chunk3FR22M3Ocjs.SettlementError)(
1742
+ throw new (0, _chunkQONQSZHJcjs.SettlementError)(
1690
1743
  `upto settle: the merchant relayer failed to broadcast the proxy settle (${shorten3(err instanceof Error ? err.message : String(err))}). The payer's signature is still valid and its nonce unused \u2014 fund/fix the relayer and the payer can retry.`,
1691
1744
  { cause: err }
1692
1745
  );
@@ -1698,7 +1751,7 @@ async function verifyAndSettleUptoEvm(input) {
1698
1751
  return { ok: false, error: "tx_reverted", detail: `Settlement tx ${txHash} reverted on-chain.` };
1699
1752
  }
1700
1753
  } catch (err) {
1701
- throw new (0, _chunk3FR22M3Ocjs.SettlementError)(
1754
+ throw new (0, _chunkQONQSZHJcjs.SettlementError)(
1702
1755
  `upto settle: broadcast ${txHash} but couldn't confirm it (${shorten3(err instanceof Error ? err.message : String(err))}).`,
1703
1756
  { cause: err }
1704
1757
  );
@@ -1720,318 +1773,6 @@ async function verifyAndSettleUptoEvm(input) {
1720
1773
  };
1721
1774
  }
1722
1775
 
1723
- // src/x402.ts
1724
- var HEADER_REQUIRED = "payment-required";
1725
- var HEADER_SIGNATURE = "payment-signature";
1726
- var HEADER_RESPONSE = "payment-response";
1727
- var HEADER_SIGNATURE_V1 = "x-payment";
1728
- var HEADER_RESPONSE_V1 = "x-payment-response";
1729
- function encodeBase64(str) {
1730
- if (typeof Buffer !== "undefined") return Buffer.from(str, "utf8").toString("base64");
1731
- if (typeof btoa === "function" && typeof TextEncoder !== "undefined") {
1732
- const bytes = new TextEncoder().encode(str);
1733
- let binary = "";
1734
- for (let i = 0; i < bytes.length; i++) binary += String.fromCharCode(bytes[i]);
1735
- return btoa(binary);
1736
- }
1737
- throw new Error("No base64 encoder available in this runtime.");
1738
- }
1739
- function decodeBase64(b64) {
1740
- if (typeof Buffer !== "undefined") return Buffer.from(b64, "base64").toString("utf8");
1741
- if (typeof atob === "function" && typeof TextDecoder !== "undefined") {
1742
- const binary = atob(b64);
1743
- const bytes = new Uint8Array(binary.length);
1744
- for (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);
1745
- return new TextDecoder().decode(bytes);
1746
- }
1747
- throw new Error("No base64 decoder available in this runtime.");
1748
- }
1749
- function fromBase64Json(b64) {
1750
- try {
1751
- return JSON.parse(decodeBase64(b64));
1752
- } catch (e19) {
1753
- return null;
1754
- }
1755
- }
1756
- function decodeBase64Json(value) {
1757
- return fromBase64Json(value);
1758
- }
1759
- function toBase64Json(value) {
1760
- return encodeBase64(JSON.stringify(value));
1761
- }
1762
- function networkForChain(chainId) {
1763
- return `eip155:${chainId}`;
1764
- }
1765
- function chainIdFromNetwork(network) {
1766
- const match = /^eip155:(\d+)$/.exec(network);
1767
- if (!match || !match[1]) return null;
1768
- const n = Number(match[1]);
1769
- return Number.isSafeInteger(n) && n > 0 ? n : null;
1770
- }
1771
- function buildChallengeHeader(challenge) {
1772
- return toBase64Json(challenge);
1773
- }
1774
- function buildReceiptHeader(receipt, extensions) {
1775
- return toBase64Json(extensions ? { ...receipt, extensions } : receipt);
1776
- }
1777
- var EXT_OFFER_RECEIPT = "offer-receipt";
1778
- function buildReceiptExtension(bundle) {
1779
- const info = { settlement: bundle.receipt, resource: bundle.resource };
1780
- if (typeof bundle.decimals === "number") info.decimals = bundle.decimals;
1781
- if (bundle.attestation) info.receipt = bundle.attestation;
1782
- return { [EXT_OFFER_RECEIPT]: { info } };
1783
- }
1784
- var EXT_PAYMENT_IDENTIFIER = "payment-identifier";
1785
- var PAYMENT_ID_MIN = 16;
1786
- var PAYMENT_ID_MAX = 128;
1787
- var PAYMENT_ID_RE = /^[A-Za-z0-9_-]+$/;
1788
- function buildPaymentIdentifierAdvertisement() {
1789
- return {
1790
- [EXT_PAYMENT_IDENTIFIER]: {
1791
- info: { required: false },
1792
- schema: { properties: { id: { type: "string", minLength: PAYMENT_ID_MIN, maxLength: PAYMENT_ID_MAX } } }
1793
- }
1794
- };
1795
- }
1796
- function readPaymentIdentifier(payload) {
1797
- if (typeof payload !== "object" || payload === null) return null;
1798
- const ext = payload.extensions;
1799
- if (typeof ext !== "object" || ext === null) return null;
1800
- const block = ext[EXT_PAYMENT_IDENTIFIER];
1801
- if (typeof block !== "object" || block === null) return null;
1802
- const info = block.info;
1803
- if (typeof info !== "object" || info === null) return null;
1804
- const id = info.id;
1805
- if (id === void 0) return null;
1806
- if (typeof id !== "string") return { invalid: "payment-identifier id must be a string" };
1807
- if (id.length < PAYMENT_ID_MIN || id.length > PAYMENT_ID_MAX) {
1808
- return { invalid: `payment-identifier id must be ${PAYMENT_ID_MIN}\u2013${PAYMENT_ID_MAX} chars (got ${id.length})` };
1809
- }
1810
- if (!PAYMENT_ID_RE.test(id)) {
1811
- return { invalid: "payment-identifier id must match [A-Za-z0-9_-]" };
1812
- }
1813
- return id;
1814
- }
1815
- function buildSignatureHeader(signature) {
1816
- return toBase64Json(signature);
1817
- }
1818
- function buildExactSignatureHeader(input) {
1819
- return toBase64Json({ x402Version: 2, accepted: input.accepted, payload: input.payload });
1820
- }
1821
- function buildUptoSignatureHeader(input) {
1822
- return toBase64Json({ x402Version: 2, accepted: input.accepted, payload: input.payload });
1823
- }
1824
- async function parseChallenge(response) {
1825
- const headerValue = response.headers.get(HEADER_REQUIRED);
1826
- if (headerValue) {
1827
- const parsed = fromBase64Json(headerValue);
1828
- if (isValidChallenge(parsed)) return parsed;
1829
- }
1830
- try {
1831
- const body = await response.clone().json();
1832
- if (isValidChallenge(body)) return body;
1833
- } catch (e20) {
1834
- }
1835
- return null;
1836
- }
1837
- function parseReceipt(response) {
1838
- const headerValue = _nullishCoalesce(response.headers.get(HEADER_RESPONSE), () => ( response.headers.get(HEADER_RESPONSE_V1)));
1839
- if (!headerValue) return null;
1840
- const parsed = fromBase64Json(headerValue);
1841
- if (!isValidReceipt(parsed)) return null;
1842
- const r = parsed;
1843
- if (typeof r.transaction !== "string" && typeof r.txHash === "string") r.transaction = r.txHash;
1844
- return r;
1845
- }
1846
- function parseReceiptExtension(response) {
1847
- const headerValue = _nullishCoalesce(response.headers.get(HEADER_RESPONSE), () => ( response.headers.get(HEADER_RESPONSE_V1)));
1848
- if (!headerValue) return null;
1849
- const parsed = fromBase64Json(headerValue);
1850
- if (!parsed || typeof parsed !== "object") return null;
1851
- const ext = parsed.extensions;
1852
- const block = _optionalChain([ext, 'optionalAccess', _12 => _12[EXT_OFFER_RECEIPT]]);
1853
- const info = _optionalChain([block, 'optionalAccess', _13 => _13.info]);
1854
- if (!info) return null;
1855
- const settlement = isValidReceipt(info.settlement) ? info.settlement : isValidReceipt(info.receipt) ? info.receipt : void 0;
1856
- if (!settlement) return null;
1857
- const attestation = info.receipt && info.receipt !== settlement ? info.receipt : void 0;
1858
- const res = info.resource;
1859
- return {
1860
- piprail: "1",
1861
- receipt: settlement,
1862
- resource: { url: res && typeof res.url === "string" ? res.url : "" },
1863
- ...typeof info.decimals === "number" ? { decimals: info.decimals } : {},
1864
- ...attestation ? { attestation } : {}
1865
- };
1866
- }
1867
- function parseSettleResponse(response) {
1868
- const headerValue = _nullishCoalesce(response.headers.get(HEADER_RESPONSE), () => ( response.headers.get(HEADER_RESPONSE_V1)));
1869
- if (!headerValue) return null;
1870
- const parsed = fromBase64Json(headerValue);
1871
- if (!parsed || typeof parsed !== "object" || typeof parsed.success !== "boolean") return null;
1872
- return {
1873
- success: parsed.success,
1874
- // Tolerate the legacy v1 `txHash` alias for `transaction` (mirrors isValidReceipt/parseReceipt).
1875
- ...typeof parsed.transaction === "string" ? { transaction: parsed.transaction } : typeof parsed.txHash === "string" ? { transaction: parsed.txHash } : {},
1876
- ...typeof parsed.network === "string" ? { network: parsed.network } : {},
1877
- ...typeof parsed.payer === "string" ? { payer: parsed.payer } : {},
1878
- ...typeof parsed.errorReason === "string" ? { errorReason: parsed.errorReason } : {},
1879
- // The upto SettleResponse's REQUIRED `amount` (actual settled atomic units) — string
1880
- // passthrough so the upto buyer records ACTUAL, not MAX. Absent on onchain-proof/exact.
1881
- ...typeof parsed.amount === "string" ? { amount: parsed.amount } : {}
1882
- };
1883
- }
1884
- function parseSignatureObject(parsed) {
1885
- if (!parsed || typeof parsed !== "object") return null;
1886
- const v = parsed;
1887
- const accepted = v.accepted;
1888
- const scheme = _nullishCoalesce(_optionalChain([accepted, 'optionalAccess', _14 => _14.scheme]), () => ( v.scheme));
1889
- if (scheme !== "onchain-proof") return null;
1890
- const payload = v.payload;
1891
- if (!payload || typeof payload.txHash !== "string" || typeof payload.nonce !== "string") {
1892
- return null;
1893
- }
1894
- if (!accepted) {
1895
- const synthesized = {
1896
- scheme: "onchain-proof",
1897
- ...typeof v.network === "string" ? { network: v.network } : {},
1898
- ...typeof v.asset === "string" ? { asset: v.asset } : {}
1899
- };
1900
- return { ...v, accepted: synthesized, payload };
1901
- }
1902
- return parsed;
1903
- }
1904
- function parseSignatureHeader(value) {
1905
- return parseSignatureObject(fromBase64Json(value));
1906
- }
1907
- function parseExactPaymentHeader(value) {
1908
- return parseExactObject(fromBase64Json(value));
1909
- }
1910
- function parseExactObject(parsed) {
1911
- if (!parsed || typeof parsed !== "object") return null;
1912
- const v = parsed;
1913
- const accepted = _nullishCoalesce(v.accepted, () => ( null));
1914
- const scheme = _nullishCoalesce(_optionalChain([accepted, 'optionalAccess', _15 => _15.scheme]), () => ( v.scheme));
1915
- if (scheme !== "exact") return null;
1916
- const network = _nullishCoalesce(_optionalChain([accepted, 'optionalAccess', _16 => _16.network]), () => ( v.network));
1917
- if (typeof network !== "string") return null;
1918
- const payload = v.payload;
1919
- if (!payload || typeof payload !== "object") return null;
1920
- const x402Version = typeof v.x402Version === "number" ? v.x402Version : 2;
1921
- const asset = accepted && typeof accepted.asset === "string" ? accepted.asset : void 0;
1922
- const base2 = { x402Version, network, ...asset ? { asset } : {}, raw: v };
1923
- if (typeof payload.signedDelegateAction === "string") {
1924
- return { ...base2, method: "near", payload: { signedDelegateAction: payload.signedDelegateAction } };
1925
- }
1926
- if (typeof payload.transaction === "string" && typeof payload.senderAuth === "string") {
1927
- return { ...base2, method: "aptos", payload: { transaction: payload.transaction, senderAuth: payload.senderAuth } };
1928
- }
1929
- if (typeof payload.transaction === "string") {
1930
- return { ...base2, method: "svm", payload: { transaction: payload.transaction } };
1931
- }
1932
- if (Array.isArray(payload.paymentGroup)) {
1933
- const group = payload.paymentGroup;
1934
- const index = payload.paymentIndex;
1935
- if (group.length === 0 || group.length > 16 || !group.every((t) => typeof t === "string") || typeof index !== "number" || !Number.isInteger(index) || index < 0 || index >= group.length) {
1936
- return null;
1937
- }
1938
- return {
1939
- ...base2,
1940
- method: "algorand",
1941
- payload: { paymentIndex: index, paymentGroup: group }
1942
- };
1943
- }
1944
- const signature = payload.signature;
1945
- if (typeof signature !== "string") return null;
1946
- const authorization = payload.authorization;
1947
- if (authorization && typeof authorization === "object") {
1948
- for (const k of ["from", "to", "value", "validAfter", "validBefore", "nonce"]) {
1949
- if (typeof authorization[k] !== "string") return null;
1950
- }
1951
- return {
1952
- ...base2,
1953
- method: "eip3009",
1954
- payload: { signature, authorization }
1955
- };
1956
- }
1957
- const p2 = payload.permit2Authorization;
1958
- if (p2 && typeof p2 === "object") {
1959
- const permitted = p2.permitted;
1960
- const witness = p2.witness;
1961
- if (!permitted || typeof permitted !== "object" || !witness || typeof witness !== "object") return null;
1962
- if (typeof permitted.token !== "string" || typeof permitted.amount !== "string") return null;
1963
- if (typeof witness.to !== "string" || typeof witness.validAfter !== "string") return null;
1964
- for (const k of ["from", "spender", "nonce", "deadline"]) {
1965
- if (typeof p2[k] !== "string") return null;
1966
- }
1967
- return {
1968
- ...base2,
1969
- method: "permit2",
1970
- payload: { signature, permit2Authorization: p2 }
1971
- };
1972
- }
1973
- return null;
1974
- }
1975
- function parseUptoPaymentHeader(value) {
1976
- return parseUptoObject(fromBase64Json(value));
1977
- }
1978
- function parseUptoObject(parsed) {
1979
- if (!parsed || typeof parsed !== "object") return null;
1980
- const v = parsed;
1981
- const accepted = _nullishCoalesce(v.accepted, () => ( null));
1982
- const scheme = _nullishCoalesce(_optionalChain([accepted, 'optionalAccess', _17 => _17.scheme]), () => ( v.scheme));
1983
- if (scheme !== "upto") return null;
1984
- const network = _nullishCoalesce(_optionalChain([accepted, 'optionalAccess', _18 => _18.network]), () => ( v.network));
1985
- if (typeof network !== "string") return null;
1986
- const payload = v.payload;
1987
- if (!payload || typeof payload !== "object") return null;
1988
- const signature = payload.signature;
1989
- if (typeof signature !== "string") return null;
1990
- const p2 = payload.permit2Authorization;
1991
- if (!p2 || typeof p2 !== "object") return null;
1992
- const permitted = p2.permitted;
1993
- const witness = p2.witness;
1994
- if (!permitted || typeof permitted !== "object" || !witness || typeof witness !== "object") return null;
1995
- if (typeof permitted.token !== "string" || typeof permitted.amount !== "string") return null;
1996
- if (typeof witness.to !== "string" || typeof witness.facilitator !== "string" || typeof witness.validAfter !== "string") {
1997
- return null;
1998
- }
1999
- for (const k of ["from", "spender", "nonce", "deadline"]) {
2000
- if (typeof p2[k] !== "string") return null;
2001
- }
2002
- const x402Version = typeof v.x402Version === "number" ? v.x402Version : 2;
2003
- const asset = accepted && typeof accepted.asset === "string" ? accepted.asset : void 0;
2004
- const base2 = { x402Version, network, ...asset ? { asset } : {}, raw: v };
2005
- return {
2006
- ...base2,
2007
- method: "permit2-upto",
2008
- payload: { signature, permit2Authorization: p2 }
2009
- };
2010
- }
2011
- function isValidChallenge(value) {
2012
- if (!value || typeof value !== "object") return false;
2013
- const v = value;
2014
- if (v.x402Version !== 2) return false;
2015
- if (!Array.isArray(v.accepts) || v.accepts.length === 0) return false;
2016
- if (!v.accepts.every((a) => a !== null && typeof a === "object")) return false;
2017
- if (!v.resource || typeof v.resource !== "object") return false;
2018
- return true;
2019
- }
2020
- function isValidReceipt(value) {
2021
- if (!value || typeof value !== "object") return false;
2022
- const v = value;
2023
- if (v.scheme !== "onchain-proof" && v.scheme !== "exact" && v.scheme !== "upto") return false;
2024
- if (typeof v.transaction !== "string" && typeof v.txHash !== "string") return false;
2025
- if (typeof v.payer !== "string") return false;
2026
- return true;
2027
- }
2028
- function pickAccept(challenge, matches) {
2029
- for (const accept of challenge.accepts) {
2030
- if (accept.scheme === "onchain-proof" && matches(accept.network)) return accept;
2031
- }
2032
- return null;
2033
- }
2034
-
2035
1776
  // src/drivers/evm/index.ts
2036
1777
  var evmDriver = {
2037
1778
  family: "evm",
@@ -2041,20 +1782,20 @@ var evmDriver = {
2041
1782
  try {
2042
1783
  return makeEvmNetwork(resolveChain(opts.chain, opts.rpcUrl));
2043
1784
  } catch (err) {
2044
- throw new (0, _chunk3FR22M3Ocjs.UnsupportedNetworkError)(err instanceof Error ? err.message : String(err), { cause: err });
1785
+ throw new (0, _chunkQONQSZHJcjs.UnsupportedNetworkError)(err instanceof Error ? err.message : String(err), { cause: err });
2045
1786
  }
2046
1787
  }
2047
1788
  let resolved;
2048
1789
  try {
2049
1790
  resolved = resolveChain(opts.chain, opts.rpcUrl);
2050
- } catch (e21) {
1791
+ } catch (e19) {
2051
1792
  return null;
2052
1793
  }
2053
1794
  return makeEvmNetwork(resolved);
2054
1795
  }
2055
1796
  };
2056
1797
  function makeEvmNetwork(resolved) {
2057
- const network = networkForChain(resolved.chainId);
1798
+ const network = _chunkOXEFPLZAcjs.networkForChain.call(void 0, resolved.chainId);
2058
1799
  const publicClient = _viem.createPublicClient.call(void 0, {
2059
1800
  chain: resolved.chain,
2060
1801
  transport: _viem.http.call(void 0, resolved.rpcUrl)
@@ -2062,7 +1803,7 @@ function makeEvmNetwork(resolved) {
2062
1803
  return {
2063
1804
  family: "evm",
2064
1805
  network,
2065
- supports: (n) => chainIdFromNetwork(n) === resolved.chainId,
1806
+ supports: (n) => _chunkOXEFPLZAcjs.chainIdFromNetwork.call(void 0, n) === resolved.chainId,
2066
1807
  resolveToken(token) {
2067
1808
  if (token === "native") {
2068
1809
  return {
@@ -2075,20 +1816,20 @@ function makeEvmNetwork(resolved) {
2075
1816
  const info = resolved.tokens[token.toUpperCase()];
2076
1817
  if (!info) {
2077
1818
  const known = Object.keys(resolved.tokens).join(", ") || "(none built in)";
2078
- throw new (0, _chunk3FR22M3Ocjs.UnknownTokenError)(
1819
+ throw new (0, _chunkQONQSZHJcjs.UnknownTokenError)(
2079
1820
  `token "${token}" isn't built in for ${resolved.chain.name} (known: ${known}). Pass { address, decimals } instead, or use 'native'.`
2080
1821
  );
2081
1822
  }
2082
1823
  return { asset: info.address, decimals: info.decimals, symbol: info.symbol };
2083
1824
  }
2084
- _chunk3FR22M3Ocjs.rejectForeignToken.call(void 0, token, "evm", network);
1825
+ _chunkQONQSZHJcjs.rejectForeignToken.call(void 0, token, "evm", network);
2085
1826
  if (!("address" in token)) {
2086
- throw new (0, _chunk3FR22M3Ocjs.WrongFamilyError)(
1827
+ throw new (0, _chunkQONQSZHJcjs.WrongFamilyError)(
2087
1828
  `chain ${network} is EVM; a custom token must be { address, decimals }.`
2088
1829
  );
2089
1830
  }
2090
1831
  if (!_viem.isAddress.call(void 0, token.address)) {
2091
- throw new (0, _chunk3FR22M3Ocjs.WrongFamilyError)(
1832
+ throw new (0, _chunkQONQSZHJcjs.WrongFamilyError)(
2092
1833
  `chain ${network} is EVM, but token address "${token.address}" is not a valid 0x address.`
2093
1834
  );
2094
1835
  }
@@ -2108,7 +1849,7 @@ function makeEvmNetwork(resolved) {
2108
1849
  let normalized;
2109
1850
  try {
2110
1851
  normalized = _viem.getAddress.call(void 0, asset);
2111
- } catch (e22) {
1852
+ } catch (e20) {
2112
1853
  return null;
2113
1854
  }
2114
1855
  for (const info of Object.values(resolved.tokens)) {
@@ -2120,20 +1861,20 @@ function makeEvmNetwork(resolved) {
2120
1861
  },
2121
1862
  assertValidPayTo(payTo) {
2122
1863
  if (!_viem.isAddress.call(void 0, payTo)) {
2123
- throw new (0, _chunk3FR22M3Ocjs.WrongFamilyError)(
1864
+ throw new (0, _chunkQONQSZHJcjs.WrongFamilyError)(
2124
1865
  `chain ${network} is EVM, but payTo "${payTo}" is not a valid 0x address.`
2125
1866
  );
2126
1867
  }
2127
1868
  },
2128
1869
  bindWallet(wallet) {
2129
1870
  if (typeof wallet !== "object" || wallet === null) {
2130
- throw new (0, _chunk3FR22M3Ocjs.WrongFamilyError)(
1871
+ throw new (0, _chunkQONQSZHJcjs.WrongFamilyError)(
2131
1872
  `chain ${network} is EVM; wallet must be { key } (0x\u2026 hex) or { walletClient }.`
2132
1873
  );
2133
1874
  }
2134
- _chunk3FR22M3Ocjs.assertNoLegacyWalletKey.call(void 0, wallet, "EVM");
1875
+ _chunkQONQSZHJcjs.assertNoLegacyWalletKey.call(void 0, wallet, "EVM");
2135
1876
  if (!("key" in wallet) && !("walletClient" in wallet)) {
2136
- throw new (0, _chunk3FR22M3Ocjs.WrongFamilyError)(
1877
+ throw new (0, _chunkQONQSZHJcjs.WrongFamilyError)(
2137
1878
  `chain ${network} is EVM; wallet must be { key } (0x\u2026 hex) or { walletClient }.`
2138
1879
  );
2139
1880
  }
@@ -2150,12 +1891,12 @@ function makeEvmNetwork(resolved) {
2150
1891
  });
2151
1892
  } catch (err) {
2152
1893
  if (isViemInsufficientFunds(err)) {
2153
- throw new (0, _chunk3FR22M3Ocjs.InsufficientFundsError)(
1894
+ throw new (0, _chunkQONQSZHJcjs.InsufficientFundsError)(
2154
1895
  err instanceof Error ? err.message : "Insufficient funds for payment.",
2155
1896
  { cause: err }
2156
1897
  );
2157
1898
  }
2158
- throw _nullishCoalesce(_chunk3FR22M3Ocjs.toInsufficientFundsError.call(void 0, err), () => ( err));
1899
+ throw _nullishCoalesce(_chunkQONQSZHJcjs.toInsufficientFundsError.call(void 0, err), () => ( err));
2159
1900
  }
2160
1901
  },
2161
1902
  async confirm(ref, minConfirmations) {
@@ -2166,7 +1907,7 @@ function makeEvmNetwork(resolved) {
2166
1907
  });
2167
1908
  return { height: receipt.blockNumber.toString() };
2168
1909
  } catch (err) {
2169
- throw new (0, _chunk3FR22M3Ocjs.ConfirmationTimeoutError)(
1910
+ throw new (0, _chunkQONQSZHJcjs.ConfirmationTimeoutError)(
2170
1911
  `EVM tx ${ref} did not reach ${minConfirmations} confirmation(s) in time.`,
2171
1912
  { cause: err }
2172
1913
  );
@@ -2175,9 +1916,9 @@ function makeEvmNetwork(resolved) {
2175
1916
  async estimateCost(accept) {
2176
1917
  const { decimals, symbol } = resolved.chain.nativeCurrency;
2177
1918
  if (accept.scheme === "exact" || accept.scheme === "upto") {
2178
- const m = _optionalChain([accept, 'access', _19 => _19.extra, 'optionalAccess', _20 => _20.assetTransferMethod]);
1919
+ const m = _optionalChain([accept, 'access', _20 => _20.extra, 'optionalAccess', _21 => _21.assetTransferMethod]);
2179
1920
  const permit2 = m === "permit2" || m === "permit2-exact" || m === "permit2-upto";
2180
- return _chunk3FR22M3Ocjs.nativeCost.call(void 0, {
1921
+ return _chunkQONQSZHJcjs.nativeCost.call(void 0, {
2181
1922
  symbol,
2182
1923
  decimals,
2183
1924
  fee: 0n,
@@ -2188,16 +1929,16 @@ function makeEvmNetwork(resolved) {
2188
1929
  const gasLimit = accept.asset === "native" ? 21000n : 65000n;
2189
1930
  try {
2190
1931
  const gasPrice = await publicClient.getGasPrice();
2191
- return _chunk3FR22M3Ocjs.nativeCost.call(void 0, {
1932
+ return _chunkQONQSZHJcjs.nativeCost.call(void 0, {
2192
1933
  symbol,
2193
1934
  decimals,
2194
1935
  fee: gasPrice * gasLimit,
2195
1936
  basis: "estimated",
2196
1937
  detail: `~${gasLimit} gas @ ${gasPrice} wei/gas`
2197
1938
  });
2198
- } catch (e23) {
1939
+ } catch (e21) {
2199
1940
  const gasPrice = 5000000000n;
2200
- return _chunk3FR22M3Ocjs.nativeCost.call(void 0, {
1941
+ return _chunkQONQSZHJcjs.nativeCost.call(void 0, {
2201
1942
  symbol,
2202
1943
  decimals,
2203
1944
  fee: gasPrice * gasLimit,
@@ -2218,7 +1959,7 @@ function makeEvmNetwork(resolved) {
2218
1959
  functionName: "balanceOf",
2219
1960
  args: [owner]
2220
1961
  });
2221
- } catch (e24) {
1962
+ } catch (e22) {
2222
1963
  token = null;
2223
1964
  }
2224
1965
  return { token, native };
@@ -2260,7 +2001,7 @@ function makeEvmNetwork(resolved) {
2260
2001
  // Throws UnsupportedSchemeError for a contract signer (or a non-EIP-3009 token on the eip3009 path).
2261
2002
  async payExact(wallet, accept) {
2262
2003
  const a = wallet._native;
2263
- const method = accept.extra.assetTransferMethod;
2004
+ const method = _chunkOXEFPLZAcjs.exactTransferMethod.call(void 0, accept);
2264
2005
  if (method === "permit2" || method === "permit2-exact") {
2265
2006
  const { payload: payload2, payerFrom: payerFrom2, nonce: nonce2 } = await payPermit2Evm({
2266
2007
  publicClient,
@@ -2296,7 +2037,19 @@ function makeEvmNetwork(resolved) {
2296
2037
  return resolveExactRailEvm({
2297
2038
  asset,
2298
2039
  method,
2299
- readDomain: (a) => readExactDomain(publicClient, a),
2040
+ // `readExactDomain` fails CLOSED to null on two very different causes: the token really
2041
+ // isn't EIP-3009, or the RPC read blipped (rate-limit, timeout, an HTML error page from a
2042
+ // proxy). Treating a blip as "not EIP-3009" silently downgrades a perfectly good gasless
2043
+ // rail to onchain-proof — the merchant's buyers start paying gas and the warning blames
2044
+ // their TOKEN, which is the one thing that isn't wrong. The buyer side already retries
2045
+ // once for exactly this reason (see payExactEvm); the gate side did not, so a rate-limited
2046
+ // public RPC could turn real Base USDC into "this token isn't EIP-3009". Mirror it.
2047
+ readDomain: async (a) => {
2048
+ const first = await readExactDomain(publicClient, a);
2049
+ if (first) return first;
2050
+ await new Promise((r) => setTimeout(r, 300));
2051
+ return readExactDomain(publicClient, a);
2052
+ },
2300
2053
  permit2Supported: () => isPermit2ProxyChain(resolved.chainId)
2301
2054
  });
2302
2055
  },
@@ -2321,6 +2074,9 @@ function makeEvmNetwork(resolved) {
2321
2074
  if ("signedDelegateAction" in payload) {
2322
2075
  return { ok: false, error: "signature_invalid", detail: "A NEAR payload was submitted to an EVM exact rail." };
2323
2076
  }
2077
+ if ("signedTxBlob" in payload) {
2078
+ return { ok: false, error: "signature_invalid", detail: "An XRPL payload was submitted to an EVM exact rail." };
2079
+ }
2324
2080
  return verifyAndSettleExactEvm({
2325
2081
  publicClient,
2326
2082
  walletClient: a.walletClient,
@@ -2382,9 +2138,9 @@ var loaders = {
2382
2138
  solana: async () => {
2383
2139
  let mod;
2384
2140
  try {
2385
- mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./solana-OU6IUMQM.cjs")));
2141
+ mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./solana-AI2G7V33.cjs")));
2386
2142
  } catch (cause) {
2387
- throw new (0, _chunk3FR22M3Ocjs.MissingDriverError)(
2143
+ throw new (0, _chunkQONQSZHJcjs.MissingDriverError)(
2388
2144
  `Solana selected, but its packages aren't installed. Run: npm install @solana/web3.js @solana/spl-token bs58`,
2389
2145
  { cause }
2390
2146
  );
@@ -2394,9 +2150,9 @@ var loaders = {
2394
2150
  ton: async () => {
2395
2151
  let mod;
2396
2152
  try {
2397
- mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./ton-MYOI3U3H.cjs")));
2153
+ mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./ton-J7TQWRN4.cjs")));
2398
2154
  } catch (cause) {
2399
- throw new (0, _chunk3FR22M3Ocjs.MissingDriverError)(
2155
+ throw new (0, _chunkQONQSZHJcjs.MissingDriverError)(
2400
2156
  `TON selected, but its packages aren't installed. Run: npm install @ton/ton @ton/core @ton/crypto`,
2401
2157
  { cause }
2402
2158
  );
@@ -2406,9 +2162,9 @@ var loaders = {
2406
2162
  stellar: async () => {
2407
2163
  let mod;
2408
2164
  try {
2409
- mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./stellar-RSNVOIKL.cjs")));
2165
+ mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./stellar-E2KWEV2E.cjs")));
2410
2166
  } catch (cause) {
2411
- throw new (0, _chunk3FR22M3Ocjs.MissingDriverError)(
2167
+ throw new (0, _chunkQONQSZHJcjs.MissingDriverError)(
2412
2168
  `Stellar selected, but its package isn't installed. Run: npm install @stellar/stellar-sdk`,
2413
2169
  { cause }
2414
2170
  );
@@ -2418,9 +2174,9 @@ var loaders = {
2418
2174
  xrpl: async () => {
2419
2175
  let mod;
2420
2176
  try {
2421
- mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./xrpl-MGUBUNSZ.cjs")));
2177
+ mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./xrpl-SVVS445B.cjs")));
2422
2178
  } catch (cause) {
2423
- throw new (0, _chunk3FR22M3Ocjs.MissingDriverError)(
2179
+ throw new (0, _chunkQONQSZHJcjs.MissingDriverError)(
2424
2180
  `XRPL selected, but its package isn't installed. Run: npm install xrpl`,
2425
2181
  { cause }
2426
2182
  );
@@ -2430,9 +2186,9 @@ var loaders = {
2430
2186
  tron: async () => {
2431
2187
  let mod;
2432
2188
  try {
2433
- mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./tron-42X5N4GQ.cjs")));
2189
+ mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./tron-HIPMOX7S.cjs")));
2434
2190
  } catch (cause) {
2435
- throw new (0, _chunk3FR22M3Ocjs.MissingDriverError)(
2191
+ throw new (0, _chunkQONQSZHJcjs.MissingDriverError)(
2436
2192
  `Tron selected, but its package isn't installed. Run: npm install tronweb`,
2437
2193
  { cause }
2438
2194
  );
@@ -2442,9 +2198,9 @@ var loaders = {
2442
2198
  sui: async () => {
2443
2199
  let mod;
2444
2200
  try {
2445
- mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./sui-MVC46BFJ.cjs")));
2201
+ mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./sui-Q3NJOJZS.cjs")));
2446
2202
  } catch (cause) {
2447
- throw new (0, _chunk3FR22M3Ocjs.MissingDriverError)(
2203
+ throw new (0, _chunkQONQSZHJcjs.MissingDriverError)(
2448
2204
  `Sui selected, but its package isn't installed. Run: npm install @mysten/sui`,
2449
2205
  { cause }
2450
2206
  );
@@ -2454,9 +2210,9 @@ var loaders = {
2454
2210
  near: async () => {
2455
2211
  let mod;
2456
2212
  try {
2457
- mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./near-NDQLGI4U.cjs")));
2213
+ mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./near-5LTTDU6G.cjs")));
2458
2214
  } catch (cause) {
2459
- throw new (0, _chunk3FR22M3Ocjs.MissingDriverError)(
2215
+ throw new (0, _chunkQONQSZHJcjs.MissingDriverError)(
2460
2216
  `NEAR selected, but its package isn't installed. Run: npm install near-api-js`,
2461
2217
  { cause }
2462
2218
  );
@@ -2466,9 +2222,9 @@ var loaders = {
2466
2222
  aptos: async () => {
2467
2223
  let mod;
2468
2224
  try {
2469
- mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./aptos-GA5AEYYL.cjs")));
2225
+ mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./aptos-VBJONBFY.cjs")));
2470
2226
  } catch (cause) {
2471
- throw new (0, _chunk3FR22M3Ocjs.MissingDriverError)(
2227
+ throw new (0, _chunkQONQSZHJcjs.MissingDriverError)(
2472
2228
  `Aptos selected, but its package isn't installed. Run: npm install @aptos-labs/ts-sdk`,
2473
2229
  { cause }
2474
2230
  );
@@ -2478,9 +2234,9 @@ var loaders = {
2478
2234
  algorand: async () => {
2479
2235
  let mod;
2480
2236
  try {
2481
- mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./algorand-I2O24RSM.cjs")));
2237
+ mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./algorand-Q3TUQLPK.cjs")));
2482
2238
  } catch (cause) {
2483
- throw new (0, _chunk3FR22M3Ocjs.MissingDriverError)(
2239
+ throw new (0, _chunkQONQSZHJcjs.MissingDriverError)(
2484
2240
  `Algorand selected, but its package isn't installed. Run: npm install algosdk`,
2485
2241
  { cause }
2486
2242
  );
@@ -2510,621 +2266,8 @@ async function resolveNetwork2(opts) {
2510
2266
  return resolveNetwork(opts);
2511
2267
  }
2512
2268
 
2513
- // src/indexes.ts
2514
- var DIRECTORY_INFO = Object.freeze({
2515
- "402index": {
2516
- source: "402index",
2517
- review: "probe-sync",
2518
- auth: "none",
2519
- chains: null,
2520
- onSuccess: "pending-review",
2521
- readByDiscover: true,
2522
- caveat: "402 Index probes your URL on submit (rejecting anything that does not return a real 402), then lists it \u2014 a self-registered resource becomes searchable once it passes automated health + payment-validity checks, with NO domain verification required (observed live: searchable within ~2 days for a healthy endpoint). Verify your domain on 402index.io for instant, guaranteed approval + a verified badge, which also flips every pending listing on that domain live at once."
2523
- },
2524
- x402scan: {
2525
- source: "x402scan",
2526
- review: "probe-sync",
2527
- auth: "siwx",
2528
- chains: ["eip155:8453", "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp"],
2529
- onSuccess: "live",
2530
- readByDiscover: false,
2531
- caveat: "x402scan lists Base/Solana only, needs one wallet signature (SIWX), and requires a resolvable input schema (from /openapi.json or the bazaar extension in the 402 body). It goes live on x402scan.com immediately on success \u2014 but discover() does NOT read x402scan, so the listing won't appear in discover() results."
2532
- },
2533
- bazaar: {
2534
- source: "bazaar",
2535
- review: "settle-coupled",
2536
- auth: "facilitator-only",
2537
- chains: null,
2538
- onSuccess: "not-listable",
2539
- readByDiscover: true,
2540
- caveat: "CDP Bazaar has no register endpoint \u2014 it catalogs a resource only when its own facilitator settles a payment. PipRail verifies locally with no facilitator, so a PipRail resource cannot be listed here (you can still READ Bazaar to find others). List on 402 Index or x402scan instead."
2541
- }
2542
- });
2543
- function getDirectoryInfo(source) {
2544
- return DIRECTORY_INFO[source];
2545
- }
2546
- function decorateOutcome(o) {
2547
- const info = DIRECTORY_INFO[o.source];
2548
- return { ...o, visibility: _nullishCoalesce(o.visibility, () => ( (o.ok ? info.onSuccess : "not-listable"))), note: info.caveat };
2549
- }
2550
- var BAZAAR_URL = "https://api.cdp.coinbase.com/platform/v2/x402/discovery/resources";
2551
- var INDEX402_SEARCH = "https://402index.io/api/v1/services";
2552
- var INDEX402_REGISTER = "https://402index.io/api/v1/register";
2553
- var INDEX402_CLAIM = "https://402index.io/api/v1/claim";
2554
- var INDEX402_VERIFY = "https://402index.io/api/v1/claim/verify";
2555
- var X402SCAN_REGISTER = "https://www.x402scan.com/api/x402/registry/register";
2556
- var USER_AGENT = "@piprail/sdk (+https://piprail.com)";
2557
- function clientHeaders(extra = {}) {
2558
- return { "user-agent": USER_AGENT, ...extra };
2559
- }
2560
- var SLUG_TO_CAIP2 = {
2561
- // EVM (the common index-reported slugs; others fall through to net.supports)
2562
- ethereum: "eip155:1",
2563
- base: "eip155:8453",
2564
- polygon: "eip155:137",
2565
- arbitrum: "eip155:42161",
2566
- optimism: "eip155:10",
2567
- avalanche: "eip155:43114",
2568
- bnb: "eip155:56",
2569
- bsc: "eip155:56",
2570
- // non-EVM families — values mirror each driver's bound caip2 exactly
2571
- solana: "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",
2572
- ton: "tvm:-239",
2573
- tron: "tron:mainnet",
2574
- near: "near:mainnet",
2575
- sui: "sui:mainnet",
2576
- aptos: "aptos:1",
2577
- algorand: "algorand:wGHE2Pwdvd7S12BL5FaOP20EGYesN73ktiC1qzkkit8=",
2578
- stellar: "stellar:pubnet",
2579
- xrpl: "xrpl:0"
2580
- };
2581
- var LEGACY_CAIP2_ALIAS = {
2582
- "ton:-239": "tvm:-239"
2583
- };
2584
- function normalizeNetwork(network) {
2585
- const legacy = LEGACY_CAIP2_ALIAS[network];
2586
- if (legacy) return legacy;
2587
- if (network.includes(":")) return network;
2588
- return _nullishCoalesce(SLUG_TO_CAIP2[network.toLowerCase()], () => ( network));
2589
- }
2590
- async function searchOpenIndexes(opts = {}) {
2591
- const sources = _nullishCoalesce(opts.sources, () => ( ["bazaar", "402index"]));
2592
- const limit = _nullishCoalesce(opts.limit, () => ( 20));
2593
- const filters = {
2594
- ...optionalRaw("category", opts.category),
2595
- ...optionalRaw("asset", opts.asset),
2596
- ...optionalRaw("maxPrice", opts.maxPrice),
2597
- ...optionalRaw("verified", opts.verified),
2598
- ...optionalRaw("paymentValid", opts.paymentValid),
2599
- ...optionalRaw("sort", opts.sort),
2600
- ...optionalRaw("order", opts.order)
2601
- };
2602
- const results = await Promise.all(
2603
- sources.map((source) => {
2604
- if (source === "bazaar") return safeSearch(() => searchBazaar(opts.query, limit, opts.signal));
2605
- if (source === "402index") return safeSearch(() => search402Index(opts.query, limit, filters, opts.signal));
2606
- return Promise.resolve([]);
2607
- })
2608
- );
2609
- const merged = applyClientFilters(dedupeByResource(results.flat()), opts);
2610
- const wantRelevance = opts.query !== void 0 && (_nullishCoalesce(opts.sort, () => ( "relevance"))) === "relevance";
2611
- if (wantRelevance) return rankResources(merged, opts.query);
2612
- if (opts.sort && opts.sort !== "relevance") return sortResources(merged, opts.sort, _nullishCoalesce(opts.order, () => ( "desc")));
2613
- return merged;
2614
- }
2615
- function optionalRaw(field, value) {
2616
- return value !== void 0 ? { [field]: value } : {};
2617
- }
2618
- function applyClientFilters(items, opts) {
2619
- let out = items;
2620
- if (opts.category) {
2621
- const want = opts.category.toLowerCase();
2622
- out = out.filter((r) => r.category !== void 0 && r.category.toLowerCase().startsWith(want));
2623
- }
2624
- if (opts.maxPrice !== void 0) {
2625
- const max = opts.maxPrice;
2626
- out = out.filter((r) => r.priceUsd === void 0 || r.priceUsd <= max);
2627
- }
2628
- if (opts.asset) {
2629
- const want = opts.asset.toLowerCase();
2630
- out = out.filter((r) => {
2631
- const known = r.rails.map((x) => _nullishCoalesce(x.symbol, () => ( x.asset))).filter((a) => !!a);
2632
- return known.length === 0 || known.some((a) => a.toLowerCase() === want);
2633
- });
2634
- }
2635
- if (opts.minReliability !== void 0) {
2636
- const min = opts.minReliability;
2637
- out = out.filter((r) => r.reliabilityScore === void 0 || r.reliabilityScore >= min);
2638
- }
2639
- return out;
2640
- }
2641
- function tokenize(s) {
2642
- return _nullishCoalesce((_nullishCoalesce(s, () => ( ""))).toLowerCase().match(/[a-z0-9]+/g), () => ( []));
2643
- }
2644
- var FIELD_WEIGHTS = { name: 6, category: 4, tags: 4, path: 3, description: 2 };
2645
- function fieldTokens(r) {
2646
- let pathText = r.resource;
2647
- try {
2648
- const u = new URL(r.resource);
2649
- pathText = `${u.hostname} ${u.pathname}`;
2650
- } catch (e25) {
2651
- }
2652
- return [
2653
- [tokenize(r.name), FIELD_WEIGHTS.name],
2654
- [tokenize(r.category), FIELD_WEIGHTS.category],
2655
- [tokenize((_nullishCoalesce(r.tags, () => ( []))).join(" ")), FIELD_WEIGHTS.tags],
2656
- [tokenize(pathText), FIELD_WEIGHTS.path],
2657
- [tokenize(r.description), FIELD_WEIGHTS.description]
2658
- ];
2659
- }
2660
- function scoreResource(r, queryTokens) {
2661
- if (queryTokens.length === 0) return 0;
2662
- const fields = fieldTokens(r);
2663
- let score = 0;
2664
- let matched = 0;
2665
- for (const qt of queryTokens) {
2666
- let hit = false;
2667
- for (const [toks, w] of fields) {
2668
- if (toks.includes(qt)) {
2669
- score += w;
2670
- hit = true;
2671
- } else if (qt.length >= 4 && toks.some((t) => t.startsWith(qt) || t.length >= 4 && qt.startsWith(t))) {
2672
- score += w * 0.4;
2673
- hit = true;
2674
- }
2675
- }
2676
- if (hit) matched++;
2677
- }
2678
- if (matched === 0) return 0;
2679
- if (matched === queryTokens.length) score += 8;
2680
- if (r.reliabilityScore !== void 0) score += r.reliabilityScore / 1e3;
2681
- return score;
2682
- }
2683
- function rankResources(items, query) {
2684
- const qTokens = tokenize(query);
2685
- if (qTokens.length === 0) return items;
2686
- return items.map((r, i) => ({ r, i, s: scoreResource(r, qTokens) })).filter((x) => x.s > 0).sort((a, b) => b.s - a.s || a.i - b.i).map((x) => ({ ...x.r, score: x.s }));
2687
- }
2688
- function sortResources(items, sort, order) {
2689
- const dir = order === "asc" ? 1 : -1;
2690
- const key = (r) => sort === "reliability" || sort === "uptime" ? r.reliabilityScore : sort === "price" ? r.priceUsd : sort === "name" ? (_nullishCoalesce(r.name, () => ( r.resource))).toLowerCase() : void 0;
2691
- return items.map((r, i) => ({ r, i })).sort((a, b) => {
2692
- const ka = key(a.r);
2693
- const kb = key(b.r);
2694
- if (ka === void 0 && kb === void 0) return a.i - b.i;
2695
- if (ka === void 0) return 1;
2696
- if (kb === void 0) return -1;
2697
- if (ka < kb) return -1 * dir;
2698
- if (ka > kb) return 1 * dir;
2699
- return a.i - b.i;
2700
- }).map((x) => x.r);
2701
- }
2702
- async function safeSearch(run) {
2703
- try {
2704
- return await run();
2705
- } catch (e26) {
2706
- return [];
2707
- }
2708
- }
2709
- function dedupeByResource(items) {
2710
- const seen = /* @__PURE__ */ new Set();
2711
- const out = [];
2712
- for (const it of items) {
2713
- const key = it.resource;
2714
- if (!key || seen.has(key)) continue;
2715
- seen.add(key);
2716
- out.push(it);
2717
- }
2718
- return out;
2719
- }
2720
- async function searchBazaar(query, limit, signal) {
2721
- const res = await fetch(`${BAZAAR_URL}?limit=${encodeURIComponent(String(limit))}`, {
2722
- headers: clientHeaders({ accept: "application/json" }),
2723
- ...signal ? { signal } : {}
2724
- });
2725
- if (!res.ok) return [];
2726
- const body = await res.json();
2727
- const items = Array.isArray(body.items) ? body.items : [];
2728
- const mapped = items.map(mapBazaarItem).filter((r) => r !== null);
2729
- return query ? mapped.filter((r) => matchesQuery(r, query)) : mapped;
2730
- }
2731
- function mapBazaarItem(raw) {
2732
- if (!raw || typeof raw !== "object") return null;
2733
- const o = raw;
2734
- const resource = pickString(o, "resource", "url", "endpoint");
2735
- if (!resource) return null;
2736
- const meta = o.metadata && typeof o.metadata === "object" ? o.metadata : {};
2737
- return {
2738
- resource,
2739
- source: "bazaar",
2740
- rails: mapRails(o.accepts),
2741
- ...optionalString("name", pickString(meta, "name", "title")),
2742
- ...optionalString("description", _nullishCoalesce(pickString(meta, "description"), () => ( pickString(o, "description")))),
2743
- ...optionalString("category", pickString(meta, "category"))
2744
- };
2745
- }
2746
- async function search402Index(query, limit, filters, signal) {
2747
- const tokens = tokenize(query);
2748
- const queries = query && tokens.length > 1 ? [.../* @__PURE__ */ new Set([query, ...tokens])].slice(0, 5) : [query];
2749
- const pages = await Promise.all(queries.map((q) => safeSearch(() => fetch402Page(q, limit, filters, signal))));
2750
- return dedupeByResource(pages.flat());
2751
- }
2752
- async function fetch402Page(query, limit, filters, signal) {
2753
- const qs = new URLSearchParams({ limit: String(limit) });
2754
- if (query) qs.set("q", query);
2755
- if (filters.category) qs.set("category", filters.category);
2756
- if (filters.asset) qs.set("payment_asset", filters.asset);
2757
- if (filters.maxPrice !== void 0) qs.set("max_price_usd", String(filters.maxPrice));
2758
- if (filters.verified) qs.set("verified", "true");
2759
- if (filters.paymentValid) qs.set("payment_valid", "true");
2760
- if (filters.sort && filters.sort !== "relevance") {
2761
- qs.set("sort", filters.sort);
2762
- qs.set("order", _nullishCoalesce(filters.order, () => ( "desc")));
2763
- }
2764
- const res = await fetch(`${INDEX402_SEARCH}?${qs.toString()}`, {
2765
- headers: clientHeaders({ accept: "application/json" }),
2766
- ...signal ? { signal } : {}
2767
- });
2768
- if (!res.ok) return [];
2769
- const body = await res.json();
2770
- const list = firstArray(body, "services", "results", "items", "data");
2771
- return list.map(map402IndexItem).filter((r) => r !== null).filter((r) => r.rails.length > 0);
2772
- }
2773
- function map402IndexItem(raw) {
2774
- if (!raw || typeof raw !== "object") return null;
2775
- const o = raw;
2776
- const resource = pickString(o, "url", "resource", "endpoint");
2777
- if (!resource) return null;
2778
- const protocol = (_nullishCoalesce(pickString(o, "protocol"), () => ( "x402"))).toLowerCase();
2779
- if (protocol !== "x402") return null;
2780
- const rails = Array.isArray(o.accepts) ? mapRails(o.accepts) : railFrom402IndexFields(o);
2781
- const priceUsd = pickNumber(o, "price_usd", "priceUsd", "price");
2782
- const reliabilityScore = pickNumber(o, "reliability_score", "reliabilityScore");
2783
- const tags = pickStringArray(o, "tags", "keywords");
2784
- return {
2785
- resource,
2786
- source: "402index",
2787
- rails,
2788
- ...priceUsd !== void 0 ? { priceUsd } : {},
2789
- ...reliabilityScore !== void 0 ? { reliabilityScore } : {},
2790
- ...tags ? { tags } : {},
2791
- ...optionalString("name", pickString(o, "name", "title")),
2792
- ...optionalString("description", pickString(o, "description")),
2793
- ...optionalString("category", pickString(o, "category", "tag")),
2794
- ...optionalString("health", pickString(o, "health_status", "health")),
2795
- // 402 Index reports domain_verified as 0/1; surface a boolean only when the field is present.
2796
- ...o.domain_verified !== void 0 || o.verified !== void 0 ? { verified: isTruthyFlag(o.domain_verified) || isTruthyFlag(o.verified) } : {}
2797
- };
2798
- }
2799
- function isTruthyFlag(v) {
2800
- return v === 1 || v === true || v === "1" || v === "true";
2801
- }
2802
- function railFrom402IndexFields(o) {
2803
- const network = pickString(o, "payment_network", "network");
2804
- const asset = pickString(o, "payment_asset", "asset", "token");
2805
- if (!network && !asset) return [];
2806
- return [
2807
- {
2808
- scheme: "exact",
2809
- network: _nullishCoalesce(network, () => ( "unknown")),
2810
- ...asset ? { asset } : {},
2811
- ...optionalString("symbol", asset)
2812
- }
2813
- ];
2814
- }
2815
- async function register402Index(input) {
2816
- try {
2817
- const attributionOn = input.attribution !== false;
2818
- const withTags = appendKeywords(input.description, input.tags);
2819
- const description = attributionOn ? appendAttribution(withTags) : withTags;
2820
- const payload = {
2821
- url: input.url,
2822
- name: _nullishCoalesce(input.name, () => ( hostOf(input.url))),
2823
- protocol: "x402",
2824
- ...description ? { description } : {},
2825
- ...typeof input.priceUsd === "number" ? { price_usd: input.priceUsd } : {},
2826
- ...input.asset ? { payment_asset: input.asset } : {},
2827
- ...input.network ? { payment_network: input.network } : {},
2828
- ...input.method ? { http_method: input.method.toUpperCase() } : {},
2829
- ...input.category ? { category: input.category } : {},
2830
- ...input.tags && input.tags.length > 0 ? { tags: input.tags } : {},
2831
- ...input.provider ? { provider: input.provider } : {},
2832
- ...input.contactEmail ? { contact_email: input.contactEmail } : {},
2833
- ...input.probeBody !== void 0 ? { probe_body: input.probeBody } : {},
2834
- ...attributionOn ? { via: "@piprail/sdk" } : {}
2835
- };
2836
- const res = await fetch(INDEX402_REGISTER, {
2837
- method: "POST",
2838
- headers: clientHeaders({ "content-type": "application/json", accept: "application/json" }),
2839
- body: JSON.stringify(payload)
2840
- });
2841
- if (res.ok) {
2842
- const body = await res.json().catch(() => ({}));
2843
- const msg = typeof body.message === "string" && body.message.length > 0 ? body.message : void 0;
2844
- const live = _optionalChain([body, 'access', _21 => _21.service, 'optionalAccess', _22 => _22.status]) === "active";
2845
- return {
2846
- source: "402index",
2847
- ok: true,
2848
- status: res.status,
2849
- ...live ? { visibility: "live" } : {},
2850
- detail: _nullishCoalesce(msg, () => ( (live ? "Registered + live on 402 Index (domain verified)." : "Registered on 402 Index \u2014 probed on submit, then searchable once it passes automated health + payment checks (verify your domain on 402index.io for instant approval + a verified badge).")))
2851
- };
2852
- }
2853
- const why = await readIndexError(res);
2854
- return {
2855
- source: "402index",
2856
- ok: false,
2857
- status: res.status,
2858
- detail: why ? `402 Index rejected it (HTTP ${res.status}): ${why}` : `402 Index returned HTTP ${res.status}.`
2859
- };
2860
- } catch (err) {
2861
- return { source: "402index", ok: false, detail: errMsg(err) };
2862
- }
2863
- }
2864
- async function readIndexError(res) {
2865
- try {
2866
- const body = await res.json();
2867
- const parts = [body.error, body.detail, body.message].filter(
2868
- (p) => typeof p === "string" && p.length > 0
2869
- );
2870
- return parts.length ? [...new Set(parts)].join(" \u2014 ") : void 0;
2871
- } catch (e27) {
2872
- return void 0;
2873
- }
2874
- }
2875
- async function registerX402Scan(input, signer) {
2876
- try {
2877
- const challengeRes = await fetch(X402SCAN_REGISTER, {
2878
- method: "POST",
2879
- headers: clientHeaders({ "content-type": "application/json", accept: "application/json" }),
2880
- body: JSON.stringify({ url: input.url })
2881
- });
2882
- if (challengeRes.status !== 402) {
2883
- return {
2884
- source: "x402scan",
2885
- ok: challengeRes.ok,
2886
- status: challengeRes.status,
2887
- detail: challengeRes.ok ? "Listed on x402scan." : `x402scan returned HTTP ${challengeRes.status} (expected a SIWX 402 challenge).`
2888
- };
2889
- }
2890
- const info = await readSiwxInfo(challengeRes);
2891
- if (!info) {
2892
- return { source: "x402scan", ok: false, status: 402, detail: "x402scan SIWX challenge was unparseable." };
2893
- }
2894
- const resolvedInfo = { ...info, issuedAt: _nullishCoalesce(info.issuedAt, () => ( (/* @__PURE__ */ new Date()).toISOString())) };
2895
- const message = formatSiweMessage(resolvedInfo, signer.address);
2896
- const signature = await signer.signMessage(message);
2897
- const header = encodeBase642(
2898
- JSON.stringify({ ...resolvedInfo, address: signer.address, type: "eip191", message, signature })
2899
- );
2900
- const res = await fetch(X402SCAN_REGISTER, {
2901
- method: "POST",
2902
- headers: clientHeaders({
2903
- "content-type": "application/json",
2904
- accept: "application/json",
2905
- "sign-in-with-x": header
2906
- }),
2907
- body: JSON.stringify({ url: input.url })
2908
- });
2909
- if (res.ok) {
2910
- return { source: "x402scan", ok: true, status: res.status, detail: "Listed on x402scan (SIWX)." };
2911
- }
2912
- const why = await readIndexError(res);
2913
- return {
2914
- source: "x402scan",
2915
- ok: false,
2916
- status: res.status,
2917
- detail: why ? `x402scan rejected it (HTTP ${res.status}): ${why}` : `x402scan returned HTTP ${res.status} after signing.`
2918
- };
2919
- } catch (err) {
2920
- return { source: "x402scan", ok: false, detail: errMsg(err) };
2921
- }
2922
- }
2923
- async function claim402IndexDomain(domainOrUrl, opts = {}) {
2924
- const domain = hostOf(domainOrUrl);
2925
- try {
2926
- const res = await fetch(INDEX402_CLAIM, {
2927
- method: "POST",
2928
- headers: clientHeaders({ "content-type": "application/json", accept: "application/json" }),
2929
- body: JSON.stringify({ domain, ...opts.contactEmail ? { contact_email: opts.contactEmail } : {} })
2930
- });
2931
- const body = await res.json().catch(() => ({}));
2932
- if (!res.ok) {
2933
- return { ok: false, domain, httpStatus: res.status, detail: _nullishCoalesce(pickString(body, "error", "detail", "message"), () => ( `402 Index claim returned HTTP ${res.status}.`)) };
2934
- }
2935
- const verificationToken = pickString(body, "verification_token");
2936
- const verificationHash = await _asyncNullishCoalesce(pickString(body, "verification_hash"), async () => ( (verificationToken ? await sha256Hex(verificationToken) : void 0)));
2937
- return {
2938
- ok: true,
2939
- domain,
2940
- httpStatus: res.status,
2941
- ...optionalString("verificationHash", verificationHash),
2942
- ...optionalString("verificationToken", verificationToken),
2943
- ...optionalString("verificationUrl", pickString(body, "verification_url")),
2944
- ...optionalString("instructions", pickString(body, "instructions"))
2945
- };
2946
- } catch (err) {
2947
- return { ok: false, domain, detail: errMsg(err) };
2948
- }
2949
- }
2950
- async function sha256Hex(input) {
2951
- const digest = await globalThis.crypto.subtle.digest("SHA-256", new TextEncoder().encode(input));
2952
- return Array.from(new Uint8Array(digest)).map((b) => b.toString(16).padStart(2, "0")).join("");
2953
- }
2954
- async function verify402IndexDomain(domainOrUrl) {
2955
- const domain = hostOf(domainOrUrl);
2956
- try {
2957
- const res = await fetch(INDEX402_VERIFY, {
2958
- method: "POST",
2959
- headers: clientHeaders({ "content-type": "application/json", accept: "application/json" }),
2960
- body: JSON.stringify({ domain })
2961
- });
2962
- const body = await res.json().catch(() => ({}));
2963
- if (!res.ok) {
2964
- return { ok: false, domain, httpStatus: res.status, detail: _nullishCoalesce(pickString(body, "error", "detail", "message"), () => ( `402 Index verify returned HTTP ${res.status}.`)) };
2965
- }
2966
- return {
2967
- ok: true,
2968
- domain,
2969
- httpStatus: res.status,
2970
- ...optionalString("status", pickString(body, "status")),
2971
- ...typeof body.services_count === "number" ? { servicesCount: body.services_count } : {}
2972
- };
2973
- } catch (err) {
2974
- return { ok: false, domain, detail: errMsg(err) };
2975
- }
2976
- }
2977
- async function readSiwxInfo(res) {
2978
- try {
2979
- const body = await res.json();
2980
- const ext = body.extensions;
2981
- const siwx = _optionalChain([ext, 'optionalAccess', _23 => _23["sign-in-with-x"]]);
2982
- const info = _nullishCoalesce(_optionalChain([siwx, 'optionalAccess', _24 => _24.info]), () => ( siwx));
2983
- if (info && info.chainId == null && Array.isArray(_optionalChain([siwx, 'optionalAccess', _25 => _25.supportedChains]))) {
2984
- const evm = siwx.supportedChains.find(
2985
- (c) => typeof _optionalChain([c, 'optionalAccess', _26 => _26.chainId]) === "string" && c.chainId.startsWith("eip155:")
2986
- );
2987
- if (evm && typeof evm.chainId === "string") info.chainId = evm.chainId;
2988
- }
2989
- if (info && typeof info.domain === "string" && info.domain.length > 0 && typeof info.nonce === "string" && info.nonce.length > 0 && typeof info.uri === "string" && info.uri.length > 0) {
2990
- return info;
2991
- }
2992
- return null;
2993
- } catch (e28) {
2994
- return null;
2995
- }
2996
- }
2997
- function formatSiweMessage(info, address) {
2998
- const chainId = info.chainId ? caip2ToChainId(info.chainId) : 1;
2999
- const statement = info.statement && info.statement.trim() ? info.statement : void 0;
3000
- const lines = [
3001
- `${info.domain} wants you to sign in with your Ethereum account:`,
3002
- address,
3003
- "",
3004
- ...statement ? [statement, ""] : [""],
3005
- `URI: ${info.uri}`,
3006
- "Version: 1",
3007
- `Chain ID: ${chainId}`,
3008
- `Nonce: ${info.nonce}`,
3009
- `Issued At: ${info.issuedAt}`,
3010
- ...info.expirationTime ? [`Expiration Time: ${info.expirationTime}`] : []
3011
- ];
3012
- return lines.join("\n");
3013
- }
3014
- function caip2ToChainId(caip2) {
3015
- const m = /^eip155:(\d+)$/.exec(caip2);
3016
- const n = m ? Number(m[1]) : Number(caip2);
3017
- return Number.isSafeInteger(n) && n > 0 ? n : 1;
3018
- }
3019
- function mapRails(accepts) {
3020
- if (!Array.isArray(accepts)) return [];
3021
- const out = [];
3022
- for (const raw of accepts) {
3023
- if (!raw || typeof raw !== "object") continue;
3024
- const a = raw;
3025
- const network = pickString(a, "network");
3026
- if (!network) continue;
3027
- const extra = a.extra && typeof a.extra === "object" ? a.extra : {};
3028
- out.push({
3029
- scheme: _nullishCoalesce(pickString(a, "scheme"), () => ( "exact")),
3030
- network,
3031
- ...optionalString("asset", pickString(a, "asset")),
3032
- ...optionalString("amount", pickString(a, "amount", "maxAmountRequired")),
3033
- ...optionalString("payTo", pickString(a, "payTo")),
3034
- ...optionalString("symbol", pickString(extra, "symbol"))
3035
- });
3036
- }
3037
- return out;
3038
- }
3039
- function matchesQuery(r, query) {
3040
- const haystack = [r.name, r.description, r.category, (_nullishCoalesce(r.tags, () => ( []))).join(" "), r.resource].filter(Boolean).join(" ").toLowerCase();
3041
- if (haystack.includes(query.toLowerCase())) return true;
3042
- const qTokens = tokenize(query);
3043
- const hayTokens = new Set(tokenize(haystack));
3044
- return qTokens.some((t) => hayTokens.has(t));
3045
- }
3046
- function pickStringArray(o, ...keys) {
3047
- for (const k of keys) {
3048
- const v = o[k];
3049
- if (Array.isArray(v)) {
3050
- const arr = v.filter((x) => typeof x === "string" && x.length > 0);
3051
- if (arr.length) return arr;
3052
- } else if (typeof v === "string" && v.trim()) {
3053
- const arr = v.split(/[,\s]+/).filter((x) => x.length > 0);
3054
- if (arr.length) return arr;
3055
- }
3056
- }
3057
- return void 0;
3058
- }
3059
- function pickString(o, ...keys) {
3060
- for (const k of keys) {
3061
- const v = o[k];
3062
- if (typeof v === "string" && v.length > 0) return v;
3063
- }
3064
- return void 0;
3065
- }
3066
- function pickNumber(o, ...keys) {
3067
- for (const k of keys) {
3068
- const v = o[k];
3069
- if (typeof v === "number" && Number.isFinite(v)) return v;
3070
- if (typeof v === "string" && /^\d+(\.\d+)?$/.test(v.trim())) {
3071
- const n = Number(v.trim());
3072
- if (Number.isFinite(n)) return n;
3073
- }
3074
- }
3075
- return void 0;
3076
- }
3077
- function optionalString(field, value) {
3078
- return value !== void 0 ? { [field]: value } : {};
3079
- }
3080
- function firstArray(o, ...keys) {
3081
- for (const k of keys) {
3082
- if (Array.isArray(o[k])) return o[k];
3083
- }
3084
- return Array.isArray(o) ? o : [];
3085
- }
3086
- function hostOf(url) {
3087
- try {
3088
- const withScheme = /^[a-z][a-z0-9+.-]*:\/\//i.test(url) ? url : `https://${url}`;
3089
- return new URL(withScheme).hostname || url;
3090
- } catch (e29) {
3091
- return url;
3092
- }
3093
- }
3094
- function errMsg(err) {
3095
- return err instanceof Error ? err.message : String(err);
3096
- }
3097
- var REGISTER_ATTRIBUTION = "\xB7 Built with @piprail/sdk";
3098
- function appendAttribution(description) {
3099
- if (!description) return description;
3100
- if (/piprail/i.test(description)) return description;
3101
- const next = `${description.trimEnd()} ${REGISTER_ATTRIBUTION}`;
3102
- return next.length <= 500 ? next : description;
3103
- }
3104
- function appendKeywords(description, tags) {
3105
- const clean = (_nullishCoalesce(tags, () => ( []))).map((t) => t.trim()).filter((t) => t.length > 0);
3106
- if (clean.length === 0) return description;
3107
- const have = (_nullishCoalesce(description, () => ( ""))).toLowerCase();
3108
- const fresh = [...new Set(clean.filter((t) => !have.includes(t.toLowerCase())))];
3109
- if (fresh.length === 0) return description;
3110
- const tail = `Keywords: ${fresh.join(", ")}`;
3111
- if (!description) return tail;
3112
- const next = `${description.trimEnd()} \xB7 ${tail}`;
3113
- return next.length <= 500 ? next : description;
3114
- }
3115
- function encodeBase642(str) {
3116
- if (typeof Buffer !== "undefined") return Buffer.from(str, "utf8").toString("base64");
3117
- if (typeof btoa === "function" && typeof TextEncoder !== "undefined") {
3118
- const bytes = new TextEncoder().encode(str);
3119
- let binary = "";
3120
- for (let i = 0; i < bytes.length; i++) binary += String.fromCharCode(bytes[i]);
3121
- return btoa(binary);
3122
- }
3123
- throw new Error("No base64 encoder available in this runtime.");
3124
- }
3125
-
3126
2269
  // src/policy.ts
3127
- var DENOM_PRECISION = _chunk3FR22M3Ocjs.MAX_DECIMALS;
2270
+ var DENOM_PRECISION = _chunkQONQSZHJcjs.MAX_DECIMALS;
3128
2271
  var BUILTIN_DENOMS = {
3129
2272
  USDC: "USD",
3130
2273
  USDT: "USD",
@@ -3138,7 +2281,7 @@ var BUILTIN_DENOMS = {
3138
2281
  function denomOf(symbol, asset, policy) {
3139
2282
  if (asset === "native") return void 0;
3140
2283
  const norm = (v) => typeof v === "string" && v.trim() !== "" ? v.trim().toUpperCase() : void 0;
3141
- const override = _optionalChain([policy, 'optionalAccess', _27 => _27.denomFor]);
2284
+ const override = _optionalChain([policy, 'optionalAccess', _22 => _22.denomFor]);
3142
2285
  if (override && typeof override === "object") {
3143
2286
  if (asset && asset in override) {
3144
2287
  const d = norm(override[asset]);
@@ -3239,7 +2382,7 @@ function evaluatePolicy(intent, policy, spentForAssetBase, ctx) {
3239
2382
  }
3240
2383
  }
3241
2384
  if (policy.maxAmount !== void 0) {
3242
- const cap = _chunk3FR22M3Ocjs.floorUnits.call(void 0, policy.maxAmount, intent.decimals);
2385
+ const cap = _chunkQONQSZHJcjs.floorUnits.call(void 0, policy.maxAmount, intent.decimals);
3243
2386
  if (intent.amountBase > cap) {
3244
2387
  return deny(
3245
2388
  "MAX_AMOUNT",
@@ -3248,7 +2391,7 @@ function evaluatePolicy(intent, policy, spentForAssetBase, ctx) {
3248
2391
  }
3249
2392
  }
3250
2393
  if (policy.maxTotal !== void 0) {
3251
- const cap = _chunk3FR22M3Ocjs.floorUnits.call(void 0, policy.maxTotal, intent.decimals);
2394
+ const cap = _chunkQONQSZHJcjs.floorUnits.call(void 0, policy.maxTotal, intent.decimals);
3252
2395
  if (spentForAssetBase + intent.amountBase > cap) {
3253
2396
  return deny(
3254
2397
  "MAX_TOTAL",
@@ -3267,7 +2410,7 @@ function evaluatePolicy(intent, policy, spentForAssetBase, ctx) {
3267
2410
  `token for ${denom} has more than ${DENOM_PRECISION} decimals \u2014 refusing to count it toward policy.maxTotalPerDenom.${denom} on trust (it can't be summed safely).`
3268
2411
  );
3269
2412
  }
3270
- const capScaled = _chunk3FR22M3Ocjs.floorUnits.call(void 0, capStr, DENOM_PRECISION);
2413
+ const capScaled = _chunkQONQSZHJcjs.floorUnits.call(void 0, capStr, DENOM_PRECISION);
3271
2414
  if ((_nullishCoalesce(ctx.spentInDenomScaled, () => ( 0n))) + thisScaled > capScaled) {
3272
2415
  return deny(
3273
2416
  "MAX_TOTAL_DENOM",
@@ -3285,7 +2428,7 @@ function evaluatePolicy(intent, policy, spentForAssetBase, ctx) {
3285
2428
  }
3286
2429
  }
3287
2430
  if (ctx && policy.windowTotal !== void 0 && policy.windowSeconds !== void 0) {
3288
- const cap = _chunk3FR22M3Ocjs.floorUnits.call(void 0, policy.windowTotal, intent.decimals);
2431
+ const cap = _chunkQONQSZHJcjs.floorUnits.call(void 0, policy.windowTotal, intent.decimals);
3289
2432
  if (ctx.spentInWindowBase + intent.amountBase > cap) {
3290
2433
  return deny(
3291
2434
  "WINDOW_TOTAL",
@@ -3336,10 +2479,10 @@ var SpendLedger = (_class = class {
3336
2479
  let seed = [];
3337
2480
  try {
3338
2481
  seed = _nullishCoalesce(store.load(), () => ( []));
3339
- } catch (e30) {
2482
+ } catch (e23) {
3340
2483
  seed = [];
3341
2484
  }
3342
- for (const r of seed) this.ingest(r, _nullishCoalesce(_optionalChain([r, 'optionalAccess', _28 => _28.decimals]), () => ( 0)), _optionalChain([r, 'optionalAccess', _29 => _29.denom]));
2485
+ for (const r of seed) this.ingest(r, _nullishCoalesce(_optionalChain([r, 'optionalAccess', _23 => _23.decimals]), () => ( 0)), _optionalChain([r, 'optionalAccess', _24 => _24.denom]));
3343
2486
  }
3344
2487
  }
3345
2488
  /**
@@ -3351,7 +2494,7 @@ var SpendLedger = (_class = class {
3351
2494
  * read or the constructor.
3352
2495
  */
3353
2496
  isTallyable(r, decimals) {
3354
- return !!r && typeof r.amountBase === "string" && /^\d+$/.test(r.amountBase) && Number.isInteger(decimals) && decimals >= 0 && decimals <= _chunk3FR22M3Ocjs.MAX_DECIMALS;
2497
+ return !!r && typeof r.amountBase === "string" && /^\d+$/.test(r.amountBase) && Number.isInteger(decimals) && decimals >= 0 && decimals <= _chunkQONQSZHJcjs.MAX_DECIMALS;
3355
2498
  }
3356
2499
  /** Apply a record to the in-memory tallies (records + per-asset bucket + denom total).
3357
2500
  * Shared by {@link record} and constructor hydration; does NOT persist. Returns the
@@ -3395,13 +2538,13 @@ var SpendLedger = (_class = class {
3395
2538
  if (rec && this.store) {
3396
2539
  try {
3397
2540
  this.store.append(rec);
3398
- } catch (e31) {
2541
+ } catch (e24) {
3399
2542
  }
3400
2543
  }
3401
2544
  }
3402
2545
  /** Running total (base units) already spent on this (network, asset). */
3403
2546
  totalFor(network, asset) {
3404
- return _nullishCoalesce(_optionalChain([this, 'access', _30 => _30.buckets, 'access', _31 => _31.get, 'call', _32 => _32(keyFor(network, asset)), 'optionalAccess', _33 => _33.total]), () => ( 0n));
2547
+ return _nullishCoalesce(_optionalChain([this, 'access', _25 => _25.buckets, 'access', _26 => _26.get, 'call', _27 => _27(keyFor(network, asset)), 'optionalAccess', _28 => _28.total]), () => ( 0n));
3405
2548
  }
3406
2549
  /**
3407
2550
  * Running grand total for a DENOMINATION, scaled to {@link DENOM_PRECISION} (so
@@ -3488,14 +2631,14 @@ var SpendLedger = (_class = class {
3488
2631
  symbol: b.symbol,
3489
2632
  decimals: b.decimals,
3490
2633
  totalBase: b.total.toString(),
3491
- totalFormatted: _chunk3FR22M3Ocjs.formatUnits.call(void 0, b.total, b.decimals),
2634
+ totalFormatted: _chunkQONQSZHJcjs.formatUnits.call(void 0, b.total, b.decimals),
3492
2635
  count: b.count
3493
2636
  })),
3494
2637
  byDenom: [...this.denomTotals.entries()].map(([denom, scaled]) => ({
3495
2638
  denom,
3496
2639
  totalScaled: scaled.toString(),
3497
- totalFormatted: _chunk3FR22M3Ocjs.formatUnits.call(void 0, scaled, DENOM_PRECISION),
3498
- count: this.records.filter((r) => _optionalChain([r, 'access', _34 => _34.denom, 'optionalAccess', _35 => _35.toUpperCase, 'call', _36 => _36()]) === denom).length
2640
+ totalFormatted: _chunkQONQSZHJcjs.formatUnits.call(void 0, scaled, DENOM_PRECISION),
2641
+ count: this.records.filter((r) => _optionalChain([r, 'access', _29 => _29.denom, 'optionalAccess', _30 => _30.toUpperCase, 'call', _31 => _31()]) === denom).length
3499
2642
  })),
3500
2643
  records: [...this.records]
3501
2644
  };
@@ -3692,7 +2835,7 @@ var PipRailClient = (_class2 = class {
3692
2835
  safeEmit(event) {
3693
2836
  try {
3694
2837
  this.onEvent(event);
3695
- } catch (e32) {
2838
+ } catch (e25) {
3696
2839
  }
3697
2840
  }
3698
2841
  /**
@@ -3703,9 +2846,9 @@ var PipRailClient = (_class2 = class {
3703
2846
  */
3704
2847
  captureReceipt(response, url) {
3705
2848
  try {
3706
- const parsed = parseReceiptExtension(response);
2849
+ const parsed = _chunkOXEFPLZAcjs.parseReceiptExtension.call(void 0, response);
3707
2850
  this.lastReceiptValue = parsed ? { ...parsed, resource: { url } } : null;
3708
- } catch (e33) {
2851
+ } catch (e26) {
3709
2852
  this.lastReceiptValue = null;
3710
2853
  }
3711
2854
  }
@@ -3731,17 +2874,17 @@ var PipRailClient = (_class2 = class {
3731
2874
  * {@link ReceiptVerification}).
3732
2875
  */
3733
2876
  static async verifyReceipt(receipt, opts) {
3734
- const r = _optionalChain([receipt, 'optionalAccess', _37 => _37.receipt]);
2877
+ const r = _optionalChain([receipt, 'optionalAccess', _32 => _32.receipt]);
3735
2878
  if (!r || typeof r !== "object") {
3736
2879
  return { ok: false, onChain: { payTo: "", asset: "", amount: "", payer: "" }, matchesClaims: false, ageSeconds: 0, error: "tx_not_found" };
3737
2880
  }
3738
2881
  const claimed = { payTo: _nullishCoalesce(r.payTo, () => ( "")), asset: _nullishCoalesce(r.asset, () => ( "")), amount: _nullishCoalesce(r.amount, () => ( "")), payer: _nullishCoalesce(r.payer, () => ( "")) };
3739
2882
  const ageSeconds = receiptAgeSeconds(r.verifiedAt);
3740
2883
  try {
3741
- const chain = chainSelectorForNetwork(r.network, _optionalChain([opts, 'optionalAccess', _38 => _38.rpcUrl]));
2884
+ const chain = chainSelectorForNetwork(r.network, _optionalChain([opts, 'optionalAccess', _33 => _33.rpcUrl]));
3742
2885
  const net = await resolveNetwork2({
3743
2886
  chain,
3744
- ..._optionalChain([opts, 'optionalAccess', _39 => _39.rpcUrl]) ? { rpcUrl: opts.rpcUrl } : {}
2887
+ ..._optionalChain([opts, 'optionalAccess', _34 => _34.rpcUrl]) ? { rpcUrl: opts.rpcUrl } : {}
3745
2888
  });
3746
2889
  const accept = {
3747
2890
  scheme: "onchain-proof",
@@ -3768,7 +2911,7 @@ var PipRailClient = (_class2 = class {
3768
2911
  const onChain = { payTo: oc.payTo, asset: oc.asset, amount: oc.amount, payer: oc.payer };
3769
2912
  const matchesClaims = sameAddress(oc.payer, r.payer);
3770
2913
  return { ok: true, onChain, matchesClaims, ageSeconds };
3771
- } catch (e34) {
2914
+ } catch (e27) {
3772
2915
  return { ok: false, onChain: claimed, matchesClaims: false, ageSeconds, error: "tx_not_found" };
3773
2916
  }
3774
2917
  }
@@ -3788,7 +2931,7 @@ var PipRailClient = (_class2 = class {
3788
2931
  * no chain libs. The JWS format defers to R3 (`{ ok:false, reason:'jws-not-loaded' }`).
3789
2932
  */
3790
2933
  static async verifyAttestation(receipt) {
3791
- const att = _optionalChain([receipt, 'optionalAccess', _40 => _40.attestation]);
2934
+ const att = _optionalChain([receipt, 'optionalAccess', _35 => _35.attestation]);
3792
2935
  if (!att || typeof att !== "object" || typeof att.signature !== "string") {
3793
2936
  return { ok: false, reason: "no-attestation" };
3794
2937
  }
@@ -3799,7 +2942,7 @@ var PipRailClient = (_class2 = class {
3799
2942
  if (!r || typeof r !== "object") return { ok: false, reason: "no-receipt" };
3800
2943
  const payload = _nullishCoalesce(att.payload, () => ( {}));
3801
2944
  const network = typeof payload.network === "string" ? payload.network : r.network;
3802
- const resourceUrl = typeof payload.resourceUrl === "string" ? payload.resourceUrl : _nullishCoalesce(_optionalChain([receipt, 'access', _41 => _41.resource, 'optionalAccess', _42 => _42.url]), () => ( ""));
2945
+ const resourceUrl = typeof payload.resourceUrl === "string" ? payload.resourceUrl : _nullishCoalesce(_optionalChain([receipt, 'access', _36 => _36.resource, 'optionalAccess', _37 => _37.url]), () => ( ""));
3803
2946
  const payer = typeof payload.payer === "string" ? payload.payer : r.payer;
3804
2947
  const issuedAt = typeof payload.issuedAt === "number" ? payload.issuedAt : receiptIssuedAtSeconds(r.verifiedAt);
3805
2948
  const transaction = typeof payload.transaction === "string" ? payload.transaction : _nullishCoalesce(r.transaction, () => ( ""));
@@ -3814,7 +2957,7 @@ var PipRailClient = (_class2 = class {
3814
2957
  transaction,
3815
2958
  signature: att.signature
3816
2959
  });
3817
- } catch (e35) {
2960
+ } catch (e28) {
3818
2961
  return { ok: false, reason: "verify-failed" };
3819
2962
  }
3820
2963
  }
@@ -3845,7 +2988,7 @@ var PipRailClient = (_class2 = class {
3845
2988
  * as-is) or a plain object (serialised as JSON).
3846
2989
  */
3847
2990
  post(url, body, init) {
3848
- const headers = new Headers(_optionalChain([init, 'optionalAccess', _43 => _43.headers]));
2991
+ const headers = new Headers(_optionalChain([init, 'optionalAccess', _38 => _38.headers]));
3849
2992
  let payload;
3850
2993
  if (body === void 0 || body === null) {
3851
2994
  payload = void 0;
@@ -3876,7 +3019,7 @@ var PipRailClient = (_class2 = class {
3876
3019
  * "0.05 USDC on Base, within budget → pay it." No funds move.
3877
3020
  */
3878
3021
  async quote(url, init) {
3879
- const res = await fetch(url, { ..._nullishCoalesce(init, () => ( {})), method: _nullishCoalesce(_optionalChain([init, 'optionalAccess', _44 => _44.method]), () => ( "GET")) });
3022
+ const res = await fetch(url, { ..._nullishCoalesce(init, () => ( {})), method: _nullishCoalesce(_optionalChain([init, 'optionalAccess', _39 => _39.method]), () => ( "GET")) });
3880
3023
  if (res.status !== 402) return null;
3881
3024
  const { quote } = await this.resolveChallenge(url, res, this.resolveSchemes());
3882
3025
  return quote;
@@ -3895,14 +3038,14 @@ var PipRailClient = (_class2 = class {
3895
3038
  * on Tron, where a USD₮ transfer can cost real TRX.
3896
3039
  */
3897
3040
  async estimateCost(url, init) {
3898
- const res = await fetch(url, { ..._nullishCoalesce(init, () => ( {})), method: _nullishCoalesce(_optionalChain([init, 'optionalAccess', _45 => _45.method]), () => ( "GET")) });
3041
+ const res = await fetch(url, { ..._nullishCoalesce(init, () => ( {})), method: _nullishCoalesce(_optionalChain([init, 'optionalAccess', _40 => _40.method]), () => ( "GET")) });
3899
3042
  if (res.status !== 402) return null;
3900
3043
  try {
3901
3044
  const { net, accept, quote } = await this.resolveChallenge(url, res, this.resolveSchemes());
3902
3045
  const cost = await net.estimateCost(accept);
3903
3046
  return { quote, cost };
3904
3047
  } catch (err) {
3905
- if (err instanceof _chunk3FR22M3Ocjs.InvalidEnvelopeError) return null;
3048
+ if (err instanceof _chunkQONQSZHJcjs.InvalidEnvelopeError) return null;
3906
3049
  throw err;
3907
3050
  }
3908
3051
  }
@@ -3933,8 +3076,8 @@ var PipRailClient = (_class2 = class {
3933
3076
  return {
3934
3077
  session: {
3935
3078
  start,
3936
- expiresAt: _optionalChain([view, 'optionalAccess', _46 => _46.expiresAt]) != null ? new Date(view.expiresAt).toISOString() : null,
3937
- secondsRemaining: _nullishCoalesce(_optionalChain([view, 'optionalAccess', _47 => _47.secondsRemaining]), () => ( null))
3079
+ expiresAt: _optionalChain([view, 'optionalAccess', _41 => _41.expiresAt]) != null ? new Date(view.expiresAt).toISOString() : null,
3080
+ secondsRemaining: _nullishCoalesce(_optionalChain([view, 'optionalAccess', _42 => _42.secondsRemaining]), () => ( null))
3938
3081
  },
3939
3082
  byAsset: this.remaining(),
3940
3083
  byDenom: this.denomRemaining(),
@@ -3949,19 +3092,19 @@ var PipRailClient = (_class2 = class {
3949
3092
  * price-converted figure (tokens grouped as one unit, each 1:1).
3950
3093
  */
3951
3094
  denomRemaining() {
3952
- const caps = _optionalChain([this, 'access', _48 => _48.opts, 'access', _49 => _49.policy, 'optionalAccess', _50 => _50.maxTotalPerDenom]);
3095
+ const caps = _optionalChain([this, 'access', _43 => _43.opts, 'access', _44 => _44.policy, 'optionalAccess', _45 => _45.maxTotalPerDenom]);
3953
3096
  if (!caps) return [];
3954
3097
  return Object.entries(caps).map(([rawDenom, capStr]) => {
3955
3098
  const denom = rawDenom.toUpperCase();
3956
3099
  const spentScaled = this.ledger.totalForDenom(denom);
3957
- const capScaled = _chunk3FR22M3Ocjs.floorUnits.call(void 0, capStr, DENOM_PRECISION);
3100
+ const capScaled = _chunkQONQSZHJcjs.floorUnits.call(void 0, capStr, DENOM_PRECISION);
3958
3101
  const remainingScaled = capScaled > spentScaled ? capScaled - spentScaled : 0n;
3959
3102
  const fraction = capScaled === 0n ? spentScaled > 0n ? 1 : 0 : Number(spentScaled * 1000000n / capScaled) / 1e6;
3960
3103
  return {
3961
3104
  denom,
3962
- spentFormatted: _chunk3FR22M3Ocjs.formatUnits.call(void 0, spentScaled, DENOM_PRECISION),
3963
- capFormatted: _chunk3FR22M3Ocjs.formatUnits.call(void 0, capScaled, DENOM_PRECISION),
3964
- remainingFormatted: _chunk3FR22M3Ocjs.formatUnits.call(void 0, remainingScaled, DENOM_PRECISION),
3105
+ spentFormatted: _chunkQONQSZHJcjs.formatUnits.call(void 0, spentScaled, DENOM_PRECISION),
3106
+ capFormatted: _chunkQONQSZHJcjs.formatUnits.call(void 0, capScaled, DENOM_PRECISION),
3107
+ remainingFormatted: _chunkQONQSZHJcjs.formatUnits.call(void 0, remainingScaled, DENOM_PRECISION),
3965
3108
  fraction
3966
3109
  };
3967
3110
  });
@@ -3972,11 +3115,11 @@ var PipRailClient = (_class2 = class {
3972
3115
  const policy = this.opts.policy;
3973
3116
  const settled = this.ledger.count();
3974
3117
  const out = { settled };
3975
- if (_optionalChain([policy, 'optionalAccess', _51 => _51.maxPayments]) !== void 0) {
3118
+ if (_optionalChain([policy, 'optionalAccess', _46 => _46.maxPayments]) !== void 0) {
3976
3119
  out.lifetimeCap = policy.maxPayments;
3977
3120
  out.lifetimeRemaining = Math.max(0, policy.maxPayments - settled);
3978
3121
  }
3979
- if (_optionalChain([policy, 'optionalAccess', _52 => _52.maxPaymentsPerWindow]) !== void 0 && policy.windowSeconds !== void 0) {
3122
+ if (_optionalChain([policy, 'optionalAccess', _47 => _47.maxPaymentsPerWindow]) !== void 0 && policy.windowSeconds !== void 0) {
3980
3123
  const windowSettled = this.ledger.countSince(Date.now() - policy.windowSeconds * 1e3);
3981
3124
  out.windowCap = policy.maxPaymentsPerWindow;
3982
3125
  out.windowSettled = windowSettled;
@@ -3992,7 +3135,7 @@ var PipRailClient = (_class2 = class {
3992
3135
  * never throws, never sums across tokens (no price oracle). PROCESS-SCOPED.
3993
3136
  */
3994
3137
  remaining() {
3995
- const maxTotal = _optionalChain([this, 'access', _53 => _53.opts, 'access', _54 => _54.policy, 'optionalAccess', _55 => _55.maxTotal]);
3138
+ const maxTotal = _optionalChain([this, 'access', _48 => _48.opts, 'access', _49 => _49.policy, 'optionalAccess', _50 => _50.maxTotal]);
3996
3139
  return this.ledger.assetBuckets().map((b) => {
3997
3140
  const base2 = {
3998
3141
  network: b.network,
@@ -4002,13 +3145,13 @@ var PipRailClient = (_class2 = class {
4002
3145
  spentBase: b.totalBase.toString()
4003
3146
  };
4004
3147
  if (maxTotal === void 0) return base2;
4005
- const capBase = _chunk3FR22M3Ocjs.floorUnits.call(void 0, maxTotal, b.decimals);
3148
+ const capBase = _chunkQONQSZHJcjs.floorUnits.call(void 0, maxTotal, b.decimals);
4006
3149
  const remainingBase = capBase > b.totalBase ? capBase - b.totalBase : 0n;
4007
3150
  return {
4008
3151
  ...base2,
4009
3152
  capBase: capBase.toString(),
4010
3153
  remainingBase: remainingBase.toString(),
4011
- remainingFormatted: _chunk3FR22M3Ocjs.formatUnits.call(void 0, remainingBase, b.decimals)
3154
+ remainingFormatted: _chunkQONQSZHJcjs.formatUnits.call(void 0, remainingBase, b.decimals)
4012
3155
  };
4013
3156
  });
4014
3157
  }
@@ -4044,15 +3187,15 @@ var PipRailClient = (_class2 = class {
4044
3187
  * the plan yourself. No funds move.
4045
3188
  */
4046
3189
  async planPayment(url, init) {
4047
- const res = await fetch(url, { ..._nullishCoalesce(init, () => ( {})), method: _nullishCoalesce(_optionalChain([init, 'optionalAccess', _56 => _56.method]), () => ( "GET")) });
3190
+ const res = await fetch(url, { ..._nullishCoalesce(init, () => ( {})), method: _nullishCoalesce(_optionalChain([init, 'optionalAccess', _51 => _51.method]), () => ( "GET")) });
4048
3191
  if (res.status !== 402) return null;
4049
- const challenge = await parseChallenge(res);
3192
+ const challenge = await _chunkOXEFPLZAcjs.parseChallenge.call(void 0, res);
4050
3193
  if (!challenge) {
4051
- throw new (0, _chunk3FR22M3Ocjs.InvalidEnvelopeError)("402 response did not include a parseable x402 challenge.");
3194
+ throw new (0, _chunkQONQSZHJcjs.InvalidEnvelopeError)("402 response did not include a parseable x402 challenge.");
4052
3195
  }
4053
3196
  const { net, wallet } = await this.ensure();
4054
3197
  if (!wallet) {
4055
- throw new (0, _chunk3FR22M3Ocjs.WalletRequiredError)(
3198
+ throw new (0, _chunkQONQSZHJcjs.WalletRequiredError)(
4056
3199
  "planPayment needs a wallet (it checks YOUR balance, gas, and recipient-readiness). This client is read-only \u2014 construct it with a `wallet` to plan or pay."
4057
3200
  );
4058
3201
  }
@@ -4086,10 +3229,10 @@ var PipRailClient = (_class2 = class {
4086
3229
  * - Results are cross-scheme (mostly the mainstream `exact` scheme); `fetch()` pays
4087
3230
  * `onchain-proof` rails by default, and standard `exact` rails too once you opt in
4088
3231
  * with `schemes: ['onchain-proof', 'exact']` (EVM EIP-3009/Permit2 + Solana SVM + Algorand
4089
- * + Aptos + NEAR).
3232
+ * + Aptos + NEAR + XRPL native XRP).
4090
3233
  */
4091
3234
  async discover(opts = {}) {
4092
- const found = await searchOpenIndexes({
3235
+ const found = await _chunkV2IJ5HUWcjs.searchOpenIndexes.call(void 0, {
4093
3236
  ...opts.query !== void 0 ? { query: opts.query } : {},
4094
3237
  ...opts.sources ? { sources: opts.sources } : {},
4095
3238
  ...opts.limit !== void 0 ? { limit: opts.limit } : {},
@@ -4108,7 +3251,7 @@ var PipRailClient = (_class2 = class {
4108
3251
  const { net } = await this.ensure();
4109
3252
  return found.filter((r) => r.rails.some((rail) => railOnNetwork(rail, (n) => net.supports(n))));
4110
3253
  }
4111
- const target = normalizeNetwork(scope);
3254
+ const target = _chunkV2IJ5HUWcjs.normalizeNetwork.call(void 0, scope);
4112
3255
  return found.filter((r) => r.rails.some((rail) => railOnNetwork(rail, (n) => n === target)));
4113
3256
  }
4114
3257
  /**
@@ -4142,7 +3285,7 @@ var PipRailClient = (_class2 = class {
4142
3285
  for (const target of targets) {
4143
3286
  if (target === "402index") {
4144
3287
  outcomes.push(
4145
- await register402Index({
3288
+ await _chunkV2IJ5HUWcjs.register402Index.call(void 0, {
4146
3289
  url,
4147
3290
  ...opts.name ? { name: opts.name } : {},
4148
3291
  ...opts.description ? { description: opts.description } : {},
@@ -4169,7 +3312,7 @@ var PipRailClient = (_class2 = class {
4169
3312
  });
4170
3313
  continue;
4171
3314
  }
4172
- outcomes.push(await registerX402Scan({ url }, signer));
3315
+ outcomes.push(await _chunkV2IJ5HUWcjs.registerX402Scan.call(void 0, { url }, signer));
4173
3316
  } else {
4174
3317
  outcomes.push({
4175
3318
  source: "bazaar",
@@ -4178,7 +3321,7 @@ var PipRailClient = (_class2 = class {
4178
3321
  });
4179
3322
  }
4180
3323
  }
4181
- return outcomes.map(decorateOutcome);
3324
+ return outcomes.map(_chunkV2IJ5HUWcjs.decorateOutcome);
4182
3325
  }
4183
3326
  /**
4184
3327
  * **402 Index domain verification, step 1 of 2.** A self-registered 402 Index
@@ -4195,7 +3338,7 @@ var PipRailClient = (_class2 = class {
4195
3338
  * ```
4196
3339
  */
4197
3340
  async claimDomain(urlOrDomain, opts = {}) {
4198
- return claim402IndexDomain(urlOrDomain, opts);
3341
+ return _chunkV2IJ5HUWcjs.claim402IndexDomain.call(void 0, urlOrDomain, opts);
4199
3342
  }
4200
3343
  /**
4201
3344
  * **402 Index domain verification, step 2 of 2.** After {@link claimDomain} and
@@ -4204,7 +3347,7 @@ var PipRailClient = (_class2 = class {
4204
3347
  * (`{ ok:true, status:'verified', servicesCount }`). Moves no funds; never throws.
4205
3348
  */
4206
3349
  async verifyDomain(urlOrDomain) {
4207
- return verify402IndexDomain(urlOrDomain);
3350
+ return _chunkV2IJ5HUWcjs.verify402IndexDomain.call(void 0, urlOrDomain);
4208
3351
  }
4209
3352
  /**
4210
3353
  * The discovery signer for the bound wallet (its address + a message signer),
@@ -4226,31 +3369,31 @@ var PipRailClient = (_class2 = class {
4226
3369
  * streams throw `NonReplayableBodyError`.
4227
3370
  */
4228
3371
  async fetch(url, init) {
4229
- const body = _optionalChain([init, 'optionalAccess', _57 => _57.body]);
3372
+ const body = _optionalChain([init, 'optionalAccess', _52 => _52.body]);
4230
3373
  if (body !== void 0 && body !== null && !isReplayableBodyInit(body)) {
4231
- throw new (0, _chunk3FR22M3Ocjs.NonReplayableBodyError)(
3374
+ throw new (0, _chunkQONQSZHJcjs.NonReplayableBodyError)(
4232
3375
  "fetch(): init.body is not replayable. Pass a string, FormData, URLSearchParams, ArrayBuffer, or Blob \u2014 not a ReadableStream."
4233
3376
  );
4234
3377
  }
4235
3378
  const firstResponse = await fetch(url, init);
4236
3379
  if (firstResponse.status !== 402) return firstResponse;
4237
- const schemes = this.resolveSchemes(_optionalChain([init, 'optionalAccess', _58 => _58.schemes]));
3380
+ const schemes = this.resolveSchemes(_optionalChain([init, 'optionalAccess', _53 => _53.schemes]));
4238
3381
  const resolved = await this.resolveChallenge(url, firstResponse, schemes);
4239
3382
  const { net, wallet, challenge } = resolved;
4240
3383
  if (!wallet) {
4241
- throw new (0, _chunk3FR22M3Ocjs.WalletRequiredError)(
3384
+ throw new (0, _chunkQONQSZHJcjs.WalletRequiredError)(
4242
3385
  "Paying a 402 needs a wallet to sign + settle. This client is read-only \u2014 construct it with a `wallet` to pay (quote/discover/register still work without one)."
4243
3386
  );
4244
3387
  }
4245
3388
  let accept = resolved.accept;
4246
3389
  let quote = resolved.quote;
4247
- const autoRoute = _nullishCoalesce(_nullishCoalesce(_optionalChain([init, 'optionalAccess', _59 => _59.autoRoute]), () => ( this.opts.autoRoute)), () => ( false));
3390
+ const autoRoute = _nullishCoalesce(_nullishCoalesce(_optionalChain([init, 'optionalAccess', _54 => _54.autoRoute]), () => ( this.opts.autoRoute)), () => ( false));
4248
3391
  if (autoRoute) {
4249
3392
  const plan = await this.planFromChallenge(net, wallet, challenge, url, schemes);
4250
3393
  if (!plan.best) {
4251
3394
  const reason = _nullishCoalesce(plan.fundingHint, () => ( "No rail is settleable for this payment."));
4252
3395
  this.safeEmit({ kind: "payment-failed", reason });
4253
- throw new (0, _chunk3FR22M3Ocjs.PaymentDeclinedError)(reason);
3396
+ throw new (0, _chunkQONQSZHJcjs.PaymentDeclinedError)(reason);
4254
3397
  }
4255
3398
  accept = plan.best.accept;
4256
3399
  quote = plan.best.quote;
@@ -4261,10 +3404,10 @@ var PipRailClient = (_class2 = class {
4261
3404
  return this.payUptoRail(net, wallet, accept, url, init, quote);
4262
3405
  }
4263
3406
  if (accept.scheme === "exact") {
4264
- return this.payExactRail(net, wallet, accept, url, init, quote);
3407
+ return this.payExactRail(net, wallet, accept, url, init, quote, challenge.x402Version);
4265
3408
  }
4266
3409
  if (accept.scheme !== "onchain-proof") {
4267
- throw new (0, _chunk3FR22M3Ocjs.UnsupportedSchemeError)(
3410
+ throw new (0, _chunkQONQSZHJcjs.UnsupportedSchemeError)(
4268
3411
  `internal: unrouted accept scheme '${accept.scheme}' reached the onchain-proof pay path.`
4269
3412
  );
4270
3413
  }
@@ -4280,9 +3423,9 @@ var PipRailClient = (_class2 = class {
4280
3423
  * `quote()` (read-only) and `fetch()` (which then authorises + pays).
4281
3424
  */
4282
3425
  async resolveChallenge(url, response, schemes) {
4283
- const challenge = await parseChallenge(response);
3426
+ const challenge = await _chunkOXEFPLZAcjs.parseChallenge.call(void 0, response);
4284
3427
  if (!challenge) {
4285
- throw new (0, _chunk3FR22M3Ocjs.InvalidEnvelopeError)(
3428
+ throw new (0, _chunkQONQSZHJcjs.InvalidEnvelopeError)(
4286
3429
  "402 response did not include a parseable x402 challenge."
4287
3430
  );
4288
3431
  }
@@ -4293,7 +3436,7 @@ var PipRailClient = (_class2 = class {
4293
3436
  (a) => a.scheme === "exact" && this.supportsNetwork(net, a.network)
4294
3437
  );
4295
3438
  if (schemes.includes("exact") && exactOnNet && typeof net.payExact !== "function") {
4296
- throw new (0, _chunk3FR22M3Ocjs.UnsupportedSchemeError)(
3439
+ throw new (0, _chunkQONQSZHJcjs.UnsupportedSchemeError)(
4297
3440
  `This 402 offers a standard 'exact' rail on ${net.network}, but the ${net.family} family can't pay 'exact' (supported on EVM, Solana, Algorand, Aptos + NEAR today), and no 'onchain-proof' rail was offered.`
4298
3441
  );
4299
3442
  }
@@ -4302,13 +3445,13 @@ var PipRailClient = (_class2 = class {
4302
3445
  (a) => a.scheme === "exact" && this.supportsNetwork(net, a.network) && net.describeAsset(a.asset) != null
4303
3446
  );
4304
3447
  if (payable) {
4305
- throw new (0, _chunk3FR22M3Ocjs.NoCompatibleAcceptError)(
3448
+ throw new (0, _chunkQONQSZHJcjs.NoCompatibleAcceptError)(
4306
3449
  `This 402 is payable only via the standard 'exact' rail on ${net.network}, which is OFF by default. Enable it: new PipRailClient({ \u2026, schemes: ['onchain-proof', 'exact'] }) or per call fetch(url, { schemes: ['exact'] }) (MCP: PIPRAIL_SCHEMES=onchain-proof,exact).`
4307
3450
  );
4308
3451
  }
4309
3452
  }
4310
3453
  const networks = [...new Set(challenge.accepts.map((a) => a.network))].join(", ");
4311
- throw new (0, _chunk3FR22M3Ocjs.NoCompatibleAcceptError)(
3454
+ throw new (0, _chunkQONQSZHJcjs.NoCompatibleAcceptError)(
4312
3455
  `No accepts[] entry payable by this client on ${net.network} (schemes: ${schemes.join(", ")}; challenge offered: ${networks || "none"}).`
4313
3456
  );
4314
3457
  }
@@ -4328,7 +3471,7 @@ var PipRailClient = (_class2 = class {
4328
3471
  * newly matchable (an unknown slug stays unresolved → still unmatched; a different
4329
3472
  * chain's slug resolves elsewhere → still unmatched). */
4330
3473
  supportsNetwork(net, network) {
4331
- return net.supports(normalizeNetwork(network));
3474
+ return net.supports(_chunkV2IJ5HUWcjs.normalizeNetwork.call(void 0, network));
4332
3475
  }
4333
3476
  /** The candidate accepts this client could pay, on the bound network. Always the
4334
3477
  * backendless `onchain-proof` rails; PLUS standard `exact` rails when `schemes`
@@ -4347,15 +3490,35 @@ var PipRailClient = (_class2 = class {
4347
3490
  if (schemes.includes("exact")) {
4348
3491
  out.push(
4349
3492
  ...challenge.accepts.filter(
4350
- (a) => a.scheme === "exact" && this.supportsNetwork(net, a.network) && typeof net.payExact === "function" && // `native` is never `exact`-payable on ANY family (exact = an EIP-3009/Permit2-style
4351
- // signed-authorization scheme a native coin can't support; every driver's payExact
4352
- // throws/returns-null for it). describeAsset('native') IS non-null (onchain-proof needs
4353
- // it), so without this guard a malformed 402 advertising a native `exact` rail would be
4354
- // gathered, planned `payable`, even chosen by autoRoute then throw at pay time.
4355
- a.asset !== "native" && // the exact pay path (payExact → driver) reads `extra.assetTransferMethod`; a malformed
4356
- // 402 offering an exact rail for a RECOGNISED token but omitting `extra` would otherwise
4357
- // be planned payable then throw a raw TypeError mid-pay. Require it at gather time.
4358
- typeof _optionalChain([a, 'access', _60 => _60.extra, 'optionalAccess', _61 => _61.assetTransferMethod]) === "string" && net.describeAsset(a.asset) != null && // a foreign rail's maxTimeoutSeconds must be a usable positive integer, or
3493
+ (a) => a.scheme === "exact" && this.supportsNetwork(net, a.network) && typeof net.payExact === "function" && /*
3494
+ * Can this family sign an `exact` payment for THIS asset?
3495
+ *
3496
+ * The default for every family that doesn't say otherwise is "any recognised token
3497
+ * yes, the native coin no". `exact` is an EIP-3009/Permit2-style signed-authorization
3498
+ * scheme a native coin can't carry, and `describeAsset('native')` IS non-null
3499
+ * (onchain-proof needs it), so without the rule a 402 advertising a native exact rail
3500
+ * would gather, plan `payable`, even win autoRoute then throw at pay time.
3501
+ *
3502
+ * XRPL is the first family to overturn it, in BOTH directions. There an `exact` payment
3503
+ * is simply a fully signed `Payment`, so native XRP is the most natural thing to send —
3504
+ * 863 of its 1,732 live rails are priced in XRP. Its ISSUED currencies are excluded
3505
+ * instead: they state a decimal `value` on the wire while the spend policy caps in base
3506
+ * units, so pricing one as base units would let a 12-RLUSD rail slip under any cap.
3507
+ * A driver that declares `exactPayableAsset` replaces this rule for all of its assets.
3508
+ */
3509
+ (net.exactPayableAsset ? net.exactPayableAsset(a.asset) : a.asset !== "native") && /*
3510
+ * The rail's transfer method must be one a driver can sign — but an ABSENT method is
3511
+ * not an unknown one. `scheme_exact_evm.md`: "If no `assetTransferMethod` is specified
3512
+ * in `PaymentRequired.extra`, clients should default to `eip3009`", and the SVM /
3513
+ * Algorand / Aptos / NEAR / Hedera schemes never define the key at all. This predicate
3514
+ * previously REQUIRED the key, which rejected 91% of the deployed x402 web — every
3515
+ * Solana rail, every Arbitrum rail, 85% of Base — while the pay path had always
3516
+ * handled its absence correctly (the EVM driver defaults to eip3009 and re-derives the
3517
+ * EIP-712 domain on-chain). `isSettleableExactMethod` keeps the real guard: a rail that
3518
+ * NAMES a method we don't implement (the spec's `erc7710`) is still skipped, because
3519
+ * signing an EIP-3009 authorization for it would just be rejected by its facilitator.
3520
+ */
3521
+ _chunkOXEFPLZAcjs.isSettleableExactMethod.call(void 0, a) && net.describeAsset(a.asset) != null && // a foreign rail's maxTimeoutSeconds must be a usable positive integer, or
4359
3522
  // signing it would build a NaN/garbage validBefore — drop it silently
4360
3523
  // (symmetric with an unrecognised token) rather than leak a raw SyntaxError.
4361
3524
  Number.isInteger(a.maxTimeoutSeconds) && a.maxTimeoutSeconds > 0
@@ -4366,7 +3529,7 @@ var PipRailClient = (_class2 = class {
4366
3529
  out.push(
4367
3530
  ...challenge.accepts.filter(
4368
3531
  (a) => a.scheme === "upto" && this.supportsNetwork(net, a.network) && typeof net.payUpto === "function" && a.asset !== "native" && // native is not upto-payable either (same reason as exact)
4369
- net.describeAsset(a.asset) != null && typeof _optionalChain([a, 'access', _62 => _62.extra, 'optionalAccess', _63 => _63.facilitatorAddress]) === "string" && a.extra.facilitatorAddress.length > 0 && Number.isInteger(a.maxTimeoutSeconds) && a.maxTimeoutSeconds > 0
3532
+ net.describeAsset(a.asset) != null && typeof _optionalChain([a, 'access', _55 => _55.extra, 'optionalAccess', _56 => _56.facilitatorAddress]) === "string" && a.extra.facilitatorAddress.length > 0 && Number.isInteger(a.maxTimeoutSeconds) && a.maxTimeoutSeconds > 0
4370
3533
  )
4371
3534
  );
4372
3535
  }
@@ -4437,21 +3600,21 @@ var PipRailClient = (_class2 = class {
4437
3600
  if (isExact) {
4438
3601
  if (tokenKnown && bal.token < amount) {
4439
3602
  blockers.push("INSUFFICIENT_TOKEN");
4440
- shortfall.token = _chunk3FR22M3Ocjs.formatUnits.call(void 0, amount - bal.token, quote.decimals);
3603
+ shortfall.token = _chunkQONQSZHJcjs.formatUnits.call(void 0, amount - bal.token, quote.decimals);
4441
3604
  }
4442
3605
  } else if (isNative) {
4443
3606
  if (nativeKnown && bal.native < amount + fee) {
4444
3607
  blockers.push("INSUFFICIENT_TOKEN");
4445
- shortfall.token = _chunk3FR22M3Ocjs.formatUnits.call(void 0, amount + fee - bal.native, quote.decimals);
3608
+ shortfall.token = _chunkQONQSZHJcjs.formatUnits.call(void 0, amount + fee - bal.native, quote.decimals);
4446
3609
  }
4447
3610
  } else {
4448
3611
  if (tokenKnown && bal.token < amount) {
4449
3612
  blockers.push("INSUFFICIENT_TOKEN");
4450
- shortfall.token = _chunk3FR22M3Ocjs.formatUnits.call(void 0, amount - bal.token, quote.decimals);
3613
+ shortfall.token = _chunkQONQSZHJcjs.formatUnits.call(void 0, amount - bal.token, quote.decimals);
4451
3614
  }
4452
3615
  if (nativeKnown && bal.native < fee) {
4453
3616
  blockers.push("INSUFFICIENT_GAS");
4454
- shortfall.native = _chunk3FR22M3Ocjs.formatUnits.call(void 0, fee - bal.native, cost.feeDecimals);
3617
+ shortfall.native = _chunkQONQSZHJcjs.formatUnits.call(void 0, fee - bal.native, cost.feeDecimals);
4455
3618
  } else if (nativeKnown && fee > 0n && bal.native < fee * 3n / 2n) {
4456
3619
  warnings.push("THIN_GAS_MARGIN");
4457
3620
  }
@@ -4472,12 +3635,20 @@ var PipRailClient = (_class2 = class {
4472
3635
  accept,
4473
3636
  quote,
4474
3637
  cost,
3638
+ // Surface the transfer method we INFERRED, not just the one the rail named — an absent
3639
+ // marker means the scheme's default, and saying so is how an agent (or a maintainer) sees
3640
+ // why a domain-only rail is payable and gasless. The default is PER FAMILY: a Solana rail
3641
+ // naming nothing means `svm`, never `eip3009`.
3642
+ ...accept.scheme === "exact" ? {
3643
+ method: _optionalChain([accept, 'access', _57 => _57.extra, 'optionalAccess', _58 => _58.assetTransferMethod]) ? _chunkOXEFPLZAcjs.exactTransferMethod.call(void 0, accept) : `${_chunkOXEFPLZAcjs.exactTransferMethod.call(void 0, accept, net.family)} (default)`
3644
+ } : {},
3645
+ ...accept.scheme === "upto" ? { method: "permit2-upto" } : {},
4475
3646
  state,
4476
3647
  blockers,
4477
3648
  warnings,
4478
3649
  balance: {
4479
- token: bal.token != null ? _chunk3FR22M3Ocjs.formatUnits.call(void 0, bal.token, quote.decimals) : null,
4480
- native: bal.native != null ? _chunk3FR22M3Ocjs.formatUnits.call(void 0, bal.native, cost.feeDecimals) : null
3650
+ token: bal.token != null ? _chunkQONQSZHJcjs.formatUnits.call(void 0, bal.token, quote.decimals) : null,
3651
+ native: bal.native != null ? _chunkQONQSZHJcjs.formatUnits.call(void 0, bal.native, cost.feeDecimals) : null
4481
3652
  },
4482
3653
  need: { token: quote.amountFormatted, native: cost.feeFormatted },
4483
3654
  ...shortfall.token || shortfall.native ? { shortfall } : {},
@@ -4488,32 +3659,32 @@ var PipRailClient = (_class2 = class {
4488
3659
  * driver's describeAsset) + the policy verdict + a symbol-mismatch flag. */
4489
3660
  buildQuote(net, accept, url, description) {
4490
3661
  if (typeof accept.amount !== "string" || !/^\d+$/.test(accept.amount)) {
4491
- throw new (0, _chunk3FR22M3Ocjs.InvalidEnvelopeError)(
3662
+ throw new (0, _chunkQONQSZHJcjs.InvalidEnvelopeError)(
4492
3663
  `challenge amount "${String(accept.amount)}" is not a base-unit integer string.`
4493
3664
  );
4494
3665
  }
4495
3666
  if (typeof accept.asset !== "string" || accept.asset.length === 0) {
4496
- throw new (0, _chunk3FR22M3Ocjs.InvalidEnvelopeError)(
3667
+ throw new (0, _chunkQONQSZHJcjs.InvalidEnvelopeError)(
4497
3668
  `challenge on ${accept.network} states no (string) asset \u2014 refusing to price it.`
4498
3669
  );
4499
3670
  }
4500
3671
  const amountBase = BigInt(accept.amount);
4501
3672
  const described = net.describeAsset(accept.asset);
4502
- const decimals = _nullishCoalesce(_optionalChain([described, 'optionalAccess', _64 => _64.decimals]), () => ( _optionalChain([accept, 'access', _65 => _65.extra, 'optionalAccess', _66 => _66.decimals])));
3673
+ const decimals = _nullishCoalesce(_optionalChain([described, 'optionalAccess', _59 => _59.decimals]), () => ( _optionalChain([accept, 'access', _60 => _60.extra, 'optionalAccess', _61 => _61.decimals])));
4503
3674
  if (typeof decimals !== "number" || !Number.isInteger(decimals) || decimals < 0) {
4504
- throw new (0, _chunk3FR22M3Ocjs.InvalidEnvelopeError)(
3675
+ throw new (0, _chunkQONQSZHJcjs.InvalidEnvelopeError)(
4505
3676
  `challenge for ${accept.asset} on ${accept.network} states no valid decimals and the SDK doesn't recognise the token \u2014 refusing to price it.`
4506
3677
  );
4507
3678
  }
4508
- if (decimals > _chunk3FR22M3Ocjs.MAX_DECIMALS) {
4509
- throw new (0, _chunk3FR22M3Ocjs.InvalidEnvelopeError)(
4510
- `challenge for ${accept.asset} on ${accept.network} states ${decimals} decimals (> ${_chunk3FR22M3Ocjs.MAX_DECIMALS}) \u2014 refusing to price it (no real token is that deep).`
3679
+ if (decimals > _chunkQONQSZHJcjs.MAX_DECIMALS) {
3680
+ throw new (0, _chunkQONQSZHJcjs.InvalidEnvelopeError)(
3681
+ `challenge for ${accept.asset} on ${accept.network} states ${decimals} decimals (> ${_chunkQONQSZHJcjs.MAX_DECIMALS}) \u2014 refusing to price it (no real token is that deep).`
4511
3682
  );
4512
3683
  }
4513
- const symbol = _nullishCoalesce(_optionalChain([described, 'optionalAccess', _67 => _67.symbol]), () => ( _optionalChain([accept, 'access', _68 => _68.extra, 'optionalAccess', _69 => _69.symbol])));
4514
- const amountFormatted = _chunk3FR22M3Ocjs.formatUnits.call(void 0, amountBase, decimals);
3684
+ const symbol = _nullishCoalesce(_optionalChain([described, 'optionalAccess', _62 => _62.symbol]), () => ( _optionalChain([accept, 'access', _63 => _63.extra, 'optionalAccess', _64 => _64.symbol])));
3685
+ const amountFormatted = _chunkQONQSZHJcjs.formatUnits.call(void 0, amountBase, decimals);
4515
3686
  const intent = {
4516
- host: hostOf2(url),
3687
+ host: hostOf(url),
4517
3688
  chain: this.opts.chain,
4518
3689
  network: accept.network,
4519
3690
  asset: accept.asset,
@@ -4552,7 +3723,7 @@ var PipRailClient = (_class2 = class {
4552
3723
  this.ledger.totalFor(accept.network, accept.asset),
4553
3724
  ctx
4554
3725
  );
4555
- const serverSymbol = _optionalChain([accept, 'access', _70 => _70.extra, 'optionalAccess', _71 => _71.symbol]);
3726
+ const serverSymbol = _optionalChain([accept, 'access', _65 => _65.extra, 'optionalAccess', _66 => _66.symbol]);
4556
3727
  const symbolMismatch = intent.recognized && !!serverSymbol && !!symbol && serverSymbol.toUpperCase() !== symbol.toUpperCase();
4557
3728
  return {
4558
3729
  url,
@@ -4616,7 +3787,7 @@ var PipRailClient = (_class2 = class {
4616
3787
  ...opts.quote ? { quote: opts.quote } : {},
4617
3788
  budget: this.budget()
4618
3789
  });
4619
- throw new (0, _chunk3FR22M3Ocjs.PaymentDeclinedError)(reason, {
3790
+ throw new (0, _chunkQONQSZHJcjs.PaymentDeclinedError)(reason, {
4620
3791
  ...opts.reasonCode ? { reasonCode: opts.reasonCode } : {},
4621
3792
  ...opts.cause !== void 0 ? { cause: opts.cause } : {}
4622
3793
  });
@@ -4648,13 +3819,13 @@ var PipRailClient = (_class2 = class {
4648
3819
  const max = BigInt(quote.amount);
4649
3820
  const shown = claimed < max ? claimed : max;
4650
3821
  settledBase = shown.toString();
4651
- settledFormatted = _chunk3FR22M3Ocjs.formatUnits.call(void 0, shown, quote.decimals);
4652
- } catch (e36) {
3822
+ settledFormatted = _chunkQONQSZHJcjs.formatUnits.call(void 0, shown, quote.decimals);
3823
+ } catch (e29) {
4653
3824
  }
4654
3825
  }
4655
3826
  const record = {
4656
3827
  url: quote.url,
4657
- host: hostOf2(quote.url),
3828
+ host: hostOf(quote.url),
4658
3829
  network: quote.network,
4659
3830
  asset: quote.asset,
4660
3831
  amountBase,
@@ -4671,7 +3842,7 @@ var PipRailClient = (_class2 = class {
4671
3842
  if (this.opts.onSpend) {
4672
3843
  try {
4673
3844
  this.opts.onSpend(record, budget);
4674
- } catch (e37) {
3845
+ } catch (e30) {
4675
3846
  }
4676
3847
  }
4677
3848
  this.emitThresholds(budget);
@@ -4684,7 +3855,7 @@ var PipRailClient = (_class2 = class {
4684
3855
  * `warnAtFraction` is set. Reads the just-computed {@link SessionBudget}; isolated (safeEmit).
4685
3856
  */
4686
3857
  emitThresholds(budget) {
4687
- const frac = _optionalChain([this, 'access', _72 => _72.opts, 'access', _73 => _73.policy, 'optionalAccess', _74 => _74.warnAtFraction]);
3858
+ const frac = _optionalChain([this, 'access', _67 => _67.opts, 'access', _68 => _68.policy, 'optionalAccess', _69 => _69.warnAtFraction]);
4688
3859
  if (frac === void 0) return;
4689
3860
  const fire = (scope, label, spentFormatted, capFormatted, fraction) => {
4690
3861
  if (fraction < frac) return;
@@ -4699,8 +3870,8 @@ var PipRailClient = (_class2 = class {
4699
3870
  fire(
4700
3871
  "asset",
4701
3872
  `${_nullishCoalesce(r.symbol, () => ( r.asset))} on ${r.network}`,
4702
- _chunk3FR22M3Ocjs.formatUnits.call(void 0, spent, r.decimals),
4703
- _chunk3FR22M3Ocjs.formatUnits.call(void 0, cap, r.decimals),
3873
+ _chunkQONQSZHJcjs.formatUnits.call(void 0, spent, r.decimals),
3874
+ _chunkQONQSZHJcjs.formatUnits.call(void 0, cap, r.decimals),
4704
3875
  fraction
4705
3876
  );
4706
3877
  }
@@ -4708,17 +3879,17 @@ var PipRailClient = (_class2 = class {
4708
3879
  fire("denom", d.denom, d.spentFormatted, d.capFormatted, d.fraction);
4709
3880
  }
4710
3881
  const policy = this.opts.policy;
4711
- if (_optionalChain([policy, 'optionalAccess', _75 => _75.windowTotal]) !== void 0 && policy.windowSeconds !== void 0) {
3882
+ if (_optionalChain([policy, 'optionalAccess', _70 => _70.windowTotal]) !== void 0 && policy.windowSeconds !== void 0) {
4712
3883
  const since = Date.now() - policy.windowSeconds * 1e3;
4713
3884
  for (const r of budget.byAsset) {
4714
- const cap = _chunk3FR22M3Ocjs.floorUnits.call(void 0, policy.windowTotal, r.decimals);
3885
+ const cap = _chunkQONQSZHJcjs.floorUnits.call(void 0, policy.windowTotal, r.decimals);
4715
3886
  const spent = this.ledger.totalSince(r.network, r.asset, since);
4716
3887
  const fraction = cap === 0n ? spent > 0n ? 1 : 0 : Number(spent * 1000000n / cap) / 1e6;
4717
3888
  fire(
4718
3889
  "window",
4719
3890
  `${_nullishCoalesce(r.symbol, () => ( r.asset))} on ${r.network}`,
4720
- _chunk3FR22M3Ocjs.formatUnits.call(void 0, spent, r.decimals),
4721
- _chunk3FR22M3Ocjs.formatUnits.call(void 0, cap, r.decimals),
3891
+ _chunkQONQSZHJcjs.formatUnits.call(void 0, spent, r.decimals),
3892
+ _chunkQONQSZHJcjs.formatUnits.call(void 0, cap, r.decimals),
4722
3893
  fraction
4723
3894
  );
4724
3895
  }
@@ -4739,14 +3910,14 @@ var PipRailClient = (_class2 = class {
4739
3910
  }
4740
3911
  async payAndConfirm(net, wallet, accept) {
4741
3912
  if (!this.supportsNetwork(net, accept.network)) {
4742
- throw new (0, _chunk3FR22M3Ocjs.WrongChainError)(
3913
+ throw new (0, _chunkQONQSZHJcjs.WrongChainError)(
4743
3914
  `Challenge expects ${accept.network} but client is on ${net.network}.`
4744
3915
  );
4745
3916
  }
4746
3917
  const ref = await net.send(wallet, accept);
4747
3918
  this.safeEmit({ kind: "payment-broadcast", ref });
4748
3919
  try {
4749
- const { height } = await net.confirm(ref, _nullishCoalesce(_optionalChain([accept, 'access', _76 => _76.extra, 'optionalAccess', _77 => _77.minConfirmations]), () => ( 1)));
3920
+ const { height } = await net.confirm(ref, _nullishCoalesce(_optionalChain([accept, 'access', _71 => _71.extra, 'optionalAccess', _72 => _72.minConfirmations]), () => ( 1)));
4750
3921
  this.safeEmit({
4751
3922
  kind: "payment-confirmed",
4752
3923
  ref,
@@ -4766,10 +3937,10 @@ var PipRailClient = (_class2 = class {
4766
3937
  const signature = {
4767
3938
  x402Version: 2,
4768
3939
  accepted: accept,
4769
- payload: { nonce: _optionalChain([accept, 'access', _78 => _78.extra, 'optionalAccess', _79 => _79.nonce]), txHash: ref }
3940
+ payload: { nonce: _optionalChain([accept, 'access', _73 => _73.extra, 'optionalAccess', _74 => _74.nonce]), txHash: ref }
4770
3941
  };
4771
- const headers = new Headers(_optionalChain([originalInit, 'optionalAccess', _80 => _80.headers]));
4772
- headers.set(HEADER_SIGNATURE, buildSignatureHeader(signature));
3942
+ const headers = new Headers(_optionalChain([originalInit, 'optionalAccess', _75 => _75.headers]));
3943
+ headers.set(_chunkOXEFPLZAcjs.HEADER_SIGNATURE, _chunkOXEFPLZAcjs.buildSignatureHeader.call(void 0, signature));
4773
3944
  let lastResponse = null;
4774
3945
  let lastReason = null;
4775
3946
  const attempts = confirmed ? this.maxRetries : Math.max(this.maxRetries, 6);
@@ -4783,7 +3954,7 @@ var PipRailClient = (_class2 = class {
4783
3954
  () => timeoutController.abort(),
4784
3955
  this.retryTimeoutMs
4785
3956
  );
4786
- const signal = _optionalChain([originalInit, 'optionalAccess', _81 => _81.signal]) && typeof AbortSignal.any === "function" ? AbortSignal.any([timeoutController.signal, originalInit.signal]) : timeoutController.signal;
3957
+ const signal = _optionalChain([originalInit, 'optionalAccess', _76 => _76.signal]) && typeof AbortSignal.any === "function" ? AbortSignal.any([timeoutController.signal, originalInit.signal]) : timeoutController.signal;
4787
3958
  try {
4788
3959
  lastResponse = await fetch(url, {
4789
3960
  ..._nullishCoalesce(originalInit, () => ( {})),
@@ -4792,7 +3963,7 @@ var PipRailClient = (_class2 = class {
4792
3963
  });
4793
3964
  } catch (err) {
4794
3965
  if (timeoutController.signal.aborted) {
4795
- throw new (0, _chunk3FR22M3Ocjs.PaymentTimeoutError)(
3966
+ throw new (0, _chunkQONQSZHJcjs.PaymentTimeoutError)(
4796
3967
  `Server did not respond within ${this.retryTimeoutMs}ms after broadcasting payment ${ref}. Re-verify or re-submit ref=${ref} \u2014 do NOT re-pay.`,
4797
3968
  { cause: err, ref }
4798
3969
  );
@@ -4802,7 +3973,7 @@ var PipRailClient = (_class2 = class {
4802
3973
  clearTimeout(timeoutId);
4803
3974
  }
4804
3975
  if (lastResponse.status !== 402) {
4805
- const receipt = parseReceipt(lastResponse);
3976
+ const receipt = _chunkOXEFPLZAcjs.parseReceipt.call(void 0, lastResponse);
4806
3977
  this.captureReceipt(lastResponse, url);
4807
3978
  this.safeEmit({ kind: "payment-settled", receipt });
4808
3979
  return lastResponse;
@@ -4816,7 +3987,7 @@ var PipRailClient = (_class2 = class {
4816
3987
  reason: `server returned 402 after broadcasting payment ${ref}${unconfirmedNote} (${why})`,
4817
3988
  ...lastReason ? { code: lastReason.error, detail: lastReason.detail } : {}
4818
3989
  });
4819
- throw new (0, _chunk3FR22M3Ocjs.MaxRetriesExceededError)(
3990
+ throw new (0, _chunkQONQSZHJcjs.MaxRetriesExceededError)(
4820
3991
  `Server still returned 402 after ${attempts} attempt(s) with on-chain proof ref=${ref}${unconfirmedNote}. Last server rejection: ${why}. Re-verify or re-submit ref=${ref} before retrying \u2014 never re-pay (it would double-spend).`,
4821
3992
  { ref }
4822
3993
  );
@@ -4838,19 +4009,30 @@ var PipRailClient = (_class2 = class {
4838
4009
  * • a 200 whose SettleResponse says `success:false` → a rejection, NEVER a spend;
4839
4010
  * • the spend is recorded EXACTLY ONCE, on an affirmative settlement only.
4840
4011
  */
4841
- async payExactRail(net, wallet, accept, url, init, quote) {
4012
+ async payExactRail(net, wallet, accept, url, init, quote, x402Version = 2) {
4842
4013
  if (!net.payExact) {
4843
- throw new (0, _chunk3FR22M3Ocjs.UnsupportedSchemeError)(
4014
+ throw new (0, _chunkQONQSZHJcjs.UnsupportedSchemeError)(
4844
4015
  `the ${net.family} family can't pay a standard 'exact' rail (supported on EVM, Solana, Algorand, Aptos + NEAR today).`
4845
4016
  );
4846
4017
  }
4847
- throwIfAborted(_optionalChain([init, 'optionalAccess', _82 => _82.signal]));
4018
+ throwIfAborted(_optionalChain([init, 'optionalAccess', _77 => _77.signal]));
4848
4019
  const { payload, accepted, payerFrom, nonce } = await net.payExact(wallet, accept);
4849
- const headers = new Headers(_optionalChain([init, 'optionalAccess', _83 => _83.headers]));
4850
- headers.set(HEADER_SIGNATURE, buildExactSignatureHeader({ accepted, payload }));
4020
+ const headers = new Headers(_optionalChain([init, 'optionalAccess', _78 => _78.headers]));
4021
+ if (x402Version === 1) {
4022
+ headers.set(
4023
+ _chunkOXEFPLZAcjs.HEADER_SIGNATURE_V1,
4024
+ _chunkOXEFPLZAcjs.buildV1PaymentHeader.call(void 0, {
4025
+ scheme: accepted.scheme,
4026
+ network: _nullishCoalesce(accept.wireNetwork, () => ( accepted.network)),
4027
+ payload
4028
+ })
4029
+ );
4030
+ } else {
4031
+ headers.set(_chunkOXEFPLZAcjs.HEADER_SIGNATURE, _chunkOXEFPLZAcjs.buildExactSignatureHeader.call(void 0, { accepted, payload }));
4032
+ }
4851
4033
  const rejectDefinitive = (why2) => {
4852
4034
  this.safeEmit({ kind: "payment-failed", reason: `exact: facilitator rejected nonce=${nonce} (${why2})`, code: why2 });
4853
- throw new (0, _chunk3FR22M3Ocjs.MaxRetriesExceededError)(
4035
+ throw new (0, _chunkQONQSZHJcjs.MaxRetriesExceededError)(
4854
4036
  `exact: the facilitator rejected the payment (${why2}). Fix the cause, then re-present the SAME signed authorization (nonce=${nonce}) \u2014 do NOT re-sign a fresh nonce. ref=${nonce}.`,
4855
4037
  { ref: nonce }
4856
4038
  );
@@ -4863,34 +4045,34 @@ var PipRailClient = (_class2 = class {
4863
4045
  if (Date.now() >= deadline) break;
4864
4046
  await new Promise((r) => setTimeout(r, Math.min(2e3, 400 * 2 ** (attempt - 1))));
4865
4047
  }
4866
- throwIfAborted(_optionalChain([init, 'optionalAccess', _84 => _84.signal]));
4048
+ throwIfAborted(_optionalChain([init, 'optionalAccess', _79 => _79.signal]));
4867
4049
  const budget = Math.min(this.retryTimeoutMs, deadline - Date.now());
4868
4050
  if (budget <= 0) break;
4869
4051
  const timeoutController = new AbortController();
4870
4052
  const timeoutId = setTimeout(() => timeoutController.abort(), budget);
4871
- const signal = _optionalChain([init, 'optionalAccess', _85 => _85.signal]) && typeof AbortSignal.any === "function" ? AbortSignal.any([timeoutController.signal, init.signal]) : timeoutController.signal;
4053
+ const signal = _optionalChain([init, 'optionalAccess', _80 => _80.signal]) && typeof AbortSignal.any === "function" ? AbortSignal.any([timeoutController.signal, init.signal]) : timeoutController.signal;
4872
4054
  let response;
4873
4055
  try {
4874
4056
  response = await fetch(url, { ..._nullishCoalesce(init, () => ( {})), headers, signal });
4875
4057
  } catch (err) {
4876
- throw new (0, _chunk3FR22M3Ocjs.PaymentTimeoutError)(
4877
- `exact: no response after submitting the authorization (nonce=${nonce}) to ${hostOf2(url)}. The facilitator may have already settled it \u2014 verify on-chain via ${exactSettleCheckHint(net.family, payerFrom, nonce)} before re-presenting the SAME signed authorization; do NOT re-pay.`,
4058
+ throw new (0, _chunkQONQSZHJcjs.PaymentTimeoutError)(
4059
+ `exact: no response after submitting the authorization (nonce=${nonce}) to ${hostOf(url)}. The facilitator may have already settled it \u2014 verify on-chain via ${exactSettleCheckHint(net.family, payerFrom, nonce)} before re-presenting the SAME signed authorization; do NOT re-pay.`,
4878
4060
  { cause: err, ref: nonce }
4879
4061
  );
4880
4062
  } finally {
4881
4063
  clearTimeout(timeoutId);
4882
4064
  }
4883
- const settle = parseSettleResponse(response);
4065
+ const settle = _chunkOXEFPLZAcjs.parseSettleResponse.call(void 0, response);
4884
4066
  if (response.status === 402) {
4885
4067
  if (settle && settle.success === false) rejectDefinitive(_nullishCoalesce(settle.errorReason, () => ( "the facilitator reported success:false")));
4886
4068
  lastReason = await _asyncNullishCoalesce(await readInvalidReason(response), async () => ( lastReason));
4887
4069
  continue;
4888
4070
  }
4889
4071
  if (response.ok && !(settle && settle.success === false)) {
4890
- const receipt = parseReceipt(response);
4072
+ const receipt = _chunkOXEFPLZAcjs.parseReceipt.call(void 0, response);
4891
4073
  this.captureReceipt(response, url);
4892
4074
  this.safeEmit({ kind: "payment-settled", receipt, ...settle ? { settle } : {} });
4893
- const ref = _optionalChain([settle, 'optionalAccess', _86 => _86.transaction]) || _optionalChain([receipt, 'optionalAccess', _87 => _87.transaction]) || `${net.family === "evm" ? "eip3009" : net.family}-nonce:${nonce}`;
4075
+ const ref = _optionalChain([settle, 'optionalAccess', _81 => _81.transaction]) || _optionalChain([receipt, 'optionalAccess', _82 => _82.transaction]) || `${net.family === "evm" ? "eip3009" : net.family}-nonce:${nonce}`;
4894
4076
  this.recordSpend(quote, ref);
4895
4077
  return response;
4896
4078
  }
@@ -4908,7 +4090,7 @@ var PipRailClient = (_class2 = class {
4908
4090
  reason: `exact: 402 after submitting authorization nonce=${nonce} (${why})`,
4909
4091
  ...lastReason ? { code: lastReason.error, detail: lastReason.detail } : {}
4910
4092
  });
4911
- throw new (0, _chunk3FR22M3Ocjs.MaxRetriesExceededError)(
4093
+ throw new (0, _chunkQONQSZHJcjs.MaxRetriesExceededError)(
4912
4094
  `exact: server still returned 402 after submitting the signed authorization (nonce=${nonce}). Last rejection: ${why}. Re-present the SAME authorization \u2014 do NOT re-sign a fresh nonce; verify on-chain via ${exactSettleCheckHint(net.family, payerFrom, nonce)} first. ref=${nonce}.`,
4913
4095
  { ref: nonce }
4914
4096
  );
@@ -4924,17 +4106,17 @@ var PipRailClient = (_class2 = class {
4924
4106
  */
4925
4107
  async payUptoRail(net, wallet, accept, url, init, quote) {
4926
4108
  if (!net.payUpto) {
4927
- throw new (0, _chunk3FR22M3Ocjs.UnsupportedSchemeError)(
4109
+ throw new (0, _chunkQONQSZHJcjs.UnsupportedSchemeError)(
4928
4110
  `the ${net.family} family can't pay a standard 'upto' rail (EVM-Permit2 only today).`
4929
4111
  );
4930
4112
  }
4931
- throwIfAborted(_optionalChain([init, 'optionalAccess', _88 => _88.signal]));
4113
+ throwIfAborted(_optionalChain([init, 'optionalAccess', _83 => _83.signal]));
4932
4114
  const { payload, accepted, payerFrom, nonce } = await net.payUpto(wallet, accept);
4933
- const headers = new Headers(_optionalChain([init, 'optionalAccess', _89 => _89.headers]));
4934
- headers.set(HEADER_SIGNATURE, buildUptoSignatureHeader({ accepted, payload }));
4115
+ const headers = new Headers(_optionalChain([init, 'optionalAccess', _84 => _84.headers]));
4116
+ headers.set(_chunkOXEFPLZAcjs.HEADER_SIGNATURE, _chunkOXEFPLZAcjs.buildUptoSignatureHeader.call(void 0, { accepted, payload }));
4935
4117
  const rejectDefinitive = (why2) => {
4936
4118
  this.safeEmit({ kind: "payment-failed", reason: `upto: facilitator rejected nonce=${nonce} (${why2})`, code: why2 });
4937
- throw new (0, _chunk3FR22M3Ocjs.MaxRetriesExceededError)(
4119
+ throw new (0, _chunkQONQSZHJcjs.MaxRetriesExceededError)(
4938
4120
  `upto: the server rejected the payment (${why2}). Fix the cause, then re-present the SAME signed authorization (nonce=${nonce}) \u2014 do NOT re-sign a fresh nonce. ref=${nonce}.`,
4939
4121
  { ref: nonce }
4940
4122
  );
@@ -4947,35 +4129,35 @@ var PipRailClient = (_class2 = class {
4947
4129
  if (Date.now() >= deadline) break;
4948
4130
  await new Promise((r) => setTimeout(r, Math.min(2e3, 400 * 2 ** (attempt - 1))));
4949
4131
  }
4950
- throwIfAborted(_optionalChain([init, 'optionalAccess', _90 => _90.signal]));
4132
+ throwIfAborted(_optionalChain([init, 'optionalAccess', _85 => _85.signal]));
4951
4133
  const budget = Math.min(this.retryTimeoutMs, deadline - Date.now());
4952
4134
  if (budget <= 0) break;
4953
4135
  const timeoutController = new AbortController();
4954
4136
  const timeoutId = setTimeout(() => timeoutController.abort(), budget);
4955
- const signal = _optionalChain([init, 'optionalAccess', _91 => _91.signal]) && typeof AbortSignal.any === "function" ? AbortSignal.any([timeoutController.signal, init.signal]) : timeoutController.signal;
4137
+ const signal = _optionalChain([init, 'optionalAccess', _86 => _86.signal]) && typeof AbortSignal.any === "function" ? AbortSignal.any([timeoutController.signal, init.signal]) : timeoutController.signal;
4956
4138
  let response;
4957
4139
  try {
4958
4140
  response = await fetch(url, { ..._nullishCoalesce(init, () => ( {})), headers, signal });
4959
4141
  } catch (err) {
4960
- throw new (0, _chunk3FR22M3Ocjs.PaymentTimeoutError)(
4961
- `upto: no response after submitting the authorization (nonce=${nonce}) to ${hostOf2(url)}. The merchant may have already settled it \u2014 verify on-chain before re-presenting; do NOT re-pay.`,
4142
+ throw new (0, _chunkQONQSZHJcjs.PaymentTimeoutError)(
4143
+ `upto: no response after submitting the authorization (nonce=${nonce}) to ${hostOf(url)}. The merchant may have already settled it \u2014 verify on-chain before re-presenting; do NOT re-pay.`,
4962
4144
  { cause: err, ref: nonce }
4963
4145
  );
4964
4146
  } finally {
4965
4147
  clearTimeout(timeoutId);
4966
4148
  }
4967
- const settle = parseSettleResponse(response);
4149
+ const settle = _chunkOXEFPLZAcjs.parseSettleResponse.call(void 0, response);
4968
4150
  if (response.status === 402) {
4969
4151
  if (settle && settle.success === false) rejectDefinitive(_nullishCoalesce(settle.errorReason, () => ( "the server reported success:false")));
4970
4152
  lastReason = await _asyncNullishCoalesce(await readInvalidReason(response), async () => ( lastReason));
4971
4153
  continue;
4972
4154
  }
4973
4155
  if (response.ok && !(settle && settle.success === false)) {
4974
- const receipt = parseReceipt(response);
4156
+ const receipt = _chunkOXEFPLZAcjs.parseReceipt.call(void 0, response);
4975
4157
  this.captureReceipt(response, url);
4976
4158
  this.safeEmit({ kind: "payment-settled", receipt, ...settle ? { settle } : {} });
4977
- const ref = _optionalChain([settle, 'optionalAccess', _92 => _92.transaction]) || _optionalChain([receipt, 'optionalAccess', _93 => _93.transaction]) || `upto-nonce:${nonce}`;
4978
- const settledAmount = _nullishCoalesce(_optionalChain([settle, 'optionalAccess', _94 => _94.amount]), () => ( _optionalChain([receipt, 'optionalAccess', _95 => _95.amount])));
4159
+ const ref = _optionalChain([settle, 'optionalAccess', _87 => _87.transaction]) || _optionalChain([receipt, 'optionalAccess', _88 => _88.transaction]) || `upto-nonce:${nonce}`;
4160
+ const settledAmount = _nullishCoalesce(_optionalChain([settle, 'optionalAccess', _89 => _89.amount]), () => ( _optionalChain([receipt, 'optionalAccess', _90 => _90.amount])));
4979
4161
  this.recordSpend(quote, ref, settledAmount);
4980
4162
  return response;
4981
4163
  }
@@ -4993,21 +4175,21 @@ var PipRailClient = (_class2 = class {
4993
4175
  reason: `upto: 402 after submitting authorization nonce=${nonce} (${why})`,
4994
4176
  ...lastReason ? { code: lastReason.error, detail: lastReason.detail } : {}
4995
4177
  });
4996
- throw new (0, _chunk3FR22M3Ocjs.MaxRetriesExceededError)(
4178
+ throw new (0, _chunkQONQSZHJcjs.MaxRetriesExceededError)(
4997
4179
  `upto: server still returned 402 after submitting the signed authorization (nonce=${nonce}). Last rejection: ${why}. Re-present the SAME authorization \u2014 do NOT re-sign a fresh nonce. ref=${nonce}.`,
4998
4180
  { ref: nonce }
4999
4181
  );
5000
4182
  }
5001
4183
  }, _class2);
5002
4184
  function throwIfAborted(signal) {
5003
- if (_optionalChain([signal, 'optionalAccess', _96 => _96.aborted])) {
4185
+ if (_optionalChain([signal, 'optionalAccess', _91 => _91.aborted])) {
5004
4186
  throw _nullishCoalesce(signal.reason, () => ( new DOMException("This operation was aborted.", "AbortError")));
5005
4187
  }
5006
4188
  }
5007
4189
  function safeBig(s) {
5008
4190
  try {
5009
4191
  return BigInt(s);
5010
- } catch (e38) {
4192
+ } catch (e31) {
5011
4193
  return 0n;
5012
4194
  }
5013
4195
  }
@@ -5070,10 +4252,10 @@ function buildFundingHint(options, chainLabel) {
5070
4252
  return `Couldn't fully read your wallet on ${chainLabel} (RPC throttled) \u2014 retry; you may already be able to pay ${target.quote.amountFormatted} ${sym}.`;
5071
4253
  }
5072
4254
  const parts = [];
5073
- if (target.blockers.includes("INSUFFICIENT_TOKEN") && _optionalChain([target, 'access', _97 => _97.shortfall, 'optionalAccess', _98 => _98.token])) {
4255
+ if (target.blockers.includes("INSUFFICIENT_TOKEN") && _optionalChain([target, 'access', _92 => _92.shortfall, 'optionalAccess', _93 => _93.token])) {
5074
4256
  parts.push(`top up ${target.shortfall.token} ${sym}`);
5075
4257
  }
5076
- if (target.blockers.includes("INSUFFICIENT_GAS") && _optionalChain([target, 'access', _99 => _99.shortfall, 'optionalAccess', _100 => _100.native])) {
4258
+ if (target.blockers.includes("INSUFFICIENT_GAS") && _optionalChain([target, 'access', _94 => _94.shortfall, 'optionalAccess', _95 => _95.native])) {
5077
4259
  parts.push(`add ~${target.shortfall.native} ${target.cost.feeSymbol} for gas`);
5078
4260
  }
5079
4261
  return parts.length ? `Can't settle on ${chainLabel}: ${parts.join(" and ")} (to pay ${target.quote.amountFormatted} ${sym}).` : `Can't settle on ${chainLabel} for ${target.quote.amountFormatted} ${sym}.`;
@@ -5087,7 +4269,7 @@ async function planAcross(clients, url, init) {
5087
4269
  const status = best ? "ready" : options.some((o) => o.state === "unknown") ? "unknown" : "blocked";
5088
4270
  return {
5089
4271
  url,
5090
- network: _nullishCoalesce(_optionalChain([best, 'optionalAccess', _101 => _101.accept, 'access', _102 => _102.network]), () => ( live[0].network)),
4272
+ network: _nullishCoalesce(_optionalChain([best, 'optionalAccess', _96 => _96.accept, 'access', _97 => _97.network]), () => ( live[0].network)),
5091
4273
  status,
5092
4274
  payable: best !== null,
5093
4275
  best,
@@ -5106,13 +4288,13 @@ async function fetchAcross(clients, url, init) {
5106
4288
  const best = rankAcross(live.map((p) => p.plan)).find((o) => o.state === "payable");
5107
4289
  if (!best) {
5108
4290
  const hint = mergeDeclineHint(live.map((p) => p.plan));
5109
- throw new (0, _chunk3FR22M3Ocjs.PaymentDeclinedError)(hint || "No funded chain can settle this payment right now.");
4291
+ throw new (0, _chunkQONQSZHJcjs.PaymentDeclinedError)(hint || "No funded chain can settle this payment right now.");
5110
4292
  }
5111
4293
  const owner = live.find((p) => p.plan.options.includes(best)).client;
5112
4294
  return owner.fetch(url, { ..._nullishCoalesce(init, () => ( {})), autoRoute: true });
5113
4295
  }
5114
4296
  function railOnNetwork(rail, matches) {
5115
- const n = normalizeNetwork(rail.network);
4297
+ const n = _chunkV2IJ5HUWcjs.normalizeNetwork.call(void 0, rail.network);
5116
4298
  return !n.includes(":") || matches(n);
5117
4299
  }
5118
4300
  function reasonCodeForPolicy(code) {
@@ -5132,10 +4314,10 @@ function reasonCodeForPolicy(code) {
5132
4314
  return "POLICY";
5133
4315
  }
5134
4316
  }
5135
- function hostOf2(url) {
4317
+ function hostOf(url) {
5136
4318
  try {
5137
4319
  return new URL(url).hostname;
5138
- } catch (e39) {
4320
+ } catch (e32) {
5139
4321
  return url;
5140
4322
  }
5141
4323
  }
@@ -5152,8 +4334,8 @@ function isReplayableBodyInit(value) {
5152
4334
  async function readInvalidReason(response) {
5153
4335
  try {
5154
4336
  const body = await response.clone().json();
5155
- const ext = _optionalChain([body, 'optionalAccess', _103 => _103.extensions]);
5156
- const piprail = _optionalChain([ext, 'optionalAccess', _104 => _104.piprail]);
4337
+ const ext = _optionalChain([body, 'optionalAccess', _98 => _98.extensions]);
4338
+ const piprail = _optionalChain([ext, 'optionalAccess', _99 => _99.piprail]);
5157
4339
  if (piprail && typeof piprail.code === "string") {
5158
4340
  return {
5159
4341
  error: piprail.code,
@@ -5172,10 +4354,10 @@ async function readInvalidReason(response) {
5172
4354
  detail: typeof body.invalidMessage === "string" ? body.invalidMessage : ""
5173
4355
  };
5174
4356
  }
5175
- } catch (e40) {
4357
+ } catch (e33) {
5176
4358
  }
5177
- const settle = parseSettleResponse(response);
5178
- if (_optionalChain([settle, 'optionalAccess', _105 => _105.errorReason])) return { error: settle.errorReason, detail: "" };
4359
+ const settle = _chunkOXEFPLZAcjs.parseSettleResponse.call(void 0, response);
4360
+ if (_optionalChain([settle, 'optionalAccess', _100 => _100.errorReason])) return { error: settle.errorReason, detail: "" };
5179
4361
  return null;
5180
4362
  }
5181
4363
  var EVM_PRESET_FOR_CHAINID = {
@@ -5188,7 +4370,7 @@ var EVM_PRESET_FOR_CHAINID = {
5188
4370
  56: "bnb"
5189
4371
  };
5190
4372
  function chainSelectorForNetwork(network, rpcUrl) {
5191
- const chainId = chainIdFromNetwork(network);
4373
+ const chainId = _chunkOXEFPLZAcjs.chainIdFromNetwork.call(void 0, network);
5192
4374
  if (chainId !== null) {
5193
4375
  const preset = EVM_PRESET_FOR_CHAINID[chainId];
5194
4376
  if (preset) return preset;
@@ -5273,7 +4455,7 @@ var MultiChainPayer = class _MultiChainPayer {
5273
4455
  ledger,
5274
4456
  ...opts.policy ? { policy: opts.policy } : {},
5275
4457
  ...opts.schemes ? { schemes: opts.schemes } : {},
5276
- ..._optionalChain([opts, 'access', _106 => _106.rpcUrls, 'optionalAccess', _107 => _107[chain]]) ? { rpcUrl: opts.rpcUrls[chain] } : {},
4458
+ ..._optionalChain([opts, 'access', _101 => _101.rpcUrls, 'optionalAccess', _102 => _102[chain]]) ? { rpcUrl: opts.rpcUrls[chain] } : {},
5277
4459
  ...opts.onBeforePay ? { onBeforePay: opts.onBeforePay } : {},
5278
4460
  ...opts.onEvent ? { onEvent: opts.onEvent } : {},
5279
4461
  ...opts.maxPaymentRetries != null ? { maxPaymentRetries: opts.maxPaymentRetries } : {},
@@ -5331,7 +4513,7 @@ var MultiChainPayer = class _MultiChainPayer {
5331
4513
  * {@link PipRailClient.post}.
5332
4514
  */
5333
4515
  post(url, body, init) {
5334
- const headers = new Headers(_optionalChain([init, 'optionalAccess', _108 => _108.headers]));
4516
+ const headers = new Headers(_optionalChain([init, 'optionalAccess', _103 => _103.headers]));
5335
4517
  let payload;
5336
4518
  if (body === void 0 || body === null) {
5337
4519
  payload = void 0;
@@ -5481,14 +4663,14 @@ function buildSelfDescription(input) {
5481
4663
  }
5482
4664
  function buildEndpointInfo(input) {
5483
4665
  const d = input.descriptor;
5484
- const summary = _nullishCoalesce(_optionalChain([d, 'optionalAccess', _109 => _109.summary]), () => ( input.description));
5485
- const hasInput = _optionalChain([d, 'optionalAccess', _110 => _110.queryParams]) && Object.keys(d.queryParams).length > 0;
4666
+ const summary = _nullishCoalesce(_optionalChain([d, 'optionalAccess', _104 => _104.summary]), () => ( input.description));
4667
+ const hasInput = _optionalChain([d, 'optionalAccess', _105 => _105.queryParams]) && Object.keys(d.queryParams).length > 0;
5486
4668
  const endpoint = {
5487
4669
  ...summary ? { summary } : {},
5488
- ..._optionalChain([d, 'optionalAccess', _111 => _111.method]) ? { method: d.method.toUpperCase() } : {},
4670
+ ..._optionalChain([d, 'optionalAccess', _106 => _106.method]) ? { method: d.method.toUpperCase() } : {},
5489
4671
  ...input.mimeType ? { mimeType: input.mimeType } : {},
5490
4672
  ...hasInput ? { input: d.queryParams } : {},
5491
- ..._optionalChain([d, 'optionalAccess', _112 => _112.output]) ? { output: d.output } : {}
4673
+ ..._optionalChain([d, 'optionalAccess', _107 => _107.output]) ? { output: d.output } : {}
5492
4674
  };
5493
4675
  return Object.keys(endpoint).length > 0 ? endpoint : void 0;
5494
4676
  }
@@ -5506,7 +4688,7 @@ function summarizePlan(plan) {
5506
4688
  return `NOT payable: ${_nullishCoalesce(plan.fundingHint, () => ( `no settleable rail on ${plan.network}`))}`;
5507
4689
  }
5508
4690
  function explainDecline(err) {
5509
- if (!(err instanceof _chunk3FR22M3Ocjs.PipRailError)) {
4691
+ if (!(err instanceof _chunkQONQSZHJcjs.PipRailError)) {
5510
4692
  return `Payment failed: ${err instanceof Error ? err.message : String(err)}`;
5511
4693
  }
5512
4694
  switch (err.code) {
@@ -5539,16 +4721,16 @@ function formatSpendReport(summary) {
5539
4721
  function describeChallenge(challenge) {
5540
4722
  const generic = `${BRAND.name} x402 payment endpoint. Pay with @piprail/sdk (${BRAND.sdkInstall}). Docs: ${BRAND.home}.`;
5541
4723
  try {
5542
- const accepts = Array.isArray(_optionalChain([challenge, 'optionalAccess', _113 => _113.accepts])) ? challenge.accepts : [];
4724
+ const accepts = Array.isArray(_optionalChain([challenge, 'optionalAccess', _108 => _108.accepts])) ? challenge.accepts : [];
5543
4725
  const first = accepts[0];
5544
4726
  if (!first) return generic;
5545
4727
  const extra = _nullishCoalesce(first.extra, () => ( {}));
5546
4728
  const amount = _nullishCoalesce(extra.amountFormatted, () => ( first.amount));
5547
4729
  const token = _nullishCoalesce(extra.symbol, () => ( first.asset));
5548
- const hasExact = accepts.some((a) => _optionalChain([a, 'optionalAccess', _114 => _114.scheme]) === "exact");
4730
+ const hasExact = accepts.some((a) => _optionalChain([a, 'optionalAccess', _109 => _109.scheme]) === "exact");
5549
4731
  const standard = hasExact ? "; or any standard x402 client (an exact rail is offered)" : "";
5550
4732
  return `${BRAND.name} x402 payment endpoint \u2014 pay ${amount} ${token} on ${first.network} to ${first.payTo}. Programmatic: ${BRAND.sdkInstall} then client.fetch(url)${standard}. Docs: ${BRAND.home}.`;
5551
- } catch (e41) {
4733
+ } catch (e34) {
5552
4734
  return generic;
5553
4735
  }
5554
4736
  }
@@ -5586,6 +4768,9 @@ A 402 may offer up to three rails; you don't choose per payment \u2014 the clien
5586
4768
  (e.g. PayAI) \u2014 broadcasts it, so you pay ZERO gas (you need only the token, no native coin). It
5587
4769
  works on EVM, Solana, Algorand, Aptos + NEAR, and the on-chain method (EIP-3009 / Permit2 / SVM /
5588
4770
  Algorand fee-pooled group / Aptos fee-payer / NEAR SignedDelegateAction) is picked automatically.
4771
+ XRPL also supports exact (native XRP), with ONE difference that matters to your budget: there the
4772
+ PAYER pays the network fee, because on the XRP Ledger the fee lives inside the signed transaction.
4773
+ So keep a little XRP for fees on that chain \u2014 everywhere else exact means you need no native coin.
5589
4774
  - upto (the metered/variable x402 rail, opt-in, EVM): the amount you see is a MAXIMUM \u2014 you sign
5590
4775
  a ceiling, the server meters real usage and settles the ACTUAL (<= the max). BUDGET AGAINST THE MAX:
5591
4776
  the plan/policy treat the ceiling as the spend (a server may charge up to it), so a payable plan
@@ -5657,19 +4842,19 @@ async function readBody(res) {
5657
4842
  if (!text) return null;
5658
4843
  try {
5659
4844
  return JSON.parse(text);
5660
- } catch (e42) {
4845
+ } catch (e35) {
5661
4846
  return text;
5662
4847
  }
5663
4848
  }
5664
4849
  function toToolError(err) {
5665
- if (!(err instanceof _chunk3FR22M3Ocjs.PipRailError)) throw err;
4850
+ if (!(err instanceof _chunkQONQSZHJcjs.PipRailError)) throw err;
5666
4851
  const out = {
5667
4852
  ok: false,
5668
4853
  code: err.code,
5669
4854
  reason: err.message,
5670
4855
  explain: explainDecline(err)
5671
4856
  };
5672
- if (err instanceof _chunk3FR22M3Ocjs.PaymentDeclinedError) {
4857
+ if (err instanceof _chunkQONQSZHJcjs.PaymentDeclinedError) {
5673
4858
  out.declined = true;
5674
4859
  if (err.reasonCode) out.reasonCode = err.reasonCode;
5675
4860
  }
@@ -5876,23 +5061,23 @@ function paymentTools(client) {
5876
5061
  }
5877
5062
  res = await client.fetch(url, { method, headers, body });
5878
5063
  }
5879
- const verifiable = parseReceiptExtension(res);
5064
+ const verifiable = _chunkOXEFPLZAcjs.parseReceiptExtension.call(void 0, res);
5880
5065
  return {
5881
5066
  status: res.status,
5882
5067
  ok: res.ok,
5883
5068
  body: await readBody(res),
5884
- receipt: parseReceipt(res),
5069
+ receipt: _chunkOXEFPLZAcjs.parseReceipt.call(void 0, res),
5885
5070
  ...verifiable ? { verifiableReceipt: { ...verifiable, resource: { url } } } : {}
5886
5071
  };
5887
5072
  } catch (err) {
5888
- if (err instanceof _chunk3FR22M3Ocjs.PipRailError) {
5073
+ if (err instanceof _chunkQONQSZHJcjs.PipRailError) {
5889
5074
  const out = {
5890
5075
  ok: false,
5891
5076
  code: err.code,
5892
5077
  reason: err.message,
5893
5078
  explain: explainDecline(err)
5894
5079
  };
5895
- if (err instanceof _chunk3FR22M3Ocjs.PaymentDeclinedError) {
5080
+ if (err instanceof _chunkQONQSZHJcjs.PaymentDeclinedError) {
5896
5081
  out.declined = true;
5897
5082
  if (err.reasonCode) out.reasonCode = err.reasonCode;
5898
5083
  }
@@ -6041,20 +5226,20 @@ function paymentTools(client) {
6041
5226
  // src/classify.ts
6042
5227
  function classifyChallenge(challenge, opts) {
6043
5228
  try {
6044
- const accepts = Array.isArray(_optionalChain([challenge, 'optionalAccess', _115 => _115.accepts])) ? challenge.accepts : [];
6045
- const network = _optionalChain([opts, 'optionalAccess', _116 => _116.network]);
6046
- const schemes = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _117 => _117.schemes]), () => ( []));
5229
+ const accepts = Array.isArray(_optionalChain([challenge, 'optionalAccess', _110 => _110.accepts])) ? challenge.accepts : [];
5230
+ const network = _optionalChain([opts, 'optionalAccess', _111 => _111.network]);
5231
+ const schemes = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _112 => _112.schemes]), () => ( []));
6047
5232
  const offeredSchemes = [
6048
- ...new Set(accepts.map((a) => _optionalChain([a, 'optionalAccess', _118 => _118.scheme])).filter((s) => s != null))
5233
+ ...new Set(accepts.map((a) => _optionalChain([a, 'optionalAccess', _113 => _113.scheme])).filter((s) => s != null))
6049
5234
  ];
6050
- const offeredNetworks = [...new Set(accepts.map((a) => _optionalChain([a, 'optionalAccess', _119 => _119.network])).filter((n) => n != null))];
6051
- const onClientChain = accepts.some((a) => _optionalChain([a, 'optionalAccess', _120 => _120.network]) === network);
5235
+ const offeredNetworks = [...new Set(accepts.map((a) => _optionalChain([a, 'optionalAccess', _114 => _114.network])).filter((n) => n != null))];
5236
+ const onClientChain = accepts.some((a) => _optionalChain([a, 'optionalAccess', _115 => _115.network]) === network);
6052
5237
  const payableScheme = accepts.some(
6053
- (a) => _optionalChain([a, 'optionalAccess', _121 => _121.network]) === network && schemes.includes(_optionalChain([a, 'optionalAccess', _122 => _122.scheme]))
5238
+ (a) => _optionalChain([a, 'optionalAccess', _116 => _116.network]) === network && schemes.includes(_optionalChain([a, 'optionalAccess', _117 => _117.scheme]))
6054
5239
  );
6055
5240
  const verdict = accepts.length === 0 ? "NO_RAIL" : payableScheme ? "PAYABLE_RAIL" : onClientChain ? "UNPAYABLE_SCHEME" : "WRONG_CHAIN";
6056
5241
  return { onClientChain, payableScheme, offeredSchemes, offeredNetworks, verdict };
6057
- } catch (e43) {
5242
+ } catch (e36) {
6058
5243
  return {
6059
5244
  onClientChain: false,
6060
5245
  payableScheme: false,
@@ -6104,12 +5289,12 @@ function buildBazaarExtension(descriptor = {}) {
6104
5289
  function pathOf(url) {
6105
5290
  try {
6106
5291
  return new URL(url).pathname || "/";
6107
- } catch (e44) {
5292
+ } catch (e37) {
6108
5293
  return url.startsWith("/") ? url : `/${url}`;
6109
5294
  }
6110
5295
  }
6111
5296
  function buildOpenApi(input) {
6112
- assertResourceList(_optionalChain([input, 'optionalAccess', _123 => _123.resources]), "buildOpenApi");
5297
+ assertResourceList(_optionalChain([input, 'optionalAccess', _118 => _118.resources]), "buildOpenApi");
6113
5298
  const paths = {};
6114
5299
  for (const r of input.resources) {
6115
5300
  const path = pathOf(r.url);
@@ -6139,7 +5324,7 @@ function buildOpenApi(input) {
6139
5324
  };
6140
5325
  }
6141
5326
  function buildWellKnownX402(input) {
6142
- assertResourceList(_optionalChain([input, 'optionalAccess', _124 => _124.resources]), "buildWellKnownX402");
5327
+ assertResourceList(_optionalChain([input, 'optionalAccess', _119 => _119.resources]), "buildWellKnownX402");
6143
5328
  return {
6144
5329
  version: 1,
6145
5330
  resources: input.resources.map((r) => r.url),
@@ -6148,18 +5333,18 @@ function buildWellKnownX402(input) {
6148
5333
  }
6149
5334
  function assertResourceList(resources, fn) {
6150
5335
  if (!Array.isArray(resources)) {
6151
- throw new (0, _chunk3FR22M3Ocjs.InvalidConfigError)(`${fn}: \`resources\` must be an array of ResourceDescription.`);
5336
+ throw new (0, _chunkQONQSZHJcjs.InvalidConfigError)(`${fn}: \`resources\` must be an array of ResourceDescription.`);
6152
5337
  }
6153
5338
  resources.forEach((r, i) => {
6154
5339
  if (r === null || typeof r !== "object" || typeof r.url !== "string") {
6155
- throw new (0, _chunk3FR22M3Ocjs.InvalidConfigError)(
5340
+ throw new (0, _chunkQONQSZHJcjs.InvalidConfigError)(
6156
5341
  `${fn}: resources[${i}] must be a ResourceDescription with a string \`url\`.`
6157
5342
  );
6158
5343
  }
6159
5344
  });
6160
5345
  }
6161
5346
  function buildWellKnownX402Manifest(input) {
6162
- assertResourceList(_optionalChain([input, 'optionalAccess', _125 => _125.resources]), "buildWellKnownX402Manifest");
5347
+ assertResourceList(_optionalChain([input, 'optionalAccess', _120 => _120.resources]), "buildWellKnownX402Manifest");
6163
5348
  const lastUpdated = typeof input.lastUpdated === "number" && Number.isFinite(input.lastUpdated) ? input.lastUpdated : Math.floor(Date.now() / 1e3);
6164
5349
  return {
6165
5350
  x402Version: 2,
@@ -6246,28 +5431,28 @@ async function fetchFacilitatorFeePayer(url, network, timeoutMs = 8e3) {
6246
5431
  const res = await fetch(`${base2}/supported`, { signal: ctrl.signal });
6247
5432
  if (!res.ok) return void 0;
6248
5433
  const body = await res.json();
6249
- const kinds = Array.isArray(_optionalChain([body, 'optionalAccess', _126 => _126.kinds])) ? body.kinds : [];
6250
- const want = normalizeNetwork(network);
6251
- const kind = kinds.find((k) => _optionalChain([k, 'optionalAccess', _127 => _127.scheme]) === "exact" && normalizeNetwork(String(_nullishCoalesce(_optionalChain([k, 'optionalAccess', _128 => _128.network]), () => ( "")))) === want);
6252
- const fp = _optionalChain([kind, 'optionalAccess', _129 => _129.extra, 'optionalAccess', _130 => _130.feePayer]);
5434
+ const kinds = Array.isArray(_optionalChain([body, 'optionalAccess', _121 => _121.kinds])) ? body.kinds : [];
5435
+ const want = _chunkV2IJ5HUWcjs.normalizeNetwork.call(void 0, network);
5436
+ const kind = kinds.find((k) => _optionalChain([k, 'optionalAccess', _122 => _122.scheme]) === "exact" && _chunkV2IJ5HUWcjs.normalizeNetwork.call(void 0, String(_nullishCoalesce(_optionalChain([k, 'optionalAccess', _123 => _123.network]), () => ( "")))) === want);
5437
+ const fp = _optionalChain([kind, 'optionalAccess', _124 => _124.extra, 'optionalAccess', _125 => _125.feePayer]);
6253
5438
  return typeof fp === "string" ? fp : void 0;
6254
- } catch (e45) {
5439
+ } catch (e38) {
6255
5440
  return void 0;
6256
5441
  } finally {
6257
5442
  clearTimeout(timer);
6258
5443
  }
6259
5444
  }
6260
5445
  function parseFacilitatorSupported(body) {
6261
- const kinds = _optionalChain([body, 'optionalAccess', _131 => _131.kinds]);
5446
+ const kinds = _optionalChain([body, 'optionalAccess', _126 => _126.kinds]);
6262
5447
  if (!Array.isArray(kinds)) return [];
6263
5448
  const out = [];
6264
5449
  for (const k of kinds) {
6265
5450
  if (!k || typeof k !== "object") continue;
6266
5451
  const o = k;
6267
5452
  if (typeof o.scheme !== "string" || typeof o.network !== "string") continue;
6268
- const fp = _optionalChain([o, 'access', _132 => _132.extra, 'optionalAccess', _133 => _133.feePayer]);
5453
+ const fp = _optionalChain([o, 'access', _127 => _127.extra, 'optionalAccess', _128 => _128.feePayer]);
6269
5454
  const ver = o.x402Version;
6270
- const method = _optionalChain([o, 'access', _134 => _134.extra, 'optionalAccess', _135 => _135.assetTransferMethod]);
5455
+ const method = _optionalChain([o, 'access', _129 => _129.extra, 'optionalAccess', _130 => _130.assetTransferMethod]);
6271
5456
  out.push({
6272
5457
  scheme: o.scheme,
6273
5458
  network: o.network,
@@ -6286,7 +5471,7 @@ async function facilitatorCoverage(url, timeoutMs = 8e3) {
6286
5471
  const res = await fetch(`${base2}/supported`, { signal: ctrl.signal });
6287
5472
  if (!res.ok) return [];
6288
5473
  return parseFacilitatorSupported(await res.json());
6289
- } catch (e46) {
5474
+ } catch (e39) {
6290
5475
  return [];
6291
5476
  } finally {
6292
5477
  clearTimeout(timer);
@@ -6315,7 +5500,7 @@ async function post(url, body, headers) {
6315
5500
  let json = null;
6316
5501
  try {
6317
5502
  json = await res.json();
6318
- } catch (e47) {
5503
+ } catch (e40) {
6319
5504
  }
6320
5505
  return { status: res.status, json };
6321
5506
  }
@@ -6331,13 +5516,13 @@ async function settleViaFacilitator(input) {
6331
5516
  try {
6332
5517
  verify = await post(`${base2}/verify`, body, auth);
6333
5518
  } catch (err) {
6334
- throw new (0, _chunk3FR22M3Ocjs.SettlementError)(
5519
+ throw new (0, _chunkQONQSZHJcjs.SettlementError)(
6335
5520
  `exact settle (facilitator ${base2}): /verify request failed (${err instanceof Error ? err.message : String(err)}).`,
6336
5521
  { cause: err }
6337
5522
  );
6338
5523
  }
6339
5524
  if (verify.status !== 200) {
6340
- throw new (0, _chunk3FR22M3Ocjs.SettlementError)(
5525
+ throw new (0, _chunkQONQSZHJcjs.SettlementError)(
6341
5526
  `exact settle (facilitator ${base2}): /verify returned HTTP ${verify.status} (transport/auth error).`
6342
5527
  );
6343
5528
  }
@@ -6353,13 +5538,13 @@ async function settleViaFacilitator(input) {
6353
5538
  try {
6354
5539
  settle = await post(`${base2}/settle`, body, auth);
6355
5540
  } catch (err) {
6356
- throw new (0, _chunk3FR22M3Ocjs.SettlementError)(
5541
+ throw new (0, _chunkQONQSZHJcjs.SettlementError)(
6357
5542
  `exact settle (facilitator ${base2}): /settle request failed (${err instanceof Error ? err.message : String(err)}).`,
6358
5543
  { cause: err }
6359
5544
  );
6360
5545
  }
6361
5546
  if (settle.status !== 200) {
6362
- throw new (0, _chunk3FR22M3Ocjs.SettlementError)(
5547
+ throw new (0, _chunkQONQSZHJcjs.SettlementError)(
6363
5548
  `exact settle (facilitator ${base2}): /settle returned HTTP ${settle.status} (transport/auth error).`
6364
5549
  );
6365
5550
  }
@@ -6395,82 +5580,61 @@ var KNOWN_FACILITATORS = {
6395
5580
  keyless: true,
6396
5581
  schemes: ["exact"],
6397
5582
  settles: ["eip3009"],
6398
- note: "PayAI \u2014 keyless, sponsors gas (Base USDC EIP-3009). Verified 2026-06-14 (/supported + live demo)."
5583
+ note: "PayAI: keyless, sponsors gas (Base USDC EIP-3009). Verified 2026-06-14 (/supported + live demo)."
6399
5584
  },
6400
5585
  {
6401
5586
  url: "https://facilitator.xpay.sh",
6402
5587
  keyless: true,
6403
5588
  schemes: ["exact"],
6404
5589
  settles: ["eip3009"],
6405
- note: "xpay \u2014 keyless, zero-fee, sponsors gas. LIVE-settled on Base 2026-06-15 (tx 0x2273d5\u2026)."
5590
+ note: "xpay: keyless, zero-fee, sponsors gas. LIVE-settled on Base 2026-06-15 (tx 0x2273d5\u2026)."
6406
5591
  },
6407
5592
  {
6408
5593
  url: "https://facilitator.ultravioletadao.xyz",
6409
5594
  keyless: true,
6410
5595
  schemes: ["exact"],
6411
5596
  settles: ["eip3009"],
6412
- note: "Ultravioleta DAO \u2014 keyless, 100% gas-sponsored (Base USDC EIP-3009). LIVE-settled on Base 2026-06-17 (tx 0x58a69042a4129be649c5642456752ede95a5ff921daddfd30560ae70ae5907ff). 2nd UVD validation chain (after HyperEVM)."
5597
+ note: "Ultravioleta DAO: keyless, 100% gas-sponsored (Base USDC EIP-3009). LIVE-settled on Base 2026-06-17 (tx 0x58a69042a4129be649c5642456752ede95a5ff921daddfd30560ae70ae5907ff). 2nd UVD validation chain (after HyperEVM)."
6413
5598
  },
6414
5599
  {
6415
5600
  url: "https://x402.dexter.cash",
6416
5601
  keyless: true,
6417
5602
  schemes: ["exact"],
6418
5603
  settles: ["eip3009"],
6419
- note: "Dexter \u2014 keyless, gas-sponsored (Base USDC EIP-3009). LIVE-settled on Base 2026-06-17 (tx 0xdf030e4d5bf41a88c5a3bfe73bb433dfbb90b058d3b8ded63b68e026eedb9de8). Note: ~$0.001 dynamic floor on Base."
6420
- },
6421
- {
6422
- url: "https://facilitator.corbits.dev",
6423
- keyless: true,
6424
- schemes: ["exact"],
6425
- settles: ["eip3009"],
6426
- note: "Corbits (Faremeter) \u2014 keyless, sponsors gas (Base USDC EIP-3009). LIVE-settled on Base 2026-06-17 (tx 0x2e41c581af023100429ada81f1371bef82d41dd577ed438d72ddc18676d4213d). Also seeded on Monad + Solana."
5604
+ note: "Dexter: keyless, gas-sponsored (Base USDC EIP-3009). LIVE-settled on Base 2026-06-17 (tx 0xdf030e4d5bf41a88c5a3bfe73bb433dfbb90b058d3b8ded63b68e026eedb9de8). Note: ~$0.001 dynamic floor on Base."
6427
5605
  },
6428
5606
  {
6429
5607
  url: "https://facilitator.goplausible.xyz",
6430
5608
  keyless: true,
6431
5609
  schemes: ["exact"],
6432
5610
  settles: ["eip3009"],
6433
- note: "GoPlausible \u2014 keyless, sponsors gas (Base USDC EIP-3009). LIVE-settled on Base 2026-06-17 (tx 0x9bcbc1f01fe1fd1aed2a79e5582555164cc4185e9800189df378a6b46eb9c59e). 2nd GoPlausible validation chain (after Algorand)."
5611
+ note: "GoPlausible: keyless, sponsors gas (Base USDC EIP-3009). LIVE-settled on Base 2026-06-17 (tx 0x9bcbc1f01fe1fd1aed2a79e5582555164cc4185e9800189df378a6b46eb9c59e). 2nd GoPlausible validation chain (after Algorand)."
6434
5612
  },
6435
5613
  {
6436
5614
  url: "https://facilitator.cascade.fyi",
6437
5615
  keyless: true,
6438
5616
  schemes: ["exact"],
6439
5617
  settles: ["eip3009"],
6440
- note: "Cascade \u2014 keyless, sponsors gas (Base USDC EIP-3009). LIVE-settled on Base 2026-06-18 (tx 0x2e784725f3c66e170720cc8df43a9248f02ad80914fcbe05dadbdbe411c3b52b)."
6441
- },
6442
- {
6443
- url: "https://facilitator.bitcoinsapi.com",
6444
- keyless: true,
6445
- schemes: ["exact"],
6446
- settles: ["eip3009"],
6447
- note: "Satoshi (bitcoinsapi) \u2014 keyless, sponsors gas (Base USDC EIP-3009). LIVE-settled on Base 2026-06-18 (tx 0xbb2b6c354b12c6d07cce91e2b337e38327d4b0833bbd1dfbeda3ad495b67b819)."
5618
+ note: "Cascade: keyless, sponsors gas (Base USDC EIP-3009). LIVE-settled on Base 2026-06-18 (tx 0x2e784725f3c66e170720cc8df43a9248f02ad80914fcbe05dadbdbe411c3b52b)."
6448
5619
  }
6449
5620
  ],
6450
5621
  // Monad (eip155:143). Corbits + Ultravioleta DAO each keyless-settle the EVM EIP-3009 exact rail
6451
5622
  // (Monad's native Circle USDC), buyer paid zero gas — real LIVE settles, not just /supported reads.
6452
5623
  // Makes `exact: true` zero-config gasless on Monad.
6453
5624
  "eip155:143": [
6454
- {
6455
- url: "https://facilitator.corbits.dev",
6456
- keyless: true,
6457
- schemes: ["exact"],
6458
- settles: ["eip3009"],
6459
- note: "Corbits (Faremeter) \u2014 keyless, sponsors gas (Monad native USDC EIP-3009). LIVE-settled on Monad 2026-06-17 (tx 0x7797be27ce22c17f7433a0389bd22d46e338899b1faac505fffd068174428ae6)."
6460
- },
6461
5625
  {
6462
5626
  url: "https://facilitator.ultravioletadao.xyz",
6463
5627
  keyless: true,
6464
5628
  schemes: ["exact"],
6465
5629
  settles: ["eip3009"],
6466
- note: "Ultravioleta DAO \u2014 keyless, 100% gas-sponsored (Monad native USDC EIP-3009). LIVE-settled on Monad 2026-06-17 (tx 0xb107576effbaceb5586c07a9ddc996ef2b6d455f1858314995ef83a7c6e64d11). 3rd UVD validation chain."
5630
+ note: "Ultravioleta DAO: keyless, 100% gas-sponsored (Monad native USDC EIP-3009). LIVE-settled on Monad 2026-06-17 (tx 0xb107576effbaceb5586c07a9ddc996ef2b6d455f1858314995ef83a7c6e64d11). 3rd UVD validation chain."
6467
5631
  },
6468
5632
  {
6469
5633
  url: "https://facilitator.pieverse.io",
6470
5634
  keyless: true,
6471
5635
  schemes: ["exact"],
6472
5636
  settles: ["eip3009"],
6473
- note: "Pieverse \u2014 keyless, sponsors gas (Monad USDC EIP-3009). LIVE-settled on Monad 2026-06-17 (tx 0x00cfeb93876e5ef57dcb002510038b7304913233ca286d7ab33c72a8b119eb0d)."
5637
+ note: "Pieverse: keyless, sponsors gas (Monad USDC EIP-3009). LIVE-settled on Monad 2026-06-17 (tx 0x00cfeb93876e5ef57dcb002510038b7304913233ca286d7ab33c72a8b119eb0d)."
6474
5638
  }
6475
5639
  ],
6476
5640
  // BNB Chain (eip155:56). Dexter + Pieverse keyless-settle the EVM EIP-3009 exact rail for BNB's
@@ -6484,14 +5648,14 @@ var KNOWN_FACILITATORS = {
6484
5648
  keyless: true,
6485
5649
  schemes: ["exact"],
6486
5650
  settles: ["eip3009"],
6487
- note: "Dexter \u2014 keyless, gas-sponsored. BNB EIP-3009 tokens FDUSD/USD1/U (Binance-Peg USDC/USDT are Permit2 \u2192 not facilitator-settleable); ~$0.003 dynamic floor. LIVE-settled on BNB 2026-06-17 with FDUSD (tx 0x6d9eb4e4939f3f3c74cb19424cc7822d66ec8ed5c5c7c330d9f88a5f9ad59e9e); accepts U (verify confirmed 2026-06-21)."
5651
+ note: "Dexter: keyless, gas-sponsored. BNB EIP-3009 tokens FDUSD/USD1/U (Binance-Peg USDC/USDT are Permit2 \u2192 not facilitator-settleable); ~$0.003 dynamic floor. LIVE-settled on BNB 2026-06-17 with FDUSD (tx 0x6d9eb4e4939f3f3c74cb19424cc7822d66ec8ed5c5c7c330d9f88a5f9ad59e9e); accepts U (verify confirmed 2026-06-21)."
6488
5652
  },
6489
5653
  {
6490
5654
  url: "https://facilitator.pieverse.io",
6491
5655
  keyless: true,
6492
5656
  schemes: ["exact"],
6493
5657
  settles: ["eip3009"],
6494
- note: "Pieverse \u2014 keyless, sponsors gas. BNB EIP-3009 tokens FDUSD/USD1/U (same Binance-Peg caveat as Dexter). LIVE-settled on BNB with FDUSD 2026-06-17 (tx 0xb9c76affc45bd07a51559efd813ca71516fc30625478724476c2cf42fc2203d3) AND with the U / United Stables token 2026-06-21 (tx 0x2b3b8c51ae81df441551301c44a64652c84c796af3b9d03ec58ea38f1cb013d5, buyer 0 BNB) \u2014 a 2nd keyless BNB facilitator (failover for Dexter)."
5658
+ note: "Pieverse: keyless, sponsors gas. BNB EIP-3009 tokens FDUSD/USD1/U (same Binance-Peg caveat as Dexter). LIVE-settled on BNB with FDUSD 2026-06-17 (tx 0xb9c76affc45bd07a51559efd813ca71516fc30625478724476c2cf42fc2203d3) AND with the U / United Stables token 2026-06-21 (tx 0x2b3b8c51ae81df441551301c44a64652c84c796af3b9d03ec58ea38f1cb013d5, buyer 0 BNB). A 2nd keyless BNB facilitator (failover for Dexter)."
6495
5659
  }
6496
5660
  ],
6497
5661
  // HyperEVM (eip155:999). Ultravioleta DAO keyless-settles the EVM EIP-3009 exact rail (HyperEVM's
@@ -6504,7 +5668,7 @@ var KNOWN_FACILITATORS = {
6504
5668
  keyless: true,
6505
5669
  schemes: ["exact"],
6506
5670
  settles: ["eip3009"],
6507
- note: "Ultravioleta DAO \u2014 keyless, 100% gas-sponsored (HyperEVM native USDC EIP-3009). LIVE-settled on HyperEVM 2026-06-17 (tx 0x56af8148a92a291f0ce362e250919f7742074e5464ac0f315ad68abaec93bd0a)."
5671
+ note: "Ultravioleta DAO: keyless, 100% gas-sponsored (HyperEVM native USDC EIP-3009). LIVE-settled on HyperEVM 2026-06-17 (tx 0x56af8148a92a291f0ce362e250919f7742074e5464ac0f315ad68abaec93bd0a)."
6508
5672
  }
6509
5673
  ],
6510
5674
  // ── gasless-extension (2026-06-18): 7 more EVM mainnets, each LIVE-settled by us — a real EIP-3009
@@ -6521,7 +5685,7 @@ var KNOWN_FACILITATORS = {
6521
5685
  keyless: true,
6522
5686
  schemes: ["exact"],
6523
5687
  settles: ["eip3009"],
6524
- note: "Ultravioleta DAO \u2014 keyless, 100% gas-sponsored (Ethereum native USDC EIP-3009; no settlement floor). LIVE-settled on Ethereum mainnet 2026-06-18 (tx 0x7fcc3cafdf43c52888f0117cde633eff35371f832dfb8dbd84e6fd7704ae5cfc)."
5688
+ note: "Ultravioleta DAO: keyless, 100% gas-sponsored (Ethereum native USDC EIP-3009; no settlement floor). LIVE-settled on Ethereum mainnet 2026-06-18 (tx 0x7fcc3cafdf43c52888f0117cde633eff35371f832dfb8dbd84e6fd7704ae5cfc)."
6525
5689
  }
6526
5690
  ],
6527
5691
  // Polygon PoS (eip155:137) — FIVE keyless facilitators (the broadest after Base), all live-settled.
@@ -6531,35 +5695,28 @@ var KNOWN_FACILITATORS = {
6531
5695
  keyless: true,
6532
5696
  schemes: ["exact"],
6533
5697
  settles: ["eip3009"],
6534
- note: "PayAI \u2014 keyless, sponsors gas (Polygon native USDC EIP-3009). LIVE-settled on Polygon 2026-06-18 (tx 0xb37630871504618c4db35e8ef0edd3c99deac102b143b7e5eb738c03fb13a619)."
5698
+ note: "PayAI: keyless, sponsors gas (Polygon native USDC EIP-3009). LIVE-settled on Polygon 2026-06-18 (tx 0xb37630871504618c4db35e8ef0edd3c99deac102b143b7e5eb738c03fb13a619)."
6535
5699
  },
6536
5700
  {
6537
5701
  url: "https://x402.polygon.technology",
6538
5702
  keyless: true,
6539
5703
  schemes: ["exact"],
6540
5704
  settles: ["eip3009"],
6541
- note: "Polygon Labs (the official Polygon facilitator) \u2014 keyless, sponsors gas. LIVE-settled on Polygon 2026-06-18 (tx 0x6a8ca60ea111959a61a85ad6c4f2ed99e192052ec7b9ffb59baa33691a86f419)."
6542
- },
6543
- {
6544
- url: "https://facilitator.corbits.dev",
6545
- keyless: true,
6546
- schemes: ["exact"],
6547
- settles: ["eip3009"],
6548
- note: "Corbits (Faremeter) \u2014 keyless, sponsors gas. LIVE-settled on Polygon 2026-06-18 (tx 0x2fadca2ee3cd7fcff32d015e8b06109de6b747d7cd0f80dcd8fb022b2d58d008)."
5705
+ note: "Polygon Labs (the official Polygon facilitator): keyless, sponsors gas. LIVE-settled on Polygon 2026-06-18 (tx 0x6a8ca60ea111959a61a85ad6c4f2ed99e192052ec7b9ffb59baa33691a86f419)."
6549
5706
  },
6550
5707
  {
6551
5708
  url: "https://facilitator.ultravioletadao.xyz",
6552
5709
  keyless: true,
6553
5710
  schemes: ["exact"],
6554
5711
  settles: ["eip3009"],
6555
- note: "Ultravioleta DAO \u2014 keyless, 100% gas-sponsored. LIVE-settled on Polygon 2026-06-18 (tx 0x0922cd78f3b7c35cc294cf0c0d9b7609e6596eb337be0d197fa5fc511eacba34)."
5712
+ note: "Ultravioleta DAO: keyless, 100% gas-sponsored. LIVE-settled on Polygon 2026-06-18 (tx 0x0922cd78f3b7c35cc294cf0c0d9b7609e6596eb337be0d197fa5fc511eacba34)."
6556
5713
  },
6557
5714
  {
6558
5715
  url: "https://x402.dexter.cash",
6559
5716
  keyless: true,
6560
5717
  schemes: ["exact"],
6561
5718
  settles: ["eip3009"],
6562
- note: "Dexter \u2014 keyless, sponsors gas; ~$0.004 dynamic settlement floor (sub-floor \u2192 amount_too_low). LIVE-settled on Polygon 2026-06-18 at $0.005 (tx 0x4a7cfc96e4e2496652435c77b0021db4a459e7bcd97948c15e6bea09077c164b)."
5719
+ note: "Dexter: keyless, sponsors gas; ~$0.004 dynamic settlement floor (sub-floor \u2192 amount_too_low). LIVE-settled on Polygon 2026-06-18 at $0.005 (tx 0x4a7cfc96e4e2496652435c77b0021db4a459e7bcd97948c15e6bea09077c164b)."
6563
5720
  }
6564
5721
  ],
6565
5722
  // Arbitrum One (eip155:42161) — PayAI + UVD + Dexter.
@@ -6569,21 +5726,21 @@ var KNOWN_FACILITATORS = {
6569
5726
  keyless: true,
6570
5727
  schemes: ["exact"],
6571
5728
  settles: ["eip3009"],
6572
- note: "PayAI \u2014 keyless, sponsors gas (Arbitrum native USDC EIP-3009). LIVE-settled on Arbitrum 2026-06-18 (tx 0x4c7fbfb37ef087bb9bc8872b1b2b0b83ea7ca4cf6b50bc883e51f9b85be61199)."
5729
+ note: "PayAI: keyless, sponsors gas (Arbitrum native USDC EIP-3009). LIVE-settled on Arbitrum 2026-06-18 (tx 0x4c7fbfb37ef087bb9bc8872b1b2b0b83ea7ca4cf6b50bc883e51f9b85be61199)."
6573
5730
  },
6574
5731
  {
6575
5732
  url: "https://facilitator.ultravioletadao.xyz",
6576
5733
  keyless: true,
6577
5734
  schemes: ["exact"],
6578
5735
  settles: ["eip3009"],
6579
- note: "Ultravioleta DAO \u2014 keyless, 100% gas-sponsored. LIVE-settled on Arbitrum 2026-06-18 (tx 0xd1fa7e6ffbd59502bba5809ce181d7936749b93a45c8c2277b4f6d8638326dec)."
5736
+ note: "Ultravioleta DAO: keyless, 100% gas-sponsored. LIVE-settled on Arbitrum 2026-06-18 (tx 0xd1fa7e6ffbd59502bba5809ce181d7936749b93a45c8c2277b4f6d8638326dec)."
6580
5737
  },
6581
5738
  {
6582
5739
  url: "https://x402.dexter.cash",
6583
5740
  keyless: true,
6584
5741
  schemes: ["exact"],
6585
5742
  settles: ["eip3009"],
6586
- note: "Dexter \u2014 keyless, sponsors gas; ~$0.004 dynamic floor. LIVE-settled on Arbitrum 2026-06-18 at $0.005 (tx 0x0993d51b3859dfd7e8d5b2af709ce64f01ff34ed14bfef665dbb340e7373d599)."
5743
+ note: "Dexter: keyless, sponsors gas; ~$0.004 dynamic floor. LIVE-settled on Arbitrum 2026-06-18 at $0.005 (tx 0x0993d51b3859dfd7e8d5b2af709ce64f01ff34ed14bfef665dbb340e7373d599)."
6587
5744
  }
6588
5745
  ],
6589
5746
  // Optimism (eip155:10) — Dexter + UVD.
@@ -6593,14 +5750,14 @@ var KNOWN_FACILITATORS = {
6593
5750
  keyless: true,
6594
5751
  schemes: ["exact"],
6595
5752
  settles: ["eip3009"],
6596
- note: "Dexter \u2014 keyless, sponsors gas; ~$0.004 dynamic floor. LIVE-settled on Optimism 2026-06-18 at $0.005 (tx 0x98b282a5dd698054eff4900ff8547170d4f7605b51140c55147fc5ae485f81da)."
5753
+ note: "Dexter: keyless, sponsors gas; ~$0.004 dynamic floor. LIVE-settled on Optimism 2026-06-18 at $0.005 (tx 0x98b282a5dd698054eff4900ff8547170d4f7605b51140c55147fc5ae485f81da)."
6597
5754
  },
6598
5755
  {
6599
5756
  url: "https://facilitator.ultravioletadao.xyz",
6600
5757
  keyless: true,
6601
5758
  schemes: ["exact"],
6602
5759
  settles: ["eip3009"],
6603
- note: "Ultravioleta DAO \u2014 keyless, 100% gas-sponsored. LIVE-settled on Optimism 2026-06-18 (tx 0xdd91dfdf12bed2d196e37fa1dea9a0da71a97e3c39a0ec0ed114be6a9af22837)."
5760
+ note: "Ultravioleta DAO: keyless, 100% gas-sponsored. LIVE-settled on Optimism 2026-06-18 (tx 0xdd91dfdf12bed2d196e37fa1dea9a0da71a97e3c39a0ec0ed114be6a9af22837)."
6604
5761
  }
6605
5762
  ],
6606
5763
  // Avalanche C-Chain (eip155:43114) — PayAI + Dexter. (UVD advertises it but contract_call_failed → unseeded.)
@@ -6610,14 +5767,14 @@ var KNOWN_FACILITATORS = {
6610
5767
  keyless: true,
6611
5768
  schemes: ["exact"],
6612
5769
  settles: ["eip3009"],
6613
- note: "PayAI \u2014 keyless, sponsors gas (Avalanche native USDC EIP-3009). LIVE-settled on Avalanche 2026-06-18 (tx 0x6a1307bc48a157de236ea03440ea2cb6ad4f27e22dd9c89a4345b4c3edb270c7)."
5770
+ note: "PayAI: keyless, sponsors gas (Avalanche native USDC EIP-3009). LIVE-settled on Avalanche 2026-06-18 (tx 0x6a1307bc48a157de236ea03440ea2cb6ad4f27e22dd9c89a4345b4c3edb270c7)."
6614
5771
  },
6615
5772
  {
6616
5773
  url: "https://x402.dexter.cash",
6617
5774
  keyless: true,
6618
5775
  schemes: ["exact"],
6619
5776
  settles: ["eip3009"],
6620
- note: "Dexter \u2014 keyless, sponsors gas (no floor hit at $0.001 here). LIVE-settled on Avalanche 2026-06-18 (tx 0xb2263e9a4ea3917eee6acabcb454d42a50264fdd69a0781ed8fcaec5590e264b)."
5777
+ note: "Dexter: keyless, sponsors gas (no floor hit at $0.001 here). LIVE-settled on Avalanche 2026-06-18 (tx 0xb2263e9a4ea3917eee6acabcb454d42a50264fdd69a0781ed8fcaec5590e264b)."
6621
5778
  }
6622
5779
  ],
6623
5780
  // Sei (eip155:1329) — PayAI (the only keyless facilitator that lists Sei).
@@ -6627,7 +5784,7 @@ var KNOWN_FACILITATORS = {
6627
5784
  keyless: true,
6628
5785
  schemes: ["exact"],
6629
5786
  settles: ["eip3009"],
6630
- note: "PayAI \u2014 keyless, sponsors gas (Sei native USDC EIP-3009). LIVE-settled on Sei 2026-06-18 (tx 0xde63679b64749cb59625527e5c7682503c851d66b9b8b8ba217ed7b099461312)."
5787
+ note: "PayAI: keyless, sponsors gas (Sei native USDC EIP-3009). LIVE-settled on Sei 2026-06-18 (tx 0xde63679b64749cb59625527e5c7682503c851d66b9b8b8ba217ed7b099461312)."
6631
5788
  }
6632
5789
  ],
6633
5790
  // Unichain (eip155:130) — UVD (the only keyless facilitator that lists Unichain).
@@ -6637,7 +5794,7 @@ var KNOWN_FACILITATORS = {
6637
5794
  keyless: true,
6638
5795
  schemes: ["exact"],
6639
5796
  settles: ["eip3009"],
6640
- note: "Ultravioleta DAO \u2014 keyless, 100% gas-sponsored (Unichain native USDC EIP-3009). LIVE-settled on Unichain 2026-06-18 (tx 0xf8bf4a9a200f24159ac67c6315c30b194257999d7da21471b39d5f2cc32b2236)."
5797
+ note: "Ultravioleta DAO: keyless, 100% gas-sponsored (Unichain native USDC EIP-3009). LIVE-settled on Unichain 2026-06-18 (tx 0xf8bf4a9a200f24159ac67c6315c30b194257999d7da21471b39d5f2cc32b2236)."
6641
5798
  }
6642
5799
  ],
6643
5800
  // Algorand (mainnet, CAIP-2 = full base64 genesis hash). GoPlausible keyless-settles the ratified
@@ -6653,7 +5810,7 @@ var KNOWN_FACILITATORS = {
6653
5810
  keyless: true,
6654
5811
  schemes: ["exact"],
6655
5812
  settles: ["algorand"],
6656
- note: "GoPlausible \u2014 keyless, 100% gas-sponsored (Algorand USDCa, atomic-group fee pooling; both buyer AND merchant pay 0 ALGO). LIVE-settled on Algorand mainnet 2026-06-17 (tx PDVDVRFGJAG2K6AJ7L26OTSCSRL7AURVKEX4D4KHBAOLNSCYENXA). The only keyless Algorand x402 facilitator."
5813
+ note: "GoPlausible: keyless, 100% gas-sponsored (Algorand USDCa, atomic-group fee pooling; both buyer AND merchant pay 0 ALGO). LIVE-settled on Algorand mainnet 2026-06-17 (tx PDVDVRFGJAG2K6AJ7L26OTSCSRL7AURVKEX4D4KHBAOLNSCYENXA). The only keyless Algorand x402 facilitator."
6657
5814
  }
6658
5815
  ],
6659
5816
  // Solana (mainnet-beta). Keyless fee-payer sponsors for the SVM exact rail, each LIVE-settled
@@ -6666,21 +5823,14 @@ var KNOWN_FACILITATORS = {
6666
5823
  keyless: true,
6667
5824
  schemes: ["exact"],
6668
5825
  settles: ["svm"],
6669
- note: "PayAI \u2014 keyless fee-payer sponsor (Solana SPL SVM). LIVE-settled 2026-06-14 (tx 4dL8jRKH\u2026)."
5826
+ note: "PayAI: keyless fee-payer sponsor (Solana SPL SVM). LIVE-settled 2026-06-14 (tx 4dL8jRKH\u2026)."
6670
5827
  },
6671
5828
  {
6672
5829
  url: "https://pay.openfacilitator.io",
6673
5830
  keyless: true,
6674
5831
  schemes: ["exact"],
6675
5832
  settles: ["svm"],
6676
- note: "OpenFacilitator \u2014 keyless (no signup), fee-payer sponsor. LIVE-settled on Solana 2026-06-15 (tx 5BabDtX\u2026)."
6677
- },
6678
- {
6679
- url: "https://facilitator.corbits.dev",
6680
- keyless: true,
6681
- schemes: ["exact"],
6682
- settles: ["svm"],
6683
- note: "Corbits \u2014 keyless, Solana-first fee-payer sponsor. LIVE-settled on Solana 2026-06-15 (tx BCreYer\u2026)."
5833
+ note: "OpenFacilitator: keyless (no signup), fee-payer sponsor. LIVE-settled on Solana 2026-06-15 (tx 5BabDtX\u2026)."
6684
5834
  }
6685
5835
  ]
6686
5836
  // NEAR (near:mainnet) — DELIBERATELY UNSEEDED: no x402 facilitator settles NEAR yet.
@@ -6711,13 +5861,13 @@ function toInvalidBody(result) {
6711
5861
  function normaliseAccepts(options) {
6712
5862
  if (Array.isArray(options.accept) && options.accept.length > 0) {
6713
5863
  if (options.chain !== void 0 || options.token !== void 0 || options.amount !== void 0) {
6714
- throw new (0, _chunk3FR22M3Ocjs.InvalidConfigError)(
5864
+ throw new (0, _chunkQONQSZHJcjs.InvalidConfigError)(
6715
5865
  "requirePayment: pass EITHER `accept: [...]` (multi-chain) OR `chain`/`token`/`amount` (single) \u2014 not both."
6716
5866
  );
6717
5867
  }
6718
5868
  options.accept.forEach((a, i) => {
6719
5869
  if (a === null || typeof a !== "object") {
6720
- throw new (0, _chunk3FR22M3Ocjs.InvalidConfigError)(
5870
+ throw new (0, _chunkQONQSZHJcjs.InvalidConfigError)(
6721
5871
  `requirePayment: accept[${i}] must be { chain, token, amount }, got ${a === null ? "null" : typeof a}.`
6722
5872
  );
6723
5873
  }
@@ -6727,7 +5877,7 @@ function normaliseAccepts(options) {
6727
5877
  if (options.chain !== void 0 && options.token !== void 0 && options.amount !== void 0) {
6728
5878
  return [{ chain: options.chain, token: options.token, amount: options.amount }];
6729
5879
  }
6730
- throw new (0, _chunk3FR22M3Ocjs.InvalidConfigError)(
5880
+ throw new (0, _chunkQONQSZHJcjs.InvalidConfigError)(
6731
5881
  "requirePayment: provide either { chain, token, amount } or a non-empty `accept: [{ chain, token, amount }, \u2026]`."
6732
5882
  );
6733
5883
  }
@@ -6761,7 +5911,7 @@ function createPaymentGate(options) {
6761
5911
  attestWarned = true;
6762
5912
  try {
6763
5913
  console.warn(`[piprail] receipts.attest ${reason}; emitting an unsigned Tier-1 receipt instead.`);
6764
- } catch (e48) {
5914
+ } catch (e41) {
6765
5915
  }
6766
5916
  }
6767
5917
  let resolved;
@@ -6776,13 +5926,13 @@ function createPaymentGate(options) {
6776
5926
  const net = await resolveNetwork2({ chain: a.chain, rpcUrl: _nullishCoalesce(a.rpcUrl, () => ( options.rpcUrl)) });
6777
5927
  const payTo = _nullishCoalesce(a.payTo, () => ( options.payTo));
6778
5928
  if (!payTo) {
6779
- throw new (0, _chunk3FR22M3Ocjs.InvalidConfigError)(
5929
+ throw new (0, _chunkQONQSZHJcjs.InvalidConfigError)(
6780
5930
  `requirePayment: no payTo for chain ${net.network}. Set it on the accept entry or pass a top-level payTo.`
6781
5931
  );
6782
5932
  }
6783
5933
  net.assertValidPayTo(payTo);
6784
5934
  const { asset, decimals, symbol } = net.resolveToken(a.token);
6785
- const amountBase = _chunk3FR22M3Ocjs.parseUnits.call(void 0, a.amount, decimals);
5935
+ const amountBase = _chunkQONQSZHJcjs.parseUnits.call(void 0, a.amount, decimals);
6786
5936
  const spec = { net, asset, decimals, symbol, amountBase, amountFormatted: a.amount, payTo };
6787
5937
  if (exactOption) {
6788
5938
  const outcome = await resolveExactRail(net, asset);
@@ -6805,7 +5955,7 @@ function createPaymentGate(options) {
6805
5955
  if (exactOption && !specs.some((s) => s.exact)) {
6806
5956
  const why = exactSkips.length > 0 ? exactSkips.join(" ") : "The standard `exact` rail is EVM ERC-20 (EIP-3009 \u2014 USDC / EURC \u2014 or Permit2, e.g. Binance-Peg USDC on BNB) or a Solana SPL token (SVM) \u2014 NOT native coins, NOT families without a standard `exact` scheme.";
6807
5957
  if (exactOption.settle === "keyless") {
6808
- if (typeof process === "undefined" || !_optionalChain([process, 'optionalAccess', _136 => _136.env, 'optionalAccess', _137 => _137.PIPRAIL_NO_HINTS])) {
5958
+ if (typeof process === "undefined" || !_optionalChain([process, 'optionalAccess', _131 => _131.env, 'optionalAccess', _132 => _132.PIPRAIL_NO_HINTS])) {
6809
5959
  console.warn(
6810
5960
  `[piprail] exact: true \u2014 no offered chain has a gasless \`exact\` rail available, so this gate serves ONCHAIN-PROOF ONLY (buyers PAY GAS \u2014 the fallback when no facilitator can sponsor). ${why} To be gasless: pin \`exact: { settle: { facilitator } }\` or self-settle \`exact: { settle: 'self', relayer }\`. (Suppress with PIPRAIL_NO_HINTS=1.)`
6811
5961
  );
@@ -6833,7 +5983,7 @@ function createPaymentGate(options) {
6833
5983
  skipReason: `${net.network}: \`exact: true\` found no known keyless facilitator for this network. Pass \`exact: { settle: { facilitator } }\`, \`exact: { settle: 'self', relayer }\`, or see the coverage map (KNOWN_FACILITATORS / docs.piprail.com).`
6834
5984
  };
6835
5985
  }
6836
- if (typeof process === "undefined" || _optionalChain([process, 'optionalAccess', _138 => _138.env, 'optionalAccess', _139 => _139.NODE_ENV]) !== "production" && !_optionalChain([process, 'optionalAccess', _140 => _140.env, 'optionalAccess', _141 => _141.PIPRAIL_NO_HINTS])) {
5986
+ if (typeof process === "undefined" || _optionalChain([process, 'optionalAccess', _133 => _133.env, 'optionalAccess', _134 => _134.NODE_ENV]) !== "production" && !_optionalChain([process, 'optionalAccess', _135 => _135.env, 'optionalAccess', _136 => _136.PIPRAIL_NO_HINTS])) {
6837
5987
  console.warn(
6838
5988
  `[piprail] exact: keyless rail on ${net.network} auto-settles via ${picked.url} (zero-config; pin \`exact.settle.facilitator\` in production).`
6839
5989
  );
@@ -6871,7 +6021,7 @@ function createPaymentGate(options) {
6871
6021
  );
6872
6022
  }
6873
6023
  return {
6874
- skipReason: `${net.network}: this token isn't EIP-3009 (auto-selected Permit2), which a third-party facilitator can't settle \u2014 it would serve onchain-proof only here. Use an EIP-3009 token (USDC / EURC) with the facilitator, or \`settle: 'self'\` to settle Permit2 yourself.`
6024
+ skipReason: `${net.network}: auto-selected Permit2, which a third-party facilitator can't settle \u2014 it would serve onchain-proof only here. Either this token isn't EIP-3009 (use USDC / EURC with the facilitator, or \`settle: 'self'\` to settle Permit2 yourself), OR the EIP-712 domain read failed on your RPC (transient): if you expected a gasless rail here, pass a reliable \`rpcUrl\` and retry.`
6875
6025
  };
6876
6026
  }
6877
6027
  const mode = settle === "self" ? { kind: "self", relayer } : {
@@ -6977,7 +6127,7 @@ function createPaymentGate(options) {
6977
6127
  extra: {
6978
6128
  assetTransferMethod: "permit2-upto",
6979
6129
  // facilitatorAddress comes from rail.extra; the spread below carries it (+ name/version).
6980
- facilitatorAddress: _nullishCoalesce(_optionalChain([rail, 'access', _142 => _142.extra, 'optionalAccess', _143 => _143.facilitatorAddress]), () => ( "")),
6130
+ facilitatorAddress: _nullishCoalesce(_optionalChain([rail, 'access', _137 => _137.extra, 'optionalAccess', _138 => _138.facilitatorAddress]), () => ( "")),
6981
6131
  minConfirmations,
6982
6132
  decimals: s.decimals,
6983
6133
  amountFormatted: s.amountFormatted,
@@ -6999,7 +6149,7 @@ function createPaymentGate(options) {
6999
6149
  const specs = await ready();
7000
6150
  const nonce = genNonce();
7001
6151
  const bazaar = options.discovery ? { bazaar: buildBazaarExtension(options.discovery === true ? {} : options.discovery) } : void 0;
7002
- const paymentIdAd = options.paymentIdentifier ? buildPaymentIdentifierAdvertisement() : void 0;
6152
+ const paymentIdAd = options.paymentIdentifier ? _chunkOXEFPLZAcjs.buildPaymentIdentifierAdvertisement.call(void 0, ) : void 0;
7003
6153
  const accepts = buildAccepts(specs, nonce);
7004
6154
  const endpointInfo = buildEndpointInfo({
7005
6155
  ...options.description ? { description: options.description } : {},
@@ -7012,7 +6162,7 @@ function createPaymentGate(options) {
7012
6162
  ...endpointInfo ? { endpoint: endpointInfo } : {},
7013
6163
  ...receiptsOn ? { verifiableReceipts: true } : {}
7014
6164
  });
7015
- const rejectionExt = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _144 => _144.extensions]), () => ( {}));
6165
+ const rejectionExt = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _139 => _139.extensions]), () => ( {}));
7016
6166
  const rejectionPiprail = _nullishCoalesce(rejectionExt.piprail, () => ( {}));
7017
6167
  const bodyPiprail = { ..._nullishCoalesce(selfDescribe, () => ( {})), ...rejectionPiprail };
7018
6168
  const bodyExtensions = {
@@ -7034,14 +6184,14 @@ function createPaymentGate(options) {
7034
6184
  ...options.mimeType ? { mimeType: options.mimeType } : {}
7035
6185
  },
7036
6186
  accepts,
7037
- ..._optionalChain([opts, 'optionalAccess', _145 => _145.error]) ? { error: opts.error } : {},
6187
+ ..._optionalChain([opts, 'optionalAccess', _140 => _140.error]) ? { error: opts.error } : {},
7038
6188
  ...Object.keys(bodyExtensions).length > 0 ? { extensions: bodyExtensions } : {}
7039
6189
  };
7040
6190
  const headerChallenge = {
7041
6191
  ...challenge2,
7042
6192
  ...Object.keys(headerExtensions).length > 0 ? { extensions: headerExtensions } : { extensions: void 0 }
7043
6193
  };
7044
- return { challenge: challenge2, requiredHeader: buildChallengeHeader(headerChallenge) };
6194
+ return { challenge: challenge2, requiredHeader: _chunkOXEFPLZAcjs.buildChallengeHeader.call(void 0, headerChallenge) };
7045
6195
  }
7046
6196
  async function challenge(resourceUrl = "") {
7047
6197
  return makeChallenge(resourceUrl);
@@ -7065,8 +6215,8 @@ function createPaymentGate(options) {
7065
6215
  function enrichReceipt(spec, receipt) {
7066
6216
  let amountFormatted = receipt.amount;
7067
6217
  try {
7068
- amountFormatted = _chunk3FR22M3Ocjs.formatUnits.call(void 0, BigInt(receipt.amount), spec.decimals);
7069
- } catch (e49) {
6218
+ amountFormatted = _chunkQONQSZHJcjs.formatUnits.call(void 0, BigInt(receipt.amount), spec.decimals);
6219
+ } catch (e42) {
7070
6220
  }
7071
6221
  return {
7072
6222
  ...receipt,
@@ -7080,7 +6230,7 @@ function createPaymentGate(options) {
7080
6230
  if (!options.onPaidError) return;
7081
6231
  try {
7082
6232
  options.onPaidError(error, receipt);
7083
- } catch (e50) {
6233
+ } catch (e43) {
7084
6234
  }
7085
6235
  }
7086
6236
  function fireOnPaid(receipt) {
@@ -7103,7 +6253,7 @@ function createPaymentGate(options) {
7103
6253
  }
7104
6254
  async function buildPaidResult(spec, receipt, nonce) {
7105
6255
  if (!receiptsOn) {
7106
- return { kind: "paid", receipt, receiptHeader: buildReceiptHeader(receipt) };
6256
+ return { kind: "paid", receipt, receiptHeader: _chunkOXEFPLZAcjs.buildReceiptHeader.call(void 0, receipt) };
7107
6257
  }
7108
6258
  try {
7109
6259
  const stamped = {
@@ -7113,15 +6263,15 @@ function createPaymentGate(options) {
7113
6263
  ...receiptIncludeTxHash ? {} : { transaction: "" }
7114
6264
  };
7115
6265
  const attestation = await maybeSignAttestation(spec, stamped);
7116
- const extensions = buildReceiptExtension({
6266
+ const extensions = _chunkOXEFPLZAcjs.buildReceiptExtension.call(void 0, {
7117
6267
  receipt: stamped,
7118
6268
  resource: { url: receiptResourceUrl },
7119
6269
  decimals: spec.decimals,
7120
6270
  ...attestation ? { attestation } : {}
7121
6271
  });
7122
- return { kind: "paid", receipt: stamped, receiptHeader: buildReceiptHeader(stamped, extensions) };
7123
- } catch (e51) {
7124
- return { kind: "paid", receipt, receiptHeader: buildReceiptHeader(receipt) };
6272
+ return { kind: "paid", receipt: stamped, receiptHeader: _chunkOXEFPLZAcjs.buildReceiptHeader.call(void 0, stamped, extensions) };
6273
+ } catch (e44) {
6274
+ return { kind: "paid", receipt, receiptHeader: _chunkOXEFPLZAcjs.buildReceiptHeader.call(void 0, receipt) };
7125
6275
  }
7126
6276
  }
7127
6277
  async function maybeSignAttestation(spec, stamped) {
@@ -7145,7 +6295,7 @@ function createPaymentGate(options) {
7145
6295
  // §5.3: the signed message carries the empty string for a suppressed tx, never omitted.
7146
6296
  transaction: receiptIncludeTxHash ? stamped.transaction : ""
7147
6297
  });
7148
- } catch (e52) {
6298
+ } catch (e45) {
7149
6299
  warnAttestDegrade("signing failed");
7150
6300
  return void 0;
7151
6301
  }
@@ -7154,7 +6304,7 @@ function createPaymentGate(options) {
7154
6304
  if (!options.onFailedError) return;
7155
6305
  try {
7156
6306
  options.onFailedError(error, failure);
7157
- } catch (e53) {
6307
+ } catch (e46) {
7158
6308
  }
7159
6309
  }
7160
6310
  function fireOnFailed(failure) {
@@ -7198,8 +6348,8 @@ function createPaymentGate(options) {
7198
6348
  maxTimeoutSeconds,
7199
6349
  ...s.symbol ? { symbol: s.symbol } : {}
7200
6350
  };
7201
- if (s.exact) accepts.push({ scheme: "exact", ...base2, ...railExtra(buildExactAccept(s).extra) });
7202
- if (s.upto) accepts.push({ scheme: "upto", ...base2, ...railExtra(buildUptoAccept(s).extra) });
6351
+ if (s.exact) accepts.push({ scheme: "exact", ...base2, ...railExtra(_nullishCoalesce(buildExactAccept(s).extra, () => ( {}))) });
6352
+ if (s.upto) accepts.push({ scheme: "upto", ...base2, ...railExtra(_nullishCoalesce(buildUptoAccept(s).extra, () => ( {}))) });
7203
6353
  accepts.push({ scheme: "onchain-proof", ...base2 });
7204
6354
  }
7205
6355
  return {
@@ -7212,7 +6362,7 @@ function createPaymentGate(options) {
7212
6362
  async function verifyOnchainProof(sig) {
7213
6363
  const specs = await ready();
7214
6364
  const spec = specs.find(
7215
- (s) => s.net.network === sig.accepted.network && s.asset === sig.accepted.asset
6365
+ (s) => _chunkV2IJ5HUWcjs.normalizeNetwork.call(void 0, s.net.network) === _chunkV2IJ5HUWcjs.normalizeNetwork.call(void 0, sig.accepted.network) && s.asset === sig.accepted.asset
7216
6366
  );
7217
6367
  if (!spec) {
7218
6368
  return rejection(
@@ -7220,7 +6370,7 @@ function createPaymentGate(options) {
7220
6370
  `Proof claims ${sig.accepted.asset} on ${sig.accepted.network}, which this resource doesn't accept (offered: ${specs.map((s) => `${s.asset}@${s.net.network}`).join(", ")}).`
7221
6371
  );
7222
6372
  }
7223
- const ref = sig.payload.txHash;
6373
+ const ref = typeof sig.payload.txHash === "string" ? sig.payload.txHash.trim() : sig.payload.txHash;
7224
6374
  if (await claimTx(ref)) return rejection("tx_already_used", `Proof ${ref} was already redeemed.`);
7225
6375
  let result;
7226
6376
  try {
@@ -7254,7 +6404,8 @@ function createPaymentGate(options) {
7254
6404
  return rejection("transfer_not_found", "This resource offers no standard `exact` rail.");
7255
6405
  }
7256
6406
  const isCaip = exact.network.includes(":");
7257
- let candidates = isCaip ? exactSpecs.filter((s) => s.net.network === exact.network) : exactSpecs;
6407
+ const wantExactNet = _chunkV2IJ5HUWcjs.normalizeNetwork.call(void 0, exact.network);
6408
+ let candidates = isCaip ? exactSpecs.filter((s) => _chunkV2IJ5HUWcjs.normalizeNetwork.call(void 0, s.net.network) === wantExactNet) : exactSpecs;
7258
6409
  if (exact.asset) {
7259
6410
  candidates = candidates.filter((s) => s.asset.toLowerCase() === exact.asset.toLowerCase());
7260
6411
  }
@@ -7273,30 +6424,32 @@ function createPaymentGate(options) {
7273
6424
  nonce = [exact.payload.transaction, exact.payload.senderAuth].map((t) => {
7274
6425
  try {
7275
6426
  return Buffer.from(t, "base64").toString("base64");
7276
- } catch (e54) {
6427
+ } catch (e47) {
7277
6428
  return t;
7278
6429
  }
7279
6430
  }).join("|");
7280
6431
  } else if ("transaction" in exact.payload) {
7281
6432
  try {
7282
6433
  nonce = Buffer.from(exact.payload.transaction, "base64").toString("base64");
7283
- } catch (e55) {
6434
+ } catch (e48) {
7284
6435
  nonce = exact.payload.transaction;
7285
6436
  }
7286
6437
  } else if ("paymentGroup" in exact.payload) {
7287
6438
  nonce = exact.payload.paymentGroup.map((t) => {
7288
6439
  try {
7289
6440
  return Buffer.from(t, "base64").toString("base64");
7290
- } catch (e56) {
6441
+ } catch (e49) {
7291
6442
  return t;
7292
6443
  }
7293
6444
  }).join("|");
7294
6445
  } else if ("signedDelegateAction" in exact.payload) {
7295
6446
  try {
7296
6447
  nonce = Buffer.from(exact.payload.signedDelegateAction, "base64").toString("base64");
7297
- } catch (e57) {
6448
+ } catch (e50) {
7298
6449
  nonce = exact.payload.signedDelegateAction;
7299
6450
  }
6451
+ } else if ("signedTxBlob" in exact.payload) {
6452
+ nonce = exact.payload.signedTxBlob.trim().toUpperCase();
7300
6453
  } else if ("permit2Authorization" in exact.payload) {
7301
6454
  evmAuth = exact.payload.permit2Authorization;
7302
6455
  nonce = evmAuth.nonce;
@@ -7314,10 +6467,10 @@ function createPaymentGate(options) {
7314
6467
  if (mode.kind === "self") {
7315
6468
  result = await spec.net.settleExactSelf({ relayer: mode.relayer, payload: exact.payload, accept });
7316
6469
  } else {
7317
- const ftMethod = accept.extra.assetTransferMethod;
6470
+ const ftMethod = _optionalChain([accept, 'access', _141 => _141.extra, 'optionalAccess', _142 => _142.assetTransferMethod]);
7318
6471
  const needsFeePayer = ftMethod === "svm" || ftMethod === "algorand" || ftMethod === "aptos" || ftMethod === "near";
7319
- if (needsFeePayer && !accept.extra.feePayer) {
7320
- throw new (0, _chunk3FR22M3Ocjs.SettlementError)(
6472
+ if (needsFeePayer && !_optionalChain([accept, 'access', _143 => _143.extra, 'optionalAccess', _144 => _144.feePayer])) {
6473
+ throw new (0, _chunkQONQSZHJcjs.SettlementError)(
7321
6474
  `exact settle: the ${ftMethod} facilitator rail is missing extra.feePayer (the gas sponsor) \u2014 cannot settle.`
7322
6475
  );
7323
6476
  }
@@ -7337,7 +6490,7 @@ function createPaymentGate(options) {
7337
6490
  amount: accept.amount,
7338
6491
  payTo: accept.payTo,
7339
6492
  maxTimeoutSeconds: accept.maxTimeoutSeconds,
7340
- extra: needsFeePayer ? { feePayer: accept.extra.feePayer } : { name: _nullishCoalesce(accept.extra.name, () => ( "")), version: _nullishCoalesce(accept.extra.version, () => ( "")) }
6493
+ extra: needsFeePayer ? { feePayer: accept.extra.feePayer } : { name: _nullishCoalesce(_optionalChain([accept, 'access', _145 => _145.extra, 'optionalAccess', _146 => _146.name]), () => ( "")), version: _nullishCoalesce(_optionalChain([accept, 'access', _147 => _147.extra, 'optionalAccess', _148 => _148.version]), () => ( "")) }
7341
6494
  },
7342
6495
  receipt: { network: accept.network, asset: accept.asset, payTo: accept.payTo, amount: accept.amount },
7343
6496
  // The buyer address, for the receipt's `payer` fallback. EVM carries it in the
@@ -7365,16 +6518,16 @@ function createPaymentGate(options) {
7365
6518
  if (s.endsWith("%")) {
7366
6519
  const pct = s.slice(0, -1).trim();
7367
6520
  if (!/^\d+(\.\d+)?$/.test(pct)) return null;
7368
- const pctScaled = _chunk3FR22M3Ocjs.floorUnits.call(void 0, pct, 4);
6521
+ const pctScaled = _chunkQONQSZHJcjs.floorUnits.call(void 0, pct, 4);
7369
6522
  return maxAmount * pctScaled / (100n * 10n ** 4n);
7370
6523
  }
7371
6524
  if (s.startsWith("$")) {
7372
6525
  const amt = s.slice(1).trim();
7373
- return _chunk3FR22M3Ocjs.floorUnits.call(void 0, amt, decimals);
6526
+ return _chunkQONQSZHJcjs.floorUnits.call(void 0, amt, decimals);
7374
6527
  }
7375
6528
  if (/^\d+$/.test(s)) return BigInt(s);
7376
- return _chunk3FR22M3Ocjs.floorUnits.call(void 0, s, decimals);
7377
- } catch (e58) {
6529
+ return _chunkQONQSZHJcjs.floorUnits.call(void 0, s, decimals);
6530
+ } catch (e51) {
7378
6531
  return null;
7379
6532
  }
7380
6533
  }
@@ -7385,7 +6538,8 @@ function createPaymentGate(options) {
7385
6538
  return rejection("transfer_not_found", "This resource offers no standard `upto` (metered) rail.");
7386
6539
  }
7387
6540
  const isCaip = upto.network.includes(":");
7388
- let candidates = isCaip ? uptoSpecs.filter((s) => s.net.network === upto.network) : uptoSpecs;
6541
+ const wantUptoNet = _chunkV2IJ5HUWcjs.normalizeNetwork.call(void 0, upto.network);
6542
+ let candidates = isCaip ? uptoSpecs.filter((s) => _chunkV2IJ5HUWcjs.normalizeNetwork.call(void 0, s.net.network) === wantUptoNet) : uptoSpecs;
7389
6543
  if (upto.asset) {
7390
6544
  candidates = candidates.filter((s) => s.asset.toLowerCase() === upto.asset.toLowerCase());
7391
6545
  }
@@ -7424,7 +6578,7 @@ function createPaymentGate(options) {
7424
6578
  result = await spec.net.settleUptoSelf({ relayer, payload: upto.payload, accept, settleAmount });
7425
6579
  } catch (err) {
7426
6580
  await settleTx(nonce, false);
7427
- if (err instanceof _chunk3FR22M3Ocjs.SettlementError) throw err;
6581
+ if (err instanceof _chunkQONQSZHJcjs.SettlementError) throw err;
7428
6582
  return rejection(
7429
6583
  "tx_reverted",
7430
6584
  `upto: metering/settle failed (${err instanceof Error ? err.message : String(err)}).`
@@ -7440,7 +6594,7 @@ function createPaymentGate(options) {
7440
6594
  }
7441
6595
  async function verify(paymentSignature) {
7442
6596
  const raw = normaliseHeader(paymentSignature);
7443
- const result = await resolveVerdictObject(raw === void 0 ? void 0 : decodeBase64Json(raw));
6597
+ const result = await resolveVerdictObject(raw === void 0 ? void 0 : _chunkOXEFPLZAcjs.decodeBase64Json.call(void 0, raw));
7444
6598
  if (result.kind === "invalid") await deliverOnFailed(result);
7445
6599
  return result;
7446
6600
  }
@@ -7451,33 +6605,33 @@ function createPaymentGate(options) {
7451
6605
  }
7452
6606
  async function routeVerdictObject(obj) {
7453
6607
  if (obj === void 0 || obj === null) return asChallenge();
7454
- const sig = parseSignatureObject(obj);
6608
+ const sig = _chunkOXEFPLZAcjs.parseSignatureObject.call(void 0, obj);
7455
6609
  if (sig && sig.accepted && typeof sig.accepted.network === "string" && typeof sig.accepted.asset === "string") {
7456
6610
  return verifyOnchainProof(sig);
7457
6611
  }
7458
- const upto = parseUptoObject(obj);
6612
+ const upto = _chunkOXEFPLZAcjs.parseUptoObject.call(void 0, obj);
7459
6613
  if (upto) return verifyUpto(upto);
7460
- const exact = parseExactObject(obj);
6614
+ const exact = _chunkOXEFPLZAcjs.parseExactObject.call(void 0, obj);
7461
6615
  if (exact) return verifyExact(exact);
7462
6616
  return asChallenge();
7463
6617
  }
7464
6618
  function echoPaymentIdentifier(result, id) {
7465
6619
  try {
7466
- const decoded = decodeBase64Json(result.receiptHeader);
6620
+ const decoded = _chunkOXEFPLZAcjs.decodeBase64Json.call(void 0, result.receiptHeader);
7467
6621
  if (!decoded) return result;
7468
6622
  const { extensions: existing, ...receiptOnly } = decoded;
7469
6623
  const merged = {
7470
6624
  ..._nullishCoalesce(existing, () => ( {})),
7471
- [EXT_PAYMENT_IDENTIFIER]: { info: { required: false, id } }
6625
+ [_chunkOXEFPLZAcjs.EXT_PAYMENT_IDENTIFIER]: { info: { required: false, id } }
7472
6626
  };
7473
- return { ...result, receiptHeader: buildReceiptHeader(receiptOnly, merged) };
7474
- } catch (e59) {
6627
+ return { ...result, receiptHeader: _chunkOXEFPLZAcjs.buildReceiptHeader.call(void 0, receiptOnly, merged) };
6628
+ } catch (e52) {
7475
6629
  return result;
7476
6630
  }
7477
6631
  }
7478
6632
  async function resolveVerdictObject(obj) {
7479
6633
  if (!options.paymentIdentifier) return routeVerdictObject(obj);
7480
- const id = readPaymentIdentifier(obj);
6634
+ const id = _chunkOXEFPLZAcjs.readPaymentIdentifier.call(void 0, obj);
7481
6635
  if (id !== null && typeof id === "object") {
7482
6636
  return rejection("signature_invalid", `payment-identifier: ${id.invalid}.`);
7483
6637
  }
@@ -7532,7 +6686,7 @@ function createPaymentGate(options) {
7532
6686
  }
7533
6687
  function requirePayment(options) {
7534
6688
  if (options.upto) {
7535
- throw new (_class3 = class extends _chunk3FR22M3Ocjs.PipRailError {constructor(...args2) { super(...args2); _class3.prototype.__init7.call(this); }
6689
+ throw new (_class3 = class extends _chunkQONQSZHJcjs.PipRailError {constructor(...args2) { super(...args2); _class3.prototype.__init7.call(this); }
7536
6690
  __init7() {this.code = "UNSUPPORTED_SCHEME"}
7537
6691
  }, _class3)(
7538
6692
  "requirePayment: the 'upto' (metered) rail is unsupported through the Express middleware \u2014 it settles before the route handler serves, so metered usage is unknown at settle time. Call gate.verify() directly (createPaymentGate) and meter inside settleAmount; see docs/accepting-payments/upto-rail-seller.md."
@@ -7542,9 +6696,9 @@ function requirePayment(options) {
7542
6696
  return async (req, res, next) => {
7543
6697
  let result;
7544
6698
  try {
7545
- result = await gate.verify(_nullishCoalesce(req.headers[HEADER_SIGNATURE], () => ( req.headers[HEADER_SIGNATURE_V1])));
6699
+ result = await gate.verify(_nullishCoalesce(req.headers[_chunkOXEFPLZAcjs.HEADER_SIGNATURE], () => ( req.headers[_chunkOXEFPLZAcjs.HEADER_SIGNATURE_V1])));
7546
6700
  } catch (err) {
7547
- if (err instanceof _chunk3FR22M3Ocjs.SettlementError) {
6701
+ if (err instanceof _chunkQONQSZHJcjs.SettlementError) {
7548
6702
  res.status(502);
7549
6703
  res.json({
7550
6704
  x402Version: 2,
@@ -7559,16 +6713,16 @@ function requirePayment(options) {
7559
6713
  }
7560
6714
  switch (result.kind) {
7561
6715
  case "paid":
7562
- res.setHeader(HEADER_RESPONSE, result.receiptHeader);
7563
- res.setHeader(HEADER_RESPONSE_V1, result.receiptHeader);
6716
+ res.setHeader(_chunkOXEFPLZAcjs.HEADER_RESPONSE, result.receiptHeader);
6717
+ res.setHeader(_chunkOXEFPLZAcjs.HEADER_RESPONSE_V1, result.receiptHeader);
7564
6718
  return next();
7565
6719
  case "challenge":
7566
- res.setHeader(HEADER_REQUIRED, result.requiredHeader);
6720
+ res.setHeader(_chunkOXEFPLZAcjs.HEADER_REQUIRED, result.requiredHeader);
7567
6721
  res.status(result.statusCode);
7568
6722
  res.json(result.challenge);
7569
6723
  return;
7570
6724
  case "invalid":
7571
- res.setHeader(HEADER_REQUIRED, result.requiredHeader);
6725
+ res.setHeader(_chunkOXEFPLZAcjs.HEADER_REQUIRED, result.requiredHeader);
7572
6726
  res.status(result.statusCode);
7573
6727
  res.json(result.challenge);
7574
6728
  return;
@@ -7606,18 +6760,18 @@ function withSettlementHeaders(res, receiptHeader) {
7606
6760
  return combined ? [combined] : [];
7607
6761
  })();
7608
6762
  for (const cookie of cookies) headers.append("set-cookie", cookie);
7609
- headers.set(HEADER_RESPONSE, receiptHeader);
7610
- headers.set(HEADER_RESPONSE_V1, receiptHeader);
6763
+ headers.set(_chunkOXEFPLZAcjs.HEADER_RESPONSE, receiptHeader);
6764
+ headers.set(_chunkOXEFPLZAcjs.HEADER_RESPONSE_V1, receiptHeader);
7611
6765
  return new Response(res.body, { status: res.status, statusText: res.statusText, headers });
7612
6766
  }
7613
6767
  function toFetchHandler(gate, serve) {
7614
6768
  return async (request, ...rest) => {
7615
6769
  let result;
7616
6770
  try {
7617
- const sig = _nullishCoalesce(_nullishCoalesce(request.headers.get(HEADER_SIGNATURE), () => ( request.headers.get(HEADER_SIGNATURE_V1))), () => ( void 0));
6771
+ const sig = _nullishCoalesce(_nullishCoalesce(request.headers.get(_chunkOXEFPLZAcjs.HEADER_SIGNATURE), () => ( request.headers.get(_chunkOXEFPLZAcjs.HEADER_SIGNATURE_V1))), () => ( void 0));
7618
6772
  result = await gate.verify(sig);
7619
6773
  } catch (err) {
7620
- if (err instanceof _chunk3FR22M3Ocjs.SettlementError) {
6774
+ if (err instanceof _chunkQONQSZHJcjs.SettlementError) {
7621
6775
  return jsonResponse(
7622
6776
  {
7623
6777
  x402Version: 2,
@@ -7634,7 +6788,7 @@ function toFetchHandler(gate, serve) {
7634
6788
  const res = await serve(request, ...rest);
7635
6789
  return withSettlementHeaders(res, result.receiptHeader);
7636
6790
  }
7637
- return jsonResponse(result.challenge, 402, { [HEADER_REQUIRED]: result.requiredHeader });
6791
+ return jsonResponse(result.challenge, 402, { [_chunkOXEFPLZAcjs.HEADER_REQUIRED]: result.requiredHeader });
7638
6792
  };
7639
6793
  }
7640
6794
  function toWorker(gate, serve) {
@@ -7646,8 +6800,8 @@ function proxyTo(origin) {
7646
6800
  const inUrl = new URL(request.url);
7647
6801
  const target = base2 + inUrl.pathname + inUrl.search;
7648
6802
  const headers = new Headers(request.headers);
7649
- headers.delete(HEADER_SIGNATURE);
7650
- headers.delete(HEADER_SIGNATURE_V1);
6803
+ headers.delete(_chunkOXEFPLZAcjs.HEADER_SIGNATURE);
6804
+ headers.delete(_chunkOXEFPLZAcjs.HEADER_SIGNATURE_V1);
7651
6805
  const init = {
7652
6806
  method: request.method,
7653
6807
  headers,
@@ -7673,7 +6827,7 @@ function isRetryableStatus(status) {
7673
6827
  }
7674
6828
  var sleep = (ms) => ms > 0 ? new Promise((resolve) => setTimeout(resolve, ms)) : Promise.resolve();
7675
6829
  async function signBody(secret, body) {
7676
- const subtle = _optionalChain([globalThis, 'access', _146 => _146.crypto, 'optionalAccess', _147 => _147.subtle]);
6830
+ const subtle = _optionalChain([globalThis, 'access', _149 => _149.crypto, 'optionalAccess', _150 => _150.subtle]);
7677
6831
  if (!subtle) return null;
7678
6832
  try {
7679
6833
  const enc = new TextEncoder();
@@ -7683,7 +6837,7 @@ async function signBody(secret, body) {
7683
6837
  const sig = await subtle.sign("HMAC", key, enc.encode(body));
7684
6838
  const hex = Array.from(new Uint8Array(sig)).map((b) => b.toString(16).padStart(2, "0")).join("");
7685
6839
  return `sha256=${hex}`;
7686
- } catch (e60) {
6840
+ } catch (e53) {
7687
6841
  return null;
7688
6842
  }
7689
6843
  }
@@ -7743,8 +6897,8 @@ async function deliverReceipt(receipt, options) {
7743
6897
  const retryable = status === void 0 ? true : isRetryableStatus(status);
7744
6898
  const willRetry = !ok && retryable && attempt < maxAttempts;
7745
6899
  try {
7746
- _optionalChain([onAttempt, 'optionalCall', _148 => _148({ attempt, ok, ...status !== void 0 ? { status } : {}, ...error ? { error } : {}, willRetry })]);
7747
- } catch (e61) {
6900
+ _optionalChain([onAttempt, 'optionalCall', _151 => _151({ attempt, ok, ...status !== void 0 ? { status } : {}, ...error ? { error } : {}, willRetry })]);
6901
+ } catch (e54) {
7748
6902
  }
7749
6903
  if (ok) return { delivered: true, attempts: attempt, status };
7750
6904
  if (!willRetry) {
@@ -7832,13 +6986,13 @@ function toA2APaymentFailed(code, detail, receipts = [], network) {
7832
6986
  };
7833
6987
  }
7834
6988
  function fromA2APaymentRequired(task) {
7835
- const meta = _optionalChain([task, 'access', _149 => _149.status, 'optionalAccess', _150 => _150.message, 'optionalAccess', _151 => _151.metadata]);
7836
- const required = _optionalChain([meta, 'optionalAccess', _152 => _152[A2A_REQUIRED_KEY]]);
6989
+ const meta = _optionalChain([task, 'access', _152 => _152.status, 'optionalAccess', _153 => _153.message, 'optionalAccess', _154 => _154.metadata]);
6990
+ const required = _optionalChain([meta, 'optionalAccess', _155 => _155[A2A_REQUIRED_KEY]]);
7837
6991
  if (!required || typeof required !== "object") return null;
7838
6992
  return required;
7839
6993
  }
7840
6994
  function fromA2APaymentPayload(message) {
7841
- const raw = _optionalChain([message, 'access', _153 => _153.metadata, 'optionalAccess', _154 => _154[A2A_PAYLOAD_KEY]]);
6995
+ const raw = _optionalChain([message, 'access', _156 => _156.metadata, 'optionalAccess', _157 => _157[A2A_PAYLOAD_KEY]]);
7842
6996
  if (raw === void 0 || raw === null) return null;
7843
6997
  return { raw, taskId: _nullishCoalesce(message.taskId, () => ( "")) };
7844
6998
  }
@@ -7871,7 +7025,7 @@ function createA2APaymentHandler(options) {
7871
7025
  const ttlMs = _nullishCoalesce(options.taskTtlMs, () => ( maxTimeoutSeconds * 1e3));
7872
7026
  const store = _nullishCoalesce(options.taskStore, () => ( defaultTaskStore()));
7873
7027
  function appendReceipt(taskId, entry) {
7874
- const prior = _nullishCoalesce(_optionalChain([store, 'access', _155 => _155.get, 'call', _156 => _156(taskId), 'optionalAccess', _157 => _157.receipts]), () => ( []));
7028
+ const prior = _nullishCoalesce(_optionalChain([store, 'access', _158 => _158.get, 'call', _159 => _159(taskId), 'optionalAccess', _160 => _160.receipts]), () => ( []));
7875
7029
  const isDup = "success" in entry && entry.success === true && entry.transaction !== "" && prior.some((r) => "transaction" in r && r.transaction === entry.transaction);
7876
7030
  const next = isDup ? prior : [...prior, entry];
7877
7031
  const receipts = next.length > MAX_TASK_RECEIPTS ? next.slice(-MAX_TASK_RECEIPTS) : next;
@@ -7947,7 +7101,7 @@ function createA2APaymentHandler(options) {
7947
7101
  try {
7948
7102
  result = await gate.verifyObject(inbound.raw);
7949
7103
  } catch (err) {
7950
- if (err instanceof _chunk3FR22M3Ocjs.SettlementError) {
7104
+ if (err instanceof _chunkQONQSZHJcjs.SettlementError) {
7951
7105
  return failedTask(id, "settlement_failed", err.message, attempted);
7952
7106
  }
7953
7107
  const detail = err instanceof Error ? err.message : String(err);
@@ -7979,11 +7133,11 @@ function createA2APaymentHandler(options) {
7979
7133
  }
7980
7134
  }
7981
7135
  function agentCardExtension(opts) {
7982
- const uri = _optionalChain([opts, 'optionalAccess', _158 => _158.version]) === "v0.2" ? A2A_X402_EXTENSION_URI_V02 : A2A_X402_EXTENSION_URI_V01;
7136
+ const uri = _optionalChain([opts, 'optionalAccess', _161 => _161.version]) === "v0.2" ? A2A_X402_EXTENSION_URI_V02 : A2A_X402_EXTENSION_URI_V01;
7983
7137
  return {
7984
7138
  uri,
7985
7139
  description: "Supports payments using the x402 protocol for on-chain settlement.",
7986
- ..._optionalChain([opts, 'optionalAccess', _159 => _159.required]) ? { required: true } : {}
7140
+ ..._optionalChain([opts, 'optionalAccess', _162 => _162.required]) ? { required: true } : {}
7987
7141
  };
7988
7142
  }
7989
7143
  return { handleMessage, agentCardExtension, gate };
@@ -7994,7 +7148,7 @@ function singleNetworkOf(challenge) {
7994
7148
  }
7995
7149
  function networkFromPayload(raw) {
7996
7150
  const v = raw;
7997
- if (v && typeof _optionalChain([v, 'access', _160 => _160.accepted, 'optionalAccess', _161 => _161.network]) === "string") return v.accepted.network;
7151
+ if (v && typeof _optionalChain([v, 'access', _163 => _163.accepted, 'optionalAccess', _164 => _164.network]) === "string") return v.accepted.network;
7998
7152
  if (v && typeof v.network === "string") return v.network;
7999
7153
  return void 0;
8000
7154
  }
@@ -8036,7 +7190,7 @@ function toMcpPaymentResponse(content, receipt) {
8036
7190
  };
8037
7191
  }
8038
7192
  function fromMcpPayment(params) {
8039
- const meta = _optionalChain([params, 'optionalAccess', _162 => _162._meta, 'optionalAccess', _163 => _163[MCP_PAYMENT_META_KEY]]);
7193
+ const meta = _optionalChain([params, 'optionalAccess', _165 => _165._meta, 'optionalAccess', _166 => _166[MCP_PAYMENT_META_KEY]]);
8040
7194
  return meta == null ? null : meta;
8041
7195
  }
8042
7196
  function fromMcpPaymentRequired(result) {
@@ -8045,14 +7199,14 @@ function fromMcpPaymentRequired(result) {
8045
7199
  if (sc && typeof sc === "object" && typeof sc.x402Version === "number") {
8046
7200
  return sc;
8047
7201
  }
8048
- const text = _optionalChain([result, 'access', _164 => _164.content, 'optionalAccess', _165 => _165[0], 'optionalAccess', _166 => _166.text]);
7202
+ const text = _optionalChain([result, 'access', _167 => _167.content, 'optionalAccess', _168 => _168[0], 'optionalAccess', _169 => _169.text]);
8049
7203
  if (typeof text === "string") {
8050
7204
  try {
8051
7205
  const parsed = JSON.parse(text);
8052
7206
  if (parsed && typeof parsed === "object" && typeof parsed.x402Version === "number") {
8053
7207
  return parsed;
8054
7208
  }
8055
- } catch (e62) {
7209
+ } catch (e55) {
8056
7210
  }
8057
7211
  }
8058
7212
  return null;
@@ -8061,7 +7215,7 @@ function isMcpPaymentRequired(result) {
8061
7215
  return fromMcpPaymentRequired(result) != null;
8062
7216
  }
8063
7217
  function fromMcpPaymentResponse(result) {
8064
- const meta = _optionalChain([result, 'optionalAccess', _167 => _167._meta, 'optionalAccess', _168 => _168[MCP_PAYMENT_RESPONSE_META_KEY]]);
7218
+ const meta = _optionalChain([result, 'optionalAccess', _170 => _170._meta, 'optionalAccess', _171 => _171[MCP_PAYMENT_RESPONSE_META_KEY]]);
8065
7219
  if (!meta || typeof meta !== "object") return null;
8066
7220
  return meta;
8067
7221
  }
@@ -8098,7 +7252,7 @@ function createMcpPaymentTool(options) {
8098
7252
  try {
8099
7253
  result = await gate.verifyObject(raw);
8100
7254
  } catch (err) {
8101
- if (err instanceof _chunk3FR22M3Ocjs.SettlementError) return settlementFailed("settlement_failed", err.message);
7255
+ if (err instanceof _chunkQONQSZHJcjs.SettlementError) return settlementFailed("settlement_failed", err.message);
8102
7256
  throw err;
8103
7257
  }
8104
7258
  if (result.kind === "paid") {
@@ -8270,4 +7424,10 @@ function createMcpPaymentTool(options) {
8270
7424
 
8271
7425
 
8272
7426
 
8273
- exports.A2A_ERROR_KEY = A2A_ERROR_KEY; exports.A2A_EXTENSIONS_HEADER = A2A_EXTENSIONS_HEADER; exports.A2A_PAYLOAD_KEY = A2A_PAYLOAD_KEY; exports.A2A_RECEIPTS_KEY = A2A_RECEIPTS_KEY; exports.A2A_REQUIRED_KEY = A2A_REQUIRED_KEY; exports.A2A_STATUS_KEY = A2A_STATUS_KEY; exports.A2A_X402_EXTENSION_URI_V01 = A2A_X402_EXTENSION_URI_V01; exports.A2A_X402_EXTENSION_URI_V02 = A2A_X402_EXTENSION_URI_V02; exports.BRAND = BRAND; exports.BUILTIN_DENOMS = BUILTIN_DENOMS; exports.CHAINS = CHAINS; exports.ConfirmationTimeoutError = _chunk3FR22M3Ocjs.ConfirmationTimeoutError; exports.DENOM_PRECISION = DENOM_PRECISION; exports.DIRECTORY_INFO = DIRECTORY_INFO; exports.EIP3009_TYPES = EIP3009_TYPES; exports.EXACT_NETWORK_SLUGS = EXACT_NETWORK_SLUGS; exports.EXT_OFFER_RECEIPT = EXT_OFFER_RECEIPT; exports.EXT_PAYMENT_IDENTIFIER = EXT_PAYMENT_IDENTIFIER; exports.GENERATOR = GENERATOR; exports.HEADER_REQUIRED = HEADER_REQUIRED; exports.HEADER_RESPONSE = HEADER_RESPONSE; exports.HEADER_RESPONSE_V1 = HEADER_RESPONSE_V1; exports.HEADER_SIGNATURE = HEADER_SIGNATURE; exports.HEADER_SIGNATURE_V1 = HEADER_SIGNATURE_V1; exports.InsufficientFundsError = _chunk3FR22M3Ocjs.InsufficientFundsError; exports.InvalidConfigError = _chunk3FR22M3Ocjs.InvalidConfigError; exports.InvalidEnvelopeError = _chunk3FR22M3Ocjs.InvalidEnvelopeError; exports.KNOWN_FACILITATORS = KNOWN_FACILITATORS; exports.MCP_PAYMENT_META_KEY = MCP_PAYMENT_META_KEY; exports.MCP_PAYMENT_RESPONSE_META_KEY = MCP_PAYMENT_RESPONSE_META_KEY; exports.MaxRetriesExceededError = _chunk3FR22M3Ocjs.MaxRetriesExceededError; exports.MissingDriverError = _chunk3FR22M3Ocjs.MissingDriverError; exports.MultiChainPayer = MultiChainPayer; exports.NoCompatibleAcceptError = _chunk3FR22M3Ocjs.NoCompatibleAcceptError; exports.NonReplayableBodyError = _chunk3FR22M3Ocjs.NonReplayableBodyError; exports.PERMIT2_ADDRESS = PERMIT2_ADDRESS; exports.PERMIT2_PROXY_CHAIN_IDS = PERMIT2_PROXY_CHAIN_IDS; exports.PERMIT2_UPTO_WITNESS_TYPES = PERMIT2_UPTO_WITNESS_TYPES; exports.PERMIT2_WITNESS_TYPES = PERMIT2_WITNESS_TYPES; exports.PIPRAIL_AGENT_GUIDE = PIPRAIL_AGENT_GUIDE; exports.POWERED_BY = POWERED_BY; exports.PaymentDeclinedError = _chunk3FR22M3Ocjs.PaymentDeclinedError; exports.PaymentTimeoutError = _chunk3FR22M3Ocjs.PaymentTimeoutError; exports.PipRailClient = PipRailClient; exports.PipRailError = _chunk3FR22M3Ocjs.PipRailError; exports.REGISTER_ATTRIBUTION = REGISTER_ATTRIBUTION; exports.RecipientNotReadyError = _chunk3FR22M3Ocjs.RecipientNotReadyError; exports.SettlementError = _chunk3FR22M3Ocjs.SettlementError; exports.SpendLedger = SpendLedger; exports.UPTO_PROXY_CHAIN_IDS = UPTO_PROXY_CHAIN_IDS; exports.UnknownTokenError = _chunk3FR22M3Ocjs.UnknownTokenError; exports.UnsupportedNetworkError = _chunk3FR22M3Ocjs.UnsupportedNetworkError; exports.UnsupportedSchemeError = _chunk3FR22M3Ocjs.UnsupportedSchemeError; exports.VERIFY_CODE_TO_A2A_ERROR = VERIFY_CODE_TO_A2A_ERROR; exports.WalletRequiredError = _chunk3FR22M3Ocjs.WalletRequiredError; exports.WrongChainError = _chunk3FR22M3Ocjs.WrongChainError; exports.WrongFamilyError = _chunk3FR22M3Ocjs.WrongFamilyError; exports.X402_EXACT_PERMIT2_PROXY = X402_EXACT_PERMIT2_PROXY; exports.X402_UPTO_PERMIT2_PROXY = X402_UPTO_PERMIT2_PROXY; exports.agentGuide = agentGuide; exports.appendAttribution = appendAttribution; exports.appendKeywords = appendKeywords; exports.buildBazaarExtension = buildBazaarExtension; exports.buildChallengeHeader = buildChallengeHeader; exports.buildEndpointInfo = buildEndpointInfo; exports.buildExactAuthorization = buildExactAuthorization; exports.buildExactSignatureHeader = buildExactSignatureHeader; exports.buildMcpPaymentMeta = buildMcpPaymentMeta; exports.buildOpenApi = buildOpenApi; exports.buildPaymentIdentifierAdvertisement = buildPaymentIdentifierAdvertisement; exports.buildReceiptExtension = buildReceiptExtension; exports.buildReceiptHeader = buildReceiptHeader; exports.buildSelfDescription = buildSelfDescription; exports.buildSignatureHeader = buildSignatureHeader; exports.buildUptoSignatureHeader = buildUptoSignatureHeader; exports.buildWellKnownX402 = buildWellKnownX402; exports.buildWellKnownX402Manifest = buildWellKnownX402Manifest; exports.buildX402DnsTxt = buildX402DnsTxt; exports.chainIdForExactNetwork = chainIdForExactNetwork; exports.claim402IndexDomain = claim402IndexDomain; exports.classifyChallenge = classifyChallenge; exports.createA2APaymentHandler = createA2APaymentHandler; exports.createMcpPaymentTool = createMcpPaymentTool; exports.createPaymentGate = createPaymentGate; exports.createPaywall = createPaywall; exports.createTipJar = createTipJar; exports.decodeBase64Json = decodeBase64Json; exports.decorateOutcome = decorateOutcome; exports.deliverReceipt = deliverReceipt; exports.denomOf = denomOf; exports.describeChallenge = describeChallenge; exports.discoveryHeaders = discoveryHeaders; exports.eip3009Abi = eip3009Abi; exports.encodeXPaymentHeader = encodeXPaymentHeader; exports.evaluatePolicy = evaluatePolicy; exports.explainDecline = explainDecline; exports.facilitatorCoverage = facilitatorCoverage; exports.fetchAcross = fetchAcross; exports.firstKeylessFacilitator = firstKeylessFacilitator; exports.formatSpendReport = formatSpendReport; exports.fromA2APaymentPayload = fromA2APaymentPayload; exports.fromA2APaymentRequired = fromA2APaymentRequired; exports.fromMcpPayment = fromMcpPayment; exports.fromMcpPaymentRequired = fromMcpPaymentRequired; exports.fromMcpPaymentResponse = fromMcpPaymentResponse; exports.getDirectoryInfo = getDirectoryInfo; exports.isMcpPaymentRequired = isMcpPaymentRequired; exports.isPermit2ProxyChain = isPermit2ProxyChain; exports.isUptoProxyChain = isUptoProxyChain; exports.knownFacilitatorsFor = knownFacilitatorsFor; exports.memorySpendStore = _chunkO4UQOZ4Zcjs.memorySpendStore; exports.normalizeNetwork = normalizeNetwork; exports.parseChallenge = parseChallenge; exports.parseExactObject = parseExactObject; exports.parseExactPaymentHeader = parseExactPaymentHeader; exports.parseExactRequirements = parseExactRequirements; exports.parseFacilitatorSupported = parseFacilitatorSupported; exports.parseReceipt = parseReceipt; exports.parseReceiptExtension = parseReceiptExtension; exports.parseSettleResponse = parseSettleResponse; exports.parseSignatureHeader = parseSignatureHeader; exports.parseSignatureObject = parseSignatureObject; exports.parseUptoObject = parseUptoObject; exports.parseUptoPaymentHeader = parseUptoPaymentHeader; exports.paymentTools = paymentTools; exports.pickAccept = pickAccept; exports.planAcross = planAcross; exports.proxyTo = proxyTo; exports.rankResources = rankResources; exports.readExactDomain = readExactDomain; exports.readPaymentIdentifier = readPaymentIdentifier; exports.register402Index = register402Index; exports.registerDriver = registerDriver; exports.registerX402Scan = registerX402Scan; exports.renderLandingPage = renderLandingPage; exports.requirePayment = requirePayment; exports.resolveChain = resolveChain; exports.scoreResource = scoreResource; exports.searchOpenIndexes = searchOpenIndexes; exports.settleViaFacilitator = settleViaFacilitator; exports.summarizePlan = summarizePlan; exports.toA2AErrorCode = toA2AErrorCode; exports.toA2APaymentFailed = toA2APaymentFailed; exports.toA2APaymentReceipts = toA2APaymentReceipts; exports.toA2APaymentRequired = toA2APaymentRequired; exports.toFetchHandler = toFetchHandler; exports.toInsufficientFundsError = _chunk3FR22M3Ocjs.toInsufficientFundsError; exports.toInvalidBody = toInvalidBody; exports.toMcpPaymentRequired = toMcpPaymentRequired; exports.toMcpPaymentResponse = toMcpPaymentResponse; exports.toWorker = toWorker; exports.verify402IndexDomain = verify402IndexDomain;
7427
+
7428
+
7429
+
7430
+
7431
+
7432
+
7433
+ exports.A2A_ERROR_KEY = A2A_ERROR_KEY; exports.A2A_EXTENSIONS_HEADER = A2A_EXTENSIONS_HEADER; exports.A2A_PAYLOAD_KEY = A2A_PAYLOAD_KEY; exports.A2A_RECEIPTS_KEY = A2A_RECEIPTS_KEY; exports.A2A_REQUIRED_KEY = A2A_REQUIRED_KEY; exports.A2A_STATUS_KEY = A2A_STATUS_KEY; exports.A2A_X402_EXTENSION_URI_V01 = A2A_X402_EXTENSION_URI_V01; exports.A2A_X402_EXTENSION_URI_V02 = A2A_X402_EXTENSION_URI_V02; exports.BRAND = BRAND; exports.BUILTIN_DENOMS = BUILTIN_DENOMS; exports.CHAINS = CHAINS; exports.ConfirmationTimeoutError = _chunkQONQSZHJcjs.ConfirmationTimeoutError; exports.DEFAULT_EXACT_TRANSFER_METHOD = _chunkOXEFPLZAcjs.DEFAULT_EXACT_TRANSFER_METHOD; exports.DENOM_PRECISION = DENOM_PRECISION; exports.DIRECTORY_INFO = _chunkV2IJ5HUWcjs.DIRECTORY_INFO; exports.EIP3009_TYPES = EIP3009_TYPES; exports.EXACT_NETWORK_SLUGS = EXACT_NETWORK_SLUGS; exports.EXT_OFFER_RECEIPT = _chunkOXEFPLZAcjs.EXT_OFFER_RECEIPT; exports.EXT_PAYMENT_IDENTIFIER = _chunkOXEFPLZAcjs.EXT_PAYMENT_IDENTIFIER; exports.GENERATOR = GENERATOR; exports.HEADER_REQUIRED = _chunkOXEFPLZAcjs.HEADER_REQUIRED; exports.HEADER_RESPONSE = _chunkOXEFPLZAcjs.HEADER_RESPONSE; exports.HEADER_RESPONSE_V1 = _chunkOXEFPLZAcjs.HEADER_RESPONSE_V1; exports.HEADER_SIGNATURE = _chunkOXEFPLZAcjs.HEADER_SIGNATURE; exports.HEADER_SIGNATURE_V1 = _chunkOXEFPLZAcjs.HEADER_SIGNATURE_V1; exports.InsufficientFundsError = _chunkQONQSZHJcjs.InsufficientFundsError; exports.InvalidConfigError = _chunkQONQSZHJcjs.InvalidConfigError; exports.InvalidEnvelopeError = _chunkQONQSZHJcjs.InvalidEnvelopeError; exports.KNOWN_EXACT_TRANSFER_METHODS = _chunkOXEFPLZAcjs.KNOWN_EXACT_TRANSFER_METHODS; exports.KNOWN_FACILITATORS = KNOWN_FACILITATORS; exports.MCP_PAYMENT_META_KEY = MCP_PAYMENT_META_KEY; exports.MCP_PAYMENT_RESPONSE_META_KEY = MCP_PAYMENT_RESPONSE_META_KEY; exports.MaxRetriesExceededError = _chunkQONQSZHJcjs.MaxRetriesExceededError; exports.MissingDriverError = _chunkQONQSZHJcjs.MissingDriverError; exports.MultiChainPayer = MultiChainPayer; exports.NoCompatibleAcceptError = _chunkQONQSZHJcjs.NoCompatibleAcceptError; exports.NonReplayableBodyError = _chunkQONQSZHJcjs.NonReplayableBodyError; exports.PERMIT2_ADDRESS = PERMIT2_ADDRESS; exports.PERMIT2_PROXY_CHAIN_IDS = PERMIT2_PROXY_CHAIN_IDS; exports.PERMIT2_UPTO_WITNESS_TYPES = PERMIT2_UPTO_WITNESS_TYPES; exports.PERMIT2_WITNESS_TYPES = PERMIT2_WITNESS_TYPES; exports.PIPRAIL_AGENT_GUIDE = PIPRAIL_AGENT_GUIDE; exports.POWERED_BY = POWERED_BY; exports.PaymentDeclinedError = _chunkQONQSZHJcjs.PaymentDeclinedError; exports.PaymentTimeoutError = _chunkQONQSZHJcjs.PaymentTimeoutError; exports.PipRailClient = PipRailClient; exports.PipRailError = _chunkQONQSZHJcjs.PipRailError; exports.REGISTER_ATTRIBUTION = _chunkV2IJ5HUWcjs.REGISTER_ATTRIBUTION; exports.RecipientNotReadyError = _chunkQONQSZHJcjs.RecipientNotReadyError; exports.SettlementError = _chunkQONQSZHJcjs.SettlementError; exports.SpendLedger = SpendLedger; exports.UPTO_PROXY_CHAIN_IDS = UPTO_PROXY_CHAIN_IDS; exports.UnknownTokenError = _chunkQONQSZHJcjs.UnknownTokenError; exports.UnsupportedNetworkError = _chunkQONQSZHJcjs.UnsupportedNetworkError; exports.UnsupportedSchemeError = _chunkQONQSZHJcjs.UnsupportedSchemeError; exports.VERIFY_CODE_TO_A2A_ERROR = VERIFY_CODE_TO_A2A_ERROR; exports.WalletRequiredError = _chunkQONQSZHJcjs.WalletRequiredError; exports.WrongChainError = _chunkQONQSZHJcjs.WrongChainError; exports.WrongFamilyError = _chunkQONQSZHJcjs.WrongFamilyError; exports.X402_EXACT_PERMIT2_PROXY = X402_EXACT_PERMIT2_PROXY; exports.X402_UPTO_PERMIT2_PROXY = X402_UPTO_PERMIT2_PROXY; exports.agentGuide = agentGuide; exports.appendAttribution = _chunkV2IJ5HUWcjs.appendAttribution; exports.appendKeywords = _chunkV2IJ5HUWcjs.appendKeywords; exports.buildBazaarExtension = buildBazaarExtension; exports.buildChallengeHeader = _chunkOXEFPLZAcjs.buildChallengeHeader; exports.buildEndpointInfo = buildEndpointInfo; exports.buildExactAuthorization = buildExactAuthorization; exports.buildExactSignatureHeader = _chunkOXEFPLZAcjs.buildExactSignatureHeader; exports.buildMcpPaymentMeta = buildMcpPaymentMeta; exports.buildOpenApi = buildOpenApi; exports.buildPaymentIdentifierAdvertisement = _chunkOXEFPLZAcjs.buildPaymentIdentifierAdvertisement; exports.buildReceiptExtension = _chunkOXEFPLZAcjs.buildReceiptExtension; exports.buildReceiptHeader = _chunkOXEFPLZAcjs.buildReceiptHeader; exports.buildSelfDescription = buildSelfDescription; exports.buildSignatureHeader = _chunkOXEFPLZAcjs.buildSignatureHeader; exports.buildUptoSignatureHeader = _chunkOXEFPLZAcjs.buildUptoSignatureHeader; exports.buildV1PaymentHeader = _chunkOXEFPLZAcjs.buildV1PaymentHeader; exports.buildWellKnownX402 = buildWellKnownX402; exports.buildWellKnownX402Manifest = buildWellKnownX402Manifest; exports.buildX402DnsTxt = buildX402DnsTxt; exports.chainIdForExactNetwork = chainIdForExactNetwork; exports.claim402IndexDomain = _chunkV2IJ5HUWcjs.claim402IndexDomain; exports.classifyChallenge = classifyChallenge; exports.createA2APaymentHandler = createA2APaymentHandler; exports.createMcpPaymentTool = createMcpPaymentTool; exports.createPaymentGate = createPaymentGate; exports.createPaywall = createPaywall; exports.createTipJar = createTipJar; exports.decodeBase64Json = _chunkOXEFPLZAcjs.decodeBase64Json; exports.decorateOutcome = _chunkV2IJ5HUWcjs.decorateOutcome; exports.deliverReceipt = deliverReceipt; exports.denomOf = denomOf; exports.describeChallenge = describeChallenge; exports.discoveryHeaders = discoveryHeaders; exports.eip3009Abi = eip3009Abi; exports.encodeXPaymentHeader = encodeXPaymentHeader; exports.evaluatePolicy = evaluatePolicy; exports.exactTransferMethod = _chunkOXEFPLZAcjs.exactTransferMethod; exports.explainDecline = explainDecline; exports.facilitatorCoverage = facilitatorCoverage; exports.fetchAcross = fetchAcross; exports.firstKeylessFacilitator = firstKeylessFacilitator; exports.formatSpendReport = formatSpendReport; exports.fromA2APaymentPayload = fromA2APaymentPayload; exports.fromA2APaymentRequired = fromA2APaymentRequired; exports.fromMcpPayment = fromMcpPayment; exports.fromMcpPaymentRequired = fromMcpPaymentRequired; exports.fromMcpPaymentResponse = fromMcpPaymentResponse; exports.getDirectoryInfo = _chunkV2IJ5HUWcjs.getDirectoryInfo; exports.isMcpPaymentRequired = isMcpPaymentRequired; exports.isPermit2ProxyChain = isPermit2ProxyChain; exports.isSettleableExactMethod = _chunkOXEFPLZAcjs.isSettleableExactMethod; exports.isUptoProxyChain = isUptoProxyChain; exports.knownFacilitatorsFor = knownFacilitatorsFor; exports.memorySpendStore = _chunkO4UQOZ4Zcjs.memorySpendStore; exports.normalizeNetwork = _chunkV2IJ5HUWcjs.normalizeNetwork; exports.normalizeV1Challenge = _chunkOXEFPLZAcjs.normalizeV1Challenge; exports.parseChallenge = _chunkOXEFPLZAcjs.parseChallenge; exports.parseExactObject = _chunkOXEFPLZAcjs.parseExactObject; exports.parseExactPaymentHeader = _chunkOXEFPLZAcjs.parseExactPaymentHeader; exports.parseExactRequirements = parseExactRequirements; exports.parseFacilitatorSupported = parseFacilitatorSupported; exports.parseReceipt = _chunkOXEFPLZAcjs.parseReceipt; exports.parseReceiptExtension = _chunkOXEFPLZAcjs.parseReceiptExtension; exports.parseSettleResponse = _chunkOXEFPLZAcjs.parseSettleResponse; exports.parseSignatureHeader = _chunkOXEFPLZAcjs.parseSignatureHeader; exports.parseSignatureObject = _chunkOXEFPLZAcjs.parseSignatureObject; exports.parseUptoObject = _chunkOXEFPLZAcjs.parseUptoObject; exports.parseUptoPaymentHeader = _chunkOXEFPLZAcjs.parseUptoPaymentHeader; exports.paymentTools = paymentTools; exports.pickAccept = _chunkOXEFPLZAcjs.pickAccept; exports.planAcross = planAcross; exports.proxyTo = proxyTo; exports.rankResources = _chunkV2IJ5HUWcjs.rankResources; exports.readExactDomain = readExactDomain; exports.readPaymentIdentifier = _chunkOXEFPLZAcjs.readPaymentIdentifier; exports.register402Index = _chunkV2IJ5HUWcjs.register402Index; exports.registerDriver = registerDriver; exports.registerX402Scan = _chunkV2IJ5HUWcjs.registerX402Scan; exports.renderLandingPage = renderLandingPage; exports.requirePayment = requirePayment; exports.resolveChain = resolveChain; exports.scoreResource = _chunkV2IJ5HUWcjs.scoreResource; exports.searchOpenIndexes = _chunkV2IJ5HUWcjs.searchOpenIndexes; exports.settleViaFacilitator = settleViaFacilitator; exports.summarizePlan = summarizePlan; exports.toA2AErrorCode = toA2AErrorCode; exports.toA2APaymentFailed = toA2APaymentFailed; exports.toA2APaymentReceipts = toA2APaymentReceipts; exports.toA2APaymentRequired = toA2APaymentRequired; exports.toFetchHandler = toFetchHandler; exports.toInsufficientFundsError = _chunkQONQSZHJcjs.toInsufficientFundsError; exports.toInvalidBody = toInvalidBody; exports.toMcpPaymentRequired = toMcpPaymentRequired; exports.toMcpPaymentResponse = toMcpPaymentResponse; exports.toWorker = toWorker; exports.verify402IndexDomain = _chunkV2IJ5HUWcjs.verify402IndexDomain;