@onekeyfe/hardware-cli 1.2.0-alpha.58 → 1.2.0-alpha.59
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 +2 -2
- package/dist/cli.js +7 -7
- package/package.json +6 -6
- package/src/cli.ts +9 -11
package/dist/cli.d.ts
CHANGED
|
@@ -53,7 +53,7 @@ export declare function runFirmwareUpdateV4WithRetry({ sdk, globalOpts, params,
|
|
|
53
53
|
}): Promise<unknown>;
|
|
54
54
|
declare function buildFirmwareUpdateV4Params(opts: {
|
|
55
55
|
chunkSize?: string;
|
|
56
|
-
|
|
56
|
+
resourceFile?: string[];
|
|
57
57
|
romloader?: string;
|
|
58
58
|
bootloader?: string;
|
|
59
59
|
applicationP1?: string;
|
|
@@ -69,7 +69,7 @@ declare function buildFirmwareUpdateV4Params(opts: {
|
|
|
69
69
|
connectProtocol: "V2";
|
|
70
70
|
chunkSize: number | undefined;
|
|
71
71
|
forcedUpdateRes: boolean | undefined;
|
|
72
|
-
|
|
72
|
+
resourceFiles: {
|
|
73
73
|
binary: ArrayBuffer;
|
|
74
74
|
devicePath: string;
|
|
75
75
|
}[] | undefined;
|
package/dist/cli.js
CHANGED
|
@@ -485,7 +485,7 @@ 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-
|
|
488
|
+
.option('--resource-file <spec...>', 'Resource direct-write spec: <localPath>:<devicePath>, e.g. wallpaper.okpkg:vol0:/bundles/images/wallpaper.okpkg')
|
|
489
489
|
.option('--romloader <path>', 'FW_MGMT_TARGET_ROMLOADER binary path')
|
|
490
490
|
.option('--bootloader <path>', 'FW_MGMT_TARGET_BOOTLOADER binary path')
|
|
491
491
|
.option('--application-p1 <path>', 'FW_MGMT_TARGET_APPLICATION_P1 binary path')
|
|
@@ -957,15 +957,15 @@ 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
|
|
960
|
+
function parseResourceFileParam(spec) {
|
|
961
961
|
const sep = spec.indexOf(':');
|
|
962
962
|
if (sep <= 0 || sep === spec.length - 1) {
|
|
963
|
-
throw new Error(`Invalid --resource-
|
|
963
|
+
throw new Error(`Invalid --resource-file value: "${spec}". Expected <localPath>:<devicePath>`);
|
|
964
964
|
}
|
|
965
965
|
const localPath = spec.slice(0, sep);
|
|
966
966
|
const devicePath = spec.slice(sep + 1);
|
|
967
967
|
if (!devicePath.startsWith('vol')) {
|
|
968
|
-
throw new Error(`Invalid --resource-
|
|
968
|
+
throw new Error(`Invalid --resource-file device path: "${devicePath}". Expected a vol*:/... path`);
|
|
969
969
|
}
|
|
970
970
|
return {
|
|
971
971
|
binary: readBinaryParam(localPath),
|
|
@@ -974,7 +974,7 @@ function parseResourceBundleParam(spec) {
|
|
|
974
974
|
}
|
|
975
975
|
function getFirmwareUpdateV4TotalBytes(params) {
|
|
976
976
|
return [
|
|
977
|
-
...(params.
|
|
977
|
+
...(params.resourceFiles?.map(item => item.binary) ?? []),
|
|
978
978
|
params.bootloaderBinary,
|
|
979
979
|
params.applicationP1Binary,
|
|
980
980
|
params.applicationP2Binary,
|
|
@@ -1209,7 +1209,7 @@ function buildFirmwareUpdateV4Params(opts) {
|
|
|
1209
1209
|
connectProtocol: 'V2',
|
|
1210
1210
|
chunkSize: opts.chunkSize ? safeParseInt(opts.chunkSize, '--chunk-size') : undefined,
|
|
1211
1211
|
forcedUpdateRes: opts.forcedUpdateRes,
|
|
1212
|
-
|
|
1212
|
+
resourceFiles: opts.resourceFile?.map(parseResourceFileParam),
|
|
1213
1213
|
romloaderBinary: opts.romloader ? readBinaryParam(opts.romloader) : undefined,
|
|
1214
1214
|
bootloaderBinary: opts.bootloader ? readBinaryParam(opts.bootloader) : undefined,
|
|
1215
1215
|
applicationP1Binary: opts.applicationP1 ? readBinaryParam(opts.applicationP1) : undefined,
|
|
@@ -1221,7 +1221,7 @@ function buildFirmwareUpdateV4Params(opts) {
|
|
|
1221
1221
|
se04Binary: opts.se04 ? readBinaryParam(opts.se04) : undefined,
|
|
1222
1222
|
};
|
|
1223
1223
|
const hasPayload = [
|
|
1224
|
-
params.
|
|
1224
|
+
params.resourceFiles,
|
|
1225
1225
|
params.romloaderBinary,
|
|
1226
1226
|
params.bootloaderBinary,
|
|
1227
1227
|
params.applicationP1Binary,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/hardware-cli",
|
|
3
|
-
"version": "1.2.0-alpha.
|
|
3
|
+
"version": "1.2.0-alpha.59",
|
|
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.
|
|
35
|
-
"@onekeyfe/hd-core": "1.2.0-alpha.
|
|
36
|
-
"@onekeyfe/hd-shared": "1.2.0-alpha.
|
|
37
|
-
"@onekeyfe/hd-transport-usb": "1.2.0-alpha.
|
|
34
|
+
"@onekeyfe/hd-common-connect-sdk": "1.2.0-alpha.59",
|
|
35
|
+
"@onekeyfe/hd-core": "1.2.0-alpha.59",
|
|
36
|
+
"@onekeyfe/hd-shared": "1.2.0-alpha.59",
|
|
37
|
+
"@onekeyfe/hd-transport-usb": "1.2.0-alpha.59",
|
|
38
38
|
"@stoprocent/noble": "2.3.16",
|
|
39
39
|
"commander": "^12.0.0"
|
|
40
40
|
},
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "98794c3032aab55e13fb2afedc645d8281141d5f"
|
|
42
42
|
}
|
package/src/cli.ts
CHANGED
|
@@ -629,8 +629,8 @@ program
|
|
|
629
629
|
.description('Run Protocol V2 firmware update through sdk.firmwareUpdateV4')
|
|
630
630
|
.option('--chunk-size <bytes>', 'Transfer chunk size in bytes')
|
|
631
631
|
.option(
|
|
632
|
-
'--resource-
|
|
633
|
-
'
|
|
632
|
+
'--resource-file <spec...>',
|
|
633
|
+
'Resource direct-write spec: <localPath>:<devicePath>, e.g. wallpaper.okpkg:vol0:/bundles/images/wallpaper.okpkg'
|
|
634
634
|
)
|
|
635
635
|
.option('--romloader <path>', 'FW_MGMT_TARGET_ROMLOADER binary path')
|
|
636
636
|
.option('--bootloader <path>', 'FW_MGMT_TARGET_BOOTLOADER binary path')
|
|
@@ -1253,18 +1253,16 @@ async function resolveLegacyFirmwareConnectId(
|
|
|
1253
1253
|
return connectId;
|
|
1254
1254
|
}
|
|
1255
1255
|
|
|
1256
|
-
function
|
|
1256
|
+
function parseResourceFileParam(spec: string): { binary: ArrayBuffer; devicePath: string } {
|
|
1257
1257
|
const sep = spec.indexOf(':');
|
|
1258
1258
|
if (sep <= 0 || sep === spec.length - 1) {
|
|
1259
|
-
throw new Error(
|
|
1260
|
-
`Invalid --resource-bundle value: "${spec}". Expected <localPath>:<devicePath>`
|
|
1261
|
-
);
|
|
1259
|
+
throw new Error(`Invalid --resource-file value: "${spec}". Expected <localPath>:<devicePath>`);
|
|
1262
1260
|
}
|
|
1263
1261
|
const localPath = spec.slice(0, sep);
|
|
1264
1262
|
const devicePath = spec.slice(sep + 1);
|
|
1265
1263
|
if (!devicePath.startsWith('vol')) {
|
|
1266
1264
|
throw new Error(
|
|
1267
|
-
`Invalid --resource-
|
|
1265
|
+
`Invalid --resource-file device path: "${devicePath}". Expected a vol*:/... path`
|
|
1268
1266
|
);
|
|
1269
1267
|
}
|
|
1270
1268
|
return {
|
|
@@ -1275,7 +1273,7 @@ function parseResourceBundleParam(spec: string): { binary: ArrayBuffer; devicePa
|
|
|
1275
1273
|
|
|
1276
1274
|
function getFirmwareUpdateV4TotalBytes(params: ReturnType<typeof buildFirmwareUpdateV4Params>) {
|
|
1277
1275
|
return [
|
|
1278
|
-
...(params.
|
|
1276
|
+
...(params.resourceFiles?.map(item => item.binary) ?? []),
|
|
1279
1277
|
params.bootloaderBinary,
|
|
1280
1278
|
params.applicationP1Binary,
|
|
1281
1279
|
params.applicationP2Binary,
|
|
@@ -1600,7 +1598,7 @@ export async function runFirmwareUpdateV4WithRetry({
|
|
|
1600
1598
|
|
|
1601
1599
|
function buildFirmwareUpdateV4Params(opts: {
|
|
1602
1600
|
chunkSize?: string;
|
|
1603
|
-
|
|
1601
|
+
resourceFile?: string[];
|
|
1604
1602
|
romloader?: string;
|
|
1605
1603
|
bootloader?: string;
|
|
1606
1604
|
applicationP1?: string;
|
|
@@ -1617,7 +1615,7 @@ function buildFirmwareUpdateV4Params(opts: {
|
|
|
1617
1615
|
connectProtocol: 'V2' as const,
|
|
1618
1616
|
chunkSize: opts.chunkSize ? safeParseInt(opts.chunkSize, '--chunk-size') : undefined,
|
|
1619
1617
|
forcedUpdateRes: opts.forcedUpdateRes,
|
|
1620
|
-
|
|
1618
|
+
resourceFiles: opts.resourceFile?.map(parseResourceFileParam),
|
|
1621
1619
|
romloaderBinary: opts.romloader ? readBinaryParam(opts.romloader) : undefined,
|
|
1622
1620
|
bootloaderBinary: opts.bootloader ? readBinaryParam(opts.bootloader) : undefined,
|
|
1623
1621
|
applicationP1Binary: opts.applicationP1 ? readBinaryParam(opts.applicationP1) : undefined,
|
|
@@ -1630,7 +1628,7 @@ function buildFirmwareUpdateV4Params(opts: {
|
|
|
1630
1628
|
};
|
|
1631
1629
|
|
|
1632
1630
|
const hasPayload = [
|
|
1633
|
-
params.
|
|
1631
|
+
params.resourceFiles,
|
|
1634
1632
|
params.romloaderBinary,
|
|
1635
1633
|
params.bootloaderBinary,
|
|
1636
1634
|
params.applicationP1Binary,
|