@sidhujag/sysweb3-keyring 1.0.627 → 2.0.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 (140) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/README.md +66 -0
  3. package/cjs/hardware-wallet-manager.js +302 -128
  4. package/cjs/hardware-wallet-manager.js.map +1 -1
  5. package/cjs/keyring-core.js +2605 -0
  6. package/cjs/keyring-core.js.map +1 -0
  7. package/cjs/keyring-manager.js +31 -2439
  8. package/cjs/keyring-manager.js.map +1 -1
  9. package/cjs/ledger/bitcoin_client/lib/appClient.js.map +1 -1
  10. package/cjs/ledger/host-types.js +10 -0
  11. package/cjs/ledger/host-types.js.map +1 -0
  12. package/cjs/ledger/index.js +243 -447
  13. package/cjs/ledger/index.js.map +1 -1
  14. package/cjs/ledger/prepare-psbt.js +177 -0
  15. package/cjs/ledger/prepare-psbt.js.map +1 -0
  16. package/cjs/software-hd-account.js +23 -0
  17. package/cjs/software-hd-account.js.map +1 -0
  18. package/cjs/software.js +74 -0
  19. package/cjs/software.js.map +1 -0
  20. package/cjs/storage-core.js +227 -0
  21. package/cjs/storage-core.js.map +1 -0
  22. package/cjs/storage.js +15 -210
  23. package/cjs/storage.js.map +1 -1
  24. package/cjs/transactions/ethereum.js +176 -39
  25. package/cjs/transactions/ethereum.js.map +1 -1
  26. package/cjs/transactions/evm-local-signer.js +11 -1
  27. package/cjs/transactions/evm-local-signer.js.map +1 -1
  28. package/cjs/transactions/hardware-psbt.js +159 -0
  29. package/cjs/transactions/hardware-psbt.js.map +1 -0
  30. package/cjs/transactions/prepared-evm.js +196 -0
  31. package/cjs/transactions/prepared-evm.js.map +1 -0
  32. package/cjs/transactions/syscoin-core.js +651 -0
  33. package/cjs/transactions/syscoin-core.js.map +1 -0
  34. package/cjs/transactions/syscoin.js +8 -768
  35. package/cjs/transactions/syscoin.js.map +1 -1
  36. package/cjs/trezor/connect.js +243 -0
  37. package/cjs/trezor/connect.js.map +1 -0
  38. package/cjs/trezor/index.js +96 -58
  39. package/cjs/trezor/index.js.map +1 -1
  40. package/cjs/trezor/witness.js +25 -0
  41. package/cjs/trezor/witness.js.map +1 -0
  42. package/cjs/types.js.map +1 -1
  43. package/cjs/utils/psbt-account-scope.js +5 -3
  44. package/cjs/utils/psbt-account-scope.js.map +1 -1
  45. package/esm/errorUtils.js +72 -0
  46. package/esm/errorUtils.js.map +1 -0
  47. package/esm/ethers-v6.js +207 -0
  48. package/esm/ethers-v6.js.map +1 -0
  49. package/esm/hardware-wallet-manager.js +643 -0
  50. package/esm/hardware-wallet-manager.js.map +1 -0
  51. package/esm/ledger/bitcoin_client/lib/appClient.js +279 -0
  52. package/esm/ledger/bitcoin_client/lib/appClient.js.map +1 -0
  53. package/esm/ledger/bitcoin_client/lib/bip32.js +49 -0
  54. package/esm/ledger/bitcoin_client/lib/bip32.js.map +1 -0
  55. package/esm/ledger/bitcoin_client/lib/buffertools.js +119 -0
  56. package/esm/ledger/bitcoin_client/lib/buffertools.js.map +1 -0
  57. package/esm/ledger/bitcoin_client/lib/clientCommands.js +269 -0
  58. package/esm/ledger/bitcoin_client/lib/clientCommands.js.map +1 -0
  59. package/esm/ledger/bitcoin_client/lib/merkelizedPsbt.js +50 -0
  60. package/esm/ledger/bitcoin_client/lib/merkelizedPsbt.js.map +1 -0
  61. package/esm/ledger/bitcoin_client/lib/merkle.js +111 -0
  62. package/esm/ledger/bitcoin_client/lib/merkle.js.map +1 -0
  63. package/esm/ledger/bitcoin_client/lib/merkleMap.js +42 -0
  64. package/esm/ledger/bitcoin_client/lib/merkleMap.js.map +1 -0
  65. package/esm/ledger/bitcoin_client/lib/policy.js +68 -0
  66. package/esm/ledger/bitcoin_client/lib/policy.js.map +1 -0
  67. package/esm/ledger/bitcoin_client/lib/psbtv2.js +645 -0
  68. package/esm/ledger/bitcoin_client/lib/psbtv2.js.map +1 -0
  69. package/esm/ledger/bitcoin_client/lib/varint.js +108 -0
  70. package/esm/ledger/bitcoin_client/lib/varint.js.map +1 -0
  71. package/esm/ledger/consts.js +4 -0
  72. package/esm/ledger/consts.js.map +1 -0
  73. package/esm/ledger/dmk-evm.js +258 -0
  74. package/esm/ledger/dmk-evm.js.map +1 -0
  75. package/esm/ledger/dmk-session.js +264 -0
  76. package/esm/ledger/dmk-session.js.map +1 -0
  77. package/esm/ledger/dmk-utxo.js +279 -0
  78. package/esm/ledger/dmk-utxo.js.map +1 -0
  79. package/esm/ledger/host-types.js +5 -0
  80. package/esm/ledger/host-types.js.map +1 -0
  81. package/esm/ledger/index.js +268 -0
  82. package/esm/ledger/index.js.map +1 -0
  83. package/esm/ledger/prepare-psbt.js +141 -0
  84. package/esm/ledger/prepare-psbt.js.map +1 -0
  85. package/esm/ledger/types.js +2 -0
  86. package/esm/ledger/types.js.map +1 -0
  87. package/esm/ledger-host.js +36 -0
  88. package/esm/ledger-host.js.map +1 -0
  89. package/esm/private-records.js +153 -0
  90. package/esm/private-records.js.map +1 -0
  91. package/esm/providers.js +588 -0
  92. package/esm/providers.js.map +1 -0
  93. package/esm/signers.js +28 -0
  94. package/esm/signers.js.map +1 -0
  95. package/esm/trezor/connect.js +206 -0
  96. package/esm/trezor/connect.js.map +1 -0
  97. package/esm/trezor/index.js +876 -0
  98. package/esm/trezor/index.js.map +1 -0
  99. package/esm/trezor/witness.js +21 -0
  100. package/esm/trezor/witness.js.map +1 -0
  101. package/esm/types.js +17 -0
  102. package/esm/types.js.map +1 -0
  103. package/esm/utils/derivation-paths.js +109 -0
  104. package/esm/utils/derivation-paths.js.map +1 -0
  105. package/esm/utils/psbt-account-scope.js +310 -0
  106. package/esm/utils/psbt-account-scope.js.map +1 -0
  107. package/package.json +55 -8
  108. package/types/hardware-wallet-manager.d.ts +12 -19
  109. package/types/keyring-core.d.ts +263 -0
  110. package/types/keyring-manager.d.ts +7 -224
  111. package/types/ledger/bitcoin_client/lib/appClient.d.ts +6 -3
  112. package/types/ledger/dmk-evm.d.ts +8 -0
  113. package/types/ledger/dmk-session.d.ts +60 -0
  114. package/types/ledger/dmk-utxo.d.ts +26 -0
  115. package/types/ledger/host-types.d.ts +131 -0
  116. package/types/ledger/index.d.ts +21 -58
  117. package/types/ledger/prepare-psbt.d.ts +3 -0
  118. package/types/ledger/types.d.ts +3 -0
  119. package/types/ledger-host.d.ts +7 -0
  120. package/types/software-hd-account.d.ts +16 -0
  121. package/types/software.d.ts +39 -0
  122. package/types/storage-core.d.ts +22 -0
  123. package/types/storage.d.ts +1 -4
  124. package/types/transactions/ethereum.d.ts +17 -7
  125. package/types/transactions/evm-local-signer.d.ts +3 -1
  126. package/types/transactions/hardware-psbt.d.ts +7 -0
  127. package/types/transactions/prepared-evm.d.ts +53 -0
  128. package/types/transactions/syscoin-core.d.ts +92 -0
  129. package/types/transactions/syscoin.d.ts +8 -67
  130. package/types/trezor/connect.d.ts +42 -0
  131. package/types/trezor/index.d.ts +22 -4
  132. package/types/trezor/witness.d.ts +3 -0
  133. package/types/types.d.ts +10 -0
  134. package/types/utils/psbt-account-scope.d.ts +1 -0
  135. package/cjs/transactions/__tests__/integration.test.js +0 -237
  136. package/cjs/transactions/__tests__/integration.test.js.map +0 -1
  137. package/cjs/transactions/__tests__/syscoin.test.js +0 -361
  138. package/cjs/transactions/__tests__/syscoin.test.js.map +0 -1
  139. package/types/transactions/__tests__/integration.test.d.ts +0 -1
  140. package/types/transactions/__tests__/syscoin.test.d.ts +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,47 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.0.0
4
+
5
+ - Add `SoftwareKeyring.deriveEvmHdRuntimeAccount` for host-allocated Ethereum BIP44 indices. It returns the existing password-encrypted runtime account record without installing an account, writing storage or querying a network. The method binds session, selection and network identity and requires a synchronous host guard. Hosts must strip encrypted `xprv` before producing public metadata.
6
+
7
+ - Add `SoftwareKeyring.signPreparedEvmTransaction` for offline signing of fully specified legacy/EIP-1559 envelopes. The request binds the selected software account and exact network/endpoint, requires synchronous host admission, validates all signed fields and recovered identity, and returns immutable signed bytes plus their local hash. It never estimates fees, resolves names, fills fields or broadcasts; hosts must durably retain the result before submission and reconcile uncertain broadcasts by hash.
8
+
9
+ - Breaking: Ledger signing requires an explicitly injected semantic `LedgerHost`. Raw LedgerJS transports/clients are removed; use the isolated browser ESM host entry for device access.
10
+ - Adopt current Device Management Kit and Ethereum signer packages while preserving the custom Syscoin/Bitcoin protocol. Serialize device operations and reject stale, wrong-account, malformed and mismatched-sighash responses.
11
+ - Disable remote Ledger metadata/transaction checks/telemetry by default. Require fresh per-intent consent for transaction/typed-data signing that may fall back to blind signing.
12
+ - Bind receive addresses to public account derivation, preserve on-device approval for unusual paths, and snapshot queued UTXO requests before connection awaits.
13
+ - Existing software-only entry, vault formats and account derivation remain compatible. Host/device and native-runtime qualification are separate requirements.
14
+
15
+ - Remove the legacy Trezor UTXO library. Reuse Bitcoinjs address decoding with a checksum-verified two-byte-version compatibility path, and encode witness vectors with the public CompactSize codec.
16
+
17
+ - Move Trezor hardware integration to Connect 10.0.1 and remove the redundant direct Connect Web dependency.
18
+ - Load the browser transport only inside a supported MV3 extension. Preserve CommonJS/ESM and software-entry imports without browser globals or device initialization.
19
+ - Preserve the existing SDK failure payload while retaining Connect error codes; stop retrying cancellations, disconnects and unsupported hosts/coins.
20
+ - Replace removed Connect device events with status updates from request outcomes and disposal. Immediate physical unplug notifications are no longer exposed by upstream.
21
+ - Reject pending calls locally on lock/disposal and discard late responses. Defer remote cleanup while requests are outstanding; return `HARDWARE_SIGNER_BUSY` until they settle rather than opening another approval prompt.
22
+ - Normalize Trezor hexadecimal recovery values without mutating signed responses; preserve approved transaction and session checks.
23
+ - Physical device qualification and consuming-extension Suite Web permissions remain release gates.
24
+
25
+ ## 1.0.628
26
+
27
+ - Add the `cjs/software` entry with explicit asynchronous host storage and an opaque wallet-authority handle. Software keyrings do not load browser hardware transports or global storage.
28
+ - Keep the legacy `KeyringManager` entry and normal device defaults. The software entry rejects unavailable hardware, storage rebinding, direct session injection and cross-authority session transfer.
29
+ - Expose reusable vault persistence and software transaction cores with typed deep imports. Preserve vault encryption formats, KDF profiles, private-record domains and account derivation.
30
+ - Move Pali's existing cancellation fee-consent safeguards into source: optional unsigned preview and selected payer, required approved fee ceiling for sending, and final populated-envelope validation.
31
+ - Preserve the original value of a MAX-send replacement; return `REPLACEMENT_VALUE_WOULD_CHANGE` if the higher fee cannot be funded without reducing it.
32
+ - Add an optional synchronous final validator to local transaction sending. Promise/thenable decisions are rejected before signing; the existing five-argument call remains supported.
33
+ - Exclude compiled test fixtures from the published package; runtime code and declarations are unchanged.
34
+
35
+ ### Cancellation callers
36
+
37
+ A cancellation send now requires `approvedMaximumFee` (decimal wei), in addition to the existing synchronous `assertCurrentContext` and `validateOriginal` callbacks. `previewOnly: true` returns `maximumFee` without requesting credentials, device signing or broadcast. After the user deliberately reviews and approves that fee ceiling, pass the approved value when sending; a later higher fee is rejected. `targetAccount` selects the supported outer payer while the host's selected-account context remains guarded.
38
+
39
+ Pali already enforces these rules through its 1.0.627 package patch. It may remove that patch only when adopting this release and validating the actual installed package.
40
+
41
+ ### Host integration limits
42
+
43
+ The software entry is a low-level SDK, not a native-wallet security boundary by itself. The host must invalidate its authorization generation immediately on lock/background, clear late unlock results, and control public-state publication. Native cryptographic/storage adapters, biometrics, device behavior and full mobile functionality still require their own implementation and qualification. See `docs/software-entry.md` and `docs/storage-core.md` in the source repository.
44
+
3
45
  ## 1.0.626
4
46
 
5
47
  - Add an optional synchronous host guard to formatted EVM transaction submission. The SDK captures it once and rechecks it with the existing account, network and session guards before signing and broadcast.
package/README.md CHANGED
@@ -150,6 +150,32 @@ const signature = await keyringManager.ethereumTransaction.signPersonalMessage([
150
150
 
151
151
  ### Hardware Wallet Support
152
152
 
153
+ Trezor uses `@trezor/connect-webextension` 10.0.1. The hardware adapter loads it
154
+ only when a supported MV3 extension invokes Trezor; ordinary Node CommonJS/ESM
155
+ imports and the software entry do not initialize browser transports. Unsupported
156
+ hosts reject hardware operations instead of falling back to software signing.
157
+
158
+ The extension must configure `externally_connectable` for
159
+ `https://suite.trezor.io/*` and host access to that origin, as required by the
160
+ [published Connect 10 webextension package](https://www.npmjs.com/package/@trezor/connect-webextension/v/10.0.1).
161
+ Connect selects Suite Desktop or the Suite Web popup. The old Connect 9 iframe,
162
+ content script, and `connectSrc` settings are not part of this integration.
163
+
164
+ Connect 10 does not expose the old device event emitter. SDK connection status
165
+ and cached model information update from request results and disposal; they are
166
+ not immediate physical unplug notifications. Disposal immediately rejects pending
167
+ SDK operations and fences late replies. Suite Web may leave its popup open; a
168
+ late approval there is discarded locally rather than treated as a fresh approval.
169
+ When an underlying request is still active, transport cleanup is deferred to avoid
170
+ triggering an automatic fallback popup. New initialization fails with
171
+ `HARDWARE_SIGNER_BUSY` until that request settles; local lock/disposal does not
172
+ wait for the remote prompt. An upstream transport failure can still trigger remote
173
+ fallback UI while that old request is pending; the local SDK will reject its result.
174
+ A failed or cancelled operation
175
+ never authorizes a cached transaction, and terminal disconnect/unsupported-host
176
+ errors are not retried. Device pairing, display verification, signing, and
177
+ reconnection still require physical-device qualification in the consuming host.
178
+
153
179
  ```javascript
154
180
  // Import Trezor account
155
181
  const trezorAccount = await keyringManager.importTrezorAccount(
@@ -293,3 +319,43 @@ collection rather than guaranteed memory erasure.
293
319
  ## License
294
320
 
295
321
  MIT License
322
+
323
+ ### Ledger platform host
324
+
325
+ Ledger device access uses the Device Management Kit. The regular and software
326
+ entries do not load a Ledger transport or device SDK. Browser integrations must
327
+ create the heavy host from `@sidhujag/sysweb3-keyring/esm/ledger-host` in a visible
328
+ extension page and inject its semantic `LedgerHost` port into the wallet authority:
329
+
330
+ ```ts
331
+ // Visible device page only:
332
+ import { createLedgerDmkHost } from '@sidhujag/sysweb3-keyring/esm/ledger-host';
333
+ const host = createLedgerDmkHost({
334
+ confirmBlindSigning: async (intent, signal) => {
335
+ // Show the exact immutable intent and an explicit blind-signing warning.
336
+ // Return true only after a fresh user decision; cancellation must return false.
337
+ return showTrustedWalletConfirmation(intent, signal);
338
+ },
339
+ });
340
+
341
+ // Wallet authority: use a secured semantic port to that page, not a raw APDU port.
342
+ const wallet = new KeyringManager(undefined, authorizedLedgerHostPort);
343
+ ```
344
+
345
+ Use only the ESM host entry with a browser bundler and its required platform
346
+ polyfills. `cjs/ledger-host` is not a supported entry. A service worker cannot own
347
+ the WebHID device picker. The platform must bind the host to its own trusted page,
348
+ revoke pending operations on lock/close, and never expose this port to dapps.
349
+ A missing host fails with `HARDWARE_SIGNER_UNAVAILABLE`; there is no legacy
350
+ LedgerJS fallback. Pass either a shared hardware manager or a Ledger host to
351
+ `KeyringManager`, not both.
352
+
353
+ The default host performs no remote metadata lookup, transaction checks, or
354
+ signing telemetry. The current Ethereum signer library can fall back to blind
355
+ signing, so transaction and typed-data signing require per-request approval
356
+ through the trusted `confirmBlindSigning` callback. Omitting it fails closed.
357
+ Personal-message signing and address retrieval remain available offline.
358
+ Signatures are checked against the expected account; UTXO signatures must also
359
+ match the approved PSBT and its requested sighash coverage. The custom UTXO host
360
+ supports the existing Syscoin and Bitcoin app protocols. Physical-device and
361
+ firmware qualification remain separate from source and mocked-device tests.