@onekeyfe/hd-core 1.2.0-alpha.30 → 1.2.0-alpha.32
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 +251 -0
- package/__tests__/connectSettings.test.ts +5 -47
- package/__tests__/device-state-mapper.test.ts +10 -1
- package/__tests__/firmware-update/firmware-update-v2-download-before-boot.test.ts +31 -59
- package/__tests__/networkUtils.test.ts +20 -0
- package/__tests__/open-wallet-session.test.ts +19 -5
- package/__tests__/protocol-v2-firmware-targets.test.ts +18 -0
- package/__tests__/protocol-v2.test.ts +58 -240
- package/__tests__/public-device-state-api.test.ts +10 -1
- package/dist/api/CheckAllFirmwareRelease.d.ts +24 -1
- package/dist/api/CheckAllFirmwareRelease.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV2.d.ts +0 -11
- package/dist/api/FirmwareUpdateV2.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV3.d.ts +3 -7
- package/dist/api/FirmwareUpdateV3.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV4.d.ts +6 -22
- package/dist/api/FirmwareUpdateV4.d.ts.map +1 -1
- package/dist/api/OpenWalletSession.d.ts.map +1 -1
- package/dist/api/PromptWebDeviceAccess.d.ts.map +1 -1
- package/dist/api/device/DeviceUpdateBootloader.d.ts +1 -5
- package/dist/api/device/DeviceUpdateBootloader.d.ts.map +1 -1
- package/dist/api/firmware/FirmwareUpdateBaseMethod.d.ts +0 -7
- package/dist/api/firmware/FirmwareUpdateBaseMethod.d.ts.map +1 -1
- package/dist/api/firmware/getBinary.d.ts +0 -7
- package/dist/api/firmware/getBinary.d.ts.map +1 -1
- package/dist/api/firmware/updateBootloader.d.ts +0 -2
- package/dist/api/firmware/updateBootloader.d.ts.map +1 -1
- package/dist/api/firmware/uploadFirmware.d.ts +1 -9
- package/dist/api/firmware/uploadFirmware.d.ts.map +1 -1
- package/dist/api/stellar/StellarSignTransaction.d.ts +1 -1
- package/dist/data-manager/DataManager.d.ts +0 -1
- package/dist/data-manager/DataManager.d.ts.map +1 -1
- package/dist/data-manager/connectSettings.d.ts.map +1 -1
- package/dist/device/DeviceStateMapper.d.ts.map +1 -1
- package/dist/index.d.ts +43 -179
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1048 -2606
- package/dist/inject.d.ts.map +1 -1
- package/dist/lowLevelInject.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/walletSession.d.ts.map +1 -1
- package/dist/topLevelInject.d.ts.map +1 -1
- package/dist/types/api/checkAllFirmwareRelease.d.ts +25 -7
- package/dist/types/api/checkAllFirmwareRelease.d.ts.map +1 -1
- package/dist/types/api/deviceUpdateBootloader.d.ts +0 -6
- package/dist/types/api/deviceUpdateBootloader.d.ts.map +1 -1
- package/dist/types/api/export.d.ts +2 -4
- package/dist/types/api/export.d.ts.map +1 -1
- package/dist/types/api/firmwareUpdate.d.ts +0 -69
- package/dist/types/api/firmwareUpdate.d.ts.map +1 -1
- package/dist/types/api/index.d.ts +3 -10
- package/dist/types/api/index.d.ts.map +1 -1
- package/dist/types/api/openWalletSession.d.ts +9 -3
- package/dist/types/api/openWalletSession.d.ts.map +1 -1
- package/dist/types/device.d.ts +6 -0
- package/dist/types/device.d.ts.map +1 -1
- package/dist/types/settings.d.ts +1 -13
- package/dist/types/settings.d.ts.map +1 -1
- package/dist/utils/networkUtils.d.ts +1 -0
- package/dist/utils/networkUtils.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/api/CheckAllFirmwareRelease.ts +368 -50
- package/src/api/FirmwareUpdateV2.ts +120 -298
- package/src/api/FirmwareUpdateV3.ts +56 -258
- package/src/api/FirmwareUpdateV4.ts +328 -765
- package/src/api/OpenWalletSession.ts +12 -8
- package/src/api/PromptWebDeviceAccess.ts +2 -6
- package/src/api/device/DeviceUpdateBootloader.ts +6 -122
- package/src/api/firmware/FirmwareUpdateBaseMethod.ts +0 -50
- package/src/api/firmware/updateBootloader.ts +4 -19
- package/src/api/firmware/uploadFirmware.ts +22 -140
- package/src/data/messages/messages-protocol-v2.json +4 -0
- package/src/data-manager/DataManager.ts +33 -33
- package/src/data-manager/connectSettings.ts +0 -11
- package/src/device/DeviceStateMapper.ts +6 -0
- package/src/index.ts +0 -5
- package/src/inject.ts +2 -22
- package/src/lowLevelInject.ts +1 -5
- package/src/protocols/protocol-v2/walletSession.ts +2 -1
- package/src/topLevelInject.ts +1 -5
- package/src/types/api/checkAllFirmwareRelease.ts +46 -7
- package/src/types/api/deviceUpdateBootloader.ts +0 -6
- package/src/types/api/export.ts +5 -18
- package/src/types/api/firmwareUpdate.ts +0 -76
- package/src/types/api/index.ts +6 -15
- package/src/types/api/openWalletSession.ts +12 -3
- package/src/types/device.ts +6 -0
- package/src/types/settings.ts +3 -13
- package/src/utils/networkUtils.ts +5 -3
- package/__tests__/firmware-update/check-all-firmware-release.test.ts +0 -174
- package/__tests__/firmware-update/firmware-artifact-source.test.ts +0 -119
- package/__tests__/firmware-update/firmware-host-binding.test.ts +0 -70
- package/__tests__/firmware-update/firmware-preparation-error.test.ts +0 -27
- package/__tests__/firmware-update/firmware-update-capabilities.test.ts +0 -13
- package/__tests__/firmware-update/firmware-update-plan.test.ts +0 -593
- package/__tests__/firmware-update/firmware-update-prepared-plan.test.ts +0 -213
- package/__tests__/firmware-update/firmware-upload-source.test.ts +0 -70
- package/dist/api/firmware/FirmwareArtifactSource.d.ts +0 -25
- package/dist/api/firmware/FirmwareArtifactSource.d.ts.map +0 -1
- package/dist/api/firmware/FirmwareHostBinding.d.ts +0 -6
- package/dist/api/firmware/FirmwareHostBinding.d.ts.map +0 -1
- package/dist/api/firmware/FirmwarePreparationError.d.ts +0 -3
- package/dist/api/firmware/FirmwarePreparationError.d.ts.map +0 -1
- package/dist/api/firmware/FirmwareUpdateCapabilities.d.ts +0 -3
- package/dist/api/firmware/FirmwareUpdateCapabilities.d.ts.map +0 -1
- package/dist/api/firmware/FirmwareUpdatePlan.d.ts +0 -25
- package/dist/api/firmware/FirmwareUpdatePlan.d.ts.map +0 -1
- package/dist/api/firmware/FirmwareUpdatePreparedPlan.d.ts +0 -30
- package/dist/api/firmware/FirmwareUpdatePreparedPlan.d.ts.map +0 -1
- package/dist/types/api/firmwareUpdateCapabilities.d.ts +0 -9
- package/dist/types/api/firmwareUpdateCapabilities.d.ts.map +0 -1
- package/dist/types/api/firmwareUpdatePlan.d.ts +0 -28
- package/dist/types/api/firmwareUpdatePlan.d.ts.map +0 -1
- package/dist/types/api/firmwareUpdatePreparedPlan.d.ts +0 -42
- package/dist/types/api/firmwareUpdatePreparedPlan.d.ts.map +0 -1
- package/src/api/firmware/FirmwareArtifactSource.ts +0 -278
- package/src/api/firmware/FirmwareHostBinding.ts +0 -100
- package/src/api/firmware/FirmwarePreparationError.ts +0 -12
- package/src/api/firmware/FirmwareUpdateCapabilities.ts +0 -9
- package/src/api/firmware/FirmwareUpdatePlan.ts +0 -745
- package/src/api/firmware/FirmwareUpdatePreparedPlan.ts +0 -392
- package/src/types/api/firmwareUpdateCapabilities.ts +0 -9
- package/src/types/api/firmwareUpdatePlan.ts +0 -38
- package/src/types/api/firmwareUpdatePreparedPlan.ts +0 -53
|
@@ -399,17 +399,7 @@ export default class DataManager {
|
|
|
399
399
|
|
|
400
400
|
static async load(settings: ConnectSettings) {
|
|
401
401
|
this.settings = settings;
|
|
402
|
-
|
|
403
|
-
settings.firmwareManifestMode ?? (settings.fetchConfig ? 'sdk-managed' : undefined);
|
|
404
|
-
if (settings.preloadedConfig) {
|
|
405
|
-
this.applyRemoteConfig(settings.preloadedConfig);
|
|
406
|
-
Log.log('[DataConfig] Preloaded firmware config loaded');
|
|
407
|
-
return;
|
|
408
|
-
}
|
|
409
|
-
if (manifestMode === 'external-only') {
|
|
410
|
-
throw new Error('External firmware config snapshot is required');
|
|
411
|
-
}
|
|
412
|
-
if (manifestMode !== 'sdk-managed') {
|
|
402
|
+
if (!settings.fetchConfig) {
|
|
413
403
|
return;
|
|
414
404
|
}
|
|
415
405
|
|
|
@@ -419,50 +409,60 @@ export default class DataManager {
|
|
|
419
409
|
|
|
420
410
|
const urlWithCache = `${url}?noCache=${getTimeStamp()}`;
|
|
421
411
|
let data: RemoteConfigResponse | null = null;
|
|
412
|
+
let fetchMethod: 'configFetcher' | 'axios' | 'none' = 'none';
|
|
413
|
+
|
|
414
|
+
// 1. Try custom configFetcher first (client-side IP direct connection support)
|
|
422
415
|
if (settings.configFetcher) {
|
|
423
|
-
Log.debug('[DataConfig] Trying client
|
|
416
|
+
Log.debug('[DataConfig] Trying configFetcher (client-side fetcher)...');
|
|
424
417
|
try {
|
|
425
418
|
data = await settings.configFetcher(urlWithCache);
|
|
419
|
+
if (data) {
|
|
420
|
+
fetchMethod = 'configFetcher';
|
|
421
|
+
Log.log('[DataConfig] ConfigFetcher success');
|
|
422
|
+
} else {
|
|
423
|
+
Log.debug('[DataConfig] ConfigFetcher returned null, will fallback to axios');
|
|
424
|
+
}
|
|
426
425
|
} catch (e) {
|
|
427
|
-
Log.warn('[DataConfig]
|
|
426
|
+
Log.warn('[DataConfig] ConfigFetcher error, will fallback to axios:', e);
|
|
428
427
|
}
|
|
429
428
|
}
|
|
429
|
+
|
|
430
|
+
// 2. Fallback to default axios request
|
|
430
431
|
if (!data) {
|
|
431
|
-
Log.debug('[DataConfig] Trying SDK
|
|
432
|
+
Log.debug('[DataConfig] Trying axios (SDK default fetcher)...');
|
|
432
433
|
try {
|
|
433
434
|
const response = await axios.get<RemoteConfigResponse>(urlWithCache, {
|
|
434
435
|
// because of iframe timeout is 10000
|
|
435
436
|
timeout: 7000,
|
|
436
437
|
});
|
|
437
438
|
data = response.data;
|
|
438
|
-
|
|
439
|
+
fetchMethod = 'axios';
|
|
440
|
+
Log.log('[DataConfig] Axios fetch success');
|
|
439
441
|
} catch (e) {
|
|
440
|
-
Log.warn('[DataConfig]
|
|
442
|
+
Log.warn('[DataConfig] Axios fetch error:', e);
|
|
441
443
|
}
|
|
442
444
|
}
|
|
443
445
|
|
|
446
|
+
// 3. Apply config if available
|
|
444
447
|
if (data) {
|
|
445
|
-
|
|
448
|
+
Log.log(`[DataConfig] Config loaded successfully via [${fetchMethod}]`);
|
|
449
|
+
this.deviceMap = {
|
|
450
|
+
[EDeviceType.Classic]: this.enrichFirmwareReleaseInfo(data.classic),
|
|
451
|
+
[EDeviceType.Classic1s]: this.enrichFirmwareReleaseInfo(data.classic1s),
|
|
452
|
+
[EDeviceType.ClassicPure]: this.enrichFirmwareReleaseInfo(data.classicpure),
|
|
453
|
+
[EDeviceType.Mini]: this.enrichFirmwareReleaseInfo(data.mini),
|
|
454
|
+
[EDeviceType.Touch]: this.enrichFirmwareReleaseInfo(data.touch),
|
|
455
|
+
[EDeviceType.Pro]: this.enrichFirmwareReleaseInfo(data.pro),
|
|
456
|
+
[EDeviceType.Pro2]: this.enrichFirmwareReleaseInfo(data.pro2),
|
|
457
|
+
};
|
|
458
|
+
this.assets = {
|
|
459
|
+
bridge: data.bridge,
|
|
460
|
+
};
|
|
446
461
|
} else {
|
|
447
|
-
Log.warn('[DataConfig]
|
|
462
|
+
Log.warn('[DataConfig] All fetch methods failed, using built-in default config');
|
|
448
463
|
}
|
|
449
464
|
}
|
|
450
465
|
|
|
451
|
-
private static applyRemoteConfig(data: RemoteConfigResponse) {
|
|
452
|
-
this.deviceMap = {
|
|
453
|
-
[EDeviceType.Classic]: this.enrichFirmwareReleaseInfo(data.classic),
|
|
454
|
-
[EDeviceType.Classic1s]: this.enrichFirmwareReleaseInfo(data.classic1s),
|
|
455
|
-
[EDeviceType.ClassicPure]: this.enrichFirmwareReleaseInfo(data.classicpure),
|
|
456
|
-
[EDeviceType.Mini]: this.enrichFirmwareReleaseInfo(data.mini),
|
|
457
|
-
[EDeviceType.Touch]: this.enrichFirmwareReleaseInfo(data.touch),
|
|
458
|
-
[EDeviceType.Pro]: this.enrichFirmwareReleaseInfo(data.pro),
|
|
459
|
-
[EDeviceType.Pro2]: this.enrichFirmwareReleaseInfo(data.pro2),
|
|
460
|
-
};
|
|
461
|
-
this.assets = {
|
|
462
|
-
bridge: data.bridge,
|
|
463
|
-
};
|
|
464
|
-
}
|
|
465
|
-
|
|
466
466
|
static updateEnv(newEnv: ConnectSettings['env']) {
|
|
467
467
|
if (this.settings) {
|
|
468
468
|
const prevEnv = this.settings.env;
|
|
@@ -115,21 +115,10 @@ export const parseConnectSettings = (input: Partial<ConnectSettings> = {}) => {
|
|
|
115
115
|
settings.fetchConfig = input.fetchConfig;
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
-
if (
|
|
119
|
-
input.firmwareManifestMode === 'sdk-managed' ||
|
|
120
|
-
input.firmwareManifestMode === 'external-only'
|
|
121
|
-
) {
|
|
122
|
-
settings.firmwareManifestMode = input.firmwareManifestMode;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
118
|
if (input.configFetcher) {
|
|
126
119
|
settings.configFetcher = input.configFetcher;
|
|
127
120
|
}
|
|
128
121
|
|
|
129
|
-
if (input.preloadedConfig) {
|
|
130
|
-
settings.preloadedConfig = input.preloadedConfig;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
122
|
return settings;
|
|
134
123
|
};
|
|
135
124
|
|
|
@@ -242,6 +242,8 @@ export const mapProtocolV2DeviceInfoToState = (
|
|
|
242
242
|
: { mode },
|
|
243
243
|
versions: definedEntries({
|
|
244
244
|
firmware: imageVersion(info.fw?.application),
|
|
245
|
+
applicationP1: imageVersion(info.fw?.application),
|
|
246
|
+
applicationP2: imageVersion(info.fw?.application_data),
|
|
245
247
|
bootloader: imageVersion(info.fw?.bootloader),
|
|
246
248
|
board: imageVersion(info.fw?.romloader),
|
|
247
249
|
ble: imageVersion(info.coprocessor?.application),
|
|
@@ -257,6 +259,10 @@ export const mapProtocolV2DeviceInfoToState = (
|
|
|
257
259
|
verification: definedEntries({
|
|
258
260
|
firmwareBuildId: imageBuildId(info.fw?.application),
|
|
259
261
|
firmwareHash: imageHash(info.fw?.application),
|
|
262
|
+
applicationP1BuildId: imageBuildId(info.fw?.application),
|
|
263
|
+
applicationP1Hash: imageHash(info.fw?.application),
|
|
264
|
+
applicationP2BuildId: imageBuildId(info.fw?.application_data),
|
|
265
|
+
applicationP2Hash: imageHash(info.fw?.application_data),
|
|
260
266
|
bootloaderBuildId: imageBuildId(info.fw?.bootloader),
|
|
261
267
|
bootloaderHash: imageHash(info.fw?.bootloader),
|
|
262
268
|
boardBuildId: imageBuildId(info.fw?.romloader),
|
package/src/index.ts
CHANGED
|
@@ -19,11 +19,6 @@ export * from './types';
|
|
|
19
19
|
export { whitelist, whitelistExtension } from './data/config';
|
|
20
20
|
export { executeCallback, cleanupCallback };
|
|
21
21
|
export { preloadSessionCache } from './device/Device';
|
|
22
|
-
export {
|
|
23
|
-
getFirmwareUpdateHostBindingGeneration,
|
|
24
|
-
registerFirmwareUpdateHostBinding,
|
|
25
|
-
unregisterFirmwareUpdateHostBinding,
|
|
26
|
-
} from './api/firmware/FirmwareHostBinding';
|
|
27
22
|
|
|
28
23
|
const HardwareSdk = ({
|
|
29
24
|
init,
|
package/src/inject.ts
CHANGED
|
@@ -1,17 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
prepareFirmwareUpdatePlan,
|
|
4
|
-
validateFirmwareUpdatePreparedPlan,
|
|
5
|
-
} from './api/firmware/FirmwareUpdatePreparedPlan';
|
|
6
|
-
import {
|
|
7
|
-
getFirmwareUpdateHostBindingGeneration,
|
|
8
|
-
registerFirmwareUpdateHostBinding,
|
|
9
|
-
unregisterFirmwareUpdateHostBinding,
|
|
10
|
-
} from './api/firmware/FirmwareHostBinding';
|
|
11
|
-
|
|
1
|
+
import type { Unsuccessful } from './types';
|
|
12
2
|
import type { EventEmitter } from 'events';
|
|
13
3
|
import type { CallMethod } from './events';
|
|
14
|
-
import type { Unsuccessful } from './types';
|
|
15
4
|
import type { CoreApi } from './types/api';
|
|
16
5
|
import type { AllNetworkAddress } from './types/api/allNetworkGetAddress';
|
|
17
6
|
|
|
@@ -79,10 +68,7 @@ export const inject = ({
|
|
|
79
68
|
|
|
80
69
|
call,
|
|
81
70
|
|
|
82
|
-
dispose
|
|
83
|
-
unregisterFirmwareUpdateHostBinding();
|
|
84
|
-
await dispose();
|
|
85
|
-
},
|
|
71
|
+
dispose,
|
|
86
72
|
|
|
87
73
|
uiResponse,
|
|
88
74
|
|
|
@@ -113,12 +99,6 @@ export const createCoreApi = (
|
|
|
113
99
|
| 'updateSettings'
|
|
114
100
|
| 'switchTransport'
|
|
115
101
|
> => ({
|
|
116
|
-
getFirmwareUpdateCapabilities,
|
|
117
|
-
registerFirmwareUpdateHostBinding,
|
|
118
|
-
unregisterFirmwareUpdateHostBinding,
|
|
119
|
-
getFirmwareUpdateHostBindingGeneration,
|
|
120
|
-
prepareFirmwareUpdatePlan,
|
|
121
|
-
validateFirmwareUpdatePreparedPlan,
|
|
122
102
|
getLogs: () => call({ method: 'getLogs' }),
|
|
123
103
|
clearSessionCache: params => call({ ...params, method: 'clearSessionCache' }),
|
|
124
104
|
/**
|
package/src/lowLevelInject.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { createCoreApi } from './inject';
|
|
2
|
-
import { unregisterFirmwareUpdateHostBinding } from './api/firmware/FirmwareHostBinding';
|
|
3
2
|
|
|
4
3
|
import type { EventEmitter } from 'events';
|
|
5
4
|
import type { CallMethod, CoreMessage } from './events';
|
|
@@ -44,10 +43,7 @@ export const lowLevelInject = ({
|
|
|
44
43
|
|
|
45
44
|
call,
|
|
46
45
|
|
|
47
|
-
dispose
|
|
48
|
-
unregisterFirmwareUpdateHostBinding();
|
|
49
|
-
await dispose();
|
|
50
|
-
},
|
|
46
|
+
dispose,
|
|
51
47
|
|
|
52
48
|
uiResponse,
|
|
53
49
|
|
|
@@ -41,7 +41,7 @@ const askDevicePassphrase = async (device: Device, passphrase?: string) => {
|
|
|
41
41
|
device.commands.typedCall(
|
|
42
42
|
'DeviceSessionAskPassphrase',
|
|
43
43
|
'Success',
|
|
44
|
-
passphrase ? { passphrase } : {}
|
|
44
|
+
passphrase ? { passphrase, on_device: false } : { on_device: true }
|
|
45
45
|
);
|
|
46
46
|
try {
|
|
47
47
|
return await request();
|
|
@@ -63,6 +63,7 @@ const selectDeviceSession = async (device: Device) => {
|
|
|
63
63
|
const response = await device.commands.promptPassphrase(
|
|
64
64
|
{
|
|
65
65
|
existsAttachPinUser,
|
|
66
|
+
deviceOnly: true,
|
|
66
67
|
...metadata,
|
|
67
68
|
},
|
|
68
69
|
{ cancelDeviceOnReject: false }
|
package/src/topLevelInject.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import EventEmitter from 'events';
|
|
2
2
|
|
|
3
3
|
import { createCoreApi } from './inject';
|
|
4
|
-
import { unregisterFirmwareUpdateHostBinding } from './api/firmware/FirmwareHostBinding';
|
|
5
4
|
|
|
6
5
|
import type { ConnectSettings } from './types/settings';
|
|
7
6
|
import type { CoreApi } from './types/api';
|
|
@@ -47,10 +46,7 @@ export const topLevelInject = () => {
|
|
|
47
46
|
lowLevelApi?.removeAllListeners(type);
|
|
48
47
|
},
|
|
49
48
|
|
|
50
|
-
dispose:
|
|
51
|
-
unregisterFirmwareUpdateHostBinding();
|
|
52
|
-
await lowLevelApi?.dispose();
|
|
53
|
-
},
|
|
49
|
+
dispose: () => lowLevelApi?.dispose(),
|
|
54
50
|
|
|
55
51
|
uiResponse: response => lowLevelApi?.uiResponse(response),
|
|
56
52
|
|
|
@@ -1,8 +1,17 @@
|
|
|
1
|
-
import type { IBLEFirmwareReleaseInfo } from '../settings';
|
|
2
1
|
import type { EFirmwareType } from '@onekeyfe/hd-shared';
|
|
3
2
|
import type { CommonParams, Response } from '../params';
|
|
4
|
-
import type {
|
|
5
|
-
|
|
3
|
+
import type {
|
|
4
|
+
DeviceStateVersions,
|
|
5
|
+
Features,
|
|
6
|
+
IDeviceBLEFirmwareStatus,
|
|
7
|
+
IDeviceFirmwareStatus,
|
|
8
|
+
} from '../device';
|
|
9
|
+
import type {
|
|
10
|
+
IBLEFirmwareReleaseInfo,
|
|
11
|
+
IFirmwareReleaseInfo,
|
|
12
|
+
IProtocolV2FirmwareComponentTarget,
|
|
13
|
+
} from '../settings';
|
|
14
|
+
import type { FirmwareUpdateV4Target } from './firmwareUpdate';
|
|
6
15
|
|
|
7
16
|
export type FirmwareRelease = {
|
|
8
17
|
shouldUpdate?: boolean;
|
|
@@ -11,24 +20,54 @@ export type FirmwareRelease = {
|
|
|
11
20
|
'zh-CN': string;
|
|
12
21
|
'en-US': string;
|
|
13
22
|
}[];
|
|
14
|
-
release: IDeviceBLEFirmwareStatus | IBLEFirmwareReleaseInfo;
|
|
23
|
+
release: IDeviceBLEFirmwareStatus | IBLEFirmwareReleaseInfo | IFirmwareReleaseInfo;
|
|
15
24
|
bootloaderMode?: boolean;
|
|
16
25
|
};
|
|
17
26
|
|
|
27
|
+
export type ProtocolV2FirmwareComponentReleaseStatus =
|
|
28
|
+
| 'valid'
|
|
29
|
+
| 'outdated'
|
|
30
|
+
| 'unknown'
|
|
31
|
+
| 'unsupported';
|
|
32
|
+
|
|
33
|
+
export type ProtocolV2FirmwareReleaseStatus =
|
|
34
|
+
| 'unavailable'
|
|
35
|
+
| 'valid'
|
|
36
|
+
| 'unknown'
|
|
37
|
+
| 'outdated'
|
|
38
|
+
| 'required';
|
|
39
|
+
|
|
40
|
+
export type ProtocolV2FirmwareComponentRelease = {
|
|
41
|
+
configKey: string;
|
|
42
|
+
componentTarget: IProtocolV2FirmwareComponentTarget;
|
|
43
|
+
updateTarget: FirmwareUpdateV4Target | null;
|
|
44
|
+
currentVersion: string | null;
|
|
45
|
+
targetVersion: string | null;
|
|
46
|
+
status: ProtocolV2FirmwareComponentReleaseStatus;
|
|
47
|
+
required: boolean;
|
|
48
|
+
};
|
|
49
|
+
|
|
18
50
|
export type AllFirmwareRelease = {
|
|
19
51
|
firmware: FirmwareRelease;
|
|
20
52
|
ble: FirmwareRelease;
|
|
21
53
|
bootloader?: FirmwareRelease;
|
|
22
54
|
bridge?: FirmwareRelease;
|
|
23
55
|
features?: Features;
|
|
24
|
-
|
|
56
|
+
protocol?: 'V1' | 'V2';
|
|
57
|
+
deviceType?: 'pro2';
|
|
58
|
+
firmwareType?: EFirmwareType;
|
|
59
|
+
status?: ProtocolV2FirmwareReleaseStatus;
|
|
60
|
+
hasUpgrade?: boolean;
|
|
61
|
+
required?: boolean;
|
|
62
|
+
currentVersions?: DeviceStateVersions;
|
|
63
|
+
components?: ProtocolV2FirmwareComponentRelease[];
|
|
64
|
+
targetsToUpdate?: FirmwareUpdateV4Target[];
|
|
65
|
+
release?: IFirmwareReleaseInfo;
|
|
25
66
|
};
|
|
26
67
|
|
|
27
68
|
export type CheckAllFirmwareReleaseParams = {
|
|
28
69
|
checkBridgeRelease?: boolean;
|
|
29
70
|
firmwareType?: EFirmwareType;
|
|
30
|
-
platform?: 'native' | 'desktop' | 'ext' | 'web' | 'web-embed';
|
|
31
|
-
forceUpdateTargets?: FirmwareUpdatePlanForceTarget[];
|
|
32
71
|
};
|
|
33
72
|
|
|
34
73
|
export declare function checkAllFirmwareRelease(
|
|
@@ -1,15 +1,9 @@
|
|
|
1
1
|
import type { Success } from '@onekeyfe/hd-transport';
|
|
2
2
|
import type { EFirmwareType } from '@onekeyfe/hd-shared';
|
|
3
|
-
import type { FirmwareArtifactReader, FirmwareArtifactReference } from './firmwareUpdate';
|
|
4
|
-
import type { FirmwareUpdatePreparedPlan } from './firmwareUpdatePreparedPlan';
|
|
5
3
|
import type { Response } from '../params';
|
|
6
4
|
|
|
7
5
|
export type DeviceUpdateBootloaderParams = {
|
|
8
|
-
preparedPlan?: FirmwareUpdatePreparedPlan;
|
|
9
|
-
hostBindingGeneration?: number;
|
|
10
6
|
binary?: ArrayBuffer;
|
|
11
|
-
artifact?: FirmwareArtifactReference;
|
|
12
|
-
artifactReader?: FirmwareArtifactReader;
|
|
13
7
|
firmwareType?: EFirmwareType;
|
|
14
8
|
};
|
|
15
9
|
|
package/src/types/api/export.ts
CHANGED
|
@@ -25,31 +25,18 @@ export type {
|
|
|
25
25
|
DeviceUploadResourceResponse,
|
|
26
26
|
} from './deviceUploadResource';
|
|
27
27
|
export type {
|
|
28
|
-
FirmwareArtifactReader,
|
|
29
|
-
FirmwareArtifactReference,
|
|
30
|
-
FirmwareUpdateHostBinding,
|
|
31
|
-
FirmwareUpdateArtifactParams,
|
|
32
28
|
FirmwareUpdateParams,
|
|
33
29
|
FirmwareUpdateBinaryParams,
|
|
34
30
|
FirmwareUpdateV3Params,
|
|
35
31
|
FirmwareUpdateV4Params,
|
|
36
32
|
FirmwareUpdateV4Target,
|
|
37
33
|
} from './firmwareUpdate';
|
|
38
|
-
export type {
|
|
39
|
-
FirmwareUpdatePlan,
|
|
40
|
-
FirmwareUpdatePlanArtifact,
|
|
41
|
-
FirmwareUpdatePlanArtifactRole,
|
|
42
|
-
FirmwareUpdatePlanForceTarget,
|
|
43
|
-
FirmwareUpdatePlanTarget,
|
|
44
|
-
} from './firmwareUpdatePlan';
|
|
45
|
-
export type {
|
|
46
|
-
FirmwareUpdatePreparedArtifact,
|
|
47
|
-
FirmwareUpdatePreparedArtifactInput,
|
|
48
|
-
FirmwareUpdatePreparedEntry,
|
|
49
|
-
FirmwareUpdatePreparedPlan,
|
|
50
|
-
} from './firmwareUpdatePreparedPlan';
|
|
51
|
-
export type { FirmwareUpdateCapabilities } from './firmwareUpdateCapabilities';
|
|
52
34
|
export type { AllFirmwareRelease } from './checkAllFirmwareRelease';
|
|
35
|
+
export type {
|
|
36
|
+
ProtocolV2FirmwareComponentRelease,
|
|
37
|
+
ProtocolV2FirmwareComponentReleaseStatus,
|
|
38
|
+
ProtocolV2FirmwareReleaseStatus,
|
|
39
|
+
} from './checkAllFirmwareRelease';
|
|
53
40
|
|
|
54
41
|
export type { AllNetworkAddressParams, AllNetworkGetAddressParams } from './allNetworkGetAddress';
|
|
55
42
|
|
|
@@ -1,53 +1,14 @@
|
|
|
1
1
|
import type { EFirmwareType } from '@onekeyfe/hd-shared';
|
|
2
2
|
import type { PROTO } from '../../constants';
|
|
3
3
|
import type { Params, Response } from '../params';
|
|
4
|
-
import type { FirmwareUpdatePreparedPlan } from './firmwareUpdatePreparedPlan';
|
|
5
4
|
|
|
6
5
|
type IUpdateType = 'firmware' | 'ble';
|
|
7
6
|
|
|
8
|
-
export interface FirmwareArtifactReference {
|
|
9
|
-
artifactRef: string;
|
|
10
|
-
size: number;
|
|
11
|
-
sha256: string;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export interface FirmwareArtifactReader {
|
|
15
|
-
open(input: { artifactRef: string }): Promise<{
|
|
16
|
-
readerId: string;
|
|
17
|
-
size: number;
|
|
18
|
-
}>;
|
|
19
|
-
read(input: { readerId: string; offset: number; length: number }): Promise<{
|
|
20
|
-
data: ArrayBuffer;
|
|
21
|
-
bytesRead: number;
|
|
22
|
-
eof: boolean;
|
|
23
|
-
}>;
|
|
24
|
-
close(input: { readerId: string }): Promise<void>;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export interface FirmwareUpdateHostBinding {
|
|
28
|
-
artifactReader: FirmwareArtifactReader;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
7
|
export interface FirmwareUpdateBinaryParams {
|
|
32
8
|
binary: ArrayBuffer;
|
|
33
9
|
updateType: IUpdateType;
|
|
34
10
|
}
|
|
35
11
|
|
|
36
|
-
export interface FirmwareUpdateArtifactParams {
|
|
37
|
-
preparedPlan: FirmwareUpdatePreparedPlan;
|
|
38
|
-
hostBindingGeneration: number;
|
|
39
|
-
artifact: FirmwareArtifactReference;
|
|
40
|
-
resourceArtifact?: FirmwareArtifactReference;
|
|
41
|
-
resourceEntries?: Array<{
|
|
42
|
-
entryName: string;
|
|
43
|
-
artifact: FirmwareArtifactReference;
|
|
44
|
-
}>;
|
|
45
|
-
updateType: IUpdateType;
|
|
46
|
-
forcedUpdateRes?: boolean;
|
|
47
|
-
isUpdateBootloader?: boolean;
|
|
48
|
-
firmwareType?: EFirmwareType;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
12
|
export interface FirmwareUpdateParams {
|
|
52
13
|
version?: number[];
|
|
53
14
|
updateType: IUpdateType;
|
|
@@ -76,14 +37,8 @@ export declare function firmwareUpdateV2(
|
|
|
76
37
|
connectId: string | undefined,
|
|
77
38
|
params: Params<FirmwareUpdateBinaryParams & Platform>
|
|
78
39
|
): Response<PROTO.Success>;
|
|
79
|
-
export declare function firmwareUpdateV2(
|
|
80
|
-
connectId: string | undefined,
|
|
81
|
-
params: Params<FirmwareUpdateArtifactParams & Platform>
|
|
82
|
-
): Response<PROTO.Success>;
|
|
83
40
|
|
|
84
41
|
export interface FirmwareUpdateV3Params {
|
|
85
|
-
preparedPlan?: FirmwareUpdatePreparedPlan;
|
|
86
|
-
hostBindingGeneration?: number;
|
|
87
42
|
bleVersion?: number[];
|
|
88
43
|
bleBinary?: ArrayBuffer;
|
|
89
44
|
chunkSize?: number;
|
|
@@ -100,17 +55,6 @@ export interface FirmwareUpdateV3Params {
|
|
|
100
55
|
firmwareType?: EFirmwareType;
|
|
101
56
|
|
|
102
57
|
platform: IPlatform;
|
|
103
|
-
|
|
104
|
-
artifactReader?: FirmwareArtifactReader;
|
|
105
|
-
artifacts?: {
|
|
106
|
-
ble?: FirmwareArtifactReference;
|
|
107
|
-
firmware?: FirmwareArtifactReference;
|
|
108
|
-
bootloader?: FirmwareArtifactReference;
|
|
109
|
-
resourceEntries?: Array<{
|
|
110
|
-
entryName: string;
|
|
111
|
-
artifact: FirmwareArtifactReference;
|
|
112
|
-
}>;
|
|
113
|
-
};
|
|
114
58
|
}
|
|
115
59
|
|
|
116
60
|
/**
|
|
@@ -129,14 +73,10 @@ export type FirmwareUpdateV4Target =
|
|
|
129
73
|
| 'se04';
|
|
130
74
|
|
|
131
75
|
export interface FirmwareUpdateV4Params {
|
|
132
|
-
preparedPlan?: FirmwareUpdatePreparedPlan;
|
|
133
|
-
hostBindingGeneration?: number;
|
|
134
76
|
platform: IPlatform;
|
|
135
|
-
expectedDeviceId?: string;
|
|
136
77
|
chunkSize?: number;
|
|
137
78
|
firmwareType?: EFirmwareType;
|
|
138
79
|
targetsToUpdate?: FirmwareUpdateV4Target[];
|
|
139
|
-
expectedTargetVersions?: Partial<Record<FirmwareUpdateV4Target, string>>;
|
|
140
80
|
|
|
141
81
|
/** FW_MGMT_TARGET_ROMLOADER = 2; Pro2 cannot install it through firmwareUpdateV4. */
|
|
142
82
|
romloaderBinary?: ArrayBuffer;
|
|
@@ -162,24 +102,8 @@ export interface FirmwareUpdateV4Params {
|
|
|
162
102
|
binary: ArrayBuffer;
|
|
163
103
|
devicePath: string;
|
|
164
104
|
}>;
|
|
165
|
-
artifactReader?: FirmwareArtifactReader;
|
|
166
|
-
componentArtifacts?: Partial<
|
|
167
|
-
Record<Exclude<FirmwareUpdateV4Target, 'resource'>, FirmwareArtifactReference>
|
|
168
|
-
>;
|
|
169
|
-
resourceBundleArtifacts?: Array<{
|
|
170
|
-
name: string;
|
|
171
|
-
artifact: FirmwareArtifactReference;
|
|
172
|
-
}>;
|
|
173
105
|
}
|
|
174
106
|
|
|
175
|
-
export declare function registerFirmwareUpdateHostBinding(
|
|
176
|
-
binding: FirmwareUpdateHostBinding
|
|
177
|
-
): number;
|
|
178
|
-
|
|
179
|
-
export declare function unregisterFirmwareUpdateHostBinding(generation?: number): boolean;
|
|
180
|
-
|
|
181
|
-
export declare function getFirmwareUpdateHostBindingGeneration(): number;
|
|
182
|
-
|
|
183
107
|
export declare function firmwareUpdateV3(
|
|
184
108
|
connectId: string | undefined,
|
|
185
109
|
params: Params<FirmwareUpdateV3Params>
|
package/src/types/api/index.ts
CHANGED
|
@@ -30,15 +30,7 @@ import type {
|
|
|
30
30
|
firmwareUpdateV2,
|
|
31
31
|
firmwareUpdateV3,
|
|
32
32
|
firmwareUpdateV4,
|
|
33
|
-
getFirmwareUpdateHostBindingGeneration,
|
|
34
|
-
registerFirmwareUpdateHostBinding,
|
|
35
|
-
unregisterFirmwareUpdateHostBinding,
|
|
36
33
|
} from './firmwareUpdate';
|
|
37
|
-
import type { getFirmwareUpdateCapabilities } from './firmwareUpdateCapabilities';
|
|
38
|
-
import type {
|
|
39
|
-
prepareFirmwareUpdatePlan,
|
|
40
|
-
validateFirmwareUpdatePreparedPlan,
|
|
41
|
-
} from './firmwareUpdatePreparedPlan';
|
|
42
34
|
import type { promptWebDeviceAccess } from './promptWebDeviceAccess';
|
|
43
35
|
import type { deviceReset } from './deviceReset';
|
|
44
36
|
import type { deviceRecovery } from './deviceRecovery';
|
|
@@ -156,7 +148,12 @@ import type { ConnectSettings } from '../settings';
|
|
|
156
148
|
export * from './export';
|
|
157
149
|
export type { DeviceStateScope, GetDeviceStateParams } from './getDeviceState';
|
|
158
150
|
export type { GetPassphraseStateParams } from './getPassphraseState';
|
|
159
|
-
export
|
|
151
|
+
export { OpenWalletSessionMode } from './openWalletSession';
|
|
152
|
+
export type {
|
|
153
|
+
OpenWalletSessionModeValue,
|
|
154
|
+
OpenWalletSessionParams,
|
|
155
|
+
OpenWalletSessionPayload,
|
|
156
|
+
} from './openWalletSession';
|
|
160
157
|
export type { ClearSessionCacheParams, ClearSessionCachePayload } from './sessionCache';
|
|
161
158
|
export type { TestProtocolV2PingParams } from './protocolV2';
|
|
162
159
|
|
|
@@ -230,12 +227,6 @@ export type CoreApi = {
|
|
|
230
227
|
firmwareUpdateV2: typeof firmwareUpdateV2;
|
|
231
228
|
firmwareUpdateV3: typeof firmwareUpdateV3;
|
|
232
229
|
firmwareUpdateV4: typeof firmwareUpdateV4;
|
|
233
|
-
registerFirmwareUpdateHostBinding: typeof registerFirmwareUpdateHostBinding;
|
|
234
|
-
unregisterFirmwareUpdateHostBinding: typeof unregisterFirmwareUpdateHostBinding;
|
|
235
|
-
getFirmwareUpdateHostBindingGeneration: typeof getFirmwareUpdateHostBindingGeneration;
|
|
236
|
-
getFirmwareUpdateCapabilities: typeof getFirmwareUpdateCapabilities;
|
|
237
|
-
prepareFirmwareUpdatePlan: typeof prepareFirmwareUpdatePlan;
|
|
238
|
-
validateFirmwareUpdatePreparedPlan: typeof validateFirmwareUpdatePreparedPlan;
|
|
239
230
|
cipherKeyValue: typeof cipherKeyValue;
|
|
240
231
|
|
|
241
232
|
/**
|
|
@@ -1,18 +1,27 @@
|
|
|
1
1
|
import type { CommonParams, Response } from '../params';
|
|
2
2
|
|
|
3
|
+
export const OpenWalletSessionMode = {
|
|
4
|
+
Standard: 'standard',
|
|
5
|
+
SelectHidden: 'select-hidden',
|
|
6
|
+
ResumeHidden: 'resume-hidden',
|
|
7
|
+
} as const;
|
|
8
|
+
|
|
9
|
+
export type OpenWalletSessionModeValue =
|
|
10
|
+
(typeof OpenWalletSessionMode)[keyof typeof OpenWalletSessionMode];
|
|
11
|
+
|
|
3
12
|
export type OpenWalletSessionParams =
|
|
4
13
|
| {
|
|
5
|
-
mode:
|
|
14
|
+
mode: typeof OpenWalletSessionMode.Standard;
|
|
6
15
|
deviceId?: never;
|
|
7
16
|
passphraseState?: never;
|
|
8
17
|
}
|
|
9
18
|
| {
|
|
10
|
-
mode:
|
|
19
|
+
mode: typeof OpenWalletSessionMode.SelectHidden;
|
|
11
20
|
deviceId?: never;
|
|
12
21
|
passphraseState?: never;
|
|
13
22
|
}
|
|
14
23
|
| {
|
|
15
|
-
mode:
|
|
24
|
+
mode: typeof OpenWalletSessionMode.ResumeHidden;
|
|
16
25
|
deviceId: string;
|
|
17
26
|
passphraseState: string;
|
|
18
27
|
};
|
package/src/types/device.ts
CHANGED
|
@@ -124,6 +124,10 @@ export type DeviceFeaturesMode =
|
|
|
124
124
|
export type DeviceFeaturesVerify = {
|
|
125
125
|
firmwareBuildId?: string;
|
|
126
126
|
firmwareHash?: string;
|
|
127
|
+
applicationP1BuildId?: string;
|
|
128
|
+
applicationP1Hash?: string;
|
|
129
|
+
applicationP2BuildId?: string;
|
|
130
|
+
applicationP2Hash?: string;
|
|
127
131
|
bootloaderBuildId?: string;
|
|
128
132
|
bootloaderHash?: string;
|
|
129
133
|
boardBuildId?: string;
|
|
@@ -230,6 +234,8 @@ export type DeviceStateSettings = {
|
|
|
230
234
|
|
|
231
235
|
export type DeviceStateVersions = {
|
|
232
236
|
firmware: string | null;
|
|
237
|
+
applicationP1?: string | null;
|
|
238
|
+
applicationP2?: string | null;
|
|
233
239
|
bootloader: string | null;
|
|
234
240
|
board: string | null;
|
|
235
241
|
ble: string | null;
|
package/src/types/settings.ts
CHANGED
|
@@ -31,8 +31,6 @@ export type ConnectSettings = {
|
|
|
31
31
|
timestamp: number;
|
|
32
32
|
isFrame?: boolean;
|
|
33
33
|
preRelease?: boolean;
|
|
34
|
-
firmwareManifestMode?: 'sdk-managed' | 'external-only';
|
|
35
|
-
preloadedConfig?: RemoteConfigResponse;
|
|
36
34
|
fetchConfig?: boolean;
|
|
37
35
|
extension?: string;
|
|
38
36
|
configFetcher?: (url: string) => Promise<RemoteConfigResponse | null>;
|
|
@@ -56,8 +54,10 @@ export type IProtocolV2FirmwareComponentTarget =
|
|
|
56
54
|
export type IProtocolV2FirmwareComponent = {
|
|
57
55
|
target: IProtocolV2FirmwareComponentTarget;
|
|
58
56
|
url: string;
|
|
57
|
+
/** SHA-256 of the complete okpkg, used after downloading the package. */
|
|
59
58
|
fingerprint?: string;
|
|
60
|
-
|
|
59
|
+
/** OKPP payload hash, used to detect same-version package changes. */
|
|
60
|
+
payloadHash?: string;
|
|
61
61
|
version?: IVersionArray;
|
|
62
62
|
};
|
|
63
63
|
|
|
@@ -67,8 +67,6 @@ export type IProtocolV2ResourceBundle = {
|
|
|
67
67
|
name: string;
|
|
68
68
|
/** Download URL. */
|
|
69
69
|
url: string;
|
|
70
|
-
fingerprint?: string;
|
|
71
|
-
expectedSize?: number;
|
|
72
70
|
/** Device target path, such as vol0:/bundles/images/images.okpkg. */
|
|
73
71
|
devicePath: string;
|
|
74
72
|
/** okpkg payload_version used to skip matching content after FileRead. */
|
|
@@ -90,16 +88,10 @@ export type IFirmwareReleaseInfo = {
|
|
|
90
88
|
firmwareType?: EFirmwareType;
|
|
91
89
|
/** Firmware UI resource */
|
|
92
90
|
resource?: string;
|
|
93
|
-
resourceFingerprint?: string;
|
|
94
|
-
resourceExpectedSize?: number;
|
|
95
91
|
/** Firmware full UI resource */
|
|
96
92
|
fullResource?: string;
|
|
97
|
-
fullResourceFingerprint?: string;
|
|
98
|
-
fullResourceExpectedSize?: number;
|
|
99
93
|
fullResourceRange?: string[];
|
|
100
94
|
bootloaderResource?: string;
|
|
101
|
-
bootloaderFingerprint?: string;
|
|
102
|
-
bootloaderExpectedSize?: number;
|
|
103
95
|
bootloaderVersion?: IVersionArray;
|
|
104
96
|
displayBootloaderVersion?: IVersionArray;
|
|
105
97
|
bootloaderRelatedFirmwareVersion?: IVersionArray;
|
|
@@ -112,7 +104,6 @@ export type IFirmwareReleaseInfo = {
|
|
|
112
104
|
[k in ILocale]: string;
|
|
113
105
|
};
|
|
114
106
|
fingerprint: string;
|
|
115
|
-
expectedSize?: number;
|
|
116
107
|
version: IVersionArray;
|
|
117
108
|
changelog: {
|
|
118
109
|
[k in ILocale]: string;
|
|
@@ -128,7 +119,6 @@ export type IBLEFirmwareReleaseInfo = {
|
|
|
128
119
|
webUpdate: string;
|
|
129
120
|
fingerprint: string;
|
|
130
121
|
fingerprintWeb: string;
|
|
131
|
-
expectedSize?: number;
|
|
132
122
|
version: IVersionArray;
|
|
133
123
|
changelog: {
|
|
134
124
|
[k in ILocale]: string;
|