@onekeyfe/hd-core 1.2.0-alpha.127 → 1.2.0-alpha.129
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-prepared-resource-archive.test.ts +21 -0
- package/__tests__/firmware-update/firmware-update-v4-install-poll.test.ts +5 -0
- package/__tests__/protocol-v2-resources.test.ts +108 -13
- package/__tests__/protocol-v2.test.ts +69 -19
- package/dist/api/CheckAllFirmwareRelease.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV4.d.ts.map +1 -1
- package/dist/api/firmware/FirmwarePreparedResourceArchive.d.ts.map +1 -1
- package/dist/api/firmware/getBinary.d.ts +1 -0
- package/dist/api/firmware/getBinary.d.ts.map +1 -1
- package/dist/data-manager/DataManager.d.ts +4 -3
- package/dist/data-manager/DataManager.d.ts.map +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.js +58 -41
- 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 +2 -4
- package/src/api/FirmwareUpdateV4.ts +42 -20
- package/src/api/firmware/FirmwarePreparedResourceArchive.ts +10 -1
- package/src/data-manager/DataManager.ts +45 -38
- package/src/types/settings.ts +2 -2
|
@@ -105,6 +105,27 @@ const createPreparedResourcePlan = ({
|
|
|
105
105
|
};
|
|
106
106
|
|
|
107
107
|
describe.each(['v2', 'v3'] as const)('%s prepared resource archive binding', executor => {
|
|
108
|
+
test('rejects a missing artifact reader', async () => {
|
|
109
|
+
const entryBinary = Uint8Array.from([1, 2, 3, 4]).buffer;
|
|
110
|
+
const zip = new JSZip();
|
|
111
|
+
zip.file('images/logo.bin', entryBinary);
|
|
112
|
+
const archiveBinary = await zip.generateAsync({ type: 'arraybuffer' });
|
|
113
|
+
const { preparedPlan } = createPreparedResourcePlan({
|
|
114
|
+
executor,
|
|
115
|
+
archiveBinary,
|
|
116
|
+
entryBinary,
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
await expect(
|
|
120
|
+
readVerifiedPreparedResourceArchive({
|
|
121
|
+
preparedPlan,
|
|
122
|
+
reader: undefined,
|
|
123
|
+
})
|
|
124
|
+
).rejects.toMatchObject({
|
|
125
|
+
params: { firmwareUpdateCode: 'FirmwareArtifactReaderInvalid' },
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
|
|
108
129
|
test('uses canonical bytes extracted from the approved ZIP', async () => {
|
|
109
130
|
const entryBinary = Uint8Array.from([1, 2, 3, 4]).buffer;
|
|
110
131
|
const zip = new JSZip();
|
|
@@ -42,7 +42,12 @@ describe('FirmwareUpdateV4 install polling', () => {
|
|
|
42
42
|
|
|
43
43
|
method.device = {
|
|
44
44
|
getCommands: () => ({ typedCall, call }),
|
|
45
|
+
createProtocolV2UiPhaseMetadata: jest.fn().mockReturnValue(undefined),
|
|
46
|
+
toMessageObject: jest.fn().mockReturnValue({ connectId: 'pro2-ble' }),
|
|
47
|
+
setCancelableAction: jest.fn(),
|
|
48
|
+
clearCancelableAction: jest.fn(),
|
|
45
49
|
} as unknown as Device;
|
|
50
|
+
method.postMessage = jest.fn();
|
|
46
51
|
method.postTipMessage = jest.fn();
|
|
47
52
|
method.postProgressMessage = jest.fn();
|
|
48
53
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import axios from 'axios';
|
|
2
2
|
import { sha256 } from '@noble/hashes/sha256';
|
|
3
|
-
import { EDeviceType, HardwareErrorCode } from '@onekeyfe/hd-shared';
|
|
3
|
+
import { EDeviceType, EFirmwareType, HardwareErrorCode } from '@onekeyfe/hd-shared';
|
|
4
4
|
|
|
5
5
|
import { DataManager } from '../src/data-manager';
|
|
6
6
|
import {
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
parseProtocolV2Resources,
|
|
9
9
|
} from '../src/protocols/protocol-v2/resources';
|
|
10
10
|
|
|
11
|
-
import type { ConnectSettings, RemoteConfigResponse } from '../src/types';
|
|
11
|
+
import type { ConnectSettings, Features, RemoteConfigResponse } from '../src/types';
|
|
12
12
|
|
|
13
13
|
jest.mock('axios');
|
|
14
14
|
jest.mock('../src/data/config', () => ({
|
|
@@ -108,11 +108,38 @@ const createRemoteConfig = (): RemoteConfigResponse =>
|
|
|
108
108
|
mini: { firmware: [], ble: [] },
|
|
109
109
|
touch: { firmware: [], ble: [] },
|
|
110
110
|
pro: { firmware: [], ble: [] },
|
|
111
|
-
pro2: {
|
|
112
|
-
|
|
111
|
+
pro2: {
|
|
112
|
+
'firmware-v1': [
|
|
113
|
+
{
|
|
114
|
+
required: false,
|
|
115
|
+
version: [1, 0, 0],
|
|
116
|
+
url: 'https://example.com/pro2.okpkg',
|
|
117
|
+
fingerprint: 'a'.repeat(64),
|
|
118
|
+
changelog: { 'zh-CN': 'Pro2', 'en-US': 'Pro2' },
|
|
119
|
+
resources: { source: resourceSource },
|
|
120
|
+
},
|
|
121
|
+
],
|
|
122
|
+
ble: [],
|
|
123
|
+
},
|
|
124
|
+
neo: {
|
|
125
|
+
'firmware-v1': [
|
|
126
|
+
{
|
|
127
|
+
required: false,
|
|
128
|
+
version: [1, 0, 0],
|
|
129
|
+
url: 'https://example.com/neo.okpkg',
|
|
130
|
+
fingerprint: 'b'.repeat(64),
|
|
131
|
+
changelog: { 'zh-CN': 'Neo', 'en-US': 'Neo' },
|
|
132
|
+
resources: { source: neoResourceSource },
|
|
133
|
+
},
|
|
134
|
+
],
|
|
135
|
+
ble: [],
|
|
136
|
+
},
|
|
113
137
|
bridge: {},
|
|
114
138
|
} as unknown as RemoteConfigResponse);
|
|
115
139
|
|
|
140
|
+
const getProtocolV2Release = (deviceType: EDeviceType.Pro2 | EDeviceType.Neo) =>
|
|
141
|
+
DataManager.deviceMap[deviceType]?.['firmware-v1']?.[0];
|
|
142
|
+
|
|
116
143
|
describe('Pro2 resource configuration', () => {
|
|
117
144
|
beforeEach(() => {
|
|
118
145
|
jest.clearAllMocks();
|
|
@@ -184,10 +211,70 @@ describe('Pro2 resource configuration', () => {
|
|
|
184
211
|
expect(configFetcher).toHaveBeenCalledWith(
|
|
185
212
|
expect.stringMatching(/^https:\/\/data\.onekey\.so\/pre-config\.json\?noCache=/)
|
|
186
213
|
);
|
|
187
|
-
expect(DataManager.getProtocolV2ResourceSource()).toEqual(
|
|
214
|
+
expect(DataManager.getProtocolV2ResourceSource(getProtocolV2Release(EDeviceType.Pro2))).toEqual(
|
|
215
|
+
resourceSource
|
|
216
|
+
);
|
|
188
217
|
expect(DataManager.lastCheckTimestamp).toBeGreaterThan(0);
|
|
189
218
|
});
|
|
190
219
|
|
|
220
|
+
test('uses the resource archive bound to the selected firmware release', async () => {
|
|
221
|
+
const newerResourceSource = {
|
|
222
|
+
archiveUrl: 'https://example.com/resource/pro2-resource-v2.zip',
|
|
223
|
+
archiveSha256: 'c'.repeat(64),
|
|
224
|
+
archiveSize: 20_000_000,
|
|
225
|
+
};
|
|
226
|
+
const remoteConfig = createRemoteConfig();
|
|
227
|
+
remoteConfig.pro2['firmware-v1']?.push({
|
|
228
|
+
...remoteConfig.pro2['firmware-v1'][0],
|
|
229
|
+
version: [2, 0, 0],
|
|
230
|
+
resources: { source: newerResourceSource },
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
await expect(
|
|
234
|
+
DataManager.load(createSettings(jest.fn().mockResolvedValue(remoteConfig)))
|
|
235
|
+
).resolves.toBe(true);
|
|
236
|
+
|
|
237
|
+
const selectedRelease = DataManager.getFirmwareLatestRelease(
|
|
238
|
+
{ deviceType: 'pro2', firmwareVersion: '1.0.0' } as Features,
|
|
239
|
+
EFirmwareType.Universal
|
|
240
|
+
);
|
|
241
|
+
expect(selectedRelease?.version).toEqual([2, 0, 0]);
|
|
242
|
+
expect(DataManager.getProtocolV2ResourceSource(selectedRelease)).toEqual(newerResourceSource);
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
test('does not use a device-level Protocol V2 resource archive', async () => {
|
|
246
|
+
const remoteConfig = createRemoteConfig();
|
|
247
|
+
delete remoteConfig.pro2['firmware-v1']?.[0].resources;
|
|
248
|
+
(remoteConfig.pro2 as unknown as { resources: unknown }).resources = {
|
|
249
|
+
source: resourceSource,
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
await expect(
|
|
253
|
+
DataManager.load(createSettings(jest.fn().mockResolvedValue(remoteConfig)))
|
|
254
|
+
).resolves.toBe(true);
|
|
255
|
+
|
|
256
|
+
expect(
|
|
257
|
+
DataManager.getProtocolV2ResourceSource(getProtocolV2Release(EDeviceType.Pro2))
|
|
258
|
+
).toBeUndefined();
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
test('does not block the latest release when an older release has invalid resources', async () => {
|
|
262
|
+
const remoteConfig = createRemoteConfig();
|
|
263
|
+
(remoteConfig.pro2['firmware-v1']?.[0] as { resources?: unknown }).resources = { source: {} };
|
|
264
|
+
remoteConfig.pro2['firmware-v1']?.push({
|
|
265
|
+
...remoteConfig.pro2['firmware-v1'][0],
|
|
266
|
+
version: [2, 0, 0],
|
|
267
|
+
resources: { source: resourceSource },
|
|
268
|
+
});
|
|
269
|
+
const configFetcher = jest.fn().mockResolvedValue(remoteConfig);
|
|
270
|
+
|
|
271
|
+
await expect(DataManager.load(createSettings(configFetcher))).resolves.toBe(true);
|
|
272
|
+
await expect(DataManager.forceReloadData({ requireResources: true })).resolves.toBeUndefined();
|
|
273
|
+
|
|
274
|
+
const latestRelease = DataManager.deviceMap[EDeviceType.Pro2]?.['firmware-v1']?.[1];
|
|
275
|
+
expect(DataManager.getProtocolV2ResourceSource(latestRelease)).toEqual(resourceSource);
|
|
276
|
+
});
|
|
277
|
+
|
|
191
278
|
test('reuses the configuration fetched during SDK initialization for an immediate update', async () => {
|
|
192
279
|
const configFetcher = jest.fn().mockResolvedValue(createRemoteConfig());
|
|
193
280
|
const settings = createSettings(configFetcher);
|
|
@@ -200,25 +287,33 @@ describe('Pro2 resource configuration', () => {
|
|
|
200
287
|
|
|
201
288
|
test('keeps base SDK initialization available when remote Pro2 resources are invalid', async () => {
|
|
202
289
|
const remoteConfig = createRemoteConfig();
|
|
203
|
-
(remoteConfig.pro2 as { resources?: unknown }).resources = { source: {} };
|
|
290
|
+
(remoteConfig.pro2['firmware-v1']?.[0] as { resources?: unknown }).resources = { source: {} };
|
|
204
291
|
const configFetcher = jest.fn().mockResolvedValue(remoteConfig);
|
|
205
292
|
|
|
206
293
|
await expect(DataManager.load(createSettings(configFetcher))).resolves.toBe(true);
|
|
207
294
|
|
|
208
|
-
expect(
|
|
295
|
+
expect(
|
|
296
|
+
DataManager.getProtocolV2ResourceSource(getProtocolV2Release(EDeviceType.Pro2))
|
|
297
|
+
).toBeUndefined();
|
|
209
298
|
expect(DataManager.protocolV2ResourcesConfigError).toBeInstanceOf(Error);
|
|
210
|
-
expect(DataManager.getProtocolV2ResourceSource(EDeviceType.Neo)).toEqual(
|
|
299
|
+
expect(DataManager.getProtocolV2ResourceSource(getProtocolV2Release(EDeviceType.Neo))).toEqual(
|
|
300
|
+
neoResourceSource
|
|
301
|
+
);
|
|
211
302
|
});
|
|
212
303
|
|
|
213
304
|
test('keeps Pro2 resources available when remote Neo resources are invalid', async () => {
|
|
214
305
|
const remoteConfig = createRemoteConfig();
|
|
215
|
-
(remoteConfig.neo as { resources?: unknown }).resources = { source: {} };
|
|
306
|
+
(remoteConfig.neo?.['firmware-v1']?.[0] as { resources?: unknown }).resources = { source: {} };
|
|
216
307
|
const configFetcher = jest.fn().mockResolvedValue(remoteConfig);
|
|
217
308
|
|
|
218
309
|
await expect(DataManager.load(createSettings(configFetcher))).resolves.toBe(true);
|
|
219
310
|
|
|
220
|
-
expect(DataManager.getProtocolV2ResourceSource(EDeviceType.Pro2)).toEqual(
|
|
221
|
-
|
|
311
|
+
expect(DataManager.getProtocolV2ResourceSource(getProtocolV2Release(EDeviceType.Pro2))).toEqual(
|
|
312
|
+
resourceSource
|
|
313
|
+
);
|
|
314
|
+
expect(
|
|
315
|
+
DataManager.getProtocolV2ResourceSource(getProtocolV2Release(EDeviceType.Neo))
|
|
316
|
+
).toBeUndefined();
|
|
222
317
|
await expect(
|
|
223
318
|
DataManager.forceReloadData({
|
|
224
319
|
requireResources: true,
|
|
@@ -238,7 +333,7 @@ describe('Pro2 resource configuration', () => {
|
|
|
238
333
|
|
|
239
334
|
test('only blocks resource mutation when the refreshed Pro2 resources are invalid', async () => {
|
|
240
335
|
const remoteConfig = createRemoteConfig();
|
|
241
|
-
(remoteConfig.pro2 as { resources?: unknown }).resources = { source: {} };
|
|
336
|
+
(remoteConfig.pro2['firmware-v1']?.[0] as { resources?: unknown }).resources = { source: {} };
|
|
242
337
|
const settings = createSettings(jest.fn().mockResolvedValue(remoteConfig));
|
|
243
338
|
DataManager.settings = settings;
|
|
244
339
|
|
|
@@ -252,7 +347,7 @@ describe('Pro2 resource configuration', () => {
|
|
|
252
347
|
|
|
253
348
|
test('checks resource configuration errors for the requested device only', async () => {
|
|
254
349
|
const remoteConfig = createRemoteConfig();
|
|
255
|
-
(remoteConfig.pro2 as { resources?: unknown }).resources = { source: {} };
|
|
350
|
+
(remoteConfig.pro2['firmware-v1']?.[0] as { resources?: unknown }).resources = { source: {} };
|
|
256
351
|
const settings = createSettings(jest.fn().mockResolvedValue(remoteConfig));
|
|
257
352
|
DataManager.settings = settings;
|
|
258
353
|
|
|
@@ -514,6 +514,10 @@ function stubDevice<T extends Record<string, any>>(device: T): T {
|
|
|
514
514
|
const d = device as any;
|
|
515
515
|
d.updateState ??= jest.fn();
|
|
516
516
|
d.markProtocolV2Reboot ??= jest.fn();
|
|
517
|
+
d.setCancelableAction ??= jest.fn();
|
|
518
|
+
d.clearCancelableAction ??= jest.fn();
|
|
519
|
+
d.toMessageObject ??= jest.fn(() => ({ connectId: d.originalDescriptor?.id }));
|
|
520
|
+
d.createProtocolV2UiPhaseMetadata ??= jest.fn(() => undefined);
|
|
517
521
|
d.isProtocolV2 ??= () => d.originalDescriptor?.protocolType === 'V2';
|
|
518
522
|
d.isBootloader ??= () => d.features?.mode === 'bootloader';
|
|
519
523
|
d.isRomloader ??= () => d.features?.mode === 'romloader';
|
|
@@ -4271,7 +4275,7 @@ describe('Protocol V2 firmware update targets', () => {
|
|
|
4271
4275
|
});
|
|
4272
4276
|
(method as any).protocolV2Reboot = jest.fn();
|
|
4273
4277
|
(method as any).enterProtocolV2BootloaderMode = jest.fn().mockResolvedValue(true);
|
|
4274
|
-
method.
|
|
4278
|
+
method.postMessage = jest.fn();
|
|
4275
4279
|
|
|
4276
4280
|
await method.run();
|
|
4277
4281
|
|
|
@@ -5254,10 +5258,26 @@ describe('Protocol V2 firmware update targets', () => {
|
|
|
5254
5258
|
const targets = [{ target_id: 4, path: 'vol1:firmware.bin' }];
|
|
5255
5259
|
const typedCall = jest.fn().mockResolvedValue({ type: 'Success', message: {} });
|
|
5256
5260
|
const call = jest.fn().mockResolvedValue({ type: 'WriteCompleted', message: {} });
|
|
5261
|
+
const cancelDevice = jest.fn().mockResolvedValue(undefined);
|
|
5262
|
+
let cancelableAction: (() => Promise<unknown>) | undefined;
|
|
5263
|
+
const interaction = {
|
|
5264
|
+
interactionId: 'firmware-update',
|
|
5265
|
+
phaseId: 'firmware-update:phase-1',
|
|
5266
|
+
sequence: 1,
|
|
5267
|
+
phase: 'button',
|
|
5268
|
+
transition: 'start',
|
|
5269
|
+
protocol: 'V2',
|
|
5270
|
+
};
|
|
5257
5271
|
|
|
5258
5272
|
(method as any).device = stubDevice({
|
|
5259
|
-
getCommands: () => ({ typedCall, call }),
|
|
5273
|
+
getCommands: () => ({ typedCall, call, cancelDevice }),
|
|
5274
|
+
createProtocolV2UiPhaseMetadata: jest.fn().mockReturnValue(interaction),
|
|
5275
|
+
toMessageObject: jest.fn().mockReturnValue({ connectId: 'pro2' }),
|
|
5276
|
+
setCancelableAction: jest.fn(action => {
|
|
5277
|
+
cancelableAction = action;
|
|
5278
|
+
}),
|
|
5260
5279
|
});
|
|
5280
|
+
method.postMessage = jest.fn();
|
|
5261
5281
|
method.postTipMessage = jest.fn();
|
|
5262
5282
|
method.postProgressMessage = jest.fn();
|
|
5263
5283
|
|
|
@@ -5266,14 +5286,32 @@ describe('Protocol V2 firmware update targets', () => {
|
|
|
5266
5286
|
).resolves.toBeUndefined();
|
|
5267
5287
|
|
|
5268
5288
|
expect(typedCall).toHaveBeenCalledWith('DeviceFirmwareUpdateStage', 'Success', { targets });
|
|
5289
|
+
expect(method.postMessage).toHaveBeenCalledWith({
|
|
5290
|
+
event: 'UI_EVENT',
|
|
5291
|
+
type: UI_REQUEST.REQUEST_BUTTON,
|
|
5292
|
+
payload: {
|
|
5293
|
+
device: { connectId: 'pro2' },
|
|
5294
|
+
source: 'method-lifecycle',
|
|
5295
|
+
reason: 'firmware-update',
|
|
5296
|
+
completion: 'operation-completed',
|
|
5297
|
+
deviceOnly: true,
|
|
5298
|
+
operation: 'firmwareUpdateV4',
|
|
5299
|
+
interaction,
|
|
5300
|
+
},
|
|
5301
|
+
});
|
|
5269
5302
|
expect(call).toHaveBeenCalledWith(
|
|
5270
5303
|
'DeviceFirmwareUpdateRequest',
|
|
5271
5304
|
{},
|
|
5272
5305
|
{ returnAfterWrite: true }
|
|
5273
5306
|
);
|
|
5274
5307
|
expect(typedCall.mock.invocationCallOrder[0]).toBeLessThan(call.mock.invocationCallOrder[0]);
|
|
5275
|
-
expect(method.
|
|
5276
|
-
|
|
5308
|
+
expect((method.postMessage as jest.Mock).mock.invocationCallOrder[0]).toBeLessThan(
|
|
5309
|
+
call.mock.invocationCallOrder[0]
|
|
5310
|
+
);
|
|
5311
|
+
expect(method.postTipMessage).not.toHaveBeenCalled();
|
|
5312
|
+
expect(method.postProgressMessage).not.toHaveBeenCalled();
|
|
5313
|
+
await cancelableAction?.();
|
|
5314
|
+
expect(cancelDevice).toHaveBeenCalledTimes(1);
|
|
5277
5315
|
});
|
|
5278
5316
|
|
|
5279
5317
|
test('does not send the install request when Protocol V2 staging fails', async () => {
|
|
@@ -5289,6 +5327,7 @@ describe('Protocol V2 firmware update targets', () => {
|
|
|
5289
5327
|
(method as any).device = stubDevice({
|
|
5290
5328
|
getCommands: () => ({ typedCall, call }),
|
|
5291
5329
|
});
|
|
5330
|
+
method.postMessage = jest.fn();
|
|
5292
5331
|
method.postTipMessage = jest.fn();
|
|
5293
5332
|
method.postProgressMessage = jest.fn();
|
|
5294
5333
|
|
|
@@ -5299,6 +5338,7 @@ describe('Protocol V2 firmware update targets', () => {
|
|
|
5299
5338
|
).rejects.toThrow('stage failed');
|
|
5300
5339
|
|
|
5301
5340
|
expect(call).not.toHaveBeenCalled();
|
|
5341
|
+
expect(method.postMessage).not.toHaveBeenCalled();
|
|
5302
5342
|
expect(method.postTipMessage).not.toHaveBeenCalled();
|
|
5303
5343
|
expect(method.postProgressMessage).not.toHaveBeenCalled();
|
|
5304
5344
|
});
|
|
@@ -5315,7 +5355,10 @@ describe('Protocol V2 firmware update targets', () => {
|
|
|
5315
5355
|
|
|
5316
5356
|
(method as any).device = stubDevice({
|
|
5317
5357
|
getCommands: () => ({ typedCall, call }),
|
|
5358
|
+
createProtocolV2UiPhaseMetadata: jest.fn().mockReturnValue(undefined),
|
|
5359
|
+
toMessageObject: jest.fn().mockReturnValue({ connectId: 'pro2' }),
|
|
5318
5360
|
});
|
|
5361
|
+
method.postMessage = jest.fn();
|
|
5319
5362
|
method.postTipMessage = jest.fn();
|
|
5320
5363
|
method.postProgressMessage = jest.fn();
|
|
5321
5364
|
|
|
@@ -5347,23 +5390,23 @@ describe('Protocol V2 firmware update targets', () => {
|
|
|
5347
5390
|
type: 'DeviceFirmwareUpdateStatus',
|
|
5348
5391
|
message: { records: [{ target_id: 4, status: 2 }] },
|
|
5349
5392
|
});
|
|
5350
|
-
const reconnectProtocolV2Device = jest
|
|
5351
|
-
|
|
5352
|
-
.mockRejectedValueOnce(new Error('Device rebooting'))
|
|
5353
|
-
.mockResolvedValue(undefined);
|
|
5393
|
+
const reconnectProtocolV2Device = jest.fn();
|
|
5394
|
+
const verifyProtocolV2ReconnectIdentity = jest.fn();
|
|
5354
5395
|
|
|
5355
5396
|
(method as any).device = stubDevice({
|
|
5356
5397
|
getCommands: () => ({ typedCall }),
|
|
5357
5398
|
});
|
|
5358
5399
|
(method as any).reconnectProtocolV2Device = reconnectProtocolV2Device;
|
|
5359
|
-
(method as any).verifyProtocolV2ReconnectIdentity =
|
|
5400
|
+
(method as any).verifyProtocolV2ReconnectIdentity = verifyProtocolV2ReconnectIdentity;
|
|
5360
5401
|
method.postProgressMessage = jest.fn();
|
|
5402
|
+
method.postTipMessage = jest.fn();
|
|
5361
5403
|
|
|
5362
5404
|
await (method as any).waitForProtocolV2FirmwareUpdateComplete([
|
|
5363
5405
|
{ target_id: 4, path: 'vol0:/application_p1.bin' },
|
|
5364
5406
|
]);
|
|
5365
5407
|
|
|
5366
|
-
expect(reconnectProtocolV2Device).
|
|
5408
|
+
expect(reconnectProtocolV2Device).not.toHaveBeenCalled();
|
|
5409
|
+
expect(verifyProtocolV2ReconnectIdentity).not.toHaveBeenCalled();
|
|
5367
5410
|
expect(typedCall.mock.calls.map(call => call[0])).toEqual([
|
|
5368
5411
|
'DeviceFirmwareUpdateStatusGet',
|
|
5369
5412
|
'DeviceFirmwareUpdateStatusGet',
|
|
@@ -5418,7 +5461,7 @@ describe('Protocol V2 firmware update targets', () => {
|
|
|
5418
5461
|
setTimeoutSpy.mockRestore();
|
|
5419
5462
|
}
|
|
5420
5463
|
|
|
5421
|
-
expect(reconnectProtocolV2Device).
|
|
5464
|
+
expect(reconnectProtocolV2Device).not.toHaveBeenCalled();
|
|
5422
5465
|
expect(typedCall.mock.calls.map(call => call[0])).toEqual([
|
|
5423
5466
|
'DeviceFirmwareUpdateStatusGet',
|
|
5424
5467
|
'DeviceFirmwareUpdateStatusGet',
|
|
@@ -5706,7 +5749,9 @@ describe('Protocol V2 firmware update targets', () => {
|
|
|
5706
5749
|
'DeviceFirmwareUpdateStatusGet',
|
|
5707
5750
|
'DeviceFirmwareUpdateStatusGet',
|
|
5708
5751
|
]);
|
|
5709
|
-
expect((method as any).
|
|
5752
|
+
expect((method as any).reconnectProtocolV2Device).toHaveBeenCalledTimes(1);
|
|
5753
|
+
expect((method as any).verifyProtocolV2ReconnectIdentity).toHaveBeenCalledTimes(1);
|
|
5754
|
+
expect((method as any).probeProtocolV2NormalMode).not.toHaveBeenCalled();
|
|
5710
5755
|
});
|
|
5711
5756
|
|
|
5712
5757
|
test('rejects a finished target whose payload version conflicts with the plan', () => {
|
|
@@ -5916,7 +5961,7 @@ describe('Protocol V2 firmware update targets', () => {
|
|
|
5916
5961
|
])
|
|
5917
5962
|
).resolves.toBeUndefined();
|
|
5918
5963
|
|
|
5919
|
-
expect(reconnectProtocolV2Device).
|
|
5964
|
+
expect(reconnectProtocolV2Device).not.toHaveBeenCalled();
|
|
5920
5965
|
expect(typedCall).toHaveBeenCalledWith(
|
|
5921
5966
|
'DeviceFirmwareUpdateStatusGet',
|
|
5922
5967
|
['DeviceFirmwareUpdateStatus', 'Success'],
|
|
@@ -6015,7 +6060,7 @@ describe('Protocol V2 firmware update targets', () => {
|
|
|
6015
6060
|
{ target_id: 4, path: 'vol0:/application_p1.bin' },
|
|
6016
6061
|
])
|
|
6017
6062
|
).resolves.toBeUndefined();
|
|
6018
|
-
expect(reconnectProtocolV2Device).toHaveBeenCalledTimes(
|
|
6063
|
+
expect(reconnectProtocolV2Device).toHaveBeenCalledTimes(1);
|
|
6019
6064
|
expect(typedCall).toHaveBeenCalledTimes(4);
|
|
6020
6065
|
});
|
|
6021
6066
|
|
|
@@ -8426,7 +8471,7 @@ describe('Protocol V2 firmware update targets', () => {
|
|
|
8426
8471
|
expect(writePayloads.map(payload => payload.file.data.byteLength)).toEqual([1960, 1]);
|
|
8427
8472
|
});
|
|
8428
8473
|
|
|
8429
|
-
test('
|
|
8474
|
+
test('keeps the confirmation UI active after Stage and the empty Request are written', async () => {
|
|
8430
8475
|
const method = new FirmwareUpdateV4({
|
|
8431
8476
|
id: 1,
|
|
8432
8477
|
payload: {
|
|
@@ -8444,7 +8489,10 @@ describe('Protocol V2 firmware update targets', () => {
|
|
|
8444
8489
|
|
|
8445
8490
|
(method as any).device = stubDevice({
|
|
8446
8491
|
getCommands: () => ({ typedCall, call }),
|
|
8492
|
+
createProtocolV2UiPhaseMetadata: jest.fn().mockReturnValue(undefined),
|
|
8493
|
+
toMessageObject: jest.fn().mockReturnValue({ connectId: 'pro2' }),
|
|
8447
8494
|
});
|
|
8495
|
+
method.postMessage = jest.fn();
|
|
8448
8496
|
method.postProgressMessage = jest.fn();
|
|
8449
8497
|
method.postTipMessage = jest.fn();
|
|
8450
8498
|
|
|
@@ -8470,9 +8518,8 @@ describe('Protocol V2 firmware update targets', () => {
|
|
|
8470
8518
|
|
|
8471
8519
|
resolveWrite?.({ type: 'WriteCompleted', message: {} });
|
|
8472
8520
|
await startPromise;
|
|
8473
|
-
expect(method.postTipMessage).
|
|
8474
|
-
expect(method.postProgressMessage).
|
|
8475
|
-
expect(method.postTipMessage).toHaveBeenCalledTimes(1);
|
|
8521
|
+
expect(method.postTipMessage).not.toHaveBeenCalled();
|
|
8522
|
+
expect(method.postProgressMessage).not.toHaveBeenCalled();
|
|
8476
8523
|
});
|
|
8477
8524
|
|
|
8478
8525
|
test('sends an empty Protocol V2 firmware install request without waiting for its response', async () => {
|
|
@@ -8490,7 +8537,10 @@ describe('Protocol V2 firmware update targets', () => {
|
|
|
8490
8537
|
|
|
8491
8538
|
(method as any).device = stubDevice({
|
|
8492
8539
|
getCommands: () => ({ typedCall, call }),
|
|
8540
|
+
createProtocolV2UiPhaseMetadata: jest.fn().mockReturnValue(undefined),
|
|
8541
|
+
toMessageObject: jest.fn().mockReturnValue({ connectId: 'pro2' }),
|
|
8493
8542
|
});
|
|
8543
|
+
method.postMessage = jest.fn();
|
|
8494
8544
|
method.postProgressMessage = jest.fn();
|
|
8495
8545
|
method.postTipMessage = jest.fn();
|
|
8496
8546
|
|
|
@@ -8504,7 +8554,7 @@ describe('Protocol V2 firmware update targets', () => {
|
|
|
8504
8554
|
{},
|
|
8505
8555
|
{ returnAfterWrite: true }
|
|
8506
8556
|
);
|
|
8507
|
-
expect(method.postTipMessage).
|
|
8557
|
+
expect(method.postTipMessage).not.toHaveBeenCalled();
|
|
8508
8558
|
});
|
|
8509
8559
|
});
|
|
8510
8560
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CheckAllFirmwareRelease.d.ts","sourceRoot":"","sources":["../../src/api/CheckAllFirmwareRelease.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAgC1C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,EACV,kBAAkB,EAElB,kCAAkC,EAClC,+BAA+B,EAChC,MAAM,sCAAsC,CAAC;AAC9C,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAC1E,OAAO,KAAK,EACV,oBAAoB,EACpB,mBAAmB,EACnB,oBAAoB,EAGrB,MAAM,UAAU,CAAC;AAgIlB,MAAM,MAAM,6BAA6B,GAAG;IAC1C,YAAY,EAAE,aAAa,CAAC;IAC5B,MAAM,EAAE,+BAA+B,CAAC;IACxC,UAAU,EAAE,OAAO,CAAC;IACpB,QAAQ,EAAE,OAAO,CAAC;IAClB,eAAe,EAAE,mBAAmB,CAAC;IACrC,UAAU,EAAE,kCAAkC,EAAE,CAAC;IACjD,eAAe,EAAE,sBAAsB,EAAE,CAAC;IAC1C,OAAO,EAAE,oBAAoB,GAAG,SAAS,CAAC;CAC3C,CAAC;AAEF,wBAAgB,8BAA8B,CAAC,EAC7C,eAAe,EACf,mBAAwB,EACxB,iBAAyB,EACzB,mBAAwB,EACxB,YAAY,EACZ,OAAO,EACP,UAAU,GACX,EAAE;IACD,eAAe,EAAE,mBAAmB,CAAC;IACrC,mBAAmB,CAAC,EAAE,OAAO,CAAC,oBAAoB,CAAC,CAAC;IACpD,iBAAiB,CAAC,E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AAwB,EACxB,YAAY,EACZ,OAAO,EACP,UAAU,GACX,EAAE;IACD,eAAe,EAAE,mBAAmB,CAAC;IACrC,mBAAmB,CAAC,EAAE,OAAO,CAAC,oBAAoB,CAAC,CAAC;IACpD,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,mBAAmB,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC;IAC9D,YAAY,EAAE,aAAa,CAAC;IAC5B,OAAO,EAAE,oBAAoB,GAAG,SAAS,CAAC;IAC1C,UAAU,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;CAC7B,GAAG,6BAA6B,CAiFhC;AAID,MAAM,CAAC,OAAO,OAAO,uBAAwB,SAAQ,UAAU;IAC7D,qBAAqB;IAIrB,IAAI;IAME,GAAG;YAuFK,aAAa;CAyH5B"}
|
|
@@ -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;AAyBlG,OAAO,EAAE,wBAAwB,EAAE,MAAM,qCAAqC,CAAC;AAkC/E,OAAO,KAAK,EAEV,sBAAsB,EAEvB,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"FirmwareUpdateV4.d.ts","sourceRoot":"","sources":["../../src/api/FirmwareUpdateV4.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAkD,MAAM,qBAAqB,CAAC;AAyBlG,OAAO,EAAE,wBAAwB,EAAE,MAAM,qCAAqC,CAAC;AAkC/E,OAAO,KAAK,EAEV,sBAAsB,EAEvB,MAAM,6BAA6B,CAAC;AAoFrC,wBAAgB,wCAAwC,CACtD,UAAU,EAAE,WAAW,GAAG,MAAM,GAAG,SAAS,EAC5C,MAAM,EAAE,sBAAsB,EAC9B,0BAA0B,U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7F,MAAM,MAAM,6BAA6B,GAAG;IAC1C,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,WAAW,CAAC;CACrB,CAAC;
|
|
1
|
+
{"version":3,"file":"FirmwarePreparedResourceArchive.d.ts","sourceRoot":"","sources":["../../../src/api/firmware/FirmwarePreparedResourceArchive.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAC7E,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,4CAA4C,CAAC;AAY7F,MAAM,MAAM,6BAA6B,GAAG;IAC1C,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,WAAW,CAAC;CACrB,CAAC;AAmCF,eAAO,MAAM,mCAAmC;kBAIhC,0BAA0B;YAChC,sBAAsB,GAAG,SAAS;MACxC,QAAQ,6BAA6B,EAAE,CAkI1C,CAAC"}
|
|
@@ -35,6 +35,7 @@ export declare const getBinary: ({ features, updateType, version, isUpdateBootlo
|
|
|
35
35
|
upgradeType?: string | undefined;
|
|
36
36
|
components?: Record<string, import("../../types").IProtocolV2FirmwareComponent> | undefined;
|
|
37
37
|
installOrder?: string[] | undefined;
|
|
38
|
+
resources?: import("../../types").IProtocolV2Resources | undefined;
|
|
38
39
|
bootloaderChangelog?: {
|
|
39
40
|
"zh-CN": string;
|
|
40
41
|
"en-US": string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getBinary.d.ts","sourceRoot":"","sources":["../../../src/api/firmware/getBinary.ts"],"names":[],"mappings":";AAQA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGzD,MAAM,MAAM,cAAc,GAAG,WAAW,GAAG,MAAM,CAAC;AAElD,MAAM,WAAW,YAAY;IAC3B,QAAQ,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areType } from '@onekeyfe/hd-shared';
|
|
2
|
-
import type { AssetsMap, ConnectSettings, DeviceTypeMap, Features, IDeviceBLEFirmwareStatus, IDeviceFirmwareStatus, ITransportStatus, IVersionArray } from '../types';
|
|
2
|
+
import type { AssetsMap, ConnectSettings, DeviceTypeMap, Features, IDeviceBLEFirmwareStatus, IDeviceFirmwareStatus, IFirmwareReleaseInfo, ITransportStatus, IVersionArray } from '../types';
|
|
3
3
|
export declare const FIRMWARE_FIELDS: readonly ["firmware", "firmware-v1", "firmware-v2", "firmware-v8", "firmware-btc-v8"];
|
|
4
4
|
export type IFirmwareField = (typeof FIRMWARE_FIELDS)[number];
|
|
5
5
|
export type ProtocolV1MessageSchema = 'v1CurrentSchema' | 'v1LegacySchema';
|
|
@@ -30,7 +30,7 @@ export default class DataManager {
|
|
|
30
30
|
"zh-CN": string;
|
|
31
31
|
"en-US": string;
|
|
32
32
|
}[];
|
|
33
|
-
static getFirmwareLatestRelease: (features: Features, firmwareType: EFirmwareType) =>
|
|
33
|
+
static getFirmwareLatestRelease: (features: Features, firmwareType: EFirmwareType) => IFirmwareReleaseInfo | undefined;
|
|
34
34
|
static getBLEFirmwareStatus: (features: Features) => IDeviceBLEFirmwareStatus;
|
|
35
35
|
static getBleFirmwareChangelog: (features: Features) => {
|
|
36
36
|
"zh-CN": string;
|
|
@@ -43,6 +43,7 @@ export default class DataManager {
|
|
|
43
43
|
"en-US": string;
|
|
44
44
|
} | undefined;
|
|
45
45
|
private static enrichFirmwareReleaseInfo;
|
|
46
|
+
private static enrichProtocolV2FirmwareReleaseInfo;
|
|
46
47
|
static load(settings: ConnectSettings): Promise<boolean>;
|
|
47
48
|
private static applyRemoteConfig;
|
|
48
49
|
static updateEnv(newEnv: ConnectSettings['env']): void;
|
|
@@ -51,7 +52,7 @@ export default class DataManager {
|
|
|
51
52
|
requireResources?: boolean;
|
|
52
53
|
resourceDeviceType?: EDeviceType.Pro2 | EDeviceType.Neo;
|
|
53
54
|
}): Promise<void>;
|
|
54
|
-
static getProtocolV2ResourceSource(
|
|
55
|
+
static getProtocolV2ResourceSource(release: IFirmwareReleaseInfo | undefined): import("../types").IProtocolV2ResourceSource | undefined;
|
|
55
56
|
static getProtobufMessages(schema?: ProtobufMessageSchema): JSON;
|
|
56
57
|
static getSettings(key?: undefined): ConnectSettings;
|
|
57
58
|
static getSettings<T extends keyof ConnectSettings>(key: T): ConnectSettings[T];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataManager.d.ts","sourceRoot":"","sources":["../../src/data-manager/DataManager.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,aAAa,EAA6B,MAAM,qBAAqB,CAAC;AAmB5F,OAAO,KAAK,EACV,SAAS,EACT,eAAe,EACf,aAAa,EACb,QAAQ,EACR,wBAAwB,EACxB,qBAAqB,
|
|
1
|
+
{"version":3,"file":"DataManager.d.ts","sourceRoot":"","sources":["../../src/data-manager/DataManager.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,aAAa,EAA6B,MAAM,qBAAqB,CAAC;AAmB5F,OAAO,KAAK,EACV,SAAS,EACT,eAAe,EACf,aAAa,EACb,QAAQ,EACR,wBAAwB,EACxB,qBAAqB,EACrB,oBAAoB,EACpB,gBAAgB,EAChB,aAAa,EAEd,MAAM,UAAU,CAAC;AAMlB,eAAO,MAAM,eAAe,uFAMlB,CAAC;AAEX,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC;AAE9D,MAAM,MAAM,uBAAuB,GAAG,iBAAiB,GAAG,gBAAgB,CAAC;AAC3E,MAAM,MAAM,qBAAqB,GAAG,uBAAuB,GAAG,UAAU,CAAC;AAsBzE,MAAM,CAAC,OAAO,OAAO,WAAW;IAC9B,MAAM,CAAC,SAAS,EAAE,aAAa,GAAG;QAChC,CAAC,CAAC,EAAE,MAAM,GAAG,WAAW,CAAC,aAAa,CAAC,MAAM,aAAa,CAAC,C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4CxC,OAAO,CAAC,MAAM,CAAC,mCAAmC;WA+BrC,IAAI,CAAC,QAAQ,EAAE,eAAe,GAAG,OAAO,CAAC,OAAO,CAAC;IA+D9D,OAAO,CAAC,MAAM,CAAC,iBAAiB;IA2BhC,MAAM,CAAC,SAAS,CAAC,MAAM,EAAE,eAAe,CAAC,KAAK,CAAC;WAalC,kBAAkB;WAUlB,eAAe,CAAC,EAC3B,gBAAwB,EACxB,kBAAqC,GACtC,GAAE;QACD,gBAAgB,CAAC,EAAE,OAAO,CAAC;QAC3B,kBAAkB,CAAC,EAAE,WAAW,CAAC,IAAI,GAAG,WAAW,CAAC,GAAG,CAAC;KACpD,GAAG,OAAO,CAAC,IAAI,CAAC;IAyCtB,MAAM,CAAC,2BAA2B,CAAC,OAAO,EAAE,oBAAoB,GAAG,SAAS;IAI5E,MAAM,CAAC,mBAAmB,CAAC,MAAM,GAAE,qBAAyC,GAAG,IAAI;IAInF,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE,SAAS,GAAG,eAAe;IAEpD,MAAM,CAAC,WAAW,CAAC,CAAC,SAAS,MAAM,eAAe,EAAE,GAAG,EAAE,CAAC,GAAG,eAAe,CAAC,CAAC,CAAC;IAU/E,MAAM,CAAC,YAAY,QAAS,eAAe,CAAC,KAAK,CAAC,aAC0B;IAG5E,MAAM,CAAC,eAAe,QAAS,eAAe,CAAC,KAAK,CAAC,aAA8B;IAGnF,MAAM,CAAC,eAAe,QAAS,eAAe,CAAC,KAAK,CAAC,aAAsB;CAC5E"}
|
package/dist/index.d.ts
CHANGED
|
@@ -259,6 +259,8 @@ type IFirmwareReleaseInfo = {
|
|
|
259
259
|
upgradeType?: 'payload-package-set' | string;
|
|
260
260
|
components?: Record<string, IProtocolV2FirmwareComponent>;
|
|
261
261
|
installOrder?: string[];
|
|
262
|
+
/** Protocol V2 resources matched to this firmware release. */
|
|
263
|
+
resources?: IProtocolV2Resources;
|
|
262
264
|
bootloaderChangelog?: {
|
|
263
265
|
[k in ILocale]: string;
|
|
264
266
|
};
|
|
@@ -293,8 +295,6 @@ type IDeviceReleaseInfo = {
|
|
|
293
295
|
'firmware-v8'?: IFirmwareReleaseInfo[];
|
|
294
296
|
'firmware-btc-v8'?: IFirmwareReleaseInfo[];
|
|
295
297
|
ble?: IBLEFirmwareReleaseInfo[];
|
|
296
|
-
/** Independent Protocol V2 resource release configuration. */
|
|
297
|
-
resources?: IProtocolV2Resources;
|
|
298
298
|
};
|
|
299
299
|
type DeviceTypeMap = {
|
|
300
300
|
[k in Exclude<IKnownDevice, 'neo'>]: IDeviceReleaseInfo;
|
|
@@ -4725,6 +4725,7 @@ declare class DataManager {
|
|
|
4725
4725
|
"en-US": string;
|
|
4726
4726
|
} | undefined;
|
|
4727
4727
|
private static enrichFirmwareReleaseInfo;
|
|
4728
|
+
private static enrichProtocolV2FirmwareReleaseInfo;
|
|
4728
4729
|
static load(settings: ConnectSettings): Promise<boolean>;
|
|
4729
4730
|
private static applyRemoteConfig;
|
|
4730
4731
|
static updateEnv(newEnv: ConnectSettings['env']): void;
|
|
@@ -4734,7 +4735,7 @@ declare class DataManager {
|
|
|
4734
4735
|
requireResources?: boolean;
|
|
4735
4736
|
resourceDeviceType?: EDeviceType.Pro2 | EDeviceType.Neo;
|
|
4736
4737
|
}): Promise<void>;
|
|
4737
|
-
static getProtocolV2ResourceSource(
|
|
4738
|
+
static getProtocolV2ResourceSource(release: IFirmwareReleaseInfo | undefined): IProtocolV2ResourceSource | undefined;
|
|
4738
4739
|
static getProtobufMessages(schema?: ProtobufMessageSchema): JSON;
|
|
4739
4740
|
static getSettings(key?: undefined): ConnectSettings;
|
|
4740
4741
|
static getSettings<T extends keyof ConnectSettings>(key: T): ConnectSettings[T];
|
package/dist/index.js
CHANGED
|
@@ -40850,6 +40850,27 @@ class DataManager {
|
|
|
40850
40850
|
});
|
|
40851
40851
|
return enrichedData;
|
|
40852
40852
|
}
|
|
40853
|
+
static enrichProtocolV2FirmwareReleaseInfo(deviceData, onResourcesError) {
|
|
40854
|
+
const enrichedData = this.enrichFirmwareReleaseInfo(deviceData);
|
|
40855
|
+
const releases = enrichedData['firmware-v1'];
|
|
40856
|
+
if (!Array.isArray(releases)) {
|
|
40857
|
+
return enrichedData;
|
|
40858
|
+
}
|
|
40859
|
+
const latestRelease = findLatestRelease(releases);
|
|
40860
|
+
return Object.assign(Object.assign({}, enrichedData), { 'firmware-v1': releases.map(release => {
|
|
40861
|
+
const { resources: rawResources } = release, releaseWithoutResources = __rest(release, ["resources"]);
|
|
40862
|
+
try {
|
|
40863
|
+
const resources = parseProtocolV2Resources(rawResources);
|
|
40864
|
+
return Object.assign(Object.assign({}, releaseWithoutResources), (resources ? { resources } : undefined));
|
|
40865
|
+
}
|
|
40866
|
+
catch (error) {
|
|
40867
|
+
if (release === latestRelease) {
|
|
40868
|
+
onResourcesError(error instanceof Error ? error : new Error(String(error)));
|
|
40869
|
+
}
|
|
40870
|
+
return releaseWithoutResources;
|
|
40871
|
+
}
|
|
40872
|
+
}) });
|
|
40873
|
+
}
|
|
40853
40874
|
static load(settings) {
|
|
40854
40875
|
var _b;
|
|
40855
40876
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -40911,29 +40932,14 @@ class DataManager {
|
|
|
40911
40932
|
});
|
|
40912
40933
|
}
|
|
40913
40934
|
static applyRemoteConfig(data) {
|
|
40914
|
-
|
|
40915
|
-
|
|
40916
|
-
|
|
40917
|
-
|
|
40918
|
-
|
|
40919
|
-
|
|
40920
|
-
|
|
40921
|
-
|
|
40922
|
-
error instanceof Error ? error : new Error(String(error));
|
|
40923
|
-
Log$k.warn('[DataConfig] Ignoring invalid Pro2 resources config:', error);
|
|
40924
|
-
}
|
|
40925
|
-
try {
|
|
40926
|
-
neoResources = parseProtocolV2Resources((_c = data.neo) === null || _c === void 0 ? void 0 : _c.resources);
|
|
40927
|
-
}
|
|
40928
|
-
catch (error) {
|
|
40929
|
-
this.protocolV2NeoResourcesConfigError =
|
|
40930
|
-
error instanceof Error ? error : new Error(String(error));
|
|
40931
|
-
Log$k.warn('[DataConfig] Ignoring invalid Neo resources config:', error);
|
|
40932
|
-
}
|
|
40933
|
-
const enrichedPro2Config = this.enrichFirmwareReleaseInfo(data.pro2);
|
|
40934
|
-
const enrichedNeoConfig = this.enrichFirmwareReleaseInfo(data.neo);
|
|
40935
|
-
const pro2Config = __rest(enrichedPro2Config, ["resources"]);
|
|
40936
|
-
const neoConfig = __rest(enrichedNeoConfig, ["resources"]);
|
|
40935
|
+
const pro2Config = this.enrichProtocolV2FirmwareReleaseInfo(data.pro2, error => {
|
|
40936
|
+
this.protocolV2ResourcesConfigError = error;
|
|
40937
|
+
Log$k.warn('[DataConfig] Ignoring invalid Pro2 release resources config:', error);
|
|
40938
|
+
});
|
|
40939
|
+
const neoConfig = this.enrichProtocolV2FirmwareReleaseInfo(data.neo, error => {
|
|
40940
|
+
this.protocolV2NeoResourcesConfigError = error;
|
|
40941
|
+
Log$k.warn('[DataConfig] Ignoring invalid Neo release resources config:', error);
|
|
40942
|
+
});
|
|
40937
40943
|
this.deviceMap = {
|
|
40938
40944
|
[hdShared.EDeviceType.Classic]: this.enrichFirmwareReleaseInfo(data.classic),
|
|
40939
40945
|
[hdShared.EDeviceType.Classic1s]: this.enrichFirmwareReleaseInfo(data.classic1s),
|
|
@@ -40941,8 +40947,8 @@ class DataManager {
|
|
|
40941
40947
|
[hdShared.EDeviceType.Mini]: this.enrichFirmwareReleaseInfo(data.mini),
|
|
40942
40948
|
[hdShared.EDeviceType.Touch]: this.enrichFirmwareReleaseInfo(data.touch),
|
|
40943
40949
|
[hdShared.EDeviceType.Pro]: this.enrichFirmwareReleaseInfo(data.pro),
|
|
40944
|
-
[hdShared.EDeviceType.Pro2]:
|
|
40945
|
-
[hdShared.EDeviceType.Neo]:
|
|
40950
|
+
[hdShared.EDeviceType.Pro2]: pro2Config,
|
|
40951
|
+
[hdShared.EDeviceType.Neo]: neoConfig,
|
|
40946
40952
|
};
|
|
40947
40953
|
this.assets = {
|
|
40948
40954
|
bridge: data.bridge,
|
|
@@ -40996,9 +41002,9 @@ class DataManager {
|
|
|
40996
41002
|
this.lastCheckTimestamp = getTimeStamp();
|
|
40997
41003
|
});
|
|
40998
41004
|
}
|
|
40999
|
-
static getProtocolV2ResourceSource(
|
|
41000
|
-
var _b
|
|
41001
|
-
return (
|
|
41005
|
+
static getProtocolV2ResourceSource(release) {
|
|
41006
|
+
var _b;
|
|
41007
|
+
return (_b = release === null || release === void 0 ? void 0 : release.resources) === null || _b === void 0 ? void 0 : _b.source;
|
|
41002
41008
|
}
|
|
41003
41009
|
static getProtobufMessages(schema = 'v1CurrentSchema') {
|
|
41004
41010
|
return this.messages[schema];
|
|
@@ -47848,8 +47854,7 @@ class CheckAllFirmwareRelease extends BaseMethod {
|
|
|
47848
47854
|
release,
|
|
47849
47855
|
deviceType: state.identity.deviceType,
|
|
47850
47856
|
});
|
|
47851
|
-
const
|
|
47852
|
-
const resourceSource = DataManager.getProtocolV2ResourceSource(resourceDeviceType);
|
|
47857
|
+
const resourceSource = DataManager.getProtocolV2ResourceSource(release);
|
|
47853
47858
|
const resourceStatus = 'unknown';
|
|
47854
47859
|
const detectedComponentTargets = validatedForceUpdateTargets.includes('firmware')
|
|
47855
47860
|
? plan.components.flatMap(component => component.updateTarget ? [component.updateTarget] : [])
|
|
@@ -50245,6 +50250,9 @@ const readVerifiedPreparedResourceArchive = ({ preparedPlan, reader, }) => __awa
|
|
|
50245
50250
|
}
|
|
50246
50251
|
return [];
|
|
50247
50252
|
}
|
|
50253
|
+
if (!reader) {
|
|
50254
|
+
return resourceArchiveError('Firmware artifact reader is required for prepared resource archives', 'FirmwareArtifactReaderInvalid');
|
|
50255
|
+
}
|
|
50248
50256
|
if (resourceArtifacts.length !== 1) {
|
|
50249
50257
|
return resourceArchiveError('Firmware prepared plan must contain exactly one materialized resource ZIP', 'FirmwareArtifactsNotPrepared');
|
|
50250
50258
|
}
|
|
@@ -52235,7 +52243,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
52235
52243
|
}));
|
|
52236
52244
|
}
|
|
52237
52245
|
if (wantsResources) {
|
|
52238
|
-
this.params.resourceArchiveBinary = yield this.downloadRemoteProtocolV2ResourceArchive(deviceFeatures);
|
|
52246
|
+
this.params.resourceArchiveBinary = yield this.downloadRemoteProtocolV2ResourceArchive(deviceFeatures, firmwareType);
|
|
52239
52247
|
resourceMemoryHost = yield this.prepareProtocolV2LocalMemoryHost({
|
|
52240
52248
|
features: deviceFeatures,
|
|
52241
52249
|
firmwareType,
|
|
@@ -52933,13 +52941,14 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
52933
52941
|
return Object.assign(Object.assign({}, target), { binary });
|
|
52934
52942
|
});
|
|
52935
52943
|
}
|
|
52936
|
-
downloadRemoteProtocolV2ResourceArchive(features) {
|
|
52944
|
+
downloadRemoteProtocolV2ResourceArchive(features, firmwareType) {
|
|
52937
52945
|
return __awaiter(this, void 0, void 0, function* () {
|
|
52938
52946
|
const deviceType = getDeviceType(features);
|
|
52939
52947
|
if (deviceType !== hdShared.EDeviceType.Pro2 && deviceType !== hdShared.EDeviceType.Neo) {
|
|
52940
52948
|
throw hdShared.ERRORS.TypedError(hdShared.HardwareErrorCode.RuntimeError, 'Protocol V2 resource archive requires a Pro2 or Neo device');
|
|
52941
52949
|
}
|
|
52942
|
-
const
|
|
52950
|
+
const release = DataManager.getFirmwareLatestRelease(features, firmwareType);
|
|
52951
|
+
const source = DataManager.getProtocolV2ResourceSource(release);
|
|
52943
52952
|
const expectedSha256 = normalizeProtocolV2Hex(source === null || source === void 0 ? void 0 : source.archiveSha256);
|
|
52944
52953
|
if (!(source === null || source === void 0 ? void 0 : source.archiveUrl) ||
|
|
52945
52954
|
!Number.isSafeInteger(source.archiveSize) ||
|
|
@@ -53270,6 +53279,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53270
53279
|
});
|
|
53271
53280
|
}
|
|
53272
53281
|
executeProtocolV2TransferPhase({ installSources, resourceSources, }) {
|
|
53282
|
+
var _a;
|
|
53273
53283
|
return __awaiter(this, void 0, void 0, function* () {
|
|
53274
53284
|
let totalSize = installSources.reduce((total, item) => total + item.source.size, 0);
|
|
53275
53285
|
const resourcesToSync = [];
|
|
@@ -53324,9 +53334,14 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53324
53334
|
target_id: item.targetId,
|
|
53325
53335
|
path: item.path,
|
|
53326
53336
|
}));
|
|
53327
|
-
|
|
53328
|
-
|
|
53329
|
-
|
|
53337
|
+
try {
|
|
53338
|
+
yield this.protocolV2StartFirmwareUpdate({ targets });
|
|
53339
|
+
yield hdShared.wait(PROTOCOL_V2_INSTALL_STATUS_INITIAL_DELAY);
|
|
53340
|
+
yield this.waitForProtocolV2FirmwareUpdateComplete(targets, true);
|
|
53341
|
+
}
|
|
53342
|
+
finally {
|
|
53343
|
+
(_a = this.device) === null || _a === void 0 ? void 0 : _a.clearCancelableAction();
|
|
53344
|
+
}
|
|
53330
53345
|
});
|
|
53331
53346
|
}
|
|
53332
53347
|
protocolV2SourceUpdateProcess({ source, filePath, processedSize, totalSize, }) {
|
|
@@ -53500,7 +53515,7 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53500
53515
|
const expectedPaths = new Map(targets.map(target => [target.target_id, target.path]));
|
|
53501
53516
|
const startTime = Date.now();
|
|
53502
53517
|
let lastError;
|
|
53503
|
-
let shouldReconnect =
|
|
53518
|
+
let shouldReconnect = false;
|
|
53504
53519
|
let deviceInfo;
|
|
53505
53520
|
let missingTargetStatusSince;
|
|
53506
53521
|
let missingTargetStatusKey;
|
|
@@ -53536,12 +53551,13 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53536
53551
|
const statusTargets = statusResponse.type === 'DeviceFirmwareUpdateStatus'
|
|
53537
53552
|
? ((_a = statusResponse.message.records) !== null && _a !== void 0 ? _a : [])
|
|
53538
53553
|
: [];
|
|
53539
|
-
|
|
53554
|
+
const hasInProgressTarget = statusTargets.some(target => {
|
|
53540
53555
|
const targetId = normalizeProtocolV2TargetId(target.target_id);
|
|
53541
53556
|
return (targetId !== undefined &&
|
|
53542
53557
|
expectedTargetIds.has(targetId) &&
|
|
53543
53558
|
isProtocolV2TargetStatusInProgress(target.status));
|
|
53544
|
-
})
|
|
53559
|
+
});
|
|
53560
|
+
if (hasInProgressTarget) {
|
|
53545
53561
|
currentInstallStatusObserved = true;
|
|
53546
53562
|
}
|
|
53547
53563
|
const hasMatchingTargetStatus = statusTargets.some(target => {
|
|
@@ -53874,9 +53890,10 @@ class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod {
|
|
|
53874
53890
|
this.protocolV2LastRuntimeProbeFeatures = undefined;
|
|
53875
53891
|
const commands = this.device.getCommands();
|
|
53876
53892
|
yield commands.typedCall('DeviceFirmwareUpdateStage', 'Success', { targets });
|
|
53893
|
+
this.device.setCancelableAction(() => commands.cancelDevice());
|
|
53894
|
+
const interaction = this.device.createProtocolV2UiPhaseMetadata('button', 'start');
|
|
53895
|
+
this.postMessage(createUiMessage(UI_REQUEST.REQUEST_BUTTON, Object.assign({ device: this.device.toMessageObject(), source: 'method-lifecycle', reason: 'firmware-update', completion: 'operation-completed', deviceOnly: true, operation: this.name }, (interaction ? { interaction } : {}))));
|
|
53877
53896
|
yield commands.call('DeviceFirmwareUpdateRequest', {}, { returnAfterWrite: true });
|
|
53878
|
-
this.postTipMessage(exports.FirmwareUpdateTipMessage.FirmwareUpdating);
|
|
53879
|
-
this.postProgressMessage(0, 'installingFirmware');
|
|
53880
53897
|
});
|
|
53881
53898
|
}
|
|
53882
53899
|
protocolV2Reboot(rebootType) {
|
package/dist/types/settings.d.ts
CHANGED
|
@@ -76,6 +76,7 @@ export type IFirmwareReleaseInfo = {
|
|
|
76
76
|
upgradeType?: 'payload-package-set' | string;
|
|
77
77
|
components?: Record<string, IProtocolV2FirmwareComponent>;
|
|
78
78
|
installOrder?: string[];
|
|
79
|
+
resources?: IProtocolV2Resources;
|
|
79
80
|
bootloaderChangelog?: {
|
|
80
81
|
[k in ILocale]: string;
|
|
81
82
|
};
|
|
@@ -106,7 +107,6 @@ type IDeviceReleaseInfo = {
|
|
|
106
107
|
'firmware-v8'?: IFirmwareReleaseInfo[];
|
|
107
108
|
'firmware-btc-v8'?: IFirmwareReleaseInfo[];
|
|
108
109
|
ble?: IBLEFirmwareReleaseInfo[];
|
|
109
|
-
resources?: IProtocolV2Resources;
|
|
110
110
|
};
|
|
111
111
|
export type DeviceTypeMap = {
|
|
112
112
|
[k in Exclude<IKnownDevice, 'neo'>]: IDeviceReleaseInfo;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../../src/types/settings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAE5C,MAAM,MAAM,YAAY,GACpB,MAAM,GACN,KAAK,GACL,cAAc,GACd,UAAU,GACV,cAAc,GACd,QAAQ,GACR,gBAAgB,GAChB,iBAAiB,GACjB,UAAU,GACV,UAAU,GACV,UAAU,CAAC;AACf,MAAM,MAAM,eAAe,GAAG;IAC5B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,OAAO,CAAC;IACrB,gBAAgB,CAAC,EAAE,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,WAAW,EAAE,SAAS,CAAC,CAAC;AACpD,KAAK,kBAAkB,GAAG;IACxB,QAAQ,CAAC,EAAE,oBAAoB,EAAE,CAAC;IAElC,aAAa,CAAC,EAAE,oBAAoB,EAAE,CAAC;IACvC,aAAa,CAAC,EAAE,oBAAoB,EAAE,CAAC;IACvC,aAAa,CAAC,EAAE,oBAAoB,EAAE,CAAC;IACvC,iBAAiB,CAAC,EAAE,oBAAoB,EAAE,CAAC;IAC3C,GAAG,CAAC,EAAE,uBAAuB,EAAE,CAAC;CACjC,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;KACzB,CAAC,IAAI,OAAO,CAAC,YAAY,EAAE,KAAK,CAAC,GAAG,kBAAkB;CACxD,GAAG;IAEF,GAAG,CAAC,EAAE,kBAAkB,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACtB,MAAM,EAAE;QACN,OAAO,EAAE,aAAa,CAAC;QACvB,UAAU,EAAE,MAAM,CAAC;QACnB,UAAU,EAAE,MAAM,CAAC;QACnB,UAAU,EAAE,MAAM,CAAC;QACnB,UAAU,EAAE,MAAM,CAAC;QACnB,GAAG,EAAE,MAAM,CAAC;QACZ,GAAG,EAAE,MAAM,CAAC;QACZ,YAAY,EAAE,MAAM,CAAC;QACrB,SAAS,EAAE;aACR,CAAC,IAAI,OAAO,GAAG,MAAM;SACvB,CAAC;KACH,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,MAAM,EAAE,SAAS,CAAC,QAAQ,CAAC,CAAC;CAC7B,GAAG,aAAa,CAAC"}
|
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.129",
|
|
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.129",
|
|
29
|
+
"@onekeyfe/hd-transport": "1.2.0-alpha.129",
|
|
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": "d996758fef2d61a868b1989efcce1f04c8ef5e22"
|
|
50
50
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { HardwareError } from '@onekeyfe/hd-shared';
|
|
2
2
|
import semver from 'semver';
|
|
3
3
|
|
|
4
4
|
import { BaseMethod } from './BaseMethod';
|
|
@@ -411,9 +411,7 @@ export default class CheckAllFirmwareRelease extends BaseMethod {
|
|
|
411
411
|
release,
|
|
412
412
|
deviceType: state.identity.deviceType,
|
|
413
413
|
});
|
|
414
|
-
const
|
|
415
|
-
state.identity.deviceType === 'neo' ? EDeviceType.Neo : EDeviceType.Pro2;
|
|
416
|
-
const resourceSource = DataManager.getProtocolV2ResourceSource(resourceDeviceType);
|
|
414
|
+
const resourceSource = DataManager.getProtocolV2ResourceSource(release);
|
|
417
415
|
const resourceStatus = 'unknown' as const;
|
|
418
416
|
const detectedComponentTargets = validatedForceUpdateTargets.includes('firmware')
|
|
419
417
|
? plan.components.flatMap(component =>
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
} from '@onekeyfe/hd-transport';
|
|
10
10
|
import { sha256 } from '@noble/hashes/sha256';
|
|
11
11
|
|
|
12
|
-
import { FirmwareUpdateTipMessage, UI_REQUEST } from '../events/ui-request';
|
|
12
|
+
import { FirmwareUpdateTipMessage, UI_REQUEST, createUiMessage } from '../events/ui-request';
|
|
13
13
|
import { validateParams } from './helpers/paramsValidator';
|
|
14
14
|
import {
|
|
15
15
|
LoggerNames,
|
|
@@ -71,6 +71,7 @@ import type {
|
|
|
71
71
|
IProtocolV2FirmwareComponent,
|
|
72
72
|
IProtocolV2ResourceManifestFile,
|
|
73
73
|
IVersionArray,
|
|
74
|
+
KnownDevice,
|
|
74
75
|
} from '../types';
|
|
75
76
|
import type { FirmwareByteSource } from './firmware/FirmwareArtifactSource';
|
|
76
77
|
import type {
|
|
@@ -914,7 +915,8 @@ export default class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod<FirmwareU
|
|
|
914
915
|
}
|
|
915
916
|
if (wantsResources) {
|
|
916
917
|
this.params.resourceArchiveBinary = await this.downloadRemoteProtocolV2ResourceArchive(
|
|
917
|
-
deviceFeatures
|
|
918
|
+
deviceFeatures,
|
|
919
|
+
firmwareType
|
|
918
920
|
);
|
|
919
921
|
resourceMemoryHost = await this.prepareProtocolV2LocalMemoryHost({
|
|
920
922
|
features: deviceFeatures,
|
|
@@ -1879,7 +1881,10 @@ export default class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod<FirmwareU
|
|
|
1879
1881
|
};
|
|
1880
1882
|
}
|
|
1881
1883
|
|
|
1882
|
-
private async downloadRemoteProtocolV2ResourceArchive(
|
|
1884
|
+
private async downloadRemoteProtocolV2ResourceArchive(
|
|
1885
|
+
features: Features,
|
|
1886
|
+
firmwareType: EFirmwareType
|
|
1887
|
+
): Promise<ArrayBuffer> {
|
|
1883
1888
|
const deviceType = getDeviceType(features);
|
|
1884
1889
|
if (deviceType !== EDeviceType.Pro2 && deviceType !== EDeviceType.Neo) {
|
|
1885
1890
|
throw ERRORS.TypedError(
|
|
@@ -1887,7 +1892,8 @@ export default class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod<FirmwareU
|
|
|
1887
1892
|
'Protocol V2 resource archive requires a Pro2 or Neo device'
|
|
1888
1893
|
);
|
|
1889
1894
|
}
|
|
1890
|
-
const
|
|
1895
|
+
const release = DataManager.getFirmwareLatestRelease(features, firmwareType);
|
|
1896
|
+
const source = DataManager.getProtocolV2ResourceSource(release);
|
|
1891
1897
|
const expectedSha256 = normalizeProtocolV2Hex(source?.archiveSha256);
|
|
1892
1898
|
if (
|
|
1893
1899
|
!source?.archiveUrl ||
|
|
@@ -2375,9 +2381,13 @@ export default class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod<FirmwareU
|
|
|
2375
2381
|
target_id: item.targetId,
|
|
2376
2382
|
path: item.path,
|
|
2377
2383
|
}));
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2384
|
+
try {
|
|
2385
|
+
await this.protocolV2StartFirmwareUpdate({ targets });
|
|
2386
|
+
await wait(PROTOCOL_V2_INSTALL_STATUS_INITIAL_DELAY);
|
|
2387
|
+
await this.waitForProtocolV2FirmwareUpdateComplete(targets, true);
|
|
2388
|
+
} finally {
|
|
2389
|
+
this.device?.clearCancelableAction();
|
|
2390
|
+
}
|
|
2381
2391
|
}
|
|
2382
2392
|
|
|
2383
2393
|
private async protocolV2SourceUpdateProcess({
|
|
@@ -2637,7 +2647,9 @@ export default class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod<FirmwareU
|
|
|
2637
2647
|
const expectedPaths = new Map(targets.map(target => [target.target_id, target.path]));
|
|
2638
2648
|
const startTime = Date.now();
|
|
2639
2649
|
let lastError: unknown;
|
|
2640
|
-
|
|
2650
|
+
// DeviceFirmwareUpdateRequest leaves the current loader link usable for status polling.
|
|
2651
|
+
// Reconnecting here probes DeviceInfo, which loaders reject while installation is active.
|
|
2652
|
+
let shouldReconnect = false;
|
|
2641
2653
|
let deviceInfo: ProtocolV2DeviceInfo | undefined;
|
|
2642
2654
|
let missingTargetStatusSince: number | undefined;
|
|
2643
2655
|
let missingTargetStatusKey: string | undefined;
|
|
@@ -2684,16 +2696,15 @@ export default class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod<FirmwareU
|
|
|
2684
2696
|
statusResponse.type === 'DeviceFirmwareUpdateStatus'
|
|
2685
2697
|
? ((statusResponse.message.records ?? []) as ProtocolV2FirmwareUpdateStatusTarget[])
|
|
2686
2698
|
: [];
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
) {
|
|
2699
|
+
const hasInProgressTarget = statusTargets.some(target => {
|
|
2700
|
+
const targetId = normalizeProtocolV2TargetId(target.target_id);
|
|
2701
|
+
return (
|
|
2702
|
+
targetId !== undefined &&
|
|
2703
|
+
expectedTargetIds.has(targetId) &&
|
|
2704
|
+
isProtocolV2TargetStatusInProgress(target.status)
|
|
2705
|
+
);
|
|
2706
|
+
});
|
|
2707
|
+
if (hasInProgressTarget) {
|
|
2697
2708
|
currentInstallStatusObserved = true;
|
|
2698
2709
|
}
|
|
2699
2710
|
const hasMatchingTargetStatus = statusTargets.some(target => {
|
|
@@ -3138,9 +3149,20 @@ export default class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod<FirmwareU
|
|
|
3138
3149
|
this.protocolV2LastRuntimeProbeFeatures = undefined;
|
|
3139
3150
|
const commands = this.device.getCommands();
|
|
3140
3151
|
await commands.typedCall('DeviceFirmwareUpdateStage', 'Success', { targets });
|
|
3152
|
+
this.device.setCancelableAction(() => commands.cancelDevice());
|
|
3153
|
+
const interaction = this.device.createProtocolV2UiPhaseMetadata('button', 'start');
|
|
3154
|
+
this.postMessage(
|
|
3155
|
+
createUiMessage(UI_REQUEST.REQUEST_BUTTON, {
|
|
3156
|
+
device: this.device.toMessageObject() as KnownDevice,
|
|
3157
|
+
source: 'method-lifecycle',
|
|
3158
|
+
reason: 'firmware-update',
|
|
3159
|
+
completion: 'operation-completed',
|
|
3160
|
+
deviceOnly: true,
|
|
3161
|
+
operation: this.name,
|
|
3162
|
+
...(interaction ? { interaction } : {}),
|
|
3163
|
+
})
|
|
3164
|
+
);
|
|
3141
3165
|
await commands.call('DeviceFirmwareUpdateRequest', {}, { returnAfterWrite: true });
|
|
3142
|
-
this.postTipMessage(FirmwareUpdateTipMessage.FirmwareUpdating);
|
|
3143
|
-
this.postProgressMessage(0, 'installingFirmware');
|
|
3144
3166
|
}
|
|
3145
3167
|
|
|
3146
3168
|
private async protocolV2Reboot(rebootType: DeviceRebootType) {
|
|
@@ -26,7 +26,10 @@ export type VerifiedPreparedResourceEntry = {
|
|
|
26
26
|
|
|
27
27
|
const resourceArchiveError = (
|
|
28
28
|
message: string,
|
|
29
|
-
firmwareUpdateCode:
|
|
29
|
+
firmwareUpdateCode:
|
|
30
|
+
| 'FirmwareArtifactsNotPrepared'
|
|
31
|
+
| 'FirmwareArtifactReceiptMismatch'
|
|
32
|
+
| 'FirmwareArtifactReaderInvalid'
|
|
30
33
|
): never => {
|
|
31
34
|
throw ERRORS.TypedError(HardwareErrorCode.RuntimeError, message, { firmwareUpdateCode });
|
|
32
35
|
};
|
|
@@ -73,6 +76,12 @@ export const readVerifiedPreparedResourceArchive = async ({
|
|
|
73
76
|
}
|
|
74
77
|
return [];
|
|
75
78
|
}
|
|
79
|
+
if (!reader) {
|
|
80
|
+
return resourceArchiveError(
|
|
81
|
+
'Firmware artifact reader is required for prepared resource archives',
|
|
82
|
+
'FirmwareArtifactReaderInvalid'
|
|
83
|
+
);
|
|
84
|
+
}
|
|
76
85
|
if (resourceArtifacts.length !== 1) {
|
|
77
86
|
return resourceArchiveError(
|
|
78
87
|
'Firmware prepared plan must contain exactly one materialized resource ZIP',
|
|
@@ -26,7 +26,7 @@ import type {
|
|
|
26
26
|
Features,
|
|
27
27
|
IDeviceBLEFirmwareStatus,
|
|
28
28
|
IDeviceFirmwareStatus,
|
|
29
|
-
|
|
29
|
+
IFirmwareReleaseInfo,
|
|
30
30
|
ITransportStatus,
|
|
31
31
|
IVersionArray,
|
|
32
32
|
RemoteConfigResponse,
|
|
@@ -407,6 +407,37 @@ export default class DataManager {
|
|
|
407
407
|
return enrichedData;
|
|
408
408
|
}
|
|
409
409
|
|
|
410
|
+
private static enrichProtocolV2FirmwareReleaseInfo(
|
|
411
|
+
deviceData: DeviceTypeMap[keyof DeviceTypeMap] | undefined,
|
|
412
|
+
onResourcesError: (error: Error) => void
|
|
413
|
+
): NonNullable<DeviceTypeMap[keyof DeviceTypeMap]> {
|
|
414
|
+
const enrichedData = this.enrichFirmwareReleaseInfo(deviceData);
|
|
415
|
+
const releases = enrichedData['firmware-v1'];
|
|
416
|
+
if (!Array.isArray(releases)) {
|
|
417
|
+
return enrichedData;
|
|
418
|
+
}
|
|
419
|
+
const latestRelease = findLatestRelease(releases);
|
|
420
|
+
|
|
421
|
+
return {
|
|
422
|
+
...enrichedData,
|
|
423
|
+
'firmware-v1': releases.map(release => {
|
|
424
|
+
const { resources: rawResources, ...releaseWithoutResources } = release;
|
|
425
|
+
try {
|
|
426
|
+
const resources = parseProtocolV2Resources(rawResources);
|
|
427
|
+
return {
|
|
428
|
+
...releaseWithoutResources,
|
|
429
|
+
...(resources ? { resources } : undefined),
|
|
430
|
+
};
|
|
431
|
+
} catch (error) {
|
|
432
|
+
if (release === latestRelease) {
|
|
433
|
+
onResourcesError(error instanceof Error ? error : new Error(String(error)));
|
|
434
|
+
}
|
|
435
|
+
return releaseWithoutResources;
|
|
436
|
+
}
|
|
437
|
+
}),
|
|
438
|
+
};
|
|
439
|
+
}
|
|
440
|
+
|
|
410
441
|
static async load(settings: ConnectSettings): Promise<boolean> {
|
|
411
442
|
this.settings = settings;
|
|
412
443
|
this.protocolV2ResourcesConfigError = undefined;
|
|
@@ -471,32 +502,16 @@ export default class DataManager {
|
|
|
471
502
|
}
|
|
472
503
|
|
|
473
504
|
private static applyRemoteConfig(data: RemoteConfigResponse) {
|
|
474
|
-
|
|
475
|
-
let neoResources: IProtocolV2Resources | undefined;
|
|
476
|
-
try {
|
|
477
|
-
pro2Resources = parseProtocolV2Resources(
|
|
478
|
-
(data.pro2 as { resources?: unknown } | undefined)?.resources
|
|
479
|
-
);
|
|
480
|
-
} catch (error) {
|
|
505
|
+
const pro2Config = this.enrichProtocolV2FirmwareReleaseInfo(data.pro2, error => {
|
|
481
506
|
// Firmware resource metadata is not required for base communication. If the
|
|
482
|
-
//
|
|
483
|
-
this.protocolV2ResourcesConfigError =
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
);
|
|
491
|
-
} catch (error) {
|
|
492
|
-
this.protocolV2NeoResourcesConfigError =
|
|
493
|
-
error instanceof Error ? error : new Error(String(error));
|
|
494
|
-
Log.warn('[DataConfig] Ignoring invalid Neo resources config:', error);
|
|
495
|
-
}
|
|
496
|
-
const enrichedPro2Config = this.enrichFirmwareReleaseInfo(data.pro2);
|
|
497
|
-
const enrichedNeoConfig = this.enrichFirmwareReleaseInfo(data.neo);
|
|
498
|
-
const { resources: _unvalidatedResources, ...pro2Config } = enrichedPro2Config;
|
|
499
|
-
const { resources: _unvalidatedNeoResources, ...neoConfig } = enrichedNeoConfig;
|
|
507
|
+
// The selected release is incomplete, so disable its resource update only.
|
|
508
|
+
this.protocolV2ResourcesConfigError = error;
|
|
509
|
+
Log.warn('[DataConfig] Ignoring invalid Pro2 release resources config:', error);
|
|
510
|
+
});
|
|
511
|
+
const neoConfig = this.enrichProtocolV2FirmwareReleaseInfo(data.neo, error => {
|
|
512
|
+
this.protocolV2NeoResourcesConfigError = error;
|
|
513
|
+
Log.warn('[DataConfig] Ignoring invalid Neo release resources config:', error);
|
|
514
|
+
});
|
|
500
515
|
this.deviceMap = {
|
|
501
516
|
[EDeviceType.Classic]: this.enrichFirmwareReleaseInfo(data.classic),
|
|
502
517
|
[EDeviceType.Classic1s]: this.enrichFirmwareReleaseInfo(data.classic1s),
|
|
@@ -504,14 +519,8 @@ export default class DataManager {
|
|
|
504
519
|
[EDeviceType.Mini]: this.enrichFirmwareReleaseInfo(data.mini),
|
|
505
520
|
[EDeviceType.Touch]: this.enrichFirmwareReleaseInfo(data.touch),
|
|
506
521
|
[EDeviceType.Pro]: this.enrichFirmwareReleaseInfo(data.pro),
|
|
507
|
-
[EDeviceType.Pro2]:
|
|
508
|
-
|
|
509
|
-
...(pro2Resources ? { resources: pro2Resources } : undefined),
|
|
510
|
-
},
|
|
511
|
-
[EDeviceType.Neo]: {
|
|
512
|
-
...neoConfig,
|
|
513
|
-
...(neoResources ? { resources: neoResources } : undefined),
|
|
514
|
-
},
|
|
522
|
+
[EDeviceType.Pro2]: pro2Config,
|
|
523
|
+
[EDeviceType.Neo]: neoConfig,
|
|
515
524
|
};
|
|
516
525
|
this.assets = {
|
|
517
526
|
bridge: data.bridge,
|
|
@@ -589,10 +598,8 @@ export default class DataManager {
|
|
|
589
598
|
this.lastCheckTimestamp = getTimeStamp();
|
|
590
599
|
}
|
|
591
600
|
|
|
592
|
-
static getProtocolV2ResourceSource(
|
|
593
|
-
|
|
594
|
-
) {
|
|
595
|
-
return this.deviceMap[deviceType]?.resources?.source;
|
|
601
|
+
static getProtocolV2ResourceSource(release: IFirmwareReleaseInfo | undefined) {
|
|
602
|
+
return release?.resources?.source;
|
|
596
603
|
}
|
|
597
604
|
|
|
598
605
|
static getProtobufMessages(schema: ProtobufMessageSchema = 'v1CurrentSchema'): JSON {
|
package/src/types/settings.ts
CHANGED
|
@@ -116,6 +116,8 @@ export type IFirmwareReleaseInfo = {
|
|
|
116
116
|
upgradeType?: 'payload-package-set' | string;
|
|
117
117
|
components?: Record<string, IProtocolV2FirmwareComponent>;
|
|
118
118
|
installOrder?: string[];
|
|
119
|
+
/** Protocol V2 resources matched to this firmware release. */
|
|
120
|
+
resources?: IProtocolV2Resources;
|
|
119
121
|
bootloaderChangelog?: {
|
|
120
122
|
[k in ILocale]: string;
|
|
121
123
|
};
|
|
@@ -152,8 +154,6 @@ type IDeviceReleaseInfo = {
|
|
|
152
154
|
'firmware-v8'?: IFirmwareReleaseInfo[];
|
|
153
155
|
'firmware-btc-v8'?: IFirmwareReleaseInfo[];
|
|
154
156
|
ble?: IBLEFirmwareReleaseInfo[];
|
|
155
|
-
/** Independent Protocol V2 resource release configuration. */
|
|
156
|
-
resources?: IProtocolV2Resources;
|
|
157
157
|
};
|
|
158
158
|
|
|
159
159
|
export type DeviceTypeMap = {
|