@piprail/sdk 2.4.0 → 2.6.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/dist/index.js CHANGED
@@ -1396,7 +1396,7 @@ function chainIdFromNetwork(network) {
1396
1396
  const match = /^eip155:(\d+)$/.exec(network);
1397
1397
  if (!match || !match[1]) return null;
1398
1398
  const n = Number(match[1]);
1399
- return Number.isSafeInteger(n) ? n : null;
1399
+ return Number.isSafeInteger(n) && n > 0 ? n : null;
1400
1400
  }
1401
1401
  function buildChallengeHeader(challenge) {
1402
1402
  return toBase64Json(challenge);
@@ -1469,6 +1469,9 @@ function parseExactPaymentHeader(value) {
1469
1469
  const x402Version = typeof v.x402Version === "number" ? v.x402Version : 2;
1470
1470
  const asset = accepted && typeof accepted.asset === "string" ? accepted.asset : void 0;
1471
1471
  const base2 = { x402Version, network, ...asset ? { asset } : {}, raw: v };
1472
+ if (typeof payload.signedDelegateAction === "string") {
1473
+ return { ...base2, method: "near", payload: { signedDelegateAction: payload.signedDelegateAction } };
1474
+ }
1472
1475
  if (typeof payload.transaction === "string" && typeof payload.senderAuth === "string") {
1473
1476
  return { ...base2, method: "aptos", payload: { transaction: payload.transaction, senderAuth: payload.senderAuth } };
1474
1477
  }
@@ -1810,6 +1813,9 @@ function makeEvmNetwork(resolved) {
1810
1813
  if ("paymentGroup" in payload) {
1811
1814
  return { ok: false, error: "signature_invalid", detail: "An Algorand payload was submitted to an EVM exact rail." };
1812
1815
  }
1816
+ if ("signedDelegateAction" in payload) {
1817
+ return { ok: false, error: "signature_invalid", detail: "A NEAR payload was submitted to an EVM exact rail." };
1818
+ }
1813
1819
  return verifyAndSettleExactEvm({
1814
1820
  publicClient,
1815
1821
  walletClient: a.walletClient,
@@ -1906,7 +1912,7 @@ var loaders = {
1906
1912
  near: async () => {
1907
1913
  let mod;
1908
1914
  try {
1909
- mod = await import("./near-MTYBCUYM.js");
1915
+ mod = await import("./near-OTPQD6BI.js");
1910
1916
  } catch (cause) {
1911
1917
  throw new MissingDriverError(
1912
1918
  `NEAR selected, but its package isn't installed. Run: npm install near-api-js`,
@@ -3242,7 +3248,7 @@ var PipRailClient = class {
3242
3248
  );
3243
3249
  if (schemes.includes("exact") && exactOnNet && typeof net.payExact !== "function") {
3244
3250
  throw new UnsupportedSchemeError(
3245
- `This 402 offers a standard 'exact' rail on ${net.network}, but the ${net.family} family can't pay 'exact' (supported on EVM, Solana + Algorand today), and no 'onchain-proof' rail was offered.`
3251
+ `This 402 offers a standard 'exact' rail on ${net.network}, but the ${net.family} family can't pay 'exact' (supported on EVM, Solana, Algorand + NEAR today), and no 'onchain-proof' rail was offered.`
3246
3252
  );
3247
3253
  }
3248
3254
  if (!schemes.includes("exact") && exactOnNet && typeof net.payExact === "function") {
@@ -3638,7 +3644,7 @@ var PipRailClient = class {
3638
3644
  async payExactRail(net, wallet, accept, url, init, quote) {
3639
3645
  if (!net.payExact) {
3640
3646
  throw new UnsupportedSchemeError(
3641
- `the ${net.family} family can't pay a standard 'exact' rail (supported on EVM, Solana + Algorand today).`
3647
+ `the ${net.family} family can't pay a standard 'exact' rail (supported on EVM, Solana, Algorand + NEAR today).`
3642
3648
  );
3643
3649
  }
3644
3650
  throwIfAborted(init?.signal);
@@ -4956,6 +4962,20 @@ var KNOWN_FACILITATORS = {
4956
4962
  schemes: ["exact"],
4957
4963
  settles: ["eip3009"],
4958
4964
  note: "GoPlausible \u2014 keyless, sponsors gas (Base USDC EIP-3009). LIVE-settled on Base 2026-06-17 (tx 0x9bcbc1f01fe1fd1aed2a79e5582555164cc4185e9800189df378a6b46eb9c59e). 2nd GoPlausible validation chain (after Algorand)."
4965
+ },
4966
+ {
4967
+ url: "https://facilitator.cascade.fyi",
4968
+ keyless: true,
4969
+ schemes: ["exact"],
4970
+ settles: ["eip3009"],
4971
+ note: "Cascade \u2014 keyless, sponsors gas (Base USDC EIP-3009). LIVE-settled on Base 2026-06-18 (tx 0x2e784725f3c66e170720cc8df43a9248f02ad80914fcbe05dadbdbe411c3b52b)."
4972
+ },
4973
+ {
4974
+ url: "https://facilitator.bitcoinsapi.com",
4975
+ keyless: true,
4976
+ schemes: ["exact"],
4977
+ settles: ["eip3009"],
4978
+ note: "Satoshi (bitcoinsapi) \u2014 keyless, sponsors gas (Base USDC EIP-3009). LIVE-settled on Base 2026-06-18 (tx 0xbb2b6c354b12c6d07cce91e2b337e38327d4b0833bbd1dfbeda3ad495b67b819)."
4959
4979
  }
4960
4980
  ],
4961
4981
  // Monad (eip155:143). Corbits + Ultravioleta DAO each keyless-settle the EVM EIP-3009 exact rail
@@ -5018,6 +5038,139 @@ var KNOWN_FACILITATORS = {
5018
5038
  note: "Ultravioleta DAO \u2014 keyless, 100% gas-sponsored (HyperEVM native USDC EIP-3009). LIVE-settled on HyperEVM 2026-06-17 (tx 0x56af8148a92a291f0ce362e250919f7742074e5464ac0f315ad68abaec93bd0a)."
5019
5039
  }
5020
5040
  ],
5041
+ // ── gasless-extension (2026-06-18): 7 more EVM mainnets, each LIVE-settled by us — a real EIP-3009
5042
+ // exact payment with the buyer holding ZERO native (so PROVABLY gasless), funded self-service by
5043
+ // bridging USDC in (LI.FI/Eco/Relay), never a /supported read. Dexter enforces a ~$0.004 dynamic
5044
+ // floor on some chains (we cleared it at $0.005); UVD has no floor (100%-sponsors) but its sponsor
5045
+ // contract is NOT deployed on every chain it advertises (Avalanche/Celo/Scroll → contract_call_failed,
5046
+ // left UNSEEDED — the NEAR lesson: advertising ≠ settling).
5047
+ // Ethereum L1 (eip155:1) — UVD (no floor, sponsors L1 gas). 2nd keyless ETH option vs Primev, which
5048
+ // rejected PipRail's exact as unsupported_scheme.
5049
+ "eip155:1": [
5050
+ {
5051
+ url: "https://facilitator.ultravioletadao.xyz",
5052
+ keyless: true,
5053
+ schemes: ["exact"],
5054
+ settles: ["eip3009"],
5055
+ note: "Ultravioleta DAO \u2014 keyless, 100% gas-sponsored (Ethereum native USDC EIP-3009; no settlement floor). LIVE-settled on Ethereum mainnet 2026-06-18 (tx 0x7fcc3cafdf43c52888f0117cde633eff35371f832dfb8dbd84e6fd7704ae5cfc)."
5056
+ }
5057
+ ],
5058
+ // Polygon PoS (eip155:137) — FIVE keyless facilitators (the broadest after Base), all live-settled.
5059
+ "eip155:137": [
5060
+ {
5061
+ url: "https://facilitator.payai.network",
5062
+ keyless: true,
5063
+ schemes: ["exact"],
5064
+ settles: ["eip3009"],
5065
+ note: "PayAI \u2014 keyless, sponsors gas (Polygon native USDC EIP-3009). LIVE-settled on Polygon 2026-06-18 (tx 0xb37630871504618c4db35e8ef0edd3c99deac102b143b7e5eb738c03fb13a619)."
5066
+ },
5067
+ {
5068
+ url: "https://x402.polygon.technology",
5069
+ keyless: true,
5070
+ schemes: ["exact"],
5071
+ settles: ["eip3009"],
5072
+ note: "Polygon Labs (the official Polygon facilitator) \u2014 keyless, sponsors gas. LIVE-settled on Polygon 2026-06-18 (tx 0x6a8ca60ea111959a61a85ad6c4f2ed99e192052ec7b9ffb59baa33691a86f419)."
5073
+ },
5074
+ {
5075
+ url: "https://facilitator.corbits.dev",
5076
+ keyless: true,
5077
+ schemes: ["exact"],
5078
+ settles: ["eip3009"],
5079
+ note: "Corbits (Faremeter) \u2014 keyless, sponsors gas. LIVE-settled on Polygon 2026-06-18 (tx 0x2fadca2ee3cd7fcff32d015e8b06109de6b747d7cd0f80dcd8fb022b2d58d008)."
5080
+ },
5081
+ {
5082
+ url: "https://facilitator.ultravioletadao.xyz",
5083
+ keyless: true,
5084
+ schemes: ["exact"],
5085
+ settles: ["eip3009"],
5086
+ note: "Ultravioleta DAO \u2014 keyless, 100% gas-sponsored. LIVE-settled on Polygon 2026-06-18 (tx 0x0922cd78f3b7c35cc294cf0c0d9b7609e6596eb337be0d197fa5fc511eacba34)."
5087
+ },
5088
+ {
5089
+ url: "https://x402.dexter.cash",
5090
+ keyless: true,
5091
+ schemes: ["exact"],
5092
+ settles: ["eip3009"],
5093
+ note: "Dexter \u2014 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)."
5094
+ }
5095
+ ],
5096
+ // Arbitrum One (eip155:42161) — PayAI + UVD + Dexter.
5097
+ "eip155:42161": [
5098
+ {
5099
+ url: "https://facilitator.payai.network",
5100
+ keyless: true,
5101
+ schemes: ["exact"],
5102
+ settles: ["eip3009"],
5103
+ note: "PayAI \u2014 keyless, sponsors gas (Arbitrum native USDC EIP-3009). LIVE-settled on Arbitrum 2026-06-18 (tx 0x4c7fbfb37ef087bb9bc8872b1b2b0b83ea7ca4cf6b50bc883e51f9b85be61199)."
5104
+ },
5105
+ {
5106
+ url: "https://facilitator.ultravioletadao.xyz",
5107
+ keyless: true,
5108
+ schemes: ["exact"],
5109
+ settles: ["eip3009"],
5110
+ note: "Ultravioleta DAO \u2014 keyless, 100% gas-sponsored. LIVE-settled on Arbitrum 2026-06-18 (tx 0xd1fa7e6ffbd59502bba5809ce181d7936749b93a45c8c2277b4f6d8638326dec)."
5111
+ },
5112
+ {
5113
+ url: "https://x402.dexter.cash",
5114
+ keyless: true,
5115
+ schemes: ["exact"],
5116
+ settles: ["eip3009"],
5117
+ note: "Dexter \u2014 keyless, sponsors gas; ~$0.004 dynamic floor. LIVE-settled on Arbitrum 2026-06-18 at $0.005 (tx 0x0993d51b3859dfd7e8d5b2af709ce64f01ff34ed14bfef665dbb340e7373d599)."
5118
+ }
5119
+ ],
5120
+ // Optimism (eip155:10) — Dexter + UVD.
5121
+ "eip155:10": [
5122
+ {
5123
+ url: "https://x402.dexter.cash",
5124
+ keyless: true,
5125
+ schemes: ["exact"],
5126
+ settles: ["eip3009"],
5127
+ note: "Dexter \u2014 keyless, sponsors gas; ~$0.004 dynamic floor. LIVE-settled on Optimism 2026-06-18 at $0.005 (tx 0x98b282a5dd698054eff4900ff8547170d4f7605b51140c55147fc5ae485f81da)."
5128
+ },
5129
+ {
5130
+ url: "https://facilitator.ultravioletadao.xyz",
5131
+ keyless: true,
5132
+ schemes: ["exact"],
5133
+ settles: ["eip3009"],
5134
+ note: "Ultravioleta DAO \u2014 keyless, 100% gas-sponsored. LIVE-settled on Optimism 2026-06-18 (tx 0xdd91dfdf12bed2d196e37fa1dea9a0da71a97e3c39a0ec0ed114be6a9af22837)."
5135
+ }
5136
+ ],
5137
+ // Avalanche C-Chain (eip155:43114) — PayAI + Dexter. (UVD advertises it but contract_call_failed → unseeded.)
5138
+ "eip155:43114": [
5139
+ {
5140
+ url: "https://facilitator.payai.network",
5141
+ keyless: true,
5142
+ schemes: ["exact"],
5143
+ settles: ["eip3009"],
5144
+ note: "PayAI \u2014 keyless, sponsors gas (Avalanche native USDC EIP-3009). LIVE-settled on Avalanche 2026-06-18 (tx 0x6a1307bc48a157de236ea03440ea2cb6ad4f27e22dd9c89a4345b4c3edb270c7)."
5145
+ },
5146
+ {
5147
+ url: "https://x402.dexter.cash",
5148
+ keyless: true,
5149
+ schemes: ["exact"],
5150
+ settles: ["eip3009"],
5151
+ note: "Dexter \u2014 keyless, sponsors gas (no floor hit at $0.001 here). LIVE-settled on Avalanche 2026-06-18 (tx 0xb2263e9a4ea3917eee6acabcb454d42a50264fdd69a0781ed8fcaec5590e264b)."
5152
+ }
5153
+ ],
5154
+ // Sei (eip155:1329) — PayAI (the only keyless facilitator that lists Sei).
5155
+ "eip155:1329": [
5156
+ {
5157
+ url: "https://facilitator.payai.network",
5158
+ keyless: true,
5159
+ schemes: ["exact"],
5160
+ settles: ["eip3009"],
5161
+ note: "PayAI \u2014 keyless, sponsors gas (Sei native USDC EIP-3009). LIVE-settled on Sei 2026-06-18 (tx 0xde63679b64749cb59625527e5c7682503c851d66b9b8b8ba217ed7b099461312)."
5162
+ }
5163
+ ],
5164
+ // Unichain (eip155:130) — UVD (the only keyless facilitator that lists Unichain).
5165
+ "eip155:130": [
5166
+ {
5167
+ url: "https://facilitator.ultravioletadao.xyz",
5168
+ keyless: true,
5169
+ schemes: ["exact"],
5170
+ settles: ["eip3009"],
5171
+ note: "Ultravioleta DAO \u2014 keyless, 100% gas-sponsored (Unichain native USDC EIP-3009). LIVE-settled on Unichain 2026-06-18 (tx 0xf8bf4a9a200f24159ac67c6315c30b194257999d7da21471b39d5f2cc32b2236)."
5172
+ }
5173
+ ],
5021
5174
  // Algorand (mainnet, CAIP-2 = full base64 genesis hash). GoPlausible keyless-settles the ratified
5022
5175
  // x402 Algorand `exact` rail (atomic-group fee pooling): its sponsor pools the whole group fee and
5023
5176
  // submits, so NEITHER the buyer NOR the merchant pays ALGO — both-sides gasless. LIVE-settled by us
@@ -5061,6 +5214,17 @@ var KNOWN_FACILITATORS = {
5061
5214
  note: "Corbits \u2014 keyless, Solana-first fee-payer sponsor. LIVE-settled on Solana 2026-06-15 (tx BCreYer\u2026)."
5062
5215
  }
5063
5216
  ]
5217
+ // NEAR (near:mainnet) — DELIBERATELY UNSEEDED: no x402 facilitator settles NEAR yet.
5218
+ // The NEAR `exact` BUYER payload PipRail builds (drivers/near/exact.ts) is LIVE-PROVEN on mainnet —
5219
+ // a real NEP-366 meta-transaction settles a USDC/USDT ft_transfer gaslessly (buyer 0 NEAR, single-use
5220
+ // via the access-key nonce; relay txs CMnQJzrLvwk… USDT + BCCnVHbSCMY… USDC, 2026-06-18). What's
5221
+ // missing is the FACILITATOR side: the public x402-rs (which Ultravioleta DAO runs) has NO NEAR chain
5222
+ // crate (only eip155/solana/aptos), and UVD's `/verify` 400s on a near:mainnet request even though its
5223
+ // `/supported` ADVERTISES `near:mainnet` + feePayer `uvd-facilitator.near` — i.e. the listing is
5224
+ // aspirational, not settle-capable (verified 2026-06-18). So `exact: true` must NOT auto-pick a NEAR
5225
+ // facilitator. Seed here ONLY after a real keyless settle through a facilitator that actually
5226
+ // implements scheme_exact_near.md (THE RULE). Merchants can still pass an explicit
5227
+ // `exact: { settle: { facilitator } }` for any facilitator they've confirmed settles near:mainnet.
5064
5228
  };
5065
5229
  function knownFacilitatorsFor(network) {
5066
5230
  return KNOWN_FACILITATORS[network] ?? [];
@@ -5476,6 +5640,12 @@ function createPaymentGate(options) {
5476
5640
  return t;
5477
5641
  }
5478
5642
  }).join("|");
5643
+ } else if ("signedDelegateAction" in exact.payload) {
5644
+ try {
5645
+ nonce = Buffer.from(exact.payload.signedDelegateAction, "base64").toString("base64");
5646
+ } catch {
5647
+ nonce = exact.payload.signedDelegateAction;
5648
+ }
5479
5649
  } else if ("permit2Authorization" in exact.payload) {
5480
5650
  evmAuth = exact.payload.permit2Authorization;
5481
5651
  nonce = evmAuth.nonce;
@@ -5494,7 +5664,7 @@ function createPaymentGate(options) {
5494
5664
  result = await spec.net.settleExactSelf({ relayer: mode.relayer, payload: exact.payload, accept });
5495
5665
  } else {
5496
5666
  const ftMethod = accept.extra.assetTransferMethod;
5497
- const needsFeePayer = ftMethod === "svm" || ftMethod === "algorand" || ftMethod === "aptos";
5667
+ const needsFeePayer = ftMethod === "svm" || ftMethod === "algorand" || ftMethod === "aptos" || ftMethod === "near";
5498
5668
  if (needsFeePayer && !accept.extra.feePayer) {
5499
5669
  throw new SettlementError(
5500
5670
  `exact settle: the ${ftMethod} facilitator rail is missing extra.feePayer (the gas sponsor) \u2014 cannot settle.`