@onekeyfe/hd-core 1.1.27-alpha.40 → 1.1.27-alpha.5

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 (362) hide show
  1. package/__tests__/DeviceCommands.test.ts +99 -0
  2. package/__tests__/evmLedgerLegacySafety.test.ts +261 -0
  3. package/__tests__/evmSignTransaction.test.ts +1 -1
  4. package/__tests__/evmSignTypedData.test.ts +1 -1
  5. package/__tests__/preInitialize.test.ts +22 -0
  6. package/dist/api/BaseMethod.d.ts +7 -1
  7. package/dist/api/BaseMethod.d.ts.map +1 -1
  8. package/dist/api/FirmwareUpdateV3.d.ts +0 -1
  9. package/dist/api/FirmwareUpdateV3.d.ts.map +1 -1
  10. package/dist/api/GetFeatures.d.ts +1 -1
  11. package/dist/api/GetOnekeyFeatures.d.ts.map +1 -1
  12. package/dist/api/GetPassphraseState.d.ts +1 -6
  13. package/dist/api/GetPassphraseState.d.ts.map +1 -1
  14. package/dist/api/SearchDevices.d.ts +1 -2
  15. package/dist/api/SearchDevices.d.ts.map +1 -1
  16. package/dist/api/alephium/AlephiumGetAddress.d.ts +6 -2
  17. package/dist/api/alephium/AlephiumGetAddress.d.ts.map +1 -1
  18. package/dist/api/alephium/AlephiumSignMessage.d.ts +5 -2
  19. package/dist/api/alephium/AlephiumSignMessage.d.ts.map +1 -1
  20. package/dist/api/alephium/AlephiumSignTransaction.d.ts +5 -2
  21. package/dist/api/alephium/AlephiumSignTransaction.d.ts.map +1 -1
  22. package/dist/api/algo/AlgoSignTransaction.d.ts.map +1 -1
  23. package/dist/api/allnetwork/AllNetworkGetAddressBase.d.ts.map +1 -1
  24. package/dist/api/aptos/AptosSignInMessage.d.ts.map +1 -1
  25. package/dist/api/aptos/AptosSignMessage.d.ts.map +1 -1
  26. package/dist/api/aptos/AptosSignTransaction.d.ts.map +1 -1
  27. package/dist/api/benfen/BenfenGetAddress.d.ts +9 -2
  28. package/dist/api/benfen/BenfenGetAddress.d.ts.map +1 -1
  29. package/dist/api/benfen/BenfenGetPublicKey.d.ts +9 -2
  30. package/dist/api/benfen/BenfenGetPublicKey.d.ts.map +1 -1
  31. package/dist/api/benfen/BenfenSignMessage.d.ts +8 -2
  32. package/dist/api/benfen/BenfenSignMessage.d.ts.map +1 -1
  33. package/dist/api/benfen/BenfenSignTransaction.d.ts +8 -2
  34. package/dist/api/benfen/BenfenSignTransaction.d.ts.map +1 -1
  35. package/dist/api/btc/BTCGetAddress.d.ts +11 -1
  36. package/dist/api/btc/BTCGetAddress.d.ts.map +1 -1
  37. package/dist/api/btc/BTCGetPublicKey.d.ts +11 -1
  38. package/dist/api/btc/BTCGetPublicKey.d.ts.map +1 -1
  39. package/dist/api/btc/BTCSignMessage.d.ts +15 -1
  40. package/dist/api/btc/BTCSignMessage.d.ts.map +1 -1
  41. package/dist/api/btc/BTCSignPsbt.d.ts.map +1 -1
  42. package/dist/api/btc/BTCSignTransaction.d.ts +11 -1
  43. package/dist/api/btc/BTCSignTransaction.d.ts.map +1 -1
  44. package/dist/api/btc/BTCVerifyMessage.d.ts +11 -1
  45. package/dist/api/btc/BTCVerifyMessage.d.ts.map +1 -1
  46. package/dist/api/btc/helpers/versionLimit.d.ts +11 -2
  47. package/dist/api/btc/helpers/versionLimit.d.ts.map +1 -1
  48. package/dist/api/cardano/CardanoSignMessage.d.ts.map +1 -1
  49. package/dist/api/cardano/CardanoSignTransaction.d.ts.map +1 -1
  50. package/dist/api/conflux/ConfluxSignMessage.d.ts.map +1 -1
  51. package/dist/api/conflux/ConfluxSignMessageCIP23.d.ts.map +1 -1
  52. package/dist/api/conflux/ConfluxSignTransaction.d.ts.map +1 -1
  53. package/dist/api/cosmos/CosmosSignTransaction.d.ts.map +1 -1
  54. package/dist/api/device/DeviceRebootToBoardloader.d.ts +1 -1
  55. package/dist/api/device/DeviceRebootToBoardloader.d.ts.map +1 -1
  56. package/dist/api/device/DeviceRebootToBootloader.d.ts.map +1 -1
  57. package/dist/api/device/PreInitialize.d.ts +6 -0
  58. package/dist/api/device/PreInitialize.d.ts.map +1 -0
  59. package/dist/api/dynex/DnxGetAddress.d.ts.map +1 -1
  60. package/dist/api/dynex/DnxSignTransaction.d.ts.map +1 -1
  61. package/dist/api/evm/EVMSignMessage.d.ts.map +1 -1
  62. package/dist/api/evm/EVMSignMessageEIP712.d.ts +8 -2
  63. package/dist/api/evm/EVMSignMessageEIP712.d.ts.map +1 -1
  64. package/dist/api/evm/EVMSignTransaction.d.ts.map +1 -1
  65. package/dist/api/evm/EVMSignTypedData.d.ts.map +1 -1
  66. package/dist/api/evm/latest/signTypedData.d.ts +1 -1
  67. package/dist/api/evm/latest/signTypedData.d.ts.map +1 -1
  68. package/dist/api/evm/legacyV1/signTypedData.d.ts +1 -1
  69. package/dist/api/evm/legacyV1/signTypedData.d.ts.map +1 -1
  70. package/dist/api/filecoin/FilecoinSignTransaction.d.ts.map +1 -1
  71. package/dist/api/firmware/FirmwareUpdateBaseMethod.d.ts +2 -10
  72. package/dist/api/firmware/FirmwareUpdateBaseMethod.d.ts.map +1 -1
  73. package/dist/api/index.d.ts +1 -28
  74. package/dist/api/index.d.ts.map +1 -1
  75. package/dist/api/kaspa/KaspaSignTransaction.d.ts.map +1 -1
  76. package/dist/api/near/NearSignTransaction.d.ts.map +1 -1
  77. package/dist/api/nem/NEMSignTransaction.d.ts.map +1 -1
  78. package/dist/api/neo/NeoGetAddress.d.ts +8 -2
  79. package/dist/api/neo/NeoGetAddress.d.ts.map +1 -1
  80. package/dist/api/neo/NeoSignTransaction.d.ts +8 -2
  81. package/dist/api/neo/NeoSignTransaction.d.ts.map +1 -1
  82. package/dist/api/nervos/NervosGetAddress.d.ts +9 -2
  83. package/dist/api/nervos/NervosGetAddress.d.ts.map +1 -1
  84. package/dist/api/nervos/NervosSignTransaction.d.ts +9 -2
  85. package/dist/api/nervos/NervosSignTransaction.d.ts.map +1 -1
  86. package/dist/api/nexa/NexaGetAddress.d.ts +8 -2
  87. package/dist/api/nexa/NexaGetAddress.d.ts.map +1 -1
  88. package/dist/api/nexa/NexaSignTransaction.d.ts +9 -2
  89. package/dist/api/nexa/NexaSignTransaction.d.ts.map +1 -1
  90. package/dist/api/nostr/NostrSignEvent.d.ts.map +1 -1
  91. package/dist/api/nostr/NostrSignSchnorr.d.ts.map +1 -1
  92. package/dist/api/polkadot/PolkadotSignTransaction.d.ts.map +1 -1
  93. package/dist/api/scdo/ScdoGetAddress.d.ts +6 -2
  94. package/dist/api/scdo/ScdoGetAddress.d.ts.map +1 -1
  95. package/dist/api/scdo/ScdoSignMessage.d.ts +5 -2
  96. package/dist/api/scdo/ScdoSignMessage.d.ts.map +1 -1
  97. package/dist/api/scdo/ScdoSignTransaction.d.ts +5 -2
  98. package/dist/api/scdo/ScdoSignTransaction.d.ts.map +1 -1
  99. package/dist/api/solana/SolGetAddress.d.ts +0 -6
  100. package/dist/api/solana/SolGetAddress.d.ts.map +1 -1
  101. package/dist/api/solana/SolSignMessage.d.ts +0 -4
  102. package/dist/api/solana/SolSignMessage.d.ts.map +1 -1
  103. package/dist/api/solana/SolSignOffchainMessage.d.ts +0 -4
  104. package/dist/api/solana/SolSignOffchainMessage.d.ts.map +1 -1
  105. package/dist/api/solana/SolSignTransaction.d.ts +0 -8
  106. package/dist/api/solana/SolSignTransaction.d.ts.map +1 -1
  107. package/dist/api/starcoin/StarcoinSignMessage.d.ts.map +1 -1
  108. package/dist/api/starcoin/StarcoinSignTransaction.d.ts.map +1 -1
  109. package/dist/api/stellar/StellarGetAddress.d.ts +1 -2
  110. package/dist/api/stellar/StellarGetAddress.d.ts.map +1 -1
  111. package/dist/api/stellar/StellarSignTransaction.d.ts +1 -2
  112. package/dist/api/stellar/StellarSignTransaction.d.ts.map +1 -1
  113. package/dist/api/sui/SuiSignMessage.d.ts.map +1 -1
  114. package/dist/api/sui/SuiSignTransaction.d.ts +2 -2
  115. package/dist/api/sui/SuiSignTransaction.d.ts.map +1 -1
  116. package/dist/api/ton/TonSignData.d.ts.map +1 -1
  117. package/dist/api/ton/TonSignMessage.d.ts.map +1 -1
  118. package/dist/api/ton/TonSignProof.d.ts.map +1 -1
  119. package/dist/api/tron/TronGetAddress.d.ts +0 -4
  120. package/dist/api/tron/TronGetAddress.d.ts.map +1 -1
  121. package/dist/api/tron/TronSignMessage.d.ts +0 -4
  122. package/dist/api/tron/TronSignMessage.d.ts.map +1 -1
  123. package/dist/api/tron/TronSignTransaction.d.ts +0 -4
  124. package/dist/api/tron/TronSignTransaction.d.ts.map +1 -1
  125. package/dist/api/xrp/XrpSignTransaction.d.ts.map +1 -1
  126. package/dist/core/PollingStateManager.d.ts +8 -0
  127. package/dist/core/PollingStateManager.d.ts.map +1 -0
  128. package/dist/core/RequestQueue.d.ts +1 -1
  129. package/dist/core/RequestQueue.d.ts.map +1 -1
  130. package/dist/core/index.d.ts.map +1 -1
  131. package/dist/data-manager/DataManager.d.ts +4 -7
  132. package/dist/data-manager/DataManager.d.ts.map +1 -1
  133. package/dist/data-manager/MessagesConfig.d.ts +2 -2
  134. package/dist/data-manager/MessagesConfig.d.ts.map +1 -1
  135. package/dist/data-manager/TransportManager.d.ts +4 -5
  136. package/dist/data-manager/TransportManager.d.ts.map +1 -1
  137. package/dist/device/Device.d.ts +18 -5
  138. package/dist/device/Device.d.ts.map +1 -1
  139. package/dist/device/DeviceCommands.d.ts +8 -8
  140. package/dist/device/DeviceCommands.d.ts.map +1 -1
  141. package/dist/device/DeviceConnector.d.ts +1 -2
  142. package/dist/device/DeviceConnector.d.ts.map +1 -1
  143. package/dist/events/ui-request.d.ts +0 -8
  144. package/dist/events/ui-request.d.ts.map +1 -1
  145. package/dist/index.d.ts +43 -292
  146. package/dist/index.js +1003 -16199
  147. package/dist/inject.d.ts.map +1 -1
  148. package/dist/types/api/export.d.ts +1 -1
  149. package/dist/types/api/export.d.ts.map +1 -1
  150. package/dist/types/api/firmwareUpdate.d.ts +0 -7
  151. package/dist/types/api/firmwareUpdate.d.ts.map +1 -1
  152. package/dist/types/api/getPassphraseState.d.ts +1 -10
  153. package/dist/types/api/getPassphraseState.d.ts.map +1 -1
  154. package/dist/types/api/index.d.ts +3 -33
  155. package/dist/types/api/index.d.ts.map +1 -1
  156. package/dist/types/api/preInitialize.d.ts +3 -0
  157. package/dist/types/api/preInitialize.d.ts.map +1 -0
  158. package/dist/types/api/searchDevices.d.ts +2 -2
  159. package/dist/types/api/searchDevices.d.ts.map +1 -1
  160. package/dist/types/device.d.ts +2 -6
  161. package/dist/types/device.d.ts.map +1 -1
  162. package/dist/types/params.d.ts +1 -2
  163. package/dist/types/params.d.ts.map +1 -1
  164. package/dist/types/settings.d.ts +1 -1
  165. package/dist/types/settings.d.ts.map +1 -1
  166. package/dist/utils/deviceFeaturesUtils.d.ts +3 -5
  167. package/dist/utils/deviceFeaturesUtils.d.ts.map +1 -1
  168. package/dist/utils/deviceInfoUtils.d.ts +0 -1
  169. package/dist/utils/deviceInfoUtils.d.ts.map +1 -1
  170. package/dist/utils/index.d.ts +1 -1
  171. package/dist/utils/index.d.ts.map +1 -1
  172. package/dist/utils/patch.d.ts +1 -1
  173. package/dist/utils/patch.d.ts.map +1 -1
  174. package/dist/utils/versionUtils.d.ts +1 -1
  175. package/package.json +4 -4
  176. package/src/api/BaseMethod.ts +82 -7
  177. package/src/api/FirmwareUpdateV3.ts +4 -21
  178. package/src/api/GetOnekeyFeatures.ts +3 -75
  179. package/src/api/GetPassphraseState.ts +7 -16
  180. package/src/api/SearchDevices.ts +2 -7
  181. package/src/api/alephium/AlephiumGetAddress.ts +2 -6
  182. package/src/api/alephium/AlephiumSignMessage.ts +2 -6
  183. package/src/api/alephium/AlephiumSignTransaction.ts +3 -6
  184. package/src/api/algo/AlgoSignTransaction.ts +1 -0
  185. package/src/api/allnetwork/AllNetworkGetAddressBase.ts +9 -18
  186. package/src/api/aptos/AptosSignInMessage.ts +1 -0
  187. package/src/api/aptos/AptosSignMessage.ts +1 -0
  188. package/src/api/aptos/AptosSignTransaction.ts +1 -0
  189. package/src/api/benfen/BenfenGetAddress.ts +2 -6
  190. package/src/api/benfen/BenfenGetPublicKey.ts +2 -6
  191. package/src/api/benfen/BenfenSignMessage.ts +2 -6
  192. package/src/api/benfen/BenfenSignTransaction.ts +2 -6
  193. package/src/api/btc/BTCSignMessage.ts +1 -0
  194. package/src/api/btc/BTCSignPsbt.ts +1 -0
  195. package/src/api/btc/BTCSignTransaction.ts +1 -0
  196. package/src/api/btc/helpers/versionLimit.ts +1 -7
  197. package/src/api/cardano/CardanoSignMessage.ts +1 -0
  198. package/src/api/cardano/CardanoSignTransaction.ts +1 -0
  199. package/src/api/conflux/ConfluxSignMessage.ts +1 -0
  200. package/src/api/conflux/ConfluxSignMessageCIP23.ts +1 -0
  201. package/src/api/conflux/ConfluxSignTransaction.ts +3 -5
  202. package/src/api/cosmos/CosmosSignTransaction.ts +1 -0
  203. package/src/api/device/DeviceRebootToBoardloader.ts +1 -10
  204. package/src/api/device/DeviceRebootToBootloader.ts +1 -10
  205. package/src/api/device/PreInitialize.ts +41 -0
  206. package/src/api/dynex/DnxGetAddress.ts +0 -7
  207. package/src/api/dynex/DnxSignTransaction.ts +1 -7
  208. package/src/api/evm/EVMGetAddress.ts +1 -1
  209. package/src/api/evm/EVMGetPublicKey.ts +1 -1
  210. package/src/api/evm/EVMSignMessage.ts +3 -1
  211. package/src/api/evm/EVMSignMessageEIP712.ts +2 -14
  212. package/src/api/evm/EVMSignTransaction.ts +3 -1
  213. package/src/api/evm/EVMSignTypedData.ts +8 -6
  214. package/src/api/evm/EVMVerifyMessage.ts +1 -1
  215. package/src/api/filecoin/FilecoinSignTransaction.ts +1 -0
  216. package/src/api/firmware/FirmwareUpdateBaseMethod.ts +4 -27
  217. package/src/api/index.ts +1 -30
  218. package/src/api/kaspa/KaspaSignTransaction.ts +1 -0
  219. package/src/api/near/NearSignTransaction.ts +1 -0
  220. package/src/api/nem/NEMSignTransaction.ts +1 -0
  221. package/src/api/neo/NeoGetAddress.ts +1 -6
  222. package/src/api/neo/NeoSignTransaction.ts +2 -6
  223. package/src/api/nervos/NervosGetAddress.ts +2 -6
  224. package/src/api/nervos/NervosSignTransaction.ts +3 -6
  225. package/src/api/nexa/NexaGetAddress.ts +2 -6
  226. package/src/api/nexa/NexaSignTransaction.ts +4 -6
  227. package/src/api/nostr/NostrSignEvent.ts +1 -0
  228. package/src/api/nostr/NostrSignSchnorr.ts +1 -0
  229. package/src/api/polkadot/PolkadotSignTransaction.ts +1 -0
  230. package/src/api/scdo/ScdoGetAddress.ts +2 -6
  231. package/src/api/scdo/ScdoSignMessage.ts +2 -6
  232. package/src/api/scdo/ScdoSignTransaction.ts +3 -6
  233. package/src/api/solana/SolGetAddress.ts +0 -9
  234. package/src/api/solana/SolSignMessage.ts +1 -4
  235. package/src/api/solana/SolSignOffchainMessage.ts +1 -4
  236. package/src/api/solana/SolSignTransaction.ts +1 -8
  237. package/src/api/starcoin/StarcoinSignMessage.ts +1 -0
  238. package/src/api/starcoin/StarcoinSignTransaction.ts +1 -0
  239. package/src/api/stellar/StellarGetAddress.ts +1 -10
  240. package/src/api/stellar/StellarSignTransaction.ts +2 -14
  241. package/src/api/sui/SuiSignMessage.ts +1 -0
  242. package/src/api/sui/SuiSignTransaction.ts +10 -12
  243. package/src/api/ton/TonSignData.ts +1 -0
  244. package/src/api/ton/TonSignMessage.ts +1 -0
  245. package/src/api/ton/TonSignProof.ts +1 -0
  246. package/src/api/tron/TronGetAddress.ts +0 -4
  247. package/src/api/tron/TronSignMessage.ts +2 -5
  248. package/src/api/tron/TronSignTransaction.ts +1 -4
  249. package/src/api/xrp/XrpSignTransaction.ts +2 -1
  250. package/src/core/PollingStateManager.ts +47 -0
  251. package/src/core/RequestQueue.ts +10 -3
  252. package/src/core/index.ts +153 -62
  253. package/src/data-manager/DataManager.ts +7 -12
  254. package/src/data-manager/MessagesConfig.ts +14 -14
  255. package/src/data-manager/TransportManager.ts +12 -38
  256. package/src/device/Device.ts +77 -88
  257. package/src/device/DeviceCommands.ts +26 -166
  258. package/src/device/DeviceConnector.ts +4 -29
  259. package/src/device/DevicePool.ts +1 -1
  260. package/src/events/ui-request.ts +0 -8
  261. package/src/inject.ts +2 -46
  262. package/src/types/api/export.ts +0 -1
  263. package/src/types/api/firmwareUpdate.ts +0 -12
  264. package/src/types/api/getPassphraseState.ts +2 -13
  265. package/src/types/api/index.ts +3 -80
  266. package/src/types/api/preInitialize.ts +3 -0
  267. package/src/types/api/searchDevices.ts +2 -2
  268. package/src/types/device.ts +2 -33
  269. package/src/types/params.ts +2 -4
  270. package/src/types/settings.ts +1 -1
  271. package/src/utils/deviceFeaturesUtils.ts +21 -62
  272. package/src/utils/deviceInfoUtils.ts +8 -15
  273. package/src/utils/index.ts +0 -1
  274. package/__tests__/protocol-v2.test.ts +0 -1661
  275. package/dist/api/DirList.d.ts +0 -10
  276. package/dist/api/DirList.d.ts.map +0 -1
  277. package/dist/api/DirMake.d.ts +0 -9
  278. package/dist/api/DirMake.d.ts.map +0 -1
  279. package/dist/api/DirRemove.d.ts +0 -9
  280. package/dist/api/DirRemove.d.ts.map +0 -1
  281. package/dist/api/FileDelete.d.ts +0 -9
  282. package/dist/api/FileDelete.d.ts.map +0 -1
  283. package/dist/api/FileRead.d.ts +0 -19
  284. package/dist/api/FileRead.d.ts.map +0 -1
  285. package/dist/api/FileWrite.d.ts +0 -23
  286. package/dist/api/FileWrite.d.ts.map +0 -1
  287. package/dist/api/FirmwareUpdateV4.d.ts +0 -32
  288. package/dist/api/FirmwareUpdateV4.d.ts.map +0 -1
  289. package/dist/api/GetDeviceInfo.d.ts +0 -9
  290. package/dist/api/GetDeviceInfo.d.ts.map +0 -1
  291. package/dist/api/PathInfo.d.ts +0 -9
  292. package/dist/api/PathInfo.d.ts.map +0 -1
  293. package/dist/api/helpers/deviceInfo.d.ts +0 -15
  294. package/dist/api/helpers/deviceInfo.d.ts.map +0 -1
  295. package/dist/api/helpers/filesystemValidation.d.ts +0 -7
  296. package/dist/api/helpers/filesystemValidation.d.ts.map +0 -1
  297. package/dist/api/protocol-v2/DeviceFirmwareUpdate.d.ts +0 -7
  298. package/dist/api/protocol-v2/DeviceFirmwareUpdate.d.ts.map +0 -1
  299. package/dist/api/protocol-v2/DeviceGetDeviceInfo.d.ts +0 -7
  300. package/dist/api/protocol-v2/DeviceGetDeviceInfo.d.ts.map +0 -1
  301. package/dist/api/protocol-v2/DeviceGetFirmwareUpdateStatus.d.ts +0 -6
  302. package/dist/api/protocol-v2/DeviceGetFirmwareUpdateStatus.d.ts.map +0 -1
  303. package/dist/api/protocol-v2/DeviceGetOnboardingStatus.d.ts +0 -6
  304. package/dist/api/protocol-v2/DeviceGetOnboardingStatus.d.ts.map +0 -1
  305. package/dist/api/protocol-v2/DeviceReboot.d.ts +0 -7
  306. package/dist/api/protocol-v2/DeviceReboot.d.ts.map +0 -1
  307. package/dist/api/protocol-v2/FactoryDeviceInfoSettings.d.ts +0 -7
  308. package/dist/api/protocol-v2/FactoryDeviceInfoSettings.d.ts.map +0 -1
  309. package/dist/api/protocol-v2/FactoryGetDeviceInfo.d.ts +0 -6
  310. package/dist/api/protocol-v2/FactoryGetDeviceInfo.d.ts.map +0 -1
  311. package/dist/api/protocol-v2/FilesystemDiskControl.d.ts +0 -10
  312. package/dist/api/protocol-v2/FilesystemDiskControl.d.ts.map +0 -1
  313. package/dist/api/protocol-v2/FilesystemFixPermission.d.ts +0 -6
  314. package/dist/api/protocol-v2/FilesystemFixPermission.d.ts.map +0 -1
  315. package/dist/api/protocol-v2/FilesystemFormat.d.ts +0 -6
  316. package/dist/api/protocol-v2/FilesystemFormat.d.ts.map +0 -1
  317. package/dist/api/protocol-v2/GetProtoVersion.d.ts +0 -6
  318. package/dist/api/protocol-v2/GetProtoVersion.d.ts.map +0 -1
  319. package/dist/api/protocol-v2/Ping.d.ts +0 -8
  320. package/dist/api/protocol-v2/Ping.d.ts.map +0 -1
  321. package/dist/api/protocol-v2/helpers.d.ts +0 -49
  322. package/dist/api/protocol-v2/helpers.d.ts.map +0 -1
  323. package/dist/protocols/protocol-v2/features.d.ts +0 -104
  324. package/dist/protocols/protocol-v2/features.d.ts.map +0 -1
  325. package/dist/protocols/protocol-v2/firmware.d.ts +0 -12
  326. package/dist/protocols/protocol-v2/firmware.d.ts.map +0 -1
  327. package/dist/protocols/protocol-v2/index.d.ts +0 -3
  328. package/dist/protocols/protocol-v2/index.d.ts.map +0 -1
  329. package/dist/types/api/getDeviceInfo.d.ts +0 -84
  330. package/dist/types/api/getDeviceInfo.d.ts.map +0 -1
  331. package/dist/types/api/protocolV2.d.ts +0 -127
  332. package/dist/types/api/protocolV2.d.ts.map +0 -1
  333. package/src/api/DirList.ts +0 -29
  334. package/src/api/DirMake.ts +0 -21
  335. package/src/api/DirRemove.ts +0 -21
  336. package/src/api/FileDelete.ts +0 -21
  337. package/src/api/FileRead.ts +0 -165
  338. package/src/api/FileWrite.ts +0 -203
  339. package/src/api/FirmwareUpdateV4.ts +0 -810
  340. package/src/api/GetDeviceInfo.ts +0 -161
  341. package/src/api/PathInfo.ts +0 -25
  342. package/src/api/helpers/deviceInfo.ts +0 -205
  343. package/src/api/helpers/filesystemValidation.ts +0 -51
  344. package/src/api/protocol-v2/DeviceFirmwareUpdate.ts +0 -50
  345. package/src/api/protocol-v2/DeviceGetDeviceInfo.ts +0 -35
  346. package/src/api/protocol-v2/DeviceGetFirmwareUpdateStatus.ts +0 -18
  347. package/src/api/protocol-v2/DeviceGetOnboardingStatus.ts +0 -18
  348. package/src/api/protocol-v2/DeviceReboot.ts +0 -22
  349. package/src/api/protocol-v2/FactoryDeviceInfoSettings.ts +0 -27
  350. package/src/api/protocol-v2/FactoryGetDeviceInfo.ts +0 -18
  351. package/src/api/protocol-v2/FilesystemDiskControl.ts +0 -34
  352. package/src/api/protocol-v2/FilesystemFixPermission.ts +0 -14
  353. package/src/api/protocol-v2/FilesystemFormat.ts +0 -14
  354. package/src/api/protocol-v2/GetProtoVersion.ts +0 -14
  355. package/src/api/protocol-v2/Ping.ts +0 -16
  356. package/src/api/protocol-v2/helpers.ts +0 -161
  357. package/src/data/messages/messages-protocol-v2.json +0 -13128
  358. package/src/protocols/protocol-v2/features.ts +0 -287
  359. package/src/protocols/protocol-v2/firmware.ts +0 -26
  360. package/src/protocols/protocol-v2/index.ts +0 -2
  361. package/src/types/api/getDeviceInfo.ts +0 -97
  362. package/src/types/api/protocolV2.ts +0 -226
@@ -41,7 +41,6 @@ import { DataManager } from '../data-manager';
41
41
  import TransportManager from '../data-manager/TransportManager';
42
42
  import { toHardened } from '../api/helpers/pathUtils';
43
43
  import { existCapability } from '../utils/capabilitieUtils';
44
- import { getProtocolV2Features } from '../protocols/protocol-v2';
45
44
 
46
45
  import type { PROTO } from '../constants';
47
46
  import type {
@@ -50,7 +49,7 @@ import type {
50
49
  PassphraseRequestPayload,
51
50
  } from '../events';
52
51
  import type { PassphrasePromptResponse } from './DeviceCommands';
53
- import type { Deferred, HardwareConnectProtocol } from '@onekeyfe/hd-shared';
52
+ import type { Deferred } from '@onekeyfe/hd-shared';
54
53
  import type { OneKeyDeviceInfo as DeviceDescriptor } from '@onekeyfe/hd-transport';
55
54
  import type DeviceConnector from './DeviceConnector';
56
55
 
@@ -59,11 +58,11 @@ export type InitOptions = {
59
58
  deviceId?: string;
60
59
  passphraseState?: string;
61
60
  deriveCardano?: boolean;
62
- connectProtocol?: HardwareConnectProtocol;
63
61
  };
64
62
 
65
63
  export type RunOptions = {
66
64
  keepSession?: boolean;
65
+ skipInitialize?: boolean;
67
66
  } & InitOptions;
68
67
 
69
68
  const parseRunOptions = (options?: RunOptions): RunOptions => {
@@ -198,6 +197,17 @@ export class Device extends EventEmitter {
198
197
 
199
198
  pendingCallbackPromise?: Deferred<void>;
200
199
 
200
+ /** Pre-initialize timestamp (ms) */
201
+ private preInitializedAt?: number;
202
+
203
+ /** Pre-initialize context, used to verify state consistency before skipping */
204
+ private preInitializeMeta?: {
205
+ passphraseState?: string;
206
+ };
207
+
208
+ /** Last Initialize duration (ms), reported as "saved" when a skip happens */
209
+ private lastInitializeDurationMs?: number;
210
+
201
211
  constructor(descriptor: DeviceDescriptor, sdkInstanceId?: string) {
202
212
  super();
203
213
  this.originalDescriptor = descriptor;
@@ -254,13 +264,13 @@ export class Device extends EventEmitter {
254
264
  * Device connect
255
265
  * @returns {Promise<boolean>}
256
266
  */
257
- connect(connectProtocol?: HardwareConnectProtocol) {
267
+ connect() {
258
268
  const env = DataManager.getSettings('env');
259
269
  // eslint-disable-next-line no-async-promise-executor
260
270
  return new Promise<boolean>(async (resolve, reject) => {
261
271
  if (DataManager.isBleConnect(env)) {
262
272
  try {
263
- await this.acquire(connectProtocol);
273
+ await this.acquire();
264
274
  resolve(true);
265
275
  } catch (error) {
266
276
  reject(error);
@@ -270,7 +280,7 @@ export class Device extends EventEmitter {
270
280
  // 不存在 Session ID 或存在 Session ID 但设备在别处使用,都需要 acquire 获取最新 sessionID
271
281
  if (!this.mainId || (!this.isUsedHere() && this.originalDescriptor)) {
272
282
  try {
273
- await this.acquire(connectProtocol);
283
+ await this.acquire();
274
284
  resolve(true);
275
285
  } catch (error) {
276
286
  reject(error);
@@ -285,44 +295,23 @@ export class Device extends EventEmitter {
285
295
  });
286
296
  }
287
297
 
288
- async acquire(connectProtocol?: HardwareConnectProtocol) {
298
+ async acquire() {
289
299
  const env = DataManager.getSettings('env');
290
300
  const mainIdKey = DataManager.isBleConnect(env) ? 'id' : 'session';
291
- const expectedProtocol = connectProtocol ?? this.originalDescriptor.protocolType;
292
301
  try {
293
- let acquireResult: unknown;
294
302
  if (DataManager.isBleConnect(env)) {
295
- acquireResult = await this.deviceConnector?.acquire(
296
- this.originalDescriptor.id,
297
- undefined,
298
- true,
299
- expectedProtocol
300
- );
301
- this.mainId = (acquireResult as any)?.uuid ?? '';
303
+ const res = await this.deviceConnector?.acquire(this.originalDescriptor.id);
304
+ this.mainId = (res as unknown as any).uuid ?? '';
302
305
  Log.debug('Expected uuid:', this.mainId);
303
306
  } else {
304
- acquireResult = await this.deviceConnector?.acquire(
307
+ this.mainId = await this.deviceConnector?.acquire(
305
308
  this.originalDescriptor.path,
306
- this.originalDescriptor.session,
307
- undefined,
308
- expectedProtocol
309
+ this.originalDescriptor.session
309
310
  );
310
- this.mainId = acquireResult as string | undefined;
311
311
  Log.debug('Expected session id:', this.mainId);
312
312
  }
313
313
  this.deviceAcquired = true;
314
314
  this.updateDescriptor({ [mainIdKey]: this.mainId } as unknown as DeviceDescriptor);
315
-
316
- // Propagate protocol version detected during acquire.
317
- const detectedProtocol =
318
- (acquireResult as { protocolType?: HardwareConnectProtocol } | undefined)?.protocolType ??
319
- TransportManager.transport?.getProtocolType?.(
320
- DataManager.isBleConnect(env) ? this.originalDescriptor.id : this.originalDescriptor.path
321
- );
322
- if (detectedProtocol) {
323
- this.originalDescriptor.protocolType = detectedProtocol;
324
- }
325
-
326
315
  if (this.commands) {
327
316
  await this.commands.dispose(false);
328
317
  }
@@ -378,6 +367,54 @@ export class Device extends EventEmitter {
378
367
  this.deviceAcquired = false;
379
368
  }
380
369
 
370
+ /**
371
+ * Pre-initialize: connect + Initialize ahead of the sign. Only runs the
372
+ * fallback init when features are missing (gate on `!this.features`, not
373
+ * isUsedHere which is always false on BLE); otherwise just records the mark.
374
+ */
375
+ async preInitialize(initOptions?: InitOptions) {
376
+ if (!this.features) {
377
+ await this.acquire();
378
+ await this.initialize(initOptions);
379
+ }
380
+ this.markPreInitialized({
381
+ passphraseState: initOptions?.passphraseState,
382
+ });
383
+ }
384
+
385
+ markPreInitialized(meta?: { passphraseState?: string }) {
386
+ this.preInitializedAt = Date.now();
387
+ this.preInitializeMeta = meta
388
+ ? {
389
+ passphraseState: meta.passphraseState === '' ? undefined : meta.passphraseState,
390
+ }
391
+ : undefined;
392
+ }
393
+
394
+ clearPreInitialized() {
395
+ this.preInitializedAt = undefined;
396
+ this.preInitializeMeta = undefined;
397
+ }
398
+
399
+ isPreInitializeMetaMatch(payload?: { passphraseState?: string }) {
400
+ if (!this.preInitializeMeta) return true;
401
+ const passphraseState = payload?.passphraseState === '' ? undefined : payload?.passphraseState;
402
+ return this.preInitializeMeta.passphraseState === passphraseState;
403
+ }
404
+
405
+ isPreInitializedValid(ttlMs: number) {
406
+ if (!this.preInitializedAt) return false;
407
+ return Date.now() - this.preInitializedAt <= ttlMs;
408
+ }
409
+
410
+ setLastInitializeDuration(durationMs: number) {
411
+ this.lastInitializeDurationMs = durationMs;
412
+ }
413
+
414
+ getLastInitializeDuration() {
415
+ return this.lastInitializeDurationMs;
416
+ }
417
+
381
418
  getCommands() {
382
419
  return this.commands;
383
420
  }
@@ -485,17 +522,6 @@ export class Device extends EventEmitter {
485
522
  }
486
523
 
487
524
  async initialize(options?: InitOptions) {
488
- // Protocol V2 不支持传统 Initialize,直接使用协议专用初始化流程。
489
- if (this.originalDescriptor.protocolType === 'V2') {
490
- this.passphraseState = options?.passphraseState;
491
- if (this.features && !this.featuresNeedsReload && !options?.initSession) {
492
- Log.debug('Skip Protocol V2 feature adapter; cached features are available');
493
- return;
494
- }
495
- await this._initializeProtocolV2();
496
- return;
497
- }
498
-
499
525
  // Log.debug('initialize param:', options);
500
526
 
501
527
  this.passphraseState = options?.passphraseState;
@@ -516,13 +542,7 @@ export class Device extends EventEmitter {
516
542
  payload.passphrase_state = options?.passphraseState;
517
543
  payload.is_contains_attach = true;
518
544
 
519
- Log.debug('Initialize device begin:', {
520
- deviceId: options?.deviceId,
521
- passphraseState: options?.passphraseState,
522
- initSession: options?.initSession,
523
- InitializePayload: payload,
524
- });
525
-
545
+ const initStartAt = Date.now();
526
546
  try {
527
547
  // @ts-expect-error
528
548
  const { message } = await Promise.race([
@@ -535,7 +555,8 @@ export class Device extends EventEmitter {
535
555
  }),
536
556
  ]);
537
557
 
538
- Log.debug('Initialize device end: ', message);
558
+ const initCostMs = Date.now() - initStartAt;
559
+ this.setLastInitializeDuration(initCostMs);
539
560
  this._updateFeatures(message, options?.initSession);
540
561
  await TransportManager.reconfigure(this.features);
541
562
  } catch (error) {
@@ -544,36 +565,6 @@ export class Device extends EventEmitter {
544
565
  }
545
566
  }
546
567
 
547
- /**
548
- * Device initialization over Protocol V2.
549
- *
550
- * Protocol V2 不走传统 Initialize/GetFeatures,直接用轻量 DeviceGetDeviceInfo
551
- * 归一成 legacy-style Features 视图。
552
- */
553
- private async _initializeProtocolV2() {
554
- Log.debug('Initialize device via Protocol V2 feature adapter');
555
-
556
- try {
557
- const features = await Promise.race([
558
- getProtocolV2Features({
559
- commands: this.commands,
560
- descriptor: this.originalDescriptor,
561
- timeoutMs: 10 * 1000,
562
- }),
563
- new Promise<never>((_, reject) => {
564
- setTimeout(() => {
565
- reject(ERRORS.TypedError(HardwareErrorCode.DeviceInitializeFailed));
566
- }, 10 * 1000);
567
- }),
568
- ]);
569
- Log.debug('Protocol V2 normalized features:', features);
570
- this._updateFeatures(features);
571
- } catch (error) {
572
- Log.error('Protocol V2 initialization failed:', error);
573
- throw error;
574
- }
575
- }
576
-
577
568
  async getFeatures() {
578
569
  const { message } = await this.commands.typedCall('GetFeatures', 'Features', {});
579
570
  this._updateFeatures(message);
@@ -644,7 +635,7 @@ export class Device extends EventEmitter {
644
635
  const env = DataManager.getSettings('env');
645
636
  if (env !== 'react-native') {
646
637
  try {
647
- await this.acquire(options.connectProtocol);
638
+ await this.acquire();
648
639
  } catch (error) {
649
640
  this.runPromise = null;
650
641
  return Promise.reject(error);
@@ -652,7 +643,9 @@ export class Device extends EventEmitter {
652
643
 
653
644
  try {
654
645
  if (fn) {
655
- await this.initialize(options);
646
+ if (!options?.skipInitialize) {
647
+ await this.initialize(options);
648
+ }
656
649
  }
657
650
  } catch (error) {
658
651
  this.runPromise = null;
@@ -886,13 +879,9 @@ export class Device extends EventEmitter {
886
879
  this.features,
887
880
  Enum_Capability.Capability_AttachToPin
888
881
  );
889
- const isPro2 = getDeviceType(this.features) === EDeviceType.Pro2;
890
882
 
891
883
  const supportUnlock =
892
- supportAttachPinCapability ||
893
- // Pro2 V2 暂未从 features 暴露 capabilities,先直连该方法用于固件联调。
894
- isPro2 ||
895
- (versionRange && semver.gte(firmwareVersion, versionRange.min));
884
+ supportAttachPinCapability || (versionRange && semver.gte(firmwareVersion, versionRange.min));
896
885
 
897
886
  if (supportUnlock) {
898
887
  const res = await this.commands.typedCall('UnLockDevice', 'UnLockDeviceResponse');
@@ -12,12 +12,7 @@ import {
12
12
  } from '../utils/tracing';
13
13
 
14
14
  import type { Device } from './Device';
15
- import type {
16
- FailureType,
17
- Messages,
18
- Transport,
19
- TransportCallOptions,
20
- } from '@onekeyfe/hd-transport';
15
+ import type { FailureType, Messages, Transport } from '@onekeyfe/hd-transport';
21
16
 
22
17
  export type PassphrasePromptResponse = {
23
18
  passphrase?: string;
@@ -27,119 +22,16 @@ export type PassphrasePromptResponse = {
27
22
  };
28
23
 
29
24
  type MessageType = Messages.MessageType;
30
- type MessageKey = Extract<keyof MessageType, string>;
25
+ type MessageKey = keyof MessageType;
31
26
  export type TypedResponseMessage<T extends MessageKey> = {
32
27
  type: T;
33
28
  message: MessageType[T];
34
29
  };
35
30
  type TypedCallResponseMap = {
36
- [K in MessageKey]: TypedResponseMessage<K>;
31
+ [K in keyof MessageType]: TypedResponseMessage<K>;
37
32
  };
38
33
  export type DefaultMessageResponse = TypedCallResponseMap[keyof MessageType];
39
34
 
40
- const MAX_DEBUG_ARRAY_ITEMS = 20;
41
- const MAX_DEBUG_OBJECT_KEYS = 40;
42
- const MAX_DEBUG_STRING_LENGTH = 512;
43
- const MAX_DEBUG_DEPTH = 4;
44
- const HIGH_VOLUME_DEBUG_CALLS = new Set([
45
- 'FilesystemFileRead',
46
- 'FilesystemFileWrite',
47
- 'FileRead',
48
- 'FileWrite',
49
- 'EmmcFileRead',
50
- 'EmmcFileWrite',
51
- 'FirmwareUpload',
52
- 'ResourceAck',
53
- ]);
54
-
55
- function shouldReduceDebugForCall(type: string) {
56
- return HIGH_VOLUME_DEBUG_CALLS.has(type);
57
- }
58
-
59
- function getBinaryByteLength(value: unknown): number | undefined {
60
- if (value instanceof ArrayBuffer) {
61
- return value.byteLength;
62
- }
63
-
64
- if (ArrayBuffer.isView(value)) {
65
- return value.byteLength;
66
- }
67
-
68
- if (typeof Blob !== 'undefined' && value instanceof Blob) {
69
- return value.size;
70
- }
71
-
72
- return undefined;
73
- }
74
-
75
- function summarizeRedactedData(value: unknown): string {
76
- const byteLength = getBinaryByteLength(value);
77
- if (byteLength !== undefined) {
78
- return `[redacted data: ${byteLength} bytes]`;
79
- }
80
-
81
- if (typeof value === 'string') {
82
- return `[redacted data: string length=${value.length}]`;
83
- }
84
-
85
- if (Array.isArray(value)) {
86
- return `[redacted data: array length=${value.length}]`;
87
- }
88
-
89
- if (value && typeof value === 'object') {
90
- return `[redacted data: object keys=${Object.keys(value).length}]`;
91
- }
92
-
93
- return `[redacted data: ${typeof value}]`;
94
- }
95
-
96
- function sanitizeDebugPayload(value: unknown, key = '', depth = 0): unknown {
97
- if (key === 'data' && value !== null && value !== undefined) {
98
- return summarizeRedactedData(value);
99
- }
100
-
101
- const byteLength = getBinaryByteLength(value);
102
- if (byteLength !== undefined) {
103
- return `[binary: ${byteLength} bytes]`;
104
- }
105
-
106
- if (typeof value === 'string') {
107
- return value.length > MAX_DEBUG_STRING_LENGTH
108
- ? `${value.slice(0, MAX_DEBUG_STRING_LENGTH)}... (len=${value.length})`
109
- : value;
110
- }
111
-
112
- if (!value || typeof value !== 'object') {
113
- return value;
114
- }
115
-
116
- if (depth >= MAX_DEBUG_DEPTH) {
117
- return Array.isArray(value)
118
- ? `[array length=${value.length}]`
119
- : `[object keys=${Object.keys(value).length}]`;
120
- }
121
-
122
- if (Array.isArray(value)) {
123
- const items = value
124
- .slice(0, MAX_DEBUG_ARRAY_ITEMS)
125
- .map(item => sanitizeDebugPayload(item, key, depth + 1));
126
- if (value.length > MAX_DEBUG_ARRAY_ITEMS) {
127
- items.push(`... (${value.length - MAX_DEBUG_ARRAY_ITEMS} more)`);
128
- }
129
- return items;
130
- }
131
-
132
- const entries = Object.entries(value).slice(0, MAX_DEBUG_OBJECT_KEYS);
133
- const sanitized: Record<string, unknown> = {};
134
- entries.forEach(([entryKey, entryValue]) => {
135
- sanitized[entryKey] = sanitizeDebugPayload(entryValue, entryKey, depth + 1);
136
- });
137
- if (Object.keys(value).length > MAX_DEBUG_OBJECT_KEYS) {
138
- sanitized.__truncated__ = `${Object.keys(value).length - MAX_DEBUG_OBJECT_KEYS} more keys`;
139
- }
140
- return sanitized;
141
- }
142
-
143
35
  const assertType = (res: DefaultMessageResponse, resType: string | string[]) => {
144
36
  const splitResTypes = Array.isArray(resType) ? resType : resType.split('|');
145
37
  if (!splitResTypes.includes(res.type)) {
@@ -332,21 +224,17 @@ export class DeviceCommands {
332
224
  // Sends an async message to the opened device.
333
225
  async call(
334
226
  type: MessageKey,
335
- msg?: DefaultMessageResponse['message'],
336
- options?: TransportCallOptions
227
+ msg: DefaultMessageResponse['message'] = {}
337
228
  ): Promise<DefaultMessageResponse> {
338
- const shouldReduceDebug = shouldReduceDebugForCall(type);
339
- if (!shouldReduceDebug) {
340
- Log.debug('[DeviceCommands] [call] Sending', type);
341
- }
229
+ Log.debug('[DeviceCommands] [call] Sending', type);
342
230
 
343
231
  try {
344
- const promise = this.transport.call(this.mainId, type, msg ?? {}, options) as any;
232
+ const promise = this.transport.call(this.mainId, type, msg) as any;
345
233
  this.callPromise = promise;
346
234
  const res = await promise;
347
235
  if (res.type === 'Failure') {
348
236
  LogCore.debug('[DeviceCommands] [call] Received', res.type, res.message);
349
- } else if (!shouldReduceDebug) {
237
+ } else {
350
238
  LogCore.debug('[DeviceCommands] [call] Received', res.type);
351
239
  }
352
240
  return res;
@@ -395,22 +283,19 @@ export class DeviceCommands {
395
283
  typedCall<T extends MessageKey, R extends MessageKey[]>(
396
284
  type: T,
397
285
  resType: R,
398
- msg?: MessageType[T],
399
- options?: TransportCallOptions
286
+ msg?: MessageType[T]
400
287
  ): Promise<TypedCallResponseMap[R[number]]>;
401
288
 
402
289
  typedCall<T extends MessageKey, R extends MessageKey>(
403
290
  type: T,
404
291
  resType: R,
405
- msg?: MessageType[T],
406
- options?: TransportCallOptions
292
+ msg?: MessageType[T]
407
293
  ): Promise<TypedResponseMessage<R>>;
408
294
 
409
295
  async typedCall(
410
296
  type: MessageKey,
411
297
  resType: MessageKey | MessageKey[],
412
- msg?: DefaultMessageResponse['message'],
413
- options?: TransportCallOptions
298
+ msg?: DefaultMessageResponse['message']
414
299
  ) {
415
300
  if (this.disposed) {
416
301
  throw ERRORS.TypedError(
@@ -427,28 +312,16 @@ export class DeviceCommands {
427
312
  'PassphraseAck',
428
313
  'Cancel',
429
314
  'BixinPinInputOnDevice',
430
- 'FilesystemFileRead',
431
- 'FilesystemFileWrite',
432
- 'FileRead',
433
- 'FileWrite',
434
- 'EmmcFileRead',
435
- 'EmmcFileWrite',
436
- 'FirmwareUpload',
437
- 'ResourceAck',
438
315
  ] as any;
439
316
  if (!skipTypes.includes(type) && msg) {
440
317
  // Use debug channel to avoid noise escalation
441
- Log.debug('[DeviceCommands] [typedCall] Sending payload', type, sanitizeDebugPayload(msg));
318
+ Log.debug('[DeviceCommands] [typedCall] Sending payload', type, msg);
442
319
  }
443
320
  } catch (e) {
444
321
  // ignore logging errors
445
322
  }
446
323
 
447
- const expectedTypes = Array.isArray(resType) ? resType : resType.split('|');
448
- const response = await this._commonCall(type, msg, {
449
- ...options,
450
- expectedTypes: options?.expectedTypes ?? expectedTypes,
451
- });
324
+ const response = await this._commonCall(type, msg);
452
325
  try {
453
326
  assertType(response, resType);
454
327
  } catch (error) {
@@ -461,12 +334,6 @@ export class DeviceCommands {
461
334
  // throw bridge network error
462
335
  if (error instanceof HardwareError) {
463
336
  if (error.errorCode === HardwareErrorCode.ResponseUnexpectTypeError) {
464
- Log.debug('[DeviceCommands] [typedCall] Unexpected response type', {
465
- request: type,
466
- expected: resType,
467
- received: response.type,
468
- response: sanitizeDebugPayload(response.message),
469
- });
470
337
  // Do not intercept CallMethodError
471
338
  // Do not intercept “assertType: Response of unexpected type” error
472
339
  // Blocking the above two messages will not know what the specific error message is, and the specific error should be handled by the subsequent business logic.
@@ -480,7 +347,7 @@ export class DeviceCommands {
480
347
  if (error.message.indexOf('BridgeDeviceDisconnected') > -1) {
481
348
  throw ERRORS.TypedError(HardwareErrorCode.BridgeDeviceDisconnected);
482
349
  }
483
- throw error;
350
+ throw ERRORS.TypedError(HardwareErrorCode.ResponseUnexpectTypeError);
484
351
  }
485
352
  } else {
486
353
  // throw error anyway, next call should be resolved properly// throw error anyway, next call should be resolved properly
@@ -490,27 +357,20 @@ export class DeviceCommands {
490
357
  return response;
491
358
  }
492
359
 
493
- async _commonCall(
494
- type: MessageKey,
495
- msg?: DefaultMessageResponse['message'],
496
- options?: TransportCallOptions
497
- ) {
498
- const resp = await this.call(type, msg, options);
499
- return this._filterCommonTypes(resp, type, options);
360
+ async _commonCall(type: MessageKey, msg?: DefaultMessageResponse['message']) {
361
+ const resp = await this.call(type, msg);
362
+ return this._filterCommonTypes(resp, type);
500
363
  }
501
364
 
502
365
  _filterCommonTypes(
503
366
  res: DefaultMessageResponse,
504
- callType: MessageKey,
505
- options?: TransportCallOptions
367
+ callType: MessageKey
506
368
  ): Promise<DefaultMessageResponse> {
507
369
  try {
508
- if (shouldReduceDebugForCall(callType)) {
509
- // 高频文件写入每个 chunk 都会经过这里,避免 debug log 反向拖慢传输。
510
- } else if (DataManager.getSettings('env') === 'react-native') {
511
- Log.debug('_filterCommonTypes: ', JSON.stringify(sanitizeDebugPayload(res)));
370
+ if (DataManager.getSettings('env') === 'react-native') {
371
+ Log.debug('_filterCommonTypes: ', JSON.stringify(res));
512
372
  } else {
513
- Log.debug('_filterCommonTypes: ', sanitizeDebugPayload(res));
373
+ Log.debug('_filterCommonTypes: ', res);
514
374
  }
515
375
  } catch (error) {
516
376
  // ignore
@@ -612,7 +472,7 @@ export class DeviceCommands {
612
472
  } else {
613
473
  this.device.emit(DEVICE.BUTTON, this.device, res.message);
614
474
  }
615
- return this._commonCall('ButtonAck', {}, options);
475
+ return this._commonCall('ButtonAck', {});
616
476
  }
617
477
 
618
478
  if (res.type === 'EntropyRequest') {
@@ -625,11 +485,11 @@ export class DeviceCommands {
625
485
  if (pin === '@@ONEKEY_INPUT_PIN_IN_DEVICE') {
626
486
  // only classic\1s\mini\pure
627
487
  this.device.setCancelableAction(() => this.cancelDeviceOnOneKeyDevice());
628
- return this._commonCall('BixinPinInputOnDevice', {}, options).finally(() => {
488
+ return this._commonCall('BixinPinInputOnDevice').finally(() => {
629
489
  this.device.clearCancelableAction();
630
490
  });
631
491
  }
632
- return this._commonCall('PinMatrixAck', { pin }, options);
492
+ return this._commonCall('PinMatrixAck', { pin });
633
493
  },
634
494
  error => Promise.reject(error)
635
495
  );
@@ -644,12 +504,12 @@ export class DeviceCommands {
644
504
 
645
505
  // Attach PIN on device
646
506
  if (attachPinOnDevice && existsAttachPinUser) {
647
- return this._commonCall('PassphraseAck', { on_device_attach_pin: true }, options);
507
+ return this._commonCall('PassphraseAck', { on_device_attach_pin: true });
648
508
  }
649
509
 
650
510
  return !passphraseOnDevice
651
- ? this._commonCall('PassphraseAck', { passphrase }, options)
652
- : this._commonCall('PassphraseAck', { on_device: true }, options);
511
+ ? this._commonCall('PassphraseAck', { passphrase })
512
+ : this._commonCall('PassphraseAck', { on_device: true });
653
513
  });
654
514
  }
655
515
 
@@ -1,5 +1,3 @@
1
- import { ERRORS, HardwareErrorCode } from '@onekeyfe/hd-shared';
2
-
3
1
  import { safeThrowError } from '../constants';
4
2
  import { DataManager } from '../data-manager';
5
3
  import TransportManager from '../data-manager/TransportManager';
@@ -8,7 +6,6 @@ import { resolveAfter } from '../utils/promiseUtils';
8
6
  import { LoggerNames, getLogger } from '../utils';
9
7
 
10
8
  import type { DeviceDescriptorDiff } from './DevicePool';
11
- import type { HardwareConnectProtocol } from '@onekeyfe/hd-shared';
12
9
  import type { OneKeyDeviceInfo as DeviceDescriptor, Transport } from '@onekeyfe/hd-transport';
13
10
 
14
11
  const Log = getLogger(LoggerNames.DeviceConnector);
@@ -78,37 +75,15 @@ export default class DeviceConnector {
78
75
  this.listening = false;
79
76
  }
80
77
 
81
- async acquire(
82
- path: string,
83
- session?: string | null,
84
- forceCleanRunPromise?: boolean,
85
- connectProtocol?: HardwareConnectProtocol
86
- ) {
87
- Log.debug('acquire', path, session, connectProtocol);
78
+ async acquire(path: string, session?: string | null, forceCleanRunPromise?: boolean) {
79
+ Log.debug('acquire', path, session);
88
80
  const env = DataManager.getSettings('env');
89
81
  try {
90
82
  let res;
91
83
  if (DataManager.isBleConnect(env)) {
92
- res = await this.transport.acquire({
93
- uuid: path,
94
- forceCleanRunPromise,
95
- expectedProtocol: connectProtocol,
96
- });
84
+ res = await this.transport.acquire({ uuid: path, forceCleanRunPromise });
97
85
  } else {
98
- res = await this.transport.acquire({
99
- path,
100
- previous: session ?? null,
101
- expectedProtocol: connectProtocol,
102
- });
103
- }
104
- if (connectProtocol) {
105
- const detectedProtocol = this.transport.getProtocolType(path);
106
- if (detectedProtocol !== connectProtocol) {
107
- throw ERRORS.TypedError(
108
- HardwareErrorCode.RuntimeError,
109
- `Device protocol mismatch: expected ${connectProtocol}, detected ${detectedProtocol}`
110
- );
111
- }
86
+ res = await this.transport.acquire({ path, previous: session ?? null });
112
87
  }
113
88
  return res;
114
89
  } catch (error) {
@@ -150,7 +150,7 @@ export class DevicePool extends EventEmitter {
150
150
  if (!device) {
151
151
  device = Device.fromDescriptor(descriptor);
152
152
  device.deviceConnector = this.connector;
153
- await device.connect(initOptions?.connectProtocol);
153
+ await device.connect();
154
154
  await device.initialize(initOptions);
155
155
  await device.release();
156
156
  }
@@ -129,10 +129,6 @@ export interface FirmwareProgress {
129
129
  device: Device;
130
130
  progress: number;
131
131
  progressType: IFirmwareUpdateProgressType;
132
- transferredBytes?: number;
133
- totalBytes?: number;
134
- rateBytesPerSecond?: number;
135
- elapsedMs?: number;
136
132
  };
137
133
  }
138
134
 
@@ -148,10 +144,6 @@ export interface DeviceProgress {
148
144
  type: typeof UI_REQUEST.DEVICE_PROGRESS;
149
145
  payload: {
150
146
  progress?: number;
151
- transferredBytes?: number;
152
- totalBytes?: number;
153
- rateBytesPerSecond?: number;
154
- elapsedMs?: number;
155
147
  };
156
148
  }
157
149