@onekeyfe/hd-core 1.2.0-alpha.2 → 1.2.0-alpha.21

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 (406) hide show
  1. package/__tests__/AllNetworkGetAddressBase.tracing.test.ts +75 -0
  2. package/__tests__/DeviceCommands.test.ts +285 -0
  3. package/__tests__/DeviceEventRegistration.test.ts +43 -0
  4. package/__tests__/connectSettings.test.ts +19 -0
  5. package/__tests__/core-dispose.test.ts +34 -0
  6. package/__tests__/core-error-output.test.ts +39 -0
  7. package/__tests__/device-features-state.test.ts +78 -0
  8. package/__tests__/device-identity.test.ts +30 -0
  9. package/__tests__/device-lifecycle-events.test.ts +117 -0
  10. package/__tests__/device-pool-state.test.ts +132 -0
  11. package/__tests__/device-settings.test.ts +391 -0
  12. package/__tests__/device-state-contract.test.ts +27 -0
  13. package/__tests__/device-state-events.test.ts +162 -0
  14. package/__tests__/device-state-mapper.test.ts +241 -0
  15. package/__tests__/device-state-projector.test.ts +94 -0
  16. package/__tests__/device-state-store.test.ts +82 -0
  17. package/__tests__/device-utils.test.ts +106 -0
  18. package/__tests__/device-wallet-session-store.test.ts +213 -0
  19. package/__tests__/deviceFeaturesUtils.test.ts +39 -0
  20. package/__tests__/deviceSettings.test.ts +103 -0
  21. package/__tests__/evmLedgerLegacySafety.test.ts +10 -6
  22. package/__tests__/evmSignTypedData.test.ts +80 -0
  23. package/__tests__/filesystemValidation.test.ts +53 -0
  24. package/__tests__/firmware-update/firmware-update-v2-download-before-boot.test.ts +402 -0
  25. package/__tests__/get-device-state.test.ts +410 -0
  26. package/__tests__/homescreen.test.ts +24 -0
  27. package/__tests__/kaspaSignTransaction.test.ts +591 -0
  28. package/__tests__/logBlockEvent.test.ts +26 -0
  29. package/__tests__/networkUtils.test.ts +386 -0
  30. package/__tests__/open-wallet-session-error-response.test.ts +43 -0
  31. package/__tests__/open-wallet-session.test.ts +559 -0
  32. package/__tests__/preInitialize.test.ts +33 -0
  33. package/__tests__/pro2Wallpaper.test.ts +50 -0
  34. package/__tests__/protocol-v2-bootloader-mode.test.ts +37 -0
  35. package/__tests__/protocol-v2-firmware-targets.test.ts +19 -0
  36. package/__tests__/protocol-v2.test.ts +3954 -1191
  37. package/__tests__/protocolV2FileWrite.test.ts +92 -0
  38. package/__tests__/protocolV2UiInteraction.test.ts +266 -0
  39. package/__tests__/public-device-state-api.test.ts +257 -0
  40. package/__tests__/public-pro2-api-boundary.test.ts +110 -0
  41. package/__tests__/refresh-device-state.test.ts +101 -0
  42. package/__tests__/request-context-logging.test.ts +16 -0
  43. package/__tests__/search-devices.test.ts +136 -0
  44. package/dist/api/BaseMethod.d.ts +8 -0
  45. package/dist/api/BaseMethod.d.ts.map +1 -1
  46. package/dist/api/CheckBootloaderRelease.d.ts.map +1 -1
  47. package/dist/api/CheckFirmwareRelease.d.ts.map +1 -1
  48. package/dist/api/ClearSessionCache.d.ts +9 -0
  49. package/dist/api/ClearSessionCache.d.ts.map +1 -0
  50. package/dist/api/DirList.d.ts.map +1 -1
  51. package/dist/api/FileRead.d.ts.map +1 -1
  52. package/dist/api/FileWrite.d.ts +1 -0
  53. package/dist/api/FileWrite.d.ts.map +1 -1
  54. package/dist/api/FirmwareUpdateV2.d.ts +2 -2
  55. package/dist/api/FirmwareUpdateV2.d.ts.map +1 -1
  56. package/dist/api/FirmwareUpdateV3.d.ts.map +1 -1
  57. package/dist/api/FirmwareUpdateV4.d.ts +25 -5
  58. package/dist/api/FirmwareUpdateV4.d.ts.map +1 -1
  59. package/dist/api/GetDeviceState.d.ts +7 -0
  60. package/dist/api/GetDeviceState.d.ts.map +1 -0
  61. package/dist/api/GetFeatures.d.ts +1 -1
  62. package/dist/api/GetFeatures.d.ts.map +1 -1
  63. package/dist/api/GetOnekeyFeatures.d.ts.map +1 -1
  64. package/dist/api/GetPassphraseState.d.ts +1 -6
  65. package/dist/api/GetPassphraseState.d.ts.map +1 -1
  66. package/dist/api/OpenWalletSession.d.ts +14 -0
  67. package/dist/api/OpenWalletSession.d.ts.map +1 -0
  68. package/dist/api/PathInfo.d.ts.map +1 -1
  69. package/dist/api/PromptWebDeviceAccess.d.ts.map +1 -1
  70. package/dist/api/SearchDevices.d.ts +3 -0
  71. package/dist/api/SearchDevices.d.ts.map +1 -1
  72. package/dist/api/UploadPortfolio.d.ts +17 -0
  73. package/dist/api/UploadPortfolio.d.ts.map +1 -0
  74. package/dist/api/allnetwork/AllNetworkGetAddressBase.d.ts.map +1 -1
  75. package/dist/api/device/DeviceCancel.d.ts.map +1 -1
  76. package/dist/api/device/DeviceChangePin.d.ts.map +1 -1
  77. package/dist/api/device/DeviceFullyUploadResource.d.ts +1 -2
  78. package/dist/api/device/DeviceFullyUploadResource.d.ts.map +1 -1
  79. package/dist/api/device/DeviceLock.d.ts.map +1 -1
  80. package/dist/api/device/DeviceRebootToBoardloader.d.ts.map +1 -1
  81. package/dist/api/device/DeviceRebootToBootloader.d.ts.map +1 -1
  82. package/dist/api/device/DeviceSettings.d.ts.map +1 -1
  83. package/dist/api/device/DeviceUnlock.d.ts +1 -1
  84. package/dist/api/device/DeviceUnlock.d.ts.map +1 -1
  85. package/dist/api/device/DeviceUpdateBootloader.d.ts.map +1 -1
  86. package/dist/api/device/DeviceWipe.d.ts.map +1 -1
  87. package/dist/api/evm/EVMSignTypedData.d.ts.map +1 -1
  88. package/dist/api/firmware/FirmwareUpdateBaseMethod.d.ts +1 -0
  89. package/dist/api/firmware/FirmwareUpdateBaseMethod.d.ts.map +1 -1
  90. package/dist/api/firmware/getBinary.d.ts +11 -3
  91. package/dist/api/firmware/getBinary.d.ts.map +1 -1
  92. package/dist/api/firmware/progressThrottle.d.ts +3 -0
  93. package/dist/api/firmware/progressThrottle.d.ts.map +1 -0
  94. package/dist/api/helpers/filesystemValidation.d.ts +3 -0
  95. package/dist/api/helpers/filesystemValidation.d.ts.map +1 -1
  96. package/dist/api/helpers/paramsValidator.d.ts +1 -0
  97. package/dist/api/helpers/paramsValidator.d.ts.map +1 -1
  98. package/dist/api/helpers/protocolV2FileWrite.d.ts +33 -0
  99. package/dist/api/helpers/protocolV2FileWrite.d.ts.map +1 -0
  100. package/dist/api/index.d.ts +12 -19
  101. package/dist/api/index.d.ts.map +1 -1
  102. package/dist/api/kaspa/KaspaSignTransaction.d.ts +5 -1
  103. package/dist/api/kaspa/KaspaSignTransaction.d.ts.map +1 -1
  104. package/dist/api/kaspa/helpers/TransferSerialize.d.ts.map +1 -1
  105. package/dist/api/protocol-v2/DeviceFactoryInfoGet.d.ts +6 -0
  106. package/dist/api/protocol-v2/DeviceFactoryInfoGet.d.ts.map +1 -0
  107. package/dist/api/protocol-v2/DeviceFactoryInfoSet.d.ts +7 -0
  108. package/dist/api/protocol-v2/DeviceFactoryInfoSet.d.ts.map +1 -0
  109. package/dist/api/protocol-v2/DeviceFirmwareUpdate.d.ts +1 -1
  110. package/dist/api/protocol-v2/DeviceFirmwareUpdate.d.ts.map +1 -1
  111. package/dist/api/protocol-v2/DeviceGetFirmwareUpdateStatus.d.ts +3 -2
  112. package/dist/api/protocol-v2/DeviceGetFirmwareUpdateStatus.d.ts.map +1 -1
  113. package/dist/api/protocol-v2/DeviceGetOnboardingStatus.d.ts +1 -1
  114. package/dist/api/protocol-v2/DeviceGetOnboardingStatus.d.ts.map +1 -1
  115. package/dist/api/protocol-v2/DeviceInfoGet.d.ts +28 -0
  116. package/dist/api/protocol-v2/DeviceInfoGet.d.ts.map +1 -0
  117. package/dist/api/protocol-v2/DeviceReboot.d.ts.map +1 -1
  118. package/dist/api/protocol-v2/DeviceStatusGet.d.ts +6 -0
  119. package/dist/api/protocol-v2/DeviceStatusGet.d.ts.map +1 -0
  120. package/dist/api/protocol-v2/DeviceUploadWallpaper.d.ts +26 -0
  121. package/dist/api/protocol-v2/DeviceUploadWallpaper.d.ts.map +1 -0
  122. package/dist/api/protocol-v2/FilesystemFormat.d.ts.map +1 -1
  123. package/dist/api/protocol-v2/{FilesystemFixPermission.d.ts → FilesystemPermissionFix.d.ts} +2 -2
  124. package/dist/api/protocol-v2/FilesystemPermissionFix.d.ts.map +1 -0
  125. package/dist/api/protocol-v2/ProtocolInfoRequest.d.ts +6 -0
  126. package/dist/api/protocol-v2/ProtocolInfoRequest.d.ts.map +1 -0
  127. package/dist/api/protocol-v2/helpers.d.ts +27 -19
  128. package/dist/api/protocol-v2/helpers.d.ts.map +1 -1
  129. package/dist/api/ton/TonSignData.d.ts +1 -5
  130. package/dist/api/ton/TonSignData.d.ts.map +1 -1
  131. package/dist/api/utils.d.ts +2 -1
  132. package/dist/api/utils.d.ts.map +1 -1
  133. package/dist/constants/index.d.ts +2 -1
  134. package/dist/constants/index.d.ts.map +1 -1
  135. package/dist/core/RequestQueue.d.ts.map +1 -1
  136. package/dist/core/deviceEventRegistration.d.ts +11 -0
  137. package/dist/core/deviceEventRegistration.d.ts.map +1 -0
  138. package/dist/core/index.d.ts +3 -1
  139. package/dist/core/index.d.ts.map +1 -1
  140. package/dist/data-manager/DataManager.d.ts +1 -1
  141. package/dist/data-manager/DataManager.d.ts.map +1 -1
  142. package/dist/data-manager/connectSettings.d.ts.map +1 -1
  143. package/dist/device/Device.d.ts +35 -11
  144. package/dist/device/Device.d.ts.map +1 -1
  145. package/dist/device/DeviceCommands.d.ts +8 -6
  146. package/dist/device/DeviceCommands.d.ts.map +1 -1
  147. package/dist/device/DeviceFeaturesState.d.ts +3 -0
  148. package/dist/device/DeviceFeaturesState.d.ts.map +1 -0
  149. package/dist/device/DevicePool.d.ts +4 -2
  150. package/dist/device/DevicePool.d.ts.map +1 -1
  151. package/dist/device/DeviceStateMapper.d.ts +13 -0
  152. package/dist/device/DeviceStateMapper.d.ts.map +1 -0
  153. package/dist/device/DeviceStateProjector.d.ts +7 -0
  154. package/dist/device/DeviceStateProjector.d.ts.map +1 -0
  155. package/dist/device/DeviceStateStore.d.ts +21 -0
  156. package/dist/device/DeviceStateStore.d.ts.map +1 -0
  157. package/dist/device/DeviceWalletSessionStore.d.ts +20 -0
  158. package/dist/device/DeviceWalletSessionStore.d.ts.map +1 -0
  159. package/dist/device/cloneDeviceState.d.ts +2 -0
  160. package/dist/device/cloneDeviceState.d.ts.map +1 -0
  161. package/dist/device/deviceIdentity.d.ts +5 -0
  162. package/dist/device/deviceIdentity.d.ts.map +1 -0
  163. package/dist/deviceProfile/buildDeviceFeatures.d.ts +9 -3
  164. package/dist/deviceProfile/buildDeviceFeatures.d.ts.map +1 -1
  165. package/dist/deviceProfile/index.d.ts +0 -1
  166. package/dist/deviceProfile/index.d.ts.map +1 -1
  167. package/dist/events/device.d.ts +11 -2
  168. package/dist/events/device.d.ts.map +1 -1
  169. package/dist/events/logBlockEvent.d.ts.map +1 -1
  170. package/dist/events/ui-request.d.ts +18 -2
  171. package/dist/events/ui-request.d.ts.map +1 -1
  172. package/dist/index.d.ts +1361 -609
  173. package/dist/index.js +5898 -2860
  174. package/dist/inject.d.ts.map +1 -1
  175. package/dist/protocols/protocol-v2/deviceSession.d.ts +7 -0
  176. package/dist/protocols/protocol-v2/deviceSession.d.ts.map +1 -0
  177. package/dist/protocols/protocol-v2/features.d.ts +23 -28
  178. package/dist/protocols/protocol-v2/features.d.ts.map +1 -1
  179. package/dist/protocols/protocol-v2/firmware.d.ts +11 -9
  180. package/dist/protocols/protocol-v2/firmware.d.ts.map +1 -1
  181. package/dist/protocols/protocol-v2/index.d.ts +3 -2
  182. package/dist/protocols/protocol-v2/index.d.ts.map +1 -1
  183. package/dist/protocols/protocol-v2/lockedError.d.ts +2 -0
  184. package/dist/protocols/protocol-v2/lockedError.d.ts.map +1 -0
  185. package/dist/protocols/protocol-v2/settingsUnlockPolicy.d.ts +16 -0
  186. package/dist/protocols/protocol-v2/settingsUnlockPolicy.d.ts.map +1 -0
  187. package/dist/protocols/protocol-v2/uiInteraction.d.ts +39 -0
  188. package/dist/protocols/protocol-v2/uiInteraction.d.ts.map +1 -0
  189. package/dist/protocols/protocol-v2/unlockRetry.d.ts +11 -0
  190. package/dist/protocols/protocol-v2/unlockRetry.d.ts.map +1 -0
  191. package/dist/protocols/protocol-v2/walletSession.d.ts +19 -0
  192. package/dist/protocols/protocol-v2/walletSession.d.ts.map +1 -0
  193. package/dist/types/api/checkAllFirmwareRelease.d.ts +1 -2
  194. package/dist/types/api/checkAllFirmwareRelease.d.ts.map +1 -1
  195. package/dist/types/api/deviceSettings.d.ts +11 -2
  196. package/dist/types/api/deviceSettings.d.ts.map +1 -1
  197. package/dist/types/api/deviceUnlock.d.ts +2 -2
  198. package/dist/types/api/deviceUnlock.d.ts.map +1 -1
  199. package/dist/types/api/firmwareUpdate.d.ts +6 -6
  200. package/dist/types/api/firmwareUpdate.d.ts.map +1 -1
  201. package/dist/types/api/getDeviceState.d.ts +12 -0
  202. package/dist/types/api/getDeviceState.d.ts.map +1 -0
  203. package/dist/types/api/getFeatures.d.ts.map +1 -1
  204. package/dist/types/api/getOnekeyFeatures.d.ts.map +1 -1
  205. package/dist/types/api/getPassphraseState.d.ts +2 -10
  206. package/dist/types/api/getPassphraseState.d.ts.map +1 -1
  207. package/dist/types/api/index.d.ts +22 -25
  208. package/dist/types/api/index.d.ts.map +1 -1
  209. package/dist/types/api/kaspaSignTransaction.d.ts +27 -2
  210. package/dist/types/api/kaspaSignTransaction.d.ts.map +1 -1
  211. package/dist/types/api/openWalletSession.d.ts +41 -0
  212. package/dist/types/api/openWalletSession.d.ts.map +1 -0
  213. package/dist/types/api/protocolV2.d.ts +23 -28
  214. package/dist/types/api/protocolV2.d.ts.map +1 -1
  215. package/dist/types/api/sessionCache.d.ts +10 -0
  216. package/dist/types/api/sessionCache.d.ts.map +1 -0
  217. package/dist/types/device.d.ts +121 -5
  218. package/dist/types/device.d.ts.map +1 -1
  219. package/dist/types/params.d.ts +1 -0
  220. package/dist/types/params.d.ts.map +1 -1
  221. package/dist/types/settings.d.ts +21 -1
  222. package/dist/types/settings.d.ts.map +1 -1
  223. package/dist/utils/assets.d.ts +2 -1
  224. package/dist/utils/assets.d.ts.map +1 -1
  225. package/dist/utils/deviceFeaturesCompat.d.ts +13 -0
  226. package/dist/utils/deviceFeaturesCompat.d.ts.map +1 -0
  227. package/dist/utils/deviceFeaturesUtils.d.ts +13 -3
  228. package/dist/utils/deviceFeaturesUtils.d.ts.map +1 -1
  229. package/dist/utils/deviceInfoUtils.d.ts +9 -8
  230. package/dist/utils/deviceInfoUtils.d.ts.map +1 -1
  231. package/dist/utils/deviceSettings.d.ts +38 -7
  232. package/dist/utils/deviceSettings.d.ts.map +1 -1
  233. package/dist/utils/deviceVersionUtils.d.ts +6 -5
  234. package/dist/utils/deviceVersionUtils.d.ts.map +1 -1
  235. package/dist/utils/homescreen.d.ts.map +1 -1
  236. package/dist/utils/index.d.ts +5 -2
  237. package/dist/utils/index.d.ts.map +1 -1
  238. package/dist/utils/networkUtils.d.ts +9 -1
  239. package/dist/utils/networkUtils.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/dist/utils/pro2Wallpaper.d.ts +12 -0
  243. package/dist/utils/pro2Wallpaper.d.ts.map +1 -0
  244. package/dist/utils/tracing.d.ts.map +1 -1
  245. package/package.json +4 -4
  246. package/src/api/BaseMethod.ts +36 -9
  247. package/src/api/CheckBootloaderRelease.ts +1 -2
  248. package/src/api/CheckFirmwareRelease.ts +1 -2
  249. package/src/api/ClearSessionCache.ts +28 -0
  250. package/src/api/DirList.ts +5 -3
  251. package/src/api/DirMake.ts +3 -3
  252. package/src/api/DirRemove.ts +3 -3
  253. package/src/api/FileDelete.ts +3 -3
  254. package/src/api/FileRead.ts +23 -7
  255. package/src/api/FileWrite.ts +23 -168
  256. package/src/api/FirmwareUpdate.ts +4 -4
  257. package/src/api/FirmwareUpdateV2.ts +133 -45
  258. package/src/api/FirmwareUpdateV3.ts +3 -5
  259. package/src/api/FirmwareUpdateV4.ts +1138 -357
  260. package/src/api/GetDeviceState.ts +55 -0
  261. package/src/api/GetFeatures.ts +8 -3
  262. package/src/api/GetOnekeyFeatures.ts +3 -72
  263. package/src/api/GetPassphraseState.ts +11 -18
  264. package/src/api/OpenWalletSession.ts +221 -0
  265. package/src/api/PathInfo.ts +5 -3
  266. package/src/api/PromptWebDeviceAccess.ts +2 -3
  267. package/src/api/SearchDevices.ts +29 -4
  268. package/src/api/UploadPortfolio.ts +40 -0
  269. package/src/api/alephium/AlephiumSignTransaction.ts +2 -2
  270. package/src/api/allnetwork/AllNetworkGetAddressBase.ts +4 -8
  271. package/src/api/benfen/BenfenGetAddress.ts +1 -1
  272. package/src/api/btc/BTCGetPublicKey.ts +1 -1
  273. package/src/api/cardano/CardanoSignMessage.ts +1 -1
  274. package/src/api/cardano/CardanoSignTransaction.ts +1 -1
  275. package/src/api/device/DeviceCancel.ts +1 -0
  276. package/src/api/device/DeviceChangePin.ts +24 -0
  277. package/src/api/device/DeviceFullyUploadResource.ts +4 -5
  278. package/src/api/device/DeviceLock.ts +1 -0
  279. package/src/api/device/DeviceRebootToBoardloader.ts +5 -4
  280. package/src/api/device/DeviceRebootToBootloader.ts +5 -4
  281. package/src/api/device/DeviceSettings.ts +183 -1
  282. package/src/api/device/DeviceUnlock.ts +11 -1
  283. package/src/api/device/DeviceUpdateBootloader.ts +1 -2
  284. package/src/api/device/DeviceWipe.ts +19 -0
  285. package/src/api/evm/EVMSignTypedData.ts +3 -5
  286. package/src/api/evm/legacyV1/getAddress.ts +2 -2
  287. package/src/api/evm/legacyV1/getPublicKey.ts +2 -2
  288. package/src/api/evm/legacyV1/signMessage.ts +2 -2
  289. package/src/api/evm/legacyV1/signTypedData.ts +2 -2
  290. package/src/api/evm/legacyV1/signTypedHash.ts +2 -2
  291. package/src/api/evm/legacyV1/verifyMessage.ts +2 -2
  292. package/src/api/firmware/FirmwareUpdateBaseMethod.ts +21 -7
  293. package/src/api/firmware/getBinary.ts +8 -3
  294. package/src/api/firmware/progressThrottle.ts +44 -0
  295. package/src/api/helpers/batchGetPublickeys.ts +2 -2
  296. package/src/api/helpers/filesystemValidation.ts +61 -0
  297. package/src/api/helpers/paramsValidator.ts +1 -1
  298. package/src/api/helpers/protocolV2FileWrite.ts +193 -0
  299. package/src/api/index.ts +14 -20
  300. package/src/api/kaspa/KaspaSignTransaction.ts +341 -22
  301. package/src/api/kaspa/helpers/TransferSerialize.ts +14 -0
  302. package/src/api/nervos/NervosSignTransaction.ts +2 -2
  303. package/src/api/nexa/NexaSignTransaction.ts +1 -1
  304. package/src/api/protocol-v2/{FactoryGetDeviceInfo.ts → DeviceFactoryInfoGet.ts} +4 -4
  305. package/src/api/protocol-v2/DeviceFactoryInfoSet.ts +32 -0
  306. package/src/api/protocol-v2/DeviceFirmwareUpdate.ts +7 -9
  307. package/src/api/protocol-v2/DeviceGetFirmwareUpdateStatus.ts +41 -6
  308. package/src/api/protocol-v2/DeviceGetOnboardingStatus.ts +6 -4
  309. package/src/api/protocol-v2/DeviceInfoGet.ts +145 -0
  310. package/src/api/protocol-v2/DeviceReboot.ts +5 -3
  311. package/src/api/protocol-v2/DeviceStatusGet.ts +16 -0
  312. package/src/api/protocol-v2/DeviceUploadWallpaper.ts +131 -0
  313. package/src/api/protocol-v2/FilesystemFormat.ts +5 -2
  314. package/src/api/protocol-v2/{FilesystemFixPermission.ts → FilesystemPermissionFix.ts} +3 -3
  315. package/src/api/protocol-v2/Ping.ts +1 -1
  316. package/src/api/protocol-v2/{GetProtoVersion.ts → ProtocolInfoRequest.ts} +3 -3
  317. package/src/api/protocol-v2/helpers.ts +58 -62
  318. package/src/api/ton/TonSignData.ts +1 -5
  319. package/src/api/utils.ts +7 -3
  320. package/src/constants/index.ts +7 -1
  321. package/src/core/RequestQueue.ts +1 -0
  322. package/src/core/deviceEventRegistration.ts +23 -0
  323. package/src/core/index.ts +140 -35
  324. package/src/data/messages/messages-protocol-v2.json +825 -709
  325. package/src/data/messages/messages.json +286 -1
  326. package/src/data-manager/DataManager.ts +13 -6
  327. package/src/data-manager/connectSettings.ts +4 -0
  328. package/src/device/Device.ts +480 -192
  329. package/src/device/DeviceCommands.ts +81 -25
  330. package/src/device/DeviceFeaturesState.ts +25 -0
  331. package/src/device/DevicePool.ts +67 -19
  332. package/src/device/DeviceStateMapper.ts +349 -0
  333. package/src/device/DeviceStateProjector.ts +95 -0
  334. package/src/device/DeviceStateStore.ts +201 -0
  335. package/src/device/DeviceWalletSessionStore.ts +105 -0
  336. package/src/device/cloneDeviceState.ts +39 -0
  337. package/src/device/deviceIdentity.ts +18 -0
  338. package/src/deviceProfile/buildDeviceFeatures.ts +235 -210
  339. package/src/deviceProfile/index.ts +0 -1
  340. package/src/events/device.ts +17 -1
  341. package/src/events/logBlockEvent.ts +8 -1
  342. package/src/events/ui-request.ts +24 -2
  343. package/src/inject.ts +23 -34
  344. package/src/protocols/protocol-v2/deviceSession.ts +24 -0
  345. package/src/protocols/protocol-v2/features.ts +68 -82
  346. package/src/protocols/protocol-v2/firmware.ts +12 -36
  347. package/src/protocols/protocol-v2/index.ts +3 -1
  348. package/src/protocols/protocol-v2/lockedError.ts +10 -0
  349. package/src/protocols/protocol-v2/settingsUnlockPolicy.ts +61 -0
  350. package/src/protocols/protocol-v2/uiInteraction.ts +210 -0
  351. package/src/protocols/protocol-v2/unlockRetry.ts +76 -0
  352. package/src/protocols/protocol-v2/walletSession.ts +107 -0
  353. package/src/types/api/checkAllFirmwareRelease.ts +1 -2
  354. package/src/types/api/deviceSettings.ts +26 -2
  355. package/src/types/api/deviceUnlock.ts +5 -2
  356. package/src/types/api/firmwareUpdate.ts +28 -20
  357. package/src/types/api/getDeviceState.ts +19 -0
  358. package/src/types/api/getFeatures.ts +3 -0
  359. package/src/types/api/getOnekeyFeatures.ts +3 -0
  360. package/src/types/api/getPassphraseState.ts +8 -11
  361. package/src/types/api/index.ts +30 -53
  362. package/src/types/api/kaspaSignTransaction.ts +40 -2
  363. package/src/types/api/openWalletSession.ts +64 -0
  364. package/src/types/api/protocolV2.ts +58 -55
  365. package/src/types/api/sessionCache.ts +14 -0
  366. package/src/types/device.ts +170 -4
  367. package/src/types/params.ts +4 -0
  368. package/src/types/settings.ts +42 -30
  369. package/src/utils/assets.ts +4 -1
  370. package/src/utils/deviceFeaturesCompat.ts +173 -0
  371. package/src/utils/deviceFeaturesUtils.ts +68 -24
  372. package/src/utils/deviceInfoUtils.ts +26 -64
  373. package/src/utils/deviceSettings.ts +161 -39
  374. package/src/utils/deviceVersionUtils.ts +25 -44
  375. package/src/utils/findDefectiveBatchDevice.ts +3 -3
  376. package/src/utils/homescreen.ts +10 -0
  377. package/src/utils/index.ts +21 -1
  378. package/src/utils/networkUtils.ts +270 -14
  379. package/src/utils/pro2Wallpaper.ts +109 -0
  380. package/src/utils/tracing.ts +3 -1
  381. package/dist/api/GetDeviceInfo.d.ts +0 -9
  382. package/dist/api/GetDeviceInfo.d.ts.map +0 -1
  383. package/dist/api/protocol-v2/DevReboot.d.ts +0 -7
  384. package/dist/api/protocol-v2/DevReboot.d.ts.map +0 -1
  385. package/dist/api/protocol-v2/DeviceGetDeviceInfo.d.ts +0 -29
  386. package/dist/api/protocol-v2/DeviceGetDeviceInfo.d.ts.map +0 -1
  387. package/dist/api/protocol-v2/FactoryDeviceInfoSettings.d.ts +0 -7
  388. package/dist/api/protocol-v2/FactoryDeviceInfoSettings.d.ts.map +0 -1
  389. package/dist/api/protocol-v2/FactoryGetDeviceInfo.d.ts +0 -6
  390. package/dist/api/protocol-v2/FactoryGetDeviceInfo.d.ts.map +0 -1
  391. package/dist/api/protocol-v2/FilesystemDiskControl.d.ts +0 -13
  392. package/dist/api/protocol-v2/FilesystemDiskControl.d.ts.map +0 -1
  393. package/dist/api/protocol-v2/FilesystemFixPermission.d.ts.map +0 -1
  394. package/dist/api/protocol-v2/GetProtoVersion.d.ts +0 -6
  395. package/dist/api/protocol-v2/GetProtoVersion.d.ts.map +0 -1
  396. package/dist/deviceProfile/buildDeviceProfile.d.ts +0 -21
  397. package/dist/deviceProfile/buildDeviceProfile.d.ts.map +0 -1
  398. package/dist/types/api/getDeviceInfo.d.ts +0 -85
  399. package/dist/types/api/getDeviceInfo.d.ts.map +0 -1
  400. package/src/api/GetDeviceInfo.ts +0 -145
  401. package/src/api/protocol-v2/DevReboot.ts +0 -24
  402. package/src/api/protocol-v2/DeviceGetDeviceInfo.ts +0 -118
  403. package/src/api/protocol-v2/FactoryDeviceInfoSettings.ts +0 -29
  404. package/src/api/protocol-v2/FilesystemDiskControl.ts +0 -50
  405. package/src/deviceProfile/buildDeviceProfile.ts +0 -334
  406. package/src/types/api/getDeviceInfo.ts +0 -99
@@ -0,0 +1,210 @@
1
+ import { UI_REQUEST, createUiMessage } from '../../events';
2
+
3
+ import type { CoreMessage, ProtocolV2UiCompletion } from '../../events';
4
+ import type { Device } from '../../device/Device';
5
+ import type { KnownDevice } from '../../types';
6
+
7
+ export type ProtocolV2InteractionDescriptor = {
8
+ request: 'button' | 'pin';
9
+ source: 'method-lifecycle';
10
+ reason:
11
+ | 'change-pin'
12
+ | 'device-unlock'
13
+ | 'settings-page'
14
+ | 'address-confirmation'
15
+ | 'public-key-confirmation'
16
+ | 'signing-confirmation'
17
+ | 'device-management';
18
+ completion: ProtocolV2UiCompletion;
19
+ deviceOnly: true;
20
+ page?: string | number;
21
+ operation?: string;
22
+ };
23
+
24
+ type ProtocolV2InteractionMethod = {
25
+ name?: string;
26
+ params?: unknown;
27
+ payload?: unknown;
28
+ protocolV2UiInteraction?: ProtocolV2InteractionDescriptor;
29
+ };
30
+
31
+ type InteractionDevice = Pick<Device, 'isProtocolV2' | 'toMessageObject'>;
32
+ type PostMessage = (message: CoreMessage) => void;
33
+
34
+ export const isProtocolV2UiEnabled = (method: { protocolV2UiMode?: 'auto' | 'none' }) =>
35
+ method.protocolV2UiMode !== 'none';
36
+
37
+ const getDisplayState = (value: unknown) => {
38
+ const visited = new Set<object>();
39
+ let seen = false;
40
+ let enabled = false;
41
+
42
+ const visit = (current: unknown) => {
43
+ if (current == null || typeof current !== 'object') return;
44
+ if (visited.has(current)) return;
45
+ visited.add(current);
46
+
47
+ if (Array.isArray(current)) {
48
+ current.forEach(visit);
49
+ return;
50
+ }
51
+
52
+ Object.entries(current).forEach(([key, item]) => {
53
+ if ((key === 'show_display' || key === 'showOnOneKey') && typeof item === 'boolean') {
54
+ seen = true;
55
+ enabled ||= item;
56
+ return;
57
+ }
58
+ visit(item);
59
+ });
60
+ };
61
+
62
+ visit(value);
63
+ return { seen, enabled };
64
+ };
65
+
66
+ const createMethodInteraction = (
67
+ reason: 'address-confirmation' | 'public-key-confirmation' | 'signing-confirmation',
68
+ operation: string
69
+ ): ProtocolV2InteractionDescriptor => ({
70
+ request: 'button',
71
+ source: 'method-lifecycle',
72
+ reason,
73
+ completion: 'operation-completed',
74
+ deviceOnly: true,
75
+ operation,
76
+ });
77
+
78
+ const hasCipherConfirmation = (value: unknown): boolean => {
79
+ if (Array.isArray(value)) return value.some(hasCipherConfirmation);
80
+ if (value == null || typeof value !== 'object') return false;
81
+
82
+ const params = value as {
83
+ encrypt?: boolean;
84
+ ask_on_encrypt?: boolean;
85
+ ask_on_decrypt?: boolean;
86
+ };
87
+ return params.encrypt === true ? params.ask_on_encrypt === true : params.ask_on_decrypt === true;
88
+ };
89
+
90
+ /**
91
+ * Protocol V2 no longer relies on firmware ButtonRequest, so the SDK synthesizes
92
+ * compatible UI events. Explicit descriptors win; address/public-key prompts appear
93
+ * only when displayed, while signing emits one prompt.
94
+ */
95
+ export const resolveProtocolV2UiInteraction = (
96
+ method: ProtocolV2InteractionMethod
97
+ ): ProtocolV2InteractionDescriptor | undefined => {
98
+ if (method.protocolV2UiInteraction) return method.protocolV2UiInteraction;
99
+
100
+ const operation = method.name;
101
+ if (!operation) return undefined;
102
+
103
+ const isAddress = /getAddress(?:ByLoop)?$/i.test(operation);
104
+ const isPublicKey = /getPublicKey$/i.test(operation);
105
+ if (isAddress || isPublicKey) {
106
+ const paramsDisplay = getDisplayState(method.params);
107
+ const payloadDisplay = getDisplayState(method.payload);
108
+ const display = paramsDisplay.seen ? paramsDisplay : payloadDisplay;
109
+
110
+ // Address methods usually display by default; public-key methods may be silent.
111
+ const shouldDisplay = display.seen ? display.enabled : isAddress;
112
+ if (!shouldDisplay) return undefined;
113
+
114
+ return createMethodInteraction(
115
+ isAddress ? 'address-confirmation' : 'public-key-confirmation',
116
+ operation
117
+ );
118
+ }
119
+
120
+ if (/sign/i.test(operation) || /verifyMessage$/i.test(operation) || operation === 'lnurlAuth') {
121
+ return createMethodInteraction('signing-confirmation', operation);
122
+ }
123
+
124
+ if (operation === 'nostrEncryptMessage' || operation === 'nostrDecryptMessage') {
125
+ const display = getDisplayState(method.params);
126
+ if (!display.enabled) return undefined;
127
+ return createMethodInteraction('signing-confirmation', operation);
128
+ }
129
+
130
+ if (operation === 'cipherKeyValue' && hasCipherConfirmation(method.params)) {
131
+ return createMethodInteraction('signing-confirmation', operation);
132
+ }
133
+
134
+ return undefined;
135
+ };
136
+
137
+ export class ProtocolV2UiInteractionCoordinator {
138
+ private readonly device: InteractionDevice;
139
+
140
+ private readonly postMessage: PostMessage;
141
+
142
+ private methodInteraction?: ProtocolV2InteractionDescriptor;
143
+
144
+ private currentPhase?: string;
145
+
146
+ private opened = false;
147
+
148
+ private closed = false;
149
+
150
+ constructor(device: InteractionDevice, postMessage: PostMessage) {
151
+ this.device = device;
152
+ this.postMessage = postMessage;
153
+ }
154
+
155
+ enterMethodInteraction(interaction?: ProtocolV2InteractionDescriptor) {
156
+ this.methodInteraction = interaction;
157
+ if (!interaction) return;
158
+ const { request, ...metadata } = interaction;
159
+
160
+ this.emit(
161
+ request === 'pin' ? UI_REQUEST.REQUEST_PIN : UI_REQUEST.REQUEST_BUTTON,
162
+ {
163
+ device: this.device.toMessageObject() as KnownDevice,
164
+ ...metadata,
165
+ },
166
+ `method:${request}:${interaction.reason}:${interaction.page ?? ''}:${
167
+ interaction.operation ?? ''
168
+ }`
169
+ );
170
+ }
171
+
172
+ enterUnlockInteraction(method?: string) {
173
+ this.emit(
174
+ UI_REQUEST.REQUEST_PIN,
175
+ {
176
+ device: this.device.toMessageObject() as KnownDevice,
177
+ source: 'unlock-coordinator',
178
+ reason: 'device-locked',
179
+ deviceOnly: true,
180
+ method,
181
+ },
182
+ `unlock:${method ?? ''}`
183
+ );
184
+ }
185
+
186
+ resumeMethodInteraction() {
187
+ this.enterMethodInteraction(this.methodInteraction);
188
+ }
189
+
190
+ close() {
191
+ if (!this.device.isProtocolV2() || !this.opened || this.closed) return;
192
+ this.closed = true;
193
+ this.postMessage(createUiMessage(UI_REQUEST.CLOSE_UI_WINDOW));
194
+ }
195
+
196
+ private emit(
197
+ type: typeof UI_REQUEST.REQUEST_BUTTON | typeof UI_REQUEST.REQUEST_PIN,
198
+ payload: any,
199
+ phase: string
200
+ ) {
201
+ if (!this.device.isProtocolV2() || this.closed || this.currentPhase === phase) return;
202
+ this.currentPhase = phase;
203
+ this.opened = true;
204
+ const message =
205
+ type === UI_REQUEST.REQUEST_BUTTON
206
+ ? createUiMessage(UI_REQUEST.REQUEST_BUTTON, payload)
207
+ : createUiMessage(UI_REQUEST.REQUEST_PIN, payload);
208
+ this.postMessage(message);
209
+ }
210
+ }
@@ -0,0 +1,76 @@
1
+ import { LoggerNames, getLogger } from '../../utils';
2
+ import { isDeviceLockedError } from './lockedError';
3
+ import { isProtocolV2UiEnabled, resolveProtocolV2UiInteraction } from './uiInteraction';
4
+
5
+ import type { BaseMethod } from '../../api/BaseMethod';
6
+ import type { Device } from '../../device/Device';
7
+ import type { ProtocolV2UiInteractionCoordinator } from './uiInteraction';
8
+
9
+ const Log = getLogger(LoggerNames.Core);
10
+
11
+ type RunnableMethod = Pick<
12
+ BaseMethod,
13
+ 'run' | 'unlockPolicy' | 'protocolV2UiInteraction' | 'protocolV2UiMode' | 'params' | 'payload'
14
+ > & { name?: string };
15
+ type UnlockableDevice = Pick<Device, 'isProtocolV2' | 'unlockDevice' | 'features'>;
16
+ type UiInteractionCoordinator = Pick<
17
+ ProtocolV2UiInteractionCoordinator,
18
+ 'enterMethodInteraction' | 'enterUnlockInteraction' | 'resumeMethodInteraction'
19
+ >;
20
+
21
+ export async function runMethodWithUnlockRetry(
22
+ method: RunnableMethod,
23
+ device: UnlockableDevice,
24
+ uiCoordinator?: UiInteractionCoordinator
25
+ ) {
26
+ const shouldEmitUi = isProtocolV2UiEnabled(method);
27
+ const shouldUnlockBeforeRun =
28
+ device.isProtocolV2() &&
29
+ method.unlockPolicy === 'retry-on-locked' &&
30
+ device.features?.unlocked === false;
31
+
32
+ if (shouldUnlockBeforeRun) {
33
+ if (shouldEmitUi) {
34
+ uiCoordinator?.enterUnlockInteraction(method.name);
35
+ }
36
+ await device.unlockDevice();
37
+ Log.debug('Protocol V2 pre-unlock completed', { method: method.name });
38
+ if (shouldEmitUi) {
39
+ uiCoordinator?.enterMethodInteraction(resolveProtocolV2UiInteraction(method));
40
+ }
41
+ return method.run();
42
+ }
43
+
44
+ if (shouldEmitUi) {
45
+ uiCoordinator?.enterMethodInteraction(resolveProtocolV2UiInteraction(method));
46
+ }
47
+ try {
48
+ return await method.run();
49
+ } catch (error) {
50
+ if (
51
+ !device.isProtocolV2() ||
52
+ method.unlockPolicy !== 'retry-on-locked' ||
53
+ !isDeviceLockedError(error)
54
+ ) {
55
+ throw error;
56
+ }
57
+
58
+ Log.debug('Protocol V2 unlock retry triggered', { method: method.name });
59
+ if (shouldEmitUi) {
60
+ uiCoordinator?.enterUnlockInteraction(method.name);
61
+ }
62
+ await device.unlockDevice();
63
+ Log.debug('Protocol V2 unlock completed', { method: method.name });
64
+ if (shouldEmitUi) {
65
+ uiCoordinator?.resumeMethodInteraction();
66
+ }
67
+ try {
68
+ const response = await method.run();
69
+ Log.debug('Protocol V2 method retry completed', { method: method.name, success: true });
70
+ return response;
71
+ } catch (retryError) {
72
+ Log.debug('Protocol V2 method retry completed', { method: method.name, success: false });
73
+ throw retryError;
74
+ }
75
+ }
76
+ }
@@ -0,0 +1,107 @@
1
+ import { ERRORS, HardwareErrorCode } from '@onekeyfe/hd-shared';
2
+
3
+ import { assertCompleteDeviceSession } from './deviceSession';
4
+ import { isDeviceLockedError } from './lockedError';
5
+
6
+ import type { DeviceSessionGet } from '@onekeyfe/hd-transport';
7
+ import type { Device } from '../../device/Device';
8
+
9
+ export async function requestProtocolV2DeviceStatus(device: Device) {
10
+ const { message } = await device.commands.typedCall('DeviceStatusGet', 'DeviceStatus', {});
11
+ return message;
12
+ }
13
+
14
+ export async function refreshProtocolV2DeviceStatus(device: Device) {
15
+ const status = await requestProtocolV2DeviceStatus(device);
16
+ return device.updateProtocolV2Status(status);
17
+ }
18
+
19
+ const getDeviceSession = async (device: Device, request: DeviceSessionGet) => {
20
+ try {
21
+ return await device.commands.typedCall('DeviceSessionGet', 'DeviceSession', request);
22
+ } catch (error) {
23
+ if (!isDeviceLockedError(error)) {
24
+ throw error;
25
+ }
26
+ await device.unlockDevice();
27
+ return device.commands.typedCall('DeviceSessionGet', 'DeviceSession', request);
28
+ }
29
+ };
30
+
31
+ export async function getProtocolV2WalletSession(
32
+ device: Device,
33
+ options?: {
34
+ initSession?: boolean;
35
+ expectedPassphraseState?: string;
36
+ onlyMainPin?: boolean;
37
+ }
38
+ ) {
39
+ if (options?.initSession) {
40
+ device.clearInternalState();
41
+ }
42
+
43
+ const expectedPassphraseState = options?.expectedPassphraseState ?? device.passphraseState;
44
+
45
+ // Unlock with PIN first. DeviceSessionGet operates on the wallet selected by
46
+ // the device unlock flow; Protocol V2 does not accept a host passphrase here.
47
+ if (device.features?.unlocked === false) {
48
+ await device.unlockDevice();
49
+ }
50
+
51
+ // A standard wallet needs no DeviceSession. After unlock confirms passphrase is
52
+ // disabled, do not create or forward a hidden-wallet passphraseState.
53
+ if (options?.onlyMainPin || device.getCurrentPassphraseProtection() === false) {
54
+ return {
55
+ passphraseState: undefined,
56
+ newSession: undefined,
57
+ unlockedAttachPin: device.features?.unlockedAttachPin ?? false,
58
+ resumed: false,
59
+ };
60
+ }
61
+
62
+ const cachedSessionId =
63
+ typeof device.getInternalState === 'function' ? device.getInternalState() : undefined;
64
+ let response;
65
+ let resumed = false;
66
+
67
+ if (cachedSessionId && expectedPassphraseState) {
68
+ try {
69
+ response = await getDeviceSession(device, { session_id: cachedSessionId });
70
+ resumed = true;
71
+ } catch (error) {
72
+ device.clearInternalState();
73
+ throw error;
74
+ }
75
+ }
76
+
77
+ if (!response) {
78
+ response = await getDeviceSession(device, {});
79
+ }
80
+
81
+ const { message } = response;
82
+ try {
83
+ assertCompleteDeviceSession(message);
84
+ } catch (error) {
85
+ device.clearInternalState();
86
+ throw error;
87
+ }
88
+ if (expectedPassphraseState && expectedPassphraseState !== message.btc_test_address) {
89
+ device.clearInternalState();
90
+ throw ERRORS.TypedError(HardwareErrorCode.DeviceCheckPassphraseStateError);
91
+ }
92
+
93
+ device.updateInternalState(
94
+ true,
95
+ message.btc_test_address,
96
+ device.getCurrentDeviceId(),
97
+ message.session_id,
98
+ options?.initSession ? null : device.features?.sessionId ?? null
99
+ );
100
+
101
+ return {
102
+ passphraseState: message.btc_test_address,
103
+ newSession: message.session_id,
104
+ unlockedAttachPin: device.features?.unlockedAttachPin ?? undefined,
105
+ resumed,
106
+ };
107
+ }
@@ -1,8 +1,7 @@
1
1
  import type { IBLEFirmwareReleaseInfo } from '../settings';
2
2
  import type { EFirmwareType } from '@onekeyfe/hd-shared';
3
- import type { Features } from '@onekeyfe/hd-transport';
4
3
  import type { CommonParams, Response } from '../params';
5
- import type { IDeviceBLEFirmwareStatus, IDeviceFirmwareStatus } from '../device';
4
+ import type { Features, IDeviceBLEFirmwareStatus, IDeviceFirmwareStatus } from '../device';
6
5
 
7
6
  export type FirmwareRelease = {
8
7
  shouldUpdate?: boolean;
@@ -1,20 +1,44 @@
1
- import type { SafetyCheckLevel, Success } from '@onekeyfe/hd-transport';
1
+ import type { Enum_SafetyCheckLevel, Success } from '@onekeyfe/hd-transport';
2
2
  import type { CommonParams, Response } from '../params';
3
3
 
4
4
  export type DeviceSettingsParams = {
5
5
  language?: string;
6
6
  label?: string;
7
7
  usePassphrase?: boolean;
8
+ /** Protocol V1 only. */
8
9
  homescreen?: string;
10
+ /** Protocol V1 only. */
9
11
  passphraseSource?: number;
10
12
  autoLockDelayMs?: number;
13
+ /** Protocol V1 only. */
11
14
  displayRotation?: number;
15
+ /** Protocol V1 only. */
12
16
  passphraseAlwaysOnDevice?: boolean;
13
- safetyChecks?: SafetyCheckLevel;
17
+ /** Protocol V1 only. Uses Enum_SafetyCheckLevel numeric values. */
18
+ safetyChecks?: Enum_SafetyCheckLevel;
19
+ /** Protocol V1 only; the current Protocol V2 schema has no matching field. */
14
20
  experimentalFeatures?: boolean;
15
21
  autoShutdownDelayMs?: number;
22
+ /** Protocol V1 only; opens the legacy device-side brightness flow. */
16
23
  changeBrightness?: boolean;
24
+ /** Protocol V2 only. */
25
+ brightness?: number;
17
26
  hapticFeedback?: boolean;
27
+ bluetoothEnabled?: boolean;
28
+ /** Protocol V2 only; changed through an on-device confirmation page. */
29
+ airgapMode?: boolean;
30
+ /** Protocol V2 only. */
31
+ animationEnabled?: boolean;
32
+ /** Protocol V2 only. */
33
+ tapToWake?: boolean;
34
+ /** Protocol V2 only. */
35
+ deviceNameDisplayEnabled?: boolean;
36
+ /** Protocol V2 only. */
37
+ fidoEnabled?: boolean;
38
+ /** Protocol V2 only. */
39
+ usbLockEnabled?: boolean;
40
+ /** Protocol V2 only. */
41
+ randomKeypad?: boolean;
18
42
  };
19
43
 
20
44
  export declare function deviceSettings(
@@ -1,4 +1,7 @@
1
- import type { Features } from '@onekeyfe/hd-transport';
1
+ import type { DeviceState } from '../device';
2
2
  import type { CommonParams, Response } from '../params';
3
3
 
4
- export declare function deviceUnlock(connectId: string, params?: CommonParams): Response<Features>;
4
+ export declare function deviceUnlock(
5
+ connectId: string,
6
+ params?: CommonParams
7
+ ): Response<DeviceState>;
@@ -58,42 +58,50 @@ export interface FirmwareUpdateV3Params {
58
58
  }
59
59
 
60
60
  /**
61
- * firmwareUpdateV4(Protocol V2)按 DevFirmwareTargetType 拆分的目标二进制。
62
- * 每个字段对应一个固件升级 target,可单独更新,也可任意组合一次更新。
61
+ * firmwareUpdateV4 target binaries grouped by DeviceFirmwareTargetType.
62
+ * Except for romloader, each field maps to a target accepted by bootloader.
63
63
  */
64
+ export type FirmwareUpdateV4Target =
65
+ | 'boot'
66
+ | 'app_v1'
67
+ | 'app_v2'
68
+ | 'coprocessor'
69
+ | 'resource'
70
+ | 'se01'
71
+ | 'se02'
72
+ | 'se03'
73
+ | 'se04';
74
+
64
75
  export interface FirmwareUpdateV4Params {
65
76
  platform: IPlatform;
66
77
  chunkSize?: number;
67
78
  firmwareType?: EFirmwareType;
79
+ targetsToUpdate?: FirmwareUpdateV4Target[];
68
80
 
69
- /** TARGET_MAIN_BOOT = 1 */
81
+ /** FW_MGMT_TARGET_ROMLOADER = 2; Pro2 cannot install it through firmwareUpdateV4. */
70
82
  romloaderBinary?: ArrayBuffer;
71
- /** TARGET_MAIN_BOOT = 1 */
83
+ /** FW_MGMT_TARGET_BOOTLOADER = 3 */
72
84
  bootloaderBinary?: ArrayBuffer;
73
- /** TARGET_MAIN_APP = 0 */
85
+ /** FW_MGMT_TARGET_APPLICATION_P1 = 4 */
74
86
  applicationP1Binary?: ArrayBuffer;
75
- /** TARGET_MAIN_APP = 0 */
87
+ /** FW_MGMT_TARGET_APPLICATION_P2 = 5 */
76
88
  applicationP2Binary?: ArrayBuffer;
77
- /** TARGET_BT = 2 */
89
+ /** FW_MGMT_TARGET_COPROCESSOR = 6 */
78
90
  coprocessorBinary?: ArrayBuffer;
79
- /** TARGET_SE1-4 = 3-6 */
91
+ /** FW_MGMT_TARGET_SE01-04 = 7-10 */
80
92
  se01Binary?: ArrayBuffer;
81
93
  se02Binary?: ArrayBuffer;
82
94
  se03Binary?: ArrayBuffer;
83
95
  se04Binary?: ArrayBuffer;
84
- /** TARGET_RESOURCE = 10(zip 包,解压后逐文件上传) */
85
- resourceBinary?: ArrayBuffer;
86
96
  forcedUpdateRes?: boolean;
87
-
88
- /** release 配置自动下载 */
89
- firmwareVersion?: number[];
90
- bleVersion?: number[];
91
- bootloaderVersion?: number[];
92
-
93
- /** legacy 别名:等价 applicationP1Binary */
94
- firmwareBinary?: ArrayBuffer;
95
- /** legacy 别名:等价 coprocessorBinary */
96
- bleBinary?: ArrayBuffer;
97
+ /**
98
+ * RESC bundle okpkg files written directly to devicePath through FilesystemFileWrite.
99
+ * Manual mode installs them without version comparison.
100
+ */
101
+ resourceBundleFiles?: Array<{
102
+ binary: ArrayBuffer;
103
+ devicePath: string;
104
+ }>;
97
105
  }
98
106
 
99
107
  export declare function firmwareUpdateV3(
@@ -0,0 +1,19 @@
1
+ import type { DeviceState, DeviceStateSection } from '../device';
2
+ import type { CommonParams, Response } from '../params';
3
+
4
+ export type DeviceStateScope = 'runtime' | 'settings' | 'firmware';
5
+
6
+ export type GetDeviceStateParams = CommonParams & {
7
+ scope?: DeviceStateScope;
8
+ };
9
+
10
+ /** Internal state-read options, not part of the public CoreApi. */
11
+ export type DeviceStateReadOptions = {
12
+ refreshSections?: DeviceStateSection[];
13
+ includeRaw?: boolean;
14
+ };
15
+
16
+ export declare function getDeviceState(
17
+ connectId?: string,
18
+ params?: GetDeviceStateParams
19
+ ): Response<DeviceState>;
@@ -1,4 +1,7 @@
1
1
  import type { CommonParams, Response } from '../params';
2
2
  import type { Features } from '../device';
3
3
 
4
+ /**
5
+ * @deprecated Use `getDeviceState` for both Protocol V1 and Protocol V2 devices.
6
+ */
4
7
  export declare function getFeatures(connectId?: string, params?: CommonParams): Response<Features>;
@@ -1,6 +1,9 @@
1
1
  import type { CommonParams, Response } from '../params';
2
2
  import type { OnekeyFeatures } from '../device';
3
3
 
4
+ /**
5
+ * @deprecated Use `getDeviceState(connectId, { scope: 'firmware' })`.
6
+ */
4
7
  export declare function getOnekeyFeatures(
5
8
  connectId?: string,
6
9
  params?: CommonParams
@@ -1,17 +1,14 @@
1
1
  import type { CommonParams, Response } from '../params';
2
2
 
3
- export type GetPassphraseStatePayload = {
4
- passphrase_state?: string;
5
- session_id?: string;
6
- unlocked_attach_pin?: boolean;
7
- passphrase_protection?: boolean | null;
8
- };
9
-
10
- export type GetPassphraseStateParams = CommonParams & {
11
- allowCreateAttachPin?: boolean;
12
- };
3
+ export type GetPassphraseStateParams = CommonParams;
13
4
 
5
+ /**
6
+ * Legacy Protocol V1 wallet API.
7
+ *
8
+ * This remains supported for Protocol V1 integrations. New cross-protocol integrations
9
+ * and all Protocol V2 callers should use `openWalletSession`.
10
+ */
14
11
  export declare function getPassphraseState(
15
12
  connectId?: string,
16
13
  params?: GetPassphraseStateParams
17
- ): Response<GetPassphraseStatePayload>;
14
+ ): Response<string | undefined>;