@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
@@ -74,9 +74,7 @@ import type { DeviceStateReadOptions } from '../types/api/getDeviceState';
74
74
  import type {
75
75
  DeviceButtonRequestPayload,
76
76
  DeviceFeaturesPayload,
77
- HardwareUiInteractionMeta,
78
77
  PassphraseRequestPayload,
79
- ProtocolV2UiEventMetadata,
80
78
  } from '../events';
81
79
  import type { PassphrasePromptResponse } from './DeviceCommands';
82
80
  import type { Deferred, HardwareConnectProtocol } from '@onekeyfe/hd-shared';
@@ -95,10 +93,14 @@ export type InitOptions = {
95
93
  passphraseState?: string;
96
94
  deriveCardano?: boolean;
97
95
  connectProtocol?: HardwareConnectProtocol;
98
- forceProtocolDetection?: boolean;
99
96
  protocolV2DeviceInfoTimeoutMs?: number;
100
97
  /** Refresh Protocol V2 runtime state before returning discovery results. */
101
98
  refreshRuntimeState?: boolean;
99
+ /**
100
+ * Protocol V1 Initialize response timeout override. Reboot-wait polling passes a
101
+ * short value so an unanswered probe settles before the next poll tick.
102
+ */
103
+ timeoutMs?: number;
102
104
  };
103
105
 
104
106
  export type RunOptions = {
@@ -135,8 +137,6 @@ const isProtocolV2DeviceStatusUnsupportedError = (error: unknown) => {
135
137
 
136
138
  export interface DeviceEvents {
137
139
  [DEVICE.PIN]: [Device, PROTO.PinMatrixRequestType | undefined, (err: any, pin: string) => void];
138
- [DEVICE.PIN_ON_DEVICE]: [Device, DeviceSessionPinType, ProtocolV2UiEventMetadata?];
139
- [DEVICE.PIN_ON_DEVICE_COMPLETE]: [Device, HardwareUiInteractionMeta];
140
140
  [DEVICE.PASSPHRASE_ON_DEVICE]: [Device, PassphraseRequestPayload?];
141
141
  [DEVICE.ATTACH_PIN_ON_DEVICE]: [Device, PassphraseRequestPayload?];
142
142
  [DEVICE.BUTTON]: [Device, DeviceButtonRequestPayload];
@@ -235,24 +235,6 @@ export class Device extends EventEmitter {
235
235
  /** Force the next initialization to reload DeviceInfo after reconnect or reboot. */
236
236
  private protocolV2StateNeedsReload = false;
237
237
 
238
- /** Runtime context negotiated once per active Protocol V2 link. */
239
- private protocolV2RuntimeContext?: ProtocolInfo;
240
-
241
- /** Coalesces concurrent first-use runtime negotiation on the same active link. */
242
- private protocolV2RuntimeContextPromise?: Promise<ProtocolInfo>;
243
-
244
- /** Invalidates an in-flight runtime-context response without adding a transport epoch. */
245
- private protocolV2RuntimeContextRequestToken?: object;
246
-
247
- private protocolV2UiInteraction?: {
248
- interactionId: string;
249
- phaseCounter: number;
250
- sequence: number;
251
- opened: boolean;
252
- };
253
-
254
- private protocolV2UiInteractionCounter = 0;
255
-
256
238
  get state() {
257
239
  return this.stateStore.getState();
258
240
  }
@@ -360,7 +342,7 @@ export class Device extends EventEmitter {
360
342
  deviceId,
361
343
  path: this.originalDescriptor?.path,
362
344
  bleName,
363
- name: bleName || displayName || `OneKey ${deviceType?.toUpperCase()}`,
345
+ name: displayName || bleName || `OneKey ${deviceType?.toUpperCase()}`,
364
346
  // Keep the legacy top-level field string-compatible while preserving
365
347
  // the canonical nullable value at state.identity.label.
366
348
  label: displayName ?? '',
@@ -378,10 +360,7 @@ export class Device extends EventEmitter {
378
360
  * Device connect
379
361
  * @returns {Promise<boolean>}
380
362
  */
381
- connect(
382
- connectProtocol?: HardwareConnectProtocol,
383
- options?: { forceProtocolDetection?: boolean }
384
- ) {
363
+ connect(connectProtocol?: HardwareConnectProtocol) {
385
364
  const env = DataManager.getSettings('env');
386
365
  // eslint-disable-next-line no-async-promise-executor
387
366
  return new Promise<boolean>(async (resolve, reject) => {
@@ -391,7 +370,7 @@ export class Device extends EventEmitter {
391
370
  return;
392
371
  }
393
372
  try {
394
- await this.acquire(connectProtocol, options);
373
+ await this.acquire(connectProtocol);
395
374
  resolve(true);
396
375
  } catch (error) {
397
376
  reject(error);
@@ -401,7 +380,7 @@ export class Device extends EventEmitter {
401
380
  // 不存在 Session ID 或存在 Session ID 但设备在别处使用,都需要 acquire 获取最新 sessionID
402
381
  if (!this.mainId || (!this.isUsedHere() && this.originalDescriptor)) {
403
382
  try {
404
- await this.acquire(connectProtocol, options);
383
+ await this.acquire(connectProtocol);
405
384
  resolve(true);
406
385
  } catch (error) {
407
386
  reject(error);
@@ -418,16 +397,11 @@ export class Device extends EventEmitter {
418
397
 
419
398
  async acquire(
420
399
  expectedProtocol?: HardwareConnectProtocol,
421
- options?: { throwOnRunPromiseError?: boolean; forceProtocolDetection?: boolean }
400
+ options?: { throwOnRunPromiseError?: boolean }
422
401
  ) {
423
402
  const env = DataManager.getSettings('env');
424
403
  const mainIdKey = DataManager.isBleConnect(env) ? 'id' : 'session';
425
- const previousProtocol = this.originalDescriptor.protocolType;
426
- // A protocol stored after a successful probe is authoritative. Only the explicit
427
- // first-connection/recovery path may bypass it and probe both protocols again.
428
- const strictProtocol = options?.forceProtocolDetection
429
- ? undefined
430
- : expectedProtocol ?? this.originalDescriptor.protocolType;
404
+ const protocolHint = expectedProtocol ? undefined : this.originalDescriptor.protocolType;
431
405
  try {
432
406
  let acquireResult: unknown;
433
407
  if (DataManager.isBleConnect(env)) {
@@ -439,8 +413,8 @@ export class Device extends EventEmitter {
439
413
  this.originalDescriptor.id,
440
414
  undefined,
441
415
  true,
442
- strictProtocol,
443
- undefined
416
+ expectedProtocol,
417
+ protocolHint
444
418
  );
445
419
  this.mainId = (acquireResult as any)?.uuid ?? '';
446
420
  Log.debug('Expected uuid:', this.mainId);
@@ -449,31 +423,24 @@ export class Device extends EventEmitter {
449
423
  this.originalDescriptor.path,
450
424
  this.originalDescriptor.session,
451
425
  undefined,
452
- strictProtocol,
453
- undefined
426
+ expectedProtocol,
427
+ protocolHint
454
428
  );
455
429
  this.mainId = acquireResult as string | undefined;
456
430
  Log.debug('Expected session id:', this.mainId);
457
431
  }
432
+ this.deviceAcquired = true;
433
+ this.updateDescriptor({ [mainIdKey]: this.mainId } as unknown as DeviceDescriptor);
434
+
458
435
  // Propagate protocol version detected during acquire.
459
436
  const detectedProtocol =
460
437
  (acquireResult as { protocolType?: HardwareConnectProtocol } | undefined)?.protocolType ??
461
438
  TransportManager.transport?.getProtocolType?.(
462
439
  DataManager.isBleConnect(env) ? this.originalDescriptor.id : this.originalDescriptor.path
463
440
  );
464
- if (options?.forceProtocolDetection && !detectedProtocol) {
465
- throw ERRORS.TypedError(
466
- HardwareErrorCode.RuntimeError,
467
- `Active protocol detection returned no protocol for ${
468
- this.originalDescriptor.path || this.originalDescriptor.id
469
- }`
470
- );
471
- }
472
441
  if (detectedProtocol) {
473
442
  this.originalDescriptor.protocolType = detectedProtocol;
474
443
  }
475
- this.deviceAcquired = true;
476
- this.updateDescriptor({ [mainIdKey]: this.mainId } as unknown as DeviceDescriptor);
477
444
 
478
445
  if (this.commands) {
479
446
  await this.commands.dispose(false);
@@ -481,22 +448,6 @@ export class Device extends EventEmitter {
481
448
 
482
449
  this.commands = new DeviceCommands(this, this.mainId ?? '');
483
450
  } catch (error) {
484
- if (options?.forceProtocolDetection) {
485
- this.originalDescriptor.protocolType = previousProtocol;
486
- const failedSession = this.mainId;
487
- this.deviceAcquired = false;
488
- if (failedSession) {
489
- try {
490
- await this.deviceConnector?.release?.(failedSession, false);
491
- } catch (releaseError) {
492
- Log.debug('Failed to release an unsuccessful protocol probe', releaseError);
493
- }
494
- }
495
- if (!DataManager.isBleConnect(env)) {
496
- this.mainId = null;
497
- this.updateDescriptor({ session: null } as DeviceDescriptor);
498
- }
499
- }
500
451
  if (options?.throwOnRunPromiseError) {
501
452
  throw error;
502
453
  }
@@ -696,7 +647,6 @@ export class Device extends EventEmitter {
696
647
  // Most-specific model first; must match getMethodVersionRange in deviceInfoUtils,
697
648
  // otherwise e.g. Classic1s resolves the looser model_mini range before model_classic1s.
698
649
  const modelFallbacks: IDeviceModel[] = [
699
- 'model_pro2',
700
650
  'model_classic1s',
701
651
  'model_classic',
702
652
  'model_mini',
@@ -716,8 +666,7 @@ export class Device extends EventEmitter {
716
666
  if (
717
667
  deviceType === EDeviceType.Touch ||
718
668
  deviceType === EDeviceType.Pro ||
719
- deviceType === EDeviceType.Pro2 ||
720
- deviceType === EDeviceType.Neo
669
+ deviceType === EDeviceType.Pro2
721
670
  ) {
722
671
  return { support: true };
723
672
  }
@@ -734,8 +683,7 @@ export class Device extends EventEmitter {
734
683
  if (
735
684
  deviceType === EDeviceType.Touch ||
736
685
  deviceType === EDeviceType.Pro ||
737
- deviceType === EDeviceType.Pro2 ||
738
- deviceType === EDeviceType.Neo
686
+ deviceType === EDeviceType.Pro2
739
687
  ) {
740
688
  return { support: false };
741
689
  }
@@ -908,7 +856,7 @@ export class Device extends EventEmitter {
908
856
  const initStartAt = Date.now();
909
857
  const { message } = await this.commands.typedCall('Initialize', 'Features', payload, {
910
858
  // iOS BLE bound devices can need close to 20 seconds.
911
- timeoutMs: 25 * 1000,
859
+ timeoutMs: options?.timeoutMs ?? 25 * 1000,
912
860
  });
913
861
  this.setLastInitializeDuration(Date.now() - initStartAt);
914
862
  this._updateFeatures(message, initSession);
@@ -1021,10 +969,7 @@ export class Device extends EventEmitter {
1021
969
  await this.getFeatures();
1022
970
  }
1023
971
 
1024
- const supportsProtocolV1OnekeyFeatures =
1025
- this.getCurrentDeviceType() === EDeviceType.Touch ||
1026
- this.getCurrentDeviceType() === EDeviceType.Pro;
1027
- if (!this.isProtocolV2() && refresh.has('verification') && supportsProtocolV1OnekeyFeatures) {
972
+ if (!this.isProtocolV2() && refresh.has('verification')) {
1028
973
  const { message } = await this.commands.typedCall('OnekeyGetFeatures', 'OnekeyFeatures');
1029
974
  this.updateState(mapProtocolV1OnekeyFeaturesToState(message), 'device-info');
1030
975
  }
@@ -1047,7 +992,13 @@ export class Device extends EventEmitter {
1047
992
  }
1048
993
 
1049
994
  if (refresh.has('status') && !initializedWithDeviceInfo) {
1050
- await this.probeProtocolV2RuntimeState(refreshedDeviceInfo);
995
+ const deviceInfo =
996
+ refreshedDeviceInfo ??
997
+ (await requestProtocolV2DeviceInfo({
998
+ commands: this.commands,
999
+ request: getProtocolV2DeviceInfoRequest(),
1000
+ }));
1001
+ await this.probeProtocolV2RuntimeState(deviceInfo);
1051
1002
  }
1052
1003
 
1053
1004
  if (refresh.has('settings') && this.state?.status.mode === 'normal') {
@@ -1118,66 +1069,19 @@ export class Device extends EventEmitter {
1118
1069
  return this.features;
1119
1070
  }
1120
1071
 
1121
- async ensureProtocolV2RuntimeContext(timeoutMs?: number): Promise<ProtocolInfo> {
1122
- const cachedProtocolInfo =
1123
- this.protocolV2RuntimeContext ??
1124
- (!this.protocolV2StateNeedsReload
1125
- ? this.state?.raw?.protocolV2ProtocolInfo ?? undefined
1126
- : undefined);
1127
- if (cachedProtocolInfo) {
1128
- this.protocolV2RuntimeContext = cachedProtocolInfo;
1129
- return cachedProtocolInfo;
1130
- }
1131
-
1132
- if (this.protocolV2RuntimeContextPromise) {
1133
- return this.protocolV2RuntimeContextPromise;
1134
- }
1135
-
1136
- const requestToken = {};
1137
- const pendingRequest = (async () => {
1138
- const protocolInfo = await requestProtocolV2ProtocolInfo({
1139
- commands: this.commands,
1140
- timeoutMs,
1141
- });
1142
- if (this.protocolV2RuntimeContextRequestToken !== requestToken) {
1143
- throw ERRORS.TypedError(
1144
- HardwareErrorCode.DeviceInitializeFailed,
1145
- 'Protocol V2 runtime context was invalidated while loading.'
1146
- );
1147
- }
1148
- this.protocolV2RuntimeContext = protocolInfo;
1149
- return protocolInfo;
1150
- })();
1151
- this.protocolV2RuntimeContextRequestToken = requestToken;
1152
- this.protocolV2RuntimeContextPromise = pendingRequest;
1153
-
1154
- try {
1155
- return await pendingRequest;
1156
- } finally {
1157
- if (this.protocolV2RuntimeContextPromise === pendingRequest) {
1158
- this.protocolV2RuntimeContextPromise = undefined;
1159
- }
1160
- if (this.protocolV2RuntimeContextRequestToken === requestToken) {
1161
- this.protocolV2RuntimeContextRequestToken = undefined;
1162
- }
1163
- }
1164
- }
1165
-
1166
- async probeProtocolV2RuntimeState(deviceInfo?: ProtocolV2DeviceInfo, timeoutMs?: number) {
1167
- const protocolInfo = await this.ensureProtocolV2RuntimeContext(timeoutMs);
1072
+ async probeProtocolV2RuntimeState(deviceInfo: ProtocolV2DeviceInfo, timeoutMs?: number) {
1073
+ const protocolInfo = await requestProtocolV2ProtocolInfo({
1074
+ commands: this.commands,
1075
+ timeoutMs,
1076
+ });
1168
1077
  const runtimeMode = getProtocolV2RuntimeMode(protocolInfo);
1169
- const runtimeDeviceInfo = deviceInfo ?? this.state?.raw?.protocolV2DeviceInfo;
1170
- const protocolV2DeviceType = runtimeDeviceInfo
1171
- ? resolveProtocolV2DeviceIdentity(runtimeDeviceInfo.hw?.Device_type).deviceType
1172
- : this.getCurrentDeviceType();
1173
- if (
1174
- runtimeMode === 'romloader' &&
1175
- protocolV2DeviceType !== EDeviceType.Pro2 &&
1176
- protocolV2DeviceType !== EDeviceType.Neo
1177
- ) {
1078
+ const protocolV2DeviceType = resolveProtocolV2DeviceIdentity(
1079
+ deviceInfo.hw?.Device_type
1080
+ ).deviceType;
1081
+ if (runtimeMode === 'romloader' && protocolV2DeviceType !== EDeviceType.Pro2) {
1178
1082
  throw ERRORS.TypedError(
1179
1083
  HardwareErrorCode.DeviceInitializeFailed,
1180
- 'Protocol V2 romloader mode is only supported for Pro2 and Neo.'
1084
+ 'Protocol V2 romloader mode is only supported for Pro2.'
1181
1085
  );
1182
1086
  }
1183
1087
  const deviceStatusSupported = supportsProtocolV2Message(
@@ -1248,9 +1152,6 @@ export class Device extends EventEmitter {
1248
1152
  this.deviceAcquired = false;
1249
1153
  if (!this.isProtocolV2()) return;
1250
1154
  this.protocolV2StateNeedsReload = true;
1251
- this.protocolV2RuntimeContext = undefined;
1252
- this.protocolV2RuntimeContextPromise = undefined;
1253
- this.protocolV2RuntimeContextRequestToken = undefined;
1254
1155
  this.clearPreInitialized();
1255
1156
  }
1256
1157
 
@@ -1259,14 +1160,9 @@ export class Device extends EventEmitter {
1259
1160
  if (deviceId) {
1260
1161
  deviceWalletSessionStore.deleteDevice(deviceId);
1261
1162
  }
1262
- if (this.isProtocolV2()) {
1263
- if (this.originalDescriptor.path !== deviceId) {
1264
- deviceWalletSessionStore.deleteDevice(this.originalDescriptor.path);
1265
- }
1163
+ if (this.isProtocolV2() && this.originalDescriptor.path !== deviceId) {
1164
+ deviceWalletSessionStore.deleteDevice(this.originalDescriptor.path);
1266
1165
  this.protocolV2StateNeedsReload = true;
1267
- this.protocolV2RuntimeContext = undefined;
1268
- this.protocolV2RuntimeContextPromise = undefined;
1269
- this.protocolV2RuntimeContextRequestToken = undefined;
1270
1166
  }
1271
1167
 
1272
1168
  this.passphraseState = undefined;
@@ -1279,9 +1175,6 @@ export class Device extends EventEmitter {
1279
1175
  if (!this.isProtocolV2()) return;
1280
1176
 
1281
1177
  this.protocolV2StateNeedsReload = true;
1282
- this.protocolV2RuntimeContext = undefined;
1283
- this.protocolV2RuntimeContextPromise = undefined;
1284
- this.protocolV2RuntimeContextRequestToken = undefined;
1285
1178
  this.clearPreInitialized();
1286
1179
  let loaderMode: 'bootloader' | 'romloader' | undefined;
1287
1180
  if (rebootType === DeviceRebootType.Bootloader) {
@@ -1388,17 +1281,11 @@ export class Device extends EventEmitter {
1388
1281
  }
1389
1282
  };
1390
1283
 
1391
- const env = DataManager.getSettings('env');
1392
- if (options.forceProtocolDetection && env !== 'react-native' && this.isUsedHere()) {
1393
- await this.release();
1394
- }
1395
-
1396
- if (options.forceProtocolDetection || !this.isUsedHere() || this.commands.disposed) {
1284
+ if (!this.isUsedHere() || this.commands.disposed) {
1285
+ const env = DataManager.getSettings('env');
1397
1286
  if (env !== 'react-native') {
1398
1287
  try {
1399
- await this.acquire(options.connectProtocol, {
1400
- forceProtocolDetection: options.forceProtocolDetection,
1401
- });
1288
+ await this.acquire(options.connectProtocol);
1402
1289
  } catch (error) {
1403
1290
  clearRunPromise();
1404
1291
  runPromise.reject(error);
@@ -1576,8 +1463,7 @@ export class Device extends EventEmitter {
1576
1463
  if (!this.state) return undefined;
1577
1464
  return (
1578
1465
  this.isProtocolV2() &&
1579
- (this.getCurrentDeviceType() === EDeviceType.Pro2 ||
1580
- this.getCurrentDeviceType() === EDeviceType.Neo) &&
1466
+ this.getCurrentDeviceType() === EDeviceType.Pro2 &&
1581
1467
  this.state.status.mode === 'romloader'
1582
1468
  );
1583
1469
  }
@@ -1623,8 +1509,7 @@ export class Device extends EventEmitter {
1623
1509
  const isModeT =
1624
1510
  deviceType === EDeviceType.Touch ||
1625
1511
  deviceType === EDeviceType.Pro ||
1626
- deviceType === EDeviceType.Pro2 ||
1627
- deviceType === EDeviceType.Neo;
1512
+ deviceType === EDeviceType.Pro2;
1628
1513
  const unlocked = this.state?.status.unlocked;
1629
1514
  const preCheckTouch = isModeT && unlocked === false;
1630
1515
  const passphraseProtection = this.getCurrentPassphraseProtection();
@@ -1642,85 +1527,6 @@ export class Device extends EventEmitter {
1642
1527
  return res.message;
1643
1528
  }
1644
1529
 
1645
- beginProtocolV2UiInteraction() {
1646
- if (!this.isProtocolV2()) return;
1647
- this.protocolV2UiInteraction = {
1648
- interactionId: `${this.instanceId}:${Date.now()}:${++this.protocolV2UiInteractionCounter}`,
1649
- phaseCounter: 0,
1650
- sequence: 0,
1651
- opened: false,
1652
- };
1653
- }
1654
-
1655
- createProtocolV2UiPhaseMetadata(
1656
- phase: HardwareUiInteractionMeta['phase'],
1657
- transition: HardwareUiInteractionMeta['transition'],
1658
- options?: {
1659
- phaseId?: string;
1660
- outcome?: HardwareUiInteractionMeta['outcome'];
1661
- }
1662
- ): HardwareUiInteractionMeta | undefined {
1663
- if (!this.isProtocolV2()) return undefined;
1664
- if (!this.protocolV2UiInteraction) this.beginProtocolV2UiInteraction();
1665
-
1666
- const interaction = this.protocolV2UiInteraction;
1667
- if (!interaction) return undefined;
1668
- const phaseId =
1669
- options?.phaseId ?? `${interaction.interactionId}:phase-${++interaction.phaseCounter}`;
1670
- interaction.opened = true;
1671
- interaction.sequence += 1;
1672
-
1673
- return {
1674
- interactionId: interaction.interactionId,
1675
- phaseId,
1676
- sequence: interaction.sequence,
1677
- phase,
1678
- transition,
1679
- ...(options?.outcome ? { outcome: options.outcome } : {}),
1680
- protocol: 'V2',
1681
- };
1682
- }
1683
-
1684
- completeProtocolV2UiPhase(
1685
- phase: HardwareUiInteractionMeta,
1686
- outcome: HardwareUiInteractionMeta['outcome'] = 'succeeded'
1687
- ) {
1688
- return this.createProtocolV2UiPhaseMetadata(phase.phase, 'complete', {
1689
- phaseId: phase.phaseId,
1690
- outcome,
1691
- });
1692
- }
1693
-
1694
- finishProtocolV2UiInteraction(
1695
- outcome?: HardwareUiInteractionMeta['outcome'],
1696
- options?: { ensureMetadata?: boolean }
1697
- ) {
1698
- const interaction = this.protocolV2UiInteraction;
1699
- if (!interaction || (!interaction.opened && !options?.ensureMetadata)) {
1700
- this.protocolV2UiInteraction = undefined;
1701
- return undefined;
1702
- }
1703
-
1704
- const phaseId = `${interaction.interactionId}:phase-${Math.max(interaction.phaseCounter, 1)}`;
1705
- interaction.opened = true;
1706
- interaction.sequence += 1;
1707
- const metadata: HardwareUiInteractionMeta = {
1708
- interactionId: interaction.interactionId,
1709
- phaseId,
1710
- sequence: interaction.sequence,
1711
- phase: 'processing',
1712
- transition: 'finish',
1713
- outcome: outcome ?? 'succeeded',
1714
- protocol: 'V2',
1715
- };
1716
- this.protocolV2UiInteraction = undefined;
1717
- return metadata;
1718
- }
1719
-
1720
- hasOpenProtocolV2UiInteraction() {
1721
- return this.protocolV2UiInteraction?.opened === true;
1722
- }
1723
-
1724
1530
  supportUnlockVersionRange(): DeviceFirmwareRange {
1725
1531
  // This range applies to Protocol V1 Pro devices; Pro2 has a dedicated unlock flow.
1726
1532
  return {
@@ -1730,33 +1536,10 @@ export class Device extends EventEmitter {
1730
1536
  };
1731
1537
  }
1732
1538
 
1733
- async unlockDevice(
1734
- pinType?: DeviceSessionPinType,
1735
- options?: ProtocolV2UiEventMetadata & { emitUiEvent?: boolean }
1736
- ) {
1539
+ async unlockDevice(pinType: DeviceSessionPinType = DeviceSessionPinType.Main) {
1737
1540
  if (this.isProtocolV2()) {
1738
- const requestedPinType = pinType ?? DeviceSessionPinType.Main;
1739
- const interaction =
1740
- options?.interaction ??
1741
- (options?.emitUiEvent === false
1742
- ? undefined
1743
- : this.createProtocolV2UiPhaseMetadata('pin', 'start'));
1744
- if (options?.emitUiEvent !== false) {
1745
- this.emit(DEVICE.PIN_ON_DEVICE, this, requestedPinType, {
1746
- source: options?.source ?? 'unlock-coordinator',
1747
- reason: options?.reason ?? 'device-unlock',
1748
- deviceOnly: options?.deviceOnly ?? true,
1749
- completion: options?.completion,
1750
- method: options?.method,
1751
- page: options?.page,
1752
- operation: options?.operation,
1753
- interaction: options?.interaction ?? interaction,
1754
- });
1755
- }
1756
1541
  try {
1757
- await this.commands.typedCall('DeviceSessionAskPin', 'Success', {
1758
- type: requestedPinType,
1759
- });
1542
+ await this.commands.typedCall('DeviceSessionAskPin', 'Success', { type: pinType });
1760
1543
  } catch (error) {
1761
1544
  const errorText =
1762
1545
  error instanceof Error
@@ -1768,11 +1551,6 @@ export class Device extends EventEmitter {
1768
1551
  throw error;
1769
1552
  }
1770
1553
 
1771
- const completion = interaction ? this.completeProtocolV2UiPhase(interaction) : undefined;
1772
- if (completion) {
1773
- this.emit(DEVICE.PIN_ON_DEVICE_COMPLETE, this, completion);
1774
- }
1775
-
1776
1554
  const status = await requestProtocolV2DeviceStatus({ commands: this.commands });
1777
1555
  return this.updateProtocolV2Status(status);
1778
1556
  }
@@ -1834,8 +1612,7 @@ export class Device extends EventEmitter {
1834
1612
  async checkPassphraseStateSafety(
1835
1613
  passphraseState?: string,
1836
1614
  useEmptyPassphrase?: boolean,
1837
- skipPassphraseCheck?: boolean,
1838
- deriveCardano?: boolean
1615
+ skipPassphraseCheck?: boolean
1839
1616
  ) {
1840
1617
  if (this.isUnacquired()) return false;
1841
1618
 
@@ -1844,8 +1621,6 @@ export class Device extends EventEmitter {
1844
1621
  await getPassphraseStateWithRefreshDeviceInfo(this, {
1845
1622
  expectPassphraseState: expectedPassphraseState,
1846
1623
  onlyMainPin: useEmptyPassphrase,
1847
- deriveCardano,
1848
- rejectAttachPinForMainWallet: useEmptyPassphrase === true,
1849
1624
  });
1850
1625
 
1851
1626
  // Main wallet and unlock Attach Pin, throw safe error
@@ -54,19 +54,9 @@ const DEVICE_SESSION_CALLS = new Set([
54
54
  'DeviceSessionAskPin',
55
55
  'DeviceSessionAskPassphrase',
56
56
  ]);
57
- const DEVICE_CONTROL_CALLS = new Set([
58
- 'DeviceReboot',
59
- 'DeviceSettingsGet',
60
- 'DeviceSettingsSet',
61
- 'DeviceSettingsPageShow',
62
- 'DeviceCertificateWrite',
63
- 'DeviceCertificateRead',
64
- 'DeviceCertificateSign',
65
- 'DeviceMiscUsbMscControl',
66
- ]);
67
57
 
68
- // Older Protocol V2 firmware may omit the cancellation subcode, so retain a
69
- // narrow message fallback for compatibility.
58
+ // Protocol V2 subcodes are domain-scoped, so cross-domain cancellation fallback
59
+ // must use explicit firmware cancellation messages instead of a global number map.
70
60
  const isProtocolV2ActionCancelledMessage = (message: string) =>
71
61
  /^(?:cancel(?:led|ed)(?: on device)?|confirm dismissed|user cancel(?:led|ed)(?:\s+.*)?)$/i.test(
72
62
  message
@@ -445,13 +435,7 @@ export class DeviceCommands {
445
435
  if (!shouldReduceDebugForCall(callType)) {
446
436
  Log.debug('_filterCommonTypes: ', {
447
437
  request: callType,
448
- response:
449
- callType === 'DeviceFirmwareUpdateStatusGet'
450
- ? {
451
- type: res.type,
452
- message: getSafeTransportLogPayload(res.message, res.type),
453
- }
454
- : res.type,
438
+ response: res.type,
455
439
  });
456
440
  }
457
441
  } catch (error) {
@@ -509,10 +493,6 @@ export class DeviceCommands {
509
493
  const normalizedMessage = message?.trim() ?? '';
510
494
  const isProtocolV2ActionCancelledFailure =
511
495
  this.device.isProtocolV2() && isProtocolV2ActionCancelledMessage(normalizedMessage);
512
- const isProtocolV2DeviceBusyFailure =
513
- this.device.isProtocolV2() &&
514
- DEVICE_CONTROL_CALLS.has(callType) &&
515
- subcode === DeviceErrorCode.DeviceError_Busy;
516
496
  const isLegacyProtocolV2LockedFailure =
517
497
  this.device.isProtocolV2() && /^device (?:is )?locked$/i.test(normalizedMessage);
518
498
  if (
@@ -570,15 +550,8 @@ export class DeviceCommands {
570
550
  subcode,
571
551
  firmwareMessage: message,
572
552
  });
573
- } else if (isProtocolV2DeviceBusyFailure) {
574
- error = ERRORS.TypedError(HardwareErrorCode.DeviceBusy, message, {
575
- failureCode: code,
576
- subcode,
577
- firmwareMessage: message,
578
- });
579
553
  } else if (
580
- (DEVICE_CONTROL_CALLS.has(callType) &&
581
- subcode === DeviceErrorCode.DeviceError_ActionCancelled) ||
554
+ subcode === DeviceErrorCode.DeviceError_ActionCancelled ||
582
555
  isProtocolV2ActionCancelledFailure
583
556
  ) {
584
557
  error = ERRORS.TypedError(HardwareErrorCode.ActionCancelled, message, {