@onekeyfe/hd-core 1.2.8-alpha.9 → 1.2.9

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 (154) hide show
  1. package/README.md +27 -0
  2. package/__tests__/AllNetworkGetAddressBase.tracing.test.ts +13 -4
  3. package/__tests__/DeviceCommands.test.ts +25 -0
  4. package/__tests__/allNetworkGetAddress-privacy-networks.test.ts +77 -0
  5. package/__tests__/allNetworkGetAddress-skippable.test.ts +49 -0
  6. package/__tests__/btc-derive-context-hash.test.ts +200 -0
  7. package/__tests__/core-dispose.test.ts +114 -1
  8. package/__tests__/core-error-output.test.ts +21 -0
  9. package/__tests__/device-connector-protocol.test.ts +5 -2
  10. package/__tests__/device-lifecycle-events.test.ts +127 -10
  11. package/__tests__/firmware-update/firmware-artifact-source.test.ts +11 -0
  12. package/__tests__/logBlockEvent.test.ts +331 -9
  13. package/__tests__/logger.test.ts +18 -0
  14. package/__tests__/monero-get-address.test.ts +147 -0
  15. package/__tests__/monero-key-image-sync.test.ts +272 -0
  16. package/__tests__/monero-sign-transaction.test.ts +436 -0
  17. package/__tests__/protocol-v2-key-export-confirmation.test.ts +75 -0
  18. package/__tests__/protocol-v2-resources.test.ts +14 -0
  19. package/__tests__/protocol-v2.test.ts +845 -3
  20. package/__tests__/protocolV2FileWrite.test.ts +454 -7
  21. package/__tests__/search-devices.test.ts +36 -0
  22. package/__tests__/sol-sign-offchain-message.test.ts +8 -0
  23. package/__tests__/usb-identity-probe.test.ts +358 -0
  24. package/__tests__/zcash-protobuf.test.ts +152 -0
  25. package/__tests__/zcash-sign-pczt.test.ts +525 -0
  26. package/dist/api/BaseMethod.d.ts.map +1 -1
  27. package/dist/api/FileWrite.d.ts.map +1 -1
  28. package/dist/api/FirmwareUpdateV4.d.ts +5 -0
  29. package/dist/api/FirmwareUpdateV4.d.ts.map +1 -1
  30. package/dist/api/SearchDevices.d.ts +21 -1
  31. package/dist/api/SearchDevices.d.ts.map +1 -1
  32. package/dist/api/allnetwork/AllNetworkGetAddressBase.d.ts +3 -0
  33. package/dist/api/allnetwork/AllNetworkGetAddressBase.d.ts.map +1 -1
  34. package/dist/api/btc/BTCDeriveContextHash.d.ts +16 -0
  35. package/dist/api/btc/BTCDeriveContextHash.d.ts.map +1 -0
  36. package/dist/api/firmware/FirmwareArtifactSource.d.ts.map +1 -1
  37. package/dist/api/helpers/pathUtils.d.ts +1 -0
  38. package/dist/api/helpers/pathUtils.d.ts.map +1 -1
  39. package/dist/api/helpers/protocolV2FileWrite.d.ts +5 -1
  40. package/dist/api/helpers/protocolV2FileWrite.d.ts.map +1 -1
  41. package/dist/api/index.d.ts +8 -0
  42. package/dist/api/index.d.ts.map +1 -1
  43. package/dist/api/monero/MoneroGetAddress.d.ts +11 -0
  44. package/dist/api/monero/MoneroGetAddress.d.ts.map +1 -0
  45. package/dist/api/monero/MoneroGetWatchKey.d.ts +11 -0
  46. package/dist/api/monero/MoneroGetWatchKey.d.ts.map +1 -0
  47. package/dist/api/monero/MoneroKeyImageSync.d.ts +20 -0
  48. package/dist/api/monero/MoneroKeyImageSync.d.ts.map +1 -0
  49. package/dist/api/monero/MoneroSignTransaction.d.ts +17 -0
  50. package/dist/api/monero/MoneroSignTransaction.d.ts.map +1 -0
  51. package/dist/api/monero/helpers.d.ts +5 -0
  52. package/dist/api/monero/helpers.d.ts.map +1 -0
  53. package/dist/api/protocol-v2/DeviceUploadNft.d.ts.map +1 -1
  54. package/dist/api/protocol-v2/DeviceUploadWallpaper.d.ts.map +1 -1
  55. package/dist/api/zcash/ZcashGetAddress.d.ts +12 -0
  56. package/dist/api/zcash/ZcashGetAddress.d.ts.map +1 -0
  57. package/dist/api/zcash/ZcashGetFullViewingKey.d.ts +12 -0
  58. package/dist/api/zcash/ZcashGetFullViewingKey.d.ts.map +1 -0
  59. package/dist/api/zcash/ZcashSignPczt.d.ts +16 -0
  60. package/dist/api/zcash/ZcashSignPczt.d.ts.map +1 -0
  61. package/dist/api/zcash/helpers.d.ts +2 -0
  62. package/dist/api/zcash/helpers.d.ts.map +1 -0
  63. package/dist/core/index.d.ts +3 -1
  64. package/dist/core/index.d.ts.map +1 -1
  65. package/dist/device/Device.d.ts +1 -0
  66. package/dist/device/Device.d.ts.map +1 -1
  67. package/dist/device/DeviceCommands.d.ts +4 -4
  68. package/dist/device/DeviceCommands.d.ts.map +1 -1
  69. package/dist/events/logBlockEvent.d.ts +10 -0
  70. package/dist/events/logBlockEvent.d.ts.map +1 -1
  71. package/dist/events/ui-request.d.ts +2 -0
  72. package/dist/events/ui-request.d.ts.map +1 -1
  73. package/dist/index.d.ts +202 -7
  74. package/dist/index.d.ts.map +1 -1
  75. package/dist/index.js +5849 -4205
  76. package/dist/inject.d.ts.map +1 -1
  77. package/dist/protocols/protocol-v2/resources.d.ts +1 -0
  78. package/dist/protocols/protocol-v2/resources.d.ts.map +1 -1
  79. package/dist/protocols/protocol-v2/uiInteraction.d.ts +1 -0
  80. package/dist/protocols/protocol-v2/uiInteraction.d.ts.map +1 -1
  81. package/dist/types/api/allNetworkGetAddress.d.ts +4 -1
  82. package/dist/types/api/allNetworkGetAddress.d.ts.map +1 -1
  83. package/dist/types/api/btcDeriveContextHash.d.ts +10 -0
  84. package/dist/types/api/btcDeriveContextHash.d.ts.map +1 -0
  85. package/dist/types/api/export.d.ts +8 -0
  86. package/dist/types/api/export.d.ts.map +1 -1
  87. package/dist/types/api/index.d.ts +16 -0
  88. package/dist/types/api/index.d.ts.map +1 -1
  89. package/dist/types/api/moneroGetAddress.d.ts +15 -0
  90. package/dist/types/api/moneroGetAddress.d.ts.map +1 -0
  91. package/dist/types/api/moneroGetWatchKey.d.ts +15 -0
  92. package/dist/types/api/moneroGetWatchKey.d.ts.map +1 -0
  93. package/dist/types/api/moneroKeyImageSync.d.ts +24 -0
  94. package/dist/types/api/moneroKeyImageSync.d.ts.map +1 -0
  95. package/dist/types/api/moneroSignTransaction.d.ts +32 -0
  96. package/dist/types/api/moneroSignTransaction.d.ts.map +1 -0
  97. package/dist/types/api/zcashGetAddress.d.ts +20 -0
  98. package/dist/types/api/zcashGetAddress.d.ts.map +1 -0
  99. package/dist/types/api/zcashGetFullViewingKey.d.ts +13 -0
  100. package/dist/types/api/zcashGetFullViewingKey.d.ts.map +1 -0
  101. package/dist/types/api/zcashSignPczt.d.ts +9 -0
  102. package/dist/types/api/zcashSignPczt.d.ts.map +1 -0
  103. package/dist/types/device.d.ts +10 -0
  104. package/dist/types/device.d.ts.map +1 -1
  105. package/dist/utils/logger.d.ts.map +1 -1
  106. package/dist/utils/patch.d.ts +1 -1
  107. package/dist/utils/patch.d.ts.map +1 -1
  108. package/package.json +4 -4
  109. package/src/api/BaseMethod.ts +2 -0
  110. package/src/api/FileWrite.ts +7 -1
  111. package/src/api/FirmwareUpdateV4.ts +358 -74
  112. package/src/api/SearchDevices.ts +172 -7
  113. package/src/api/allnetwork/AllNetworkGetAddressBase.ts +55 -15
  114. package/src/api/btc/BTCDeriveContextHash.ts +90 -0
  115. package/src/api/firmware/FirmwareArtifactSource.ts +12 -3
  116. package/src/api/helpers/pathUtils.ts +23 -0
  117. package/src/api/helpers/protocolV2FileWrite.ts +382 -111
  118. package/src/api/index.ts +9 -0
  119. package/src/api/monero/MoneroGetAddress.ts +71 -0
  120. package/src/api/monero/MoneroGetWatchKey.ts +75 -0
  121. package/src/api/monero/MoneroKeyImageSync.ts +170 -0
  122. package/src/api/monero/MoneroSignTransaction.ts +319 -0
  123. package/src/api/monero/helpers.ts +28 -0
  124. package/src/api/protocol-v2/DeviceUploadNft.ts +6 -1
  125. package/src/api/protocol-v2/DeviceUploadWallpaper.ts +15 -1
  126. package/src/api/zcash/ZcashGetAddress.ts +108 -0
  127. package/src/api/zcash/ZcashGetFullViewingKey.ts +78 -0
  128. package/src/api/zcash/ZcashSignPczt.ts +152 -0
  129. package/src/api/zcash/helpers.ts +16 -0
  130. package/src/core/index.ts +49 -17
  131. package/src/data/messages/messages-protocol-v2.json +152 -0
  132. package/src/data/messages/messages.json +51 -0
  133. package/src/device/Device.ts +21 -3
  134. package/src/device/DeviceCommands.ts +17 -0
  135. package/src/device/DeviceConnector.ts +4 -4
  136. package/src/events/logBlockEvent.ts +58 -3
  137. package/src/events/ui-request.ts +2 -0
  138. package/src/index.ts +1 -0
  139. package/src/inject.ts +17 -0
  140. package/src/protocols/protocol-v2/resources.ts +6 -1
  141. package/src/protocols/protocol-v2/uiInteraction.ts +1 -1
  142. package/src/types/api/allNetworkGetAddress.ts +8 -1
  143. package/src/types/api/btcDeriveContextHash.ts +15 -0
  144. package/src/types/api/export.ts +17 -0
  145. package/src/types/api/index.ts +24 -0
  146. package/src/types/api/moneroGetAddress.ts +27 -0
  147. package/src/types/api/moneroGetWatchKey.ts +28 -0
  148. package/src/types/api/moneroKeyImageSync.ts +45 -0
  149. package/src/types/api/moneroSignTransaction.ts +54 -0
  150. package/src/types/api/zcashGetAddress.ts +32 -0
  151. package/src/types/api/zcashGetFullViewingKey.ts +24 -0
  152. package/src/types/api/zcashSignPczt.ts +18 -0
  153. package/src/types/device.ts +18 -0
  154. package/src/utils/logger.ts +4 -0
@@ -0,0 +1,28 @@
1
+ import type { CommonParams, Response } from '../params';
2
+
3
+ export type MoneroWatchKey = {
4
+ path: string;
5
+ // Private view key, hex
6
+ watchKey: string;
7
+ // Primary address of the account, base58
8
+ address: string;
9
+ };
10
+
11
+ export type MoneroGetWatchKeyParams = {
12
+ // Account path, m/44'/128'/account'
13
+ path: string | number[];
14
+ // 0 mainnet, 1 testnet, 2 stagenet
15
+ networkType?: number;
16
+ };
17
+
18
+ export declare function moneroGetWatchKey(
19
+ connectId: string,
20
+ deviceId: string,
21
+ params: CommonParams & MoneroGetWatchKeyParams
22
+ ): Response<MoneroWatchKey>;
23
+
24
+ export declare function moneroGetWatchKey(
25
+ connectId: string,
26
+ deviceId: string,
27
+ params: CommonParams & { bundle?: MoneroGetWatchKeyParams[] }
28
+ ): Response<Array<MoneroWatchKey>>;
@@ -0,0 +1,45 @@
1
+ import type { CommonParams, Response } from '../params';
2
+
3
+ // One owned output, as wallet2 describes it to the device. Keys are 32-byte hex.
4
+ export type MoneroKeyImageTransfer = {
5
+ // Output public key
6
+ outKey: string;
7
+ // Transaction public key R
8
+ txPubKey: string;
9
+ // Additional tx public keys: the one for this output, or the whole list
10
+ additionalTxPubKeys?: string[];
11
+ // Index of the output within its transaction
12
+ internalOutputIndex: number;
13
+ // Receiving subaddress index; omitted means 0 (primary address)
14
+ subAddrMajor?: number;
15
+ subAddrMinor?: number;
16
+ };
17
+
18
+ // ChaCha20-Poly1305 under encKey, hex.
19
+ export type MoneroEncryptedKeyImage = {
20
+ // 12-byte nonce
21
+ iv: string;
22
+ // Ciphertext of key image || signature c || signature r, then the 16-byte tag
23
+ blob: string;
24
+ };
25
+
26
+ export type MoneroKeyImageSyncResult = {
27
+ // Key that decrypts every blob, hex
28
+ encKey: string;
29
+ // One entry per transfer, in request order
30
+ keyImages: MoneroEncryptedKeyImage[];
31
+ };
32
+
33
+ export type MoneroKeyImageSyncParams = {
34
+ // Account path, m/44'/128'/account'
35
+ path: string | number[];
36
+ // 0 mainnet, 1 testnet, 2 stagenet
37
+ networkType?: number;
38
+ transfers: MoneroKeyImageTransfer[];
39
+ };
40
+
41
+ export declare function moneroKeyImageSync(
42
+ connectId: string,
43
+ deviceId: string,
44
+ params: CommonParams & MoneroKeyImageSyncParams
45
+ ): Response<MoneroKeyImageSyncResult>;
@@ -0,0 +1,54 @@
1
+ import type { MoneroTransactionData, MoneroTransactionSourceEntry } from '@onekeyfe/hd-transport';
2
+ import type { CommonParams, Response } from '../params';
3
+
4
+ export type MoneroSignTransactionParams = {
5
+ // Account path, m/44'/128'/account'
6
+ path: string | number[];
7
+ // 0 mainnet, 1 testnet, 2 stagenet
8
+ networkType?: number;
9
+ // Init data in protobuf field names; outputs include the change, in final order
10
+ tsxData: MoneroTransactionData;
11
+ // One source entry per input, in original order, each with its full ring
12
+ inputs: MoneroTransactionSourceEntry[];
13
+ };
14
+
15
+ // Raw device output, hex unless noted. The host assembles the transaction.
16
+ export type MoneroSignTransactionResult = {
17
+ // Original input index of each sorted input
18
+ origIndices: number[];
19
+ // Serialized tx.vin entries, sorted by key image (descending)
20
+ vinis: string[];
21
+ // Pseudo-output commitments from SignInputAck, sorted order
22
+ pseudoOuts: string[];
23
+ // Sealed CLSAG signatures, sorted order; openingKey unseals them
24
+ signatures: string[];
25
+ // Serialized tx.vout entries, output order
26
+ txOuts: string[];
27
+ // Output key and commitment (64 bytes each), output order
28
+ outPks: string[];
29
+ // Encrypted 8-byte amounts, output order
30
+ ecdhInfos: string[];
31
+ // Aggregated Bulletproof+ without V
32
+ rsig: string;
33
+ extra: string;
34
+ txPrefixHash: string;
35
+ fullMessageHash: string;
36
+ rv: {
37
+ // Decimal piconero
38
+ txnFee: string;
39
+ message: string;
40
+ rvType: number;
41
+ };
42
+ openingKey: string;
43
+ // Tx private keys sealed by the device for later proofs (MoneroGetTxKeyRequest), with the
44
+ // salts that rederive the sealing key; wallet2 keeps them as salt1, salt2, enc_keys
45
+ salt: string;
46
+ randMult: string;
47
+ txEncKeys: string;
48
+ };
49
+
50
+ export declare function moneroSignTransaction(
51
+ connectId: string,
52
+ deviceId: string,
53
+ params: CommonParams & MoneroSignTransactionParams
54
+ ): Response<MoneroSignTransactionResult>;
@@ -0,0 +1,32 @@
1
+ import type { ZcashAddressScope, ZcashAddressType } from '@onekeyfe/hd-transport';
2
+ import type { CommonParams, Response } from '../params';
3
+
4
+ export type ZcashAddress = {
5
+ path: string;
6
+ // ZIP-316 unified address or transparent P2PKH address
7
+ address: string;
8
+ // ZIP-32 seed fingerprint (hex), present when includeSeedFingerprint was requested
9
+ seedFingerprint?: string;
10
+ };
11
+
12
+ export type ZcashGetAddressParams = {
13
+ // ZIP-32 account path, m/32'/133'/account'
14
+ path: string | number[];
15
+ showOnOneKey?: boolean;
16
+ diversifierIndex?: number;
17
+ addressType?: ZcashAddressType;
18
+ scope?: ZcashAddressScope;
19
+ includeSeedFingerprint?: boolean;
20
+ };
21
+
22
+ export declare function zcashGetAddress(
23
+ connectId: string,
24
+ deviceId: string,
25
+ params: CommonParams & ZcashGetAddressParams
26
+ ): Response<ZcashAddress>;
27
+
28
+ export declare function zcashGetAddress(
29
+ connectId: string,
30
+ deviceId: string,
31
+ params: CommonParams & { bundle?: ZcashGetAddressParams[] }
32
+ ): Response<Array<ZcashAddress>>;
@@ -0,0 +1,24 @@
1
+ import type { CommonParams, Response } from '../params';
2
+
3
+ export type ZcashFullViewingKey = {
4
+ path: string;
5
+ // ZIP-316 unified full viewing key with transparent and Orchard components
6
+ ufvk: string;
7
+ };
8
+
9
+ export type ZcashGetFullViewingKeyParams = {
10
+ // ZIP-32 account path, m/32'/133'/account'
11
+ path: string | number[];
12
+ };
13
+
14
+ export declare function zcashGetFullViewingKey(
15
+ connectId: string,
16
+ deviceId: string,
17
+ params: CommonParams & ZcashGetFullViewingKeyParams
18
+ ): Response<ZcashFullViewingKey>;
19
+
20
+ export declare function zcashGetFullViewingKey(
21
+ connectId: string,
22
+ deviceId: string,
23
+ params: CommonParams & { bundle?: ZcashGetFullViewingKeyParams[] }
24
+ ): Response<Array<ZcashFullViewingKey>>;
@@ -0,0 +1,18 @@
1
+ import type { CommonParams, Response } from '../params';
2
+
3
+ export type ZcashSignPcztParams = {
4
+ // Unproved PCZT (v2, tx v6) as hex; the device signs it and returns a
5
+ // redacted copy with signatures filled in.
6
+ pczt: string;
7
+ };
8
+
9
+ export type ZcashSignedPczt = {
10
+ // Signed, redacted PCZT as hex
11
+ pczt: string;
12
+ };
13
+
14
+ export declare function zcashSignPczt(
15
+ connectId: string,
16
+ deviceId: string,
17
+ params: CommonParams & ZcashSignPcztParams
18
+ ): Response<ZcashSignedPczt>;
@@ -83,6 +83,24 @@ export type SearchDevice = {
83
83
  deviceType: IDeviceType;
84
84
  name: string;
85
85
  commType: OneKeyDeviceCommType;
86
+ /**
87
+ * React Native and Electron BLE discovery only. Serial-number color letter ('A'-'Z')
88
+ * advertised by Pro2 / Neo, possibly remembered from an earlier advertisement in this
89
+ * process. Absent when unknown; the letter's meaning depends on deviceType.
90
+ */
91
+ bleColorCode?: string;
92
+ };
93
+
94
+ /** Identity confirmed over USB. The descriptor path is only a transport address. */
95
+ export type UsbDeviceIdentity = {
96
+ path: string;
97
+ serialNo: string | null;
98
+ deviceId: string | null;
99
+ deviceType: IDeviceType;
100
+ connectProtocol: HardwareConnectProtocol;
101
+ commType: 'webusb' | 'bridge';
102
+ /** Mode confirmed by the device response; absent when discovery cannot establish it. */
103
+ mode?: DeviceStateMode;
86
104
  };
87
105
 
88
106
  // export type UnknownDevice = {
@@ -78,6 +78,10 @@ class Log {
78
78
  const _logs: { [k: string]: Log } = {};
79
79
 
80
80
  export const initLog = (prefix: string, enabled?: boolean) => {
81
+ // Loggers that share a prefix must share one instance; otherwise enableLog only reaches the
82
+ // last one registered and the others never print.
83
+ const existing = _logs[prefix];
84
+ if (existing) return existing;
81
85
  const instance = new Log(prefix, !!enabled);
82
86
  _logs[prefix] = instance;
83
87
  return instance;