@onekeyfe/hardware-cli 1.2.0-alpha.97 → 1.2.0-alpha.99

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/dist/cli.d.ts CHANGED
@@ -53,7 +53,6 @@ export declare function runFirmwareUpdateV4WithRetry({ sdk, globalOpts, params,
53
53
  }): Promise<unknown>;
54
54
  declare function buildFirmwareUpdateV4Params(opts: {
55
55
  chunkSize?: string;
56
- resourceFile?: string[];
57
56
  romloader?: string;
58
57
  bootloader?: string;
59
58
  applicationP1?: string;
@@ -63,16 +62,13 @@ declare function buildFirmwareUpdateV4Params(opts: {
63
62
  se02?: string;
64
63
  se03?: string;
65
64
  se04?: string;
65
+ resourceArchive?: string;
66
66
  forcedUpdateRes?: boolean;
67
67
  }): {
68
68
  platform: "desktop";
69
69
  connectProtocol: "V2";
70
70
  chunkSize: number | undefined;
71
71
  forcedUpdateRes: boolean | undefined;
72
- resourceFiles: {
73
- binary: ArrayBuffer;
74
- devicePath: string;
75
- }[] | undefined;
76
72
  romloaderBinary: ArrayBuffer | undefined;
77
73
  bootloaderBinary: ArrayBuffer | undefined;
78
74
  applicationP1Binary: ArrayBuffer | undefined;
@@ -82,5 +78,6 @@ declare function buildFirmwareUpdateV4Params(opts: {
82
78
  se02Binary: ArrayBuffer | undefined;
83
79
  se03Binary: ArrayBuffer | undefined;
84
80
  se04Binary: ArrayBuffer | undefined;
81
+ resourceArchiveBinary: ArrayBuffer | undefined;
85
82
  };
86
83
  export { program };
package/dist/cli.js CHANGED
@@ -485,7 +485,6 @@ program
485
485
  .command('firmware-update-v4')
486
486
  .description('Run Protocol V2 firmware update through sdk.firmwareUpdateV4')
487
487
  .option('--chunk-size <bytes>', 'Transfer chunk size in bytes')
488
- .option('--resource-file <spec...>', 'Resource direct-write spec: <localPath>:<devicePath>, e.g. wallpaper.okpkg:vol0:/bundles/images/wallpaper.okpkg')
489
488
  .option('--romloader <path>', 'FW_MGMT_TARGET_ROMLOADER binary path')
490
489
  .option('--bootloader <path>', 'FW_MGMT_TARGET_BOOTLOADER binary path')
491
490
  .option('--application-p1 <path>', 'FW_MGMT_TARGET_APPLICATION_P1 binary path')
@@ -495,6 +494,7 @@ program
495
494
  .option('--se02 <path>', 'FW_MGMT_TARGET_SE02 binary path')
496
495
  .option('--se03 <path>', 'FW_MGMT_TARGET_SE03 binary path')
497
496
  .option('--se04 <path>', 'FW_MGMT_TARGET_SE04 binary path')
497
+ .option('--resource-archive <path>', 'Complete signed Protocol V2 resource ZIP path')
498
498
  .option('--forced-update-res', 'Force resource update')
499
499
  .option('--retries <count>', 'Retry count for transient Protocol V2 USB probe failures')
500
500
  .action(opts => runCommand({}, async ({ sdk, globalOpts }) => {
@@ -957,24 +957,8 @@ async function resolveLegacyFirmwareConnectId(sdk, explicitConnectId, deviceName
957
957
  throw new Error(`BLE device has no connect ID: ${name}`);
958
958
  return connectId;
959
959
  }
960
- function parseResourceFileParam(spec) {
961
- const sep = spec.indexOf(':');
962
- if (sep <= 0 || sep === spec.length - 1) {
963
- throw new Error(`Invalid --resource-file value: "${spec}". Expected <localPath>:<devicePath>`);
964
- }
965
- const localPath = spec.slice(0, sep);
966
- const devicePath = spec.slice(sep + 1);
967
- if (!devicePath.startsWith('vol')) {
968
- throw new Error(`Invalid --resource-file device path: "${devicePath}". Expected a vol*:/... path`);
969
- }
970
- return {
971
- binary: readBinaryParam(localPath),
972
- devicePath,
973
- };
974
- }
975
960
  function getFirmwareUpdateV4TotalBytes(params) {
976
961
  return [
977
- ...(params.resourceFiles?.map(item => item.binary) ?? []),
978
962
  params.bootloaderBinary,
979
963
  params.applicationP1Binary,
980
964
  params.applicationP2Binary,
@@ -1209,7 +1193,6 @@ function buildFirmwareUpdateV4Params(opts) {
1209
1193
  connectProtocol: 'V2',
1210
1194
  chunkSize: opts.chunkSize ? safeParseInt(opts.chunkSize, '--chunk-size') : undefined,
1211
1195
  forcedUpdateRes: opts.forcedUpdateRes,
1212
- resourceFiles: opts.resourceFile?.map(parseResourceFileParam),
1213
1196
  romloaderBinary: opts.romloader ? readBinaryParam(opts.romloader) : undefined,
1214
1197
  bootloaderBinary: opts.bootloader ? readBinaryParam(opts.bootloader) : undefined,
1215
1198
  applicationP1Binary: opts.applicationP1 ? readBinaryParam(opts.applicationP1) : undefined,
@@ -1219,9 +1202,9 @@ function buildFirmwareUpdateV4Params(opts) {
1219
1202
  se02Binary: opts.se02 ? readBinaryParam(opts.se02) : undefined,
1220
1203
  se03Binary: opts.se03 ? readBinaryParam(opts.se03) : undefined,
1221
1204
  se04Binary: opts.se04 ? readBinaryParam(opts.se04) : undefined,
1205
+ resourceArchiveBinary: opts.resourceArchive ? readBinaryParam(opts.resourceArchive) : undefined,
1222
1206
  };
1223
1207
  const hasPayload = [
1224
- params.resourceFiles,
1225
1208
  params.romloaderBinary,
1226
1209
  params.bootloaderBinary,
1227
1210
  params.applicationP1Binary,
@@ -1231,9 +1214,10 @@ function buildFirmwareUpdateV4Params(opts) {
1231
1214
  params.se02Binary,
1232
1215
  params.se03Binary,
1233
1216
  params.se04Binary,
1217
+ params.resourceArchiveBinary,
1234
1218
  ].some(Boolean);
1235
1219
  if (!hasPayload) {
1236
- const err = new Error('firmware-update-v4 requires at least one binary path');
1220
+ const err = new Error('firmware-update-v4 requires at least one firmware binary or resource archive path');
1237
1221
  err.code = 'MISSING_FIRMWARE_BINARY';
1238
1222
  throw err;
1239
1223
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/hardware-cli",
3
- "version": "1.2.0-alpha.97",
3
+ "version": "1.2.0-alpha.99",
4
4
  "description": "OneKey hardware wallet CLI for testing device communication",
5
5
  "author": "OneKey",
6
6
  "license": "Apache-2.0",
@@ -31,12 +31,12 @@
31
31
  "test": "jest"
32
32
  },
33
33
  "dependencies": {
34
- "@onekeyfe/hd-common-connect-sdk": "1.2.0-alpha.97",
35
- "@onekeyfe/hd-core": "1.2.0-alpha.97",
36
- "@onekeyfe/hd-shared": "1.2.0-alpha.97",
37
- "@onekeyfe/hd-transport-usb": "1.2.0-alpha.97",
34
+ "@onekeyfe/hd-common-connect-sdk": "1.2.0-alpha.99",
35
+ "@onekeyfe/hd-core": "1.2.0-alpha.99",
36
+ "@onekeyfe/hd-shared": "1.2.0-alpha.99",
37
+ "@onekeyfe/hd-transport-usb": "1.2.0-alpha.99",
38
38
  "@stoprocent/noble": "2.3.16",
39
39
  "commander": "^12.0.0"
40
40
  },
41
- "gitHead": "d68cfec311df84b21124066ce3fe608596e4af0d"
41
+ "gitHead": "8924c0e509f84675a2c33c0062166967f5bcb2d0"
42
42
  }
@@ -36,6 +36,7 @@ describe('firmware-update-v4 CLI command', () => {
36
36
  expect(command?.description()).toBe(
37
37
  'Run Protocol V2 firmware update through sdk.firmwareUpdateV4'
38
38
  );
39
+ expect(command?.options.some(option => option.long === '--resource-archive')).toBe(true);
39
40
  });
40
41
 
41
42
  test('does not expose the pre-release firmware-update-v4-debug command', () => {
package/src/cli.ts CHANGED
@@ -628,10 +628,6 @@ program
628
628
  .command('firmware-update-v4')
629
629
  .description('Run Protocol V2 firmware update through sdk.firmwareUpdateV4')
630
630
  .option('--chunk-size <bytes>', 'Transfer chunk size in bytes')
631
- .option(
632
- '--resource-file <spec...>',
633
- 'Resource direct-write spec: <localPath>:<devicePath>, e.g. wallpaper.okpkg:vol0:/bundles/images/wallpaper.okpkg'
634
- )
635
631
  .option('--romloader <path>', 'FW_MGMT_TARGET_ROMLOADER binary path')
636
632
  .option('--bootloader <path>', 'FW_MGMT_TARGET_BOOTLOADER binary path')
637
633
  .option('--application-p1 <path>', 'FW_MGMT_TARGET_APPLICATION_P1 binary path')
@@ -641,6 +637,7 @@ program
641
637
  .option('--se02 <path>', 'FW_MGMT_TARGET_SE02 binary path')
642
638
  .option('--se03 <path>', 'FW_MGMT_TARGET_SE03 binary path')
643
639
  .option('--se04 <path>', 'FW_MGMT_TARGET_SE04 binary path')
640
+ .option('--resource-archive <path>', 'Complete signed Protocol V2 resource ZIP path')
644
641
  .option('--forced-update-res', 'Force resource update')
645
642
  .option('--retries <count>', 'Retry count for transient Protocol V2 USB probe failures')
646
643
  .action(opts =>
@@ -1253,27 +1250,8 @@ async function resolveLegacyFirmwareConnectId(
1253
1250
  return connectId;
1254
1251
  }
1255
1252
 
1256
- function parseResourceFileParam(spec: string): { binary: ArrayBuffer; devicePath: string } {
1257
- const sep = spec.indexOf(':');
1258
- if (sep <= 0 || sep === spec.length - 1) {
1259
- throw new Error(`Invalid --resource-file value: "${spec}". Expected <localPath>:<devicePath>`);
1260
- }
1261
- const localPath = spec.slice(0, sep);
1262
- const devicePath = spec.slice(sep + 1);
1263
- if (!devicePath.startsWith('vol')) {
1264
- throw new Error(
1265
- `Invalid --resource-file device path: "${devicePath}". Expected a vol*:/... path`
1266
- );
1267
- }
1268
- return {
1269
- binary: readBinaryParam(localPath),
1270
- devicePath,
1271
- };
1272
- }
1273
-
1274
1253
  function getFirmwareUpdateV4TotalBytes(params: ReturnType<typeof buildFirmwareUpdateV4Params>) {
1275
1254
  return [
1276
- ...(params.resourceFiles?.map(item => item.binary) ?? []),
1277
1255
  params.bootloaderBinary,
1278
1256
  params.applicationP1Binary,
1279
1257
  params.applicationP2Binary,
@@ -1598,7 +1576,6 @@ export async function runFirmwareUpdateV4WithRetry({
1598
1576
 
1599
1577
  function buildFirmwareUpdateV4Params(opts: {
1600
1578
  chunkSize?: string;
1601
- resourceFile?: string[];
1602
1579
  romloader?: string;
1603
1580
  bootloader?: string;
1604
1581
  applicationP1?: string;
@@ -1608,6 +1585,7 @@ function buildFirmwareUpdateV4Params(opts: {
1608
1585
  se02?: string;
1609
1586
  se03?: string;
1610
1587
  se04?: string;
1588
+ resourceArchive?: string;
1611
1589
  forcedUpdateRes?: boolean;
1612
1590
  }) {
1613
1591
  const params = {
@@ -1615,7 +1593,6 @@ function buildFirmwareUpdateV4Params(opts: {
1615
1593
  connectProtocol: 'V2' as const,
1616
1594
  chunkSize: opts.chunkSize ? safeParseInt(opts.chunkSize, '--chunk-size') : undefined,
1617
1595
  forcedUpdateRes: opts.forcedUpdateRes,
1618
- resourceFiles: opts.resourceFile?.map(parseResourceFileParam),
1619
1596
  romloaderBinary: opts.romloader ? readBinaryParam(opts.romloader) : undefined,
1620
1597
  bootloaderBinary: opts.bootloader ? readBinaryParam(opts.bootloader) : undefined,
1621
1598
  applicationP1Binary: opts.applicationP1 ? readBinaryParam(opts.applicationP1) : undefined,
@@ -1625,10 +1602,10 @@ function buildFirmwareUpdateV4Params(opts: {
1625
1602
  se02Binary: opts.se02 ? readBinaryParam(opts.se02) : undefined,
1626
1603
  se03Binary: opts.se03 ? readBinaryParam(opts.se03) : undefined,
1627
1604
  se04Binary: opts.se04 ? readBinaryParam(opts.se04) : undefined,
1605
+ resourceArchiveBinary: opts.resourceArchive ? readBinaryParam(opts.resourceArchive) : undefined,
1628
1606
  };
1629
1607
 
1630
1608
  const hasPayload = [
1631
- params.resourceFiles,
1632
1609
  params.romloaderBinary,
1633
1610
  params.bootloaderBinary,
1634
1611
  params.applicationP1Binary,
@@ -1638,10 +1615,13 @@ function buildFirmwareUpdateV4Params(opts: {
1638
1615
  params.se02Binary,
1639
1616
  params.se03Binary,
1640
1617
  params.se04Binary,
1618
+ params.resourceArchiveBinary,
1641
1619
  ].some(Boolean);
1642
1620
 
1643
1621
  if (!hasPayload) {
1644
- const err = new Error('firmware-update-v4 requires at least one binary path');
1622
+ const err = new Error(
1623
+ 'firmware-update-v4 requires at least one firmware binary or resource archive path'
1624
+ );
1645
1625
  (err as Error & { code?: string }).code = 'MISSING_FIRMWARE_BINARY';
1646
1626
  throw err;
1647
1627
  }