@onekeyfe/hd-core 1.2.0-alpha.95 → 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.
- package/__tests__/check-all-firmware-release-protocol-v2.test.ts +84 -404
- package/__tests__/firmware-update/device-update-bootloader.test.ts +2 -6
- package/__tests__/firmware-update/firmware-host-binding.test.ts +0 -9
- package/__tests__/firmware-update/firmware-update-bootloader-poll.test.ts +112 -0
- package/__tests__/firmware-update/firmware-update-plan.test.ts +70 -131
- package/__tests__/firmware-update/firmware-update-prepared-plan.test.ts +1 -53
- package/__tests__/protocol-v2-resources.test.ts +232 -148
- package/__tests__/protocol-v2.test.ts +517 -1106
- package/dist/api/CheckAllFirmwareRelease.d.ts +3 -2
- package/dist/api/CheckAllFirmwareRelease.d.ts.map +1 -1
- package/dist/api/CheckBLEFirmwareRelease.d.ts +2 -3
- package/dist/api/CheckBLEFirmwareRelease.d.ts.map +1 -1
- package/dist/api/CheckBootloaderRelease.d.ts +1 -2
- package/dist/api/CheckBootloaderRelease.d.ts.map +1 -1
- package/dist/api/CheckFirmwareRelease.d.ts +2 -3
- package/dist/api/CheckFirmwareRelease.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV2.d.ts +0 -1
- package/dist/api/FirmwareUpdateV2.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV3.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV4.d.ts +8 -6
- package/dist/api/FirmwareUpdateV4.d.ts.map +1 -1
- package/dist/api/UploadPortfolio.d.ts.map +1 -1
- package/dist/api/device/DeviceUpdateBootloader.d.ts.map +1 -1
- package/dist/api/firmware/FirmwareHostBinding.d.ts +1 -1
- package/dist/api/firmware/FirmwareHostBinding.d.ts.map +1 -1
- package/dist/api/firmware/FirmwareUpdateBaseMethod.d.ts.map +1 -1
- package/dist/api/firmware/FirmwareUpdatePlan.d.ts +1 -48
- package/dist/api/firmware/FirmwareUpdatePlan.d.ts.map +1 -1
- package/dist/api/firmware/FirmwareUpdatePreparedPlan.d.ts.map +1 -1
- package/dist/api/firmware/getBinary.d.ts +1 -0
- package/dist/api/firmware/getBinary.d.ts.map +1 -1
- package/dist/data-manager/DataManager.d.ts +3 -4
- package/dist/data-manager/DataManager.d.ts.map +1 -1
- package/dist/index.d.ts +111 -103
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +849 -1301
- package/dist/protocols/protocol-v2/resources.d.ts +28 -10
- package/dist/protocols/protocol-v2/resources.d.ts.map +1 -1
- package/dist/types/api/checkAllFirmwareRelease.d.ts +8 -20
- package/dist/types/api/checkAllFirmwareRelease.d.ts.map +1 -1
- package/dist/types/api/checkBLEFirmwareRelease.d.ts +13 -2
- package/dist/types/api/checkBLEFirmwareRelease.d.ts.map +1 -1
- package/dist/types/api/checkBootloaderRelease.d.ts +6 -2
- package/dist/types/api/checkBootloaderRelease.d.ts.map +1 -1
- package/dist/types/api/checkFirmwareRelease.d.ts +13 -2
- package/dist/types/api/checkFirmwareRelease.d.ts.map +1 -1
- package/dist/types/api/checkFirmwareTypeAvailable.d.ts +2 -2
- package/dist/types/api/checkFirmwareTypeAvailable.d.ts.map +1 -1
- package/dist/types/api/export.d.ts +1 -1
- package/dist/types/api/export.d.ts.map +1 -1
- package/dist/types/api/firmwareUpdate.d.ts +11 -3
- package/dist/types/api/firmwareUpdate.d.ts.map +1 -1
- package/dist/types/settings.d.ts +36 -35
- package/dist/types/settings.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/api/CheckAllFirmwareRelease.ts +80 -108
- package/src/api/CheckBLEFirmwareRelease.ts +5 -37
- package/src/api/CheckBootloaderRelease.ts +3 -35
- package/src/api/CheckFirmwareRelease.ts +7 -35
- package/src/api/FirmwareUpdateV2.ts +3 -15
- package/src/api/FirmwareUpdateV3.ts +6 -13
- package/src/api/FirmwareUpdateV4.ts +407 -824
- package/src/api/UploadPortfolio.ts +0 -18
- package/src/api/device/DeviceUpdateBootloader.ts +5 -26
- package/src/api/firmware/FirmwareHostBinding.ts +3 -16
- package/src/api/firmware/FirmwareUpdateBaseMethod.ts +2 -0
- package/src/api/firmware/FirmwareUpdatePlan.ts +88 -226
- package/src/api/firmware/FirmwareUpdatePreparedPlan.ts +3 -10
- package/src/data-manager/DataManager.ts +19 -35
- package/src/index.ts +0 -10
- package/src/protocols/protocol-v2/resources.ts +341 -157
- package/src/types/api/checkAllFirmwareRelease.ts +12 -27
- package/src/types/api/checkBLEFirmwareRelease.ts +13 -4
- package/src/types/api/checkBootloaderRelease.ts +6 -2
- package/src/types/api/checkFirmwareRelease.ts +13 -2
- package/src/types/api/checkFirmwareTypeAvailable.ts +2 -2
- package/src/types/api/export.ts +1 -6
- package/src/types/api/firmwareUpdate.ts +16 -10
- package/src/types/settings.ts +61 -35
- package/src/utils/deviceFeaturesUtils.ts +2 -2
- package/__tests__/check-firmware-release-protocol-v2.test.ts +0 -199
- package/__tests__/firmware-memory-host.test.ts +0 -112
- package/__tests__/firmware-update/firmware-prepared-host-digest.test.ts +0 -448
- package/dist/api/firmware/FirmwareMemoryHost.d.ts +0 -22
- package/dist/api/firmware/FirmwareMemoryHost.d.ts.map +0 -1
- package/dist/api/firmware/protocolV2Release.d.ts +0 -33
- package/dist/api/firmware/protocolV2Release.d.ts.map +0 -1
- package/src/api/firmware/FirmwareMemoryHost.ts +0 -142
- 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
|
-
|
|
97
|
+
firmware: [],
|
|
98
|
+
ble: [],
|
|
98
99
|
},
|
|
99
100
|
[EDeviceType.Neo]: {
|
|
100
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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
|
|
566
|
+
`Invalid Pro2 resources config: ${this.protocolV2ResourcesConfigError.message}`
|
|
587
567
|
);
|
|
588
568
|
}
|
|
589
569
|
this.lastCheckTimestamp = getTimeStamp();
|
|
590
570
|
}
|
|
591
571
|
|
|
592
|
-
static
|
|
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?.
|
|
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,
|