@onekeyfe/hd-core 1.2.0-alpha.3 → 1.2.0-alpha.5
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__/preInitialize.test.ts +33 -0
- package/__tests__/protocol-v2.test.ts +1443 -480
- package/dist/api/FileRead.d.ts.map +1 -1
- package/dist/api/FileWrite.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV4.d.ts +22 -2
- package/dist/api/FirmwareUpdateV4.d.ts.map +1 -1
- package/dist/api/firmware/FirmwareUpdateBaseMethod.d.ts +1 -0
- package/dist/api/firmware/FirmwareUpdateBaseMethod.d.ts.map +1 -1
- package/dist/api/firmware/getBinary.d.ts +4 -0
- package/dist/api/firmware/getBinary.d.ts.map +1 -1
- package/dist/api/firmware/progressThrottle.d.ts +3 -0
- package/dist/api/firmware/progressThrottle.d.ts.map +1 -0
- package/dist/api/index.d.ts +5 -10
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/protocol-v2/DeviceFactoryInfoGet.d.ts +6 -0
- package/dist/api/protocol-v2/DeviceFactoryInfoGet.d.ts.map +1 -0
- package/dist/api/protocol-v2/DeviceFactoryInfoSet.d.ts +7 -0
- package/dist/api/protocol-v2/DeviceFactoryInfoSet.d.ts.map +1 -0
- package/dist/api/protocol-v2/DeviceFirmwareUpdate.d.ts +1 -1
- package/dist/api/protocol-v2/DeviceFirmwareUpdate.d.ts.map +1 -1
- package/dist/api/protocol-v2/DeviceGetFirmwareUpdateStatus.d.ts +3 -2
- package/dist/api/protocol-v2/DeviceGetFirmwareUpdateStatus.d.ts.map +1 -1
- package/dist/api/protocol-v2/{DeviceGetDeviceInfo.d.ts → DeviceInfoGet.d.ts} +10 -10
- package/dist/api/protocol-v2/DeviceInfoGet.d.ts.map +1 -0
- package/dist/api/protocol-v2/{FilesystemFixPermission.d.ts → FilesystemPermissionFix.d.ts} +2 -2
- package/dist/api/protocol-v2/FilesystemPermissionFix.d.ts.map +1 -0
- package/dist/api/protocol-v2/ProtocolInfoRequest.d.ts +6 -0
- package/dist/api/protocol-v2/ProtocolInfoRequest.d.ts.map +1 -0
- package/dist/api/protocol-v2/helpers.d.ts +27 -18
- package/dist/api/protocol-v2/helpers.d.ts.map +1 -1
- package/dist/api/ton/TonSignData.d.ts +1 -5
- package/dist/api/ton/TonSignData.d.ts.map +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/data-manager/DataManager.d.ts +1 -1
- package/dist/data-manager/DataManager.d.ts.map +1 -1
- package/dist/data-manager/connectSettings.d.ts.map +1 -1
- package/dist/device/Device.d.ts +4 -1
- package/dist/device/Device.d.ts.map +1 -1
- package/dist/deviceProfile/buildDeviceFeatures.d.ts.map +1 -1
- package/dist/deviceProfile/buildDeviceProfile.d.ts.map +1 -1
- package/dist/index.d.ts +82 -54
- package/dist/index.js +1615 -1537
- package/dist/inject.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/features.d.ts +12 -14
- package/dist/protocols/protocol-v2/features.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/firmware.d.ts +11 -9
- package/dist/protocols/protocol-v2/firmware.d.ts.map +1 -1
- package/dist/types/api/firmwareUpdate.d.ts +1 -6
- package/dist/types/api/firmwareUpdate.d.ts.map +1 -1
- package/dist/types/api/getDeviceInfo.d.ts +2 -0
- package/dist/types/api/getDeviceInfo.d.ts.map +1 -1
- package/dist/types/api/index.d.ts +6 -11
- package/dist/types/api/index.d.ts.map +1 -1
- package/dist/types/api/protocolV2.d.ts +12 -17
- package/dist/types/api/protocolV2.d.ts.map +1 -1
- package/dist/types/device.d.ts +1 -0
- package/dist/types/device.d.ts.map +1 -1
- package/dist/types/params.d.ts +1 -0
- package/dist/types/params.d.ts.map +1 -1
- package/dist/types/settings.d.ts +29 -2
- package/dist/types/settings.d.ts.map +1 -1
- 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/FileRead.ts +14 -1
- package/src/api/FileWrite.ts +14 -1
- package/src/api/FirmwareUpdateV4.ts +975 -201
- package/src/api/GetOnekeyFeatures.ts +1 -1
- package/src/api/device/DeviceRebootToBoardloader.ts +4 -4
- package/src/api/device/DeviceRebootToBootloader.ts +4 -4
- package/src/api/firmware/FirmwareUpdateBaseMethod.ts +18 -4
- package/src/api/firmware/progressThrottle.ts +44 -0
- package/src/api/index.ts +5 -10
- package/src/api/protocol-v2/{FactoryGetDeviceInfo.ts → DeviceFactoryInfoGet.ts} +3 -3
- package/src/api/protocol-v2/DeviceFactoryInfoSet.ts +32 -0
- package/src/api/protocol-v2/DeviceFirmwareUpdate.ts +3 -5
- package/src/api/protocol-v2/DeviceGetFirmwareUpdateStatus.ts +39 -5
- package/src/api/protocol-v2/{DeviceGetDeviceInfo.ts → DeviceInfoGet.ts} +52 -22
- package/src/api/protocol-v2/DeviceReboot.ts +1 -1
- package/src/api/protocol-v2/{FilesystemFixPermission.ts → FilesystemPermissionFix.ts} +2 -2
- package/src/api/protocol-v2/{GetProtoVersion.ts → ProtocolInfoRequest.ts} +2 -2
- package/src/api/protocol-v2/helpers.ts +64 -43
- package/src/api/ton/TonSignData.ts +1 -5
- package/src/core/index.ts +19 -5
- package/src/data/messages/messages-protocol-v2.json +485 -1069
- package/src/data-manager/DataManager.ts +7 -0
- package/src/data-manager/connectSettings.ts +0 -6
- package/src/device/Device.ts +25 -14
- package/src/deviceProfile/buildDeviceFeatures.ts +60 -63
- package/src/deviceProfile/buildDeviceProfile.ts +77 -58
- package/src/inject.ts +10 -16
- package/src/protocols/protocol-v2/features.ts +26 -63
- package/src/protocols/protocol-v2/firmware.ts +12 -36
- package/src/types/api/firmwareUpdate.ts +10 -20
- package/src/types/api/getDeviceInfo.ts +2 -0
- package/src/types/api/index.ts +10 -20
- package/src/types/api/protocolV2.ts +25 -43
- package/src/types/device.ts +1 -0
- package/src/types/params.ts +4 -0
- package/src/types/settings.ts +44 -35
- package/src/utils/deviceFeaturesUtils.ts +45 -10
- package/dist/api/protocol-v2/DevReboot.d.ts +0 -7
- package/dist/api/protocol-v2/DevReboot.d.ts.map +0 -1
- package/dist/api/protocol-v2/DeviceGetDeviceInfo.d.ts.map +0 -1
- package/dist/api/protocol-v2/DeviceGetOnboardingStatus.d.ts +0 -6
- package/dist/api/protocol-v2/DeviceGetOnboardingStatus.d.ts.map +0 -1
- package/dist/api/protocol-v2/FactoryDeviceInfoSettings.d.ts +0 -7
- package/dist/api/protocol-v2/FactoryDeviceInfoSettings.d.ts.map +0 -1
- package/dist/api/protocol-v2/FactoryGetDeviceInfo.d.ts +0 -6
- package/dist/api/protocol-v2/FactoryGetDeviceInfo.d.ts.map +0 -1
- package/dist/api/protocol-v2/FilesystemFixPermission.d.ts.map +0 -1
- package/dist/api/protocol-v2/GetProtoVersion.d.ts +0 -6
- package/dist/api/protocol-v2/GetProtoVersion.d.ts.map +0 -1
- package/src/api/protocol-v2/DevReboot.ts +0 -24
- package/src/api/protocol-v2/DeviceGetOnboardingStatus.ts +0 -16
- package/src/api/protocol-v2/FactoryDeviceInfoSettings.ts +0 -29
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DeviceSEState, DeviceSeType } from '@onekeyfe/hd-transport';
|
|
2
2
|
|
|
3
|
-
import type {
|
|
3
|
+
import type { DeviceInfoGet, DeviceSEInfo, ProtocolV2DeviceInfo } from '@onekeyfe/hd-transport';
|
|
4
4
|
import type { DeviceCommands } from '../../device/DeviceCommands';
|
|
5
5
|
|
|
6
|
-
// 单源类型:直接使用 hd-transport 生成的 ProtocolV2DeviceInfo /
|
|
7
|
-
//
|
|
6
|
+
// 单源类型:直接使用 hd-transport 生成的 ProtocolV2DeviceInfo / DeviceSEInfo /
|
|
7
|
+
// DeviceFirmwareImageInfo(与 firmware-pro2 proto 一致),不再维护手写副本。
|
|
8
8
|
export type { ProtocolV2DeviceInfo };
|
|
9
|
-
export type {
|
|
10
|
-
export type {
|
|
9
|
+
export type { DeviceFirmwareImageInfo as ProtocolV2FirmwareImageInfo } from '@onekeyfe/hd-transport';
|
|
10
|
+
export type { DeviceSEInfo as ProtocolV2SEInfo } from '@onekeyfe/hd-transport';
|
|
11
11
|
|
|
12
12
|
export type ProtocolV2SeStateLabel = 'BOOT' | 'APP_FACTORY' | 'APP';
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
|
-
*
|
|
16
|
-
*
|
|
15
|
+
* 传输层沿用历史 decode 语义:单值 proto enum 输出为名称字符串。
|
|
16
|
+
* 这里按 SDK decode 后的字符串语义处理,同时接受数字枚举,便于低层调用复用。
|
|
17
17
|
*/
|
|
18
18
|
const normalizeEnumValue = <T extends Record<string | number, string | number>>(
|
|
19
19
|
enumObject: T,
|
|
@@ -26,11 +26,11 @@ const normalizeEnumValue = <T extends Record<string | number, string | number>>(
|
|
|
26
26
|
};
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
|
-
*
|
|
29
|
+
* DeviceSEInfo.state → 可读标签。SDK 内唯一的 SE 状态映射实现,
|
|
30
30
|
* DeviceProfile 与标准 Features 构建都从这里取。
|
|
31
31
|
*/
|
|
32
|
-
export const getProtocolV2SeState = (se?:
|
|
33
|
-
const label = normalizeEnumValue(
|
|
32
|
+
export const getProtocolV2SeState = (se?: DeviceSEInfo): ProtocolV2SeStateLabel | null => {
|
|
33
|
+
const label = normalizeEnumValue(DeviceSEState, se?.state);
|
|
34
34
|
switch (label) {
|
|
35
35
|
case 'BOOT':
|
|
36
36
|
return 'BOOT';
|
|
@@ -44,17 +44,20 @@ export const getProtocolV2SeState = (se?: DevSEInfo): ProtocolV2SeStateLabel | n
|
|
|
44
44
|
};
|
|
45
45
|
|
|
46
46
|
/**
|
|
47
|
-
*
|
|
47
|
+
* DeviceSEInfo.type → 可读标签(如 'THD89')。DeviceProfile / Features
|
|
48
48
|
* 的 SE 类型归一化从这里取。
|
|
49
49
|
*/
|
|
50
|
-
export const getProtocolV2SeType = (se?:
|
|
51
|
-
normalizeEnumValue(
|
|
50
|
+
export const getProtocolV2SeType = (se?: DeviceSEInfo): string | null =>
|
|
51
|
+
normalizeEnumValue(DeviceSeType, se?.type);
|
|
52
|
+
|
|
53
|
+
export const isProtocolV2BootloaderDeviceInfo = (deviceInfo?: ProtocolV2DeviceInfo | null) =>
|
|
54
|
+
!!deviceInfo && deviceInfo.status == null;
|
|
52
55
|
|
|
53
56
|
export const PROTOCOL_V2_FEATURES_DEVICE_INFO_REQUEST = {
|
|
54
57
|
targets: {
|
|
55
58
|
hw: true,
|
|
56
59
|
fw: true,
|
|
57
|
-
|
|
60
|
+
coprocessor: true,
|
|
58
61
|
status: true,
|
|
59
62
|
},
|
|
60
63
|
types: {
|
|
@@ -66,13 +69,13 @@ export const PROTOCOL_V2_FEATURES_DEVICE_INFO_REQUEST = {
|
|
|
66
69
|
/**
|
|
67
70
|
* 轻量状态刷新请求(每次 run 前使用)。
|
|
68
71
|
*
|
|
69
|
-
* status 提供 init_states /
|
|
70
|
-
* hw /
|
|
72
|
+
* status 提供 init_states / passphrase_enabled 等会在设备端变化的字段;
|
|
73
|
+
* hw / coprocessor 提供 serialNo / bleName 等身份字段;不含 fw/SE targets,单帧请求开销很小。
|
|
71
74
|
*/
|
|
72
75
|
export const PROTOCOL_V2_STATUS_DEVICE_INFO_REQUEST = {
|
|
73
76
|
targets: {
|
|
74
77
|
hw: true,
|
|
75
|
-
|
|
78
|
+
coprocessor: true,
|
|
76
79
|
status: true,
|
|
77
80
|
},
|
|
78
81
|
types: {
|
|
@@ -85,7 +88,7 @@ export const PROTOCOL_V2_VERSIONS_DEVICE_INFO_REQUEST = {
|
|
|
85
88
|
targets: {
|
|
86
89
|
hw: true,
|
|
87
90
|
fw: true,
|
|
88
|
-
|
|
91
|
+
coprocessor: true,
|
|
89
92
|
se1: true,
|
|
90
93
|
se2: true,
|
|
91
94
|
se3: true,
|
|
@@ -102,7 +105,7 @@ export const PROTOCOL_V2_FULL_DEVICE_INFO_REQUEST = {
|
|
|
102
105
|
targets: {
|
|
103
106
|
hw: true,
|
|
104
107
|
fw: true,
|
|
105
|
-
|
|
108
|
+
coprocessor: true,
|
|
106
109
|
se1: true,
|
|
107
110
|
se2: true,
|
|
108
111
|
se3: true,
|
|
@@ -120,43 +123,6 @@ export const PROTOCOL_V2_FULL_DEVICE_INFO_REQUEST = {
|
|
|
120
123
|
export const PROTOCOL_V2_DEVICE_INFO_REQUEST = PROTOCOL_V2_FULL_DEVICE_INFO_REQUEST;
|
|
121
124
|
export const PROTOCOL_V2_DEVICE_INFO_TIMEOUT_MS = 10 * 1000;
|
|
122
125
|
|
|
123
|
-
/**
|
|
124
|
-
* 临时开关(默认关闭):当前正式链路直接调用 DevGetDeviceInfo。
|
|
125
|
-
* 仅当 Pro2 测试固件 / 早期工程板尚未实现 DevGetDeviceInfo 时,才显式开启 mock。
|
|
126
|
-
* 开启时跳过 wire 调用,直接返回 mock DeviceInfo;
|
|
127
|
-
* DevGetDeviceInfo 尚未返回的字段保持为空,不再用 transport path 兜底成设备身份。
|
|
128
|
-
*
|
|
129
|
-
* 固件实现 DevGetDeviceInfo 稳定后:删除开关与 mock。
|
|
130
|
-
* 注意:开启期间 FirmwareUpdateV4 的“升级完成版本比对”拿到的也是 mock 版本,
|
|
131
|
-
* 不能作为升级成功的依据。
|
|
132
|
-
*/
|
|
133
|
-
let protocolV2DeviceInfoMockEnabled = false;
|
|
134
|
-
|
|
135
|
-
export const setProtocolV2DeviceInfoMock = (enabled: boolean) => {
|
|
136
|
-
protocolV2DeviceInfoMockEnabled = enabled;
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
export const isProtocolV2DeviceInfoMockEnabled = () => protocolV2DeviceInfoMockEnabled;
|
|
140
|
-
|
|
141
|
-
/** 每次调用返回新对象,避免调用方原地修改互相污染。 */
|
|
142
|
-
export const buildMockProtocolV2DeviceInfo = (): ProtocolV2DeviceInfo => ({
|
|
143
|
-
protocol_version: 2,
|
|
144
|
-
hw: {
|
|
145
|
-
// 留空:协议未上报时 SDK 不再用 transport path 伪造身份字段
|
|
146
|
-
serial_no: '',
|
|
147
|
-
},
|
|
148
|
-
fw: {
|
|
149
|
-
app: { version: '0.1.0' },
|
|
150
|
-
},
|
|
151
|
-
bt: {},
|
|
152
|
-
status: {
|
|
153
|
-
init_states: true,
|
|
154
|
-
language: 'en_US',
|
|
155
|
-
passphrase_protection: false,
|
|
156
|
-
bt_enable: true,
|
|
157
|
-
},
|
|
158
|
-
});
|
|
159
|
-
|
|
160
126
|
export async function requestProtocolV2DeviceInfo({
|
|
161
127
|
commands,
|
|
162
128
|
timeoutMs = PROTOCOL_V2_DEVICE_INFO_TIMEOUT_MS,
|
|
@@ -164,15 +130,12 @@ export async function requestProtocolV2DeviceInfo({
|
|
|
164
130
|
}: {
|
|
165
131
|
commands: DeviceCommands;
|
|
166
132
|
timeoutMs?: number;
|
|
167
|
-
request?:
|
|
133
|
+
request?: DeviceInfoGet;
|
|
168
134
|
}): Promise<ProtocolV2DeviceInfo> {
|
|
169
|
-
|
|
170
|
-
return buildMockProtocolV2DeviceInfo();
|
|
171
|
-
}
|
|
172
|
-
const { message } = await commands.typedCall('DevGetDeviceInfo', 'DeviceInfo', request, {
|
|
135
|
+
const { message } = await commands.typedCall('DeviceInfoGet', 'DeviceInfo', request, {
|
|
173
136
|
timeoutMs,
|
|
174
137
|
});
|
|
175
138
|
// 'DeviceInfo' 在生成类型里是 V1 DeviceInfo | ProtocolV2DeviceInfo 的合并;
|
|
176
|
-
//
|
|
139
|
+
// DeviceInfoGet 是 V2-only 消息,这里收窄到 V2 形态。
|
|
177
140
|
return message as ProtocolV2DeviceInfo;
|
|
178
141
|
}
|
|
@@ -1,43 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* 当前 firmware-pro2 子模块的
|
|
3
|
-
*
|
|
4
|
-
* 注意:仓库里的 hd-transport 生成物暂时仍带旧 target 名称;这里显式按
|
|
5
|
-
* submodules/firmware-pro2/sys/protobuf/onekey_protocol/latest/messages_device.proto
|
|
6
|
-
* 对齐当前子模块,避免运行时取到 undefined。
|
|
2
|
+
* 当前 firmware-pro2 子模块的 DeviceFirmwareTargetType。
|
|
7
3
|
*/
|
|
8
4
|
export const ProtocolV2FirmwareTargetType = {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
5
|
+
FW_MGMT_TARGET_INVALID: 0,
|
|
6
|
+
FW_MGMT_TARGET_CRATE: 1,
|
|
7
|
+
FW_MGMT_TARGET_ROMLOADER: 2,
|
|
8
|
+
FW_MGMT_TARGET_BOOTLOADER: 3,
|
|
9
|
+
FW_MGMT_TARGET_APPLICATION_P1: 4,
|
|
10
|
+
FW_MGMT_TARGET_APPLICATION_P2: 5,
|
|
11
|
+
FW_MGMT_TARGET_COPROCESSOR: 6,
|
|
12
|
+
FW_MGMT_TARGET_SE01: 7,
|
|
13
|
+
FW_MGMT_TARGET_SE02: 8,
|
|
14
|
+
FW_MGMT_TARGET_SE03: 9,
|
|
15
|
+
FW_MGMT_TARGET_SE04: 10,
|
|
17
16
|
} as const;
|
|
18
17
|
|
|
19
18
|
export type ProtocolV2FirmwareTargetType =
|
|
20
19
|
(typeof ProtocolV2FirmwareTargetType)[keyof typeof ProtocolV2FirmwareTargetType];
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Map Protocol V2 firmware file name to DevFirmwareUpdate target_id.
|
|
24
|
-
*/
|
|
25
|
-
export function protocolV2FileNameToTargetId(fileName: string): ProtocolV2FirmwareTargetType {
|
|
26
|
-
const normalized = fileName.toLowerCase();
|
|
27
|
-
if (normalized.includes('bootloader') || normalized.includes('update_rom')) {
|
|
28
|
-
return ProtocolV2FirmwareTargetType.TARGET_MAIN_BOOT;
|
|
29
|
-
}
|
|
30
|
-
if (
|
|
31
|
-
normalized.includes('coprocessor') ||
|
|
32
|
-
normalized.includes('ble') ||
|
|
33
|
-
normalized.includes('bluetooth') ||
|
|
34
|
-
normalized.includes('bt')
|
|
35
|
-
) {
|
|
36
|
-
return ProtocolV2FirmwareTargetType.TARGET_BT;
|
|
37
|
-
}
|
|
38
|
-
if (normalized.includes('se4')) return ProtocolV2FirmwareTargetType.TARGET_SE4;
|
|
39
|
-
if (normalized.includes('se3')) return ProtocolV2FirmwareTargetType.TARGET_SE3;
|
|
40
|
-
if (normalized.includes('se2')) return ProtocolV2FirmwareTargetType.TARGET_SE2;
|
|
41
|
-
if (normalized.includes('se')) return ProtocolV2FirmwareTargetType.TARGET_SE1;
|
|
42
|
-
return ProtocolV2FirmwareTargetType.TARGET_MAIN_APP;
|
|
43
|
-
}
|
|
@@ -58,42 +58,32 @@ export interface FirmwareUpdateV3Params {
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
/**
|
|
61
|
-
* firmwareUpdateV4(Protocol V2)按
|
|
62
|
-
*
|
|
61
|
+
* firmwareUpdateV4(Protocol V2)按 DeviceFirmwareTargetType 拆分的目标二进制。
|
|
62
|
+
* 除 romloader 外,每个字段对应一个 bootloader 可接受的固件升级 target。
|
|
63
63
|
*/
|
|
64
64
|
export interface FirmwareUpdateV4Params {
|
|
65
65
|
platform: IPlatform;
|
|
66
66
|
chunkSize?: number;
|
|
67
67
|
firmwareType?: EFirmwareType;
|
|
68
68
|
|
|
69
|
-
/**
|
|
69
|
+
/** FW_MGMT_TARGET_ROMLOADER = 2;当前 Pro2 bootloader 不接受通过 firmwareUpdateV4 安装 */
|
|
70
70
|
romloaderBinary?: ArrayBuffer;
|
|
71
|
-
/**
|
|
71
|
+
/** FW_MGMT_TARGET_BOOTLOADER = 3 */
|
|
72
72
|
bootloaderBinary?: ArrayBuffer;
|
|
73
|
-
/**
|
|
73
|
+
/** FW_MGMT_TARGET_APPLICATION_P1 = 4 */
|
|
74
74
|
applicationP1Binary?: ArrayBuffer;
|
|
75
|
-
/**
|
|
75
|
+
/** FW_MGMT_TARGET_APPLICATION_P2 = 5 */
|
|
76
76
|
applicationP2Binary?: ArrayBuffer;
|
|
77
|
-
/**
|
|
77
|
+
/** FW_MGMT_TARGET_COPROCESSOR = 6 */
|
|
78
78
|
coprocessorBinary?: ArrayBuffer;
|
|
79
|
-
/**
|
|
79
|
+
/** FW_MGMT_TARGET_SE01-04 = 7-10 */
|
|
80
80
|
se01Binary?: ArrayBuffer;
|
|
81
81
|
se02Binary?: ArrayBuffer;
|
|
82
82
|
se03Binary?: ArrayBuffer;
|
|
83
83
|
se04Binary?: ArrayBuffer;
|
|
84
|
-
/**
|
|
85
|
-
|
|
84
|
+
/** 资源包通过 FW_MGMT_TARGET_CRATE = 1 安装;每个元素是一个独立资源包 */
|
|
85
|
+
resourceBinaries?: ArrayBuffer[];
|
|
86
86
|
forcedUpdateRes?: boolean;
|
|
87
|
-
|
|
88
|
-
/** 按 release 配置自动下载 */
|
|
89
|
-
firmwareVersion?: number[];
|
|
90
|
-
bleVersion?: number[];
|
|
91
|
-
bootloaderVersion?: number[];
|
|
92
|
-
|
|
93
|
-
/** legacy 别名:等价 applicationP1Binary */
|
|
94
|
-
firmwareBinary?: ArrayBuffer;
|
|
95
|
-
/** legacy 别名:等价 coprocessorBinary */
|
|
96
|
-
bleBinary?: ArrayBuffer;
|
|
97
87
|
}
|
|
98
88
|
|
|
99
89
|
export declare function firmwareUpdateV3(
|
|
@@ -24,6 +24,8 @@ export type DeviceInfoStatus = {
|
|
|
24
24
|
bootloaderMode: boolean | null;
|
|
25
25
|
unlocked: boolean | null;
|
|
26
26
|
passphraseProtection: boolean | null;
|
|
27
|
+
attachToPinEnabled?: boolean | null;
|
|
28
|
+
unlockedAttachPin?: boolean | null;
|
|
27
29
|
backupRequired: boolean | null;
|
|
28
30
|
noBackup: boolean | null;
|
|
29
31
|
language: string | null;
|
package/src/types/api/index.ts
CHANGED
|
@@ -1,18 +1,13 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
deviceFirmwareUpdate,
|
|
3
|
-
|
|
3
|
+
deviceFactoryInfoGet,
|
|
4
|
+
deviceFactoryInfoSet,
|
|
5
|
+
deviceInfoGet,
|
|
4
6
|
deviceGetFirmwareUpdateStatus,
|
|
5
|
-
deviceGetOnboardingStatus,
|
|
6
7
|
deviceReboot,
|
|
7
|
-
devFirmwareUpdate,
|
|
8
|
-
devGetDeviceInfo,
|
|
9
|
-
devGetFirmwareUpdateStatus,
|
|
10
|
-
devReboot,
|
|
11
8
|
dirList,
|
|
12
9
|
dirMake,
|
|
13
10
|
dirRemove,
|
|
14
|
-
factoryDeviceInfoSettings,
|
|
15
|
-
factoryGetDeviceInfo,
|
|
16
11
|
fileDelete,
|
|
17
12
|
fileRead,
|
|
18
13
|
fileWrite,
|
|
@@ -23,12 +18,12 @@ import type {
|
|
|
23
18
|
filesystemFileDelete,
|
|
24
19
|
filesystemFileRead,
|
|
25
20
|
filesystemFileWrite,
|
|
26
|
-
|
|
21
|
+
filesystemPermissionFix,
|
|
27
22
|
filesystemFormat,
|
|
28
23
|
filesystemPathInfoQuery,
|
|
29
|
-
getProtoVersion,
|
|
30
24
|
pathInfo,
|
|
31
25
|
ping,
|
|
26
|
+
protocolInfoRequest,
|
|
32
27
|
} from './protocolV2';
|
|
33
28
|
import type { off, on, removeAllListeners } from './event';
|
|
34
29
|
import type { uiResponse } from './uiResponse';
|
|
@@ -255,20 +250,15 @@ export type CoreApi = {
|
|
|
255
250
|
/**
|
|
256
251
|
* File system & device control API (Protocol V2 only)
|
|
257
252
|
*/
|
|
258
|
-
|
|
253
|
+
protocolInfoRequest: typeof protocolInfoRequest;
|
|
259
254
|
ping: typeof ping;
|
|
260
255
|
deviceReboot: typeof deviceReboot;
|
|
261
|
-
|
|
262
|
-
deviceGetOnboardingStatus: typeof deviceGetOnboardingStatus;
|
|
256
|
+
deviceInfoGet: typeof deviceInfoGet;
|
|
263
257
|
deviceFirmwareUpdate: typeof deviceFirmwareUpdate;
|
|
264
258
|
deviceGetFirmwareUpdateStatus: typeof deviceGetFirmwareUpdateStatus;
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
devGetFirmwareUpdateStatus: typeof devGetFirmwareUpdateStatus;
|
|
269
|
-
factoryDeviceInfoSettings: typeof factoryDeviceInfoSettings;
|
|
270
|
-
factoryGetDeviceInfo: typeof factoryGetDeviceInfo;
|
|
271
|
-
filesystemFixPermission: typeof filesystemFixPermission;
|
|
259
|
+
deviceFactoryInfoSet: typeof deviceFactoryInfoSet;
|
|
260
|
+
deviceFactoryInfoGet: typeof deviceFactoryInfoGet;
|
|
261
|
+
filesystemPermissionFix: typeof filesystemPermissionFix;
|
|
272
262
|
fileRead: typeof fileRead;
|
|
273
263
|
fileWrite: typeof fileWrite;
|
|
274
264
|
fileDelete: typeof fileDelete;
|
|
@@ -1,32 +1,33 @@
|
|
|
1
1
|
import type { CommonParams, Response } from '../params';
|
|
2
2
|
import type {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
ProtoVersion,
|
|
3
|
+
DeviceFirmwareUpdateStatus,
|
|
4
|
+
DeviceFactoryInfo,
|
|
5
|
+
ProtocolInfo,
|
|
7
6
|
ProtocolV2DeviceInfo,
|
|
8
7
|
Success,
|
|
9
8
|
} from '@onekeyfe/hd-transport';
|
|
10
9
|
import type {
|
|
11
10
|
DeviceFirmwareUpdateParams,
|
|
11
|
+
DeviceFirmwareUpdateStatusGetParams,
|
|
12
12
|
DeviceRebootParams,
|
|
13
|
-
|
|
13
|
+
DeviceFactoryInfoSetParams,
|
|
14
14
|
} from '../../api/protocol-v2/helpers';
|
|
15
|
-
import type {
|
|
15
|
+
import type { DeviceInfoGetParams } from '../../api/protocol-v2/DeviceInfoGet';
|
|
16
16
|
|
|
17
17
|
// 参数类型单源:以 api/protocol-v2 的实现为准(type-only re-export,无运行时依赖)
|
|
18
18
|
export type {
|
|
19
19
|
DeviceFirmwareTargetInput,
|
|
20
20
|
DeviceFirmwareUpdateParams,
|
|
21
|
+
DeviceFirmwareUpdateStatusGetParams,
|
|
21
22
|
DeviceRebootParams,
|
|
22
|
-
|
|
23
|
+
DeviceFactoryInfoSetParams,
|
|
23
24
|
RebootTypeInput,
|
|
24
25
|
} from '../../api/protocol-v2/helpers';
|
|
25
26
|
export type {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
} from '../../api/protocol-v2/
|
|
27
|
+
DeviceInfoGetParams,
|
|
28
|
+
DeviceInfoGetTargets,
|
|
29
|
+
DeviceInfoGetTypes,
|
|
30
|
+
} from '../../api/protocol-v2/DeviceInfoGet';
|
|
30
31
|
|
|
31
32
|
// ── Shared response shapes (Protocol V2 file system) ────────────────────
|
|
32
33
|
|
|
@@ -67,10 +68,10 @@ export type PathInfoResult = {
|
|
|
67
68
|
|
|
68
69
|
// ── Method signatures ─────────────────────────────────────────────────────
|
|
69
70
|
|
|
70
|
-
export declare function
|
|
71
|
+
export declare function protocolInfoRequest(
|
|
71
72
|
connectId: string,
|
|
72
73
|
params?: CommonParams
|
|
73
|
-
): Response<
|
|
74
|
+
): Response<ProtocolInfo>;
|
|
74
75
|
|
|
75
76
|
export declare function ping(
|
|
76
77
|
connectId: string,
|
|
@@ -82,55 +83,36 @@ export declare function deviceReboot(
|
|
|
82
83
|
params: CommonParams & DeviceRebootParams
|
|
83
84
|
): Response<Success>;
|
|
84
85
|
|
|
85
|
-
export declare function
|
|
86
|
+
export declare function deviceInfoGet(
|
|
86
87
|
connectId: string,
|
|
87
|
-
params?: CommonParams &
|
|
88
|
+
params?: CommonParams & DeviceInfoGetParams
|
|
88
89
|
): Response<ProtocolV2DeviceInfo>;
|
|
89
90
|
|
|
90
|
-
export declare function deviceGetOnboardingStatus(
|
|
91
|
-
connectId: string,
|
|
92
|
-
params?: CommonParams
|
|
93
|
-
): Response<OnboardingStatus>;
|
|
94
|
-
|
|
95
91
|
export declare function deviceFirmwareUpdate(
|
|
96
92
|
connectId: string,
|
|
97
93
|
params: CommonParams & DeviceFirmwareUpdateParams
|
|
98
|
-
): Response<Success |
|
|
94
|
+
): Response<Success | DeviceFirmwareUpdateStatus>;
|
|
99
95
|
|
|
100
96
|
export declare function deviceGetFirmwareUpdateStatus(
|
|
101
97
|
connectId: string,
|
|
102
|
-
params?: CommonParams
|
|
103
|
-
): Response<
|
|
98
|
+
params?: CommonParams & DeviceFirmwareUpdateStatusGetParams
|
|
99
|
+
): Response<DeviceFirmwareUpdateStatus>;
|
|
104
100
|
|
|
105
|
-
export declare function
|
|
101
|
+
export declare function deviceFactoryInfoSet(
|
|
106
102
|
connectId: string,
|
|
107
|
-
params: CommonParams &
|
|
103
|
+
params: CommonParams & DeviceFactoryInfoSetParams
|
|
108
104
|
): Response<Success>;
|
|
109
105
|
|
|
110
|
-
export declare function
|
|
111
|
-
connectId: string,
|
|
112
|
-
params?: CommonParams & DeviceGetDeviceInfoParams
|
|
113
|
-
): Response<ProtocolV2DeviceInfo>;
|
|
114
|
-
|
|
115
|
-
export declare function devFirmwareUpdate(
|
|
116
|
-
connectId: string,
|
|
117
|
-
params: CommonParams & DeviceFirmwareUpdateParams
|
|
118
|
-
): Response<Success | DevFirmwareUpdateStatus>;
|
|
119
|
-
|
|
120
|
-
export declare function devGetFirmwareUpdateStatus(
|
|
106
|
+
export declare function deviceFactoryInfoGet(
|
|
121
107
|
connectId: string,
|
|
122
108
|
params?: CommonParams
|
|
123
|
-
): Response<
|
|
109
|
+
): Response<DeviceFactoryInfo>;
|
|
124
110
|
|
|
125
|
-
export declare function
|
|
111
|
+
export declare function filesystemPermissionFix(
|
|
126
112
|
connectId: string,
|
|
127
|
-
params
|
|
113
|
+
params?: CommonParams
|
|
128
114
|
): Response<Success>;
|
|
129
115
|
|
|
130
|
-
export declare function factoryGetDeviceInfo(connectId: string): Response<FactoryDeviceInfo>;
|
|
131
|
-
|
|
132
|
-
export declare function filesystemFixPermission(connectId: string): Response<Success>;
|
|
133
|
-
|
|
134
116
|
export declare function fileRead(
|
|
135
117
|
connectId: string,
|
|
136
118
|
params: {
|
package/src/types/device.ts
CHANGED
|
@@ -157,6 +157,7 @@ export type Features = {
|
|
|
157
157
|
sdProtection: boolean | null;
|
|
158
158
|
wipeCodeProtection: boolean | null;
|
|
159
159
|
passphraseAlwaysOnDevice: boolean | null;
|
|
160
|
+
attachToPinEnabled?: boolean | null;
|
|
160
161
|
safetyChecks: string | null;
|
|
161
162
|
autoLockDelayMs: number | null;
|
|
162
163
|
displayRotation: number | null;
|
package/src/types/params.ts
CHANGED
package/src/types/settings.ts
CHANGED
|
@@ -34,17 +34,49 @@ 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;
|
|
42
37
|
};
|
|
43
38
|
|
|
44
39
|
export type IVersionArray = [number, number, number];
|
|
45
40
|
|
|
46
41
|
export type ILocale = 'zh-CN' | 'en-US';
|
|
47
42
|
|
|
43
|
+
export type IProtocolV2FirmwareComponentTarget =
|
|
44
|
+
| 'ROMLOADER'
|
|
45
|
+
| 'BOOTLOADER'
|
|
46
|
+
| 'APPLICATION_P1'
|
|
47
|
+
| 'APPLICATION_P2'
|
|
48
|
+
| 'COPROCESSOR'
|
|
49
|
+
| 'SE01'
|
|
50
|
+
| 'SE02'
|
|
51
|
+
| 'SE03'
|
|
52
|
+
| 'SE04'
|
|
53
|
+
| 'CRATE';
|
|
54
|
+
|
|
55
|
+
export type IProtocolV2FirmwareComponent = {
|
|
56
|
+
target: IProtocolV2FirmwareComponentTarget;
|
|
57
|
+
url: string;
|
|
58
|
+
fingerprint?: string;
|
|
59
|
+
version?: IVersionArray;
|
|
60
|
+
resourceManifest?: IProtocolV2ResourceManifest;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export type IProtocolV2ResourceManifestPackage = {
|
|
64
|
+
name?: string;
|
|
65
|
+
path: string;
|
|
66
|
+
type?: string;
|
|
67
|
+
version?: IVersionArray;
|
|
68
|
+
sha256?: string;
|
|
69
|
+
payloadHash?: string;
|
|
70
|
+
headerHash?: string;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export type IProtocolV2ResourceManifest = {
|
|
74
|
+
format?: 'okpkg-crate' | string;
|
|
75
|
+
target?: 'CRATE' | string;
|
|
76
|
+
version?: IVersionArray;
|
|
77
|
+
packages: IProtocolV2ResourceManifestPackage[];
|
|
78
|
+
};
|
|
79
|
+
|
|
48
80
|
/** STM32 firmware config */
|
|
49
81
|
export type IFirmwareReleaseInfo = {
|
|
50
82
|
required: boolean;
|
|
@@ -63,6 +95,10 @@ export type IFirmwareReleaseInfo = {
|
|
|
63
95
|
bootloaderVersion?: IVersionArray;
|
|
64
96
|
displayBootloaderVersion?: IVersionArray;
|
|
65
97
|
bootloaderRelatedFirmwareVersion?: IVersionArray;
|
|
98
|
+
upgradeType?: 'payload-package-set' | string;
|
|
99
|
+
components?: Record<string, IProtocolV2FirmwareComponent>;
|
|
100
|
+
installOrder?: string[];
|
|
101
|
+
resourceManifest?: IProtocolV2ResourceManifest;
|
|
66
102
|
bootloaderChangelog?: {
|
|
67
103
|
[k in ILocale]: string;
|
|
68
104
|
};
|
|
@@ -88,43 +124,16 @@ export type IBLEFirmwareReleaseInfo = {
|
|
|
88
124
|
};
|
|
89
125
|
};
|
|
90
126
|
|
|
91
|
-
type IKnownDevice = Exclude<IDeviceType, 'unknown'
|
|
127
|
+
type IKnownDevice = Exclude<IDeviceType, 'unknown'>;
|
|
92
128
|
|
|
93
|
-
/**
|
|
94
|
-
* Device firmware configuration map
|
|
95
|
-
*
|
|
96
|
-
* IMPORTANT: This type is used for firmware update logic.
|
|
97
|
-
* - DO NOT remove existing firmware fields
|
|
98
|
-
* - Only ADD new optional firmware fields for new versions
|
|
99
|
-
* - 'firmware' field is required for backward compatibility
|
|
100
|
-
* - 'ble' field is required for BLE firmware updates
|
|
101
|
-
*
|
|
102
|
-
* @example
|
|
103
|
-
* // When adding firmware-v8:
|
|
104
|
-
* // {
|
|
105
|
-
* // firmware: IFirmwareReleaseInfo[];
|
|
106
|
-
* // 'firmware-v2'?: IFirmwareReleaseInfo[];
|
|
107
|
-
* // 'firmware-v8'?: IFirmwareReleaseInfo[];
|
|
108
|
-
* // 'firmware-v8'?: IFirmwareReleaseInfo[]; // New
|
|
109
|
-
* // 'firmware-btc-v8'?: IFirmwareReleaseInfo[];
|
|
110
|
-
* // 'firmware-btc-v8'?: IFirmwareReleaseInfo[]; // New
|
|
111
|
-
* // ble: IBLEFirmwareReleaseInfo[];
|
|
112
|
-
* // }
|
|
113
|
-
*/
|
|
114
129
|
export type DeviceTypeMap = {
|
|
115
130
|
[k in IKnownDevice]: {
|
|
116
|
-
/** Base firmware field (required for backward compatibility) */
|
|
117
131
|
firmware: IFirmwareReleaseInfo[];
|
|
118
|
-
/**
|
|
132
|
+
/** Pro2 Protocol V2 payload package set */
|
|
133
|
+
'firmware-v1'?: IFirmwareReleaseInfo[];
|
|
119
134
|
'firmware-v2'?: IFirmwareReleaseInfo[];
|
|
120
|
-
/** Universal firmware v7 */
|
|
121
135
|
'firmware-v8'?: IFirmwareReleaseInfo[];
|
|
122
|
-
/** Bitcoin-only firmware v7 */
|
|
123
136
|
'firmware-btc-v8'?: IFirmwareReleaseInfo[];
|
|
124
|
-
// Future firmware versions should be added here as optional fields:
|
|
125
|
-
// 'firmware-v8'?: IFirmwareReleaseInfo[];
|
|
126
|
-
// 'firmware-btc-v8'?: IFirmwareReleaseInfo[];
|
|
127
|
-
/** BLE firmware (required) */
|
|
128
137
|
ble: IBLEFirmwareReleaseInfo[];
|
|
129
138
|
};
|
|
130
139
|
};
|