@onekeyfe/hd-core 1.1.27-alpha.30 → 1.1.27-alpha.32
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 +503 -37
- package/dist/api/DirList.d.ts.map +1 -1
- package/dist/api/DirMake.d.ts.map +1 -1
- package/dist/api/DirRemove.d.ts.map +1 -1
- package/dist/api/FileDelete.d.ts.map +1 -1
- package/dist/api/FileRead.d.ts.map +1 -1
- package/dist/api/FileWrite.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.map +1 -1
- package/dist/api/conflux/ConfluxSignTransaction.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/helpers/batchGetPublickeys.d.ts.map +1 -1
- package/dist/api/helpers/filesystemValidation.d.ts +7 -0
- package/dist/api/helpers/filesystemValidation.d.ts.map +1 -0
- package/dist/api/index.d.ts +5 -5
- 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/helpers.d.ts +19 -19
- package/dist/api/protocol-v2/helpers.d.ts.map +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/data-manager/DataManager.d.ts +4 -3
- 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 +3 -3
- package/dist/data-manager/TransportManager.d.ts.map +1 -1
- package/dist/device/Device.d.ts.map +1 -1
- package/dist/index.d.ts +37 -27
- package/dist/index.js +385 -236
- package/dist/protocols/protocol-v2/features.d.ts +2 -1
- package/dist/protocols/protocol-v2/features.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/firmware.d.ts +7 -7
- package/dist/types/api/getPassphraseState.d.ts +10 -1
- package/dist/types/api/getPassphraseState.d.ts.map +1 -1
- package/dist/types/api/index.d.ts +7 -6
- package/dist/types/api/index.d.ts.map +1 -1
- package/dist/types/api/protocolV2.d.ts +16 -16
- package/dist/types/api/protocolV2.d.ts.map +1 -1
- package/dist/utils/deviceFeaturesUtils.d.ts +5 -3
- package/dist/utils/deviceFeaturesUtils.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/DirList.ts +6 -2
- package/src/api/DirMake.ts +2 -1
- package/src/api/DirRemove.ts +2 -1
- package/src/api/FileDelete.ts +2 -1
- package/src/api/FileRead.ts +12 -5
- package/src/api/FileWrite.ts +19 -7
- package/src/api/FirmwareUpdateV4.ts +13 -13
- package/src/api/GetPassphraseState.ts +18 -2
- package/src/api/PathInfo.ts +2 -1
- package/src/api/allnetwork/AllNetworkGetAddressBase.ts +15 -0
- package/src/api/conflux/ConfluxSignTransaction.ts +5 -2
- package/src/api/device/DeviceRebootToBoardloader.ts +4 -4
- package/src/api/device/DeviceRebootToBootloader.ts +4 -4
- 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/helpers/batchGetPublickeys.ts +4 -2
- package/src/api/helpers/filesystemValidation.ts +51 -0
- package/src/api/index.ts +5 -5
- package/src/api/protocol-v2/{DevFirmwareUpdate.ts → DeviceFirmwareUpdate.ts} +5 -4
- package/src/api/protocol-v2/{DevGetDeviceInfo.ts → DeviceGetDeviceInfo.ts} +3 -3
- package/src/api/protocol-v2/{DevGetFirmwareUpdateStatus.ts → DeviceGetFirmwareUpdateStatus.ts} +3 -3
- package/src/api/protocol-v2/{DevGetOnboardingStatus.ts → DeviceGetOnboardingStatus.ts} +3 -3
- package/src/api/protocol-v2/{DevReboot.ts → DeviceReboot.ts} +3 -3
- package/src/api/protocol-v2/helpers.ts +68 -45
- package/src/api/tron/TronSignMessage.ts +1 -1
- package/src/api/xrp/XrpSignTransaction.ts +1 -1
- package/src/core/index.ts +13 -1
- package/src/data/messages/{messages-pro2.json → messages-protocol-v2.json} +67 -63
- package/src/data-manager/DataManager.ts +9 -8
- package/src/data-manager/MessagesConfig.ts +14 -14
- package/src/data-manager/TransportManager.ts +13 -13
- package/src/device/Device.ts +7 -3
- package/src/inject.ts +9 -9
- package/src/protocols/protocol-v2/features.ts +39 -41
- package/src/protocols/protocol-v2/firmware.ts +16 -16
- package/src/types/api/getPassphraseState.ts +15 -2
- package/src/types/api/index.ts +11 -10
- package/src/types/api/protocolV2.ts +27 -27
- package/src/utils/deviceFeaturesUtils.ts +53 -19
- package/dist/api/protocol-v2/DevFirmwareUpdate.d.ts +0 -7
- package/dist/api/protocol-v2/DevFirmwareUpdate.d.ts.map +0 -1
- package/dist/api/protocol-v2/DevGetDeviceInfo.d.ts +0 -7
- package/dist/api/protocol-v2/DevGetDeviceInfo.d.ts.map +0 -1
- package/dist/api/protocol-v2/DevGetFirmwareUpdateStatus.d.ts +0 -6
- package/dist/api/protocol-v2/DevGetFirmwareUpdateStatus.d.ts.map +0 -1
- package/dist/api/protocol-v2/DevGetOnboardingStatus.d.ts +0 -6
- package/dist/api/protocol-v2/DevGetOnboardingStatus.d.ts.map +0 -1
- package/dist/api/protocol-v2/DevReboot.d.ts +0 -7
- package/dist/api/protocol-v2/DevReboot.d.ts.map +0 -1
|
@@ -1,23 +1,25 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DeviceRebootType } from '@onekeyfe/hd-transport';
|
|
2
|
+
|
|
3
|
+
import { invalidParameter, validateNonEmptyString } from '../helpers/filesystemValidation';
|
|
2
4
|
|
|
3
5
|
import type {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
DeviceFirmwareTarget,
|
|
7
|
+
DeviceFirmwareTargetType,
|
|
8
|
+
DeviceInfoTargets,
|
|
9
|
+
DeviceInfoTypes,
|
|
8
10
|
TransportCallOptions,
|
|
9
11
|
} from '@onekeyfe/hd-transport';
|
|
10
12
|
|
|
11
|
-
export type RebootTypeInput =
|
|
13
|
+
export type RebootTypeInput = DeviceRebootType | keyof typeof DeviceRebootType | string | number;
|
|
12
14
|
|
|
13
|
-
export type
|
|
15
|
+
export type DeviceRebootParams = {
|
|
14
16
|
rebootType?: RebootTypeInput;
|
|
15
17
|
reboot_type?: RebootTypeInput;
|
|
16
18
|
};
|
|
17
19
|
|
|
18
|
-
export type
|
|
19
|
-
targets?:
|
|
20
|
-
types?:
|
|
20
|
+
export type DeviceGetDeviceInfoParams = {
|
|
21
|
+
targets?: DeviceInfoTargets;
|
|
22
|
+
types?: DeviceInfoTypes;
|
|
21
23
|
targetHw?: boolean;
|
|
22
24
|
targetFw?: boolean;
|
|
23
25
|
targetBt?: boolean;
|
|
@@ -32,18 +34,18 @@ export type DevGetDeviceInfoParams = {
|
|
|
32
34
|
includeSpecific?: boolean;
|
|
33
35
|
};
|
|
34
36
|
|
|
35
|
-
export type
|
|
36
|
-
|
|
|
37
|
+
export type DeviceFirmwareTargetInput =
|
|
38
|
+
| DeviceFirmwareTarget
|
|
37
39
|
| {
|
|
38
|
-
targetId?:
|
|
39
|
-
target_id?:
|
|
40
|
+
targetId?: DeviceFirmwareTargetType | string | number;
|
|
41
|
+
target_id?: DeviceFirmwareTargetType | string | number;
|
|
40
42
|
path: string;
|
|
41
43
|
};
|
|
42
44
|
|
|
43
|
-
export type
|
|
44
|
-
targets?:
|
|
45
|
-
targetId?:
|
|
46
|
-
target_id?:
|
|
45
|
+
export type DeviceFirmwareUpdateParams = {
|
|
46
|
+
targets?: DeviceFirmwareTargetInput[];
|
|
47
|
+
targetId?: DeviceFirmwareTargetType | string | number;
|
|
48
|
+
target_id?: DeviceFirmwareTargetType | string | number;
|
|
47
49
|
path?: string;
|
|
48
50
|
};
|
|
49
51
|
|
|
@@ -56,42 +58,53 @@ export type FactoryDeviceInfoSettingsParams = {
|
|
|
56
58
|
preFirmware?: string;
|
|
57
59
|
};
|
|
58
60
|
|
|
59
|
-
const
|
|
60
|
-
Normal:
|
|
61
|
-
normal:
|
|
62
|
-
Boardloader:
|
|
63
|
-
boardloader:
|
|
64
|
-
Bootloader:
|
|
65
|
-
bootloader:
|
|
61
|
+
const DEVICE_REBOOT_TYPES: Record<string, DeviceRebootType> = {
|
|
62
|
+
Normal: DeviceRebootType.Normal,
|
|
63
|
+
normal: DeviceRebootType.Normal,
|
|
64
|
+
Boardloader: DeviceRebootType.Boardloader,
|
|
65
|
+
boardloader: DeviceRebootType.Boardloader,
|
|
66
|
+
Bootloader: DeviceRebootType.Bootloader,
|
|
67
|
+
bootloader: DeviceRebootType.Bootloader,
|
|
66
68
|
};
|
|
67
69
|
|
|
68
70
|
export const PROTOCOL_V2_FIRMWARE_UPDATE_OPTIONS: TransportCallOptions = {
|
|
69
|
-
intermediateTypes: ['
|
|
71
|
+
intermediateTypes: ['DeviceFirmwareInstallProgress'],
|
|
70
72
|
};
|
|
71
73
|
|
|
72
|
-
export const PROTOCOL_V2_FIRMWARE_UPDATE_RESPONSE_TYPES: (
|
|
73
|
-
|
|
74
|
+
export const PROTOCOL_V2_FIRMWARE_UPDATE_RESPONSE_TYPES: (
|
|
75
|
+
| 'Success'
|
|
76
|
+
| 'DeviceFirmwareUpdateStatus'
|
|
77
|
+
)[] = ['Success', 'DeviceFirmwareUpdateStatus'];
|
|
74
78
|
|
|
75
|
-
export function normalizeRebootType(value: RebootTypeInput | undefined):
|
|
79
|
+
export function normalizeRebootType(value: RebootTypeInput | undefined): DeviceRebootType {
|
|
76
80
|
if (typeof value === 'number') return value;
|
|
77
81
|
if (typeof value === 'string') {
|
|
78
82
|
const numeric = Number(value);
|
|
79
83
|
if (Number.isFinite(numeric)) return numeric;
|
|
80
|
-
if (value in
|
|
84
|
+
if (value in DEVICE_REBOOT_TYPES) return DEVICE_REBOOT_TYPES[value];
|
|
81
85
|
}
|
|
82
|
-
return
|
|
86
|
+
return DeviceRebootType.Normal;
|
|
83
87
|
}
|
|
84
88
|
|
|
85
89
|
function normalizeTargetId(
|
|
86
|
-
value:
|
|
87
|
-
|
|
88
|
-
|
|
90
|
+
value: DeviceFirmwareTargetType | string | number | undefined,
|
|
91
|
+
name: string
|
|
92
|
+
): DeviceFirmwareTargetType {
|
|
93
|
+
if (value === undefined || value === null) {
|
|
94
|
+
throw invalidParameter(`Missing required parameter: ${name}`);
|
|
95
|
+
}
|
|
96
|
+
if (typeof value === 'number') {
|
|
97
|
+
if (Number.isSafeInteger(value) && value > 0) return value;
|
|
98
|
+
throw invalidParameter(`Parameter [${name}] must be a valid firmware target id.`);
|
|
99
|
+
}
|
|
89
100
|
const numeric = Number(value);
|
|
90
|
-
if (Number.
|
|
91
|
-
|
|
101
|
+
if (Number.isSafeInteger(numeric) && numeric > 0) return numeric;
|
|
102
|
+
throw invalidParameter(`Parameter [${name}] must be a valid firmware target id.`);
|
|
92
103
|
}
|
|
93
104
|
|
|
94
|
-
export function normalizeFirmwareTargets(
|
|
105
|
+
export function normalizeFirmwareTargets(
|
|
106
|
+
params: DeviceFirmwareUpdateParams
|
|
107
|
+
): DeviceFirmwareTarget[] {
|
|
95
108
|
const targets =
|
|
96
109
|
params.targets ??
|
|
97
110
|
(params.path
|
|
@@ -103,16 +116,26 @@ export function normalizeFirmwareTargets(params: DevFirmwareUpdateParams): DevFi
|
|
|
103
116
|
]
|
|
104
117
|
: []);
|
|
105
118
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
119
|
+
if (!Array.isArray(targets) || targets.length === 0) {
|
|
120
|
+
throw invalidParameter('Parameter [targets] must contain at least one firmware target.');
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return targets.map((target, index) => {
|
|
124
|
+
if (!target || typeof target !== 'object') {
|
|
125
|
+
throw invalidParameter(`Parameter [targets.${index}] must be an object.`);
|
|
126
|
+
}
|
|
127
|
+
const targetId = target.target_id ?? target.targetId;
|
|
128
|
+
return {
|
|
129
|
+
target_id: normalizeTargetId(targetId, `targets.${index}.target_id`),
|
|
130
|
+
path: validateNonEmptyString(target.path, `targets.${index}.path`),
|
|
131
|
+
};
|
|
132
|
+
});
|
|
110
133
|
}
|
|
111
134
|
|
|
112
|
-
export function buildTargets(params:
|
|
135
|
+
export function buildTargets(params: DeviceGetDeviceInfoParams): DeviceInfoTargets | undefined {
|
|
113
136
|
if (params.targets) return params.targets;
|
|
114
137
|
|
|
115
|
-
const targets:
|
|
138
|
+
const targets: DeviceInfoTargets = {
|
|
116
139
|
hw: params.targetHw,
|
|
117
140
|
fw: params.targetFw,
|
|
118
141
|
bt: params.targetBt,
|
|
@@ -125,10 +148,10 @@ export function buildTargets(params: DevGetDeviceInfoParams): DevInfoTargets | u
|
|
|
125
148
|
return Object.values(targets).some(value => value !== undefined) ? targets : undefined;
|
|
126
149
|
}
|
|
127
150
|
|
|
128
|
-
export function buildTypes(params:
|
|
151
|
+
export function buildTypes(params: DeviceGetDeviceInfoParams): DeviceInfoTypes | undefined {
|
|
129
152
|
if (params.types) return params.types;
|
|
130
153
|
|
|
131
|
-
const types:
|
|
154
|
+
const types: DeviceInfoTypes = {
|
|
132
155
|
version: params.includeVersion,
|
|
133
156
|
build_id: params.includeBuildId,
|
|
134
157
|
hash: params.includeHash,
|
|
@@ -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,6 +20,7 @@ import {
|
|
|
19
20
|
enableLog,
|
|
20
21
|
getDeviceBLEFirmwareVersion,
|
|
21
22
|
getDeviceFirmwareVersion,
|
|
23
|
+
getDeviceType,
|
|
22
24
|
getFirmwareType,
|
|
23
25
|
getLogger,
|
|
24
26
|
getMethodVersionRange,
|
|
@@ -477,7 +479,7 @@ const onCallDevice = async (
|
|
|
477
479
|
// Check to see if it is safe to use Passphrase
|
|
478
480
|
checkPassphraseEnableState(method, device.features);
|
|
479
481
|
|
|
480
|
-
if (
|
|
482
|
+
if (shouldCheckPassphraseState(method, device)) {
|
|
481
483
|
// check version
|
|
482
484
|
const support = supportNewPassphrase(device.features);
|
|
483
485
|
if (!support.support) {
|
|
@@ -1010,6 +1012,16 @@ const checkPassphraseEnableState = (method: BaseMethod, features?: Features) =>
|
|
|
1010
1012
|
}
|
|
1011
1013
|
};
|
|
1012
1014
|
|
|
1015
|
+
const shouldCheckPassphraseState = (method: BaseMethod, device: Device) => {
|
|
1016
|
+
if (!method.useDevicePassphraseState) return false;
|
|
1017
|
+
|
|
1018
|
+
const isPro2 = getDeviceType(device.features) === EDeviceType.Pro2;
|
|
1019
|
+
const pro2ExplicitWalletSelection =
|
|
1020
|
+
isPro2 && (!!method.payload?.passphraseState || !!method.payload?.useEmptyPassphrase);
|
|
1021
|
+
|
|
1022
|
+
return device.hasUsePassphrase() || pro2ExplicitWalletSelection;
|
|
1023
|
+
};
|
|
1024
|
+
|
|
1013
1025
|
const cleanup = () => {
|
|
1014
1026
|
_uiPromises = [];
|
|
1015
1027
|
Log.debug('Cleanup...');
|
|
@@ -484,11 +484,11 @@
|
|
|
484
484
|
"MessageType_Ping": 60206,
|
|
485
485
|
"MessageType_Success": 60207,
|
|
486
486
|
"MessageType_Failure": 60208,
|
|
487
|
-
"
|
|
488
|
-
"
|
|
487
|
+
"MessageType_DeviceReboot": 60400,
|
|
488
|
+
"MessageType_DeviceGetDeviceInfo": 60600,
|
|
489
489
|
"MessageType_DeviceInfo": 60601,
|
|
490
|
-
"
|
|
491
|
-
"
|
|
490
|
+
"MessageType_DeviceGetOnboardingStatus": 60602,
|
|
491
|
+
"MessageType_DeviceOnboardingStatus": 60603,
|
|
492
492
|
"MessageType_FilesystemFixPermission": 60800,
|
|
493
493
|
"MessageType_FilesystemPathInfo": 60801,
|
|
494
494
|
"MessageType_FilesystemPathInfoQuery": 60802,
|
|
@@ -501,10 +501,10 @@
|
|
|
501
501
|
"MessageType_FilesystemDirMake": 60809,
|
|
502
502
|
"MessageType_FilesystemDirRemove": 60810,
|
|
503
503
|
"MessageType_FilesystemFormat": 60811,
|
|
504
|
-
"
|
|
505
|
-
"
|
|
506
|
-
"
|
|
507
|
-
"
|
|
504
|
+
"MessageType_DeviceFirmwareUpdate": 61000,
|
|
505
|
+
"MessageType_DeviceFirmwareInstallProgress": 61001,
|
|
506
|
+
"MessageType_DeviceGetFirmwareUpdateStatus": 61002,
|
|
507
|
+
"MessageType_DeviceFirmwareUpdateStatus": 61003
|
|
508
508
|
}
|
|
509
509
|
},
|
|
510
510
|
"AlephiumGetAddress": {
|
|
@@ -11790,18 +11790,18 @@
|
|
|
11790
11790
|
}
|
|
11791
11791
|
}
|
|
11792
11792
|
},
|
|
11793
|
-
"
|
|
11793
|
+
"DeviceRebootType": {
|
|
11794
11794
|
"values": {
|
|
11795
11795
|
"Normal": 0,
|
|
11796
11796
|
"Boardloader": 1,
|
|
11797
11797
|
"Bootloader": 2
|
|
11798
11798
|
}
|
|
11799
11799
|
},
|
|
11800
|
-
"
|
|
11800
|
+
"DeviceReboot": {
|
|
11801
11801
|
"fields": {
|
|
11802
11802
|
"reboot_type": {
|
|
11803
11803
|
"rule": "required",
|
|
11804
|
-
"type": "
|
|
11804
|
+
"type": "DeviceRebootType",
|
|
11805
11805
|
"id": 1
|
|
11806
11806
|
}
|
|
11807
11807
|
}
|
|
@@ -11816,20 +11816,20 @@
|
|
|
11816
11816
|
"CLASSIC1S_PURE": 6
|
|
11817
11817
|
}
|
|
11818
11818
|
},
|
|
11819
|
-
"
|
|
11819
|
+
"DeviceSeType": {
|
|
11820
11820
|
"values": {
|
|
11821
11821
|
"THD89": 0,
|
|
11822
11822
|
"SE608A": 1
|
|
11823
11823
|
}
|
|
11824
11824
|
},
|
|
11825
|
-
"
|
|
11825
|
+
"DeviceSEState": {
|
|
11826
11826
|
"values": {
|
|
11827
11827
|
"BOOT": 0,
|
|
11828
11828
|
"APP_FACTORY": 51,
|
|
11829
11829
|
"APP": 85
|
|
11830
11830
|
}
|
|
11831
11831
|
},
|
|
11832
|
-
"
|
|
11832
|
+
"DeviceFirmwareImageInfo": {
|
|
11833
11833
|
"fields": {
|
|
11834
11834
|
"version": {
|
|
11835
11835
|
"type": "string",
|
|
@@ -11845,9 +11845,9 @@
|
|
|
11845
11845
|
}
|
|
11846
11846
|
}
|
|
11847
11847
|
},
|
|
11848
|
-
"
|
|
11848
|
+
"DeviceHardwareInfo": {
|
|
11849
11849
|
"fields": {
|
|
11850
|
-
"
|
|
11850
|
+
"Device_type": {
|
|
11851
11851
|
"type": "DeviceType",
|
|
11852
11852
|
"id": 10
|
|
11853
11853
|
},
|
|
@@ -11865,30 +11865,30 @@
|
|
|
11865
11865
|
}
|
|
11866
11866
|
}
|
|
11867
11867
|
},
|
|
11868
|
-
"
|
|
11868
|
+
"DeviceMainMcuInfo": {
|
|
11869
11869
|
"fields": {
|
|
11870
11870
|
"board": {
|
|
11871
|
-
"type": "
|
|
11871
|
+
"type": "DeviceFirmwareImageInfo",
|
|
11872
11872
|
"id": 10
|
|
11873
11873
|
},
|
|
11874
11874
|
"boot": {
|
|
11875
|
-
"type": "
|
|
11875
|
+
"type": "DeviceFirmwareImageInfo",
|
|
11876
11876
|
"id": 20
|
|
11877
11877
|
},
|
|
11878
11878
|
"app": {
|
|
11879
|
-
"type": "
|
|
11879
|
+
"type": "DeviceFirmwareImageInfo",
|
|
11880
11880
|
"id": 30
|
|
11881
11881
|
}
|
|
11882
11882
|
}
|
|
11883
11883
|
},
|
|
11884
|
-
"
|
|
11884
|
+
"DeviceBluetoothInfo": {
|
|
11885
11885
|
"fields": {
|
|
11886
11886
|
"boot": {
|
|
11887
|
-
"type": "
|
|
11887
|
+
"type": "DeviceFirmwareImageInfo",
|
|
11888
11888
|
"id": 20
|
|
11889
11889
|
},
|
|
11890
11890
|
"app": {
|
|
11891
|
-
"type": "
|
|
11891
|
+
"type": "DeviceFirmwareImageInfo",
|
|
11892
11892
|
"id": 30
|
|
11893
11893
|
},
|
|
11894
11894
|
"adv_name": {
|
|
@@ -11901,27 +11901,27 @@
|
|
|
11901
11901
|
}
|
|
11902
11902
|
}
|
|
11903
11903
|
},
|
|
11904
|
-
"
|
|
11904
|
+
"DeviceSEInfo": {
|
|
11905
11905
|
"fields": {
|
|
11906
11906
|
"boot": {
|
|
11907
|
-
"type": "
|
|
11907
|
+
"type": "DeviceFirmwareImageInfo",
|
|
11908
11908
|
"id": 20
|
|
11909
11909
|
},
|
|
11910
11910
|
"app": {
|
|
11911
|
-
"type": "
|
|
11911
|
+
"type": "DeviceFirmwareImageInfo",
|
|
11912
11912
|
"id": 30
|
|
11913
11913
|
},
|
|
11914
11914
|
"type": {
|
|
11915
|
-
"type": "
|
|
11915
|
+
"type": "DeviceSeType",
|
|
11916
11916
|
"id": 100
|
|
11917
11917
|
},
|
|
11918
11918
|
"state": {
|
|
11919
|
-
"type": "
|
|
11919
|
+
"type": "DeviceSEState",
|
|
11920
11920
|
"id": 110
|
|
11921
11921
|
}
|
|
11922
11922
|
}
|
|
11923
11923
|
},
|
|
11924
|
-
"
|
|
11924
|
+
"DeviceInfoTargets": {
|
|
11925
11925
|
"fields": {
|
|
11926
11926
|
"hw": {
|
|
11927
11927
|
"type": "bool",
|
|
@@ -11957,7 +11957,7 @@
|
|
|
11957
11957
|
}
|
|
11958
11958
|
}
|
|
11959
11959
|
},
|
|
11960
|
-
"
|
|
11960
|
+
"DeviceInfoTypes": {
|
|
11961
11961
|
"fields": {
|
|
11962
11962
|
"version": {
|
|
11963
11963
|
"type": "bool",
|
|
@@ -11977,7 +11977,7 @@
|
|
|
11977
11977
|
}
|
|
11978
11978
|
}
|
|
11979
11979
|
},
|
|
11980
|
-
"
|
|
11980
|
+
"DeviceStatus": {
|
|
11981
11981
|
"fields": {
|
|
11982
11982
|
"language": {
|
|
11983
11983
|
"type": "string",
|
|
@@ -12005,14 +12005,14 @@
|
|
|
12005
12005
|
}
|
|
12006
12006
|
}
|
|
12007
12007
|
},
|
|
12008
|
-
"
|
|
12008
|
+
"DeviceGetDeviceInfo": {
|
|
12009
12009
|
"fields": {
|
|
12010
12010
|
"targets": {
|
|
12011
|
-
"type": "
|
|
12011
|
+
"type": "DeviceInfoTargets",
|
|
12012
12012
|
"id": 1
|
|
12013
12013
|
},
|
|
12014
12014
|
"types": {
|
|
12015
|
-
"type": "
|
|
12015
|
+
"type": "DeviceInfoTypes",
|
|
12016
12016
|
"id": 2
|
|
12017
12017
|
}
|
|
12018
12018
|
}
|
|
@@ -12025,56 +12025,56 @@
|
|
|
12025
12025
|
"id": 1
|
|
12026
12026
|
},
|
|
12027
12027
|
"hw": {
|
|
12028
|
-
"type": "
|
|
12028
|
+
"type": "DeviceHardwareInfo",
|
|
12029
12029
|
"id": 100
|
|
12030
12030
|
},
|
|
12031
12031
|
"fw": {
|
|
12032
|
-
"type": "
|
|
12032
|
+
"type": "DeviceMainMcuInfo",
|
|
12033
12033
|
"id": 200
|
|
12034
12034
|
},
|
|
12035
12035
|
"bt": {
|
|
12036
|
-
"type": "
|
|
12036
|
+
"type": "DeviceBluetoothInfo",
|
|
12037
12037
|
"id": 300
|
|
12038
12038
|
},
|
|
12039
12039
|
"se1": {
|
|
12040
|
-
"type": "
|
|
12040
|
+
"type": "DeviceSEInfo",
|
|
12041
12041
|
"id": 400
|
|
12042
12042
|
},
|
|
12043
12043
|
"se2": {
|
|
12044
|
-
"type": "
|
|
12044
|
+
"type": "DeviceSEInfo",
|
|
12045
12045
|
"id": 410
|
|
12046
12046
|
},
|
|
12047
12047
|
"se3": {
|
|
12048
|
-
"type": "
|
|
12048
|
+
"type": "DeviceSEInfo",
|
|
12049
12049
|
"id": 420
|
|
12050
12050
|
},
|
|
12051
12051
|
"se4": {
|
|
12052
|
-
"type": "
|
|
12052
|
+
"type": "DeviceSEInfo",
|
|
12053
12053
|
"id": 430
|
|
12054
12054
|
},
|
|
12055
12055
|
"status": {
|
|
12056
|
-
"type": "
|
|
12056
|
+
"type": "DeviceStatus",
|
|
12057
12057
|
"id": 10000
|
|
12058
12058
|
}
|
|
12059
12059
|
}
|
|
12060
12060
|
},
|
|
12061
|
-
"
|
|
12061
|
+
"DeviceFirmwareTargetType": {
|
|
12062
12062
|
"values": {
|
|
12063
|
-
"
|
|
12064
|
-
"
|
|
12065
|
-
"
|
|
12066
|
-
"
|
|
12067
|
-
"
|
|
12068
|
-
"
|
|
12069
|
-
"
|
|
12063
|
+
"TARGET_INVALID": 0,
|
|
12064
|
+
"TARGET_ROMLOADER": 1,
|
|
12065
|
+
"TARGET_BOOTLOADER": 2,
|
|
12066
|
+
"TARGET_FIRMWARE_P1": 3,
|
|
12067
|
+
"TARGET_FIRMWARE_P2": 4,
|
|
12068
|
+
"TARGET_COPROCESSOR": 5,
|
|
12069
|
+
"TARGET_SE": 6,
|
|
12070
12070
|
"TARGET_RESOURCE": 10
|
|
12071
12071
|
}
|
|
12072
12072
|
},
|
|
12073
|
-
"
|
|
12073
|
+
"DeviceFirmwareTarget": {
|
|
12074
12074
|
"fields": {
|
|
12075
12075
|
"target_id": {
|
|
12076
12076
|
"rule": "required",
|
|
12077
|
-
"type": "
|
|
12077
|
+
"type": "DeviceFirmwareTargetType",
|
|
12078
12078
|
"id": 1
|
|
12079
12079
|
},
|
|
12080
12080
|
"path": {
|
|
@@ -12084,20 +12084,24 @@
|
|
|
12084
12084
|
}
|
|
12085
12085
|
}
|
|
12086
12086
|
},
|
|
12087
|
-
"
|
|
12087
|
+
"DeviceFirmwareUpdate": {
|
|
12088
12088
|
"fields": {
|
|
12089
12089
|
"targets": {
|
|
12090
12090
|
"rule": "repeated",
|
|
12091
|
-
"type": "
|
|
12091
|
+
"type": "DeviceFirmwareTarget",
|
|
12092
12092
|
"id": 1
|
|
12093
|
+
},
|
|
12094
|
+
"max_concurrent": {
|
|
12095
|
+
"type": "uint32",
|
|
12096
|
+
"id": 2
|
|
12093
12097
|
}
|
|
12094
12098
|
}
|
|
12095
12099
|
},
|
|
12096
|
-
"
|
|
12100
|
+
"DeviceFirmwareInstallProgress": {
|
|
12097
12101
|
"fields": {
|
|
12098
12102
|
"target_id": {
|
|
12099
12103
|
"rule": "required",
|
|
12100
|
-
"type": "
|
|
12104
|
+
"type": "DeviceFirmwareTargetType",
|
|
12101
12105
|
"id": 1
|
|
12102
12106
|
},
|
|
12103
12107
|
"progress": {
|
|
@@ -12111,11 +12115,11 @@
|
|
|
12111
12115
|
}
|
|
12112
12116
|
}
|
|
12113
12117
|
},
|
|
12114
|
-
"
|
|
12118
|
+
"DeviceFirmwareUpdateStatusEntry": {
|
|
12115
12119
|
"fields": {
|
|
12116
12120
|
"target_id": {
|
|
12117
12121
|
"rule": "required",
|
|
12118
|
-
"type": "
|
|
12122
|
+
"type": "DeviceFirmwareTargetType",
|
|
12119
12123
|
"id": 1
|
|
12120
12124
|
},
|
|
12121
12125
|
"status": {
|
|
@@ -12125,14 +12129,14 @@
|
|
|
12125
12129
|
}
|
|
12126
12130
|
}
|
|
12127
12131
|
},
|
|
12128
|
-
"
|
|
12132
|
+
"DeviceGetFirmwareUpdateStatus": {
|
|
12129
12133
|
"fields": {}
|
|
12130
12134
|
},
|
|
12131
|
-
"
|
|
12135
|
+
"DeviceFirmwareUpdateStatus": {
|
|
12132
12136
|
"fields": {
|
|
12133
12137
|
"targets": {
|
|
12134
12138
|
"rule": "repeated",
|
|
12135
|
-
"type": "
|
|
12139
|
+
"type": "DeviceFirmwareUpdateStatusEntry",
|
|
12136
12140
|
"id": 1
|
|
12137
12141
|
}
|
|
12138
12142
|
}
|
|
@@ -12399,10 +12403,10 @@
|
|
|
12399
12403
|
"FilesystemFormat": {
|
|
12400
12404
|
"fields": {}
|
|
12401
12405
|
},
|
|
12402
|
-
"
|
|
12406
|
+
"DeviceGetOnboardingStatus": {
|
|
12403
12407
|
"fields": {}
|
|
12404
12408
|
},
|
|
12405
|
-
"
|
|
12409
|
+
"DeviceOnboardingStatus": {
|
|
12406
12410
|
"fields": {
|
|
12407
12411
|
"page_index": {
|
|
12408
12412
|
"type": "uint32",
|
|
@@ -4,7 +4,7 @@ import { EDeviceType, EFirmwareType } from '@onekeyfe/hd-shared';
|
|
|
4
4
|
|
|
5
5
|
import MessagesJSON from '../data/messages/messages.json';
|
|
6
6
|
import MessagesLegacyV1JSON from '../data/messages/messages_legacy_v1.json';
|
|
7
|
-
import
|
|
7
|
+
import MessagesProtocolV2JSON from '../data/messages/messages-protocol-v2.json';
|
|
8
8
|
import {
|
|
9
9
|
LoggerNames,
|
|
10
10
|
getDeviceBLEFirmwareVersion,
|
|
@@ -41,7 +41,8 @@ export const FIRMWARE_FIELDS = [
|
|
|
41
41
|
|
|
42
42
|
export type IFirmwareField = (typeof FIRMWARE_FIELDS)[number];
|
|
43
43
|
|
|
44
|
-
export type
|
|
44
|
+
export type ProtocolV1MessageSchema = 'v1CurrentSchema' | 'v1LegacySchema';
|
|
45
|
+
export type ProtobufMessageSchema = ProtocolV1MessageSchema | 'v2Schema';
|
|
45
46
|
|
|
46
47
|
const FIRMWARE_FIELD_TYPE_MAP: Readonly<Record<IFirmwareField, EFirmwareType>> = {
|
|
47
48
|
firmware: EFirmwareType.Universal,
|
|
@@ -96,10 +97,10 @@ export default class DataManager {
|
|
|
96
97
|
|
|
97
98
|
static settings: ConnectSettings;
|
|
98
99
|
|
|
99
|
-
static messages: { [
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
100
|
+
static messages: { [schema in ProtobufMessageSchema]: JSON } = {
|
|
101
|
+
v1CurrentSchema: MessagesJSON as unknown as JSON,
|
|
102
|
+
v1LegacySchema: MessagesLegacyV1JSON as unknown as JSON,
|
|
103
|
+
v2Schema: MessagesProtocolV2JSON as unknown as JSON,
|
|
103
104
|
};
|
|
104
105
|
|
|
105
106
|
static lastCheckTimestamp = 0;
|
|
@@ -476,8 +477,8 @@ export default class DataManager {
|
|
|
476
477
|
}
|
|
477
478
|
}
|
|
478
479
|
|
|
479
|
-
static getProtobufMessages(
|
|
480
|
-
return this.messages[
|
|
480
|
+
static getProtobufMessages(schema: ProtobufMessageSchema = 'v1CurrentSchema'): JSON {
|
|
481
|
+
return this.messages[schema];
|
|
481
482
|
}
|
|
482
483
|
|
|
483
484
|
static getSettings(key?: undefined): ConnectSettings;
|
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
import type { IDeviceModel, IDeviceType } from '../types';
|
|
2
|
-
import type {
|
|
2
|
+
import type { ProtocolV1MessageSchema } from './DataManager';
|
|
3
3
|
|
|
4
4
|
type DeviceVersionConfig = {
|
|
5
5
|
[deviceType in IDeviceType | IDeviceModel]?: {
|
|
6
6
|
minVersion: string;
|
|
7
|
-
|
|
7
|
+
protocolV1MessageSchema: ProtocolV1MessageSchema;
|
|
8
8
|
}[];
|
|
9
9
|
};
|
|
10
10
|
|
|
11
11
|
export const PROTOBUF_MESSAGE_CONFIG: DeviceVersionConfig = {
|
|
12
12
|
model_mini: [
|
|
13
|
-
// Classic1s starts from 3.5.0, so use
|
|
14
|
-
// Only use
|
|
15
|
-
{ minVersion: '3.3.0',
|
|
16
|
-
{ minVersion: '0.0.1',
|
|
17
|
-
// Fallback to
|
|
18
|
-
{ minVersion: '0.0.0',
|
|
13
|
+
// Classic1s starts from 3.5.0, so use the current Protocol V1 schema by default.
|
|
14
|
+
// Only use the legacy Protocol V1 schema for specific old versions (< 3.3.0).
|
|
15
|
+
{ minVersion: '3.3.0', protocolV1MessageSchema: 'v1CurrentSchema' },
|
|
16
|
+
{ minVersion: '0.0.1', protocolV1MessageSchema: 'v1LegacySchema' },
|
|
17
|
+
// Fallback to current Protocol V1 schema for unknown versions (0.0.0).
|
|
18
|
+
{ minVersion: '0.0.0', protocolV1MessageSchema: 'v1CurrentSchema' },
|
|
19
19
|
],
|
|
20
20
|
model_touch: [
|
|
21
|
-
// Use
|
|
22
|
-
// Only use
|
|
23
|
-
{ minVersion: '4.5.0',
|
|
24
|
-
{ minVersion: '0.0.1',
|
|
25
|
-
// Fallback to
|
|
26
|
-
{ minVersion: '0.0.0',
|
|
21
|
+
// Use the current Protocol V1 schema by default for Touch/Pro.
|
|
22
|
+
// Only use the legacy Protocol V1 schema for specific old versions (< 4.5.0).
|
|
23
|
+
{ minVersion: '4.5.0', protocolV1MessageSchema: 'v1CurrentSchema' },
|
|
24
|
+
{ minVersion: '0.0.1', protocolV1MessageSchema: 'v1LegacySchema' },
|
|
25
|
+
// Fallback to current Protocol V1 schema for unknown versions (0.0.0).
|
|
26
|
+
{ minVersion: '0.0.0', protocolV1MessageSchema: 'v1CurrentSchema' },
|
|
27
27
|
],
|
|
28
28
|
};
|