@0xio/sdk 2.7.1 → 2.8.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
@@ -2,19 +2,53 @@
2
2
 
3
3
  All notable changes to the 0xio Wallet SDK will be documented in this file.
4
4
 
5
+ ## [2.8.0] - 2026-06-09
6
+
7
+ ### Added
8
+
9
+ - **Generic provider passthrough**: `wallet.request(method, params)` sends any method through the bridge, so dapps can reach wallet primitives without an SDK upgrade.
10
+ - **Typed RFP private primitives** (thin helpers over the bridge; the wallet keeps all private/FHE secret material internal and returns only ciphertexts/proofs/tx-hashes):
11
+ - `getPrivateCapabilities()`: feature-detect supported private capabilities so a dapp renders the right UI or fails closed.
12
+ - `callContractView()`, `getPrivateBalance()`
13
+ - `encryptValue()`, `decryptValue()`
14
+ - `makeZeroProof()`: returns `{ proof, commitment, blinding, encoding }` (the Octra bound-proof scheme needs the commitment+blinding alongside the proof).
15
+ - `makeRangeProof()`: returns `{ proof, encoding }` (self-contained).
16
+ - `registerPrivateViewKey()`, `sendContractTransactionSequence()`
17
+ - Internal bridge method names: `get_private_capabilities`, `encrypt_value`, `decrypt_value`, `make_zero_proof`, `make_range_proof`, `get_private_balance`, `register_private_view_key`, `send_contract_transaction_sequence`.
18
+ - **0xio Signed Message standard + verification**: `wallet.signMessage` is domain-separated: the wallet signs `"Octra Signed Message:\n<byteLength>\n<message>"` so a signed message can never be a transaction pre-image. New `verifyMessage(message, signature, publicKey)` (Web Crypto Ed25519, zero-dep), `getSignedMessageBytes(message)` to verify with any Ed25519 library, and `buildAuthMessage(service, nonce, origin)` for `signAuthMessage`. Note: verifiers of raw-message signatures must adopt the framing.
19
+
20
+ ### Changed
21
+
22
+ - **Amounts are documented the way the wallet counts them.** `sendTransaction`, `signTransaction` and `callContract` have always passed `amount` to the wallet unchanged, and the wallet reads it as raw micro-OCT (1 OCT = 1000000), not OCT as the docs said. Nothing on the wire changes: whatever a dapp sends today still goes through as is. A new `amountOct` field takes OCT and converts it exactly; `sendPrivateTransfer` gains `amountRaw` for the same reason in the other direction. Pass one or the other.
23
+ - **Permission names match the wallet.** The wallet enforces `accounts`, `public_transactions`, `contract_calls`, `contract_views`, `private_balance_read`, `private_proofs`, `private_transfers` and `private_claims`, and dropped every other name, so dapps asking for `view_private_balance` or `stealth_claim` never received the private scopes. The SDK now translates the older names when it connects and returns them as aliases next to the granted scopes, so existing checks keep working. `WALLET_PERMISSIONS`, `LEGACY_PERMISSION_MAP`, `toWalletPermissions` and `withLegacyAliases` are exported.
24
+ - `sendPrivateTransfer` waits up to 10 minutes: the wallet builds proofs after the approval.
25
+ - `switchNetwork` and everything that signs or submits need a connected page; the wallet now refuses them otherwise with `NOT_CONNECTED`.
26
+ - The RFC-O-1 adapter maps the 2.8.0 primitives to their `octra_*` names, so they work over `window.octra` too.
27
+
28
+ ### Fixed
29
+
30
+ - `getPublicKey()` exists. The docs and the signing example called it, but the wallet class had no such method.
31
+ - `rpcCall(method, params)` wraps the wallet's read-only node RPC allow-list; a bare `request('octra_balance')` is not a wallet method.
32
+ - `transactionFailed` events reach the dapp; they were filtered out.
33
+ - `ErrorCode` includes the codes the wallet actually returns (`NOT_CONNECTED`, `INVALID_PARAMS`, `NOT_AVAILABLE`, `PRIVATE_PROOF_FAILED` and the rest).
34
+ - `encryptValue` and `makeZeroProof` result types include the `commitment` (and `blinding`) the wallet returns.
35
+ - `encryptBalance` and `decryptBalance` are marked deprecated: the 0xio extension answers `NOT_AVAILABLE`.
36
+ - The built-in devnet entry points at `https://devnet.octrascan.io`; the old direct IP is dead.
37
+ - `PendingPrivateTransfer` documents what the wallet really returns (`id` and a raw `amount`).
38
+
5
39
  ## [2.7.1] - 2026-05-27
6
40
 
7
41
  ### Security
8
42
 
9
43
  - **LOW (re-assessed from HIGH):** Removed `this.config.networkId` silent fallback in `connect()` and `getConnectionStatus()`. If neither `networkInfo` nor `networkId` can be resolved from the response, `connect()` now throws `NETWORK_ERROR` and `getConnectionStatus()` returns cached state. The current extension always returns valid `networkInfo`; this hardens against malformed responses from custom or future adapters.
10
- - **MED-1:** Added `SDKConfig.trustedParentOrigins` when set, only listed origins (+ `tauri://`) are trusted as parent iframe bridges; implicit localhost trust is disabled. Omitting the field keeps existing dev-friendly behavior.
11
- - **LOW-2:** `validateNetworkInfo()` now rejects `http://` `rpcUrl` values on non-testnet networks. Testnet networks (`isTestnet: true`) and localhost are unaffected. Prevents a malicious bridge from injecting an insecure RPC endpoint.
12
- - **LOW-19:** `encryptBalance()`, `decryptBalance()`, `sendPrivateTransfer()`, and `callContract()` now throw `INVALID_AMOUNT` when a numeric amount cannot be represented exactly in micro-OCT (6 decimal places). Pass a string (e.g. `"0.300000"`) for exact control.
13
- - **LOW-28 (docs):** `ContractCallData.amount` JSDoc corrected field is OCT, not micro-units. No behavior change.
44
+ - Added `SDKConfig.trustedParentOrigins`: when set, only listed origins (+ `tauri://`) are trusted as parent iframe bridges; implicit localhost trust is disabled. Omitting the field keeps existing dev-friendly behavior.
45
+ - `validateNetworkInfo()` now rejects `http://` `rpcUrl` values on non-testnet networks. Testnet networks (`isTestnet: true`) and localhost are unaffected. Prevents a malicious bridge from injecting an insecure RPC endpoint.
46
+ - `encryptBalance()`, `decryptBalance()`, `sendPrivateTransfer()`, and `callContract()` now throw `INVALID_AMOUNT` when a numeric amount cannot be represented exactly in micro-OCT (6 decimal places). Pass a string (e.g. `"0.300000"`) for exact control.
47
+ - **Docs:** `ContractCallData.amount` JSDoc corrected: field is OCT, not micro-units. No behavior change.
14
48
 
15
49
  ### Added
16
50
 
17
- - **`OctraProviderAdapter`** (`src/supports/octra-provider.ts`): RFC-O-1 compliant transport adapter that uses `window.octra.request()` instead of the postMessage bridge. Detects any wallet exposing `window.octra.isOctra === true`. Translates SDK method names to RFC-O-1 method names (`send_transaction` `octra_sendTransaction`, etc.) and maps events back to SDK vocabulary. Registered second in the adapter registry existing DApps using the postMessage bridge are unaffected.
51
+ - **`OctraProviderAdapter`** (`src/supports/octra-provider.ts`): RFC-O-1 compliant transport adapter that uses `window.octra.request()` instead of the postMessage bridge. Detects any wallet exposing `window.octra.isOctra === true`. Translates SDK method names to RFC-O-1 method names (`send_transaction` to `octra_sendTransaction`, etc.) and maps events back to SDK vocabulary. Registered second in the adapter registry: existing DApps using the postMessage bridge are unaffected.
18
52
  - **`listenForReady`** in `OctraProviderAdapter` now also listens for `octra#initialized` CustomEvent (dispatched by 0xio extension v2.4.3+) in addition to `octraWalletReady`, ensuring the provider is detected immediately on page load.
19
53
 
20
54
  ### Fixed
@@ -23,7 +57,7 @@ All notable changes to the 0xio Wallet SDK will be documented in this file.
23
57
 
24
58
  ### Compatibility
25
59
 
26
- - No breaking changes `ZeroXIOAdapter` (postMessage bridge) remains the default and takes priority when `window.wallet0xio` is present
60
+ - No breaking changes: `ZeroXIOAdapter` (postMessage bridge) remains the default and takes priority when `window.wallet0xio` is present
27
61
  - Old DApps work unchanged; new DApps can opt into `OctraProviderAdapter` explicitly or via `detectWalletAdapter()`
28
62
  - Requires 0xio Wallet Extension v2.4.3+ for `octra#initialized` event; falls back to `octraWalletReady` on older versions
29
63
 
@@ -32,18 +66,18 @@ All notable changes to the 0xio Wallet SDK will be documented in this file.
32
66
  ### Security (post-audit remediation)
33
67
 
34
68
  **Transport hardening:**
35
- - Session nonce validation on all bridge responses blocks same-origin impersonation
36
- - Removed wildcard `'*'` postMessage fallback parent only addressed once origin established
37
- - Removed `Math.random()` fallback for request IDs throws if `crypto` unavailable
69
+ - Session nonce validation on all bridge responses: blocks same-origin impersonation
70
+ - Removed wildcard `'*'` postMessage fallback: parent only addressed once origin established
71
+ - Removed `Math.random()` fallback for request IDs: throws if `crypto` unavailable
38
72
  - `requestTimestamps` capped to prevent unbounded growth in idle tabs
39
73
  - Removed legacy `octraWalletReady` listeners and `createOctraWallet` alias
40
74
 
41
75
  ### Added
42
76
 
43
77
  - **Pluggable wallet adapter system** (`src/adapter.ts`, `src/supports/`):
44
- - `WalletTransportAdapter` interface add support for any wallet without touching core SDK
45
- - `src/supports/0xio.ts` built-in adapter with session nonce + iframe bridge support
46
- - `src/supports/template.ts` starter template for new adapters
78
+ - `WalletTransportAdapter` interface: add support for any wallet without touching core SDK
79
+ - `src/supports/0xio.ts`: built-in adapter with session nonce + iframe bridge support
80
+ - `src/supports/template.ts`: starter template for new adapters
47
81
  - `detectWalletAdapter()` auto-detect helper
48
82
  - Exported: `WalletTransportAdapter`, `AdapterRequest`, `AdapterIncomingMessage`, `ZeroXIOAdapter`, `createZeroXIOAdapter`, `detectWalletAdapter`, `getAllAdapters`
49
83
 
@@ -55,24 +89,24 @@ All notable changes to the 0xio Wallet SDK will be documented in this file.
55
89
  - No breaking changes to `ZeroXIOWallet` public API
56
90
 
57
91
  **SDK fixes:**
58
- - Session versioning `_sessionVersion` counter prevents stale writes from in-flight requests after disconnect/account switch
59
- - Debug log scrubbing only non-sensitive fields logged (`{ to }`, `{ contract, method }`, `{ public }`)
92
+ - Session versioning: `_sessionVersion` counter prevents stale writes from in-flight requests after disconnect/account switch
93
+ - Debug log scrubbing: only non-sensitive fields logged (`{ to }`, `{ contract, method }`, `{ public }`)
60
94
  - Removed `retry()` and `withTimeout()` from public API export
61
- - Per-method payload size limits method names ≤ 200 chars, params ≤ 64 KB, memos ≤ 1,000 chars
95
+ - Per-method payload size limits: method names ≤ 200 chars, params ≤ 64 KB, memos ≤ 1,000 chars
62
96
  - Input validation at all mutating method entry points (`isValidAddress()`, `isValidAmount()`)
63
- - Added `signAuthMessage(service, nonce)` domain-separated auth signing with origin binding
64
- - Amount types accept `string | number` eliminates JS precision loss for large values
65
- - Added `deriveOctraAddress(publicKeyBase64)` `connect()` and `getConnectionStatus()` verify pubkeyaddr binding
97
+ - Added `signAuthMessage(service, nonce)`: domain-separated auth signing with origin binding
98
+ - Amount types accept `string | number`: eliminates JS precision loss for large values
99
+ - Added `deriveOctraAddress(publicKeyBase64)`: `connect()` and `getConnectionStatus()` verify pubkey to addr binding
66
100
  - `encrypt/decryptBalance()` return full `TransactionResult` (was boolean)
67
101
  - `contractCallView` no longer leaks connected address as default caller
68
102
  - `balanceChanged` emits on public/private split change (not just total)
69
- - `once()` removes listener before invoke throwing listeners no longer re-fire
103
+ - `once()` removes listener before invoke: throwing listeners no longer re-fire
70
104
  - `extensionLocked`/`extensionUnlocked` events emitted (were suppressed)
71
105
  - Permissions stored in `ConnectionInfo` and survive session restore
72
106
  - `connectedAt` preserved across `getConnectionStatus()` polls
73
- - `connect` event only emits on disconnectedconnected transition
107
+ - `connect` event only emits on disconnected to connected transition
74
108
  - `NETWORKS` frozen + `getNetworkConfig()` returns frozen copies
75
- - `validateBalance()` uses `Number()` not `parseFloat()` rejects partial numerics
109
+ - `validateBalance()` uses `Number()` not `parseFloat()`: rejects partial numerics
76
110
  - `validateNetworkInfo()` rejects empty rpcUrl (except custom network)
77
111
  - `switchNetwork()` requires active connection
78
112
  - `checkSDKCompatibility()` no longer falsely flags non-Chrome transports
@@ -85,7 +119,7 @@ All notable changes to the 0xio Wallet SDK will be documented in this file.
85
119
  - **`claimPrivateTransfer(transferId)`**: Claim a pending private transfer, adding it to the wallet's encrypted balance.
86
120
 
87
121
  ### Changed
88
- - Privacy transfer methods no longer return NOT_AVAILABLE fully wired to extension v2.4.0+
122
+ - Privacy transfer methods no longer return NOT_AVAILABLE: fully wired to extension v2.4.0+
89
123
  - Updated JSDoc for all privacy methods with PVAC flow description
90
124
 
91
125
  ### Compatibility
@@ -96,7 +130,7 @@ All notable changes to the 0xio Wallet SDK will be documented in this file.
96
130
  ## [2.5.0] - 2026-05-10
97
131
 
98
132
  ### Added
99
- - **`switchNetwork(networkId)`**: Silently switch the extension's active network without opening the popup. Works like Rabby's `wallet_switchEthereumChain` DApps can detect network mismatch and offer one-click switch.
133
+ - **`switchNetwork(networkId)`**: Silently switch the extension's active network without opening the popup. Works like Rabby's `wallet_switchEthereumChain`: DApps can detect network mismatch and offer one-click switch.
100
134
  - **`getNetworkId()`**: Returns the extension's current network ID ('mainnet' or 'devnet').
101
135
  - DApps can now detect + switch network programmatically, enabling network-aware UIs.
102
136
 
@@ -116,7 +150,7 @@ All notable changes to the 0xio Wallet SDK will be documented in this file.
116
150
  ### Changed
117
151
  - **Connect response enriched**: Extension now returns `networkInfo` (id, name, rpcUrl, color, isTestnet) and `permissions` array in both fresh connect and reconnect responses.
118
152
  - **Network info complete**: `getNetworkInfo` response now includes `explorerUrl`, `explorerAddressUrl`, `indexerUrl`, `supportsPrivacy`, `isTestnet` fields.
119
- - **networkInfo fallback chain**: SDK tries `result.networkInfo` `getNetworkConfig(result.networkId)` `getNetworkConfig(this.config.networkId)`.
153
+ - **networkInfo fallback chain**: SDK tries `result.networkInfo`, then `getNetworkConfig(result.networkId)`, then `getNetworkConfig(this.config.networkId)`.
120
154
 
121
155
  ### Compatibility
122
156
  - Requires 0xio Wallet Extension v2.3.5+ for full alignment
@@ -192,7 +226,7 @@ All notable changes to the 0xio Wallet SDK will be documented in this file.
192
226
  - Extension content script messages continue to use strict origin validation
193
227
 
194
228
  ### Compatibility
195
- - Fully backward compatible extension-based DApps work unchanged
229
+ - Fully backward compatible: extension-based DApps work unchanged
196
230
  - Desktop (0xio Desktop): DApps loaded in BrowserScreen iframe now auto-connect
197
231
  - Mobile (0xio App): DApps loaded in WebView browser now auto-connect via existing bridge
198
232
  - Mainnet Alpha: Extension v2.0.1+
@@ -203,7 +237,7 @@ All notable changes to the 0xio Wallet SDK will be documented in this file.
203
237
  ## [2.3.0] - 2026-03-10
204
238
 
205
239
  ### Added
206
- - **Smart Contract Interaction**: New `callContract()` method for state-changing contract calls. The extension builds, signs, and submits via `octra_submit` works on both mainnet and devnet.
240
+ - **Smart Contract Interaction**: New `callContract()` method for state-changing contract calls. The extension builds, signs, and submits via `octra_submit`: works on both mainnet and devnet.
207
241
  - **Contract View Calls**: New `contractCallView()` method for read-only contract queries. No wallet unlock or approval popup required.
208
242
  - **Contract Storage**: New `getContractStorage()` method to read contract storage by key directly from the chain.
209
243
  - **New Types**: `ContractCallData`, `ContractViewCallData`, and `ContractParams` for type-safe contract interaction.
@@ -256,13 +290,13 @@ All notable changes to the 0xio Wallet SDK will be documented in this file.
256
290
  ### Added
257
291
  - **Transaction Finality**: New `TransactionFinality` type (`'pending' | 'confirmed' | 'rejected'`) and `finality` field on `TransactionResult` and `Transaction` interfaces.
258
292
  - **RPC Error Codes**: 7 new `ErrorCode` entries for RPC-level transaction errors from `octra_submit` and `octra_submitBatch`:
259
- - `MALFORMED_TRANSACTION` Transaction is malformed
260
- - `SELF_TRANSFER` Cannot transfer to yourself
261
- - `SENDER_NOT_FOUND` Sender address not found
262
- - `INVALID_SIGNATURE` Invalid transaction signature
263
- - `DUPLICATE_TRANSACTION` Duplicate transaction detected
264
- - `NONCE_TOO_FAR` Transaction nonce is too far ahead
265
- - `INTERNAL_ERROR` Internal server error
293
+ - `MALFORMED_TRANSACTION`: Transaction is malformed
294
+ - `SELF_TRANSFER`: Cannot transfer to yourself
295
+ - `SENDER_NOT_FOUND`: Sender address not found
296
+ - `INVALID_SIGNATURE`: Invalid transaction signature
297
+ - `DUPLICATE_TRANSACTION`: Duplicate transaction detected
298
+ - `NONCE_TOO_FAR`: Transaction nonce is too far ahead
299
+ - `INTERNAL_ERROR`: Internal server error
266
300
  - **Error Messages**: All new error codes have corresponding human-readable messages in `createErrorMessage()`.
267
301
 
268
302
  ### Fixed
@@ -340,8 +374,8 @@ All notable changes to the 0xio Wallet SDK will be documented in this file.
340
374
 
341
375
  ### Breaking Changes
342
376
  - **Rebranded message sources**: Changed from `octra-sdk-*` to `0xio-sdk-*` for consistency with 0xio branding
343
- - `octra-sdk-request` `0xio-sdk-request`
344
- - `octra-sdk-bridge` `0xio-sdk-bridge`
377
+ - `octra-sdk-request` to `0xio-sdk-request`
378
+ - `octra-sdk-bridge` to `0xio-sdk-bridge`
345
379
  - This is a breaking change that requires wallet extension v2.0+ for compatibility
346
380
 
347
381
  ### Changed
@@ -349,7 +383,7 @@ All notable changes to the 0xio Wallet SDK will be documented in this file.
349
383
  - Changed author from "NullxGery" to "0xio Team"
350
384
  - Updated author email from "0xgery@proton.me" to "team@0xio.xyz"
351
385
  - Updated repository URL from `0xGery/0xio-sdk` to `0xio-xyz/0xio-sdk`
352
- - Updated keywords: "0xio" "0xio wallet", added "octra wallet"
386
+ - Updated keywords: "0xio" to "0xio wallet", added "octra wallet"
353
387
  - Author URL changed to organization: `https://github.com/0xio-xyz`
354
388
 
355
389
  ### Migration Guide
@@ -408,8 +442,8 @@ This is the first stable release of the 0xio Wallet SDK, a comprehensive bridge
408
442
  - **Professional code refactoring**: All files now include comprehensive JSDoc documentation
409
443
 
410
444
  ### Package Changes
411
- - **Package renamed**: `@0xgery/wallet-sdk` `@0xio/sdk`
412
- - **Version bump**: 0.2.1 1.0.0 (production-ready)
445
+ - **Package renamed**: `@0xgery/wallet-sdk` to `@0xio/sdk`
446
+ - **Version bump**: 0.2.1 to 1.0.0 (production-ready)
413
447
  - **Repository**: Published to https://github.com/0xGery/0xio-sdk
414
448
  - **Homepage**: https://0xio.xyz
415
449
 
@@ -425,7 +459,7 @@ This is the first stable release of the 0xio Wallet SDK, a comprehensive bridge
425
459
  - Complete integration examples (React, Vue, Vanilla JS)
426
460
 
427
461
  ### Technical Improvements
428
- - **JSDoc coverage**: 0% 95%
462
+ - **JSDoc coverage**: 0% to 95%
429
463
  - **Code quality**: Refactored all functions to <30 lines
430
464
  - **Error handling**: Enhanced with detailed context and diagnostics
431
465
  - **TypeScript**: Full type safety with comprehensive type definitions