@onekeyfe/hd-core 1.2.0-alpha.88 → 1.2.0-alpha.89
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 +24 -2
- package/__tests__/firmware-memory-host.test.ts +1 -0
- package/__tests__/firmware-update/firmware-update-plan.test.ts +47 -0
- package/__tests__/protocol-v2.test.ts +147 -12
- package/dist/api/FirmwareUpdateV4.d.ts +1 -0
- package/dist/api/FirmwareUpdateV4.d.ts.map +1 -1
- package/dist/api/firmware/FirmwareMemoryHost.d.ts.map +1 -1
- package/dist/api/firmware/FirmwareUpdatePlan.d.ts +15 -0
- package/dist/api/firmware/FirmwareUpdatePlan.d.ts.map +1 -1
- package/dist/index.d.ts +17 -3
- package/dist/index.js +290 -123
- package/dist/types/api/firmwareUpdate.d.ts +12 -2
- package/dist/types/api/firmwareUpdate.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/api/FirmwareUpdateV4.ts +295 -55
- package/src/api/firmware/FirmwareMemoryHost.ts +9 -4
- package/src/api/firmware/FirmwareUpdatePlan.ts +49 -4
- package/src/types/api/firmwareUpdate.ts +19 -2
|
@@ -25,6 +25,11 @@ const currentVersions: DeviceStateVersions = {
|
|
|
25
25
|
se04: '1.0.0',
|
|
26
26
|
};
|
|
27
27
|
|
|
28
|
+
const validComponentIntegrity = {
|
|
29
|
+
expectedSize: 1024,
|
|
30
|
+
fingerprint: '1'.repeat(64),
|
|
31
|
+
};
|
|
32
|
+
|
|
28
33
|
const release: IFirmwareReleaseInfo = {
|
|
29
34
|
required: true,
|
|
30
35
|
version: [2, 0, 0],
|
|
@@ -40,21 +45,25 @@ const release: IFirmwareReleaseInfo = {
|
|
|
40
45
|
target: 'BOOTLOADER',
|
|
41
46
|
url: 'https://example.com/bootloader.bin',
|
|
42
47
|
version: [1, 1, 0],
|
|
48
|
+
...validComponentIntegrity,
|
|
43
49
|
},
|
|
44
50
|
applicationP1: {
|
|
45
51
|
target: 'APPLICATION_P1',
|
|
46
52
|
url: 'https://example.com/application-p1.bin',
|
|
47
53
|
version: [2, 0, 0],
|
|
54
|
+
...validComponentIntegrity,
|
|
48
55
|
},
|
|
49
56
|
se02: {
|
|
50
57
|
target: 'SE02',
|
|
51
58
|
url: 'https://example.com/se02.bin',
|
|
52
59
|
version: [2, 0, 0],
|
|
60
|
+
...validComponentIntegrity,
|
|
53
61
|
},
|
|
54
62
|
se03: {
|
|
55
63
|
target: 'SE03',
|
|
56
64
|
url: 'https://example.com/se03.bin',
|
|
57
65
|
version: [1, 0, 0],
|
|
66
|
+
...validComponentIntegrity,
|
|
58
67
|
},
|
|
59
68
|
romloader: {
|
|
60
69
|
target: 'ROMLOADER',
|
|
@@ -395,11 +404,13 @@ describe('checkAllFirmwareRelease Protocol V2 support', () => {
|
|
|
395
404
|
target: 'APPLICATION_P1',
|
|
396
405
|
url: 'https://example.com/application-p1.okpkg',
|
|
397
406
|
version: [1, 0, 0],
|
|
407
|
+
...validComponentIntegrity,
|
|
398
408
|
},
|
|
399
409
|
coprocessor: {
|
|
400
410
|
target: 'COPROCESSOR',
|
|
401
411
|
url: 'https://example.com/coprocessor.okpkg',
|
|
402
412
|
version: [1, 0, 0],
|
|
413
|
+
...validComponentIntegrity,
|
|
403
414
|
},
|
|
404
415
|
},
|
|
405
416
|
};
|
|
@@ -453,6 +464,7 @@ describe('checkAllFirmwareRelease Protocol V2 support', () => {
|
|
|
453
464
|
target: 'APPLICATION_P1',
|
|
454
465
|
url: 'https://example.com/application-p1.okpkg',
|
|
455
466
|
version: [1, 0, 0],
|
|
467
|
+
...validComponentIntegrity,
|
|
456
468
|
},
|
|
457
469
|
},
|
|
458
470
|
};
|
|
@@ -526,8 +538,18 @@ describe('checkAllFirmwareRelease Protocol V2 support', () => {
|
|
|
526
538
|
...release,
|
|
527
539
|
installOrder: ['se01', 'se02', 'se03', 'se04'],
|
|
528
540
|
components: {
|
|
529
|
-
se01: {
|
|
530
|
-
|
|
541
|
+
se01: {
|
|
542
|
+
target: 'SE01',
|
|
543
|
+
url: 'https://example.com/se01.bin',
|
|
544
|
+
version: [1, 0, 0],
|
|
545
|
+
...validComponentIntegrity,
|
|
546
|
+
},
|
|
547
|
+
se02: {
|
|
548
|
+
target: 'SE02',
|
|
549
|
+
url: 'https://example.com/se02.bin',
|
|
550
|
+
version: [2, 0, 0],
|
|
551
|
+
...validComponentIntegrity,
|
|
552
|
+
},
|
|
531
553
|
se03: { target: 'SE03', url: 'https://example.com/se03.bin', version: [1, 0, 0] },
|
|
532
554
|
se04: { target: 'SE04', url: 'https://example.com/se04.bin', version: [1, 0, 0] },
|
|
533
555
|
},
|
|
@@ -94,6 +94,7 @@ describe('prepareFirmwareUpdateV4MemoryHost', () => {
|
|
|
94
94
|
artifact => artifact.target === 'boot'
|
|
95
95
|
)?.artifact;
|
|
96
96
|
expect(componentArtifact?.size).toBe(componentBinary.byteLength);
|
|
97
|
+
new Uint8Array(componentBinary).fill(9);
|
|
97
98
|
const opened = await artifactReader!.open({
|
|
98
99
|
artifactRef: componentArtifact!.artifactRef,
|
|
99
100
|
});
|
|
@@ -306,6 +306,8 @@ describe('buildFirmwareUpdatePlan', () => {
|
|
|
306
306
|
applicationP1: {
|
|
307
307
|
target: 'APPLICATION_P1',
|
|
308
308
|
url: 'https://firmware.onekey.so/pro2/application-p1.bin',
|
|
309
|
+
expectedSize: 1024,
|
|
310
|
+
fingerprint: '1111111111111111111111111111111111111111111111111111111111111111',
|
|
309
311
|
},
|
|
310
312
|
},
|
|
311
313
|
},
|
|
@@ -326,6 +328,8 @@ describe('buildFirmwareUpdatePlan', () => {
|
|
|
326
328
|
applicationP1: {
|
|
327
329
|
target: 'APPLICATION_P1',
|
|
328
330
|
url: 'https://firmware.onekey.so/pro2/application-p1.bin',
|
|
331
|
+
expectedSize: 1024,
|
|
332
|
+
fingerprint: '1111111111111111111111111111111111111111111111111111111111111111',
|
|
329
333
|
},
|
|
330
334
|
},
|
|
331
335
|
})
|
|
@@ -377,10 +381,14 @@ describe('buildFirmwareUpdatePlan', () => {
|
|
|
377
381
|
bootloader: {
|
|
378
382
|
target: 'BOOTLOADER',
|
|
379
383
|
url: 'https://firmware.onekey.so/pro2/bootloader.bin',
|
|
384
|
+
expectedSize: 2048,
|
|
385
|
+
fingerprint: '2222222222222222222222222222222222222222222222222222222222222222',
|
|
380
386
|
},
|
|
381
387
|
se01: {
|
|
382
388
|
target: 'SE01',
|
|
383
389
|
url: 'https://firmware.onekey.so/pro2/se01.bin',
|
|
390
|
+
expectedSize: 512,
|
|
391
|
+
fingerprint: '3333333333333333333333333333333333333333333333333333333333333333',
|
|
384
392
|
},
|
|
385
393
|
},
|
|
386
394
|
},
|
|
@@ -404,6 +412,41 @@ describe('buildFirmwareUpdatePlan', () => {
|
|
|
404
412
|
);
|
|
405
413
|
});
|
|
406
414
|
|
|
415
|
+
test.each([
|
|
416
|
+
{
|
|
417
|
+
expectedSize: undefined,
|
|
418
|
+
fingerprint: '1'.repeat(64),
|
|
419
|
+
},
|
|
420
|
+
{
|
|
421
|
+
expectedSize: 1024,
|
|
422
|
+
fingerprint: undefined,
|
|
423
|
+
},
|
|
424
|
+
])('rejects a remote Pro2 component without complete integrity metadata', integrity => {
|
|
425
|
+
expectFirmwarePlanInvalid(
|
|
426
|
+
() =>
|
|
427
|
+
buildFirmwareUpdatePlan({
|
|
428
|
+
features: createFeatures({ deviceType: EDeviceType.Pro2 }),
|
|
429
|
+
firmwareType: EFirmwareType.Universal,
|
|
430
|
+
platform: 'desktop',
|
|
431
|
+
firmware: {
|
|
432
|
+
status: 'required',
|
|
433
|
+
release: {
|
|
434
|
+
components: {
|
|
435
|
+
applicationP1: {
|
|
436
|
+
target: 'APPLICATION_P1',
|
|
437
|
+
url: 'https://firmware.onekey.so/pro2/application-p1.bin',
|
|
438
|
+
...integrity,
|
|
439
|
+
},
|
|
440
|
+
},
|
|
441
|
+
},
|
|
442
|
+
},
|
|
443
|
+
ble: noUpdate,
|
|
444
|
+
bootloader: noUpdate,
|
|
445
|
+
}),
|
|
446
|
+
'integrity metadata is invalid'
|
|
447
|
+
);
|
|
448
|
+
});
|
|
449
|
+
|
|
407
450
|
test('rejects Pro2 ROMLOADER because it requires a separate loader flow', () => {
|
|
408
451
|
expect(() =>
|
|
409
452
|
buildFirmwareUpdatePlan({
|
|
@@ -435,10 +478,14 @@ describe('buildFirmwareUpdatePlan', () => {
|
|
|
435
478
|
application: {
|
|
436
479
|
target: 'APPLICATION_P1',
|
|
437
480
|
url: 'https://firmware.onekey.so/pro2/application.bin',
|
|
481
|
+
expectedSize: 1024,
|
|
482
|
+
fingerprint: '1111111111111111111111111111111111111111111111111111111111111111',
|
|
438
483
|
},
|
|
439
484
|
applicationDuplicate: {
|
|
440
485
|
target: 'APPLICATION_P1',
|
|
441
486
|
url: 'https://firmware.onekey.so/pro2/application-duplicate.bin',
|
|
487
|
+
expectedSize: 1024,
|
|
488
|
+
fingerprint: '2222222222222222222222222222222222222222222222222222222222222222',
|
|
442
489
|
},
|
|
443
490
|
},
|
|
444
491
|
},
|
|
@@ -5799,6 +5799,14 @@ describe('Protocol V2 firmware update targets', () => {
|
|
|
5799
5799
|
binary: binaries.get(url) ?? new Uint8Array([0]).buffer,
|
|
5800
5800
|
})
|
|
5801
5801
|
);
|
|
5802
|
+
const componentIntegrity = (url: string) => {
|
|
5803
|
+
const binary = binaries.get(url);
|
|
5804
|
+
if (!binary) throw new Error(`Missing test firmware binary: ${url}`);
|
|
5805
|
+
return {
|
|
5806
|
+
expectedSize: binary.byteLength,
|
|
5807
|
+
fingerprint: bytesToHex(sha256(new Uint8Array(binary))),
|
|
5808
|
+
};
|
|
5809
|
+
};
|
|
5802
5810
|
const getFirmwareLatestReleaseSpy = jest
|
|
5803
5811
|
.spyOn(DataManager, 'getFirmwareLatestRelease')
|
|
5804
5812
|
.mockReturnValue({
|
|
@@ -5823,23 +5831,43 @@ describe('Protocol V2 firmware update targets', () => {
|
|
|
5823
5831
|
bootloader: {
|
|
5824
5832
|
target: 'BOOTLOADER',
|
|
5825
5833
|
url: 'https://example.com/bootloader.pp.bin',
|
|
5834
|
+
...componentIntegrity('https://example.com/bootloader.pp.bin'),
|
|
5826
5835
|
},
|
|
5827
5836
|
applicationP1: {
|
|
5828
5837
|
target: 'APPLICATION_P1',
|
|
5829
5838
|
url: 'https://example.com/applicationP1.pp.bin',
|
|
5839
|
+
...componentIntegrity('https://example.com/applicationP1.pp.bin'),
|
|
5830
5840
|
},
|
|
5831
5841
|
applicationP2: {
|
|
5832
5842
|
target: 'APPLICATION_P2',
|
|
5833
5843
|
url: 'https://example.com/applicationP2.pp.bin',
|
|
5844
|
+
...componentIntegrity('https://example.com/applicationP2.pp.bin'),
|
|
5834
5845
|
},
|
|
5835
5846
|
coprocessor: {
|
|
5836
5847
|
target: 'COPROCESSOR',
|
|
5837
5848
|
url: 'https://example.com/coprocessor.pp.bin',
|
|
5849
|
+
...componentIntegrity('https://example.com/coprocessor.pp.bin'),
|
|
5850
|
+
},
|
|
5851
|
+
se01: {
|
|
5852
|
+
target: 'SE01',
|
|
5853
|
+
url: 'https://example.com/se01.pp.bin',
|
|
5854
|
+
...componentIntegrity('https://example.com/se01.pp.bin'),
|
|
5855
|
+
},
|
|
5856
|
+
se02: {
|
|
5857
|
+
target: 'SE02',
|
|
5858
|
+
url: 'https://example.com/se02.pp.bin',
|
|
5859
|
+
...componentIntegrity('https://example.com/se02.pp.bin'),
|
|
5860
|
+
},
|
|
5861
|
+
se03: {
|
|
5862
|
+
target: 'SE03',
|
|
5863
|
+
url: 'https://example.com/se03.pp.bin',
|
|
5864
|
+
...componentIntegrity('https://example.com/se03.pp.bin'),
|
|
5865
|
+
},
|
|
5866
|
+
se04: {
|
|
5867
|
+
target: 'SE04',
|
|
5868
|
+
url: 'https://example.com/se04.pp.bin',
|
|
5869
|
+
...componentIntegrity('https://example.com/se04.pp.bin'),
|
|
5838
5870
|
},
|
|
5839
|
-
se01: { target: 'SE01', url: 'https://example.com/se01.pp.bin' },
|
|
5840
|
-
se02: { target: 'SE02', url: 'https://example.com/se02.pp.bin' },
|
|
5841
|
-
se03: { target: 'SE03', url: 'https://example.com/se03.pp.bin' },
|
|
5842
|
-
se04: { target: 'SE04', url: 'https://example.com/se04.pp.bin' },
|
|
5843
5871
|
},
|
|
5844
5872
|
fingerprint: '',
|
|
5845
5873
|
changelog: {
|
|
@@ -5907,10 +5935,14 @@ describe('Protocol V2 firmware update targets', () => {
|
|
|
5907
5935
|
applicationP1: {
|
|
5908
5936
|
target: 'APPLICATION_P1',
|
|
5909
5937
|
url: 'https://example.com/applicationP1.pp.bin',
|
|
5938
|
+
expectedSize: explicitApplicationBinary.byteLength,
|
|
5939
|
+
fingerprint: bytesToHex(sha256(new Uint8Array(explicitApplicationBinary))),
|
|
5910
5940
|
},
|
|
5911
5941
|
coprocessor: {
|
|
5912
5942
|
target: 'COPROCESSOR',
|
|
5913
5943
|
url: 'https://example.com/coprocessor.pp.bin',
|
|
5944
|
+
expectedSize: remoteCoprocessorBinary.byteLength,
|
|
5945
|
+
fingerprint: bytesToHex(sha256(new Uint8Array(remoteCoprocessorBinary))),
|
|
5914
5946
|
},
|
|
5915
5947
|
},
|
|
5916
5948
|
fingerprint: '',
|
|
@@ -6527,7 +6559,7 @@ describe('Protocol V2 firmware update targets', () => {
|
|
|
6527
6559
|
}
|
|
6528
6560
|
});
|
|
6529
6561
|
|
|
6530
|
-
test('
|
|
6562
|
+
test('converts a local resource ZIP into a local PreparedPlan without matching a remote release', async () => {
|
|
6531
6563
|
const imagesBinary = new Uint8Array([1, 2, 3]).buffer;
|
|
6532
6564
|
const bootResourceBinary = new Uint8Array([4, 5, 6]).buffer;
|
|
6533
6565
|
const manifest = {
|
|
@@ -6571,12 +6603,14 @@ describe('Protocol V2 firmware update targets', () => {
|
|
|
6571
6603
|
zip.file('bundles/images/images.okpkg', imagesBinary);
|
|
6572
6604
|
zip.file('loaders/bootloader/boot_resource.okpkg', bootResourceBinary);
|
|
6573
6605
|
const resourceArchiveBinary = await zip.generateAsync({ type: 'arraybuffer' });
|
|
6606
|
+
const applicationP1Binary = new Uint8Array([7, 8, 9]).buffer;
|
|
6574
6607
|
const method = new FirmwareUpdateV4({
|
|
6575
6608
|
id: 1,
|
|
6576
6609
|
payload: {
|
|
6577
6610
|
method: 'firmwareUpdateV4',
|
|
6578
6611
|
platform: 'web',
|
|
6579
|
-
targetsToUpdate: ['resource'],
|
|
6612
|
+
targetsToUpdate: ['app_v1', 'resource'],
|
|
6613
|
+
applicationP1Binary,
|
|
6580
6614
|
resourceArchiveBinary,
|
|
6581
6615
|
},
|
|
6582
6616
|
});
|
|
@@ -6585,10 +6619,18 @@ describe('Protocol V2 firmware update targets', () => {
|
|
|
6585
6619
|
(method as any).postTipMessage = jest.fn();
|
|
6586
6620
|
(method as any).device = stubDevice({
|
|
6587
6621
|
originalDescriptor: { protocolType: 'V2' },
|
|
6588
|
-
features: {
|
|
6622
|
+
features: {
|
|
6623
|
+
deviceType: 'pro2',
|
|
6624
|
+
serialNo: 'pro2-device-id',
|
|
6625
|
+
firmwareVersion: '1.0.0',
|
|
6626
|
+
capabilities: [],
|
|
6627
|
+
},
|
|
6589
6628
|
getCurrentDeviceType: () => 'pro2',
|
|
6590
6629
|
});
|
|
6591
|
-
(method as any).
|
|
6630
|
+
(method as any).protocolV2ExpectedSerialNumber = 'pro2-device-id';
|
|
6631
|
+
(method as any).executeProtocolV2SourceUpdate = jest
|
|
6632
|
+
.fn()
|
|
6633
|
+
.mockResolvedValue('local-resource-result');
|
|
6592
6634
|
const releaseSpy = jest.spyOn(DataManager, 'getFirmwareLatestRelease');
|
|
6593
6635
|
const reloadSpy = jest.spyOn(DataManager, 'forceReloadData');
|
|
6594
6636
|
|
|
@@ -6596,17 +6638,26 @@ describe('Protocol V2 firmware update targets', () => {
|
|
|
6596
6638
|
await expect(method.run()).resolves.toBe('local-resource-result');
|
|
6597
6639
|
expect(releaseSpy).not.toHaveBeenCalled();
|
|
6598
6640
|
expect(reloadSpy).not.toHaveBeenCalled();
|
|
6599
|
-
expect((method as any).
|
|
6641
|
+
expect((method as any).params.preparedPlan).toMatchObject({
|
|
6642
|
+
networkPolicy: 'forbid',
|
|
6643
|
+
executor: 'v4',
|
|
6644
|
+
targetsToUpdate: ['app_v1', 'resource'],
|
|
6645
|
+
});
|
|
6646
|
+
expect((method as any).executeProtocolV2SourceUpdate).toHaveBeenCalledWith(
|
|
6600
6647
|
expect.objectContaining({
|
|
6601
|
-
|
|
6648
|
+
installSources: [
|
|
6649
|
+
expect.objectContaining({
|
|
6650
|
+
fileName: 'application_p1.bin',
|
|
6651
|
+
targetId: 4,
|
|
6652
|
+
}),
|
|
6653
|
+
],
|
|
6654
|
+
resourceSources: [
|
|
6602
6655
|
expect.objectContaining({
|
|
6603
6656
|
name: 'images.okpkg',
|
|
6604
|
-
binary: imagesBinary,
|
|
6605
6657
|
devicePath: 'vol0:/bundles/images/images.okpkg',
|
|
6606
6658
|
}),
|
|
6607
6659
|
expect.objectContaining({
|
|
6608
6660
|
name: 'boot_resource.okpkg',
|
|
6609
|
-
binary: bootResourceBinary,
|
|
6610
6661
|
devicePath: 'vol0:/loaders/bootloader/boot_resource.okpkg',
|
|
6611
6662
|
}),
|
|
6612
6663
|
],
|
|
@@ -6682,6 +6733,90 @@ describe('Protocol V2 firmware update targets', () => {
|
|
|
6682
6733
|
);
|
|
6683
6734
|
});
|
|
6684
6735
|
|
|
6736
|
+
test('rejects an oversized ZIP entry before allocating its decompressed bytes', async () => {
|
|
6737
|
+
const extractEntry = jest.fn();
|
|
6738
|
+
const loadSpy = jest.spyOn(JSZip, 'loadAsync').mockResolvedValue({
|
|
6739
|
+
files: {
|
|
6740
|
+
'manifest.json': {
|
|
6741
|
+
name: 'manifest.json',
|
|
6742
|
+
dir: false,
|
|
6743
|
+
_data: {
|
|
6744
|
+
compressedSize: 1,
|
|
6745
|
+
uncompressedSize: 2 * 1024 * 1024,
|
|
6746
|
+
},
|
|
6747
|
+
async: extractEntry,
|
|
6748
|
+
},
|
|
6749
|
+
},
|
|
6750
|
+
} as unknown as JSZip);
|
|
6751
|
+
const method = new FirmwareUpdateV4({
|
|
6752
|
+
id: 1,
|
|
6753
|
+
payload: {
|
|
6754
|
+
method: 'firmwareUpdateV4',
|
|
6755
|
+
platform: 'web',
|
|
6756
|
+
targetsToUpdate: ['resource'],
|
|
6757
|
+
},
|
|
6758
|
+
});
|
|
6759
|
+
method.init();
|
|
6760
|
+
|
|
6761
|
+
try {
|
|
6762
|
+
await expect(
|
|
6763
|
+
(method as any).prepareProtocolV2LocalResourceArchive(new Uint8Array([1]).buffer)
|
|
6764
|
+
).rejects.toThrow('declared size exceeds the allowed limit');
|
|
6765
|
+
expect(extractEntry).not.toHaveBeenCalled();
|
|
6766
|
+
} finally {
|
|
6767
|
+
loadSpy.mockRestore();
|
|
6768
|
+
}
|
|
6769
|
+
});
|
|
6770
|
+
|
|
6771
|
+
test('normalizes the deprecated boot_resources target to resource', () => {
|
|
6772
|
+
const method = new FirmwareUpdateV4({
|
|
6773
|
+
id: 1,
|
|
6774
|
+
payload: {
|
|
6775
|
+
method: 'firmwareUpdateV4',
|
|
6776
|
+
platform: 'web',
|
|
6777
|
+
targetsToUpdate: ['boot_resources'],
|
|
6778
|
+
},
|
|
6779
|
+
});
|
|
6780
|
+
|
|
6781
|
+
method.init();
|
|
6782
|
+
expect((method as any).params.targetsToUpdate).toEqual(['resource']);
|
|
6783
|
+
});
|
|
6784
|
+
|
|
6785
|
+
test.each([
|
|
6786
|
+
{
|
|
6787
|
+
resourceFiles: [
|
|
6788
|
+
{
|
|
6789
|
+
binary: new Uint8Array([1]).buffer,
|
|
6790
|
+
devicePath: 'vol0:/bundles/images/images.okpkg',
|
|
6791
|
+
},
|
|
6792
|
+
],
|
|
6793
|
+
},
|
|
6794
|
+
{
|
|
6795
|
+
resourceBundleArtifacts: [
|
|
6796
|
+
{
|
|
6797
|
+
name: 'images.okpkg',
|
|
6798
|
+
artifact: {
|
|
6799
|
+
artifactRef: 'legacy-resource',
|
|
6800
|
+
size: 1,
|
|
6801
|
+
sha256: '1'.repeat(64),
|
|
6802
|
+
},
|
|
6803
|
+
},
|
|
6804
|
+
],
|
|
6805
|
+
},
|
|
6806
|
+
])('returns an explicit migration error for legacy resource inputs', legacyInput => {
|
|
6807
|
+
const method = new FirmwareUpdateV4({
|
|
6808
|
+
id: 1,
|
|
6809
|
+
payload: {
|
|
6810
|
+
method: 'firmwareUpdateV4',
|
|
6811
|
+
platform: 'web',
|
|
6812
|
+
targetsToUpdate: ['resource'],
|
|
6813
|
+
...legacyInput,
|
|
6814
|
+
},
|
|
6815
|
+
});
|
|
6816
|
+
|
|
6817
|
+
expect(() => method.init()).toThrow('provide a complete signed resource ZIP');
|
|
6818
|
+
});
|
|
6819
|
+
|
|
6685
6820
|
test('keeps the legacy componentArtifacts and artifactReader path without a prepared Plan', async () => {
|
|
6686
6821
|
const artifactReader = {
|
|
6687
6822
|
open: jest.fn(),
|
|
@@ -25,6 +25,7 @@ export default class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod<FirmwareU
|
|
|
25
25
|
private openProtocolV2MemorySource;
|
|
26
26
|
private closeProtocolV2PreparedSources;
|
|
27
27
|
private prepareProtocolV2InstallSources;
|
|
28
|
+
private prepareProtocolV2LocalMemoryHost;
|
|
28
29
|
private prepareProtocolV2LocalResourceArchive;
|
|
29
30
|
private prepareProtocolV2ResourceSources;
|
|
30
31
|
private prepareProtocolV2ResourceArchiveSources;
|
|
@@ -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;AAyBlG,OAAO,EAAE,wBAAwB,EAAE,MAAM,qCAAqC,CAAC;
|
|
1
|
+
{"version":3,"file":"FirmwareUpdateV4.d.ts","sourceRoot":"","sources":["../../src/api/FirmwareU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,CAAC;IAC/D,qBAAqB,EAAE,MAAM,CAAC;IAC9B,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB,CAAC;AAaF,wBAAgB,iCAAiC,CAAC,EAChD,GAAG,EACH,IAAI,EACJ,SAAS,GACV,EAAE;IACD,GAAG,EAAE,IAAI,CACP,OAAO,EACL,2BAA2B,GAC3B,mCAAmC,GACnC,qCAAqC,CACxC,CAAC;IACF,IAAI,EAAE,kBAAkB,CAAC;IACzB,SAAS,EAAE,sBAAsB,EAAE,CAAC;CACrC,GAAG,0BAA0B,CAyF7B"}
|
|
@@ -35,6 +35,21 @@ export declare const validateProtocolV2FirmwareUpdateTargets: (value: unknown) =
|
|
|
35
35
|
export declare const FIRMWARE_UPDATE_PLAN_TARGETS: Set<FirmwareUpdatePlanTarget>;
|
|
36
36
|
export declare const FIRMWARE_UPDATE_PLAN_ROLES: Set<string>;
|
|
37
37
|
export declare const assertFirmwareUpdatePlan: (value: unknown) => FirmwareUpdatePlan;
|
|
38
|
+
export type ProtocolV2LocalFirmwareUpdatePlanArtifact = {
|
|
39
|
+
artifactId: string;
|
|
40
|
+
target: Exclude<FirmwareUpdateV4Target, 'boot_resources'>;
|
|
41
|
+
container: 'raw' | 'zip';
|
|
42
|
+
logicalName: string;
|
|
43
|
+
expectedSize: number;
|
|
44
|
+
expectedSha256: string;
|
|
45
|
+
targetVersion?: string;
|
|
46
|
+
};
|
|
47
|
+
export declare const buildProtocolV2LocalFirmwareUpdatePlan: ({ features, firmwareType, platform, artifacts, }: {
|
|
48
|
+
features: Features;
|
|
49
|
+
firmwareType: EFirmwareType;
|
|
50
|
+
platform: FirmwareUpdatePlatform;
|
|
51
|
+
artifacts: ProtocolV2LocalFirmwareUpdatePlanArtifact[];
|
|
52
|
+
}) => FirmwareUpdatePlan;
|
|
38
53
|
export declare const buildProtocolV2FirmwareUpdatePlan: ({ features, firmwareType, platform, release, targetsToUpdate, forceUpdateTargets, resourceArchive, }: {
|
|
39
54
|
features: Features;
|
|
40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AE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,eAAO,MAAM,sCAAsC;cAMvC,QAAQ;kBACJ,aAAa;cACjB,sBAAsB;eACrB,yCAAyC,EAAE;MACpD,kBAmBH,CAAC;AAEF,eAAO,MAAM,iCAAiC;cASlC,QAAQ;kBACJ,aAAa;cACjB,sBAAsB;aACvB,aAAa,GAAG,SAAS;qBACjB,SAAS,sBAAsB,EAAE;;qBAEjC,yBAAyB,GAAG,SAAS;MACpD,kBAgEH,CAAC;AAEF,eAAO,MAAM,uBAAuB;cASxB,QAAQ;kBACJ,aAAa;cACjB,sBAAsB;cACtB,gBAAgB;SACrB,gBAAgB;;;MAGnB,kBAwIH,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1408,7 +1408,9 @@ interface FirmwareUpdateV3Params {
|
|
|
1408
1408
|
* firmwareUpdateV4 target binaries grouped by DeviceFirmwareTargetType.
|
|
1409
1409
|
* Except for romloader, each field maps to a target accepted by bootloader.
|
|
1410
1410
|
*/
|
|
1411
|
-
type FirmwareUpdateV4Target = 'boot'
|
|
1411
|
+
type FirmwareUpdateV4Target = 'boot'
|
|
1412
|
+
/** @deprecated Use resource with resourceArchiveBinary. */
|
|
1413
|
+
| 'boot_resources' | 'app_v1' | 'app_v2' | 'coprocessor' | 'resource' | 'se01' | 'se02' | 'se03' | 'se04';
|
|
1412
1414
|
interface FirmwareUpdateV4Params {
|
|
1413
1415
|
preparedPlan?: FirmwareUpdatePreparedPlan;
|
|
1414
1416
|
hostBindingGeneration?: number;
|
|
@@ -1433,11 +1435,23 @@ interface FirmwareUpdateV4Params {
|
|
|
1433
1435
|
se02Binary?: ArrayBuffer;
|
|
1434
1436
|
se03Binary?: ArrayBuffer;
|
|
1435
1437
|
se04Binary?: ArrayBuffer;
|
|
1436
|
-
/** Complete Protocol V2 resource ZIP for local development;
|
|
1438
|
+
/** Complete Protocol V2 resource ZIP for local development; Core converts it to a local PreparedPlan. */
|
|
1437
1439
|
resourceArchiveBinary?: ArrayBuffer;
|
|
1440
|
+
/** @deprecated Package the complete signed resource set as a ZIP and use resourceArchiveBinary. */
|
|
1441
|
+
resourceFiles?: Array<{
|
|
1442
|
+
binary: ArrayBuffer;
|
|
1443
|
+
devicePath: string;
|
|
1444
|
+
size?: number;
|
|
1445
|
+
fileHash?: string;
|
|
1446
|
+
}>;
|
|
1438
1447
|
forcedUpdateRes?: boolean;
|
|
1439
1448
|
artifactReader?: FirmwareArtifactReader;
|
|
1440
|
-
componentArtifacts?: Partial<Record<Exclude<FirmwareUpdateV4Target, 'resource'>, FirmwareArtifactReference>>;
|
|
1449
|
+
componentArtifacts?: Partial<Record<Exclude<FirmwareUpdateV4Target, 'resource' | 'boot_resources'>, FirmwareArtifactReference>>;
|
|
1450
|
+
/** @deprecated Use a ZIP artifact in preparedPlan instead. */
|
|
1451
|
+
resourceBundleArtifacts?: Array<{
|
|
1452
|
+
name: string;
|
|
1453
|
+
artifact: FirmwareArtifactReference;
|
|
1454
|
+
}>;
|
|
1441
1455
|
}
|
|
1442
1456
|
declare function registerFirmwareUpdateHostBinding$1(binding: FirmwareUpdateHostBinding): number;
|
|
1443
1457
|
declare function unregisterFirmwareUpdateHostBinding$1(generation?: number): boolean;
|