@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
package/dist/index.js CHANGED
@@ -1202,35 +1202,20 @@ const DeviceTypeToModels = {
1202
1202
  [hdShared.EDeviceType.Unknown]: [],
1203
1203
  };
1204
1204
 
1205
- const existCapability = (features, capability) => { var _a; return (_a = features === null || features === void 0 ? void 0 : features.capabilities) === null || _a === void 0 ? void 0 : _a.includes(capability); };
1205
+ const existCapability = (features, capability) => { var _a; return capability !== undefined && ((_a = features === null || features === void 0 ? void 0 : features.capabilities) === null || _a === void 0 ? void 0 : _a.includes(capability)); };
1206
1206
 
1207
1207
  const getDeviceType = (features) => {
1208
1208
  if (!features || typeof features !== 'object') {
1209
1209
  return hdShared.EDeviceType.Unknown;
1210
1210
  }
1211
- switch (features.onekey_device_type) {
1212
- case 'CLASSIC':
1213
- return hdShared.EDeviceType.Classic;
1214
- case 'CLASSIC1S':
1215
- return hdShared.EDeviceType.Classic1s;
1216
- case 'MINI':
1217
- return hdShared.EDeviceType.Mini;
1218
- case 'TOUCH':
1219
- return hdShared.EDeviceType.Touch;
1220
- case 'PRO':
1221
- return hdShared.EDeviceType.Pro;
1222
- case 'PRO2':
1223
- case 'pro2':
1224
- return hdShared.EDeviceType.Pro2;
1225
- case 'PURE':
1226
- return hdShared.EDeviceType.ClassicPure;
1227
- default:
1228
- if (!lodash.isEmpty(features.onekey_serial_no)) {
1229
- return hdShared.EDeviceType.Unknown;
1230
- }
1211
+ if (features.deviceType) {
1212
+ return features.deviceType;
1213
+ }
1214
+ if (features.model === hdShared.EDeviceType.Pro2 || features.model === 'pro2') {
1215
+ return hdShared.EDeviceType.Pro2;
1231
1216
  }
1232
1217
  const serialNo = getDeviceUUID(features);
1233
- if (lodash.isEmpty(serialNo) && features.bootloader_mode === true && features.model === '1') {
1218
+ if (lodash.isEmpty(serialNo) && features.bootloaderMode === true && features.model === '1') {
1234
1219
  return hdShared.EDeviceType.Classic;
1235
1220
  }
1236
1221
  if (lodash.isEmpty(serialNo))
@@ -1248,6 +1233,8 @@ const getDeviceType = (features) => {
1248
1233
  return hdShared.EDeviceType.Touch;
1249
1234
  if (miniFlag.toLowerCase() === 'pr')
1250
1235
  return hdShared.EDeviceType.Pro;
1236
+ if (miniFlag.toLowerCase() === 'p2')
1237
+ return hdShared.EDeviceType.Pro2;
1251
1238
  return hdShared.EDeviceType.Unknown;
1252
1239
  };
1253
1240
  const getDeviceTypeByBleName = (name) => {
@@ -1270,11 +1257,11 @@ const getDeviceTypeByBleName = (name) => {
1270
1257
  const getDeviceBleName = (features) => {
1271
1258
  if (features == null)
1272
1259
  return null;
1273
- return features.onekey_ble_name || features.ble_name || null;
1260
+ return features.bleName || null;
1274
1261
  };
1275
1262
  const getDeviceUUID = (features) => {
1276
- const serialNo = features.onekey_serial_no || features.onekey_serial || features.serial_no;
1277
- return serialNo !== null && serialNo !== void 0 ? serialNo : '';
1263
+ var _a;
1264
+ return (_a = features.serialNo) !== null && _a !== void 0 ? _a : '';
1278
1265
  };
1279
1266
  const getDeviceLabel = (features) => {
1280
1267
  if (!features)
@@ -1321,8 +1308,8 @@ const getFirmwareType = (features) => {
1321
1308
  if (!features) {
1322
1309
  return hdShared.EFirmwareType.Universal;
1323
1310
  }
1324
- if (features.fw_vendor === 'OneKey Bitcoin-only') {
1325
- return hdShared.EFirmwareType.BitcoinOnly;
1311
+ if (features.firmwareType) {
1312
+ return features.firmwareType;
1326
1313
  }
1327
1314
  return ((_a = features === null || features === void 0 ? void 0 : features.capabilities) === null || _a === void 0 ? void 0 : _a.length) > 0 &&
1328
1315
  !existCapability(features, hdTransport.Enum_Capability.Capability_Bitcoin_like)
@@ -1331,19 +1318,15 @@ const getFirmwareType = (features) => {
1331
1318
  };
1332
1319
 
1333
1320
  const getDeviceFirmwareVersion = (features) => {
1334
- var _a, _b;
1335
1321
  if (!features)
1336
1322
  return [0, 0, 0];
1337
- if (semver__default["default"].valid(features.onekey_firmware_version)) {
1338
- return (_a = features.onekey_firmware_version) === null || _a === void 0 ? void 0 : _a.split('.');
1339
- }
1340
- if (semver__default["default"].valid(features.onekey_version)) {
1341
- return (_b = features.onekey_version) === null || _b === void 0 ? void 0 : _b.split('.');
1323
+ if (features.firmwareVersion && semver__default["default"].valid(features.firmwareVersion)) {
1324
+ return features.firmwareVersion.split('.').map(Number);
1342
1325
  }
1343
1326
  return [0, 0, 0];
1344
1327
  };
1345
1328
  const getDeviceBLEFirmwareVersion = (features) => {
1346
- const bleVer = (features === null || features === void 0 ? void 0 : features.onekey_ble_version) || (features === null || features === void 0 ? void 0 : features.ble_ver);
1329
+ const bleVer = features === null || features === void 0 ? void 0 : features.bleVersion;
1347
1330
  if (!bleVer) {
1348
1331
  return [0, 0, 0];
1349
1332
  }
@@ -1356,31 +1339,16 @@ const getDeviceBLEFirmwareVersion = (features) => {
1356
1339
  return [0, 0, 0];
1357
1340
  };
1358
1341
  const getDeviceBootloaderVersion = (features) => {
1359
- var _a, _b, _c, _d, _e;
1360
1342
  if (!features)
1361
1343
  return [0, 0, 0];
1362
- if (semver__default["default"].valid(features.onekey_boot_version)) {
1363
- return (_a = features.onekey_boot_version) === null || _a === void 0 ? void 0 : _a.split('.');
1364
- }
1365
- if (!features.bootloader_version) {
1366
- if (features.bootloader_mode) {
1367
- return [
1368
- (_b = features === null || features === void 0 ? void 0 : features.major_version) !== null && _b !== void 0 ? _b : 0,
1369
- (_c = features === null || features === void 0 ? void 0 : features.minor_version) !== null && _c !== void 0 ? _c : 0,
1370
- (_d = features === null || features === void 0 ? void 0 : features.patch_version) !== null && _d !== void 0 ? _d : 0,
1371
- ];
1372
- }
1373
- return [0, 0, 0];
1374
- }
1375
- if (semver__default["default"].valid(features.bootloader_version)) {
1376
- return (_e = features.bootloader_version) === null || _e === void 0 ? void 0 : _e.split('.');
1344
+ if (features.bootloaderVersion && semver__default["default"].valid(features.bootloaderVersion)) {
1345
+ return features.bootloaderVersion.split('.').map(Number);
1377
1346
  }
1378
1347
  return [0, 0, 0];
1379
1348
  };
1380
1349
  const getDeviceBoardloaderVersion = (features) => {
1381
- var _a;
1382
- if (semver__default["default"].valid(features === null || features === void 0 ? void 0 : features.onekey_board_version)) {
1383
- return (_a = features === null || features === void 0 ? void 0 : features.onekey_board_version) === null || _a === void 0 ? void 0 : _a.split('.');
1350
+ if ((features === null || features === void 0 ? void 0 : features.boardVersion) && semver__default["default"].valid(features.boardVersion)) {
1351
+ return features.boardVersion.split('.').map(Number);
1384
1352
  }
1385
1353
  return [0, 0, 0];
1386
1354
  };
@@ -25774,11 +25742,6 @@ var nested = {
25774
25742
  MessageType_NeoAddress: 12302,
25775
25743
  MessageType_NeoSignTx: 12303,
25776
25744
  MessageType_NeoSignedTx: 12304,
25777
- MessageType_UiviewShowAddressRequest: 30200,
25778
- MessageType_UiviewShowPublicKeyRequest: 30201,
25779
- MessageType_UiviewConfirmTxRequest: 30202,
25780
- MessageType_UiviewConfirmSignMessageRequest: 30203,
25781
- MessageType_UiviewResponse: 30204,
25782
25745
  MessageType_ReadSEPublicKey: 10004,
25783
25746
  MessageType_SEPublicKey: 10005,
25784
25747
  MessageType_WriteSEPublicCert: 10006,
@@ -25789,6 +25752,9 @@ var nested = {
25789
25752
  MessageType_ResourceUpload: 10018,
25790
25753
  MessageType_ZoomRequest: 10019,
25791
25754
  MessageType_BlurRequest: 10032,
25755
+ MessageType_SetWallpaper: 10033,
25756
+ MessageType_GetWallpaper: 10034,
25757
+ MessageType_Wallpaper: 10035,
25792
25758
  MessageType_ResourceRequest: 10020,
25793
25759
  MessageType_ResourceAck: 10021,
25794
25760
  MessageType_ResourceUpdate: 10022,
@@ -25830,13 +25796,7 @@ var nested = {
25830
25796
  MessageType_DevFirmwareUpdate: 61000,
25831
25797
  MessageType_DevFirmwareInstallProgress: 61001,
25832
25798
  MessageType_DevGetFirmwareUpdateStatus: 61002,
25833
- MessageType_DevFirmwareUpdateStatus: 61003,
25834
- MessageType_DeviceReboot: 60400,
25835
- MessageType_DeviceGetDeviceInfo: 60600,
25836
- MessageType_DeviceFirmwareUpdate: 61000,
25837
- MessageType_DeviceFirmwareInstallProgress: 61001,
25838
- MessageType_DeviceGetFirmwareUpdateStatus: 61002,
25839
- MessageType_DeviceFirmwareUpdateStatus: 61003
25799
+ MessageType_DevFirmwareUpdateStatus: 61003
25840
25800
  }
25841
25801
  },
25842
25802
  AlephiumGetAddress: {
@@ -29431,6 +29391,208 @@ var nested = {
29431
29391
  }
29432
29392
  }
29433
29393
  },
29394
+ DebugLinkInput: {
29395
+ fields: {
29396
+ x: {
29397
+ type: "uint32",
29398
+ id: 1
29399
+ },
29400
+ y: {
29401
+ type: "uint32",
29402
+ id: 2
29403
+ },
29404
+ duration_ms: {
29405
+ type: "uint32",
29406
+ id: 3
29407
+ },
29408
+ x_end: {
29409
+ type: "uint32",
29410
+ id: 4
29411
+ },
29412
+ y_end: {
29413
+ type: "uint32",
29414
+ id: 5
29415
+ }
29416
+ }
29417
+ },
29418
+ DebugLinkLayout: {
29419
+ fields: {
29420
+ lines: {
29421
+ rule: "repeated",
29422
+ type: "string",
29423
+ id: 1
29424
+ }
29425
+ }
29426
+ },
29427
+ DebugLinkReseedRandom: {
29428
+ fields: {
29429
+ value: {
29430
+ type: "uint32",
29431
+ id: 1
29432
+ }
29433
+ }
29434
+ },
29435
+ DebugLinkRecordScreen: {
29436
+ fields: {
29437
+ target_directory: {
29438
+ type: "string",
29439
+ id: 1
29440
+ }
29441
+ }
29442
+ },
29443
+ DebugLinkGetState: {
29444
+ fields: {
29445
+ wait_word_list: {
29446
+ type: "bool",
29447
+ id: 1
29448
+ },
29449
+ wait_word_pos: {
29450
+ type: "bool",
29451
+ id: 2
29452
+ },
29453
+ wait_layout: {
29454
+ type: "bool",
29455
+ id: 3
29456
+ }
29457
+ }
29458
+ },
29459
+ DebugLinkState: {
29460
+ fields: {
29461
+ layout: {
29462
+ type: "bytes",
29463
+ id: 1
29464
+ },
29465
+ pin: {
29466
+ type: "string",
29467
+ id: 2
29468
+ },
29469
+ matrix: {
29470
+ type: "string",
29471
+ id: 3
29472
+ },
29473
+ mnemonic_secret: {
29474
+ type: "bytes",
29475
+ id: 4
29476
+ },
29477
+ node: {
29478
+ type: "HDNodeType",
29479
+ id: 5
29480
+ },
29481
+ passphrase_protection: {
29482
+ type: "bool",
29483
+ id: 6
29484
+ },
29485
+ reset_word: {
29486
+ type: "string",
29487
+ id: 7
29488
+ },
29489
+ reset_entropy: {
29490
+ type: "bytes",
29491
+ id: 8
29492
+ },
29493
+ recovery_fake_word: {
29494
+ type: "string",
29495
+ id: 9
29496
+ },
29497
+ recovery_word_pos: {
29498
+ type: "uint32",
29499
+ id: 10
29500
+ },
29501
+ reset_word_pos: {
29502
+ type: "uint32",
29503
+ id: 11
29504
+ },
29505
+ mnemonic_type: {
29506
+ type: "BackupType",
29507
+ id: 12
29508
+ },
29509
+ layout_lines: {
29510
+ rule: "repeated",
29511
+ type: "string",
29512
+ id: 13
29513
+ }
29514
+ }
29515
+ },
29516
+ DebugLinkStop: {
29517
+ fields: {
29518
+ }
29519
+ },
29520
+ DebugLinkLog: {
29521
+ fields: {
29522
+ level: {
29523
+ type: "uint32",
29524
+ id: 1
29525
+ },
29526
+ bucket: {
29527
+ type: "string",
29528
+ id: 2
29529
+ },
29530
+ text: {
29531
+ type: "string",
29532
+ id: 3
29533
+ }
29534
+ }
29535
+ },
29536
+ DebugLinkMemoryRead: {
29537
+ fields: {
29538
+ address: {
29539
+ type: "uint32",
29540
+ id: 1
29541
+ },
29542
+ length: {
29543
+ type: "uint32",
29544
+ id: 2
29545
+ }
29546
+ }
29547
+ },
29548
+ DebugLinkMemory: {
29549
+ fields: {
29550
+ memory: {
29551
+ type: "bytes",
29552
+ id: 1
29553
+ }
29554
+ }
29555
+ },
29556
+ DebugLinkMemoryWrite: {
29557
+ fields: {
29558
+ address: {
29559
+ type: "uint32",
29560
+ id: 1
29561
+ },
29562
+ memory: {
29563
+ type: "bytes",
29564
+ id: 2
29565
+ },
29566
+ flash: {
29567
+ type: "bool",
29568
+ id: 3
29569
+ }
29570
+ }
29571
+ },
29572
+ DebugLinkFlashErase: {
29573
+ fields: {
29574
+ sector: {
29575
+ type: "uint32",
29576
+ id: 1
29577
+ }
29578
+ }
29579
+ },
29580
+ DebugLinkEraseSdCard: {
29581
+ fields: {
29582
+ format: {
29583
+ type: "bool",
29584
+ id: 1
29585
+ }
29586
+ }
29587
+ },
29588
+ DebugLinkWatchLayout: {
29589
+ fields: {
29590
+ watch: {
29591
+ type: "bool",
29592
+ id: 1
29593
+ }
29594
+ }
29595
+ },
29434
29596
  EosGetPublicKey: {
29435
29597
  fields: {
29436
29598
  address_n: {
@@ -31264,6 +31426,30 @@ var nested = {
31264
31426
  }
31265
31427
  }
31266
31428
  },
31429
+ InternalMyAddressRequest: {
31430
+ fields: {
31431
+ coin_type: {
31432
+ rule: "required",
31433
+ type: "uint32",
31434
+ id: 1
31435
+ },
31436
+ chain_id: {
31437
+ rule: "required",
31438
+ type: "uint32",
31439
+ id: 2
31440
+ },
31441
+ account_index: {
31442
+ rule: "required",
31443
+ type: "uint32",
31444
+ id: 3
31445
+ },
31446
+ derive_type: {
31447
+ rule: "required",
31448
+ type: "uint32",
31449
+ id: 4
31450
+ }
31451
+ }
31452
+ },
31267
31453
  KaspaGetAddress: {
31268
31454
  fields: {
31269
31455
  address_n: {
@@ -32608,6 +32794,49 @@ var nested = {
32608
32794
  }
32609
32795
  }
32610
32796
  },
32797
+ WallpaperTarget: {
32798
+ values: {
32799
+ Home: 0,
32800
+ Lock: 1
32801
+ }
32802
+ },
32803
+ SetWallpaper: {
32804
+ fields: {
32805
+ target: {
32806
+ rule: "required",
32807
+ type: "WallpaperTarget",
32808
+ id: 1
32809
+ },
32810
+ path: {
32811
+ rule: "required",
32812
+ type: "string",
32813
+ id: 2
32814
+ }
32815
+ }
32816
+ },
32817
+ GetWallpaper: {
32818
+ fields: {
32819
+ target: {
32820
+ rule: "required",
32821
+ type: "WallpaperTarget",
32822
+ id: 1
32823
+ }
32824
+ }
32825
+ },
32826
+ Wallpaper: {
32827
+ fields: {
32828
+ target: {
32829
+ rule: "required",
32830
+ type: "WallpaperTarget",
32831
+ id: 1
32832
+ },
32833
+ path: {
32834
+ rule: "required",
32835
+ type: "string",
32836
+ id: 2
32837
+ }
32838
+ }
32839
+ },
32611
32840
  ResourceUpdate: {
32612
32841
  fields: {
32613
32842
  file_name: {
@@ -34791,142 +35020,6 @@ var nested = {
34791
35020
  }
34792
35021
  }
34793
35022
  },
34794
- ScdoGetAddress: {
34795
- fields: {
34796
- address_n: {
34797
- rule: "repeated",
34798
- type: "uint32",
34799
- id: 1,
34800
- options: {
34801
- packed: false
34802
- }
34803
- },
34804
- show_display: {
34805
- type: "bool",
34806
- id: 2
34807
- }
34808
- }
34809
- },
34810
- ScdoAddress: {
34811
- fields: {
34812
- address: {
34813
- rule: "required",
34814
- type: "string",
34815
- id: 1
34816
- }
34817
- }
34818
- },
34819
- ScdoSignTx: {
34820
- fields: {
34821
- address_n: {
34822
- rule: "repeated",
34823
- type: "uint32",
34824
- id: 1,
34825
- options: {
34826
- packed: false
34827
- }
34828
- },
34829
- nonce: {
34830
- rule: "required",
34831
- type: "bytes",
34832
- id: 2
34833
- },
34834
- gas_price: {
34835
- rule: "required",
34836
- type: "bytes",
34837
- id: 3
34838
- },
34839
- gas_limit: {
34840
- rule: "required",
34841
- type: "bytes",
34842
- id: 4
34843
- },
34844
- to: {
34845
- rule: "required",
34846
- type: "string",
34847
- id: 5
34848
- },
34849
- value: {
34850
- rule: "required",
34851
- type: "bytes",
34852
- id: 6
34853
- },
34854
- timestamp: {
34855
- rule: "required",
34856
- type: "bytes",
34857
- id: 7
34858
- },
34859
- data_initial_chunk: {
34860
- type: "bytes",
34861
- id: 8,
34862
- options: {
34863
- "default": ""
34864
- }
34865
- },
34866
- data_length: {
34867
- type: "uint32",
34868
- id: 9,
34869
- options: {
34870
- "default": 0
34871
- }
34872
- },
34873
- tx_type: {
34874
- type: "uint32",
34875
- id: 10,
34876
- options: {
34877
- "default": 0
34878
- }
34879
- }
34880
- }
34881
- },
34882
- ScdoSignedTx: {
34883
- fields: {
34884
- data_length: {
34885
- type: "uint32",
34886
- id: 1
34887
- },
34888
- signature: {
34889
- type: "bytes",
34890
- id: 2
34891
- }
34892
- }
34893
- },
34894
- ScdoTxAck: {
34895
- fields: {
34896
- data_chunk: {
34897
- type: "bytes",
34898
- id: 1
34899
- }
34900
- }
34901
- },
34902
- ScdoSignMessage: {
34903
- fields: {
34904
- address_n: {
34905
- rule: "repeated",
34906
- type: "uint32",
34907
- id: 1,
34908
- options: {
34909
- packed: false
34910
- }
34911
- },
34912
- message: {
34913
- type: "bytes",
34914
- id: 2
34915
- }
34916
- }
34917
- },
34918
- ScdoSignedMessage: {
34919
- fields: {
34920
- signature: {
34921
- type: "bytes",
34922
- id: 1
34923
- },
34924
- address: {
34925
- type: "string",
34926
- id: 2
34927
- }
34928
- }
34929
- },
34930
35023
  SolanaOffChainMessageVersion: {
34931
35024
  values: {
34932
35025
  MESSAGE_VERSION_0: 0
@@ -36895,114 +36988,105 @@ var nested = {
36895
36988
  }
36896
36989
  }
36897
36990
  },
36898
- TxDetailsAmount: {
36991
+ ViewAmount: {
36899
36992
  fields: {
36900
- num: {
36993
+ is_unlimited: {
36901
36994
  rule: "required",
36902
- type: "string",
36995
+ type: "bool",
36903
36996
  id: 1
36904
36997
  },
36905
- decimals: {
36906
- rule: "required",
36907
- type: "uint32",
36908
- id: 2
36909
- },
36910
- symbol: {
36998
+ num: {
36911
36999
  rule: "required",
36912
37000
  type: "string",
36913
- id: 3
37001
+ id: 2
36914
37002
  }
36915
37003
  }
36916
37004
  },
36917
- TxDetailsAddress: {
37005
+ ViewDetail: {
36918
37006
  fields: {
36919
37007
  key: {
36920
37008
  rule: "required",
36921
37009
  type: "uint32",
36922
37010
  id: 1
36923
37011
  },
36924
- address: {
37012
+ value: {
36925
37013
  rule: "required",
36926
37014
  type: "string",
36927
37015
  id: 2
36928
37016
  },
36929
- owner: {
36930
- type: "string",
37017
+ is_overview: {
37018
+ rule: "required",
37019
+ type: "bool",
36931
37020
  id: 3
36932
37021
  },
36933
- icon: {
36934
- type: "string",
37022
+ has_icon: {
37023
+ rule: "required",
37024
+ type: "bool",
36935
37025
  id: 4
36936
37026
  }
36937
37027
  }
36938
37028
  },
36939
- TxDetailsNetwork: {
37029
+ ViewTipType: {
37030
+ values: {
37031
+ Default: 0,
37032
+ Highlight: 1,
37033
+ Recommend: 2,
37034
+ Warning: 3,
37035
+ Danger: 4
37036
+ }
37037
+ },
37038
+ ViewTip: {
36940
37039
  fields: {
36941
- coin_type: {
37040
+ type: {
36942
37041
  rule: "required",
36943
- type: "uint64",
37042
+ type: "ViewTipType",
36944
37043
  id: 1
36945
37044
  },
36946
- chain_id: {
36947
- type: "uint64",
37045
+ text: {
37046
+ rule: "required",
37047
+ type: "string",
36948
37048
  id: 2
36949
37049
  }
36950
37050
  }
36951
37051
  },
36952
- TxDetailsGeneral: {
37052
+ ViewSignPage: {
36953
37053
  fields: {
36954
- key: {
37054
+ title: {
36955
37055
  rule: "required",
36956
- type: "uint32",
37056
+ type: "string",
36957
37057
  id: 1
36958
37058
  },
36959
- value: {
36960
- rule: "required",
36961
- type: "string",
37059
+ amount: {
37060
+ type: "ViewAmount",
36962
37061
  id: 2
36963
37062
  },
36964
- is_overview: {
36965
- rule: "required",
36966
- type: "bool",
37063
+ general: {
37064
+ rule: "repeated",
37065
+ type: "ViewDetail",
36967
37066
  id: 3
37067
+ },
37068
+ tip: {
37069
+ type: "ViewTip",
37070
+ id: 4
36968
37071
  }
36969
37072
  }
36970
37073
  },
36971
- TxDetailsDisplayType: {
36972
- values: {
36973
- DISPLAY_TYPE_INFO: 0,
36974
- DISPLAY_TYPE_SIGN: 1
36975
- }
36976
- },
36977
- TxDetailsPage: {
37074
+ ViewVerifyPage: {
36978
37075
  fields: {
36979
37076
  title: {
36980
37077
  rule: "required",
36981
37078
  type: "string",
36982
37079
  id: 1
36983
37080
  },
36984
- display_type: {
37081
+ address: {
36985
37082
  rule: "required",
36986
- type: "TxDetailsDisplayType",
37083
+ type: "string",
36987
37084
  id: 2
36988
37085
  },
36989
- amount: {
36990
- type: "TxDetailsAmount",
37086
+ path: {
37087
+ rule: "required",
37088
+ type: "string",
36991
37089
  id: 3
36992
- },
36993
- network: {
36994
- type: "TxDetailsNetwork",
36995
- id: 4
36996
- },
36997
- address: {
36998
- rule: "repeated",
36999
- type: "TxDetailsAddress",
37000
- id: 5
37001
- },
37002
- general: {
37003
- rule: "repeated",
37004
- type: "TxDetailsGeneral",
37005
- id: 6
37006
37090
  }
37007
37091
  }
37008
37092
  },
@@ -37318,6 +37402,10 @@ var nested = {
37318
37402
  type: "string",
37319
37403
  id: 11
37320
37404
  },
37405
+ device_id: {
37406
+ type: "string",
37407
+ id: 12
37408
+ },
37321
37409
  hardware_version: {
37322
37410
  type: "string",
37323
37411
  id: 100
@@ -37523,16 +37611,13 @@ var nested = {
37523
37611
  },
37524
37612
  DevFirmwareTargetType: {
37525
37613
  values: {
37526
- TARGET_INVALID: 0,
37527
- TARGET_ROMLOADER: 1,
37528
- TARGET_BOOTLOADER: 2,
37529
- TARGET_APPLICATION_P1: 3,
37530
- TARGET_APPLICATION_P2: 4,
37531
- TARGET_COPROCESSOR: 5,
37532
- TARGET_SE01: 6,
37533
- TARGET_SE02: 7,
37534
- TARGET_SE03: 8,
37535
- TARGET_SE04: 9,
37614
+ TARGET_MAIN_APP: 0,
37615
+ TARGET_MAIN_BOOT: 1,
37616
+ TARGET_BT: 2,
37617
+ TARGET_SE1: 3,
37618
+ TARGET_SE2: 4,
37619
+ TARGET_SE3: 5,
37620
+ TARGET_SE4: 6,
37536
37621
  TARGET_RESOURCE: 10
37537
37622
  }
37538
37623
  },
@@ -38673,117 +38758,6 @@ var nested = {
38673
38758
  }
38674
38759
  }
38675
38760
  }
38676
- },
38677
- DeviceRebootType: {
38678
- values: {
38679
- Normal: 0,
38680
- Romloader: 1,
38681
- Bootloader: 2
38682
- }
38683
- },
38684
- DeviceReboot: {
38685
- fields: {
38686
- reboot_type: {
38687
- rule: "required",
38688
- type: "DeviceRebootType",
38689
- id: 1
38690
- }
38691
- }
38692
- },
38693
- DeviceGetDeviceInfo: {
38694
- fields: {
38695
- targets: {
38696
- type: "DevInfoTargets",
38697
- id: 1
38698
- },
38699
- types: {
38700
- type: "DevInfoTypes",
38701
- id: 2
38702
- }
38703
- }
38704
- },
38705
- DeviceFirmwareTargetType: {
38706
- values: {
38707
- TARGET_INVALID: 0,
38708
- TARGET_ROMLOADER: 1,
38709
- TARGET_BOOTLOADER: 2,
38710
- TARGET_APPLICATION_P1: 3,
38711
- TARGET_APPLICATION_P2: 4,
38712
- TARGET_COPROCESSOR: 5,
38713
- TARGET_SE01: 6,
38714
- TARGET_SE02: 7,
38715
- TARGET_SE03: 8,
38716
- TARGET_SE04: 9,
38717
- TARGET_RESOURCE: 10
38718
- }
38719
- },
38720
- DeviceFirmwareTarget: {
38721
- fields: {
38722
- target_id: {
38723
- rule: "required",
38724
- type: "DeviceFirmwareTargetType",
38725
- id: 1
38726
- },
38727
- path: {
38728
- rule: "required",
38729
- type: "string",
38730
- id: 2
38731
- }
38732
- }
38733
- },
38734
- DeviceFirmwareUpdate: {
38735
- fields: {
38736
- targets: {
38737
- rule: "repeated",
38738
- type: "DeviceFirmwareTarget",
38739
- id: 1
38740
- }
38741
- }
38742
- },
38743
- DeviceFirmwareInstallProgress: {
38744
- fields: {
38745
- target_id: {
38746
- rule: "required",
38747
- type: "DeviceFirmwareTargetType",
38748
- id: 1
38749
- },
38750
- progress: {
38751
- rule: "required",
38752
- type: "uint32",
38753
- id: 2
38754
- },
38755
- stage: {
38756
- type: "string",
38757
- id: 3
38758
- }
38759
- }
38760
- },
38761
- DeviceFirmwareUpdateStatusEntry: {
38762
- fields: {
38763
- target_id: {
38764
- rule: "required",
38765
- type: "DeviceFirmwareTargetType",
38766
- id: 1
38767
- },
38768
- status: {
38769
- rule: "required",
38770
- type: "uint32",
38771
- id: 2
38772
- }
38773
- }
38774
- },
38775
- DeviceGetFirmwareUpdateStatus: {
38776
- fields: {
38777
- }
38778
- },
38779
- DeviceFirmwareUpdateStatus: {
38780
- fields: {
38781
- targets: {
38782
- rule: "repeated",
38783
- type: "DeviceFirmwareUpdateStatusEntry",
38784
- id: 1
38785
- }
38786
- }
38787
38761
  }
38788
38762
  };
38789
38763
  var MessagesProtocolV2JSON = {
@@ -38994,10 +38968,10 @@ DataManager.getFirmwareStatus = (features, firmwareType) => {
38994
38968
  return 'unknown';
38995
38969
  const deviceFirmwareType = getFirmwareType(features);
38996
38970
  const deviceFirmwareVersion = getDeviceFirmwareVersion(features);
38997
- if (features.firmware_present === false) {
38971
+ if (features.firmwarePresent === false) {
38998
38972
  return 'none';
38999
38973
  }
39000
- if (DeviceModelToTypes.model_mini.includes(deviceType) && features.bootloader_mode) {
38974
+ if (DeviceModelToTypes.model_mini.includes(deviceType) && features.bootloaderMode) {
39001
38975
  return 'unknown';
39002
38976
  }
39003
38977
  const firmwareUpdateField = getFirmwareUpdateField({
@@ -39107,8 +39081,8 @@ DataManager.getFirmwareChangelog = (features, firmwareType) => {
39107
39081
  firmwareType,
39108
39082
  });
39109
39083
  const targetDeviceConfigList = (_c = (_b = _a$1.deviceMap[deviceType]) === null || _b === void 0 ? void 0 : _b[firmwareUpdateField]) !== null && _c !== void 0 ? _c : [];
39110
- if (features.firmware_present === false ||
39111
- (DeviceModelToTypes.model_classic.includes(deviceType) && features.bootloader_mode)) {
39084
+ if (features.firmwarePresent === false ||
39085
+ (DeviceModelToTypes.model_classic.includes(deviceType) && features.bootloaderMode)) {
39112
39086
  return getReleaseChangelog(targetDeviceConfigList, '0.0.0');
39113
39087
  }
39114
39088
  const currentVersion = deviceFirmwareVersion.join('.');
@@ -39247,16 +39221,14 @@ const getPassphraseStateWithRefreshDeviceInfo = (device, options) => __awaiter(v
39247
39221
  yield device.getFeatures();
39248
39222
  }
39249
39223
  const deviceId = device.getCurrentDeviceId();
39250
- if (deviceId) {
39251
- device.updateInternalState((_a = device.getCurrentPassphraseProtection()) !== null && _a !== void 0 ? _a : false, passphraseState, deviceId, newSession, (_b = device.features) === null || _b === void 0 ? void 0 : _b.session_id);
39252
- }
39224
+ device.updateInternalState((_a = device.getCurrentPassphraseProtection()) !== null && _a !== void 0 ? _a : false, passphraseState, deviceId, newSession, (_b = device.features) === null || _b === void 0 ? void 0 : _b.sessionId);
39253
39225
  return { passphraseState, newSession, unlockedAttachPin };
39254
39226
  });
39255
39227
  const supportProSeriesAttachPinPassphrase = (deviceType, firmwareVersion) => deviceType === hdShared.EDeviceType.Pro && semver__default["default"].gte(firmwareVersion, '4.15.0');
39256
39228
  const getPassphraseState = (device, options) => __awaiter(void 0, void 0, void 0, function* () {
39257
39229
  var _c;
39258
39230
  const { features, commands } = device;
39259
- if (!features && !device.profile)
39231
+ if (!features)
39260
39232
  return { passphraseState: undefined, newSession: undefined, unlockedAttachPin: undefined };
39261
39233
  const firmwareVersion = (_c = device.getCurrentFirmwareVersionString()) !== null && _c !== void 0 ? _c : '0.0.0';
39262
39234
  const deviceType = device.getCurrentDeviceType();
@@ -39377,11 +39349,8 @@ function fixVersion(version) {
39377
39349
  }
39378
39350
  const fixFeaturesFirmwareVersion = (features) => {
39379
39351
  const tempFeatures = Object.assign({}, features);
39380
- if (tempFeatures.onekey_firmware_version && !semver__default["default"].valid(tempFeatures.onekey_firmware_version)) {
39381
- tempFeatures.onekey_firmware_version = fixVersion(tempFeatures.onekey_firmware_version);
39382
- }
39383
- if (tempFeatures.onekey_version && !semver__default["default"].valid(tempFeatures.onekey_version)) {
39384
- tempFeatures.onekey_version = fixVersion(tempFeatures.onekey_version);
39352
+ if (tempFeatures.firmwareVersion && !semver__default["default"].valid(tempFeatures.firmwareVersion)) {
39353
+ tempFeatures.firmwareVersion = fixVersion(tempFeatures.firmwareVersion);
39385
39354
  }
39386
39355
  return tempFeatures;
39387
39356
  };
@@ -39419,6 +39388,7 @@ const initialSettings = {
39419
39388
  env: 'web',
39420
39389
  lazyLoad: false,
39421
39390
  timestamp: new Date().getTime(),
39391
+ protocolV2DeviceInfoMockEnabled: false,
39422
39392
  };
39423
39393
  const getEnv = () => {
39424
39394
  if (typeof chrome !== 'undefined' &&
@@ -39492,6 +39462,9 @@ const parseConnectSettings = (input = {}) => {
39492
39462
  if (input.fetchConfig) {
39493
39463
  settings.fetchConfig = input.fetchConfig;
39494
39464
  }
39465
+ if (typeof input.protocolV2DeviceInfoMockEnabled === 'boolean') {
39466
+ settings.protocolV2DeviceInfoMockEnabled = input.protocolV2DeviceInfoMockEnabled;
39467
+ }
39495
39468
  return settings;
39496
39469
  };
39497
39470
 
@@ -39510,9 +39483,10 @@ function shouldUpdateBootloaderForClassicAndMini({ currentVersion, bootloaderVer
39510
39483
  function isEnteredManuallyBoot(features, updateType) {
39511
39484
  const deviceType = getDeviceType(features);
39512
39485
  const isMini = deviceType === hdShared.EDeviceType.Mini;
39486
+ const bootloaderVersion = getDeviceBootloaderVersion(features).join('.');
39513
39487
  const isBoot183ClassicUpBle = updateType === 'firmware' &&
39514
39488
  deviceType === hdShared.EDeviceType.Classic &&
39515
- features.bootloader_version === '1.8.3';
39489
+ bootloaderVersion === '1.8.3';
39516
39490
  return isMini || isBoot183ClassicUpBle;
39517
39491
  }
39518
39492
 
@@ -39971,20 +39945,20 @@ const wait = (ms) => new Promise(resolve => {
39971
39945
  const findDefectiveBatchDevice = (features) => {
39972
39946
  if (!features)
39973
39947
  return;
39974
- const { onekey_serial: onekeySerial, se_ver: seVer } = features;
39975
- if (!onekeySerial)
39948
+ const { serialNo, seVersion } = features;
39949
+ if (!serialNo)
39976
39950
  return;
39977
- const versionNum = +onekeySerial.slice(5);
39951
+ const versionNum = +serialNo.slice(5);
39978
39952
  if (Number.isNaN(versionNum))
39979
39953
  return;
39980
- return versionNum >= 21032200001 && versionNum <= 21032201500 && seVer === '1.1.0.2';
39954
+ return versionNum >= 21032200001 && versionNum <= 21032201500 && seVersion === '1.1.0.2';
39981
39955
  };
39982
39956
  const getDefectiveDeviceInfo = (features) => {
39983
39957
  if (!findDefectiveBatchDevice(features))
39984
39958
  return null;
39985
39959
  const serialNo = getDeviceUUID(features);
39986
39960
  const deviceType = getDeviceType(features);
39987
- const seVersion = features.se_ver;
39961
+ const { seVersion } = features;
39988
39962
  return {
39989
39963
  serialNo,
39990
39964
  seVersion,
@@ -40248,14 +40222,14 @@ class DevicePool extends events.exports {
40248
40222
  _a = false;
40249
40223
  const descriptor = _d;
40250
40224
  const device = yield this._createDevice(descriptor, initOptions);
40251
- const uuid = device.getCurrentSerialNo();
40252
- if (uuid) {
40253
- if (this.devicesCache[uuid]) {
40254
- const cache = this.devicesCache[uuid];
40225
+ const connectId = device.getConnectId();
40226
+ if (connectId) {
40227
+ if (this.devicesCache[connectId]) {
40228
+ const cache = this.devicesCache[connectId];
40255
40229
  cache.updateDescriptor(descriptor, true);
40256
40230
  }
40257
- this.devicesCache[uuid] = device;
40258
- devices[uuid] = device;
40231
+ this.devicesCache[connectId] = device;
40232
+ devices[connectId] = device;
40259
40233
  }
40260
40234
  deviceList.push(device);
40261
40235
  }
@@ -40296,12 +40270,11 @@ class DevicePool extends events.exports {
40296
40270
  });
40297
40271
  }
40298
40272
  static _sendConnectMessage(initOptions) {
40299
- var _a;
40300
40273
  return __awaiter(this, void 0, void 0, function* () {
40301
40274
  for (let i = this.connectedPool.length - 1; i >= 0; i--) {
40302
40275
  const descriptor = this.connectedPool[i];
40303
40276
  const device = yield this._createDevice(descriptor, initOptions);
40304
- Log$f.debug('emit DEVICE.CONNECT: ', (_a = device === null || device === void 0 ? void 0 : device.profile) !== null && _a !== void 0 ? _a : device === null || device === void 0 ? void 0 : device.features);
40277
+ Log$f.debug('emit DEVICE.CONNECT: ', device === null || device === void 0 ? void 0 : device.features);
40305
40278
  this.emitter.emit(DEVICE.CONNECT, device);
40306
40279
  this.connectedPool.splice(i, 1);
40307
40280
  }
@@ -40328,24 +40301,22 @@ class DevicePool extends events.exports {
40328
40301
  return;
40329
40302
  }
40330
40303
  diff.connected.forEach(d => {
40331
- var _a;
40332
40304
  const device = this.getDeviceByPath(d.path);
40333
40305
  if (!device) {
40334
40306
  this._addConnectedDeviceToPool(d);
40335
40307
  return;
40336
40308
  }
40337
- Log$f.debug('emit DEVICE.CONNECT: ', (_a = device.profile) !== null && _a !== void 0 ? _a : device.features);
40309
+ Log$f.debug('emit DEVICE.CONNECT: ', device.features);
40338
40310
  this.emitter.emit(DEVICE.CONNECT, device);
40339
40311
  });
40340
40312
  diff.disconnected.forEach(d => {
40341
- var _a;
40342
40313
  this._removeDeviceFromConnectedPool(d.path);
40343
40314
  const device = this.getDeviceByPath(d.path);
40344
40315
  if (!device) {
40345
40316
  this._addDisconnectedDeviceToPool(d);
40346
40317
  return;
40347
40318
  }
40348
- Log$f.debug('emit DEVICE.DISCONNECT: ', (_a = device.profile) !== null && _a !== void 0 ? _a : device.features);
40319
+ Log$f.debug('emit DEVICE.DISCONNECT: ', device.features);
40349
40320
  this.emitter.emit(DEVICE.DISCONNECT, device);
40350
40321
  });
40351
40322
  }
@@ -41079,28 +41050,6 @@ class DeviceCommands {
41079
41050
  }
41080
41051
  }
41081
41052
 
41082
- const normalizeEnumValue = (enumObject, value) => {
41083
- if (value == null)
41084
- return null;
41085
- if (typeof value === 'string')
41086
- return value;
41087
- const label = enumObject[value];
41088
- return typeof label === 'string' ? label : null;
41089
- };
41090
- const getProtocolV2SeState = (se) => {
41091
- const label = normalizeEnumValue(hdTransport.DevSEState, se === null || se === void 0 ? void 0 : se.state);
41092
- switch (label) {
41093
- case 'BOOT':
41094
- return 'BOOT';
41095
- case 'APP_FACTORY':
41096
- return 'APP_FACTORY';
41097
- case 'APP':
41098
- return 'APP';
41099
- default:
41100
- return null;
41101
- }
41102
- };
41103
- const getProtocolV2SeType = (se) => normalizeEnumValue(hdTransport.DevSeType, se === null || se === void 0 ? void 0 : se.type);
41104
41053
  const PROTOCOL_V2_FEATURES_DEVICE_INFO_REQUEST = {
41105
41054
  targets: {
41106
41055
  hw: true,
@@ -41160,6 +41109,11 @@ const PROTOCOL_V2_FULL_DEVICE_INFO_REQUEST = {
41160
41109
  };
41161
41110
  const PROTOCOL_V2_DEVICE_INFO_REQUEST = PROTOCOL_V2_FULL_DEVICE_INFO_REQUEST;
41162
41111
  const PROTOCOL_V2_DEVICE_INFO_TIMEOUT_MS = 10 * 1000;
41112
+ let protocolV2DeviceInfoMockEnabled = false;
41113
+ const setProtocolV2DeviceInfoMock = (enabled) => {
41114
+ protocolV2DeviceInfoMockEnabled = enabled;
41115
+ };
41116
+ const isProtocolV2DeviceInfoMockEnabled = () => protocolV2DeviceInfoMockEnabled;
41163
41117
  const buildMockProtocolV2DeviceInfo = () => ({
41164
41118
  protocol_version: 2,
41165
41119
  hw: {
@@ -41178,21 +41132,25 @@ const buildMockProtocolV2DeviceInfo = () => ({
41178
41132
  });
41179
41133
  function requestProtocolV2DeviceInfo({ commands, timeoutMs = PROTOCOL_V2_DEVICE_INFO_TIMEOUT_MS, request = PROTOCOL_V2_FEATURES_DEVICE_INFO_REQUEST, }) {
41180
41134
  return __awaiter(this, void 0, void 0, function* () {
41181
- {
41135
+ if (isProtocolV2DeviceInfoMockEnabled()) {
41182
41136
  return buildMockProtocolV2DeviceInfo();
41183
41137
  }
41138
+ const { message } = yield commands.typedCall('DevGetDeviceInfo', 'DeviceInfo', request, {
41139
+ timeoutMs,
41140
+ });
41141
+ return message;
41184
41142
  });
41185
41143
  }
41186
41144
 
41187
41145
  const isMeaningfulVersion = (version) => Boolean(version && version !== '0.0.0');
41188
- const firstVersion = (...versions) => { var _a; return (_a = versions.find(isMeaningfulVersion)) !== null && _a !== void 0 ? _a : null; };
41146
+ const firstMeaningfulVersion$1 = (...versions) => { var _a; return (_a = versions.find(isMeaningfulVersion)) !== null && _a !== void 0 ? _a : null; };
41189
41147
  const versionArrayToString = (version) => {
41190
41148
  if (!version || version.length === 0)
41191
41149
  return null;
41192
41150
  const value = version.join('.');
41193
41151
  return isMeaningfulVersion(value) ? value : null;
41194
41152
  };
41195
- const bytesToHex$1 = (value) => {
41153
+ const bytesToHex$2 = (value) => {
41196
41154
  if (!value)
41197
41155
  return undefined;
41198
41156
  if (typeof value === 'string')
@@ -41207,14 +41165,14 @@ const bytesToHex$1 = (value) => {
41207
41165
  }
41208
41166
  return undefined;
41209
41167
  };
41210
- const getImageVersion = (image) => { var _a; return (_a = image === null || image === void 0 ? void 0 : image.version) !== null && _a !== void 0 ? _a : null; };
41211
- const getImageBuildId = (image) => { var _a; return (_a = image === null || image === void 0 ? void 0 : image.build_id) !== null && _a !== void 0 ? _a : undefined; };
41212
- const getImageHash = (image) => bytesToHex$1(image === null || image === void 0 ? void 0 : image.hash);
41168
+ const getImageVersion$1 = (image) => { var _a; return (_a = image === null || image === void 0 ? void 0 : image.version) !== null && _a !== void 0 ? _a : null; };
41169
+ const getImageBuildId$1 = (image) => { var _a; return (_a = image === null || image === void 0 ? void 0 : image.build_id) !== null && _a !== void 0 ? _a : undefined; };
41170
+ const getImageHash$1 = (image) => bytesToHex$2(image === null || image === void 0 ? void 0 : image.hash);
41213
41171
  const shouldIncludeVerify = (scope) => scope === 'verify' || scope === 'full';
41214
41172
  const getDeviceMode = (features) => {
41215
41173
  if (!features)
41216
41174
  return 'unknown';
41217
- if (features.bootloader_mode === true)
41175
+ if (features.bootloaderMode === true)
41218
41176
  return 'bootloader';
41219
41177
  if (features.initialized === false)
41220
41178
  return 'notInitialized';
@@ -41231,35 +41189,35 @@ const getProtocolV2Mode = (deviceInfo) => {
41231
41189
  return 'normal';
41232
41190
  return 'unknown';
41233
41191
  };
41234
- const normalizeV1Versions = (features, onekeyFeatures) => ({
41235
- firmware: firstVersion(onekeyFeatures === null || onekeyFeatures === void 0 ? void 0 : onekeyFeatures.onekey_firmware_version, versionArrayToString(getDeviceFirmwareVersion(features))),
41236
- bootloader: firstVersion(onekeyFeatures === null || onekeyFeatures === void 0 ? void 0 : onekeyFeatures.onekey_boot_version, versionArrayToString(getDeviceBootloaderVersion(features))),
41237
- board: firstVersion(onekeyFeatures === null || onekeyFeatures === void 0 ? void 0 : onekeyFeatures.onekey_board_version, versionArrayToString(features ? getDeviceBoardloaderVersion(features) : undefined)),
41238
- ble: firstVersion(onekeyFeatures === null || onekeyFeatures === void 0 ? void 0 : onekeyFeatures.onekey_ble_version, features === null || features === void 0 ? void 0 : features.onekey_ble_version, features === null || features === void 0 ? void 0 : features.ble_ver, versionArrayToString(features ? getDeviceBLEFirmwareVersion(features) : undefined)),
41239
- se01: firstVersion(onekeyFeatures === null || onekeyFeatures === void 0 ? void 0 : onekeyFeatures.onekey_se01_version, features === null || features === void 0 ? void 0 : features.onekey_se01_version),
41240
- se02: firstVersion(onekeyFeatures === null || onekeyFeatures === void 0 ? void 0 : onekeyFeatures.onekey_se02_version, features === null || features === void 0 ? void 0 : features.onekey_se02_version),
41241
- se03: firstVersion(onekeyFeatures === null || onekeyFeatures === void 0 ? void 0 : onekeyFeatures.onekey_se03_version, features === null || features === void 0 ? void 0 : features.onekey_se03_version),
41242
- se04: firstVersion(onekeyFeatures === null || onekeyFeatures === void 0 ? void 0 : onekeyFeatures.onekey_se04_version, features === null || features === void 0 ? void 0 : features.onekey_se04_version),
41243
- se01Boot: firstVersion(onekeyFeatures === null || onekeyFeatures === void 0 ? void 0 : onekeyFeatures.onekey_se01_boot_version, features === null || features === void 0 ? void 0 : features.onekey_se01_boot_version),
41244
- se02Boot: firstVersion(onekeyFeatures === null || onekeyFeatures === void 0 ? void 0 : onekeyFeatures.onekey_se02_boot_version, features === null || features === void 0 ? void 0 : features.onekey_se02_boot_version),
41245
- se03Boot: firstVersion(onekeyFeatures === null || onekeyFeatures === void 0 ? void 0 : onekeyFeatures.onekey_se03_boot_version, features === null || features === void 0 ? void 0 : features.onekey_se03_boot_version),
41246
- se04Boot: firstVersion(onekeyFeatures === null || onekeyFeatures === void 0 ? void 0 : onekeyFeatures.onekey_se04_boot_version, features === null || features === void 0 ? void 0 : features.onekey_se04_boot_version),
41192
+ const normalizeV1Versions = (features, protocolV1OneKeyFeatures) => ({
41193
+ firmware: firstMeaningfulVersion$1(protocolV1OneKeyFeatures === null || protocolV1OneKeyFeatures === void 0 ? void 0 : protocolV1OneKeyFeatures.onekey_firmware_version, versionArrayToString(getDeviceFirmwareVersion(features))),
41194
+ bootloader: firstMeaningfulVersion$1(protocolV1OneKeyFeatures === null || protocolV1OneKeyFeatures === void 0 ? void 0 : protocolV1OneKeyFeatures.onekey_boot_version, versionArrayToString(getDeviceBootloaderVersion(features))),
41195
+ board: firstMeaningfulVersion$1(protocolV1OneKeyFeatures === null || protocolV1OneKeyFeatures === void 0 ? void 0 : protocolV1OneKeyFeatures.onekey_board_version, versionArrayToString(features ? getDeviceBoardloaderVersion(features) : undefined)),
41196
+ ble: firstMeaningfulVersion$1(protocolV1OneKeyFeatures === null || protocolV1OneKeyFeatures === void 0 ? void 0 : protocolV1OneKeyFeatures.onekey_ble_version, features === null || features === void 0 ? void 0 : features.bleVersion, versionArrayToString(features ? getDeviceBLEFirmwareVersion(features) : undefined)),
41197
+ se01: firstMeaningfulVersion$1(protocolV1OneKeyFeatures === null || protocolV1OneKeyFeatures === void 0 ? void 0 : protocolV1OneKeyFeatures.onekey_se01_version, features === null || features === void 0 ? void 0 : features.se01Version),
41198
+ se02: firstMeaningfulVersion$1(protocolV1OneKeyFeatures === null || protocolV1OneKeyFeatures === void 0 ? void 0 : protocolV1OneKeyFeatures.onekey_se02_version, features === null || features === void 0 ? void 0 : features.se02Version),
41199
+ se03: firstMeaningfulVersion$1(protocolV1OneKeyFeatures === null || protocolV1OneKeyFeatures === void 0 ? void 0 : protocolV1OneKeyFeatures.onekey_se03_version, features === null || features === void 0 ? void 0 : features.se03Version),
41200
+ se04: firstMeaningfulVersion$1(protocolV1OneKeyFeatures === null || protocolV1OneKeyFeatures === void 0 ? void 0 : protocolV1OneKeyFeatures.onekey_se04_version, features === null || features === void 0 ? void 0 : features.se04Version),
41201
+ se01Boot: firstMeaningfulVersion$1(protocolV1OneKeyFeatures === null || protocolV1OneKeyFeatures === void 0 ? void 0 : protocolV1OneKeyFeatures.onekey_se01_boot_version, features === null || features === void 0 ? void 0 : features.se01BootVersion),
41202
+ se02Boot: firstMeaningfulVersion$1(protocolV1OneKeyFeatures === null || protocolV1OneKeyFeatures === void 0 ? void 0 : protocolV1OneKeyFeatures.onekey_se02_boot_version, features === null || features === void 0 ? void 0 : features.se02BootVersion),
41203
+ se03Boot: firstMeaningfulVersion$1(protocolV1OneKeyFeatures === null || protocolV1OneKeyFeatures === void 0 ? void 0 : protocolV1OneKeyFeatures.onekey_se03_boot_version, features === null || features === void 0 ? void 0 : features.se03BootVersion),
41204
+ se04Boot: firstMeaningfulVersion$1(protocolV1OneKeyFeatures === null || protocolV1OneKeyFeatures === void 0 ? void 0 : protocolV1OneKeyFeatures.onekey_se04_boot_version, features === null || features === void 0 ? void 0 : features.se04BootVersion),
41247
41205
  });
41248
41206
  const normalizeV2Versions = (deviceInfo) => {
41249
41207
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
41250
41208
  return ({
41251
- firmware: firstVersion(getImageVersion((_a = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.fw) === null || _a === void 0 ? void 0 : _a.app)),
41252
- bootloader: firstVersion(getImageVersion((_b = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.fw) === null || _b === void 0 ? void 0 : _b.boot)),
41253
- board: firstVersion(getImageVersion((_c = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.fw) === null || _c === void 0 ? void 0 : _c.board)),
41254
- ble: firstVersion(getImageVersion((_d = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.bt) === null || _d === void 0 ? void 0 : _d.app)),
41255
- se01: firstVersion(getImageVersion((_e = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se1) === null || _e === void 0 ? void 0 : _e.app)),
41256
- se02: firstVersion(getImageVersion((_f = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se2) === null || _f === void 0 ? void 0 : _f.app)),
41257
- se03: firstVersion(getImageVersion((_g = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se3) === null || _g === void 0 ? void 0 : _g.app)),
41258
- se04: firstVersion(getImageVersion((_h = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se4) === null || _h === void 0 ? void 0 : _h.app)),
41259
- se01Boot: firstVersion(getImageVersion((_j = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se1) === null || _j === void 0 ? void 0 : _j.boot)),
41260
- se02Boot: firstVersion(getImageVersion((_k = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se2) === null || _k === void 0 ? void 0 : _k.boot)),
41261
- se03Boot: firstVersion(getImageVersion((_l = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se3) === null || _l === void 0 ? void 0 : _l.boot)),
41262
- se04Boot: firstVersion(getImageVersion((_m = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se4) === null || _m === void 0 ? void 0 : _m.boot)),
41209
+ firmware: firstMeaningfulVersion$1(getImageVersion$1((_a = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.fw) === null || _a === void 0 ? void 0 : _a.app)),
41210
+ bootloader: firstMeaningfulVersion$1(getImageVersion$1((_b = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.fw) === null || _b === void 0 ? void 0 : _b.boot)),
41211
+ board: firstMeaningfulVersion$1(getImageVersion$1((_c = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.fw) === null || _c === void 0 ? void 0 : _c.board)),
41212
+ ble: firstMeaningfulVersion$1(getImageVersion$1((_d = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.bt) === null || _d === void 0 ? void 0 : _d.app)),
41213
+ se01: firstMeaningfulVersion$1(getImageVersion$1((_e = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se1) === null || _e === void 0 ? void 0 : _e.app)),
41214
+ se02: firstMeaningfulVersion$1(getImageVersion$1((_f = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se2) === null || _f === void 0 ? void 0 : _f.app)),
41215
+ se03: firstMeaningfulVersion$1(getImageVersion$1((_g = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se3) === null || _g === void 0 ? void 0 : _g.app)),
41216
+ se04: firstMeaningfulVersion$1(getImageVersion$1((_h = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se4) === null || _h === void 0 ? void 0 : _h.app)),
41217
+ se01Boot: firstMeaningfulVersion$1(getImageVersion$1((_j = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se1) === null || _j === void 0 ? void 0 : _j.boot)),
41218
+ se02Boot: firstMeaningfulVersion$1(getImageVersion$1((_k = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se2) === null || _k === void 0 ? void 0 : _k.boot)),
41219
+ se03Boot: firstMeaningfulVersion$1(getImageVersion$1((_l = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se3) === null || _l === void 0 ? void 0 : _l.boot)),
41220
+ se04Boot: firstMeaningfulVersion$1(getImageVersion$1((_m = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se4) === null || _m === void 0 ? void 0 : _m.boot)),
41263
41221
  });
41264
41222
  };
41265
41223
  const normalizeV1Status = (features) => {
@@ -41267,13 +41225,13 @@ const normalizeV1Status = (features) => {
41267
41225
  return ({
41268
41226
  mode: getDeviceMode(features),
41269
41227
  initialized: (_a = features === null || features === void 0 ? void 0 : features.initialized) !== null && _a !== void 0 ? _a : null,
41270
- bootloaderMode: (_b = features === null || features === void 0 ? void 0 : features.bootloader_mode) !== null && _b !== void 0 ? _b : null,
41228
+ bootloaderMode: (_b = features === null || features === void 0 ? void 0 : features.bootloaderMode) !== null && _b !== void 0 ? _b : null,
41271
41229
  unlocked: (_c = features === null || features === void 0 ? void 0 : features.unlocked) !== null && _c !== void 0 ? _c : null,
41272
- passphraseProtection: (_d = features === null || features === void 0 ? void 0 : features.passphrase_protection) !== null && _d !== void 0 ? _d : null,
41273
- backupRequired: (_e = features === null || features === void 0 ? void 0 : features.needs_backup) !== null && _e !== void 0 ? _e : null,
41274
- noBackup: (_f = features === null || features === void 0 ? void 0 : features.no_backup) !== null && _f !== void 0 ? _f : null,
41230
+ passphraseProtection: (_d = features === null || features === void 0 ? void 0 : features.passphraseProtection) !== null && _d !== void 0 ? _d : null,
41231
+ backupRequired: (_e = features === null || features === void 0 ? void 0 : features.backupRequired) !== null && _e !== void 0 ? _e : null,
41232
+ noBackup: (_f = features === null || features === void 0 ? void 0 : features.noBackup) !== null && _f !== void 0 ? _f : null,
41275
41233
  language: (_g = features === null || features === void 0 ? void 0 : features.language) !== null && _g !== void 0 ? _g : null,
41276
- bleEnabled: (_h = features === null || features === void 0 ? void 0 : features.ble_enable) !== null && _h !== void 0 ? _h : null,
41234
+ bleEnabled: (_h = features === null || features === void 0 ? void 0 : features.bleEnabled) !== null && _h !== void 0 ? _h : null,
41277
41235
  });
41278
41236
  };
41279
41237
  const normalizeV2Status = (deviceInfo) => {
@@ -41290,109 +41248,87 @@ const normalizeV2Status = (deviceInfo) => {
41290
41248
  bleEnabled: (_k = (_j = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.status) === null || _j === void 0 ? void 0 : _j.bt_enable) !== null && _k !== void 0 ? _k : null,
41291
41249
  });
41292
41250
  };
41293
- const normalizeV1Verify = (features, onekeyFeatures) => {
41294
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
41251
+ const normalizeV1Verify = (features, protocolV1OneKeyFeatures) => {
41252
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23;
41295
41253
  return ({
41296
- firmwareBuildId: (_a = onekeyFeatures === null || onekeyFeatures === void 0 ? void 0 : onekeyFeatures.onekey_firmware_build_id) !== null && _a !== void 0 ? _a : features === null || features === void 0 ? void 0 : features.onekey_firmware_build_id,
41297
- firmwareHash: (_b = onekeyFeatures === null || onekeyFeatures === void 0 ? void 0 : onekeyFeatures.onekey_firmware_hash) !== null && _b !== void 0 ? _b : features === null || features === void 0 ? void 0 : features.onekey_firmware_hash,
41298
- bootloaderBuildId: (_c = onekeyFeatures === null || onekeyFeatures === void 0 ? void 0 : onekeyFeatures.onekey_boot_build_id) !== null && _c !== void 0 ? _c : features === null || features === void 0 ? void 0 : features.onekey_boot_build_id,
41299
- bootloaderHash: (_d = onekeyFeatures === null || onekeyFeatures === void 0 ? void 0 : onekeyFeatures.onekey_boot_hash) !== null && _d !== void 0 ? _d : features === null || features === void 0 ? void 0 : features.onekey_boot_hash,
41300
- boardBuildId: (_e = onekeyFeatures === null || onekeyFeatures === void 0 ? void 0 : onekeyFeatures.onekey_board_build_id) !== null && _e !== void 0 ? _e : features === null || features === void 0 ? void 0 : features.onekey_board_build_id,
41301
- boardHash: (_f = onekeyFeatures === null || onekeyFeatures === void 0 ? void 0 : onekeyFeatures.onekey_board_hash) !== null && _f !== void 0 ? _f : features === null || features === void 0 ? void 0 : features.onekey_board_hash,
41302
- bleBuildId: (_g = onekeyFeatures === null || onekeyFeatures === void 0 ? void 0 : onekeyFeatures.onekey_ble_build_id) !== null && _g !== void 0 ? _g : features === null || features === void 0 ? void 0 : features.onekey_ble_build_id,
41303
- bleHash: (_h = onekeyFeatures === null || onekeyFeatures === void 0 ? void 0 : onekeyFeatures.onekey_ble_hash) !== null && _h !== void 0 ? _h : features === null || features === void 0 ? void 0 : features.onekey_ble_hash,
41304
- se01BuildId: (_j = onekeyFeatures === null || onekeyFeatures === void 0 ? void 0 : onekeyFeatures.onekey_se01_build_id) !== null && _j !== void 0 ? _j : features === null || features === void 0 ? void 0 : features.onekey_se01_build_id,
41305
- se01Hash: (_k = onekeyFeatures === null || onekeyFeatures === void 0 ? void 0 : onekeyFeatures.onekey_se01_hash) !== null && _k !== void 0 ? _k : features === null || features === void 0 ? void 0 : features.onekey_se01_hash,
41306
- se02BuildId: (_l = onekeyFeatures === null || onekeyFeatures === void 0 ? void 0 : onekeyFeatures.onekey_se02_build_id) !== null && _l !== void 0 ? _l : features === null || features === void 0 ? void 0 : features.onekey_se02_build_id,
41307
- se02Hash: (_m = onekeyFeatures === null || onekeyFeatures === void 0 ? void 0 : onekeyFeatures.onekey_se02_hash) !== null && _m !== void 0 ? _m : features === null || features === void 0 ? void 0 : features.onekey_se02_hash,
41308
- se03BuildId: (_o = onekeyFeatures === null || onekeyFeatures === void 0 ? void 0 : onekeyFeatures.onekey_se03_build_id) !== null && _o !== void 0 ? _o : features === null || features === void 0 ? void 0 : features.onekey_se03_build_id,
41309
- se03Hash: (_p = onekeyFeatures === null || onekeyFeatures === void 0 ? void 0 : onekeyFeatures.onekey_se03_hash) !== null && _p !== void 0 ? _p : features === null || features === void 0 ? void 0 : features.onekey_se03_hash,
41310
- se04BuildId: (_q = onekeyFeatures === null || onekeyFeatures === void 0 ? void 0 : onekeyFeatures.onekey_se04_build_id) !== null && _q !== void 0 ? _q : features === null || features === void 0 ? void 0 : features.onekey_se04_build_id,
41311
- se04Hash: (_r = onekeyFeatures === null || onekeyFeatures === void 0 ? void 0 : onekeyFeatures.onekey_se04_hash) !== null && _r !== void 0 ? _r : features === null || features === void 0 ? void 0 : features.onekey_se04_hash,
41312
- se01BootBuildId: (_s = onekeyFeatures === null || onekeyFeatures === void 0 ? void 0 : onekeyFeatures.onekey_se01_boot_build_id) !== null && _s !== void 0 ? _s : features === null || features === void 0 ? void 0 : features.onekey_se01_boot_build_id,
41313
- se01BootHash: (_t = onekeyFeatures === null || onekeyFeatures === void 0 ? void 0 : onekeyFeatures.onekey_se01_boot_hash) !== null && _t !== void 0 ? _t : features === null || features === void 0 ? void 0 : features.onekey_se01_boot_hash,
41314
- se02BootBuildId: (_u = onekeyFeatures === null || onekeyFeatures === void 0 ? void 0 : onekeyFeatures.onekey_se02_boot_build_id) !== null && _u !== void 0 ? _u : features === null || features === void 0 ? void 0 : features.onekey_se02_boot_build_id,
41315
- se02BootHash: (_v = onekeyFeatures === null || onekeyFeatures === void 0 ? void 0 : onekeyFeatures.onekey_se02_boot_hash) !== null && _v !== void 0 ? _v : features === null || features === void 0 ? void 0 : features.onekey_se02_boot_hash,
41316
- se03BootBuildId: (_w = onekeyFeatures === null || onekeyFeatures === void 0 ? void 0 : onekeyFeatures.onekey_se03_boot_build_id) !== null && _w !== void 0 ? _w : features === null || features === void 0 ? void 0 : features.onekey_se03_boot_build_id,
41317
- se03BootHash: (_x = onekeyFeatures === null || onekeyFeatures === void 0 ? void 0 : onekeyFeatures.onekey_se03_boot_hash) !== null && _x !== void 0 ? _x : features === null || features === void 0 ? void 0 : features.onekey_se03_boot_hash,
41318
- se04BootBuildId: (_y = onekeyFeatures === null || onekeyFeatures === void 0 ? void 0 : onekeyFeatures.onekey_se04_boot_build_id) !== null && _y !== void 0 ? _y : features === null || features === void 0 ? void 0 : features.onekey_se04_boot_build_id,
41319
- se04BootHash: (_z = onekeyFeatures === null || onekeyFeatures === void 0 ? void 0 : onekeyFeatures.onekey_se04_boot_hash) !== null && _z !== void 0 ? _z : features === null || features === void 0 ? void 0 : features.onekey_se04_boot_hash,
41254
+ firmwareBuildId: (_a = protocolV1OneKeyFeatures === null || protocolV1OneKeyFeatures === void 0 ? void 0 : protocolV1OneKeyFeatures.onekey_firmware_build_id) !== null && _a !== void 0 ? _a : (_b = features === null || features === void 0 ? void 0 : features.verify) === null || _b === void 0 ? void 0 : _b.firmwareBuildId,
41255
+ firmwareHash: (_c = protocolV1OneKeyFeatures === null || protocolV1OneKeyFeatures === void 0 ? void 0 : protocolV1OneKeyFeatures.onekey_firmware_hash) !== null && _c !== void 0 ? _c : (_d = features === null || features === void 0 ? void 0 : features.verify) === null || _d === void 0 ? void 0 : _d.firmwareHash,
41256
+ bootloaderBuildId: (_e = protocolV1OneKeyFeatures === null || protocolV1OneKeyFeatures === void 0 ? void 0 : protocolV1OneKeyFeatures.onekey_boot_build_id) !== null && _e !== void 0 ? _e : (_f = features === null || features === void 0 ? void 0 : features.verify) === null || _f === void 0 ? void 0 : _f.bootloaderBuildId,
41257
+ bootloaderHash: (_g = protocolV1OneKeyFeatures === null || protocolV1OneKeyFeatures === void 0 ? void 0 : protocolV1OneKeyFeatures.onekey_boot_hash) !== null && _g !== void 0 ? _g : (_h = features === null || features === void 0 ? void 0 : features.verify) === null || _h === void 0 ? void 0 : _h.bootloaderHash,
41258
+ boardBuildId: (_j = protocolV1OneKeyFeatures === null || protocolV1OneKeyFeatures === void 0 ? void 0 : protocolV1OneKeyFeatures.onekey_board_build_id) !== null && _j !== void 0 ? _j : (_k = features === null || features === void 0 ? void 0 : features.verify) === null || _k === void 0 ? void 0 : _k.boardBuildId,
41259
+ boardHash: (_l = protocolV1OneKeyFeatures === null || protocolV1OneKeyFeatures === void 0 ? void 0 : protocolV1OneKeyFeatures.onekey_board_hash) !== null && _l !== void 0 ? _l : (_m = features === null || features === void 0 ? void 0 : features.verify) === null || _m === void 0 ? void 0 : _m.boardHash,
41260
+ bleBuildId: (_o = protocolV1OneKeyFeatures === null || protocolV1OneKeyFeatures === void 0 ? void 0 : protocolV1OneKeyFeatures.onekey_ble_build_id) !== null && _o !== void 0 ? _o : (_p = features === null || features === void 0 ? void 0 : features.verify) === null || _p === void 0 ? void 0 : _p.bleBuildId,
41261
+ bleHash: (_q = protocolV1OneKeyFeatures === null || protocolV1OneKeyFeatures === void 0 ? void 0 : protocolV1OneKeyFeatures.onekey_ble_hash) !== null && _q !== void 0 ? _q : (_r = features === null || features === void 0 ? void 0 : features.verify) === null || _r === void 0 ? void 0 : _r.bleHash,
41262
+ se01BuildId: (_s = protocolV1OneKeyFeatures === null || protocolV1OneKeyFeatures === void 0 ? void 0 : protocolV1OneKeyFeatures.onekey_se01_build_id) !== null && _s !== void 0 ? _s : (_t = features === null || features === void 0 ? void 0 : features.verify) === null || _t === void 0 ? void 0 : _t.se01BuildId,
41263
+ se01Hash: (_u = protocolV1OneKeyFeatures === null || protocolV1OneKeyFeatures === void 0 ? void 0 : protocolV1OneKeyFeatures.onekey_se01_hash) !== null && _u !== void 0 ? _u : (_v = features === null || features === void 0 ? void 0 : features.verify) === null || _v === void 0 ? void 0 : _v.se01Hash,
41264
+ se02BuildId: (_w = protocolV1OneKeyFeatures === null || protocolV1OneKeyFeatures === void 0 ? void 0 : protocolV1OneKeyFeatures.onekey_se02_build_id) !== null && _w !== void 0 ? _w : (_x = features === null || features === void 0 ? void 0 : features.verify) === null || _x === void 0 ? void 0 : _x.se02BuildId,
41265
+ se02Hash: (_y = protocolV1OneKeyFeatures === null || protocolV1OneKeyFeatures === void 0 ? void 0 : protocolV1OneKeyFeatures.onekey_se02_hash) !== null && _y !== void 0 ? _y : (_z = features === null || features === void 0 ? void 0 : features.verify) === null || _z === void 0 ? void 0 : _z.se02Hash,
41266
+ se03BuildId: (_0 = protocolV1OneKeyFeatures === null || protocolV1OneKeyFeatures === void 0 ? void 0 : protocolV1OneKeyFeatures.onekey_se03_build_id) !== null && _0 !== void 0 ? _0 : (_1 = features === null || features === void 0 ? void 0 : features.verify) === null || _1 === void 0 ? void 0 : _1.se03BuildId,
41267
+ se03Hash: (_2 = protocolV1OneKeyFeatures === null || protocolV1OneKeyFeatures === void 0 ? void 0 : protocolV1OneKeyFeatures.onekey_se03_hash) !== null && _2 !== void 0 ? _2 : (_3 = features === null || features === void 0 ? void 0 : features.verify) === null || _3 === void 0 ? void 0 : _3.se03Hash,
41268
+ se04BuildId: (_4 = protocolV1OneKeyFeatures === null || protocolV1OneKeyFeatures === void 0 ? void 0 : protocolV1OneKeyFeatures.onekey_se04_build_id) !== null && _4 !== void 0 ? _4 : (_5 = features === null || features === void 0 ? void 0 : features.verify) === null || _5 === void 0 ? void 0 : _5.se04BuildId,
41269
+ se04Hash: (_6 = protocolV1OneKeyFeatures === null || protocolV1OneKeyFeatures === void 0 ? void 0 : protocolV1OneKeyFeatures.onekey_se04_hash) !== null && _6 !== void 0 ? _6 : (_7 = features === null || features === void 0 ? void 0 : features.verify) === null || _7 === void 0 ? void 0 : _7.se04Hash,
41270
+ se01BootBuildId: (_8 = protocolV1OneKeyFeatures === null || protocolV1OneKeyFeatures === void 0 ? void 0 : protocolV1OneKeyFeatures.onekey_se01_boot_build_id) !== null && _8 !== void 0 ? _8 : (_9 = features === null || features === void 0 ? void 0 : features.verify) === null || _9 === void 0 ? void 0 : _9.se01BootBuildId,
41271
+ se01BootHash: (_10 = protocolV1OneKeyFeatures === null || protocolV1OneKeyFeatures === void 0 ? void 0 : protocolV1OneKeyFeatures.onekey_se01_boot_hash) !== null && _10 !== void 0 ? _10 : (_11 = features === null || features === void 0 ? void 0 : features.verify) === null || _11 === void 0 ? void 0 : _11.se01BootHash,
41272
+ se02BootBuildId: (_12 = protocolV1OneKeyFeatures === null || protocolV1OneKeyFeatures === void 0 ? void 0 : protocolV1OneKeyFeatures.onekey_se02_boot_build_id) !== null && _12 !== void 0 ? _12 : (_13 = features === null || features === void 0 ? void 0 : features.verify) === null || _13 === void 0 ? void 0 : _13.se02BootBuildId,
41273
+ se02BootHash: (_14 = protocolV1OneKeyFeatures === null || protocolV1OneKeyFeatures === void 0 ? void 0 : protocolV1OneKeyFeatures.onekey_se02_boot_hash) !== null && _14 !== void 0 ? _14 : (_15 = features === null || features === void 0 ? void 0 : features.verify) === null || _15 === void 0 ? void 0 : _15.se02BootHash,
41274
+ se03BootBuildId: (_16 = protocolV1OneKeyFeatures === null || protocolV1OneKeyFeatures === void 0 ? void 0 : protocolV1OneKeyFeatures.onekey_se03_boot_build_id) !== null && _16 !== void 0 ? _16 : (_17 = features === null || features === void 0 ? void 0 : features.verify) === null || _17 === void 0 ? void 0 : _17.se03BootBuildId,
41275
+ se03BootHash: (_18 = protocolV1OneKeyFeatures === null || protocolV1OneKeyFeatures === void 0 ? void 0 : protocolV1OneKeyFeatures.onekey_se03_boot_hash) !== null && _18 !== void 0 ? _18 : (_19 = features === null || features === void 0 ? void 0 : features.verify) === null || _19 === void 0 ? void 0 : _19.se03BootHash,
41276
+ se04BootBuildId: (_20 = protocolV1OneKeyFeatures === null || protocolV1OneKeyFeatures === void 0 ? void 0 : protocolV1OneKeyFeatures.onekey_se04_boot_build_id) !== null && _20 !== void 0 ? _20 : (_21 = features === null || features === void 0 ? void 0 : features.verify) === null || _21 === void 0 ? void 0 : _21.se04BootBuildId,
41277
+ se04BootHash: (_22 = protocolV1OneKeyFeatures === null || protocolV1OneKeyFeatures === void 0 ? void 0 : protocolV1OneKeyFeatures.onekey_se04_boot_hash) !== null && _22 !== void 0 ? _22 : (_23 = features === null || features === void 0 ? void 0 : features.verify) === null || _23 === void 0 ? void 0 : _23.se04BootHash,
41320
41278
  });
41321
41279
  };
41322
41280
  const normalizeV2Verify = (deviceInfo) => {
41323
41281
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
41324
41282
  return ({
41325
- firmwareBuildId: getImageBuildId((_a = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.fw) === null || _a === void 0 ? void 0 : _a.app),
41326
- firmwareHash: getImageHash((_b = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.fw) === null || _b === void 0 ? void 0 : _b.app),
41327
- bootloaderBuildId: getImageBuildId((_c = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.fw) === null || _c === void 0 ? void 0 : _c.boot),
41328
- bootloaderHash: getImageHash((_d = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.fw) === null || _d === void 0 ? void 0 : _d.boot),
41329
- boardBuildId: getImageBuildId((_e = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.fw) === null || _e === void 0 ? void 0 : _e.board),
41330
- boardHash: getImageHash((_f = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.fw) === null || _f === void 0 ? void 0 : _f.board),
41331
- bleBuildId: getImageBuildId((_g = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.bt) === null || _g === void 0 ? void 0 : _g.app),
41332
- bleHash: getImageHash((_h = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.bt) === null || _h === void 0 ? void 0 : _h.app),
41333
- se01BuildId: getImageBuildId((_j = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se1) === null || _j === void 0 ? void 0 : _j.app),
41334
- se01Hash: getImageHash((_k = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se1) === null || _k === void 0 ? void 0 : _k.app),
41335
- se02BuildId: getImageBuildId((_l = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se2) === null || _l === void 0 ? void 0 : _l.app),
41336
- se02Hash: getImageHash((_m = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se2) === null || _m === void 0 ? void 0 : _m.app),
41337
- se03BuildId: getImageBuildId((_o = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se3) === null || _o === void 0 ? void 0 : _o.app),
41338
- se03Hash: getImageHash((_p = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se3) === null || _p === void 0 ? void 0 : _p.app),
41339
- se04BuildId: getImageBuildId((_q = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se4) === null || _q === void 0 ? void 0 : _q.app),
41340
- se04Hash: getImageHash((_r = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se4) === null || _r === void 0 ? void 0 : _r.app),
41341
- se01BootBuildId: getImageBuildId((_s = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se1) === null || _s === void 0 ? void 0 : _s.boot),
41342
- se01BootHash: getImageHash((_t = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se1) === null || _t === void 0 ? void 0 : _t.boot),
41343
- se02BootBuildId: getImageBuildId((_u = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se2) === null || _u === void 0 ? void 0 : _u.boot),
41344
- se02BootHash: getImageHash((_v = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se2) === null || _v === void 0 ? void 0 : _v.boot),
41345
- se03BootBuildId: getImageBuildId((_w = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se3) === null || _w === void 0 ? void 0 : _w.boot),
41346
- se03BootHash: getImageHash((_x = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se3) === null || _x === void 0 ? void 0 : _x.boot),
41347
- se04BootBuildId: getImageBuildId((_y = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se4) === null || _y === void 0 ? void 0 : _y.boot),
41348
- se04BootHash: getImageHash((_z = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se4) === null || _z === void 0 ? void 0 : _z.boot),
41283
+ firmwareBuildId: getImageBuildId$1((_a = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.fw) === null || _a === void 0 ? void 0 : _a.app),
41284
+ firmwareHash: getImageHash$1((_b = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.fw) === null || _b === void 0 ? void 0 : _b.app),
41285
+ bootloaderBuildId: getImageBuildId$1((_c = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.fw) === null || _c === void 0 ? void 0 : _c.boot),
41286
+ bootloaderHash: getImageHash$1((_d = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.fw) === null || _d === void 0 ? void 0 : _d.boot),
41287
+ boardBuildId: getImageBuildId$1((_e = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.fw) === null || _e === void 0 ? void 0 : _e.board),
41288
+ boardHash: getImageHash$1((_f = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.fw) === null || _f === void 0 ? void 0 : _f.board),
41289
+ bleBuildId: getImageBuildId$1((_g = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.bt) === null || _g === void 0 ? void 0 : _g.app),
41290
+ bleHash: getImageHash$1((_h = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.bt) === null || _h === void 0 ? void 0 : _h.app),
41291
+ se01BuildId: getImageBuildId$1((_j = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se1) === null || _j === void 0 ? void 0 : _j.app),
41292
+ se01Hash: getImageHash$1((_k = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se1) === null || _k === void 0 ? void 0 : _k.app),
41293
+ se02BuildId: getImageBuildId$1((_l = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se2) === null || _l === void 0 ? void 0 : _l.app),
41294
+ se02Hash: getImageHash$1((_m = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se2) === null || _m === void 0 ? void 0 : _m.app),
41295
+ se03BuildId: getImageBuildId$1((_o = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se3) === null || _o === void 0 ? void 0 : _o.app),
41296
+ se03Hash: getImageHash$1((_p = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se3) === null || _p === void 0 ? void 0 : _p.app),
41297
+ se04BuildId: getImageBuildId$1((_q = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se4) === null || _q === void 0 ? void 0 : _q.app),
41298
+ se04Hash: getImageHash$1((_r = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se4) === null || _r === void 0 ? void 0 : _r.app),
41299
+ se01BootBuildId: getImageBuildId$1((_s = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se1) === null || _s === void 0 ? void 0 : _s.boot),
41300
+ se01BootHash: getImageHash$1((_t = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se1) === null || _t === void 0 ? void 0 : _t.boot),
41301
+ se02BootBuildId: getImageBuildId$1((_u = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se2) === null || _u === void 0 ? void 0 : _u.boot),
41302
+ se02BootHash: getImageHash$1((_v = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se2) === null || _v === void 0 ? void 0 : _v.boot),
41303
+ se03BootBuildId: getImageBuildId$1((_w = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se3) === null || _w === void 0 ? void 0 : _w.boot),
41304
+ se03BootHash: getImageHash$1((_x = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se3) === null || _x === void 0 ? void 0 : _x.boot),
41305
+ se04BootBuildId: getImageBuildId$1((_y = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se4) === null || _y === void 0 ? void 0 : _y.boot),
41306
+ se04BootHash: getImageHash$1((_z = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se4) === null || _z === void 0 ? void 0 : _z.boot),
41349
41307
  });
41350
41308
  };
41351
- const normalizeRaw = ({ features, onekeyFeatures, protocolV2DeviceInfo, }) => (Object.assign(Object.assign(Object.assign({}, (features ? { features } : {})), (onekeyFeatures ? { onekeyFeatures } : {})), (protocolV2DeviceInfo ? { protocolV2DeviceInfo } : {})));
41352
- const mergeV1Features = (features, onekeyFeatures) => {
41353
- if (!features && !onekeyFeatures)
41354
- return undefined;
41355
- const _a = onekeyFeatures !== null && onekeyFeatures !== void 0 ? onekeyFeatures : {}, { onekey_device_type: onekeyDeviceType, onekey_se_type: onekeySeType, onekey_se01_state: onekeySe01State, onekey_se02_state: onekeySe02State, onekey_se03_state: onekeySe03State, onekey_se04_state: onekeySe04State } = _a, restOnekeyFeatures = __rest(_a, ["onekey_device_type", "onekey_se_type", "onekey_se01_state", "onekey_se02_state", "onekey_se03_state", "onekey_se04_state"]);
41356
- const toEnumName = (enumObject, value) => {
41357
- if (value == null || typeof value === 'string')
41358
- return value;
41359
- const label = enumObject[value];
41360
- return typeof label === 'string' ? label : String(value);
41361
- };
41362
- return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (features !== null && features !== void 0 ? features : {})), restOnekeyFeatures), (onekeyDeviceType !== undefined
41363
- ? { onekey_device_type: toEnumName(hdTransport.OneKeyDeviceType, onekeyDeviceType) }
41364
- : {})), (onekeySeType !== undefined
41365
- ? { onekey_se_type: toEnumName(hdTransport.OneKeySeType, onekeySeType) }
41366
- : {})), (onekeySe01State !== undefined
41367
- ? { onekey_se01_state: toEnumName(hdTransport.OneKeySEState, onekeySe01State) }
41368
- : {})), (onekeySe02State !== undefined
41369
- ? { onekey_se02_state: toEnumName(hdTransport.OneKeySEState, onekeySe02State) }
41370
- : {})), (onekeySe03State !== undefined
41371
- ? { onekey_se03_state: toEnumName(hdTransport.OneKeySEState, onekeySe03State) }
41372
- : {})), (onekeySe04State !== undefined
41373
- ? { onekey_se04_state: toEnumName(hdTransport.OneKeySEState, onekeySe04State) }
41374
- : {}));
41375
- };
41376
- function buildProfileFromProtocolV1({ protocol = 'V1', features, onekeyFeatures, sources = ['features'], scope = 'basic', includeRaw = false, }) {
41377
- const sourceFeatures = mergeV1Features(features, onekeyFeatures);
41378
- const verify = normalizeV1Verify(sourceFeatures, onekeyFeatures);
41309
+ const normalizeRaw = ({ features, protocolV1OneKeyFeatures, protocolV2DeviceInfo, }) => (Object.assign(Object.assign(Object.assign({}, (features ? { features } : {})), (protocolV1OneKeyFeatures ? { protocolV1OneKeyFeatures } : {})), (protocolV2DeviceInfo ? { protocolV2DeviceInfo } : {})));
41310
+ function buildProfileFromProtocolV1({ protocol = 'V1', features, protocolV1OneKeyFeatures, sources = ['features'], scope = 'basic', includeRaw = false, }) {
41311
+ const sourceFeatures = features;
41312
+ const verify = normalizeV1Verify(sourceFeatures, protocolV1OneKeyFeatures);
41379
41313
  return Object.assign(Object.assign({ protocol,
41380
- sources, deviceType: getDeviceType(sourceFeatures), firmwareType: getFirmwareType(sourceFeatures), deviceId: (sourceFeatures === null || sourceFeatures === void 0 ? void 0 : sourceFeatures.device_id) || (sourceFeatures ? getDeviceUUID(sourceFeatures) : ''), serialNo: sourceFeatures ? getDeviceUUID(sourceFeatures) : '', label: getDeviceLabel(sourceFeatures), bleName: getDeviceBleName(sourceFeatures), status: normalizeV1Status(sourceFeatures), versions: normalizeV1Versions(sourceFeatures, onekeyFeatures) }, (shouldIncludeVerify(scope) ? { verify } : {})), (includeRaw
41314
+ sources, deviceType: getDeviceType(sourceFeatures), firmwareType: getFirmwareType(sourceFeatures), deviceId: (sourceFeatures === null || sourceFeatures === void 0 ? void 0 : sourceFeatures.deviceId) || (sourceFeatures ? getDeviceUUID(sourceFeatures) : ''), serialNo: sourceFeatures ? getDeviceUUID(sourceFeatures) : '', label: getDeviceLabel(sourceFeatures), bleName: getDeviceBleName(sourceFeatures), status: normalizeV1Status(sourceFeatures), versions: normalizeV1Versions(sourceFeatures, protocolV1OneKeyFeatures) }, (shouldIncludeVerify(scope) ? { verify } : {})), (includeRaw
41381
41315
  ? {
41382
41316
  raw: normalizeRaw({
41383
41317
  features,
41384
- onekeyFeatures,
41318
+ protocolV1OneKeyFeatures,
41385
41319
  }),
41386
41320
  }
41387
41321
  : {}));
41388
41322
  }
41389
- function buildProfileFromProtocolV2({ deviceInfo, sources = ['deviceInfo'], scope = 'basic', includeRaw = false, fallbackSerialNo, }) {
41390
- var _a, _b, _c, _d, _e;
41391
- const serialNo = ((_a = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.hw) === null || _a === void 0 ? void 0 : _a.serial_no) || fallbackSerialNo || '';
41392
- const label = (_c = (_b = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.status) === null || _b === void 0 ? void 0 : _b.label) !== null && _c !== void 0 ? _c : null;
41393
- const bleName = (_e = (_d = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.bt) === null || _d === void 0 ? void 0 : _d.adv_name) !== null && _e !== void 0 ? _e : null;
41323
+ function buildProfileFromProtocolV2({ deviceInfo, sources = ['deviceInfo'], scope = 'basic', includeRaw = false, }) {
41324
+ var _a, _b, _c, _d, _e, _f;
41325
+ const deviceId = ((_a = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.hw) === null || _a === void 0 ? void 0 : _a.device_id) || '';
41326
+ const serialNo = ((_b = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.hw) === null || _b === void 0 ? void 0 : _b.serial_no) || '';
41327
+ const label = (_d = (_c = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.status) === null || _c === void 0 ? void 0 : _c.label) !== null && _d !== void 0 ? _d : null;
41328
+ const bleName = (_f = (_e = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.bt) === null || _e === void 0 ? void 0 : _e.adv_name) !== null && _f !== void 0 ? _f : null;
41394
41329
  const verify = normalizeV2Verify(deviceInfo);
41395
- return Object.assign(Object.assign({ protocol: 'V2', sources, deviceType: hdShared.EDeviceType.Pro2, firmwareType: hdShared.EFirmwareType.Universal, deviceId: serialNo, serialNo,
41330
+ return Object.assign(Object.assign({ protocol: 'V2', sources, deviceType: hdShared.EDeviceType.Pro2, firmwareType: hdShared.EFirmwareType.Universal, deviceId,
41331
+ serialNo,
41396
41332
  label,
41397
41333
  bleName, status: normalizeV2Status(deviceInfo), versions: normalizeV2Versions(deviceInfo) }, (shouldIncludeVerify(scope) ? { verify } : {})), (includeRaw
41398
41334
  ? {
@@ -41403,104 +41339,279 @@ function buildProfileFromProtocolV2({ deviceInfo, sources = ['deviceInfo'], scop
41403
41339
  : {}));
41404
41340
  }
41405
41341
 
41406
- const parseProtocolV2Version = (version) => {
41407
- if (!version)
41408
- return [0, 0, 0];
41409
- const [major = 0, minor = 0, patch = 0] = version.split('.').map(part => Number(part) || 0);
41410
- return [major, minor, patch];
41342
+ const getImageVersion = (image) => { var _a; return (_a = image === null || image === void 0 ? void 0 : image.version) !== null && _a !== void 0 ? _a : null; };
41343
+ const bytesToHex$1 = (value) => {
41344
+ if (!value)
41345
+ return undefined;
41346
+ if (typeof value === 'string')
41347
+ return value;
41348
+ if (value instanceof Uint8Array) {
41349
+ return Array.from(value)
41350
+ .map(byte => byte.toString(16).padStart(2, '0'))
41351
+ .join('');
41352
+ }
41353
+ if (Array.isArray(value)) {
41354
+ return value.map(byte => Number(byte).toString(16).padStart(2, '0')).join('');
41355
+ }
41356
+ return undefined;
41411
41357
  };
41412
- const buildProtocolV2GetFeaturesPayload = (profile, deviceInfo) => {
41413
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17;
41414
- const firmwareVersion = profile.versions.firmware;
41415
- const [fwMajor, fwMinor, fwPatch] = parseProtocolV2Version(firmwareVersion);
41358
+ const getImageBuildId = (image) => { var _a; return (_a = image === null || image === void 0 ? void 0 : image.build_id) !== null && _a !== void 0 ? _a : undefined; };
41359
+ const getImageHash = (image) => bytesToHex$1(image === null || image === void 0 ? void 0 : image.hash);
41360
+ const firstValue = (...values) => values.find(value => value !== undefined && value !== null);
41361
+ const firstMeaningfulVersion = (...versions) => { var _a; return (_a = versions.find(version => Boolean(version && version !== '0.0.0'))) !== null && _a !== void 0 ? _a : null; };
41362
+ const versionFromParts = (major, minor, patch) => [major, minor, patch].map(part => Number(part) || 0).join('.');
41363
+ const getProtocolV1Mode = (features) => {
41364
+ if (features.bootloader_mode === true)
41365
+ return 'bootloader';
41366
+ if (features.initialized === false)
41367
+ return 'notInitialized';
41368
+ if (features.initialized === true)
41369
+ return 'normal';
41370
+ return 'unknown';
41371
+ };
41372
+ const getProtocolV1DeviceType = (features) => {
41373
+ const onekeyDeviceType = features.onekey_device_type;
41374
+ switch (onekeyDeviceType) {
41375
+ case 'CLASSIC':
41376
+ return hdShared.EDeviceType.Classic;
41377
+ case 'CLASSIC1S':
41378
+ return hdShared.EDeviceType.Classic1s;
41379
+ case 'MINI':
41380
+ return hdShared.EDeviceType.Mini;
41381
+ case 'TOUCH':
41382
+ return hdShared.EDeviceType.Touch;
41383
+ case 'PRO':
41384
+ return hdShared.EDeviceType.Pro;
41385
+ case 'PRO2':
41386
+ case 'pro2':
41387
+ return hdShared.EDeviceType.Pro2;
41388
+ case 'PURE':
41389
+ return hdShared.EDeviceType.ClassicPure;
41390
+ }
41391
+ const serialNo = features.onekey_serial_no || features.onekey_serial || features.serial_no || '';
41392
+ const prefix = serialNo.slice(0, 2).toLowerCase();
41393
+ if (prefix === 'bi' || prefix === 'cl')
41394
+ return hdShared.EDeviceType.Classic;
41395
+ if (prefix === 'cp')
41396
+ return hdShared.EDeviceType.ClassicPure;
41397
+ if (prefix === 'mi')
41398
+ return hdShared.EDeviceType.Mini;
41399
+ if (prefix === 'tc')
41400
+ return hdShared.EDeviceType.Touch;
41401
+ if (prefix === 'pr')
41402
+ return hdShared.EDeviceType.Pro;
41403
+ if (prefix === 'p2')
41404
+ return hdShared.EDeviceType.Pro2;
41405
+ if (!serialNo && features.bootloader_mode === true && features.model === '1') {
41406
+ return hdShared.EDeviceType.Classic;
41407
+ }
41408
+ return hdShared.EDeviceType.Unknown;
41409
+ };
41410
+ const getProtocolV1FirmwareType = (features) => {
41411
+ if (features.fw_vendor === 'OneKey Bitcoin-only')
41412
+ return hdShared.EFirmwareType.BitcoinOnly;
41413
+ return hdShared.EFirmwareType.Universal;
41414
+ };
41415
+ const getProtocolV1Label = (features, deviceType, bleName) => {
41416
+ if (features.label)
41417
+ return features.label;
41418
+ if (bleName)
41419
+ return bleName;
41420
+ if (deviceType === hdShared.EDeviceType.Unknown)
41421
+ return null;
41422
+ if (deviceType === hdShared.EDeviceType.ClassicPure)
41423
+ return 'OneKey Classic 1S';
41424
+ return `OneKey ${deviceType.charAt(0).toUpperCase()}${deviceType.slice(1)}`;
41425
+ };
41426
+ const buildProtocolV1FeaturesPayload = (protocolV1Features, previous) => {
41427
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4;
41428
+ const features = protocolV1Features;
41429
+ const firmwareVersion = firstMeaningfulVersion(features.onekey_firmware_version, features.onekey_version, versionFromParts(features.major_version, features.minor_version, features.patch_version));
41430
+ const bootloaderVersion = firstMeaningfulVersion(features.onekey_boot_version, features.bootloader_version, features.bootloader_mode
41431
+ ? versionFromParts(features.major_version, features.minor_version, features.patch_version)
41432
+ : null);
41433
+ const boardVersion = firstMeaningfulVersion(features.onekey_board_version, features.boardloader_version);
41434
+ const bleVersion = firstMeaningfulVersion(features.onekey_ble_version, features.ble_ver);
41435
+ const serialNo = features.onekey_serial_no || features.onekey_serial || features.serial_no || '';
41436
+ const bleName = features.onekey_ble_name || features.ble_name || null;
41437
+ const deviceType = getProtocolV1DeviceType(features);
41438
+ const sessionId = (_b = (_a = features.session_id) !== null && _a !== void 0 ? _a : previous === null || previous === void 0 ? void 0 : previous.sessionId) !== null && _b !== void 0 ? _b : null;
41416
41439
  return {
41417
- vendor: 'onekey.so',
41418
- major_version: fwMajor,
41419
- minor_version: fwMinor,
41420
- patch_version: fwPatch,
41421
- bootloader_mode: false,
41422
- device_id: profile.deviceId,
41423
- pin_protection: null,
41424
- passphrase_protection: profile.status.passphraseProtection,
41425
- language: profile.status.language,
41426
- label: profile.label,
41427
- initialized: (_a = profile.status.initialized) !== null && _a !== void 0 ? _a : false,
41428
- revision: null,
41429
- bootloader_hash: null,
41430
- imported: null,
41431
- unlocked: false,
41432
- firmware_present: false,
41433
- needs_backup: profile.status.backupRequired,
41434
- flags: null,
41440
+ protocol: 'V1',
41441
+ protocolVersion: (_d = (_c = features.protocol_version) !== null && _c !== void 0 ? _c : previous === null || previous === void 0 ? void 0 : previous.protocolVersion) !== null && _d !== void 0 ? _d : 1,
41442
+ deviceType,
41443
+ firmwareType: getProtocolV1FirmwareType(features),
41444
+ model: (_e = features.model) !== null && _e !== void 0 ? _e : null,
41445
+ vendor: (_f = features.vendor) !== null && _f !== void 0 ? _f : null,
41446
+ deviceId: (_g = features.device_id) !== null && _g !== void 0 ? _g : null,
41447
+ serialNo,
41448
+ label: getProtocolV1Label(features, deviceType, bleName),
41449
+ bleName,
41450
+ capabilities: (_h = features.capabilities) !== null && _h !== void 0 ? _h : [],
41451
+ mode: getProtocolV1Mode(features),
41452
+ initialized: (_j = features.initialized) !== null && _j !== void 0 ? _j : null,
41453
+ bootloaderMode: (_k = features.bootloader_mode) !== null && _k !== void 0 ? _k : null,
41454
+ unlocked: (_l = features.unlocked) !== null && _l !== void 0 ? _l : true,
41455
+ firmwarePresent: (_m = features.firmware_present) !== null && _m !== void 0 ? _m : null,
41456
+ passphraseProtection: (_o = features.passphrase_protection) !== null && _o !== void 0 ? _o : null,
41457
+ pinProtection: (_p = features.pin_protection) !== null && _p !== void 0 ? _p : null,
41458
+ backupRequired: (_q = features.needs_backup) !== null && _q !== void 0 ? _q : null,
41459
+ noBackup: (_r = features.no_backup) !== null && _r !== void 0 ? _r : null,
41460
+ unfinishedBackup: (_s = features.unfinished_backup) !== null && _s !== void 0 ? _s : null,
41461
+ recoveryMode: (_t = features.recovery_mode) !== null && _t !== void 0 ? _t : null,
41462
+ language: (_u = features.language) !== null && _u !== void 0 ? _u : null,
41463
+ bleEnabled: (_v = features.ble_enable) !== null && _v !== void 0 ? _v : null,
41464
+ sdCardPresent: (_w = features.sd_card_present) !== null && _w !== void 0 ? _w : null,
41465
+ sdProtection: (_x = features.sd_protection) !== null && _x !== void 0 ? _x : null,
41466
+ wipeCodeProtection: (_y = features.wipe_code_protection) !== null && _y !== void 0 ? _y : null,
41467
+ passphraseAlwaysOnDevice: (_z = features.passphrase_always_on_device) !== null && _z !== void 0 ? _z : null,
41468
+ safetyChecks: (_0 = features.safety_checks) !== null && _0 !== void 0 ? _0 : null,
41469
+ autoLockDelayMs: (_1 = features.auto_lock_delay_ms) !== null && _1 !== void 0 ? _1 : null,
41470
+ displayRotation: (_2 = features.display_rotation) !== null && _2 !== void 0 ? _2 : null,
41471
+ experimentalFeatures: (_3 = features.experimental_features) !== null && _3 !== void 0 ? _3 : null,
41472
+ firmwareVersion,
41473
+ bootloaderVersion,
41474
+ boardVersion,
41475
+ bleVersion,
41476
+ se01Version: firstMeaningfulVersion(features.onekey_se01_version),
41477
+ se02Version: firstMeaningfulVersion(features.onekey_se02_version),
41478
+ se03Version: firstMeaningfulVersion(features.onekey_se03_version),
41479
+ se04Version: firstMeaningfulVersion(features.onekey_se04_version),
41480
+ se01BootVersion: firstMeaningfulVersion(features.onekey_se01_boot_version),
41481
+ se02BootVersion: firstMeaningfulVersion(features.onekey_se02_boot_version),
41482
+ se03BootVersion: firstMeaningfulVersion(features.onekey_se03_boot_version),
41483
+ se04BootVersion: firstMeaningfulVersion(features.onekey_se04_boot_version),
41484
+ seVersion: (_4 = features.se_ver) !== null && _4 !== void 0 ? _4 : null,
41485
+ verify: {
41486
+ firmwareBuildId: features.onekey_firmware_build_id,
41487
+ firmwareHash: features.onekey_firmware_hash,
41488
+ bootloaderBuildId: features.onekey_boot_build_id,
41489
+ bootloaderHash: features.onekey_boot_hash,
41490
+ boardBuildId: features.onekey_board_build_id,
41491
+ boardHash: features.onekey_board_hash,
41492
+ bleBuildId: features.onekey_ble_build_id,
41493
+ bleHash: features.onekey_ble_hash,
41494
+ se01BuildId: features.onekey_se01_build_id,
41495
+ se01Hash: features.onekey_se01_hash,
41496
+ se02BuildId: features.onekey_se02_build_id,
41497
+ se02Hash: features.onekey_se02_hash,
41498
+ se03BuildId: features.onekey_se03_build_id,
41499
+ se03Hash: features.onekey_se03_hash,
41500
+ se04BuildId: features.onekey_se04_build_id,
41501
+ se04Hash: features.onekey_se04_hash,
41502
+ se01BootBuildId: features.onekey_se01_boot_build_id,
41503
+ se01BootHash: features.onekey_se01_boot_hash,
41504
+ se02BootBuildId: features.onekey_se02_boot_build_id,
41505
+ se02BootHash: features.onekey_se02_boot_hash,
41506
+ se03BootBuildId: features.onekey_se03_boot_build_id,
41507
+ se03BootHash: features.onekey_se03_boot_hash,
41508
+ se04BootBuildId: features.onekey_se04_boot_build_id,
41509
+ se04BootHash: features.onekey_se04_boot_hash,
41510
+ },
41511
+ sessionId,
41512
+ raw: {
41513
+ protocolV1Features: protocolV1Features,
41514
+ },
41515
+ };
41516
+ };
41517
+ const buildProtocolV2FeaturesPayload = (deviceInfo, previous) => {
41518
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63, _64, _65, _66, _67, _68, _69, _70, _71, _72, _73, _74, _75, _76, _77, _78, _79;
41519
+ const info = deviceInfo;
41520
+ const fwApplication = firstValue((_a = info === null || info === void 0 ? void 0 : info.fw) === null || _a === void 0 ? void 0 : _a.application, (_b = info === null || info === void 0 ? void 0 : info.fw) === null || _b === void 0 ? void 0 : _b.app);
41521
+ const fwBootloader = firstValue((_c = info === null || info === void 0 ? void 0 : info.fw) === null || _c === void 0 ? void 0 : _c.bootloader, (_d = info === null || info === void 0 ? void 0 : info.fw) === null || _d === void 0 ? void 0 : _d.boot);
41522
+ const fwBoard = firstValue((_e = info === null || info === void 0 ? void 0 : info.fw) === null || _e === void 0 ? void 0 : _e.application_data, (_f = info === null || info === void 0 ? void 0 : info.fw) === null || _f === void 0 ? void 0 : _f.board);
41523
+ const bleApplication = firstValue((_g = info === null || info === void 0 ? void 0 : info.coprocessor) === null || _g === void 0 ? void 0 : _g.application, (_h = info === null || info === void 0 ? void 0 : info.bt) === null || _h === void 0 ? void 0 : _h.app);
41524
+ const firmwareVersion = firstMeaningfulVersion(getImageVersion(fwApplication), previous === null || previous === void 0 ? void 0 : previous.firmwareVersion);
41525
+ const bootloaderVersion = firstMeaningfulVersion(getImageVersion(fwBootloader), previous === null || previous === void 0 ? void 0 : previous.bootloaderVersion);
41526
+ const boardVersion = firstMeaningfulVersion(getImageVersion(fwBoard), previous === null || previous === void 0 ? void 0 : previous.boardVersion);
41527
+ const bleVersion = firstMeaningfulVersion(getImageVersion(bleApplication), previous === null || previous === void 0 ? void 0 : previous.bleVersion);
41528
+ const deviceId = (_k = firstValue((_j = info === null || info === void 0 ? void 0 : info.hw) === null || _j === void 0 ? void 0 : _j.device_id, previous === null || previous === void 0 ? void 0 : previous.deviceId)) !== null && _k !== void 0 ? _k : null;
41529
+ const serialNo = (_m = firstValue((_l = info === null || info === void 0 ? void 0 : info.hw) === null || _l === void 0 ? void 0 : _l.serial_no, previous === null || previous === void 0 ? void 0 : previous.serialNo)) !== null && _m !== void 0 ? _m : '';
41530
+ const label = (_p = firstValue((_o = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.status) === null || _o === void 0 ? void 0 : _o.label, previous === null || previous === void 0 ? void 0 : previous.label)) !== null && _p !== void 0 ? _p : null;
41531
+ const bleName = firstValue((_q = info === null || info === void 0 ? void 0 : info.coprocessor) === null || _q === void 0 ? void 0 : _q.bt_adv_name, (_r = info === null || info === void 0 ? void 0 : info.bt) === null || _r === void 0 ? void 0 : _r.adv_name, previous === null || previous === void 0 ? void 0 : previous.bleName);
41532
+ const initialized = (_t = firstValue((_s = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.status) === null || _s === void 0 ? void 0 : _s.init_states, previous === null || previous === void 0 ? void 0 : previous.initialized)) !== null && _t !== void 0 ? _t : null;
41533
+ const passphraseProtection = (_v = firstValue((_u = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.status) === null || _u === void 0 ? void 0 : _u.passphrase_protection, previous === null || previous === void 0 ? void 0 : previous.passphraseProtection)) !== null && _v !== void 0 ? _v : null;
41534
+ const language = (_x = firstValue((_w = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.status) === null || _w === void 0 ? void 0 : _w.language, previous === null || previous === void 0 ? void 0 : previous.language)) !== null && _x !== void 0 ? _x : null;
41535
+ const backupRequired = (_z = firstValue((_y = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.status) === null || _y === void 0 ? void 0 : _y.backup_required, previous === null || previous === void 0 ? void 0 : previous.backupRequired)) !== null && _z !== void 0 ? _z : null;
41536
+ const bleEnabled = firstValue((_0 = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.status) === null || _0 === void 0 ? void 0 : _0.bt_enable, previous === null || previous === void 0 ? void 0 : previous.bleEnabled);
41537
+ return {
41538
+ protocol: 'V2',
41539
+ protocolVersion: (_2 = (_1 = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.protocol_version) !== null && _1 !== void 0 ? _1 : previous === null || previous === void 0 ? void 0 : previous.protocolVersion) !== null && _2 !== void 0 ? _2 : null,
41540
+ deviceType: hdShared.EDeviceType.Pro2,
41541
+ firmwareType: (_3 = previous === null || previous === void 0 ? void 0 : previous.firmwareType) !== null && _3 !== void 0 ? _3 : hdShared.EFirmwareType.Universal,
41435
41542
  model: 'pro2',
41436
- fw_major: fwMajor,
41437
- fw_minor: fwMinor,
41438
- fw_patch: fwPatch,
41439
- fw_vendor: null,
41440
- unfinished_backup: null,
41441
- no_backup: null,
41442
- recovery_mode: null,
41543
+ vendor: 'onekey.so',
41544
+ deviceId,
41545
+ serialNo,
41546
+ label,
41547
+ bleName: bleName !== null && bleName !== void 0 ? bleName : null,
41443
41548
  capabilities: [],
41444
- backup_type: null,
41445
- sd_card_present: null,
41446
- sd_protection: null,
41447
- wipe_code_protection: null,
41448
- session_id: null,
41449
- passphrase_always_on_device: null,
41450
- safety_checks: null,
41451
- auto_lock_delay_ms: null,
41452
- display_rotation: null,
41453
- experimental_features: null,
41454
- protocol_version: (_b = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.protocol_version) !== null && _b !== void 0 ? _b : null,
41455
- onekey_device_type: hdShared.EDeviceType.Pro2,
41456
- onekey_serial_no: profile.serialNo,
41457
- serial_no: profile.serialNo,
41458
- ble_enable: (_c = profile.status.bleEnabled) !== null && _c !== void 0 ? _c : undefined,
41459
- onekey_ble_name: (_d = profile.bleName) !== null && _d !== void 0 ? _d : undefined,
41460
- ble_name: (_e = profile.bleName) !== null && _e !== void 0 ? _e : undefined,
41461
- onekey_firmware_version: firmwareVersion !== null && firmwareVersion !== void 0 ? firmwareVersion : undefined,
41462
- onekey_firmware_build_id: (_f = profile.verify) === null || _f === void 0 ? void 0 : _f.firmwareBuildId,
41463
- onekey_firmware_hash: (_g = profile.verify) === null || _g === void 0 ? void 0 : _g.firmwareHash,
41464
- onekey_boot_version: (_h = profile.versions.bootloader) !== null && _h !== void 0 ? _h : undefined,
41465
- bootloader_version: (_j = profile.versions.bootloader) !== null && _j !== void 0 ? _j : undefined,
41466
- onekey_boot_build_id: (_k = profile.verify) === null || _k === void 0 ? void 0 : _k.bootloaderBuildId,
41467
- onekey_boot_hash: (_l = profile.verify) === null || _l === void 0 ? void 0 : _l.bootloaderHash,
41468
- onekey_board_version: (_m = profile.versions.board) !== null && _m !== void 0 ? _m : undefined,
41469
- onekey_board_build_id: (_o = profile.verify) === null || _o === void 0 ? void 0 : _o.boardBuildId,
41470
- onekey_board_hash: (_p = profile.verify) === null || _p === void 0 ? void 0 : _p.boardHash,
41471
- onekey_ble_version: (_q = profile.versions.ble) !== null && _q !== void 0 ? _q : undefined,
41472
- ble_ver: (_r = profile.versions.ble) !== null && _r !== void 0 ? _r : undefined,
41473
- onekey_ble_build_id: (_s = profile.verify) === null || _s === void 0 ? void 0 : _s.bleBuildId,
41474
- onekey_ble_hash: (_t = profile.verify) === null || _t === void 0 ? void 0 : _t.bleHash,
41475
- onekey_se_type: getProtocolV2SeType(deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se1),
41476
- onekey_se01_version: (_u = profile.versions.se01) !== null && _u !== void 0 ? _u : undefined,
41477
- onekey_se01_hash: (_v = profile.verify) === null || _v === void 0 ? void 0 : _v.se01Hash,
41478
- onekey_se01_build_id: (_w = profile.verify) === null || _w === void 0 ? void 0 : _w.se01BuildId,
41479
- onekey_se01_boot_version: (_x = profile.versions.se01Boot) !== null && _x !== void 0 ? _x : undefined,
41480
- onekey_se01_boot_hash: (_y = profile.verify) === null || _y === void 0 ? void 0 : _y.se01BootHash,
41481
- onekey_se01_boot_build_id: (_z = profile.verify) === null || _z === void 0 ? void 0 : _z.se01BootBuildId,
41482
- onekey_se01_state: getProtocolV2SeState(deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se1),
41483
- onekey_se02_version: (_0 = profile.versions.se02) !== null && _0 !== void 0 ? _0 : undefined,
41484
- onekey_se02_hash: (_1 = profile.verify) === null || _1 === void 0 ? void 0 : _1.se02Hash,
41485
- onekey_se02_build_id: (_2 = profile.verify) === null || _2 === void 0 ? void 0 : _2.se02BuildId,
41486
- onekey_se02_boot_version: (_3 = profile.versions.se02Boot) !== null && _3 !== void 0 ? _3 : undefined,
41487
- onekey_se02_boot_hash: (_4 = profile.verify) === null || _4 === void 0 ? void 0 : _4.se02BootHash,
41488
- onekey_se02_boot_build_id: (_5 = profile.verify) === null || _5 === void 0 ? void 0 : _5.se02BootBuildId,
41489
- onekey_se02_state: getProtocolV2SeState(deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se2),
41490
- onekey_se03_version: (_6 = profile.versions.se03) !== null && _6 !== void 0 ? _6 : undefined,
41491
- onekey_se03_hash: (_7 = profile.verify) === null || _7 === void 0 ? void 0 : _7.se03Hash,
41492
- onekey_se03_build_id: (_8 = profile.verify) === null || _8 === void 0 ? void 0 : _8.se03BuildId,
41493
- onekey_se03_boot_version: (_9 = profile.versions.se03Boot) !== null && _9 !== void 0 ? _9 : undefined,
41494
- onekey_se03_boot_hash: (_10 = profile.verify) === null || _10 === void 0 ? void 0 : _10.se03BootHash,
41495
- onekey_se03_boot_build_id: (_11 = profile.verify) === null || _11 === void 0 ? void 0 : _11.se03BootBuildId,
41496
- onekey_se03_state: getProtocolV2SeState(deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se3),
41497
- onekey_se04_version: (_12 = profile.versions.se04) !== null && _12 !== void 0 ? _12 : undefined,
41498
- onekey_se04_hash: (_13 = profile.verify) === null || _13 === void 0 ? void 0 : _13.se04Hash,
41499
- onekey_se04_build_id: (_14 = profile.verify) === null || _14 === void 0 ? void 0 : _14.se04BuildId,
41500
- onekey_se04_boot_version: (_15 = profile.versions.se04Boot) !== null && _15 !== void 0 ? _15 : undefined,
41501
- onekey_se04_boot_hash: (_16 = profile.verify) === null || _16 === void 0 ? void 0 : _16.se04BootHash,
41502
- onekey_se04_boot_build_id: (_17 = profile.verify) === null || _17 === void 0 ? void 0 : _17.se04BootBuildId,
41503
- onekey_se04_state: getProtocolV2SeState(deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se4),
41549
+ mode: initialized === false ? 'notInitialized' : initialized === true ? 'normal' : 'unknown',
41550
+ initialized,
41551
+ bootloaderMode: false,
41552
+ unlocked: (_4 = previous === null || previous === void 0 ? void 0 : previous.unlocked) !== null && _4 !== void 0 ? _4 : null,
41553
+ firmwarePresent: (_5 = previous === null || previous === void 0 ? void 0 : previous.firmwarePresent) !== null && _5 !== void 0 ? _5 : null,
41554
+ passphraseProtection,
41555
+ pinProtection: null,
41556
+ backupRequired,
41557
+ noBackup: null,
41558
+ unfinishedBackup: null,
41559
+ recoveryMode: null,
41560
+ language,
41561
+ bleEnabled: bleEnabled !== null && bleEnabled !== void 0 ? bleEnabled : null,
41562
+ sdCardPresent: null,
41563
+ sdProtection: null,
41564
+ wipeCodeProtection: null,
41565
+ passphraseAlwaysOnDevice: null,
41566
+ safetyChecks: null,
41567
+ autoLockDelayMs: null,
41568
+ displayRotation: null,
41569
+ experimentalFeatures: null,
41570
+ firmwareVersion,
41571
+ bootloaderVersion,
41572
+ boardVersion,
41573
+ bleVersion,
41574
+ se01Version: firstMeaningfulVersion(getImageVersion((_6 = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se1) === null || _6 === void 0 ? void 0 : _6.app), previous === null || previous === void 0 ? void 0 : previous.se01Version),
41575
+ se02Version: firstMeaningfulVersion(getImageVersion((_7 = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se2) === null || _7 === void 0 ? void 0 : _7.app), previous === null || previous === void 0 ? void 0 : previous.se02Version),
41576
+ se03Version: firstMeaningfulVersion(getImageVersion((_8 = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se3) === null || _8 === void 0 ? void 0 : _8.app), previous === null || previous === void 0 ? void 0 : previous.se03Version),
41577
+ se04Version: firstMeaningfulVersion(getImageVersion((_9 = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se4) === null || _9 === void 0 ? void 0 : _9.app), previous === null || previous === void 0 ? void 0 : previous.se04Version),
41578
+ se01BootVersion: firstMeaningfulVersion(getImageVersion((_10 = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se1) === null || _10 === void 0 ? void 0 : _10.boot), previous === null || previous === void 0 ? void 0 : previous.se01BootVersion),
41579
+ se02BootVersion: firstMeaningfulVersion(getImageVersion((_11 = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se2) === null || _11 === void 0 ? void 0 : _11.boot), previous === null || previous === void 0 ? void 0 : previous.se02BootVersion),
41580
+ se03BootVersion: firstMeaningfulVersion(getImageVersion((_12 = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se3) === null || _12 === void 0 ? void 0 : _12.boot), previous === null || previous === void 0 ? void 0 : previous.se03BootVersion),
41581
+ se04BootVersion: firstMeaningfulVersion(getImageVersion((_13 = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se4) === null || _13 === void 0 ? void 0 : _13.boot), previous === null || previous === void 0 ? void 0 : previous.se04BootVersion),
41582
+ seVersion: (_14 = previous === null || previous === void 0 ? void 0 : previous.seVersion) !== null && _14 !== void 0 ? _14 : null,
41583
+ verify: {
41584
+ firmwareBuildId: (_15 = getImageBuildId(fwApplication)) !== null && _15 !== void 0 ? _15 : (_16 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _16 === void 0 ? void 0 : _16.firmwareBuildId,
41585
+ firmwareHash: (_17 = getImageHash(fwApplication)) !== null && _17 !== void 0 ? _17 : (_18 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _18 === void 0 ? void 0 : _18.firmwareHash,
41586
+ bootloaderBuildId: (_19 = getImageBuildId(fwBootloader)) !== null && _19 !== void 0 ? _19 : (_20 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _20 === void 0 ? void 0 : _20.bootloaderBuildId,
41587
+ bootloaderHash: (_21 = getImageHash(fwBootloader)) !== null && _21 !== void 0 ? _21 : (_22 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _22 === void 0 ? void 0 : _22.bootloaderHash,
41588
+ boardBuildId: (_23 = getImageBuildId(fwBoard)) !== null && _23 !== void 0 ? _23 : (_24 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _24 === void 0 ? void 0 : _24.boardBuildId,
41589
+ boardHash: (_25 = getImageHash(fwBoard)) !== null && _25 !== void 0 ? _25 : (_26 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _26 === void 0 ? void 0 : _26.boardHash,
41590
+ bleBuildId: (_27 = getImageBuildId(bleApplication)) !== null && _27 !== void 0 ? _27 : (_28 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _28 === void 0 ? void 0 : _28.bleBuildId,
41591
+ bleHash: (_29 = getImageHash(bleApplication)) !== null && _29 !== void 0 ? _29 : (_30 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _30 === void 0 ? void 0 : _30.bleHash,
41592
+ se01BuildId: (_32 = getImageBuildId((_31 = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se1) === null || _31 === void 0 ? void 0 : _31.app)) !== null && _32 !== void 0 ? _32 : (_33 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _33 === void 0 ? void 0 : _33.se01BuildId,
41593
+ se01Hash: (_35 = getImageHash((_34 = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se1) === null || _34 === void 0 ? void 0 : _34.app)) !== null && _35 !== void 0 ? _35 : (_36 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _36 === void 0 ? void 0 : _36.se01Hash,
41594
+ se02BuildId: (_38 = getImageBuildId((_37 = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se2) === null || _37 === void 0 ? void 0 : _37.app)) !== null && _38 !== void 0 ? _38 : (_39 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _39 === void 0 ? void 0 : _39.se02BuildId,
41595
+ se02Hash: (_41 = getImageHash((_40 = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se2) === null || _40 === void 0 ? void 0 : _40.app)) !== null && _41 !== void 0 ? _41 : (_42 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _42 === void 0 ? void 0 : _42.se02Hash,
41596
+ se03BuildId: (_44 = getImageBuildId((_43 = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se3) === null || _43 === void 0 ? void 0 : _43.app)) !== null && _44 !== void 0 ? _44 : (_45 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _45 === void 0 ? void 0 : _45.se03BuildId,
41597
+ se03Hash: (_47 = getImageHash((_46 = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se3) === null || _46 === void 0 ? void 0 : _46.app)) !== null && _47 !== void 0 ? _47 : (_48 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _48 === void 0 ? void 0 : _48.se03Hash,
41598
+ se04BuildId: (_50 = getImageBuildId((_49 = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se4) === null || _49 === void 0 ? void 0 : _49.app)) !== null && _50 !== void 0 ? _50 : (_51 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _51 === void 0 ? void 0 : _51.se04BuildId,
41599
+ se04Hash: (_53 = getImageHash((_52 = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se4) === null || _52 === void 0 ? void 0 : _52.app)) !== null && _53 !== void 0 ? _53 : (_54 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _54 === void 0 ? void 0 : _54.se04Hash,
41600
+ se01BootBuildId: (_56 = getImageBuildId((_55 = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se1) === null || _55 === void 0 ? void 0 : _55.boot)) !== null && _56 !== void 0 ? _56 : (_57 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _57 === void 0 ? void 0 : _57.se01BootBuildId,
41601
+ se01BootHash: (_59 = getImageHash((_58 = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se1) === null || _58 === void 0 ? void 0 : _58.boot)) !== null && _59 !== void 0 ? _59 : (_60 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _60 === void 0 ? void 0 : _60.se01BootHash,
41602
+ se02BootBuildId: (_62 = getImageBuildId((_61 = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se2) === null || _61 === void 0 ? void 0 : _61.boot)) !== null && _62 !== void 0 ? _62 : (_63 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _63 === void 0 ? void 0 : _63.se02BootBuildId,
41603
+ se02BootHash: (_65 = getImageHash((_64 = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se2) === null || _64 === void 0 ? void 0 : _64.boot)) !== null && _65 !== void 0 ? _65 : (_66 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _66 === void 0 ? void 0 : _66.se02BootHash,
41604
+ se03BootBuildId: (_68 = getImageBuildId((_67 = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se3) === null || _67 === void 0 ? void 0 : _67.boot)) !== null && _68 !== void 0 ? _68 : (_69 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _69 === void 0 ? void 0 : _69.se03BootBuildId,
41605
+ se03BootHash: (_71 = getImageHash((_70 = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se3) === null || _70 === void 0 ? void 0 : _70.boot)) !== null && _71 !== void 0 ? _71 : (_72 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _72 === void 0 ? void 0 : _72.se03BootHash,
41606
+ se04BootBuildId: (_74 = getImageBuildId((_73 = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se4) === null || _73 === void 0 ? void 0 : _73.boot)) !== null && _74 !== void 0 ? _74 : (_75 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _75 === void 0 ? void 0 : _75.se04BootBuildId,
41607
+ se04BootHash: (_77 = getImageHash((_76 = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se4) === null || _76 === void 0 ? void 0 : _76.boot)) !== null && _77 !== void 0 ? _77 : (_78 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _78 === void 0 ? void 0 : _78.se04BootHash,
41608
+ },
41609
+ sessionId: (_79 = previous === null || previous === void 0 ? void 0 : previous.sessionId) !== null && _79 !== void 0 ? _79 : null,
41610
+ passphraseState: previous === null || previous === void 0 ? void 0 : previous.passphraseState,
41611
+ unlockedAttachPin: previous === null || previous === void 0 ? void 0 : previous.unlockedAttachPin,
41612
+ raw: {
41613
+ protocolV2DeviceInfo: deviceInfo,
41614
+ },
41504
41615
  };
41505
41616
  };
41506
41617
 
@@ -41510,35 +41621,12 @@ const parseRunOptions = (options) => {
41510
41621
  return options;
41511
41622
  };
41512
41623
  const Log$c = getLogger(exports.LoggerNames.Device);
41513
- const profileVersionToArray = (version) => {
41514
- if (!version)
41515
- return null;
41516
- return version.split('.').map(part => Number(part) || 0);
41517
- };
41518
41624
  const deviceSessionCache = {};
41519
41625
  function preloadSessionCache(deviceId, passphraseState, sessionId) {
41520
41626
  const key = `${deviceId}@${passphraseState}`;
41521
41627
  deviceSessionCache[key] = sessionId;
41522
41628
  }
41523
41629
  class Device extends events.exports {
41524
- getFeaturesProfile() {
41525
- if (!this.features)
41526
- return undefined;
41527
- const protocol = this.originalDescriptor.protocolType === 'V2' ? 'V2' : 'V1';
41528
- return buildProfileFromProtocolV1({
41529
- protocol,
41530
- features: this.features,
41531
- onekeyFeatures: this.features,
41532
- sources: ['features'],
41533
- scope: 'verify',
41534
- });
41535
- }
41536
- get profile() {
41537
- return this.getFeaturesProfile();
41538
- }
41539
- set profile(profile) {
41540
- this.updateProfile(profile);
41541
- }
41542
41630
  constructor(descriptor, sdkInstanceId) {
41543
41631
  super();
41544
41632
  this.deviceConnector = null;
@@ -41571,10 +41659,11 @@ class Device extends events.exports {
41571
41659
  const bleName = this.getCurrentBleName();
41572
41660
  const label = this.getCurrentLabel();
41573
41661
  const serialNo = this.getCurrentSerialNo();
41662
+ const connectId = this.getConnectId();
41574
41663
  const deviceId = this.getCurrentDeviceId() || null;
41575
41664
  const features = this.features;
41576
41665
  return {
41577
- connectId: DataManager.isBleConnect(env) ? this.mainId || null : serialNo,
41666
+ connectId: DataManager.isBleConnect(env) ? this.mainId || null : connectId,
41578
41667
  uuid: serialNo,
41579
41668
  commType: this.originalDescriptor.commType,
41580
41669
  sdkInstanceId: this.sdkInstanceId,
@@ -41588,8 +41677,7 @@ class Device extends events.exports {
41588
41677
  label: label || 'OneKey',
41589
41678
  mode: this.getMode(),
41590
41679
  features,
41591
- profile: this.profile,
41592
- sessionId: (_c = (_b = this.features) === null || _b === void 0 ? void 0 : _b.session_id) !== null && _c !== void 0 ? _c : null,
41680
+ sessionId: (_c = (_b = this.features) === null || _b === void 0 ? void 0 : _b.sessionId) !== null && _c !== void 0 ? _c : null,
41593
41681
  firmwareVersion: this.getFirmwareVersion(),
41594
41682
  bleFirmwareVersion: this.getBLEFirmwareVersion(),
41595
41683
  unavailableCapabilities: this.unavailableCapabilities,
@@ -41755,60 +41843,46 @@ class Device extends events.exports {
41755
41843
  return this.getProtocol() === 'V2';
41756
41844
  }
41757
41845
  getCurrentDeviceType() {
41758
- var _a, _b;
41759
- return (_b = (_a = this.profile) === null || _a === void 0 ? void 0 : _a.deviceType) !== null && _b !== void 0 ? _b : getDeviceType(this.features);
41846
+ return getDeviceType(this.features);
41760
41847
  }
41761
41848
  getCurrentDeviceId() {
41762
41849
  var _a;
41763
- if (this.profile) {
41764
- return this.profile.deviceId || undefined;
41765
- }
41766
- return ((_a = this.features) === null || _a === void 0 ? void 0 : _a.device_id) || undefined;
41850
+ return ((_a = this.features) === null || _a === void 0 ? void 0 : _a.deviceId) || undefined;
41767
41851
  }
41768
41852
  getCurrentSerialNo() {
41769
- if (this.profile) {
41770
- return this.profile.serialNo || '';
41771
- }
41772
41853
  return this.features ? getDeviceUUID(this.features) : '';
41773
41854
  }
41855
+ getConnectId() {
41856
+ const serialNo = this.getCurrentSerialNo();
41857
+ if (serialNo)
41858
+ return serialNo;
41859
+ return this.originalDescriptor.path || this.originalDescriptor.id || '';
41860
+ }
41774
41861
  getCurrentBleName() {
41775
- var _a, _b, _c, _d;
41776
- if (this.isProtocolV2())
41777
- return (_b = (_a = this.profile) === null || _a === void 0 ? void 0 : _a.bleName) !== null && _b !== void 0 ? _b : null;
41778
- return (_d = (_c = this.profile) === null || _c === void 0 ? void 0 : _c.bleName) !== null && _d !== void 0 ? _d : getDeviceBleName(this.features);
41862
+ return getDeviceBleName(this.features);
41779
41863
  }
41780
41864
  getCurrentLabel() {
41781
- var _a, _b, _c, _d;
41782
- if (this.isProtocolV2())
41783
- return (_b = (_a = this.profile) === null || _a === void 0 ? void 0 : _a.label) !== null && _b !== void 0 ? _b : null;
41784
- return (_d = (_c = this.profile) === null || _c === void 0 ? void 0 : _c.label) !== null && _d !== void 0 ? _d : getDeviceLabel(this.features);
41865
+ return getDeviceLabel(this.features);
41785
41866
  }
41786
41867
  getCurrentPassphraseProtection() {
41787
41868
  var _a;
41788
- if (this.profile) {
41789
- return this.profile.status.passphraseProtection;
41790
- }
41791
- return (_a = this.features) === null || _a === void 0 ? void 0 : _a.passphrase_protection;
41869
+ return (_a = this.features) === null || _a === void 0 ? void 0 : _a.passphraseProtection;
41792
41870
  }
41793
41871
  getCurrentFirmwareType() {
41794
- var _a, _b;
41795
- return (_b = (_a = this.profile) === null || _a === void 0 ? void 0 : _a.firmwareType) !== null && _b !== void 0 ? _b : getFirmwareType(this.features);
41872
+ return getFirmwareType(this.features);
41796
41873
  }
41797
41874
  getCurrentFirmwareVersionString() {
41798
- var _a, _b, _c;
41799
- return (_b = (_a = this.profile) === null || _a === void 0 ? void 0 : _a.versions.firmware) !== null && _b !== void 0 ? _b : (_c = getDeviceFirmwareVersion(this.features)) === null || _c === void 0 ? void 0 : _c.join('.');
41875
+ var _a;
41876
+ return (_a = getDeviceFirmwareVersion(this.features)) === null || _a === void 0 ? void 0 : _a.join('.');
41800
41877
  }
41801
41878
  getCurrentBLEFirmwareVersionString() {
41802
- var _a;
41803
- if ((_a = this.profile) === null || _a === void 0 ? void 0 : _a.versions.ble)
41804
- return this.profile.versions.ble;
41805
41879
  if (!this.features)
41806
41880
  return undefined;
41807
41881
  return getDeviceBLEFirmwareVersion(this.features).join('.');
41808
41882
  }
41809
41883
  getCurrentSafetyChecks() {
41810
41884
  var _a;
41811
- return (_a = this.features) === null || _a === void 0 ? void 0 : _a.safety_checks;
41885
+ return (_a = this.features) === null || _a === void 0 ? void 0 : _a.safetyChecks;
41812
41886
  }
41813
41887
  getCurrentMethodVersionRange(getVersionRange) {
41814
41888
  var _a;
@@ -41880,11 +41954,20 @@ class Device extends events.exports {
41880
41954
  }
41881
41955
  return deviceId;
41882
41956
  }
41957
+ getSessionCacheDeviceKey(_deviceId) {
41958
+ const deviceId = _deviceId || this.getCurrentDeviceId();
41959
+ if (deviceId)
41960
+ return deviceId;
41961
+ if (this.isProtocolV2()) {
41962
+ return this.originalDescriptor.path || this.originalDescriptor.id;
41963
+ }
41964
+ return undefined;
41965
+ }
41883
41966
  getInternalState(_deviceId) {
41884
- var _a, _b;
41967
+ var _a;
41885
41968
  Log$c.debug('getInternalState session cache: ', deviceSessionCache);
41886
- Log$c.debug('getInternalState session param: ', `device_id: ${_deviceId}`, `features.device_id: ${(_a = this.features) === null || _a === void 0 ? void 0 : _a.device_id}`, `profile.deviceId: ${(_b = this.profile) === null || _b === void 0 ? void 0 : _b.deviceId}`, `passphraseState: ${this.passphraseState}`);
41887
- const deviceId = _deviceId || this.getCurrentDeviceId();
41969
+ Log$c.debug('getInternalState session param: ', `device_id: ${_deviceId}`, `features.deviceId: ${(_a = this.features) === null || _a === void 0 ? void 0 : _a.deviceId}`, `passphraseState: ${this.passphraseState}`);
41970
+ const deviceId = this.getSessionCacheDeviceKey(_deviceId);
41888
41971
  if (!deviceId)
41889
41972
  return undefined;
41890
41973
  if (!this.passphraseState)
@@ -41894,26 +41977,30 @@ class Device extends events.exports {
41894
41977
  }
41895
41978
  updateInternalState(enablePassphrase, passphraseState, deviceId, sessionId = null, featuresSessionId = null) {
41896
41979
  Log$c.debug('updateInternalState session param: ', `device_id: ${deviceId}`, `enablePassphrase: ${enablePassphrase}`, `passphraseState: ${passphraseState}`, `sessionId: ${sessionId}`, `featuresSessionId: ${featuresSessionId}`);
41980
+ const cacheDeviceKey = this.getSessionCacheDeviceKey(deviceId);
41981
+ if (!cacheDeviceKey)
41982
+ return;
41897
41983
  if (enablePassphrase) {
41898
41984
  if (sessionId) {
41899
- deviceSessionCache[this.generateStateKey(deviceId, passphraseState)] = sessionId;
41985
+ deviceSessionCache[this.generateStateKey(cacheDeviceKey, passphraseState)] = sessionId;
41900
41986
  }
41901
41987
  else if (featuresSessionId) {
41902
- deviceSessionCache[this.generateStateKey(deviceId, passphraseState)] = featuresSessionId;
41988
+ deviceSessionCache[this.generateStateKey(cacheDeviceKey, passphraseState)] =
41989
+ featuresSessionId;
41903
41990
  }
41904
41991
  }
41905
- const oldKey = `${deviceId}`;
41992
+ const oldKey = `${cacheDeviceKey}`;
41906
41993
  if (deviceSessionCache[oldKey]) {
41907
41994
  delete deviceSessionCache[oldKey];
41908
41995
  }
41909
41996
  Log$c.debug('updateInternalState session cache: ', deviceSessionCache);
41910
41997
  }
41911
41998
  setInternalState(state, initSession) {
41912
- var _a, _b;
41913
- Log$c.debug('setInternalState session param: ', `state: ${state}`, `initSession: ${initSession}`, `device_id: ${(_a = this.features) === null || _a === void 0 ? void 0 : _a.device_id}`, `profile.deviceId: ${(_b = this.profile) === null || _b === void 0 ? void 0 : _b.deviceId}`, `passphraseState: ${this.passphraseState}`);
41999
+ var _a;
42000
+ Log$c.debug('setInternalState session param: ', `state: ${state}`, `initSession: ${initSession}`, `deviceId: ${(_a = this.features) === null || _a === void 0 ? void 0 : _a.deviceId}`, `passphraseState: ${this.passphraseState}`);
41914
42001
  if (!this.passphraseState && !initSession)
41915
42002
  return;
41916
- const deviceId = this.getCurrentDeviceId();
42003
+ const deviceId = this.getSessionCacheDeviceKey();
41917
42004
  if (!deviceId)
41918
42005
  return;
41919
42006
  const key = this.generateStateKey(deviceId, this.passphraseState);
@@ -41924,7 +42011,7 @@ class Device extends events.exports {
41924
42011
  }
41925
42012
  clearInternalState(_deviceId) {
41926
42013
  Log$c.debug('clearInternalState param: ', _deviceId);
41927
- const deviceId = _deviceId || this.getCurrentDeviceId();
42014
+ const deviceId = this.getSessionCacheDeviceKey(_deviceId);
41928
42015
  if (!deviceId)
41929
42016
  return;
41930
42017
  const key = `${deviceId}`;
@@ -41938,7 +42025,7 @@ class Device extends events.exports {
41938
42025
  return __awaiter(this, void 0, void 0, function* () {
41939
42026
  if (this.isProtocolV2()) {
41940
42027
  this.passphraseState = options === null || options === void 0 ? void 0 : options.passphraseState;
41941
- if (this.profile && !this.featuresNeedsReload && !(options === null || options === void 0 ? void 0 : options.initSession)) {
42028
+ if (this.features && !this.featuresNeedsReload && !(options === null || options === void 0 ? void 0 : options.initSession)) {
41942
42029
  yield this._refreshProtocolV2Status();
41943
42030
  return;
41944
42031
  }
@@ -41981,20 +42068,14 @@ class Device extends events.exports {
41981
42068
  });
41982
42069
  }
41983
42070
  _initializeProtocolV2() {
41984
- var _a;
41985
42071
  return __awaiter(this, void 0, void 0, function* () {
41986
- Log$c.debug('Initialize device via Protocol V2 profile adapter');
42072
+ Log$c.debug('Initialize device via Protocol V2 features adapter');
41987
42073
  try {
41988
42074
  const deviceInfo = yield requestProtocolV2DeviceInfo({
41989
42075
  commands: this.commands,
41990
42076
  });
41991
- const profile = this.applyProfileUpdate(buildProfileFromProtocolV2({
41992
- deviceInfo,
41993
- sources: ['deviceInfo'],
41994
- scope: 'basic',
41995
- fallbackSerialNo: (_a = this.originalDescriptor) === null || _a === void 0 ? void 0 : _a.path,
41996
- }), deviceInfo);
41997
- Log$c.debug('Protocol V2 profile:', profile);
42077
+ const features = this.updateProtocolV2Features(deviceInfo);
42078
+ Log$c.debug('Protocol V2 features:', features);
41998
42079
  this.featuresNeedsReload = false;
41999
42080
  }
42000
42081
  catch (error) {
@@ -42004,20 +42085,14 @@ class Device extends events.exports {
42004
42085
  });
42005
42086
  }
42006
42087
  _refreshProtocolV2Status() {
42007
- var _a;
42008
42088
  return __awaiter(this, void 0, void 0, function* () {
42009
42089
  try {
42010
42090
  const deviceInfo = yield requestProtocolV2DeviceInfo({
42011
42091
  commands: this.commands,
42012
42092
  request: PROTOCOL_V2_STATUS_DEVICE_INFO_REQUEST,
42013
42093
  });
42014
- const profile = this.applyProfileUpdate(buildProfileFromProtocolV2({
42015
- deviceInfo,
42016
- sources: ['deviceInfo'],
42017
- scope: 'basic',
42018
- fallbackSerialNo: (_a = this.originalDescriptor) === null || _a === void 0 ? void 0 : _a.path,
42019
- }), deviceInfo);
42020
- Log$c.debug('Protocol V2 profile (status refresh):', profile);
42094
+ const features = this.updateProtocolV2Features(deviceInfo);
42095
+ Log$c.debug('Protocol V2 features (status refresh):', features);
42021
42096
  }
42022
42097
  catch (error) {
42023
42098
  Log$c.error('Protocol V2 status refresh failed:', error);
@@ -42026,79 +42101,40 @@ class Device extends events.exports {
42026
42101
  });
42027
42102
  }
42028
42103
  getFeatures() {
42029
- var _a, _b;
42030
42104
  return __awaiter(this, void 0, void 0, function* () {
42031
42105
  if (this.isProtocolV2()) {
42032
42106
  const deviceInfo = yield requestProtocolV2DeviceInfo({
42033
42107
  commands: this.commands,
42034
42108
  });
42035
- const profile = this.applyProfileUpdate(buildProfileFromProtocolV2({
42036
- deviceInfo,
42037
- sources: ['deviceInfo'],
42038
- scope: 'basic',
42039
- fallbackSerialNo: (_a = this.originalDescriptor) === null || _a === void 0 ? void 0 : _a.path,
42040
- }), deviceInfo);
42041
- return (_b = this.features) !== null && _b !== void 0 ? _b : this.updateProtocolV2Features(profile, deviceInfo);
42109
+ return this.updateProtocolV2Features(deviceInfo);
42042
42110
  }
42043
42111
  const { message } = yield this.commands.typedCall('GetFeatures', 'Features', {});
42044
42112
  this._updateFeatures(message);
42045
- return message;
42113
+ return this.features;
42046
42114
  });
42047
42115
  }
42048
- _updateFeatures(feat, initSession) {
42049
- var _a;
42050
- if (this.features && this.features.session_id && !feat.session_id) {
42051
- feat.session_id = this.features.session_id;
42116
+ _updateFeatures(protoFeatures, initSession) {
42117
+ var _a, _b;
42118
+ let feat = 'protocol' in protoFeatures
42119
+ ? protoFeatures
42120
+ : buildProtocolV1FeaturesPayload(protoFeatures, this.features);
42121
+ if (((_a = this.features) === null || _a === void 0 ? void 0 : _a.sessionId) && !feat.sessionId) {
42122
+ feat.sessionId = this.features.sessionId;
42052
42123
  }
42053
- if (this.getCurrentDeviceId() && feat.session_id) {
42054
- this.setInternalState(feat.session_id, initSession);
42124
+ if (this.getCurrentDeviceId() && feat.sessionId) {
42125
+ this.setInternalState(feat.sessionId, initSession);
42055
42126
  }
42056
- feat.unlocked = (_a = feat.unlocked) !== null && _a !== void 0 ? _a : true;
42127
+ feat.unlocked = (_b = feat.unlocked) !== null && _b !== void 0 ? _b : true;
42057
42128
  feat = fixFeaturesFirmwareVersion(feat);
42058
42129
  this.features = feat;
42059
- if (!this.isProtocolV2()) {
42060
- this.updateProfile(buildProfileFromProtocolV1({
42061
- features: feat,
42062
- sources: ['features'],
42063
- }));
42064
- }
42065
42130
  this.featuresNeedsReload = false;
42066
42131
  this.emit(DEVICE.FEATURES, this, feat);
42067
42132
  }
42068
- updateProfile(profile) {
42069
- var _a, _b;
42070
- if (!profile) {
42071
- this.features = undefined;
42072
- return;
42073
- }
42074
- if (profile.protocol === 'V2') {
42075
- this.updateProtocolV2Features(profile, (_a = profile.raw) === null || _a === void 0 ? void 0 : _a.protocolV2DeviceInfo);
42076
- return;
42077
- }
42078
- if ((_b = profile.raw) === null || _b === void 0 ? void 0 : _b.features) {
42079
- this.features = fixFeaturesFirmwareVersion(profile.raw.features);
42080
- }
42081
- }
42082
- applyProfileUpdate(next, deviceInfo) {
42083
- var _a;
42084
- const prev = this.profile;
42085
- if (!prev || prev.protocol !== next.protocol) {
42086
- this.updateProfile(Object.assign(Object.assign({}, next), { raw: Object.assign(Object.assign({}, next.raw), (deviceInfo ? { protocolV2DeviceInfo: deviceInfo } : {})) }));
42087
- return next;
42088
- }
42089
- const versions = Object.assign({}, prev.versions);
42090
- for (const [key, value] of Object.entries(next.versions)) {
42091
- if (value != null) {
42092
- versions[key] = value;
42093
- }
42094
- }
42095
- const merged = Object.assign(Object.assign(Object.assign({}, prev), next), { versions, verify: (_a = next.verify) !== null && _a !== void 0 ? _a : prev.verify, raw: Object.assign(Object.assign(Object.assign({}, prev.raw), next.raw), (deviceInfo ? { protocolV2DeviceInfo: deviceInfo } : {})) });
42096
- this.updateProfile(merged);
42097
- return merged;
42098
- }
42099
- updateProtocolV2Features(profile, deviceInfo) {
42100
- const features = fixFeaturesFirmwareVersion(buildProtocolV2GetFeaturesPayload(profile, deviceInfo));
42101
- this._updateFeatures(features);
42133
+ updateProtocolV2Features(deviceInfo) {
42134
+ const features = fixFeaturesFirmwareVersion(buildProtocolV2FeaturesPayload(deviceInfo, this.features));
42135
+ this.features = features;
42136
+ this.featuresNeedsReload = false;
42137
+ this.emit(DEVICE.FEATURES, this, features);
42102
42138
  return features;
42103
42139
  }
42104
42140
  updateDescriptor(descriptor, forceUpdate = false) {
@@ -42123,7 +42159,6 @@ class Device extends events.exports {
42123
42159
  if (device.features) {
42124
42160
  this._updateFeatures(device.features);
42125
42161
  }
42126
- this.updateProfile(device.profile);
42127
42162
  }
42128
42163
  run(fn, options) {
42129
42164
  return __awaiter(this, void 0, void 0, function* () {
@@ -42241,47 +42276,23 @@ class Device extends events.exports {
42241
42276
  }
42242
42277
  getMode() {
42243
42278
  var _a, _b, _c;
42244
- if (this.profile) {
42245
- if (this.profile.status.mode === 'bootloader')
42246
- return exports.EOneKeyDeviceMode.bootloader;
42247
- if (this.profile.status.mode === 'notInitialized')
42248
- return exports.EOneKeyDeviceMode.notInitialized;
42249
- if (this.profile.status.noBackup === true)
42250
- return exports.EOneKeyDeviceMode.backupMode;
42251
- if (this.profile.status.mode === 'normal')
42252
- return exports.EOneKeyDeviceMode.normal;
42253
- if (this.isProtocolV2())
42254
- return exports.EOneKeyDeviceMode.notInitialized;
42255
- }
42256
- if ((_a = this.features) === null || _a === void 0 ? void 0 : _a.bootloader_mode) {
42279
+ if ((_a = this.features) === null || _a === void 0 ? void 0 : _a.bootloaderMode) {
42257
42280
  return exports.EOneKeyDeviceMode.bootloader;
42258
42281
  }
42259
42282
  if (!((_b = this.features) === null || _b === void 0 ? void 0 : _b.initialized)) {
42260
42283
  return exports.EOneKeyDeviceMode.notInitialized;
42261
42284
  }
42262
- if ((_c = this.features) === null || _c === void 0 ? void 0 : _c.no_backup) {
42285
+ if ((_c = this.features) === null || _c === void 0 ? void 0 : _c.noBackup) {
42263
42286
  return exports.EOneKeyDeviceMode.backupMode;
42264
42287
  }
42265
42288
  return exports.EOneKeyDeviceMode.normal;
42266
42289
  }
42267
42290
  getFirmwareVersion() {
42268
- var _a;
42269
- const profileVersion = profileVersionToArray((_a = this.profile) === null || _a === void 0 ? void 0 : _a.versions.firmware);
42270
- if (profileVersion)
42271
- return profileVersion;
42272
- if (this.isProtocolV2())
42273
- return null;
42274
42291
  if (!this.features)
42275
42292
  return null;
42276
42293
  return getDeviceFirmwareVersion(this.features);
42277
42294
  }
42278
42295
  getBLEFirmwareVersion() {
42279
- var _a;
42280
- const profileVersion = profileVersionToArray((_a = this.profile) === null || _a === void 0 ? void 0 : _a.versions.ble);
42281
- if (profileVersion)
42282
- return profileVersion;
42283
- if (this.isProtocolV2())
42284
- return null;
42285
42296
  if (!this.features)
42286
42297
  return null;
42287
42298
  return getDeviceBLEFirmwareVersion(this.features);
@@ -42307,35 +42318,16 @@ class Device extends events.exports {
42307
42318
  return this.isUsed() && !this.isUsedHere();
42308
42319
  }
42309
42320
  isBootloader() {
42310
- if (this.profile) {
42311
- return (this.profile.status.mode === 'bootloader' || this.profile.status.bootloaderMode === true);
42312
- }
42313
- return this.features && !!this.features.bootloader_mode;
42321
+ return this.features && !!this.features.bootloaderMode;
42314
42322
  }
42315
42323
  isInitialized() {
42316
- if (this.profile) {
42317
- if (this.profile.status.initialized != null)
42318
- return this.profile.status.initialized;
42319
- if (this.profile.status.mode === 'normal')
42320
- return true;
42321
- if (this.profile.status.mode === 'notInitialized')
42322
- return false;
42323
- if (this.isProtocolV2())
42324
- return false;
42325
- if (this.features)
42326
- return !!this.features.initialized;
42327
- return false;
42328
- }
42329
42324
  return this.features && !!this.features.initialized;
42330
42325
  }
42331
42326
  isSeedless() {
42332
- if (this.profile) {
42333
- return this.profile.status.noBackup === true;
42334
- }
42335
- return this.features && !!this.features.no_backup;
42327
+ return this.features && !!this.features.noBackup;
42336
42328
  }
42337
42329
  isUnacquired() {
42338
- return this.features === undefined && this.profile === undefined;
42330
+ return this.features === undefined;
42339
42331
  }
42340
42332
  hasUnexpectedMode(allow, require) {
42341
42333
  if (!this.isUnacquired()) {
@@ -42360,7 +42352,7 @@ class Device extends events.exports {
42360
42352
  const isModeT = deviceType === hdShared.EDeviceType.Touch ||
42361
42353
  deviceType === hdShared.EDeviceType.Pro ||
42362
42354
  deviceType === hdShared.EDeviceType.Pro2;
42363
- const unlocked = this.profile ? this.profile.status.unlocked : (_a = this.features) === null || _a === void 0 ? void 0 : _a.unlocked;
42355
+ const unlocked = (_a = this.features) === null || _a === void 0 ? void 0 : _a.unlocked;
42364
42356
  const preCheckTouch = isModeT && unlocked === false;
42365
42357
  const passphraseProtection = this.getCurrentPassphraseProtection();
42366
42358
  return Boolean(passphraseProtection === true || preCheckTouch);
@@ -42394,16 +42386,11 @@ class Device extends events.exports {
42394
42386
  semver__default["default"].gte(firmwareVersion, versionRange.min));
42395
42387
  if (supportUnlock) {
42396
42388
  const res = yield this.commands.typedCall('UnLockDevice', 'UnLockDeviceResponse');
42397
- if (this.profile) {
42398
- this.updateProfile(Object.assign(Object.assign({}, this.profile), { status: Object.assign(Object.assign(Object.assign({}, this.profile.status), { unlocked: res.message.unlocked == null ? null : res.message.unlocked }), (res.message.passphrase_protection != null
42399
- ? { passphraseProtection: res.message.passphrase_protection }
42400
- : {})) }));
42401
- }
42402
42389
  if (this.features) {
42403
42390
  this.features.unlocked = res.message.unlocked == null ? null : res.message.unlocked;
42404
- this.features.unlocked_attach_pin =
42391
+ this.features.unlockedAttachPin =
42405
42392
  res.message.unlocked_attach_pin == null ? undefined : res.message.unlocked_attach_pin;
42406
- this.features.passphrase_protection =
42393
+ this.features.passphraseProtection =
42407
42394
  res.message.passphrase_protection == null ? null : res.message.passphrase_protection;
42408
42395
  return Promise.resolve(this.features);
42409
42396
  }
@@ -42517,7 +42504,7 @@ const getFirmwareReleaseInfo = (features, firmwareType) => {
42517
42504
  const firmwareStatus = DataManager.getFirmwareStatus(features, firmwareType);
42518
42505
  const changelog = DataManager.getFirmwareChangelog(features, firmwareType);
42519
42506
  const release = DataManager.getFirmwareLatestRelease(features, firmwareType);
42520
- const bootloaderMode = !!features.bootloader_mode;
42507
+ const bootloaderMode = !!features.bootloaderMode;
42521
42508
  return {
42522
42509
  status: firmwareStatus,
42523
42510
  changelog,
@@ -42529,7 +42516,7 @@ const getBleFirmwareReleaseInfo = (features) => {
42529
42516
  const firmwareStatus = DataManager.getBLEFirmwareStatus(features);
42530
42517
  const changelog = DataManager.getBleFirmwareChangelog(features);
42531
42518
  const release = DataManager.getBleFirmwareLatestRelease(features);
42532
- const bootloaderMode = !!features.bootloader_mode;
42519
+ const bootloaderMode = !!features.bootloaderMode;
42533
42520
  return {
42534
42521
  status: firmwareStatus,
42535
42522
  changelog,
@@ -42543,7 +42530,7 @@ const getBootloaderReleaseInfo = ({ features, willUpdateFirmwareVersion, firmwar
42543
42530
  typeof item === 'object' &&
42544
42531
  Object.prototype.hasOwnProperty.call(item, 'zh-CN') &&
42545
42532
  Object.prototype.hasOwnProperty.call(item, 'en-US'));
42546
- const bootloaderMode = !!features.bootloader_mode;
42533
+ const bootloaderMode = !!features.bootloaderMode;
42547
42534
  let shouldUpdate = false;
42548
42535
  const deviceType = getDeviceType(features);
42549
42536
  if (DeviceModelToTypes.model_mini.includes(deviceType)) {
@@ -42911,7 +42898,7 @@ function shouldReadOnekeyFeatures(params) {
42911
42898
  params.scope === 'full');
42912
42899
  }
42913
42900
  function supportOnekeyFeatures(features) {
42914
- if (!features || features.bootloader_mode)
42901
+ if (!features || features.bootloaderMode)
42915
42902
  return false;
42916
42903
  const deviceType = getDeviceType(features);
42917
42904
  return ![
@@ -42951,7 +42938,6 @@ class GetDeviceInfo extends BaseMethod {
42951
42938
  });
42952
42939
  }
42953
42940
  runProtocolV2() {
42954
- var _a, _b, _c;
42955
42941
  return __awaiter(this, void 0, void 0, function* () {
42956
42942
  const sources = ['deviceInfo'];
42957
42943
  const protocolV2DeviceInfo = yield requestProtocolV2DeviceInfo({
@@ -42963,40 +42949,32 @@ class GetDeviceInfo extends BaseMethod {
42963
42949
  sources,
42964
42950
  scope: this.params.scope,
42965
42951
  includeRaw: this.params.includeRaw,
42966
- fallbackSerialNo: (_a = this.device.originalDescriptor) === null || _a === void 0 ? void 0 : _a.path,
42967
42952
  });
42968
- if (typeof this.device.applyProfileUpdate === 'function') {
42969
- this.device.applyProfileUpdate(profile, protocolV2DeviceInfo);
42970
- }
42971
- else {
42972
- (_c = (_b = this.device).updateProfile) === null || _c === void 0 ? void 0 : _c.call(_b, profile);
42973
- }
42953
+ this.device.updateProtocolV2Features(protocolV2DeviceInfo);
42974
42954
  return profile;
42975
42955
  });
42976
42956
  }
42977
42957
  runProtocolV1() {
42978
- var _a, _b;
42979
42958
  return __awaiter(this, void 0, void 0, function* () {
42980
42959
  if (this.params.refresh === true) {
42981
42960
  yield this.device.getFeatures();
42982
42961
  }
42983
42962
  const sources = ['features'];
42984
42963
  const { features } = this.device;
42985
- let onekeyFeatures;
42964
+ let protocolV1OneKeyFeatures;
42986
42965
  if (shouldReadOnekeyFeatures(this.params) && supportOnekeyFeatures(features)) {
42987
42966
  const { message } = yield this.device.commands.typedCall('OnekeyGetFeatures', 'OnekeyFeatures');
42988
- onekeyFeatures = normalizeOnekeyFeatures(message);
42989
- sources.push('onekeyFeatures');
42967
+ protocolV1OneKeyFeatures = normalizeOnekeyFeatures(message);
42968
+ sources.push('protocolV1OneKeyFeatures');
42990
42969
  }
42991
42970
  const profile = buildProfileFromProtocolV1({
42992
42971
  protocol: 'V1',
42993
42972
  features,
42994
- onekeyFeatures,
42973
+ protocolV1OneKeyFeatures,
42995
42974
  sources,
42996
42975
  scope: this.params.scope,
42997
42976
  includeRaw: this.params.includeRaw,
42998
42977
  });
42999
- (_b = (_a = this.device).updateProfile) === null || _b === void 0 ? void 0 : _b.call(_a, profile);
43000
42978
  return profile;
43001
42979
  });
43002
42980
  }
@@ -43077,20 +43055,14 @@ class GetOnekeyFeatures extends BaseMethod {
43077
43055
  this.skipForceUpdateCheck = true;
43078
43056
  }
43079
43057
  run() {
43080
- var _a;
43081
43058
  return __awaiter(this, void 0, void 0, function* () {
43082
43059
  if (this.device.isProtocolV2()) {
43083
43060
  const deviceInfo = yield requestProtocolV2DeviceInfo({
43084
43061
  commands: this.device.commands,
43085
43062
  request: PROTOCOL_V2_DEVICE_INFO_REQUEST,
43086
43063
  });
43087
- const profile = this.device.applyProfileUpdate(buildProfileFromProtocolV2({
43088
- deviceInfo,
43089
- sources: ['deviceInfo'],
43090
- scope: 'verify',
43091
- fallbackSerialNo: (_a = this.device.originalDescriptor) === null || _a === void 0 ? void 0 : _a.path,
43092
- }), deviceInfo);
43093
- return pickOnekeyFeatures(buildProtocolV2GetFeaturesPayload(profile, deviceInfo));
43064
+ const features = this.device.updateProtocolV2Features(deviceInfo);
43065
+ return pickOnekeyFeatures(features);
43094
43066
  }
43095
43067
  const { message } = yield this.device.commands.typedCall('OnekeyGetFeatures', 'OnekeyFeatures');
43096
43068
  normalizeOnekeyFirmwareVersion(message);
@@ -43117,10 +43089,10 @@ class GetPassphraseState extends BaseMethod {
43117
43089
  const deviceType = this.device.getCurrentDeviceType();
43118
43090
  const isProSeries = deviceType === hdShared.EDeviceType.Pro || deviceType === hdShared.EDeviceType.Pro2;
43119
43091
  return Promise.resolve({
43120
- passphrase_state: isProSeries || passphraseProtection === true ? passphraseState : undefined,
43121
- session_id: (_b = newSession !== null && newSession !== void 0 ? newSession : features === null || features === void 0 ? void 0 : features.session_id) !== null && _b !== void 0 ? _b : undefined,
43122
- unlocked_attach_pin: unlockedAttachPin !== null && unlockedAttachPin !== void 0 ? unlockedAttachPin : features === null || features === void 0 ? void 0 : features.unlocked_attach_pin,
43123
- passphrase_protection: passphraseProtection,
43092
+ passphraseState: isProSeries || passphraseProtection === true ? passphraseState : undefined,
43093
+ sessionId: (_b = newSession !== null && newSession !== void 0 ? newSession : features === null || features === void 0 ? void 0 : features.sessionId) !== null && _b !== void 0 ? _b : undefined,
43094
+ unlockedAttachPin: unlockedAttachPin !== null && unlockedAttachPin !== void 0 ? unlockedAttachPin : features === null || features === void 0 ? void 0 : features.unlockedAttachPin,
43095
+ passphraseProtection,
43124
43096
  });
43125
43097
  });
43126
43098
  }
@@ -44071,7 +44043,7 @@ const getBinary = ({ features, updateType, version, isUpdateBootloader, firmware
44071
44043
  throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, 'no firmware found for this device');
44072
44044
  }
44073
44045
  if (version && !semver__default["default"].eq(releaseInfo.version.join('.'), version.join('.'))) {
44074
- const touchWithoutVersion = getDeviceType(features) === 'touch' && !features.onekey_version;
44046
+ const touchWithoutVersion = getDeviceType(features) === 'touch' && !features.firmwareVersion;
44075
44047
  if (!touchWithoutVersion) {
44076
44048
  throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, 'firmware version mismatch');
44077
44049
  }
@@ -44132,7 +44104,7 @@ const isDeviceDisconnectedError$1 = (error) => {
44132
44104
  };
44133
44105
  const postConfirmationMessage = (device) => {
44134
44106
  var _a;
44135
- if ((_a = device.features) === null || _a === void 0 ? void 0 : _a.firmware_present) {
44107
+ if ((_a = device.features) === null || _a === void 0 ? void 0 : _a.firmwarePresent) {
44136
44108
  device.emit(DEVICE.BUTTON, device, { code: 'ButtonRequest_FirmwareUpdate' });
44137
44109
  }
44138
44110
  };
@@ -44170,7 +44142,7 @@ const uploadFirmware = (updateType, typedCall, postMessage, device, { payload, r
44170
44142
  const isFirmware = updateType === 'firmware';
44171
44143
  if (isFirmware && !isUpdateBootloader) {
44172
44144
  const newFeatures = yield typedCall('GetFeatures', 'Features', {});
44173
- const deviceBootloaderVersion = getDeviceBootloaderVersion(newFeatures.message).join('.');
44145
+ const deviceBootloaderVersion = getDeviceBootloaderVersion(buildProtocolV1FeaturesPayload(newFeatures.message, device.features)).join('.');
44174
44146
  const supportUpgradeFileHeader = semver__default["default"].gte(deviceBootloaderVersion, '2.1.0');
44175
44147
  Log$9.debug('supportUpgradeFileHeader:', supportUpgradeFileHeader);
44176
44148
  if (supportUpgradeFileHeader) {
@@ -45299,7 +45271,7 @@ class FirmwareUpdateV2 extends BaseMethod {
45299
45271
  const isMini = deviceType === hdShared.EDeviceType.Mini;
45300
45272
  const isBoot183ClassicUpBle = this.params.updateType === 'firmware' &&
45301
45273
  deviceType === hdShared.EDeviceType.Classic &&
45302
- features.bootloader_version === '1.8.3';
45274
+ getDeviceBootloaderVersion(features).join('.') === '1.8.3';
45303
45275
  return isMini || isBoot183ClassicUpBle;
45304
45276
  }
45305
45277
  isSupportResourceUpdate(features, updateType) {
@@ -45713,7 +45685,7 @@ class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod {
45713
45685
  }),
45714
45686
  ]);
45715
45687
  getFeaturesTimeoutCount = 0;
45716
- const features = featuresRes.message;
45688
+ const features = buildProtocolV1FeaturesPayload(featuresRes.message, this.device.features);
45717
45689
  const bootloaderVersion = getDeviceBootloaderVersion(features).join('.');
45718
45690
  const bleVersion = getDeviceBLEFirmwareVersion(features).join('.');
45719
45691
  const firmwareVersion = getDeviceFirmwareVersion(features).join('.');
@@ -45921,16 +45893,6 @@ const DEV_REBOOT_TYPES = {
45921
45893
  Bootloader: hdTransport.DevRebootType.Bootloader,
45922
45894
  bootloader: hdTransport.DevRebootType.Bootloader,
45923
45895
  };
45924
- const DEVICE_REBOOT_TYPES = {
45925
- Normal: hdTransport.DeviceRebootType.Normal,
45926
- normal: hdTransport.DeviceRebootType.Normal,
45927
- Romloader: hdTransport.DeviceRebootType.Romloader,
45928
- romloader: hdTransport.DeviceRebootType.Romloader,
45929
- Boardloader: hdTransport.DeviceRebootType.Romloader,
45930
- boardloader: hdTransport.DeviceRebootType.Romloader,
45931
- Bootloader: hdTransport.DeviceRebootType.Bootloader,
45932
- bootloader: hdTransport.DeviceRebootType.Bootloader,
45933
- };
45934
45896
  const PROTOCOL_V2_FIRMWARE_UPDATE_OPTIONS = {
45935
45897
  intermediateTypes: ['DevFirmwareInstallProgress'],
45936
45898
  };
@@ -45996,18 +45958,6 @@ function normalizeRebootType(value) {
45996
45958
  }
45997
45959
  return hdTransport.DevRebootType.Normal;
45998
45960
  }
45999
- function normalizeDeviceRebootType(value) {
46000
- if (typeof value === 'number')
46001
- return value;
46002
- if (typeof value === 'string') {
46003
- const numeric = Number(value);
46004
- if (Number.isFinite(numeric))
46005
- return numeric;
46006
- if (value in DEVICE_REBOOT_TYPES)
46007
- return DEVICE_REBOOT_TYPES[value];
46008
- }
46009
- return hdTransport.DeviceRebootType.Normal;
46010
- }
46011
45961
  const VALID_FIRMWARE_TARGET_IDS = new Set([0, 1, 2, 3, 4, 5, 6, 10]);
46012
45962
  function normalizeTargetId(value, name) {
46013
45963
  if (value === undefined || value === null) {
@@ -46145,17 +46095,17 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
46145
46095
  runProtocolV2() {
46146
46096
  var _a, _b;
46147
46097
  return __awaiter(this, void 0, void 0, function* () {
46148
- const legacyFeatures = yield this.getProtocolV2LegacyFeatures();
46149
- const deviceFirmwareType = getFirmwareType(legacyFeatures);
46098
+ const deviceFeatures = yield this.getProtocolV2DeviceFeatures();
46099
+ const deviceFirmwareType = getFirmwareType(deviceFeatures);
46150
46100
  const firmwareType = (_a = this.params.firmwareType) !== null && _a !== void 0 ? _a : deviceFirmwareType;
46151
46101
  let resourceBinary = null;
46152
46102
  let fwBinaryMap = [];
46153
46103
  let bootloaderBinary = null;
46154
46104
  try {
46155
46105
  this.postTipMessage(exports.FirmwareUpdateTipMessage.StartDownloadFirmware);
46156
- resourceBinary = yield this.prepareResourceBinary(firmwareType, legacyFeatures);
46157
- fwBinaryMap = yield this.prepareFirmwareAndBleBinary(firmwareType, legacyFeatures);
46158
- bootloaderBinary = yield this.prepareBootloaderBinary(firmwareType, legacyFeatures);
46106
+ resourceBinary = yield this.prepareResourceBinary(firmwareType, deviceFeatures);
46107
+ fwBinaryMap = yield this.prepareFirmwareAndBleBinary(firmwareType, deviceFeatures);
46108
+ bootloaderBinary = yield this.prepareBootloaderBinary(firmwareType, deviceFeatures);
46159
46109
  fwBinaryMap.push(...this.collectExplicitTargetBinaries());
46160
46110
  this.postTipMessage(exports.FirmwareUpdateTipMessage.FinishDownloadFirmware);
46161
46111
  }
@@ -46177,10 +46127,12 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
46177
46127
  return versions;
46178
46128
  });
46179
46129
  }
46180
- getProtocolV2LegacyFeatures() {
46130
+ getProtocolV2DeviceFeatures() {
46181
46131
  return __awaiter(this, void 0, void 0, function* () {
46182
46132
  if (typeof this.device.getFeatures === 'function') {
46183
- return this.device.getFeatures();
46133
+ const features = yield this.device.getFeatures();
46134
+ if (features)
46135
+ return features;
46184
46136
  }
46185
46137
  if (this.device.features) {
46186
46138
  return this.device.features;
@@ -46222,15 +46174,11 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
46222
46174
  });
46223
46175
  }
46224
46176
  isProtocolV2BootloaderMode() {
46225
- var _a, _b, _c;
46177
+ var _a;
46226
46178
  if (typeof this.device.isBootloader === 'function') {
46227
46179
  return this.device.isBootloader();
46228
46180
  }
46229
- const profile = this.device.profile;
46230
- if (((_a = profile === null || profile === void 0 ? void 0 : profile.status) === null || _a === void 0 ? void 0 : _a.mode) === 'bootloader' || ((_b = profile === null || profile === void 0 ? void 0 : profile.status) === null || _b === void 0 ? void 0 : _b.bootloaderMode) === true) {
46231
- return true;
46232
- }
46233
- return !!((_c = this.device.features) === null || _c === void 0 ? void 0 : _c.bootloader_mode);
46181
+ return !!((_a = this.device.features) === null || _a === void 0 ? void 0 : _a.bootloaderMode);
46234
46182
  }
46235
46183
  enterProtocolV2BootloaderMode() {
46236
46184
  var _a, _b, _c;
@@ -46471,13 +46419,11 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
46471
46419
  });
46472
46420
  }
46473
46421
  waitForProtocolV2FinalFeatures() {
46474
- var _a, _b, _c, _d, _e;
46475
46422
  return __awaiter(this, void 0, void 0, function* () {
46476
- const profile = yield this.waitForProtocolV2ReconnectAndProfile(PROTOCOL_V2_BOOTLOADER_RECONNECT_TIMEOUT);
46477
- (_b = (_a = this.device).updateProfile) === null || _b === void 0 ? void 0 : _b.call(_a, profile);
46478
- const bootloaderVersion = (_c = profile.versions.bootloader) !== null && _c !== void 0 ? _c : '0.0.0';
46479
- const bleVersion = (_d = profile.versions.ble) !== null && _d !== void 0 ? _d : '0.0.0';
46480
- const firmwareVersion = (_e = profile.versions.firmware) !== null && _e !== void 0 ? _e : '0.0.0';
46423
+ const features = yield this.waitForProtocolV2ReconnectAndFeatures(PROTOCOL_V2_BOOTLOADER_RECONNECT_TIMEOUT);
46424
+ const bootloaderVersion = getDeviceBootloaderVersion(features).join('.');
46425
+ const bleVersion = getDeviceBLEFirmwareVersion(features).join('.');
46426
+ const firmwareVersion = getDeviceFirmwareVersion(features).join('.');
46481
46427
  if (firmwareVersion === '0.0.0') {
46482
46428
  Log$4.warn('Protocol V2 firmware update finished but app firmware version is still 0.0.0. This is allowed for Pro2 debug BLE-only update flows.');
46483
46429
  }
@@ -46488,8 +46434,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
46488
46434
  };
46489
46435
  });
46490
46436
  }
46491
- waitForProtocolV2ReconnectAndProfile(timeout) {
46492
- var _a;
46437
+ waitForProtocolV2ReconnectAndFeatures(timeout) {
46493
46438
  return __awaiter(this, void 0, void 0, function* () {
46494
46439
  const startTime = Date.now();
46495
46440
  let lastError;
@@ -46501,12 +46446,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
46501
46446
  timeoutMs: PROTOCOL_V2_SHORT_RESPONSE_TIMEOUT,
46502
46447
  request: PROTOCOL_V2_VERSIONS_DEVICE_INFO_REQUEST,
46503
46448
  });
46504
- return buildProfileFromProtocolV2({
46505
- deviceInfo,
46506
- sources: ['deviceInfo'],
46507
- scope: 'versions',
46508
- fallbackSerialNo: (_a = this.device.originalDescriptor) === null || _a === void 0 ? void 0 : _a.path,
46509
- });
46449
+ return this.device.updateProtocolV2Features(deviceInfo);
46510
46450
  }
46511
46451
  catch (error) {
46512
46452
  lastError = error;
@@ -46787,8 +46727,8 @@ class DeviceReboot extends BaseMethod {
46787
46727
  run() {
46788
46728
  var _a;
46789
46729
  return __awaiter(this, void 0, void 0, function* () {
46790
- const res = yield this.device.commands.typedCall('DeviceReboot', 'Success', {
46791
- reboot_type: normalizeDeviceRebootType((_a = this.params.reboot_type) !== null && _a !== void 0 ? _a : this.params.rebootType),
46730
+ const res = yield this.device.commands.typedCall('DevReboot', 'Success', {
46731
+ reboot_type: normalizeRebootType((_a = this.params.reboot_type) !== null && _a !== void 0 ? _a : this.params.rebootType),
46792
46732
  });
46793
46733
  return Promise.resolve(res.message);
46794
46734
  });
@@ -57763,7 +57703,7 @@ const checkPassphraseEnableState = (method, features) => {
57763
57703
  return;
57764
57704
  const passphraseProtection = method.device
57765
57705
  ? method.device.getCurrentPassphraseProtection()
57766
- : features === null || features === void 0 ? void 0 : features.passphrase_protection;
57706
+ : features === null || features === void 0 ? void 0 : features.passphraseProtection;
57767
57707
  if (passphraseProtection === true) {
57768
57708
  const hasNoPassphraseState = method.payload.passphraseState == null || method.payload.passphraseState === '';
57769
57709
  const shouldRequirePassphrase = !method.payload.useEmptyPassphrase && !method.payload.skipPassphraseCheck;
@@ -57989,12 +57929,14 @@ const initTransport = (Transport, plugin) => {
57989
57929
  TransportManager.setTransport(Transport, plugin);
57990
57930
  };
57991
57931
  const init = (settings, Transport, plugin) => __awaiter(void 0, void 0, void 0, function* () {
57932
+ var _r;
57992
57933
  try {
57993
57934
  try {
57994
57935
  yield DataManager.load(settings);
57936
+ setProtocolV2DeviceInfoMock((_r = settings.protocolV2DeviceInfoMockEnabled) !== null && _r !== void 0 ? _r : false);
57995
57937
  initTransport(Transport, plugin);
57996
57938
  }
57997
- catch (_r) {
57939
+ catch (_s) {
57998
57940
  Log.error('DataManager.load error');
57999
57941
  }
58000
57942
  enableLog(DataManager.getSettings('debug'));
@@ -58045,10 +57987,18 @@ Object.defineProperty(exports, 'PROTO', {
58045
57987
  enumerable: true,
58046
57988
  get: function () { return hdTransport.Messages; }
58047
57989
  });
57990
+ Object.defineProperty(exports, 'ResourceType', {
57991
+ enumerable: true,
57992
+ get: function () { return hdTransport.ResourceType; }
57993
+ });
58048
57994
  Object.defineProperty(exports, 'TonSignDataType', {
58049
57995
  enumerable: true,
58050
57996
  get: function () { return hdTransport.TonSignDataType; }
58051
57997
  });
57998
+ Object.defineProperty(exports, 'TonWalletVersion', {
57999
+ enumerable: true,
58000
+ get: function () { return hdTransport.TonWalletVersion; }
58001
+ });
58052
58002
  exports.CORE_EVENT = CORE_EVENT;
58053
58003
  exports.Core = Core;
58054
58004
  exports.DEFAULT_PRIORITY = DEFAULT_PRIORITY;