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

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