@onekeyfe/hd-core 1.2.0-alpha.86 → 1.2.0-alpha.88
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__/firmware-memory-host.test.ts +5 -2
- package/__tests__/protocol-v2.test.ts +388 -0
- package/dist/api/FirmwareUpdateV4.d.ts +1 -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/index.d.ts +2 -4
- package/dist/index.js +179 -57
- package/dist/types/api/firmwareUpdate.d.ts +1 -0
- package/dist/types/api/firmwareUpdate.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/api/FirmwareUpdateV4.ts +283 -32
- package/src/api/firmware/FirmwareMemoryHost.ts +0 -37
- package/src/types/api/firmwareUpdate.ts +2 -0
|
@@ -90,9 +90,12 @@ describe('prepareFirmwareUpdateV4MemoryHost', () => {
|
|
|
90
90
|
expect(sdk.registerFirmwareUpdateHostBinding).toHaveBeenCalledWith(
|
|
91
91
|
expect.objectContaining({ preparedPlanDigest: host.preparedPlan.preparedPlanDigest })
|
|
92
92
|
);
|
|
93
|
-
|
|
93
|
+
const componentArtifact = host.preparedPlan.artifacts.find(
|
|
94
|
+
artifact => artifact.target === 'boot'
|
|
95
|
+
)?.artifact;
|
|
96
|
+
expect(componentArtifact?.size).toBe(componentBinary.byteLength);
|
|
94
97
|
const opened = await artifactReader!.open({
|
|
95
|
-
artifactRef:
|
|
98
|
+
artifactRef: componentArtifact!.artifactRef,
|
|
96
99
|
});
|
|
97
100
|
const chunk = await artifactReader!.read({
|
|
98
101
|
readerId: opened.readerId,
|
|
@@ -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,
|
|
@@ -6329,6 +6332,391 @@ describe('Protocol V2 firmware update targets', () => {
|
|
|
6329
6332
|
}
|
|
6330
6333
|
});
|
|
6331
6334
|
|
|
6335
|
+
test('executes a prepared component plan without duplicated component inputs', async () => {
|
|
6336
|
+
const componentBinary = new Uint8Array([1, 2, 3]).buffer;
|
|
6337
|
+
const componentArtifact = {
|
|
6338
|
+
artifactRef: 'prepared-bootloader',
|
|
6339
|
+
size: componentBinary.byteLength,
|
|
6340
|
+
sha256: 'a'.repeat(64),
|
|
6341
|
+
};
|
|
6342
|
+
const planWithoutDigest = {
|
|
6343
|
+
schemaVersion: 2 as const,
|
|
6344
|
+
executor: 'v4' as const,
|
|
6345
|
+
deviceIdentity: 'PRO2-SERIAL',
|
|
6346
|
+
deviceModel: 'pro2',
|
|
6347
|
+
firmwareType: EFirmwareType.Universal,
|
|
6348
|
+
platform: 'web' as const,
|
|
6349
|
+
targetsToUpdate: ['boot' as const],
|
|
6350
|
+
artifacts: [
|
|
6351
|
+
{
|
|
6352
|
+
artifactId: 'component:boot',
|
|
6353
|
+
role: 'component' as const,
|
|
6354
|
+
target: 'boot' as const,
|
|
6355
|
+
url: 'https://example.com/bootloader.bin',
|
|
6356
|
+
container: 'raw' as const,
|
|
6357
|
+
logicalName: 'bootloader',
|
|
6358
|
+
targetVersion: '1.2.3',
|
|
6359
|
+
},
|
|
6360
|
+
],
|
|
6361
|
+
};
|
|
6362
|
+
const preparedPlan = prepareFirmwareUpdatePlan({
|
|
6363
|
+
plan: {
|
|
6364
|
+
...planWithoutDigest,
|
|
6365
|
+
planDigest: digestFirmwareUpdateContract(planWithoutDigest),
|
|
6366
|
+
},
|
|
6367
|
+
leaseRef: 'prepared-component-test',
|
|
6368
|
+
artifacts: [{ artifactId: 'component:boot', artifact: componentArtifact }],
|
|
6369
|
+
});
|
|
6370
|
+
const artifactReader = {
|
|
6371
|
+
open: jest.fn(() =>
|
|
6372
|
+
Promise.resolve({
|
|
6373
|
+
readerId: 'prepared-component-reader',
|
|
6374
|
+
size: componentBinary.byteLength,
|
|
6375
|
+
})
|
|
6376
|
+
),
|
|
6377
|
+
read: jest.fn(({ offset, length }: { offset: number; length: number }) => {
|
|
6378
|
+
const data = componentBinary.slice(offset, offset + length);
|
|
6379
|
+
return Promise.resolve({
|
|
6380
|
+
data,
|
|
6381
|
+
bytesRead: data.byteLength,
|
|
6382
|
+
eof: offset + length === componentBinary.byteLength,
|
|
6383
|
+
});
|
|
6384
|
+
}),
|
|
6385
|
+
close: jest.fn(() => Promise.resolve()),
|
|
6386
|
+
};
|
|
6387
|
+
const hostBindingGeneration = registerFirmwareUpdateHostBinding({
|
|
6388
|
+
preparedPlanDigest: preparedPlan.preparedPlanDigest,
|
|
6389
|
+
artifactReader,
|
|
6390
|
+
});
|
|
6391
|
+
const releaseSpy = jest
|
|
6392
|
+
.spyOn(DataManager, 'getFirmwareLatestRelease')
|
|
6393
|
+
.mockReturnValue(undefined);
|
|
6394
|
+
|
|
6395
|
+
try {
|
|
6396
|
+
const method = new FirmwareUpdateV4({
|
|
6397
|
+
id: 1,
|
|
6398
|
+
payload: {
|
|
6399
|
+
method: 'firmwareUpdateV4',
|
|
6400
|
+
platform: 'web',
|
|
6401
|
+
preparedPlan,
|
|
6402
|
+
hostBindingGeneration,
|
|
6403
|
+
},
|
|
6404
|
+
});
|
|
6405
|
+
|
|
6406
|
+
expect(() => method.init()).not.toThrow();
|
|
6407
|
+
expect((method as any).params.targetsToUpdate).toEqual(['boot']);
|
|
6408
|
+
expect((method as any).params.expectedTargetVersions).toEqual({ boot: '1.2.3' });
|
|
6409
|
+
expect((method as any).params.componentArtifacts).toBeUndefined();
|
|
6410
|
+
(method as any).postTipMessage = jest.fn();
|
|
6411
|
+
(method as any).prepareProtocolV2ResourceSources = jest.fn().mockResolvedValue([]);
|
|
6412
|
+
(method as any).executeProtocolV2SourceUpdate = jest
|
|
6413
|
+
.fn()
|
|
6414
|
+
.mockResolvedValue('prepared-result');
|
|
6415
|
+
|
|
6416
|
+
await expect(
|
|
6417
|
+
(method as any).runProtocolV2PreparedArtifacts({} as Features, EFirmwareType.Universal)
|
|
6418
|
+
).resolves.toBe('prepared-result');
|
|
6419
|
+
expect(releaseSpy).not.toHaveBeenCalled();
|
|
6420
|
+
expect(artifactReader.open).toHaveBeenCalledWith({ artifactRef: 'prepared-bootloader' });
|
|
6421
|
+
expect((method as any).executeProtocolV2SourceUpdate).toHaveBeenCalledWith({
|
|
6422
|
+
installSources: [
|
|
6423
|
+
expect.objectContaining({
|
|
6424
|
+
fileName: 'bootloader.bin',
|
|
6425
|
+
kind: 'bootloader',
|
|
6426
|
+
}),
|
|
6427
|
+
],
|
|
6428
|
+
resourceSources: [],
|
|
6429
|
+
});
|
|
6430
|
+
} finally {
|
|
6431
|
+
releaseSpy.mockRestore();
|
|
6432
|
+
unregisterFirmwareUpdateHostBinding(hostBindingGeneration);
|
|
6433
|
+
}
|
|
6434
|
+
});
|
|
6435
|
+
|
|
6436
|
+
test('executes a resource-only prepared plan without a live firmware release', async () => {
|
|
6437
|
+
const planWithoutDigest = {
|
|
6438
|
+
schemaVersion: 2 as const,
|
|
6439
|
+
executor: 'v4' as const,
|
|
6440
|
+
deviceIdentity: 'PRO2-SERIAL',
|
|
6441
|
+
deviceModel: 'pro2',
|
|
6442
|
+
firmwareType: EFirmwareType.Universal,
|
|
6443
|
+
platform: 'web' as const,
|
|
6444
|
+
targetsToUpdate: ['resource' as const],
|
|
6445
|
+
artifacts: [
|
|
6446
|
+
{
|
|
6447
|
+
artifactId: 'resource:archive',
|
|
6448
|
+
role: 'resourceBundle' as const,
|
|
6449
|
+
target: 'resource' as const,
|
|
6450
|
+
url: 'https://example.com/resource.zip',
|
|
6451
|
+
container: 'zip' as const,
|
|
6452
|
+
logicalName: 'protocol-v2-resource-archive',
|
|
6453
|
+
},
|
|
6454
|
+
],
|
|
6455
|
+
};
|
|
6456
|
+
const preparedPlan = prepareFirmwareUpdatePlan({
|
|
6457
|
+
plan: {
|
|
6458
|
+
...planWithoutDigest,
|
|
6459
|
+
planDigest: digestFirmwareUpdateContract(planWithoutDigest),
|
|
6460
|
+
},
|
|
6461
|
+
leaseRef: 'prepared-resource-only-test',
|
|
6462
|
+
artifacts: [
|
|
6463
|
+
{
|
|
6464
|
+
artifactId: 'resource:archive',
|
|
6465
|
+
artifact: {
|
|
6466
|
+
artifactRef: 'prepared-resource-archive',
|
|
6467
|
+
size: 3,
|
|
6468
|
+
sha256: 'a'.repeat(64),
|
|
6469
|
+
},
|
|
6470
|
+
materializedEntries: [
|
|
6471
|
+
{
|
|
6472
|
+
entryName: 'manifest.json',
|
|
6473
|
+
artifact: {
|
|
6474
|
+
artifactRef: 'prepared-resource-manifest',
|
|
6475
|
+
size: 2,
|
|
6476
|
+
sha256: 'b'.repeat(64),
|
|
6477
|
+
},
|
|
6478
|
+
},
|
|
6479
|
+
],
|
|
6480
|
+
},
|
|
6481
|
+
],
|
|
6482
|
+
});
|
|
6483
|
+
const hostBindingGeneration = registerFirmwareUpdateHostBinding({
|
|
6484
|
+
preparedPlanDigest: preparedPlan.preparedPlanDigest,
|
|
6485
|
+
artifactReader: {
|
|
6486
|
+
open: jest.fn(),
|
|
6487
|
+
read: jest.fn(),
|
|
6488
|
+
close: jest.fn(),
|
|
6489
|
+
},
|
|
6490
|
+
});
|
|
6491
|
+
const releaseSpy = jest
|
|
6492
|
+
.spyOn(DataManager, 'getFirmwareLatestRelease')
|
|
6493
|
+
.mockReturnValue(undefined);
|
|
6494
|
+
|
|
6495
|
+
try {
|
|
6496
|
+
const method = new FirmwareUpdateV4({
|
|
6497
|
+
id: 1,
|
|
6498
|
+
payload: {
|
|
6499
|
+
method: 'firmwareUpdateV4',
|
|
6500
|
+
platform: 'web',
|
|
6501
|
+
preparedPlan,
|
|
6502
|
+
hostBindingGeneration,
|
|
6503
|
+
},
|
|
6504
|
+
});
|
|
6505
|
+
|
|
6506
|
+
expect(() => method.init()).not.toThrow();
|
|
6507
|
+
(method as any).postTipMessage = jest.fn();
|
|
6508
|
+
const resourceSources = [{ kind: 'resource' }];
|
|
6509
|
+
(method as any).prepareProtocolV2ResourceSources = jest
|
|
6510
|
+
.fn()
|
|
6511
|
+
.mockResolvedValue(resourceSources);
|
|
6512
|
+
(method as any).executeProtocolV2SourceUpdate = jest
|
|
6513
|
+
.fn()
|
|
6514
|
+
.mockResolvedValue('resource-result');
|
|
6515
|
+
|
|
6516
|
+
await expect(
|
|
6517
|
+
(method as any).runProtocolV2PreparedArtifacts({} as Features, EFirmwareType.Universal)
|
|
6518
|
+
).resolves.toBe('resource-result');
|
|
6519
|
+
expect(releaseSpy).not.toHaveBeenCalled();
|
|
6520
|
+
expect((method as any).executeProtocolV2SourceUpdate).toHaveBeenCalledWith({
|
|
6521
|
+
installSources: [],
|
|
6522
|
+
resourceSources,
|
|
6523
|
+
});
|
|
6524
|
+
} finally {
|
|
6525
|
+
releaseSpy.mockRestore();
|
|
6526
|
+
unregisterFirmwareUpdateHostBinding(hostBindingGeneration);
|
|
6527
|
+
}
|
|
6528
|
+
});
|
|
6529
|
+
|
|
6530
|
+
test('executes a local resource ZIP without creating or matching a remote Plan', async () => {
|
|
6531
|
+
const imagesBinary = new Uint8Array([1, 2, 3]).buffer;
|
|
6532
|
+
const bootResourceBinary = new Uint8Array([4, 5, 6]).buffer;
|
|
6533
|
+
const manifest = {
|
|
6534
|
+
schema: 1,
|
|
6535
|
+
artifact_name: 'pro2-resource',
|
|
6536
|
+
release_name: 'local-development',
|
|
6537
|
+
variant: 'resource',
|
|
6538
|
+
commit: 'local',
|
|
6539
|
+
short_sha: 'local',
|
|
6540
|
+
timestamp_utc: '2026-08-09T00:00:00Z',
|
|
6541
|
+
core_version: '1.0.0',
|
|
6542
|
+
key_set: 'development',
|
|
6543
|
+
device_root: 'vol0:',
|
|
6544
|
+
restore_mode: 'bootloader_update',
|
|
6545
|
+
trees: [{ path: 'bundles', device: 'pro2' }],
|
|
6546
|
+
files: [
|
|
6547
|
+
{
|
|
6548
|
+
archive_path: 'bundles/images/images.okpkg',
|
|
6549
|
+
original_name: 'images.okpkg',
|
|
6550
|
+
device_path: 'vol0:/bundles/images/images.okpkg',
|
|
6551
|
+
size: imagesBinary.byteLength,
|
|
6552
|
+
sha256: bytesToHex(sha256(new Uint8Array(imagesBinary))),
|
|
6553
|
+
signed: true,
|
|
6554
|
+
sig_algo: 'ed25519',
|
|
6555
|
+
payload_version: '1.0.0',
|
|
6556
|
+
},
|
|
6557
|
+
{
|
|
6558
|
+
archive_path: 'loaders/bootloader/boot_resource.okpkg',
|
|
6559
|
+
original_name: 'boot_resource.okpkg',
|
|
6560
|
+
device_path: 'vol0:/loaders/bootloader/boot_resource.okpkg',
|
|
6561
|
+
size: bootResourceBinary.byteLength,
|
|
6562
|
+
sha256: bytesToHex(sha256(new Uint8Array(bootResourceBinary))),
|
|
6563
|
+
signed: true,
|
|
6564
|
+
sig_algo: 'ed25519',
|
|
6565
|
+
payload_version: '1.0.0',
|
|
6566
|
+
},
|
|
6567
|
+
],
|
|
6568
|
+
};
|
|
6569
|
+
const zip = new JSZip();
|
|
6570
|
+
zip.file('manifest.json', JSON.stringify(manifest));
|
|
6571
|
+
zip.file('bundles/images/images.okpkg', imagesBinary);
|
|
6572
|
+
zip.file('loaders/bootloader/boot_resource.okpkg', bootResourceBinary);
|
|
6573
|
+
const resourceArchiveBinary = await zip.generateAsync({ type: 'arraybuffer' });
|
|
6574
|
+
const method = new FirmwareUpdateV4({
|
|
6575
|
+
id: 1,
|
|
6576
|
+
payload: {
|
|
6577
|
+
method: 'firmwareUpdateV4',
|
|
6578
|
+
platform: 'web',
|
|
6579
|
+
targetsToUpdate: ['resource'],
|
|
6580
|
+
resourceArchiveBinary,
|
|
6581
|
+
},
|
|
6582
|
+
});
|
|
6583
|
+
method.init();
|
|
6584
|
+
(method as any).captureProtocolV2PhysicalIdentity = jest.fn().mockResolvedValue(undefined);
|
|
6585
|
+
(method as any).postTipMessage = jest.fn();
|
|
6586
|
+
(method as any).device = stubDevice({
|
|
6587
|
+
originalDescriptor: { protocolType: 'V2' },
|
|
6588
|
+
features: { deviceType: 'pro2', firmwareVersion: '1.0.0', capabilities: [] },
|
|
6589
|
+
getCurrentDeviceType: () => 'pro2',
|
|
6590
|
+
});
|
|
6591
|
+
(method as any).executeProtocolV2Update = jest.fn().mockResolvedValue('local-resource-result');
|
|
6592
|
+
const releaseSpy = jest.spyOn(DataManager, 'getFirmwareLatestRelease');
|
|
6593
|
+
const reloadSpy = jest.spyOn(DataManager, 'forceReloadData');
|
|
6594
|
+
|
|
6595
|
+
try {
|
|
6596
|
+
await expect(method.run()).resolves.toBe('local-resource-result');
|
|
6597
|
+
expect(releaseSpy).not.toHaveBeenCalled();
|
|
6598
|
+
expect(reloadSpy).not.toHaveBeenCalled();
|
|
6599
|
+
expect((method as any).executeProtocolV2Update).toHaveBeenCalledWith(
|
|
6600
|
+
expect.objectContaining({
|
|
6601
|
+
resourceBundles: [
|
|
6602
|
+
expect.objectContaining({
|
|
6603
|
+
name: 'images.okpkg',
|
|
6604
|
+
binary: imagesBinary,
|
|
6605
|
+
devicePath: 'vol0:/bundles/images/images.okpkg',
|
|
6606
|
+
}),
|
|
6607
|
+
expect.objectContaining({
|
|
6608
|
+
name: 'boot_resource.okpkg',
|
|
6609
|
+
binary: bootResourceBinary,
|
|
6610
|
+
devicePath: 'vol0:/loaders/bootloader/boot_resource.okpkg',
|
|
6611
|
+
}),
|
|
6612
|
+
],
|
|
6613
|
+
})
|
|
6614
|
+
);
|
|
6615
|
+
} finally {
|
|
6616
|
+
releaseSpy.mockRestore();
|
|
6617
|
+
reloadSpy.mockRestore();
|
|
6618
|
+
}
|
|
6619
|
+
});
|
|
6620
|
+
|
|
6621
|
+
test('rejects a local resource ZIP whose file hash does not match its manifest', async () => {
|
|
6622
|
+
const resourceBinary = new Uint8Array([1, 2, 3]).buffer;
|
|
6623
|
+
const bootResourceBinary = new Uint8Array([4, 5, 6]).buffer;
|
|
6624
|
+
const zip = new JSZip();
|
|
6625
|
+
zip.file(
|
|
6626
|
+
'manifest.json',
|
|
6627
|
+
JSON.stringify({
|
|
6628
|
+
schema: 1,
|
|
6629
|
+
artifact_name: 'pro2-resource',
|
|
6630
|
+
release_name: 'local-development',
|
|
6631
|
+
variant: 'resource',
|
|
6632
|
+
commit: 'local',
|
|
6633
|
+
short_sha: 'local',
|
|
6634
|
+
timestamp_utc: '2026-08-09T00:00:00Z',
|
|
6635
|
+
core_version: '1.0.0',
|
|
6636
|
+
key_set: 'development',
|
|
6637
|
+
device_root: 'vol0:',
|
|
6638
|
+
restore_mode: 'bootloader_update',
|
|
6639
|
+
trees: [{ path: 'bundles', device: 'pro2' }],
|
|
6640
|
+
files: [
|
|
6641
|
+
{
|
|
6642
|
+
archive_path: 'bundles/images/images.okpkg',
|
|
6643
|
+
original_name: 'images.okpkg',
|
|
6644
|
+
device_path: 'vol0:/bundles/images/images.okpkg',
|
|
6645
|
+
size: resourceBinary.byteLength,
|
|
6646
|
+
sha256: '0'.repeat(64),
|
|
6647
|
+
signed: true,
|
|
6648
|
+
sig_algo: 'ed25519',
|
|
6649
|
+
payload_version: '1.0.0',
|
|
6650
|
+
},
|
|
6651
|
+
{
|
|
6652
|
+
archive_path: 'loaders/bootloader/boot_resource.okpkg',
|
|
6653
|
+
original_name: 'boot_resource.okpkg',
|
|
6654
|
+
device_path: 'vol0:/loaders/bootloader/boot_resource.okpkg',
|
|
6655
|
+
size: bootResourceBinary.byteLength,
|
|
6656
|
+
sha256: bytesToHex(sha256(new Uint8Array(bootResourceBinary))),
|
|
6657
|
+
signed: true,
|
|
6658
|
+
sig_algo: 'ed25519',
|
|
6659
|
+
payload_version: '1.0.0',
|
|
6660
|
+
},
|
|
6661
|
+
],
|
|
6662
|
+
})
|
|
6663
|
+
);
|
|
6664
|
+
zip.file('bundles/images/images.okpkg', resourceBinary);
|
|
6665
|
+
zip.file('loaders/bootloader/boot_resource.okpkg', bootResourceBinary);
|
|
6666
|
+
const method = new FirmwareUpdateV4({
|
|
6667
|
+
id: 1,
|
|
6668
|
+
payload: {
|
|
6669
|
+
method: 'firmwareUpdateV4',
|
|
6670
|
+
platform: 'web',
|
|
6671
|
+
targetsToUpdate: ['resource'],
|
|
6672
|
+
},
|
|
6673
|
+
});
|
|
6674
|
+
method.init();
|
|
6675
|
+
|
|
6676
|
+
await expect(
|
|
6677
|
+
(method as any).prepareProtocolV2LocalResourceArchive(
|
|
6678
|
+
await zip.generateAsync({ type: 'arraybuffer' })
|
|
6679
|
+
)
|
|
6680
|
+
).rejects.toThrow(
|
|
6681
|
+
'Protocol V2 local resource file does not match manifest: bundles/images/images.okpkg'
|
|
6682
|
+
);
|
|
6683
|
+
});
|
|
6684
|
+
|
|
6685
|
+
test('keeps the legacy componentArtifacts and artifactReader path without a prepared Plan', async () => {
|
|
6686
|
+
const artifactReader = {
|
|
6687
|
+
open: jest.fn(),
|
|
6688
|
+
read: jest.fn(),
|
|
6689
|
+
close: jest.fn(),
|
|
6690
|
+
};
|
|
6691
|
+
const method = new FirmwareUpdateV4({
|
|
6692
|
+
id: 1,
|
|
6693
|
+
payload: {
|
|
6694
|
+
method: 'firmwareUpdateV4',
|
|
6695
|
+
platform: 'web',
|
|
6696
|
+
targetsToUpdate: ['boot'],
|
|
6697
|
+
artifactReader,
|
|
6698
|
+
componentArtifacts: {
|
|
6699
|
+
boot: {
|
|
6700
|
+
artifactRef: 'legacy-bootloader',
|
|
6701
|
+
size: 3,
|
|
6702
|
+
sha256: 'a'.repeat(64),
|
|
6703
|
+
},
|
|
6704
|
+
},
|
|
6705
|
+
},
|
|
6706
|
+
});
|
|
6707
|
+
|
|
6708
|
+
expect(() => method.init()).not.toThrow();
|
|
6709
|
+
(method as any).captureProtocolV2PhysicalIdentity = jest.fn().mockResolvedValue(undefined);
|
|
6710
|
+
(method as any).device = stubDevice({
|
|
6711
|
+
originalDescriptor: { protocolType: 'V2' },
|
|
6712
|
+
features: { deviceType: 'pro2', firmwareVersion: '1.0.0', capabilities: [] },
|
|
6713
|
+
});
|
|
6714
|
+
(method as any).runProtocolV2PreparedArtifacts = jest.fn().mockResolvedValue('legacy-result');
|
|
6715
|
+
|
|
6716
|
+
await expect(method.run()).resolves.toBe('legacy-result');
|
|
6717
|
+
expect((method as any).runProtocolV2PreparedArtifacts).toHaveBeenCalledTimes(1);
|
|
6718
|
+
});
|
|
6719
|
+
|
|
6332
6720
|
test('stops a remote update before reboot when the latest config cannot be refreshed', async () => {
|
|
6333
6721
|
const method = new FirmwareUpdateV4({
|
|
6334
6722
|
id: 1,
|
|
@@ -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 prepareProtocolV2LocalResourceArchive;
|
|
28
29
|
private prepareProtocolV2ResourceSources;
|
|
29
30
|
private prepareProtocolV2ResourceArchiveSources;
|
|
30
31
|
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,qBAAqB,CAAC;AAyBlG,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;AAqVD,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;IAyJJ,OAAO,CAAC,8BAA8B;IAwBhC,GAAG;;;;;YAKK,aAAa;YAkHb,4BAA4B;YAkB5B,0BAA0B;YAY1B,8BAA8B;YAK9B,+BAA+B;YAqG/B,qCAAqC;YA8GrC,gCAAgC;YAgBhC,uCAAuC;YAwHvC,8BAA8B;IAsB5C,OAAO,CAAC,8BAA8B;IA0BtC,OAAO,CAAC,kCAAkC;IAc1C,OAAO,CAAC,gCAAgC;IAsDxC,OAAO,CAAC,6BAA6B;YAsBvB,2BAA2B;IAWzC,OAAO,CAAC,yBAAyB;IAKjC,OAAO,CAAC,kCAAkC;IAS1C,OAAO,CAAC,8BAA8B;YAMxB,iCAAiC;YAOjC,iCAAiC;YAkBjC,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;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,CAoF7B"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1433,6 +1433,8 @@ interface FirmwareUpdateV4Params {
|
|
|
1433
1433
|
se02Binary?: ArrayBuffer;
|
|
1434
1434
|
se03Binary?: ArrayBuffer;
|
|
1435
1435
|
se04Binary?: ArrayBuffer;
|
|
1436
|
+
/** Complete Protocol V2 resource ZIP for local development; never bound to a remote Plan. */
|
|
1437
|
+
resourceArchiveBinary?: ArrayBuffer;
|
|
1436
1438
|
forcedUpdateRes?: boolean;
|
|
1437
1439
|
artifactReader?: FirmwareArtifactReader;
|
|
1438
1440
|
componentArtifacts?: Partial<Record<Exclude<FirmwareUpdateV4Target, 'resource'>, FirmwareArtifactReference>>;
|
|
@@ -4883,10 +4885,6 @@ type FirmwareMemoryArtifact = {
|
|
|
4883
4885
|
type FirmwareUpdateV4MemoryHost = {
|
|
4884
4886
|
preparedPlan: ReturnType<CoreApi['prepareFirmwareUpdatePlan']>;
|
|
4885
4887
|
hostBindingGeneration: number;
|
|
4886
|
-
targetsToUpdate: FirmwareUpdateV4Target[];
|
|
4887
|
-
expectedDeviceId: string;
|
|
4888
|
-
expectedTargetVersions: Partial<Record<FirmwareUpdateV4Target, string>>;
|
|
4889
|
-
componentArtifacts: Partial<Record<Exclude<FirmwareUpdateV4Target, 'resource'>, FirmwareArtifactReference>>;
|
|
4890
4888
|
release: () => void;
|
|
4891
4889
|
};
|
|
4892
4890
|
declare function prepareFirmwareUpdateV4MemoryHost({ sdk, plan, artifacts, }: {
|