@onekeyfe/hd-core 1.2.0-alpha.96 → 1.2.0-alpha.97

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 (89) hide show
  1. package/__tests__/check-all-firmware-release-protocol-v2.test.ts +84 -404
  2. package/__tests__/firmware-update/device-update-bootloader.test.ts +2 -6
  3. package/__tests__/firmware-update/firmware-host-binding.test.ts +0 -9
  4. package/__tests__/firmware-update/firmware-update-bootloader-poll.test.ts +112 -0
  5. package/__tests__/firmware-update/firmware-update-plan.test.ts +70 -131
  6. package/__tests__/firmware-update/firmware-update-prepared-plan.test.ts +1 -53
  7. package/__tests__/protocol-v2-resources.test.ts +232 -148
  8. package/__tests__/protocol-v2.test.ts +517 -1106
  9. package/dist/api/CheckAllFirmwareRelease.d.ts +3 -2
  10. package/dist/api/CheckAllFirmwareRelease.d.ts.map +1 -1
  11. package/dist/api/CheckBLEFirmwareRelease.d.ts +2 -3
  12. package/dist/api/CheckBLEFirmwareRelease.d.ts.map +1 -1
  13. package/dist/api/CheckBootloaderRelease.d.ts +1 -2
  14. package/dist/api/CheckBootloaderRelease.d.ts.map +1 -1
  15. package/dist/api/CheckFirmwareRelease.d.ts +2 -3
  16. package/dist/api/CheckFirmwareRelease.d.ts.map +1 -1
  17. package/dist/api/FirmwareUpdateV2.d.ts +0 -1
  18. package/dist/api/FirmwareUpdateV2.d.ts.map +1 -1
  19. package/dist/api/FirmwareUpdateV3.d.ts.map +1 -1
  20. package/dist/api/FirmwareUpdateV4.d.ts +8 -6
  21. package/dist/api/FirmwareUpdateV4.d.ts.map +1 -1
  22. package/dist/api/UploadPortfolio.d.ts.map +1 -1
  23. package/dist/api/device/DeviceUpdateBootloader.d.ts.map +1 -1
  24. package/dist/api/firmware/FirmwareHostBinding.d.ts +1 -1
  25. package/dist/api/firmware/FirmwareHostBinding.d.ts.map +1 -1
  26. package/dist/api/firmware/FirmwareUpdateBaseMethod.d.ts.map +1 -1
  27. package/dist/api/firmware/FirmwareUpdatePlan.d.ts +1 -48
  28. package/dist/api/firmware/FirmwareUpdatePlan.d.ts.map +1 -1
  29. package/dist/api/firmware/FirmwareUpdatePreparedPlan.d.ts.map +1 -1
  30. package/dist/api/firmware/getBinary.d.ts +1 -0
  31. package/dist/api/firmware/getBinary.d.ts.map +1 -1
  32. package/dist/data-manager/DataManager.d.ts +3 -4
  33. package/dist/data-manager/DataManager.d.ts.map +1 -1
  34. package/dist/index.d.ts +111 -103
  35. package/dist/index.d.ts.map +1 -1
  36. package/dist/index.js +849 -1313
  37. package/dist/protocols/protocol-v2/resources.d.ts +28 -10
  38. package/dist/protocols/protocol-v2/resources.d.ts.map +1 -1
  39. package/dist/types/api/checkAllFirmwareRelease.d.ts +8 -20
  40. package/dist/types/api/checkAllFirmwareRelease.d.ts.map +1 -1
  41. package/dist/types/api/checkBLEFirmwareRelease.d.ts +13 -2
  42. package/dist/types/api/checkBLEFirmwareRelease.d.ts.map +1 -1
  43. package/dist/types/api/checkBootloaderRelease.d.ts +6 -2
  44. package/dist/types/api/checkBootloaderRelease.d.ts.map +1 -1
  45. package/dist/types/api/checkFirmwareRelease.d.ts +13 -2
  46. package/dist/types/api/checkFirmwareRelease.d.ts.map +1 -1
  47. package/dist/types/api/checkFirmwareTypeAvailable.d.ts +2 -2
  48. package/dist/types/api/checkFirmwareTypeAvailable.d.ts.map +1 -1
  49. package/dist/types/api/export.d.ts +1 -1
  50. package/dist/types/api/export.d.ts.map +1 -1
  51. package/dist/types/api/firmwareUpdate.d.ts +11 -3
  52. package/dist/types/api/firmwareUpdate.d.ts.map +1 -1
  53. package/dist/types/settings.d.ts +36 -35
  54. package/dist/types/settings.d.ts.map +1 -1
  55. package/package.json +4 -4
  56. package/src/api/CheckAllFirmwareRelease.ts +80 -108
  57. package/src/api/CheckBLEFirmwareRelease.ts +5 -37
  58. package/src/api/CheckBootloaderRelease.ts +3 -35
  59. package/src/api/CheckFirmwareRelease.ts +7 -35
  60. package/src/api/FirmwareUpdateV2.ts +3 -15
  61. package/src/api/FirmwareUpdateV3.ts +7 -29
  62. package/src/api/FirmwareUpdateV4.ts +407 -824
  63. package/src/api/UploadPortfolio.ts +0 -18
  64. package/src/api/device/DeviceUpdateBootloader.ts +5 -26
  65. package/src/api/firmware/FirmwareHostBinding.ts +3 -16
  66. package/src/api/firmware/FirmwareUpdateBaseMethod.ts +2 -0
  67. package/src/api/firmware/FirmwareUpdatePlan.ts +88 -226
  68. package/src/api/firmware/FirmwareUpdatePreparedPlan.ts +3 -10
  69. package/src/data-manager/DataManager.ts +19 -35
  70. package/src/index.ts +0 -10
  71. package/src/protocols/protocol-v2/resources.ts +341 -157
  72. package/src/types/api/checkAllFirmwareRelease.ts +12 -27
  73. package/src/types/api/checkBLEFirmwareRelease.ts +13 -4
  74. package/src/types/api/checkBootloaderRelease.ts +6 -2
  75. package/src/types/api/checkFirmwareRelease.ts +13 -2
  76. package/src/types/api/checkFirmwareTypeAvailable.ts +2 -2
  77. package/src/types/api/export.ts +1 -6
  78. package/src/types/api/firmwareUpdate.ts +16 -10
  79. package/src/types/settings.ts +61 -35
  80. package/src/utils/deviceFeaturesUtils.ts +2 -2
  81. package/__tests__/check-firmware-release-protocol-v2.test.ts +0 -199
  82. package/__tests__/firmware-memory-host.test.ts +0 -112
  83. package/__tests__/firmware-update/firmware-prepared-host-digest.test.ts +0 -469
  84. package/dist/api/firmware/FirmwareMemoryHost.d.ts +0 -22
  85. package/dist/api/firmware/FirmwareMemoryHost.d.ts.map +0 -1
  86. package/dist/api/firmware/protocolV2Release.d.ts +0 -33
  87. package/dist/api/firmware/protocolV2Release.d.ts.map +0 -1
  88. package/src/api/firmware/FirmwareMemoryHost.ts +0 -142
  89. package/src/api/firmware/protocolV2Release.ts +0 -168
@@ -94,10 +94,12 @@ export default class DataManager {
94
94
  ble: [],
95
95
  },
96
96
  [EDeviceType.Pro2]: {
97
- 'firmware-v1': [],
97
+ firmware: [],
98
+ ble: [],
98
99
  },
99
100
  [EDeviceType.Neo]: {
100
- 'firmware-v1': [],
101
+ firmware: [],
102
+ ble: [],
101
103
  },
102
104
  [EDeviceType.ClassicPure]: {
103
105
  firmware: [],
@@ -119,8 +121,6 @@ export default class DataManager {
119
121
 
120
122
  static protocolV2ResourcesConfigError: Error | undefined;
121
123
 
122
- private static protocolV2NeoResourcesConfigError: Error | undefined;
123
-
124
124
  static getFirmwareStatus = (
125
125
  features: Features,
126
126
  firmwareType: EFirmwareType
@@ -410,7 +410,6 @@ 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;
414
413
  const manifestMode =
415
414
  settings.firmwareManifestMode ?? (settings.fetchConfig ? 'sdk-managed' : undefined);
416
415
  if (settings.preloadedConfig) {
@@ -477,21 +476,15 @@ export default class DataManager {
477
476
  pro2Resources = parseProtocolV2Resources(
478
477
  (data.pro2 as { resources?: unknown } | undefined)?.resources
479
478
  );
480
- } catch (error) {
481
- // Firmware resource metadata is not required for base communication. If the
482
- // remote config is temporarily incomplete, disable this resource update only.
483
- this.protocolV2ResourcesConfigError =
484
- error instanceof Error ? error : new Error(String(error));
485
- Log.warn('[DataConfig] Ignoring invalid Pro2 resources config:', error);
486
- }
487
- try {
488
479
  neoResources = parseProtocolV2Resources(
489
480
  (data.neo as { resources?: unknown } | undefined)?.resources
490
481
  );
491
482
  } catch (error) {
492
- this.protocolV2NeoResourcesConfigError =
483
+ // Firmware resource metadata is not required for base communication. If the
484
+ // remote config is temporarily incomplete, disable this resource update only.
485
+ this.protocolV2ResourcesConfigError =
493
486
  error instanceof Error ? error : new Error(String(error));
494
- Log.warn('[DataConfig] Ignoring invalid Neo resources config:', error);
487
+ Log.warn('[DataConfig] Ignoring invalid Protocol V2 resources config:', error);
495
488
  }
496
489
  const enrichedPro2Config = this.enrichFirmwareReleaseInfo(data.pro2);
497
490
  const enrichedNeoConfig = this.enrichFirmwareReleaseInfo(data.neo);
@@ -544,12 +537,7 @@ export default class DataManager {
544
537
  /** Force a fresh remote config before an update is allowed to mutate the device. */
545
538
  static async forceReloadData({
546
539
  requireResources = false,
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';
540
+ }: { requireResources?: boolean } = {}): Promise<void> {
553
541
  if (!this.settings) {
554
542
  throw new Error('Remote config settings are not initialized');
555
543
  }
@@ -557,14 +545,10 @@ export default class DataManager {
557
545
  this.lastCheckTimestamp > 0 &&
558
546
  getTimeStamp() - this.lastCheckTimestamp <= FIRMWARE_UPDATE_CONFIG_FRESHNESS_MS;
559
547
  if (hasFreshConfig) {
560
- const resourcesConfigError =
561
- resourceDeviceType === EDeviceType.Pro2
562
- ? this.protocolV2ResourcesConfigError
563
- : this.protocolV2NeoResourcesConfigError;
564
- if (requireResources && resourcesConfigError) {
548
+ if (requireResources && this.protocolV2ResourcesConfigError) {
565
549
  throw ERRORS.TypedError(
566
550
  HardwareErrorCode.FirmwareUpdateDownloadFailed,
567
- `Invalid ${resourceDeviceName} resources config: ${resourcesConfigError.message}`
551
+ `Invalid Pro2 resources config: ${this.protocolV2ResourcesConfigError.message}`
568
552
  );
569
553
  }
570
554
  return;
@@ -576,23 +560,23 @@ export default class DataManager {
576
560
  'Unable to refresh the latest remote config'
577
561
  );
578
562
  }
579
- const resourcesConfigError =
580
- resourceDeviceType === EDeviceType.Pro2
581
- ? this.protocolV2ResourcesConfigError
582
- : this.protocolV2NeoResourcesConfigError;
583
- if (requireResources && resourcesConfigError) {
563
+ if (requireResources && this.protocolV2ResourcesConfigError) {
584
564
  throw ERRORS.TypedError(
585
565
  HardwareErrorCode.FirmwareUpdateDownloadFailed,
586
- `Invalid ${resourceDeviceName} resources config: ${resourcesConfigError.message}`
566
+ `Invalid Pro2 resources config: ${this.protocolV2ResourcesConfigError.message}`
587
567
  );
588
568
  }
589
569
  this.lastCheckTimestamp = getTimeStamp();
590
570
  }
591
571
 
592
- static getProtocolV2ResourceSource(
572
+ static getProtocolV2Resources(deviceType: EDeviceType.Pro2 | EDeviceType.Neo = EDeviceType.Pro2) {
573
+ return this.deviceMap[deviceType]?.resources?.stable;
574
+ }
575
+
576
+ static getProtocolV2BootResources(
593
577
  deviceType: EDeviceType.Pro2 | EDeviceType.Neo = EDeviceType.Pro2
594
578
  ) {
595
- return this.deviceMap[deviceType]?.resources?.source;
579
+ return this.deviceMap[deviceType]?.resources?.boot;
596
580
  }
597
581
 
598
582
  static getProtobufMessages(schema: ProtobufMessageSchema = 'v1CurrentSchema'): JSON {
package/src/index.ts CHANGED
@@ -21,16 +21,6 @@ export { executeCallback, cleanupCallback };
21
21
  export { preloadSessionCache } from './device/Device';
22
22
  export { projectFeatures as projectDeviceStateFeatures } from './device/DeviceStateProjector';
23
23
  export { getMethodSupportedProtocols } from './api/utils';
24
- export {
25
- parseProtocolV2ResourceManifest,
26
- selectProtocolV2ResourceManifestFiles,
27
- } from './protocols/protocol-v2/resources';
28
- export { prepareFirmwareUpdateV4MemoryHost } from './api/firmware/FirmwareMemoryHost';
29
- export type {
30
- FirmwareMemoryArtifact,
31
- FirmwareMemoryArtifactEntry,
32
- FirmwareUpdateV4MemoryHost,
33
- } from './api/firmware/FirmwareMemoryHost';
34
24
  export {
35
25
  getFirmwareUpdateHostBindingGeneration,
36
26
  registerFirmwareUpdateHostBinding,