@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,284 +0,0 @@
1
- import axios from 'axios';
2
- import { sha256 } from '@noble/hashes/sha256';
3
-
4
- import { DataManager } from '../src/data-manager';
5
- import {
6
- PROTOCOL_V2_RESOURCE_DEVICE_PATHS,
7
- PROTOCOL_V2_RESOURCE_TYPES,
8
- buildProtocolV2ResourceUpdatePlan,
9
- isProtocolV2ResourceFileValid,
10
- parseProtocolV2Resources,
11
- readProtocolV2ResourceInventory,
12
- } from '../src/protocols/protocol-v2/resources';
13
-
14
- import type {
15
- ConnectSettings,
16
- IProtocolV2BootResources,
17
- IProtocolV2Resource,
18
- RemoteConfigResponse,
19
- } from '../src/types';
20
-
21
- jest.mock('axios');
22
- jest.mock('../src/data/config', () => ({
23
- getSDKVersion: jest.fn(() => '1.0.0-test'),
24
- DEFAULT_DOMAIN: 'https://jssdk.onekey.so/1.0.0-test/',
25
- }));
26
-
27
- const bytesToHex = (bytes: Uint8Array) =>
28
- Array.from(bytes, byte => byte.toString(16).padStart(2, '0')).join('');
29
-
30
- const PROTOCOL_V2_OKPP_HEADER_SIZE = 0x52a0;
31
-
32
- const createResourceHeader = (headerHash: string) => {
33
- const header = new Uint8Array(PROTOCOL_V2_OKPP_HEADER_SIZE);
34
- const view = new DataView(header.buffer);
35
- 'OKPP'.split('').forEach((char, index) => {
36
- header[index] = char.charCodeAt(0);
37
- });
38
- 'RESC'.split('').forEach((char, index) => {
39
- header[0x08 + index] = char.charCodeAt(0);
40
- });
41
- view.setUint32(0x0c, header.byteLength, true);
42
- for (let index = 0; index < headerHash.length / 2; index++) {
43
- header[0x240 + index] = Number.parseInt(headerHash.slice(index * 2, index * 2 + 2), 16);
44
- }
45
- return header;
46
- };
47
-
48
- const resources: IProtocolV2Resource[] = PROTOCOL_V2_RESOURCE_TYPES.map((type, index) => ({
49
- type,
50
- url: `https://example.com/${type}.okpkg`,
51
- size: index + 100,
52
- fileHash: index.toString(16).padStart(64, '0'),
53
- headerHash: index.toString(16).padStart(128, '0'),
54
- }));
55
-
56
- const bootResources: IProtocolV2BootResources = {
57
- required: false,
58
- target: 'CRATE',
59
- url: 'https://example.com/boot-resources.crate.okpkg',
60
- size: 1234,
61
- fileHash: 'ab'.repeat(32),
62
- payloadHash: 'cd'.repeat(64),
63
- headerHash: 'ef'.repeat(64),
64
- };
65
-
66
- const createSettings = (configFetcher: ConnectSettings['configFetcher']): ConnectSettings =>
67
- ({
68
- env: 'node',
69
- fetchConfig: true,
70
- preRelease: true,
71
- configFetcher,
72
- } as ConnectSettings);
73
-
74
- const createRemoteConfig = (): RemoteConfigResponse =>
75
- ({
76
- classic: { firmware: [], ble: [] },
77
- classic1s: { firmware: [], ble: [] },
78
- classicpure: { firmware: [], ble: [] },
79
- mini: { firmware: [], ble: [] },
80
- touch: { firmware: [], ble: [] },
81
- pro: { firmware: [], ble: [] },
82
- pro2: { firmware: [], ble: [], resources: { stable: resources, boot: bootResources } },
83
- bridge: {},
84
- } as unknown as RemoteConfigResponse);
85
-
86
- describe('Pro2 resource configuration', () => {
87
- beforeEach(() => {
88
- jest.clearAllMocks();
89
- DataManager.lastCheckTimestamp = 0;
90
- });
91
-
92
- test('accepts exactly six resources and normalizes their deterministic order', () => {
93
- const parsed = parseProtocolV2Resources({
94
- stable: [...resources].reverse(),
95
- boot: bootResources,
96
- });
97
-
98
- expect(parsed?.stable.map(item => item.type)).toEqual(PROTOCOL_V2_RESOURCE_TYPES);
99
- expect(parsed?.boot).toEqual(bootResources);
100
- expect(PROTOCOL_V2_RESOURCE_DEVICE_PATHS.translations).toBe(
101
- 'vol0:/bundles/translations/translations.okpkg'
102
- );
103
- });
104
-
105
- test('rejects incomplete, duplicate, or malformed stable sets', () => {
106
- expect(() => parseProtocolV2Resources({ stable: resources.slice(1) })).toThrow(
107
- 'six unique resource types'
108
- );
109
- expect(() =>
110
- parseProtocolV2Resources({ stable: [...resources.slice(0, 5), resources[0]] })
111
- ).toThrow('six unique resource types');
112
- expect(() =>
113
- parseProtocolV2Resources({
114
- stable: resources.map((resource, index) =>
115
- index === 0 ? { ...resource, headerHash: 'bad' } : resource
116
- ),
117
- })
118
- ).toThrow('headerHash');
119
- });
120
-
121
- test('requires boot resources to remain optional and use a CRATE package', () => {
122
- expect(() =>
123
- parseProtocolV2Resources({
124
- stable: resources,
125
- boot: { ...bootResources, required: true },
126
- })
127
- ).toThrow('required flag');
128
- expect(() =>
129
- parseProtocolV2Resources({
130
- stable: resources,
131
- boot: { ...bootResources, target: 'RESC' },
132
- })
133
- ).toThrow('expected CRATE');
134
- });
135
-
136
- test('downloads nothing when all resource identities match', () => {
137
- const inventory = resources.map(({ type, size, headerHash }) => ({ type, size, headerHash }));
138
-
139
- expect(
140
- buildProtocolV2ResourceUpdatePlan({ resources, inventory, mode: 'application' })
141
- ).toEqual({ status: 'valid', resources: [] });
142
- });
143
-
144
- test('builds inventory from existing filesystem calls without ResourceInventoryGet', async () => {
145
- const installedResources = resources.map((resource, index) => ({
146
- ...resource,
147
- size: PROTOCOL_V2_OKPP_HEADER_SIZE + index + 1,
148
- }));
149
- const resourceByPath = new Map(
150
- installedResources.map(resource => [
151
- PROTOCOL_V2_RESOURCE_DEVICE_PATHS[resource.type],
152
- resource,
153
- ])
154
- );
155
- const typedCall = jest.fn(
156
- (requestType: string, _responseType: string, payload: Record<string, any>) => {
157
- if (requestType === 'ResourceInventoryGet') {
158
- throw new Error('ResourceInventoryGet is unavailable on released firmware');
159
- }
160
- if (requestType === 'FilesystemPathInfoQuery') {
161
- const resource = resourceByPath.get(payload.path);
162
- return {
163
- message: {
164
- exist: Boolean(resource),
165
- directory: false,
166
- size: resource?.size ?? 0,
167
- },
168
- };
169
- }
170
- if (requestType === 'FilesystemFileRead') {
171
- const resource = resourceByPath.get(payload.file.path);
172
- if (!resource) throw new Error('missing resource');
173
- const header = createResourceHeader(resource.headerHash);
174
- const offset = Number(payload.file.offset);
175
- const chunkLength = Number(payload.chunk_len);
176
- return {
177
- message: {
178
- data: header.slice(offset, offset + chunkLength),
179
- },
180
- };
181
- }
182
- throw new Error(`Unexpected request: ${requestType}`);
183
- }
184
- );
185
-
186
- await expect(
187
- readProtocolV2ResourceInventory({
188
- commands: { typedCall },
189
- resources: installedResources,
190
- chunkSize: 4000,
191
- })
192
- ).resolves.toEqual(
193
- installedResources.map(({ type, size, headerHash }) => ({ type, size, headerHash }))
194
- );
195
- expect(typedCall.mock.calls.some(call => call[0] === 'ResourceInventoryGet')).toBe(false);
196
- expect(typedCall.mock.calls.filter(call => call[0] === 'FilesystemPathInfoQuery')).toHaveLength(
197
- 6
198
- );
199
- expect(typedCall.mock.calls.some(call => call[0] === 'FilesystemFileRead')).toBe(true);
200
- });
201
-
202
- test('selects only the changed or missing resource in application mode', () => {
203
- const inventory = resources
204
- .filter(resource => resource.type !== 'noto')
205
- .map(({ type, size, headerHash }) => ({
206
- type,
207
- size: type === 'images' ? size + 1 : size,
208
- headerHash,
209
- }));
210
-
211
- const result = buildProtocolV2ResourceUpdatePlan({
212
- resources,
213
- inventory,
214
- mode: 'application',
215
- });
216
-
217
- expect(result.status).toBe('outdated');
218
- expect(result.resources.map(resource => resource.type)).toEqual(['images', 'noto']);
219
- });
220
-
221
- test('reports unknown without an application inventory and selects all in recovery mode', () => {
222
- expect(buildProtocolV2ResourceUpdatePlan({ resources, mode: 'application' })).toEqual({
223
- status: 'unknown',
224
- resources: [],
225
- });
226
- expect(
227
- buildProtocolV2ResourceUpdatePlan({ resources, mode: 'bootloader-recovery' }).resources
228
- ).toHaveLength(6);
229
- });
230
-
231
- test('uses a filesystem inventory for incremental recovery mode updates', () => {
232
- const inventory = resources.slice(1).map(({ type, size, headerHash }) => ({
233
- type,
234
- size,
235
- headerHash,
236
- }));
237
-
238
- expect(
239
- buildProtocolV2ResourceUpdatePlan({
240
- resources,
241
- inventory,
242
- mode: 'bootloader-recovery',
243
- }).resources.map(resource => resource.type)
244
- ).toEqual(['images']);
245
- });
246
-
247
- test('verifies both full file size and SHA-256 before transfer', () => {
248
- const bytes = new Uint8Array([1, 2, 3]);
249
- const binary = bytes.buffer;
250
- const identity = { size: bytes.byteLength, fileHash: bytesToHex(sha256(bytes)) };
251
-
252
- expect(isProtocolV2ResourceFileValid(binary, identity)).toBe(true);
253
- expect(isProtocolV2ResourceFileValid(binary, { ...identity, size: 4 })).toBe(false);
254
- expect(isProtocolV2ResourceFileValid(binary, { ...identity, fileHash: '0'.repeat(64) })).toBe(
255
- false
256
- );
257
- });
258
-
259
- test('applies a validated pre-release config and exposes the stable resource set', async () => {
260
- const configFetcher = jest.fn().mockResolvedValue(createRemoteConfig());
261
-
262
- await expect(DataManager.load(createSettings(configFetcher))).resolves.toBe(true);
263
-
264
- expect(configFetcher).toHaveBeenCalledWith(
265
- expect.stringMatching(/^https:\/\/data\.onekey\.so\/pre-config\.json\?noCache=/)
266
- );
267
- expect(DataManager.getProtocolV2Resources()).toEqual(resources);
268
- expect(DataManager.getProtocolV2BootResources()).toEqual(bootResources);
269
- });
270
-
271
- test('does not advance the cache timestamp when refresh fails', async () => {
272
- jest.spyOn(axios, 'get').mockRejectedValue(new Error('offline'));
273
- const settings = createSettings(jest.fn().mockResolvedValue(null));
274
- DataManager.settings = settings;
275
-
276
- await DataManager.checkAndReloadData();
277
-
278
- expect(DataManager.lastCheckTimestamp).toBe(0);
279
- await expect(DataManager.forceReloadData()).rejects.toThrow(
280
- 'Unable to refresh the latest remote config'
281
- );
282
- expect(DataManager.lastCheckTimestamp).toBe(0);
283
- });
284
- });
@@ -1,91 +0,0 @@
1
- import { DeviceSessionPinType } from '@onekeyfe/hd-transport';
2
-
3
- import { DEVICE } from '../src/events';
4
- import { Device } from '../src/device/Device';
5
-
6
- jest.mock('../src/data/config', () => ({
7
- getSDKVersion: jest.fn(() => '1.0.0-test'),
8
- DEFAULT_DOMAIN: 'https://example.com/',
9
- }));
10
-
11
- describe('Protocol V2 UI interaction lifecycle', () => {
12
- test('synthesizes finish metadata for a progress-only operation', () => {
13
- const device = new Device({ id: 'connect-progress' } as any);
14
- device.isProtocolV2 = jest.fn(() => true);
15
- device.beginProtocolV2UiInteraction();
16
-
17
- const metadata = device.finishProtocolV2UiInteraction('succeeded', {
18
- ensureMetadata: true,
19
- });
20
-
21
- expect(metadata).toMatchObject({
22
- phase: 'processing',
23
- transition: 'finish',
24
- outcome: 'succeeded',
25
- protocol: 'V2',
26
- });
27
- });
28
-
29
- test('keeps finish metadata after the Protocol V2 transport is released', () => {
30
- const device = new Device({ id: 'connect-released' } as any);
31
- const isProtocolV2 = jest.fn().mockReturnValueOnce(true).mockReturnValue(false);
32
- device.isProtocolV2 = isProtocolV2;
33
- device.beginProtocolV2UiInteraction();
34
-
35
- const metadata = device.finishProtocolV2UiInteraction('succeeded', {
36
- ensureMetadata: true,
37
- });
38
-
39
- expect(metadata).toMatchObject({
40
- phase: 'processing',
41
- transition: 'finish',
42
- outcome: 'succeeded',
43
- protocol: 'V2',
44
- });
45
- });
46
-
47
- test('emits a matching PIN phase completion after DeviceSessionAskPin succeeds', async () => {
48
- const device = new Device({ id: 'connect-1' } as any);
49
- device.isProtocolV2 = jest.fn(() => true);
50
- device.updateProtocolV2Status = jest.fn(() => undefined as any);
51
- device.commands = {
52
- typedCall: jest.fn().mockResolvedValue({
53
- message: { unlocked: true },
54
- }),
55
- } as any;
56
- device.beginProtocolV2UiInteraction();
57
-
58
- const starts: unknown[] = [];
59
- const completions: unknown[] = [];
60
- device.on(DEVICE.PIN_ON_DEVICE, (...args) => starts.push(args));
61
- device.on(DEVICE.PIN_ON_DEVICE_COMPLETE, (...args) => completions.push(args));
62
-
63
- await device.unlockDevice(DeviceSessionPinType.Main, {
64
- source: 'unlock-coordinator',
65
- reason: 'device-locked',
66
- deviceOnly: true,
67
- });
68
-
69
- const startMetadata = (starts[0] as unknown[])[2] as Record<string, unknown>;
70
- const completionMetadata = (completions[0] as unknown[])[1] as Record<string, unknown>;
71
- expect(startMetadata.interaction).toMatchObject({
72
- phase: 'pin',
73
- transition: 'start',
74
- protocol: 'V2',
75
- });
76
- expect(completionMetadata).toMatchObject({
77
- interactionId: (startMetadata.interaction as { interactionId: string }).interactionId,
78
- phaseId: (startMetadata.interaction as { phaseId: string }).phaseId,
79
- phase: 'pin',
80
- transition: 'complete',
81
- outcome: 'succeeded',
82
- protocol: 'V2',
83
- });
84
- expect(completionMetadata.sequence).toBeGreaterThan(
85
- (startMetadata.interaction as { sequence: number }).sequence
86
- );
87
- expect(completionMetadata.phaseId).toBe(
88
- (startMetadata.interaction as { phaseId: string }).phaseId
89
- );
90
- });
91
- });
@@ -1,74 +0,0 @@
1
- import { createUiMessage } from '../src/events';
2
- import { UI_REQUEST } from '../src/events/ui-request';
3
- import { createUiProgressMessageFilter } from '../src/utils/uiProgressThrottle';
4
-
5
- import type { KnownDevice } from '../src/types';
6
-
7
- describe('createUiProgressMessageFilter', () => {
8
- let currentTime: number;
9
- let shouldPostMessage: ReturnType<typeof createUiProgressMessageFilter>;
10
-
11
- beforeEach(() => {
12
- currentTime = 1_000;
13
- shouldPostMessage = createUiProgressMessageFilter(250, () => currentTime);
14
- });
15
-
16
- const firmwareProgress = (
17
- progress: number,
18
- progressType: 'transferData' | 'installingFirmware' = 'transferData'
19
- ) =>
20
- createUiMessage(UI_REQUEST.FIRMWARE_PROGRESS, {
21
- device: {} as KnownDevice,
22
- progress,
23
- progressType,
24
- });
25
-
26
- test('limits firmware progress to one event per interval', () => {
27
- expect(shouldPostMessage(firmwareProgress(1))).toBe(true);
28
-
29
- currentTime += 100;
30
- expect(shouldPostMessage(firmwareProgress(1))).toBe(false);
31
-
32
- currentTime += 150;
33
- expect(shouldPostMessage(firmwareProgress(1))).toBe(true);
34
- });
35
-
36
- test('limits transfer and install progress independently', () => {
37
- expect(shouldPostMessage(firmwareProgress(1, 'transferData'))).toBe(true);
38
- expect(shouldPostMessage(firmwareProgress(1, 'installingFirmware'))).toBe(true);
39
-
40
- currentTime += 10;
41
- expect(shouldPostMessage(firmwareProgress(2, 'transferData'))).toBe(false);
42
- expect(shouldPostMessage(firmwareProgress(2, 'installingFirmware'))).toBe(false);
43
- });
44
-
45
- test('emits phase boundaries immediately and suppresses duplicate boundaries', () => {
46
- expect(shouldPostMessage(firmwareProgress(0))).toBe(true);
47
- expect(shouldPostMessage(firmwareProgress(0))).toBe(false);
48
-
49
- currentTime += 10;
50
- expect(shouldPostMessage(firmwareProgress(50))).toBe(false);
51
- expect(shouldPostMessage(firmwareProgress(100))).toBe(true);
52
- expect(shouldPostMessage(firmwareProgress(100))).toBe(false);
53
-
54
- expect(shouldPostMessage(firmwareProgress(0))).toBe(true);
55
- });
56
-
57
- test('treats decreasing progress as a new phase', () => {
58
- expect(shouldPostMessage(firmwareProgress(80))).toBe(true);
59
-
60
- currentTime += 10;
61
- expect(shouldPostMessage(firmwareProgress(20))).toBe(true);
62
- });
63
-
64
- test('also limits device progress and leaves other UI events unchanged', () => {
65
- const deviceProgress = (progress: number) =>
66
- createUiMessage(UI_REQUEST.DEVICE_PROGRESS, { progress });
67
-
68
- expect(shouldPostMessage(deviceProgress(1))).toBe(true);
69
- currentTime += 10;
70
- expect(shouldPostMessage(deviceProgress(2))).toBe(false);
71
-
72
- expect(shouldPostMessage(createUiMessage(UI_REQUEST.CLOSE_UI_WINDOW))).toBe(true);
73
- });
74
- });
@@ -1,86 +0,0 @@
1
- import { createDeferred } from '@onekeyfe/hd-shared';
2
-
3
- import { findUiPromiseForResponse } from '../src/core/uiPromiseRegistry';
4
- import { UI_RESPONSE } from '../src/events';
5
-
6
- import type { UiPromise, UiPromiseResponse } from '../src/events';
7
-
8
- const createPinPromise = (interactionId: string, deviceId: string) => {
9
- const promise = createDeferred(UI_RESPONSE.RECEIVE_PIN) as UiPromise<
10
- typeof UI_RESPONSE.RECEIVE_PIN
11
- >;
12
- promise.responseCorrelation = { interactionId, deviceId };
13
- return promise;
14
- };
15
-
16
- const asRegistry = (promises: UiPromise<typeof UI_RESPONSE.RECEIVE_PIN>[]) =>
17
- promises as UiPromise<UiPromiseResponse['type']>[];
18
-
19
- describe('UI response promise correlation', () => {
20
- test('matches a sensitive response by type, interactionId and deviceId', () => {
21
- const deviceA = createPinPromise('interaction-a', 'device-a');
22
- const deviceB = createPinPromise('interaction-b', 'device-b');
23
-
24
- expect(
25
- findUiPromiseForResponse(asRegistry([deviceA, deviceB]), {
26
- type: UI_RESPONSE.RECEIVE_PIN,
27
- payload: '123',
28
- interactionId: 'interaction-b',
29
- deviceId: 'device-b',
30
- })
31
- ).toBe(deviceB);
32
- });
33
-
34
- test('does not match incomplete or incorrect correlation metadata', () => {
35
- const pending = createPinPromise('interaction-a', 'device-a');
36
-
37
- expect(
38
- findUiPromiseForResponse(asRegistry([pending]), {
39
- type: UI_RESPONSE.RECEIVE_PIN,
40
- payload: '123',
41
- interactionId: 'interaction-a',
42
- })
43
- ).toBeUndefined();
44
- expect(
45
- findUiPromiseForResponse(asRegistry([pending]), {
46
- type: UI_RESPONSE.RECEIVE_PIN,
47
- payload: '123',
48
- interactionId: 'interaction-a',
49
- deviceId: 'device-b',
50
- })
51
- ).toBeUndefined();
52
- });
53
-
54
- test('keeps legacy responses only when the sensitive candidate is unique', () => {
55
- const deviceA = createPinPromise('interaction-a', 'device-a');
56
- const deviceB = createPinPromise('interaction-b', 'device-b');
57
- const legacyResponse = {
58
- type: UI_RESPONSE.RECEIVE_PIN,
59
- payload: '123',
60
- } as const;
61
-
62
- expect(findUiPromiseForResponse(asRegistry([deviceA]), legacyResponse)).toBe(deviceA);
63
- expect(
64
- findUiPromiseForResponse(asRegistry([deviceA, deviceB]), legacyResponse)
65
- ).toBeUndefined();
66
- });
67
-
68
- test('applies the same exact matching to passphrase responses', () => {
69
- const promise = createDeferred(UI_RESPONSE.RECEIVE_PASSPHRASE) as UiPromise<
70
- typeof UI_RESPONSE.RECEIVE_PASSPHRASE
71
- >;
72
- promise.responseCorrelation = {
73
- interactionId: 'passphrase-interaction',
74
- deviceId: 'device-a',
75
- };
76
-
77
- expect(
78
- findUiPromiseForResponse([promise] as UiPromise<UiPromiseResponse['type']>[], {
79
- type: UI_RESPONSE.RECEIVE_PASSPHRASE,
80
- payload: { value: 'redacted' },
81
- interactionId: 'passphrase-interaction',
82
- deviceId: 'device-a',
83
- })
84
- ).toBe(promise);
85
- });
86
- });
@@ -1,7 +0,0 @@
1
- import { BaseMethod } from './BaseMethod';
2
- export default class DetectDeviceConnectProtocol extends BaseMethod {
3
- init(): void;
4
- getSupportedProtocols(): readonly ["V1", "V2"];
5
- run(): Promise<"V1" | "V2">;
6
- }
7
- //# sourceMappingURL=DetectDeviceConnectProtocol.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DetectDeviceConnectProtocol.d.ts","sourceRoot":"","sources":["../../src/api/DetectDeviceConnectProtocol.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,MAAM,CAAC,OAAO,OAAO,2BAA4B,SAAQ,UAAU;IACjE,IAAI;IAOJ,qBAAqB;IAIrB,GAAG;CAGJ"}
@@ -1,31 +0,0 @@
1
- import { type Pro2NftImage } from '../../utils/pro2Nft';
2
- import { BaseMethod } from '../BaseMethod';
3
- export type DeviceUploadNftParams = {
4
- image: Pro2NftImage;
5
- thumbnail: Pro2NftImage;
6
- title: string;
7
- subtitle: string;
8
- timestampMs?: number;
9
- chunkSize?: number;
10
- paceMs?: number;
11
- timeoutMs?: number;
12
- };
13
- export type DeviceUploadNftResponse = {
14
- basename: string;
15
- imagePath: string;
16
- thumbnailPath: string;
17
- metadataPath: string;
18
- totalSize: number;
19
- nftUpdated: true;
20
- message?: string;
21
- };
22
- export default class DeviceUploadNft extends BaseMethod<DeviceUploadNftParams> {
23
- private bundle?;
24
- getSupportedProtocols(): readonly ["V2"];
25
- init(): void;
26
- private assertCapabilities;
27
- private assertStorageCapacity;
28
- private updateNft;
29
- run(): Promise<DeviceUploadNftResponse>;
30
- }
31
- //# sourceMappingURL=DeviceUploadNft.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DeviceUploadNft.d.ts","sourceRoot":"","sources":["../../../src/api/protocol-v2/DeviceUploadNft.ts"],"names":[],"mappings":"AAIA,OAAO,EASL,KAAK,YAAY,EAGlB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAI3C,MAAM,MAAM,qBAAqB,GAAG;IAClC,KAAK,EAAE,YAAY,CAAC;IACpB,SAAS,EAAE,YAAY,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IACpC,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,IAAI,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAMF,MAAM,CAAC,OAAO,OAAO,eAAgB,SAAQ,UAAU,CAAC,qBAAqB,CAAC;IAC5E,OAAO,CAAC,MAAM,CAAC,CAAgB;IAE/B,qBAAqB;IAIrB,IAAI;YAkCU,kBAAkB;YAalB,qBAAqB;YAgBrB,SAAS;IAcjB,GAAG,IAAI,OAAO,CAAC,uBAAuB,CAAC;CA0D9C"}
@@ -1,4 +0,0 @@
1
- import type { UiPromise, UiPromiseResponse } from '../events/ui-promise';
2
- import type { UiResponseEvent } from '../events/ui-response';
3
- export declare const findUiPromiseForResponse: (uiPromises: UiPromise<UiPromiseResponse['type']>[], response: UiResponseEvent) => UiPromise<"ui-receive_pin" | "ui-receive_passphrase" | "ui-receive_select-device-in-bootloader-for-web-device" | "ui-receive_select-device-for-switch-firmware-web-device" | "device-disconnect"> | undefined;
4
- //# sourceMappingURL=uiPromiseRegistry.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"uiPromiseRegistry.d.ts","sourceRoot":"","sources":["../../src/core/uiPromiseRegistry.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAS7D,eAAO,MAAM,wBAAwB,eACvB,UAAU,iBAAiB,CAAC,MAAM,CAAC,CAAC,EAAE,YACxC,eAAe,kNA0B1B,CAAC"}
@@ -1,30 +0,0 @@
1
- import type { IProtocolV2Resource, IProtocolV2ResourceType, IProtocolV2Resources } from '../../types';
2
- import type { DeviceCommands } from '../../device/DeviceCommands';
3
- export declare const PROTOCOL_V2_RESOURCE_TYPES: readonly ["images", "animation", "wallpaper", "translations", "roobert", "noto"];
4
- export declare const PROTOCOL_V2_RESOURCE_DEVICE_PATHS: Readonly<Record<IProtocolV2ResourceType, string>>;
5
- export declare const PROTOCOL_V2_RESOURCE_INVENTORY_TIMEOUT_MS: number;
6
- export type ProtocolV2ResourceInventoryItem = {
7
- type: IProtocolV2ResourceType;
8
- size: number;
9
- headerHash: string;
10
- };
11
- export type ProtocolV2ResourceUpdateMode = 'application' | 'bootloader-recovery';
12
- export type ProtocolV2ResourceUpdatePlan = {
13
- status: 'valid' | 'outdated' | 'unknown';
14
- resources: IProtocolV2Resource[];
15
- };
16
- export declare function readProtocolV2ResourceInventory({ commands, resources, chunkSize, timeoutMs, }: {
17
- commands: Pick<DeviceCommands, 'typedCall'>;
18
- resources: readonly IProtocolV2Resource[];
19
- chunkSize?: number;
20
- timeoutMs?: number;
21
- }): Promise<ProtocolV2ResourceInventoryItem[]>;
22
- export declare function parseProtocolV2Resources(value: unknown): IProtocolV2Resources | undefined;
23
- export declare function buildProtocolV2ResourceUpdatePlan({ resources, inventory, mode, forced, }: {
24
- resources: readonly IProtocolV2Resource[];
25
- inventory?: readonly ProtocolV2ResourceInventoryItem[];
26
- mode: ProtocolV2ResourceUpdateMode;
27
- forced?: boolean;
28
- }): ProtocolV2ResourceUpdatePlan;
29
- export declare function isProtocolV2ResourceFileValid(binary: ArrayBuffer, resource: Pick<IProtocolV2Resource, 'size' | 'fileHash'>): boolean;
30
- //# sourceMappingURL=resources.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"resources.d.ts","sourceRoot":"","sources":["../../../src/protocols/protocol-v2/resources.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAEV,mBAAmB,EACnB,uBAAuB,EACvB,oBAAoB,EACrB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAElE,eAAO,MAAM,0BAA0B,kFAOgB,CAAC;AAExD,eAAO,MAAM,iCAAiC,EAAE,QAAQ,CAAC,MAAM,CAAC,uBAAuB,EAAE,MAAM,CAAC,CAQ7F,CAAC;AAaJ,eAAO,MAAM,yCAAyC,QAAW,CAAC;AAElE,MAAM,MAAM,+BAA+B,GAAG;IAC5C,IAAI,EAAE,uBAAuB,CAAC;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,4BAA4B,GAAG,aAAa,GAAG,qBAAqB,CAAC;AAEjF,MAAM,MAAM,4BAA4B,GAAG;IACzC,MAAM,EAAE,OAAO,GAAG,UAAU,GAAG,SAAS,CAAC;IACzC,SAAS,EAAE,mBAAmB,EAAE,CAAC;CAClC,CAAC;AAwHF,wBAAsB,+BAA+B,CAAC,EACpD,QAAQ,EACR,SAAS,EACT,SAAgD,EAChD,SAAqD,GACtD,EAAE;IACD,QAAQ,EAAE,IAAI,CAAC,cAAc,EAAE,WAAW,CAAC,CAAC;IAC5C,SAAS,EAAE,SAAS,mBAAmB,EAAE,CAAC;IAC1C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GAAG,OAAO,CAAC,+BAA+B,EAAE,CAAC,CAmB7C;AAmED,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,OAAO,GAAG,oBAAoB,GAAG,SAAS,CAgCzF;AAGD,wBAAgB,iCAAiC,CAAC,EAChD,SAAS,EACT,SAAS,EACT,IAAI,EACJ,MAAc,GACf,EAAE;IACD,SAAS,EAAE,SAAS,mBAAmB,EAAE,CAAC;IAC1C,SAAS,CAAC,EAAE,SAAS,+BAA+B,EAAE,CAAC;IACvD,IAAI,EAAE,4BAA4B,CAAC;IACnC,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,GAAG,4BAA4B,CA8B/B;AAOD,wBAAgB,6BAA6B,CAC3C,MAAM,EAAE,WAAW,EACnB,QAAQ,EAAE,IAAI,CAAC,mBAAmB,EAAE,MAAM,GAAG,UAAU,CAAC,GACvD,OAAO,CAGT"}
@@ -1,22 +0,0 @@
1
- import type { BaseMethod } from '../../api/BaseMethod';
2
- import type { Device } from '../../device/Device';
3
- import type { ProtocolV2UiInteractionCoordinator } from './uiInteraction';
4
- export type ProtocolV2UnlockContext = {
5
- preflightCompleted: boolean;
6
- };
7
- export declare const createProtocolV2UnlockContext: () => ProtocolV2UnlockContext;
8
- type RunnableMethod = Pick<BaseMethod, 'run' | 'unlockPolicy' | 'useDevicePassphraseState' | 'protocolV2UiInteraction' | 'protocolV2UiMode' | 'params' | 'payload'> & {
9
- name?: string;
10
- protocolV2UnlockContext?: ProtocolV2UnlockContext;
11
- };
12
- type UiInteractionCoordinator = Pick<ProtocolV2UiInteractionCoordinator, 'enterMethodInteraction' | 'enterUnlockInteraction'>;
13
- type RunMethodWithUnlockPolicyOptions<T> = {
14
- context?: ProtocolV2UnlockContext;
15
- uiCoordinator?: UiInteractionCoordinator;
16
- afterStatusBeforeUnlock?: () => void | Promise<void>;
17
- prepare?: () => Promise<void>;
18
- run?: () => Promise<T>;
19
- };
20
- export declare function runMethodWithUnlockPolicy<T = unknown>(method: RunnableMethod, device: Device, options?: RunMethodWithUnlockPolicyOptions<T>): Promise<T>;
21
- export {};
22
- //# sourceMappingURL=unlockPolicyRunner.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"unlockPolicyRunner.d.ts","sourceRoot":"","sources":["../../../src/protocols/protocol-v2/unlockPolicyRunner.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAElD,OAAO,KAAK,EAAE,kCAAkC,EAAE,MAAM,iBAAiB,CAAC;AAI1E,MAAM,MAAM,uBAAuB,GAAG;IACpC,kBAAkB,EAAE,OAAO,CAAC;CAC7B,CAAC;AAEF,eAAO,MAAM,6BAA6B,QAAO,uBAE/C,CAAC;AAEH,KAAK,cAAc,GAAG,IAAI,CACxB,UAAU,EACR,KAAK,GACL,cAAc,GACd,0BAA0B,GAC1B,yBAAyB,GACzB,kBAAkB,GAClB,QAAQ,GACR,SAAS,CACZ,GAAG;IACF,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,uBAAuB,CAAC,EAAE,uBAAuB,CAAC;CACnD,CAAC;AAEF,KAAK,wBAAwB,GAAG,IAAI,CAClC,kCAAkC,EAClC,wBAAwB,GAAG,wBAAwB,CACpD,CAAC;AAEF,KAAK,gCAAgC,CAAC,CAAC,IAAI;IACzC,OAAO,CAAC,EAAE,uBAAuB,CAAC;IAClC,aAAa,CAAC,EAAE,wBAAwB,CAAC;IACzC,uBAAuB,CAAC,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACrD,OAAO,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9B,GAAG,CAAC,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,CAAC;CACxB,CAAC;AAEF,wBAAsB,yBAAyB,CAAC,CAAC,GAAG,OAAO,EACzD,MAAM,EAAE,cAAc,EACtB,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,gCAAgC,CAAC,CAAC,CAAM,GAChD,OAAO,CAAC,CAAC,CAAC,CAuEZ"}
@@ -1,4 +0,0 @@
1
- import type { HardwareConnectProtocol } from '@onekeyfe/hd-shared';
2
- import type { Response } from '../params';
3
- export declare function detectDeviceConnectProtocol(connectId: string): Response<HardwareConnectProtocol>;
4
- //# sourceMappingURL=detectDeviceConnectProtocol.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"detectDeviceConnectProtocol.d.ts","sourceRoot":"","sources":["../../../src/types/api/detectDeviceConnectProtocol.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAEnE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAE1C,MAAM,CAAC,OAAO,UAAU,2BAA2B,CACjD,SAAS,EAAE,MAAM,GAChB,QAAQ,CAAC,uBAAuB,CAAC,CAAC"}