@onekeyfe/hd-core 1.1.27-patch.1 → 1.2.0-alpha.0

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 (377) 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 +3025 -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.map +1 -1
  29. package/dist/api/GetOnekeyFeatures.d.ts.map +1 -1
  30. package/dist/api/GetPassphraseState.d.ts +6 -1
  31. package/dist/api/GetPassphraseState.d.ts.map +1 -1
  32. package/dist/api/PathInfo.d.ts +10 -0
  33. package/dist/api/PathInfo.d.ts.map +1 -0
  34. package/dist/api/PromptWebDeviceAccess.d.ts.map +1 -1
  35. package/dist/api/SearchDevices.d.ts +2 -1
  36. package/dist/api/SearchDevices.d.ts.map +1 -1
  37. package/dist/api/alephium/AlephiumGetAddress.d.ts +2 -6
  38. package/dist/api/alephium/AlephiumGetAddress.d.ts.map +1 -1
  39. package/dist/api/alephium/AlephiumSignMessage.d.ts +2 -5
  40. package/dist/api/alephium/AlephiumSignMessage.d.ts.map +1 -1
  41. package/dist/api/alephium/AlephiumSignTransaction.d.ts +5 -8
  42. package/dist/api/alephium/AlephiumSignTransaction.d.ts.map +1 -1
  43. package/dist/api/aptos/AptosGetAddress.d.ts.map +1 -1
  44. package/dist/api/benfen/BenfenGetAddress.d.ts +2 -9
  45. package/dist/api/benfen/BenfenGetAddress.d.ts.map +1 -1
  46. package/dist/api/benfen/BenfenGetPublicKey.d.ts +2 -9
  47. package/dist/api/benfen/BenfenGetPublicKey.d.ts.map +1 -1
  48. package/dist/api/benfen/BenfenSignMessage.d.ts +2 -8
  49. package/dist/api/benfen/BenfenSignMessage.d.ts.map +1 -1
  50. package/dist/api/benfen/BenfenSignTransaction.d.ts +2 -8
  51. package/dist/api/benfen/BenfenSignTransaction.d.ts.map +1 -1
  52. package/dist/api/btc/BTCGetAddress.d.ts +1 -11
  53. package/dist/api/btc/BTCGetAddress.d.ts.map +1 -1
  54. package/dist/api/btc/BTCGetPublicKey.d.ts +1 -11
  55. package/dist/api/btc/BTCGetPublicKey.d.ts.map +1 -1
  56. package/dist/api/btc/BTCSignMessage.d.ts +1 -15
  57. package/dist/api/btc/BTCSignMessage.d.ts.map +1 -1
  58. package/dist/api/btc/BTCSignPsbt.d.ts.map +1 -1
  59. package/dist/api/btc/BTCSignTransaction.d.ts +1 -11
  60. package/dist/api/btc/BTCSignTransaction.d.ts.map +1 -1
  61. package/dist/api/btc/BTCVerifyMessage.d.ts +1 -11
  62. package/dist/api/btc/BTCVerifyMessage.d.ts.map +1 -1
  63. package/dist/api/btc/helpers/versionLimit.d.ts +2 -11
  64. package/dist/api/btc/helpers/versionLimit.d.ts.map +1 -1
  65. package/dist/api/cardano/CardanoSignTransaction.d.ts.map +1 -1
  66. package/dist/api/conflux/ConfluxSignTransaction.d.ts.map +1 -1
  67. package/dist/api/device/DeviceLock.d.ts.map +1 -1
  68. package/dist/api/device/DeviceRebootToBoardloader.d.ts +1 -1
  69. package/dist/api/device/DeviceRebootToBoardloader.d.ts.map +1 -1
  70. package/dist/api/device/DeviceRebootToBootloader.d.ts.map +1 -1
  71. package/dist/api/device/DeviceSupportFeatures.d.ts.map +1 -1
  72. package/dist/api/device/DeviceUploadResource.d.ts.map +1 -1
  73. package/dist/api/device/DeviceVerify.d.ts.map +1 -1
  74. package/dist/api/dynex/DnxGetAddress.d.ts.map +1 -1
  75. package/dist/api/dynex/DnxSignTransaction.d.ts.map +1 -1
  76. package/dist/api/evm/EVMGetPublicKey.d.ts.map +1 -1
  77. package/dist/api/evm/EVMSignMessageEIP712.d.ts +2 -8
  78. package/dist/api/evm/EVMSignMessageEIP712.d.ts.map +1 -1
  79. package/dist/api/evm/EVMSignTypedData.d.ts.map +1 -1
  80. package/dist/api/evm/latest/signTypedData.d.ts +1 -1
  81. package/dist/api/evm/latest/signTypedData.d.ts.map +1 -1
  82. package/dist/api/evm/latest/signTypedHash.d.ts.map +1 -1
  83. package/dist/api/evm/legacyV1/getAddress.d.ts.map +1 -1
  84. package/dist/api/evm/legacyV1/getPublicKey.d.ts.map +1 -1
  85. package/dist/api/evm/legacyV1/signMessage.d.ts.map +1 -1
  86. package/dist/api/evm/legacyV1/signTypedData.d.ts +1 -1
  87. package/dist/api/evm/legacyV1/signTypedData.d.ts.map +1 -1
  88. package/dist/api/evm/legacyV1/signTypedHash.d.ts.map +1 -1
  89. package/dist/api/evm/legacyV1/verifyMessage.d.ts.map +1 -1
  90. package/dist/api/firmware/uploadFirmware.d.ts.map +1 -1
  91. package/dist/api/helpers/batchGetPublickeys.d.ts +3 -0
  92. package/dist/api/helpers/batchGetPublickeys.d.ts.map +1 -1
  93. package/dist/api/helpers/filesystemValidation.d.ts +7 -0
  94. package/dist/api/helpers/filesystemValidation.d.ts.map +1 -0
  95. package/dist/api/index.d.ts +32 -0
  96. package/dist/api/index.d.ts.map +1 -1
  97. package/dist/api/kaspa/KaspaSignTransaction.d.ts.map +1 -1
  98. package/dist/api/lightning/LnurlAuth.d.ts +4 -0
  99. package/dist/api/lightning/LnurlAuth.d.ts.map +1 -1
  100. package/dist/api/neo/NeoGetAddress.d.ts +2 -8
  101. package/dist/api/neo/NeoGetAddress.d.ts.map +1 -1
  102. package/dist/api/neo/NeoSignTransaction.d.ts +2 -8
  103. package/dist/api/neo/NeoSignTransaction.d.ts.map +1 -1
  104. package/dist/api/nervos/NervosGetAddress.d.ts +2 -9
  105. package/dist/api/nervos/NervosGetAddress.d.ts.map +1 -1
  106. package/dist/api/nervos/NervosSignTransaction.d.ts +9 -12
  107. package/dist/api/nervos/NervosSignTransaction.d.ts.map +1 -1
  108. package/dist/api/nexa/NexaGetAddress.d.ts +2 -8
  109. package/dist/api/nexa/NexaGetAddress.d.ts.map +1 -1
  110. package/dist/api/nexa/NexaSignTransaction.d.ts +2 -9
  111. package/dist/api/nexa/NexaSignTransaction.d.ts.map +1 -1
  112. package/dist/api/polkadot/PolkadotGetAddress.d.ts +3 -0
  113. package/dist/api/polkadot/PolkadotGetAddress.d.ts.map +1 -1
  114. package/dist/api/polkadot/networks.d.ts +3 -0
  115. package/dist/api/polkadot/networks.d.ts.map +1 -1
  116. package/dist/api/protocol-v2/DevReboot.d.ts +7 -0
  117. package/dist/api/protocol-v2/DevReboot.d.ts.map +1 -0
  118. package/dist/api/protocol-v2/DeviceFirmwareUpdate.d.ts +7 -0
  119. package/dist/api/protocol-v2/DeviceFirmwareUpdate.d.ts.map +1 -0
  120. package/dist/api/protocol-v2/DeviceGetDeviceInfo.d.ts +29 -0
  121. package/dist/api/protocol-v2/DeviceGetDeviceInfo.d.ts.map +1 -0
  122. package/dist/api/protocol-v2/DeviceGetFirmwareUpdateStatus.d.ts +6 -0
  123. package/dist/api/protocol-v2/DeviceGetFirmwareUpdateStatus.d.ts.map +1 -0
  124. package/dist/api/protocol-v2/DeviceGetOnboardingStatus.d.ts +6 -0
  125. package/dist/api/protocol-v2/DeviceGetOnboardingStatus.d.ts.map +1 -0
  126. package/dist/api/protocol-v2/DeviceReboot.d.ts +7 -0
  127. package/dist/api/protocol-v2/DeviceReboot.d.ts.map +1 -0
  128. package/dist/api/protocol-v2/FactoryDeviceInfoSettings.d.ts +7 -0
  129. package/dist/api/protocol-v2/FactoryDeviceInfoSettings.d.ts.map +1 -0
  130. package/dist/api/protocol-v2/FactoryGetDeviceInfo.d.ts +6 -0
  131. package/dist/api/protocol-v2/FactoryGetDeviceInfo.d.ts.map +1 -0
  132. package/dist/api/protocol-v2/FilesystemDiskControl.d.ts +13 -0
  133. package/dist/api/protocol-v2/FilesystemDiskControl.d.ts.map +1 -0
  134. package/dist/api/protocol-v2/FilesystemFixPermission.d.ts +6 -0
  135. package/dist/api/protocol-v2/FilesystemFixPermission.d.ts.map +1 -0
  136. package/dist/api/protocol-v2/FilesystemFormat.d.ts +6 -0
  137. package/dist/api/protocol-v2/FilesystemFormat.d.ts.map +1 -0
  138. package/dist/api/protocol-v2/GetProtoVersion.d.ts +6 -0
  139. package/dist/api/protocol-v2/GetProtoVersion.d.ts.map +1 -0
  140. package/dist/api/protocol-v2/Ping.d.ts +8 -0
  141. package/dist/api/protocol-v2/Ping.d.ts.map +1 -0
  142. package/dist/api/protocol-v2/helpers.d.ts +34 -0
  143. package/dist/api/protocol-v2/helpers.d.ts.map +1 -0
  144. package/dist/api/scdo/ScdoGetAddress.d.ts +2 -6
  145. package/dist/api/scdo/ScdoGetAddress.d.ts.map +1 -1
  146. package/dist/api/scdo/ScdoSignMessage.d.ts +2 -5
  147. package/dist/api/scdo/ScdoSignMessage.d.ts.map +1 -1
  148. package/dist/api/scdo/ScdoSignTransaction.d.ts +2 -5
  149. package/dist/api/scdo/ScdoSignTransaction.d.ts.map +1 -1
  150. package/dist/api/solana/SolGetAddress.d.ts +1 -0
  151. package/dist/api/solana/SolGetAddress.d.ts.map +1 -1
  152. package/dist/api/solana/SolSignMessage.d.ts +3 -0
  153. package/dist/api/solana/SolSignMessage.d.ts.map +1 -1
  154. package/dist/api/solana/SolSignOffchainMessage.d.ts +3 -0
  155. package/dist/api/solana/SolSignOffchainMessage.d.ts.map +1 -1
  156. package/dist/api/solana/SolSignTransaction.d.ts +6 -0
  157. package/dist/api/solana/SolSignTransaction.d.ts.map +1 -1
  158. package/dist/api/stellar/StellarGetAddress.d.ts +2 -1
  159. package/dist/api/stellar/StellarGetAddress.d.ts.map +1 -1
  160. package/dist/api/stellar/StellarSignTransaction.d.ts +3 -2
  161. package/dist/api/stellar/StellarSignTransaction.d.ts.map +1 -1
  162. package/dist/api/sui/SuiGetAddress.d.ts +3 -0
  163. package/dist/api/sui/SuiGetAddress.d.ts.map +1 -1
  164. package/dist/api/sui/SuiGetPublicKey.d.ts +3 -0
  165. package/dist/api/sui/SuiGetPublicKey.d.ts.map +1 -1
  166. package/dist/api/sui/SuiSignMessage.d.ts +3 -0
  167. package/dist/api/sui/SuiSignMessage.d.ts.map +1 -1
  168. package/dist/api/sui/SuiSignTransaction.d.ts +5 -2
  169. package/dist/api/sui/SuiSignTransaction.d.ts.map +1 -1
  170. package/dist/api/ton/TonGetAddress.d.ts +3 -0
  171. package/dist/api/ton/TonGetAddress.d.ts.map +1 -1
  172. package/dist/api/ton/TonSignData.d.ts +5 -0
  173. package/dist/api/ton/TonSignData.d.ts.map +1 -1
  174. package/dist/api/ton/TonSignMessage.d.ts +3 -0
  175. package/dist/api/ton/TonSignMessage.d.ts.map +1 -1
  176. package/dist/api/ton/TonSignProof.d.ts +3 -0
  177. package/dist/api/ton/TonSignProof.d.ts.map +1 -1
  178. package/dist/api/tron/TronSignMessage.d.ts +4 -0
  179. package/dist/api/tron/TronSignMessage.d.ts.map +1 -1
  180. package/dist/api/tron/TronSignTransaction.d.ts +4 -0
  181. package/dist/api/tron/TronSignTransaction.d.ts.map +1 -1
  182. package/dist/core/index.d.ts.map +1 -1
  183. package/dist/data-manager/DataManager.d.ts +7 -4
  184. package/dist/data-manager/DataManager.d.ts.map +1 -1
  185. package/dist/data-manager/MessagesConfig.d.ts +2 -2
  186. package/dist/data-manager/MessagesConfig.d.ts.map +1 -1
  187. package/dist/data-manager/TransportManager.d.ts +5 -4
  188. package/dist/data-manager/TransportManager.d.ts.map +1 -1
  189. package/dist/device/Device.d.ts +36 -10
  190. package/dist/device/Device.d.ts.map +1 -1
  191. package/dist/device/DeviceCommands.d.ts +9 -9
  192. package/dist/device/DeviceCommands.d.ts.map +1 -1
  193. package/dist/device/DeviceConnector.d.ts +2 -1
  194. package/dist/device/DeviceConnector.d.ts.map +1 -1
  195. package/dist/deviceProfile/buildDeviceProfile.d.ts +22 -0
  196. package/dist/deviceProfile/buildDeviceProfile.d.ts.map +1 -0
  197. package/dist/deviceProfile/index.d.ts +3 -0
  198. package/dist/deviceProfile/index.d.ts.map +1 -0
  199. package/dist/deviceProfile/legacyFeaturesView.d.ts +5 -0
  200. package/dist/deviceProfile/legacyFeaturesView.d.ts.map +1 -0
  201. package/dist/events/logBlockEvent.d.ts +1 -0
  202. package/dist/events/logBlockEvent.d.ts.map +1 -1
  203. package/dist/events/ui-request.d.ts +8 -0
  204. package/dist/events/ui-request.d.ts.map +1 -1
  205. package/dist/index.d.ts +720 -382
  206. package/dist/index.js +17634 -1201
  207. package/dist/inject.d.ts.map +1 -1
  208. package/dist/protocols/protocol-v2/features.d.ts +93 -0
  209. package/dist/protocols/protocol-v2/features.d.ts.map +1 -0
  210. package/dist/protocols/protocol-v2/firmware.d.ts +13 -0
  211. package/dist/protocols/protocol-v2/firmware.d.ts.map +1 -0
  212. package/dist/protocols/protocol-v2/index.d.ts +4 -0
  213. package/dist/protocols/protocol-v2/index.d.ts.map +1 -0
  214. package/dist/types/api/export.d.ts +1 -1
  215. package/dist/types/api/export.d.ts.map +1 -1
  216. package/dist/types/api/firmwareUpdate.d.ts +27 -0
  217. package/dist/types/api/firmwareUpdate.d.ts.map +1 -1
  218. package/dist/types/api/getDeviceInfo.d.ts +85 -0
  219. package/dist/types/api/getDeviceInfo.d.ts.map +1 -0
  220. package/dist/types/api/getPassphraseState.d.ts +10 -1
  221. package/dist/types/api/getPassphraseState.d.ts.map +1 -1
  222. package/dist/types/api/index.d.ts +37 -1
  223. package/dist/types/api/index.d.ts.map +1 -1
  224. package/dist/types/api/protocolV2.d.ts +103 -0
  225. package/dist/types/api/protocolV2.d.ts.map +1 -0
  226. package/dist/types/api/searchDevices.d.ts +2 -2
  227. package/dist/types/api/searchDevices.d.ts.map +1 -1
  228. package/dist/types/device.d.ts +10 -3
  229. package/dist/types/device.d.ts.map +1 -1
  230. package/dist/types/params.d.ts +2 -0
  231. package/dist/types/params.d.ts.map +1 -1
  232. package/dist/types/settings.d.ts +1 -1
  233. package/dist/types/settings.d.ts.map +1 -1
  234. package/dist/utils/deviceFeaturesUtils.d.ts +6 -8
  235. package/dist/utils/deviceFeaturesUtils.d.ts.map +1 -1
  236. package/dist/utils/deviceInfoUtils.d.ts +1 -0
  237. package/dist/utils/deviceInfoUtils.d.ts.map +1 -1
  238. package/dist/utils/index.d.ts +1 -1
  239. package/dist/utils/index.d.ts.map +1 -1
  240. package/dist/utils/patch.d.ts +1 -1
  241. package/dist/utils/patch.d.ts.map +1 -1
  242. package/package.json +4 -4
  243. package/src/api/BaseMethod.ts +26 -22
  244. package/src/api/DirList.ts +31 -0
  245. package/src/api/DirMake.ts +23 -0
  246. package/src/api/DirRemove.ts +23 -0
  247. package/src/api/FileDelete.ts +23 -0
  248. package/src/api/FileRead.ts +167 -0
  249. package/src/api/FileWrite.ts +216 -0
  250. package/src/api/FirmwareUpdate.ts +13 -5
  251. package/src/api/FirmwareUpdateV2.ts +21 -25
  252. package/src/api/FirmwareUpdateV3.ts +17 -4
  253. package/src/api/FirmwareUpdateV4.ts +827 -0
  254. package/src/api/GetDeviceInfo.ts +152 -0
  255. package/src/api/GetFeatures.ts +5 -2
  256. package/src/api/GetOnekeyFeatures.ts +95 -3
  257. package/src/api/GetPassphraseState.ts +16 -10
  258. package/src/api/PathInfo.ts +39 -0
  259. package/src/api/PromptWebDeviceAccess.ts +11 -1
  260. package/src/api/SearchDevices.ts +7 -2
  261. package/src/api/alephium/AlephiumGetAddress.ts +6 -2
  262. package/src/api/alephium/AlephiumSignMessage.ts +6 -1
  263. package/src/api/alephium/AlephiumSignTransaction.ts +15 -4
  264. package/src/api/allnetwork/AllNetworkGetAddressBase.ts +21 -13
  265. package/src/api/aptos/AptosGetAddress.ts +2 -3
  266. package/src/api/benfen/BenfenGetAddress.ts +11 -7
  267. package/src/api/benfen/BenfenGetPublicKey.ts +6 -2
  268. package/src/api/benfen/BenfenSignMessage.ts +6 -1
  269. package/src/api/benfen/BenfenSignTransaction.ts +6 -1
  270. package/src/api/btc/BTCGetPublicKey.ts +3 -2
  271. package/src/api/btc/BTCSignPsbt.ts +1 -2
  272. package/src/api/btc/helpers/versionLimit.ts +7 -1
  273. package/src/api/cardano/CardanoSignTransaction.ts +2 -4
  274. package/src/api/conflux/ConfluxSignTransaction.ts +5 -2
  275. package/src/api/device/DeviceFullyUploadResource.ts +3 -3
  276. package/src/api/device/DeviceLock.ts +1 -3
  277. package/src/api/device/DeviceRebootToBoardloader.ts +10 -1
  278. package/src/api/device/DeviceRebootToBootloader.ts +10 -1
  279. package/src/api/device/DeviceSupportFeatures.ts +2 -13
  280. package/src/api/device/DeviceUpdateBootloader.ts +4 -4
  281. package/src/api/device/DeviceUploadResource.ts +4 -5
  282. package/src/api/device/DeviceVerify.ts +1 -2
  283. package/src/api/dynex/DnxGetAddress.ts +6 -0
  284. package/src/api/dynex/DnxSignTransaction.ts +6 -0
  285. package/src/api/evm/EVMGetAddress.ts +1 -1
  286. package/src/api/evm/EVMGetPublicKey.ts +3 -4
  287. package/src/api/evm/EVMSignMessage.ts +1 -1
  288. package/src/api/evm/EVMSignMessageEIP712.ts +14 -1
  289. package/src/api/evm/EVMSignTransaction.ts +1 -1
  290. package/src/api/evm/EVMSignTypedData.ts +32 -18
  291. package/src/api/evm/EVMVerifyMessage.ts +1 -1
  292. package/src/api/evm/latest/signTypedHash.ts +2 -4
  293. package/src/api/evm/legacyV1/getAddress.ts +5 -3
  294. package/src/api/evm/legacyV1/getPublicKey.ts +5 -3
  295. package/src/api/evm/legacyV1/signMessage.ts +5 -3
  296. package/src/api/evm/legacyV1/signTypedData.ts +9 -8
  297. package/src/api/evm/legacyV1/signTypedHash.ts +7 -7
  298. package/src/api/evm/legacyV1/verifyMessage.ts +5 -3
  299. package/src/api/firmware/FirmwareUpdateBaseMethod.ts +8 -8
  300. package/src/api/firmware/uploadFirmware.ts +3 -10
  301. package/src/api/helpers/batchGetPublickeys.ts +51 -6
  302. package/src/api/helpers/filesystemValidation.ts +51 -0
  303. package/src/api/index.ts +34 -0
  304. package/src/api/kaspa/KaspaSignTransaction.ts +4 -5
  305. package/src/api/lightning/LnurlAuth.ts +4 -0
  306. package/src/api/neo/NeoGetAddress.ts +6 -1
  307. package/src/api/neo/NeoSignTransaction.ts +6 -1
  308. package/src/api/nervos/NervosGetAddress.ts +6 -2
  309. package/src/api/nervos/NervosSignTransaction.ts +14 -4
  310. package/src/api/nexa/NexaGetAddress.ts +6 -2
  311. package/src/api/nexa/NexaSignTransaction.ts +11 -12
  312. package/src/api/polkadot/networks.ts +9 -0
  313. package/src/api/protocol-v2/DevReboot.ts +24 -0
  314. package/src/api/protocol-v2/DeviceFirmwareUpdate.ts +63 -0
  315. package/src/api/protocol-v2/DeviceGetDeviceInfo.ts +118 -0
  316. package/src/api/protocol-v2/DeviceGetFirmwareUpdateStatus.ts +20 -0
  317. package/src/api/protocol-v2/DeviceGetOnboardingStatus.ts +16 -0
  318. package/src/api/protocol-v2/DeviceReboot.ts +24 -0
  319. package/src/api/protocol-v2/FactoryDeviceInfoSettings.ts +29 -0
  320. package/src/api/protocol-v2/FactoryGetDeviceInfo.ts +20 -0
  321. package/src/api/protocol-v2/FilesystemDiskControl.ts +50 -0
  322. package/src/api/protocol-v2/FilesystemFixPermission.ts +16 -0
  323. package/src/api/protocol-v2/FilesystemFormat.ts +16 -0
  324. package/src/api/protocol-v2/GetProtoVersion.ts +16 -0
  325. package/src/api/protocol-v2/Ping.ts +18 -0
  326. package/src/api/protocol-v2/helpers.ts +207 -0
  327. package/src/api/scdo/ScdoGetAddress.ts +6 -2
  328. package/src/api/scdo/ScdoSignMessage.ts +6 -1
  329. package/src/api/scdo/ScdoSignTransaction.ts +6 -2
  330. package/src/api/solana/SolGetAddress.ts +4 -0
  331. package/src/api/solana/SolSignMessage.ts +3 -0
  332. package/src/api/solana/SolSignOffchainMessage.ts +3 -0
  333. package/src/api/solana/SolSignTransaction.ts +6 -0
  334. package/src/api/stellar/StellarGetAddress.ts +10 -1
  335. package/src/api/stellar/StellarSignTransaction.ts +14 -1
  336. package/src/api/sui/SuiGetAddress.ts +5 -3
  337. package/src/api/sui/SuiGetPublicKey.ts +3 -0
  338. package/src/api/sui/SuiSignMessage.ts +3 -0
  339. package/src/api/sui/SuiSignTransaction.ts +14 -12
  340. package/src/api/ton/TonGetAddress.ts +3 -0
  341. package/src/api/ton/TonSignData.ts +10 -3
  342. package/src/api/ton/TonSignMessage.ts +6 -5
  343. package/src/api/ton/TonSignProof.ts +3 -0
  344. package/src/api/tron/TronSignMessage.ts +5 -1
  345. package/src/api/tron/TronSignTransaction.ts +4 -0
  346. package/src/api/xrp/XrpSignTransaction.ts +1 -1
  347. package/src/core/index.ts +87 -55
  348. package/src/data/messages/messages-protocol-v2.json +13369 -0
  349. package/src/data-manager/DataManager.ts +12 -7
  350. package/src/data-manager/MessagesConfig.ts +14 -14
  351. package/src/data-manager/TransportManager.ts +38 -12
  352. package/src/device/Device.ts +538 -61
  353. package/src/device/DeviceCommands.ts +195 -29
  354. package/src/device/DeviceConnector.ts +29 -4
  355. package/src/device/DevicePool.ts +7 -7
  356. package/src/deviceProfile/buildDeviceProfile.ts +387 -0
  357. package/src/deviceProfile/index.ts +2 -0
  358. package/src/deviceProfile/legacyFeaturesView.ts +123 -0
  359. package/src/events/logBlockEvent.ts +23 -0
  360. package/src/events/ui-request.ts +8 -0
  361. package/src/inject.ts +52 -1
  362. package/src/protocols/protocol-v2/features.ts +180 -0
  363. package/src/protocols/protocol-v2/firmware.ts +43 -0
  364. package/src/protocols/protocol-v2/index.ts +16 -0
  365. package/src/types/api/export.ts +1 -0
  366. package/src/types/api/firmwareUpdate.ts +49 -0
  367. package/src/types/api/getDeviceInfo.ts +99 -0
  368. package/src/types/api/getPassphraseState.ts +13 -2
  369. package/src/types/api/index.ts +88 -1
  370. package/src/types/api/protocolV2.ts +201 -0
  371. package/src/types/api/searchDevices.ts +2 -2
  372. package/src/types/device.ts +37 -3
  373. package/src/types/params.ts +7 -0
  374. package/src/types/settings.ts +1 -1
  375. package/src/utils/deviceFeaturesUtils.ts +70 -70
  376. package/src/utils/deviceInfoUtils.ts +15 -8
  377. package/src/utils/index.ts +1 -0
@@ -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
  },
@@ -5,8 +5,12 @@ import { BaseMethod } from '../BaseMethod';
5
5
  import { validateParams } from '../helpers/paramsValidator';
6
6
  import { formatAnyHex } from '../helpers/hexUtils';
7
7
 
8
- import type { NervosSignTransactionParams, NervosSignedTx } from '../../types';
9
- import type { NervosSignTx as HardwareNervosSignTx, TypedCall } from '@onekeyfe/hd-transport';
8
+ import type { DeviceFirmwareRange, NervosSignTransactionParams, NervosSignedTx } from '../../types';
9
+ import type {
10
+ NervosSignTx as HardwareNervosSignTx,
11
+ NervosTxRequest,
12
+ TypedCall,
13
+ } from '@onekeyfe/hd-transport';
10
14
  import type { TypedResponseMessage } from '../../device/DeviceCommands';
11
15
 
12
16
  type NervosSignTx = Omit<HardwareNervosSignTx, 'data_initial_chunk' | 'data_length'> & {
@@ -41,8 +45,12 @@ export default class NervosSignTransaction extends BaseMethod<NervosSignTx> {
41
45
  };
42
46
  }
43
47
 
44
- getVersionRange() {
48
+ getVersionRange(): DeviceFirmwareRange {
45
49
  return {
50
+ pro2: {
51
+ min: '0.0.0',
52
+ unsupported: true,
53
+ },
46
54
  model_mini: {
47
55
  min: '3.7.0',
48
56
  },
@@ -59,7 +67,9 @@ export default class NervosSignTransaction extends BaseMethod<NervosSignTx> {
59
67
  res: TypedResponseMessage<'NervosSignedTx'> | TypedResponseMessage<'NervosTxRequest'>,
60
68
  data: Buffer,
61
69
  offset = 0
62
- ): Promise<NervosSignedTx> => {
70
+ // 设备可能在最后一个 NervosTxRequest(无 data_length)里返回签名,
71
+ // 该消息没有 address 字段,返回类型如实声明为联合类型
72
+ ): Promise<NervosSignedTx | (NervosTxRequest & { path: string })> => {
63
73
  if (res.type === 'NervosSignedTx') {
64
74
  if (!res?.message?.signature) {
65
75
  throw new Error('No signature returned');
@@ -4,7 +4,7 @@ import { BaseMethod } from '../BaseMethod';
4
4
  import { validateParams, validateResult } from '../helpers/paramsValidator';
5
5
 
6
6
  import type { NexaGetAddress as HardwareNexaGetAddress } from '@onekeyfe/hd-transport';
7
- import type { NexaGetAddressParams } from '../../types';
7
+ import type { DeviceFirmwareRange, NexaGetAddressParams } from '../../types';
8
8
 
9
9
  export default class NexaGetAddress extends BaseMethod<HardwareNexaGetAddress[]> {
10
10
  hasBundle = false;
@@ -43,8 +43,12 @@ export default class NexaGetAddress extends BaseMethod<HardwareNexaGetAddress[]>
43
43
  });
44
44
  }
45
45
 
46
- getVersionRange() {
46
+ getVersionRange(): DeviceFirmwareRange {
47
47
  return {
48
+ pro2: {
49
+ min: '0.0.0',
50
+ unsupported: true,
51
+ },
48
52
  model_mini: {
49
53
  min: '3.2.0',
50
54
  },
@@ -6,7 +6,7 @@ import { validateParams } from '../helpers/paramsValidator';
6
6
 
7
7
  import type { TypedResponseMessage } from '../../device/DeviceCommands';
8
8
  import type { TypedCall } from '@onekeyfe/hd-transport';
9
- import type { NexaSignTransactionParams, NexaSignature } from '../../types';
9
+ import type { DeviceFirmwareRange, NexaSignTransactionParams, NexaSignature } from '../../types';
10
10
 
11
11
  export default class NexaSignTransaction extends BaseMethod<NexaSignTransactionParams> {
12
12
  hasBundle = false;
@@ -27,8 +27,12 @@ export default class NexaSignTransaction extends BaseMethod<NexaSignTransactionP
27
27
  this.params = payload;
28
28
  }
29
29
 
30
- getVersionRange() {
30
+ getVersionRange(): DeviceFirmwareRange {
31
31
  return {
32
+ pro2: {
33
+ min: '0.0.0',
34
+ unsupported: true,
35
+ },
32
36
  model_mini: {
33
37
  min: '3.2.0',
34
38
  },
@@ -68,17 +72,12 @@ export default class NexaSignTransaction extends BaseMethod<NexaSignTransactionP
68
72
 
69
73
  const nextIndex = res.message.request_index;
70
74
  const input = this.params.inputs[nextIndex];
71
- const response = await typedCall(
72
- 'NexaTxInputAck',
73
- // @ts-expect-error
74
- ['NexaTxInputRequest', 'NexaSignedTx'],
75
- {
76
- address_n: input.path,
77
- raw_message: input.message,
78
- }
79
- );
75
+ const response = await typedCall('NexaTxInputAck', ['NexaTxInputRequest', 'NexaSignedTx'], {
76
+ // path 为字符串形式,归一为 address_n 数组(与 run() 中首个 input 的处理一致)
77
+ address_n: validatePath(input.path, 3),
78
+ raw_message: input.message,
79
+ });
80
80
 
81
- // @ts-expect-error
82
81
  return this.processTxRequest(typedCall, response, nextIndex, signatures);
83
82
  }
84
83
 
@@ -23,6 +23,9 @@ const baseVersionRange = {
23
23
  model_touch: {
24
24
  min: '4.3.0',
25
25
  },
26
+ pro2: {
27
+ min: '0.0.0',
28
+ },
26
29
  };
27
30
 
28
31
  const specialVersionRange: Record<string, DeviceFirmwareRange> = {
@@ -33,6 +36,9 @@ const specialVersionRange: Record<string, DeviceFirmwareRange> = {
33
36
  model_touch: {
34
37
  min: '4.7.0',
35
38
  },
39
+ pro2: {
40
+ min: '0.0.0',
41
+ },
36
42
  },
37
43
  [Networks.Manta]: {
38
44
  model_mini: {
@@ -41,6 +47,9 @@ const specialVersionRange: Record<string, DeviceFirmwareRange> = {
41
47
  model_touch: {
42
48
  min: '4.9.0',
43
49
  },
50
+ pro2: {
51
+ min: '0.0.0',
52
+ },
44
53
  },
45
54
  };
46
55
 
@@ -0,0 +1,24 @@
1
+ import { BaseMethod } from '../BaseMethod';
2
+ import { normalizeRebootType } from './helpers';
3
+
4
+ import type { DeviceRebootParams } from './helpers';
5
+
6
+ export default class DevReboot extends BaseMethod<DeviceRebootParams> {
7
+ init() {
8
+ // Protocol V2 (Pro2) 专属方法,core 调度层统一做非 V2 设备守卫
9
+ this.requireProtocolV2 = true;
10
+ this.skipForceUpdateCheck = true;
11
+ this.useDevicePassphraseState = false;
12
+ this.params = {
13
+ rebootType: this.payload.rebootType,
14
+ reboot_type: this.payload.reboot_type,
15
+ };
16
+ }
17
+
18
+ async run() {
19
+ const res = await this.device.commands.typedCall('DevReboot', 'Success', {
20
+ reboot_type: normalizeRebootType(this.params.reboot_type ?? this.params.rebootType),
21
+ });
22
+ return Promise.resolve(res.message);
23
+ }
24
+ }
@@ -0,0 +1,63 @@
1
+ import { BaseMethod } from '../BaseMethod';
2
+ import {
3
+ PROTOCOL_V2_FIRMWARE_UPDATE_OPTIONS,
4
+ PROTOCOL_V2_FIRMWARE_UPDATE_RESPONSE_TYPES,
5
+ isProtocolV2DeviceDisconnectedError,
6
+ normalizeFirmwareTargets,
7
+ } from './helpers';
8
+ import { UI_REQUEST, createUiMessage } from '../../events/ui-request';
9
+
10
+ import type { KnownDevice } from '../../types';
11
+ import type { MessageFromOneKey } from '@onekeyfe/hd-transport';
12
+ import type { DeviceFirmwareUpdateParams } from './helpers';
13
+
14
+ export default class DeviceFirmwareUpdate extends BaseMethod<DeviceFirmwareUpdateParams> {
15
+ init() {
16
+ // Protocol V2 (Pro2) 专属方法,core 调度层统一做非 V2 设备守卫
17
+ this.requireProtocolV2 = true;
18
+ this.skipForceUpdateCheck = true;
19
+ this.useDevicePassphraseState = false;
20
+ this.params = {
21
+ targets: this.payload.targets,
22
+ targetId: this.payload.targetId,
23
+ target_id: this.payload.target_id,
24
+ path: this.payload.path,
25
+ };
26
+ }
27
+
28
+ async run() {
29
+ const targets = normalizeFirmwareTargets(this.params);
30
+ try {
31
+ const res = await this.device.commands.typedCall(
32
+ 'DevFirmwareUpdate',
33
+ PROTOCOL_V2_FIRMWARE_UPDATE_RESPONSE_TYPES,
34
+ {
35
+ targets,
36
+ },
37
+ {
38
+ ...PROTOCOL_V2_FIRMWARE_UPDATE_OPTIONS,
39
+ onIntermediateResponse: (response: MessageFromOneKey) => {
40
+ if (response.type !== 'DevFirmwareInstallProgress') return;
41
+ const progress = Number(response.message?.progress);
42
+ if (!Number.isFinite(progress)) return;
43
+ this.postMessage(
44
+ createUiMessage(UI_REQUEST.FIRMWARE_PROGRESS, {
45
+ device: this.device.toMessageObject() as KnownDevice,
46
+ progress: Math.min(Math.max(progress, 0), 100),
47
+ progressType: 'installingFirmware',
48
+ })
49
+ );
50
+ },
51
+ }
52
+ );
53
+ return Promise.resolve(res.message);
54
+ } catch (error) {
55
+ if (isProtocolV2DeviceDisconnectedError(error)) {
56
+ return Promise.resolve({
57
+ message: 'Device firmware update started',
58
+ });
59
+ }
60
+ throw error;
61
+ }
62
+ }
63
+ }
@@ -0,0 +1,118 @@
1
+ import { createDeviceNotSupportMethodError } from '@onekeyfe/hd-shared';
2
+
3
+ import { UI_REQUEST } from '../../constants/ui-request';
4
+ import { PROTOCOL_V2_DEVICE_INFO_TIMEOUT_MS } from '../../protocols/protocol-v2';
5
+ import { BaseMethod } from '../BaseMethod';
6
+
7
+ export type DeviceGetDeviceInfoTargets = {
8
+ hw?: boolean;
9
+ fw?: boolean;
10
+ bt?: boolean;
11
+ se1?: boolean;
12
+ se2?: boolean;
13
+ se3?: boolean;
14
+ se4?: boolean;
15
+ status?: boolean;
16
+ };
17
+
18
+ export type DeviceGetDeviceInfoTypes = {
19
+ version?: boolean;
20
+ build_id?: boolean;
21
+ hash?: boolean;
22
+ specific?: boolean;
23
+ };
24
+
25
+ export type DeviceGetDeviceInfoParams = {
26
+ targets?: DeviceGetDeviceInfoTargets;
27
+ types?: DeviceGetDeviceInfoTypes;
28
+ };
29
+
30
+ const TARGET_KEYS: (keyof DeviceGetDeviceInfoTargets)[] = [
31
+ 'hw',
32
+ 'fw',
33
+ 'bt',
34
+ 'se1',
35
+ 'se2',
36
+ 'se3',
37
+ 'se4',
38
+ 'status',
39
+ ];
40
+
41
+ const TYPE_KEYS: (keyof DeviceGetDeviceInfoTypes)[] = ['version', 'build_id', 'hash', 'specific'];
42
+
43
+ const DEFAULT_TARGETS: DeviceGetDeviceInfoTargets = {
44
+ hw: true,
45
+ fw: true,
46
+ bt: true,
47
+ status: true,
48
+ };
49
+
50
+ const DEFAULT_TYPES: DeviceGetDeviceInfoTypes = {
51
+ version: true,
52
+ specific: true,
53
+ };
54
+
55
+ function pickBooleanKeys<T extends Record<string, boolean | undefined>>(
56
+ value: unknown,
57
+ keys: (keyof T)[]
58
+ ): T | undefined {
59
+ if (!value || typeof value !== 'object' || Array.isArray(value)) return undefined;
60
+ const source = value as Record<string, unknown>;
61
+ const result = {} as T;
62
+ let hasKey = false;
63
+ for (const key of keys) {
64
+ if (source[key as string]) {
65
+ result[key] = true as T[keyof T];
66
+ hasKey = true;
67
+ }
68
+ }
69
+ return hasKey ? result : undefined;
70
+ }
71
+
72
+ /**
73
+ * 原生 DevGetDeviceInfo(Protocol V2 only)。
74
+ *
75
+ * 与 getDeviceInfo 不同:不构建 DeviceProfile、不更新设备缓存,
76
+ * 按调用方给定的 targets/types 原样请求并返回未加工的 DeviceInfo 消息,
77
+ * 用于调试固件字段上报。
78
+ */
79
+ export default class DeviceGetDeviceInfo extends BaseMethod<{
80
+ targets: DeviceGetDeviceInfoTargets;
81
+ types: DeviceGetDeviceInfoTypes;
82
+ }> {
83
+ init() {
84
+ // Protocol V2 (Pro2) 专属方法,core 调度层统一做非 V2 设备守卫
85
+ this.requireProtocolV2 = true;
86
+ this.allowDeviceMode = [
87
+ ...this.allowDeviceMode,
88
+ UI_REQUEST.NOT_INITIALIZE,
89
+ UI_REQUEST.BOOTLOADER,
90
+ ];
91
+ this.useDevicePassphraseState = false;
92
+ this.skipForceUpdateCheck = true;
93
+ this.params = {
94
+ targets:
95
+ pickBooleanKeys<DeviceGetDeviceInfoTargets>(this.payload.targets, TARGET_KEYS) ??
96
+ DEFAULT_TARGETS,
97
+ types:
98
+ pickBooleanKeys<DeviceGetDeviceInfoTypes>(this.payload.types, TYPE_KEYS) ?? DEFAULT_TYPES,
99
+ };
100
+ }
101
+
102
+ async run() {
103
+ if (!this.device.isProtocolV2()) {
104
+ throw createDeviceNotSupportMethodError(this.name, this.device.getCurrentFirmwareType());
105
+ }
106
+
107
+ const res = await this.device.commands.typedCall(
108
+ 'DevGetDeviceInfo',
109
+ 'DeviceInfo',
110
+ {
111
+ targets: this.params.targets,
112
+ types: this.params.types,
113
+ },
114
+ { timeoutMs: PROTOCOL_V2_DEVICE_INFO_TIMEOUT_MS }
115
+ );
116
+ return Promise.resolve(res.message);
117
+ }
118
+ }
@@ -0,0 +1,20 @@
1
+ import { BaseMethod } from '../BaseMethod';
2
+
3
+ export default class DeviceGetFirmwareUpdateStatus extends BaseMethod {
4
+ init() {
5
+ // Protocol V2 (Pro2) 专属方法,core 调度层统一做非 V2 设备守卫
6
+ this.requireProtocolV2 = true;
7
+ this.skipForceUpdateCheck = true;
8
+ this.useDevicePassphraseState = false;
9
+ this.params = undefined;
10
+ }
11
+
12
+ async run() {
13
+ const res = await this.device.commands.typedCall(
14
+ 'DevGetFirmwareUpdateStatus',
15
+ 'DevFirmwareUpdateStatus',
16
+ {}
17
+ );
18
+ return Promise.resolve(res.message);
19
+ }
20
+ }
@@ -0,0 +1,16 @@
1
+ import { BaseMethod } from '../BaseMethod';
2
+
3
+ export default class DeviceGetOnboardingStatus extends BaseMethod {
4
+ init() {
5
+ // Protocol V2 (Pro2) 专属方法,core 调度层统一做非 V2 设备守卫
6
+ this.requireProtocolV2 = true;
7
+ this.skipForceUpdateCheck = true;
8
+ this.useDevicePassphraseState = false;
9
+ this.params = undefined;
10
+ }
11
+
12
+ async run() {
13
+ const res = await this.device.commands.typedCall('GetOnboardingStatus', 'OnboardingStatus', {});
14
+ return Promise.resolve(res.message);
15
+ }
16
+ }
@@ -0,0 +1,24 @@
1
+ import { BaseMethod } from '../BaseMethod';
2
+ import { normalizeDeviceRebootType } from './helpers';
3
+
4
+ import type { DeviceRebootParams } from './helpers';
5
+
6
+ export default class DeviceReboot extends BaseMethod<DeviceRebootParams> {
7
+ init() {
8
+ // Protocol V2 (Pro2) 专属方法,core 调度层统一做非 V2 设备守卫
9
+ this.requireProtocolV2 = true;
10
+ this.skipForceUpdateCheck = true;
11
+ this.useDevicePassphraseState = false;
12
+ this.params = {
13
+ rebootType: this.payload.rebootType,
14
+ reboot_type: this.payload.reboot_type,
15
+ };
16
+ }
17
+
18
+ async run() {
19
+ const res = await this.device.commands.typedCall('DeviceReboot', 'Success', {
20
+ reboot_type: normalizeDeviceRebootType(this.params.reboot_type ?? this.params.rebootType),
21
+ });
22
+ return Promise.resolve(res.message);
23
+ }
24
+ }
@@ -0,0 +1,29 @@
1
+ import { BaseMethod } from '../BaseMethod';
2
+
3
+ import type { FactoryDeviceInfoSettingsParams } from './helpers';
4
+
5
+ export default class FactoryDeviceInfoSettings extends BaseMethod<FactoryDeviceInfoSettingsParams> {
6
+ init() {
7
+ // Protocol V2 (Pro2) 专属方法,core 调度层统一做非 V2 设备守卫
8
+ this.requireProtocolV2 = true;
9
+ this.skipForceUpdateCheck = true;
10
+ this.useDevicePassphraseState = false;
11
+ this.params = {
12
+ serial_no: this.payload.serial_no,
13
+ serialNo: this.payload.serialNo,
14
+ cpu_info: this.payload.cpu_info,
15
+ cpuInfo: this.payload.cpuInfo,
16
+ pre_firmware: this.payload.pre_firmware,
17
+ preFirmware: this.payload.preFirmware,
18
+ };
19
+ }
20
+
21
+ async run() {
22
+ const res = await this.device.commands.typedCall('FactoryDeviceInfoSettings', 'Success', {
23
+ serial_no: this.params.serial_no ?? this.params.serialNo,
24
+ cpu_info: this.params.cpu_info ?? this.params.cpuInfo,
25
+ pre_firmware: this.params.pre_firmware ?? this.params.preFirmware,
26
+ });
27
+ return Promise.resolve(res.message);
28
+ }
29
+ }
@@ -0,0 +1,20 @@
1
+ import { BaseMethod } from '../BaseMethod';
2
+
3
+ export default class FactoryGetDeviceInfo extends BaseMethod {
4
+ init() {
5
+ // Protocol V2 (Pro2) 专属方法,core 调度层统一做非 V2 设备守卫
6
+ this.requireProtocolV2 = true;
7
+ this.skipForceUpdateCheck = true;
8
+ this.useDevicePassphraseState = false;
9
+ this.params = undefined;
10
+ }
11
+
12
+ async run() {
13
+ const res = await this.device.commands.typedCall(
14
+ 'FactoryGetDeviceInfo',
15
+ 'FactoryDeviceInfo',
16
+ {}
17
+ );
18
+ return Promise.resolve(res.message);
19
+ }
20
+ }
@@ -0,0 +1,50 @@
1
+ import { BaseMethod } from '../BaseMethod';
2
+ import {
3
+ invalidParameter,
4
+ validateOptionalNonNegativeInteger,
5
+ } from '../helpers/filesystemValidation';
6
+
7
+ export type FilesystemDiskControlParams = {
8
+ // 收紧为 boolean | 0 | 1;'0' / '1' 字符串仅作为历史输入向后兼容,内部归一化为 0/1
9
+ enable?: boolean | 0 | 1;
10
+ timeoutMs?: number | string;
11
+ };
12
+
13
+ function normalizeDiskControlEnable(value: unknown): 0 | 1 {
14
+ if (value === undefined || value === null) return 0;
15
+ if (typeof value === 'boolean') return value ? 1 : 0;
16
+ if (value === 0 || value === '0') return 0;
17
+ if (value === 1 || value === '1') return 1;
18
+ throw invalidParameter('Parameter [enable] must be a boolean or 0 | 1.');
19
+ }
20
+
21
+ export default class FilesystemDiskControl extends BaseMethod<{
22
+ enable: 0 | 1;
23
+ timeoutMs?: number;
24
+ }> {
25
+ init() {
26
+ // Protocol V2 (Pro2) 专属方法,core 调度层统一做非 V2 设备守卫
27
+ this.requireProtocolV2 = true;
28
+ this.skipForceUpdateCheck = true;
29
+ this.useDevicePassphraseState = false;
30
+ this.params = {
31
+ enable: normalizeDiskControlEnable(this.payload.enable),
32
+ timeoutMs: validateOptionalNonNegativeInteger(this.payload.timeoutMs, 'timeoutMs'),
33
+ };
34
+ }
35
+
36
+ async run() {
37
+ const typedCall = this.device.commands.typedCall as any;
38
+ const res = await typedCall(
39
+ 'FilesystemDiskControl',
40
+ 'Success',
41
+ {
42
+ enable: this.params.enable,
43
+ },
44
+ {
45
+ timeoutMs: this.params.timeoutMs,
46
+ }
47
+ );
48
+ return Promise.resolve(res.message);
49
+ }
50
+ }
@@ -0,0 +1,16 @@
1
+ import { BaseMethod } from '../BaseMethod';
2
+
3
+ export default class FilesystemFixPermission extends BaseMethod {
4
+ init() {
5
+ // Protocol V2 (Pro2) 专属方法,core 调度层统一做非 V2 设备守卫
6
+ this.requireProtocolV2 = true;
7
+ this.skipForceUpdateCheck = true;
8
+ this.useDevicePassphraseState = false;
9
+ this.params = undefined;
10
+ }
11
+
12
+ async run() {
13
+ const res = await this.device.commands.typedCall('FilesystemFixPermission', 'Success', {});
14
+ return Promise.resolve(res.message);
15
+ }
16
+ }
@@ -0,0 +1,16 @@
1
+ import { BaseMethod } from '../BaseMethod';
2
+
3
+ export default class FilesystemFormat extends BaseMethod {
4
+ init() {
5
+ // Protocol V2 (Pro2) 专属方法,core 调度层统一做非 V2 设备守卫
6
+ this.requireProtocolV2 = true;
7
+ this.skipForceUpdateCheck = true;
8
+ this.useDevicePassphraseState = false;
9
+ this.params = undefined;
10
+ }
11
+
12
+ async run() {
13
+ const res = await this.device.commands.typedCall('FilesystemFormat', 'Success', {});
14
+ return Promise.resolve(res.message);
15
+ }
16
+ }
@@ -0,0 +1,16 @@
1
+ import { BaseMethod } from '../BaseMethod';
2
+
3
+ export default class GetProtoVersion extends BaseMethod {
4
+ init() {
5
+ // Protocol V2 (Pro2) 专属方法,core 调度层统一做非 V2 设备守卫
6
+ this.requireProtocolV2 = true;
7
+ this.skipForceUpdateCheck = true;
8
+ this.useDevicePassphraseState = false;
9
+ this.params = undefined;
10
+ }
11
+
12
+ async run() {
13
+ const res = await this.device.commands.typedCall('GetProtoVersion', 'ProtoVersion', {});
14
+ return Promise.resolve(res.message);
15
+ }
16
+ }
@@ -0,0 +1,18 @@
1
+ import { BaseMethod } from '../BaseMethod';
2
+
3
+ export default class Ping extends BaseMethod<{ message?: string }> {
4
+ init() {
5
+ // Protocol V2 (Pro2) 专属方法,core 调度层统一做非 V2 设备守卫
6
+ this.requireProtocolV2 = true;
7
+ this.skipForceUpdateCheck = true;
8
+ this.useDevicePassphraseState = false;
9
+ this.params = { message: this.payload.message };
10
+ }
11
+
12
+ async run() {
13
+ const res = await this.device.commands.typedCall('Ping', 'Success', {
14
+ message: this.params.message ?? '',
15
+ });
16
+ return Promise.resolve(res.message);
17
+ }
18
+ }