@onekeyfe/hd-core 1.1.27-alpha.35 → 1.1.27-alpha.4

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 (351) 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/SolSignMessage.d.ts.map +1 -1
  100. package/dist/api/solana/SolSignOffchainMessage.d.ts.map +1 -1
  101. package/dist/api/solana/SolSignTransaction.d.ts.map +1 -1
  102. package/dist/api/starcoin/StarcoinSignMessage.d.ts.map +1 -1
  103. package/dist/api/starcoin/StarcoinSignTransaction.d.ts.map +1 -1
  104. package/dist/api/stellar/StellarGetAddress.d.ts +1 -2
  105. package/dist/api/stellar/StellarGetAddress.d.ts.map +1 -1
  106. package/dist/api/stellar/StellarSignTransaction.d.ts +1 -2
  107. package/dist/api/stellar/StellarSignTransaction.d.ts.map +1 -1
  108. package/dist/api/sui/SuiSignMessage.d.ts.map +1 -1
  109. package/dist/api/sui/SuiSignTransaction.d.ts +2 -2
  110. package/dist/api/sui/SuiSignTransaction.d.ts.map +1 -1
  111. package/dist/api/ton/TonSignData.d.ts.map +1 -1
  112. package/dist/api/ton/TonSignMessage.d.ts.map +1 -1
  113. package/dist/api/ton/TonSignProof.d.ts.map +1 -1
  114. package/dist/api/tron/TronSignMessage.d.ts.map +1 -1
  115. package/dist/api/tron/TronSignTransaction.d.ts.map +1 -1
  116. package/dist/api/xrp/XrpSignTransaction.d.ts.map +1 -1
  117. package/dist/core/PollingStateManager.d.ts +8 -0
  118. package/dist/core/PollingStateManager.d.ts.map +1 -0
  119. package/dist/core/RequestQueue.d.ts +1 -1
  120. package/dist/core/RequestQueue.d.ts.map +1 -1
  121. package/dist/core/index.d.ts.map +1 -1
  122. package/dist/data-manager/DataManager.d.ts +4 -7
  123. package/dist/data-manager/DataManager.d.ts.map +1 -1
  124. package/dist/data-manager/MessagesConfig.d.ts +2 -2
  125. package/dist/data-manager/MessagesConfig.d.ts.map +1 -1
  126. package/dist/data-manager/TransportManager.d.ts +4 -5
  127. package/dist/data-manager/TransportManager.d.ts.map +1 -1
  128. package/dist/device/Device.d.ts +18 -5
  129. package/dist/device/Device.d.ts.map +1 -1
  130. package/dist/device/DeviceCommands.d.ts +8 -8
  131. package/dist/device/DeviceCommands.d.ts.map +1 -1
  132. package/dist/device/DeviceConnector.d.ts +1 -2
  133. package/dist/device/DeviceConnector.d.ts.map +1 -1
  134. package/dist/events/ui-request.d.ts +0 -8
  135. package/dist/events/ui-request.d.ts.map +1 -1
  136. package/dist/index.d.ts +43 -292
  137. package/dist/index.js +1002 -16133
  138. package/dist/inject.d.ts.map +1 -1
  139. package/dist/types/api/export.d.ts +1 -1
  140. package/dist/types/api/export.d.ts.map +1 -1
  141. package/dist/types/api/firmwareUpdate.d.ts +0 -7
  142. package/dist/types/api/firmwareUpdate.d.ts.map +1 -1
  143. package/dist/types/api/getPassphraseState.d.ts +1 -10
  144. package/dist/types/api/getPassphraseState.d.ts.map +1 -1
  145. package/dist/types/api/index.d.ts +3 -33
  146. package/dist/types/api/index.d.ts.map +1 -1
  147. package/dist/types/api/preInitialize.d.ts +3 -0
  148. package/dist/types/api/preInitialize.d.ts.map +1 -0
  149. package/dist/types/api/searchDevices.d.ts +2 -2
  150. package/dist/types/api/searchDevices.d.ts.map +1 -1
  151. package/dist/types/device.d.ts +2 -6
  152. package/dist/types/device.d.ts.map +1 -1
  153. package/dist/types/params.d.ts +1 -2
  154. package/dist/types/params.d.ts.map +1 -1
  155. package/dist/types/settings.d.ts +1 -1
  156. package/dist/types/settings.d.ts.map +1 -1
  157. package/dist/utils/deviceFeaturesUtils.d.ts +3 -5
  158. package/dist/utils/deviceFeaturesUtils.d.ts.map +1 -1
  159. package/dist/utils/deviceInfoUtils.d.ts +0 -1
  160. package/dist/utils/deviceInfoUtils.d.ts.map +1 -1
  161. package/dist/utils/index.d.ts +1 -1
  162. package/dist/utils/index.d.ts.map +1 -1
  163. package/dist/utils/patch.d.ts +1 -1
  164. package/dist/utils/patch.d.ts.map +1 -1
  165. package/dist/utils/versionUtils.d.ts +1 -1
  166. package/package.json +4 -4
  167. package/src/api/BaseMethod.ts +82 -7
  168. package/src/api/FirmwareUpdateV3.ts +4 -21
  169. package/src/api/GetOnekeyFeatures.ts +3 -75
  170. package/src/api/GetPassphraseState.ts +7 -16
  171. package/src/api/SearchDevices.ts +2 -7
  172. package/src/api/alephium/AlephiumGetAddress.ts +2 -6
  173. package/src/api/alephium/AlephiumSignMessage.ts +2 -6
  174. package/src/api/alephium/AlephiumSignTransaction.ts +3 -6
  175. package/src/api/algo/AlgoSignTransaction.ts +1 -0
  176. package/src/api/allnetwork/AllNetworkGetAddressBase.ts +9 -18
  177. package/src/api/aptos/AptosSignInMessage.ts +1 -0
  178. package/src/api/aptos/AptosSignMessage.ts +1 -0
  179. package/src/api/aptos/AptosSignTransaction.ts +1 -0
  180. package/src/api/benfen/BenfenGetAddress.ts +2 -6
  181. package/src/api/benfen/BenfenGetPublicKey.ts +2 -6
  182. package/src/api/benfen/BenfenSignMessage.ts +2 -6
  183. package/src/api/benfen/BenfenSignTransaction.ts +2 -6
  184. package/src/api/btc/BTCSignMessage.ts +1 -0
  185. package/src/api/btc/BTCSignPsbt.ts +1 -0
  186. package/src/api/btc/BTCSignTransaction.ts +1 -0
  187. package/src/api/btc/helpers/versionLimit.ts +1 -7
  188. package/src/api/cardano/CardanoSignMessage.ts +1 -0
  189. package/src/api/cardano/CardanoSignTransaction.ts +1 -0
  190. package/src/api/conflux/ConfluxSignMessage.ts +1 -0
  191. package/src/api/conflux/ConfluxSignMessageCIP23.ts +1 -0
  192. package/src/api/conflux/ConfluxSignTransaction.ts +3 -5
  193. package/src/api/cosmos/CosmosSignTransaction.ts +1 -0
  194. package/src/api/device/DeviceRebootToBoardloader.ts +1 -10
  195. package/src/api/device/DeviceRebootToBootloader.ts +1 -10
  196. package/src/api/device/PreInitialize.ts +41 -0
  197. package/src/api/dynex/DnxGetAddress.ts +0 -7
  198. package/src/api/dynex/DnxSignTransaction.ts +1 -7
  199. package/src/api/evm/EVMGetAddress.ts +1 -1
  200. package/src/api/evm/EVMGetPublicKey.ts +1 -1
  201. package/src/api/evm/EVMSignMessage.ts +3 -1
  202. package/src/api/evm/EVMSignMessageEIP712.ts +2 -14
  203. package/src/api/evm/EVMSignTransaction.ts +3 -1
  204. package/src/api/evm/EVMSignTypedData.ts +8 -6
  205. package/src/api/evm/EVMVerifyMessage.ts +1 -1
  206. package/src/api/filecoin/FilecoinSignTransaction.ts +1 -0
  207. package/src/api/firmware/FirmwareUpdateBaseMethod.ts +4 -27
  208. package/src/api/index.ts +1 -30
  209. package/src/api/kaspa/KaspaSignTransaction.ts +1 -0
  210. package/src/api/near/NearSignTransaction.ts +1 -0
  211. package/src/api/nem/NEMSignTransaction.ts +1 -0
  212. package/src/api/neo/NeoGetAddress.ts +1 -6
  213. package/src/api/neo/NeoSignTransaction.ts +2 -6
  214. package/src/api/nervos/NervosGetAddress.ts +2 -6
  215. package/src/api/nervos/NervosSignTransaction.ts +3 -6
  216. package/src/api/nexa/NexaGetAddress.ts +2 -6
  217. package/src/api/nexa/NexaSignTransaction.ts +4 -6
  218. package/src/api/nostr/NostrSignEvent.ts +1 -0
  219. package/src/api/nostr/NostrSignSchnorr.ts +1 -0
  220. package/src/api/polkadot/PolkadotSignTransaction.ts +1 -0
  221. package/src/api/scdo/ScdoGetAddress.ts +2 -6
  222. package/src/api/scdo/ScdoSignMessage.ts +2 -6
  223. package/src/api/scdo/ScdoSignTransaction.ts +3 -6
  224. package/src/api/solana/SolSignMessage.ts +1 -0
  225. package/src/api/solana/SolSignOffchainMessage.ts +1 -0
  226. package/src/api/solana/SolSignTransaction.ts +1 -0
  227. package/src/api/starcoin/StarcoinSignMessage.ts +1 -0
  228. package/src/api/starcoin/StarcoinSignTransaction.ts +1 -0
  229. package/src/api/stellar/StellarGetAddress.ts +1 -10
  230. package/src/api/stellar/StellarSignTransaction.ts +2 -14
  231. package/src/api/sui/SuiSignMessage.ts +1 -0
  232. package/src/api/sui/SuiSignTransaction.ts +10 -12
  233. package/src/api/ton/TonSignData.ts +1 -0
  234. package/src/api/ton/TonSignMessage.ts +1 -0
  235. package/src/api/ton/TonSignProof.ts +1 -0
  236. package/src/api/tron/TronSignMessage.ts +2 -1
  237. package/src/api/tron/TronSignTransaction.ts +1 -0
  238. package/src/api/xrp/XrpSignTransaction.ts +2 -1
  239. package/src/core/PollingStateManager.ts +47 -0
  240. package/src/core/RequestQueue.ts +10 -3
  241. package/src/core/index.ts +153 -62
  242. package/src/data-manager/DataManager.ts +7 -12
  243. package/src/data-manager/MessagesConfig.ts +14 -14
  244. package/src/data-manager/TransportManager.ts +12 -38
  245. package/src/device/Device.ts +75 -82
  246. package/src/device/DeviceCommands.ts +26 -162
  247. package/src/device/DeviceConnector.ts +4 -29
  248. package/src/device/DevicePool.ts +1 -1
  249. package/src/events/ui-request.ts +0 -8
  250. package/src/inject.ts +2 -46
  251. package/src/types/api/export.ts +0 -1
  252. package/src/types/api/firmwareUpdate.ts +0 -12
  253. package/src/types/api/getPassphraseState.ts +2 -13
  254. package/src/types/api/index.ts +3 -80
  255. package/src/types/api/preInitialize.ts +3 -0
  256. package/src/types/api/searchDevices.ts +2 -2
  257. package/src/types/device.ts +2 -33
  258. package/src/types/params.ts +2 -4
  259. package/src/types/settings.ts +1 -1
  260. package/src/utils/deviceFeaturesUtils.ts +21 -62
  261. package/src/utils/deviceInfoUtils.ts +8 -15
  262. package/src/utils/index.ts +0 -1
  263. package/__tests__/protocol-v2.test.ts +0 -1544
  264. package/dist/api/DirList.d.ts +0 -10
  265. package/dist/api/DirList.d.ts.map +0 -1
  266. package/dist/api/DirMake.d.ts +0 -9
  267. package/dist/api/DirMake.d.ts.map +0 -1
  268. package/dist/api/DirRemove.d.ts +0 -9
  269. package/dist/api/DirRemove.d.ts.map +0 -1
  270. package/dist/api/FileDelete.d.ts +0 -9
  271. package/dist/api/FileDelete.d.ts.map +0 -1
  272. package/dist/api/FileRead.d.ts +0 -19
  273. package/dist/api/FileRead.d.ts.map +0 -1
  274. package/dist/api/FileWrite.d.ts +0 -23
  275. package/dist/api/FileWrite.d.ts.map +0 -1
  276. package/dist/api/FirmwareUpdateV4.d.ts +0 -32
  277. package/dist/api/FirmwareUpdateV4.d.ts.map +0 -1
  278. package/dist/api/GetDeviceInfo.d.ts +0 -9
  279. package/dist/api/GetDeviceInfo.d.ts.map +0 -1
  280. package/dist/api/PathInfo.d.ts +0 -9
  281. package/dist/api/PathInfo.d.ts.map +0 -1
  282. package/dist/api/helpers/deviceInfo.d.ts +0 -15
  283. package/dist/api/helpers/deviceInfo.d.ts.map +0 -1
  284. package/dist/api/helpers/filesystemValidation.d.ts +0 -7
  285. package/dist/api/helpers/filesystemValidation.d.ts.map +0 -1
  286. package/dist/api/protocol-v2/DeviceFirmwareUpdate.d.ts +0 -7
  287. package/dist/api/protocol-v2/DeviceFirmwareUpdate.d.ts.map +0 -1
  288. package/dist/api/protocol-v2/DeviceGetDeviceInfo.d.ts +0 -7
  289. package/dist/api/protocol-v2/DeviceGetDeviceInfo.d.ts.map +0 -1
  290. package/dist/api/protocol-v2/DeviceGetFirmwareUpdateStatus.d.ts +0 -6
  291. package/dist/api/protocol-v2/DeviceGetFirmwareUpdateStatus.d.ts.map +0 -1
  292. package/dist/api/protocol-v2/DeviceGetOnboardingStatus.d.ts +0 -6
  293. package/dist/api/protocol-v2/DeviceGetOnboardingStatus.d.ts.map +0 -1
  294. package/dist/api/protocol-v2/DeviceReboot.d.ts +0 -7
  295. package/dist/api/protocol-v2/DeviceReboot.d.ts.map +0 -1
  296. package/dist/api/protocol-v2/FactoryDeviceInfoSettings.d.ts +0 -7
  297. package/dist/api/protocol-v2/FactoryDeviceInfoSettings.d.ts.map +0 -1
  298. package/dist/api/protocol-v2/FactoryGetDeviceInfo.d.ts +0 -6
  299. package/dist/api/protocol-v2/FactoryGetDeviceInfo.d.ts.map +0 -1
  300. package/dist/api/protocol-v2/FilesystemDiskControl.d.ts +0 -10
  301. package/dist/api/protocol-v2/FilesystemDiskControl.d.ts.map +0 -1
  302. package/dist/api/protocol-v2/FilesystemFixPermission.d.ts +0 -6
  303. package/dist/api/protocol-v2/FilesystemFixPermission.d.ts.map +0 -1
  304. package/dist/api/protocol-v2/FilesystemFormat.d.ts +0 -6
  305. package/dist/api/protocol-v2/FilesystemFormat.d.ts.map +0 -1
  306. package/dist/api/protocol-v2/GetProtoVersion.d.ts +0 -6
  307. package/dist/api/protocol-v2/GetProtoVersion.d.ts.map +0 -1
  308. package/dist/api/protocol-v2/Ping.d.ts +0 -8
  309. package/dist/api/protocol-v2/Ping.d.ts.map +0 -1
  310. package/dist/api/protocol-v2/helpers.d.ts +0 -49
  311. package/dist/api/protocol-v2/helpers.d.ts.map +0 -1
  312. package/dist/protocols/protocol-v2/features.d.ts +0 -74
  313. package/dist/protocols/protocol-v2/features.d.ts.map +0 -1
  314. package/dist/protocols/protocol-v2/firmware.d.ts +0 -12
  315. package/dist/protocols/protocol-v2/firmware.d.ts.map +0 -1
  316. package/dist/protocols/protocol-v2/index.d.ts +0 -3
  317. package/dist/protocols/protocol-v2/index.d.ts.map +0 -1
  318. package/dist/types/api/getDeviceInfo.d.ts +0 -84
  319. package/dist/types/api/getDeviceInfo.d.ts.map +0 -1
  320. package/dist/types/api/protocolV2.d.ts +0 -127
  321. package/dist/types/api/protocolV2.d.ts.map +0 -1
  322. package/src/api/DirList.ts +0 -29
  323. package/src/api/DirMake.ts +0 -21
  324. package/src/api/DirRemove.ts +0 -21
  325. package/src/api/FileDelete.ts +0 -21
  326. package/src/api/FileRead.ts +0 -165
  327. package/src/api/FileWrite.ts +0 -203
  328. package/src/api/FirmwareUpdateV4.ts +0 -810
  329. package/src/api/GetDeviceInfo.ts +0 -153
  330. package/src/api/PathInfo.ts +0 -25
  331. package/src/api/helpers/deviceInfo.ts +0 -205
  332. package/src/api/helpers/filesystemValidation.ts +0 -51
  333. package/src/api/protocol-v2/DeviceFirmwareUpdate.ts +0 -50
  334. package/src/api/protocol-v2/DeviceGetDeviceInfo.ts +0 -35
  335. package/src/api/protocol-v2/DeviceGetFirmwareUpdateStatus.ts +0 -18
  336. package/src/api/protocol-v2/DeviceGetOnboardingStatus.ts +0 -18
  337. package/src/api/protocol-v2/DeviceReboot.ts +0 -22
  338. package/src/api/protocol-v2/FactoryDeviceInfoSettings.ts +0 -27
  339. package/src/api/protocol-v2/FactoryGetDeviceInfo.ts +0 -18
  340. package/src/api/protocol-v2/FilesystemDiskControl.ts +0 -34
  341. package/src/api/protocol-v2/FilesystemFixPermission.ts +0 -14
  342. package/src/api/protocol-v2/FilesystemFormat.ts +0 -14
  343. package/src/api/protocol-v2/GetProtoVersion.ts +0 -14
  344. package/src/api/protocol-v2/Ping.ts +0 -16
  345. package/src/api/protocol-v2/helpers.ts +0 -161
  346. package/src/data/messages/messages-protocol-v2.json +0 -13116
  347. package/src/protocols/protocol-v2/features.ts +0 -278
  348. package/src/protocols/protocol-v2/firmware.ts +0 -26
  349. package/src/protocols/protocol-v2/index.ts +0 -2
  350. package/src/types/api/getDeviceInfo.ts +0 -97
  351. 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,40 +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
302
  if (DataManager.isBleConnect(env)) {
294
- const res = await this.deviceConnector?.acquire(
295
- this.originalDescriptor.id,
296
- undefined,
297
- true,
298
- expectedProtocol
299
- );
303
+ const res = await this.deviceConnector?.acquire(this.originalDescriptor.id);
300
304
  this.mainId = (res as unknown as any).uuid ?? '';
301
305
  Log.debug('Expected uuid:', this.mainId);
302
306
  } else {
303
307
  this.mainId = await this.deviceConnector?.acquire(
304
308
  this.originalDescriptor.path,
305
- this.originalDescriptor.session,
306
- undefined,
307
- expectedProtocol
309
+ this.originalDescriptor.session
308
310
  );
309
311
  Log.debug('Expected session id:', this.mainId);
310
312
  }
311
313
  this.deviceAcquired = true;
312
314
  this.updateDescriptor({ [mainIdKey]: this.mainId } as unknown as DeviceDescriptor);
313
-
314
- // Propagate protocol version detected during acquire.
315
- const detectedProtocol = TransportManager.transport?.getProtocolType?.(
316
- DataManager.isBleConnect(env) ? this.originalDescriptor.id : this.originalDescriptor.path
317
- );
318
- if (detectedProtocol) {
319
- this.originalDescriptor.protocolType = detectedProtocol;
320
- }
321
-
322
315
  if (this.commands) {
323
316
  await this.commands.dispose(false);
324
317
  }
@@ -374,6 +367,54 @@ export class Device extends EventEmitter {
374
367
  this.deviceAcquired = false;
375
368
  }
376
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
+
377
418
  getCommands() {
378
419
  return this.commands;
379
420
  }
@@ -481,17 +522,6 @@ export class Device extends EventEmitter {
481
522
  }
482
523
 
483
524
  async initialize(options?: InitOptions) {
484
- // Protocol V2 不支持传统 Initialize,直接使用协议专用初始化流程。
485
- if (this.originalDescriptor.protocolType === 'V2') {
486
- this.passphraseState = options?.passphraseState;
487
- if (this.features && !this.featuresNeedsReload && !options?.initSession) {
488
- Log.debug('Skip Protocol V2 feature adapter; cached features are available');
489
- return;
490
- }
491
- await this._initializeProtocolV2();
492
- return;
493
- }
494
-
495
525
  // Log.debug('initialize param:', options);
496
526
 
497
527
  this.passphraseState = options?.passphraseState;
@@ -512,13 +542,7 @@ export class Device extends EventEmitter {
512
542
  payload.passphrase_state = options?.passphraseState;
513
543
  payload.is_contains_attach = true;
514
544
 
515
- Log.debug('Initialize device begin:', {
516
- deviceId: options?.deviceId,
517
- passphraseState: options?.passphraseState,
518
- initSession: options?.initSession,
519
- InitializePayload: payload,
520
- });
521
-
545
+ const initStartAt = Date.now();
522
546
  try {
523
547
  // @ts-expect-error
524
548
  const { message } = await Promise.race([
@@ -531,7 +555,8 @@ export class Device extends EventEmitter {
531
555
  }),
532
556
  ]);
533
557
 
534
- Log.debug('Initialize device end: ', message);
558
+ const initCostMs = Date.now() - initStartAt;
559
+ this.setLastInitializeDuration(initCostMs);
535
560
  this._updateFeatures(message, options?.initSession);
536
561
  await TransportManager.reconfigure(this.features);
537
562
  } catch (error) {
@@ -540,36 +565,6 @@ export class Device extends EventEmitter {
540
565
  }
541
566
  }
542
567
 
543
- /**
544
- * Device initialization over Protocol V2.
545
- *
546
- * Protocol V2 不走传统 Initialize/GetFeatures,当前通过 Ping 验证链路,
547
- * 再用 DeviceGetDeviceInfo 归一成 legacy-style Features 视图。
548
- */
549
- private async _initializeProtocolV2() {
550
- Log.debug('Initialize device via Protocol V2 feature adapter');
551
-
552
- try {
553
- const features = await Promise.race([
554
- getProtocolV2Features({
555
- commands: this.commands,
556
- descriptor: this.originalDescriptor,
557
- timeoutMs: 10 * 1000,
558
- }),
559
- new Promise<never>((_, reject) => {
560
- setTimeout(() => {
561
- reject(ERRORS.TypedError(HardwareErrorCode.DeviceInitializeFailed));
562
- }, 10 * 1000);
563
- }),
564
- ]);
565
- Log.debug('Protocol V2 normalized features:', features);
566
- this._updateFeatures(features);
567
- } catch (error) {
568
- Log.error('Protocol V2 initialization failed:', error);
569
- throw error;
570
- }
571
- }
572
-
573
568
  async getFeatures() {
574
569
  const { message } = await this.commands.typedCall('GetFeatures', 'Features', {});
575
570
  this._updateFeatures(message);
@@ -640,7 +635,7 @@ export class Device extends EventEmitter {
640
635
  const env = DataManager.getSettings('env');
641
636
  if (env !== 'react-native') {
642
637
  try {
643
- await this.acquire(options.connectProtocol);
638
+ await this.acquire();
644
639
  } catch (error) {
645
640
  this.runPromise = null;
646
641
  return Promise.reject(error);
@@ -648,7 +643,9 @@ export class Device extends EventEmitter {
648
643
 
649
644
  try {
650
645
  if (fn) {
651
- await this.initialize(options);
646
+ if (!options?.skipInitialize) {
647
+ await this.initialize(options);
648
+ }
652
649
  }
653
650
  } catch (error) {
654
651
  this.runPromise = null;
@@ -882,13 +879,9 @@ export class Device extends EventEmitter {
882
879
  this.features,
883
880
  Enum_Capability.Capability_AttachToPin
884
881
  );
885
- const isPro2 = getDeviceType(this.features) === EDeviceType.Pro2;
886
882
 
887
883
  const supportUnlock =
888
- supportAttachPinCapability ||
889
- // Pro2 V2 暂未从 features 暴露 capabilities,先直连该方法用于固件联调。
890
- isPro2 ||
891
- (versionRange && semver.gte(firmwareVersion, versionRange.min));
884
+ supportAttachPinCapability || (versionRange && semver.gte(firmwareVersion, versionRange.min));
892
885
 
893
886
  if (supportUnlock) {
894
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,24 +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 response = await this._commonCall(type, msg, options);
324
+ const response = await this._commonCall(type, msg);
448
325
  try {
449
326
  assertType(response, resType);
450
327
  } catch (error) {
@@ -457,12 +334,6 @@ export class DeviceCommands {
457
334
  // throw bridge network error
458
335
  if (error instanceof HardwareError) {
459
336
  if (error.errorCode === HardwareErrorCode.ResponseUnexpectTypeError) {
460
- Log.debug('[DeviceCommands] [typedCall] Unexpected response type', {
461
- request: type,
462
- expected: resType,
463
- received: response.type,
464
- response: sanitizeDebugPayload(response.message),
465
- });
466
337
  // Do not intercept CallMethodError
467
338
  // Do not intercept “assertType: Response of unexpected type” error
468
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.
@@ -476,7 +347,7 @@ export class DeviceCommands {
476
347
  if (error.message.indexOf('BridgeDeviceDisconnected') > -1) {
477
348
  throw ERRORS.TypedError(HardwareErrorCode.BridgeDeviceDisconnected);
478
349
  }
479
- throw error;
350
+ throw ERRORS.TypedError(HardwareErrorCode.ResponseUnexpectTypeError);
480
351
  }
481
352
  } else {
482
353
  // throw error anyway, next call should be resolved properly// throw error anyway, next call should be resolved properly
@@ -486,27 +357,20 @@ export class DeviceCommands {
486
357
  return response;
487
358
  }
488
359
 
489
- async _commonCall(
490
- type: MessageKey,
491
- msg?: DefaultMessageResponse['message'],
492
- options?: TransportCallOptions
493
- ) {
494
- const resp = await this.call(type, msg, options);
495
- 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);
496
363
  }
497
364
 
498
365
  _filterCommonTypes(
499
366
  res: DefaultMessageResponse,
500
- callType: MessageKey,
501
- options?: TransportCallOptions
367
+ callType: MessageKey
502
368
  ): Promise<DefaultMessageResponse> {
503
369
  try {
504
- if (shouldReduceDebugForCall(callType)) {
505
- // 高频文件写入每个 chunk 都会经过这里,避免 debug log 反向拖慢传输。
506
- } else if (DataManager.getSettings('env') === 'react-native') {
507
- Log.debug('_filterCommonTypes: ', JSON.stringify(sanitizeDebugPayload(res)));
370
+ if (DataManager.getSettings('env') === 'react-native') {
371
+ Log.debug('_filterCommonTypes: ', JSON.stringify(res));
508
372
  } else {
509
- Log.debug('_filterCommonTypes: ', sanitizeDebugPayload(res));
373
+ Log.debug('_filterCommonTypes: ', res);
510
374
  }
511
375
  } catch (error) {
512
376
  // ignore
@@ -608,7 +472,7 @@ export class DeviceCommands {
608
472
  } else {
609
473
  this.device.emit(DEVICE.BUTTON, this.device, res.message);
610
474
  }
611
- return this._commonCall('ButtonAck', {}, options);
475
+ return this._commonCall('ButtonAck', {});
612
476
  }
613
477
 
614
478
  if (res.type === 'EntropyRequest') {
@@ -621,11 +485,11 @@ export class DeviceCommands {
621
485
  if (pin === '@@ONEKEY_INPUT_PIN_IN_DEVICE') {
622
486
  // only classic\1s\mini\pure
623
487
  this.device.setCancelableAction(() => this.cancelDeviceOnOneKeyDevice());
624
- return this._commonCall('BixinPinInputOnDevice', {}, options).finally(() => {
488
+ return this._commonCall('BixinPinInputOnDevice').finally(() => {
625
489
  this.device.clearCancelableAction();
626
490
  });
627
491
  }
628
- return this._commonCall('PinMatrixAck', { pin }, options);
492
+ return this._commonCall('PinMatrixAck', { pin });
629
493
  },
630
494
  error => Promise.reject(error)
631
495
  );
@@ -640,12 +504,12 @@ export class DeviceCommands {
640
504
 
641
505
  // Attach PIN on device
642
506
  if (attachPinOnDevice && existsAttachPinUser) {
643
- return this._commonCall('PassphraseAck', { on_device_attach_pin: true }, options);
507
+ return this._commonCall('PassphraseAck', { on_device_attach_pin: true });
644
508
  }
645
509
 
646
510
  return !passphraseOnDevice
647
- ? this._commonCall('PassphraseAck', { passphrase }, options)
648
- : this._commonCall('PassphraseAck', { on_device: true }, options);
511
+ ? this._commonCall('PassphraseAck', { passphrase })
512
+ : this._commonCall('PassphraseAck', { on_device: true });
649
513
  });
650
514
  }
651
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