@onekeyfe/hd-core 1.2.0-alpha.50 → 1.2.0-alpha.52

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 (238) hide show
  1. package/__tests__/AllNetworkGetAddressBase.tracing.test.ts +0 -78
  2. package/__tests__/DeviceEventRegistration.test.ts +0 -6
  3. package/__tests__/check-all-firmware-release-protocol-v2.test.ts +3 -111
  4. package/__tests__/connectSettings.test.ts +47 -5
  5. package/__tests__/device-initialize-timeout.test.ts +56 -0
  6. package/__tests__/device-lifecycle-events.test.ts +3 -105
  7. package/__tests__/firmware-update/check-all-firmware-release.test.ts +175 -0
  8. package/__tests__/firmware-update/firmware-artifact-source.test.ts +119 -0
  9. package/__tests__/firmware-update/firmware-host-binding.test.ts +70 -0
  10. package/__tests__/firmware-update/firmware-preparation-error.test.ts +27 -0
  11. package/__tests__/firmware-update/firmware-update-bootloader-poll.test.ts +200 -0
  12. package/__tests__/firmware-update/firmware-update-capabilities.test.ts +13 -0
  13. package/__tests__/firmware-update/firmware-update-plan-bootloader-identity.test.ts +294 -0
  14. package/__tests__/firmware-update/firmware-update-plan.test.ts +593 -0
  15. package/__tests__/firmware-update/firmware-update-prepared-plan.test.ts +213 -0
  16. package/__tests__/firmware-update/firmware-update-v2-download-before-boot.test.ts +59 -31
  17. package/__tests__/firmware-update/firmware-update-v3-reconnect.test.ts +58 -0
  18. package/__tests__/firmware-update/firmware-upload-source.test.ts +70 -0
  19. package/__tests__/get-device-state.test.ts +12 -132
  20. package/__tests__/homescreen.test.ts +1 -41
  21. package/__tests__/logBlockEvent.test.ts +1 -1
  22. package/__tests__/method-protocol-support.test.ts +0 -19
  23. package/__tests__/open-wallet-session.test.ts +33 -446
  24. package/__tests__/protocol-v2-unlock-policy.test.ts +35 -196
  25. package/__tests__/protocol-v2.test.ts +1032 -1056
  26. package/__tests__/protocolV2UiInteraction.test.ts +0 -63
  27. package/__tests__/public-pro2-api-boundary.test.ts +0 -1
  28. package/__tests__/search-devices.test.ts +3 -12
  29. package/dist/api/BaseMethod.d.ts +1 -3
  30. package/dist/api/BaseMethod.d.ts.map +1 -1
  31. package/dist/api/CheckAllFirmwareRelease.d.ts.map +1 -1
  32. package/dist/api/FirmwareUpdate.d.ts.map +1 -1
  33. package/dist/api/FirmwareUpdateV2.d.ts +11 -0
  34. package/dist/api/FirmwareUpdateV2.d.ts.map +1 -1
  35. package/dist/api/FirmwareUpdateV3.d.ts +7 -3
  36. package/dist/api/FirmwareUpdateV3.d.ts.map +1 -1
  37. package/dist/api/FirmwareUpdateV4.d.ts +25 -9
  38. package/dist/api/FirmwareUpdateV4.d.ts.map +1 -1
  39. package/dist/api/GetPassphraseState.d.ts.map +1 -1
  40. package/dist/api/OpenWalletSession.d.ts.map +1 -1
  41. package/dist/api/SearchDevices.d.ts.map +1 -1
  42. package/dist/api/allnetwork/AllNetworkGetAddressBase.d.ts.map +1 -1
  43. package/dist/api/device/DeviceUpdateBootloader.d.ts +5 -1
  44. package/dist/api/device/DeviceUpdateBootloader.d.ts.map +1 -1
  45. package/dist/api/firmware/FirmwareArtifactSource.d.ts +25 -0
  46. package/dist/api/firmware/FirmwareArtifactSource.d.ts.map +1 -0
  47. package/dist/api/firmware/FirmwareHostBinding.d.ts +6 -0
  48. package/dist/api/firmware/FirmwareHostBinding.d.ts.map +1 -0
  49. package/dist/api/firmware/FirmwarePreparationError.d.ts +3 -0
  50. package/dist/api/firmware/FirmwarePreparationError.d.ts.map +1 -0
  51. package/dist/api/firmware/FirmwareUpdateBaseMethod.d.ts +9 -0
  52. package/dist/api/firmware/FirmwareUpdateBaseMethod.d.ts.map +1 -1
  53. package/dist/api/firmware/FirmwareUpdateCapabilities.d.ts +3 -0
  54. package/dist/api/firmware/FirmwareUpdateCapabilities.d.ts.map +1 -0
  55. package/dist/api/firmware/FirmwareUpdatePlan.d.ts +25 -0
  56. package/dist/api/firmware/FirmwareUpdatePlan.d.ts.map +1 -0
  57. package/dist/api/firmware/FirmwareUpdatePreparedPlan.d.ts +32 -0
  58. package/dist/api/firmware/FirmwareUpdatePreparedPlan.d.ts.map +1 -0
  59. package/dist/api/firmware/getBinary.d.ts +7 -0
  60. package/dist/api/firmware/getBinary.d.ts.map +1 -1
  61. package/dist/api/firmware/progressThrottle.d.ts +3 -0
  62. package/dist/api/firmware/progressThrottle.d.ts.map +1 -0
  63. package/dist/api/firmware/updateBootloader.d.ts +2 -0
  64. package/dist/api/firmware/updateBootloader.d.ts.map +1 -1
  65. package/dist/api/firmware/uploadFirmware.d.ts +9 -1
  66. package/dist/api/firmware/uploadFirmware.d.ts.map +1 -1
  67. package/dist/api/helpers/protocolV2FileWrite.d.ts +0 -2
  68. package/dist/api/helpers/protocolV2FileWrite.d.ts.map +1 -1
  69. package/dist/api/index.d.ts +0 -2
  70. package/dist/api/index.d.ts.map +1 -1
  71. package/dist/api/protocol-v2/ProtocolInfoRequest.d.ts.map +1 -1
  72. package/dist/api/stellar/StellarSignTransaction.d.ts +1 -1
  73. package/dist/core/deviceEventRegistration.d.ts +0 -2
  74. package/dist/core/deviceEventRegistration.d.ts.map +1 -1
  75. package/dist/core/index.d.ts.map +1 -1
  76. package/dist/data-manager/DataManager.d.ts +2 -4
  77. package/dist/data-manager/DataManager.d.ts.map +1 -1
  78. package/dist/data-manager/connectSettings.d.ts.map +1 -1
  79. package/dist/device/Device.d.ts +6 -29
  80. package/dist/device/Device.d.ts.map +1 -1
  81. package/dist/device/DeviceCommands.d.ts +4 -4
  82. package/dist/device/DevicePool.d.ts.map +1 -1
  83. package/dist/events/device.d.ts +0 -4
  84. package/dist/events/device.d.ts.map +1 -1
  85. package/dist/events/logBlockEvent.d.ts.map +1 -1
  86. package/dist/events/ui-promise.d.ts +2 -4
  87. package/dist/events/ui-promise.d.ts.map +1 -1
  88. package/dist/events/ui-request.d.ts +2 -31
  89. package/dist/events/ui-request.d.ts.map +1 -1
  90. package/dist/events/ui-response.d.ts +2 -10
  91. package/dist/events/ui-response.d.ts.map +1 -1
  92. package/dist/index.d.ts +230 -203
  93. package/dist/index.d.ts.map +1 -1
  94. package/dist/index.js +3469 -2419
  95. package/dist/inject.d.ts +1 -6
  96. package/dist/inject.d.ts.map +1 -1
  97. package/dist/lowLevelInject.d.ts.map +1 -1
  98. package/dist/protocols/protocol-v2/features.d.ts.map +1 -1
  99. package/dist/protocols/protocol-v2/lockedError.d.ts +2 -0
  100. package/dist/protocols/protocol-v2/lockedError.d.ts.map +1 -0
  101. package/dist/protocols/protocol-v2/uiInteraction.d.ts +4 -7
  102. package/dist/protocols/protocol-v2/uiInteraction.d.ts.map +1 -1
  103. package/dist/protocols/protocol-v2/unlockPolicy.d.ts +3 -1
  104. package/dist/protocols/protocol-v2/unlockPolicy.d.ts.map +1 -1
  105. package/dist/protocols/protocol-v2/unlockRetry.d.ts +10 -0
  106. package/dist/protocols/protocol-v2/unlockRetry.d.ts.map +1 -0
  107. package/dist/protocols/protocol-v2/walletSession.d.ts +1 -4
  108. package/dist/protocols/protocol-v2/walletSession.d.ts.map +1 -1
  109. package/dist/topLevelInject.d.ts.map +1 -1
  110. package/dist/types/api/checkAllFirmwareRelease.d.ts +4 -1
  111. package/dist/types/api/checkAllFirmwareRelease.d.ts.map +1 -1
  112. package/dist/types/api/deviceUpdateBootloader.d.ts +6 -0
  113. package/dist/types/api/deviceUpdateBootloader.d.ts.map +1 -1
  114. package/dist/types/api/export.d.ts +4 -1
  115. package/dist/types/api/export.d.ts.map +1 -1
  116. package/dist/types/api/firmwareUpdate.d.ts +70 -2
  117. package/dist/types/api/firmwareUpdate.d.ts.map +1 -1
  118. package/dist/types/api/firmwareUpdateCapabilities.d.ts +9 -0
  119. package/dist/types/api/firmwareUpdateCapabilities.d.ts.map +1 -0
  120. package/dist/types/api/firmwareUpdatePlan.d.ts +28 -0
  121. package/dist/types/api/firmwareUpdatePlan.d.ts.map +1 -0
  122. package/dist/types/api/firmwareUpdatePreparedPlan.d.ts +42 -0
  123. package/dist/types/api/firmwareUpdatePreparedPlan.d.ts.map +1 -0
  124. package/dist/types/api/index.d.ts +10 -7
  125. package/dist/types/api/index.d.ts.map +1 -1
  126. package/dist/types/api/protocolV2.d.ts +0 -3
  127. package/dist/types/api/protocolV2.d.ts.map +1 -1
  128. package/dist/types/params.d.ts +0 -1
  129. package/dist/types/params.d.ts.map +1 -1
  130. package/dist/types/settings.d.ts +13 -22
  131. package/dist/types/settings.d.ts.map +1 -1
  132. package/dist/utils/deviceFeaturesCompat.d.ts +1 -0
  133. package/dist/utils/deviceFeaturesCompat.d.ts.map +1 -1
  134. package/dist/utils/deviceFeaturesUtils.d.ts +0 -2
  135. package/dist/utils/deviceFeaturesUtils.d.ts.map +1 -1
  136. package/dist/utils/homescreen.d.ts +0 -4
  137. package/dist/utils/homescreen.d.ts.map +1 -1
  138. package/dist/utils/index.d.ts +1 -1
  139. package/dist/utils/index.d.ts.map +1 -1
  140. package/dist/utils/patch.d.ts +1 -1
  141. package/dist/utils/patch.d.ts.map +1 -1
  142. package/dist/utils/pro2Wallpaper.d.ts +0 -10
  143. package/dist/utils/pro2Wallpaper.d.ts.map +1 -1
  144. package/package.json +4 -4
  145. package/src/api/BaseMethod.ts +10 -8
  146. package/src/api/CheckAllFirmwareRelease.ts +53 -41
  147. package/src/api/FirmwareUpdate.ts +15 -7
  148. package/src/api/FirmwareUpdateV2.ts +316 -126
  149. package/src/api/FirmwareUpdateV3.ts +265 -63
  150. package/src/api/FirmwareUpdateV4.ts +937 -430
  151. package/src/api/GetPassphraseState.ts +1 -7
  152. package/src/api/OpenWalletSession.ts +17 -54
  153. package/src/api/SearchDevices.ts +1 -3
  154. package/src/api/allnetwork/AllNetworkGetAddressBase.ts +11 -32
  155. package/src/api/device/DeviceUnlock.ts +1 -1
  156. package/src/api/device/DeviceUpdateBootloader.ts +122 -6
  157. package/src/api/firmware/FirmwareArtifactSource.ts +278 -0
  158. package/src/api/firmware/FirmwareHostBinding.ts +100 -0
  159. package/src/api/firmware/FirmwarePreparationError.ts +12 -0
  160. package/src/api/firmware/FirmwareUpdateBaseMethod.ts +83 -16
  161. package/src/api/firmware/FirmwareUpdateCapabilities.ts +9 -0
  162. package/src/api/firmware/FirmwareUpdatePlan.ts +772 -0
  163. package/src/api/firmware/FirmwareUpdatePreparedPlan.ts +415 -0
  164. package/src/api/firmware/progressThrottle.ts +44 -0
  165. package/src/api/firmware/updateBootloader.ts +19 -4
  166. package/src/api/firmware/uploadFirmware.ts +144 -39
  167. package/src/api/helpers/protocolV2FileWrite.ts +4 -11
  168. package/src/api/index.ts +0 -2
  169. package/src/api/protocol-v2/ProtocolInfoRequest.ts +1 -3
  170. package/src/core/deviceEventRegistration.ts +0 -4
  171. package/src/core/index.ts +83 -167
  172. package/src/data/messages/messages-protocol-v2.json +0 -25
  173. package/src/data-manager/DataManager.ts +38 -67
  174. package/src/data-manager/connectSettings.ts +11 -0
  175. package/src/device/Device.ts +42 -257
  176. package/src/device/DevicePool.ts +2 -7
  177. package/src/events/device.ts +0 -4
  178. package/src/events/logBlockEvent.ts +0 -1
  179. package/src/events/ui-promise.ts +2 -4
  180. package/src/events/ui-request.ts +2 -36
  181. package/src/events/ui-response.ts +2 -12
  182. package/src/index.ts +5 -0
  183. package/src/inject.ts +24 -60
  184. package/src/lowLevelInject.ts +8 -7
  185. package/src/protocols/protocol-v2/features.ts +2 -9
  186. package/src/protocols/protocol-v2/lockedError.ts +10 -0
  187. package/src/protocols/protocol-v2/uiInteraction.ts +6 -46
  188. package/src/protocols/protocol-v2/unlockPolicy.ts +105 -1
  189. package/src/protocols/protocol-v2/unlockRetry.ts +109 -0
  190. package/src/protocols/protocol-v2/walletSession.ts +30 -169
  191. package/src/topLevelInject.ts +8 -7
  192. package/src/types/api/checkAllFirmwareRelease.ts +4 -1
  193. package/src/types/api/deviceUpdateBootloader.ts +6 -0
  194. package/src/types/api/export.ts +18 -0
  195. package/src/types/api/firmwareUpdate.ts +76 -3
  196. package/src/types/api/firmwareUpdateCapabilities.ts +9 -0
  197. package/src/types/api/firmwareUpdatePlan.ts +38 -0
  198. package/src/types/api/firmwareUpdatePreparedPlan.ts +53 -0
  199. package/src/types/api/index.ts +14 -13
  200. package/src/types/api/protocolV2.ts +0 -13
  201. package/src/types/params.ts +1 -7
  202. package/src/types/settings.ts +13 -42
  203. package/src/utils/deviceFeaturesCompat.ts +6 -0
  204. package/src/utils/deviceFeaturesUtils.ts +0 -4
  205. package/src/utils/homescreen.ts +6 -32
  206. package/src/utils/index.ts +1 -6
  207. package/src/utils/pro2Wallpaper.ts +8 -35
  208. package/__tests__/deviceUploadNft.test.ts +0 -293
  209. package/__tests__/pro2Nft.test.ts +0 -108
  210. package/__tests__/protocol-binding.test.ts +0 -89
  211. package/__tests__/protocol-v2-resources.test.ts +0 -284
  212. package/__tests__/protocol-v2-ui-lifecycle.test.ts +0 -91
  213. package/__tests__/uiProgressThrottle.test.ts +0 -74
  214. package/__tests__/uiPromiseRegistry.test.ts +0 -86
  215. package/dist/api/DetectDeviceConnectProtocol.d.ts +0 -7
  216. package/dist/api/DetectDeviceConnectProtocol.d.ts.map +0 -1
  217. package/dist/api/protocol-v2/DeviceUploadNft.d.ts +0 -31
  218. package/dist/api/protocol-v2/DeviceUploadNft.d.ts.map +0 -1
  219. package/dist/core/uiPromiseRegistry.d.ts +0 -4
  220. package/dist/core/uiPromiseRegistry.d.ts.map +0 -1
  221. package/dist/protocols/protocol-v2/resources.d.ts +0 -30
  222. package/dist/protocols/protocol-v2/resources.d.ts.map +0 -1
  223. package/dist/protocols/protocol-v2/unlockPolicyRunner.d.ts +0 -22
  224. package/dist/protocols/protocol-v2/unlockPolicyRunner.d.ts.map +0 -1
  225. package/dist/types/api/detectDeviceConnectProtocol.d.ts +0 -4
  226. package/dist/types/api/detectDeviceConnectProtocol.d.ts.map +0 -1
  227. package/dist/utils/pro2Nft.d.ts +0 -31
  228. package/dist/utils/pro2Nft.d.ts.map +0 -1
  229. package/dist/utils/uiProgressThrottle.d.ts +0 -3
  230. package/dist/utils/uiProgressThrottle.d.ts.map +0 -1
  231. package/src/api/DetectDeviceConnectProtocol.ts +0 -18
  232. package/src/api/protocol-v2/DeviceUploadNft.ts +0 -189
  233. package/src/core/uiPromiseRegistry.ts +0 -41
  234. package/src/protocols/protocol-v2/resources.ts +0 -359
  235. package/src/protocols/protocol-v2/unlockPolicyRunner.ts +0 -124
  236. package/src/types/api/detectDeviceConnectProtocol.ts +0 -7
  237. package/src/utils/pro2Nft.ts +0 -142
  238. 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'),
@@ -31,7 +26,6 @@ const createDevice = ({
31
26
  unlocked: true,
32
27
  passphraseProtection,
33
28
  attachToPinEnabled: false,
34
- unlockedAttachPin: false,
35
29
  },
36
30
  commands: {
37
31
  typedCall: jest.fn((request: string, ...args: unknown[]) => {
@@ -49,21 +43,10 @@ const createDevice = ({
49
43
  }),
50
44
  promptPassphrase,
51
45
  },
52
- ensureProtocolV2RuntimeContext: jest.fn(() =>
53
- device.commands.typedCall('ProtocolInfoRequest', 'ProtocolInfo', {
54
- eventless_wallet_session: true,
55
- })
56
- ),
57
- getDeviceState: jest.fn(() =>
58
- Promise.resolve({
59
- identity: { deviceId: 'device-1' },
60
- status: {
61
- unlocked: device.features.unlocked,
62
- passphraseProtection: device.features.passphraseProtection,
63
- unlockedAttachPin: device.features.unlockedAttachPin,
64
- },
65
- })
66
- ),
46
+ getDeviceState: jest.fn().mockResolvedValue({
47
+ identity: { deviceId: 'device-1' },
48
+ status: { passphraseProtection },
49
+ }),
67
50
  getCurrentDeviceId: () => 'device-1',
68
51
  getCurrentPassphraseProtection: () => passphraseProtection,
69
52
  getInternalState: () =>
@@ -99,148 +82,6 @@ describe('openWalletSession', () => {
99
82
  deviceWalletSessionStore.clear();
100
83
  });
101
84
 
102
- test('selects the standard wallet explicitly when passphrase is enabled', async () => {
103
- const typedCall = jest.fn((request: string) => {
104
- if (request === 'ProtocolInfoRequest') {
105
- return { message: { version: 2 } };
106
- }
107
- if (request === 'DeviceSessionAskPassphrase') {
108
- return { message: {} };
109
- }
110
- if (request === 'DeviceSessionGet') {
111
- return {
112
- message: {
113
- btc_test_address: 'standard-state',
114
- session_id: 'standard-session',
115
- },
116
- };
117
- }
118
- throw new Error(`Unexpected request: ${request}`);
119
- });
120
- const device = createDevice({ typedCall });
121
-
122
- await expect(
123
- getProtocolV2WalletSession(device as any, {
124
- onlyMainPin: true,
125
- })
126
- ).resolves.toMatchObject({
127
- passphraseState: 'standard-state',
128
- newSession: 'standard-session',
129
- });
130
-
131
- expect(device.unlockDevice).not.toHaveBeenCalled();
132
- expect(typedCall).toHaveBeenCalledWith('DeviceSessionAskPassphrase', 'Success', {
133
- passphrase: '',
134
- on_device: false,
135
- });
136
- expect(typedCall).toHaveBeenCalledWith('DeviceSessionGet', 'DeviceSession', {
137
- seed_domains: [],
138
- });
139
- });
140
-
141
- test('opens the standard wallet directly when passphrase is disabled', async () => {
142
- const typedCall = jest.fn((request: string) => {
143
- if (request === 'ProtocolInfoRequest') {
144
- return { message: { version: 2 } };
145
- }
146
- if (request === 'DeviceSessionGet') {
147
- return {
148
- message: {
149
- btc_test_address: 'standard-state',
150
- session_id: 'standard-session',
151
- },
152
- };
153
- }
154
- throw new Error(`Unexpected request: ${request}`);
155
- });
156
- const device = createDevice({ passphraseProtection: false, typedCall });
157
-
158
- await getProtocolV2WalletSession(device as any, { onlyMainPin: true });
159
-
160
- expect(typedCall).not.toHaveBeenCalledWith(
161
- 'DeviceSessionAskPassphrase',
162
- 'Success',
163
- expect.anything()
164
- );
165
- expect(typedCall).toHaveBeenCalledWith('DeviceSessionGet', 'DeviceSession', {
166
- seed_domains: [],
167
- });
168
- });
169
-
170
- test('does not treat an Attach PIN DeviceStatus as the Main wallet', async () => {
171
- const typedCall = jest.fn((request: string) => {
172
- if (request === 'ProtocolInfoRequest') {
173
- return { message: { version: 2 } };
174
- }
175
- if (request === 'DeviceSessionAskPassphrase') {
176
- return { message: {} };
177
- }
178
- if (request === 'DeviceSessionGet') {
179
- return {
180
- message: {
181
- btc_test_address: 'standard-state',
182
- session_id: 'standard-session',
183
- },
184
- };
185
- }
186
- throw new Error(`Unexpected request: ${request}`);
187
- });
188
- const device = createDevice({ typedCall });
189
- device.features.unlockedAttachPin = true;
190
-
191
- await getProtocolV2WalletSession(device as any, { onlyMainPin: true });
192
-
193
- expect(device.unlockDevice).toHaveBeenCalledWith(DeviceSessionPinType.Main, {
194
- source: 'wallet-session-coordinator',
195
- reason: 'open-wallet',
196
- deviceOnly: true,
197
- });
198
- });
199
-
200
- test('unlocks a locked Protocol V2 device before restoring a wallet session', async () => {
201
- const device = {
202
- commands: {
203
- typedCall: jest.fn().mockResolvedValue({ message: { unlocked: false } }),
204
- },
205
- isBootloader: jest.fn().mockReturnValue(false),
206
- isProtocolV2: jest.fn().mockReturnValue(true),
207
- isRomloader: jest.fn().mockReturnValue(false),
208
- state: { status: { unlocked: false } },
209
- unlockDevice: jest.fn().mockResolvedValue(undefined),
210
- updateProtocolV2Status: jest.fn(function updateProtocolV2Status(
211
- this: { state: { status: { unlocked: boolean } } },
212
- status: { unlocked?: boolean }
213
- ) {
214
- this.state.status.unlocked = status.unlocked ?? this.state.status.unlocked;
215
- }),
216
- };
217
-
218
- await expect(ensureProtocolV2WalletSessionUnlocked(device as any)).resolves.toBe(true);
219
- expect(device.commands.typedCall).toHaveBeenCalledWith('DeviceStatusGet', 'DeviceStatus', {});
220
- expect(device.unlockDevice).toHaveBeenCalledWith(DeviceSessionPinType.Main, {
221
- source: 'unlock-coordinator',
222
- reason: 'device-locked',
223
- deviceOnly: true,
224
- });
225
- });
226
-
227
- test('does not request PIN when wallet-session recovery finds the device unlocked', async () => {
228
- const device = {
229
- commands: {
230
- typedCall: jest.fn().mockResolvedValue({ message: { unlocked: true } }),
231
- },
232
- isBootloader: jest.fn().mockReturnValue(false),
233
- isProtocolV2: jest.fn().mockReturnValue(true),
234
- isRomloader: jest.fn().mockReturnValue(false),
235
- state: { status: { unlocked: true } },
236
- unlockDevice: jest.fn(),
237
- updateProtocolV2Status: jest.fn(),
238
- };
239
-
240
- await expect(ensureProtocolV2WalletSessionUnlocked(device as any)).resolves.toBe(false);
241
- expect(device.unlockDevice).not.toHaveBeenCalled();
242
- });
243
-
244
85
  test.each([{ useEmptyPassphrase: true }, { initSession: true }, {}])(
245
86
  'requires the explicit mode in the new public API: %p',
246
87
  legacyParams => {
@@ -292,9 +133,7 @@ describe('openWalletSession', () => {
292
133
  passphrase: 'host hidden wallet',
293
134
  on_device: false,
294
135
  });
295
- expect(typedCall).toHaveBeenNthCalledWith(3, 'DeviceSessionGet', 'DeviceSession', {
296
- seed_domains: [],
297
- });
136
+ expect(typedCall).toHaveBeenNthCalledWith(3, 'DeviceSessionGet', 'DeviceSession', {});
298
137
  });
299
138
 
300
139
  test('keeps Legacy Protocol V1 getPassphraseState parameterless', async () => {
@@ -412,9 +251,7 @@ describe('openWalletSession', () => {
412
251
  passphrase: 'host hidden wallet',
413
252
  on_device: false,
414
253
  });
415
- expect(typedCall).toHaveBeenNthCalledWith(3, 'DeviceSessionGet', 'DeviceSession', {
416
- seed_domains: [],
417
- });
254
+ expect(typedCall).toHaveBeenNthCalledWith(3, 'DeviceSessionGet', 'DeviceSession', {});
418
255
  });
419
256
 
420
257
  test('refreshes Pro2 status and unlocks before selecting a hidden wallet when locked', async () => {
@@ -436,24 +273,10 @@ describe('openWalletSession', () => {
436
273
  typedCall,
437
274
  promptPassphrase: jest.fn().mockResolvedValue({ passphraseOnDevice: true }),
438
275
  });
439
- device.getDeviceState = jest
440
- .fn()
441
- .mockResolvedValueOnce({
442
- identity: { deviceId: 'device-1' },
443
- status: {
444
- unlocked: false,
445
- passphraseProtection: null,
446
- unlockedAttachPin: null,
447
- },
448
- })
449
- .mockResolvedValue({
450
- identity: { deviceId: 'device-1' },
451
- status: {
452
- unlocked: true,
453
- passphraseProtection: true,
454
- unlockedAttachPin: false,
455
- },
456
- });
276
+ device.getDeviceState = jest.fn().mockResolvedValue({
277
+ identity: { deviceId: 'device-1' },
278
+ status: { unlocked: false, passphraseProtection: true },
279
+ });
457
280
  method.device = device as any;
458
281
 
459
282
  await expect(method.run()).resolves.toMatchObject({
@@ -507,12 +330,6 @@ describe('openWalletSession', () => {
507
330
  status.passphrase_enabled ?? device.features.passphraseProtection;
508
331
  return device.features;
509
332
  });
510
- device.unlockDevice = jest.fn().mockImplementation(() => {
511
- device.features.unlocked = true;
512
- device.features.passphraseProtection = true;
513
- device.features.unlockedAttachPin = false;
514
- return Promise.resolve(device.features);
515
- });
516
333
  method.device = device as any;
517
334
 
518
335
  await expect(method.run()).resolves.toEqual({
@@ -522,98 +339,10 @@ describe('openWalletSession', () => {
522
339
  passphraseState: 'hidden-state-after-unlock',
523
340
  resumed: false,
524
341
  });
525
- expect(device.unlockDevice).toHaveBeenCalledTimes(1);
342
+ expect(device.unlockDevice).not.toHaveBeenCalled();
526
343
  expect(promptPassphrase).toHaveBeenCalledTimes(1);
527
344
  });
528
345
 
529
- test('unlocks before wallet selection when the Protocol V2 wallet status is unknown', async () => {
530
- const typedCall = jest
531
- .fn()
532
- .mockResolvedValueOnce({ message: { version: 2 } })
533
- .mockResolvedValueOnce({ message: {} })
534
- .mockResolvedValueOnce({
535
- message: {
536
- btc_test_address: 'hidden-state-after-unknown-status',
537
- session_id: 'hidden-session-after-unknown-status',
538
- },
539
- });
540
- const promptPassphrase = jest.fn().mockResolvedValue({ passphrase: 'host hidden wallet' });
541
- const method = new OpenWalletSession({
542
- payload: { method: 'openWalletSession', connectId: 'connect-id', mode: 'select-hidden' },
543
- });
544
- method.init();
545
- const device = createDevice({ typedCall, promptPassphrase });
546
- device.getDeviceState = jest
547
- .fn()
548
- .mockResolvedValueOnce({
549
- identity: { deviceId: 'device-1' },
550
- status: {
551
- unlocked: undefined,
552
- passphraseProtection: null,
553
- unlockedAttachPin: null,
554
- },
555
- })
556
- .mockResolvedValue({
557
- identity: { deviceId: 'device-1' },
558
- status: {
559
- unlocked: true,
560
- passphraseProtection: true,
561
- unlockedAttachPin: false,
562
- },
563
- });
564
- device.unlockDevice = jest.fn().mockImplementation(() => {
565
- device.features.unlocked = true;
566
- device.features.passphraseProtection = true;
567
- device.features.unlockedAttachPin = false;
568
- return Promise.resolve(device.features);
569
- });
570
- method.device = device as any;
571
-
572
- await expect(method.run()).resolves.toMatchObject({
573
- walletType: 'hidden',
574
- passphraseState: 'hidden-state-after-unknown-status',
575
- });
576
- expect(device.unlockDevice).toHaveBeenCalledTimes(1);
577
- expect(device.unlockDevice.mock.invocationCallOrder[0]).toBeLessThan(
578
- promptPassphrase.mock.invocationCallOrder[0]
579
- );
580
- });
581
-
582
- test('rejects wallet selection when the post-unlock Protocol V2 status remains incomplete', async () => {
583
- const typedCall = jest
584
- .fn()
585
- .mockResolvedValueOnce({ message: { version: 2 } })
586
- .mockResolvedValueOnce({ message: {} })
587
- .mockResolvedValueOnce({
588
- message: {
589
- btc_test_address: 'hidden-state-from-incomplete-status',
590
- session_id: 'hidden-session-from-incomplete-status',
591
- },
592
- });
593
- const promptPassphrase = jest.fn().mockResolvedValue({ passphrase: 'host hidden wallet' });
594
- const method = new OpenWalletSession({
595
- payload: { method: 'openWalletSession', connectId: 'connect-id', mode: 'select-hidden' },
596
- });
597
- method.init();
598
- const device = createDevice({ typedCall, promptPassphrase });
599
- device.getDeviceState = jest.fn().mockResolvedValue({
600
- identity: { deviceId: 'device-1' },
601
- status: {
602
- unlocked: true,
603
- passphraseProtection: null,
604
- unlockedAttachPin: null,
605
- },
606
- });
607
- device.unlockDevice = jest.fn().mockResolvedValue(device.features);
608
- method.device = device as any;
609
-
610
- await expect(method.run()).rejects.toMatchObject({
611
- errorCode: HardwareErrorCode.DeviceInitializeFailed,
612
- });
613
- expect(device.unlockDevice).toHaveBeenCalledTimes(1);
614
- expect(promptPassphrase).not.toHaveBeenCalled();
615
- });
616
-
617
346
  test('rejects a Pro2 standard-wallet fallback after selecting a hidden wallet', async () => {
618
347
  const typedCall = jest
619
348
  .fn()
@@ -679,9 +408,7 @@ describe('openWalletSession', () => {
679
408
  passphrase: 'host hidden wallet',
680
409
  on_device: false,
681
410
  });
682
- expect(typedCall).toHaveBeenCalledWith('DeviceSessionGet', 'DeviceSession', {
683
- seed_domains: [],
684
- });
411
+ expect(typedCall).toHaveBeenCalledWith('DeviceSessionGet', 'DeviceSession', {});
685
412
  expect(promptPassphrase).toHaveBeenCalled();
686
413
  expect(deviceWalletSessionStore.get('device-1', 'new-hidden-state')).toBe('new-hidden-session');
687
414
  });
@@ -752,8 +479,6 @@ describe('openWalletSession', () => {
752
479
  });
753
480
  expect(typedCall).toHaveBeenCalledWith('DeviceSessionGet', 'DeviceSession', {
754
481
  session_id: 'known-session',
755
- btc_test_address: 'hidden-state',
756
- seed_domains: [],
757
482
  });
758
483
  expect(promptPassphrase).not.toHaveBeenCalled();
759
484
  });
@@ -905,7 +630,6 @@ describe('openWalletSession', () => {
905
630
  const typedCall = jest
906
631
  .fn()
907
632
  .mockResolvedValueOnce({ message: { version: 2 } })
908
- .mockResolvedValueOnce({ message: {} })
909
633
  .mockResolvedValueOnce({
910
634
  message: {
911
635
  btc_test_address: 'main-wallet-state',
@@ -928,18 +652,12 @@ describe('openWalletSession', () => {
928
652
  passphraseState: null,
929
653
  resumed: false,
930
654
  });
931
- expect(typedCall).toHaveBeenCalledTimes(3);
655
+ expect(typedCall).toHaveBeenCalledTimes(2);
932
656
  expect(typedCall).toHaveBeenCalledWith('ProtocolInfoRequest', 'ProtocolInfo', {
933
657
  eventless_wallet_session: true,
934
658
  });
935
- expect(device.unlockDevice).not.toHaveBeenCalled();
936
- expect(typedCall).toHaveBeenCalledWith('DeviceSessionAskPassphrase', 'Success', {
937
- passphrase: '',
938
- on_device: false,
939
- });
940
- expect(typedCall).toHaveBeenCalledWith('DeviceSessionGet', 'DeviceSession', {
941
- seed_domains: [],
942
- });
659
+ expect(device.unlockDevice).toHaveBeenCalledWith(DeviceSessionPinType.Main);
660
+ expect(typedCall).toHaveBeenCalledWith('DeviceSessionGet', 'DeviceSession', {});
943
661
  expect(promptPassphrase).not.toHaveBeenCalled();
944
662
  expect(device.passphraseState).toBeUndefined();
945
663
  });
@@ -948,7 +666,6 @@ describe('openWalletSession', () => {
948
666
  const typedCall = jest
949
667
  .fn()
950
668
  .mockResolvedValueOnce({ message: { version: 2 } })
951
- .mockResolvedValueOnce({ message: {} })
952
669
  .mockResolvedValueOnce({
953
670
  message: {
954
671
  btc_test_address: 'main-wallet-state',
@@ -969,11 +686,7 @@ describe('openWalletSession', () => {
969
686
  })
970
687
  .mockResolvedValueOnce({
971
688
  identity: { deviceId: 'device-1' },
972
- status: {
973
- unlocked: true,
974
- passphraseProtection: true,
975
- unlockedAttachPin: false,
976
- },
689
+ status: { passphraseProtection: true },
977
690
  });
978
691
  device.unlockDevice = jest.fn().mockImplementation(() => {
979
692
  device.features.unlocked = true;
@@ -988,11 +701,7 @@ describe('openWalletSession', () => {
988
701
  passphraseState: null,
989
702
  resumed: false,
990
703
  });
991
- expect(device.unlockDevice).toHaveBeenCalledWith(DeviceSessionPinType.Main, {
992
- source: 'wallet-session-coordinator',
993
- reason: 'open-wallet',
994
- deviceOnly: true,
995
- });
704
+ expect(device.unlockDevice).toHaveBeenCalledWith(DeviceSessionPinType.Main);
996
705
  expect(device.getDeviceState).toHaveBeenCalledTimes(2);
997
706
  });
998
707
 
@@ -1000,7 +709,6 @@ describe('openWalletSession', () => {
1000
709
  const typedCall = jest
1001
710
  .fn()
1002
711
  .mockResolvedValueOnce({ message: { version: 2 } })
1003
- .mockResolvedValueOnce({ message: {} })
1004
712
  .mockResolvedValueOnce({
1005
713
  message: {
1006
714
  btc_test_address: 'main-wallet-state',
@@ -1013,24 +721,6 @@ describe('openWalletSession', () => {
1013
721
  method.init();
1014
722
  const device = createDevice({ typedCall });
1015
723
  device.features.unlockedAttachPin = true;
1016
- device.getDeviceState = jest
1017
- .fn()
1018
- .mockResolvedValueOnce({
1019
- identity: { deviceId: 'device-1' },
1020
- status: {
1021
- unlocked: true,
1022
- unlockedAttachPin: true,
1023
- passphraseProtection: true,
1024
- },
1025
- })
1026
- .mockResolvedValue({
1027
- identity: { deviceId: 'device-1' },
1028
- status: {
1029
- unlocked: true,
1030
- unlockedAttachPin: false,
1031
- passphraseProtection: true,
1032
- },
1033
- });
1034
724
  device.unlockDevice = jest.fn().mockImplementation(() => {
1035
725
  device.features.unlockedAttachPin = false;
1036
726
  return Promise.resolve(device.features);
@@ -1041,14 +731,8 @@ describe('openWalletSession', () => {
1041
731
  walletType: 'standard',
1042
732
  passphraseState: null,
1043
733
  });
1044
- expect(device.unlockDevice).toHaveBeenCalledWith(DeviceSessionPinType.Main, {
1045
- source: 'wallet-session-coordinator',
1046
- reason: 'open-wallet',
1047
- deviceOnly: true,
1048
- });
1049
- expect(typedCall).toHaveBeenCalledWith('DeviceSessionGet', 'DeviceSession', {
1050
- seed_domains: [],
1051
- });
734
+ expect(device.unlockDevice).toHaveBeenCalledWith(DeviceSessionPinType.Main);
735
+ expect(typedCall).toHaveBeenCalledWith('DeviceSessionGet', 'DeviceSession', {});
1052
736
  });
1053
737
 
1054
738
  test('selects a hidden wallet without exposing the internal device session', async () => {
@@ -1082,9 +766,7 @@ describe('openWalletSession', () => {
1082
766
  passphrase: 'host hidden wallet',
1083
767
  on_device: false,
1084
768
  });
1085
- expect(typedCall).toHaveBeenCalledWith('DeviceSessionGet', 'DeviceSession', {
1086
- seed_domains: [],
1087
- });
769
+ expect(typedCall).toHaveBeenCalledWith('DeviceSessionGet', 'DeviceSession', {});
1088
770
  expect(promptPassphrase).toHaveBeenCalled();
1089
771
  expect(device.passphraseState).toBeUndefined();
1090
772
  expect(deviceWalletSessionStore.get('device-1', 'hidden-state')).toBe('hidden-session');
@@ -1113,9 +795,7 @@ describe('openWalletSession', () => {
1113
795
  passphrase: 'host hidden wallet',
1114
796
  on_device: false,
1115
797
  });
1116
- expect(typedCall).toHaveBeenCalledWith('DeviceSessionGet', 'DeviceSession', {
1117
- seed_domains: [],
1118
- });
798
+ expect(typedCall).toHaveBeenCalledWith('DeviceSessionGet', 'DeviceSession', {});
1119
799
  });
1120
800
 
1121
801
  test('selects an on-device passphrase wallet with an explicit on_device request', async () => {
@@ -1131,28 +811,7 @@ describe('openWalletSession', () => {
1131
811
  payload: { method: 'openWalletSession', connectId: 'connect-id', mode: 'select-hidden' },
1132
812
  });
1133
813
  method.init();
1134
- const device = createDevice({ typedCall, promptPassphrase });
1135
- const passphraseInteraction = {
1136
- interactionId: 'interaction-1',
1137
- phaseId: 'interaction-1:phase-1',
1138
- sequence: 1,
1139
- phase: 'passphrase',
1140
- transition: 'start',
1141
- protocol: 'V2',
1142
- } as const;
1143
- const passphraseOnDeviceInteraction = {
1144
- interactionId: 'interaction-1',
1145
- phaseId: 'interaction-1:phase-2',
1146
- sequence: 2,
1147
- phase: 'passphrase-on-device',
1148
- transition: 'start',
1149
- protocol: 'V2',
1150
- } as const;
1151
- device.createProtocolV2UiPhaseMetadata = jest
1152
- .fn()
1153
- .mockReturnValueOnce(passphraseInteraction)
1154
- .mockReturnValueOnce(passphraseOnDeviceInteraction);
1155
- method.device = device as any;
814
+ method.device = createDevice({ typedCall, promptPassphrase }) as any;
1156
815
 
1157
816
  await expect(method.run()).resolves.toMatchObject({
1158
817
  walletType: 'hidden',
@@ -1161,19 +820,7 @@ describe('openWalletSession', () => {
1161
820
  expect(typedCall).toHaveBeenNthCalledWith(2, 'DeviceSessionAskPassphrase', 'Success', {
1162
821
  on_device: true,
1163
822
  });
1164
- expect(typedCall).toHaveBeenNthCalledWith(3, 'DeviceSessionGet', 'DeviceSession', {
1165
- seed_domains: [],
1166
- });
1167
- expect(device.createProtocolV2UiPhaseMetadata).toHaveBeenNthCalledWith(
1168
- 2,
1169
- 'passphrase-on-device',
1170
- 'start'
1171
- );
1172
- expect(device.emit).toHaveBeenCalledWith(DEVICE.PASSPHRASE_ON_DEVICE, device, {
1173
- source: 'wallet-session-coordinator',
1174
- reason: 'open-wallet',
1175
- interaction: passphraseOnDeviceInteraction,
1176
- });
823
+ expect(typedCall).toHaveBeenNthCalledWith(3, 'DeviceSessionGet', 'DeviceSession', {});
1177
824
  });
1178
825
 
1179
826
  test('forwards a host passphrase to Pro2 firmware', async () => {
@@ -1215,9 +862,7 @@ describe('openWalletSession', () => {
1215
862
  passphrase: 'host hidden wallet',
1216
863
  on_device: false,
1217
864
  });
1218
- expect(typedCall).toHaveBeenNthCalledWith(3, 'DeviceSessionGet', 'DeviceSession', {
1219
- seed_domains: [],
1220
- });
865
+ expect(typedCall).toHaveBeenNthCalledWith(3, 'DeviceSessionGet', 'DeviceSession', {});
1221
866
  });
1222
867
 
1223
868
  test('normalizes a Unicode Host passphrase before sending it to Pro2 firmware', async () => {
@@ -1294,12 +939,8 @@ describe('openWalletSession', () => {
1294
939
  },
1295
940
  { cancelDeviceOnReject: false }
1296
941
  );
1297
- expect(device.unlockDevice).toHaveBeenCalledWith(DeviceSessionPinType.AttachToPin, {
1298
- emitUiEvent: false,
1299
- });
1300
- expect(typedCall).toHaveBeenCalledWith('DeviceSessionGet', 'DeviceSession', {
1301
- seed_domains: [],
1302
- });
942
+ expect(device.unlockDevice).toHaveBeenCalledWith(DeviceSessionPinType.AttachToPin);
943
+ expect(typedCall).toHaveBeenCalledWith('DeviceSessionGet', 'DeviceSession', {});
1303
944
  });
1304
945
 
1305
946
  test('uses the complete Attach PIN wire flow without a main PIN unlock', async () => {
@@ -1328,7 +969,7 @@ describe('openWalletSession', () => {
1328
969
  ['ProtocolInfoRequest', 'ProtocolInfo', { eventless_wallet_session: true }],
1329
970
  ['DeviceSessionAskPin', 'Success', { type: DeviceSessionPinType.AttachToPin }],
1330
971
  ['DeviceStatusGet', 'DeviceStatus', {}],
1331
- ['DeviceSessionGet', 'DeviceSession', { seed_domains: [] }],
972
+ ['DeviceSessionGet', 'DeviceSession', {}],
1332
973
  ]);
1333
974
  expect(device.commands.typedCall).not.toHaveBeenCalledWith('DeviceSessionAskPin', 'Success', {
1334
975
  type: DeviceSessionPinType.Main,
@@ -1385,7 +1026,7 @@ describe('openWalletSession', () => {
1385
1026
 
1386
1027
  await expect(method.run()).rejects.toThrow(message);
1387
1028
  expect(typedCall).toHaveBeenCalledTimes(2);
1388
- expect(typedCall.mock.calls.some(([name]) => name === 'DeviceSessionGet')).toBe(false);
1029
+ expect(typedCall).not.toHaveBeenCalledWith('DeviceSessionGet', 'DeviceSession', {});
1389
1030
  }
1390
1031
  );
1391
1032
 
@@ -1539,8 +1180,6 @@ describe('openWalletSession', () => {
1539
1180
  });
1540
1181
  expect(typedCall).toHaveBeenCalledWith('DeviceSessionGet', 'DeviceSession', {
1541
1182
  session_id: 'known-session',
1542
- btc_test_address: 'hidden-state',
1543
- seed_domains: [],
1544
1183
  });
1545
1184
  expect(promptPassphrase).not.toHaveBeenCalled();
1546
1185
  });
@@ -1576,11 +1215,7 @@ describe('openWalletSession', () => {
1576
1215
  })
1577
1216
  .mockResolvedValueOnce({
1578
1217
  identity: { deviceId: 'device-1' },
1579
- status: {
1580
- unlocked: true,
1581
- passphraseProtection: true,
1582
- unlockedAttachPin: false,
1583
- },
1218
+ status: { passphraseProtection: true },
1584
1219
  });
1585
1220
  device.unlockDevice = jest.fn().mockImplementation(() => {
1586
1221
  device.features.unlocked = true;
@@ -1599,8 +1234,6 @@ describe('openWalletSession', () => {
1599
1234
  expect(device.getDeviceState).toHaveBeenCalledTimes(2);
1600
1235
  expect(typedCall).toHaveBeenCalledWith('DeviceSessionGet', 'DeviceSession', {
1601
1236
  session_id: 'known-session',
1602
- btc_test_address: 'hidden-state',
1603
- seed_domains: [],
1604
1237
  });
1605
1238
  const sessionGetCall = typedCall.mock.calls.findIndex(
1606
1239
  ([requestName]) => requestName === 'DeviceSessionGet'
@@ -1638,11 +1271,7 @@ describe('openWalletSession', () => {
1638
1271
  })
1639
1272
  .mockResolvedValueOnce({
1640
1273
  identity: { deviceId: 'other-device' },
1641
- status: {
1642
- unlocked: true,
1643
- passphraseProtection: true,
1644
- unlockedAttachPin: false,
1645
- },
1274
+ status: { passphraseProtection: true },
1646
1275
  });
1647
1276
  device.unlockDevice = jest.fn().mockImplementation(() => {
1648
1277
  device.features.unlocked = true;
@@ -1697,8 +1326,6 @@ describe('openWalletSession', () => {
1697
1326
  });
1698
1327
  expect(typedCall).toHaveBeenCalledWith('DeviceSessionGet', 'DeviceSession', {
1699
1328
  session_id: 'expired-session',
1700
- btc_test_address: 'hidden-state',
1701
- seed_domains: [],
1702
1329
  });
1703
1330
  expect(promptPassphrase).toHaveBeenCalledTimes(1);
1704
1331
  expect(deviceWalletSessionStore.get('device-1', 'hidden-state')).toBe('renewed-session');
@@ -1708,6 +1335,7 @@ describe('openWalletSession', () => {
1708
1335
  const typedCall = jest
1709
1336
  .fn()
1710
1337
  .mockResolvedValueOnce({ message: { version: 2 } })
1338
+ .mockResolvedValueOnce({ message: {} })
1711
1339
  .mockResolvedValueOnce({
1712
1340
  message: {
1713
1341
  btc_test_address: 'hidden-state',
@@ -1734,48 +1362,7 @@ describe('openWalletSession', () => {
1734
1362
  passphraseState: 'hidden-state',
1735
1363
  resumed: false,
1736
1364
  });
1737
- expect(typedCall).toHaveBeenCalledWith('DeviceSessionGet', 'DeviceSession', {
1738
- btc_test_address: 'hidden-state',
1739
- seed_domains: [],
1740
- });
1741
- expect(promptPassphrase).not.toHaveBeenCalled();
1365
+ expect(promptPassphrase).toHaveBeenCalledTimes(1);
1742
1366
  expect(deviceWalletSessionStore.get('device-1', 'hidden-state')).toBe('new-session');
1743
1367
  });
1744
-
1745
- test.each([false, true])('keeps deriveCardano API compatibility: %s', async deriveCardano => {
1746
- const typedCall = jest
1747
- .fn()
1748
- .mockResolvedValueOnce({ message: { version: 2 } })
1749
- .mockResolvedValueOnce({ message: {} })
1750
- .mockResolvedValueOnce({
1751
- message: {
1752
- btc_test_address: 'hidden-state',
1753
- session_id: 'new-session',
1754
- },
1755
- });
1756
- const method = new OpenWalletSession({
1757
- payload: {
1758
- method: 'openWalletSession',
1759
- connectId: 'connect-id',
1760
- mode: 'select-hidden',
1761
- deriveCardano,
1762
- },
1763
- });
1764
- method.init();
1765
- method.device = createDevice({
1766
- typedCall,
1767
- promptPassphrase: jest.fn().mockResolvedValue({ passphrase: 'host hidden wallet' }),
1768
- }) as any;
1769
-
1770
- await expect(method.run()).resolves.toMatchObject({
1771
- walletType: 'hidden',
1772
- passphraseState: 'hidden-state',
1773
- });
1774
- expect(typedCall).toHaveBeenCalledWith('DeviceSessionGet', 'DeviceSession', {
1775
- seed_domains: [
1776
- DeviceSessionSeedDomain.SeedDomain_Standard,
1777
- ...(deriveCardano ? [DeviceSessionSeedDomain.SeedDomain_Cardano] : []),
1778
- ],
1779
- });
1780
- });
1781
1368
  });