@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.
@@ -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: { target: 'SE01', url: 'https://example.com/se01.bin', version: [1, 0, 0] },
530
- se02: { target: 'SE02', url: 'https://example.com/se02.bin', version: [2, 0, 0] },
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
  },
@@ -90,9 +90,13 @@ describe('prepareFirmwareUpdateV4MemoryHost', () => {
90
90
  expect(sdk.registerFirmwareUpdateHostBinding).toHaveBeenCalledWith(
91
91
  expect.objectContaining({ preparedPlanDigest: host.preparedPlan.preparedPlanDigest })
92
92
  );
93
- expect(host.componentArtifacts.boot?.size).toBe(componentBinary.byteLength);
93
+ const componentArtifact = host.preparedPlan.artifacts.find(
94
+ artifact => artifact.target === 'boot'
95
+ )?.artifact;
96
+ expect(componentArtifact?.size).toBe(componentBinary.byteLength);
97
+ new Uint8Array(componentBinary).fill(9);
94
98
  const opened = await artifactReader!.open({
95
- artifactRef: host.componentArtifacts.boot!.artifactRef,
99
+ artifactRef: componentArtifact!.artifactRef,
96
100
  });
97
101
  const chunk = await artifactReader!.read({
98
102
  readerId: opened.readerId,
@@ -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
  },