@onekeyfe/hd-core 1.2.0-alpha.115 → 1.2.0-alpha.117
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__/DeviceCommands.test.ts +2 -2
- package/__tests__/device-lifecycle-events.test.ts +1 -1
- package/__tests__/device-state-mapper.test.ts +4 -4
- package/__tests__/device-utils.test.ts +1 -1
- package/__tests__/firmware-update/firmware-update-v4-install-poll.test.ts +36 -89
- package/__tests__/get-device-state.test.ts +8 -8
- package/__tests__/protocol-v2-resources.test.ts +20 -0
- package/__tests__/protocol-v2.test.ts +411 -246
- package/dist/api/FirmwareUpdateV4.d.ts +0 -3
- package/dist/api/FirmwareUpdateV4.d.ts.map +1 -1
- package/dist/api/protocol-v2/DeviceFirmwareUpdate.d.ts +3 -1
- package/dist/api/protocol-v2/DeviceFirmwareUpdate.d.ts.map +1 -1
- package/dist/api/protocol-v2/DeviceInfoGet.d.ts +1 -1
- package/dist/api/protocol-v2/DeviceInfoGet.d.ts.map +1 -1
- package/dist/index.d.ts +5 -20
- package/dist/index.js +191 -257
- package/dist/protocols/protocol-v2/features.d.ts +4 -4
- package/dist/protocols/protocol-v2/resources.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/unlockPolicyRunner.d.ts.map +1 -1
- package/dist/types/settings.d.ts +4 -19
- package/dist/types/settings.d.ts.map +1 -1
- package/dist/utils/patch.d.ts +1 -1
- package/dist/utils/patch.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/api/FirmwareUpdateV4.ts +170 -243
- package/src/api/protocol-v2/DeviceFactoryInfoSet.ts +1 -1
- package/src/api/protocol-v2/DeviceFirmwareUpdate.ts +6 -28
- package/src/api/protocol-v2/DeviceInfoGet.ts +3 -3
- package/src/data/messages/messages-protocol-v2.json +31 -14
- package/src/device/DeviceStateMapper.ts +15 -15
- package/src/deviceProfile/buildDeviceFeatures.ts +3 -3
- package/src/protocols/protocol-v2/features.ts +6 -6
- package/src/protocols/protocol-v2/resources.ts +10 -49
- package/src/protocols/protocol-v2/unlockPolicyRunner.ts +1 -0
- package/src/types/settings.ts +4 -19
|
@@ -1,14 +1,6 @@
|
|
|
1
1
|
import { BaseMethod } from '../BaseMethod';
|
|
2
|
-
import {
|
|
3
|
-
PROTOCOL_V2_FIRMWARE_UPDATE_OPTIONS,
|
|
4
|
-
PROTOCOL_V2_FIRMWARE_UPDATE_RESPONSE_TYPES,
|
|
5
|
-
isProtocolV2DeviceDisconnectedError,
|
|
6
|
-
normalizeFirmwareTargets,
|
|
7
|
-
} from './helpers';
|
|
8
|
-
import { UI_REQUEST, createUiMessage } from '../../events/ui-request';
|
|
2
|
+
import { isProtocolV2DeviceDisconnectedError, normalizeFirmwareTargets } from './helpers';
|
|
9
3
|
|
|
10
|
-
import type { KnownDevice } from '../../types';
|
|
11
|
-
import type { MessageFromOneKey } from '@onekeyfe/hd-transport';
|
|
12
4
|
import type { DeviceFirmwareUpdateParams } from './helpers';
|
|
13
5
|
|
|
14
6
|
export default class DeviceFirmwareUpdate extends BaseMethod<DeviceFirmwareUpdateParams> {
|
|
@@ -31,27 +23,13 @@ export default class DeviceFirmwareUpdate extends BaseMethod<DeviceFirmwareUpdat
|
|
|
31
23
|
async run() {
|
|
32
24
|
const targets = normalizeFirmwareTargets(this.params);
|
|
33
25
|
try {
|
|
34
|
-
|
|
26
|
+
await this.device.commands.typedCall('DeviceFirmwareUpdateStage', 'Success', { targets });
|
|
27
|
+
await this.device.commands.call(
|
|
35
28
|
'DeviceFirmwareUpdateRequest',
|
|
36
|
-
|
|
37
|
-
{
|
|
38
|
-
targets,
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
...PROTOCOL_V2_FIRMWARE_UPDATE_OPTIONS,
|
|
42
|
-
onIntermediateResponse: (response: MessageFromOneKey) => {
|
|
43
|
-
if (response.type !== 'DeviceFirmwareUpdateStatus') return;
|
|
44
|
-
this.postMessage(
|
|
45
|
-
createUiMessage(UI_REQUEST.FIRMWARE_PROGRESS, {
|
|
46
|
-
device: this.device.toMessageObject() as KnownDevice,
|
|
47
|
-
progress: 99,
|
|
48
|
-
progressType: 'installingFirmware',
|
|
49
|
-
})
|
|
50
|
-
);
|
|
51
|
-
},
|
|
52
|
-
}
|
|
29
|
+
{},
|
|
30
|
+
{ returnAfterWrite: true }
|
|
53
31
|
);
|
|
54
|
-
return
|
|
32
|
+
return { message: 'Device firmware update started' };
|
|
55
33
|
} catch (error) {
|
|
56
34
|
if (isProtocolV2DeviceDisconnectedError(error)) {
|
|
57
35
|
return {
|
|
@@ -5,7 +5,7 @@ import { invalidParameter } from '../helpers/filesystemValidation';
|
|
|
5
5
|
|
|
6
6
|
export type DeviceInfoGetTargets = {
|
|
7
7
|
hw?: boolean;
|
|
8
|
-
|
|
8
|
+
main_mcu?: boolean;
|
|
9
9
|
coprocessor?: boolean;
|
|
10
10
|
se1?: boolean;
|
|
11
11
|
se2?: boolean;
|
|
@@ -27,7 +27,7 @@ export type DeviceInfoGetParams = {
|
|
|
27
27
|
|
|
28
28
|
const TARGET_KEYS: (keyof DeviceInfoGetTargets)[] = [
|
|
29
29
|
'hw',
|
|
30
|
-
'
|
|
30
|
+
'main_mcu',
|
|
31
31
|
'coprocessor',
|
|
32
32
|
'se1',
|
|
33
33
|
'se2',
|
|
@@ -39,7 +39,7 @@ const TYPE_KEYS: (keyof DeviceInfoGetTypes)[] = ['version', 'build_id', 'hash',
|
|
|
39
39
|
|
|
40
40
|
const DEFAULT_TARGETS: DeviceInfoGetTargets = {
|
|
41
41
|
hw: true,
|
|
42
|
-
|
|
42
|
+
main_mcu: true,
|
|
43
43
|
coprocessor: true,
|
|
44
44
|
};
|
|
45
45
|
|
|
@@ -462,9 +462,10 @@
|
|
|
462
462
|
"MessageType_FilesystemDirMake": 60809,
|
|
463
463
|
"MessageType_FilesystemDirRemove": 60810,
|
|
464
464
|
"MessageType_FilesystemFormat": 60811,
|
|
465
|
-
"
|
|
466
|
-
"
|
|
467
|
-
"
|
|
465
|
+
"MessageType_DeviceFirmwareUpdateStage": 61000,
|
|
466
|
+
"MessageType_DeviceFirmwareUpdateRequest": 61001,
|
|
467
|
+
"MessageType_DeviceFirmwareUpdateStatusGet": 61002,
|
|
468
|
+
"MessageType_DeviceFirmwareUpdateStatus": 61003,
|
|
468
469
|
"MessageType_DeviceSessionGet": 61200,
|
|
469
470
|
"MessageType_DeviceSession": 61201,
|
|
470
471
|
"MessageType_DeviceSessionAskPin": 61202,
|
|
@@ -10924,7 +10925,7 @@
|
|
|
10924
10925
|
"type": "bytes",
|
|
10925
10926
|
"id": 1
|
|
10926
10927
|
},
|
|
10927
|
-
"
|
|
10928
|
+
"signning_message": {
|
|
10928
10929
|
"type": "bytes",
|
|
10929
10930
|
"id": 2
|
|
10930
10931
|
},
|
|
@@ -11813,14 +11814,14 @@
|
|
|
11813
11814
|
"type": "string",
|
|
11814
11815
|
"id": 2
|
|
11815
11816
|
},
|
|
11816
|
-
"burn_in_completed": {
|
|
11817
|
-
"type": "bool",
|
|
11818
|
-
"id": 3
|
|
11819
|
-
},
|
|
11820
11817
|
"factory_test_completed": {
|
|
11821
11818
|
"type": "bool",
|
|
11822
11819
|
"id": 4
|
|
11823
11820
|
},
|
|
11821
|
+
"factory_burn_in_completed": {
|
|
11822
|
+
"type": "bool",
|
|
11823
|
+
"id": 3
|
|
11824
|
+
},
|
|
11824
11825
|
"manufacture_time": {
|
|
11825
11826
|
"type": "DeviceFactoryInfoManufactureTime",
|
|
11826
11827
|
"id": 5
|
|
@@ -11906,7 +11907,7 @@
|
|
|
11906
11907
|
}
|
|
11907
11908
|
}
|
|
11908
11909
|
},
|
|
11909
|
-
"
|
|
11910
|
+
"DeviceFirmwareUpdateStage": {
|
|
11910
11911
|
"fields": {
|
|
11911
11912
|
"targets": {
|
|
11912
11913
|
"rule": "repeated",
|
|
@@ -11915,6 +11916,9 @@
|
|
|
11915
11916
|
}
|
|
11916
11917
|
}
|
|
11917
11918
|
},
|
|
11919
|
+
"DeviceFirmwareUpdateRequest": {
|
|
11920
|
+
"fields": {}
|
|
11921
|
+
},
|
|
11918
11922
|
"DeviceFirmwareUpdateRecord": {
|
|
11919
11923
|
"fields": {
|
|
11920
11924
|
"target_id": {
|
|
@@ -12096,7 +12100,7 @@
|
|
|
12096
12100
|
"type": "bool",
|
|
12097
12101
|
"id": 100
|
|
12098
12102
|
},
|
|
12099
|
-
"
|
|
12103
|
+
"main_mcu": {
|
|
12100
12104
|
"type": "bool",
|
|
12101
12105
|
"id": 200
|
|
12102
12106
|
},
|
|
@@ -12165,7 +12169,7 @@
|
|
|
12165
12169
|
"type": "DeviceHardwareInfo",
|
|
12166
12170
|
"id": 100
|
|
12167
12171
|
},
|
|
12168
|
-
"
|
|
12172
|
+
"main_mcu": {
|
|
12169
12173
|
"type": "DeviceMainMcuInfo",
|
|
12170
12174
|
"id": 200
|
|
12171
12175
|
},
|
|
@@ -12703,9 +12707,12 @@
|
|
|
12703
12707
|
"id": 1
|
|
12704
12708
|
},
|
|
12705
12709
|
"text": {
|
|
12706
|
-
"rule": "required",
|
|
12707
12710
|
"type": "string",
|
|
12708
12711
|
"id": 2
|
|
12712
|
+
},
|
|
12713
|
+
"text_id": {
|
|
12714
|
+
"type": "uint32",
|
|
12715
|
+
"id": 3
|
|
12709
12716
|
}
|
|
12710
12717
|
}
|
|
12711
12718
|
},
|
|
@@ -12736,7 +12743,6 @@
|
|
|
12736
12743
|
"ViewSignPage": {
|
|
12737
12744
|
"fields": {
|
|
12738
12745
|
"title": {
|
|
12739
|
-
"rule": "required",
|
|
12740
12746
|
"type": "string",
|
|
12741
12747
|
"id": 1
|
|
12742
12748
|
},
|
|
@@ -12770,13 +12776,16 @@
|
|
|
12770
12776
|
"options": {
|
|
12771
12777
|
"default": "LayoutDefault"
|
|
12772
12778
|
}
|
|
12779
|
+
},
|
|
12780
|
+
"title_id": {
|
|
12781
|
+
"type": "uint32",
|
|
12782
|
+
"id": 8
|
|
12773
12783
|
}
|
|
12774
12784
|
}
|
|
12775
12785
|
},
|
|
12776
12786
|
"ViewVerifyPage": {
|
|
12777
12787
|
"fields": {
|
|
12778
12788
|
"title": {
|
|
12779
|
-
"rule": "required",
|
|
12780
12789
|
"type": "string",
|
|
12781
12790
|
"id": 1
|
|
12782
12791
|
},
|
|
@@ -12801,6 +12810,14 @@
|
|
|
12801
12810
|
"value_key": {
|
|
12802
12811
|
"type": "uint32",
|
|
12803
12812
|
"id": 6
|
|
12813
|
+
},
|
|
12814
|
+
"title_id": {
|
|
12815
|
+
"type": "uint32",
|
|
12816
|
+
"id": 7
|
|
12817
|
+
},
|
|
12818
|
+
"chain_id": {
|
|
12819
|
+
"type": "uint32",
|
|
12820
|
+
"id": 8
|
|
12804
12821
|
}
|
|
12805
12822
|
}
|
|
12806
12823
|
},
|
|
@@ -267,11 +267,11 @@ export const mapProtocolV2DeviceInfoToState = (
|
|
|
267
267
|
}
|
|
268
268
|
: { mode },
|
|
269
269
|
versions: definedEntries({
|
|
270
|
-
firmware: imageVersion(info.
|
|
271
|
-
applicationP1: imageVersion(info.
|
|
272
|
-
applicationP2: imageVersion(info.
|
|
273
|
-
bootloader: imageVersion(info.
|
|
274
|
-
board: imageVersion(info.
|
|
270
|
+
firmware: imageVersion(info.main_mcu?.application),
|
|
271
|
+
applicationP1: imageVersion(info.main_mcu?.application),
|
|
272
|
+
applicationP2: imageVersion(info.main_mcu?.application_data),
|
|
273
|
+
bootloader: imageVersion(info.main_mcu?.bootloader),
|
|
274
|
+
board: imageVersion(info.main_mcu?.romloader),
|
|
275
275
|
ble: imageVersion(info.coprocessor?.application),
|
|
276
276
|
se01: imageVersion(info.se1?.application),
|
|
277
277
|
se02: imageVersion(info.se2?.application),
|
|
@@ -283,16 +283,16 @@ export const mapProtocolV2DeviceInfoToState = (
|
|
|
283
283
|
se04Boot: imageVersion(info.se4?.bootloader),
|
|
284
284
|
}),
|
|
285
285
|
verification: definedEntries({
|
|
286
|
-
firmwareBuildId: imageBuildId(info.
|
|
287
|
-
firmwareHash: imageHash(info.
|
|
288
|
-
applicationP1BuildId: imageBuildId(info.
|
|
289
|
-
applicationP1Hash: imageHash(info.
|
|
290
|
-
applicationP2BuildId: imageBuildId(info.
|
|
291
|
-
applicationP2Hash: imageHash(info.
|
|
292
|
-
bootloaderBuildId: imageBuildId(info.
|
|
293
|
-
bootloaderHash: imageHash(info.
|
|
294
|
-
boardBuildId: imageBuildId(info.
|
|
295
|
-
boardHash: imageHash(info.
|
|
286
|
+
firmwareBuildId: imageBuildId(info.main_mcu?.application),
|
|
287
|
+
firmwareHash: imageHash(info.main_mcu?.application),
|
|
288
|
+
applicationP1BuildId: imageBuildId(info.main_mcu?.application),
|
|
289
|
+
applicationP1Hash: imageHash(info.main_mcu?.application),
|
|
290
|
+
applicationP2BuildId: imageBuildId(info.main_mcu?.application_data),
|
|
291
|
+
applicationP2Hash: imageHash(info.main_mcu?.application_data),
|
|
292
|
+
bootloaderBuildId: imageBuildId(info.main_mcu?.bootloader),
|
|
293
|
+
bootloaderHash: imageHash(info.main_mcu?.bootloader),
|
|
294
|
+
boardBuildId: imageBuildId(info.main_mcu?.romloader),
|
|
295
|
+
boardHash: imageHash(info.main_mcu?.romloader),
|
|
296
296
|
bleBuildId: imageBuildId(info.coprocessor?.application),
|
|
297
297
|
bleHash: imageHash(info.coprocessor?.application),
|
|
298
298
|
se01BuildId: imageBuildId(info.se1?.application),
|
|
@@ -216,9 +216,9 @@ export const buildProtocolV2FeaturesPayload = ({
|
|
|
216
216
|
runtimeMode?: ProtocolV2RuntimeMode;
|
|
217
217
|
}): Features => {
|
|
218
218
|
const info = deviceInfo;
|
|
219
|
-
const fwApplication = info?.
|
|
220
|
-
const fwBootloader = info?.
|
|
221
|
-
const fwBoard = info?.
|
|
219
|
+
const fwApplication = info?.main_mcu?.application;
|
|
220
|
+
const fwBootloader = info?.main_mcu?.bootloader;
|
|
221
|
+
const fwBoard = info?.main_mcu?.romloader;
|
|
222
222
|
const bleApplication = info?.coprocessor?.application;
|
|
223
223
|
const status = deviceStatus;
|
|
224
224
|
const incomingSerialNo = info?.hw?.serial_no;
|
|
@@ -104,9 +104,9 @@ export const getProtocolV2RuntimeMode = (
|
|
|
104
104
|
if (binary === 'application') return 'normal';
|
|
105
105
|
if (binary) return binary;
|
|
106
106
|
|
|
107
|
-
if (isLegacyProtocolV2ProtocolInfo(protocolInfo) && !deviceInfo?.
|
|
108
|
-
if (deviceInfo?.
|
|
109
|
-
if (deviceInfo?.
|
|
107
|
+
if (isLegacyProtocolV2ProtocolInfo(protocolInfo) && !deviceInfo?.main_mcu?.application) {
|
|
108
|
+
if (deviceInfo?.main_mcu?.romloader) return 'romloader';
|
|
109
|
+
if (deviceInfo?.main_mcu?.bootloader) return 'bootloader';
|
|
110
110
|
}
|
|
111
111
|
return undefined;
|
|
112
112
|
};
|
|
@@ -122,7 +122,7 @@ export const supportsProtocolV2Message = (
|
|
|
122
122
|
export const PROTOCOL_V2_FEATURES_DEVICE_INFO_REQUEST = {
|
|
123
123
|
targets: {
|
|
124
124
|
hw: true,
|
|
125
|
-
|
|
125
|
+
main_mcu: true,
|
|
126
126
|
coprocessor: true,
|
|
127
127
|
},
|
|
128
128
|
types: {
|
|
@@ -138,7 +138,7 @@ export const PROTOCOL_V2_FEATURES_DEVICE_INFO_REQUEST = {
|
|
|
138
138
|
export const PROTOCOL_V2_VERSIONS_DEVICE_INFO_REQUEST = {
|
|
139
139
|
targets: {
|
|
140
140
|
hw: true,
|
|
141
|
-
|
|
141
|
+
main_mcu: true,
|
|
142
142
|
coprocessor: true,
|
|
143
143
|
se1: true,
|
|
144
144
|
se2: true,
|
|
@@ -154,7 +154,7 @@ export const PROTOCOL_V2_VERSIONS_DEVICE_INFO_REQUEST = {
|
|
|
154
154
|
export const PROTOCOL_V2_FULL_DEVICE_INFO_REQUEST = {
|
|
155
155
|
targets: {
|
|
156
156
|
hw: true,
|
|
157
|
-
|
|
157
|
+
main_mcu: true,
|
|
158
158
|
coprocessor: true,
|
|
159
159
|
se1: true,
|
|
160
160
|
se2: true,
|
|
@@ -107,10 +107,10 @@ function parseProtocolV2ResourceManifestFile(
|
|
|
107
107
|
}
|
|
108
108
|
const file = value as Partial<IProtocolV2ResourceManifestFile>;
|
|
109
109
|
const archivePath = assertManifestRelativePath(file.archive_path, `files[${index}].archive_path`);
|
|
110
|
-
const originalName =
|
|
111
|
-
file.original_name
|
|
112
|
-
|
|
113
|
-
|
|
110
|
+
const originalName =
|
|
111
|
+
file.original_name === undefined
|
|
112
|
+
? archivePath.split('/').pop() ?? archivePath
|
|
113
|
+
: assertManifestRelativePath(file.original_name, `files[${index}].original_name`);
|
|
114
114
|
if (originalName.includes('/')) {
|
|
115
115
|
throw new Error(`Invalid Pro2 resource manifest files[${index}].original_name`);
|
|
116
116
|
}
|
|
@@ -122,15 +122,6 @@ function parseProtocolV2ResourceManifestFile(
|
|
|
122
122
|
throw new Error(`Invalid Pro2 resource manifest files[${index}].size`);
|
|
123
123
|
}
|
|
124
124
|
const digest = normalizeHex(file.sha256, SHA256_HEX_LENGTH, `files[${index}].sha256`);
|
|
125
|
-
if (file.signed !== true) {
|
|
126
|
-
throw new Error(`Invalid Pro2 resource manifest files[${index}].signed`);
|
|
127
|
-
}
|
|
128
|
-
if (file.sig_algo !== 'ed25519' && file.sig_algo !== 'mldsa65') {
|
|
129
|
-
throw new Error(`Invalid Pro2 resource manifest files[${index}].sig_algo`);
|
|
130
|
-
}
|
|
131
|
-
if (file.payload_version !== null && typeof file.payload_version !== 'string') {
|
|
132
|
-
throw new Error(`Invalid Pro2 resource manifest files[${index}].payload_version`);
|
|
133
|
-
}
|
|
134
125
|
if (!archivePath.endsWith('.okpkg') || !originalName.endsWith('.okpkg')) {
|
|
135
126
|
throw new Error(`Invalid Pro2 resource manifest files[${index}] package extension`);
|
|
136
127
|
}
|
|
@@ -140,9 +131,9 @@ function parseProtocolV2ResourceManifestFile(
|
|
|
140
131
|
device_path: devicePath,
|
|
141
132
|
size: Number(file.size),
|
|
142
133
|
sha256: digest,
|
|
143
|
-
signed:
|
|
144
|
-
sig_algo: file.sig_algo,
|
|
145
|
-
payload_version: file.payload_version
|
|
134
|
+
...(file.signed === undefined ? {} : { signed: file.signed }),
|
|
135
|
+
...(file.sig_algo === undefined ? {} : { sig_algo: file.sig_algo }),
|
|
136
|
+
...(file.payload_version === undefined ? {} : { payload_version: file.payload_version }),
|
|
146
137
|
};
|
|
147
138
|
}
|
|
148
139
|
|
|
@@ -151,15 +142,8 @@ export function parseProtocolV2ResourceManifest(value: unknown): IProtocolV2Reso
|
|
|
151
142
|
throw new Error('Invalid Pro2 resource manifest');
|
|
152
143
|
}
|
|
153
144
|
const manifest = value as Partial<IProtocolV2ResourceManifest>;
|
|
154
|
-
if (
|
|
155
|
-
|
|
156
|
-
manifest.variant !== 'resource' ||
|
|
157
|
-
manifest.device_root !== 'vol0:' ||
|
|
158
|
-
manifest.restore_mode !== 'bootloader_update' ||
|
|
159
|
-
!Array.isArray(manifest.trees) ||
|
|
160
|
-
!Array.isArray(manifest.files)
|
|
161
|
-
) {
|
|
162
|
-
throw new Error('Invalid Pro2 resource manifest contract');
|
|
145
|
+
if (!Array.isArray(manifest.files)) {
|
|
146
|
+
throw new Error('Invalid Pro2 resource manifest files');
|
|
163
147
|
}
|
|
164
148
|
const files = manifest.files.map(parseProtocolV2ResourceManifestFile);
|
|
165
149
|
const devicePaths = new Set(files.map(file => file.device_path));
|
|
@@ -167,34 +151,11 @@ export function parseProtocolV2ResourceManifest(value: unknown): IProtocolV2Reso
|
|
|
167
151
|
if (
|
|
168
152
|
files.length === 0 ||
|
|
169
153
|
devicePaths.size !== files.length ||
|
|
170
|
-
archivePaths.size !== files.length
|
|
171
|
-
!devicePaths.has(PROTOCOL_V2_BOOT_RESOURCE_PACKAGE_PATH) ||
|
|
172
|
-
!files.some(file => file.device_path.startsWith('vol0:/bundles/'))
|
|
154
|
+
archivePaths.size !== files.length
|
|
173
155
|
) {
|
|
174
156
|
throw new Error('Invalid Pro2 resource manifest file set');
|
|
175
157
|
}
|
|
176
158
|
return {
|
|
177
|
-
schema: 1,
|
|
178
|
-
artifact_name: assertManifestString(manifest.artifact_name, 'artifact_name'),
|
|
179
|
-
release_name: assertManifestString(manifest.release_name, 'release_name'),
|
|
180
|
-
variant: 'resource',
|
|
181
|
-
commit: assertManifestString(manifest.commit, 'commit'),
|
|
182
|
-
short_sha: assertManifestString(manifest.short_sha, 'short_sha'),
|
|
183
|
-
timestamp_utc: assertManifestString(manifest.timestamp_utc, 'timestamp_utc'),
|
|
184
|
-
core_version: assertManifestString(manifest.core_version, 'core_version'),
|
|
185
|
-
key_set: assertManifestString(manifest.key_set, 'key_set'),
|
|
186
|
-
device_root: 'vol0:',
|
|
187
|
-
restore_mode: 'bootloader_update',
|
|
188
|
-
trees: manifest.trees.map((tree, index) => {
|
|
189
|
-
if (!tree || typeof tree !== 'object') {
|
|
190
|
-
throw new Error(`Invalid Pro2 resource manifest trees[${index}]`);
|
|
191
|
-
}
|
|
192
|
-
const item = tree as { path?: unknown; device?: unknown };
|
|
193
|
-
return {
|
|
194
|
-
path: assertManifestRelativePath(item.path, `trees[${index}].path`),
|
|
195
|
-
device: assertManifestString(item.device, `trees[${index}].device`),
|
|
196
|
-
};
|
|
197
|
-
}),
|
|
198
159
|
files,
|
|
199
160
|
};
|
|
200
161
|
}
|
|
@@ -80,6 +80,7 @@ export async function runMethodWithUnlockPolicy<T = unknown>(
|
|
|
80
80
|
const requiresPreUnlock =
|
|
81
81
|
device.isProtocolV2() &&
|
|
82
82
|
(method.useDevicePassphraseState || method.unlockPolicy === 'unlock-before-run') &&
|
|
83
|
+
device.state?.status.initialized !== false &&
|
|
83
84
|
!device.isBootloader?.() &&
|
|
84
85
|
!device.isRomloader?.();
|
|
85
86
|
|
package/src/types/settings.ts
CHANGED
|
@@ -76,31 +76,16 @@ export type IProtocolV2Resources = {
|
|
|
76
76
|
|
|
77
77
|
export type IProtocolV2ResourceManifestFile = {
|
|
78
78
|
archive_path: string;
|
|
79
|
-
original_name
|
|
79
|
+
original_name?: string;
|
|
80
80
|
device_path: string;
|
|
81
81
|
size: number;
|
|
82
82
|
sha256: string;
|
|
83
|
-
signed
|
|
84
|
-
sig_algo
|
|
85
|
-
payload_version
|
|
83
|
+
signed?: boolean;
|
|
84
|
+
sig_algo?: string;
|
|
85
|
+
payload_version?: string | null;
|
|
86
86
|
};
|
|
87
87
|
|
|
88
88
|
export type IProtocolV2ResourceManifest = {
|
|
89
|
-
schema: 1;
|
|
90
|
-
artifact_name: string;
|
|
91
|
-
release_name: string;
|
|
92
|
-
variant: 'resource';
|
|
93
|
-
commit: string;
|
|
94
|
-
short_sha: string;
|
|
95
|
-
timestamp_utc: string;
|
|
96
|
-
core_version: string;
|
|
97
|
-
key_set: string;
|
|
98
|
-
device_root: 'vol0:';
|
|
99
|
-
restore_mode: 'bootloader_update';
|
|
100
|
-
trees: Array<{
|
|
101
|
-
path: string;
|
|
102
|
-
device: string;
|
|
103
|
-
}>;
|
|
104
89
|
files: IProtocolV2ResourceManifestFile[];
|
|
105
90
|
};
|
|
106
91
|
|