@onekeyfe/hd-core 1.2.0-alpha.0 → 1.2.0-alpha.1
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__/protocol-v2.test.ts +147 -264
- package/dist/api/FirmwareUpdateV2.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV3.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV4.d.ts +2 -2
- package/dist/api/FirmwareUpdateV4.d.ts.map +1 -1
- package/dist/api/GetDeviceInfo.d.ts.map +1 -1
- package/dist/api/GetFeatures.d.ts +1 -1
- package/dist/api/GetOnekeyFeatures.d.ts.map +1 -1
- package/dist/api/GetPassphraseState.d.ts +4 -4
- package/dist/api/device/DeviceUnlock.d.ts +1 -1
- package/dist/api/firmware/bootloaderHelper.d.ts.map +1 -1
- package/dist/api/firmware/uploadFirmware.d.ts.map +1 -1
- package/dist/api/protocol-v2/helpers.d.ts +2 -3
- package/dist/api/protocol-v2/helpers.d.ts.map +1 -1
- package/dist/constants/index.d.ts +2 -1
- package/dist/constants/index.d.ts.map +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/data-manager/connectSettings.d.ts.map +1 -1
- package/dist/device/Device.d.ts +11 -15
- package/dist/device/Device.d.ts.map +1 -1
- package/dist/deviceProfile/buildDeviceFeatures.d.ts +6 -0
- package/dist/deviceProfile/buildDeviceFeatures.d.ts.map +1 -0
- package/dist/deviceProfile/buildDeviceProfile.d.ts +3 -4
- package/dist/deviceProfile/buildDeviceProfile.d.ts.map +1 -1
- package/dist/deviceProfile/index.d.ts +1 -1
- package/dist/deviceProfile/index.d.ts.map +1 -1
- package/dist/index.d.ts +579 -502
- package/dist/index.js +881 -931
- package/dist/protocols/protocol-v2/features.d.ts +2 -2
- package/dist/protocols/protocol-v2/features.d.ts.map +1 -1
- package/dist/types/api/getDeviceInfo.d.ts +2 -2
- package/dist/types/api/getDeviceInfo.d.ts.map +1 -1
- package/dist/types/api/getPassphraseState.d.ts +4 -4
- package/dist/types/api/getPassphraseState.d.ts.map +1 -1
- package/dist/types/api/protocolV2.d.ts +3 -3
- package/dist/types/api/protocolV2.d.ts.map +1 -1
- package/dist/types/device.d.ts +87 -8
- package/dist/types/device.d.ts.map +1 -1
- package/dist/types/settings.d.ts +1 -0
- package/dist/types/settings.d.ts.map +1 -1
- package/dist/utils/capabilitieUtils.d.ts.map +1 -1
- package/dist/utils/deviceFeaturesUtils.d.ts.map +1 -1
- package/dist/utils/deviceInfoUtils.d.ts.map +1 -1
- package/dist/utils/deviceVersionUtils.d.ts.map +1 -1
- package/dist/utils/findDefectiveBatchDevice.d.ts +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/FirmwareUpdateV2.ts +9 -2
- package/src/api/FirmwareUpdateV3.ts +2 -1
- package/src/api/FirmwareUpdateV4.ts +24 -31
- package/src/api/GetDeviceInfo.ts +6 -13
- package/src/api/GetOnekeyFeatures.ts +3 -14
- package/src/api/GetPassphraseState.ts +4 -4
- package/src/api/firmware/bootloaderHelper.ts +3 -2
- package/src/api/firmware/getBinary.ts +1 -1
- package/src/api/firmware/releaseHelper.ts +3 -3
- package/src/api/firmware/uploadFirmware.ts +5 -2
- package/src/api/protocol-v2/DeviceReboot.ts +3 -3
- package/src/api/protocol-v2/helpers.ts +1 -26
- package/src/constants/index.ts +10 -1
- package/src/core/index.ts +5 -7
- package/src/data/messages/messages-protocol-v2.json +329 -323
- package/src/data-manager/DataManager.ts +4 -4
- package/src/data-manager/connectSettings.ts +6 -0
- package/src/device/Device.ts +86 -241
- package/src/device/DevicePool.ts +9 -9
- package/src/deviceProfile/buildDeviceFeatures.ts +368 -0
- package/src/deviceProfile/buildDeviceProfile.ts +101 -155
- package/src/deviceProfile/index.ts +4 -1
- package/src/protocols/protocol-v2/features.ts +14 -16
- package/src/types/api/getDeviceInfo.ts +2 -2
- package/src/types/api/getPassphraseState.ts +4 -4
- package/src/types/api/protocolV2.ts +2 -3
- package/src/types/device.ts +97 -34
- package/src/types/settings.ts +5 -0
- package/src/utils/capabilitieUtils.ts +1 -2
- package/src/utils/deviceFeaturesUtils.ts +11 -17
- package/src/utils/deviceInfoUtils.ts +11 -29
- package/src/utils/deviceVersionUtils.ts +7 -25
- package/src/utils/findDefectiveBatchDevice.ts +6 -6
- package/dist/deviceProfile/legacyFeaturesView.d.ts +0 -5
- package/dist/deviceProfile/legacyFeaturesView.d.ts.map +0 -1
- package/src/deviceProfile/legacyFeaturesView.ts +0 -123
package/src/types/device.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { EDeviceType } from '@onekeyfe/hd-shared';
|
|
1
|
+
import { EDeviceType, type EFirmwareType } from '@onekeyfe/hd-shared';
|
|
2
2
|
|
|
3
3
|
import type { IVersionArray } from './settings';
|
|
4
4
|
import type { PROTO } from '../constants';
|
|
5
|
-
import type { OneKeyDeviceCommType } from '@onekeyfe/hd-transport';
|
|
6
|
-
import type { DeviceProfile } from './api/getDeviceInfo';
|
|
5
|
+
import type { OneKeyDeviceCommType, ProtocolV2DeviceInfo } from '@onekeyfe/hd-transport';
|
|
7
6
|
|
|
8
7
|
export type DeviceStatus = 'available' | 'occupied' | 'used';
|
|
9
8
|
|
|
@@ -34,8 +33,7 @@ export type KnownDevice = {
|
|
|
34
33
|
name: string;
|
|
35
34
|
error?: typeof undefined;
|
|
36
35
|
mode: EOneKeyDeviceMode;
|
|
37
|
-
|
|
38
|
-
features?: PROTO.Features;
|
|
36
|
+
features?: Features;
|
|
39
37
|
sessionId?: string | null;
|
|
40
38
|
unavailableCapabilities: UnavailableCapabilities;
|
|
41
39
|
bleFirmwareVersion: IVersionArray | null;
|
|
@@ -88,35 +86,100 @@ export type SearchDevice = {
|
|
|
88
86
|
|
|
89
87
|
export type Device = KnownDevice;
|
|
90
88
|
|
|
91
|
-
type
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
89
|
+
export type DeviceFeaturesProtocol = 'V1' | 'V2' | 'unknown';
|
|
90
|
+
|
|
91
|
+
export type DeviceFeaturesMode =
|
|
92
|
+
| 'normal'
|
|
93
|
+
| 'bootloader'
|
|
94
|
+
| 'notInitialized'
|
|
95
|
+
| 'backupMode'
|
|
96
|
+
| 'unknown';
|
|
97
|
+
|
|
98
|
+
export type DeviceFeaturesVerify = {
|
|
99
|
+
firmwareBuildId?: string;
|
|
100
|
+
firmwareHash?: string;
|
|
101
|
+
bootloaderBuildId?: string;
|
|
102
|
+
bootloaderHash?: string;
|
|
103
|
+
boardBuildId?: string;
|
|
104
|
+
boardHash?: string;
|
|
105
|
+
bleBuildId?: string;
|
|
106
|
+
bleHash?: string;
|
|
107
|
+
se01BuildId?: string;
|
|
108
|
+
se01Hash?: string;
|
|
109
|
+
se02BuildId?: string;
|
|
110
|
+
se02Hash?: string;
|
|
111
|
+
se03BuildId?: string;
|
|
112
|
+
se03Hash?: string;
|
|
113
|
+
se04BuildId?: string;
|
|
114
|
+
se04Hash?: string;
|
|
115
|
+
se01BootBuildId?: string;
|
|
116
|
+
se01BootHash?: string;
|
|
117
|
+
se02BootBuildId?: string;
|
|
118
|
+
se02BootHash?: string;
|
|
119
|
+
se03BootBuildId?: string;
|
|
120
|
+
se03BootHash?: string;
|
|
121
|
+
se04BootBuildId?: string;
|
|
122
|
+
se04BootHash?: string;
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
export type DeviceFeaturesRaw = {
|
|
126
|
+
protocolV1Features?: PROTO.Features;
|
|
127
|
+
protocolV1OneKeyFeatures?: OnekeyFeatures;
|
|
128
|
+
protocolV2DeviceInfo?: ProtocolV2DeviceInfo;
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
export type Features = {
|
|
132
|
+
protocol: DeviceFeaturesProtocol;
|
|
133
|
+
protocolVersion?: number | null;
|
|
134
|
+
deviceType: IDeviceType;
|
|
135
|
+
firmwareType: EFirmwareType;
|
|
136
|
+
model: string | null;
|
|
137
|
+
vendor: string | null;
|
|
138
|
+
deviceId: string | null;
|
|
139
|
+
serialNo: string;
|
|
140
|
+
label: string | null;
|
|
141
|
+
bleName: string | null;
|
|
142
|
+
capabilities: Array<number | string>;
|
|
143
|
+
mode: DeviceFeaturesMode;
|
|
144
|
+
initialized: boolean | null;
|
|
145
|
+
bootloaderMode: boolean | null;
|
|
146
|
+
unlocked: boolean | null;
|
|
147
|
+
firmwarePresent: boolean | null;
|
|
148
|
+
passphraseProtection: boolean | null;
|
|
149
|
+
pinProtection: boolean | null;
|
|
150
|
+
backupRequired: boolean | null;
|
|
151
|
+
noBackup: boolean | null;
|
|
152
|
+
unfinishedBackup: boolean | null;
|
|
153
|
+
recoveryMode: boolean | null;
|
|
154
|
+
language: string | null;
|
|
155
|
+
bleEnabled: boolean | null;
|
|
156
|
+
sdCardPresent: boolean | null;
|
|
157
|
+
sdProtection: boolean | null;
|
|
158
|
+
wipeCodeProtection: boolean | null;
|
|
159
|
+
passphraseAlwaysOnDevice: boolean | null;
|
|
160
|
+
safetyChecks: string | null;
|
|
161
|
+
autoLockDelayMs: number | null;
|
|
162
|
+
displayRotation: number | null;
|
|
163
|
+
experimentalFeatures: boolean | null;
|
|
164
|
+
firmwareVersion: string | null;
|
|
165
|
+
bootloaderVersion: string | null;
|
|
166
|
+
boardVersion: string | null;
|
|
167
|
+
bleVersion: string | null;
|
|
168
|
+
se01Version?: string | null;
|
|
169
|
+
se02Version?: string | null;
|
|
170
|
+
se03Version?: string | null;
|
|
171
|
+
se04Version?: string | null;
|
|
172
|
+
se01BootVersion?: string | null;
|
|
173
|
+
se02BootVersion?: string | null;
|
|
174
|
+
se03BootVersion?: string | null;
|
|
175
|
+
se04BootVersion?: string | null;
|
|
176
|
+
seVersion?: string | null;
|
|
177
|
+
verify?: DeviceFeaturesVerify;
|
|
178
|
+
sessionId: string | null;
|
|
179
|
+
passphraseState?: string;
|
|
180
|
+
unlockedAttachPin?: boolean;
|
|
181
|
+
raw?: DeviceFeaturesRaw;
|
|
182
|
+
};
|
|
120
183
|
|
|
121
184
|
export type OnekeyFeatures = PROTO.OnekeyFeatures;
|
|
122
185
|
|
package/src/types/settings.ts
CHANGED
|
@@ -34,6 +34,11 @@ export type ConnectSettings = {
|
|
|
34
34
|
fetchConfig?: boolean;
|
|
35
35
|
extension?: string;
|
|
36
36
|
configFetcher?: (url: string) => Promise<RemoteConfigResponse | null>;
|
|
37
|
+
/**
|
|
38
|
+
* 临时开关:Protocol V2 DevGetDeviceInfo 未稳定前用于 mock 设备信息。
|
|
39
|
+
* 正式 app 可显式设置为 false 以调用真实 DevGetDeviceInfo;固件稳定后删除。
|
|
40
|
+
*/
|
|
41
|
+
protocolV2DeviceInfoMockEnabled?: boolean;
|
|
37
42
|
};
|
|
38
43
|
|
|
39
44
|
export type IVersionArray = [number, number, number];
|
|
@@ -2,8 +2,7 @@ import type { Enum_Capability } from '@onekeyfe/hd-transport';
|
|
|
2
2
|
import type { Features } from '../types/device';
|
|
3
3
|
|
|
4
4
|
export const existCapability = (features?: Features, capability?: Enum_Capability) =>
|
|
5
|
-
|
|
6
|
-
features?.capabilities?.includes(capability);
|
|
5
|
+
capability !== undefined && features?.capabilities?.includes(capability);
|
|
7
6
|
|
|
8
7
|
export const requireCapability = (features: Features, capability: Enum_Capability) => {
|
|
9
8
|
if (!existCapability(features, capability)) {
|
|
@@ -123,15 +123,13 @@ export const getPassphraseStateWithRefreshDeviceInfo = async (
|
|
|
123
123
|
|
|
124
124
|
// Attach to pin try to fix internal state
|
|
125
125
|
const deviceId = device.getCurrentDeviceId();
|
|
126
|
-
|
|
127
|
-
device.
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
);
|
|
134
|
-
}
|
|
126
|
+
device.updateInternalState(
|
|
127
|
+
device.getCurrentPassphraseProtection() ?? false,
|
|
128
|
+
passphraseState,
|
|
129
|
+
deviceId,
|
|
130
|
+
newSession,
|
|
131
|
+
device.features?.sessionId
|
|
132
|
+
);
|
|
135
133
|
|
|
136
134
|
return { passphraseState, newSession, unlockedAttachPin };
|
|
137
135
|
};
|
|
@@ -155,8 +153,8 @@ export const getPassphraseState = async (
|
|
|
155
153
|
}> => {
|
|
156
154
|
const { features, commands } = device;
|
|
157
155
|
|
|
158
|
-
//
|
|
159
|
-
if (!features
|
|
156
|
+
// 设备尚未建立任何状态时无法判定,保持旧的空返回语义
|
|
157
|
+
if (!features)
|
|
160
158
|
return { passphraseState: undefined, newSession: undefined, unlockedAttachPin: undefined };
|
|
161
159
|
|
|
162
160
|
const firmwareVersion = device.getCurrentFirmwareVersionString() ?? '0.0.0';
|
|
@@ -340,12 +338,8 @@ export const fixFeaturesFirmwareVersion = (features: Features): Features => {
|
|
|
340
338
|
// fix Touch、Pro device when bootloader version is lower than 2.5.2, the features returned do not have firmware_version error
|
|
341
339
|
const tempFeatures = { ...features };
|
|
342
340
|
|
|
343
|
-
if (tempFeatures.
|
|
344
|
-
tempFeatures.
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
if (tempFeatures.onekey_version && !semver.valid(tempFeatures.onekey_version)) {
|
|
348
|
-
tempFeatures.onekey_version = fixVersion(tempFeatures.onekey_version);
|
|
341
|
+
if (tempFeatures.firmwareVersion && !semver.valid(tempFeatures.firmwareVersion)) {
|
|
342
|
+
tempFeatures.firmwareVersion = fixVersion(tempFeatures.firmwareVersion);
|
|
349
343
|
}
|
|
350
344
|
|
|
351
345
|
return tempFeatures;
|
|
@@ -14,30 +14,12 @@ export const getDeviceType = (features?: Features): IDeviceType => {
|
|
|
14
14
|
if (!features || typeof features !== 'object') {
|
|
15
15
|
return EDeviceType.Unknown;
|
|
16
16
|
}
|
|
17
|
+
if (features.deviceType) {
|
|
18
|
+
return features.deviceType;
|
|
19
|
+
}
|
|
17
20
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
case 'CLASSIC':
|
|
21
|
-
return EDeviceType.Classic;
|
|
22
|
-
case 'CLASSIC1S':
|
|
23
|
-
return EDeviceType.Classic1s;
|
|
24
|
-
case 'MINI':
|
|
25
|
-
return EDeviceType.Mini;
|
|
26
|
-
case 'TOUCH':
|
|
27
|
-
return EDeviceType.Touch;
|
|
28
|
-
case 'PRO':
|
|
29
|
-
return EDeviceType.Pro;
|
|
30
|
-
case 'PRO2':
|
|
31
|
-
case 'pro2':
|
|
32
|
-
return EDeviceType.Pro2;
|
|
33
|
-
case 'PURE':
|
|
34
|
-
return EDeviceType.ClassicPure;
|
|
35
|
-
default:
|
|
36
|
-
// future And old device onekey_device_type is empty
|
|
37
|
-
if (!isEmpty(features.onekey_serial_no)) {
|
|
38
|
-
return EDeviceType.Unknown;
|
|
39
|
-
}
|
|
40
|
-
// old device type
|
|
21
|
+
if (features.model === EDeviceType.Pro2 || features.model === 'pro2') {
|
|
22
|
+
return EDeviceType.Pro2;
|
|
41
23
|
}
|
|
42
24
|
|
|
43
25
|
// low version hardware
|
|
@@ -45,7 +27,7 @@ export const getDeviceType = (features?: Features): IDeviceType => {
|
|
|
45
27
|
const serialNo = getDeviceUUID(features);
|
|
46
28
|
|
|
47
29
|
// not exist serialNo, bootloader mode, model 1 is classic
|
|
48
|
-
if (isEmpty(serialNo) && features.
|
|
30
|
+
if (isEmpty(serialNo) && features.bootloaderMode === true && features.model === '1') {
|
|
49
31
|
return EDeviceType.Classic;
|
|
50
32
|
}
|
|
51
33
|
|
|
@@ -59,6 +41,7 @@ export const getDeviceType = (features?: Features): IDeviceType => {
|
|
|
59
41
|
if (miniFlag.toLowerCase() === 'mi') return EDeviceType.Mini;
|
|
60
42
|
if (miniFlag.toLowerCase() === 'tc') return EDeviceType.Touch;
|
|
61
43
|
if (miniFlag.toLowerCase() === 'pr') return EDeviceType.Pro;
|
|
44
|
+
if (miniFlag.toLowerCase() === 'p2') return EDeviceType.Pro2;
|
|
62
45
|
|
|
63
46
|
// unknown device
|
|
64
47
|
return EDeviceType.Unknown;
|
|
@@ -89,15 +72,14 @@ export const getDeviceTypeByBleName = (name?: string): IDeviceType => {
|
|
|
89
72
|
*/
|
|
90
73
|
export const getDeviceBleName = (features?: Features): string | null => {
|
|
91
74
|
if (features == null) return null;
|
|
92
|
-
return features.
|
|
75
|
+
return features.bleName || null;
|
|
93
76
|
};
|
|
94
77
|
|
|
95
78
|
/**
|
|
96
79
|
* Get Connected Device UUID by features
|
|
97
80
|
*/
|
|
98
81
|
export const getDeviceUUID = (features: Features) => {
|
|
99
|
-
|
|
100
|
-
return serialNo ?? '';
|
|
82
|
+
return features.serialNo ?? '';
|
|
101
83
|
};
|
|
102
84
|
|
|
103
85
|
/**
|
|
@@ -163,8 +145,8 @@ export const getFirmwareType = (features: Features | undefined) => {
|
|
|
163
145
|
if (!features) {
|
|
164
146
|
return EFirmwareType.Universal;
|
|
165
147
|
}
|
|
166
|
-
if (features.
|
|
167
|
-
return
|
|
148
|
+
if (features.firmwareType) {
|
|
149
|
+
return features.firmwareType;
|
|
168
150
|
}
|
|
169
151
|
// old firmware
|
|
170
152
|
return features?.capabilities?.length > 0 &&
|
|
@@ -8,12 +8,8 @@ import type { Features, IVersionArray } from '../types';
|
|
|
8
8
|
export const getDeviceFirmwareVersion = (features: Features | undefined): IVersionArray => {
|
|
9
9
|
if (!features) return [0, 0, 0];
|
|
10
10
|
|
|
11
|
-
if (semver.valid(features.
|
|
12
|
-
return features.
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
if (semver.valid(features.onekey_version)) {
|
|
16
|
-
return features.onekey_version?.split('.') as unknown as IVersionArray;
|
|
11
|
+
if (features.firmwareVersion && semver.valid(features.firmwareVersion)) {
|
|
12
|
+
return features.firmwareVersion.split('.').map(Number) as IVersionArray;
|
|
17
13
|
}
|
|
18
14
|
|
|
19
15
|
return [0, 0, 0];
|
|
@@ -23,7 +19,7 @@ export const getDeviceFirmwareVersion = (features: Features | undefined): IVersi
|
|
|
23
19
|
* Get Connected Device bluetooth firmware version by features
|
|
24
20
|
*/
|
|
25
21
|
export const getDeviceBLEFirmwareVersion = (features: Features): IVersionArray => {
|
|
26
|
-
const bleVer = features?.
|
|
22
|
+
const bleVer = features?.bleVersion;
|
|
27
23
|
|
|
28
24
|
if (!bleVer) {
|
|
29
25
|
return [0, 0, 0];
|
|
@@ -46,24 +42,10 @@ export const getDeviceBootloaderVersion = (features: Features | undefined): IVer
|
|
|
46
42
|
if (!features) return [0, 0, 0];
|
|
47
43
|
|
|
48
44
|
// classic1s 3.5.0 pro 4.6.0
|
|
49
|
-
if (semver.valid(features.
|
|
50
|
-
return features.
|
|
45
|
+
if (features.bootloaderVersion && semver.valid(features.bootloaderVersion)) {
|
|
46
|
+
return features.bootloaderVersion.split('.').map(Number) as IVersionArray;
|
|
51
47
|
}
|
|
52
48
|
|
|
53
|
-
// low version hardware
|
|
54
|
-
if (!features.bootloader_version) {
|
|
55
|
-
if (features.bootloader_mode) {
|
|
56
|
-
return [
|
|
57
|
-
features?.major_version ?? 0,
|
|
58
|
-
features?.minor_version ?? 0,
|
|
59
|
-
features?.patch_version ?? 0,
|
|
60
|
-
];
|
|
61
|
-
}
|
|
62
|
-
return [0, 0, 0];
|
|
63
|
-
}
|
|
64
|
-
if (semver.valid(features.bootloader_version)) {
|
|
65
|
-
return features.bootloader_version?.split('.') as unknown as IVersionArray;
|
|
66
|
-
}
|
|
67
49
|
return [0, 0, 0];
|
|
68
50
|
};
|
|
69
51
|
|
|
@@ -71,8 +53,8 @@ export const getDeviceBootloaderVersion = (features: Features | undefined): IVer
|
|
|
71
53
|
* Get Connected Device boardloader version by features
|
|
72
54
|
*/
|
|
73
55
|
export const getDeviceBoardloaderVersion = (features: Features): IVersionArray => {
|
|
74
|
-
if (semver.valid(features
|
|
75
|
-
return features
|
|
56
|
+
if (features?.boardVersion && semver.valid(features.boardVersion)) {
|
|
57
|
+
return features.boardVersion.split('.').map(Number) as IVersionArray;
|
|
76
58
|
}
|
|
77
59
|
|
|
78
60
|
return [0, 0, 0];
|
|
@@ -5,7 +5,7 @@ import type { Features } from '../types';
|
|
|
5
5
|
/**
|
|
6
6
|
* 检测故障固件设备
|
|
7
7
|
* 检测规则:
|
|
8
|
-
* - 序列号范围:21032200001 到 21032201500
|
|
8
|
+
* - 序列号范围:21032200001 到 21032201500
|
|
9
9
|
* - SE版本为 1.1.0.2
|
|
10
10
|
*
|
|
11
11
|
* 对齐之前版本的检测逻辑
|
|
@@ -13,13 +13,13 @@ import type { Features } from '../types';
|
|
|
13
13
|
export const findDefectiveBatchDevice = (features: Features) => {
|
|
14
14
|
if (!features) return;
|
|
15
15
|
|
|
16
|
-
const {
|
|
17
|
-
if (!
|
|
16
|
+
const { serialNo, seVersion } = features;
|
|
17
|
+
if (!serialNo) return;
|
|
18
18
|
|
|
19
|
-
const versionNum = +
|
|
19
|
+
const versionNum = +serialNo.slice(5);
|
|
20
20
|
if (Number.isNaN(versionNum)) return;
|
|
21
21
|
|
|
22
|
-
return versionNum >= 21032200001 && versionNum <= 21032201500 &&
|
|
22
|
+
return versionNum >= 21032200001 && versionNum <= 21032201500 && seVersion === '1.1.0.2';
|
|
23
23
|
};
|
|
24
24
|
|
|
25
25
|
/**
|
|
@@ -29,7 +29,7 @@ export const getDefectiveDeviceInfo = (features: Features) => {
|
|
|
29
29
|
if (!findDefectiveBatchDevice(features)) return null;
|
|
30
30
|
const serialNo = getDeviceUUID(features);
|
|
31
31
|
const deviceType = getDeviceType(features);
|
|
32
|
-
const seVersion = features
|
|
32
|
+
const { seVersion } = features;
|
|
33
33
|
|
|
34
34
|
return {
|
|
35
35
|
serialNo,
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { Features } from '../types';
|
|
2
|
-
import type { DeviceProfile } from '../types/api/getDeviceInfo';
|
|
3
|
-
import type { ProtocolV2DeviceInfo } from '@onekeyfe/hd-transport';
|
|
4
|
-
export declare const buildProtocolV2GetFeaturesPayload: (profile: DeviceProfile, deviceInfo?: ProtocolV2DeviceInfo) => Features;
|
|
5
|
-
//# sourceMappingURL=legacyFeaturesView.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"legacyFeaturesView.d.ts","sourceRoot":"","sources":["../../src/deviceProfile/legacyFeaturesView.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAmBnE,eAAO,MAAM,iCAAiC,YACnC,aAAa,eACT,oBAAoB,KAChC,QA8FF,CAAC"}
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import { EDeviceType } from '@onekeyfe/hd-shared';
|
|
2
|
-
|
|
3
|
-
import { getProtocolV2SeState, getProtocolV2SeType } from '../protocols/protocol-v2/features';
|
|
4
|
-
|
|
5
|
-
import type { Features } from '../types';
|
|
6
|
-
import type { DeviceProfile } from '../types/api/getDeviceInfo';
|
|
7
|
-
import type { ProtocolV2DeviceInfo } from '@onekeyfe/hd-transport';
|
|
8
|
-
|
|
9
|
-
const parseProtocolV2Version = (version?: string | null): [number, number, number] => {
|
|
10
|
-
if (!version) return [0, 0, 0];
|
|
11
|
-
const [major = 0, minor = 0, patch = 0] = version.split('.').map(part => Number(part) || 0);
|
|
12
|
-
return [major, minor, patch];
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Protocol V2 的 legacy `Features` 兼容视图。
|
|
17
|
-
*
|
|
18
|
-
* SDK 内部标准模型是 DeviceProfile;该函数只为 getFeatures() 等旧 API
|
|
19
|
-
* 临时合成 Features 形状的数据,不应被内部逻辑消费。
|
|
20
|
-
*
|
|
21
|
-
* 注意:以下字段在 V2 协议中没有等价信息,使用保守占位值——
|
|
22
|
-
* bootloader_mode/firmware_present 恒 false、unlocked 恒 false、
|
|
23
|
-
* capabilities 恒空、pin_protection/safety_checks 等恒 null。
|
|
24
|
-
* 内部判断请使用 device.profile / getCurrent* accessor,而不是这些占位值。
|
|
25
|
-
*/
|
|
26
|
-
export const buildProtocolV2GetFeaturesPayload = (
|
|
27
|
-
profile: DeviceProfile,
|
|
28
|
-
deviceInfo?: ProtocolV2DeviceInfo
|
|
29
|
-
): Features => {
|
|
30
|
-
const firmwareVersion = profile.versions.firmware;
|
|
31
|
-
const [fwMajor, fwMinor, fwPatch] = parseProtocolV2Version(firmwareVersion);
|
|
32
|
-
|
|
33
|
-
return {
|
|
34
|
-
vendor: 'onekey.so',
|
|
35
|
-
major_version: fwMajor,
|
|
36
|
-
minor_version: fwMinor,
|
|
37
|
-
patch_version: fwPatch,
|
|
38
|
-
bootloader_mode: false,
|
|
39
|
-
device_id: profile.deviceId,
|
|
40
|
-
pin_protection: null,
|
|
41
|
-
passphrase_protection: profile.status.passphraseProtection,
|
|
42
|
-
language: profile.status.language,
|
|
43
|
-
label: profile.label,
|
|
44
|
-
initialized: profile.status.initialized ?? false,
|
|
45
|
-
revision: null,
|
|
46
|
-
bootloader_hash: null,
|
|
47
|
-
imported: null,
|
|
48
|
-
unlocked: false,
|
|
49
|
-
firmware_present: false,
|
|
50
|
-
needs_backup: profile.status.backupRequired,
|
|
51
|
-
flags: null,
|
|
52
|
-
model: 'pro2',
|
|
53
|
-
fw_major: fwMajor,
|
|
54
|
-
fw_minor: fwMinor,
|
|
55
|
-
fw_patch: fwPatch,
|
|
56
|
-
fw_vendor: null,
|
|
57
|
-
unfinished_backup: null,
|
|
58
|
-
no_backup: null,
|
|
59
|
-
recovery_mode: null,
|
|
60
|
-
capabilities: [],
|
|
61
|
-
backup_type: null,
|
|
62
|
-
sd_card_present: null,
|
|
63
|
-
sd_protection: null,
|
|
64
|
-
wipe_code_protection: null,
|
|
65
|
-
session_id: null,
|
|
66
|
-
passphrase_always_on_device: null,
|
|
67
|
-
safety_checks: null,
|
|
68
|
-
auto_lock_delay_ms: null,
|
|
69
|
-
display_rotation: null,
|
|
70
|
-
experimental_features: null,
|
|
71
|
-
protocol_version: deviceInfo?.protocol_version ?? null,
|
|
72
|
-
onekey_device_type: EDeviceType.Pro2,
|
|
73
|
-
onekey_serial_no: profile.serialNo,
|
|
74
|
-
serial_no: profile.serialNo,
|
|
75
|
-
ble_enable: profile.status.bleEnabled ?? undefined,
|
|
76
|
-
onekey_ble_name: profile.bleName ?? undefined,
|
|
77
|
-
ble_name: profile.bleName ?? undefined,
|
|
78
|
-
onekey_firmware_version: firmwareVersion ?? undefined,
|
|
79
|
-
onekey_firmware_build_id: profile.verify?.firmwareBuildId,
|
|
80
|
-
onekey_firmware_hash: profile.verify?.firmwareHash,
|
|
81
|
-
onekey_boot_version: profile.versions.bootloader ?? undefined,
|
|
82
|
-
bootloader_version: profile.versions.bootloader ?? undefined,
|
|
83
|
-
onekey_boot_build_id: profile.verify?.bootloaderBuildId,
|
|
84
|
-
onekey_boot_hash: profile.verify?.bootloaderHash,
|
|
85
|
-
onekey_board_version: profile.versions.board ?? undefined,
|
|
86
|
-
onekey_board_build_id: profile.verify?.boardBuildId,
|
|
87
|
-
onekey_board_hash: profile.verify?.boardHash,
|
|
88
|
-
onekey_ble_version: profile.versions.ble ?? undefined,
|
|
89
|
-
ble_ver: profile.versions.ble ?? undefined,
|
|
90
|
-
onekey_ble_build_id: profile.verify?.bleBuildId,
|
|
91
|
-
onekey_ble_hash: profile.verify?.bleHash,
|
|
92
|
-
// Pro2 的 SE 类型在 DevGetDeviceInfo 的 se1.type 上报(如 THD89)
|
|
93
|
-
onekey_se_type: getProtocolV2SeType(deviceInfo?.se1),
|
|
94
|
-
onekey_se01_version: profile.versions.se01 ?? undefined,
|
|
95
|
-
onekey_se01_hash: profile.verify?.se01Hash,
|
|
96
|
-
onekey_se01_build_id: profile.verify?.se01BuildId,
|
|
97
|
-
onekey_se01_boot_version: profile.versions.se01Boot ?? undefined,
|
|
98
|
-
onekey_se01_boot_hash: profile.verify?.se01BootHash,
|
|
99
|
-
onekey_se01_boot_build_id: profile.verify?.se01BootBuildId,
|
|
100
|
-
onekey_se01_state: getProtocolV2SeState(deviceInfo?.se1),
|
|
101
|
-
onekey_se02_version: profile.versions.se02 ?? undefined,
|
|
102
|
-
onekey_se02_hash: profile.verify?.se02Hash,
|
|
103
|
-
onekey_se02_build_id: profile.verify?.se02BuildId,
|
|
104
|
-
onekey_se02_boot_version: profile.versions.se02Boot ?? undefined,
|
|
105
|
-
onekey_se02_boot_hash: profile.verify?.se02BootHash,
|
|
106
|
-
onekey_se02_boot_build_id: profile.verify?.se02BootBuildId,
|
|
107
|
-
onekey_se02_state: getProtocolV2SeState(deviceInfo?.se2),
|
|
108
|
-
onekey_se03_version: profile.versions.se03 ?? undefined,
|
|
109
|
-
onekey_se03_hash: profile.verify?.se03Hash,
|
|
110
|
-
onekey_se03_build_id: profile.verify?.se03BuildId,
|
|
111
|
-
onekey_se03_boot_version: profile.versions.se03Boot ?? undefined,
|
|
112
|
-
onekey_se03_boot_hash: profile.verify?.se03BootHash,
|
|
113
|
-
onekey_se03_boot_build_id: profile.verify?.se03BootBuildId,
|
|
114
|
-
onekey_se03_state: getProtocolV2SeState(deviceInfo?.se3),
|
|
115
|
-
onekey_se04_version: profile.versions.se04 ?? undefined,
|
|
116
|
-
onekey_se04_hash: profile.verify?.se04Hash,
|
|
117
|
-
onekey_se04_build_id: profile.verify?.se04BuildId,
|
|
118
|
-
onekey_se04_boot_version: profile.versions.se04Boot ?? undefined,
|
|
119
|
-
onekey_se04_boot_hash: profile.verify?.se04BootHash,
|
|
120
|
-
onekey_se04_boot_build_id: profile.verify?.se04BootBuildId,
|
|
121
|
-
onekey_se04_state: getProtocolV2SeState(deviceInfo?.se4),
|
|
122
|
-
};
|
|
123
|
-
};
|