@onekeyfe/hd-core 1.2.0-alpha.77 → 1.2.0-alpha.79

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 (57) hide show
  1. package/__tests__/check-all-firmware-release-protocol-v2.test.ts +12 -71
  2. package/__tests__/device-state-mapper.test.ts +16 -1
  3. package/__tests__/device-state-projector.test.ts +20 -0
  4. package/__tests__/device-state-store.test.ts +27 -0
  5. package/__tests__/homescreen.test.ts +17 -0
  6. package/__tests__/method-protocol-support.test.ts +13 -1
  7. package/__tests__/protocol-v2-resources.test.ts +113 -222
  8. package/__tests__/protocol-v2.test.ts +110 -380
  9. package/dist/api/CheckAllFirmwareRelease.d.ts.map +1 -1
  10. package/dist/api/FirmwareUpdateV4.d.ts +0 -6
  11. package/dist/api/FirmwareUpdateV4.d.ts.map +1 -1
  12. package/dist/api/UploadPortfolio.d.ts.map +1 -1
  13. package/dist/api/utils.d.ts +2 -0
  14. package/dist/api/utils.d.ts.map +1 -1
  15. package/dist/data-manager/DataManager.d.ts +1 -2
  16. package/dist/data-manager/DataManager.d.ts.map +1 -1
  17. package/dist/device/DeviceStateMapper.d.ts.map +1 -1
  18. package/dist/device/DeviceStateProjector.d.ts.map +1 -1
  19. package/dist/device/DeviceStateStore.d.ts.map +1 -1
  20. package/dist/index.d.ts +96 -33
  21. package/dist/index.d.ts.map +1 -1
  22. package/dist/index.js +515 -597
  23. package/dist/inject.d.ts.map +1 -1
  24. package/dist/protocols/protocol-v2/resources.d.ts +31 -28
  25. package/dist/protocols/protocol-v2/resources.d.ts.map +1 -1
  26. package/dist/types/api/checkAllFirmwareRelease.d.ts +1 -0
  27. package/dist/types/api/checkAllFirmwareRelease.d.ts.map +1 -1
  28. package/dist/types/api/export.d.ts +1 -0
  29. package/dist/types/api/export.d.ts.map +1 -1
  30. package/dist/types/api/index.d.ts +2 -0
  31. package/dist/types/api/index.d.ts.map +1 -1
  32. package/dist/types/api/protocolV2ResourceManifest.d.ts +17 -0
  33. package/dist/types/api/protocolV2ResourceManifest.d.ts.map +1 -0
  34. package/dist/types/device.d.ts +8 -0
  35. package/dist/types/device.d.ts.map +1 -1
  36. package/dist/types/settings.d.ts +30 -21
  37. package/dist/types/settings.d.ts.map +1 -1
  38. package/dist/utils/homescreen.d.ts.map +1 -1
  39. package/package.json +4 -4
  40. package/src/api/CheckAllFirmwareRelease.ts +5 -34
  41. package/src/api/FirmwareUpdateV4.ts +48 -220
  42. package/src/api/UploadPortfolio.ts +18 -0
  43. package/src/api/utils.ts +25 -0
  44. package/src/data-manager/DataManager.ts +17 -6
  45. package/src/device/DeviceStateMapper.ts +42 -0
  46. package/src/device/DeviceStateProjector.ts +58 -0
  47. package/src/device/DeviceStateStore.ts +31 -0
  48. package/src/index.ts +8 -0
  49. package/src/inject.ts +2 -0
  50. package/src/protocols/protocol-v2/resources.ts +193 -324
  51. package/src/types/api/checkAllFirmwareRelease.ts +1 -0
  52. package/src/types/api/export.ts +4 -0
  53. package/src/types/api/index.ts +2 -0
  54. package/src/types/api/protocolV2ResourceManifest.ts +19 -0
  55. package/src/types/device.ts +16 -0
  56. package/src/types/settings.ts +30 -36
  57. package/src/utils/homescreen.ts +5 -1
@@ -0,0 +1,19 @@
1
+ import type { FirmwareUpdateV4Target } from './firmwareUpdate';
2
+
3
+ export type ProtocolV2ResourceManifestBinary = {
4
+ archivePath: string;
5
+ binary: ArrayBuffer;
6
+ };
7
+
8
+ export type ProtocolV2PreparedResourceFile = {
9
+ binary: ArrayBuffer;
10
+ devicePath: string;
11
+ size: number;
12
+ fileHash: string;
13
+ };
14
+
15
+ export declare function prepareProtocolV2ResourceFiles(input: {
16
+ manifest: unknown;
17
+ files: ProtocolV2ResourceManifestBinary[];
18
+ targetsToUpdate: readonly FirmwareUpdateV4Target[];
19
+ }): ProtocolV2PreparedResourceFile[];
@@ -259,6 +259,19 @@ export type DeviceStateVersions = {
259
259
  se04Boot?: string | null;
260
260
  };
261
261
 
262
+ export type DeviceStateSecurityElement = {
263
+ type: string | null;
264
+ state: string | null;
265
+ };
266
+
267
+ export type DeviceStateSecurityElements = Partial<
268
+ Record<'se01' | 'se02' | 'se03' | 'se04', DeviceStateSecurityElement>
269
+ >;
270
+
271
+ export type DeviceStateSecurityElementsPatch = Partial<
272
+ Record<keyof DeviceStateSecurityElements, Partial<DeviceStateSecurityElement>>
273
+ >;
274
+
262
275
  export type DeviceState = {
263
276
  schemaVersion: 1;
264
277
  revision: number;
@@ -270,6 +283,8 @@ export type DeviceState = {
270
283
  status: DeviceStateStatus;
271
284
  settings: DeviceStateSettings;
272
285
  versions: DeviceStateVersions;
286
+ /** Secure-element metadata exposed by the unified firmware information read. */
287
+ securityElements?: DeviceStateSecurityElements;
273
288
  capabilities: Array<number | string>;
274
289
  verification?: Partial<DeviceFeaturesVerify>;
275
290
  };
@@ -281,6 +296,7 @@ export type DeviceStatePatch = {
281
296
  status?: Partial<DeviceStateStatus>;
282
297
  settings?: Partial<DeviceStateSettings>;
283
298
  versions?: Partial<DeviceStateVersions>;
299
+ securityElements?: DeviceStateSecurityElementsPatch;
284
300
  capabilities?: Array<number | string>;
285
301
  verification?: DeviceFeaturesVerify;
286
302
  raw?: DeviceFeaturesRawPatch;
@@ -64,48 +64,42 @@ export type IProtocolV2FirmwareComponent = {
64
64
  version?: IVersionArray;
65
65
  };
66
66
 
67
- export type IProtocolV2ResourceType =
68
- | 'images'
69
- | 'animation'
70
- | 'wallpaper'
71
- | 'translations'
72
- | 'roobert'
73
- | 'noto'
74
- | 'firmware_logo';
75
-
76
- /** Pro2 RES package descriptor. Hashes identify content without a human-managed version. */
77
- export type IProtocolV2Resource = {
78
- type: IProtocolV2ResourceType;
79
- url: string;
80
- /** Complete okpkg file size in bytes. */
81
- size: number;
82
- /** SHA-256 of the complete okpkg file. */
83
- fileHash: string;
84
- /** SHA3-512 header_hash from the signed okpkg header. */
85
- headerHash: string;
67
+ export type IProtocolV2ResourceSource = {
68
+ manifestUrl: string;
86
69
  };
87
70
 
88
- /** A file from the Protocol V2 resource manifest, written directly with FileWrite. */
89
- export type IProtocolV2ResourceFile = {
90
- name?: string;
91
- url: string;
92
- devicePath: string;
93
- size: number;
94
- /** SHA-256 of the complete file. */
95
- fileHash: string;
71
+ export type IProtocolV2Resources = {
72
+ source: IProtocolV2ResourceSource;
96
73
  };
97
74
 
98
- /** Optional Protocol V2 boot resources restored as individual files. */
99
- export type IProtocolV2BootResources = {
100
- required: false;
101
- target: 'RES';
102
- manifestUrl?: string;
103
- files: IProtocolV2ResourceFile[];
75
+ export type IProtocolV2ResourceManifestFile = {
76
+ archive_path: string;
77
+ original_name: string;
78
+ device_path: string;
79
+ size: number;
80
+ sha256: string;
81
+ signed: true;
82
+ sig_algo: 'ed25519' | 'mldsa65';
83
+ payload_version: string | null;
104
84
  };
105
85
 
106
- export type IProtocolV2Resources = {
107
- stable: IProtocolV2Resource[];
108
- boot?: IProtocolV2BootResources;
86
+ export type IProtocolV2ResourceManifest = {
87
+ schema: 1;
88
+ artifact_name: string;
89
+ release_name: string;
90
+ variant: 'resource';
91
+ commit: string;
92
+ short_sha: string;
93
+ timestamp_utc: string;
94
+ core_version: string;
95
+ key_set: string;
96
+ device_root: 'vol0:';
97
+ restore_mode: 'bootloader_update';
98
+ trees: Array<{
99
+ path: string;
100
+ device: string;
101
+ }>;
102
+ files: IProtocolV2ResourceManifestFile[];
109
103
  };
110
104
 
111
105
  /** Pro2 RESC bundle okpkg descriptor for incremental FileWrite synchronization. */
@@ -328,6 +328,10 @@ export const getNftSize = ({
328
328
  full: { width: PRO2_NFT_IMAGE_WIDTH, height: PRO2_NFT_IMAGE_HEIGHT },
329
329
  thumbnail: { width: PRO2_NFT_THUMBNAIL_WIDTH, height: PRO2_NFT_THUMBNAIL_HEIGHT },
330
330
  },
331
+ neo: {
332
+ full: { width: PRO2_NFT_IMAGE_WIDTH, height: PRO2_NFT_IMAGE_HEIGHT },
333
+ thumbnail: { width: PRO2_NFT_THUMBNAIL_WIDTH, height: PRO2_NFT_THUMBNAIL_HEIGHT },
334
+ },
331
335
  };
332
336
 
333
337
  return sizes[deviceType]?.[thumbnail ? 'thumbnail' : 'full'];
@@ -342,7 +346,7 @@ export const getHomeScreenSize = ({
342
346
  homeScreenType: 'WallPaper' | 'Nft';
343
347
  thumbnail?: boolean;
344
348
  }) => {
345
- if (deviceType === EDeviceType.Pro2) {
349
+ if (deviceType === EDeviceType.Pro2 || deviceType === EDeviceType.Neo) {
346
350
  return thumbnail ? undefined : { width: PRO2_WALLPAPER_WIDTH, height: PRO2_WALLPAPER_HEIGHT };
347
351
  }
348
352