@onekeyfe/hd-core 1.2.0-alpha.85 → 1.2.0-alpha.87

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 (31) hide show
  1. package/__tests__/check-all-firmware-release-protocol-v2.test.ts +74 -37
  2. package/__tests__/check-firmware-release-protocol-v2.test.ts +1 -2
  3. package/__tests__/firmware-memory-host.test.ts +3 -0
  4. package/__tests__/firmware-update/device-update-bootloader.test.ts +4 -1
  5. package/__tests__/firmware-update/firmware-host-binding.test.ts +9 -0
  6. package/__tests__/protocol-v2-resources.test.ts +59 -1
  7. package/__tests__/protocol-v2.test.ts +96 -1
  8. package/dist/api/CheckAllFirmwareRelease.d.ts.map +1 -1
  9. package/dist/api/FirmwareUpdateV4.d.ts.map +1 -1
  10. package/dist/api/firmware/FirmwareHostBinding.d.ts +1 -1
  11. package/dist/api/firmware/FirmwareHostBinding.d.ts.map +1 -1
  12. package/dist/api/firmware/FirmwareMemoryHost.d.ts.map +1 -1
  13. package/dist/data-manager/DataManager.d.ts +3 -1
  14. package/dist/data-manager/DataManager.d.ts.map +1 -1
  15. package/dist/index.d.ts +8 -6
  16. package/dist/index.js +57 -35
  17. package/dist/types/api/checkAllFirmwareRelease.d.ts +0 -1
  18. package/dist/types/api/checkAllFirmwareRelease.d.ts.map +1 -1
  19. package/dist/types/api/firmwareUpdate.d.ts +1 -0
  20. package/dist/types/api/firmwareUpdate.d.ts.map +1 -1
  21. package/dist/types/settings.d.ts +3 -4
  22. package/dist/types/settings.d.ts.map +1 -1
  23. package/package.json +4 -4
  24. package/src/api/CheckAllFirmwareRelease.ts +2 -7
  25. package/src/api/FirmwareUpdateV4.ts +22 -12
  26. package/src/api/firmware/FirmwareHostBinding.ts +16 -3
  27. package/src/api/firmware/FirmwareMemoryHost.ts +4 -1
  28. package/src/data-manager/DataManager.ts +33 -13
  29. package/src/types/api/checkAllFirmwareRelease.ts +0 -1
  30. package/src/types/api/firmwareUpdate.ts +2 -0
  31. package/src/types/settings.ts +3 -5
@@ -94,12 +94,10 @@ export default class DataManager {
94
94
  ble: [],
95
95
  },
96
96
  [EDeviceType.Pro2]: {
97
- firmware: [],
98
- ble: [],
97
+ 'firmware-v1': [],
99
98
  },
100
99
  [EDeviceType.Neo]: {
101
- firmware: [],
102
- ble: [],
100
+ 'firmware-v1': [],
103
101
  },
104
102
  [EDeviceType.ClassicPure]: {
105
103
  firmware: [],
@@ -121,6 +119,8 @@ export default class DataManager {
121
119
 
122
120
  static protocolV2ResourcesConfigError: Error | undefined;
123
121
 
122
+ private static protocolV2NeoResourcesConfigError: Error | undefined;
123
+
124
124
  static getFirmwareStatus = (
125
125
  features: Features,
126
126
  firmwareType: EFirmwareType
@@ -410,6 +410,7 @@ export default class DataManager {
410
410
  static async load(settings: ConnectSettings): Promise<boolean> {
411
411
  this.settings = settings;
412
412
  this.protocolV2ResourcesConfigError = undefined;
413
+ this.protocolV2NeoResourcesConfigError = undefined;
413
414
  const manifestMode =
414
415
  settings.firmwareManifestMode ?? (settings.fetchConfig ? 'sdk-managed' : undefined);
415
416
  if (settings.preloadedConfig) {
@@ -476,15 +477,21 @@ export default class DataManager {
476
477
  pro2Resources = parseProtocolV2Resources(
477
478
  (data.pro2 as { resources?: unknown } | undefined)?.resources
478
479
  );
479
- neoResources = parseProtocolV2Resources(
480
- (data.neo as { resources?: unknown } | undefined)?.resources
481
- );
482
480
  } catch (error) {
483
481
  // Firmware resource metadata is not required for base communication. If the
484
482
  // remote config is temporarily incomplete, disable this resource update only.
485
483
  this.protocolV2ResourcesConfigError =
486
484
  error instanceof Error ? error : new Error(String(error));
487
- Log.warn('[DataConfig] Ignoring invalid Protocol V2 resources config:', error);
485
+ Log.warn('[DataConfig] Ignoring invalid Pro2 resources config:', error);
486
+ }
487
+ try {
488
+ neoResources = parseProtocolV2Resources(
489
+ (data.neo as { resources?: unknown } | undefined)?.resources
490
+ );
491
+ } catch (error) {
492
+ this.protocolV2NeoResourcesConfigError =
493
+ error instanceof Error ? error : new Error(String(error));
494
+ Log.warn('[DataConfig] Ignoring invalid Neo resources config:', error);
488
495
  }
489
496
  const enrichedPro2Config = this.enrichFirmwareReleaseInfo(data.pro2);
490
497
  const enrichedNeoConfig = this.enrichFirmwareReleaseInfo(data.neo);
@@ -537,7 +544,12 @@ export default class DataManager {
537
544
  /** Force a fresh remote config before an update is allowed to mutate the device. */
538
545
  static async forceReloadData({
539
546
  requireResources = false,
540
- }: { requireResources?: boolean } = {}): Promise<void> {
547
+ resourceDeviceType = EDeviceType.Pro2,
548
+ }: {
549
+ requireResources?: boolean;
550
+ resourceDeviceType?: EDeviceType.Pro2 | EDeviceType.Neo;
551
+ } = {}): Promise<void> {
552
+ const resourceDeviceName = resourceDeviceType === EDeviceType.Pro2 ? 'Pro2' : 'Neo';
541
553
  if (!this.settings) {
542
554
  throw new Error('Remote config settings are not initialized');
543
555
  }
@@ -545,10 +557,14 @@ export default class DataManager {
545
557
  this.lastCheckTimestamp > 0 &&
546
558
  getTimeStamp() - this.lastCheckTimestamp <= FIRMWARE_UPDATE_CONFIG_FRESHNESS_MS;
547
559
  if (hasFreshConfig) {
548
- if (requireResources && this.protocolV2ResourcesConfigError) {
560
+ const resourcesConfigError =
561
+ resourceDeviceType === EDeviceType.Pro2
562
+ ? this.protocolV2ResourcesConfigError
563
+ : this.protocolV2NeoResourcesConfigError;
564
+ if (requireResources && resourcesConfigError) {
549
565
  throw ERRORS.TypedError(
550
566
  HardwareErrorCode.FirmwareUpdateDownloadFailed,
551
- `Invalid Pro2 resources config: ${this.protocolV2ResourcesConfigError.message}`
567
+ `Invalid ${resourceDeviceName} resources config: ${resourcesConfigError.message}`
552
568
  );
553
569
  }
554
570
  return;
@@ -560,10 +576,14 @@ export default class DataManager {
560
576
  'Unable to refresh the latest remote config'
561
577
  );
562
578
  }
563
- if (requireResources && this.protocolV2ResourcesConfigError) {
579
+ const resourcesConfigError =
580
+ resourceDeviceType === EDeviceType.Pro2
581
+ ? this.protocolV2ResourcesConfigError
582
+ : this.protocolV2NeoResourcesConfigError;
583
+ if (requireResources && resourcesConfigError) {
564
584
  throw ERRORS.TypedError(
565
585
  HardwareErrorCode.FirmwareUpdateDownloadFailed,
566
- `Invalid Pro2 resources config: ${this.protocolV2ResourcesConfigError.message}`
586
+ `Invalid ${resourceDeviceName} resources config: ${resourcesConfigError.message}`
567
587
  );
568
588
  }
569
589
  this.lastCheckTimestamp = getTimeStamp();
@@ -75,7 +75,6 @@ export type AllFirmwareRelease = {
75
75
  required?: boolean;
76
76
  resourceStatus?: 'valid' | 'outdated' | 'unknown';
77
77
  resourceArchive?: IProtocolV2ResourceSource;
78
- resourcePreparationRequired?: boolean;
79
78
  currentVersions?: DeviceStateVersions;
80
79
  components?: ProtocolV2FirmwareComponentRelease[];
81
80
  targetsToUpdate?: FirmwareUpdateV4Target[];
@@ -26,6 +26,8 @@ export interface FirmwareArtifactReader {
26
26
 
27
27
  export interface FirmwareUpdateHostBinding {
28
28
  artifactReader: FirmwareArtifactReader;
29
+ /** 将读取器 generation 绑定到包含 ZIP 条目的完整 PreparedPlan。 */
30
+ preparedPlanDigest: string;
29
31
  }
30
32
 
31
33
  export interface FirmwareUpdateBinaryParams {
@@ -159,22 +159,20 @@ export type IBLEFirmwareReleaseInfo = {
159
159
  };
160
160
 
161
161
  type IKnownDevice = Exclude<IDeviceType, 'unknown'>;
162
- type ILegacyKnownDevice = Exclude<IKnownDevice, 'neo'>;
163
-
164
162
  type IDeviceReleaseInfo = {
165
- firmware: IFirmwareReleaseInfo[];
163
+ firmware?: IFirmwareReleaseInfo[];
166
164
  /** Protocol V2 payload package set */
167
165
  'firmware-v1'?: IFirmwareReleaseInfo[];
168
166
  'firmware-v2'?: IFirmwareReleaseInfo[];
169
167
  'firmware-v8'?: IFirmwareReleaseInfo[];
170
168
  'firmware-btc-v8'?: IFirmwareReleaseInfo[];
171
- ble: IBLEFirmwareReleaseInfo[];
169
+ ble?: IBLEFirmwareReleaseInfo[];
172
170
  /** Independent Protocol V2 resource release configuration. */
173
171
  resources?: IProtocolV2Resources;
174
172
  };
175
173
 
176
174
  export type DeviceTypeMap = {
177
- [k in ILegacyKnownDevice]: IDeviceReleaseInfo;
175
+ [k in Exclude<IKnownDevice, 'neo'>]: IDeviceReleaseInfo;
178
176
  } & {
179
177
  /** Optional until every remote-config producer publishes a Neo entry. */
180
178
  neo?: IDeviceReleaseInfo;