@0xio/sdk 2.6.0 → 2.7.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,6 +2,56 @@
2
2
 
3
3
  All notable changes to the 0xio Wallet SDK will be documented in this file.
4
4
 
5
+ ## [2.7.0] - 2026-05-16
6
+
7
+ ### Security (post-audit remediation)
8
+
9
+ **Transport hardening:**
10
+ - Session nonce validation on all bridge responses — blocks same-origin impersonation
11
+ - Removed wildcard `'*'` postMessage fallback — parent only addressed once origin established
12
+ - Removed `Math.random()` fallback for request IDs — throws if `crypto` unavailable
13
+ - `requestTimestamps` capped to prevent unbounded growth in idle tabs
14
+ - Removed legacy `octraWalletReady` listeners and `createOctraWallet` alias
15
+
16
+ ### Added
17
+
18
+ - **Pluggable wallet adapter system** (`src/adapter.ts`, `src/supports/`):
19
+ - `WalletTransportAdapter` interface — add support for any wallet without touching core SDK
20
+ - `src/supports/0xio.ts` — built-in adapter with session nonce + iframe bridge support
21
+ - `src/supports/template.ts` — starter template for new adapters
22
+ - `detectWalletAdapter()` auto-detect helper
23
+ - Exported: `WalletTransportAdapter`, `AdapterRequest`, `AdapterIncomingMessage`, `ZeroXIOAdapter`, `createZeroXIOAdapter`, `detectWalletAdapter`, `getAllAdapters`
24
+
25
+ ### Changed
26
+
27
+ - `ExtensionCommunicator` delegates to adapter for detect, postMessage, listen, and ready events
28
+ - Session nonce handling moved from communicator to adapter
29
+ - Requires Chrome 111+ when using the 0xio browser extension
30
+ - No breaking changes to `ZeroXIOWallet` public API
31
+
32
+ **SDK fixes:**
33
+ - Session versioning — `_sessionVersion` counter prevents stale writes from in-flight requests after disconnect/account switch
34
+ - Debug log scrubbing — only non-sensitive fields logged (`{ to }`, `{ contract, method }`, `{ public }`)
35
+ - Removed `retry()` and `withTimeout()` from public API export
36
+ - Per-method payload size limits — method names ≤ 200 chars, params ≤ 64 KB, memos ≤ 1,000 chars
37
+ - Input validation at all mutating method entry points (`isValidAddress()`, `isValidAmount()`)
38
+ - Added `signAuthMessage(service, nonce)` — domain-separated auth signing with origin binding
39
+ - Amount types accept `string | number` — eliminates JS precision loss for large values
40
+ - Added `deriveOctraAddress(publicKeyBase64)` — `connect()` and `getConnectionStatus()` verify pubkey→addr binding
41
+ - `encrypt/decryptBalance()` return full `TransactionResult` (was boolean)
42
+ - `contractCallView` no longer leaks connected address as default caller
43
+ - `balanceChanged` emits on public/private split change (not just total)
44
+ - `once()` removes listener before invoke — throwing listeners no longer re-fire
45
+ - `extensionLocked`/`extensionUnlocked` events emitted (were suppressed)
46
+ - Permissions stored in `ConnectionInfo` and survive session restore
47
+ - `connectedAt` preserved across `getConnectionStatus()` polls
48
+ - `connect` event only emits on disconnected→connected transition
49
+ - `NETWORKS` frozen + `getNetworkConfig()` returns frozen copies
50
+ - `validateBalance()` uses `Number()` not `parseFloat()` — rejects partial numerics
51
+ - `validateNetworkInfo()` rejects empty rpcUrl (except custom network)
52
+ - `switchNetwork()` requires active connection
53
+ - `checkSDKCompatibility()` no longer falsely flags non-Chrome transports
54
+
5
55
  ## [2.6.0] - 2026-05-13
6
56
 
7
57
  ### Added
package/README.md CHANGED
@@ -1,9 +1,21 @@
1
1
  # 0xio Wallet SDK
2
2
 
3
- **Version:** 2.6.0
3
+ **Version:** 2.7.0
4
4
 
5
5
  Official TypeScript SDK for integrating DApps with 0xio Wallet on Octra Network.
6
6
 
7
+ ## What's New in v2.7.0
8
+
9
+ Security hardening release (post-audit remediation):
10
+ - **MessageChannel transport** (H-2 fix): Extension now uses a private `MessageChannel` port instead of `window.postMessage`, preventing page scripts from intercepting or injecting wallet messages. SDK validates a per-session nonce on every response.
11
+ - **Pluggable wallet adapters**: New `src/supports/` system — implement `WalletTransportAdapter` and drop a file in `supports/` to add any wallet without touching core SDK code. See `src/supports/template.ts` for the starting point.
12
+ - Fixed wildcard postMessage target leaking request payloads to any origin (HIGH)
13
+ - Removed `Math.random()` fallback for request IDs — throws if `crypto` unavailable (MEDIUM)
14
+ - Fixed `requestTimestamps` unbounded memory growth in idle tabs (LOW)
15
+ - Removed all `octraWalletReady` legacy event listeners and `createOctraWallet` alias (LOW)
16
+ - Extension fixes: balance/network events now delivered end-to-end; `accountChanged` on wallet switch; exact hostname tab matching; approval listener spoofing from content scripts blocked
17
+ - All 17 post-audit findings resolved. See `AUDIT_REMEDIATION.md` for full details.
18
+
7
19
  ## What's New in v2.6.0
8
20
 
9
21
  - **`sendPrivateTransfer(to, amount)`**: Send encrypted (stealth) transfers — amount is hidden from everyone except sender and recipient. Uses PVAC-HFHE for ciphertext subtraction + zero-knowledge proofs. The node re-encrypts under the recipient's key.
@@ -295,6 +307,38 @@ The SDK automatically detects when your DApp is running inside:
295
307
 
296
308
  No code changes are needed for DApp developers. Just use the SDK as normal and it will auto-detect the environment and choose the correct transport.
297
309
 
310
+ ## Wallet Adapters
311
+
312
+ The SDK ships with a pluggable adapter system so multiple wallets can be supported without changing core code.
313
+
314
+ ### Auto-detect
315
+
316
+ ```typescript
317
+ import { detectWalletAdapter, ZeroXIOWallet } from '@0xio/sdk';
318
+
319
+ const adapter = detectWalletAdapter();
320
+ if (!adapter) throw new Error('No supported wallet found');
321
+
322
+ const wallet = new ZeroXIOWallet({ appName: 'My DApp', adapter });
323
+ ```
324
+
325
+ ### Pass an adapter explicitly
326
+
327
+ ```typescript
328
+ import { ZeroXIOWallet, ZeroXIOAdapter } from '@0xio/sdk';
329
+
330
+ const wallet = new ZeroXIOWallet({ appName: 'My DApp', adapter: ZeroXIOAdapter });
331
+ ```
332
+
333
+ ### Add support for another wallet
334
+
335
+ 1. Copy `src/supports/template.ts` → `src/supports/my-wallet.ts`
336
+ 2. Fill in the four constants (`REQUEST_SOURCE`, `RESPONSE_SOURCE`, `WINDOW_KEY`, `READY_EVENT`) and the message-shape mapping
337
+ 3. Register it in `src/supports/index.ts` `REGISTERED_ADAPTERS`
338
+ 4. Export it from `src/index.ts` if you want it in the public API
339
+
340
+ See `DOCUMENTATION.md → Wallet Adapter System` for the full interface spec.
341
+
298
342
  ## Requirements
299
343
 
300
344
  - 0xio Wallet Extension v2.0.1 or higher (Mainnet Alpha)