@piprail/sdk 1.13.0 → 1.13.1
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 +10 -0
- package/dist/index.cjs +40 -45
- package/dist/index.js +6 -11
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,15 @@ All notable changes to `@piprail/sdk` are documented here. The format
|
|
|
4
4
|
follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and the
|
|
5
5
|
versions follow [Semantic Versioning](https://semver.org/).
|
|
6
6
|
|
|
7
|
+
## [1.13.1] — 2026-06-10
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
- **`register()` visibility is now accurate for a verified domain.** 402 Index returns a structured
|
|
11
|
+
`service.status` — a register from a domain you've verified comes back `'active'`, so the outcome now
|
|
12
|
+
reports `visibility:'live'` instead of the conservative `'pending-review'` default (`decorateOutcome`
|
|
13
|
+
honours a visibility the adapter already set). The `detail` already surfaced 402 Index's own message;
|
|
14
|
+
now `visibility` and `detail` agree.
|
|
15
|
+
|
|
7
16
|
## [1.13.0] — 2026-06-10
|
|
8
17
|
|
|
9
18
|
### Added — gate `discovery` option (one flag → x402scan-listable)
|
|
@@ -615,6 +624,7 @@ straight into your wallet. The API is small and self-contained.
|
|
|
615
624
|
to your wallet; PipRail never holds funds.
|
|
616
625
|
- `viem ^2.21` is a peer dependency. Node 20+ or a modern browser.
|
|
617
626
|
|
|
627
|
+
[1.13.1]: https://www.npmjs.com/package/@piprail/sdk
|
|
618
628
|
[1.13.0]: https://www.npmjs.com/package/@piprail/sdk
|
|
619
629
|
[1.12.0]: https://www.npmjs.com/package/@piprail/sdk
|
|
620
630
|
[1.11.0]: https://www.npmjs.com/package/@piprail/sdk
|
package/dist/index.cjs
CHANGED
|
@@ -1339,7 +1339,7 @@ function getDirectoryInfo(source) {
|
|
|
1339
1339
|
}
|
|
1340
1340
|
function decorateOutcome(o) {
|
|
1341
1341
|
const info = DIRECTORY_INFO[o.source];
|
|
1342
|
-
return { ...o, visibility: o.ok ? info.onSuccess : "not-listable", note: info.caveat };
|
|
1342
|
+
return { ...o, visibility: _nullishCoalesce(o.visibility, () => ( (o.ok ? info.onSuccess : "not-listable"))), note: info.caveat };
|
|
1343
1343
|
}
|
|
1344
1344
|
var BAZAAR_URL = "https://api.cdp.coinbase.com/platform/v2/x402/discovery/resources";
|
|
1345
1345
|
var INDEX402_SEARCH = "https://402index.io/api/v1/services";
|
|
@@ -1495,12 +1495,15 @@ async function register402Index(input) {
|
|
|
1495
1495
|
body: JSON.stringify(payload)
|
|
1496
1496
|
});
|
|
1497
1497
|
if (res.ok) {
|
|
1498
|
-
const
|
|
1498
|
+
const body = await res.json().catch(() => ({}));
|
|
1499
|
+
const msg = typeof body.message === "string" && body.message.length > 0 ? body.message : void 0;
|
|
1500
|
+
const live = _optionalChain([body, 'access', _8 => _8.service, 'optionalAccess', _9 => _9.status]) === "active";
|
|
1499
1501
|
return {
|
|
1500
1502
|
source: "402index",
|
|
1501
1503
|
ok: true,
|
|
1502
1504
|
status: res.status,
|
|
1503
|
-
|
|
1505
|
+
...live ? { visibility: "live" } : {},
|
|
1506
|
+
detail: _nullishCoalesce(msg, () => ( (live ? "Registered + live on 402 Index (domain verified)." : "Registered on 402 Index \u2014 pending review (verify your domain on 402index.io for instant approval).")))
|
|
1504
1507
|
};
|
|
1505
1508
|
}
|
|
1506
1509
|
const why = await readIndexError(res);
|
|
@@ -1514,14 +1517,6 @@ async function register402Index(input) {
|
|
|
1514
1517
|
return { source: "402index", ok: false, detail: errMsg(err) };
|
|
1515
1518
|
}
|
|
1516
1519
|
}
|
|
1517
|
-
async function readIndexMessage(res) {
|
|
1518
|
-
try {
|
|
1519
|
-
const body = await res.json();
|
|
1520
|
-
return typeof body.message === "string" && body.message.length > 0 ? body.message : void 0;
|
|
1521
|
-
} catch (e17) {
|
|
1522
|
-
return void 0;
|
|
1523
|
-
}
|
|
1524
|
-
}
|
|
1525
1520
|
async function readIndexError(res) {
|
|
1526
1521
|
try {
|
|
1527
1522
|
const body = await res.json();
|
|
@@ -1529,7 +1524,7 @@ async function readIndexError(res) {
|
|
|
1529
1524
|
(p) => typeof p === "string" && p.length > 0
|
|
1530
1525
|
);
|
|
1531
1526
|
return parts.length ? [...new Set(parts)].join(" \u2014 ") : void 0;
|
|
1532
|
-
} catch (
|
|
1527
|
+
} catch (e17) {
|
|
1533
1528
|
return void 0;
|
|
1534
1529
|
}
|
|
1535
1530
|
}
|
|
@@ -1639,11 +1634,11 @@ async function readSiwxInfo(res) {
|
|
|
1639
1634
|
try {
|
|
1640
1635
|
const body = await res.json();
|
|
1641
1636
|
const ext = body.extensions;
|
|
1642
|
-
const siwx = _optionalChain([ext, 'optionalAccess',
|
|
1643
|
-
const info = _nullishCoalesce(_optionalChain([siwx, 'optionalAccess',
|
|
1644
|
-
if (info && info.chainId == null && Array.isArray(_optionalChain([siwx, 'optionalAccess',
|
|
1637
|
+
const siwx = _optionalChain([ext, 'optionalAccess', _10 => _10["sign-in-with-x"]]);
|
|
1638
|
+
const info = _nullishCoalesce(_optionalChain([siwx, 'optionalAccess', _11 => _11.info]), () => ( siwx));
|
|
1639
|
+
if (info && info.chainId == null && Array.isArray(_optionalChain([siwx, 'optionalAccess', _12 => _12.supportedChains]))) {
|
|
1645
1640
|
const evm = siwx.supportedChains.find(
|
|
1646
|
-
(c) => typeof _optionalChain([c, 'optionalAccess',
|
|
1641
|
+
(c) => typeof _optionalChain([c, 'optionalAccess', _13 => _13.chainId]) === "string" && c.chainId.startsWith("eip155:")
|
|
1647
1642
|
);
|
|
1648
1643
|
if (evm && typeof evm.chainId === "string") info.chainId = evm.chainId;
|
|
1649
1644
|
}
|
|
@@ -1651,7 +1646,7 @@ async function readSiwxInfo(res) {
|
|
|
1651
1646
|
return info;
|
|
1652
1647
|
}
|
|
1653
1648
|
return null;
|
|
1654
|
-
} catch (
|
|
1649
|
+
} catch (e18) {
|
|
1655
1650
|
return null;
|
|
1656
1651
|
}
|
|
1657
1652
|
}
|
|
@@ -1699,7 +1694,7 @@ function mapRails(accepts) {
|
|
|
1699
1694
|
}
|
|
1700
1695
|
function matchesQuery(r, query) {
|
|
1701
1696
|
const q = query.toLowerCase();
|
|
1702
|
-
return r.resource.toLowerCase().includes(q) || (_nullishCoalesce(_optionalChain([r, 'access',
|
|
1697
|
+
return r.resource.toLowerCase().includes(q) || (_nullishCoalesce(_optionalChain([r, 'access', _14 => _14.name, 'optionalAccess', _15 => _15.toLowerCase, 'call', _16 => _16(), 'access', _17 => _17.includes, 'call', _18 => _18(q)]), () => ( false))) || (_nullishCoalesce(_optionalChain([r, 'access', _19 => _19.description, 'optionalAccess', _20 => _20.toLowerCase, 'call', _21 => _21(), 'access', _22 => _22.includes, 'call', _23 => _23(q)]), () => ( false)));
|
|
1703
1698
|
}
|
|
1704
1699
|
function pickString(o, ...keys) {
|
|
1705
1700
|
for (const k of keys) {
|
|
@@ -1732,7 +1727,7 @@ function hostOf(url) {
|
|
|
1732
1727
|
try {
|
|
1733
1728
|
const withScheme = /^[a-z][a-z0-9+.-]*:\/\//i.test(url) ? url : `https://${url}`;
|
|
1734
1729
|
return new URL(withScheme).hostname || url;
|
|
1735
|
-
} catch (
|
|
1730
|
+
} catch (e19) {
|
|
1736
1731
|
return url;
|
|
1737
1732
|
}
|
|
1738
1733
|
}
|
|
@@ -1843,7 +1838,7 @@ var SpendLedger = (_class = class {constructor() { _class.prototype.__init.call(
|
|
|
1843
1838
|
}
|
|
1844
1839
|
/** Running total (base units) already spent on this (network, asset). */
|
|
1845
1840
|
totalFor(network, asset) {
|
|
1846
|
-
return _nullishCoalesce(_optionalChain([this, 'access',
|
|
1841
|
+
return _nullishCoalesce(_optionalChain([this, 'access', _24 => _24.buckets, 'access', _25 => _25.get, 'call', _26 => _26(keyFor(network, asset)), 'optionalAccess', _27 => _27.total]), () => ( 0n));
|
|
1847
1842
|
}
|
|
1848
1843
|
/** An immutable snapshot of all spend so far. */
|
|
1849
1844
|
summary() {
|
|
@@ -1892,7 +1887,7 @@ var PipRailClient = (_class2 = class {
|
|
|
1892
1887
|
safeEmit(event) {
|
|
1893
1888
|
try {
|
|
1894
1889
|
this.onEvent(event);
|
|
1895
|
-
} catch (
|
|
1890
|
+
} catch (e20) {
|
|
1896
1891
|
}
|
|
1897
1892
|
}
|
|
1898
1893
|
/** Auto-mount the chain's driver, resolve the network, and bind the wallet — once. */
|
|
@@ -1917,7 +1912,7 @@ var PipRailClient = (_class2 = class {
|
|
|
1917
1912
|
* as-is) or a plain object (serialised as JSON).
|
|
1918
1913
|
*/
|
|
1919
1914
|
post(url, body, init) {
|
|
1920
|
-
const headers = new Headers(_optionalChain([init, 'optionalAccess',
|
|
1915
|
+
const headers = new Headers(_optionalChain([init, 'optionalAccess', _28 => _28.headers]));
|
|
1921
1916
|
let payload;
|
|
1922
1917
|
if (body === void 0 || body === null) {
|
|
1923
1918
|
payload = void 0;
|
|
@@ -1948,7 +1943,7 @@ var PipRailClient = (_class2 = class {
|
|
|
1948
1943
|
* "0.05 USDC on Base, within budget → pay it." No funds move.
|
|
1949
1944
|
*/
|
|
1950
1945
|
async quote(url, init) {
|
|
1951
|
-
const res = await fetch(url, { ..._nullishCoalesce(init, () => ( {})), method: _nullishCoalesce(_optionalChain([init, 'optionalAccess',
|
|
1946
|
+
const res = await fetch(url, { ..._nullishCoalesce(init, () => ( {})), method: _nullishCoalesce(_optionalChain([init, 'optionalAccess', _29 => _29.method]), () => ( "GET")) });
|
|
1952
1947
|
if (res.status !== 402) return null;
|
|
1953
1948
|
const { quote } = await this.resolveChallenge(url, res);
|
|
1954
1949
|
return quote;
|
|
@@ -1967,7 +1962,7 @@ var PipRailClient = (_class2 = class {
|
|
|
1967
1962
|
* on Tron, where a USD₮ transfer can cost real TRX.
|
|
1968
1963
|
*/
|
|
1969
1964
|
async estimateCost(url, init) {
|
|
1970
|
-
const res = await fetch(url, { ..._nullishCoalesce(init, () => ( {})), method: _nullishCoalesce(_optionalChain([init, 'optionalAccess',
|
|
1965
|
+
const res = await fetch(url, { ..._nullishCoalesce(init, () => ( {})), method: _nullishCoalesce(_optionalChain([init, 'optionalAccess', _30 => _30.method]), () => ( "GET")) });
|
|
1971
1966
|
if (res.status !== 402) return null;
|
|
1972
1967
|
const { net, accept, quote } = await this.resolveChallenge(url, res);
|
|
1973
1968
|
const cost = await net.estimateCost(accept);
|
|
@@ -1998,7 +1993,7 @@ var PipRailClient = (_class2 = class {
|
|
|
1998
1993
|
* the plan yourself. No funds move.
|
|
1999
1994
|
*/
|
|
2000
1995
|
async planPayment(url, init) {
|
|
2001
|
-
const res = await fetch(url, { ..._nullishCoalesce(init, () => ( {})), method: _nullishCoalesce(_optionalChain([init, 'optionalAccess',
|
|
1996
|
+
const res = await fetch(url, { ..._nullishCoalesce(init, () => ( {})), method: _nullishCoalesce(_optionalChain([init, 'optionalAccess', _31 => _31.method]), () => ( "GET")) });
|
|
2002
1997
|
if (res.status !== 402) return null;
|
|
2003
1998
|
const challenge = await parseChallenge(res);
|
|
2004
1999
|
if (!challenge) {
|
|
@@ -2165,7 +2160,7 @@ var PipRailClient = (_class2 = class {
|
|
|
2165
2160
|
* streams throw `NonReplayableBodyError`.
|
|
2166
2161
|
*/
|
|
2167
2162
|
async fetch(url, init) {
|
|
2168
|
-
const body = _optionalChain([init, 'optionalAccess',
|
|
2163
|
+
const body = _optionalChain([init, 'optionalAccess', _32 => _32.body]);
|
|
2169
2164
|
if (body !== void 0 && body !== null && !isReplayableBodyInit(body)) {
|
|
2170
2165
|
throw new (0, _chunkMDLZJGLYcjs.NonReplayableBodyError)(
|
|
2171
2166
|
"fetch(): init.body is not replayable. Pass a string, FormData, URLSearchParams, ArrayBuffer, or Blob \u2014 not a ReadableStream."
|
|
@@ -2177,7 +2172,7 @@ var PipRailClient = (_class2 = class {
|
|
|
2177
2172
|
const { net, wallet, challenge } = resolved;
|
|
2178
2173
|
let accept = resolved.accept;
|
|
2179
2174
|
let quote = resolved.quote;
|
|
2180
|
-
const autoRoute = _nullishCoalesce(_nullishCoalesce(_optionalChain([init, 'optionalAccess',
|
|
2175
|
+
const autoRoute = _nullishCoalesce(_nullishCoalesce(_optionalChain([init, 'optionalAccess', _33 => _33.autoRoute]), () => ( this.opts.autoRoute)), () => ( false));
|
|
2181
2176
|
if (autoRoute) {
|
|
2182
2177
|
const plan = await this.planFromChallenge(net, wallet, challenge, url);
|
|
2183
2178
|
if (!plan.best) {
|
|
@@ -2339,8 +2334,8 @@ var PipRailClient = (_class2 = class {
|
|
|
2339
2334
|
}
|
|
2340
2335
|
const amountBase = BigInt(accept.amount);
|
|
2341
2336
|
const described = net.describeAsset(accept.asset);
|
|
2342
|
-
const decimals = _nullishCoalesce(_optionalChain([described, 'optionalAccess',
|
|
2343
|
-
const symbol = _nullishCoalesce(_optionalChain([described, 'optionalAccess',
|
|
2337
|
+
const decimals = _nullishCoalesce(_optionalChain([described, 'optionalAccess', _34 => _34.decimals]), () => ( accept.extra.decimals));
|
|
2338
|
+
const symbol = _nullishCoalesce(_optionalChain([described, 'optionalAccess', _35 => _35.symbol]), () => ( accept.extra.symbol));
|
|
2344
2339
|
const amountFormatted = _chunkMDLZJGLYcjs.formatUnits.call(void 0, amountBase, decimals);
|
|
2345
2340
|
const intent = {
|
|
2346
2341
|
host: hostOf2(url),
|
|
@@ -2449,7 +2444,7 @@ var PipRailClient = (_class2 = class {
|
|
|
2449
2444
|
accepted: accept,
|
|
2450
2445
|
payload: { nonce: accept.extra.nonce, txHash: ref }
|
|
2451
2446
|
};
|
|
2452
|
-
const headers = new Headers(_optionalChain([originalInit, 'optionalAccess',
|
|
2447
|
+
const headers = new Headers(_optionalChain([originalInit, 'optionalAccess', _36 => _36.headers]));
|
|
2453
2448
|
headers.set(HEADER_SIGNATURE, buildSignatureHeader(signature));
|
|
2454
2449
|
let lastResponse = null;
|
|
2455
2450
|
let lastReason = null;
|
|
@@ -2464,7 +2459,7 @@ var PipRailClient = (_class2 = class {
|
|
|
2464
2459
|
() => timeoutController.abort(),
|
|
2465
2460
|
this.retryTimeoutMs
|
|
2466
2461
|
);
|
|
2467
|
-
const signal = _optionalChain([originalInit, 'optionalAccess',
|
|
2462
|
+
const signal = _optionalChain([originalInit, 'optionalAccess', _37 => _37.signal]) && typeof AbortSignal.any === "function" ? AbortSignal.any([timeoutController.signal, originalInit.signal]) : timeoutController.signal;
|
|
2468
2463
|
try {
|
|
2469
2464
|
lastResponse = await fetch(url, {
|
|
2470
2465
|
..._nullishCoalesce(originalInit, () => ( {})),
|
|
@@ -2504,7 +2499,7 @@ var PipRailClient = (_class2 = class {
|
|
|
2504
2499
|
function safeBig(s) {
|
|
2505
2500
|
try {
|
|
2506
2501
|
return BigInt(s);
|
|
2507
|
-
} catch (
|
|
2502
|
+
} catch (e21) {
|
|
2508
2503
|
return 0n;
|
|
2509
2504
|
}
|
|
2510
2505
|
}
|
|
@@ -2537,10 +2532,10 @@ function buildFundingHint(options, chainLabel) {
|
|
|
2537
2532
|
return `Couldn't fully read your wallet on ${chainLabel} (RPC throttled) \u2014 retry; you may already be able to pay ${target.quote.amountFormatted} ${sym}.`;
|
|
2538
2533
|
}
|
|
2539
2534
|
const parts = [];
|
|
2540
|
-
if (target.blockers.includes("INSUFFICIENT_TOKEN") && _optionalChain([target, 'access',
|
|
2535
|
+
if (target.blockers.includes("INSUFFICIENT_TOKEN") && _optionalChain([target, 'access', _38 => _38.shortfall, 'optionalAccess', _39 => _39.token])) {
|
|
2541
2536
|
parts.push(`top up ${target.shortfall.token} ${sym}`);
|
|
2542
2537
|
}
|
|
2543
|
-
if (target.blockers.includes("INSUFFICIENT_GAS") && _optionalChain([target, 'access',
|
|
2538
|
+
if (target.blockers.includes("INSUFFICIENT_GAS") && _optionalChain([target, 'access', _40 => _40.shortfall, 'optionalAccess', _41 => _41.native])) {
|
|
2544
2539
|
parts.push(`add ~${target.shortfall.native} ${target.cost.feeSymbol} for gas`);
|
|
2545
2540
|
}
|
|
2546
2541
|
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}.`;
|
|
@@ -2554,7 +2549,7 @@ async function planAcross(clients, url, init) {
|
|
|
2554
2549
|
const status = best ? "ready" : options.some((o) => o.state === "unknown") ? "unknown" : "blocked";
|
|
2555
2550
|
return {
|
|
2556
2551
|
url,
|
|
2557
|
-
network: _nullishCoalesce(_optionalChain([best, 'optionalAccess',
|
|
2552
|
+
network: _nullishCoalesce(_optionalChain([best, 'optionalAccess', _42 => _42.accept, 'access', _43 => _43.network]), () => ( live[0].network)),
|
|
2558
2553
|
status,
|
|
2559
2554
|
payable: best !== null,
|
|
2560
2555
|
best,
|
|
@@ -2570,7 +2565,7 @@ function railOnNetwork(rail, matches) {
|
|
|
2570
2565
|
function hostOf2(url) {
|
|
2571
2566
|
try {
|
|
2572
2567
|
return new URL(url).hostname;
|
|
2573
|
-
} catch (
|
|
2568
|
+
} catch (e22) {
|
|
2574
2569
|
return url;
|
|
2575
2570
|
}
|
|
2576
2571
|
}
|
|
@@ -2587,8 +2582,8 @@ function isReplayableBodyInit(value) {
|
|
|
2587
2582
|
async function readInvalidReason(response) {
|
|
2588
2583
|
try {
|
|
2589
2584
|
const body = await response.clone().json();
|
|
2590
|
-
const ext = _optionalChain([body, 'optionalAccess',
|
|
2591
|
-
const piprail = _optionalChain([ext, 'optionalAccess',
|
|
2585
|
+
const ext = _optionalChain([body, 'optionalAccess', _44 => _44.extensions]);
|
|
2586
|
+
const piprail = _optionalChain([ext, 'optionalAccess', _45 => _45.piprail]);
|
|
2592
2587
|
if (piprail && typeof piprail.code === "string") {
|
|
2593
2588
|
return {
|
|
2594
2589
|
error: piprail.code,
|
|
@@ -2601,7 +2596,7 @@ async function readInvalidReason(response) {
|
|
|
2601
2596
|
detail: typeof body.detail === "string" ? body.detail : ""
|
|
2602
2597
|
};
|
|
2603
2598
|
}
|
|
2604
|
-
} catch (
|
|
2599
|
+
} catch (e23) {
|
|
2605
2600
|
}
|
|
2606
2601
|
return null;
|
|
2607
2602
|
}
|
|
@@ -2612,7 +2607,7 @@ async function readBody(res) {
|
|
|
2612
2607
|
if (!text) return null;
|
|
2613
2608
|
try {
|
|
2614
2609
|
return JSON.parse(text);
|
|
2615
|
-
} catch (
|
|
2610
|
+
} catch (e24) {
|
|
2616
2611
|
return text;
|
|
2617
2612
|
}
|
|
2618
2613
|
}
|
|
@@ -2858,7 +2853,7 @@ function buildBazaarExtension(descriptor = {}) {
|
|
|
2858
2853
|
function pathOf(url) {
|
|
2859
2854
|
try {
|
|
2860
2855
|
return new URL(url).pathname || "/";
|
|
2861
|
-
} catch (
|
|
2856
|
+
} catch (e25) {
|
|
2862
2857
|
return url.startsWith("/") ? url : `/${url}`;
|
|
2863
2858
|
}
|
|
2864
2859
|
}
|
|
@@ -2931,7 +2926,7 @@ async function post(url, body, headers) {
|
|
|
2931
2926
|
let json = null;
|
|
2932
2927
|
try {
|
|
2933
2928
|
json = await res.json();
|
|
2934
|
-
} catch (
|
|
2929
|
+
} catch (e26) {
|
|
2935
2930
|
}
|
|
2936
2931
|
return { status: res.status, json };
|
|
2937
2932
|
}
|
|
@@ -3156,7 +3151,7 @@ function createPaymentGate(options) {
|
|
|
3156
3151
|
const specs = await ready();
|
|
3157
3152
|
const nonce = genNonce();
|
|
3158
3153
|
const bazaar = options.discovery ? { bazaar: buildBazaarExtension(options.discovery === true ? {} : options.discovery) } : void 0;
|
|
3159
|
-
const extensions = { ...bazaar, ..._optionalChain([opts, 'optionalAccess',
|
|
3154
|
+
const extensions = { ...bazaar, ..._optionalChain([opts, 'optionalAccess', _46 => _46.extensions]) };
|
|
3160
3155
|
const challenge2 = {
|
|
3161
3156
|
x402Version: 2,
|
|
3162
3157
|
resource: {
|
|
@@ -3164,7 +3159,7 @@ function createPaymentGate(options) {
|
|
|
3164
3159
|
...options.description ? { description: options.description } : {}
|
|
3165
3160
|
},
|
|
3166
3161
|
accepts: buildAccepts(specs, nonce),
|
|
3167
|
-
..._optionalChain([opts, 'optionalAccess',
|
|
3162
|
+
..._optionalChain([opts, 'optionalAccess', _47 => _47.error]) ? { error: opts.error } : {},
|
|
3168
3163
|
...Object.keys(extensions).length > 0 ? { extensions } : {}
|
|
3169
3164
|
};
|
|
3170
3165
|
return { challenge: challenge2, requiredHeader: buildChallengeHeader(challenge2) };
|
|
@@ -3187,7 +3182,7 @@ function createPaymentGate(options) {
|
|
|
3187
3182
|
if (options.onPaid) {
|
|
3188
3183
|
try {
|
|
3189
3184
|
options.onPaid(receipt);
|
|
3190
|
-
} catch (
|
|
3185
|
+
} catch (e27) {
|
|
3191
3186
|
}
|
|
3192
3187
|
}
|
|
3193
3188
|
}
|
package/dist/index.js
CHANGED
|
@@ -1339,7 +1339,7 @@ function getDirectoryInfo(source) {
|
|
|
1339
1339
|
}
|
|
1340
1340
|
function decorateOutcome(o) {
|
|
1341
1341
|
const info = DIRECTORY_INFO[o.source];
|
|
1342
|
-
return { ...o, visibility: o.ok ? info.onSuccess : "not-listable", note: info.caveat };
|
|
1342
|
+
return { ...o, visibility: o.visibility ?? (o.ok ? info.onSuccess : "not-listable"), note: info.caveat };
|
|
1343
1343
|
}
|
|
1344
1344
|
var BAZAAR_URL = "https://api.cdp.coinbase.com/platform/v2/x402/discovery/resources";
|
|
1345
1345
|
var INDEX402_SEARCH = "https://402index.io/api/v1/services";
|
|
@@ -1495,12 +1495,15 @@ async function register402Index(input) {
|
|
|
1495
1495
|
body: JSON.stringify(payload)
|
|
1496
1496
|
});
|
|
1497
1497
|
if (res.ok) {
|
|
1498
|
-
const
|
|
1498
|
+
const body = await res.json().catch(() => ({}));
|
|
1499
|
+
const msg = typeof body.message === "string" && body.message.length > 0 ? body.message : void 0;
|
|
1500
|
+
const live = body.service?.status === "active";
|
|
1499
1501
|
return {
|
|
1500
1502
|
source: "402index",
|
|
1501
1503
|
ok: true,
|
|
1502
1504
|
status: res.status,
|
|
1503
|
-
|
|
1505
|
+
...live ? { visibility: "live" } : {},
|
|
1506
|
+
detail: msg ?? (live ? "Registered + live on 402 Index (domain verified)." : "Registered on 402 Index \u2014 pending review (verify your domain on 402index.io for instant approval).")
|
|
1504
1507
|
};
|
|
1505
1508
|
}
|
|
1506
1509
|
const why = await readIndexError(res);
|
|
@@ -1514,14 +1517,6 @@ async function register402Index(input) {
|
|
|
1514
1517
|
return { source: "402index", ok: false, detail: errMsg(err) };
|
|
1515
1518
|
}
|
|
1516
1519
|
}
|
|
1517
|
-
async function readIndexMessage(res) {
|
|
1518
|
-
try {
|
|
1519
|
-
const body = await res.json();
|
|
1520
|
-
return typeof body.message === "string" && body.message.length > 0 ? body.message : void 0;
|
|
1521
|
-
} catch {
|
|
1522
|
-
return void 0;
|
|
1523
|
-
}
|
|
1524
|
-
}
|
|
1525
1520
|
async function readIndexError(res) {
|
|
1526
1521
|
try {
|
|
1527
1522
|
const body = await res.json();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@piprail/sdk",
|
|
3
|
-
"version": "1.13.
|
|
3
|
+
"version": "1.13.1",
|
|
4
4
|
"description": "Accept x402 crypto payments across 29 chains — every major EVM chain plus Solana, TON, Tron, NEAR, Sui, Aptos, Algorand, Stellar & XRPL — in a couple of lines. No backend, no database, no fee; payments settle straight to your wallet.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|