@onekeyfe/hd-core 1.2.0-alpha.11 → 1.2.0-alpha.13

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 (59) hide show
  1. package/__tests__/protocol-v2-bootloader-mode.test.ts +37 -0
  2. package/__tests__/protocol-v2.test.ts +240 -82
  3. package/__tests__/protocolV2FileWrite.test.ts +67 -0
  4. package/dist/api/FileWrite.d.ts.map +1 -1
  5. package/dist/api/FirmwareUpdateV4.d.ts +2 -0
  6. package/dist/api/FirmwareUpdateV4.d.ts.map +1 -1
  7. package/dist/api/helpers/protocolV2FileWrite.d.ts +32 -0
  8. package/dist/api/helpers/protocolV2FileWrite.d.ts.map +1 -0
  9. package/dist/api/index.d.ts +1 -1
  10. package/dist/api/index.d.ts.map +1 -1
  11. package/dist/api/protocol-v2/DeviceGetOnboardingStatus.d.ts +6 -0
  12. package/dist/api/protocol-v2/DeviceGetOnboardingStatus.d.ts.map +1 -0
  13. package/dist/api/protocol-v2/DeviceUploadWallpaper.d.ts.map +1 -1
  14. package/dist/api/protocol-v2/helpers.d.ts.map +1 -1
  15. package/dist/device/Device.d.ts.map +1 -1
  16. package/dist/deviceProfile/buildDeviceFeatures.d.ts +2 -2
  17. package/dist/deviceProfile/buildDeviceFeatures.d.ts.map +1 -1
  18. package/dist/deviceProfile/buildDeviceProfile.d.ts.map +1 -1
  19. package/dist/index.d.ts +9 -11
  20. package/dist/index.js +736 -391
  21. package/dist/protocols/protocol-v2/features.d.ts +1 -0
  22. package/dist/protocols/protocol-v2/features.d.ts.map +1 -1
  23. package/dist/protocols/protocol-v2/index.d.ts +1 -1
  24. package/dist/protocols/protocol-v2/index.d.ts.map +1 -1
  25. package/dist/types/api/getDeviceInfo.d.ts +1 -1
  26. package/dist/types/api/getDeviceInfo.d.ts.map +1 -1
  27. package/dist/types/api/index.d.ts +2 -2
  28. package/dist/types/api/index.d.ts.map +1 -1
  29. package/dist/types/api/protocolV2.d.ts +2 -5
  30. package/dist/types/api/protocolV2.d.ts.map +1 -1
  31. package/dist/types/device.d.ts +3 -2
  32. package/dist/types/device.d.ts.map +1 -1
  33. package/dist/utils/patch.d.ts +1 -1
  34. package/dist/utils/patch.d.ts.map +1 -1
  35. package/package.json +4 -4
  36. package/src/api/FileWrite.ts +18 -186
  37. package/src/api/FirmwareUpdateV4.ts +46 -6
  38. package/src/api/cardano/CardanoSignMessage.ts +1 -1
  39. package/src/api/cardano/CardanoSignTransaction.ts +1 -1
  40. package/src/api/helpers/protocolV2FileWrite.ts +168 -0
  41. package/src/api/index.ts +1 -1
  42. package/src/api/protocol-v2/DeviceGetOnboardingStatus.ts +18 -0
  43. package/src/api/protocol-v2/DeviceUploadWallpaper.ts +22 -52
  44. package/src/api/protocol-v2/helpers.ts +0 -3
  45. package/src/data/messages/messages-protocol-v2.json +422 -16
  46. package/src/data/messages/messages.json +0 -8
  47. package/src/device/Device.ts +7 -17
  48. package/src/deviceProfile/buildDeviceFeatures.ts +28 -12
  49. package/src/deviceProfile/buildDeviceProfile.ts +8 -6
  50. package/src/inject.ts +2 -2
  51. package/src/protocols/protocol-v2/features.ts +19 -1
  52. package/src/protocols/protocol-v2/index.ts +2 -0
  53. package/src/types/api/getDeviceInfo.ts +1 -1
  54. package/src/types/api/index.ts +2 -2
  55. package/src/types/api/protocolV2.ts +6 -6
  56. package/src/types/device.ts +6 -1
  57. package/dist/api/protocol-v2/FilesystemDiskControl.d.ts +0 -13
  58. package/dist/api/protocol-v2/FilesystemDiskControl.d.ts.map +0 -1
  59. package/src/api/protocol-v2/FilesystemDiskControl.ts +0 -50
package/dist/index.js CHANGED
@@ -145,6 +145,7 @@ const createCoreApi = (call) => ({
145
145
  deviceReboot: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'deviceReboot' })),
146
146
  deviceInfoGet: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'deviceInfoGet' })),
147
147
  deviceStatusGet: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'deviceStatusGet' })),
148
+ deviceGetOnboardingStatus: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'deviceGetOnboardingStatus' })),
148
149
  deviceSessionGet: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'deviceSessionGet' })),
149
150
  deviceFirmwareUpdate: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'deviceFirmwareUpdate' })),
150
151
  deviceGetFirmwareUpdateStatus: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'deviceGetFirmwareUpdateStatus' })),
@@ -171,7 +172,6 @@ const createCoreApi = (call) => ({
171
172
  filesystemDirRemove: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'filesystemDirRemove' })),
172
173
  filesystemPathInfoQuery: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'filesystemPathInfoQuery' })),
173
174
  filesystemFormat: connectId => call({ connectId, method: 'filesystemFormat' }),
174
- filesystemDiskControl: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'filesystemDiskControl' })),
175
175
  deviceRecovery: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'deviceRecovery' })),
176
176
  deviceReset: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'deviceReset' })),
177
177
  deviceSettings: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'deviceSettings' })),
@@ -9287,14 +9287,6 @@ var nested$2 = {
9287
9287
  passphrase_state: {
9288
9288
  type: "string",
9289
9289
  id: 1
9290
- },
9291
- _only_main_pin: {
9292
- type: "bool",
9293
- id: 2
9294
- },
9295
- allow_create_attach_pin: {
9296
- type: "bool",
9297
- id: 3
9298
9290
  }
9299
9291
  }
9300
9292
  },
@@ -25790,7 +25782,6 @@ var nested = {
25790
25782
  MessageType_DeviceSessionGet: 60606,
25791
25783
  MessageType_DeviceSession: 60607,
25792
25784
  MessageType_DeviceSessionAskPin: 60608,
25793
- MessageType_DeviceSessionPinResult: 60609,
25794
25785
  MessageType_FilesystemPermissionFix: 60800,
25795
25786
  MessageType_FilesystemPathInfo: 60801,
25796
25787
  MessageType_FilesystemPathInfoQuery: 60802,
@@ -31484,6 +31475,33 @@ var nested = {
31484
31475
  PromptTemporarily: 2
31485
31476
  }
31486
31477
  },
31478
+ Initialize: {
31479
+ fields: {
31480
+ session_id: {
31481
+ type: "bytes",
31482
+ id: 1
31483
+ },
31484
+ _skip_passphrase: {
31485
+ type: "bool",
31486
+ id: 2,
31487
+ options: {
31488
+ deprecated: true
31489
+ }
31490
+ },
31491
+ derive_cardano: {
31492
+ type: "bool",
31493
+ id: 3
31494
+ },
31495
+ passphrase_state: {
31496
+ type: "string",
31497
+ id: 8000
31498
+ },
31499
+ is_contains_attach: {
31500
+ type: "bool",
31501
+ id: 8001
31502
+ }
31503
+ }
31504
+ },
31487
31505
  StartSession: {
31488
31506
  fields: {
31489
31507
  session_id: {
@@ -31507,6 +31525,14 @@ var nested = {
31507
31525
  fields: {
31508
31526
  }
31509
31527
  },
31528
+ GetFeatures: {
31529
+ fields: {
31530
+ }
31531
+ },
31532
+ OnekeyGetFeatures: {
31533
+ fields: {
31534
+ }
31535
+ },
31510
31536
  OneKeyDeviceType: {
31511
31537
  values: {
31512
31538
  CLASSIC: 0,
@@ -31528,6 +31554,388 @@ var nested = {
31528
31554
  APP: 1
31529
31555
  }
31530
31556
  },
31557
+ Features: {
31558
+ fields: {
31559
+ vendor: {
31560
+ type: "string",
31561
+ id: 1
31562
+ },
31563
+ major_version: {
31564
+ rule: "required",
31565
+ type: "uint32",
31566
+ id: 2
31567
+ },
31568
+ minor_version: {
31569
+ rule: "required",
31570
+ type: "uint32",
31571
+ id: 3
31572
+ },
31573
+ patch_version: {
31574
+ rule: "required",
31575
+ type: "uint32",
31576
+ id: 4
31577
+ },
31578
+ bootloader_mode: {
31579
+ type: "bool",
31580
+ id: 5
31581
+ },
31582
+ device_id: {
31583
+ type: "string",
31584
+ id: 6
31585
+ },
31586
+ pin_protection: {
31587
+ type: "bool",
31588
+ id: 7
31589
+ },
31590
+ passphrase_protection: {
31591
+ type: "bool",
31592
+ id: 8
31593
+ },
31594
+ language: {
31595
+ type: "string",
31596
+ id: 9
31597
+ },
31598
+ label: {
31599
+ type: "string",
31600
+ id: 10
31601
+ },
31602
+ initialized: {
31603
+ type: "bool",
31604
+ id: 12
31605
+ },
31606
+ revision: {
31607
+ type: "bytes",
31608
+ id: 13
31609
+ },
31610
+ bootloader_hash: {
31611
+ type: "bytes",
31612
+ id: 14
31613
+ },
31614
+ imported: {
31615
+ type: "bool",
31616
+ id: 15
31617
+ },
31618
+ unlocked: {
31619
+ type: "bool",
31620
+ id: 16
31621
+ },
31622
+ _passphrase_cached: {
31623
+ type: "bool",
31624
+ id: 17,
31625
+ options: {
31626
+ deprecated: true
31627
+ }
31628
+ },
31629
+ firmware_present: {
31630
+ type: "bool",
31631
+ id: 18
31632
+ },
31633
+ needs_backup: {
31634
+ type: "bool",
31635
+ id: 19
31636
+ },
31637
+ flags: {
31638
+ type: "uint32",
31639
+ id: 20
31640
+ },
31641
+ model: {
31642
+ type: "string",
31643
+ id: 21
31644
+ },
31645
+ fw_major: {
31646
+ type: "uint32",
31647
+ id: 22
31648
+ },
31649
+ fw_minor: {
31650
+ type: "uint32",
31651
+ id: 23
31652
+ },
31653
+ fw_patch: {
31654
+ type: "uint32",
31655
+ id: 24
31656
+ },
31657
+ fw_vendor: {
31658
+ type: "string",
31659
+ id: 25
31660
+ },
31661
+ unfinished_backup: {
31662
+ type: "bool",
31663
+ id: 27
31664
+ },
31665
+ no_backup: {
31666
+ type: "bool",
31667
+ id: 28
31668
+ },
31669
+ recovery_mode: {
31670
+ type: "bool",
31671
+ id: 29
31672
+ },
31673
+ capabilities: {
31674
+ rule: "repeated",
31675
+ type: "Capability",
31676
+ id: 30,
31677
+ options: {
31678
+ packed: false
31679
+ }
31680
+ },
31681
+ backup_type: {
31682
+ type: "BackupType",
31683
+ id: 31
31684
+ },
31685
+ sd_card_present: {
31686
+ type: "bool",
31687
+ id: 32
31688
+ },
31689
+ sd_protection: {
31690
+ type: "bool",
31691
+ id: 33
31692
+ },
31693
+ wipe_code_protection: {
31694
+ type: "bool",
31695
+ id: 34
31696
+ },
31697
+ session_id: {
31698
+ type: "bytes",
31699
+ id: 35
31700
+ },
31701
+ passphrase_always_on_device: {
31702
+ type: "bool",
31703
+ id: 36
31704
+ },
31705
+ safety_checks: {
31706
+ type: "SafetyCheckLevel",
31707
+ id: 37
31708
+ },
31709
+ auto_lock_delay_ms: {
31710
+ type: "uint32",
31711
+ id: 38
31712
+ },
31713
+ display_rotation: {
31714
+ type: "uint32",
31715
+ id: 39
31716
+ },
31717
+ experimental_features: {
31718
+ type: "bool",
31719
+ id: 40
31720
+ },
31721
+ offset: {
31722
+ type: "uint32",
31723
+ id: 500
31724
+ },
31725
+ coprocessor_bt_name: {
31726
+ type: "string",
31727
+ id: 501
31728
+ },
31729
+ coprocessor_version: {
31730
+ type: "string",
31731
+ id: 502
31732
+ },
31733
+ coprocessor_bt_enable: {
31734
+ type: "bool",
31735
+ id: 503
31736
+ },
31737
+ se_enable: {
31738
+ type: "bool",
31739
+ id: 504
31740
+ },
31741
+ se_ver: {
31742
+ type: "string",
31743
+ id: 506
31744
+ },
31745
+ backup_only: {
31746
+ type: "bool",
31747
+ id: 507
31748
+ },
31749
+ onekey_version: {
31750
+ type: "string",
31751
+ id: 508
31752
+ },
31753
+ onekey_serial: {
31754
+ type: "string",
31755
+ id: 509
31756
+ },
31757
+ bootloader_version: {
31758
+ type: "string",
31759
+ id: 510
31760
+ },
31761
+ serial_no: {
31762
+ type: "string",
31763
+ id: 511
31764
+ },
31765
+ spi_flash: {
31766
+ type: "string",
31767
+ id: 512
31768
+ },
31769
+ initstates: {
31770
+ type: "uint32",
31771
+ id: 513
31772
+ },
31773
+ NFT_voucher: {
31774
+ type: "bytes",
31775
+ id: 514
31776
+ },
31777
+ cpu_info: {
31778
+ type: "string",
31779
+ id: 515
31780
+ },
31781
+ pre_firmware: {
31782
+ type: "string",
31783
+ id: 516
31784
+ },
31785
+ coin_switch: {
31786
+ type: "uint32",
31787
+ id: 517
31788
+ },
31789
+ build_id: {
31790
+ type: "bytes",
31791
+ id: 518
31792
+ },
31793
+ romloader_version: {
31794
+ type: "string",
31795
+ id: 519
31796
+ },
31797
+ busy: {
31798
+ type: "bool",
31799
+ id: 41
31800
+ },
31801
+ onekey_device_type: {
31802
+ type: "OneKeyDeviceType",
31803
+ id: 600
31804
+ },
31805
+ onekey_se_type: {
31806
+ type: "OneKeySeType",
31807
+ id: 601
31808
+ },
31809
+ onekey_romloader_version: {
31810
+ type: "string",
31811
+ id: 602
31812
+ },
31813
+ onekey_romloader_hash: {
31814
+ type: "bytes",
31815
+ id: 603
31816
+ },
31817
+ onekey_bootloader_version: {
31818
+ type: "string",
31819
+ id: 604
31820
+ },
31821
+ onekey_bootloader_hash: {
31822
+ type: "bytes",
31823
+ id: 605
31824
+ },
31825
+ onekey_se01_version: {
31826
+ type: "string",
31827
+ id: 606
31828
+ },
31829
+ onekey_se01_hash: {
31830
+ type: "bytes",
31831
+ id: 607
31832
+ },
31833
+ onekey_se01_build_id: {
31834
+ type: "string",
31835
+ id: 608
31836
+ },
31837
+ onekey_firmware_version: {
31838
+ type: "string",
31839
+ id: 609
31840
+ },
31841
+ onekey_firmware_hash: {
31842
+ type: "bytes",
31843
+ id: 610
31844
+ },
31845
+ onekey_firmware_build_id: {
31846
+ type: "string",
31847
+ id: 611
31848
+ },
31849
+ onekey_serial_no: {
31850
+ type: "string",
31851
+ id: 612
31852
+ },
31853
+ onekey_bootloader_build_id: {
31854
+ type: "string",
31855
+ id: 613
31856
+ },
31857
+ onekey_coprocessor_bt_name: {
31858
+ type: "string",
31859
+ id: 614
31860
+ },
31861
+ onekey_coprocessor_version: {
31862
+ type: "string",
31863
+ id: 615
31864
+ },
31865
+ onekey_coprocessor_build_id: {
31866
+ type: "string",
31867
+ id: 616
31868
+ },
31869
+ onekey_coprocessor_hash: {
31870
+ type: "bytes",
31871
+ id: 617
31872
+ },
31873
+ onekey_se02_version: {
31874
+ type: "string",
31875
+ id: 618
31876
+ },
31877
+ onekey_se03_version: {
31878
+ type: "string",
31879
+ id: 619
31880
+ },
31881
+ onekey_se04_version: {
31882
+ type: "string",
31883
+ id: 620
31884
+ },
31885
+ onekey_se01_state: {
31886
+ type: "OneKeySEState",
31887
+ id: 621
31888
+ },
31889
+ onekey_se02_state: {
31890
+ type: "OneKeySEState",
31891
+ id: 622
31892
+ },
31893
+ onekey_se03_state: {
31894
+ type: "OneKeySEState",
31895
+ id: 623
31896
+ },
31897
+ onekey_se04_state: {
31898
+ type: "OneKeySEState",
31899
+ id: 624
31900
+ },
31901
+ attach_to_pin_user: {
31902
+ type: "bool",
31903
+ id: 625
31904
+ },
31905
+ unlocked_attach_pin: {
31906
+ type: "bool",
31907
+ id: 626
31908
+ }
31909
+ },
31910
+ nested: {
31911
+ Capability: {
31912
+ options: {
31913
+ "(has_bitcoin_only_values)": true
31914
+ },
31915
+ values: {
31916
+ Capability_Bitcoin: 1,
31917
+ Capability_Bitcoin_like: 2,
31918
+ Capability_Binance: 3,
31919
+ Capability_Cardano: 4,
31920
+ Capability_Crypto: 5,
31921
+ Capability_EOS: 6,
31922
+ Capability_Ethereum: 7,
31923
+ Capability_Lisk: 8,
31924
+ Capability_Monero: 9,
31925
+ Capability_NEM: 10,
31926
+ Capability_Ripple: 11,
31927
+ Capability_Stellar: 12,
31928
+ Capability_Tezos: 13,
31929
+ Capability_U2F: 14,
31930
+ Capability_Shamir: 15,
31931
+ Capability_ShamirGroups: 16,
31932
+ Capability_PassphraseEntry: 17,
31933
+ Capability_AttachToPin: 18,
31934
+ Capability_EthereumTypedData: 1000
31935
+ }
31936
+ }
31937
+ }
31938
+ },
31531
31939
  OnekeyFeatures: {
31532
31940
  fields: {
31533
31941
  onekey_device_type: {
@@ -36517,7 +36925,10 @@ var nested = {
36517
36925
  ViewSignLayout: {
36518
36926
  values: {
36519
36927
  LayoutDefault: 0,
36520
- LayoutSafeTxCreate: 1
36928
+ LayoutSafeTxCreate: 1,
36929
+ LayoutFinalConfirm: 2,
36930
+ Layout7702: 3,
36931
+ LayoutFlat: 4
36521
36932
  }
36522
36933
  },
36523
36934
  ViewSignPage: {
@@ -37378,20 +37789,9 @@ var nested = {
37378
37789
  fields: {
37379
37790
  }
37380
37791
  },
37381
- DeviceSessionPinResult: {
37382
- fields: {
37383
- unlocked: {
37384
- type: "bool",
37385
- id: 1
37386
- },
37387
- unlocked_attach_pin: {
37388
- type: "bool",
37389
- id: 2
37390
- },
37391
- passphrase_protection: {
37392
- type: "bool",
37393
- id: 3
37394
- }
37792
+ DeviceSessionAskPin_FailureSubCodes: {
37793
+ values: {
37794
+ UserCancel: 1
37395
37795
  }
37396
37796
  },
37397
37797
  DeviceStatus: {
@@ -41001,7 +41401,20 @@ class DeviceWalletSessionStore {
41001
41401
  }
41002
41402
  const deviceWalletSessionStore = new DeviceWalletSessionStore();
41003
41403
 
41004
- const isProtocolV2BootloaderDeviceInfo = (deviceInfo) => !!deviceInfo && deviceInfo.status == null;
41404
+ const isProtocolV2RomloaderDeviceInfo = (deviceInfo) => {
41405
+ var _a, _b, _c;
41406
+ return !!deviceInfo &&
41407
+ deviceInfo.status == null &&
41408
+ ((_a = deviceInfo.fw) === null || _a === void 0 ? void 0 : _a.romloader) != null &&
41409
+ ((_b = deviceInfo.fw) === null || _b === void 0 ? void 0 : _b.application) == null &&
41410
+ ((_c = deviceInfo.fw) === null || _c === void 0 ? void 0 : _c.application_data) == null &&
41411
+ deviceInfo.coprocessor == null &&
41412
+ deviceInfo.se1 == null &&
41413
+ deviceInfo.se2 == null &&
41414
+ deviceInfo.se3 == null &&
41415
+ deviceInfo.se4 == null;
41416
+ };
41417
+ const isProtocolV2BootloaderDeviceInfo = (deviceInfo) => !!deviceInfo && deviceInfo.status == null && !isProtocolV2RomloaderDeviceInfo(deviceInfo);
41005
41418
  const PROTOCOL_V2_FEATURES_DEVICE_INFO_REQUEST = {
41006
41419
  targets: {
41007
41420
  hw: true,
@@ -41110,6 +41523,8 @@ const getDeviceMode = (features) => {
41110
41523
  };
41111
41524
  const getProtocolV2Mode = (deviceInfo) => {
41112
41525
  var _a;
41526
+ if (isProtocolV2RomloaderDeviceInfo(deviceInfo))
41527
+ return 'romloader';
41113
41528
  if (isProtocolV2BootloaderDeviceInfo(deviceInfo))
41114
41529
  return 'bootloader';
41115
41530
  const initialized = (_a = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.status) === null || _a === void 0 ? void 0 : _a.init_states;
@@ -41134,21 +41549,21 @@ const normalizeV1Versions = (features, protocolV1OneKeyFeatures) => ({
41134
41549
  se04Boot: firstMeaningfulVersion$1(protocolV1OneKeyFeatures === null || protocolV1OneKeyFeatures === void 0 ? void 0 : protocolV1OneKeyFeatures.onekey_se04_boot_version, features === null || features === void 0 ? void 0 : features.se04BootVersion),
41135
41550
  });
41136
41551
  const normalizeV2Versions = (deviceInfo) => {
41137
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
41552
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
41138
41553
  const info = deviceInfo;
41139
41554
  return {
41140
41555
  firmware: firstMeaningfulVersion$1(getImageVersion$1((_a = info === null || info === void 0 ? void 0 : info.fw) === null || _a === void 0 ? void 0 : _a.application)),
41141
41556
  bootloader: firstMeaningfulVersion$1(getImageVersion$1((_b = info === null || info === void 0 ? void 0 : info.fw) === null || _b === void 0 ? void 0 : _b.bootloader)),
41142
- board: firstMeaningfulVersion$1(getImageVersion$1((_d = (_c = info === null || info === void 0 ? void 0 : info.fw) === null || _c === void 0 ? void 0 : _c.application_data) !== null && _d !== void 0 ? _d : (_e = info === null || info === void 0 ? void 0 : info.fw) === null || _e === void 0 ? void 0 : _e.romloader)),
41143
- ble: firstMeaningfulVersion$1(getImageVersion$1((_f = info === null || info === void 0 ? void 0 : info.coprocessor) === null || _f === void 0 ? void 0 : _f.application)),
41144
- se01: firstMeaningfulVersion$1(getImageVersion$1((_g = info === null || info === void 0 ? void 0 : info.se1) === null || _g === void 0 ? void 0 : _g.application)),
41145
- se02: firstMeaningfulVersion$1(getImageVersion$1((_h = info === null || info === void 0 ? void 0 : info.se2) === null || _h === void 0 ? void 0 : _h.application)),
41146
- se03: firstMeaningfulVersion$1(getImageVersion$1((_j = info === null || info === void 0 ? void 0 : info.se3) === null || _j === void 0 ? void 0 : _j.application)),
41147
- se04: firstMeaningfulVersion$1(getImageVersion$1((_k = info === null || info === void 0 ? void 0 : info.se4) === null || _k === void 0 ? void 0 : _k.application)),
41148
- se01Boot: firstMeaningfulVersion$1(getImageVersion$1((_l = info === null || info === void 0 ? void 0 : info.se1) === null || _l === void 0 ? void 0 : _l.bootloader)),
41149
- se02Boot: firstMeaningfulVersion$1(getImageVersion$1((_m = info === null || info === void 0 ? void 0 : info.se2) === null || _m === void 0 ? void 0 : _m.bootloader)),
41150
- se03Boot: firstMeaningfulVersion$1(getImageVersion$1((_o = info === null || info === void 0 ? void 0 : info.se3) === null || _o === void 0 ? void 0 : _o.bootloader)),
41151
- se04Boot: firstMeaningfulVersion$1(getImageVersion$1((_p = info === null || info === void 0 ? void 0 : info.se4) === null || _p === void 0 ? void 0 : _p.bootloader)),
41557
+ board: firstMeaningfulVersion$1(getImageVersion$1((_c = info === null || info === void 0 ? void 0 : info.fw) === null || _c === void 0 ? void 0 : _c.romloader)),
41558
+ ble: firstMeaningfulVersion$1(getImageVersion$1((_d = info === null || info === void 0 ? void 0 : info.coprocessor) === null || _d === void 0 ? void 0 : _d.application)),
41559
+ se01: firstMeaningfulVersion$1(getImageVersion$1((_e = info === null || info === void 0 ? void 0 : info.se1) === null || _e === void 0 ? void 0 : _e.application)),
41560
+ se02: firstMeaningfulVersion$1(getImageVersion$1((_f = info === null || info === void 0 ? void 0 : info.se2) === null || _f === void 0 ? void 0 : _f.application)),
41561
+ se03: firstMeaningfulVersion$1(getImageVersion$1((_g = info === null || info === void 0 ? void 0 : info.se3) === null || _g === void 0 ? void 0 : _g.application)),
41562
+ se04: firstMeaningfulVersion$1(getImageVersion$1((_h = info === null || info === void 0 ? void 0 : info.se4) === null || _h === void 0 ? void 0 : _h.application)),
41563
+ se01Boot: firstMeaningfulVersion$1(getImageVersion$1((_j = info === null || info === void 0 ? void 0 : info.se1) === null || _j === void 0 ? void 0 : _j.bootloader)),
41564
+ se02Boot: firstMeaningfulVersion$1(getImageVersion$1((_k = info === null || info === void 0 ? void 0 : info.se2) === null || _k === void 0 ? void 0 : _k.bootloader)),
41565
+ se03Boot: firstMeaningfulVersion$1(getImageVersion$1((_l = info === null || info === void 0 ? void 0 : info.se3) === null || _l === void 0 ? void 0 : _l.bootloader)),
41566
+ se04Boot: firstMeaningfulVersion$1(getImageVersion$1((_m = info === null || info === void 0 ? void 0 : info.se4) === null || _m === void 0 ? void 0 : _m.bootloader)),
41152
41567
  };
41153
41568
  };
41154
41569
  const normalizeV1Status = (features) => {
@@ -41215,33 +41630,33 @@ const normalizeV1Verify = (features, protocolV1OneKeyFeatures) => {
41215
41630
  });
41216
41631
  };
41217
41632
  const normalizeV2Verify = (deviceInfo) => {
41218
- 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;
41633
+ 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;
41219
41634
  const info = deviceInfo;
41220
41635
  return {
41221
41636
  firmwareBuildId: getImageBuildId$1((_a = info === null || info === void 0 ? void 0 : info.fw) === null || _a === void 0 ? void 0 : _a.application),
41222
41637
  firmwareHash: getImageHash$1((_b = info === null || info === void 0 ? void 0 : info.fw) === null || _b === void 0 ? void 0 : _b.application),
41223
41638
  bootloaderBuildId: getImageBuildId$1((_c = info === null || info === void 0 ? void 0 : info.fw) === null || _c === void 0 ? void 0 : _c.bootloader),
41224
41639
  bootloaderHash: getImageHash$1((_d = info === null || info === void 0 ? void 0 : info.fw) === null || _d === void 0 ? void 0 : _d.bootloader),
41225
- boardBuildId: getImageBuildId$1((_f = (_e = info === null || info === void 0 ? void 0 : info.fw) === null || _e === void 0 ? void 0 : _e.application_data) !== null && _f !== void 0 ? _f : (_g = info === null || info === void 0 ? void 0 : info.fw) === null || _g === void 0 ? void 0 : _g.romloader),
41226
- boardHash: getImageHash$1((_j = (_h = info === null || info === void 0 ? void 0 : info.fw) === null || _h === void 0 ? void 0 : _h.application_data) !== null && _j !== void 0 ? _j : (_k = info === null || info === void 0 ? void 0 : info.fw) === null || _k === void 0 ? void 0 : _k.romloader),
41227
- bleBuildId: getImageBuildId$1((_l = info === null || info === void 0 ? void 0 : info.coprocessor) === null || _l === void 0 ? void 0 : _l.application),
41228
- bleHash: getImageHash$1((_m = info === null || info === void 0 ? void 0 : info.coprocessor) === null || _m === void 0 ? void 0 : _m.application),
41229
- se01BuildId: getImageBuildId$1((_o = info === null || info === void 0 ? void 0 : info.se1) === null || _o === void 0 ? void 0 : _o.application),
41230
- se01Hash: getImageHash$1((_p = info === null || info === void 0 ? void 0 : info.se1) === null || _p === void 0 ? void 0 : _p.application),
41231
- se02BuildId: getImageBuildId$1((_q = info === null || info === void 0 ? void 0 : info.se2) === null || _q === void 0 ? void 0 : _q.application),
41232
- se02Hash: getImageHash$1((_r = info === null || info === void 0 ? void 0 : info.se2) === null || _r === void 0 ? void 0 : _r.application),
41233
- se03BuildId: getImageBuildId$1((_s = info === null || info === void 0 ? void 0 : info.se3) === null || _s === void 0 ? void 0 : _s.application),
41234
- se03Hash: getImageHash$1((_t = info === null || info === void 0 ? void 0 : info.se3) === null || _t === void 0 ? void 0 : _t.application),
41235
- se04BuildId: getImageBuildId$1((_u = info === null || info === void 0 ? void 0 : info.se4) === null || _u === void 0 ? void 0 : _u.application),
41236
- se04Hash: getImageHash$1((_v = info === null || info === void 0 ? void 0 : info.se4) === null || _v === void 0 ? void 0 : _v.application),
41237
- se01BootBuildId: getImageBuildId$1((_w = info === null || info === void 0 ? void 0 : info.se1) === null || _w === void 0 ? void 0 : _w.bootloader),
41238
- se01BootHash: getImageHash$1((_x = info === null || info === void 0 ? void 0 : info.se1) === null || _x === void 0 ? void 0 : _x.bootloader),
41239
- se02BootBuildId: getImageBuildId$1((_y = info === null || info === void 0 ? void 0 : info.se2) === null || _y === void 0 ? void 0 : _y.bootloader),
41240
- se02BootHash: getImageHash$1((_z = info === null || info === void 0 ? void 0 : info.se2) === null || _z === void 0 ? void 0 : _z.bootloader),
41241
- se03BootBuildId: getImageBuildId$1((_0 = info === null || info === void 0 ? void 0 : info.se3) === null || _0 === void 0 ? void 0 : _0.bootloader),
41242
- se03BootHash: getImageHash$1((_1 = info === null || info === void 0 ? void 0 : info.se3) === null || _1 === void 0 ? void 0 : _1.bootloader),
41243
- se04BootBuildId: getImageBuildId$1((_2 = info === null || info === void 0 ? void 0 : info.se4) === null || _2 === void 0 ? void 0 : _2.bootloader),
41244
- se04BootHash: getImageHash$1((_3 = info === null || info === void 0 ? void 0 : info.se4) === null || _3 === void 0 ? void 0 : _3.bootloader),
41640
+ boardBuildId: getImageBuildId$1((_e = info === null || info === void 0 ? void 0 : info.fw) === null || _e === void 0 ? void 0 : _e.romloader),
41641
+ boardHash: getImageHash$1((_f = info === null || info === void 0 ? void 0 : info.fw) === null || _f === void 0 ? void 0 : _f.romloader),
41642
+ bleBuildId: getImageBuildId$1((_g = info === null || info === void 0 ? void 0 : info.coprocessor) === null || _g === void 0 ? void 0 : _g.application),
41643
+ bleHash: getImageHash$1((_h = info === null || info === void 0 ? void 0 : info.coprocessor) === null || _h === void 0 ? void 0 : _h.application),
41644
+ se01BuildId: getImageBuildId$1((_j = info === null || info === void 0 ? void 0 : info.se1) === null || _j === void 0 ? void 0 : _j.application),
41645
+ se01Hash: getImageHash$1((_k = info === null || info === void 0 ? void 0 : info.se1) === null || _k === void 0 ? void 0 : _k.application),
41646
+ se02BuildId: getImageBuildId$1((_l = info === null || info === void 0 ? void 0 : info.se2) === null || _l === void 0 ? void 0 : _l.application),
41647
+ se02Hash: getImageHash$1((_m = info === null || info === void 0 ? void 0 : info.se2) === null || _m === void 0 ? void 0 : _m.application),
41648
+ se03BuildId: getImageBuildId$1((_o = info === null || info === void 0 ? void 0 : info.se3) === null || _o === void 0 ? void 0 : _o.application),
41649
+ se03Hash: getImageHash$1((_p = info === null || info === void 0 ? void 0 : info.se3) === null || _p === void 0 ? void 0 : _p.application),
41650
+ se04BuildId: getImageBuildId$1((_q = info === null || info === void 0 ? void 0 : info.se4) === null || _q === void 0 ? void 0 : _q.application),
41651
+ se04Hash: getImageHash$1((_r = info === null || info === void 0 ? void 0 : info.se4) === null || _r === void 0 ? void 0 : _r.application),
41652
+ se01BootBuildId: getImageBuildId$1((_s = info === null || info === void 0 ? void 0 : info.se1) === null || _s === void 0 ? void 0 : _s.bootloader),
41653
+ se01BootHash: getImageHash$1((_t = info === null || info === void 0 ? void 0 : info.se1) === null || _t === void 0 ? void 0 : _t.bootloader),
41654
+ se02BootBuildId: getImageBuildId$1((_u = info === null || info === void 0 ? void 0 : info.se2) === null || _u === void 0 ? void 0 : _u.bootloader),
41655
+ se02BootHash: getImageHash$1((_v = info === null || info === void 0 ? void 0 : info.se2) === null || _v === void 0 ? void 0 : _v.bootloader),
41656
+ se03BootBuildId: getImageBuildId$1((_w = info === null || info === void 0 ? void 0 : info.se3) === null || _w === void 0 ? void 0 : _w.bootloader),
41657
+ se03BootHash: getImageHash$1((_x = info === null || info === void 0 ? void 0 : info.se3) === null || _x === void 0 ? void 0 : _x.bootloader),
41658
+ se04BootBuildId: getImageBuildId$1((_y = info === null || info === void 0 ? void 0 : info.se4) === null || _y === void 0 ? void 0 : _y.bootloader),
41659
+ se04BootHash: getImageHash$1((_z = info === null || info === void 0 ? void 0 : info.se4) === null || _z === void 0 ? void 0 : _z.bootloader),
41245
41660
  };
41246
41661
  };
41247
41662
  const normalizeRaw = ({ features, protocolV1OneKeyFeatures, protocolV2DeviceInfo, }) => (Object.assign(Object.assign(Object.assign({}, (features ? { features } : {})), (protocolV1OneKeyFeatures ? { protocolV1OneKeyFeatures } : {})), (protocolV2DeviceInfo ? { protocolV2DeviceInfo } : {})));
@@ -41375,53 +41790,10 @@ const buildProtocolV1FeaturesPayload = (protocolV1Features, previous) => {
41375
41790
  const bleName = features.onekey_ble_name || features.ble_name || null;
41376
41791
  const deviceType = getProtocolV1DeviceType(features);
41377
41792
  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;
41378
- return {
41379
- protocol: 'V1',
41380
- 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,
41381
- deviceType,
41382
- firmwareType: getProtocolV1FirmwareType(features),
41383
- model: (_e = features.model) !== null && _e !== void 0 ? _e : null,
41384
- vendor: (_f = features.vendor) !== null && _f !== void 0 ? _f : null,
41385
- deviceId: (_g = features.device_id) !== null && _g !== void 0 ? _g : null,
41386
- serialNo,
41387
- label: getProtocolV1Label(features, deviceType, bleName),
41388
- bleName,
41389
- capabilities: (_h = features.capabilities) !== null && _h !== void 0 ? _h : [],
41390
- mode: getProtocolV1Mode(features),
41391
- initialized: (_j = features.initialized) !== null && _j !== void 0 ? _j : null,
41392
- bootloaderMode: (_k = features.bootloader_mode) !== null && _k !== void 0 ? _k : null,
41393
- unlocked: (_l = features.unlocked) !== null && _l !== void 0 ? _l : true,
41394
- firmwarePresent: (_m = features.firmware_present) !== null && _m !== void 0 ? _m : null,
41395
- passphraseProtection: (_o = features.passphrase_protection) !== null && _o !== void 0 ? _o : null,
41396
- pinProtection: (_p = features.pin_protection) !== null && _p !== void 0 ? _p : null,
41397
- backupRequired: (_q = features.needs_backup) !== null && _q !== void 0 ? _q : null,
41398
- noBackup: (_r = features.no_backup) !== null && _r !== void 0 ? _r : null,
41399
- unfinishedBackup: (_s = features.unfinished_backup) !== null && _s !== void 0 ? _s : null,
41400
- recoveryMode: (_t = features.recovery_mode) !== null && _t !== void 0 ? _t : null,
41401
- language: (_u = features.language) !== null && _u !== void 0 ? _u : null,
41402
- bleEnabled: (_v = features.ble_enable) !== null && _v !== void 0 ? _v : null,
41403
- sdCardPresent: (_w = features.sd_card_present) !== null && _w !== void 0 ? _w : null,
41404
- sdProtection: (_x = features.sd_protection) !== null && _x !== void 0 ? _x : null,
41405
- wipeCodeProtection: (_y = features.wipe_code_protection) !== null && _y !== void 0 ? _y : null,
41406
- passphraseAlwaysOnDevice: (_z = features.passphrase_always_on_device) !== null && _z !== void 0 ? _z : null,
41407
- safetyChecks: (_0 = features.safety_checks) !== null && _0 !== void 0 ? _0 : null,
41408
- autoLockDelayMs: (_1 = features.auto_lock_delay_ms) !== null && _1 !== void 0 ? _1 : null,
41409
- displayRotation: (_2 = features.display_rotation) !== null && _2 !== void 0 ? _2 : null,
41410
- experimentalFeatures: (_3 = features.experimental_features) !== null && _3 !== void 0 ? _3 : null,
41411
- firmwareVersion,
41793
+ return Object.assign(Object.assign({}, features), { protocol: 'V1', 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, deviceType, firmwareType: getProtocolV1FirmwareType(features), model: (_e = features.model) !== null && _e !== void 0 ? _e : null, vendor: (_f = features.vendor) !== null && _f !== void 0 ? _f : null, deviceId: (_g = features.device_id) !== null && _g !== void 0 ? _g : null, serialNo, label: getProtocolV1Label(features, deviceType, bleName), bleName, capabilities: (_h = features.capabilities) !== null && _h !== void 0 ? _h : [], mode: getProtocolV1Mode(features), initialized: (_j = features.initialized) !== null && _j !== void 0 ? _j : null, bootloaderMode: (_k = features.bootloader_mode) !== null && _k !== void 0 ? _k : null, unlocked: (_l = features.unlocked) !== null && _l !== void 0 ? _l : true, firmwarePresent: (_m = features.firmware_present) !== null && _m !== void 0 ? _m : null, passphraseProtection: (_o = features.passphrase_protection) !== null && _o !== void 0 ? _o : null, pinProtection: (_p = features.pin_protection) !== null && _p !== void 0 ? _p : null, backupRequired: (_q = features.needs_backup) !== null && _q !== void 0 ? _q : null, noBackup: (_r = features.no_backup) !== null && _r !== void 0 ? _r : null, unfinishedBackup: (_s = features.unfinished_backup) !== null && _s !== void 0 ? _s : null, recoveryMode: (_t = features.recovery_mode) !== null && _t !== void 0 ? _t : null, language: (_u = features.language) !== null && _u !== void 0 ? _u : null, bleEnabled: (_v = features.ble_enable) !== null && _v !== void 0 ? _v : null, sdCardPresent: (_w = features.sd_card_present) !== null && _w !== void 0 ? _w : null, sdProtection: (_x = features.sd_protection) !== null && _x !== void 0 ? _x : null, wipeCodeProtection: (_y = features.wipe_code_protection) !== null && _y !== void 0 ? _y : null, passphraseAlwaysOnDevice: (_z = features.passphrase_always_on_device) !== null && _z !== void 0 ? _z : null, safetyChecks: (_0 = features.safety_checks) !== null && _0 !== void 0 ? _0 : null, autoLockDelayMs: (_1 = features.auto_lock_delay_ms) !== null && _1 !== void 0 ? _1 : null, displayRotation: (_2 = features.display_rotation) !== null && _2 !== void 0 ? _2 : null, experimentalFeatures: (_3 = features.experimental_features) !== null && _3 !== void 0 ? _3 : null, firmwareVersion,
41412
41794
  bootloaderVersion,
41413
41795
  boardVersion,
41414
- bleVersion,
41415
- se01Version: firstMeaningfulVersion(features.onekey_se01_version),
41416
- se02Version: firstMeaningfulVersion(features.onekey_se02_version),
41417
- se03Version: firstMeaningfulVersion(features.onekey_se03_version),
41418
- se04Version: firstMeaningfulVersion(features.onekey_se04_version),
41419
- se01BootVersion: firstMeaningfulVersion(features.onekey_se01_boot_version),
41420
- se02BootVersion: firstMeaningfulVersion(features.onekey_se02_boot_version),
41421
- se03BootVersion: firstMeaningfulVersion(features.onekey_se03_boot_version),
41422
- se04BootVersion: firstMeaningfulVersion(features.onekey_se04_boot_version),
41423
- seVersion: (_4 = features.se_ver) !== null && _4 !== void 0 ? _4 : null,
41424
- verify: {
41796
+ bleVersion, se01Version: firstMeaningfulVersion(features.onekey_se01_version), se02Version: firstMeaningfulVersion(features.onekey_se02_version), se03Version: firstMeaningfulVersion(features.onekey_se03_version), se04Version: firstMeaningfulVersion(features.onekey_se04_version), se01BootVersion: firstMeaningfulVersion(features.onekey_se01_boot_version), se02BootVersion: firstMeaningfulVersion(features.onekey_se02_boot_version), se03BootVersion: firstMeaningfulVersion(features.onekey_se03_boot_version), se04BootVersion: firstMeaningfulVersion(features.onekey_se04_boot_version), seVersion: (_4 = features.se_ver) !== null && _4 !== void 0 ? _4 : null, verify: {
41425
41797
  firmwareBuildId: features.onekey_firmware_build_id,
41426
41798
  firmwareHash: features.onekey_firmware_hash,
41427
41799
  bootloaderBuildId: features.onekey_boot_build_id,
@@ -41446,50 +41818,54 @@ const buildProtocolV1FeaturesPayload = (protocolV1Features, previous) => {
41446
41818
  se03BootHash: features.onekey_se03_boot_hash,
41447
41819
  se04BootBuildId: features.onekey_se04_boot_build_id,
41448
41820
  se04BootHash: features.onekey_se04_boot_hash,
41449
- },
41450
- sessionId,
41451
- raw: {
41452
- protocolV1Features: protocolV1Features,
41453
- },
41454
- };
41821
+ }, sessionId, session_id: sessionId !== null && sessionId !== void 0 ? sessionId : undefined, raw: {
41822
+ protocolV1Features,
41823
+ } });
41455
41824
  };
41456
41825
  const buildProtocolV2FeaturesPayload = (deviceInfo, previous) => {
41457
41826
  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;
41458
41827
  const info = deviceInfo;
41459
41828
  const fwApplication = (_a = info === null || info === void 0 ? void 0 : info.fw) === null || _a === void 0 ? void 0 : _a.application;
41460
41829
  const fwBootloader = (_b = info === null || info === void 0 ? void 0 : info.fw) === null || _b === void 0 ? void 0 : _b.bootloader;
41461
- const fwBoard = firstValue((_c = info === null || info === void 0 ? void 0 : info.fw) === null || _c === void 0 ? void 0 : _c.application_data, (_d = info === null || info === void 0 ? void 0 : info.fw) === null || _d === void 0 ? void 0 : _d.romloader);
41462
- const bleApplication = (_e = info === null || info === void 0 ? void 0 : info.coprocessor) === null || _e === void 0 ? void 0 : _e.application;
41830
+ const fwBoard = (_c = info === null || info === void 0 ? void 0 : info.fw) === null || _c === void 0 ? void 0 : _c.romloader;
41831
+ const bleApplication = (_d = info === null || info === void 0 ? void 0 : info.coprocessor) === null || _d === void 0 ? void 0 : _d.application;
41463
41832
  const status = info === null || info === void 0 ? void 0 : info.status;
41464
41833
  const firmwareVersion = firstMeaningfulVersion(getImageVersion(fwApplication), previous === null || previous === void 0 ? void 0 : previous.firmwareVersion);
41465
41834
  const bootloaderVersion = firstMeaningfulVersion(getImageVersion(fwBootloader), previous === null || previous === void 0 ? void 0 : previous.bootloaderVersion);
41466
41835
  const boardVersion = firstMeaningfulVersion(getImageVersion(fwBoard), previous === null || previous === void 0 ? void 0 : previous.boardVersion);
41467
41836
  const bleVersion = firstMeaningfulVersion(getImageVersion(bleApplication), previous === null || previous === void 0 ? void 0 : previous.bleVersion);
41468
- const deviceId = (_f = status === null || status === void 0 ? void 0 : status.device_id) !== null && _f !== void 0 ? _f : null;
41469
- const serialNo = (_h = firstValue((_g = info === null || info === void 0 ? void 0 : info.hw) === null || _g === void 0 ? void 0 : _g.serial_no, previous === null || previous === void 0 ? void 0 : previous.serialNo)) !== null && _h !== void 0 ? _h : '';
41470
- const label = (_j = previous === null || previous === void 0 ? void 0 : previous.label) !== null && _j !== void 0 ? _j : null;
41471
- const bleName = firstValue((_k = info === null || info === void 0 ? void 0 : info.coprocessor) === null || _k === void 0 ? void 0 : _k.bt_adv_name, previous === null || previous === void 0 ? void 0 : previous.bleName);
41472
- const initialized = (_l = firstValue(status === null || status === void 0 ? void 0 : status.init_states, previous === null || previous === void 0 ? void 0 : previous.initialized)) !== null && _l !== void 0 ? _l : null;
41473
- const passphraseProtection = (_m = status === null || status === void 0 ? void 0 : status.passphrase_enabled) !== null && _m !== void 0 ? _m : null;
41474
- const language = (_o = previous === null || previous === void 0 ? void 0 : previous.language) !== null && _o !== void 0 ? _o : null;
41475
- const backupRequired = (_p = firstValue(status === null || status === void 0 ? void 0 : status.backup_required, previous === null || previous === void 0 ? void 0 : previous.backupRequired)) !== null && _p !== void 0 ? _p : null;
41837
+ const deviceId = (_e = status === null || status === void 0 ? void 0 : status.device_id) !== null && _e !== void 0 ? _e : null;
41838
+ const serialNo = (_g = firstValue((_f = info === null || info === void 0 ? void 0 : info.hw) === null || _f === void 0 ? void 0 : _f.serial_no, previous === null || previous === void 0 ? void 0 : previous.serialNo)) !== null && _g !== void 0 ? _g : '';
41839
+ const label = (_h = previous === null || previous === void 0 ? void 0 : previous.label) !== null && _h !== void 0 ? _h : null;
41840
+ const bleName = firstValue((_j = info === null || info === void 0 ? void 0 : info.coprocessor) === null || _j === void 0 ? void 0 : _j.bt_adv_name, previous === null || previous === void 0 ? void 0 : previous.bleName);
41841
+ const initialized = (_k = firstValue(status === null || status === void 0 ? void 0 : status.init_states, previous === null || previous === void 0 ? void 0 : previous.initialized)) !== null && _k !== void 0 ? _k : null;
41842
+ const passphraseProtection = (_l = status === null || status === void 0 ? void 0 : status.passphrase_enabled) !== null && _l !== void 0 ? _l : null;
41843
+ const language = (_m = previous === null || previous === void 0 ? void 0 : previous.language) !== null && _m !== void 0 ? _m : null;
41844
+ const backupRequired = (_o = firstValue(status === null || status === void 0 ? void 0 : status.backup_required, previous === null || previous === void 0 ? void 0 : previous.backupRequired)) !== null && _o !== void 0 ? _o : null;
41476
41845
  const bleEnabled = previous === null || previous === void 0 ? void 0 : previous.bleEnabled;
41477
- const unlocked = (_q = firstValue(status === null || status === void 0 ? void 0 : status.unlocked, previous === null || previous === void 0 ? void 0 : previous.unlocked)) !== null && _q !== void 0 ? _q : null;
41478
- const attachToPinEnabled = (_r = status === null || status === void 0 ? void 0 : status.attach_to_pin_enabled) !== null && _r !== void 0 ? _r : null;
41479
- const unlockedAttachPin = (_s = status === null || status === void 0 ? void 0 : status.unlocked_by_attach_to_pin) !== null && _s !== void 0 ? _s : undefined;
41846
+ const unlocked = (_p = firstValue(status === null || status === void 0 ? void 0 : status.unlocked, previous === null || previous === void 0 ? void 0 : previous.unlocked)) !== null && _p !== void 0 ? _p : null;
41847
+ const attachToPinEnabled = (_q = status === null || status === void 0 ? void 0 : status.attach_to_pin_enabled) !== null && _q !== void 0 ? _q : null;
41848
+ const unlockedAttachPin = (_r = status === null || status === void 0 ? void 0 : status.unlocked_by_attach_to_pin) !== null && _r !== void 0 ? _r : undefined;
41849
+ const romloaderMode = isProtocolV2RomloaderDeviceInfo(info);
41480
41850
  const bootloaderMode = isProtocolV2BootloaderDeviceInfo(info);
41481
- const mode = bootloaderMode
41482
- ? 'bootloader'
41483
- : initialized === false
41484
- ? 'notInitialized'
41485
- : initialized === true
41486
- ? 'normal'
41487
- : 'unknown';
41851
+ let mode = 'unknown';
41852
+ if (romloaderMode) {
41853
+ mode = 'romloader';
41854
+ }
41855
+ else if (bootloaderMode) {
41856
+ mode = 'bootloader';
41857
+ }
41858
+ else if (initialized === false) {
41859
+ mode = 'notInitialized';
41860
+ }
41861
+ else if (initialized === true) {
41862
+ mode = 'normal';
41863
+ }
41488
41864
  return {
41489
41865
  protocol: 'V2',
41490
- protocolVersion: (_u = (_t = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.protocol_version) !== null && _t !== void 0 ? _t : previous === null || previous === void 0 ? void 0 : previous.protocolVersion) !== null && _u !== void 0 ? _u : null,
41866
+ protocolVersion: (_t = (_s = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.protocol_version) !== null && _s !== void 0 ? _s : previous === null || previous === void 0 ? void 0 : previous.protocolVersion) !== null && _t !== void 0 ? _t : null,
41491
41867
  deviceType: hdShared.EDeviceType.Pro2,
41492
- firmwareType: (_v = previous === null || previous === void 0 ? void 0 : previous.firmwareType) !== null && _v !== void 0 ? _v : hdShared.EFirmwareType.Universal,
41868
+ firmwareType: (_u = previous === null || previous === void 0 ? void 0 : previous.firmwareType) !== null && _u !== void 0 ? _u : hdShared.EFirmwareType.Universal,
41493
41869
  model: 'pro2',
41494
41870
  vendor: 'onekey.so',
41495
41871
  deviceId,
@@ -41501,7 +41877,7 @@ const buildProtocolV2FeaturesPayload = (deviceInfo, previous) => {
41501
41877
  initialized,
41502
41878
  bootloaderMode,
41503
41879
  unlocked,
41504
- firmwarePresent: (_w = previous === null || previous === void 0 ? void 0 : previous.firmwarePresent) !== null && _w !== void 0 ? _w : null,
41880
+ firmwarePresent: (_v = previous === null || previous === void 0 ? void 0 : previous.firmwarePresent) !== null && _v !== void 0 ? _v : null,
41505
41881
  passphraseProtection,
41506
41882
  pinProtection: null,
41507
41883
  backupRequired,
@@ -41523,42 +41899,48 @@ const buildProtocolV2FeaturesPayload = (deviceInfo, previous) => {
41523
41899
  bootloaderVersion,
41524
41900
  boardVersion,
41525
41901
  bleVersion,
41526
- se01Version: firstMeaningfulVersion(getImageVersion((_x = info === null || info === void 0 ? void 0 : info.se1) === null || _x === void 0 ? void 0 : _x.application), previous === null || previous === void 0 ? void 0 : previous.se01Version),
41527
- se02Version: firstMeaningfulVersion(getImageVersion((_y = info === null || info === void 0 ? void 0 : info.se2) === null || _y === void 0 ? void 0 : _y.application), previous === null || previous === void 0 ? void 0 : previous.se02Version),
41528
- se03Version: firstMeaningfulVersion(getImageVersion((_z = info === null || info === void 0 ? void 0 : info.se3) === null || _z === void 0 ? void 0 : _z.application), previous === null || previous === void 0 ? void 0 : previous.se03Version),
41529
- se04Version: firstMeaningfulVersion(getImageVersion((_0 = info === null || info === void 0 ? void 0 : info.se4) === null || _0 === void 0 ? void 0 : _0.application), previous === null || previous === void 0 ? void 0 : previous.se04Version),
41530
- se01BootVersion: firstMeaningfulVersion(getImageVersion((_1 = info === null || info === void 0 ? void 0 : info.se1) === null || _1 === void 0 ? void 0 : _1.bootloader), previous === null || previous === void 0 ? void 0 : previous.se01BootVersion),
41531
- se02BootVersion: firstMeaningfulVersion(getImageVersion((_2 = info === null || info === void 0 ? void 0 : info.se2) === null || _2 === void 0 ? void 0 : _2.bootloader), previous === null || previous === void 0 ? void 0 : previous.se02BootVersion),
41532
- se03BootVersion: firstMeaningfulVersion(getImageVersion((_3 = info === null || info === void 0 ? void 0 : info.se3) === null || _3 === void 0 ? void 0 : _3.bootloader), previous === null || previous === void 0 ? void 0 : previous.se03BootVersion),
41533
- se04BootVersion: firstMeaningfulVersion(getImageVersion((_4 = info === null || info === void 0 ? void 0 : info.se4) === null || _4 === void 0 ? void 0 : _4.bootloader), previous === null || previous === void 0 ? void 0 : previous.se04BootVersion),
41534
- seVersion: (_5 = previous === null || previous === void 0 ? void 0 : previous.seVersion) !== null && _5 !== void 0 ? _5 : null,
41902
+ se01Version: firstMeaningfulVersion(getImageVersion((_w = info === null || info === void 0 ? void 0 : info.se1) === null || _w === void 0 ? void 0 : _w.application), previous === null || previous === void 0 ? void 0 : previous.se01Version),
41903
+ se02Version: firstMeaningfulVersion(getImageVersion((_x = info === null || info === void 0 ? void 0 : info.se2) === null || _x === void 0 ? void 0 : _x.application), previous === null || previous === void 0 ? void 0 : previous.se02Version),
41904
+ se03Version: firstMeaningfulVersion(getImageVersion((_y = info === null || info === void 0 ? void 0 : info.se3) === null || _y === void 0 ? void 0 : _y.application), previous === null || previous === void 0 ? void 0 : previous.se03Version),
41905
+ se04Version: firstMeaningfulVersion(getImageVersion((_z = info === null || info === void 0 ? void 0 : info.se4) === null || _z === void 0 ? void 0 : _z.application), previous === null || previous === void 0 ? void 0 : previous.se04Version),
41906
+ se01BootVersion: firstMeaningfulVersion(getImageVersion((_0 = info === null || info === void 0 ? void 0 : info.se1) === null || _0 === void 0 ? void 0 : _0.bootloader), previous === null || previous === void 0 ? void 0 : previous.se01BootVersion),
41907
+ se02BootVersion: firstMeaningfulVersion(getImageVersion((_1 = info === null || info === void 0 ? void 0 : info.se2) === null || _1 === void 0 ? void 0 : _1.bootloader), previous === null || previous === void 0 ? void 0 : previous.se02BootVersion),
41908
+ se03BootVersion: firstMeaningfulVersion(getImageVersion((_2 = info === null || info === void 0 ? void 0 : info.se3) === null || _2 === void 0 ? void 0 : _2.bootloader), previous === null || previous === void 0 ? void 0 : previous.se03BootVersion),
41909
+ se04BootVersion: firstMeaningfulVersion(getImageVersion((_3 = info === null || info === void 0 ? void 0 : info.se4) === null || _3 === void 0 ? void 0 : _3.bootloader), previous === null || previous === void 0 ? void 0 : previous.se04BootVersion),
41910
+ seVersion: (_4 = previous === null || previous === void 0 ? void 0 : previous.seVersion) !== null && _4 !== void 0 ? _4 : null,
41535
41911
  verify: {
41536
- firmwareBuildId: (_6 = getImageBuildId(fwApplication)) !== null && _6 !== void 0 ? _6 : (_7 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _7 === void 0 ? void 0 : _7.firmwareBuildId,
41537
- firmwareHash: (_8 = getImageHash(fwApplication)) !== null && _8 !== void 0 ? _8 : (_9 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _9 === void 0 ? void 0 : _9.firmwareHash,
41538
- bootloaderBuildId: (_10 = getImageBuildId(fwBootloader)) !== null && _10 !== void 0 ? _10 : (_11 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _11 === void 0 ? void 0 : _11.bootloaderBuildId,
41539
- bootloaderHash: (_12 = getImageHash(fwBootloader)) !== null && _12 !== void 0 ? _12 : (_13 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _13 === void 0 ? void 0 : _13.bootloaderHash,
41540
- boardBuildId: (_14 = getImageBuildId(fwBoard)) !== null && _14 !== void 0 ? _14 : (_15 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _15 === void 0 ? void 0 : _15.boardBuildId,
41541
- boardHash: (_16 = getImageHash(fwBoard)) !== null && _16 !== void 0 ? _16 : (_17 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _17 === void 0 ? void 0 : _17.boardHash,
41542
- bleBuildId: (_18 = getImageBuildId(bleApplication)) !== null && _18 !== void 0 ? _18 : (_19 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _19 === void 0 ? void 0 : _19.bleBuildId,
41543
- bleHash: (_20 = getImageHash(bleApplication)) !== null && _20 !== void 0 ? _20 : (_21 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _21 === void 0 ? void 0 : _21.bleHash,
41544
- se01BuildId: (_23 = getImageBuildId((_22 = info === null || info === void 0 ? void 0 : info.se1) === null || _22 === void 0 ? void 0 : _22.application)) !== null && _23 !== void 0 ? _23 : (_24 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _24 === void 0 ? void 0 : _24.se01BuildId,
41545
- se01Hash: (_26 = getImageHash((_25 = info === null || info === void 0 ? void 0 : info.se1) === null || _25 === void 0 ? void 0 : _25.application)) !== null && _26 !== void 0 ? _26 : (_27 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _27 === void 0 ? void 0 : _27.se01Hash,
41546
- se02BuildId: (_29 = getImageBuildId((_28 = info === null || info === void 0 ? void 0 : info.se2) === null || _28 === void 0 ? void 0 : _28.application)) !== null && _29 !== void 0 ? _29 : (_30 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _30 === void 0 ? void 0 : _30.se02BuildId,
41547
- se02Hash: (_32 = getImageHash((_31 = info === null || info === void 0 ? void 0 : info.se2) === null || _31 === void 0 ? void 0 : _31.application)) !== null && _32 !== void 0 ? _32 : (_33 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _33 === void 0 ? void 0 : _33.se02Hash,
41548
- se03BuildId: (_35 = getImageBuildId((_34 = info === null || info === void 0 ? void 0 : info.se3) === null || _34 === void 0 ? void 0 : _34.application)) !== null && _35 !== void 0 ? _35 : (_36 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _36 === void 0 ? void 0 : _36.se03BuildId,
41549
- se03Hash: (_38 = getImageHash((_37 = info === null || info === void 0 ? void 0 : info.se3) === null || _37 === void 0 ? void 0 : _37.application)) !== null && _38 !== void 0 ? _38 : (_39 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _39 === void 0 ? void 0 : _39.se03Hash,
41550
- se04BuildId: (_41 = getImageBuildId((_40 = info === null || info === void 0 ? void 0 : info.se4) === null || _40 === void 0 ? void 0 : _40.application)) !== null && _41 !== void 0 ? _41 : (_42 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _42 === void 0 ? void 0 : _42.se04BuildId,
41551
- se04Hash: (_44 = getImageHash((_43 = info === null || info === void 0 ? void 0 : info.se4) === null || _43 === void 0 ? void 0 : _43.application)) !== null && _44 !== void 0 ? _44 : (_45 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _45 === void 0 ? void 0 : _45.se04Hash,
41552
- se01BootBuildId: (_47 = getImageBuildId((_46 = info === null || info === void 0 ? void 0 : info.se1) === null || _46 === void 0 ? void 0 : _46.bootloader)) !== null && _47 !== void 0 ? _47 : (_48 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _48 === void 0 ? void 0 : _48.se01BootBuildId,
41553
- se01BootHash: (_50 = getImageHash((_49 = info === null || info === void 0 ? void 0 : info.se1) === null || _49 === void 0 ? void 0 : _49.bootloader)) !== null && _50 !== void 0 ? _50 : (_51 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _51 === void 0 ? void 0 : _51.se01BootHash,
41554
- se02BootBuildId: (_53 = getImageBuildId((_52 = info === null || info === void 0 ? void 0 : info.se2) === null || _52 === void 0 ? void 0 : _52.bootloader)) !== null && _53 !== void 0 ? _53 : (_54 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _54 === void 0 ? void 0 : _54.se02BootBuildId,
41555
- se02BootHash: (_56 = getImageHash((_55 = info === null || info === void 0 ? void 0 : info.se2) === null || _55 === void 0 ? void 0 : _55.bootloader)) !== null && _56 !== void 0 ? _56 : (_57 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _57 === void 0 ? void 0 : _57.se02BootHash,
41556
- se03BootBuildId: (_59 = getImageBuildId((_58 = info === null || info === void 0 ? void 0 : info.se3) === null || _58 === void 0 ? void 0 : _58.bootloader)) !== null && _59 !== void 0 ? _59 : (_60 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _60 === void 0 ? void 0 : _60.se03BootBuildId,
41557
- se03BootHash: (_62 = getImageHash((_61 = info === null || info === void 0 ? void 0 : info.se3) === null || _61 === void 0 ? void 0 : _61.bootloader)) !== null && _62 !== void 0 ? _62 : (_63 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _63 === void 0 ? void 0 : _63.se03BootHash,
41558
- se04BootBuildId: (_65 = getImageBuildId((_64 = info === null || info === void 0 ? void 0 : info.se4) === null || _64 === void 0 ? void 0 : _64.bootloader)) !== null && _65 !== void 0 ? _65 : (_66 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _66 === void 0 ? void 0 : _66.se04BootBuildId,
41559
- se04BootHash: (_68 = getImageHash((_67 = info === null || info === void 0 ? void 0 : info.se4) === null || _67 === void 0 ? void 0 : _67.bootloader)) !== null && _68 !== void 0 ? _68 : (_69 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _69 === void 0 ? void 0 : _69.se04BootHash,
41912
+ firmwareBuildId: (_5 = getImageBuildId(fwApplication)) !== null && _5 !== void 0 ? _5 : (_6 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _6 === void 0 ? void 0 : _6.firmwareBuildId,
41913
+ firmwareHash: (_7 = getImageHash(fwApplication)) !== null && _7 !== void 0 ? _7 : (_8 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _8 === void 0 ? void 0 : _8.firmwareHash,
41914
+ bootloaderBuildId: (_9 = getImageBuildId(fwBootloader)) !== null && _9 !== void 0 ? _9 : (_10 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _10 === void 0 ? void 0 : _10.bootloaderBuildId,
41915
+ bootloaderHash: (_11 = getImageHash(fwBootloader)) !== null && _11 !== void 0 ? _11 : (_12 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _12 === void 0 ? void 0 : _12.bootloaderHash,
41916
+ boardBuildId: (_13 = getImageBuildId(fwBoard)) !== null && _13 !== void 0 ? _13 : (_14 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _14 === void 0 ? void 0 : _14.boardBuildId,
41917
+ boardHash: (_15 = getImageHash(fwBoard)) !== null && _15 !== void 0 ? _15 : (_16 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _16 === void 0 ? void 0 : _16.boardHash,
41918
+ bleBuildId: (_17 = getImageBuildId(bleApplication)) !== null && _17 !== void 0 ? _17 : (_18 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _18 === void 0 ? void 0 : _18.bleBuildId,
41919
+ bleHash: (_19 = getImageHash(bleApplication)) !== null && _19 !== void 0 ? _19 : (_20 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _20 === void 0 ? void 0 : _20.bleHash,
41920
+ se01BuildId: (_22 = getImageBuildId((_21 = info === null || info === void 0 ? void 0 : info.se1) === null || _21 === void 0 ? void 0 : _21.application)) !== null && _22 !== void 0 ? _22 : (_23 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _23 === void 0 ? void 0 : _23.se01BuildId,
41921
+ se01Hash: (_25 = getImageHash((_24 = info === null || info === void 0 ? void 0 : info.se1) === null || _24 === void 0 ? void 0 : _24.application)) !== null && _25 !== void 0 ? _25 : (_26 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _26 === void 0 ? void 0 : _26.se01Hash,
41922
+ se02BuildId: (_28 = getImageBuildId((_27 = info === null || info === void 0 ? void 0 : info.se2) === null || _27 === void 0 ? void 0 : _27.application)) !== null && _28 !== void 0 ? _28 : (_29 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _29 === void 0 ? void 0 : _29.se02BuildId,
41923
+ se02Hash: (_31 = getImageHash((_30 = info === null || info === void 0 ? void 0 : info.se2) === null || _30 === void 0 ? void 0 : _30.application)) !== null && _31 !== void 0 ? _31 : (_32 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _32 === void 0 ? void 0 : _32.se02Hash,
41924
+ se03BuildId: (_34 = getImageBuildId((_33 = info === null || info === void 0 ? void 0 : info.se3) === null || _33 === void 0 ? void 0 : _33.application)) !== null && _34 !== void 0 ? _34 : (_35 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _35 === void 0 ? void 0 : _35.se03BuildId,
41925
+ se03Hash: (_37 = getImageHash((_36 = info === null || info === void 0 ? void 0 : info.se3) === null || _36 === void 0 ? void 0 : _36.application)) !== null && _37 !== void 0 ? _37 : (_38 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _38 === void 0 ? void 0 : _38.se03Hash,
41926
+ se04BuildId: (_40 = getImageBuildId((_39 = info === null || info === void 0 ? void 0 : info.se4) === null || _39 === void 0 ? void 0 : _39.application)) !== null && _40 !== void 0 ? _40 : (_41 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _41 === void 0 ? void 0 : _41.se04BuildId,
41927
+ se04Hash: (_43 = getImageHash((_42 = info === null || info === void 0 ? void 0 : info.se4) === null || _42 === void 0 ? void 0 : _42.application)) !== null && _43 !== void 0 ? _43 : (_44 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _44 === void 0 ? void 0 : _44.se04Hash,
41928
+ se01BootBuildId: (_46 = getImageBuildId((_45 = info === null || info === void 0 ? void 0 : info.se1) === null || _45 === void 0 ? void 0 : _45.bootloader)) !== null && _46 !== void 0 ? _46 : (_47 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _47 === void 0 ? void 0 : _47.se01BootBuildId,
41929
+ se01BootHash: (_49 = getImageHash((_48 = info === null || info === void 0 ? void 0 : info.se1) === null || _48 === void 0 ? void 0 : _48.bootloader)) !== null && _49 !== void 0 ? _49 : (_50 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _50 === void 0 ? void 0 : _50.se01BootHash,
41930
+ se02BootBuildId: (_52 = getImageBuildId((_51 = info === null || info === void 0 ? void 0 : info.se2) === null || _51 === void 0 ? void 0 : _51.bootloader)) !== null && _52 !== void 0 ? _52 : (_53 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _53 === void 0 ? void 0 : _53.se02BootBuildId,
41931
+ se02BootHash: (_55 = getImageHash((_54 = info === null || info === void 0 ? void 0 : info.se2) === null || _54 === void 0 ? void 0 : _54.bootloader)) !== null && _55 !== void 0 ? _55 : (_56 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _56 === void 0 ? void 0 : _56.se02BootHash,
41932
+ se03BootBuildId: (_58 = getImageBuildId((_57 = info === null || info === void 0 ? void 0 : info.se3) === null || _57 === void 0 ? void 0 : _57.bootloader)) !== null && _58 !== void 0 ? _58 : (_59 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _59 === void 0 ? void 0 : _59.se03BootBuildId,
41933
+ se03BootHash: (_61 = getImageHash((_60 = info === null || info === void 0 ? void 0 : info.se3) === null || _60 === void 0 ? void 0 : _60.bootloader)) !== null && _61 !== void 0 ? _61 : (_62 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _62 === void 0 ? void 0 : _62.se03BootHash,
41934
+ se04BootBuildId: (_64 = getImageBuildId((_63 = info === null || info === void 0 ? void 0 : info.se4) === null || _63 === void 0 ? void 0 : _63.bootloader)) !== null && _64 !== void 0 ? _64 : (_65 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _65 === void 0 ? void 0 : _65.se04BootBuildId,
41935
+ se04BootHash: (_67 = getImageHash((_66 = info === null || info === void 0 ? void 0 : info.se4) === null || _66 === void 0 ? void 0 : _66.bootloader)) !== null && _67 !== void 0 ? _67 : (_68 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _68 === void 0 ? void 0 : _68.se04BootHash,
41560
41936
  },
41561
- sessionId: (_70 = previous === null || previous === void 0 ? void 0 : previous.sessionId) !== null && _70 !== void 0 ? _70 : null,
41937
+ sessionId: (_69 = previous === null || previous === void 0 ? void 0 : previous.sessionId) !== null && _69 !== void 0 ? _69 : null,
41938
+ device_id: deviceId !== null && deviceId !== void 0 ? deviceId : undefined,
41939
+ session_id: (_70 = previous === null || previous === void 0 ? void 0 : previous.sessionId) !== null && _70 !== void 0 ? _70 : undefined,
41940
+ ble_name: bleName !== null && bleName !== void 0 ? bleName : undefined,
41941
+ onekey_device_type: 'PRO2',
41942
+ passphrase_protection: passphraseProtection !== null && passphraseProtection !== void 0 ? passphraseProtection : undefined,
41943
+ bootloader_mode: bootloaderMode,
41562
41944
  passphraseState: previous === null || previous === void 0 ? void 0 : previous.passphraseState,
41563
41945
  unlockedAttachPin,
41564
41946
  raw: {
@@ -42287,7 +42669,7 @@ class Device extends events.exports {
42287
42669
  }
42288
42670
  hasUnexpectedMode(allow, require) {
42289
42671
  if (!this.isUnacquired()) {
42290
- if (this.isBootloader() && !allow.includes(UI_REQUEST.BOOTLOADER)) {
42672
+ if (this.isBootloader() && !this.isProtocolV2() && !allow.includes(UI_REQUEST.BOOTLOADER)) {
42291
42673
  return UI_REQUEST.BOOTLOADER;
42292
42674
  }
42293
42675
  if (!this.isInitialized() && !allow.includes(UI_REQUEST.NOT_INITIALIZE)) {
@@ -42333,9 +42715,8 @@ class Device extends events.exports {
42333
42715
  var _a, _b, _c;
42334
42716
  return __awaiter(this, void 0, void 0, function* () {
42335
42717
  if (this.isProtocolV2()) {
42336
- let pinResult;
42337
42718
  try {
42338
- ({ message: pinResult } = yield this.commands.typedCall('DeviceSessionAskPin', 'DeviceSessionPinResult'));
42719
+ yield this.commands.typedCall('DeviceSessionAskPin', 'Success');
42339
42720
  }
42340
42721
  catch (error) {
42341
42722
  const errorText = error instanceof Error
@@ -42346,16 +42727,7 @@ class Device extends events.exports {
42346
42727
  }
42347
42728
  throw error;
42348
42729
  }
42349
- const status = {};
42350
- if (pinResult.unlocked != null) {
42351
- status.unlocked = pinResult.unlocked;
42352
- }
42353
- if (pinResult.unlocked_attach_pin != null) {
42354
- status.unlocked_by_attach_to_pin = pinResult.unlocked_attach_pin;
42355
- }
42356
- if (pinResult.passphrase_protection != null) {
42357
- status.passphrase_enabled = pinResult.passphrase_protection;
42358
- }
42730
+ const { message: status } = yield this.commands.typedCall('DeviceStatusGet', 'DeviceStatus', {});
42359
42731
  return this.updateProtocolV2Status(status);
42360
42732
  }
42361
42733
  const firmwareVersion = (_c = this.getCurrentFirmwareVersionString()) !== null && _c !== void 0 ? _c : '0.0.0';
@@ -45965,9 +46337,6 @@ const isProtocolV2DeviceDisconnectedError = (error) => {
45965
46337
  message.includes('connection has timed out unexpectedly') ||
45966
46338
  message.includes('connection error has occured') ||
45967
46339
  message.includes('connection error has occurred') ||
45968
- message.includes('transferIn') ||
45969
- message.includes('transferin') ||
45970
- message.includes('usbdevice') ||
45971
46340
  message.includes('multiplatformbleadapter') ||
45972
46341
  message.includes('multipalformebleadapter') ||
45973
46342
  compactMessage.includes('rxerrorerror6') ||
@@ -46263,6 +46632,16 @@ const parseProtocolV2OkppHeader = (bytes) => {
46263
46632
  headerHash: bytesToHex(bytes.slice(PROTOCOL_V2_OKPP_HEADER_HASH_OFFSET, PROTOCOL_V2_OKPP_HEADER_HASH_OFFSET + PROTOCOL_V2_OKPP_HASH_SIZE)),
46264
46633
  };
46265
46634
  };
46635
+ const assertProtocolV2ReconnectIdentity = (expectedDeviceId, actualDeviceId) => {
46636
+ if (!expectedDeviceId)
46637
+ return;
46638
+ if (!actualDeviceId) {
46639
+ throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceNotFound, 'Protocol V2 reconnect identity unavailable');
46640
+ }
46641
+ if (actualDeviceId !== expectedDeviceId) {
46642
+ throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceNotFound, `Protocol V2 reconnect identity mismatch: expected ${expectedDeviceId}, received ${actualDeviceId}`);
46643
+ }
46644
+ };
46266
46645
  class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
46267
46646
  init() {
46268
46647
  this.allowDeviceMode = [UI_REQUEST.BOOTLOADER, UI_REQUEST.NOT_INITIALIZE];
@@ -46339,11 +46718,12 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
46339
46718
  });
46340
46719
  }
46341
46720
  runProtocolV2() {
46342
- var _a, _b;
46721
+ var _a, _b, _c;
46343
46722
  return __awaiter(this, void 0, void 0, function* () {
46344
46723
  const deviceFeatures = yield this.getProtocolV2DeviceFeatures();
46724
+ this.protocolV2ExpectedDeviceId = (_a = deviceFeatures.deviceId) !== null && _a !== void 0 ? _a : undefined;
46345
46725
  const deviceFirmwareType = getFirmwareType(deviceFeatures);
46346
- const firmwareType = (_a = this.params.firmwareType) !== null && _a !== void 0 ? _a : deviceFirmwareType;
46726
+ const firmwareType = (_b = this.params.firmwareType) !== null && _b !== void 0 ? _b : deviceFirmwareType;
46347
46727
  let fwBinaryMap = [];
46348
46728
  let bootloaderBinary = null;
46349
46729
  let installItems;
@@ -46360,7 +46740,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
46360
46740
  this.postTipMessage(exports.FirmwareUpdateTipMessage.FinishDownloadFirmware);
46361
46741
  }
46362
46742
  catch (err) {
46363
- throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.FirmwareUpdateDownloadFailed, (_b = err.message) !== null && _b !== void 0 ? _b : err);
46743
+ throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.FirmwareUpdateDownloadFailed, (_c = err.message) !== null && _c !== void 0 ? _c : err);
46364
46744
  }
46365
46745
  const resourceBundles = this.prepareProtocolV2ResourceBundles(firmwareType, deviceFeatures);
46366
46746
  if (!bootloaderBinary && fwBinaryMap.length === 0 && !(resourceBundles === null || resourceBundles === void 0 ? void 0 : resourceBundles.length)) {
@@ -46689,6 +47069,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
46689
47069
  });
46690
47070
  }
46691
47071
  waitForProtocolV2BootloaderMode(timeout = PROTOCOL_V2_BOOTLOADER_RECONNECT_TIMEOUT, retryInterval = 1000) {
47072
+ var _a;
46692
47073
  return __awaiter(this, void 0, void 0, function* () {
46693
47074
  const startTime = Date.now();
46694
47075
  let lastError;
@@ -46700,6 +47081,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
46700
47081
  timeoutMs: PROTOCOL_V2_SHORT_RESPONSE_TIMEOUT,
46701
47082
  });
46702
47083
  const features = this.device.updateProtocolV2Features(deviceInfo);
47084
+ assertProtocolV2ReconnectIdentity(this.protocolV2ExpectedDeviceId, (_a = features.deviceId) !== null && _a !== void 0 ? _a : undefined);
46703
47085
  if (features === null || features === void 0 ? void 0 : features.bootloaderMode) {
46704
47086
  return features;
46705
47087
  }
@@ -46835,6 +47217,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
46835
47217
  return !!features && !features.bootloaderMode && features.mode !== 'bootloader';
46836
47218
  }
46837
47219
  probeProtocolV2NormalMode() {
47220
+ var _a;
46838
47221
  return __awaiter(this, void 0, void 0, function* () {
46839
47222
  const deviceInfo = yield requestProtocolV2DeviceInfo({
46840
47223
  commands: this.device.getCommands(),
@@ -46842,6 +47225,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
46842
47225
  request: PROTOCOL_V2_VERSIONS_DEVICE_INFO_REQUEST,
46843
47226
  });
46844
47227
  const features = this.device.updateProtocolV2Features(deviceInfo);
47228
+ assertProtocolV2ReconnectIdentity(this.protocolV2ExpectedDeviceId, (_a = features.deviceId) !== null && _a !== void 0 ? _a : undefined);
46845
47229
  if (this.isProtocolV2NormalModeFeatures(features)) {
46846
47230
  Log$5.log('Protocol V2 firmware install finished; device is back in normal mode');
46847
47231
  return true;
@@ -46961,6 +47345,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
46961
47345
  });
46962
47346
  }
46963
47347
  waitForProtocolV2ReconnectAndFeatures(timeout) {
47348
+ var _a;
46964
47349
  return __awaiter(this, void 0, void 0, function* () {
46965
47350
  const startTime = Date.now();
46966
47351
  let lastError;
@@ -46973,6 +47358,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
46973
47358
  request: PROTOCOL_V2_VERSIONS_DEVICE_INFO_REQUEST,
46974
47359
  });
46975
47360
  const features = this.device.updateProtocolV2Features(deviceInfo);
47361
+ assertProtocolV2ReconnectIdentity(this.protocolV2ExpectedDeviceId, (_a = features.deviceId) !== null && _a !== void 0 ? _a : undefined);
46976
47362
  if (features.bootloaderMode || features.mode === 'bootloader') {
46977
47363
  throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceNotFound, 'Protocol V2 device is still in bootloader mode');
46978
47364
  }
@@ -47003,6 +47389,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
47003
47389
  this.device.commands.disposed = false;
47004
47390
  this.device.getCommands().mainId = (_c = this.device.mainId) !== null && _c !== void 0 ? _c : '';
47005
47391
  yield this.device.initialize();
47392
+ assertProtocolV2ReconnectIdentity(this.protocolV2ExpectedDeviceId, this.device.getCurrentDeviceId());
47006
47393
  return;
47007
47394
  }
47008
47395
  const { deviceList } = yield DevicePool.getDevices(devicesDescriptor, undefined, {
@@ -47017,6 +47404,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
47017
47404
  this.device.commands.disposed = false;
47018
47405
  this.device.getCommands().mainId = (_d = this.device.mainId) !== null && _d !== void 0 ? _d : '';
47019
47406
  yield this.device.initialize();
47407
+ assertProtocolV2ReconnectIdentity(this.protocolV2ExpectedDeviceId, this.device.getCurrentDeviceId());
47020
47408
  });
47021
47409
  }
47022
47410
  protocolV2CommonUpdateProcess(params) {
@@ -47055,11 +47443,10 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
47055
47443
  const overwrite = offset === 0;
47056
47444
  const progress = getProtocolV2DeviceTransferProgress((processedSize !== null && processedSize !== void 0 ? processedSize : 0) + offset, (processedSize !== null && processedSize !== void 0 ? processedSize : 0) + chunkEnd, totalSize !== null && totalSize !== void 0 ? totalSize : payload.byteLength);
47057
47445
  const writeRes = yield this.fileWriteChunk(filePath, payload.byteLength, offset, chunk, overwrite, progress);
47058
- const processedByte = Number(writeRes.message.processed_byte);
47059
- const nextOffset = Number.isFinite(processedByte) && processedByte > offset
47060
- ? processedByte
47061
- : offset + chunkLength;
47062
- if (nextOffset <= offset || nextOffset > payload.byteLength) {
47446
+ const rawProcessedByte = writeRes.message.processed_byte;
47447
+ const processedByte = Number(rawProcessedByte);
47448
+ const nextOffset = rawProcessedByte === undefined ? offset + chunkLength : processedByte;
47449
+ if (!Number.isFinite(nextOffset) || nextOffset <= offset || nextOffset > chunkEnd) {
47063
47450
  throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.EmmcFileWriteFirmwareError, `invalid processed_byte ${writeRes.message.processed_byte} for offset ${offset}`);
47064
47451
  }
47065
47452
  offset = nextOffset;
@@ -47394,6 +47781,20 @@ class DeviceStatusGet extends BaseMethod {
47394
47781
  }
47395
47782
  }
47396
47783
 
47784
+ class DeviceGetOnboardingStatus extends BaseMethod {
47785
+ init() {
47786
+ this.requireProtocolV2 = true;
47787
+ this.skipForceUpdateCheck = true;
47788
+ this.useDevicePassphraseState = false;
47789
+ }
47790
+ run() {
47791
+ return __awaiter(this, void 0, void 0, function* () {
47792
+ const { message } = yield this.device.commands.typedCall('DevGetOnboardingStatus', 'DevOnboardingStatus', {});
47793
+ return message;
47794
+ });
47795
+ }
47796
+ }
47797
+
47397
47798
  class DeviceSessionGet extends BaseMethod {
47398
47799
  init() {
47399
47800
  this.requireProtocolV2 = true;
@@ -47606,14 +48007,111 @@ class DeviceSettingsPageShow extends BaseMethod {
47606
48007
  }
47607
48008
  }
47608
48009
 
47609
- const WALLPAPER_DIRECTORY = 'vol0:/wallpapers/user';
47610
- const SAFE_FILE_NAME = /^[A-Za-z0-9_-]+(?:\.bin)?$/;
47611
- function getDefaultChunkSize() {
48010
+ const MIN_FILE_CHUNK_SIZE = 64;
48011
+ function getProtocolV2FileChunkLimit() {
47612
48012
  const env = DataManager.getSettings('env');
47613
48013
  return env && DataManager.isBleConnect(env)
47614
48014
  ? hdTransport.PROTOCOL_V2_BLE_FILE_CHUNK_SIZE
47615
48015
  : hdTransport.PROTOCOL_V2_WEBUSB_FILE_CHUNK_SIZE;
47616
48016
  }
48017
+ function dataToUint8Array(data) {
48018
+ return __awaiter(this, void 0, void 0, function* () {
48019
+ if (typeof data === 'string')
48020
+ return new TextEncoder().encode(data);
48021
+ if (data instanceof ArrayBuffer)
48022
+ return new Uint8Array(data);
48023
+ if (ArrayBuffer.isView(data)) {
48024
+ return new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
48025
+ }
48026
+ if (typeof Blob !== 'undefined' && data instanceof Blob) {
48027
+ return new Uint8Array(yield data.arrayBuffer());
48028
+ }
48029
+ throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.CallMethodInvalidParameter, 'Unsupported FilesystemFileWrite data');
48030
+ });
48031
+ }
48032
+ function normalizeChunkSize$1(value, maxChunkSize) {
48033
+ const numeric = Number(value);
48034
+ if (!Number.isFinite(numeric) || numeric <= 0)
48035
+ return maxChunkSize;
48036
+ return Math.min(Math.max(Math.floor(numeric), MIN_FILE_CHUNK_SIZE), maxChunkSize);
48037
+ }
48038
+ function getDeviceTransferProgress$1(before, after, total) {
48039
+ if (!Number.isFinite(total) || total <= 0)
48040
+ return 100;
48041
+ if (before <= 0 && after < total)
48042
+ return 0;
48043
+ if (after >= total)
48044
+ return 100;
48045
+ return Math.min(Math.max(Math.ceil((after / total) * 100), 1), 99);
48046
+ }
48047
+ function getConfirmedProgress(processed, total, written, length) {
48048
+ if (Number.isFinite(processed) && Number.isFinite(total) && total > 0) {
48049
+ if (processed >= total)
48050
+ return 100;
48051
+ return Math.min(Math.max(Math.floor((processed / total) * 100), 0), 99);
48052
+ }
48053
+ if (length > 0)
48054
+ return written >= length ? 100 : Math.floor((written / length) * 100);
48055
+ return 100;
48056
+ }
48057
+ function writeProtocolV2File(options) {
48058
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
48059
+ return __awaiter(this, void 0, void 0, function* () {
48060
+ (_a = options.throwIfAborted) === null || _a === void 0 ? void 0 : _a.call(options);
48061
+ const data = yield dataToUint8Array(options.data);
48062
+ const dataLength = data.byteLength;
48063
+ const startOffset = Number.isFinite(options.offset) && Number(options.offset) > 0 ? Number(options.offset) : 0;
48064
+ const totalSize = Number.isFinite(options.totalSize) && Number(options.totalSize) > 0
48065
+ ? Number(options.totalSize)
48066
+ : startOffset + dataLength;
48067
+ if (totalSize < startOffset + dataLength) {
48068
+ throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, `FilesystemFileWrite totalSize ${totalSize} is smaller than offset + data length ${startOffset + dataLength}`);
48069
+ }
48070
+ const chunkSize = normalizeChunkSize$1((_b = options.chunkSize) !== null && _b !== void 0 ? _b : options.chunkLen, getProtocolV2FileChunkLimit());
48071
+ let written = 0;
48072
+ let chunks = 0;
48073
+ let lastMessage;
48074
+ const startTime = Date.now();
48075
+ while (written < dataLength) {
48076
+ (_c = options.throwIfAborted) === null || _c === void 0 ? void 0 : _c.call(options);
48077
+ const chunk = data.slice(written, Math.min(written + chunkSize, dataLength));
48078
+ const offset = startOffset + written;
48079
+ const progress = (_d = options.uiPercentage) !== null && _d !== void 0 ? _d : getDeviceTransferProgress$1(offset, offset + chunk.byteLength, totalSize);
48080
+ const response = yield options.commands.typedCall('FilesystemFileWrite', 'FilesystemFile', {
48081
+ file: { path: options.path, offset, total_size: totalSize, data: chunk },
48082
+ overwrite: chunks === 0 ? (_e = options.overwrite) !== null && _e !== void 0 ? _e : false : false,
48083
+ append: (_f = options.append) !== null && _f !== void 0 ? _f : false,
48084
+ ui_percentage: progress,
48085
+ }, { timeoutMs: options.timeoutMs });
48086
+ (_g = options.throwIfAborted) === null || _g === void 0 ? void 0 : _g.call(options);
48087
+ lastMessage = response.message;
48088
+ const rawProcessedByte = (_h = response.message) === null || _h === void 0 ? void 0 : _h.processed_byte;
48089
+ const processedByte = Number(rawProcessedByte);
48090
+ if (rawProcessedByte !== undefined &&
48091
+ (!Number.isFinite(processedByte) ||
48092
+ processedByte <= offset ||
48093
+ processedByte > offset + chunk.byteLength)) {
48094
+ throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, `FilesystemFileWrite invalid processed_byte ${processedByte}`);
48095
+ }
48096
+ written =
48097
+ rawProcessedByte === undefined ? written + chunk.byteLength : processedByte - startOffset;
48098
+ chunks += 1;
48099
+ const elapsedMs = Date.now() - startTime;
48100
+ const transferredBytes = Math.min(written, dataLength);
48101
+ (_j = options.onProgress) === null || _j === void 0 ? void 0 : _j.call(options, {
48102
+ progress: getConfirmedProgress(startOffset + written, totalSize, written, dataLength),
48103
+ transferredBytes,
48104
+ totalBytes: dataLength,
48105
+ rateBytesPerSecond: elapsedMs > 0 ? Math.round((transferredBytes / elapsedMs) * 1000) : undefined,
48106
+ elapsedMs,
48107
+ });
48108
+ }
48109
+ return Object.assign(Object.assign({}, lastMessage), { path: options.path, offset: startOffset, total_size: totalSize, processed_byte: startOffset + written, chunks });
48110
+ });
48111
+ }
48112
+
48113
+ const WALLPAPER_DIRECTORY = 'vol0:/wallpapers/user';
48114
+ const SAFE_FILE_NAME = /^[A-Za-z0-9_-]+(?:\.bin)?$/;
47617
48115
  function normalizeFileName(fileName, data) {
47618
48116
  if (fileName !== undefined && (!fileName || !SAFE_FILE_NAME.test(fileName))) {
47619
48117
  throw invalidParameter('Parameter [fileName] may only contain letters, numbers, underscores, hyphens and an optional .bin suffix.');
@@ -47668,52 +48166,40 @@ class DeviceUploadWallpaper extends BaseMethod {
47668
48166
  });
47669
48167
  }
47670
48168
  upload() {
47671
- var _a, _b;
47672
48169
  return __awaiter(this, void 0, void 0, function* () {
47673
48170
  if (this.uploaded)
47674
48171
  return;
47675
- const encoded = this.encoded;
48172
+ const { encoded } = this;
47676
48173
  if (!encoded)
47677
48174
  throw invalidParameter('Wallpaper data has not been initialized.');
47678
- const maxChunkSize = getDefaultChunkSize();
47679
- const requestedChunkSize = (_a = this.params.chunkSize) !== null && _a !== void 0 ? _a : maxChunkSize;
47680
- const chunkSize = Math.min(Math.max(64, Math.floor(requestedChunkSize)), maxChunkSize);
47681
- let offset = 0;
47682
- while (offset < encoded.data.byteLength) {
47683
- const chunk = encoded.data.slice(offset, Math.min(offset + chunkSize, encoded.data.byteLength));
47684
- const response = yield this.device.commands.typedCall('FilesystemFileWrite', 'FilesystemFile', {
47685
- file: {
47686
- path: this.path,
47687
- offset,
47688
- total_size: encoded.data.byteLength,
47689
- data: chunk,
47690
- },
47691
- overwrite: offset === 0,
47692
- append: false,
47693
- ui_percentage: Math.min(Math.ceil(((offset + chunk.byteLength) / encoded.data.byteLength) * 100), 100),
47694
- }, { timeoutMs: undefined });
47695
- const processedByte = Number((_b = response.message) === null || _b === void 0 ? void 0 : _b.processed_byte);
47696
- offset = Number.isFinite(processedByte) && processedByte > offset
47697
- ? processedByte
47698
- : offset + chunk.byteLength;
47699
- if (offset > encoded.data.byteLength) {
47700
- throw invalidParameter(`Invalid processed_byte returned by device: ${processedByte}.`);
47701
- }
47702
- }
48175
+ yield writeProtocolV2File({
48176
+ commands: this.device.commands,
48177
+ path: this.path,
48178
+ data: encoded.data,
48179
+ totalSize: encoded.data.byteLength,
48180
+ chunkSize: this.params.chunkSize,
48181
+ overwrite: true,
48182
+ append: false,
48183
+ throwIfAborted: () => this.throwIfAborted(),
48184
+ onProgress: payload => {
48185
+ if (typeof this.postMessage === 'function') {
48186
+ this.postMessage(createUiMessage(UI_REQUEST.DEVICE_PROGRESS, payload));
48187
+ }
48188
+ },
48189
+ });
47703
48190
  this.uploaded = true;
47704
48191
  });
47705
48192
  }
47706
48193
  run() {
47707
48194
  var _a;
47708
48195
  return __awaiter(this, void 0, void 0, function* () {
47709
- const encoded = this.encoded;
48196
+ const { encoded } = this;
47710
48197
  if (!encoded)
47711
48198
  throw invalidParameter('Wallpaper data has not been initialized.');
47712
48199
  yield this.ensureDirectory();
47713
48200
  yield this.upload();
47714
- const response = yield this.device.commands.typedCall('SetWallpaper', 'Success', {
47715
- target: hdTransport.WallpaperTarget.Lock,
47716
- path: this.path,
48201
+ const response = yield this.device.commands.typedCall('DeviceSettingsSet', 'Success', {
48202
+ settings: { wallpaper_path: this.path },
47717
48203
  });
47718
48204
  return {
47719
48205
  path: this.path,
@@ -47758,40 +48244,6 @@ class FilesystemFormat extends BaseMethod {
47758
48244
  }
47759
48245
  }
47760
48246
 
47761
- function normalizeDiskControlEnable(value) {
47762
- if (value === undefined || value === null)
47763
- return 0;
47764
- if (typeof value === 'boolean')
47765
- return value ? 1 : 0;
47766
- if (value === 0 || value === '0')
47767
- return 0;
47768
- if (value === 1 || value === '1')
47769
- return 1;
47770
- throw invalidParameter('Parameter [enable] must be a boolean or 0 | 1.');
47771
- }
47772
- class FilesystemDiskControl extends BaseMethod {
47773
- init() {
47774
- this.requireProtocolV2 = true;
47775
- this.skipForceUpdateCheck = true;
47776
- this.useDevicePassphraseState = false;
47777
- this.params = {
47778
- enable: normalizeDiskControlEnable(this.payload.enable),
47779
- timeoutMs: validateOptionalNonNegativeInteger(this.payload.timeoutMs, 'timeoutMs'),
47780
- };
47781
- }
47782
- run() {
47783
- return __awaiter(this, void 0, void 0, function* () {
47784
- const typedCall = this.device.commands.typedCall;
47785
- const res = yield typedCall('FilesystemDiskControl', 'Success', {
47786
- enable: this.params.enable,
47787
- }, {
47788
- timeoutMs: this.params.timeoutMs,
47789
- });
47790
- return Promise.resolve(res.message);
47791
- });
47792
- }
47793
- }
47794
-
47795
48247
  const MIN_FILE_READ_CHUNK_SIZE = 64;
47796
48248
  function getProtocolV2FileReadChunkLimit() {
47797
48249
  const env = DataManager.getSettings('env');
@@ -47800,7 +48252,7 @@ function getProtocolV2FileReadChunkLimit() {
47800
48252
  }
47801
48253
  return hdTransport.PROTOCOL_V2_WEBUSB_FILE_CHUNK_SIZE;
47802
48254
  }
47803
- function normalizeChunkSize$1(value, maxChunkSize) {
48255
+ function normalizeChunkSize(value, maxChunkSize) {
47804
48256
  const numeric = Number(value);
47805
48257
  if (!Number.isFinite(numeric) || numeric <= 0)
47806
48258
  return maxChunkSize;
@@ -47840,7 +48292,7 @@ function toUint8Array(value) {
47840
48292
  }
47841
48293
  return new Uint8Array(0);
47842
48294
  }
47843
- function getDeviceTransferProgress$1(bytesBeforeChunk, bytesAfterChunk, totalBytes) {
48295
+ function getDeviceTransferProgress(bytesBeforeChunk, bytesAfterChunk, totalBytes) {
47844
48296
  if (!Number.isFinite(totalBytes) || totalBytes <= 0) {
47845
48297
  return 100;
47846
48298
  }
@@ -47871,7 +48323,7 @@ class FileRead extends BaseMethod {
47871
48323
  return __awaiter(this, void 0, void 0, function* () {
47872
48324
  const startOffset = (_a = this.params.offset) !== null && _a !== void 0 ? _a : 0;
47873
48325
  const requestedLength = Number(this.params.totalSize);
47874
- const chunkSize = normalizeChunkSize$1(this.params.chunkLen, getProtocolV2FileReadChunkLimit());
48326
+ const chunkSize = normalizeChunkSize(this.params.chunkLen, getProtocolV2FileReadChunkLimit());
47875
48327
  let totalLength = Number.isFinite(requestedLength) && requestedLength > 0 ? requestedLength : 0;
47876
48328
  if (totalLength === 0) {
47877
48329
  const pathInfoRes = yield this.device.commands.typedCall('FilesystemPathInfoQuery', 'FilesystemPathInfo', {
@@ -47892,7 +48344,7 @@ class FileRead extends BaseMethod {
47892
48344
  while (read < totalLength) {
47893
48345
  const readLen = Math.min(chunkSize, totalLength - read);
47894
48346
  const offset = startOffset + read;
47895
- const progress = (_e = this.params.uiPercentage) !== null && _e !== void 0 ? _e : getDeviceTransferProgress$1(read, read + readLen, totalLength);
48347
+ const progress = (_e = this.params.uiPercentage) !== null && _e !== void 0 ? _e : getDeviceTransferProgress(read, read + readLen, totalLength);
47896
48348
  const res = yield this.device.commands.typedCall('FilesystemFileRead', 'FilesystemFile', {
47897
48349
  file: {
47898
48350
  path: this.params.path,
@@ -47921,62 +48373,6 @@ class FileRead extends BaseMethod {
47921
48373
  }
47922
48374
  }
47923
48375
 
47924
- const MIN_FILE_CHUNK_SIZE = 64;
47925
- function getProtocolV2FileChunkLimit() {
47926
- const env = DataManager.getSettings('env');
47927
- if (env && DataManager.isBleConnect(env)) {
47928
- return hdTransport.PROTOCOL_V2_BLE_FILE_CHUNK_SIZE;
47929
- }
47930
- return hdTransport.PROTOCOL_V2_WEBUSB_FILE_CHUNK_SIZE;
47931
- }
47932
- function dataToUint8Array(data) {
47933
- return __awaiter(this, void 0, void 0, function* () {
47934
- if (typeof data === 'string') {
47935
- return new TextEncoder().encode(data);
47936
- }
47937
- if (data instanceof ArrayBuffer) {
47938
- return new Uint8Array(data);
47939
- }
47940
- if (ArrayBuffer.isView(data)) {
47941
- return new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
47942
- }
47943
- if (typeof Blob !== 'undefined' && data instanceof Blob) {
47944
- return new Uint8Array(yield data.arrayBuffer());
47945
- }
47946
- throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.CallMethodInvalidParameter, 'Unsupported FilesystemFileWrite data');
47947
- });
47948
- }
47949
- function normalizeChunkSize(value, maxChunkSize) {
47950
- const numeric = Number(value);
47951
- if (!Number.isFinite(numeric) || numeric <= 0)
47952
- return maxChunkSize;
47953
- return Math.min(Math.max(Math.floor(numeric), MIN_FILE_CHUNK_SIZE), maxChunkSize);
47954
- }
47955
- function getConfirmedProgress(processedByte, totalSize, written, dataLength) {
47956
- if (Number.isFinite(processedByte) && Number.isFinite(totalSize) && totalSize > 0) {
47957
- if (processedByte >= totalSize)
47958
- return 100;
47959
- return Math.min(Math.max(Math.floor((processedByte / totalSize) * 100), 0), 99);
47960
- }
47961
- if (dataLength > 0) {
47962
- if (written >= dataLength)
47963
- return 100;
47964
- return Math.min(Math.max(Math.floor((written / dataLength) * 100), 0), 99);
47965
- }
47966
- return 100;
47967
- }
47968
- function getDeviceTransferProgress(bytesBeforeChunk, bytesAfterChunk, totalBytes) {
47969
- if (!Number.isFinite(totalBytes) || totalBytes <= 0) {
47970
- return 100;
47971
- }
47972
- if (bytesBeforeChunk <= 0 && bytesAfterChunk < totalBytes) {
47973
- return 0;
47974
- }
47975
- if (bytesAfterChunk >= totalBytes) {
47976
- return 100;
47977
- }
47978
- return Math.min(Math.max(Math.ceil((bytesAfterChunk / totalBytes) * 100), 1), 99);
47979
- }
47980
48376
  class FileWrite extends BaseMethod {
47981
48377
  init() {
47982
48378
  var _a, _b;
@@ -48000,77 +48396,26 @@ class FileWrite extends BaseMethod {
48000
48396
  };
48001
48397
  }
48002
48398
  run() {
48003
- var _a, _b, _c, _d, _e, _f;
48004
48399
  return __awaiter(this, void 0, void 0, function* () {
48005
- this.throwIfAborted();
48006
- const data = yield dataToUint8Array(this.params.data);
48007
- const dataLength = data.byteLength;
48008
- const offsetValue = Number((_a = this.params.offset) !== null && _a !== void 0 ? _a : 0);
48009
- const startOffset = Number.isFinite(offsetValue) && offsetValue > 0 ? offsetValue : 0;
48010
- const payloadTotalSize = Number(this.params.totalSize);
48011
- const totalSize = Number.isFinite(payloadTotalSize) && payloadTotalSize > 0
48012
- ? payloadTotalSize
48013
- : startOffset + dataLength;
48014
- if (totalSize < startOffset + dataLength) {
48015
- throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, `FilesystemFileWrite totalSize ${totalSize} is smaller than offset + data length ${startOffset + dataLength}`);
48016
- }
48017
- const chunkSize = normalizeChunkSize((_b = this.params.chunkSize) !== null && _b !== void 0 ? _b : this.params.chunkLen, getProtocolV2FileChunkLimit());
48018
- const overwrite = (_c = this.params.overwrite) !== null && _c !== void 0 ? _c : false;
48019
- const append = (_d = this.params.append) !== null && _d !== void 0 ? _d : false;
48020
- let written = 0;
48021
- let chunkIndex = 0;
48022
- let lastMessage;
48023
- const startTime = Date.now();
48024
- const timeoutMs = this.params.timeoutMs === undefined ? undefined : Number(this.params.timeoutMs);
48025
- while (written < dataLength) {
48026
- this.throwIfAborted();
48027
- const chunkEnd = Math.min(written + chunkSize, dataLength);
48028
- const chunk = data.slice(written, chunkEnd);
48029
- const offset = startOffset + written;
48030
- const isFirstChunk = chunkIndex === 0;
48031
- const progress = (_e = this.params.uiPercentage) !== null && _e !== void 0 ? _e : getDeviceTransferProgress(offset, offset + chunk.byteLength, totalSize);
48032
- const res = yield this.device.commands.typedCall('FilesystemFileWrite', 'FilesystemFile', {
48033
- file: {
48034
- path: this.params.path,
48035
- offset,
48036
- total_size: totalSize,
48037
- data: chunk,
48038
- },
48039
- overwrite: isFirstChunk ? overwrite : false,
48040
- append,
48041
- ui_percentage: progress,
48042
- }, {
48043
- timeoutMs,
48044
- });
48045
- this.throwIfAborted();
48046
- lastMessage = res.message;
48047
- const processedByte = Number((_f = res.message) === null || _f === void 0 ? void 0 : _f.processed_byte);
48048
- if (Number.isFinite(processedByte) && processedByte > offset) {
48049
- written = processedByte - startOffset;
48050
- }
48051
- else {
48052
- written += chunk.byteLength;
48053
- }
48054
- if (written > dataLength) {
48055
- throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, `FilesystemFileWrite invalid processed_byte ${processedByte}`);
48056
- }
48057
- const confirmedProcessedByte = Number.isFinite(processedByte) && processedByte > offset
48058
- ? processedByte
48059
- : startOffset + written;
48060
- if (typeof this.postMessage === 'function') {
48061
- const elapsedMs = Date.now() - startTime;
48062
- const transferredBytes = Math.min(written, dataLength);
48063
- this.postMessage(createUiMessage(UI_REQUEST.DEVICE_PROGRESS, {
48064
- progress: getConfirmedProgress(confirmedProcessedByte, totalSize, written, dataLength),
48065
- transferredBytes,
48066
- totalBytes: dataLength,
48067
- rateBytesPerSecond: elapsedMs > 0 ? Math.round((transferredBytes / elapsedMs) * 1000) : undefined,
48068
- elapsedMs,
48069
- }));
48070
- }
48071
- chunkIndex += 1;
48072
- }
48073
- return Promise.resolve(Object.assign(Object.assign({}, lastMessage), { path: this.params.path, offset: startOffset, total_size: totalSize, processed_byte: startOffset + written, chunks: chunkIndex }));
48400
+ return writeProtocolV2File({
48401
+ commands: this.device.commands,
48402
+ path: this.params.path,
48403
+ data: this.params.data,
48404
+ offset: this.params.offset,
48405
+ totalSize: this.params.totalSize,
48406
+ chunkSize: this.params.chunkSize,
48407
+ chunkLen: this.params.chunkLen,
48408
+ overwrite: this.params.overwrite,
48409
+ append: this.params.append,
48410
+ uiPercentage: this.params.uiPercentage,
48411
+ timeoutMs: this.params.timeoutMs === undefined ? undefined : Number(this.params.timeoutMs),
48412
+ throwIfAborted: () => this.throwIfAborted(),
48413
+ onProgress: payload => {
48414
+ if (typeof this.postMessage === 'function') {
48415
+ this.postMessage(createUiMessage(UI_REQUEST.DEVICE_PROGRESS, payload));
48416
+ }
48417
+ },
48418
+ });
48074
48419
  });
48075
48420
  }
48076
48421
  }
@@ -54457,7 +54802,7 @@ class CardanoSignTransaction extends BaseMethod {
54457
54802
  var _a;
54458
54803
  this.checkDeviceId = true;
54459
54804
  this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
54460
- this.allowUsePreInitialize = true;
54805
+ this.allowUsePreInitialize = false;
54461
54806
  this.hasBundle = !!((_a = this.payload) === null || _a === void 0 ? void 0 : _a.bundle);
54462
54807
  const { payload } = this;
54463
54808
  if (payload.auxiliaryData && payload.auxiliaryData.governanceRegistrationParameters) {
@@ -54693,7 +55038,7 @@ class CardanoSignMessage extends BaseMethod {
54693
55038
  init() {
54694
55039
  this.checkDeviceId = true;
54695
55040
  this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.NOT_INITIALIZE];
54696
- this.allowUsePreInitialize = true;
55041
+ this.allowUsePreInitialize = false;
54697
55042
  const { payload } = this;
54698
55043
  validateParams(payload, [
54699
55044
  { name: 'path', type: 'string', required: true },
@@ -57408,6 +57753,7 @@ var ApiMethods = /*#__PURE__*/Object.freeze({
57408
57753
  deviceReboot: DeviceReboot,
57409
57754
  deviceInfoGet: DeviceInfoGet,
57410
57755
  deviceStatusGet: DeviceStatusGet,
57756
+ deviceGetOnboardingStatus: DeviceGetOnboardingStatus,
57411
57757
  deviceSessionGet: DeviceSessionGet,
57412
57758
  deviceFirmwareUpdate: DeviceFirmwareUpdate,
57413
57759
  deviceGetFirmwareUpdateStatus: DeviceGetFirmwareUpdateStatus,
@@ -57419,7 +57765,6 @@ var ApiMethods = /*#__PURE__*/Object.freeze({
57419
57765
  deviceUploadWallpaper: DeviceUploadWallpaper,
57420
57766
  filesystemPermissionFix: FilesystemPermissionFix,
57421
57767
  filesystemFormat: FilesystemFormat,
57422
- filesystemDiskControl: FilesystemDiskControl,
57423
57768
  fileRead: FileRead,
57424
57769
  fileWrite: FileWrite,
57425
57770
  fileDelete: FileDelete,