@piprail/sdk 3.1.0 → 3.1.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 CHANGED
@@ -4,6 +4,30 @@ 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
+ ## [3.1.1] — 2026-09-09 — XRPL payments work again
8
+
9
+ ### Fixed
10
+
11
+ - **A facilitator's payload rejection answered 5xx instead of 402.** Every non-200 from a
12
+ facilitator's `/verify` was treated as a transport failure, so a **400** — a forged or
13
+ malformed authorization — made the gate return a server error. That tells the buyer "our
14
+ fault, try again" about a payment that can never succeed, and shows in the merchant's metrics
15
+ as an outage they do not have. Now only `400`/`422` (the payload is bad, and only the buyer
16
+ can fix it) reject with the facilitator's own reason; `401`/`403` (our credentials),
17
+ `404` (our URL), `429` and `5xx` stay `SettlementError`, because a buyer can do nothing about
18
+ any of them. Found by tampering with a real authorization on Base.
19
+
20
+ - 🔴 **Every XRPL payment failed.** `ledger_current` is documented to return
21
+ `ledger_current_index`, and rippled does, but the public clusters in front of it answer with
22
+ `ledger_index`. Reading only the documented name returned `undefined`, `undefined + 20` became
23
+ `NaN`, and the transaction died in xrpl.js's serializer. Both names are now accepted, and a
24
+ response carrying neither is refused with a message that says nothing was signed.
25
+
26
+ Latent since XRPL shipped and intermittent by nature: it depends on which backend the cluster
27
+ routes to, which is why the same wallet settled all morning and then could not settle at all.
28
+ Caught by a post-release live sweep against the published package — the pre-flight guard added
29
+ in 3.1.0 is what turned an unreadable serializer error into a sentence naming the field.
30
+
7
31
  ## [3.1.0] — 2026-09-09 — spendable is not held, and a swap refused for no reason
8
32
 
9
33
  ### Fixed
@@ -2642,6 +2666,7 @@ straight into your wallet. The API is small and self-contained.
2642
2666
  [1.5.0]: https://www.npmjs.com/package/@piprail/sdk
2643
2667
  [1.4.0]: https://www.npmjs.com/package/@piprail/sdk
2644
2668
  [1.3.1]: https://www.npmjs.com/package/@piprail/sdk
2669
+ [3.1.1]: https://www.npmjs.com/package/@piprail/sdk
2645
2670
  [3.1.0]: https://www.npmjs.com/package/@piprail/sdk
2646
2671
  [3.0.0]: https://www.npmjs.com/package/@piprail/sdk
2647
2672
  [1.3.0]: https://www.npmjs.com/package/@piprail/sdk
package/dist/index.cjs CHANGED
@@ -2498,7 +2498,7 @@ var loaders = {
2498
2498
  xrpl: async () => {
2499
2499
  let mod;
2500
2500
  try {
2501
- mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./xrpl-G2FKFXRI.cjs")));
2501
+ mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./xrpl-YUGDNI2R.cjs")));
2502
2502
  } catch (cause) {
2503
2503
  throw new (0, _chunk6XTNI2OQcjs.MissingDriverError)(
2504
2504
  `XRPL selected, but its package isn't installed. Run: npm install xrpl`,
@@ -6238,6 +6238,14 @@ async function settleViaFacilitator(input) {
6238
6238
  );
6239
6239
  }
6240
6240
  if (verify.status !== 200) {
6241
+ if (verify.status === 400 || verify.status === 422) {
6242
+ const vr4 = _nullishCoalesce(verify.json, () => ( {}));
6243
+ return {
6244
+ ok: false,
6245
+ error: mapReason(vr4.invalidReason),
6246
+ detail: `Facilitator rejected the payment payload (HTTP ${verify.status})${vr4.invalidReason ? `: ${vr4.invalidReason}` : ""}${vr4.invalidMessage ? ` \u2014 ${vr4.invalidMessage}` : ""}.`
6247
+ };
6248
+ }
6241
6249
  throw new (0, _chunk6XTNI2OQcjs.SettlementError)(
6242
6250
  `exact settle (facilitator ${base2}): /verify returned HTTP ${verify.status} (transport/auth error).`
6243
6251
  );
package/dist/index.js CHANGED
@@ -2498,7 +2498,7 @@ var loaders = {
2498
2498
  xrpl: async () => {
2499
2499
  let mod;
2500
2500
  try {
2501
- mod = await import("./xrpl-5K444RGX.js");
2501
+ mod = await import("./xrpl-WIDRV2XY.js");
2502
2502
  } catch (cause) {
2503
2503
  throw new MissingDriverError(
2504
2504
  `XRPL selected, but its package isn't installed. Run: npm install xrpl`,
@@ -6238,6 +6238,14 @@ async function settleViaFacilitator(input) {
6238
6238
  );
6239
6239
  }
6240
6240
  if (verify.status !== 200) {
6241
+ if (verify.status === 400 || verify.status === 422) {
6242
+ const vr4 = verify.json ?? {};
6243
+ return {
6244
+ ok: false,
6245
+ error: mapReason(vr4.invalidReason),
6246
+ detail: `Facilitator rejected the payment payload (HTTP ${verify.status})${vr4.invalidReason ? `: ${vr4.invalidReason}` : ""}${vr4.invalidMessage ? ` \u2014 ${vr4.invalidMessage}` : ""}.`
6247
+ };
6248
+ }
6241
6249
  throw new SettlementError(
6242
6250
  `exact settle (facilitator ${base2}): /verify returned HTTP ${verify.status} (transport/auth error).`
6243
6251
  );
@@ -745,7 +745,13 @@ function makeXrplNetwork(preset, rpcUrl) {
745
745
  },
746
746
  async currentLedgerIndex() {
747
747
  const r = await rpc("ledger_current", {});
748
- return r.ledger_current_index;
748
+ const index = r.ledger_current_index ?? r.ledger_index;
749
+ if (typeof index !== "number") {
750
+ throw new Error(
751
+ `XRPL: ledger_current returned neither ledger_current_index nor ledger_index (got ${JSON.stringify(Object.keys(r ?? {}))}). Nothing was signed or submitted.`
752
+ );
753
+ }
754
+ return index;
749
755
  },
750
756
  async submit(txBlob) {
751
757
  return rpc("submit", { tx_blob: txBlob });
@@ -745,7 +745,13 @@ function makeXrplNetwork(preset, rpcUrl) {
745
745
  },
746
746
  async currentLedgerIndex() {
747
747
  const r = await rpc("ledger_current", {});
748
- return r.ledger_current_index;
748
+ const index = _nullishCoalesce(r.ledger_current_index, () => ( r.ledger_index));
749
+ if (typeof index !== "number") {
750
+ throw new Error(
751
+ `XRPL: ledger_current returned neither ledger_current_index nor ledger_index (got ${JSON.stringify(Object.keys(_nullishCoalesce(r, () => ( {}))))}). Nothing was signed or submitted.`
752
+ );
753
+ }
754
+ return index;
749
755
  },
750
756
  async submit(txBlob) {
751
757
  return rpc("submit", { tx_blob: txBlob });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@piprail/sdk",
3
- "version": "3.1.0",
3
+ "version": "3.1.1",
4
4
  "description": "Accept x402 crypto payments across 30 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",