@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.
- package/README.md +27 -0
- package/__tests__/AllNetworkGetAddressBase.tracing.test.ts +13 -4
- package/__tests__/DeviceCommands.test.ts +25 -0
- package/__tests__/allNetworkGetAddress-privacy-networks.test.ts +77 -0
- package/__tests__/allNetworkGetAddress-skippable.test.ts +49 -0
- package/__tests__/btc-derive-context-hash.test.ts +200 -0
- package/__tests__/core-dispose.test.ts +114 -1
- package/__tests__/core-error-output.test.ts +21 -0
- package/__tests__/device-connector-protocol.test.ts +5 -2
- package/__tests__/device-lifecycle-events.test.ts +127 -10
- package/__tests__/firmware-update/firmware-artifact-source.test.ts +11 -0
- package/__tests__/logBlockEvent.test.ts +331 -9
- package/__tests__/logger.test.ts +18 -0
- package/__tests__/monero-get-address.test.ts +147 -0
- package/__tests__/monero-key-image-sync.test.ts +272 -0
- package/__tests__/monero-sign-transaction.test.ts +436 -0
- package/__tests__/protocol-v2-key-export-confirmation.test.ts +75 -0
- package/__tests__/protocol-v2-resources.test.ts +14 -0
- package/__tests__/protocol-v2.test.ts +845 -3
- package/__tests__/protocolV2FileWrite.test.ts +454 -7
- package/__tests__/search-devices.test.ts +36 -0
- package/__tests__/sol-sign-offchain-message.test.ts +8 -0
- package/__tests__/usb-identity-probe.test.ts +358 -0
- package/__tests__/zcash-protobuf.test.ts +152 -0
- package/__tests__/zcash-sign-pczt.test.ts +525 -0
- package/dist/api/BaseMethod.d.ts.map +1 -1
- package/dist/api/FileWrite.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV4.d.ts +5 -0
- package/dist/api/FirmwareUpdateV4.d.ts.map +1 -1
- package/dist/api/SearchDevices.d.ts +21 -1
- package/dist/api/SearchDevices.d.ts.map +1 -1
- package/dist/api/allnetwork/AllNetworkGetAddressBase.d.ts +3 -0
- package/dist/api/allnetwork/AllNetworkGetAddressBase.d.ts.map +1 -1
- package/dist/api/btc/BTCDeriveContextHash.d.ts +16 -0
- package/dist/api/btc/BTCDeriveContextHash.d.ts.map +1 -0
- package/dist/api/firmware/FirmwareArtifactSource.d.ts.map +1 -1
- package/dist/api/helpers/pathUtils.d.ts +1 -0
- package/dist/api/helpers/pathUtils.d.ts.map +1 -1
- package/dist/api/helpers/protocolV2FileWrite.d.ts +5 -1
- package/dist/api/helpers/protocolV2FileWrite.d.ts.map +1 -1
- package/dist/api/index.d.ts +8 -0
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/monero/MoneroGetAddress.d.ts +11 -0
- package/dist/api/monero/MoneroGetAddress.d.ts.map +1 -0
- package/dist/api/monero/MoneroGetWatchKey.d.ts +11 -0
- package/dist/api/monero/MoneroGetWatchKey.d.ts.map +1 -0
- package/dist/api/monero/MoneroKeyImageSync.d.ts +20 -0
- package/dist/api/monero/MoneroKeyImageSync.d.ts.map +1 -0
- package/dist/api/monero/MoneroSignTransaction.d.ts +17 -0
- package/dist/api/monero/MoneroSignTransaction.d.ts.map +1 -0
- package/dist/api/monero/helpers.d.ts +5 -0
- package/dist/api/monero/helpers.d.ts.map +1 -0
- package/dist/api/protocol-v2/DeviceUploadNft.d.ts.map +1 -1
- package/dist/api/protocol-v2/DeviceUploadWallpaper.d.ts.map +1 -1
- package/dist/api/zcash/ZcashGetAddress.d.ts +12 -0
- package/dist/api/zcash/ZcashGetAddress.d.ts.map +1 -0
- package/dist/api/zcash/ZcashGetFullViewingKey.d.ts +12 -0
- package/dist/api/zcash/ZcashGetFullViewingKey.d.ts.map +1 -0
- package/dist/api/zcash/ZcashSignPczt.d.ts +16 -0
- package/dist/api/zcash/ZcashSignPczt.d.ts.map +1 -0
- package/dist/api/zcash/helpers.d.ts +2 -0
- package/dist/api/zcash/helpers.d.ts.map +1 -0
- package/dist/core/index.d.ts +3 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/device/Device.d.ts +1 -0
- package/dist/device/Device.d.ts.map +1 -1
- package/dist/device/DeviceCommands.d.ts +4 -4
- package/dist/device/DeviceCommands.d.ts.map +1 -1
- package/dist/events/logBlockEvent.d.ts +10 -0
- package/dist/events/logBlockEvent.d.ts.map +1 -1
- package/dist/events/ui-request.d.ts +2 -0
- package/dist/events/ui-request.d.ts.map +1 -1
- package/dist/index.d.ts +202 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5849 -4205
- package/dist/inject.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/resources.d.ts +1 -0
- package/dist/protocols/protocol-v2/resources.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/uiInteraction.d.ts +1 -0
- package/dist/protocols/protocol-v2/uiInteraction.d.ts.map +1 -1
- package/dist/types/api/allNetworkGetAddress.d.ts +4 -1
- package/dist/types/api/allNetworkGetAddress.d.ts.map +1 -1
- package/dist/types/api/btcDeriveContextHash.d.ts +10 -0
- package/dist/types/api/btcDeriveContextHash.d.ts.map +1 -0
- package/dist/types/api/export.d.ts +8 -0
- package/dist/types/api/export.d.ts.map +1 -1
- package/dist/types/api/index.d.ts +16 -0
- package/dist/types/api/index.d.ts.map +1 -1
- package/dist/types/api/moneroGetAddress.d.ts +15 -0
- package/dist/types/api/moneroGetAddress.d.ts.map +1 -0
- package/dist/types/api/moneroGetWatchKey.d.ts +15 -0
- package/dist/types/api/moneroGetWatchKey.d.ts.map +1 -0
- package/dist/types/api/moneroKeyImageSync.d.ts +24 -0
- package/dist/types/api/moneroKeyImageSync.d.ts.map +1 -0
- package/dist/types/api/moneroSignTransaction.d.ts +32 -0
- package/dist/types/api/moneroSignTransaction.d.ts.map +1 -0
- package/dist/types/api/zcashGetAddress.d.ts +20 -0
- package/dist/types/api/zcashGetAddress.d.ts.map +1 -0
- package/dist/types/api/zcashGetFullViewingKey.d.ts +13 -0
- package/dist/types/api/zcashGetFullViewingKey.d.ts.map +1 -0
- package/dist/types/api/zcashSignPczt.d.ts +9 -0
- package/dist/types/api/zcashSignPczt.d.ts.map +1 -0
- package/dist/types/device.d.ts +10 -0
- package/dist/types/device.d.ts.map +1 -1
- package/dist/utils/logger.d.ts.map +1 -1
- package/dist/utils/patch.d.ts +1 -1
- package/dist/utils/patch.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/api/BaseMethod.ts +2 -0
- package/src/api/FileWrite.ts +7 -1
- package/src/api/FirmwareUpdateV4.ts +358 -74
- package/src/api/SearchDevices.ts +172 -7
- package/src/api/allnetwork/AllNetworkGetAddressBase.ts +55 -15
- package/src/api/btc/BTCDeriveContextHash.ts +90 -0
- package/src/api/firmware/FirmwareArtifactSource.ts +12 -3
- package/src/api/helpers/pathUtils.ts +23 -0
- package/src/api/helpers/protocolV2FileWrite.ts +382 -111
- package/src/api/index.ts +9 -0
- package/src/api/monero/MoneroGetAddress.ts +71 -0
- package/src/api/monero/MoneroGetWatchKey.ts +75 -0
- package/src/api/monero/MoneroKeyImageSync.ts +170 -0
- package/src/api/monero/MoneroSignTransaction.ts +319 -0
- package/src/api/monero/helpers.ts +28 -0
- package/src/api/protocol-v2/DeviceUploadNft.ts +6 -1
- package/src/api/protocol-v2/DeviceUploadWallpaper.ts +15 -1
- package/src/api/zcash/ZcashGetAddress.ts +108 -0
- package/src/api/zcash/ZcashGetFullViewingKey.ts +78 -0
- package/src/api/zcash/ZcashSignPczt.ts +152 -0
- package/src/api/zcash/helpers.ts +16 -0
- package/src/core/index.ts +49 -17
- package/src/data/messages/messages-protocol-v2.json +152 -0
- package/src/data/messages/messages.json +51 -0
- package/src/device/Device.ts +21 -3
- package/src/device/DeviceCommands.ts +17 -0
- package/src/device/DeviceConnector.ts +4 -4
- package/src/events/logBlockEvent.ts +58 -3
- package/src/events/ui-request.ts +2 -0
- package/src/index.ts +1 -0
- package/src/inject.ts +17 -0
- package/src/protocols/protocol-v2/resources.ts +6 -1
- package/src/protocols/protocol-v2/uiInteraction.ts +1 -1
- package/src/types/api/allNetworkGetAddress.ts +8 -1
- package/src/types/api/btcDeriveContextHash.ts +15 -0
- package/src/types/api/export.ts +17 -0
- package/src/types/api/index.ts +24 -0
- package/src/types/api/moneroGetAddress.ts +27 -0
- package/src/types/api/moneroGetWatchKey.ts +28 -0
- package/src/types/api/moneroKeyImageSync.ts +45 -0
- package/src/types/api/moneroSignTransaction.ts +54 -0
- package/src/types/api/zcashGetAddress.ts +32 -0
- package/src/types/api/zcashGetFullViewingKey.ts +24 -0
- package/src/types/api/zcashSignPczt.ts +18 -0
- package/src/types/device.ts +18 -0
- 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>;
|
package/src/types/device.ts
CHANGED
|
@@ -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 = {
|
package/src/utils/logger.ts
CHANGED
|
@@ -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;
|