@onekeyfe/hd-core 1.2.0-alpha.70 → 1.2.0-alpha.72
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__/check-all-firmware-release-protocol-v2.test.ts +28 -0
- package/__tests__/protocol-v2-firmware-targets.test.ts +49 -1
- package/__tests__/protocol-v2-resources.test.ts +9 -6
- package/__tests__/protocol-v2.test.ts +431 -61
- package/__tests__/protocolV2FileWrite.test.ts +48 -7
- package/dist/api/CheckAllFirmwareRelease.d.ts +2 -1
- package/dist/api/CheckAllFirmwareRelease.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV4.d.ts +4 -0
- package/dist/api/FirmwareUpdateV4.d.ts.map +1 -1
- package/dist/api/helpers/protocolV2FileWrite.d.ts +1 -0
- package/dist/api/helpers/protocolV2FileWrite.d.ts.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +193 -43
- package/dist/protocols/protocol-v2/resources.d.ts +1 -1
- package/dist/protocols/protocol-v2/resources.d.ts.map +1 -1
- package/dist/types/api/firmwareUpdate.d.ts.map +1 -1
- package/dist/types/settings.d.ts +1 -1
- package/dist/types/settings.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/api/CheckAllFirmwareRelease.ts +19 -4
- package/src/api/FirmwareUpdateV4.ts +155 -23
- package/src/api/helpers/protocolV2FileWrite.ts +62 -8
- package/src/protocols/protocol-v2/resources.ts +5 -1
- package/src/types/api/firmwareUpdate.ts +1 -0
- package/src/types/settings.ts +2 -1
|
@@ -163,6 +163,34 @@ describe('checkAllFirmwareRelease Protocol V2 support', () => {
|
|
|
163
163
|
});
|
|
164
164
|
});
|
|
165
165
|
|
|
166
|
+
test('marks SE03 and SE04 as unsupported in a Neo firmware plan', () => {
|
|
167
|
+
const neoRelease: IFirmwareReleaseInfo = {
|
|
168
|
+
...release,
|
|
169
|
+
installOrder: ['se01', 'se02', 'se03', 'se04'],
|
|
170
|
+
components: {
|
|
171
|
+
se01: { target: 'SE01', url: 'https://example.com/se01.bin', version: [2, 0, 0] },
|
|
172
|
+
se02: { target: 'SE02', url: 'https://example.com/se02.bin', version: [3, 0, 0] },
|
|
173
|
+
se03: { target: 'SE03', url: 'https://example.com/se03.bin', version: [2, 0, 0] },
|
|
174
|
+
se04: { target: 'SE04', url: 'https://example.com/se04.bin', version: [2, 0, 0] },
|
|
175
|
+
},
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
const result = buildProtocolV2FirmwareRelease({
|
|
179
|
+
currentVersions,
|
|
180
|
+
firmwareType: EFirmwareType.Universal,
|
|
181
|
+
release: neoRelease,
|
|
182
|
+
deviceType: 'neo',
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
expect(result.targetsToUpdate).toEqual(['se01', 'se02']);
|
|
186
|
+
expect(result.components).toEqual(
|
|
187
|
+
expect.arrayContaining([
|
|
188
|
+
expect.objectContaining({ configKey: 'se03', status: 'unsupported', updateTarget: null }),
|
|
189
|
+
expect.objectContaining({ configKey: 'se04', status: 'unsupported', updateTarget: null }),
|
|
190
|
+
])
|
|
191
|
+
);
|
|
192
|
+
});
|
|
193
|
+
|
|
166
194
|
test('returns an unavailable plan when no Pro2 release is configured', () => {
|
|
167
195
|
expect(
|
|
168
196
|
buildProtocolV2FirmwareRelease({
|
|
@@ -1,5 +1,10 @@
|
|
|
1
|
+
import { EDeviceType, HardwareErrorCode } from '@onekeyfe/hd-shared';
|
|
2
|
+
|
|
1
3
|
import { ProtocolV2FirmwareTargetType } from '../src/protocols/protocol-v2/firmware';
|
|
2
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
assertProtocolV2FirmwareTargetsSupported,
|
|
6
|
+
isProtocolV2FirmwareFingerprintValid,
|
|
7
|
+
} from '../src/api/FirmwareUpdateV4';
|
|
3
8
|
|
|
4
9
|
jest.mock('../src/data/config', () => ({
|
|
5
10
|
DEFAULT_DOMAIN: 'https://example.com/',
|
|
@@ -34,4 +39,47 @@ describe('Protocol V2 firmware target contract', () => {
|
|
|
34
39
|
).toBe(true);
|
|
35
40
|
expect(isProtocolV2FirmwareFingerprintValid(binary, '00'.repeat(32))).toBe(false);
|
|
36
41
|
});
|
|
42
|
+
|
|
43
|
+
test('allows only SE01 and SE02 firmware targets on Neo', () => {
|
|
44
|
+
expect(() =>
|
|
45
|
+
assertProtocolV2FirmwareTargetsSupported(EDeviceType.Neo, {
|
|
46
|
+
platform: 'web',
|
|
47
|
+
targetsToUpdate: ['se01', 'se02'],
|
|
48
|
+
})
|
|
49
|
+
).not.toThrow();
|
|
50
|
+
|
|
51
|
+
expect(() =>
|
|
52
|
+
assertProtocolV2FirmwareTargetsSupported(EDeviceType.Neo, {
|
|
53
|
+
platform: 'web',
|
|
54
|
+
targetsToUpdate: ['se03'],
|
|
55
|
+
se04Binary: new ArrayBuffer(1),
|
|
56
|
+
})
|
|
57
|
+
).toThrow('Neo only supports SE01 and SE02; unsupported firmware targets: se03, se04');
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
test('keeps all four SE firmware targets available on Pro2', () => {
|
|
61
|
+
expect(() =>
|
|
62
|
+
assertProtocolV2FirmwareTargetsSupported(EDeviceType.Pro2, {
|
|
63
|
+
platform: 'web',
|
|
64
|
+
targetsToUpdate: ['se03'],
|
|
65
|
+
se04Binary: new ArrayBuffer(1),
|
|
66
|
+
})
|
|
67
|
+
).not.toThrow();
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
test('fails closed when SE03 or SE04 is requested without a confirmed device type', () => {
|
|
71
|
+
try {
|
|
72
|
+
assertProtocolV2FirmwareTargetsSupported(undefined, {
|
|
73
|
+
platform: 'web',
|
|
74
|
+
targetsToUpdate: ['se03'],
|
|
75
|
+
});
|
|
76
|
+
throw new Error('Expected unsupported target validation to fail');
|
|
77
|
+
} catch (error) {
|
|
78
|
+
expect(error).toMatchObject({ errorCode: HardwareErrorCode.DeviceNotSupportMethod });
|
|
79
|
+
expect(error).toHaveProperty(
|
|
80
|
+
'message',
|
|
81
|
+
'Cannot safely update se03 without a confirmed Pro2 device type'
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
});
|
|
37
85
|
});
|
|
@@ -95,7 +95,7 @@ describe('Pro2 resource configuration', () => {
|
|
|
95
95
|
DataManager.lastCheckTimestamp = 0;
|
|
96
96
|
});
|
|
97
97
|
|
|
98
|
-
test('accepts exactly
|
|
98
|
+
test('accepts exactly seven resources and normalizes their deterministic order', () => {
|
|
99
99
|
const parsed = parseProtocolV2Resources({
|
|
100
100
|
stable: [...resources].reverse(),
|
|
101
101
|
boot: bootResources,
|
|
@@ -106,15 +106,18 @@ describe('Pro2 resource configuration', () => {
|
|
|
106
106
|
expect(PROTOCOL_V2_RESOURCE_DEVICE_PATHS.translations).toBe(
|
|
107
107
|
'vol0:/bundles/translations/translations.okpkg'
|
|
108
108
|
);
|
|
109
|
+
expect(PROTOCOL_V2_RESOURCE_DEVICE_PATHS.firmware_logo).toBe(
|
|
110
|
+
'vol0:/bundles/firmware_logo.okpkg'
|
|
111
|
+
);
|
|
109
112
|
});
|
|
110
113
|
|
|
111
114
|
test('rejects incomplete, duplicate, or malformed stable sets', () => {
|
|
112
115
|
expect(() => parseProtocolV2Resources({ stable: resources.slice(1) })).toThrow(
|
|
113
|
-
'
|
|
116
|
+
'7 unique resource types'
|
|
114
117
|
);
|
|
115
118
|
expect(() =>
|
|
116
|
-
parseProtocolV2Resources({ stable: [...resources.slice(0,
|
|
117
|
-
).toThrow('
|
|
119
|
+
parseProtocolV2Resources({ stable: [...resources.slice(0, 6), resources[0]] })
|
|
120
|
+
).toThrow('7 unique resource types');
|
|
118
121
|
expect(() =>
|
|
119
122
|
parseProtocolV2Resources({
|
|
120
123
|
stable: resources.map((resource, index) =>
|
|
@@ -224,7 +227,7 @@ describe('Pro2 resource configuration', () => {
|
|
|
224
227
|
);
|
|
225
228
|
expect(typedCall.mock.calls.some(call => call[0] === 'ResourceInventoryGet')).toBe(false);
|
|
226
229
|
expect(typedCall.mock.calls.filter(call => call[0] === 'FilesystemPathInfoQuery')).toHaveLength(
|
|
227
|
-
|
|
230
|
+
7
|
|
228
231
|
);
|
|
229
232
|
expect(typedCall.mock.calls.some(call => call[0] === 'FilesystemFileRead')).toBe(true);
|
|
230
233
|
});
|
|
@@ -255,7 +258,7 @@ describe('Pro2 resource configuration', () => {
|
|
|
255
258
|
});
|
|
256
259
|
expect(
|
|
257
260
|
buildProtocolV2ResourceUpdatePlan({ resources, mode: 'bootloader-recovery' }).resources
|
|
258
|
-
).toHaveLength(
|
|
261
|
+
).toHaveLength(7);
|
|
259
262
|
});
|
|
260
263
|
|
|
261
264
|
test('uses a filesystem inventory for incremental recovery mode updates', () => {
|