@onekeyfe/hd-core 1.1.28 → 1.2.0-alpha.1

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 (394) hide show
  1. package/__tests__/evmLedgerLegacySafety.test.ts +15 -4
  2. package/__tests__/evmSignTransaction.test.ts +1 -1
  3. package/__tests__/evmSignTypedData.test.ts +1 -1
  4. package/__tests__/logBlockEvent.test.ts +37 -0
  5. package/__tests__/protocol-v2.test.ts +2908 -0
  6. package/dist/api/BaseMethod.d.ts +1 -0
  7. package/dist/api/BaseMethod.d.ts.map +1 -1
  8. package/dist/api/DirList.d.ts +10 -0
  9. package/dist/api/DirList.d.ts.map +1 -0
  10. package/dist/api/DirMake.d.ts +9 -0
  11. package/dist/api/DirMake.d.ts.map +1 -0
  12. package/dist/api/DirRemove.d.ts +9 -0
  13. package/dist/api/DirRemove.d.ts.map +1 -0
  14. package/dist/api/FileDelete.d.ts +9 -0
  15. package/dist/api/FileDelete.d.ts.map +1 -0
  16. package/dist/api/FileRead.d.ts +19 -0
  17. package/dist/api/FileRead.d.ts.map +1 -0
  18. package/dist/api/FileWrite.d.ts +24 -0
  19. package/dist/api/FileWrite.d.ts.map +1 -0
  20. package/dist/api/FirmwareUpdate.d.ts.map +1 -1
  21. package/dist/api/FirmwareUpdateV2.d.ts.map +1 -1
  22. package/dist/api/FirmwareUpdateV3.d.ts +1 -0
  23. package/dist/api/FirmwareUpdateV3.d.ts.map +1 -1
  24. package/dist/api/FirmwareUpdateV4.d.ts +35 -0
  25. package/dist/api/FirmwareUpdateV4.d.ts.map +1 -0
  26. package/dist/api/GetDeviceInfo.d.ts +9 -0
  27. package/dist/api/GetDeviceInfo.d.ts.map +1 -0
  28. package/dist/api/GetFeatures.d.ts +1 -1
  29. package/dist/api/GetFeatures.d.ts.map +1 -1
  30. package/dist/api/GetOnekeyFeatures.d.ts.map +1 -1
  31. package/dist/api/GetPassphraseState.d.ts +6 -1
  32. package/dist/api/GetPassphraseState.d.ts.map +1 -1
  33. package/dist/api/PathInfo.d.ts +10 -0
  34. package/dist/api/PathInfo.d.ts.map +1 -0
  35. package/dist/api/PromptWebDeviceAccess.d.ts.map +1 -1
  36. package/dist/api/SearchDevices.d.ts +2 -1
  37. package/dist/api/SearchDevices.d.ts.map +1 -1
  38. package/dist/api/alephium/AlephiumGetAddress.d.ts +2 -6
  39. package/dist/api/alephium/AlephiumGetAddress.d.ts.map +1 -1
  40. package/dist/api/alephium/AlephiumSignMessage.d.ts +2 -5
  41. package/dist/api/alephium/AlephiumSignMessage.d.ts.map +1 -1
  42. package/dist/api/alephium/AlephiumSignTransaction.d.ts +5 -8
  43. package/dist/api/alephium/AlephiumSignTransaction.d.ts.map +1 -1
  44. package/dist/api/aptos/AptosGetAddress.d.ts.map +1 -1
  45. package/dist/api/benfen/BenfenGetAddress.d.ts +2 -9
  46. package/dist/api/benfen/BenfenGetAddress.d.ts.map +1 -1
  47. package/dist/api/benfen/BenfenGetPublicKey.d.ts +2 -9
  48. package/dist/api/benfen/BenfenGetPublicKey.d.ts.map +1 -1
  49. package/dist/api/benfen/BenfenSignMessage.d.ts +2 -8
  50. package/dist/api/benfen/BenfenSignMessage.d.ts.map +1 -1
  51. package/dist/api/benfen/BenfenSignTransaction.d.ts +2 -8
  52. package/dist/api/benfen/BenfenSignTransaction.d.ts.map +1 -1
  53. package/dist/api/btc/BTCGetAddress.d.ts +1 -11
  54. package/dist/api/btc/BTCGetAddress.d.ts.map +1 -1
  55. package/dist/api/btc/BTCGetPublicKey.d.ts +1 -11
  56. package/dist/api/btc/BTCGetPublicKey.d.ts.map +1 -1
  57. package/dist/api/btc/BTCSignMessage.d.ts +1 -15
  58. package/dist/api/btc/BTCSignMessage.d.ts.map +1 -1
  59. package/dist/api/btc/BTCSignPsbt.d.ts.map +1 -1
  60. package/dist/api/btc/BTCSignTransaction.d.ts +1 -11
  61. package/dist/api/btc/BTCSignTransaction.d.ts.map +1 -1
  62. package/dist/api/btc/BTCVerifyMessage.d.ts +1 -11
  63. package/dist/api/btc/BTCVerifyMessage.d.ts.map +1 -1
  64. package/dist/api/btc/helpers/versionLimit.d.ts +2 -11
  65. package/dist/api/btc/helpers/versionLimit.d.ts.map +1 -1
  66. package/dist/api/cardano/CardanoSignTransaction.d.ts.map +1 -1
  67. package/dist/api/conflux/ConfluxSignTransaction.d.ts.map +1 -1
  68. package/dist/api/device/DeviceLock.d.ts.map +1 -1
  69. package/dist/api/device/DeviceRebootToBoardloader.d.ts +1 -1
  70. package/dist/api/device/DeviceRebootToBoardloader.d.ts.map +1 -1
  71. package/dist/api/device/DeviceRebootToBootloader.d.ts.map +1 -1
  72. package/dist/api/device/DeviceSupportFeatures.d.ts.map +1 -1
  73. package/dist/api/device/DeviceUnlock.d.ts +1 -1
  74. package/dist/api/device/DeviceUploadResource.d.ts.map +1 -1
  75. package/dist/api/device/DeviceVerify.d.ts.map +1 -1
  76. package/dist/api/dynex/DnxGetAddress.d.ts.map +1 -1
  77. package/dist/api/dynex/DnxSignTransaction.d.ts.map +1 -1
  78. package/dist/api/evm/EVMGetPublicKey.d.ts.map +1 -1
  79. package/dist/api/evm/EVMSignMessageEIP712.d.ts +2 -8
  80. package/dist/api/evm/EVMSignMessageEIP712.d.ts.map +1 -1
  81. package/dist/api/evm/EVMSignTypedData.d.ts.map +1 -1
  82. package/dist/api/evm/latest/signTypedData.d.ts +1 -1
  83. package/dist/api/evm/latest/signTypedData.d.ts.map +1 -1
  84. package/dist/api/evm/latest/signTypedHash.d.ts.map +1 -1
  85. package/dist/api/evm/legacyV1/getAddress.d.ts.map +1 -1
  86. package/dist/api/evm/legacyV1/getPublicKey.d.ts.map +1 -1
  87. package/dist/api/evm/legacyV1/signMessage.d.ts.map +1 -1
  88. package/dist/api/evm/legacyV1/signTypedData.d.ts +1 -1
  89. package/dist/api/evm/legacyV1/signTypedData.d.ts.map +1 -1
  90. package/dist/api/evm/legacyV1/signTypedHash.d.ts.map +1 -1
  91. package/dist/api/evm/legacyV1/verifyMessage.d.ts.map +1 -1
  92. package/dist/api/firmware/bootloaderHelper.d.ts.map +1 -1
  93. package/dist/api/firmware/uploadFirmware.d.ts.map +1 -1
  94. package/dist/api/helpers/batchGetPublickeys.d.ts +3 -0
  95. package/dist/api/helpers/batchGetPublickeys.d.ts.map +1 -1
  96. package/dist/api/helpers/filesystemValidation.d.ts +7 -0
  97. package/dist/api/helpers/filesystemValidation.d.ts.map +1 -0
  98. package/dist/api/index.d.ts +32 -0
  99. package/dist/api/index.d.ts.map +1 -1
  100. package/dist/api/kaspa/KaspaSignTransaction.d.ts.map +1 -1
  101. package/dist/api/lightning/LnurlAuth.d.ts +4 -0
  102. package/dist/api/lightning/LnurlAuth.d.ts.map +1 -1
  103. package/dist/api/neo/NeoGetAddress.d.ts +2 -8
  104. package/dist/api/neo/NeoGetAddress.d.ts.map +1 -1
  105. package/dist/api/neo/NeoSignTransaction.d.ts +2 -8
  106. package/dist/api/neo/NeoSignTransaction.d.ts.map +1 -1
  107. package/dist/api/nervos/NervosGetAddress.d.ts +2 -9
  108. package/dist/api/nervos/NervosGetAddress.d.ts.map +1 -1
  109. package/dist/api/nervos/NervosSignTransaction.d.ts +9 -12
  110. package/dist/api/nervos/NervosSignTransaction.d.ts.map +1 -1
  111. package/dist/api/nexa/NexaGetAddress.d.ts +2 -8
  112. package/dist/api/nexa/NexaGetAddress.d.ts.map +1 -1
  113. package/dist/api/nexa/NexaSignTransaction.d.ts +2 -9
  114. package/dist/api/nexa/NexaSignTransaction.d.ts.map +1 -1
  115. package/dist/api/polkadot/PolkadotGetAddress.d.ts +3 -0
  116. package/dist/api/polkadot/PolkadotGetAddress.d.ts.map +1 -1
  117. package/dist/api/polkadot/networks.d.ts +3 -0
  118. package/dist/api/polkadot/networks.d.ts.map +1 -1
  119. package/dist/api/protocol-v2/DevReboot.d.ts +7 -0
  120. package/dist/api/protocol-v2/DevReboot.d.ts.map +1 -0
  121. package/dist/api/protocol-v2/DeviceFirmwareUpdate.d.ts +7 -0
  122. package/dist/api/protocol-v2/DeviceFirmwareUpdate.d.ts.map +1 -0
  123. package/dist/api/protocol-v2/DeviceGetDeviceInfo.d.ts +29 -0
  124. package/dist/api/protocol-v2/DeviceGetDeviceInfo.d.ts.map +1 -0
  125. package/dist/api/protocol-v2/DeviceGetFirmwareUpdateStatus.d.ts +6 -0
  126. package/dist/api/protocol-v2/DeviceGetFirmwareUpdateStatus.d.ts.map +1 -0
  127. package/dist/api/protocol-v2/DeviceGetOnboardingStatus.d.ts +6 -0
  128. package/dist/api/protocol-v2/DeviceGetOnboardingStatus.d.ts.map +1 -0
  129. package/dist/api/protocol-v2/DeviceReboot.d.ts +7 -0
  130. package/dist/api/protocol-v2/DeviceReboot.d.ts.map +1 -0
  131. package/dist/api/protocol-v2/FactoryDeviceInfoSettings.d.ts +7 -0
  132. package/dist/api/protocol-v2/FactoryDeviceInfoSettings.d.ts.map +1 -0
  133. package/dist/api/protocol-v2/FactoryGetDeviceInfo.d.ts +6 -0
  134. package/dist/api/protocol-v2/FactoryGetDeviceInfo.d.ts.map +1 -0
  135. package/dist/api/protocol-v2/FilesystemDiskControl.d.ts +13 -0
  136. package/dist/api/protocol-v2/FilesystemDiskControl.d.ts.map +1 -0
  137. package/dist/api/protocol-v2/FilesystemFixPermission.d.ts +6 -0
  138. package/dist/api/protocol-v2/FilesystemFixPermission.d.ts.map +1 -0
  139. package/dist/api/protocol-v2/FilesystemFormat.d.ts +6 -0
  140. package/dist/api/protocol-v2/FilesystemFormat.d.ts.map +1 -0
  141. package/dist/api/protocol-v2/GetProtoVersion.d.ts +6 -0
  142. package/dist/api/protocol-v2/GetProtoVersion.d.ts.map +1 -0
  143. package/dist/api/protocol-v2/Ping.d.ts +8 -0
  144. package/dist/api/protocol-v2/Ping.d.ts.map +1 -0
  145. package/dist/api/protocol-v2/helpers.d.ts +33 -0
  146. package/dist/api/protocol-v2/helpers.d.ts.map +1 -0
  147. package/dist/api/scdo/ScdoGetAddress.d.ts +2 -6
  148. package/dist/api/scdo/ScdoGetAddress.d.ts.map +1 -1
  149. package/dist/api/scdo/ScdoSignMessage.d.ts +2 -5
  150. package/dist/api/scdo/ScdoSignMessage.d.ts.map +1 -1
  151. package/dist/api/scdo/ScdoSignTransaction.d.ts +2 -5
  152. package/dist/api/scdo/ScdoSignTransaction.d.ts.map +1 -1
  153. package/dist/api/solana/SolGetAddress.d.ts +1 -0
  154. package/dist/api/solana/SolGetAddress.d.ts.map +1 -1
  155. package/dist/api/solana/SolSignMessage.d.ts +3 -0
  156. package/dist/api/solana/SolSignMessage.d.ts.map +1 -1
  157. package/dist/api/solana/SolSignOffchainMessage.d.ts +3 -0
  158. package/dist/api/solana/SolSignOffchainMessage.d.ts.map +1 -1
  159. package/dist/api/solana/SolSignTransaction.d.ts +6 -0
  160. package/dist/api/solana/SolSignTransaction.d.ts.map +1 -1
  161. package/dist/api/stellar/StellarGetAddress.d.ts +2 -1
  162. package/dist/api/stellar/StellarGetAddress.d.ts.map +1 -1
  163. package/dist/api/stellar/StellarSignTransaction.d.ts +3 -2
  164. package/dist/api/stellar/StellarSignTransaction.d.ts.map +1 -1
  165. package/dist/api/sui/SuiGetAddress.d.ts +3 -0
  166. package/dist/api/sui/SuiGetAddress.d.ts.map +1 -1
  167. package/dist/api/sui/SuiGetPublicKey.d.ts +3 -0
  168. package/dist/api/sui/SuiGetPublicKey.d.ts.map +1 -1
  169. package/dist/api/sui/SuiSignMessage.d.ts +3 -0
  170. package/dist/api/sui/SuiSignMessage.d.ts.map +1 -1
  171. package/dist/api/sui/SuiSignTransaction.d.ts +5 -2
  172. package/dist/api/sui/SuiSignTransaction.d.ts.map +1 -1
  173. package/dist/api/ton/TonGetAddress.d.ts +3 -0
  174. package/dist/api/ton/TonGetAddress.d.ts.map +1 -1
  175. package/dist/api/ton/TonSignData.d.ts +5 -0
  176. package/dist/api/ton/TonSignData.d.ts.map +1 -1
  177. package/dist/api/ton/TonSignMessage.d.ts +3 -0
  178. package/dist/api/ton/TonSignMessage.d.ts.map +1 -1
  179. package/dist/api/ton/TonSignProof.d.ts +3 -0
  180. package/dist/api/ton/TonSignProof.d.ts.map +1 -1
  181. package/dist/api/tron/TronSignMessage.d.ts +4 -0
  182. package/dist/api/tron/TronSignMessage.d.ts.map +1 -1
  183. package/dist/api/tron/TronSignTransaction.d.ts +4 -0
  184. package/dist/api/tron/TronSignTransaction.d.ts.map +1 -1
  185. package/dist/constants/index.d.ts +2 -1
  186. package/dist/constants/index.d.ts.map +1 -1
  187. package/dist/core/index.d.ts.map +1 -1
  188. package/dist/data-manager/DataManager.d.ts +7 -4
  189. package/dist/data-manager/DataManager.d.ts.map +1 -1
  190. package/dist/data-manager/MessagesConfig.d.ts +2 -2
  191. package/dist/data-manager/MessagesConfig.d.ts.map +1 -1
  192. package/dist/data-manager/TransportManager.d.ts +5 -4
  193. package/dist/data-manager/TransportManager.d.ts.map +1 -1
  194. package/dist/data-manager/connectSettings.d.ts.map +1 -1
  195. package/dist/device/Device.d.ts +33 -11
  196. package/dist/device/Device.d.ts.map +1 -1
  197. package/dist/device/DeviceCommands.d.ts +9 -9
  198. package/dist/device/DeviceCommands.d.ts.map +1 -1
  199. package/dist/device/DeviceConnector.d.ts +2 -1
  200. package/dist/device/DeviceConnector.d.ts.map +1 -1
  201. package/dist/deviceProfile/buildDeviceFeatures.d.ts +6 -0
  202. package/dist/deviceProfile/buildDeviceFeatures.d.ts.map +1 -0
  203. package/dist/deviceProfile/buildDeviceProfile.d.ts +21 -0
  204. package/dist/deviceProfile/buildDeviceProfile.d.ts.map +1 -0
  205. package/dist/deviceProfile/index.d.ts +3 -0
  206. package/dist/deviceProfile/index.d.ts.map +1 -0
  207. package/dist/events/logBlockEvent.d.ts +1 -0
  208. package/dist/events/logBlockEvent.d.ts.map +1 -1
  209. package/dist/events/ui-request.d.ts +8 -0
  210. package/dist/events/ui-request.d.ts.map +1 -1
  211. package/dist/index.d.ts +717 -302
  212. package/dist/index.js +17654 -1271
  213. package/dist/inject.d.ts.map +1 -1
  214. package/dist/protocols/protocol-v2/features.d.ts +93 -0
  215. package/dist/protocols/protocol-v2/features.d.ts.map +1 -0
  216. package/dist/protocols/protocol-v2/firmware.d.ts +13 -0
  217. package/dist/protocols/protocol-v2/firmware.d.ts.map +1 -0
  218. package/dist/protocols/protocol-v2/index.d.ts +4 -0
  219. package/dist/protocols/protocol-v2/index.d.ts.map +1 -0
  220. package/dist/types/api/export.d.ts +1 -1
  221. package/dist/types/api/export.d.ts.map +1 -1
  222. package/dist/types/api/firmwareUpdate.d.ts +27 -0
  223. package/dist/types/api/firmwareUpdate.d.ts.map +1 -1
  224. package/dist/types/api/getDeviceInfo.d.ts +85 -0
  225. package/dist/types/api/getDeviceInfo.d.ts.map +1 -0
  226. package/dist/types/api/getPassphraseState.d.ts +10 -1
  227. package/dist/types/api/getPassphraseState.d.ts.map +1 -1
  228. package/dist/types/api/index.d.ts +37 -1
  229. package/dist/types/api/index.d.ts.map +1 -1
  230. package/dist/types/api/protocolV2.d.ts +103 -0
  231. package/dist/types/api/protocolV2.d.ts.map +1 -0
  232. package/dist/types/api/searchDevices.d.ts +2 -2
  233. package/dist/types/api/searchDevices.d.ts.map +1 -1
  234. package/dist/types/device.d.ts +91 -5
  235. package/dist/types/device.d.ts.map +1 -1
  236. package/dist/types/params.d.ts +2 -0
  237. package/dist/types/params.d.ts.map +1 -1
  238. package/dist/types/settings.d.ts +2 -1
  239. package/dist/types/settings.d.ts.map +1 -1
  240. package/dist/utils/capabilitieUtils.d.ts.map +1 -1
  241. package/dist/utils/deviceFeaturesUtils.d.ts +6 -8
  242. package/dist/utils/deviceFeaturesUtils.d.ts.map +1 -1
  243. package/dist/utils/deviceInfoUtils.d.ts +1 -0
  244. package/dist/utils/deviceInfoUtils.d.ts.map +1 -1
  245. package/dist/utils/deviceVersionUtils.d.ts.map +1 -1
  246. package/dist/utils/findDefectiveBatchDevice.d.ts +1 -1
  247. package/dist/utils/index.d.ts +1 -1
  248. package/dist/utils/index.d.ts.map +1 -1
  249. package/dist/utils/patch.d.ts +1 -1
  250. package/dist/utils/patch.d.ts.map +1 -1
  251. package/package.json +4 -4
  252. package/src/api/BaseMethod.ts +26 -22
  253. package/src/api/DirList.ts +31 -0
  254. package/src/api/DirMake.ts +23 -0
  255. package/src/api/DirRemove.ts +23 -0
  256. package/src/api/FileDelete.ts +23 -0
  257. package/src/api/FileRead.ts +167 -0
  258. package/src/api/FileWrite.ts +216 -0
  259. package/src/api/FirmwareUpdate.ts +13 -5
  260. package/src/api/FirmwareUpdateV2.ts +22 -19
  261. package/src/api/FirmwareUpdateV3.ts +19 -5
  262. package/src/api/FirmwareUpdateV4.ts +820 -0
  263. package/src/api/GetDeviceInfo.ts +145 -0
  264. package/src/api/GetFeatures.ts +5 -2
  265. package/src/api/GetOnekeyFeatures.ts +84 -3
  266. package/src/api/GetPassphraseState.ts +16 -10
  267. package/src/api/PathInfo.ts +39 -0
  268. package/src/api/PromptWebDeviceAccess.ts +11 -1
  269. package/src/api/SearchDevices.ts +7 -2
  270. package/src/api/alephium/AlephiumGetAddress.ts +6 -2
  271. package/src/api/alephium/AlephiumSignMessage.ts +6 -1
  272. package/src/api/alephium/AlephiumSignTransaction.ts +15 -4
  273. package/src/api/allnetwork/AllNetworkGetAddressBase.ts +21 -13
  274. package/src/api/aptos/AptosGetAddress.ts +2 -3
  275. package/src/api/benfen/BenfenGetAddress.ts +11 -7
  276. package/src/api/benfen/BenfenGetPublicKey.ts +6 -2
  277. package/src/api/benfen/BenfenSignMessage.ts +6 -1
  278. package/src/api/benfen/BenfenSignTransaction.ts +6 -1
  279. package/src/api/btc/BTCGetPublicKey.ts +3 -2
  280. package/src/api/btc/BTCSignPsbt.ts +1 -2
  281. package/src/api/btc/helpers/versionLimit.ts +7 -1
  282. package/src/api/cardano/CardanoSignTransaction.ts +2 -4
  283. package/src/api/conflux/ConfluxSignTransaction.ts +5 -2
  284. package/src/api/device/DeviceFullyUploadResource.ts +3 -3
  285. package/src/api/device/DeviceLock.ts +1 -3
  286. package/src/api/device/DeviceRebootToBoardloader.ts +10 -1
  287. package/src/api/device/DeviceRebootToBootloader.ts +10 -1
  288. package/src/api/device/DeviceSupportFeatures.ts +2 -13
  289. package/src/api/device/DeviceUpdateBootloader.ts +4 -4
  290. package/src/api/device/DeviceUploadResource.ts +4 -5
  291. package/src/api/device/DeviceVerify.ts +1 -2
  292. package/src/api/dynex/DnxGetAddress.ts +6 -0
  293. package/src/api/dynex/DnxSignTransaction.ts +6 -0
  294. package/src/api/evm/EVMGetAddress.ts +1 -1
  295. package/src/api/evm/EVMGetPublicKey.ts +3 -4
  296. package/src/api/evm/EVMSignMessage.ts +1 -1
  297. package/src/api/evm/EVMSignMessageEIP712.ts +14 -1
  298. package/src/api/evm/EVMSignTransaction.ts +1 -1
  299. package/src/api/evm/EVMSignTypedData.ts +32 -18
  300. package/src/api/evm/EVMVerifyMessage.ts +1 -1
  301. package/src/api/evm/latest/signTypedHash.ts +2 -4
  302. package/src/api/evm/legacyV1/getAddress.ts +5 -3
  303. package/src/api/evm/legacyV1/getPublicKey.ts +5 -3
  304. package/src/api/evm/legacyV1/signMessage.ts +5 -3
  305. package/src/api/evm/legacyV1/signTypedData.ts +9 -8
  306. package/src/api/evm/legacyV1/signTypedHash.ts +7 -7
  307. package/src/api/evm/legacyV1/verifyMessage.ts +5 -3
  308. package/src/api/firmware/FirmwareUpdateBaseMethod.ts +8 -8
  309. package/src/api/firmware/bootloaderHelper.ts +3 -2
  310. package/src/api/firmware/getBinary.ts +1 -1
  311. package/src/api/firmware/releaseHelper.ts +3 -3
  312. package/src/api/firmware/uploadFirmware.ts +8 -12
  313. package/src/api/helpers/batchGetPublickeys.ts +51 -6
  314. package/src/api/helpers/filesystemValidation.ts +51 -0
  315. package/src/api/index.ts +34 -0
  316. package/src/api/kaspa/KaspaSignTransaction.ts +4 -5
  317. package/src/api/lightning/LnurlAuth.ts +4 -0
  318. package/src/api/neo/NeoGetAddress.ts +6 -1
  319. package/src/api/neo/NeoSignTransaction.ts +6 -1
  320. package/src/api/nervos/NervosGetAddress.ts +6 -2
  321. package/src/api/nervos/NervosSignTransaction.ts +14 -4
  322. package/src/api/nexa/NexaGetAddress.ts +6 -2
  323. package/src/api/nexa/NexaSignTransaction.ts +11 -12
  324. package/src/api/polkadot/networks.ts +9 -0
  325. package/src/api/protocol-v2/DevReboot.ts +24 -0
  326. package/src/api/protocol-v2/DeviceFirmwareUpdate.ts +63 -0
  327. package/src/api/protocol-v2/DeviceGetDeviceInfo.ts +118 -0
  328. package/src/api/protocol-v2/DeviceGetFirmwareUpdateStatus.ts +20 -0
  329. package/src/api/protocol-v2/DeviceGetOnboardingStatus.ts +16 -0
  330. package/src/api/protocol-v2/DeviceReboot.ts +24 -0
  331. package/src/api/protocol-v2/FactoryDeviceInfoSettings.ts +29 -0
  332. package/src/api/protocol-v2/FactoryGetDeviceInfo.ts +20 -0
  333. package/src/api/protocol-v2/FilesystemDiskControl.ts +50 -0
  334. package/src/api/protocol-v2/FilesystemFixPermission.ts +16 -0
  335. package/src/api/protocol-v2/FilesystemFormat.ts +16 -0
  336. package/src/api/protocol-v2/GetProtoVersion.ts +16 -0
  337. package/src/api/protocol-v2/Ping.ts +18 -0
  338. package/src/api/protocol-v2/helpers.ts +182 -0
  339. package/src/api/scdo/ScdoGetAddress.ts +6 -2
  340. package/src/api/scdo/ScdoSignMessage.ts +6 -1
  341. package/src/api/scdo/ScdoSignTransaction.ts +6 -2
  342. package/src/api/solana/SolGetAddress.ts +4 -0
  343. package/src/api/solana/SolSignMessage.ts +3 -0
  344. package/src/api/solana/SolSignOffchainMessage.ts +3 -0
  345. package/src/api/solana/SolSignTransaction.ts +6 -0
  346. package/src/api/stellar/StellarGetAddress.ts +10 -1
  347. package/src/api/stellar/StellarSignTransaction.ts +14 -1
  348. package/src/api/sui/SuiGetAddress.ts +5 -3
  349. package/src/api/sui/SuiGetPublicKey.ts +3 -0
  350. package/src/api/sui/SuiSignMessage.ts +3 -0
  351. package/src/api/sui/SuiSignTransaction.ts +14 -12
  352. package/src/api/ton/TonGetAddress.ts +3 -0
  353. package/src/api/ton/TonSignData.ts +10 -3
  354. package/src/api/ton/TonSignMessage.ts +6 -5
  355. package/src/api/ton/TonSignProof.ts +3 -0
  356. package/src/api/tron/TronSignMessage.ts +5 -1
  357. package/src/api/tron/TronSignTransaction.ts +4 -0
  358. package/src/api/xrp/XrpSignTransaction.ts +1 -1
  359. package/src/constants/index.ts +10 -1
  360. package/src/core/index.ts +91 -61
  361. package/src/data/messages/messages-protocol-v2.json +13375 -0
  362. package/src/data-manager/DataManager.ts +16 -11
  363. package/src/data-manager/MessagesConfig.ts +14 -14
  364. package/src/data-manager/TransportManager.ts +38 -12
  365. package/src/data-manager/connectSettings.ts +6 -0
  366. package/src/device/Device.ts +398 -76
  367. package/src/device/DeviceCommands.ts +195 -29
  368. package/src/device/DeviceConnector.ts +29 -4
  369. package/src/device/DevicePool.ts +8 -8
  370. package/src/deviceProfile/buildDeviceFeatures.ts +368 -0
  371. package/src/deviceProfile/buildDeviceProfile.ts +333 -0
  372. package/src/deviceProfile/index.ts +5 -0
  373. package/src/events/logBlockEvent.ts +23 -0
  374. package/src/events/ui-request.ts +8 -0
  375. package/src/inject.ts +52 -1
  376. package/src/protocols/protocol-v2/features.ts +178 -0
  377. package/src/protocols/protocol-v2/firmware.ts +43 -0
  378. package/src/protocols/protocol-v2/index.ts +16 -0
  379. package/src/types/api/export.ts +1 -0
  380. package/src/types/api/firmwareUpdate.ts +49 -0
  381. package/src/types/api/getDeviceInfo.ts +99 -0
  382. package/src/types/api/getPassphraseState.ts +13 -2
  383. package/src/types/api/index.ts +88 -1
  384. package/src/types/api/protocolV2.ts +200 -0
  385. package/src/types/api/searchDevices.ts +2 -2
  386. package/src/types/device.ts +102 -5
  387. package/src/types/params.ts +7 -0
  388. package/src/types/settings.ts +6 -1
  389. package/src/utils/capabilitieUtils.ts +1 -2
  390. package/src/utils/deviceFeaturesUtils.ts +75 -81
  391. package/src/utils/deviceInfoUtils.ts +23 -34
  392. package/src/utils/deviceVersionUtils.ts +7 -25
  393. package/src/utils/findDefectiveBatchDevice.ts +6 -6
  394. package/src/utils/index.ts +1 -0
@@ -1,27 +1,33 @@
1
1
  import semver from 'semver';
2
2
  import { isNaN } from 'lodash';
3
3
  import { EDeviceType, type EFirmwareType, ERRORS, HardwareErrorCode } from '@onekeyfe/hd-shared';
4
- import { Enum_Capability } from '@onekeyfe/hd-transport';
4
+ import { Enum_Capability, type GetPassphraseState } from '@onekeyfe/hd-transport';
5
5
 
6
6
  import { toHardened } from '../api/helpers/pathUtils';
7
7
  import { DeviceModelToTypes, DeviceTypeToModels } from '../types';
8
- import DataManager, { type IFirmwareField, type MessageVersion } from '../data-manager/DataManager';
8
+ import DataManager, {
9
+ type IFirmwareField,
10
+ type ProtocolV1MessageSchema,
11
+ } from '../data-manager/DataManager';
9
12
  import { PROTOBUF_MESSAGE_CONFIG } from '../data-manager/MessagesConfig';
10
13
  import { getDeviceType } from './deviceInfoUtils';
11
14
  import { getDeviceFirmwareVersion } from './deviceVersionUtils';
12
15
  import { existCapability } from './capabilitieUtils';
13
16
 
14
17
  import type { Device } from '../device/Device';
15
- import type { DeviceCommands } from '../device/DeviceCommands';
16
- import type { Features, SupportFeatureType } from '../types';
18
+ import type { Features, IDeviceType, SupportFeatureType } from '../types';
17
19
 
18
- export const getSupportMessageVersion = (
20
+ // 生成的 GetPassphraseState 已包含 _only_main_pin / allow_create_attach_pin,
21
+ // 不再需要手动扩展字段。
22
+ type GetPassphraseStateMessage = GetPassphraseState;
23
+
24
+ export const getSupportProtocolV1MessageSchema = (
19
25
  features: Features | undefined
20
- ): { messages: JSON; messageVersion: MessageVersion } => {
26
+ ): { messages: JSON; protocolV1MessageSchema: ProtocolV1MessageSchema } => {
21
27
  if (!features)
22
28
  return {
23
- messages: DataManager.messages.latest,
24
- messageVersion: 'latest',
29
+ messages: DataManager.messages.v1CurrentSchema,
30
+ protocolV1MessageSchema: 'v1CurrentSchema',
25
31
  };
26
32
 
27
33
  const currentDeviceVersion = getDeviceFirmwareVersion(features).join('.');
@@ -37,18 +43,18 @@ export const getSupportMessageVersion = (
37
43
  const sortedDeviceVersionConfigs =
38
44
  deviceVersionConfigs?.sort((a, b) => semver.compare(b.minVersion, a.minVersion)) ?? [];
39
45
 
40
- for (const { minVersion, messageVersion } of sortedDeviceVersionConfigs) {
46
+ for (const { minVersion, protocolV1MessageSchema } of sortedDeviceVersionConfigs) {
41
47
  if (semver.gte(currentDeviceVersion, minVersion)) {
42
48
  return {
43
- messages: DataManager.messages[messageVersion],
44
- messageVersion,
49
+ messages: DataManager.messages[protocolV1MessageSchema],
50
+ protocolV1MessageSchema,
45
51
  };
46
52
  }
47
53
  }
48
54
 
49
55
  return {
50
- messages: DataManager.messages.latest,
51
- messageVersion: 'latest',
56
+ messages: DataManager.messages.v1CurrentSchema,
57
+ protocolV1MessageSchema: 'v1CurrentSchema',
52
58
  };
53
59
  };
54
60
 
@@ -68,7 +74,11 @@ export const supportNewPassphrase = (features?: Features): SupportFeatureType =>
68
74
  if (!features) return { support: false };
69
75
 
70
76
  const deviceType = getDeviceType(features);
71
- if (deviceType === EDeviceType.Touch || deviceType === EDeviceType.Pro) {
77
+ if (
78
+ deviceType === EDeviceType.Touch ||
79
+ deviceType === EDeviceType.Pro ||
80
+ deviceType === EDeviceType.Pro2
81
+ ) {
72
82
  return { support: true };
73
83
  }
74
84
 
@@ -82,25 +92,26 @@ export const getPassphraseStateWithRefreshDeviceInfo = async (
82
92
  options?: {
83
93
  expectPassphraseState?: string;
84
94
  onlyMainPin?: boolean;
95
+ allowCreateAttachPin?: boolean;
85
96
  }
86
97
  ) => {
87
- const { features, commands } = device;
98
+ const { features } = device;
88
99
  const locked = features?.unlocked === false;
100
+ const deviceType = device.getCurrentDeviceType();
89
101
 
90
- const { passphraseState, newSession, unlockedAttachPin } = await getPassphraseState(
91
- features,
92
- commands,
93
- {
94
- ...options,
95
- }
96
- );
102
+ const { passphraseState, newSession, unlockedAttachPin } = await getPassphraseState(device, {
103
+ ...options,
104
+ });
97
105
 
98
106
  const isModeT =
99
- getDeviceType(features) === EDeviceType.Touch || getDeviceType(features) === EDeviceType.Pro;
107
+ deviceType === EDeviceType.Touch ||
108
+ deviceType === EDeviceType.Pro ||
109
+ deviceType === EDeviceType.Pro2;
100
110
 
101
111
  // 如果可以获取到 passphraseState,但是设备 features 显示设备未开启 passphrase,需要刷新设备状态
102
112
  // if passphraseState can be obtained, but the device features show that the device has not enabled passphrase, the device status needs to be refreshed
103
- const needRefreshWithPassphrase = passphraseState && features?.passphrase_protection !== true;
113
+ const needRefreshWithPassphrase =
114
+ passphraseState && device.getCurrentPassphraseProtection() !== true;
104
115
  // 如果 Touch/Pro 在之前是锁定状态,刷新设备状态
105
116
  // if Touch/Pro was locked before, refresh the device state
106
117
  const needRefreshWithLocked = isModeT && locked;
@@ -111,49 +122,68 @@ export const getPassphraseStateWithRefreshDeviceInfo = async (
111
122
  }
112
123
 
113
124
  // Attach to pin try to fix internal state
114
- if (features?.device_id) {
115
- device.updateInternalState(
116
- device.features?.passphrase_protection ?? false,
117
- passphraseState,
118
- device.features?.device_id ?? '',
119
- newSession,
120
- device.features?.session_id
121
- );
122
- }
125
+ const deviceId = device.getCurrentDeviceId();
126
+ device.updateInternalState(
127
+ device.getCurrentPassphraseProtection() ?? false,
128
+ passphraseState,
129
+ deviceId,
130
+ newSession,
131
+ device.features?.sessionId
132
+ );
123
133
 
124
134
  return { passphraseState, newSession, unlockedAttachPin };
125
135
  };
126
136
 
137
+ // 仅适用于 Protocol V1 的 Pro:Pro2 走独立版本线,不能套用 4.15.0 门槛
138
+ // (Pro2 在 getPassphraseState 中通过 isProtocolV2 直接判定支持)。
139
+ const supportProSeriesAttachPinPassphrase = (deviceType: IDeviceType, firmwareVersion: string) =>
140
+ deviceType === EDeviceType.Pro && semver.gte(firmwareVersion, '4.15.0');
141
+
127
142
  export const getPassphraseState = async (
128
- features: Features | undefined,
129
- commands: DeviceCommands,
143
+ device: Device,
130
144
  options?: {
131
145
  expectPassphraseState?: string;
132
146
  onlyMainPin?: boolean;
147
+ allowCreateAttachPin?: boolean;
133
148
  }
134
149
  ): Promise<{
135
150
  passphraseState: string | undefined;
136
151
  newSession: string | undefined;
137
152
  unlockedAttachPin: boolean | undefined;
138
153
  }> => {
154
+ const { features, commands } = device;
155
+
156
+ // 设备尚未建立任何状态时无法判定,保持旧的空返回语义
139
157
  if (!features)
140
158
  return { passphraseState: undefined, newSession: undefined, unlockedAttachPin: undefined };
141
159
 
142
- const firmwareVersion = getDeviceFirmwareVersion(features);
143
- const deviceType = getDeviceType(features);
160
+ const firmwareVersion = device.getCurrentFirmwareVersionString() ?? '0.0.0';
161
+ const deviceType = device.getCurrentDeviceType();
144
162
 
145
163
  const supportAttachPinCapability = existCapability(
146
164
  features,
147
165
  Enum_Capability.Capability_AttachToPin
148
166
  );
167
+ // Pro2 (Protocol V2) 协议自带 GetPassphraseState(10028),固件从首个版本即支持,
168
+ // 不依赖 Pro 系列的 4.15.0 版本线;V2 也没有 GetAddress Testnet 探测这条 legacy 回退路径。
149
169
  const supportGetPassphraseState =
170
+ device.isProtocolV2() ||
150
171
  supportAttachPinCapability ||
151
- (deviceType === EDeviceType.Pro && semver.gte(firmwareVersion.join('.'), '4.15.0'));
172
+ supportProSeriesAttachPinPassphrase(deviceType, firmwareVersion);
152
173
 
153
174
  if (supportGetPassphraseState) {
154
- const { message, type } = await commands.typedCall('GetPassphraseState', 'PassphraseState', {
155
- passphrase_state: options?.onlyMainPin ? undefined : options?.expectPassphraseState,
156
- });
175
+ const payload: GetPassphraseStateMessage = options?.onlyMainPin
176
+ ? { _only_main_pin: true }
177
+ : { passphrase_state: options?.expectPassphraseState };
178
+ if (options?.allowCreateAttachPin) {
179
+ payload.allow_create_attach_pin = true;
180
+ }
181
+
182
+ const { message, type } = await commands.typedCall(
183
+ 'GetPassphraseState',
184
+ 'PassphraseState',
185
+ payload
186
+ );
157
187
 
158
188
  // @ts-expect-error
159
189
  if (type === 'CallMethodError') {
@@ -186,40 +216,8 @@ export const getPassphraseState = async (
186
216
  };
187
217
  };
188
218
 
189
- export const supportBatchPublicKey = (
190
- features?: Features,
191
- options?: {
192
- includeNode?: boolean;
193
- }
194
- ): boolean => {
195
- if (!features) return false;
196
- const currentVersion = getDeviceFirmwareVersion(features).join('.');
197
-
198
- const deviceType = getDeviceType(features);
199
- // btc batch get public key
200
- if (!!options?.includeNode && deviceType === EDeviceType.Pro) {
201
- return semver.gte(currentVersion, '4.14.0');
202
- }
203
- if (!!options?.includeNode && deviceType === EDeviceType.Touch) {
204
- return semver.gte(currentVersion, '4.11.0');
205
- }
206
- if (!!options?.includeNode && DeviceModelToTypes.model_classic1s.includes(deviceType)) {
207
- return semver.gte(currentVersion, '3.12.0');
208
- }
209
- if (!!options?.includeNode && DeviceModelToTypes.model_mini.includes(deviceType)) {
210
- return semver.gte(currentVersion, '3.10.0');
211
- }
212
- if (options?.includeNode) {
213
- return false;
214
- }
215
-
216
- // support batch get public key
217
- if (deviceType === EDeviceType.Touch || deviceType === EDeviceType.Pro) {
218
- return semver.gte(currentVersion, '3.1.0');
219
- }
220
-
221
- return semver.gte(currentVersion, '2.6.0');
222
- };
219
+ // supportBatchPublicKey 已迁移为 device-aware 版本:
220
+ // 见 api/helpers/batchGetPublickeys.ts 的 supportBatchPublicKeyByDevice
223
221
 
224
222
  export const supportModifyHomescreen = (features?: Features): SupportFeatureType => {
225
223
  if (!features) return { support: false };
@@ -340,12 +338,8 @@ export const fixFeaturesFirmwareVersion = (features: Features): Features => {
340
338
  // fix Touch、Pro device when bootloader version is lower than 2.5.2, the features returned do not have firmware_version error
341
339
  const tempFeatures = { ...features };
342
340
 
343
- if (tempFeatures.onekey_firmware_version && !semver.valid(tempFeatures.onekey_firmware_version)) {
344
- tempFeatures.onekey_firmware_version = fixVersion(tempFeatures.onekey_firmware_version);
345
- }
346
-
347
- if (tempFeatures.onekey_version && !semver.valid(tempFeatures.onekey_version)) {
348
- tempFeatures.onekey_version = fixVersion(tempFeatures.onekey_version);
341
+ if (tempFeatures.firmwareVersion && !semver.valid(tempFeatures.firmwareVersion)) {
342
+ tempFeatures.firmwareVersion = fixVersion(tempFeatures.firmwareVersion);
349
343
  }
350
344
 
351
345
  return tempFeatures;
@@ -14,27 +14,12 @@ export const getDeviceType = (features?: Features): IDeviceType => {
14
14
  if (!features || typeof features !== 'object') {
15
15
  return EDeviceType.Unknown;
16
16
  }
17
+ if (features.deviceType) {
18
+ return features.deviceType;
19
+ }
17
20
 
18
- // classic1s 3.5.0 pro 4.6.0
19
- switch (features.onekey_device_type) {
20
- case 'CLASSIC':
21
- return EDeviceType.Classic;
22
- case 'CLASSIC1S':
23
- return EDeviceType.Classic1s;
24
- case 'MINI':
25
- return EDeviceType.Mini;
26
- case 'TOUCH':
27
- return EDeviceType.Touch;
28
- case 'PRO':
29
- return EDeviceType.Pro;
30
- case 'PURE':
31
- return EDeviceType.ClassicPure;
32
- default:
33
- // future And old device onekey_device_type is empty
34
- if (!isEmpty(features.onekey_serial_no)) {
35
- return EDeviceType.Unknown;
36
- }
37
- // old device type
21
+ if (features.model === EDeviceType.Pro2 || features.model === 'pro2') {
22
+ return EDeviceType.Pro2;
38
23
  }
39
24
 
40
25
  // low version hardware
@@ -42,7 +27,7 @@ export const getDeviceType = (features?: Features): IDeviceType => {
42
27
  const serialNo = getDeviceUUID(features);
43
28
 
44
29
  // not exist serialNo, bootloader mode, model 1 is classic
45
- if (isEmpty(serialNo) && features.bootloader_mode === true && features.model === '1') {
30
+ if (isEmpty(serialNo) && features.bootloaderMode === true && features.model === '1') {
46
31
  return EDeviceType.Classic;
47
32
  }
48
33
 
@@ -56,6 +41,7 @@ export const getDeviceType = (features?: Features): IDeviceType => {
56
41
  if (miniFlag.toLowerCase() === 'mi') return EDeviceType.Mini;
57
42
  if (miniFlag.toLowerCase() === 'tc') return EDeviceType.Touch;
58
43
  if (miniFlag.toLowerCase() === 'pr') return EDeviceType.Pro;
44
+ if (miniFlag.toLowerCase() === 'p2') return EDeviceType.Pro2;
59
45
 
60
46
  // unknown device
61
47
  return EDeviceType.Unknown;
@@ -68,13 +54,14 @@ export const getDeviceType = (features?: Features): IDeviceType => {
68
54
  export const getDeviceTypeByBleName = (name?: string): IDeviceType => {
69
55
  if (!name) return EDeviceType.Unknown;
70
56
 
71
- if (name.startsWith('BixinKey')) return EDeviceType.Classic;
72
- if (name.startsWith('K')) return EDeviceType.Classic;
57
+ if (/^BixinKey/i.test(name)) return EDeviceType.Classic;
58
+ if (/^K/i.test(name)) return EDeviceType.Classic;
73
59
 
74
- if (name.startsWith('T')) return EDeviceType.Touch;
75
- if (name.startsWith('Touch')) return EDeviceType.Touch;
60
+ if (/^T/i.test(name)) return EDeviceType.Touch;
61
+ if (/^Touch/i.test(name)) return EDeviceType.Touch;
76
62
 
77
- if (name.startsWith('Pro')) return EDeviceType.Pro;
63
+ if (/\bPro\s*2\b/i.test(name) || /^Pro2/i.test(name)) return EDeviceType.Pro2;
64
+ if (/\bPro\b/i.test(name) || /^Pro/i.test(name)) return EDeviceType.Pro;
78
65
 
79
66
  return EDeviceType.Unknown;
80
67
  };
@@ -85,15 +72,14 @@ export const getDeviceTypeByBleName = (name?: string): IDeviceType => {
85
72
  */
86
73
  export const getDeviceBleName = (features?: Features): string | null => {
87
74
  if (features == null) return null;
88
- return features.onekey_ble_name || features.ble_name || null;
75
+ return features.bleName || null;
89
76
  };
90
77
 
91
78
  /**
92
79
  * Get Connected Device UUID by features
93
80
  */
94
81
  export const getDeviceUUID = (features: Features) => {
95
- const serialNo = features.onekey_serial_no || features.onekey_serial || features.serial_no;
96
- return serialNo ?? '';
82
+ return features.serialNo ?? '';
97
83
  };
98
84
 
99
85
  /**
@@ -128,8 +114,8 @@ export const getMethodVersionRange = (
128
114
  getVersionRange: (deviceModel: IDeviceType | IDeviceModel) => IVersionRange | undefined
129
115
  ): IVersionRange | undefined => {
130
116
  const deviceType = getDeviceType(features);
131
- let versionRange: IVersionRange | undefined = getVersionRange(deviceType);
132
117
 
118
+ const versionRange = getVersionRange(deviceType);
133
119
  if (versionRange) {
134
120
  return versionRange;
135
121
  }
@@ -142,22 +128,25 @@ export const getMethodVersionRange = (
142
128
  ];
143
129
  for (const model of modelFallbacks) {
144
130
  if (DeviceModelToTypes[model].includes(deviceType)) {
145
- versionRange = getVersionRange(model);
131
+ const versionRange = getVersionRange(model);
146
132
  if (versionRange) {
147
133
  return versionRange;
148
134
  }
149
135
  }
150
136
  }
151
137
 
152
- return versionRange;
138
+ return undefined;
153
139
  };
154
140
 
141
+ export const isMethodVersionRangeUnsupported = (versionRange?: IVersionRange): boolean =>
142
+ versionRange?.unsupported === true;
143
+
155
144
  export const getFirmwareType = (features: Features | undefined) => {
156
145
  if (!features) {
157
146
  return EFirmwareType.Universal;
158
147
  }
159
- if (features.fw_vendor === 'OneKey Bitcoin-only') {
160
- return EFirmwareType.BitcoinOnly;
148
+ if (features.firmwareType) {
149
+ return features.firmwareType;
161
150
  }
162
151
  // old firmware
163
152
  return features?.capabilities?.length > 0 &&
@@ -8,12 +8,8 @@ import type { Features, IVersionArray } from '../types';
8
8
  export const getDeviceFirmwareVersion = (features: Features | undefined): IVersionArray => {
9
9
  if (!features) return [0, 0, 0];
10
10
 
11
- if (semver.valid(features.onekey_firmware_version)) {
12
- return features.onekey_firmware_version?.split('.') as unknown as IVersionArray;
13
- }
14
-
15
- if (semver.valid(features.onekey_version)) {
16
- return features.onekey_version?.split('.') as unknown as IVersionArray;
11
+ if (features.firmwareVersion && semver.valid(features.firmwareVersion)) {
12
+ return features.firmwareVersion.split('.').map(Number) as IVersionArray;
17
13
  }
18
14
 
19
15
  return [0, 0, 0];
@@ -23,7 +19,7 @@ export const getDeviceFirmwareVersion = (features: Features | undefined): IVersi
23
19
  * Get Connected Device bluetooth firmware version by features
24
20
  */
25
21
  export const getDeviceBLEFirmwareVersion = (features: Features): IVersionArray => {
26
- const bleVer = features?.onekey_ble_version || features?.ble_ver;
22
+ const bleVer = features?.bleVersion;
27
23
 
28
24
  if (!bleVer) {
29
25
  return [0, 0, 0];
@@ -46,24 +42,10 @@ export const getDeviceBootloaderVersion = (features: Features | undefined): IVer
46
42
  if (!features) return [0, 0, 0];
47
43
 
48
44
  // classic1s 3.5.0 pro 4.6.0
49
- if (semver.valid(features.onekey_boot_version)) {
50
- return features.onekey_boot_version?.split('.') as unknown as IVersionArray;
45
+ if (features.bootloaderVersion && semver.valid(features.bootloaderVersion)) {
46
+ return features.bootloaderVersion.split('.').map(Number) as IVersionArray;
51
47
  }
52
48
 
53
- // low version hardware
54
- if (!features.bootloader_version) {
55
- if (features.bootloader_mode) {
56
- return [
57
- features?.major_version ?? 0,
58
- features?.minor_version ?? 0,
59
- features?.patch_version ?? 0,
60
- ];
61
- }
62
- return [0, 0, 0];
63
- }
64
- if (semver.valid(features.bootloader_version)) {
65
- return features.bootloader_version?.split('.') as unknown as IVersionArray;
66
- }
67
49
  return [0, 0, 0];
68
50
  };
69
51
 
@@ -71,8 +53,8 @@ export const getDeviceBootloaderVersion = (features: Features | undefined): IVer
71
53
  * Get Connected Device boardloader version by features
72
54
  */
73
55
  export const getDeviceBoardloaderVersion = (features: Features): IVersionArray => {
74
- if (semver.valid(features?.onekey_board_version)) {
75
- return features?.onekey_board_version?.split('.') as unknown as IVersionArray;
56
+ if (features?.boardVersion && semver.valid(features.boardVersion)) {
57
+ return features.boardVersion.split('.').map(Number) as IVersionArray;
76
58
  }
77
59
 
78
60
  return [0, 0, 0];
@@ -5,7 +5,7 @@ import type { Features } from '../types';
5
5
  /**
6
6
  * 检测故障固件设备
7
7
  * 检测规则:
8
- * - 序列号范围:21032200001 到 21032201500 (从 onekey_serial 字段提取)
8
+ * - 序列号范围:21032200001 到 21032201500
9
9
  * - SE版本为 1.1.0.2
10
10
  *
11
11
  * 对齐之前版本的检测逻辑
@@ -13,13 +13,13 @@ import type { Features } from '../types';
13
13
  export const findDefectiveBatchDevice = (features: Features) => {
14
14
  if (!features) return;
15
15
 
16
- const { onekey_serial: onekeySerial, se_ver: seVer } = features;
17
- if (!onekeySerial) return;
16
+ const { serialNo, seVersion } = features;
17
+ if (!serialNo) return;
18
18
 
19
- const versionNum = +onekeySerial.slice(5);
19
+ const versionNum = +serialNo.slice(5);
20
20
  if (Number.isNaN(versionNum)) return;
21
21
 
22
- return versionNum >= 21032200001 && versionNum <= 21032201500 && seVer === '1.1.0.2';
22
+ return versionNum >= 21032200001 && versionNum <= 21032201500 && seVersion === '1.1.0.2';
23
23
  };
24
24
 
25
25
  /**
@@ -29,7 +29,7 @@ export const getDefectiveDeviceInfo = (features: Features) => {
29
29
  if (!findDefectiveBatchDevice(features)) return null;
30
30
  const serialNo = getDeviceUUID(features);
31
31
  const deviceType = getDeviceType(features);
32
- const seVersion = features.se_ver;
32
+ const { seVersion } = features;
33
33
 
34
34
  return {
35
35
  serialNo,
@@ -11,6 +11,7 @@ export {
11
11
  getDeviceUUID,
12
12
  getDeviceLabel,
13
13
  getMethodVersionRange,
14
+ isMethodVersionRangeUnsupported,
14
15
  getFirmwareType,
15
16
  } from './deviceInfoUtils';
16
17
  export {