@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.
Files changed (84) hide show
  1. package/__tests__/protocol-v2.test.ts +147 -264
  2. package/dist/api/FirmwareUpdateV2.d.ts.map +1 -1
  3. package/dist/api/FirmwareUpdateV3.d.ts.map +1 -1
  4. package/dist/api/FirmwareUpdateV4.d.ts +2 -2
  5. package/dist/api/FirmwareUpdateV4.d.ts.map +1 -1
  6. package/dist/api/GetDeviceInfo.d.ts.map +1 -1
  7. package/dist/api/GetFeatures.d.ts +1 -1
  8. package/dist/api/GetOnekeyFeatures.d.ts.map +1 -1
  9. package/dist/api/GetPassphraseState.d.ts +4 -4
  10. package/dist/api/device/DeviceUnlock.d.ts +1 -1
  11. package/dist/api/firmware/bootloaderHelper.d.ts.map +1 -1
  12. package/dist/api/firmware/uploadFirmware.d.ts.map +1 -1
  13. package/dist/api/protocol-v2/helpers.d.ts +2 -3
  14. package/dist/api/protocol-v2/helpers.d.ts.map +1 -1
  15. package/dist/constants/index.d.ts +2 -1
  16. package/dist/constants/index.d.ts.map +1 -1
  17. package/dist/core/index.d.ts.map +1 -1
  18. package/dist/data-manager/connectSettings.d.ts.map +1 -1
  19. package/dist/device/Device.d.ts +11 -15
  20. package/dist/device/Device.d.ts.map +1 -1
  21. package/dist/deviceProfile/buildDeviceFeatures.d.ts +6 -0
  22. package/dist/deviceProfile/buildDeviceFeatures.d.ts.map +1 -0
  23. package/dist/deviceProfile/buildDeviceProfile.d.ts +3 -4
  24. package/dist/deviceProfile/buildDeviceProfile.d.ts.map +1 -1
  25. package/dist/deviceProfile/index.d.ts +1 -1
  26. package/dist/deviceProfile/index.d.ts.map +1 -1
  27. package/dist/index.d.ts +579 -502
  28. package/dist/index.js +881 -931
  29. package/dist/protocols/protocol-v2/features.d.ts +2 -2
  30. package/dist/protocols/protocol-v2/features.d.ts.map +1 -1
  31. package/dist/types/api/getDeviceInfo.d.ts +2 -2
  32. package/dist/types/api/getDeviceInfo.d.ts.map +1 -1
  33. package/dist/types/api/getPassphraseState.d.ts +4 -4
  34. package/dist/types/api/getPassphraseState.d.ts.map +1 -1
  35. package/dist/types/api/protocolV2.d.ts +3 -3
  36. package/dist/types/api/protocolV2.d.ts.map +1 -1
  37. package/dist/types/device.d.ts +87 -8
  38. package/dist/types/device.d.ts.map +1 -1
  39. package/dist/types/settings.d.ts +1 -0
  40. package/dist/types/settings.d.ts.map +1 -1
  41. package/dist/utils/capabilitieUtils.d.ts.map +1 -1
  42. package/dist/utils/deviceFeaturesUtils.d.ts.map +1 -1
  43. package/dist/utils/deviceInfoUtils.d.ts.map +1 -1
  44. package/dist/utils/deviceVersionUtils.d.ts.map +1 -1
  45. package/dist/utils/findDefectiveBatchDevice.d.ts +1 -1
  46. package/dist/utils/patch.d.ts +1 -1
  47. package/dist/utils/patch.d.ts.map +1 -1
  48. package/package.json +4 -4
  49. package/src/api/FirmwareUpdateV2.ts +9 -2
  50. package/src/api/FirmwareUpdateV3.ts +2 -1
  51. package/src/api/FirmwareUpdateV4.ts +24 -31
  52. package/src/api/GetDeviceInfo.ts +6 -13
  53. package/src/api/GetOnekeyFeatures.ts +3 -14
  54. package/src/api/GetPassphraseState.ts +4 -4
  55. package/src/api/firmware/bootloaderHelper.ts +3 -2
  56. package/src/api/firmware/getBinary.ts +1 -1
  57. package/src/api/firmware/releaseHelper.ts +3 -3
  58. package/src/api/firmware/uploadFirmware.ts +5 -2
  59. package/src/api/protocol-v2/DeviceReboot.ts +3 -3
  60. package/src/api/protocol-v2/helpers.ts +1 -26
  61. package/src/constants/index.ts +10 -1
  62. package/src/core/index.ts +5 -7
  63. package/src/data/messages/messages-protocol-v2.json +329 -323
  64. package/src/data-manager/DataManager.ts +4 -4
  65. package/src/data-manager/connectSettings.ts +6 -0
  66. package/src/device/Device.ts +86 -241
  67. package/src/device/DevicePool.ts +9 -9
  68. package/src/deviceProfile/buildDeviceFeatures.ts +368 -0
  69. package/src/deviceProfile/buildDeviceProfile.ts +101 -155
  70. package/src/deviceProfile/index.ts +4 -1
  71. package/src/protocols/protocol-v2/features.ts +14 -16
  72. package/src/types/api/getDeviceInfo.ts +2 -2
  73. package/src/types/api/getPassphraseState.ts +4 -4
  74. package/src/types/api/protocolV2.ts +2 -3
  75. package/src/types/device.ts +97 -34
  76. package/src/types/settings.ts +5 -0
  77. package/src/utils/capabilitieUtils.ts +1 -2
  78. package/src/utils/deviceFeaturesUtils.ts +11 -17
  79. package/src/utils/deviceInfoUtils.ts +11 -29
  80. package/src/utils/deviceVersionUtils.ts +7 -25
  81. package/src/utils/findDefectiveBatchDevice.ts +6 -6
  82. package/dist/deviceProfile/legacyFeaturesView.d.ts +0 -5
  83. package/dist/deviceProfile/legacyFeaturesView.d.ts.map +0 -1
  84. package/src/deviceProfile/legacyFeaturesView.ts +0 -123
@@ -118,14 +118,14 @@ export class DevicePool extends EventEmitter {
118
118
  for await (const descriptor of descriptorList) {
119
119
  const device = await this._createDevice(descriptor, initOptions);
120
120
 
121
- const uuid = device.getCurrentSerialNo();
122
- if (uuid) {
123
- if (this.devicesCache[uuid]) {
124
- const cache = this.devicesCache[uuid];
121
+ const connectId = device.getConnectId();
122
+ if (connectId) {
123
+ if (this.devicesCache[connectId]) {
124
+ const cache = this.devicesCache[connectId];
125
125
  cache.updateDescriptor(descriptor, true);
126
126
  }
127
- this.devicesCache[uuid] = device;
128
- devices[uuid] = device;
127
+ this.devicesCache[connectId] = device;
128
+ devices[connectId] = device;
129
129
  }
130
130
 
131
131
  deviceList.push(device);
@@ -166,7 +166,7 @@ export class DevicePool extends EventEmitter {
166
166
  for (let i = this.connectedPool.length - 1; i >= 0; i--) {
167
167
  const descriptor = this.connectedPool[i];
168
168
  const device = await this._createDevice(descriptor, initOptions);
169
- Log.debug('emit DEVICE.CONNECT: ', device?.profile ?? device?.features);
169
+ Log.debug('emit DEVICE.CONNECT: ', device?.features);
170
170
  this.emitter.emit(DEVICE.CONNECT, device);
171
171
  this.connectedPool.splice(i, 1);
172
172
  }
@@ -203,7 +203,7 @@ export class DevicePool extends EventEmitter {
203
203
  this._addConnectedDeviceToPool(d);
204
204
  return;
205
205
  }
206
- Log.debug('emit DEVICE.CONNECT: ', device.profile ?? device.features);
206
+ Log.debug('emit DEVICE.CONNECT: ', device.features);
207
207
  this.emitter.emit(DEVICE.CONNECT, device);
208
208
  });
209
209
 
@@ -215,7 +215,7 @@ export class DevicePool extends EventEmitter {
215
215
  return;
216
216
  }
217
217
 
218
- Log.debug('emit DEVICE.DISCONNECT: ', device.profile ?? device.features);
218
+ Log.debug('emit DEVICE.DISCONNECT: ', device.features);
219
219
  this.emitter.emit(DEVICE.DISCONNECT, device);
220
220
  });
221
221
  }
@@ -0,0 +1,368 @@
1
+ import { EDeviceType, EFirmwareType } from '@onekeyfe/hd-shared';
2
+
3
+ import type { Features } from '../types';
4
+ import type { PROTO } from '../constants';
5
+ import type { DevFirmwareImageInfo, ProtocolV2DeviceInfo } from '@onekeyfe/hd-transport';
6
+
7
+ type ProtocolV2DeviceInfoCompat = ProtocolV2DeviceInfo & {
8
+ fw?: ProtocolV2DeviceInfo['fw'] & {
9
+ application?: DevFirmwareImageInfo | null;
10
+ application_data?: DevFirmwareImageInfo | null;
11
+ bootloader?: DevFirmwareImageInfo | null;
12
+ romloader?: DevFirmwareImageInfo | null;
13
+ };
14
+ coprocessor?: {
15
+ application?: DevFirmwareImageInfo | null;
16
+ bootloader?: DevFirmwareImageInfo | null;
17
+ bt_adv_name?: string | null;
18
+ bt_mac?: unknown;
19
+ } | null;
20
+ };
21
+
22
+ type ProtocolV1FeaturesCompat = PROTO.Features &
23
+ Partial<PROTO.OnekeyFeatures> & {
24
+ protocol_version?: number | null;
25
+ onekey_version?: string;
26
+ onekey_serial?: string;
27
+ };
28
+
29
+ const getImageVersion = (image?: DevFirmwareImageInfo | null) => image?.version ?? null;
30
+
31
+ const bytesToHex = (value: unknown): string | undefined => {
32
+ if (!value) return undefined;
33
+ if (typeof value === 'string') return value;
34
+ if (value instanceof Uint8Array) {
35
+ return Array.from(value)
36
+ .map(byte => byte.toString(16).padStart(2, '0'))
37
+ .join('');
38
+ }
39
+ if (Array.isArray(value)) {
40
+ return value.map(byte => Number(byte).toString(16).padStart(2, '0')).join('');
41
+ }
42
+ return undefined;
43
+ };
44
+
45
+ const getImageBuildId = (image?: DevFirmwareImageInfo | null) => image?.build_id ?? undefined;
46
+
47
+ const getImageHash = (image?: DevFirmwareImageInfo | null) => bytesToHex(image?.hash);
48
+
49
+ const firstValue = <T>(...values: Array<T | null | undefined>) =>
50
+ values.find(value => value !== undefined && value !== null);
51
+
52
+ const firstMeaningfulVersion = (...versions: Array<string | null | undefined>) =>
53
+ versions.find(version => Boolean(version && version !== '0.0.0')) ?? null;
54
+
55
+ const versionFromParts = (major?: number | null, minor?: number | null, patch?: number | null) =>
56
+ [major, minor, patch].map(part => Number(part) || 0).join('.');
57
+
58
+ const getProtocolV1Mode = (features: ProtocolV1FeaturesCompat): Features['mode'] => {
59
+ if (features.bootloader_mode === true) return 'bootloader';
60
+ if (features.initialized === false) return 'notInitialized';
61
+ if (features.initialized === true) return 'normal';
62
+ return 'unknown';
63
+ };
64
+
65
+ const getProtocolV1DeviceType = (features: ProtocolV1FeaturesCompat): Features['deviceType'] => {
66
+ const onekeyDeviceType = features.onekey_device_type as string | null | undefined;
67
+ switch (onekeyDeviceType) {
68
+ case 'CLASSIC':
69
+ return EDeviceType.Classic;
70
+ case 'CLASSIC1S':
71
+ return EDeviceType.Classic1s;
72
+ case 'MINI':
73
+ return EDeviceType.Mini;
74
+ case 'TOUCH':
75
+ return EDeviceType.Touch;
76
+ case 'PRO':
77
+ return EDeviceType.Pro;
78
+ case 'PRO2':
79
+ case 'pro2':
80
+ return EDeviceType.Pro2;
81
+ case 'PURE':
82
+ return EDeviceType.ClassicPure;
83
+ default:
84
+ break;
85
+ }
86
+
87
+ const serialNo = features.onekey_serial_no || features.onekey_serial || features.serial_no || '';
88
+ const prefix = serialNo.slice(0, 2).toLowerCase();
89
+ if (prefix === 'bi' || prefix === 'cl') return EDeviceType.Classic;
90
+ if (prefix === 'cp') return EDeviceType.ClassicPure;
91
+ if (prefix === 'mi') return EDeviceType.Mini;
92
+ if (prefix === 'tc') return EDeviceType.Touch;
93
+ if (prefix === 'pr') return EDeviceType.Pro;
94
+ if (prefix === 'p2') return EDeviceType.Pro2;
95
+ if (!serialNo && features.bootloader_mode === true && features.model === '1') {
96
+ return EDeviceType.Classic;
97
+ }
98
+ return EDeviceType.Unknown;
99
+ };
100
+
101
+ const getProtocolV1FirmwareType = (
102
+ features: ProtocolV1FeaturesCompat
103
+ ): Features['firmwareType'] => {
104
+ if (features.fw_vendor === 'OneKey Bitcoin-only') return EFirmwareType.BitcoinOnly;
105
+ return EFirmwareType.Universal;
106
+ };
107
+
108
+ const getProtocolV1Label = (
109
+ features: ProtocolV1FeaturesCompat,
110
+ deviceType: Features['deviceType'],
111
+ bleName: string | null
112
+ ) => {
113
+ if (features.label) return features.label;
114
+ if (bleName) return bleName;
115
+ if (deviceType === EDeviceType.Unknown) return null;
116
+ if (deviceType === EDeviceType.ClassicPure) return 'OneKey Classic 1S';
117
+ return `OneKey ${deviceType.charAt(0).toUpperCase()}${deviceType.slice(1)}`;
118
+ };
119
+
120
+ export const buildProtocolV1FeaturesPayload = (
121
+ protocolV1Features: PROTO.Features,
122
+ previous?: Features
123
+ ): Features => {
124
+ const features = protocolV1Features as ProtocolV1FeaturesCompat;
125
+ const firmwareVersion = firstMeaningfulVersion(
126
+ features.onekey_firmware_version,
127
+ features.onekey_version,
128
+ versionFromParts(features.major_version, features.minor_version, features.patch_version)
129
+ );
130
+ const bootloaderVersion = firstMeaningfulVersion(
131
+ features.onekey_boot_version,
132
+ features.bootloader_version,
133
+ features.bootloader_mode
134
+ ? versionFromParts(features.major_version, features.minor_version, features.patch_version)
135
+ : null
136
+ );
137
+ const boardVersion = firstMeaningfulVersion(
138
+ features.onekey_board_version,
139
+ features.boardloader_version
140
+ );
141
+ const bleVersion = firstMeaningfulVersion(features.onekey_ble_version, features.ble_ver);
142
+ const serialNo = features.onekey_serial_no || features.onekey_serial || features.serial_no || '';
143
+ const bleName = features.onekey_ble_name || features.ble_name || null;
144
+ const deviceType = getProtocolV1DeviceType(features);
145
+ const sessionId = features.session_id ?? previous?.sessionId ?? null;
146
+
147
+ return {
148
+ protocol: 'V1',
149
+ protocolVersion: features.protocol_version ?? previous?.protocolVersion ?? 1,
150
+ deviceType,
151
+ firmwareType: getProtocolV1FirmwareType(features),
152
+ model: features.model ?? null,
153
+ vendor: features.vendor ?? null,
154
+ deviceId: features.device_id ?? null,
155
+ serialNo,
156
+ label: getProtocolV1Label(features, deviceType, bleName),
157
+ bleName,
158
+ capabilities: features.capabilities ?? [],
159
+ mode: getProtocolV1Mode(features),
160
+ initialized: features.initialized ?? null,
161
+ bootloaderMode: features.bootloader_mode ?? null,
162
+ unlocked: features.unlocked ?? true,
163
+ firmwarePresent: features.firmware_present ?? null,
164
+ passphraseProtection: features.passphrase_protection ?? null,
165
+ pinProtection: features.pin_protection ?? null,
166
+ backupRequired: features.needs_backup ?? null,
167
+ noBackup: features.no_backup ?? null,
168
+ unfinishedBackup: features.unfinished_backup ?? null,
169
+ recoveryMode: features.recovery_mode ?? null,
170
+ language: features.language ?? null,
171
+ bleEnabled: features.ble_enable ?? null,
172
+ sdCardPresent: features.sd_card_present ?? null,
173
+ sdProtection: features.sd_protection ?? null,
174
+ wipeCodeProtection: features.wipe_code_protection ?? null,
175
+ passphraseAlwaysOnDevice: features.passphrase_always_on_device ?? null,
176
+ safetyChecks: features.safety_checks ?? null,
177
+ autoLockDelayMs: features.auto_lock_delay_ms ?? null,
178
+ displayRotation: features.display_rotation ?? null,
179
+ experimentalFeatures: features.experimental_features ?? null,
180
+ firmwareVersion,
181
+ bootloaderVersion,
182
+ boardVersion,
183
+ bleVersion,
184
+ se01Version: firstMeaningfulVersion(features.onekey_se01_version),
185
+ se02Version: firstMeaningfulVersion(features.onekey_se02_version),
186
+ se03Version: firstMeaningfulVersion(features.onekey_se03_version),
187
+ se04Version: firstMeaningfulVersion(features.onekey_se04_version),
188
+ se01BootVersion: firstMeaningfulVersion(features.onekey_se01_boot_version),
189
+ se02BootVersion: firstMeaningfulVersion(features.onekey_se02_boot_version),
190
+ se03BootVersion: firstMeaningfulVersion(features.onekey_se03_boot_version),
191
+ se04BootVersion: firstMeaningfulVersion(features.onekey_se04_boot_version),
192
+ seVersion: features.se_ver ?? null,
193
+ verify: {
194
+ firmwareBuildId: features.onekey_firmware_build_id,
195
+ firmwareHash: features.onekey_firmware_hash,
196
+ bootloaderBuildId: features.onekey_boot_build_id,
197
+ bootloaderHash: features.onekey_boot_hash,
198
+ boardBuildId: features.onekey_board_build_id,
199
+ boardHash: features.onekey_board_hash,
200
+ bleBuildId: features.onekey_ble_build_id,
201
+ bleHash: features.onekey_ble_hash,
202
+ se01BuildId: features.onekey_se01_build_id,
203
+ se01Hash: features.onekey_se01_hash,
204
+ se02BuildId: features.onekey_se02_build_id,
205
+ se02Hash: features.onekey_se02_hash,
206
+ se03BuildId: features.onekey_se03_build_id,
207
+ se03Hash: features.onekey_se03_hash,
208
+ se04BuildId: features.onekey_se04_build_id,
209
+ se04Hash: features.onekey_se04_hash,
210
+ se01BootBuildId: features.onekey_se01_boot_build_id,
211
+ se01BootHash: features.onekey_se01_boot_hash,
212
+ se02BootBuildId: features.onekey_se02_boot_build_id,
213
+ se02BootHash: features.onekey_se02_boot_hash,
214
+ se03BootBuildId: features.onekey_se03_boot_build_id,
215
+ se03BootHash: features.onekey_se03_boot_hash,
216
+ se04BootBuildId: features.onekey_se04_boot_build_id,
217
+ se04BootHash: features.onekey_se04_boot_hash,
218
+ },
219
+ sessionId,
220
+ raw: {
221
+ protocolV1Features: protocolV1Features,
222
+ },
223
+ };
224
+ };
225
+
226
+ /**
227
+ * Protocol V2 的结构化 `Features` 构建器。
228
+ *
229
+ * 这是 Device 内部唯一缓存状态。字段只来自 DevGetDeviceInfo 或前一次 features
230
+ * 缓存的同名字段级合并;不存在协议等价语义的字段保持 null/空值,不再通过
231
+ * DeviceProfile 或 transport path 做身份兜底。
232
+ */
233
+ export const buildProtocolV2FeaturesPayload = (
234
+ deviceInfo?: ProtocolV2DeviceInfo,
235
+ previous?: Features
236
+ ): Features => {
237
+ const info = deviceInfo as ProtocolV2DeviceInfoCompat | undefined;
238
+ const fwApplication = firstValue(info?.fw?.application, info?.fw?.app);
239
+ const fwBootloader = firstValue(info?.fw?.bootloader, info?.fw?.boot);
240
+ const fwBoard = firstValue(info?.fw?.application_data, info?.fw?.board);
241
+ const bleApplication = firstValue(info?.coprocessor?.application, info?.bt?.app);
242
+
243
+ const firmwareVersion = firstMeaningfulVersion(
244
+ getImageVersion(fwApplication),
245
+ previous?.firmwareVersion
246
+ );
247
+ const bootloaderVersion = firstMeaningfulVersion(
248
+ getImageVersion(fwBootloader),
249
+ previous?.bootloaderVersion
250
+ );
251
+ const boardVersion = firstMeaningfulVersion(getImageVersion(fwBoard), previous?.boardVersion);
252
+ const bleVersion = firstMeaningfulVersion(getImageVersion(bleApplication), previous?.bleVersion);
253
+ const deviceId = firstValue(info?.hw?.device_id, previous?.deviceId) ?? null;
254
+ const serialNo = firstValue(info?.hw?.serial_no, previous?.serialNo) ?? '';
255
+ const label = firstValue(deviceInfo?.status?.label, previous?.label) ?? null;
256
+ const bleName = firstValue(info?.coprocessor?.bt_adv_name, info?.bt?.adv_name, previous?.bleName);
257
+ const initialized = firstValue(deviceInfo?.status?.init_states, previous?.initialized) ?? null;
258
+ const passphraseProtection =
259
+ firstValue(deviceInfo?.status?.passphrase_protection, previous?.passphraseProtection) ?? null;
260
+ const language = firstValue(deviceInfo?.status?.language, previous?.language) ?? null;
261
+ const backupRequired =
262
+ firstValue(deviceInfo?.status?.backup_required, previous?.backupRequired) ?? null;
263
+ const bleEnabled = firstValue(deviceInfo?.status?.bt_enable, previous?.bleEnabled);
264
+
265
+ return {
266
+ protocol: 'V2',
267
+ protocolVersion: deviceInfo?.protocol_version ?? previous?.protocolVersion ?? null,
268
+ deviceType: EDeviceType.Pro2,
269
+ firmwareType: previous?.firmwareType ?? EFirmwareType.Universal,
270
+ model: 'pro2',
271
+ vendor: 'onekey.so',
272
+ deviceId,
273
+ serialNo,
274
+ label,
275
+ bleName: bleName ?? null,
276
+ capabilities: [],
277
+ mode: initialized === false ? 'notInitialized' : initialized === true ? 'normal' : 'unknown',
278
+ initialized,
279
+ bootloaderMode: false,
280
+ unlocked: previous?.unlocked ?? null,
281
+ firmwarePresent: previous?.firmwarePresent ?? null,
282
+ passphraseProtection,
283
+ pinProtection: null,
284
+ backupRequired,
285
+ noBackup: null,
286
+ unfinishedBackup: null,
287
+ recoveryMode: null,
288
+ language,
289
+ bleEnabled: bleEnabled ?? null,
290
+ sdCardPresent: null,
291
+ sdProtection: null,
292
+ wipeCodeProtection: null,
293
+ passphraseAlwaysOnDevice: null,
294
+ safetyChecks: null,
295
+ autoLockDelayMs: null,
296
+ displayRotation: null,
297
+ experimentalFeatures: null,
298
+ firmwareVersion,
299
+ bootloaderVersion,
300
+ boardVersion,
301
+ bleVersion,
302
+ se01Version: firstMeaningfulVersion(
303
+ getImageVersion(deviceInfo?.se1?.app),
304
+ previous?.se01Version
305
+ ),
306
+ se02Version: firstMeaningfulVersion(
307
+ getImageVersion(deviceInfo?.se2?.app),
308
+ previous?.se02Version
309
+ ),
310
+ se03Version: firstMeaningfulVersion(
311
+ getImageVersion(deviceInfo?.se3?.app),
312
+ previous?.se03Version
313
+ ),
314
+ se04Version: firstMeaningfulVersion(
315
+ getImageVersion(deviceInfo?.se4?.app),
316
+ previous?.se04Version
317
+ ),
318
+ se01BootVersion: firstMeaningfulVersion(
319
+ getImageVersion(deviceInfo?.se1?.boot),
320
+ previous?.se01BootVersion
321
+ ),
322
+ se02BootVersion: firstMeaningfulVersion(
323
+ getImageVersion(deviceInfo?.se2?.boot),
324
+ previous?.se02BootVersion
325
+ ),
326
+ se03BootVersion: firstMeaningfulVersion(
327
+ getImageVersion(deviceInfo?.se3?.boot),
328
+ previous?.se03BootVersion
329
+ ),
330
+ se04BootVersion: firstMeaningfulVersion(
331
+ getImageVersion(deviceInfo?.se4?.boot),
332
+ previous?.se04BootVersion
333
+ ),
334
+ seVersion: previous?.seVersion ?? null,
335
+ verify: {
336
+ firmwareBuildId: getImageBuildId(fwApplication) ?? previous?.verify?.firmwareBuildId,
337
+ firmwareHash: getImageHash(fwApplication) ?? previous?.verify?.firmwareHash,
338
+ bootloaderBuildId: getImageBuildId(fwBootloader) ?? previous?.verify?.bootloaderBuildId,
339
+ bootloaderHash: getImageHash(fwBootloader) ?? previous?.verify?.bootloaderHash,
340
+ boardBuildId: getImageBuildId(fwBoard) ?? previous?.verify?.boardBuildId,
341
+ boardHash: getImageHash(fwBoard) ?? previous?.verify?.boardHash,
342
+ bleBuildId: getImageBuildId(bleApplication) ?? previous?.verify?.bleBuildId,
343
+ bleHash: getImageHash(bleApplication) ?? previous?.verify?.bleHash,
344
+ se01BuildId: getImageBuildId(deviceInfo?.se1?.app) ?? previous?.verify?.se01BuildId,
345
+ se01Hash: getImageHash(deviceInfo?.se1?.app) ?? previous?.verify?.se01Hash,
346
+ se02BuildId: getImageBuildId(deviceInfo?.se2?.app) ?? previous?.verify?.se02BuildId,
347
+ se02Hash: getImageHash(deviceInfo?.se2?.app) ?? previous?.verify?.se02Hash,
348
+ se03BuildId: getImageBuildId(deviceInfo?.se3?.app) ?? previous?.verify?.se03BuildId,
349
+ se03Hash: getImageHash(deviceInfo?.se3?.app) ?? previous?.verify?.se03Hash,
350
+ se04BuildId: getImageBuildId(deviceInfo?.se4?.app) ?? previous?.verify?.se04BuildId,
351
+ se04Hash: getImageHash(deviceInfo?.se4?.app) ?? previous?.verify?.se04Hash,
352
+ se01BootBuildId: getImageBuildId(deviceInfo?.se1?.boot) ?? previous?.verify?.se01BootBuildId,
353
+ se01BootHash: getImageHash(deviceInfo?.se1?.boot) ?? previous?.verify?.se01BootHash,
354
+ se02BootBuildId: getImageBuildId(deviceInfo?.se2?.boot) ?? previous?.verify?.se02BootBuildId,
355
+ se02BootHash: getImageHash(deviceInfo?.se2?.boot) ?? previous?.verify?.se02BootHash,
356
+ se03BootBuildId: getImageBuildId(deviceInfo?.se3?.boot) ?? previous?.verify?.se03BootBuildId,
357
+ se03BootHash: getImageHash(deviceInfo?.se3?.boot) ?? previous?.verify?.se03BootHash,
358
+ se04BootBuildId: getImageBuildId(deviceInfo?.se4?.boot) ?? previous?.verify?.se04BootBuildId,
359
+ se04BootHash: getImageHash(deviceInfo?.se4?.boot) ?? previous?.verify?.se04BootHash,
360
+ },
361
+ sessionId: previous?.sessionId ?? null,
362
+ passphraseState: previous?.passphraseState,
363
+ unlockedAttachPin: previous?.unlockedAttachPin,
364
+ raw: {
365
+ protocolV2DeviceInfo: deviceInfo,
366
+ },
367
+ };
368
+ };