@onekeyfe/hd-core 1.2.0-alpha.86 → 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.
|
@@ -6329,6 +6329,41 @@ describe('Protocol V2 firmware update targets', () => {
|
|
|
6329
6329
|
}
|
|
6330
6330
|
});
|
|
6331
6331
|
|
|
6332
|
+
test('keeps the legacy componentArtifacts and artifactReader path without a prepared Plan', async () => {
|
|
6333
|
+
const artifactReader = {
|
|
6334
|
+
open: jest.fn(),
|
|
6335
|
+
read: jest.fn(),
|
|
6336
|
+
close: jest.fn(),
|
|
6337
|
+
};
|
|
6338
|
+
const method = new FirmwareUpdateV4({
|
|
6339
|
+
id: 1,
|
|
6340
|
+
payload: {
|
|
6341
|
+
method: 'firmwareUpdateV4',
|
|
6342
|
+
platform: 'web',
|
|
6343
|
+
targetsToUpdate: ['boot'],
|
|
6344
|
+
artifactReader,
|
|
6345
|
+
componentArtifacts: {
|
|
6346
|
+
boot: {
|
|
6347
|
+
artifactRef: 'legacy-bootloader',
|
|
6348
|
+
size: 3,
|
|
6349
|
+
sha256: 'a'.repeat(64),
|
|
6350
|
+
},
|
|
6351
|
+
},
|
|
6352
|
+
},
|
|
6353
|
+
});
|
|
6354
|
+
|
|
6355
|
+
expect(() => method.init()).not.toThrow();
|
|
6356
|
+
(method as any).captureProtocolV2PhysicalIdentity = jest.fn().mockResolvedValue(undefined);
|
|
6357
|
+
(method as any).device = stubDevice({
|
|
6358
|
+
originalDescriptor: { protocolType: 'V2' },
|
|
6359
|
+
features: { deviceType: 'pro2', firmwareVersion: '1.0.0', capabilities: [] },
|
|
6360
|
+
});
|
|
6361
|
+
(method as any).runProtocolV2PreparedArtifacts = jest.fn().mockResolvedValue('legacy-result');
|
|
6362
|
+
|
|
6363
|
+
await expect(method.run()).resolves.toBe('legacy-result');
|
|
6364
|
+
expect((method as any).runProtocolV2PreparedArtifacts).toHaveBeenCalledTimes(1);
|
|
6365
|
+
});
|
|
6366
|
+
|
|
6332
6367
|
test('stops a remote update before reboot when the latest config cannot be refreshed', async () => {
|
|
6333
6368
|
const method = new FirmwareUpdateV4({
|
|
6334
6369
|
id: 1,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FirmwareUpdateV4.d.ts","sourceRoot":"","sources":["../../src/api/FirmwareUpdateV4.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAkD,MAAM,qBAAqB,CAAC;AAwBlG,OAAO,EAAE,wBAAwB,EAAE,MAAM,qCAAqC,CAAC;AA2B/E,OAAO,KAAK,EAEV,sBAAsB,EAEvB,MAAM,6BAA6B,CAAC;AAgDrC,wBAAgB,wCAAwC,CACtD,UAAU,EAAE,WAAW,GAAG,MAAM,GAAG,SAAS,EAC5C,MAAM,EAAE,sBAAsB,QAgB/B;AAoUD,eAAO,MAAM,oCAAoC,WACvC,WAAW,GAAG,UAAU,eACnB,MAAM,GAAG,SAAS,YAKhC,CAAC;AAEF,eAAO,MAAM,iCAAiC,0BACrB,MAAM,uBACR,MAAM,iBACZ,MAAM,eACR,MAAM,SAsBpB,CAAC;AAUF,MAAM,CAAC,OAAO,OAAO,gBAAiB,SAAQ,wBAAwB,CAAC,sBAAsB,CAAC;IAC5F,OAAO,CAAC,8BAA8B,CAAC,CAAS;IAEhD,OAAO,CAAC,sBAAsB,CAAC,CAAS;IAExC,qBAAqB;IAIrB,OAAO,CAAC,yBAAyB,CAA4B;IAE7D,OAAO,CAAC,2BAA2B,CAAS;IAE5C,OAAO,CAAC,iCAAiC,CAA6B;IAEtE,OAAO,CAAC,6BAA6B,CAAC,CAAW;IAEjD,OAAO,CAAC,6BAA6B,CAAS;IAE9C,IAAI;IAyGJ,OAAO,CAAC,8BAA8B;IAwBhC,GAAG;;;;;YAKK,aAAa;
|
|
1
|
+
{"version":3,"file":"FirmwareUpdateV4.d.ts","sourceRoot":"","sources":["../../src/api/FirmwareUpdateV4.ts"],"names":[],"mappings":"AAAA,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AkBjC,iCAAiC;IAM/C,OAAO,CAAC,uBAAuB;IAI/B,OAAO,CAAC,mCAAmC;IAY3C,OAAO,CAAC,2BAA2B;IAsBnC,OAAO,CAAC,yBAAyB;IAiBjC,OAAO,CAAC,wBAAwB;YAkBlB,iCAAiC;YAmCjC,+BAA+B;IA6E7C,OAAO,CAAC,6BAA6B;YAMvB,8BAA8B;YA+C9B,kCAAkC;IA+BhD,OAAO,CAAC,0BAA0B;IAUlC,OAAO,CAAC,yBAAyB;IAc3B,6BAA6B;YAgCrB,+BAA+B;IAkD7C,OAAO,CAAC,6BAA6B;IAkCrC,OAAO,CAAC,8BAA8B;YA8CxB,uBAAuB;YAiCvB,6BAA6B;YAa7B,uBAAuB;YAiCvB,8BAA8B;YA8D9B,6BAA6B;IAuE3C,OAAO,CAAC,mCAAmC;YAI7B,0BAA0B;IAaxC,OAAO,CAAC,4BAA4B;IAyGpC,OAAO,CAAC,6BAA6B;YAcvB,uCAAuC;YA0JvC,gCAAgC;YAehC,yBAAyB;YAQzB,8BAA8B;IAQ5C,OAAO,CAAC,0BAA0B;YAkBpB,mCAAmC;YAWnC,qCAAqC;YAgDrC,yBAAyB;YA8DzB,8BAA8B;IAU5C,OAAO,CAAC,kCAAkC;YAQ5B,cAAc;YAuCd,6BAA6B;YAW7B,0BAA0B;YAS1B,6BAA6B;YAmB7B,gBAAgB;IAiB9B,OAAO,CAAC,qBAAqB;CAM9B"}
|
package/dist/index.js
CHANGED
|
@@ -51554,13 +51554,13 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
51554
51554
|
const preparedPlan = payload.preparedPlan
|
|
51555
51555
|
? validateFirmwareUpdatePreparedPlan(payload.preparedPlan)
|
|
51556
51556
|
: undefined;
|
|
51557
|
-
const hostBinding =
|
|
51557
|
+
const hostBinding = payload.hostBindingGeneration !== undefined
|
|
51558
51558
|
? resolveFirmwareUpdateHostBinding(payload.hostBindingGeneration, preparedPlan === null || preparedPlan === void 0 ? void 0 : preparedPlan.preparedPlanDigest)
|
|
51559
51559
|
: undefined;
|
|
51560
|
-
if (
|
|
51560
|
+
if (preparedPlan) {
|
|
51561
51561
|
const componentArtifacts = ((_a = payload.componentArtifacts) !== null && _a !== void 0 ? _a : {});
|
|
51562
51562
|
assertFirmwareUpdatePreparedPlanBinding({
|
|
51563
|
-
preparedPlan
|
|
51563
|
+
preparedPlan,
|
|
51564
51564
|
executor: 'v4',
|
|
51565
51565
|
platform: payload.platform,
|
|
51566
51566
|
scopeTargets: ['boot', 'app_v1', 'app_v2', 'coprocessor', 'se01', 'se02', 'se03', 'se04'],
|
|
@@ -51626,7 +51626,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
51626
51626
|
});
|
|
51627
51627
|
}
|
|
51628
51628
|
runProtocolV2() {
|
|
51629
|
-
var _a, _b, _c, _d;
|
|
51629
|
+
var _a, _b, _c, _d, _e;
|
|
51630
51630
|
return __awaiter(this, void 0, void 0, function* () {
|
|
51631
51631
|
yield this.captureProtocolV2PhysicalIdentity();
|
|
51632
51632
|
const deviceFeatures = yield this.getProtocolV2DeviceFeatures();
|
|
@@ -51638,10 +51638,11 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
51638
51638
|
const deviceFirmwareType = getFirmwareType(deviceFeatures);
|
|
51639
51639
|
const firmwareType = (_a = this.params.firmwareType) !== null && _a !== void 0 ? _a : deviceFirmwareType;
|
|
51640
51640
|
this.validateExpectedTargetVersions();
|
|
51641
|
-
|
|
51641
|
+
const hasPreparedComponentArtifacts = Object.values((_b = this.params.componentArtifacts) !== null && _b !== void 0 ? _b : {}).some(Boolean);
|
|
51642
|
+
if (this.params.preparedPlan || hasPreparedComponentArtifacts) {
|
|
51642
51643
|
return this.runProtocolV2PreparedArtifacts(deviceFeatures, firmwareType);
|
|
51643
51644
|
}
|
|
51644
|
-
const wantsResources = !!((
|
|
51645
|
+
const wantsResources = !!((_c = this.params.targetsToUpdate) === null || _c === void 0 ? void 0 : _c.includes('resource'));
|
|
51645
51646
|
let fwBinaryMap = [];
|
|
51646
51647
|
let bootloaderBinary = null;
|
|
51647
51648
|
let installItems;
|
|
@@ -51654,7 +51655,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
51654
51655
|
fwBinaryMap,
|
|
51655
51656
|
});
|
|
51656
51657
|
const missingFirmwareTargets = this.getMissingProtocolV2FirmwareTargets(explicitInstallItems);
|
|
51657
|
-
const needsRemoteFirmware = ((
|
|
51658
|
+
const needsRemoteFirmware = ((_d = this.params.targetsToUpdate) === null || _d === void 0 ? void 0 : _d.length)
|
|
51658
51659
|
? missingFirmwareTargets.length > 0
|
|
51659
51660
|
: explicitInstallItems.length === 0;
|
|
51660
51661
|
if (wantsResources) {
|
|
@@ -51684,7 +51685,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
51684
51685
|
if (typeof err === 'object' &&
|
|
51685
51686
|
err !== null &&
|
|
51686
51687
|
'params' in err &&
|
|
51687
|
-
((
|
|
51688
|
+
((_e = err.params) === null || _e === void 0 ? void 0 : _e.firmwareUpdateCode) === 'FirmwareArtifactsNotPrepared') {
|
|
51688
51689
|
throw err;
|
|
51689
51690
|
}
|
|
51690
51691
|
if (err instanceof hdShared.HardwareError && err.errorCode === hdShared.HardwareErrorCode.NetworkError) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/hd-core",
|
|
3
|
-
"version": "1.2.0-alpha.
|
|
3
|
+
"version": "1.2.0-alpha.87",
|
|
4
4
|
"description": "Core processes and APIs for communicating with OneKey hardware devices.",
|
|
5
5
|
"author": "OneKey",
|
|
6
6
|
"homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"url": "https://github.com/OneKeyHQ/hardware-js-sdk/issues"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@onekeyfe/hd-shared": "1.2.0-alpha.
|
|
29
|
-
"@onekeyfe/hd-transport": "1.2.0-alpha.
|
|
28
|
+
"@onekeyfe/hd-shared": "1.2.0-alpha.87",
|
|
29
|
+
"@onekeyfe/hd-transport": "1.2.0-alpha.87",
|
|
30
30
|
"axios": "1.15.2",
|
|
31
31
|
"bignumber.js": "^9.0.2",
|
|
32
32
|
"bytebuffer": "^5.0.1",
|
|
@@ -44,5 +44,5 @@
|
|
|
44
44
|
"@types/w3c-web-usb": "^1.0.10",
|
|
45
45
|
"@types/web-bluetooth": "^0.0.21"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "4192396a9d3cf4930ce7d710752db898155a3293"
|
|
48
48
|
}
|
|
@@ -559,18 +559,18 @@ export default class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod<FirmwareU
|
|
|
559
559
|
? validateFirmwareUpdatePreparedPlan(payload.preparedPlan)
|
|
560
560
|
: undefined;
|
|
561
561
|
const hostBinding =
|
|
562
|
-
|
|
562
|
+
payload.hostBindingGeneration !== undefined
|
|
563
563
|
? resolveFirmwareUpdateHostBinding(
|
|
564
564
|
payload.hostBindingGeneration,
|
|
565
565
|
preparedPlan?.preparedPlanDigest
|
|
566
566
|
)
|
|
567
567
|
: undefined;
|
|
568
|
-
if (
|
|
568
|
+
if (preparedPlan) {
|
|
569
569
|
const componentArtifacts = (payload.componentArtifacts ?? {}) as NonNullable<
|
|
570
570
|
FirmwareUpdateV4Params['componentArtifacts']
|
|
571
571
|
>;
|
|
572
572
|
assertFirmwareUpdatePreparedPlanBinding({
|
|
573
|
-
preparedPlan
|
|
573
|
+
preparedPlan,
|
|
574
574
|
executor: 'v4',
|
|
575
575
|
platform: payload.platform,
|
|
576
576
|
scopeTargets: ['boot', 'app_v1', 'app_v2', 'coprocessor', 'se01', 'se02', 'se03', 'se04'],
|
|
@@ -654,7 +654,10 @@ export default class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod<FirmwareU
|
|
|
654
654
|
const firmwareType = this.params.firmwareType ?? deviceFirmwareType;
|
|
655
655
|
this.validateExpectedTargetVersions();
|
|
656
656
|
|
|
657
|
-
|
|
657
|
+
const hasPreparedComponentArtifacts = Object.values(this.params.componentArtifacts ?? {}).some(
|
|
658
|
+
Boolean
|
|
659
|
+
);
|
|
660
|
+
if (this.params.preparedPlan || hasPreparedComponentArtifacts) {
|
|
658
661
|
return this.runProtocolV2PreparedArtifacts(deviceFeatures, firmwareType);
|
|
659
662
|
}
|
|
660
663
|
const wantsResources = !!this.params.targetsToUpdate?.includes('resource');
|