@piprail/sdk 2.13.1 → 2.14.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 (30) hide show
  1. package/CHANGELOG.md +70 -0
  2. package/dist/{algorand-TQCYK2XT.js → algorand-6J3IABVF.js} +12 -11
  3. package/dist/{algorand-AQK5EAUF.cjs → algorand-QU6G2DQZ.cjs} +43 -42
  4. package/dist/{aptos-RYQOSFBQ.js → aptos-DHOMTBLZ.js} +11 -10
  5. package/dist/{aptos-65UX7GKA.cjs → aptos-LFTQGBBK.cjs} +41 -40
  6. package/dist/{chunk-DCOUJZPL.cjs → chunk-GYM46G5L.cjs} +16 -0
  7. package/dist/{chunk-O32N6MFN.js → chunk-PAMKCWVW.js} +16 -0
  8. package/dist/index.cjs +484 -231
  9. package/dist/index.d.cts +270 -7
  10. package/dist/index.d.ts +270 -7
  11. package/dist/index.js +280 -27
  12. package/dist/{ledger-mF_SoiDB.d.ts → ledger-uFtXlIHY.d.cts} +31 -1
  13. package/dist/{ledger-mF_SoiDB.d.cts → ledger-uFtXlIHY.d.ts} +31 -1
  14. package/dist/{near-VDATC5AV.js → near-5PXTVQ47.js} +14 -5
  15. package/dist/{near-UDPFA6SV.cjs → near-YNNK7RW7.cjs} +39 -30
  16. package/dist/node.d.cts +2 -2
  17. package/dist/node.d.ts +2 -2
  18. package/dist/{solana-VYLWFNAH.js → solana-HITVI3HF.js} +22 -7
  19. package/dist/{solana-RQNXFCZO.cjs → solana-N3UCNCYE.cjs} +54 -39
  20. package/dist/{stellar-KBR4V77T.js → stellar-2QT6YYKN.js} +4 -4
  21. package/dist/{stellar-OK2HW5PZ.cjs → stellar-Y3SQN7S5.cjs} +23 -23
  22. package/dist/{sui-SVFBJFW5.cjs → sui-4AL4E6XU.cjs} +35 -27
  23. package/dist/{sui-BXHB6D3W.js → sui-FV5L6WF5.js} +20 -12
  24. package/dist/{ton-NNKQFQ6U.js → ton-5FWDQ4QR.js} +18 -7
  25. package/dist/{ton-D7YN6BGR.cjs → ton-5HDVOTMR.cjs} +33 -22
  26. package/dist/{tron-W2D5PQXV.js → tron-AZDY7BMQ.js} +10 -10
  27. package/dist/{tron-WZFU57NX.cjs → tron-TX2B4N2A.cjs} +39 -39
  28. package/dist/{xrpl-5NHY3NEL.cjs → xrpl-5TYDLQFS.cjs} +31 -31
  29. package/dist/{xrpl-37E23W53.js → xrpl-UJL5J7CY.js} +13 -13
  30. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -31,7 +31,7 @@ var _chunkCQQI5IJXcjs = require('./chunk-CQQI5IJX.cjs');
31
31
 
32
32
 
33
33
 
34
- var _chunkDCOUJZPLcjs = require('./chunk-DCOUJZPL.cjs');
34
+ var _chunkGYM46G5Lcjs = require('./chunk-GYM46G5L.cjs');
35
35
 
36
36
  // src/drivers/registry.ts
37
37
  var byFamily = /* @__PURE__ */ new Map();
@@ -60,13 +60,13 @@ function resolveNetwork(opts) {
60
60
  const family = familyForChain(opts.chain);
61
61
  const driver = byFamily.get(family);
62
62
  if (!driver) {
63
- throw new (0, _chunkDCOUJZPLcjs.UnsupportedNetworkError)(
63
+ throw new (0, _chunkGYM46G5Lcjs.UnsupportedNetworkError)(
64
64
  `No driver registered for the "${family}" family \u2014 it may not be mounted yet (use the async resolveNetwork()).`
65
65
  );
66
66
  }
67
67
  const net = driver.resolve(opts);
68
68
  if (!net) {
69
- throw new (0, _chunkDCOUJZPLcjs.UnsupportedNetworkError)(
69
+ throw new (0, _chunkGYM46G5Lcjs.UnsupportedNetworkError)(
70
70
  `The ${family} driver didn't recognise this chain input.`
71
71
  );
72
72
  }
@@ -331,12 +331,12 @@ function resolveChain(input, rpcUrlOverride) {
331
331
 
332
332
  var _accounts = require('viem/accounts');
333
333
  function createWalletAdapter(config, resolved) {
334
- _chunkDCOUJZPLcjs.assertNoLegacyWalletKey.call(void 0, config, "EVM");
334
+ _chunkGYM46G5Lcjs.assertNoLegacyWalletKey.call(void 0, config, "EVM");
335
335
  if ("key" in config) {
336
336
  const key = config.key;
337
337
  if (typeof key !== "string" || !/^0x[0-9a-fA-F]{64}$/.test(key)) {
338
338
  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).";
339
- throw new (0, _chunkDCOUJZPLcjs.WrongFamilyError)(
339
+ throw new (0, _chunkGYM46G5Lcjs.WrongFamilyError)(
340
340
  `chain is EVM; the wallet { key } is not a valid 0x\u2026 32-byte hex private key${hint}`
341
341
  );
342
342
  }
@@ -344,7 +344,7 @@ function createWalletAdapter(config, resolved) {
344
344
  try {
345
345
  account = _accounts.privateKeyToAccount.call(void 0, key);
346
346
  } catch (err) {
347
- throw new (0, _chunkDCOUJZPLcjs.WrongFamilyError)(
347
+ throw new (0, _chunkGYM46G5Lcjs.WrongFamilyError)(
348
348
  `chain is EVM; the wallet { key } is not a valid 0x\u2026 32-byte hex private key: ${err instanceof Error ? err.message : String(err)}.`
349
349
  );
350
350
  }
@@ -354,12 +354,12 @@ function createWalletAdapter(config, resolved) {
354
354
  }
355
355
  const wc = config.walletClient;
356
356
  if (!wc.account) {
357
- throw new (0, _chunkDCOUJZPLcjs.WrongFamilyError)(
357
+ throw new (0, _chunkGYM46G5Lcjs.WrongFamilyError)(
358
358
  "chain is EVM; the provided walletClient has no attached account. Use `createWalletClient({ account, chain, transport })`, or pass { key }."
359
359
  );
360
360
  }
361
361
  if (wc.chain && wc.chain.id !== resolved.chainId) {
362
- throw new (0, _chunkDCOUJZPLcjs.WrongChainError)(
362
+ throw new (0, _chunkGYM46G5Lcjs.WrongChainError)(
363
363
  `PipRailClient: walletClient is on chain ${wc.chain.id} but the SDK was configured with chain ${resolved.chainId}. They must match.`
364
364
  );
365
365
  }
@@ -689,7 +689,7 @@ async function payExactEvm(input) {
689
689
  code = void 0;
690
690
  }
691
691
  if (code && code !== "0x") {
692
- throw new (0, _chunkDCOUJZPLcjs.UnsupportedSchemeError)(
692
+ throw new (0, _chunkGYM46G5Lcjs.UnsupportedSchemeError)(
693
693
  `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.`
694
694
  );
695
695
  }
@@ -699,13 +699,13 @@ async function payExactEvm(input) {
699
699
  domain = await readExactDomain(publicClient, accept.asset);
700
700
  }
701
701
  if (!domain) {
702
- throw new (0, _chunkDCOUJZPLcjs.UnsupportedSchemeError)(
702
+ throw new (0, _chunkGYM46G5Lcjs.UnsupportedSchemeError)(
703
703
  `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.`
704
704
  );
705
705
  }
706
706
  const g = globalThis.crypto;
707
707
  if (!_optionalChain([g, 'optionalAccess', _5 => _5.getRandomValues])) {
708
- throw new (0, _chunkDCOUJZPLcjs.UnsupportedSchemeError)(
708
+ throw new (0, _chunkGYM46G5Lcjs.UnsupportedSchemeError)(
709
709
  "this runtime lacks Web Crypto (globalThis.crypto.getRandomValues); the exact rail needs a CSPRNG nonce."
710
710
  );
711
711
  }
@@ -962,7 +962,7 @@ async function verifyAndSettleExactEvm(input) {
962
962
  args: writeArgs
963
963
  });
964
964
  } catch (err) {
965
- throw new (0, _chunkDCOUJZPLcjs.SettlementError)(
965
+ throw new (0, _chunkGYM46G5Lcjs.SettlementError)(
966
966
  `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.`,
967
967
  { cause: err }
968
968
  );
@@ -974,7 +974,7 @@ async function verifyAndSettleExactEvm(input) {
974
974
  return { ok: false, error: "tx_reverted", detail: `Settlement tx ${txHash} reverted on-chain.` };
975
975
  }
976
976
  } catch (err) {
977
- throw new (0, _chunkDCOUJZPLcjs.SettlementError)(
977
+ throw new (0, _chunkGYM46G5Lcjs.SettlementError)(
978
978
  `exact settle: broadcast ${txHash} but couldn't confirm it (${shorten(err instanceof Error ? err.message : String(err))}).`,
979
979
  { cause: err }
980
980
  );
@@ -1105,7 +1105,7 @@ function shorten2(msg) {
1105
1105
  function randomPermit2Nonce() {
1106
1106
  const g = globalThis.crypto;
1107
1107
  if (!_optionalChain([g, 'optionalAccess', _8 => _8.getRandomValues])) {
1108
- throw new (0, _chunkDCOUJZPLcjs.UnsupportedSchemeError)(
1108
+ throw new (0, _chunkGYM46G5Lcjs.UnsupportedSchemeError)(
1109
1109
  "this runtime lacks Web Crypto (globalThis.crypto.getRandomValues); the permit2 rail needs a CSPRNG nonce."
1110
1110
  );
1111
1111
  }
@@ -1124,7 +1124,7 @@ async function ensurePermit2Allowance(input) {
1124
1124
  args: [account.address, PERMIT2_ADDRESS]
1125
1125
  });
1126
1126
  } catch (err) {
1127
- throw new (0, _chunkDCOUJZPLcjs.UnsupportedSchemeError)(
1127
+ throw new (0, _chunkGYM46G5Lcjs.UnsupportedSchemeError)(
1128
1128
  `permit2: couldn't read the Permit2 allowance for ${token} (${shorten2(err instanceof Error ? err.message : String(err))}).`
1129
1129
  );
1130
1130
  }
@@ -1141,7 +1141,7 @@ async function ensurePermit2Allowance(input) {
1141
1141
  await publicClient.waitForTransactionReceipt({ hash, confirmations: 1 });
1142
1142
  return hash;
1143
1143
  } catch (err) {
1144
- throw _nullishCoalesce(_chunkDCOUJZPLcjs.toInsufficientFundsError.call(void 0, err), () => ( new (0, _chunkDCOUJZPLcjs.SettlementError)(
1144
+ throw _nullishCoalesce(_chunkGYM46G5Lcjs.toInsufficientFundsError.call(void 0, err), () => ( new (0, _chunkGYM46G5Lcjs.SettlementError)(
1145
1145
  `permit2: the one-time Permit2 approval for ${token} failed to broadcast (${shorten2(err instanceof Error ? err.message : String(err))}).`,
1146
1146
  { cause: err }
1147
1147
  )));
@@ -1156,7 +1156,7 @@ async function payPermit2Evm(input) {
1156
1156
  code = void 0;
1157
1157
  }
1158
1158
  if (code && code !== "0x") {
1159
- throw new (0, _chunkDCOUJZPLcjs.UnsupportedSchemeError)(
1159
+ throw new (0, _chunkGYM46G5Lcjs.UnsupportedSchemeError)(
1160
1160
  `permit2 buyer rail requires an EOA signer; ${account.address} is a contract / EIP-1271 / EIP-7702-delegated account. Pay via onchain-proof.`
1161
1161
  );
1162
1162
  }
@@ -1331,7 +1331,7 @@ async function verifyAndSettlePermit2Evm(input) {
1331
1331
  args: settleArgs
1332
1332
  });
1333
1333
  } catch (err) {
1334
- throw new (0, _chunkDCOUJZPLcjs.SettlementError)(
1334
+ throw new (0, _chunkGYM46G5Lcjs.SettlementError)(
1335
1335
  `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.`,
1336
1336
  { cause: err }
1337
1337
  );
@@ -1343,7 +1343,7 @@ async function verifyAndSettlePermit2Evm(input) {
1343
1343
  return { ok: false, error: "tx_reverted", detail: `Settlement tx ${txHash} reverted on-chain.` };
1344
1344
  }
1345
1345
  } catch (err) {
1346
- throw new (0, _chunkDCOUJZPLcjs.SettlementError)(
1346
+ throw new (0, _chunkGYM46G5Lcjs.SettlementError)(
1347
1347
  `permit2 settle: broadcast ${txHash} but couldn't confirm it (${shorten2(err instanceof Error ? err.message : String(err))}).`,
1348
1348
  { cause: err }
1349
1349
  );
@@ -1441,7 +1441,7 @@ function shorten3(msg) {
1441
1441
  function randomPermit2Nonce2() {
1442
1442
  const g = globalThis.crypto;
1443
1443
  if (!_optionalChain([g, 'optionalAccess', _9 => _9.getRandomValues])) {
1444
- throw new (0, _chunkDCOUJZPLcjs.UnsupportedSchemeError)(
1444
+ throw new (0, _chunkGYM46G5Lcjs.UnsupportedSchemeError)(
1445
1445
  "this runtime lacks Web Crypto (globalThis.crypto.getRandomValues); the upto rail needs a CSPRNG nonce."
1446
1446
  );
1447
1447
  }
@@ -1458,13 +1458,13 @@ async function payUptoEvm(input) {
1458
1458
  code = void 0;
1459
1459
  }
1460
1460
  if (code && code !== "0x") {
1461
- throw new (0, _chunkDCOUJZPLcjs.UnsupportedSchemeError)(
1461
+ throw new (0, _chunkGYM46G5Lcjs.UnsupportedSchemeError)(
1462
1462
  `upto buyer rail requires an EOA signer; ${account.address} is a contract / EIP-1271 / EIP-7702-delegated account. Pay via onchain-proof.`
1463
1463
  );
1464
1464
  }
1465
1465
  const facilitatorAddress = _optionalChain([accept, 'access', _10 => _10.extra, 'optionalAccess', _11 => _11.facilitatorAddress]);
1466
1466
  if (typeof facilitatorAddress !== "string" || facilitatorAddress.length === 0) {
1467
- throw new (0, _chunkDCOUJZPLcjs.UnsupportedSchemeError)(
1467
+ throw new (0, _chunkGYM46G5Lcjs.UnsupportedSchemeError)(
1468
1468
  `upto: the rail carries no extra.facilitatorAddress to bind into witness.facilitator \u2014 refusing to sign.`
1469
1469
  );
1470
1470
  }
@@ -1685,7 +1685,7 @@ async function verifyAndSettleUptoEvm(input) {
1685
1685
  args: settleArgs
1686
1686
  });
1687
1687
  } catch (err) {
1688
- throw new (0, _chunkDCOUJZPLcjs.SettlementError)(
1688
+ throw new (0, _chunkGYM46G5Lcjs.SettlementError)(
1689
1689
  `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.`,
1690
1690
  { cause: err }
1691
1691
  );
@@ -1697,7 +1697,7 @@ async function verifyAndSettleUptoEvm(input) {
1697
1697
  return { ok: false, error: "tx_reverted", detail: `Settlement tx ${txHash} reverted on-chain.` };
1698
1698
  }
1699
1699
  } catch (err) {
1700
- throw new (0, _chunkDCOUJZPLcjs.SettlementError)(
1700
+ throw new (0, _chunkGYM46G5Lcjs.SettlementError)(
1701
1701
  `upto settle: broadcast ${txHash} but couldn't confirm it (${shorten3(err instanceof Error ? err.message : String(err))}).`,
1702
1702
  { cause: err }
1703
1703
  );
@@ -1780,6 +1780,37 @@ function buildReceiptExtension(bundle) {
1780
1780
  if (bundle.attestation) info.receipt = bundle.attestation;
1781
1781
  return { [EXT_OFFER_RECEIPT]: { info } };
1782
1782
  }
1783
+ var EXT_PAYMENT_IDENTIFIER = "payment-identifier";
1784
+ var PAYMENT_ID_MIN = 16;
1785
+ var PAYMENT_ID_MAX = 128;
1786
+ var PAYMENT_ID_RE = /^[A-Za-z0-9_-]+$/;
1787
+ function buildPaymentIdentifierAdvertisement() {
1788
+ return {
1789
+ [EXT_PAYMENT_IDENTIFIER]: {
1790
+ info: { required: false },
1791
+ schema: { properties: { id: { type: "string", minLength: PAYMENT_ID_MIN, maxLength: PAYMENT_ID_MAX } } }
1792
+ }
1793
+ };
1794
+ }
1795
+ function readPaymentIdentifier(payload) {
1796
+ if (typeof payload !== "object" || payload === null) return null;
1797
+ const ext = payload.extensions;
1798
+ if (typeof ext !== "object" || ext === null) return null;
1799
+ const block = ext[EXT_PAYMENT_IDENTIFIER];
1800
+ if (typeof block !== "object" || block === null) return null;
1801
+ const info = block.info;
1802
+ if (typeof info !== "object" || info === null) return null;
1803
+ const id = info.id;
1804
+ if (id === void 0) return null;
1805
+ if (typeof id !== "string") return { invalid: "payment-identifier id must be a string" };
1806
+ if (id.length < PAYMENT_ID_MIN || id.length > PAYMENT_ID_MAX) {
1807
+ return { invalid: `payment-identifier id must be ${PAYMENT_ID_MIN}\u2013${PAYMENT_ID_MAX} chars (got ${id.length})` };
1808
+ }
1809
+ if (!PAYMENT_ID_RE.test(id)) {
1810
+ return { invalid: "payment-identifier id must match [A-Za-z0-9_-]" };
1811
+ }
1812
+ return id;
1813
+ }
1783
1814
  function buildSignatureHeader(signature) {
1784
1815
  return toBase64Json(signature);
1785
1816
  }
@@ -1806,7 +1837,10 @@ function parseReceipt(response) {
1806
1837
  const headerValue = _nullishCoalesce(response.headers.get(HEADER_RESPONSE), () => ( response.headers.get(HEADER_RESPONSE_V1)));
1807
1838
  if (!headerValue) return null;
1808
1839
  const parsed = fromBase64Json(headerValue);
1809
- return isValidReceipt(parsed) ? parsed : null;
1840
+ if (!isValidReceipt(parsed)) return null;
1841
+ const r = parsed;
1842
+ if (typeof r.transaction !== "string" && typeof r.txHash === "string") r.transaction = r.txHash;
1843
+ return r;
1810
1844
  }
1811
1845
  function parseReceiptExtension(response) {
1812
1846
  const headerValue = _nullishCoalesce(response.headers.get(HEADER_RESPONSE), () => ( response.headers.get(HEADER_RESPONSE_V1)));
@@ -1836,7 +1870,8 @@ function parseSettleResponse(response) {
1836
1870
  if (!parsed || typeof parsed !== "object" || typeof parsed.success !== "boolean") return null;
1837
1871
  return {
1838
1872
  success: parsed.success,
1839
- ...typeof parsed.transaction === "string" ? { transaction: parsed.transaction } : {},
1873
+ // Tolerate the legacy v1 `txHash` alias for `transaction` (mirrors isValidReceipt/parseReceipt).
1874
+ ...typeof parsed.transaction === "string" ? { transaction: parsed.transaction } : typeof parsed.txHash === "string" ? { transaction: parsed.txHash } : {},
1840
1875
  ...typeof parsed.network === "string" ? { network: parsed.network } : {},
1841
1876
  ...typeof parsed.payer === "string" ? { payer: parsed.payer } : {},
1842
1877
  ...typeof parsed.errorReason === "string" ? { errorReason: parsed.errorReason } : {},
@@ -1855,6 +1890,14 @@ function parseSignatureObject(parsed) {
1855
1890
  if (!payload || typeof payload.txHash !== "string" || typeof payload.nonce !== "string") {
1856
1891
  return null;
1857
1892
  }
1893
+ if (!accepted) {
1894
+ const synthesized = {
1895
+ scheme: "onchain-proof",
1896
+ ...typeof v.network === "string" ? { network: v.network } : {},
1897
+ ...typeof v.asset === "string" ? { asset: v.asset } : {}
1898
+ };
1899
+ return { ...v, accepted: synthesized, payload };
1900
+ }
1858
1901
  return parsed;
1859
1902
  }
1860
1903
  function parseSignatureHeader(value) {
@@ -1994,7 +2037,11 @@ var evmDriver = {
1994
2037
  resolve(opts) {
1995
2038
  if (typeof opts.chain === "string" && /^(solana|ton|stellar)/.test(opts.chain)) return null;
1996
2039
  if (typeof opts.chain === "string") {
1997
- return makeEvmNetwork(resolveChain(opts.chain, opts.rpcUrl));
2040
+ try {
2041
+ return makeEvmNetwork(resolveChain(opts.chain, opts.rpcUrl));
2042
+ } catch (err) {
2043
+ throw new (0, _chunkGYM46G5Lcjs.UnsupportedNetworkError)(err instanceof Error ? err.message : String(err), { cause: err });
2044
+ }
1998
2045
  }
1999
2046
  let resolved;
2000
2047
  try {
@@ -2027,20 +2074,25 @@ function makeEvmNetwork(resolved) {
2027
2074
  const info = resolved.tokens[token.toUpperCase()];
2028
2075
  if (!info) {
2029
2076
  const known = Object.keys(resolved.tokens).join(", ") || "(none built in)";
2030
- throw new (0, _chunkDCOUJZPLcjs.UnknownTokenError)(
2077
+ throw new (0, _chunkGYM46G5Lcjs.UnknownTokenError)(
2031
2078
  `token "${token}" isn't built in for ${resolved.chain.name} (known: ${known}). Pass { address, decimals } instead, or use 'native'.`
2032
2079
  );
2033
2080
  }
2034
2081
  return { asset: info.address, decimals: info.decimals, symbol: info.symbol };
2035
2082
  }
2036
- _chunkDCOUJZPLcjs.rejectForeignToken.call(void 0, token, "evm", network);
2083
+ _chunkGYM46G5Lcjs.rejectForeignToken.call(void 0, token, "evm", network);
2037
2084
  if (!("address" in token)) {
2038
- throw new (0, _chunkDCOUJZPLcjs.WrongFamilyError)(
2085
+ throw new (0, _chunkGYM46G5Lcjs.WrongFamilyError)(
2039
2086
  `chain ${network} is EVM; a custom token must be { address, decimals }.`
2040
2087
  );
2041
2088
  }
2089
+ if (!_viem.isAddress.call(void 0, token.address)) {
2090
+ throw new (0, _chunkGYM46G5Lcjs.WrongFamilyError)(
2091
+ `chain ${network} is EVM, but token address "${token.address}" is not a valid 0x address.`
2092
+ );
2093
+ }
2042
2094
  return {
2043
- asset: token.address,
2095
+ asset: _viem.getAddress.call(void 0, token.address),
2044
2096
  decimals: token.decimals,
2045
2097
  ...token.symbol ? { symbol: token.symbol } : {}
2046
2098
  };
@@ -2067,20 +2119,20 @@ function makeEvmNetwork(resolved) {
2067
2119
  },
2068
2120
  assertValidPayTo(payTo) {
2069
2121
  if (!_viem.isAddress.call(void 0, payTo)) {
2070
- throw new (0, _chunkDCOUJZPLcjs.WrongFamilyError)(
2122
+ throw new (0, _chunkGYM46G5Lcjs.WrongFamilyError)(
2071
2123
  `chain ${network} is EVM, but payTo "${payTo}" is not a valid 0x address.`
2072
2124
  );
2073
2125
  }
2074
2126
  },
2075
2127
  bindWallet(wallet) {
2076
2128
  if (typeof wallet !== "object" || wallet === null) {
2077
- throw new (0, _chunkDCOUJZPLcjs.WrongFamilyError)(
2129
+ throw new (0, _chunkGYM46G5Lcjs.WrongFamilyError)(
2078
2130
  `chain ${network} is EVM; wallet must be { key } (0x\u2026 hex) or { walletClient }.`
2079
2131
  );
2080
2132
  }
2081
- _chunkDCOUJZPLcjs.assertNoLegacyWalletKey.call(void 0, wallet, "EVM");
2133
+ _chunkGYM46G5Lcjs.assertNoLegacyWalletKey.call(void 0, wallet, "EVM");
2082
2134
  if (!("key" in wallet) && !("walletClient" in wallet)) {
2083
- throw new (0, _chunkDCOUJZPLcjs.WrongFamilyError)(
2135
+ throw new (0, _chunkGYM46G5Lcjs.WrongFamilyError)(
2084
2136
  `chain ${network} is EVM; wallet must be { key } (0x\u2026 hex) or { walletClient }.`
2085
2137
  );
2086
2138
  }
@@ -2097,12 +2149,12 @@ function makeEvmNetwork(resolved) {
2097
2149
  });
2098
2150
  } catch (err) {
2099
2151
  if (isViemInsufficientFunds(err)) {
2100
- throw new (0, _chunkDCOUJZPLcjs.InsufficientFundsError)(
2152
+ throw new (0, _chunkGYM46G5Lcjs.InsufficientFundsError)(
2101
2153
  err instanceof Error ? err.message : "Insufficient funds for payment.",
2102
2154
  { cause: err }
2103
2155
  );
2104
2156
  }
2105
- throw _nullishCoalesce(_chunkDCOUJZPLcjs.toInsufficientFundsError.call(void 0, err), () => ( err));
2157
+ throw _nullishCoalesce(_chunkGYM46G5Lcjs.toInsufficientFundsError.call(void 0, err), () => ( err));
2106
2158
  }
2107
2159
  },
2108
2160
  async confirm(ref, minConfirmations) {
@@ -2113,7 +2165,7 @@ function makeEvmNetwork(resolved) {
2113
2165
  });
2114
2166
  return { height: receipt.blockNumber.toString() };
2115
2167
  } catch (err) {
2116
- throw new (0, _chunkDCOUJZPLcjs.ConfirmationTimeoutError)(
2168
+ throw new (0, _chunkGYM46G5Lcjs.ConfirmationTimeoutError)(
2117
2169
  `EVM tx ${ref} did not reach ${minConfirmations} confirmation(s) in time.`,
2118
2170
  { cause: err }
2119
2171
  );
@@ -2121,10 +2173,10 @@ function makeEvmNetwork(resolved) {
2121
2173
  },
2122
2174
  async estimateCost(accept) {
2123
2175
  const { decimals, symbol } = resolved.chain.nativeCurrency;
2124
- if (accept.scheme === "exact") {
2125
- const m = accept.extra.assetTransferMethod;
2126
- const permit2 = m === "permit2" || m === "permit2-exact";
2127
- return _chunkDCOUJZPLcjs.nativeCost.call(void 0, {
2176
+ if (accept.scheme === "exact" || accept.scheme === "upto") {
2177
+ const m = _optionalChain([accept, 'access', _19 => _19.extra, 'optionalAccess', _20 => _20.assetTransferMethod]);
2178
+ const permit2 = m === "permit2" || m === "permit2-exact" || m === "permit2-upto";
2179
+ return _chunkGYM46G5Lcjs.nativeCost.call(void 0, {
2128
2180
  symbol,
2129
2181
  decimals,
2130
2182
  fee: 0n,
@@ -2135,7 +2187,7 @@ function makeEvmNetwork(resolved) {
2135
2187
  const gasLimit = accept.asset === "native" ? 21000n : 65000n;
2136
2188
  try {
2137
2189
  const gasPrice = await publicClient.getGasPrice();
2138
- return _chunkDCOUJZPLcjs.nativeCost.call(void 0, {
2190
+ return _chunkGYM46G5Lcjs.nativeCost.call(void 0, {
2139
2191
  symbol,
2140
2192
  decimals,
2141
2193
  fee: gasPrice * gasLimit,
@@ -2144,7 +2196,7 @@ function makeEvmNetwork(resolved) {
2144
2196
  });
2145
2197
  } catch (e23) {
2146
2198
  const gasPrice = 5000000000n;
2147
- return _chunkDCOUJZPLcjs.nativeCost.call(void 0, {
2199
+ return _chunkGYM46G5Lcjs.nativeCost.call(void 0, {
2148
2200
  symbol,
2149
2201
  decimals,
2150
2202
  fee: gasPrice * gasLimit,
@@ -2329,9 +2381,9 @@ var loaders = {
2329
2381
  solana: async () => {
2330
2382
  let mod;
2331
2383
  try {
2332
- mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./solana-RQNXFCZO.cjs")));
2384
+ mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./solana-N3UCNCYE.cjs")));
2333
2385
  } catch (cause) {
2334
- throw new (0, _chunkDCOUJZPLcjs.MissingDriverError)(
2386
+ throw new (0, _chunkGYM46G5Lcjs.MissingDriverError)(
2335
2387
  `Solana selected, but its packages aren't installed. Run: npm install @solana/web3.js @solana/spl-token bs58`,
2336
2388
  { cause }
2337
2389
  );
@@ -2341,9 +2393,9 @@ var loaders = {
2341
2393
  ton: async () => {
2342
2394
  let mod;
2343
2395
  try {
2344
- mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./ton-D7YN6BGR.cjs")));
2396
+ mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./ton-5HDVOTMR.cjs")));
2345
2397
  } catch (cause) {
2346
- throw new (0, _chunkDCOUJZPLcjs.MissingDriverError)(
2398
+ throw new (0, _chunkGYM46G5Lcjs.MissingDriverError)(
2347
2399
  `TON selected, but its packages aren't installed. Run: npm install @ton/ton @ton/core @ton/crypto`,
2348
2400
  { cause }
2349
2401
  );
@@ -2353,9 +2405,9 @@ var loaders = {
2353
2405
  stellar: async () => {
2354
2406
  let mod;
2355
2407
  try {
2356
- mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./stellar-OK2HW5PZ.cjs")));
2408
+ mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./stellar-Y3SQN7S5.cjs")));
2357
2409
  } catch (cause) {
2358
- throw new (0, _chunkDCOUJZPLcjs.MissingDriverError)(
2410
+ throw new (0, _chunkGYM46G5Lcjs.MissingDriverError)(
2359
2411
  `Stellar selected, but its package isn't installed. Run: npm install @stellar/stellar-sdk`,
2360
2412
  { cause }
2361
2413
  );
@@ -2365,9 +2417,9 @@ var loaders = {
2365
2417
  xrpl: async () => {
2366
2418
  let mod;
2367
2419
  try {
2368
- mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./xrpl-5NHY3NEL.cjs")));
2420
+ mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./xrpl-5TYDLQFS.cjs")));
2369
2421
  } catch (cause) {
2370
- throw new (0, _chunkDCOUJZPLcjs.MissingDriverError)(
2422
+ throw new (0, _chunkGYM46G5Lcjs.MissingDriverError)(
2371
2423
  `XRPL selected, but its package isn't installed. Run: npm install xrpl`,
2372
2424
  { cause }
2373
2425
  );
@@ -2377,9 +2429,9 @@ var loaders = {
2377
2429
  tron: async () => {
2378
2430
  let mod;
2379
2431
  try {
2380
- mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./tron-WZFU57NX.cjs")));
2432
+ mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./tron-TX2B4N2A.cjs")));
2381
2433
  } catch (cause) {
2382
- throw new (0, _chunkDCOUJZPLcjs.MissingDriverError)(
2434
+ throw new (0, _chunkGYM46G5Lcjs.MissingDriverError)(
2383
2435
  `Tron selected, but its package isn't installed. Run: npm install tronweb`,
2384
2436
  { cause }
2385
2437
  );
@@ -2389,9 +2441,9 @@ var loaders = {
2389
2441
  sui: async () => {
2390
2442
  let mod;
2391
2443
  try {
2392
- mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./sui-SVFBJFW5.cjs")));
2444
+ mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./sui-4AL4E6XU.cjs")));
2393
2445
  } catch (cause) {
2394
- throw new (0, _chunkDCOUJZPLcjs.MissingDriverError)(
2446
+ throw new (0, _chunkGYM46G5Lcjs.MissingDriverError)(
2395
2447
  `Sui selected, but its package isn't installed. Run: npm install @mysten/sui`,
2396
2448
  { cause }
2397
2449
  );
@@ -2401,9 +2453,9 @@ var loaders = {
2401
2453
  near: async () => {
2402
2454
  let mod;
2403
2455
  try {
2404
- mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./near-UDPFA6SV.cjs")));
2456
+ mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./near-YNNK7RW7.cjs")));
2405
2457
  } catch (cause) {
2406
- throw new (0, _chunkDCOUJZPLcjs.MissingDriverError)(
2458
+ throw new (0, _chunkGYM46G5Lcjs.MissingDriverError)(
2407
2459
  `NEAR selected, but its package isn't installed. Run: npm install near-api-js`,
2408
2460
  { cause }
2409
2461
  );
@@ -2413,9 +2465,9 @@ var loaders = {
2413
2465
  aptos: async () => {
2414
2466
  let mod;
2415
2467
  try {
2416
- mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./aptos-65UX7GKA.cjs")));
2468
+ mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./aptos-LFTQGBBK.cjs")));
2417
2469
  } catch (cause) {
2418
- throw new (0, _chunkDCOUJZPLcjs.MissingDriverError)(
2470
+ throw new (0, _chunkGYM46G5Lcjs.MissingDriverError)(
2419
2471
  `Aptos selected, but its package isn't installed. Run: npm install @aptos-labs/ts-sdk`,
2420
2472
  { cause }
2421
2473
  );
@@ -2425,9 +2477,9 @@ var loaders = {
2425
2477
  algorand: async () => {
2426
2478
  let mod;
2427
2479
  try {
2428
- mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./algorand-AQK5EAUF.cjs")));
2480
+ mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./algorand-QU6G2DQZ.cjs")));
2429
2481
  } catch (cause) {
2430
- throw new (0, _chunkDCOUJZPLcjs.MissingDriverError)(
2482
+ throw new (0, _chunkGYM46G5Lcjs.MissingDriverError)(
2431
2483
  `Algorand selected, but its package isn't installed. Run: npm install algosdk`,
2432
2484
  { cause }
2433
2485
  );
@@ -2788,7 +2840,7 @@ async function register402Index(input) {
2788
2840
  if (res.ok) {
2789
2841
  const body = await res.json().catch(() => ({}));
2790
2842
  const msg = typeof body.message === "string" && body.message.length > 0 ? body.message : void 0;
2791
- const live = _optionalChain([body, 'access', _19 => _19.service, 'optionalAccess', _20 => _20.status]) === "active";
2843
+ const live = _optionalChain([body, 'access', _21 => _21.service, 'optionalAccess', _22 => _22.status]) === "active";
2792
2844
  return {
2793
2845
  source: "402index",
2794
2846
  ok: true,
@@ -2925,11 +2977,11 @@ async function readSiwxInfo(res) {
2925
2977
  try {
2926
2978
  const body = await res.json();
2927
2979
  const ext = body.extensions;
2928
- const siwx = _optionalChain([ext, 'optionalAccess', _21 => _21["sign-in-with-x"]]);
2929
- const info = _nullishCoalesce(_optionalChain([siwx, 'optionalAccess', _22 => _22.info]), () => ( siwx));
2930
- if (info && info.chainId == null && Array.isArray(_optionalChain([siwx, 'optionalAccess', _23 => _23.supportedChains]))) {
2980
+ const siwx = _optionalChain([ext, 'optionalAccess', _23 => _23["sign-in-with-x"]]);
2981
+ const info = _nullishCoalesce(_optionalChain([siwx, 'optionalAccess', _24 => _24.info]), () => ( siwx));
2982
+ if (info && info.chainId == null && Array.isArray(_optionalChain([siwx, 'optionalAccess', _25 => _25.supportedChains]))) {
2931
2983
  const evm = siwx.supportedChains.find(
2932
- (c) => typeof _optionalChain([c, 'optionalAccess', _24 => _24.chainId]) === "string" && c.chainId.startsWith("eip155:")
2984
+ (c) => typeof _optionalChain([c, 'optionalAccess', _26 => _26.chainId]) === "string" && c.chainId.startsWith("eip155:")
2933
2985
  );
2934
2986
  if (evm && typeof evm.chainId === "string") info.chainId = evm.chainId;
2935
2987
  }
@@ -3071,7 +3123,7 @@ function encodeBase642(str) {
3071
3123
  }
3072
3124
 
3073
3125
  // src/policy.ts
3074
- var DENOM_PRECISION = _chunkDCOUJZPLcjs.MAX_DECIMALS;
3126
+ var DENOM_PRECISION = _chunkGYM46G5Lcjs.MAX_DECIMALS;
3075
3127
  var BUILTIN_DENOMS = {
3076
3128
  USDC: "USD",
3077
3129
  USDT: "USD",
@@ -3085,7 +3137,7 @@ var BUILTIN_DENOMS = {
3085
3137
  function denomOf(symbol, asset, policy) {
3086
3138
  if (asset === "native") return void 0;
3087
3139
  const norm = (v) => typeof v === "string" && v.trim() !== "" ? v.trim().toUpperCase() : void 0;
3088
- const override = _optionalChain([policy, 'optionalAccess', _25 => _25.denomFor]);
3140
+ const override = _optionalChain([policy, 'optionalAccess', _27 => _27.denomFor]);
3089
3141
  if (override && typeof override === "object") {
3090
3142
  if (asset && asset in override) {
3091
3143
  const d = norm(override[asset]);
@@ -3186,7 +3238,7 @@ function evaluatePolicy(intent, policy, spentForAssetBase, ctx) {
3186
3238
  }
3187
3239
  }
3188
3240
  if (policy.maxAmount !== void 0) {
3189
- const cap = _chunkDCOUJZPLcjs.floorUnits.call(void 0, policy.maxAmount, intent.decimals);
3241
+ const cap = _chunkGYM46G5Lcjs.floorUnits.call(void 0, policy.maxAmount, intent.decimals);
3190
3242
  if (intent.amountBase > cap) {
3191
3243
  return deny(
3192
3244
  "MAX_AMOUNT",
@@ -3195,7 +3247,7 @@ function evaluatePolicy(intent, policy, spentForAssetBase, ctx) {
3195
3247
  }
3196
3248
  }
3197
3249
  if (policy.maxTotal !== void 0) {
3198
- const cap = _chunkDCOUJZPLcjs.floorUnits.call(void 0, policy.maxTotal, intent.decimals);
3250
+ const cap = _chunkGYM46G5Lcjs.floorUnits.call(void 0, policy.maxTotal, intent.decimals);
3199
3251
  if (spentForAssetBase + intent.amountBase > cap) {
3200
3252
  return deny(
3201
3253
  "MAX_TOTAL",
@@ -3214,7 +3266,7 @@ function evaluatePolicy(intent, policy, spentForAssetBase, ctx) {
3214
3266
  `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).`
3215
3267
  );
3216
3268
  }
3217
- const capScaled = _chunkDCOUJZPLcjs.floorUnits.call(void 0, capStr, DENOM_PRECISION);
3269
+ const capScaled = _chunkGYM46G5Lcjs.floorUnits.call(void 0, capStr, DENOM_PRECISION);
3218
3270
  if ((_nullishCoalesce(ctx.spentInDenomScaled, () => ( 0n))) + thisScaled > capScaled) {
3219
3271
  return deny(
3220
3272
  "MAX_TOTAL_DENOM",
@@ -3232,7 +3284,7 @@ function evaluatePolicy(intent, policy, spentForAssetBase, ctx) {
3232
3284
  }
3233
3285
  }
3234
3286
  if (ctx && policy.windowTotal !== void 0 && policy.windowSeconds !== void 0) {
3235
- const cap = _chunkDCOUJZPLcjs.floorUnits.call(void 0, policy.windowTotal, intent.decimals);
3287
+ const cap = _chunkGYM46G5Lcjs.floorUnits.call(void 0, policy.windowTotal, intent.decimals);
3236
3288
  if (ctx.spentInWindowBase + intent.amountBase > cap) {
3237
3289
  return deny(
3238
3290
  "WINDOW_TOTAL",
@@ -3286,7 +3338,7 @@ var SpendLedger = (_class = class {
3286
3338
  } catch (e30) {
3287
3339
  seed = [];
3288
3340
  }
3289
- for (const r of seed) this.ingest(r, _nullishCoalesce(_optionalChain([r, 'optionalAccess', _26 => _26.decimals]), () => ( 0)), _optionalChain([r, 'optionalAccess', _27 => _27.denom]));
3341
+ for (const r of seed) this.ingest(r, _nullishCoalesce(_optionalChain([r, 'optionalAccess', _28 => _28.decimals]), () => ( 0)), _optionalChain([r, 'optionalAccess', _29 => _29.denom]));
3290
3342
  }
3291
3343
  }
3292
3344
  /**
@@ -3298,7 +3350,7 @@ var SpendLedger = (_class = class {
3298
3350
  * read or the constructor.
3299
3351
  */
3300
3352
  isTallyable(r, decimals) {
3301
- return !!r && typeof r.amountBase === "string" && /^\d+$/.test(r.amountBase) && Number.isInteger(decimals) && decimals >= 0 && decimals <= _chunkDCOUJZPLcjs.MAX_DECIMALS;
3353
+ return !!r && typeof r.amountBase === "string" && /^\d+$/.test(r.amountBase) && Number.isInteger(decimals) && decimals >= 0 && decimals <= _chunkGYM46G5Lcjs.MAX_DECIMALS;
3302
3354
  }
3303
3355
  /** Apply a record to the in-memory tallies (records + per-asset bucket + denom total).
3304
3356
  * Shared by {@link record} and constructor hydration; does NOT persist. Returns the
@@ -3348,7 +3400,7 @@ var SpendLedger = (_class = class {
3348
3400
  }
3349
3401
  /** Running total (base units) already spent on this (network, asset). */
3350
3402
  totalFor(network, asset) {
3351
- return _nullishCoalesce(_optionalChain([this, 'access', _28 => _28.buckets, 'access', _29 => _29.get, 'call', _30 => _30(keyFor(network, asset)), 'optionalAccess', _31 => _31.total]), () => ( 0n));
3403
+ return _nullishCoalesce(_optionalChain([this, 'access', _30 => _30.buckets, 'access', _31 => _31.get, 'call', _32 => _32(keyFor(network, asset)), 'optionalAccess', _33 => _33.total]), () => ( 0n));
3352
3404
  }
3353
3405
  /**
3354
3406
  * Running grand total for a DENOMINATION, scaled to {@link DENOM_PRECISION} (so
@@ -3435,14 +3487,14 @@ var SpendLedger = (_class = class {
3435
3487
  symbol: b.symbol,
3436
3488
  decimals: b.decimals,
3437
3489
  totalBase: b.total.toString(),
3438
- totalFormatted: _chunkDCOUJZPLcjs.formatUnits.call(void 0, b.total, b.decimals),
3490
+ totalFormatted: _chunkGYM46G5Lcjs.formatUnits.call(void 0, b.total, b.decimals),
3439
3491
  count: b.count
3440
3492
  })),
3441
3493
  byDenom: [...this.denomTotals.entries()].map(([denom, scaled]) => ({
3442
3494
  denom,
3443
3495
  totalScaled: scaled.toString(),
3444
- totalFormatted: _chunkDCOUJZPLcjs.formatUnits.call(void 0, scaled, DENOM_PRECISION),
3445
- count: this.records.filter((r) => _optionalChain([r, 'access', _32 => _32.denom, 'optionalAccess', _33 => _33.toUpperCase, 'call', _34 => _34()]) === denom).length
3496
+ totalFormatted: _chunkGYM46G5Lcjs.formatUnits.call(void 0, scaled, DENOM_PRECISION),
3497
+ count: this.records.filter((r) => _optionalChain([r, 'access', _34 => _34.denom, 'optionalAccess', _35 => _35.toUpperCase, 'call', _36 => _36()]) === denom).length
3446
3498
  })),
3447
3499
  records: [...this.records]
3448
3500
  };
@@ -3678,17 +3730,17 @@ var PipRailClient = (_class2 = class {
3678
3730
  * {@link ReceiptVerification}).
3679
3731
  */
3680
3732
  static async verifyReceipt(receipt, opts) {
3681
- const r = _optionalChain([receipt, 'optionalAccess', _35 => _35.receipt]);
3733
+ const r = _optionalChain([receipt, 'optionalAccess', _37 => _37.receipt]);
3682
3734
  if (!r || typeof r !== "object") {
3683
3735
  return { ok: false, onChain: { payTo: "", asset: "", amount: "", payer: "" }, matchesClaims: false, ageSeconds: 0, error: "tx_not_found" };
3684
3736
  }
3685
3737
  const claimed = { payTo: _nullishCoalesce(r.payTo, () => ( "")), asset: _nullishCoalesce(r.asset, () => ( "")), amount: _nullishCoalesce(r.amount, () => ( "")), payer: _nullishCoalesce(r.payer, () => ( "")) };
3686
3738
  const ageSeconds = receiptAgeSeconds(r.verifiedAt);
3687
3739
  try {
3688
- const chain = chainSelectorForNetwork(r.network, _optionalChain([opts, 'optionalAccess', _36 => _36.rpcUrl]));
3740
+ const chain = chainSelectorForNetwork(r.network, _optionalChain([opts, 'optionalAccess', _38 => _38.rpcUrl]));
3689
3741
  const net = await resolveNetwork2({
3690
3742
  chain,
3691
- ..._optionalChain([opts, 'optionalAccess', _37 => _37.rpcUrl]) ? { rpcUrl: opts.rpcUrl } : {}
3743
+ ..._optionalChain([opts, 'optionalAccess', _39 => _39.rpcUrl]) ? { rpcUrl: opts.rpcUrl } : {}
3692
3744
  });
3693
3745
  const accept = {
3694
3746
  scheme: "onchain-proof",
@@ -3735,7 +3787,7 @@ var PipRailClient = (_class2 = class {
3735
3787
  * no chain libs. The JWS format defers to R3 (`{ ok:false, reason:'jws-not-loaded' }`).
3736
3788
  */
3737
3789
  static async verifyAttestation(receipt) {
3738
- const att = _optionalChain([receipt, 'optionalAccess', _38 => _38.attestation]);
3790
+ const att = _optionalChain([receipt, 'optionalAccess', _40 => _40.attestation]);
3739
3791
  if (!att || typeof att !== "object" || typeof att.signature !== "string") {
3740
3792
  return { ok: false, reason: "no-attestation" };
3741
3793
  }
@@ -3746,7 +3798,7 @@ var PipRailClient = (_class2 = class {
3746
3798
  if (!r || typeof r !== "object") return { ok: false, reason: "no-receipt" };
3747
3799
  const payload = _nullishCoalesce(att.payload, () => ( {}));
3748
3800
  const network = typeof payload.network === "string" ? payload.network : r.network;
3749
- const resourceUrl = typeof payload.resourceUrl === "string" ? payload.resourceUrl : _nullishCoalesce(_optionalChain([receipt, 'access', _39 => _39.resource, 'optionalAccess', _40 => _40.url]), () => ( ""));
3801
+ const resourceUrl = typeof payload.resourceUrl === "string" ? payload.resourceUrl : _nullishCoalesce(_optionalChain([receipt, 'access', _41 => _41.resource, 'optionalAccess', _42 => _42.url]), () => ( ""));
3750
3802
  const payer = typeof payload.payer === "string" ? payload.payer : r.payer;
3751
3803
  const issuedAt = typeof payload.issuedAt === "number" ? payload.issuedAt : receiptIssuedAtSeconds(r.verifiedAt);
3752
3804
  const transaction = typeof payload.transaction === "string" ? payload.transaction : _nullishCoalesce(r.transaction, () => ( ""));
@@ -3792,7 +3844,7 @@ var PipRailClient = (_class2 = class {
3792
3844
  * as-is) or a plain object (serialised as JSON).
3793
3845
  */
3794
3846
  post(url, body, init) {
3795
- const headers = new Headers(_optionalChain([init, 'optionalAccess', _41 => _41.headers]));
3847
+ const headers = new Headers(_optionalChain([init, 'optionalAccess', _43 => _43.headers]));
3796
3848
  let payload;
3797
3849
  if (body === void 0 || body === null) {
3798
3850
  payload = void 0;
@@ -3823,7 +3875,7 @@ var PipRailClient = (_class2 = class {
3823
3875
  * "0.05 USDC on Base, within budget → pay it." No funds move.
3824
3876
  */
3825
3877
  async quote(url, init) {
3826
- const res = await fetch(url, { ..._nullishCoalesce(init, () => ( {})), method: _nullishCoalesce(_optionalChain([init, 'optionalAccess', _42 => _42.method]), () => ( "GET")) });
3878
+ const res = await fetch(url, { ..._nullishCoalesce(init, () => ( {})), method: _nullishCoalesce(_optionalChain([init, 'optionalAccess', _44 => _44.method]), () => ( "GET")) });
3827
3879
  if (res.status !== 402) return null;
3828
3880
  const { quote } = await this.resolveChallenge(url, res, this.resolveSchemes());
3829
3881
  return quote;
@@ -3842,14 +3894,14 @@ var PipRailClient = (_class2 = class {
3842
3894
  * on Tron, where a USD₮ transfer can cost real TRX.
3843
3895
  */
3844
3896
  async estimateCost(url, init) {
3845
- const res = await fetch(url, { ..._nullishCoalesce(init, () => ( {})), method: _nullishCoalesce(_optionalChain([init, 'optionalAccess', _43 => _43.method]), () => ( "GET")) });
3897
+ const res = await fetch(url, { ..._nullishCoalesce(init, () => ( {})), method: _nullishCoalesce(_optionalChain([init, 'optionalAccess', _45 => _45.method]), () => ( "GET")) });
3846
3898
  if (res.status !== 402) return null;
3847
3899
  try {
3848
3900
  const { net, accept, quote } = await this.resolveChallenge(url, res, this.resolveSchemes());
3849
3901
  const cost = await net.estimateCost(accept);
3850
3902
  return { quote, cost };
3851
3903
  } catch (err) {
3852
- if (err instanceof _chunkDCOUJZPLcjs.InvalidEnvelopeError) return null;
3904
+ if (err instanceof _chunkGYM46G5Lcjs.InvalidEnvelopeError) return null;
3853
3905
  throw err;
3854
3906
  }
3855
3907
  }
@@ -3880,8 +3932,8 @@ var PipRailClient = (_class2 = class {
3880
3932
  return {
3881
3933
  session: {
3882
3934
  start,
3883
- expiresAt: _optionalChain([view, 'optionalAccess', _44 => _44.expiresAt]) != null ? new Date(view.expiresAt).toISOString() : null,
3884
- secondsRemaining: _nullishCoalesce(_optionalChain([view, 'optionalAccess', _45 => _45.secondsRemaining]), () => ( null))
3935
+ expiresAt: _optionalChain([view, 'optionalAccess', _46 => _46.expiresAt]) != null ? new Date(view.expiresAt).toISOString() : null,
3936
+ secondsRemaining: _nullishCoalesce(_optionalChain([view, 'optionalAccess', _47 => _47.secondsRemaining]), () => ( null))
3885
3937
  },
3886
3938
  byAsset: this.remaining(),
3887
3939
  byDenom: this.denomRemaining(),
@@ -3896,19 +3948,19 @@ var PipRailClient = (_class2 = class {
3896
3948
  * price-converted figure (tokens grouped as one unit, each 1:1).
3897
3949
  */
3898
3950
  denomRemaining() {
3899
- const caps = _optionalChain([this, 'access', _46 => _46.opts, 'access', _47 => _47.policy, 'optionalAccess', _48 => _48.maxTotalPerDenom]);
3951
+ const caps = _optionalChain([this, 'access', _48 => _48.opts, 'access', _49 => _49.policy, 'optionalAccess', _50 => _50.maxTotalPerDenom]);
3900
3952
  if (!caps) return [];
3901
3953
  return Object.entries(caps).map(([rawDenom, capStr]) => {
3902
3954
  const denom = rawDenom.toUpperCase();
3903
3955
  const spentScaled = this.ledger.totalForDenom(denom);
3904
- const capScaled = _chunkDCOUJZPLcjs.floorUnits.call(void 0, capStr, DENOM_PRECISION);
3956
+ const capScaled = _chunkGYM46G5Lcjs.floorUnits.call(void 0, capStr, DENOM_PRECISION);
3905
3957
  const remainingScaled = capScaled > spentScaled ? capScaled - spentScaled : 0n;
3906
3958
  const fraction = capScaled === 0n ? spentScaled > 0n ? 1 : 0 : Number(spentScaled * 1000000n / capScaled) / 1e6;
3907
3959
  return {
3908
3960
  denom,
3909
- spentFormatted: _chunkDCOUJZPLcjs.formatUnits.call(void 0, spentScaled, DENOM_PRECISION),
3910
- capFormatted: _chunkDCOUJZPLcjs.formatUnits.call(void 0, capScaled, DENOM_PRECISION),
3911
- remainingFormatted: _chunkDCOUJZPLcjs.formatUnits.call(void 0, remainingScaled, DENOM_PRECISION),
3961
+ spentFormatted: _chunkGYM46G5Lcjs.formatUnits.call(void 0, spentScaled, DENOM_PRECISION),
3962
+ capFormatted: _chunkGYM46G5Lcjs.formatUnits.call(void 0, capScaled, DENOM_PRECISION),
3963
+ remainingFormatted: _chunkGYM46G5Lcjs.formatUnits.call(void 0, remainingScaled, DENOM_PRECISION),
3912
3964
  fraction
3913
3965
  };
3914
3966
  });
@@ -3919,11 +3971,11 @@ var PipRailClient = (_class2 = class {
3919
3971
  const policy = this.opts.policy;
3920
3972
  const settled = this.ledger.count();
3921
3973
  const out = { settled };
3922
- if (_optionalChain([policy, 'optionalAccess', _49 => _49.maxPayments]) !== void 0) {
3974
+ if (_optionalChain([policy, 'optionalAccess', _51 => _51.maxPayments]) !== void 0) {
3923
3975
  out.lifetimeCap = policy.maxPayments;
3924
3976
  out.lifetimeRemaining = Math.max(0, policy.maxPayments - settled);
3925
3977
  }
3926
- if (_optionalChain([policy, 'optionalAccess', _50 => _50.maxPaymentsPerWindow]) !== void 0 && policy.windowSeconds !== void 0) {
3978
+ if (_optionalChain([policy, 'optionalAccess', _52 => _52.maxPaymentsPerWindow]) !== void 0 && policy.windowSeconds !== void 0) {
3927
3979
  const windowSettled = this.ledger.countSince(Date.now() - policy.windowSeconds * 1e3);
3928
3980
  out.windowCap = policy.maxPaymentsPerWindow;
3929
3981
  out.windowSettled = windowSettled;
@@ -3939,7 +3991,7 @@ var PipRailClient = (_class2 = class {
3939
3991
  * never throws, never sums across tokens (no price oracle). PROCESS-SCOPED.
3940
3992
  */
3941
3993
  remaining() {
3942
- const maxTotal = _optionalChain([this, 'access', _51 => _51.opts, 'access', _52 => _52.policy, 'optionalAccess', _53 => _53.maxTotal]);
3994
+ const maxTotal = _optionalChain([this, 'access', _53 => _53.opts, 'access', _54 => _54.policy, 'optionalAccess', _55 => _55.maxTotal]);
3943
3995
  return this.ledger.assetBuckets().map((b) => {
3944
3996
  const base2 = {
3945
3997
  network: b.network,
@@ -3949,13 +4001,13 @@ var PipRailClient = (_class2 = class {
3949
4001
  spentBase: b.totalBase.toString()
3950
4002
  };
3951
4003
  if (maxTotal === void 0) return base2;
3952
- const capBase = _chunkDCOUJZPLcjs.floorUnits.call(void 0, maxTotal, b.decimals);
4004
+ const capBase = _chunkGYM46G5Lcjs.floorUnits.call(void 0, maxTotal, b.decimals);
3953
4005
  const remainingBase = capBase > b.totalBase ? capBase - b.totalBase : 0n;
3954
4006
  return {
3955
4007
  ...base2,
3956
4008
  capBase: capBase.toString(),
3957
4009
  remainingBase: remainingBase.toString(),
3958
- remainingFormatted: _chunkDCOUJZPLcjs.formatUnits.call(void 0, remainingBase, b.decimals)
4010
+ remainingFormatted: _chunkGYM46G5Lcjs.formatUnits.call(void 0, remainingBase, b.decimals)
3959
4011
  };
3960
4012
  });
3961
4013
  }
@@ -3991,15 +4043,15 @@ var PipRailClient = (_class2 = class {
3991
4043
  * the plan yourself. No funds move.
3992
4044
  */
3993
4045
  async planPayment(url, init) {
3994
- const res = await fetch(url, { ..._nullishCoalesce(init, () => ( {})), method: _nullishCoalesce(_optionalChain([init, 'optionalAccess', _54 => _54.method]), () => ( "GET")) });
4046
+ const res = await fetch(url, { ..._nullishCoalesce(init, () => ( {})), method: _nullishCoalesce(_optionalChain([init, 'optionalAccess', _56 => _56.method]), () => ( "GET")) });
3995
4047
  if (res.status !== 402) return null;
3996
4048
  const challenge = await parseChallenge(res);
3997
4049
  if (!challenge) {
3998
- throw new (0, _chunkDCOUJZPLcjs.InvalidEnvelopeError)("402 response did not include a parseable x402 challenge.");
4050
+ throw new (0, _chunkGYM46G5Lcjs.InvalidEnvelopeError)("402 response did not include a parseable x402 challenge.");
3999
4051
  }
4000
4052
  const { net, wallet } = await this.ensure();
4001
4053
  if (!wallet) {
4002
- throw new (0, _chunkDCOUJZPLcjs.WalletRequiredError)(
4054
+ throw new (0, _chunkGYM46G5Lcjs.WalletRequiredError)(
4003
4055
  "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."
4004
4056
  );
4005
4057
  }
@@ -4032,7 +4084,8 @@ var PipRailClient = (_class2 = class {
4032
4084
  * before publishing, so retry with a brief backoff if a fresh listing is missing.
4033
4085
  * - Results are cross-scheme (mostly the mainstream `exact` scheme); `fetch()` pays
4034
4086
  * `onchain-proof` rails by default, and standard `exact` rails too once you opt in
4035
- * with `schemes: ['onchain-proof', 'exact']` (EVM EIP-3009/Permit2 + Solana SVM + Algorand).
4087
+ * with `schemes: ['onchain-proof', 'exact']` (EVM EIP-3009/Permit2 + Solana SVM + Algorand
4088
+ * + Aptos + NEAR).
4036
4089
  */
4037
4090
  async discover(opts = {}) {
4038
4091
  const found = await searchOpenIndexes({
@@ -4172,31 +4225,31 @@ var PipRailClient = (_class2 = class {
4172
4225
  * streams throw `NonReplayableBodyError`.
4173
4226
  */
4174
4227
  async fetch(url, init) {
4175
- const body = _optionalChain([init, 'optionalAccess', _55 => _55.body]);
4228
+ const body = _optionalChain([init, 'optionalAccess', _57 => _57.body]);
4176
4229
  if (body !== void 0 && body !== null && !isReplayableBodyInit(body)) {
4177
- throw new (0, _chunkDCOUJZPLcjs.NonReplayableBodyError)(
4230
+ throw new (0, _chunkGYM46G5Lcjs.NonReplayableBodyError)(
4178
4231
  "fetch(): init.body is not replayable. Pass a string, FormData, URLSearchParams, ArrayBuffer, or Blob \u2014 not a ReadableStream."
4179
4232
  );
4180
4233
  }
4181
4234
  const firstResponse = await fetch(url, init);
4182
4235
  if (firstResponse.status !== 402) return firstResponse;
4183
- const schemes = this.resolveSchemes(_optionalChain([init, 'optionalAccess', _56 => _56.schemes]));
4236
+ const schemes = this.resolveSchemes(_optionalChain([init, 'optionalAccess', _58 => _58.schemes]));
4184
4237
  const resolved = await this.resolveChallenge(url, firstResponse, schemes);
4185
4238
  const { net, wallet, challenge } = resolved;
4186
4239
  if (!wallet) {
4187
- throw new (0, _chunkDCOUJZPLcjs.WalletRequiredError)(
4240
+ throw new (0, _chunkGYM46G5Lcjs.WalletRequiredError)(
4188
4241
  "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)."
4189
4242
  );
4190
4243
  }
4191
4244
  let accept = resolved.accept;
4192
4245
  let quote = resolved.quote;
4193
- const autoRoute = _nullishCoalesce(_nullishCoalesce(_optionalChain([init, 'optionalAccess', _57 => _57.autoRoute]), () => ( this.opts.autoRoute)), () => ( false));
4246
+ const autoRoute = _nullishCoalesce(_nullishCoalesce(_optionalChain([init, 'optionalAccess', _59 => _59.autoRoute]), () => ( this.opts.autoRoute)), () => ( false));
4194
4247
  if (autoRoute) {
4195
4248
  const plan = await this.planFromChallenge(net, wallet, challenge, url, schemes);
4196
4249
  if (!plan.best) {
4197
4250
  const reason = _nullishCoalesce(plan.fundingHint, () => ( "No rail is settleable for this payment."));
4198
4251
  this.safeEmit({ kind: "payment-failed", reason });
4199
- throw new (0, _chunkDCOUJZPLcjs.PaymentDeclinedError)(reason);
4252
+ throw new (0, _chunkGYM46G5Lcjs.PaymentDeclinedError)(reason);
4200
4253
  }
4201
4254
  accept = plan.best.accept;
4202
4255
  quote = plan.best.quote;
@@ -4210,7 +4263,7 @@ var PipRailClient = (_class2 = class {
4210
4263
  return this.payExactRail(net, wallet, accept, url, init, quote);
4211
4264
  }
4212
4265
  if (accept.scheme !== "onchain-proof") {
4213
- throw new (0, _chunkDCOUJZPLcjs.UnsupportedSchemeError)(
4266
+ throw new (0, _chunkGYM46G5Lcjs.UnsupportedSchemeError)(
4214
4267
  `internal: unrouted accept scheme '${accept.scheme}' reached the onchain-proof pay path.`
4215
4268
  );
4216
4269
  }
@@ -4228,7 +4281,7 @@ var PipRailClient = (_class2 = class {
4228
4281
  async resolveChallenge(url, response, schemes) {
4229
4282
  const challenge = await parseChallenge(response);
4230
4283
  if (!challenge) {
4231
- throw new (0, _chunkDCOUJZPLcjs.InvalidEnvelopeError)(
4284
+ throw new (0, _chunkGYM46G5Lcjs.InvalidEnvelopeError)(
4232
4285
  "402 response did not include a parseable x402 challenge."
4233
4286
  );
4234
4287
  }
@@ -4239,8 +4292,8 @@ var PipRailClient = (_class2 = class {
4239
4292
  (a) => a.scheme === "exact" && this.supportsNetwork(net, a.network)
4240
4293
  );
4241
4294
  if (schemes.includes("exact") && exactOnNet && typeof net.payExact !== "function") {
4242
- throw new (0, _chunkDCOUJZPLcjs.UnsupportedSchemeError)(
4243
- `This 402 offers a standard 'exact' rail on ${net.network}, but the ${net.family} family can't pay 'exact' (supported on EVM, Solana, Algorand + NEAR today), and no 'onchain-proof' rail was offered.`
4295
+ throw new (0, _chunkGYM46G5Lcjs.UnsupportedSchemeError)(
4296
+ `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.`
4244
4297
  );
4245
4298
  }
4246
4299
  if (!schemes.includes("exact") && exactOnNet && typeof net.payExact === "function") {
@@ -4248,13 +4301,13 @@ var PipRailClient = (_class2 = class {
4248
4301
  (a) => a.scheme === "exact" && this.supportsNetwork(net, a.network) && net.describeAsset(a.asset) != null
4249
4302
  );
4250
4303
  if (payable) {
4251
- throw new (0, _chunkDCOUJZPLcjs.NoCompatibleAcceptError)(
4304
+ throw new (0, _chunkGYM46G5Lcjs.NoCompatibleAcceptError)(
4252
4305
  `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).`
4253
4306
  );
4254
4307
  }
4255
4308
  }
4256
4309
  const networks = [...new Set(challenge.accepts.map((a) => a.network))].join(", ");
4257
- throw new (0, _chunkDCOUJZPLcjs.NoCompatibleAcceptError)(
4310
+ throw new (0, _chunkGYM46G5Lcjs.NoCompatibleAcceptError)(
4258
4311
  `No accepts[] entry payable by this client on ${net.network} (schemes: ${schemes.join(", ")}; challenge offered: ${networks || "none"}).`
4259
4312
  );
4260
4313
  }
@@ -4293,7 +4346,15 @@ var PipRailClient = (_class2 = class {
4293
4346
  if (schemes.includes("exact")) {
4294
4347
  out.push(
4295
4348
  ...challenge.accepts.filter(
4296
- (a) => a.scheme === "exact" && this.supportsNetwork(net, a.network) && typeof net.payExact === "function" && net.describeAsset(a.asset) != null && // a foreign rail's maxTimeoutSeconds must be a usable positive integer, or
4349
+ (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
4350
+ // signed-authorization scheme a native coin can't support; every driver's payExact
4351
+ // throws/returns-null for it). describeAsset('native') IS non-null (onchain-proof needs
4352
+ // it), so without this guard a malformed 402 advertising a native `exact` rail would be
4353
+ // gathered, planned `payable`, even chosen by autoRoute — then throw at pay time.
4354
+ a.asset !== "native" && // the exact pay path (payExact → driver) reads `extra.assetTransferMethod`; a malformed
4355
+ // 402 offering an exact rail for a RECOGNISED token but omitting `extra` would otherwise
4356
+ // be planned payable then throw a raw TypeError mid-pay. Require it at gather time.
4357
+ 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
4297
4358
  // signing it would build a NaN/garbage validBefore — drop it silently
4298
4359
  // (symmetric with an unrecognised token) rather than leak a raw SyntaxError.
4299
4360
  Number.isInteger(a.maxTimeoutSeconds) && a.maxTimeoutSeconds > 0
@@ -4303,7 +4364,8 @@ var PipRailClient = (_class2 = class {
4303
4364
  if (schemes.includes("upto")) {
4304
4365
  out.push(
4305
4366
  ...challenge.accepts.filter(
4306
- (a) => a.scheme === "upto" && this.supportsNetwork(net, a.network) && typeof net.payUpto === "function" && net.describeAsset(a.asset) != null && typeof _optionalChain([a, 'access', _58 => _58.extra, 'optionalAccess', _59 => _59.facilitatorAddress]) === "string" && a.extra.facilitatorAddress.length > 0 && Number.isInteger(a.maxTimeoutSeconds) && a.maxTimeoutSeconds > 0
4367
+ (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)
4368
+ 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
4307
4369
  )
4308
4370
  );
4309
4371
  }
@@ -4374,21 +4436,21 @@ var PipRailClient = (_class2 = class {
4374
4436
  if (isExact) {
4375
4437
  if (tokenKnown && bal.token < amount) {
4376
4438
  blockers.push("INSUFFICIENT_TOKEN");
4377
- shortfall.token = _chunkDCOUJZPLcjs.formatUnits.call(void 0, amount - bal.token, quote.decimals);
4439
+ shortfall.token = _chunkGYM46G5Lcjs.formatUnits.call(void 0, amount - bal.token, quote.decimals);
4378
4440
  }
4379
4441
  } else if (isNative) {
4380
4442
  if (nativeKnown && bal.native < amount + fee) {
4381
4443
  blockers.push("INSUFFICIENT_TOKEN");
4382
- shortfall.token = _chunkDCOUJZPLcjs.formatUnits.call(void 0, amount + fee - bal.native, quote.decimals);
4444
+ shortfall.token = _chunkGYM46G5Lcjs.formatUnits.call(void 0, amount + fee - bal.native, quote.decimals);
4383
4445
  }
4384
4446
  } else {
4385
4447
  if (tokenKnown && bal.token < amount) {
4386
4448
  blockers.push("INSUFFICIENT_TOKEN");
4387
- shortfall.token = _chunkDCOUJZPLcjs.formatUnits.call(void 0, amount - bal.token, quote.decimals);
4449
+ shortfall.token = _chunkGYM46G5Lcjs.formatUnits.call(void 0, amount - bal.token, quote.decimals);
4388
4450
  }
4389
4451
  if (nativeKnown && bal.native < fee) {
4390
4452
  blockers.push("INSUFFICIENT_GAS");
4391
- shortfall.native = _chunkDCOUJZPLcjs.formatUnits.call(void 0, fee - bal.native, cost.feeDecimals);
4453
+ shortfall.native = _chunkGYM46G5Lcjs.formatUnits.call(void 0, fee - bal.native, cost.feeDecimals);
4392
4454
  } else if (nativeKnown && fee > 0n && bal.native < fee * 3n / 2n) {
4393
4455
  warnings.push("THIN_GAS_MARGIN");
4394
4456
  }
@@ -4413,8 +4475,8 @@ var PipRailClient = (_class2 = class {
4413
4475
  blockers,
4414
4476
  warnings,
4415
4477
  balance: {
4416
- token: bal.token != null ? _chunkDCOUJZPLcjs.formatUnits.call(void 0, bal.token, quote.decimals) : null,
4417
- native: bal.native != null ? _chunkDCOUJZPLcjs.formatUnits.call(void 0, bal.native, cost.feeDecimals) : null
4478
+ token: bal.token != null ? _chunkGYM46G5Lcjs.formatUnits.call(void 0, bal.token, quote.decimals) : null,
4479
+ native: bal.native != null ? _chunkGYM46G5Lcjs.formatUnits.call(void 0, bal.native, cost.feeDecimals) : null
4418
4480
  },
4419
4481
  need: { token: quote.amountFormatted, native: cost.feeFormatted },
4420
4482
  ...shortfall.token || shortfall.native ? { shortfall } : {},
@@ -4425,30 +4487,30 @@ var PipRailClient = (_class2 = class {
4425
4487
  * driver's describeAsset) + the policy verdict + a symbol-mismatch flag. */
4426
4488
  buildQuote(net, accept, url, description) {
4427
4489
  if (typeof accept.amount !== "string" || !/^\d+$/.test(accept.amount)) {
4428
- throw new (0, _chunkDCOUJZPLcjs.InvalidEnvelopeError)(
4490
+ throw new (0, _chunkGYM46G5Lcjs.InvalidEnvelopeError)(
4429
4491
  `challenge amount "${String(accept.amount)}" is not a base-unit integer string.`
4430
4492
  );
4431
4493
  }
4432
4494
  if (typeof accept.asset !== "string" || accept.asset.length === 0) {
4433
- throw new (0, _chunkDCOUJZPLcjs.InvalidEnvelopeError)(
4495
+ throw new (0, _chunkGYM46G5Lcjs.InvalidEnvelopeError)(
4434
4496
  `challenge on ${accept.network} states no (string) asset \u2014 refusing to price it.`
4435
4497
  );
4436
4498
  }
4437
4499
  const amountBase = BigInt(accept.amount);
4438
4500
  const described = net.describeAsset(accept.asset);
4439
- const decimals = _nullishCoalesce(_optionalChain([described, 'optionalAccess', _60 => _60.decimals]), () => ( _optionalChain([accept, 'access', _61 => _61.extra, 'optionalAccess', _62 => _62.decimals])));
4501
+ const decimals = _nullishCoalesce(_optionalChain([described, 'optionalAccess', _64 => _64.decimals]), () => ( _optionalChain([accept, 'access', _65 => _65.extra, 'optionalAccess', _66 => _66.decimals])));
4440
4502
  if (typeof decimals !== "number" || !Number.isInteger(decimals) || decimals < 0) {
4441
- throw new (0, _chunkDCOUJZPLcjs.InvalidEnvelopeError)(
4503
+ throw new (0, _chunkGYM46G5Lcjs.InvalidEnvelopeError)(
4442
4504
  `challenge for ${accept.asset} on ${accept.network} states no valid decimals and the SDK doesn't recognise the token \u2014 refusing to price it.`
4443
4505
  );
4444
4506
  }
4445
- if (decimals > _chunkDCOUJZPLcjs.MAX_DECIMALS) {
4446
- throw new (0, _chunkDCOUJZPLcjs.InvalidEnvelopeError)(
4447
- `challenge for ${accept.asset} on ${accept.network} states ${decimals} decimals (> ${_chunkDCOUJZPLcjs.MAX_DECIMALS}) \u2014 refusing to price it (no real token is that deep).`
4507
+ if (decimals > _chunkGYM46G5Lcjs.MAX_DECIMALS) {
4508
+ throw new (0, _chunkGYM46G5Lcjs.InvalidEnvelopeError)(
4509
+ `challenge for ${accept.asset} on ${accept.network} states ${decimals} decimals (> ${_chunkGYM46G5Lcjs.MAX_DECIMALS}) \u2014 refusing to price it (no real token is that deep).`
4448
4510
  );
4449
4511
  }
4450
- const symbol = _nullishCoalesce(_optionalChain([described, 'optionalAccess', _63 => _63.symbol]), () => ( _optionalChain([accept, 'access', _64 => _64.extra, 'optionalAccess', _65 => _65.symbol])));
4451
- const amountFormatted = _chunkDCOUJZPLcjs.formatUnits.call(void 0, amountBase, decimals);
4512
+ const symbol = _nullishCoalesce(_optionalChain([described, 'optionalAccess', _67 => _67.symbol]), () => ( _optionalChain([accept, 'access', _68 => _68.extra, 'optionalAccess', _69 => _69.symbol])));
4513
+ const amountFormatted = _chunkGYM46G5Lcjs.formatUnits.call(void 0, amountBase, decimals);
4452
4514
  const intent = {
4453
4515
  host: hostOf2(url),
4454
4516
  chain: this.opts.chain,
@@ -4489,7 +4551,7 @@ var PipRailClient = (_class2 = class {
4489
4551
  this.ledger.totalFor(accept.network, accept.asset),
4490
4552
  ctx
4491
4553
  );
4492
- const serverSymbol = _optionalChain([accept, 'access', _66 => _66.extra, 'optionalAccess', _67 => _67.symbol]);
4554
+ const serverSymbol = _optionalChain([accept, 'access', _70 => _70.extra, 'optionalAccess', _71 => _71.symbol]);
4493
4555
  const symbolMismatch = intent.recognized && !!serverSymbol && !!symbol && serverSymbol.toUpperCase() !== symbol.toUpperCase();
4494
4556
  return {
4495
4557
  url,
@@ -4553,7 +4615,7 @@ var PipRailClient = (_class2 = class {
4553
4615
  ...opts.quote ? { quote: opts.quote } : {},
4554
4616
  budget: this.budget()
4555
4617
  });
4556
- throw new (0, _chunkDCOUJZPLcjs.PaymentDeclinedError)(reason, {
4618
+ throw new (0, _chunkGYM46G5Lcjs.PaymentDeclinedError)(reason, {
4557
4619
  ...opts.reasonCode ? { reasonCode: opts.reasonCode } : {},
4558
4620
  ...opts.cause !== void 0 ? { cause: opts.cause } : {}
4559
4621
  });
@@ -4585,7 +4647,7 @@ var PipRailClient = (_class2 = class {
4585
4647
  const max = BigInt(quote.amount);
4586
4648
  const shown = claimed < max ? claimed : max;
4587
4649
  settledBase = shown.toString();
4588
- settledFormatted = _chunkDCOUJZPLcjs.formatUnits.call(void 0, shown, quote.decimals);
4650
+ settledFormatted = _chunkGYM46G5Lcjs.formatUnits.call(void 0, shown, quote.decimals);
4589
4651
  } catch (e36) {
4590
4652
  }
4591
4653
  }
@@ -4621,7 +4683,7 @@ var PipRailClient = (_class2 = class {
4621
4683
  * `warnAtFraction` is set. Reads the just-computed {@link SessionBudget}; isolated (safeEmit).
4622
4684
  */
4623
4685
  emitThresholds(budget) {
4624
- const frac = _optionalChain([this, 'access', _68 => _68.opts, 'access', _69 => _69.policy, 'optionalAccess', _70 => _70.warnAtFraction]);
4686
+ const frac = _optionalChain([this, 'access', _72 => _72.opts, 'access', _73 => _73.policy, 'optionalAccess', _74 => _74.warnAtFraction]);
4625
4687
  if (frac === void 0) return;
4626
4688
  const fire = (scope, label, spentFormatted, capFormatted, fraction) => {
4627
4689
  if (fraction < frac) return;
@@ -4636,8 +4698,8 @@ var PipRailClient = (_class2 = class {
4636
4698
  fire(
4637
4699
  "asset",
4638
4700
  `${_nullishCoalesce(r.symbol, () => ( r.asset))} on ${r.network}`,
4639
- _chunkDCOUJZPLcjs.formatUnits.call(void 0, spent, r.decimals),
4640
- _chunkDCOUJZPLcjs.formatUnits.call(void 0, cap, r.decimals),
4701
+ _chunkGYM46G5Lcjs.formatUnits.call(void 0, spent, r.decimals),
4702
+ _chunkGYM46G5Lcjs.formatUnits.call(void 0, cap, r.decimals),
4641
4703
  fraction
4642
4704
  );
4643
4705
  }
@@ -4645,17 +4707,17 @@ var PipRailClient = (_class2 = class {
4645
4707
  fire("denom", d.denom, d.spentFormatted, d.capFormatted, d.fraction);
4646
4708
  }
4647
4709
  const policy = this.opts.policy;
4648
- if (_optionalChain([policy, 'optionalAccess', _71 => _71.windowTotal]) !== void 0 && policy.windowSeconds !== void 0) {
4710
+ if (_optionalChain([policy, 'optionalAccess', _75 => _75.windowTotal]) !== void 0 && policy.windowSeconds !== void 0) {
4649
4711
  const since = Date.now() - policy.windowSeconds * 1e3;
4650
4712
  for (const r of budget.byAsset) {
4651
- const cap = _chunkDCOUJZPLcjs.floorUnits.call(void 0, policy.windowTotal, r.decimals);
4713
+ const cap = _chunkGYM46G5Lcjs.floorUnits.call(void 0, policy.windowTotal, r.decimals);
4652
4714
  const spent = this.ledger.totalSince(r.network, r.asset, since);
4653
4715
  const fraction = cap === 0n ? spent > 0n ? 1 : 0 : Number(spent * 1000000n / cap) / 1e6;
4654
4716
  fire(
4655
4717
  "window",
4656
4718
  `${_nullishCoalesce(r.symbol, () => ( r.asset))} on ${r.network}`,
4657
- _chunkDCOUJZPLcjs.formatUnits.call(void 0, spent, r.decimals),
4658
- _chunkDCOUJZPLcjs.formatUnits.call(void 0, cap, r.decimals),
4719
+ _chunkGYM46G5Lcjs.formatUnits.call(void 0, spent, r.decimals),
4720
+ _chunkGYM46G5Lcjs.formatUnits.call(void 0, cap, r.decimals),
4659
4721
  fraction
4660
4722
  );
4661
4723
  }
@@ -4676,14 +4738,14 @@ var PipRailClient = (_class2 = class {
4676
4738
  }
4677
4739
  async payAndConfirm(net, wallet, accept) {
4678
4740
  if (!this.supportsNetwork(net, accept.network)) {
4679
- throw new (0, _chunkDCOUJZPLcjs.WrongChainError)(
4741
+ throw new (0, _chunkGYM46G5Lcjs.WrongChainError)(
4680
4742
  `Challenge expects ${accept.network} but client is on ${net.network}.`
4681
4743
  );
4682
4744
  }
4683
4745
  const ref = await net.send(wallet, accept);
4684
4746
  this.safeEmit({ kind: "payment-broadcast", ref });
4685
4747
  try {
4686
- const { height } = await net.confirm(ref, _nullishCoalesce(_optionalChain([accept, 'access', _72 => _72.extra, 'optionalAccess', _73 => _73.minConfirmations]), () => ( 1)));
4748
+ const { height } = await net.confirm(ref, _nullishCoalesce(_optionalChain([accept, 'access', _76 => _76.extra, 'optionalAccess', _77 => _77.minConfirmations]), () => ( 1)));
4687
4749
  this.safeEmit({
4688
4750
  kind: "payment-confirmed",
4689
4751
  ref,
@@ -4703,9 +4765,9 @@ var PipRailClient = (_class2 = class {
4703
4765
  const signature = {
4704
4766
  x402Version: 2,
4705
4767
  accepted: accept,
4706
- payload: { nonce: _optionalChain([accept, 'access', _74 => _74.extra, 'optionalAccess', _75 => _75.nonce]), txHash: ref }
4768
+ payload: { nonce: _optionalChain([accept, 'access', _78 => _78.extra, 'optionalAccess', _79 => _79.nonce]), txHash: ref }
4707
4769
  };
4708
- const headers = new Headers(_optionalChain([originalInit, 'optionalAccess', _76 => _76.headers]));
4770
+ const headers = new Headers(_optionalChain([originalInit, 'optionalAccess', _80 => _80.headers]));
4709
4771
  headers.set(HEADER_SIGNATURE, buildSignatureHeader(signature));
4710
4772
  let lastResponse = null;
4711
4773
  let lastReason = null;
@@ -4720,7 +4782,7 @@ var PipRailClient = (_class2 = class {
4720
4782
  () => timeoutController.abort(),
4721
4783
  this.retryTimeoutMs
4722
4784
  );
4723
- const signal = _optionalChain([originalInit, 'optionalAccess', _77 => _77.signal]) && typeof AbortSignal.any === "function" ? AbortSignal.any([timeoutController.signal, originalInit.signal]) : timeoutController.signal;
4785
+ const signal = _optionalChain([originalInit, 'optionalAccess', _81 => _81.signal]) && typeof AbortSignal.any === "function" ? AbortSignal.any([timeoutController.signal, originalInit.signal]) : timeoutController.signal;
4724
4786
  try {
4725
4787
  lastResponse = await fetch(url, {
4726
4788
  ..._nullishCoalesce(originalInit, () => ( {})),
@@ -4729,7 +4791,7 @@ var PipRailClient = (_class2 = class {
4729
4791
  });
4730
4792
  } catch (err) {
4731
4793
  if (timeoutController.signal.aborted) {
4732
- throw new (0, _chunkDCOUJZPLcjs.PaymentTimeoutError)(
4794
+ throw new (0, _chunkGYM46G5Lcjs.PaymentTimeoutError)(
4733
4795
  `Server did not respond within ${this.retryTimeoutMs}ms after broadcasting payment ${ref}. Re-verify or re-submit ref=${ref} \u2014 do NOT re-pay.`,
4734
4796
  { cause: err, ref }
4735
4797
  );
@@ -4753,7 +4815,7 @@ var PipRailClient = (_class2 = class {
4753
4815
  reason: `server returned 402 after broadcasting payment ${ref}${unconfirmedNote} (${why})`,
4754
4816
  ...lastReason ? { code: lastReason.error, detail: lastReason.detail } : {}
4755
4817
  });
4756
- throw new (0, _chunkDCOUJZPLcjs.MaxRetriesExceededError)(
4818
+ throw new (0, _chunkGYM46G5Lcjs.MaxRetriesExceededError)(
4757
4819
  `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).`,
4758
4820
  { ref }
4759
4821
  );
@@ -4777,17 +4839,17 @@ var PipRailClient = (_class2 = class {
4777
4839
  */
4778
4840
  async payExactRail(net, wallet, accept, url, init, quote) {
4779
4841
  if (!net.payExact) {
4780
- throw new (0, _chunkDCOUJZPLcjs.UnsupportedSchemeError)(
4842
+ throw new (0, _chunkGYM46G5Lcjs.UnsupportedSchemeError)(
4781
4843
  `the ${net.family} family can't pay a standard 'exact' rail (supported on EVM, Solana, Algorand, Aptos + NEAR today).`
4782
4844
  );
4783
4845
  }
4784
- throwIfAborted(_optionalChain([init, 'optionalAccess', _78 => _78.signal]));
4846
+ throwIfAborted(_optionalChain([init, 'optionalAccess', _82 => _82.signal]));
4785
4847
  const { payload, accepted, payerFrom, nonce } = await net.payExact(wallet, accept);
4786
- const headers = new Headers(_optionalChain([init, 'optionalAccess', _79 => _79.headers]));
4848
+ const headers = new Headers(_optionalChain([init, 'optionalAccess', _83 => _83.headers]));
4787
4849
  headers.set(HEADER_SIGNATURE, buildExactSignatureHeader({ accepted, payload }));
4788
4850
  const rejectDefinitive = (why2) => {
4789
4851
  this.safeEmit({ kind: "payment-failed", reason: `exact: facilitator rejected nonce=${nonce} (${why2})`, code: why2 });
4790
- throw new (0, _chunkDCOUJZPLcjs.MaxRetriesExceededError)(
4852
+ throw new (0, _chunkGYM46G5Lcjs.MaxRetriesExceededError)(
4791
4853
  `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}.`,
4792
4854
  { ref: nonce }
4793
4855
  );
@@ -4800,17 +4862,17 @@ var PipRailClient = (_class2 = class {
4800
4862
  if (Date.now() >= deadline) break;
4801
4863
  await new Promise((r) => setTimeout(r, Math.min(2e3, 400 * 2 ** (attempt - 1))));
4802
4864
  }
4803
- throwIfAborted(_optionalChain([init, 'optionalAccess', _80 => _80.signal]));
4865
+ throwIfAborted(_optionalChain([init, 'optionalAccess', _84 => _84.signal]));
4804
4866
  const budget = Math.min(this.retryTimeoutMs, deadline - Date.now());
4805
4867
  if (budget <= 0) break;
4806
4868
  const timeoutController = new AbortController();
4807
4869
  const timeoutId = setTimeout(() => timeoutController.abort(), budget);
4808
- const signal = _optionalChain([init, 'optionalAccess', _81 => _81.signal]) && typeof AbortSignal.any === "function" ? AbortSignal.any([timeoutController.signal, init.signal]) : timeoutController.signal;
4870
+ const signal = _optionalChain([init, 'optionalAccess', _85 => _85.signal]) && typeof AbortSignal.any === "function" ? AbortSignal.any([timeoutController.signal, init.signal]) : timeoutController.signal;
4809
4871
  let response;
4810
4872
  try {
4811
4873
  response = await fetch(url, { ..._nullishCoalesce(init, () => ( {})), headers, signal });
4812
4874
  } catch (err) {
4813
- throw new (0, _chunkDCOUJZPLcjs.PaymentTimeoutError)(
4875
+ throw new (0, _chunkGYM46G5Lcjs.PaymentTimeoutError)(
4814
4876
  `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.`,
4815
4877
  { cause: err, ref: nonce }
4816
4878
  );
@@ -4827,7 +4889,7 @@ var PipRailClient = (_class2 = class {
4827
4889
  const receipt = parseReceipt(response);
4828
4890
  this.captureReceipt(response, url);
4829
4891
  this.safeEmit({ kind: "payment-settled", receipt, ...settle ? { settle } : {} });
4830
- const ref = _optionalChain([settle, 'optionalAccess', _82 => _82.transaction]) || _optionalChain([receipt, 'optionalAccess', _83 => _83.transaction]) || `${net.family === "evm" ? "eip3009" : net.family}-nonce:${nonce}`;
4892
+ const ref = _optionalChain([settle, 'optionalAccess', _86 => _86.transaction]) || _optionalChain([receipt, 'optionalAccess', _87 => _87.transaction]) || `${net.family === "evm" ? "eip3009" : net.family}-nonce:${nonce}`;
4831
4893
  this.recordSpend(quote, ref);
4832
4894
  return response;
4833
4895
  }
@@ -4845,7 +4907,7 @@ var PipRailClient = (_class2 = class {
4845
4907
  reason: `exact: 402 after submitting authorization nonce=${nonce} (${why})`,
4846
4908
  ...lastReason ? { code: lastReason.error, detail: lastReason.detail } : {}
4847
4909
  });
4848
- throw new (0, _chunkDCOUJZPLcjs.MaxRetriesExceededError)(
4910
+ throw new (0, _chunkGYM46G5Lcjs.MaxRetriesExceededError)(
4849
4911
  `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}.`,
4850
4912
  { ref: nonce }
4851
4913
  );
@@ -4861,17 +4923,17 @@ var PipRailClient = (_class2 = class {
4861
4923
  */
4862
4924
  async payUptoRail(net, wallet, accept, url, init, quote) {
4863
4925
  if (!net.payUpto) {
4864
- throw new (0, _chunkDCOUJZPLcjs.UnsupportedSchemeError)(
4926
+ throw new (0, _chunkGYM46G5Lcjs.UnsupportedSchemeError)(
4865
4927
  `the ${net.family} family can't pay a standard 'upto' rail (EVM-Permit2 only today).`
4866
4928
  );
4867
4929
  }
4868
- throwIfAborted(_optionalChain([init, 'optionalAccess', _84 => _84.signal]));
4930
+ throwIfAborted(_optionalChain([init, 'optionalAccess', _88 => _88.signal]));
4869
4931
  const { payload, accepted, payerFrom, nonce } = await net.payUpto(wallet, accept);
4870
- const headers = new Headers(_optionalChain([init, 'optionalAccess', _85 => _85.headers]));
4932
+ const headers = new Headers(_optionalChain([init, 'optionalAccess', _89 => _89.headers]));
4871
4933
  headers.set(HEADER_SIGNATURE, buildUptoSignatureHeader({ accepted, payload }));
4872
4934
  const rejectDefinitive = (why2) => {
4873
4935
  this.safeEmit({ kind: "payment-failed", reason: `upto: facilitator rejected nonce=${nonce} (${why2})`, code: why2 });
4874
- throw new (0, _chunkDCOUJZPLcjs.MaxRetriesExceededError)(
4936
+ throw new (0, _chunkGYM46G5Lcjs.MaxRetriesExceededError)(
4875
4937
  `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}.`,
4876
4938
  { ref: nonce }
4877
4939
  );
@@ -4884,17 +4946,17 @@ var PipRailClient = (_class2 = class {
4884
4946
  if (Date.now() >= deadline) break;
4885
4947
  await new Promise((r) => setTimeout(r, Math.min(2e3, 400 * 2 ** (attempt - 1))));
4886
4948
  }
4887
- throwIfAborted(_optionalChain([init, 'optionalAccess', _86 => _86.signal]));
4949
+ throwIfAborted(_optionalChain([init, 'optionalAccess', _90 => _90.signal]));
4888
4950
  const budget = Math.min(this.retryTimeoutMs, deadline - Date.now());
4889
4951
  if (budget <= 0) break;
4890
4952
  const timeoutController = new AbortController();
4891
4953
  const timeoutId = setTimeout(() => timeoutController.abort(), budget);
4892
- const signal = _optionalChain([init, 'optionalAccess', _87 => _87.signal]) && typeof AbortSignal.any === "function" ? AbortSignal.any([timeoutController.signal, init.signal]) : timeoutController.signal;
4954
+ const signal = _optionalChain([init, 'optionalAccess', _91 => _91.signal]) && typeof AbortSignal.any === "function" ? AbortSignal.any([timeoutController.signal, init.signal]) : timeoutController.signal;
4893
4955
  let response;
4894
4956
  try {
4895
4957
  response = await fetch(url, { ..._nullishCoalesce(init, () => ( {})), headers, signal });
4896
4958
  } catch (err) {
4897
- throw new (0, _chunkDCOUJZPLcjs.PaymentTimeoutError)(
4959
+ throw new (0, _chunkGYM46G5Lcjs.PaymentTimeoutError)(
4898
4960
  `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.`,
4899
4961
  { cause: err, ref: nonce }
4900
4962
  );
@@ -4911,8 +4973,8 @@ var PipRailClient = (_class2 = class {
4911
4973
  const receipt = parseReceipt(response);
4912
4974
  this.captureReceipt(response, url);
4913
4975
  this.safeEmit({ kind: "payment-settled", receipt, ...settle ? { settle } : {} });
4914
- const ref = _optionalChain([settle, 'optionalAccess', _88 => _88.transaction]) || _optionalChain([receipt, 'optionalAccess', _89 => _89.transaction]) || `upto-nonce:${nonce}`;
4915
- const settledAmount = _nullishCoalesce(_optionalChain([settle, 'optionalAccess', _90 => _90.amount]), () => ( _optionalChain([receipt, 'optionalAccess', _91 => _91.amount])));
4976
+ const ref = _optionalChain([settle, 'optionalAccess', _92 => _92.transaction]) || _optionalChain([receipt, 'optionalAccess', _93 => _93.transaction]) || `upto-nonce:${nonce}`;
4977
+ const settledAmount = _nullishCoalesce(_optionalChain([settle, 'optionalAccess', _94 => _94.amount]), () => ( _optionalChain([receipt, 'optionalAccess', _95 => _95.amount])));
4916
4978
  this.recordSpend(quote, ref, settledAmount);
4917
4979
  return response;
4918
4980
  }
@@ -4930,14 +4992,14 @@ var PipRailClient = (_class2 = class {
4930
4992
  reason: `upto: 402 after submitting authorization nonce=${nonce} (${why})`,
4931
4993
  ...lastReason ? { code: lastReason.error, detail: lastReason.detail } : {}
4932
4994
  });
4933
- throw new (0, _chunkDCOUJZPLcjs.MaxRetriesExceededError)(
4995
+ throw new (0, _chunkGYM46G5Lcjs.MaxRetriesExceededError)(
4934
4996
  `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}.`,
4935
4997
  { ref: nonce }
4936
4998
  );
4937
4999
  }
4938
5000
  }, _class2);
4939
5001
  function throwIfAborted(signal) {
4940
- if (_optionalChain([signal, 'optionalAccess', _92 => _92.aborted])) {
5002
+ if (_optionalChain([signal, 'optionalAccess', _96 => _96.aborted])) {
4941
5003
  throw _nullishCoalesce(signal.reason, () => ( new DOMException("This operation was aborted.", "AbortError")));
4942
5004
  }
4943
5005
  }
@@ -5007,10 +5069,10 @@ function buildFundingHint(options, chainLabel) {
5007
5069
  return `Couldn't fully read your wallet on ${chainLabel} (RPC throttled) \u2014 retry; you may already be able to pay ${target.quote.amountFormatted} ${sym}.`;
5008
5070
  }
5009
5071
  const parts = [];
5010
- if (target.blockers.includes("INSUFFICIENT_TOKEN") && _optionalChain([target, 'access', _93 => _93.shortfall, 'optionalAccess', _94 => _94.token])) {
5072
+ if (target.blockers.includes("INSUFFICIENT_TOKEN") && _optionalChain([target, 'access', _97 => _97.shortfall, 'optionalAccess', _98 => _98.token])) {
5011
5073
  parts.push(`top up ${target.shortfall.token} ${sym}`);
5012
5074
  }
5013
- if (target.blockers.includes("INSUFFICIENT_GAS") && _optionalChain([target, 'access', _95 => _95.shortfall, 'optionalAccess', _96 => _96.native])) {
5075
+ if (target.blockers.includes("INSUFFICIENT_GAS") && _optionalChain([target, 'access', _99 => _99.shortfall, 'optionalAccess', _100 => _100.native])) {
5014
5076
  parts.push(`add ~${target.shortfall.native} ${target.cost.feeSymbol} for gas`);
5015
5077
  }
5016
5078
  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}.`;
@@ -5024,7 +5086,7 @@ async function planAcross(clients, url, init) {
5024
5086
  const status = best ? "ready" : options.some((o) => o.state === "unknown") ? "unknown" : "blocked";
5025
5087
  return {
5026
5088
  url,
5027
- network: _nullishCoalesce(_optionalChain([best, 'optionalAccess', _97 => _97.accept, 'access', _98 => _98.network]), () => ( live[0].network)),
5089
+ network: _nullishCoalesce(_optionalChain([best, 'optionalAccess', _101 => _101.accept, 'access', _102 => _102.network]), () => ( live[0].network)),
5028
5090
  status,
5029
5091
  payable: best !== null,
5030
5092
  best,
@@ -5043,7 +5105,7 @@ async function fetchAcross(clients, url, init) {
5043
5105
  const best = rankAcross(live.map((p) => p.plan)).find((o) => o.state === "payable");
5044
5106
  if (!best) {
5045
5107
  const hint = mergeDeclineHint(live.map((p) => p.plan));
5046
- throw new (0, _chunkDCOUJZPLcjs.PaymentDeclinedError)(hint || "No funded chain can settle this payment right now.");
5108
+ throw new (0, _chunkGYM46G5Lcjs.PaymentDeclinedError)(hint || "No funded chain can settle this payment right now.");
5047
5109
  }
5048
5110
  const owner = live.find((p) => p.plan.options.includes(best)).client;
5049
5111
  return owner.fetch(url, { ..._nullishCoalesce(init, () => ( {})), autoRoute: true });
@@ -5089,8 +5151,8 @@ function isReplayableBodyInit(value) {
5089
5151
  async function readInvalidReason(response) {
5090
5152
  try {
5091
5153
  const body = await response.clone().json();
5092
- const ext = _optionalChain([body, 'optionalAccess', _99 => _99.extensions]);
5093
- const piprail = _optionalChain([ext, 'optionalAccess', _100 => _100.piprail]);
5154
+ const ext = _optionalChain([body, 'optionalAccess', _103 => _103.extensions]);
5155
+ const piprail = _optionalChain([ext, 'optionalAccess', _104 => _104.piprail]);
5094
5156
  if (piprail && typeof piprail.code === "string") {
5095
5157
  return {
5096
5158
  error: piprail.code,
@@ -5112,7 +5174,7 @@ async function readInvalidReason(response) {
5112
5174
  } catch (e40) {
5113
5175
  }
5114
5176
  const settle = parseSettleResponse(response);
5115
- if (_optionalChain([settle, 'optionalAccess', _101 => _101.errorReason])) return { error: settle.errorReason, detail: "" };
5177
+ if (_optionalChain([settle, 'optionalAccess', _105 => _105.errorReason])) return { error: settle.errorReason, detail: "" };
5116
5178
  return null;
5117
5179
  }
5118
5180
  var EVM_PRESET_FOR_CHAINID = {
@@ -5210,7 +5272,7 @@ var MultiChainPayer = class _MultiChainPayer {
5210
5272
  ledger,
5211
5273
  ...opts.policy ? { policy: opts.policy } : {},
5212
5274
  ...opts.schemes ? { schemes: opts.schemes } : {},
5213
- ..._optionalChain([opts, 'access', _102 => _102.rpcUrls, 'optionalAccess', _103 => _103[chain]]) ? { rpcUrl: opts.rpcUrls[chain] } : {},
5275
+ ..._optionalChain([opts, 'access', _106 => _106.rpcUrls, 'optionalAccess', _107 => _107[chain]]) ? { rpcUrl: opts.rpcUrls[chain] } : {},
5214
5276
  ...opts.onBeforePay ? { onBeforePay: opts.onBeforePay } : {},
5215
5277
  ...opts.onEvent ? { onEvent: opts.onEvent } : {},
5216
5278
  ...opts.maxPaymentRetries != null ? { maxPaymentRetries: opts.maxPaymentRetries } : {},
@@ -5268,7 +5330,7 @@ var MultiChainPayer = class _MultiChainPayer {
5268
5330
  * {@link PipRailClient.post}.
5269
5331
  */
5270
5332
  post(url, body, init) {
5271
- const headers = new Headers(_optionalChain([init, 'optionalAccess', _104 => _104.headers]));
5333
+ const headers = new Headers(_optionalChain([init, 'optionalAccess', _108 => _108.headers]));
5272
5334
  let payload;
5273
5335
  if (body === void 0 || body === null) {
5274
5336
  payload = void 0;
@@ -5418,14 +5480,14 @@ function buildSelfDescription(input) {
5418
5480
  }
5419
5481
  function buildEndpointInfo(input) {
5420
5482
  const d = input.descriptor;
5421
- const summary = _nullishCoalesce(_optionalChain([d, 'optionalAccess', _105 => _105.summary]), () => ( input.description));
5422
- const hasInput = _optionalChain([d, 'optionalAccess', _106 => _106.queryParams]) && Object.keys(d.queryParams).length > 0;
5483
+ const summary = _nullishCoalesce(_optionalChain([d, 'optionalAccess', _109 => _109.summary]), () => ( input.description));
5484
+ const hasInput = _optionalChain([d, 'optionalAccess', _110 => _110.queryParams]) && Object.keys(d.queryParams).length > 0;
5423
5485
  const endpoint = {
5424
5486
  ...summary ? { summary } : {},
5425
- ..._optionalChain([d, 'optionalAccess', _107 => _107.method]) ? { method: d.method.toUpperCase() } : {},
5487
+ ..._optionalChain([d, 'optionalAccess', _111 => _111.method]) ? { method: d.method.toUpperCase() } : {},
5426
5488
  ...input.mimeType ? { mimeType: input.mimeType } : {},
5427
5489
  ...hasInput ? { input: d.queryParams } : {},
5428
- ..._optionalChain([d, 'optionalAccess', _108 => _108.output]) ? { output: d.output } : {}
5490
+ ..._optionalChain([d, 'optionalAccess', _112 => _112.output]) ? { output: d.output } : {}
5429
5491
  };
5430
5492
  return Object.keys(endpoint).length > 0 ? endpoint : void 0;
5431
5493
  }
@@ -5443,7 +5505,7 @@ function summarizePlan(plan) {
5443
5505
  return `NOT payable: ${_nullishCoalesce(plan.fundingHint, () => ( `no settleable rail on ${plan.network}`))}`;
5444
5506
  }
5445
5507
  function explainDecline(err) {
5446
- if (!(err instanceof _chunkDCOUJZPLcjs.PipRailError)) {
5508
+ if (!(err instanceof _chunkGYM46G5Lcjs.PipRailError)) {
5447
5509
  return `Payment failed: ${err instanceof Error ? err.message : String(err)}`;
5448
5510
  }
5449
5511
  switch (err.code) {
@@ -5517,8 +5579,8 @@ A 402 may offer up to three rails; you don't choose per payment \u2014 the clien
5517
5579
  (the native coin \u2014 ETH/SOL/\u2026). Works on every chain.
5518
5580
  - exact (the ratified x402 rail, opt-in): you only SIGN; the server \u2014 or a facilitator it chose
5519
5581
  (e.g. PayAI) \u2014 broadcasts it, so you pay ZERO gas (you need only the token, no native coin). It
5520
- works on EVM, Solana + Algorand, and the on-chain method (EIP-3009 / Permit2 / SVM / Algorand
5521
- fee-pooled group) is picked automatically.
5582
+ works on EVM, Solana, Algorand, Aptos + NEAR, and the on-chain method (EIP-3009 / Permit2 / SVM /
5583
+ Algorand fee-pooled group / Aptos fee-payer / NEAR SignedDelegateAction) is picked automatically.
5522
5584
  - upto (the metered/variable x402 rail, opt-in, EVM): the amount you see is a MAXIMUM \u2014 you sign
5523
5585
  a ceiling, the server meters real usage and settles the ACTUAL (<= the max). BUDGET AGAINST THE MAX:
5524
5586
  the plan/policy treat the ceiling as the spend (a server may charge up to it), so a payable plan
@@ -5595,14 +5657,14 @@ async function readBody(res) {
5595
5657
  }
5596
5658
  }
5597
5659
  function toToolError(err) {
5598
- if (!(err instanceof _chunkDCOUJZPLcjs.PipRailError)) throw err;
5660
+ if (!(err instanceof _chunkGYM46G5Lcjs.PipRailError)) throw err;
5599
5661
  const out = {
5600
5662
  ok: false,
5601
5663
  code: err.code,
5602
5664
  reason: err.message,
5603
5665
  explain: explainDecline(err)
5604
5666
  };
5605
- if (err instanceof _chunkDCOUJZPLcjs.PaymentDeclinedError) {
5667
+ if (err instanceof _chunkGYM46G5Lcjs.PaymentDeclinedError) {
5606
5668
  out.declined = true;
5607
5669
  if (err.reasonCode) out.reasonCode = err.reasonCode;
5608
5670
  }
@@ -5818,14 +5880,14 @@ function paymentTools(client) {
5818
5880
  ...verifiable ? { verifiableReceipt: { ...verifiable, resource: { url } } } : {}
5819
5881
  };
5820
5882
  } catch (err) {
5821
- if (err instanceof _chunkDCOUJZPLcjs.PipRailError) {
5883
+ if (err instanceof _chunkGYM46G5Lcjs.PipRailError) {
5822
5884
  const out = {
5823
5885
  ok: false,
5824
5886
  code: err.code,
5825
5887
  reason: err.message,
5826
5888
  explain: explainDecline(err)
5827
5889
  };
5828
- if (err instanceof _chunkDCOUJZPLcjs.PaymentDeclinedError) {
5890
+ if (err instanceof _chunkGYM46G5Lcjs.PaymentDeclinedError) {
5829
5891
  out.declined = true;
5830
5892
  if (err.reasonCode) out.reasonCode = err.reasonCode;
5831
5893
  }
@@ -6063,6 +6125,23 @@ function buildWellKnownX402(input) {
6063
6125
  ...input.ownershipProofs && input.ownershipProofs.length > 0 ? { ownershipProofs: input.ownershipProofs } : {}
6064
6126
  };
6065
6127
  }
6128
+ function buildWellKnownX402Manifest(input) {
6129
+ return {
6130
+ x402Version: 2,
6131
+ lastUpdated: _nullishCoalesce(input.lastUpdated, () => ( Math.floor(Date.now() / 1e3))),
6132
+ items: input.resources.map((r) => ({
6133
+ resource: {
6134
+ url: r.url,
6135
+ ...r.description ? { description: r.description } : {},
6136
+ ...r.mimeType ? { mimeType: r.mimeType } : {}
6137
+ },
6138
+ type: "http",
6139
+ accepts: r.accepts,
6140
+ input: { method: (_nullishCoalesce(r.method, () => ( "GET"))).toUpperCase() },
6141
+ ...r.mimeType ? { output: { mimeType: r.mimeType } } : {}
6142
+ }))
6143
+ };
6144
+ }
6066
6145
  function buildX402DnsTxt(input) {
6067
6146
  const descriptor = input.descriptor ? `descriptor=${input.descriptor};` : "";
6068
6147
  return {
@@ -6132,10 +6211,10 @@ async function fetchFacilitatorFeePayer(url, network, timeoutMs = 8e3) {
6132
6211
  const res = await fetch(`${base2}/supported`, { signal: ctrl.signal });
6133
6212
  if (!res.ok) return void 0;
6134
6213
  const body = await res.json();
6135
- const kinds = Array.isArray(_optionalChain([body, 'optionalAccess', _109 => _109.kinds])) ? body.kinds : [];
6214
+ const kinds = Array.isArray(_optionalChain([body, 'optionalAccess', _113 => _113.kinds])) ? body.kinds : [];
6136
6215
  const want = normalizeNetwork(network);
6137
- const kind = kinds.find((k) => _optionalChain([k, 'optionalAccess', _110 => _110.scheme]) === "exact" && normalizeNetwork(String(_nullishCoalesce(_optionalChain([k, 'optionalAccess', _111 => _111.network]), () => ( "")))) === want);
6138
- const fp = _optionalChain([kind, 'optionalAccess', _112 => _112.extra, 'optionalAccess', _113 => _113.feePayer]);
6216
+ const kind = kinds.find((k) => _optionalChain([k, 'optionalAccess', _114 => _114.scheme]) === "exact" && normalizeNetwork(String(_nullishCoalesce(_optionalChain([k, 'optionalAccess', _115 => _115.network]), () => ( "")))) === want);
6217
+ const fp = _optionalChain([kind, 'optionalAccess', _116 => _116.extra, 'optionalAccess', _117 => _117.feePayer]);
6139
6218
  return typeof fp === "string" ? fp : void 0;
6140
6219
  } catch (e43) {
6141
6220
  return void 0;
@@ -6144,16 +6223,16 @@ async function fetchFacilitatorFeePayer(url, network, timeoutMs = 8e3) {
6144
6223
  }
6145
6224
  }
6146
6225
  function parseFacilitatorSupported(body) {
6147
- const kinds = _optionalChain([body, 'optionalAccess', _114 => _114.kinds]);
6226
+ const kinds = _optionalChain([body, 'optionalAccess', _118 => _118.kinds]);
6148
6227
  if (!Array.isArray(kinds)) return [];
6149
6228
  const out = [];
6150
6229
  for (const k of kinds) {
6151
6230
  if (!k || typeof k !== "object") continue;
6152
6231
  const o = k;
6153
6232
  if (typeof o.scheme !== "string" || typeof o.network !== "string") continue;
6154
- const fp = _optionalChain([o, 'access', _115 => _115.extra, 'optionalAccess', _116 => _116.feePayer]);
6233
+ const fp = _optionalChain([o, 'access', _119 => _119.extra, 'optionalAccess', _120 => _120.feePayer]);
6155
6234
  const ver = o.x402Version;
6156
- const method = _optionalChain([o, 'access', _117 => _117.extra, 'optionalAccess', _118 => _118.assetTransferMethod]);
6235
+ const method = _optionalChain([o, 'access', _121 => _121.extra, 'optionalAccess', _122 => _122.assetTransferMethod]);
6157
6236
  out.push({
6158
6237
  scheme: o.scheme,
6159
6238
  network: o.network,
@@ -6217,13 +6296,13 @@ async function settleViaFacilitator(input) {
6217
6296
  try {
6218
6297
  verify = await post(`${base2}/verify`, body, auth);
6219
6298
  } catch (err) {
6220
- throw new (0, _chunkDCOUJZPLcjs.SettlementError)(
6299
+ throw new (0, _chunkGYM46G5Lcjs.SettlementError)(
6221
6300
  `exact settle (facilitator ${base2}): /verify request failed (${err instanceof Error ? err.message : String(err)}).`,
6222
6301
  { cause: err }
6223
6302
  );
6224
6303
  }
6225
6304
  if (verify.status !== 200) {
6226
- throw new (0, _chunkDCOUJZPLcjs.SettlementError)(
6305
+ throw new (0, _chunkGYM46G5Lcjs.SettlementError)(
6227
6306
  `exact settle (facilitator ${base2}): /verify returned HTTP ${verify.status} (transport/auth error).`
6228
6307
  );
6229
6308
  }
@@ -6239,13 +6318,13 @@ async function settleViaFacilitator(input) {
6239
6318
  try {
6240
6319
  settle = await post(`${base2}/settle`, body, auth);
6241
6320
  } catch (err) {
6242
- throw new (0, _chunkDCOUJZPLcjs.SettlementError)(
6321
+ throw new (0, _chunkGYM46G5Lcjs.SettlementError)(
6243
6322
  `exact settle (facilitator ${base2}): /settle request failed (${err instanceof Error ? err.message : String(err)}).`,
6244
6323
  { cause: err }
6245
6324
  );
6246
6325
  }
6247
6326
  if (settle.status !== 200) {
6248
- throw new (0, _chunkDCOUJZPLcjs.SettlementError)(
6327
+ throw new (0, _chunkGYM46G5Lcjs.SettlementError)(
6249
6328
  `exact settle (facilitator ${base2}): /settle returned HTTP ${settle.status} (transport/auth error).`
6250
6329
  );
6251
6330
  }
@@ -6661,7 +6740,7 @@ function createPaymentGate(options) {
6661
6740
  }
6662
6741
  net.assertValidPayTo(payTo);
6663
6742
  const { asset, decimals, symbol } = net.resolveToken(a.token);
6664
- const amountBase = _chunkDCOUJZPLcjs.parseUnits.call(void 0, a.amount, decimals);
6743
+ const amountBase = _chunkGYM46G5Lcjs.parseUnits.call(void 0, a.amount, decimals);
6665
6744
  const spec = { net, asset, decimals, symbol, amountBase, amountFormatted: a.amount, payTo };
6666
6745
  if (exactOption) {
6667
6746
  const outcome = await resolveExactRail(net, asset);
@@ -6684,7 +6763,7 @@ function createPaymentGate(options) {
6684
6763
  if (exactOption && !specs.some((s) => s.exact)) {
6685
6764
  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.";
6686
6765
  if (exactOption.settle === "keyless") {
6687
- if (typeof process === "undefined" || !_optionalChain([process, 'optionalAccess', _119 => _119.env, 'optionalAccess', _120 => _120.PIPRAIL_NO_HINTS])) {
6766
+ if (typeof process === "undefined" || !_optionalChain([process, 'optionalAccess', _123 => _123.env, 'optionalAccess', _124 => _124.PIPRAIL_NO_HINTS])) {
6688
6767
  console.warn(
6689
6768
  `[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.)`
6690
6769
  );
@@ -6712,7 +6791,7 @@ function createPaymentGate(options) {
6712
6791
  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).`
6713
6792
  };
6714
6793
  }
6715
- if (typeof process === "undefined" || _optionalChain([process, 'optionalAccess', _121 => _121.env, 'optionalAccess', _122 => _122.NODE_ENV]) !== "production" && !_optionalChain([process, 'optionalAccess', _123 => _123.env, 'optionalAccess', _124 => _124.PIPRAIL_NO_HINTS])) {
6794
+ if (typeof process === "undefined" || _optionalChain([process, 'optionalAccess', _125 => _125.env, 'optionalAccess', _126 => _126.NODE_ENV]) !== "production" && !_optionalChain([process, 'optionalAccess', _127 => _127.env, 'optionalAccess', _128 => _128.PIPRAIL_NO_HINTS])) {
6716
6795
  console.warn(
6717
6796
  `[piprail] exact: keyless rail on ${net.network} auto-settles via ${picked.url} (zero-config; pin \`exact.settle.facilitator\` in production).`
6718
6797
  );
@@ -6793,7 +6872,7 @@ function createPaymentGate(options) {
6793
6872
  if (hasCustomStore) {
6794
6873
  return options.isUsed ? Boolean(await options.isUsed(ref)) : false;
6795
6874
  }
6796
- const key = ref.toLowerCase();
6875
+ const key = ref.startsWith("pid:") ? ref : ref.toLowerCase();
6797
6876
  const now = Date.now();
6798
6877
  pruneUsed(now);
6799
6878
  if (localUsed.has(key)) return true;
@@ -6805,7 +6884,7 @@ function createPaymentGate(options) {
6805
6884
  if (ok && options.markUsed) await options.markUsed(ref);
6806
6885
  return;
6807
6886
  }
6808
- if (!ok) localUsed.delete(ref.toLowerCase());
6887
+ if (!ok) localUsed.delete(ref.startsWith("pid:") ? ref : ref.toLowerCase());
6809
6888
  }
6810
6889
  function buildAccept(s, nonce) {
6811
6890
  return {
@@ -6856,7 +6935,7 @@ function createPaymentGate(options) {
6856
6935
  extra: {
6857
6936
  assetTransferMethod: "permit2-upto",
6858
6937
  // facilitatorAddress comes from rail.extra; the spread below carries it (+ name/version).
6859
- facilitatorAddress: _nullishCoalesce(_optionalChain([rail, 'access', _125 => _125.extra, 'optionalAccess', _126 => _126.facilitatorAddress]), () => ( "")),
6938
+ facilitatorAddress: _nullishCoalesce(_optionalChain([rail, 'access', _129 => _129.extra, 'optionalAccess', _130 => _130.facilitatorAddress]), () => ( "")),
6860
6939
  minConfirmations,
6861
6940
  decimals: s.decimals,
6862
6941
  amountFormatted: s.amountFormatted,
@@ -6878,6 +6957,7 @@ function createPaymentGate(options) {
6878
6957
  const specs = await ready();
6879
6958
  const nonce = genNonce();
6880
6959
  const bazaar = options.discovery ? { bazaar: buildBazaarExtension(options.discovery === true ? {} : options.discovery) } : void 0;
6960
+ const paymentIdAd = options.paymentIdentifier ? buildPaymentIdentifierAdvertisement() : void 0;
6881
6961
  const accepts = buildAccepts(specs, nonce);
6882
6962
  const endpointInfo = buildEndpointInfo({
6883
6963
  ...options.description ? { description: options.description } : {},
@@ -6890,16 +6970,18 @@ function createPaymentGate(options) {
6890
6970
  ...endpointInfo ? { endpoint: endpointInfo } : {},
6891
6971
  ...receiptsOn ? { verifiableReceipts: true } : {}
6892
6972
  });
6893
- const rejectionExt = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _127 => _127.extensions]), () => ( {}));
6973
+ const rejectionExt = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _131 => _131.extensions]), () => ( {}));
6894
6974
  const rejectionPiprail = _nullishCoalesce(rejectionExt.piprail, () => ( {}));
6895
6975
  const bodyPiprail = { ..._nullishCoalesce(selfDescribe, () => ( {})), ...rejectionPiprail };
6896
6976
  const bodyExtensions = {
6897
6977
  ...bazaar,
6978
+ ...paymentIdAd,
6898
6979
  ...rejectionExt,
6899
6980
  ...Object.keys(bodyPiprail).length > 0 ? { piprail: bodyPiprail } : {}
6900
6981
  };
6901
6982
  const headerExtensions = {
6902
6983
  ...bazaar,
6984
+ ...paymentIdAd,
6903
6985
  ...Object.keys(rejectionPiprail).length > 0 ? { piprail: rejectionPiprail } : {}
6904
6986
  };
6905
6987
  const challenge2 = {
@@ -6910,7 +6992,7 @@ function createPaymentGate(options) {
6910
6992
  ...options.mimeType ? { mimeType: options.mimeType } : {}
6911
6993
  },
6912
6994
  accepts,
6913
- ..._optionalChain([opts, 'optionalAccess', _128 => _128.error]) ? { error: opts.error } : {},
6995
+ ..._optionalChain([opts, 'optionalAccess', _132 => _132.error]) ? { error: opts.error } : {},
6914
6996
  ...Object.keys(bodyExtensions).length > 0 ? { extensions: bodyExtensions } : {}
6915
6997
  };
6916
6998
  const headerChallenge = {
@@ -6941,7 +7023,7 @@ function createPaymentGate(options) {
6941
7023
  function enrichReceipt(spec, receipt) {
6942
7024
  let amountFormatted = receipt.amount;
6943
7025
  try {
6944
- amountFormatted = _chunkDCOUJZPLcjs.formatUnits.call(void 0, BigInt(receipt.amount), spec.decimals);
7026
+ amountFormatted = _chunkGYM46G5Lcjs.formatUnits.call(void 0, BigInt(receipt.amount), spec.decimals);
6945
7027
  } catch (e47) {
6946
7028
  }
6947
7029
  return {
@@ -7109,7 +7191,17 @@ function createPaymentGate(options) {
7109
7191
  await settleTx(ref, false);
7110
7192
  return rejection(result.error, result.detail);
7111
7193
  }
7112
- await settleTx(ref, true);
7194
+ const verified = result.receipt.transaction;
7195
+ if (verified && verified !== ref) {
7196
+ if (await claimTx(verified)) {
7197
+ await settleTx(ref, false);
7198
+ return rejection("tx_already_used", `Payment ${verified} was already redeemed.`);
7199
+ }
7200
+ await settleTx(ref, false);
7201
+ await settleTx(verified, true);
7202
+ } else {
7203
+ await settleTx(ref, true);
7204
+ }
7113
7205
  await deliverOnPaid(spec, result.receipt);
7114
7206
  return await buildPaidResult(spec, result.receipt, sig.payload.nonce);
7115
7207
  }
@@ -7183,7 +7275,7 @@ function createPaymentGate(options) {
7183
7275
  const ftMethod = accept.extra.assetTransferMethod;
7184
7276
  const needsFeePayer = ftMethod === "svm" || ftMethod === "algorand" || ftMethod === "aptos" || ftMethod === "near";
7185
7277
  if (needsFeePayer && !accept.extra.feePayer) {
7186
- throw new (0, _chunkDCOUJZPLcjs.SettlementError)(
7278
+ throw new (0, _chunkGYM46G5Lcjs.SettlementError)(
7187
7279
  `exact settle: the ${ftMethod} facilitator rail is missing extra.feePayer (the gas sponsor) \u2014 cannot settle.`
7188
7280
  );
7189
7281
  }
@@ -7231,15 +7323,15 @@ function createPaymentGate(options) {
7231
7323
  if (s.endsWith("%")) {
7232
7324
  const pct = s.slice(0, -1).trim();
7233
7325
  if (!/^\d+(\.\d+)?$/.test(pct)) return null;
7234
- const pctScaled = _chunkDCOUJZPLcjs.floorUnits.call(void 0, pct, 4);
7326
+ const pctScaled = _chunkGYM46G5Lcjs.floorUnits.call(void 0, pct, 4);
7235
7327
  return maxAmount * pctScaled / (100n * 10n ** 4n);
7236
7328
  }
7237
7329
  if (s.startsWith("$")) {
7238
7330
  const amt = s.slice(1).trim();
7239
- return _chunkDCOUJZPLcjs.floorUnits.call(void 0, amt, decimals);
7331
+ return _chunkGYM46G5Lcjs.floorUnits.call(void 0, amt, decimals);
7240
7332
  }
7241
7333
  if (/^\d+$/.test(s)) return BigInt(s);
7242
- return _chunkDCOUJZPLcjs.floorUnits.call(void 0, s, decimals);
7334
+ return _chunkGYM46G5Lcjs.floorUnits.call(void 0, s, decimals);
7243
7335
  } catch (e56) {
7244
7336
  return null;
7245
7337
  }
@@ -7290,7 +7382,7 @@ function createPaymentGate(options) {
7290
7382
  result = await spec.net.settleUptoSelf({ relayer, payload: upto.payload, accept, settleAmount });
7291
7383
  } catch (err) {
7292
7384
  await settleTx(nonce, false);
7293
- if (err instanceof _chunkDCOUJZPLcjs.SettlementError) throw err;
7385
+ if (err instanceof _chunkGYM46G5Lcjs.SettlementError) throw err;
7294
7386
  return rejection(
7295
7387
  "tx_reverted",
7296
7388
  `upto: metering/settle failed (${err instanceof Error ? err.message : String(err)}).`
@@ -7315,7 +7407,7 @@ function createPaymentGate(options) {
7315
7407
  if (result.kind === "invalid") await deliverOnFailed(result);
7316
7408
  return result;
7317
7409
  }
7318
- async function resolveVerdictObject(obj) {
7410
+ async function routeVerdictObject(obj) {
7319
7411
  if (obj === void 0 || obj === null) return asChallenge();
7320
7412
  const sig = parseSignatureObject(obj);
7321
7413
  if (sig && sig.accepted && typeof sig.accepted.network === "string" && typeof sig.accepted.asset === "string") {
@@ -7327,11 +7419,49 @@ function createPaymentGate(options) {
7327
7419
  if (exact) return verifyExact(exact);
7328
7420
  return asChallenge();
7329
7421
  }
7422
+ function echoPaymentIdentifier(result, id) {
7423
+ try {
7424
+ const decoded = decodeBase64Json(result.receiptHeader);
7425
+ if (!decoded) return result;
7426
+ const { extensions: existing, ...receiptOnly } = decoded;
7427
+ const merged = {
7428
+ ..._nullishCoalesce(existing, () => ( {})),
7429
+ [EXT_PAYMENT_IDENTIFIER]: { info: { required: false, id } }
7430
+ };
7431
+ return { ...result, receiptHeader: buildReceiptHeader(receiptOnly, merged) };
7432
+ } catch (e57) {
7433
+ return result;
7434
+ }
7435
+ }
7436
+ async function resolveVerdictObject(obj) {
7437
+ if (!options.paymentIdentifier) return routeVerdictObject(obj);
7438
+ const id = readPaymentIdentifier(obj);
7439
+ if (id !== null && typeof id === "object") {
7440
+ return rejection("signature_invalid", `payment-identifier: ${id.invalid}.`);
7441
+ }
7442
+ if (id === null) return routeVerdictObject(obj);
7443
+ const idKey = "pid:" + id;
7444
+ if (await claimTx(idKey)) {
7445
+ return rejection(
7446
+ "tx_already_used",
7447
+ `Idempotency id "${id}" is already bound to a settled payment; use a fresh id for a new payment.`
7448
+ );
7449
+ }
7450
+ let result;
7451
+ try {
7452
+ result = await routeVerdictObject(obj);
7453
+ } catch (err) {
7454
+ await settleTx(idKey, false);
7455
+ throw err;
7456
+ }
7457
+ await settleTx(idKey, result.kind === "paid");
7458
+ return result.kind === "paid" ? echoPaymentIdentifier(result, id) : result;
7459
+ }
7330
7460
  return { challenge, verify, verifyObject, describe, landingPage };
7331
7461
  }
7332
7462
  function requirePayment(options) {
7333
7463
  if (options.upto) {
7334
- throw new (_class3 = class extends _chunkDCOUJZPLcjs.PipRailError {constructor(...args2) { super(...args2); _class3.prototype.__init7.call(this); }
7464
+ throw new (_class3 = class extends _chunkGYM46G5Lcjs.PipRailError {constructor(...args2) { super(...args2); _class3.prototype.__init7.call(this); }
7335
7465
  __init7() {this.code = "UNSUPPORTED_SCHEME"}
7336
7466
  }, _class3)(
7337
7467
  "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."
@@ -7343,7 +7473,7 @@ function requirePayment(options) {
7343
7473
  try {
7344
7474
  result = await gate.verify(_nullishCoalesce(req.headers[HEADER_SIGNATURE], () => ( req.headers[HEADER_SIGNATURE_V1])));
7345
7475
  } catch (err) {
7346
- if (err instanceof _chunkDCOUJZPLcjs.SettlementError) {
7476
+ if (err instanceof _chunkGYM46G5Lcjs.SettlementError) {
7347
7477
  res.status(502);
7348
7478
  res.json({
7349
7479
  x402Version: 2,
@@ -7391,7 +7521,7 @@ function isRetryableStatus(status) {
7391
7521
  }
7392
7522
  var sleep = (ms) => ms > 0 ? new Promise((resolve) => setTimeout(resolve, ms)) : Promise.resolve();
7393
7523
  async function signBody(secret, body) {
7394
- const subtle = _optionalChain([globalThis, 'access', _129 => _129.crypto, 'optionalAccess', _130 => _130.subtle]);
7524
+ const subtle = _optionalChain([globalThis, 'access', _133 => _133.crypto, 'optionalAccess', _134 => _134.subtle]);
7395
7525
  if (!subtle) return null;
7396
7526
  try {
7397
7527
  const enc = new TextEncoder();
@@ -7401,7 +7531,7 @@ async function signBody(secret, body) {
7401
7531
  const sig = await subtle.sign("HMAC", key, enc.encode(body));
7402
7532
  const hex = Array.from(new Uint8Array(sig)).map((b) => b.toString(16).padStart(2, "0")).join("");
7403
7533
  return `sha256=${hex}`;
7404
- } catch (e57) {
7534
+ } catch (e58) {
7405
7535
  return null;
7406
7536
  }
7407
7537
  }
@@ -7461,8 +7591,8 @@ async function deliverReceipt(receipt, options) {
7461
7591
  const retryable = status === void 0 ? true : isRetryableStatus(status);
7462
7592
  const willRetry = !ok && retryable && attempt < maxAttempts;
7463
7593
  try {
7464
- _optionalChain([onAttempt, 'optionalCall', _131 => _131({ attempt, ok, ...status !== void 0 ? { status } : {}, ...error ? { error } : {}, willRetry })]);
7465
- } catch (e58) {
7594
+ _optionalChain([onAttempt, 'optionalCall', _135 => _135({ attempt, ok, ...status !== void 0 ? { status } : {}, ...error ? { error } : {}, willRetry })]);
7595
+ } catch (e59) {
7466
7596
  }
7467
7597
  if (ok) return { delivered: true, attempts: attempt, status };
7468
7598
  if (!willRetry) {
@@ -7550,13 +7680,13 @@ function toA2APaymentFailed(code, detail, receipts = [], network) {
7550
7680
  };
7551
7681
  }
7552
7682
  function fromA2APaymentRequired(task) {
7553
- const meta = _optionalChain([task, 'access', _132 => _132.status, 'optionalAccess', _133 => _133.message, 'optionalAccess', _134 => _134.metadata]);
7554
- const required = _optionalChain([meta, 'optionalAccess', _135 => _135[A2A_REQUIRED_KEY]]);
7683
+ const meta = _optionalChain([task, 'access', _136 => _136.status, 'optionalAccess', _137 => _137.message, 'optionalAccess', _138 => _138.metadata]);
7684
+ const required = _optionalChain([meta, 'optionalAccess', _139 => _139[A2A_REQUIRED_KEY]]);
7555
7685
  if (!required || typeof required !== "object") return null;
7556
7686
  return required;
7557
7687
  }
7558
7688
  function fromA2APaymentPayload(message) {
7559
- const raw = _optionalChain([message, 'access', _136 => _136.metadata, 'optionalAccess', _137 => _137[A2A_PAYLOAD_KEY]]);
7689
+ const raw = _optionalChain([message, 'access', _140 => _140.metadata, 'optionalAccess', _141 => _141[A2A_PAYLOAD_KEY]]);
7560
7690
  if (raw === void 0 || raw === null) return null;
7561
7691
  return { raw, taskId: _nullishCoalesce(message.taskId, () => ( "")) };
7562
7692
  }
@@ -7589,7 +7719,7 @@ function createA2APaymentHandler(options) {
7589
7719
  const ttlMs = _nullishCoalesce(options.taskTtlMs, () => ( maxTimeoutSeconds * 1e3));
7590
7720
  const store = _nullishCoalesce(options.taskStore, () => ( defaultTaskStore()));
7591
7721
  function appendReceipt(taskId, entry) {
7592
- const prior = _nullishCoalesce(_optionalChain([store, 'access', _138 => _138.get, 'call', _139 => _139(taskId), 'optionalAccess', _140 => _140.receipts]), () => ( []));
7722
+ const prior = _nullishCoalesce(_optionalChain([store, 'access', _142 => _142.get, 'call', _143 => _143(taskId), 'optionalAccess', _144 => _144.receipts]), () => ( []));
7593
7723
  const isDup = "success" in entry && entry.success === true && entry.transaction !== "" && prior.some((r) => "transaction" in r && r.transaction === entry.transaction);
7594
7724
  const next = isDup ? prior : [...prior, entry];
7595
7725
  const receipts = next.length > MAX_TASK_RECEIPTS ? next.slice(-MAX_TASK_RECEIPTS) : next;
@@ -7665,7 +7795,7 @@ function createA2APaymentHandler(options) {
7665
7795
  try {
7666
7796
  result = await gate.verifyObject(inbound.raw);
7667
7797
  } catch (err) {
7668
- if (err instanceof _chunkDCOUJZPLcjs.SettlementError) {
7798
+ if (err instanceof _chunkGYM46G5Lcjs.SettlementError) {
7669
7799
  return failedTask(id, "settlement_failed", err.message, attempted);
7670
7800
  }
7671
7801
  const detail = err instanceof Error ? err.message : String(err);
@@ -7697,11 +7827,11 @@ function createA2APaymentHandler(options) {
7697
7827
  }
7698
7828
  }
7699
7829
  function agentCardExtension(opts) {
7700
- const uri = _optionalChain([opts, 'optionalAccess', _141 => _141.version]) === "v0.2" ? A2A_X402_EXTENSION_URI_V02 : A2A_X402_EXTENSION_URI_V01;
7830
+ const uri = _optionalChain([opts, 'optionalAccess', _145 => _145.version]) === "v0.2" ? A2A_X402_EXTENSION_URI_V02 : A2A_X402_EXTENSION_URI_V01;
7701
7831
  return {
7702
7832
  uri,
7703
7833
  description: "Supports payments using the x402 protocol for on-chain settlement.",
7704
- ..._optionalChain([opts, 'optionalAccess', _142 => _142.required]) ? { required: true } : {}
7834
+ ..._optionalChain([opts, 'optionalAccess', _146 => _146.required]) ? { required: true } : {}
7705
7835
  };
7706
7836
  }
7707
7837
  return { handleMessage, agentCardExtension, gate };
@@ -7712,7 +7842,7 @@ function singleNetworkOf(challenge) {
7712
7842
  }
7713
7843
  function networkFromPayload(raw) {
7714
7844
  const v = raw;
7715
- if (v && typeof _optionalChain([v, 'access', _143 => _143.accepted, 'optionalAccess', _144 => _144.network]) === "string") return v.accepted.network;
7845
+ if (v && typeof _optionalChain([v, 'access', _147 => _147.accepted, 'optionalAccess', _148 => _148.network]) === "string") return v.accepted.network;
7716
7846
  if (v && typeof v.network === "string") return v.network;
7717
7847
  return void 0;
7718
7848
  }
@@ -7727,6 +7857,129 @@ function resourceUrlFromMessage(message) {
7727
7857
  return "";
7728
7858
  }
7729
7859
 
7860
+ // src/transports/mcp-types.ts
7861
+ var MCP_PAYMENT_META_KEY = "x402/payment";
7862
+ var MCP_PAYMENT_RESPONSE_META_KEY = "x402/payment-response";
7863
+
7864
+ // src/transports/mcp.ts
7865
+ function toMcpPaymentRequired(challenge) {
7866
+ const text = JSON.stringify(challenge);
7867
+ return {
7868
+ isError: true,
7869
+ structuredContent: challenge,
7870
+ content: [{ type: "text", text }]
7871
+ };
7872
+ }
7873
+ function toMcpPaymentResponse(content, receipt) {
7874
+ return {
7875
+ content,
7876
+ _meta: {
7877
+ [MCP_PAYMENT_RESPONSE_META_KEY]: {
7878
+ success: true,
7879
+ transaction: receipt.transaction,
7880
+ network: receipt.network,
7881
+ payer: receipt.payer
7882
+ }
7883
+ }
7884
+ };
7885
+ }
7886
+ function fromMcpPayment(params) {
7887
+ const meta = _optionalChain([params, 'optionalAccess', _149 => _149._meta, 'optionalAccess', _150 => _150[MCP_PAYMENT_META_KEY]]);
7888
+ return meta == null ? null : meta;
7889
+ }
7890
+ function fromMcpPaymentRequired(result) {
7891
+ if (!result || result.isError !== true) return null;
7892
+ const sc = result.structuredContent;
7893
+ if (sc && typeof sc === "object" && typeof sc.x402Version === "number") {
7894
+ return sc;
7895
+ }
7896
+ const text = _optionalChain([result, 'access', _151 => _151.content, 'optionalAccess', _152 => _152[0], 'optionalAccess', _153 => _153.text]);
7897
+ if (typeof text === "string") {
7898
+ try {
7899
+ const parsed = JSON.parse(text);
7900
+ if (parsed && typeof parsed === "object" && typeof parsed.x402Version === "number") {
7901
+ return parsed;
7902
+ }
7903
+ } catch (e60) {
7904
+ }
7905
+ }
7906
+ return null;
7907
+ }
7908
+ function isMcpPaymentRequired(result) {
7909
+ return fromMcpPaymentRequired(result) != null;
7910
+ }
7911
+ function fromMcpPaymentResponse(result) {
7912
+ const meta = _optionalChain([result, 'optionalAccess', _154 => _154._meta, 'optionalAccess', _155 => _155[MCP_PAYMENT_RESPONSE_META_KEY]]);
7913
+ if (!meta || typeof meta !== "object") return null;
7914
+ return meta;
7915
+ }
7916
+ function buildMcpPaymentMeta(input) {
7917
+ return {
7918
+ [MCP_PAYMENT_META_KEY]: {
7919
+ x402Version: _nullishCoalesce(input.x402Version, () => ( 2)),
7920
+ ...input.resource ? { resource: input.resource } : {},
7921
+ accepted: input.accepted,
7922
+ payload: input.payload
7923
+ }
7924
+ };
7925
+ }
7926
+ function createMcpPaymentTool(options) {
7927
+ const gate = _nullishCoalesce(options.gate, () => ( createPaymentGate(options)));
7928
+ function settlementFailed(code, detail) {
7929
+ return {
7930
+ isError: true,
7931
+ content: [
7932
+ {
7933
+ type: "text",
7934
+ text: `x402 settlement failed (${toA2AErrorCode(code)}): ${detail}. The buyer can retry, or pay the onchain-proof rail directly.`
7935
+ }
7936
+ ]
7937
+ };
7938
+ }
7939
+ async function handleToolCall(params) {
7940
+ const raw = fromMcpPayment(params);
7941
+ if (raw == null) {
7942
+ const { challenge } = await gate.challenge(_nullishCoalesce(options.resourceUrl, () => ( "")));
7943
+ return toMcpPaymentRequired(challenge);
7944
+ }
7945
+ let result;
7946
+ try {
7947
+ result = await gate.verifyObject(raw);
7948
+ } catch (err) {
7949
+ if (err instanceof _chunkGYM46G5Lcjs.SettlementError) return settlementFailed("settlement_failed", err.message);
7950
+ throw err;
7951
+ }
7952
+ if (result.kind === "paid") {
7953
+ try {
7954
+ const content = await options.fulfill({ receipt: result.receipt, params });
7955
+ return toMcpPaymentResponse(content, result.receipt);
7956
+ } catch (err) {
7957
+ const detail = err instanceof Error ? err.message : String(err);
7958
+ return toMcpPaymentResponse(
7959
+ [{ type: "text", text: `Payment settled (tx ${result.receipt.transaction}), but serving the result failed: ${detail}` }],
7960
+ result.receipt
7961
+ );
7962
+ }
7963
+ }
7964
+ return toMcpPaymentRequired(result.challenge);
7965
+ }
7966
+ return { handleToolCall, gate };
7967
+ }
7968
+
7969
+
7970
+
7971
+
7972
+
7973
+
7974
+
7975
+
7976
+
7977
+
7978
+
7979
+
7980
+
7981
+
7982
+
7730
7983
 
7731
7984
 
7732
7985
 
@@ -7859,4 +8112,4 @@ function resourceUrlFromMessage(message) {
7859
8112
 
7860
8113
 
7861
8114
 
7862
- 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 = _chunkDCOUJZPLcjs.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.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 = _chunkDCOUJZPLcjs.InsufficientFundsError; exports.InvalidEnvelopeError = _chunkDCOUJZPLcjs.InvalidEnvelopeError; exports.KNOWN_FACILITATORS = KNOWN_FACILITATORS; exports.MaxRetriesExceededError = _chunkDCOUJZPLcjs.MaxRetriesExceededError; exports.MissingDriverError = _chunkDCOUJZPLcjs.MissingDriverError; exports.MultiChainPayer = MultiChainPayer; exports.NoCompatibleAcceptError = _chunkDCOUJZPLcjs.NoCompatibleAcceptError; exports.NonReplayableBodyError = _chunkDCOUJZPLcjs.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 = _chunkDCOUJZPLcjs.PaymentDeclinedError; exports.PaymentTimeoutError = _chunkDCOUJZPLcjs.PaymentTimeoutError; exports.PipRailClient = PipRailClient; exports.PipRailError = _chunkDCOUJZPLcjs.PipRailError; exports.REGISTER_ATTRIBUTION = REGISTER_ATTRIBUTION; exports.RecipientNotReadyError = _chunkDCOUJZPLcjs.RecipientNotReadyError; exports.SettlementError = _chunkDCOUJZPLcjs.SettlementError; exports.SpendLedger = SpendLedger; exports.UPTO_PROXY_CHAIN_IDS = UPTO_PROXY_CHAIN_IDS; exports.UnknownTokenError = _chunkDCOUJZPLcjs.UnknownTokenError; exports.UnsupportedNetworkError = _chunkDCOUJZPLcjs.UnsupportedNetworkError; exports.UnsupportedSchemeError = _chunkDCOUJZPLcjs.UnsupportedSchemeError; exports.VERIFY_CODE_TO_A2A_ERROR = VERIFY_CODE_TO_A2A_ERROR; exports.WalletRequiredError = _chunkDCOUJZPLcjs.WalletRequiredError; exports.WrongChainError = _chunkDCOUJZPLcjs.WrongChainError; exports.WrongFamilyError = _chunkDCOUJZPLcjs.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.buildOpenApi = buildOpenApi; exports.buildReceiptExtension = buildReceiptExtension; exports.buildReceiptHeader = buildReceiptHeader; exports.buildSelfDescription = buildSelfDescription; exports.buildSignatureHeader = buildSignatureHeader; exports.buildUptoSignatureHeader = buildUptoSignatureHeader; exports.buildWellKnownX402 = buildWellKnownX402; exports.buildX402DnsTxt = buildX402DnsTxt; exports.chainIdForExactNetwork = chainIdForExactNetwork; exports.claim402IndexDomain = claim402IndexDomain; exports.classifyChallenge = classifyChallenge; exports.createA2APaymentHandler = createA2APaymentHandler; exports.createPaymentGate = createPaymentGate; 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.getDirectoryInfo = getDirectoryInfo; 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.rankResources = rankResources; exports.readExactDomain = readExactDomain; 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.toInsufficientFundsError = _chunkDCOUJZPLcjs.toInsufficientFundsError; exports.toInvalidBody = toInvalidBody; exports.verify402IndexDomain = verify402IndexDomain;
8115
+ 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 = _chunkGYM46G5Lcjs.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 = _chunkGYM46G5Lcjs.InsufficientFundsError; exports.InvalidEnvelopeError = _chunkGYM46G5Lcjs.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 = _chunkGYM46G5Lcjs.MaxRetriesExceededError; exports.MissingDriverError = _chunkGYM46G5Lcjs.MissingDriverError; exports.MultiChainPayer = MultiChainPayer; exports.NoCompatibleAcceptError = _chunkGYM46G5Lcjs.NoCompatibleAcceptError; exports.NonReplayableBodyError = _chunkGYM46G5Lcjs.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 = _chunkGYM46G5Lcjs.PaymentDeclinedError; exports.PaymentTimeoutError = _chunkGYM46G5Lcjs.PaymentTimeoutError; exports.PipRailClient = PipRailClient; exports.PipRailError = _chunkGYM46G5Lcjs.PipRailError; exports.REGISTER_ATTRIBUTION = REGISTER_ATTRIBUTION; exports.RecipientNotReadyError = _chunkGYM46G5Lcjs.RecipientNotReadyError; exports.SettlementError = _chunkGYM46G5Lcjs.SettlementError; exports.SpendLedger = SpendLedger; exports.UPTO_PROXY_CHAIN_IDS = UPTO_PROXY_CHAIN_IDS; exports.UnknownTokenError = _chunkGYM46G5Lcjs.UnknownTokenError; exports.UnsupportedNetworkError = _chunkGYM46G5Lcjs.UnsupportedNetworkError; exports.UnsupportedSchemeError = _chunkGYM46G5Lcjs.UnsupportedSchemeError; exports.VERIFY_CODE_TO_A2A_ERROR = VERIFY_CODE_TO_A2A_ERROR; exports.WalletRequiredError = _chunkGYM46G5Lcjs.WalletRequiredError; exports.WrongChainError = _chunkGYM46G5Lcjs.WrongChainError; exports.WrongFamilyError = _chunkGYM46G5Lcjs.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.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.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.toInsufficientFundsError = _chunkGYM46G5Lcjs.toInsufficientFundsError; exports.toInvalidBody = toInvalidBody; exports.toMcpPaymentRequired = toMcpPaymentRequired; exports.toMcpPaymentResponse = toMcpPaymentResponse; exports.verify402IndexDomain = verify402IndexDomain;