@onekeyfe/hd-core 1.2.0-alpha.91 → 1.2.0-alpha.93
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.
|
@@ -6783,41 +6783,6 @@ describe('Protocol V2 firmware update targets', () => {
|
|
|
6783
6783
|
expect((method as any).params.targetsToUpdate).toEqual(['resource']);
|
|
6784
6784
|
});
|
|
6785
6785
|
|
|
6786
|
-
test.each([
|
|
6787
|
-
{
|
|
6788
|
-
resourceFiles: [
|
|
6789
|
-
{
|
|
6790
|
-
binary: new Uint8Array([1]).buffer,
|
|
6791
|
-
devicePath: 'vol0:/bundles/images/images.okpkg',
|
|
6792
|
-
},
|
|
6793
|
-
],
|
|
6794
|
-
},
|
|
6795
|
-
{
|
|
6796
|
-
resourceBundleArtifacts: [
|
|
6797
|
-
{
|
|
6798
|
-
name: 'images.okpkg',
|
|
6799
|
-
artifact: {
|
|
6800
|
-
artifactRef: 'legacy-resource',
|
|
6801
|
-
size: 1,
|
|
6802
|
-
sha256: '1'.repeat(64),
|
|
6803
|
-
},
|
|
6804
|
-
},
|
|
6805
|
-
],
|
|
6806
|
-
},
|
|
6807
|
-
])('returns an explicit migration error for legacy resource inputs', legacyInput => {
|
|
6808
|
-
const method = new FirmwareUpdateV4({
|
|
6809
|
-
id: 1,
|
|
6810
|
-
payload: {
|
|
6811
|
-
method: 'firmwareUpdateV4',
|
|
6812
|
-
platform: 'web',
|
|
6813
|
-
targetsToUpdate: ['resource'],
|
|
6814
|
-
...legacyInput,
|
|
6815
|
-
},
|
|
6816
|
-
});
|
|
6817
|
-
|
|
6818
|
-
expect(() => method.init()).toThrow('provide a complete signed resource ZIP');
|
|
6819
|
-
});
|
|
6820
|
-
|
|
6821
6786
|
test('keeps the legacy componentArtifacts and artifactReader path without a prepared Plan', async () => {
|
|
6822
6787
|
const artifactReader = {
|
|
6823
6788
|
open: jest.fn(),
|
|
@@ -7769,7 +7734,7 @@ describe('Protocol V2 firmware reconnect identity', () => {
|
|
|
7769
7734
|
);
|
|
7770
7735
|
});
|
|
7771
7736
|
|
|
7772
|
-
test('
|
|
7737
|
+
test('uses the connection route when DeviceInfo has no physical serial', async () => {
|
|
7773
7738
|
const method = new FirmwareUpdateV4({
|
|
7774
7739
|
id: 1,
|
|
7775
7740
|
payload: { method: 'firmwareUpdateV4' },
|
|
@@ -7779,12 +7744,14 @@ describe('Protocol V2 firmware reconnect identity', () => {
|
|
|
7779
7744
|
message: { protocol_version: 1, hw: {} },
|
|
7780
7745
|
});
|
|
7781
7746
|
(method as any).device = stubDevice({
|
|
7747
|
+
originalDescriptor: { path: '' },
|
|
7748
|
+
getConnectId: () => '000000000000',
|
|
7782
7749
|
getCommands: () => ({ typedCall }),
|
|
7783
7750
|
});
|
|
7784
7751
|
|
|
7785
|
-
await expect((method as any).captureProtocolV2PhysicalIdentity()).
|
|
7786
|
-
|
|
7787
|
-
|
|
7752
|
+
await expect((method as any).captureProtocolV2PhysicalIdentity()).resolves.toBeUndefined();
|
|
7753
|
+
expect((method as any).protocolV2ExpectedSerialNumber).toBeUndefined();
|
|
7754
|
+
expect((method as any).protocolV2ExpectedPath).toBe('000000000000');
|
|
7788
7755
|
});
|
|
7789
7756
|
|
|
7790
7757
|
test('uses the BLE read limit when reading an existing firmware bundle header', async () => {
|
|
@@ -36,6 +36,7 @@ export default class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod<FirmwareU
|
|
|
36
36
|
private getProtocolV2RequestedTargets;
|
|
37
37
|
private getProtocolV2DeviceFeatures;
|
|
38
38
|
private getProtocolV2SerialNumber;
|
|
39
|
+
private getProtocolV2ConnectionRoute;
|
|
39
40
|
private assertProtocolV2DeviceInfoIdentity;
|
|
40
41
|
private getProtocolV2DeviceInfoTimeout;
|
|
41
42
|
private requestProtocolV2PhysicalIdentity;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FirmwareUpdateV4.d.ts","sourceRoot":"","sources":["../../src/api/FirmwareUpdateV4.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;YAQ5B,cAAc;YAuCd,6BAA6B;YAW7B,0BAA0B;YAS1B,6BAA6B;YAmB7B,gBAAgB;IAiB9B,OAAO,CAAC,qBAAqB;CAM9B"}
|
package/dist/index.js
CHANGED
|
@@ -51637,7 +51637,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
51637
51637
|
return ['V2'];
|
|
51638
51638
|
}
|
|
51639
51639
|
init() {
|
|
51640
|
-
var _a, _b, _c
|
|
51640
|
+
var _a, _b, _c;
|
|
51641
51641
|
this.allowDeviceMode = [UI_REQUEST.BOOTLOADER, UI_REQUEST.NOT_INITIALIZE];
|
|
51642
51642
|
this.requireDeviceMode = [];
|
|
51643
51643
|
this.unlockPolicy = 'unlock-before-run';
|
|
@@ -51669,8 +51669,6 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
51669
51669
|
{ name: 'se03Binary', type: 'buffer' },
|
|
51670
51670
|
{ name: 'se04Binary', type: 'buffer' },
|
|
51671
51671
|
{ name: 'resourceArchiveBinary', type: 'buffer' },
|
|
51672
|
-
{ name: 'resourceFiles', type: 'array', allowEmpty: true },
|
|
51673
|
-
{ name: 'resourceBundleArtifacts', type: 'array', allowEmpty: true },
|
|
51674
51672
|
{ name: 'firmwareType', type: 'string' },
|
|
51675
51673
|
{ name: 'targetsToUpdate', type: 'array', allowEmpty: true },
|
|
51676
51674
|
{ name: 'platform', type: 'string' },
|
|
@@ -51680,9 +51678,6 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
51680
51678
|
(payload.expectedDeviceId.length === 0 || payload.expectedDeviceId.length > 160)) {
|
|
51681
51679
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.CallMethodInvalidParameter, 'Protocol V2 expected device identity is invalid');
|
|
51682
51680
|
}
|
|
51683
|
-
if (((_a = payload.resourceFiles) === null || _a === void 0 ? void 0 : _a.length) || ((_b = payload.resourceBundleArtifacts) === null || _b === void 0 ? void 0 : _b.length)) {
|
|
51684
|
-
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.CallMethodInvalidParameter, 'Protocol V2 resourceFiles and resourceBundleArtifacts are deprecated; provide a complete signed resource ZIP through resourceArchiveBinary or preparedPlan');
|
|
51685
|
-
}
|
|
51686
51681
|
const preparedPlan = payload.preparedPlan
|
|
51687
51682
|
? validateFirmwareUpdatePreparedPlan(payload.preparedPlan)
|
|
51688
51683
|
: undefined;
|
|
@@ -51699,7 +51694,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
51699
51694
|
payload.resourceArchiveBinary,
|
|
51700
51695
|
].some(Boolean);
|
|
51701
51696
|
if (preparedPlan && hasLocalArtifacts) {
|
|
51702
|
-
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.CallMethodInvalidParameter, 'Prepared firmware plans cannot be combined with local firmware
|
|
51697
|
+
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.CallMethodInvalidParameter, 'Prepared firmware plans cannot be combined with legacy or local firmware inputs');
|
|
51703
51698
|
}
|
|
51704
51699
|
const hostBinding = payload.hostBindingGeneration !== undefined
|
|
51705
51700
|
? resolveFirmwareUpdateHostBinding(payload.hostBindingGeneration, preparedPlan === null || preparedPlan === void 0 ? void 0 : preparedPlan.preparedPlanDigest)
|
|
@@ -51739,7 +51734,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
51739
51734
|
}
|
|
51740
51735
|
return result;
|
|
51741
51736
|
}, {});
|
|
51742
|
-
const localTargetsToUpdate = (
|
|
51737
|
+
const localTargetsToUpdate = (_a = payload.targetsToUpdate) === null || _a === void 0 ? void 0 : _a.map((target) => target === 'boot_resources' ? 'resource' : target);
|
|
51743
51738
|
if (payload.resourceArchiveBinary &&
|
|
51744
51739
|
localTargetsToUpdate &&
|
|
51745
51740
|
!localTargetsToUpdate.includes('resource')) {
|
|
@@ -51760,7 +51755,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
51760
51755
|
se03Binary: payload.se03Binary,
|
|
51761
51756
|
se04Binary: payload.se04Binary,
|
|
51762
51757
|
resourceArchiveBinary: payload.resourceArchiveBinary,
|
|
51763
|
-
firmwareType: (
|
|
51758
|
+
firmwareType: (_b = preparedPlan === null || preparedPlan === void 0 ? void 0 : preparedPlan.firmwareType) !== null && _b !== void 0 ? _b : payload.firmwareType,
|
|
51764
51759
|
targetsToUpdate: preparedPlan
|
|
51765
51760
|
? [...preparedPlan.targetsToUpdate]
|
|
51766
51761
|
: resolvedLocalTargetsToUpdate,
|
|
@@ -51769,7 +51764,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
51769
51764
|
: payload.expectedTargetVersions,
|
|
51770
51765
|
platform: payload.platform,
|
|
51771
51766
|
expectedDeviceId: payload.expectedDeviceId,
|
|
51772
|
-
artifactReader: (
|
|
51767
|
+
artifactReader: (_c = hostBinding === null || hostBinding === void 0 ? void 0 : hostBinding.artifactReader) !== null && _c !== void 0 ? _c : payload.artifactReader,
|
|
51773
51768
|
componentArtifacts: preparedPlan ? undefined : payload.componentArtifacts,
|
|
51774
51769
|
};
|
|
51775
51770
|
}
|
|
@@ -52374,8 +52369,16 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
52374
52369
|
const serialNumber = (_b = (_a = deviceInfo.hw) === null || _a === void 0 ? void 0 : _a.serial_no) === null || _b === void 0 ? void 0 : _b.trim();
|
|
52375
52370
|
return serialNumber || undefined;
|
|
52376
52371
|
}
|
|
52372
|
+
getProtocolV2ConnectionRoute() {
|
|
52373
|
+
var _a, _b, _c, _d, _e;
|
|
52374
|
+
const descriptor = this.device.originalDescriptor;
|
|
52375
|
+
return (((_a = descriptor === null || descriptor === void 0 ? void 0 : descriptor.path) === null || _a === void 0 ? void 0 : _a.trim()) ||
|
|
52376
|
+
((_d = (_c = (_b = this.device).getConnectId) === null || _c === void 0 ? void 0 : _c.call(_b)) === null || _d === void 0 ? void 0 : _d.trim()) ||
|
|
52377
|
+
((_e = descriptor === null || descriptor === void 0 ? void 0 : descriptor.id) === null || _e === void 0 ? void 0 : _e.trim()) ||
|
|
52378
|
+
undefined);
|
|
52379
|
+
}
|
|
52377
52380
|
assertProtocolV2DeviceInfoIdentity(deviceInfo) {
|
|
52378
|
-
assertProtocolV2ReconnectIdentity(this.protocolV2ExpectedSerialNumber, this.getProtocolV2SerialNumber(deviceInfo), this.protocolV2ExpectedPath, this.
|
|
52381
|
+
assertProtocolV2ReconnectIdentity(this.protocolV2ExpectedSerialNumber, this.getProtocolV2SerialNumber(deviceInfo), this.protocolV2ExpectedPath, this.getProtocolV2ConnectionRoute());
|
|
52379
52382
|
}
|
|
52380
52383
|
getProtocolV2DeviceInfoTimeout() {
|
|
52381
52384
|
var _a;
|
|
@@ -52392,19 +52395,19 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
52392
52395
|
});
|
|
52393
52396
|
}
|
|
52394
52397
|
captureProtocolV2PhysicalIdentity() {
|
|
52395
|
-
var _a, _b, _c
|
|
52398
|
+
var _a, _b, _c;
|
|
52396
52399
|
return __awaiter(this, void 0, void 0, function* () {
|
|
52397
52400
|
const deviceInfo = yield this.requestProtocolV2PhysicalIdentity();
|
|
52398
52401
|
const serialNumber = this.getProtocolV2SerialNumber(deviceInfo);
|
|
52399
|
-
const path =
|
|
52400
|
-
if ((
|
|
52402
|
+
const path = this.getProtocolV2ConnectionRoute();
|
|
52403
|
+
if ((_a = this.params) === null || _a === void 0 ? void 0 : _a.preparedPlan) {
|
|
52401
52404
|
assertFirmwareUpdatePreparedPlanDeviceIdentity({
|
|
52402
52405
|
preparedPlan: this.params.preparedPlan,
|
|
52403
52406
|
deviceIdentity: serialNumber,
|
|
52404
52407
|
});
|
|
52405
52408
|
}
|
|
52406
|
-
else if ((
|
|
52407
|
-
assertProtocolV2ReconnectIdentity((
|
|
52409
|
+
else if ((_b = this.params) === null || _b === void 0 ? void 0 : _b.expectedDeviceId) {
|
|
52410
|
+
assertProtocolV2ReconnectIdentity((_c = this.params) === null || _c === void 0 ? void 0 : _c.expectedDeviceId, serialNumber);
|
|
52408
52411
|
}
|
|
52409
52412
|
else {
|
|
52410
52413
|
assertProtocolV2ReconnectIdentity(serialNumber, serialNumber, path, path);
|
|
@@ -52819,7 +52822,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
52819
52822
|
});
|
|
52820
52823
|
});
|
|
52821
52824
|
}
|
|
52822
|
-
executeProtocolV2Update({ fwBinaryMap, bootloaderBinary, installItems,
|
|
52825
|
+
executeProtocolV2Update({ fwBinaryMap, bootloaderBinary, installItems, }) {
|
|
52823
52826
|
return __awaiter(this, void 0, void 0, function* () {
|
|
52824
52827
|
const memoryInstallItems = installItems !== null && installItems !== void 0 ? installItems : this.buildProtocolV2InstallItems({
|
|
52825
52828
|
fwBinaryMap: fwBinaryMap !== null && fwBinaryMap !== void 0 ? fwBinaryMap : [],
|
|
@@ -52834,12 +52837,9 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
52834
52837
|
kind: item.kind,
|
|
52835
52838
|
});
|
|
52836
52839
|
})));
|
|
52837
|
-
const resourceSources = yield Promise.all(resourceBundles.map((resource) => __awaiter(this, void 0, void 0, function* () {
|
|
52838
|
-
return (Object.assign(Object.assign(Object.assign({ name: resource.name, source: yield this.openProtocolV2MemorySource(resource.binary), devicePath: resource.devicePath }, (resource.version ? { version: resource.version } : {})), (resource.payloadHash ? { payloadHash: resource.payloadHash } : {})), (resource.headerHash ? { headerHash: resource.headerHash } : {})));
|
|
52839
|
-
})));
|
|
52840
52840
|
return yield this.executeProtocolV2Phases({
|
|
52841
52841
|
installSources,
|
|
52842
|
-
resourceSources,
|
|
52842
|
+
resourceSources: [],
|
|
52843
52843
|
});
|
|
52844
52844
|
}
|
|
52845
52845
|
finally {
|
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.93",
|
|
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.93",
|
|
29
|
+
"@onekeyfe/hd-transport": "1.2.0-alpha.93",
|
|
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": "0cae321e989b47b8c05455b2d59755e5322f2bb1"
|
|
48
48
|
}
|
|
@@ -213,10 +213,6 @@ type ProtocolV2ResourceBundleSource = {
|
|
|
213
213
|
headerHash?: string;
|
|
214
214
|
};
|
|
215
215
|
|
|
216
|
-
type ProtocolV2ResourceBundleBinary = Omit<ProtocolV2ResourceBundleSource, 'source'> & {
|
|
217
|
-
binary: ArrayBuffer;
|
|
218
|
-
};
|
|
219
|
-
|
|
220
216
|
type ProtocolV2LocalResourceArchive = {
|
|
221
217
|
binary: ArrayBuffer;
|
|
222
218
|
materializedEntries: FirmwareMemoryArtifactEntry[];
|
|
@@ -609,8 +605,6 @@ export default class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod<FirmwareU
|
|
|
609
605
|
{ name: 'se03Binary', type: 'buffer' },
|
|
610
606
|
{ name: 'se04Binary', type: 'buffer' },
|
|
611
607
|
{ name: 'resourceArchiveBinary', type: 'buffer' },
|
|
612
|
-
{ name: 'resourceFiles', type: 'array', allowEmpty: true },
|
|
613
|
-
{ name: 'resourceBundleArtifacts', type: 'array', allowEmpty: true },
|
|
614
608
|
{ name: 'firmwareType', type: 'string' },
|
|
615
609
|
{ name: 'targetsToUpdate', type: 'array', allowEmpty: true },
|
|
616
610
|
{ name: 'platform', type: 'string' },
|
|
@@ -625,12 +619,6 @@ export default class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod<FirmwareU
|
|
|
625
619
|
'Protocol V2 expected device identity is invalid'
|
|
626
620
|
);
|
|
627
621
|
}
|
|
628
|
-
if (payload.resourceFiles?.length || payload.resourceBundleArtifacts?.length) {
|
|
629
|
-
throw ERRORS.TypedError(
|
|
630
|
-
HardwareErrorCode.CallMethodInvalidParameter,
|
|
631
|
-
'Protocol V2 resourceFiles and resourceBundleArtifacts are deprecated; provide a complete signed resource ZIP through resourceArchiveBinary or preparedPlan'
|
|
632
|
-
);
|
|
633
|
-
}
|
|
634
622
|
const preparedPlan = payload.preparedPlan
|
|
635
623
|
? validateFirmwareUpdatePreparedPlan(payload.preparedPlan)
|
|
636
624
|
: undefined;
|
|
@@ -649,7 +637,7 @@ export default class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod<FirmwareU
|
|
|
649
637
|
if (preparedPlan && hasLocalArtifacts) {
|
|
650
638
|
throw ERRORS.TypedError(
|
|
651
639
|
HardwareErrorCode.CallMethodInvalidParameter,
|
|
652
|
-
'Prepared firmware plans cannot be combined with local firmware
|
|
640
|
+
'Prepared firmware plans cannot be combined with legacy or local firmware inputs'
|
|
653
641
|
);
|
|
654
642
|
}
|
|
655
643
|
const hostBinding =
|
|
@@ -1585,12 +1573,22 @@ export default class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod<FirmwareU
|
|
|
1585
1573
|
return serialNumber || undefined;
|
|
1586
1574
|
}
|
|
1587
1575
|
|
|
1576
|
+
private getProtocolV2ConnectionRoute() {
|
|
1577
|
+
const descriptor = this.device.originalDescriptor;
|
|
1578
|
+
return (
|
|
1579
|
+
descriptor?.path?.trim() ||
|
|
1580
|
+
this.device.getConnectId?.()?.trim() ||
|
|
1581
|
+
descriptor?.id?.trim() ||
|
|
1582
|
+
undefined
|
|
1583
|
+
);
|
|
1584
|
+
}
|
|
1585
|
+
|
|
1588
1586
|
private assertProtocolV2DeviceInfoIdentity(deviceInfo: ProtocolV2DeviceInfo) {
|
|
1589
1587
|
assertProtocolV2ReconnectIdentity(
|
|
1590
1588
|
this.protocolV2ExpectedSerialNumber,
|
|
1591
1589
|
this.getProtocolV2SerialNumber(deviceInfo),
|
|
1592
1590
|
this.protocolV2ExpectedPath,
|
|
1593
|
-
this.
|
|
1591
|
+
this.getProtocolV2ConnectionRoute()
|
|
1594
1592
|
);
|
|
1595
1593
|
}
|
|
1596
1594
|
|
|
@@ -1610,7 +1608,7 @@ export default class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod<FirmwareU
|
|
|
1610
1608
|
private async captureProtocolV2PhysicalIdentity() {
|
|
1611
1609
|
const deviceInfo = await this.requestProtocolV2PhysicalIdentity();
|
|
1612
1610
|
const serialNumber = this.getProtocolV2SerialNumber(deviceInfo);
|
|
1613
|
-
const path = this.
|
|
1611
|
+
const path = this.getProtocolV2ConnectionRoute();
|
|
1614
1612
|
if (this.params?.preparedPlan) {
|
|
1615
1613
|
assertFirmwareUpdatePreparedPlanDeviceIdentity({
|
|
1616
1614
|
preparedPlan: this.params.preparedPlan,
|
|
@@ -2159,12 +2157,10 @@ export default class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod<FirmwareU
|
|
|
2159
2157
|
fwBinaryMap,
|
|
2160
2158
|
bootloaderBinary,
|
|
2161
2159
|
installItems,
|
|
2162
|
-
resourceBundles = [],
|
|
2163
2160
|
}: {
|
|
2164
2161
|
fwBinaryMap?: ProtocolV2TargetBinary[];
|
|
2165
2162
|
bootloaderBinary?: ArrayBuffer | null;
|
|
2166
2163
|
installItems?: ProtocolV2InstallItem[];
|
|
2167
|
-
resourceBundles?: ProtocolV2ResourceBundleBinary[];
|
|
2168
2164
|
}) {
|
|
2169
2165
|
const memoryInstallItems =
|
|
2170
2166
|
installItems ??
|
|
@@ -2181,19 +2177,9 @@ export default class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod<FirmwareU
|
|
|
2181
2177
|
kind: item.kind,
|
|
2182
2178
|
}))
|
|
2183
2179
|
);
|
|
2184
|
-
const resourceSources = await Promise.all(
|
|
2185
|
-
resourceBundles.map(async resource => ({
|
|
2186
|
-
name: resource.name,
|
|
2187
|
-
source: await this.openProtocolV2MemorySource(resource.binary),
|
|
2188
|
-
devicePath: resource.devicePath,
|
|
2189
|
-
...(resource.version ? { version: resource.version } : {}),
|
|
2190
|
-
...(resource.payloadHash ? { payloadHash: resource.payloadHash } : {}),
|
|
2191
|
-
...(resource.headerHash ? { headerHash: resource.headerHash } : {}),
|
|
2192
|
-
}))
|
|
2193
|
-
);
|
|
2194
2180
|
return await this.executeProtocolV2Phases({
|
|
2195
2181
|
installSources,
|
|
2196
|
-
resourceSources,
|
|
2182
|
+
resourceSources: [],
|
|
2197
2183
|
});
|
|
2198
2184
|
} finally {
|
|
2199
2185
|
await this.closeProtocolV2PreparedSources();
|