@piprail/sdk 2.14.0 → 2.14.2
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/CHANGELOG.md +65 -0
- package/dist/{algorand-6J3IABVF.js → algorand-CSEUTWNW.js} +1 -1
- package/dist/{algorand-QU6G2DQZ.cjs → algorand-I2O24RSM.cjs} +32 -32
- package/dist/{aptos-LFTQGBBK.cjs → aptos-GA5AEYYL.cjs} +31 -31
- package/dist/{aptos-DHOMTBLZ.js → aptos-J7QGCWNW.js} +1 -1
- package/dist/{chunk-GYM46G5L.cjs → chunk-3FR22M3O.cjs} +35 -20
- package/dist/{chunk-PAMKCWVW.js → chunk-3ZWM3DKM.js} +17 -2
- package/dist/index.cjs +246 -203
- package/dist/index.d.cts +10 -10
- package/dist/index.d.ts +10 -10
- package/dist/index.js +78 -35
- package/dist/{near-YNNK7RW7.cjs → near-NDQLGI4U.cjs} +27 -27
- package/dist/{near-5PXTVQ47.js → near-YA4Y4IGC.js} +1 -1
- package/dist/{solana-HITVI3HF.js → solana-MB6G3OA5.js} +1 -1
- package/dist/{solana-N3UCNCYE.cjs → solana-OU6IUMQM.cjs} +32 -32
- package/dist/{stellar-Y3SQN7S5.cjs → stellar-RSNVOIKL.cjs} +20 -20
- package/dist/{stellar-2QT6YYKN.js → stellar-WDWSYOED.js} +1 -1
- package/dist/{sui-FV5L6WF5.js → sui-GVSFNNJX.js} +1 -1
- package/dist/{sui-4AL4E6XU.cjs → sui-MVC46BFJ.cjs} +16 -16
- package/dist/{ton-5FWDQ4QR.js → ton-EJMGM3YI.js} +1 -1
- package/dist/{ton-5HDVOTMR.cjs → ton-MYOI3U3H.cjs} +16 -16
- package/dist/{tron-TX2B4N2A.cjs → tron-42X5N4GQ.cjs} +25 -25
- package/dist/{tron-AZDY7BMQ.js → tron-VAPVMGJK.js} +1 -1
- package/dist/{xrpl-5TYDLQFS.cjs → xrpl-MGUBUNSZ.cjs} +20 -20
- package/dist/{xrpl-UJL5J7CY.js → xrpl-Q2UWPCTJ.js} +1 -1
- package/package.json +3 -2
package/dist/index.cjs
CHANGED
|
@@ -31,7 +31,8 @@ var _chunkCQQI5IJXcjs = require('./chunk-CQQI5IJX.cjs');
|
|
|
31
31
|
|
|
32
32
|
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
|
|
35
|
+
var _chunk3FR22M3Ocjs = require('./chunk-3FR22M3O.cjs');
|
|
35
36
|
|
|
36
37
|
// src/drivers/registry.ts
|
|
37
38
|
var byFamily = /* @__PURE__ */ new Map();
|
|
@@ -60,13 +61,13 @@ function resolveNetwork(opts) {
|
|
|
60
61
|
const family = familyForChain(opts.chain);
|
|
61
62
|
const driver = byFamily.get(family);
|
|
62
63
|
if (!driver) {
|
|
63
|
-
throw new (0,
|
|
64
|
+
throw new (0, _chunk3FR22M3Ocjs.UnsupportedNetworkError)(
|
|
64
65
|
`No driver registered for the "${family}" family \u2014 it may not be mounted yet (use the async resolveNetwork()).`
|
|
65
66
|
);
|
|
66
67
|
}
|
|
67
68
|
const net = driver.resolve(opts);
|
|
68
69
|
if (!net) {
|
|
69
|
-
throw new (0,
|
|
70
|
+
throw new (0, _chunk3FR22M3Ocjs.UnsupportedNetworkError)(
|
|
70
71
|
`The ${family} driver didn't recognise this chain input.`
|
|
71
72
|
);
|
|
72
73
|
}
|
|
@@ -331,12 +332,12 @@ function resolveChain(input, rpcUrlOverride) {
|
|
|
331
332
|
|
|
332
333
|
var _accounts = require('viem/accounts');
|
|
333
334
|
function createWalletAdapter(config, resolved) {
|
|
334
|
-
|
|
335
|
+
_chunk3FR22M3Ocjs.assertNoLegacyWalletKey.call(void 0, config, "EVM");
|
|
335
336
|
if ("key" in config) {
|
|
336
337
|
const key = config.key;
|
|
337
338
|
if (typeof key !== "string" || !/^0x[0-9a-fA-F]{64}$/.test(key)) {
|
|
338
339
|
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,
|
|
340
|
+
throw new (0, _chunk3FR22M3Ocjs.WrongFamilyError)(
|
|
340
341
|
`chain is EVM; the wallet { key } is not a valid 0x\u2026 32-byte hex private key${hint}`
|
|
341
342
|
);
|
|
342
343
|
}
|
|
@@ -344,7 +345,7 @@ function createWalletAdapter(config, resolved) {
|
|
|
344
345
|
try {
|
|
345
346
|
account = _accounts.privateKeyToAccount.call(void 0, key);
|
|
346
347
|
} catch (err) {
|
|
347
|
-
throw new (0,
|
|
348
|
+
throw new (0, _chunk3FR22M3Ocjs.WrongFamilyError)(
|
|
348
349
|
`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
350
|
);
|
|
350
351
|
}
|
|
@@ -354,12 +355,12 @@ function createWalletAdapter(config, resolved) {
|
|
|
354
355
|
}
|
|
355
356
|
const wc = config.walletClient;
|
|
356
357
|
if (!wc.account) {
|
|
357
|
-
throw new (0,
|
|
358
|
+
throw new (0, _chunk3FR22M3Ocjs.WrongFamilyError)(
|
|
358
359
|
"chain is EVM; the provided walletClient has no attached account. Use `createWalletClient({ account, chain, transport })`, or pass { key }."
|
|
359
360
|
);
|
|
360
361
|
}
|
|
361
362
|
if (wc.chain && wc.chain.id !== resolved.chainId) {
|
|
362
|
-
throw new (0,
|
|
363
|
+
throw new (0, _chunk3FR22M3Ocjs.WrongChainError)(
|
|
363
364
|
`PipRailClient: walletClient is on chain ${wc.chain.id} but the SDK was configured with chain ${resolved.chainId}. They must match.`
|
|
364
365
|
);
|
|
365
366
|
}
|
|
@@ -689,7 +690,7 @@ async function payExactEvm(input) {
|
|
|
689
690
|
code = void 0;
|
|
690
691
|
}
|
|
691
692
|
if (code && code !== "0x") {
|
|
692
|
-
throw new (0,
|
|
693
|
+
throw new (0, _chunk3FR22M3Ocjs.UnsupportedSchemeError)(
|
|
693
694
|
`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
695
|
);
|
|
695
696
|
}
|
|
@@ -699,13 +700,13 @@ async function payExactEvm(input) {
|
|
|
699
700
|
domain = await readExactDomain(publicClient, accept.asset);
|
|
700
701
|
}
|
|
701
702
|
if (!domain) {
|
|
702
|
-
throw new (0,
|
|
703
|
+
throw new (0, _chunk3FR22M3Ocjs.UnsupportedSchemeError)(
|
|
703
704
|
`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
705
|
);
|
|
705
706
|
}
|
|
706
707
|
const g = globalThis.crypto;
|
|
707
708
|
if (!_optionalChain([g, 'optionalAccess', _5 => _5.getRandomValues])) {
|
|
708
|
-
throw new (0,
|
|
709
|
+
throw new (0, _chunk3FR22M3Ocjs.UnsupportedSchemeError)(
|
|
709
710
|
"this runtime lacks Web Crypto (globalThis.crypto.getRandomValues); the exact rail needs a CSPRNG nonce."
|
|
710
711
|
);
|
|
711
712
|
}
|
|
@@ -962,7 +963,7 @@ async function verifyAndSettleExactEvm(input) {
|
|
|
962
963
|
args: writeArgs
|
|
963
964
|
});
|
|
964
965
|
} catch (err) {
|
|
965
|
-
throw new (0,
|
|
966
|
+
throw new (0, _chunk3FR22M3Ocjs.SettlementError)(
|
|
966
967
|
`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
968
|
{ cause: err }
|
|
968
969
|
);
|
|
@@ -974,7 +975,7 @@ async function verifyAndSettleExactEvm(input) {
|
|
|
974
975
|
return { ok: false, error: "tx_reverted", detail: `Settlement tx ${txHash} reverted on-chain.` };
|
|
975
976
|
}
|
|
976
977
|
} catch (err) {
|
|
977
|
-
throw new (0,
|
|
978
|
+
throw new (0, _chunk3FR22M3Ocjs.SettlementError)(
|
|
978
979
|
`exact settle: broadcast ${txHash} but couldn't confirm it (${shorten(err instanceof Error ? err.message : String(err))}).`,
|
|
979
980
|
{ cause: err }
|
|
980
981
|
);
|
|
@@ -1105,7 +1106,7 @@ function shorten2(msg) {
|
|
|
1105
1106
|
function randomPermit2Nonce() {
|
|
1106
1107
|
const g = globalThis.crypto;
|
|
1107
1108
|
if (!_optionalChain([g, 'optionalAccess', _8 => _8.getRandomValues])) {
|
|
1108
|
-
throw new (0,
|
|
1109
|
+
throw new (0, _chunk3FR22M3Ocjs.UnsupportedSchemeError)(
|
|
1109
1110
|
"this runtime lacks Web Crypto (globalThis.crypto.getRandomValues); the permit2 rail needs a CSPRNG nonce."
|
|
1110
1111
|
);
|
|
1111
1112
|
}
|
|
@@ -1124,7 +1125,7 @@ async function ensurePermit2Allowance(input) {
|
|
|
1124
1125
|
args: [account.address, PERMIT2_ADDRESS]
|
|
1125
1126
|
});
|
|
1126
1127
|
} catch (err) {
|
|
1127
|
-
throw new (0,
|
|
1128
|
+
throw new (0, _chunk3FR22M3Ocjs.UnsupportedSchemeError)(
|
|
1128
1129
|
`permit2: couldn't read the Permit2 allowance for ${token} (${shorten2(err instanceof Error ? err.message : String(err))}).`
|
|
1129
1130
|
);
|
|
1130
1131
|
}
|
|
@@ -1141,7 +1142,7 @@ async function ensurePermit2Allowance(input) {
|
|
|
1141
1142
|
await publicClient.waitForTransactionReceipt({ hash, confirmations: 1 });
|
|
1142
1143
|
return hash;
|
|
1143
1144
|
} catch (err) {
|
|
1144
|
-
throw _nullishCoalesce(
|
|
1145
|
+
throw _nullishCoalesce(_chunk3FR22M3Ocjs.toInsufficientFundsError.call(void 0, err), () => ( new (0, _chunk3FR22M3Ocjs.SettlementError)(
|
|
1145
1146
|
`permit2: the one-time Permit2 approval for ${token} failed to broadcast (${shorten2(err instanceof Error ? err.message : String(err))}).`,
|
|
1146
1147
|
{ cause: err }
|
|
1147
1148
|
)));
|
|
@@ -1156,7 +1157,7 @@ async function payPermit2Evm(input) {
|
|
|
1156
1157
|
code = void 0;
|
|
1157
1158
|
}
|
|
1158
1159
|
if (code && code !== "0x") {
|
|
1159
|
-
throw new (0,
|
|
1160
|
+
throw new (0, _chunk3FR22M3Ocjs.UnsupportedSchemeError)(
|
|
1160
1161
|
`permit2 buyer rail requires an EOA signer; ${account.address} is a contract / EIP-1271 / EIP-7702-delegated account. Pay via onchain-proof.`
|
|
1161
1162
|
);
|
|
1162
1163
|
}
|
|
@@ -1331,7 +1332,7 @@ async function verifyAndSettlePermit2Evm(input) {
|
|
|
1331
1332
|
args: settleArgs
|
|
1332
1333
|
});
|
|
1333
1334
|
} catch (err) {
|
|
1334
|
-
throw new (0,
|
|
1335
|
+
throw new (0, _chunk3FR22M3Ocjs.SettlementError)(
|
|
1335
1336
|
`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
1337
|
{ cause: err }
|
|
1337
1338
|
);
|
|
@@ -1343,7 +1344,7 @@ async function verifyAndSettlePermit2Evm(input) {
|
|
|
1343
1344
|
return { ok: false, error: "tx_reverted", detail: `Settlement tx ${txHash} reverted on-chain.` };
|
|
1344
1345
|
}
|
|
1345
1346
|
} catch (err) {
|
|
1346
|
-
throw new (0,
|
|
1347
|
+
throw new (0, _chunk3FR22M3Ocjs.SettlementError)(
|
|
1347
1348
|
`permit2 settle: broadcast ${txHash} but couldn't confirm it (${shorten2(err instanceof Error ? err.message : String(err))}).`,
|
|
1348
1349
|
{ cause: err }
|
|
1349
1350
|
);
|
|
@@ -1441,7 +1442,7 @@ function shorten3(msg) {
|
|
|
1441
1442
|
function randomPermit2Nonce2() {
|
|
1442
1443
|
const g = globalThis.crypto;
|
|
1443
1444
|
if (!_optionalChain([g, 'optionalAccess', _9 => _9.getRandomValues])) {
|
|
1444
|
-
throw new (0,
|
|
1445
|
+
throw new (0, _chunk3FR22M3Ocjs.UnsupportedSchemeError)(
|
|
1445
1446
|
"this runtime lacks Web Crypto (globalThis.crypto.getRandomValues); the upto rail needs a CSPRNG nonce."
|
|
1446
1447
|
);
|
|
1447
1448
|
}
|
|
@@ -1458,13 +1459,13 @@ async function payUptoEvm(input) {
|
|
|
1458
1459
|
code = void 0;
|
|
1459
1460
|
}
|
|
1460
1461
|
if (code && code !== "0x") {
|
|
1461
|
-
throw new (0,
|
|
1462
|
+
throw new (0, _chunk3FR22M3Ocjs.UnsupportedSchemeError)(
|
|
1462
1463
|
`upto buyer rail requires an EOA signer; ${account.address} is a contract / EIP-1271 / EIP-7702-delegated account. Pay via onchain-proof.`
|
|
1463
1464
|
);
|
|
1464
1465
|
}
|
|
1465
1466
|
const facilitatorAddress = _optionalChain([accept, 'access', _10 => _10.extra, 'optionalAccess', _11 => _11.facilitatorAddress]);
|
|
1466
1467
|
if (typeof facilitatorAddress !== "string" || facilitatorAddress.length === 0) {
|
|
1467
|
-
throw new (0,
|
|
1468
|
+
throw new (0, _chunk3FR22M3Ocjs.UnsupportedSchemeError)(
|
|
1468
1469
|
`upto: the rail carries no extra.facilitatorAddress to bind into witness.facilitator \u2014 refusing to sign.`
|
|
1469
1470
|
);
|
|
1470
1471
|
}
|
|
@@ -1685,7 +1686,7 @@ async function verifyAndSettleUptoEvm(input) {
|
|
|
1685
1686
|
args: settleArgs
|
|
1686
1687
|
});
|
|
1687
1688
|
} catch (err) {
|
|
1688
|
-
throw new (0,
|
|
1689
|
+
throw new (0, _chunk3FR22M3Ocjs.SettlementError)(
|
|
1689
1690
|
`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
1691
|
{ cause: err }
|
|
1691
1692
|
);
|
|
@@ -1697,7 +1698,7 @@ async function verifyAndSettleUptoEvm(input) {
|
|
|
1697
1698
|
return { ok: false, error: "tx_reverted", detail: `Settlement tx ${txHash} reverted on-chain.` };
|
|
1698
1699
|
}
|
|
1699
1700
|
} catch (err) {
|
|
1700
|
-
throw new (0,
|
|
1701
|
+
throw new (0, _chunk3FR22M3Ocjs.SettlementError)(
|
|
1701
1702
|
`upto settle: broadcast ${txHash} but couldn't confirm it (${shorten3(err instanceof Error ? err.message : String(err))}).`,
|
|
1702
1703
|
{ cause: err }
|
|
1703
1704
|
);
|
|
@@ -2040,7 +2041,7 @@ var evmDriver = {
|
|
|
2040
2041
|
try {
|
|
2041
2042
|
return makeEvmNetwork(resolveChain(opts.chain, opts.rpcUrl));
|
|
2042
2043
|
} catch (err) {
|
|
2043
|
-
throw new (0,
|
|
2044
|
+
throw new (0, _chunk3FR22M3Ocjs.UnsupportedNetworkError)(err instanceof Error ? err.message : String(err), { cause: err });
|
|
2044
2045
|
}
|
|
2045
2046
|
}
|
|
2046
2047
|
let resolved;
|
|
@@ -2074,20 +2075,20 @@ function makeEvmNetwork(resolved) {
|
|
|
2074
2075
|
const info = resolved.tokens[token.toUpperCase()];
|
|
2075
2076
|
if (!info) {
|
|
2076
2077
|
const known = Object.keys(resolved.tokens).join(", ") || "(none built in)";
|
|
2077
|
-
throw new (0,
|
|
2078
|
+
throw new (0, _chunk3FR22M3Ocjs.UnknownTokenError)(
|
|
2078
2079
|
`token "${token}" isn't built in for ${resolved.chain.name} (known: ${known}). Pass { address, decimals } instead, or use 'native'.`
|
|
2079
2080
|
);
|
|
2080
2081
|
}
|
|
2081
2082
|
return { asset: info.address, decimals: info.decimals, symbol: info.symbol };
|
|
2082
2083
|
}
|
|
2083
|
-
|
|
2084
|
+
_chunk3FR22M3Ocjs.rejectForeignToken.call(void 0, token, "evm", network);
|
|
2084
2085
|
if (!("address" in token)) {
|
|
2085
|
-
throw new (0,
|
|
2086
|
+
throw new (0, _chunk3FR22M3Ocjs.WrongFamilyError)(
|
|
2086
2087
|
`chain ${network} is EVM; a custom token must be { address, decimals }.`
|
|
2087
2088
|
);
|
|
2088
2089
|
}
|
|
2089
2090
|
if (!_viem.isAddress.call(void 0, token.address)) {
|
|
2090
|
-
throw new (0,
|
|
2091
|
+
throw new (0, _chunk3FR22M3Ocjs.WrongFamilyError)(
|
|
2091
2092
|
`chain ${network} is EVM, but token address "${token.address}" is not a valid 0x address.`
|
|
2092
2093
|
);
|
|
2093
2094
|
}
|
|
@@ -2119,20 +2120,20 @@ function makeEvmNetwork(resolved) {
|
|
|
2119
2120
|
},
|
|
2120
2121
|
assertValidPayTo(payTo) {
|
|
2121
2122
|
if (!_viem.isAddress.call(void 0, payTo)) {
|
|
2122
|
-
throw new (0,
|
|
2123
|
+
throw new (0, _chunk3FR22M3Ocjs.WrongFamilyError)(
|
|
2123
2124
|
`chain ${network} is EVM, but payTo "${payTo}" is not a valid 0x address.`
|
|
2124
2125
|
);
|
|
2125
2126
|
}
|
|
2126
2127
|
},
|
|
2127
2128
|
bindWallet(wallet) {
|
|
2128
2129
|
if (typeof wallet !== "object" || wallet === null) {
|
|
2129
|
-
throw new (0,
|
|
2130
|
+
throw new (0, _chunk3FR22M3Ocjs.WrongFamilyError)(
|
|
2130
2131
|
`chain ${network} is EVM; wallet must be { key } (0x\u2026 hex) or { walletClient }.`
|
|
2131
2132
|
);
|
|
2132
2133
|
}
|
|
2133
|
-
|
|
2134
|
+
_chunk3FR22M3Ocjs.assertNoLegacyWalletKey.call(void 0, wallet, "EVM");
|
|
2134
2135
|
if (!("key" in wallet) && !("walletClient" in wallet)) {
|
|
2135
|
-
throw new (0,
|
|
2136
|
+
throw new (0, _chunk3FR22M3Ocjs.WrongFamilyError)(
|
|
2136
2137
|
`chain ${network} is EVM; wallet must be { key } (0x\u2026 hex) or { walletClient }.`
|
|
2137
2138
|
);
|
|
2138
2139
|
}
|
|
@@ -2149,12 +2150,12 @@ function makeEvmNetwork(resolved) {
|
|
|
2149
2150
|
});
|
|
2150
2151
|
} catch (err) {
|
|
2151
2152
|
if (isViemInsufficientFunds(err)) {
|
|
2152
|
-
throw new (0,
|
|
2153
|
+
throw new (0, _chunk3FR22M3Ocjs.InsufficientFundsError)(
|
|
2153
2154
|
err instanceof Error ? err.message : "Insufficient funds for payment.",
|
|
2154
2155
|
{ cause: err }
|
|
2155
2156
|
);
|
|
2156
2157
|
}
|
|
2157
|
-
throw _nullishCoalesce(
|
|
2158
|
+
throw _nullishCoalesce(_chunk3FR22M3Ocjs.toInsufficientFundsError.call(void 0, err), () => ( err));
|
|
2158
2159
|
}
|
|
2159
2160
|
},
|
|
2160
2161
|
async confirm(ref, minConfirmations) {
|
|
@@ -2165,7 +2166,7 @@ function makeEvmNetwork(resolved) {
|
|
|
2165
2166
|
});
|
|
2166
2167
|
return { height: receipt.blockNumber.toString() };
|
|
2167
2168
|
} catch (err) {
|
|
2168
|
-
throw new (0,
|
|
2169
|
+
throw new (0, _chunk3FR22M3Ocjs.ConfirmationTimeoutError)(
|
|
2169
2170
|
`EVM tx ${ref} did not reach ${minConfirmations} confirmation(s) in time.`,
|
|
2170
2171
|
{ cause: err }
|
|
2171
2172
|
);
|
|
@@ -2176,7 +2177,7 @@ function makeEvmNetwork(resolved) {
|
|
|
2176
2177
|
if (accept.scheme === "exact" || accept.scheme === "upto") {
|
|
2177
2178
|
const m = _optionalChain([accept, 'access', _19 => _19.extra, 'optionalAccess', _20 => _20.assetTransferMethod]);
|
|
2178
2179
|
const permit2 = m === "permit2" || m === "permit2-exact" || m === "permit2-upto";
|
|
2179
|
-
return
|
|
2180
|
+
return _chunk3FR22M3Ocjs.nativeCost.call(void 0, {
|
|
2180
2181
|
symbol,
|
|
2181
2182
|
decimals,
|
|
2182
2183
|
fee: 0n,
|
|
@@ -2187,7 +2188,7 @@ function makeEvmNetwork(resolved) {
|
|
|
2187
2188
|
const gasLimit = accept.asset === "native" ? 21000n : 65000n;
|
|
2188
2189
|
try {
|
|
2189
2190
|
const gasPrice = await publicClient.getGasPrice();
|
|
2190
|
-
return
|
|
2191
|
+
return _chunk3FR22M3Ocjs.nativeCost.call(void 0, {
|
|
2191
2192
|
symbol,
|
|
2192
2193
|
decimals,
|
|
2193
2194
|
fee: gasPrice * gasLimit,
|
|
@@ -2196,7 +2197,7 @@ function makeEvmNetwork(resolved) {
|
|
|
2196
2197
|
});
|
|
2197
2198
|
} catch (e23) {
|
|
2198
2199
|
const gasPrice = 5000000000n;
|
|
2199
|
-
return
|
|
2200
|
+
return _chunk3FR22M3Ocjs.nativeCost.call(void 0, {
|
|
2200
2201
|
symbol,
|
|
2201
2202
|
decimals,
|
|
2202
2203
|
fee: gasPrice * gasLimit,
|
|
@@ -2381,9 +2382,9 @@ var loaders = {
|
|
|
2381
2382
|
solana: async () => {
|
|
2382
2383
|
let mod;
|
|
2383
2384
|
try {
|
|
2384
|
-
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./solana-
|
|
2385
|
+
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./solana-OU6IUMQM.cjs")));
|
|
2385
2386
|
} catch (cause) {
|
|
2386
|
-
throw new (0,
|
|
2387
|
+
throw new (0, _chunk3FR22M3Ocjs.MissingDriverError)(
|
|
2387
2388
|
`Solana selected, but its packages aren't installed. Run: npm install @solana/web3.js @solana/spl-token bs58`,
|
|
2388
2389
|
{ cause }
|
|
2389
2390
|
);
|
|
@@ -2393,9 +2394,9 @@ var loaders = {
|
|
|
2393
2394
|
ton: async () => {
|
|
2394
2395
|
let mod;
|
|
2395
2396
|
try {
|
|
2396
|
-
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./ton-
|
|
2397
|
+
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./ton-MYOI3U3H.cjs")));
|
|
2397
2398
|
} catch (cause) {
|
|
2398
|
-
throw new (0,
|
|
2399
|
+
throw new (0, _chunk3FR22M3Ocjs.MissingDriverError)(
|
|
2399
2400
|
`TON selected, but its packages aren't installed. Run: npm install @ton/ton @ton/core @ton/crypto`,
|
|
2400
2401
|
{ cause }
|
|
2401
2402
|
);
|
|
@@ -2405,9 +2406,9 @@ var loaders = {
|
|
|
2405
2406
|
stellar: async () => {
|
|
2406
2407
|
let mod;
|
|
2407
2408
|
try {
|
|
2408
|
-
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./stellar-
|
|
2409
|
+
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./stellar-RSNVOIKL.cjs")));
|
|
2409
2410
|
} catch (cause) {
|
|
2410
|
-
throw new (0,
|
|
2411
|
+
throw new (0, _chunk3FR22M3Ocjs.MissingDriverError)(
|
|
2411
2412
|
`Stellar selected, but its package isn't installed. Run: npm install @stellar/stellar-sdk`,
|
|
2412
2413
|
{ cause }
|
|
2413
2414
|
);
|
|
@@ -2417,9 +2418,9 @@ var loaders = {
|
|
|
2417
2418
|
xrpl: async () => {
|
|
2418
2419
|
let mod;
|
|
2419
2420
|
try {
|
|
2420
|
-
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./xrpl-
|
|
2421
|
+
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./xrpl-MGUBUNSZ.cjs")));
|
|
2421
2422
|
} catch (cause) {
|
|
2422
|
-
throw new (0,
|
|
2423
|
+
throw new (0, _chunk3FR22M3Ocjs.MissingDriverError)(
|
|
2423
2424
|
`XRPL selected, but its package isn't installed. Run: npm install xrpl`,
|
|
2424
2425
|
{ cause }
|
|
2425
2426
|
);
|
|
@@ -2429,9 +2430,9 @@ var loaders = {
|
|
|
2429
2430
|
tron: async () => {
|
|
2430
2431
|
let mod;
|
|
2431
2432
|
try {
|
|
2432
|
-
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./tron-
|
|
2433
|
+
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./tron-42X5N4GQ.cjs")));
|
|
2433
2434
|
} catch (cause) {
|
|
2434
|
-
throw new (0,
|
|
2435
|
+
throw new (0, _chunk3FR22M3Ocjs.MissingDriverError)(
|
|
2435
2436
|
`Tron selected, but its package isn't installed. Run: npm install tronweb`,
|
|
2436
2437
|
{ cause }
|
|
2437
2438
|
);
|
|
@@ -2441,9 +2442,9 @@ var loaders = {
|
|
|
2441
2442
|
sui: async () => {
|
|
2442
2443
|
let mod;
|
|
2443
2444
|
try {
|
|
2444
|
-
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./sui-
|
|
2445
|
+
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./sui-MVC46BFJ.cjs")));
|
|
2445
2446
|
} catch (cause) {
|
|
2446
|
-
throw new (0,
|
|
2447
|
+
throw new (0, _chunk3FR22M3Ocjs.MissingDriverError)(
|
|
2447
2448
|
`Sui selected, but its package isn't installed. Run: npm install @mysten/sui`,
|
|
2448
2449
|
{ cause }
|
|
2449
2450
|
);
|
|
@@ -2453,9 +2454,9 @@ var loaders = {
|
|
|
2453
2454
|
near: async () => {
|
|
2454
2455
|
let mod;
|
|
2455
2456
|
try {
|
|
2456
|
-
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./near-
|
|
2457
|
+
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./near-NDQLGI4U.cjs")));
|
|
2457
2458
|
} catch (cause) {
|
|
2458
|
-
throw new (0,
|
|
2459
|
+
throw new (0, _chunk3FR22M3Ocjs.MissingDriverError)(
|
|
2459
2460
|
`NEAR selected, but its package isn't installed. Run: npm install near-api-js`,
|
|
2460
2461
|
{ cause }
|
|
2461
2462
|
);
|
|
@@ -2465,9 +2466,9 @@ var loaders = {
|
|
|
2465
2466
|
aptos: async () => {
|
|
2466
2467
|
let mod;
|
|
2467
2468
|
try {
|
|
2468
|
-
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./aptos-
|
|
2469
|
+
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./aptos-GA5AEYYL.cjs")));
|
|
2469
2470
|
} catch (cause) {
|
|
2470
|
-
throw new (0,
|
|
2471
|
+
throw new (0, _chunk3FR22M3Ocjs.MissingDriverError)(
|
|
2471
2472
|
`Aptos selected, but its package isn't installed. Run: npm install @aptos-labs/ts-sdk`,
|
|
2472
2473
|
{ cause }
|
|
2473
2474
|
);
|
|
@@ -2477,9 +2478,9 @@ var loaders = {
|
|
|
2477
2478
|
algorand: async () => {
|
|
2478
2479
|
let mod;
|
|
2479
2480
|
try {
|
|
2480
|
-
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./algorand-
|
|
2481
|
+
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./algorand-I2O24RSM.cjs")));
|
|
2481
2482
|
} catch (cause) {
|
|
2482
|
-
throw new (0,
|
|
2483
|
+
throw new (0, _chunk3FR22M3Ocjs.MissingDriverError)(
|
|
2483
2484
|
`Algorand selected, but its package isn't installed. Run: npm install algosdk`,
|
|
2484
2485
|
{ cause }
|
|
2485
2486
|
);
|
|
@@ -2510,7 +2511,7 @@ async function resolveNetwork2(opts) {
|
|
|
2510
2511
|
}
|
|
2511
2512
|
|
|
2512
2513
|
// src/indexes.ts
|
|
2513
|
-
var DIRECTORY_INFO = {
|
|
2514
|
+
var DIRECTORY_INFO = Object.freeze({
|
|
2514
2515
|
"402index": {
|
|
2515
2516
|
source: "402index",
|
|
2516
2517
|
review: "probe-sync",
|
|
@@ -2538,7 +2539,7 @@ var DIRECTORY_INFO = {
|
|
|
2538
2539
|
readByDiscover: true,
|
|
2539
2540
|
caveat: "CDP Bazaar has no register endpoint \u2014 it catalogs a resource only when its own facilitator settles a payment. PipRail verifies locally with no facilitator, so a PipRail resource cannot be listed here (you can still READ Bazaar to find others). List on 402 Index or x402scan instead."
|
|
2540
2541
|
}
|
|
2541
|
-
};
|
|
2542
|
+
});
|
|
2542
2543
|
function getDirectoryInfo(source) {
|
|
2543
2544
|
return DIRECTORY_INFO[source];
|
|
2544
2545
|
}
|
|
@@ -3123,7 +3124,7 @@ function encodeBase642(str) {
|
|
|
3123
3124
|
}
|
|
3124
3125
|
|
|
3125
3126
|
// src/policy.ts
|
|
3126
|
-
var DENOM_PRECISION =
|
|
3127
|
+
var DENOM_PRECISION = _chunk3FR22M3Ocjs.MAX_DECIMALS;
|
|
3127
3128
|
var BUILTIN_DENOMS = {
|
|
3128
3129
|
USDC: "USD",
|
|
3129
3130
|
USDT: "USD",
|
|
@@ -3238,7 +3239,7 @@ function evaluatePolicy(intent, policy, spentForAssetBase, ctx) {
|
|
|
3238
3239
|
}
|
|
3239
3240
|
}
|
|
3240
3241
|
if (policy.maxAmount !== void 0) {
|
|
3241
|
-
const cap =
|
|
3242
|
+
const cap = _chunk3FR22M3Ocjs.floorUnits.call(void 0, policy.maxAmount, intent.decimals);
|
|
3242
3243
|
if (intent.amountBase > cap) {
|
|
3243
3244
|
return deny(
|
|
3244
3245
|
"MAX_AMOUNT",
|
|
@@ -3247,7 +3248,7 @@ function evaluatePolicy(intent, policy, spentForAssetBase, ctx) {
|
|
|
3247
3248
|
}
|
|
3248
3249
|
}
|
|
3249
3250
|
if (policy.maxTotal !== void 0) {
|
|
3250
|
-
const cap =
|
|
3251
|
+
const cap = _chunk3FR22M3Ocjs.floorUnits.call(void 0, policy.maxTotal, intent.decimals);
|
|
3251
3252
|
if (spentForAssetBase + intent.amountBase > cap) {
|
|
3252
3253
|
return deny(
|
|
3253
3254
|
"MAX_TOTAL",
|
|
@@ -3266,7 +3267,7 @@ function evaluatePolicy(intent, policy, spentForAssetBase, ctx) {
|
|
|
3266
3267
|
`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).`
|
|
3267
3268
|
);
|
|
3268
3269
|
}
|
|
3269
|
-
const capScaled =
|
|
3270
|
+
const capScaled = _chunk3FR22M3Ocjs.floorUnits.call(void 0, capStr, DENOM_PRECISION);
|
|
3270
3271
|
if ((_nullishCoalesce(ctx.spentInDenomScaled, () => ( 0n))) + thisScaled > capScaled) {
|
|
3271
3272
|
return deny(
|
|
3272
3273
|
"MAX_TOTAL_DENOM",
|
|
@@ -3284,7 +3285,7 @@ function evaluatePolicy(intent, policy, spentForAssetBase, ctx) {
|
|
|
3284
3285
|
}
|
|
3285
3286
|
}
|
|
3286
3287
|
if (ctx && policy.windowTotal !== void 0 && policy.windowSeconds !== void 0) {
|
|
3287
|
-
const cap =
|
|
3288
|
+
const cap = _chunk3FR22M3Ocjs.floorUnits.call(void 0, policy.windowTotal, intent.decimals);
|
|
3288
3289
|
if (ctx.spentInWindowBase + intent.amountBase > cap) {
|
|
3289
3290
|
return deny(
|
|
3290
3291
|
"WINDOW_TOTAL",
|
|
@@ -3350,7 +3351,7 @@ var SpendLedger = (_class = class {
|
|
|
3350
3351
|
* read or the constructor.
|
|
3351
3352
|
*/
|
|
3352
3353
|
isTallyable(r, decimals) {
|
|
3353
|
-
return !!r && typeof r.amountBase === "string" && /^\d+$/.test(r.amountBase) && Number.isInteger(decimals) && decimals >= 0 && decimals <=
|
|
3354
|
+
return !!r && typeof r.amountBase === "string" && /^\d+$/.test(r.amountBase) && Number.isInteger(decimals) && decimals >= 0 && decimals <= _chunk3FR22M3Ocjs.MAX_DECIMALS;
|
|
3354
3355
|
}
|
|
3355
3356
|
/** Apply a record to the in-memory tallies (records + per-asset bucket + denom total).
|
|
3356
3357
|
* Shared by {@link record} and constructor hydration; does NOT persist. Returns the
|
|
@@ -3487,13 +3488,13 @@ var SpendLedger = (_class = class {
|
|
|
3487
3488
|
symbol: b.symbol,
|
|
3488
3489
|
decimals: b.decimals,
|
|
3489
3490
|
totalBase: b.total.toString(),
|
|
3490
|
-
totalFormatted:
|
|
3491
|
+
totalFormatted: _chunk3FR22M3Ocjs.formatUnits.call(void 0, b.total, b.decimals),
|
|
3491
3492
|
count: b.count
|
|
3492
3493
|
})),
|
|
3493
3494
|
byDenom: [...this.denomTotals.entries()].map(([denom, scaled]) => ({
|
|
3494
3495
|
denom,
|
|
3495
3496
|
totalScaled: scaled.toString(),
|
|
3496
|
-
totalFormatted:
|
|
3497
|
+
totalFormatted: _chunk3FR22M3Ocjs.formatUnits.call(void 0, scaled, DENOM_PRECISION),
|
|
3497
3498
|
count: this.records.filter((r) => _optionalChain([r, 'access', _34 => _34.denom, 'optionalAccess', _35 => _35.toUpperCase, 'call', _36 => _36()]) === denom).length
|
|
3498
3499
|
})),
|
|
3499
3500
|
records: [...this.records]
|
|
@@ -3901,7 +3902,7 @@ var PipRailClient = (_class2 = class {
|
|
|
3901
3902
|
const cost = await net.estimateCost(accept);
|
|
3902
3903
|
return { quote, cost };
|
|
3903
3904
|
} catch (err) {
|
|
3904
|
-
if (err instanceof
|
|
3905
|
+
if (err instanceof _chunk3FR22M3Ocjs.InvalidEnvelopeError) return null;
|
|
3905
3906
|
throw err;
|
|
3906
3907
|
}
|
|
3907
3908
|
}
|
|
@@ -3953,14 +3954,14 @@ var PipRailClient = (_class2 = class {
|
|
|
3953
3954
|
return Object.entries(caps).map(([rawDenom, capStr]) => {
|
|
3954
3955
|
const denom = rawDenom.toUpperCase();
|
|
3955
3956
|
const spentScaled = this.ledger.totalForDenom(denom);
|
|
3956
|
-
const capScaled =
|
|
3957
|
+
const capScaled = _chunk3FR22M3Ocjs.floorUnits.call(void 0, capStr, DENOM_PRECISION);
|
|
3957
3958
|
const remainingScaled = capScaled > spentScaled ? capScaled - spentScaled : 0n;
|
|
3958
3959
|
const fraction = capScaled === 0n ? spentScaled > 0n ? 1 : 0 : Number(spentScaled * 1000000n / capScaled) / 1e6;
|
|
3959
3960
|
return {
|
|
3960
3961
|
denom,
|
|
3961
|
-
spentFormatted:
|
|
3962
|
-
capFormatted:
|
|
3963
|
-
remainingFormatted:
|
|
3962
|
+
spentFormatted: _chunk3FR22M3Ocjs.formatUnits.call(void 0, spentScaled, DENOM_PRECISION),
|
|
3963
|
+
capFormatted: _chunk3FR22M3Ocjs.formatUnits.call(void 0, capScaled, DENOM_PRECISION),
|
|
3964
|
+
remainingFormatted: _chunk3FR22M3Ocjs.formatUnits.call(void 0, remainingScaled, DENOM_PRECISION),
|
|
3964
3965
|
fraction
|
|
3965
3966
|
};
|
|
3966
3967
|
});
|
|
@@ -4001,13 +4002,13 @@ var PipRailClient = (_class2 = class {
|
|
|
4001
4002
|
spentBase: b.totalBase.toString()
|
|
4002
4003
|
};
|
|
4003
4004
|
if (maxTotal === void 0) return base2;
|
|
4004
|
-
const capBase =
|
|
4005
|
+
const capBase = _chunk3FR22M3Ocjs.floorUnits.call(void 0, maxTotal, b.decimals);
|
|
4005
4006
|
const remainingBase = capBase > b.totalBase ? capBase - b.totalBase : 0n;
|
|
4006
4007
|
return {
|
|
4007
4008
|
...base2,
|
|
4008
4009
|
capBase: capBase.toString(),
|
|
4009
4010
|
remainingBase: remainingBase.toString(),
|
|
4010
|
-
remainingFormatted:
|
|
4011
|
+
remainingFormatted: _chunk3FR22M3Ocjs.formatUnits.call(void 0, remainingBase, b.decimals)
|
|
4011
4012
|
};
|
|
4012
4013
|
});
|
|
4013
4014
|
}
|
|
@@ -4047,11 +4048,11 @@ var PipRailClient = (_class2 = class {
|
|
|
4047
4048
|
if (res.status !== 402) return null;
|
|
4048
4049
|
const challenge = await parseChallenge(res);
|
|
4049
4050
|
if (!challenge) {
|
|
4050
|
-
throw new (0,
|
|
4051
|
+
throw new (0, _chunk3FR22M3Ocjs.InvalidEnvelopeError)("402 response did not include a parseable x402 challenge.");
|
|
4051
4052
|
}
|
|
4052
4053
|
const { net, wallet } = await this.ensure();
|
|
4053
4054
|
if (!wallet) {
|
|
4054
|
-
throw new (0,
|
|
4055
|
+
throw new (0, _chunk3FR22M3Ocjs.WalletRequiredError)(
|
|
4055
4056
|
"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."
|
|
4056
4057
|
);
|
|
4057
4058
|
}
|
|
@@ -4227,7 +4228,7 @@ var PipRailClient = (_class2 = class {
|
|
|
4227
4228
|
async fetch(url, init) {
|
|
4228
4229
|
const body = _optionalChain([init, 'optionalAccess', _57 => _57.body]);
|
|
4229
4230
|
if (body !== void 0 && body !== null && !isReplayableBodyInit(body)) {
|
|
4230
|
-
throw new (0,
|
|
4231
|
+
throw new (0, _chunk3FR22M3Ocjs.NonReplayableBodyError)(
|
|
4231
4232
|
"fetch(): init.body is not replayable. Pass a string, FormData, URLSearchParams, ArrayBuffer, or Blob \u2014 not a ReadableStream."
|
|
4232
4233
|
);
|
|
4233
4234
|
}
|
|
@@ -4237,7 +4238,7 @@ var PipRailClient = (_class2 = class {
|
|
|
4237
4238
|
const resolved = await this.resolveChallenge(url, firstResponse, schemes);
|
|
4238
4239
|
const { net, wallet, challenge } = resolved;
|
|
4239
4240
|
if (!wallet) {
|
|
4240
|
-
throw new (0,
|
|
4241
|
+
throw new (0, _chunk3FR22M3Ocjs.WalletRequiredError)(
|
|
4241
4242
|
"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)."
|
|
4242
4243
|
);
|
|
4243
4244
|
}
|
|
@@ -4249,7 +4250,7 @@ var PipRailClient = (_class2 = class {
|
|
|
4249
4250
|
if (!plan.best) {
|
|
4250
4251
|
const reason = _nullishCoalesce(plan.fundingHint, () => ( "No rail is settleable for this payment."));
|
|
4251
4252
|
this.safeEmit({ kind: "payment-failed", reason });
|
|
4252
|
-
throw new (0,
|
|
4253
|
+
throw new (0, _chunk3FR22M3Ocjs.PaymentDeclinedError)(reason);
|
|
4253
4254
|
}
|
|
4254
4255
|
accept = plan.best.accept;
|
|
4255
4256
|
quote = plan.best.quote;
|
|
@@ -4263,7 +4264,7 @@ var PipRailClient = (_class2 = class {
|
|
|
4263
4264
|
return this.payExactRail(net, wallet, accept, url, init, quote);
|
|
4264
4265
|
}
|
|
4265
4266
|
if (accept.scheme !== "onchain-proof") {
|
|
4266
|
-
throw new (0,
|
|
4267
|
+
throw new (0, _chunk3FR22M3Ocjs.UnsupportedSchemeError)(
|
|
4267
4268
|
`internal: unrouted accept scheme '${accept.scheme}' reached the onchain-proof pay path.`
|
|
4268
4269
|
);
|
|
4269
4270
|
}
|
|
@@ -4281,7 +4282,7 @@ var PipRailClient = (_class2 = class {
|
|
|
4281
4282
|
async resolveChallenge(url, response, schemes) {
|
|
4282
4283
|
const challenge = await parseChallenge(response);
|
|
4283
4284
|
if (!challenge) {
|
|
4284
|
-
throw new (0,
|
|
4285
|
+
throw new (0, _chunk3FR22M3Ocjs.InvalidEnvelopeError)(
|
|
4285
4286
|
"402 response did not include a parseable x402 challenge."
|
|
4286
4287
|
);
|
|
4287
4288
|
}
|
|
@@ -4292,7 +4293,7 @@ var PipRailClient = (_class2 = class {
|
|
|
4292
4293
|
(a) => a.scheme === "exact" && this.supportsNetwork(net, a.network)
|
|
4293
4294
|
);
|
|
4294
4295
|
if (schemes.includes("exact") && exactOnNet && typeof net.payExact !== "function") {
|
|
4295
|
-
throw new (0,
|
|
4296
|
+
throw new (0, _chunk3FR22M3Ocjs.UnsupportedSchemeError)(
|
|
4296
4297
|
`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.`
|
|
4297
4298
|
);
|
|
4298
4299
|
}
|
|
@@ -4301,13 +4302,13 @@ var PipRailClient = (_class2 = class {
|
|
|
4301
4302
|
(a) => a.scheme === "exact" && this.supportsNetwork(net, a.network) && net.describeAsset(a.asset) != null
|
|
4302
4303
|
);
|
|
4303
4304
|
if (payable) {
|
|
4304
|
-
throw new (0,
|
|
4305
|
+
throw new (0, _chunk3FR22M3Ocjs.NoCompatibleAcceptError)(
|
|
4305
4306
|
`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).`
|
|
4306
4307
|
);
|
|
4307
4308
|
}
|
|
4308
4309
|
}
|
|
4309
4310
|
const networks = [...new Set(challenge.accepts.map((a) => a.network))].join(", ");
|
|
4310
|
-
throw new (0,
|
|
4311
|
+
throw new (0, _chunk3FR22M3Ocjs.NoCompatibleAcceptError)(
|
|
4311
4312
|
`No accepts[] entry payable by this client on ${net.network} (schemes: ${schemes.join(", ")}; challenge offered: ${networks || "none"}).`
|
|
4312
4313
|
);
|
|
4313
4314
|
}
|
|
@@ -4436,21 +4437,21 @@ var PipRailClient = (_class2 = class {
|
|
|
4436
4437
|
if (isExact) {
|
|
4437
4438
|
if (tokenKnown && bal.token < amount) {
|
|
4438
4439
|
blockers.push("INSUFFICIENT_TOKEN");
|
|
4439
|
-
shortfall.token =
|
|
4440
|
+
shortfall.token = _chunk3FR22M3Ocjs.formatUnits.call(void 0, amount - bal.token, quote.decimals);
|
|
4440
4441
|
}
|
|
4441
4442
|
} else if (isNative) {
|
|
4442
4443
|
if (nativeKnown && bal.native < amount + fee) {
|
|
4443
4444
|
blockers.push("INSUFFICIENT_TOKEN");
|
|
4444
|
-
shortfall.token =
|
|
4445
|
+
shortfall.token = _chunk3FR22M3Ocjs.formatUnits.call(void 0, amount + fee - bal.native, quote.decimals);
|
|
4445
4446
|
}
|
|
4446
4447
|
} else {
|
|
4447
4448
|
if (tokenKnown && bal.token < amount) {
|
|
4448
4449
|
blockers.push("INSUFFICIENT_TOKEN");
|
|
4449
|
-
shortfall.token =
|
|
4450
|
+
shortfall.token = _chunk3FR22M3Ocjs.formatUnits.call(void 0, amount - bal.token, quote.decimals);
|
|
4450
4451
|
}
|
|
4451
4452
|
if (nativeKnown && bal.native < fee) {
|
|
4452
4453
|
blockers.push("INSUFFICIENT_GAS");
|
|
4453
|
-
shortfall.native =
|
|
4454
|
+
shortfall.native = _chunk3FR22M3Ocjs.formatUnits.call(void 0, fee - bal.native, cost.feeDecimals);
|
|
4454
4455
|
} else if (nativeKnown && fee > 0n && bal.native < fee * 3n / 2n) {
|
|
4455
4456
|
warnings.push("THIN_GAS_MARGIN");
|
|
4456
4457
|
}
|
|
@@ -4475,8 +4476,8 @@ var PipRailClient = (_class2 = class {
|
|
|
4475
4476
|
blockers,
|
|
4476
4477
|
warnings,
|
|
4477
4478
|
balance: {
|
|
4478
|
-
token: bal.token != null ?
|
|
4479
|
-
native: bal.native != null ?
|
|
4479
|
+
token: bal.token != null ? _chunk3FR22M3Ocjs.formatUnits.call(void 0, bal.token, quote.decimals) : null,
|
|
4480
|
+
native: bal.native != null ? _chunk3FR22M3Ocjs.formatUnits.call(void 0, bal.native, cost.feeDecimals) : null
|
|
4480
4481
|
},
|
|
4481
4482
|
need: { token: quote.amountFormatted, native: cost.feeFormatted },
|
|
4482
4483
|
...shortfall.token || shortfall.native ? { shortfall } : {},
|
|
@@ -4487,12 +4488,12 @@ var PipRailClient = (_class2 = class {
|
|
|
4487
4488
|
* driver's describeAsset) + the policy verdict + a symbol-mismatch flag. */
|
|
4488
4489
|
buildQuote(net, accept, url, description) {
|
|
4489
4490
|
if (typeof accept.amount !== "string" || !/^\d+$/.test(accept.amount)) {
|
|
4490
|
-
throw new (0,
|
|
4491
|
+
throw new (0, _chunk3FR22M3Ocjs.InvalidEnvelopeError)(
|
|
4491
4492
|
`challenge amount "${String(accept.amount)}" is not a base-unit integer string.`
|
|
4492
4493
|
);
|
|
4493
4494
|
}
|
|
4494
4495
|
if (typeof accept.asset !== "string" || accept.asset.length === 0) {
|
|
4495
|
-
throw new (0,
|
|
4496
|
+
throw new (0, _chunk3FR22M3Ocjs.InvalidEnvelopeError)(
|
|
4496
4497
|
`challenge on ${accept.network} states no (string) asset \u2014 refusing to price it.`
|
|
4497
4498
|
);
|
|
4498
4499
|
}
|
|
@@ -4500,17 +4501,17 @@ var PipRailClient = (_class2 = class {
|
|
|
4500
4501
|
const described = net.describeAsset(accept.asset);
|
|
4501
4502
|
const decimals = _nullishCoalesce(_optionalChain([described, 'optionalAccess', _64 => _64.decimals]), () => ( _optionalChain([accept, 'access', _65 => _65.extra, 'optionalAccess', _66 => _66.decimals])));
|
|
4502
4503
|
if (typeof decimals !== "number" || !Number.isInteger(decimals) || decimals < 0) {
|
|
4503
|
-
throw new (0,
|
|
4504
|
+
throw new (0, _chunk3FR22M3Ocjs.InvalidEnvelopeError)(
|
|
4504
4505
|
`challenge for ${accept.asset} on ${accept.network} states no valid decimals and the SDK doesn't recognise the token \u2014 refusing to price it.`
|
|
4505
4506
|
);
|
|
4506
4507
|
}
|
|
4507
|
-
if (decimals >
|
|
4508
|
-
throw new (0,
|
|
4509
|
-
`challenge for ${accept.asset} on ${accept.network} states ${decimals} decimals (> ${
|
|
4508
|
+
if (decimals > _chunk3FR22M3Ocjs.MAX_DECIMALS) {
|
|
4509
|
+
throw new (0, _chunk3FR22M3Ocjs.InvalidEnvelopeError)(
|
|
4510
|
+
`challenge for ${accept.asset} on ${accept.network} states ${decimals} decimals (> ${_chunk3FR22M3Ocjs.MAX_DECIMALS}) \u2014 refusing to price it (no real token is that deep).`
|
|
4510
4511
|
);
|
|
4511
4512
|
}
|
|
4512
4513
|
const symbol = _nullishCoalesce(_optionalChain([described, 'optionalAccess', _67 => _67.symbol]), () => ( _optionalChain([accept, 'access', _68 => _68.extra, 'optionalAccess', _69 => _69.symbol])));
|
|
4513
|
-
const amountFormatted =
|
|
4514
|
+
const amountFormatted = _chunk3FR22M3Ocjs.formatUnits.call(void 0, amountBase, decimals);
|
|
4514
4515
|
const intent = {
|
|
4515
4516
|
host: hostOf2(url),
|
|
4516
4517
|
chain: this.opts.chain,
|
|
@@ -4615,7 +4616,7 @@ var PipRailClient = (_class2 = class {
|
|
|
4615
4616
|
...opts.quote ? { quote: opts.quote } : {},
|
|
4616
4617
|
budget: this.budget()
|
|
4617
4618
|
});
|
|
4618
|
-
throw new (0,
|
|
4619
|
+
throw new (0, _chunk3FR22M3Ocjs.PaymentDeclinedError)(reason, {
|
|
4619
4620
|
...opts.reasonCode ? { reasonCode: opts.reasonCode } : {},
|
|
4620
4621
|
...opts.cause !== void 0 ? { cause: opts.cause } : {}
|
|
4621
4622
|
});
|
|
@@ -4647,7 +4648,7 @@ var PipRailClient = (_class2 = class {
|
|
|
4647
4648
|
const max = BigInt(quote.amount);
|
|
4648
4649
|
const shown = claimed < max ? claimed : max;
|
|
4649
4650
|
settledBase = shown.toString();
|
|
4650
|
-
settledFormatted =
|
|
4651
|
+
settledFormatted = _chunk3FR22M3Ocjs.formatUnits.call(void 0, shown, quote.decimals);
|
|
4651
4652
|
} catch (e36) {
|
|
4652
4653
|
}
|
|
4653
4654
|
}
|
|
@@ -4698,8 +4699,8 @@ var PipRailClient = (_class2 = class {
|
|
|
4698
4699
|
fire(
|
|
4699
4700
|
"asset",
|
|
4700
4701
|
`${_nullishCoalesce(r.symbol, () => ( r.asset))} on ${r.network}`,
|
|
4701
|
-
|
|
4702
|
-
|
|
4702
|
+
_chunk3FR22M3Ocjs.formatUnits.call(void 0, spent, r.decimals),
|
|
4703
|
+
_chunk3FR22M3Ocjs.formatUnits.call(void 0, cap, r.decimals),
|
|
4703
4704
|
fraction
|
|
4704
4705
|
);
|
|
4705
4706
|
}
|
|
@@ -4710,14 +4711,14 @@ var PipRailClient = (_class2 = class {
|
|
|
4710
4711
|
if (_optionalChain([policy, 'optionalAccess', _75 => _75.windowTotal]) !== void 0 && policy.windowSeconds !== void 0) {
|
|
4711
4712
|
const since = Date.now() - policy.windowSeconds * 1e3;
|
|
4712
4713
|
for (const r of budget.byAsset) {
|
|
4713
|
-
const cap =
|
|
4714
|
+
const cap = _chunk3FR22M3Ocjs.floorUnits.call(void 0, policy.windowTotal, r.decimals);
|
|
4714
4715
|
const spent = this.ledger.totalSince(r.network, r.asset, since);
|
|
4715
4716
|
const fraction = cap === 0n ? spent > 0n ? 1 : 0 : Number(spent * 1000000n / cap) / 1e6;
|
|
4716
4717
|
fire(
|
|
4717
4718
|
"window",
|
|
4718
4719
|
`${_nullishCoalesce(r.symbol, () => ( r.asset))} on ${r.network}`,
|
|
4719
|
-
|
|
4720
|
-
|
|
4720
|
+
_chunk3FR22M3Ocjs.formatUnits.call(void 0, spent, r.decimals),
|
|
4721
|
+
_chunk3FR22M3Ocjs.formatUnits.call(void 0, cap, r.decimals),
|
|
4721
4722
|
fraction
|
|
4722
4723
|
);
|
|
4723
4724
|
}
|
|
@@ -4738,7 +4739,7 @@ var PipRailClient = (_class2 = class {
|
|
|
4738
4739
|
}
|
|
4739
4740
|
async payAndConfirm(net, wallet, accept) {
|
|
4740
4741
|
if (!this.supportsNetwork(net, accept.network)) {
|
|
4741
|
-
throw new (0,
|
|
4742
|
+
throw new (0, _chunk3FR22M3Ocjs.WrongChainError)(
|
|
4742
4743
|
`Challenge expects ${accept.network} but client is on ${net.network}.`
|
|
4743
4744
|
);
|
|
4744
4745
|
}
|
|
@@ -4791,7 +4792,7 @@ var PipRailClient = (_class2 = class {
|
|
|
4791
4792
|
});
|
|
4792
4793
|
} catch (err) {
|
|
4793
4794
|
if (timeoutController.signal.aborted) {
|
|
4794
|
-
throw new (0,
|
|
4795
|
+
throw new (0, _chunk3FR22M3Ocjs.PaymentTimeoutError)(
|
|
4795
4796
|
`Server did not respond within ${this.retryTimeoutMs}ms after broadcasting payment ${ref}. Re-verify or re-submit ref=${ref} \u2014 do NOT re-pay.`,
|
|
4796
4797
|
{ cause: err, ref }
|
|
4797
4798
|
);
|
|
@@ -4815,7 +4816,7 @@ var PipRailClient = (_class2 = class {
|
|
|
4815
4816
|
reason: `server returned 402 after broadcasting payment ${ref}${unconfirmedNote} (${why})`,
|
|
4816
4817
|
...lastReason ? { code: lastReason.error, detail: lastReason.detail } : {}
|
|
4817
4818
|
});
|
|
4818
|
-
throw new (0,
|
|
4819
|
+
throw new (0, _chunk3FR22M3Ocjs.MaxRetriesExceededError)(
|
|
4819
4820
|
`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).`,
|
|
4820
4821
|
{ ref }
|
|
4821
4822
|
);
|
|
@@ -4839,7 +4840,7 @@ var PipRailClient = (_class2 = class {
|
|
|
4839
4840
|
*/
|
|
4840
4841
|
async payExactRail(net, wallet, accept, url, init, quote) {
|
|
4841
4842
|
if (!net.payExact) {
|
|
4842
|
-
throw new (0,
|
|
4843
|
+
throw new (0, _chunk3FR22M3Ocjs.UnsupportedSchemeError)(
|
|
4843
4844
|
`the ${net.family} family can't pay a standard 'exact' rail (supported on EVM, Solana, Algorand, Aptos + NEAR today).`
|
|
4844
4845
|
);
|
|
4845
4846
|
}
|
|
@@ -4849,7 +4850,7 @@ var PipRailClient = (_class2 = class {
|
|
|
4849
4850
|
headers.set(HEADER_SIGNATURE, buildExactSignatureHeader({ accepted, payload }));
|
|
4850
4851
|
const rejectDefinitive = (why2) => {
|
|
4851
4852
|
this.safeEmit({ kind: "payment-failed", reason: `exact: facilitator rejected nonce=${nonce} (${why2})`, code: why2 });
|
|
4852
|
-
throw new (0,
|
|
4853
|
+
throw new (0, _chunk3FR22M3Ocjs.MaxRetriesExceededError)(
|
|
4853
4854
|
`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}.`,
|
|
4854
4855
|
{ ref: nonce }
|
|
4855
4856
|
);
|
|
@@ -4872,7 +4873,7 @@ var PipRailClient = (_class2 = class {
|
|
|
4872
4873
|
try {
|
|
4873
4874
|
response = await fetch(url, { ..._nullishCoalesce(init, () => ( {})), headers, signal });
|
|
4874
4875
|
} catch (err) {
|
|
4875
|
-
throw new (0,
|
|
4876
|
+
throw new (0, _chunk3FR22M3Ocjs.PaymentTimeoutError)(
|
|
4876
4877
|
`exact: no response after submitting the authorization (nonce=${nonce}) to ${hostOf2(url)}. The facilitator may have already settled it \u2014 verify on-chain via ${exactSettleCheckHint(net.family, payerFrom, nonce)} before re-presenting the SAME signed authorization; do NOT re-pay.`,
|
|
4877
4878
|
{ cause: err, ref: nonce }
|
|
4878
4879
|
);
|
|
@@ -4907,7 +4908,7 @@ var PipRailClient = (_class2 = class {
|
|
|
4907
4908
|
reason: `exact: 402 after submitting authorization nonce=${nonce} (${why})`,
|
|
4908
4909
|
...lastReason ? { code: lastReason.error, detail: lastReason.detail } : {}
|
|
4909
4910
|
});
|
|
4910
|
-
throw new (0,
|
|
4911
|
+
throw new (0, _chunk3FR22M3Ocjs.MaxRetriesExceededError)(
|
|
4911
4912
|
`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}.`,
|
|
4912
4913
|
{ ref: nonce }
|
|
4913
4914
|
);
|
|
@@ -4923,7 +4924,7 @@ var PipRailClient = (_class2 = class {
|
|
|
4923
4924
|
*/
|
|
4924
4925
|
async payUptoRail(net, wallet, accept, url, init, quote) {
|
|
4925
4926
|
if (!net.payUpto) {
|
|
4926
|
-
throw new (0,
|
|
4927
|
+
throw new (0, _chunk3FR22M3Ocjs.UnsupportedSchemeError)(
|
|
4927
4928
|
`the ${net.family} family can't pay a standard 'upto' rail (EVM-Permit2 only today).`
|
|
4928
4929
|
);
|
|
4929
4930
|
}
|
|
@@ -4933,7 +4934,7 @@ var PipRailClient = (_class2 = class {
|
|
|
4933
4934
|
headers.set(HEADER_SIGNATURE, buildUptoSignatureHeader({ accepted, payload }));
|
|
4934
4935
|
const rejectDefinitive = (why2) => {
|
|
4935
4936
|
this.safeEmit({ kind: "payment-failed", reason: `upto: facilitator rejected nonce=${nonce} (${why2})`, code: why2 });
|
|
4936
|
-
throw new (0,
|
|
4937
|
+
throw new (0, _chunk3FR22M3Ocjs.MaxRetriesExceededError)(
|
|
4937
4938
|
`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}.`,
|
|
4938
4939
|
{ ref: nonce }
|
|
4939
4940
|
);
|
|
@@ -4956,7 +4957,7 @@ var PipRailClient = (_class2 = class {
|
|
|
4956
4957
|
try {
|
|
4957
4958
|
response = await fetch(url, { ..._nullishCoalesce(init, () => ( {})), headers, signal });
|
|
4958
4959
|
} catch (err) {
|
|
4959
|
-
throw new (0,
|
|
4960
|
+
throw new (0, _chunk3FR22M3Ocjs.PaymentTimeoutError)(
|
|
4960
4961
|
`upto: no response after submitting the authorization (nonce=${nonce}) to ${hostOf2(url)}. The merchant may have already settled it \u2014 verify on-chain before re-presenting; do NOT re-pay.`,
|
|
4961
4962
|
{ cause: err, ref: nonce }
|
|
4962
4963
|
);
|
|
@@ -4992,7 +4993,7 @@ var PipRailClient = (_class2 = class {
|
|
|
4992
4993
|
reason: `upto: 402 after submitting authorization nonce=${nonce} (${why})`,
|
|
4993
4994
|
...lastReason ? { code: lastReason.error, detail: lastReason.detail } : {}
|
|
4994
4995
|
});
|
|
4995
|
-
throw new (0,
|
|
4996
|
+
throw new (0, _chunk3FR22M3Ocjs.MaxRetriesExceededError)(
|
|
4996
4997
|
`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}.`,
|
|
4997
4998
|
{ ref: nonce }
|
|
4998
4999
|
);
|
|
@@ -5105,7 +5106,7 @@ async function fetchAcross(clients, url, init) {
|
|
|
5105
5106
|
const best = rankAcross(live.map((p) => p.plan)).find((o) => o.state === "payable");
|
|
5106
5107
|
if (!best) {
|
|
5107
5108
|
const hint = mergeDeclineHint(live.map((p) => p.plan));
|
|
5108
|
-
throw new (0,
|
|
5109
|
+
throw new (0, _chunk3FR22M3Ocjs.PaymentDeclinedError)(hint || "No funded chain can settle this payment right now.");
|
|
5109
5110
|
}
|
|
5110
5111
|
const owner = live.find((p) => p.plan.options.includes(best)).client;
|
|
5111
5112
|
return owner.fetch(url, { ..._nullishCoalesce(init, () => ( {})), autoRoute: true });
|
|
@@ -5505,7 +5506,7 @@ function summarizePlan(plan) {
|
|
|
5505
5506
|
return `NOT payable: ${_nullishCoalesce(plan.fundingHint, () => ( `no settleable rail on ${plan.network}`))}`;
|
|
5506
5507
|
}
|
|
5507
5508
|
function explainDecline(err) {
|
|
5508
|
-
if (!(err instanceof
|
|
5509
|
+
if (!(err instanceof _chunk3FR22M3Ocjs.PipRailError)) {
|
|
5509
5510
|
return `Payment failed: ${err instanceof Error ? err.message : String(err)}`;
|
|
5510
5511
|
}
|
|
5511
5512
|
switch (err.code) {
|
|
@@ -5536,16 +5537,20 @@ function formatSpendReport(summary) {
|
|
|
5536
5537
|
return `${perAsset} \u2014 grand total: ${grand}`;
|
|
5537
5538
|
}
|
|
5538
5539
|
function describeChallenge(challenge) {
|
|
5539
|
-
const
|
|
5540
|
-
|
|
5541
|
-
|
|
5540
|
+
const generic = `${BRAND.name} x402 payment endpoint. Pay with @piprail/sdk (${BRAND.sdkInstall}). Docs: ${BRAND.home}.`;
|
|
5541
|
+
try {
|
|
5542
|
+
const accepts = Array.isArray(_optionalChain([challenge, 'optionalAccess', _113 => _113.accepts])) ? challenge.accepts : [];
|
|
5543
|
+
const first = accepts[0];
|
|
5544
|
+
if (!first) return generic;
|
|
5545
|
+
const extra = _nullishCoalesce(first.extra, () => ( {}));
|
|
5546
|
+
const amount = _nullishCoalesce(extra.amountFormatted, () => ( first.amount));
|
|
5547
|
+
const token = _nullishCoalesce(extra.symbol, () => ( first.asset));
|
|
5548
|
+
const hasExact = accepts.some((a) => _optionalChain([a, 'optionalAccess', _114 => _114.scheme]) === "exact");
|
|
5549
|
+
const standard = hasExact ? "; or any standard x402 client (an exact rail is offered)" : "";
|
|
5550
|
+
return `${BRAND.name} x402 payment endpoint \u2014 pay ${amount} ${token} on ${first.network} to ${first.payTo}. Programmatic: ${BRAND.sdkInstall} then client.fetch(url)${standard}. Docs: ${BRAND.home}.`;
|
|
5551
|
+
} catch (e41) {
|
|
5552
|
+
return generic;
|
|
5542
5553
|
}
|
|
5543
|
-
const extra = _nullishCoalesce(first.extra, () => ( {}));
|
|
5544
|
-
const amount = _nullishCoalesce(extra.amountFormatted, () => ( first.amount));
|
|
5545
|
-
const token = _nullishCoalesce(extra.symbol, () => ( first.asset));
|
|
5546
|
-
const hasExact = challenge.accepts.some((a) => a.scheme === "exact");
|
|
5547
|
-
const standard = hasExact ? "; or any standard x402 client (an exact rail is offered)" : "";
|
|
5548
|
-
return `${BRAND.name} x402 payment endpoint \u2014 pay ${amount} ${token} on ${first.network} to ${first.payTo}. Programmatic: ${BRAND.sdkInstall} then client.fetch(url)${standard}. Docs: ${BRAND.home}.`;
|
|
5549
5554
|
}
|
|
5550
5555
|
|
|
5551
5556
|
// src/agentGuide.ts
|
|
@@ -5652,19 +5657,19 @@ async function readBody(res) {
|
|
|
5652
5657
|
if (!text) return null;
|
|
5653
5658
|
try {
|
|
5654
5659
|
return JSON.parse(text);
|
|
5655
|
-
} catch (
|
|
5660
|
+
} catch (e42) {
|
|
5656
5661
|
return text;
|
|
5657
5662
|
}
|
|
5658
5663
|
}
|
|
5659
5664
|
function toToolError(err) {
|
|
5660
|
-
if (!(err instanceof
|
|
5665
|
+
if (!(err instanceof _chunk3FR22M3Ocjs.PipRailError)) throw err;
|
|
5661
5666
|
const out = {
|
|
5662
5667
|
ok: false,
|
|
5663
5668
|
code: err.code,
|
|
5664
5669
|
reason: err.message,
|
|
5665
5670
|
explain: explainDecline(err)
|
|
5666
5671
|
};
|
|
5667
|
-
if (err instanceof
|
|
5672
|
+
if (err instanceof _chunk3FR22M3Ocjs.PaymentDeclinedError) {
|
|
5668
5673
|
out.declined = true;
|
|
5669
5674
|
if (err.reasonCode) out.reasonCode = err.reasonCode;
|
|
5670
5675
|
}
|
|
@@ -5880,14 +5885,14 @@ function paymentTools(client) {
|
|
|
5880
5885
|
...verifiable ? { verifiableReceipt: { ...verifiable, resource: { url } } } : {}
|
|
5881
5886
|
};
|
|
5882
5887
|
} catch (err) {
|
|
5883
|
-
if (err instanceof
|
|
5888
|
+
if (err instanceof _chunk3FR22M3Ocjs.PipRailError) {
|
|
5884
5889
|
const out = {
|
|
5885
5890
|
ok: false,
|
|
5886
5891
|
code: err.code,
|
|
5887
5892
|
reason: err.message,
|
|
5888
5893
|
explain: explainDecline(err)
|
|
5889
5894
|
};
|
|
5890
|
-
if (err instanceof
|
|
5895
|
+
if (err instanceof _chunk3FR22M3Ocjs.PaymentDeclinedError) {
|
|
5891
5896
|
out.declined = true;
|
|
5892
5897
|
if (err.reasonCode) out.reasonCode = err.reasonCode;
|
|
5893
5898
|
}
|
|
@@ -6035,15 +6040,29 @@ function paymentTools(client) {
|
|
|
6035
6040
|
|
|
6036
6041
|
// src/classify.ts
|
|
6037
6042
|
function classifyChallenge(challenge, opts) {
|
|
6038
|
-
|
|
6039
|
-
|
|
6040
|
-
|
|
6041
|
-
|
|
6042
|
-
|
|
6043
|
-
|
|
6044
|
-
|
|
6045
|
-
|
|
6046
|
-
|
|
6043
|
+
try {
|
|
6044
|
+
const accepts = Array.isArray(_optionalChain([challenge, 'optionalAccess', _115 => _115.accepts])) ? challenge.accepts : [];
|
|
6045
|
+
const network = _optionalChain([opts, 'optionalAccess', _116 => _116.network]);
|
|
6046
|
+
const schemes = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _117 => _117.schemes]), () => ( []));
|
|
6047
|
+
const offeredSchemes = [
|
|
6048
|
+
...new Set(accepts.map((a) => _optionalChain([a, 'optionalAccess', _118 => _118.scheme])).filter((s) => s != null))
|
|
6049
|
+
];
|
|
6050
|
+
const offeredNetworks = [...new Set(accepts.map((a) => _optionalChain([a, 'optionalAccess', _119 => _119.network])).filter((n) => n != null))];
|
|
6051
|
+
const onClientChain = accepts.some((a) => _optionalChain([a, 'optionalAccess', _120 => _120.network]) === network);
|
|
6052
|
+
const payableScheme = accepts.some(
|
|
6053
|
+
(a) => _optionalChain([a, 'optionalAccess', _121 => _121.network]) === network && schemes.includes(_optionalChain([a, 'optionalAccess', _122 => _122.scheme]))
|
|
6054
|
+
);
|
|
6055
|
+
const verdict = accepts.length === 0 ? "NO_RAIL" : payableScheme ? "PAYABLE_RAIL" : onClientChain ? "UNPAYABLE_SCHEME" : "WRONG_CHAIN";
|
|
6056
|
+
return { onClientChain, payableScheme, offeredSchemes, offeredNetworks, verdict };
|
|
6057
|
+
} catch (e43) {
|
|
6058
|
+
return {
|
|
6059
|
+
onClientChain: false,
|
|
6060
|
+
payableScheme: false,
|
|
6061
|
+
offeredSchemes: [],
|
|
6062
|
+
offeredNetworks: [],
|
|
6063
|
+
verdict: "NO_RAIL"
|
|
6064
|
+
};
|
|
6065
|
+
}
|
|
6047
6066
|
}
|
|
6048
6067
|
|
|
6049
6068
|
// src/discovery.ts
|
|
@@ -6085,11 +6104,12 @@ function buildBazaarExtension(descriptor = {}) {
|
|
|
6085
6104
|
function pathOf(url) {
|
|
6086
6105
|
try {
|
|
6087
6106
|
return new URL(url).pathname || "/";
|
|
6088
|
-
} catch (
|
|
6107
|
+
} catch (e44) {
|
|
6089
6108
|
return url.startsWith("/") ? url : `/${url}`;
|
|
6090
6109
|
}
|
|
6091
6110
|
}
|
|
6092
6111
|
function buildOpenApi(input) {
|
|
6112
|
+
assertResourceList(_optionalChain([input, 'optionalAccess', _123 => _123.resources]), "buildOpenApi");
|
|
6093
6113
|
const paths = {};
|
|
6094
6114
|
for (const r of input.resources) {
|
|
6095
6115
|
const path = pathOf(r.url);
|
|
@@ -6119,16 +6139,31 @@ function buildOpenApi(input) {
|
|
|
6119
6139
|
};
|
|
6120
6140
|
}
|
|
6121
6141
|
function buildWellKnownX402(input) {
|
|
6142
|
+
assertResourceList(_optionalChain([input, 'optionalAccess', _124 => _124.resources]), "buildWellKnownX402");
|
|
6122
6143
|
return {
|
|
6123
6144
|
version: 1,
|
|
6124
6145
|
resources: input.resources.map((r) => r.url),
|
|
6125
6146
|
...input.ownershipProofs && input.ownershipProofs.length > 0 ? { ownershipProofs: input.ownershipProofs } : {}
|
|
6126
6147
|
};
|
|
6127
6148
|
}
|
|
6149
|
+
function assertResourceList(resources, fn) {
|
|
6150
|
+
if (!Array.isArray(resources)) {
|
|
6151
|
+
throw new (0, _chunk3FR22M3Ocjs.InvalidConfigError)(`${fn}: \`resources\` must be an array of ResourceDescription.`);
|
|
6152
|
+
}
|
|
6153
|
+
resources.forEach((r, i) => {
|
|
6154
|
+
if (r === null || typeof r !== "object" || typeof r.url !== "string") {
|
|
6155
|
+
throw new (0, _chunk3FR22M3Ocjs.InvalidConfigError)(
|
|
6156
|
+
`${fn}: resources[${i}] must be a ResourceDescription with a string \`url\`.`
|
|
6157
|
+
);
|
|
6158
|
+
}
|
|
6159
|
+
});
|
|
6160
|
+
}
|
|
6128
6161
|
function buildWellKnownX402Manifest(input) {
|
|
6162
|
+
assertResourceList(_optionalChain([input, 'optionalAccess', _125 => _125.resources]), "buildWellKnownX402Manifest");
|
|
6163
|
+
const lastUpdated = typeof input.lastUpdated === "number" && Number.isFinite(input.lastUpdated) ? input.lastUpdated : Math.floor(Date.now() / 1e3);
|
|
6129
6164
|
return {
|
|
6130
6165
|
x402Version: 2,
|
|
6131
|
-
lastUpdated
|
|
6166
|
+
lastUpdated,
|
|
6132
6167
|
items: input.resources.map((r) => ({
|
|
6133
6168
|
resource: {
|
|
6134
6169
|
url: r.url,
|
|
@@ -6211,28 +6246,28 @@ async function fetchFacilitatorFeePayer(url, network, timeoutMs = 8e3) {
|
|
|
6211
6246
|
const res = await fetch(`${base2}/supported`, { signal: ctrl.signal });
|
|
6212
6247
|
if (!res.ok) return void 0;
|
|
6213
6248
|
const body = await res.json();
|
|
6214
|
-
const kinds = Array.isArray(_optionalChain([body, 'optionalAccess',
|
|
6249
|
+
const kinds = Array.isArray(_optionalChain([body, 'optionalAccess', _126 => _126.kinds])) ? body.kinds : [];
|
|
6215
6250
|
const want = normalizeNetwork(network);
|
|
6216
|
-
const kind = kinds.find((k) => _optionalChain([k, 'optionalAccess',
|
|
6217
|
-
const fp = _optionalChain([kind, 'optionalAccess',
|
|
6251
|
+
const kind = kinds.find((k) => _optionalChain([k, 'optionalAccess', _127 => _127.scheme]) === "exact" && normalizeNetwork(String(_nullishCoalesce(_optionalChain([k, 'optionalAccess', _128 => _128.network]), () => ( "")))) === want);
|
|
6252
|
+
const fp = _optionalChain([kind, 'optionalAccess', _129 => _129.extra, 'optionalAccess', _130 => _130.feePayer]);
|
|
6218
6253
|
return typeof fp === "string" ? fp : void 0;
|
|
6219
|
-
} catch (
|
|
6254
|
+
} catch (e45) {
|
|
6220
6255
|
return void 0;
|
|
6221
6256
|
} finally {
|
|
6222
6257
|
clearTimeout(timer);
|
|
6223
6258
|
}
|
|
6224
6259
|
}
|
|
6225
6260
|
function parseFacilitatorSupported(body) {
|
|
6226
|
-
const kinds = _optionalChain([body, 'optionalAccess',
|
|
6261
|
+
const kinds = _optionalChain([body, 'optionalAccess', _131 => _131.kinds]);
|
|
6227
6262
|
if (!Array.isArray(kinds)) return [];
|
|
6228
6263
|
const out = [];
|
|
6229
6264
|
for (const k of kinds) {
|
|
6230
6265
|
if (!k || typeof k !== "object") continue;
|
|
6231
6266
|
const o = k;
|
|
6232
6267
|
if (typeof o.scheme !== "string" || typeof o.network !== "string") continue;
|
|
6233
|
-
const fp = _optionalChain([o, 'access',
|
|
6268
|
+
const fp = _optionalChain([o, 'access', _132 => _132.extra, 'optionalAccess', _133 => _133.feePayer]);
|
|
6234
6269
|
const ver = o.x402Version;
|
|
6235
|
-
const method = _optionalChain([o, 'access',
|
|
6270
|
+
const method = _optionalChain([o, 'access', _134 => _134.extra, 'optionalAccess', _135 => _135.assetTransferMethod]);
|
|
6236
6271
|
out.push({
|
|
6237
6272
|
scheme: o.scheme,
|
|
6238
6273
|
network: o.network,
|
|
@@ -6251,7 +6286,7 @@ async function facilitatorCoverage(url, timeoutMs = 8e3) {
|
|
|
6251
6286
|
const res = await fetch(`${base2}/supported`, { signal: ctrl.signal });
|
|
6252
6287
|
if (!res.ok) return [];
|
|
6253
6288
|
return parseFacilitatorSupported(await res.json());
|
|
6254
|
-
} catch (
|
|
6289
|
+
} catch (e46) {
|
|
6255
6290
|
return [];
|
|
6256
6291
|
} finally {
|
|
6257
6292
|
clearTimeout(timer);
|
|
@@ -6280,7 +6315,7 @@ async function post(url, body, headers) {
|
|
|
6280
6315
|
let json = null;
|
|
6281
6316
|
try {
|
|
6282
6317
|
json = await res.json();
|
|
6283
|
-
} catch (
|
|
6318
|
+
} catch (e47) {
|
|
6284
6319
|
}
|
|
6285
6320
|
return { status: res.status, json };
|
|
6286
6321
|
}
|
|
@@ -6296,13 +6331,13 @@ async function settleViaFacilitator(input) {
|
|
|
6296
6331
|
try {
|
|
6297
6332
|
verify = await post(`${base2}/verify`, body, auth);
|
|
6298
6333
|
} catch (err) {
|
|
6299
|
-
throw new (0,
|
|
6334
|
+
throw new (0, _chunk3FR22M3Ocjs.SettlementError)(
|
|
6300
6335
|
`exact settle (facilitator ${base2}): /verify request failed (${err instanceof Error ? err.message : String(err)}).`,
|
|
6301
6336
|
{ cause: err }
|
|
6302
6337
|
);
|
|
6303
6338
|
}
|
|
6304
6339
|
if (verify.status !== 200) {
|
|
6305
|
-
throw new (0,
|
|
6340
|
+
throw new (0, _chunk3FR22M3Ocjs.SettlementError)(
|
|
6306
6341
|
`exact settle (facilitator ${base2}): /verify returned HTTP ${verify.status} (transport/auth error).`
|
|
6307
6342
|
);
|
|
6308
6343
|
}
|
|
@@ -6318,13 +6353,13 @@ async function settleViaFacilitator(input) {
|
|
|
6318
6353
|
try {
|
|
6319
6354
|
settle = await post(`${base2}/settle`, body, auth);
|
|
6320
6355
|
} catch (err) {
|
|
6321
|
-
throw new (0,
|
|
6356
|
+
throw new (0, _chunk3FR22M3Ocjs.SettlementError)(
|
|
6322
6357
|
`exact settle (facilitator ${base2}): /settle request failed (${err instanceof Error ? err.message : String(err)}).`,
|
|
6323
6358
|
{ cause: err }
|
|
6324
6359
|
);
|
|
6325
6360
|
}
|
|
6326
6361
|
if (settle.status !== 200) {
|
|
6327
|
-
throw new (0,
|
|
6362
|
+
throw new (0, _chunk3FR22M3Ocjs.SettlementError)(
|
|
6328
6363
|
`exact settle (facilitator ${base2}): /settle returned HTTP ${settle.status} (transport/auth error).`
|
|
6329
6364
|
);
|
|
6330
6365
|
}
|
|
@@ -6674,18 +6709,25 @@ function toInvalidBody(result) {
|
|
|
6674
6709
|
return { x402Version: 2, status: "invalid", error: result.error, detail: result.detail };
|
|
6675
6710
|
}
|
|
6676
6711
|
function normaliseAccepts(options) {
|
|
6677
|
-
if (options.accept && options.accept.length > 0) {
|
|
6712
|
+
if (Array.isArray(options.accept) && options.accept.length > 0) {
|
|
6678
6713
|
if (options.chain !== void 0 || options.token !== void 0 || options.amount !== void 0) {
|
|
6679
|
-
throw new
|
|
6714
|
+
throw new (0, _chunk3FR22M3Ocjs.InvalidConfigError)(
|
|
6680
6715
|
"requirePayment: pass EITHER `accept: [...]` (multi-chain) OR `chain`/`token`/`amount` (single) \u2014 not both."
|
|
6681
6716
|
);
|
|
6682
6717
|
}
|
|
6718
|
+
options.accept.forEach((a, i) => {
|
|
6719
|
+
if (a === null || typeof a !== "object") {
|
|
6720
|
+
throw new (0, _chunk3FR22M3Ocjs.InvalidConfigError)(
|
|
6721
|
+
`requirePayment: accept[${i}] must be { chain, token, amount }, got ${a === null ? "null" : typeof a}.`
|
|
6722
|
+
);
|
|
6723
|
+
}
|
|
6724
|
+
});
|
|
6683
6725
|
return options.accept;
|
|
6684
6726
|
}
|
|
6685
6727
|
if (options.chain !== void 0 && options.token !== void 0 && options.amount !== void 0) {
|
|
6686
6728
|
return [{ chain: options.chain, token: options.token, amount: options.amount }];
|
|
6687
6729
|
}
|
|
6688
|
-
throw new
|
|
6730
|
+
throw new (0, _chunk3FR22M3Ocjs.InvalidConfigError)(
|
|
6689
6731
|
"requirePayment: provide either { chain, token, amount } or a non-empty `accept: [{ chain, token, amount }, \u2026]`."
|
|
6690
6732
|
);
|
|
6691
6733
|
}
|
|
@@ -6719,7 +6761,7 @@ function createPaymentGate(options) {
|
|
|
6719
6761
|
attestWarned = true;
|
|
6720
6762
|
try {
|
|
6721
6763
|
console.warn(`[piprail] receipts.attest ${reason}; emitting an unsigned Tier-1 receipt instead.`);
|
|
6722
|
-
} catch (
|
|
6764
|
+
} catch (e48) {
|
|
6723
6765
|
}
|
|
6724
6766
|
}
|
|
6725
6767
|
let resolved;
|
|
@@ -6734,13 +6776,13 @@ function createPaymentGate(options) {
|
|
|
6734
6776
|
const net = await resolveNetwork2({ chain: a.chain, rpcUrl: _nullishCoalesce(a.rpcUrl, () => ( options.rpcUrl)) });
|
|
6735
6777
|
const payTo = _nullishCoalesce(a.payTo, () => ( options.payTo));
|
|
6736
6778
|
if (!payTo) {
|
|
6737
|
-
throw new
|
|
6779
|
+
throw new (0, _chunk3FR22M3Ocjs.InvalidConfigError)(
|
|
6738
6780
|
`requirePayment: no payTo for chain ${net.network}. Set it on the accept entry or pass a top-level payTo.`
|
|
6739
6781
|
);
|
|
6740
6782
|
}
|
|
6741
6783
|
net.assertValidPayTo(payTo);
|
|
6742
6784
|
const { asset, decimals, symbol } = net.resolveToken(a.token);
|
|
6743
|
-
const amountBase =
|
|
6785
|
+
const amountBase = _chunk3FR22M3Ocjs.parseUnits.call(void 0, a.amount, decimals);
|
|
6744
6786
|
const spec = { net, asset, decimals, symbol, amountBase, amountFormatted: a.amount, payTo };
|
|
6745
6787
|
if (exactOption) {
|
|
6746
6788
|
const outcome = await resolveExactRail(net, asset);
|
|
@@ -6763,7 +6805,7 @@ function createPaymentGate(options) {
|
|
|
6763
6805
|
if (exactOption && !specs.some((s) => s.exact)) {
|
|
6764
6806
|
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.";
|
|
6765
6807
|
if (exactOption.settle === "keyless") {
|
|
6766
|
-
if (typeof process === "undefined" || !_optionalChain([process, 'optionalAccess',
|
|
6808
|
+
if (typeof process === "undefined" || !_optionalChain([process, 'optionalAccess', _136 => _136.env, 'optionalAccess', _137 => _137.PIPRAIL_NO_HINTS])) {
|
|
6767
6809
|
console.warn(
|
|
6768
6810
|
`[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.)`
|
|
6769
6811
|
);
|
|
@@ -6791,7 +6833,7 @@ function createPaymentGate(options) {
|
|
|
6791
6833
|
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).`
|
|
6792
6834
|
};
|
|
6793
6835
|
}
|
|
6794
|
-
if (typeof process === "undefined" || _optionalChain([process, 'optionalAccess',
|
|
6836
|
+
if (typeof process === "undefined" || _optionalChain([process, 'optionalAccess', _138 => _138.env, 'optionalAccess', _139 => _139.NODE_ENV]) !== "production" && !_optionalChain([process, 'optionalAccess', _140 => _140.env, 'optionalAccess', _141 => _141.PIPRAIL_NO_HINTS])) {
|
|
6795
6837
|
console.warn(
|
|
6796
6838
|
`[piprail] exact: keyless rail on ${net.network} auto-settles via ${picked.url} (zero-config; pin \`exact.settle.facilitator\` in production).`
|
|
6797
6839
|
);
|
|
@@ -6935,7 +6977,7 @@ function createPaymentGate(options) {
|
|
|
6935
6977
|
extra: {
|
|
6936
6978
|
assetTransferMethod: "permit2-upto",
|
|
6937
6979
|
// facilitatorAddress comes from rail.extra; the spread below carries it (+ name/version).
|
|
6938
|
-
facilitatorAddress: _nullishCoalesce(_optionalChain([rail, 'access',
|
|
6980
|
+
facilitatorAddress: _nullishCoalesce(_optionalChain([rail, 'access', _142 => _142.extra, 'optionalAccess', _143 => _143.facilitatorAddress]), () => ( "")),
|
|
6939
6981
|
minConfirmations,
|
|
6940
6982
|
decimals: s.decimals,
|
|
6941
6983
|
amountFormatted: s.amountFormatted,
|
|
@@ -6970,7 +7012,7 @@ function createPaymentGate(options) {
|
|
|
6970
7012
|
...endpointInfo ? { endpoint: endpointInfo } : {},
|
|
6971
7013
|
...receiptsOn ? { verifiableReceipts: true } : {}
|
|
6972
7014
|
});
|
|
6973
|
-
const rejectionExt = _nullishCoalesce(_optionalChain([opts, 'optionalAccess',
|
|
7015
|
+
const rejectionExt = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _144 => _144.extensions]), () => ( {}));
|
|
6974
7016
|
const rejectionPiprail = _nullishCoalesce(rejectionExt.piprail, () => ( {}));
|
|
6975
7017
|
const bodyPiprail = { ..._nullishCoalesce(selfDescribe, () => ( {})), ...rejectionPiprail };
|
|
6976
7018
|
const bodyExtensions = {
|
|
@@ -6992,7 +7034,7 @@ function createPaymentGate(options) {
|
|
|
6992
7034
|
...options.mimeType ? { mimeType: options.mimeType } : {}
|
|
6993
7035
|
},
|
|
6994
7036
|
accepts,
|
|
6995
|
-
..._optionalChain([opts, 'optionalAccess',
|
|
7037
|
+
..._optionalChain([opts, 'optionalAccess', _145 => _145.error]) ? { error: opts.error } : {},
|
|
6996
7038
|
...Object.keys(bodyExtensions).length > 0 ? { extensions: bodyExtensions } : {}
|
|
6997
7039
|
};
|
|
6998
7040
|
const headerChallenge = {
|
|
@@ -7023,8 +7065,8 @@ function createPaymentGate(options) {
|
|
|
7023
7065
|
function enrichReceipt(spec, receipt) {
|
|
7024
7066
|
let amountFormatted = receipt.amount;
|
|
7025
7067
|
try {
|
|
7026
|
-
amountFormatted =
|
|
7027
|
-
} catch (
|
|
7068
|
+
amountFormatted = _chunk3FR22M3Ocjs.formatUnits.call(void 0, BigInt(receipt.amount), spec.decimals);
|
|
7069
|
+
} catch (e49) {
|
|
7028
7070
|
}
|
|
7029
7071
|
return {
|
|
7030
7072
|
...receipt,
|
|
@@ -7038,7 +7080,7 @@ function createPaymentGate(options) {
|
|
|
7038
7080
|
if (!options.onPaidError) return;
|
|
7039
7081
|
try {
|
|
7040
7082
|
options.onPaidError(error, receipt);
|
|
7041
|
-
} catch (
|
|
7083
|
+
} catch (e50) {
|
|
7042
7084
|
}
|
|
7043
7085
|
}
|
|
7044
7086
|
function fireOnPaid(receipt) {
|
|
@@ -7078,7 +7120,7 @@ function createPaymentGate(options) {
|
|
|
7078
7120
|
...attestation ? { attestation } : {}
|
|
7079
7121
|
});
|
|
7080
7122
|
return { kind: "paid", receipt: stamped, receiptHeader: buildReceiptHeader(stamped, extensions) };
|
|
7081
|
-
} catch (
|
|
7123
|
+
} catch (e51) {
|
|
7082
7124
|
return { kind: "paid", receipt, receiptHeader: buildReceiptHeader(receipt) };
|
|
7083
7125
|
}
|
|
7084
7126
|
}
|
|
@@ -7103,7 +7145,7 @@ function createPaymentGate(options) {
|
|
|
7103
7145
|
// §5.3: the signed message carries the empty string for a suppressed tx, never omitted.
|
|
7104
7146
|
transaction: receiptIncludeTxHash ? stamped.transaction : ""
|
|
7105
7147
|
});
|
|
7106
|
-
} catch (
|
|
7148
|
+
} catch (e52) {
|
|
7107
7149
|
warnAttestDegrade("signing failed");
|
|
7108
7150
|
return void 0;
|
|
7109
7151
|
}
|
|
@@ -7112,7 +7154,7 @@ function createPaymentGate(options) {
|
|
|
7112
7154
|
if (!options.onFailedError) return;
|
|
7113
7155
|
try {
|
|
7114
7156
|
options.onFailedError(error, failure);
|
|
7115
|
-
} catch (
|
|
7157
|
+
} catch (e53) {
|
|
7116
7158
|
}
|
|
7117
7159
|
}
|
|
7118
7160
|
function fireOnFailed(failure) {
|
|
@@ -7231,28 +7273,28 @@ function createPaymentGate(options) {
|
|
|
7231
7273
|
nonce = [exact.payload.transaction, exact.payload.senderAuth].map((t) => {
|
|
7232
7274
|
try {
|
|
7233
7275
|
return Buffer.from(t, "base64").toString("base64");
|
|
7234
|
-
} catch (
|
|
7276
|
+
} catch (e54) {
|
|
7235
7277
|
return t;
|
|
7236
7278
|
}
|
|
7237
7279
|
}).join("|");
|
|
7238
7280
|
} else if ("transaction" in exact.payload) {
|
|
7239
7281
|
try {
|
|
7240
7282
|
nonce = Buffer.from(exact.payload.transaction, "base64").toString("base64");
|
|
7241
|
-
} catch (
|
|
7283
|
+
} catch (e55) {
|
|
7242
7284
|
nonce = exact.payload.transaction;
|
|
7243
7285
|
}
|
|
7244
7286
|
} else if ("paymentGroup" in exact.payload) {
|
|
7245
7287
|
nonce = exact.payload.paymentGroup.map((t) => {
|
|
7246
7288
|
try {
|
|
7247
7289
|
return Buffer.from(t, "base64").toString("base64");
|
|
7248
|
-
} catch (
|
|
7290
|
+
} catch (e56) {
|
|
7249
7291
|
return t;
|
|
7250
7292
|
}
|
|
7251
7293
|
}).join("|");
|
|
7252
7294
|
} else if ("signedDelegateAction" in exact.payload) {
|
|
7253
7295
|
try {
|
|
7254
7296
|
nonce = Buffer.from(exact.payload.signedDelegateAction, "base64").toString("base64");
|
|
7255
|
-
} catch (
|
|
7297
|
+
} catch (e57) {
|
|
7256
7298
|
nonce = exact.payload.signedDelegateAction;
|
|
7257
7299
|
}
|
|
7258
7300
|
} else if ("permit2Authorization" in exact.payload) {
|
|
@@ -7275,7 +7317,7 @@ function createPaymentGate(options) {
|
|
|
7275
7317
|
const ftMethod = accept.extra.assetTransferMethod;
|
|
7276
7318
|
const needsFeePayer = ftMethod === "svm" || ftMethod === "algorand" || ftMethod === "aptos" || ftMethod === "near";
|
|
7277
7319
|
if (needsFeePayer && !accept.extra.feePayer) {
|
|
7278
|
-
throw new (0,
|
|
7320
|
+
throw new (0, _chunk3FR22M3Ocjs.SettlementError)(
|
|
7279
7321
|
`exact settle: the ${ftMethod} facilitator rail is missing extra.feePayer (the gas sponsor) \u2014 cannot settle.`
|
|
7280
7322
|
);
|
|
7281
7323
|
}
|
|
@@ -7323,16 +7365,16 @@ function createPaymentGate(options) {
|
|
|
7323
7365
|
if (s.endsWith("%")) {
|
|
7324
7366
|
const pct = s.slice(0, -1).trim();
|
|
7325
7367
|
if (!/^\d+(\.\d+)?$/.test(pct)) return null;
|
|
7326
|
-
const pctScaled =
|
|
7368
|
+
const pctScaled = _chunk3FR22M3Ocjs.floorUnits.call(void 0, pct, 4);
|
|
7327
7369
|
return maxAmount * pctScaled / (100n * 10n ** 4n);
|
|
7328
7370
|
}
|
|
7329
7371
|
if (s.startsWith("$")) {
|
|
7330
7372
|
const amt = s.slice(1).trim();
|
|
7331
|
-
return
|
|
7373
|
+
return _chunk3FR22M3Ocjs.floorUnits.call(void 0, amt, decimals);
|
|
7332
7374
|
}
|
|
7333
7375
|
if (/^\d+$/.test(s)) return BigInt(s);
|
|
7334
|
-
return
|
|
7335
|
-
} catch (
|
|
7376
|
+
return _chunk3FR22M3Ocjs.floorUnits.call(void 0, s, decimals);
|
|
7377
|
+
} catch (e58) {
|
|
7336
7378
|
return null;
|
|
7337
7379
|
}
|
|
7338
7380
|
}
|
|
@@ -7382,7 +7424,7 @@ function createPaymentGate(options) {
|
|
|
7382
7424
|
result = await spec.net.settleUptoSelf({ relayer, payload: upto.payload, accept, settleAmount });
|
|
7383
7425
|
} catch (err) {
|
|
7384
7426
|
await settleTx(nonce, false);
|
|
7385
|
-
if (err instanceof
|
|
7427
|
+
if (err instanceof _chunk3FR22M3Ocjs.SettlementError) throw err;
|
|
7386
7428
|
return rejection(
|
|
7387
7429
|
"tx_reverted",
|
|
7388
7430
|
`upto: metering/settle failed (${err instanceof Error ? err.message : String(err)}).`
|
|
@@ -7429,7 +7471,7 @@ function createPaymentGate(options) {
|
|
|
7429
7471
|
[EXT_PAYMENT_IDENTIFIER]: { info: { required: false, id } }
|
|
7430
7472
|
};
|
|
7431
7473
|
return { ...result, receiptHeader: buildReceiptHeader(receiptOnly, merged) };
|
|
7432
|
-
} catch (
|
|
7474
|
+
} catch (e59) {
|
|
7433
7475
|
return result;
|
|
7434
7476
|
}
|
|
7435
7477
|
}
|
|
@@ -7461,7 +7503,7 @@ function createPaymentGate(options) {
|
|
|
7461
7503
|
}
|
|
7462
7504
|
function requirePayment(options) {
|
|
7463
7505
|
if (options.upto) {
|
|
7464
|
-
throw new (_class3 = class extends
|
|
7506
|
+
throw new (_class3 = class extends _chunk3FR22M3Ocjs.PipRailError {constructor(...args2) { super(...args2); _class3.prototype.__init7.call(this); }
|
|
7465
7507
|
__init7() {this.code = "UNSUPPORTED_SCHEME"}
|
|
7466
7508
|
}, _class3)(
|
|
7467
7509
|
"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."
|
|
@@ -7473,7 +7515,7 @@ function requirePayment(options) {
|
|
|
7473
7515
|
try {
|
|
7474
7516
|
result = await gate.verify(_nullishCoalesce(req.headers[HEADER_SIGNATURE], () => ( req.headers[HEADER_SIGNATURE_V1])));
|
|
7475
7517
|
} catch (err) {
|
|
7476
|
-
if (err instanceof
|
|
7518
|
+
if (err instanceof _chunk3FR22M3Ocjs.SettlementError) {
|
|
7477
7519
|
res.status(502);
|
|
7478
7520
|
res.json({
|
|
7479
7521
|
x402Version: 2,
|
|
@@ -7521,7 +7563,7 @@ function isRetryableStatus(status) {
|
|
|
7521
7563
|
}
|
|
7522
7564
|
var sleep = (ms) => ms > 0 ? new Promise((resolve) => setTimeout(resolve, ms)) : Promise.resolve();
|
|
7523
7565
|
async function signBody(secret, body) {
|
|
7524
|
-
const subtle = _optionalChain([globalThis, 'access',
|
|
7566
|
+
const subtle = _optionalChain([globalThis, 'access', _146 => _146.crypto, 'optionalAccess', _147 => _147.subtle]);
|
|
7525
7567
|
if (!subtle) return null;
|
|
7526
7568
|
try {
|
|
7527
7569
|
const enc = new TextEncoder();
|
|
@@ -7531,7 +7573,7 @@ async function signBody(secret, body) {
|
|
|
7531
7573
|
const sig = await subtle.sign("HMAC", key, enc.encode(body));
|
|
7532
7574
|
const hex = Array.from(new Uint8Array(sig)).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
7533
7575
|
return `sha256=${hex}`;
|
|
7534
|
-
} catch (
|
|
7576
|
+
} catch (e60) {
|
|
7535
7577
|
return null;
|
|
7536
7578
|
}
|
|
7537
7579
|
}
|
|
@@ -7591,8 +7633,8 @@ async function deliverReceipt(receipt, options) {
|
|
|
7591
7633
|
const retryable = status === void 0 ? true : isRetryableStatus(status);
|
|
7592
7634
|
const willRetry = !ok && retryable && attempt < maxAttempts;
|
|
7593
7635
|
try {
|
|
7594
|
-
_optionalChain([onAttempt, 'optionalCall',
|
|
7595
|
-
} catch (
|
|
7636
|
+
_optionalChain([onAttempt, 'optionalCall', _148 => _148({ attempt, ok, ...status !== void 0 ? { status } : {}, ...error ? { error } : {}, willRetry })]);
|
|
7637
|
+
} catch (e61) {
|
|
7596
7638
|
}
|
|
7597
7639
|
if (ok) return { delivered: true, attempts: attempt, status };
|
|
7598
7640
|
if (!willRetry) {
|
|
@@ -7680,13 +7722,13 @@ function toA2APaymentFailed(code, detail, receipts = [], network) {
|
|
|
7680
7722
|
};
|
|
7681
7723
|
}
|
|
7682
7724
|
function fromA2APaymentRequired(task) {
|
|
7683
|
-
const meta = _optionalChain([task, 'access',
|
|
7684
|
-
const required = _optionalChain([meta, 'optionalAccess',
|
|
7725
|
+
const meta = _optionalChain([task, 'access', _149 => _149.status, 'optionalAccess', _150 => _150.message, 'optionalAccess', _151 => _151.metadata]);
|
|
7726
|
+
const required = _optionalChain([meta, 'optionalAccess', _152 => _152[A2A_REQUIRED_KEY]]);
|
|
7685
7727
|
if (!required || typeof required !== "object") return null;
|
|
7686
7728
|
return required;
|
|
7687
7729
|
}
|
|
7688
7730
|
function fromA2APaymentPayload(message) {
|
|
7689
|
-
const raw = _optionalChain([message, 'access',
|
|
7731
|
+
const raw = _optionalChain([message, 'access', _153 => _153.metadata, 'optionalAccess', _154 => _154[A2A_PAYLOAD_KEY]]);
|
|
7690
7732
|
if (raw === void 0 || raw === null) return null;
|
|
7691
7733
|
return { raw, taskId: _nullishCoalesce(message.taskId, () => ( "")) };
|
|
7692
7734
|
}
|
|
@@ -7719,7 +7761,7 @@ function createA2APaymentHandler(options) {
|
|
|
7719
7761
|
const ttlMs = _nullishCoalesce(options.taskTtlMs, () => ( maxTimeoutSeconds * 1e3));
|
|
7720
7762
|
const store = _nullishCoalesce(options.taskStore, () => ( defaultTaskStore()));
|
|
7721
7763
|
function appendReceipt(taskId, entry) {
|
|
7722
|
-
const prior = _nullishCoalesce(_optionalChain([store, 'access',
|
|
7764
|
+
const prior = _nullishCoalesce(_optionalChain([store, 'access', _155 => _155.get, 'call', _156 => _156(taskId), 'optionalAccess', _157 => _157.receipts]), () => ( []));
|
|
7723
7765
|
const isDup = "success" in entry && entry.success === true && entry.transaction !== "" && prior.some((r) => "transaction" in r && r.transaction === entry.transaction);
|
|
7724
7766
|
const next = isDup ? prior : [...prior, entry];
|
|
7725
7767
|
const receipts = next.length > MAX_TASK_RECEIPTS ? next.slice(-MAX_TASK_RECEIPTS) : next;
|
|
@@ -7795,7 +7837,7 @@ function createA2APaymentHandler(options) {
|
|
|
7795
7837
|
try {
|
|
7796
7838
|
result = await gate.verifyObject(inbound.raw);
|
|
7797
7839
|
} catch (err) {
|
|
7798
|
-
if (err instanceof
|
|
7840
|
+
if (err instanceof _chunk3FR22M3Ocjs.SettlementError) {
|
|
7799
7841
|
return failedTask(id, "settlement_failed", err.message, attempted);
|
|
7800
7842
|
}
|
|
7801
7843
|
const detail = err instanceof Error ? err.message : String(err);
|
|
@@ -7827,11 +7869,11 @@ function createA2APaymentHandler(options) {
|
|
|
7827
7869
|
}
|
|
7828
7870
|
}
|
|
7829
7871
|
function agentCardExtension(opts) {
|
|
7830
|
-
const uri = _optionalChain([opts, 'optionalAccess',
|
|
7872
|
+
const uri = _optionalChain([opts, 'optionalAccess', _158 => _158.version]) === "v0.2" ? A2A_X402_EXTENSION_URI_V02 : A2A_X402_EXTENSION_URI_V01;
|
|
7831
7873
|
return {
|
|
7832
7874
|
uri,
|
|
7833
7875
|
description: "Supports payments using the x402 protocol for on-chain settlement.",
|
|
7834
|
-
..._optionalChain([opts, 'optionalAccess',
|
|
7876
|
+
..._optionalChain([opts, 'optionalAccess', _159 => _159.required]) ? { required: true } : {}
|
|
7835
7877
|
};
|
|
7836
7878
|
}
|
|
7837
7879
|
return { handleMessage, agentCardExtension, gate };
|
|
@@ -7842,7 +7884,7 @@ function singleNetworkOf(challenge) {
|
|
|
7842
7884
|
}
|
|
7843
7885
|
function networkFromPayload(raw) {
|
|
7844
7886
|
const v = raw;
|
|
7845
|
-
if (v && typeof _optionalChain([v, 'access',
|
|
7887
|
+
if (v && typeof _optionalChain([v, 'access', _160 => _160.accepted, 'optionalAccess', _161 => _161.network]) === "string") return v.accepted.network;
|
|
7846
7888
|
if (v && typeof v.network === "string") return v.network;
|
|
7847
7889
|
return void 0;
|
|
7848
7890
|
}
|
|
@@ -7884,7 +7926,7 @@ function toMcpPaymentResponse(content, receipt) {
|
|
|
7884
7926
|
};
|
|
7885
7927
|
}
|
|
7886
7928
|
function fromMcpPayment(params) {
|
|
7887
|
-
const meta = _optionalChain([params, 'optionalAccess',
|
|
7929
|
+
const meta = _optionalChain([params, 'optionalAccess', _162 => _162._meta, 'optionalAccess', _163 => _163[MCP_PAYMENT_META_KEY]]);
|
|
7888
7930
|
return meta == null ? null : meta;
|
|
7889
7931
|
}
|
|
7890
7932
|
function fromMcpPaymentRequired(result) {
|
|
@@ -7893,14 +7935,14 @@ function fromMcpPaymentRequired(result) {
|
|
|
7893
7935
|
if (sc && typeof sc === "object" && typeof sc.x402Version === "number") {
|
|
7894
7936
|
return sc;
|
|
7895
7937
|
}
|
|
7896
|
-
const text = _optionalChain([result, 'access',
|
|
7938
|
+
const text = _optionalChain([result, 'access', _164 => _164.content, 'optionalAccess', _165 => _165[0], 'optionalAccess', _166 => _166.text]);
|
|
7897
7939
|
if (typeof text === "string") {
|
|
7898
7940
|
try {
|
|
7899
7941
|
const parsed = JSON.parse(text);
|
|
7900
7942
|
if (parsed && typeof parsed === "object" && typeof parsed.x402Version === "number") {
|
|
7901
7943
|
return parsed;
|
|
7902
7944
|
}
|
|
7903
|
-
} catch (
|
|
7945
|
+
} catch (e62) {
|
|
7904
7946
|
}
|
|
7905
7947
|
}
|
|
7906
7948
|
return null;
|
|
@@ -7909,7 +7951,7 @@ function isMcpPaymentRequired(result) {
|
|
|
7909
7951
|
return fromMcpPaymentRequired(result) != null;
|
|
7910
7952
|
}
|
|
7911
7953
|
function fromMcpPaymentResponse(result) {
|
|
7912
|
-
const meta = _optionalChain([result, 'optionalAccess',
|
|
7954
|
+
const meta = _optionalChain([result, 'optionalAccess', _167 => _167._meta, 'optionalAccess', _168 => _168[MCP_PAYMENT_RESPONSE_META_KEY]]);
|
|
7913
7955
|
if (!meta || typeof meta !== "object") return null;
|
|
7914
7956
|
return meta;
|
|
7915
7957
|
}
|
|
@@ -7946,7 +7988,7 @@ function createMcpPaymentTool(options) {
|
|
|
7946
7988
|
try {
|
|
7947
7989
|
result = await gate.verifyObject(raw);
|
|
7948
7990
|
} catch (err) {
|
|
7949
|
-
if (err instanceof
|
|
7991
|
+
if (err instanceof _chunk3FR22M3Ocjs.SettlementError) return settlementFailed("settlement_failed", err.message);
|
|
7950
7992
|
throw err;
|
|
7951
7993
|
}
|
|
7952
7994
|
if (result.kind === "paid") {
|
|
@@ -8112,4 +8154,5 @@ function createMcpPaymentTool(options) {
|
|
|
8112
8154
|
|
|
8113
8155
|
|
|
8114
8156
|
|
|
8115
|
-
|
|
8157
|
+
|
|
8158
|
+
exports.A2A_ERROR_KEY = A2A_ERROR_KEY; exports.A2A_EXTENSIONS_HEADER = A2A_EXTENSIONS_HEADER; exports.A2A_PAYLOAD_KEY = A2A_PAYLOAD_KEY; exports.A2A_RECEIPTS_KEY = A2A_RECEIPTS_KEY; exports.A2A_REQUIRED_KEY = A2A_REQUIRED_KEY; exports.A2A_STATUS_KEY = A2A_STATUS_KEY; exports.A2A_X402_EXTENSION_URI_V01 = A2A_X402_EXTENSION_URI_V01; exports.A2A_X402_EXTENSION_URI_V02 = A2A_X402_EXTENSION_URI_V02; exports.BRAND = BRAND; exports.BUILTIN_DENOMS = BUILTIN_DENOMS; exports.CHAINS = CHAINS; exports.ConfirmationTimeoutError = _chunk3FR22M3Ocjs.ConfirmationTimeoutError; exports.DENOM_PRECISION = DENOM_PRECISION; exports.DIRECTORY_INFO = DIRECTORY_INFO; exports.EIP3009_TYPES = EIP3009_TYPES; exports.EXACT_NETWORK_SLUGS = EXACT_NETWORK_SLUGS; exports.EXT_OFFER_RECEIPT = EXT_OFFER_RECEIPT; exports.EXT_PAYMENT_IDENTIFIER = EXT_PAYMENT_IDENTIFIER; exports.GENERATOR = GENERATOR; exports.HEADER_REQUIRED = HEADER_REQUIRED; exports.HEADER_RESPONSE = HEADER_RESPONSE; exports.HEADER_RESPONSE_V1 = HEADER_RESPONSE_V1; exports.HEADER_SIGNATURE = HEADER_SIGNATURE; exports.HEADER_SIGNATURE_V1 = HEADER_SIGNATURE_V1; exports.InsufficientFundsError = _chunk3FR22M3Ocjs.InsufficientFundsError; exports.InvalidConfigError = _chunk3FR22M3Ocjs.InvalidConfigError; exports.InvalidEnvelopeError = _chunk3FR22M3Ocjs.InvalidEnvelopeError; exports.KNOWN_FACILITATORS = KNOWN_FACILITATORS; exports.MCP_PAYMENT_META_KEY = MCP_PAYMENT_META_KEY; exports.MCP_PAYMENT_RESPONSE_META_KEY = MCP_PAYMENT_RESPONSE_META_KEY; exports.MaxRetriesExceededError = _chunk3FR22M3Ocjs.MaxRetriesExceededError; exports.MissingDriverError = _chunk3FR22M3Ocjs.MissingDriverError; exports.MultiChainPayer = MultiChainPayer; exports.NoCompatibleAcceptError = _chunk3FR22M3Ocjs.NoCompatibleAcceptError; exports.NonReplayableBodyError = _chunk3FR22M3Ocjs.NonReplayableBodyError; exports.PERMIT2_ADDRESS = PERMIT2_ADDRESS; exports.PERMIT2_PROXY_CHAIN_IDS = PERMIT2_PROXY_CHAIN_IDS; exports.PERMIT2_UPTO_WITNESS_TYPES = PERMIT2_UPTO_WITNESS_TYPES; exports.PERMIT2_WITNESS_TYPES = PERMIT2_WITNESS_TYPES; exports.PIPRAIL_AGENT_GUIDE = PIPRAIL_AGENT_GUIDE; exports.POWERED_BY = POWERED_BY; exports.PaymentDeclinedError = _chunk3FR22M3Ocjs.PaymentDeclinedError; exports.PaymentTimeoutError = _chunk3FR22M3Ocjs.PaymentTimeoutError; exports.PipRailClient = PipRailClient; exports.PipRailError = _chunk3FR22M3Ocjs.PipRailError; exports.REGISTER_ATTRIBUTION = REGISTER_ATTRIBUTION; exports.RecipientNotReadyError = _chunk3FR22M3Ocjs.RecipientNotReadyError; exports.SettlementError = _chunk3FR22M3Ocjs.SettlementError; exports.SpendLedger = SpendLedger; exports.UPTO_PROXY_CHAIN_IDS = UPTO_PROXY_CHAIN_IDS; exports.UnknownTokenError = _chunk3FR22M3Ocjs.UnknownTokenError; exports.UnsupportedNetworkError = _chunk3FR22M3Ocjs.UnsupportedNetworkError; exports.UnsupportedSchemeError = _chunk3FR22M3Ocjs.UnsupportedSchemeError; exports.VERIFY_CODE_TO_A2A_ERROR = VERIFY_CODE_TO_A2A_ERROR; exports.WalletRequiredError = _chunk3FR22M3Ocjs.WalletRequiredError; exports.WrongChainError = _chunk3FR22M3Ocjs.WrongChainError; exports.WrongFamilyError = _chunk3FR22M3Ocjs.WrongFamilyError; exports.X402_EXACT_PERMIT2_PROXY = X402_EXACT_PERMIT2_PROXY; exports.X402_UPTO_PERMIT2_PROXY = X402_UPTO_PERMIT2_PROXY; exports.agentGuide = agentGuide; exports.appendAttribution = appendAttribution; exports.appendKeywords = appendKeywords; exports.buildBazaarExtension = buildBazaarExtension; exports.buildChallengeHeader = buildChallengeHeader; exports.buildEndpointInfo = buildEndpointInfo; exports.buildExactAuthorization = buildExactAuthorization; exports.buildExactSignatureHeader = buildExactSignatureHeader; exports.buildMcpPaymentMeta = buildMcpPaymentMeta; exports.buildOpenApi = buildOpenApi; exports.buildPaymentIdentifierAdvertisement = buildPaymentIdentifierAdvertisement; exports.buildReceiptExtension = buildReceiptExtension; exports.buildReceiptHeader = buildReceiptHeader; exports.buildSelfDescription = buildSelfDescription; exports.buildSignatureHeader = buildSignatureHeader; exports.buildUptoSignatureHeader = buildUptoSignatureHeader; exports.buildWellKnownX402 = buildWellKnownX402; exports.buildWellKnownX402Manifest = buildWellKnownX402Manifest; exports.buildX402DnsTxt = buildX402DnsTxt; exports.chainIdForExactNetwork = chainIdForExactNetwork; exports.claim402IndexDomain = claim402IndexDomain; exports.classifyChallenge = classifyChallenge; exports.createA2APaymentHandler = createA2APaymentHandler; exports.createMcpPaymentTool = createMcpPaymentTool; exports.createPaymentGate = createPaymentGate; exports.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 = _chunk3FR22M3Ocjs.toInsufficientFundsError; exports.toInvalidBody = toInvalidBody; exports.toMcpPaymentRequired = toMcpPaymentRequired; exports.toMcpPaymentResponse = toMcpPaymentResponse; exports.verify402IndexDomain = verify402IndexDomain;
|