@0xio/sdk 2.6.0 → 2.7.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 +75 -0
- package/README.md +77 -2
- package/dist/index.d.ts +326 -336
- package/dist/index.esm.js +1053 -682
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +1059 -684
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +1059 -684
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,81 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to the 0xio Wallet SDK will be documented in this file.
|
|
4
4
|
|
|
5
|
+
## [2.7.1] - 2026-05-27
|
|
6
|
+
|
|
7
|
+
### Security
|
|
8
|
+
|
|
9
|
+
- **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.
|
|
14
|
+
|
|
15
|
+
### Added
|
|
16
|
+
|
|
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.
|
|
18
|
+
- **`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
|
+
|
|
20
|
+
### Fixed
|
|
21
|
+
|
|
22
|
+
- Mainnet RPC URL in docs updated to `https://octra.network` (was stale `http://46.101.86.250:8080`)
|
|
23
|
+
|
|
24
|
+
### Compatibility
|
|
25
|
+
|
|
26
|
+
- No breaking changes — `ZeroXIOAdapter` (postMessage bridge) remains the default and takes priority when `window.wallet0xio` is present
|
|
27
|
+
- Old DApps work unchanged; new DApps can opt into `OctraProviderAdapter` explicitly or via `detectWalletAdapter()`
|
|
28
|
+
- Requires 0xio Wallet Extension v2.4.3+ for `octra#initialized` event; falls back to `octraWalletReady` on older versions
|
|
29
|
+
|
|
30
|
+
## [2.7.0] - 2026-05-16
|
|
31
|
+
|
|
32
|
+
### Security (post-audit remediation)
|
|
33
|
+
|
|
34
|
+
**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
|
|
38
|
+
- `requestTimestamps` capped to prevent unbounded growth in idle tabs
|
|
39
|
+
- Removed legacy `octraWalletReady` listeners and `createOctraWallet` alias
|
|
40
|
+
|
|
41
|
+
### Added
|
|
42
|
+
|
|
43
|
+
- **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
|
|
47
|
+
- `detectWalletAdapter()` auto-detect helper
|
|
48
|
+
- Exported: `WalletTransportAdapter`, `AdapterRequest`, `AdapterIncomingMessage`, `ZeroXIOAdapter`, `createZeroXIOAdapter`, `detectWalletAdapter`, `getAllAdapters`
|
|
49
|
+
|
|
50
|
+
### Changed
|
|
51
|
+
|
|
52
|
+
- `ExtensionCommunicator` delegates to adapter for detect, postMessage, listen, and ready events
|
|
53
|
+
- Session nonce handling moved from communicator to adapter
|
|
54
|
+
- Requires Chrome 111+ when using the 0xio browser extension
|
|
55
|
+
- No breaking changes to `ZeroXIOWallet` public API
|
|
56
|
+
|
|
57
|
+
**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 }`)
|
|
60
|
+
- 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
|
|
62
|
+
- 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 pubkey→addr binding
|
|
66
|
+
- `encrypt/decryptBalance()` return full `TransactionResult` (was boolean)
|
|
67
|
+
- `contractCallView` no longer leaks connected address as default caller
|
|
68
|
+
- `balanceChanged` emits on public/private split change (not just total)
|
|
69
|
+
- `once()` removes listener before invoke — throwing listeners no longer re-fire
|
|
70
|
+
- `extensionLocked`/`extensionUnlocked` events emitted (were suppressed)
|
|
71
|
+
- Permissions stored in `ConnectionInfo` and survive session restore
|
|
72
|
+
- `connectedAt` preserved across `getConnectionStatus()` polls
|
|
73
|
+
- `connect` event only emits on disconnected→connected transition
|
|
74
|
+
- `NETWORKS` frozen + `getNetworkConfig()` returns frozen copies
|
|
75
|
+
- `validateBalance()` uses `Number()` not `parseFloat()` — rejects partial numerics
|
|
76
|
+
- `validateNetworkInfo()` rejects empty rpcUrl (except custom network)
|
|
77
|
+
- `switchNetwork()` requires active connection
|
|
78
|
+
- `checkSDKCompatibility()` no longer falsely flags non-Chrome transports
|
|
79
|
+
|
|
5
80
|
## [2.6.0] - 2026-05-13
|
|
6
81
|
|
|
7
82
|
### Added
|
package/README.md
CHANGED
|
@@ -1,9 +1,21 @@
|
|
|
1
1
|
# 0xio Wallet SDK
|
|
2
2
|
|
|
3
|
-
**Version:** 2.
|
|
3
|
+
**Version:** 2.7.1
|
|
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.
|
|
@@ -260,7 +272,7 @@ console.log(devnet.isTestnet); // true
|
|
|
260
272
|
|
|
261
273
|
// Get mainnet config
|
|
262
274
|
const mainnet = getNetworkConfig('mainnet');
|
|
263
|
-
console.log(mainnet.rpcUrl); //
|
|
275
|
+
console.log(mainnet.rpcUrl); // https://octra.network
|
|
264
276
|
console.log(mainnet.supportsPrivacy); // true
|
|
265
277
|
```
|
|
266
278
|
|
|
@@ -295,6 +307,69 @@ 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
|
+
|
|
342
|
+
## RFC-O-1 Provider Interface (`window.octra`)
|
|
343
|
+
|
|
344
|
+
The 0xio extension exposes a standard `window.octra` provider per the RFC-O-1 spec in addition to the legacy `window.wallet0xio` bridge. The SDK supports both automatically.
|
|
345
|
+
|
|
346
|
+
```typescript
|
|
347
|
+
// window.octra shape (injected by the extension)
|
|
348
|
+
window.octra.isOctra // true — standard wallet detection
|
|
349
|
+
window.octra.request({ method: 'octra_requestAccounts', params: [{}] })
|
|
350
|
+
window.octra.on('accountsChanged', handler)
|
|
351
|
+
window.octra.removeListener('accountsChanged', handler)
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
### How adapter priority works
|
|
355
|
+
|
|
356
|
+
When the SDK initializes, `detectWalletAdapter()` runs detection in order:
|
|
357
|
+
|
|
358
|
+
1. **`ZeroXIOAdapter`** — detected via `window.wallet0xio` / `window.ZeroXIOWallet` (postMessage bridge). Priority when the 0xio extension is installed — existing DApps are unaffected.
|
|
359
|
+
2. **`OctraProviderAdapter`** — detected via `window.octra.isOctra === true`. Used when only the RFC-O-1 provider is present (third-party RFC-O-1 wallets, or DApps that explicitly request it).
|
|
360
|
+
|
|
361
|
+
Old DApps using the postMessage bridge continue to work unchanged. New DApps can opt into `OctraProviderAdapter` directly:
|
|
362
|
+
|
|
363
|
+
```typescript
|
|
364
|
+
import { ZeroXIOWallet, OctraProviderAdapter } from '@0xio/sdk';
|
|
365
|
+
|
|
366
|
+
// Explicitly use the RFC-O-1 window.octra provider
|
|
367
|
+
const wallet = new ZeroXIOWallet({
|
|
368
|
+
appName: 'My DApp',
|
|
369
|
+
adapter: OctraProviderAdapter,
|
|
370
|
+
});
|
|
371
|
+
```
|
|
372
|
+
|
|
298
373
|
## Requirements
|
|
299
374
|
|
|
300
375
|
- 0xio Wallet Extension v2.0.1 or higher (Mainnet Alpha)
|