@onekeyfe/hd-core 1.2.0-alpha.41 → 1.2.0-alpha.43
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__/AllNetworkGetAddressBase.tracing.test.ts +78 -0
- package/__tests__/DeviceEventRegistration.test.ts +6 -0
- package/__tests__/check-all-firmware-release-protocol-v2.test.ts +14 -1
- package/__tests__/connectSettings.test.ts +5 -47
- package/__tests__/deviceUploadNft.test.ts +272 -0
- package/__tests__/firmware-update/firmware-update-v2-download-before-boot.test.ts +31 -59
- package/__tests__/get-device-state.test.ts +132 -12
- package/__tests__/homescreen.test.ts +41 -1
- package/__tests__/logBlockEvent.test.ts +1 -1
- package/__tests__/open-wallet-session.test.ts +366 -31
- package/__tests__/pro2Nft.test.ts +108 -0
- package/__tests__/protocol-v2-resources.test.ts +204 -0
- package/__tests__/protocol-v2-ui-lifecycle.test.ts +91 -0
- package/__tests__/protocol-v2-unlock-policy.test.ts +196 -35
- package/__tests__/protocol-v2.test.ts +568 -957
- package/__tests__/protocolV2UiInteraction.test.ts +63 -0
- package/__tests__/public-pro2-api-boundary.test.ts +1 -0
- package/__tests__/uiProgressThrottle.test.ts +74 -0
- package/dist/api/BaseMethod.d.ts +3 -1
- package/dist/api/BaseMethod.d.ts.map +1 -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 -25
- package/dist/api/FirmwareUpdateV4.d.ts.map +1 -1
- package/dist/api/GetPassphraseState.d.ts.map +1 -1
- package/dist/api/OpenWalletSession.d.ts.map +1 -1
- package/dist/api/allnetwork/AllNetworkGetAddressBase.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 -8
- 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/helpers/protocolV2FileWrite.d.ts +2 -0
- package/dist/api/helpers/protocolV2FileWrite.d.ts.map +1 -1
- package/dist/api/index.d.ts +1 -0
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/protocol-v2/DeviceUploadNft.d.ts +31 -0
- package/dist/api/protocol-v2/DeviceUploadNft.d.ts.map +1 -0
- package/dist/api/protocol-v2/ProtocolInfoRequest.d.ts.map +1 -1
- package/dist/api/stellar/StellarSignTransaction.d.ts +1 -1
- package/dist/core/deviceEventRegistration.d.ts +2 -0
- package/dist/core/deviceEventRegistration.d.ts.map +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/data-manager/DataManager.d.ts +3 -2
- 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 +24 -4
- package/dist/device/Device.d.ts.map +1 -1
- package/dist/device/DeviceCommands.d.ts +4 -4
- package/dist/events/device.d.ts +4 -0
- package/dist/events/device.d.ts.map +1 -1
- package/dist/events/logBlockEvent.d.ts.map +1 -1
- package/dist/events/ui-request.d.ts +28 -2
- package/dist/events/ui-request.d.ts.map +1 -1
- package/dist/index.d.ts +115 -184
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2051 -3349
- package/dist/inject.d.ts.map +1 -1
- package/dist/lowLevelInject.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/features.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/resources.d.ts +30 -0
- package/dist/protocols/protocol-v2/resources.d.ts.map +1 -0
- package/dist/protocols/protocol-v2/uiInteraction.d.ts +7 -4
- package/dist/protocols/protocol-v2/uiInteraction.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/unlockPolicy.d.ts +1 -3
- package/dist/protocols/protocol-v2/unlockPolicy.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/unlockPolicyRunner.d.ts +22 -0
- package/dist/protocols/protocol-v2/unlockPolicyRunner.d.ts.map +1 -0
- package/dist/protocols/protocol-v2/walletSession.d.ts +4 -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 +1 -4
- 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 +1 -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/protocolV2.d.ts +3 -0
- package/dist/types/api/protocolV2.d.ts.map +1 -1
- package/dist/types/settings.d.ts +12 -13
- package/dist/types/settings.d.ts.map +1 -1
- package/dist/utils/deviceFeaturesUtils.d.ts +2 -0
- package/dist/utils/deviceFeaturesUtils.d.ts.map +1 -1
- package/dist/utils/homescreen.d.ts +4 -0
- package/dist/utils/homescreen.d.ts.map +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/patch.d.ts +1 -1
- package/dist/utils/patch.d.ts.map +1 -1
- package/dist/utils/pro2Nft.d.ts +31 -0
- package/dist/utils/pro2Nft.d.ts.map +1 -0
- package/dist/utils/pro2Wallpaper.d.ts +10 -0
- package/dist/utils/pro2Wallpaper.d.ts.map +1 -1
- package/dist/utils/uiProgressThrottle.d.ts +3 -0
- package/dist/utils/uiProgressThrottle.d.ts.map +1 -0
- package/package.json +4 -4
- package/src/api/BaseMethod.ts +8 -10
- package/src/api/CheckAllFirmwareRelease.ts +40 -53
- package/src/api/FirmwareUpdateV2.ts +120 -298
- package/src/api/FirmwareUpdateV3.ts +57 -263
- package/src/api/FirmwareUpdateV4.ts +307 -912
- package/src/api/GetPassphraseState.ts +7 -1
- package/src/api/OpenWalletSession.ts +54 -17
- package/src/api/allnetwork/AllNetworkGetAddressBase.ts +32 -11
- package/src/api/device/DeviceUnlock.ts +1 -1
- package/src/api/device/DeviceUpdateBootloader.ts +6 -122
- package/src/api/firmware/FirmwareUpdateBaseMethod.ts +0 -57
- package/src/api/firmware/updateBootloader.ts +4 -19
- package/src/api/firmware/uploadFirmware.ts +22 -140
- package/src/api/helpers/protocolV2FileWrite.ts +11 -4
- package/src/api/index.ts +1 -0
- package/src/api/protocol-v2/DeviceUploadNft.ts +189 -0
- package/src/api/protocol-v2/ProtocolInfoRequest.ts +3 -1
- package/src/core/deviceEventRegistration.ts +4 -0
- package/src/core/index.ts +136 -77
- package/src/data/messages/messages-protocol-v2.json +68 -0
- package/src/data-manager/DataManager.ts +63 -38
- package/src/data-manager/connectSettings.ts +0 -11
- package/src/device/Device.ts +203 -21
- package/src/events/device.ts +4 -0
- package/src/events/logBlockEvent.ts +1 -0
- package/src/events/ui-request.ts +33 -2
- package/src/index.ts +0 -5
- package/src/inject.ts +3 -22
- package/src/lowLevelInject.ts +1 -5
- package/src/protocols/protocol-v2/features.ts +9 -2
- package/src/protocols/protocol-v2/resources.ts +233 -0
- package/src/protocols/protocol-v2/uiInteraction.ts +46 -6
- package/src/protocols/protocol-v2/unlockPolicy.ts +1 -105
- package/src/protocols/protocol-v2/unlockPolicyRunner.ts +124 -0
- package/src/protocols/protocol-v2/walletSession.ts +154 -30
- package/src/topLevelInject.ts +1 -5
- package/src/types/api/checkAllFirmwareRelease.ts +1 -4
- package/src/types/api/deviceUpdateBootloader.ts +0 -6
- package/src/types/api/export.ts +0 -18
- package/src/types/api/firmwareUpdate.ts +0 -76
- package/src/types/api/index.ts +2 -14
- package/src/types/api/protocolV2.ts +13 -0
- package/src/types/settings.ts +26 -13
- package/src/utils/deviceFeaturesUtils.ts +4 -0
- package/src/utils/homescreen.ts +32 -6
- package/src/utils/index.ts +6 -1
- package/src/utils/pro2Nft.ts +142 -0
- package/src/utils/pro2Wallpaper.ts +35 -8
- package/src/utils/uiProgressThrottle.ts +63 -0
- package/__tests__/firmware-update/check-all-firmware-release.test.ts +0 -175
- 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-update-v3-reconnect.test.ts +0 -58
- 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/api/firmware/progressThrottle.d.ts +0 -3
- package/dist/api/firmware/progressThrottle.d.ts.map +0 -1
- package/dist/protocols/protocol-v2/lockedError.d.ts +0 -2
- package/dist/protocols/protocol-v2/lockedError.d.ts.map +0 -1
- package/dist/protocols/protocol-v2/unlockRetry.d.ts +0 -10
- package/dist/protocols/protocol-v2/unlockRetry.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/api/firmware/progressThrottle.ts +0 -44
- package/src/protocols/protocol-v2/lockedError.ts +0 -10
- package/src/protocols/protocol-v2/unlockRetry.ts +0 -109
- package/src/types/api/firmwareUpdateCapabilities.ts +0 -9
- package/src/types/api/firmwareUpdatePlan.ts +0 -38
- package/src/types/api/firmwareUpdatePreparedPlan.ts +0 -53
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.43",
|
|
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.43",
|
|
29
|
+
"@onekeyfe/hd-transport": "1.2.0-alpha.43",
|
|
30
30
|
"axios": "1.15.2",
|
|
31
31
|
"bignumber.js": "^9.0.2",
|
|
32
32
|
"bytebuffer": "^5.0.1",
|
|
@@ -44,5 +44,5 @@
|
|
|
44
44
|
"@types/w3c-web-usb": "^1.0.10",
|
|
45
45
|
"@types/web-bluetooth": "^0.0.21"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "2ea7c9d60472502a272a57f808aed3773ccd84c4"
|
|
48
48
|
}
|
package/src/api/BaseMethod.ts
CHANGED
|
@@ -16,16 +16,14 @@ import { getBleFirmwareReleaseInfo, getFirmwareReleaseInfo } from './firmware/re
|
|
|
16
16
|
import { LoggerNames, getLogger } from '../utils';
|
|
17
17
|
import { generateInstanceId } from '../utils/tracing';
|
|
18
18
|
import { DeviceModelToTypes } from '../types';
|
|
19
|
-
import {
|
|
20
|
-
type UnlockPolicy,
|
|
21
|
-
getProtocolV2UnlockPolicy,
|
|
22
|
-
} from '../protocols/protocol-v2/unlockPolicy';
|
|
23
19
|
|
|
24
20
|
import type { Device } from '../device/Device';
|
|
25
21
|
import type DeviceConnector from '../device/DeviceConnector';
|
|
26
22
|
import type { DeviceFirmwareRange, KnownDevice } from '../types';
|
|
27
23
|
import type { CoreMessage } from '../events';
|
|
24
|
+
import type { UnlockPolicy } from '../protocols/protocol-v2/unlockPolicy';
|
|
28
25
|
import type { ProtocolV2InteractionDescriptor } from '../protocols/protocol-v2/uiInteraction';
|
|
26
|
+
import type { ProtocolV2UnlockContext } from '../protocols/protocol-v2/unlockPolicyRunner';
|
|
29
27
|
import type { RequestContext } from '../utils/tracing';
|
|
30
28
|
import type { CoreContext } from '../core';
|
|
31
29
|
|
|
@@ -128,9 +126,7 @@ export abstract class BaseMethod<Params = undefined> {
|
|
|
128
126
|
*/
|
|
129
127
|
checkDeviceId = false;
|
|
130
128
|
|
|
131
|
-
/**
|
|
132
|
-
* 该方法是否需要校验 passphrase state
|
|
133
|
-
*/
|
|
129
|
+
/** Whether the method requires wallet-session selection and Protocol V2 pre-unlock. */
|
|
134
130
|
useDevicePassphraseState = true;
|
|
135
131
|
|
|
136
132
|
/**
|
|
@@ -168,9 +164,12 @@ export abstract class BaseMethod<Params = undefined> {
|
|
|
168
164
|
*/
|
|
169
165
|
strictCheckDeviceSupport = false;
|
|
170
166
|
|
|
171
|
-
/**
|
|
167
|
+
/** Non-wallet methods may explicitly require Protocol V2 pre-unlock. */
|
|
172
168
|
unlockPolicy: UnlockPolicy = 'none';
|
|
173
169
|
|
|
170
|
+
/** Shared by composite methods so nested calls do not repeat the root preflight. */
|
|
171
|
+
protocolV2UnlockContext?: ProtocolV2UnlockContext;
|
|
172
|
+
|
|
174
173
|
getSupportedProtocols(): readonly ProtocolType[] {
|
|
175
174
|
return ['V1'];
|
|
176
175
|
}
|
|
@@ -188,7 +187,7 @@ export abstract class BaseMethod<Params = undefined> {
|
|
|
188
187
|
/** Non-blocking Protocol V2 interaction synthesized by the SDK. */
|
|
189
188
|
protocolV2UiInteraction?: ProtocolV2InteractionDescriptor;
|
|
190
189
|
|
|
191
|
-
/** Special background methods may suppress
|
|
190
|
+
/** Special background methods may suppress method-level Protocol V2 UI events. */
|
|
192
191
|
protocolV2UiMode: ProtocolV2UiMode = 'auto';
|
|
193
192
|
|
|
194
193
|
protected throwIfAborted() {
|
|
@@ -217,7 +216,6 @@ export abstract class BaseMethod<Params = undefined> {
|
|
|
217
216
|
this.useDevice = true;
|
|
218
217
|
this.allowDeviceMode = [UI_REQUEST.NOT_INITIALIZE];
|
|
219
218
|
this.requireDeviceMode = [];
|
|
220
|
-
this.unlockPolicy = getProtocolV2UnlockPolicy(this.name);
|
|
221
219
|
}
|
|
222
220
|
|
|
223
221
|
abstract init(): void;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { EFirmwareType, ERRORS,
|
|
1
|
+
import { EFirmwareType, ERRORS, HardwareErrorCode } from '@onekeyfe/hd-shared';
|
|
2
2
|
import semver from 'semver';
|
|
3
3
|
|
|
4
|
-
import { BaseMethod } from './BaseMethod';
|
|
5
4
|
import { UI_REQUEST } from '../constants/ui-request';
|
|
6
5
|
import { DataManager } from '../data-manager';
|
|
7
6
|
import {
|
|
@@ -9,18 +8,13 @@ import {
|
|
|
9
8
|
getBootloaderReleaseInfo,
|
|
10
9
|
getFirmwareReleaseInfo,
|
|
11
10
|
} from './firmware/releaseHelper';
|
|
12
|
-
import {
|
|
13
|
-
buildFirmwareUpdatePlan,
|
|
14
|
-
validateFirmwareUpdatePlanForceTargets,
|
|
15
|
-
} from './firmware/FirmwareUpdatePlan';
|
|
16
11
|
import { getBridgeReleaseInfo } from '../utils/bridgeUpdate';
|
|
12
|
+
import { getDeviceFirmwareVersion, getDeviceType, getFirmwareType } from '../utils';
|
|
13
|
+
import { BaseMethod } from './BaseMethod';
|
|
17
14
|
import {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
getFirmwareType,
|
|
22
|
-
getLogger,
|
|
23
|
-
} from '../utils';
|
|
15
|
+
buildProtocolV2ResourceUpdatePlan,
|
|
16
|
+
requestProtocolV2ResourceInventory,
|
|
17
|
+
} from '../protocols/protocol-v2/resources';
|
|
24
18
|
|
|
25
19
|
import type {
|
|
26
20
|
AllFirmwareRelease,
|
|
@@ -36,7 +30,6 @@ import type {
|
|
|
36
30
|
IProtocolV2FirmwareComponent,
|
|
37
31
|
IProtocolV2FirmwareComponentTarget,
|
|
38
32
|
} from '../types';
|
|
39
|
-
import type { FirmwareUpdatePlan } from '../types/api/firmwareUpdatePlan';
|
|
40
33
|
|
|
41
34
|
const UPDATE_TARGET_BY_COMPONENT_TARGET: Readonly<
|
|
42
35
|
Partial<Record<IProtocolV2FirmwareComponentTarget, FirmwareUpdateV4Target>>
|
|
@@ -230,9 +223,6 @@ export function buildProtocolV2FirmwareRelease({
|
|
|
230
223
|
const targetsToUpdate = components.flatMap(component =>
|
|
231
224
|
component.status === 'outdated' && component.updateTarget ? [component.updateTarget] : []
|
|
232
225
|
);
|
|
233
|
-
if (targetsToUpdate.length > 0 && release.resourceBundles?.length) {
|
|
234
|
-
targetsToUpdate.push('resource');
|
|
235
|
-
}
|
|
236
226
|
const uniqueTargetsToUpdate = Array.from(new Set(targetsToUpdate));
|
|
237
227
|
const hasUpgrade = uniqueTargetsToUpdate.length > 0;
|
|
238
228
|
const required = release.required && hasUpgrade;
|
|
@@ -257,8 +247,6 @@ export function buildProtocolV2FirmwareRelease({
|
|
|
257
247
|
};
|
|
258
248
|
}
|
|
259
249
|
|
|
260
|
-
const Log = getLogger(LoggerNames.Method);
|
|
261
|
-
|
|
262
250
|
export default class CheckAllFirmwareRelease extends BaseMethod {
|
|
263
251
|
getSupportedProtocols() {
|
|
264
252
|
return ['V1', 'V2'] as const;
|
|
@@ -276,13 +264,8 @@ export default class CheckAllFirmwareRelease extends BaseMethod {
|
|
|
276
264
|
}
|
|
277
265
|
|
|
278
266
|
const { features } = this.device;
|
|
279
|
-
const {
|
|
280
|
-
|
|
281
|
-
firmwareType: firmwareTypeParams,
|
|
282
|
-
platform,
|
|
283
|
-
forceUpdateTargets,
|
|
284
|
-
} = this.payload as CheckAllFirmwareReleaseParams;
|
|
285
|
-
const validatedForceUpdateTargets = validateFirmwareUpdatePlanForceTargets(forceUpdateTargets);
|
|
267
|
+
const { checkBridgeRelease, firmwareType: firmwareTypeParams } = this
|
|
268
|
+
.payload as CheckAllFirmwareReleaseParams;
|
|
286
269
|
|
|
287
270
|
if (!features) {
|
|
288
271
|
return Promise.resolve(null);
|
|
@@ -313,32 +296,6 @@ export default class CheckAllFirmwareRelease extends BaseMethod {
|
|
|
313
296
|
firmwareType,
|
|
314
297
|
});
|
|
315
298
|
const bleFirmwareReleaseInfo = getBleFirmwareReleaseInfo(features);
|
|
316
|
-
let firmwareUpdatePlan: FirmwareUpdatePlan | undefined;
|
|
317
|
-
try {
|
|
318
|
-
firmwareUpdatePlan = buildFirmwareUpdatePlan({
|
|
319
|
-
features,
|
|
320
|
-
firmwareType,
|
|
321
|
-
platform: platform ?? 'web',
|
|
322
|
-
firmware: firmwareRelease,
|
|
323
|
-
ble: bleFirmwareReleaseInfo,
|
|
324
|
-
bootloader: bootloaderRelease,
|
|
325
|
-
forceUpdateTargets: validatedForceUpdateTargets,
|
|
326
|
-
});
|
|
327
|
-
} catch (error) {
|
|
328
|
-
if (
|
|
329
|
-
validatedForceUpdateTargets.length > 0 ||
|
|
330
|
-
!(error instanceof HardwareError) ||
|
|
331
|
-
error.params?.firmwareUpdateCode !== 'FirmwarePlanInvalid'
|
|
332
|
-
) {
|
|
333
|
-
throw error;
|
|
334
|
-
}
|
|
335
|
-
// A Plan is an optional external-host capability. Release checks remain
|
|
336
|
-
// available for legacy and recovery flows when a Plan cannot be built.
|
|
337
|
-
Log.warn(
|
|
338
|
-
'[CheckAllFirmwareRelease] Optional firmware Plan is unavailable; using the legacy release result'
|
|
339
|
-
);
|
|
340
|
-
firmwareUpdatePlan = undefined;
|
|
341
|
-
}
|
|
342
299
|
|
|
343
300
|
return {
|
|
344
301
|
firmware: firmwareRelease,
|
|
@@ -353,8 +310,7 @@ export default class CheckAllFirmwareRelease extends BaseMethod {
|
|
|
353
310
|
}
|
|
354
311
|
: undefined,
|
|
355
312
|
features,
|
|
356
|
-
|
|
357
|
-
} as unknown as AllFirmwareRelease;
|
|
313
|
+
} as AllFirmwareRelease;
|
|
358
314
|
}
|
|
359
315
|
|
|
360
316
|
private async runProtocolV2(): Promise<AllFirmwareRelease> {
|
|
@@ -386,6 +342,34 @@ export default class CheckAllFirmwareRelease extends BaseMethod {
|
|
|
386
342
|
firmwareType,
|
|
387
343
|
release,
|
|
388
344
|
});
|
|
345
|
+
const resources = DataManager.getProtocolV2Resources();
|
|
346
|
+
let resourceStatus: 'valid' | 'outdated' | 'unknown' = 'unknown';
|
|
347
|
+
if (resources?.length) {
|
|
348
|
+
const loaderMode = state.status.mode === 'bootloader' || state.status.mode === 'romloader';
|
|
349
|
+
if (loaderMode) {
|
|
350
|
+
resourceStatus = buildProtocolV2ResourceUpdatePlan({
|
|
351
|
+
resources,
|
|
352
|
+
mode: 'bootloader-recovery',
|
|
353
|
+
}).status;
|
|
354
|
+
} else if (state.status.mode === 'normal') {
|
|
355
|
+
try {
|
|
356
|
+
const inventory = await requestProtocolV2ResourceInventory({
|
|
357
|
+
commands: this.device.getCommands(),
|
|
358
|
+
});
|
|
359
|
+
resourceStatus = buildProtocolV2ResourceUpdatePlan({
|
|
360
|
+
resources,
|
|
361
|
+
inventory,
|
|
362
|
+
mode: 'application',
|
|
363
|
+
}).status;
|
|
364
|
+
} catch {
|
|
365
|
+
resourceStatus = 'unknown';
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
const targetsToUpdate = [
|
|
370
|
+
...plan.targetsToUpdate,
|
|
371
|
+
...(resourceStatus === 'outdated' ? (['resource'] as const) : []),
|
|
372
|
+
];
|
|
389
373
|
const firmwareStatus = plan.status === 'unavailable' ? 'unknown' : plan.status;
|
|
390
374
|
const emptyRelease = 'none' as const;
|
|
391
375
|
|
|
@@ -408,6 +392,9 @@ export default class CheckAllFirmwareRelease extends BaseMethod {
|
|
|
408
392
|
protocol: 'V2',
|
|
409
393
|
deviceType: 'pro2',
|
|
410
394
|
...plan,
|
|
395
|
+
resourceStatus,
|
|
396
|
+
hasUpgrade: plan.hasUpgrade || resourceStatus === 'outdated',
|
|
397
|
+
targetsToUpdate,
|
|
411
398
|
};
|
|
412
399
|
}
|
|
413
400
|
}
|