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

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 (175) hide show
  1. package/__tests__/DeviceCommands.test.ts +87 -2
  2. package/__tests__/connectSettings.test.ts +47 -5
  3. package/__tests__/device-identity.test.ts +24 -2
  4. package/__tests__/device-settings.test.ts +1 -1
  5. package/__tests__/device-wallet-session-store.test.ts +111 -7
  6. package/__tests__/firmware-update/firmware-artifact-source.test.ts +119 -0
  7. package/__tests__/firmware-update/firmware-host-binding.test.ts +70 -0
  8. package/__tests__/firmware-update/firmware-update-capabilities.test.ts +13 -0
  9. package/__tests__/firmware-update/firmware-update-plan.test.ts +326 -0
  10. package/__tests__/firmware-update/firmware-update-prepared-plan.test.ts +200 -0
  11. package/__tests__/firmware-update/firmware-update-v2-download-before-boot.test.ts +39 -30
  12. package/__tests__/firmware-update/firmware-upload-source.test.ts +70 -0
  13. package/__tests__/open-wallet-session.test.ts +253 -13
  14. package/__tests__/pro2Wallpaper.test.ts +7 -18
  15. package/__tests__/protocol-v2-unlock-policy.test.ts +45 -0
  16. package/__tests__/protocol-v2.test.ts +415 -145
  17. package/__tests__/public-device-state-api.test.ts +69 -62
  18. package/__tests__/public-pro2-api-boundary.test.ts +8 -34
  19. package/dist/api/BaseMethod.d.ts +2 -1
  20. package/dist/api/BaseMethod.d.ts.map +1 -1
  21. package/dist/api/CheckAllFirmwareRelease.d.ts.map +1 -1
  22. package/dist/api/ClearSessionCache.d.ts.map +1 -1
  23. package/dist/api/FirmwareUpdate.d.ts.map +1 -1
  24. package/dist/api/FirmwareUpdateV2.d.ts +11 -0
  25. package/dist/api/FirmwareUpdateV2.d.ts.map +1 -1
  26. package/dist/api/FirmwareUpdateV3.d.ts +7 -3
  27. package/dist/api/FirmwareUpdateV3.d.ts.map +1 -1
  28. package/dist/api/FirmwareUpdateV4.d.ts +29 -10
  29. package/dist/api/FirmwareUpdateV4.d.ts.map +1 -1
  30. package/dist/api/OpenWalletSession.d.ts.map +1 -1
  31. package/dist/api/conflux/ConfluxGetAddress.d.ts +1 -0
  32. package/dist/api/conflux/ConfluxGetAddress.d.ts.map +1 -1
  33. package/dist/api/conflux/ConfluxSignMessage.d.ts +1 -0
  34. package/dist/api/conflux/ConfluxSignMessage.d.ts.map +1 -1
  35. package/dist/api/conflux/ConfluxSignMessageCIP23.d.ts +1 -0
  36. package/dist/api/conflux/ConfluxSignMessageCIP23.d.ts.map +1 -1
  37. package/dist/api/conflux/ConfluxSignTransaction.d.ts +1 -0
  38. package/dist/api/conflux/ConfluxSignTransaction.d.ts.map +1 -1
  39. package/dist/api/device/DeviceUnlock.d.ts +1 -1
  40. package/dist/api/device/DeviceUnlock.d.ts.map +1 -1
  41. package/dist/api/device/DeviceUpdateBootloader.d.ts +5 -1
  42. package/dist/api/device/DeviceUpdateBootloader.d.ts.map +1 -1
  43. package/dist/api/firmware/FirmwareArtifactSource.d.ts +26 -0
  44. package/dist/api/firmware/FirmwareArtifactSource.d.ts.map +1 -0
  45. package/dist/api/firmware/FirmwareHostBinding.d.ts +6 -0
  46. package/dist/api/firmware/FirmwareHostBinding.d.ts.map +1 -0
  47. package/dist/api/firmware/FirmwareUpdateBaseMethod.d.ts +7 -0
  48. package/dist/api/firmware/FirmwareUpdateBaseMethod.d.ts.map +1 -1
  49. package/dist/api/firmware/FirmwareUpdateCapabilities.d.ts +3 -0
  50. package/dist/api/firmware/FirmwareUpdateCapabilities.d.ts.map +1 -0
  51. package/dist/api/firmware/FirmwareUpdatePlan.d.ts +24 -0
  52. package/dist/api/firmware/FirmwareUpdatePlan.d.ts.map +1 -0
  53. package/dist/api/firmware/FirmwareUpdatePreparedPlan.d.ts +25 -0
  54. package/dist/api/firmware/FirmwareUpdatePreparedPlan.d.ts.map +1 -0
  55. package/dist/api/firmware/getBinary.d.ts +7 -0
  56. package/dist/api/firmware/getBinary.d.ts.map +1 -1
  57. package/dist/api/firmware/updateBootloader.d.ts +2 -0
  58. package/dist/api/firmware/updateBootloader.d.ts.map +1 -1
  59. package/dist/api/firmware/uploadFirmware.d.ts +9 -1
  60. package/dist/api/firmware/uploadFirmware.d.ts.map +1 -1
  61. package/dist/api/helpers/protocolV2FileWrite.d.ts.map +1 -1
  62. package/dist/api/index.d.ts +0 -17
  63. package/dist/api/index.d.ts.map +1 -1
  64. package/dist/api/nexa/NexaSignTransaction.d.ts +1 -0
  65. package/dist/api/nexa/NexaSignTransaction.d.ts.map +1 -1
  66. package/dist/api/stellar/StellarSignTransaction.d.ts +1 -1
  67. package/dist/data-manager/DataManager.d.ts +1 -0
  68. package/dist/data-manager/DataManager.d.ts.map +1 -1
  69. package/dist/data-manager/connectSettings.d.ts.map +1 -1
  70. package/dist/device/Device.d.ts.map +1 -1
  71. package/dist/device/DeviceCommands.d.ts.map +1 -1
  72. package/dist/device/DeviceStateMapper.d.ts.map +1 -1
  73. package/dist/device/DeviceStateProjector.d.ts.map +1 -1
  74. package/dist/events/logBlockEvent.d.ts.map +1 -1
  75. package/dist/index.d.ts +265 -226
  76. package/dist/index.d.ts.map +1 -1
  77. package/dist/index.js +3045 -1550
  78. package/dist/inject.d.ts.map +1 -1
  79. package/dist/lowLevelInject.d.ts.map +1 -1
  80. package/dist/protocols/protocol-v2/settingsUnlockPolicy.d.ts.map +1 -1
  81. package/dist/protocols/protocol-v2/unlockPolicy.d.ts +4 -0
  82. package/dist/protocols/protocol-v2/unlockPolicy.d.ts.map +1 -0
  83. package/dist/protocols/protocol-v2/unlockRetry.d.ts.map +1 -1
  84. package/dist/protocols/protocol-v2/walletSession.d.ts.map +1 -1
  85. package/dist/topLevelInject.d.ts.map +1 -1
  86. package/dist/types/api/checkAllFirmwareRelease.d.ts +3 -0
  87. package/dist/types/api/checkAllFirmwareRelease.d.ts.map +1 -1
  88. package/dist/types/api/deviceUnlock.d.ts +2 -2
  89. package/dist/types/api/deviceUnlock.d.ts.map +1 -1
  90. package/dist/types/api/deviceUpdateBootloader.d.ts +6 -0
  91. package/dist/types/api/deviceUpdateBootloader.d.ts.map +1 -1
  92. package/dist/types/api/export.d.ts +4 -1
  93. package/dist/types/api/export.d.ts.map +1 -1
  94. package/dist/types/api/firmwareUpdate.d.ts +69 -0
  95. package/dist/types/api/firmwareUpdate.d.ts.map +1 -1
  96. package/dist/types/api/firmwareUpdateCapabilities.d.ts +9 -0
  97. package/dist/types/api/firmwareUpdateCapabilities.d.ts.map +1 -0
  98. package/dist/types/api/firmwareUpdatePlan.d.ts +27 -0
  99. package/dist/types/api/firmwareUpdatePlan.d.ts.map +1 -0
  100. package/dist/types/api/firmwareUpdatePreparedPlan.d.ts +42 -0
  101. package/dist/types/api/firmwareUpdatePreparedPlan.d.ts.map +1 -0
  102. package/dist/types/api/index.d.ts +10 -19
  103. package/dist/types/api/index.d.ts.map +1 -1
  104. package/dist/types/api/openWalletSession.d.ts +1 -0
  105. package/dist/types/api/openWalletSession.d.ts.map +1 -1
  106. package/dist/types/api/protocolV2.d.ts +3 -76
  107. package/dist/types/api/protocolV2.d.ts.map +1 -1
  108. package/dist/types/api/sessionCache.d.ts +4 -1
  109. package/dist/types/api/sessionCache.d.ts.map +1 -1
  110. package/dist/types/settings.d.ts +13 -0
  111. package/dist/types/settings.d.ts.map +1 -1
  112. package/dist/utils/deviceFeaturesUtils.d.ts.map +1 -1
  113. package/dist/utils/patch.d.ts +1 -1
  114. package/dist/utils/patch.d.ts.map +1 -1
  115. package/package.json +4 -4
  116. package/src/api/BaseMethod.ts +8 -3
  117. package/src/api/CheckAllFirmwareRelease.ts +16 -3
  118. package/src/api/ClearSessionCache.ts +4 -0
  119. package/src/api/FirmwareUpdate.ts +8 -1
  120. package/src/api/FirmwareUpdateV2.ts +284 -119
  121. package/src/api/FirmwareUpdateV3.ts +248 -55
  122. package/src/api/FirmwareUpdateV4.ts +816 -328
  123. package/src/api/OpenWalletSession.ts +74 -25
  124. package/src/api/UploadPortfolio.ts +1 -1
  125. package/src/api/conflux/ConfluxGetAddress.ts +2 -0
  126. package/src/api/conflux/ConfluxSignMessage.ts +2 -0
  127. package/src/api/conflux/ConfluxSignMessageCIP23.ts +2 -0
  128. package/src/api/conflux/ConfluxSignTransaction.ts +2 -0
  129. package/src/api/device/DeviceChangePin.ts +1 -1
  130. package/src/api/device/DeviceUnlock.ts +1 -2
  131. package/src/api/device/DeviceUpdateBootloader.ts +114 -6
  132. package/src/api/device/DeviceWipe.ts +1 -1
  133. package/src/api/firmware/FirmwareArtifactSource.ts +278 -0
  134. package/src/api/firmware/FirmwareHostBinding.ts +100 -0
  135. package/src/api/firmware/FirmwareUpdateBaseMethod.ts +50 -0
  136. package/src/api/firmware/FirmwareUpdateCapabilities.ts +9 -0
  137. package/src/api/firmware/FirmwareUpdatePlan.ts +621 -0
  138. package/src/api/firmware/FirmwareUpdatePreparedPlan.ts +378 -0
  139. package/src/api/firmware/updateBootloader.ts +19 -4
  140. package/src/api/firmware/uploadFirmware.ts +140 -22
  141. package/src/api/helpers/protocolV2FileWrite.ts +6 -0
  142. package/src/api/index.ts +0 -18
  143. package/src/api/nexa/NexaSignTransaction.ts +2 -0
  144. package/src/api/protocol-v2/DeviceUploadWallpaper.ts +1 -1
  145. package/src/data/messages/messages-protocol-v2.json +77 -4
  146. package/src/data-manager/DataManager.ts +33 -33
  147. package/src/data-manager/connectSettings.ts +11 -0
  148. package/src/device/Device.ts +50 -60
  149. package/src/device/DeviceCommands.ts +58 -14
  150. package/src/device/DeviceStateMapper.ts +18 -1
  151. package/src/device/DeviceStateProjector.ts +7 -1
  152. package/src/events/logBlockEvent.ts +1 -0
  153. package/src/index.ts +5 -0
  154. package/src/inject.ts +22 -25
  155. package/src/lowLevelInject.ts +5 -1
  156. package/src/protocols/protocol-v2/deviceSession.ts +1 -1
  157. package/src/protocols/protocol-v2/settingsUnlockPolicy.ts +2 -2
  158. package/src/protocols/protocol-v2/unlockPolicy.ts +105 -0
  159. package/src/protocols/protocol-v2/unlockRetry.ts +1 -3
  160. package/src/protocols/protocol-v2/walletSession.ts +68 -12
  161. package/src/topLevelInject.ts +5 -1
  162. package/src/types/api/checkAllFirmwareRelease.ts +3 -0
  163. package/src/types/api/deviceUnlock.ts +2 -5
  164. package/src/types/api/deviceUpdateBootloader.ts +6 -0
  165. package/src/types/api/export.ts +18 -0
  166. package/src/types/api/firmwareUpdate.ts +76 -0
  167. package/src/types/api/firmwareUpdateCapabilities.ts +9 -0
  168. package/src/types/api/firmwareUpdatePlan.ts +36 -0
  169. package/src/types/api/firmwareUpdatePreparedPlan.ts +53 -0
  170. package/src/types/api/index.ts +14 -34
  171. package/src/types/api/openWalletSession.ts +2 -0
  172. package/src/types/api/protocolV2.ts +3 -156
  173. package/src/types/api/sessionCache.ts +9 -4
  174. package/src/types/settings.ts +13 -0
  175. package/src/utils/deviceFeaturesUtils.ts +5 -1
@@ -0,0 +1,53 @@
1
+ import type { FirmwareArtifactReference } from './firmwareUpdate';
2
+ import type {
3
+ FirmwareUpdatePlan,
4
+ FirmwareUpdatePlanArtifactRole,
5
+ FirmwareUpdatePlanTarget,
6
+ } from './firmwareUpdatePlan';
7
+
8
+ export interface FirmwareUpdatePreparedEntry {
9
+ entryName: string;
10
+ artifact: FirmwareArtifactReference;
11
+ }
12
+
13
+ export interface FirmwareUpdatePreparedArtifactInput {
14
+ artifactId: string;
15
+ artifact: FirmwareArtifactReference;
16
+ materializedEntries?: FirmwareUpdatePreparedEntry[];
17
+ }
18
+
19
+ export interface FirmwareUpdatePreparedArtifact {
20
+ artifactId: string;
21
+ role: FirmwareUpdatePlanArtifactRole;
22
+ target: FirmwareUpdatePlanTarget;
23
+ container: 'raw' | 'zip';
24
+ logicalName?: string;
25
+ targetVersion?: string;
26
+ artifact: FirmwareArtifactReference;
27
+ materializedEntries?: FirmwareUpdatePreparedEntry[];
28
+ }
29
+
30
+ export interface FirmwareUpdatePreparedPlan {
31
+ schemaVersion: 2;
32
+ preparedPlanDigest: string;
33
+ planDigest: string;
34
+ networkPolicy: 'forbid';
35
+ executor: FirmwareUpdatePlan['executor'];
36
+ deviceIdentity: string;
37
+ deviceModel: string;
38
+ firmwareType: FirmwareUpdatePlan['firmwareType'];
39
+ platform: FirmwareUpdatePlan['platform'];
40
+ leaseRef: string;
41
+ artifacts: FirmwareUpdatePreparedArtifact[];
42
+ targetsToUpdate: FirmwareUpdatePlanTarget[];
43
+ }
44
+
45
+ export declare function prepareFirmwareUpdatePlan(input: {
46
+ plan: FirmwareUpdatePlan;
47
+ leaseRef: string;
48
+ artifacts: FirmwareUpdatePreparedArtifactInput[];
49
+ }): FirmwareUpdatePreparedPlan;
50
+
51
+ export declare function validateFirmwareUpdatePreparedPlan(
52
+ value: unknown
53
+ ): FirmwareUpdatePreparedPlan;
@@ -1,24 +1,7 @@
1
1
  import type {
2
- deviceFactoryInfoGet,
3
- deviceFactoryInfoSet,
4
- deviceFirmwareUpdate,
5
- deviceGetFirmwareUpdateStatus,
6
2
  deviceGetOnboardingStatus,
7
- deviceInfoGet,
8
3
  deviceReboot,
9
- deviceStatusGet,
10
4
  deviceUploadWallpaper,
11
- dirList,
12
- dirMake,
13
- dirRemove,
14
- fileDelete,
15
- fileRead,
16
- fileWrite,
17
- filesystemFormat,
18
- filesystemPermissionFix,
19
- pathInfo,
20
- ping,
21
- protocolInfoRequest,
22
5
  uploadPortfolio,
23
6
  } from './protocolV2';
24
7
  import type { off, on, removeAllListeners } from './event';
@@ -46,7 +29,15 @@ import type {
46
29
  firmwareUpdateV2,
47
30
  firmwareUpdateV3,
48
31
  firmwareUpdateV4,
32
+ getFirmwareUpdateHostBindingGeneration,
33
+ registerFirmwareUpdateHostBinding,
34
+ unregisterFirmwareUpdateHostBinding,
49
35
  } from './firmwareUpdate';
36
+ import type { getFirmwareUpdateCapabilities } from './firmwareUpdateCapabilities';
37
+ import type {
38
+ prepareFirmwareUpdatePlan,
39
+ validateFirmwareUpdatePreparedPlan,
40
+ } from './firmwareUpdatePreparedPlan';
50
41
  import type { promptWebDeviceAccess } from './promptWebDeviceAccess';
51
42
  import type { deviceReset } from './deviceReset';
52
43
  import type { deviceRecovery } from './deviceRecovery';
@@ -236,6 +227,12 @@ export type CoreApi = {
236
227
  firmwareUpdateV2: typeof firmwareUpdateV2;
237
228
  firmwareUpdateV3: typeof firmwareUpdateV3;
238
229
  firmwareUpdateV4: typeof firmwareUpdateV4;
230
+ registerFirmwareUpdateHostBinding: typeof registerFirmwareUpdateHostBinding;
231
+ unregisterFirmwareUpdateHostBinding: typeof unregisterFirmwareUpdateHostBinding;
232
+ getFirmwareUpdateHostBindingGeneration: typeof getFirmwareUpdateHostBindingGeneration;
233
+ getFirmwareUpdateCapabilities: typeof getFirmwareUpdateCapabilities;
234
+ prepareFirmwareUpdatePlan: typeof prepareFirmwareUpdatePlan;
235
+ validateFirmwareUpdatePreparedPlan: typeof validateFirmwareUpdatePreparedPlan;
239
236
  cipherKeyValue: typeof cipherKeyValue;
240
237
 
241
238
  /**
@@ -244,24 +241,7 @@ export type CoreApi = {
244
241
  deviceReboot: typeof deviceReboot;
245
242
  deviceGetOnboardingStatus: typeof deviceGetOnboardingStatus;
246
243
  deviceUploadWallpaper: typeof deviceUploadWallpaper;
247
- deviceInfoGet: typeof deviceInfoGet;
248
- deviceStatusGet: typeof deviceStatusGet;
249
- protocolInfoRequest: typeof protocolInfoRequest;
250
- ping: typeof ping;
251
- deviceFirmwareUpdate: typeof deviceFirmwareUpdate;
252
- deviceGetFirmwareUpdateStatus: typeof deviceGetFirmwareUpdateStatus;
253
- deviceFactoryInfoSet: typeof deviceFactoryInfoSet;
254
- deviceFactoryInfoGet: typeof deviceFactoryInfoGet;
255
- filesystemPermissionFix: typeof filesystemPermissionFix;
256
- filesystemFormat: typeof filesystemFormat;
257
244
  uploadPortfolio: typeof uploadPortfolio;
258
- fileRead: typeof fileRead;
259
- fileWrite: typeof fileWrite;
260
- fileDelete: typeof fileDelete;
261
- dirList: typeof dirList;
262
- dirMake: typeof dirMake;
263
- dirRemove: typeof dirRemove;
264
- pathInfo: typeof pathInfo;
265
245
 
266
246
  /**
267
247
  * All network function
@@ -40,6 +40,8 @@ type OpenWalletSessionPayloadBase = {
40
40
  protocol: 'V1' | 'V2';
41
41
  deviceId: string;
42
42
  resumed: boolean;
43
+ /** Forwarded only when the firmware response contains a wallet session id. */
44
+ sessionId?: string;
43
45
  };
44
46
 
45
47
  export type OpenWalletSessionPayload = OpenWalletSessionPayloadBase &
@@ -1,39 +1,13 @@
1
1
  import type { CommonParams, Response } from '../params';
2
- import type {
3
- DevOnboardingStatus,
4
- DeviceFactoryInfo,
5
- DeviceFirmwareUpdateStatus,
6
- DeviceStatus,
7
- ProtocolInfo,
8
- ProtocolV2DeviceInfo,
9
- Success,
10
- } from '@onekeyfe/hd-transport';
11
- import type {
12
- DeviceFactoryInfoSetParams,
13
- DeviceFirmwareUpdateParams,
14
- DeviceFirmwareUpdateStatusGetParams,
15
- DeviceRebootParams,
16
- } from '../../api/protocol-v2/helpers';
17
- import type { DeviceInfoGetParams } from '../../api/protocol-v2/DeviceInfoGet';
2
+ import type { DevOnboardingStatus, Success } from '@onekeyfe/hd-transport';
3
+ import type { DeviceRebootParams } from '../../api/protocol-v2/helpers';
18
4
  import type {
19
5
  DeviceUploadWallpaperParams,
20
6
  DeviceUploadWallpaperResponse,
21
7
  } from '../../api/protocol-v2/DeviceUploadWallpaper';
22
8
 
23
9
  // Re-export implementation parameter types as the single source of truth.
24
- export type {
25
- DeviceFirmwareTargetInput,
26
- DeviceFirmwareUpdateParams,
27
- DeviceFirmwareUpdateStatusGetParams,
28
- DeviceRebootParams,
29
- DeviceFactoryInfoSetParams,
30
- RebootTypeInput,
31
- } from '../../api/protocol-v2/helpers';
32
- export type {
33
- DeviceInfoGetParams,
34
- DeviceInfoGetTargets,
35
- DeviceInfoGetTypes,
36
- } from '../../api/protocol-v2/DeviceInfoGet';
10
+ export type { DeviceRebootParams, RebootTypeInput } from '../../api/protocol-v2/helpers';
37
11
  export type {
38
12
  DeviceUploadWallpaperParams,
39
13
  DeviceUploadWallpaperResponse,
@@ -41,8 +15,6 @@ export type {
41
15
 
42
16
  // ── Shared response shapes (Protocol V2 file system) ────────────────────
43
17
 
44
- export type FileOpSuccess = { message?: string };
45
-
46
18
  export type FileInfo = {
47
19
  path: string;
48
20
  offset: number;
@@ -53,54 +25,8 @@ export type FileInfo = {
53
25
  chunks?: number;
54
26
  };
55
27
 
56
- export type DirInfo = {
57
- path: string;
58
- child_dirs?: string;
59
- child_files?: string;
60
- };
61
-
62
- // All FilesystemPathInfo proto fields are required; keep this type aligned.
63
- export type PathInfoResult = {
64
- exist: boolean;
65
- size: number;
66
- year: number;
67
- month: number;
68
- day: number;
69
- hour: number;
70
- minute: number;
71
- second: number;
72
- readonly: boolean;
73
- hidden: boolean;
74
- system: boolean;
75
- archive: boolean;
76
- directory: boolean;
77
- };
78
-
79
28
  // ── Method signatures ─────────────────────────────────────────────────────
80
29
 
81
- /** @deprecated Development-only raw Protocol V2 command. Use `getDeviceState`. */
82
- export declare function deviceInfoGet(
83
- connectId: string,
84
- params?: CommonParams & DeviceInfoGetParams
85
- ): Response<ProtocolV2DeviceInfo>;
86
-
87
- /** @deprecated Development-only raw Protocol V2 command. Use `getDeviceState`. */
88
- export declare function deviceStatusGet(
89
- connectId: string,
90
- params?: CommonParams
91
- ): Response<DeviceStatus>;
92
-
93
- /** @deprecated Development-only raw Protocol V2 command. */
94
- export declare function protocolInfoRequest(
95
- connectId: string,
96
- params?: CommonParams
97
- ): Response<ProtocolInfo>;
98
-
99
- export declare function ping(
100
- connectId: string,
101
- params?: CommonParams & { message?: string }
102
- ): Response<Success>;
103
-
104
30
  export declare function deviceReboot(
105
31
  connectId: string,
106
32
  params: CommonParams & DeviceRebootParams
@@ -111,88 +37,11 @@ export declare function deviceGetOnboardingStatus(
111
37
  params?: CommonParams
112
38
  ): Response<DevOnboardingStatus>;
113
39
 
114
- export declare function deviceFirmwareUpdate(
115
- connectId: string,
116
- params: CommonParams & DeviceFirmwareUpdateParams
117
- ): Response<Success | DeviceFirmwareUpdateStatus>;
118
-
119
- export declare function deviceGetFirmwareUpdateStatus(
120
- connectId: string,
121
- params?: CommonParams & DeviceFirmwareUpdateStatusGetParams
122
- ): Response<DeviceFirmwareUpdateStatus>;
123
-
124
- export declare function deviceFactoryInfoSet(
125
- connectId: string,
126
- params: CommonParams & DeviceFactoryInfoSetParams
127
- ): Response<Success>;
128
-
129
- export declare function deviceFactoryInfoGet(
130
- connectId: string,
131
- params?: CommonParams
132
- ): Response<DeviceFactoryInfo>;
133
-
134
40
  export declare function deviceUploadWallpaper(
135
41
  connectId: string,
136
42
  params: CommonParams & DeviceUploadWallpaperParams
137
43
  ): Response<DeviceUploadWallpaperResponse>;
138
44
 
139
- export declare function filesystemPermissionFix(
140
- connectId: string,
141
- params?: CommonParams
142
- ): Response<Success>;
143
-
144
- export declare function fileRead(
145
- connectId: string,
146
- params: {
147
- path: string;
148
- offset?: number;
149
- totalSize?: number;
150
- chunkLen?: number;
151
- uiPercentage?: number;
152
- }
153
- ): Response<FileInfo>;
154
-
155
- export declare function fileWrite(
156
- connectId: string,
157
- params: {
158
- path: string;
159
- offset?: number;
160
- totalSize?: number;
161
- chunkSize?: number;
162
- chunkLen?: number;
163
- data: ArrayBuffer | Uint8Array | Blob | string;
164
- overwrite?: boolean;
165
- append?: boolean;
166
- uiPercentage?: number;
167
- timeoutMs?: number | string;
168
- }
169
- ): Response<FileInfo>;
170
-
171
- export declare function fileDelete(
172
- connectId: string,
173
- params: { path: string }
174
- ): Response<FileOpSuccess>;
175
-
176
- export declare function dirList(
177
- connectId: string,
178
- params: { path: string; depth?: number }
179
- ): Response<DirInfo>;
180
-
181
- export declare function dirMake(
182
- connectId: string,
183
- params: { path: string }
184
- ): Response<FileOpSuccess>;
185
-
186
- export declare function dirRemove(
187
- connectId: string,
188
- params: { path: string }
189
- ): Response<FileOpSuccess>;
190
-
191
- export declare function pathInfo(
192
- connectId: string,
193
- params: { path: string; timeoutMs?: number | string }
194
- ): Response<PathInfoResult>;
195
-
196
45
  export declare function uploadPortfolio(
197
46
  connectId: string,
198
47
  params: {
@@ -200,5 +49,3 @@ export declare function uploadPortfolio(
200
49
  timeoutMs?: number | string;
201
50
  }
202
51
  ): Response<FileInfo & { portfolioUpdated: true }>;
203
-
204
- export declare function filesystemFormat(connectId: string): Response<Success>;
@@ -1,9 +1,14 @@
1
1
  import type { Response } from '../params';
2
2
 
3
- export type ClearSessionCacheParams = {
4
- deviceId?: string;
5
- passphraseState?: string;
6
- };
3
+ export type ClearSessionCacheParams =
4
+ | {
5
+ deviceId?: never;
6
+ passphraseState?: never;
7
+ }
8
+ | {
9
+ deviceId: string;
10
+ passphraseState?: string;
11
+ };
7
12
 
8
13
  export type ClearSessionCachePayload = {
9
14
  cleared: true;
@@ -31,6 +31,8 @@ export type ConnectSettings = {
31
31
  timestamp: number;
32
32
  isFrame?: boolean;
33
33
  preRelease?: boolean;
34
+ firmwareManifestMode?: 'sdk-managed' | 'external-only';
35
+ preloadedConfig?: RemoteConfigResponse;
34
36
  fetchConfig?: boolean;
35
37
  extension?: string;
36
38
  configFetcher?: (url: string) => Promise<RemoteConfigResponse | null>;
@@ -55,6 +57,7 @@ export type IProtocolV2FirmwareComponent = {
55
57
  target: IProtocolV2FirmwareComponentTarget;
56
58
  url: string;
57
59
  fingerprint?: string;
60
+ expectedSize?: number;
58
61
  version?: IVersionArray;
59
62
  };
60
63
 
@@ -64,6 +67,8 @@ export type IProtocolV2ResourceBundle = {
64
67
  name: string;
65
68
  /** Download URL. */
66
69
  url: string;
70
+ fingerprint?: string;
71
+ expectedSize?: number;
67
72
  /** Device target path, such as vol0:/bundles/images/images.okpkg. */
68
73
  devicePath: string;
69
74
  /** okpkg payload_version used to skip matching content after FileRead. */
@@ -85,10 +90,16 @@ export type IFirmwareReleaseInfo = {
85
90
  firmwareType?: EFirmwareType;
86
91
  /** Firmware UI resource */
87
92
  resource?: string;
93
+ resourceFingerprint?: string;
94
+ resourceExpectedSize?: number;
88
95
  /** Firmware full UI resource */
89
96
  fullResource?: string;
97
+ fullResourceFingerprint?: string;
98
+ fullResourceExpectedSize?: number;
90
99
  fullResourceRange?: string[];
91
100
  bootloaderResource?: string;
101
+ bootloaderFingerprint?: string;
102
+ bootloaderExpectedSize?: number;
92
103
  bootloaderVersion?: IVersionArray;
93
104
  displayBootloaderVersion?: IVersionArray;
94
105
  bootloaderRelatedFirmwareVersion?: IVersionArray;
@@ -101,6 +112,7 @@ export type IFirmwareReleaseInfo = {
101
112
  [k in ILocale]: string;
102
113
  };
103
114
  fingerprint: string;
115
+ expectedSize?: number;
104
116
  version: IVersionArray;
105
117
  changelog: {
106
118
  [k in ILocale]: string;
@@ -116,6 +128,7 @@ export type IBLEFirmwareReleaseInfo = {
116
128
  webUpdate: string;
117
129
  fingerprint: string;
118
130
  fingerprintWeb: string;
131
+ expectedSize?: number;
119
132
  version: IVersionArray;
120
133
  changelog: {
121
134
  [k in ILocale]: string;
@@ -156,12 +156,16 @@ export const getPassphraseStateWithRefreshDeviceInfo = async (
156
156
 
157
157
  // Attach to pin try to fix internal state
158
158
  const deviceId = device.getCurrentDeviceId();
159
+ let existingSessionId: string | null | undefined;
160
+ if (!options?.initSession && typeof device.getInternalState === 'function') {
161
+ existingSessionId = device.getInternalState();
162
+ }
159
163
  device.updateInternalState(
160
164
  device.getCurrentPassphraseProtection() ?? false,
161
165
  passphraseState,
162
166
  deviceId,
163
167
  newSession,
164
- options?.initSession ? null : device.features?.sessionId
168
+ options?.initSession ? null : existingSessionId
165
169
  );
166
170
 
167
171
  return {