@onekeyfe/hd-core 1.1.26 → 1.1.27-alpha.31
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/__tests__/evmSignTransaction.test.ts +1 -1
- package/__tests__/evmSignTypedData.test.ts +1 -1
- package/__tests__/protocol-v2.test.ts +1096 -0
- package/dist/api/BaseMethod.d.ts +1 -3
- package/dist/api/BaseMethod.d.ts.map +1 -1
- package/dist/api/DirList.d.ts +10 -0
- package/dist/api/DirList.d.ts.map +1 -0
- package/dist/api/DirMake.d.ts +9 -0
- package/dist/api/DirMake.d.ts.map +1 -0
- package/dist/api/DirRemove.d.ts +9 -0
- package/dist/api/DirRemove.d.ts.map +1 -0
- package/dist/api/FileDelete.d.ts +9 -0
- package/dist/api/FileDelete.d.ts.map +1 -0
- package/dist/api/FileRead.d.ts +19 -0
- package/dist/api/FileRead.d.ts.map +1 -0
- package/dist/api/FileWrite.d.ts +23 -0
- package/dist/api/FileWrite.d.ts.map +1 -0
- package/dist/api/FirmwareUpdateV3.d.ts +1 -0
- package/dist/api/FirmwareUpdateV3.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV4.d.ts +32 -0
- package/dist/api/FirmwareUpdateV4.d.ts.map +1 -0
- package/dist/api/GetOnekeyFeatures.d.ts.map +1 -1
- package/dist/api/GetPassphraseState.d.ts +6 -1
- package/dist/api/GetPassphraseState.d.ts.map +1 -1
- package/dist/api/PathInfo.d.ts +9 -0
- package/dist/api/PathInfo.d.ts.map +1 -0
- package/dist/api/SearchDevices.d.ts +2 -1
- package/dist/api/SearchDevices.d.ts.map +1 -1
- package/dist/api/allnetwork/AllNetworkGetAddressBase.d.ts.map +1 -1
- package/dist/api/conflux/ConfluxSignTransaction.d.ts.map +1 -1
- package/dist/api/device/DeviceRebootToBoardloader.d.ts +1 -1
- package/dist/api/device/DeviceRebootToBoardloader.d.ts.map +1 -1
- package/dist/api/device/DeviceRebootToBootloader.d.ts.map +1 -1
- package/dist/api/dynex/DnxGetAddress.d.ts.map +1 -1
- package/dist/api/dynex/DnxSignTransaction.d.ts.map +1 -1
- package/dist/api/firmware/FirmwareUpdateBaseMethod.d.ts +10 -2
- package/dist/api/firmware/FirmwareUpdateBaseMethod.d.ts.map +1 -1
- package/dist/api/helpers/batchGetPublickeys.d.ts.map +1 -1
- package/dist/api/index.d.ts +26 -0
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/protocol-v2/DeviceFirmwareUpdate.d.ts +7 -0
- package/dist/api/protocol-v2/DeviceFirmwareUpdate.d.ts.map +1 -0
- package/dist/api/protocol-v2/DeviceGetDeviceInfo.d.ts +7 -0
- package/dist/api/protocol-v2/DeviceGetDeviceInfo.d.ts.map +1 -0
- package/dist/api/protocol-v2/DeviceGetFirmwareUpdateStatus.d.ts +6 -0
- package/dist/api/protocol-v2/DeviceGetFirmwareUpdateStatus.d.ts.map +1 -0
- package/dist/api/protocol-v2/DeviceGetOnboardingStatus.d.ts +6 -0
- package/dist/api/protocol-v2/DeviceGetOnboardingStatus.d.ts.map +1 -0
- package/dist/api/protocol-v2/DeviceReboot.d.ts +7 -0
- package/dist/api/protocol-v2/DeviceReboot.d.ts.map +1 -0
- package/dist/api/protocol-v2/FactoryDeviceInfoSettings.d.ts +7 -0
- package/dist/api/protocol-v2/FactoryDeviceInfoSettings.d.ts.map +1 -0
- package/dist/api/protocol-v2/FactoryGetDeviceInfo.d.ts +6 -0
- package/dist/api/protocol-v2/FactoryGetDeviceInfo.d.ts.map +1 -0
- package/dist/api/protocol-v2/FilesystemFixPermission.d.ts +6 -0
- package/dist/api/protocol-v2/FilesystemFixPermission.d.ts.map +1 -0
- package/dist/api/protocol-v2/FilesystemFormat.d.ts +6 -0
- package/dist/api/protocol-v2/FilesystemFormat.d.ts.map +1 -0
- package/dist/api/protocol-v2/GetProtoVersion.d.ts +6 -0
- package/dist/api/protocol-v2/GetProtoVersion.d.ts.map +1 -0
- package/dist/api/protocol-v2/Ping.d.ts +8 -0
- package/dist/api/protocol-v2/Ping.d.ts.map +1 -0
- package/dist/api/protocol-v2/helpers.d.ts +49 -0
- package/dist/api/protocol-v2/helpers.d.ts.map +1 -0
- package/dist/core/index.d.ts.map +1 -1
- package/dist/data-manager/DataManager.d.ts +7 -4
- package/dist/data-manager/DataManager.d.ts.map +1 -1
- package/dist/data-manager/MessagesConfig.d.ts +2 -2
- package/dist/data-manager/MessagesConfig.d.ts.map +1 -1
- package/dist/data-manager/TransportManager.d.ts +5 -4
- package/dist/data-manager/TransportManager.d.ts.map +1 -1
- package/dist/device/Device.d.ts +5 -3
- package/dist/device/Device.d.ts.map +1 -1
- package/dist/device/DeviceCommands.d.ts +8 -8
- package/dist/device/DeviceCommands.d.ts.map +1 -1
- package/dist/device/DeviceConnector.d.ts +2 -1
- package/dist/device/DeviceConnector.d.ts.map +1 -1
- package/dist/events/ui-request.d.ts +8 -0
- package/dist/events/ui-request.d.ts.map +1 -1
- package/dist/index.d.ts +198 -23
- package/dist/index.js +15726 -806
- package/dist/inject.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/features.d.ts +57 -0
- package/dist/protocols/protocol-v2/features.d.ts.map +1 -0
- package/dist/protocols/protocol-v2/firmware.d.ts +12 -0
- package/dist/protocols/protocol-v2/firmware.d.ts.map +1 -0
- package/dist/protocols/protocol-v2/index.d.ts +3 -0
- package/dist/protocols/protocol-v2/index.d.ts.map +1 -0
- package/dist/types/api/export.d.ts +1 -1
- package/dist/types/api/export.d.ts.map +1 -1
- package/dist/types/api/firmwareUpdate.d.ts +7 -0
- package/dist/types/api/firmwareUpdate.d.ts.map +1 -1
- package/dist/types/api/getPassphraseState.d.ts +7 -1
- package/dist/types/api/getPassphraseState.d.ts.map +1 -1
- package/dist/types/api/index.d.ts +29 -1
- package/dist/types/api/index.d.ts.map +1 -1
- package/dist/types/api/protocolV2.d.ts +123 -0
- package/dist/types/api/protocolV2.d.ts.map +1 -0
- package/dist/types/api/searchDevices.d.ts +2 -2
- package/dist/types/api/searchDevices.d.ts.map +1 -1
- package/dist/types/device.d.ts +1 -1
- package/dist/types/device.d.ts.map +1 -1
- package/dist/types/params.d.ts +2 -0
- package/dist/types/params.d.ts.map +1 -1
- package/dist/types/settings.d.ts +1 -1
- package/dist/types/settings.d.ts.map +1 -1
- package/dist/utils/deviceFeaturesUtils.d.ts +3 -3
- package/dist/utils/deviceFeaturesUtils.d.ts.map +1 -1
- package/dist/utils/deviceInfoUtils.d.ts +1 -0
- package/dist/utils/deviceInfoUtils.d.ts.map +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/patch.d.ts +1 -1
- package/dist/utils/patch.d.ts.map +1 -1
- package/dist/utils/versionUtils.d.ts +1 -1
- package/package.json +4 -4
- package/src/api/BaseMethod.ts +12 -60
- package/src/api/DirList.ts +25 -0
- package/src/api/DirMake.ts +20 -0
- package/src/api/DirRemove.ts +20 -0
- package/src/api/FileDelete.ts +20 -0
- package/src/api/FileRead.ts +158 -0
- package/src/api/FileWrite.ts +191 -0
- package/src/api/FirmwareUpdateV3.ts +21 -4
- package/src/api/FirmwareUpdateV4.ts +810 -0
- package/src/api/GetOnekeyFeatures.ts +75 -3
- package/src/api/GetPassphraseState.ts +14 -2
- package/src/api/PathInfo.ts +24 -0
- package/src/api/SearchDevices.ts +7 -2
- package/src/api/allnetwork/AllNetworkGetAddressBase.ts +25 -9
- package/src/api/conflux/ConfluxSignTransaction.ts +5 -2
- package/src/api/device/DeviceRebootToBoardloader.ts +10 -1
- package/src/api/device/DeviceRebootToBootloader.ts +10 -1
- package/src/api/dynex/DnxGetAddress.ts +7 -0
- package/src/api/dynex/DnxSignTransaction.ts +7 -0
- package/src/api/evm/EVMGetAddress.ts +1 -1
- package/src/api/evm/EVMGetPublicKey.ts +1 -1
- package/src/api/evm/EVMSignMessage.ts +1 -1
- package/src/api/evm/EVMSignTransaction.ts +1 -1
- package/src/api/evm/EVMSignTypedData.ts +6 -6
- package/src/api/evm/EVMVerifyMessage.ts +1 -1
- package/src/api/firmware/FirmwareUpdateBaseMethod.ts +27 -4
- package/src/api/helpers/batchGetPublickeys.ts +4 -2
- package/src/api/index.ts +28 -0
- package/src/api/protocol-v2/DeviceFirmwareUpdate.ts +33 -0
- package/src/api/protocol-v2/DeviceGetDeviceInfo.ts +35 -0
- package/src/api/protocol-v2/DeviceGetFirmwareUpdateStatus.ts +18 -0
- package/src/api/protocol-v2/DeviceGetOnboardingStatus.ts +18 -0
- package/src/api/protocol-v2/DeviceReboot.ts +22 -0
- package/src/api/protocol-v2/FactoryDeviceInfoSettings.ts +27 -0
- package/src/api/protocol-v2/FactoryGetDeviceInfo.ts +18 -0
- package/src/api/protocol-v2/FilesystemFixPermission.ts +14 -0
- package/src/api/protocol-v2/FilesystemFormat.ts +14 -0
- package/src/api/protocol-v2/GetProtoVersion.ts +14 -0
- package/src/api/protocol-v2/Ping.ts +16 -0
- package/src/api/protocol-v2/helpers.ts +138 -0
- package/src/api/tron/TronSignMessage.ts +1 -1
- package/src/api/xrp/XrpSignTransaction.ts +1 -1
- package/src/core/index.ts +31 -5
- package/src/data/messages/messages-pro2.json +13106 -0
- package/src/data-manager/DataManager.ts +12 -7
- package/src/data-manager/MessagesConfig.ts +14 -14
- package/src/data-manager/TransportManager.ts +38 -12
- package/src/device/Device.ts +73 -9
- package/src/device/DeviceCommands.ts +162 -26
- package/src/device/DeviceConnector.ts +29 -4
- package/src/device/DevicePool.ts +1 -1
- package/src/events/ui-request.ts +8 -0
- package/src/inject.ts +42 -1
- package/src/protocols/protocol-v2/features.ts +267 -0
- package/src/protocols/protocol-v2/firmware.ts +26 -0
- package/src/protocols/protocol-v2/index.ts +2 -0
- package/src/types/api/export.ts +1 -0
- package/src/types/api/firmwareUpdate.ts +12 -0
- package/src/types/api/getPassphraseState.ts +10 -1
- package/src/types/api/index.ts +64 -1
- package/src/types/api/protocolV2.ts +221 -0
- package/src/types/api/searchDevices.ts +2 -2
- package/src/types/device.ts +3 -1
- package/src/types/params.ts +7 -0
- package/src/types/settings.ts +1 -1
- package/src/utils/deviceFeaturesUtils.ts +33 -15
- package/src/utils/deviceInfoUtils.ts +14 -5
- package/src/utils/index.ts +1 -0
- package/__tests__/DeviceCommands.test.ts +0 -99
- package/__tests__/evmLedgerLegacySafety.test.ts +0 -261
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { BaseMethod } from '../BaseMethod';
|
|
2
|
+
|
|
3
|
+
export default class DeviceGetFirmwareUpdateStatus extends BaseMethod {
|
|
4
|
+
init() {
|
|
5
|
+
this.skipForceUpdateCheck = true;
|
|
6
|
+
this.useDevicePassphraseState = false;
|
|
7
|
+
this.params = undefined;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
async run() {
|
|
11
|
+
const res = await this.device.commands.typedCall(
|
|
12
|
+
'DeviceGetFirmwareUpdateStatus',
|
|
13
|
+
'DeviceFirmwareUpdateStatus',
|
|
14
|
+
{}
|
|
15
|
+
);
|
|
16
|
+
return Promise.resolve(res.message);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { BaseMethod } from '../BaseMethod';
|
|
2
|
+
|
|
3
|
+
export default class DeviceGetOnboardingStatus extends BaseMethod {
|
|
4
|
+
init() {
|
|
5
|
+
this.skipForceUpdateCheck = true;
|
|
6
|
+
this.useDevicePassphraseState = false;
|
|
7
|
+
this.params = undefined;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
async run() {
|
|
11
|
+
const res = await this.device.commands.typedCall(
|
|
12
|
+
'DeviceGetOnboardingStatus',
|
|
13
|
+
'DeviceOnboardingStatus',
|
|
14
|
+
{}
|
|
15
|
+
);
|
|
16
|
+
return Promise.resolve(res.message);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { BaseMethod } from '../BaseMethod';
|
|
2
|
+
import { normalizeRebootType } from './helpers';
|
|
3
|
+
|
|
4
|
+
import type { DeviceRebootParams } from './helpers';
|
|
5
|
+
|
|
6
|
+
export default class DeviceReboot extends BaseMethod<DeviceRebootParams> {
|
|
7
|
+
init() {
|
|
8
|
+
this.skipForceUpdateCheck = true;
|
|
9
|
+
this.useDevicePassphraseState = false;
|
|
10
|
+
this.params = {
|
|
11
|
+
rebootType: this.payload.rebootType,
|
|
12
|
+
reboot_type: this.payload.reboot_type,
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
async run() {
|
|
17
|
+
const res = await this.device.commands.typedCall('DeviceReboot', 'Success', {
|
|
18
|
+
reboot_type: normalizeRebootType(this.params.reboot_type ?? this.params.rebootType),
|
|
19
|
+
});
|
|
20
|
+
return Promise.resolve(res.message);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { BaseMethod } from '../BaseMethod';
|
|
2
|
+
|
|
3
|
+
import type { FactoryDeviceInfoSettingsParams } from './helpers';
|
|
4
|
+
|
|
5
|
+
export default class FactoryDeviceInfoSettings extends BaseMethod<FactoryDeviceInfoSettingsParams> {
|
|
6
|
+
init() {
|
|
7
|
+
this.skipForceUpdateCheck = true;
|
|
8
|
+
this.useDevicePassphraseState = false;
|
|
9
|
+
this.params = {
|
|
10
|
+
serial_no: this.payload.serial_no,
|
|
11
|
+
serialNo: this.payload.serialNo,
|
|
12
|
+
cpu_info: this.payload.cpu_info,
|
|
13
|
+
cpuInfo: this.payload.cpuInfo,
|
|
14
|
+
pre_firmware: this.payload.pre_firmware,
|
|
15
|
+
preFirmware: this.payload.preFirmware,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
async run() {
|
|
20
|
+
const res = await this.device.commands.typedCall('FactoryDeviceInfoSettings', 'Success', {
|
|
21
|
+
serial_no: this.params.serial_no ?? this.params.serialNo,
|
|
22
|
+
cpu_info: this.params.cpu_info ?? this.params.cpuInfo,
|
|
23
|
+
pre_firmware: this.params.pre_firmware ?? this.params.preFirmware,
|
|
24
|
+
});
|
|
25
|
+
return Promise.resolve(res.message);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { BaseMethod } from '../BaseMethod';
|
|
2
|
+
|
|
3
|
+
export default class FactoryGetDeviceInfo extends BaseMethod {
|
|
4
|
+
init() {
|
|
5
|
+
this.skipForceUpdateCheck = true;
|
|
6
|
+
this.useDevicePassphraseState = false;
|
|
7
|
+
this.params = undefined;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
async run() {
|
|
11
|
+
const res = await this.device.commands.typedCall(
|
|
12
|
+
'FactoryGetDeviceInfo',
|
|
13
|
+
'FactoryDeviceInfo',
|
|
14
|
+
{}
|
|
15
|
+
);
|
|
16
|
+
return Promise.resolve(res.message);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { BaseMethod } from '../BaseMethod';
|
|
2
|
+
|
|
3
|
+
export default class FilesystemFixPermission extends BaseMethod {
|
|
4
|
+
init() {
|
|
5
|
+
this.skipForceUpdateCheck = true;
|
|
6
|
+
this.useDevicePassphraseState = false;
|
|
7
|
+
this.params = undefined;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
async run() {
|
|
11
|
+
const res = await this.device.commands.typedCall('FilesystemFixPermission', 'Success', {});
|
|
12
|
+
return Promise.resolve(res.message);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { BaseMethod } from '../BaseMethod';
|
|
2
|
+
|
|
3
|
+
export default class FilesystemFormat extends BaseMethod {
|
|
4
|
+
init() {
|
|
5
|
+
this.skipForceUpdateCheck = true;
|
|
6
|
+
this.useDevicePassphraseState = false;
|
|
7
|
+
this.params = undefined;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
async run() {
|
|
11
|
+
const res = await this.device.commands.typedCall('FilesystemFormat', 'Success', {});
|
|
12
|
+
return Promise.resolve(res.message);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { BaseMethod } from '../BaseMethod';
|
|
2
|
+
|
|
3
|
+
export default class GetProtoVersion extends BaseMethod {
|
|
4
|
+
init() {
|
|
5
|
+
this.skipForceUpdateCheck = true;
|
|
6
|
+
this.useDevicePassphraseState = false;
|
|
7
|
+
this.params = undefined;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
async run() {
|
|
11
|
+
const res = await this.device.commands.typedCall('GetProtoVersion', 'ProtoVersion', {});
|
|
12
|
+
return Promise.resolve(res.message);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { BaseMethod } from '../BaseMethod';
|
|
2
|
+
|
|
3
|
+
export default class Ping extends BaseMethod<{ message?: string }> {
|
|
4
|
+
init() {
|
|
5
|
+
this.skipForceUpdateCheck = true;
|
|
6
|
+
this.useDevicePassphraseState = false;
|
|
7
|
+
this.params = { message: this.payload.message };
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
async run() {
|
|
11
|
+
const res = await this.device.commands.typedCall('Ping', 'Success', {
|
|
12
|
+
message: this.params.message ?? '',
|
|
13
|
+
});
|
|
14
|
+
return Promise.resolve(res.message);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { DeviceRebootType } from '@onekeyfe/hd-transport';
|
|
2
|
+
|
|
3
|
+
import type {
|
|
4
|
+
DeviceFirmwareTarget,
|
|
5
|
+
DeviceFirmwareTargetType,
|
|
6
|
+
DeviceInfoTargets,
|
|
7
|
+
DeviceInfoTypes,
|
|
8
|
+
TransportCallOptions,
|
|
9
|
+
} from '@onekeyfe/hd-transport';
|
|
10
|
+
|
|
11
|
+
export type RebootTypeInput = DeviceRebootType | keyof typeof DeviceRebootType | string | number;
|
|
12
|
+
|
|
13
|
+
export type DeviceRebootParams = {
|
|
14
|
+
rebootType?: RebootTypeInput;
|
|
15
|
+
reboot_type?: RebootTypeInput;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export type DeviceGetDeviceInfoParams = {
|
|
19
|
+
targets?: DeviceInfoTargets;
|
|
20
|
+
types?: DeviceInfoTypes;
|
|
21
|
+
targetHw?: boolean;
|
|
22
|
+
targetFw?: boolean;
|
|
23
|
+
targetBt?: boolean;
|
|
24
|
+
targetSe1?: boolean;
|
|
25
|
+
targetSe2?: boolean;
|
|
26
|
+
targetSe3?: boolean;
|
|
27
|
+
targetSe4?: boolean;
|
|
28
|
+
targetStatus?: boolean;
|
|
29
|
+
includeVersion?: boolean;
|
|
30
|
+
includeBuildId?: boolean;
|
|
31
|
+
includeHash?: boolean;
|
|
32
|
+
includeSpecific?: boolean;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export type DeviceFirmwareTargetInput =
|
|
36
|
+
| DeviceFirmwareTarget
|
|
37
|
+
| {
|
|
38
|
+
targetId?: DeviceFirmwareTargetType | string | number;
|
|
39
|
+
target_id?: DeviceFirmwareTargetType | string | number;
|
|
40
|
+
path: string;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export type DeviceFirmwareUpdateParams = {
|
|
44
|
+
targets?: DeviceFirmwareTargetInput[];
|
|
45
|
+
targetId?: DeviceFirmwareTargetType | string | number;
|
|
46
|
+
target_id?: DeviceFirmwareTargetType | string | number;
|
|
47
|
+
path?: string;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export type FactoryDeviceInfoSettingsParams = {
|
|
51
|
+
serial_no?: string;
|
|
52
|
+
serialNo?: string;
|
|
53
|
+
cpu_info?: string;
|
|
54
|
+
cpuInfo?: string;
|
|
55
|
+
pre_firmware?: string;
|
|
56
|
+
preFirmware?: string;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const DEVICE_REBOOT_TYPES: Record<string, DeviceRebootType> = {
|
|
60
|
+
Normal: DeviceRebootType.Normal,
|
|
61
|
+
normal: DeviceRebootType.Normal,
|
|
62
|
+
Boardloader: DeviceRebootType.Boardloader,
|
|
63
|
+
boardloader: DeviceRebootType.Boardloader,
|
|
64
|
+
Bootloader: DeviceRebootType.Bootloader,
|
|
65
|
+
bootloader: DeviceRebootType.Bootloader,
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export const PROTOCOL_V2_FIRMWARE_UPDATE_OPTIONS: TransportCallOptions = {
|
|
69
|
+
intermediateTypes: ['DeviceFirmwareInstallProgress'],
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export const PROTOCOL_V2_FIRMWARE_UPDATE_RESPONSE_TYPES: ('Success' | 'DeviceFirmwareUpdateStatus')[] =
|
|
73
|
+
['Success', 'DeviceFirmwareUpdateStatus'];
|
|
74
|
+
|
|
75
|
+
export function normalizeRebootType(value: RebootTypeInput | undefined): DeviceRebootType {
|
|
76
|
+
if (typeof value === 'number') return value;
|
|
77
|
+
if (typeof value === 'string') {
|
|
78
|
+
const numeric = Number(value);
|
|
79
|
+
if (Number.isFinite(numeric)) return numeric;
|
|
80
|
+
if (value in DEVICE_REBOOT_TYPES) return DEVICE_REBOOT_TYPES[value];
|
|
81
|
+
}
|
|
82
|
+
return DeviceRebootType.Normal;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function normalizeTargetId(
|
|
86
|
+
value: DeviceFirmwareTargetType | string | number | undefined
|
|
87
|
+
): DeviceFirmwareTargetType {
|
|
88
|
+
if (typeof value === 'number') return value;
|
|
89
|
+
const numeric = Number(value);
|
|
90
|
+
if (Number.isFinite(numeric)) return numeric;
|
|
91
|
+
return 0;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export function normalizeFirmwareTargets(params: DeviceFirmwareUpdateParams): DeviceFirmwareTarget[] {
|
|
95
|
+
const targets =
|
|
96
|
+
params.targets ??
|
|
97
|
+
(params.path
|
|
98
|
+
? [
|
|
99
|
+
{
|
|
100
|
+
target_id: params.target_id ?? params.targetId ?? 0,
|
|
101
|
+
path: params.path,
|
|
102
|
+
},
|
|
103
|
+
]
|
|
104
|
+
: []);
|
|
105
|
+
|
|
106
|
+
return targets.map(target => ({
|
|
107
|
+
target_id: normalizeTargetId('target_id' in target ? target.target_id : target.targetId),
|
|
108
|
+
path: target.path,
|
|
109
|
+
}));
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export function buildTargets(params: DeviceGetDeviceInfoParams): DeviceInfoTargets | undefined {
|
|
113
|
+
if (params.targets) return params.targets;
|
|
114
|
+
|
|
115
|
+
const targets: DeviceInfoTargets = {
|
|
116
|
+
hw: params.targetHw,
|
|
117
|
+
fw: params.targetFw,
|
|
118
|
+
bt: params.targetBt,
|
|
119
|
+
se1: params.targetSe1,
|
|
120
|
+
se2: params.targetSe2,
|
|
121
|
+
se3: params.targetSe3,
|
|
122
|
+
se4: params.targetSe4,
|
|
123
|
+
status: params.targetStatus,
|
|
124
|
+
};
|
|
125
|
+
return Object.values(targets).some(value => value !== undefined) ? targets : undefined;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export function buildTypes(params: DeviceGetDeviceInfoParams): DeviceInfoTypes | undefined {
|
|
129
|
+
if (params.types) return params.types;
|
|
130
|
+
|
|
131
|
+
const types: DeviceInfoTypes = {
|
|
132
|
+
version: params.includeVersion,
|
|
133
|
+
build_id: params.includeBuildId,
|
|
134
|
+
hash: params.includeHash,
|
|
135
|
+
specific: params.includeSpecific,
|
|
136
|
+
};
|
|
137
|
+
return Object.values(types).some(value => value !== undefined) ? types : undefined;
|
|
138
|
+
}
|
|
@@ -28,7 +28,7 @@ export default class TronSignMessage extends BaseMethod<HardwareTronSignMessage>
|
|
|
28
28
|
if (this.payload.messageType === 'V1' || this.payload.messageType == null) {
|
|
29
29
|
throw createDeviceNotSupportMethodError(
|
|
30
30
|
'TronSignMessage',
|
|
31
|
-
getFirmwareType(this.device
|
|
31
|
+
getFirmwareType(this.device?.features)
|
|
32
32
|
);
|
|
33
33
|
}
|
|
34
34
|
|
|
@@ -29,7 +29,7 @@ export default class XrpGetAddress extends BaseMethod<XrpSignTransactionParams>
|
|
|
29
29
|
{ name: 'payment', type: 'object' },
|
|
30
30
|
]);
|
|
31
31
|
validateParams(transaction.payment, [
|
|
32
|
-
{ name: 'amount', type: '
|
|
32
|
+
{ name: 'amount', type: 'uint', required: true },
|
|
33
33
|
{ name: 'destination', type: 'string', required: true },
|
|
34
34
|
{ name: 'destinationTag', type: 'number' },
|
|
35
35
|
]);
|
package/src/core/index.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import semver from 'semver';
|
|
2
2
|
import EventEmitter from 'events';
|
|
3
3
|
import {
|
|
4
|
+
EDeviceType,
|
|
4
5
|
ERRORS,
|
|
5
6
|
ERROR_CODES_REQUIRE_RELEASE,
|
|
6
7
|
HardwareError,
|
|
@@ -19,10 +20,12 @@ import {
|
|
|
19
20
|
enableLog,
|
|
20
21
|
getDeviceBLEFirmwareVersion,
|
|
21
22
|
getDeviceFirmwareVersion,
|
|
23
|
+
getDeviceType,
|
|
22
24
|
getFirmwareType,
|
|
23
25
|
getLogger,
|
|
24
26
|
getMethodVersionRange,
|
|
25
27
|
setLoggerPostMessage,
|
|
28
|
+
shouldSkipMethodSupportCheck,
|
|
26
29
|
wait,
|
|
27
30
|
} from '../utils';
|
|
28
31
|
import {
|
|
@@ -95,6 +98,7 @@ const parseInitOptions = (method?: BaseMethod): InitOptions => ({
|
|
|
95
98
|
passphraseState: method?.payload.passphraseState,
|
|
96
99
|
deviceId: method?.payload.deviceId,
|
|
97
100
|
deriveCardano: method && hasDeriveCardano(method),
|
|
101
|
+
connectProtocol: method?.payload.connectProtocol,
|
|
98
102
|
});
|
|
99
103
|
|
|
100
104
|
let _core: Core;
|
|
@@ -342,6 +346,10 @@ const onCallDevice = async (
|
|
|
342
346
|
device.features,
|
|
343
347
|
type => method.getVersionRange()[type]
|
|
344
348
|
);
|
|
349
|
+
const skipMethodSupportCheck = shouldSkipMethodSupportCheck(
|
|
350
|
+
device.features,
|
|
351
|
+
device.originalDescriptor?.protocolType
|
|
352
|
+
);
|
|
345
353
|
|
|
346
354
|
if (device.features) {
|
|
347
355
|
await DataManager.checkAndReloadData();
|
|
@@ -392,7 +400,7 @@ const onCallDevice = async (
|
|
|
392
400
|
);
|
|
393
401
|
}
|
|
394
402
|
|
|
395
|
-
if (versionRange) {
|
|
403
|
+
if (!skipMethodSupportCheck && versionRange) {
|
|
396
404
|
if (
|
|
397
405
|
semver.valid(versionRange.min) &&
|
|
398
406
|
semver.lt(currentFirmwareVersion, versionRange.min)
|
|
@@ -424,7 +432,7 @@ const onCallDevice = async (
|
|
|
424
432
|
createDeprecatedHardwareError(currentFirmwareVersion, versionRange.max, method.name)
|
|
425
433
|
);
|
|
426
434
|
}
|
|
427
|
-
} else if (method.strictCheckDeviceSupport) {
|
|
435
|
+
} else if (!skipMethodSupportCheck && method.strictCheckDeviceSupport) {
|
|
428
436
|
throw createDeviceNotSupportMethodError(method.name, getFirmwareType(device.features));
|
|
429
437
|
}
|
|
430
438
|
}
|
|
@@ -648,6 +656,7 @@ function initDevice(method: BaseMethod) {
|
|
|
648
656
|
} else if (allDevices.length > 1) {
|
|
649
657
|
throw ERRORS.TypedError(
|
|
650
658
|
[
|
|
659
|
+
'firmwareUpdateV4',
|
|
651
660
|
'firmwareUpdateV3',
|
|
652
661
|
'firmwareUpdateV2',
|
|
653
662
|
'checkFirmwareRelease',
|
|
@@ -702,15 +711,30 @@ function initDeviceForBle(method: BaseMethod) {
|
|
|
702
711
|
*/
|
|
703
712
|
let bleTimeoutRetry = 0;
|
|
704
713
|
|
|
714
|
+
function isRetryableBleProtocolV2ProbeError(method: BaseMethod, error: unknown) {
|
|
715
|
+
const message = error instanceof Error ? error.message : String(error ?? '');
|
|
716
|
+
return (
|
|
717
|
+
method.payload.connectProtocol === 'V2' &&
|
|
718
|
+
message.includes('Device protocol mismatch') &&
|
|
719
|
+
message.includes('expected V2') &&
|
|
720
|
+
message.includes('did not respond to expected protocol')
|
|
721
|
+
);
|
|
722
|
+
}
|
|
723
|
+
|
|
705
724
|
async function connectDeviceForBle(method: BaseMethod, device: Device) {
|
|
706
725
|
try {
|
|
707
|
-
await device.acquire();
|
|
726
|
+
await device.acquire(method.payload.connectProtocol);
|
|
708
727
|
if (method.payload?.onlyConnectBleDevice) {
|
|
709
728
|
return;
|
|
710
729
|
}
|
|
711
730
|
await device.initialize(parseInitOptions(method));
|
|
712
731
|
} catch (err) {
|
|
713
|
-
if (
|
|
732
|
+
if (
|
|
733
|
+
(err.errorCode === HardwareErrorCode.BleTimeoutError ||
|
|
734
|
+
err.errorCode === HardwareErrorCode.BleConnectedError ||
|
|
735
|
+
isRetryableBleProtocolV2ProbeError(method, err)) &&
|
|
736
|
+
bleTimeoutRetry <= 5
|
|
737
|
+
) {
|
|
714
738
|
bleTimeoutRetry += 1;
|
|
715
739
|
Log.debug(`Bletooth connect timeout and will retry, retry count: ${bleTimeoutRetry}`);
|
|
716
740
|
await wait(3000);
|
|
@@ -970,6 +994,8 @@ export const cancel = (context: CoreContext, connectId?: string) => {
|
|
|
970
994
|
const checkPassphraseEnableState = (method: BaseMethod, features?: Features) => {
|
|
971
995
|
if (!method.useDevicePassphraseState) return;
|
|
972
996
|
|
|
997
|
+
const isPro2 = getDeviceType(features) === EDeviceType.Pro2;
|
|
998
|
+
|
|
973
999
|
if (features?.passphrase_protection === true) {
|
|
974
1000
|
const hasNoPassphraseState =
|
|
975
1001
|
method.payload.passphraseState == null || method.payload.passphraseState === '';
|
|
@@ -982,7 +1008,7 @@ const checkPassphraseEnableState = (method: BaseMethod, features?: Features) =>
|
|
|
982
1008
|
}
|
|
983
1009
|
}
|
|
984
1010
|
|
|
985
|
-
if (features?.passphrase_protection === false && method.payload.passphraseState) {
|
|
1011
|
+
if (features?.passphrase_protection === false && method.payload.passphraseState && !isPro2) {
|
|
986
1012
|
DevicePool.clearDeviceCache(method.payload.connectId);
|
|
987
1013
|
throw ERRORS.TypedError(HardwareErrorCode.DeviceNotOpenedPassphrase);
|
|
988
1014
|
}
|