@onekeyfe/hd-core 1.2.0-alpha.156 → 1.2.0-alpha.157
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-update/firmware-update-prepared-plan.test.ts +16 -3
- package/__tests__/protocol-v2-resources.test.ts +19 -0
- package/__tests__/protocol-v2.test.ts +4 -0
- package/dist/api/FirmwareUpdateV4.d.ts.map +1 -1
- package/dist/api/firmware/FirmwareUpdatePreparedPlan.d.ts.map +1 -1
- package/dist/index.js +20 -3
- package/dist/protocols/protocol-v2/resources.d.ts +1 -0
- package/dist/protocols/protocol-v2/resources.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/api/FirmwareUpdateV4.ts +2 -1
- package/src/api/firmware/FirmwareUpdatePreparedPlan.ts +8 -6
- package/src/protocols/protocol-v2/resources.ts +14 -0
|
@@ -179,7 +179,7 @@ describe('FirmwareUpdatePreparedPlan', () => {
|
|
|
179
179
|
).toThrow('plan digest is invalid');
|
|
180
180
|
});
|
|
181
181
|
|
|
182
|
-
test('
|
|
182
|
+
test('keeps ZIP entries unique by archive path, not basename', () => {
|
|
183
183
|
const plan = buildPlan();
|
|
184
184
|
const buildArtifacts = (entryNames: string[]) => [
|
|
185
185
|
{
|
|
@@ -200,7 +200,20 @@ describe('FirmwareUpdatePreparedPlan', () => {
|
|
|
200
200
|
prepareFirmwareUpdatePlan({
|
|
201
201
|
plan,
|
|
202
202
|
leaseRef: 'fwlease:00000000-0000-4000-8000-000000000001',
|
|
203
|
-
artifacts: buildArtifacts([
|
|
203
|
+
artifacts: buildArtifacts([
|
|
204
|
+
'loaders/bootloader/params-pro2-prod_resource-unsigned.okpkg',
|
|
205
|
+
'loaders/rom/params-pro2-prod_resource-unsigned.okpkg',
|
|
206
|
+
]),
|
|
207
|
+
})
|
|
208
|
+
).not.toThrow();
|
|
209
|
+
expect(() =>
|
|
210
|
+
prepareFirmwareUpdatePlan({
|
|
211
|
+
plan,
|
|
212
|
+
leaseRef: 'fwlease:00000000-0000-4000-8000-000000000001',
|
|
213
|
+
artifacts: buildArtifacts([
|
|
214
|
+
'loaders/rom/params.okpkg',
|
|
215
|
+
'loaders/rom/params.okpkg',
|
|
216
|
+
]),
|
|
204
217
|
})
|
|
205
218
|
).toThrow('duplicate entry names');
|
|
206
219
|
expect(() =>
|
|
@@ -248,7 +261,7 @@ describe('FirmwareUpdatePreparedPlan', () => {
|
|
|
248
261
|
materializedEntries: [
|
|
249
262
|
...(resourceArtifact.materializedEntries ?? []),
|
|
250
263
|
{
|
|
251
|
-
entryName: '
|
|
264
|
+
entryName: 'resource/index.bin',
|
|
252
265
|
artifact: artifact('d'.repeat(64), 2),
|
|
253
266
|
},
|
|
254
267
|
],
|
|
@@ -3,6 +3,7 @@ import { EDeviceType, EFirmwareType, HardwareErrorCode } from '@onekeyfe/hd-shar
|
|
|
3
3
|
|
|
4
4
|
import { DataManager } from '../src/data-manager';
|
|
5
5
|
import {
|
|
6
|
+
isProtocolV2ResourceArchiveEntryName,
|
|
6
7
|
parseProtocolV2ResourcePackage,
|
|
7
8
|
parseProtocolV2Resources,
|
|
8
9
|
} from '../src/protocols/protocol-v2/resources';
|
|
@@ -104,6 +105,24 @@ describe('Pro2 resource configuration', () => {
|
|
|
104
105
|
});
|
|
105
106
|
});
|
|
106
107
|
|
|
108
|
+
test('ignores macOS ZIP metadata that only looks like a resource package', () => {
|
|
109
|
+
expect(
|
|
110
|
+
isProtocolV2ResourceArchiveEntryName(
|
|
111
|
+
'bundles/firmware_logo-pro2-prod_resource-signed.okpkg'
|
|
112
|
+
)
|
|
113
|
+
).toBe(true);
|
|
114
|
+
expect(
|
|
115
|
+
isProtocolV2ResourceArchiveEntryName(
|
|
116
|
+
'__MACOSX/pro2-prod_resource 2/bundles/._firmware_logo-pro2-prod_resource-signed.okpkg'
|
|
117
|
+
)
|
|
118
|
+
).toBe(false);
|
|
119
|
+
expect(
|
|
120
|
+
isProtocolV2ResourceArchiveEntryName(
|
|
121
|
+
'bundles/._firmware_logo-pro2-prod_resource-signed.okpkg'
|
|
122
|
+
)
|
|
123
|
+
).toBe(false);
|
|
124
|
+
});
|
|
125
|
+
|
|
107
126
|
test('reads the version, hashes, and direct device path from a RESC package', () => {
|
|
108
127
|
expect(
|
|
109
128
|
parseProtocolV2ResourcePackage(createResourcePackage('vol0:/bundles/images.okpkg'))
|
|
@@ -7720,6 +7720,10 @@ describe('Protocol V2 firmware update targets', () => {
|
|
|
7720
7720
|
zip.file('pro2-resource/bundles/images/images.okpkg', imagesBinary);
|
|
7721
7721
|
zip.file('pro2-resource/loaders/bootloader/boot_resource.okpkg', bootResourceBinary);
|
|
7722
7722
|
zip.file('pro2-resource/build-info.txt', 'ignored');
|
|
7723
|
+
zip.file(
|
|
7724
|
+
'__MACOSX/pro2-resource 2/bundles/._images.okpkg',
|
|
7725
|
+
new Uint8Array([0x00, 0x05, 0x16, 0x07])
|
|
7726
|
+
);
|
|
7723
7727
|
const method = new FirmwareUpdateV4({
|
|
7724
7728
|
id: 1,
|
|
7725
7729
|
payload: {
|
|
@@ -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;AA0BlG,OAAO,EAAE,wBAAwB,EAAE,MAAM,qCAAqC,CAAC;
|
|
1
|
+
{"version":3,"file":"FirmwareUpdateV4.d.ts","sourceRoot":"","sources":["../../src/api/FirmwareUpdateV4.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAkD,MAAM,qBAAqB,CAAC;AA0BlG,OAAO,EAAE,wBAAwB,EAAE,MAAM,qCAAqC,CAAC;AAsC/E,OAAO,KAAK,EAEV,sBAAsB,EAEvB,MAAM,6BAA6B,CAAC;AAyErC,wBAAgB,wCAAwC,CACtD,UAAU,EAAE,WAAW,GAAG,MAAM,GAAG,SA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firmware/FirmwareUpdatePreparedPlan.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EACV,8BAA8B,EAC9B,mCAAmC,EAEnC,0BAA0B,EAC3B,MAAM,4CAA4C,CAAC;AACpD,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAChF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAwB7E,eAAO,MAAM,6BAA6B,UAAW,OAAO,KAAG,MA8B9D,CAAC;
|
|
1
|
+
{"version":3,"file":"FirmwareUpdatePreparedPlan.d.ts","sourceRoot":"","sources":["../../../src/api/firmware/FirmwareUpdatePreparedPlan.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EACV,8BAA8B,EAC9B,mCAAmC,EAEnC,0BAA0B,EAC3B,MAAM,4CAA4C,CAAC;AACpD,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAChF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAwB7E,eAAO,MAAM,6BAA6B,UAAW,OAAO,KAAG,MA8B9D,CAAC;AAkGF,eAAO,MAAM,yBAAyB;UAK9B,kBAAkB;cACd,MAAM;eACL,mCAAmC,EAAE;MAC9C,0BAmBH,CAAC;AAEF,eAAO,MAAM,kCAAkC,UAAW,OAAO,KAAG,0BA0GnE,CAAC;AAEF,eAAO,MAAM,oCAAoC;kBAKjC,OAAO;YACb,8BAA8B,CAAC,QAAQ,CAAC;UAC1C,8BAA8B,CAAC,MAAM,CAAC;MAC1C,8BAOH,CAAC;AA4BF,eAAO,MAAM,gDAAgD,uBACvC,MAAM,KACzB,IAEF,CAAC;AAEF,eAAO,MAAM,8CAA8C;kBAM3C,OAAO;oBACL,MAAM,GAAG,SAAS;;;MAKhC,0BAsCH,CAAC;AAEF,KAAK,6BAA6B,GAAG;IACnC,MAAM,EAAE,kBAAkB,CAAC,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAC;IACtD,QAAQ,EAAE,yBAAyB,CAAC;IACpC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAUF,eAAO,MAAM,uCAAuC;kBAQpC,OAAO;cACX,0BAA0B,CAAC,UAAU,CAAC;;;kBAGlC,0BAA0B,CAAC,iBAAiB,CAAC;cACjD,6BAA6B,EAAE;MACvC,0BAmDH,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1136,6 +1136,10 @@ const getFirmwareUpdateResourceName = (value) => {
|
|
|
1136
1136
|
}
|
|
1137
1137
|
return resourceName;
|
|
1138
1138
|
};
|
|
1139
|
+
const getPreparedEntryIdentity = (entryName) => {
|
|
1140
|
+
getFirmwareUpdateResourceName(entryName);
|
|
1141
|
+
return entryName.toLowerCase();
|
|
1142
|
+
};
|
|
1139
1143
|
const assertPreparedEntry = (value) => {
|
|
1140
1144
|
if (!value || typeof value !== 'object' || Array.isArray(value)) {
|
|
1141
1145
|
return preparedPlanError('Firmware prepared plan entry must be an object');
|
|
@@ -1188,7 +1192,8 @@ const assertPreparedArtifacts = ({ plan, artifacts, }) => {
|
|
|
1188
1192
|
return preparedPlanError('Firmware prepared plan materialization is incomplete');
|
|
1189
1193
|
}
|
|
1190
1194
|
if (materializedEntries &&
|
|
1191
|
-
new Set(materializedEntries.map(entry =>
|
|
1195
|
+
new Set(materializedEntries.map(entry => getPreparedEntryIdentity(entry.entryName))).size !==
|
|
1196
|
+
materializedEntries.length) {
|
|
1192
1197
|
return preparedPlanError('Firmware prepared plan contains duplicate entry names');
|
|
1193
1198
|
}
|
|
1194
1199
|
return Object.assign(Object.assign(Object.assign(Object.assign({ artifactId: planArtifact.artifactId, role: planArtifact.role, target: planArtifact.target, container: planArtifact.container }, (planArtifact.logicalName ? { logicalName: planArtifact.logicalName } : {})), (planArtifact.targetVersion ? { targetVersion: planArtifact.targetVersion } : {})), { artifact: Object.assign(Object.assign({}, artifact), { sha256: artifact.sha256.toLowerCase() }) }), ((materializedEntries === null || materializedEntries === void 0 ? void 0 : materializedEntries.length) ? { materializedEntries } : {}));
|
|
@@ -1294,7 +1299,7 @@ const validateFirmwareUpdatePreparedPlan = (value) => {
|
|
|
1294
1299
|
assertFirmwareArtifactReference(artifact.artifact);
|
|
1295
1300
|
const materializedEntryNames = (_d = (_c = artifact.materializedEntries) === null || _c === void 0 ? void 0 : _c.map(entry => {
|
|
1296
1301
|
assertPreparedEntry(entry);
|
|
1297
|
-
return
|
|
1302
|
+
return getPreparedEntryIdentity(entry.entryName);
|
|
1298
1303
|
})) !== null && _d !== void 0 ? _d : [];
|
|
1299
1304
|
if (new Set(materializedEntryNames).size !== materializedEntryNames.length) {
|
|
1300
1305
|
return preparedPlanError('Firmware prepared plan contains duplicate entry names');
|
|
@@ -40717,6 +40722,18 @@ function parseProtocolV2Resources(value) {
|
|
|
40717
40722
|
},
|
|
40718
40723
|
};
|
|
40719
40724
|
}
|
|
40725
|
+
function isProtocolV2ResourceArchiveEntryName(entryName) {
|
|
40726
|
+
var _a;
|
|
40727
|
+
const normalized = entryName.replace(/\\/g, '/');
|
|
40728
|
+
if (!normalized.toLowerCase().endsWith('.okpkg')) {
|
|
40729
|
+
return false;
|
|
40730
|
+
}
|
|
40731
|
+
const parts = normalized.split('/');
|
|
40732
|
+
const fileName = (_a = parts[parts.length - 1]) !== null && _a !== void 0 ? _a : '';
|
|
40733
|
+
return (fileName.length > 0 &&
|
|
40734
|
+
!fileName.startsWith('.') &&
|
|
40735
|
+
!parts.some(part => part === '__MACOSX' || part === '.' || part === '..' || part === ''));
|
|
40736
|
+
}
|
|
40720
40737
|
function isSafeResourceDevicePath(path) {
|
|
40721
40738
|
return !(path.includes('\\') ||
|
|
40722
40739
|
path.includes('//') ||
|
|
@@ -52551,7 +52568,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
52551
52568
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, 'Protocol V2 resource ZIP cannot be parsed', { firmwareUpdateCode: 'FirmwareArtifactsNotPrepared' });
|
|
52552
52569
|
}
|
|
52553
52570
|
const zipEntries = Object.values(zip.files);
|
|
52554
|
-
const resourceEntries = zipEntries.filter(entry => !entry.dir && entry.name
|
|
52571
|
+
const resourceEntries = zipEntries.filter(entry => !entry.dir && isProtocolV2ResourceArchiveEntryName(entry.name));
|
|
52555
52572
|
if (resourceEntries.length === 0 ||
|
|
52556
52573
|
resourceEntries.length > PROTOCOL_V2_RESOURCE_FILE_MAX_COUNT) {
|
|
52557
52574
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, 'Protocol V2 resource ZIP has no valid resource package set', { firmwareUpdateCode: 'FirmwareArtifactsNotPrepared' });
|
|
@@ -4,6 +4,7 @@ export declare const PROTOCOL_V2_BOOT_RESOURCE_PACKAGE_STAGING_PATH: string;
|
|
|
4
4
|
export declare const PROTOCOL_V2_ROM_PARAMS_PACKAGE_PATH = "vol0:/loaders/rom/params.okpkg";
|
|
5
5
|
export declare const PROTOCOL_V2_RESOURCE_PACKAGE_HEADER_SIZE = 24464;
|
|
6
6
|
export declare function parseProtocolV2Resources(value: unknown): IProtocolV2Resources | undefined;
|
|
7
|
+
export declare function isProtocolV2ResourceArchiveEntryName(entryName: string): boolean;
|
|
7
8
|
export type ProtocolV2ResourcePackageHeader = {
|
|
8
9
|
version: IVersionArray;
|
|
9
10
|
payloadLength: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resources.d.ts","sourceRoot":"","sources":["../../../src/protocols/protocol-v2/resources.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEvE,eAAO,MAAM,sCAAsC,iDACH,CAAC;AACjD,eAAO,MAAM,8CAA8C,QAAsD,CAAC;AAClH,eAAO,MAAM,mCAAmC,mCAAmC,CAAC;AACpF,eAAO,MAAM,wCAAwC,QAAS,CAAC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AA8B,CAC5C,MAAM,EAAE,WAAW,GAAG,UAAU,GAC/B,+BAA+B,CAGjC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/hd-core",
|
|
3
|
-
"version": "1.2.0-alpha.
|
|
3
|
+
"version": "1.2.0-alpha.157",
|
|
4
4
|
"description": "Core processes and APIs for communicating with OneKey hardware devices.",
|
|
5
5
|
"author": "OneKey",
|
|
6
6
|
"homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"url": "https://github.com/OneKeyHQ/hardware-js-sdk/issues"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@onekeyfe/hd-shared": "1.2.0-alpha.
|
|
29
|
-
"@onekeyfe/hd-transport": "1.2.0-alpha.
|
|
28
|
+
"@onekeyfe/hd-shared": "1.2.0-alpha.157",
|
|
29
|
+
"@onekeyfe/hd-transport": "1.2.0-alpha.157",
|
|
30
30
|
"axios": "1.15.2",
|
|
31
31
|
"bignumber.js": "^9.0.2",
|
|
32
32
|
"buffer": "^6.0.3",
|
|
@@ -46,5 +46,5 @@
|
|
|
46
46
|
"@types/w3c-web-usb": "^1.0.10",
|
|
47
47
|
"@types/web-bluetooth": "^0.0.21"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "1e9aaf5fbf64562504ebc22dc34fb22220ba0b0b"
|
|
50
50
|
}
|
|
@@ -34,6 +34,7 @@ import { requestProtocolV2DeviceInfo } from '../protocols/protocol-v2/features';
|
|
|
34
34
|
import {
|
|
35
35
|
PROTOCOL_V2_BOOT_RESOURCE_PACKAGE_STAGING_PATH,
|
|
36
36
|
PROTOCOL_V2_RESOURCE_PACKAGE_HEADER_SIZE,
|
|
37
|
+
isProtocolV2ResourceArchiveEntryName,
|
|
37
38
|
parseProtocolV2ResourcePackage,
|
|
38
39
|
parseProtocolV2ResourcePackageHeader,
|
|
39
40
|
type ProtocolV2ResourcePackageHeader,
|
|
@@ -1210,7 +1211,7 @@ export default class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod<FirmwareU
|
|
|
1210
1211
|
}
|
|
1211
1212
|
const zipEntries = Object.values(zip.files);
|
|
1212
1213
|
const resourceEntries = zipEntries.filter(
|
|
1213
|
-
entry => !entry.dir && entry.name
|
|
1214
|
+
entry => !entry.dir && isProtocolV2ResourceArchiveEntryName(entry.name)
|
|
1214
1215
|
);
|
|
1215
1216
|
if (
|
|
1216
1217
|
resourceEntries.length === 0 ||
|
|
@@ -71,6 +71,11 @@ export const getFirmwareUpdateResourceName = (value: unknown): string => {
|
|
|
71
71
|
return resourceName;
|
|
72
72
|
};
|
|
73
73
|
|
|
74
|
+
const getPreparedEntryIdentity = (entryName: unknown): string => {
|
|
75
|
+
getFirmwareUpdateResourceName(entryName);
|
|
76
|
+
return (entryName as string).toLowerCase();
|
|
77
|
+
};
|
|
78
|
+
|
|
74
79
|
const assertPreparedEntry = (value: unknown): FirmwareUpdatePreparedEntry => {
|
|
75
80
|
if (!value || typeof value !== 'object' || Array.isArray(value)) {
|
|
76
81
|
return preparedPlanError('Firmware prepared plan entry must be an object');
|
|
@@ -141,11 +146,8 @@ const assertPreparedArtifacts = ({
|
|
|
141
146
|
}
|
|
142
147
|
if (
|
|
143
148
|
materializedEntries &&
|
|
144
|
-
new Set(
|
|
145
|
-
materializedEntries.
|
|
146
|
-
getFirmwareUpdateResourceName(entry.entryName).toLowerCase()
|
|
147
|
-
)
|
|
148
|
-
).size !== materializedEntries.length
|
|
149
|
+
new Set(materializedEntries.map(entry => getPreparedEntryIdentity(entry.entryName))).size !==
|
|
150
|
+
materializedEntries.length
|
|
149
151
|
) {
|
|
150
152
|
return preparedPlanError('Firmware prepared plan contains duplicate entry names');
|
|
151
153
|
}
|
|
@@ -281,7 +283,7 @@ export const validateFirmwareUpdatePreparedPlan = (value: unknown): FirmwareUpda
|
|
|
281
283
|
const materializedEntryNames =
|
|
282
284
|
artifact.materializedEntries?.map(entry => {
|
|
283
285
|
assertPreparedEntry(entry);
|
|
284
|
-
return
|
|
286
|
+
return getPreparedEntryIdentity(entry.entryName);
|
|
285
287
|
}) ?? [];
|
|
286
288
|
if (new Set(materializedEntryNames).size !== materializedEntryNames.length) {
|
|
287
289
|
return preparedPlanError('Firmware prepared plan contains duplicate entry names');
|
|
@@ -49,6 +49,20 @@ export function parseProtocolV2Resources(value: unknown): IProtocolV2Resources |
|
|
|
49
49
|
};
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
+
export function isProtocolV2ResourceArchiveEntryName(entryName: string): boolean {
|
|
53
|
+
const normalized = entryName.replace(/\\/g, '/');
|
|
54
|
+
if (!normalized.toLowerCase().endsWith('.okpkg')) {
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
const parts = normalized.split('/');
|
|
58
|
+
const fileName = parts[parts.length - 1] ?? '';
|
|
59
|
+
return (
|
|
60
|
+
fileName.length > 0 &&
|
|
61
|
+
!fileName.startsWith('.') &&
|
|
62
|
+
!parts.some(part => part === '__MACOSX' || part === '.' || part === '..' || part === '')
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
|
|
52
66
|
function isSafeResourceDevicePath(path: string): boolean {
|
|
53
67
|
return !(
|
|
54
68
|
path.includes('\\') ||
|