@onekeyfe/hd-core 1.2.0-alpha.24 → 1.2.0-alpha.25

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 (490) hide show
  1. package/__tests__/AllNetworkGetAddressBase.tracing.test.ts +2 -0
  2. package/__tests__/chain-params-onekey-compatibility.test.ts +229 -0
  3. package/__tests__/connectSettings.test.ts +47 -5
  4. package/__tests__/device-state-events.test.ts +124 -0
  5. package/__tests__/evmLedgerLegacySafety.test.ts +3 -1
  6. package/__tests__/firmware-update/check-all-firmware-release.test.ts +127 -0
  7. package/__tests__/firmware-update/firmware-artifact-source.test.ts +119 -0
  8. package/__tests__/firmware-update/firmware-host-binding.test.ts +70 -0
  9. package/__tests__/firmware-update/firmware-update-capabilities.test.ts +13 -0
  10. package/__tests__/firmware-update/firmware-update-plan.test.ts +354 -0
  11. package/__tests__/firmware-update/firmware-update-prepared-plan.test.ts +213 -0
  12. package/__tests__/firmware-update/firmware-update-v2-download-before-boot.test.ts +39 -30
  13. package/__tests__/firmware-update/firmware-upload-source.test.ts +70 -0
  14. package/__tests__/kaspa-public-types.type-test.ts +16 -0
  15. package/__tests__/kaspaSignTransaction.test.ts +4 -3
  16. package/__tests__/method-protocol-support.test.ts +113 -0
  17. package/__tests__/protocol-v2.test.ts +271 -117
  18. package/__tests__/public-device-state-api.test.ts +10 -8
  19. package/__tests__/tron-sign-message-init.test.ts +46 -0
  20. package/dist/api/BaseMethod.d.ts +6 -2
  21. package/dist/api/BaseMethod.d.ts.map +1 -1
  22. package/dist/api/CheckAllFirmwareRelease.d.ts.map +1 -1
  23. package/dist/api/CipherKeyValue.d.ts +1 -0
  24. package/dist/api/CipherKeyValue.d.ts.map +1 -1
  25. package/dist/api/DirList.d.ts +1 -0
  26. package/dist/api/DirList.d.ts.map +1 -1
  27. package/dist/api/DirMake.d.ts +1 -0
  28. package/dist/api/DirMake.d.ts.map +1 -1
  29. package/dist/api/DirRemove.d.ts +1 -0
  30. package/dist/api/DirRemove.d.ts.map +1 -1
  31. package/dist/api/FileDelete.d.ts +1 -0
  32. package/dist/api/FileDelete.d.ts.map +1 -1
  33. package/dist/api/FileRead.d.ts +1 -0
  34. package/dist/api/FileRead.d.ts.map +1 -1
  35. package/dist/api/FileWrite.d.ts +1 -0
  36. package/dist/api/FileWrite.d.ts.map +1 -1
  37. package/dist/api/FirmwareUpdate.d.ts.map +1 -1
  38. package/dist/api/FirmwareUpdateV2.d.ts +11 -0
  39. package/dist/api/FirmwareUpdateV2.d.ts.map +1 -1
  40. package/dist/api/FirmwareUpdateV3.d.ts +7 -3
  41. package/dist/api/FirmwareUpdateV3.d.ts.map +1 -1
  42. package/dist/api/FirmwareUpdateV4.d.ts +23 -5
  43. package/dist/api/FirmwareUpdateV4.d.ts.map +1 -1
  44. package/dist/api/GetDeviceState.d.ts +1 -0
  45. package/dist/api/GetDeviceState.d.ts.map +1 -1
  46. package/dist/api/GetFeatures.d.ts.map +1 -1
  47. package/dist/api/GetOnekeyFeatures.d.ts.map +1 -1
  48. package/dist/api/GetPassphraseState.d.ts +1 -0
  49. package/dist/api/GetPassphraseState.d.ts.map +1 -1
  50. package/dist/api/OpenWalletSession.d.ts +1 -0
  51. package/dist/api/OpenWalletSession.d.ts.map +1 -1
  52. package/dist/api/PathInfo.d.ts +1 -0
  53. package/dist/api/PathInfo.d.ts.map +1 -1
  54. package/dist/api/alephium/AlephiumGetAddress.d.ts.map +1 -1
  55. package/dist/api/alephium/AlephiumSignMessage.d.ts.map +1 -1
  56. package/dist/api/alephium/AlephiumSignTransaction.d.ts.map +1 -1
  57. package/dist/api/algo/AlgoGetAddress.d.ts +1 -0
  58. package/dist/api/algo/AlgoGetAddress.d.ts.map +1 -1
  59. package/dist/api/algo/AlgoSignTransaction.d.ts +1 -0
  60. package/dist/api/algo/AlgoSignTransaction.d.ts.map +1 -1
  61. package/dist/api/allnetwork/AllNetworkGetAddressBase.d.ts +1 -0
  62. package/dist/api/allnetwork/AllNetworkGetAddressBase.d.ts.map +1 -1
  63. package/dist/api/aptos/AptosGetAddress.d.ts +1 -0
  64. package/dist/api/aptos/AptosGetAddress.d.ts.map +1 -1
  65. package/dist/api/aptos/AptosGetPublicKey.d.ts +1 -0
  66. package/dist/api/aptos/AptosGetPublicKey.d.ts.map +1 -1
  67. package/dist/api/aptos/AptosSignInMessage.d.ts +1 -0
  68. package/dist/api/aptos/AptosSignInMessage.d.ts.map +1 -1
  69. package/dist/api/aptos/AptosSignMessage.d.ts +1 -0
  70. package/dist/api/aptos/AptosSignMessage.d.ts.map +1 -1
  71. package/dist/api/aptos/AptosSignTransaction.d.ts +1 -0
  72. package/dist/api/aptos/AptosSignTransaction.d.ts.map +1 -1
  73. package/dist/api/benfen/BenfenGetAddress.d.ts.map +1 -1
  74. package/dist/api/benfen/BenfenGetPublicKey.d.ts.map +1 -1
  75. package/dist/api/benfen/BenfenSignMessage.d.ts.map +1 -1
  76. package/dist/api/benfen/BenfenSignTransaction.d.ts.map +1 -1
  77. package/dist/api/btc/BTCGetAddress.d.ts +1 -0
  78. package/dist/api/btc/BTCGetAddress.d.ts.map +1 -1
  79. package/dist/api/btc/BTCGetPublicKey.d.ts +1 -0
  80. package/dist/api/btc/BTCGetPublicKey.d.ts.map +1 -1
  81. package/dist/api/btc/BTCSignMessage.d.ts +1 -0
  82. package/dist/api/btc/BTCSignMessage.d.ts.map +1 -1
  83. package/dist/api/btc/BTCSignPsbt.d.ts +1 -0
  84. package/dist/api/btc/BTCSignPsbt.d.ts.map +1 -1
  85. package/dist/api/btc/BTCSignTransaction.d.ts +1 -0
  86. package/dist/api/btc/BTCSignTransaction.d.ts.map +1 -1
  87. package/dist/api/btc/BTCVerifyMessage.d.ts +1 -0
  88. package/dist/api/btc/BTCVerifyMessage.d.ts.map +1 -1
  89. package/dist/api/btc/helpers/versionLimit.d.ts +2 -0
  90. package/dist/api/btc/helpers/versionLimit.d.ts.map +1 -1
  91. package/dist/api/cardano/CardanoGetAddress.d.ts +1 -0
  92. package/dist/api/cardano/CardanoGetAddress.d.ts.map +1 -1
  93. package/dist/api/cardano/CardanoGetPublicKey.d.ts +1 -0
  94. package/dist/api/cardano/CardanoGetPublicKey.d.ts.map +1 -1
  95. package/dist/api/cardano/CardanoSignMessage.d.ts +1 -0
  96. package/dist/api/cardano/CardanoSignMessage.d.ts.map +1 -1
  97. package/dist/api/cardano/CardanoSignTransaction.d.ts +1 -0
  98. package/dist/api/cardano/CardanoSignTransaction.d.ts.map +1 -1
  99. package/dist/api/conflux/ConfluxGetAddress.d.ts +1 -0
  100. package/dist/api/conflux/ConfluxGetAddress.d.ts.map +1 -1
  101. package/dist/api/conflux/ConfluxSignMessage.d.ts +1 -0
  102. package/dist/api/conflux/ConfluxSignMessage.d.ts.map +1 -1
  103. package/dist/api/conflux/ConfluxSignMessageCIP23.d.ts +1 -0
  104. package/dist/api/conflux/ConfluxSignMessageCIP23.d.ts.map +1 -1
  105. package/dist/api/conflux/ConfluxSignTransaction.d.ts +1 -0
  106. package/dist/api/conflux/ConfluxSignTransaction.d.ts.map +1 -1
  107. package/dist/api/cosmos/CosmosGetAddress.d.ts +1 -0
  108. package/dist/api/cosmos/CosmosGetAddress.d.ts.map +1 -1
  109. package/dist/api/cosmos/CosmosGetPublicKey.d.ts +1 -0
  110. package/dist/api/cosmos/CosmosGetPublicKey.d.ts.map +1 -1
  111. package/dist/api/cosmos/CosmosSignTransaction.d.ts +1 -0
  112. package/dist/api/cosmos/CosmosSignTransaction.d.ts.map +1 -1
  113. package/dist/api/device/DeviceCancel.d.ts +1 -0
  114. package/dist/api/device/DeviceCancel.d.ts.map +1 -1
  115. package/dist/api/device/DeviceChangePin.d.ts +1 -0
  116. package/dist/api/device/DeviceChangePin.d.ts.map +1 -1
  117. package/dist/api/device/DeviceLock.d.ts +1 -0
  118. package/dist/api/device/DeviceLock.d.ts.map +1 -1
  119. package/dist/api/device/DeviceRebootToBoardloader.d.ts +1 -0
  120. package/dist/api/device/DeviceRebootToBoardloader.d.ts.map +1 -1
  121. package/dist/api/device/DeviceRebootToBootloader.d.ts +1 -0
  122. package/dist/api/device/DeviceRebootToBootloader.d.ts.map +1 -1
  123. package/dist/api/device/DeviceSettings.d.ts +1 -0
  124. package/dist/api/device/DeviceSettings.d.ts.map +1 -1
  125. package/dist/api/device/DeviceSupportFeatures.d.ts +1 -0
  126. package/dist/api/device/DeviceSupportFeatures.d.ts.map +1 -1
  127. package/dist/api/device/DeviceUnlock.d.ts +1 -0
  128. package/dist/api/device/DeviceUnlock.d.ts.map +1 -1
  129. package/dist/api/device/DeviceUpdateBootloader.d.ts +5 -1
  130. package/dist/api/device/DeviceUpdateBootloader.d.ts.map +1 -1
  131. package/dist/api/device/DeviceWipe.d.ts +1 -0
  132. package/dist/api/device/DeviceWipe.d.ts.map +1 -1
  133. package/dist/api/device/PreInitialize.d.ts +1 -0
  134. package/dist/api/device/PreInitialize.d.ts.map +1 -1
  135. package/dist/api/dynex/DnxGetAddress.d.ts.map +1 -1
  136. package/dist/api/dynex/DnxSignTransaction.d.ts.map +1 -1
  137. package/dist/api/evm/EVMGetAddress.d.ts +1 -0
  138. package/dist/api/evm/EVMGetAddress.d.ts.map +1 -1
  139. package/dist/api/evm/EVMGetPublicKey.d.ts +1 -0
  140. package/dist/api/evm/EVMGetPublicKey.d.ts.map +1 -1
  141. package/dist/api/evm/EVMSignMessage.d.ts +1 -0
  142. package/dist/api/evm/EVMSignMessage.d.ts.map +1 -1
  143. package/dist/api/evm/EVMSignMessageEIP712.d.ts.map +1 -1
  144. package/dist/api/evm/EVMSignTransaction.d.ts +1 -0
  145. package/dist/api/evm/EVMSignTransaction.d.ts.map +1 -1
  146. package/dist/api/evm/EVMSignTypedData.d.ts +1 -0
  147. package/dist/api/evm/EVMSignTypedData.d.ts.map +1 -1
  148. package/dist/api/evm/EVMVerifyMessage.d.ts +1 -0
  149. package/dist/api/evm/EVMVerifyMessage.d.ts.map +1 -1
  150. package/dist/api/filecoin/FilecoinGetAddress.d.ts +1 -0
  151. package/dist/api/filecoin/FilecoinGetAddress.d.ts.map +1 -1
  152. package/dist/api/filecoin/FilecoinSignTransaction.d.ts +1 -0
  153. package/dist/api/filecoin/FilecoinSignTransaction.d.ts.map +1 -1
  154. package/dist/api/firmware/FirmwareArtifactSource.d.ts +25 -0
  155. package/dist/api/firmware/FirmwareArtifactSource.d.ts.map +1 -0
  156. package/dist/api/firmware/FirmwareHostBinding.d.ts +6 -0
  157. package/dist/api/firmware/FirmwareHostBinding.d.ts.map +1 -0
  158. package/dist/api/firmware/FirmwareUpdateBaseMethod.d.ts +7 -0
  159. package/dist/api/firmware/FirmwareUpdateBaseMethod.d.ts.map +1 -1
  160. package/dist/api/firmware/FirmwareUpdateCapabilities.d.ts +3 -0
  161. package/dist/api/firmware/FirmwareUpdateCapabilities.d.ts.map +1 -0
  162. package/dist/api/firmware/FirmwareUpdatePlan.d.ts +23 -0
  163. package/dist/api/firmware/FirmwareUpdatePlan.d.ts.map +1 -0
  164. package/dist/api/firmware/FirmwareUpdatePreparedPlan.d.ts +30 -0
  165. package/dist/api/firmware/FirmwareUpdatePreparedPlan.d.ts.map +1 -0
  166. package/dist/api/firmware/getBinary.d.ts +7 -0
  167. package/dist/api/firmware/getBinary.d.ts.map +1 -1
  168. package/dist/api/firmware/updateBootloader.d.ts +2 -0
  169. package/dist/api/firmware/updateBootloader.d.ts.map +1 -1
  170. package/dist/api/firmware/uploadFirmware.d.ts +9 -1
  171. package/dist/api/firmware/uploadFirmware.d.ts.map +1 -1
  172. package/dist/api/kaspa/KaspaGetAddress.d.ts +1 -0
  173. package/dist/api/kaspa/KaspaGetAddress.d.ts.map +1 -1
  174. package/dist/api/kaspa/KaspaSignTransaction.d.ts +1 -0
  175. package/dist/api/kaspa/KaspaSignTransaction.d.ts.map +1 -1
  176. package/dist/api/kaspa/helpers/TransferSerialize.d.ts.map +1 -1
  177. package/dist/api/lightning/LnurlAuth.d.ts +0 -4
  178. package/dist/api/lightning/LnurlAuth.d.ts.map +1 -1
  179. package/dist/api/near/NearGetAddress.d.ts +1 -0
  180. package/dist/api/near/NearGetAddress.d.ts.map +1 -1
  181. package/dist/api/near/NearSignTransaction.d.ts +1 -0
  182. package/dist/api/near/NearSignTransaction.d.ts.map +1 -1
  183. package/dist/api/nem/NEMGetAddress.d.ts +1 -0
  184. package/dist/api/nem/NEMGetAddress.d.ts.map +1 -1
  185. package/dist/api/nem/NEMSignTransaction.d.ts +1 -0
  186. package/dist/api/nem/NEMSignTransaction.d.ts.map +1 -1
  187. package/dist/api/neo/NeoGetAddress.d.ts.map +1 -1
  188. package/dist/api/neo/NeoSignTransaction.d.ts.map +1 -1
  189. package/dist/api/nervos/NervosGetAddress.d.ts.map +1 -1
  190. package/dist/api/nervos/NervosSignTransaction.d.ts.map +1 -1
  191. package/dist/api/nexa/NexaGetAddress.d.ts.map +1 -1
  192. package/dist/api/nexa/NexaSignTransaction.d.ts.map +1 -1
  193. package/dist/api/nostr/NostrDecryptMessage.d.ts +1 -0
  194. package/dist/api/nostr/NostrDecryptMessage.d.ts.map +1 -1
  195. package/dist/api/nostr/NostrEncryptMessage.d.ts +1 -0
  196. package/dist/api/nostr/NostrEncryptMessage.d.ts.map +1 -1
  197. package/dist/api/nostr/NostrGetPublicKey.d.ts +1 -0
  198. package/dist/api/nostr/NostrGetPublicKey.d.ts.map +1 -1
  199. package/dist/api/nostr/NostrSignEvent.d.ts +1 -0
  200. package/dist/api/nostr/NostrSignEvent.d.ts.map +1 -1
  201. package/dist/api/nostr/NostrSignSchnorr.d.ts +1 -0
  202. package/dist/api/nostr/NostrSignSchnorr.d.ts.map +1 -1
  203. package/dist/api/polkadot/PolkadotGetAddress.d.ts +1 -0
  204. package/dist/api/polkadot/PolkadotGetAddress.d.ts.map +1 -1
  205. package/dist/api/polkadot/PolkadotSignTransaction.d.ts +1 -0
  206. package/dist/api/polkadot/PolkadotSignTransaction.d.ts.map +1 -1
  207. package/dist/api/protocol-v2/DeviceFactoryInfoGet.d.ts +1 -0
  208. package/dist/api/protocol-v2/DeviceFactoryInfoGet.d.ts.map +1 -1
  209. package/dist/api/protocol-v2/DeviceFactoryInfoSet.d.ts +1 -0
  210. package/dist/api/protocol-v2/DeviceFactoryInfoSet.d.ts.map +1 -1
  211. package/dist/api/protocol-v2/DeviceFirmwareUpdate.d.ts +1 -0
  212. package/dist/api/protocol-v2/DeviceFirmwareUpdate.d.ts.map +1 -1
  213. package/dist/api/protocol-v2/DeviceGetFirmwareUpdateStatus.d.ts +1 -0
  214. package/dist/api/protocol-v2/DeviceGetFirmwareUpdateStatus.d.ts.map +1 -1
  215. package/dist/api/protocol-v2/DeviceGetOnboardingStatus.d.ts +1 -0
  216. package/dist/api/protocol-v2/DeviceGetOnboardingStatus.d.ts.map +1 -1
  217. package/dist/api/protocol-v2/DeviceInfoGet.d.ts +1 -0
  218. package/dist/api/protocol-v2/DeviceInfoGet.d.ts.map +1 -1
  219. package/dist/api/protocol-v2/DeviceReboot.d.ts +1 -0
  220. package/dist/api/protocol-v2/DeviceReboot.d.ts.map +1 -1
  221. package/dist/api/protocol-v2/DeviceStatusGet.d.ts +1 -0
  222. package/dist/api/protocol-v2/DeviceStatusGet.d.ts.map +1 -1
  223. package/dist/api/protocol-v2/DeviceUploadWallpaper.d.ts +1 -0
  224. package/dist/api/protocol-v2/DeviceUploadWallpaper.d.ts.map +1 -1
  225. package/dist/api/protocol-v2/FilesystemFormat.d.ts +1 -0
  226. package/dist/api/protocol-v2/FilesystemFormat.d.ts.map +1 -1
  227. package/dist/api/protocol-v2/FilesystemPermissionFix.d.ts +1 -0
  228. package/dist/api/protocol-v2/FilesystemPermissionFix.d.ts.map +1 -1
  229. package/dist/api/protocol-v2/Ping.d.ts +1 -0
  230. package/dist/api/protocol-v2/Ping.d.ts.map +1 -1
  231. package/dist/api/protocol-v2/ProtocolInfoRequest.d.ts +1 -0
  232. package/dist/api/protocol-v2/ProtocolInfoRequest.d.ts.map +1 -1
  233. package/dist/api/scdo/ScdoGetAddress.d.ts.map +1 -1
  234. package/dist/api/scdo/ScdoSignMessage.d.ts.map +1 -1
  235. package/dist/api/scdo/ScdoSignTransaction.d.ts.map +1 -1
  236. package/dist/api/solana/SolGetAddress.d.ts +1 -0
  237. package/dist/api/solana/SolGetAddress.d.ts.map +1 -1
  238. package/dist/api/solana/SolSignMessage.d.ts +1 -0
  239. package/dist/api/solana/SolSignMessage.d.ts.map +1 -1
  240. package/dist/api/solana/SolSignOffchainMessage.d.ts +1 -0
  241. package/dist/api/solana/SolSignOffchainMessage.d.ts.map +1 -1
  242. package/dist/api/solana/SolSignTransaction.d.ts +1 -0
  243. package/dist/api/solana/SolSignTransaction.d.ts.map +1 -1
  244. package/dist/api/starcoin/StarcoinGetAddress.d.ts +1 -0
  245. package/dist/api/starcoin/StarcoinGetAddress.d.ts.map +1 -1
  246. package/dist/api/starcoin/StarcoinGetPublicKey.d.ts +1 -0
  247. package/dist/api/starcoin/StarcoinGetPublicKey.d.ts.map +1 -1
  248. package/dist/api/starcoin/StarcoinSignMessage.d.ts +1 -0
  249. package/dist/api/starcoin/StarcoinSignMessage.d.ts.map +1 -1
  250. package/dist/api/starcoin/StarcoinSignTransaction.d.ts +1 -0
  251. package/dist/api/starcoin/StarcoinSignTransaction.d.ts.map +1 -1
  252. package/dist/api/starcoin/StarcoinVerifyMessage.d.ts +1 -0
  253. package/dist/api/starcoin/StarcoinVerifyMessage.d.ts.map +1 -1
  254. package/dist/api/stellar/StellarGetAddress.d.ts +1 -2
  255. package/dist/api/stellar/StellarGetAddress.d.ts.map +1 -1
  256. package/dist/api/stellar/StellarSignTransaction.d.ts +2 -3
  257. package/dist/api/stellar/StellarSignTransaction.d.ts.map +1 -1
  258. package/dist/api/sui/SuiGetAddress.d.ts +1 -0
  259. package/dist/api/sui/SuiGetAddress.d.ts.map +1 -1
  260. package/dist/api/sui/SuiGetPublicKey.d.ts +1 -0
  261. package/dist/api/sui/SuiGetPublicKey.d.ts.map +1 -1
  262. package/dist/api/sui/SuiSignMessage.d.ts +1 -0
  263. package/dist/api/sui/SuiSignMessage.d.ts.map +1 -1
  264. package/dist/api/sui/SuiSignTransaction.d.ts +1 -0
  265. package/dist/api/sui/SuiSignTransaction.d.ts.map +1 -1
  266. package/dist/api/ton/TonGetAddress.d.ts +1 -0
  267. package/dist/api/ton/TonGetAddress.d.ts.map +1 -1
  268. package/dist/api/ton/TonSignData.d.ts +1 -0
  269. package/dist/api/ton/TonSignData.d.ts.map +1 -1
  270. package/dist/api/ton/TonSignMessage.d.ts +1 -0
  271. package/dist/api/ton/TonSignMessage.d.ts.map +1 -1
  272. package/dist/api/ton/TonSignProof.d.ts +1 -0
  273. package/dist/api/ton/TonSignProof.d.ts.map +1 -1
  274. package/dist/api/tron/TronGetAddress.d.ts +1 -0
  275. package/dist/api/tron/TronGetAddress.d.ts.map +1 -1
  276. package/dist/api/tron/TronSignMessage.d.ts +2 -0
  277. package/dist/api/tron/TronSignMessage.d.ts.map +1 -1
  278. package/dist/api/tron/TronSignTransaction.d.ts +1 -0
  279. package/dist/api/tron/TronSignTransaction.d.ts.map +1 -1
  280. package/dist/api/xrp/XrpGetAddress.d.ts +1 -0
  281. package/dist/api/xrp/XrpGetAddress.d.ts.map +1 -1
  282. package/dist/api/xrp/XrpSignTransaction.d.ts +1 -0
  283. package/dist/api/xrp/XrpSignTransaction.d.ts.map +1 -1
  284. package/dist/core/index.d.ts.map +1 -1
  285. package/dist/data-manager/DataManager.d.ts +1 -0
  286. package/dist/data-manager/DataManager.d.ts.map +1 -1
  287. package/dist/data-manager/connectSettings.d.ts.map +1 -1
  288. package/dist/device/Device.d.ts +3 -1
  289. package/dist/device/Device.d.ts.map +1 -1
  290. package/dist/index.d.ts +271 -87
  291. package/dist/index.d.ts.map +1 -1
  292. package/dist/index.js +2844 -882
  293. package/dist/inject.d.ts.map +1 -1
  294. package/dist/lowLevelInject.d.ts.map +1 -1
  295. package/dist/topLevelInject.d.ts.map +1 -1
  296. package/dist/types/api/checkAllFirmwareRelease.d.ts +3 -0
  297. package/dist/types/api/checkAllFirmwareRelease.d.ts.map +1 -1
  298. package/dist/types/api/deviceUpdateBootloader.d.ts +6 -0
  299. package/dist/types/api/deviceUpdateBootloader.d.ts.map +1 -1
  300. package/dist/types/api/export.d.ts +5 -2
  301. package/dist/types/api/export.d.ts.map +1 -1
  302. package/dist/types/api/firmwareUpdate.d.ts +69 -0
  303. package/dist/types/api/firmwareUpdate.d.ts.map +1 -1
  304. package/dist/types/api/firmwareUpdateCapabilities.d.ts +9 -0
  305. package/dist/types/api/firmwareUpdateCapabilities.d.ts.map +1 -0
  306. package/dist/types/api/firmwareUpdatePlan.d.ts +27 -0
  307. package/dist/types/api/firmwareUpdatePlan.d.ts.map +1 -0
  308. package/dist/types/api/firmwareUpdatePreparedPlan.d.ts +42 -0
  309. package/dist/types/api/firmwareUpdatePreparedPlan.d.ts.map +1 -0
  310. package/dist/types/api/index.d.ts +9 -1
  311. package/dist/types/api/index.d.ts.map +1 -1
  312. package/dist/types/api/kaspaSignTransaction.d.ts +15 -2
  313. package/dist/types/api/kaspaSignTransaction.d.ts.map +1 -1
  314. package/dist/types/device.d.ts +0 -1
  315. package/dist/types/device.d.ts.map +1 -1
  316. package/dist/types/settings.d.ts +13 -0
  317. package/dist/types/settings.d.ts.map +1 -1
  318. package/dist/utils/deviceInfoUtils.d.ts +0 -1
  319. package/dist/utils/deviceInfoUtils.d.ts.map +1 -1
  320. package/dist/utils/deviceVersionUtils.d.ts +1 -0
  321. package/dist/utils/deviceVersionUtils.d.ts.map +1 -1
  322. package/dist/utils/index.d.ts +1 -1
  323. package/dist/utils/index.d.ts.map +1 -1
  324. package/package.json +4 -4
  325. package/src/api/BaseMethod.ts +21 -18
  326. package/src/api/CheckAllFirmwareRelease.ts +44 -4
  327. package/src/api/CipherKeyValue.ts +4 -0
  328. package/src/api/DirList.ts +4 -1
  329. package/src/api/DirMake.ts +4 -1
  330. package/src/api/DirRemove.ts +4 -1
  331. package/src/api/FileDelete.ts +4 -1
  332. package/src/api/FileRead.ts +4 -1
  333. package/src/api/FileWrite.ts +4 -1
  334. package/src/api/FirmwareUpdate.ts +0 -8
  335. package/src/api/FirmwareUpdateV2.ts +292 -120
  336. package/src/api/FirmwareUpdateV3.ts +256 -61
  337. package/src/api/FirmwareUpdateV4.ts +767 -289
  338. package/src/api/GetDeviceState.ts +4 -0
  339. package/src/api/GetFeatures.ts +1 -4
  340. package/src/api/GetOnekeyFeatures.ts +0 -5
  341. package/src/api/GetPassphraseState.ts +4 -0
  342. package/src/api/OpenWalletSession.ts +4 -0
  343. package/src/api/PathInfo.ts +4 -1
  344. package/src/api/alephium/AlephiumGetAddress.ts +0 -4
  345. package/src/api/alephium/AlephiumSignMessage.ts +0 -4
  346. package/src/api/alephium/AlephiumSignTransaction.ts +0 -4
  347. package/src/api/algo/AlgoGetAddress.ts +4 -0
  348. package/src/api/algo/AlgoSignTransaction.ts +4 -0
  349. package/src/api/allnetwork/AllNetworkGetAddressBase.ts +5 -13
  350. package/src/api/aptos/AptosGetAddress.ts +4 -0
  351. package/src/api/aptos/AptosGetPublicKey.ts +4 -0
  352. package/src/api/aptos/AptosSignInMessage.ts +4 -0
  353. package/src/api/aptos/AptosSignMessage.ts +4 -0
  354. package/src/api/aptos/AptosSignTransaction.ts +4 -0
  355. package/src/api/benfen/BenfenGetAddress.ts +11 -7
  356. package/src/api/benfen/BenfenGetPublicKey.ts +0 -4
  357. package/src/api/benfen/BenfenSignMessage.ts +0 -4
  358. package/src/api/benfen/BenfenSignTransaction.ts +0 -4
  359. package/src/api/btc/BTCGetAddress.ts +8 -1
  360. package/src/api/btc/BTCGetPublicKey.ts +8 -1
  361. package/src/api/btc/BTCSignMessage.ts +8 -1
  362. package/src/api/btc/BTCSignPsbt.ts +4 -0
  363. package/src/api/btc/BTCSignTransaction.ts +8 -1
  364. package/src/api/btc/BTCVerifyMessage.ts +8 -1
  365. package/src/api/btc/helpers/versionLimit.ts +7 -4
  366. package/src/api/cardano/CardanoGetAddress.ts +4 -0
  367. package/src/api/cardano/CardanoGetPublicKey.ts +4 -0
  368. package/src/api/cardano/CardanoSignMessage.ts +4 -0
  369. package/src/api/cardano/CardanoSignTransaction.ts +4 -0
  370. package/src/api/conflux/ConfluxGetAddress.ts +4 -0
  371. package/src/api/conflux/ConfluxSignMessage.ts +4 -0
  372. package/src/api/conflux/ConfluxSignMessageCIP23.ts +4 -0
  373. package/src/api/conflux/ConfluxSignTransaction.ts +6 -5
  374. package/src/api/cosmos/CosmosGetAddress.ts +4 -0
  375. package/src/api/cosmos/CosmosGetPublicKey.ts +4 -0
  376. package/src/api/cosmos/CosmosSignTransaction.ts +4 -0
  377. package/src/api/device/DeviceCancel.ts +4 -0
  378. package/src/api/device/DeviceChangePin.ts +4 -0
  379. package/src/api/device/DeviceLock.ts +4 -0
  380. package/src/api/device/DeviceRebootToBoardloader.ts +4 -0
  381. package/src/api/device/DeviceRebootToBootloader.ts +4 -0
  382. package/src/api/device/DeviceSettings.ts +4 -0
  383. package/src/api/device/DeviceSupportFeatures.ts +4 -0
  384. package/src/api/device/DeviceUnlock.ts +4 -0
  385. package/src/api/device/DeviceUpdateBootloader.ts +122 -6
  386. package/src/api/device/DeviceWipe.ts +4 -0
  387. package/src/api/device/PreInitialize.ts +4 -0
  388. package/src/api/dynex/DnxGetAddress.ts +0 -6
  389. package/src/api/dynex/DnxSignTransaction.ts +0 -6
  390. package/src/api/evm/EVMGetAddress.ts +4 -0
  391. package/src/api/evm/EVMGetPublicKey.ts +4 -0
  392. package/src/api/evm/EVMSignMessage.ts +4 -0
  393. package/src/api/evm/EVMSignMessageEIP712.ts +1 -11
  394. package/src/api/evm/EVMSignTransaction.ts +4 -0
  395. package/src/api/evm/EVMSignTypedData.ts +4 -0
  396. package/src/api/evm/EVMVerifyMessage.ts +4 -0
  397. package/src/api/filecoin/FilecoinGetAddress.ts +4 -0
  398. package/src/api/filecoin/FilecoinSignTransaction.ts +4 -0
  399. package/src/api/firmware/FirmwareArtifactSource.ts +278 -0
  400. package/src/api/firmware/FirmwareHostBinding.ts +100 -0
  401. package/src/api/firmware/FirmwareUpdateBaseMethod.ts +50 -0
  402. package/src/api/firmware/FirmwareUpdateCapabilities.ts +9 -0
  403. package/src/api/firmware/FirmwareUpdatePlan.ts +628 -0
  404. package/src/api/firmware/FirmwareUpdatePreparedPlan.ts +392 -0
  405. package/src/api/firmware/updateBootloader.ts +19 -4
  406. package/src/api/firmware/uploadFirmware.ts +140 -22
  407. package/src/api/kaspa/KaspaGetAddress.ts +4 -0
  408. package/src/api/kaspa/KaspaSignTransaction.ts +37 -15
  409. package/src/api/kaspa/helpers/TransferSerialize.ts +3 -7
  410. package/src/api/lightning/LnurlAuth.ts +0 -4
  411. package/src/api/near/NearGetAddress.ts +4 -0
  412. package/src/api/near/NearSignTransaction.ts +4 -0
  413. package/src/api/nem/NEMGetAddress.ts +4 -0
  414. package/src/api/nem/NEMSignTransaction.ts +4 -0
  415. package/src/api/neo/NeoGetAddress.ts +0 -4
  416. package/src/api/neo/NeoSignTransaction.ts +0 -4
  417. package/src/api/nervos/NervosGetAddress.ts +0 -4
  418. package/src/api/nervos/NervosSignTransaction.ts +0 -4
  419. package/src/api/nexa/NexaGetAddress.ts +0 -4
  420. package/src/api/nexa/NexaSignTransaction.ts +0 -4
  421. package/src/api/nostr/NostrDecryptMessage.ts +4 -0
  422. package/src/api/nostr/NostrEncryptMessage.ts +4 -0
  423. package/src/api/nostr/NostrGetPublicKey.ts +4 -0
  424. package/src/api/nostr/NostrSignEvent.ts +4 -0
  425. package/src/api/nostr/NostrSignSchnorr.ts +4 -0
  426. package/src/api/polkadot/PolkadotGetAddress.ts +4 -0
  427. package/src/api/polkadot/PolkadotSignTransaction.ts +4 -0
  428. package/src/api/protocol-v2/DeviceFactoryInfoGet.ts +4 -1
  429. package/src/api/protocol-v2/DeviceFactoryInfoSet.ts +4 -1
  430. package/src/api/protocol-v2/DeviceFirmwareUpdate.ts +4 -1
  431. package/src/api/protocol-v2/DeviceGetFirmwareUpdateStatus.ts +4 -1
  432. package/src/api/protocol-v2/DeviceGetOnboardingStatus.ts +4 -1
  433. package/src/api/protocol-v2/DeviceInfoGet.ts +4 -8
  434. package/src/api/protocol-v2/DeviceReboot.ts +4 -2
  435. package/src/api/protocol-v2/DeviceStatusGet.ts +4 -1
  436. package/src/api/protocol-v2/DeviceUploadWallpaper.ts +4 -1
  437. package/src/api/protocol-v2/FilesystemFormat.ts +4 -1
  438. package/src/api/protocol-v2/FilesystemPermissionFix.ts +4 -1
  439. package/src/api/protocol-v2/Ping.ts +4 -1
  440. package/src/api/protocol-v2/ProtocolInfoRequest.ts +4 -1
  441. package/src/api/scdo/ScdoGetAddress.ts +0 -4
  442. package/src/api/scdo/ScdoSignMessage.ts +0 -4
  443. package/src/api/scdo/ScdoSignTransaction.ts +0 -4
  444. package/src/api/solana/SolGetAddress.ts +4 -0
  445. package/src/api/solana/SolSignMessage.ts +4 -0
  446. package/src/api/solana/SolSignOffchainMessage.ts +4 -0
  447. package/src/api/solana/SolSignTransaction.ts +4 -0
  448. package/src/api/starcoin/StarcoinGetAddress.ts +4 -0
  449. package/src/api/starcoin/StarcoinGetPublicKey.ts +4 -0
  450. package/src/api/starcoin/StarcoinSignMessage.ts +4 -0
  451. package/src/api/starcoin/StarcoinSignTransaction.ts +4 -0
  452. package/src/api/starcoin/StarcoinVerifyMessage.ts +4 -0
  453. package/src/api/stellar/StellarGetAddress.ts +1 -10
  454. package/src/api/stellar/StellarSignTransaction.ts +1 -14
  455. package/src/api/sui/SuiGetAddress.ts +4 -0
  456. package/src/api/sui/SuiGetPublicKey.ts +4 -0
  457. package/src/api/sui/SuiSignMessage.ts +4 -0
  458. package/src/api/sui/SuiSignTransaction.ts +4 -0
  459. package/src/api/ton/TonGetAddress.ts +4 -0
  460. package/src/api/ton/TonSignData.ts +5 -1
  461. package/src/api/ton/TonSignMessage.ts +4 -0
  462. package/src/api/ton/TonSignProof.ts +4 -0
  463. package/src/api/tron/TronGetAddress.ts +4 -0
  464. package/src/api/tron/TronSignMessage.ts +15 -7
  465. package/src/api/tron/TronSignTransaction.ts +4 -0
  466. package/src/api/xrp/XrpGetAddress.ts +4 -0
  467. package/src/api/xrp/XrpSignTransaction.ts +5 -1
  468. package/src/core/index.ts +4 -17
  469. package/src/data-manager/DataManager.ts +33 -33
  470. package/src/data-manager/connectSettings.ts +11 -0
  471. package/src/device/Device.ts +53 -53
  472. package/src/index.ts +5 -0
  473. package/src/inject.ts +22 -2
  474. package/src/lowLevelInject.ts +5 -1
  475. package/src/topLevelInject.ts +5 -1
  476. package/src/types/api/checkAllFirmwareRelease.ts +3 -0
  477. package/src/types/api/deviceUpdateBootloader.ts +6 -0
  478. package/src/types/api/export.ts +20 -0
  479. package/src/types/api/firmwareUpdate.ts +76 -0
  480. package/src/types/api/firmwareUpdateCapabilities.ts +9 -0
  481. package/src/types/api/firmwareUpdatePlan.ts +36 -0
  482. package/src/types/api/firmwareUpdatePreparedPlan.ts +53 -0
  483. package/src/types/api/index.ts +14 -0
  484. package/src/types/api/kaspaSignTransaction.ts +20 -2
  485. package/src/types/device.ts +0 -1
  486. package/src/types/settings.ts +13 -0
  487. package/src/utils/deviceInfoUtils.ts +0 -3
  488. package/src/utils/deviceVersionUtils.ts +1 -1
  489. package/src/utils/index.ts +0 -1
  490. package/tsconfig.type-tests.json +8 -0
@@ -1,4 +1,4 @@
1
- import { HardwareErrorCode } from '@onekeyfe/hd-shared';
1
+ import { EFirmwareType, HardwareErrorCode } from '@onekeyfe/hd-shared';
2
2
  import { DeviceRebootType, DeviceSessionPinType, DeviceSettingsPage } from '@onekeyfe/hd-transport';
3
3
 
4
4
  import * as firmwareBinaryApi from '../src/api/firmware/getBinary';
@@ -50,7 +50,7 @@ import TonSignProof from '../src/api/ton/TonSignProof';
50
50
  import TronGetAddress from '../src/api/tron/TronGetAddress';
51
51
  import StellarGetAddress from '../src/api/stellar/StellarGetAddress';
52
52
  import BenfenSignMessage from '../src/api/benfen/BenfenSignMessage';
53
- import { getBitcoinForkVersionRange } from '../src/api/btc/helpers/versionLimit';
53
+ import { getBitcoinForkSupportedProtocols } from '../src/api/btc/helpers/versionLimit';
54
54
  import { DataManager } from '../src/data-manager';
55
55
  import { createCoreApi } from '../src/inject';
56
56
  import { Device, preloadSessionCache } from '../src/device/Device';
@@ -80,9 +80,9 @@ import {
80
80
  getFirmwareUpdateField,
81
81
  getFirmwareUpdateFieldArray,
82
82
  getMethodVersionRange,
83
- isMethodVersionRangeUnsupported,
84
83
  } from '../src/utils';
85
84
  import { getDeviceFirmwareVersion } from '../src/utils/deviceVersionUtils';
85
+ import { openFirmwareByteSource } from '../src/api/firmware/FirmwareArtifactSource';
86
86
  import {
87
87
  getPassphraseState,
88
88
  getPassphraseStateWithRefreshDeviceInfo,
@@ -129,7 +129,7 @@ describe('DeviceUploadWallpaper', () => {
129
129
  method.init();
130
130
  const result = await method.run();
131
131
 
132
- expect(method.requireProtocolV2).toBe(true);
132
+ expect(method.getSupportedProtocols()).toEqual(['V2']);
133
133
  expect(method.unlockPolicy).toBe('unlock-before-run');
134
134
  expect(typedCall).toHaveBeenNthCalledWith(1, 'FilesystemDirMake', 'Success', {
135
135
  path: 'vol1:/wallpapers',
@@ -971,7 +971,7 @@ describe('Protocol V2 feature adapter', () => {
971
971
  wallet_initialized: false,
972
972
  });
973
973
  expect(typedCall).toHaveBeenCalledWith('DevGetOnboardingStatus', 'DevOnboardingStatus', {});
974
- expect(method.requireProtocolV2).toBe(true);
974
+ expect(method.getSupportedProtocols()).toEqual(['V2']);
975
975
  });
976
976
 
977
977
  test('routes onboarding without exposing the raw session command through CoreApi', async () => {
@@ -1957,13 +1957,6 @@ describe('Protocol V2 feature adapter', () => {
1957
1957
  });
1958
1958
 
1959
1959
  test('marks known unsupported public-chain methods as unsupported on Protocol V2', () => {
1960
- const features = normalizeProtocolV2Features({ ...descriptor, protocolType: 'V2' } as any, {
1961
- fw: {
1962
- application: {
1963
- version: '9.9.9',
1964
- },
1965
- },
1966
- });
1967
1960
  const stellar = new StellarGetAddress({
1968
1961
  id: 1,
1969
1962
  payload: {
@@ -1992,21 +1985,10 @@ describe('Protocol V2 feature adapter', () => {
1992
1985
  benfen.init();
1993
1986
  lnurlAuth.init();
1994
1987
 
1995
- const stellarRange = getMethodVersionRange(features, type => stellar.getVersionRange()[type]);
1996
- const benfenRange = getMethodVersionRange(features, type => benfen.getVersionRange()[type]);
1997
- const lnurlAuthRange = getMethodVersionRange(
1998
- features,
1999
- type => lnurlAuth.getVersionRange()[type]
2000
- );
2001
- const neuraiRange = getMethodVersionRange(
2002
- features,
2003
- type => getBitcoinForkVersionRange(['Neurai'])[type]
2004
- );
2005
-
2006
- expect(isMethodVersionRangeUnsupported(stellarRange)).toBe(true);
2007
- expect(isMethodVersionRangeUnsupported(benfenRange)).toBe(true);
2008
- expect(isMethodVersionRangeUnsupported(lnurlAuthRange)).toBe(true);
2009
- expect(isMethodVersionRangeUnsupported(neuraiRange)).toBe(true);
1988
+ expect(stellar.supportsProtocol('V2')).toBe(false);
1989
+ expect(benfen.supportsProtocol('V2')).toBe(false);
1990
+ expect(lnurlAuth.supportsProtocol('V2')).toBe(false);
1991
+ expect(getBitcoinForkSupportedProtocols(['Neurai'])).toEqual(['V1']);
2010
1992
  });
2011
1993
 
2012
1994
  test('does not block batch public key support checks on Protocol V2', async () => {
@@ -2045,7 +2027,7 @@ describe('Protocol V2 feature adapter', () => {
2045
2027
  });
2046
2028
  });
2047
2029
 
2048
- test('rejects legacy getOnekeyFeatures for Protocol V2 devices', async () => {
2030
+ test('declares legacy getOnekeyFeatures unsupported on Protocol V2', () => {
2049
2031
  const method = new GetOnekeyFeatures({
2050
2032
  id: 1,
2051
2033
  payload: {
@@ -2059,9 +2041,9 @@ describe('Protocol V2 feature adapter', () => {
2059
2041
  commands: { typedCall },
2060
2042
  });
2061
2043
 
2062
- await expect(method.run()).rejects.toMatchObject({
2063
- errorCode: expect.any(Number),
2064
- });
2044
+ expect(() => method.assertProtocolSupported('V2', EFirmwareType.Universal)).toThrow(
2045
+ expect.objectContaining({ errorCode: HardwareErrorCode.DeviceNotSupportMethod })
2046
+ );
2065
2047
  expect(typedCall).not.toHaveBeenCalled();
2066
2048
  });
2067
2049
 
@@ -2594,16 +2576,8 @@ describe('API compatibility handling', () => {
2594
2576
 
2595
2577
  polkadotGetAddressMethod.init();
2596
2578
 
2597
- expect(
2598
- isMethodVersionRangeUnsupported(
2599
- getMethodVersionRange(features, type => tronMethod.getVersionRange()[type])
2600
- )
2601
- ).toBe(false);
2602
- expect(
2603
- isMethodVersionRangeUnsupported(
2604
- getMethodVersionRange(features, type => solMethod.getVersionRange()[type])
2605
- )
2606
- ).toBe(false);
2579
+ expect(tronMethod.supportsProtocol('V2')).toBe(true);
2580
+ expect(solMethod.supportsProtocol('V2')).toBe(true);
2607
2581
  expect(
2608
2582
  getMethodVersionRange(features, type => tonGetAddressMethod.getVersionRange()[type])
2609
2583
  ).toEqual({
@@ -2759,7 +2733,7 @@ describe('API compatibility handling', () => {
2759
2733
  expect(params.data_initial_chunk).toHaveLength(2048);
2760
2734
  });
2761
2735
 
2762
- test('returns a typed unsupported error for Dynex signing on Protocol V2', async () => {
2736
+ test('declares Dynex signing unsupported on Protocol V2', () => {
2763
2737
  const method = new DnxSignTransaction({
2764
2738
  id: 1,
2765
2739
  payload: {
@@ -2781,17 +2755,14 @@ describe('API compatibility handling', () => {
2781
2755
  });
2782
2756
 
2783
2757
  method.init();
2784
- (method as any).device = stubDevice({
2785
- originalDescriptor: { protocolType: 'V2' },
2786
- features: normalizeProtocolV2Features({ ...descriptor, protocolType: 'V2' } as any),
2787
- });
2788
-
2789
- await expect(method.run()).rejects.toMatchObject({
2790
- errorCode: HardwareErrorCode.DeviceNotSupportMethod,
2791
- });
2758
+ expect(() => method.assertProtocolSupported('V2', EFirmwareType.Universal)).toThrow(
2759
+ expect.objectContaining({
2760
+ errorCode: HardwareErrorCode.DeviceNotSupportMethod,
2761
+ })
2762
+ );
2792
2763
  });
2793
2764
 
2794
- test('returns a typed unsupported error for Dynex address on Protocol V2', async () => {
2765
+ test('declares Dynex address unsupported on Protocol V2', () => {
2795
2766
  const method = new DnxGetAddress({
2796
2767
  id: 1,
2797
2768
  payload: {
@@ -2802,14 +2773,11 @@ describe('API compatibility handling', () => {
2802
2773
  });
2803
2774
 
2804
2775
  method.init();
2805
- (method as any).device = stubDevice({
2806
- originalDescriptor: { protocolType: 'V2' },
2807
- features: normalizeProtocolV2Features({ ...descriptor, protocolType: 'V2' } as any),
2808
- });
2809
-
2810
- await expect(method.run()).rejects.toMatchObject({
2811
- errorCode: HardwareErrorCode.DeviceNotSupportMethod,
2812
- });
2776
+ expect(() => method.assertProtocolSupported('V2', EFirmwareType.Universal)).toThrow(
2777
+ expect.objectContaining({
2778
+ errorCode: HardwareErrorCode.DeviceNotSupportMethod,
2779
+ })
2780
+ );
2813
2781
  });
2814
2782
  });
2815
2783
 
@@ -2848,18 +2816,16 @@ describe('Protocol V2 firmware update targets', () => {
2848
2816
  return header;
2849
2817
  };
2850
2818
 
2851
- test('keeps Protocol V2 firmware updates off the firmwareUpdateV3 path', async () => {
2819
+ test('keeps Protocol V2 firmware updates off the firmwareUpdateV3 path', () => {
2852
2820
  const method = new FirmwareUpdateV3({
2853
2821
  id: 1,
2854
2822
  payload: {
2855
2823
  method: 'firmwareUpdateV3',
2856
2824
  },
2857
2825
  });
2858
- (method as any).device = stubDevice({
2859
- originalDescriptor: { protocolType: 'V2' },
2860
- });
2861
-
2862
- await expect(method.run()).rejects.toThrow('firmwareUpdateV4');
2826
+ expect(() => method.assertProtocolSupported('V2', EFirmwareType.Universal)).toThrow(
2827
+ expect.objectContaining({ errorCode: HardwareErrorCode.DeviceNotSupportMethod })
2828
+ );
2863
2829
  });
2864
2830
 
2865
2831
  test('uses Protocol V2 features after BLE final reconnect without V1 Initialize', async () => {
@@ -2946,7 +2912,7 @@ describe('Protocol V2 firmware update targets', () => {
2946
2912
  });
2947
2913
  });
2948
2914
 
2949
- test('enters Protocol V2 bootloader before upload', async () => {
2915
+ test('delegates Protocol V2 mode transition to the phase executor', async () => {
2950
2916
  const method = new FirmwareUpdateV4({
2951
2917
  id: 1,
2952
2918
  payload: {
@@ -2981,7 +2947,7 @@ describe('Protocol V2 firmware update targets', () => {
2981
2947
 
2982
2948
  await method.run();
2983
2949
 
2984
- expect((method as any).enterProtocolV2BootloaderMode).toHaveBeenCalledTimes(1);
2950
+ expect((method as any).enterProtocolV2BootloaderMode).not.toHaveBeenCalled();
2985
2951
  expect((method as any).executeProtocolV2Update).toHaveBeenCalledWith({
2986
2952
  fwBinaryMap: [
2987
2953
  {
@@ -3300,9 +3266,9 @@ describe('Protocol V2 firmware update targets', () => {
3300
3266
  const typedCall = jest
3301
3267
  .fn()
3302
3268
  .mockRejectedValue(
3303
- new DOMException(
3304
- "Failed to execute 'open' on 'USBDevice': The device was disconnected",
3305
- 'NotFoundError'
3269
+ Object.assign(
3270
+ new Error("Failed to execute 'open' on 'USBDevice': The device was disconnected"),
3271
+ { name: 'NotFoundError' }
3306
3272
  )
3307
3273
  );
3308
3274
 
@@ -3390,7 +3356,7 @@ describe('Protocol V2 firmware update targets', () => {
3390
3356
  expect(method.postProgressMessage).toHaveBeenCalledWith(100, 'installingFirmware');
3391
3357
  });
3392
3358
 
3393
- test('accepts a missing firmware status handler as an app reboot signal', async () => {
3359
+ test('does not treat a missing firmware status handler as install completion', async () => {
3394
3360
  const method = new FirmwareUpdateV4({
3395
3361
  id: 1,
3396
3362
  payload: {
@@ -3409,12 +3375,88 @@ describe('Protocol V2 firmware update targets', () => {
3409
3375
  (method as any).verifyProtocolV2ReconnectIdentity = jest.fn().mockResolvedValue(undefined);
3410
3376
  method.postProgressMessage = jest.fn();
3411
3377
 
3412
- await (method as any).waitForProtocolV2FirmwareUpdateComplete([
3413
- { target_id: 4, path: 'vol0:/application_p1.bin' },
3414
- ]);
3378
+ await expect(
3379
+ (method as any).waitForProtocolV2FirmwareUpdateComplete([
3380
+ { target_id: 4, path: 'vol0:/application_p1.bin' },
3381
+ ])
3382
+ ).rejects.toThrow('Protocol V2 firmware install status is unavailable');
3415
3383
 
3416
3384
  expect(reconnectProtocolV2Device).toHaveBeenCalledTimes(1);
3417
- expect(typedCall.mock.calls.map(call => call[0])).toEqual(['DeviceFirmwareUpdateStatusGet']);
3385
+ expect(typedCall.mock.calls.map(call => call[0])).toEqual([
3386
+ 'DeviceFirmwareUpdateStatusGet',
3387
+ 'DeviceInfoGet',
3388
+ ]);
3389
+ });
3390
+
3391
+ test('rejects a finished target whose payload version conflicts with the plan', () => {
3392
+ const method = new FirmwareUpdateV4({
3393
+ id: 1,
3394
+ payload: {
3395
+ method: 'firmwareUpdateV4',
3396
+ platform: 'desktop',
3397
+ expectedTargetVersions: {
3398
+ app_v1: '2.0.0',
3399
+ },
3400
+ },
3401
+ });
3402
+ method.init();
3403
+ method.postProgressMessage = jest.fn();
3404
+
3405
+ expect(() =>
3406
+ (method as any).assertProtocolV2TargetStatus(
3407
+ [{ target_id: 4, status: 2, payload_version: 0x010000 }],
3408
+ new Set([4])
3409
+ )
3410
+ ).toThrow('expected 131072');
3411
+ });
3412
+
3413
+ test('does not fail a completed multi-app install when final app versions are unobservable', () => {
3414
+ const method = new FirmwareUpdateV4({
3415
+ id: 1,
3416
+ payload: {
3417
+ method: 'firmwareUpdateV4',
3418
+ platform: 'desktop',
3419
+ targetsToUpdate: ['app_v1', 'app_v2'],
3420
+ expectedTargetVersions: {
3421
+ app_v1: '1.0.0',
3422
+ app_v2: '2.0.0',
3423
+ },
3424
+ },
3425
+ });
3426
+ method.init();
3427
+ (method as any).protocolV2LatestFinalFeatures = {
3428
+ major_version: 3,
3429
+ minor_version: 0,
3430
+ patch_version: 0,
3431
+ };
3432
+ (method as any).protocolV2FinalStatusVerified = true;
3433
+
3434
+ expect(() => (method as any).assertExpectedProtocolV2Versions()).not.toThrow();
3435
+ });
3436
+
3437
+ test('rejects unobservable final versions after the status endpoint fallback', () => {
3438
+ const method = new FirmwareUpdateV4({
3439
+ id: 1,
3440
+ payload: {
3441
+ method: 'firmwareUpdateV4',
3442
+ platform: 'desktop',
3443
+ targetsToUpdate: ['app_v1', 'app_v2'],
3444
+ expectedTargetVersions: {
3445
+ app_v1: '1.0.0',
3446
+ app_v2: '2.0.0',
3447
+ },
3448
+ },
3449
+ });
3450
+ method.init();
3451
+ (method as any).protocolV2LatestFinalFeatures = {
3452
+ major_version: 3,
3453
+ minor_version: 0,
3454
+ patch_version: 0,
3455
+ };
3456
+
3457
+ expect(() => (method as any).assertExpectedProtocolV2Versions()).toThrow(
3458
+ 'has no observable final version after status fallback'
3459
+ );
3418
3460
  });
3419
3461
 
3420
3462
  test('polls target status after update ACK and finishes when all targets complete', async () => {
@@ -3593,10 +3635,14 @@ describe('Protocol V2 firmware update targets', () => {
3593
3635
  const writtenPaths: string[] = [];
3594
3636
  method.postTipMessage = jest.fn();
3595
3637
  method.postProgressMessage = jest.fn();
3596
- (method as any).protocolV2CommonUpdateProcess = jest.fn().mockImplementation(params => {
3638
+ (method as any).protocolV2SourceUpdateProcess = jest.fn().mockImplementation(params => {
3597
3639
  writtenPaths.push(params.filePath);
3598
- return Number(params.processedSize ?? 0) + Number(params.payload.byteLength);
3640
+ return Number(params.processedSize ?? 0) + Number(params.source.size);
3599
3641
  });
3642
+ (method as any).enterProtocolV2BootloaderMode = jest.fn().mockResolvedValue(undefined);
3643
+ (method as any).exitProtocolV2BootloaderToNormal = jest.fn().mockResolvedValue(undefined);
3644
+ (method as any).waitForProtocolV2FinalFeatures = jest.fn().mockResolvedValue({});
3645
+ (method as any).completeProtocolV2FinalVerification = jest.fn().mockResolvedValue({});
3600
3646
  (method as any).verifyProtocolV2StagedFile = jest.fn().mockResolvedValue(undefined);
3601
3647
  (method as any).protocolV2StartFirmwareUpdate = jest.fn().mockResolvedValue(undefined);
3602
3648
  (method as any).waitForProtocolV2FirmwareUpdateComplete = jest
@@ -3636,10 +3682,12 @@ describe('Protocol V2 firmware update targets', () => {
3636
3682
  'vol0:/coprocessor.bin',
3637
3683
  1
3638
3684
  );
3639
- expect((method as any).protocolV2StartFirmwareUpdate).toHaveBeenCalledTimes(1);
3640
- expect((method as any).protocolV2StartFirmwareUpdate).toHaveBeenCalledWith({
3685
+ expect((method as any).protocolV2StartFirmwareUpdate).toHaveBeenCalledTimes(2);
3686
+ expect((method as any).protocolV2StartFirmwareUpdate).toHaveBeenNthCalledWith(1, {
3687
+ targets: [{ target_id: 3, path: 'vol0:/bootloader.bin' }],
3688
+ });
3689
+ expect((method as any).protocolV2StartFirmwareUpdate).toHaveBeenNthCalledWith(2, {
3641
3690
  targets: [
3642
- { target_id: 3, path: 'vol0:/bootloader.bin' },
3643
3691
  { target_id: 6, path: 'vol0:/coprocessor.bin' },
3644
3692
  { target_id: 7, path: 'vol0:/se01.bin' },
3645
3693
  { target_id: 4, path: 'vol0:/application_p1.bin' },
@@ -3649,7 +3697,7 @@ describe('Protocol V2 firmware update targets', () => {
3649
3697
  expect((method as any).waitForProtocolV2FirmwareUpdateComplete).toHaveBeenCalled();
3650
3698
  });
3651
3699
 
3652
- test('announces one transfer when syncing resource bundles and staging firmware', async () => {
3700
+ test('announces separate resource and component transfer phases', async () => {
3653
3701
  const method = new FirmwareUpdateV4({
3654
3702
  id: 1,
3655
3703
  payload: {
@@ -3659,11 +3707,14 @@ describe('Protocol V2 firmware update targets', () => {
3659
3707
 
3660
3708
  method.postTipMessage = jest.fn();
3661
3709
  method.postProgressMessage = jest.fn();
3662
- (method as any).protocolV2CommonUpdateProcess = jest
3710
+ (method as any).protocolV2SourceUpdateProcess = jest
3663
3711
  .fn()
3664
3712
  .mockImplementation(params =>
3665
- Promise.resolve(Number(params.processedSize ?? 0) + Number(params.payload.byteLength))
3713
+ Promise.resolve(Number(params.processedSize ?? 0) + Number(params.source.size))
3666
3714
  );
3715
+ (method as any).enterProtocolV2BootloaderMode = jest.fn().mockResolvedValue(undefined);
3716
+ (method as any).exitProtocolV2BootloaderToNormal = jest.fn().mockResolvedValue(undefined);
3717
+ (method as any).completeProtocolV2FinalVerification = jest.fn().mockResolvedValue({});
3667
3718
  (method as any).verifyProtocolV2StagedFile = jest.fn().mockResolvedValue(undefined);
3668
3719
  (method as any).protocolV2StartFirmwareUpdate = jest.fn().mockResolvedValue(undefined);
3669
3720
  (method as any).waitForProtocolV2FirmwareUpdateComplete = jest
@@ -3683,21 +3734,22 @@ describe('Protocol V2 firmware update targets', () => {
3683
3734
  {
3684
3735
  fileName: 'application_p1.bin',
3685
3736
  binary: new Uint8Array([3]).buffer,
3686
- targetId: 3,
3737
+ targetId: 4,
3687
3738
  },
3688
3739
  ],
3689
3740
  });
3690
3741
 
3691
- expect(method.postTipMessage).toHaveBeenCalledTimes(2);
3742
+ expect(method.postTipMessage).toHaveBeenCalledTimes(3);
3692
3743
  expect(method.postTipMessage).toHaveBeenNthCalledWith(1, 'StartTransferData');
3693
- expect(method.postTipMessage).toHaveBeenNthCalledWith(2, 'ConfirmOnDevice');
3694
- expect((method as any).protocolV2CommonUpdateProcess).toHaveBeenNthCalledWith(
3744
+ expect(method.postTipMessage).toHaveBeenNthCalledWith(2, 'StartTransferData');
3745
+ expect(method.postTipMessage).toHaveBeenNthCalledWith(3, 'ConfirmOnDevice');
3746
+ expect((method as any).protocolV2SourceUpdateProcess).toHaveBeenNthCalledWith(
3695
3747
  1,
3696
- expect.objectContaining({ processedSize: 0, totalSize: 3 })
3748
+ expect.objectContaining({ processedSize: 0, totalSize: 2 })
3697
3749
  );
3698
- expect((method as any).protocolV2CommonUpdateProcess).toHaveBeenNthCalledWith(
3750
+ expect((method as any).protocolV2SourceUpdateProcess).toHaveBeenNthCalledWith(
3699
3751
  2,
3700
- expect.objectContaining({ processedSize: 2, totalSize: 3 })
3752
+ expect.objectContaining({ processedSize: 0, totalSize: 1 })
3701
3753
  );
3702
3754
  });
3703
3755
 
@@ -3711,7 +3763,8 @@ describe('Protocol V2 firmware update targets', () => {
3711
3763
 
3712
3764
  method.postTipMessage = jest.fn();
3713
3765
  method.postProgressMessage = jest.fn();
3714
- (method as any).protocolV2CommonUpdateProcess = jest.fn().mockResolvedValue(3);
3766
+ (method as any).protocolV2SourceUpdateProcess = jest.fn().mockResolvedValue(3);
3767
+ (method as any).enterProtocolV2BootloaderMode = jest.fn().mockResolvedValue(undefined);
3715
3768
  (method as any).device = stubDevice({
3716
3769
  getCommands: () => ({
3717
3770
  typedCall: jest.fn().mockResolvedValue({
@@ -3757,11 +3810,14 @@ describe('Protocol V2 firmware update targets', () => {
3757
3810
 
3758
3811
  method.postTipMessage = jest.fn();
3759
3812
  method.postProgressMessage = jest.fn();
3760
- (method as any).protocolV2CommonUpdateProcess = jest
3813
+ (method as any).protocolV2SourceUpdateProcess = jest
3761
3814
  .fn()
3762
3815
  .mockImplementation(params =>
3763
- Promise.resolve(Number(params.processedSize ?? 0) + Number(params.payload.byteLength))
3816
+ Promise.resolve(Number(params.processedSize ?? 0) + Number(params.source.size))
3764
3817
  );
3818
+ (method as any).enterProtocolV2BootloaderMode = jest.fn().mockResolvedValue(undefined);
3819
+ (method as any).exitProtocolV2BootloaderToNormal = jest.fn().mockResolvedValue(undefined);
3820
+ (method as any).completeProtocolV2FinalVerification = jest.fn().mockResolvedValue({});
3765
3821
  (method as any).verifyProtocolV2StagedFile = jest.fn().mockResolvedValue(undefined);
3766
3822
  (method as any).protocolV2StartFirmwareUpdate = jest.fn().mockResolvedValue(undefined);
3767
3823
  (method as any).waitForProtocolV2FirmwareUpdateComplete = jest
@@ -4028,6 +4084,58 @@ describe('Protocol V2 firmware update targets', () => {
4028
4084
  getFirmwareLatestReleaseSpy.mockRestore();
4029
4085
  });
4030
4086
 
4087
+ test('rejects prepared RESC bundle paths before opening an artifact source', async () => {
4088
+ const method = new FirmwareUpdateV4({
4089
+ id: 1,
4090
+ payload: {
4091
+ method: 'firmwareUpdateV4',
4092
+ },
4093
+ });
4094
+ const openPreparedSource = jest.fn();
4095
+ (method as any).params = {
4096
+ targetsToUpdate: ['resource'],
4097
+ resourceBundleArtifacts: [
4098
+ {
4099
+ name: 'images',
4100
+ artifact: {
4101
+ artifactRef: `fw:${'a'.repeat(64)}`,
4102
+ size: 1,
4103
+ sha256: 'a'.repeat(64),
4104
+ },
4105
+ },
4106
+ ],
4107
+ };
4108
+ (method as any).openProtocolV2PreparedSource = openPreparedSource;
4109
+ const getFirmwareLatestReleaseSpy = jest
4110
+ .spyOn(DataManager, 'getFirmwareLatestRelease')
4111
+ .mockReturnValue({
4112
+ required: false,
4113
+ version: [1, 0, 0],
4114
+ url: '',
4115
+ resourceBundles: [
4116
+ {
4117
+ name: 'images',
4118
+ url: 'https://example.com/images.okpkg',
4119
+ devicePath: 'vol0:/resource/../images.okpkg',
4120
+ },
4121
+ ],
4122
+ fingerprint: '',
4123
+ changelog: {
4124
+ 'zh-CN': '',
4125
+ 'en-US': '',
4126
+ },
4127
+ });
4128
+
4129
+ await expect(
4130
+ (method as any).prepareProtocolV2ResourceSources('universal', {
4131
+ deviceType: 'pro2',
4132
+ })
4133
+ ).rejects.toThrow('resourceBundles[].devicePath');
4134
+ expect(openPreparedSource).not.toHaveBeenCalled();
4135
+
4136
+ getFirmwareLatestReleaseSpy.mockRestore();
4137
+ });
4138
+
4031
4139
  test('downloads and validates remote RESC bundles before entering bootloader', async () => {
4032
4140
  const method = new FirmwareUpdateV4({
4033
4141
  id: 1,
@@ -4080,7 +4188,9 @@ describe('Protocol V2 firmware update targets', () => {
4080
4188
  order.push('bootloader');
4081
4189
  return Promise.resolve(true);
4082
4190
  });
4083
- (method as any).executeProtocolV2Update = jest.fn().mockResolvedValue(undefined);
4191
+ const executeProtocolV2UpdateSpy = jest.spyOn(method as any, 'executeProtocolV2Update');
4192
+ (method as any).executeProtocolV2TransferPhase = jest.fn().mockResolvedValue(undefined);
4193
+ (method as any).completeProtocolV2FinalVerification = jest.fn().mockResolvedValue(undefined);
4084
4194
  (method as any).exitProtocolV2BootloaderToNormal = jest.fn().mockResolvedValue(undefined);
4085
4195
  (method as any).waitForProtocolV2FinalFeatures = jest.fn().mockResolvedValue({
4086
4196
  bootloaderVersion: '1.0.0',
@@ -4092,7 +4202,7 @@ describe('Protocol V2 firmware update targets', () => {
4092
4202
  await method.run();
4093
4203
 
4094
4204
  expect(order).toEqual(['download', 'bootloader']);
4095
- expect((method as any).executeProtocolV2Update).toHaveBeenCalledWith({
4205
+ expect(executeProtocolV2UpdateSpy).toHaveBeenCalledWith({
4096
4206
  bootloaderBinary: null,
4097
4207
  fwBinaryMap: [],
4098
4208
  resourceBundles: [
@@ -4105,6 +4215,7 @@ describe('Protocol V2 firmware update targets', () => {
4105
4215
  ],
4106
4216
  });
4107
4217
 
4218
+ executeProtocolV2UpdateSpy.mockRestore();
4108
4219
  getSysResourceBinarySpy.mockRestore();
4109
4220
  getFirmwareLatestReleaseSpy.mockRestore();
4110
4221
  });
@@ -4393,7 +4504,10 @@ describe('Protocol V2 firmware update targets', () => {
4393
4504
 
4394
4505
  method.postTipMessage = jest.fn();
4395
4506
  method.postProgressMessage = jest.fn();
4396
- (method as any).protocolV2CommonUpdateProcess = jest.fn().mockResolvedValue(3);
4507
+ (method as any).protocolV2SourceUpdateProcess = jest.fn().mockResolvedValue(3);
4508
+ (method as any).enterProtocolV2BootloaderMode = jest.fn().mockResolvedValue(undefined);
4509
+ (method as any).completeProtocolV2FinalVerification = jest.fn().mockResolvedValue({});
4510
+ (method as any).verifyProtocolV2StagedFile = jest.fn().mockResolvedValue(undefined);
4397
4511
  (method as any).protocolV2StartFirmwareUpdate = jest.fn();
4398
4512
  (method as any).waitForProtocolV2FirmwareUpdateComplete = jest.fn();
4399
4513
 
@@ -4409,7 +4523,7 @@ describe('Protocol V2 firmware update targets', () => {
4409
4523
  fwBinaryMap: [],
4410
4524
  });
4411
4525
 
4412
- expect((method as any).protocolV2CommonUpdateProcess).toHaveBeenCalledTimes(1);
4526
+ expect((method as any).protocolV2SourceUpdateProcess).toHaveBeenCalledTimes(1);
4413
4527
  expect((method as any).protocolV2StartFirmwareUpdate).not.toHaveBeenCalled();
4414
4528
  expect((method as any).waitForProtocolV2FirmwareUpdateComplete).not.toHaveBeenCalled();
4415
4529
  });
@@ -4440,12 +4554,19 @@ describe('Protocol V2 firmware update targets', () => {
4440
4554
  });
4441
4555
  method.postProgressMessage = jest.fn();
4442
4556
 
4443
- await (method as any).protocolV2CommonUpdateProcess({
4444
- payload: new Uint8Array(4097).buffer,
4445
- filePath: 'vol1:firmware.bin',
4446
- processedSize: 0,
4447
- totalSize: 4097,
4557
+ const source = await openFirmwareByteSource({
4558
+ binary: new Uint8Array(4097).buffer,
4448
4559
  });
4560
+ try {
4561
+ await (method as any).protocolV2SourceUpdateProcess({
4562
+ source,
4563
+ filePath: 'vol1:firmware.bin',
4564
+ processedSize: 0,
4565
+ totalSize: 4097,
4566
+ });
4567
+ } finally {
4568
+ await source?.close();
4569
+ }
4449
4570
 
4450
4571
  const writePayloads = typedCall.mock.calls.map(call => call[2]);
4451
4572
  expect(writePayloads.map(payload => payload.file.offset)).toEqual([0, 4000]);
@@ -4496,12 +4617,16 @@ describe('Protocol V2 firmware update targets', () => {
4496
4617
  method.postProgressMessage = jest.fn();
4497
4618
 
4498
4619
  try {
4499
- await (method as any).protocolV2CommonUpdateProcess({
4500
- payload: new Uint8Array(8001).buffer,
4620
+ const source = await openFirmwareByteSource({
4621
+ binary: new Uint8Array(8001).buffer,
4622
+ });
4623
+ await (method as any).protocolV2SourceUpdateProcess({
4624
+ source,
4501
4625
  filePath: 'vol0:/firmware.bin',
4502
4626
  processedSize: 0,
4503
4627
  totalSize: 8001,
4504
4628
  });
4629
+ await source?.close();
4505
4630
  } finally {
4506
4631
  setTimeoutSpy.mockRestore();
4507
4632
  }
@@ -4533,16 +4658,21 @@ describe('Protocol V2 firmware update targets', () => {
4533
4658
  });
4534
4659
  method.postProgressMessage = jest.fn();
4535
4660
  method.postTipMessage = jest.fn();
4661
+ (method as any).recoverProtocolV2FileTransfer = jest.fn().mockResolvedValue(undefined);
4536
4662
 
4663
+ const source = await openFirmwareByteSource({
4664
+ binary: new Uint8Array(4097).buffer,
4665
+ });
4537
4666
  await expect(
4538
- (method as any).protocolV2WriteWholeFile({
4539
- payload: new Uint8Array(4097).buffer,
4667
+ (method as any).protocolV2SourceUpdateProcess({
4668
+ source,
4540
4669
  filePath: 'vol0:/firmware.bin',
4541
4670
  processedSize: 0,
4542
4671
  totalSize: 4097,
4543
4672
  })
4544
4673
  ).rejects.toMatchObject({ errorCode: HardwareErrorCode.EmmcFileWriteFirmwareError });
4545
- expect(typedCall).toHaveBeenCalledTimes(2);
4674
+ await source?.close();
4675
+ expect(typedCall).toHaveBeenCalledTimes(6);
4546
4676
  });
4547
4677
 
4548
4678
  test('caps native BLE firmware upload chunks below the WebUSB limit', async () => {
@@ -4575,12 +4705,19 @@ describe('Protocol V2 firmware update targets', () => {
4575
4705
  });
4576
4706
  method.postProgressMessage = jest.fn();
4577
4707
 
4578
- await (method as any).protocolV2CommonUpdateProcess({
4579
- payload: new Uint8Array(1801).buffer,
4580
- filePath: 'vol1:ble-firmware.bin',
4581
- processedSize: 0,
4582
- totalSize: 1801,
4708
+ const source = await openFirmwareByteSource({
4709
+ binary: new Uint8Array(1801).buffer,
4583
4710
  });
4711
+ try {
4712
+ await (method as any).protocolV2SourceUpdateProcess({
4713
+ source,
4714
+ filePath: 'vol1:ble-firmware.bin',
4715
+ processedSize: 0,
4716
+ totalSize: 1801,
4717
+ });
4718
+ } finally {
4719
+ await source?.close();
4720
+ }
4584
4721
 
4585
4722
  const writePayloads = typedCall.mock.calls.map(call => call[2]);
4586
4723
  expect(writePayloads.map(payload => payload.file.offset)).toEqual([0, 1800]);
@@ -4697,9 +4834,9 @@ describe('Protocol V2 firmware update method', () => {
4697
4834
  const typedCall = jest
4698
4835
  .fn()
4699
4836
  .mockRejectedValue(
4700
- new DOMException(
4701
- "Failed to execute 'open' on 'USBDevice': The device was disconnected",
4702
- 'NotFoundError'
4837
+ Object.assign(
4838
+ new Error("Failed to execute 'open' on 'USBDevice': The device was disconnected"),
4839
+ { name: 'NotFoundError' }
4703
4840
  )
4704
4841
  );
4705
4842
 
@@ -4864,6 +5001,21 @@ describe('Protocol V2 firmware update method', () => {
4864
5001
  });
4865
5002
 
4866
5003
  describe('Protocol V2 firmware reconnect identity', () => {
5004
+ test('keeps the host plan identity as the V4 reconnect anchor', () => {
5005
+ const method = new FirmwareUpdateV4({
5006
+ id: 1,
5007
+ payload: {
5008
+ method: 'firmwareUpdateV4',
5009
+ platform: 'native',
5010
+ expectedDeviceId: 'persisted-device-id',
5011
+ },
5012
+ });
5013
+
5014
+ method.init();
5015
+
5016
+ expect((method as any).params.expectedDeviceId).toBe('persisted-device-id');
5017
+ });
5018
+
4867
5019
  test('rejects a different physical serial before firmware transfer resumes', () => {
4868
5020
  expect(() => assertProtocolV2ReconnectIdentity('expected-serial', 'other-serial')).toThrow(
4869
5021
  'identity mismatch'
@@ -5779,7 +5931,7 @@ describe('Protocol V2 raw device info method', () => {
5779
5931
  );
5780
5932
  });
5781
5933
 
5782
- test('rejects on Protocol V1 devices instead of sending an unknown message', async () => {
5934
+ test('rejects on Protocol V1 devices instead of sending an unknown message', () => {
5783
5935
  const method = buildMethod();
5784
5936
  const typedCall = jest.fn();
5785
5937
  (method as any).device = stubDevice({
@@ -5787,7 +5939,9 @@ describe('Protocol V2 raw device info method', () => {
5787
5939
  commands: { typedCall },
5788
5940
  });
5789
5941
 
5790
- await expect(method.run()).rejects.toThrow();
5942
+ expect(() => method.assertProtocolSupported('V1', EFirmwareType.Universal)).toThrow(
5943
+ expect.objectContaining({ errorCode: HardwareErrorCode.DeviceNotSupportMethod })
5944
+ );
5791
5945
  expect(typedCall).not.toHaveBeenCalled();
5792
5946
  });
5793
5947
  });