@piprail/sdk 2.3.0 → 2.5.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 CHANGED
@@ -4,6 +4,138 @@ 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
+ ## [2.5.0] — 2026-06-18 — gasless NEAR `exact` rail (NEP-366 meta-transactions)
8
+
9
+ Additive and backward-compatible — defaults and the zero-config 402 stay byte-identical; pure-EVM
10
+ installs still never download a non-EVM library (NEAR + its borsh decoder stay lazy-loaded — verified:
11
+ the built EVM bundle has zero static non-EVM imports, only lazy chunks).
12
+
13
+ ### Added
14
+
15
+ - **NEAR `exact` rail — gasless for the buyer on a fifth family.** PipRail's `exact` scheme now covers
16
+ NEAR (NEP-141 tokens — USDC / USDT) via the ratified
17
+ [`scheme_exact_near`](https://github.com/x402-foundation/x402/blob/main/specs/schemes/exact/scheme_exact_near.md)
18
+ (x402 v2). The buyer signs a **NEP-366 `SignedDelegateAction`** authorizing exactly one `ft_transfer`
19
+ with a **full-access key** and never broadcasts it or holds any NEAR; a relayer wraps it, prepays the
20
+ gas + the 1 yoctoNEAR, and submits — the agent is **completely gasless**. Opt-in
21
+ (`schemes: ['onchain-proof', 'exact']`); native NEAR is **not** exact-payable (the scheme is over
22
+ `ft_transfer`) and stays `onchain-proof`. Proven on NEAR mainnet for both USDC and USDT.
23
+ - New `payExactNear` (buyer build/sign) and `verifyAndSettleExactNear` (seller verify + relay) driver
24
+ functions; `resolveExactRail` / `payExact` / `settleExactSelf` are now implemented for NEAR.
25
+ - **Self-settle today** (`exact: { settle: 'self', relayer: { accountId, key } }`): the merchant runs
26
+ a small funded relayer that pays the sub-cent settle gas — the buyer stays gasless, exactly like the
27
+ Solana / Algorand / Aptos self-settle. The **facilitator** path (`settle: { facilitator }`) is wired
28
+ and will work the moment a real NEAR x402 facilitator ships; **none does yet** (some advertise
29
+ `near:mainnet` in `/supported` without settling it), so `exact: true` deliberately excludes NEAR and
30
+ self-settle is the supported gasless-for-buyer config. See the NEAR chain doc for the caveat.
31
+ - **Sponsor fee-drain guard**: the relayer prepays both the gas and the attached deposit, so the gate
32
+ rejects any delegate whose attached `deposit` ≠ exactly 1 yoctoNEAR or whose `gas` exceeds the
33
+ 300 TGas cap (re-derived from the trusted rail) **before** the relayer signs.
34
+
35
+ ### Dependencies
36
+
37
+ - Added **`borsh` (`>=2 <3`) as an OPTIONAL peer dependency** — used only to decode the inbound NEAR
38
+ `SignedDelegateAction` during self-settle, lazy-loaded inside the NEAR driver. NEAR users already have
39
+ it via `near-api-js`; pure-EVM (and non-NEAR) installs never load it.
40
+
41
+ ## [2.4.0] — 2026-06-17 — gasless Algorand & Aptos rails + keyless gasless on SIX chains (incl. Algorand & BNB)
42
+
43
+ Additive and backward-compatible — defaults and the zero-config 402 stay byte-identical; pure-EVM
44
+ installs still never download a non-EVM library (Algorand and Aptos stay lazy-loaded — verified: the
45
+ built EVM bundle has zero static non-EVM imports, only lazy chunks).
46
+
47
+ ### Added
48
+
49
+ - **Algorand `exact` rail — gasless on a fourth family.** PipRail's `exact` scheme now covers Algorand
50
+ (ASAs) alongside EVM and Solana, via the ratified `scheme_exact_algo`. The buyer signs an ASA
51
+ `axfer` to `payTo` at **fee 0**, atomically grouped with a 0-ALGO `pay` whose pooled fee covers the
52
+ group; the sponsor (the merchant's relayer in self-settle, or a keyless facilitator) signs the fee
53
+ txn and submits — the buyer spends **zero ALGO**. New `payExactAlgorand` / `verifyAndSettleExactAlgorand`
54
+ driver functions; `resolveExactRail` / `payExact` / `settleExactSelf` are now implemented for the
55
+ Algorand family. **Live-proven on Algorand mainnet** (self-settle round-trip, buyer paid 0 ALGO).
56
+ Unlike Solana, **`feePayer === payTo` is allowed** (the fee txn is separate — no isolation rule), so
57
+ a single merchant account can self-settle. Native ALGO stays `onchain-proof`-only.
58
+ - **Aptos `exact` rail — gasless on a fifth family.** PipRail's `exact` scheme now also covers Aptos
59
+ (Fungible Assets), via the ratified `scheme_exact_aptos`. The buyer builds a fee-payer (sponsored,
60
+ AIP-39) `0x1::primary_fungible_store::transfer` to `payTo` and signs **only the sender slot** — spending
61
+ **zero APT**; the sponsor (the merchant's relayer in self-settle, or a keyless facilitator) adds the
62
+ fee-payer signature and submits, paying the sub-cent gas. It's **one-shot** (no gas-station round-trip,
63
+ unlike Sui's sponsorship — which is why Aptos fits PipRail's backendless model and Sui's gasless path
64
+ doesn't). New `payExactAptos` / `verifyAndSettleExactAptos` driver functions; `resolveExactRail` /
65
+ `payExact` / `settleExactSelf` are now implemented for the Aptos family; the seller verifies by
66
+ **decoding the entry function** and binding the FA metadata/recipient/amount to its trusted rail, caps
67
+ the fee payer's gas exposure, and verifies the sender signature off-chain before settling.
68
+ **Live-proven on Aptos mainnet** (self-settle round-trip, buyer paid 0 APT). Like Algorand,
69
+ **`feePayer === payTo` is allowed**. Any Fungible Asset (USDC + USD₮) is gasless; native APT stays
70
+ `onchain-proof`-only.
71
+ - **`exact: true` zero-config gasless now spans SIX chains** — Base, **BNB**, HyperEVM, Monad, Solana,
72
+ and **Algorand** — where a **keyless facilitator sponsors gas for *both* sides** (neither buyer nor
73
+ merchant pays). Each `KNOWN_FACILITATORS` row was added only after a real mainnet keyless settle (THE
74
+ RULE), all 2026-06-17:
75
+ - **Algorand** (`algorand:wGHE2Pwdvd7S12BL5FaOP20EGYesN73ktiC1qzkkit8=`) — **new keyless chain, the
76
+ first non-EVM/non-Solana one**, via **GoPlausible** (the only keyless Algorand x402 facilitator).
77
+ Atomic-group fee pooling: the sponsor pools the whole group fee, so the **buyer AND the merchant both
78
+ pay 0 ALGO** (tx `PDVDVRFGJAG2K6AJ7L26OTSCSRL7AURVKEX4D4KHBAOLNSCYENXA`).
79
+ - **BNB** (`eip155:56`) — **new keyless chain** via **Dexter** + **Pieverse**, settling the EIP-3009
80
+ tokens **FDUSD/USD1** (BNB's Binance-Peg USDC/USDT are Permit2 → not facilitator-settleable; Dexter
81
+ has a ~$0.003 floor). This beats the BNB token-overlap wall that blocks AEON.
82
+ - **Monad** (`eip155:143`) — **Corbits** + **Ultravioleta DAO** + **Pieverse** (3 facilitators).
83
+ - **HyperEVM** (`eip155:999`) — **Ultravioleta DAO**.
84
+ - **Base** (`eip155:8453`) — PayAI + xpay + **Ultravioleta DAO** + **Dexter** + **Corbits** +
85
+ **GoPlausible** (6 facilitators → automatic failover).
86
+ - **Solana** — PayAI + OpenFacilitator + Corbits (SVM).
87
+ Ultravioleta DAO (the broadest endpoint — 18 PipRail networks) is live-validated on **3** chains
88
+ (HyperEVM, Base, Monad); **GoPlausible** on **2** (Algorand, Base). As more chains are funded the same
89
+ sweep seeds them — **9 more EVM chains have a keyless facilitator awaiting funding** (Polygon, Arbitrum,
90
+ Optimism, Avalanche, Ethereum, Celo, Unichain, Scroll, Sei).
91
+ - The `exact` transfer-method union (`ExactRailInfo.method`, `KnownFacilitator.settles`,
92
+ `assetTransferMethod`, the parsed-payment + wire types) now includes **`'algorand'`** and **`'aptos'`**,
93
+ and two new wire payloads are parsed/validated: `ExactAlgorandPaymentPayload` (`{ paymentIndex,
94
+ paymentGroup }`) and `ExactAptosPaymentPayload` (`{ transaction, senderAuth }`).
95
+
96
+ ### Changed
97
+
98
+ - The gate's facilitator-settle path forwards the sponsor `feePayer` for Algorand and Aptos (as it
99
+ already does for Solana), and the replay claim canonicalizes the Algorand `paymentGroup` and the Aptos
100
+ `{ transaction, senderAuth }` (so a base64-malleated re-submission of the same payment can't slip past
101
+ the used-proof set). All additive — EVM/Solana behaviour is unchanged.
102
+ - **Algorand's CAIP-2 is now the FULL 44-char base64 genesis hash**
103
+ (`algorand:wGHE2Pwdvd7S12BL5FaOP20EGYesN73ktiC1qzkkit8=`, was a 32-char prefix) — the exact form the
104
+ ratified x402 Algorand scheme and its facilitators (GoPlausible) use, so a facilitator-settled rail
105
+ interops on the wire and `fetchFacilitatorFeePayer` auto-matches. The on-chain `exact` group is
106
+ **byte-identical** (GoPlausible accepts PipRail's group as-is — the gate already sends the `amount`
107
+ field it needs); self-settle is **behaviour-neutral** (re-proven live on mainnet). Safe because 2.4.0
108
+ is unreleased, so no published version emitted the prefix form.
109
+ - `verifyExact` now matches a v2 `exact` payment's CAIP-2 network **family-agnostically** (any
110
+ `namespace:reference`, not just `eip155:`), so a foreign non-EVM v2 payment (`solana:…`/`algorand:…`/
111
+ `aptos:…`) routes precisely by network on a multi-rail gate instead of relying on the asset filter.
112
+ PipRail's own buyer (which always echoes the asset) is unaffected.
113
+
114
+ ### Security
115
+
116
+ A pre-release adversarial sweep of every `exact` rail found — and this release fixes — a **sponsor
117
+ fee-drain** class on the two rails where the buyer constructs a fee/gas parameter the gate co-signs and
118
+ submits from the sponsor's balance (the keyless facilitator, or the merchant's self-settle relayer). In
119
+ both cases the buyer signs a valid, correctly-bound transfer, so every other check (recipient, amount,
120
+ asset, fee-payer isolation) passed and simulation succeeded — only the fee magnitude was unbounded. Both
121
+ now cap it, mirroring the Aptos rail's existing gas caps. Neither shipped in a released version (the
122
+ Algorand/Aptos rails are new in 2.4.0; the Solana cap hardens a rail first released in 2.x), and both are
123
+ covered by a new red-then-green adversarial test.
124
+
125
+ - **Algorand** (`drivers/algorand/exact.ts`): the seller co-signed the buyer-supplied pooled-fee `pay`
126
+ txn **without bounding its fee**. A malicious buyer could name the sponsor as fee payer and set an
127
+ arbitrarily large fee, draining it for a sub-cent transfer. Fixed with `MAX_GROUP_FEE` (20 000 µALGO,
128
+ ~10× the honest `minFee × 2`).
129
+ - **Solana** (`drivers/solana/exact.ts`): the seller did not bound the **compute-unit limit/price**
130
+ (the priority fee the fee payer pays). A malicious buyer could set a huge `setComputeUnitLimit` ×
131
+ `setComputeUnitPrice` and drain the sponsor's SOL (Solana's max budget makes this multi-SOL per
132
+ request). Fixed with `MAX_COMPUTE_UNIT_LIMIT` (300 000) + `MAX_COMPUTE_UNIT_PRICE_MICROLAMPORTS`
133
+ (100 000), enforced before co-signing — worst case ≈ 0.00003 SOL, vs the canonical 20 000-unit @
134
+ 1-µlamport path.
135
+ - EVM (EIP-3009 / Permit2) and Aptos were reviewed and found **not** exposed: EVM derives gas at
136
+ broadcast (never from the buyer payload), and Aptos already caps gas. The fee-payer drain guards are
137
+ now consistent across all four rails.
138
+
7
139
  ## [2.3.0] — 2026-06-17 — `exact: true` zero-config gasless gate
8
140
 
9
141
  Additive and backward-compatible — defaults and the zero-config 402 stay byte-identical. A new
@@ -1249,6 +1381,8 @@ straight into your wallet. The API is small and self-contained.
1249
1381
  to your wallet; PipRail never holds funds.
1250
1382
  - `viem ^2.21` is a peer dependency. Node 20+ or a modern browser.
1251
1383
 
1384
+ [2.5.0]: https://www.npmjs.com/package/@piprail/sdk
1385
+ [2.4.0]: https://www.npmjs.com/package/@piprail/sdk
1252
1386
  [2.3.0]: https://www.npmjs.com/package/@piprail/sdk
1253
1387
  [2.2.0]: https://www.npmjs.com/package/@piprail/sdk
1254
1388
  [2.1.1]: https://www.npmjs.com/package/@piprail/sdk