@onekeyfe/hd-core 1.2.0-alpha.3 → 1.2.0-alpha.4

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.
Files changed (112) hide show
  1. package/__tests__/preInitialize.test.ts +33 -0
  2. package/__tests__/protocol-v2.test.ts +1377 -480
  3. package/dist/api/FileRead.d.ts.map +1 -1
  4. package/dist/api/FileWrite.d.ts.map +1 -1
  5. package/dist/api/FirmwareUpdateV4.d.ts +20 -2
  6. package/dist/api/FirmwareUpdateV4.d.ts.map +1 -1
  7. package/dist/api/firmware/FirmwareUpdateBaseMethod.d.ts.map +1 -1
  8. package/dist/api/firmware/getBinary.d.ts +4 -0
  9. package/dist/api/firmware/getBinary.d.ts.map +1 -1
  10. package/dist/api/index.d.ts +5 -10
  11. package/dist/api/index.d.ts.map +1 -1
  12. package/dist/api/protocol-v2/DeviceFactoryInfoGet.d.ts +6 -0
  13. package/dist/api/protocol-v2/DeviceFactoryInfoGet.d.ts.map +1 -0
  14. package/dist/api/protocol-v2/DeviceFactoryInfoSet.d.ts +7 -0
  15. package/dist/api/protocol-v2/DeviceFactoryInfoSet.d.ts.map +1 -0
  16. package/dist/api/protocol-v2/DeviceFirmwareUpdate.d.ts +1 -1
  17. package/dist/api/protocol-v2/DeviceFirmwareUpdate.d.ts.map +1 -1
  18. package/dist/api/protocol-v2/DeviceGetFirmwareUpdateStatus.d.ts +1 -1
  19. package/dist/api/protocol-v2/{DeviceGetDeviceInfo.d.ts → DeviceInfoGet.d.ts} +10 -10
  20. package/dist/api/protocol-v2/DeviceInfoGet.d.ts.map +1 -0
  21. package/dist/api/protocol-v2/{FilesystemFixPermission.d.ts → FilesystemPermissionFix.d.ts} +2 -2
  22. package/dist/api/protocol-v2/FilesystemPermissionFix.d.ts.map +1 -0
  23. package/dist/api/protocol-v2/ProtocolInfoRequest.d.ts +6 -0
  24. package/dist/api/protocol-v2/ProtocolInfoRequest.d.ts.map +1 -0
  25. package/dist/api/protocol-v2/helpers.d.ts +24 -18
  26. package/dist/api/protocol-v2/helpers.d.ts.map +1 -1
  27. package/dist/api/ton/TonSignData.d.ts +1 -5
  28. package/dist/api/ton/TonSignData.d.ts.map +1 -1
  29. package/dist/core/index.d.ts.map +1 -1
  30. package/dist/data-manager/DataManager.d.ts +1 -1
  31. package/dist/data-manager/DataManager.d.ts.map +1 -1
  32. package/dist/data-manager/connectSettings.d.ts.map +1 -1
  33. package/dist/device/Device.d.ts +4 -1
  34. package/dist/device/Device.d.ts.map +1 -1
  35. package/dist/deviceProfile/buildDeviceFeatures.d.ts.map +1 -1
  36. package/dist/deviceProfile/buildDeviceProfile.d.ts.map +1 -1
  37. package/dist/index.d.ts +79 -54
  38. package/dist/index.js +1537 -1528
  39. package/dist/inject.d.ts.map +1 -1
  40. package/dist/protocols/protocol-v2/features.d.ts +12 -14
  41. package/dist/protocols/protocol-v2/features.d.ts.map +1 -1
  42. package/dist/protocols/protocol-v2/firmware.d.ts +10 -9
  43. package/dist/protocols/protocol-v2/firmware.d.ts.map +1 -1
  44. package/dist/types/api/firmwareUpdate.d.ts +1 -6
  45. package/dist/types/api/firmwareUpdate.d.ts.map +1 -1
  46. package/dist/types/api/getDeviceInfo.d.ts +2 -0
  47. package/dist/types/api/getDeviceInfo.d.ts.map +1 -1
  48. package/dist/types/api/index.d.ts +6 -11
  49. package/dist/types/api/index.d.ts.map +1 -1
  50. package/dist/types/api/protocolV2.d.ts +12 -17
  51. package/dist/types/api/protocolV2.d.ts.map +1 -1
  52. package/dist/types/device.d.ts +1 -0
  53. package/dist/types/device.d.ts.map +1 -1
  54. package/dist/types/params.d.ts +1 -0
  55. package/dist/types/params.d.ts.map +1 -1
  56. package/dist/types/settings.d.ts +29 -2
  57. package/dist/types/settings.d.ts.map +1 -1
  58. package/dist/utils/deviceFeaturesUtils.d.ts.map +1 -1
  59. package/dist/utils/patch.d.ts +1 -1
  60. package/dist/utils/patch.d.ts.map +1 -1
  61. package/package.json +4 -4
  62. package/src/api/FileRead.ts +14 -1
  63. package/src/api/FileWrite.ts +14 -1
  64. package/src/api/FirmwareUpdateV4.ts +933 -197
  65. package/src/api/GetOnekeyFeatures.ts +1 -1
  66. package/src/api/device/DeviceRebootToBoardloader.ts +4 -4
  67. package/src/api/device/DeviceRebootToBootloader.ts +4 -4
  68. package/src/api/firmware/FirmwareUpdateBaseMethod.ts +11 -4
  69. package/src/api/index.ts +5 -10
  70. package/src/api/protocol-v2/{FactoryGetDeviceInfo.ts → DeviceFactoryInfoGet.ts} +3 -3
  71. package/src/api/protocol-v2/DeviceFactoryInfoSet.ts +32 -0
  72. package/src/api/protocol-v2/DeviceFirmwareUpdate.ts +3 -5
  73. package/src/api/protocol-v2/DeviceGetFirmwareUpdateStatus.ts +2 -2
  74. package/src/api/protocol-v2/{DeviceGetDeviceInfo.ts → DeviceInfoGet.ts} +52 -22
  75. package/src/api/protocol-v2/DeviceReboot.ts +1 -1
  76. package/src/api/protocol-v2/{FilesystemFixPermission.ts → FilesystemPermissionFix.ts} +2 -2
  77. package/src/api/protocol-v2/{GetProtoVersion.ts → ProtocolInfoRequest.ts} +2 -2
  78. package/src/api/protocol-v2/helpers.ts +59 -43
  79. package/src/api/ton/TonSignData.ts +1 -5
  80. package/src/core/index.ts +19 -5
  81. package/src/data/messages/messages-protocol-v2.json +486 -1072
  82. package/src/data-manager/DataManager.ts +7 -0
  83. package/src/data-manager/connectSettings.ts +0 -6
  84. package/src/device/Device.ts +25 -14
  85. package/src/deviceProfile/buildDeviceFeatures.ts +60 -63
  86. package/src/deviceProfile/buildDeviceProfile.ts +77 -58
  87. package/src/inject.ts +10 -16
  88. package/src/protocols/protocol-v2/features.ts +26 -63
  89. package/src/protocols/protocol-v2/firmware.ts +11 -36
  90. package/src/types/api/firmwareUpdate.ts +10 -20
  91. package/src/types/api/getDeviceInfo.ts +2 -0
  92. package/src/types/api/index.ts +10 -20
  93. package/src/types/api/protocolV2.ts +22 -42
  94. package/src/types/device.ts +1 -0
  95. package/src/types/params.ts +4 -0
  96. package/src/types/settings.ts +44 -35
  97. package/src/utils/deviceFeaturesUtils.ts +45 -10
  98. package/dist/api/protocol-v2/DevReboot.d.ts +0 -7
  99. package/dist/api/protocol-v2/DevReboot.d.ts.map +0 -1
  100. package/dist/api/protocol-v2/DeviceGetDeviceInfo.d.ts.map +0 -1
  101. package/dist/api/protocol-v2/DeviceGetOnboardingStatus.d.ts +0 -6
  102. package/dist/api/protocol-v2/DeviceGetOnboardingStatus.d.ts.map +0 -1
  103. package/dist/api/protocol-v2/FactoryDeviceInfoSettings.d.ts +0 -7
  104. package/dist/api/protocol-v2/FactoryDeviceInfoSettings.d.ts.map +0 -1
  105. package/dist/api/protocol-v2/FactoryGetDeviceInfo.d.ts +0 -6
  106. package/dist/api/protocol-v2/FactoryGetDeviceInfo.d.ts.map +0 -1
  107. package/dist/api/protocol-v2/FilesystemFixPermission.d.ts.map +0 -1
  108. package/dist/api/protocol-v2/GetProtoVersion.d.ts +0 -6
  109. package/dist/api/protocol-v2/GetProtoVersion.d.ts.map +0 -1
  110. package/src/api/protocol-v2/DevReboot.ts +0 -24
  111. package/src/api/protocol-v2/DeviceGetOnboardingStatus.ts +0 -16
  112. package/src/api/protocol-v2/FactoryDeviceInfoSettings.ts +0 -29
@@ -1,19 +1,19 @@
1
- import { DevSEState, DevSeType } from '@onekeyfe/hd-transport';
1
+ import { DeviceSEState, DeviceSeType } from '@onekeyfe/hd-transport';
2
2
 
3
- import type { DevGetDeviceInfo, DevSEInfo, ProtocolV2DeviceInfo } from '@onekeyfe/hd-transport';
3
+ import type { DeviceInfoGet, DeviceSEInfo, ProtocolV2DeviceInfo } from '@onekeyfe/hd-transport';
4
4
  import type { DeviceCommands } from '../../device/DeviceCommands';
5
5
 
6
- // 单源类型:直接使用 hd-transport 生成的 ProtocolV2DeviceInfo / DevSEInfo /
7
- // DevFirmwareImageInfo(与 firmware-pro2 proto 一致),不再维护手写副本。
6
+ // 单源类型:直接使用 hd-transport 生成的 ProtocolV2DeviceInfo / DeviceSEInfo /
7
+ // DeviceFirmwareImageInfo(与 firmware-pro2 proto 一致),不再维护手写副本。
8
8
  export type { ProtocolV2DeviceInfo };
9
- export type { DevFirmwareImageInfo as ProtocolV2FirmwareImageInfo } from '@onekeyfe/hd-transport';
10
- export type { DevSEInfo as ProtocolV2SEInfo } from '@onekeyfe/hd-transport';
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
- * 传输层解码会把 proto 枚举输出为名称字符串(见 hd-transport messageToJSON),
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
- * DevSEInfo.state → 可读标签。SDK 内唯一的 SE 状态映射实现,
29
+ * DeviceSEInfo.state → 可读标签。SDK 内唯一的 SE 状态映射实现,
30
30
  * DeviceProfile 与标准 Features 构建都从这里取。
31
31
  */
32
- export const getProtocolV2SeState = (se?: DevSEInfo): ProtocolV2SeStateLabel | null => {
33
- const label = normalizeEnumValue(DevSEState, se?.state);
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
- * DevSEInfo.type → 可读标签(如 'THD89')。DeviceProfile / Features
47
+ * DeviceSEInfo.type → 可读标签(如 'THD89')。DeviceProfile / Features
48
48
  * 的 SE 类型归一化从这里取。
49
49
  */
50
- export const getProtocolV2SeType = (se?: DevSEInfo): string | null =>
51
- normalizeEnumValue(DevSeType, se?.type);
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
- bt: true,
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 / label / passphrase_protection 等会在设备端变化的字段;
70
- * hw / bt 提供 serialNo / bleName 等身份字段;不含 fw/SE targets,单帧请求开销很小。
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
- bt: true,
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
- bt: true,
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
- bt: true,
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?: DevGetDeviceInfo;
133
+ request?: DeviceInfoGet;
168
134
  }): Promise<ProtocolV2DeviceInfo> {
169
- if (isProtocolV2DeviceInfoMockEnabled()) {
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
- // DevGetDeviceInfo 是 V2-only 消息,这里收窄到 V2 形态。
139
+ // DeviceInfoGet 是 V2-only 消息,这里收窄到 V2 形态。
177
140
  return message as ProtocolV2DeviceInfo;
178
141
  }
@@ -1,43 +1,18 @@
1
1
  /**
2
- * 当前 firmware-pro2 子模块的 DevFirmwareTargetType
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
- TARGET_MAIN_APP: 0,
10
- TARGET_MAIN_BOOT: 1,
11
- TARGET_BT: 2,
12
- TARGET_SE1: 3,
13
- TARGET_SE2: 4,
14
- TARGET_SE3: 5,
15
- TARGET_SE4: 6,
16
- TARGET_RESOURCE: 10,
5
+ FW_MGMT_TARGET_CRATE: 1,
6
+ FW_MGMT_TARGET_ROMLOADER: 2,
7
+ FW_MGMT_TARGET_BOOTLOADER: 3,
8
+ FW_MGMT_TARGET_APPLICATION_P1: 4,
9
+ FW_MGMT_TARGET_APPLICATION_P2: 5,
10
+ FW_MGMT_TARGET_COPROCESSOR: 6,
11
+ FW_MGMT_TARGET_SE01: 7,
12
+ FW_MGMT_TARGET_SE02: 8,
13
+ FW_MGMT_TARGET_SE03: 9,
14
+ FW_MGMT_TARGET_SE04: 10,
17
15
  } as const;
18
16
 
19
17
  export type ProtocolV2FirmwareTargetType =
20
18
  (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)按 DevFirmwareTargetType 拆分的目标二进制。
62
- * 每个字段对应一个固件升级 target,可单独更新,也可任意组合一次更新。
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
- /** TARGET_MAIN_BOOT = 1 */
69
+ /** FW_MGMT_TARGET_ROMLOADER = 2;当前 Pro2 bootloader 不接受通过 firmwareUpdateV4 安装 */
70
70
  romloaderBinary?: ArrayBuffer;
71
- /** TARGET_MAIN_BOOT = 1 */
71
+ /** FW_MGMT_TARGET_BOOTLOADER = 3 */
72
72
  bootloaderBinary?: ArrayBuffer;
73
- /** TARGET_MAIN_APP = 0 */
73
+ /** FW_MGMT_TARGET_APPLICATION_P1 = 4 */
74
74
  applicationP1Binary?: ArrayBuffer;
75
- /** TARGET_MAIN_APP = 0 */
75
+ /** FW_MGMT_TARGET_APPLICATION_P2 = 5 */
76
76
  applicationP2Binary?: ArrayBuffer;
77
- /** TARGET_BT = 2 */
77
+ /** FW_MGMT_TARGET_COPROCESSOR = 6 */
78
78
  coprocessorBinary?: ArrayBuffer;
79
- /** TARGET_SE1-4 = 3-6 */
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
- /** TARGET_RESOURCE = 10(zip 包,解压后逐文件上传) */
85
- resourceBinary?: ArrayBuffer;
84
+ /** 资源包通过 FW_MGMT_TARGET_CRATE = 1 安装;每个元素是一个独立 CRATE */
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;
@@ -1,18 +1,13 @@
1
1
  import type {
2
2
  deviceFirmwareUpdate,
3
- deviceGetDeviceInfo,
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
- filesystemFixPermission,
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
- getProtoVersion: typeof getProtoVersion;
253
+ protocolInfoRequest: typeof protocolInfoRequest;
259
254
  ping: typeof ping;
260
255
  deviceReboot: typeof deviceReboot;
261
- deviceGetDeviceInfo: typeof deviceGetDeviceInfo;
262
- deviceGetOnboardingStatus: typeof deviceGetOnboardingStatus;
256
+ deviceInfoGet: typeof deviceInfoGet;
263
257
  deviceFirmwareUpdate: typeof deviceFirmwareUpdate;
264
258
  deviceGetFirmwareUpdateStatus: typeof deviceGetFirmwareUpdateStatus;
265
- devReboot: typeof devReboot;
266
- devGetDeviceInfo: typeof devGetDeviceInfo;
267
- devFirmwareUpdate: typeof devFirmwareUpdate;
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,31 @@
1
1
  import type { CommonParams, Response } from '../params';
2
2
  import type {
3
- DevFirmwareUpdateStatus,
4
- FactoryDeviceInfo,
5
- OnboardingStatus,
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,
12
11
  DeviceRebootParams,
13
- FactoryDeviceInfoSettingsParams,
12
+ DeviceFactoryInfoSetParams,
14
13
  } from '../../api/protocol-v2/helpers';
15
- import type { DeviceGetDeviceInfoParams } from '../../api/protocol-v2/DeviceGetDeviceInfo';
14
+ import type { DeviceInfoGetParams } from '../../api/protocol-v2/DeviceInfoGet';
16
15
 
17
16
  // 参数类型单源:以 api/protocol-v2 的实现为准(type-only re-export,无运行时依赖)
18
17
  export type {
19
18
  DeviceFirmwareTargetInput,
20
19
  DeviceFirmwareUpdateParams,
21
20
  DeviceRebootParams,
22
- FactoryDeviceInfoSettingsParams,
21
+ DeviceFactoryInfoSetParams,
23
22
  RebootTypeInput,
24
23
  } from '../../api/protocol-v2/helpers';
25
24
  export type {
26
- DeviceGetDeviceInfoParams,
27
- DeviceGetDeviceInfoTargets,
28
- DeviceGetDeviceInfoTypes,
29
- } from '../../api/protocol-v2/DeviceGetDeviceInfo';
25
+ DeviceInfoGetParams,
26
+ DeviceInfoGetTargets,
27
+ DeviceInfoGetTypes,
28
+ } from '../../api/protocol-v2/DeviceInfoGet';
30
29
 
31
30
  // ── Shared response shapes (Protocol V2 file system) ────────────────────
32
31
 
@@ -67,10 +66,10 @@ export type PathInfoResult = {
67
66
 
68
67
  // ── Method signatures ─────────────────────────────────────────────────────
69
68
 
70
- export declare function getProtoVersion(
69
+ export declare function protocolInfoRequest(
71
70
  connectId: string,
72
71
  params?: CommonParams
73
- ): Response<ProtoVersion>;
72
+ ): Response<ProtocolInfo>;
74
73
 
75
74
  export declare function ping(
76
75
  connectId: string,
@@ -82,55 +81,36 @@ export declare function deviceReboot(
82
81
  params: CommonParams & DeviceRebootParams
83
82
  ): Response<Success>;
84
83
 
85
- export declare function deviceGetDeviceInfo(
84
+ export declare function deviceInfoGet(
86
85
  connectId: string,
87
- params?: CommonParams & DeviceGetDeviceInfoParams
86
+ params?: CommonParams & DeviceInfoGetParams
88
87
  ): Response<ProtocolV2DeviceInfo>;
89
88
 
90
- export declare function deviceGetOnboardingStatus(
91
- connectId: string,
92
- params?: CommonParams
93
- ): Response<OnboardingStatus>;
94
-
95
89
  export declare function deviceFirmwareUpdate(
96
90
  connectId: string,
97
91
  params: CommonParams & DeviceFirmwareUpdateParams
98
- ): Response<Success | DevFirmwareUpdateStatus>;
92
+ ): Response<Success | DeviceFirmwareUpdateStatus>;
99
93
 
100
94
  export declare function deviceGetFirmwareUpdateStatus(
101
95
  connectId: string,
102
96
  params?: CommonParams
103
- ): Response<DevFirmwareUpdateStatus>;
97
+ ): Response<DeviceFirmwareUpdateStatus>;
104
98
 
105
- export declare function devReboot(
99
+ export declare function deviceFactoryInfoSet(
106
100
  connectId: string,
107
- params: CommonParams & DeviceRebootParams
101
+ params: CommonParams & DeviceFactoryInfoSetParams
108
102
  ): Response<Success>;
109
103
 
110
- export declare function devGetDeviceInfo(
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(
104
+ export declare function deviceFactoryInfoGet(
121
105
  connectId: string,
122
106
  params?: CommonParams
123
- ): Response<DevFirmwareUpdateStatus>;
107
+ ): Response<DeviceFactoryInfo>;
124
108
 
125
- export declare function factoryDeviceInfoSettings(
109
+ export declare function filesystemPermissionFix(
126
110
  connectId: string,
127
- params: FactoryDeviceInfoSettingsParams
111
+ params?: CommonParams
128
112
  ): Response<Success>;
129
113
 
130
- export declare function factoryGetDeviceInfo(connectId: string): Response<FactoryDeviceInfo>;
131
-
132
- export declare function filesystemFixPermission(connectId: string): Response<Success>;
133
-
134
114
  export declare function fileRead(
135
115
  connectId: string,
136
116
  params: {
@@ -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;
@@ -14,6 +14,10 @@ export interface CommonParams {
14
14
  * Timeout time for single polling
15
15
  */
16
16
  timeout?: number;
17
+ /**
18
+ * Protocol V2 初始化阶段 DeviceInfoGet 超时时间
19
+ */
20
+ protocolV2DeviceInfoTimeoutMs?: number;
17
21
  /**
18
22
  * passphrase state
19
23
  */
@@ -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' | 'pro2'>;
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
- /** Firmware v2 (Touch/Pro specific) */
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
  };