@onekeyfe/hd-core 1.2.0-alpha.66 → 1.2.0-alpha.67

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 (315) hide show
  1. package/__tests__/AllNetworkGetAddressBase.tracing.test.ts +0 -313
  2. package/__tests__/DeviceCommands.test.ts +13 -59
  3. package/__tests__/DeviceEventRegistration.test.ts +0 -6
  4. package/__tests__/check-all-firmware-release-protocol-v2.test.ts +3 -198
  5. package/__tests__/connectSettings.test.ts +47 -5
  6. package/__tests__/device-initialize-timeout.test.ts +56 -0
  7. package/__tests__/device-lifecycle-events.test.ts +3 -105
  8. package/__tests__/device-pool-state.test.ts +0 -22
  9. package/__tests__/device-settings.test.ts +18 -39
  10. package/__tests__/device-state-contract.test.ts +0 -1
  11. package/__tests__/device-state-mapper.test.ts +1 -13
  12. package/__tests__/device-utils.test.ts +1 -48
  13. package/__tests__/deviceSettings.test.ts +1 -11
  14. package/__tests__/firmware-update/check-all-firmware-release.test.ts +175 -0
  15. package/__tests__/firmware-update/device-update-bootloader.test.ts +87 -0
  16. package/__tests__/firmware-update/firmware-artifact-source.test.ts +119 -0
  17. package/__tests__/firmware-update/firmware-host-binding.test.ts +70 -0
  18. package/__tests__/firmware-update/firmware-preparation-error.test.ts +27 -0
  19. package/__tests__/firmware-update/firmware-update-bootloader-poll.test.ts +200 -0
  20. package/__tests__/firmware-update/firmware-update-capabilities.test.ts +13 -0
  21. package/__tests__/firmware-update/firmware-update-plan-bootloader-identity.test.ts +394 -0
  22. package/__tests__/firmware-update/firmware-update-plan.test.ts +593 -0
  23. package/__tests__/firmware-update/firmware-update-prepared-plan.test.ts +231 -0
  24. package/__tests__/firmware-update/firmware-update-v2-download-before-boot.test.ts +59 -31
  25. package/__tests__/firmware-update/firmware-update-v3-reconnect.test.ts +58 -0
  26. package/__tests__/firmware-update/firmware-upload-source.test.ts +70 -0
  27. package/__tests__/get-device-state.test.ts +12 -132
  28. package/__tests__/homescreen.test.ts +1 -41
  29. package/__tests__/kaspa-use-tweak-pro2.test.ts +2 -2
  30. package/__tests__/kaspaSignTransaction.test.ts +26 -3
  31. package/__tests__/logBlockEvent.test.ts +1 -1
  32. package/__tests__/method-protocol-support.test.ts +0 -19
  33. package/__tests__/open-wallet-session.test.ts +37 -568
  34. package/__tests__/protocol-v2-unlock-policy.test.ts +37 -300
  35. package/__tests__/protocol-v2.test.ts +1153 -1458
  36. package/__tests__/protocolV2FileWrite.test.ts +0 -152
  37. package/__tests__/protocolV2UiInteraction.test.ts +0 -63
  38. package/__tests__/public-pro2-api-boundary.test.ts +0 -1
  39. package/__tests__/search-devices.test.ts +3 -12
  40. package/__tests__/tron-sign-message-init.test.ts +2 -2
  41. package/dist/api/BaseMethod.d.ts +1 -3
  42. package/dist/api/BaseMethod.d.ts.map +1 -1
  43. package/dist/api/CheckAllFirmwareRelease.d.ts +1 -2
  44. package/dist/api/CheckAllFirmwareRelease.d.ts.map +1 -1
  45. package/dist/api/FirmwareUpdate.d.ts.map +1 -1
  46. package/dist/api/FirmwareUpdateV2.d.ts +10 -0
  47. package/dist/api/FirmwareUpdateV2.d.ts.map +1 -1
  48. package/dist/api/FirmwareUpdateV3.d.ts +7 -3
  49. package/dist/api/FirmwareUpdateV3.d.ts.map +1 -1
  50. package/dist/api/FirmwareUpdateV4.d.ts +27 -13
  51. package/dist/api/FirmwareUpdateV4.d.ts.map +1 -1
  52. package/dist/api/GetPassphraseState.d.ts.map +1 -1
  53. package/dist/api/OpenWalletSession.d.ts.map +1 -1
  54. package/dist/api/SearchDevices.d.ts.map +1 -1
  55. package/dist/api/allnetwork/AllNetworkGetAddressBase.d.ts.map +1 -1
  56. package/dist/api/device/DeviceSettings.d.ts.map +1 -1
  57. package/dist/api/device/DeviceUnlock.d.ts +2 -2
  58. package/dist/api/device/DeviceUnlock.d.ts.map +1 -1
  59. package/dist/api/device/DeviceUpdateBootloader.d.ts +5 -1
  60. package/dist/api/device/DeviceUpdateBootloader.d.ts.map +1 -1
  61. package/dist/api/firmware/FirmwareArtifactSource.d.ts +25 -0
  62. package/dist/api/firmware/FirmwareArtifactSource.d.ts.map +1 -0
  63. package/dist/api/firmware/FirmwareHostBinding.d.ts +6 -0
  64. package/dist/api/firmware/FirmwareHostBinding.d.ts.map +1 -0
  65. package/dist/api/firmware/FirmwarePreparationError.d.ts +3 -0
  66. package/dist/api/firmware/FirmwarePreparationError.d.ts.map +1 -0
  67. package/dist/api/firmware/FirmwareUpdateBaseMethod.d.ts +11 -4
  68. package/dist/api/firmware/FirmwareUpdateBaseMethod.d.ts.map +1 -1
  69. package/dist/api/firmware/FirmwareUpdateCapabilities.d.ts +3 -0
  70. package/dist/api/firmware/FirmwareUpdateCapabilities.d.ts.map +1 -0
  71. package/dist/api/firmware/FirmwareUpdatePlan.d.ts +25 -0
  72. package/dist/api/firmware/FirmwareUpdatePlan.d.ts.map +1 -0
  73. package/dist/api/firmware/FirmwareUpdatePreparedPlan.d.ts +32 -0
  74. package/dist/api/firmware/FirmwareUpdatePreparedPlan.d.ts.map +1 -0
  75. package/dist/api/firmware/getBinary.d.ts +7 -0
  76. package/dist/api/firmware/getBinary.d.ts.map +1 -1
  77. package/dist/api/firmware/progressThrottle.d.ts +3 -0
  78. package/dist/api/firmware/progressThrottle.d.ts.map +1 -0
  79. package/dist/api/firmware/updateBootloader.d.ts +2 -0
  80. package/dist/api/firmware/updateBootloader.d.ts.map +1 -1
  81. package/dist/api/firmware/uploadFirmware.d.ts +9 -1
  82. package/dist/api/firmware/uploadFirmware.d.ts.map +1 -1
  83. package/dist/api/helpers/protocolV2FileWrite.d.ts +0 -9
  84. package/dist/api/helpers/protocolV2FileWrite.d.ts.map +1 -1
  85. package/dist/api/index.d.ts +0 -2
  86. package/dist/api/index.d.ts.map +1 -1
  87. package/dist/api/kaspa/KaspaGetAddress.d.ts +1 -1
  88. package/dist/api/kaspa/KaspaSignTransaction.d.ts +1 -1
  89. package/dist/api/kaspa/KaspaSignTransaction.d.ts.map +1 -1
  90. package/dist/api/polkadot/PolkadotGetAddress.d.ts +1 -1
  91. package/dist/api/polkadot/networks.d.ts +1 -1
  92. package/dist/api/protocol-v2/ProtocolInfoRequest.d.ts.map +1 -1
  93. package/dist/api/protocol-v2/helpers.d.ts.map +1 -1
  94. package/dist/api/solana/SolSignMessage.d.ts +1 -1
  95. package/dist/api/solana/SolSignOffchainMessage.d.ts +1 -1
  96. package/dist/api/solana/SolSignTransaction.d.ts +2 -2
  97. package/dist/api/stellar/StellarSignTransaction.d.ts +1 -1
  98. package/dist/api/sui/SuiGetAddress.d.ts +1 -1
  99. package/dist/api/sui/SuiGetPublicKey.d.ts +1 -1
  100. package/dist/api/sui/SuiSignMessage.d.ts +1 -1
  101. package/dist/api/sui/SuiSignTransaction.d.ts +1 -1
  102. package/dist/api/ton/TonGetAddress.d.ts +1 -1
  103. package/dist/api/ton/TonSignMessage.d.ts +1 -1
  104. package/dist/api/ton/TonSignProof.d.ts +1 -1
  105. package/dist/api/tron/TronSignMessage.d.ts +2 -2
  106. package/dist/api/tron/TronSignTransaction.d.ts +1 -1
  107. package/dist/core/deviceEventRegistration.d.ts +0 -2
  108. package/dist/core/deviceEventRegistration.d.ts.map +1 -1
  109. package/dist/core/index.d.ts.map +1 -1
  110. package/dist/data-manager/DataManager.d.ts +4 -9
  111. package/dist/data-manager/DataManager.d.ts.map +1 -1
  112. package/dist/data-manager/TransportManager.d.ts.map +1 -1
  113. package/dist/data-manager/connectSettings.d.ts.map +1 -1
  114. package/dist/device/Device.d.ts +6 -29
  115. package/dist/device/Device.d.ts.map +1 -1
  116. package/dist/device/DeviceCommands.d.ts +4 -4
  117. package/dist/device/DeviceCommands.d.ts.map +1 -1
  118. package/dist/device/DeviceConnector.d.ts +1 -2
  119. package/dist/device/DeviceConnector.d.ts.map +1 -1
  120. package/dist/device/DevicePool.d.ts.map +1 -1
  121. package/dist/deviceProfile/protocolV2DeviceIdentity.d.ts.map +1 -1
  122. package/dist/events/device.d.ts +0 -4
  123. package/dist/events/device.d.ts.map +1 -1
  124. package/dist/events/logBlockEvent.d.ts.map +1 -1
  125. package/dist/events/ui-promise.d.ts +2 -4
  126. package/dist/events/ui-promise.d.ts.map +1 -1
  127. package/dist/events/ui-request.d.ts +2 -31
  128. package/dist/events/ui-request.d.ts.map +1 -1
  129. package/dist/events/ui-response.d.ts +2 -10
  130. package/dist/events/ui-response.d.ts.map +1 -1
  131. package/dist/index.d.ts +247 -243
  132. package/dist/index.d.ts.map +1 -1
  133. package/dist/index.js +3773 -3054
  134. package/dist/inject.d.ts +1 -6
  135. package/dist/inject.d.ts.map +1 -1
  136. package/dist/lowLevelInject.d.ts.map +1 -1
  137. package/dist/protocols/protocol-v2/features.d.ts +4 -0
  138. package/dist/protocols/protocol-v2/features.d.ts.map +1 -1
  139. package/dist/protocols/protocol-v2/firmware.d.ts.map +1 -1
  140. package/dist/protocols/protocol-v2/lockedError.d.ts +2 -0
  141. package/dist/protocols/protocol-v2/lockedError.d.ts.map +1 -0
  142. package/dist/protocols/protocol-v2/uiInteraction.d.ts +4 -7
  143. package/dist/protocols/protocol-v2/uiInteraction.d.ts.map +1 -1
  144. package/dist/protocols/protocol-v2/unlockPolicy.d.ts +3 -1
  145. package/dist/protocols/protocol-v2/unlockPolicy.d.ts.map +1 -1
  146. package/dist/protocols/protocol-v2/unlockRetry.d.ts +10 -0
  147. package/dist/protocols/protocol-v2/unlockRetry.d.ts.map +1 -0
  148. package/dist/protocols/protocol-v2/walletSession.d.ts +1 -6
  149. package/dist/protocols/protocol-v2/walletSession.d.ts.map +1 -1
  150. package/dist/topLevelInject.d.ts.map +1 -1
  151. package/dist/types/api/checkAllFirmwareRelease.d.ts +5 -3
  152. package/dist/types/api/checkAllFirmwareRelease.d.ts.map +1 -1
  153. package/dist/types/api/deviceUnlock.d.ts +1 -5
  154. package/dist/types/api/deviceUnlock.d.ts.map +1 -1
  155. package/dist/types/api/deviceUpdateBootloader.d.ts +6 -0
  156. package/dist/types/api/deviceUpdateBootloader.d.ts.map +1 -1
  157. package/dist/types/api/export.d.ts +4 -2
  158. package/dist/types/api/export.d.ts.map +1 -1
  159. package/dist/types/api/firmwareUpdate.d.ts +70 -4
  160. package/dist/types/api/firmwareUpdate.d.ts.map +1 -1
  161. package/dist/types/api/firmwareUpdateCapabilities.d.ts +9 -0
  162. package/dist/types/api/firmwareUpdateCapabilities.d.ts.map +1 -0
  163. package/dist/types/api/firmwareUpdatePlan.d.ts +28 -0
  164. package/dist/types/api/firmwareUpdatePlan.d.ts.map +1 -0
  165. package/dist/types/api/firmwareUpdatePreparedPlan.d.ts +42 -0
  166. package/dist/types/api/firmwareUpdatePreparedPlan.d.ts.map +1 -0
  167. package/dist/types/api/index.d.ts +10 -7
  168. package/dist/types/api/index.d.ts.map +1 -1
  169. package/dist/types/api/protocolV2.d.ts +0 -3
  170. package/dist/types/api/protocolV2.d.ts.map +1 -1
  171. package/dist/types/device.d.ts +2 -2
  172. package/dist/types/device.d.ts.map +1 -1
  173. package/dist/types/params.d.ts +0 -1
  174. package/dist/types/params.d.ts.map +1 -1
  175. package/dist/types/settings.d.ts +21 -38
  176. package/dist/types/settings.d.ts.map +1 -1
  177. package/dist/utils/deviceFeaturesCompat.d.ts +1 -0
  178. package/dist/utils/deviceFeaturesCompat.d.ts.map +1 -1
  179. package/dist/utils/deviceFeaturesUtils.d.ts +0 -4
  180. package/dist/utils/deviceFeaturesUtils.d.ts.map +1 -1
  181. package/dist/utils/deviceInfoUtils.d.ts.map +1 -1
  182. package/dist/utils/deviceSettings.d.ts.map +1 -1
  183. package/dist/utils/homescreen.d.ts +0 -4
  184. package/dist/utils/homescreen.d.ts.map +1 -1
  185. package/dist/utils/index.d.ts +1 -1
  186. package/dist/utils/index.d.ts.map +1 -1
  187. package/dist/utils/patch.d.ts +1 -1
  188. package/dist/utils/patch.d.ts.map +1 -1
  189. package/dist/utils/pro2Wallpaper.d.ts +0 -10
  190. package/dist/utils/pro2Wallpaper.d.ts.map +1 -1
  191. package/package.json +4 -4
  192. package/src/api/BaseMethod.ts +10 -8
  193. package/src/api/CheckAllFirmwareRelease.ts +60 -59
  194. package/src/api/FirmwareUpdate.ts +15 -7
  195. package/src/api/FirmwareUpdateV2.ts +298 -126
  196. package/src/api/FirmwareUpdateV3.ts +265 -63
  197. package/src/api/FirmwareUpdateV4.ts +1017 -602
  198. package/src/api/GetPassphraseState.ts +1 -7
  199. package/src/api/OpenWalletSession.ts +17 -71
  200. package/src/api/SearchDevices.ts +1 -3
  201. package/src/api/allnetwork/AllNetworkGetAddress.ts +21 -21
  202. package/src/api/allnetwork/AllNetworkGetAddressBase.ts +11 -36
  203. package/src/api/device/DeviceSettings.ts +4 -5
  204. package/src/api/device/DeviceUnlock.ts +3 -8
  205. package/src/api/device/DeviceUpdateBootloader.ts +125 -6
  206. package/src/api/firmware/FirmwareArtifactSource.ts +278 -0
  207. package/src/api/firmware/FirmwareHostBinding.ts +100 -0
  208. package/src/api/firmware/FirmwarePreparationError.ts +12 -0
  209. package/src/api/firmware/FirmwareUpdateBaseMethod.ts +83 -27
  210. package/src/api/firmware/FirmwareUpdateCapabilities.ts +9 -0
  211. package/src/api/firmware/FirmwareUpdatePlan.ts +772 -0
  212. package/src/api/firmware/FirmwareUpdatePreparedPlan.ts +449 -0
  213. package/src/api/firmware/progressThrottle.ts +44 -0
  214. package/src/api/firmware/updateBootloader.ts +19 -4
  215. package/src/api/firmware/uploadFirmware.ts +144 -39
  216. package/src/api/helpers/protocolV2FileWrite.ts +63 -202
  217. package/src/api/index.ts +0 -2
  218. package/src/api/kaspa/KaspaGetAddress.ts +1 -1
  219. package/src/api/kaspa/KaspaSignTransaction.ts +13 -2
  220. package/src/api/polkadot/networks.ts +3 -3
  221. package/src/api/protocol-v2/ProtocolInfoRequest.ts +1 -3
  222. package/src/api/protocol-v2/helpers.ts +1 -1
  223. package/src/api/solana/SolSignMessage.ts +1 -1
  224. package/src/api/solana/SolSignOffchainMessage.ts +1 -1
  225. package/src/api/solana/SolSignTransaction.ts +2 -2
  226. package/src/api/sui/SuiGetAddress.ts +1 -1
  227. package/src/api/sui/SuiGetPublicKey.ts +1 -1
  228. package/src/api/sui/SuiSignMessage.ts +1 -1
  229. package/src/api/sui/SuiSignTransaction.ts +1 -1
  230. package/src/api/ton/TonGetAddress.ts +1 -1
  231. package/src/api/ton/TonSignMessage.ts +1 -1
  232. package/src/api/ton/TonSignProof.ts +1 -1
  233. package/src/api/tron/TronSignMessage.ts +2 -2
  234. package/src/api/tron/TronSignTransaction.ts +1 -1
  235. package/src/core/deviceEventRegistration.ts +0 -4
  236. package/src/core/index.ts +111 -213
  237. package/src/data/messages/messages-protocol-v2.json +0 -25
  238. package/src/data-manager/DataManager.ts +41 -113
  239. package/src/data-manager/TransportManager.ts +0 -6
  240. package/src/data-manager/connectSettings.ts +11 -0
  241. package/src/device/Device.ts +49 -274
  242. package/src/device/DeviceCommands.ts +4 -31
  243. package/src/device/DeviceConnector.ts +13 -33
  244. package/src/device/DevicePool.ts +7 -21
  245. package/src/deviceProfile/buildDeviceFeatures.ts +2 -2
  246. package/src/deviceProfile/protocolV2DeviceIdentity.ts +0 -3
  247. package/src/events/device.ts +0 -4
  248. package/src/events/logBlockEvent.ts +0 -1
  249. package/src/events/ui-promise.ts +2 -4
  250. package/src/events/ui-request.ts +2 -36
  251. package/src/events/ui-response.ts +2 -12
  252. package/src/index.ts +5 -0
  253. package/src/inject.ts +24 -60
  254. package/src/lowLevelInject.ts +8 -7
  255. package/src/protocols/protocol-v2/features.ts +7 -10
  256. package/src/protocols/protocol-v2/firmware.ts +0 -2
  257. package/src/protocols/protocol-v2/lockedError.ts +10 -0
  258. package/src/protocols/protocol-v2/uiInteraction.ts +6 -46
  259. package/src/protocols/protocol-v2/unlockPolicy.ts +105 -1
  260. package/src/protocols/protocol-v2/unlockRetry.ts +109 -0
  261. package/src/protocols/protocol-v2/walletSession.ts +36 -214
  262. package/src/topLevelInject.ts +8 -7
  263. package/src/types/api/checkAllFirmwareRelease.ts +5 -3
  264. package/src/types/api/deviceUnlock.ts +1 -12
  265. package/src/types/api/deviceUpdateBootloader.ts +6 -0
  266. package/src/types/api/export.ts +18 -1
  267. package/src/types/api/firmwareUpdate.ts +78 -6
  268. package/src/types/api/firmwareUpdateCapabilities.ts +9 -0
  269. package/src/types/api/firmwareUpdatePlan.ts +38 -0
  270. package/src/types/api/firmwareUpdatePreparedPlan.ts +53 -0
  271. package/src/types/api/index.ts +14 -13
  272. package/src/types/api/protocolV2.ts +0 -13
  273. package/src/types/device.ts +3 -15
  274. package/src/types/params.ts +1 -7
  275. package/src/types/settings.ts +22 -60
  276. package/src/utils/deviceFeaturesCompat.ts +6 -5
  277. package/src/utils/deviceFeaturesUtils.ts +3 -14
  278. package/src/utils/deviceInfoUtils.ts +0 -2
  279. package/src/utils/deviceSettings.ts +0 -3
  280. package/src/utils/homescreen.ts +6 -32
  281. package/src/utils/index.ts +1 -6
  282. package/src/utils/pro2Wallpaper.ts +8 -35
  283. package/__tests__/core-initialization.test.ts +0 -23
  284. package/__tests__/device-connector-protocol.test.ts +0 -81
  285. package/__tests__/deviceUploadNft.test.ts +0 -316
  286. package/__tests__/pro2Nft.test.ts +0 -108
  287. package/__tests__/protocol-binding.test.ts +0 -89
  288. package/__tests__/protocol-v2-resources.test.ts +0 -340
  289. package/__tests__/protocol-v2-ui-lifecycle.test.ts +0 -91
  290. package/__tests__/uiProgressThrottle.test.ts +0 -74
  291. package/__tests__/uiPromiseRegistry.test.ts +0 -115
  292. package/dist/api/DetectDeviceConnectProtocol.d.ts +0 -7
  293. package/dist/api/DetectDeviceConnectProtocol.d.ts.map +0 -1
  294. package/dist/api/protocol-v2/DeviceUploadNft.d.ts +0 -31
  295. package/dist/api/protocol-v2/DeviceUploadNft.d.ts.map +0 -1
  296. package/dist/core/uiPromiseRegistry.d.ts +0 -6
  297. package/dist/core/uiPromiseRegistry.d.ts.map +0 -1
  298. package/dist/protocols/protocol-v2/resources.d.ts +0 -30
  299. package/dist/protocols/protocol-v2/resources.d.ts.map +0 -1
  300. package/dist/protocols/protocol-v2/unlockPolicyRunner.d.ts +0 -22
  301. package/dist/protocols/protocol-v2/unlockPolicyRunner.d.ts.map +0 -1
  302. package/dist/types/api/detectDeviceConnectProtocol.d.ts +0 -4
  303. package/dist/types/api/detectDeviceConnectProtocol.d.ts.map +0 -1
  304. package/dist/utils/pro2Nft.d.ts +0 -31
  305. package/dist/utils/pro2Nft.d.ts.map +0 -1
  306. package/dist/utils/uiProgressThrottle.d.ts +0 -3
  307. package/dist/utils/uiProgressThrottle.d.ts.map +0 -1
  308. package/src/api/DetectDeviceConnectProtocol.ts +0 -18
  309. package/src/api/protocol-v2/DeviceUploadNft.ts +0 -197
  310. package/src/core/uiPromiseRegistry.ts +0 -63
  311. package/src/protocols/protocol-v2/resources.ts +0 -390
  312. package/src/protocols/protocol-v2/unlockPolicyRunner.ts +0 -131
  313. package/src/types/api/detectDeviceConnectProtocol.ts +0 -6
  314. package/src/utils/pro2Nft.ts +0 -142
  315. package/src/utils/uiProgressThrottle.ts +0 -63
@@ -14,7 +14,7 @@ import type { OneKeyDeviceInfo as DeviceDescriptor, Transport } from '@onekeyfe/
14
14
  const Log = getLogger(LoggerNames.DeviceConnector);
15
15
 
16
16
  export default class DeviceConnector {
17
- transport?: Transport;
17
+ transport: Transport;
18
18
 
19
19
  listenTimestamp = 0;
20
20
 
@@ -30,21 +30,9 @@ export default class DeviceConnector {
30
30
  DevicePool.setConnector(this);
31
31
  }
32
32
 
33
- private getActiveTransport(): Transport {
34
- const transport = this.transport ?? TransportManager.getTransport();
35
- if (!transport) {
36
- throw ERRORS.TypedError(
37
- HardwareErrorCode.TransportNotConfigured,
38
- 'Device connector was created before transport initialization'
39
- );
40
- }
41
- this.transport = transport;
42
- return transport;
43
- }
44
-
45
33
  async enumerate() {
46
34
  try {
47
- const descriptors = await this.getActiveTransport().enumerate();
35
+ const descriptors = await this.transport.enumerate();
48
36
  this.upcoming = descriptors;
49
37
  this._reportDevicesChange();
50
38
  return { descriptors } as DeviceDescriptorDiff;
@@ -62,10 +50,11 @@ export default class DeviceConnector {
62
50
  let descriptors: DeviceDescriptor[];
63
51
 
64
52
  try {
65
- const transport = this.getActiveTransport();
66
53
  Log.debug('Start listening', current);
67
54
  this.listenTimestamp = new Date().getTime();
68
- descriptors = waitForEvent ? await transport.listen(current) : await transport.enumerate();
55
+ descriptors = waitForEvent
56
+ ? await this.transport.listen(current)
57
+ : await this.transport.enumerate();
69
58
  if (!this.listening) return; // do not continue if stop() was called
70
59
 
71
60
  this.upcoming = descriptors;
@@ -99,17 +88,16 @@ export default class DeviceConnector {
99
88
  Log.debug('acquire', path, session, expectedProtocol, protocolHint);
100
89
  const env = DataManager.getSettings('env');
101
90
  try {
102
- const transport = this.getActiveTransport();
103
91
  let res;
104
92
  if (DataManager.isBleConnect(env)) {
105
- res = await transport.acquire({
93
+ res = await this.transport.acquire({
106
94
  uuid: path,
107
95
  forceCleanRunPromise,
108
96
  expectedProtocol,
109
97
  protocolHint,
110
98
  });
111
99
  } else {
112
- res = await transport.acquire({
100
+ res = await this.transport.acquire({
113
101
  path,
114
102
  previous: session ?? null,
115
103
  expectedProtocol,
@@ -117,13 +105,7 @@ export default class DeviceConnector {
117
105
  });
118
106
  }
119
107
  if (expectedProtocol) {
120
- // The acquire response is the stable snapshot from this active probe. A delayed
121
- // disconnect from an older generation may clear caches, so do not rely on cache alone.
122
- const acquiredProtocol =
123
- typeof res === 'object' && res !== null
124
- ? (res as DeviceDescriptor).protocolType
125
- : undefined;
126
- const detectedProtocol = acquiredProtocol ?? transport.getProtocolType(path);
108
+ const detectedProtocol = this.transport.getProtocolType(path);
127
109
  if (detectedProtocol !== expectedProtocol) {
128
110
  throw ERRORS.TypedError(
129
111
  HardwareErrorCode.RuntimeError,
@@ -140,7 +122,7 @@ export default class DeviceConnector {
140
122
 
141
123
  async release(session: string, onclose: boolean) {
142
124
  try {
143
- const res = await this.getActiveTransport().release(session, onclose);
125
+ const res = await this.transport.release(session, onclose);
144
126
  return res;
145
127
  } catch (error) {
146
128
  safeThrowError(error);
@@ -149,9 +131,8 @@ export default class DeviceConnector {
149
131
 
150
132
  async disconnect(session: string | undefined | null) {
151
133
  try {
152
- const transport = this.getActiveTransport();
153
- if (transport.disconnect && !!session) {
154
- await transport.disconnect(session);
134
+ if (this.transport.disconnect && !!session) {
135
+ await this.transport.disconnect(session);
155
136
  }
156
137
  } catch (error) {
157
138
  safeThrowError(error);
@@ -159,11 +140,10 @@ export default class DeviceConnector {
159
140
  }
160
141
 
161
142
  promptDeviceAccess(): Promise<USBDevice | BluetoothDevice | null> {
162
- const transport = this.getActiveTransport();
163
- if (!transport.promptDeviceAccess) {
143
+ if (!this.transport.promptDeviceAccess) {
164
144
  return Promise.resolve(null);
165
145
  }
166
- return transport.promptDeviceAccess();
146
+ return this.transport.promptDeviceAccess();
167
147
  }
168
148
 
169
149
  _reportDevicesChange() {
@@ -103,7 +103,7 @@ export class DevicePool extends EventEmitter {
103
103
  const device = this.devicesCache[connectId];
104
104
  if (device) {
105
105
  const exist = descriptorList.find(d => d.path === device.originalDescriptor.path);
106
- if (exist && !initOptions?.forceProtocolDetection) {
106
+ if (exist) {
107
107
  // Log.debug('find existed Device: ', connectId);
108
108
  device.updateDescriptor(exist, true);
109
109
  await this._refreshRuntimeState(device, initOptions);
@@ -151,23 +151,12 @@ export class DevicePool extends EventEmitter {
151
151
  }
152
152
  }
153
153
 
154
- static async _createDevice(
155
- descriptor: DeviceDescriptor,
156
- initOptions?: InitOptions
157
- ): Promise<Device> {
158
- const cachedDevice = this.getDeviceByPath(descriptor.path);
159
- const forceProtocolDetection = initOptions?.forceProtocolDetection === true;
160
- const isNewDevice = !cachedDevice;
161
- const device = cachedDevice ?? Device.fromDescriptor(descriptor);
162
- if (isNewDevice || forceProtocolDetection) {
154
+ static async _createDevice(descriptor: DeviceDescriptor, initOptions?: InitOptions) {
155
+ let device = this.getDeviceByPath(descriptor.path);
156
+ if (!device) {
157
+ device = Device.fromDescriptor(descriptor);
163
158
  device.deviceConnector = this.connector;
164
- if (forceProtocolDetection && !isNewDevice) {
165
- await device.acquire(initOptions?.connectProtocol, { forceProtocolDetection: true });
166
- } else {
167
- await device.connect(initOptions?.connectProtocol, {
168
- forceProtocolDetection: initOptions?.forceProtocolDetection,
169
- });
170
- }
159
+ await device.connect(initOptions?.connectProtocol);
171
160
  try {
172
161
  await device.initialize(initOptions);
173
162
  if (initOptions?.refreshRuntimeState && device.isProtocolV2()) {
@@ -192,10 +181,7 @@ export class DevicePool extends EventEmitter {
192
181
  refreshError = error;
193
182
  }
194
183
  },
195
- {
196
- connectProtocol: initOptions.connectProtocol,
197
- forceProtocolDetection: initOptions.forceProtocolDetection,
198
- }
184
+ { connectProtocol: initOptions.connectProtocol }
199
185
  );
200
186
  if (refreshError instanceof Error) throw refreshError;
201
187
  if (refreshError) throw new Error(String(refreshError));
@@ -1,4 +1,4 @@
1
- import { EDeviceType, EFirmwareType } from '@onekeyfe/hd-shared';
1
+ import { EFirmwareType } from '@onekeyfe/hd-shared';
2
2
 
3
3
  import {
4
4
  resolveDeviceBleFirmwareVersion,
@@ -386,7 +386,7 @@ export const buildProtocolV2FeaturesPayload = ({
386
386
  device_id: deviceId ?? undefined,
387
387
  session_id: cached?.sessionId ?? undefined,
388
388
  ble_name: bleName ?? undefined,
389
- onekey_device_type: deviceType === EDeviceType.Unknown ? undefined : deviceType.toUpperCase(),
389
+ onekey_device_type: 'PRO2',
390
390
  passphrase_protection: passphraseProtection ?? undefined,
391
391
  bootloader_mode: bootloaderMode,
392
392
  passphraseState: cached?.passphraseState,
@@ -26,9 +26,6 @@ export const resolveProtocolV2DeviceIdentity = (
26
26
  case DeviceType.PRO2:
27
27
  case 'PRO2':
28
28
  return { deviceType: EDeviceType.Pro2, model: 'pro2' };
29
- case DeviceType.NEO:
30
- case 'NEO':
31
- return { deviceType: EDeviceType.Neo, model: 'neo' };
32
29
  default:
33
30
  return { deviceType: EDeviceType.Unknown, model: null };
34
31
  }
@@ -1,5 +1,4 @@
1
1
  import type { MessageFactoryFn } from './utils';
2
- import type { HardwareUiInteractionMeta } from './ui-request';
3
2
  import type { PROTO } from '../constants';
4
3
  import type {
5
4
  KnownDevice as Device,
@@ -27,8 +26,6 @@ export const DEVICE = {
27
26
  // onekey-transport events in protobuf format
28
27
  BUTTON: 'button',
29
28
  PIN: 'pin',
30
- PIN_ON_DEVICE: 'pin_on_device',
31
- PIN_ON_DEVICE_COMPLETE: 'pin_on_device_complete',
32
29
  PASSPHRASE: 'passphrase',
33
30
  PASSPHRASE_ON_DEVICE: 'passphrase_on_device',
34
31
  ATTACH_PIN_ON_DEVICE: 'attach_pin_on_device',
@@ -61,7 +58,6 @@ export type PassphraseRequestPayload = {
61
58
  source?: 'wallet-session-coordinator';
62
59
  reason?: 'open-wallet' | 'session-recovery';
63
60
  expectedPassphraseState?: string;
64
- interaction?: HardwareUiInteractionMeta;
65
61
  };
66
62
 
67
63
  export interface DeviceButtonRequest {
@@ -10,7 +10,6 @@ export const LogBlockEvent: Set<string> = new Set([
10
10
 
11
11
  const LogLabelMethod: Set<string> = new Set([
12
12
  'openWalletSession',
13
- 'deviceUploadNft',
14
13
  'deviceUploadWallpaper',
15
14
  'uploadPortfolio',
16
15
  'fileWrite',
@@ -1,7 +1,7 @@
1
1
  import type { Deferred } from '@onekeyfe/hd-shared';
2
2
  import type { DEVICE } from './device';
3
3
  import type { Device } from '../device/Device';
4
- import type { UiResponseCorrelation, UiResponseEvent } from './ui-response';
4
+ import type { UiResponseEvent } from './ui-response';
5
5
 
6
6
  export type UiPromiseResponse =
7
7
  | UiResponseEvent
@@ -11,6 +11,4 @@ export type UiPromise<T extends UiPromiseResponse['type']> = Deferred<
11
11
  Extract<UiPromiseResponse, { type: T }>,
12
12
  T,
13
13
  Device
14
- > & {
15
- responseCorrelation?: UiResponseCorrelation;
16
- };
14
+ >;
@@ -1,7 +1,6 @@
1
1
  import type { PROTO } from '../constants';
2
2
  import type { Device } from '../types';
3
3
  import type { DeviceButtonRequest } from './device';
4
- import type { UiResponseCorrelation } from './ui-response';
5
4
  import type { MessageFactoryFn } from './utils';
6
5
 
7
6
  export const UI_EVENT = 'UI_EVENT';
@@ -57,17 +56,6 @@ export type ProtocolV2UiEventSource =
57
56
 
58
57
  export type ProtocolV2UiCompletion = 'page-accepted' | 'operation-completed';
59
58
 
60
- export type HardwareUiInteractionMeta = {
61
- interactionId: string;
62
- phaseId: string;
63
- sequence: number;
64
- phase: 'pin' | 'passphrase' | 'passphrase-on-device' | 'button' | 'processing';
65
- transition: 'start' | 'complete' | 'finish';
66
- outcome?: 'submitted' | 'succeeded' | 'failed' | 'cancelled' | 'disconnected';
67
- protocol: 'V2';
68
- device?: Device;
69
- };
70
-
71
59
  export type ProtocolV2UiEventMetadata = {
72
60
  source?: ProtocolV2UiEventSource;
73
61
  reason?: string;
@@ -76,29 +64,12 @@ export type ProtocolV2UiEventMetadata = {
76
64
  method?: string;
77
65
  page?: string | number;
78
66
  operation?: string;
79
- interaction?: HardwareUiInteractionMeta;
80
67
  };
81
68
 
82
- export type UiRequestWindowClose =
83
- | {
84
- type: typeof UI_REQUEST.CLOSE_UI_WINDOW;
85
- payload: HardwareUiInteractionMeta;
86
- }
87
- | {
88
- type: typeof UI_REQUEST.CLOSE_UI_PIN_WINDOW;
89
- payload: HardwareUiInteractionMeta;
90
- }
91
- | {
92
- type: typeof UI_REQUEST.CLOSE_UI_WINDOW;
93
- payload?: undefined;
94
- }
95
- | {
96
- type: typeof UI_REQUEST.CLOSE_UI_PIN_WINDOW;
97
- payload?: undefined;
98
- };
99
-
100
69
  export interface UiRequestWithoutPayload {
101
70
  type:
71
+ | typeof UI_REQUEST.CLOSE_UI_WINDOW
72
+ | typeof UI_REQUEST.CLOSE_UI_PIN_WINDOW
102
73
  | typeof UI_REQUEST.BLUETOOTH_PERMISSION
103
74
  | typeof UI_REQUEST.BLUETOOTH_UNSUPPORTED
104
75
  | typeof UI_REQUEST.BLUETOOTH_POWERED_OFF
@@ -122,7 +93,6 @@ export type UiRequestDeviceAction = {
122
93
  payload: ProtocolV2UiEventMetadata & {
123
94
  device: Device;
124
95
  type?: PROTO.PinMatrixRequestType | 'ButtonRequest_PinEntry' | 'ButtonRequest_AttachPin';
125
- responseCorrelation?: UiResponseCorrelation;
126
96
  };
127
97
  };
128
98
 
@@ -141,8 +111,6 @@ export interface UiRequestPassphrase {
141
111
  source?: 'wallet-session-coordinator';
142
112
  reason?: 'open-wallet' | 'session-recovery';
143
113
  expectedPassphraseState?: string;
144
- interaction?: HardwareUiInteractionMeta;
145
- responseCorrelation?: UiResponseCorrelation;
146
114
  };
147
115
  }
148
116
 
@@ -153,7 +121,6 @@ export interface UiRequestPassphraseOnDevice {
153
121
  passphraseState?: string;
154
122
  source?: 'wallet-session-coordinator';
155
123
  reason?: 'open-wallet' | 'session-recovery';
156
- interaction?: HardwareUiInteractionMeta;
157
124
  };
158
125
  }
159
126
 
@@ -224,7 +191,6 @@ export interface PreviousAddressResult {
224
191
 
225
192
  export type UiEvent =
226
193
  | UiRequestWithoutPayload
227
- | UiRequestWindowClose
228
194
  | UiRequestDeviceAction
229
195
  | UiRequestButton
230
196
  | UiRequestPassphraseOnDevice
@@ -11,22 +11,12 @@ export const UI_RESPONSE = {
11
11
  'ui-receive_select-device-for-switch-firmware-web-device',
12
12
  } as const;
13
13
 
14
- export interface UiResponseCorrelation {
15
- interactionId: string;
16
- deviceId: string;
17
- }
18
-
19
- export interface UiResponseCorrelationFields {
20
- interactionId?: string;
21
- deviceId?: string;
22
- }
23
-
24
- export interface UiResponsePin extends UiResponseCorrelationFields {
14
+ export interface UiResponsePin {
25
15
  type: typeof UI_RESPONSE.RECEIVE_PIN;
26
16
  payload: string;
27
17
  }
28
18
 
29
- export interface UiResponsePassphrase extends UiResponseCorrelationFields {
19
+ export interface UiResponsePassphrase {
30
20
  type: typeof UI_RESPONSE.RECEIVE_PASSPHRASE;
31
21
  payload: {
32
22
  value: string;
package/src/index.ts CHANGED
@@ -19,6 +19,11 @@ export * from './types';
19
19
  export { whitelist, whitelistExtension } from './data/config';
20
20
  export { executeCallback, cleanupCallback };
21
21
  export { preloadSessionCache } from './device/Device';
22
+ export {
23
+ getFirmwareUpdateHostBindingGeneration,
24
+ registerFirmwareUpdateHostBinding,
25
+ unregisterFirmwareUpdateHostBinding,
26
+ } from './api/firmware/FirmwareHostBinding';
22
27
 
23
28
  const HardwareSdk = ({
24
29
  init,
package/src/inject.ts CHANGED
@@ -1,7 +1,17 @@
1
- import type { HardwareConnectProtocol } from '@onekeyfe/hd-shared';
2
- import type { Unsuccessful } from './types';
1
+ import { getFirmwareUpdateCapabilities } from './api/firmware/FirmwareUpdateCapabilities';
2
+ import {
3
+ prepareFirmwareUpdatePlan,
4
+ validateFirmwareUpdatePreparedPlan,
5
+ } from './api/firmware/FirmwareUpdatePreparedPlan';
6
+ import {
7
+ getFirmwareUpdateHostBindingGeneration,
8
+ registerFirmwareUpdateHostBinding,
9
+ unregisterFirmwareUpdateHostBinding,
10
+ } from './api/firmware/FirmwareHostBinding';
11
+
3
12
  import type { EventEmitter } from 'events';
4
13
  import type { CallMethod } from './events';
14
+ import type { Unsuccessful } from './types';
5
15
  import type { CoreApi } from './types/api';
6
16
  import type { AllNetworkAddress } from './types/api/allNetworkGetAddress';
7
17
 
@@ -40,50 +50,6 @@ export interface InjectApi {
40
50
  switchTransport: CoreApi['switchTransport'];
41
51
  }
42
52
 
43
- const normalizeConnectId = (connectId: string) => connectId.trim().toLowerCase();
44
-
45
- /**
46
- * Keeps verified protocols isolated per transport endpoint and injects them at
47
- * the single public call boundary, including APIs that do not expose params.
48
- */
49
- export const createProtocolAwareCall = (rawCall: CoreApi['call']) => {
50
- const protocolByConnectId = new Map<string, HardwareConnectProtocol>();
51
-
52
- const setDeviceConnectProtocol: CoreApi['setDeviceConnectProtocol'] = (
53
- connectId,
54
- connectProtocol
55
- ) => {
56
- const normalizedConnectId = normalizeConnectId(connectId);
57
- if (!normalizedConnectId) return;
58
- if (connectProtocol) {
59
- protocolByConnectId.set(normalizedConnectId, connectProtocol);
60
- } else {
61
- protocolByConnectId.delete(normalizedConnectId);
62
- }
63
- };
64
-
65
- const call: CoreApi['call'] = params => {
66
- if (!params || typeof params !== 'object') {
67
- return rawCall(params);
68
- }
69
-
70
- const connectId = typeof params.connectId === 'string' ? params.connectId : undefined;
71
- const boundProtocol = connectId
72
- ? protocolByConnectId.get(normalizeConnectId(connectId))
73
- : undefined;
74
- if (
75
- boundProtocol &&
76
- params.connectProtocol === undefined &&
77
- params.forceProtocolDetection !== true
78
- ) {
79
- return rawCall({ ...params, connectProtocol: boundProtocol });
80
- }
81
- return rawCall(params);
82
- };
83
-
84
- return { call, setDeviceConnectProtocol };
85
- };
86
-
87
53
  export const inject = ({
88
54
  call,
89
55
  cancel,
@@ -94,7 +60,6 @@ export const inject = ({
94
60
  switchTransport,
95
61
  uiResponse,
96
62
  }: InjectApi): CoreApi => {
97
- const protocolAwareCall = createProtocolAwareCall(call);
98
63
  const api: CoreApi = {
99
64
  on: <T extends string, P extends (...args: any[]) => any>(type: T, fn: P) => {
100
65
  eventEmitter.on(type, fn);
@@ -112,11 +77,12 @@ export const inject = ({
112
77
 
113
78
  init,
114
79
 
115
- call: protocolAwareCall.call,
80
+ call,
116
81
 
117
- setDeviceConnectProtocol: protocolAwareCall.setDeviceConnectProtocol,
118
-
119
- dispose,
82
+ dispose: async () => {
83
+ unregisterFirmwareUpdateHostBinding();
84
+ await dispose();
85
+ },
120
86
 
121
87
  uiResponse,
122
88
 
@@ -126,7 +92,7 @@ export const inject = ({
126
92
 
127
93
  switchTransport,
128
94
 
129
- ...createCoreApi(protocolAwareCall.call),
95
+ ...createCoreApi(call),
130
96
  };
131
97
  return api;
132
98
  };
@@ -141,25 +107,24 @@ export const createCoreApi = (
141
107
  | 'removeAllListeners'
142
108
  | 'init'
143
109
  | 'call'
144
- | 'setDeviceConnectProtocol'
145
110
  | 'dispose'
146
111
  | 'uiResponse'
147
112
  | 'cancel'
148
113
  | 'updateSettings'
149
114
  | 'switchTransport'
150
115
  > => ({
116
+ getFirmwareUpdateCapabilities,
117
+ registerFirmwareUpdateHostBinding,
118
+ unregisterFirmwareUpdateHostBinding,
119
+ getFirmwareUpdateHostBindingGeneration,
120
+ prepareFirmwareUpdatePlan,
121
+ validateFirmwareUpdatePreparedPlan,
151
122
  getLogs: () => call({ method: 'getLogs' }),
152
123
  clearSessionCache: params => call({ ...params, method: 'clearSessionCache' }),
153
124
  /**
154
125
  * 搜索设备
155
126
  */
156
127
  searchDevices: params => call({ ...params, method: 'searchDevices' }),
157
- detectDeviceConnectProtocol: connectId =>
158
- call({
159
- connectId,
160
- method: 'detectDeviceConnectProtocol',
161
- forceProtocolDetection: true,
162
- }),
163
128
 
164
129
  /**
165
130
  * 获取设备信息
@@ -217,7 +182,6 @@ export const createCoreApi = (
217
182
  call({ ...params, connectId, method: 'deviceGetOnboardingStatus' }),
218
183
  deviceUploadWallpaper: (connectId, params) =>
219
184
  call({ ...params, connectId, method: 'deviceUploadWallpaper' }),
220
- deviceUploadNft: (connectId, params) => call({ ...params, connectId, method: 'deviceUploadNft' }),
221
185
  uploadPortfolio: (connectId, params) => call({ ...params, connectId, method: 'uploadPortfolio' }),
222
186
  deviceRecovery: (connectId, params) => call({ ...params, connectId, method: 'deviceRecovery' }),
223
187
  deviceReset: (connectId, params) => call({ ...params, connectId, method: 'deviceReset' }),
@@ -1,4 +1,5 @@
1
- import { createCoreApi, createProtocolAwareCall } from './inject';
1
+ import { createCoreApi } from './inject';
2
+ import { unregisterFirmwareUpdateHostBinding } from './api/firmware/FirmwareHostBinding';
2
3
 
3
4
  import type { EventEmitter } from 'events';
4
5
  import type { CallMethod, CoreMessage } from './events';
@@ -33,7 +34,6 @@ export const lowLevelInject = ({
33
34
  switchTransport,
34
35
  addHardwareGlobalEventListener,
35
36
  }: LowLevelInjectApi): LowLevelCoreApi => {
36
- const protocolAwareCall = createProtocolAwareCall(call);
37
37
  const api: LowLevelCoreApi = {
38
38
  addHardwareGlobalEventListener,
39
39
  removeAllListeners: type => {
@@ -42,11 +42,12 @@ export const lowLevelInject = ({
42
42
 
43
43
  init,
44
44
 
45
- call: protocolAwareCall.call,
45
+ call,
46
46
 
47
- setDeviceConnectProtocol: protocolAwareCall.setDeviceConnectProtocol,
48
-
49
- dispose,
47
+ dispose: async () => {
48
+ unregisterFirmwareUpdateHostBinding();
49
+ await dispose();
50
+ },
50
51
 
51
52
  uiResponse,
52
53
 
@@ -58,7 +59,7 @@ export const lowLevelInject = ({
58
59
 
59
60
  emit: () => {},
60
61
 
61
- ...createCoreApi(protocolAwareCall.call),
62
+ ...createCoreApi(call),
62
63
  };
63
64
  return api;
64
65
  };
@@ -107,6 +107,10 @@ export const PROTOCOL_V2_FEATURES_DEVICE_INFO_REQUEST = {
107
107
  hw: true,
108
108
  fw: true,
109
109
  coprocessor: true,
110
+ se1: true,
111
+ se2: true,
112
+ se3: true,
113
+ se4: true,
110
114
  },
111
115
  types: {
112
116
  version: true,
@@ -153,7 +157,7 @@ export const PROTOCOL_V2_FULL_DEVICE_INFO_REQUEST = {
153
157
  };
154
158
 
155
159
  export const PROTOCOL_V2_DEVICE_INFO_REQUEST = PROTOCOL_V2_FULL_DEVICE_INFO_REQUEST;
156
- export const PROTOCOL_V2_DEVICE_INFO_TIMEOUT_MS = 30 * 1000;
160
+ export const PROTOCOL_V2_DEVICE_INFO_TIMEOUT_MS = 10 * 1000;
157
161
 
158
162
  export async function requestProtocolV2ProtocolInfo({
159
163
  commands,
@@ -164,15 +168,8 @@ export async function requestProtocolV2ProtocolInfo({
164
168
  }): Promise<ProtocolInfo> {
165
169
  const response =
166
170
  timeoutMs === undefined
167
- ? await commands.typedCall('ProtocolInfoRequest', 'ProtocolInfo', {
168
- eventless_wallet_session: true,
169
- })
170
- : await commands.typedCall(
171
- 'ProtocolInfoRequest',
172
- 'ProtocolInfo',
173
- { eventless_wallet_session: true },
174
- { timeoutMs }
175
- );
171
+ ? await commands.typedCall('ProtocolInfoRequest', 'ProtocolInfo', {})
172
+ : await commands.typedCall('ProtocolInfoRequest', 'ProtocolInfo', {}, { timeoutMs });
176
173
  return response.message;
177
174
  }
178
175
 
@@ -15,7 +15,5 @@ export const ProtocolV2FirmwareTargetType = {
15
15
  FW_MGMT_TARGET_SE04: 10,
16
16
  } as const;
17
17
 
18
- // 这里有意同时导出同名值与类型,以保持现有公共 API 不变。
19
- // eslint-disable-next-line @typescript-eslint/no-redeclare
20
18
  export type ProtocolV2FirmwareTargetType =
21
19
  (typeof ProtocolV2FirmwareTargetType)[keyof typeof ProtocolV2FirmwareTargetType];
@@ -0,0 +1,10 @@
1
+ import { HardwareErrorCode } from '@onekeyfe/hd-shared';
2
+
3
+ export function isDeviceLockedError(error: unknown): boolean {
4
+ return (
5
+ typeof error === 'object' &&
6
+ error !== null &&
7
+ 'errorCode' in error &&
8
+ error.errorCode === HardwareErrorCode.DeviceLocked
9
+ );
10
+ }