@0xio/sdk 2.7.1 → 2.8.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
@@ -2,19 +2,60 @@
2
2
 
3
3
  All notable changes to the 0xio Wallet SDK will be documented in this file.
4
4
 
5
+ ## [2.8.1] - 2026-09-22
6
+
7
+ ### Changed
8
+
9
+ - **`switchNetwork` asks the user.** The 0xio wallets now show a confirmation before a site moves them to another network (extension 2.5.6, app 1.3.0, desktop 0.4.1), and refuse the switch while another request from the site is waiting for approval, so a transaction under review can never land on the other network. Declining rejects with `USER_REJECTED`. Documentation only: the call and its result are unchanged; handle the rejection where you call it.
10
+ - **`signMessage` is framed on every 0xio wallet.** 0xio Desktop 0.4.1 and the 0xio app 1.3.0 (in-app browser and WalletConnect) sign the same `Octra Signed Message` bytes as the extension, so `verifyMessage` now verifies their signatures too.
11
+
12
+ ## [2.8.0] - 2026-06-09
13
+
14
+ ### Added
15
+
16
+ - **Generic provider passthrough**: `wallet.request(method, params)` sends any method through the bridge, so dapps can reach wallet primitives without an SDK upgrade.
17
+ - **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):
18
+ - `getPrivateCapabilities()`: feature-detect supported private capabilities so a dapp renders the right UI or fails closed.
19
+ - `callContractView()`, `getPrivateBalance()`
20
+ - `encryptValue()`, `decryptValue()`
21
+ - `makeZeroProof()`: returns `{ proof, commitment, blinding, encoding }` (the Octra bound-proof scheme needs the commitment+blinding alongside the proof).
22
+ - `makeRangeProof()`: returns `{ proof, encoding }` (self-contained).
23
+ - `registerPrivateViewKey()`, `sendContractTransactionSequence()`
24
+ - 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`.
25
+ - **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.
26
+
27
+ ### Changed
28
+
29
+ - **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.
30
+ - **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.
31
+ - `sendPrivateTransfer` waits up to 10 minutes: the wallet builds proofs after the approval.
32
+ - `switchNetwork` and everything that signs or submits need a connected page; the wallet now refuses them otherwise with `NOT_CONNECTED`.
33
+ - The RFC-O-1 adapter maps the 2.8.0 primitives to their `octra_*` names, so they work over `window.octra` too.
34
+
35
+ ### Fixed
36
+
37
+ - `getPublicKey()` exists. The docs and the signing example called it, but the wallet class had no such method.
38
+ - `rpcCall(method, params)` wraps the wallet's read-only node RPC allow-list; a bare `request('octra_balance')` is not a wallet method.
39
+ - `transactionFailed` events reach the dapp; they were filtered out.
40
+ - `ErrorCode` includes the codes the wallet actually returns (`NOT_CONNECTED`, `INVALID_PARAMS`, `NOT_AVAILABLE`, `PRIVATE_PROOF_FAILED` and the rest).
41
+ - `encryptValue` and `makeZeroProof` result types include the `commitment` (and `blinding`) the wallet returns.
42
+ - `encryptBalance` and `decryptBalance` are marked deprecated: the 0xio extension answers `NOT_AVAILABLE`.
43
+ - The built-in devnet entry points at `https://devnet.octrascan.io`; the old direct IP is dead.
44
+ - `PendingPrivateTransfer` documents what the wallet really returns (`id` and a raw `amount`).
45
+
5
46
  ## [2.7.1] - 2026-05-27
6
47
 
7
48
  ### Security
8
49
 
9
50
  - **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.
51
+ - 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.
52
+ - `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.
53
+ - `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.
54
+ - **Docs:** `ContractCallData.amount` JSDoc corrected: field is OCT, not micro-units. No behavior change.
14
55
 
15
56
  ### Added
16
57
 
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.
58
+ - **`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
59
  - **`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
60
 
20
61
  ### Fixed
@@ -23,7 +64,7 @@ All notable changes to the 0xio Wallet SDK will be documented in this file.
23
64
 
24
65
  ### Compatibility
25
66
 
26
- - No breaking changes `ZeroXIOAdapter` (postMessage bridge) remains the default and takes priority when `window.wallet0xio` is present
67
+ - No breaking changes: `ZeroXIOAdapter` (postMessage bridge) remains the default and takes priority when `window.wallet0xio` is present
27
68
  - Old DApps work unchanged; new DApps can opt into `OctraProviderAdapter` explicitly or via `detectWalletAdapter()`
28
69
  - Requires 0xio Wallet Extension v2.4.3+ for `octra#initialized` event; falls back to `octraWalletReady` on older versions
29
70
 
@@ -32,18 +73,18 @@ All notable changes to the 0xio Wallet SDK will be documented in this file.
32
73
  ### Security (post-audit remediation)
33
74
 
34
75
  **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
76
+ - Session nonce validation on all bridge responses: blocks same-origin impersonation
77
+ - Removed wildcard `'*'` postMessage fallback: parent only addressed once origin established
78
+ - Removed `Math.random()` fallback for request IDs: throws if `crypto` unavailable
38
79
  - `requestTimestamps` capped to prevent unbounded growth in idle tabs
39
80
  - Removed legacy `octraWalletReady` listeners and `createOctraWallet` alias
40
81
 
41
82
  ### Added
42
83
 
43
84
  - **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
85
+ - `WalletTransportAdapter` interface: add support for any wallet without touching core SDK
86
+ - `src/supports/0xio.ts`: built-in adapter with session nonce + iframe bridge support
87
+ - `src/supports/template.ts`: starter template for new adapters
47
88
  - `detectWalletAdapter()` auto-detect helper
48
89
  - Exported: `WalletTransportAdapter`, `AdapterRequest`, `AdapterIncomingMessage`, `ZeroXIOAdapter`, `createZeroXIOAdapter`, `detectWalletAdapter`, `getAllAdapters`
49
90
 
@@ -55,24 +96,24 @@ All notable changes to the 0xio Wallet SDK will be documented in this file.
55
96
  - No breaking changes to `ZeroXIOWallet` public API
56
97
 
57
98
  **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 }`)
99
+ - Session versioning: `_sessionVersion` counter prevents stale writes from in-flight requests after disconnect/account switch
100
+ - Debug log scrubbing: only non-sensitive fields logged (`{ to }`, `{ contract, method }`, `{ public }`)
60
101
  - 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
102
+ - Per-method payload size limits: method names ≤ 200 chars, params ≤ 64 KB, memos ≤ 1,000 chars
62
103
  - 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
104
+ - Added `signAuthMessage(service, nonce)`: domain-separated auth signing with origin binding
105
+ - Amount types accept `string | number`: eliminates JS precision loss for large values
106
+ - Added `deriveOctraAddress(publicKeyBase64)`: `connect()` and `getConnectionStatus()` verify pubkey to addr binding
66
107
  - `encrypt/decryptBalance()` return full `TransactionResult` (was boolean)
67
108
  - `contractCallView` no longer leaks connected address as default caller
68
109
  - `balanceChanged` emits on public/private split change (not just total)
69
- - `once()` removes listener before invoke throwing listeners no longer re-fire
110
+ - `once()` removes listener before invoke: throwing listeners no longer re-fire
70
111
  - `extensionLocked`/`extensionUnlocked` events emitted (were suppressed)
71
112
  - Permissions stored in `ConnectionInfo` and survive session restore
72
113
  - `connectedAt` preserved across `getConnectionStatus()` polls
73
- - `connect` event only emits on disconnectedconnected transition
114
+ - `connect` event only emits on disconnected to connected transition
74
115
  - `NETWORKS` frozen + `getNetworkConfig()` returns frozen copies
75
- - `validateBalance()` uses `Number()` not `parseFloat()` rejects partial numerics
116
+ - `validateBalance()` uses `Number()` not `parseFloat()`: rejects partial numerics
76
117
  - `validateNetworkInfo()` rejects empty rpcUrl (except custom network)
77
118
  - `switchNetwork()` requires active connection
78
119
  - `checkSDKCompatibility()` no longer falsely flags non-Chrome transports
@@ -85,7 +126,7 @@ All notable changes to the 0xio Wallet SDK will be documented in this file.
85
126
  - **`claimPrivateTransfer(transferId)`**: Claim a pending private transfer, adding it to the wallet's encrypted balance.
86
127
 
87
128
  ### Changed
88
- - Privacy transfer methods no longer return NOT_AVAILABLE fully wired to extension v2.4.0+
129
+ - Privacy transfer methods no longer return NOT_AVAILABLE: fully wired to extension v2.4.0+
89
130
  - Updated JSDoc for all privacy methods with PVAC flow description
90
131
 
91
132
  ### Compatibility
@@ -96,7 +137,7 @@ All notable changes to the 0xio Wallet SDK will be documented in this file.
96
137
  ## [2.5.0] - 2026-05-10
97
138
 
98
139
  ### 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.
140
+ - **`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
141
  - **`getNetworkId()`**: Returns the extension's current network ID ('mainnet' or 'devnet').
101
142
  - DApps can now detect + switch network programmatically, enabling network-aware UIs.
102
143
 
@@ -116,7 +157,7 @@ All notable changes to the 0xio Wallet SDK will be documented in this file.
116
157
  ### Changed
117
158
  - **Connect response enriched**: Extension now returns `networkInfo` (id, name, rpcUrl, color, isTestnet) and `permissions` array in both fresh connect and reconnect responses.
118
159
  - **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)`.
160
+ - **networkInfo fallback chain**: SDK tries `result.networkInfo`, then `getNetworkConfig(result.networkId)`, then `getNetworkConfig(this.config.networkId)`.
120
161
 
121
162
  ### Compatibility
122
163
  - Requires 0xio Wallet Extension v2.3.5+ for full alignment
@@ -192,7 +233,7 @@ All notable changes to the 0xio Wallet SDK will be documented in this file.
192
233
  - Extension content script messages continue to use strict origin validation
193
234
 
194
235
  ### Compatibility
195
- - Fully backward compatible extension-based DApps work unchanged
236
+ - Fully backward compatible: extension-based DApps work unchanged
196
237
  - Desktop (0xio Desktop): DApps loaded in BrowserScreen iframe now auto-connect
197
238
  - Mobile (0xio App): DApps loaded in WebView browser now auto-connect via existing bridge
198
239
  - Mainnet Alpha: Extension v2.0.1+
@@ -203,7 +244,7 @@ All notable changes to the 0xio Wallet SDK will be documented in this file.
203
244
  ## [2.3.0] - 2026-03-10
204
245
 
205
246
  ### 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.
247
+ - **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
248
  - **Contract View Calls**: New `contractCallView()` method for read-only contract queries. No wallet unlock or approval popup required.
208
249
  - **Contract Storage**: New `getContractStorage()` method to read contract storage by key directly from the chain.
209
250
  - **New Types**: `ContractCallData`, `ContractViewCallData`, and `ContractParams` for type-safe contract interaction.
@@ -256,13 +297,13 @@ All notable changes to the 0xio Wallet SDK will be documented in this file.
256
297
  ### Added
257
298
  - **Transaction Finality**: New `TransactionFinality` type (`'pending' | 'confirmed' | 'rejected'`) and `finality` field on `TransactionResult` and `Transaction` interfaces.
258
299
  - **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
300
+ - `MALFORMED_TRANSACTION`: Transaction is malformed
301
+ - `SELF_TRANSFER`: Cannot transfer to yourself
302
+ - `SENDER_NOT_FOUND`: Sender address not found
303
+ - `INVALID_SIGNATURE`: Invalid transaction signature
304
+ - `DUPLICATE_TRANSACTION`: Duplicate transaction detected
305
+ - `NONCE_TOO_FAR`: Transaction nonce is too far ahead
306
+ - `INTERNAL_ERROR`: Internal server error
266
307
  - **Error Messages**: All new error codes have corresponding human-readable messages in `createErrorMessage()`.
267
308
 
268
309
  ### Fixed
@@ -340,8 +381,8 @@ All notable changes to the 0xio Wallet SDK will be documented in this file.
340
381
 
341
382
  ### Breaking Changes
342
383
  - **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`
384
+ - `octra-sdk-request` to `0xio-sdk-request`
385
+ - `octra-sdk-bridge` to `0xio-sdk-bridge`
345
386
  - This is a breaking change that requires wallet extension v2.0+ for compatibility
346
387
 
347
388
  ### Changed
@@ -349,7 +390,7 @@ All notable changes to the 0xio Wallet SDK will be documented in this file.
349
390
  - Changed author from "NullxGery" to "0xio Team"
350
391
  - Updated author email from "0xgery@proton.me" to "team@0xio.xyz"
351
392
  - Updated repository URL from `0xGery/0xio-sdk` to `0xio-xyz/0xio-sdk`
352
- - Updated keywords: "0xio" "0xio wallet", added "octra wallet"
393
+ - Updated keywords: "0xio" to "0xio wallet", added "octra wallet"
353
394
  - Author URL changed to organization: `https://github.com/0xio-xyz`
354
395
 
355
396
  ### Migration Guide
@@ -408,8 +449,8 @@ This is the first stable release of the 0xio Wallet SDK, a comprehensive bridge
408
449
  - **Professional code refactoring**: All files now include comprehensive JSDoc documentation
409
450
 
410
451
  ### Package Changes
411
- - **Package renamed**: `@0xgery/wallet-sdk` `@0xio/sdk`
412
- - **Version bump**: 0.2.1 1.0.0 (production-ready)
452
+ - **Package renamed**: `@0xgery/wallet-sdk` to `@0xio/sdk`
453
+ - **Version bump**: 0.2.1 to 1.0.0 (production-ready)
413
454
  - **Repository**: Published to https://github.com/0xGery/0xio-sdk
414
455
  - **Homepage**: https://0xio.xyz
415
456
 
@@ -425,7 +466,7 @@ This is the first stable release of the 0xio Wallet SDK, a comprehensive bridge
425
466
  - Complete integration examples (React, Vue, Vanilla JS)
426
467
 
427
468
  ### Technical Improvements
428
- - **JSDoc coverage**: 0% 95%
469
+ - **JSDoc coverage**: 0% to 95%
429
470
  - **Code quality**: Refactored all functions to <30 lines
430
471
  - **Error handling**: Enhanced with detailed context and diagnostics
431
472
  - **TypeScript**: Full type safety with comprehensive type definitions