@onekeyfe/hd-core 1.2.0-alpha.10 → 1.2.0-alpha.12

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 (122) hide show
  1. package/__tests__/DeviceCommands.test.ts +25 -0
  2. package/__tests__/RequestQueue.test.ts +34 -0
  3. package/__tests__/pro2Wallpaper.test.ts +50 -0
  4. package/__tests__/protocol-v2.test.ts +511 -61
  5. package/__tests__/protocolV2FileWrite.test.ts +55 -0
  6. package/dist/api/BaseMethod.d.ts +4 -0
  7. package/dist/api/BaseMethod.d.ts.map +1 -1
  8. package/dist/api/FileWrite.d.ts.map +1 -1
  9. package/dist/api/FirmwareUpdateV4.d.ts +0 -4
  10. package/dist/api/FirmwareUpdateV4.d.ts.map +1 -1
  11. package/dist/api/GetPassphraseState.d.ts +1 -6
  12. package/dist/api/GetPassphraseState.d.ts.map +1 -1
  13. package/dist/api/UploadPortfolio.d.ts +18 -0
  14. package/dist/api/UploadPortfolio.d.ts.map +1 -0
  15. package/dist/api/helpers/protocolV2FileWrite.d.ts +32 -0
  16. package/dist/api/helpers/protocolV2FileWrite.d.ts.map +1 -0
  17. package/dist/api/index.d.ts +6 -0
  18. package/dist/api/index.d.ts.map +1 -1
  19. package/dist/api/protocol-v2/DeviceGetOnboardingStatus.d.ts +6 -0
  20. package/dist/api/protocol-v2/DeviceGetOnboardingStatus.d.ts.map +1 -0
  21. package/dist/api/protocol-v2/DeviceSessionGet.d.ts +1 -4
  22. package/dist/api/protocol-v2/DeviceSessionGet.d.ts.map +1 -1
  23. package/dist/api/protocol-v2/DeviceSettingsGet.d.ts +6 -0
  24. package/dist/api/protocol-v2/DeviceSettingsGet.d.ts.map +1 -0
  25. package/dist/api/protocol-v2/DeviceSettingsPageShow.d.ts +16 -0
  26. package/dist/api/protocol-v2/DeviceSettingsPageShow.d.ts.map +1 -0
  27. package/dist/api/protocol-v2/DeviceSettingsSet.d.ts +12 -0
  28. package/dist/api/protocol-v2/DeviceSettingsSet.d.ts.map +1 -0
  29. package/dist/api/protocol-v2/DeviceUploadWallpaper.d.ts +26 -0
  30. package/dist/api/protocol-v2/DeviceUploadWallpaper.d.ts.map +1 -0
  31. package/dist/core/RequestQueue.d.ts +2 -0
  32. package/dist/core/RequestQueue.d.ts.map +1 -1
  33. package/dist/core/index.d.ts +1 -0
  34. package/dist/core/index.d.ts.map +1 -1
  35. package/dist/device/Device.d.ts.map +1 -1
  36. package/dist/device/DeviceCommands.d.ts +4 -4
  37. package/dist/device/DeviceCommands.d.ts.map +1 -1
  38. package/dist/deviceProfile/buildDeviceFeatures.d.ts +2 -2
  39. package/dist/deviceProfile/buildDeviceFeatures.d.ts.map +1 -1
  40. package/dist/deviceProfile/buildDeviceProfile.d.ts.map +1 -1
  41. package/dist/events/call.d.ts +7 -0
  42. package/dist/events/call.d.ts.map +1 -1
  43. package/dist/events/core.d.ts +2 -2
  44. package/dist/events/core.d.ts.map +1 -1
  45. package/dist/events/iframe.d.ts +1 -0
  46. package/dist/events/iframe.d.ts.map +1 -1
  47. package/dist/index.d.ts +80 -23
  48. package/dist/index.d.ts.map +1 -1
  49. package/dist/index.js +922 -472
  50. package/dist/inject.d.ts +3 -2
  51. package/dist/inject.d.ts.map +1 -1
  52. package/dist/lowLevelInject.d.ts +2 -1
  53. package/dist/lowLevelInject.d.ts.map +1 -1
  54. package/dist/protocols/protocol-v2/features.d.ts +1 -0
  55. package/dist/protocols/protocol-v2/features.d.ts.map +1 -1
  56. package/dist/protocols/protocol-v2/index.d.ts +1 -1
  57. package/dist/protocols/protocol-v2/index.d.ts.map +1 -1
  58. package/dist/protocols/protocol-v2/unlockRetry.d.ts +9 -0
  59. package/dist/protocols/protocol-v2/unlockRetry.d.ts.map +1 -0
  60. package/dist/protocols/protocol-v2/walletSession.d.ts.map +1 -1
  61. package/dist/topLevelInject.d.ts.map +1 -1
  62. package/dist/types/api/firmwareUpdate.d.ts +2 -0
  63. package/dist/types/api/firmwareUpdate.d.ts.map +1 -1
  64. package/dist/types/api/getDeviceInfo.d.ts +1 -1
  65. package/dist/types/api/getDeviceInfo.d.ts.map +1 -1
  66. package/dist/types/api/getPassphraseState.d.ts +2 -10
  67. package/dist/types/api/getPassphraseState.d.ts.map +1 -1
  68. package/dist/types/api/index.d.ts +9 -2
  69. package/dist/types/api/index.d.ts.map +1 -1
  70. package/dist/types/api/protocolV2.d.ts +20 -4
  71. package/dist/types/api/protocolV2.d.ts.map +1 -1
  72. package/dist/types/device.d.ts +1 -1
  73. package/dist/types/device.d.ts.map +1 -1
  74. package/dist/utils/deviceFeaturesUtils.d.ts +0 -2
  75. package/dist/utils/deviceFeaturesUtils.d.ts.map +1 -1
  76. package/dist/utils/index.d.ts +2 -0
  77. package/dist/utils/index.d.ts.map +1 -1
  78. package/dist/utils/patch.d.ts +1 -1
  79. package/dist/utils/patch.d.ts.map +1 -1
  80. package/dist/utils/pro2Wallpaper.d.ts +12 -0
  81. package/dist/utils/pro2Wallpaper.d.ts.map +1 -0
  82. package/package.json +4 -4
  83. package/src/api/BaseMethod.ts +18 -0
  84. package/src/api/FileWrite.ts +18 -178
  85. package/src/api/FirmwareUpdateV4.ts +21 -91
  86. package/src/api/GetPassphraseState.ts +9 -18
  87. package/src/api/UploadPortfolio.ts +37 -0
  88. package/src/api/helpers/protocolV2FileWrite.ts +164 -0
  89. package/src/api/index.ts +6 -0
  90. package/src/api/protocol-v2/DeviceGetOnboardingStatus.ts +18 -0
  91. package/src/api/protocol-v2/DeviceSessionGet.ts +3 -14
  92. package/src/api/protocol-v2/DeviceSettingsGet.ts +16 -0
  93. package/src/api/protocol-v2/DeviceSettingsPageShow.ts +59 -0
  94. package/src/api/protocol-v2/DeviceSettingsSet.ts +39 -0
  95. package/src/api/protocol-v2/DeviceUploadWallpaper.ts +124 -0
  96. package/src/core/RequestQueue.ts +19 -0
  97. package/src/core/index.ts +10 -1
  98. package/src/data/messages/messages-protocol-v2.json +92 -8
  99. package/src/device/Device.ts +17 -3
  100. package/src/device/DeviceCommands.ts +9 -3
  101. package/src/deviceProfile/buildDeviceFeatures.ts +20 -12
  102. package/src/deviceProfile/buildDeviceProfile.ts +8 -6
  103. package/src/events/call.ts +6 -0
  104. package/src/events/core.ts +2 -0
  105. package/src/events/iframe.ts +1 -0
  106. package/src/index.ts +4 -0
  107. package/src/inject.ts +15 -0
  108. package/src/lowLevelInject.ts +3 -0
  109. package/src/protocols/protocol-v2/features.ts +19 -1
  110. package/src/protocols/protocol-v2/index.ts +2 -0
  111. package/src/protocols/protocol-v2/unlockRetry.ts +46 -0
  112. package/src/protocols/protocol-v2/walletSession.ts +14 -5
  113. package/src/topLevelInject.ts +2 -0
  114. package/src/types/api/firmwareUpdate.ts +12 -0
  115. package/src/types/api/getDeviceInfo.ts +1 -1
  116. package/src/types/api/getPassphraseState.ts +2 -11
  117. package/src/types/api/index.ts +14 -1
  118. package/src/types/api/protocolV2.ts +52 -3
  119. package/src/types/device.ts +1 -0
  120. package/src/utils/deviceFeaturesUtils.ts +3 -8
  121. package/src/utils/index.ts +6 -0
  122. package/src/utils/pro2Wallpaper.ts +111 -0
package/dist/index.js CHANGED
@@ -101,7 +101,7 @@ const executeCallback = (id, ...args) => {
101
101
  const cleanupCallback = (id) => {
102
102
  callbackManager.delete(id);
103
103
  };
104
- const inject = ({ call, cancel, dispose, eventEmitter, init, updateSettings, switchTransport, uiResponse, }) => {
104
+ const inject = ({ call, cancel, cancelOperation, dispose, eventEmitter, init, updateSettings, switchTransport, uiResponse, }) => {
105
105
  const api = Object.assign({ on: (type, fn) => {
106
106
  eventEmitter.on(type, fn);
107
107
  }, emit: () => { }, off: (type, fn) => {
@@ -113,6 +113,7 @@ const inject = ({ call, cancel, dispose, eventEmitter, init, updateSettings, swi
113
113
  dispose,
114
114
  uiResponse,
115
115
  cancel,
116
+ cancelOperation,
116
117
  updateSettings,
117
118
  switchTransport }, createCoreApi(call));
118
119
  return api;
@@ -144,11 +145,16 @@ const createCoreApi = (call) => ({
144
145
  deviceReboot: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'deviceReboot' })),
145
146
  deviceInfoGet: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'deviceInfoGet' })),
146
147
  deviceStatusGet: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'deviceStatusGet' })),
148
+ deviceGetOnboardingStatus: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'deviceGetOnboardingStatus' })),
147
149
  deviceSessionGet: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'deviceSessionGet' })),
148
150
  deviceFirmwareUpdate: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'deviceFirmwareUpdate' })),
149
151
  deviceGetFirmwareUpdateStatus: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'deviceGetFirmwareUpdateStatus' })),
150
152
  deviceFactoryInfoSet: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'deviceFactoryInfoSet' })),
151
153
  deviceFactoryInfoGet: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'deviceFactoryInfoGet' })),
154
+ deviceSettingsGet: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'deviceSettingsGet' })),
155
+ deviceSettingsSet: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'deviceSettingsSet' })),
156
+ deviceSettingsPageShow: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'deviceSettingsPageShow' })),
157
+ deviceUploadWallpaper: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'deviceUploadWallpaper' })),
152
158
  filesystemPermissionFix: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'filesystemPermissionFix' })),
153
159
  fileRead: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'fileRead' })),
154
160
  fileWrite: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'fileWrite' })),
@@ -159,6 +165,7 @@ const createCoreApi = (call) => ({
159
165
  pathInfo: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'pathInfo' })),
160
166
  filesystemFileRead: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'filesystemFileRead' })),
161
167
  filesystemFileWrite: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'filesystemFileWrite' })),
168
+ uploadPortfolio: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'uploadPortfolio' })),
162
169
  filesystemFileDelete: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'filesystemFileDelete' })),
163
170
  filesystemDirList: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'filesystemDirList' })),
164
171
  filesystemDirMake: (connectId, params) => call(Object.assign(Object.assign({}, params), { connectId, method: 'filesystemDirMake' })),
@@ -293,7 +300,7 @@ const createCoreApi = (call) => ({
293
300
  neoSignTransaction: (connectId, deviceId, params) => call(Object.assign(Object.assign({}, params), { connectId, deviceId, method: 'neoSignTransaction' })),
294
301
  });
295
302
 
296
- const lowLevelInject = ({ call, cancel, dispose, eventEmitter, init, uiResponse, updateSettings, switchTransport, addHardwareGlobalEventListener, }) => {
303
+ const lowLevelInject = ({ call, cancel, cancelOperation, dispose, eventEmitter, init, uiResponse, updateSettings, switchTransport, addHardwareGlobalEventListener, }) => {
297
304
  const api = Object.assign({ addHardwareGlobalEventListener, removeAllListeners: type => {
298
305
  eventEmitter.removeAllListeners(type);
299
306
  }, init,
@@ -301,6 +308,7 @@ const lowLevelInject = ({ call, cancel, dispose, eventEmitter, init, uiResponse,
301
308
  dispose,
302
309
  uiResponse,
303
310
  cancel,
311
+ cancelOperation,
304
312
  updateSettings,
305
313
  switchTransport, emit: () => { } }, createCoreApi(call));
306
314
  return api;
@@ -803,7 +811,7 @@ const topLevelInject = () => {
803
811
  }, call }, createCoreApi(call)), { removeAllListeners: type => {
804
812
  eventEmitter.removeAllListeners(type);
805
813
  lowLevelApi === null || lowLevelApi === void 0 ? void 0 : lowLevelApi.removeAllListeners(type);
806
- }, dispose: () => lowLevelApi === null || lowLevelApi === void 0 ? void 0 : lowLevelApi.dispose(), uiResponse: response => lowLevelApi === null || lowLevelApi === void 0 ? void 0 : lowLevelApi.uiResponse(response), cancel: (connectId) => lowLevelApi === null || lowLevelApi === void 0 ? void 0 : lowLevelApi.cancel(connectId), updateSettings: settings => { var _a; return (_a = lowLevelApi === null || lowLevelApi === void 0 ? void 0 : lowLevelApi.updateSettings(settings)) !== null && _a !== void 0 ? _a : Promise.resolve(false); }, switchTransport: (env) => { var _a; return (_a = lowLevelApi === null || lowLevelApi === void 0 ? void 0 : lowLevelApi.switchTransport(env)) !== null && _a !== void 0 ? _a : Promise.resolve({ success: false }); } });
814
+ }, dispose: () => lowLevelApi === null || lowLevelApi === void 0 ? void 0 : lowLevelApi.dispose(), uiResponse: response => lowLevelApi === null || lowLevelApi === void 0 ? void 0 : lowLevelApi.uiResponse(response), cancel: (connectId) => lowLevelApi === null || lowLevelApi === void 0 ? void 0 : lowLevelApi.cancel(connectId), cancelOperation: (operationId) => lowLevelApi === null || lowLevelApi === void 0 ? void 0 : lowLevelApi.cancelOperation(operationId), updateSettings: settings => { var _a; return (_a = lowLevelApi === null || lowLevelApi === void 0 ? void 0 : lowLevelApi.updateSettings(settings)) !== null && _a !== void 0 ? _a : Promise.resolve(false); }, switchTransport: (env) => { var _a; return (_a = lowLevelApi === null || lowLevelApi === void 0 ? void 0 : lowLevelApi.switchTransport(env)) !== null && _a !== void 0 ? _a : Promise.resolve({ success: false }); } });
807
815
  return api;
808
816
  };
809
817
 
@@ -819,7 +827,7 @@ const createLogMessage = (type, payload) => ({
819
827
 
820
828
  const MAX_ENTRIES = 500;
821
829
  let postMessage$1;
822
- class Log$i {
830
+ class Log$j {
823
831
  constructor(prefix, enabled) {
824
832
  this.prefix = prefix;
825
833
  this.enabled = enabled;
@@ -871,7 +879,7 @@ class Log$i {
871
879
  }
872
880
  const _logs = {};
873
881
  const initLog = (prefix, enabled) => {
874
- const instance = new Log$i(prefix, !!enabled);
882
+ const instance = new Log$j(prefix, !!enabled);
875
883
  _logs[prefix] = instance;
876
884
  return instance;
877
885
  };
@@ -1069,7 +1077,7 @@ function patchFeatures(response) {
1069
1077
  return response;
1070
1078
  }
1071
1079
 
1072
- const Log$h = getLogger(exports.LoggerNames.Core);
1080
+ const Log$i = getLogger(exports.LoggerNames.Core);
1073
1081
  let globalInstanceCounter = 0;
1074
1082
  let sdkInstanceCounter = 0;
1075
1083
  function generateSdkInstanceId() {
@@ -1129,7 +1137,7 @@ function completeRequestContext(responseID, error) {
1129
1137
  context.status = error ? 'error' : 'success';
1130
1138
  if (error) {
1131
1139
  context.error = error.message;
1132
- Log$h.error(`[RequestContext] [completeRequestContext] Error: ${formatRequestContext(context)}`);
1140
+ Log$i.error(`[RequestContext] [completeRequestContext] Error: ${formatRequestContext(context)}`);
1133
1141
  }
1134
1142
  globalActiveRequests.delete(responseID);
1135
1143
  if (context.sdkInstanceId) {
@@ -25765,6 +25773,7 @@ var nested = {
25765
25773
  MessageType_DeviceSettings: 60410,
25766
25774
  MessageType_DeviceSettingsGet: 60411,
25767
25775
  MessageType_DeviceSettingsSet: 60412,
25776
+ MessageType_DeviceSettingsPageShow: 60413,
25768
25777
  MessageType_DeviceCertificate: 60420,
25769
25778
  MessageType_DeviceCertificateWrite: 60421,
25770
25779
  MessageType_DeviceCertificateRead: 60422,
@@ -32374,14 +32383,6 @@ var nested = {
32374
32383
  passphrase_state: {
32375
32384
  type: "string",
32376
32385
  id: 1
32377
- },
32378
- _only_main_pin: {
32379
- type: "bool",
32380
- id: 2
32381
- },
32382
- allow_create_attach_pin: {
32383
- type: "bool",
32384
- id: 3
32385
32386
  }
32386
32387
  }
32387
32388
  },
@@ -36737,6 +36738,20 @@ var nested = {
36737
36738
  }
36738
36739
  }
36739
36740
  },
36741
+ DeviceErrorCode: {
36742
+ values: {
36743
+ DeviceError_None: 0,
36744
+ DeviceError_Busy: 1,
36745
+ DeviceError_NotInitialized: 2,
36746
+ DeviceError_ActionCancelled: 3,
36747
+ DeviceError_PinAlreadyUsed: 4,
36748
+ DeviceError_PersistFailed: 5,
36749
+ DeviceError_SeError: 6,
36750
+ DeviceError_InvalidLanguage: 7,
36751
+ DeviceError_WallpaperNotUsable: 8,
36752
+ DeviceError_DeviceLocked: 9
36753
+ }
36754
+ },
36740
36755
  DeviceRebootType: {
36741
36756
  values: {
36742
36757
  Normal: 0,
@@ -36766,6 +36781,62 @@ var nested = {
36766
36781
  language: {
36767
36782
  type: "string",
36768
36783
  id: 3
36784
+ },
36785
+ wallpaper_path: {
36786
+ type: "string",
36787
+ id: 4
36788
+ },
36789
+ passphrase_enable: {
36790
+ type: "bool",
36791
+ id: 6
36792
+ },
36793
+ brightness: {
36794
+ type: "uint32",
36795
+ id: 7
36796
+ },
36797
+ autolock_delay_ms: {
36798
+ type: "uint32",
36799
+ id: 8
36800
+ },
36801
+ autoshutdown_delay_ms: {
36802
+ type: "uint32",
36803
+ id: 9
36804
+ },
36805
+ animation_enable: {
36806
+ type: "bool",
36807
+ id: 10
36808
+ },
36809
+ tap_to_wake: {
36810
+ type: "bool",
36811
+ id: 11
36812
+ },
36813
+ haptic_feedback: {
36814
+ type: "bool",
36815
+ id: 12
36816
+ },
36817
+ device_name_display_enabled: {
36818
+ type: "bool",
36819
+ id: 13
36820
+ },
36821
+ airgap_mode: {
36822
+ type: "bool",
36823
+ id: 14
36824
+ },
36825
+ fido_enabled: {
36826
+ type: "bool",
36827
+ id: 15
36828
+ },
36829
+ experimental_features: {
36830
+ type: "bool",
36831
+ id: 16
36832
+ },
36833
+ usb_lock_enable: {
36834
+ type: "bool",
36835
+ id: 17
36836
+ },
36837
+ random_keypad: {
36838
+ type: "bool",
36839
+ id: 18
36769
36840
  }
36770
36841
  }
36771
36842
  },
@@ -36782,6 +36853,27 @@ var nested = {
36782
36853
  }
36783
36854
  }
36784
36855
  },
36856
+ DeviceSettingsPage: {
36857
+ values: {
36858
+ DeviceReset: 0,
36859
+ DevicePinChange: 1,
36860
+ DevicePassphrase: 2,
36861
+ DeviceAirgap: 3
36862
+ }
36863
+ },
36864
+ DeviceSettingsPageShow: {
36865
+ fields: {
36866
+ page: {
36867
+ rule: "required",
36868
+ type: "DeviceSettingsPage",
36869
+ id: 1
36870
+ },
36871
+ field_name: {
36872
+ type: "string",
36873
+ id: 2
36874
+ }
36875
+ }
36876
+ },
36785
36877
  DeviceCertificate: {
36786
36878
  fields: {
36787
36879
  cert_and_pubkey: {
@@ -38373,7 +38465,7 @@ const findLatestRelease = (releases) => {
38373
38465
  };
38374
38466
 
38375
38467
  var _a$1;
38376
- const Log$g = getLogger(exports.LoggerNames.Core);
38468
+ const Log$h = getLogger(exports.LoggerNames.Core);
38377
38469
  const FIRMWARE_FIELDS = [
38378
38470
  'firmware',
38379
38471
  'firmware-v1',
@@ -38437,37 +38529,37 @@ class DataManager {
38437
38529
  let data = null;
38438
38530
  let fetchMethod = 'none';
38439
38531
  if (settings.configFetcher) {
38440
- Log$g.debug('[DataConfig] Trying configFetcher (client-side fetcher)...');
38532
+ Log$h.debug('[DataConfig] Trying configFetcher (client-side fetcher)...');
38441
38533
  try {
38442
38534
  data = yield settings.configFetcher(urlWithCache);
38443
38535
  if (data) {
38444
38536
  fetchMethod = 'configFetcher';
38445
- Log$g.log('[DataConfig] ConfigFetcher success');
38537
+ Log$h.log('[DataConfig] ConfigFetcher success');
38446
38538
  }
38447
38539
  else {
38448
- Log$g.debug('[DataConfig] ConfigFetcher returned null, will fallback to axios');
38540
+ Log$h.debug('[DataConfig] ConfigFetcher returned null, will fallback to axios');
38449
38541
  }
38450
38542
  }
38451
38543
  catch (e) {
38452
- Log$g.warn('[DataConfig] ConfigFetcher error, will fallback to axios:', e);
38544
+ Log$h.warn('[DataConfig] ConfigFetcher error, will fallback to axios:', e);
38453
38545
  }
38454
38546
  }
38455
38547
  if (!data) {
38456
- Log$g.debug('[DataConfig] Trying axios (SDK default fetcher)...');
38548
+ Log$h.debug('[DataConfig] Trying axios (SDK default fetcher)...');
38457
38549
  try {
38458
38550
  const response = yield axios__default["default"].get(urlWithCache, {
38459
38551
  timeout: 7000,
38460
38552
  });
38461
38553
  data = response.data;
38462
38554
  fetchMethod = 'axios';
38463
- Log$g.log('[DataConfig] Axios fetch success');
38555
+ Log$h.log('[DataConfig] Axios fetch success');
38464
38556
  }
38465
38557
  catch (e) {
38466
- Log$g.warn('[DataConfig] Axios fetch error:', e);
38558
+ Log$h.warn('[DataConfig] Axios fetch error:', e);
38467
38559
  }
38468
38560
  }
38469
38561
  if (data) {
38470
- Log$g.log(`[DataConfig] Config loaded successfully via [${fetchMethod}]`);
38562
+ Log$h.log(`[DataConfig] Config loaded successfully via [${fetchMethod}]`);
38471
38563
  this.deviceMap = {
38472
38564
  [hdShared.EDeviceType.Classic]: this.enrichFirmwareReleaseInfo(data.classic),
38473
38565
  [hdShared.EDeviceType.Classic1s]: this.enrichFirmwareReleaseInfo(data.classic1s),
@@ -38482,7 +38574,7 @@ class DataManager {
38482
38574
  };
38483
38575
  }
38484
38576
  else {
38485
- Log$g.warn('[DataConfig] All fetch methods failed, using built-in default config');
38577
+ Log$h.warn('[DataConfig] All fetch methods failed, using built-in default config');
38486
38578
  }
38487
38579
  });
38488
38580
  }
@@ -38796,7 +38888,14 @@ function getProtocolV2WalletSession(device, options) {
38796
38888
  }
38797
38889
  const cachedSessionId = typeof device.getInternalState === 'function' ? device.getInternalState() : undefined;
38798
38890
  try {
38799
- const { message } = yield device.commands.typedCall('DeviceSessionGet', 'DeviceSession', cachedSessionId ? { session_id: cachedSessionId } : {});
38891
+ const requestDeviceSession = (sessionId) => device.commands.typedCall('DeviceSessionGet', 'DeviceSession', sessionId ? { session_id: sessionId } : {});
38892
+ const { message } = yield requestDeviceSession(cachedSessionId).catch((error) => __awaiter(this, void 0, void 0, function* () {
38893
+ if (!cachedSessionId || !isProtocolV2InvalidSessionError(error)) {
38894
+ throw error;
38895
+ }
38896
+ device.clearInternalState();
38897
+ return requestDeviceSession();
38898
+ }));
38800
38899
  if ((options === null || options === void 0 ? void 0 : options.expectedPassphraseState) &&
38801
38900
  options.expectedPassphraseState !== message.btc_test_address) {
38802
38901
  device.clearInternalState();
@@ -38914,12 +39013,9 @@ const getPassphraseState = (device, options) => __awaiter(void 0, void 0, void 0
38914
39013
  const supportAttachPinCapability = existCapability(features, hdTransport.Enum_Capability.Capability_AttachToPin);
38915
39014
  const supportGetPassphraseState = supportAttachPinCapability || supportProSeriesAttachPinPassphrase(deviceType, firmwareVersion);
38916
39015
  if (supportGetPassphraseState) {
38917
- const payload = (options === null || options === void 0 ? void 0 : options.onlyMainPin)
38918
- ? { _only_main_pin: true }
38919
- : { passphrase_state: options === null || options === void 0 ? void 0 : options.expectPassphraseState };
38920
- if (options === null || options === void 0 ? void 0 : options.allowCreateAttachPin) {
38921
- payload.allow_create_attach_pin = true;
38922
- }
39016
+ const payload = {
39017
+ passphrase_state: (options === null || options === void 0 ? void 0 : options.onlyMainPin) ? undefined : options === null || options === void 0 ? void 0 : options.expectPassphraseState,
39018
+ };
38923
39019
  const { message, type } = yield commands.typedCall('GetPassphraseState', 'PassphraseState', payload);
38924
39020
  if (type === 'CallMethodError') {
38925
39021
  throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, 'Get the passphrase state error');
@@ -39619,6 +39715,93 @@ const getHomeScreenSize = ({ deviceType, homeScreenType, thumbnail, }) => {
39619
39715
  return thumbnail ? deviceConfig.thumbnail[homeScreenType] : deviceConfig.full;
39620
39716
  };
39621
39717
 
39718
+ const PRO2_WALLPAPER_WIDTH = 604;
39719
+ const PRO2_WALLPAPER_HEIGHT = 1024;
39720
+ const COLOR_FORMAT_RGB565 = 0x12;
39721
+ const COLOR_FORMAT_RGB565A8 = 0x14;
39722
+ const RED_THRESHOLD = [
39723
+ 1, 7, 3, 5, 0, 8, 2, 6, 7, 1, 5, 3, 8, 0, 6, 2, 3, 5, 0, 8, 2, 6, 1, 7, 5, 3, 8,
39724
+ 0, 6, 2, 7, 1, 0, 8, 2, 6, 1, 7, 3, 5, 8, 0, 6, 2, 7, 1, 5, 3, 2, 6, 1, 7, 3, 5, 0,
39725
+ 8, 6, 2, 7, 1, 5, 3, 8, 0,
39726
+ ];
39727
+ const GREEN_THRESHOLD = [
39728
+ 1, 3, 2, 2, 3, 1, 2, 2, 2, 2, 0, 4, 2, 2, 4, 0, 3, 1, 2, 2, 1, 3, 2, 2, 2, 2, 4,
39729
+ 0, 2, 2, 0, 4, 1, 3, 2, 2, 3, 1, 2, 2, 2, 2, 0, 4, 2, 2, 4, 0, 3, 1, 2, 2, 1, 3, 2,
39730
+ 2, 2, 2, 4, 0, 2, 2, 0, 4,
39731
+ ];
39732
+ const BLUE_THRESHOLD = [
39733
+ 5, 3, 8, 0, 6, 2, 7, 1, 3, 5, 0, 8, 2, 6, 1, 7, 8, 0, 6, 2, 7, 1, 5, 3, 0, 8, 2,
39734
+ 6, 1, 7, 3, 5, 6, 2, 7, 1, 5, 3, 8, 0, 2, 6, 1, 7, 3, 5, 0, 8, 7, 1, 5, 3, 8, 0, 6,
39735
+ 2, 1, 7, 3, 5, 0, 8, 2, 6,
39736
+ ];
39737
+ function invalidParameter$2(message) {
39738
+ return hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.CallMethodInvalidParameter, message);
39739
+ }
39740
+ function asBytes(rgba) {
39741
+ return rgba instanceof Uint8Array ? rgba : new Uint8Array(rgba);
39742
+ }
39743
+ function align(value, boundary) {
39744
+ return Math.ceil(value / boundary) * boundary;
39745
+ }
39746
+ function encodePro2Wallpaper(options) {
39747
+ const { width, height } = options;
39748
+ if (!Number.isInteger(width) || width <= 0 || width > 0xffff) {
39749
+ throw invalidParameter$2('Wallpaper width must be an integer between 1 and 65535.');
39750
+ }
39751
+ if (!Number.isInteger(height) || height <= 0 || height > 0xffff) {
39752
+ throw invalidParameter$2('Wallpaper height must be an integer between 1 and 65535.');
39753
+ }
39754
+ const rgba = asBytes(options.rgba);
39755
+ const expectedLength = width * height * 4;
39756
+ if (rgba.byteLength !== expectedLength) {
39757
+ throw invalidParameter$2(`Wallpaper RGBA data length must be ${expectedLength} bytes, received ${rgba.byteLength}.`);
39758
+ }
39759
+ let hasTransparency = false;
39760
+ for (let index = 3; index < rgba.length; index += 4) {
39761
+ if (rgba[index] !== 0xff) {
39762
+ hasTransparency = true;
39763
+ break;
39764
+ }
39765
+ }
39766
+ const colorFormat = hasTransparency ? 'RGB565A8' : 'RGB565';
39767
+ const stride = align(width * 2, 4);
39768
+ const alphaStride = stride / 2;
39769
+ const rgbSize = stride * height;
39770
+ const alphaSize = hasTransparency ? alphaStride * height : 0;
39771
+ const data = new Uint8Array(12 + rgbSize + alphaSize);
39772
+ const view = new DataView(data.buffer);
39773
+ data[0] = 0x19;
39774
+ data[1] = hasTransparency ? COLOR_FORMAT_RGB565A8 : COLOR_FORMAT_RGB565;
39775
+ view.setUint16(2, 0, true);
39776
+ view.setUint16(4, width, true);
39777
+ view.setUint16(6, height, true);
39778
+ view.setUint16(8, stride, true);
39779
+ view.setUint16(10, 0, true);
39780
+ for (let y = 0; y < height; y += 1) {
39781
+ for (let x = 0; x < width; x += 1) {
39782
+ const sourceOffset = (y * width + x) * 4;
39783
+ const thresholdIndex = ((y & 7) << 3) + (x & 7);
39784
+ let red = Math.min(rgba[sourceOffset] + RED_THRESHOLD[thresholdIndex], 0xff) & 0xf8;
39785
+ let green = Math.min(rgba[sourceOffset + 1] + GREEN_THRESHOLD[thresholdIndex], 0xff) & 0xfc;
39786
+ let blue = Math.min(rgba[sourceOffset + 2] + BLUE_THRESHOLD[thresholdIndex], 0xff) & 0xf8;
39787
+ if (!hasTransparency) {
39788
+ const alpha = rgba[sourceOffset + 3];
39789
+ red = (red * alpha) >> 8;
39790
+ green = (green * alpha) >> 8;
39791
+ blue = (blue * alpha) >> 8;
39792
+ }
39793
+ const rgb565 = ((red >> 3) << 11) | ((green >> 2) << 5) | (blue >> 3);
39794
+ const rgbOffset = 12 + y * stride + x * 2;
39795
+ data[rgbOffset] = rgb565 & 0xff;
39796
+ data[rgbOffset + 1] = rgb565 >> 8;
39797
+ if (hasTransparency) {
39798
+ data[12 + rgbSize + y * alphaStride + x] = rgba[sourceOffset + 3];
39799
+ }
39800
+ }
39801
+ }
39802
+ return { data, colorFormat };
39803
+ }
39804
+
39622
39805
  const isBleConnect = (env) => env === 'react-native' || env === 'lowlevel';
39623
39806
  const wait = (ms) => new Promise(resolve => {
39624
39807
  setTimeout(resolve, ms);
@@ -39748,6 +39931,7 @@ const IFRAME = {
39748
39931
  INIT_BRIDGE: 'iframe-init-bridge',
39749
39932
  CALL: 'iframe-call',
39750
39933
  CANCEL: 'iframe-cancel',
39934
+ CANCEL_OPERATION: 'iframe-cancel-operation',
39751
39935
  SWITCH_TRANSPORT: 'iframe-switch-transport',
39752
39936
  CALLBACK: 'iframe-callback',
39753
39937
  };
@@ -39837,7 +40021,7 @@ function getLogBlockLabel(message) {
39837
40021
  return undefined;
39838
40022
  }
39839
40023
 
39840
- const Log$f = getLogger(exports.LoggerNames.DevicePool);
40024
+ const Log$g = getLogger(exports.LoggerNames.DevicePool);
39841
40025
  const getDiff = (current, descriptors) => {
39842
40026
  const connected = descriptors.filter(d => current.find(x => x.path === d.path) === undefined);
39843
40027
  const disconnected = current.filter(d => descriptors.find(x => x.path === d.path) === undefined);
@@ -39895,7 +40079,7 @@ class DevicePool extends events.exports {
39895
40079
  yield this._checkDevicePool(initOptions);
39896
40080
  return { devices, deviceList };
39897
40081
  }
39898
- Log$f.debug('found device in cache, but path is different: ', connectId);
40082
+ Log$g.debug('found device in cache, but path is different: ', connectId);
39899
40083
  }
39900
40084
  }
39901
40085
  try {
@@ -39956,7 +40140,7 @@ class DevicePool extends events.exports {
39956
40140
  for (let i = this.connectedPool.length - 1; i >= 0; i--) {
39957
40141
  const descriptor = this.connectedPool[i];
39958
40142
  const device = yield this._createDevice(descriptor, initOptions);
39959
- Log$f.debug('emit DEVICE.CONNECT: ', device === null || device === void 0 ? void 0 : device.features);
40143
+ Log$g.debug('emit DEVICE.CONNECT: ', device === null || device === void 0 ? void 0 : device.features);
39960
40144
  this.emitter.emit(DEVICE.CONNECT, device);
39961
40145
  this.connectedPool.splice(i, 1);
39962
40146
  }
@@ -39976,9 +40160,9 @@ class DevicePool extends events.exports {
39976
40160
  const diff = getDiff(this.current || [], upcoming);
39977
40161
  this.upcoming = upcoming;
39978
40162
  this.current = this.upcoming;
39979
- Log$f.debug('device pool -> current: ', this.current);
39980
- Log$f.debug('device pool -> upcomming: ', this.upcoming);
39981
- Log$f.debug('DeviceCache.reportDeviceChange diff: ', diff);
40163
+ Log$g.debug('device pool -> current: ', this.current);
40164
+ Log$g.debug('device pool -> upcomming: ', this.upcoming);
40165
+ Log$g.debug('DeviceCache.reportDeviceChange diff: ', diff);
39982
40166
  if (!diff.didUpdate) {
39983
40167
  return;
39984
40168
  }
@@ -39988,7 +40172,7 @@ class DevicePool extends events.exports {
39988
40172
  this._addConnectedDeviceToPool(d);
39989
40173
  return;
39990
40174
  }
39991
- Log$f.debug('emit DEVICE.CONNECT: ', device.features);
40175
+ Log$g.debug('emit DEVICE.CONNECT: ', device.features);
39992
40176
  this.emitter.emit(DEVICE.CONNECT, device);
39993
40177
  });
39994
40178
  diff.disconnected.forEach(d => {
@@ -39998,7 +40182,7 @@ class DevicePool extends events.exports {
39998
40182
  this._addDisconnectedDeviceToPool(d);
39999
40183
  return;
40000
40184
  }
40001
- Log$f.debug('emit DEVICE.DISCONNECT: ', device.features);
40185
+ Log$g.debug('emit DEVICE.DISCONNECT: ', device.features);
40002
40186
  this.emitter.emit(DEVICE.DISCONNECT, device);
40003
40187
  });
40004
40188
  }
@@ -40034,7 +40218,7 @@ class DevicePool extends events.exports {
40034
40218
  this.disconnectPool = [];
40035
40219
  this.devicesCache = {};
40036
40220
  this.emitter.removeAllListeners();
40037
- Log$f.debug('DevicePool state has been reset');
40221
+ Log$g.debug('DevicePool state has been reset');
40038
40222
  }
40039
40223
  }
40040
40224
  DevicePool.current = null;
@@ -40044,7 +40228,7 @@ DevicePool.disconnectPool = [];
40044
40228
  DevicePool.devicesCache = {};
40045
40229
  DevicePool.emitter = new events.exports();
40046
40230
 
40047
- const Log$e = getLogger(exports.LoggerNames.Transport);
40231
+ const Log$f = getLogger(exports.LoggerNames.Transport);
40048
40232
  const BleLogger = getLogger(exports.LoggerNames.HdBleTransport);
40049
40233
  const HttpLogger = getLogger(exports.LoggerNames.HdTransportHttp);
40050
40234
  const LowLevelLogger = getLogger(exports.LoggerNames.HdTransportLowLevel);
@@ -40054,7 +40238,7 @@ const WebUsbLogger = getLogger(exports.LoggerNames.HdTransportWebUsb);
40054
40238
  const REACT_NATIVE_BLE_SCAN_TIMEOUT_MS = 8000;
40055
40239
  class TransportManager {
40056
40240
  static load() {
40057
- Log$e.debug('transport manager load');
40241
+ Log$f.debug('transport manager load');
40058
40242
  this.defaultMessages = DataManager.getProtobufMessages();
40059
40243
  this.currentMessages = this.defaultMessages;
40060
40244
  this.protocolV1MessageSchema = 'v1CurrentSchema';
@@ -40063,14 +40247,14 @@ class TransportManager {
40063
40247
  return __awaiter(this, void 0, void 0, function* () {
40064
40248
  try {
40065
40249
  const env = DataManager.getSettings('env');
40066
- Log$e.debug('Initializing transports', env);
40250
+ Log$f.debug('Initializing transports', env);
40067
40251
  if (env === 'react-native') {
40068
40252
  if (!this.reactNativeInit) {
40069
40253
  yield this.transport.init(BleLogger, DevicePool.emitter);
40070
40254
  this.reactNativeInit = true;
40071
40255
  }
40072
40256
  else {
40073
- Log$e.debug('React Native Do Not Initializing transports');
40257
+ Log$f.debug('React Native Do Not Initializing transports');
40074
40258
  }
40075
40259
  }
40076
40260
  else if (env === 'node-usb') {
@@ -40091,15 +40275,15 @@ class TransportManager {
40091
40275
  else {
40092
40276
  yield this.transport.init(HttpLogger);
40093
40277
  }
40094
- Log$e.debug('Configuring transports');
40278
+ Log$f.debug('Configuring transports');
40095
40279
  yield this.transport.configure(JSON.stringify(this.defaultMessages));
40096
40280
  this.currentMessages = this.defaultMessages;
40097
40281
  this.protocolV1MessageSchema = 'v1CurrentSchema';
40098
40282
  yield this.configureProtocolV2Messages();
40099
- Log$e.debug('Configuring transports done');
40283
+ Log$f.debug('Configuring transports done');
40100
40284
  }
40101
40285
  catch (error) {
40102
- Log$e.debug('Initializing transports error: ', error);
40286
+ Log$f.debug('Initializing transports error: ', error);
40103
40287
  if (error.code === 'ECONNABORTED') {
40104
40288
  throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.BridgeTimeoutError);
40105
40289
  }
@@ -40115,7 +40299,7 @@ class TransportManager {
40115
40299
  if (this.currentMessages === messages || !messages) {
40116
40300
  return;
40117
40301
  }
40118
- Log$e.debug(`Reconfiguring transports Protocol V1 schema:${protocolV1MessageSchema}`);
40302
+ Log$f.debug(`Reconfiguring transports Protocol V1 schema:${protocolV1MessageSchema}`);
40119
40303
  try {
40120
40304
  yield this.transport.configure(JSON.stringify(messages));
40121
40305
  this.currentMessages = messages;
@@ -40138,9 +40322,9 @@ class TransportManager {
40138
40322
  }
40139
40323
  if (plugin) {
40140
40324
  this.plugin = plugin;
40141
- Log$e.debug('set transport plugin: ', this.plugin);
40325
+ Log$f.debug('set transport plugin: ', this.plugin);
40142
40326
  }
40143
- Log$e.debug('set transport: ', this.transport.name, this.transport.version, this.transport.configured);
40327
+ Log$f.debug('set transport: ', this.transport.name, this.transport.version, this.transport.configured);
40144
40328
  }
40145
40329
  static getTransport() {
40146
40330
  return this.transport;
@@ -40151,7 +40335,7 @@ class TransportManager {
40151
40335
  const { configureProtocolV2 } = this.transport;
40152
40336
  if (protocolV2Messages && typeof configureProtocolV2 === 'function') {
40153
40337
  yield configureProtocolV2.call(this.transport, JSON.stringify(protocolV2Messages));
40154
- Log$e.debug('Protocol V2 messages configured');
40338
+ Log$f.debug('Protocol V2 messages configured');
40155
40339
  }
40156
40340
  });
40157
40341
  }
@@ -40329,7 +40513,7 @@ const cancelDeviceWithInitialize = (device) => {
40329
40513
  },
40330
40514
  }));
40331
40515
  };
40332
- const Log$d = getLogger(exports.LoggerNames.DeviceCommands);
40516
+ const Log$e = getLogger(exports.LoggerNames.DeviceCommands);
40333
40517
  const LogCore = getLogger(exports.LoggerNames.Core);
40334
40518
  class DeviceCommands {
40335
40519
  constructor(device, mainId) {
@@ -40338,7 +40522,7 @@ class DeviceCommands {
40338
40522
  this.transport = TransportManager.getTransport();
40339
40523
  this.disposed = false;
40340
40524
  this.instanceId = generateInstanceId('DeviceCommands', device.sdkInstanceId);
40341
- Log$d.debug(`[DeviceCommands] Created: ${this.instanceId}, device: ${this.device.instanceId}`);
40525
+ Log$e.debug(`[DeviceCommands] Created: ${this.instanceId}, device: ${this.device.instanceId}`);
40342
40526
  }
40343
40527
  dispose(_cancelRequest) {
40344
40528
  var _a, _b;
@@ -40408,7 +40592,7 @@ class DeviceCommands {
40408
40592
  return __awaiter(this, void 0, void 0, function* () {
40409
40593
  const shouldReduceDebug = shouldReduceDebugForCall(type);
40410
40594
  if (!shouldReduceDebug) {
40411
- Log$d.debug('[DeviceCommands] [call] Sending', type);
40595
+ Log$e.debug('[DeviceCommands] [call] Sending', type);
40412
40596
  }
40413
40597
  try {
40414
40598
  const promise = this.transport.call(this.mainId, type, msg !== null && msg !== void 0 ? msg : {}, options);
@@ -40443,7 +40627,7 @@ class DeviceCommands {
40443
40627
  }
40444
40628
  }
40445
40629
  if (responseData) {
40446
- Log$d.debug('error response', responseData);
40630
+ Log$e.debug('error response', responseData);
40447
40631
  }
40448
40632
  if (responseError === 'device disconnected during action') {
40449
40633
  return { type: 'BridgeDeviceDisconnected', message: { error: responseError } };
@@ -40483,7 +40667,7 @@ class DeviceCommands {
40483
40667
  'ResourceAck',
40484
40668
  ];
40485
40669
  if (!skipTypes.includes(type) && msg) {
40486
- Log$d.debug('[DeviceCommands] [typedCall] Sending payload', type, sanitizeDebugPayload(msg));
40670
+ Log$e.debug('[DeviceCommands] [typedCall] Sending payload', type, sanitizeDebugPayload(msg));
40487
40671
  }
40488
40672
  }
40489
40673
  catch (e) {
@@ -40494,10 +40678,10 @@ class DeviceCommands {
40494
40678
  assertType(response, resType);
40495
40679
  }
40496
40680
  catch (error) {
40497
- Log$d.debug('DeviceCommands typedcall error: ', error);
40681
+ Log$e.debug('DeviceCommands typedcall error: ', error);
40498
40682
  if (error instanceof hdShared.HardwareError) {
40499
40683
  if (error.errorCode === hdShared.HardwareErrorCode.ResponseUnexpectTypeError) {
40500
- Log$d.debug('[DeviceCommands] [typedCall] Unexpected response type', {
40684
+ Log$e.debug('[DeviceCommands] [typedCall] Unexpected response type', {
40501
40685
  request: type,
40502
40686
  expected: resType,
40503
40687
  received: response.type,
@@ -40533,17 +40717,17 @@ class DeviceCommands {
40533
40717
  if (shouldReduceDebugForCall(callType)) {
40534
40718
  }
40535
40719
  else if (DataManager.getSettings('env') === 'react-native') {
40536
- Log$d.debug('_filterCommonTypes: ', JSON.stringify(sanitizeDebugPayload(res)));
40720
+ Log$e.debug('_filterCommonTypes: ', JSON.stringify(sanitizeDebugPayload(res)));
40537
40721
  }
40538
40722
  else {
40539
- Log$d.debug('_filterCommonTypes: ', sanitizeDebugPayload(res));
40723
+ Log$e.debug('_filterCommonTypes: ', sanitizeDebugPayload(res));
40540
40724
  }
40541
40725
  }
40542
40726
  catch (error) {
40543
40727
  }
40544
40728
  this.device.clearCancelableAction();
40545
40729
  if (res.type === 'Failure') {
40546
- const { code, message } = res.message;
40730
+ const { code, subcode, message } = res.message;
40547
40731
  let error = null;
40548
40732
  if (code === 'Failure_FirmwareError' && !message) {
40549
40733
  error = hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.FirmwareError);
@@ -40578,7 +40762,14 @@ class DeviceCommands {
40578
40762
  }
40579
40763
  }
40580
40764
  if (code === 'Failure_ProcessError') {
40581
- if ((message === null || message === void 0 ? void 0 : message.includes('Bootloader file verify failed')) ||
40765
+ if (subcode === 9) {
40766
+ error = hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceLocked, message, {
40767
+ failureCode: code,
40768
+ subcode,
40769
+ firmwareMessage: message,
40770
+ });
40771
+ }
40772
+ else if ((message === null || message === void 0 ? void 0 : message.includes('Bootloader file verify failed')) ||
40582
40773
  (message === null || message === void 0 ? void 0 : message.includes('verify failed'))) {
40583
40774
  error = hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.FirmwareVerificationFailed, message);
40584
40775
  }
@@ -40665,7 +40856,7 @@ class DeviceCommands {
40665
40856
  reject(error);
40666
40857
  });
40667
40858
  const listenerCount = this.device.listenerCount(DEVICE.PIN);
40668
- Log$d.debug(`[${this.instanceId}] _promptPin called`, {
40859
+ Log$e.debug(`[${this.instanceId}] _promptPin called`, {
40669
40860
  responseID: this.currentResponseID,
40670
40861
  deviceInstanceId: this.device.instanceId,
40671
40862
  listenerCount,
@@ -40811,7 +41002,20 @@ class DeviceWalletSessionStore {
40811
41002
  }
40812
41003
  const deviceWalletSessionStore = new DeviceWalletSessionStore();
40813
41004
 
40814
- const isProtocolV2BootloaderDeviceInfo = (deviceInfo) => !!deviceInfo && deviceInfo.status == null;
41005
+ const isProtocolV2RomloaderDeviceInfo = (deviceInfo) => {
41006
+ var _a, _b, _c;
41007
+ return !!deviceInfo &&
41008
+ deviceInfo.status == null &&
41009
+ ((_a = deviceInfo.fw) === null || _a === void 0 ? void 0 : _a.romloader) != null &&
41010
+ ((_b = deviceInfo.fw) === null || _b === void 0 ? void 0 : _b.application) == null &&
41011
+ ((_c = deviceInfo.fw) === null || _c === void 0 ? void 0 : _c.application_data) == null &&
41012
+ deviceInfo.coprocessor == null &&
41013
+ deviceInfo.se1 == null &&
41014
+ deviceInfo.se2 == null &&
41015
+ deviceInfo.se3 == null &&
41016
+ deviceInfo.se4 == null;
41017
+ };
41018
+ const isProtocolV2BootloaderDeviceInfo = (deviceInfo) => !!deviceInfo && deviceInfo.status == null && !isProtocolV2RomloaderDeviceInfo(deviceInfo);
40815
41019
  const PROTOCOL_V2_FEATURES_DEVICE_INFO_REQUEST = {
40816
41020
  targets: {
40817
41021
  hw: true,
@@ -40920,6 +41124,8 @@ const getDeviceMode = (features) => {
40920
41124
  };
40921
41125
  const getProtocolV2Mode = (deviceInfo) => {
40922
41126
  var _a;
41127
+ if (isProtocolV2RomloaderDeviceInfo(deviceInfo))
41128
+ return 'romloader';
40923
41129
  if (isProtocolV2BootloaderDeviceInfo(deviceInfo))
40924
41130
  return 'bootloader';
40925
41131
  const initialized = (_a = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.status) === null || _a === void 0 ? void 0 : _a.init_states;
@@ -40944,21 +41150,21 @@ const normalizeV1Versions = (features, protocolV1OneKeyFeatures) => ({
40944
41150
  se04Boot: firstMeaningfulVersion$1(protocolV1OneKeyFeatures === null || protocolV1OneKeyFeatures === void 0 ? void 0 : protocolV1OneKeyFeatures.onekey_se04_boot_version, features === null || features === void 0 ? void 0 : features.se04BootVersion),
40945
41151
  });
40946
41152
  const normalizeV2Versions = (deviceInfo) => {
40947
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
41153
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
40948
41154
  const info = deviceInfo;
40949
41155
  return {
40950
41156
  firmware: firstMeaningfulVersion$1(getImageVersion$1((_a = info === null || info === void 0 ? void 0 : info.fw) === null || _a === void 0 ? void 0 : _a.application)),
40951
41157
  bootloader: firstMeaningfulVersion$1(getImageVersion$1((_b = info === null || info === void 0 ? void 0 : info.fw) === null || _b === void 0 ? void 0 : _b.bootloader)),
40952
- 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)),
40953
- ble: firstMeaningfulVersion$1(getImageVersion$1((_f = info === null || info === void 0 ? void 0 : info.coprocessor) === null || _f === void 0 ? void 0 : _f.application)),
40954
- se01: firstMeaningfulVersion$1(getImageVersion$1((_g = info === null || info === void 0 ? void 0 : info.se1) === null || _g === void 0 ? void 0 : _g.application)),
40955
- se02: firstMeaningfulVersion$1(getImageVersion$1((_h = info === null || info === void 0 ? void 0 : info.se2) === null || _h === void 0 ? void 0 : _h.application)),
40956
- se03: firstMeaningfulVersion$1(getImageVersion$1((_j = info === null || info === void 0 ? void 0 : info.se3) === null || _j === void 0 ? void 0 : _j.application)),
40957
- se04: firstMeaningfulVersion$1(getImageVersion$1((_k = info === null || info === void 0 ? void 0 : info.se4) === null || _k === void 0 ? void 0 : _k.application)),
40958
- se01Boot: firstMeaningfulVersion$1(getImageVersion$1((_l = info === null || info === void 0 ? void 0 : info.se1) === null || _l === void 0 ? void 0 : _l.bootloader)),
40959
- se02Boot: firstMeaningfulVersion$1(getImageVersion$1((_m = info === null || info === void 0 ? void 0 : info.se2) === null || _m === void 0 ? void 0 : _m.bootloader)),
40960
- se03Boot: firstMeaningfulVersion$1(getImageVersion$1((_o = info === null || info === void 0 ? void 0 : info.se3) === null || _o === void 0 ? void 0 : _o.bootloader)),
40961
- se04Boot: firstMeaningfulVersion$1(getImageVersion$1((_p = info === null || info === void 0 ? void 0 : info.se4) === null || _p === void 0 ? void 0 : _p.bootloader)),
41158
+ board: firstMeaningfulVersion$1(getImageVersion$1((_c = info === null || info === void 0 ? void 0 : info.fw) === null || _c === void 0 ? void 0 : _c.romloader)),
41159
+ ble: firstMeaningfulVersion$1(getImageVersion$1((_d = info === null || info === void 0 ? void 0 : info.coprocessor) === null || _d === void 0 ? void 0 : _d.application)),
41160
+ se01: firstMeaningfulVersion$1(getImageVersion$1((_e = info === null || info === void 0 ? void 0 : info.se1) === null || _e === void 0 ? void 0 : _e.application)),
41161
+ se02: firstMeaningfulVersion$1(getImageVersion$1((_f = info === null || info === void 0 ? void 0 : info.se2) === null || _f === void 0 ? void 0 : _f.application)),
41162
+ se03: firstMeaningfulVersion$1(getImageVersion$1((_g = info === null || info === void 0 ? void 0 : info.se3) === null || _g === void 0 ? void 0 : _g.application)),
41163
+ se04: firstMeaningfulVersion$1(getImageVersion$1((_h = info === null || info === void 0 ? void 0 : info.se4) === null || _h === void 0 ? void 0 : _h.application)),
41164
+ se01Boot: firstMeaningfulVersion$1(getImageVersion$1((_j = info === null || info === void 0 ? void 0 : info.se1) === null || _j === void 0 ? void 0 : _j.bootloader)),
41165
+ se02Boot: firstMeaningfulVersion$1(getImageVersion$1((_k = info === null || info === void 0 ? void 0 : info.se2) === null || _k === void 0 ? void 0 : _k.bootloader)),
41166
+ se03Boot: firstMeaningfulVersion$1(getImageVersion$1((_l = info === null || info === void 0 ? void 0 : info.se3) === null || _l === void 0 ? void 0 : _l.bootloader)),
41167
+ se04Boot: firstMeaningfulVersion$1(getImageVersion$1((_m = info === null || info === void 0 ? void 0 : info.se4) === null || _m === void 0 ? void 0 : _m.bootloader)),
40962
41168
  };
40963
41169
  };
40964
41170
  const normalizeV1Status = (features) => {
@@ -41025,33 +41231,33 @@ const normalizeV1Verify = (features, protocolV1OneKeyFeatures) => {
41025
41231
  });
41026
41232
  };
41027
41233
  const normalizeV2Verify = (deviceInfo) => {
41028
- 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;
41234
+ 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;
41029
41235
  const info = deviceInfo;
41030
41236
  return {
41031
41237
  firmwareBuildId: getImageBuildId$1((_a = info === null || info === void 0 ? void 0 : info.fw) === null || _a === void 0 ? void 0 : _a.application),
41032
41238
  firmwareHash: getImageHash$1((_b = info === null || info === void 0 ? void 0 : info.fw) === null || _b === void 0 ? void 0 : _b.application),
41033
41239
  bootloaderBuildId: getImageBuildId$1((_c = info === null || info === void 0 ? void 0 : info.fw) === null || _c === void 0 ? void 0 : _c.bootloader),
41034
41240
  bootloaderHash: getImageHash$1((_d = info === null || info === void 0 ? void 0 : info.fw) === null || _d === void 0 ? void 0 : _d.bootloader),
41035
- 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),
41036
- 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),
41037
- bleBuildId: getImageBuildId$1((_l = info === null || info === void 0 ? void 0 : info.coprocessor) === null || _l === void 0 ? void 0 : _l.application),
41038
- bleHash: getImageHash$1((_m = info === null || info === void 0 ? void 0 : info.coprocessor) === null || _m === void 0 ? void 0 : _m.application),
41039
- se01BuildId: getImageBuildId$1((_o = info === null || info === void 0 ? void 0 : info.se1) === null || _o === void 0 ? void 0 : _o.application),
41040
- se01Hash: getImageHash$1((_p = info === null || info === void 0 ? void 0 : info.se1) === null || _p === void 0 ? void 0 : _p.application),
41041
- se02BuildId: getImageBuildId$1((_q = info === null || info === void 0 ? void 0 : info.se2) === null || _q === void 0 ? void 0 : _q.application),
41042
- se02Hash: getImageHash$1((_r = info === null || info === void 0 ? void 0 : info.se2) === null || _r === void 0 ? void 0 : _r.application),
41043
- se03BuildId: getImageBuildId$1((_s = info === null || info === void 0 ? void 0 : info.se3) === null || _s === void 0 ? void 0 : _s.application),
41044
- se03Hash: getImageHash$1((_t = info === null || info === void 0 ? void 0 : info.se3) === null || _t === void 0 ? void 0 : _t.application),
41045
- se04BuildId: getImageBuildId$1((_u = info === null || info === void 0 ? void 0 : info.se4) === null || _u === void 0 ? void 0 : _u.application),
41046
- se04Hash: getImageHash$1((_v = info === null || info === void 0 ? void 0 : info.se4) === null || _v === void 0 ? void 0 : _v.application),
41047
- se01BootBuildId: getImageBuildId$1((_w = info === null || info === void 0 ? void 0 : info.se1) === null || _w === void 0 ? void 0 : _w.bootloader),
41048
- se01BootHash: getImageHash$1((_x = info === null || info === void 0 ? void 0 : info.se1) === null || _x === void 0 ? void 0 : _x.bootloader),
41049
- se02BootBuildId: getImageBuildId$1((_y = info === null || info === void 0 ? void 0 : info.se2) === null || _y === void 0 ? void 0 : _y.bootloader),
41050
- se02BootHash: getImageHash$1((_z = info === null || info === void 0 ? void 0 : info.se2) === null || _z === void 0 ? void 0 : _z.bootloader),
41051
- se03BootBuildId: getImageBuildId$1((_0 = info === null || info === void 0 ? void 0 : info.se3) === null || _0 === void 0 ? void 0 : _0.bootloader),
41052
- se03BootHash: getImageHash$1((_1 = info === null || info === void 0 ? void 0 : info.se3) === null || _1 === void 0 ? void 0 : _1.bootloader),
41053
- se04BootBuildId: getImageBuildId$1((_2 = info === null || info === void 0 ? void 0 : info.se4) === null || _2 === void 0 ? void 0 : _2.bootloader),
41054
- se04BootHash: getImageHash$1((_3 = info === null || info === void 0 ? void 0 : info.se4) === null || _3 === void 0 ? void 0 : _3.bootloader),
41241
+ boardBuildId: getImageBuildId$1((_e = info === null || info === void 0 ? void 0 : info.fw) === null || _e === void 0 ? void 0 : _e.romloader),
41242
+ boardHash: getImageHash$1((_f = info === null || info === void 0 ? void 0 : info.fw) === null || _f === void 0 ? void 0 : _f.romloader),
41243
+ bleBuildId: getImageBuildId$1((_g = info === null || info === void 0 ? void 0 : info.coprocessor) === null || _g === void 0 ? void 0 : _g.application),
41244
+ bleHash: getImageHash$1((_h = info === null || info === void 0 ? void 0 : info.coprocessor) === null || _h === void 0 ? void 0 : _h.application),
41245
+ se01BuildId: getImageBuildId$1((_j = info === null || info === void 0 ? void 0 : info.se1) === null || _j === void 0 ? void 0 : _j.application),
41246
+ se01Hash: getImageHash$1((_k = info === null || info === void 0 ? void 0 : info.se1) === null || _k === void 0 ? void 0 : _k.application),
41247
+ se02BuildId: getImageBuildId$1((_l = info === null || info === void 0 ? void 0 : info.se2) === null || _l === void 0 ? void 0 : _l.application),
41248
+ se02Hash: getImageHash$1((_m = info === null || info === void 0 ? void 0 : info.se2) === null || _m === void 0 ? void 0 : _m.application),
41249
+ se03BuildId: getImageBuildId$1((_o = info === null || info === void 0 ? void 0 : info.se3) === null || _o === void 0 ? void 0 : _o.application),
41250
+ se03Hash: getImageHash$1((_p = info === null || info === void 0 ? void 0 : info.se3) === null || _p === void 0 ? void 0 : _p.application),
41251
+ se04BuildId: getImageBuildId$1((_q = info === null || info === void 0 ? void 0 : info.se4) === null || _q === void 0 ? void 0 : _q.application),
41252
+ se04Hash: getImageHash$1((_r = info === null || info === void 0 ? void 0 : info.se4) === null || _r === void 0 ? void 0 : _r.application),
41253
+ se01BootBuildId: getImageBuildId$1((_s = info === null || info === void 0 ? void 0 : info.se1) === null || _s === void 0 ? void 0 : _s.bootloader),
41254
+ se01BootHash: getImageHash$1((_t = info === null || info === void 0 ? void 0 : info.se1) === null || _t === void 0 ? void 0 : _t.bootloader),
41255
+ se02BootBuildId: getImageBuildId$1((_u = info === null || info === void 0 ? void 0 : info.se2) === null || _u === void 0 ? void 0 : _u.bootloader),
41256
+ se02BootHash: getImageHash$1((_v = info === null || info === void 0 ? void 0 : info.se2) === null || _v === void 0 ? void 0 : _v.bootloader),
41257
+ se03BootBuildId: getImageBuildId$1((_w = info === null || info === void 0 ? void 0 : info.se3) === null || _w === void 0 ? void 0 : _w.bootloader),
41258
+ se03BootHash: getImageHash$1((_x = info === null || info === void 0 ? void 0 : info.se3) === null || _x === void 0 ? void 0 : _x.bootloader),
41259
+ se04BootBuildId: getImageBuildId$1((_y = info === null || info === void 0 ? void 0 : info.se4) === null || _y === void 0 ? void 0 : _y.bootloader),
41260
+ se04BootHash: getImageHash$1((_z = info === null || info === void 0 ? void 0 : info.se4) === null || _z === void 0 ? void 0 : _z.bootloader),
41055
41261
  };
41056
41262
  };
41057
41263
  const normalizeRaw = ({ features, protocolV1OneKeyFeatures, protocolV2DeviceInfo, }) => (Object.assign(Object.assign(Object.assign({}, (features ? { features } : {})), (protocolV1OneKeyFeatures ? { protocolV1OneKeyFeatures } : {})), (protocolV2DeviceInfo ? { protocolV2DeviceInfo } : {})));
@@ -41259,47 +41465,54 @@ const buildProtocolV1FeaturesPayload = (protocolV1Features, previous) => {
41259
41465
  },
41260
41466
  sessionId,
41261
41467
  raw: {
41262
- protocolV1Features: protocolV1Features,
41468
+ protocolV1Features,
41263
41469
  },
41264
41470
  };
41265
41471
  };
41266
41472
  const buildProtocolV2FeaturesPayload = (deviceInfo, previous) => {
41267
- 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;
41473
+ 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;
41268
41474
  const info = deviceInfo;
41269
41475
  const fwApplication = (_a = info === null || info === void 0 ? void 0 : info.fw) === null || _a === void 0 ? void 0 : _a.application;
41270
41476
  const fwBootloader = (_b = info === null || info === void 0 ? void 0 : info.fw) === null || _b === void 0 ? void 0 : _b.bootloader;
41271
- 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);
41272
- const bleApplication = (_e = info === null || info === void 0 ? void 0 : info.coprocessor) === null || _e === void 0 ? void 0 : _e.application;
41477
+ const fwBoard = (_c = info === null || info === void 0 ? void 0 : info.fw) === null || _c === void 0 ? void 0 : _c.romloader;
41478
+ const bleApplication = (_d = info === null || info === void 0 ? void 0 : info.coprocessor) === null || _d === void 0 ? void 0 : _d.application;
41273
41479
  const status = info === null || info === void 0 ? void 0 : info.status;
41274
41480
  const firmwareVersion = firstMeaningfulVersion(getImageVersion(fwApplication), previous === null || previous === void 0 ? void 0 : previous.firmwareVersion);
41275
41481
  const bootloaderVersion = firstMeaningfulVersion(getImageVersion(fwBootloader), previous === null || previous === void 0 ? void 0 : previous.bootloaderVersion);
41276
41482
  const boardVersion = firstMeaningfulVersion(getImageVersion(fwBoard), previous === null || previous === void 0 ? void 0 : previous.boardVersion);
41277
41483
  const bleVersion = firstMeaningfulVersion(getImageVersion(bleApplication), previous === null || previous === void 0 ? void 0 : previous.bleVersion);
41278
- const deviceId = (_f = status === null || status === void 0 ? void 0 : status.device_id) !== null && _f !== void 0 ? _f : null;
41279
- 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 : '';
41280
- const label = (_j = previous === null || previous === void 0 ? void 0 : previous.label) !== null && _j !== void 0 ? _j : null;
41281
- 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);
41282
- 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;
41283
- const passphraseProtection = (_m = status === null || status === void 0 ? void 0 : status.passphrase_enabled) !== null && _m !== void 0 ? _m : null;
41284
- const language = (_o = previous === null || previous === void 0 ? void 0 : previous.language) !== null && _o !== void 0 ? _o : null;
41285
- 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;
41484
+ const deviceId = (_e = status === null || status === void 0 ? void 0 : status.device_id) !== null && _e !== void 0 ? _e : null;
41485
+ const serialNo = (_g = firstValue((_f = info === null || info === void 0 ? void 0 : info.hw) === null || _f === void 0 ? void 0 : _f.serial_no, previous === null || previous === void 0 ? void 0 : previous.serialNo)) !== null && _g !== void 0 ? _g : '';
41486
+ const label = (_h = previous === null || previous === void 0 ? void 0 : previous.label) !== null && _h !== void 0 ? _h : null;
41487
+ const bleName = firstValue((_j = info === null || info === void 0 ? void 0 : info.coprocessor) === null || _j === void 0 ? void 0 : _j.bt_adv_name, previous === null || previous === void 0 ? void 0 : previous.bleName);
41488
+ const initialized = (_k = firstValue(status === null || status === void 0 ? void 0 : status.init_states, previous === null || previous === void 0 ? void 0 : previous.initialized)) !== null && _k !== void 0 ? _k : null;
41489
+ const passphraseProtection = (_l = status === null || status === void 0 ? void 0 : status.passphrase_enabled) !== null && _l !== void 0 ? _l : null;
41490
+ const language = (_m = previous === null || previous === void 0 ? void 0 : previous.language) !== null && _m !== void 0 ? _m : null;
41491
+ const backupRequired = (_o = firstValue(status === null || status === void 0 ? void 0 : status.backup_required, previous === null || previous === void 0 ? void 0 : previous.backupRequired)) !== null && _o !== void 0 ? _o : null;
41286
41492
  const bleEnabled = previous === null || previous === void 0 ? void 0 : previous.bleEnabled;
41287
- 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;
41288
- const attachToPinEnabled = (_r = status === null || status === void 0 ? void 0 : status.attach_to_pin_enabled) !== null && _r !== void 0 ? _r : null;
41289
- const unlockedAttachPin = (_s = status === null || status === void 0 ? void 0 : status.unlocked_by_attach_to_pin) !== null && _s !== void 0 ? _s : undefined;
41493
+ const unlocked = (_p = firstValue(status === null || status === void 0 ? void 0 : status.unlocked, previous === null || previous === void 0 ? void 0 : previous.unlocked)) !== null && _p !== void 0 ? _p : null;
41494
+ const attachToPinEnabled = (_q = status === null || status === void 0 ? void 0 : status.attach_to_pin_enabled) !== null && _q !== void 0 ? _q : null;
41495
+ const unlockedAttachPin = (_r = status === null || status === void 0 ? void 0 : status.unlocked_by_attach_to_pin) !== null && _r !== void 0 ? _r : undefined;
41496
+ const romloaderMode = isProtocolV2RomloaderDeviceInfo(info);
41290
41497
  const bootloaderMode = isProtocolV2BootloaderDeviceInfo(info);
41291
- const mode = bootloaderMode
41292
- ? 'bootloader'
41293
- : initialized === false
41294
- ? 'notInitialized'
41295
- : initialized === true
41296
- ? 'normal'
41297
- : 'unknown';
41498
+ let mode = 'unknown';
41499
+ if (romloaderMode) {
41500
+ mode = 'romloader';
41501
+ }
41502
+ else if (bootloaderMode) {
41503
+ mode = 'bootloader';
41504
+ }
41505
+ else if (initialized === false) {
41506
+ mode = 'notInitialized';
41507
+ }
41508
+ else if (initialized === true) {
41509
+ mode = 'normal';
41510
+ }
41298
41511
  return {
41299
41512
  protocol: 'V2',
41300
- 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,
41513
+ protocolVersion: (_t = (_s = deviceInfo === null || deviceInfo === void 0 ? void 0 : deviceInfo.protocol_version) !== null && _s !== void 0 ? _s : previous === null || previous === void 0 ? void 0 : previous.protocolVersion) !== null && _t !== void 0 ? _t : null,
41301
41514
  deviceType: hdShared.EDeviceType.Pro2,
41302
- firmwareType: (_v = previous === null || previous === void 0 ? void 0 : previous.firmwareType) !== null && _v !== void 0 ? _v : hdShared.EFirmwareType.Universal,
41515
+ firmwareType: (_u = previous === null || previous === void 0 ? void 0 : previous.firmwareType) !== null && _u !== void 0 ? _u : hdShared.EFirmwareType.Universal,
41303
41516
  model: 'pro2',
41304
41517
  vendor: 'onekey.so',
41305
41518
  deviceId,
@@ -41311,7 +41524,7 @@ const buildProtocolV2FeaturesPayload = (deviceInfo, previous) => {
41311
41524
  initialized,
41312
41525
  bootloaderMode,
41313
41526
  unlocked,
41314
- firmwarePresent: (_w = previous === null || previous === void 0 ? void 0 : previous.firmwarePresent) !== null && _w !== void 0 ? _w : null,
41527
+ firmwarePresent: (_v = previous === null || previous === void 0 ? void 0 : previous.firmwarePresent) !== null && _v !== void 0 ? _v : null,
41315
41528
  passphraseProtection,
41316
41529
  pinProtection: null,
41317
41530
  backupRequired,
@@ -41333,42 +41546,42 @@ const buildProtocolV2FeaturesPayload = (deviceInfo, previous) => {
41333
41546
  bootloaderVersion,
41334
41547
  boardVersion,
41335
41548
  bleVersion,
41336
- 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),
41337
- 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),
41338
- 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),
41339
- 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),
41340
- 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),
41341
- 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),
41342
- 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),
41343
- 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),
41344
- seVersion: (_5 = previous === null || previous === void 0 ? void 0 : previous.seVersion) !== null && _5 !== void 0 ? _5 : null,
41549
+ se01Version: firstMeaningfulVersion(getImageVersion((_w = info === null || info === void 0 ? void 0 : info.se1) === null || _w === void 0 ? void 0 : _w.application), previous === null || previous === void 0 ? void 0 : previous.se01Version),
41550
+ se02Version: firstMeaningfulVersion(getImageVersion((_x = info === null || info === void 0 ? void 0 : info.se2) === null || _x === void 0 ? void 0 : _x.application), previous === null || previous === void 0 ? void 0 : previous.se02Version),
41551
+ se03Version: firstMeaningfulVersion(getImageVersion((_y = info === null || info === void 0 ? void 0 : info.se3) === null || _y === void 0 ? void 0 : _y.application), previous === null || previous === void 0 ? void 0 : previous.se03Version),
41552
+ se04Version: firstMeaningfulVersion(getImageVersion((_z = info === null || info === void 0 ? void 0 : info.se4) === null || _z === void 0 ? void 0 : _z.application), previous === null || previous === void 0 ? void 0 : previous.se04Version),
41553
+ se01BootVersion: firstMeaningfulVersion(getImageVersion((_0 = info === null || info === void 0 ? void 0 : info.se1) === null || _0 === void 0 ? void 0 : _0.bootloader), previous === null || previous === void 0 ? void 0 : previous.se01BootVersion),
41554
+ se02BootVersion: firstMeaningfulVersion(getImageVersion((_1 = info === null || info === void 0 ? void 0 : info.se2) === null || _1 === void 0 ? void 0 : _1.bootloader), previous === null || previous === void 0 ? void 0 : previous.se02BootVersion),
41555
+ se03BootVersion: firstMeaningfulVersion(getImageVersion((_2 = info === null || info === void 0 ? void 0 : info.se3) === null || _2 === void 0 ? void 0 : _2.bootloader), previous === null || previous === void 0 ? void 0 : previous.se03BootVersion),
41556
+ se04BootVersion: firstMeaningfulVersion(getImageVersion((_3 = info === null || info === void 0 ? void 0 : info.se4) === null || _3 === void 0 ? void 0 : _3.bootloader), previous === null || previous === void 0 ? void 0 : previous.se04BootVersion),
41557
+ seVersion: (_4 = previous === null || previous === void 0 ? void 0 : previous.seVersion) !== null && _4 !== void 0 ? _4 : null,
41345
41558
  verify: {
41346
- 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,
41347
- 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,
41348
- 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,
41349
- 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,
41350
- 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,
41351
- 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,
41352
- 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,
41353
- 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,
41354
- 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,
41355
- 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,
41356
- 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,
41357
- 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,
41358
- 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,
41359
- 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,
41360
- 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,
41361
- 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,
41362
- 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,
41363
- 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,
41364
- 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,
41365
- 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,
41366
- 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,
41367
- 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,
41368
- 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,
41369
- 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,
41559
+ firmwareBuildId: (_5 = getImageBuildId(fwApplication)) !== null && _5 !== void 0 ? _5 : (_6 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _6 === void 0 ? void 0 : _6.firmwareBuildId,
41560
+ firmwareHash: (_7 = getImageHash(fwApplication)) !== null && _7 !== void 0 ? _7 : (_8 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _8 === void 0 ? void 0 : _8.firmwareHash,
41561
+ bootloaderBuildId: (_9 = getImageBuildId(fwBootloader)) !== null && _9 !== void 0 ? _9 : (_10 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _10 === void 0 ? void 0 : _10.bootloaderBuildId,
41562
+ bootloaderHash: (_11 = getImageHash(fwBootloader)) !== null && _11 !== void 0 ? _11 : (_12 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _12 === void 0 ? void 0 : _12.bootloaderHash,
41563
+ boardBuildId: (_13 = getImageBuildId(fwBoard)) !== null && _13 !== void 0 ? _13 : (_14 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _14 === void 0 ? void 0 : _14.boardBuildId,
41564
+ boardHash: (_15 = getImageHash(fwBoard)) !== null && _15 !== void 0 ? _15 : (_16 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _16 === void 0 ? void 0 : _16.boardHash,
41565
+ bleBuildId: (_17 = getImageBuildId(bleApplication)) !== null && _17 !== void 0 ? _17 : (_18 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _18 === void 0 ? void 0 : _18.bleBuildId,
41566
+ bleHash: (_19 = getImageHash(bleApplication)) !== null && _19 !== void 0 ? _19 : (_20 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _20 === void 0 ? void 0 : _20.bleHash,
41567
+ se01BuildId: (_22 = getImageBuildId((_21 = info === null || info === void 0 ? void 0 : info.se1) === null || _21 === void 0 ? void 0 : _21.application)) !== null && _22 !== void 0 ? _22 : (_23 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _23 === void 0 ? void 0 : _23.se01BuildId,
41568
+ se01Hash: (_25 = getImageHash((_24 = info === null || info === void 0 ? void 0 : info.se1) === null || _24 === void 0 ? void 0 : _24.application)) !== null && _25 !== void 0 ? _25 : (_26 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _26 === void 0 ? void 0 : _26.se01Hash,
41569
+ se02BuildId: (_28 = getImageBuildId((_27 = info === null || info === void 0 ? void 0 : info.se2) === null || _27 === void 0 ? void 0 : _27.application)) !== null && _28 !== void 0 ? _28 : (_29 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _29 === void 0 ? void 0 : _29.se02BuildId,
41570
+ se02Hash: (_31 = getImageHash((_30 = info === null || info === void 0 ? void 0 : info.se2) === null || _30 === void 0 ? void 0 : _30.application)) !== null && _31 !== void 0 ? _31 : (_32 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _32 === void 0 ? void 0 : _32.se02Hash,
41571
+ se03BuildId: (_34 = getImageBuildId((_33 = info === null || info === void 0 ? void 0 : info.se3) === null || _33 === void 0 ? void 0 : _33.application)) !== null && _34 !== void 0 ? _34 : (_35 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _35 === void 0 ? void 0 : _35.se03BuildId,
41572
+ se03Hash: (_37 = getImageHash((_36 = info === null || info === void 0 ? void 0 : info.se3) === null || _36 === void 0 ? void 0 : _36.application)) !== null && _37 !== void 0 ? _37 : (_38 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _38 === void 0 ? void 0 : _38.se03Hash,
41573
+ se04BuildId: (_40 = getImageBuildId((_39 = info === null || info === void 0 ? void 0 : info.se4) === null || _39 === void 0 ? void 0 : _39.application)) !== null && _40 !== void 0 ? _40 : (_41 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _41 === void 0 ? void 0 : _41.se04BuildId,
41574
+ se04Hash: (_43 = getImageHash((_42 = info === null || info === void 0 ? void 0 : info.se4) === null || _42 === void 0 ? void 0 : _42.application)) !== null && _43 !== void 0 ? _43 : (_44 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _44 === void 0 ? void 0 : _44.se04Hash,
41575
+ se01BootBuildId: (_46 = getImageBuildId((_45 = info === null || info === void 0 ? void 0 : info.se1) === null || _45 === void 0 ? void 0 : _45.bootloader)) !== null && _46 !== void 0 ? _46 : (_47 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _47 === void 0 ? void 0 : _47.se01BootBuildId,
41576
+ se01BootHash: (_49 = getImageHash((_48 = info === null || info === void 0 ? void 0 : info.se1) === null || _48 === void 0 ? void 0 : _48.bootloader)) !== null && _49 !== void 0 ? _49 : (_50 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _50 === void 0 ? void 0 : _50.se01BootHash,
41577
+ se02BootBuildId: (_52 = getImageBuildId((_51 = info === null || info === void 0 ? void 0 : info.se2) === null || _51 === void 0 ? void 0 : _51.bootloader)) !== null && _52 !== void 0 ? _52 : (_53 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _53 === void 0 ? void 0 : _53.se02BootBuildId,
41578
+ se02BootHash: (_55 = getImageHash((_54 = info === null || info === void 0 ? void 0 : info.se2) === null || _54 === void 0 ? void 0 : _54.bootloader)) !== null && _55 !== void 0 ? _55 : (_56 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _56 === void 0 ? void 0 : _56.se02BootHash,
41579
+ se03BootBuildId: (_58 = getImageBuildId((_57 = info === null || info === void 0 ? void 0 : info.se3) === null || _57 === void 0 ? void 0 : _57.bootloader)) !== null && _58 !== void 0 ? _58 : (_59 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _59 === void 0 ? void 0 : _59.se03BootBuildId,
41580
+ se03BootHash: (_61 = getImageHash((_60 = info === null || info === void 0 ? void 0 : info.se3) === null || _60 === void 0 ? void 0 : _60.bootloader)) !== null && _61 !== void 0 ? _61 : (_62 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _62 === void 0 ? void 0 : _62.se03BootHash,
41581
+ se04BootBuildId: (_64 = getImageBuildId((_63 = info === null || info === void 0 ? void 0 : info.se4) === null || _63 === void 0 ? void 0 : _63.bootloader)) !== null && _64 !== void 0 ? _64 : (_65 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _65 === void 0 ? void 0 : _65.se04BootBuildId,
41582
+ se04BootHash: (_67 = getImageHash((_66 = info === null || info === void 0 ? void 0 : info.se4) === null || _66 === void 0 ? void 0 : _66.bootloader)) !== null && _67 !== void 0 ? _67 : (_68 = previous === null || previous === void 0 ? void 0 : previous.verify) === null || _68 === void 0 ? void 0 : _68.se04BootHash,
41370
41583
  },
41371
- sessionId: (_70 = previous === null || previous === void 0 ? void 0 : previous.sessionId) !== null && _70 !== void 0 ? _70 : null,
41584
+ sessionId: (_69 = previous === null || previous === void 0 ? void 0 : previous.sessionId) !== null && _69 !== void 0 ? _69 : null,
41372
41585
  passphraseState: previous === null || previous === void 0 ? void 0 : previous.passphraseState,
41373
41586
  unlockedAttachPin,
41374
41587
  raw: {
@@ -41382,7 +41595,7 @@ const parseRunOptions = (options) => {
41382
41595
  options = {};
41383
41596
  return options;
41384
41597
  };
41385
- const Log$c = getLogger(exports.LoggerNames.Device);
41598
+ const Log$d = getLogger(exports.LoggerNames.Device);
41386
41599
  function preloadSessionCache(deviceId, passphraseState, sessionId) {
41387
41600
  deviceWalletSessionStore.set(deviceId, passphraseState, sessionId);
41388
41601
  }
@@ -41404,7 +41617,7 @@ class Device extends events.exports {
41404
41617
  this.sdkInstanceId = sdkInstanceId;
41405
41618
  this.instanceId = generateInstanceId('Device', this.sdkInstanceId);
41406
41619
  this.createdAt = Date.now();
41407
- Log$c.debug(`[Device] Created: ${this.instanceId}${this.sdkInstanceId ? ` for SDK: ${this.sdkInstanceId}` : ''}`);
41620
+ Log$d.debug(`[Device] Created: ${this.instanceId}${this.sdkInstanceId ? ` for SDK: ${this.sdkInstanceId}` : ''}`);
41408
41621
  }
41409
41622
  static fromDescriptor(originalDescriptor, sdkInstanceId) {
41410
41623
  const descriptor = Object.assign({}, originalDescriptor);
@@ -41484,12 +41697,12 @@ class Device extends events.exports {
41484
41697
  if (DataManager.isBleConnect(env)) {
41485
41698
  acquireResult = yield ((_a = this.deviceConnector) === null || _a === void 0 ? void 0 : _a.acquire(this.originalDescriptor.id, undefined, true, expectedProtocol));
41486
41699
  this.mainId = (_b = acquireResult === null || acquireResult === void 0 ? void 0 : acquireResult.uuid) !== null && _b !== void 0 ? _b : '';
41487
- Log$c.debug('Expected uuid:', this.mainId);
41700
+ Log$d.debug('Expected uuid:', this.mainId);
41488
41701
  }
41489
41702
  else {
41490
41703
  acquireResult = yield ((_c = this.deviceConnector) === null || _c === void 0 ? void 0 : _c.acquire(this.originalDescriptor.path, this.originalDescriptor.session, undefined, expectedProtocol));
41491
41704
  this.mainId = acquireResult;
41492
- Log$c.debug('Expected session id:', this.mainId);
41705
+ Log$d.debug('Expected session id:', this.mainId);
41493
41706
  }
41494
41707
  this.deviceAcquired = true;
41495
41708
  this.updateDescriptor({ [mainIdKey]: this.mainId });
@@ -41524,11 +41737,11 @@ class Device extends events.exports {
41524
41737
  (this.mainId && DataManager.isBleConnect(env))) {
41525
41738
  if (this.pendingCallbackPromise) {
41526
41739
  try {
41527
- Log$c.debug('Waiting for callback tasks to complete before releasing device (in release method)');
41740
+ Log$d.debug('Waiting for callback tasks to complete before releasing device (in release method)');
41528
41741
  yield this.pendingCallbackPromise.promise;
41529
41742
  }
41530
41743
  catch (error) {
41531
- Log$c.error('Error waiting for callback tasks in release method:', error);
41744
+ Log$d.error('Error waiting for callback tasks in release method:', error);
41532
41745
  }
41533
41746
  }
41534
41747
  if (this.commands) {
@@ -41547,7 +41760,7 @@ class Device extends events.exports {
41547
41760
  this.updateDescriptor({ session: null });
41548
41761
  }
41549
41762
  catch (err) {
41550
- Log$c.error('[Device] release error: ', err);
41763
+ Log$d.error('[Device] release error: ', err);
41551
41764
  }
41552
41765
  finally {
41553
41766
  this.needReloadDevice = true;
@@ -41722,7 +41935,7 @@ class Device extends events.exports {
41722
41935
  }
41723
41936
  getInternalState(_deviceId) {
41724
41937
  var _a;
41725
- Log$c.debug('getInternalState session param: ', `device_id: ${_deviceId}`, `features.deviceId: ${(_a = this.features) === null || _a === void 0 ? void 0 : _a.deviceId}`, `passphraseState: ${this.passphraseState}`);
41938
+ Log$d.debug('getInternalState session param: ', `device_id: ${_deviceId}`, `features.deviceId: ${(_a = this.features) === null || _a === void 0 ? void 0 : _a.deviceId}`, `passphraseState: ${this.passphraseState}`);
41726
41939
  const deviceId = this.getSessionCacheDeviceKey(_deviceId);
41727
41940
  if (!deviceId)
41728
41941
  return undefined;
@@ -41731,7 +41944,7 @@ class Device extends events.exports {
41731
41944
  return deviceWalletSessionStore.get(deviceId, this.passphraseState);
41732
41945
  }
41733
41946
  updateInternalState(enablePassphrase, passphraseState, deviceId, sessionId = null, featuresSessionId = null) {
41734
- Log$c.debug('updateInternalState session param: ', `device_id: ${deviceId}`, `enablePassphrase: ${enablePassphrase}`, `passphraseState: ${passphraseState}`, `hasSessionId: ${Boolean(sessionId)}`, `hasFeaturesSessionId: ${Boolean(featuresSessionId)}`);
41947
+ Log$d.debug('updateInternalState session param: ', `device_id: ${deviceId}`, `enablePassphrase: ${enablePassphrase}`, `passphraseState: ${passphraseState}`, `hasSessionId: ${Boolean(sessionId)}`, `hasFeaturesSessionId: ${Boolean(featuresSessionId)}`);
41735
41948
  const cacheDeviceKey = this.getSessionCacheDeviceKey(deviceId);
41736
41949
  if (!cacheDeviceKey)
41737
41950
  return;
@@ -41743,7 +41956,7 @@ class Device extends events.exports {
41743
41956
  }
41744
41957
  setInternalState(state, initSession) {
41745
41958
  var _a;
41746
- Log$c.debug('setInternalState session param: ', `hasState: ${Boolean(state)}`, `initSession: ${initSession}`, `deviceId: ${(_a = this.features) === null || _a === void 0 ? void 0 : _a.deviceId}`, `passphraseState: ${this.passphraseState}`);
41959
+ Log$d.debug('setInternalState session param: ', `hasState: ${Boolean(state)}`, `initSession: ${initSession}`, `deviceId: ${(_a = this.features) === null || _a === void 0 ? void 0 : _a.deviceId}`, `passphraseState: ${this.passphraseState}`);
41747
41960
  if (!this.passphraseState && !initSession)
41748
41961
  return;
41749
41962
  const deviceId = this.getSessionCacheDeviceKey();
@@ -41757,7 +41970,7 @@ class Device extends events.exports {
41757
41970
  }
41758
41971
  }
41759
41972
  clearInternalState(_deviceId) {
41760
- Log$c.debug('clearInternalState param: ', _deviceId);
41973
+ Log$d.debug('clearInternalState param: ', _deviceId);
41761
41974
  const deviceId = this.getSessionCacheDeviceKey(_deviceId);
41762
41975
  if (!deviceId)
41763
41976
  return;
@@ -41810,25 +42023,25 @@ class Device extends events.exports {
41810
42023
  yield TransportManager.reconfigure(this.features);
41811
42024
  }
41812
42025
  catch (error) {
41813
- Log$c.error('Initialization failed:', error);
42026
+ Log$d.error('Initialization failed:', error);
41814
42027
  throw error;
41815
42028
  }
41816
42029
  });
41817
42030
  }
41818
42031
  _initializeProtocolV2(options) {
41819
42032
  return __awaiter(this, void 0, void 0, function* () {
41820
- Log$c.debug('Initialize device via Protocol V2 features adapter');
42033
+ Log$d.debug('Initialize device via Protocol V2 features adapter');
41821
42034
  try {
41822
42035
  const deviceInfo = yield requestProtocolV2DeviceInfo({
41823
42036
  commands: this.commands,
41824
42037
  timeoutMs: options === null || options === void 0 ? void 0 : options.protocolV2DeviceInfoTimeoutMs,
41825
42038
  });
41826
42039
  const features = this.updateProtocolV2Features(deviceInfo);
41827
- Log$c.debug('Protocol V2 features:', features);
42040
+ Log$d.debug('Protocol V2 features:', features);
41828
42041
  this.featuresNeedsReload = false;
41829
42042
  }
41830
42043
  catch (error) {
41831
- Log$c.error('Protocol V2 initialization failed:', error);
42044
+ Log$d.error('Protocol V2 initialization failed:', error);
41832
42045
  throw error;
41833
42046
  }
41834
42047
  });
@@ -41842,10 +42055,10 @@ class Device extends events.exports {
41842
42055
  timeoutMs: options === null || options === void 0 ? void 0 : options.protocolV2DeviceInfoTimeoutMs,
41843
42056
  });
41844
42057
  const features = this.updateProtocolV2Features(deviceInfo);
41845
- Log$c.debug('Protocol V2 features (status refresh):', features);
42058
+ Log$d.debug('Protocol V2 features (status refresh):', features);
41846
42059
  }
41847
42060
  catch (error) {
41848
- Log$c.error('Protocol V2 status refresh failed:', error);
42061
+ Log$d.error('Protocol V2 status refresh failed:', error);
41849
42062
  throw error;
41850
42063
  }
41851
42064
  });
@@ -41930,7 +42143,7 @@ class Device extends events.exports {
41930
42143
  return __awaiter(this, void 0, void 0, function* () {
41931
42144
  if (this.runPromise) {
41932
42145
  yield this.interruptionFromOutside();
41933
- Log$c.debug('[Device] run error:', 'Device is running, but will cancel previous operate');
42146
+ Log$d.debug('[Device] run error:', 'Device is running, but will cancel previous operate');
41934
42147
  }
41935
42148
  options = parseRunOptions(options);
41936
42149
  this.runPromise = hdShared.createDeferred(this._runInner.bind(this, fn, options));
@@ -41988,7 +42201,7 @@ class Device extends events.exports {
41988
42201
  yield ((_a = this.deviceConnector) === null || _a === void 0 ? void 0 : _a.disconnect(this.mainId));
41989
42202
  }
41990
42203
  yield this.release();
41991
- Log$c.debug(`error code ${e.errorCode} release device, mainId: ${this.mainId}`);
42204
+ Log$d.debug(`error code ${e.errorCode} release device, mainId: ${this.mainId}`);
41992
42205
  }
41993
42206
  this.runPromise = null;
41994
42207
  return;
@@ -41998,7 +42211,7 @@ class Device extends events.exports {
41998
42211
  options.keepSession === false) {
41999
42212
  this.keepSession = false;
42000
42213
  yield this.release();
42001
- Log$c.debug('release device, mainId: ', this.mainId);
42214
+ Log$d.debug('release device, mainId: ', this.mainId);
42002
42215
  }
42003
42216
  if (this.runPromise) {
42004
42217
  this.runPromise.resolve();
@@ -42031,7 +42244,7 @@ class Device extends events.exports {
42031
42244
  setCancelableAction(callback) {
42032
42245
  this.cancelableAction = (e) => callback(e)
42033
42246
  .catch(e2 => {
42034
- Log$c.debug('cancelableAction error', e2);
42247
+ Log$d.debug('cancelableAction error', e2);
42035
42248
  })
42036
42249
  .finally(() => {
42037
42250
  this.clearCancelableAction();
@@ -42143,8 +42356,9 @@ class Device extends events.exports {
42143
42356
  var _a, _b, _c;
42144
42357
  return __awaiter(this, void 0, void 0, function* () {
42145
42358
  if (this.isProtocolV2()) {
42359
+ let pinResult;
42146
42360
  try {
42147
- yield this.commands.typedCall('DeviceSessionAskPin', 'DeviceSessionPinResult');
42361
+ ({ message: pinResult } = yield this.commands.typedCall('DeviceSessionAskPin', 'DeviceSessionPinResult'));
42148
42362
  }
42149
42363
  catch (error) {
42150
42364
  const errorText = error instanceof Error
@@ -42155,7 +42369,17 @@ class Device extends events.exports {
42155
42369
  }
42156
42370
  throw error;
42157
42371
  }
42158
- return refreshProtocolV2DeviceStatus(this);
42372
+ const status = {};
42373
+ if (pinResult.unlocked != null) {
42374
+ status.unlocked = pinResult.unlocked;
42375
+ }
42376
+ if (pinResult.unlocked_attach_pin != null) {
42377
+ status.unlocked_by_attach_to_pin = pinResult.unlocked_attach_pin;
42378
+ }
42379
+ if (pinResult.passphrase_protection != null) {
42380
+ status.passphrase_enabled = pinResult.passphrase_protection;
42381
+ }
42382
+ return this.updateProtocolV2Status(status);
42159
42383
  }
42160
42384
  const firmwareVersion = (_c = this.getCurrentFirmwareVersionString()) !== null && _c !== void 0 ? _c : '0.0.0';
42161
42385
  const versionRange = this.getCurrentMethodVersionRange(type => this.supportUnlockVersionRange()[type]);
@@ -42201,7 +42425,7 @@ class Device extends events.exports {
42201
42425
  const mainWalletUseAttachPin = unlockedAttachPin && useEmptyPassphrase;
42202
42426
  const useErrorAttachPin = unlockedAttachPin && passphraseState && passphraseState !== newPassphraseState;
42203
42427
  const passphraseStateMismatch = !!passphraseState && passphraseState !== newPassphraseState;
42204
- Log$c.debug('Check passphrase state safety: ', {
42428
+ Log$d.debug('Check passphrase state safety: ', {
42205
42429
  passphraseState,
42206
42430
  newPassphraseState,
42207
42431
  unlockedAttachPin,
@@ -42329,7 +42553,7 @@ const getBootloaderReleaseInfo = ({ features, willUpdateFirmwareVersion, firmwar
42329
42553
  };
42330
42554
  };
42331
42555
 
42332
- const Log$b = getLogger(exports.LoggerNames.Method);
42556
+ const Log$c = getLogger(exports.LoggerNames.Method);
42333
42557
  const isEvmLedgerLegacyPathWithHighIndex = (path) => {
42334
42558
  let addressN;
42335
42559
  if (typeof path === 'string') {
@@ -42362,6 +42586,12 @@ class BaseMethod {
42362
42586
  this.name,
42363
42587
  ].join('|');
42364
42588
  }
42589
+ throwIfAborted() {
42590
+ var _a;
42591
+ if ((_a = this.abortSignal) === null || _a === void 0 ? void 0 : _a.aborted) {
42592
+ throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.CallQueueActionCancelled, 'Hardware operation cancelled');
42593
+ }
42594
+ }
42365
42595
  constructor(message) {
42366
42596
  this.shouldEnsureConnected = true;
42367
42597
  this.checkDeviceId = false;
@@ -42372,6 +42602,7 @@ class BaseMethod {
42372
42602
  this.preWarmTtl = 60 * 1000;
42373
42603
  this.strictCheckDeviceSupport = false;
42374
42604
  this.requireProtocolV2 = false;
42605
+ this.unlockPolicy = 'none';
42375
42606
  this.temporarySafetyCheckPrompted = false;
42376
42607
  this.postPreviousAddressMessage = (data) => {
42377
42608
  this.postMessage(createUiMessage(UI_REQUEST.PREVIOUS_ADDRESS_RESULT, {
@@ -42395,7 +42626,7 @@ class BaseMethod {
42395
42626
  setContext(context) {
42396
42627
  this.sdkInstanceId = context.sdkInstanceId;
42397
42628
  this.instanceId = generateInstanceId('Method', this.sdkInstanceId);
42398
- Log$b.debug(`[BaseMethod] Created: ${this.instanceId}, method: ${this.name}, SDK: ${this.sdkInstanceId}`);
42629
+ Log$c.debug(`[BaseMethod] Created: ${this.instanceId}, method: ${this.name}, SDK: ${this.sdkInstanceId}`);
42399
42630
  }
42400
42631
  setDevice(device) {
42401
42632
  var _a, _b;
@@ -42415,7 +42646,7 @@ class BaseMethod {
42415
42646
  if (device.commands) {
42416
42647
  device.commands.currentResponseID = this.responseID;
42417
42648
  }
42418
- Log$b.debug(`[${this.instanceId}] setDevice: ${device.instanceId}, commands: ${(_b = device.commands) === null || _b === void 0 ? void 0 : _b.instanceId}`);
42649
+ Log$c.debug(`[${this.instanceId}] setDevice: ${device.instanceId}, commands: ${(_b = device.commands) === null || _b === void 0 ? void 0 : _b.instanceId}`);
42419
42650
  }
42420
42651
  checkFirmwareRelease() {
42421
42652
  if (!this.device || this.device.isProtocolV2())
@@ -42493,7 +42724,7 @@ class BaseMethod {
42493
42724
  checkFlag = true;
42494
42725
  }
42495
42726
  if (checkFlag && this.device.getCurrentSafetyChecks() === 'Strict') {
42496
- Log$b.debug('will change safety_checks level');
42727
+ Log$c.debug('will change safety_checks level');
42497
42728
  yield this.device.commands.typedCall('ApplySettings', 'Success', {
42498
42729
  safety_checks: 'PromptTemporarily',
42499
42730
  });
@@ -42527,7 +42758,7 @@ class TestInitializeDeviceDuration extends BaseMethod {
42527
42758
  }
42528
42759
  }
42529
42760
 
42530
- const Log$a = getLogger(exports.LoggerNames.Core);
42761
+ const Log$b = getLogger(exports.LoggerNames.Core);
42531
42762
  const parseInitOptions$1 = (payload) => ({
42532
42763
  initSession: payload === null || payload === void 0 ? void 0 : payload.initSession,
42533
42764
  passphraseState: payload === null || payload === void 0 ? void 0 : payload.passphraseState,
@@ -42550,7 +42781,7 @@ class PreInitialize extends BaseMethod {
42550
42781
  }
42551
42782
  catch (_a) {
42552
42783
  this.device.clearPreInitialized();
42553
- Log$a.debug('[PRE-INIT][FAILED]');
42784
+ Log$b.debug('[PRE-INIT][FAILED]');
42554
42785
  return false;
42555
42786
  }
42556
42787
  });
@@ -42836,26 +43067,16 @@ class GetPassphraseState extends BaseMethod {
42836
43067
  this.useDevicePassphraseState = false;
42837
43068
  }
42838
43069
  run() {
42839
- var _a, _b;
42840
43070
  return __awaiter(this, void 0, void 0, function* () {
42841
- const { passphraseState, newSession, unlockedAttachPin } = yield getPassphraseStateWithRefreshDeviceInfo(this.device, {
43071
+ const { passphraseState } = yield getPassphraseStateWithRefreshDeviceInfo(this.device, {
42842
43072
  expectPassphraseState: this.payload.passphraseState,
42843
43073
  onlyMainPin: this.payload.useEmptyPassphrase,
42844
- allowCreateAttachPin: this.payload.allowCreateAttachPin,
42845
43074
  initSession: this.payload.initSession,
42846
43075
  });
42847
- const { features } = this.device;
42848
- const passphraseProtection = (_a = this.device.getCurrentPassphraseProtection()) !== null && _a !== void 0 ? _a : null;
43076
+ const passphraseProtection = this.device.getCurrentPassphraseProtection();
42849
43077
  const deviceType = this.device.getCurrentDeviceType();
42850
43078
  const isProSeries = deviceType === hdShared.EDeviceType.Pro || deviceType === hdShared.EDeviceType.Pro2;
42851
- return Promise.resolve({
42852
- passphraseState: isProSeries || passphraseProtection === true ? passphraseState : undefined,
42853
- sessionId: this.payload.initSession
42854
- ? newSession !== null && newSession !== void 0 ? newSession : undefined
42855
- : (_b = newSession !== null && newSession !== void 0 ? newSession : features === null || features === void 0 ? void 0 : features.sessionId) !== null && _b !== void 0 ? _b : undefined,
42856
- unlockedAttachPin: unlockedAttachPin !== null && unlockedAttachPin !== void 0 ? unlockedAttachPin : features === null || features === void 0 ? void 0 : features.unlockedAttachPin,
42857
- passphraseProtection,
42858
- });
43079
+ return Promise.resolve(isProSeries || passphraseProtection === true ? passphraseState : undefined);
42859
43080
  });
42860
43081
  }
42861
43082
  }
@@ -43882,7 +44103,7 @@ const getInfo = ({ features, updateType, targetVersion, firmwareType }) => {
43882
44103
  const NEW_BOOT_UPRATE_FIRMWARE_VERSION = '2.4.5';
43883
44104
  const SESSION_ERROR$2 = 'session not found';
43884
44105
  const FIRMWARE_UPDATE_CONFIRM$1 = 'Firmware install confirmed';
43885
- const Log$9 = getLogger(exports.LoggerNames.Method);
44106
+ const Log$a = getLogger(exports.LoggerNames.Method);
43886
44107
  const isDeviceDisconnectedError$1 = (error) => {
43887
44108
  const message = error instanceof Error ? error.message : String(error !== null && error !== void 0 ? error : '');
43888
44109
  return (message.includes('device was disconnected') ||
@@ -43931,13 +44152,13 @@ const uploadFirmware = (updateType, typedCall, postMessage, device, { payload, r
43931
44152
  const newFeatures = yield typedCall('GetFeatures', 'Features', {});
43932
44153
  const deviceBootloaderVersion = getDeviceBootloaderVersion(buildProtocolV1FeaturesPayload(newFeatures.message, device.features)).join('.');
43933
44154
  const supportUpgradeFileHeader = semver__default["default"].gte(deviceBootloaderVersion, '2.1.0');
43934
- Log$9.debug('supportUpgradeFileHeader:', supportUpgradeFileHeader);
44155
+ Log$a.debug('supportUpgradeFileHeader:', supportUpgradeFileHeader);
43935
44156
  if (supportUpgradeFileHeader) {
43936
44157
  const HEADER_SIZE = 1024;
43937
44158
  if (payload.byteLength < HEADER_SIZE) {
43938
44159
  throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, `firmware payload too small: ${payload.byteLength} bytes, expected at least ${HEADER_SIZE} bytes`);
43939
44160
  }
43940
- Log$9.debug('Uploading firmware header:', {
44161
+ Log$a.debug('Uploading firmware header:', {
43941
44162
  size: HEADER_SIZE,
43942
44163
  totalSize: payload.byteLength,
43943
44164
  });
@@ -43949,18 +44170,18 @@ const uploadFirmware = (updateType, typedCall, postMessage, device, { payload, r
43949
44170
  });
43950
44171
  const isUnknownMessage = (_b = (_a = headerRes.message) === null || _a === void 0 ? void 0 : _a.message) === null || _b === void 0 ? void 0 : _b.includes('Failure_UnknownMessage');
43951
44172
  if (headerRes.type !== 'Success' && !isUnknownMessage) {
43952
- Log$9.error('Firmware header upload failed:', headerRes);
44173
+ Log$a.error('Firmware header upload failed:', headerRes);
43953
44174
  throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, 'failed to upload firmware header');
43954
44175
  }
43955
44176
  }
43956
44177
  catch (error) {
43957
- Log$9.error('Firmware header upload failed:', error);
44178
+ Log$a.error('Firmware header upload failed:', error);
43958
44179
  const message = error instanceof Error ? error.message : String(error !== null && error !== void 0 ? error : '');
43959
44180
  if (!message.includes('Failure_UnknownMessage')) {
43960
44181
  throw error;
43961
44182
  }
43962
44183
  }
43963
- Log$9.debug('Firmware header uploaded successfully');
44184
+ Log$a.debug('Firmware header uploaded successfully');
43964
44185
  }
43965
44186
  }
43966
44187
  const eraseCommand = isFirmware ? 'FirmwareErase' : 'FirmwareErase_ex';
@@ -43978,7 +44199,7 @@ const uploadFirmware = (updateType, typedCall, postMessage, device, { payload, r
43978
44199
  }
43979
44200
  catch (error) {
43980
44201
  if (isDeviceDisconnectedError$1(error)) {
43981
- Log$9.log('Rebooting device');
44202
+ Log$a.log('Rebooting device');
43982
44203
  updateResponse = {
43983
44204
  type: 'Success',
43984
44205
  message: { message: FIRMWARE_UPDATE_CONFIRM$1 },
@@ -44064,7 +44285,7 @@ const newTouchUpdateProcess = (updateType, postMessage, device, { payload }, reb
44064
44285
  }
44065
44286
  catch (error) {
44066
44287
  if (isDeviceDisconnectedError$1(error)) {
44067
- Log$9.log('Rebooting device');
44288
+ Log$a.log('Rebooting device');
44068
44289
  response = {
44069
44290
  type: 'Success',
44070
44291
  message: { message: FIRMWARE_UPDATE_CONFIRM$1 },
@@ -44095,7 +44316,7 @@ const newTouchUpdateProcess = (updateType, postMessage, device, { payload }, reb
44095
44316
  ]);
44096
44317
  }
44097
44318
  catch (e) {
44098
- Log$9.log('catch Bluetooth error when device is restarting: ', e);
44319
+ Log$a.log('catch Bluetooth error when device is restarting: ', e);
44099
44320
  }
44100
44321
  }
44101
44322
  else {
@@ -44116,7 +44337,7 @@ const newTouchUpdateProcess = (updateType, postMessage, device, { payload }, reb
44116
44337
  }
44117
44338
  catch (error) {
44118
44339
  console.error('Device reconnect failed: ', error);
44119
- Log$9.error('Device reconnect failed:', error);
44340
+ Log$a.error('Device reconnect failed:', error);
44120
44341
  yield wait(1000);
44121
44342
  }
44122
44343
  }
@@ -44156,7 +44377,7 @@ const emmcFileWriteWithRetry = (device, filePath, chunkLength, offset, chunk, ov
44156
44377
  return result;
44157
44378
  }
44158
44379
  catch (error) {
44159
- Log$9.error(`emmcWrite error: `, error);
44380
+ Log$a.error(`emmcWrite error: `, error);
44160
44381
  retryCount--;
44161
44382
  if (retryCount === 0) {
44162
44383
  throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.EmmcFileWriteFirmwareError, 'transfer data error');
@@ -44327,7 +44548,7 @@ const createFirmwareProgressThrottle = (intervalMs = DEFAULT_FIRMWARE_PROGRESS_I
44327
44548
  };
44328
44549
  };
44329
44550
 
44330
- const Log$8 = getLogger(exports.LoggerNames.Method);
44551
+ const Log$9 = getLogger(exports.LoggerNames.Method);
44331
44552
  const SESSION_ERROR$1 = 'session not found';
44332
44553
  const FIRMWARE_UPDATE_CONFIRM = 'Firmware install confirmed';
44333
44554
  const isDeviceDisconnectedError = (error) => {
@@ -44410,7 +44631,7 @@ class FirmwareUpdateBaseMethod extends BaseMethod {
44410
44631
  this.checkPromise = hdShared.createDeferred();
44411
44632
  const env = DataManager.getSettings('env');
44412
44633
  const isBleReconnect = connectId && DataManager.isBleConnect(env);
44413
- Log$8.log('FirmwareUpdateBaseMethod [checkDeviceToBootloader] isBleReconnect: ', isBleReconnect);
44634
+ Log$9.log('FirmwareUpdateBaseMethod [checkDeviceToBootloader] isBleReconnect: ', isBleReconnect);
44414
44635
  let isFirstCheck = true;
44415
44636
  let checkCount = 0;
44416
44637
  let hasPromptedWebDevice = false;
@@ -44421,10 +44642,10 @@ class FirmwareUpdateBaseMethod extends BaseMethod {
44421
44642
  const intervalTimer = setInterval(() => __awaiter(this, void 0, void 0, function* () {
44422
44643
  var _c, _d, _e;
44423
44644
  checkCount += 1;
44424
- Log$8.log('FirmwareUpdateBaseMethod [checkDeviceToBootloader] isFirstCheck: ', isFirstCheck);
44645
+ Log$9.log('FirmwareUpdateBaseMethod [checkDeviceToBootloader] isFirstCheck: ', isFirstCheck);
44425
44646
  if (isTouchOrProDevice && isFirstCheck) {
44426
44647
  isFirstCheck = false;
44427
- Log$8.log('FirmwareUpdateBaseMethod [checkDeviceToBootloader] wait 3000ms');
44648
+ Log$9.log('FirmwareUpdateBaseMethod [checkDeviceToBootloader] wait 3000ms');
44428
44649
  yield wait(3000);
44429
44650
  }
44430
44651
  if (checkCount > 4 &&
@@ -44444,7 +44665,7 @@ class FirmwareUpdateBaseMethod extends BaseMethod {
44444
44665
  catch (e) {
44445
44666
  clearInterval(intervalTimer);
44446
44667
  clearTimeout(timeoutTimer);
44447
- Log$8.log('FirmwareUpdateBaseMethod [checkDeviceToBootloader] _promptDeviceInBootloaderForWebDevice failed: ', e);
44668
+ Log$9.log('FirmwareUpdateBaseMethod [checkDeviceToBootloader] _promptDeviceInBootloaderForWebDevice failed: ', e);
44448
44669
  (_c = this.checkPromise) === null || _c === void 0 ? void 0 : _c.reject(e);
44449
44670
  }
44450
44671
  finally {
@@ -44462,7 +44683,7 @@ class FirmwareUpdateBaseMethod extends BaseMethod {
44462
44683
  }
44463
44684
  }
44464
44685
  catch (e) {
44465
- Log$8.log('catch Bluetooth error when device is restarting: ', e);
44686
+ Log$9.log('catch Bluetooth error when device is restarting: ', e);
44466
44687
  }
44467
44688
  }
44468
44689
  else {
@@ -44543,7 +44764,7 @@ class FirmwareUpdateBaseMethod extends BaseMethod {
44543
44764
  }
44544
44765
  catch (error) {
44545
44766
  if (isDeviceDisconnectedError(error)) {
44546
- Log$8.log('Rebooting device');
44767
+ Log$9.log('Rebooting device');
44547
44768
  updateResponse = {
44548
44769
  type: 'Success',
44549
44770
  message: { message: FIRMWARE_UPDATE_CONFIRM },
@@ -44633,7 +44854,7 @@ class FirmwareUpdateBaseMethod extends BaseMethod {
44633
44854
  return result;
44634
44855
  }
44635
44856
  catch (error) {
44636
- Log$8.error(`emmcWrite error: `, error);
44857
+ Log$9.error(`emmcWrite error: `, error);
44637
44858
  retryCount--;
44638
44859
  if (retryCount === 0) {
44639
44860
  throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.EmmcFileWriteFirmwareError, 'transfer data error');
@@ -44811,7 +45032,7 @@ class GetNextU2FCounter extends BaseMethod {
44811
45032
  }
44812
45033
  }
44813
45034
 
44814
- const Log$7 = getLogger(exports.LoggerNames.Method);
45035
+ const Log$8 = getLogger(exports.LoggerNames.Method);
44815
45036
  class FirmwareUpdate extends BaseMethod {
44816
45037
  constructor() {
44817
45038
  super(...arguments);
@@ -44849,7 +45070,7 @@ class FirmwareUpdate extends BaseMethod {
44849
45070
  this.checkPromise = hdShared.createDeferred();
44850
45071
  const env = DataManager.getSettings('env');
44851
45072
  const isBleReconnect = connectId && DataManager.isBleConnect(env);
44852
- Log$7.log('FirmwareUpdate [checkDeviceToBootloader] isBleReconnect: ', isBleReconnect);
45073
+ Log$8.log('FirmwareUpdate [checkDeviceToBootloader] isBleReconnect: ', isBleReconnect);
44853
45074
  const intervalTimer = setInterval(() => __awaiter(this, void 0, void 0, function* () {
44854
45075
  var _a, _b, _c, _d, _e, _f;
44855
45076
  if (isBleReconnect) {
@@ -44862,7 +45083,7 @@ class FirmwareUpdate extends BaseMethod {
44862
45083
  }
44863
45084
  }
44864
45085
  catch (e) {
44865
- Log$7.log('catch Bluetooth error when device is restarting: ', e);
45086
+ Log$8.log('catch Bluetooth error when device is restarting: ', e);
44866
45087
  }
44867
45088
  }
44868
45089
  else {
@@ -44919,7 +45140,7 @@ class FirmwareUpdate extends BaseMethod {
44919
45140
  if (e instanceof hdShared.HardwareError) {
44920
45141
  return Promise.reject(e);
44921
45142
  }
44922
- Log$7.log('auto go to bootloader mode failed: ', e);
45143
+ Log$8.log('auto go to bootloader mode failed: ', e);
44923
45144
  return Promise.reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.FirmwareUpdateAutoEnterBootFailure));
44924
45145
  }
44925
45146
  }
@@ -44956,7 +45177,7 @@ class FirmwareUpdate extends BaseMethod {
44956
45177
  }
44957
45178
  }
44958
45179
 
44959
- const Log$6 = getLogger(exports.LoggerNames.Method);
45180
+ const Log$7 = getLogger(exports.LoggerNames.Method);
44960
45181
  class FirmwareUpdateV2 extends BaseMethod {
44961
45182
  constructor() {
44962
45183
  super(...arguments);
@@ -45019,7 +45240,7 @@ class FirmwareUpdateV2 extends BaseMethod {
45019
45240
  this.checkPromise = hdShared.createDeferred();
45020
45241
  const env = DataManager.getSettings('env');
45021
45242
  const isBleReconnect = connectId && DataManager.isBleConnect(env);
45022
- Log$6.log('FirmwareUpdateV2 [checkDeviceToBootloader] isBleReconnect: ', isBleReconnect);
45243
+ Log$7.log('FirmwareUpdateV2 [checkDeviceToBootloader] isBleReconnect: ', isBleReconnect);
45023
45244
  let isFirstCheck = true;
45024
45245
  let checkCount = 0;
45025
45246
  let timeoutTimer;
@@ -45028,10 +45249,10 @@ class FirmwareUpdateV2 extends BaseMethod {
45028
45249
  const intervalTimer = setInterval(() => __awaiter(this, void 0, void 0, function* () {
45029
45250
  var _b, _c, _d;
45030
45251
  checkCount += 1;
45031
- Log$6.log('FirmwareUpdateV2 [checkDeviceToBootloader] isFirstCheck: ', isFirstCheck);
45252
+ Log$7.log('FirmwareUpdateV2 [checkDeviceToBootloader] isFirstCheck: ', isFirstCheck);
45032
45253
  if (isTouchOrProDevice && isFirstCheck) {
45033
45254
  isFirstCheck = false;
45034
- Log$6.log('FirmwareUpdateV2 [checkDeviceToBootloader] wait 3000ms');
45255
+ Log$7.log('FirmwareUpdateV2 [checkDeviceToBootloader] wait 3000ms');
45035
45256
  yield wait(3000);
45036
45257
  }
45037
45258
  if (checkCount > 4 &&
@@ -45047,7 +45268,7 @@ class FirmwareUpdateV2 extends BaseMethod {
45047
45268
  }
45048
45269
  }
45049
45270
  catch (e) {
45050
- Log$6.log('FirmwareUpdateV2 [checkDeviceToBootloader] promptDeviceInBootloaderForWebDevice failed: ', e);
45271
+ Log$7.log('FirmwareUpdateV2 [checkDeviceToBootloader] promptDeviceInBootloaderForWebDevice failed: ', e);
45051
45272
  (_b = this.checkPromise) === null || _b === void 0 ? void 0 : _b.reject(e);
45052
45273
  }
45053
45274
  return;
@@ -45062,7 +45283,7 @@ class FirmwareUpdateV2 extends BaseMethod {
45062
45283
  }
45063
45284
  }
45064
45285
  catch (e) {
45065
- Log$6.log('catch Bluetooth error when device is restarting: ', e);
45286
+ Log$7.log('catch Bluetooth error when device is restarting: ', e);
45066
45287
  }
45067
45288
  }
45068
45289
  else {
@@ -45229,7 +45450,7 @@ class FirmwareUpdateV2 extends BaseMethod {
45229
45450
  }
45230
45451
  }
45231
45452
 
45232
- const Log$5 = getLogger(exports.LoggerNames.Method);
45453
+ const Log$6 = getLogger(exports.LoggerNames.Method);
45233
45454
  const MIN_UPDATE_V3_BOOTLOADER_VERSION = '2.8.0';
45234
45455
  class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod {
45235
45456
  constructor() {
@@ -45273,7 +45494,7 @@ class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod {
45273
45494
  if (this.device.isProtocolV2()) {
45274
45495
  throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, 'Protocol V2 firmware update must use firmwareUpdateV4');
45275
45496
  }
45276
- Log$5.debug('FirmwareUpdateV3 strategy: Protocol V1');
45497
+ Log$6.debug('FirmwareUpdateV3 strategy: Protocol V1');
45277
45498
  return this.runProtocolV1();
45278
45499
  });
45279
45500
  }
@@ -45344,7 +45565,7 @@ class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod {
45344
45565
  const resource = (yield getSysResourceBinary(resourceUrl)).binary;
45345
45566
  return resource;
45346
45567
  }
45347
- Log$5.warn('No resource url found');
45568
+ Log$6.warn('No resource url found');
45348
45569
  return null;
45349
45570
  });
45350
45571
  }
@@ -45469,7 +45690,7 @@ class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod {
45469
45690
  yield this.startEmmcFirmwareUpdate({ path: '0:updates' });
45470
45691
  }
45471
45692
  catch (error) {
45472
- Log$5.error('triggerFirmwareUpdateEmmc error: ', error);
45693
+ Log$6.error('triggerFirmwareUpdateEmmc error: ', error);
45473
45694
  if (error === null || error === void 0 ? void 0 : error.errorCode) {
45474
45695
  const unexpectedError = [
45475
45696
  hdShared.HardwareErrorCode.ActionCancelled,
@@ -45530,7 +45751,7 @@ class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod {
45530
45751
  yield hdShared.wait(1000);
45531
45752
  }
45532
45753
  catch (error) {
45533
- Log$5.log('getFeatures error', error);
45754
+ Log$6.log('getFeatures error', error);
45534
45755
  let shouldReconnect = true;
45535
45756
  const progress = this.extractUpdateModeProgress(error);
45536
45757
  if (progress !== null) {
@@ -45628,7 +45849,7 @@ class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod {
45628
45849
  return;
45629
45850
  }
45630
45851
  catch (e) {
45631
- Log$5.log('catch Bluetooth error when device is restarting: ', e);
45852
+ Log$6.log('catch Bluetooth error when device is restarting: ', e);
45632
45853
  }
45633
45854
  }
45634
45855
  else {
@@ -45643,7 +45864,7 @@ class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod {
45643
45864
  yield this._promptDeviceForSwitchFirmwareWebDevice();
45644
45865
  }
45645
45866
  catch (e) {
45646
- Log$5.log('WebUSB re-authorization failed: ', e);
45867
+ Log$6.log('WebUSB re-authorization failed: ', e);
45647
45868
  }
45648
45869
  webUsbCheckCount = 0;
45649
45870
  }
@@ -45664,7 +45885,7 @@ class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod {
45664
45885
  }
45665
45886
  catch (error) {
45666
45887
  console.error('Device reconnect failed: ', error);
45667
- Log$5.error('Device reconnect failed:', error);
45888
+ Log$6.error('Device reconnect failed:', error);
45668
45889
  yield hdShared.wait(1000);
45669
45890
  }
45670
45891
  }
@@ -45838,7 +46059,7 @@ function normalizeFirmwareTargets(params) {
45838
46059
  });
45839
46060
  }
45840
46061
 
45841
- const Log$4 = getLogger(exports.LoggerNames.Method);
46062
+ const Log$5 = getLogger(exports.LoggerNames.Method);
45842
46063
  const SESSION_ERROR = 'session not found';
45843
46064
  const PROTOCOL_V2_BOOTLOADER_RECONNECT_TIMEOUT = 60 * 1000;
45844
46065
  const PROTOCOL_V2_SHORT_RESPONSE_TIMEOUT = 5 * 1000;
@@ -45918,6 +46139,16 @@ const PROTOCOL_V2_REMOTE_COMPONENT_TARGETS = {
45918
46139
  kind: 'firmware',
45919
46140
  },
45920
46141
  };
46142
+ const PROTOCOL_V2_UPDATE_TARGET_BY_TARGET_ID = new Map([
46143
+ [ProtocolV2FirmwareTargetType.FW_MGMT_TARGET_BOOTLOADER, 'boot'],
46144
+ [ProtocolV2FirmwareTargetType.FW_MGMT_TARGET_APPLICATION_P1, 'app_v1'],
46145
+ [ProtocolV2FirmwareTargetType.FW_MGMT_TARGET_APPLICATION_P2, 'app_v2'],
46146
+ [ProtocolV2FirmwareTargetType.FW_MGMT_TARGET_COPROCESSOR, 'coprocessor'],
46147
+ [ProtocolV2FirmwareTargetType.FW_MGMT_TARGET_SE01, 'se01'],
46148
+ [ProtocolV2FirmwareTargetType.FW_MGMT_TARGET_SE02, 'se02'],
46149
+ [ProtocolV2FirmwareTargetType.FW_MGMT_TARGET_SE03, 'se03'],
46150
+ [ProtocolV2FirmwareTargetType.FW_MGMT_TARGET_SE04, 'se04'],
46151
+ ]);
45921
46152
  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.';
45922
46153
  const PROTOCOL_V2_TARGET_ID_BY_DECODED_NAME = new Map(Object.entries(ProtocolV2FirmwareTargetType).map(([key, value]) => [key, value]));
45923
46154
  const PROTOCOL_V2_TARGET_STATUS_BY_DECODED_NAME = new Map([
@@ -45982,14 +46213,6 @@ const versionArrayToNumber = (version) => {
45982
46213
  return undefined;
45983
46214
  return version[0] * 0x10000 + version[1] * 0x100 + version[2];
45984
46215
  };
45985
- const versionStringToArray = (version) => {
45986
- if (!version)
45987
- return undefined;
45988
- const parts = version.split('.').map(part => Number(part));
45989
- if (parts.length !== 3 || parts.some(part => !Number.isFinite(part)))
45990
- return undefined;
45991
- return parts;
45992
- };
45993
46216
  const compareProtocolV2Versions = (current, target) => {
45994
46217
  const currentNumber = versionArrayToNumber(current);
45995
46218
  const targetNumber = versionArrayToNumber(target);
@@ -46095,6 +46318,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
46095
46318
  { name: 'se03Binary', type: 'buffer' },
46096
46319
  { name: 'se04Binary', type: 'buffer' },
46097
46320
  { name: 'firmwareType', type: 'string' },
46321
+ { name: 'targetsToUpdate', type: 'array', allowEmpty: true },
46098
46322
  { name: 'platform', type: 'string' },
46099
46323
  { name: 'resourceBundleFiles', type: 'array', allowEmpty: true },
46100
46324
  ]);
@@ -46112,6 +46336,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
46112
46336
  se04Binary: payload.se04Binary,
46113
46337
  resourceBundleFiles: payload.resourceBundleFiles,
46114
46338
  firmwareType: payload.firmwareType,
46339
+ targetsToUpdate: payload.targetsToUpdate,
46115
46340
  platform: payload.platform,
46116
46341
  };
46117
46342
  }
@@ -46132,7 +46357,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
46132
46357
  if (!this.device.isProtocolV2()) {
46133
46358
  throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, 'firmwareUpdateV4 requires a Protocol V2 device');
46134
46359
  }
46135
- Log$4.debug('FirmwareUpdateV4 strategy: Protocol V2');
46360
+ Log$5.debug('FirmwareUpdateV4 strategy: Protocol V2');
46136
46361
  return this.runProtocolV2();
46137
46362
  });
46138
46363
  }
@@ -46238,47 +46463,6 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
46238
46463
  }
46239
46464
  return target;
46240
46465
  }
46241
- getProtocolV2ComponentTargetVersion(release, component, target) {
46242
- if (component.version)
46243
- return component.version;
46244
- if (target.targetId === ProtocolV2FirmwareTargetType.FW_MGMT_TARGET_BOOTLOADER) {
46245
- return release.bootloaderVersion;
46246
- }
46247
- if (target.targetId === ProtocolV2FirmwareTargetType.FW_MGMT_TARGET_APPLICATION_P1 ||
46248
- target.targetId === ProtocolV2FirmwareTargetType.FW_MGMT_TARGET_APPLICATION_P2) {
46249
- return release.version;
46250
- }
46251
- return undefined;
46252
- }
46253
- getProtocolV2ComponentCurrentVersion(features, target) {
46254
- switch (target.targetId) {
46255
- case ProtocolV2FirmwareTargetType.FW_MGMT_TARGET_BOOTLOADER:
46256
- return getDeviceBootloaderVersion(features);
46257
- case ProtocolV2FirmwareTargetType.FW_MGMT_TARGET_APPLICATION_P1:
46258
- case ProtocolV2FirmwareTargetType.FW_MGMT_TARGET_APPLICATION_P2:
46259
- return getDeviceFirmwareVersion(features);
46260
- case ProtocolV2FirmwareTargetType.FW_MGMT_TARGET_COPROCESSOR:
46261
- return getDeviceBLEFirmwareVersion(features);
46262
- case ProtocolV2FirmwareTargetType.FW_MGMT_TARGET_SE01:
46263
- return versionStringToArray(features.se01Version);
46264
- case ProtocolV2FirmwareTargetType.FW_MGMT_TARGET_SE02:
46265
- return versionStringToArray(features.se02Version);
46266
- case ProtocolV2FirmwareTargetType.FW_MGMT_TARGET_SE03:
46267
- return versionStringToArray(features.se03Version);
46268
- case ProtocolV2FirmwareTargetType.FW_MGMT_TARGET_SE04:
46269
- return versionStringToArray(features.se04Version);
46270
- default:
46271
- return undefined;
46272
- }
46273
- }
46274
- isProtocolV2ComponentVersionSatisfied(release, component, target, features) {
46275
- const targetVersion = this.getProtocolV2ComponentTargetVersion(release, component, target);
46276
- if (!targetVersion)
46277
- return false;
46278
- const currentVersion = this.getProtocolV2ComponentCurrentVersion(features, target);
46279
- const compareResult = compareProtocolV2Versions(currentVersion, targetVersion);
46280
- return compareResult !== undefined && compareResult >= 0;
46281
- }
46282
46466
  getProtocolV2ResourceFilePath(path) {
46283
46467
  if (path.startsWith('vol'))
46284
46468
  return path;
@@ -46330,13 +46514,6 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
46330
46514
  return parseProtocolV2OkppHeader(headerBytes);
46331
46515
  });
46332
46516
  }
46333
- shouldInstallRemoteProtocolV2Component(release, key, component, target, features) {
46334
- const versionSatisfied = this.isProtocolV2ComponentVersionSatisfied(release, component, target, features);
46335
- if (versionSatisfied) {
46336
- Log$4.log(`[FirmwareUpdateV4] skip Protocol V2 component ${key}; version is up to date`);
46337
- }
46338
- return !versionSatisfied;
46339
- }
46340
46517
  downloadRemoteProtocolV2Component(key, component) {
46341
46518
  return __awaiter(this, void 0, void 0, function* () {
46342
46519
  const target = this.getRemoteComponentTarget(key, component);
@@ -46348,6 +46525,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
46348
46525
  });
46349
46526
  }
46350
46527
  prepareRemoteProtocolV2Binaries(firmwareType, features) {
46528
+ var _a;
46351
46529
  return __awaiter(this, void 0, void 0, function* () {
46352
46530
  const release = DataManager.getFirmwareLatestRelease(features, firmwareType);
46353
46531
  let bootloaderBinary = null;
@@ -46361,9 +46539,11 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
46361
46539
  };
46362
46540
  }
46363
46541
  const entries = this.getRemoteComponentEntries(release);
46542
+ const targetsToUpdate = new Set((_a = this.params.targetsToUpdate) !== null && _a !== void 0 ? _a : []);
46364
46543
  for (const [key, component] of entries) {
46365
46544
  const target = this.getRemoteComponentTarget(key, component);
46366
- const shouldInstall = this.shouldInstallRemoteProtocolV2Component(release, key, component, target, features);
46545
+ const updateTarget = PROTOCOL_V2_UPDATE_TARGET_BY_TARGET_ID.get(target.targetId);
46546
+ const shouldInstall = updateTarget ? targetsToUpdate.has(updateTarget) : false;
46367
46547
  if (shouldInstall) {
46368
46548
  const remoteBinary = yield this.downloadRemoteProtocolV2Component(key, component);
46369
46549
  if (remoteBinary.kind === 'bootloader') {
@@ -46394,7 +46574,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
46394
46574
  });
46395
46575
  }
46396
46576
  prepareProtocolV2ResourceBundles(firmwareType, features) {
46397
- var _a, _b;
46577
+ var _a, _b, _c;
46398
46578
  if ((_a = this.params.resourceBundleFiles) === null || _a === void 0 ? void 0 : _a.length) {
46399
46579
  return this.params.resourceBundleFiles.map(file => {
46400
46580
  var _a;
@@ -46405,8 +46585,11 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
46405
46585
  });
46406
46586
  });
46407
46587
  }
46588
+ if (!((_b = this.params.targetsToUpdate) === null || _b === void 0 ? void 0 : _b.includes('resource'))) {
46589
+ return undefined;
46590
+ }
46408
46591
  const release = DataManager.getFirmwareLatestRelease(features, firmwareType);
46409
- if (!((_b = release === null || release === void 0 ? void 0 : release.resourceBundles) === null || _b === void 0 ? void 0 : _b.length))
46592
+ if (!((_c = release === null || release === void 0 ? void 0 : release.resourceBundles) === null || _c === void 0 ? void 0 : _c.length))
46410
46593
  return undefined;
46411
46594
  return release.resourceBundles.map(bundle => ({
46412
46595
  name: bundle.name,
@@ -46428,13 +46611,13 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
46428
46611
  const filtered = [];
46429
46612
  for (const bundle of bundles) {
46430
46613
  if (bundle.binary.byteLength === 0 && bundle.url) {
46431
- Log$4.log(`[FirmwareUpdateV4] downloading RESC bundle ${bundle.name} from ${bundle.url}`);
46614
+ Log$5.log(`[FirmwareUpdateV4] downloading RESC bundle ${bundle.name} from ${bundle.url}`);
46432
46615
  const { binary } = yield getSysResourceBinary(bundle.url);
46433
46616
  bundle.binary = binary;
46434
46617
  }
46435
46618
  const upToDate = yield this.isProtocolV2ResourceBundleUpToDate(bundle);
46436
46619
  if (upToDate) {
46437
- Log$4.log(`[FirmwareUpdateV4] skip RESC bundle ${bundle.name}; already up to date`);
46620
+ Log$5.log(`[FirmwareUpdateV4] skip RESC bundle ${bundle.name}; already up to date`);
46438
46621
  }
46439
46622
  else {
46440
46623
  filtered.push(bundle);
@@ -46443,7 +46626,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
46443
46626
  bundlesToSync = filtered;
46444
46627
  }
46445
46628
  if (bundlesToSync.length === 0) {
46446
- Log$4.log('[FirmwareUpdateV4] all RESC bundles up to date, nothing to sync');
46629
+ Log$5.log('[FirmwareUpdateV4] all RESC bundles up to date, nothing to sync');
46447
46630
  return { processedSize: 0, totalSize: firmwareSize };
46448
46631
  }
46449
46632
  let totalSize = 0;
@@ -46452,7 +46635,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
46452
46635
  const transferTotalSize = totalSize + firmwareSize;
46453
46636
  let processedSize = 0;
46454
46637
  for (const bundle of bundlesToSync) {
46455
- Log$4.log(`[FirmwareUpdateV4] syncing RESC bundle ${bundle.name} -> ${bundle.devicePath} bytes=${bundle.binary.byteLength}`);
46638
+ Log$5.log(`[FirmwareUpdateV4] syncing RESC bundle ${bundle.name} -> ${bundle.devicePath} bytes=${bundle.binary.byteLength}`);
46456
46639
  processedSize = yield this.protocolV2CommonUpdateProcess({
46457
46640
  payload: bundle.binary,
46458
46641
  filePath: bundle.devicePath,
@@ -46461,7 +46644,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
46461
46644
  });
46462
46645
  }
46463
46646
  const elapsedMs = Date.now() - transferStartTime;
46464
- Log$4.log(`[FirmwareUpdateV4] RESC bundle sync finished transport=${transferTransport} bytes=${totalSize} elapsed=${(elapsedMs / 1000).toFixed(2)}s speed=${formatProtocolV2TransferSpeed(totalSize, elapsedMs)} KB/s`);
46647
+ Log$5.log(`[FirmwareUpdateV4] RESC bundle sync finished transport=${transferTransport} bytes=${totalSize} elapsed=${(elapsedMs / 1000).toFixed(2)}s speed=${formatProtocolV2TransferSpeed(totalSize, elapsedMs)} KB/s`);
46465
46648
  return { processedSize, totalSize: transferTotalSize };
46466
46649
  });
46467
46650
  }
@@ -46493,7 +46676,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
46493
46676
  return true;
46494
46677
  }
46495
46678
  catch (error) {
46496
- Log$4.log(`[FirmwareUpdateV4] RESC bundle ${bundle.name} header check failed: `, error);
46679
+ Log$5.log(`[FirmwareUpdateV4] RESC bundle ${bundle.name} header check failed: `, error);
46497
46680
  return false;
46498
46681
  }
46499
46682
  });
@@ -46508,7 +46691,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
46508
46691
  enterProtocolV2BootloaderMode() {
46509
46692
  return __awaiter(this, void 0, void 0, function* () {
46510
46693
  if (this.isProtocolV2BootloaderMode()) {
46511
- Log$4.debug('Protocol V2 device is already in bootloader mode, skip reboot to bootloader');
46694
+ Log$5.debug('Protocol V2 device is already in bootloader mode, skip reboot to bootloader');
46512
46695
  return false;
46513
46696
  }
46514
46697
  try {
@@ -46523,7 +46706,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
46523
46706
  if (error instanceof hdShared.HardwareError) {
46524
46707
  throw error;
46525
46708
  }
46526
- Log$4.log('Protocol V2 auto go to bootloader mode failed: ', error);
46709
+ Log$5.log('Protocol V2 auto go to bootloader mode failed: ', error);
46527
46710
  throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.FirmwareUpdateAutoEnterBootFailure);
46528
46711
  }
46529
46712
  });
@@ -46547,7 +46730,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
46547
46730
  }
46548
46731
  catch (error) {
46549
46732
  lastError = error;
46550
- Log$4.log('Protocol V2 bootloader mode not ready, polling reconnect: ', error);
46733
+ Log$5.log('Protocol V2 bootloader mode not ready, polling reconnect: ', error);
46551
46734
  }
46552
46735
  yield hdShared.wait(retryInterval);
46553
46736
  }
@@ -46590,7 +46773,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
46590
46773
  totalSize = resourceTransfer.totalSize;
46591
46774
  }
46592
46775
  if (orderedInstallItems.length === 0) {
46593
- Log$4.log('[FirmwareUpdateV4] no firmware targets to install (RESC bundles only)');
46776
+ Log$5.log('[FirmwareUpdateV4] no firmware targets to install (RESC bundles only)');
46594
46777
  if (totalSize > 0) {
46595
46778
  this.postProgressMessage(100, 'transferData');
46596
46779
  }
@@ -46603,12 +46786,12 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
46603
46786
  const onTransferredBytes = (bytes) => {
46604
46787
  transferredSize = bytes;
46605
46788
  };
46606
- Log$4.log(`[FirmwareUpdateV4] transfer started transport=${transferTransport} total=${totalSize} bytes chunk=${chunkSize} bytes`);
46789
+ Log$5.log(`[FirmwareUpdateV4] transfer started transport=${transferTransport} total=${totalSize} bytes chunk=${chunkSize} bytes`);
46607
46790
  const stagedInstallTargets = [];
46608
46791
  try {
46609
46792
  for (const item of orderedInstallItems) {
46610
46793
  const filePath = this.getProtocolV2InstallItemStagingPath(item);
46611
- Log$4.log(`[FirmwareUpdateV4] staging ${item.kind} via FilesystemFileWrite target=${item.targetId} path=${filePath} source=${item.fileName} bytes=${item.binary.byteLength}`);
46794
+ Log$5.log(`[FirmwareUpdateV4] staging ${item.kind} via FilesystemFileWrite target=${item.targetId} path=${filePath} source=${item.fileName} bytes=${item.binary.byteLength}`);
46612
46795
  processedSize = yield this.protocolV2CommonUpdateProcess({
46613
46796
  payload: item.binary,
46614
46797
  filePath,
@@ -46624,11 +46807,11 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
46624
46807
  this.postProgressMessage(100, 'transferData');
46625
46808
  }
46626
46809
  const elapsedMs = Date.now() - transferStartTime;
46627
- Log$4.log(`[FirmwareUpdateV4] transfer finished transport=${transferTransport} bytes=${totalSize} elapsed=${(elapsedMs / 1000).toFixed(2)}s speed=${formatProtocolV2TransferSpeed(totalSize, elapsedMs)} KB/s`);
46810
+ Log$5.log(`[FirmwareUpdateV4] transfer finished transport=${transferTransport} bytes=${totalSize} elapsed=${(elapsedMs / 1000).toFixed(2)}s speed=${formatProtocolV2TransferSpeed(totalSize, elapsedMs)} KB/s`);
46628
46811
  }
46629
46812
  catch (error) {
46630
46813
  const elapsedMs = Date.now() - transferStartTime;
46631
- Log$4.warn(`[FirmwareUpdateV4] transfer failed transport=${transferTransport} bytes=${transferredSize}/${totalSize} elapsed=${(elapsedMs / 1000).toFixed(2)}s speed=${formatProtocolV2TransferSpeed(transferredSize, elapsedMs)} KB/s`);
46814
+ Log$5.warn(`[FirmwareUpdateV4] transfer failed transport=${transferTransport} bytes=${transferredSize}/${totalSize} elapsed=${(elapsedMs / 1000).toFixed(2)}s speed=${formatProtocolV2TransferSpeed(transferredSize, elapsedMs)} KB/s`);
46632
46815
  throw error;
46633
46816
  }
46634
46817
  this.postTipMessage(exports.FirmwareUpdateTipMessage.ConfirmOnDevice);
@@ -46636,7 +46819,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
46636
46819
  target_id: item.targetId,
46637
46820
  path: item.path,
46638
46821
  }));
46639
- Log$4.log(`[FirmwareUpdateV4] DeviceFirmwareUpdateRequest targets=${JSON.stringify(allTargets)}`);
46822
+ Log$5.log(`[FirmwareUpdateV4] DeviceFirmwareUpdateRequest targets=${JSON.stringify(allTargets)}`);
46640
46823
  const startResponse = yield this.protocolV2StartFirmwareUpdate({ targets: allTargets });
46641
46824
  yield this.waitForProtocolV2FirmwareUpdateComplete(allTargets, startResponse);
46642
46825
  });
@@ -46683,7 +46866,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
46683
46866
  });
46684
46867
  const features = this.device.updateProtocolV2Features(deviceInfo);
46685
46868
  if (this.isProtocolV2NormalModeFeatures(features)) {
46686
- Log$4.log('Protocol V2 firmware install finished; device is back in normal mode');
46869
+ Log$5.log('Protocol V2 firmware install finished; device is back in normal mode');
46687
46870
  return true;
46688
46871
  }
46689
46872
  return false;
@@ -46741,7 +46924,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
46741
46924
  if (error instanceof hdShared.HardwareError && error.errorCode === hdShared.HardwareErrorCode.FirmwareError) {
46742
46925
  throw error;
46743
46926
  }
46744
- Log$4.log('Protocol V2 firmware install status polling failed: ', error);
46927
+ Log$5.log('Protocol V2 firmware install status polling failed: ', error);
46745
46928
  if (isProtocolV2PollingTransientError(error)) {
46746
46929
  try {
46747
46930
  yield this.reconnectProtocolV2Device();
@@ -46751,15 +46934,15 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
46751
46934
  }
46752
46935
  catch (reconnectError) {
46753
46936
  lastError = reconnectError;
46754
- Log$4.log('Protocol V2 firmware install reconnect/normal-mode probe failed: ', reconnectError);
46937
+ Log$5.log('Protocol V2 firmware install reconnect/normal-mode probe failed: ', reconnectError);
46755
46938
  }
46756
46939
  try {
46757
46940
  yield this.pingProtocolV2Device();
46758
- Log$4.log('Protocol V2 firmware status unavailable, Ping is ready');
46941
+ Log$5.log('Protocol V2 firmware status unavailable, Ping is ready');
46759
46942
  }
46760
46943
  catch (pingError) {
46761
46944
  lastError = pingError;
46762
- Log$4.log('Protocol V2 firmware install Ping polling failed: ', pingError);
46945
+ Log$5.log('Protocol V2 firmware install Ping polling failed: ', pingError);
46763
46946
  }
46764
46947
  }
46765
46948
  }
@@ -46774,12 +46957,12 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
46774
46957
  try {
46775
46958
  yield this.reconnectProtocolV2Device();
46776
46959
  if (yield this.probeProtocolV2NormalMode()) {
46777
- Log$4.log('Protocol V2 device is already in normal mode, skip normal reboot');
46960
+ Log$5.log('Protocol V2 device is already in normal mode, skip normal reboot');
46778
46961
  return;
46779
46962
  }
46780
46963
  }
46781
46964
  catch (error) {
46782
- Log$4.log('Protocol V2 normal-mode probe before reboot failed: ', error);
46965
+ Log$5.log('Protocol V2 normal-mode probe before reboot failed: ', error);
46783
46966
  }
46784
46967
  yield this.protocolV2Reboot(hdTransport.DeviceRebootType.Normal);
46785
46968
  });
@@ -46791,7 +46974,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
46791
46974
  const bleVersion = getDeviceBLEFirmwareVersion(features).join('.');
46792
46975
  const firmwareVersion = getDeviceFirmwareVersion(features).join('.');
46793
46976
  if (firmwareVersion === '0.0.0') {
46794
- Log$4.warn('Protocol V2 firmware update finished but app firmware version is still 0.0.0. This is allowed for Pro2 debug BLE-only update flows.');
46977
+ Log$5.warn('Protocol V2 firmware update finished but app firmware version is still 0.0.0. This is allowed for Pro2 debug BLE-only update flows.');
46795
46978
  }
46796
46979
  return {
46797
46980
  bootloaderVersion,
@@ -46820,7 +47003,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
46820
47003
  }
46821
47004
  catch (error) {
46822
47005
  lastError = error;
46823
- Log$4.log('Protocol V2 normal mode not ready, polling Ping: ', error);
47006
+ Log$5.log('Protocol V2 normal mode not ready, polling Ping: ', error);
46824
47007
  yield hdShared.wait(1000);
46825
47008
  }
46826
47009
  }
@@ -46851,7 +47034,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
46851
47034
  if (deviceList.length !== 1) {
46852
47035
  throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.DeviceNotFound);
46853
47036
  }
46854
- Log$4.debug('Protocol V2 firmware reconnect using single enumerated device:', deviceList[0].getConnectId());
47037
+ Log$5.debug('Protocol V2 firmware reconnect using single enumerated device:', deviceList[0].getConnectId());
46855
47038
  this.device.updateFromCache(deviceList[0]);
46856
47039
  yield this.device.acquire(PROTOCOL_V2_CONNECT_PROTOCOL, { throwOnRunPromiseError: true });
46857
47040
  this.device.commands.disposed = false;
@@ -46868,7 +47051,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
46868
47051
  }
46869
47052
  catch (error) {
46870
47053
  lastError = error;
46871
- Log$4.error(`Protocol V2 file transfer failed path=${params.filePath} attempt=${attempt}/${PROTOCOL_V2_FILE_TRANSFER_RETRY_COUNT}; restarting from offset 0`, error);
47054
+ Log$5.error(`Protocol V2 file transfer failed path=${params.filePath} attempt=${attempt}/${PROTOCOL_V2_FILE_TRANSFER_RETRY_COUNT}; restarting from offset 0`, error);
46872
47055
  if (attempt === PROTOCOL_V2_FILE_TRANSFER_RETRY_COUNT) {
46873
47056
  break;
46874
47057
  }
@@ -46982,7 +47165,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
46982
47165
  }
46983
47166
  catch (error) {
46984
47167
  if (isProtocolV2StartUpdateTransientError(error)) {
46985
- Log$4.log('Protocol V2 firmware update request did not return; continue status polling', error);
47168
+ Log$5.log('Protocol V2 firmware update request did not return; continue status polling', error);
46986
47169
  }
46987
47170
  else {
46988
47171
  throw error;
@@ -47017,7 +47200,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
47017
47200
  }
47018
47201
  }
47019
47202
 
47020
- const Log$3 = getLogger(exports.LoggerNames.Method);
47203
+ const Log$4 = getLogger(exports.LoggerNames.Method);
47021
47204
  class PromptWebDeviceAccess extends BaseMethod {
47022
47205
  init() {
47023
47206
  this.useDevice = false;
@@ -47074,7 +47257,7 @@ class PromptWebDeviceAccess extends BaseMethod {
47074
47257
  return { device: null };
47075
47258
  }
47076
47259
  catch (error) {
47077
- Log$3.debug(error);
47260
+ Log$4.debug(error);
47078
47261
  return Promise.reject(hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, 'Please select the device to connect'));
47079
47262
  }
47080
47263
  });
@@ -47234,19 +47417,30 @@ class DeviceStatusGet extends BaseMethod {
47234
47417
  }
47235
47418
  }
47236
47419
 
47420
+ class DeviceGetOnboardingStatus extends BaseMethod {
47421
+ init() {
47422
+ this.requireProtocolV2 = true;
47423
+ this.skipForceUpdateCheck = true;
47424
+ this.useDevicePassphraseState = false;
47425
+ }
47426
+ run() {
47427
+ return __awaiter(this, void 0, void 0, function* () {
47428
+ const { message } = yield this.device.commands.typedCall('DevGetOnboardingStatus', 'DevOnboardingStatus', {});
47429
+ return message;
47430
+ });
47431
+ }
47432
+ }
47433
+
47237
47434
  class DeviceSessionGet extends BaseMethod {
47238
47435
  init() {
47239
47436
  this.requireProtocolV2 = true;
47240
47437
  this.useDevicePassphraseState = false;
47241
47438
  this.skipForceUpdateCheck = true;
47242
- this.params = {
47243
- sessionId: this.payload.sessionId,
47244
- };
47439
+ this.params = undefined;
47245
47440
  }
47246
47441
  run() {
47247
47442
  return __awaiter(this, void 0, void 0, function* () {
47248
- const payload = this.params.sessionId ? { session_id: this.params.sessionId } : {};
47249
- const { message } = yield this.device.commands.typedCall('DeviceSessionGet', 'DeviceSession', payload);
47443
+ const { message } = yield this.device.commands.typedCall('DeviceSessionGet', 'DeviceSession', {});
47250
47444
  return message;
47251
47445
  });
47252
47446
  }
@@ -47376,6 +47570,276 @@ class DeviceFactoryInfoGet extends BaseMethod {
47376
47570
  }
47377
47571
  }
47378
47572
 
47573
+ class DeviceSettingsGet extends BaseMethod {
47574
+ init() {
47575
+ this.requireProtocolV2 = true;
47576
+ this.unlockPolicy = 'retry-on-locked';
47577
+ this.skipForceUpdateCheck = true;
47578
+ this.useDevicePassphraseState = false;
47579
+ this.params = undefined;
47580
+ }
47581
+ run() {
47582
+ return __awaiter(this, void 0, void 0, function* () {
47583
+ const res = yield this.device.commands.typedCall('DeviceSettingsGet', 'DeviceSettings', {});
47584
+ return Promise.resolve(res.message);
47585
+ });
47586
+ }
47587
+ }
47588
+
47589
+ class DeviceSettingsSet extends BaseMethod {
47590
+ init() {
47591
+ const settings = this.payload.settings;
47592
+ if (!settings || typeof settings !== 'object' || Array.isArray(settings)) {
47593
+ throw invalidParameter('Parameter [settings] must be an object.');
47594
+ }
47595
+ const _a = settings, supported = __rest(_a, ["passphrase_enable", "airgap_mode"]);
47596
+ if (Object.keys(supported).length === 0) {
47597
+ throw invalidParameter('Parameter [settings] must contain at least one supported setting.');
47598
+ }
47599
+ this.requireProtocolV2 = true;
47600
+ this.unlockPolicy = 'retry-on-locked';
47601
+ this.skipForceUpdateCheck = true;
47602
+ this.useDevicePassphraseState = false;
47603
+ this.params = { settings: supported };
47604
+ }
47605
+ run() {
47606
+ return __awaiter(this, void 0, void 0, function* () {
47607
+ const res = yield this.device.commands.typedCall('DeviceSettingsSet', 'Success', this.params);
47608
+ return Promise.resolve(res.message);
47609
+ });
47610
+ }
47611
+ }
47612
+
47613
+ const SUPPORTED_PAGES = new Set([
47614
+ hdTransport.DeviceSettingsPage.DeviceReset,
47615
+ hdTransport.DeviceSettingsPage.DevicePinChange,
47616
+ hdTransport.DeviceSettingsPage.DevicePassphrase,
47617
+ hdTransport.DeviceSettingsPage.DeviceAirgap,
47618
+ ]);
47619
+ function normalizePage(value) {
47620
+ const page = typeof value === 'string' ? hdTransport.DeviceSettingsPage[value] : value;
47621
+ if (page !== undefined && SUPPORTED_PAGES.has(page)) {
47622
+ return page;
47623
+ }
47624
+ throw invalidParameter('Parameter [page] must be DeviceReset, DevicePinChange, DevicePassphrase, or DeviceAirgap.');
47625
+ }
47626
+ class DeviceSettingsPageShow extends BaseMethod {
47627
+ init() {
47628
+ var _a;
47629
+ this.requireProtocolV2 = true;
47630
+ this.unlockPolicy = 'retry-on-locked';
47631
+ this.skipForceUpdateCheck = true;
47632
+ this.useDevicePassphraseState = false;
47633
+ this.params = {
47634
+ page: normalizePage(this.payload.page),
47635
+ field_name: (_a = this.payload.field_name) !== null && _a !== void 0 ? _a : this.payload.fieldName,
47636
+ };
47637
+ }
47638
+ run() {
47639
+ return __awaiter(this, void 0, void 0, function* () {
47640
+ const res = yield this.device.commands.typedCall('DeviceSettingsPageShow', 'Success', this.params);
47641
+ return Promise.resolve(res.message);
47642
+ });
47643
+ }
47644
+ }
47645
+
47646
+ const MIN_FILE_CHUNK_SIZE = 64;
47647
+ function getProtocolV2FileChunkLimit() {
47648
+ const env = DataManager.getSettings('env');
47649
+ return env && DataManager.isBleConnect(env)
47650
+ ? hdTransport.PROTOCOL_V2_BLE_FILE_CHUNK_SIZE
47651
+ : hdTransport.PROTOCOL_V2_WEBUSB_FILE_CHUNK_SIZE;
47652
+ }
47653
+ function dataToUint8Array(data) {
47654
+ return __awaiter(this, void 0, void 0, function* () {
47655
+ if (typeof data === 'string')
47656
+ return new TextEncoder().encode(data);
47657
+ if (data instanceof ArrayBuffer)
47658
+ return new Uint8Array(data);
47659
+ if (ArrayBuffer.isView(data)) {
47660
+ return new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
47661
+ }
47662
+ if (typeof Blob !== 'undefined' && data instanceof Blob) {
47663
+ return new Uint8Array(yield data.arrayBuffer());
47664
+ }
47665
+ throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.CallMethodInvalidParameter, 'Unsupported FilesystemFileWrite data');
47666
+ });
47667
+ }
47668
+ function normalizeChunkSize$1(value, maxChunkSize) {
47669
+ const numeric = Number(value);
47670
+ if (!Number.isFinite(numeric) || numeric <= 0)
47671
+ return maxChunkSize;
47672
+ return Math.min(Math.max(Math.floor(numeric), MIN_FILE_CHUNK_SIZE), maxChunkSize);
47673
+ }
47674
+ function getDeviceTransferProgress$1(before, after, total) {
47675
+ if (!Number.isFinite(total) || total <= 0)
47676
+ return 100;
47677
+ if (before <= 0 && after < total)
47678
+ return 0;
47679
+ if (after >= total)
47680
+ return 100;
47681
+ return Math.min(Math.max(Math.ceil((after / total) * 100), 1), 99);
47682
+ }
47683
+ function getConfirmedProgress(processed, total, written, length) {
47684
+ if (Number.isFinite(processed) && Number.isFinite(total) && total > 0) {
47685
+ if (processed >= total)
47686
+ return 100;
47687
+ return Math.min(Math.max(Math.floor((processed / total) * 100), 0), 99);
47688
+ }
47689
+ if (length > 0)
47690
+ return written >= length ? 100 : Math.floor((written / length) * 100);
47691
+ return 100;
47692
+ }
47693
+ function writeProtocolV2File(options) {
47694
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
47695
+ return __awaiter(this, void 0, void 0, function* () {
47696
+ (_a = options.throwIfAborted) === null || _a === void 0 ? void 0 : _a.call(options);
47697
+ const data = yield dataToUint8Array(options.data);
47698
+ const dataLength = data.byteLength;
47699
+ const startOffset = Number.isFinite(options.offset) && Number(options.offset) > 0 ? Number(options.offset) : 0;
47700
+ const totalSize = Number.isFinite(options.totalSize) && Number(options.totalSize) > 0
47701
+ ? Number(options.totalSize)
47702
+ : startOffset + dataLength;
47703
+ if (totalSize < startOffset + dataLength) {
47704
+ throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, `FilesystemFileWrite totalSize ${totalSize} is smaller than offset + data length ${startOffset + dataLength}`);
47705
+ }
47706
+ const chunkSize = normalizeChunkSize$1((_b = options.chunkSize) !== null && _b !== void 0 ? _b : options.chunkLen, getProtocolV2FileChunkLimit());
47707
+ let written = 0;
47708
+ let chunks = 0;
47709
+ let lastMessage;
47710
+ const startTime = Date.now();
47711
+ while (written < dataLength) {
47712
+ (_c = options.throwIfAborted) === null || _c === void 0 ? void 0 : _c.call(options);
47713
+ const chunk = data.slice(written, Math.min(written + chunkSize, dataLength));
47714
+ const offset = startOffset + written;
47715
+ const progress = (_d = options.uiPercentage) !== null && _d !== void 0 ? _d : getDeviceTransferProgress$1(offset, offset + chunk.byteLength, totalSize);
47716
+ const response = yield options.commands.typedCall('FilesystemFileWrite', 'FilesystemFile', {
47717
+ file: { path: options.path, offset, total_size: totalSize, data: chunk },
47718
+ overwrite: chunks === 0 ? (_e = options.overwrite) !== null && _e !== void 0 ? _e : false : false,
47719
+ append: (_f = options.append) !== null && _f !== void 0 ? _f : false,
47720
+ ui_percentage: progress,
47721
+ }, { timeoutMs: options.timeoutMs });
47722
+ (_g = options.throwIfAborted) === null || _g === void 0 ? void 0 : _g.call(options);
47723
+ lastMessage = response.message;
47724
+ const processedByte = Number((_h = response.message) === null || _h === void 0 ? void 0 : _h.processed_byte);
47725
+ written =
47726
+ Number.isFinite(processedByte) && processedByte > offset
47727
+ ? processedByte - startOffset
47728
+ : written + chunk.byteLength;
47729
+ if (written > dataLength) {
47730
+ throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, `FilesystemFileWrite invalid processed_byte ${processedByte}`);
47731
+ }
47732
+ chunks += 1;
47733
+ const elapsedMs = Date.now() - startTime;
47734
+ const transferredBytes = Math.min(written, dataLength);
47735
+ (_j = options.onProgress) === null || _j === void 0 ? void 0 : _j.call(options, {
47736
+ progress: getConfirmedProgress(startOffset + written, totalSize, written, dataLength),
47737
+ transferredBytes,
47738
+ totalBytes: dataLength,
47739
+ rateBytesPerSecond: elapsedMs > 0 ? Math.round((transferredBytes / elapsedMs) * 1000) : undefined,
47740
+ elapsedMs,
47741
+ });
47742
+ }
47743
+ return Object.assign(Object.assign({}, lastMessage), { path: options.path, offset: startOffset, total_size: totalSize, processed_byte: startOffset + written, chunks });
47744
+ });
47745
+ }
47746
+
47747
+ const WALLPAPER_DIRECTORY = 'vol0:/wallpapers/user';
47748
+ const SAFE_FILE_NAME = /^[A-Za-z0-9_-]+(?:\.bin)?$/;
47749
+ function normalizeFileName(fileName, data) {
47750
+ if (fileName !== undefined && (!fileName || !SAFE_FILE_NAME.test(fileName))) {
47751
+ throw invalidParameter('Parameter [fileName] may only contain letters, numbers, underscores, hyphens and an optional .bin suffix.');
47752
+ }
47753
+ const baseName = fileName !== null && fileName !== void 0 ? fileName : `wallpaper-${utils.bytesToHex(blake2s.blake2s(data)).slice(0, 12)}`;
47754
+ return baseName.endsWith('.bin') ? baseName : `${baseName}.bin`;
47755
+ }
47756
+ class DeviceUploadWallpaper extends BaseMethod {
47757
+ constructor() {
47758
+ super(...arguments);
47759
+ this.directoryReady = false;
47760
+ this.uploaded = false;
47761
+ this.path = '';
47762
+ }
47763
+ init() {
47764
+ const { width, height, rgba, fileName, chunkSize } = this.payload;
47765
+ if (width !== PRO2_WALLPAPER_WIDTH || height !== PRO2_WALLPAPER_HEIGHT) {
47766
+ throw invalidParameter(`Pro2 wallpaper dimensions must be ${PRO2_WALLPAPER_WIDTH}x${PRO2_WALLPAPER_HEIGHT}.`);
47767
+ }
47768
+ if (!(rgba instanceof ArrayBuffer) && !ArrayBuffer.isView(rgba)) {
47769
+ throw invalidParameter('Parameter [rgba] must be an ArrayBuffer or Uint8Array.');
47770
+ }
47771
+ if (chunkSize !== undefined && (!Number.isInteger(chunkSize) || chunkSize <= 0)) {
47772
+ throw invalidParameter('Parameter [chunkSize] must be a positive integer.');
47773
+ }
47774
+ const rgbaBytes = rgba instanceof ArrayBuffer
47775
+ ? rgba
47776
+ : new Uint8Array(rgba.buffer, rgba.byteOffset, rgba.byteLength);
47777
+ this.encoded = encodePro2Wallpaper({ width, height, rgba: rgbaBytes });
47778
+ this.path = `${WALLPAPER_DIRECTORY}/${normalizeFileName(fileName, this.encoded.data)}`;
47779
+ this.params = { width, height, rgba: rgbaBytes, fileName, chunkSize };
47780
+ this.requireProtocolV2 = true;
47781
+ this.unlockPolicy = 'retry-on-locked';
47782
+ this.skipForceUpdateCheck = true;
47783
+ this.useDevicePassphraseState = false;
47784
+ }
47785
+ ensureDirectory() {
47786
+ return __awaiter(this, void 0, void 0, function* () {
47787
+ if (this.directoryReady)
47788
+ return;
47789
+ try {
47790
+ yield this.device.commands.typedCall('FilesystemDirMake', 'Success', {
47791
+ path: WALLPAPER_DIRECTORY,
47792
+ });
47793
+ }
47794
+ catch (error) {
47795
+ const message = error instanceof Error ? error.message : String(error);
47796
+ if (!/exist/i.test(message))
47797
+ throw error;
47798
+ }
47799
+ this.directoryReady = true;
47800
+ });
47801
+ }
47802
+ upload() {
47803
+ return __awaiter(this, void 0, void 0, function* () {
47804
+ if (this.uploaded)
47805
+ return;
47806
+ const encoded = this.encoded;
47807
+ if (!encoded)
47808
+ throw invalidParameter('Wallpaper data has not been initialized.');
47809
+ yield writeProtocolV2File({
47810
+ commands: this.device.commands,
47811
+ path: this.path,
47812
+ data: encoded.data,
47813
+ totalSize: encoded.data.byteLength,
47814
+ chunkSize: this.params.chunkSize,
47815
+ overwrite: true,
47816
+ append: false,
47817
+ throwIfAborted: () => this.throwIfAborted(),
47818
+ });
47819
+ this.uploaded = true;
47820
+ });
47821
+ }
47822
+ run() {
47823
+ var _a;
47824
+ return __awaiter(this, void 0, void 0, function* () {
47825
+ const encoded = this.encoded;
47826
+ if (!encoded)
47827
+ throw invalidParameter('Wallpaper data has not been initialized.');
47828
+ yield this.ensureDirectory();
47829
+ yield this.upload();
47830
+ const response = yield this.device.commands.typedCall('DeviceSettingsSet', 'Success', {
47831
+ settings: { wallpaper_path: this.path },
47832
+ });
47833
+ return {
47834
+ path: this.path,
47835
+ size: encoded.data.byteLength,
47836
+ colorFormat: encoded.colorFormat,
47837
+ message: (_a = response.message) === null || _a === void 0 ? void 0 : _a.message,
47838
+ };
47839
+ });
47840
+ }
47841
+ }
47842
+
47379
47843
  class FilesystemPermissionFix extends BaseMethod {
47380
47844
  init() {
47381
47845
  this.requireProtocolV2 = true;
@@ -47451,7 +47915,7 @@ function getProtocolV2FileReadChunkLimit() {
47451
47915
  }
47452
47916
  return hdTransport.PROTOCOL_V2_WEBUSB_FILE_CHUNK_SIZE;
47453
47917
  }
47454
- function normalizeChunkSize$1(value, maxChunkSize) {
47918
+ function normalizeChunkSize(value, maxChunkSize) {
47455
47919
  const numeric = Number(value);
47456
47920
  if (!Number.isFinite(numeric) || numeric <= 0)
47457
47921
  return maxChunkSize;
@@ -47491,7 +47955,7 @@ function toUint8Array(value) {
47491
47955
  }
47492
47956
  return new Uint8Array(0);
47493
47957
  }
47494
- function getDeviceTransferProgress$1(bytesBeforeChunk, bytesAfterChunk, totalBytes) {
47958
+ function getDeviceTransferProgress(bytesBeforeChunk, bytesAfterChunk, totalBytes) {
47495
47959
  if (!Number.isFinite(totalBytes) || totalBytes <= 0) {
47496
47960
  return 100;
47497
47961
  }
@@ -47522,7 +47986,7 @@ class FileRead extends BaseMethod {
47522
47986
  return __awaiter(this, void 0, void 0, function* () {
47523
47987
  const startOffset = (_a = this.params.offset) !== null && _a !== void 0 ? _a : 0;
47524
47988
  const requestedLength = Number(this.params.totalSize);
47525
- const chunkSize = normalizeChunkSize$1(this.params.chunkLen, getProtocolV2FileReadChunkLimit());
47989
+ const chunkSize = normalizeChunkSize(this.params.chunkLen, getProtocolV2FileReadChunkLimit());
47526
47990
  let totalLength = Number.isFinite(requestedLength) && requestedLength > 0 ? requestedLength : 0;
47527
47991
  if (totalLength === 0) {
47528
47992
  const pathInfoRes = yield this.device.commands.typedCall('FilesystemPathInfoQuery', 'FilesystemPathInfo', {
@@ -47543,7 +48007,7 @@ class FileRead extends BaseMethod {
47543
48007
  while (read < totalLength) {
47544
48008
  const readLen = Math.min(chunkSize, totalLength - read);
47545
48009
  const offset = startOffset + read;
47546
- const progress = (_e = this.params.uiPercentage) !== null && _e !== void 0 ? _e : getDeviceTransferProgress$1(read, read + readLen, totalLength);
48010
+ const progress = (_e = this.params.uiPercentage) !== null && _e !== void 0 ? _e : getDeviceTransferProgress(read, read + readLen, totalLength);
47547
48011
  const res = yield this.device.commands.typedCall('FilesystemFileRead', 'FilesystemFile', {
47548
48012
  file: {
47549
48013
  path: this.params.path,
@@ -47572,62 +48036,6 @@ class FileRead extends BaseMethod {
47572
48036
  }
47573
48037
  }
47574
48038
 
47575
- const MIN_FILE_CHUNK_SIZE = 64;
47576
- function getProtocolV2FileChunkLimit() {
47577
- const env = DataManager.getSettings('env');
47578
- if (env && DataManager.isBleConnect(env)) {
47579
- return hdTransport.PROTOCOL_V2_BLE_FILE_CHUNK_SIZE;
47580
- }
47581
- return hdTransport.PROTOCOL_V2_WEBUSB_FILE_CHUNK_SIZE;
47582
- }
47583
- function dataToUint8Array(data) {
47584
- return __awaiter(this, void 0, void 0, function* () {
47585
- if (typeof data === 'string') {
47586
- return new TextEncoder().encode(data);
47587
- }
47588
- if (data instanceof ArrayBuffer) {
47589
- return new Uint8Array(data);
47590
- }
47591
- if (ArrayBuffer.isView(data)) {
47592
- return new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
47593
- }
47594
- if (typeof Blob !== 'undefined' && data instanceof Blob) {
47595
- return new Uint8Array(yield data.arrayBuffer());
47596
- }
47597
- throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.CallMethodInvalidParameter, 'Unsupported FilesystemFileWrite data');
47598
- });
47599
- }
47600
- function normalizeChunkSize(value, maxChunkSize) {
47601
- const numeric = Number(value);
47602
- if (!Number.isFinite(numeric) || numeric <= 0)
47603
- return maxChunkSize;
47604
- return Math.min(Math.max(Math.floor(numeric), MIN_FILE_CHUNK_SIZE), maxChunkSize);
47605
- }
47606
- function getConfirmedProgress(processedByte, totalSize, written, dataLength) {
47607
- if (Number.isFinite(processedByte) && Number.isFinite(totalSize) && totalSize > 0) {
47608
- if (processedByte >= totalSize)
47609
- return 100;
47610
- return Math.min(Math.max(Math.floor((processedByte / totalSize) * 100), 0), 99);
47611
- }
47612
- if (dataLength > 0) {
47613
- if (written >= dataLength)
47614
- return 100;
47615
- return Math.min(Math.max(Math.floor((written / dataLength) * 100), 0), 99);
47616
- }
47617
- return 100;
47618
- }
47619
- function getDeviceTransferProgress(bytesBeforeChunk, bytesAfterChunk, totalBytes) {
47620
- if (!Number.isFinite(totalBytes) || totalBytes <= 0) {
47621
- return 100;
47622
- }
47623
- if (bytesBeforeChunk <= 0 && bytesAfterChunk < totalBytes) {
47624
- return 0;
47625
- }
47626
- if (bytesAfterChunk >= totalBytes) {
47627
- return 100;
47628
- }
47629
- return Math.min(Math.max(Math.ceil((bytesAfterChunk / totalBytes) * 100), 1), 99);
47630
- }
47631
48039
  class FileWrite extends BaseMethod {
47632
48040
  init() {
47633
48041
  var _a, _b;
@@ -47651,74 +48059,26 @@ class FileWrite extends BaseMethod {
47651
48059
  };
47652
48060
  }
47653
48061
  run() {
47654
- var _a, _b, _c, _d, _e, _f;
47655
48062
  return __awaiter(this, void 0, void 0, function* () {
47656
- const data = yield dataToUint8Array(this.params.data);
47657
- const dataLength = data.byteLength;
47658
- const offsetValue = Number((_a = this.params.offset) !== null && _a !== void 0 ? _a : 0);
47659
- const startOffset = Number.isFinite(offsetValue) && offsetValue > 0 ? offsetValue : 0;
47660
- const payloadTotalSize = Number(this.params.totalSize);
47661
- const totalSize = Number.isFinite(payloadTotalSize) && payloadTotalSize > 0
47662
- ? payloadTotalSize
47663
- : startOffset + dataLength;
47664
- if (totalSize < startOffset + dataLength) {
47665
- throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, `FilesystemFileWrite totalSize ${totalSize} is smaller than offset + data length ${startOffset + dataLength}`);
47666
- }
47667
- const chunkSize = normalizeChunkSize((_b = this.params.chunkSize) !== null && _b !== void 0 ? _b : this.params.chunkLen, getProtocolV2FileChunkLimit());
47668
- const overwrite = (_c = this.params.overwrite) !== null && _c !== void 0 ? _c : false;
47669
- const append = (_d = this.params.append) !== null && _d !== void 0 ? _d : false;
47670
- let written = 0;
47671
- let chunkIndex = 0;
47672
- let lastMessage;
47673
- const startTime = Date.now();
47674
- const timeoutMs = this.params.timeoutMs === undefined ? undefined : Number(this.params.timeoutMs);
47675
- while (written < dataLength) {
47676
- const chunkEnd = Math.min(written + chunkSize, dataLength);
47677
- const chunk = data.slice(written, chunkEnd);
47678
- const offset = startOffset + written;
47679
- const isFirstChunk = chunkIndex === 0;
47680
- const progress = (_e = this.params.uiPercentage) !== null && _e !== void 0 ? _e : getDeviceTransferProgress(offset, offset + chunk.byteLength, totalSize);
47681
- const res = yield this.device.commands.typedCall('FilesystemFileWrite', 'FilesystemFile', {
47682
- file: {
47683
- path: this.params.path,
47684
- offset,
47685
- total_size: totalSize,
47686
- data: chunk,
47687
- },
47688
- overwrite: isFirstChunk ? overwrite : false,
47689
- append,
47690
- ui_percentage: progress,
47691
- }, {
47692
- timeoutMs,
47693
- });
47694
- lastMessage = res.message;
47695
- const processedByte = Number((_f = res.message) === null || _f === void 0 ? void 0 : _f.processed_byte);
47696
- if (Number.isFinite(processedByte) && processedByte > offset) {
47697
- written = processedByte - startOffset;
47698
- }
47699
- else {
47700
- written += chunk.byteLength;
47701
- }
47702
- if (written > dataLength) {
47703
- throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, `FilesystemFileWrite invalid processed_byte ${processedByte}`);
47704
- }
47705
- const confirmedProcessedByte = Number.isFinite(processedByte) && processedByte > offset
47706
- ? processedByte
47707
- : startOffset + written;
47708
- if (typeof this.postMessage === 'function') {
47709
- const elapsedMs = Date.now() - startTime;
47710
- const transferredBytes = Math.min(written, dataLength);
47711
- this.postMessage(createUiMessage(UI_REQUEST.DEVICE_PROGRESS, {
47712
- progress: getConfirmedProgress(confirmedProcessedByte, totalSize, written, dataLength),
47713
- transferredBytes,
47714
- totalBytes: dataLength,
47715
- rateBytesPerSecond: elapsedMs > 0 ? Math.round((transferredBytes / elapsedMs) * 1000) : undefined,
47716
- elapsedMs,
47717
- }));
47718
- }
47719
- chunkIndex += 1;
47720
- }
47721
- return Promise.resolve(Object.assign(Object.assign({}, lastMessage), { path: this.params.path, offset: startOffset, total_size: totalSize, processed_byte: startOffset + written, chunks: chunkIndex }));
48063
+ return writeProtocolV2File({
48064
+ commands: this.device.commands,
48065
+ path: this.params.path,
48066
+ data: this.params.data,
48067
+ offset: this.params.offset,
48068
+ totalSize: this.params.totalSize,
48069
+ chunkSize: this.params.chunkSize,
48070
+ chunkLen: this.params.chunkLen,
48071
+ overwrite: this.params.overwrite,
48072
+ append: this.params.append,
48073
+ uiPercentage: this.params.uiPercentage,
48074
+ timeoutMs: this.params.timeoutMs === undefined ? undefined : Number(this.params.timeoutMs),
48075
+ throwIfAborted: () => this.throwIfAborted(),
48076
+ onProgress: payload => {
48077
+ if (typeof this.postMessage === 'function') {
48078
+ this.postMessage(createUiMessage(UI_REQUEST.DEVICE_PROGRESS, payload));
48079
+ }
48080
+ },
48081
+ });
47722
48082
  });
47723
48083
  }
47724
48084
  }
@@ -47818,6 +48178,27 @@ class PathInfo extends BaseMethod {
47818
48178
  }
47819
48179
  }
47820
48180
 
48181
+ const PORTFOLIO_PENDING_PATH = 'vol1:/portfolio/portfolio.pfol.pending';
48182
+ const PORTFOLIO_CHUNK_SIZE = 2048;
48183
+ class UploadPortfolio extends FileWrite {
48184
+ init() {
48185
+ const { packageBytes, timeoutMs } = this.payload;
48186
+ this.payload = Object.assign(Object.assign({}, this.payload), { path: PORTFOLIO_PENDING_PATH, offset: 0, data: packageBytes, chunkSize: PORTFOLIO_CHUNK_SIZE, overwrite: true, append: false, timeoutMs });
48187
+ super.init();
48188
+ }
48189
+ run() {
48190
+ const _super = Object.create(null, {
48191
+ run: { get: () => super.run }
48192
+ });
48193
+ return __awaiter(this, void 0, void 0, function* () {
48194
+ const stagedFile = yield _super.run.call(this);
48195
+ this.throwIfAborted();
48196
+ yield this.device.commands.typedCall('PortfolioUpdate', 'Success', {});
48197
+ return Object.assign(Object.assign({}, stagedFile), { portfolioUpdated: true });
48198
+ });
48199
+ }
48200
+ }
48201
+
47821
48202
  class CipherKeyValue extends BaseMethod {
47822
48203
  constructor() {
47823
48204
  super(...arguments);
@@ -57035,11 +57416,16 @@ var ApiMethods = /*#__PURE__*/Object.freeze({
57035
57416
  deviceReboot: DeviceReboot,
57036
57417
  deviceInfoGet: DeviceInfoGet,
57037
57418
  deviceStatusGet: DeviceStatusGet,
57419
+ deviceGetOnboardingStatus: DeviceGetOnboardingStatus,
57038
57420
  deviceSessionGet: DeviceSessionGet,
57039
57421
  deviceFirmwareUpdate: DeviceFirmwareUpdate,
57040
57422
  deviceGetFirmwareUpdateStatus: DeviceGetFirmwareUpdateStatus,
57041
57423
  deviceFactoryInfoSet: DeviceFactoryInfoSet,
57042
57424
  deviceFactoryInfoGet: DeviceFactoryInfoGet,
57425
+ deviceSettingsGet: DeviceSettingsGet,
57426
+ deviceSettingsSet: DeviceSettingsSet,
57427
+ deviceSettingsPageShow: DeviceSettingsPageShow,
57428
+ deviceUploadWallpaper: DeviceUploadWallpaper,
57043
57429
  filesystemPermissionFix: FilesystemPermissionFix,
57044
57430
  filesystemFormat: FilesystemFormat,
57045
57431
  filesystemDiskControl: FilesystemDiskControl,
@@ -57052,6 +57438,7 @@ var ApiMethods = /*#__PURE__*/Object.freeze({
57052
57438
  pathInfo: PathInfo,
57053
57439
  filesystemFileRead: FileRead,
57054
57440
  filesystemFileWrite: FileWrite,
57441
+ uploadPortfolio: UploadPortfolio,
57055
57442
  filesystemFileDelete: FileDelete,
57056
57443
  filesystemDirList: DirList,
57057
57444
  filesystemDirMake: DirMake,
@@ -57167,7 +57554,7 @@ const resolveAfter = (msec, value) => new Promise(resolve => {
57167
57554
  setTimeout(resolve, msec, value);
57168
57555
  });
57169
57556
 
57170
- const Log$2 = getLogger(exports.LoggerNames.DeviceConnector);
57557
+ const Log$3 = getLogger(exports.LoggerNames.DeviceConnector);
57171
57558
  class DeviceConnector {
57172
57559
  constructor() {
57173
57560
  this.listenTimestamp = 0;
@@ -57198,7 +57585,7 @@ class DeviceConnector {
57198
57585
  this.listening = true;
57199
57586
  let descriptors;
57200
57587
  try {
57201
- Log$2.debug('Start listening', current);
57588
+ Log$3.debug('Start listening', current);
57202
57589
  this.listenTimestamp = new Date().getTime();
57203
57590
  descriptors = waitForEvent
57204
57591
  ? yield this.transport.listen(current)
@@ -57206,21 +57593,21 @@ class DeviceConnector {
57206
57593
  if (!this.listening)
57207
57594
  return;
57208
57595
  this.upcoming = descriptors;
57209
- Log$2.debug('Listen result', descriptors);
57596
+ Log$3.debug('Listen result', descriptors);
57210
57597
  this._reportDevicesChange();
57211
57598
  if (this.listening)
57212
57599
  this.listen();
57213
57600
  }
57214
57601
  catch (error) {
57215
57602
  const time = new Date().getTime() - this.listenTimestamp;
57216
- Log$2.debug('Listen error', 'timestamp', time, typeof error);
57603
+ Log$3.debug('Listen error', 'timestamp', time, typeof error);
57217
57604
  if (time > 1100) {
57218
57605
  yield resolveAfter(1000, null);
57219
57606
  if (this.listening)
57220
57607
  this.listen();
57221
57608
  }
57222
57609
  else {
57223
- Log$2.warn('Transport error');
57610
+ Log$3.warn('Transport error');
57224
57611
  }
57225
57612
  }
57226
57613
  });
@@ -57230,7 +57617,7 @@ class DeviceConnector {
57230
57617
  }
57231
57618
  acquire(path, session, forceCleanRunPromise, connectProtocol) {
57232
57619
  return __awaiter(this, void 0, void 0, function* () {
57233
- Log$2.debug('acquire', path, session, connectProtocol);
57620
+ Log$3.debug('acquire', path, session, connectProtocol);
57234
57621
  const env = DataManager.getSettings('env');
57235
57622
  try {
57236
57623
  let res;
@@ -57257,7 +57644,7 @@ class DeviceConnector {
57257
57644
  return res;
57258
57645
  }
57259
57646
  catch (error) {
57260
- Log$2.error('acquire error: ', error.message);
57647
+ Log$3.error('acquire error: ', error.message);
57261
57648
  safeThrowError(error);
57262
57649
  }
57263
57650
  });
@@ -57296,10 +57683,11 @@ class DeviceConnector {
57296
57683
  }
57297
57684
  }
57298
57685
 
57299
- const Log$1 = getLogger(exports.LoggerNames.Core);
57686
+ const Log$2 = getLogger(exports.LoggerNames.Core);
57300
57687
  class RequestQueue {
57301
57688
  constructor() {
57302
57689
  this.requestQueue = new Map();
57690
+ this.operationRequestIds = new Map();
57303
57691
  this.pendingCallbackTasks = new Map();
57304
57692
  this.generateRequestId = (method) => {
57305
57693
  if (method && method.responseID != null) {
@@ -57309,15 +57697,25 @@ class RequestQueue {
57309
57697
  };
57310
57698
  }
57311
57699
  createTask(method) {
57700
+ var _a;
57312
57701
  const requestId = this.generateRequestId(method);
57313
57702
  if (method && method.responseID !== requestId) {
57314
57703
  method.responseID = requestId;
57315
57704
  }
57316
57705
  const abortController = new AbortController();
57706
+ method.abortSignal = abortController.signal;
57317
57707
  const task = { id: requestId, method, abortController };
57318
57708
  this.requestQueue.set(requestId, task);
57709
+ const operationId = (_a = method.payload) === null || _a === void 0 ? void 0 : _a.operationId;
57710
+ if (typeof operationId === 'string' && operationId) {
57711
+ this.operationRequestIds.set(operationId, requestId);
57712
+ }
57319
57713
  return task;
57320
57714
  }
57715
+ abortOperation(operationId) {
57716
+ const requestId = this.operationRequestIds.get(operationId);
57717
+ return requestId === undefined ? false : this.abortRequest(requestId);
57718
+ }
57321
57719
  getTask(requestId) {
57322
57720
  return this.requestQueue.get(requestId);
57323
57721
  }
@@ -57328,7 +57726,7 @@ class RequestQueue {
57328
57726
  abortRequest(requestId) {
57329
57727
  const request = this.requestQueue.get(requestId);
57330
57728
  if (request === null || request === void 0 ? void 0 : request.abortController) {
57331
- Log$1.debug(`Aborting request ${requestId}`);
57729
+ Log$2.debug(`Aborting request ${requestId}`);
57332
57730
  request.abortController.abort();
57333
57731
  return true;
57334
57732
  }
@@ -57375,12 +57773,18 @@ class RequestQueue {
57375
57773
  this.releaseTask(requestId);
57376
57774
  }
57377
57775
  releaseTask(requestId) {
57776
+ var _a, _b;
57777
+ const operationId = (_b = (_a = this.requestQueue.get(requestId)) === null || _a === void 0 ? void 0 : _a.method.payload) === null || _b === void 0 ? void 0 : _b.operationId;
57778
+ if (typeof operationId === 'string' &&
57779
+ this.operationRequestIds.get(operationId) === requestId) {
57780
+ this.operationRequestIds.delete(operationId);
57781
+ }
57378
57782
  this.requestQueue.delete(requestId);
57379
57783
  }
57380
57784
  registerPendingCallbackTask(connectId, callbackPromise) {
57381
57785
  this.pendingCallbackTasks.set(connectId, callbackPromise);
57382
57786
  callbackPromise.promise.finally(() => {
57383
- Log$1.debug(`Callback task completed for connectId: ${connectId}`);
57787
+ Log$2.debug(`Callback task completed for connectId: ${connectId}`);
57384
57788
  if (this.pendingCallbackTasks.get(connectId) === callbackPromise) {
57385
57789
  this.pendingCallbackTasks.delete(connectId);
57386
57790
  }
@@ -57390,7 +57794,7 @@ class RequestQueue {
57390
57794
  return __awaiter(this, void 0, void 0, function* () {
57391
57795
  const pendingTask = this.pendingCallbackTasks.get(connectId);
57392
57796
  if (pendingTask && pendingTask !== exceptTask) {
57393
- Log$1.debug(`Waiting for pending callback task to complete for connectId: ${connectId}`);
57797
+ Log$2.debug(`Waiting for pending callback task to complete for connectId: ${connectId}`);
57394
57798
  yield pendingTask.promise;
57395
57799
  }
57396
57800
  });
@@ -57425,6 +57829,40 @@ const getSynchronize = (mutex) => {
57425
57829
  return (action, lockId) => lock(lockId).then(unlock => Promise.resolve().then(action).finally(unlock));
57426
57830
  };
57427
57831
 
57832
+ const Log$1 = getLogger(exports.LoggerNames.Core);
57833
+ function isDeviceLockedError(error) {
57834
+ return (typeof error === 'object' &&
57835
+ error !== null &&
57836
+ 'errorCode' in error &&
57837
+ error.errorCode === hdShared.HardwareErrorCode.DeviceLocked);
57838
+ }
57839
+ function runMethodWithUnlockRetry(method, device) {
57840
+ return __awaiter(this, void 0, void 0, function* () {
57841
+ try {
57842
+ return yield method.run();
57843
+ }
57844
+ catch (error) {
57845
+ if (!device.isProtocolV2() ||
57846
+ method.unlockPolicy !== 'retry-on-locked' ||
57847
+ !isDeviceLockedError(error)) {
57848
+ throw error;
57849
+ }
57850
+ Log$1.debug('Protocol V2 unlock retry triggered', { method: method.name });
57851
+ yield device.unlockDevice();
57852
+ Log$1.debug('Protocol V2 unlock completed', { method: method.name });
57853
+ try {
57854
+ const response = yield method.run();
57855
+ Log$1.debug('Protocol V2 method retry completed', { method: method.name, success: true });
57856
+ return response;
57857
+ }
57858
+ catch (retryError) {
57859
+ Log$1.debug('Protocol V2 method retry completed', { method: method.name, success: false });
57860
+ throw retryError;
57861
+ }
57862
+ }
57863
+ });
57864
+ }
57865
+
57428
57866
  const Log = getLogger(exports.LoggerNames.Core);
57429
57867
  const PRE_INITIALIZE_TTL_MS = 60 * 1000;
57430
57868
  const preWarmInflight = new Map();
@@ -57776,7 +58214,7 @@ const onCallDevice = (context, message, method) => __awaiter(void 0, void 0, voi
57776
58214
  }
57777
58215
  (_p = (_o = method.device) === null || _o === void 0 ? void 0 : _o.commands) === null || _p === void 0 ? void 0 : _p.checkDisposed();
57778
58216
  try {
57779
- const response = yield method.run();
58217
+ const response = yield runMethodWithUnlockRetry(method, device);
57780
58218
  messageResponse = createResponseMessage(method.responseID, true, response);
57781
58219
  requestQueue.resolveRequest(method.responseID, messageResponse);
57782
58220
  completeMethodRequestContext(method);
@@ -58310,6 +58748,9 @@ class Core extends events.exports {
58310
58748
  this.sdkInstanceId = this.tracingContext.sdkInstanceId;
58311
58749
  Log.debug(`[Core] Created SDK instance: ${this.sdkInstanceId}`);
58312
58750
  }
58751
+ cancelOperation(operationId) {
58752
+ this.requestQueue.abortOperation(operationId);
58753
+ }
58313
58754
  getCoreContext() {
58314
58755
  return {
58315
58756
  sdkInstanceId: this.sdkInstanceId,
@@ -58367,6 +58808,10 @@ class Core extends events.exports {
58367
58808
  cancel(this.getCoreContext(), message.payload.connectId);
58368
58809
  break;
58369
58810
  }
58811
+ case IFRAME.CANCEL_OPERATION: {
58812
+ this.cancelOperation(message.payload.operationId);
58813
+ break;
58814
+ }
58370
58815
  case IFRAME.CALLBACK: {
58371
58816
  Log.log('callback message: ', message);
58372
58817
  postMessage(message);
@@ -58428,17 +58873,18 @@ const switchTransport = ({ env, Transport, plugin, }) => {
58428
58873
  initConnector();
58429
58874
  };
58430
58875
 
58431
- const HardwareSdk = ({ init, call, dispose, eventEmitter, uiResponse, cancel, updateSettings, switchTransport, }) => inject({
58876
+ const HardwareSdk = ({ init, call, dispose, eventEmitter, uiResponse, cancel, cancelOperation, updateSettings, switchTransport, }) => inject({
58432
58877
  init,
58433
58878
  call,
58434
58879
  dispose,
58435
58880
  eventEmitter,
58436
58881
  uiResponse,
58437
58882
  cancel,
58883
+ cancelOperation,
58438
58884
  updateSettings,
58439
58885
  switchTransport,
58440
58886
  });
58441
- const HardwareSDKLowLevel = ({ init, call, dispose, eventEmitter, addHardwareGlobalEventListener, uiResponse, cancel, updateSettings, switchTransport, }) => lowLevelInject({
58887
+ const HardwareSDKLowLevel = ({ init, call, dispose, eventEmitter, addHardwareGlobalEventListener, uiResponse, cancel, cancelOperation, updateSettings, switchTransport, }) => lowLevelInject({
58442
58888
  init,
58443
58889
  call,
58444
58890
  dispose,
@@ -58446,6 +58892,7 @@ const HardwareSDKLowLevel = ({ init, call, dispose, eventEmitter, addHardwareGlo
58446
58892
  addHardwareGlobalEventListener,
58447
58893
  uiResponse,
58448
58894
  cancel,
58895
+ cancelOperation,
58449
58896
  updateSettings,
58450
58897
  switchTransport,
58451
58898
  });
@@ -58483,6 +58930,8 @@ exports.IFRAME = IFRAME;
58483
58930
  exports.LOG = LOG;
58484
58931
  exports.LOG_EVENT = LOG_EVENT;
58485
58932
  exports.LogBlockEvent = LogBlockEvent;
58933
+ exports.PRO2_WALLPAPER_HEIGHT = PRO2_WALLPAPER_HEIGHT;
58934
+ exports.PRO2_WALLPAPER_WIDTH = PRO2_WALLPAPER_WIDTH;
58486
58935
  exports.RESPONSE_EVENT = RESPONSE_EVENT;
58487
58936
  exports.UI_EVENT = UI_EVENT;
58488
58937
  exports.UI_REQUEST = UI_REQUEST;
@@ -58505,6 +58954,7 @@ exports.createUiMessage = createUiMessage;
58505
58954
  exports.createUiResponse = createUiResponse;
58506
58955
  exports["default"] = HardwareSdk;
58507
58956
  exports.enableLog = enableLog;
58957
+ exports.encodePro2Wallpaper = encodePro2Wallpaper;
58508
58958
  exports.executeCallback = executeCallback;
58509
58959
  exports.formatRequestContext = formatRequestContext;
58510
58960
  exports.generateInstanceId = generateInstanceId;