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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. package/__tests__/preInitialize.test.ts +33 -0
  2. package/__tests__/protocol-v2.test.ts +1377 -480
  3. package/dist/api/FileRead.d.ts.map +1 -1
  4. package/dist/api/FileWrite.d.ts.map +1 -1
  5. package/dist/api/FirmwareUpdateV4.d.ts +20 -2
  6. package/dist/api/FirmwareUpdateV4.d.ts.map +1 -1
  7. package/dist/api/firmware/FirmwareUpdateBaseMethod.d.ts.map +1 -1
  8. package/dist/api/firmware/getBinary.d.ts +4 -0
  9. package/dist/api/firmware/getBinary.d.ts.map +1 -1
  10. package/dist/api/index.d.ts +5 -10
  11. package/dist/api/index.d.ts.map +1 -1
  12. package/dist/api/protocol-v2/DeviceFactoryInfoGet.d.ts +6 -0
  13. package/dist/api/protocol-v2/DeviceFactoryInfoGet.d.ts.map +1 -0
  14. package/dist/api/protocol-v2/DeviceFactoryInfoSet.d.ts +7 -0
  15. package/dist/api/protocol-v2/DeviceFactoryInfoSet.d.ts.map +1 -0
  16. package/dist/api/protocol-v2/DeviceFirmwareUpdate.d.ts +1 -1
  17. package/dist/api/protocol-v2/DeviceFirmwareUpdate.d.ts.map +1 -1
  18. package/dist/api/protocol-v2/DeviceGetFirmwareUpdateStatus.d.ts +1 -1
  19. package/dist/api/protocol-v2/{DeviceGetDeviceInfo.d.ts → DeviceInfoGet.d.ts} +10 -10
  20. package/dist/api/protocol-v2/DeviceInfoGet.d.ts.map +1 -0
  21. package/dist/api/protocol-v2/{FilesystemFixPermission.d.ts → FilesystemPermissionFix.d.ts} +2 -2
  22. package/dist/api/protocol-v2/FilesystemPermissionFix.d.ts.map +1 -0
  23. package/dist/api/protocol-v2/ProtocolInfoRequest.d.ts +6 -0
  24. package/dist/api/protocol-v2/ProtocolInfoRequest.d.ts.map +1 -0
  25. package/dist/api/protocol-v2/helpers.d.ts +24 -18
  26. package/dist/api/protocol-v2/helpers.d.ts.map +1 -1
  27. package/dist/api/ton/TonSignData.d.ts +1 -5
  28. package/dist/api/ton/TonSignData.d.ts.map +1 -1
  29. package/dist/core/index.d.ts.map +1 -1
  30. package/dist/data-manager/DataManager.d.ts +1 -1
  31. package/dist/data-manager/DataManager.d.ts.map +1 -1
  32. package/dist/data-manager/connectSettings.d.ts.map +1 -1
  33. package/dist/device/Device.d.ts +4 -1
  34. package/dist/device/Device.d.ts.map +1 -1
  35. package/dist/deviceProfile/buildDeviceFeatures.d.ts.map +1 -1
  36. package/dist/deviceProfile/buildDeviceProfile.d.ts.map +1 -1
  37. package/dist/index.d.ts +79 -54
  38. package/dist/index.js +1537 -1528
  39. package/dist/inject.d.ts.map +1 -1
  40. package/dist/protocols/protocol-v2/features.d.ts +12 -14
  41. package/dist/protocols/protocol-v2/features.d.ts.map +1 -1
  42. package/dist/protocols/protocol-v2/firmware.d.ts +10 -9
  43. package/dist/protocols/protocol-v2/firmware.d.ts.map +1 -1
  44. package/dist/types/api/firmwareUpdate.d.ts +1 -6
  45. package/dist/types/api/firmwareUpdate.d.ts.map +1 -1
  46. package/dist/types/api/getDeviceInfo.d.ts +2 -0
  47. package/dist/types/api/getDeviceInfo.d.ts.map +1 -1
  48. package/dist/types/api/index.d.ts +6 -11
  49. package/dist/types/api/index.d.ts.map +1 -1
  50. package/dist/types/api/protocolV2.d.ts +12 -17
  51. package/dist/types/api/protocolV2.d.ts.map +1 -1
  52. package/dist/types/device.d.ts +1 -0
  53. package/dist/types/device.d.ts.map +1 -1
  54. package/dist/types/params.d.ts +1 -0
  55. package/dist/types/params.d.ts.map +1 -1
  56. package/dist/types/settings.d.ts +29 -2
  57. package/dist/types/settings.d.ts.map +1 -1
  58. package/dist/utils/deviceFeaturesUtils.d.ts.map +1 -1
  59. package/dist/utils/patch.d.ts +1 -1
  60. package/dist/utils/patch.d.ts.map +1 -1
  61. package/package.json +4 -4
  62. package/src/api/FileRead.ts +14 -1
  63. package/src/api/FileWrite.ts +14 -1
  64. package/src/api/FirmwareUpdateV4.ts +933 -197
  65. package/src/api/GetOnekeyFeatures.ts +1 -1
  66. package/src/api/device/DeviceRebootToBoardloader.ts +4 -4
  67. package/src/api/device/DeviceRebootToBootloader.ts +4 -4
  68. package/src/api/firmware/FirmwareUpdateBaseMethod.ts +11 -4
  69. package/src/api/index.ts +5 -10
  70. package/src/api/protocol-v2/{FactoryGetDeviceInfo.ts → DeviceFactoryInfoGet.ts} +3 -3
  71. package/src/api/protocol-v2/DeviceFactoryInfoSet.ts +32 -0
  72. package/src/api/protocol-v2/DeviceFirmwareUpdate.ts +3 -5
  73. package/src/api/protocol-v2/DeviceGetFirmwareUpdateStatus.ts +2 -2
  74. package/src/api/protocol-v2/{DeviceGetDeviceInfo.ts → DeviceInfoGet.ts} +52 -22
  75. package/src/api/protocol-v2/DeviceReboot.ts +1 -1
  76. package/src/api/protocol-v2/{FilesystemFixPermission.ts → FilesystemPermissionFix.ts} +2 -2
  77. package/src/api/protocol-v2/{GetProtoVersion.ts → ProtocolInfoRequest.ts} +2 -2
  78. package/src/api/protocol-v2/helpers.ts +59 -43
  79. package/src/api/ton/TonSignData.ts +1 -5
  80. package/src/core/index.ts +19 -5
  81. package/src/data/messages/messages-protocol-v2.json +486 -1072
  82. package/src/data-manager/DataManager.ts +7 -0
  83. package/src/data-manager/connectSettings.ts +0 -6
  84. package/src/device/Device.ts +25 -14
  85. package/src/deviceProfile/buildDeviceFeatures.ts +60 -63
  86. package/src/deviceProfile/buildDeviceProfile.ts +77 -58
  87. package/src/inject.ts +10 -16
  88. package/src/protocols/protocol-v2/features.ts +26 -63
  89. package/src/protocols/protocol-v2/firmware.ts +11 -36
  90. package/src/types/api/firmwareUpdate.ts +10 -20
  91. package/src/types/api/getDeviceInfo.ts +2 -0
  92. package/src/types/api/index.ts +10 -20
  93. package/src/types/api/protocolV2.ts +22 -42
  94. package/src/types/device.ts +1 -0
  95. package/src/types/params.ts +4 -0
  96. package/src/types/settings.ts +44 -35
  97. package/src/utils/deviceFeaturesUtils.ts +45 -10
  98. package/dist/api/protocol-v2/DevReboot.d.ts +0 -7
  99. package/dist/api/protocol-v2/DevReboot.d.ts.map +0 -1
  100. package/dist/api/protocol-v2/DeviceGetDeviceInfo.d.ts.map +0 -1
  101. package/dist/api/protocol-v2/DeviceGetOnboardingStatus.d.ts +0 -6
  102. package/dist/api/protocol-v2/DeviceGetOnboardingStatus.d.ts.map +0 -1
  103. package/dist/api/protocol-v2/FactoryDeviceInfoSettings.d.ts +0 -7
  104. package/dist/api/protocol-v2/FactoryDeviceInfoSettings.d.ts.map +0 -1
  105. package/dist/api/protocol-v2/FactoryGetDeviceInfo.d.ts +0 -6
  106. package/dist/api/protocol-v2/FactoryGetDeviceInfo.d.ts.map +0 -1
  107. package/dist/api/protocol-v2/FilesystemFixPermission.d.ts.map +0 -1
  108. package/dist/api/protocol-v2/GetProtoVersion.d.ts +0 -6
  109. package/dist/api/protocol-v2/GetProtoVersion.d.ts.map +0 -1
  110. package/src/api/protocol-v2/DevReboot.ts +0 -24
  111. package/src/api/protocol-v2/DeviceGetOnboardingStatus.ts +0 -16
  112. package/src/api/protocol-v2/FactoryDeviceInfoSettings.ts +0 -29
package/dist/index.js CHANGED
@@ -138,20 +138,15 @@ const createCoreApi = (call) => ({
138
138
  deviceFlags: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'deviceFlags' })),
139
139
  deviceRebootToBoardloader: connectId => call({ connectId, method: 'deviceRebootToBoardloader' }),
140
140
  deviceRebootToBootloader: connectId => call({ connectId, method: 'deviceRebootToBootloader' }),
141
- getProtoVersion: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'getProtoVersion' })),
141
+ protocolInfoRequest: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'protocolInfoRequest' })),
142
142
  ping: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'ping' })),
143
143
  deviceReboot: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'deviceReboot' })),
144
- deviceGetDeviceInfo: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'deviceGetDeviceInfo' })),
145
- deviceGetOnboardingStatus: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'deviceGetOnboardingStatus' })),
144
+ deviceInfoGet: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'deviceInfoGet' })),
146
145
  deviceFirmwareUpdate: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'deviceFirmwareUpdate' })),
147
146
  deviceGetFirmwareUpdateStatus: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'deviceGetFirmwareUpdateStatus' })),
148
- devReboot: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'devReboot' })),
149
- devGetDeviceInfo: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'devGetDeviceInfo' })),
150
- devFirmwareUpdate: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'devFirmwareUpdate' })),
151
- devGetFirmwareUpdateStatus: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'devGetFirmwareUpdateStatus' })),
152
- factoryDeviceInfoSettings: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'factoryDeviceInfoSettings' })),
153
- factoryGetDeviceInfo: connectId => call({ connectId, method: 'factoryGetDeviceInfo' }),
154
- filesystemFixPermission: connectId => call({ connectId, method: 'filesystemFixPermission' }),
147
+ deviceFactoryInfoSet: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'deviceFactoryInfoSet' })),
148
+ deviceFactoryInfoGet: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'deviceFactoryInfoGet' })),
149
+ filesystemPermissionFix: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'filesystemPermissionFix' })),
155
150
  fileRead: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'fileRead' })),
156
151
  fileWrite: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'fileWrite' })),
157
152
  fileDelete: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'fileDelete' })),
@@ -25392,7 +25387,6 @@ var nested = {
25392
25387
  MessageType_GetFeatures: 55,
25393
25388
  MessageType_SdProtect: 79,
25394
25389
  MessageType_ChangeWipeCode: 82,
25395
- MessageType_EndSession: 83,
25396
25390
  MessageType_DoPreauthorized: 84,
25397
25391
  MessageType_PreauthorizedRequest: 85,
25398
25392
  MessageType_CancelAuthorization: 86,
@@ -25711,8 +25705,6 @@ var nested = {
25711
25705
  MessageType_TonSignProof: 11905,
25712
25706
  MessageType_TonSignedProof: 11906,
25713
25707
  MessageType_TonTxAck: 11907,
25714
- MessageType_TonSignData: 11908,
25715
- MessageType_TonSignedData: 11909,
25716
25708
  MessageType_ScdoGetAddress: 12001,
25717
25709
  MessageType_ScdoAddress: 12002,
25718
25710
  MessageType_ScdoSignTx: 12003,
@@ -25742,46 +25734,36 @@ var nested = {
25742
25734
  MessageType_NeoAddress: 12302,
25743
25735
  MessageType_NeoSignTx: 12303,
25744
25736
  MessageType_NeoSignedTx: 12304,
25745
- MessageType_ReadSEPublicKey: 10004,
25746
- MessageType_SEPublicKey: 10005,
25747
- MessageType_WriteSEPublicCert: 10006,
25748
- MessageType_ReadSEPublicCert: 10007,
25749
- MessageType_SEPublicCert: 10008,
25750
- MessageType_SESignMessage: 10012,
25751
- MessageType_SEMessageSignature: 10013,
25752
- MessageType_ResourceUpload: 10018,
25753
- MessageType_ZoomRequest: 10019,
25754
- MessageType_BlurRequest: 10032,
25755
- MessageType_SetWallpaper: 10033,
25756
- MessageType_GetWallpaper: 10034,
25757
- MessageType_Wallpaper: 10035,
25758
- MessageType_ResourceRequest: 10020,
25759
- MessageType_ResourceAck: 10021,
25760
- MessageType_ResourceUpdate: 10022,
25761
- MessageType_ListResDir: 10023,
25762
- MessageType_FileInfoList: 10024,
25763
- MessageType_OnekeyGetFeatures: 10025,
25764
- MessageType_OnekeyFeatures: 10026,
25765
- MessageType_WriteSEPrivateKey: 10027,
25766
- MessageType_GetPassphraseState: 10028,
25767
- MessageType_PassphraseState: 10029,
25768
- MessageType_UnLockDevice: 10030,
25769
- MessageType_UnLockDeviceResponse: 10031,
25770
- MessageType_FactoryDeviceInfoSettings: 60000,
25771
- MessageType_FactoryGetDeviceInfo: 60001,
25772
- MessageType_FactoryDeviceInfo: 60002,
25773
- MessageType_GetProtoVersion: 60200,
25774
- MessageType_ProtoVersion: 60201,
25775
- MessageType_StartSession: 60205,
25737
+ MessageType_UiviewShowAddressRequest: 30200,
25738
+ MessageType_UiviewShowPublicKeyRequest: 30201,
25739
+ MessageType_UiviewConfirmTxRequest: 30202,
25740
+ MessageType_UiviewConfirmSignMessageRequest: 30203,
25741
+ MessageType_UiviewResponse: 30204,
25742
+ MessageType_DeviceFactoryInfoSet: 60000,
25743
+ MessageType_DeviceFactoryInfoGet: 60001,
25744
+ MessageType_DeviceFactoryInfo: 60002,
25745
+ MessageType_DeviceFactoryPermanentLock: 60003,
25746
+ MessageType_DeviceFactoryTest: 60004,
25747
+ MessageType_ProtocolInfoRequest: 60200,
25748
+ MessageType_ProtocolInfo: 60201,
25776
25749
  MessageType_Ping: 60206,
25777
25750
  MessageType_Success: 60207,
25778
25751
  MessageType_Failure: 60208,
25779
- MessageType_DevReboot: 60400,
25780
- MessageType_DevGetDeviceInfo: 60600,
25752
+ MessageType_DeviceReboot: 60400,
25753
+ MessageType_DeviceSettings: 60410,
25754
+ MessageType_DeviceSettingsGet: 60411,
25755
+ MessageType_DeviceSettingsSet: 60412,
25756
+ MessageType_DeviceCertificate: 60420,
25757
+ MessageType_DeviceCertificateWrite: 60421,
25758
+ MessageType_DeviceCertificateRead: 60422,
25759
+ MessageType_DeviceCertificateSignature: 60423,
25760
+ MessageType_DeviceCertificateSign: 60424,
25761
+ MessageType_SetWallpaper: 60430,
25762
+ MessageType_GetWallpaper: 60431,
25763
+ MessageType_Wallpaper: 60432,
25764
+ MessageType_DeviceInfoGet: 60600,
25781
25765
  MessageType_DeviceInfo: 60601,
25782
- MessageType_GetOnboardingStatus: 60602,
25783
- MessageType_OnboardingStatus: 60603,
25784
- MessageType_FilesystemFixPermission: 60800,
25766
+ MessageType_FilesystemPermissionFix: 60800,
25785
25767
  MessageType_FilesystemPathInfo: 60801,
25786
25768
  MessageType_FilesystemPathInfoQuery: 60802,
25787
25769
  MessageType_FilesystemFile: 60803,
@@ -25793,11 +25775,28 @@ var nested = {
25793
25775
  MessageType_FilesystemDirMake: 60809,
25794
25776
  MessageType_FilesystemDirRemove: 60810,
25795
25777
  MessageType_FilesystemFormat: 60811,
25796
- MessageType_DevFirmwareUpdate: 61000,
25797
- MessageType_DevFirmwareInstallProgress: 61001,
25798
- MessageType_DevGetFirmwareUpdateStatus: 61002,
25799
- MessageType_DevFirmwareUpdateStatus: 61003
25800
- }
25778
+ MessageType_DeviceFirmwareUpdateRequest: 61000,
25779
+ MessageType_DeviceFirmwareUpdateStatusGet: 61001,
25780
+ MessageType_DeviceFirmwareUpdateStatus: 61002
25781
+ },
25782
+ reserved: [
25783
+ [
25784
+ 90,
25785
+ 92
25786
+ ],
25787
+ [
25788
+ 114,
25789
+ 122
25790
+ ],
25791
+ [
25792
+ 300,
25793
+ 304
25794
+ ],
25795
+ [
25796
+ 309,
25797
+ 312
25798
+ ]
25799
+ ]
25801
25800
  },
25802
25801
  AlephiumGetAddress: {
25803
25802
  fields: {
@@ -29391,208 +29390,6 @@ var nested = {
29391
29390
  }
29392
29391
  }
29393
29392
  },
29394
- DebugLinkInput: {
29395
- fields: {
29396
- x: {
29397
- type: "uint32",
29398
- id: 1
29399
- },
29400
- y: {
29401
- type: "uint32",
29402
- id: 2
29403
- },
29404
- duration_ms: {
29405
- type: "uint32",
29406
- id: 3
29407
- },
29408
- x_end: {
29409
- type: "uint32",
29410
- id: 4
29411
- },
29412
- y_end: {
29413
- type: "uint32",
29414
- id: 5
29415
- }
29416
- }
29417
- },
29418
- DebugLinkLayout: {
29419
- fields: {
29420
- lines: {
29421
- rule: "repeated",
29422
- type: "string",
29423
- id: 1
29424
- }
29425
- }
29426
- },
29427
- DebugLinkReseedRandom: {
29428
- fields: {
29429
- value: {
29430
- type: "uint32",
29431
- id: 1
29432
- }
29433
- }
29434
- },
29435
- DebugLinkRecordScreen: {
29436
- fields: {
29437
- target_directory: {
29438
- type: "string",
29439
- id: 1
29440
- }
29441
- }
29442
- },
29443
- DebugLinkGetState: {
29444
- fields: {
29445
- wait_word_list: {
29446
- type: "bool",
29447
- id: 1
29448
- },
29449
- wait_word_pos: {
29450
- type: "bool",
29451
- id: 2
29452
- },
29453
- wait_layout: {
29454
- type: "bool",
29455
- id: 3
29456
- }
29457
- }
29458
- },
29459
- DebugLinkState: {
29460
- fields: {
29461
- layout: {
29462
- type: "bytes",
29463
- id: 1
29464
- },
29465
- pin: {
29466
- type: "string",
29467
- id: 2
29468
- },
29469
- matrix: {
29470
- type: "string",
29471
- id: 3
29472
- },
29473
- mnemonic_secret: {
29474
- type: "bytes",
29475
- id: 4
29476
- },
29477
- node: {
29478
- type: "HDNodeType",
29479
- id: 5
29480
- },
29481
- passphrase_protection: {
29482
- type: "bool",
29483
- id: 6
29484
- },
29485
- reset_word: {
29486
- type: "string",
29487
- id: 7
29488
- },
29489
- reset_entropy: {
29490
- type: "bytes",
29491
- id: 8
29492
- },
29493
- recovery_fake_word: {
29494
- type: "string",
29495
- id: 9
29496
- },
29497
- recovery_word_pos: {
29498
- type: "uint32",
29499
- id: 10
29500
- },
29501
- reset_word_pos: {
29502
- type: "uint32",
29503
- id: 11
29504
- },
29505
- mnemonic_type: {
29506
- type: "BackupType",
29507
- id: 12
29508
- },
29509
- layout_lines: {
29510
- rule: "repeated",
29511
- type: "string",
29512
- id: 13
29513
- }
29514
- }
29515
- },
29516
- DebugLinkStop: {
29517
- fields: {
29518
- }
29519
- },
29520
- DebugLinkLog: {
29521
- fields: {
29522
- level: {
29523
- type: "uint32",
29524
- id: 1
29525
- },
29526
- bucket: {
29527
- type: "string",
29528
- id: 2
29529
- },
29530
- text: {
29531
- type: "string",
29532
- id: 3
29533
- }
29534
- }
29535
- },
29536
- DebugLinkMemoryRead: {
29537
- fields: {
29538
- address: {
29539
- type: "uint32",
29540
- id: 1
29541
- },
29542
- length: {
29543
- type: "uint32",
29544
- id: 2
29545
- }
29546
- }
29547
- },
29548
- DebugLinkMemory: {
29549
- fields: {
29550
- memory: {
29551
- type: "bytes",
29552
- id: 1
29553
- }
29554
- }
29555
- },
29556
- DebugLinkMemoryWrite: {
29557
- fields: {
29558
- address: {
29559
- type: "uint32",
29560
- id: 1
29561
- },
29562
- memory: {
29563
- type: "bytes",
29564
- id: 2
29565
- },
29566
- flash: {
29567
- type: "bool",
29568
- id: 3
29569
- }
29570
- }
29571
- },
29572
- DebugLinkFlashErase: {
29573
- fields: {
29574
- sector: {
29575
- type: "uint32",
29576
- id: 1
29577
- }
29578
- }
29579
- },
29580
- DebugLinkEraseSdCard: {
29581
- fields: {
29582
- format: {
29583
- type: "bool",
29584
- id: 1
29585
- }
29586
- }
29587
- },
29588
- DebugLinkWatchLayout: {
29589
- fields: {
29590
- watch: {
29591
- type: "bool",
29592
- id: 1
29593
- }
29594
- }
29595
- },
29596
29393
  EosGetPublicKey: {
29597
29394
  fields: {
29598
29395
  address_n: {
@@ -31627,7 +31424,7 @@ var nested = {
31627
31424
  PromptTemporarily: 2
31628
31425
  }
31629
31426
  },
31630
- Initialize: {
31427
+ StartSession: {
31631
31428
  fields: {
31632
31429
  session_id: {
31633
31430
  type: "bytes",
@@ -31643,22 +31440,10 @@ var nested = {
31643
31440
  derive_cardano: {
31644
31441
  type: "bool",
31645
31442
  id: 3
31646
- },
31647
- passphrase_state: {
31648
- type: "string",
31649
- id: 8000
31650
- },
31651
- is_contains_attach: {
31652
- type: "bool",
31653
- id: 8001
31654
31443
  }
31655
31444
  }
31656
31445
  },
31657
- GetFeatures: {
31658
- fields: {
31659
- }
31660
- },
31661
- OnekeyGetFeatures: {
31446
+ EndSession: {
31662
31447
  fields: {
31663
31448
  }
31664
31449
  },
@@ -31683,399 +31468,17 @@ var nested = {
31683
31468
  APP: 1
31684
31469
  }
31685
31470
  },
31686
- Features: {
31687
- fields: {
31688
- vendor: {
31689
- type: "string",
31690
- id: 1
31691
- },
31692
- major_version: {
31693
- rule: "required",
31694
- type: "uint32",
31695
- id: 2
31696
- },
31697
- minor_version: {
31698
- rule: "required",
31699
- type: "uint32",
31700
- id: 3
31701
- },
31702
- patch_version: {
31703
- rule: "required",
31704
- type: "uint32",
31705
- id: 4
31706
- },
31707
- bootloader_mode: {
31708
- type: "bool",
31709
- id: 5
31710
- },
31711
- device_id: {
31712
- type: "string",
31713
- id: 6
31714
- },
31715
- pin_protection: {
31716
- type: "bool",
31717
- id: 7
31718
- },
31719
- passphrase_protection: {
31720
- type: "bool",
31721
- id: 8
31722
- },
31723
- language: {
31724
- type: "string",
31725
- id: 9
31726
- },
31727
- label: {
31728
- type: "string",
31729
- id: 10
31730
- },
31731
- initialized: {
31732
- type: "bool",
31733
- id: 12
31734
- },
31735
- revision: {
31736
- type: "bytes",
31737
- id: 13
31738
- },
31739
- bootloader_hash: {
31740
- type: "bytes",
31741
- id: 14
31742
- },
31743
- imported: {
31744
- type: "bool",
31745
- id: 15
31746
- },
31747
- unlocked: {
31748
- type: "bool",
31749
- id: 16
31750
- },
31751
- _passphrase_cached: {
31752
- type: "bool",
31753
- id: 17,
31754
- options: {
31755
- deprecated: true
31756
- }
31757
- },
31758
- firmware_present: {
31759
- type: "bool",
31760
- id: 18
31761
- },
31762
- needs_backup: {
31763
- type: "bool",
31764
- id: 19
31765
- },
31766
- flags: {
31767
- type: "uint32",
31768
- id: 20
31769
- },
31770
- model: {
31771
- type: "string",
31772
- id: 21
31773
- },
31774
- fw_major: {
31775
- type: "uint32",
31776
- id: 22
31777
- },
31778
- fw_minor: {
31779
- type: "uint32",
31780
- id: 23
31781
- },
31782
- fw_patch: {
31783
- type: "uint32",
31784
- id: 24
31785
- },
31786
- fw_vendor: {
31787
- type: "string",
31788
- id: 25
31789
- },
31790
- unfinished_backup: {
31791
- type: "bool",
31792
- id: 27
31793
- },
31794
- no_backup: {
31795
- type: "bool",
31796
- id: 28
31797
- },
31798
- recovery_mode: {
31799
- type: "bool",
31800
- id: 29
31801
- },
31802
- capabilities: {
31803
- rule: "repeated",
31804
- type: "Capability",
31805
- id: 30,
31806
- options: {
31807
- packed: false
31808
- }
31809
- },
31810
- backup_type: {
31811
- type: "BackupType",
31812
- id: 31
31813
- },
31814
- sd_card_present: {
31815
- type: "bool",
31816
- id: 32
31817
- },
31818
- sd_protection: {
31819
- type: "bool",
31820
- id: 33
31821
- },
31822
- wipe_code_protection: {
31823
- type: "bool",
31824
- id: 34
31825
- },
31826
- session_id: {
31827
- type: "bytes",
31828
- id: 35
31829
- },
31830
- passphrase_always_on_device: {
31831
- type: "bool",
31832
- id: 36
31833
- },
31834
- safety_checks: {
31835
- type: "SafetyCheckLevel",
31836
- id: 37
31837
- },
31838
- auto_lock_delay_ms: {
31839
- type: "uint32",
31840
- id: 38
31841
- },
31842
- display_rotation: {
31843
- type: "uint32",
31844
- id: 39
31845
- },
31846
- experimental_features: {
31847
- type: "bool",
31848
- id: 40
31849
- },
31850
- offset: {
31851
- type: "uint32",
31852
- id: 500
31853
- },
31854
- ble_name: {
31855
- type: "string",
31856
- id: 501
31857
- },
31858
- ble_ver: {
31859
- type: "string",
31860
- id: 502
31861
- },
31862
- ble_enable: {
31863
- type: "bool",
31864
- id: 503
31865
- },
31866
- se_enable: {
31867
- type: "bool",
31868
- id: 504
31869
- },
31870
- se_ver: {
31871
- type: "string",
31872
- id: 506
31873
- },
31874
- backup_only: {
31875
- type: "bool",
31876
- id: 507
31877
- },
31878
- onekey_version: {
31879
- type: "string",
31880
- id: 508
31881
- },
31882
- onekey_serial: {
31883
- type: "string",
31884
- id: 509
31885
- },
31886
- bootloader_version: {
31887
- type: "string",
31888
- id: 510
31889
- },
31890
- serial_no: {
31891
- type: "string",
31892
- id: 511
31893
- },
31894
- spi_flash: {
31895
- type: "string",
31896
- id: 512
31897
- },
31898
- initstates: {
31899
- type: "uint32",
31900
- id: 513
31901
- },
31902
- NFT_voucher: {
31903
- type: "bytes",
31904
- id: 514
31905
- },
31906
- cpu_info: {
31907
- type: "string",
31908
- id: 515
31909
- },
31910
- pre_firmware: {
31911
- type: "string",
31912
- id: 516
31913
- },
31914
- coin_switch: {
31915
- type: "uint32",
31916
- id: 517
31917
- },
31918
- build_id: {
31919
- type: "bytes",
31920
- id: 518
31921
- },
31922
- boardloader_version: {
31923
- type: "string",
31924
- id: 519
31925
- },
31926
- busy: {
31927
- type: "bool",
31928
- id: 41
31929
- },
31930
- onekey_device_type: {
31931
- type: "OneKeyDeviceType",
31932
- id: 600
31933
- },
31934
- onekey_se_type: {
31935
- type: "OneKeySeType",
31936
- id: 601
31937
- },
31938
- onekey_board_version: {
31939
- type: "string",
31940
- id: 602
31941
- },
31942
- onekey_board_hash: {
31943
- type: "bytes",
31944
- id: 603
31945
- },
31946
- onekey_boot_version: {
31947
- type: "string",
31948
- id: 604
31949
- },
31950
- onekey_boot_hash: {
31951
- type: "bytes",
31952
- id: 605
31953
- },
31954
- onekey_se01_version: {
31955
- type: "string",
31956
- id: 606
31957
- },
31958
- onekey_se01_hash: {
31959
- type: "bytes",
31960
- id: 607
31961
- },
31962
- onekey_se01_build_id: {
31963
- type: "string",
31964
- id: 608
31965
- },
31966
- onekey_firmware_version: {
31967
- type: "string",
31968
- id: 609
31969
- },
31970
- onekey_firmware_hash: {
31971
- type: "bytes",
31972
- id: 610
31973
- },
31974
- onekey_firmware_build_id: {
31975
- type: "string",
31976
- id: 611
31977
- },
31978
- onekey_serial_no: {
31979
- type: "string",
31980
- id: 612
31981
- },
31982
- onekey_boot_build_id: {
31983
- type: "string",
31984
- id: 613
31985
- },
31986
- onekey_ble_name: {
31987
- type: "string",
31988
- id: 614
31989
- },
31990
- onekey_ble_version: {
31991
- type: "string",
31992
- id: 615
31993
- },
31994
- onekey_ble_build_id: {
31995
- type: "string",
31996
- id: 616
31997
- },
31998
- onekey_ble_hash: {
31999
- type: "bytes",
32000
- id: 617
32001
- },
32002
- onekey_se02_version: {
32003
- type: "string",
32004
- id: 618
32005
- },
32006
- onekey_se03_version: {
32007
- type: "string",
32008
- id: 619
32009
- },
32010
- onekey_se04_version: {
32011
- type: "string",
32012
- id: 620
32013
- },
32014
- onekey_se01_state: {
32015
- type: "OneKeySEState",
32016
- id: 621
32017
- },
32018
- onekey_se02_state: {
32019
- type: "OneKeySEState",
32020
- id: 622
32021
- },
32022
- onekey_se03_state: {
32023
- type: "OneKeySEState",
32024
- id: 623
32025
- },
32026
- onekey_se04_state: {
32027
- type: "OneKeySEState",
32028
- id: 624
32029
- },
32030
- attach_to_pin_user: {
32031
- type: "bool",
32032
- id: 625
32033
- },
32034
- unlocked_attach_pin: {
32035
- type: "bool",
32036
- id: 626
32037
- }
32038
- },
32039
- nested: {
32040
- Capability: {
32041
- options: {
32042
- "(has_bitcoin_only_values)": true
32043
- },
32044
- values: {
32045
- Capability_Bitcoin: 1,
32046
- Capability_Bitcoin_like: 2,
32047
- Capability_Binance: 3,
32048
- Capability_Cardano: 4,
32049
- Capability_Crypto: 5,
32050
- Capability_EOS: 6,
32051
- Capability_Ethereum: 7,
32052
- Capability_Lisk: 8,
32053
- Capability_Monero: 9,
32054
- Capability_NEM: 10,
32055
- Capability_Ripple: 11,
32056
- Capability_Stellar: 12,
32057
- Capability_Tezos: 13,
32058
- Capability_U2F: 14,
32059
- Capability_Shamir: 15,
32060
- Capability_ShamirGroups: 16,
32061
- Capability_PassphraseEntry: 17,
32062
- Capability_AttachToPin: 18,
32063
- Capability_EthereumTypedData: 1000
32064
- }
32065
- }
32066
- }
32067
- },
32068
31471
  OnekeyFeatures: {
32069
31472
  fields: {
32070
31473
  onekey_device_type: {
32071
31474
  type: "OneKeyDeviceType",
32072
31475
  id: 1
32073
31476
  },
32074
- onekey_board_version: {
31477
+ onekey_romloader_version: {
32075
31478
  type: "string",
32076
31479
  id: 2
32077
31480
  },
32078
- onekey_boot_version: {
31481
+ onekey_bootloader_version: {
32079
31482
  type: "string",
32080
31483
  id: 3
32081
31484
  },
@@ -32083,11 +31486,11 @@ var nested = {
32083
31486
  type: "string",
32084
31487
  id: 4
32085
31488
  },
32086
- onekey_board_hash: {
31489
+ onekey_romloader_hash: {
32087
31490
  type: "bytes",
32088
31491
  id: 5
32089
31492
  },
32090
- onekey_boot_hash: {
31493
+ onekey_bootloader_hash: {
32091
31494
  type: "bytes",
32092
31495
  id: 6
32093
31496
  },
@@ -32095,11 +31498,11 @@ var nested = {
32095
31498
  type: "bytes",
32096
31499
  id: 7
32097
31500
  },
32098
- onekey_board_build_id: {
31501
+ onekey_romloader_build_id: {
32099
31502
  type: "string",
32100
31503
  id: 8
32101
31504
  },
32102
- onekey_boot_build_id: {
31505
+ onekey_bootloader_build_id: {
32103
31506
  type: "string",
32104
31507
  id: 9
32105
31508
  },
@@ -32111,19 +31514,19 @@ var nested = {
32111
31514
  type: "string",
32112
31515
  id: 11
32113
31516
  },
32114
- onekey_ble_name: {
31517
+ onekey_coprocessor_bt_name: {
32115
31518
  type: "string",
32116
31519
  id: 12
32117
31520
  },
32118
- onekey_ble_version: {
31521
+ onekey_coprocessor_version: {
32119
31522
  type: "string",
32120
31523
  id: 13
32121
31524
  },
32122
- onekey_ble_build_id: {
31525
+ onekey_coprocessor_build_id: {
32123
31526
  type: "string",
32124
31527
  id: 14
32125
31528
  },
32126
- onekey_ble_hash: {
31529
+ onekey_coprocessor_hash: {
32127
31530
  type: "bytes",
32128
31531
  id: 15
32129
31532
  },
@@ -32195,51 +31598,51 @@ var nested = {
32195
31598
  type: "string",
32196
31599
  id: 32
32197
31600
  },
32198
- onekey_se01_boot_version: {
31601
+ onekey_se01_bootloader_version: {
32199
31602
  type: "string",
32200
31603
  id: 33
32201
31604
  },
32202
- onekey_se02_boot_version: {
31605
+ onekey_se02_bootloader_version: {
32203
31606
  type: "string",
32204
31607
  id: 34
32205
31608
  },
32206
- onekey_se03_boot_version: {
31609
+ onekey_se03_bootloader_version: {
32207
31610
  type: "string",
32208
31611
  id: 35
32209
31612
  },
32210
- onekey_se04_boot_version: {
31613
+ onekey_se04_bootloader_version: {
32211
31614
  type: "string",
32212
31615
  id: 36
32213
31616
  },
32214
- onekey_se01_boot_hash: {
31617
+ onekey_se01_bootloader_hash: {
32215
31618
  type: "bytes",
32216
31619
  id: 37
32217
31620
  },
32218
- onekey_se02_boot_hash: {
31621
+ onekey_se02_bootloader_hash: {
32219
31622
  type: "bytes",
32220
31623
  id: 38
32221
31624
  },
32222
- onekey_se03_boot_hash: {
31625
+ onekey_se03_bootloader_hash: {
32223
31626
  type: "bytes",
32224
31627
  id: 39
32225
31628
  },
32226
- onekey_se04_boot_hash: {
31629
+ onekey_se04_bootloader_hash: {
32227
31630
  type: "bytes",
32228
31631
  id: 40
32229
31632
  },
32230
- onekey_se01_boot_build_id: {
31633
+ onekey_se01_bootloader_build_id: {
32231
31634
  type: "string",
32232
31635
  id: 41
32233
31636
  },
32234
- onekey_se02_boot_build_id: {
31637
+ onekey_se02_bootloader_build_id: {
32235
31638
  type: "string",
32236
31639
  id: 42
32237
31640
  },
32238
- onekey_se03_boot_build_id: {
31641
+ onekey_se03_bootloader_build_id: {
32239
31642
  type: "string",
32240
31643
  id: 43
32241
31644
  },
32242
- onekey_se04_boot_build_id: {
31645
+ onekey_se04_bootloader_build_id: {
32243
31646
  type: "string",
32244
31647
  id: 44
32245
31648
  }
@@ -32257,10 +31660,6 @@ var nested = {
32257
31660
  }
32258
31661
  }
32259
31662
  },
32260
- EndSession: {
32261
- fields: {
32262
- }
32263
- },
32264
31663
  ApplySettings: {
32265
31664
  fields: {
32266
31665
  language: {
@@ -37173,182 +36572,373 @@ var nested = {
37173
36572
  }
37174
36573
  }
37175
36574
  },
37176
- TonSignData: {
36575
+ ProtocolInfoRequest: {
37177
36576
  fields: {
37178
- address_n: {
36577
+ }
36578
+ },
36579
+ ProtocolInfo: {
36580
+ fields: {
36581
+ version: {
36582
+ rule: "required",
36583
+ type: "uint32",
36584
+ id: 1
36585
+ },
36586
+ supported_messages: {
37179
36587
  rule: "repeated",
37180
36588
  type: "uint32",
37181
- id: 1,
36589
+ id: 2,
37182
36590
  options: {
37183
36591
  packed: false
37184
36592
  }
37185
36593
  },
37186
- type: {
37187
- rule: "required",
37188
- type: "TonSignDataType",
37189
- id: 2
37190
- },
37191
- payload: {
37192
- rule: "required",
37193
- type: "bytes",
37194
- id: 3
37195
- },
37196
- schema: {
36594
+ protobuf_definition: {
37197
36595
  type: "string",
37198
- id: 4
37199
- },
37200
- appdomain: {
37201
- rule: "required",
37202
- type: "string",
37203
- id: 5
37204
- },
37205
- timestamp: {
37206
- rule: "required",
37207
- type: "uint64",
37208
- id: 6
37209
- },
37210
- from_address: {
36596
+ id: 3
36597
+ }
36598
+ }
36599
+ },
36600
+ Ping: {
36601
+ fields: {
36602
+ message: {
37211
36603
  type: "string",
37212
- id: 7
37213
- },
37214
- wallet_version: {
37215
- type: "TonWalletVersion",
37216
- id: 8,
37217
- options: {
37218
- "default": "V4R2"
37219
- }
37220
- },
37221
- wallet_id: {
37222
- type: "uint32",
37223
- id: 9,
36604
+ id: 1,
37224
36605
  options: {
37225
- "default": 698983191
36606
+ "default": ""
37226
36607
  }
37227
- },
37228
- workchain: {
37229
- type: "TonWorkChain",
37230
- id: 10,
36608
+ }
36609
+ }
36610
+ },
36611
+ Success: {
36612
+ fields: {
36613
+ message: {
36614
+ type: "string",
36615
+ id: 1,
37231
36616
  options: {
37232
- "default": "BASECHAIN"
36617
+ "default": ""
37233
36618
  }
36619
+ }
36620
+ }
36621
+ },
36622
+ Failure: {
36623
+ fields: {
36624
+ code: {
36625
+ rule: "required",
36626
+ type: "FailureType",
36627
+ id: 1
37234
36628
  },
37235
- is_bounceable: {
37236
- type: "bool",
37237
- id: 11,
37238
- options: {
37239
- "default": false
37240
- }
36629
+ subcode: {
36630
+ type: "uint32",
36631
+ id: 2
37241
36632
  },
37242
- is_testnet_only: {
37243
- type: "bool",
37244
- id: 12,
37245
- options: {
37246
- "default": false
37247
- }
36633
+ message: {
36634
+ type: "string",
36635
+ id: 3
37248
36636
  }
37249
36637
  },
37250
36638
  nested: {
37251
- TonSignDataType: {
36639
+ FailureType: {
37252
36640
  values: {
37253
- TEXT: 0,
37254
- BINARY: 1,
37255
- CELL: 2
36641
+ Failure_InvalidMessage: 1,
36642
+ Failure_UndefinedError: 2,
36643
+ Failure_UsageError: 3,
36644
+ Failure_DataError: 4,
36645
+ Failure_ProcessError: 5
37256
36646
  }
37257
36647
  }
37258
36648
  }
37259
36649
  },
37260
- TonSignedData: {
36650
+ DeviceRebootType: {
36651
+ values: {
36652
+ Normal: 0,
36653
+ Romloader: 1,
36654
+ Bootloader: 2
36655
+ }
36656
+ },
36657
+ DeviceReboot: {
37261
36658
  fields: {
37262
- signature: {
36659
+ reboot_type: {
36660
+ rule: "required",
36661
+ type: "DeviceRebootType",
36662
+ id: 1
36663
+ }
36664
+ }
36665
+ },
36666
+ DeviceSettings: {
36667
+ fields: {
36668
+ label: {
36669
+ type: "string",
36670
+ id: 1
36671
+ },
36672
+ bt_enable: {
36673
+ type: "bool",
36674
+ id: 2
36675
+ },
36676
+ language: {
36677
+ type: "string",
36678
+ id: 3
36679
+ }
36680
+ }
36681
+ },
36682
+ DeviceSettingsGet: {
36683
+ fields: {
36684
+ }
36685
+ },
36686
+ DeviceSettingsSet: {
36687
+ fields: {
36688
+ settings: {
36689
+ rule: "required",
36690
+ type: "DeviceSettings",
36691
+ id: 1
36692
+ }
36693
+ }
36694
+ },
36695
+ DeviceCertificate: {
36696
+ fields: {
36697
+ cert_and_pubkey: {
36698
+ rule: "required",
37263
36699
  type: "bytes",
37264
36700
  id: 1
37265
36701
  },
37266
- digest: {
36702
+ private_key: {
37267
36703
  type: "bytes",
37268
36704
  id: 2
37269
36705
  }
37270
36706
  }
37271
36707
  },
37272
- GetProtoVersion: {
36708
+ DeviceCertificateWrite: {
36709
+ fields: {
36710
+ cert: {
36711
+ rule: "required",
36712
+ type: "DeviceCertificate",
36713
+ id: 1
36714
+ }
36715
+ }
36716
+ },
36717
+ DeviceCertificateRead: {
37273
36718
  fields: {
37274
36719
  }
37275
36720
  },
37276
- ProtoVersion: {
36721
+ DeviceCertificateSignature: {
37277
36722
  fields: {
37278
- proto_version: {
36723
+ data: {
37279
36724
  rule: "required",
37280
- type: "uint32",
36725
+ type: "bytes",
37281
36726
  id: 1
37282
36727
  }
37283
36728
  }
37284
36729
  },
37285
- Ping: {
36730
+ DeviceCertificateSign: {
37286
36731
  fields: {
37287
- message: {
36732
+ data: {
36733
+ rule: "required",
36734
+ type: "bytes",
36735
+ id: 1
36736
+ }
36737
+ }
36738
+ },
36739
+ DeviceFirmwareTargetType: {
36740
+ values: {
36741
+ FW_MGMT_TARGET_INVALID: 0,
36742
+ FW_MGMT_TARGET_CRATE: 1,
36743
+ FW_MGMT_TARGET_ROMLOADER: 2,
36744
+ FW_MGMT_TARGET_BOOTLOADER: 3,
36745
+ FW_MGMT_TARGET_APPLICATION_P1: 4,
36746
+ FW_MGMT_TARGET_APPLICATION_P2: 5,
36747
+ FW_MGMT_TARGET_COPROCESSOR: 6,
36748
+ FW_MGMT_TARGET_SE01: 7,
36749
+ FW_MGMT_TARGET_SE02: 8,
36750
+ FW_MGMT_TARGET_SE03: 9,
36751
+ FW_MGMT_TARGET_SE04: 10
36752
+ }
36753
+ },
36754
+ DeviceFirmwareUpdateTaskStatus: {
36755
+ values: {
36756
+ FW_MGMT_UPDATER_TASK_STATUS_PENDING: 0,
36757
+ FW_MGMT_UPDATER_TASK_STATUS_IN_PROGRESS: 1,
36758
+ FW_MGMT_UPDATER_TASK_STATUS_FINISHED: 2,
36759
+ FW_MGMT_UPDATER_TASK_STATUS_FAILED_FILE_NOT_FOUND: 3,
36760
+ FW_MGMT_UPDATER_TASK_STATUS_FAILED_FILE_READ: 4,
36761
+ FW_MGMT_UPDATER_TASK_STATUS_FAILED_FILE_WRITE: 5,
36762
+ FW_MGMT_UPDATER_TASK_STATUS_FAILED_VERIFY: 6,
36763
+ FW_MGMT_UPDATER_TASK_STATUS_FAILED_INSTALL: 7,
36764
+ FW_MGMT_UPDATER_TASK_STATUS_FAILED_ABORT: 8,
36765
+ FW_MGMT_UPDATER_TASK_STATUS_FAILED_BUSY: 9,
36766
+ FW_MGMT_UPDATER_TASK_STATUS_FAILED_ENTRY_OUT_OF_BOUNDS: 10
36767
+ }
36768
+ },
36769
+ DeviceFirmwareTarget: {
36770
+ fields: {
36771
+ target_id: {
36772
+ rule: "required",
36773
+ type: "DeviceFirmwareTargetType",
36774
+ id: 1
36775
+ },
36776
+ path: {
36777
+ rule: "required",
37288
36778
  type: "string",
37289
- id: 1,
37290
- options: {
37291
- "default": ""
37292
- }
36779
+ id: 2
37293
36780
  }
37294
36781
  }
37295
36782
  },
37296
- Success: {
36783
+ DeviceFirmwareUpdateRequest: {
37297
36784
  fields: {
37298
- message: {
36785
+ targets: {
36786
+ rule: "repeated",
36787
+ type: "DeviceFirmwareTarget",
36788
+ id: 1
36789
+ }
36790
+ }
36791
+ },
36792
+ DeviceFirmwareUpdateRecord: {
36793
+ fields: {
36794
+ target_id: {
36795
+ rule: "required",
36796
+ type: "DeviceFirmwareTargetType",
36797
+ id: 1
36798
+ },
36799
+ status: {
36800
+ type: "DeviceFirmwareUpdateTaskStatus",
36801
+ id: 10
36802
+ },
36803
+ payload_version: {
36804
+ type: "uint32",
36805
+ id: 20
36806
+ },
36807
+ path: {
37299
36808
  type: "string",
37300
- id: 1,
37301
- options: {
37302
- "default": ""
37303
- }
36809
+ id: 30
37304
36810
  }
37305
36811
  }
37306
36812
  },
37307
- Failure: {
36813
+ DeviceFirmwareUpdateRecordFields: {
37308
36814
  fields: {
37309
- code: {
37310
- type: "FailureType",
36815
+ status: {
36816
+ type: "bool",
36817
+ id: 10
36818
+ },
36819
+ payload_version: {
36820
+ type: "bool",
36821
+ id: 20
36822
+ },
36823
+ path: {
36824
+ type: "bool",
36825
+ id: 30
36826
+ }
36827
+ }
36828
+ },
36829
+ DeviceFirmwareUpdateStatusGet: {
36830
+ fields: {
36831
+ fields: {
36832
+ type: "DeviceFirmwareUpdateRecordFields",
36833
+ id: 1
36834
+ }
36835
+ }
36836
+ },
36837
+ DeviceFirmwareUpdateStatus: {
36838
+ fields: {
36839
+ records: {
36840
+ rule: "repeated",
36841
+ type: "DeviceFirmwareUpdateRecord",
36842
+ id: 1
36843
+ }
36844
+ }
36845
+ },
36846
+ DeviceFactoryAck: {
36847
+ values: {
36848
+ FACTORY_ACK_SUCCESS: 0,
36849
+ FACTORY_ACK_FAIL: 1
36850
+ }
36851
+ },
36852
+ DeviceFactoryInfoManufactureTime: {
36853
+ fields: {
36854
+ year: {
36855
+ rule: "required",
36856
+ type: "uint32",
37311
36857
  id: 1
37312
36858
  },
37313
- message: {
36859
+ month: {
36860
+ rule: "required",
36861
+ type: "uint32",
36862
+ id: 2
36863
+ },
36864
+ day: {
36865
+ rule: "required",
36866
+ type: "uint32",
36867
+ id: 3
36868
+ },
36869
+ hour: {
36870
+ rule: "required",
36871
+ type: "uint32",
36872
+ id: 4
36873
+ },
36874
+ minute: {
36875
+ rule: "required",
36876
+ type: "uint32",
36877
+ id: 5
36878
+ },
36879
+ second: {
36880
+ rule: "required",
36881
+ type: "uint32",
36882
+ id: 6
36883
+ }
36884
+ }
36885
+ },
36886
+ DeviceFactoryInfo: {
36887
+ fields: {
36888
+ version: {
36889
+ type: "uint32",
36890
+ id: 1
36891
+ },
36892
+ serial_number: {
37314
36893
  type: "string",
37315
36894
  id: 2
36895
+ },
36896
+ burn_in_completed: {
36897
+ type: "bool",
36898
+ id: 3
36899
+ },
36900
+ factory_test_completed: {
36901
+ type: "bool",
36902
+ id: 4
36903
+ },
36904
+ manufacture_time: {
36905
+ type: "DeviceFactoryInfoManufactureTime",
36906
+ id: 5
37316
36907
  }
37317
- },
37318
- nested: {
37319
- FailureType: {
37320
- values: {
37321
- Failure_UnexpectedMessage: 1,
37322
- Failure_ButtonExpected: 2,
37323
- Failure_DataError: 3,
37324
- Failure_ActionCancelled: 4,
37325
- Failure_PinExpected: 5,
37326
- Failure_PinCancelled: 6,
37327
- Failure_PinInvalid: 7,
37328
- Failure_InvalidSignature: 8,
37329
- Failure_ProcessError: 9,
37330
- Failure_NotEnoughFunds: 10,
37331
- Failure_NotInitialized: 11,
37332
- Failure_PinMismatch: 12,
37333
- Failure_WipeCodeMismatch: 13,
37334
- Failure_InvalidSession: 14,
37335
- Failure_FirmwareError: 99
37336
- }
36908
+ }
36909
+ },
36910
+ DeviceFactoryInfoSet: {
36911
+ fields: {
36912
+ info: {
36913
+ rule: "required",
36914
+ type: "DeviceFactoryInfo",
36915
+ id: 1
37337
36916
  }
37338
36917
  }
37339
36918
  },
37340
- DevRebootType: {
37341
- values: {
37342
- Normal: 0,
37343
- Boardloader: 1,
37344
- Bootloader: 2
36919
+ DeviceFactoryInfoGet: {
36920
+ fields: {
37345
36921
  }
37346
36922
  },
37347
- DevReboot: {
36923
+ DeviceFactoryPermanentLock: {
37348
36924
  fields: {
37349
- reboot_type: {
36925
+ check_a: {
37350
36926
  rule: "required",
37351
- type: "DevRebootType",
36927
+ type: "bytes",
36928
+ id: 1
36929
+ },
36930
+ check_b: {
36931
+ rule: "required",
36932
+ type: "bytes",
36933
+ id: 2
36934
+ }
36935
+ }
36936
+ },
36937
+ DeviceFactoryTest: {
36938
+ fields: {
36939
+ burn_in_test: {
36940
+ rule: "required",
36941
+ type: "bool",
37352
36942
  id: 1
37353
36943
  }
37354
36944
  }
@@ -37360,23 +36950,25 @@ var nested = {
37360
36950
  MINI: 2,
37361
36951
  TOUCH: 3,
37362
36952
  PRO: 5,
37363
- CLASSIC1S_PURE: 6
36953
+ CLASSIC1S_PURE: 6,
36954
+ PRO2: 7,
36955
+ NEO: 8
37364
36956
  }
37365
36957
  },
37366
- DevSeType: {
36958
+ DeviceSeType: {
37367
36959
  values: {
37368
36960
  THD89: 0,
37369
36961
  SE608A: 1
37370
36962
  }
37371
36963
  },
37372
- DevSEState: {
36964
+ DeviceSEState: {
37373
36965
  values: {
37374
36966
  BOOT: 0,
37375
36967
  APP_FACTORY: 51,
37376
36968
  APP: 85
37377
36969
  }
37378
36970
  },
37379
- DevFirmwareImageInfo: {
36971
+ DeviceFirmwareImageInfo: {
37380
36972
  fields: {
37381
36973
  version: {
37382
36974
  type: "string",
@@ -37392,19 +36984,15 @@ var nested = {
37392
36984
  }
37393
36985
  }
37394
36986
  },
37395
- DevHardwareInfo: {
36987
+ DeviceHardwareInfo: {
37396
36988
  fields: {
37397
- device_type: {
36989
+ Device_type: {
37398
36990
  type: "DeviceType",
37399
36991
  id: 10
37400
36992
  },
37401
36993
  serial_no: {
37402
36994
  type: "string",
37403
- id: 11
37404
- },
37405
- device_id: {
37406
- type: "string",
37407
- id: 12
36995
+ id: 20
37408
36996
  },
37409
36997
  hardware_version: {
37410
36998
  type: "string",
@@ -37412,67 +37000,71 @@ var nested = {
37412
37000
  },
37413
37001
  hardware_version_raw_adc: {
37414
37002
  type: "uint32",
37415
- id: 101
37003
+ id: 110
37416
37004
  }
37417
37005
  }
37418
37006
  },
37419
- DevMainMcuInfo: {
37007
+ DeviceMainMcuInfo: {
37420
37008
  fields: {
37421
- board: {
37422
- type: "DevFirmwareImageInfo",
37009
+ romloader: {
37010
+ type: "DeviceFirmwareImageInfo",
37423
37011
  id: 10
37424
37012
  },
37425
- boot: {
37426
- type: "DevFirmwareImageInfo",
37013
+ bootloader: {
37014
+ type: "DeviceFirmwareImageInfo",
37427
37015
  id: 20
37428
37016
  },
37429
- app: {
37430
- type: "DevFirmwareImageInfo",
37017
+ application: {
37018
+ type: "DeviceFirmwareImageInfo",
37431
37019
  id: 30
37020
+ },
37021
+ application_data: {
37022
+ type: "DeviceFirmwareImageInfo",
37023
+ id: 40
37432
37024
  }
37433
37025
  }
37434
37026
  },
37435
- DevBluetoothInfo: {
37027
+ DeviceCoprocessorInfo: {
37436
37028
  fields: {
37437
- boot: {
37438
- type: "DevFirmwareImageInfo",
37029
+ bootloader: {
37030
+ type: "DeviceFirmwareImageInfo",
37439
37031
  id: 20
37440
37032
  },
37441
- app: {
37442
- type: "DevFirmwareImageInfo",
37033
+ application: {
37034
+ type: "DeviceFirmwareImageInfo",
37443
37035
  id: 30
37444
37036
  },
37445
- adv_name: {
37037
+ bt_adv_name: {
37446
37038
  type: "string",
37447
37039
  id: 100
37448
37040
  },
37449
- mac: {
37041
+ bt_mac: {
37450
37042
  type: "bytes",
37451
37043
  id: 110
37452
37044
  }
37453
37045
  }
37454
37046
  },
37455
- DevSEInfo: {
37047
+ DeviceSEInfo: {
37456
37048
  fields: {
37457
- boot: {
37458
- type: "DevFirmwareImageInfo",
37049
+ bootloader: {
37050
+ type: "DeviceFirmwareImageInfo",
37459
37051
  id: 20
37460
37052
  },
37461
- app: {
37462
- type: "DevFirmwareImageInfo",
37053
+ application: {
37054
+ type: "DeviceFirmwareImageInfo",
37463
37055
  id: 30
37464
37056
  },
37465
37057
  type: {
37466
- type: "DevSeType",
37058
+ type: "DeviceSeType",
37467
37059
  id: 100
37468
37060
  },
37469
37061
  state: {
37470
- type: "DevSEState",
37062
+ type: "DeviceSEState",
37471
37063
  id: 110
37472
37064
  }
37473
37065
  }
37474
37066
  },
37475
- DevInfoTargets: {
37067
+ DeviceInfoTargets: {
37476
37068
  fields: {
37477
37069
  hw: {
37478
37070
  type: "bool",
@@ -37482,7 +37074,7 @@ var nested = {
37482
37074
  type: "bool",
37483
37075
  id: 200
37484
37076
  },
37485
- bt: {
37077
+ coprocessor: {
37486
37078
  type: "bool",
37487
37079
  id: 300
37488
37080
  },
@@ -37508,7 +37100,7 @@ var nested = {
37508
37100
  }
37509
37101
  }
37510
37102
  },
37511
- DevInfoTypes: {
37103
+ DeviceInfoTypes: {
37512
37104
  fields: {
37513
37105
  version: {
37514
37106
  type: "bool",
@@ -37528,42 +37120,14 @@ var nested = {
37528
37120
  }
37529
37121
  }
37530
37122
  },
37531
- DevStatus: {
37532
- fields: {
37533
- language: {
37534
- type: "string",
37535
- id: 100
37536
- },
37537
- bt_enable: {
37538
- type: "bool",
37539
- id: 101
37540
- },
37541
- init_states: {
37542
- type: "bool",
37543
- id: 102
37544
- },
37545
- backup_required: {
37546
- type: "bool",
37547
- id: 200
37548
- },
37549
- passphrase_protection: {
37550
- type: "bool",
37551
- id: 201
37552
- },
37553
- label: {
37554
- type: "string",
37555
- id: 300
37556
- }
37557
- }
37558
- },
37559
- DevGetDeviceInfo: {
37123
+ DeviceInfoGet: {
37560
37124
  fields: {
37561
37125
  targets: {
37562
- type: "DevInfoTargets",
37126
+ type: "DeviceInfoTargets",
37563
37127
  id: 1
37564
37128
  },
37565
37129
  types: {
37566
- type: "DevInfoTypes",
37130
+ type: "DeviceInfoTypes",
37567
37131
  id: 2
37568
37132
  }
37569
37133
  }
@@ -37576,168 +37140,92 @@ var nested = {
37576
37140
  id: 1
37577
37141
  },
37578
37142
  hw: {
37579
- type: "DevHardwareInfo",
37143
+ type: "DeviceHardwareInfo",
37580
37144
  id: 100
37581
37145
  },
37582
37146
  fw: {
37583
- type: "DevMainMcuInfo",
37147
+ type: "DeviceMainMcuInfo",
37584
37148
  id: 200
37585
37149
  },
37586
- bt: {
37587
- type: "DevBluetoothInfo",
37150
+ coprocessor: {
37151
+ type: "DeviceCoprocessorInfo",
37588
37152
  id: 300
37589
37153
  },
37590
37154
  se1: {
37591
- type: "DevSEInfo",
37155
+ type: "DeviceSEInfo",
37592
37156
  id: 400
37593
37157
  },
37594
37158
  se2: {
37595
- type: "DevSEInfo",
37159
+ type: "DeviceSEInfo",
37596
37160
  id: 410
37597
37161
  },
37598
37162
  se3: {
37599
- type: "DevSEInfo",
37163
+ type: "DeviceSEInfo",
37600
37164
  id: 420
37601
37165
  },
37602
37166
  se4: {
37603
- type: "DevSEInfo",
37167
+ type: "DeviceSEInfo",
37604
37168
  id: 430
37605
37169
  },
37606
37170
  status: {
37607
- type: "DevStatus",
37171
+ type: "DeviceStatus",
37608
37172
  id: 10000
37609
37173
  }
37610
37174
  }
37611
37175
  },
37612
- DevFirmwareTargetType: {
37613
- values: {
37614
- TARGET_MAIN_APP: 0,
37615
- TARGET_MAIN_BOOT: 1,
37616
- TARGET_BT: 2,
37617
- TARGET_SE1: 3,
37618
- TARGET_SE2: 4,
37619
- TARGET_SE3: 5,
37620
- TARGET_SE4: 6,
37621
- TARGET_RESOURCE: 10
37622
- }
37623
- },
37624
- DevFirmwareTarget: {
37625
- fields: {
37626
- target_id: {
37627
- rule: "required",
37628
- type: "DevFirmwareTargetType",
37629
- id: 1
37630
- },
37631
- path: {
37632
- rule: "required",
37633
- type: "string",
37634
- id: 2
37635
- }
37636
- }
37637
- },
37638
- DevFirmwareUpdate: {
37639
- fields: {
37640
- targets: {
37641
- rule: "repeated",
37642
- type: "DevFirmwareTarget",
37643
- id: 1
37644
- }
37645
- }
37646
- },
37647
- DevFirmwareInstallProgress: {
37648
- fields: {
37649
- target_id: {
37650
- rule: "required",
37651
- type: "DevFirmwareTargetType",
37652
- id: 1
37653
- },
37654
- progress: {
37655
- rule: "required",
37656
- type: "uint32",
37657
- id: 2
37658
- },
37659
- stage: {
37660
- type: "string",
37661
- id: 3
37662
- }
37663
- }
37664
- },
37665
- DevFirmwareUpdateStatusEntry: {
37666
- fields: {
37667
- target_id: {
37668
- rule: "required",
37669
- type: "DevFirmwareTargetType",
37670
- id: 1
37671
- },
37672
- status: {
37673
- rule: "required",
37674
- type: "uint32",
37675
- id: 2
37676
- }
37677
- }
37678
- },
37679
- DevGetFirmwareUpdateStatus: {
37176
+ DeviceSessionGet: {
37680
37177
  fields: {
37681
- }
37682
- },
37683
- DevFirmwareUpdateStatus: {
37684
- fields: {
37685
- targets: {
37686
- rule: "repeated",
37687
- type: "DevFirmwareUpdateStatusEntry",
37178
+ session_id: {
37179
+ type: "bytes",
37688
37180
  id: 1
37689
37181
  }
37690
37182
  }
37691
37183
  },
37692
- FactoryDeviceInfoSettings: {
37184
+ DeviceSession: {
37693
37185
  fields: {
37694
- serial_no: {
37695
- type: "string",
37186
+ session_id: {
37187
+ type: "bytes",
37696
37188
  id: 1
37697
37189
  },
37698
- cpu_info: {
37190
+ btc_test_address: {
37699
37191
  type: "string",
37700
37192
  id: 2
37701
- },
37702
- pre_firmware: {
37703
- type: "string",
37704
- id: 3
37705
37193
  }
37706
37194
  }
37707
37195
  },
37708
- FactoryGetDeviceInfo: {
37709
- fields: {
37710
- }
37711
- },
37712
- FactoryDeviceInfo: {
37196
+ DeviceStatus: {
37713
37197
  fields: {
37714
- serial_no: {
37198
+ device_id: {
37715
37199
  type: "string",
37716
37200
  id: 1
37717
37201
  },
37718
- spi_flash_info: {
37719
- type: "string",
37202
+ unlocked: {
37203
+ type: "bool",
37720
37204
  id: 2
37721
37205
  },
37722
- se_info: {
37723
- type: "string",
37206
+ init_states: {
37207
+ type: "bool",
37724
37208
  id: 3
37725
37209
  },
37726
- nft_voucher: {
37727
- type: "bytes",
37210
+ backup_required: {
37211
+ type: "bool",
37728
37212
  id: 4
37729
37213
  },
37730
- cpu_info: {
37731
- type: "string",
37732
- id: 5
37214
+ passphrase_enabled: {
37215
+ type: "bool",
37216
+ id: 10
37733
37217
  },
37734
- pre_firmware: {
37735
- type: "string",
37736
- id: 6
37218
+ attach_to_pin_enabled: {
37219
+ type: "bool",
37220
+ id: 11
37221
+ },
37222
+ unlocked_by_attach_to_pin: {
37223
+ type: "bool",
37224
+ id: 12
37737
37225
  }
37738
37226
  }
37739
37227
  },
37740
- FilesystemFixPermission: {
37228
+ FilesystemPermissionFix: {
37741
37229
  fields: {
37742
37230
  }
37743
37231
  },
@@ -37954,76 +37442,6 @@ var nested = {
37954
37442
  fields: {
37955
37443
  }
37956
37444
  },
37957
- OnboardingStep: {
37958
- values: {
37959
- ONBOARDING_STEP_UNKNOWN: 0,
37960
- ONBOARDING_STEP_DEVICE_VERIFICATION: 1,
37961
- ONBOARDING_STEP_PERSONALIZATION: 2,
37962
- ONBOARDING_STEP_SETUP: 3,
37963
- ONBOARDING_STEP_FIRMWARE: 4
37964
- }
37965
- },
37966
- GetOnboardingStatus: {
37967
- fields: {
37968
- }
37969
- },
37970
- OnboardingStatus: {
37971
- fields: {
37972
- step: {
37973
- rule: "required",
37974
- type: "OnboardingStep",
37975
- id: 1
37976
- },
37977
- setup: {
37978
- type: "Setup",
37979
- id: 2
37980
- },
37981
- detail_code: {
37982
- type: "uint32",
37983
- id: 3
37984
- },
37985
- detail_str: {
37986
- type: "string",
37987
- id: 4
37988
- }
37989
- },
37990
- nested: {
37991
- Setup: {
37992
- fields: {
37993
- new_device: {
37994
- type: "NewDevice",
37995
- id: 1
37996
- },
37997
- restore: {
37998
- type: "Restore",
37999
- id: 2
38000
- }
38001
- },
38002
- nested: {
38003
- NewDevice: {
38004
- fields: {
38005
- seedcard_backup: {
38006
- type: "bool",
38007
- id: 1
38008
- }
38009
- }
38010
- },
38011
- Restore: {
38012
- fields: {
38013
- mnemonic: {
38014
- type: "bool",
38015
- id: 1
38016
- },
38017
- seedcard: {
38018
- type: "bool",
38019
- id: 2
38020
- }
38021
- }
38022
- }
38023
- }
38024
- }
38025
- }
38026
- },
38027
37445
  google: {
38028
37446
  nested: {
38029
37447
  protobuf: {
@@ -38792,12 +38210,14 @@ var _a$1;
38792
38210
  const Log$g = getLogger(exports.LoggerNames.Core);
38793
38211
  const FIRMWARE_FIELDS = [
38794
38212
  'firmware',
38213
+ 'firmware-v1',
38795
38214
  'firmware-v2',
38796
38215
  'firmware-v8',
38797
38216
  'firmware-btc-v8',
38798
38217
  ];
38799
38218
  const FIRMWARE_FIELD_TYPE_MAP = {
38800
38219
  firmware: hdShared.EFirmwareType.Universal,
38220
+ 'firmware-v1': hdShared.EFirmwareType.Universal,
38801
38221
  'firmware-v2': hdShared.EFirmwareType.Universal,
38802
38222
  'firmware-v8': hdShared.EFirmwareType.Universal,
38803
38223
  'firmware-btc-v8': hdShared.EFirmwareType.BitcoinOnly,
@@ -38889,6 +38309,7 @@ class DataManager {
38889
38309
  [hdShared.EDeviceType.Mini]: this.enrichFirmwareReleaseInfo(data.mini),
38890
38310
  [hdShared.EDeviceType.Touch]: this.enrichFirmwareReleaseInfo(data.touch),
38891
38311
  [hdShared.EDeviceType.Pro]: this.enrichFirmwareReleaseInfo(data.pro),
38312
+ [hdShared.EDeviceType.Pro2]: this.enrichFirmwareReleaseInfo(data.pro2),
38892
38313
  };
38893
38314
  this.assets = {
38894
38315
  bridge: data.bridge,
@@ -38949,6 +38370,10 @@ DataManager.deviceMap = {
38949
38370
  firmware: [],
38950
38371
  ble: [],
38951
38372
  },
38373
+ [hdShared.EDeviceType.Pro2]: {
38374
+ firmware: [],
38375
+ ble: [],
38376
+ },
38952
38377
  [hdShared.EDeviceType.ClassicPure]: {
38953
38378
  firmware: [],
38954
38379
  ble: [],
@@ -39207,7 +38632,7 @@ const supportInputPinOnSoftware = (features) => {
39207
38632
  return { support: semver__default["default"].gte(currentVersion, '2.3.0'), require: '2.3.0' };
39208
38633
  };
39209
38634
  const getPassphraseStateWithRefreshDeviceInfo = (device, options) => __awaiter(void 0, void 0, void 0, function* () {
39210
- var _a, _b;
38635
+ var _a, _b, _c;
39211
38636
  const { features } = device;
39212
38637
  const locked = (features === null || features === void 0 ? void 0 : features.unlocked) === false;
39213
38638
  const deviceType = device.getCurrentDeviceType();
@@ -39225,19 +38650,38 @@ const getPassphraseStateWithRefreshDeviceInfo = (device, options) => __awaiter(v
39225
38650
  }
39226
38651
  const deviceId = device.getCurrentDeviceId();
39227
38652
  device.updateInternalState((_a = device.getCurrentPassphraseProtection()) !== null && _a !== void 0 ? _a : false, passphraseState, deviceId, newSession, (options === null || options === void 0 ? void 0 : options.initSession) ? null : (_b = device.features) === null || _b === void 0 ? void 0 : _b.sessionId);
39228
- return { passphraseState, newSession, unlockedAttachPin };
38653
+ return {
38654
+ passphraseState,
38655
+ newSession,
38656
+ unlockedAttachPin: unlockedAttachPin !== null && unlockedAttachPin !== void 0 ? unlockedAttachPin : (_c = device.features) === null || _c === void 0 ? void 0 : _c.unlockedAttachPin,
38657
+ };
39229
38658
  });
39230
38659
  const supportProSeriesAttachPinPassphrase = (deviceType, firmwareVersion) => deviceType === hdShared.EDeviceType.Pro && semver__default["default"].gte(firmwareVersion, '4.15.0');
39231
38660
  const getPassphraseState = (device, options) => __awaiter(void 0, void 0, void 0, function* () {
39232
- var _c;
38661
+ var _d, _e;
39233
38662
  const { features, commands } = device;
39234
38663
  if (!features)
39235
38664
  return { passphraseState: undefined, newSession: undefined, unlockedAttachPin: undefined };
39236
- const firmwareVersion = (_c = device.getCurrentFirmwareVersionString()) !== null && _c !== void 0 ? _c : '0.0.0';
38665
+ const firmwareVersion = (_d = device.getCurrentFirmwareVersionString()) !== null && _d !== void 0 ? _d : '0.0.0';
39237
38666
  const deviceType = device.getCurrentDeviceType();
38667
+ if (device.isProtocolV2()) {
38668
+ const payload = {};
38669
+ const cachedSessionId = typeof device.getInternalState === 'function' ? device.getInternalState() : undefined;
38670
+ if (cachedSessionId) {
38671
+ payload.session_id = cachedSessionId;
38672
+ }
38673
+ const { message, type } = yield commands.typedCall('DeviceSessionGet', 'DeviceSession', payload);
38674
+ if (type === 'CallMethodError') {
38675
+ throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, 'Get the passphrase state error');
38676
+ }
38677
+ return {
38678
+ passphraseState: message.btc_test_address,
38679
+ newSession: message.session_id,
38680
+ unlockedAttachPin: (_e = features.unlockedAttachPin) !== null && _e !== void 0 ? _e : undefined,
38681
+ };
38682
+ }
39238
38683
  const supportAttachPinCapability = existCapability(features, hdTransport.Enum_Capability.Capability_AttachToPin);
39239
- const supportGetPassphraseState = device.isProtocolV2() ||
39240
- supportAttachPinCapability ||
38684
+ const supportGetPassphraseState = supportAttachPinCapability ||
39241
38685
  supportProSeriesAttachPinPassphrase(deviceType, firmwareVersion);
39242
38686
  if (supportGetPassphraseState) {
39243
38687
  const payload = (options === null || options === void 0 ? void 0 : options.onlyMainPin)
@@ -39311,6 +38755,9 @@ const getFirmwareUpdateField = ({ features, updateType, targetVersion, firmwareT
39311
38755
  if (deviceType === hdShared.EDeviceType.Pro) {
39312
38756
  return latestFirmwareField;
39313
38757
  }
38758
+ if (deviceType === hdShared.EDeviceType.Pro2) {
38759
+ return 'firmware-v1';
38760
+ }
39314
38761
  return 'firmware';
39315
38762
  };
39316
38763
  const getFirmwareUpdateFieldArray = (features, updateType) => {
@@ -39340,6 +38787,9 @@ const getFirmwareUpdateFieldArray = (features, updateType) => {
39340
38787
  if (deviceType === 'pro') {
39341
38788
  return ['firmware-v8'];
39342
38789
  }
38790
+ if (deviceType === 'pro2') {
38791
+ return ['firmware-v1'];
38792
+ }
39343
38793
  return ['firmware'];
39344
38794
  };
39345
38795
  function fixVersion(version) {
@@ -39391,7 +38841,6 @@ const initialSettings = {
39391
38841
  env: 'web',
39392
38842
  lazyLoad: false,
39393
38843
  timestamp: new Date().getTime(),
39394
- protocolV2DeviceInfoMockEnabled: false,
39395
38844
  };
39396
38845
  const getEnv = () => {
39397
38846
  if (typeof chrome !== 'undefined' &&
@@ -39465,9 +38914,6 @@ const parseConnectSettings = (input = {}) => {
39465
38914
  if (input.fetchConfig) {
39466
38915
  settings.fetchConfig = input.fetchConfig;
39467
38916
  }
39468
- if (typeof input.protocolV2DeviceInfoMockEnabled === 'boolean') {
39469
- settings.protocolV2DeviceInfoMockEnabled = input.protocolV2DeviceInfoMockEnabled;
39470
- }
39471
38917
  return settings;
39472
38918
  };
39473
38919
 
@@ -41053,11 +40499,12 @@ class DeviceCommands {
41053
40499
  }
41054
40500
  }
41055
40501
 
40502
+ const isProtocolV2BootloaderDeviceInfo = (deviceInfo) => !!deviceInfo && deviceInfo.status == null;
41056
40503
  const PROTOCOL_V2_FEATURES_DEVICE_INFO_REQUEST = {
41057
40504
  targets: {
41058
40505
  hw: true,
41059
40506
  fw: true,
41060
- bt: true,
40507
+ coprocessor: true,
41061
40508
  status: true,
41062
40509
  },
41063
40510
  types: {
@@ -41068,7 +40515,7 @@ const PROTOCOL_V2_FEATURES_DEVICE_INFO_REQUEST = {
41068
40515
  const PROTOCOL_V2_STATUS_DEVICE_INFO_REQUEST = {
41069
40516
  targets: {
41070
40517
  hw: true,
41071
- bt: true,
40518
+ coprocessor: true,
41072
40519
  status: true,
41073
40520
  },
41074
40521
  types: {
@@ -41080,7 +40527,7 @@ const PROTOCOL_V2_VERSIONS_DEVICE_INFO_REQUEST = {
41080
40527
  targets: {
41081
40528
  hw: true,
41082
40529
  fw: true,
41083
- bt: true,
40530
+ coprocessor: true,
41084
40531
  se1: true,
41085
40532
  se2: true,
41086
40533
  se3: true,
@@ -41096,7 +40543,7 @@ const PROTOCOL_V2_FULL_DEVICE_INFO_REQUEST = {
41096
40543
  targets: {
41097
40544
  hw: true,
41098
40545
  fw: true,
41099
- bt: true,
40546
+ coprocessor: true,
41100
40547
  se1: true,
41101
40548
  se2: true,
41102
40549
  se3: true,
@@ -41112,33 +40559,9 @@ const PROTOCOL_V2_FULL_DEVICE_INFO_REQUEST = {
41112
40559
  };
41113
40560
  const PROTOCOL_V2_DEVICE_INFO_REQUEST = PROTOCOL_V2_FULL_DEVICE_INFO_REQUEST;
41114
40561
  const PROTOCOL_V2_DEVICE_INFO_TIMEOUT_MS = 10 * 1000;
41115
- let protocolV2DeviceInfoMockEnabled = false;
41116
- const setProtocolV2DeviceInfoMock = (enabled) => {
41117
- protocolV2DeviceInfoMockEnabled = enabled;
41118
- };
41119
- const isProtocolV2DeviceInfoMockEnabled = () => protocolV2DeviceInfoMockEnabled;
41120
- const buildMockProtocolV2DeviceInfo = () => ({
41121
- protocol_version: 2,
41122
- hw: {
41123
- serial_no: '',
41124
- },
41125
- fw: {
41126
- app: { version: '0.1.0' },
41127
- },
41128
- bt: {},
41129
- status: {
41130
- init_states: true,
41131
- language: 'en_US',
41132
- passphrase_protection: false,
41133
- bt_enable: true,
41134
- },
41135
- });
41136
40562
  function requestProtocolV2DeviceInfo({ commands, timeoutMs = PROTOCOL_V2_DEVICE_INFO_TIMEOUT_MS, request = PROTOCOL_V2_FEATURES_DEVICE_INFO_REQUEST, }) {
41137
40563
  return __awaiter(this, void 0, void 0, function* () {
41138
- if (isProtocolV2DeviceInfoMockEnabled()) {
41139
- return buildMockProtocolV2DeviceInfo();
41140
- }
41141
- const { message } = yield commands.typedCall('DevGetDeviceInfo', 'DeviceInfo', request, {
40564
+ const { message } = yield commands.typedCall('DeviceInfoGet', 'DeviceInfo', request, {
41142
40565
  timeoutMs,
41143
40566
  });
41144
40567
  return message;
@@ -41153,7 +40576,7 @@ const versionArrayToString = (version) => {
41153
40576
  const value = version.join('.');
41154
40577
  return isMeaningfulVersion(value) ? value : null;
41155
40578
  };
41156
- const bytesToHex$2 = (value) => {
40579
+ const bytesToHex$3 = (value) => {
41157
40580
  if (!value)
41158
40581
  return undefined;
41159
40582
  if (typeof value === 'string')
@@ -41170,7 +40593,7 @@ const bytesToHex$2 = (value) => {
41170
40593
  };
41171
40594
  const getImageVersion$1 = (image) => { var _a; return (_a = image === null || image === void 0 ? void 0 : image.version) !== null && _a !== void 0 ? _a : null; };
41172
40595
  const getImageBuildId$1 = (image) => { var _a; return (_a = image === null || image === void 0 ? void 0 : image.build_id) !== null && _a !== void 0 ? _a : undefined; };
41173
- const getImageHash$1 = (image) => bytesToHex$2(image === null || image === void 0 ? void 0 : image.hash);
40596
+ const getImageHash$1 = (image) => bytesToHex$3(image === null || image === void 0 ? void 0 : image.hash);
41174
40597
  const shouldIncludeVerify = (scope) => scope === 'verify' || scope === 'full';
41175
40598
  const getDeviceMode = (features) => {
41176
40599
  if (!features)
@@ -41185,6 +40608,8 @@ const getDeviceMode = (features) => {
41185
40608
  };
41186
40609
  const getProtocolV2Mode = (deviceInfo) => {
41187
40610
  var _a;
40611
+ if (isProtocolV2BootloaderDeviceInfo(deviceInfo))
40612
+ return 'bootloader';
41188
40613
  const initialized = (_a = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.status) === null || _a === void 0 ? void 0 : _a.init_states;
41189
40614
  if (initialized === false)
41190
40615
  return 'notInitialized';
@@ -41207,49 +40632,56 @@ const normalizeV1Versions = (features, protocolV1OneKeyFeatures) => ({
41207
40632
  se04Boot: firstMeaningfulVersion$1(protocolV1OneKeyFeatures === null || protocolV1OneKeyFeatures === void 0 ? void 0 : protocolV1OneKeyFeatures.onekey_se04_boot_version, features === null || features === void 0 ? void 0 : features.se04BootVersion),
41208
40633
  });
41209
40634
  const normalizeV2Versions = (deviceInfo) => {
41210
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
41211
- return ({
41212
- firmware: firstMeaningfulVersion$1(getImageVersion$1((_a = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.fw) === null || _a === void 0 ? void 0 : _a.app)),
41213
- bootloader: firstMeaningfulVersion$1(getImageVersion$1((_b = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.fw) === null || _b === void 0 ? void 0 : _b.boot)),
41214
- board: firstMeaningfulVersion$1(getImageVersion$1((_c = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.fw) === null || _c === void 0 ? void 0 : _c.board)),
41215
- ble: firstMeaningfulVersion$1(getImageVersion$1((_d = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.bt) === null || _d === void 0 ? void 0 : _d.app)),
41216
- se01: firstMeaningfulVersion$1(getImageVersion$1((_e = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se1) === null || _e === void 0 ? void 0 : _e.app)),
41217
- se02: firstMeaningfulVersion$1(getImageVersion$1((_f = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se2) === null || _f === void 0 ? void 0 : _f.app)),
41218
- se03: firstMeaningfulVersion$1(getImageVersion$1((_g = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se3) === null || _g === void 0 ? void 0 : _g.app)),
41219
- se04: firstMeaningfulVersion$1(getImageVersion$1((_h = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se4) === null || _h === void 0 ? void 0 : _h.app)),
41220
- se01Boot: firstMeaningfulVersion$1(getImageVersion$1((_j = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se1) === null || _j === void 0 ? void 0 : _j.boot)),
41221
- se02Boot: firstMeaningfulVersion$1(getImageVersion$1((_k = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se2) === null || _k === void 0 ? void 0 : _k.boot)),
41222
- se03Boot: firstMeaningfulVersion$1(getImageVersion$1((_l = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se3) === null || _l === void 0 ? void 0 : _l.boot)),
41223
- se04Boot: firstMeaningfulVersion$1(getImageVersion$1((_m = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se4) === null || _m === void 0 ? void 0 : _m.boot)),
41224
- });
40635
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
40636
+ const info = deviceInfo;
40637
+ return {
40638
+ firmware: firstMeaningfulVersion$1(getImageVersion$1((_a = info === null || info === void 0 ? void 0 : info.fw) === null || _a === void 0 ? void 0 : _a.application)),
40639
+ bootloader: firstMeaningfulVersion$1(getImageVersion$1((_b = info === null || info === void 0 ? void 0 : info.fw) === null || _b === void 0 ? void 0 : _b.bootloader)),
40640
+ 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)),
40641
+ ble: firstMeaningfulVersion$1(getImageVersion$1((_f = info === null || info === void 0 ? void 0 : info.coprocessor) === null || _f === void 0 ? void 0 : _f.application)),
40642
+ se01: firstMeaningfulVersion$1(getImageVersion$1((_g = info === null || info === void 0 ? void 0 : info.se1) === null || _g === void 0 ? void 0 : _g.application)),
40643
+ se02: firstMeaningfulVersion$1(getImageVersion$1((_h = info === null || info === void 0 ? void 0 : info.se2) === null || _h === void 0 ? void 0 : _h.application)),
40644
+ se03: firstMeaningfulVersion$1(getImageVersion$1((_j = info === null || info === void 0 ? void 0 : info.se3) === null || _j === void 0 ? void 0 : _j.application)),
40645
+ se04: firstMeaningfulVersion$1(getImageVersion$1((_k = info === null || info === void 0 ? void 0 : info.se4) === null || _k === void 0 ? void 0 : _k.application)),
40646
+ se01Boot: firstMeaningfulVersion$1(getImageVersion$1((_l = info === null || info === void 0 ? void 0 : info.se1) === null || _l === void 0 ? void 0 : _l.bootloader)),
40647
+ se02Boot: firstMeaningfulVersion$1(getImageVersion$1((_m = info === null || info === void 0 ? void 0 : info.se2) === null || _m === void 0 ? void 0 : _m.bootloader)),
40648
+ se03Boot: firstMeaningfulVersion$1(getImageVersion$1((_o = info === null || info === void 0 ? void 0 : info.se3) === null || _o === void 0 ? void 0 : _o.bootloader)),
40649
+ se04Boot: firstMeaningfulVersion$1(getImageVersion$1((_p = info === null || info === void 0 ? void 0 : info.se4) === null || _p === void 0 ? void 0 : _p.bootloader)),
40650
+ };
41225
40651
  };
41226
40652
  const normalizeV1Status = (features) => {
41227
- var _a, _b, _c, _d, _e, _f, _g, _h;
40653
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
41228
40654
  return ({
41229
40655
  mode: getDeviceMode(features),
41230
40656
  initialized: (_a = features === null || features === void 0 ? void 0 : features.initialized) !== null && _a !== void 0 ? _a : null,
41231
40657
  bootloaderMode: (_b = features === null || features === void 0 ? void 0 : features.bootloaderMode) !== null && _b !== void 0 ? _b : null,
41232
40658
  unlocked: (_c = features === null || features === void 0 ? void 0 : features.unlocked) !== null && _c !== void 0 ? _c : null,
41233
40659
  passphraseProtection: (_d = features === null || features === void 0 ? void 0 : features.passphraseProtection) !== null && _d !== void 0 ? _d : null,
41234
- backupRequired: (_e = features === null || features === void 0 ? void 0 : features.backupRequired) !== null && _e !== void 0 ? _e : null,
41235
- noBackup: (_f = features === null || features === void 0 ? void 0 : features.noBackup) !== null && _f !== void 0 ? _f : null,
41236
- language: (_g = features === null || features === void 0 ? void 0 : features.language) !== null && _g !== void 0 ? _g : null,
41237
- bleEnabled: (_h = features === null || features === void 0 ? void 0 : features.bleEnabled) !== null && _h !== void 0 ? _h : null,
40660
+ attachToPinEnabled: (_e = features === null || features === void 0 ? void 0 : features.attachToPinEnabled) !== null && _e !== void 0 ? _e : null,
40661
+ unlockedAttachPin: (_f = features === null || features === void 0 ? void 0 : features.unlockedAttachPin) !== null && _f !== void 0 ? _f : null,
40662
+ backupRequired: (_g = features === null || features === void 0 ? void 0 : features.backupRequired) !== null && _g !== void 0 ? _g : null,
40663
+ noBackup: (_h = features === null || features === void 0 ? void 0 : features.noBackup) !== null && _h !== void 0 ? _h : null,
40664
+ language: (_j = features === null || features === void 0 ? void 0 : features.language) !== null && _j !== void 0 ? _j : null,
40665
+ bleEnabled: (_k = features === null || features === void 0 ? void 0 : features.bleEnabled) !== null && _k !== void 0 ? _k : null,
41238
40666
  });
41239
40667
  };
41240
40668
  const normalizeV2Status = (deviceInfo) => {
41241
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
41242
- return ({
40669
+ var _a, _b, _c, _d, _e, _f;
40670
+ const status = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.status;
40671
+ const bootloaderMode = isProtocolV2BootloaderDeviceInfo(deviceInfo);
40672
+ return {
41243
40673
  mode: getProtocolV2Mode(deviceInfo),
41244
- initialized: (_b = (_a = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.status) === null || _a === void 0 ? void 0 : _a.init_states) !== null && _b !== void 0 ? _b : null,
41245
- bootloaderMode: false,
41246
- unlocked: null,
41247
- passphraseProtection: (_d = (_c = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.status) === null || _c === void 0 ? void 0 : _c.passphrase_protection) !== null && _d !== void 0 ? _d : null,
41248
- backupRequired: (_f = (_e = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.status) === null || _e === void 0 ? void 0 : _e.backup_required) !== null && _f !== void 0 ? _f : null,
40674
+ initialized: (_a = status === null || status === void 0 ? void 0 : status.init_states) !== null && _a !== void 0 ? _a : null,
40675
+ bootloaderMode,
40676
+ unlocked: (_b = status === null || status === void 0 ? void 0 : status.unlocked) !== null && _b !== void 0 ? _b : null,
40677
+ passphraseProtection: (_c = status === null || status === void 0 ? void 0 : status.passphrase_enabled) !== null && _c !== void 0 ? _c : null,
40678
+ attachToPinEnabled: (_d = status === null || status === void 0 ? void 0 : status.attach_to_pin_enabled) !== null && _d !== void 0 ? _d : null,
40679
+ unlockedAttachPin: (_e = status === null || status === void 0 ? void 0 : status.unlocked_by_attach_to_pin) !== null && _e !== void 0 ? _e : null,
40680
+ backupRequired: (_f = status === null || status === void 0 ? void 0 : status.backup_required) !== null && _f !== void 0 ? _f : null,
41249
40681
  noBackup: null,
41250
- language: (_h = (_g = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.status) === null || _g === void 0 ? void 0 : _g.language) !== null && _h !== void 0 ? _h : null,
41251
- bleEnabled: (_k = (_j = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.status) === null || _j === void 0 ? void 0 : _j.bt_enable) !== null && _k !== void 0 ? _k : null,
41252
- });
40682
+ language: null,
40683
+ bleEnabled: null,
40684
+ };
41253
40685
  };
41254
40686
  const normalizeV1Verify = (features, protocolV1OneKeyFeatures) => {
41255
40687
  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;
@@ -41281,33 +40713,34 @@ const normalizeV1Verify = (features, protocolV1OneKeyFeatures) => {
41281
40713
  });
41282
40714
  };
41283
40715
  const normalizeV2Verify = (deviceInfo) => {
41284
- 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;
41285
- return ({
41286
- firmwareBuildId: getImageBuildId$1((_a = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.fw) === null || _a === void 0 ? void 0 : _a.app),
41287
- firmwareHash: getImageHash$1((_b = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.fw) === null || _b === void 0 ? void 0 : _b.app),
41288
- bootloaderBuildId: getImageBuildId$1((_c = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.fw) === null || _c === void 0 ? void 0 : _c.boot),
41289
- bootloaderHash: getImageHash$1((_d = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.fw) === null || _d === void 0 ? void 0 : _d.boot),
41290
- boardBuildId: getImageBuildId$1((_e = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.fw) === null || _e === void 0 ? void 0 : _e.board),
41291
- boardHash: getImageHash$1((_f = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.fw) === null || _f === void 0 ? void 0 : _f.board),
41292
- bleBuildId: getImageBuildId$1((_g = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.bt) === null || _g === void 0 ? void 0 : _g.app),
41293
- bleHash: getImageHash$1((_h = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.bt) === null || _h === void 0 ? void 0 : _h.app),
41294
- se01BuildId: getImageBuildId$1((_j = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se1) === null || _j === void 0 ? void 0 : _j.app),
41295
- se01Hash: getImageHash$1((_k = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se1) === null || _k === void 0 ? void 0 : _k.app),
41296
- se02BuildId: getImageBuildId$1((_l = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se2) === null || _l === void 0 ? void 0 : _l.app),
41297
- se02Hash: getImageHash$1((_m = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se2) === null || _m === void 0 ? void 0 : _m.app),
41298
- se03BuildId: getImageBuildId$1((_o = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se3) === null || _o === void 0 ? void 0 : _o.app),
41299
- se03Hash: getImageHash$1((_p = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se3) === null || _p === void 0 ? void 0 : _p.app),
41300
- se04BuildId: getImageBuildId$1((_q = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se4) === null || _q === void 0 ? void 0 : _q.app),
41301
- se04Hash: getImageHash$1((_r = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se4) === null || _r === void 0 ? void 0 : _r.app),
41302
- se01BootBuildId: getImageBuildId$1((_s = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se1) === null || _s === void 0 ? void 0 : _s.boot),
41303
- se01BootHash: getImageHash$1((_t = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se1) === null || _t === void 0 ? void 0 : _t.boot),
41304
- se02BootBuildId: getImageBuildId$1((_u = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se2) === null || _u === void 0 ? void 0 : _u.boot),
41305
- se02BootHash: getImageHash$1((_v = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se2) === null || _v === void 0 ? void 0 : _v.boot),
41306
- se03BootBuildId: getImageBuildId$1((_w = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se3) === null || _w === void 0 ? void 0 : _w.boot),
41307
- se03BootHash: getImageHash$1((_x = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se3) === null || _x === void 0 ? void 0 : _x.boot),
41308
- se04BootBuildId: getImageBuildId$1((_y = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se4) === null || _y === void 0 ? void 0 : _y.boot),
41309
- se04BootHash: getImageHash$1((_z = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se4) === null || _z === void 0 ? void 0 : _z.boot),
41310
- });
40716
+ 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;
40717
+ const info = deviceInfo;
40718
+ return {
40719
+ firmwareBuildId: getImageBuildId$1((_a = info === null || info === void 0 ? void 0 : info.fw) === null || _a === void 0 ? void 0 : _a.application),
40720
+ firmwareHash: getImageHash$1((_b = info === null || info === void 0 ? void 0 : info.fw) === null || _b === void 0 ? void 0 : _b.application),
40721
+ bootloaderBuildId: getImageBuildId$1((_c = info === null || info === void 0 ? void 0 : info.fw) === null || _c === void 0 ? void 0 : _c.bootloader),
40722
+ bootloaderHash: getImageHash$1((_d = info === null || info === void 0 ? void 0 : info.fw) === null || _d === void 0 ? void 0 : _d.bootloader),
40723
+ 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),
40724
+ 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),
40725
+ bleBuildId: getImageBuildId$1((_l = info === null || info === void 0 ? void 0 : info.coprocessor) === null || _l === void 0 ? void 0 : _l.application),
40726
+ bleHash: getImageHash$1((_m = info === null || info === void 0 ? void 0 : info.coprocessor) === null || _m === void 0 ? void 0 : _m.application),
40727
+ se01BuildId: getImageBuildId$1((_o = info === null || info === void 0 ? void 0 : info.se1) === null || _o === void 0 ? void 0 : _o.application),
40728
+ se01Hash: getImageHash$1((_p = info === null || info === void 0 ? void 0 : info.se1) === null || _p === void 0 ? void 0 : _p.application),
40729
+ se02BuildId: getImageBuildId$1((_q = info === null || info === void 0 ? void 0 : info.se2) === null || _q === void 0 ? void 0 : _q.application),
40730
+ se02Hash: getImageHash$1((_r = info === null || info === void 0 ? void 0 : info.se2) === null || _r === void 0 ? void 0 : _r.application),
40731
+ se03BuildId: getImageBuildId$1((_s = info === null || info === void 0 ? void 0 : info.se3) === null || _s === void 0 ? void 0 : _s.application),
40732
+ se03Hash: getImageHash$1((_t = info === null || info === void 0 ? void 0 : info.se3) === null || _t === void 0 ? void 0 : _t.application),
40733
+ se04BuildId: getImageBuildId$1((_u = info === null || info === void 0 ? void 0 : info.se4) === null || _u === void 0 ? void 0 : _u.application),
40734
+ se04Hash: getImageHash$1((_v = info === null || info === void 0 ? void 0 : info.se4) === null || _v === void 0 ? void 0 : _v.application),
40735
+ se01BootBuildId: getImageBuildId$1((_w = info === null || info === void 0 ? void 0 : info.se1) === null || _w === void 0 ? void 0 : _w.bootloader),
40736
+ se01BootHash: getImageHash$1((_x = info === null || info === void 0 ? void 0 : info.se1) === null || _x === void 0 ? void 0 : _x.bootloader),
40737
+ se02BootBuildId: getImageBuildId$1((_y = info === null || info === void 0 ? void 0 : info.se2) === null || _y === void 0 ? void 0 : _y.bootloader),
40738
+ se02BootHash: getImageHash$1((_z = info === null || info === void 0 ? void 0 : info.se2) === null || _z === void 0 ? void 0 : _z.bootloader),
40739
+ se03BootBuildId: getImageBuildId$1((_0 = info === null || info === void 0 ? void 0 : info.se3) === null || _0 === void 0 ? void 0 : _0.bootloader),
40740
+ se03BootHash: getImageHash$1((_1 = info === null || info === void 0 ? void 0 : info.se3) === null || _1 === void 0 ? void 0 : _1.bootloader),
40741
+ se04BootBuildId: getImageBuildId$1((_2 = info === null || info === void 0 ? void 0 : info.se4) === null || _2 === void 0 ? void 0 : _2.bootloader),
40742
+ se04BootHash: getImageHash$1((_3 = info === null || info === void 0 ? void 0 : info.se4) === null || _3 === void 0 ? void 0 : _3.bootloader),
40743
+ };
41311
40744
  };
41312
40745
  const normalizeRaw = ({ features, protocolV1OneKeyFeatures, protocolV2DeviceInfo, }) => (Object.assign(Object.assign(Object.assign({}, (features ? { features } : {})), (protocolV1OneKeyFeatures ? { protocolV1OneKeyFeatures } : {})), (protocolV2DeviceInfo ? { protocolV2DeviceInfo } : {})));
41313
40746
  function buildProfileFromProtocolV1({ protocol = 'V1', features, protocolV1OneKeyFeatures, sources = ['features'], scope = 'basic', includeRaw = false, }) {
@@ -41324,11 +40757,12 @@ function buildProfileFromProtocolV1({ protocol = 'V1', features, protocolV1OneKe
41324
40757
  : {}));
41325
40758
  }
41326
40759
  function buildProfileFromProtocolV2({ deviceInfo, sources = ['deviceInfo'], scope = 'basic', includeRaw = false, }) {
41327
- var _a, _b, _c, _d, _e, _f;
41328
- const deviceId = ((_a = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.hw) === null || _a === void 0 ? void 0 : _a.device_id) || '';
40760
+ var _a, _b, _c, _d;
40761
+ const info = deviceInfo;
40762
+ const deviceId = ((_a = info === null || info === void 0 ? void 0 : info.status) === null || _a === void 0 ? void 0 : _a.device_id) || '';
41329
40763
  const serialNo = ((_b = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.hw) === null || _b === void 0 ? void 0 : _b.serial_no) || '';
41330
- const label = (_d = (_c = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.status) === null || _c === void 0 ? void 0 : _c.label) !== null && _d !== void 0 ? _d : null;
41331
- const bleName = (_f = (_e = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.bt) === null || _e === void 0 ? void 0 : _e.adv_name) !== null && _f !== void 0 ? _f : null;
40764
+ const label = null;
40765
+ const bleName = (_d = (_c = info === null || info === void 0 ? void 0 : info.coprocessor) === null || _c === void 0 ? void 0 : _c.bt_adv_name) !== null && _d !== void 0 ? _d : null;
41332
40766
  const verify = normalizeV2Verify(deviceInfo);
41333
40767
  return Object.assign(Object.assign({ protocol: 'V2', sources, deviceType: hdShared.EDeviceType.Pro2, firmwareType: hdShared.EFirmwareType.Universal, deviceId,
41334
40768
  serialNo,
@@ -41343,7 +40777,7 @@ function buildProfileFromProtocolV2({ deviceInfo, sources = ['deviceInfo'], scop
41343
40777
  }
41344
40778
 
41345
40779
  const getImageVersion = (image) => { var _a; return (_a = image === null || image === void 0 ? void 0 : image.version) !== null && _a !== void 0 ? _a : null; };
41346
- const bytesToHex$1 = (value) => {
40780
+ const bytesToHex$2 = (value) => {
41347
40781
  if (!value)
41348
40782
  return undefined;
41349
40783
  if (typeof value === 'string')
@@ -41359,7 +40793,7 @@ const bytesToHex$1 = (value) => {
41359
40793
  return undefined;
41360
40794
  };
41361
40795
  const getImageBuildId = (image) => { var _a; return (_a = image === null || image === void 0 ? void 0 : image.build_id) !== null && _a !== void 0 ? _a : undefined; };
41362
- const getImageHash = (image) => bytesToHex$1(image === null || image === void 0 ? void 0 : image.hash);
40796
+ const getImageHash = (image) => bytesToHex$2(image === null || image === void 0 ? void 0 : image.hash);
41363
40797
  const firstValue = (...values) => values.find(value => value !== undefined && value !== null);
41364
40798
  const firstMeaningfulVersion = (...versions) => { var _a; return (_a = versions.find(version => Boolean(version && version !== '0.0.0'))) !== null && _a !== void 0 ? _a : null; };
41365
40799
  const versionFromParts = (major, minor, patch) => [major, minor, patch].map(part => Number(part) || 0).join('.');
@@ -41518,30 +40952,42 @@ const buildProtocolV1FeaturesPayload = (protocolV1Features, previous) => {
41518
40952
  };
41519
40953
  };
41520
40954
  const buildProtocolV2FeaturesPayload = (deviceInfo, previous) => {
41521
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63, _64, _65, _66, _67, _68, _69, _70, _71, _72, _73, _74, _75, _76, _77, _78, _79;
40955
+ 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;
41522
40956
  const info = deviceInfo;
41523
- const fwApplication = firstValue((_a = info === null || info === void 0 ? void 0 : info.fw) === null || _a === void 0 ? void 0 : _a.application, (_b = info === null || info === void 0 ? void 0 : info.fw) === null || _b === void 0 ? void 0 : _b.app);
41524
- const fwBootloader = firstValue((_c = info === null || info === void 0 ? void 0 : info.fw) === null || _c === void 0 ? void 0 : _c.bootloader, (_d = info === null || info === void 0 ? void 0 : info.fw) === null || _d === void 0 ? void 0 : _d.boot);
41525
- const fwBoard = firstValue((_e = info === null || info === void 0 ? void 0 : info.fw) === null || _e === void 0 ? void 0 : _e.application_data, (_f = info === null || info === void 0 ? void 0 : info.fw) === null || _f === void 0 ? void 0 : _f.board);
41526
- const bleApplication = firstValue((_g = info === null || info === void 0 ? void 0 : info.coprocessor) === null || _g === void 0 ? void 0 : _g.application, (_h = info === null || info === void 0 ? void 0 : info.bt) === null || _h === void 0 ? void 0 : _h.app);
40957
+ const fwApplication = (_a = info === null || info === void 0 ? void 0 : info.fw) === null || _a === void 0 ? void 0 : _a.application;
40958
+ const fwBootloader = (_b = info === null || info === void 0 ? void 0 : info.fw) === null || _b === void 0 ? void 0 : _b.bootloader;
40959
+ 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);
40960
+ const bleApplication = (_e = info === null || info === void 0 ? void 0 : info.coprocessor) === null || _e === void 0 ? void 0 : _e.application;
40961
+ const status = info === null || info === void 0 ? void 0 : info.status;
41527
40962
  const firmwareVersion = firstMeaningfulVersion(getImageVersion(fwApplication), previous === null || previous === void 0 ? void 0 : previous.firmwareVersion);
41528
40963
  const bootloaderVersion = firstMeaningfulVersion(getImageVersion(fwBootloader), previous === null || previous === void 0 ? void 0 : previous.bootloaderVersion);
41529
40964
  const boardVersion = firstMeaningfulVersion(getImageVersion(fwBoard), previous === null || previous === void 0 ? void 0 : previous.boardVersion);
41530
40965
  const bleVersion = firstMeaningfulVersion(getImageVersion(bleApplication), previous === null || previous === void 0 ? void 0 : previous.bleVersion);
41531
- const deviceId = (_k = firstValue((_j = info === null || info === void 0 ? void 0 : info.hw) === null || _j === void 0 ? void 0 : _j.device_id, previous === null || previous === void 0 ? void 0 : previous.deviceId)) !== null && _k !== void 0 ? _k : null;
41532
- const serialNo = (_m = firstValue((_l = info === null || info === void 0 ? void 0 : info.hw) === null || _l === void 0 ? void 0 : _l.serial_no, previous === null || previous === void 0 ? void 0 : previous.serialNo)) !== null && _m !== void 0 ? _m : '';
41533
- const label = (_p = firstValue((_o = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.status) === null || _o === void 0 ? void 0 : _o.label, previous === null || previous === void 0 ? void 0 : previous.label)) !== null && _p !== void 0 ? _p : null;
41534
- const bleName = firstValue((_q = info === null || info === void 0 ? void 0 : info.coprocessor) === null || _q === void 0 ? void 0 : _q.bt_adv_name, (_r = info === null || info === void 0 ? void 0 : info.bt) === null || _r === void 0 ? void 0 : _r.adv_name, previous === null || previous === void 0 ? void 0 : previous.bleName);
41535
- const initialized = (_t = firstValue((_s = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.status) === null || _s === void 0 ? void 0 : _s.init_states, previous === null || previous === void 0 ? void 0 : previous.initialized)) !== null && _t !== void 0 ? _t : null;
41536
- const passphraseProtection = (_v = firstValue((_u = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.status) === null || _u === void 0 ? void 0 : _u.passphrase_protection, previous === null || previous === void 0 ? void 0 : previous.passphraseProtection)) !== null && _v !== void 0 ? _v : null;
41537
- const language = (_x = firstValue((_w = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.status) === null || _w === void 0 ? void 0 : _w.language, previous === null || previous === void 0 ? void 0 : previous.language)) !== null && _x !== void 0 ? _x : null;
41538
- const backupRequired = (_z = firstValue((_y = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.status) === null || _y === void 0 ? void 0 : _y.backup_required, previous === null || previous === void 0 ? void 0 : previous.backupRequired)) !== null && _z !== void 0 ? _z : null;
41539
- const bleEnabled = firstValue((_0 = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.status) === null || _0 === void 0 ? void 0 : _0.bt_enable, previous === null || previous === void 0 ? void 0 : previous.bleEnabled);
40966
+ const deviceId = (_f = status === null || status === void 0 ? void 0 : status.device_id) !== null && _f !== void 0 ? _f : null;
40967
+ 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 : '';
40968
+ const label = (_j = previous === null || previous === void 0 ? void 0 : previous.label) !== null && _j !== void 0 ? _j : null;
40969
+ 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);
40970
+ 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;
40971
+ const passphraseProtection = (_m = status === null || status === void 0 ? void 0 : status.passphrase_enabled) !== null && _m !== void 0 ? _m : null;
40972
+ const language = (_o = previous === null || previous === void 0 ? void 0 : previous.language) !== null && _o !== void 0 ? _o : null;
40973
+ 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;
40974
+ const bleEnabled = previous === null || previous === void 0 ? void 0 : previous.bleEnabled;
40975
+ 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;
40976
+ const attachToPinEnabled = (_r = status === null || status === void 0 ? void 0 : status.attach_to_pin_enabled) !== null && _r !== void 0 ? _r : null;
40977
+ const unlockedAttachPin = (_s = status === null || status === void 0 ? void 0 : status.unlocked_by_attach_to_pin) !== null && _s !== void 0 ? _s : undefined;
40978
+ const bootloaderMode = isProtocolV2BootloaderDeviceInfo(info);
40979
+ const mode = bootloaderMode
40980
+ ? 'bootloader'
40981
+ : initialized === false
40982
+ ? 'notInitialized'
40983
+ : initialized === true
40984
+ ? 'normal'
40985
+ : 'unknown';
41540
40986
  return {
41541
40987
  protocol: 'V2',
41542
- protocolVersion: (_2 = (_1 = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.protocol_version) !== null && _1 !== void 0 ? _1 : previous === null || previous === void 0 ? void 0 : previous.protocolVersion) !== null && _2 !== void 0 ? _2 : null,
40988
+ 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,
41543
40989
  deviceType: hdShared.EDeviceType.Pro2,
41544
- firmwareType: (_3 = previous === null || previous === void 0 ? void 0 : previous.firmwareType) !== null && _3 !== void 0 ? _3 : hdShared.EFirmwareType.Universal,
40990
+ firmwareType: (_v = previous === null || previous === void 0 ? void 0 : previous.firmwareType) !== null && _v !== void 0 ? _v : hdShared.EFirmwareType.Universal,
41545
40991
  model: 'pro2',
41546
40992
  vendor: 'onekey.so',
41547
40993
  deviceId,
@@ -41549,11 +40995,11 @@ const buildProtocolV2FeaturesPayload = (deviceInfo, previous) => {
41549
40995
  label,
41550
40996
  bleName: bleName !== null && bleName !== void 0 ? bleName : null,
41551
40997
  capabilities: [],
41552
- mode: initialized === false ? 'notInitialized' : initialized === true ? 'normal' : 'unknown',
40998
+ mode,
41553
40999
  initialized,
41554
- bootloaderMode: false,
41555
- unlocked: (_4 = previous === null || previous === void 0 ? void 0 : previous.unlocked) !== null && _4 !== void 0 ? _4 : null,
41556
- firmwarePresent: (_5 = previous === null || previous === void 0 ? void 0 : previous.firmwarePresent) !== null && _5 !== void 0 ? _5 : null,
41000
+ bootloaderMode,
41001
+ unlocked,
41002
+ firmwarePresent: (_w = previous === null || previous === void 0 ? void 0 : previous.firmwarePresent) !== null && _w !== void 0 ? _w : null,
41557
41003
  passphraseProtection,
41558
41004
  pinProtection: null,
41559
41005
  backupRequired,
@@ -41566,6 +41012,7 @@ const buildProtocolV2FeaturesPayload = (deviceInfo, previous) => {
41566
41012
  sdProtection: null,
41567
41013
  wipeCodeProtection: null,
41568
41014
  passphraseAlwaysOnDevice: null,
41015
+ attachToPinEnabled,
41569
41016
  safetyChecks: null,
41570
41017
  autoLockDelayMs: null,
41571
41018
  displayRotation: null,
@@ -41574,44 +41021,44 @@ const buildProtocolV2FeaturesPayload = (deviceInfo, previous) => {
41574
41021
  bootloaderVersion,
41575
41022
  boardVersion,
41576
41023
  bleVersion,
41577
- se01Version: firstMeaningfulVersion(getImageVersion((_6 = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se1) === null || _6 === void 0 ? void 0 : _6.app), previous === null || previous === void 0 ? void 0 : previous.se01Version),
41578
- se02Version: firstMeaningfulVersion(getImageVersion((_7 = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se2) === null || _7 === void 0 ? void 0 : _7.app), previous === null || previous === void 0 ? void 0 : previous.se02Version),
41579
- se03Version: firstMeaningfulVersion(getImageVersion((_8 = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se3) === null || _8 === void 0 ? void 0 : _8.app), previous === null || previous === void 0 ? void 0 : previous.se03Version),
41580
- se04Version: firstMeaningfulVersion(getImageVersion((_9 = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se4) === null || _9 === void 0 ? void 0 : _9.app), previous === null || previous === void 0 ? void 0 : previous.se04Version),
41581
- se01BootVersion: firstMeaningfulVersion(getImageVersion((_10 = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se1) === null || _10 === void 0 ? void 0 : _10.boot), previous === null || previous === void 0 ? void 0 : previous.se01BootVersion),
41582
- se02BootVersion: firstMeaningfulVersion(getImageVersion((_11 = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se2) === null || _11 === void 0 ? void 0 : _11.boot), previous === null || previous === void 0 ? void 0 : previous.se02BootVersion),
41583
- se03BootVersion: firstMeaningfulVersion(getImageVersion((_12 = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se3) === null || _12 === void 0 ? void 0 : _12.boot), previous === null || previous === void 0 ? void 0 : previous.se03BootVersion),
41584
- se04BootVersion: firstMeaningfulVersion(getImageVersion((_13 = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se4) === null || _13 === void 0 ? void 0 : _13.boot), previous === null || previous === void 0 ? void 0 : previous.se04BootVersion),
41585
- seVersion: (_14 = previous === null || previous === void 0 ? void 0 : previous.seVersion) !== null && _14 !== void 0 ? _14 : null,
41024
+ 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),
41025
+ 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),
41026
+ 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),
41027
+ 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),
41028
+ 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),
41029
+ 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),
41030
+ 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),
41031
+ 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),
41032
+ seVersion: (_5 = previous === null || previous === void 0 ? void 0 : previous.seVersion) !== null && _5 !== void 0 ? _5 : null,
41586
41033
  verify: {
41587
- firmwareBuildId: (_15 = getImageBuildId(fwApplication)) !== null && _15 !== void 0 ? _15 : (_16 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _16 === void 0 ? void 0 : _16.firmwareBuildId,
41588
- firmwareHash: (_17 = getImageHash(fwApplication)) !== null && _17 !== void 0 ? _17 : (_18 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _18 === void 0 ? void 0 : _18.firmwareHash,
41589
- bootloaderBuildId: (_19 = getImageBuildId(fwBootloader)) !== null && _19 !== void 0 ? _19 : (_20 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _20 === void 0 ? void 0 : _20.bootloaderBuildId,
41590
- bootloaderHash: (_21 = getImageHash(fwBootloader)) !== null && _21 !== void 0 ? _21 : (_22 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _22 === void 0 ? void 0 : _22.bootloaderHash,
41591
- boardBuildId: (_23 = getImageBuildId(fwBoard)) !== null && _23 !== void 0 ? _23 : (_24 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _24 === void 0 ? void 0 : _24.boardBuildId,
41592
- boardHash: (_25 = getImageHash(fwBoard)) !== null && _25 !== void 0 ? _25 : (_26 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _26 === void 0 ? void 0 : _26.boardHash,
41593
- bleBuildId: (_27 = getImageBuildId(bleApplication)) !== null && _27 !== void 0 ? _27 : (_28 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _28 === void 0 ? void 0 : _28.bleBuildId,
41594
- bleHash: (_29 = getImageHash(bleApplication)) !== null && _29 !== void 0 ? _29 : (_30 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _30 === void 0 ? void 0 : _30.bleHash,
41595
- se01BuildId: (_32 = getImageBuildId((_31 = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se1) === null || _31 === void 0 ? void 0 : _31.app)) !== null && _32 !== void 0 ? _32 : (_33 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _33 === void 0 ? void 0 : _33.se01BuildId,
41596
- se01Hash: (_35 = getImageHash((_34 = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se1) === null || _34 === void 0 ? void 0 : _34.app)) !== null && _35 !== void 0 ? _35 : (_36 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _36 === void 0 ? void 0 : _36.se01Hash,
41597
- se02BuildId: (_38 = getImageBuildId((_37 = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se2) === null || _37 === void 0 ? void 0 : _37.app)) !== null && _38 !== void 0 ? _38 : (_39 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _39 === void 0 ? void 0 : _39.se02BuildId,
41598
- se02Hash: (_41 = getImageHash((_40 = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se2) === null || _40 === void 0 ? void 0 : _40.app)) !== null && _41 !== void 0 ? _41 : (_42 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _42 === void 0 ? void 0 : _42.se02Hash,
41599
- se03BuildId: (_44 = getImageBuildId((_43 = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se3) === null || _43 === void 0 ? void 0 : _43.app)) !== null && _44 !== void 0 ? _44 : (_45 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _45 === void 0 ? void 0 : _45.se03BuildId,
41600
- se03Hash: (_47 = getImageHash((_46 = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se3) === null || _46 === void 0 ? void 0 : _46.app)) !== null && _47 !== void 0 ? _47 : (_48 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _48 === void 0 ? void 0 : _48.se03Hash,
41601
- se04BuildId: (_50 = getImageBuildId((_49 = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se4) === null || _49 === void 0 ? void 0 : _49.app)) !== null && _50 !== void 0 ? _50 : (_51 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _51 === void 0 ? void 0 : _51.se04BuildId,
41602
- se04Hash: (_53 = getImageHash((_52 = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se4) === null || _52 === void 0 ? void 0 : _52.app)) !== null && _53 !== void 0 ? _53 : (_54 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _54 === void 0 ? void 0 : _54.se04Hash,
41603
- se01BootBuildId: (_56 = getImageBuildId((_55 = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se1) === null || _55 === void 0 ? void 0 : _55.boot)) !== null && _56 !== void 0 ? _56 : (_57 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _57 === void 0 ? void 0 : _57.se01BootBuildId,
41604
- se01BootHash: (_59 = getImageHash((_58 = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se1) === null || _58 === void 0 ? void 0 : _58.boot)) !== null && _59 !== void 0 ? _59 : (_60 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _60 === void 0 ? void 0 : _60.se01BootHash,
41605
- se02BootBuildId: (_62 = getImageBuildId((_61 = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se2) === null || _61 === void 0 ? void 0 : _61.boot)) !== null && _62 !== void 0 ? _62 : (_63 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _63 === void 0 ? void 0 : _63.se02BootBuildId,
41606
- se02BootHash: (_65 = getImageHash((_64 = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se2) === null || _64 === void 0 ? void 0 : _64.boot)) !== null && _65 !== void 0 ? _65 : (_66 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _66 === void 0 ? void 0 : _66.se02BootHash,
41607
- se03BootBuildId: (_68 = getImageBuildId((_67 = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se3) === null || _67 === void 0 ? void 0 : _67.boot)) !== null && _68 !== void 0 ? _68 : (_69 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _69 === void 0 ? void 0 : _69.se03BootBuildId,
41608
- se03BootHash: (_71 = getImageHash((_70 = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se3) === null || _70 === void 0 ? void 0 : _70.boot)) !== null && _71 !== void 0 ? _71 : (_72 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _72 === void 0 ? void 0 : _72.se03BootHash,
41609
- se04BootBuildId: (_74 = getImageBuildId((_73 = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se4) === null || _73 === void 0 ? void 0 : _73.boot)) !== null && _74 !== void 0 ? _74 : (_75 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _75 === void 0 ? void 0 : _75.se04BootBuildId,
41610
- se04BootHash: (_77 = getImageHash((_76 = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.se4) === null || _76 === void 0 ? void 0 : _76.boot)) !== null && _77 !== void 0 ? _77 : (_78 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _78 === void 0 ? void 0 : _78.se04BootHash,
41034
+ 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,
41035
+ 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,
41036
+ 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,
41037
+ 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,
41038
+ 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,
41039
+ 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,
41040
+ 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,
41041
+ 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,
41042
+ 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,
41043
+ 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,
41044
+ 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,
41045
+ 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,
41046
+ 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,
41047
+ 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,
41048
+ 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,
41049
+ 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,
41050
+ 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,
41051
+ 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,
41052
+ 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,
41053
+ 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,
41054
+ 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,
41055
+ 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,
41056
+ 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,
41057
+ 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,
41611
41058
  },
41612
- sessionId: (_79 = previous === null || previous === void 0 ? void 0 : previous.sessionId) !== null && _79 !== void 0 ? _79 : null,
41059
+ sessionId: (_70 = previous === null || previous === void 0 ? void 0 : previous.sessionId) !== null && _70 !== void 0 ? _70 : null,
41613
41060
  passphraseState: previous === null || previous === void 0 ? void 0 : previous.passphraseState,
41614
- unlockedAttachPin: previous === null || previous === void 0 ? void 0 : previous.unlockedAttachPin,
41061
+ unlockedAttachPin,
41615
41062
  raw: {
41616
41063
  protocolV2DeviceInfo: deviceInfo,
41617
41064
  },
@@ -41716,7 +41163,7 @@ class Device extends events.exports {
41716
41163
  resolve(false);
41717
41164
  }));
41718
41165
  }
41719
- acquire(connectProtocol) {
41166
+ acquire(connectProtocol, options) {
41720
41167
  var _a, _b, _c, _d, _e, _f, _g;
41721
41168
  return __awaiter(this, void 0, void 0, function* () {
41722
41169
  const env = DataManager.getSettings('env');
@@ -41746,6 +41193,9 @@ class Device extends events.exports {
41746
41193
  this.commands = new DeviceCommands(this, (_g = this.mainId) !== null && _g !== void 0 ? _g : '');
41747
41194
  }
41748
41195
  catch (error) {
41196
+ if (options === null || options === void 0 ? void 0 : options.throwOnRunPromiseError) {
41197
+ throw error;
41198
+ }
41749
41199
  if (this.runPromise) {
41750
41200
  this.runPromise.reject(error);
41751
41201
  }
@@ -42029,10 +41479,13 @@ class Device extends events.exports {
42029
41479
  if (this.isProtocolV2()) {
42030
41480
  this.passphraseState = options === null || options === void 0 ? void 0 : options.passphraseState;
42031
41481
  if (this.features && !this.featuresNeedsReload && !(options === null || options === void 0 ? void 0 : options.initSession)) {
42032
- yield this._refreshProtocolV2Status();
41482
+ if (this.features.bootloaderMode) {
41483
+ return;
41484
+ }
41485
+ yield this._refreshProtocolV2Status(options);
42033
41486
  return;
42034
41487
  }
42035
- yield this._initializeProtocolV2();
41488
+ yield this._initializeProtocolV2(options);
42036
41489
  return;
42037
41490
  }
42038
41491
  this.passphraseState = options === null || options === void 0 ? void 0 : options.passphraseState;
@@ -42070,12 +41523,13 @@ class Device extends events.exports {
42070
41523
  }
42071
41524
  });
42072
41525
  }
42073
- _initializeProtocolV2() {
41526
+ _initializeProtocolV2(options) {
42074
41527
  return __awaiter(this, void 0, void 0, function* () {
42075
41528
  Log$c.debug('Initialize device via Protocol V2 features adapter');
42076
41529
  try {
42077
41530
  const deviceInfo = yield requestProtocolV2DeviceInfo({
42078
41531
  commands: this.commands,
41532
+ timeoutMs: options === null || options === void 0 ? void 0 : options.protocolV2DeviceInfoTimeoutMs,
42079
41533
  });
42080
41534
  const features = this.updateProtocolV2Features(deviceInfo);
42081
41535
  Log$c.debug('Protocol V2 features:', features);
@@ -42087,12 +41541,13 @@ class Device extends events.exports {
42087
41541
  }
42088
41542
  });
42089
41543
  }
42090
- _refreshProtocolV2Status() {
41544
+ _refreshProtocolV2Status(options) {
42091
41545
  return __awaiter(this, void 0, void 0, function* () {
42092
41546
  try {
42093
41547
  const deviceInfo = yield requestProtocolV2DeviceInfo({
42094
41548
  commands: this.commands,
42095
41549
  request: PROTOCOL_V2_STATUS_DEVICE_INFO_REQUEST,
41550
+ timeoutMs: options === null || options === void 0 ? void 0 : options.protocolV2DeviceInfoTimeoutMs,
42096
41551
  });
42097
41552
  const features = this.updateProtocolV2Features(deviceInfo);
42098
41553
  Log$c.debug('Protocol V2 features (status refresh):', features);
@@ -42842,36 +42297,17 @@ class GetFeatures extends BaseMethod {
42842
42297
  }
42843
42298
 
42844
42299
  const ProtocolV2FirmwareTargetType = {
42845
- TARGET_MAIN_APP: 0,
42846
- TARGET_MAIN_BOOT: 1,
42847
- TARGET_BT: 2,
42848
- TARGET_SE1: 3,
42849
- TARGET_SE2: 4,
42850
- TARGET_SE3: 5,
42851
- TARGET_SE4: 6,
42852
- TARGET_RESOURCE: 10,
42300
+ FW_MGMT_TARGET_CRATE: 1,
42301
+ FW_MGMT_TARGET_ROMLOADER: 2,
42302
+ FW_MGMT_TARGET_BOOTLOADER: 3,
42303
+ FW_MGMT_TARGET_APPLICATION_P1: 4,
42304
+ FW_MGMT_TARGET_APPLICATION_P2: 5,
42305
+ FW_MGMT_TARGET_COPROCESSOR: 6,
42306
+ FW_MGMT_TARGET_SE01: 7,
42307
+ FW_MGMT_TARGET_SE02: 8,
42308
+ FW_MGMT_TARGET_SE03: 9,
42309
+ FW_MGMT_TARGET_SE04: 10,
42853
42310
  };
42854
- function protocolV2FileNameToTargetId(fileName) {
42855
- const normalized = fileName.toLowerCase();
42856
- if (normalized.includes('bootloader') || normalized.includes('update_rom')) {
42857
- return ProtocolV2FirmwareTargetType.TARGET_MAIN_BOOT;
42858
- }
42859
- if (normalized.includes('coprocessor') ||
42860
- normalized.includes('ble') ||
42861
- normalized.includes('bluetooth') ||
42862
- normalized.includes('bt')) {
42863
- return ProtocolV2FirmwareTargetType.TARGET_BT;
42864
- }
42865
- if (normalized.includes('se4'))
42866
- return ProtocolV2FirmwareTargetType.TARGET_SE4;
42867
- if (normalized.includes('se3'))
42868
- return ProtocolV2FirmwareTargetType.TARGET_SE3;
42869
- if (normalized.includes('se2'))
42870
- return ProtocolV2FirmwareTargetType.TARGET_SE2;
42871
- if (normalized.includes('se'))
42872
- return ProtocolV2FirmwareTargetType.TARGET_SE1;
42873
- return ProtocolV2FirmwareTargetType.TARGET_MAIN_APP;
42874
- }
42875
42311
 
42876
42312
  const DEVICE_INFO_SCOPES = ['basic', 'versions', 'verify', 'full'];
42877
42313
  function isDeviceInfoScope(scope) {
@@ -43428,7 +42864,7 @@ const formatAnyHex = value => {
43428
42864
  return value;
43429
42865
  };
43430
42866
  const hexes = Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, '0'));
43431
- function bytesToHex(uint8a) {
42867
+ function bytesToHex$1(uint8a) {
43432
42868
  if (!(uint8a instanceof Uint8Array))
43433
42869
  throw new Error('Uint8Array expected');
43434
42870
  let hex = '';
@@ -43626,8 +43062,8 @@ class DeviceRebootToBootloader extends BaseMethod {
43626
43062
  run() {
43627
43063
  return __awaiter(this, void 0, void 0, function* () {
43628
43064
  if (this.device.isProtocolV2()) {
43629
- const res = yield this.device.commands.typedCall('DevReboot', 'Success', {
43630
- reboot_type: hdTransport.DevRebootType.Bootloader,
43065
+ const res = yield this.device.commands.typedCall('DeviceReboot', 'Success', {
43066
+ reboot_type: hdTransport.DeviceRebootType.Bootloader,
43631
43067
  });
43632
43068
  return Promise.resolve(res.message);
43633
43069
  }
@@ -43655,8 +43091,8 @@ class DeviceRebootToBoardloader extends BaseMethod {
43655
43091
  run() {
43656
43092
  return __awaiter(this, void 0, void 0, function* () {
43657
43093
  if (this.device.isProtocolV2()) {
43658
- const res = yield this.device.commands.typedCall('DevReboot', 'Success', {
43659
- reboot_type: hdTransport.DevRebootType.Boardloader,
43094
+ const res = yield this.device.commands.typedCall('DeviceReboot', 'Success', {
43095
+ reboot_type: hdTransport.DeviceRebootType.Romloader,
43660
43096
  });
43661
43097
  return Promise.resolve(res.message);
43662
43098
  }
@@ -44164,7 +43600,7 @@ const uploadFirmware = (updateType, typedCall, postMessage, device, { payload, r
44164
43600
  const header = new Uint8Array(payload.slice(0, HEADER_SIZE));
44165
43601
  try {
44166
43602
  const headerRes = yield typedCall('UpgradeFileHeader', 'Success', {
44167
- data: bytesToHex(header),
43603
+ data: bytesToHex$1(header),
44168
43604
  });
44169
43605
  const isUnknownMessage = (_b = (_a = headerRes.message) === null || _a === void 0 ? void 0 : _a.message) === null || _b === void 0 ? void 0 : _b.includes('Failure_UnknownMessage');
44170
43606
  if (headerRes.type !== 'Success' && !isUnknownMessage) {
@@ -44413,8 +43849,8 @@ const processResourceRequest = (typedCall, res, data) => __awaiter(void 0, void
44413
43849
  const payload = new Uint8Array(data.slice(offset, Math.min(offset + data_length, data.byteLength)));
44414
43850
  const digest = blake2s.blake2s(payload);
44415
43851
  const resourceAckParams = {
44416
- data_chunk: bytesToHex(payload),
44417
- hash: bytesToHex(digest),
43852
+ data_chunk: bytesToHex$1(payload),
43853
+ hash: bytesToHex$1(digest),
44418
43854
  };
44419
43855
  const response = yield typedCall('ResourceAck', ['ResourceRequest', 'Success'], Object.assign({}, resourceAckParams));
44420
43856
  return processResourceRequest(typedCall, response, data);
@@ -44425,8 +43861,8 @@ const updateResource = (typedCall, fileName, data, onConfirmAfter) => __awaiter(
44425
43861
  const res = yield typedCall('ResourceUpdate', ['ResourceRequest', 'Success'], {
44426
43862
  file_name: fileName,
44427
43863
  data_length: data.byteLength,
44428
- initial_data_chunk: bytesToHex(chunk),
44429
- hash: bytesToHex(digest),
43864
+ initial_data_chunk: bytesToHex$1(chunk),
43865
+ hash: bytesToHex$1(digest),
44430
43866
  });
44431
43867
  onConfirmAfter === null || onConfirmAfter === void 0 ? void 0 : onConfirmAfter();
44432
43868
  return processResourceRequest(typedCall, res, data);
@@ -44599,6 +44035,8 @@ class FirmwareUpdateBaseMethod extends BaseMethod {
44599
44035
  Log$8.log('FirmwareUpdateBaseMethod [checkDeviceToBootloader] isBleReconnect: ', isBleReconnect);
44600
44036
  let isFirstCheck = true;
44601
44037
  let checkCount = 0;
44038
+ let hasPromptedWebDevice = false;
44039
+ let isPromptingWebDevice = false;
44602
44040
  let timeoutTimer;
44603
44041
  const isTouchOrProDevice = ((_a = this === null || this === void 0 ? void 0 : this.device) === null || _a === void 0 ? void 0 : _a.getCurrentDeviceType()) === hdShared.EDeviceType.Touch ||
44604
44042
  ((_b = this === null || this === void 0 ? void 0 : this.device) === null || _b === void 0 ? void 0 : _b.getCurrentDeviceType()) === hdShared.EDeviceType.Pro;
@@ -44613,20 +44051,27 @@ class FirmwareUpdateBaseMethod extends BaseMethod {
44613
44051
  }
44614
44052
  if (checkCount > 4 &&
44615
44053
  DataManager.isBrowserWebUsb(DataManager.getSettings('env')) &&
44616
- !this.payload.skipWebDevicePrompt) {
44617
- clearInterval(intervalTimer);
44618
- clearTimeout(timeoutTimer);
44054
+ !this.payload.skipWebDevicePrompt &&
44055
+ !hasPromptedWebDevice &&
44056
+ !isPromptingWebDevice) {
44057
+ isPromptingWebDevice = true;
44619
44058
  try {
44620
44059
  this.postTipMessage(exports.FirmwareUpdateTipMessage.SelectDeviceInBootloaderForWebDevice);
44621
44060
  const confirmed = yield this._promptDeviceInBootloaderForWebDevice();
44061
+ hasPromptedWebDevice = true;
44622
44062
  if (confirmed) {
44623
44063
  yield this._checkDeviceInBootloaderMode(connectId, intervalTimer, timeoutTimer);
44624
44064
  }
44625
44065
  }
44626
44066
  catch (e) {
44067
+ clearInterval(intervalTimer);
44068
+ clearTimeout(timeoutTimer);
44627
44069
  Log$8.log('FirmwareUpdateBaseMethod [checkDeviceToBootloader] _promptDeviceInBootloaderForWebDevice failed: ', e);
44628
44070
  (_c = this.checkPromise) === null || _c === void 0 ? void 0 : _c.reject(e);
44629
44071
  }
44072
+ finally {
44073
+ isPromptingWebDevice = false;
44074
+ }
44630
44075
  return;
44631
44076
  }
44632
44077
  if (isBleReconnect) {
@@ -45889,20 +45334,20 @@ function validateRequiredData(value, name) {
45889
45334
  }
45890
45335
  }
45891
45336
 
45892
- const DEV_REBOOT_TYPES = {
45893
- Normal: hdTransport.DevRebootType.Normal,
45894
- normal: hdTransport.DevRebootType.Normal,
45895
- Romloader: hdTransport.DevRebootType.Boardloader,
45896
- romloader: hdTransport.DevRebootType.Boardloader,
45897
- Boardloader: hdTransport.DevRebootType.Boardloader,
45898
- boardloader: hdTransport.DevRebootType.Boardloader,
45899
- Bootloader: hdTransport.DevRebootType.Bootloader,
45900
- bootloader: hdTransport.DevRebootType.Bootloader,
45337
+ const DEVICE_REBOOT_TYPES = {
45338
+ Normal: hdTransport.DeviceRebootType.Normal,
45339
+ normal: hdTransport.DeviceRebootType.Normal,
45340
+ Romloader: hdTransport.DeviceRebootType.Romloader,
45341
+ romloader: hdTransport.DeviceRebootType.Romloader,
45342
+ Boardloader: hdTransport.DeviceRebootType.Romloader,
45343
+ boardloader: hdTransport.DeviceRebootType.Romloader,
45344
+ Bootloader: hdTransport.DeviceRebootType.Bootloader,
45345
+ bootloader: hdTransport.DeviceRebootType.Bootloader,
45901
45346
  };
45902
45347
  const PROTOCOL_V2_FIRMWARE_UPDATE_OPTIONS = {
45903
- intermediateTypes: ['DevFirmwareInstallProgress'],
45348
+ intermediateTypes: ['DeviceFirmwareUpdateStatus'],
45904
45349
  };
45905
- const PROTOCOL_V2_FIRMWARE_UPDATE_RESPONSE_TYPES = ['Success', 'DevFirmwareUpdateStatus'];
45350
+ const PROTOCOL_V2_FIRMWARE_UPDATE_RESPONSE_TYPES = ['Success', 'DeviceFirmwareUpdateStatus'];
45906
45351
  const getProtocolV2UnknownErrorText = (error) => {
45907
45352
  if (!error) {
45908
45353
  return '';
@@ -45959,17 +45404,21 @@ function normalizeRebootType(value) {
45959
45404
  const numeric = Number(value);
45960
45405
  if (Number.isFinite(numeric))
45961
45406
  return numeric;
45962
- if (value in DEV_REBOOT_TYPES)
45963
- return DEV_REBOOT_TYPES[value];
45407
+ if (value in DEVICE_REBOOT_TYPES)
45408
+ return DEVICE_REBOOT_TYPES[value];
45964
45409
  }
45965
- return hdTransport.DevRebootType.Normal;
45410
+ return hdTransport.DeviceRebootType.Normal;
45966
45411
  }
45967
- const VALID_FIRMWARE_TARGET_IDS = new Set([0, 1, 2, 3, 4, 5, 6, 10]);
45412
+ const VALID_FIRMWARE_TARGET_IDS = new Set(Object.values(ProtocolV2FirmwareTargetType).filter(value => typeof value === 'number'));
45413
+ const FIRMWARE_TARGET_ID_BY_NAME = new Map(Object.entries(ProtocolV2FirmwareTargetType).flatMap(([key, value]) => VALID_FIRMWARE_TARGET_IDS.has(value)
45414
+ ? [[key, value]]
45415
+ : []));
45968
45416
  function normalizeTargetId(value, name) {
45969
45417
  if (value === undefined || value === null) {
45970
45418
  throw invalidParameter(`Missing required parameter: ${name}`);
45971
45419
  }
45972
- const numeric = typeof value === 'number' ? value : Number(value);
45420
+ const named = typeof value === 'string' ? FIRMWARE_TARGET_ID_BY_NAME.get(value) : undefined;
45421
+ const numeric = named !== null && named !== void 0 ? named : (typeof value === 'number' ? value : Number(value));
45973
45422
  if (Number.isSafeInteger(numeric) && VALID_FIRMWARE_TARGET_IDS.has(numeric)) {
45974
45423
  return numeric;
45975
45424
  }
@@ -46007,13 +45456,101 @@ const Log$4 = getLogger(exports.LoggerNames.Method);
46007
45456
  const SESSION_ERROR = 'session not found';
46008
45457
  const PROTOCOL_V2_BOOTLOADER_RECONNECT_TIMEOUT = 60 * 1000;
46009
45458
  const PROTOCOL_V2_SHORT_RESPONSE_TIMEOUT = 5 * 1000;
45459
+ const PROTOCOL_V2_START_UPDATE_TIMEOUT = 60 * 1000;
46010
45460
  const PROTOCOL_V2_INSTALL_TIMEOUT = 5 * 60 * 1000;
46011
- const PROTOCOL_V2_TARGET_STATUS_FINISHED = 0;
45461
+ const PROTOCOL_V2_TARGET_STATUS_PENDING = 0;
46012
45462
  const PROTOCOL_V2_TARGET_STATUS_IN_PROGRESS = 1;
46013
- const PROTOCOL_V2_TARGET_STATUS_FAILED = 2;
45463
+ const PROTOCOL_V2_TARGET_STATUS_FINISHED = 2;
45464
+ const PROTOCOL_V2_TARGET_STATUS_FAILED_MIN = 3;
46014
45465
  const PROTOCOL_V2_CONNECT_PROTOCOL = 'V2';
46015
45466
  const PROTOCOL_V2_FIRMWARE_STAGING_VOLUME = 'vol1:';
46016
45467
  const PROTOCOL_V2_MIN_FILE_CHUNK_SIZE = 64;
45468
+ const PROTOCOL_V2_CONNECT_RETRY_COUNT = 10;
45469
+ const PROTOCOL_V2_CONNECT_POLL_INTERVAL = 500;
45470
+ const PROTOCOL_V2_CONNECT_SINGLE_TIMEOUT = 75 * 1000;
45471
+ const PROTOCOL_V2_DEVICE_INFO_READY_TIMEOUT = 60 * 1000;
45472
+ const PROTOCOL_V2_OKPP_HEADER_SIZE = 0x52a0;
45473
+ const PROTOCOL_V2_OKPP_PAYLOAD_HASH_OFFSET = 0x200;
45474
+ const PROTOCOL_V2_OKPP_HEADER_HASH_OFFSET = 0x240;
45475
+ const PROTOCOL_V2_OKPP_HASH_SIZE = 64;
45476
+ const getProtocolV2DeviceTransferProgress = (bytesBeforeChunk, bytesAfterChunk, totalBytes) => {
45477
+ if (!Number.isFinite(totalBytes) || totalBytes <= 0) {
45478
+ return 100;
45479
+ }
45480
+ if (bytesBeforeChunk <= 0 && bytesAfterChunk < totalBytes) {
45481
+ return 0;
45482
+ }
45483
+ if (bytesAfterChunk >= totalBytes) {
45484
+ return 100;
45485
+ }
45486
+ return Math.min(Math.max(Math.ceil((bytesAfterChunk / totalBytes) * 100), 1), 99);
45487
+ };
45488
+ const formatProtocolV2TransferSpeed = (bytes, elapsedMs) => {
45489
+ const safeElapsedMs = Math.max(elapsedMs, 1);
45490
+ return (bytes / 1024 / (safeElapsedMs / 1000)).toFixed(2);
45491
+ };
45492
+ const PROTOCOL_V2_REMOTE_COMPONENT_TARGETS = {
45493
+ BOOTLOADER: {
45494
+ fileName: 'bootloader.bin',
45495
+ targetId: ProtocolV2FirmwareTargetType.FW_MGMT_TARGET_BOOTLOADER,
45496
+ kind: 'bootloader',
45497
+ },
45498
+ APPLICATION_P1: {
45499
+ fileName: 'application_p1.bin',
45500
+ targetId: ProtocolV2FirmwareTargetType.FW_MGMT_TARGET_APPLICATION_P1,
45501
+ kind: 'firmware',
45502
+ },
45503
+ APPLICATION_P2: {
45504
+ fileName: 'application_p2.bin',
45505
+ targetId: ProtocolV2FirmwareTargetType.FW_MGMT_TARGET_APPLICATION_P2,
45506
+ kind: 'firmware',
45507
+ },
45508
+ COPROCESSOR: {
45509
+ fileName: 'coprocessor.bin',
45510
+ targetId: ProtocolV2FirmwareTargetType.FW_MGMT_TARGET_COPROCESSOR,
45511
+ kind: 'firmware',
45512
+ },
45513
+ SE01: {
45514
+ fileName: 'se01.bin',
45515
+ targetId: ProtocolV2FirmwareTargetType.FW_MGMT_TARGET_SE01,
45516
+ kind: 'firmware',
45517
+ },
45518
+ SE02: {
45519
+ fileName: 'se02.bin',
45520
+ targetId: ProtocolV2FirmwareTargetType.FW_MGMT_TARGET_SE02,
45521
+ kind: 'firmware',
45522
+ },
45523
+ SE03: {
45524
+ fileName: 'se03.bin',
45525
+ targetId: ProtocolV2FirmwareTargetType.FW_MGMT_TARGET_SE03,
45526
+ kind: 'firmware',
45527
+ },
45528
+ SE04: {
45529
+ fileName: 'se04.bin',
45530
+ targetId: ProtocolV2FirmwareTargetType.FW_MGMT_TARGET_SE04,
45531
+ kind: 'firmware',
45532
+ },
45533
+ CRATE: {
45534
+ fileName: 'resource.bin',
45535
+ targetId: ProtocolV2FirmwareTargetType.FW_MGMT_TARGET_CRATE,
45536
+ kind: 'resource',
45537
+ },
45538
+ };
45539
+ const PROTOCOL_V2_ROMLOADER_UNSUPPORTED_MESSAGE = 'FW_MGMT_TARGET_ROMLOADER is not accepted by the current Pro2 bootloader update request. Flash romloader with the loader-specific flow instead of firmwareUpdateV4.';
45540
+ const PROTOCOL_V2_TARGET_ID_BY_DECODED_NAME = new Map(Object.entries(ProtocolV2FirmwareTargetType).map(([key, value]) => [key, value]));
45541
+ const PROTOCOL_V2_TARGET_STATUS_BY_DECODED_NAME = new Map([
45542
+ ['FW_MGMT_UPDATER_TASK_STATUS_PENDING', PROTOCOL_V2_TARGET_STATUS_PENDING],
45543
+ ['FW_MGMT_UPDATER_TASK_STATUS_IN_PROGRESS', PROTOCOL_V2_TARGET_STATUS_IN_PROGRESS],
45544
+ ['FW_MGMT_UPDATER_TASK_STATUS_FINISHED', PROTOCOL_V2_TARGET_STATUS_FINISHED],
45545
+ ['FW_MGMT_UPDATER_TASK_STATUS_FAILED_FILE_NOT_FOUND', 3],
45546
+ ['FW_MGMT_UPDATER_TASK_STATUS_FAILED_FILE_READ', 4],
45547
+ ['FW_MGMT_UPDATER_TASK_STATUS_FAILED_FILE_WRITE', 5],
45548
+ ['FW_MGMT_UPDATER_TASK_STATUS_FAILED_VERIFY', 6],
45549
+ ['FW_MGMT_UPDATER_TASK_STATUS_FAILED_INSTALL', 7],
45550
+ ['FW_MGMT_UPDATER_TASK_STATUS_FAILED_ABORT', 8],
45551
+ ['FW_MGMT_UPDATER_TASK_STATUS_FAILED_BUSY', 9],
45552
+ ['FW_MGMT_UPDATER_TASK_STATUS_FAILED_ENTRY_OUT_OF_BOUNDS', 10],
45553
+ ]);
46017
45554
  const isProtocolV2ReconnectProbeError = (error) => {
46018
45555
  const message = getProtocolV2UnknownErrorText(error).toLowerCase();
46019
45556
  return ((message.includes('device protocol mismatch') && message.includes('expected v2')) ||
@@ -46023,10 +45560,127 @@ const isProtocolV2PollingTransientError = (error) => {
46023
45560
  const message = getProtocolV2UnknownErrorText(error).toLowerCase();
46024
45561
  return (isProtocolV2DeviceDisconnectedError(error) ||
46025
45562
  isProtocolV2ReconnectProbeError(error) ||
46026
- (message.includes('response timeout') && message.includes('devicegetfirmwareupdatestatus')) ||
45563
+ message.includes('libusb_transfer_timed_out') ||
45564
+ (message.includes('response timeout') && message.includes('devicefirmwareupdatestatusget')) ||
46027
45565
  message.includes('device not found') ||
46028
45566
  message.includes('transportnotfound'));
46029
45567
  };
45568
+ const isProtocolV2StartUpdateTransientError = (error) => {
45569
+ const message = getProtocolV2UnknownErrorText(error).toLowerCase();
45570
+ return (isProtocolV2DeviceDisconnectedError(error) ||
45571
+ isProtocolV2ReconnectProbeError(error) ||
45572
+ message.includes('libusb_transfer_timed_out') ||
45573
+ (message.includes('response timeout') && message.includes('devicefirmwareupdaterequest')));
45574
+ };
45575
+ const isProtocolV2TargetStatusFinished = (status) => normalizeProtocolV2TargetStatus(status) === PROTOCOL_V2_TARGET_STATUS_FINISHED;
45576
+ const isProtocolV2TargetStatusInProgress = (status) => normalizeProtocolV2TargetStatus(status) === PROTOCOL_V2_TARGET_STATUS_PENDING ||
45577
+ normalizeProtocolV2TargetStatus(status) === PROTOCOL_V2_TARGET_STATUS_IN_PROGRESS;
45578
+ const isProtocolV2TargetStatusFailed = (status) => {
45579
+ const normalizedStatus = normalizeProtocolV2TargetStatus(status);
45580
+ return (typeof normalizedStatus === 'number' && normalizedStatus >= PROTOCOL_V2_TARGET_STATUS_FAILED_MIN);
45581
+ };
45582
+ const normalizeProtocolV2TargetId = (targetId) => {
45583
+ if (typeof targetId === 'number') {
45584
+ return targetId;
45585
+ }
45586
+ return PROTOCOL_V2_TARGET_ID_BY_DECODED_NAME.get(targetId);
45587
+ };
45588
+ const normalizeProtocolV2TargetStatus = (status) => {
45589
+ if (typeof status === 'number') {
45590
+ return status;
45591
+ }
45592
+ if (typeof status === 'string') {
45593
+ return PROTOCOL_V2_TARGET_STATUS_BY_DECODED_NAME.get(status);
45594
+ }
45595
+ return undefined;
45596
+ };
45597
+ const normalizeProtocolV2Hex = (value) => value === null || value === void 0 ? void 0 : value.replace(/^0x/i, '').toLowerCase();
45598
+ const versionArrayToNumber = (version) => {
45599
+ if (!version)
45600
+ return undefined;
45601
+ return version[0] * 0x10000 + version[1] * 0x100 + version[2];
45602
+ };
45603
+ const versionStringToArray = (version) => {
45604
+ if (!version)
45605
+ return undefined;
45606
+ const parts = version.split('.').map(part => Number(part));
45607
+ if (parts.length !== 3 || parts.some(part => !Number.isFinite(part)))
45608
+ return undefined;
45609
+ return parts;
45610
+ };
45611
+ const compareProtocolV2Versions = (current, target) => {
45612
+ const currentNumber = versionArrayToNumber(current);
45613
+ const targetNumber = versionArrayToNumber(target);
45614
+ if (currentNumber === undefined || targetNumber === undefined)
45615
+ return undefined;
45616
+ return currentNumber - targetNumber;
45617
+ };
45618
+ const bytesToHex = (bytes) => Array.from(bytes)
45619
+ .map(byte => byte.toString(16).padStart(2, '0'))
45620
+ .join('');
45621
+ const hexToProtocolV2Bytes = (hex) => {
45622
+ const normalized = hex.replace(/^0x/i, '');
45623
+ if (!normalized || normalized.length % 2 !== 0 || /[^0-9a-f]/i.test(normalized)) {
45624
+ return new Uint8Array(0);
45625
+ }
45626
+ const bytes = new Uint8Array(normalized.length / 2);
45627
+ for (let i = 0; i < bytes.length; i++) {
45628
+ bytes[i] = Number.parseInt(normalized.slice(i * 2, i * 2 + 2), 16);
45629
+ }
45630
+ return bytes;
45631
+ };
45632
+ const toProtocolV2Bytes = (value) => {
45633
+ if (value instanceof Uint8Array)
45634
+ return value;
45635
+ if (value instanceof ArrayBuffer)
45636
+ return new Uint8Array(value);
45637
+ if (ArrayBuffer.isView(value)) {
45638
+ return new Uint8Array(value.buffer, value.byteOffset, value.byteLength);
45639
+ }
45640
+ if (typeof value === 'string')
45641
+ return hexToProtocolV2Bytes(value);
45642
+ return new Uint8Array(0);
45643
+ };
45644
+ const toProtocolV2FiniteNumber = (value) => {
45645
+ if (typeof value === 'number' && Number.isFinite(value))
45646
+ return value;
45647
+ if (typeof value === 'string') {
45648
+ const numeric = Number(value);
45649
+ return Number.isFinite(numeric) ? numeric : undefined;
45650
+ }
45651
+ if (value && typeof value === 'object') {
45652
+ const longLike = value;
45653
+ if (typeof longLike.toNumber === 'function') {
45654
+ const numeric = longLike.toNumber();
45655
+ return Number.isFinite(numeric) ? numeric : undefined;
45656
+ }
45657
+ }
45658
+ return undefined;
45659
+ };
45660
+ const readProtocolV2Ascii = (bytes, offset, length) => Array.from(bytes.slice(offset, offset + length))
45661
+ .map(byte => String.fromCharCode(byte))
45662
+ .join('');
45663
+ const parseProtocolV2OkppHeader = (bytes) => {
45664
+ if (bytes.byteLength < PROTOCOL_V2_OKPP_HEADER_SIZE)
45665
+ return null;
45666
+ if (readProtocolV2Ascii(bytes, 0, 4) !== 'OKPP')
45667
+ return null;
45668
+ const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
45669
+ const headerLen = view.getUint32(0x0c, true);
45670
+ if (headerLen !== PROTOCOL_V2_OKPP_HEADER_SIZE)
45671
+ return null;
45672
+ const packedVersion = view.getUint32(0x10, true);
45673
+ return {
45674
+ type: readProtocolV2Ascii(bytes, 0x08, 4),
45675
+ version: [
45676
+ Math.floor(packedVersion / 0x10000) % 0x100,
45677
+ Math.floor(packedVersion / 0x100) % 0x100,
45678
+ packedVersion % 0x100,
45679
+ ],
45680
+ payloadHash: bytesToHex(bytes.slice(PROTOCOL_V2_OKPP_PAYLOAD_HASH_OFFSET, PROTOCOL_V2_OKPP_PAYLOAD_HASH_OFFSET + PROTOCOL_V2_OKPP_HASH_SIZE)),
45681
+ headerHash: bytesToHex(bytes.slice(PROTOCOL_V2_OKPP_HEADER_HASH_OFFSET, PROTOCOL_V2_OKPP_HEADER_HASH_OFFSET + PROTOCOL_V2_OKPP_HASH_SIZE)),
45682
+ };
45683
+ };
46030
45684
  class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
46031
45685
  init() {
46032
45686
  this.allowDeviceMode = [UI_REQUEST.BOOTLOADER, UI_REQUEST.NOT_INITIALIZE];
@@ -46034,15 +45688,22 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
46034
45688
  this.useDevicePassphraseState = false;
46035
45689
  this.skipForceUpdateCheck = true;
46036
45690
  const { payload } = this;
45691
+ if (typeof payload.retryCount !== 'number') {
45692
+ payload.retryCount = PROTOCOL_V2_CONNECT_RETRY_COUNT;
45693
+ }
45694
+ if (typeof payload.pollIntervalTime !== 'number') {
45695
+ payload.pollIntervalTime = PROTOCOL_V2_CONNECT_POLL_INTERVAL;
45696
+ }
45697
+ if (typeof payload.timeout !== 'number') {
45698
+ payload.timeout = PROTOCOL_V2_CONNECT_SINGLE_TIMEOUT;
45699
+ }
45700
+ if (typeof payload.protocolV2DeviceInfoTimeoutMs !== 'number') {
45701
+ payload.protocolV2DeviceInfoTimeoutMs = PROTOCOL_V2_DEVICE_INFO_READY_TIMEOUT;
45702
+ }
46037
45703
  validateParams(payload, [
46038
- { name: 'bleVersion', type: 'array' },
46039
- { name: 'bleBinary', type: 'buffer' },
46040
45704
  { name: 'chunkSize', type: 'number' },
46041
- { name: 'firmwareVersion', type: 'array' },
46042
- { name: 'firmwareBinary', type: 'buffer' },
46043
- { name: 'resourceBinary', type: 'buffer' },
45705
+ { name: 'resourceBinaries', type: 'array', allowEmpty: true },
46044
45706
  { name: 'forcedUpdateRes', type: 'boolean' },
46045
- { name: 'bootloaderVersion', type: 'array' },
46046
45707
  { name: 'bootloaderBinary', type: 'buffer' },
46047
45708
  { name: 'romloaderBinary', type: 'buffer' },
46048
45709
  { name: 'applicationP1Binary', type: 'buffer' },
@@ -46056,12 +45717,8 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
46056
45717
  { name: 'platform', type: 'string' },
46057
45718
  ]);
46058
45719
  this.params = {
46059
- bleBinary: payload.bleBinary,
46060
45720
  chunkSize: payload.chunkSize,
46061
- firmwareBinary: payload.firmwareBinary,
46062
45721
  forcedUpdateRes: payload.forcedUpdateRes,
46063
- bleVersion: payload.bleVersion,
46064
- bootloaderVersion: payload.bootloaderVersion,
46065
45722
  bootloaderBinary: payload.bootloaderBinary,
46066
45723
  romloaderBinary: payload.romloaderBinary,
46067
45724
  applicationP1Binary: payload.applicationP1Binary,
@@ -46071,8 +45728,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
46071
45728
  se02Binary: payload.se02Binary,
46072
45729
  se03Binary: payload.se03Binary,
46073
45730
  se04Binary: payload.se04Binary,
46074
- firmwareVersion: payload.firmwareVersion,
46075
- resourceBinary: payload.resourceBinary,
45731
+ resourceBinaries: payload.resourceBinaries,
46076
45732
  firmwareType: payload.firmwareType,
46077
45733
  platform: payload.platform,
46078
45734
  };
@@ -46104,25 +45760,31 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
46104
45760
  const deviceFeatures = yield this.getProtocolV2DeviceFeatures();
46105
45761
  const deviceFirmwareType = getFirmwareType(deviceFeatures);
46106
45762
  const firmwareType = (_a = this.params.firmwareType) !== null && _a !== void 0 ? _a : deviceFirmwareType;
46107
- let resourceBinary = null;
45763
+ let resourceBinaryMap = [];
46108
45764
  let fwBinaryMap = [];
46109
45765
  let bootloaderBinary = null;
46110
45766
  try {
46111
45767
  this.postTipMessage(exports.FirmwareUpdateTipMessage.StartDownloadFirmware);
46112
- resourceBinary = yield this.prepareResourceBinary(firmwareType, deviceFeatures);
46113
- fwBinaryMap = yield this.prepareFirmwareAndBleBinary(firmwareType, deviceFeatures);
46114
- bootloaderBinary = yield this.prepareBootloaderBinary(firmwareType, deviceFeatures);
46115
- fwBinaryMap.push(...this.collectExplicitTargetBinaries());
45768
+ resourceBinaryMap = yield this.prepareResourceBinaries(firmwareType, deviceFeatures);
45769
+ fwBinaryMap = this.collectExplicitTargetBinaries();
45770
+ bootloaderBinary = this.prepareBootloaderBinary();
45771
+ if (!this.hasExplicitProtocolV2Payload(fwBinaryMap)) {
45772
+ const remoteBinaries = yield this.prepareRemoteProtocolV2Binaries(firmwareType, deviceFeatures);
45773
+ resourceBinaryMap = remoteBinaries.resourceBinaryMap;
45774
+ bootloaderBinary = remoteBinaries.bootloaderBinary;
45775
+ fwBinaryMap = remoteBinaries.fwBinaryMap;
45776
+ }
46116
45777
  this.postTipMessage(exports.FirmwareUpdateTipMessage.FinishDownloadFirmware);
46117
45778
  }
46118
45779
  catch (err) {
46119
45780
  throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.FirmwareUpdateDownloadFailed, (_b = err.message) !== null && _b !== void 0 ? _b : err);
46120
45781
  }
46121
- if (!resourceBinary && !bootloaderBinary && fwBinaryMap.length === 0) {
45782
+ if (resourceBinaryMap.length === 0 && !bootloaderBinary && fwBinaryMap.length === 0) {
46122
45783
  throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.FirmwareUpdateDownloadFailed, 'No firmware to update');
46123
45784
  }
45785
+ yield this.enterProtocolV2BootloaderMode();
46124
45786
  yield this.executeProtocolV2Update({
46125
- resourceBinary,
45787
+ resourceBinaryMap,
46126
45788
  fwBinaryMap,
46127
45789
  bootloaderBinary,
46128
45790
  });
@@ -46135,21 +45797,31 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
46135
45797
  }
46136
45798
  getProtocolV2DeviceFeatures() {
46137
45799
  return __awaiter(this, void 0, void 0, function* () {
45800
+ if (this.device.features) {
45801
+ return this.device.features;
45802
+ }
46138
45803
  if (typeof this.device.getFeatures === 'function') {
46139
45804
  const features = yield this.device.getFeatures();
46140
45805
  if (features)
46141
45806
  return features;
46142
45807
  }
46143
- if (this.device.features) {
46144
- return this.device.features;
46145
- }
46146
45808
  throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, 'Device features not available');
46147
45809
  });
46148
45810
  }
46149
- prepareResourceBinary(firmwareType, features) {
45811
+ prepareResourceBinaries(firmwareType, features) {
45812
+ var _a;
46150
45813
  return __awaiter(this, void 0, void 0, function* () {
46151
- if (this.params.resourceBinary) {
46152
- return this.params.resourceBinary;
45814
+ if ((_a = this.params.resourceBinaries) === null || _a === void 0 ? void 0 : _a.length) {
45815
+ this.params.resourceBinaries.forEach((binary, index) => {
45816
+ if (!(binary instanceof ArrayBuffer)) {
45817
+ throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.CallMethodInvalidParameter, `Parameter [resourceBinaries.${index}] is of type invalid and should be [buffer].`);
45818
+ }
45819
+ });
45820
+ return this.params.resourceBinaries.map((binary, index) => ({
45821
+ fileName: `resource-${index + 1}.bin`,
45822
+ binary,
45823
+ targetId: ProtocolV2FirmwareTargetType.FW_MGMT_TARGET_CRATE,
45824
+ }));
46153
45825
  }
46154
45826
  const resourceUrl = DataManager.getSysResourcesLatestRelease({
46155
45827
  features,
@@ -46158,25 +45830,271 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
46158
45830
  });
46159
45831
  if (resourceUrl) {
46160
45832
  const resource = (yield getSysResourceBinary(resourceUrl)).binary;
46161
- return resource;
45833
+ return [
45834
+ {
45835
+ fileName: 'resource.bin',
45836
+ binary: resource,
45837
+ targetId: ProtocolV2FirmwareTargetType.FW_MGMT_TARGET_CRATE,
45838
+ },
45839
+ ];
46162
45840
  }
46163
45841
  Log$4.warn('No resource url found');
46164
- return null;
45842
+ return [];
46165
45843
  });
46166
45844
  }
46167
- prepareBootloaderBinary(firmwareType, features) {
45845
+ prepareBootloaderBinary() {
45846
+ var _a;
45847
+ return (_a = this.params.bootloaderBinary) !== null && _a !== void 0 ? _a : null;
45848
+ }
45849
+ hasExplicitProtocolV2Payload(fwBinaryMap) {
45850
+ var _a;
45851
+ return (!!((_a = this.params.resourceBinaries) === null || _a === void 0 ? void 0 : _a.length) ||
45852
+ !!this.params.bootloaderBinary ||
45853
+ fwBinaryMap.length > 0);
45854
+ }
45855
+ getRemoteComponentEntries(release) {
45856
+ var _a;
45857
+ const { components } = release;
45858
+ if (!components)
45859
+ return [];
45860
+ const orderedKeys = [
45861
+ ...((_a = release.installOrder) !== null && _a !== void 0 ? _a : []),
45862
+ ...Object.keys(components).filter(key => { var _a; return !((_a = release.installOrder) === null || _a === void 0 ? void 0 : _a.includes(key)); }),
45863
+ ];
45864
+ return orderedKeys
45865
+ .map(key => {
45866
+ const component = components[key];
45867
+ return component ? [key, component] : undefined;
45868
+ })
45869
+ .filter((entry) => !!entry);
45870
+ }
45871
+ getRemoteComponentTarget(key, component) {
45872
+ var _a;
45873
+ const targetName = (_a = component.target) === null || _a === void 0 ? void 0 : _a.toUpperCase();
45874
+ if (targetName === 'ROMLOADER') {
45875
+ throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, PROTOCOL_V2_ROMLOADER_UNSUPPORTED_MESSAGE);
45876
+ }
45877
+ const target = PROTOCOL_V2_REMOTE_COMPONENT_TARGETS[targetName];
45878
+ if (!target) {
45879
+ throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, `Unsupported Protocol V2 firmware component target: ${key}/${component.target}`);
45880
+ }
45881
+ return target;
45882
+ }
45883
+ getProtocolV2ComponentTargetVersion(release, component, target) {
45884
+ if (component.version)
45885
+ return component.version;
45886
+ if (target.targetId === ProtocolV2FirmwareTargetType.FW_MGMT_TARGET_BOOTLOADER) {
45887
+ return release.bootloaderVersion;
45888
+ }
45889
+ if (target.targetId === ProtocolV2FirmwareTargetType.FW_MGMT_TARGET_APPLICATION_P1 ||
45890
+ target.targetId === ProtocolV2FirmwareTargetType.FW_MGMT_TARGET_APPLICATION_P2) {
45891
+ return release.version;
45892
+ }
45893
+ return undefined;
45894
+ }
45895
+ getProtocolV2ComponentCurrentVersion(features, target) {
45896
+ switch (target.targetId) {
45897
+ case ProtocolV2FirmwareTargetType.FW_MGMT_TARGET_BOOTLOADER:
45898
+ return getDeviceBootloaderVersion(features);
45899
+ case ProtocolV2FirmwareTargetType.FW_MGMT_TARGET_APPLICATION_P1:
45900
+ case ProtocolV2FirmwareTargetType.FW_MGMT_TARGET_APPLICATION_P2:
45901
+ return getDeviceFirmwareVersion(features);
45902
+ case ProtocolV2FirmwareTargetType.FW_MGMT_TARGET_COPROCESSOR:
45903
+ return getDeviceBLEFirmwareVersion(features);
45904
+ case ProtocolV2FirmwareTargetType.FW_MGMT_TARGET_SE01:
45905
+ return versionStringToArray(features.se01Version);
45906
+ case ProtocolV2FirmwareTargetType.FW_MGMT_TARGET_SE02:
45907
+ return versionStringToArray(features.se02Version);
45908
+ case ProtocolV2FirmwareTargetType.FW_MGMT_TARGET_SE03:
45909
+ return versionStringToArray(features.se03Version);
45910
+ case ProtocolV2FirmwareTargetType.FW_MGMT_TARGET_SE04:
45911
+ return versionStringToArray(features.se04Version);
45912
+ default:
45913
+ return undefined;
45914
+ }
45915
+ }
45916
+ isProtocolV2ComponentVersionSatisfied(release, component, target, features) {
45917
+ const targetVersion = this.getProtocolV2ComponentTargetVersion(release, component, target);
45918
+ if (!targetVersion)
45919
+ return false;
45920
+ const currentVersion = this.getProtocolV2ComponentCurrentVersion(features, target);
45921
+ const compareResult = compareProtocolV2Versions(currentVersion, targetVersion);
45922
+ return compareResult !== undefined && compareResult >= 0;
45923
+ }
45924
+ getProtocolV2ResourceFilePath(path) {
45925
+ if (path.startsWith('vol'))
45926
+ return path;
45927
+ if (path.startsWith('/'))
45928
+ return `vol0:${path}`;
45929
+ return `vol0:/${path}`;
45930
+ }
45931
+ readProtocolV2DeviceFileHeader(path) {
45932
+ var _a, _b, _c, _d;
46168
45933
  return __awaiter(this, void 0, void 0, function* () {
46169
- if (this.params.bootloaderBinary) {
46170
- return this.params.bootloaderBinary;
45934
+ const typedCall = this.device.getCommands().typedCall.bind(this.device.getCommands());
45935
+ const filePath = this.getProtocolV2ResourceFilePath(path);
45936
+ const pathInfoRes = yield typedCall('FilesystemPathInfoQuery', 'FilesystemPathInfo', {
45937
+ path: filePath,
45938
+ });
45939
+ const fileSize = toProtocolV2FiniteNumber((_a = pathInfoRes.message) === null || _a === void 0 ? void 0 : _a.size);
45940
+ if (!((_b = pathInfoRes.message) === null || _b === void 0 ? void 0 : _b.exist) ||
45941
+ ((_c = pathInfoRes.message) === null || _c === void 0 ? void 0 : _c.directory) ||
45942
+ fileSize === undefined ||
45943
+ fileSize < PROTOCOL_V2_OKPP_HEADER_SIZE) {
45944
+ return null;
46171
45945
  }
46172
- if (this.params.bootloaderVersion) {
46173
- const bootResourceUrl = DataManager.getBootloaderResource(features, firmwareType);
46174
- if (bootResourceUrl) {
46175
- const bootBinary = (yield getSysResourceBinary(bootResourceUrl)).binary;
46176
- return bootBinary;
45946
+ const chunkSize = this.getProtocolV2FirmwareChunkSize();
45947
+ const chunks = [];
45948
+ let offset = 0;
45949
+ while (offset < PROTOCOL_V2_OKPP_HEADER_SIZE) {
45950
+ const readLen = Math.min(chunkSize, PROTOCOL_V2_OKPP_HEADER_SIZE - offset);
45951
+ const res = yield typedCall('FilesystemFileRead', 'FilesystemFile', {
45952
+ file: {
45953
+ path: filePath,
45954
+ offset,
45955
+ total_size: 0,
45956
+ },
45957
+ chunk_len: readLen,
45958
+ ui_percentage: undefined,
45959
+ });
45960
+ const data = toProtocolV2Bytes((_d = res.message) === null || _d === void 0 ? void 0 : _d.data);
45961
+ if (data.byteLength === 0)
45962
+ return null;
45963
+ chunks.push(data);
45964
+ offset += data.byteLength;
45965
+ }
45966
+ const headerBytes = new Uint8Array(offset);
45967
+ let cursor = 0;
45968
+ chunks.forEach(chunk => {
45969
+ headerBytes.set(chunk, cursor);
45970
+ cursor += chunk.byteLength;
45971
+ });
45972
+ return parseProtocolV2OkppHeader(headerBytes);
45973
+ });
45974
+ }
45975
+ isProtocolV2ResourcePackageMatched(pkg, manifestVersion) {
45976
+ var _a, _b;
45977
+ return __awaiter(this, void 0, void 0, function* () {
45978
+ try {
45979
+ const header = yield this.readProtocolV2DeviceFileHeader(pkg.path);
45980
+ if (!header)
45981
+ return false;
45982
+ const expectedType = (_a = pkg.type) !== null && _a !== void 0 ? _a : 'RESC';
45983
+ const expectedVersion = (_b = pkg.version) !== null && _b !== void 0 ? _b : manifestVersion;
45984
+ if (header.type !== expectedType)
45985
+ return false;
45986
+ if (expectedVersion && compareProtocolV2Versions(header.version, expectedVersion) !== 0) {
45987
+ return false;
46177
45988
  }
45989
+ const expectedPayloadHash = normalizeProtocolV2Hex(pkg.payloadHash);
45990
+ if (expectedPayloadHash && header.payloadHash !== expectedPayloadHash)
45991
+ return false;
45992
+ const expectedHeaderHash = normalizeProtocolV2Hex(pkg.headerHash);
45993
+ if (expectedHeaderHash && header.headerHash !== expectedHeaderHash)
45994
+ return false;
45995
+ return true;
46178
45996
  }
46179
- return null;
45997
+ catch (error) {
45998
+ Log$4.log(`Protocol V2 resource package check failed for ${pkg.path}: `, error);
45999
+ return false;
46000
+ }
46001
+ });
46002
+ }
46003
+ isProtocolV2ResourceManifestSatisfied(manifest) {
46004
+ var _a;
46005
+ return __awaiter(this, void 0, void 0, function* () {
46006
+ if (!((_a = manifest === null || manifest === void 0 ? void 0 : manifest.packages) === null || _a === void 0 ? void 0 : _a.length))
46007
+ return false;
46008
+ for (const pkg of manifest.packages) {
46009
+ if (!(yield this.isProtocolV2ResourcePackageMatched(pkg, manifest.version))) {
46010
+ return false;
46011
+ }
46012
+ }
46013
+ return true;
46014
+ });
46015
+ }
46016
+ getProtocolV2ResourceManifest(release, component) {
46017
+ var _a;
46018
+ return (_a = component.resourceManifest) !== null && _a !== void 0 ? _a : release.resourceManifest;
46019
+ }
46020
+ getProtocolV2ResourceComponentFileName(key) {
46021
+ const safeKey = key.replace(/[^a-z0-9_-]/gi, '_') || 'resource';
46022
+ return `resource-${safeKey}.bin`;
46023
+ }
46024
+ shouldInstallRemoteProtocolV2Component(release, key, component, target, features) {
46025
+ return __awaiter(this, void 0, void 0, function* () {
46026
+ if (target.kind === 'resource') {
46027
+ if (this.params.forcedUpdateRes ||
46028
+ features.bootloaderMode ||
46029
+ features.mode === 'bootloader') {
46030
+ return true;
46031
+ }
46032
+ const resourceMatched = yield this.isProtocolV2ResourceManifestSatisfied(this.getProtocolV2ResourceManifest(release, component));
46033
+ if (resourceMatched) {
46034
+ Log$4.log(`[FirmwareUpdateV4] skip Protocol V2 resource component ${key}; manifest matched`);
46035
+ }
46036
+ return !resourceMatched;
46037
+ }
46038
+ const versionSatisfied = this.isProtocolV2ComponentVersionSatisfied(release, component, target, features);
46039
+ if (versionSatisfied) {
46040
+ Log$4.log(`[FirmwareUpdateV4] skip Protocol V2 component ${key}; version is up to date`);
46041
+ }
46042
+ return !versionSatisfied;
46043
+ });
46044
+ }
46045
+ downloadRemoteProtocolV2Component(key, component) {
46046
+ return __awaiter(this, void 0, void 0, function* () {
46047
+ const target = this.getRemoteComponentTarget(key, component);
46048
+ if (!component.url) {
46049
+ throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, `Missing Protocol V2 firmware component url: ${key}/${component.target}`);
46050
+ }
46051
+ const { binary } = yield getSysResourceBinary(component.url);
46052
+ return Object.assign(Object.assign({}, target), { binary });
46053
+ });
46054
+ }
46055
+ prepareRemoteProtocolV2Binaries(firmwareType, features) {
46056
+ return __awaiter(this, void 0, void 0, function* () {
46057
+ const release = DataManager.getFirmwareLatestRelease(features, firmwareType);
46058
+ const resourceBinaryMap = [];
46059
+ let bootloaderBinary = null;
46060
+ const fwBinaryMap = [];
46061
+ if (!release) {
46062
+ return {
46063
+ resourceBinaryMap,
46064
+ bootloaderBinary,
46065
+ fwBinaryMap,
46066
+ };
46067
+ }
46068
+ const entries = this.getRemoteComponentEntries(release);
46069
+ for (const [key, component] of entries) {
46070
+ const target = this.getRemoteComponentTarget(key, component);
46071
+ const shouldInstall = yield this.shouldInstallRemoteProtocolV2Component(release, key, component, target, features);
46072
+ if (shouldInstall) {
46073
+ const remoteBinary = yield this.downloadRemoteProtocolV2Component(key, component);
46074
+ if (remoteBinary.kind === 'resource') {
46075
+ resourceBinaryMap.push({
46076
+ fileName: this.getProtocolV2ResourceComponentFileName(key),
46077
+ binary: remoteBinary.binary,
46078
+ targetId: remoteBinary.targetId,
46079
+ });
46080
+ }
46081
+ else if (remoteBinary.kind === 'bootloader') {
46082
+ bootloaderBinary = remoteBinary.binary;
46083
+ }
46084
+ else {
46085
+ fwBinaryMap.push({
46086
+ fileName: remoteBinary.fileName,
46087
+ binary: remoteBinary.binary,
46088
+ targetId: remoteBinary.targetId,
46089
+ });
46090
+ }
46091
+ }
46092
+ }
46093
+ return {
46094
+ resourceBinaryMap,
46095
+ bootloaderBinary,
46096
+ fwBinaryMap,
46097
+ };
46180
46098
  });
46181
46099
  }
46182
46100
  isProtocolV2BootloaderMode() {
@@ -46187,20 +46105,17 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
46187
46105
  return !!((_a = this.device.features) === null || _a === void 0 ? void 0 : _a.bootloaderMode);
46188
46106
  }
46189
46107
  enterProtocolV2BootloaderMode() {
46190
- var _a, _b, _c;
46191
46108
  return __awaiter(this, void 0, void 0, function* () {
46192
46109
  if (this.isProtocolV2BootloaderMode()) {
46110
+ Log$4.debug('Protocol V2 device is already in bootloader mode, skip reboot to bootloader');
46193
46111
  return false;
46194
46112
  }
46195
46113
  try {
46196
46114
  this.postTipMessage(exports.FirmwareUpdateTipMessage.AutoRebootToBootloader);
46197
- yield this.protocolV2Reboot(hdTransport.DevRebootType.Bootloader);
46115
+ yield this.protocolV2Reboot(hdTransport.DeviceRebootType.Bootloader);
46198
46116
  this.postTipMessage(exports.FirmwareUpdateTipMessage.GoToBootloaderSuccess);
46199
- this.checkDeviceToBootloader(this.payload.connectId);
46200
- yield ((_a = this.checkPromise) === null || _a === void 0 ? void 0 : _a.promise);
46201
- this.checkPromise = null;
46202
- yield hdShared.wait(1500);
46203
- yield ((_c = (_b = this.device).acquire) === null || _c === void 0 ? void 0 : _c.call(_b));
46117
+ yield hdShared.wait(1000);
46118
+ yield this.waitForProtocolV2BootloaderMode();
46204
46119
  return true;
46205
46120
  }
46206
46121
  catch (error) {
@@ -46212,129 +46127,151 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
46212
46127
  }
46213
46128
  });
46214
46129
  }
46130
+ waitForProtocolV2BootloaderMode(timeout = PROTOCOL_V2_BOOTLOADER_RECONNECT_TIMEOUT, retryInterval = 1000) {
46131
+ return __awaiter(this, void 0, void 0, function* () {
46132
+ const startTime = Date.now();
46133
+ let lastError;
46134
+ while (Date.now() - startTime < timeout) {
46135
+ try {
46136
+ yield this.reconnectProtocolV2Device();
46137
+ const deviceInfo = yield requestProtocolV2DeviceInfo({
46138
+ commands: this.device.getCommands(),
46139
+ timeoutMs: PROTOCOL_V2_SHORT_RESPONSE_TIMEOUT,
46140
+ });
46141
+ const features = this.device.updateProtocolV2Features(deviceInfo);
46142
+ if (features === null || features === void 0 ? void 0 : features.bootloaderMode) {
46143
+ return features;
46144
+ }
46145
+ lastError = new Error('Protocol V2 device is reachable but is not in bootloader mode');
46146
+ }
46147
+ catch (error) {
46148
+ lastError = error;
46149
+ Log$4.log('Protocol V2 bootloader mode not ready, polling reconnect: ', error);
46150
+ }
46151
+ yield hdShared.wait(retryInterval);
46152
+ }
46153
+ throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.FirmwareUpdateAutoEnterBootFailure, `Protocol V2 bootloader not ready within ${timeout / 1000}s: ${this.normalizeErrorMessage(lastError)}`);
46154
+ });
46155
+ }
46215
46156
  collectExplicitTargetBinaries() {
46216
46157
  const entries = [];
46217
46158
  const push = (binary, fileName, targetId) => {
46218
46159
  if (binary)
46219
46160
  entries.push({ fileName, binary, targetId });
46220
46161
  };
46221
- push(this.params.romloaderBinary, 'romloader.bin', ProtocolV2FirmwareTargetType.TARGET_MAIN_BOOT);
46222
- push(this.params.applicationP1Binary, 'application_p1.bin', ProtocolV2FirmwareTargetType.TARGET_MAIN_APP);
46223
- push(this.params.applicationP2Binary, 'application_p2.bin', ProtocolV2FirmwareTargetType.TARGET_MAIN_APP);
46224
- push(this.params.coprocessorBinary, 'coprocessor.bin', ProtocolV2FirmwareTargetType.TARGET_BT);
46225
- push(this.params.se01Binary, 'se01.bin', ProtocolV2FirmwareTargetType.TARGET_SE1);
46226
- push(this.params.se02Binary, 'se02.bin', ProtocolV2FirmwareTargetType.TARGET_SE2);
46227
- push(this.params.se03Binary, 'se03.bin', ProtocolV2FirmwareTargetType.TARGET_SE3);
46228
- push(this.params.se04Binary, 'se04.bin', ProtocolV2FirmwareTargetType.TARGET_SE4);
46162
+ if (this.params.romloaderBinary) {
46163
+ throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, PROTOCOL_V2_ROMLOADER_UNSUPPORTED_MESSAGE);
46164
+ }
46165
+ push(this.params.applicationP1Binary, 'application_p1.bin', ProtocolV2FirmwareTargetType.FW_MGMT_TARGET_APPLICATION_P1);
46166
+ push(this.params.applicationP2Binary, 'application_p2.bin', ProtocolV2FirmwareTargetType.FW_MGMT_TARGET_APPLICATION_P2);
46167
+ push(this.params.coprocessorBinary, 'coprocessor.bin', ProtocolV2FirmwareTargetType.FW_MGMT_TARGET_COPROCESSOR);
46168
+ push(this.params.se01Binary, 'se01.bin', ProtocolV2FirmwareTargetType.FW_MGMT_TARGET_SE01);
46169
+ push(this.params.se02Binary, 'se02.bin', ProtocolV2FirmwareTargetType.FW_MGMT_TARGET_SE02);
46170
+ push(this.params.se03Binary, 'se03.bin', ProtocolV2FirmwareTargetType.FW_MGMT_TARGET_SE03);
46171
+ push(this.params.se04Binary, 'se04.bin', ProtocolV2FirmwareTargetType.FW_MGMT_TARGET_SE04);
46229
46172
  return entries;
46230
46173
  }
46231
- prepareFirmwareAndBleBinary(firmwareType, features) {
46232
- return __awaiter(this, void 0, void 0, function* () {
46233
- const fwBinaryMap = [];
46234
- if (this.params.firmwareBinary) {
46235
- fwBinaryMap.push({
46236
- fileName: 'firmware.bin',
46237
- binary: this.params.firmwareBinary,
46238
- });
46239
- }
46240
- else if (this.params.firmwareVersion) {
46241
- const firmwareBinary = (yield getBinary({
46242
- features,
46243
- version: this.params.firmwareVersion,
46244
- updateType: 'firmware',
46245
- isUpdateBootloader: false,
46246
- firmwareType,
46247
- })).binary;
46248
- fwBinaryMap.push({
46249
- fileName: 'firmware.bin',
46250
- binary: firmwareBinary,
46251
- });
46252
- }
46253
- if (this.params.bleBinary) {
46254
- fwBinaryMap.push({
46255
- fileName: 'ble-firmware.bin',
46256
- binary: this.params.bleBinary,
46257
- });
46258
- }
46259
- else if (this.params.bleVersion) {
46260
- const bleBinary = yield getBinary({
46261
- features,
46262
- version: this.params.bleVersion,
46263
- updateType: 'ble',
46264
- firmwareType,
46265
- });
46266
- fwBinaryMap.push({
46267
- fileName: 'ble-firmware.bin',
46268
- binary: bleBinary.binary,
46269
- });
46270
- }
46271
- return fwBinaryMap;
46272
- });
46273
- }
46274
- executeProtocolV2Update({ resourceBinary, fwBinaryMap, bootloaderBinary, }) {
46275
- var _a;
46174
+ executeProtocolV2Update({ resourceBinaryMap, fwBinaryMap, bootloaderBinary, }) {
46276
46175
  return __awaiter(this, void 0, void 0, function* () {
46277
46176
  let totalSize = 0;
46278
46177
  let processedSize = 0;
46279
- if (resourceBinary)
46280
- totalSize += resourceBinary.byteLength;
46178
+ let transferredSize = 0;
46179
+ for (const resource of resourceBinaryMap)
46180
+ totalSize += resource.binary.byteLength;
46281
46181
  for (const fwbinary of fwBinaryMap)
46282
46182
  totalSize += fwbinary.binary.byteLength;
46283
46183
  if (bootloaderBinary)
46284
46184
  totalSize += bootloaderBinary.byteLength;
46285
46185
  this.postTipMessage(exports.FirmwareUpdateTipMessage.StartTransferData);
46186
+ const transferStartTime = Date.now();
46187
+ const transferTransport = this.getProtocolV2FirmwareTransferTransport();
46188
+ const chunkSize = this.getProtocolV2FirmwareChunkSize();
46189
+ const onTransferredBytes = (bytes) => {
46190
+ transferredSize = bytes;
46191
+ };
46192
+ Log$4.log(`[FirmwareUpdateV4] transfer started transport=${transferTransport} total=${totalSize} bytes chunk=${chunkSize} bytes`);
46193
+ const resourceTargets = [];
46286
46194
  const targets = [];
46287
- if (resourceBinary) {
46288
- const resourceFilePath = `${PROTOCOL_V2_FIRMWARE_STAGING_VOLUME}resource.bin`;
46289
- processedSize = yield this.protocolV2CommonUpdateProcess({
46290
- payload: resourceBinary,
46291
- filePath: resourceFilePath,
46292
- processedSize,
46293
- totalSize,
46294
- });
46295
- targets.push({
46296
- target_id: ProtocolV2FirmwareTargetType.TARGET_RESOURCE,
46297
- path: resourceFilePath,
46298
- });
46195
+ try {
46196
+ for (const resource of resourceBinaryMap) {
46197
+ const resourceFilePath = `${PROTOCOL_V2_FIRMWARE_STAGING_VOLUME}${resource.fileName}`;
46198
+ Log$4.log(`[FirmwareUpdateV4] staging resource via FilesystemFileWrite target=${resource.targetId} path=${resourceFilePath} bytes=${resource.binary.byteLength}`);
46199
+ processedSize = yield this.protocolV2CommonUpdateProcess({
46200
+ payload: resource.binary,
46201
+ filePath: resourceFilePath,
46202
+ processedSize,
46203
+ totalSize,
46204
+ onTransferredBytes,
46205
+ });
46206
+ transferredSize = processedSize;
46207
+ resourceTargets.push({
46208
+ target_id: resource.targetId,
46209
+ path: resourceFilePath,
46210
+ });
46211
+ }
46212
+ if (bootloaderBinary) {
46213
+ const bootloaderPath = `${PROTOCOL_V2_FIRMWARE_STAGING_VOLUME}bootloader.bin`;
46214
+ Log$4.log(`[FirmwareUpdateV4] staging bootloader via FilesystemFileWrite target=${ProtocolV2FirmwareTargetType.FW_MGMT_TARGET_BOOTLOADER} path=${bootloaderPath} bytes=${bootloaderBinary.byteLength}`);
46215
+ processedSize = yield this.protocolV2CommonUpdateProcess({
46216
+ payload: bootloaderBinary,
46217
+ filePath: bootloaderPath,
46218
+ processedSize,
46219
+ totalSize,
46220
+ onTransferredBytes,
46221
+ });
46222
+ transferredSize = processedSize;
46223
+ targets.push({
46224
+ target_id: ProtocolV2FirmwareTargetType.FW_MGMT_TARGET_BOOTLOADER,
46225
+ path: bootloaderPath,
46226
+ });
46227
+ }
46228
+ for (const fwbinary of fwBinaryMap) {
46229
+ const firmwarePath = `${PROTOCOL_V2_FIRMWARE_STAGING_VOLUME}${fwbinary.fileName}`;
46230
+ Log$4.log(`[FirmwareUpdateV4] staging firmware via FilesystemFileWrite target=${fwbinary.targetId} path=${firmwarePath} bytes=${fwbinary.binary.byteLength}`);
46231
+ processedSize = yield this.protocolV2CommonUpdateProcess({
46232
+ payload: fwbinary.binary,
46233
+ filePath: firmwarePath,
46234
+ processedSize,
46235
+ totalSize,
46236
+ onTransferredBytes,
46237
+ });
46238
+ transferredSize = processedSize;
46239
+ targets.push({
46240
+ target_id: fwbinary.targetId,
46241
+ path: firmwarePath,
46242
+ });
46243
+ }
46244
+ if (totalSize > 0) {
46245
+ this.postProgressMessage(100, 'transferData');
46246
+ }
46247
+ const elapsedMs = Date.now() - transferStartTime;
46248
+ Log$4.log(`[FirmwareUpdateV4] transfer finished transport=${transferTransport} bytes=${totalSize} elapsed=${(elapsedMs / 1000).toFixed(2)}s speed=${formatProtocolV2TransferSpeed(totalSize, elapsedMs)} KB/s`);
46299
46249
  }
46300
- if (bootloaderBinary) {
46301
- const bootloaderPath = `${PROTOCOL_V2_FIRMWARE_STAGING_VOLUME}bootloader.bin`;
46302
- processedSize = yield this.protocolV2CommonUpdateProcess({
46303
- payload: bootloaderBinary,
46304
- filePath: bootloaderPath,
46305
- processedSize,
46306
- totalSize,
46307
- });
46308
- targets.push({
46309
- target_id: ProtocolV2FirmwareTargetType.TARGET_MAIN_BOOT,
46310
- path: bootloaderPath,
46311
- });
46250
+ catch (error) {
46251
+ const elapsedMs = Date.now() - transferStartTime;
46252
+ Log$4.warn(`[FirmwareUpdateV4] transfer failed transport=${transferTransport} bytes=${transferredSize}/${totalSize} elapsed=${(elapsedMs / 1000).toFixed(2)}s speed=${formatProtocolV2TransferSpeed(transferredSize, elapsedMs)} KB/s`);
46253
+ throw error;
46312
46254
  }
46313
- for (const fwbinary of fwBinaryMap) {
46314
- const firmwarePath = `${PROTOCOL_V2_FIRMWARE_STAGING_VOLUME}${fwbinary.fileName}`;
46315
- processedSize = yield this.protocolV2CommonUpdateProcess({
46316
- payload: fwbinary.binary,
46317
- filePath: firmwarePath,
46318
- processedSize,
46319
- totalSize,
46320
- });
46321
- targets.push({
46322
- target_id: (_a = fwbinary.targetId) !== null && _a !== void 0 ? _a : protocolV2FileNameToTargetId(fwbinary.fileName),
46323
- path: firmwarePath,
46255
+ this.postTipMessage(exports.FirmwareUpdateTipMessage.ConfirmOnDevice);
46256
+ for (const resourceTarget of resourceTargets) {
46257
+ const resourceTargetsBatch = [resourceTarget];
46258
+ Log$4.log(`[FirmwareUpdateV4] DeviceFirmwareUpdateRequest resources=${JSON.stringify(resourceTargetsBatch)}`);
46259
+ const startResponse = yield this.protocolV2StartFirmwareUpdate({
46260
+ targets: resourceTargetsBatch,
46324
46261
  });
46262
+ yield this.waitForProtocolV2FirmwareUpdateComplete(resourceTargetsBatch, startResponse);
46325
46263
  }
46326
- if (totalSize > 0) {
46327
- this.postProgressMessage(100, 'transferData');
46264
+ if (targets.length > 0) {
46265
+ Log$4.log(`[FirmwareUpdateV4] DeviceFirmwareUpdateRequest targets=${JSON.stringify(targets)}`);
46266
+ const startResponse = yield this.protocolV2StartFirmwareUpdate({ targets });
46267
+ yield this.waitForProtocolV2FirmwareUpdateComplete(targets, startResponse);
46328
46268
  }
46329
- this.postTipMessage(exports.FirmwareUpdateTipMessage.ConfirmOnDevice);
46330
- const startResponse = yield this.protocolV2StartFirmwareUpdate({ targets });
46331
- yield this.waitForProtocolV2FirmwareUpdateComplete(targets, startResponse);
46332
46269
  });
46333
46270
  }
46334
46271
  queryProtocolV2FirmwareUpdateStatus() {
46335
46272
  return __awaiter(this, void 0, void 0, function* () {
46336
46273
  const typedCall = this.device.getCommands().typedCall.bind(this.device.getCommands());
46337
- return typedCall('DevGetFirmwareUpdateStatus', 'DevFirmwareUpdateStatus', {}, {
46274
+ return typedCall('DeviceFirmwareUpdateStatusGet', 'DeviceFirmwareUpdateStatus', {}, {
46338
46275
  timeoutMs: PROTOCOL_V2_SHORT_RESPONSE_TIMEOUT,
46339
46276
  });
46340
46277
  });
@@ -46347,19 +46284,46 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
46347
46284
  });
46348
46285
  });
46349
46286
  }
46287
+ isProtocolV2NormalModeFeatures(features) {
46288
+ return !!features && !features.bootloaderMode && features.mode !== 'bootloader';
46289
+ }
46290
+ probeProtocolV2NormalMode() {
46291
+ return __awaiter(this, void 0, void 0, function* () {
46292
+ const deviceInfo = yield requestProtocolV2DeviceInfo({
46293
+ commands: this.device.getCommands(),
46294
+ timeoutMs: PROTOCOL_V2_SHORT_RESPONSE_TIMEOUT,
46295
+ request: PROTOCOL_V2_VERSIONS_DEVICE_INFO_REQUEST,
46296
+ });
46297
+ const features = this.device.updateProtocolV2Features(deviceInfo);
46298
+ if (this.isProtocolV2NormalModeFeatures(features)) {
46299
+ Log$4.log('Protocol V2 firmware install finished; device is back in normal mode');
46300
+ return true;
46301
+ }
46302
+ return false;
46303
+ });
46304
+ }
46350
46305
  assertProtocolV2TargetStatus(statusTargets, expectedTargetIds) {
46351
- const failedTarget = statusTargets.find(target => expectedTargetIds.has(target.target_id) &&
46352
- target.status === PROTOCOL_V2_TARGET_STATUS_FAILED);
46306
+ const failedTarget = statusTargets.find(target => {
46307
+ var _a;
46308
+ return expectedTargetIds.has((_a = normalizeProtocolV2TargetId(target.target_id)) !== null && _a !== void 0 ? _a : -1) &&
46309
+ isProtocolV2TargetStatusFailed(target.status);
46310
+ });
46353
46311
  if (failedTarget) {
46354
46312
  throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.FirmwareError, `Protocol V2 firmware target ${failedTarget.target_id} failed`);
46355
46313
  }
46356
- const completedTargets = statusTargets.filter(target => expectedTargetIds.has(target.target_id) &&
46357
- target.status === PROTOCOL_V2_TARGET_STATUS_FINISHED);
46314
+ const completedTargets = statusTargets.filter(target => {
46315
+ var _a;
46316
+ return expectedTargetIds.has((_a = normalizeProtocolV2TargetId(target.target_id)) !== null && _a !== void 0 ? _a : -1) &&
46317
+ isProtocolV2TargetStatusFinished(target.status);
46318
+ });
46358
46319
  if (completedTargets.length === expectedTargetIds.size && expectedTargetIds.size > 0) {
46359
46320
  return true;
46360
46321
  }
46361
- const inProgressTarget = statusTargets.find(target => expectedTargetIds.has(target.target_id) &&
46362
- target.status === PROTOCOL_V2_TARGET_STATUS_IN_PROGRESS);
46322
+ const inProgressTarget = statusTargets.find(target => {
46323
+ var _a;
46324
+ return expectedTargetIds.has((_a = normalizeProtocolV2TargetId(target.target_id)) !== null && _a !== void 0 ? _a : -1) &&
46325
+ isProtocolV2TargetStatusInProgress(target.status);
46326
+ });
46363
46327
  if (inProgressTarget) {
46364
46328
  this.postProgressMessage(99, 'installingFirmware');
46365
46329
  }
@@ -46369,11 +46333,8 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
46369
46333
  var _a, _b;
46370
46334
  return __awaiter(this, void 0, void 0, function* () {
46371
46335
  const expectedTargetIds = new Set(targets.map(target => target.target_id));
46372
- if ((startResponse === null || startResponse === void 0 ? void 0 : startResponse.type) === 'Success') {
46373
- return;
46374
- }
46375
- if ((startResponse === null || startResponse === void 0 ? void 0 : startResponse.type) === 'DevFirmwareUpdateStatus') {
46376
- const statusTargets = ((_a = startResponse.message.targets) !== null && _a !== void 0 ? _a : []);
46336
+ if ((startResponse === null || startResponse === void 0 ? void 0 : startResponse.type) === 'DeviceFirmwareUpdateStatus') {
46337
+ const statusTargets = ((_a = startResponse.message.records) !== null && _a !== void 0 ? _a : []);
46377
46338
  if (this.assertProtocolV2TargetStatus(statusTargets, expectedTargetIds)) {
46378
46339
  return;
46379
46340
  }
@@ -46383,7 +46344,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
46383
46344
  while (Date.now() - startTime < PROTOCOL_V2_INSTALL_TIMEOUT) {
46384
46345
  try {
46385
46346
  const statusRes = yield this.queryProtocolV2FirmwareUpdateStatus();
46386
- const statusTargets = ((_b = statusRes.message.targets) !== null && _b !== void 0 ? _b : []);
46347
+ const statusTargets = ((_b = statusRes.message.records) !== null && _b !== void 0 ? _b : []);
46387
46348
  if (this.assertProtocolV2TargetStatus(statusTargets, expectedTargetIds)) {
46388
46349
  return;
46389
46350
  }
@@ -46397,15 +46358,17 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
46397
46358
  if (isProtocolV2PollingTransientError(error)) {
46398
46359
  try {
46399
46360
  yield this.reconnectProtocolV2Device();
46361
+ if (yield this.probeProtocolV2NormalMode()) {
46362
+ return;
46363
+ }
46400
46364
  }
46401
46365
  catch (reconnectError) {
46402
46366
  lastError = reconnectError;
46403
- Log$4.log('Protocol V2 firmware install reconnect/status polling failed: ', reconnectError);
46367
+ Log$4.log('Protocol V2 firmware install reconnect/normal-mode probe failed: ', reconnectError);
46404
46368
  }
46405
46369
  try {
46406
46370
  yield this.pingProtocolV2Device();
46407
46371
  Log$4.log('Protocol V2 firmware status unavailable, Ping is ready');
46408
- return;
46409
46372
  }
46410
46373
  catch (pingError) {
46411
46374
  lastError = pingError;
@@ -46421,7 +46384,17 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
46421
46384
  exitProtocolV2BootloaderToNormal() {
46422
46385
  return __awaiter(this, void 0, void 0, function* () {
46423
46386
  this.postTipMessage(exports.FirmwareUpdateTipMessage.SwitchFirmwareReconnectDevice);
46424
- yield this.protocolV2Reboot(hdTransport.DevRebootType.Normal);
46387
+ try {
46388
+ yield this.reconnectProtocolV2Device();
46389
+ if (yield this.probeProtocolV2NormalMode()) {
46390
+ Log$4.log('Protocol V2 device is already in normal mode, skip normal reboot');
46391
+ return;
46392
+ }
46393
+ }
46394
+ catch (error) {
46395
+ Log$4.log('Protocol V2 normal-mode probe before reboot failed: ', error);
46396
+ }
46397
+ yield this.protocolV2Reboot(hdTransport.DeviceRebootType.Normal);
46425
46398
  });
46426
46399
  }
46427
46400
  waitForProtocolV2FinalFeatures() {
@@ -46452,7 +46425,11 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
46452
46425
  timeoutMs: PROTOCOL_V2_SHORT_RESPONSE_TIMEOUT,
46453
46426
  request: PROTOCOL_V2_VERSIONS_DEVICE_INFO_REQUEST,
46454
46427
  });
46455
- return this.device.updateProtocolV2Features(deviceInfo);
46428
+ const features = this.device.updateProtocolV2Features(deviceInfo);
46429
+ if (features.bootloaderMode || features.mode === 'bootloader') {
46430
+ throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceNotFound, 'Protocol V2 device is still in bootloader mode');
46431
+ }
46432
+ return features;
46456
46433
  }
46457
46434
  catch (error) {
46458
46435
  lastError = error;
@@ -46464,7 +46441,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
46464
46441
  });
46465
46442
  }
46466
46443
  reconnectProtocolV2Device() {
46467
- var _a, _b, _c;
46444
+ var _a, _b, _c, _d;
46468
46445
  return __awaiter(this, void 0, void 0, function* () {
46469
46446
  if (this.isBleReconnect()) {
46470
46447
  yield this.acquireProtocolV2BleDevice();
@@ -46472,17 +46449,30 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
46472
46449
  }
46473
46450
  const deviceDiff = yield ((_a = this.device.deviceConnector) === null || _a === void 0 ? void 0 : _a.enumerate());
46474
46451
  const devicesDescriptor = (_b = deviceDiff === null || deviceDiff === void 0 ? void 0 : deviceDiff.descriptors) !== null && _b !== void 0 ? _b : [];
46475
- const { deviceList } = yield DevicePool.getDevices(devicesDescriptor, this.connectId);
46452
+ if (DataManager.isBrowserWebUsb(DataManager.getSettings('env')) &&
46453
+ devicesDescriptor.length === 1) {
46454
+ this.device.updateDescriptor(Object.assign(Object.assign({}, devicesDescriptor[0]), { protocolType: PROTOCOL_V2_CONNECT_PROTOCOL }), true);
46455
+ yield this.device.acquire(PROTOCOL_V2_CONNECT_PROTOCOL, { throwOnRunPromiseError: true });
46456
+ this.device.commands.disposed = false;
46457
+ this.device.getCommands().mainId = (_c = this.device.mainId) !== null && _c !== void 0 ? _c : '';
46458
+ yield this.device.initialize();
46459
+ return;
46460
+ }
46461
+ const { deviceList } = yield DevicePool.getDevices(devicesDescriptor, undefined, {
46462
+ connectProtocol: PROTOCOL_V2_CONNECT_PROTOCOL,
46463
+ });
46476
46464
  if (deviceList.length !== 1) {
46477
46465
  throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceNotFound);
46478
46466
  }
46467
+ Log$4.debug('Protocol V2 firmware reconnect using single enumerated device:', deviceList[0].getConnectId());
46479
46468
  this.device.updateFromCache(deviceList[0]);
46480
- yield this.device.acquire();
46469
+ yield this.device.acquire(PROTOCOL_V2_CONNECT_PROTOCOL, { throwOnRunPromiseError: true });
46481
46470
  this.device.commands.disposed = false;
46482
- this.device.getCommands().mainId = (_c = this.device.mainId) !== null && _c !== void 0 ? _c : '';
46471
+ this.device.getCommands().mainId = (_d = this.device.mainId) !== null && _d !== void 0 ? _d : '';
46472
+ yield this.device.initialize();
46483
46473
  });
46484
46474
  }
46485
- protocolV2CommonUpdateProcess({ payload, filePath, processedSize, totalSize, }) {
46475
+ protocolV2CommonUpdateProcess({ payload, filePath, processedSize, totalSize, onTransferredBytes, }) {
46486
46476
  return __awaiter(this, void 0, void 0, function* () {
46487
46477
  const chunkSize = this.getProtocolV2FirmwareChunkSize();
46488
46478
  let offset = 0;
@@ -46497,7 +46487,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
46497
46487
  const chunkLength = chunkEnd - offset;
46498
46488
  const chunk = payload.slice(offset, chunkEnd);
46499
46489
  const overwrite = offset === 0;
46500
- const progress = getUploadProgress(chunkEnd);
46490
+ 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);
46501
46491
  const writeRes = yield this.fileWriteWithRetry(filePath, payload.byteLength, offset, chunk, overwrite, progress);
46502
46492
  const processedByte = Number(writeRes.message.processed_byte);
46503
46493
  const nextOffset = Number.isFinite(processedByte) && processedByte > offset
@@ -46507,11 +46497,23 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
46507
46497
  throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.EmmcFileWriteFirmwareError, `invalid processed_byte ${writeRes.message.processed_byte} for offset ${offset}`);
46508
46498
  }
46509
46499
  offset = nextOffset;
46500
+ onTransferredBytes === null || onTransferredBytes === void 0 ? void 0 : onTransferredBytes((processedSize !== null && processedSize !== void 0 ? processedSize : 0) + offset);
46510
46501
  this.postProgressMessage(getUploadProgress(offset), 'transferData');
46511
46502
  }
46512
46503
  return totalSize !== undefined ? (processedSize !== null && processedSize !== void 0 ? processedSize : 0) + payload.byteLength : 0;
46513
46504
  });
46514
46505
  }
46506
+ getProtocolV2FirmwareTransferTransport() {
46507
+ const env = DataManager.getSettings('env');
46508
+ if (env && DataManager.isBleConnect(env)) {
46509
+ return 'BLE';
46510
+ }
46511
+ if (env &&
46512
+ (DataManager.isBrowserWebUsb(env) || DataManager.isDesktopWebUsb(env) || env === 'web')) {
46513
+ return 'WebUSB';
46514
+ }
46515
+ return env !== null && env !== void 0 ? env : 'unknown';
46516
+ }
46515
46517
  fileWriteWithRetry(filePath, totalFileSize, offset, chunk, overwrite, progress) {
46516
46518
  return __awaiter(this, void 0, void 0, function* () {
46517
46519
  const writeFunc = () => __awaiter(this, void 0, void 0, function* () {
@@ -46573,22 +46575,21 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
46573
46575
  const commands = this.device.getCommands();
46574
46576
  let response;
46575
46577
  try {
46576
- response = yield commands.typedCall('DevFirmwareUpdate', PROTOCOL_V2_FIRMWARE_UPDATE_RESPONSE_TYPES, {
46578
+ response = yield commands.typedCall('DeviceFirmwareUpdateRequest', PROTOCOL_V2_FIRMWARE_UPDATE_RESPONSE_TYPES, {
46577
46579
  targets,
46578
46580
  }, {
46579
- intermediateTypes: ['DevFirmwareInstallProgress'],
46581
+ intermediateTypes: ['DeviceFirmwareUpdateStatus'],
46582
+ timeoutMs: PROTOCOL_V2_START_UPDATE_TIMEOUT,
46580
46583
  onIntermediateResponse: (response) => {
46581
- var _a;
46582
- const progress = Number((_a = response.message) === null || _a === void 0 ? void 0 : _a.progress);
46583
- if (Number.isFinite(progress)) {
46584
- this.postProgressMessage(Math.min(progress, 99), 'installingFirmware');
46584
+ if (response.type === 'DeviceFirmwareUpdateStatus') {
46585
+ this.postProgressMessage(99, 'installingFirmware');
46585
46586
  }
46586
46587
  },
46587
46588
  });
46588
46589
  }
46589
46590
  catch (error) {
46590
- if (isProtocolV2DeviceDisconnectedError(error)) {
46591
- Log$4.log('Rebooting device');
46591
+ if (isProtocolV2StartUpdateTransientError(error)) {
46592
+ Log$4.log('Protocol V2 firmware update request did not return; continue status polling', error);
46592
46593
  }
46593
46594
  else {
46594
46595
  throw error;
@@ -46602,7 +46603,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
46602
46603
  return __awaiter(this, void 0, void 0, function* () {
46603
46604
  const typedCall = this.device.getCommands().typedCall.bind(this.device.getCommands());
46604
46605
  try {
46605
- const res = yield typedCall('DevReboot', 'Success', {
46606
+ const res = yield typedCall('DeviceReboot', 'Success', {
46606
46607
  reboot_type: rebootType,
46607
46608
  });
46608
46609
  return res.message;
@@ -46687,7 +46688,7 @@ class PromptWebDeviceAccess extends BaseMethod {
46687
46688
  }
46688
46689
  }
46689
46690
 
46690
- class GetProtoVersion extends BaseMethod {
46691
+ class ProtocolInfoRequest extends BaseMethod {
46691
46692
  init() {
46692
46693
  this.requireProtocolV2 = true;
46693
46694
  this.skipForceUpdateCheck = true;
@@ -46696,7 +46697,7 @@ class GetProtoVersion extends BaseMethod {
46696
46697
  }
46697
46698
  run() {
46698
46699
  return __awaiter(this, void 0, void 0, function* () {
46699
- const res = yield this.device.commands.typedCall('GetProtoVersion', 'ProtoVersion', {});
46700
+ const res = yield this.device.commands.typedCall('ProtocolInfoRequest', 'ProtocolInfo', {});
46700
46701
  return Promise.resolve(res.message);
46701
46702
  });
46702
46703
  }
@@ -46733,7 +46734,7 @@ class DeviceReboot extends BaseMethod {
46733
46734
  run() {
46734
46735
  var _a;
46735
46736
  return __awaiter(this, void 0, void 0, function* () {
46736
- const res = yield this.device.commands.typedCall('DevReboot', 'Success', {
46737
+ const res = yield this.device.commands.typedCall('DeviceReboot', 'Success', {
46737
46738
  reboot_type: normalizeRebootType((_a = this.params.reboot_type) !== null && _a !== void 0 ? _a : this.params.rebootType),
46738
46739
  });
46739
46740
  return Promise.resolve(res.message);
@@ -46744,7 +46745,7 @@ class DeviceReboot extends BaseMethod {
46744
46745
  const TARGET_KEYS = [
46745
46746
  'hw',
46746
46747
  'fw',
46747
- 'bt',
46748
+ 'coprocessor',
46748
46749
  'se1',
46749
46750
  'se2',
46750
46751
  'se3',
@@ -46755,7 +46756,7 @@ const TYPE_KEYS = ['version', 'build_id', 'hash', 'specific'];
46755
46756
  const DEFAULT_TARGETS = {
46756
46757
  hw: true,
46757
46758
  fw: true,
46758
- bt: true,
46759
+ coprocessor: true,
46759
46760
  status: true,
46760
46761
  };
46761
46762
  const DEFAULT_TYPES = {
@@ -46776,7 +46777,27 @@ function pickBooleanKeys(value, keys) {
46776
46777
  }
46777
46778
  return hasKey ? result : undefined;
46778
46779
  }
46779
- class DeviceGetDeviceInfo extends BaseMethod {
46780
+ function assertKnownKeys(value, keys, name) {
46781
+ if (value == null)
46782
+ return;
46783
+ if (typeof value !== 'object' || Array.isArray(value)) {
46784
+ throw invalidParameter(`Parameter [${name}] must be an object.`);
46785
+ }
46786
+ const allowed = new Set(keys);
46787
+ const unknownKeys = Object.keys(value).filter(key => !allowed.has(key));
46788
+ if (unknownKeys.length > 0) {
46789
+ throw invalidParameter(`Parameter [${name}] contains unsupported key(s): ${unknownKeys.join(', ')}.`);
46790
+ }
46791
+ }
46792
+ function normalizeTargets(value) {
46793
+ assertKnownKeys(value, TARGET_KEYS.map(key => String(key)), 'targets');
46794
+ return pickBooleanKeys(value, TARGET_KEYS);
46795
+ }
46796
+ function normalizeTypes(value) {
46797
+ assertKnownKeys(value, TYPE_KEYS.map(key => String(key)), 'types');
46798
+ return pickBooleanKeys(value, TYPE_KEYS);
46799
+ }
46800
+ class DeviceInfoGet extends BaseMethod {
46780
46801
  init() {
46781
46802
  var _a, _b;
46782
46803
  this.requireProtocolV2 = true;
@@ -46788,8 +46809,8 @@ class DeviceGetDeviceInfo extends BaseMethod {
46788
46809
  this.useDevicePassphraseState = false;
46789
46810
  this.skipForceUpdateCheck = true;
46790
46811
  this.params = {
46791
- targets: (_a = pickBooleanKeys(this.payload.targets, TARGET_KEYS)) !== null && _a !== void 0 ? _a : DEFAULT_TARGETS,
46792
- types: (_b = pickBooleanKeys(this.payload.types, TYPE_KEYS)) !== null && _b !== void 0 ? _b : DEFAULT_TYPES,
46812
+ targets: (_a = normalizeTargets(this.payload.targets)) !== null && _a !== void 0 ? _a : DEFAULT_TARGETS,
46813
+ types: (_b = normalizeTypes(this.payload.types)) !== null && _b !== void 0 ? _b : DEFAULT_TYPES,
46793
46814
  };
46794
46815
  }
46795
46816
  run() {
@@ -46797,7 +46818,7 @@ class DeviceGetDeviceInfo extends BaseMethod {
46797
46818
  if (!this.device.isProtocolV2()) {
46798
46819
  throw hdShared.createDeviceNotSupportMethodError(this.name, this.device.getCurrentFirmwareType());
46799
46820
  }
46800
- const res = yield this.device.commands.typedCall('DevGetDeviceInfo', 'DeviceInfo', {
46821
+ const res = yield this.device.commands.typedCall('DeviceInfoGet', 'DeviceInfo', {
46801
46822
  targets: this.params.targets,
46802
46823
  types: this.params.types,
46803
46824
  }, { timeoutMs: PROTOCOL_V2_DEVICE_INFO_TIMEOUT_MS });
@@ -46806,21 +46827,6 @@ class DeviceGetDeviceInfo extends BaseMethod {
46806
46827
  }
46807
46828
  }
46808
46829
 
46809
- class DeviceGetOnboardingStatus extends BaseMethod {
46810
- init() {
46811
- this.requireProtocolV2 = true;
46812
- this.skipForceUpdateCheck = true;
46813
- this.useDevicePassphraseState = false;
46814
- this.params = undefined;
46815
- }
46816
- run() {
46817
- return __awaiter(this, void 0, void 0, function* () {
46818
- const res = yield this.device.commands.typedCall('GetOnboardingStatus', 'OnboardingStatus', {});
46819
- return Promise.resolve(res.message);
46820
- });
46821
- }
46822
- }
46823
-
46824
46830
  class DeviceFirmwareUpdate extends BaseMethod {
46825
46831
  init() {
46826
46832
  this.requireProtocolV2 = true;
@@ -46837,18 +46843,14 @@ class DeviceFirmwareUpdate extends BaseMethod {
46837
46843
  return __awaiter(this, void 0, void 0, function* () {
46838
46844
  const targets = normalizeFirmwareTargets(this.params);
46839
46845
  try {
46840
- const res = yield this.device.commands.typedCall('DevFirmwareUpdate', PROTOCOL_V2_FIRMWARE_UPDATE_RESPONSE_TYPES, {
46846
+ const res = yield this.device.commands.typedCall('DeviceFirmwareUpdateRequest', PROTOCOL_V2_FIRMWARE_UPDATE_RESPONSE_TYPES, {
46841
46847
  targets,
46842
46848
  }, Object.assign(Object.assign({}, PROTOCOL_V2_FIRMWARE_UPDATE_OPTIONS), { onIntermediateResponse: (response) => {
46843
- var _a;
46844
- if (response.type !== 'DevFirmwareInstallProgress')
46845
- return;
46846
- const progress = Number((_a = response.message) === null || _a === void 0 ? void 0 : _a.progress);
46847
- if (!Number.isFinite(progress))
46849
+ if (response.type !== 'DeviceFirmwareUpdateStatus')
46848
46850
  return;
46849
46851
  this.postMessage(createUiMessage(UI_REQUEST.FIRMWARE_PROGRESS, {
46850
46852
  device: this.device.toMessageObject(),
46851
- progress: Math.min(Math.max(progress, 0), 100),
46853
+ progress: 99,
46852
46854
  progressType: 'installingFirmware',
46853
46855
  }));
46854
46856
  } }));
@@ -46875,61 +46877,42 @@ class DeviceGetFirmwareUpdateStatus extends BaseMethod {
46875
46877
  }
46876
46878
  run() {
46877
46879
  return __awaiter(this, void 0, void 0, function* () {
46878
- const res = yield this.device.commands.typedCall('DevGetFirmwareUpdateStatus', 'DevFirmwareUpdateStatus', {});
46879
- return Promise.resolve(res.message);
46880
- });
46881
- }
46882
- }
46883
-
46884
- class DevReboot extends BaseMethod {
46885
- init() {
46886
- this.requireProtocolV2 = true;
46887
- this.skipForceUpdateCheck = true;
46888
- this.useDevicePassphraseState = false;
46889
- this.params = {
46890
- rebootType: this.payload.rebootType,
46891
- reboot_type: this.payload.reboot_type,
46892
- };
46893
- }
46894
- run() {
46895
- var _a;
46896
- return __awaiter(this, void 0, void 0, function* () {
46897
- const res = yield this.device.commands.typedCall('DevReboot', 'Success', {
46898
- reboot_type: normalizeRebootType((_a = this.params.reboot_type) !== null && _a !== void 0 ? _a : this.params.rebootType),
46899
- });
46880
+ const res = yield this.device.commands.typedCall('DeviceFirmwareUpdateStatusGet', 'DeviceFirmwareUpdateStatus', {});
46900
46881
  return Promise.resolve(res.message);
46901
46882
  });
46902
46883
  }
46903
46884
  }
46904
46885
 
46905
- class FactoryDeviceInfoSettings extends BaseMethod {
46886
+ class DeviceFactoryInfoSet extends BaseMethod {
46906
46887
  init() {
46907
46888
  this.requireProtocolV2 = true;
46908
46889
  this.skipForceUpdateCheck = true;
46909
46890
  this.useDevicePassphraseState = false;
46910
46891
  this.params = {
46911
- serial_no: this.payload.serial_no,
46912
- serialNo: this.payload.serialNo,
46913
- cpu_info: this.payload.cpu_info,
46914
- cpuInfo: this.payload.cpuInfo,
46915
- pre_firmware: this.payload.pre_firmware,
46916
- preFirmware: this.payload.preFirmware,
46892
+ version: this.payload.version,
46893
+ serial_number: this.payload.serial_number,
46894
+ burn_in_completed: this.payload.burn_in_completed,
46895
+ factory_test_completed: this.payload.factory_test_completed,
46896
+ manufacture_time: this.payload.manufacture_time,
46917
46897
  };
46918
46898
  }
46919
46899
  run() {
46920
- var _a, _b, _c;
46921
46900
  return __awaiter(this, void 0, void 0, function* () {
46922
- const res = yield this.device.commands.typedCall('FactoryDeviceInfoSettings', 'Success', {
46923
- serial_no: (_a = this.params.serial_no) !== null && _a !== void 0 ? _a : this.params.serialNo,
46924
- cpu_info: (_b = this.params.cpu_info) !== null && _b !== void 0 ? _b : this.params.cpuInfo,
46925
- pre_firmware: (_c = this.params.pre_firmware) !== null && _c !== void 0 ? _c : this.params.preFirmware,
46901
+ const res = yield this.device.commands.typedCall('DeviceFactoryInfoSet', 'Success', {
46902
+ info: {
46903
+ version: this.params.version,
46904
+ serial_number: this.params.serial_number,
46905
+ burn_in_completed: this.params.burn_in_completed,
46906
+ factory_test_completed: this.params.factory_test_completed,
46907
+ manufacture_time: this.params.manufacture_time,
46908
+ },
46926
46909
  });
46927
46910
  return Promise.resolve(res.message);
46928
46911
  });
46929
46912
  }
46930
46913
  }
46931
46914
 
46932
- class FactoryGetDeviceInfo extends BaseMethod {
46915
+ class DeviceFactoryInfoGet extends BaseMethod {
46933
46916
  init() {
46934
46917
  this.requireProtocolV2 = true;
46935
46918
  this.skipForceUpdateCheck = true;
@@ -46938,13 +46921,13 @@ class FactoryGetDeviceInfo extends BaseMethod {
46938
46921
  }
46939
46922
  run() {
46940
46923
  return __awaiter(this, void 0, void 0, function* () {
46941
- const res = yield this.device.commands.typedCall('FactoryGetDeviceInfo', 'FactoryDeviceInfo', {});
46924
+ const res = yield this.device.commands.typedCall('DeviceFactoryInfoGet', 'DeviceFactoryInfo', {});
46942
46925
  return Promise.resolve(res.message);
46943
46926
  });
46944
46927
  }
46945
46928
  }
46946
46929
 
46947
- class FilesystemFixPermission extends BaseMethod {
46930
+ class FilesystemPermissionFix extends BaseMethod {
46948
46931
  init() {
46949
46932
  this.requireProtocolV2 = true;
46950
46933
  this.skipForceUpdateCheck = true;
@@ -46953,7 +46936,7 @@ class FilesystemFixPermission extends BaseMethod {
46953
46936
  }
46954
46937
  run() {
46955
46938
  return __awaiter(this, void 0, void 0, function* () {
46956
- const res = yield this.device.commands.typedCall('FilesystemFixPermission', 'Success', {});
46939
+ const res = yield this.device.commands.typedCall('FilesystemPermissionFix', 'Success', {});
46957
46940
  return Promise.resolve(res.message);
46958
46941
  });
46959
46942
  }
@@ -47056,6 +47039,18 @@ function toUint8Array(value) {
47056
47039
  }
47057
47040
  return new Uint8Array(0);
47058
47041
  }
47042
+ function getDeviceTransferProgress$1(bytesBeforeChunk, bytesAfterChunk, totalBytes) {
47043
+ if (!Number.isFinite(totalBytes) || totalBytes <= 0) {
47044
+ return 100;
47045
+ }
47046
+ if (bytesBeforeChunk <= 0 && bytesAfterChunk < totalBytes) {
47047
+ return 0;
47048
+ }
47049
+ if (bytesAfterChunk >= totalBytes) {
47050
+ return 100;
47051
+ }
47052
+ return Math.min(Math.max(Math.ceil((bytesAfterChunk / totalBytes) * 100), 1), 99);
47053
+ }
47059
47054
  class FileRead extends BaseMethod {
47060
47055
  init() {
47061
47056
  this.requireProtocolV2 = true;
@@ -47096,7 +47091,7 @@ class FileRead extends BaseMethod {
47096
47091
  while (read < totalLength) {
47097
47092
  const readLen = Math.min(chunkSize, totalLength - read);
47098
47093
  const offset = startOffset + read;
47099
- const progress = (_e = this.params.uiPercentage) !== null && _e !== void 0 ? _e : Math.min(Math.ceil(((read + readLen) / Math.max(totalLength, 1)) * 100), 99);
47094
+ const progress = (_e = this.params.uiPercentage) !== null && _e !== void 0 ? _e : getDeviceTransferProgress$1(read, read + readLen, totalLength);
47100
47095
  const res = yield this.device.commands.typedCall('FilesystemFileRead', 'FilesystemFile', {
47101
47096
  file: {
47102
47097
  path: this.params.path,
@@ -47169,6 +47164,18 @@ function getConfirmedProgress(processedByte, totalSize, written, dataLength) {
47169
47164
  }
47170
47165
  return 100;
47171
47166
  }
47167
+ function getDeviceTransferProgress(bytesBeforeChunk, bytesAfterChunk, totalBytes) {
47168
+ if (!Number.isFinite(totalBytes) || totalBytes <= 0) {
47169
+ return 100;
47170
+ }
47171
+ if (bytesBeforeChunk <= 0 && bytesAfterChunk < totalBytes) {
47172
+ return 0;
47173
+ }
47174
+ if (bytesAfterChunk >= totalBytes) {
47175
+ return 100;
47176
+ }
47177
+ return Math.min(Math.max(Math.ceil((bytesAfterChunk / totalBytes) * 100), 1), 99);
47178
+ }
47172
47179
  class FileWrite extends BaseMethod {
47173
47180
  init() {
47174
47181
  var _a, _b;
@@ -47218,7 +47225,7 @@ class FileWrite extends BaseMethod {
47218
47225
  const chunk = data.slice(written, chunkEnd);
47219
47226
  const offset = startOffset + written;
47220
47227
  const isFirstChunk = chunkIndex === 0;
47221
- const progress = (_e = this.params.uiPercentage) !== null && _e !== void 0 ? _e : Math.min(Math.ceil(((written + chunk.byteLength) / dataLength) * 100), 99);
47228
+ const progress = (_e = this.params.uiPercentage) !== null && _e !== void 0 ? _e : getDeviceTransferProgress(offset, offset + chunk.byteLength, totalSize);
47222
47229
  const res = yield this.device.commands.typedCall('FilesystemFileWrite', 'FilesystemFile', {
47223
47230
  file: {
47224
47231
  path: this.params.path,
@@ -54920,7 +54927,7 @@ class NostrSignEvent extends BaseMethod {
54920
54927
  const addressN = validatePath(payload.path, 5);
54921
54928
  this.params = {
54922
54929
  address_n: addressN,
54923
- event: bytesToHex(Buffer.from(JSON.stringify(payload.event, null, 0), 'utf-8')),
54930
+ event: bytesToHex$1(Buffer.from(JSON.stringify(payload.event, null, 0), 'utf-8')),
54924
54931
  };
54925
54932
  }
54926
54933
  getVersionRange() {
@@ -55102,8 +55109,8 @@ class LnurlAuth1 extends BaseMethod {
55102
55109
  { name: 'k1', type: 'string', required: true },
55103
55110
  ]);
55104
55111
  this.params = {
55105
- domain: bytesToHex(Buffer.from(payload.domain, 'utf-8')),
55106
- data: bytesToHex(Buffer.from(payload.k1, 'hex')),
55112
+ domain: bytesToHex$1(Buffer.from(payload.domain, 'utf-8')),
55113
+ data: bytesToHex$1(Buffer.from(payload.k1, 'hex')),
55107
55114
  };
55108
55115
  }
55109
55116
  getVersionRange() {
@@ -55762,11 +55769,7 @@ class TonSignData extends BaseMethod {
55762
55769
  };
55763
55770
  }
55764
55771
  getVersionRange() {
55765
- return {
55766
- pro2: {
55767
- min: '0.0.0',
55768
- },
55769
- };
55772
+ return {};
55770
55773
  }
55771
55774
  run() {
55772
55775
  return __awaiter(this, void 0, void 0, function* () {
@@ -56574,20 +56577,15 @@ var ApiMethods = /*#__PURE__*/Object.freeze({
56574
56577
  firmwareUpdateV3: FirmwareUpdateV3,
56575
56578
  firmwareUpdateV4: FirmwareUpdateV4,
56576
56579
  promptWebDeviceAccess: PromptWebDeviceAccess,
56577
- getProtoVersion: GetProtoVersion,
56580
+ protocolInfoRequest: ProtocolInfoRequest,
56578
56581
  ping: Ping,
56579
56582
  deviceReboot: DeviceReboot,
56580
- deviceGetDeviceInfo: DeviceGetDeviceInfo,
56581
- deviceGetOnboardingStatus: DeviceGetOnboardingStatus,
56583
+ deviceInfoGet: DeviceInfoGet,
56582
56584
  deviceFirmwareUpdate: DeviceFirmwareUpdate,
56583
56585
  deviceGetFirmwareUpdateStatus: DeviceGetFirmwareUpdateStatus,
56584
- devReboot: DevReboot,
56585
- devGetDeviceInfo: DeviceGetDeviceInfo,
56586
- devFirmwareUpdate: DeviceFirmwareUpdate,
56587
- devGetFirmwareUpdateStatus: DeviceGetFirmwareUpdateStatus,
56588
- factoryDeviceInfoSettings: FactoryDeviceInfoSettings,
56589
- factoryGetDeviceInfo: FactoryGetDeviceInfo,
56590
- filesystemFixPermission: FilesystemFixPermission,
56586
+ deviceFactoryInfoSet: DeviceFactoryInfoSet,
56587
+ deviceFactoryInfoGet: DeviceFactoryInfoGet,
56588
+ filesystemPermissionFix: FilesystemPermissionFix,
56591
56589
  filesystemFormat: FilesystemFormat,
56592
56590
  filesystemDiskControl: FilesystemDiskControl,
56593
56591
  fileRead: FileRead,
@@ -56992,6 +56990,7 @@ const parseInitOptions = (method) => ({
56992
56990
  deviceId: method === null || method === void 0 ? void 0 : method.payload.deviceId,
56993
56991
  deriveCardano: method && hasDeriveCardano(method),
56994
56992
  connectProtocol: method === null || method === void 0 ? void 0 : method.payload.connectProtocol,
56993
+ protocolV2DeviceInfoTimeoutMs: method === null || method === void 0 ? void 0 : method.payload.protocolV2DeviceInfoTimeoutMs,
56995
56994
  });
56996
56995
  let _core;
56997
56996
  let _deviceList;
@@ -57081,8 +57080,13 @@ const callAPI = (context, message) => __awaiter(void 0, void 0, void 0, function
57081
57080
  return onCallDevice(context, message, method);
57082
57081
  });
57083
57082
  const handlePreWarmSignal = (context, message, method) => __awaiter(void 0, void 0, void 0, function* () {
57084
- if (!method.connectId) {
57083
+ const createAckResponse = () => {
57084
+ completeMethodRequestContext(method);
57085
+ method.dispose();
57085
57086
  return createResponseMessage(method.responseID, true, true);
57087
+ };
57088
+ if (!method.connectId) {
57089
+ return createAckResponse();
57086
57090
  }
57087
57091
  const key = method.getPreWarmKey();
57088
57092
  const inflight = preWarmInflight.get(key);
@@ -57092,11 +57096,11 @@ const handlePreWarmSignal = (context, message, method) => __awaiter(void 0, void
57092
57096
  }
57093
57097
  catch (_b) {
57094
57098
  }
57095
- return createResponseMessage(method.responseID, true, true);
57099
+ return createAckResponse();
57096
57100
  }
57097
57101
  const doneAt = preWarmDoneAt.get(key);
57098
57102
  if (typeof doneAt === 'number' && Date.now() - doneAt <= method.preWarmTtl) {
57099
- return createResponseMessage(method.responseID, true, true);
57103
+ return createAckResponse();
57100
57104
  }
57101
57105
  const run = onCallDevice(context, message, method);
57102
57106
  preWarmInflight.set(key, run);
@@ -57405,6 +57409,13 @@ function initDevice(method) {
57405
57409
  }
57406
57410
  if (method.connectId) {
57407
57411
  device = _deviceList.getDevice(method.connectId);
57412
+ if (!device && method.name === 'firmwareUpdateV4' && allDevices.length === 1) {
57413
+ const [singleDevice] = allDevices;
57414
+ if (singleDevice.isBootloader()) {
57415
+ Log.debug('firmwareUpdateV4 uses the only bootloader device when connectId changed after reboot');
57416
+ device = singleDevice;
57417
+ }
57418
+ }
57408
57419
  }
57409
57420
  else if (allDevices.length === 1) {
57410
57421
  [device] = allDevices;
@@ -57933,14 +57944,12 @@ const initTransport = (Transport, plugin) => {
57933
57944
  TransportManager.setTransport(Transport, plugin);
57934
57945
  };
57935
57946
  const init = (settings, Transport, plugin) => __awaiter(void 0, void 0, void 0, function* () {
57936
- var _r;
57937
57947
  try {
57938
57948
  try {
57939
57949
  yield DataManager.load(settings);
57940
- setProtocolV2DeviceInfoMock((_r = settings.protocolV2DeviceInfoMockEnabled) !== null && _r !== void 0 ? _r : false);
57941
57950
  initTransport(Transport, plugin);
57942
57951
  }
57943
- catch (_s) {
57952
+ catch (_r) {
57944
57953
  Log.error('DataManager.load error');
57945
57954
  }
57946
57955
  enableLog(DataManager.getSettings('debug'));