uvd-x402-sdk 2.105.0 → 2.107.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.
Files changed (95) hide show
  1. package/README.md +25 -1
  2. package/dist/adapters/index.js +56 -3
  3. package/dist/adapters/index.js.map +1 -1
  4. package/dist/adapters/index.mjs +56 -3
  5. package/dist/adapters/index.mjs.map +1 -1
  6. package/dist/backend/index.d.mts +1 -1
  7. package/dist/backend/index.d.ts +1 -1
  8. package/dist/backend/index.js +102 -26
  9. package/dist/backend/index.js.map +1 -1
  10. package/dist/backend/index.mjs +102 -26
  11. package/dist/backend/index.mjs.map +1 -1
  12. package/dist/erc8128/index.js +2 -0
  13. package/dist/erc8128/index.js.map +1 -1
  14. package/dist/erc8128/index.mjs +2 -0
  15. package/dist/erc8128/index.mjs.map +1 -1
  16. package/dist/{escrow-contracts-Bf3PU_Ub.d.ts → escrow-contracts-Bbr_osYS.d.ts} +4 -3
  17. package/dist/{escrow-contracts-amyDktMD.d.mts → escrow-contracts-Fa138lPh.d.mts} +4 -3
  18. package/dist/{index-jNJd8jEb.d.mts → index-D9l_j3c-.d.mts} +2 -2
  19. package/dist/{index-CZHgEr58.d.ts → index-DmdTO8VO.d.ts} +2 -2
  20. package/dist/index.d.mts +2 -2
  21. package/dist/index.d.ts +2 -2
  22. package/dist/index.js +96 -22
  23. package/dist/index.js.map +1 -1
  24. package/dist/index.mjs +96 -22
  25. package/dist/index.mjs.map +1 -1
  26. package/dist/providers/algorand/index.js +56 -3
  27. package/dist/providers/algorand/index.js.map +1 -1
  28. package/dist/providers/algorand/index.mjs +56 -3
  29. package/dist/providers/algorand/index.mjs.map +1 -1
  30. package/dist/providers/evm/index.js +56 -3
  31. package/dist/providers/evm/index.js.map +1 -1
  32. package/dist/providers/evm/index.mjs +56 -3
  33. package/dist/providers/evm/index.mjs.map +1 -1
  34. package/dist/providers/near/index.js +56 -3
  35. package/dist/providers/near/index.js.map +1 -1
  36. package/dist/providers/near/index.mjs +56 -3
  37. package/dist/providers/near/index.mjs.map +1 -1
  38. package/dist/providers/solana/index.js +56 -3
  39. package/dist/providers/solana/index.js.map +1 -1
  40. package/dist/providers/solana/index.mjs +56 -3
  41. package/dist/providers/solana/index.mjs.map +1 -1
  42. package/dist/providers/stellar/index.js +56 -3
  43. package/dist/providers/stellar/index.js.map +1 -1
  44. package/dist/providers/stellar/index.mjs +56 -3
  45. package/dist/providers/stellar/index.mjs.map +1 -1
  46. package/dist/providers/sui/index.js +56 -3
  47. package/dist/providers/sui/index.js.map +1 -1
  48. package/dist/providers/sui/index.mjs +56 -3
  49. package/dist/providers/sui/index.mjs.map +1 -1
  50. package/dist/providers/xrpl/index.js +56 -3
  51. package/dist/providers/xrpl/index.js.map +1 -1
  52. package/dist/providers/xrpl/index.mjs +56 -3
  53. package/dist/providers/xrpl/index.mjs.map +1 -1
  54. package/dist/react/index.d.mts +1 -1
  55. package/dist/react/index.d.ts +1 -1
  56. package/dist/react/index.js +56 -3
  57. package/dist/react/index.js.map +1 -1
  58. package/dist/react/index.mjs +56 -3
  59. package/dist/react/index.mjs.map +1 -1
  60. package/dist/react/picker/index.js +54 -3
  61. package/dist/react/picker/index.js.map +1 -1
  62. package/dist/react/picker/index.mjs +54 -3
  63. package/dist/react/picker/index.mjs.map +1 -1
  64. package/dist/reputation/index.d.mts +1159 -0
  65. package/dist/reputation/index.d.ts +1159 -0
  66. package/dist/reputation/index.js +3721 -0
  67. package/dist/reputation/index.js.map +1 -0
  68. package/dist/reputation/index.mjs +3654 -0
  69. package/dist/reputation/index.mjs.map +1 -0
  70. package/dist/utils/index.js +56 -3
  71. package/dist/utils/index.js.map +1 -1
  72. package/dist/utils/index.mjs +56 -3
  73. package/dist/utils/index.mjs.map +1 -1
  74. package/package.json +17 -3
  75. package/src/backend/index.ts +67 -31
  76. package/src/chains/index.ts +56 -4
  77. package/src/index.ts +2 -2
  78. package/src/reputation/README.md +167 -0
  79. package/src/reputation/canonical.ts +76 -0
  80. package/src/reputation/constants.ts +136 -0
  81. package/src/reputation/directory.ts +60 -0
  82. package/src/reputation/errors.ts +108 -0
  83. package/src/reputation/evidence.ts +321 -0
  84. package/src/reputation/governor.ts +389 -0
  85. package/src/reputation/index.ts +144 -0
  86. package/src/reputation/message-ref.ts +63 -0
  87. package/src/reputation/outbox.ts +510 -0
  88. package/src/reputation/payment.ts +490 -0
  89. package/src/reputation/redact.ts +82 -0
  90. package/src/reputation/sign.ts +227 -0
  91. package/src/reputation/sqlite-outbox.ts +244 -0
  92. package/src/reputation/submit.ts +1005 -0
  93. package/src/reputation/validate.ts +372 -0
  94. package/src/reputation/values.ts +106 -0
  95. package/src/types/index.ts +2 -0
package/README.md CHANGED
@@ -10,7 +10,7 @@ Users sign a message or transaction, and the Ultravioleta facilitator handles on
10
10
 
11
11
  ## Features
12
12
 
13
- - **29 Networks**: EVM (17 including Arc, Scroll, SKALE Base, Robinhood Chain), Solana, Fogo, Stellar, NEAR, Algorand, Sui, XRP Ledger, Hedera (mainnet + testnet)
13
+ - **31 Networks**: EVM (19 including HashKey Chain, Arc, Scroll, SKALE Base, Robinhood Chain), Solana, Fogo, Stellar, NEAR, Algorand, Sui, XRP Ledger, Hedera (mainnet + testnet)
14
14
  - **Multi-Stablecoin**: USDC, EURC, AUSD, PYUSD, USDT, USDG (Robinhood Chain)
15
15
  - **x402 v1 & v2**: Protocol auto-detection; native Hedera supports v2/exact only
16
16
  - **Gasless**: Facilitator pays all network fees
@@ -24,6 +24,7 @@ Users sign a message or transaction, and the Ultravioleta facilitator handles on
24
24
  - **Advanced Escrow**: Full escrow lifecycle (authorize, release, refund, charge) with SigningWalletAdapter support
25
25
  - **Escrow Pre-Auth**: Sign-on-assignment `X-Payment-Auth` builder (`buildEscrowPreAuth`) — vector-pinned parity with the Python SDK and Execution Market
26
26
  - **Batch Settlement (buyer)**: `uvd-x402-sdk/batch-settlement` — one ERC-3009 deposit opens a channel, each later request pays with a cumulative voucher; capped deposits, vector-pinned parity with the Python SDK
27
+ - **Reputation (rater-authored ERC-8004)**: `uvd-x402-sdk/reputation` — anchor payment, checked prepare, low-s signatures, a persistent outbox that never prepares twice, caps and a circuit breaker, evidence without chat text; vector-pinned parity with the Python SDK
27
28
  - **Commerce Scheme**: `'commerce'` scheme alias for marketplace integrations (identical to `'escrow'` on-chain)
28
29
  - **`/accepts` Negotiation**: Discover facilitator capabilities before constructing payments
29
30
  - **Bazaar Discovery**: Register and discover paid resources across the x402 network
@@ -707,6 +708,23 @@ if (res.ok) await client.confirm(prepared, settleResponse.extra); // from the PA
707
708
 
708
709
  A deposit is never above `maxDeposit`: the seller's `extra.minDeposit` is a target, and a deposit the next voucher needs above the cap throws `BatchSettlementError` with nothing signed. Only `eip155:*` networks and the ERC-3009 deposit are signed (`assetTransferMethod: 'permit2'` throws). `confirm` records previous cumulative + `chargedAmount` and never copies the seller's `channelState`; a mismatch leaves the local state untouched and resolves to `false`. If the payer may be an EIP-7702 delegated account (a Paybox wallet), pass `delegationResolver` (e.g. `rpcDelegationResolver(rpcUrl)`): the deposit authorization is then wrapped for ERC-1271 when the delegate needs it, and an unreadable chain refuses instead of signing plain. Not included: Permit2 deposits, the cooperative refund and the corrective-402 resync.
709
710
 
711
+ ## Reputation (rater-authored ERC-8004)
712
+
713
+ Ratings the chain records as authored by your program's own rater wallet, relayed by the facilitator, each anchored by a small USDC payment from the rater to the rated wallet. One module for every program, the same contract and shared vectors as the Python SDK's `uvd_x402_sdk.reputation`. Integration in fifteen lines, the money rules, the outbox states and `!forgetme`: [`src/reputation/README.md`](src/reputation/README.md).
714
+
715
+ ```typescript
716
+ import { Erc8004Client } from 'uvd-x402-sdk/backend';
717
+ import { Governor, SqliteRatingOutbox, describeNetHealth, messageRef, processRating } from 'uvd-x402-sdk/reputation';
718
+
719
+ const outbox = new SqliteRatingOutbox(db); // a better-sqlite3 Database (optional peer dependency), synchronous = FULL
720
+ const governor = new Governor(caps, describeNetHealth(), { store: outbox }); // caps: eight parameters, no defaults
721
+ const ref = messageRef('my-app:v1', streamId, messageId);
722
+ await outbox.enqueue({ ref, network: 'base', subject: wallet, streamId, value: 90, amount: 1000, viewerId });
723
+ await processRating(ref, { outbox, governor, client: new Erc8004Client(), rpc, signer, resolveAgent, buildFeedback });
724
+ ```
725
+
726
+ The module never reads a key (it signs through the `signer` you pass), never pays a wallet whose agent it has not resolved and checked, refuses to sign any prepare that is not the exact rating asked for, stores the signed payment before broadcasting it and the signed rating before sending it, and once a rating is signed it only reads the chain until the deadline, and the delegate's own spent-nonce cell in the rater's storage, prove it did not land.
727
+
710
728
  ## Multi-Stablecoin (EVM)
711
729
 
712
730
  ```typescript
@@ -795,6 +813,8 @@ const header = svm.encodePaymentHeader(payload, chainConfig);
795
813
  | Scroll | 534352 | USDC |
796
814
  | SKALE Base | 1187947933 | USDC.e |
797
815
  | SKALE Base Sepolia | 324705682 | USDC.e |
816
+ | HashKey Chain | 177 | USDC |
817
+ | HashKey Chain Testnet | 133 | USDC |
798
818
  | Robinhood Chain | 4663 | USDG |
799
819
  | Robinhood Chain Testnet | 46630 | USDG |
800
820
  | Arc | 5042 | USDC, EURC |
@@ -802,6 +822,8 @@ const header = svm.encodePaymentHeader(payload, chainConfig);
802
822
 
803
823
  > **Arc mainnet and testnet:** payment amounts use 6 decimals. USDC signs with the `USDC` / `2` domain; EURC (`0xbEf5…21c1` mainnet, `0x89B5…D72a` testnet) signs with `EURC` / `2` and its amounts are **euros**, not dollars (`tokenType: 'eurc'`, `usdPegged: false`). Native gas uses 18 decimals on the same balance. Use `arc` / `eip155:5042` for mainnet and `arc-testnet` / `eip155:5042002` for testnet. See [Arc usage and validation](docs/networks/arc.md).
804
824
 
825
+ > **HashKey Chain / USDC:** Use `hashkey` (177) or `hashkey-testnet` (133). Gas is HSK; payments use 6-decimal USDC. Mainnet's EIP-712 name is `Bridged USDC` and testnet's is `USD Coin`, both version `2`. HashKey USDT is unsupported because it has no EIP-3009. [Network configuration and measured domains](docs/networks/hashkey.md).
826
+
805
827
  > **Robinhood Chain / USDG:** Robinhood Chain has no USDC — the settlement stablecoin is Paxos **USDG** (Global Dollar, 6 decimals, EIP-3009). Its on-chain `version()` getter reverts, so the EIP-712 domain `{ name: "Global Dollar", version: "1" }` can never be resolved on-chain. The SDK carries this domain in the chain config; when constructing `PaymentRequirements` yourself, send it in `extra`: `{ "name": "Global Dollar", "version": "1" }`. Use `tokenType: 'usdg'` (or the default, which resolves to USDG on these networks).
806
828
 
807
829
  ### SVM (2)
@@ -864,6 +886,8 @@ getFacilitatorAddress('xrpl-mainnet'); // rfADKk...
864
886
 
865
887
  ## Backend
866
888
 
889
+ Payment headers follow one rule in Express, Hono and `createFetchPaywall`: send `X-PAYMENT`, `PAYMENT-SIGNATURE`, or both with the same value. Names are case-insensitive and surrounding HTTP spaces/tabs are ignored. Distinct values return **400** (`Conflicting payment headers`) before verification or settlement. Empty or malformed payment headers, including payments with no network in either `network` or `accepted.network`, return **400**; absent payment headers return **402**. The extractor returns `null` for invalid or conflicting headers. Standard v2 payments carry their network in `accepted.network`; a top-level string `network` takes precedence when present. Empty or whitespace-padded networks are invalid. Verification and settlement use the same parsed payment, including manual settlement.
890
+
867
891
  ```typescript
868
892
  import {
869
893
  FacilitatorClient,
@@ -36,7 +36,7 @@ var SUPPORTED_CHAINS = {
36
36
  x402: { facilitatorUrl: DEFAULT_FACILITATOR_URL, enabled: true }
37
37
  },
38
38
  // ============================================================================
39
- // EVM CHAINS (16 enabled + BSC, disabled)
39
+ // EVM CHAINS (19 enabled + BSC, disabled)
40
40
  // ============================================================================
41
41
  base: {
42
42
  chainId: 8453,
@@ -441,8 +441,8 @@ var SUPPORTED_CHAINS = {
441
441
  usdt: {
442
442
  address: "0xe7cd86e13AC4309349F30B3435a9d337750fC82D",
443
443
  decimals: 6,
444
- name: "USD\u20AE0",
445
- // USD₮0 (USDT0 omnichain via LayerZero)
444
+ name: "USDT0",
445
+ // ASCII on Monad, unlike USD₮0 on Arbitrum/Optimism (src/usdt-domains.test.ts)
446
446
  version: "1"
447
447
  }
448
448
  },
@@ -594,6 +594,57 @@ var SUPPORTED_CHAINS = {
594
594
  enabled: true
595
595
  }
596
596
  },
597
+ // HashKey Chain: USDC supports EIP-3009; HashKey USDT does not.
598
+ hashkey: {
599
+ chainId: 177,
600
+ chainIdHex: "0xb1",
601
+ name: "hashkey",
602
+ displayName: "HashKey Chain",
603
+ networkType: "evm",
604
+ rpcUrl: "https://mainnet.hsk.xyz",
605
+ explorerUrl: "https://hsk.blockscout.com",
606
+ nativeCurrency: { name: "HashKey", symbol: "HSK", decimals: 18 },
607
+ usdc: {
608
+ address: "0x054ed45810DbBAb8B27668922D110669c9D88D0a",
609
+ decimals: 6,
610
+ name: "Bridged USDC",
611
+ version: "2"
612
+ },
613
+ tokens: {
614
+ usdc: {
615
+ address: "0x054ed45810DbBAb8B27668922D110669c9D88D0a",
616
+ decimals: 6,
617
+ name: "Bridged USDC",
618
+ version: "2"
619
+ }
620
+ },
621
+ x402: { facilitatorUrl: DEFAULT_FACILITATOR_URL, enabled: true }
622
+ },
623
+ "hashkey-testnet": {
624
+ chainId: 133,
625
+ chainIdHex: "0x85",
626
+ name: "hashkey-testnet",
627
+ displayName: "HashKey Chain Testnet",
628
+ networkType: "evm",
629
+ rpcUrl: "https://testnet.hsk.xyz",
630
+ explorerUrl: "https://testnet-explorer.hskchain.net",
631
+ nativeCurrency: { name: "HashKey", symbol: "HSK", decimals: 18 },
632
+ usdc: {
633
+ address: "0x8FE3cB719Ee4410E236Cd6b72ab1fCDC06eF53c6",
634
+ decimals: 6,
635
+ name: "USD Coin",
636
+ version: "2"
637
+ },
638
+ tokens: {
639
+ usdc: {
640
+ address: "0x8FE3cB719Ee4410E236Cd6b72ab1fCDC06eF53c6",
641
+ decimals: 6,
642
+ name: "USD Coin",
643
+ version: "2"
644
+ }
645
+ },
646
+ x402: { facilitatorUrl: DEFAULT_FACILITATOR_URL, enabled: true }
647
+ },
597
648
  // Robinhood Chain (Arbitrum Orbit L2). NOTE: there is NO USDC on this chain -
598
649
  // the settlement stablecoin is Paxos USDG (Global Dollar). The `usdc` field
599
650
  // below carries USDG for interface compatibility (same pattern as XRPL's native
@@ -1156,6 +1207,8 @@ var CAIP2_IDENTIFIERS = {
1156
1207
  scroll: "eip155:534352",
1157
1208
  "skale-base": "eip155:1187947933",
1158
1209
  "skale-base-sepolia": "eip155:324705682",
1210
+ hashkey: "eip155:177",
1211
+ "hashkey-testnet": "eip155:133",
1159
1212
  robinhood: "eip155:4663",
1160
1213
  "robinhood-testnet": "eip155:46630",
1161
1214
  arc: "eip155:5042",