@piprail/sdk 2.15.1 → 2.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +188 -1
- package/README.md +1 -1
- package/dist/{algorand-UF7BLBFN.js → algorand-25FMBCT3.js} +12 -3
- package/dist/{algorand-XGSWDMCZ.cjs → algorand-Q3TUQLPK.cjs} +17 -8
- package/dist/{aptos-KDLX42CR.js → aptos-SBV6SGDP.js} +2 -2
- package/dist/{aptos-J2QSWHTO.cjs → aptos-VBJONBFY.cjs} +5 -5
- package/dist/chunk-2CX7XRZK.js +649 -0
- package/dist/chunk-C52H5TYB.js +474 -0
- package/dist/chunk-OXEFPLZA.cjs +474 -0
- package/dist/chunk-V2IJ5HUW.cjs +649 -0
- package/dist/index.cjs +355 -1181
- package/dist/index.d.cts +39 -6
- package/dist/index.d.ts +39 -6
- package/dist/index.js +171 -997
- package/dist/{ledger-uFtXlIHY.d.cts → ledger-Crc1bZox.d.cts} +164 -10
- package/dist/{ledger-uFtXlIHY.d.ts → ledger-Crc1bZox.d.ts} +164 -10
- package/dist/node.d.cts +2 -2
- package/dist/node.d.ts +2 -2
- package/dist/{solana-S2T3JNR7.cjs → solana-AI2G7V33.cjs} +42 -21
- package/dist/{solana-WO2G7WWZ.js → solana-HTKDRTD3.js} +31 -10
- package/dist/{xrpl-6B2XOXGC.js → xrpl-RUOB37QH.js} +282 -4
- package/dist/{xrpl-VOUXIUYD.cjs → xrpl-SVVS445B.cjs} +292 -14
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -24,6 +24,59 @@ var _chunkCQQI5IJXcjs = require('./chunk-CQQI5IJX.cjs');
|
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
var _chunkOXEFPLZAcjs = require('./chunk-OXEFPLZA.cjs');
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
var _chunkV2IJ5HUWcjs = require('./chunk-V2IJ5HUW.cjs');
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
|
|
27
80
|
|
|
28
81
|
|
|
29
82
|
|
|
@@ -896,8 +949,8 @@ async function verifyAndSettleExactEvm(input) {
|
|
|
896
949
|
try {
|
|
897
950
|
recovered = await _viem.recoverTypedDataAddress.call(void 0, {
|
|
898
951
|
domain: {
|
|
899
|
-
name: accept.extra.name,
|
|
900
|
-
version: accept.extra.version,
|
|
952
|
+
name: _optionalChain([accept, 'access', _8 => _8.extra, 'optionalAccess', _9 => _9.name]),
|
|
953
|
+
version: _optionalChain([accept, 'access', _10 => _10.extra, 'optionalAccess', _11 => _11.version]),
|
|
901
954
|
chainId: chain.id,
|
|
902
955
|
verifyingContract: token
|
|
903
956
|
},
|
|
@@ -969,7 +1022,7 @@ async function verifyAndSettleExactEvm(input) {
|
|
|
969
1022
|
);
|
|
970
1023
|
}
|
|
971
1024
|
try {
|
|
972
|
-
const confirmations = _nullishCoalesce(accept.extra.minConfirmations, () => ( 1));
|
|
1025
|
+
const confirmations = _nullishCoalesce(_optionalChain([accept, 'access', _12 => _12.extra, 'optionalAccess', _13 => _13.minConfirmations]), () => ( 1));
|
|
973
1026
|
const receipt = await publicClient.waitForTransactionReceipt({ hash: txHash, confirmations });
|
|
974
1027
|
if (receipt.status !== "success") {
|
|
975
1028
|
return { ok: false, error: "tx_reverted", detail: `Settlement tx ${txHash} reverted on-chain.` };
|
|
@@ -1105,7 +1158,7 @@ function shorten2(msg) {
|
|
|
1105
1158
|
}
|
|
1106
1159
|
function randomPermit2Nonce() {
|
|
1107
1160
|
const g = globalThis.crypto;
|
|
1108
|
-
if (!_optionalChain([g, 'optionalAccess',
|
|
1161
|
+
if (!_optionalChain([g, 'optionalAccess', _14 => _14.getRandomValues])) {
|
|
1109
1162
|
throw new (0, _chunkQONQSZHJcjs.UnsupportedSchemeError)(
|
|
1110
1163
|
"this runtime lacks Web Crypto (globalThis.crypto.getRandomValues); the permit2 rail needs a CSPRNG nonce."
|
|
1111
1164
|
);
|
|
@@ -1338,7 +1391,7 @@ async function verifyAndSettlePermit2Evm(input) {
|
|
|
1338
1391
|
);
|
|
1339
1392
|
}
|
|
1340
1393
|
try {
|
|
1341
|
-
const confirmations = _nullishCoalesce(accept.extra.minConfirmations, () => ( 1));
|
|
1394
|
+
const confirmations = _nullishCoalesce(_optionalChain([accept, 'access', _15 => _15.extra, 'optionalAccess', _16 => _16.minConfirmations]), () => ( 1));
|
|
1342
1395
|
const receipt = await publicClient.waitForTransactionReceipt({ hash: txHash, confirmations });
|
|
1343
1396
|
if (receipt.status !== "success") {
|
|
1344
1397
|
return { ok: false, error: "tx_reverted", detail: `Settlement tx ${txHash} reverted on-chain.` };
|
|
@@ -1441,7 +1494,7 @@ function shorten3(msg) {
|
|
|
1441
1494
|
}
|
|
1442
1495
|
function randomPermit2Nonce2() {
|
|
1443
1496
|
const g = globalThis.crypto;
|
|
1444
|
-
if (!_optionalChain([g, 'optionalAccess',
|
|
1497
|
+
if (!_optionalChain([g, 'optionalAccess', _17 => _17.getRandomValues])) {
|
|
1445
1498
|
throw new (0, _chunkQONQSZHJcjs.UnsupportedSchemeError)(
|
|
1446
1499
|
"this runtime lacks Web Crypto (globalThis.crypto.getRandomValues); the upto rail needs a CSPRNG nonce."
|
|
1447
1500
|
);
|
|
@@ -1463,7 +1516,7 @@ async function payUptoEvm(input) {
|
|
|
1463
1516
|
`upto buyer rail requires an EOA signer; ${account.address} is a contract / EIP-1271 / EIP-7702-delegated account. Pay via onchain-proof.`
|
|
1464
1517
|
);
|
|
1465
1518
|
}
|
|
1466
|
-
const facilitatorAddress = _optionalChain([accept, 'access',
|
|
1519
|
+
const facilitatorAddress = _optionalChain([accept, 'access', _18 => _18.extra, 'optionalAccess', _19 => _19.facilitatorAddress]);
|
|
1467
1520
|
if (typeof facilitatorAddress !== "string" || facilitatorAddress.length === 0) {
|
|
1468
1521
|
throw new (0, _chunkQONQSZHJcjs.UnsupportedSchemeError)(
|
|
1469
1522
|
`upto: the rail carries no extra.facilitatorAddress to bind into witness.facilitator \u2014 refusing to sign.`
|
|
@@ -1720,327 +1773,6 @@ async function verifyAndSettleUptoEvm(input) {
|
|
|
1720
1773
|
};
|
|
1721
1774
|
}
|
|
1722
1775
|
|
|
1723
|
-
// src/x402.ts
|
|
1724
|
-
var HEADER_REQUIRED = "payment-required";
|
|
1725
|
-
var HEADER_SIGNATURE = "payment-signature";
|
|
1726
|
-
var HEADER_RESPONSE = "payment-response";
|
|
1727
|
-
var HEADER_SIGNATURE_V1 = "x-payment";
|
|
1728
|
-
var HEADER_RESPONSE_V1 = "x-payment-response";
|
|
1729
|
-
function encodeBase64(str) {
|
|
1730
|
-
if (typeof Buffer !== "undefined") return Buffer.from(str, "utf8").toString("base64");
|
|
1731
|
-
if (typeof btoa === "function" && typeof TextEncoder !== "undefined") {
|
|
1732
|
-
const bytes = new TextEncoder().encode(str);
|
|
1733
|
-
let binary = "";
|
|
1734
|
-
for (let i = 0; i < bytes.length; i++) binary += String.fromCharCode(bytes[i]);
|
|
1735
|
-
return btoa(binary);
|
|
1736
|
-
}
|
|
1737
|
-
throw new Error("No base64 encoder available in this runtime.");
|
|
1738
|
-
}
|
|
1739
|
-
function decodeBase64(b64) {
|
|
1740
|
-
if (typeof Buffer !== "undefined") return Buffer.from(b64, "base64").toString("utf8");
|
|
1741
|
-
if (typeof atob === "function" && typeof TextDecoder !== "undefined") {
|
|
1742
|
-
const binary = atob(b64);
|
|
1743
|
-
const bytes = new Uint8Array(binary.length);
|
|
1744
|
-
for (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);
|
|
1745
|
-
return new TextDecoder().decode(bytes);
|
|
1746
|
-
}
|
|
1747
|
-
throw new Error("No base64 decoder available in this runtime.");
|
|
1748
|
-
}
|
|
1749
|
-
function fromBase64Json(b64) {
|
|
1750
|
-
try {
|
|
1751
|
-
return JSON.parse(decodeBase64(b64));
|
|
1752
|
-
} catch (e19) {
|
|
1753
|
-
return null;
|
|
1754
|
-
}
|
|
1755
|
-
}
|
|
1756
|
-
function decodeBase64Json(value) {
|
|
1757
|
-
return fromBase64Json(value);
|
|
1758
|
-
}
|
|
1759
|
-
function toBase64Json(value) {
|
|
1760
|
-
let json;
|
|
1761
|
-
try {
|
|
1762
|
-
json = JSON.stringify(value);
|
|
1763
|
-
} catch (cause) {
|
|
1764
|
-
throw new (0, _chunkQONQSZHJcjs.InvalidConfigError)(
|
|
1765
|
-
`x402: this payload cannot be serialised to JSON (${cause.message}). Amounts must be decimal STRINGS, not BigInt \u2014 pass '50000', not 50000n.`,
|
|
1766
|
-
{ cause }
|
|
1767
|
-
);
|
|
1768
|
-
}
|
|
1769
|
-
return encodeBase64(json);
|
|
1770
|
-
}
|
|
1771
|
-
function networkForChain(chainId) {
|
|
1772
|
-
return `eip155:${chainId}`;
|
|
1773
|
-
}
|
|
1774
|
-
function chainIdFromNetwork(network) {
|
|
1775
|
-
const match = /^eip155:(\d+)$/.exec(network);
|
|
1776
|
-
if (!match || !match[1]) return null;
|
|
1777
|
-
const n = Number(match[1]);
|
|
1778
|
-
return Number.isSafeInteger(n) && n > 0 ? n : null;
|
|
1779
|
-
}
|
|
1780
|
-
function buildChallengeHeader(challenge) {
|
|
1781
|
-
return toBase64Json(challenge);
|
|
1782
|
-
}
|
|
1783
|
-
function buildReceiptHeader(receipt, extensions) {
|
|
1784
|
-
return toBase64Json(extensions ? { ...receipt, extensions } : receipt);
|
|
1785
|
-
}
|
|
1786
|
-
var EXT_OFFER_RECEIPT = "offer-receipt";
|
|
1787
|
-
function buildReceiptExtension(bundle) {
|
|
1788
|
-
const info = { settlement: bundle.receipt, resource: bundle.resource };
|
|
1789
|
-
if (typeof bundle.decimals === "number") info.decimals = bundle.decimals;
|
|
1790
|
-
if (bundle.attestation) info.receipt = bundle.attestation;
|
|
1791
|
-
return { [EXT_OFFER_RECEIPT]: { info } };
|
|
1792
|
-
}
|
|
1793
|
-
var EXT_PAYMENT_IDENTIFIER = "payment-identifier";
|
|
1794
|
-
var PAYMENT_ID_MIN = 16;
|
|
1795
|
-
var PAYMENT_ID_MAX = 128;
|
|
1796
|
-
var PAYMENT_ID_RE = /^[A-Za-z0-9_-]+$/;
|
|
1797
|
-
function buildPaymentIdentifierAdvertisement() {
|
|
1798
|
-
return {
|
|
1799
|
-
[EXT_PAYMENT_IDENTIFIER]: {
|
|
1800
|
-
info: { required: false },
|
|
1801
|
-
schema: { properties: { id: { type: "string", minLength: PAYMENT_ID_MIN, maxLength: PAYMENT_ID_MAX } } }
|
|
1802
|
-
}
|
|
1803
|
-
};
|
|
1804
|
-
}
|
|
1805
|
-
function readPaymentIdentifier(payload) {
|
|
1806
|
-
if (typeof payload !== "object" || payload === null) return null;
|
|
1807
|
-
const ext = payload.extensions;
|
|
1808
|
-
if (typeof ext !== "object" || ext === null) return null;
|
|
1809
|
-
const block = ext[EXT_PAYMENT_IDENTIFIER];
|
|
1810
|
-
if (typeof block !== "object" || block === null) return null;
|
|
1811
|
-
const info = block.info;
|
|
1812
|
-
if (typeof info !== "object" || info === null) return null;
|
|
1813
|
-
const id = info.id;
|
|
1814
|
-
if (id === void 0) return null;
|
|
1815
|
-
if (typeof id !== "string") return { invalid: "payment-identifier id must be a string" };
|
|
1816
|
-
if (id.length < PAYMENT_ID_MIN || id.length > PAYMENT_ID_MAX) {
|
|
1817
|
-
return { invalid: `payment-identifier id must be ${PAYMENT_ID_MIN}\u2013${PAYMENT_ID_MAX} chars (got ${id.length})` };
|
|
1818
|
-
}
|
|
1819
|
-
if (!PAYMENT_ID_RE.test(id)) {
|
|
1820
|
-
return { invalid: "payment-identifier id must match [A-Za-z0-9_-]" };
|
|
1821
|
-
}
|
|
1822
|
-
return id;
|
|
1823
|
-
}
|
|
1824
|
-
function buildSignatureHeader(signature) {
|
|
1825
|
-
return toBase64Json(signature);
|
|
1826
|
-
}
|
|
1827
|
-
function buildExactSignatureHeader(input) {
|
|
1828
|
-
return toBase64Json({ x402Version: 2, accepted: input.accepted, payload: input.payload });
|
|
1829
|
-
}
|
|
1830
|
-
function buildUptoSignatureHeader(input) {
|
|
1831
|
-
return toBase64Json({ x402Version: 2, accepted: input.accepted, payload: input.payload });
|
|
1832
|
-
}
|
|
1833
|
-
async function parseChallenge(response) {
|
|
1834
|
-
const headerValue = response.headers.get(HEADER_REQUIRED);
|
|
1835
|
-
if (headerValue) {
|
|
1836
|
-
const parsed = fromBase64Json(headerValue);
|
|
1837
|
-
if (isValidChallenge(parsed)) return parsed;
|
|
1838
|
-
}
|
|
1839
|
-
try {
|
|
1840
|
-
const body = await response.clone().json();
|
|
1841
|
-
if (isValidChallenge(body)) return body;
|
|
1842
|
-
} catch (e20) {
|
|
1843
|
-
}
|
|
1844
|
-
return null;
|
|
1845
|
-
}
|
|
1846
|
-
function parseReceipt(response) {
|
|
1847
|
-
const headerValue = _nullishCoalesce(response.headers.get(HEADER_RESPONSE), () => ( response.headers.get(HEADER_RESPONSE_V1)));
|
|
1848
|
-
if (!headerValue) return null;
|
|
1849
|
-
const parsed = fromBase64Json(headerValue);
|
|
1850
|
-
if (!isValidReceipt(parsed)) return null;
|
|
1851
|
-
const r = parsed;
|
|
1852
|
-
if (typeof r.transaction !== "string" && typeof r.txHash === "string") r.transaction = r.txHash;
|
|
1853
|
-
return r;
|
|
1854
|
-
}
|
|
1855
|
-
function parseReceiptExtension(response) {
|
|
1856
|
-
const headerValue = _nullishCoalesce(response.headers.get(HEADER_RESPONSE), () => ( response.headers.get(HEADER_RESPONSE_V1)));
|
|
1857
|
-
if (!headerValue) return null;
|
|
1858
|
-
const parsed = fromBase64Json(headerValue);
|
|
1859
|
-
if (!parsed || typeof parsed !== "object") return null;
|
|
1860
|
-
const ext = parsed.extensions;
|
|
1861
|
-
const block = _optionalChain([ext, 'optionalAccess', _12 => _12[EXT_OFFER_RECEIPT]]);
|
|
1862
|
-
const info = _optionalChain([block, 'optionalAccess', _13 => _13.info]);
|
|
1863
|
-
if (!info) return null;
|
|
1864
|
-
const settlement = isValidReceipt(info.settlement) ? info.settlement : isValidReceipt(info.receipt) ? info.receipt : void 0;
|
|
1865
|
-
if (!settlement) return null;
|
|
1866
|
-
const attestation = info.receipt && info.receipt !== settlement ? info.receipt : void 0;
|
|
1867
|
-
const res = info.resource;
|
|
1868
|
-
return {
|
|
1869
|
-
piprail: "1",
|
|
1870
|
-
receipt: settlement,
|
|
1871
|
-
resource: { url: res && typeof res.url === "string" ? res.url : "" },
|
|
1872
|
-
...typeof info.decimals === "number" ? { decimals: info.decimals } : {},
|
|
1873
|
-
...attestation ? { attestation } : {}
|
|
1874
|
-
};
|
|
1875
|
-
}
|
|
1876
|
-
function parseSettleResponse(response) {
|
|
1877
|
-
const headerValue = _nullishCoalesce(response.headers.get(HEADER_RESPONSE), () => ( response.headers.get(HEADER_RESPONSE_V1)));
|
|
1878
|
-
if (!headerValue) return null;
|
|
1879
|
-
const parsed = fromBase64Json(headerValue);
|
|
1880
|
-
if (!parsed || typeof parsed !== "object" || typeof parsed.success !== "boolean") return null;
|
|
1881
|
-
return {
|
|
1882
|
-
success: parsed.success,
|
|
1883
|
-
// Tolerate the legacy v1 `txHash` alias for `transaction` (mirrors isValidReceipt/parseReceipt).
|
|
1884
|
-
...typeof parsed.transaction === "string" ? { transaction: parsed.transaction } : typeof parsed.txHash === "string" ? { transaction: parsed.txHash } : {},
|
|
1885
|
-
...typeof parsed.network === "string" ? { network: parsed.network } : {},
|
|
1886
|
-
...typeof parsed.payer === "string" ? { payer: parsed.payer } : {},
|
|
1887
|
-
...typeof parsed.errorReason === "string" ? { errorReason: parsed.errorReason } : {},
|
|
1888
|
-
// The upto SettleResponse's REQUIRED `amount` (actual settled atomic units) — string
|
|
1889
|
-
// passthrough so the upto buyer records ACTUAL, not MAX. Absent on onchain-proof/exact.
|
|
1890
|
-
...typeof parsed.amount === "string" ? { amount: parsed.amount } : {}
|
|
1891
|
-
};
|
|
1892
|
-
}
|
|
1893
|
-
function parseSignatureObject(parsed) {
|
|
1894
|
-
if (!parsed || typeof parsed !== "object") return null;
|
|
1895
|
-
const v = parsed;
|
|
1896
|
-
const accepted = v.accepted;
|
|
1897
|
-
const scheme = _nullishCoalesce(_optionalChain([accepted, 'optionalAccess', _14 => _14.scheme]), () => ( v.scheme));
|
|
1898
|
-
if (scheme !== "onchain-proof") return null;
|
|
1899
|
-
const payload = v.payload;
|
|
1900
|
-
if (!payload || typeof payload.txHash !== "string" || typeof payload.nonce !== "string") {
|
|
1901
|
-
return null;
|
|
1902
|
-
}
|
|
1903
|
-
if (!accepted) {
|
|
1904
|
-
const synthesized = {
|
|
1905
|
-
scheme: "onchain-proof",
|
|
1906
|
-
...typeof v.network === "string" ? { network: v.network } : {},
|
|
1907
|
-
...typeof v.asset === "string" ? { asset: v.asset } : {}
|
|
1908
|
-
};
|
|
1909
|
-
return { ...v, accepted: synthesized, payload };
|
|
1910
|
-
}
|
|
1911
|
-
return parsed;
|
|
1912
|
-
}
|
|
1913
|
-
function parseSignatureHeader(value) {
|
|
1914
|
-
return parseSignatureObject(fromBase64Json(value));
|
|
1915
|
-
}
|
|
1916
|
-
function parseExactPaymentHeader(value) {
|
|
1917
|
-
return parseExactObject(fromBase64Json(value));
|
|
1918
|
-
}
|
|
1919
|
-
function parseExactObject(parsed) {
|
|
1920
|
-
if (!parsed || typeof parsed !== "object") return null;
|
|
1921
|
-
const v = parsed;
|
|
1922
|
-
const accepted = _nullishCoalesce(v.accepted, () => ( null));
|
|
1923
|
-
const scheme = _nullishCoalesce(_optionalChain([accepted, 'optionalAccess', _15 => _15.scheme]), () => ( v.scheme));
|
|
1924
|
-
if (scheme !== "exact") return null;
|
|
1925
|
-
const network = _nullishCoalesce(_optionalChain([accepted, 'optionalAccess', _16 => _16.network]), () => ( v.network));
|
|
1926
|
-
if (typeof network !== "string") return null;
|
|
1927
|
-
const payload = v.payload;
|
|
1928
|
-
if (!payload || typeof payload !== "object") return null;
|
|
1929
|
-
const x402Version = typeof v.x402Version === "number" ? v.x402Version : 2;
|
|
1930
|
-
const asset = accepted && typeof accepted.asset === "string" ? accepted.asset : void 0;
|
|
1931
|
-
const base2 = { x402Version, network, ...asset ? { asset } : {}, raw: v };
|
|
1932
|
-
if (typeof payload.signedDelegateAction === "string") {
|
|
1933
|
-
return { ...base2, method: "near", payload: { signedDelegateAction: payload.signedDelegateAction } };
|
|
1934
|
-
}
|
|
1935
|
-
if (typeof payload.transaction === "string" && typeof payload.senderAuth === "string") {
|
|
1936
|
-
return { ...base2, method: "aptos", payload: { transaction: payload.transaction, senderAuth: payload.senderAuth } };
|
|
1937
|
-
}
|
|
1938
|
-
if (typeof payload.transaction === "string") {
|
|
1939
|
-
return { ...base2, method: "svm", payload: { transaction: payload.transaction } };
|
|
1940
|
-
}
|
|
1941
|
-
if (Array.isArray(payload.paymentGroup)) {
|
|
1942
|
-
const group = payload.paymentGroup;
|
|
1943
|
-
const index = payload.paymentIndex;
|
|
1944
|
-
if (group.length === 0 || group.length > 16 || !group.every((t) => typeof t === "string") || typeof index !== "number" || !Number.isInteger(index) || index < 0 || index >= group.length) {
|
|
1945
|
-
return null;
|
|
1946
|
-
}
|
|
1947
|
-
return {
|
|
1948
|
-
...base2,
|
|
1949
|
-
method: "algorand",
|
|
1950
|
-
payload: { paymentIndex: index, paymentGroup: group }
|
|
1951
|
-
};
|
|
1952
|
-
}
|
|
1953
|
-
const signature = payload.signature;
|
|
1954
|
-
if (typeof signature !== "string") return null;
|
|
1955
|
-
const authorization = payload.authorization;
|
|
1956
|
-
if (authorization && typeof authorization === "object") {
|
|
1957
|
-
for (const k of ["from", "to", "value", "validAfter", "validBefore", "nonce"]) {
|
|
1958
|
-
if (typeof authorization[k] !== "string") return null;
|
|
1959
|
-
}
|
|
1960
|
-
return {
|
|
1961
|
-
...base2,
|
|
1962
|
-
method: "eip3009",
|
|
1963
|
-
payload: { signature, authorization }
|
|
1964
|
-
};
|
|
1965
|
-
}
|
|
1966
|
-
const p2 = payload.permit2Authorization;
|
|
1967
|
-
if (p2 && typeof p2 === "object") {
|
|
1968
|
-
const permitted = p2.permitted;
|
|
1969
|
-
const witness = p2.witness;
|
|
1970
|
-
if (!permitted || typeof permitted !== "object" || !witness || typeof witness !== "object") return null;
|
|
1971
|
-
if (typeof permitted.token !== "string" || typeof permitted.amount !== "string") return null;
|
|
1972
|
-
if (typeof witness.to !== "string" || typeof witness.validAfter !== "string") return null;
|
|
1973
|
-
for (const k of ["from", "spender", "nonce", "deadline"]) {
|
|
1974
|
-
if (typeof p2[k] !== "string") return null;
|
|
1975
|
-
}
|
|
1976
|
-
return {
|
|
1977
|
-
...base2,
|
|
1978
|
-
method: "permit2",
|
|
1979
|
-
payload: { signature, permit2Authorization: p2 }
|
|
1980
|
-
};
|
|
1981
|
-
}
|
|
1982
|
-
return null;
|
|
1983
|
-
}
|
|
1984
|
-
function parseUptoPaymentHeader(value) {
|
|
1985
|
-
return parseUptoObject(fromBase64Json(value));
|
|
1986
|
-
}
|
|
1987
|
-
function parseUptoObject(parsed) {
|
|
1988
|
-
if (!parsed || typeof parsed !== "object") return null;
|
|
1989
|
-
const v = parsed;
|
|
1990
|
-
const accepted = _nullishCoalesce(v.accepted, () => ( null));
|
|
1991
|
-
const scheme = _nullishCoalesce(_optionalChain([accepted, 'optionalAccess', _17 => _17.scheme]), () => ( v.scheme));
|
|
1992
|
-
if (scheme !== "upto") return null;
|
|
1993
|
-
const network = _nullishCoalesce(_optionalChain([accepted, 'optionalAccess', _18 => _18.network]), () => ( v.network));
|
|
1994
|
-
if (typeof network !== "string") return null;
|
|
1995
|
-
const payload = v.payload;
|
|
1996
|
-
if (!payload || typeof payload !== "object") return null;
|
|
1997
|
-
const signature = payload.signature;
|
|
1998
|
-
if (typeof signature !== "string") return null;
|
|
1999
|
-
const p2 = payload.permit2Authorization;
|
|
2000
|
-
if (!p2 || typeof p2 !== "object") return null;
|
|
2001
|
-
const permitted = p2.permitted;
|
|
2002
|
-
const witness = p2.witness;
|
|
2003
|
-
if (!permitted || typeof permitted !== "object" || !witness || typeof witness !== "object") return null;
|
|
2004
|
-
if (typeof permitted.token !== "string" || typeof permitted.amount !== "string") return null;
|
|
2005
|
-
if (typeof witness.to !== "string" || typeof witness.facilitator !== "string" || typeof witness.validAfter !== "string") {
|
|
2006
|
-
return null;
|
|
2007
|
-
}
|
|
2008
|
-
for (const k of ["from", "spender", "nonce", "deadline"]) {
|
|
2009
|
-
if (typeof p2[k] !== "string") return null;
|
|
2010
|
-
}
|
|
2011
|
-
const x402Version = typeof v.x402Version === "number" ? v.x402Version : 2;
|
|
2012
|
-
const asset = accepted && typeof accepted.asset === "string" ? accepted.asset : void 0;
|
|
2013
|
-
const base2 = { x402Version, network, ...asset ? { asset } : {}, raw: v };
|
|
2014
|
-
return {
|
|
2015
|
-
...base2,
|
|
2016
|
-
method: "permit2-upto",
|
|
2017
|
-
payload: { signature, permit2Authorization: p2 }
|
|
2018
|
-
};
|
|
2019
|
-
}
|
|
2020
|
-
function isValidChallenge(value) {
|
|
2021
|
-
if (!value || typeof value !== "object") return false;
|
|
2022
|
-
const v = value;
|
|
2023
|
-
if (v.x402Version !== 2) return false;
|
|
2024
|
-
if (!Array.isArray(v.accepts) || v.accepts.length === 0) return false;
|
|
2025
|
-
if (!v.accepts.every((a) => a !== null && typeof a === "object")) return false;
|
|
2026
|
-
if (!v.resource || typeof v.resource !== "object") return false;
|
|
2027
|
-
return true;
|
|
2028
|
-
}
|
|
2029
|
-
function isValidReceipt(value) {
|
|
2030
|
-
if (!value || typeof value !== "object") return false;
|
|
2031
|
-
const v = value;
|
|
2032
|
-
if (v.scheme !== "onchain-proof" && v.scheme !== "exact" && v.scheme !== "upto") return false;
|
|
2033
|
-
if (typeof v.transaction !== "string" && typeof v.txHash !== "string") return false;
|
|
2034
|
-
if (typeof v.payer !== "string") return false;
|
|
2035
|
-
return true;
|
|
2036
|
-
}
|
|
2037
|
-
function pickAccept(challenge, matches) {
|
|
2038
|
-
for (const accept of challenge.accepts) {
|
|
2039
|
-
if (accept.scheme === "onchain-proof" && matches(accept.network)) return accept;
|
|
2040
|
-
}
|
|
2041
|
-
return null;
|
|
2042
|
-
}
|
|
2043
|
-
|
|
2044
1776
|
// src/drivers/evm/index.ts
|
|
2045
1777
|
var evmDriver = {
|
|
2046
1778
|
family: "evm",
|
|
@@ -2056,14 +1788,14 @@ var evmDriver = {
|
|
|
2056
1788
|
let resolved;
|
|
2057
1789
|
try {
|
|
2058
1790
|
resolved = resolveChain(opts.chain, opts.rpcUrl);
|
|
2059
|
-
} catch (
|
|
1791
|
+
} catch (e19) {
|
|
2060
1792
|
return null;
|
|
2061
1793
|
}
|
|
2062
1794
|
return makeEvmNetwork(resolved);
|
|
2063
1795
|
}
|
|
2064
1796
|
};
|
|
2065
1797
|
function makeEvmNetwork(resolved) {
|
|
2066
|
-
const network = networkForChain(resolved.chainId);
|
|
1798
|
+
const network = _chunkOXEFPLZAcjs.networkForChain.call(void 0, resolved.chainId);
|
|
2067
1799
|
const publicClient = _viem.createPublicClient.call(void 0, {
|
|
2068
1800
|
chain: resolved.chain,
|
|
2069
1801
|
transport: _viem.http.call(void 0, resolved.rpcUrl)
|
|
@@ -2071,7 +1803,7 @@ function makeEvmNetwork(resolved) {
|
|
|
2071
1803
|
return {
|
|
2072
1804
|
family: "evm",
|
|
2073
1805
|
network,
|
|
2074
|
-
supports: (n) => chainIdFromNetwork(n) === resolved.chainId,
|
|
1806
|
+
supports: (n) => _chunkOXEFPLZAcjs.chainIdFromNetwork.call(void 0, n) === resolved.chainId,
|
|
2075
1807
|
resolveToken(token) {
|
|
2076
1808
|
if (token === "native") {
|
|
2077
1809
|
return {
|
|
@@ -2117,7 +1849,7 @@ function makeEvmNetwork(resolved) {
|
|
|
2117
1849
|
let normalized;
|
|
2118
1850
|
try {
|
|
2119
1851
|
normalized = _viem.getAddress.call(void 0, asset);
|
|
2120
|
-
} catch (
|
|
1852
|
+
} catch (e20) {
|
|
2121
1853
|
return null;
|
|
2122
1854
|
}
|
|
2123
1855
|
for (const info of Object.values(resolved.tokens)) {
|
|
@@ -2184,7 +1916,7 @@ function makeEvmNetwork(resolved) {
|
|
|
2184
1916
|
async estimateCost(accept) {
|
|
2185
1917
|
const { decimals, symbol } = resolved.chain.nativeCurrency;
|
|
2186
1918
|
if (accept.scheme === "exact" || accept.scheme === "upto") {
|
|
2187
|
-
const m = _optionalChain([accept, 'access',
|
|
1919
|
+
const m = _optionalChain([accept, 'access', _20 => _20.extra, 'optionalAccess', _21 => _21.assetTransferMethod]);
|
|
2188
1920
|
const permit2 = m === "permit2" || m === "permit2-exact" || m === "permit2-upto";
|
|
2189
1921
|
return _chunkQONQSZHJcjs.nativeCost.call(void 0, {
|
|
2190
1922
|
symbol,
|
|
@@ -2204,7 +1936,7 @@ function makeEvmNetwork(resolved) {
|
|
|
2204
1936
|
basis: "estimated",
|
|
2205
1937
|
detail: `~${gasLimit} gas @ ${gasPrice} wei/gas`
|
|
2206
1938
|
});
|
|
2207
|
-
} catch (
|
|
1939
|
+
} catch (e21) {
|
|
2208
1940
|
const gasPrice = 5000000000n;
|
|
2209
1941
|
return _chunkQONQSZHJcjs.nativeCost.call(void 0, {
|
|
2210
1942
|
symbol,
|
|
@@ -2227,7 +1959,7 @@ function makeEvmNetwork(resolved) {
|
|
|
2227
1959
|
functionName: "balanceOf",
|
|
2228
1960
|
args: [owner]
|
|
2229
1961
|
});
|
|
2230
|
-
} catch (
|
|
1962
|
+
} catch (e22) {
|
|
2231
1963
|
token = null;
|
|
2232
1964
|
}
|
|
2233
1965
|
return { token, native };
|
|
@@ -2269,7 +2001,7 @@ function makeEvmNetwork(resolved) {
|
|
|
2269
2001
|
// Throws UnsupportedSchemeError for a contract signer (or a non-EIP-3009 token on the eip3009 path).
|
|
2270
2002
|
async payExact(wallet, accept) {
|
|
2271
2003
|
const a = wallet._native;
|
|
2272
|
-
const method =
|
|
2004
|
+
const method = _chunkOXEFPLZAcjs.exactTransferMethod.call(void 0, accept);
|
|
2273
2005
|
if (method === "permit2" || method === "permit2-exact") {
|
|
2274
2006
|
const { payload: payload2, payerFrom: payerFrom2, nonce: nonce2 } = await payPermit2Evm({
|
|
2275
2007
|
publicClient,
|
|
@@ -2342,6 +2074,9 @@ function makeEvmNetwork(resolved) {
|
|
|
2342
2074
|
if ("signedDelegateAction" in payload) {
|
|
2343
2075
|
return { ok: false, error: "signature_invalid", detail: "A NEAR payload was submitted to an EVM exact rail." };
|
|
2344
2076
|
}
|
|
2077
|
+
if ("signedTxBlob" in payload) {
|
|
2078
|
+
return { ok: false, error: "signature_invalid", detail: "An XRPL payload was submitted to an EVM exact rail." };
|
|
2079
|
+
}
|
|
2345
2080
|
return verifyAndSettleExactEvm({
|
|
2346
2081
|
publicClient,
|
|
2347
2082
|
walletClient: a.walletClient,
|
|
@@ -2403,7 +2138,7 @@ var loaders = {
|
|
|
2403
2138
|
solana: async () => {
|
|
2404
2139
|
let mod;
|
|
2405
2140
|
try {
|
|
2406
|
-
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./solana-
|
|
2141
|
+
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./solana-AI2G7V33.cjs")));
|
|
2407
2142
|
} catch (cause) {
|
|
2408
2143
|
throw new (0, _chunkQONQSZHJcjs.MissingDriverError)(
|
|
2409
2144
|
`Solana selected, but its packages aren't installed. Run: npm install @solana/web3.js @solana/spl-token bs58`,
|
|
@@ -2439,7 +2174,7 @@ var loaders = {
|
|
|
2439
2174
|
xrpl: async () => {
|
|
2440
2175
|
let mod;
|
|
2441
2176
|
try {
|
|
2442
|
-
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./xrpl-
|
|
2177
|
+
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./xrpl-SVVS445B.cjs")));
|
|
2443
2178
|
} catch (cause) {
|
|
2444
2179
|
throw new (0, _chunkQONQSZHJcjs.MissingDriverError)(
|
|
2445
2180
|
`XRPL selected, but its package isn't installed. Run: npm install xrpl`,
|
|
@@ -2487,7 +2222,7 @@ var loaders = {
|
|
|
2487
2222
|
aptos: async () => {
|
|
2488
2223
|
let mod;
|
|
2489
2224
|
try {
|
|
2490
|
-
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./aptos-
|
|
2225
|
+
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./aptos-VBJONBFY.cjs")));
|
|
2491
2226
|
} catch (cause) {
|
|
2492
2227
|
throw new (0, _chunkQONQSZHJcjs.MissingDriverError)(
|
|
2493
2228
|
`Aptos selected, but its package isn't installed. Run: npm install @aptos-labs/ts-sdk`,
|
|
@@ -2499,7 +2234,7 @@ var loaders = {
|
|
|
2499
2234
|
algorand: async () => {
|
|
2500
2235
|
let mod;
|
|
2501
2236
|
try {
|
|
2502
|
-
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./algorand-
|
|
2237
|
+
mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./algorand-Q3TUQLPK.cjs")));
|
|
2503
2238
|
} catch (cause) {
|
|
2504
2239
|
throw new (0, _chunkQONQSZHJcjs.MissingDriverError)(
|
|
2505
2240
|
`Algorand selected, but its package isn't installed. Run: npm install algosdk`,
|
|
@@ -2531,619 +2266,6 @@ async function resolveNetwork2(opts) {
|
|
|
2531
2266
|
return resolveNetwork(opts);
|
|
2532
2267
|
}
|
|
2533
2268
|
|
|
2534
|
-
// src/indexes.ts
|
|
2535
|
-
var DIRECTORY_INFO = Object.freeze({
|
|
2536
|
-
"402index": {
|
|
2537
|
-
source: "402index",
|
|
2538
|
-
review: "probe-sync",
|
|
2539
|
-
auth: "none",
|
|
2540
|
-
chains: null,
|
|
2541
|
-
onSuccess: "pending-review",
|
|
2542
|
-
readByDiscover: true,
|
|
2543
|
-
caveat: "402 Index probes your URL on submit (rejecting anything that does not return a real 402), then lists it \u2014 a self-registered resource becomes searchable once it passes automated health + payment-validity checks, with NO domain verification required (observed live: searchable within ~2 days for a healthy endpoint). Verify your domain on 402index.io for instant, guaranteed approval + a verified badge, which also flips every pending listing on that domain live at once."
|
|
2544
|
-
},
|
|
2545
|
-
x402scan: {
|
|
2546
|
-
source: "x402scan",
|
|
2547
|
-
review: "probe-sync",
|
|
2548
|
-
auth: "siwx",
|
|
2549
|
-
chains: ["eip155:8453", "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp"],
|
|
2550
|
-
onSuccess: "live",
|
|
2551
|
-
readByDiscover: false,
|
|
2552
|
-
caveat: "x402scan lists Base/Solana only, needs one wallet signature (SIWX), and requires a resolvable input schema (from /openapi.json or the bazaar extension in the 402 body). It goes live on x402scan.com immediately on success \u2014 but discover() does NOT read x402scan, so the listing won't appear in discover() results."
|
|
2553
|
-
},
|
|
2554
|
-
bazaar: {
|
|
2555
|
-
source: "bazaar",
|
|
2556
|
-
review: "settle-coupled",
|
|
2557
|
-
auth: "facilitator-only",
|
|
2558
|
-
chains: null,
|
|
2559
|
-
onSuccess: "not-listable",
|
|
2560
|
-
readByDiscover: true,
|
|
2561
|
-
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."
|
|
2562
|
-
}
|
|
2563
|
-
});
|
|
2564
|
-
function getDirectoryInfo(source) {
|
|
2565
|
-
return DIRECTORY_INFO[source];
|
|
2566
|
-
}
|
|
2567
|
-
function decorateOutcome(o) {
|
|
2568
|
-
const info = DIRECTORY_INFO[o.source];
|
|
2569
|
-
return { ...o, visibility: _nullishCoalesce(o.visibility, () => ( (o.ok ? info.onSuccess : "not-listable"))), note: info.caveat };
|
|
2570
|
-
}
|
|
2571
|
-
var BAZAAR_URL = "https://api.cdp.coinbase.com/platform/v2/x402/discovery/resources";
|
|
2572
|
-
var INDEX402_SEARCH = "https://402index.io/api/v1/services";
|
|
2573
|
-
var INDEX402_REGISTER = "https://402index.io/api/v1/register";
|
|
2574
|
-
var INDEX402_CLAIM = "https://402index.io/api/v1/claim";
|
|
2575
|
-
var INDEX402_VERIFY = "https://402index.io/api/v1/claim/verify";
|
|
2576
|
-
var X402SCAN_REGISTER = "https://www.x402scan.com/api/x402/registry/register";
|
|
2577
|
-
var USER_AGENT = "@piprail/sdk (+https://piprail.com)";
|
|
2578
|
-
function clientHeaders(extra = {}) {
|
|
2579
|
-
return { "user-agent": USER_AGENT, ...extra };
|
|
2580
|
-
}
|
|
2581
|
-
var SLUG_TO_CAIP2 = {
|
|
2582
|
-
// EVM (the common index-reported slugs; others fall through to net.supports)
|
|
2583
|
-
ethereum: "eip155:1",
|
|
2584
|
-
base: "eip155:8453",
|
|
2585
|
-
polygon: "eip155:137",
|
|
2586
|
-
arbitrum: "eip155:42161",
|
|
2587
|
-
optimism: "eip155:10",
|
|
2588
|
-
avalanche: "eip155:43114",
|
|
2589
|
-
bnb: "eip155:56",
|
|
2590
|
-
bsc: "eip155:56",
|
|
2591
|
-
// non-EVM families — values mirror each driver's bound caip2 exactly
|
|
2592
|
-
solana: "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",
|
|
2593
|
-
ton: "tvm:-239",
|
|
2594
|
-
tron: "tron:mainnet",
|
|
2595
|
-
near: "near:mainnet",
|
|
2596
|
-
sui: "sui:mainnet",
|
|
2597
|
-
aptos: "aptos:1",
|
|
2598
|
-
algorand: "algorand:wGHE2Pwdvd7S12BL5FaOP20EGYesN73ktiC1qzkkit8=",
|
|
2599
|
-
stellar: "stellar:pubnet",
|
|
2600
|
-
xrpl: "xrpl:0"
|
|
2601
|
-
};
|
|
2602
|
-
var LEGACY_CAIP2_ALIAS = {
|
|
2603
|
-
"ton:-239": "tvm:-239"
|
|
2604
|
-
};
|
|
2605
|
-
function normalizeNetwork(network) {
|
|
2606
|
-
const legacy = LEGACY_CAIP2_ALIAS[network];
|
|
2607
|
-
if (legacy) return legacy;
|
|
2608
|
-
if (network.includes(":")) return network;
|
|
2609
|
-
return _nullishCoalesce(SLUG_TO_CAIP2[network.toLowerCase()], () => ( network));
|
|
2610
|
-
}
|
|
2611
|
-
async function searchOpenIndexes(opts = {}) {
|
|
2612
|
-
const sources = _nullishCoalesce(opts.sources, () => ( ["bazaar", "402index"]));
|
|
2613
|
-
const limit = _nullishCoalesce(opts.limit, () => ( 20));
|
|
2614
|
-
const filters = {
|
|
2615
|
-
...optionalRaw("category", opts.category),
|
|
2616
|
-
...optionalRaw("asset", opts.asset),
|
|
2617
|
-
...optionalRaw("maxPrice", opts.maxPrice),
|
|
2618
|
-
...optionalRaw("verified", opts.verified),
|
|
2619
|
-
...optionalRaw("paymentValid", opts.paymentValid),
|
|
2620
|
-
...optionalRaw("sort", opts.sort),
|
|
2621
|
-
...optionalRaw("order", opts.order)
|
|
2622
|
-
};
|
|
2623
|
-
const results = await Promise.all(
|
|
2624
|
-
sources.map((source) => {
|
|
2625
|
-
if (source === "bazaar") return safeSearch(() => searchBazaar(opts.query, limit, opts.signal));
|
|
2626
|
-
if (source === "402index") return safeSearch(() => search402Index(opts.query, limit, filters, opts.signal));
|
|
2627
|
-
return Promise.resolve([]);
|
|
2628
|
-
})
|
|
2629
|
-
);
|
|
2630
|
-
const merged = applyClientFilters(dedupeByResource(results.flat()), opts);
|
|
2631
|
-
const wantRelevance = opts.query !== void 0 && (_nullishCoalesce(opts.sort, () => ( "relevance"))) === "relevance";
|
|
2632
|
-
if (wantRelevance) return rankResources(merged, opts.query);
|
|
2633
|
-
if (opts.sort && opts.sort !== "relevance") return sortResources(merged, opts.sort, _nullishCoalesce(opts.order, () => ( "desc")));
|
|
2634
|
-
return merged;
|
|
2635
|
-
}
|
|
2636
|
-
function optionalRaw(field, value) {
|
|
2637
|
-
return value !== void 0 ? { [field]: value } : {};
|
|
2638
|
-
}
|
|
2639
|
-
function applyClientFilters(items, opts) {
|
|
2640
|
-
let out = items;
|
|
2641
|
-
if (opts.category) {
|
|
2642
|
-
const want = opts.category.toLowerCase();
|
|
2643
|
-
out = out.filter((r) => r.category !== void 0 && r.category.toLowerCase().startsWith(want));
|
|
2644
|
-
}
|
|
2645
|
-
if (opts.maxPrice !== void 0) {
|
|
2646
|
-
const max = opts.maxPrice;
|
|
2647
|
-
out = out.filter((r) => r.priceUsd === void 0 || r.priceUsd <= max);
|
|
2648
|
-
}
|
|
2649
|
-
if (opts.asset) {
|
|
2650
|
-
const want = opts.asset.toLowerCase();
|
|
2651
|
-
out = out.filter((r) => {
|
|
2652
|
-
const known = r.rails.map((x) => _nullishCoalesce(x.symbol, () => ( x.asset))).filter((a) => !!a);
|
|
2653
|
-
return known.length === 0 || known.some((a) => a.toLowerCase() === want);
|
|
2654
|
-
});
|
|
2655
|
-
}
|
|
2656
|
-
if (opts.minReliability !== void 0) {
|
|
2657
|
-
const min = opts.minReliability;
|
|
2658
|
-
out = out.filter((r) => r.reliabilityScore === void 0 || r.reliabilityScore >= min);
|
|
2659
|
-
}
|
|
2660
|
-
return out;
|
|
2661
|
-
}
|
|
2662
|
-
function tokenize(s) {
|
|
2663
|
-
return _nullishCoalesce((_nullishCoalesce(s, () => ( ""))).toLowerCase().match(/[a-z0-9]+/g), () => ( []));
|
|
2664
|
-
}
|
|
2665
|
-
var FIELD_WEIGHTS = { name: 6, category: 4, tags: 4, path: 3, description: 2 };
|
|
2666
|
-
function fieldTokens(r) {
|
|
2667
|
-
let pathText = r.resource;
|
|
2668
|
-
try {
|
|
2669
|
-
const u = new URL(r.resource);
|
|
2670
|
-
pathText = `${u.hostname} ${u.pathname}`;
|
|
2671
|
-
} catch (e25) {
|
|
2672
|
-
}
|
|
2673
|
-
return [
|
|
2674
|
-
[tokenize(r.name), FIELD_WEIGHTS.name],
|
|
2675
|
-
[tokenize(r.category), FIELD_WEIGHTS.category],
|
|
2676
|
-
[tokenize((_nullishCoalesce(r.tags, () => ( []))).join(" ")), FIELD_WEIGHTS.tags],
|
|
2677
|
-
[tokenize(pathText), FIELD_WEIGHTS.path],
|
|
2678
|
-
[tokenize(r.description), FIELD_WEIGHTS.description]
|
|
2679
|
-
];
|
|
2680
|
-
}
|
|
2681
|
-
function scoreResource(r, queryTokens) {
|
|
2682
|
-
if (queryTokens.length === 0) return 0;
|
|
2683
|
-
const fields = fieldTokens(r);
|
|
2684
|
-
let score = 0;
|
|
2685
|
-
let matched = 0;
|
|
2686
|
-
for (const qt of queryTokens) {
|
|
2687
|
-
let hit = false;
|
|
2688
|
-
for (const [toks, w] of fields) {
|
|
2689
|
-
if (toks.includes(qt)) {
|
|
2690
|
-
score += w;
|
|
2691
|
-
hit = true;
|
|
2692
|
-
} else if (qt.length >= 4 && toks.some((t) => t.startsWith(qt) || t.length >= 4 && qt.startsWith(t))) {
|
|
2693
|
-
score += w * 0.4;
|
|
2694
|
-
hit = true;
|
|
2695
|
-
}
|
|
2696
|
-
}
|
|
2697
|
-
if (hit) matched++;
|
|
2698
|
-
}
|
|
2699
|
-
if (matched === 0) return 0;
|
|
2700
|
-
if (matched === queryTokens.length) score += 8;
|
|
2701
|
-
if (r.reliabilityScore !== void 0) score += r.reliabilityScore / 1e3;
|
|
2702
|
-
return score;
|
|
2703
|
-
}
|
|
2704
|
-
function rankResources(items, query) {
|
|
2705
|
-
const qTokens = tokenize(query);
|
|
2706
|
-
if (qTokens.length === 0) return items;
|
|
2707
|
-
return items.map((r, i) => ({ r, i, s: scoreResource(r, qTokens) })).filter((x) => x.s > 0).sort((a, b) => b.s - a.s || a.i - b.i).map((x) => ({ ...x.r, score: x.s }));
|
|
2708
|
-
}
|
|
2709
|
-
function sortResources(items, sort, order) {
|
|
2710
|
-
const dir = order === "asc" ? 1 : -1;
|
|
2711
|
-
const key = (r) => sort === "reliability" || sort === "uptime" ? r.reliabilityScore : sort === "price" ? r.priceUsd : sort === "name" ? (_nullishCoalesce(r.name, () => ( r.resource))).toLowerCase() : void 0;
|
|
2712
|
-
return items.map((r, i) => ({ r, i })).sort((a, b) => {
|
|
2713
|
-
const ka = key(a.r);
|
|
2714
|
-
const kb = key(b.r);
|
|
2715
|
-
if (ka === void 0 && kb === void 0) return a.i - b.i;
|
|
2716
|
-
if (ka === void 0) return 1;
|
|
2717
|
-
if (kb === void 0) return -1;
|
|
2718
|
-
if (ka < kb) return -1 * dir;
|
|
2719
|
-
if (ka > kb) return 1 * dir;
|
|
2720
|
-
return a.i - b.i;
|
|
2721
|
-
}).map((x) => x.r);
|
|
2722
|
-
}
|
|
2723
|
-
async function safeSearch(run) {
|
|
2724
|
-
try {
|
|
2725
|
-
return await run();
|
|
2726
|
-
} catch (e26) {
|
|
2727
|
-
return [];
|
|
2728
|
-
}
|
|
2729
|
-
}
|
|
2730
|
-
function dedupeByResource(items) {
|
|
2731
|
-
const seen = /* @__PURE__ */ new Set();
|
|
2732
|
-
const out = [];
|
|
2733
|
-
for (const it of items) {
|
|
2734
|
-
const key = it.resource;
|
|
2735
|
-
if (!key || seen.has(key)) continue;
|
|
2736
|
-
seen.add(key);
|
|
2737
|
-
out.push(it);
|
|
2738
|
-
}
|
|
2739
|
-
return out;
|
|
2740
|
-
}
|
|
2741
|
-
async function searchBazaar(query, limit, signal) {
|
|
2742
|
-
const res = await fetch(`${BAZAAR_URL}?limit=${encodeURIComponent(String(limit))}`, {
|
|
2743
|
-
headers: clientHeaders({ accept: "application/json" }),
|
|
2744
|
-
...signal ? { signal } : {}
|
|
2745
|
-
});
|
|
2746
|
-
if (!res.ok) return [];
|
|
2747
|
-
const body = await res.json();
|
|
2748
|
-
const items = Array.isArray(body.items) ? body.items : [];
|
|
2749
|
-
const mapped = items.map(mapBazaarItem).filter((r) => r !== null);
|
|
2750
|
-
return query ? mapped.filter((r) => matchesQuery(r, query)) : mapped;
|
|
2751
|
-
}
|
|
2752
|
-
function mapBazaarItem(raw) {
|
|
2753
|
-
if (!raw || typeof raw !== "object") return null;
|
|
2754
|
-
const o = raw;
|
|
2755
|
-
const resource = pickString(o, "resource", "url", "endpoint");
|
|
2756
|
-
if (!resource) return null;
|
|
2757
|
-
const meta = o.metadata && typeof o.metadata === "object" ? o.metadata : {};
|
|
2758
|
-
return {
|
|
2759
|
-
resource,
|
|
2760
|
-
source: "bazaar",
|
|
2761
|
-
rails: mapRails(o.accepts),
|
|
2762
|
-
...optionalString("name", pickString(meta, "name", "title")),
|
|
2763
|
-
...optionalString("description", _nullishCoalesce(pickString(meta, "description"), () => ( pickString(o, "description")))),
|
|
2764
|
-
...optionalString("category", pickString(meta, "category"))
|
|
2765
|
-
};
|
|
2766
|
-
}
|
|
2767
|
-
async function search402Index(query, limit, filters, signal) {
|
|
2768
|
-
const tokens = tokenize(query);
|
|
2769
|
-
const queries = query && tokens.length > 1 ? [.../* @__PURE__ */ new Set([query, ...tokens])].slice(0, 5) : [query];
|
|
2770
|
-
const pages = await Promise.all(queries.map((q) => safeSearch(() => fetch402Page(q, limit, filters, signal))));
|
|
2771
|
-
return dedupeByResource(pages.flat());
|
|
2772
|
-
}
|
|
2773
|
-
async function fetch402Page(query, limit, filters, signal) {
|
|
2774
|
-
const qs = new URLSearchParams({ limit: String(limit) });
|
|
2775
|
-
if (query) qs.set("q", query);
|
|
2776
|
-
if (filters.category) qs.set("category", filters.category);
|
|
2777
|
-
if (filters.asset) qs.set("payment_asset", filters.asset);
|
|
2778
|
-
if (filters.maxPrice !== void 0) qs.set("max_price_usd", String(filters.maxPrice));
|
|
2779
|
-
if (filters.verified) qs.set("verified", "true");
|
|
2780
|
-
if (filters.paymentValid) qs.set("payment_valid", "true");
|
|
2781
|
-
if (filters.sort && filters.sort !== "relevance") {
|
|
2782
|
-
qs.set("sort", filters.sort);
|
|
2783
|
-
qs.set("order", _nullishCoalesce(filters.order, () => ( "desc")));
|
|
2784
|
-
}
|
|
2785
|
-
const res = await fetch(`${INDEX402_SEARCH}?${qs.toString()}`, {
|
|
2786
|
-
headers: clientHeaders({ accept: "application/json" }),
|
|
2787
|
-
...signal ? { signal } : {}
|
|
2788
|
-
});
|
|
2789
|
-
if (!res.ok) return [];
|
|
2790
|
-
const body = await res.json();
|
|
2791
|
-
const list = firstArray(body, "services", "results", "items", "data");
|
|
2792
|
-
return list.map(map402IndexItem).filter((r) => r !== null).filter((r) => r.rails.length > 0);
|
|
2793
|
-
}
|
|
2794
|
-
function map402IndexItem(raw) {
|
|
2795
|
-
if (!raw || typeof raw !== "object") return null;
|
|
2796
|
-
const o = raw;
|
|
2797
|
-
const resource = pickString(o, "url", "resource", "endpoint");
|
|
2798
|
-
if (!resource) return null;
|
|
2799
|
-
const protocol = (_nullishCoalesce(pickString(o, "protocol"), () => ( "x402"))).toLowerCase();
|
|
2800
|
-
if (protocol !== "x402") return null;
|
|
2801
|
-
const rails = Array.isArray(o.accepts) ? mapRails(o.accepts) : railFrom402IndexFields(o);
|
|
2802
|
-
const priceUsd = pickNumber(o, "price_usd", "priceUsd", "price");
|
|
2803
|
-
const reliabilityScore = pickNumber(o, "reliability_score", "reliabilityScore");
|
|
2804
|
-
const tags = pickStringArray(o, "tags", "keywords");
|
|
2805
|
-
return {
|
|
2806
|
-
resource,
|
|
2807
|
-
source: "402index",
|
|
2808
|
-
rails,
|
|
2809
|
-
...priceUsd !== void 0 ? { priceUsd } : {},
|
|
2810
|
-
...reliabilityScore !== void 0 ? { reliabilityScore } : {},
|
|
2811
|
-
...tags ? { tags } : {},
|
|
2812
|
-
...optionalString("name", pickString(o, "name", "title")),
|
|
2813
|
-
...optionalString("description", pickString(o, "description")),
|
|
2814
|
-
...optionalString("category", pickString(o, "category", "tag")),
|
|
2815
|
-
...optionalString("health", pickString(o, "health_status", "health")),
|
|
2816
|
-
// 402 Index reports domain_verified as 0/1; surface a boolean only when the field is present.
|
|
2817
|
-
...o.domain_verified !== void 0 || o.verified !== void 0 ? { verified: isTruthyFlag(o.domain_verified) || isTruthyFlag(o.verified) } : {}
|
|
2818
|
-
};
|
|
2819
|
-
}
|
|
2820
|
-
function isTruthyFlag(v) {
|
|
2821
|
-
return v === 1 || v === true || v === "1" || v === "true";
|
|
2822
|
-
}
|
|
2823
|
-
function railFrom402IndexFields(o) {
|
|
2824
|
-
const network = pickString(o, "payment_network", "network");
|
|
2825
|
-
const asset = pickString(o, "payment_asset", "asset", "token");
|
|
2826
|
-
if (!network && !asset) return [];
|
|
2827
|
-
return [
|
|
2828
|
-
{
|
|
2829
|
-
scheme: "exact",
|
|
2830
|
-
network: _nullishCoalesce(network, () => ( "unknown")),
|
|
2831
|
-
...asset ? { asset } : {},
|
|
2832
|
-
...optionalString("symbol", asset)
|
|
2833
|
-
}
|
|
2834
|
-
];
|
|
2835
|
-
}
|
|
2836
|
-
async function register402Index(input) {
|
|
2837
|
-
try {
|
|
2838
|
-
const attributionOn = input.attribution !== false;
|
|
2839
|
-
const withTags = appendKeywords(input.description, input.tags);
|
|
2840
|
-
const description = attributionOn ? appendAttribution(withTags) : withTags;
|
|
2841
|
-
const payload = {
|
|
2842
|
-
url: input.url,
|
|
2843
|
-
name: _nullishCoalesce(input.name, () => ( hostOf(input.url))),
|
|
2844
|
-
protocol: "x402",
|
|
2845
|
-
...description ? { description } : {},
|
|
2846
|
-
...typeof input.priceUsd === "number" ? { price_usd: input.priceUsd } : {},
|
|
2847
|
-
...input.asset ? { payment_asset: input.asset } : {},
|
|
2848
|
-
...input.network ? { payment_network: input.network } : {},
|
|
2849
|
-
...input.method ? { http_method: input.method.toUpperCase() } : {},
|
|
2850
|
-
...input.category ? { category: input.category } : {},
|
|
2851
|
-
...input.tags && input.tags.length > 0 ? { tags: input.tags } : {},
|
|
2852
|
-
...input.provider ? { provider: input.provider } : {},
|
|
2853
|
-
...input.contactEmail ? { contact_email: input.contactEmail } : {},
|
|
2854
|
-
...input.probeBody !== void 0 ? { probe_body: input.probeBody } : {},
|
|
2855
|
-
...attributionOn ? { via: "@piprail/sdk" } : {}
|
|
2856
|
-
};
|
|
2857
|
-
const res = await fetch(INDEX402_REGISTER, {
|
|
2858
|
-
method: "POST",
|
|
2859
|
-
headers: clientHeaders({ "content-type": "application/json", accept: "application/json" }),
|
|
2860
|
-
body: JSON.stringify(payload)
|
|
2861
|
-
});
|
|
2862
|
-
if (res.ok) {
|
|
2863
|
-
const body = await res.json().catch(() => ({}));
|
|
2864
|
-
const msg = typeof body.message === "string" && body.message.length > 0 ? body.message : void 0;
|
|
2865
|
-
const live = _optionalChain([body, 'access', _21 => _21.service, 'optionalAccess', _22 => _22.status]) === "active";
|
|
2866
|
-
return {
|
|
2867
|
-
source: "402index",
|
|
2868
|
-
ok: true,
|
|
2869
|
-
status: res.status,
|
|
2870
|
-
...live ? { visibility: "live" } : {},
|
|
2871
|
-
detail: _nullishCoalesce(msg, () => ( (live ? "Registered + live on 402 Index (domain verified)." : "Registered on 402 Index \u2014 probed on submit, then searchable once it passes automated health + payment checks (verify your domain on 402index.io for instant approval + a verified badge).")))
|
|
2872
|
-
};
|
|
2873
|
-
}
|
|
2874
|
-
const why = await readIndexError(res);
|
|
2875
|
-
return {
|
|
2876
|
-
source: "402index",
|
|
2877
|
-
ok: false,
|
|
2878
|
-
status: res.status,
|
|
2879
|
-
detail: why ? `402 Index rejected it (HTTP ${res.status}): ${why}` : `402 Index returned HTTP ${res.status}.`
|
|
2880
|
-
};
|
|
2881
|
-
} catch (err) {
|
|
2882
|
-
return { source: "402index", ok: false, detail: errMsg(err) };
|
|
2883
|
-
}
|
|
2884
|
-
}
|
|
2885
|
-
async function readIndexError(res) {
|
|
2886
|
-
try {
|
|
2887
|
-
const body = await res.json();
|
|
2888
|
-
const parts = [body.error, body.detail, body.message].filter(
|
|
2889
|
-
(p) => typeof p === "string" && p.length > 0
|
|
2890
|
-
);
|
|
2891
|
-
return parts.length ? [...new Set(parts)].join(" \u2014 ") : void 0;
|
|
2892
|
-
} catch (e27) {
|
|
2893
|
-
return void 0;
|
|
2894
|
-
}
|
|
2895
|
-
}
|
|
2896
|
-
async function registerX402Scan(input, signer) {
|
|
2897
|
-
try {
|
|
2898
|
-
const challengeRes = await fetch(X402SCAN_REGISTER, {
|
|
2899
|
-
method: "POST",
|
|
2900
|
-
headers: clientHeaders({ "content-type": "application/json", accept: "application/json" }),
|
|
2901
|
-
body: JSON.stringify({ url: input.url })
|
|
2902
|
-
});
|
|
2903
|
-
if (challengeRes.status !== 402) {
|
|
2904
|
-
return {
|
|
2905
|
-
source: "x402scan",
|
|
2906
|
-
ok: challengeRes.ok,
|
|
2907
|
-
status: challengeRes.status,
|
|
2908
|
-
detail: challengeRes.ok ? "Listed on x402scan." : `x402scan returned HTTP ${challengeRes.status} (expected a SIWX 402 challenge).`
|
|
2909
|
-
};
|
|
2910
|
-
}
|
|
2911
|
-
const info = await readSiwxInfo(challengeRes);
|
|
2912
|
-
if (!info) {
|
|
2913
|
-
return { source: "x402scan", ok: false, status: 402, detail: "x402scan SIWX challenge was unparseable." };
|
|
2914
|
-
}
|
|
2915
|
-
const resolvedInfo = { ...info, issuedAt: _nullishCoalesce(info.issuedAt, () => ( (/* @__PURE__ */ new Date()).toISOString())) };
|
|
2916
|
-
const message = formatSiweMessage(resolvedInfo, signer.address);
|
|
2917
|
-
const signature = await signer.signMessage(message);
|
|
2918
|
-
const header = encodeBase642(
|
|
2919
|
-
JSON.stringify({ ...resolvedInfo, address: signer.address, type: "eip191", message, signature })
|
|
2920
|
-
);
|
|
2921
|
-
const res = await fetch(X402SCAN_REGISTER, {
|
|
2922
|
-
method: "POST",
|
|
2923
|
-
headers: clientHeaders({
|
|
2924
|
-
"content-type": "application/json",
|
|
2925
|
-
accept: "application/json",
|
|
2926
|
-
"sign-in-with-x": header
|
|
2927
|
-
}),
|
|
2928
|
-
body: JSON.stringify({ url: input.url })
|
|
2929
|
-
});
|
|
2930
|
-
if (res.ok) {
|
|
2931
|
-
return { source: "x402scan", ok: true, status: res.status, detail: "Listed on x402scan (SIWX)." };
|
|
2932
|
-
}
|
|
2933
|
-
const why = await readIndexError(res);
|
|
2934
|
-
return {
|
|
2935
|
-
source: "x402scan",
|
|
2936
|
-
ok: false,
|
|
2937
|
-
status: res.status,
|
|
2938
|
-
detail: why ? `x402scan rejected it (HTTP ${res.status}): ${why}` : `x402scan returned HTTP ${res.status} after signing.`
|
|
2939
|
-
};
|
|
2940
|
-
} catch (err) {
|
|
2941
|
-
return { source: "x402scan", ok: false, detail: errMsg(err) };
|
|
2942
|
-
}
|
|
2943
|
-
}
|
|
2944
|
-
async function claim402IndexDomain(domainOrUrl, opts = {}) {
|
|
2945
|
-
const domain = hostOf(domainOrUrl);
|
|
2946
|
-
try {
|
|
2947
|
-
const res = await fetch(INDEX402_CLAIM, {
|
|
2948
|
-
method: "POST",
|
|
2949
|
-
headers: clientHeaders({ "content-type": "application/json", accept: "application/json" }),
|
|
2950
|
-
body: JSON.stringify({ domain, ...opts.contactEmail ? { contact_email: opts.contactEmail } : {} })
|
|
2951
|
-
});
|
|
2952
|
-
const body = await res.json().catch(() => ({}));
|
|
2953
|
-
if (!res.ok) {
|
|
2954
|
-
return { ok: false, domain, httpStatus: res.status, detail: _nullishCoalesce(pickString(body, "error", "detail", "message"), () => ( `402 Index claim returned HTTP ${res.status}.`)) };
|
|
2955
|
-
}
|
|
2956
|
-
const verificationToken = pickString(body, "verification_token");
|
|
2957
|
-
const verificationHash = await _asyncNullishCoalesce(pickString(body, "verification_hash"), async () => ( (verificationToken ? await sha256Hex(verificationToken) : void 0)));
|
|
2958
|
-
return {
|
|
2959
|
-
ok: true,
|
|
2960
|
-
domain,
|
|
2961
|
-
httpStatus: res.status,
|
|
2962
|
-
...optionalString("verificationHash", verificationHash),
|
|
2963
|
-
...optionalString("verificationToken", verificationToken),
|
|
2964
|
-
...optionalString("verificationUrl", pickString(body, "verification_url")),
|
|
2965
|
-
...optionalString("instructions", pickString(body, "instructions"))
|
|
2966
|
-
};
|
|
2967
|
-
} catch (err) {
|
|
2968
|
-
return { ok: false, domain, detail: errMsg(err) };
|
|
2969
|
-
}
|
|
2970
|
-
}
|
|
2971
|
-
async function sha256Hex(input) {
|
|
2972
|
-
const digest = await globalThis.crypto.subtle.digest("SHA-256", new TextEncoder().encode(input));
|
|
2973
|
-
return Array.from(new Uint8Array(digest)).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
2974
|
-
}
|
|
2975
|
-
async function verify402IndexDomain(domainOrUrl) {
|
|
2976
|
-
const domain = hostOf(domainOrUrl);
|
|
2977
|
-
try {
|
|
2978
|
-
const res = await fetch(INDEX402_VERIFY, {
|
|
2979
|
-
method: "POST",
|
|
2980
|
-
headers: clientHeaders({ "content-type": "application/json", accept: "application/json" }),
|
|
2981
|
-
body: JSON.stringify({ domain })
|
|
2982
|
-
});
|
|
2983
|
-
const body = await res.json().catch(() => ({}));
|
|
2984
|
-
if (!res.ok) {
|
|
2985
|
-
return { ok: false, domain, httpStatus: res.status, detail: _nullishCoalesce(pickString(body, "error", "detail", "message"), () => ( `402 Index verify returned HTTP ${res.status}.`)) };
|
|
2986
|
-
}
|
|
2987
|
-
return {
|
|
2988
|
-
ok: true,
|
|
2989
|
-
domain,
|
|
2990
|
-
httpStatus: res.status,
|
|
2991
|
-
...optionalString("status", pickString(body, "status")),
|
|
2992
|
-
...typeof body.services_count === "number" ? { servicesCount: body.services_count } : {}
|
|
2993
|
-
};
|
|
2994
|
-
} catch (err) {
|
|
2995
|
-
return { ok: false, domain, detail: errMsg(err) };
|
|
2996
|
-
}
|
|
2997
|
-
}
|
|
2998
|
-
async function readSiwxInfo(res) {
|
|
2999
|
-
try {
|
|
3000
|
-
const body = await res.json();
|
|
3001
|
-
const ext = body.extensions;
|
|
3002
|
-
const siwx = _optionalChain([ext, 'optionalAccess', _23 => _23["sign-in-with-x"]]);
|
|
3003
|
-
const info = _nullishCoalesce(_optionalChain([siwx, 'optionalAccess', _24 => _24.info]), () => ( siwx));
|
|
3004
|
-
if (info && info.chainId == null && Array.isArray(_optionalChain([siwx, 'optionalAccess', _25 => _25.supportedChains]))) {
|
|
3005
|
-
const evm = siwx.supportedChains.find(
|
|
3006
|
-
(c) => typeof _optionalChain([c, 'optionalAccess', _26 => _26.chainId]) === "string" && c.chainId.startsWith("eip155:")
|
|
3007
|
-
);
|
|
3008
|
-
if (evm && typeof evm.chainId === "string") info.chainId = evm.chainId;
|
|
3009
|
-
}
|
|
3010
|
-
if (info && typeof info.domain === "string" && info.domain.length > 0 && typeof info.nonce === "string" && info.nonce.length > 0 && typeof info.uri === "string" && info.uri.length > 0) {
|
|
3011
|
-
return info;
|
|
3012
|
-
}
|
|
3013
|
-
return null;
|
|
3014
|
-
} catch (e28) {
|
|
3015
|
-
return null;
|
|
3016
|
-
}
|
|
3017
|
-
}
|
|
3018
|
-
function formatSiweMessage(info, address) {
|
|
3019
|
-
const chainId = info.chainId ? caip2ToChainId(info.chainId) : 1;
|
|
3020
|
-
const statement = info.statement && info.statement.trim() ? info.statement : void 0;
|
|
3021
|
-
const lines = [
|
|
3022
|
-
`${info.domain} wants you to sign in with your Ethereum account:`,
|
|
3023
|
-
address,
|
|
3024
|
-
"",
|
|
3025
|
-
...statement ? [statement, ""] : [""],
|
|
3026
|
-
`URI: ${info.uri}`,
|
|
3027
|
-
"Version: 1",
|
|
3028
|
-
`Chain ID: ${chainId}`,
|
|
3029
|
-
`Nonce: ${info.nonce}`,
|
|
3030
|
-
`Issued At: ${info.issuedAt}`,
|
|
3031
|
-
...info.expirationTime ? [`Expiration Time: ${info.expirationTime}`] : []
|
|
3032
|
-
];
|
|
3033
|
-
return lines.join("\n");
|
|
3034
|
-
}
|
|
3035
|
-
function caip2ToChainId(caip2) {
|
|
3036
|
-
const m = /^eip155:(\d+)$/.exec(caip2);
|
|
3037
|
-
const n = m ? Number(m[1]) : Number(caip2);
|
|
3038
|
-
return Number.isSafeInteger(n) && n > 0 ? n : 1;
|
|
3039
|
-
}
|
|
3040
|
-
function mapRails(accepts) {
|
|
3041
|
-
if (!Array.isArray(accepts)) return [];
|
|
3042
|
-
const out = [];
|
|
3043
|
-
for (const raw of accepts) {
|
|
3044
|
-
if (!raw || typeof raw !== "object") continue;
|
|
3045
|
-
const a = raw;
|
|
3046
|
-
const network = pickString(a, "network");
|
|
3047
|
-
if (!network) continue;
|
|
3048
|
-
const extra = a.extra && typeof a.extra === "object" ? a.extra : {};
|
|
3049
|
-
out.push({
|
|
3050
|
-
scheme: _nullishCoalesce(pickString(a, "scheme"), () => ( "exact")),
|
|
3051
|
-
network,
|
|
3052
|
-
...optionalString("asset", pickString(a, "asset")),
|
|
3053
|
-
...optionalString("amount", pickString(a, "amount", "maxAmountRequired")),
|
|
3054
|
-
...optionalString("payTo", pickString(a, "payTo")),
|
|
3055
|
-
...optionalString("symbol", pickString(extra, "symbol"))
|
|
3056
|
-
});
|
|
3057
|
-
}
|
|
3058
|
-
return out;
|
|
3059
|
-
}
|
|
3060
|
-
function matchesQuery(r, query) {
|
|
3061
|
-
const haystack = [r.name, r.description, r.category, (_nullishCoalesce(r.tags, () => ( []))).join(" "), r.resource].filter(Boolean).join(" ").toLowerCase();
|
|
3062
|
-
if (haystack.includes(query.toLowerCase())) return true;
|
|
3063
|
-
const qTokens = tokenize(query);
|
|
3064
|
-
const hayTokens = new Set(tokenize(haystack));
|
|
3065
|
-
return qTokens.some((t) => hayTokens.has(t));
|
|
3066
|
-
}
|
|
3067
|
-
function pickStringArray(o, ...keys) {
|
|
3068
|
-
for (const k of keys) {
|
|
3069
|
-
const v = o[k];
|
|
3070
|
-
if (Array.isArray(v)) {
|
|
3071
|
-
const arr = v.filter((x) => typeof x === "string" && x.length > 0);
|
|
3072
|
-
if (arr.length) return arr;
|
|
3073
|
-
} else if (typeof v === "string" && v.trim()) {
|
|
3074
|
-
const arr = v.split(/[,\s]+/).filter((x) => x.length > 0);
|
|
3075
|
-
if (arr.length) return arr;
|
|
3076
|
-
}
|
|
3077
|
-
}
|
|
3078
|
-
return void 0;
|
|
3079
|
-
}
|
|
3080
|
-
function pickString(o, ...keys) {
|
|
3081
|
-
for (const k of keys) {
|
|
3082
|
-
const v = o[k];
|
|
3083
|
-
if (typeof v === "string" && v.length > 0) return v;
|
|
3084
|
-
}
|
|
3085
|
-
return void 0;
|
|
3086
|
-
}
|
|
3087
|
-
function pickNumber(o, ...keys) {
|
|
3088
|
-
for (const k of keys) {
|
|
3089
|
-
const v = o[k];
|
|
3090
|
-
if (typeof v === "number" && Number.isFinite(v)) return v;
|
|
3091
|
-
if (typeof v === "string" && /^\d+(\.\d+)?$/.test(v.trim())) {
|
|
3092
|
-
const n = Number(v.trim());
|
|
3093
|
-
if (Number.isFinite(n)) return n;
|
|
3094
|
-
}
|
|
3095
|
-
}
|
|
3096
|
-
return void 0;
|
|
3097
|
-
}
|
|
3098
|
-
function optionalString(field, value) {
|
|
3099
|
-
return value !== void 0 ? { [field]: value } : {};
|
|
3100
|
-
}
|
|
3101
|
-
function firstArray(o, ...keys) {
|
|
3102
|
-
for (const k of keys) {
|
|
3103
|
-
if (Array.isArray(o[k])) return o[k];
|
|
3104
|
-
}
|
|
3105
|
-
return Array.isArray(o) ? o : [];
|
|
3106
|
-
}
|
|
3107
|
-
function hostOf(url) {
|
|
3108
|
-
try {
|
|
3109
|
-
const withScheme = /^[a-z][a-z0-9+.-]*:\/\//i.test(url) ? url : `https://${url}`;
|
|
3110
|
-
return new URL(withScheme).hostname || url;
|
|
3111
|
-
} catch (e29) {
|
|
3112
|
-
return url;
|
|
3113
|
-
}
|
|
3114
|
-
}
|
|
3115
|
-
function errMsg(err) {
|
|
3116
|
-
return err instanceof Error ? err.message : String(err);
|
|
3117
|
-
}
|
|
3118
|
-
var REGISTER_ATTRIBUTION = "\xB7 Built with @piprail/sdk";
|
|
3119
|
-
function appendAttribution(description) {
|
|
3120
|
-
if (!description) return description;
|
|
3121
|
-
if (/piprail/i.test(description)) return description;
|
|
3122
|
-
const next = `${description.trimEnd()} ${REGISTER_ATTRIBUTION}`;
|
|
3123
|
-
return next.length <= 500 ? next : description;
|
|
3124
|
-
}
|
|
3125
|
-
function appendKeywords(description, tags) {
|
|
3126
|
-
const clean = (_nullishCoalesce(tags, () => ( []))).map((t) => t.trim()).filter((t) => t.length > 0);
|
|
3127
|
-
if (clean.length === 0) return description;
|
|
3128
|
-
const have = (_nullishCoalesce(description, () => ( ""))).toLowerCase();
|
|
3129
|
-
const fresh = [...new Set(clean.filter((t) => !have.includes(t.toLowerCase())))];
|
|
3130
|
-
if (fresh.length === 0) return description;
|
|
3131
|
-
const tail = `Keywords: ${fresh.join(", ")}`;
|
|
3132
|
-
if (!description) return tail;
|
|
3133
|
-
const next = `${description.trimEnd()} \xB7 ${tail}`;
|
|
3134
|
-
return next.length <= 500 ? next : description;
|
|
3135
|
-
}
|
|
3136
|
-
function encodeBase642(str) {
|
|
3137
|
-
if (typeof Buffer !== "undefined") return Buffer.from(str, "utf8").toString("base64");
|
|
3138
|
-
if (typeof btoa === "function" && typeof TextEncoder !== "undefined") {
|
|
3139
|
-
const bytes = new TextEncoder().encode(str);
|
|
3140
|
-
let binary = "";
|
|
3141
|
-
for (let i = 0; i < bytes.length; i++) binary += String.fromCharCode(bytes[i]);
|
|
3142
|
-
return btoa(binary);
|
|
3143
|
-
}
|
|
3144
|
-
throw new Error("No base64 encoder available in this runtime.");
|
|
3145
|
-
}
|
|
3146
|
-
|
|
3147
2269
|
// src/policy.ts
|
|
3148
2270
|
var DENOM_PRECISION = _chunkQONQSZHJcjs.MAX_DECIMALS;
|
|
3149
2271
|
var BUILTIN_DENOMS = {
|
|
@@ -3159,7 +2281,7 @@ var BUILTIN_DENOMS = {
|
|
|
3159
2281
|
function denomOf(symbol, asset, policy) {
|
|
3160
2282
|
if (asset === "native") return void 0;
|
|
3161
2283
|
const norm = (v) => typeof v === "string" && v.trim() !== "" ? v.trim().toUpperCase() : void 0;
|
|
3162
|
-
const override = _optionalChain([policy, 'optionalAccess',
|
|
2284
|
+
const override = _optionalChain([policy, 'optionalAccess', _22 => _22.denomFor]);
|
|
3163
2285
|
if (override && typeof override === "object") {
|
|
3164
2286
|
if (asset && asset in override) {
|
|
3165
2287
|
const d = norm(override[asset]);
|
|
@@ -3357,10 +2479,10 @@ var SpendLedger = (_class = class {
|
|
|
3357
2479
|
let seed = [];
|
|
3358
2480
|
try {
|
|
3359
2481
|
seed = _nullishCoalesce(store.load(), () => ( []));
|
|
3360
|
-
} catch (
|
|
2482
|
+
} catch (e23) {
|
|
3361
2483
|
seed = [];
|
|
3362
2484
|
}
|
|
3363
|
-
for (const r of seed) this.ingest(r, _nullishCoalesce(_optionalChain([r, 'optionalAccess',
|
|
2485
|
+
for (const r of seed) this.ingest(r, _nullishCoalesce(_optionalChain([r, 'optionalAccess', _23 => _23.decimals]), () => ( 0)), _optionalChain([r, 'optionalAccess', _24 => _24.denom]));
|
|
3364
2486
|
}
|
|
3365
2487
|
}
|
|
3366
2488
|
/**
|
|
@@ -3416,13 +2538,13 @@ var SpendLedger = (_class = class {
|
|
|
3416
2538
|
if (rec && this.store) {
|
|
3417
2539
|
try {
|
|
3418
2540
|
this.store.append(rec);
|
|
3419
|
-
} catch (
|
|
2541
|
+
} catch (e24) {
|
|
3420
2542
|
}
|
|
3421
2543
|
}
|
|
3422
2544
|
}
|
|
3423
2545
|
/** Running total (base units) already spent on this (network, asset). */
|
|
3424
2546
|
totalFor(network, asset) {
|
|
3425
|
-
return _nullishCoalesce(_optionalChain([this, 'access',
|
|
2547
|
+
return _nullishCoalesce(_optionalChain([this, 'access', _25 => _25.buckets, 'access', _26 => _26.get, 'call', _27 => _27(keyFor(network, asset)), 'optionalAccess', _28 => _28.total]), () => ( 0n));
|
|
3426
2548
|
}
|
|
3427
2549
|
/**
|
|
3428
2550
|
* Running grand total for a DENOMINATION, scaled to {@link DENOM_PRECISION} (so
|
|
@@ -3516,7 +2638,7 @@ var SpendLedger = (_class = class {
|
|
|
3516
2638
|
denom,
|
|
3517
2639
|
totalScaled: scaled.toString(),
|
|
3518
2640
|
totalFormatted: _chunkQONQSZHJcjs.formatUnits.call(void 0, scaled, DENOM_PRECISION),
|
|
3519
|
-
count: this.records.filter((r) => _optionalChain([r, 'access',
|
|
2641
|
+
count: this.records.filter((r) => _optionalChain([r, 'access', _29 => _29.denom, 'optionalAccess', _30 => _30.toUpperCase, 'call', _31 => _31()]) === denom).length
|
|
3520
2642
|
})),
|
|
3521
2643
|
records: [...this.records]
|
|
3522
2644
|
};
|
|
@@ -3713,7 +2835,7 @@ var PipRailClient = (_class2 = class {
|
|
|
3713
2835
|
safeEmit(event) {
|
|
3714
2836
|
try {
|
|
3715
2837
|
this.onEvent(event);
|
|
3716
|
-
} catch (
|
|
2838
|
+
} catch (e25) {
|
|
3717
2839
|
}
|
|
3718
2840
|
}
|
|
3719
2841
|
/**
|
|
@@ -3724,9 +2846,9 @@ var PipRailClient = (_class2 = class {
|
|
|
3724
2846
|
*/
|
|
3725
2847
|
captureReceipt(response, url) {
|
|
3726
2848
|
try {
|
|
3727
|
-
const parsed = parseReceiptExtension(response);
|
|
2849
|
+
const parsed = _chunkOXEFPLZAcjs.parseReceiptExtension.call(void 0, response);
|
|
3728
2850
|
this.lastReceiptValue = parsed ? { ...parsed, resource: { url } } : null;
|
|
3729
|
-
} catch (
|
|
2851
|
+
} catch (e26) {
|
|
3730
2852
|
this.lastReceiptValue = null;
|
|
3731
2853
|
}
|
|
3732
2854
|
}
|
|
@@ -3752,17 +2874,17 @@ var PipRailClient = (_class2 = class {
|
|
|
3752
2874
|
* {@link ReceiptVerification}).
|
|
3753
2875
|
*/
|
|
3754
2876
|
static async verifyReceipt(receipt, opts) {
|
|
3755
|
-
const r = _optionalChain([receipt, 'optionalAccess',
|
|
2877
|
+
const r = _optionalChain([receipt, 'optionalAccess', _32 => _32.receipt]);
|
|
3756
2878
|
if (!r || typeof r !== "object") {
|
|
3757
2879
|
return { ok: false, onChain: { payTo: "", asset: "", amount: "", payer: "" }, matchesClaims: false, ageSeconds: 0, error: "tx_not_found" };
|
|
3758
2880
|
}
|
|
3759
2881
|
const claimed = { payTo: _nullishCoalesce(r.payTo, () => ( "")), asset: _nullishCoalesce(r.asset, () => ( "")), amount: _nullishCoalesce(r.amount, () => ( "")), payer: _nullishCoalesce(r.payer, () => ( "")) };
|
|
3760
2882
|
const ageSeconds = receiptAgeSeconds(r.verifiedAt);
|
|
3761
2883
|
try {
|
|
3762
|
-
const chain = chainSelectorForNetwork(r.network, _optionalChain([opts, 'optionalAccess',
|
|
2884
|
+
const chain = chainSelectorForNetwork(r.network, _optionalChain([opts, 'optionalAccess', _33 => _33.rpcUrl]));
|
|
3763
2885
|
const net = await resolveNetwork2({
|
|
3764
2886
|
chain,
|
|
3765
|
-
..._optionalChain([opts, 'optionalAccess',
|
|
2887
|
+
..._optionalChain([opts, 'optionalAccess', _34 => _34.rpcUrl]) ? { rpcUrl: opts.rpcUrl } : {}
|
|
3766
2888
|
});
|
|
3767
2889
|
const accept = {
|
|
3768
2890
|
scheme: "onchain-proof",
|
|
@@ -3789,7 +2911,7 @@ var PipRailClient = (_class2 = class {
|
|
|
3789
2911
|
const onChain = { payTo: oc.payTo, asset: oc.asset, amount: oc.amount, payer: oc.payer };
|
|
3790
2912
|
const matchesClaims = sameAddress(oc.payer, r.payer);
|
|
3791
2913
|
return { ok: true, onChain, matchesClaims, ageSeconds };
|
|
3792
|
-
} catch (
|
|
2914
|
+
} catch (e27) {
|
|
3793
2915
|
return { ok: false, onChain: claimed, matchesClaims: false, ageSeconds, error: "tx_not_found" };
|
|
3794
2916
|
}
|
|
3795
2917
|
}
|
|
@@ -3809,7 +2931,7 @@ var PipRailClient = (_class2 = class {
|
|
|
3809
2931
|
* no chain libs. The JWS format defers to R3 (`{ ok:false, reason:'jws-not-loaded' }`).
|
|
3810
2932
|
*/
|
|
3811
2933
|
static async verifyAttestation(receipt) {
|
|
3812
|
-
const att = _optionalChain([receipt, 'optionalAccess',
|
|
2934
|
+
const att = _optionalChain([receipt, 'optionalAccess', _35 => _35.attestation]);
|
|
3813
2935
|
if (!att || typeof att !== "object" || typeof att.signature !== "string") {
|
|
3814
2936
|
return { ok: false, reason: "no-attestation" };
|
|
3815
2937
|
}
|
|
@@ -3820,7 +2942,7 @@ var PipRailClient = (_class2 = class {
|
|
|
3820
2942
|
if (!r || typeof r !== "object") return { ok: false, reason: "no-receipt" };
|
|
3821
2943
|
const payload = _nullishCoalesce(att.payload, () => ( {}));
|
|
3822
2944
|
const network = typeof payload.network === "string" ? payload.network : r.network;
|
|
3823
|
-
const resourceUrl = typeof payload.resourceUrl === "string" ? payload.resourceUrl : _nullishCoalesce(_optionalChain([receipt, 'access',
|
|
2945
|
+
const resourceUrl = typeof payload.resourceUrl === "string" ? payload.resourceUrl : _nullishCoalesce(_optionalChain([receipt, 'access', _36 => _36.resource, 'optionalAccess', _37 => _37.url]), () => ( ""));
|
|
3824
2946
|
const payer = typeof payload.payer === "string" ? payload.payer : r.payer;
|
|
3825
2947
|
const issuedAt = typeof payload.issuedAt === "number" ? payload.issuedAt : receiptIssuedAtSeconds(r.verifiedAt);
|
|
3826
2948
|
const transaction = typeof payload.transaction === "string" ? payload.transaction : _nullishCoalesce(r.transaction, () => ( ""));
|
|
@@ -3835,7 +2957,7 @@ var PipRailClient = (_class2 = class {
|
|
|
3835
2957
|
transaction,
|
|
3836
2958
|
signature: att.signature
|
|
3837
2959
|
});
|
|
3838
|
-
} catch (
|
|
2960
|
+
} catch (e28) {
|
|
3839
2961
|
return { ok: false, reason: "verify-failed" };
|
|
3840
2962
|
}
|
|
3841
2963
|
}
|
|
@@ -3866,7 +2988,7 @@ var PipRailClient = (_class2 = class {
|
|
|
3866
2988
|
* as-is) or a plain object (serialised as JSON).
|
|
3867
2989
|
*/
|
|
3868
2990
|
post(url, body, init) {
|
|
3869
|
-
const headers = new Headers(_optionalChain([init, 'optionalAccess',
|
|
2991
|
+
const headers = new Headers(_optionalChain([init, 'optionalAccess', _38 => _38.headers]));
|
|
3870
2992
|
let payload;
|
|
3871
2993
|
if (body === void 0 || body === null) {
|
|
3872
2994
|
payload = void 0;
|
|
@@ -3897,7 +3019,7 @@ var PipRailClient = (_class2 = class {
|
|
|
3897
3019
|
* "0.05 USDC on Base, within budget → pay it." No funds move.
|
|
3898
3020
|
*/
|
|
3899
3021
|
async quote(url, init) {
|
|
3900
|
-
const res = await fetch(url, { ..._nullishCoalesce(init, () => ( {})), method: _nullishCoalesce(_optionalChain([init, 'optionalAccess',
|
|
3022
|
+
const res = await fetch(url, { ..._nullishCoalesce(init, () => ( {})), method: _nullishCoalesce(_optionalChain([init, 'optionalAccess', _39 => _39.method]), () => ( "GET")) });
|
|
3901
3023
|
if (res.status !== 402) return null;
|
|
3902
3024
|
const { quote } = await this.resolveChallenge(url, res, this.resolveSchemes());
|
|
3903
3025
|
return quote;
|
|
@@ -3916,7 +3038,7 @@ var PipRailClient = (_class2 = class {
|
|
|
3916
3038
|
* on Tron, where a USD₮ transfer can cost real TRX.
|
|
3917
3039
|
*/
|
|
3918
3040
|
async estimateCost(url, init) {
|
|
3919
|
-
const res = await fetch(url, { ..._nullishCoalesce(init, () => ( {})), method: _nullishCoalesce(_optionalChain([init, 'optionalAccess',
|
|
3041
|
+
const res = await fetch(url, { ..._nullishCoalesce(init, () => ( {})), method: _nullishCoalesce(_optionalChain([init, 'optionalAccess', _40 => _40.method]), () => ( "GET")) });
|
|
3920
3042
|
if (res.status !== 402) return null;
|
|
3921
3043
|
try {
|
|
3922
3044
|
const { net, accept, quote } = await this.resolveChallenge(url, res, this.resolveSchemes());
|
|
@@ -3954,8 +3076,8 @@ var PipRailClient = (_class2 = class {
|
|
|
3954
3076
|
return {
|
|
3955
3077
|
session: {
|
|
3956
3078
|
start,
|
|
3957
|
-
expiresAt: _optionalChain([view, 'optionalAccess',
|
|
3958
|
-
secondsRemaining: _nullishCoalesce(_optionalChain([view, 'optionalAccess',
|
|
3079
|
+
expiresAt: _optionalChain([view, 'optionalAccess', _41 => _41.expiresAt]) != null ? new Date(view.expiresAt).toISOString() : null,
|
|
3080
|
+
secondsRemaining: _nullishCoalesce(_optionalChain([view, 'optionalAccess', _42 => _42.secondsRemaining]), () => ( null))
|
|
3959
3081
|
},
|
|
3960
3082
|
byAsset: this.remaining(),
|
|
3961
3083
|
byDenom: this.denomRemaining(),
|
|
@@ -3970,7 +3092,7 @@ var PipRailClient = (_class2 = class {
|
|
|
3970
3092
|
* price-converted figure (tokens grouped as one unit, each 1:1).
|
|
3971
3093
|
*/
|
|
3972
3094
|
denomRemaining() {
|
|
3973
|
-
const caps = _optionalChain([this, 'access',
|
|
3095
|
+
const caps = _optionalChain([this, 'access', _43 => _43.opts, 'access', _44 => _44.policy, 'optionalAccess', _45 => _45.maxTotalPerDenom]);
|
|
3974
3096
|
if (!caps) return [];
|
|
3975
3097
|
return Object.entries(caps).map(([rawDenom, capStr]) => {
|
|
3976
3098
|
const denom = rawDenom.toUpperCase();
|
|
@@ -3993,11 +3115,11 @@ var PipRailClient = (_class2 = class {
|
|
|
3993
3115
|
const policy = this.opts.policy;
|
|
3994
3116
|
const settled = this.ledger.count();
|
|
3995
3117
|
const out = { settled };
|
|
3996
|
-
if (_optionalChain([policy, 'optionalAccess',
|
|
3118
|
+
if (_optionalChain([policy, 'optionalAccess', _46 => _46.maxPayments]) !== void 0) {
|
|
3997
3119
|
out.lifetimeCap = policy.maxPayments;
|
|
3998
3120
|
out.lifetimeRemaining = Math.max(0, policy.maxPayments - settled);
|
|
3999
3121
|
}
|
|
4000
|
-
if (_optionalChain([policy, 'optionalAccess',
|
|
3122
|
+
if (_optionalChain([policy, 'optionalAccess', _47 => _47.maxPaymentsPerWindow]) !== void 0 && policy.windowSeconds !== void 0) {
|
|
4001
3123
|
const windowSettled = this.ledger.countSince(Date.now() - policy.windowSeconds * 1e3);
|
|
4002
3124
|
out.windowCap = policy.maxPaymentsPerWindow;
|
|
4003
3125
|
out.windowSettled = windowSettled;
|
|
@@ -4013,7 +3135,7 @@ var PipRailClient = (_class2 = class {
|
|
|
4013
3135
|
* never throws, never sums across tokens (no price oracle). PROCESS-SCOPED.
|
|
4014
3136
|
*/
|
|
4015
3137
|
remaining() {
|
|
4016
|
-
const maxTotal = _optionalChain([this, 'access',
|
|
3138
|
+
const maxTotal = _optionalChain([this, 'access', _48 => _48.opts, 'access', _49 => _49.policy, 'optionalAccess', _50 => _50.maxTotal]);
|
|
4017
3139
|
return this.ledger.assetBuckets().map((b) => {
|
|
4018
3140
|
const base2 = {
|
|
4019
3141
|
network: b.network,
|
|
@@ -4065,9 +3187,9 @@ var PipRailClient = (_class2 = class {
|
|
|
4065
3187
|
* the plan yourself. No funds move.
|
|
4066
3188
|
*/
|
|
4067
3189
|
async planPayment(url, init) {
|
|
4068
|
-
const res = await fetch(url, { ..._nullishCoalesce(init, () => ( {})), method: _nullishCoalesce(_optionalChain([init, 'optionalAccess',
|
|
3190
|
+
const res = await fetch(url, { ..._nullishCoalesce(init, () => ( {})), method: _nullishCoalesce(_optionalChain([init, 'optionalAccess', _51 => _51.method]), () => ( "GET")) });
|
|
4069
3191
|
if (res.status !== 402) return null;
|
|
4070
|
-
const challenge = await parseChallenge(res);
|
|
3192
|
+
const challenge = await _chunkOXEFPLZAcjs.parseChallenge.call(void 0, res);
|
|
4071
3193
|
if (!challenge) {
|
|
4072
3194
|
throw new (0, _chunkQONQSZHJcjs.InvalidEnvelopeError)("402 response did not include a parseable x402 challenge.");
|
|
4073
3195
|
}
|
|
@@ -4107,10 +3229,10 @@ var PipRailClient = (_class2 = class {
|
|
|
4107
3229
|
* - Results are cross-scheme (mostly the mainstream `exact` scheme); `fetch()` pays
|
|
4108
3230
|
* `onchain-proof` rails by default, and standard `exact` rails too once you opt in
|
|
4109
3231
|
* with `schemes: ['onchain-proof', 'exact']` (EVM EIP-3009/Permit2 + Solana SVM + Algorand
|
|
4110
|
-
* + Aptos + NEAR).
|
|
3232
|
+
* + Aptos + NEAR + XRPL native XRP).
|
|
4111
3233
|
*/
|
|
4112
3234
|
async discover(opts = {}) {
|
|
4113
|
-
const found = await searchOpenIndexes({
|
|
3235
|
+
const found = await _chunkV2IJ5HUWcjs.searchOpenIndexes.call(void 0, {
|
|
4114
3236
|
...opts.query !== void 0 ? { query: opts.query } : {},
|
|
4115
3237
|
...opts.sources ? { sources: opts.sources } : {},
|
|
4116
3238
|
...opts.limit !== void 0 ? { limit: opts.limit } : {},
|
|
@@ -4129,7 +3251,7 @@ var PipRailClient = (_class2 = class {
|
|
|
4129
3251
|
const { net } = await this.ensure();
|
|
4130
3252
|
return found.filter((r) => r.rails.some((rail) => railOnNetwork(rail, (n) => net.supports(n))));
|
|
4131
3253
|
}
|
|
4132
|
-
const target = normalizeNetwork(scope);
|
|
3254
|
+
const target = _chunkV2IJ5HUWcjs.normalizeNetwork.call(void 0, scope);
|
|
4133
3255
|
return found.filter((r) => r.rails.some((rail) => railOnNetwork(rail, (n) => n === target)));
|
|
4134
3256
|
}
|
|
4135
3257
|
/**
|
|
@@ -4163,7 +3285,7 @@ var PipRailClient = (_class2 = class {
|
|
|
4163
3285
|
for (const target of targets) {
|
|
4164
3286
|
if (target === "402index") {
|
|
4165
3287
|
outcomes.push(
|
|
4166
|
-
await register402Index({
|
|
3288
|
+
await _chunkV2IJ5HUWcjs.register402Index.call(void 0, {
|
|
4167
3289
|
url,
|
|
4168
3290
|
...opts.name ? { name: opts.name } : {},
|
|
4169
3291
|
...opts.description ? { description: opts.description } : {},
|
|
@@ -4190,7 +3312,7 @@ var PipRailClient = (_class2 = class {
|
|
|
4190
3312
|
});
|
|
4191
3313
|
continue;
|
|
4192
3314
|
}
|
|
4193
|
-
outcomes.push(await registerX402Scan({ url }, signer));
|
|
3315
|
+
outcomes.push(await _chunkV2IJ5HUWcjs.registerX402Scan.call(void 0, { url }, signer));
|
|
4194
3316
|
} else {
|
|
4195
3317
|
outcomes.push({
|
|
4196
3318
|
source: "bazaar",
|
|
@@ -4199,7 +3321,7 @@ var PipRailClient = (_class2 = class {
|
|
|
4199
3321
|
});
|
|
4200
3322
|
}
|
|
4201
3323
|
}
|
|
4202
|
-
return outcomes.map(decorateOutcome);
|
|
3324
|
+
return outcomes.map(_chunkV2IJ5HUWcjs.decorateOutcome);
|
|
4203
3325
|
}
|
|
4204
3326
|
/**
|
|
4205
3327
|
* **402 Index domain verification, step 1 of 2.** A self-registered 402 Index
|
|
@@ -4216,7 +3338,7 @@ var PipRailClient = (_class2 = class {
|
|
|
4216
3338
|
* ```
|
|
4217
3339
|
*/
|
|
4218
3340
|
async claimDomain(urlOrDomain, opts = {}) {
|
|
4219
|
-
return claim402IndexDomain(urlOrDomain, opts);
|
|
3341
|
+
return _chunkV2IJ5HUWcjs.claim402IndexDomain.call(void 0, urlOrDomain, opts);
|
|
4220
3342
|
}
|
|
4221
3343
|
/**
|
|
4222
3344
|
* **402 Index domain verification, step 2 of 2.** After {@link claimDomain} and
|
|
@@ -4225,7 +3347,7 @@ var PipRailClient = (_class2 = class {
|
|
|
4225
3347
|
* (`{ ok:true, status:'verified', servicesCount }`). Moves no funds; never throws.
|
|
4226
3348
|
*/
|
|
4227
3349
|
async verifyDomain(urlOrDomain) {
|
|
4228
|
-
return verify402IndexDomain(urlOrDomain);
|
|
3350
|
+
return _chunkV2IJ5HUWcjs.verify402IndexDomain.call(void 0, urlOrDomain);
|
|
4229
3351
|
}
|
|
4230
3352
|
/**
|
|
4231
3353
|
* The discovery signer for the bound wallet (its address + a message signer),
|
|
@@ -4247,7 +3369,7 @@ var PipRailClient = (_class2 = class {
|
|
|
4247
3369
|
* streams throw `NonReplayableBodyError`.
|
|
4248
3370
|
*/
|
|
4249
3371
|
async fetch(url, init) {
|
|
4250
|
-
const body = _optionalChain([init, 'optionalAccess',
|
|
3372
|
+
const body = _optionalChain([init, 'optionalAccess', _52 => _52.body]);
|
|
4251
3373
|
if (body !== void 0 && body !== null && !isReplayableBodyInit(body)) {
|
|
4252
3374
|
throw new (0, _chunkQONQSZHJcjs.NonReplayableBodyError)(
|
|
4253
3375
|
"fetch(): init.body is not replayable. Pass a string, FormData, URLSearchParams, ArrayBuffer, or Blob \u2014 not a ReadableStream."
|
|
@@ -4255,7 +3377,7 @@ var PipRailClient = (_class2 = class {
|
|
|
4255
3377
|
}
|
|
4256
3378
|
const firstResponse = await fetch(url, init);
|
|
4257
3379
|
if (firstResponse.status !== 402) return firstResponse;
|
|
4258
|
-
const schemes = this.resolveSchemes(_optionalChain([init, 'optionalAccess',
|
|
3380
|
+
const schemes = this.resolveSchemes(_optionalChain([init, 'optionalAccess', _53 => _53.schemes]));
|
|
4259
3381
|
const resolved = await this.resolveChallenge(url, firstResponse, schemes);
|
|
4260
3382
|
const { net, wallet, challenge } = resolved;
|
|
4261
3383
|
if (!wallet) {
|
|
@@ -4265,7 +3387,7 @@ var PipRailClient = (_class2 = class {
|
|
|
4265
3387
|
}
|
|
4266
3388
|
let accept = resolved.accept;
|
|
4267
3389
|
let quote = resolved.quote;
|
|
4268
|
-
const autoRoute = _nullishCoalesce(_nullishCoalesce(_optionalChain([init, 'optionalAccess',
|
|
3390
|
+
const autoRoute = _nullishCoalesce(_nullishCoalesce(_optionalChain([init, 'optionalAccess', _54 => _54.autoRoute]), () => ( this.opts.autoRoute)), () => ( false));
|
|
4269
3391
|
if (autoRoute) {
|
|
4270
3392
|
const plan = await this.planFromChallenge(net, wallet, challenge, url, schemes);
|
|
4271
3393
|
if (!plan.best) {
|
|
@@ -4282,7 +3404,7 @@ var PipRailClient = (_class2 = class {
|
|
|
4282
3404
|
return this.payUptoRail(net, wallet, accept, url, init, quote);
|
|
4283
3405
|
}
|
|
4284
3406
|
if (accept.scheme === "exact") {
|
|
4285
|
-
return this.payExactRail(net, wallet, accept, url, init, quote);
|
|
3407
|
+
return this.payExactRail(net, wallet, accept, url, init, quote, challenge.x402Version);
|
|
4286
3408
|
}
|
|
4287
3409
|
if (accept.scheme !== "onchain-proof") {
|
|
4288
3410
|
throw new (0, _chunkQONQSZHJcjs.UnsupportedSchemeError)(
|
|
@@ -4301,7 +3423,7 @@ var PipRailClient = (_class2 = class {
|
|
|
4301
3423
|
* `quote()` (read-only) and `fetch()` (which then authorises + pays).
|
|
4302
3424
|
*/
|
|
4303
3425
|
async resolveChallenge(url, response, schemes) {
|
|
4304
|
-
const challenge = await parseChallenge(response);
|
|
3426
|
+
const challenge = await _chunkOXEFPLZAcjs.parseChallenge.call(void 0, response);
|
|
4305
3427
|
if (!challenge) {
|
|
4306
3428
|
throw new (0, _chunkQONQSZHJcjs.InvalidEnvelopeError)(
|
|
4307
3429
|
"402 response did not include a parseable x402 challenge."
|
|
@@ -4349,7 +3471,7 @@ var PipRailClient = (_class2 = class {
|
|
|
4349
3471
|
* newly matchable (an unknown slug stays unresolved → still unmatched; a different
|
|
4350
3472
|
* chain's slug resolves elsewhere → still unmatched). */
|
|
4351
3473
|
supportsNetwork(net, network) {
|
|
4352
|
-
return net.supports(normalizeNetwork(network));
|
|
3474
|
+
return net.supports(_chunkV2IJ5HUWcjs.normalizeNetwork.call(void 0, network));
|
|
4353
3475
|
}
|
|
4354
3476
|
/** The candidate accepts this client could pay, on the bound network. Always the
|
|
4355
3477
|
* backendless `onchain-proof` rails; PLUS standard `exact` rails when `schemes`
|
|
@@ -4368,15 +3490,35 @@ var PipRailClient = (_class2 = class {
|
|
|
4368
3490
|
if (schemes.includes("exact")) {
|
|
4369
3491
|
out.push(
|
|
4370
3492
|
...challenge.accepts.filter(
|
|
4371
|
-
(a) => a.scheme === "exact" && this.supportsNetwork(net, a.network) && typeof net.payExact === "function" &&
|
|
4372
|
-
|
|
4373
|
-
|
|
4374
|
-
|
|
4375
|
-
|
|
4376
|
-
|
|
4377
|
-
|
|
4378
|
-
|
|
4379
|
-
|
|
3493
|
+
(a) => a.scheme === "exact" && this.supportsNetwork(net, a.network) && typeof net.payExact === "function" && /*
|
|
3494
|
+
* Can this family sign an `exact` payment for THIS asset?
|
|
3495
|
+
*
|
|
3496
|
+
* The default — for every family that doesn't say otherwise — is "any recognised token
|
|
3497
|
+
* yes, the native coin no". `exact` is an EIP-3009/Permit2-style signed-authorization
|
|
3498
|
+
* scheme a native coin can't carry, and `describeAsset('native')` IS non-null
|
|
3499
|
+
* (onchain-proof needs it), so without the rule a 402 advertising a native exact rail
|
|
3500
|
+
* would gather, plan `payable`, even win autoRoute — then throw at pay time.
|
|
3501
|
+
*
|
|
3502
|
+
* XRPL is the first family to overturn it, in BOTH directions. There an `exact` payment
|
|
3503
|
+
* is simply a fully signed `Payment`, so native XRP is the most natural thing to send —
|
|
3504
|
+
* 863 of its 1,732 live rails are priced in XRP. Its ISSUED currencies are excluded
|
|
3505
|
+
* instead: they state a decimal `value` on the wire while the spend policy caps in base
|
|
3506
|
+
* units, so pricing one as base units would let a 12-RLUSD rail slip under any cap.
|
|
3507
|
+
* A driver that declares `exactPayableAsset` replaces this rule for all of its assets.
|
|
3508
|
+
*/
|
|
3509
|
+
(net.exactPayableAsset ? net.exactPayableAsset(a.asset) : a.asset !== "native") && /*
|
|
3510
|
+
* The rail's transfer method must be one a driver can sign — but an ABSENT method is
|
|
3511
|
+
* not an unknown one. `scheme_exact_evm.md`: "If no `assetTransferMethod` is specified
|
|
3512
|
+
* in `PaymentRequired.extra`, clients should default to `eip3009`", and the SVM /
|
|
3513
|
+
* Algorand / Aptos / NEAR / Hedera schemes never define the key at all. This predicate
|
|
3514
|
+
* previously REQUIRED the key, which rejected 91% of the deployed x402 web — every
|
|
3515
|
+
* Solana rail, every Arbitrum rail, 85% of Base — while the pay path had always
|
|
3516
|
+
* handled its absence correctly (the EVM driver defaults to eip3009 and re-derives the
|
|
3517
|
+
* EIP-712 domain on-chain). `isSettleableExactMethod` keeps the real guard: a rail that
|
|
3518
|
+
* NAMES a method we don't implement (the spec's `erc7710`) is still skipped, because
|
|
3519
|
+
* signing an EIP-3009 authorization for it would just be rejected by its facilitator.
|
|
3520
|
+
*/
|
|
3521
|
+
_chunkOXEFPLZAcjs.isSettleableExactMethod.call(void 0, a) && net.describeAsset(a.asset) != null && // a foreign rail's maxTimeoutSeconds must be a usable positive integer, or
|
|
4380
3522
|
// signing it would build a NaN/garbage validBefore — drop it silently
|
|
4381
3523
|
// (symmetric with an unrecognised token) rather than leak a raw SyntaxError.
|
|
4382
3524
|
Number.isInteger(a.maxTimeoutSeconds) && a.maxTimeoutSeconds > 0
|
|
@@ -4387,7 +3529,7 @@ var PipRailClient = (_class2 = class {
|
|
|
4387
3529
|
out.push(
|
|
4388
3530
|
...challenge.accepts.filter(
|
|
4389
3531
|
(a) => a.scheme === "upto" && this.supportsNetwork(net, a.network) && typeof net.payUpto === "function" && a.asset !== "native" && // native is not upto-payable either (same reason as exact)
|
|
4390
|
-
net.describeAsset(a.asset) != null && typeof _optionalChain([a, 'access',
|
|
3532
|
+
net.describeAsset(a.asset) != null && typeof _optionalChain([a, 'access', _55 => _55.extra, 'optionalAccess', _56 => _56.facilitatorAddress]) === "string" && a.extra.facilitatorAddress.length > 0 && Number.isInteger(a.maxTimeoutSeconds) && a.maxTimeoutSeconds > 0
|
|
4391
3533
|
)
|
|
4392
3534
|
);
|
|
4393
3535
|
}
|
|
@@ -4493,6 +3635,14 @@ var PipRailClient = (_class2 = class {
|
|
|
4493
3635
|
accept,
|
|
4494
3636
|
quote,
|
|
4495
3637
|
cost,
|
|
3638
|
+
// Surface the transfer method we INFERRED, not just the one the rail named — an absent
|
|
3639
|
+
// marker means the scheme's default, and saying so is how an agent (or a maintainer) sees
|
|
3640
|
+
// why a domain-only rail is payable and gasless. The default is PER FAMILY: a Solana rail
|
|
3641
|
+
// naming nothing means `svm`, never `eip3009`.
|
|
3642
|
+
...accept.scheme === "exact" ? {
|
|
3643
|
+
method: _optionalChain([accept, 'access', _57 => _57.extra, 'optionalAccess', _58 => _58.assetTransferMethod]) ? _chunkOXEFPLZAcjs.exactTransferMethod.call(void 0, accept) : `${_chunkOXEFPLZAcjs.exactTransferMethod.call(void 0, accept, net.family)} (default)`
|
|
3644
|
+
} : {},
|
|
3645
|
+
...accept.scheme === "upto" ? { method: "permit2-upto" } : {},
|
|
4496
3646
|
state,
|
|
4497
3647
|
blockers,
|
|
4498
3648
|
warnings,
|
|
@@ -4520,7 +3670,7 @@ var PipRailClient = (_class2 = class {
|
|
|
4520
3670
|
}
|
|
4521
3671
|
const amountBase = BigInt(accept.amount);
|
|
4522
3672
|
const described = net.describeAsset(accept.asset);
|
|
4523
|
-
const decimals = _nullishCoalesce(_optionalChain([described, 'optionalAccess',
|
|
3673
|
+
const decimals = _nullishCoalesce(_optionalChain([described, 'optionalAccess', _59 => _59.decimals]), () => ( _optionalChain([accept, 'access', _60 => _60.extra, 'optionalAccess', _61 => _61.decimals])));
|
|
4524
3674
|
if (typeof decimals !== "number" || !Number.isInteger(decimals) || decimals < 0) {
|
|
4525
3675
|
throw new (0, _chunkQONQSZHJcjs.InvalidEnvelopeError)(
|
|
4526
3676
|
`challenge for ${accept.asset} on ${accept.network} states no valid decimals and the SDK doesn't recognise the token \u2014 refusing to price it.`
|
|
@@ -4531,10 +3681,10 @@ var PipRailClient = (_class2 = class {
|
|
|
4531
3681
|
`challenge for ${accept.asset} on ${accept.network} states ${decimals} decimals (> ${_chunkQONQSZHJcjs.MAX_DECIMALS}) \u2014 refusing to price it (no real token is that deep).`
|
|
4532
3682
|
);
|
|
4533
3683
|
}
|
|
4534
|
-
const symbol = _nullishCoalesce(_optionalChain([described, 'optionalAccess',
|
|
3684
|
+
const symbol = _nullishCoalesce(_optionalChain([described, 'optionalAccess', _62 => _62.symbol]), () => ( _optionalChain([accept, 'access', _63 => _63.extra, 'optionalAccess', _64 => _64.symbol])));
|
|
4535
3685
|
const amountFormatted = _chunkQONQSZHJcjs.formatUnits.call(void 0, amountBase, decimals);
|
|
4536
3686
|
const intent = {
|
|
4537
|
-
host:
|
|
3687
|
+
host: hostOf(url),
|
|
4538
3688
|
chain: this.opts.chain,
|
|
4539
3689
|
network: accept.network,
|
|
4540
3690
|
asset: accept.asset,
|
|
@@ -4573,7 +3723,7 @@ var PipRailClient = (_class2 = class {
|
|
|
4573
3723
|
this.ledger.totalFor(accept.network, accept.asset),
|
|
4574
3724
|
ctx
|
|
4575
3725
|
);
|
|
4576
|
-
const serverSymbol = _optionalChain([accept, 'access',
|
|
3726
|
+
const serverSymbol = _optionalChain([accept, 'access', _65 => _65.extra, 'optionalAccess', _66 => _66.symbol]);
|
|
4577
3727
|
const symbolMismatch = intent.recognized && !!serverSymbol && !!symbol && serverSymbol.toUpperCase() !== symbol.toUpperCase();
|
|
4578
3728
|
return {
|
|
4579
3729
|
url,
|
|
@@ -4670,12 +3820,12 @@ var PipRailClient = (_class2 = class {
|
|
|
4670
3820
|
const shown = claimed < max ? claimed : max;
|
|
4671
3821
|
settledBase = shown.toString();
|
|
4672
3822
|
settledFormatted = _chunkQONQSZHJcjs.formatUnits.call(void 0, shown, quote.decimals);
|
|
4673
|
-
} catch (
|
|
3823
|
+
} catch (e29) {
|
|
4674
3824
|
}
|
|
4675
3825
|
}
|
|
4676
3826
|
const record = {
|
|
4677
3827
|
url: quote.url,
|
|
4678
|
-
host:
|
|
3828
|
+
host: hostOf(quote.url),
|
|
4679
3829
|
network: quote.network,
|
|
4680
3830
|
asset: quote.asset,
|
|
4681
3831
|
amountBase,
|
|
@@ -4692,7 +3842,7 @@ var PipRailClient = (_class2 = class {
|
|
|
4692
3842
|
if (this.opts.onSpend) {
|
|
4693
3843
|
try {
|
|
4694
3844
|
this.opts.onSpend(record, budget);
|
|
4695
|
-
} catch (
|
|
3845
|
+
} catch (e30) {
|
|
4696
3846
|
}
|
|
4697
3847
|
}
|
|
4698
3848
|
this.emitThresholds(budget);
|
|
@@ -4705,7 +3855,7 @@ var PipRailClient = (_class2 = class {
|
|
|
4705
3855
|
* `warnAtFraction` is set. Reads the just-computed {@link SessionBudget}; isolated (safeEmit).
|
|
4706
3856
|
*/
|
|
4707
3857
|
emitThresholds(budget) {
|
|
4708
|
-
const frac = _optionalChain([this, 'access',
|
|
3858
|
+
const frac = _optionalChain([this, 'access', _67 => _67.opts, 'access', _68 => _68.policy, 'optionalAccess', _69 => _69.warnAtFraction]);
|
|
4709
3859
|
if (frac === void 0) return;
|
|
4710
3860
|
const fire = (scope, label, spentFormatted, capFormatted, fraction) => {
|
|
4711
3861
|
if (fraction < frac) return;
|
|
@@ -4729,7 +3879,7 @@ var PipRailClient = (_class2 = class {
|
|
|
4729
3879
|
fire("denom", d.denom, d.spentFormatted, d.capFormatted, d.fraction);
|
|
4730
3880
|
}
|
|
4731
3881
|
const policy = this.opts.policy;
|
|
4732
|
-
if (_optionalChain([policy, 'optionalAccess',
|
|
3882
|
+
if (_optionalChain([policy, 'optionalAccess', _70 => _70.windowTotal]) !== void 0 && policy.windowSeconds !== void 0) {
|
|
4733
3883
|
const since = Date.now() - policy.windowSeconds * 1e3;
|
|
4734
3884
|
for (const r of budget.byAsset) {
|
|
4735
3885
|
const cap = _chunkQONQSZHJcjs.floorUnits.call(void 0, policy.windowTotal, r.decimals);
|
|
@@ -4767,7 +3917,7 @@ var PipRailClient = (_class2 = class {
|
|
|
4767
3917
|
const ref = await net.send(wallet, accept);
|
|
4768
3918
|
this.safeEmit({ kind: "payment-broadcast", ref });
|
|
4769
3919
|
try {
|
|
4770
|
-
const { height } = await net.confirm(ref, _nullishCoalesce(_optionalChain([accept, 'access',
|
|
3920
|
+
const { height } = await net.confirm(ref, _nullishCoalesce(_optionalChain([accept, 'access', _71 => _71.extra, 'optionalAccess', _72 => _72.minConfirmations]), () => ( 1)));
|
|
4771
3921
|
this.safeEmit({
|
|
4772
3922
|
kind: "payment-confirmed",
|
|
4773
3923
|
ref,
|
|
@@ -4787,10 +3937,10 @@ var PipRailClient = (_class2 = class {
|
|
|
4787
3937
|
const signature = {
|
|
4788
3938
|
x402Version: 2,
|
|
4789
3939
|
accepted: accept,
|
|
4790
|
-
payload: { nonce: _optionalChain([accept, 'access',
|
|
3940
|
+
payload: { nonce: _optionalChain([accept, 'access', _73 => _73.extra, 'optionalAccess', _74 => _74.nonce]), txHash: ref }
|
|
4791
3941
|
};
|
|
4792
|
-
const headers = new Headers(_optionalChain([originalInit, 'optionalAccess',
|
|
4793
|
-
headers.set(HEADER_SIGNATURE, buildSignatureHeader(signature));
|
|
3942
|
+
const headers = new Headers(_optionalChain([originalInit, 'optionalAccess', _75 => _75.headers]));
|
|
3943
|
+
headers.set(_chunkOXEFPLZAcjs.HEADER_SIGNATURE, _chunkOXEFPLZAcjs.buildSignatureHeader.call(void 0, signature));
|
|
4794
3944
|
let lastResponse = null;
|
|
4795
3945
|
let lastReason = null;
|
|
4796
3946
|
const attempts = confirmed ? this.maxRetries : Math.max(this.maxRetries, 6);
|
|
@@ -4804,7 +3954,7 @@ var PipRailClient = (_class2 = class {
|
|
|
4804
3954
|
() => timeoutController.abort(),
|
|
4805
3955
|
this.retryTimeoutMs
|
|
4806
3956
|
);
|
|
4807
|
-
const signal = _optionalChain([originalInit, 'optionalAccess',
|
|
3957
|
+
const signal = _optionalChain([originalInit, 'optionalAccess', _76 => _76.signal]) && typeof AbortSignal.any === "function" ? AbortSignal.any([timeoutController.signal, originalInit.signal]) : timeoutController.signal;
|
|
4808
3958
|
try {
|
|
4809
3959
|
lastResponse = await fetch(url, {
|
|
4810
3960
|
..._nullishCoalesce(originalInit, () => ( {})),
|
|
@@ -4823,7 +3973,7 @@ var PipRailClient = (_class2 = class {
|
|
|
4823
3973
|
clearTimeout(timeoutId);
|
|
4824
3974
|
}
|
|
4825
3975
|
if (lastResponse.status !== 402) {
|
|
4826
|
-
const receipt = parseReceipt(lastResponse);
|
|
3976
|
+
const receipt = _chunkOXEFPLZAcjs.parseReceipt.call(void 0, lastResponse);
|
|
4827
3977
|
this.captureReceipt(lastResponse, url);
|
|
4828
3978
|
this.safeEmit({ kind: "payment-settled", receipt });
|
|
4829
3979
|
return lastResponse;
|
|
@@ -4859,16 +4009,27 @@ var PipRailClient = (_class2 = class {
|
|
|
4859
4009
|
* • a 200 whose SettleResponse says `success:false` → a rejection, NEVER a spend;
|
|
4860
4010
|
* • the spend is recorded EXACTLY ONCE, on an affirmative settlement only.
|
|
4861
4011
|
*/
|
|
4862
|
-
async payExactRail(net, wallet, accept, url, init, quote) {
|
|
4012
|
+
async payExactRail(net, wallet, accept, url, init, quote, x402Version = 2) {
|
|
4863
4013
|
if (!net.payExact) {
|
|
4864
4014
|
throw new (0, _chunkQONQSZHJcjs.UnsupportedSchemeError)(
|
|
4865
4015
|
`the ${net.family} family can't pay a standard 'exact' rail (supported on EVM, Solana, Algorand, Aptos + NEAR today).`
|
|
4866
4016
|
);
|
|
4867
4017
|
}
|
|
4868
|
-
throwIfAborted(_optionalChain([init, 'optionalAccess',
|
|
4018
|
+
throwIfAborted(_optionalChain([init, 'optionalAccess', _77 => _77.signal]));
|
|
4869
4019
|
const { payload, accepted, payerFrom, nonce } = await net.payExact(wallet, accept);
|
|
4870
|
-
const headers = new Headers(_optionalChain([init, 'optionalAccess',
|
|
4871
|
-
|
|
4020
|
+
const headers = new Headers(_optionalChain([init, 'optionalAccess', _78 => _78.headers]));
|
|
4021
|
+
if (x402Version === 1) {
|
|
4022
|
+
headers.set(
|
|
4023
|
+
_chunkOXEFPLZAcjs.HEADER_SIGNATURE_V1,
|
|
4024
|
+
_chunkOXEFPLZAcjs.buildV1PaymentHeader.call(void 0, {
|
|
4025
|
+
scheme: accepted.scheme,
|
|
4026
|
+
network: _nullishCoalesce(accept.wireNetwork, () => ( accepted.network)),
|
|
4027
|
+
payload
|
|
4028
|
+
})
|
|
4029
|
+
);
|
|
4030
|
+
} else {
|
|
4031
|
+
headers.set(_chunkOXEFPLZAcjs.HEADER_SIGNATURE, _chunkOXEFPLZAcjs.buildExactSignatureHeader.call(void 0, { accepted, payload }));
|
|
4032
|
+
}
|
|
4872
4033
|
const rejectDefinitive = (why2) => {
|
|
4873
4034
|
this.safeEmit({ kind: "payment-failed", reason: `exact: facilitator rejected nonce=${nonce} (${why2})`, code: why2 });
|
|
4874
4035
|
throw new (0, _chunkQONQSZHJcjs.MaxRetriesExceededError)(
|
|
@@ -4884,34 +4045,34 @@ var PipRailClient = (_class2 = class {
|
|
|
4884
4045
|
if (Date.now() >= deadline) break;
|
|
4885
4046
|
await new Promise((r) => setTimeout(r, Math.min(2e3, 400 * 2 ** (attempt - 1))));
|
|
4886
4047
|
}
|
|
4887
|
-
throwIfAborted(_optionalChain([init, 'optionalAccess',
|
|
4048
|
+
throwIfAborted(_optionalChain([init, 'optionalAccess', _79 => _79.signal]));
|
|
4888
4049
|
const budget = Math.min(this.retryTimeoutMs, deadline - Date.now());
|
|
4889
4050
|
if (budget <= 0) break;
|
|
4890
4051
|
const timeoutController = new AbortController();
|
|
4891
4052
|
const timeoutId = setTimeout(() => timeoutController.abort(), budget);
|
|
4892
|
-
const signal = _optionalChain([init, 'optionalAccess',
|
|
4053
|
+
const signal = _optionalChain([init, 'optionalAccess', _80 => _80.signal]) && typeof AbortSignal.any === "function" ? AbortSignal.any([timeoutController.signal, init.signal]) : timeoutController.signal;
|
|
4893
4054
|
let response;
|
|
4894
4055
|
try {
|
|
4895
4056
|
response = await fetch(url, { ..._nullishCoalesce(init, () => ( {})), headers, signal });
|
|
4896
4057
|
} catch (err) {
|
|
4897
4058
|
throw new (0, _chunkQONQSZHJcjs.PaymentTimeoutError)(
|
|
4898
|
-
`exact: no response after submitting the authorization (nonce=${nonce}) to ${
|
|
4059
|
+
`exact: no response after submitting the authorization (nonce=${nonce}) to ${hostOf(url)}. The facilitator may have already settled it \u2014 verify on-chain via ${exactSettleCheckHint(net.family, payerFrom, nonce)} before re-presenting the SAME signed authorization; do NOT re-pay.`,
|
|
4899
4060
|
{ cause: err, ref: nonce }
|
|
4900
4061
|
);
|
|
4901
4062
|
} finally {
|
|
4902
4063
|
clearTimeout(timeoutId);
|
|
4903
4064
|
}
|
|
4904
|
-
const settle = parseSettleResponse(response);
|
|
4065
|
+
const settle = _chunkOXEFPLZAcjs.parseSettleResponse.call(void 0, response);
|
|
4905
4066
|
if (response.status === 402) {
|
|
4906
4067
|
if (settle && settle.success === false) rejectDefinitive(_nullishCoalesce(settle.errorReason, () => ( "the facilitator reported success:false")));
|
|
4907
4068
|
lastReason = await _asyncNullishCoalesce(await readInvalidReason(response), async () => ( lastReason));
|
|
4908
4069
|
continue;
|
|
4909
4070
|
}
|
|
4910
4071
|
if (response.ok && !(settle && settle.success === false)) {
|
|
4911
|
-
const receipt = parseReceipt(response);
|
|
4072
|
+
const receipt = _chunkOXEFPLZAcjs.parseReceipt.call(void 0, response);
|
|
4912
4073
|
this.captureReceipt(response, url);
|
|
4913
4074
|
this.safeEmit({ kind: "payment-settled", receipt, ...settle ? { settle } : {} });
|
|
4914
|
-
const ref = _optionalChain([settle, 'optionalAccess',
|
|
4075
|
+
const ref = _optionalChain([settle, 'optionalAccess', _81 => _81.transaction]) || _optionalChain([receipt, 'optionalAccess', _82 => _82.transaction]) || `${net.family === "evm" ? "eip3009" : net.family}-nonce:${nonce}`;
|
|
4915
4076
|
this.recordSpend(quote, ref);
|
|
4916
4077
|
return response;
|
|
4917
4078
|
}
|
|
@@ -4949,10 +4110,10 @@ var PipRailClient = (_class2 = class {
|
|
|
4949
4110
|
`the ${net.family} family can't pay a standard 'upto' rail (EVM-Permit2 only today).`
|
|
4950
4111
|
);
|
|
4951
4112
|
}
|
|
4952
|
-
throwIfAborted(_optionalChain([init, 'optionalAccess',
|
|
4113
|
+
throwIfAborted(_optionalChain([init, 'optionalAccess', _83 => _83.signal]));
|
|
4953
4114
|
const { payload, accepted, payerFrom, nonce } = await net.payUpto(wallet, accept);
|
|
4954
|
-
const headers = new Headers(_optionalChain([init, 'optionalAccess',
|
|
4955
|
-
headers.set(HEADER_SIGNATURE, buildUptoSignatureHeader({ accepted, payload }));
|
|
4115
|
+
const headers = new Headers(_optionalChain([init, 'optionalAccess', _84 => _84.headers]));
|
|
4116
|
+
headers.set(_chunkOXEFPLZAcjs.HEADER_SIGNATURE, _chunkOXEFPLZAcjs.buildUptoSignatureHeader.call(void 0, { accepted, payload }));
|
|
4956
4117
|
const rejectDefinitive = (why2) => {
|
|
4957
4118
|
this.safeEmit({ kind: "payment-failed", reason: `upto: facilitator rejected nonce=${nonce} (${why2})`, code: why2 });
|
|
4958
4119
|
throw new (0, _chunkQONQSZHJcjs.MaxRetriesExceededError)(
|
|
@@ -4968,35 +4129,35 @@ var PipRailClient = (_class2 = class {
|
|
|
4968
4129
|
if (Date.now() >= deadline) break;
|
|
4969
4130
|
await new Promise((r) => setTimeout(r, Math.min(2e3, 400 * 2 ** (attempt - 1))));
|
|
4970
4131
|
}
|
|
4971
|
-
throwIfAborted(_optionalChain([init, 'optionalAccess',
|
|
4132
|
+
throwIfAborted(_optionalChain([init, 'optionalAccess', _85 => _85.signal]));
|
|
4972
4133
|
const budget = Math.min(this.retryTimeoutMs, deadline - Date.now());
|
|
4973
4134
|
if (budget <= 0) break;
|
|
4974
4135
|
const timeoutController = new AbortController();
|
|
4975
4136
|
const timeoutId = setTimeout(() => timeoutController.abort(), budget);
|
|
4976
|
-
const signal = _optionalChain([init, 'optionalAccess',
|
|
4137
|
+
const signal = _optionalChain([init, 'optionalAccess', _86 => _86.signal]) && typeof AbortSignal.any === "function" ? AbortSignal.any([timeoutController.signal, init.signal]) : timeoutController.signal;
|
|
4977
4138
|
let response;
|
|
4978
4139
|
try {
|
|
4979
4140
|
response = await fetch(url, { ..._nullishCoalesce(init, () => ( {})), headers, signal });
|
|
4980
4141
|
} catch (err) {
|
|
4981
4142
|
throw new (0, _chunkQONQSZHJcjs.PaymentTimeoutError)(
|
|
4982
|
-
`upto: no response after submitting the authorization (nonce=${nonce}) to ${
|
|
4143
|
+
`upto: no response after submitting the authorization (nonce=${nonce}) to ${hostOf(url)}. The merchant may have already settled it \u2014 verify on-chain before re-presenting; do NOT re-pay.`,
|
|
4983
4144
|
{ cause: err, ref: nonce }
|
|
4984
4145
|
);
|
|
4985
4146
|
} finally {
|
|
4986
4147
|
clearTimeout(timeoutId);
|
|
4987
4148
|
}
|
|
4988
|
-
const settle = parseSettleResponse(response);
|
|
4149
|
+
const settle = _chunkOXEFPLZAcjs.parseSettleResponse.call(void 0, response);
|
|
4989
4150
|
if (response.status === 402) {
|
|
4990
4151
|
if (settle && settle.success === false) rejectDefinitive(_nullishCoalesce(settle.errorReason, () => ( "the server reported success:false")));
|
|
4991
4152
|
lastReason = await _asyncNullishCoalesce(await readInvalidReason(response), async () => ( lastReason));
|
|
4992
4153
|
continue;
|
|
4993
4154
|
}
|
|
4994
4155
|
if (response.ok && !(settle && settle.success === false)) {
|
|
4995
|
-
const receipt = parseReceipt(response);
|
|
4156
|
+
const receipt = _chunkOXEFPLZAcjs.parseReceipt.call(void 0, response);
|
|
4996
4157
|
this.captureReceipt(response, url);
|
|
4997
4158
|
this.safeEmit({ kind: "payment-settled", receipt, ...settle ? { settle } : {} });
|
|
4998
|
-
const ref = _optionalChain([settle, 'optionalAccess',
|
|
4999
|
-
const settledAmount = _nullishCoalesce(_optionalChain([settle, 'optionalAccess',
|
|
4159
|
+
const ref = _optionalChain([settle, 'optionalAccess', _87 => _87.transaction]) || _optionalChain([receipt, 'optionalAccess', _88 => _88.transaction]) || `upto-nonce:${nonce}`;
|
|
4160
|
+
const settledAmount = _nullishCoalesce(_optionalChain([settle, 'optionalAccess', _89 => _89.amount]), () => ( _optionalChain([receipt, 'optionalAccess', _90 => _90.amount])));
|
|
5000
4161
|
this.recordSpend(quote, ref, settledAmount);
|
|
5001
4162
|
return response;
|
|
5002
4163
|
}
|
|
@@ -5021,14 +4182,14 @@ var PipRailClient = (_class2 = class {
|
|
|
5021
4182
|
}
|
|
5022
4183
|
}, _class2);
|
|
5023
4184
|
function throwIfAborted(signal) {
|
|
5024
|
-
if (_optionalChain([signal, 'optionalAccess',
|
|
4185
|
+
if (_optionalChain([signal, 'optionalAccess', _91 => _91.aborted])) {
|
|
5025
4186
|
throw _nullishCoalesce(signal.reason, () => ( new DOMException("This operation was aborted.", "AbortError")));
|
|
5026
4187
|
}
|
|
5027
4188
|
}
|
|
5028
4189
|
function safeBig(s) {
|
|
5029
4190
|
try {
|
|
5030
4191
|
return BigInt(s);
|
|
5031
|
-
} catch (
|
|
4192
|
+
} catch (e31) {
|
|
5032
4193
|
return 0n;
|
|
5033
4194
|
}
|
|
5034
4195
|
}
|
|
@@ -5091,10 +4252,10 @@ function buildFundingHint(options, chainLabel) {
|
|
|
5091
4252
|
return `Couldn't fully read your wallet on ${chainLabel} (RPC throttled) \u2014 retry; you may already be able to pay ${target.quote.amountFormatted} ${sym}.`;
|
|
5092
4253
|
}
|
|
5093
4254
|
const parts = [];
|
|
5094
|
-
if (target.blockers.includes("INSUFFICIENT_TOKEN") && _optionalChain([target, 'access',
|
|
4255
|
+
if (target.blockers.includes("INSUFFICIENT_TOKEN") && _optionalChain([target, 'access', _92 => _92.shortfall, 'optionalAccess', _93 => _93.token])) {
|
|
5095
4256
|
parts.push(`top up ${target.shortfall.token} ${sym}`);
|
|
5096
4257
|
}
|
|
5097
|
-
if (target.blockers.includes("INSUFFICIENT_GAS") && _optionalChain([target, 'access',
|
|
4258
|
+
if (target.blockers.includes("INSUFFICIENT_GAS") && _optionalChain([target, 'access', _94 => _94.shortfall, 'optionalAccess', _95 => _95.native])) {
|
|
5098
4259
|
parts.push(`add ~${target.shortfall.native} ${target.cost.feeSymbol} for gas`);
|
|
5099
4260
|
}
|
|
5100
4261
|
return parts.length ? `Can't settle on ${chainLabel}: ${parts.join(" and ")} (to pay ${target.quote.amountFormatted} ${sym}).` : `Can't settle on ${chainLabel} for ${target.quote.amountFormatted} ${sym}.`;
|
|
@@ -5108,7 +4269,7 @@ async function planAcross(clients, url, init) {
|
|
|
5108
4269
|
const status = best ? "ready" : options.some((o) => o.state === "unknown") ? "unknown" : "blocked";
|
|
5109
4270
|
return {
|
|
5110
4271
|
url,
|
|
5111
|
-
network: _nullishCoalesce(_optionalChain([best, 'optionalAccess',
|
|
4272
|
+
network: _nullishCoalesce(_optionalChain([best, 'optionalAccess', _96 => _96.accept, 'access', _97 => _97.network]), () => ( live[0].network)),
|
|
5112
4273
|
status,
|
|
5113
4274
|
payable: best !== null,
|
|
5114
4275
|
best,
|
|
@@ -5133,7 +4294,7 @@ async function fetchAcross(clients, url, init) {
|
|
|
5133
4294
|
return owner.fetch(url, { ..._nullishCoalesce(init, () => ( {})), autoRoute: true });
|
|
5134
4295
|
}
|
|
5135
4296
|
function railOnNetwork(rail, matches) {
|
|
5136
|
-
const n = normalizeNetwork(rail.network);
|
|
4297
|
+
const n = _chunkV2IJ5HUWcjs.normalizeNetwork.call(void 0, rail.network);
|
|
5137
4298
|
return !n.includes(":") || matches(n);
|
|
5138
4299
|
}
|
|
5139
4300
|
function reasonCodeForPolicy(code) {
|
|
@@ -5153,10 +4314,10 @@ function reasonCodeForPolicy(code) {
|
|
|
5153
4314
|
return "POLICY";
|
|
5154
4315
|
}
|
|
5155
4316
|
}
|
|
5156
|
-
function
|
|
4317
|
+
function hostOf(url) {
|
|
5157
4318
|
try {
|
|
5158
4319
|
return new URL(url).hostname;
|
|
5159
|
-
} catch (
|
|
4320
|
+
} catch (e32) {
|
|
5160
4321
|
return url;
|
|
5161
4322
|
}
|
|
5162
4323
|
}
|
|
@@ -5173,8 +4334,8 @@ function isReplayableBodyInit(value) {
|
|
|
5173
4334
|
async function readInvalidReason(response) {
|
|
5174
4335
|
try {
|
|
5175
4336
|
const body = await response.clone().json();
|
|
5176
|
-
const ext = _optionalChain([body, 'optionalAccess',
|
|
5177
|
-
const piprail = _optionalChain([ext, 'optionalAccess',
|
|
4337
|
+
const ext = _optionalChain([body, 'optionalAccess', _98 => _98.extensions]);
|
|
4338
|
+
const piprail = _optionalChain([ext, 'optionalAccess', _99 => _99.piprail]);
|
|
5178
4339
|
if (piprail && typeof piprail.code === "string") {
|
|
5179
4340
|
return {
|
|
5180
4341
|
error: piprail.code,
|
|
@@ -5193,10 +4354,10 @@ async function readInvalidReason(response) {
|
|
|
5193
4354
|
detail: typeof body.invalidMessage === "string" ? body.invalidMessage : ""
|
|
5194
4355
|
};
|
|
5195
4356
|
}
|
|
5196
|
-
} catch (
|
|
4357
|
+
} catch (e33) {
|
|
5197
4358
|
}
|
|
5198
|
-
const settle = parseSettleResponse(response);
|
|
5199
|
-
if (_optionalChain([settle, 'optionalAccess',
|
|
4359
|
+
const settle = _chunkOXEFPLZAcjs.parseSettleResponse.call(void 0, response);
|
|
4360
|
+
if (_optionalChain([settle, 'optionalAccess', _100 => _100.errorReason])) return { error: settle.errorReason, detail: "" };
|
|
5200
4361
|
return null;
|
|
5201
4362
|
}
|
|
5202
4363
|
var EVM_PRESET_FOR_CHAINID = {
|
|
@@ -5209,7 +4370,7 @@ var EVM_PRESET_FOR_CHAINID = {
|
|
|
5209
4370
|
56: "bnb"
|
|
5210
4371
|
};
|
|
5211
4372
|
function chainSelectorForNetwork(network, rpcUrl) {
|
|
5212
|
-
const chainId = chainIdFromNetwork(network);
|
|
4373
|
+
const chainId = _chunkOXEFPLZAcjs.chainIdFromNetwork.call(void 0, network);
|
|
5213
4374
|
if (chainId !== null) {
|
|
5214
4375
|
const preset = EVM_PRESET_FOR_CHAINID[chainId];
|
|
5215
4376
|
if (preset) return preset;
|
|
@@ -5294,7 +4455,7 @@ var MultiChainPayer = class _MultiChainPayer {
|
|
|
5294
4455
|
ledger,
|
|
5295
4456
|
...opts.policy ? { policy: opts.policy } : {},
|
|
5296
4457
|
...opts.schemes ? { schemes: opts.schemes } : {},
|
|
5297
|
-
..._optionalChain([opts, 'access',
|
|
4458
|
+
..._optionalChain([opts, 'access', _101 => _101.rpcUrls, 'optionalAccess', _102 => _102[chain]]) ? { rpcUrl: opts.rpcUrls[chain] } : {},
|
|
5298
4459
|
...opts.onBeforePay ? { onBeforePay: opts.onBeforePay } : {},
|
|
5299
4460
|
...opts.onEvent ? { onEvent: opts.onEvent } : {},
|
|
5300
4461
|
...opts.maxPaymentRetries != null ? { maxPaymentRetries: opts.maxPaymentRetries } : {},
|
|
@@ -5352,7 +4513,7 @@ var MultiChainPayer = class _MultiChainPayer {
|
|
|
5352
4513
|
* {@link PipRailClient.post}.
|
|
5353
4514
|
*/
|
|
5354
4515
|
post(url, body, init) {
|
|
5355
|
-
const headers = new Headers(_optionalChain([init, 'optionalAccess',
|
|
4516
|
+
const headers = new Headers(_optionalChain([init, 'optionalAccess', _103 => _103.headers]));
|
|
5356
4517
|
let payload;
|
|
5357
4518
|
if (body === void 0 || body === null) {
|
|
5358
4519
|
payload = void 0;
|
|
@@ -5502,14 +4663,14 @@ function buildSelfDescription(input) {
|
|
|
5502
4663
|
}
|
|
5503
4664
|
function buildEndpointInfo(input) {
|
|
5504
4665
|
const d = input.descriptor;
|
|
5505
|
-
const summary = _nullishCoalesce(_optionalChain([d, 'optionalAccess',
|
|
5506
|
-
const hasInput = _optionalChain([d, 'optionalAccess',
|
|
4666
|
+
const summary = _nullishCoalesce(_optionalChain([d, 'optionalAccess', _104 => _104.summary]), () => ( input.description));
|
|
4667
|
+
const hasInput = _optionalChain([d, 'optionalAccess', _105 => _105.queryParams]) && Object.keys(d.queryParams).length > 0;
|
|
5507
4668
|
const endpoint = {
|
|
5508
4669
|
...summary ? { summary } : {},
|
|
5509
|
-
..._optionalChain([d, 'optionalAccess',
|
|
4670
|
+
..._optionalChain([d, 'optionalAccess', _106 => _106.method]) ? { method: d.method.toUpperCase() } : {},
|
|
5510
4671
|
...input.mimeType ? { mimeType: input.mimeType } : {},
|
|
5511
4672
|
...hasInput ? { input: d.queryParams } : {},
|
|
5512
|
-
..._optionalChain([d, 'optionalAccess',
|
|
4673
|
+
..._optionalChain([d, 'optionalAccess', _107 => _107.output]) ? { output: d.output } : {}
|
|
5513
4674
|
};
|
|
5514
4675
|
return Object.keys(endpoint).length > 0 ? endpoint : void 0;
|
|
5515
4676
|
}
|
|
@@ -5560,16 +4721,16 @@ function formatSpendReport(summary) {
|
|
|
5560
4721
|
function describeChallenge(challenge) {
|
|
5561
4722
|
const generic = `${BRAND.name} x402 payment endpoint. Pay with @piprail/sdk (${BRAND.sdkInstall}). Docs: ${BRAND.home}.`;
|
|
5562
4723
|
try {
|
|
5563
|
-
const accepts = Array.isArray(_optionalChain([challenge, 'optionalAccess',
|
|
4724
|
+
const accepts = Array.isArray(_optionalChain([challenge, 'optionalAccess', _108 => _108.accepts])) ? challenge.accepts : [];
|
|
5564
4725
|
const first = accepts[0];
|
|
5565
4726
|
if (!first) return generic;
|
|
5566
4727
|
const extra = _nullishCoalesce(first.extra, () => ( {}));
|
|
5567
4728
|
const amount = _nullishCoalesce(extra.amountFormatted, () => ( first.amount));
|
|
5568
4729
|
const token = _nullishCoalesce(extra.symbol, () => ( first.asset));
|
|
5569
|
-
const hasExact = accepts.some((a) => _optionalChain([a, 'optionalAccess',
|
|
4730
|
+
const hasExact = accepts.some((a) => _optionalChain([a, 'optionalAccess', _109 => _109.scheme]) === "exact");
|
|
5570
4731
|
const standard = hasExact ? "; or any standard x402 client (an exact rail is offered)" : "";
|
|
5571
4732
|
return `${BRAND.name} x402 payment endpoint \u2014 pay ${amount} ${token} on ${first.network} to ${first.payTo}. Programmatic: ${BRAND.sdkInstall} then client.fetch(url)${standard}. Docs: ${BRAND.home}.`;
|
|
5572
|
-
} catch (
|
|
4733
|
+
} catch (e34) {
|
|
5573
4734
|
return generic;
|
|
5574
4735
|
}
|
|
5575
4736
|
}
|
|
@@ -5607,6 +4768,9 @@ A 402 may offer up to three rails; you don't choose per payment \u2014 the clien
|
|
|
5607
4768
|
(e.g. PayAI) \u2014 broadcasts it, so you pay ZERO gas (you need only the token, no native coin). It
|
|
5608
4769
|
works on EVM, Solana, Algorand, Aptos + NEAR, and the on-chain method (EIP-3009 / Permit2 / SVM /
|
|
5609
4770
|
Algorand fee-pooled group / Aptos fee-payer / NEAR SignedDelegateAction) is picked automatically.
|
|
4771
|
+
XRPL also supports exact (native XRP), with ONE difference that matters to your budget: there the
|
|
4772
|
+
PAYER pays the network fee, because on the XRP Ledger the fee lives inside the signed transaction.
|
|
4773
|
+
So keep a little XRP for fees on that chain \u2014 everywhere else exact means you need no native coin.
|
|
5610
4774
|
- upto (the metered/variable x402 rail, opt-in, EVM): the amount you see is a MAXIMUM \u2014 you sign
|
|
5611
4775
|
a ceiling, the server meters real usage and settles the ACTUAL (<= the max). BUDGET AGAINST THE MAX:
|
|
5612
4776
|
the plan/policy treat the ceiling as the spend (a server may charge up to it), so a payable plan
|
|
@@ -5678,7 +4842,7 @@ async function readBody(res) {
|
|
|
5678
4842
|
if (!text) return null;
|
|
5679
4843
|
try {
|
|
5680
4844
|
return JSON.parse(text);
|
|
5681
|
-
} catch (
|
|
4845
|
+
} catch (e35) {
|
|
5682
4846
|
return text;
|
|
5683
4847
|
}
|
|
5684
4848
|
}
|
|
@@ -5897,12 +5061,12 @@ function paymentTools(client) {
|
|
|
5897
5061
|
}
|
|
5898
5062
|
res = await client.fetch(url, { method, headers, body });
|
|
5899
5063
|
}
|
|
5900
|
-
const verifiable = parseReceiptExtension(res);
|
|
5064
|
+
const verifiable = _chunkOXEFPLZAcjs.parseReceiptExtension.call(void 0, res);
|
|
5901
5065
|
return {
|
|
5902
5066
|
status: res.status,
|
|
5903
5067
|
ok: res.ok,
|
|
5904
5068
|
body: await readBody(res),
|
|
5905
|
-
receipt: parseReceipt(res),
|
|
5069
|
+
receipt: _chunkOXEFPLZAcjs.parseReceipt.call(void 0, res),
|
|
5906
5070
|
...verifiable ? { verifiableReceipt: { ...verifiable, resource: { url } } } : {}
|
|
5907
5071
|
};
|
|
5908
5072
|
} catch (err) {
|
|
@@ -6062,20 +5226,20 @@ function paymentTools(client) {
|
|
|
6062
5226
|
// src/classify.ts
|
|
6063
5227
|
function classifyChallenge(challenge, opts) {
|
|
6064
5228
|
try {
|
|
6065
|
-
const accepts = Array.isArray(_optionalChain([challenge, 'optionalAccess',
|
|
6066
|
-
const network = _optionalChain([opts, 'optionalAccess',
|
|
6067
|
-
const schemes = _nullishCoalesce(_optionalChain([opts, 'optionalAccess',
|
|
5229
|
+
const accepts = Array.isArray(_optionalChain([challenge, 'optionalAccess', _110 => _110.accepts])) ? challenge.accepts : [];
|
|
5230
|
+
const network = _optionalChain([opts, 'optionalAccess', _111 => _111.network]);
|
|
5231
|
+
const schemes = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _112 => _112.schemes]), () => ( []));
|
|
6068
5232
|
const offeredSchemes = [
|
|
6069
|
-
...new Set(accepts.map((a) => _optionalChain([a, 'optionalAccess',
|
|
5233
|
+
...new Set(accepts.map((a) => _optionalChain([a, 'optionalAccess', _113 => _113.scheme])).filter((s) => s != null))
|
|
6070
5234
|
];
|
|
6071
|
-
const offeredNetworks = [...new Set(accepts.map((a) => _optionalChain([a, 'optionalAccess',
|
|
6072
|
-
const onClientChain = accepts.some((a) => _optionalChain([a, 'optionalAccess',
|
|
5235
|
+
const offeredNetworks = [...new Set(accepts.map((a) => _optionalChain([a, 'optionalAccess', _114 => _114.network])).filter((n) => n != null))];
|
|
5236
|
+
const onClientChain = accepts.some((a) => _optionalChain([a, 'optionalAccess', _115 => _115.network]) === network);
|
|
6073
5237
|
const payableScheme = accepts.some(
|
|
6074
|
-
(a) => _optionalChain([a, 'optionalAccess',
|
|
5238
|
+
(a) => _optionalChain([a, 'optionalAccess', _116 => _116.network]) === network && schemes.includes(_optionalChain([a, 'optionalAccess', _117 => _117.scheme]))
|
|
6075
5239
|
);
|
|
6076
5240
|
const verdict = accepts.length === 0 ? "NO_RAIL" : payableScheme ? "PAYABLE_RAIL" : onClientChain ? "UNPAYABLE_SCHEME" : "WRONG_CHAIN";
|
|
6077
5241
|
return { onClientChain, payableScheme, offeredSchemes, offeredNetworks, verdict };
|
|
6078
|
-
} catch (
|
|
5242
|
+
} catch (e36) {
|
|
6079
5243
|
return {
|
|
6080
5244
|
onClientChain: false,
|
|
6081
5245
|
payableScheme: false,
|
|
@@ -6125,12 +5289,12 @@ function buildBazaarExtension(descriptor = {}) {
|
|
|
6125
5289
|
function pathOf(url) {
|
|
6126
5290
|
try {
|
|
6127
5291
|
return new URL(url).pathname || "/";
|
|
6128
|
-
} catch (
|
|
5292
|
+
} catch (e37) {
|
|
6129
5293
|
return url.startsWith("/") ? url : `/${url}`;
|
|
6130
5294
|
}
|
|
6131
5295
|
}
|
|
6132
5296
|
function buildOpenApi(input) {
|
|
6133
|
-
assertResourceList(_optionalChain([input, 'optionalAccess',
|
|
5297
|
+
assertResourceList(_optionalChain([input, 'optionalAccess', _118 => _118.resources]), "buildOpenApi");
|
|
6134
5298
|
const paths = {};
|
|
6135
5299
|
for (const r of input.resources) {
|
|
6136
5300
|
const path = pathOf(r.url);
|
|
@@ -6160,7 +5324,7 @@ function buildOpenApi(input) {
|
|
|
6160
5324
|
};
|
|
6161
5325
|
}
|
|
6162
5326
|
function buildWellKnownX402(input) {
|
|
6163
|
-
assertResourceList(_optionalChain([input, 'optionalAccess',
|
|
5327
|
+
assertResourceList(_optionalChain([input, 'optionalAccess', _119 => _119.resources]), "buildWellKnownX402");
|
|
6164
5328
|
return {
|
|
6165
5329
|
version: 1,
|
|
6166
5330
|
resources: input.resources.map((r) => r.url),
|
|
@@ -6180,7 +5344,7 @@ function assertResourceList(resources, fn) {
|
|
|
6180
5344
|
});
|
|
6181
5345
|
}
|
|
6182
5346
|
function buildWellKnownX402Manifest(input) {
|
|
6183
|
-
assertResourceList(_optionalChain([input, 'optionalAccess',
|
|
5347
|
+
assertResourceList(_optionalChain([input, 'optionalAccess', _120 => _120.resources]), "buildWellKnownX402Manifest");
|
|
6184
5348
|
const lastUpdated = typeof input.lastUpdated === "number" && Number.isFinite(input.lastUpdated) ? input.lastUpdated : Math.floor(Date.now() / 1e3);
|
|
6185
5349
|
return {
|
|
6186
5350
|
x402Version: 2,
|
|
@@ -6267,28 +5431,28 @@ async function fetchFacilitatorFeePayer(url, network, timeoutMs = 8e3) {
|
|
|
6267
5431
|
const res = await fetch(`${base2}/supported`, { signal: ctrl.signal });
|
|
6268
5432
|
if (!res.ok) return void 0;
|
|
6269
5433
|
const body = await res.json();
|
|
6270
|
-
const kinds = Array.isArray(_optionalChain([body, 'optionalAccess',
|
|
6271
|
-
const want = normalizeNetwork(network);
|
|
6272
|
-
const kind = kinds.find((k) => _optionalChain([k, 'optionalAccess',
|
|
6273
|
-
const fp = _optionalChain([kind, 'optionalAccess',
|
|
5434
|
+
const kinds = Array.isArray(_optionalChain([body, 'optionalAccess', _121 => _121.kinds])) ? body.kinds : [];
|
|
5435
|
+
const want = _chunkV2IJ5HUWcjs.normalizeNetwork.call(void 0, network);
|
|
5436
|
+
const kind = kinds.find((k) => _optionalChain([k, 'optionalAccess', _122 => _122.scheme]) === "exact" && _chunkV2IJ5HUWcjs.normalizeNetwork.call(void 0, String(_nullishCoalesce(_optionalChain([k, 'optionalAccess', _123 => _123.network]), () => ( "")))) === want);
|
|
5437
|
+
const fp = _optionalChain([kind, 'optionalAccess', _124 => _124.extra, 'optionalAccess', _125 => _125.feePayer]);
|
|
6274
5438
|
return typeof fp === "string" ? fp : void 0;
|
|
6275
|
-
} catch (
|
|
5439
|
+
} catch (e38) {
|
|
6276
5440
|
return void 0;
|
|
6277
5441
|
} finally {
|
|
6278
5442
|
clearTimeout(timer);
|
|
6279
5443
|
}
|
|
6280
5444
|
}
|
|
6281
5445
|
function parseFacilitatorSupported(body) {
|
|
6282
|
-
const kinds = _optionalChain([body, 'optionalAccess',
|
|
5446
|
+
const kinds = _optionalChain([body, 'optionalAccess', _126 => _126.kinds]);
|
|
6283
5447
|
if (!Array.isArray(kinds)) return [];
|
|
6284
5448
|
const out = [];
|
|
6285
5449
|
for (const k of kinds) {
|
|
6286
5450
|
if (!k || typeof k !== "object") continue;
|
|
6287
5451
|
const o = k;
|
|
6288
5452
|
if (typeof o.scheme !== "string" || typeof o.network !== "string") continue;
|
|
6289
|
-
const fp = _optionalChain([o, 'access',
|
|
5453
|
+
const fp = _optionalChain([o, 'access', _127 => _127.extra, 'optionalAccess', _128 => _128.feePayer]);
|
|
6290
5454
|
const ver = o.x402Version;
|
|
6291
|
-
const method = _optionalChain([o, 'access',
|
|
5455
|
+
const method = _optionalChain([o, 'access', _129 => _129.extra, 'optionalAccess', _130 => _130.assetTransferMethod]);
|
|
6292
5456
|
out.push({
|
|
6293
5457
|
scheme: o.scheme,
|
|
6294
5458
|
network: o.network,
|
|
@@ -6307,7 +5471,7 @@ async function facilitatorCoverage(url, timeoutMs = 8e3) {
|
|
|
6307
5471
|
const res = await fetch(`${base2}/supported`, { signal: ctrl.signal });
|
|
6308
5472
|
if (!res.ok) return [];
|
|
6309
5473
|
return parseFacilitatorSupported(await res.json());
|
|
6310
|
-
} catch (
|
|
5474
|
+
} catch (e39) {
|
|
6311
5475
|
return [];
|
|
6312
5476
|
} finally {
|
|
6313
5477
|
clearTimeout(timer);
|
|
@@ -6336,7 +5500,7 @@ async function post(url, body, headers) {
|
|
|
6336
5500
|
let json = null;
|
|
6337
5501
|
try {
|
|
6338
5502
|
json = await res.json();
|
|
6339
|
-
} catch (
|
|
5503
|
+
} catch (e40) {
|
|
6340
5504
|
}
|
|
6341
5505
|
return { status: res.status, json };
|
|
6342
5506
|
}
|
|
@@ -6416,42 +5580,42 @@ var KNOWN_FACILITATORS = {
|
|
|
6416
5580
|
keyless: true,
|
|
6417
5581
|
schemes: ["exact"],
|
|
6418
5582
|
settles: ["eip3009"],
|
|
6419
|
-
note: "PayAI
|
|
5583
|
+
note: "PayAI: keyless, sponsors gas (Base USDC EIP-3009). Verified 2026-06-14 (/supported + live demo)."
|
|
6420
5584
|
},
|
|
6421
5585
|
{
|
|
6422
5586
|
url: "https://facilitator.xpay.sh",
|
|
6423
5587
|
keyless: true,
|
|
6424
5588
|
schemes: ["exact"],
|
|
6425
5589
|
settles: ["eip3009"],
|
|
6426
|
-
note: "xpay
|
|
5590
|
+
note: "xpay: keyless, zero-fee, sponsors gas. LIVE-settled on Base 2026-06-15 (tx 0x2273d5\u2026)."
|
|
6427
5591
|
},
|
|
6428
5592
|
{
|
|
6429
5593
|
url: "https://facilitator.ultravioletadao.xyz",
|
|
6430
5594
|
keyless: true,
|
|
6431
5595
|
schemes: ["exact"],
|
|
6432
5596
|
settles: ["eip3009"],
|
|
6433
|
-
note: "Ultravioleta DAO
|
|
5597
|
+
note: "Ultravioleta DAO: keyless, 100% gas-sponsored (Base USDC EIP-3009). LIVE-settled on Base 2026-06-17 (tx 0x58a69042a4129be649c5642456752ede95a5ff921daddfd30560ae70ae5907ff). 2nd UVD validation chain (after HyperEVM)."
|
|
6434
5598
|
},
|
|
6435
5599
|
{
|
|
6436
5600
|
url: "https://x402.dexter.cash",
|
|
6437
5601
|
keyless: true,
|
|
6438
5602
|
schemes: ["exact"],
|
|
6439
5603
|
settles: ["eip3009"],
|
|
6440
|
-
note: "Dexter
|
|
5604
|
+
note: "Dexter: keyless, gas-sponsored (Base USDC EIP-3009). LIVE-settled on Base 2026-06-17 (tx 0xdf030e4d5bf41a88c5a3bfe73bb433dfbb90b058d3b8ded63b68e026eedb9de8). Note: ~$0.001 dynamic floor on Base."
|
|
6441
5605
|
},
|
|
6442
5606
|
{
|
|
6443
5607
|
url: "https://facilitator.goplausible.xyz",
|
|
6444
5608
|
keyless: true,
|
|
6445
5609
|
schemes: ["exact"],
|
|
6446
5610
|
settles: ["eip3009"],
|
|
6447
|
-
note: "GoPlausible
|
|
5611
|
+
note: "GoPlausible: keyless, sponsors gas (Base USDC EIP-3009). LIVE-settled on Base 2026-06-17 (tx 0x9bcbc1f01fe1fd1aed2a79e5582555164cc4185e9800189df378a6b46eb9c59e). 2nd GoPlausible validation chain (after Algorand)."
|
|
6448
5612
|
},
|
|
6449
5613
|
{
|
|
6450
5614
|
url: "https://facilitator.cascade.fyi",
|
|
6451
5615
|
keyless: true,
|
|
6452
5616
|
schemes: ["exact"],
|
|
6453
5617
|
settles: ["eip3009"],
|
|
6454
|
-
note: "Cascade
|
|
5618
|
+
note: "Cascade: keyless, sponsors gas (Base USDC EIP-3009). LIVE-settled on Base 2026-06-18 (tx 0x2e784725f3c66e170720cc8df43a9248f02ad80914fcbe05dadbdbe411c3b52b)."
|
|
6455
5619
|
}
|
|
6456
5620
|
],
|
|
6457
5621
|
// Monad (eip155:143). Corbits + Ultravioleta DAO each keyless-settle the EVM EIP-3009 exact rail
|
|
@@ -6463,14 +5627,14 @@ var KNOWN_FACILITATORS = {
|
|
|
6463
5627
|
keyless: true,
|
|
6464
5628
|
schemes: ["exact"],
|
|
6465
5629
|
settles: ["eip3009"],
|
|
6466
|
-
note: "Ultravioleta DAO
|
|
5630
|
+
note: "Ultravioleta DAO: keyless, 100% gas-sponsored (Monad native USDC EIP-3009). LIVE-settled on Monad 2026-06-17 (tx 0xb107576effbaceb5586c07a9ddc996ef2b6d455f1858314995ef83a7c6e64d11). 3rd UVD validation chain."
|
|
6467
5631
|
},
|
|
6468
5632
|
{
|
|
6469
5633
|
url: "https://facilitator.pieverse.io",
|
|
6470
5634
|
keyless: true,
|
|
6471
5635
|
schemes: ["exact"],
|
|
6472
5636
|
settles: ["eip3009"],
|
|
6473
|
-
note: "Pieverse
|
|
5637
|
+
note: "Pieverse: keyless, sponsors gas (Monad USDC EIP-3009). LIVE-settled on Monad 2026-06-17 (tx 0x00cfeb93876e5ef57dcb002510038b7304913233ca286d7ab33c72a8b119eb0d)."
|
|
6474
5638
|
}
|
|
6475
5639
|
],
|
|
6476
5640
|
// BNB Chain (eip155:56). Dexter + Pieverse keyless-settle the EVM EIP-3009 exact rail for BNB's
|
|
@@ -6484,14 +5648,14 @@ var KNOWN_FACILITATORS = {
|
|
|
6484
5648
|
keyless: true,
|
|
6485
5649
|
schemes: ["exact"],
|
|
6486
5650
|
settles: ["eip3009"],
|
|
6487
|
-
note: "Dexter
|
|
5651
|
+
note: "Dexter: keyless, gas-sponsored. BNB EIP-3009 tokens FDUSD/USD1/U (Binance-Peg USDC/USDT are Permit2 \u2192 not facilitator-settleable); ~$0.003 dynamic floor. LIVE-settled on BNB 2026-06-17 with FDUSD (tx 0x6d9eb4e4939f3f3c74cb19424cc7822d66ec8ed5c5c7c330d9f88a5f9ad59e9e); accepts U (verify confirmed 2026-06-21)."
|
|
6488
5652
|
},
|
|
6489
5653
|
{
|
|
6490
5654
|
url: "https://facilitator.pieverse.io",
|
|
6491
5655
|
keyless: true,
|
|
6492
5656
|
schemes: ["exact"],
|
|
6493
5657
|
settles: ["eip3009"],
|
|
6494
|
-
note: "Pieverse
|
|
5658
|
+
note: "Pieverse: keyless, sponsors gas. BNB EIP-3009 tokens FDUSD/USD1/U (same Binance-Peg caveat as Dexter). LIVE-settled on BNB with FDUSD 2026-06-17 (tx 0xb9c76affc45bd07a51559efd813ca71516fc30625478724476c2cf42fc2203d3) AND with the U / United Stables token 2026-06-21 (tx 0x2b3b8c51ae81df441551301c44a64652c84c796af3b9d03ec58ea38f1cb013d5, buyer 0 BNB). A 2nd keyless BNB facilitator (failover for Dexter)."
|
|
6495
5659
|
}
|
|
6496
5660
|
],
|
|
6497
5661
|
// HyperEVM (eip155:999). Ultravioleta DAO keyless-settles the EVM EIP-3009 exact rail (HyperEVM's
|
|
@@ -6504,7 +5668,7 @@ var KNOWN_FACILITATORS = {
|
|
|
6504
5668
|
keyless: true,
|
|
6505
5669
|
schemes: ["exact"],
|
|
6506
5670
|
settles: ["eip3009"],
|
|
6507
|
-
note: "Ultravioleta DAO
|
|
5671
|
+
note: "Ultravioleta DAO: keyless, 100% gas-sponsored (HyperEVM native USDC EIP-3009). LIVE-settled on HyperEVM 2026-06-17 (tx 0x56af8148a92a291f0ce362e250919f7742074e5464ac0f315ad68abaec93bd0a)."
|
|
6508
5672
|
}
|
|
6509
5673
|
],
|
|
6510
5674
|
// ── gasless-extension (2026-06-18): 7 more EVM mainnets, each LIVE-settled by us — a real EIP-3009
|
|
@@ -6521,7 +5685,7 @@ var KNOWN_FACILITATORS = {
|
|
|
6521
5685
|
keyless: true,
|
|
6522
5686
|
schemes: ["exact"],
|
|
6523
5687
|
settles: ["eip3009"],
|
|
6524
|
-
note: "Ultravioleta DAO
|
|
5688
|
+
note: "Ultravioleta DAO: keyless, 100% gas-sponsored (Ethereum native USDC EIP-3009; no settlement floor). LIVE-settled on Ethereum mainnet 2026-06-18 (tx 0x7fcc3cafdf43c52888f0117cde633eff35371f832dfb8dbd84e6fd7704ae5cfc)."
|
|
6525
5689
|
}
|
|
6526
5690
|
],
|
|
6527
5691
|
// Polygon PoS (eip155:137) — FIVE keyless facilitators (the broadest after Base), all live-settled.
|
|
@@ -6531,28 +5695,28 @@ var KNOWN_FACILITATORS = {
|
|
|
6531
5695
|
keyless: true,
|
|
6532
5696
|
schemes: ["exact"],
|
|
6533
5697
|
settles: ["eip3009"],
|
|
6534
|
-
note: "PayAI
|
|
5698
|
+
note: "PayAI: keyless, sponsors gas (Polygon native USDC EIP-3009). LIVE-settled on Polygon 2026-06-18 (tx 0xb37630871504618c4db35e8ef0edd3c99deac102b143b7e5eb738c03fb13a619)."
|
|
6535
5699
|
},
|
|
6536
5700
|
{
|
|
6537
5701
|
url: "https://x402.polygon.technology",
|
|
6538
5702
|
keyless: true,
|
|
6539
5703
|
schemes: ["exact"],
|
|
6540
5704
|
settles: ["eip3009"],
|
|
6541
|
-
note: "Polygon Labs (the official Polygon facilitator)
|
|
5705
|
+
note: "Polygon Labs (the official Polygon facilitator): keyless, sponsors gas. LIVE-settled on Polygon 2026-06-18 (tx 0x6a8ca60ea111959a61a85ad6c4f2ed99e192052ec7b9ffb59baa33691a86f419)."
|
|
6542
5706
|
},
|
|
6543
5707
|
{
|
|
6544
5708
|
url: "https://facilitator.ultravioletadao.xyz",
|
|
6545
5709
|
keyless: true,
|
|
6546
5710
|
schemes: ["exact"],
|
|
6547
5711
|
settles: ["eip3009"],
|
|
6548
|
-
note: "Ultravioleta DAO
|
|
5712
|
+
note: "Ultravioleta DAO: keyless, 100% gas-sponsored. LIVE-settled on Polygon 2026-06-18 (tx 0x0922cd78f3b7c35cc294cf0c0d9b7609e6596eb337be0d197fa5fc511eacba34)."
|
|
6549
5713
|
},
|
|
6550
5714
|
{
|
|
6551
5715
|
url: "https://x402.dexter.cash",
|
|
6552
5716
|
keyless: true,
|
|
6553
5717
|
schemes: ["exact"],
|
|
6554
5718
|
settles: ["eip3009"],
|
|
6555
|
-
note: "Dexter
|
|
5719
|
+
note: "Dexter: keyless, sponsors gas; ~$0.004 dynamic settlement floor (sub-floor \u2192 amount_too_low). LIVE-settled on Polygon 2026-06-18 at $0.005 (tx 0x4a7cfc96e4e2496652435c77b0021db4a459e7bcd97948c15e6bea09077c164b)."
|
|
6556
5720
|
}
|
|
6557
5721
|
],
|
|
6558
5722
|
// Arbitrum One (eip155:42161) — PayAI + UVD + Dexter.
|
|
@@ -6562,21 +5726,21 @@ var KNOWN_FACILITATORS = {
|
|
|
6562
5726
|
keyless: true,
|
|
6563
5727
|
schemes: ["exact"],
|
|
6564
5728
|
settles: ["eip3009"],
|
|
6565
|
-
note: "PayAI
|
|
5729
|
+
note: "PayAI: keyless, sponsors gas (Arbitrum native USDC EIP-3009). LIVE-settled on Arbitrum 2026-06-18 (tx 0x4c7fbfb37ef087bb9bc8872b1b2b0b83ea7ca4cf6b50bc883e51f9b85be61199)."
|
|
6566
5730
|
},
|
|
6567
5731
|
{
|
|
6568
5732
|
url: "https://facilitator.ultravioletadao.xyz",
|
|
6569
5733
|
keyless: true,
|
|
6570
5734
|
schemes: ["exact"],
|
|
6571
5735
|
settles: ["eip3009"],
|
|
6572
|
-
note: "Ultravioleta DAO
|
|
5736
|
+
note: "Ultravioleta DAO: keyless, 100% gas-sponsored. LIVE-settled on Arbitrum 2026-06-18 (tx 0xd1fa7e6ffbd59502bba5809ce181d7936749b93a45c8c2277b4f6d8638326dec)."
|
|
6573
5737
|
},
|
|
6574
5738
|
{
|
|
6575
5739
|
url: "https://x402.dexter.cash",
|
|
6576
5740
|
keyless: true,
|
|
6577
5741
|
schemes: ["exact"],
|
|
6578
5742
|
settles: ["eip3009"],
|
|
6579
|
-
note: "Dexter
|
|
5743
|
+
note: "Dexter: keyless, sponsors gas; ~$0.004 dynamic floor. LIVE-settled on Arbitrum 2026-06-18 at $0.005 (tx 0x0993d51b3859dfd7e8d5b2af709ce64f01ff34ed14bfef665dbb340e7373d599)."
|
|
6580
5744
|
}
|
|
6581
5745
|
],
|
|
6582
5746
|
// Optimism (eip155:10) — Dexter + UVD.
|
|
@@ -6586,14 +5750,14 @@ var KNOWN_FACILITATORS = {
|
|
|
6586
5750
|
keyless: true,
|
|
6587
5751
|
schemes: ["exact"],
|
|
6588
5752
|
settles: ["eip3009"],
|
|
6589
|
-
note: "Dexter
|
|
5753
|
+
note: "Dexter: keyless, sponsors gas; ~$0.004 dynamic floor. LIVE-settled on Optimism 2026-06-18 at $0.005 (tx 0x98b282a5dd698054eff4900ff8547170d4f7605b51140c55147fc5ae485f81da)."
|
|
6590
5754
|
},
|
|
6591
5755
|
{
|
|
6592
5756
|
url: "https://facilitator.ultravioletadao.xyz",
|
|
6593
5757
|
keyless: true,
|
|
6594
5758
|
schemes: ["exact"],
|
|
6595
5759
|
settles: ["eip3009"],
|
|
6596
|
-
note: "Ultravioleta DAO
|
|
5760
|
+
note: "Ultravioleta DAO: keyless, 100% gas-sponsored. LIVE-settled on Optimism 2026-06-18 (tx 0xdd91dfdf12bed2d196e37fa1dea9a0da71a97e3c39a0ec0ed114be6a9af22837)."
|
|
6597
5761
|
}
|
|
6598
5762
|
],
|
|
6599
5763
|
// Avalanche C-Chain (eip155:43114) — PayAI + Dexter. (UVD advertises it but contract_call_failed → unseeded.)
|
|
@@ -6603,14 +5767,14 @@ var KNOWN_FACILITATORS = {
|
|
|
6603
5767
|
keyless: true,
|
|
6604
5768
|
schemes: ["exact"],
|
|
6605
5769
|
settles: ["eip3009"],
|
|
6606
|
-
note: "PayAI
|
|
5770
|
+
note: "PayAI: keyless, sponsors gas (Avalanche native USDC EIP-3009). LIVE-settled on Avalanche 2026-06-18 (tx 0x6a1307bc48a157de236ea03440ea2cb6ad4f27e22dd9c89a4345b4c3edb270c7)."
|
|
6607
5771
|
},
|
|
6608
5772
|
{
|
|
6609
5773
|
url: "https://x402.dexter.cash",
|
|
6610
5774
|
keyless: true,
|
|
6611
5775
|
schemes: ["exact"],
|
|
6612
5776
|
settles: ["eip3009"],
|
|
6613
|
-
note: "Dexter
|
|
5777
|
+
note: "Dexter: keyless, sponsors gas (no floor hit at $0.001 here). LIVE-settled on Avalanche 2026-06-18 (tx 0xb2263e9a4ea3917eee6acabcb454d42a50264fdd69a0781ed8fcaec5590e264b)."
|
|
6614
5778
|
}
|
|
6615
5779
|
],
|
|
6616
5780
|
// Sei (eip155:1329) — PayAI (the only keyless facilitator that lists Sei).
|
|
@@ -6620,7 +5784,7 @@ var KNOWN_FACILITATORS = {
|
|
|
6620
5784
|
keyless: true,
|
|
6621
5785
|
schemes: ["exact"],
|
|
6622
5786
|
settles: ["eip3009"],
|
|
6623
|
-
note: "PayAI
|
|
5787
|
+
note: "PayAI: keyless, sponsors gas (Sei native USDC EIP-3009). LIVE-settled on Sei 2026-06-18 (tx 0xde63679b64749cb59625527e5c7682503c851d66b9b8b8ba217ed7b099461312)."
|
|
6624
5788
|
}
|
|
6625
5789
|
],
|
|
6626
5790
|
// Unichain (eip155:130) — UVD (the only keyless facilitator that lists Unichain).
|
|
@@ -6630,7 +5794,7 @@ var KNOWN_FACILITATORS = {
|
|
|
6630
5794
|
keyless: true,
|
|
6631
5795
|
schemes: ["exact"],
|
|
6632
5796
|
settles: ["eip3009"],
|
|
6633
|
-
note: "Ultravioleta DAO
|
|
5797
|
+
note: "Ultravioleta DAO: keyless, 100% gas-sponsored (Unichain native USDC EIP-3009). LIVE-settled on Unichain 2026-06-18 (tx 0xf8bf4a9a200f24159ac67c6315c30b194257999d7da21471b39d5f2cc32b2236)."
|
|
6634
5798
|
}
|
|
6635
5799
|
],
|
|
6636
5800
|
// Algorand (mainnet, CAIP-2 = full base64 genesis hash). GoPlausible keyless-settles the ratified
|
|
@@ -6646,7 +5810,7 @@ var KNOWN_FACILITATORS = {
|
|
|
6646
5810
|
keyless: true,
|
|
6647
5811
|
schemes: ["exact"],
|
|
6648
5812
|
settles: ["algorand"],
|
|
6649
|
-
note: "GoPlausible
|
|
5813
|
+
note: "GoPlausible: keyless, 100% gas-sponsored (Algorand USDCa, atomic-group fee pooling; both buyer AND merchant pay 0 ALGO). LIVE-settled on Algorand mainnet 2026-06-17 (tx PDVDVRFGJAG2K6AJ7L26OTSCSRL7AURVKEX4D4KHBAOLNSCYENXA). The only keyless Algorand x402 facilitator."
|
|
6650
5814
|
}
|
|
6651
5815
|
],
|
|
6652
5816
|
// Solana (mainnet-beta). Keyless fee-payer sponsors for the SVM exact rail, each LIVE-settled
|
|
@@ -6659,14 +5823,14 @@ var KNOWN_FACILITATORS = {
|
|
|
6659
5823
|
keyless: true,
|
|
6660
5824
|
schemes: ["exact"],
|
|
6661
5825
|
settles: ["svm"],
|
|
6662
|
-
note: "PayAI
|
|
5826
|
+
note: "PayAI: keyless fee-payer sponsor (Solana SPL SVM). LIVE-settled 2026-06-14 (tx 4dL8jRKH\u2026)."
|
|
6663
5827
|
},
|
|
6664
5828
|
{
|
|
6665
5829
|
url: "https://pay.openfacilitator.io",
|
|
6666
5830
|
keyless: true,
|
|
6667
5831
|
schemes: ["exact"],
|
|
6668
5832
|
settles: ["svm"],
|
|
6669
|
-
note: "OpenFacilitator
|
|
5833
|
+
note: "OpenFacilitator: keyless (no signup), fee-payer sponsor. LIVE-settled on Solana 2026-06-15 (tx 5BabDtX\u2026)."
|
|
6670
5834
|
}
|
|
6671
5835
|
]
|
|
6672
5836
|
// NEAR (near:mainnet) — DELIBERATELY UNSEEDED: no x402 facilitator settles NEAR yet.
|
|
@@ -6747,7 +5911,7 @@ function createPaymentGate(options) {
|
|
|
6747
5911
|
attestWarned = true;
|
|
6748
5912
|
try {
|
|
6749
5913
|
console.warn(`[piprail] receipts.attest ${reason}; emitting an unsigned Tier-1 receipt instead.`);
|
|
6750
|
-
} catch (
|
|
5914
|
+
} catch (e41) {
|
|
6751
5915
|
}
|
|
6752
5916
|
}
|
|
6753
5917
|
let resolved;
|
|
@@ -6791,7 +5955,7 @@ function createPaymentGate(options) {
|
|
|
6791
5955
|
if (exactOption && !specs.some((s) => s.exact)) {
|
|
6792
5956
|
const why = exactSkips.length > 0 ? exactSkips.join(" ") : "The standard `exact` rail is EVM ERC-20 (EIP-3009 \u2014 USDC / EURC \u2014 or Permit2, e.g. Binance-Peg USDC on BNB) or a Solana SPL token (SVM) \u2014 NOT native coins, NOT families without a standard `exact` scheme.";
|
|
6793
5957
|
if (exactOption.settle === "keyless") {
|
|
6794
|
-
if (typeof process === "undefined" || !_optionalChain([process, 'optionalAccess',
|
|
5958
|
+
if (typeof process === "undefined" || !_optionalChain([process, 'optionalAccess', _131 => _131.env, 'optionalAccess', _132 => _132.PIPRAIL_NO_HINTS])) {
|
|
6795
5959
|
console.warn(
|
|
6796
5960
|
`[piprail] exact: true \u2014 no offered chain has a gasless \`exact\` rail available, so this gate serves ONCHAIN-PROOF ONLY (buyers PAY GAS \u2014 the fallback when no facilitator can sponsor). ${why} To be gasless: pin \`exact: { settle: { facilitator } }\` or self-settle \`exact: { settle: 'self', relayer }\`. (Suppress with PIPRAIL_NO_HINTS=1.)`
|
|
6797
5961
|
);
|
|
@@ -6819,7 +5983,7 @@ function createPaymentGate(options) {
|
|
|
6819
5983
|
skipReason: `${net.network}: \`exact: true\` found no known keyless facilitator for this network. Pass \`exact: { settle: { facilitator } }\`, \`exact: { settle: 'self', relayer }\`, or see the coverage map (KNOWN_FACILITATORS / docs.piprail.com).`
|
|
6820
5984
|
};
|
|
6821
5985
|
}
|
|
6822
|
-
if (typeof process === "undefined" || _optionalChain([process, 'optionalAccess',
|
|
5986
|
+
if (typeof process === "undefined" || _optionalChain([process, 'optionalAccess', _133 => _133.env, 'optionalAccess', _134 => _134.NODE_ENV]) !== "production" && !_optionalChain([process, 'optionalAccess', _135 => _135.env, 'optionalAccess', _136 => _136.PIPRAIL_NO_HINTS])) {
|
|
6823
5987
|
console.warn(
|
|
6824
5988
|
`[piprail] exact: keyless rail on ${net.network} auto-settles via ${picked.url} (zero-config; pin \`exact.settle.facilitator\` in production).`
|
|
6825
5989
|
);
|
|
@@ -6963,7 +6127,7 @@ function createPaymentGate(options) {
|
|
|
6963
6127
|
extra: {
|
|
6964
6128
|
assetTransferMethod: "permit2-upto",
|
|
6965
6129
|
// facilitatorAddress comes from rail.extra; the spread below carries it (+ name/version).
|
|
6966
|
-
facilitatorAddress: _nullishCoalesce(_optionalChain([rail, 'access',
|
|
6130
|
+
facilitatorAddress: _nullishCoalesce(_optionalChain([rail, 'access', _137 => _137.extra, 'optionalAccess', _138 => _138.facilitatorAddress]), () => ( "")),
|
|
6967
6131
|
minConfirmations,
|
|
6968
6132
|
decimals: s.decimals,
|
|
6969
6133
|
amountFormatted: s.amountFormatted,
|
|
@@ -6985,7 +6149,7 @@ function createPaymentGate(options) {
|
|
|
6985
6149
|
const specs = await ready();
|
|
6986
6150
|
const nonce = genNonce();
|
|
6987
6151
|
const bazaar = options.discovery ? { bazaar: buildBazaarExtension(options.discovery === true ? {} : options.discovery) } : void 0;
|
|
6988
|
-
const paymentIdAd = options.paymentIdentifier ? buildPaymentIdentifierAdvertisement() : void 0;
|
|
6152
|
+
const paymentIdAd = options.paymentIdentifier ? _chunkOXEFPLZAcjs.buildPaymentIdentifierAdvertisement.call(void 0, ) : void 0;
|
|
6989
6153
|
const accepts = buildAccepts(specs, nonce);
|
|
6990
6154
|
const endpointInfo = buildEndpointInfo({
|
|
6991
6155
|
...options.description ? { description: options.description } : {},
|
|
@@ -6998,7 +6162,7 @@ function createPaymentGate(options) {
|
|
|
6998
6162
|
...endpointInfo ? { endpoint: endpointInfo } : {},
|
|
6999
6163
|
...receiptsOn ? { verifiableReceipts: true } : {}
|
|
7000
6164
|
});
|
|
7001
|
-
const rejectionExt = _nullishCoalesce(_optionalChain([opts, 'optionalAccess',
|
|
6165
|
+
const rejectionExt = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _139 => _139.extensions]), () => ( {}));
|
|
7002
6166
|
const rejectionPiprail = _nullishCoalesce(rejectionExt.piprail, () => ( {}));
|
|
7003
6167
|
const bodyPiprail = { ..._nullishCoalesce(selfDescribe, () => ( {})), ...rejectionPiprail };
|
|
7004
6168
|
const bodyExtensions = {
|
|
@@ -7020,14 +6184,14 @@ function createPaymentGate(options) {
|
|
|
7020
6184
|
...options.mimeType ? { mimeType: options.mimeType } : {}
|
|
7021
6185
|
},
|
|
7022
6186
|
accepts,
|
|
7023
|
-
..._optionalChain([opts, 'optionalAccess',
|
|
6187
|
+
..._optionalChain([opts, 'optionalAccess', _140 => _140.error]) ? { error: opts.error } : {},
|
|
7024
6188
|
...Object.keys(bodyExtensions).length > 0 ? { extensions: bodyExtensions } : {}
|
|
7025
6189
|
};
|
|
7026
6190
|
const headerChallenge = {
|
|
7027
6191
|
...challenge2,
|
|
7028
6192
|
...Object.keys(headerExtensions).length > 0 ? { extensions: headerExtensions } : { extensions: void 0 }
|
|
7029
6193
|
};
|
|
7030
|
-
return { challenge: challenge2, requiredHeader: buildChallengeHeader(headerChallenge) };
|
|
6194
|
+
return { challenge: challenge2, requiredHeader: _chunkOXEFPLZAcjs.buildChallengeHeader.call(void 0, headerChallenge) };
|
|
7031
6195
|
}
|
|
7032
6196
|
async function challenge(resourceUrl = "") {
|
|
7033
6197
|
return makeChallenge(resourceUrl);
|
|
@@ -7052,7 +6216,7 @@ function createPaymentGate(options) {
|
|
|
7052
6216
|
let amountFormatted = receipt.amount;
|
|
7053
6217
|
try {
|
|
7054
6218
|
amountFormatted = _chunkQONQSZHJcjs.formatUnits.call(void 0, BigInt(receipt.amount), spec.decimals);
|
|
7055
|
-
} catch (
|
|
6219
|
+
} catch (e42) {
|
|
7056
6220
|
}
|
|
7057
6221
|
return {
|
|
7058
6222
|
...receipt,
|
|
@@ -7066,7 +6230,7 @@ function createPaymentGate(options) {
|
|
|
7066
6230
|
if (!options.onPaidError) return;
|
|
7067
6231
|
try {
|
|
7068
6232
|
options.onPaidError(error, receipt);
|
|
7069
|
-
} catch (
|
|
6233
|
+
} catch (e43) {
|
|
7070
6234
|
}
|
|
7071
6235
|
}
|
|
7072
6236
|
function fireOnPaid(receipt) {
|
|
@@ -7089,7 +6253,7 @@ function createPaymentGate(options) {
|
|
|
7089
6253
|
}
|
|
7090
6254
|
async function buildPaidResult(spec, receipt, nonce) {
|
|
7091
6255
|
if (!receiptsOn) {
|
|
7092
|
-
return { kind: "paid", receipt, receiptHeader: buildReceiptHeader(receipt) };
|
|
6256
|
+
return { kind: "paid", receipt, receiptHeader: _chunkOXEFPLZAcjs.buildReceiptHeader.call(void 0, receipt) };
|
|
7093
6257
|
}
|
|
7094
6258
|
try {
|
|
7095
6259
|
const stamped = {
|
|
@@ -7099,15 +6263,15 @@ function createPaymentGate(options) {
|
|
|
7099
6263
|
...receiptIncludeTxHash ? {} : { transaction: "" }
|
|
7100
6264
|
};
|
|
7101
6265
|
const attestation = await maybeSignAttestation(spec, stamped);
|
|
7102
|
-
const extensions = buildReceiptExtension({
|
|
6266
|
+
const extensions = _chunkOXEFPLZAcjs.buildReceiptExtension.call(void 0, {
|
|
7103
6267
|
receipt: stamped,
|
|
7104
6268
|
resource: { url: receiptResourceUrl },
|
|
7105
6269
|
decimals: spec.decimals,
|
|
7106
6270
|
...attestation ? { attestation } : {}
|
|
7107
6271
|
});
|
|
7108
|
-
return { kind: "paid", receipt: stamped, receiptHeader: buildReceiptHeader(stamped, extensions) };
|
|
7109
|
-
} catch (
|
|
7110
|
-
return { kind: "paid", receipt, receiptHeader: buildReceiptHeader(receipt) };
|
|
6272
|
+
return { kind: "paid", receipt: stamped, receiptHeader: _chunkOXEFPLZAcjs.buildReceiptHeader.call(void 0, stamped, extensions) };
|
|
6273
|
+
} catch (e44) {
|
|
6274
|
+
return { kind: "paid", receipt, receiptHeader: _chunkOXEFPLZAcjs.buildReceiptHeader.call(void 0, receipt) };
|
|
7111
6275
|
}
|
|
7112
6276
|
}
|
|
7113
6277
|
async function maybeSignAttestation(spec, stamped) {
|
|
@@ -7131,7 +6295,7 @@ function createPaymentGate(options) {
|
|
|
7131
6295
|
// §5.3: the signed message carries the empty string for a suppressed tx, never omitted.
|
|
7132
6296
|
transaction: receiptIncludeTxHash ? stamped.transaction : ""
|
|
7133
6297
|
});
|
|
7134
|
-
} catch (
|
|
6298
|
+
} catch (e45) {
|
|
7135
6299
|
warnAttestDegrade("signing failed");
|
|
7136
6300
|
return void 0;
|
|
7137
6301
|
}
|
|
@@ -7140,7 +6304,7 @@ function createPaymentGate(options) {
|
|
|
7140
6304
|
if (!options.onFailedError) return;
|
|
7141
6305
|
try {
|
|
7142
6306
|
options.onFailedError(error, failure);
|
|
7143
|
-
} catch (
|
|
6307
|
+
} catch (e46) {
|
|
7144
6308
|
}
|
|
7145
6309
|
}
|
|
7146
6310
|
function fireOnFailed(failure) {
|
|
@@ -7184,8 +6348,8 @@ function createPaymentGate(options) {
|
|
|
7184
6348
|
maxTimeoutSeconds,
|
|
7185
6349
|
...s.symbol ? { symbol: s.symbol } : {}
|
|
7186
6350
|
};
|
|
7187
|
-
if (s.exact) accepts.push({ scheme: "exact", ...base2, ...railExtra(buildExactAccept(s).extra) });
|
|
7188
|
-
if (s.upto) accepts.push({ scheme: "upto", ...base2, ...railExtra(buildUptoAccept(s).extra) });
|
|
6351
|
+
if (s.exact) accepts.push({ scheme: "exact", ...base2, ...railExtra(_nullishCoalesce(buildExactAccept(s).extra, () => ( {}))) });
|
|
6352
|
+
if (s.upto) accepts.push({ scheme: "upto", ...base2, ...railExtra(_nullishCoalesce(buildUptoAccept(s).extra, () => ( {}))) });
|
|
7189
6353
|
accepts.push({ scheme: "onchain-proof", ...base2 });
|
|
7190
6354
|
}
|
|
7191
6355
|
return {
|
|
@@ -7198,7 +6362,7 @@ function createPaymentGate(options) {
|
|
|
7198
6362
|
async function verifyOnchainProof(sig) {
|
|
7199
6363
|
const specs = await ready();
|
|
7200
6364
|
const spec = specs.find(
|
|
7201
|
-
(s) => s.net.network === sig.accepted.network && s.asset === sig.accepted.asset
|
|
6365
|
+
(s) => _chunkV2IJ5HUWcjs.normalizeNetwork.call(void 0, s.net.network) === _chunkV2IJ5HUWcjs.normalizeNetwork.call(void 0, sig.accepted.network) && s.asset === sig.accepted.asset
|
|
7202
6366
|
);
|
|
7203
6367
|
if (!spec) {
|
|
7204
6368
|
return rejection(
|
|
@@ -7240,7 +6404,8 @@ function createPaymentGate(options) {
|
|
|
7240
6404
|
return rejection("transfer_not_found", "This resource offers no standard `exact` rail.");
|
|
7241
6405
|
}
|
|
7242
6406
|
const isCaip = exact.network.includes(":");
|
|
7243
|
-
|
|
6407
|
+
const wantExactNet = _chunkV2IJ5HUWcjs.normalizeNetwork.call(void 0, exact.network);
|
|
6408
|
+
let candidates = isCaip ? exactSpecs.filter((s) => _chunkV2IJ5HUWcjs.normalizeNetwork.call(void 0, s.net.network) === wantExactNet) : exactSpecs;
|
|
7244
6409
|
if (exact.asset) {
|
|
7245
6410
|
candidates = candidates.filter((s) => s.asset.toLowerCase() === exact.asset.toLowerCase());
|
|
7246
6411
|
}
|
|
@@ -7259,30 +6424,32 @@ function createPaymentGate(options) {
|
|
|
7259
6424
|
nonce = [exact.payload.transaction, exact.payload.senderAuth].map((t) => {
|
|
7260
6425
|
try {
|
|
7261
6426
|
return Buffer.from(t, "base64").toString("base64");
|
|
7262
|
-
} catch (
|
|
6427
|
+
} catch (e47) {
|
|
7263
6428
|
return t;
|
|
7264
6429
|
}
|
|
7265
6430
|
}).join("|");
|
|
7266
6431
|
} else if ("transaction" in exact.payload) {
|
|
7267
6432
|
try {
|
|
7268
6433
|
nonce = Buffer.from(exact.payload.transaction, "base64").toString("base64");
|
|
7269
|
-
} catch (
|
|
6434
|
+
} catch (e48) {
|
|
7270
6435
|
nonce = exact.payload.transaction;
|
|
7271
6436
|
}
|
|
7272
6437
|
} else if ("paymentGroup" in exact.payload) {
|
|
7273
6438
|
nonce = exact.payload.paymentGroup.map((t) => {
|
|
7274
6439
|
try {
|
|
7275
6440
|
return Buffer.from(t, "base64").toString("base64");
|
|
7276
|
-
} catch (
|
|
6441
|
+
} catch (e49) {
|
|
7277
6442
|
return t;
|
|
7278
6443
|
}
|
|
7279
6444
|
}).join("|");
|
|
7280
6445
|
} else if ("signedDelegateAction" in exact.payload) {
|
|
7281
6446
|
try {
|
|
7282
6447
|
nonce = Buffer.from(exact.payload.signedDelegateAction, "base64").toString("base64");
|
|
7283
|
-
} catch (
|
|
6448
|
+
} catch (e50) {
|
|
7284
6449
|
nonce = exact.payload.signedDelegateAction;
|
|
7285
6450
|
}
|
|
6451
|
+
} else if ("signedTxBlob" in exact.payload) {
|
|
6452
|
+
nonce = exact.payload.signedTxBlob.trim().toUpperCase();
|
|
7286
6453
|
} else if ("permit2Authorization" in exact.payload) {
|
|
7287
6454
|
evmAuth = exact.payload.permit2Authorization;
|
|
7288
6455
|
nonce = evmAuth.nonce;
|
|
@@ -7300,9 +6467,9 @@ function createPaymentGate(options) {
|
|
|
7300
6467
|
if (mode.kind === "self") {
|
|
7301
6468
|
result = await spec.net.settleExactSelf({ relayer: mode.relayer, payload: exact.payload, accept });
|
|
7302
6469
|
} else {
|
|
7303
|
-
const ftMethod = accept.extra.assetTransferMethod;
|
|
6470
|
+
const ftMethod = _optionalChain([accept, 'access', _141 => _141.extra, 'optionalAccess', _142 => _142.assetTransferMethod]);
|
|
7304
6471
|
const needsFeePayer = ftMethod === "svm" || ftMethod === "algorand" || ftMethod === "aptos" || ftMethod === "near";
|
|
7305
|
-
if (needsFeePayer && !accept.extra.feePayer) {
|
|
6472
|
+
if (needsFeePayer && !_optionalChain([accept, 'access', _143 => _143.extra, 'optionalAccess', _144 => _144.feePayer])) {
|
|
7306
6473
|
throw new (0, _chunkQONQSZHJcjs.SettlementError)(
|
|
7307
6474
|
`exact settle: the ${ftMethod} facilitator rail is missing extra.feePayer (the gas sponsor) \u2014 cannot settle.`
|
|
7308
6475
|
);
|
|
@@ -7323,7 +6490,7 @@ function createPaymentGate(options) {
|
|
|
7323
6490
|
amount: accept.amount,
|
|
7324
6491
|
payTo: accept.payTo,
|
|
7325
6492
|
maxTimeoutSeconds: accept.maxTimeoutSeconds,
|
|
7326
|
-
extra: needsFeePayer ? { feePayer: accept.extra.feePayer } : { name: _nullishCoalesce(accept.extra.name, () => ( "")), version: _nullishCoalesce(accept.extra.version, () => ( "")) }
|
|
6493
|
+
extra: needsFeePayer ? { feePayer: accept.extra.feePayer } : { name: _nullishCoalesce(_optionalChain([accept, 'access', _145 => _145.extra, 'optionalAccess', _146 => _146.name]), () => ( "")), version: _nullishCoalesce(_optionalChain([accept, 'access', _147 => _147.extra, 'optionalAccess', _148 => _148.version]), () => ( "")) }
|
|
7327
6494
|
},
|
|
7328
6495
|
receipt: { network: accept.network, asset: accept.asset, payTo: accept.payTo, amount: accept.amount },
|
|
7329
6496
|
// The buyer address, for the receipt's `payer` fallback. EVM carries it in the
|
|
@@ -7360,7 +6527,7 @@ function createPaymentGate(options) {
|
|
|
7360
6527
|
}
|
|
7361
6528
|
if (/^\d+$/.test(s)) return BigInt(s);
|
|
7362
6529
|
return _chunkQONQSZHJcjs.floorUnits.call(void 0, s, decimals);
|
|
7363
|
-
} catch (
|
|
6530
|
+
} catch (e51) {
|
|
7364
6531
|
return null;
|
|
7365
6532
|
}
|
|
7366
6533
|
}
|
|
@@ -7371,7 +6538,8 @@ function createPaymentGate(options) {
|
|
|
7371
6538
|
return rejection("transfer_not_found", "This resource offers no standard `upto` (metered) rail.");
|
|
7372
6539
|
}
|
|
7373
6540
|
const isCaip = upto.network.includes(":");
|
|
7374
|
-
|
|
6541
|
+
const wantUptoNet = _chunkV2IJ5HUWcjs.normalizeNetwork.call(void 0, upto.network);
|
|
6542
|
+
let candidates = isCaip ? uptoSpecs.filter((s) => _chunkV2IJ5HUWcjs.normalizeNetwork.call(void 0, s.net.network) === wantUptoNet) : uptoSpecs;
|
|
7375
6543
|
if (upto.asset) {
|
|
7376
6544
|
candidates = candidates.filter((s) => s.asset.toLowerCase() === upto.asset.toLowerCase());
|
|
7377
6545
|
}
|
|
@@ -7426,7 +6594,7 @@ function createPaymentGate(options) {
|
|
|
7426
6594
|
}
|
|
7427
6595
|
async function verify(paymentSignature) {
|
|
7428
6596
|
const raw = normaliseHeader(paymentSignature);
|
|
7429
|
-
const result = await resolveVerdictObject(raw === void 0 ? void 0 : decodeBase64Json(raw));
|
|
6597
|
+
const result = await resolveVerdictObject(raw === void 0 ? void 0 : _chunkOXEFPLZAcjs.decodeBase64Json.call(void 0, raw));
|
|
7430
6598
|
if (result.kind === "invalid") await deliverOnFailed(result);
|
|
7431
6599
|
return result;
|
|
7432
6600
|
}
|
|
@@ -7437,33 +6605,33 @@ function createPaymentGate(options) {
|
|
|
7437
6605
|
}
|
|
7438
6606
|
async function routeVerdictObject(obj) {
|
|
7439
6607
|
if (obj === void 0 || obj === null) return asChallenge();
|
|
7440
|
-
const sig = parseSignatureObject(obj);
|
|
6608
|
+
const sig = _chunkOXEFPLZAcjs.parseSignatureObject.call(void 0, obj);
|
|
7441
6609
|
if (sig && sig.accepted && typeof sig.accepted.network === "string" && typeof sig.accepted.asset === "string") {
|
|
7442
6610
|
return verifyOnchainProof(sig);
|
|
7443
6611
|
}
|
|
7444
|
-
const upto = parseUptoObject(obj);
|
|
6612
|
+
const upto = _chunkOXEFPLZAcjs.parseUptoObject.call(void 0, obj);
|
|
7445
6613
|
if (upto) return verifyUpto(upto);
|
|
7446
|
-
const exact = parseExactObject(obj);
|
|
6614
|
+
const exact = _chunkOXEFPLZAcjs.parseExactObject.call(void 0, obj);
|
|
7447
6615
|
if (exact) return verifyExact(exact);
|
|
7448
6616
|
return asChallenge();
|
|
7449
6617
|
}
|
|
7450
6618
|
function echoPaymentIdentifier(result, id) {
|
|
7451
6619
|
try {
|
|
7452
|
-
const decoded = decodeBase64Json(result.receiptHeader);
|
|
6620
|
+
const decoded = _chunkOXEFPLZAcjs.decodeBase64Json.call(void 0, result.receiptHeader);
|
|
7453
6621
|
if (!decoded) return result;
|
|
7454
6622
|
const { extensions: existing, ...receiptOnly } = decoded;
|
|
7455
6623
|
const merged = {
|
|
7456
6624
|
..._nullishCoalesce(existing, () => ( {})),
|
|
7457
|
-
[EXT_PAYMENT_IDENTIFIER]: { info: { required: false, id } }
|
|
6625
|
+
[_chunkOXEFPLZAcjs.EXT_PAYMENT_IDENTIFIER]: { info: { required: false, id } }
|
|
7458
6626
|
};
|
|
7459
|
-
return { ...result, receiptHeader: buildReceiptHeader(receiptOnly, merged) };
|
|
7460
|
-
} catch (
|
|
6627
|
+
return { ...result, receiptHeader: _chunkOXEFPLZAcjs.buildReceiptHeader.call(void 0, receiptOnly, merged) };
|
|
6628
|
+
} catch (e52) {
|
|
7461
6629
|
return result;
|
|
7462
6630
|
}
|
|
7463
6631
|
}
|
|
7464
6632
|
async function resolveVerdictObject(obj) {
|
|
7465
6633
|
if (!options.paymentIdentifier) return routeVerdictObject(obj);
|
|
7466
|
-
const id = readPaymentIdentifier(obj);
|
|
6634
|
+
const id = _chunkOXEFPLZAcjs.readPaymentIdentifier.call(void 0, obj);
|
|
7467
6635
|
if (id !== null && typeof id === "object") {
|
|
7468
6636
|
return rejection("signature_invalid", `payment-identifier: ${id.invalid}.`);
|
|
7469
6637
|
}
|
|
@@ -7528,7 +6696,7 @@ function requirePayment(options) {
|
|
|
7528
6696
|
return async (req, res, next) => {
|
|
7529
6697
|
let result;
|
|
7530
6698
|
try {
|
|
7531
|
-
result = await gate.verify(_nullishCoalesce(req.headers[HEADER_SIGNATURE], () => ( req.headers[HEADER_SIGNATURE_V1])));
|
|
6699
|
+
result = await gate.verify(_nullishCoalesce(req.headers[_chunkOXEFPLZAcjs.HEADER_SIGNATURE], () => ( req.headers[_chunkOXEFPLZAcjs.HEADER_SIGNATURE_V1])));
|
|
7532
6700
|
} catch (err) {
|
|
7533
6701
|
if (err instanceof _chunkQONQSZHJcjs.SettlementError) {
|
|
7534
6702
|
res.status(502);
|
|
@@ -7545,16 +6713,16 @@ function requirePayment(options) {
|
|
|
7545
6713
|
}
|
|
7546
6714
|
switch (result.kind) {
|
|
7547
6715
|
case "paid":
|
|
7548
|
-
res.setHeader(HEADER_RESPONSE, result.receiptHeader);
|
|
7549
|
-
res.setHeader(HEADER_RESPONSE_V1, result.receiptHeader);
|
|
6716
|
+
res.setHeader(_chunkOXEFPLZAcjs.HEADER_RESPONSE, result.receiptHeader);
|
|
6717
|
+
res.setHeader(_chunkOXEFPLZAcjs.HEADER_RESPONSE_V1, result.receiptHeader);
|
|
7550
6718
|
return next();
|
|
7551
6719
|
case "challenge":
|
|
7552
|
-
res.setHeader(HEADER_REQUIRED, result.requiredHeader);
|
|
6720
|
+
res.setHeader(_chunkOXEFPLZAcjs.HEADER_REQUIRED, result.requiredHeader);
|
|
7553
6721
|
res.status(result.statusCode);
|
|
7554
6722
|
res.json(result.challenge);
|
|
7555
6723
|
return;
|
|
7556
6724
|
case "invalid":
|
|
7557
|
-
res.setHeader(HEADER_REQUIRED, result.requiredHeader);
|
|
6725
|
+
res.setHeader(_chunkOXEFPLZAcjs.HEADER_REQUIRED, result.requiredHeader);
|
|
7558
6726
|
res.status(result.statusCode);
|
|
7559
6727
|
res.json(result.challenge);
|
|
7560
6728
|
return;
|
|
@@ -7592,15 +6760,15 @@ function withSettlementHeaders(res, receiptHeader) {
|
|
|
7592
6760
|
return combined ? [combined] : [];
|
|
7593
6761
|
})();
|
|
7594
6762
|
for (const cookie of cookies) headers.append("set-cookie", cookie);
|
|
7595
|
-
headers.set(HEADER_RESPONSE, receiptHeader);
|
|
7596
|
-
headers.set(HEADER_RESPONSE_V1, receiptHeader);
|
|
6763
|
+
headers.set(_chunkOXEFPLZAcjs.HEADER_RESPONSE, receiptHeader);
|
|
6764
|
+
headers.set(_chunkOXEFPLZAcjs.HEADER_RESPONSE_V1, receiptHeader);
|
|
7597
6765
|
return new Response(res.body, { status: res.status, statusText: res.statusText, headers });
|
|
7598
6766
|
}
|
|
7599
6767
|
function toFetchHandler(gate, serve) {
|
|
7600
6768
|
return async (request, ...rest) => {
|
|
7601
6769
|
let result;
|
|
7602
6770
|
try {
|
|
7603
|
-
const sig = _nullishCoalesce(_nullishCoalesce(request.headers.get(HEADER_SIGNATURE), () => ( request.headers.get(HEADER_SIGNATURE_V1))), () => ( void 0));
|
|
6771
|
+
const sig = _nullishCoalesce(_nullishCoalesce(request.headers.get(_chunkOXEFPLZAcjs.HEADER_SIGNATURE), () => ( request.headers.get(_chunkOXEFPLZAcjs.HEADER_SIGNATURE_V1))), () => ( void 0));
|
|
7604
6772
|
result = await gate.verify(sig);
|
|
7605
6773
|
} catch (err) {
|
|
7606
6774
|
if (err instanceof _chunkQONQSZHJcjs.SettlementError) {
|
|
@@ -7620,7 +6788,7 @@ function toFetchHandler(gate, serve) {
|
|
|
7620
6788
|
const res = await serve(request, ...rest);
|
|
7621
6789
|
return withSettlementHeaders(res, result.receiptHeader);
|
|
7622
6790
|
}
|
|
7623
|
-
return jsonResponse(result.challenge, 402, { [HEADER_REQUIRED]: result.requiredHeader });
|
|
6791
|
+
return jsonResponse(result.challenge, 402, { [_chunkOXEFPLZAcjs.HEADER_REQUIRED]: result.requiredHeader });
|
|
7624
6792
|
};
|
|
7625
6793
|
}
|
|
7626
6794
|
function toWorker(gate, serve) {
|
|
@@ -7632,8 +6800,8 @@ function proxyTo(origin) {
|
|
|
7632
6800
|
const inUrl = new URL(request.url);
|
|
7633
6801
|
const target = base2 + inUrl.pathname + inUrl.search;
|
|
7634
6802
|
const headers = new Headers(request.headers);
|
|
7635
|
-
headers.delete(HEADER_SIGNATURE);
|
|
7636
|
-
headers.delete(HEADER_SIGNATURE_V1);
|
|
6803
|
+
headers.delete(_chunkOXEFPLZAcjs.HEADER_SIGNATURE);
|
|
6804
|
+
headers.delete(_chunkOXEFPLZAcjs.HEADER_SIGNATURE_V1);
|
|
7637
6805
|
const init = {
|
|
7638
6806
|
method: request.method,
|
|
7639
6807
|
headers,
|
|
@@ -7659,7 +6827,7 @@ function isRetryableStatus(status) {
|
|
|
7659
6827
|
}
|
|
7660
6828
|
var sleep = (ms) => ms > 0 ? new Promise((resolve) => setTimeout(resolve, ms)) : Promise.resolve();
|
|
7661
6829
|
async function signBody(secret, body) {
|
|
7662
|
-
const subtle = _optionalChain([globalThis, 'access',
|
|
6830
|
+
const subtle = _optionalChain([globalThis, 'access', _149 => _149.crypto, 'optionalAccess', _150 => _150.subtle]);
|
|
7663
6831
|
if (!subtle) return null;
|
|
7664
6832
|
try {
|
|
7665
6833
|
const enc = new TextEncoder();
|
|
@@ -7669,7 +6837,7 @@ async function signBody(secret, body) {
|
|
|
7669
6837
|
const sig = await subtle.sign("HMAC", key, enc.encode(body));
|
|
7670
6838
|
const hex = Array.from(new Uint8Array(sig)).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
7671
6839
|
return `sha256=${hex}`;
|
|
7672
|
-
} catch (
|
|
6840
|
+
} catch (e53) {
|
|
7673
6841
|
return null;
|
|
7674
6842
|
}
|
|
7675
6843
|
}
|
|
@@ -7729,8 +6897,8 @@ async function deliverReceipt(receipt, options) {
|
|
|
7729
6897
|
const retryable = status === void 0 ? true : isRetryableStatus(status);
|
|
7730
6898
|
const willRetry = !ok && retryable && attempt < maxAttempts;
|
|
7731
6899
|
try {
|
|
7732
|
-
_optionalChain([onAttempt, 'optionalCall',
|
|
7733
|
-
} catch (
|
|
6900
|
+
_optionalChain([onAttempt, 'optionalCall', _151 => _151({ attempt, ok, ...status !== void 0 ? { status } : {}, ...error ? { error } : {}, willRetry })]);
|
|
6901
|
+
} catch (e54) {
|
|
7734
6902
|
}
|
|
7735
6903
|
if (ok) return { delivered: true, attempts: attempt, status };
|
|
7736
6904
|
if (!willRetry) {
|
|
@@ -7818,13 +6986,13 @@ function toA2APaymentFailed(code, detail, receipts = [], network) {
|
|
|
7818
6986
|
};
|
|
7819
6987
|
}
|
|
7820
6988
|
function fromA2APaymentRequired(task) {
|
|
7821
|
-
const meta = _optionalChain([task, 'access',
|
|
7822
|
-
const required = _optionalChain([meta, 'optionalAccess',
|
|
6989
|
+
const meta = _optionalChain([task, 'access', _152 => _152.status, 'optionalAccess', _153 => _153.message, 'optionalAccess', _154 => _154.metadata]);
|
|
6990
|
+
const required = _optionalChain([meta, 'optionalAccess', _155 => _155[A2A_REQUIRED_KEY]]);
|
|
7823
6991
|
if (!required || typeof required !== "object") return null;
|
|
7824
6992
|
return required;
|
|
7825
6993
|
}
|
|
7826
6994
|
function fromA2APaymentPayload(message) {
|
|
7827
|
-
const raw = _optionalChain([message, 'access',
|
|
6995
|
+
const raw = _optionalChain([message, 'access', _156 => _156.metadata, 'optionalAccess', _157 => _157[A2A_PAYLOAD_KEY]]);
|
|
7828
6996
|
if (raw === void 0 || raw === null) return null;
|
|
7829
6997
|
return { raw, taskId: _nullishCoalesce(message.taskId, () => ( "")) };
|
|
7830
6998
|
}
|
|
@@ -7857,7 +7025,7 @@ function createA2APaymentHandler(options) {
|
|
|
7857
7025
|
const ttlMs = _nullishCoalesce(options.taskTtlMs, () => ( maxTimeoutSeconds * 1e3));
|
|
7858
7026
|
const store = _nullishCoalesce(options.taskStore, () => ( defaultTaskStore()));
|
|
7859
7027
|
function appendReceipt(taskId, entry) {
|
|
7860
|
-
const prior = _nullishCoalesce(_optionalChain([store, 'access',
|
|
7028
|
+
const prior = _nullishCoalesce(_optionalChain([store, 'access', _158 => _158.get, 'call', _159 => _159(taskId), 'optionalAccess', _160 => _160.receipts]), () => ( []));
|
|
7861
7029
|
const isDup = "success" in entry && entry.success === true && entry.transaction !== "" && prior.some((r) => "transaction" in r && r.transaction === entry.transaction);
|
|
7862
7030
|
const next = isDup ? prior : [...prior, entry];
|
|
7863
7031
|
const receipts = next.length > MAX_TASK_RECEIPTS ? next.slice(-MAX_TASK_RECEIPTS) : next;
|
|
@@ -7965,11 +7133,11 @@ function createA2APaymentHandler(options) {
|
|
|
7965
7133
|
}
|
|
7966
7134
|
}
|
|
7967
7135
|
function agentCardExtension(opts) {
|
|
7968
|
-
const uri = _optionalChain([opts, 'optionalAccess',
|
|
7136
|
+
const uri = _optionalChain([opts, 'optionalAccess', _161 => _161.version]) === "v0.2" ? A2A_X402_EXTENSION_URI_V02 : A2A_X402_EXTENSION_URI_V01;
|
|
7969
7137
|
return {
|
|
7970
7138
|
uri,
|
|
7971
7139
|
description: "Supports payments using the x402 protocol for on-chain settlement.",
|
|
7972
|
-
..._optionalChain([opts, 'optionalAccess',
|
|
7140
|
+
..._optionalChain([opts, 'optionalAccess', _162 => _162.required]) ? { required: true } : {}
|
|
7973
7141
|
};
|
|
7974
7142
|
}
|
|
7975
7143
|
return { handleMessage, agentCardExtension, gate };
|
|
@@ -7980,7 +7148,7 @@ function singleNetworkOf(challenge) {
|
|
|
7980
7148
|
}
|
|
7981
7149
|
function networkFromPayload(raw) {
|
|
7982
7150
|
const v = raw;
|
|
7983
|
-
if (v && typeof _optionalChain([v, 'access',
|
|
7151
|
+
if (v && typeof _optionalChain([v, 'access', _163 => _163.accepted, 'optionalAccess', _164 => _164.network]) === "string") return v.accepted.network;
|
|
7984
7152
|
if (v && typeof v.network === "string") return v.network;
|
|
7985
7153
|
return void 0;
|
|
7986
7154
|
}
|
|
@@ -8022,7 +7190,7 @@ function toMcpPaymentResponse(content, receipt) {
|
|
|
8022
7190
|
};
|
|
8023
7191
|
}
|
|
8024
7192
|
function fromMcpPayment(params) {
|
|
8025
|
-
const meta = _optionalChain([params, 'optionalAccess',
|
|
7193
|
+
const meta = _optionalChain([params, 'optionalAccess', _165 => _165._meta, 'optionalAccess', _166 => _166[MCP_PAYMENT_META_KEY]]);
|
|
8026
7194
|
return meta == null ? null : meta;
|
|
8027
7195
|
}
|
|
8028
7196
|
function fromMcpPaymentRequired(result) {
|
|
@@ -8031,14 +7199,14 @@ function fromMcpPaymentRequired(result) {
|
|
|
8031
7199
|
if (sc && typeof sc === "object" && typeof sc.x402Version === "number") {
|
|
8032
7200
|
return sc;
|
|
8033
7201
|
}
|
|
8034
|
-
const text = _optionalChain([result, 'access',
|
|
7202
|
+
const text = _optionalChain([result, 'access', _167 => _167.content, 'optionalAccess', _168 => _168[0], 'optionalAccess', _169 => _169.text]);
|
|
8035
7203
|
if (typeof text === "string") {
|
|
8036
7204
|
try {
|
|
8037
7205
|
const parsed = JSON.parse(text);
|
|
8038
7206
|
if (parsed && typeof parsed === "object" && typeof parsed.x402Version === "number") {
|
|
8039
7207
|
return parsed;
|
|
8040
7208
|
}
|
|
8041
|
-
} catch (
|
|
7209
|
+
} catch (e55) {
|
|
8042
7210
|
}
|
|
8043
7211
|
}
|
|
8044
7212
|
return null;
|
|
@@ -8047,7 +7215,7 @@ function isMcpPaymentRequired(result) {
|
|
|
8047
7215
|
return fromMcpPaymentRequired(result) != null;
|
|
8048
7216
|
}
|
|
8049
7217
|
function fromMcpPaymentResponse(result) {
|
|
8050
|
-
const meta = _optionalChain([result, 'optionalAccess',
|
|
7218
|
+
const meta = _optionalChain([result, 'optionalAccess', _170 => _170._meta, 'optionalAccess', _171 => _171[MCP_PAYMENT_RESPONSE_META_KEY]]);
|
|
8051
7219
|
if (!meta || typeof meta !== "object") return null;
|
|
8052
7220
|
return meta;
|
|
8053
7221
|
}
|
|
@@ -8256,4 +7424,10 @@ function createMcpPaymentTool(options) {
|
|
|
8256
7424
|
|
|
8257
7425
|
|
|
8258
7426
|
|
|
8259
|
-
|
|
7427
|
+
|
|
7428
|
+
|
|
7429
|
+
|
|
7430
|
+
|
|
7431
|
+
|
|
7432
|
+
|
|
7433
|
+
exports.A2A_ERROR_KEY = A2A_ERROR_KEY; exports.A2A_EXTENSIONS_HEADER = A2A_EXTENSIONS_HEADER; exports.A2A_PAYLOAD_KEY = A2A_PAYLOAD_KEY; exports.A2A_RECEIPTS_KEY = A2A_RECEIPTS_KEY; exports.A2A_REQUIRED_KEY = A2A_REQUIRED_KEY; exports.A2A_STATUS_KEY = A2A_STATUS_KEY; exports.A2A_X402_EXTENSION_URI_V01 = A2A_X402_EXTENSION_URI_V01; exports.A2A_X402_EXTENSION_URI_V02 = A2A_X402_EXTENSION_URI_V02; exports.BRAND = BRAND; exports.BUILTIN_DENOMS = BUILTIN_DENOMS; exports.CHAINS = CHAINS; exports.ConfirmationTimeoutError = _chunkQONQSZHJcjs.ConfirmationTimeoutError; exports.DEFAULT_EXACT_TRANSFER_METHOD = _chunkOXEFPLZAcjs.DEFAULT_EXACT_TRANSFER_METHOD; exports.DENOM_PRECISION = DENOM_PRECISION; exports.DIRECTORY_INFO = _chunkV2IJ5HUWcjs.DIRECTORY_INFO; exports.EIP3009_TYPES = EIP3009_TYPES; exports.EXACT_NETWORK_SLUGS = EXACT_NETWORK_SLUGS; exports.EXT_OFFER_RECEIPT = _chunkOXEFPLZAcjs.EXT_OFFER_RECEIPT; exports.EXT_PAYMENT_IDENTIFIER = _chunkOXEFPLZAcjs.EXT_PAYMENT_IDENTIFIER; exports.GENERATOR = GENERATOR; exports.HEADER_REQUIRED = _chunkOXEFPLZAcjs.HEADER_REQUIRED; exports.HEADER_RESPONSE = _chunkOXEFPLZAcjs.HEADER_RESPONSE; exports.HEADER_RESPONSE_V1 = _chunkOXEFPLZAcjs.HEADER_RESPONSE_V1; exports.HEADER_SIGNATURE = _chunkOXEFPLZAcjs.HEADER_SIGNATURE; exports.HEADER_SIGNATURE_V1 = _chunkOXEFPLZAcjs.HEADER_SIGNATURE_V1; exports.InsufficientFundsError = _chunkQONQSZHJcjs.InsufficientFundsError; exports.InvalidConfigError = _chunkQONQSZHJcjs.InvalidConfigError; exports.InvalidEnvelopeError = _chunkQONQSZHJcjs.InvalidEnvelopeError; exports.KNOWN_EXACT_TRANSFER_METHODS = _chunkOXEFPLZAcjs.KNOWN_EXACT_TRANSFER_METHODS; exports.KNOWN_FACILITATORS = KNOWN_FACILITATORS; exports.MCP_PAYMENT_META_KEY = MCP_PAYMENT_META_KEY; exports.MCP_PAYMENT_RESPONSE_META_KEY = MCP_PAYMENT_RESPONSE_META_KEY; exports.MaxRetriesExceededError = _chunkQONQSZHJcjs.MaxRetriesExceededError; exports.MissingDriverError = _chunkQONQSZHJcjs.MissingDriverError; exports.MultiChainPayer = MultiChainPayer; exports.NoCompatibleAcceptError = _chunkQONQSZHJcjs.NoCompatibleAcceptError; exports.NonReplayableBodyError = _chunkQONQSZHJcjs.NonReplayableBodyError; exports.PERMIT2_ADDRESS = PERMIT2_ADDRESS; exports.PERMIT2_PROXY_CHAIN_IDS = PERMIT2_PROXY_CHAIN_IDS; exports.PERMIT2_UPTO_WITNESS_TYPES = PERMIT2_UPTO_WITNESS_TYPES; exports.PERMIT2_WITNESS_TYPES = PERMIT2_WITNESS_TYPES; exports.PIPRAIL_AGENT_GUIDE = PIPRAIL_AGENT_GUIDE; exports.POWERED_BY = POWERED_BY; exports.PaymentDeclinedError = _chunkQONQSZHJcjs.PaymentDeclinedError; exports.PaymentTimeoutError = _chunkQONQSZHJcjs.PaymentTimeoutError; exports.PipRailClient = PipRailClient; exports.PipRailError = _chunkQONQSZHJcjs.PipRailError; exports.REGISTER_ATTRIBUTION = _chunkV2IJ5HUWcjs.REGISTER_ATTRIBUTION; exports.RecipientNotReadyError = _chunkQONQSZHJcjs.RecipientNotReadyError; exports.SettlementError = _chunkQONQSZHJcjs.SettlementError; exports.SpendLedger = SpendLedger; exports.UPTO_PROXY_CHAIN_IDS = UPTO_PROXY_CHAIN_IDS; exports.UnknownTokenError = _chunkQONQSZHJcjs.UnknownTokenError; exports.UnsupportedNetworkError = _chunkQONQSZHJcjs.UnsupportedNetworkError; exports.UnsupportedSchemeError = _chunkQONQSZHJcjs.UnsupportedSchemeError; exports.VERIFY_CODE_TO_A2A_ERROR = VERIFY_CODE_TO_A2A_ERROR; exports.WalletRequiredError = _chunkQONQSZHJcjs.WalletRequiredError; exports.WrongChainError = _chunkQONQSZHJcjs.WrongChainError; exports.WrongFamilyError = _chunkQONQSZHJcjs.WrongFamilyError; exports.X402_EXACT_PERMIT2_PROXY = X402_EXACT_PERMIT2_PROXY; exports.X402_UPTO_PERMIT2_PROXY = X402_UPTO_PERMIT2_PROXY; exports.agentGuide = agentGuide; exports.appendAttribution = _chunkV2IJ5HUWcjs.appendAttribution; exports.appendKeywords = _chunkV2IJ5HUWcjs.appendKeywords; exports.buildBazaarExtension = buildBazaarExtension; exports.buildChallengeHeader = _chunkOXEFPLZAcjs.buildChallengeHeader; exports.buildEndpointInfo = buildEndpointInfo; exports.buildExactAuthorization = buildExactAuthorization; exports.buildExactSignatureHeader = _chunkOXEFPLZAcjs.buildExactSignatureHeader; exports.buildMcpPaymentMeta = buildMcpPaymentMeta; exports.buildOpenApi = buildOpenApi; exports.buildPaymentIdentifierAdvertisement = _chunkOXEFPLZAcjs.buildPaymentIdentifierAdvertisement; exports.buildReceiptExtension = _chunkOXEFPLZAcjs.buildReceiptExtension; exports.buildReceiptHeader = _chunkOXEFPLZAcjs.buildReceiptHeader; exports.buildSelfDescription = buildSelfDescription; exports.buildSignatureHeader = _chunkOXEFPLZAcjs.buildSignatureHeader; exports.buildUptoSignatureHeader = _chunkOXEFPLZAcjs.buildUptoSignatureHeader; exports.buildV1PaymentHeader = _chunkOXEFPLZAcjs.buildV1PaymentHeader; exports.buildWellKnownX402 = buildWellKnownX402; exports.buildWellKnownX402Manifest = buildWellKnownX402Manifest; exports.buildX402DnsTxt = buildX402DnsTxt; exports.chainIdForExactNetwork = chainIdForExactNetwork; exports.claim402IndexDomain = _chunkV2IJ5HUWcjs.claim402IndexDomain; exports.classifyChallenge = classifyChallenge; exports.createA2APaymentHandler = createA2APaymentHandler; exports.createMcpPaymentTool = createMcpPaymentTool; exports.createPaymentGate = createPaymentGate; exports.createPaywall = createPaywall; exports.createTipJar = createTipJar; exports.decodeBase64Json = _chunkOXEFPLZAcjs.decodeBase64Json; exports.decorateOutcome = _chunkV2IJ5HUWcjs.decorateOutcome; exports.deliverReceipt = deliverReceipt; exports.denomOf = denomOf; exports.describeChallenge = describeChallenge; exports.discoveryHeaders = discoveryHeaders; exports.eip3009Abi = eip3009Abi; exports.encodeXPaymentHeader = encodeXPaymentHeader; exports.evaluatePolicy = evaluatePolicy; exports.exactTransferMethod = _chunkOXEFPLZAcjs.exactTransferMethod; exports.explainDecline = explainDecline; exports.facilitatorCoverage = facilitatorCoverage; exports.fetchAcross = fetchAcross; exports.firstKeylessFacilitator = firstKeylessFacilitator; exports.formatSpendReport = formatSpendReport; exports.fromA2APaymentPayload = fromA2APaymentPayload; exports.fromA2APaymentRequired = fromA2APaymentRequired; exports.fromMcpPayment = fromMcpPayment; exports.fromMcpPaymentRequired = fromMcpPaymentRequired; exports.fromMcpPaymentResponse = fromMcpPaymentResponse; exports.getDirectoryInfo = _chunkV2IJ5HUWcjs.getDirectoryInfo; exports.isMcpPaymentRequired = isMcpPaymentRequired; exports.isPermit2ProxyChain = isPermit2ProxyChain; exports.isSettleableExactMethod = _chunkOXEFPLZAcjs.isSettleableExactMethod; exports.isUptoProxyChain = isUptoProxyChain; exports.knownFacilitatorsFor = knownFacilitatorsFor; exports.memorySpendStore = _chunkO4UQOZ4Zcjs.memorySpendStore; exports.normalizeNetwork = _chunkV2IJ5HUWcjs.normalizeNetwork; exports.normalizeV1Challenge = _chunkOXEFPLZAcjs.normalizeV1Challenge; exports.parseChallenge = _chunkOXEFPLZAcjs.parseChallenge; exports.parseExactObject = _chunkOXEFPLZAcjs.parseExactObject; exports.parseExactPaymentHeader = _chunkOXEFPLZAcjs.parseExactPaymentHeader; exports.parseExactRequirements = parseExactRequirements; exports.parseFacilitatorSupported = parseFacilitatorSupported; exports.parseReceipt = _chunkOXEFPLZAcjs.parseReceipt; exports.parseReceiptExtension = _chunkOXEFPLZAcjs.parseReceiptExtension; exports.parseSettleResponse = _chunkOXEFPLZAcjs.parseSettleResponse; exports.parseSignatureHeader = _chunkOXEFPLZAcjs.parseSignatureHeader; exports.parseSignatureObject = _chunkOXEFPLZAcjs.parseSignatureObject; exports.parseUptoObject = _chunkOXEFPLZAcjs.parseUptoObject; exports.parseUptoPaymentHeader = _chunkOXEFPLZAcjs.parseUptoPaymentHeader; exports.paymentTools = paymentTools; exports.pickAccept = _chunkOXEFPLZAcjs.pickAccept; exports.planAcross = planAcross; exports.proxyTo = proxyTo; exports.rankResources = _chunkV2IJ5HUWcjs.rankResources; exports.readExactDomain = readExactDomain; exports.readPaymentIdentifier = _chunkOXEFPLZAcjs.readPaymentIdentifier; exports.register402Index = _chunkV2IJ5HUWcjs.register402Index; exports.registerDriver = registerDriver; exports.registerX402Scan = _chunkV2IJ5HUWcjs.registerX402Scan; exports.renderLandingPage = renderLandingPage; exports.requirePayment = requirePayment; exports.resolveChain = resolveChain; exports.scoreResource = _chunkV2IJ5HUWcjs.scoreResource; exports.searchOpenIndexes = _chunkV2IJ5HUWcjs.searchOpenIndexes; exports.settleViaFacilitator = settleViaFacilitator; exports.summarizePlan = summarizePlan; exports.toA2AErrorCode = toA2AErrorCode; exports.toA2APaymentFailed = toA2APaymentFailed; exports.toA2APaymentReceipts = toA2APaymentReceipts; exports.toA2APaymentRequired = toA2APaymentRequired; exports.toFetchHandler = toFetchHandler; exports.toInsufficientFundsError = _chunkQONQSZHJcjs.toInsufficientFundsError; exports.toInvalidBody = toInvalidBody; exports.toMcpPaymentRequired = toMcpPaymentRequired; exports.toMcpPaymentResponse = toMcpPaymentResponse; exports.toWorker = toWorker; exports.verify402IndexDomain = _chunkV2IJ5HUWcjs.verify402IndexDomain;
|