@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,8 +1,6 @@
1
1
  import semver from 'semver';
2
2
  import { EDeviceType, ERRORS, HardwareErrorCode } from '@onekeyfe/hd-shared';
3
3
 
4
- import { getDeviceFirmwareVersion, getDeviceType } from '../../../utils';
5
-
6
4
  import type { Device } from '../../../device/Device';
7
5
  import type { MessageResponse, TypedCall } from '@onekeyfe/hd-transport';
8
6
 
@@ -21,10 +19,10 @@ export const signTypedHash = async ({
21
19
  domainHash: string;
22
20
  messageHash: string | undefined;
23
21
  }): Promise<MessageResponse<'EthereumTypedDataSignatureOneKey'>> => {
24
- const deviceType = getDeviceType(device.features);
22
+ const deviceType = device.getCurrentDeviceType();
25
23
  if (deviceType === EDeviceType.Touch || deviceType === EDeviceType.Pro) {
26
24
  // Touch Pro Sign NestedArrays
27
- const currentVersion = getDeviceFirmwareVersion(device.features).join('.');
25
+ const currentVersion = device.getCurrentFirmwareVersionString() ?? '0.0.0';
28
26
  const supportNestedArraysSignVersion = '4.2.0';
29
27
 
30
28
  // 4.2.0 is the first version that supports nested arrays in signTypedData
@@ -7,10 +7,12 @@ export default async function ({
7
7
  typedCall: TypedCall;
8
8
  param: EthereumGetAddressOneKey;
9
9
  }): Promise<MessageResponse<'EthereumAddress'>> {
10
- return typedCall('EthereumGetAddress', 'EthereumAddress', {
10
+ // legacy EthereumGetAddress 的生成类型没有 chain_id 字段,但旧固件按 OneKey 扩展
11
+ // 接受该字段;通过预先声明的对象(非 fresh literal)携带额外字段,保持原有运行时行为。
12
+ const message = {
11
13
  address_n: param.address_n,
12
14
  show_display: param.show_display,
13
- // @ts-ignore
14
15
  chain_id: param.chain_id,
15
- });
16
+ };
17
+ return typedCall('EthereumGetAddress', 'EthereumAddress', message);
16
18
  }
@@ -11,10 +11,12 @@ export default async function ({
11
11
  typedCall: TypedCall;
12
12
  param: EthereumGetPublicKeyOneKey;
13
13
  }): Promise<MessageResponse<'EthereumPublicKey'>> {
14
- return typedCall('EthereumGetPublicKey', 'EthereumPublicKey', {
14
+ // legacy EthereumGetPublicKey 的生成类型没有 chain_id 字段,但旧固件按 OneKey 扩展
15
+ // 接受该字段;通过预先声明的对象(非 fresh literal)携带额外字段,保持原有运行时行为。
16
+ const message = {
15
17
  address_n: param.address_n,
16
18
  show_display: param.show_display,
17
- // @ts-ignore
18
19
  chain_id: param.chain_id,
19
- });
20
+ };
21
+ return typedCall('EthereumGetPublicKey', 'EthereumPublicKey', message);
20
22
  }
@@ -11,12 +11,14 @@ export default async function ({
11
11
  typedCall: TypedCall;
12
12
  params: EthereumSignMessageOneKey;
13
13
  }): Promise<EthereumMessageSignature> {
14
- const res = await typedCall('EthereumSignMessage', 'EthereumMessageSignature', {
14
+ // legacy EthereumSignMessage 的生成类型没有 chain_id 字段,但旧固件按 OneKey 扩展
15
+ // 接受该字段;通过预先声明的对象(非 fresh literal)携带额外字段,保持原有运行时行为。
16
+ const message = {
15
17
  address_n: params.address_n,
16
18
  message: params.message,
17
- // @ts-ignore
18
19
  chain_id: params.chain_id,
19
- });
20
+ };
21
+ const res = await typedCall('EthereumSignMessage', 'EthereumMessageSignature', message);
20
22
 
21
23
  return Promise.resolve(res.message);
22
24
  }
@@ -16,22 +16,23 @@ export const signTypedData = async ({
16
16
  }) => {
17
17
  const { primaryType }: EthereumSignTypedDataMessage<EthereumSignTypedDataTypes> = data;
18
18
 
19
+ // legacy EthereumSignTypedData 的生成类型没有 chain_id 字段,但旧固件按 OneKey 扩展
20
+ // 接受该字段;通过预先声明的对象(非 fresh literal)携带额外字段,保持原有运行时行为。
21
+ const message = {
22
+ address_n: addressN,
23
+ primary_type: primaryType as string,
24
+ metamask_v4_compat: metamaskV4Compat,
25
+ chain_id: chainId,
26
+ };
19
27
  const response = await typedCall(
20
28
  'EthereumSignTypedData',
21
- // @ts-ignore
22
29
  [
23
30
  'EthereumTypedDataStructRequest',
24
31
  'EthereumTypedDataValueRequest',
25
32
  'EthereumTypedDataSignature',
26
33
  'EthereumGnosisSafeTxRequest',
27
34
  ],
28
- {
29
- address_n: addressN,
30
- primary_type: primaryType as string,
31
- metamask_v4_compat: metamaskV4Compat,
32
- // @ts-ignore
33
- chain_id: chainId,
34
- }
35
+ message
35
36
  );
36
37
  return response;
37
38
  };
@@ -1,8 +1,6 @@
1
1
  import semver from 'semver';
2
2
  import { EDeviceType, ERRORS, HardwareErrorCode } from '@onekeyfe/hd-shared';
3
3
 
4
- import { getDeviceFirmwareVersion, getDeviceType } from '../../../utils';
5
-
6
4
  import type { Device } from '../../../device/Device';
7
5
  import type { MessageResponse, TypedCall } from '@onekeyfe/hd-transport';
8
6
 
@@ -24,10 +22,10 @@ export const signTypedHash = async ({
24
22
  | MessageResponse<'EthereumTypedDataSignature'>
25
23
  | MessageResponse<'EthereumTypedDataSignatureOneKey'>
26
24
  > => {
27
- const deviceType = getDeviceType(device.features);
25
+ const deviceType = device.getCurrentDeviceType();
28
26
  if (deviceType === EDeviceType.Touch || deviceType === EDeviceType.Pro) {
29
27
  // Touch Pro Sign NestedArrays
30
- const currentVersion = getDeviceFirmwareVersion(device.features).join('.');
28
+ const currentVersion = device.getCurrentFirmwareVersionString() ?? '0.0.0';
31
29
  const supportNestedArraysSignVersion = '4.2.0';
32
30
 
33
31
  // 4.2.0 is the first version that supports nested arrays in signTypedData
@@ -40,11 +38,13 @@ export const signTypedHash = async ({
40
38
  }
41
39
  }
42
40
 
43
- return typedCall('EthereumSignTypedHash', 'EthereumTypedDataSignature', {
41
+ // legacy EthereumSignTypedHash 的生成类型没有 chain_id 字段,但旧固件按 OneKey 扩展
42
+ // 接受该字段;通过预先声明的对象(非 fresh literal)携带额外字段,保持原有运行时行为。
43
+ const message = {
44
44
  address_n: addressN,
45
45
  domain_separator_hash: domainHash ?? '',
46
46
  message_hash: messageHash,
47
- // @ts-ignore
48
47
  chain_id: chainId,
49
- });
48
+ };
49
+ return typedCall('EthereumSignTypedHash', 'EthereumTypedDataSignature', message);
50
50
  };
@@ -7,13 +7,15 @@ export default async function ({
7
7
  typedCall: TypedCall;
8
8
  params: EthereumVerifyMessageOneKey;
9
9
  }): Promise<Success> {
10
- const res = await typedCall('EthereumVerifyMessage', 'Success', {
10
+ // legacy EthereumVerifyMessage 的生成类型没有 chain_id 字段,但旧固件按 OneKey 扩展
11
+ // 接受该字段;通过预先声明的对象(非 fresh literal)携带额外字段,保持原有运行时行为。
12
+ const message = {
11
13
  signature: params.signature,
12
14
  message: params.message,
13
15
  address: params.address,
14
- // @ts-ignore
15
16
  chain_id: params.chain_id,
16
- });
17
+ };
18
+ const res = await typedCall('EthereumVerifyMessage', 'Success', message);
17
19
 
18
20
  return Promise.resolve(res.message);
19
21
  }
@@ -8,7 +8,7 @@ import {
8
8
 
9
9
  import { FirmwareUpdateTipMessage, UI_REQUEST, createUiMessage } from '../../events/ui-request';
10
10
  import { DevicePool } from '../../device/DevicePool';
11
- import { LoggerNames, getDeviceType, getDeviceUUID, getLogger, wait } from '../../utils';
11
+ import { LoggerNames, getDeviceUUID, getLogger, wait } from '../../utils';
12
12
  import { DeviceModelToTypes } from '../../types';
13
13
  import { DataManager } from '../../data-manager';
14
14
  import { BaseMethod } from '../BaseMethod';
@@ -142,8 +142,8 @@ export class FirmwareUpdateBaseMethod<Params> extends BaseMethod<Params> {
142
142
  let timeoutTimer: ReturnType<typeof setTimeout> | undefined;
143
143
 
144
144
  const isTouchOrProDevice =
145
- getDeviceType(this?.device?.features) === EDeviceType.Touch ||
146
- getDeviceType(this?.device?.features) === EDeviceType.Pro;
145
+ this?.device?.getCurrentDeviceType() === EDeviceType.Touch ||
146
+ this?.device?.getCurrentDeviceType() === EDeviceType.Pro;
147
147
 
148
148
  const intervalTimer: ReturnType<typeof setInterval> | undefined = setInterval(
149
149
  async () => {
@@ -187,7 +187,7 @@ export class FirmwareUpdateBaseMethod<Params> extends BaseMethod<Params> {
187
187
  true
188
188
  );
189
189
  await this.device.initialize();
190
- if (this.device.features?.bootloader_mode) {
190
+ if (this.device.isBootloader()) {
191
191
  clearInterval(intervalTimer);
192
192
  this.checkPromise?.resolve(true);
193
193
  }
@@ -220,7 +220,7 @@ export class FirmwareUpdateBaseMethod<Params> extends BaseMethod<Params> {
220
220
  const devicesDescriptor = deviceDiff?.descriptors ?? [];
221
221
  const { deviceList } = await DevicePool.getDevices(devicesDescriptor, connectId);
222
222
 
223
- if (deviceList.length === 1 && deviceList[0]?.features?.bootloader_mode) {
223
+ if (deviceList.length === 1 && deviceList[0]?.isBootloader()) {
224
224
  // should update current device from cache
225
225
  // because device was reboot and had some new requests
226
226
  this.device.updateFromCache(deviceList[0]);
@@ -236,9 +236,9 @@ export class FirmwareUpdateBaseMethod<Params> extends BaseMethod<Params> {
236
236
 
237
237
  async enterBootloaderMode() {
238
238
  const typedCall = this.device.getCommands().typedCall.bind(this.device.getCommands());
239
- if (this.device.features && !this.device.features.bootloader_mode) {
239
+ if (this.device.features && !this.device.isBootloader()) {
240
240
  const uuid = getDeviceUUID(this.device.features);
241
- const deviceType = getDeviceType(this.device.features);
241
+ const deviceType = this.device.getCurrentDeviceType();
242
242
  // auto go to bootloader mode
243
243
  try {
244
244
  this.postTipMessage(FirmwareUpdateTipMessage.AutoRebootToBootloader);
@@ -436,7 +436,7 @@ export class FirmwareUpdateBaseMethod<Params> extends BaseMethod<Params> {
436
436
  const deviceDiff = await this.device.deviceConnector?.enumerate();
437
437
  const devicesDescriptor = deviceDiff?.descriptors ?? [];
438
438
  const { deviceList } = await DevicePool.getDevices(devicesDescriptor, undefined);
439
- if (deviceList.length === 1 && deviceList[0]?.features?.bootloader_mode) {
439
+ if (deviceList.length === 1 && deviceList[0]?.isBootloader()) {
440
440
  this.device.updateFromCache(deviceList[0]);
441
441
  await this.device.acquire();
442
442
  this.device.getCommands().mainId = this.device.mainId ?? '';
@@ -1,7 +1,7 @@
1
1
  import semver from 'semver';
2
2
  import { EDeviceType } from '@onekeyfe/hd-shared';
3
3
 
4
- import { getDeviceType } from '../../utils';
4
+ import { getDeviceBootloaderVersion, getDeviceType } from '../../utils';
5
5
 
6
6
  import type { Features, IVersionArray } from '../../types';
7
7
 
@@ -38,9 +38,10 @@ export function shouldUpdateBootloaderForClassicAndMini({
38
38
  export function isEnteredManuallyBoot(features: Features, updateType: string) {
39
39
  const deviceType = getDeviceType(features);
40
40
  const isMini = deviceType === EDeviceType.Mini;
41
+ const bootloaderVersion = getDeviceBootloaderVersion(features).join('.');
41
42
  const isBoot183ClassicUpBle =
42
43
  updateType === 'firmware' &&
43
44
  deviceType === EDeviceType.Classic &&
44
- features.bootloader_version === '1.8.3';
45
+ bootloaderVersion === '1.8.3';
45
46
  return isMini || isBoot183ClassicUpBle;
46
47
  }
@@ -41,7 +41,7 @@ export const getBinary = async ({
41
41
  }
42
42
 
43
43
  if (version && !semver.eq(releaseInfo.version.join('.'), version.join('.'))) {
44
- const touchWithoutVersion = getDeviceType(features) === 'touch' && !features.onekey_version;
44
+ const touchWithoutVersion = getDeviceType(features) === 'touch' && !features.firmwareVersion;
45
45
  if (!touchWithoutVersion) {
46
46
  throw ERRORS.TypedError(HardwareErrorCode.RuntimeError, 'firmware version mismatch');
47
47
  }
@@ -12,7 +12,7 @@ export const getFirmwareReleaseInfo = (features: Features, firmwareType: EFirmwa
12
12
  const firmwareStatus = DataManager.getFirmwareStatus(features, firmwareType);
13
13
  const changelog = DataManager.getFirmwareChangelog(features, firmwareType);
14
14
  const release = DataManager.getFirmwareLatestRelease(features, firmwareType);
15
- const bootloaderMode = !!features.bootloader_mode;
15
+ const bootloaderMode = !!features.bootloaderMode;
16
16
  return {
17
17
  status: firmwareStatus,
18
18
  changelog,
@@ -25,7 +25,7 @@ export const getBleFirmwareReleaseInfo = (features: Features) => {
25
25
  const firmwareStatus = DataManager.getBLEFirmwareStatus(features);
26
26
  const changelog = DataManager.getBleFirmwareChangelog(features);
27
27
  const release = DataManager.getBleFirmwareLatestRelease(features);
28
- const bootloaderMode = !!features.bootloader_mode;
28
+ const bootloaderMode = !!features.bootloaderMode;
29
29
  return {
30
30
  status: firmwareStatus,
31
31
  changelog,
@@ -52,7 +52,7 @@ export const getBootloaderReleaseInfo = ({
52
52
  Object.prototype.hasOwnProperty.call(item, 'en-US')
53
53
  );
54
54
 
55
- const bootloaderMode = !!features.bootloader_mode;
55
+ const bootloaderMode = !!features.bootloaderMode;
56
56
 
57
57
  let shouldUpdate = false;
58
58
 
@@ -3,19 +3,13 @@ import { blake2s } from '@noble/hashes/blake2s';
3
3
  import JSZip from 'jszip';
4
4
  import { ERRORS, HardwareErrorCode } from '@onekeyfe/hd-shared';
5
5
 
6
- import { getDeviceFirmwareVersion } from '../../utils/deviceVersionUtils';
7
- import {
8
- LoggerNames,
9
- getDeviceBootloaderVersion,
10
- getDeviceType,
11
- getLogger,
12
- wait,
13
- } from '../../utils';
6
+ import { LoggerNames, getDeviceBootloaderVersion, getLogger, wait } from '../../utils';
14
7
  import { DEVICE, UI_REQUEST, createUiMessage } from '../../events';
15
8
  import { DeviceModelToTypes } from '../../types';
16
9
  import { bytesToHex } from '../helpers/hexUtils';
17
10
  import { DataManager } from '../../data-manager';
18
11
  import { DevicePool } from '../../device/DevicePool';
12
+ import { buildProtocolV1FeaturesPayload } from '../../deviceProfile';
19
13
 
20
14
  import type { KnownDevice } from '../../types';
21
15
  import type { TypedCall, TypedResponseMessage } from '../../device/DeviceCommands';
@@ -41,7 +35,7 @@ const isDeviceDisconnectedError = (error: unknown) => {
41
35
 
42
36
  const postConfirmationMessage = (device: Device) => {
43
37
  // only if firmware is already installed. fresh device does not require button confirmation
44
- if (device.features?.firmware_present) {
38
+ if (device.features?.firmwarePresent) {
45
39
  device.emit(DEVICE.BUTTON, device, { code: 'ButtonRequest_FirmwareUpdate' });
46
40
  }
47
41
  };
@@ -107,7 +101,7 @@ export const uploadFirmware = async (
107
101
  },
108
102
  isUpdateBootloader?: boolean
109
103
  ) => {
110
- const deviceType = getDeviceType(device.features);
104
+ const deviceType = device.getCurrentDeviceType();
111
105
  if (DeviceModelToTypes.model_mini.includes(deviceType)) {
112
106
  postConfirmationMessage(device);
113
107
  postProgressTip(device, 'ConfirmOnDevice', postMessage);
@@ -116,7 +110,9 @@ export const uploadFirmware = async (
116
110
 
117
111
  if (isFirmware && !isUpdateBootloader) {
118
112
  const newFeatures = await typedCall('GetFeatures', 'Features', {});
119
- const deviceBootloaderVersion = getDeviceBootloaderVersion(newFeatures.message).join('.');
113
+ const deviceBootloaderVersion = getDeviceBootloaderVersion(
114
+ buildProtocolV1FeaturesPayload(newFeatures.message, device.features)
115
+ ).join('.');
120
116
  const supportUpgradeFileHeader = semver.gte(deviceBootloaderVersion, '2.1.0');
121
117
  Log.debug('supportUpgradeFileHeader:', supportUpgradeFileHeader);
122
118
 
@@ -429,7 +425,7 @@ const emmcFileWriteWithRetry = async (
429
425
  const deviceDiff = await device.deviceConnector?.enumerate();
430
426
  const devicesDescriptor = deviceDiff?.descriptors ?? [];
431
427
  const { deviceList } = await DevicePool.getDevices(devicesDescriptor, undefined);
432
- if (deviceList.length === 1 && deviceList[0]?.features?.bootloader_mode) {
428
+ if (deviceList.length === 1 && deviceList[0]?.isBootloader()) {
433
429
  device.updateFromCache(deviceList[0]);
434
430
  await device.acquire();
435
431
  device.getCommands().mainId = device.mainId ?? '';
@@ -1,18 +1,63 @@
1
+ import semver from 'semver';
1
2
  import {
3
+ EDeviceType,
2
4
  HardwareErrorCode,
3
5
  TypedError,
4
6
  createDeviceNotSupportMethodError,
5
7
  } from '@onekeyfe/hd-shared';
6
8
 
7
- import { supportBatchPublicKey } from '../../utils/deviceFeaturesUtils';
8
9
  import { isEqualBip44CoinType } from './pathUtils';
9
10
  import { splitArray } from '../../utils/arrayUtils';
10
- import { getDeviceType, getFirmwareType } from '../../utils';
11
11
  import { DeviceModelToTypes } from '../../types';
12
12
 
13
13
  import type { EcdsaPublicKeys, Path } from '@onekeyfe/hd-transport';
14
14
  import type { Device } from '../../device/Device';
15
15
 
16
+ /**
17
+ * Protocol-agnostic version of `supportBatchPublicKey` (utils/deviceFeaturesUtils):
18
+ * derives device type and firmware version through Device accessors so that
19
+ * Protocol V2 devices (features === undefined, profile set) resolve correctly.
20
+ */
21
+ export function supportBatchPublicKeyByDevice(
22
+ device: Device,
23
+ options?: {
24
+ includeNode?: boolean;
25
+ }
26
+ ): boolean {
27
+ const currentVersion = device.getCurrentFirmwareVersionString() ?? '0.0.0';
28
+ const deviceType = device.getCurrentDeviceType();
29
+
30
+ // Pro2 (Protocol V2) 版本线独立于 Pro 系列,固件从首个版本即支持 batch / include_node,
31
+ // 不能套用下面 Pro 系列的 4.x 门槛。
32
+ if (device.isProtocolV2() || deviceType === EDeviceType.Pro2) {
33
+ return true;
34
+ }
35
+
36
+ // btc batch get public key
37
+ if (!!options?.includeNode && deviceType === EDeviceType.Pro) {
38
+ return semver.gte(currentVersion, '4.14.0');
39
+ }
40
+ if (!!options?.includeNode && deviceType === EDeviceType.Touch) {
41
+ return semver.gte(currentVersion, '4.11.0');
42
+ }
43
+ if (!!options?.includeNode && DeviceModelToTypes.model_classic1s.includes(deviceType)) {
44
+ return semver.gte(currentVersion, '3.12.0');
45
+ }
46
+ if (!!options?.includeNode && DeviceModelToTypes.model_mini.includes(deviceType)) {
47
+ return semver.gte(currentVersion, '3.10.0');
48
+ }
49
+ if (options?.includeNode) {
50
+ return false;
51
+ }
52
+
53
+ // support batch get public key
54
+ if (deviceType === EDeviceType.Touch || deviceType === EDeviceType.Pro) {
55
+ return semver.gte(currentVersion, '3.1.0');
56
+ }
57
+
58
+ return semver.gte(currentVersion, '2.6.0');
59
+ }
60
+
16
61
  export async function batchGetPublickeys(
17
62
  device: Device,
18
63
  paths: Path[],
@@ -28,9 +73,9 @@ export async function batchGetPublickeys(
28
73
  throw TypedError(HardwareErrorCode.ForbiddenKeyPath, 'Path length must be greater than 3');
29
74
  }
30
75
 
31
- const supportsBatchPublicKey = supportBatchPublicKey(device.features, options);
76
+ const supportsBatchPublicKey = supportBatchPublicKeyByDevice(device, options);
32
77
  if (!supportsBatchPublicKey) {
33
- throw createDeviceNotSupportMethodError('BatchGetPublickeys', getFirmwareType(device.features));
78
+ throw createDeviceNotSupportMethodError('BatchGetPublickeys', device.getCurrentFirmwareType());
34
79
  }
35
80
 
36
81
  const existsPathNotEqualCoinType = paths.find(p => !isEqualBip44CoinType(p.address_n, coinType));
@@ -39,7 +84,7 @@ export async function batchGetPublickeys(
39
84
  }
40
85
 
41
86
  let batchSize = 10;
42
- const deviceType = getDeviceType(device.features);
87
+ const deviceType = device.getCurrentDeviceType();
43
88
  if (DeviceModelToTypes.model_mini.includes(deviceType)) {
44
89
  batchSize = 10;
45
90
  } else if (DeviceModelToTypes.model_touch.includes(deviceType)) {
@@ -60,7 +105,7 @@ export async function batchGetPublickeys(
60
105
  if (res.type !== 'EcdsaPublicKeys') {
61
106
  throw createDeviceNotSupportMethodError(
62
107
  'BatchGetPublickeys',
63
- getFirmwareType(device.features)
108
+ device.getCurrentFirmwareType()
64
109
  );
65
110
  } else {
66
111
  result.root_fingerprint = res.message.root_fingerprint;
@@ -0,0 +1,51 @@
1
+ import { ERRORS, HardwareErrorCode } from '@onekeyfe/hd-shared';
2
+
3
+ export const invalidParameter = (message: string) =>
4
+ ERRORS.TypedError(HardwareErrorCode.CallMethodInvalidParameter, message);
5
+
6
+ export function validateNonEmptyString(value: unknown, name: string): string {
7
+ if (typeof value !== 'string' || value.trim().length === 0) {
8
+ throw invalidParameter(`Parameter [${name}] is required and must be a non-empty string.`);
9
+ }
10
+ return value;
11
+ }
12
+
13
+ export function validateNonNegativeInteger(
14
+ value: unknown,
15
+ name: string,
16
+ defaultValue?: number
17
+ ): number {
18
+ if (value === undefined || value === null) {
19
+ if (defaultValue !== undefined) return defaultValue;
20
+ throw invalidParameter(`Missing required parameter: ${name}`);
21
+ }
22
+
23
+ const numeric = typeof value === 'string' && value.trim() !== '' ? Number(value) : value;
24
+ if (typeof numeric !== 'number' || !Number.isSafeInteger(numeric) || numeric < 0) {
25
+ throw invalidParameter(`Parameter [${name}] must be a non-negative integer.`);
26
+ }
27
+ return numeric;
28
+ }
29
+
30
+ export function validateOptionalNonNegativeInteger(
31
+ value: unknown,
32
+ name: string
33
+ ): number | undefined {
34
+ if (value === undefined || value === null) return undefined;
35
+ return validateNonNegativeInteger(value, name);
36
+ }
37
+
38
+ export function validateOptionalPercentage(value: unknown, name: string): number | undefined {
39
+ const numeric = validateOptionalNonNegativeInteger(value, name);
40
+ if (numeric === undefined) return undefined;
41
+ if (numeric > 100) {
42
+ throw invalidParameter(`Parameter [${name}] must be between 0 and 100.`);
43
+ }
44
+ return numeric;
45
+ }
46
+
47
+ export function validateRequiredData(value: unknown, name: string): void {
48
+ if (value === undefined || value === null) {
49
+ throw invalidParameter(`Missing required parameter: ${name}`);
50
+ }
51
+ }
package/src/api/index.ts CHANGED
@@ -3,6 +3,7 @@ export { default as preInitialize } from './device/PreInitialize';
3
3
 
4
4
  export { default as searchDevices } from './SearchDevices';
5
5
  export { default as getFeatures } from './GetFeatures';
6
+ export { default as getDeviceInfo } from './GetDeviceInfo';
6
7
  export { default as getOnekeyFeatures } from './GetOnekeyFeatures';
7
8
  export { default as getPassphraseState } from './GetPassphraseState';
8
9
  export { default as getLogs } from './GetLogs';
@@ -38,8 +39,41 @@ export { default as getNextU2FCounter } from './u2f/GetNextU2FCounter';
38
39
  export { default as firmwareUpdate } from './FirmwareUpdate';
39
40
  export { default as firmwareUpdateV2 } from './FirmwareUpdateV2';
40
41
  export { default as firmwareUpdateV3 } from './FirmwareUpdateV3';
42
+ export { default as firmwareUpdateV4 } from './FirmwareUpdateV4';
41
43
  export { default as promptWebDeviceAccess } from './PromptWebDeviceAccess';
42
44
 
45
+ // File system & device control API (Protocol V2 only)
46
+ export { default as getProtoVersion } from './protocol-v2/GetProtoVersion';
47
+ export { default as ping } from './protocol-v2/Ping';
48
+ export { default as deviceReboot } from './protocol-v2/DeviceReboot';
49
+ export { default as deviceGetDeviceInfo } from './protocol-v2/DeviceGetDeviceInfo';
50
+ export { default as deviceGetOnboardingStatus } from './protocol-v2/DeviceGetOnboardingStatus';
51
+ export { default as deviceFirmwareUpdate } from './protocol-v2/DeviceFirmwareUpdate';
52
+ export { default as deviceGetFirmwareUpdateStatus } from './protocol-v2/DeviceGetFirmwareUpdateStatus';
53
+ export { default as devReboot } from './protocol-v2/DevReboot';
54
+ export { default as devGetDeviceInfo } from './protocol-v2/DeviceGetDeviceInfo';
55
+ export { default as devFirmwareUpdate } from './protocol-v2/DeviceFirmwareUpdate';
56
+ export { default as devGetFirmwareUpdateStatus } from './protocol-v2/DeviceGetFirmwareUpdateStatus';
57
+ export { default as factoryDeviceInfoSettings } from './protocol-v2/FactoryDeviceInfoSettings';
58
+ export { default as factoryGetDeviceInfo } from './protocol-v2/FactoryGetDeviceInfo';
59
+ export { default as filesystemFixPermission } from './protocol-v2/FilesystemFixPermission';
60
+ export { default as filesystemFormat } from './protocol-v2/FilesystemFormat';
61
+ export { default as filesystemDiskControl } from './protocol-v2/FilesystemDiskControl';
62
+ export { default as fileRead } from './FileRead';
63
+ export { default as fileWrite } from './FileWrite';
64
+ export { default as fileDelete } from './FileDelete';
65
+ export { default as dirList } from './DirList';
66
+ export { default as dirMake } from './DirMake';
67
+ export { default as dirRemove } from './DirRemove';
68
+ export { default as pathInfo } from './PathInfo';
69
+ export { default as filesystemFileRead } from './FileRead';
70
+ export { default as filesystemFileWrite } from './FileWrite';
71
+ export { default as filesystemFileDelete } from './FileDelete';
72
+ export { default as filesystemDirList } from './DirList';
73
+ export { default as filesystemDirMake } from './DirMake';
74
+ export { default as filesystemDirRemove } from './DirRemove';
75
+ export { default as filesystemPathInfoQuery } from './PathInfo';
76
+
43
77
  export { default as cipherKeyValue } from './CipherKeyValue';
44
78
 
45
79
  export { default as allNetworkGetAddress } from './allnetwork/AllNetworkGetAddress';
@@ -134,15 +134,14 @@ export default class KaspaSignTransaction extends BaseMethod<KaspaSignTransactio
134
134
 
135
135
  const response = await typedCall(
136
136
  'KaspaTxInputAck',
137
- // @ts-expect-error
138
137
  ['KaspaTxInputRequest', 'KaspaSignedTx'],
139
138
  {
140
- address_n: input.path,
139
+ // params.inputs 的 path 可能是字符串或已解析数组,统一归一为 address_n 数组
140
+ address_n: validatePath(input.path, 3),
141
141
  raw_message: bytesToHex(rawMessage),
142
142
  }
143
143
  );
144
144
 
145
- // @ts-expect-error
146
145
  return this.processTxRequest(typedCall, response, nextIndex, signature);
147
146
  }
148
147
 
@@ -164,12 +163,12 @@ export default class KaspaSignTransaction extends BaseMethod<KaspaSignTransactio
164
163
 
165
164
  const { device, params } = this;
166
165
 
167
- // @ts-expect-error
168
166
  const response = await device.commands.typedCall(
169
167
  'KaspaSignTx',
170
168
  ['KaspaTxInputRequest', 'KaspaSignedTx'],
171
169
  {
172
- address_n: input.path,
170
+ // init() 已把 path 归一为数组,这里再过一遍 validatePath 收窄类型
171
+ address_n: validatePath(input.path, 3),
173
172
  raw_message: bytesToHex(rawMessage),
174
173
  scheme: params.scheme,
175
174
  prefix: params.prefix,
@@ -32,6 +32,10 @@ export default class LnurlAuth1 extends BaseMethod<ILnurlAuth> {
32
32
  model_touch: {
33
33
  min: '4.8.0',
34
34
  },
35
+ pro2: {
36
+ min: '0.0.0',
37
+ unsupported: true,
38
+ },
35
39
  };
36
40
  }
37
41
 
@@ -5,6 +5,7 @@ import { UI_REQUEST } from '../../constants/ui-request';
5
5
 
6
6
  import type { NeoGetAddress as HardwareNeoGetAddress } from '@onekeyfe/hd-transport';
7
7
  import type { NeoAddress, NeoGetAddressParams } from '../../types/api/neoGetAddress';
8
+ import type { DeviceFirmwareRange } from '../../types';
8
9
 
9
10
  export default class NeoGetAddress extends BaseMethod<HardwareNeoGetAddress[]> {
10
11
  hasBundle = false;
@@ -37,8 +38,12 @@ export default class NeoGetAddress extends BaseMethod<HardwareNeoGetAddress[]> {
37
38
  });
38
39
  }
39
40
 
40
- getVersionRange() {
41
+ getVersionRange(): DeviceFirmwareRange {
41
42
  return {
43
+ pro2: {
44
+ min: '0.0.0',
45
+ unsupported: true,
46
+ },
42
47
  pro: {
43
48
  min: '4.12.0',
44
49
  },
@@ -5,6 +5,7 @@ import { validateParams } from '../helpers/paramsValidator';
5
5
  import { formatAnyHex } from '../helpers/hexUtils';
6
6
 
7
7
  import type { NeoSignTx } from '@onekeyfe/hd-transport';
8
+ import type { DeviceFirmwareRange } from '../../types';
8
9
 
9
10
  export default class NeoSignTransaction extends BaseMethod<NeoSignTx> {
10
11
  init() {
@@ -29,8 +30,12 @@ export default class NeoSignTransaction extends BaseMethod<NeoSignTx> {
29
30
  };
30
31
  }
31
32
 
32
- getVersionRange() {
33
+ getVersionRange(): DeviceFirmwareRange {
33
34
  return {
35
+ pro2: {
36
+ min: '0.0.0',
37
+ unsupported: true,
38
+ },
34
39
  pro: {
35
40
  min: '4.12.0',
36
41
  },
@@ -4,7 +4,7 @@ import { BaseMethod } from '../BaseMethod';
4
4
  import { validateParams, validateResult } from '../helpers/paramsValidator';
5
5
 
6
6
  import type { NervosGetAddress as HardwareNervosGetAddress } from '@onekeyfe/hd-transport';
7
- import type { NervosAddress, NervosGetAddressParams } from '../../types';
7
+ import type { DeviceFirmwareRange, NervosAddress, NervosGetAddressParams } from '../../types';
8
8
 
9
9
  export default class NervosGetAddress extends BaseMethod<HardwareNervosGetAddress[]> {
10
10
  hasBundle = false;
@@ -40,8 +40,12 @@ export default class NervosGetAddress extends BaseMethod<HardwareNervosGetAddres
40
40
  });
41
41
  }
42
42
 
43
- getVersionRange() {
43
+ getVersionRange(): DeviceFirmwareRange {
44
44
  return {
45
+ pro2: {
46
+ min: '0.0.0',
47
+ unsupported: true,
48
+ },
45
49
  model_mini: {
46
50
  min: '3.7.0',
47
51
  },