@onekeyfe/hd-core 1.2.0-alpha.69 → 1.2.0-alpha.70
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 +0 -28
- package/__tests__/connectSettings.test.ts +45 -5
- package/__tests__/device-initialize-timeout.test.ts +56 -0
- package/__tests__/firmware-update/check-all-firmware-release.test.ts +175 -0
- package/__tests__/firmware-update/device-update-bootloader.test.ts +87 -0
- package/__tests__/firmware-update/firmware-artifact-source.test.ts +119 -0
- package/__tests__/firmware-update/firmware-host-binding.test.ts +70 -0
- package/__tests__/firmware-update/firmware-preparation-error.test.ts +27 -0
- package/__tests__/firmware-update/firmware-update-bootloader-poll.test.ts +200 -0
- package/__tests__/firmware-update/firmware-update-capabilities.test.ts +13 -0
- package/__tests__/firmware-update/firmware-update-plan-bootloader-identity.test.ts +394 -0
- package/__tests__/firmware-update/firmware-update-plan.test.ts +593 -0
- package/__tests__/firmware-update/firmware-update-prepared-plan.test.ts +231 -0
- package/__tests__/firmware-update/firmware-update-v2-download-before-boot.test.ts +59 -31
- package/__tests__/firmware-update/firmware-update-v3-reconnect.test.ts +63 -0
- package/__tests__/firmware-update/firmware-upload-source.test.ts +70 -0
- package/__tests__/protocol-v2-firmware-targets.test.ts +1 -33
- package/__tests__/protocol-v2-resources.test.ts +6 -9
- package/__tests__/protocol-v2.test.ts +383 -174
- package/__tests__/protocolV2FileWrite.test.ts +7 -48
- package/dist/api/CheckAllFirmwareRelease.d.ts +1 -2
- package/dist/api/CheckAllFirmwareRelease.d.ts.map +1 -1
- package/dist/api/FirmwareUpdate.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV2.d.ts +10 -0
- package/dist/api/FirmwareUpdateV2.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV3.d.ts +7 -3
- package/dist/api/FirmwareUpdateV3.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV4.d.ts +25 -6
- package/dist/api/FirmwareUpdateV4.d.ts.map +1 -1
- package/dist/api/device/DeviceUpdateBootloader.d.ts +5 -1
- package/dist/api/device/DeviceUpdateBootloader.d.ts.map +1 -1
- package/dist/api/firmware/FirmwareArtifactSource.d.ts +25 -0
- package/dist/api/firmware/FirmwareArtifactSource.d.ts.map +1 -0
- package/dist/api/firmware/FirmwareHostBinding.d.ts +6 -0
- package/dist/api/firmware/FirmwareHostBinding.d.ts.map +1 -0
- package/dist/api/firmware/FirmwarePreparationError.d.ts +3 -0
- package/dist/api/firmware/FirmwarePreparationError.d.ts.map +1 -0
- package/dist/api/firmware/FirmwareUpdateBaseMethod.d.ts +8 -0
- package/dist/api/firmware/FirmwareUpdateBaseMethod.d.ts.map +1 -1
- package/dist/api/firmware/FirmwareUpdateCapabilities.d.ts +3 -0
- package/dist/api/firmware/FirmwareUpdateCapabilities.d.ts.map +1 -0
- package/dist/api/firmware/FirmwareUpdatePlan.d.ts +25 -0
- package/dist/api/firmware/FirmwareUpdatePlan.d.ts.map +1 -0
- package/dist/api/firmware/FirmwareUpdatePreparedPlan.d.ts +32 -0
- package/dist/api/firmware/FirmwareUpdatePreparedPlan.d.ts.map +1 -0
- package/dist/api/firmware/getBinary.d.ts +7 -0
- package/dist/api/firmware/getBinary.d.ts.map +1 -1
- package/dist/api/firmware/updateBootloader.d.ts +2 -0
- package/dist/api/firmware/updateBootloader.d.ts.map +1 -1
- package/dist/api/firmware/uploadFirmware.d.ts +9 -1
- package/dist/api/firmware/uploadFirmware.d.ts.map +1 -1
- package/dist/api/helpers/protocolV2FileWrite.d.ts.map +1 -1
- package/dist/api/stellar/StellarSignTransaction.d.ts +1 -1
- package/dist/data-manager/DataManager.d.ts +1 -0
- package/dist/data-manager/DataManager.d.ts.map +1 -1
- package/dist/data-manager/connectSettings.d.ts.map +1 -1
- package/dist/device/Device.d.ts +1 -0
- package/dist/device/Device.d.ts.map +1 -1
- package/dist/index.d.ts +180 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3038 -1041
- package/dist/inject.d.ts.map +1 -1
- package/dist/lowLevelInject.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/resources.d.ts +1 -1
- package/dist/protocols/protocol-v2/resources.d.ts.map +1 -1
- package/dist/topLevelInject.d.ts.map +1 -1
- package/dist/types/api/checkAllFirmwareRelease.d.ts +4 -0
- package/dist/types/api/checkAllFirmwareRelease.d.ts.map +1 -1
- package/dist/types/api/deviceUpdateBootloader.d.ts +6 -0
- package/dist/types/api/deviceUpdateBootloader.d.ts.map +1 -1
- package/dist/types/api/export.d.ts +4 -1
- package/dist/types/api/export.d.ts.map +1 -1
- package/dist/types/api/firmwareUpdate.d.ts +68 -0
- package/dist/types/api/firmwareUpdate.d.ts.map +1 -1
- package/dist/types/api/firmwareUpdateCapabilities.d.ts +9 -0
- package/dist/types/api/firmwareUpdateCapabilities.d.ts.map +1 -0
- package/dist/types/api/firmwareUpdatePlan.d.ts +28 -0
- package/dist/types/api/firmwareUpdatePlan.d.ts.map +1 -0
- package/dist/types/api/firmwareUpdatePreparedPlan.d.ts +42 -0
- package/dist/types/api/firmwareUpdatePreparedPlan.d.ts.map +1 -0
- package/dist/types/api/index.d.ts +9 -1
- package/dist/types/api/index.d.ts.map +1 -1
- package/dist/types/settings.d.ts +14 -1
- package/dist/types/settings.d.ts.map +1 -1
- package/dist/utils/deviceFeaturesCompat.d.ts +1 -0
- package/dist/utils/deviceFeaturesCompat.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/api/CheckAllFirmwareRelease.ts +61 -25
- package/src/api/FirmwareUpdate.ts +13 -1
- package/src/api/FirmwareUpdateV2.ts +296 -121
- package/src/api/FirmwareUpdateV3.ts +263 -57
- package/src/api/FirmwareUpdateV4.ts +865 -287
- package/src/api/device/DeviceUpdateBootloader.ts +125 -6
- package/src/api/firmware/FirmwareArtifactSource.ts +278 -0
- package/src/api/firmware/FirmwareHostBinding.ts +100 -0
- package/src/api/firmware/FirmwarePreparationError.ts +12 -0
- package/src/api/firmware/FirmwareUpdateBaseMethod.ts +72 -1
- package/src/api/firmware/FirmwareUpdateCapabilities.ts +9 -0
- package/src/api/firmware/FirmwareUpdatePlan.ts +772 -0
- package/src/api/firmware/FirmwareUpdatePreparedPlan.ts +449 -0
- package/src/api/firmware/updateBootloader.ts +19 -4
- package/src/api/firmware/uploadFirmware.ts +140 -22
- package/src/api/helpers/protocolV2FileWrite.ts +4 -54
- package/src/data-manager/DataManager.ts +62 -54
- package/src/data-manager/connectSettings.ts +11 -0
- package/src/device/Device.ts +6 -1
- package/src/index.ts +5 -0
- package/src/inject.ts +22 -2
- package/src/lowLevelInject.ts +5 -1
- package/src/protocols/protocol-v2/resources.ts +1 -5
- package/src/topLevelInject.ts +5 -1
- package/src/types/api/checkAllFirmwareRelease.ts +4 -0
- package/src/types/api/deviceUpdateBootloader.ts +6 -0
- package/src/types/api/export.ts +18 -0
- package/src/types/api/firmwareUpdate.ts +75 -0
- package/src/types/api/firmwareUpdateCapabilities.ts +9 -0
- package/src/types/api/firmwareUpdatePlan.ts +38 -0
- package/src/types/api/firmwareUpdatePreparedPlan.ts +53 -0
- package/src/types/api/index.ts +14 -0
- package/src/types/settings.ts +14 -2
- package/src/utils/deviceFeaturesCompat.ts +6 -0
package/src/lowLevelInject.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createCoreApi, createProtocolAwareCall } from './inject';
|
|
2
|
+
import { unregisterFirmwareUpdateHostBinding } from './api/firmware/FirmwareHostBinding';
|
|
2
3
|
|
|
3
4
|
import type { EventEmitter } from 'events';
|
|
4
5
|
import type { CallMethod, CoreMessage } from './events';
|
|
@@ -46,7 +47,10 @@ export const lowLevelInject = ({
|
|
|
46
47
|
|
|
47
48
|
setDeviceConnectProtocol: protocolAwareCall.setDeviceConnectProtocol,
|
|
48
49
|
|
|
49
|
-
dispose
|
|
50
|
+
dispose: async () => {
|
|
51
|
+
unregisterFirmwareUpdateHostBinding();
|
|
52
|
+
await dispose();
|
|
53
|
+
},
|
|
50
54
|
|
|
51
55
|
uiResponse,
|
|
52
56
|
|
|
@@ -17,7 +17,6 @@ export const PROTOCOL_V2_RESOURCE_TYPES = [
|
|
|
17
17
|
'translations',
|
|
18
18
|
'roobert',
|
|
19
19
|
'noto',
|
|
20
|
-
'firmware_logo',
|
|
21
20
|
] as const satisfies readonly IProtocolV2ResourceType[];
|
|
22
21
|
|
|
23
22
|
export const PROTOCOL_V2_RESOURCE_DEVICE_PATHS: Readonly<Record<IProtocolV2ResourceType, string>> =
|
|
@@ -28,7 +27,6 @@ export const PROTOCOL_V2_RESOURCE_DEVICE_PATHS: Readonly<Record<IProtocolV2Resou
|
|
|
28
27
|
translations: 'vol0:/bundles/translations/translations.okpkg',
|
|
29
28
|
roobert: 'vol0:/bundles/font/roobert.okpkg',
|
|
30
29
|
noto: 'vol0:/bundles/font/noto.okpkg',
|
|
31
|
-
firmware_logo: 'vol0:/bundles/firmware_logo.okpkg',
|
|
32
30
|
};
|
|
33
31
|
|
|
34
32
|
const RESOURCE_TYPE_SET = new Set<string>(PROTOCOL_V2_RESOURCE_TYPES);
|
|
@@ -315,9 +313,7 @@ export function parseProtocolV2Resources(value: unknown): IProtocolV2Resources |
|
|
|
315
313
|
const stable = config.stable.map(validateResource);
|
|
316
314
|
const types = new Set(stable.map(resource => resource.type));
|
|
317
315
|
if (stable.length !== PROTOCOL_V2_RESOURCE_TYPES.length || types.size !== stable.length) {
|
|
318
|
-
throw new Error(
|
|
319
|
-
`Invalid Pro2 resources config: stable must contain ${PROTOCOL_V2_RESOURCE_TYPES.length} unique resource types`
|
|
320
|
-
);
|
|
316
|
+
throw new Error('Invalid Pro2 resources config: stable must contain six unique resource types');
|
|
321
317
|
}
|
|
322
318
|
for (const type of PROTOCOL_V2_RESOURCE_TYPES) {
|
|
323
319
|
if (!types.has(type)) {
|
package/src/topLevelInject.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import EventEmitter from 'events';
|
|
2
2
|
|
|
3
3
|
import { createCoreApi, createProtocolAwareCall } from './inject';
|
|
4
|
+
import { unregisterFirmwareUpdateHostBinding } from './api/firmware/FirmwareHostBinding';
|
|
4
5
|
|
|
5
6
|
import type { ConnectSettings } from './types/settings';
|
|
6
7
|
import type { CoreApi } from './types/api';
|
|
@@ -49,7 +50,10 @@ export const topLevelInject = () => {
|
|
|
49
50
|
lowLevelApi?.removeAllListeners(type);
|
|
50
51
|
},
|
|
51
52
|
|
|
52
|
-
dispose: () =>
|
|
53
|
+
dispose: async () => {
|
|
54
|
+
unregisterFirmwareUpdateHostBinding();
|
|
55
|
+
await lowLevelApi?.dispose();
|
|
56
|
+
},
|
|
53
57
|
|
|
54
58
|
uiResponse: response => lowLevelApi?.uiResponse(response),
|
|
55
59
|
|
|
@@ -12,6 +12,7 @@ import type {
|
|
|
12
12
|
IProtocolV2FirmwareComponentTarget,
|
|
13
13
|
} from '../settings';
|
|
14
14
|
import type { FirmwareUpdateV4Target } from './firmwareUpdate';
|
|
15
|
+
import type { FirmwareUpdatePlan, FirmwareUpdatePlanForceTarget } from './firmwareUpdatePlan';
|
|
15
16
|
|
|
16
17
|
export type FirmwareRelease = {
|
|
17
18
|
shouldUpdate?: boolean;
|
|
@@ -64,12 +65,15 @@ export type AllFirmwareRelease = {
|
|
|
64
65
|
components?: ProtocolV2FirmwareComponentRelease[];
|
|
65
66
|
targetsToUpdate?: FirmwareUpdateV4Target[];
|
|
66
67
|
release?: IFirmwareReleaseInfo;
|
|
68
|
+
firmwareUpdatePlan?: FirmwareUpdatePlan;
|
|
67
69
|
};
|
|
68
70
|
|
|
69
71
|
export type CheckAllFirmwareReleaseParams = {
|
|
70
72
|
checkBridgeRelease?: boolean;
|
|
71
73
|
checkFirmwareHash?: boolean;
|
|
72
74
|
firmwareType?: EFirmwareType;
|
|
75
|
+
platform?: 'native' | 'desktop' | 'ext' | 'web' | 'web-embed';
|
|
76
|
+
forceUpdateTargets?: FirmwareUpdatePlanForceTarget[];
|
|
73
77
|
};
|
|
74
78
|
|
|
75
79
|
export declare function checkAllFirmwareRelease(
|
|
@@ -1,9 +1,15 @@
|
|
|
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';
|
|
3
5
|
import type { Response } from '../params';
|
|
4
6
|
|
|
5
7
|
export type DeviceUpdateBootloaderParams = {
|
|
8
|
+
preparedPlan?: FirmwareUpdatePreparedPlan;
|
|
9
|
+
hostBindingGeneration?: number;
|
|
6
10
|
binary?: ArrayBuffer;
|
|
11
|
+
artifact?: FirmwareArtifactReference;
|
|
12
|
+
artifactReader?: FirmwareArtifactReader;
|
|
7
13
|
firmwareType?: EFirmwareType;
|
|
8
14
|
};
|
|
9
15
|
|
package/src/types/api/export.ts
CHANGED
|
@@ -26,12 +26,30 @@ export type {
|
|
|
26
26
|
DeviceUploadResourceResponse,
|
|
27
27
|
} from './deviceUploadResource';
|
|
28
28
|
export type {
|
|
29
|
+
FirmwareArtifactReader,
|
|
30
|
+
FirmwareArtifactReference,
|
|
31
|
+
FirmwareUpdateHostBinding,
|
|
32
|
+
FirmwareUpdateArtifactParams,
|
|
29
33
|
FirmwareUpdateParams,
|
|
30
34
|
FirmwareUpdateBinaryParams,
|
|
31
35
|
FirmwareUpdateV3Params,
|
|
32
36
|
FirmwareUpdateV4Params,
|
|
33
37
|
FirmwareUpdateV4Target,
|
|
34
38
|
} from './firmwareUpdate';
|
|
39
|
+
export type {
|
|
40
|
+
FirmwareUpdatePlan,
|
|
41
|
+
FirmwareUpdatePlanArtifact,
|
|
42
|
+
FirmwareUpdatePlanArtifactRole,
|
|
43
|
+
FirmwareUpdatePlanForceTarget,
|
|
44
|
+
FirmwareUpdatePlanTarget,
|
|
45
|
+
} from './firmwareUpdatePlan';
|
|
46
|
+
export type {
|
|
47
|
+
FirmwareUpdatePreparedArtifact,
|
|
48
|
+
FirmwareUpdatePreparedArtifactInput,
|
|
49
|
+
FirmwareUpdatePreparedEntry,
|
|
50
|
+
FirmwareUpdatePreparedPlan,
|
|
51
|
+
} from './firmwareUpdatePreparedPlan';
|
|
52
|
+
export type { FirmwareUpdateCapabilities } from './firmwareUpdateCapabilities';
|
|
35
53
|
export type { AllFirmwareRelease } from './checkAllFirmwareRelease';
|
|
36
54
|
export type {
|
|
37
55
|
ProtocolV2FirmwareComponentRelease,
|
|
@@ -1,14 +1,52 @@
|
|
|
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';
|
|
4
5
|
|
|
5
6
|
type IUpdateType = 'firmware' | 'ble';
|
|
6
7
|
|
|
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
|
+
|
|
7
31
|
export interface FirmwareUpdateBinaryParams {
|
|
8
32
|
binary: ArrayBuffer;
|
|
9
33
|
updateType: IUpdateType;
|
|
10
34
|
}
|
|
11
35
|
|
|
36
|
+
export interface FirmwareUpdateArtifactParams {
|
|
37
|
+
preparedPlan: FirmwareUpdatePreparedPlan;
|
|
38
|
+
hostBindingGeneration: number;
|
|
39
|
+
artifact: FirmwareArtifactReference;
|
|
40
|
+
resourceEntries?: Array<{
|
|
41
|
+
entryName: string;
|
|
42
|
+
artifact: FirmwareArtifactReference;
|
|
43
|
+
}>;
|
|
44
|
+
updateType: IUpdateType;
|
|
45
|
+
forcedUpdateRes?: boolean;
|
|
46
|
+
isUpdateBootloader?: boolean;
|
|
47
|
+
firmwareType?: EFirmwareType;
|
|
48
|
+
}
|
|
49
|
+
|
|
12
50
|
export interface FirmwareUpdateParams {
|
|
13
51
|
version?: number[];
|
|
14
52
|
updateType: IUpdateType;
|
|
@@ -37,8 +75,14 @@ export declare function firmwareUpdateV2(
|
|
|
37
75
|
connectId: string | undefined,
|
|
38
76
|
params: Params<FirmwareUpdateBinaryParams & Platform>
|
|
39
77
|
): Response<PROTO.Success>;
|
|
78
|
+
export declare function firmwareUpdateV2(
|
|
79
|
+
connectId: string | undefined,
|
|
80
|
+
params: Params<FirmwareUpdateArtifactParams & Platform>
|
|
81
|
+
): Response<PROTO.Success>;
|
|
40
82
|
|
|
41
83
|
export interface FirmwareUpdateV3Params {
|
|
84
|
+
preparedPlan?: FirmwareUpdatePreparedPlan;
|
|
85
|
+
hostBindingGeneration?: number;
|
|
42
86
|
bleVersion?: number[];
|
|
43
87
|
bleBinary?: ArrayBuffer;
|
|
44
88
|
chunkSize?: number;
|
|
@@ -55,6 +99,17 @@ export interface FirmwareUpdateV3Params {
|
|
|
55
99
|
firmwareType?: EFirmwareType;
|
|
56
100
|
|
|
57
101
|
platform: IPlatform;
|
|
102
|
+
|
|
103
|
+
artifactReader?: FirmwareArtifactReader;
|
|
104
|
+
artifacts?: {
|
|
105
|
+
ble?: FirmwareArtifactReference;
|
|
106
|
+
firmware?: FirmwareArtifactReference;
|
|
107
|
+
bootloader?: FirmwareArtifactReference;
|
|
108
|
+
resourceEntries?: Array<{
|
|
109
|
+
entryName: string;
|
|
110
|
+
artifact: FirmwareArtifactReference;
|
|
111
|
+
}>;
|
|
112
|
+
};
|
|
58
113
|
}
|
|
59
114
|
|
|
60
115
|
/**
|
|
@@ -74,10 +129,14 @@ export type FirmwareUpdateV4Target =
|
|
|
74
129
|
| 'se04';
|
|
75
130
|
|
|
76
131
|
export interface FirmwareUpdateV4Params {
|
|
132
|
+
preparedPlan?: FirmwareUpdatePreparedPlan;
|
|
133
|
+
hostBindingGeneration?: number;
|
|
77
134
|
platform: IPlatform;
|
|
135
|
+
expectedDeviceId?: string;
|
|
78
136
|
chunkSize?: number;
|
|
79
137
|
firmwareType?: EFirmwareType;
|
|
80
138
|
targetsToUpdate?: FirmwareUpdateV4Target[];
|
|
139
|
+
expectedTargetVersions?: Partial<Record<FirmwareUpdateV4Target, string>>;
|
|
81
140
|
|
|
82
141
|
/** FW_MGMT_TARGET_ROMLOADER = 2; Pro2 cannot install it through firmwareUpdateV4. */
|
|
83
142
|
romloaderBinary?: ArrayBuffer;
|
|
@@ -105,8 +164,24 @@ export interface FirmwareUpdateV4Params {
|
|
|
105
164
|
size?: number;
|
|
106
165
|
fileHash?: string;
|
|
107
166
|
}>;
|
|
167
|
+
artifactReader?: FirmwareArtifactReader;
|
|
168
|
+
componentArtifacts?: Partial<
|
|
169
|
+
Record<Exclude<FirmwareUpdateV4Target, 'resource'>, FirmwareArtifactReference>
|
|
170
|
+
>;
|
|
171
|
+
resourceBundleArtifacts?: Array<{
|
|
172
|
+
name: string;
|
|
173
|
+
artifact: FirmwareArtifactReference;
|
|
174
|
+
}>;
|
|
108
175
|
}
|
|
109
176
|
|
|
177
|
+
export declare function registerFirmwareUpdateHostBinding(
|
|
178
|
+
binding: FirmwareUpdateHostBinding
|
|
179
|
+
): number;
|
|
180
|
+
|
|
181
|
+
export declare function unregisterFirmwareUpdateHostBinding(generation?: number): boolean;
|
|
182
|
+
|
|
183
|
+
export declare function getFirmwareUpdateHostBindingGeneration(): number;
|
|
184
|
+
|
|
110
185
|
export declare function firmwareUpdateV3(
|
|
111
186
|
connectId: string | undefined,
|
|
112
187
|
params: Params<FirmwareUpdateV3Params>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface FirmwareUpdateCapabilities {
|
|
2
|
+
planSchemaVersion: 2;
|
|
3
|
+
preparedPlanSchemaVersion: 2;
|
|
4
|
+
hostBindingProtocolVersion: 2;
|
|
5
|
+
manifestModes: Array<'external-only' | 'sdk-managed'>;
|
|
6
|
+
supportsArtifactReader: true;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export declare function getFirmwareUpdateCapabilities(): FirmwareUpdateCapabilities;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { FirmwareUpdateV4Target } from './firmwareUpdate';
|
|
2
|
+
import type { EFirmwareType } from '@onekeyfe/hd-shared';
|
|
3
|
+
|
|
4
|
+
export type FirmwareUpdatePlanArtifactRole =
|
|
5
|
+
| 'firmware'
|
|
6
|
+
| 'ble'
|
|
7
|
+
| 'bootloader'
|
|
8
|
+
| 'resource'
|
|
9
|
+
| 'component'
|
|
10
|
+
| 'resourceBundle';
|
|
11
|
+
|
|
12
|
+
export type FirmwareUpdatePlanTarget = 'firmware' | 'ble' | 'bootloader' | FirmwareUpdateV4Target;
|
|
13
|
+
|
|
14
|
+
export type FirmwareUpdatePlanForceTarget = 'firmware' | 'ble' | 'bootloader' | 'resource';
|
|
15
|
+
|
|
16
|
+
export interface FirmwareUpdatePlanArtifact {
|
|
17
|
+
artifactId: string;
|
|
18
|
+
role: FirmwareUpdatePlanArtifactRole;
|
|
19
|
+
target: FirmwareUpdatePlanTarget;
|
|
20
|
+
url: string;
|
|
21
|
+
container: 'raw' | 'zip';
|
|
22
|
+
logicalName?: string;
|
|
23
|
+
expectedSize?: number;
|
|
24
|
+
expectedSha256?: string;
|
|
25
|
+
targetVersion?: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface FirmwareUpdatePlan {
|
|
29
|
+
schemaVersion: 2;
|
|
30
|
+
planDigest: string;
|
|
31
|
+
executor: 'v2' | 'v3' | 'v4';
|
|
32
|
+
deviceIdentity: string;
|
|
33
|
+
deviceModel: string;
|
|
34
|
+
firmwareType: EFirmwareType;
|
|
35
|
+
platform: 'native' | 'desktop' | 'ext' | 'web' | 'web-embed';
|
|
36
|
+
artifacts: FirmwareUpdatePlanArtifact[];
|
|
37
|
+
targetsToUpdate: FirmwareUpdatePlanTarget[];
|
|
38
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { FirmwareArtifactReference } from './firmwareUpdate';
|
|
2
|
+
import type {
|
|
3
|
+
FirmwareUpdatePlan,
|
|
4
|
+
FirmwareUpdatePlanArtifactRole,
|
|
5
|
+
FirmwareUpdatePlanTarget,
|
|
6
|
+
} from './firmwareUpdatePlan';
|
|
7
|
+
|
|
8
|
+
export interface FirmwareUpdatePreparedEntry {
|
|
9
|
+
entryName: string;
|
|
10
|
+
artifact: FirmwareArtifactReference;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface FirmwareUpdatePreparedArtifactInput {
|
|
14
|
+
artifactId: string;
|
|
15
|
+
artifact: FirmwareArtifactReference;
|
|
16
|
+
materializedEntries?: FirmwareUpdatePreparedEntry[];
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface FirmwareUpdatePreparedArtifact {
|
|
20
|
+
artifactId: string;
|
|
21
|
+
role: FirmwareUpdatePlanArtifactRole;
|
|
22
|
+
target: FirmwareUpdatePlanTarget;
|
|
23
|
+
container: 'raw' | 'zip';
|
|
24
|
+
logicalName?: string;
|
|
25
|
+
targetVersion?: string;
|
|
26
|
+
artifact: FirmwareArtifactReference;
|
|
27
|
+
materializedEntries?: FirmwareUpdatePreparedEntry[];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface FirmwareUpdatePreparedPlan {
|
|
31
|
+
schemaVersion: 2;
|
|
32
|
+
preparedPlanDigest: string;
|
|
33
|
+
planDigest: string;
|
|
34
|
+
networkPolicy: 'forbid';
|
|
35
|
+
executor: FirmwareUpdatePlan['executor'];
|
|
36
|
+
deviceIdentity: string;
|
|
37
|
+
deviceModel: string;
|
|
38
|
+
firmwareType: FirmwareUpdatePlan['firmwareType'];
|
|
39
|
+
platform: FirmwareUpdatePlan['platform'];
|
|
40
|
+
leaseRef: string;
|
|
41
|
+
artifacts: FirmwareUpdatePreparedArtifact[];
|
|
42
|
+
targetsToUpdate: FirmwareUpdatePlanTarget[];
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export declare function prepareFirmwareUpdatePlan(input: {
|
|
46
|
+
plan: FirmwareUpdatePlan;
|
|
47
|
+
leaseRef: string;
|
|
48
|
+
artifacts: FirmwareUpdatePreparedArtifactInput[];
|
|
49
|
+
}): FirmwareUpdatePreparedPlan;
|
|
50
|
+
|
|
51
|
+
export declare function validateFirmwareUpdatePreparedPlan(
|
|
52
|
+
value: unknown
|
|
53
|
+
): FirmwareUpdatePreparedPlan;
|
package/src/types/api/index.ts
CHANGED
|
@@ -32,7 +32,15 @@ import type {
|
|
|
32
32
|
firmwareUpdateV2,
|
|
33
33
|
firmwareUpdateV3,
|
|
34
34
|
firmwareUpdateV4,
|
|
35
|
+
getFirmwareUpdateHostBindingGeneration,
|
|
36
|
+
registerFirmwareUpdateHostBinding,
|
|
37
|
+
unregisterFirmwareUpdateHostBinding,
|
|
35
38
|
} from './firmwareUpdate';
|
|
39
|
+
import type { getFirmwareUpdateCapabilities } from './firmwareUpdateCapabilities';
|
|
40
|
+
import type {
|
|
41
|
+
prepareFirmwareUpdatePlan,
|
|
42
|
+
validateFirmwareUpdatePreparedPlan,
|
|
43
|
+
} from './firmwareUpdatePreparedPlan';
|
|
36
44
|
import type { promptWebDeviceAccess } from './promptWebDeviceAccess';
|
|
37
45
|
import type { deviceReset } from './deviceReset';
|
|
38
46
|
import type { deviceRecovery } from './deviceRecovery';
|
|
@@ -239,6 +247,12 @@ export type CoreApi = {
|
|
|
239
247
|
firmwareUpdateV2: typeof firmwareUpdateV2;
|
|
240
248
|
firmwareUpdateV3: typeof firmwareUpdateV3;
|
|
241
249
|
firmwareUpdateV4: typeof firmwareUpdateV4;
|
|
250
|
+
registerFirmwareUpdateHostBinding: typeof registerFirmwareUpdateHostBinding;
|
|
251
|
+
unregisterFirmwareUpdateHostBinding: typeof unregisterFirmwareUpdateHostBinding;
|
|
252
|
+
getFirmwareUpdateHostBindingGeneration: typeof getFirmwareUpdateHostBindingGeneration;
|
|
253
|
+
getFirmwareUpdateCapabilities: typeof getFirmwareUpdateCapabilities;
|
|
254
|
+
prepareFirmwareUpdatePlan: typeof prepareFirmwareUpdatePlan;
|
|
255
|
+
validateFirmwareUpdatePreparedPlan: typeof validateFirmwareUpdatePreparedPlan;
|
|
242
256
|
cipherKeyValue: typeof cipherKeyValue;
|
|
243
257
|
|
|
244
258
|
/**
|
package/src/types/settings.ts
CHANGED
|
@@ -31,6 +31,8 @@ export type ConnectSettings = {
|
|
|
31
31
|
timestamp: number;
|
|
32
32
|
isFrame?: boolean;
|
|
33
33
|
preRelease?: boolean;
|
|
34
|
+
firmwareManifestMode?: 'sdk-managed' | 'external-only';
|
|
35
|
+
preloadedConfig?: RemoteConfigResponse;
|
|
34
36
|
fetchConfig?: boolean;
|
|
35
37
|
extension?: string;
|
|
36
38
|
configFetcher?: (url: string) => Promise<RemoteConfigResponse | null>;
|
|
@@ -58,6 +60,7 @@ export type IProtocolV2FirmwareComponent = {
|
|
|
58
60
|
fingerprint?: string;
|
|
59
61
|
/** OKPP payload hash, used to detect same-version package changes. */
|
|
60
62
|
payloadHash?: string;
|
|
63
|
+
expectedSize?: number;
|
|
61
64
|
version?: IVersionArray;
|
|
62
65
|
};
|
|
63
66
|
|
|
@@ -67,8 +70,7 @@ export type IProtocolV2ResourceType =
|
|
|
67
70
|
| 'wallpaper'
|
|
68
71
|
| 'translations'
|
|
69
72
|
| 'roobert'
|
|
70
|
-
| 'noto'
|
|
71
|
-
| 'firmware_logo';
|
|
73
|
+
| 'noto';
|
|
72
74
|
|
|
73
75
|
/** Pro2 RES package descriptor. Hashes identify content without a human-managed version. */
|
|
74
76
|
export type IProtocolV2Resource = {
|
|
@@ -111,6 +113,8 @@ export type IProtocolV2ResourceBundle = {
|
|
|
111
113
|
name: string;
|
|
112
114
|
/** Download URL. */
|
|
113
115
|
url: string;
|
|
116
|
+
fingerprint?: string;
|
|
117
|
+
expectedSize?: number;
|
|
114
118
|
/** Device target path, such as vol0:/bundles/images/images.okpkg. */
|
|
115
119
|
devicePath: string;
|
|
116
120
|
/** okpkg payload_version used to skip matching content after FileRead. */
|
|
@@ -132,10 +136,16 @@ export type IFirmwareReleaseInfo = {
|
|
|
132
136
|
firmwareType?: EFirmwareType;
|
|
133
137
|
/** Firmware UI resource */
|
|
134
138
|
resource?: string;
|
|
139
|
+
resourceFingerprint?: string;
|
|
140
|
+
resourceExpectedSize?: number;
|
|
135
141
|
/** Firmware full UI resource */
|
|
136
142
|
fullResource?: string;
|
|
143
|
+
fullResourceFingerprint?: string;
|
|
144
|
+
fullResourceExpectedSize?: number;
|
|
137
145
|
fullResourceRange?: string[];
|
|
138
146
|
bootloaderResource?: string;
|
|
147
|
+
bootloaderFingerprint?: string;
|
|
148
|
+
bootloaderExpectedSize?: number;
|
|
139
149
|
bootloaderVersion?: IVersionArray;
|
|
140
150
|
displayBootloaderVersion?: IVersionArray;
|
|
141
151
|
bootloaderRelatedFirmwareVersion?: IVersionArray;
|
|
@@ -148,6 +158,7 @@ export type IFirmwareReleaseInfo = {
|
|
|
148
158
|
[k in ILocale]: string;
|
|
149
159
|
};
|
|
150
160
|
fingerprint: string;
|
|
161
|
+
expectedSize?: number;
|
|
151
162
|
version: IVersionArray;
|
|
152
163
|
changelog: {
|
|
153
164
|
[k in ILocale]: string;
|
|
@@ -163,6 +174,7 @@ export type IBLEFirmwareReleaseInfo = {
|
|
|
163
174
|
webUpdate: string;
|
|
164
175
|
fingerprint: string;
|
|
165
176
|
fingerprintWeb: string;
|
|
177
|
+
expectedSize?: number;
|
|
166
178
|
version: IVersionArray;
|
|
167
179
|
changelog: {
|
|
168
180
|
[k in ILocale]: string;
|
|
@@ -37,6 +37,12 @@ export const resolveDeviceSerialNo = (features?: DeviceFeaturesInput): string =>
|
|
|
37
37
|
);
|
|
38
38
|
};
|
|
39
39
|
|
|
40
|
+
export const resolveDeviceBootloaderMode = (features?: DeviceFeaturesInput): boolean => {
|
|
41
|
+
if (!features) return false;
|
|
42
|
+
const compatible = asCompatibleFeatures(features);
|
|
43
|
+
return (compatible.bootloaderMode ?? compatible.bootloader_mode) === true;
|
|
44
|
+
};
|
|
45
|
+
|
|
40
46
|
export const resolveDeviceType = (features?: DeviceFeaturesInput): IDeviceType => {
|
|
41
47
|
if (!features || typeof features !== 'object') {
|
|
42
48
|
return EDeviceType.Unknown;
|