@onekeyfe/hd-core 1.2.0-alpha.66 → 1.2.0-alpha.67

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 (315) hide show
  1. package/__tests__/AllNetworkGetAddressBase.tracing.test.ts +0 -313
  2. package/__tests__/DeviceCommands.test.ts +13 -59
  3. package/__tests__/DeviceEventRegistration.test.ts +0 -6
  4. package/__tests__/check-all-firmware-release-protocol-v2.test.ts +3 -198
  5. package/__tests__/connectSettings.test.ts +47 -5
  6. package/__tests__/device-initialize-timeout.test.ts +56 -0
  7. package/__tests__/device-lifecycle-events.test.ts +3 -105
  8. package/__tests__/device-pool-state.test.ts +0 -22
  9. package/__tests__/device-settings.test.ts +18 -39
  10. package/__tests__/device-state-contract.test.ts +0 -1
  11. package/__tests__/device-state-mapper.test.ts +1 -13
  12. package/__tests__/device-utils.test.ts +1 -48
  13. package/__tests__/deviceSettings.test.ts +1 -11
  14. package/__tests__/firmware-update/check-all-firmware-release.test.ts +175 -0
  15. package/__tests__/firmware-update/device-update-bootloader.test.ts +87 -0
  16. package/__tests__/firmware-update/firmware-artifact-source.test.ts +119 -0
  17. package/__tests__/firmware-update/firmware-host-binding.test.ts +70 -0
  18. package/__tests__/firmware-update/firmware-preparation-error.test.ts +27 -0
  19. package/__tests__/firmware-update/firmware-update-bootloader-poll.test.ts +200 -0
  20. package/__tests__/firmware-update/firmware-update-capabilities.test.ts +13 -0
  21. package/__tests__/firmware-update/firmware-update-plan-bootloader-identity.test.ts +394 -0
  22. package/__tests__/firmware-update/firmware-update-plan.test.ts +593 -0
  23. package/__tests__/firmware-update/firmware-update-prepared-plan.test.ts +231 -0
  24. package/__tests__/firmware-update/firmware-update-v2-download-before-boot.test.ts +59 -31
  25. package/__tests__/firmware-update/firmware-update-v3-reconnect.test.ts +58 -0
  26. package/__tests__/firmware-update/firmware-upload-source.test.ts +70 -0
  27. package/__tests__/get-device-state.test.ts +12 -132
  28. package/__tests__/homescreen.test.ts +1 -41
  29. package/__tests__/kaspa-use-tweak-pro2.test.ts +2 -2
  30. package/__tests__/kaspaSignTransaction.test.ts +26 -3
  31. package/__tests__/logBlockEvent.test.ts +1 -1
  32. package/__tests__/method-protocol-support.test.ts +0 -19
  33. package/__tests__/open-wallet-session.test.ts +37 -568
  34. package/__tests__/protocol-v2-unlock-policy.test.ts +37 -300
  35. package/__tests__/protocol-v2.test.ts +1153 -1458
  36. package/__tests__/protocolV2FileWrite.test.ts +0 -152
  37. package/__tests__/protocolV2UiInteraction.test.ts +0 -63
  38. package/__tests__/public-pro2-api-boundary.test.ts +0 -1
  39. package/__tests__/search-devices.test.ts +3 -12
  40. package/__tests__/tron-sign-message-init.test.ts +2 -2
  41. package/dist/api/BaseMethod.d.ts +1 -3
  42. package/dist/api/BaseMethod.d.ts.map +1 -1
  43. package/dist/api/CheckAllFirmwareRelease.d.ts +1 -2
  44. package/dist/api/CheckAllFirmwareRelease.d.ts.map +1 -1
  45. package/dist/api/FirmwareUpdate.d.ts.map +1 -1
  46. package/dist/api/FirmwareUpdateV2.d.ts +10 -0
  47. package/dist/api/FirmwareUpdateV2.d.ts.map +1 -1
  48. package/dist/api/FirmwareUpdateV3.d.ts +7 -3
  49. package/dist/api/FirmwareUpdateV3.d.ts.map +1 -1
  50. package/dist/api/FirmwareUpdateV4.d.ts +27 -13
  51. package/dist/api/FirmwareUpdateV4.d.ts.map +1 -1
  52. package/dist/api/GetPassphraseState.d.ts.map +1 -1
  53. package/dist/api/OpenWalletSession.d.ts.map +1 -1
  54. package/dist/api/SearchDevices.d.ts.map +1 -1
  55. package/dist/api/allnetwork/AllNetworkGetAddressBase.d.ts.map +1 -1
  56. package/dist/api/device/DeviceSettings.d.ts.map +1 -1
  57. package/dist/api/device/DeviceUnlock.d.ts +2 -2
  58. package/dist/api/device/DeviceUnlock.d.ts.map +1 -1
  59. package/dist/api/device/DeviceUpdateBootloader.d.ts +5 -1
  60. package/dist/api/device/DeviceUpdateBootloader.d.ts.map +1 -1
  61. package/dist/api/firmware/FirmwareArtifactSource.d.ts +25 -0
  62. package/dist/api/firmware/FirmwareArtifactSource.d.ts.map +1 -0
  63. package/dist/api/firmware/FirmwareHostBinding.d.ts +6 -0
  64. package/dist/api/firmware/FirmwareHostBinding.d.ts.map +1 -0
  65. package/dist/api/firmware/FirmwarePreparationError.d.ts +3 -0
  66. package/dist/api/firmware/FirmwarePreparationError.d.ts.map +1 -0
  67. package/dist/api/firmware/FirmwareUpdateBaseMethod.d.ts +11 -4
  68. package/dist/api/firmware/FirmwareUpdateBaseMethod.d.ts.map +1 -1
  69. package/dist/api/firmware/FirmwareUpdateCapabilities.d.ts +3 -0
  70. package/dist/api/firmware/FirmwareUpdateCapabilities.d.ts.map +1 -0
  71. package/dist/api/firmware/FirmwareUpdatePlan.d.ts +25 -0
  72. package/dist/api/firmware/FirmwareUpdatePlan.d.ts.map +1 -0
  73. package/dist/api/firmware/FirmwareUpdatePreparedPlan.d.ts +32 -0
  74. package/dist/api/firmware/FirmwareUpdatePreparedPlan.d.ts.map +1 -0
  75. package/dist/api/firmware/getBinary.d.ts +7 -0
  76. package/dist/api/firmware/getBinary.d.ts.map +1 -1
  77. package/dist/api/firmware/progressThrottle.d.ts +3 -0
  78. package/dist/api/firmware/progressThrottle.d.ts.map +1 -0
  79. package/dist/api/firmware/updateBootloader.d.ts +2 -0
  80. package/dist/api/firmware/updateBootloader.d.ts.map +1 -1
  81. package/dist/api/firmware/uploadFirmware.d.ts +9 -1
  82. package/dist/api/firmware/uploadFirmware.d.ts.map +1 -1
  83. package/dist/api/helpers/protocolV2FileWrite.d.ts +0 -9
  84. package/dist/api/helpers/protocolV2FileWrite.d.ts.map +1 -1
  85. package/dist/api/index.d.ts +0 -2
  86. package/dist/api/index.d.ts.map +1 -1
  87. package/dist/api/kaspa/KaspaGetAddress.d.ts +1 -1
  88. package/dist/api/kaspa/KaspaSignTransaction.d.ts +1 -1
  89. package/dist/api/kaspa/KaspaSignTransaction.d.ts.map +1 -1
  90. package/dist/api/polkadot/PolkadotGetAddress.d.ts +1 -1
  91. package/dist/api/polkadot/networks.d.ts +1 -1
  92. package/dist/api/protocol-v2/ProtocolInfoRequest.d.ts.map +1 -1
  93. package/dist/api/protocol-v2/helpers.d.ts.map +1 -1
  94. package/dist/api/solana/SolSignMessage.d.ts +1 -1
  95. package/dist/api/solana/SolSignOffchainMessage.d.ts +1 -1
  96. package/dist/api/solana/SolSignTransaction.d.ts +2 -2
  97. package/dist/api/stellar/StellarSignTransaction.d.ts +1 -1
  98. package/dist/api/sui/SuiGetAddress.d.ts +1 -1
  99. package/dist/api/sui/SuiGetPublicKey.d.ts +1 -1
  100. package/dist/api/sui/SuiSignMessage.d.ts +1 -1
  101. package/dist/api/sui/SuiSignTransaction.d.ts +1 -1
  102. package/dist/api/ton/TonGetAddress.d.ts +1 -1
  103. package/dist/api/ton/TonSignMessage.d.ts +1 -1
  104. package/dist/api/ton/TonSignProof.d.ts +1 -1
  105. package/dist/api/tron/TronSignMessage.d.ts +2 -2
  106. package/dist/api/tron/TronSignTransaction.d.ts +1 -1
  107. package/dist/core/deviceEventRegistration.d.ts +0 -2
  108. package/dist/core/deviceEventRegistration.d.ts.map +1 -1
  109. package/dist/core/index.d.ts.map +1 -1
  110. package/dist/data-manager/DataManager.d.ts +4 -9
  111. package/dist/data-manager/DataManager.d.ts.map +1 -1
  112. package/dist/data-manager/TransportManager.d.ts.map +1 -1
  113. package/dist/data-manager/connectSettings.d.ts.map +1 -1
  114. package/dist/device/Device.d.ts +6 -29
  115. package/dist/device/Device.d.ts.map +1 -1
  116. package/dist/device/DeviceCommands.d.ts +4 -4
  117. package/dist/device/DeviceCommands.d.ts.map +1 -1
  118. package/dist/device/DeviceConnector.d.ts +1 -2
  119. package/dist/device/DeviceConnector.d.ts.map +1 -1
  120. package/dist/device/DevicePool.d.ts.map +1 -1
  121. package/dist/deviceProfile/protocolV2DeviceIdentity.d.ts.map +1 -1
  122. package/dist/events/device.d.ts +0 -4
  123. package/dist/events/device.d.ts.map +1 -1
  124. package/dist/events/logBlockEvent.d.ts.map +1 -1
  125. package/dist/events/ui-promise.d.ts +2 -4
  126. package/dist/events/ui-promise.d.ts.map +1 -1
  127. package/dist/events/ui-request.d.ts +2 -31
  128. package/dist/events/ui-request.d.ts.map +1 -1
  129. package/dist/events/ui-response.d.ts +2 -10
  130. package/dist/events/ui-response.d.ts.map +1 -1
  131. package/dist/index.d.ts +247 -243
  132. package/dist/index.d.ts.map +1 -1
  133. package/dist/index.js +3773 -3054
  134. package/dist/inject.d.ts +1 -6
  135. package/dist/inject.d.ts.map +1 -1
  136. package/dist/lowLevelInject.d.ts.map +1 -1
  137. package/dist/protocols/protocol-v2/features.d.ts +4 -0
  138. package/dist/protocols/protocol-v2/features.d.ts.map +1 -1
  139. package/dist/protocols/protocol-v2/firmware.d.ts.map +1 -1
  140. package/dist/protocols/protocol-v2/lockedError.d.ts +2 -0
  141. package/dist/protocols/protocol-v2/lockedError.d.ts.map +1 -0
  142. package/dist/protocols/protocol-v2/uiInteraction.d.ts +4 -7
  143. package/dist/protocols/protocol-v2/uiInteraction.d.ts.map +1 -1
  144. package/dist/protocols/protocol-v2/unlockPolicy.d.ts +3 -1
  145. package/dist/protocols/protocol-v2/unlockPolicy.d.ts.map +1 -1
  146. package/dist/protocols/protocol-v2/unlockRetry.d.ts +10 -0
  147. package/dist/protocols/protocol-v2/unlockRetry.d.ts.map +1 -0
  148. package/dist/protocols/protocol-v2/walletSession.d.ts +1 -6
  149. package/dist/protocols/protocol-v2/walletSession.d.ts.map +1 -1
  150. package/dist/topLevelInject.d.ts.map +1 -1
  151. package/dist/types/api/checkAllFirmwareRelease.d.ts +5 -3
  152. package/dist/types/api/checkAllFirmwareRelease.d.ts.map +1 -1
  153. package/dist/types/api/deviceUnlock.d.ts +1 -5
  154. package/dist/types/api/deviceUnlock.d.ts.map +1 -1
  155. package/dist/types/api/deviceUpdateBootloader.d.ts +6 -0
  156. package/dist/types/api/deviceUpdateBootloader.d.ts.map +1 -1
  157. package/dist/types/api/export.d.ts +4 -2
  158. package/dist/types/api/export.d.ts.map +1 -1
  159. package/dist/types/api/firmwareUpdate.d.ts +70 -4
  160. package/dist/types/api/firmwareUpdate.d.ts.map +1 -1
  161. package/dist/types/api/firmwareUpdateCapabilities.d.ts +9 -0
  162. package/dist/types/api/firmwareUpdateCapabilities.d.ts.map +1 -0
  163. package/dist/types/api/firmwareUpdatePlan.d.ts +28 -0
  164. package/dist/types/api/firmwareUpdatePlan.d.ts.map +1 -0
  165. package/dist/types/api/firmwareUpdatePreparedPlan.d.ts +42 -0
  166. package/dist/types/api/firmwareUpdatePreparedPlan.d.ts.map +1 -0
  167. package/dist/types/api/index.d.ts +10 -7
  168. package/dist/types/api/index.d.ts.map +1 -1
  169. package/dist/types/api/protocolV2.d.ts +0 -3
  170. package/dist/types/api/protocolV2.d.ts.map +1 -1
  171. package/dist/types/device.d.ts +2 -2
  172. package/dist/types/device.d.ts.map +1 -1
  173. package/dist/types/params.d.ts +0 -1
  174. package/dist/types/params.d.ts.map +1 -1
  175. package/dist/types/settings.d.ts +21 -38
  176. package/dist/types/settings.d.ts.map +1 -1
  177. package/dist/utils/deviceFeaturesCompat.d.ts +1 -0
  178. package/dist/utils/deviceFeaturesCompat.d.ts.map +1 -1
  179. package/dist/utils/deviceFeaturesUtils.d.ts +0 -4
  180. package/dist/utils/deviceFeaturesUtils.d.ts.map +1 -1
  181. package/dist/utils/deviceInfoUtils.d.ts.map +1 -1
  182. package/dist/utils/deviceSettings.d.ts.map +1 -1
  183. package/dist/utils/homescreen.d.ts +0 -4
  184. package/dist/utils/homescreen.d.ts.map +1 -1
  185. package/dist/utils/index.d.ts +1 -1
  186. package/dist/utils/index.d.ts.map +1 -1
  187. package/dist/utils/patch.d.ts +1 -1
  188. package/dist/utils/patch.d.ts.map +1 -1
  189. package/dist/utils/pro2Wallpaper.d.ts +0 -10
  190. package/dist/utils/pro2Wallpaper.d.ts.map +1 -1
  191. package/package.json +4 -4
  192. package/src/api/BaseMethod.ts +10 -8
  193. package/src/api/CheckAllFirmwareRelease.ts +60 -59
  194. package/src/api/FirmwareUpdate.ts +15 -7
  195. package/src/api/FirmwareUpdateV2.ts +298 -126
  196. package/src/api/FirmwareUpdateV3.ts +265 -63
  197. package/src/api/FirmwareUpdateV4.ts +1017 -602
  198. package/src/api/GetPassphraseState.ts +1 -7
  199. package/src/api/OpenWalletSession.ts +17 -71
  200. package/src/api/SearchDevices.ts +1 -3
  201. package/src/api/allnetwork/AllNetworkGetAddress.ts +21 -21
  202. package/src/api/allnetwork/AllNetworkGetAddressBase.ts +11 -36
  203. package/src/api/device/DeviceSettings.ts +4 -5
  204. package/src/api/device/DeviceUnlock.ts +3 -8
  205. package/src/api/device/DeviceUpdateBootloader.ts +125 -6
  206. package/src/api/firmware/FirmwareArtifactSource.ts +278 -0
  207. package/src/api/firmware/FirmwareHostBinding.ts +100 -0
  208. package/src/api/firmware/FirmwarePreparationError.ts +12 -0
  209. package/src/api/firmware/FirmwareUpdateBaseMethod.ts +83 -27
  210. package/src/api/firmware/FirmwareUpdateCapabilities.ts +9 -0
  211. package/src/api/firmware/FirmwareUpdatePlan.ts +772 -0
  212. package/src/api/firmware/FirmwareUpdatePreparedPlan.ts +449 -0
  213. package/src/api/firmware/progressThrottle.ts +44 -0
  214. package/src/api/firmware/updateBootloader.ts +19 -4
  215. package/src/api/firmware/uploadFirmware.ts +144 -39
  216. package/src/api/helpers/protocolV2FileWrite.ts +63 -202
  217. package/src/api/index.ts +0 -2
  218. package/src/api/kaspa/KaspaGetAddress.ts +1 -1
  219. package/src/api/kaspa/KaspaSignTransaction.ts +13 -2
  220. package/src/api/polkadot/networks.ts +3 -3
  221. package/src/api/protocol-v2/ProtocolInfoRequest.ts +1 -3
  222. package/src/api/protocol-v2/helpers.ts +1 -1
  223. package/src/api/solana/SolSignMessage.ts +1 -1
  224. package/src/api/solana/SolSignOffchainMessage.ts +1 -1
  225. package/src/api/solana/SolSignTransaction.ts +2 -2
  226. package/src/api/sui/SuiGetAddress.ts +1 -1
  227. package/src/api/sui/SuiGetPublicKey.ts +1 -1
  228. package/src/api/sui/SuiSignMessage.ts +1 -1
  229. package/src/api/sui/SuiSignTransaction.ts +1 -1
  230. package/src/api/ton/TonGetAddress.ts +1 -1
  231. package/src/api/ton/TonSignMessage.ts +1 -1
  232. package/src/api/ton/TonSignProof.ts +1 -1
  233. package/src/api/tron/TronSignMessage.ts +2 -2
  234. package/src/api/tron/TronSignTransaction.ts +1 -1
  235. package/src/core/deviceEventRegistration.ts +0 -4
  236. package/src/core/index.ts +111 -213
  237. package/src/data/messages/messages-protocol-v2.json +0 -25
  238. package/src/data-manager/DataManager.ts +41 -113
  239. package/src/data-manager/TransportManager.ts +0 -6
  240. package/src/data-manager/connectSettings.ts +11 -0
  241. package/src/device/Device.ts +49 -274
  242. package/src/device/DeviceCommands.ts +4 -31
  243. package/src/device/DeviceConnector.ts +13 -33
  244. package/src/device/DevicePool.ts +7 -21
  245. package/src/deviceProfile/buildDeviceFeatures.ts +2 -2
  246. package/src/deviceProfile/protocolV2DeviceIdentity.ts +0 -3
  247. package/src/events/device.ts +0 -4
  248. package/src/events/logBlockEvent.ts +0 -1
  249. package/src/events/ui-promise.ts +2 -4
  250. package/src/events/ui-request.ts +2 -36
  251. package/src/events/ui-response.ts +2 -12
  252. package/src/index.ts +5 -0
  253. package/src/inject.ts +24 -60
  254. package/src/lowLevelInject.ts +8 -7
  255. package/src/protocols/protocol-v2/features.ts +7 -10
  256. package/src/protocols/protocol-v2/firmware.ts +0 -2
  257. package/src/protocols/protocol-v2/lockedError.ts +10 -0
  258. package/src/protocols/protocol-v2/uiInteraction.ts +6 -46
  259. package/src/protocols/protocol-v2/unlockPolicy.ts +105 -1
  260. package/src/protocols/protocol-v2/unlockRetry.ts +109 -0
  261. package/src/protocols/protocol-v2/walletSession.ts +36 -214
  262. package/src/topLevelInject.ts +8 -7
  263. package/src/types/api/checkAllFirmwareRelease.ts +5 -3
  264. package/src/types/api/deviceUnlock.ts +1 -12
  265. package/src/types/api/deviceUpdateBootloader.ts +6 -0
  266. package/src/types/api/export.ts +18 -1
  267. package/src/types/api/firmwareUpdate.ts +78 -6
  268. package/src/types/api/firmwareUpdateCapabilities.ts +9 -0
  269. package/src/types/api/firmwareUpdatePlan.ts +38 -0
  270. package/src/types/api/firmwareUpdatePreparedPlan.ts +53 -0
  271. package/src/types/api/index.ts +14 -13
  272. package/src/types/api/protocolV2.ts +0 -13
  273. package/src/types/device.ts +3 -15
  274. package/src/types/params.ts +1 -7
  275. package/src/types/settings.ts +22 -60
  276. package/src/utils/deviceFeaturesCompat.ts +6 -5
  277. package/src/utils/deviceFeaturesUtils.ts +3 -14
  278. package/src/utils/deviceInfoUtils.ts +0 -2
  279. package/src/utils/deviceSettings.ts +0 -3
  280. package/src/utils/homescreen.ts +6 -32
  281. package/src/utils/index.ts +1 -6
  282. package/src/utils/pro2Wallpaper.ts +8 -35
  283. package/__tests__/core-initialization.test.ts +0 -23
  284. package/__tests__/device-connector-protocol.test.ts +0 -81
  285. package/__tests__/deviceUploadNft.test.ts +0 -316
  286. package/__tests__/pro2Nft.test.ts +0 -108
  287. package/__tests__/protocol-binding.test.ts +0 -89
  288. package/__tests__/protocol-v2-resources.test.ts +0 -340
  289. package/__tests__/protocol-v2-ui-lifecycle.test.ts +0 -91
  290. package/__tests__/uiProgressThrottle.test.ts +0 -74
  291. package/__tests__/uiPromiseRegistry.test.ts +0 -115
  292. package/dist/api/DetectDeviceConnectProtocol.d.ts +0 -7
  293. package/dist/api/DetectDeviceConnectProtocol.d.ts.map +0 -1
  294. package/dist/api/protocol-v2/DeviceUploadNft.d.ts +0 -31
  295. package/dist/api/protocol-v2/DeviceUploadNft.d.ts.map +0 -1
  296. package/dist/core/uiPromiseRegistry.d.ts +0 -6
  297. package/dist/core/uiPromiseRegistry.d.ts.map +0 -1
  298. package/dist/protocols/protocol-v2/resources.d.ts +0 -30
  299. package/dist/protocols/protocol-v2/resources.d.ts.map +0 -1
  300. package/dist/protocols/protocol-v2/unlockPolicyRunner.d.ts +0 -22
  301. package/dist/protocols/protocol-v2/unlockPolicyRunner.d.ts.map +0 -1
  302. package/dist/types/api/detectDeviceConnectProtocol.d.ts +0 -4
  303. package/dist/types/api/detectDeviceConnectProtocol.d.ts.map +0 -1
  304. package/dist/utils/pro2Nft.d.ts +0 -31
  305. package/dist/utils/pro2Nft.d.ts.map +0 -1
  306. package/dist/utils/uiProgressThrottle.d.ts +0 -3
  307. package/dist/utils/uiProgressThrottle.d.ts.map +0 -1
  308. package/src/api/DetectDeviceConnectProtocol.ts +0 -18
  309. package/src/api/protocol-v2/DeviceUploadNft.ts +0 -197
  310. package/src/core/uiPromiseRegistry.ts +0 -63
  311. package/src/protocols/protocol-v2/resources.ts +0 -390
  312. package/src/protocols/protocol-v2/unlockPolicyRunner.ts +0 -131
  313. package/src/types/api/detectDeviceConnectProtocol.ts +0 -6
  314. package/src/utils/pro2Nft.ts +0 -142
  315. package/src/utils/uiProgressThrottle.ts +0 -63
@@ -1,15 +1,10 @@
1
1
  import { EDeviceType, HardwareErrorCode } from '@onekeyfe/hd-shared';
2
- import { DeviceSessionPinType, DeviceSessionSeedDomain } from '@onekeyfe/hd-transport';
2
+ import { DeviceSessionPinType } from '@onekeyfe/hd-transport';
3
3
 
4
4
  import GetPassphraseState from '../src/api/GetPassphraseState';
5
5
  import OpenWalletSession from '../src/api/OpenWalletSession';
6
6
  import { Device } from '../src/device/Device';
7
7
  import { deviceWalletSessionStore } from '../src/device/DeviceWalletSessionStore';
8
- import { DEVICE } from '../src/events';
9
- import {
10
- ensureProtocolV2WalletSessionUnlocked,
11
- getProtocolV2WalletSession,
12
- } from '../src/protocols/protocol-v2/walletSession';
13
8
 
14
9
  jest.mock('../src/data/config', () => ({
15
10
  getSDKVersion: jest.fn(() => '1.0.0'),
@@ -18,14 +13,10 @@ jest.mock('../src/data/config', () => ({
18
13
 
19
14
  const createDevice = ({
20
15
  passphraseProtection = true,
21
- unlockedAttachPin = false,
22
- refreshedUnlockedAttachPin = unlockedAttachPin,
23
16
  typedCall = jest.fn(),
24
17
  promptPassphrase = jest.fn(),
25
18
  }: {
26
19
  passphraseProtection?: boolean;
27
- unlockedAttachPin?: boolean;
28
- refreshedUnlockedAttachPin?: boolean;
29
20
  typedCall?: jest.Mock;
30
21
  promptPassphrase?: jest.Mock;
31
22
  } = {}) => {
@@ -34,8 +25,7 @@ const createDevice = ({
34
25
  features: {
35
26
  unlocked: true,
36
27
  passphraseProtection,
37
- attachToPinEnabled: unlockedAttachPin,
38
- unlockedAttachPin,
28
+ attachToPinEnabled: false,
39
29
  },
40
30
  commands: {
41
31
  typedCall: jest.fn((request: string, ...args: unknown[]) => {
@@ -44,9 +34,7 @@ const createDevice = ({
44
34
  message: {
45
35
  device_id: 'device-1',
46
36
  unlocked: true,
47
- attach_to_pin_enabled: unlockedAttachPin,
48
- unlocked_attach_pin: refreshedUnlockedAttachPin,
49
- unlocked_by_attach_to_pin: refreshedUnlockedAttachPin,
37
+ unlocked_attach_pin: false,
50
38
  passphrase_enabled: passphraseProtection,
51
39
  },
52
40
  };
@@ -55,21 +43,10 @@ const createDevice = ({
55
43
  }),
56
44
  promptPassphrase,
57
45
  },
58
- ensureProtocolV2RuntimeContext: jest.fn(() =>
59
- device.commands.typedCall('ProtocolInfoRequest', 'ProtocolInfo', {
60
- eventless_wallet_session: true,
61
- })
62
- ),
63
- getDeviceState: jest.fn(() =>
64
- Promise.resolve({
65
- identity: { deviceId: 'device-1' },
66
- status: {
67
- unlocked: device.features.unlocked,
68
- passphraseProtection: device.features.passphraseProtection,
69
- unlockedAttachPin: device.features.unlockedAttachPin,
70
- },
71
- })
72
- ),
46
+ getDeviceState: jest.fn().mockResolvedValue({
47
+ identity: { deviceId: 'device-1' },
48
+ status: { passphraseProtection },
49
+ }),
73
50
  getCurrentDeviceId: () => 'device-1',
74
51
  getCurrentPassphraseProtection: () => passphraseProtection,
75
52
  getInternalState: () =>
@@ -88,12 +65,8 @@ const createDevice = ({
88
65
  unlockDevice: jest.fn(),
89
66
  updateProtocolV2Status: jest.fn((status: Record<string, unknown>) => {
90
67
  device.features.unlocked = status.unlocked ?? device.features.unlocked;
91
- device.features.attachToPinEnabled =
92
- status.attach_to_pin_enabled ?? device.features.attachToPinEnabled;
93
68
  device.features.unlockedAttachPin =
94
- status.unlocked_by_attach_to_pin ??
95
- status.unlocked_attach_pin ??
96
- device.features.unlockedAttachPin;
69
+ status.unlocked_attach_pin ?? device.features.unlockedAttachPin;
97
70
  return device.features;
98
71
  }),
99
72
  initialize: jest.fn(),
@@ -109,148 +82,6 @@ describe('openWalletSession', () => {
109
82
  deviceWalletSessionStore.clear();
110
83
  });
111
84
 
112
- test('selects the standard wallet explicitly when passphrase is enabled', async () => {
113
- const typedCall = jest.fn((request: string) => {
114
- if (request === 'ProtocolInfoRequest') {
115
- return { message: { version: 2 } };
116
- }
117
- if (request === 'DeviceSessionAskPassphrase') {
118
- return { message: {} };
119
- }
120
- if (request === 'DeviceSessionGet') {
121
- return {
122
- message: {
123
- btc_test_address: 'standard-state',
124
- session_id: 'standard-session',
125
- },
126
- };
127
- }
128
- throw new Error(`Unexpected request: ${request}`);
129
- });
130
- const device = createDevice({ typedCall });
131
-
132
- await expect(
133
- getProtocolV2WalletSession(device as any, {
134
- onlyMainPin: true,
135
- })
136
- ).resolves.toMatchObject({
137
- passphraseState: 'standard-state',
138
- newSession: 'standard-session',
139
- });
140
-
141
- expect(device.unlockDevice).not.toHaveBeenCalled();
142
- expect(typedCall).toHaveBeenCalledWith('DeviceSessionAskPassphrase', 'Success', {
143
- passphrase: '',
144
- on_device: false,
145
- });
146
- expect(typedCall).toHaveBeenCalledWith('DeviceSessionGet', 'DeviceSession', {
147
- seed_domains: [],
148
- });
149
- });
150
-
151
- test('opens the standard wallet directly when passphrase is disabled', async () => {
152
- const typedCall = jest.fn((request: string) => {
153
- if (request === 'ProtocolInfoRequest') {
154
- return { message: { version: 2 } };
155
- }
156
- if (request === 'DeviceSessionGet') {
157
- return {
158
- message: {
159
- btc_test_address: 'standard-state',
160
- session_id: 'standard-session',
161
- },
162
- };
163
- }
164
- throw new Error(`Unexpected request: ${request}`);
165
- });
166
- const device = createDevice({ passphraseProtection: false, typedCall });
167
-
168
- await getProtocolV2WalletSession(device as any, { onlyMainPin: true });
169
-
170
- expect(typedCall).not.toHaveBeenCalledWith(
171
- 'DeviceSessionAskPassphrase',
172
- 'Success',
173
- expect.anything()
174
- );
175
- expect(typedCall).toHaveBeenCalledWith('DeviceSessionGet', 'DeviceSession', {
176
- seed_domains: [],
177
- });
178
- });
179
-
180
- test('does not treat an Attach PIN DeviceStatus as the Main wallet', async () => {
181
- const typedCall = jest.fn((request: string) => {
182
- if (request === 'ProtocolInfoRequest') {
183
- return { message: { version: 2 } };
184
- }
185
- if (request === 'DeviceSessionAskPassphrase') {
186
- return { message: {} };
187
- }
188
- if (request === 'DeviceSessionGet') {
189
- return {
190
- message: {
191
- btc_test_address: 'standard-state',
192
- session_id: 'standard-session',
193
- },
194
- };
195
- }
196
- throw new Error(`Unexpected request: ${request}`);
197
- });
198
- const device = createDevice({ typedCall });
199
- device.features.unlockedAttachPin = true;
200
-
201
- await getProtocolV2WalletSession(device as any, { onlyMainPin: true });
202
-
203
- expect(device.unlockDevice).toHaveBeenCalledWith(DeviceSessionPinType.Main, {
204
- source: 'wallet-session-coordinator',
205
- reason: 'open-wallet',
206
- deviceOnly: true,
207
- });
208
- });
209
-
210
- test('unlocks a locked Protocol V2 device before restoring a wallet session', async () => {
211
- const device = {
212
- commands: {
213
- typedCall: jest.fn().mockResolvedValue({ message: { unlocked: false } }),
214
- },
215
- isBootloader: jest.fn().mockReturnValue(false),
216
- isProtocolV2: jest.fn().mockReturnValue(true),
217
- isRomloader: jest.fn().mockReturnValue(false),
218
- state: { status: { unlocked: false } },
219
- unlockDevice: jest.fn().mockResolvedValue(undefined),
220
- updateProtocolV2Status: jest.fn(function updateProtocolV2Status(
221
- this: { state: { status: { unlocked: boolean } } },
222
- status: { unlocked?: boolean }
223
- ) {
224
- this.state.status.unlocked = status.unlocked ?? this.state.status.unlocked;
225
- }),
226
- };
227
-
228
- await expect(ensureProtocolV2WalletSessionUnlocked(device as any)).resolves.toBe(true);
229
- expect(device.commands.typedCall).toHaveBeenCalledWith('DeviceStatusGet', 'DeviceStatus', {});
230
- expect(device.unlockDevice).toHaveBeenCalledWith(DeviceSessionPinType.Main, {
231
- source: 'unlock-coordinator',
232
- reason: 'device-locked',
233
- deviceOnly: true,
234
- });
235
- });
236
-
237
- test('does not request PIN when wallet-session recovery finds the device unlocked', async () => {
238
- const device = {
239
- commands: {
240
- typedCall: jest.fn().mockResolvedValue({ message: { unlocked: true } }),
241
- },
242
- isBootloader: jest.fn().mockReturnValue(false),
243
- isProtocolV2: jest.fn().mockReturnValue(true),
244
- isRomloader: jest.fn().mockReturnValue(false),
245
- state: { status: { unlocked: true } },
246
- unlockDevice: jest.fn(),
247
- updateProtocolV2Status: jest.fn(),
248
- };
249
-
250
- await expect(ensureProtocolV2WalletSessionUnlocked(device as any)).resolves.toBe(false);
251
- expect(device.unlockDevice).not.toHaveBeenCalled();
252
- });
253
-
254
85
  test.each([{ useEmptyPassphrase: true }, { initSession: true }, {}])(
255
86
  'requires the explicit mode in the new public API: %p',
256
87
  legacyParams => {
@@ -302,9 +133,7 @@ describe('openWalletSession', () => {
302
133
  passphrase: 'host hidden wallet',
303
134
  on_device: false,
304
135
  });
305
- expect(typedCall).toHaveBeenNthCalledWith(3, 'DeviceSessionGet', 'DeviceSession', {
306
- seed_domains: [],
307
- });
136
+ expect(typedCall).toHaveBeenNthCalledWith(3, 'DeviceSessionGet', 'DeviceSession', {});
308
137
  });
309
138
 
310
139
  test('keeps Legacy Protocol V1 getPassphraseState parameterless', async () => {
@@ -422,9 +251,7 @@ describe('openWalletSession', () => {
422
251
  passphrase: 'host hidden wallet',
423
252
  on_device: false,
424
253
  });
425
- expect(typedCall).toHaveBeenNthCalledWith(3, 'DeviceSessionGet', 'DeviceSession', {
426
- seed_domains: [],
427
- });
254
+ expect(typedCall).toHaveBeenNthCalledWith(3, 'DeviceSessionGet', 'DeviceSession', {});
428
255
  });
429
256
 
430
257
  test('refreshes Pro2 status and unlocks before selecting a hidden wallet when locked', async () => {
@@ -446,24 +273,10 @@ describe('openWalletSession', () => {
446
273
  typedCall,
447
274
  promptPassphrase: jest.fn().mockResolvedValue({ passphraseOnDevice: true }),
448
275
  });
449
- device.getDeviceState = jest
450
- .fn()
451
- .mockResolvedValueOnce({
452
- identity: { deviceId: 'device-1' },
453
- status: {
454
- unlocked: false,
455
- passphraseProtection: null,
456
- unlockedAttachPin: null,
457
- },
458
- })
459
- .mockResolvedValue({
460
- identity: { deviceId: 'device-1' },
461
- status: {
462
- unlocked: true,
463
- passphraseProtection: true,
464
- unlockedAttachPin: false,
465
- },
466
- });
276
+ device.getDeviceState = jest.fn().mockResolvedValue({
277
+ identity: { deviceId: 'device-1' },
278
+ status: { unlocked: false, passphraseProtection: true },
279
+ });
467
280
  method.device = device as any;
468
281
 
469
282
  await expect(method.run()).resolves.toMatchObject({
@@ -517,12 +330,6 @@ describe('openWalletSession', () => {
517
330
  status.passphrase_enabled ?? device.features.passphraseProtection;
518
331
  return device.features;
519
332
  });
520
- device.unlockDevice = jest.fn().mockImplementation(() => {
521
- device.features.unlocked = true;
522
- device.features.passphraseProtection = true;
523
- device.features.unlockedAttachPin = false;
524
- return Promise.resolve(device.features);
525
- });
526
333
  method.device = device as any;
527
334
 
528
335
  await expect(method.run()).resolves.toEqual({
@@ -532,99 +339,11 @@ describe('openWalletSession', () => {
532
339
  passphraseState: 'hidden-state-after-unlock',
533
340
  resumed: false,
534
341
  });
535
- expect(device.unlockDevice).toHaveBeenCalledTimes(1);
342
+ expect(device.unlockDevice).not.toHaveBeenCalled();
536
343
  expect(promptPassphrase).toHaveBeenCalledTimes(1);
537
344
  });
538
345
 
539
- test('unlocks before wallet selection when the Protocol V2 wallet status is unknown', async () => {
540
- const typedCall = jest
541
- .fn()
542
- .mockResolvedValueOnce({ message: { version: 2 } })
543
- .mockResolvedValueOnce({ message: {} })
544
- .mockResolvedValueOnce({
545
- message: {
546
- btc_test_address: 'hidden-state-after-unknown-status',
547
- session_id: 'hidden-session-after-unknown-status',
548
- },
549
- });
550
- const promptPassphrase = jest.fn().mockResolvedValue({ passphrase: 'host hidden wallet' });
551
- const method = new OpenWalletSession({
552
- payload: { method: 'openWalletSession', connectId: 'connect-id', mode: 'select-hidden' },
553
- });
554
- method.init();
555
- const device = createDevice({ typedCall, promptPassphrase });
556
- device.getDeviceState = jest
557
- .fn()
558
- .mockResolvedValueOnce({
559
- identity: { deviceId: 'device-1' },
560
- status: {
561
- unlocked: undefined,
562
- passphraseProtection: null,
563
- unlockedAttachPin: null,
564
- },
565
- })
566
- .mockResolvedValue({
567
- identity: { deviceId: 'device-1' },
568
- status: {
569
- unlocked: true,
570
- passphraseProtection: true,
571
- unlockedAttachPin: false,
572
- },
573
- });
574
- device.unlockDevice = jest.fn().mockImplementation(() => {
575
- device.features.unlocked = true;
576
- device.features.passphraseProtection = true;
577
- device.features.unlockedAttachPin = false;
578
- return Promise.resolve(device.features);
579
- });
580
- method.device = device as any;
581
-
582
- await expect(method.run()).resolves.toMatchObject({
583
- walletType: 'hidden',
584
- passphraseState: 'hidden-state-after-unknown-status',
585
- });
586
- expect(device.unlockDevice).toHaveBeenCalledTimes(1);
587
- expect(device.unlockDevice.mock.invocationCallOrder[0]).toBeLessThan(
588
- promptPassphrase.mock.invocationCallOrder[0]
589
- );
590
- });
591
-
592
- test('rejects wallet selection when the post-unlock Protocol V2 status remains incomplete', async () => {
593
- const typedCall = jest
594
- .fn()
595
- .mockResolvedValueOnce({ message: { version: 2 } })
596
- .mockResolvedValueOnce({ message: {} })
597
- .mockResolvedValueOnce({
598
- message: {
599
- btc_test_address: 'hidden-state-from-incomplete-status',
600
- session_id: 'hidden-session-from-incomplete-status',
601
- },
602
- });
603
- const promptPassphrase = jest.fn().mockResolvedValue({ passphrase: 'host hidden wallet' });
604
- const method = new OpenWalletSession({
605
- payload: { method: 'openWalletSession', connectId: 'connect-id', mode: 'select-hidden' },
606
- });
607
- method.init();
608
- const device = createDevice({ typedCall, promptPassphrase });
609
- device.getDeviceState = jest.fn().mockResolvedValue({
610
- identity: { deviceId: 'device-1' },
611
- status: {
612
- unlocked: true,
613
- passphraseProtection: null,
614
- unlockedAttachPin: null,
615
- },
616
- });
617
- device.unlockDevice = jest.fn().mockResolvedValue(device.features);
618
- method.device = device as any;
619
-
620
- await expect(method.run()).rejects.toMatchObject({
621
- errorCode: HardwareErrorCode.DeviceInitializeFailed,
622
- });
623
- expect(device.unlockDevice).toHaveBeenCalledTimes(1);
624
- expect(promptPassphrase).not.toHaveBeenCalled();
625
- });
626
-
627
- test('rejects before prompting for a hidden wallet when Pro2 passphrase is disabled', async () => {
346
+ test('rejects a Pro2 standard-wallet fallback after selecting a hidden wallet', async () => {
628
347
  const typedCall = jest
629
348
  .fn()
630
349
  .mockResolvedValueOnce({ message: { version: 2 } })
@@ -651,114 +370,6 @@ describe('openWalletSession', () => {
651
370
  errorCode: HardwareErrorCode.DeviceNotOpenedPassphrase,
652
371
  });
653
372
  expect(device.clearInternalState).toHaveBeenCalled();
654
- expect(promptPassphrase).not.toHaveBeenCalled();
655
- expect(typedCall).not.toHaveBeenCalledWith(
656
- 'DeviceSessionAskPassphrase',
657
- 'Success',
658
- expect.anything()
659
- );
660
- });
661
-
662
- test('reuses the current Attach PIN session without reopening wallet selection', async () => {
663
- const typedCall = jest.fn((request: string) => {
664
- if (request === 'ProtocolInfoRequest') {
665
- return { message: { version: 2 } };
666
- }
667
- if (request === 'DeviceSessionAskPassphrase') {
668
- return { message: {} };
669
- }
670
- if (request === 'DeviceSessionGet') {
671
- return {
672
- message: {
673
- btc_test_address: 'attach-state',
674
- session_id: 'attach-session',
675
- },
676
- };
677
- }
678
- throw new Error(`Unexpected request: ${request}`);
679
- });
680
- const promptPassphrase = jest.fn().mockResolvedValue({ passphrase: 'must not be requested' });
681
- const method = new OpenWalletSession({
682
- payload: { method: 'openWalletSession', connectId: 'connect-id', mode: 'select-hidden' },
683
- });
684
- method.init();
685
- const device = createDevice({
686
- typedCall,
687
- promptPassphrase,
688
- unlockedAttachPin: true,
689
- });
690
- method.device = device as any;
691
-
692
- await expect(method.run()).resolves.toEqual({
693
- protocol: 'V2',
694
- walletType: 'hidden',
695
- deviceId: 'device-1',
696
- passphraseState: 'attach-state',
697
- resumed: false,
698
- });
699
- expect(promptPassphrase).not.toHaveBeenCalled();
700
- expect(device.unlockDevice).not.toHaveBeenCalled();
701
- expect(device.commands.typedCall).toHaveBeenCalledWith('DeviceSessionGet', 'DeviceSession', {
702
- seed_domains: [],
703
- });
704
- expect(device.commands.typedCall).not.toHaveBeenCalledWith(
705
- 'DeviceSessionAskPassphrase',
706
- 'Success',
707
- expect.anything()
708
- );
709
- expect(device.commands.typedCall).not.toHaveBeenCalledWith(
710
- 'DeviceSessionAskPin',
711
- 'Success',
712
- expect.anything()
713
- );
714
- });
715
-
716
- test('fails closed when the Attach PIN state changes before reading the current session', async () => {
717
- const typedCall = jest.fn((request: string) => {
718
- if (request === 'ProtocolInfoRequest') {
719
- return { message: { version: 2 } };
720
- }
721
- if (request === 'DeviceSessionAskPassphrase') {
722
- return { message: {} };
723
- }
724
- if (request === 'DeviceSessionGet') {
725
- return {
726
- message: {
727
- btc_test_address: 'unexpected-state',
728
- session_id: 'unexpected-session',
729
- },
730
- };
731
- }
732
- throw new Error(`Unexpected request: ${request}`);
733
- });
734
- const promptPassphrase = jest.fn().mockResolvedValue({ passphrase: 'must not be requested' });
735
- const method = new OpenWalletSession({
736
- payload: { method: 'openWalletSession', connectId: 'connect-id', mode: 'select-hidden' },
737
- });
738
- method.init();
739
- const device = createDevice({
740
- typedCall,
741
- promptPassphrase,
742
- unlockedAttachPin: true,
743
- refreshedUnlockedAttachPin: false,
744
- });
745
- method.device = device as any;
746
-
747
- await expect(method.run()).rejects.toMatchObject({
748
- errorCode: HardwareErrorCode.DeviceCheckUnlockTypeError,
749
- });
750
- expect(device.clearInternalState).toHaveBeenCalled();
751
- expect(promptPassphrase).not.toHaveBeenCalled();
752
- expect(device.commands.typedCall).not.toHaveBeenCalledWith(
753
- 'DeviceSessionAskPassphrase',
754
- 'Success',
755
- expect.anything()
756
- );
757
- expect(device.commands.typedCall).not.toHaveBeenCalledWith(
758
- 'DeviceSessionGet',
759
- 'DeviceSession',
760
- expect.anything()
761
- );
762
373
  });
763
374
 
764
375
  test('select-hidden starts a fresh hidden-wallet session on Protocol V2', async () => {
@@ -797,9 +408,7 @@ describe('openWalletSession', () => {
797
408
  passphrase: 'host hidden wallet',
798
409
  on_device: false,
799
410
  });
800
- expect(typedCall).toHaveBeenCalledWith('DeviceSessionGet', 'DeviceSession', {
801
- seed_domains: [],
802
- });
411
+ expect(typedCall).toHaveBeenCalledWith('DeviceSessionGet', 'DeviceSession', {});
803
412
  expect(promptPassphrase).toHaveBeenCalled();
804
413
  expect(deviceWalletSessionStore.get('device-1', 'new-hidden-state')).toBe('new-hidden-session');
805
414
  });
@@ -870,8 +479,6 @@ describe('openWalletSession', () => {
870
479
  });
871
480
  expect(typedCall).toHaveBeenCalledWith('DeviceSessionGet', 'DeviceSession', {
872
481
  session_id: 'known-session',
873
- btc_test_address: 'hidden-state',
874
- seed_domains: [],
875
482
  });
876
483
  expect(promptPassphrase).not.toHaveBeenCalled();
877
484
  });
@@ -1023,7 +630,6 @@ describe('openWalletSession', () => {
1023
630
  const typedCall = jest
1024
631
  .fn()
1025
632
  .mockResolvedValueOnce({ message: { version: 2 } })
1026
- .mockResolvedValueOnce({ message: {} })
1027
633
  .mockResolvedValueOnce({
1028
634
  message: {
1029
635
  btc_test_address: 'main-wallet-state',
@@ -1046,18 +652,12 @@ describe('openWalletSession', () => {
1046
652
  passphraseState: null,
1047
653
  resumed: false,
1048
654
  });
1049
- expect(typedCall).toHaveBeenCalledTimes(3);
655
+ expect(typedCall).toHaveBeenCalledTimes(2);
1050
656
  expect(typedCall).toHaveBeenCalledWith('ProtocolInfoRequest', 'ProtocolInfo', {
1051
657
  eventless_wallet_session: true,
1052
658
  });
1053
- expect(device.unlockDevice).not.toHaveBeenCalled();
1054
- expect(typedCall).toHaveBeenCalledWith('DeviceSessionAskPassphrase', 'Success', {
1055
- passphrase: '',
1056
- on_device: false,
1057
- });
1058
- expect(typedCall).toHaveBeenCalledWith('DeviceSessionGet', 'DeviceSession', {
1059
- seed_domains: [],
1060
- });
659
+ expect(device.unlockDevice).toHaveBeenCalledWith(DeviceSessionPinType.Main);
660
+ expect(typedCall).toHaveBeenCalledWith('DeviceSessionGet', 'DeviceSession', {});
1061
661
  expect(promptPassphrase).not.toHaveBeenCalled();
1062
662
  expect(device.passphraseState).toBeUndefined();
1063
663
  });
@@ -1066,7 +666,6 @@ describe('openWalletSession', () => {
1066
666
  const typedCall = jest
1067
667
  .fn()
1068
668
  .mockResolvedValueOnce({ message: { version: 2 } })
1069
- .mockResolvedValueOnce({ message: {} })
1070
669
  .mockResolvedValueOnce({
1071
670
  message: {
1072
671
  btc_test_address: 'main-wallet-state',
@@ -1087,11 +686,7 @@ describe('openWalletSession', () => {
1087
686
  })
1088
687
  .mockResolvedValueOnce({
1089
688
  identity: { deviceId: 'device-1' },
1090
- status: {
1091
- unlocked: true,
1092
- passphraseProtection: true,
1093
- unlockedAttachPin: false,
1094
- },
689
+ status: { passphraseProtection: true },
1095
690
  });
1096
691
  device.unlockDevice = jest.fn().mockImplementation(() => {
1097
692
  device.features.unlocked = true;
@@ -1106,11 +701,7 @@ describe('openWalletSession', () => {
1106
701
  passphraseState: null,
1107
702
  resumed: false,
1108
703
  });
1109
- expect(device.unlockDevice).toHaveBeenCalledWith(DeviceSessionPinType.Main, {
1110
- source: 'wallet-session-coordinator',
1111
- reason: 'open-wallet',
1112
- deviceOnly: true,
1113
- });
704
+ expect(device.unlockDevice).toHaveBeenCalledWith(DeviceSessionPinType.Main);
1114
705
  expect(device.getDeviceState).toHaveBeenCalledTimes(2);
1115
706
  });
1116
707
 
@@ -1118,7 +709,6 @@ describe('openWalletSession', () => {
1118
709
  const typedCall = jest
1119
710
  .fn()
1120
711
  .mockResolvedValueOnce({ message: { version: 2 } })
1121
- .mockResolvedValueOnce({ message: {} })
1122
712
  .mockResolvedValueOnce({
1123
713
  message: {
1124
714
  btc_test_address: 'main-wallet-state',
@@ -1131,24 +721,6 @@ describe('openWalletSession', () => {
1131
721
  method.init();
1132
722
  const device = createDevice({ typedCall });
1133
723
  device.features.unlockedAttachPin = true;
1134
- device.getDeviceState = jest
1135
- .fn()
1136
- .mockResolvedValueOnce({
1137
- identity: { deviceId: 'device-1' },
1138
- status: {
1139
- unlocked: true,
1140
- unlockedAttachPin: true,
1141
- passphraseProtection: true,
1142
- },
1143
- })
1144
- .mockResolvedValue({
1145
- identity: { deviceId: 'device-1' },
1146
- status: {
1147
- unlocked: true,
1148
- unlockedAttachPin: false,
1149
- passphraseProtection: true,
1150
- },
1151
- });
1152
724
  device.unlockDevice = jest.fn().mockImplementation(() => {
1153
725
  device.features.unlockedAttachPin = false;
1154
726
  return Promise.resolve(device.features);
@@ -1159,14 +731,8 @@ describe('openWalletSession', () => {
1159
731
  walletType: 'standard',
1160
732
  passphraseState: null,
1161
733
  });
1162
- expect(device.unlockDevice).toHaveBeenCalledWith(DeviceSessionPinType.Main, {
1163
- source: 'wallet-session-coordinator',
1164
- reason: 'open-wallet',
1165
- deviceOnly: true,
1166
- });
1167
- expect(typedCall).toHaveBeenCalledWith('DeviceSessionGet', 'DeviceSession', {
1168
- seed_domains: [],
1169
- });
734
+ expect(device.unlockDevice).toHaveBeenCalledWith(DeviceSessionPinType.Main);
735
+ expect(typedCall).toHaveBeenCalledWith('DeviceSessionGet', 'DeviceSession', {});
1170
736
  });
1171
737
 
1172
738
  test('selects a hidden wallet without exposing the internal device session', async () => {
@@ -1200,9 +766,7 @@ describe('openWalletSession', () => {
1200
766
  passphrase: 'host hidden wallet',
1201
767
  on_device: false,
1202
768
  });
1203
- expect(typedCall).toHaveBeenCalledWith('DeviceSessionGet', 'DeviceSession', {
1204
- seed_domains: [],
1205
- });
769
+ expect(typedCall).toHaveBeenCalledWith('DeviceSessionGet', 'DeviceSession', {});
1206
770
  expect(promptPassphrase).toHaveBeenCalled();
1207
771
  expect(device.passphraseState).toBeUndefined();
1208
772
  expect(deviceWalletSessionStore.get('device-1', 'hidden-state')).toBe('hidden-session');
@@ -1231,9 +795,7 @@ describe('openWalletSession', () => {
1231
795
  passphrase: 'host hidden wallet',
1232
796
  on_device: false,
1233
797
  });
1234
- expect(typedCall).toHaveBeenCalledWith('DeviceSessionGet', 'DeviceSession', {
1235
- seed_domains: [],
1236
- });
798
+ expect(typedCall).toHaveBeenCalledWith('DeviceSessionGet', 'DeviceSession', {});
1237
799
  });
1238
800
 
1239
801
  test('selects an on-device passphrase wallet with an explicit on_device request', async () => {
@@ -1249,28 +811,7 @@ describe('openWalletSession', () => {
1249
811
  payload: { method: 'openWalletSession', connectId: 'connect-id', mode: 'select-hidden' },
1250
812
  });
1251
813
  method.init();
1252
- const device = createDevice({ typedCall, promptPassphrase });
1253
- const passphraseInteraction = {
1254
- interactionId: 'interaction-1',
1255
- phaseId: 'interaction-1:phase-1',
1256
- sequence: 1,
1257
- phase: 'passphrase',
1258
- transition: 'start',
1259
- protocol: 'V2',
1260
- } as const;
1261
- const passphraseOnDeviceInteraction = {
1262
- interactionId: 'interaction-1',
1263
- phaseId: 'interaction-1:phase-2',
1264
- sequence: 2,
1265
- phase: 'passphrase-on-device',
1266
- transition: 'start',
1267
- protocol: 'V2',
1268
- } as const;
1269
- device.createProtocolV2UiPhaseMetadata = jest
1270
- .fn()
1271
- .mockReturnValueOnce(passphraseInteraction)
1272
- .mockReturnValueOnce(passphraseOnDeviceInteraction);
1273
- method.device = device as any;
814
+ method.device = createDevice({ typedCall, promptPassphrase }) as any;
1274
815
 
1275
816
  await expect(method.run()).resolves.toMatchObject({
1276
817
  walletType: 'hidden',
@@ -1279,19 +820,7 @@ describe('openWalletSession', () => {
1279
820
  expect(typedCall).toHaveBeenNthCalledWith(2, 'DeviceSessionAskPassphrase', 'Success', {
1280
821
  on_device: true,
1281
822
  });
1282
- expect(typedCall).toHaveBeenNthCalledWith(3, 'DeviceSessionGet', 'DeviceSession', {
1283
- seed_domains: [],
1284
- });
1285
- expect(device.createProtocolV2UiPhaseMetadata).toHaveBeenNthCalledWith(
1286
- 2,
1287
- 'passphrase-on-device',
1288
- 'start'
1289
- );
1290
- expect(device.emit).toHaveBeenCalledWith(DEVICE.PASSPHRASE_ON_DEVICE, device, {
1291
- source: 'wallet-session-coordinator',
1292
- reason: 'open-wallet',
1293
- interaction: passphraseOnDeviceInteraction,
1294
- });
823
+ expect(typedCall).toHaveBeenNthCalledWith(3, 'DeviceSessionGet', 'DeviceSession', {});
1295
824
  });
1296
825
 
1297
826
  test('forwards a host passphrase to Pro2 firmware', async () => {
@@ -1333,9 +862,7 @@ describe('openWalletSession', () => {
1333
862
  passphrase: 'host hidden wallet',
1334
863
  on_device: false,
1335
864
  });
1336
- expect(typedCall).toHaveBeenNthCalledWith(3, 'DeviceSessionGet', 'DeviceSession', {
1337
- seed_domains: [],
1338
- });
865
+ expect(typedCall).toHaveBeenNthCalledWith(3, 'DeviceSessionGet', 'DeviceSession', {});
1339
866
  });
1340
867
 
1341
868
  test('normalizes a Unicode Host passphrase before sending it to Pro2 firmware', async () => {
@@ -1412,12 +939,8 @@ describe('openWalletSession', () => {
1412
939
  },
1413
940
  { cancelDeviceOnReject: false }
1414
941
  );
1415
- expect(device.unlockDevice).toHaveBeenCalledWith(DeviceSessionPinType.AttachToPin, {
1416
- emitUiEvent: false,
1417
- });
1418
- expect(typedCall).toHaveBeenCalledWith('DeviceSessionGet', 'DeviceSession', {
1419
- seed_domains: [],
1420
- });
942
+ expect(device.unlockDevice).toHaveBeenCalledWith(DeviceSessionPinType.AttachToPin);
943
+ expect(typedCall).toHaveBeenCalledWith('DeviceSessionGet', 'DeviceSession', {});
1421
944
  });
1422
945
 
1423
946
  test('uses the complete Attach PIN wire flow without a main PIN unlock', async () => {
@@ -1446,7 +969,7 @@ describe('openWalletSession', () => {
1446
969
  ['ProtocolInfoRequest', 'ProtocolInfo', { eventless_wallet_session: true }],
1447
970
  ['DeviceSessionAskPin', 'Success', { type: DeviceSessionPinType.AttachToPin }],
1448
971
  ['DeviceStatusGet', 'DeviceStatus', {}],
1449
- ['DeviceSessionGet', 'DeviceSession', { seed_domains: [] }],
972
+ ['DeviceSessionGet', 'DeviceSession', {}],
1450
973
  ]);
1451
974
  expect(device.commands.typedCall).not.toHaveBeenCalledWith('DeviceSessionAskPin', 'Success', {
1452
975
  type: DeviceSessionPinType.Main,
@@ -1503,7 +1026,7 @@ describe('openWalletSession', () => {
1503
1026
 
1504
1027
  await expect(method.run()).rejects.toThrow(message);
1505
1028
  expect(typedCall).toHaveBeenCalledTimes(2);
1506
- expect(typedCall.mock.calls.some(([name]) => name === 'DeviceSessionGet')).toBe(false);
1029
+ expect(typedCall).not.toHaveBeenCalledWith('DeviceSessionGet', 'DeviceSession', {});
1507
1030
  }
1508
1031
  );
1509
1032
 
@@ -1657,8 +1180,6 @@ describe('openWalletSession', () => {
1657
1180
  });
1658
1181
  expect(typedCall).toHaveBeenCalledWith('DeviceSessionGet', 'DeviceSession', {
1659
1182
  session_id: 'known-session',
1660
- btc_test_address: 'hidden-state',
1661
- seed_domains: [],
1662
1183
  });
1663
1184
  expect(promptPassphrase).not.toHaveBeenCalled();
1664
1185
  });
@@ -1694,11 +1215,7 @@ describe('openWalletSession', () => {
1694
1215
  })
1695
1216
  .mockResolvedValueOnce({
1696
1217
  identity: { deviceId: 'device-1' },
1697
- status: {
1698
- unlocked: true,
1699
- passphraseProtection: true,
1700
- unlockedAttachPin: false,
1701
- },
1218
+ status: { passphraseProtection: true },
1702
1219
  });
1703
1220
  device.unlockDevice = jest.fn().mockImplementation(() => {
1704
1221
  device.features.unlocked = true;
@@ -1717,8 +1234,6 @@ describe('openWalletSession', () => {
1717
1234
  expect(device.getDeviceState).toHaveBeenCalledTimes(2);
1718
1235
  expect(typedCall).toHaveBeenCalledWith('DeviceSessionGet', 'DeviceSession', {
1719
1236
  session_id: 'known-session',
1720
- btc_test_address: 'hidden-state',
1721
- seed_domains: [],
1722
1237
  });
1723
1238
  const sessionGetCall = typedCall.mock.calls.findIndex(
1724
1239
  ([requestName]) => requestName === 'DeviceSessionGet'
@@ -1756,11 +1271,7 @@ describe('openWalletSession', () => {
1756
1271
  })
1757
1272
  .mockResolvedValueOnce({
1758
1273
  identity: { deviceId: 'other-device' },
1759
- status: {
1760
- unlocked: true,
1761
- passphraseProtection: true,
1762
- unlockedAttachPin: false,
1763
- },
1274
+ status: { passphraseProtection: true },
1764
1275
  });
1765
1276
  device.unlockDevice = jest.fn().mockImplementation(() => {
1766
1277
  device.features.unlocked = true;
@@ -1815,8 +1326,6 @@ describe('openWalletSession', () => {
1815
1326
  });
1816
1327
  expect(typedCall).toHaveBeenCalledWith('DeviceSessionGet', 'DeviceSession', {
1817
1328
  session_id: 'expired-session',
1818
- btc_test_address: 'hidden-state',
1819
- seed_domains: [],
1820
1329
  });
1821
1330
  expect(promptPassphrase).toHaveBeenCalledTimes(1);
1822
1331
  expect(deviceWalletSessionStore.get('device-1', 'hidden-state')).toBe('renewed-session');
@@ -1826,6 +1335,7 @@ describe('openWalletSession', () => {
1826
1335
  const typedCall = jest
1827
1336
  .fn()
1828
1337
  .mockResolvedValueOnce({ message: { version: 2 } })
1338
+ .mockResolvedValueOnce({ message: {} })
1829
1339
  .mockResolvedValueOnce({
1830
1340
  message: {
1831
1341
  btc_test_address: 'hidden-state',
@@ -1852,48 +1362,7 @@ describe('openWalletSession', () => {
1852
1362
  passphraseState: 'hidden-state',
1853
1363
  resumed: false,
1854
1364
  });
1855
- expect(typedCall).toHaveBeenCalledWith('DeviceSessionGet', 'DeviceSession', {
1856
- btc_test_address: 'hidden-state',
1857
- seed_domains: [],
1858
- });
1859
- expect(promptPassphrase).not.toHaveBeenCalled();
1365
+ expect(promptPassphrase).toHaveBeenCalledTimes(1);
1860
1366
  expect(deviceWalletSessionStore.get('device-1', 'hidden-state')).toBe('new-session');
1861
1367
  });
1862
-
1863
- test.each([false, true])('keeps deriveCardano API compatibility: %s', async deriveCardano => {
1864
- const typedCall = jest
1865
- .fn()
1866
- .mockResolvedValueOnce({ message: { version: 2 } })
1867
- .mockResolvedValueOnce({ message: {} })
1868
- .mockResolvedValueOnce({
1869
- message: {
1870
- btc_test_address: 'hidden-state',
1871
- session_id: 'new-session',
1872
- },
1873
- });
1874
- const method = new OpenWalletSession({
1875
- payload: {
1876
- method: 'openWalletSession',
1877
- connectId: 'connect-id',
1878
- mode: 'select-hidden',
1879
- deriveCardano,
1880
- },
1881
- });
1882
- method.init();
1883
- method.device = createDevice({
1884
- typedCall,
1885
- promptPassphrase: jest.fn().mockResolvedValue({ passphrase: 'host hidden wallet' }),
1886
- }) as any;
1887
-
1888
- await expect(method.run()).resolves.toMatchObject({
1889
- walletType: 'hidden',
1890
- passphraseState: 'hidden-state',
1891
- });
1892
- expect(typedCall).toHaveBeenCalledWith('DeviceSessionGet', 'DeviceSession', {
1893
- seed_domains: [
1894
- DeviceSessionSeedDomain.SeedDomain_Standard,
1895
- ...(deriveCardano ? [DeviceSessionSeedDomain.SeedDomain_Cardano] : []),
1896
- ],
1897
- });
1898
- });
1899
1368
  });