@onekeyfe/hd-core 1.2.0-alpha.87 → 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 +6 -2
- package/__tests__/firmware-update/firmware-update-plan.test.ts +47 -0
- package/__tests__/protocol-v2.test.ts +492 -4
- package/dist/api/FirmwareUpdateV4.d.ts +2 -0
- package/dist/api/FirmwareUpdateV4.d.ts.map +1 -1
- package/dist/api/firmware/FirmwareMemoryHost.d.ts +0 -5
- 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 +18 -6
- package/dist/index.js +422 -134
- package/dist/types/api/firmwareUpdate.d.ts +13 -2
- package/dist/types/api/firmwareUpdate.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/api/FirmwareUpdateV4.ts +516 -28
- package/src/api/firmware/FirmwareMemoryHost.ts +9 -41
- package/src/api/firmware/FirmwareUpdatePlan.ts +49 -4
- package/src/types/api/firmwareUpdate.ts +20 -1
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { EFirmwareType, ERRORS, HardwareErrorCode } from '@onekeyfe/hd-shared';
|
|
2
|
+
import { sha256 } from '@noble/hashes/sha256';
|
|
3
|
+
import { bytesToHex } from '@noble/hashes/utils';
|
|
4
|
+
import JSZip from 'jszip';
|
|
2
5
|
import {
|
|
3
6
|
DeviceRebootType,
|
|
4
7
|
DeviceSessionPinType,
|
|
@@ -5796,6 +5799,14 @@ describe('Protocol V2 firmware update targets', () => {
|
|
|
5796
5799
|
binary: binaries.get(url) ?? new Uint8Array([0]).buffer,
|
|
5797
5800
|
})
|
|
5798
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
|
+
};
|
|
5799
5810
|
const getFirmwareLatestReleaseSpy = jest
|
|
5800
5811
|
.spyOn(DataManager, 'getFirmwareLatestRelease')
|
|
5801
5812
|
.mockReturnValue({
|
|
@@ -5820,23 +5831,43 @@ describe('Protocol V2 firmware update targets', () => {
|
|
|
5820
5831
|
bootloader: {
|
|
5821
5832
|
target: 'BOOTLOADER',
|
|
5822
5833
|
url: 'https://example.com/bootloader.pp.bin',
|
|
5834
|
+
...componentIntegrity('https://example.com/bootloader.pp.bin'),
|
|
5823
5835
|
},
|
|
5824
5836
|
applicationP1: {
|
|
5825
5837
|
target: 'APPLICATION_P1',
|
|
5826
5838
|
url: 'https://example.com/applicationP1.pp.bin',
|
|
5839
|
+
...componentIntegrity('https://example.com/applicationP1.pp.bin'),
|
|
5827
5840
|
},
|
|
5828
5841
|
applicationP2: {
|
|
5829
5842
|
target: 'APPLICATION_P2',
|
|
5830
5843
|
url: 'https://example.com/applicationP2.pp.bin',
|
|
5844
|
+
...componentIntegrity('https://example.com/applicationP2.pp.bin'),
|
|
5831
5845
|
},
|
|
5832
5846
|
coprocessor: {
|
|
5833
5847
|
target: 'COPROCESSOR',
|
|
5834
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'),
|
|
5835
5870
|
},
|
|
5836
|
-
se01: { target: 'SE01', url: 'https://example.com/se01.pp.bin' },
|
|
5837
|
-
se02: { target: 'SE02', url: 'https://example.com/se02.pp.bin' },
|
|
5838
|
-
se03: { target: 'SE03', url: 'https://example.com/se03.pp.bin' },
|
|
5839
|
-
se04: { target: 'SE04', url: 'https://example.com/se04.pp.bin' },
|
|
5840
5871
|
},
|
|
5841
5872
|
fingerprint: '',
|
|
5842
5873
|
changelog: {
|
|
@@ -5904,10 +5935,14 @@ describe('Protocol V2 firmware update targets', () => {
|
|
|
5904
5935
|
applicationP1: {
|
|
5905
5936
|
target: 'APPLICATION_P1',
|
|
5906
5937
|
url: 'https://example.com/applicationP1.pp.bin',
|
|
5938
|
+
expectedSize: explicitApplicationBinary.byteLength,
|
|
5939
|
+
fingerprint: bytesToHex(sha256(new Uint8Array(explicitApplicationBinary))),
|
|
5907
5940
|
},
|
|
5908
5941
|
coprocessor: {
|
|
5909
5942
|
target: 'COPROCESSOR',
|
|
5910
5943
|
url: 'https://example.com/coprocessor.pp.bin',
|
|
5944
|
+
expectedSize: remoteCoprocessorBinary.byteLength,
|
|
5945
|
+
fingerprint: bytesToHex(sha256(new Uint8Array(remoteCoprocessorBinary))),
|
|
5911
5946
|
},
|
|
5912
5947
|
},
|
|
5913
5948
|
fingerprint: '',
|
|
@@ -6329,6 +6364,459 @@ describe('Protocol V2 firmware update targets', () => {
|
|
|
6329
6364
|
}
|
|
6330
6365
|
});
|
|
6331
6366
|
|
|
6367
|
+
test('executes a prepared component plan without duplicated component inputs', async () => {
|
|
6368
|
+
const componentBinary = new Uint8Array([1, 2, 3]).buffer;
|
|
6369
|
+
const componentArtifact = {
|
|
6370
|
+
artifactRef: 'prepared-bootloader',
|
|
6371
|
+
size: componentBinary.byteLength,
|
|
6372
|
+
sha256: 'a'.repeat(64),
|
|
6373
|
+
};
|
|
6374
|
+
const planWithoutDigest = {
|
|
6375
|
+
schemaVersion: 2 as const,
|
|
6376
|
+
executor: 'v4' as const,
|
|
6377
|
+
deviceIdentity: 'PRO2-SERIAL',
|
|
6378
|
+
deviceModel: 'pro2',
|
|
6379
|
+
firmwareType: EFirmwareType.Universal,
|
|
6380
|
+
platform: 'web' as const,
|
|
6381
|
+
targetsToUpdate: ['boot' as const],
|
|
6382
|
+
artifacts: [
|
|
6383
|
+
{
|
|
6384
|
+
artifactId: 'component:boot',
|
|
6385
|
+
role: 'component' as const,
|
|
6386
|
+
target: 'boot' as const,
|
|
6387
|
+
url: 'https://example.com/bootloader.bin',
|
|
6388
|
+
container: 'raw' as const,
|
|
6389
|
+
logicalName: 'bootloader',
|
|
6390
|
+
targetVersion: '1.2.3',
|
|
6391
|
+
},
|
|
6392
|
+
],
|
|
6393
|
+
};
|
|
6394
|
+
const preparedPlan = prepareFirmwareUpdatePlan({
|
|
6395
|
+
plan: {
|
|
6396
|
+
...planWithoutDigest,
|
|
6397
|
+
planDigest: digestFirmwareUpdateContract(planWithoutDigest),
|
|
6398
|
+
},
|
|
6399
|
+
leaseRef: 'prepared-component-test',
|
|
6400
|
+
artifacts: [{ artifactId: 'component:boot', artifact: componentArtifact }],
|
|
6401
|
+
});
|
|
6402
|
+
const artifactReader = {
|
|
6403
|
+
open: jest.fn(() =>
|
|
6404
|
+
Promise.resolve({
|
|
6405
|
+
readerId: 'prepared-component-reader',
|
|
6406
|
+
size: componentBinary.byteLength,
|
|
6407
|
+
})
|
|
6408
|
+
),
|
|
6409
|
+
read: jest.fn(({ offset, length }: { offset: number; length: number }) => {
|
|
6410
|
+
const data = componentBinary.slice(offset, offset + length);
|
|
6411
|
+
return Promise.resolve({
|
|
6412
|
+
data,
|
|
6413
|
+
bytesRead: data.byteLength,
|
|
6414
|
+
eof: offset + length === componentBinary.byteLength,
|
|
6415
|
+
});
|
|
6416
|
+
}),
|
|
6417
|
+
close: jest.fn(() => Promise.resolve()),
|
|
6418
|
+
};
|
|
6419
|
+
const hostBindingGeneration = registerFirmwareUpdateHostBinding({
|
|
6420
|
+
preparedPlanDigest: preparedPlan.preparedPlanDigest,
|
|
6421
|
+
artifactReader,
|
|
6422
|
+
});
|
|
6423
|
+
const releaseSpy = jest
|
|
6424
|
+
.spyOn(DataManager, 'getFirmwareLatestRelease')
|
|
6425
|
+
.mockReturnValue(undefined);
|
|
6426
|
+
|
|
6427
|
+
try {
|
|
6428
|
+
const method = new FirmwareUpdateV4({
|
|
6429
|
+
id: 1,
|
|
6430
|
+
payload: {
|
|
6431
|
+
method: 'firmwareUpdateV4',
|
|
6432
|
+
platform: 'web',
|
|
6433
|
+
preparedPlan,
|
|
6434
|
+
hostBindingGeneration,
|
|
6435
|
+
},
|
|
6436
|
+
});
|
|
6437
|
+
|
|
6438
|
+
expect(() => method.init()).not.toThrow();
|
|
6439
|
+
expect((method as any).params.targetsToUpdate).toEqual(['boot']);
|
|
6440
|
+
expect((method as any).params.expectedTargetVersions).toEqual({ boot: '1.2.3' });
|
|
6441
|
+
expect((method as any).params.componentArtifacts).toBeUndefined();
|
|
6442
|
+
(method as any).postTipMessage = jest.fn();
|
|
6443
|
+
(method as any).prepareProtocolV2ResourceSources = jest.fn().mockResolvedValue([]);
|
|
6444
|
+
(method as any).executeProtocolV2SourceUpdate = jest
|
|
6445
|
+
.fn()
|
|
6446
|
+
.mockResolvedValue('prepared-result');
|
|
6447
|
+
|
|
6448
|
+
await expect(
|
|
6449
|
+
(method as any).runProtocolV2PreparedArtifacts({} as Features, EFirmwareType.Universal)
|
|
6450
|
+
).resolves.toBe('prepared-result');
|
|
6451
|
+
expect(releaseSpy).not.toHaveBeenCalled();
|
|
6452
|
+
expect(artifactReader.open).toHaveBeenCalledWith({ artifactRef: 'prepared-bootloader' });
|
|
6453
|
+
expect((method as any).executeProtocolV2SourceUpdate).toHaveBeenCalledWith({
|
|
6454
|
+
installSources: [
|
|
6455
|
+
expect.objectContaining({
|
|
6456
|
+
fileName: 'bootloader.bin',
|
|
6457
|
+
kind: 'bootloader',
|
|
6458
|
+
}),
|
|
6459
|
+
],
|
|
6460
|
+
resourceSources: [],
|
|
6461
|
+
});
|
|
6462
|
+
} finally {
|
|
6463
|
+
releaseSpy.mockRestore();
|
|
6464
|
+
unregisterFirmwareUpdateHostBinding(hostBindingGeneration);
|
|
6465
|
+
}
|
|
6466
|
+
});
|
|
6467
|
+
|
|
6468
|
+
test('executes a resource-only prepared plan without a live firmware release', async () => {
|
|
6469
|
+
const planWithoutDigest = {
|
|
6470
|
+
schemaVersion: 2 as const,
|
|
6471
|
+
executor: 'v4' as const,
|
|
6472
|
+
deviceIdentity: 'PRO2-SERIAL',
|
|
6473
|
+
deviceModel: 'pro2',
|
|
6474
|
+
firmwareType: EFirmwareType.Universal,
|
|
6475
|
+
platform: 'web' as const,
|
|
6476
|
+
targetsToUpdate: ['resource' as const],
|
|
6477
|
+
artifacts: [
|
|
6478
|
+
{
|
|
6479
|
+
artifactId: 'resource:archive',
|
|
6480
|
+
role: 'resourceBundle' as const,
|
|
6481
|
+
target: 'resource' as const,
|
|
6482
|
+
url: 'https://example.com/resource.zip',
|
|
6483
|
+
container: 'zip' as const,
|
|
6484
|
+
logicalName: 'protocol-v2-resource-archive',
|
|
6485
|
+
},
|
|
6486
|
+
],
|
|
6487
|
+
};
|
|
6488
|
+
const preparedPlan = prepareFirmwareUpdatePlan({
|
|
6489
|
+
plan: {
|
|
6490
|
+
...planWithoutDigest,
|
|
6491
|
+
planDigest: digestFirmwareUpdateContract(planWithoutDigest),
|
|
6492
|
+
},
|
|
6493
|
+
leaseRef: 'prepared-resource-only-test',
|
|
6494
|
+
artifacts: [
|
|
6495
|
+
{
|
|
6496
|
+
artifactId: 'resource:archive',
|
|
6497
|
+
artifact: {
|
|
6498
|
+
artifactRef: 'prepared-resource-archive',
|
|
6499
|
+
size: 3,
|
|
6500
|
+
sha256: 'a'.repeat(64),
|
|
6501
|
+
},
|
|
6502
|
+
materializedEntries: [
|
|
6503
|
+
{
|
|
6504
|
+
entryName: 'manifest.json',
|
|
6505
|
+
artifact: {
|
|
6506
|
+
artifactRef: 'prepared-resource-manifest',
|
|
6507
|
+
size: 2,
|
|
6508
|
+
sha256: 'b'.repeat(64),
|
|
6509
|
+
},
|
|
6510
|
+
},
|
|
6511
|
+
],
|
|
6512
|
+
},
|
|
6513
|
+
],
|
|
6514
|
+
});
|
|
6515
|
+
const hostBindingGeneration = registerFirmwareUpdateHostBinding({
|
|
6516
|
+
preparedPlanDigest: preparedPlan.preparedPlanDigest,
|
|
6517
|
+
artifactReader: {
|
|
6518
|
+
open: jest.fn(),
|
|
6519
|
+
read: jest.fn(),
|
|
6520
|
+
close: jest.fn(),
|
|
6521
|
+
},
|
|
6522
|
+
});
|
|
6523
|
+
const releaseSpy = jest
|
|
6524
|
+
.spyOn(DataManager, 'getFirmwareLatestRelease')
|
|
6525
|
+
.mockReturnValue(undefined);
|
|
6526
|
+
|
|
6527
|
+
try {
|
|
6528
|
+
const method = new FirmwareUpdateV4({
|
|
6529
|
+
id: 1,
|
|
6530
|
+
payload: {
|
|
6531
|
+
method: 'firmwareUpdateV4',
|
|
6532
|
+
platform: 'web',
|
|
6533
|
+
preparedPlan,
|
|
6534
|
+
hostBindingGeneration,
|
|
6535
|
+
},
|
|
6536
|
+
});
|
|
6537
|
+
|
|
6538
|
+
expect(() => method.init()).not.toThrow();
|
|
6539
|
+
(method as any).postTipMessage = jest.fn();
|
|
6540
|
+
const resourceSources = [{ kind: 'resource' }];
|
|
6541
|
+
(method as any).prepareProtocolV2ResourceSources = jest
|
|
6542
|
+
.fn()
|
|
6543
|
+
.mockResolvedValue(resourceSources);
|
|
6544
|
+
(method as any).executeProtocolV2SourceUpdate = jest
|
|
6545
|
+
.fn()
|
|
6546
|
+
.mockResolvedValue('resource-result');
|
|
6547
|
+
|
|
6548
|
+
await expect(
|
|
6549
|
+
(method as any).runProtocolV2PreparedArtifacts({} as Features, EFirmwareType.Universal)
|
|
6550
|
+
).resolves.toBe('resource-result');
|
|
6551
|
+
expect(releaseSpy).not.toHaveBeenCalled();
|
|
6552
|
+
expect((method as any).executeProtocolV2SourceUpdate).toHaveBeenCalledWith({
|
|
6553
|
+
installSources: [],
|
|
6554
|
+
resourceSources,
|
|
6555
|
+
});
|
|
6556
|
+
} finally {
|
|
6557
|
+
releaseSpy.mockRestore();
|
|
6558
|
+
unregisterFirmwareUpdateHostBinding(hostBindingGeneration);
|
|
6559
|
+
}
|
|
6560
|
+
});
|
|
6561
|
+
|
|
6562
|
+
test('converts a local resource ZIP into a local PreparedPlan without matching a remote release', async () => {
|
|
6563
|
+
const imagesBinary = new Uint8Array([1, 2, 3]).buffer;
|
|
6564
|
+
const bootResourceBinary = new Uint8Array([4, 5, 6]).buffer;
|
|
6565
|
+
const manifest = {
|
|
6566
|
+
schema: 1,
|
|
6567
|
+
artifact_name: 'pro2-resource',
|
|
6568
|
+
release_name: 'local-development',
|
|
6569
|
+
variant: 'resource',
|
|
6570
|
+
commit: 'local',
|
|
6571
|
+
short_sha: 'local',
|
|
6572
|
+
timestamp_utc: '2026-08-09T00:00:00Z',
|
|
6573
|
+
core_version: '1.0.0',
|
|
6574
|
+
key_set: 'development',
|
|
6575
|
+
device_root: 'vol0:',
|
|
6576
|
+
restore_mode: 'bootloader_update',
|
|
6577
|
+
trees: [{ path: 'bundles', device: 'pro2' }],
|
|
6578
|
+
files: [
|
|
6579
|
+
{
|
|
6580
|
+
archive_path: 'bundles/images/images.okpkg',
|
|
6581
|
+
original_name: 'images.okpkg',
|
|
6582
|
+
device_path: 'vol0:/bundles/images/images.okpkg',
|
|
6583
|
+
size: imagesBinary.byteLength,
|
|
6584
|
+
sha256: bytesToHex(sha256(new Uint8Array(imagesBinary))),
|
|
6585
|
+
signed: true,
|
|
6586
|
+
sig_algo: 'ed25519',
|
|
6587
|
+
payload_version: '1.0.0',
|
|
6588
|
+
},
|
|
6589
|
+
{
|
|
6590
|
+
archive_path: 'loaders/bootloader/boot_resource.okpkg',
|
|
6591
|
+
original_name: 'boot_resource.okpkg',
|
|
6592
|
+
device_path: 'vol0:/loaders/bootloader/boot_resource.okpkg',
|
|
6593
|
+
size: bootResourceBinary.byteLength,
|
|
6594
|
+
sha256: bytesToHex(sha256(new Uint8Array(bootResourceBinary))),
|
|
6595
|
+
signed: true,
|
|
6596
|
+
sig_algo: 'ed25519',
|
|
6597
|
+
payload_version: '1.0.0',
|
|
6598
|
+
},
|
|
6599
|
+
],
|
|
6600
|
+
};
|
|
6601
|
+
const zip = new JSZip();
|
|
6602
|
+
zip.file('manifest.json', JSON.stringify(manifest));
|
|
6603
|
+
zip.file('bundles/images/images.okpkg', imagesBinary);
|
|
6604
|
+
zip.file('loaders/bootloader/boot_resource.okpkg', bootResourceBinary);
|
|
6605
|
+
const resourceArchiveBinary = await zip.generateAsync({ type: 'arraybuffer' });
|
|
6606
|
+
const applicationP1Binary = new Uint8Array([7, 8, 9]).buffer;
|
|
6607
|
+
const method = new FirmwareUpdateV4({
|
|
6608
|
+
id: 1,
|
|
6609
|
+
payload: {
|
|
6610
|
+
method: 'firmwareUpdateV4',
|
|
6611
|
+
platform: 'web',
|
|
6612
|
+
targetsToUpdate: ['app_v1', 'resource'],
|
|
6613
|
+
applicationP1Binary,
|
|
6614
|
+
resourceArchiveBinary,
|
|
6615
|
+
},
|
|
6616
|
+
});
|
|
6617
|
+
method.init();
|
|
6618
|
+
(method as any).captureProtocolV2PhysicalIdentity = jest.fn().mockResolvedValue(undefined);
|
|
6619
|
+
(method as any).postTipMessage = jest.fn();
|
|
6620
|
+
(method as any).device = stubDevice({
|
|
6621
|
+
originalDescriptor: { protocolType: 'V2' },
|
|
6622
|
+
features: {
|
|
6623
|
+
deviceType: 'pro2',
|
|
6624
|
+
serialNo: 'pro2-device-id',
|
|
6625
|
+
firmwareVersion: '1.0.0',
|
|
6626
|
+
capabilities: [],
|
|
6627
|
+
},
|
|
6628
|
+
getCurrentDeviceType: () => 'pro2',
|
|
6629
|
+
});
|
|
6630
|
+
(method as any).protocolV2ExpectedSerialNumber = 'pro2-device-id';
|
|
6631
|
+
(method as any).executeProtocolV2SourceUpdate = jest
|
|
6632
|
+
.fn()
|
|
6633
|
+
.mockResolvedValue('local-resource-result');
|
|
6634
|
+
const releaseSpy = jest.spyOn(DataManager, 'getFirmwareLatestRelease');
|
|
6635
|
+
const reloadSpy = jest.spyOn(DataManager, 'forceReloadData');
|
|
6636
|
+
|
|
6637
|
+
try {
|
|
6638
|
+
await expect(method.run()).resolves.toBe('local-resource-result');
|
|
6639
|
+
expect(releaseSpy).not.toHaveBeenCalled();
|
|
6640
|
+
expect(reloadSpy).not.toHaveBeenCalled();
|
|
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(
|
|
6647
|
+
expect.objectContaining({
|
|
6648
|
+
installSources: [
|
|
6649
|
+
expect.objectContaining({
|
|
6650
|
+
fileName: 'application_p1.bin',
|
|
6651
|
+
targetId: 4,
|
|
6652
|
+
}),
|
|
6653
|
+
],
|
|
6654
|
+
resourceSources: [
|
|
6655
|
+
expect.objectContaining({
|
|
6656
|
+
name: 'images.okpkg',
|
|
6657
|
+
devicePath: 'vol0:/bundles/images/images.okpkg',
|
|
6658
|
+
}),
|
|
6659
|
+
expect.objectContaining({
|
|
6660
|
+
name: 'boot_resource.okpkg',
|
|
6661
|
+
devicePath: 'vol0:/loaders/bootloader/boot_resource.okpkg',
|
|
6662
|
+
}),
|
|
6663
|
+
],
|
|
6664
|
+
})
|
|
6665
|
+
);
|
|
6666
|
+
} finally {
|
|
6667
|
+
releaseSpy.mockRestore();
|
|
6668
|
+
reloadSpy.mockRestore();
|
|
6669
|
+
}
|
|
6670
|
+
});
|
|
6671
|
+
|
|
6672
|
+
test('rejects a local resource ZIP whose file hash does not match its manifest', async () => {
|
|
6673
|
+
const resourceBinary = new Uint8Array([1, 2, 3]).buffer;
|
|
6674
|
+
const bootResourceBinary = new Uint8Array([4, 5, 6]).buffer;
|
|
6675
|
+
const zip = new JSZip();
|
|
6676
|
+
zip.file(
|
|
6677
|
+
'manifest.json',
|
|
6678
|
+
JSON.stringify({
|
|
6679
|
+
schema: 1,
|
|
6680
|
+
artifact_name: 'pro2-resource',
|
|
6681
|
+
release_name: 'local-development',
|
|
6682
|
+
variant: 'resource',
|
|
6683
|
+
commit: 'local',
|
|
6684
|
+
short_sha: 'local',
|
|
6685
|
+
timestamp_utc: '2026-08-09T00:00:00Z',
|
|
6686
|
+
core_version: '1.0.0',
|
|
6687
|
+
key_set: 'development',
|
|
6688
|
+
device_root: 'vol0:',
|
|
6689
|
+
restore_mode: 'bootloader_update',
|
|
6690
|
+
trees: [{ path: 'bundles', device: 'pro2' }],
|
|
6691
|
+
files: [
|
|
6692
|
+
{
|
|
6693
|
+
archive_path: 'bundles/images/images.okpkg',
|
|
6694
|
+
original_name: 'images.okpkg',
|
|
6695
|
+
device_path: 'vol0:/bundles/images/images.okpkg',
|
|
6696
|
+
size: resourceBinary.byteLength,
|
|
6697
|
+
sha256: '0'.repeat(64),
|
|
6698
|
+
signed: true,
|
|
6699
|
+
sig_algo: 'ed25519',
|
|
6700
|
+
payload_version: '1.0.0',
|
|
6701
|
+
},
|
|
6702
|
+
{
|
|
6703
|
+
archive_path: 'loaders/bootloader/boot_resource.okpkg',
|
|
6704
|
+
original_name: 'boot_resource.okpkg',
|
|
6705
|
+
device_path: 'vol0:/loaders/bootloader/boot_resource.okpkg',
|
|
6706
|
+
size: bootResourceBinary.byteLength,
|
|
6707
|
+
sha256: bytesToHex(sha256(new Uint8Array(bootResourceBinary))),
|
|
6708
|
+
signed: true,
|
|
6709
|
+
sig_algo: 'ed25519',
|
|
6710
|
+
payload_version: '1.0.0',
|
|
6711
|
+
},
|
|
6712
|
+
],
|
|
6713
|
+
})
|
|
6714
|
+
);
|
|
6715
|
+
zip.file('bundles/images/images.okpkg', resourceBinary);
|
|
6716
|
+
zip.file('loaders/bootloader/boot_resource.okpkg', bootResourceBinary);
|
|
6717
|
+
const method = new FirmwareUpdateV4({
|
|
6718
|
+
id: 1,
|
|
6719
|
+
payload: {
|
|
6720
|
+
method: 'firmwareUpdateV4',
|
|
6721
|
+
platform: 'web',
|
|
6722
|
+
targetsToUpdate: ['resource'],
|
|
6723
|
+
},
|
|
6724
|
+
});
|
|
6725
|
+
method.init();
|
|
6726
|
+
|
|
6727
|
+
await expect(
|
|
6728
|
+
(method as any).prepareProtocolV2LocalResourceArchive(
|
|
6729
|
+
await zip.generateAsync({ type: 'arraybuffer' })
|
|
6730
|
+
)
|
|
6731
|
+
).rejects.toThrow(
|
|
6732
|
+
'Protocol V2 local resource file does not match manifest: bundles/images/images.okpkg'
|
|
6733
|
+
);
|
|
6734
|
+
});
|
|
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
|
+
|
|
6332
6820
|
test('keeps the legacy componentArtifacts and artifactReader path without a prepared Plan', async () => {
|
|
6333
6821
|
const artifactReader = {
|
|
6334
6822
|
open: jest.fn(),
|
|
@@ -25,6 +25,8 @@ export default class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod<FirmwareU
|
|
|
25
25
|
private openProtocolV2MemorySource;
|
|
26
26
|
private closeProtocolV2PreparedSources;
|
|
27
27
|
private prepareProtocolV2InstallSources;
|
|
28
|
+
private prepareProtocolV2LocalMemoryHost;
|
|
29
|
+
private prepareProtocolV2LocalResourceArchive;
|
|
28
30
|
private prepareProtocolV2ResourceSources;
|
|
29
31
|
private prepareProtocolV2ResourceArchiveSources;
|
|
30
32
|
private runProtocolV2PreparedArtifacts;
|
|
@@ -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;
|
|
1
|
+
{"version":3,"file":"FirmwareUpdateV4.d.ts","sourceRoot":"","sources":["../../src/api/FirmwareUpdateV4.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAkD,MAAM,qB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AkBjC,iCAAiC;IAM/C,OAAO,CAAC,uBAAuB;IAI/B,OAAO,CAAC,mCAAmC;IAe3C,OAAO,CAAC,2BAA2B;IAsBnC,OAAO,CAAC,yBAAyB;IAiBjC,OAAO,CAAC,wBAAwB;YAkBlB,iCAAiC;YAuDjC,+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;YA6CvB,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"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { CoreApi } from '../../types/api';
|
|
2
|
-
import type { FirmwareArtifactReference, FirmwareUpdateV4Target } from '../../types/api/firmwareUpdate';
|
|
3
2
|
import type { FirmwareUpdatePlan } from '../../types/api/firmwareUpdatePlan';
|
|
4
3
|
export type FirmwareMemoryArtifactEntry = {
|
|
5
4
|
entryName: string;
|
|
@@ -13,10 +12,6 @@ export type FirmwareMemoryArtifact = {
|
|
|
13
12
|
export type FirmwareUpdateV4MemoryHost = {
|
|
14
13
|
preparedPlan: ReturnType<CoreApi['prepareFirmwareUpdatePlan']>;
|
|
15
14
|
hostBindingGeneration: number;
|
|
16
|
-
targetsToUpdate: FirmwareUpdateV4Target[];
|
|
17
|
-
expectedDeviceId: string;
|
|
18
|
-
expectedTargetVersions: Partial<Record<FirmwareUpdateV4Target, string>>;
|
|
19
|
-
componentArtifacts: Partial<Record<Exclude<FirmwareUpdateV4Target, 'resource'>, FirmwareArtifactReference>>;
|
|
20
15
|
release: () => void;
|
|
21
16
|
};
|
|
22
17
|
export declare function prepareFirmwareUpdateV4MemoryHost({ sdk, plan, artifacts, }: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FirmwareMemoryHost.d.ts","sourceRoot":"","sources":["../../../src/api/firmware/FirmwareMemoryHost.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"FirmwareMemoryHost.d.ts","sourceRoot":"","sources":["../../../src/api/firmware/FirmwareMemoryHost.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAK/C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAE7E,MAAM,MAAM,2BAA2B,GAAG;IACxC,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,WAAW,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,WAAW,CAAC;IACpB,mBAAmB,CAAC,EAAE,2BAA2B,EAAE,CAAC;CACrD,CAAC;AAEF,MAAM,MAAM,0BAA0B,GAAG;IACvC,YAAY,EAAE,UAAU,CAAC,OAAO,CAAC,2BAA2B,CAAC,CAAC,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
55
|
firmwareType: EFirmwareType;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FirmwareUpdatePlan.d.ts","sourceRoot":"","sources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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,9 +1435,23 @@ interface FirmwareUpdateV4Params {
|
|
|
1433
1435
|
se02Binary?: ArrayBuffer;
|
|
1434
1436
|
se03Binary?: ArrayBuffer;
|
|
1435
1437
|
se04Binary?: ArrayBuffer;
|
|
1438
|
+
/** Complete Protocol V2 resource ZIP for local development; Core converts it to a local PreparedPlan. */
|
|
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
|
+
}>;
|
|
1436
1447
|
forcedUpdateRes?: boolean;
|
|
1437
1448
|
artifactReader?: FirmwareArtifactReader;
|
|
1438
|
-
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
|
+
}>;
|
|
1439
1455
|
}
|
|
1440
1456
|
declare function registerFirmwareUpdateHostBinding$1(binding: FirmwareUpdateHostBinding): number;
|
|
1441
1457
|
declare function unregisterFirmwareUpdateHostBinding$1(generation?: number): boolean;
|
|
@@ -4883,10 +4899,6 @@ type FirmwareMemoryArtifact = {
|
|
|
4883
4899
|
type FirmwareUpdateV4MemoryHost = {
|
|
4884
4900
|
preparedPlan: ReturnType<CoreApi['prepareFirmwareUpdatePlan']>;
|
|
4885
4901
|
hostBindingGeneration: number;
|
|
4886
|
-
targetsToUpdate: FirmwareUpdateV4Target[];
|
|
4887
|
-
expectedDeviceId: string;
|
|
4888
|
-
expectedTargetVersions: Partial<Record<FirmwareUpdateV4Target, string>>;
|
|
4889
|
-
componentArtifacts: Partial<Record<Exclude<FirmwareUpdateV4Target, 'resource'>, FirmwareArtifactReference>>;
|
|
4890
4902
|
release: () => void;
|
|
4891
4903
|
};
|
|
4892
4904
|
declare function prepareFirmwareUpdateV4MemoryHost({ sdk, plan, artifacts, }: {
|