@piprail/sdk 2.6.0 → 2.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -24,7 +24,7 @@
24
24
 
25
25
 
26
26
 
27
- var _chunkJG6KRAW6cjs = require('./chunk-JG6KRAW6.cjs');
27
+ var _chunkVPENSVOIcjs = require('./chunk-VPENSVOI.cjs');
28
28
 
29
29
  // src/drivers/registry.ts
30
30
  var byFamily = /* @__PURE__ */ new Map();
@@ -53,13 +53,13 @@ function resolveNetwork(opts) {
53
53
  const family = familyForChain(opts.chain);
54
54
  const driver = byFamily.get(family);
55
55
  if (!driver) {
56
- throw new (0, _chunkJG6KRAW6cjs.UnsupportedNetworkError)(
56
+ throw new (0, _chunkVPENSVOIcjs.UnsupportedNetworkError)(
57
57
  `No driver registered for the "${family}" family \u2014 it may not be mounted yet (use the async resolveNetwork()).`
58
58
  );
59
59
  }
60
60
  const net = driver.resolve(opts);
61
61
  if (!net) {
62
- throw new (0, _chunkJG6KRAW6cjs.UnsupportedNetworkError)(
62
+ throw new (0, _chunkVPENSVOIcjs.UnsupportedNetworkError)(
63
63
  `The ${family} driver didn't recognise this chain input.`
64
64
  );
65
65
  }
@@ -320,12 +320,12 @@ function resolveChain(input, rpcUrlOverride) {
320
320
 
321
321
  var _accounts = require('viem/accounts');
322
322
  function createWalletAdapter(config, resolved) {
323
- _chunkJG6KRAW6cjs.assertNoLegacyWalletKey.call(void 0, config, "EVM");
323
+ _chunkVPENSVOIcjs.assertNoLegacyWalletKey.call(void 0, config, "EVM");
324
324
  if ("key" in config) {
325
325
  const key = config.key;
326
326
  if (typeof key !== "string" || !/^0x[0-9a-fA-F]{64}$/.test(key)) {
327
327
  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).";
328
- throw new (0, _chunkJG6KRAW6cjs.WrongFamilyError)(
328
+ throw new (0, _chunkVPENSVOIcjs.WrongFamilyError)(
329
329
  `chain is EVM; the wallet { key } is not a valid 0x\u2026 32-byte hex private key${hint}`
330
330
  );
331
331
  }
@@ -333,7 +333,7 @@ function createWalletAdapter(config, resolved) {
333
333
  try {
334
334
  account = _accounts.privateKeyToAccount.call(void 0, key);
335
335
  } catch (err) {
336
- throw new (0, _chunkJG6KRAW6cjs.WrongFamilyError)(
336
+ throw new (0, _chunkVPENSVOIcjs.WrongFamilyError)(
337
337
  `chain is EVM; the wallet { key } is not a valid 0x\u2026 32-byte hex private key: ${err instanceof Error ? err.message : String(err)}.`
338
338
  );
339
339
  }
@@ -343,12 +343,12 @@ function createWalletAdapter(config, resolved) {
343
343
  }
344
344
  const wc = config.walletClient;
345
345
  if (!wc.account) {
346
- throw new (0, _chunkJG6KRAW6cjs.WrongFamilyError)(
346
+ throw new (0, _chunkVPENSVOIcjs.WrongFamilyError)(
347
347
  "chain is EVM; the provided walletClient has no attached account. Use `createWalletClient({ account, chain, transport })`, or pass { key }."
348
348
  );
349
349
  }
350
350
  if (wc.chain && wc.chain.id !== resolved.chainId) {
351
- throw new (0, _chunkJG6KRAW6cjs.WrongChainError)(
351
+ throw new (0, _chunkVPENSVOIcjs.WrongChainError)(
352
352
  `PipRailClient: walletClient is on chain ${wc.chain.id} but the SDK was configured with chain ${resolved.chainId}. They must match.`
353
353
  );
354
354
  }
@@ -678,7 +678,7 @@ async function payExactEvm(input) {
678
678
  code = void 0;
679
679
  }
680
680
  if (code && code !== "0x") {
681
- throw new (0, _chunkJG6KRAW6cjs.UnsupportedSchemeError)(
681
+ throw new (0, _chunkVPENSVOIcjs.UnsupportedSchemeError)(
682
682
  `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.`
683
683
  );
684
684
  }
@@ -688,13 +688,13 @@ async function payExactEvm(input) {
688
688
  domain = await readExactDomain(publicClient, accept.asset);
689
689
  }
690
690
  if (!domain) {
691
- throw new (0, _chunkJG6KRAW6cjs.UnsupportedSchemeError)(
691
+ throw new (0, _chunkVPENSVOIcjs.UnsupportedSchemeError)(
692
692
  `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.`
693
693
  );
694
694
  }
695
695
  const g = globalThis.crypto;
696
696
  if (!_optionalChain([g, 'optionalAccess', _5 => _5.getRandomValues])) {
697
- throw new (0, _chunkJG6KRAW6cjs.UnsupportedSchemeError)(
697
+ throw new (0, _chunkVPENSVOIcjs.UnsupportedSchemeError)(
698
698
  "this runtime lacks Web Crypto (globalThis.crypto.getRandomValues); the exact rail needs a CSPRNG nonce."
699
699
  );
700
700
  }
@@ -951,7 +951,7 @@ async function verifyAndSettleExactEvm(input) {
951
951
  args: writeArgs
952
952
  });
953
953
  } catch (err) {
954
- throw new (0, _chunkJG6KRAW6cjs.SettlementError)(
954
+ throw new (0, _chunkVPENSVOIcjs.SettlementError)(
955
955
  `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.`,
956
956
  { cause: err }
957
957
  );
@@ -963,7 +963,7 @@ async function verifyAndSettleExactEvm(input) {
963
963
  return { ok: false, error: "tx_reverted", detail: `Settlement tx ${txHash} reverted on-chain.` };
964
964
  }
965
965
  } catch (err) {
966
- throw new (0, _chunkJG6KRAW6cjs.SettlementError)(
966
+ throw new (0, _chunkVPENSVOIcjs.SettlementError)(
967
967
  `exact settle: broadcast ${txHash} but couldn't confirm it (${shorten(err instanceof Error ? err.message : String(err))}).`,
968
968
  { cause: err }
969
969
  );
@@ -1094,7 +1094,7 @@ function shorten2(msg) {
1094
1094
  function randomPermit2Nonce() {
1095
1095
  const g = globalThis.crypto;
1096
1096
  if (!_optionalChain([g, 'optionalAccess', _8 => _8.getRandomValues])) {
1097
- throw new (0, _chunkJG6KRAW6cjs.UnsupportedSchemeError)(
1097
+ throw new (0, _chunkVPENSVOIcjs.UnsupportedSchemeError)(
1098
1098
  "this runtime lacks Web Crypto (globalThis.crypto.getRandomValues); the permit2 rail needs a CSPRNG nonce."
1099
1099
  );
1100
1100
  }
@@ -1113,7 +1113,7 @@ async function ensurePermit2Allowance(input) {
1113
1113
  args: [account.address, PERMIT2_ADDRESS]
1114
1114
  });
1115
1115
  } catch (err) {
1116
- throw new (0, _chunkJG6KRAW6cjs.UnsupportedSchemeError)(
1116
+ throw new (0, _chunkVPENSVOIcjs.UnsupportedSchemeError)(
1117
1117
  `permit2: couldn't read the Permit2 allowance for ${token} (${shorten2(err instanceof Error ? err.message : String(err))}).`
1118
1118
  );
1119
1119
  }
@@ -1130,7 +1130,7 @@ async function ensurePermit2Allowance(input) {
1130
1130
  await publicClient.waitForTransactionReceipt({ hash, confirmations: 1 });
1131
1131
  return hash;
1132
1132
  } catch (err) {
1133
- throw _nullishCoalesce(_chunkJG6KRAW6cjs.toInsufficientFundsError.call(void 0, err), () => ( new (0, _chunkJG6KRAW6cjs.SettlementError)(
1133
+ throw _nullishCoalesce(_chunkVPENSVOIcjs.toInsufficientFundsError.call(void 0, err), () => ( new (0, _chunkVPENSVOIcjs.SettlementError)(
1134
1134
  `permit2: the one-time Permit2 approval for ${token} failed to broadcast (${shorten2(err instanceof Error ? err.message : String(err))}).`,
1135
1135
  { cause: err }
1136
1136
  )));
@@ -1145,7 +1145,7 @@ async function payPermit2Evm(input) {
1145
1145
  code = void 0;
1146
1146
  }
1147
1147
  if (code && code !== "0x") {
1148
- throw new (0, _chunkJG6KRAW6cjs.UnsupportedSchemeError)(
1148
+ throw new (0, _chunkVPENSVOIcjs.UnsupportedSchemeError)(
1149
1149
  `permit2 buyer rail requires an EOA signer; ${account.address} is a contract / EIP-1271 / EIP-7702-delegated account. Pay via onchain-proof.`
1150
1150
  );
1151
1151
  }
@@ -1320,7 +1320,7 @@ async function verifyAndSettlePermit2Evm(input) {
1320
1320
  args: settleArgs
1321
1321
  });
1322
1322
  } catch (err) {
1323
- throw new (0, _chunkJG6KRAW6cjs.SettlementError)(
1323
+ throw new (0, _chunkVPENSVOIcjs.SettlementError)(
1324
1324
  `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.`,
1325
1325
  { cause: err }
1326
1326
  );
@@ -1332,7 +1332,7 @@ async function verifyAndSettlePermit2Evm(input) {
1332
1332
  return { ok: false, error: "tx_reverted", detail: `Settlement tx ${txHash} reverted on-chain.` };
1333
1333
  }
1334
1334
  } catch (err) {
1335
- throw new (0, _chunkJG6KRAW6cjs.SettlementError)(
1335
+ throw new (0, _chunkVPENSVOIcjs.SettlementError)(
1336
1336
  `permit2 settle: broadcast ${txHash} but couldn't confirm it (${shorten2(err instanceof Error ? err.message : String(err))}).`,
1337
1337
  { cause: err }
1338
1338
  );
@@ -1584,15 +1584,15 @@ function makeEvmNetwork(resolved) {
1584
1584
  const info = resolved.tokens[token.toUpperCase()];
1585
1585
  if (!info) {
1586
1586
  const known = Object.keys(resolved.tokens).join(", ") || "(none built in)";
1587
- throw new (0, _chunkJG6KRAW6cjs.UnknownTokenError)(
1587
+ throw new (0, _chunkVPENSVOIcjs.UnknownTokenError)(
1588
1588
  `token "${token}" isn't built in for ${resolved.chain.name} (known: ${known}). Pass { address, decimals } instead, or use 'native'.`
1589
1589
  );
1590
1590
  }
1591
1591
  return { asset: info.address, decimals: info.decimals, symbol: info.symbol };
1592
1592
  }
1593
- _chunkJG6KRAW6cjs.rejectForeignToken.call(void 0, token, "evm", network);
1593
+ _chunkVPENSVOIcjs.rejectForeignToken.call(void 0, token, "evm", network);
1594
1594
  if (!("address" in token)) {
1595
- throw new (0, _chunkJG6KRAW6cjs.WrongFamilyError)(
1595
+ throw new (0, _chunkVPENSVOIcjs.WrongFamilyError)(
1596
1596
  `chain ${network} is EVM; a custom token must be { address, decimals }.`
1597
1597
  );
1598
1598
  }
@@ -1624,20 +1624,20 @@ function makeEvmNetwork(resolved) {
1624
1624
  },
1625
1625
  assertValidPayTo(payTo) {
1626
1626
  if (!_viem.isAddress.call(void 0, payTo)) {
1627
- throw new (0, _chunkJG6KRAW6cjs.WrongFamilyError)(
1627
+ throw new (0, _chunkVPENSVOIcjs.WrongFamilyError)(
1628
1628
  `chain ${network} is EVM, but payTo "${payTo}" is not a valid 0x address.`
1629
1629
  );
1630
1630
  }
1631
1631
  },
1632
1632
  bindWallet(wallet) {
1633
1633
  if (typeof wallet !== "object" || wallet === null) {
1634
- throw new (0, _chunkJG6KRAW6cjs.WrongFamilyError)(
1634
+ throw new (0, _chunkVPENSVOIcjs.WrongFamilyError)(
1635
1635
  `chain ${network} is EVM; wallet must be { key } (0x\u2026 hex) or { walletClient }.`
1636
1636
  );
1637
1637
  }
1638
- _chunkJG6KRAW6cjs.assertNoLegacyWalletKey.call(void 0, wallet, "EVM");
1638
+ _chunkVPENSVOIcjs.assertNoLegacyWalletKey.call(void 0, wallet, "EVM");
1639
1639
  if (!("key" in wallet) && !("walletClient" in wallet)) {
1640
- throw new (0, _chunkJG6KRAW6cjs.WrongFamilyError)(
1640
+ throw new (0, _chunkVPENSVOIcjs.WrongFamilyError)(
1641
1641
  `chain ${network} is EVM; wallet must be { key } (0x\u2026 hex) or { walletClient }.`
1642
1642
  );
1643
1643
  }
@@ -1654,12 +1654,12 @@ function makeEvmNetwork(resolved) {
1654
1654
  });
1655
1655
  } catch (err) {
1656
1656
  if (isViemInsufficientFunds(err)) {
1657
- throw new (0, _chunkJG6KRAW6cjs.InsufficientFundsError)(
1657
+ throw new (0, _chunkVPENSVOIcjs.InsufficientFundsError)(
1658
1658
  err instanceof Error ? err.message : "Insufficient funds for payment.",
1659
1659
  { cause: err }
1660
1660
  );
1661
1661
  }
1662
- throw _nullishCoalesce(_chunkJG6KRAW6cjs.toInsufficientFundsError.call(void 0, err), () => ( err));
1662
+ throw _nullishCoalesce(_chunkVPENSVOIcjs.toInsufficientFundsError.call(void 0, err), () => ( err));
1663
1663
  }
1664
1664
  },
1665
1665
  async confirm(ref, minConfirmations) {
@@ -1670,7 +1670,7 @@ function makeEvmNetwork(resolved) {
1670
1670
  });
1671
1671
  return { height: receipt.blockNumber.toString() };
1672
1672
  } catch (err) {
1673
- throw new (0, _chunkJG6KRAW6cjs.ConfirmationTimeoutError)(
1673
+ throw new (0, _chunkVPENSVOIcjs.ConfirmationTimeoutError)(
1674
1674
  `EVM tx ${ref} did not reach ${minConfirmations} confirmation(s) in time.`,
1675
1675
  { cause: err }
1676
1676
  );
@@ -1680,7 +1680,7 @@ function makeEvmNetwork(resolved) {
1680
1680
  const { decimals, symbol } = resolved.chain.nativeCurrency;
1681
1681
  if (accept.scheme === "exact") {
1682
1682
  const permit2 = accept.extra.assetTransferMethod === "permit2";
1683
- return _chunkJG6KRAW6cjs.nativeCost.call(void 0, {
1683
+ return _chunkVPENSVOIcjs.nativeCost.call(void 0, {
1684
1684
  symbol,
1685
1685
  decimals,
1686
1686
  fee: 0n,
@@ -1691,7 +1691,7 @@ function makeEvmNetwork(resolved) {
1691
1691
  const gasLimit = accept.asset === "native" ? 21000n : 65000n;
1692
1692
  try {
1693
1693
  const gasPrice = await publicClient.getGasPrice();
1694
- return _chunkJG6KRAW6cjs.nativeCost.call(void 0, {
1694
+ return _chunkVPENSVOIcjs.nativeCost.call(void 0, {
1695
1695
  symbol,
1696
1696
  decimals,
1697
1697
  fee: gasPrice * gasLimit,
@@ -1700,7 +1700,7 @@ function makeEvmNetwork(resolved) {
1700
1700
  });
1701
1701
  } catch (e20) {
1702
1702
  const gasPrice = 5000000000n;
1703
- return _chunkJG6KRAW6cjs.nativeCost.call(void 0, {
1703
+ return _chunkVPENSVOIcjs.nativeCost.call(void 0, {
1704
1704
  symbol,
1705
1705
  decimals,
1706
1706
  fee: gasPrice * gasLimit,
@@ -1840,9 +1840,9 @@ var loaders = {
1840
1840
  solana: async () => {
1841
1841
  let mod;
1842
1842
  try {
1843
- mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./solana-M3VOHCMO.cjs")));
1843
+ mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./solana-L342QCSV.cjs")));
1844
1844
  } catch (cause) {
1845
- throw new (0, _chunkJG6KRAW6cjs.MissingDriverError)(
1845
+ throw new (0, _chunkVPENSVOIcjs.MissingDriverError)(
1846
1846
  `Solana selected, but its packages aren't installed. Run: npm install @solana/web3.js @solana/spl-token bs58`,
1847
1847
  { cause }
1848
1848
  );
@@ -1852,9 +1852,9 @@ var loaders = {
1852
1852
  ton: async () => {
1853
1853
  let mod;
1854
1854
  try {
1855
- mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./ton-MMPKWT6N.cjs")));
1855
+ mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./ton-LZKJWYHV.cjs")));
1856
1856
  } catch (cause) {
1857
- throw new (0, _chunkJG6KRAW6cjs.MissingDriverError)(
1857
+ throw new (0, _chunkVPENSVOIcjs.MissingDriverError)(
1858
1858
  `TON selected, but its packages aren't installed. Run: npm install @ton/ton @ton/core @ton/crypto`,
1859
1859
  { cause }
1860
1860
  );
@@ -1864,9 +1864,9 @@ var loaders = {
1864
1864
  stellar: async () => {
1865
1865
  let mod;
1866
1866
  try {
1867
- mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./stellar-FW6C6FBE.cjs")));
1867
+ mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./stellar-YEXRVR3W.cjs")));
1868
1868
  } catch (cause) {
1869
- throw new (0, _chunkJG6KRAW6cjs.MissingDriverError)(
1869
+ throw new (0, _chunkVPENSVOIcjs.MissingDriverError)(
1870
1870
  `Stellar selected, but its package isn't installed. Run: npm install @stellar/stellar-sdk`,
1871
1871
  { cause }
1872
1872
  );
@@ -1876,9 +1876,9 @@ var loaders = {
1876
1876
  xrpl: async () => {
1877
1877
  let mod;
1878
1878
  try {
1879
- mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./xrpl-PECT4IMX.cjs")));
1879
+ mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./xrpl-K3U3SBF4.cjs")));
1880
1880
  } catch (cause) {
1881
- throw new (0, _chunkJG6KRAW6cjs.MissingDriverError)(
1881
+ throw new (0, _chunkVPENSVOIcjs.MissingDriverError)(
1882
1882
  `XRPL selected, but its package isn't installed. Run: npm install xrpl`,
1883
1883
  { cause }
1884
1884
  );
@@ -1888,9 +1888,9 @@ var loaders = {
1888
1888
  tron: async () => {
1889
1889
  let mod;
1890
1890
  try {
1891
- mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./tron-JOT4STIG.cjs")));
1891
+ mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./tron-DQU4WTGQ.cjs")));
1892
1892
  } catch (cause) {
1893
- throw new (0, _chunkJG6KRAW6cjs.MissingDriverError)(
1893
+ throw new (0, _chunkVPENSVOIcjs.MissingDriverError)(
1894
1894
  `Tron selected, but its package isn't installed. Run: npm install tronweb`,
1895
1895
  { cause }
1896
1896
  );
@@ -1900,9 +1900,9 @@ var loaders = {
1900
1900
  sui: async () => {
1901
1901
  let mod;
1902
1902
  try {
1903
- mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./sui-47C2KEZI.cjs")));
1903
+ mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./sui-EFRSCDWN.cjs")));
1904
1904
  } catch (cause) {
1905
- throw new (0, _chunkJG6KRAW6cjs.MissingDriverError)(
1905
+ throw new (0, _chunkVPENSVOIcjs.MissingDriverError)(
1906
1906
  `Sui selected, but its package isn't installed. Run: npm install @mysten/sui`,
1907
1907
  { cause }
1908
1908
  );
@@ -1912,9 +1912,9 @@ var loaders = {
1912
1912
  near: async () => {
1913
1913
  let mod;
1914
1914
  try {
1915
- mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./near-H5AQ253I.cjs")));
1915
+ mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./near-NYFMX2KA.cjs")));
1916
1916
  } catch (cause) {
1917
- throw new (0, _chunkJG6KRAW6cjs.MissingDriverError)(
1917
+ throw new (0, _chunkVPENSVOIcjs.MissingDriverError)(
1918
1918
  `NEAR selected, but its package isn't installed. Run: npm install near-api-js`,
1919
1919
  { cause }
1920
1920
  );
@@ -1924,9 +1924,9 @@ var loaders = {
1924
1924
  aptos: async () => {
1925
1925
  let mod;
1926
1926
  try {
1927
- mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./aptos-JQMZNTMD.cjs")));
1927
+ mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./aptos-CVHLVMAF.cjs")));
1928
1928
  } catch (cause) {
1929
- throw new (0, _chunkJG6KRAW6cjs.MissingDriverError)(
1929
+ throw new (0, _chunkVPENSVOIcjs.MissingDriverError)(
1930
1930
  `Aptos selected, but its package isn't installed. Run: npm install @aptos-labs/ts-sdk`,
1931
1931
  { cause }
1932
1932
  );
@@ -1936,9 +1936,9 @@ var loaders = {
1936
1936
  algorand: async () => {
1937
1937
  let mod;
1938
1938
  try {
1939
- mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./algorand-TMA62DN2.cjs")));
1939
+ mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./algorand-EKD34T4Q.cjs")));
1940
1940
  } catch (cause) {
1941
- throw new (0, _chunkJG6KRAW6cjs.MissingDriverError)(
1941
+ throw new (0, _chunkVPENSVOIcjs.MissingDriverError)(
1942
1942
  `Algorand selected, but its package isn't installed. Run: npm install algosdk`,
1943
1943
  { cause }
1944
1944
  );
@@ -2027,7 +2027,7 @@ var SLUG_TO_CAIP2 = {
2027
2027
  bsc: "eip155:56",
2028
2028
  // non-EVM families — values mirror each driver's bound caip2 exactly
2029
2029
  solana: "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",
2030
- ton: "ton:-239",
2030
+ ton: "tvm:-239",
2031
2031
  tron: "tron:mainnet",
2032
2032
  near: "near:mainnet",
2033
2033
  sui: "sui:mainnet",
@@ -2036,7 +2036,12 @@ var SLUG_TO_CAIP2 = {
2036
2036
  stellar: "stellar:pubnet",
2037
2037
  xrpl: "xrpl:0"
2038
2038
  };
2039
+ var LEGACY_CAIP2_ALIAS = {
2040
+ "ton:-239": "tvm:-239"
2041
+ };
2039
2042
  function normalizeNetwork(network) {
2043
+ const legacy = LEGACY_CAIP2_ALIAS[network];
2044
+ if (legacy) return legacy;
2040
2045
  if (network.includes(":")) return network;
2041
2046
  return _nullishCoalesce(SLUG_TO_CAIP2[network.toLowerCase()], () => ( network));
2042
2047
  }
@@ -2643,7 +2648,7 @@ function evaluatePolicy(intent, policy, spentForAssetBase, ctx) {
2643
2648
  }
2644
2649
  }
2645
2650
  if (policy.maxAmount !== void 0) {
2646
- const cap = _chunkJG6KRAW6cjs.floorUnits.call(void 0, policy.maxAmount, intent.decimals);
2651
+ const cap = _chunkVPENSVOIcjs.floorUnits.call(void 0, policy.maxAmount, intent.decimals);
2647
2652
  if (intent.amountBase > cap) {
2648
2653
  return deny(
2649
2654
  "MAX_AMOUNT",
@@ -2652,7 +2657,7 @@ function evaluatePolicy(intent, policy, spentForAssetBase, ctx) {
2652
2657
  }
2653
2658
  }
2654
2659
  if (policy.maxTotal !== void 0) {
2655
- const cap = _chunkJG6KRAW6cjs.floorUnits.call(void 0, policy.maxTotal, intent.decimals);
2660
+ const cap = _chunkVPENSVOIcjs.floorUnits.call(void 0, policy.maxTotal, intent.decimals);
2656
2661
  if (spentForAssetBase + intent.amountBase > cap) {
2657
2662
  return deny(
2658
2663
  "MAX_TOTAL",
@@ -2661,7 +2666,7 @@ function evaluatePolicy(intent, policy, spentForAssetBase, ctx) {
2661
2666
  }
2662
2667
  }
2663
2668
  if (ctx && policy.windowTotal !== void 0 && policy.windowSeconds !== void 0) {
2664
- const cap = _chunkJG6KRAW6cjs.floorUnits.call(void 0, policy.windowTotal, intent.decimals);
2669
+ const cap = _chunkVPENSVOIcjs.floorUnits.call(void 0, policy.windowTotal, intent.decimals);
2665
2670
  if (ctx.spentInWindowBase + intent.amountBase > cap) {
2666
2671
  return deny(
2667
2672
  "WINDOW_TOTAL",
@@ -2750,7 +2755,7 @@ var SpendLedger = (_class = class {constructor() { _class.prototype.__init.call(
2750
2755
  symbol: b.symbol,
2751
2756
  decimals: b.decimals,
2752
2757
  totalBase: b.total.toString(),
2753
- totalFormatted: _chunkJG6KRAW6cjs.formatUnits.call(void 0, b.total, b.decimals),
2758
+ totalFormatted: _chunkVPENSVOIcjs.formatUnits.call(void 0, b.total, b.decimals),
2754
2759
  count: b.count
2755
2760
  })),
2756
2761
  records: [...this.records]
@@ -2967,13 +2972,13 @@ var PipRailClient = (_class2 = class {
2967
2972
  spentBase: b.totalBase.toString()
2968
2973
  };
2969
2974
  if (maxTotal === void 0) return base2;
2970
- const capBase = _chunkJG6KRAW6cjs.floorUnits.call(void 0, maxTotal, b.decimals);
2975
+ const capBase = _chunkVPENSVOIcjs.floorUnits.call(void 0, maxTotal, b.decimals);
2971
2976
  const remainingBase = capBase > b.totalBase ? capBase - b.totalBase : 0n;
2972
2977
  return {
2973
2978
  ...base2,
2974
2979
  capBase: capBase.toString(),
2975
2980
  remainingBase: remainingBase.toString(),
2976
- remainingFormatted: _chunkJG6KRAW6cjs.formatUnits.call(void 0, remainingBase, b.decimals)
2981
+ remainingFormatted: _chunkVPENSVOIcjs.formatUnits.call(void 0, remainingBase, b.decimals)
2977
2982
  };
2978
2983
  });
2979
2984
  }
@@ -3013,11 +3018,11 @@ var PipRailClient = (_class2 = class {
3013
3018
  if (res.status !== 402) return null;
3014
3019
  const challenge = await parseChallenge(res);
3015
3020
  if (!challenge) {
3016
- throw new (0, _chunkJG6KRAW6cjs.InvalidEnvelopeError)("402 response did not include a parseable x402 challenge.");
3021
+ throw new (0, _chunkVPENSVOIcjs.InvalidEnvelopeError)("402 response did not include a parseable x402 challenge.");
3017
3022
  }
3018
3023
  const { net, wallet } = await this.ensure();
3019
3024
  if (!wallet) {
3020
- throw new (0, _chunkJG6KRAW6cjs.WalletRequiredError)(
3025
+ throw new (0, _chunkVPENSVOIcjs.WalletRequiredError)(
3021
3026
  "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."
3022
3027
  );
3023
3028
  }
@@ -3192,7 +3197,7 @@ var PipRailClient = (_class2 = class {
3192
3197
  async fetch(url, init) {
3193
3198
  const body = _optionalChain([init, 'optionalAccess', _31 => _31.body]);
3194
3199
  if (body !== void 0 && body !== null && !isReplayableBodyInit(body)) {
3195
- throw new (0, _chunkJG6KRAW6cjs.NonReplayableBodyError)(
3200
+ throw new (0, _chunkVPENSVOIcjs.NonReplayableBodyError)(
3196
3201
  "fetch(): init.body is not replayable. Pass a string, FormData, URLSearchParams, ArrayBuffer, or Blob \u2014 not a ReadableStream."
3197
3202
  );
3198
3203
  }
@@ -3202,7 +3207,7 @@ var PipRailClient = (_class2 = class {
3202
3207
  const resolved = await this.resolveChallenge(url, firstResponse, schemes);
3203
3208
  const { net, wallet, challenge } = resolved;
3204
3209
  if (!wallet) {
3205
- throw new (0, _chunkJG6KRAW6cjs.WalletRequiredError)(
3210
+ throw new (0, _chunkVPENSVOIcjs.WalletRequiredError)(
3206
3211
  "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)."
3207
3212
  );
3208
3213
  }
@@ -3212,7 +3217,9 @@ var PipRailClient = (_class2 = class {
3212
3217
  if (autoRoute) {
3213
3218
  const plan = await this.planFromChallenge(net, wallet, challenge, url, schemes);
3214
3219
  if (!plan.best) {
3215
- throw new (0, _chunkJG6KRAW6cjs.PaymentDeclinedError)(_nullishCoalesce(plan.fundingHint, () => ( "No rail is settleable for this payment.")));
3220
+ const reason = _nullishCoalesce(plan.fundingHint, () => ( "No rail is settleable for this payment."));
3221
+ this.safeEmit({ kind: "payment-failed", reason });
3222
+ throw new (0, _chunkVPENSVOIcjs.PaymentDeclinedError)(reason);
3216
3223
  }
3217
3224
  accept = plan.best.accept;
3218
3225
  quote = plan.best.quote;
@@ -3236,7 +3243,7 @@ var PipRailClient = (_class2 = class {
3236
3243
  async resolveChallenge(url, response, schemes) {
3237
3244
  const challenge = await parseChallenge(response);
3238
3245
  if (!challenge) {
3239
- throw new (0, _chunkJG6KRAW6cjs.InvalidEnvelopeError)(
3246
+ throw new (0, _chunkVPENSVOIcjs.InvalidEnvelopeError)(
3240
3247
  "402 response did not include a parseable x402 challenge."
3241
3248
  );
3242
3249
  }
@@ -3247,7 +3254,7 @@ var PipRailClient = (_class2 = class {
3247
3254
  (a) => a.scheme === "exact" && this.supportsNetwork(net, a.network)
3248
3255
  );
3249
3256
  if (schemes.includes("exact") && exactOnNet && typeof net.payExact !== "function") {
3250
- throw new (0, _chunkJG6KRAW6cjs.UnsupportedSchemeError)(
3257
+ throw new (0, _chunkVPENSVOIcjs.UnsupportedSchemeError)(
3251
3258
  `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.`
3252
3259
  );
3253
3260
  }
@@ -3256,13 +3263,13 @@ var PipRailClient = (_class2 = class {
3256
3263
  (a) => a.scheme === "exact" && this.supportsNetwork(net, a.network) && net.describeAsset(a.asset) != null
3257
3264
  );
3258
3265
  if (payable) {
3259
- throw new (0, _chunkJG6KRAW6cjs.NoCompatibleAcceptError)(
3266
+ throw new (0, _chunkVPENSVOIcjs.NoCompatibleAcceptError)(
3260
3267
  `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).`
3261
3268
  );
3262
3269
  }
3263
3270
  }
3264
3271
  const networks = [...new Set(challenge.accepts.map((a) => a.network))].join(", ");
3265
- throw new (0, _chunkJG6KRAW6cjs.NoCompatibleAcceptError)(
3272
+ throw new (0, _chunkVPENSVOIcjs.NoCompatibleAcceptError)(
3266
3273
  `No accepts[] entry payable by this client on ${net.network} (schemes: ${schemes.join(", ")}; challenge offered: ${networks || "none"}).`
3267
3274
  );
3268
3275
  }
@@ -3375,21 +3382,21 @@ var PipRailClient = (_class2 = class {
3375
3382
  if (isExact) {
3376
3383
  if (tokenKnown && bal.token < amount) {
3377
3384
  blockers.push("INSUFFICIENT_TOKEN");
3378
- shortfall.token = _chunkJG6KRAW6cjs.formatUnits.call(void 0, amount - bal.token, quote.decimals);
3385
+ shortfall.token = _chunkVPENSVOIcjs.formatUnits.call(void 0, amount - bal.token, quote.decimals);
3379
3386
  }
3380
3387
  } else if (isNative) {
3381
3388
  if (nativeKnown && bal.native < amount + fee) {
3382
3389
  blockers.push("INSUFFICIENT_TOKEN");
3383
- shortfall.token = _chunkJG6KRAW6cjs.formatUnits.call(void 0, amount + fee - bal.native, quote.decimals);
3390
+ shortfall.token = _chunkVPENSVOIcjs.formatUnits.call(void 0, amount + fee - bal.native, quote.decimals);
3384
3391
  }
3385
3392
  } else {
3386
3393
  if (tokenKnown && bal.token < amount) {
3387
3394
  blockers.push("INSUFFICIENT_TOKEN");
3388
- shortfall.token = _chunkJG6KRAW6cjs.formatUnits.call(void 0, amount - bal.token, quote.decimals);
3395
+ shortfall.token = _chunkVPENSVOIcjs.formatUnits.call(void 0, amount - bal.token, quote.decimals);
3389
3396
  }
3390
3397
  if (nativeKnown && bal.native < fee) {
3391
3398
  blockers.push("INSUFFICIENT_GAS");
3392
- shortfall.native = _chunkJG6KRAW6cjs.formatUnits.call(void 0, fee - bal.native, cost.feeDecimals);
3399
+ shortfall.native = _chunkVPENSVOIcjs.formatUnits.call(void 0, fee - bal.native, cost.feeDecimals);
3393
3400
  } else if (nativeKnown && fee > 0n && bal.native < fee * 3n / 2n) {
3394
3401
  warnings.push("THIN_GAS_MARGIN");
3395
3402
  }
@@ -3414,8 +3421,8 @@ var PipRailClient = (_class2 = class {
3414
3421
  blockers,
3415
3422
  warnings,
3416
3423
  balance: {
3417
- token: bal.token != null ? _chunkJG6KRAW6cjs.formatUnits.call(void 0, bal.token, quote.decimals) : null,
3418
- native: bal.native != null ? _chunkJG6KRAW6cjs.formatUnits.call(void 0, bal.native, cost.feeDecimals) : null
3424
+ token: bal.token != null ? _chunkVPENSVOIcjs.formatUnits.call(void 0, bal.token, quote.decimals) : null,
3425
+ native: bal.native != null ? _chunkVPENSVOIcjs.formatUnits.call(void 0, bal.native, cost.feeDecimals) : null
3419
3426
  },
3420
3427
  need: { token: quote.amountFormatted, native: cost.feeFormatted },
3421
3428
  ...shortfall.token || shortfall.native ? { shortfall } : {},
@@ -3426,12 +3433,12 @@ var PipRailClient = (_class2 = class {
3426
3433
  * driver's describeAsset) + the policy verdict + a symbol-mismatch flag. */
3427
3434
  buildQuote(net, accept, url, description) {
3428
3435
  if (typeof accept.amount !== "string" || !/^\d+$/.test(accept.amount)) {
3429
- throw new (0, _chunkJG6KRAW6cjs.InvalidEnvelopeError)(
3436
+ throw new (0, _chunkVPENSVOIcjs.InvalidEnvelopeError)(
3430
3437
  `challenge amount "${String(accept.amount)}" is not a base-unit integer string.`
3431
3438
  );
3432
3439
  }
3433
3440
  if (typeof accept.asset !== "string" || accept.asset.length === 0) {
3434
- throw new (0, _chunkJG6KRAW6cjs.InvalidEnvelopeError)(
3441
+ throw new (0, _chunkVPENSVOIcjs.InvalidEnvelopeError)(
3435
3442
  `challenge on ${accept.network} states no (string) asset \u2014 refusing to price it.`
3436
3443
  );
3437
3444
  }
@@ -3439,12 +3446,12 @@ var PipRailClient = (_class2 = class {
3439
3446
  const described = net.describeAsset(accept.asset);
3440
3447
  const decimals = _nullishCoalesce(_optionalChain([described, 'optionalAccess', _34 => _34.decimals]), () => ( _optionalChain([accept, 'access', _35 => _35.extra, 'optionalAccess', _36 => _36.decimals])));
3441
3448
  if (typeof decimals !== "number" || !Number.isInteger(decimals) || decimals < 0) {
3442
- throw new (0, _chunkJG6KRAW6cjs.InvalidEnvelopeError)(
3449
+ throw new (0, _chunkVPENSVOIcjs.InvalidEnvelopeError)(
3443
3450
  `challenge for ${accept.asset} on ${accept.network} states no valid decimals and the SDK doesn't recognise the token \u2014 refusing to price it.`
3444
3451
  );
3445
3452
  }
3446
3453
  const symbol = _nullishCoalesce(_optionalChain([described, 'optionalAccess', _37 => _37.symbol]), () => ( _optionalChain([accept, 'access', _38 => _38.extra, 'optionalAccess', _39 => _39.symbol])));
3447
- const amountFormatted = _chunkJG6KRAW6cjs.formatUnits.call(void 0, amountBase, decimals);
3454
+ const amountFormatted = _chunkVPENSVOIcjs.formatUnits.call(void 0, amountBase, decimals);
3448
3455
  const intent = {
3449
3456
  host: hostOf2(url),
3450
3457
  chain: this.opts.chain,
@@ -3502,10 +3509,10 @@ var PipRailClient = (_class2 = class {
3502
3509
  * TERMINAL expiry/approval decline it must not retry) without parsing prose. */
3503
3510
  async authorize(quote) {
3504
3511
  if (!quote.withinPolicy) {
3505
- throw new (0, _chunkJG6KRAW6cjs.PaymentDeclinedError)(
3506
- `Payment refused by policy: ${_nullishCoalesce(quote.policyReason, () => ( "not allowed"))}`,
3507
- { reasonCode: reasonCodeForPolicy(quote.policyCode) }
3508
- );
3512
+ const reason = `Payment refused by policy: ${_nullishCoalesce(quote.policyReason, () => ( "not allowed"))}`;
3513
+ const reasonCode = reasonCodeForPolicy(quote.policyCode);
3514
+ this.safeEmit({ kind: "payment-failed", reason, code: reasonCode });
3515
+ throw new (0, _chunkVPENSVOIcjs.PaymentDeclinedError)(reason, { reasonCode });
3509
3516
  }
3510
3517
  const hook = this.opts.onBeforePay;
3511
3518
  if (!hook) return;
@@ -3513,16 +3520,14 @@ var PipRailClient = (_class2 = class {
3513
3520
  try {
3514
3521
  approved = await hook(quote);
3515
3522
  } catch (err) {
3516
- throw new (0, _chunkJG6KRAW6cjs.PaymentDeclinedError)("onBeforePay threw \u2014 refusing to pay.", {
3517
- cause: err,
3518
- reasonCode: "APPROVAL"
3519
- });
3523
+ const reason = "onBeforePay threw \u2014 refusing to pay.";
3524
+ this.safeEmit({ kind: "payment-failed", reason, code: "APPROVAL" });
3525
+ throw new (0, _chunkVPENSVOIcjs.PaymentDeclinedError)(reason, { cause: err, reasonCode: "APPROVAL" });
3520
3526
  }
3521
3527
  if (!approved) {
3522
- throw new (0, _chunkJG6KRAW6cjs.PaymentDeclinedError)(
3523
- `onBeforePay declined ${quote.amountFormatted} ${_nullishCoalesce(quote.symbol, () => ( ""))}`.trimEnd() + ` on ${quote.network}.`,
3524
- { reasonCode: "APPROVAL" }
3525
- );
3528
+ const reason = `onBeforePay declined ${quote.amountFormatted} ${_nullishCoalesce(quote.symbol, () => ( ""))}`.trimEnd() + ` on ${quote.network}.`;
3529
+ this.safeEmit({ kind: "payment-failed", reason, code: "APPROVAL" });
3530
+ throw new (0, _chunkVPENSVOIcjs.PaymentDeclinedError)(reason, { reasonCode: "APPROVAL" });
3526
3531
  }
3527
3532
  }
3528
3533
  /** Record a settled payment in the ledger (true decimals for the running total). */
@@ -3544,7 +3549,7 @@ var PipRailClient = (_class2 = class {
3544
3549
  }
3545
3550
  async payAndConfirm(net, wallet, accept) {
3546
3551
  if (!this.supportsNetwork(net, accept.network)) {
3547
- throw new (0, _chunkJG6KRAW6cjs.WrongChainError)(
3552
+ throw new (0, _chunkVPENSVOIcjs.WrongChainError)(
3548
3553
  `Challenge expects ${accept.network} but client is on ${net.network}.`
3549
3554
  );
3550
3555
  }
@@ -3597,7 +3602,7 @@ var PipRailClient = (_class2 = class {
3597
3602
  });
3598
3603
  } catch (err) {
3599
3604
  if (timeoutController.signal.aborted) {
3600
- throw new (0, _chunkJG6KRAW6cjs.PaymentTimeoutError)(
3605
+ throw new (0, _chunkVPENSVOIcjs.PaymentTimeoutError)(
3601
3606
  `Server did not respond within ${this.retryTimeoutMs}ms after broadcasting payment ${ref}. Re-verify or re-submit ref=${ref} \u2014 do NOT re-pay.`,
3602
3607
  { cause: err, ref }
3603
3608
  );
@@ -3617,9 +3622,10 @@ var PipRailClient = (_class2 = class {
3617
3622
  const unconfirmedNote = confirmed ? "" : " (broadcast but NOT locally confirmed \u2014 it may still have settled on-chain)";
3618
3623
  this.safeEmit({
3619
3624
  kind: "payment-failed",
3620
- reason: `server returned 402 after broadcasting payment ${ref}${unconfirmedNote} (${why})`
3625
+ reason: `server returned 402 after broadcasting payment ${ref}${unconfirmedNote} (${why})`,
3626
+ ...lastReason ? { code: lastReason.error, detail: lastReason.detail } : {}
3621
3627
  });
3622
- throw new (0, _chunkJG6KRAW6cjs.MaxRetriesExceededError)(
3628
+ throw new (0, _chunkVPENSVOIcjs.MaxRetriesExceededError)(
3623
3629
  `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).`,
3624
3630
  { ref }
3625
3631
  );
@@ -3643,7 +3649,7 @@ var PipRailClient = (_class2 = class {
3643
3649
  */
3644
3650
  async payExactRail(net, wallet, accept, url, init, quote) {
3645
3651
  if (!net.payExact) {
3646
- throw new (0, _chunkJG6KRAW6cjs.UnsupportedSchemeError)(
3652
+ throw new (0, _chunkVPENSVOIcjs.UnsupportedSchemeError)(
3647
3653
  `the ${net.family} family can't pay a standard 'exact' rail (supported on EVM, Solana, Algorand + NEAR today).`
3648
3654
  );
3649
3655
  }
@@ -3652,8 +3658,8 @@ var PipRailClient = (_class2 = class {
3652
3658
  const headers = new Headers(_optionalChain([init, 'optionalAccess', _49 => _49.headers]));
3653
3659
  headers.set(HEADER_SIGNATURE, buildExactSignatureHeader({ accepted, payload }));
3654
3660
  const rejectDefinitive = (why2) => {
3655
- this.safeEmit({ kind: "payment-failed", reason: `exact: facilitator rejected nonce=${nonce} (${why2})` });
3656
- throw new (0, _chunkJG6KRAW6cjs.MaxRetriesExceededError)(
3661
+ this.safeEmit({ kind: "payment-failed", reason: `exact: facilitator rejected nonce=${nonce} (${why2})`, code: why2 });
3662
+ throw new (0, _chunkVPENSVOIcjs.MaxRetriesExceededError)(
3657
3663
  `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}.`,
3658
3664
  { ref: nonce }
3659
3665
  );
@@ -3676,7 +3682,7 @@ var PipRailClient = (_class2 = class {
3676
3682
  try {
3677
3683
  response = await fetch(url, { ..._nullishCoalesce(init, () => ( {})), headers, signal });
3678
3684
  } catch (err) {
3679
- throw new (0, _chunkJG6KRAW6cjs.PaymentTimeoutError)(
3685
+ throw new (0, _chunkVPENSVOIcjs.PaymentTimeoutError)(
3680
3686
  `exact: no response after submitting the authorization (nonce=${nonce}) to ${hostOf2(url)}. The facilitator may have already settled it \u2014 verify on-chain with authorizationState(${payerFrom}, ${nonce}) before re-presenting; do NOT re-pay.`,
3681
3687
  { cause: err, ref: nonce }
3682
3688
  );
@@ -3707,9 +3713,10 @@ var PipRailClient = (_class2 = class {
3707
3713
  const why = lastReason ? `${lastReason.error}${lastReason.detail ? ` \u2014 ${lastReason.detail}` : ""}` : "server gave no reason";
3708
3714
  this.safeEmit({
3709
3715
  kind: "payment-failed",
3710
- reason: `exact: 402 after submitting authorization nonce=${nonce} (${why})`
3716
+ reason: `exact: 402 after submitting authorization nonce=${nonce} (${why})`,
3717
+ ...lastReason ? { code: lastReason.error, detail: lastReason.detail } : {}
3711
3718
  });
3712
- throw new (0, _chunkJG6KRAW6cjs.MaxRetriesExceededError)(
3719
+ throw new (0, _chunkVPENSVOIcjs.MaxRetriesExceededError)(
3713
3720
  `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 authorizationState(${payerFrom}, ${nonce}) first. ref=${nonce}.`,
3714
3721
  { ref: nonce }
3715
3722
  );
@@ -3822,7 +3829,7 @@ async function fetchAcross(clients, url, init) {
3822
3829
  const best = rankAcross(live.map((p) => p.plan)).find((o) => o.state === "payable");
3823
3830
  if (!best) {
3824
3831
  const hint = mergeDeclineHint(live.map((p) => p.plan));
3825
- throw new (0, _chunkJG6KRAW6cjs.PaymentDeclinedError)(hint || "No funded chain can settle this payment right now.");
3832
+ throw new (0, _chunkVPENSVOIcjs.PaymentDeclinedError)(hint || "No funded chain can settle this payment right now.");
3826
3833
  }
3827
3834
  const owner = live.find((p) => p.plan.options.includes(best)).client;
3828
3835
  return owner.fetch(url, { ..._nullishCoalesce(init, () => ( {})), autoRoute: true });
@@ -4142,7 +4149,7 @@ function summarizePlan(plan) {
4142
4149
  return `NOT payable: ${_nullishCoalesce(plan.fundingHint, () => ( `no settleable rail on ${plan.network}`))}`;
4143
4150
  }
4144
4151
  function explainDecline(err) {
4145
- if (!(err instanceof _chunkJG6KRAW6cjs.PipRailError)) {
4152
+ if (!(err instanceof _chunkVPENSVOIcjs.PipRailError)) {
4146
4153
  return `Payment failed: ${err instanceof Error ? err.message : String(err)}`;
4147
4154
  }
4148
4155
  switch (err.code) {
@@ -4280,14 +4287,14 @@ async function readBody(res) {
4280
4287
  }
4281
4288
  }
4282
4289
  function toToolError(err) {
4283
- if (!(err instanceof _chunkJG6KRAW6cjs.PipRailError)) throw err;
4290
+ if (!(err instanceof _chunkVPENSVOIcjs.PipRailError)) throw err;
4284
4291
  const out = {
4285
4292
  ok: false,
4286
4293
  code: err.code,
4287
4294
  reason: err.message,
4288
4295
  explain: explainDecline(err)
4289
4296
  };
4290
- if (err instanceof _chunkJG6KRAW6cjs.PaymentDeclinedError) {
4297
+ if (err instanceof _chunkVPENSVOIcjs.PaymentDeclinedError) {
4291
4298
  out.declined = true;
4292
4299
  if (err.reasonCode) out.reasonCode = err.reasonCode;
4293
4300
  }
@@ -4501,14 +4508,14 @@ function paymentTools(client) {
4501
4508
  receipt: parseReceipt(res)
4502
4509
  };
4503
4510
  } catch (err) {
4504
- if (err instanceof _chunkJG6KRAW6cjs.PipRailError) {
4511
+ if (err instanceof _chunkVPENSVOIcjs.PipRailError) {
4505
4512
  const out = {
4506
4513
  ok: false,
4507
4514
  code: err.code,
4508
4515
  reason: err.message,
4509
4516
  explain: explainDecline(err)
4510
4517
  };
4511
- if (err instanceof _chunkJG6KRAW6cjs.PaymentDeclinedError) {
4518
+ if (err instanceof _chunkVPENSVOIcjs.PaymentDeclinedError) {
4512
4519
  out.declined = true;
4513
4520
  if (err.reasonCode) out.reasonCode = err.reasonCode;
4514
4521
  }
@@ -4862,13 +4869,13 @@ async function settleViaFacilitator(input) {
4862
4869
  try {
4863
4870
  verify = await post(`${base2}/verify`, body, auth);
4864
4871
  } catch (err) {
4865
- throw new (0, _chunkJG6KRAW6cjs.SettlementError)(
4872
+ throw new (0, _chunkVPENSVOIcjs.SettlementError)(
4866
4873
  `exact settle (facilitator ${base2}): /verify request failed (${err instanceof Error ? err.message : String(err)}).`,
4867
4874
  { cause: err }
4868
4875
  );
4869
4876
  }
4870
4877
  if (verify.status !== 200) {
4871
- throw new (0, _chunkJG6KRAW6cjs.SettlementError)(
4878
+ throw new (0, _chunkVPENSVOIcjs.SettlementError)(
4872
4879
  `exact settle (facilitator ${base2}): /verify returned HTTP ${verify.status} (transport/auth error).`
4873
4880
  );
4874
4881
  }
@@ -4884,13 +4891,13 @@ async function settleViaFacilitator(input) {
4884
4891
  try {
4885
4892
  settle = await post(`${base2}/settle`, body, auth);
4886
4893
  } catch (err) {
4887
- throw new (0, _chunkJG6KRAW6cjs.SettlementError)(
4894
+ throw new (0, _chunkVPENSVOIcjs.SettlementError)(
4888
4895
  `exact settle (facilitator ${base2}): /settle request failed (${err instanceof Error ? err.message : String(err)}).`,
4889
4896
  { cause: err }
4890
4897
  );
4891
4898
  }
4892
4899
  if (settle.status !== 200) {
4893
- throw new (0, _chunkJG6KRAW6cjs.SettlementError)(
4900
+ throw new (0, _chunkVPENSVOIcjs.SettlementError)(
4894
4901
  `exact settle (facilitator ${base2}): /settle returned HTTP ${settle.status} (transport/auth error).`
4895
4902
  );
4896
4903
  }
@@ -5260,6 +5267,7 @@ function normaliseExactOption(exact) {
5260
5267
  if (exact === true) return { settle: "keyless" };
5261
5268
  return exact;
5262
5269
  }
5270
+ var TRANSIENT_VERIFY_CODES = /* @__PURE__ */ new Set(["tx_not_found", "insufficient_confirmations"]);
5263
5271
  function createPaymentGate(options) {
5264
5272
  const minConfirmations = _nullishCoalesce(options.minConfirmations, () => ( 1));
5265
5273
  const maxTimeoutSeconds = _nullishCoalesce(options.maxTimeoutSeconds, () => ( 600));
@@ -5282,7 +5290,7 @@ function createPaymentGate(options) {
5282
5290
  }
5283
5291
  net.assertValidPayTo(payTo);
5284
5292
  const { asset, decimals, symbol } = net.resolveToken(a.token);
5285
- const amountBase = _chunkJG6KRAW6cjs.parseUnits.call(void 0, a.amount, decimals);
5293
+ const amountBase = _chunkVPENSVOIcjs.parseUnits.call(void 0, a.amount, decimals);
5286
5294
  const spec = { net, asset, decimals, symbol, amountBase, amountFormatted: a.amount, payTo };
5287
5295
  if (exactOption) {
5288
5296
  const outcome = await resolveExactRail(net, asset);
@@ -5508,7 +5516,7 @@ function createPaymentGate(options) {
5508
5516
  function enrichReceipt(spec, receipt) {
5509
5517
  let amountFormatted = receipt.amount;
5510
5518
  try {
5511
- amountFormatted = _chunkJG6KRAW6cjs.formatUnits.call(void 0, BigInt(receipt.amount), spec.decimals);
5519
+ amountFormatted = _chunkVPENSVOIcjs.formatUnits.call(void 0, BigInt(receipt.amount), spec.decimals);
5512
5520
  } catch (e36) {
5513
5521
  }
5514
5522
  return {
@@ -5544,6 +5552,32 @@ function createPaymentGate(options) {
5544
5552
  if (options.awaitOnPaid) await fireOnPaid(paid);
5545
5553
  else void fireOnPaid(paid);
5546
5554
  }
5555
+ function reportOnFailedError(error, failure) {
5556
+ if (!options.onFailedError) return;
5557
+ try {
5558
+ options.onFailedError(error, failure);
5559
+ } catch (e38) {
5560
+ }
5561
+ }
5562
+ function fireOnFailed(failure) {
5563
+ if (!options.onFailed) return;
5564
+ let outcome;
5565
+ try {
5566
+ outcome = options.onFailed(failure);
5567
+ } catch (err) {
5568
+ reportOnFailedError(err, failure);
5569
+ return;
5570
+ }
5571
+ if (outcome != null && typeof outcome.then === "function") {
5572
+ return Promise.resolve(outcome).catch((err) => reportOnFailedError(err, failure));
5573
+ }
5574
+ }
5575
+ async function deliverOnFailed(result) {
5576
+ const code = result.error;
5577
+ const failure = { code, detail: result.detail, transient: TRANSIENT_VERIFY_CODES.has(code) };
5578
+ if (options.awaitOnFailed) await fireOnFailed(failure);
5579
+ else void fireOnFailed(failure);
5580
+ }
5547
5581
  async function describe(resourceUrl = "") {
5548
5582
  const specs = await ready();
5549
5583
  const accepts = [];
@@ -5622,28 +5656,28 @@ function createPaymentGate(options) {
5622
5656
  nonce = [exact.payload.transaction, exact.payload.senderAuth].map((t) => {
5623
5657
  try {
5624
5658
  return Buffer.from(t, "base64").toString("base64");
5625
- } catch (e38) {
5659
+ } catch (e39) {
5626
5660
  return t;
5627
5661
  }
5628
5662
  }).join("|");
5629
5663
  } else if ("transaction" in exact.payload) {
5630
5664
  try {
5631
5665
  nonce = Buffer.from(exact.payload.transaction, "base64").toString("base64");
5632
- } catch (e39) {
5666
+ } catch (e40) {
5633
5667
  nonce = exact.payload.transaction;
5634
5668
  }
5635
5669
  } else if ("paymentGroup" in exact.payload) {
5636
5670
  nonce = exact.payload.paymentGroup.map((t) => {
5637
5671
  try {
5638
5672
  return Buffer.from(t, "base64").toString("base64");
5639
- } catch (e40) {
5673
+ } catch (e41) {
5640
5674
  return t;
5641
5675
  }
5642
5676
  }).join("|");
5643
5677
  } else if ("signedDelegateAction" in exact.payload) {
5644
5678
  try {
5645
5679
  nonce = Buffer.from(exact.payload.signedDelegateAction, "base64").toString("base64");
5646
- } catch (e41) {
5680
+ } catch (e42) {
5647
5681
  nonce = exact.payload.signedDelegateAction;
5648
5682
  }
5649
5683
  } else if ("permit2Authorization" in exact.payload) {
@@ -5666,7 +5700,7 @@ function createPaymentGate(options) {
5666
5700
  const ftMethod = accept.extra.assetTransferMethod;
5667
5701
  const needsFeePayer = ftMethod === "svm" || ftMethod === "algorand" || ftMethod === "aptos" || ftMethod === "near";
5668
5702
  if (needsFeePayer && !accept.extra.feePayer) {
5669
- throw new (0, _chunkJG6KRAW6cjs.SettlementError)(
5703
+ throw new (0, _chunkVPENSVOIcjs.SettlementError)(
5670
5704
  `exact settle: the ${ftMethod} facilitator rail is missing extra.feePayer (the gas sponsor) \u2014 cannot settle.`
5671
5705
  );
5672
5706
  }
@@ -5707,6 +5741,11 @@ function createPaymentGate(options) {
5707
5741
  return { kind: "paid", receipt: result.receipt, receiptHeader: buildReceiptHeader(result.receipt) };
5708
5742
  }
5709
5743
  async function verify(paymentSignature) {
5744
+ const result = await resolveVerdict(paymentSignature);
5745
+ if (result.kind === "invalid") await deliverOnFailed(result);
5746
+ return result;
5747
+ }
5748
+ async function resolveVerdict(paymentSignature) {
5710
5749
  const raw = normaliseHeader(paymentSignature);
5711
5750
  if (!raw) return asChallenge();
5712
5751
  const sig = parseSignatureHeader(raw);
@@ -5726,7 +5765,7 @@ function requirePayment(options) {
5726
5765
  try {
5727
5766
  result = await gate.verify(_nullishCoalesce(req.headers[HEADER_SIGNATURE], () => ( req.headers[HEADER_SIGNATURE_V1])));
5728
5767
  } catch (err) {
5729
- if (err instanceof _chunkJG6KRAW6cjs.SettlementError) {
5768
+ if (err instanceof _chunkVPENSVOIcjs.SettlementError) {
5730
5769
  res.status(502);
5731
5770
  res.json({
5732
5771
  x402Version: 2,
@@ -5784,7 +5823,7 @@ async function signBody(secret, body) {
5784
5823
  const sig = await subtle.sign("HMAC", key, enc.encode(body));
5785
5824
  const hex = Array.from(new Uint8Array(sig)).map((b) => b.toString(16).padStart(2, "0")).join("");
5786
5825
  return `sha256=${hex}`;
5787
- } catch (e42) {
5826
+ } catch (e43) {
5788
5827
  return null;
5789
5828
  }
5790
5829
  }
@@ -5845,7 +5884,7 @@ async function deliverReceipt(receipt, options) {
5845
5884
  const willRetry = !ok && retryable && attempt < maxAttempts;
5846
5885
  try {
5847
5886
  _optionalChain([onAttempt, 'optionalCall', _91 => _91({ attempt, ok, ...status !== void 0 ? { status } : {}, ...error ? { error } : {}, willRetry })]);
5848
- } catch (e43) {
5887
+ } catch (e44) {
5849
5888
  }
5850
5889
  if (ok) return { delivered: true, attempts: attempt, status };
5851
5890
  if (!willRetry) {
@@ -5964,4 +6003,4 @@ async function deliverReceipt(receipt, options) {
5964
6003
 
5965
6004
 
5966
6005
 
5967
- exports.BRAND = BRAND; exports.CHAINS = CHAINS; exports.ConfirmationTimeoutError = _chunkJG6KRAW6cjs.ConfirmationTimeoutError; exports.DIRECTORY_INFO = DIRECTORY_INFO; exports.EIP3009_TYPES = EIP3009_TYPES; exports.EXACT_NETWORK_SLUGS = EXACT_NETWORK_SLUGS; 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 = _chunkJG6KRAW6cjs.InsufficientFundsError; exports.InvalidEnvelopeError = _chunkJG6KRAW6cjs.InvalidEnvelopeError; exports.KNOWN_FACILITATORS = KNOWN_FACILITATORS; exports.MaxRetriesExceededError = _chunkJG6KRAW6cjs.MaxRetriesExceededError; exports.MissingDriverError = _chunkJG6KRAW6cjs.MissingDriverError; exports.MultiChainPayer = MultiChainPayer; exports.NoCompatibleAcceptError = _chunkJG6KRAW6cjs.NoCompatibleAcceptError; exports.NonReplayableBodyError = _chunkJG6KRAW6cjs.NonReplayableBodyError; exports.PERMIT2_ADDRESS = PERMIT2_ADDRESS; exports.PERMIT2_PROXY_CHAIN_IDS = PERMIT2_PROXY_CHAIN_IDS; exports.PERMIT2_WITNESS_TYPES = PERMIT2_WITNESS_TYPES; exports.PIPRAIL_AGENT_GUIDE = PIPRAIL_AGENT_GUIDE; exports.POWERED_BY = POWERED_BY; exports.PaymentDeclinedError = _chunkJG6KRAW6cjs.PaymentDeclinedError; exports.PaymentTimeoutError = _chunkJG6KRAW6cjs.PaymentTimeoutError; exports.PipRailClient = PipRailClient; exports.PipRailError = _chunkJG6KRAW6cjs.PipRailError; exports.REGISTER_ATTRIBUTION = REGISTER_ATTRIBUTION; exports.RecipientNotReadyError = _chunkJG6KRAW6cjs.RecipientNotReadyError; exports.SettlementError = _chunkJG6KRAW6cjs.SettlementError; exports.UnknownTokenError = _chunkJG6KRAW6cjs.UnknownTokenError; exports.UnsupportedNetworkError = _chunkJG6KRAW6cjs.UnsupportedNetworkError; exports.UnsupportedSchemeError = _chunkJG6KRAW6cjs.UnsupportedSchemeError; exports.WalletRequiredError = _chunkJG6KRAW6cjs.WalletRequiredError; exports.WrongChainError = _chunkJG6KRAW6cjs.WrongChainError; exports.WrongFamilyError = _chunkJG6KRAW6cjs.WrongFamilyError; exports.X402_EXACT_PERMIT2_PROXY = X402_EXACT_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.buildReceiptHeader = buildReceiptHeader; exports.buildSelfDescription = buildSelfDescription; exports.buildSignatureHeader = buildSignatureHeader; exports.buildWellKnownX402 = buildWellKnownX402; exports.buildX402DnsTxt = buildX402DnsTxt; exports.chainIdForExactNetwork = chainIdForExactNetwork; exports.claim402IndexDomain = claim402IndexDomain; exports.classifyChallenge = classifyChallenge; exports.createPaymentGate = createPaymentGate; exports.decorateOutcome = decorateOutcome; exports.deliverReceipt = deliverReceipt; 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.getDirectoryInfo = getDirectoryInfo; exports.isPermit2ProxyChain = isPermit2ProxyChain; exports.knownFacilitatorsFor = knownFacilitatorsFor; exports.normalizeNetwork = normalizeNetwork; exports.parseChallenge = parseChallenge; exports.parseExactPaymentHeader = parseExactPaymentHeader; exports.parseExactRequirements = parseExactRequirements; exports.parseFacilitatorSupported = parseFacilitatorSupported; exports.parseReceipt = parseReceipt; exports.parseSettleResponse = parseSettleResponse; exports.parseSignatureHeader = parseSignatureHeader; 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.toInsufficientFundsError = _chunkJG6KRAW6cjs.toInsufficientFundsError; exports.toInvalidBody = toInvalidBody; exports.verify402IndexDomain = verify402IndexDomain;
6006
+ exports.BRAND = BRAND; exports.CHAINS = CHAINS; exports.ConfirmationTimeoutError = _chunkVPENSVOIcjs.ConfirmationTimeoutError; exports.DIRECTORY_INFO = DIRECTORY_INFO; exports.EIP3009_TYPES = EIP3009_TYPES; exports.EXACT_NETWORK_SLUGS = EXACT_NETWORK_SLUGS; 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 = _chunkVPENSVOIcjs.InsufficientFundsError; exports.InvalidEnvelopeError = _chunkVPENSVOIcjs.InvalidEnvelopeError; exports.KNOWN_FACILITATORS = KNOWN_FACILITATORS; exports.MaxRetriesExceededError = _chunkVPENSVOIcjs.MaxRetriesExceededError; exports.MissingDriverError = _chunkVPENSVOIcjs.MissingDriverError; exports.MultiChainPayer = MultiChainPayer; exports.NoCompatibleAcceptError = _chunkVPENSVOIcjs.NoCompatibleAcceptError; exports.NonReplayableBodyError = _chunkVPENSVOIcjs.NonReplayableBodyError; exports.PERMIT2_ADDRESS = PERMIT2_ADDRESS; exports.PERMIT2_PROXY_CHAIN_IDS = PERMIT2_PROXY_CHAIN_IDS; exports.PERMIT2_WITNESS_TYPES = PERMIT2_WITNESS_TYPES; exports.PIPRAIL_AGENT_GUIDE = PIPRAIL_AGENT_GUIDE; exports.POWERED_BY = POWERED_BY; exports.PaymentDeclinedError = _chunkVPENSVOIcjs.PaymentDeclinedError; exports.PaymentTimeoutError = _chunkVPENSVOIcjs.PaymentTimeoutError; exports.PipRailClient = PipRailClient; exports.PipRailError = _chunkVPENSVOIcjs.PipRailError; exports.REGISTER_ATTRIBUTION = REGISTER_ATTRIBUTION; exports.RecipientNotReadyError = _chunkVPENSVOIcjs.RecipientNotReadyError; exports.SettlementError = _chunkVPENSVOIcjs.SettlementError; exports.UnknownTokenError = _chunkVPENSVOIcjs.UnknownTokenError; exports.UnsupportedNetworkError = _chunkVPENSVOIcjs.UnsupportedNetworkError; exports.UnsupportedSchemeError = _chunkVPENSVOIcjs.UnsupportedSchemeError; exports.WalletRequiredError = _chunkVPENSVOIcjs.WalletRequiredError; exports.WrongChainError = _chunkVPENSVOIcjs.WrongChainError; exports.WrongFamilyError = _chunkVPENSVOIcjs.WrongFamilyError; exports.X402_EXACT_PERMIT2_PROXY = X402_EXACT_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.buildReceiptHeader = buildReceiptHeader; exports.buildSelfDescription = buildSelfDescription; exports.buildSignatureHeader = buildSignatureHeader; exports.buildWellKnownX402 = buildWellKnownX402; exports.buildX402DnsTxt = buildX402DnsTxt; exports.chainIdForExactNetwork = chainIdForExactNetwork; exports.claim402IndexDomain = claim402IndexDomain; exports.classifyChallenge = classifyChallenge; exports.createPaymentGate = createPaymentGate; exports.decorateOutcome = decorateOutcome; exports.deliverReceipt = deliverReceipt; 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.getDirectoryInfo = getDirectoryInfo; exports.isPermit2ProxyChain = isPermit2ProxyChain; exports.knownFacilitatorsFor = knownFacilitatorsFor; exports.normalizeNetwork = normalizeNetwork; exports.parseChallenge = parseChallenge; exports.parseExactPaymentHeader = parseExactPaymentHeader; exports.parseExactRequirements = parseExactRequirements; exports.parseFacilitatorSupported = parseFacilitatorSupported; exports.parseReceipt = parseReceipt; exports.parseSettleResponse = parseSettleResponse; exports.parseSignatureHeader = parseSignatureHeader; 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.toInsufficientFundsError = _chunkVPENSVOIcjs.toInsufficientFundsError; exports.toInvalidBody = toInvalidBody; exports.verify402IndexDomain = verify402IndexDomain;