@onekeyfe/hd-core 1.2.0-alpha.64 → 1.2.0-alpha.66
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 +313 -0
- package/__tests__/DeviceCommands.test.ts +59 -13
- package/__tests__/DeviceEventRegistration.test.ts +6 -0
- package/__tests__/check-all-firmware-release-protocol-v2.test.ts +198 -3
- package/__tests__/connectSettings.test.ts +5 -47
- package/__tests__/core-initialization.test.ts +23 -0
- package/__tests__/device-connector-protocol.test.ts +81 -0
- package/__tests__/device-lifecycle-events.test.ts +105 -3
- package/__tests__/device-pool-state.test.ts +22 -0
- package/__tests__/device-settings.test.ts +39 -18
- package/__tests__/device-state-contract.test.ts +1 -0
- package/__tests__/device-state-mapper.test.ts +13 -1
- package/__tests__/device-utils.test.ts +48 -1
- package/__tests__/deviceSettings.test.ts +11 -1
- package/__tests__/deviceUploadNft.test.ts +316 -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__/kaspa-use-tweak-pro2.test.ts +2 -2
- package/__tests__/kaspaSignTransaction.test.ts +3 -26
- package/__tests__/logBlockEvent.test.ts +1 -1
- package/__tests__/method-protocol-support.test.ts +19 -0
- package/__tests__/open-wallet-session.test.ts +568 -37
- package/__tests__/pro2Nft.test.ts +108 -0
- package/__tests__/protocol-binding.test.ts +89 -0
- package/__tests__/protocol-v2-resources.test.ts +340 -0
- package/__tests__/protocol-v2-ui-lifecycle.test.ts +91 -0
- package/__tests__/protocol-v2-unlock-policy.test.ts +300 -37
- package/__tests__/protocol-v2.test.ts +1506 -1097
- package/__tests__/protocolV2FileWrite.test.ts +152 -0
- package/__tests__/protocolV2UiInteraction.test.ts +63 -0
- package/__tests__/public-pro2-api-boundary.test.ts +1 -0
- package/__tests__/search-devices.test.ts +12 -3
- package/__tests__/tron-sign-message-init.test.ts +2 -2
- package/__tests__/uiProgressThrottle.test.ts +74 -0
- package/__tests__/uiPromiseRegistry.test.ts +115 -0
- package/dist/api/BaseMethod.d.ts +3 -1
- package/dist/api/BaseMethod.d.ts.map +1 -1
- package/dist/api/CheckAllFirmwareRelease.d.ts +2 -1
- package/dist/api/CheckAllFirmwareRelease.d.ts.map +1 -1
- package/dist/api/DetectDeviceConnectProtocol.d.ts +7 -0
- package/dist/api/DetectDeviceConnectProtocol.d.ts.map +1 -0
- package/dist/api/FirmwareUpdate.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 +13 -27
- 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/SearchDevices.d.ts.map +1 -1
- package/dist/api/allnetwork/AllNetworkGetAddressBase.d.ts.map +1 -1
- package/dist/api/device/DeviceSettings.d.ts.map +1 -1
- package/dist/api/device/DeviceUnlock.d.ts +2 -2
- package/dist/api/device/DeviceUnlock.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 +4 -11
- 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 +9 -0
- package/dist/api/helpers/protocolV2FileWrite.d.ts.map +1 -1
- package/dist/api/index.d.ts +2 -0
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/kaspa/KaspaGetAddress.d.ts +1 -1
- package/dist/api/kaspa/KaspaSignTransaction.d.ts +1 -1
- package/dist/api/kaspa/KaspaSignTransaction.d.ts.map +1 -1
- package/dist/api/polkadot/PolkadotGetAddress.d.ts +1 -1
- package/dist/api/polkadot/networks.d.ts +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/protocol-v2/helpers.d.ts.map +1 -1
- package/dist/api/solana/SolSignMessage.d.ts +1 -1
- package/dist/api/solana/SolSignOffchainMessage.d.ts +1 -1
- package/dist/api/solana/SolSignTransaction.d.ts +2 -2
- package/dist/api/stellar/StellarSignTransaction.d.ts +1 -1
- package/dist/api/sui/SuiGetAddress.d.ts +1 -1
- package/dist/api/sui/SuiGetPublicKey.d.ts +1 -1
- package/dist/api/sui/SuiSignMessage.d.ts +1 -1
- package/dist/api/sui/SuiSignTransaction.d.ts +1 -1
- package/dist/api/ton/TonGetAddress.d.ts +1 -1
- package/dist/api/ton/TonSignMessage.d.ts +1 -1
- package/dist/api/ton/TonSignProof.d.ts +1 -1
- package/dist/api/tron/TronSignMessage.d.ts +2 -2
- package/dist/api/tron/TronSignTransaction.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/core/uiPromiseRegistry.d.ts +6 -0
- package/dist/core/uiPromiseRegistry.d.ts.map +1 -0
- package/dist/data-manager/DataManager.d.ts +9 -4
- package/dist/data-manager/DataManager.d.ts.map +1 -1
- package/dist/data-manager/TransportManager.d.ts.map +1 -1
- package/dist/data-manager/connectSettings.d.ts.map +1 -1
- package/dist/device/Device.d.ts +29 -6
- package/dist/device/Device.d.ts.map +1 -1
- package/dist/device/DeviceCommands.d.ts +4 -4
- package/dist/device/DeviceCommands.d.ts.map +1 -1
- package/dist/device/DeviceConnector.d.ts +2 -1
- package/dist/device/DeviceConnector.d.ts.map +1 -1
- package/dist/device/DevicePool.d.ts.map +1 -1
- package/dist/deviceProfile/protocolV2DeviceIdentity.d.ts.map +1 -1
- 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-promise.d.ts +4 -2
- package/dist/events/ui-promise.d.ts.map +1 -1
- package/dist/events/ui-request.d.ts +31 -2
- package/dist/events/ui-request.d.ts.map +1 -1
- package/dist/events/ui-response.d.ts +10 -2
- package/dist/events/ui-response.d.ts.map +1 -1
- package/dist/index.d.ts +243 -248
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3051 -3774
- package/dist/inject.d.ts +6 -1
- package/dist/inject.d.ts.map +1 -1
- package/dist/lowLevelInject.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/features.d.ts +0 -4
- package/dist/protocols/protocol-v2/features.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/firmware.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 +6 -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 +3 -5
- package/dist/types/api/checkAllFirmwareRelease.d.ts.map +1 -1
- package/dist/types/api/detectDeviceConnectProtocol.d.ts +4 -0
- package/dist/types/api/detectDeviceConnectProtocol.d.ts.map +1 -0
- package/dist/types/api/deviceUnlock.d.ts +5 -1
- package/dist/types/api/deviceUnlock.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 +4 -71
- package/dist/types/api/firmwareUpdate.d.ts.map +1 -1
- package/dist/types/api/index.d.ts +7 -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/device.d.ts +2 -2
- package/dist/types/device.d.ts.map +1 -1
- package/dist/types/params.d.ts +1 -0
- package/dist/types/params.d.ts.map +1 -1
- package/dist/types/settings.d.ts +38 -21
- package/dist/types/settings.d.ts.map +1 -1
- package/dist/utils/deviceFeaturesCompat.d.ts +0 -1
- package/dist/utils/deviceFeaturesCompat.d.ts.map +1 -1
- package/dist/utils/deviceFeaturesUtils.d.ts +4 -0
- package/dist/utils/deviceFeaturesUtils.d.ts.map +1 -1
- package/dist/utils/deviceInfoUtils.d.ts.map +1 -1
- package/dist/utils/deviceSettings.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 +59 -60
- package/src/api/DetectDeviceConnectProtocol.ts +18 -0
- package/src/api/FirmwareUpdate.ts +7 -15
- package/src/api/FirmwareUpdateV2.ts +126 -316
- package/src/api/FirmwareUpdateV3.ts +63 -265
- package/src/api/FirmwareUpdateV4.ts +597 -1005
- package/src/api/GetPassphraseState.ts +7 -1
- package/src/api/OpenWalletSession.ts +71 -17
- package/src/api/SearchDevices.ts +3 -1
- package/src/api/allnetwork/AllNetworkGetAddress.ts +21 -21
- package/src/api/allnetwork/AllNetworkGetAddressBase.ts +36 -11
- package/src/api/device/DeviceSettings.ts +5 -4
- package/src/api/device/DeviceUnlock.ts +8 -3
- package/src/api/device/DeviceUpdateBootloader.ts +6 -125
- package/src/api/firmware/FirmwareUpdateBaseMethod.ts +27 -83
- package/src/api/firmware/updateBootloader.ts +4 -19
- package/src/api/firmware/uploadFirmware.ts +39 -144
- package/src/api/helpers/protocolV2FileWrite.ts +202 -63
- package/src/api/index.ts +2 -0
- package/src/api/kaspa/KaspaGetAddress.ts +1 -1
- package/src/api/kaspa/KaspaSignTransaction.ts +2 -13
- package/src/api/polkadot/networks.ts +3 -3
- package/src/api/protocol-v2/DeviceUploadNft.ts +197 -0
- package/src/api/protocol-v2/ProtocolInfoRequest.ts +3 -1
- package/src/api/protocol-v2/helpers.ts +1 -1
- package/src/api/solana/SolSignMessage.ts +1 -1
- package/src/api/solana/SolSignOffchainMessage.ts +1 -1
- package/src/api/solana/SolSignTransaction.ts +2 -2
- package/src/api/sui/SuiGetAddress.ts +1 -1
- package/src/api/sui/SuiGetPublicKey.ts +1 -1
- package/src/api/sui/SuiSignMessage.ts +1 -1
- package/src/api/sui/SuiSignTransaction.ts +1 -1
- package/src/api/ton/TonGetAddress.ts +1 -1
- package/src/api/ton/TonSignMessage.ts +1 -1
- package/src/api/ton/TonSignProof.ts +1 -1
- package/src/api/tron/TronSignMessage.ts +2 -2
- package/src/api/tron/TronSignTransaction.ts +1 -1
- package/src/core/deviceEventRegistration.ts +4 -0
- package/src/core/index.ts +213 -111
- package/src/core/uiPromiseRegistry.ts +63 -0
- package/src/data/messages/messages-protocol-v2.json +25 -0
- package/src/data-manager/DataManager.ts +113 -41
- package/src/data-manager/TransportManager.ts +6 -0
- package/src/data-manager/connectSettings.ts +0 -11
- package/src/device/Device.ts +274 -49
- package/src/device/DeviceCommands.ts +31 -4
- package/src/device/DeviceConnector.ts +33 -13
- package/src/device/DevicePool.ts +21 -7
- package/src/deviceProfile/buildDeviceFeatures.ts +2 -2
- package/src/deviceProfile/protocolV2DeviceIdentity.ts +3 -0
- package/src/events/device.ts +4 -0
- package/src/events/logBlockEvent.ts +1 -0
- package/src/events/ui-promise.ts +4 -2
- package/src/events/ui-request.ts +36 -2
- package/src/events/ui-response.ts +12 -2
- package/src/index.ts +0 -5
- package/src/inject.ts +60 -24
- package/src/lowLevelInject.ts +7 -8
- package/src/protocols/protocol-v2/features.ts +10 -7
- package/src/protocols/protocol-v2/firmware.ts +2 -0
- package/src/protocols/protocol-v2/resources.ts +390 -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 +131 -0
- package/src/protocols/protocol-v2/walletSession.ts +214 -36
- package/src/topLevelInject.ts +7 -8
- package/src/types/api/checkAllFirmwareRelease.ts +3 -5
- package/src/types/api/detectDeviceConnectProtocol.ts +6 -0
- package/src/types/api/deviceUnlock.ts +12 -1
- package/src/types/api/deviceUpdateBootloader.ts +0 -6
- package/src/types/api/export.ts +1 -18
- package/src/types/api/firmwareUpdate.ts +6 -79
- package/src/types/api/index.ts +13 -14
- package/src/types/api/protocolV2.ts +13 -0
- package/src/types/device.ts +15 -3
- package/src/types/params.ts +7 -1
- package/src/types/settings.ts +60 -22
- package/src/utils/deviceFeaturesCompat.ts +5 -6
- package/src/utils/deviceFeaturesUtils.ts +14 -3
- package/src/utils/deviceInfoUtils.ts +2 -0
- package/src/utils/deviceSettings.ts +3 -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__/device-initialize-timeout.test.ts +0 -56
- 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-bootloader-poll.test.ts +0 -200
- package/__tests__/firmware-update/firmware-update-capabilities.test.ts +0 -13
- package/__tests__/firmware-update/firmware-update-plan-bootloader-identity.test.ts +0 -394
- 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 -32
- 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 -772
- package/src/api/firmware/FirmwareUpdatePreparedPlan.ts +0 -449
- 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
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { EFirmwareType, ERRORS,
|
|
1
|
+
import { EDeviceType, 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
|
+
readProtocolV2ResourceInventory,
|
|
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>>
|
|
@@ -101,6 +94,7 @@ function buildComponentRelease({
|
|
|
101
94
|
component,
|
|
102
95
|
currentVersions,
|
|
103
96
|
currentVerification,
|
|
97
|
+
checkFirmwareHash,
|
|
104
98
|
remotePayloadHash,
|
|
105
99
|
releaseRequired,
|
|
106
100
|
}: {
|
|
@@ -108,6 +102,7 @@ function buildComponentRelease({
|
|
|
108
102
|
component: IProtocolV2FirmwareComponent;
|
|
109
103
|
currentVersions: DeviceStateVersions;
|
|
110
104
|
currentVerification: Partial<DeviceFeaturesVerify>;
|
|
105
|
+
checkFirmwareHash: boolean;
|
|
111
106
|
remotePayloadHash: string | null | undefined;
|
|
112
107
|
releaseRequired: boolean;
|
|
113
108
|
}): ProtocolV2FirmwareComponentRelease {
|
|
@@ -136,7 +131,7 @@ function buildComponentRelease({
|
|
|
136
131
|
status = 'valid';
|
|
137
132
|
} else {
|
|
138
133
|
const currentHashKey = CURRENT_HASH_BY_COMPONENT_TARGET[componentTarget];
|
|
139
|
-
if (!currentHashKey) {
|
|
134
|
+
if (!checkFirmwareHash || !currentHashKey) {
|
|
140
135
|
status = 'valid';
|
|
141
136
|
} else {
|
|
142
137
|
const currentHash = normalizeHex(currentVerification[currentHashKey]);
|
|
@@ -175,12 +170,14 @@ type ProtocolV2FirmwareReleasePlan = {
|
|
|
175
170
|
export function buildProtocolV2FirmwareRelease({
|
|
176
171
|
currentVersions,
|
|
177
172
|
currentVerification = {},
|
|
173
|
+
checkFirmwareHash = false,
|
|
178
174
|
remotePayloadHashes = {},
|
|
179
175
|
firmwareType,
|
|
180
176
|
release,
|
|
181
177
|
}: {
|
|
182
178
|
currentVersions: DeviceStateVersions;
|
|
183
179
|
currentVerification?: Partial<DeviceFeaturesVerify>;
|
|
180
|
+
checkFirmwareHash?: boolean;
|
|
184
181
|
remotePayloadHashes?: Readonly<Record<string, string | null>>;
|
|
185
182
|
firmwareType: EFirmwareType;
|
|
186
183
|
release: IFirmwareReleaseInfo | undefined;
|
|
@@ -204,6 +201,7 @@ export function buildProtocolV2FirmwareRelease({
|
|
|
204
201
|
component,
|
|
205
202
|
currentVersions,
|
|
206
203
|
currentVerification,
|
|
204
|
+
checkFirmwareHash,
|
|
207
205
|
remotePayloadHash: Object.prototype.hasOwnProperty.call(remotePayloadHashes, configKey)
|
|
208
206
|
? remotePayloadHashes[configKey]
|
|
209
207
|
: normalizeHex(component.payloadHash),
|
|
@@ -230,9 +228,6 @@ export function buildProtocolV2FirmwareRelease({
|
|
|
230
228
|
const targetsToUpdate = components.flatMap(component =>
|
|
231
229
|
component.status === 'outdated' && component.updateTarget ? [component.updateTarget] : []
|
|
232
230
|
);
|
|
233
|
-
if (targetsToUpdate.length > 0 && release.resourceBundles?.length) {
|
|
234
|
-
targetsToUpdate.push('resource');
|
|
235
|
-
}
|
|
236
231
|
const uniqueTargetsToUpdate = Array.from(new Set(targetsToUpdate));
|
|
237
232
|
const hasUpgrade = uniqueTargetsToUpdate.length > 0;
|
|
238
233
|
const required = release.required && hasUpgrade;
|
|
@@ -257,8 +252,6 @@ export function buildProtocolV2FirmwareRelease({
|
|
|
257
252
|
};
|
|
258
253
|
}
|
|
259
254
|
|
|
260
|
-
const Log = getLogger(LoggerNames.Method);
|
|
261
|
-
|
|
262
255
|
export default class CheckAllFirmwareRelease extends BaseMethod {
|
|
263
256
|
getSupportedProtocols() {
|
|
264
257
|
return ['V1', 'V2'] as const;
|
|
@@ -276,13 +269,8 @@ export default class CheckAllFirmwareRelease extends BaseMethod {
|
|
|
276
269
|
}
|
|
277
270
|
|
|
278
271
|
const { features } = this.device;
|
|
279
|
-
const {
|
|
280
|
-
|
|
281
|
-
firmwareType: firmwareTypeParams,
|
|
282
|
-
platform,
|
|
283
|
-
forceUpdateTargets,
|
|
284
|
-
} = this.payload as CheckAllFirmwareReleaseParams;
|
|
285
|
-
const validatedForceUpdateTargets = validateFirmwareUpdatePlanForceTargets(forceUpdateTargets);
|
|
272
|
+
const { checkBridgeRelease, firmwareType: firmwareTypeParams } = this
|
|
273
|
+
.payload as CheckAllFirmwareReleaseParams;
|
|
286
274
|
|
|
287
275
|
if (!features) {
|
|
288
276
|
return Promise.resolve(null);
|
|
@@ -313,32 +301,6 @@ export default class CheckAllFirmwareRelease extends BaseMethod {
|
|
|
313
301
|
firmwareType,
|
|
314
302
|
});
|
|
315
303
|
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
304
|
|
|
343
305
|
return {
|
|
344
306
|
firmware: firmwareRelease,
|
|
@@ -353,18 +315,21 @@ export default class CheckAllFirmwareRelease extends BaseMethod {
|
|
|
353
315
|
}
|
|
354
316
|
: undefined,
|
|
355
317
|
features,
|
|
356
|
-
|
|
357
|
-
} as unknown as AllFirmwareRelease;
|
|
318
|
+
} as AllFirmwareRelease;
|
|
358
319
|
}
|
|
359
320
|
|
|
360
321
|
private async runProtocolV2(): Promise<AllFirmwareRelease> {
|
|
322
|
+
const { checkFirmwareHash = false, firmwareType: firmwareTypeParam } = this
|
|
323
|
+
.payload as CheckAllFirmwareReleaseParams;
|
|
361
324
|
const state = await this.device.getDeviceState({
|
|
362
|
-
refreshSections:
|
|
325
|
+
refreshSections: checkFirmwareHash
|
|
326
|
+
? ['identity', 'versions', 'verification']
|
|
327
|
+
: ['identity', 'versions'],
|
|
363
328
|
});
|
|
364
|
-
if (state.identity.deviceType !== 'pro2') {
|
|
329
|
+
if (state.identity.deviceType !== 'pro2' && state.identity.deviceType !== 'neo') {
|
|
365
330
|
throw ERRORS.TypedError(
|
|
366
331
|
HardwareErrorCode.DeviceNotSupportMethod,
|
|
367
|
-
'checkAllFirmwareRelease requires a Pro2 device for Protocol V2'
|
|
332
|
+
'checkAllFirmwareRelease requires a Pro2 or Neo device for Protocol V2'
|
|
368
333
|
);
|
|
369
334
|
}
|
|
370
335
|
|
|
@@ -376,16 +341,47 @@ export default class CheckAllFirmwareRelease extends BaseMethod {
|
|
|
376
341
|
);
|
|
377
342
|
}
|
|
378
343
|
|
|
379
|
-
const { firmwareType: firmwareTypeParam } = this.payload as CheckAllFirmwareReleaseParams;
|
|
380
344
|
const firmwareType =
|
|
381
345
|
firmwareTypeParam ?? state.identity.firmwareType ?? EFirmwareType.Universal;
|
|
382
346
|
const release = DataManager.getFirmwareLatestRelease(features, firmwareType);
|
|
383
347
|
const plan = buildProtocolV2FirmwareRelease({
|
|
384
348
|
currentVersions: state.versions,
|
|
385
|
-
currentVerification: state.verification,
|
|
349
|
+
currentVerification: checkFirmwareHash ? state.verification : undefined,
|
|
350
|
+
checkFirmwareHash,
|
|
386
351
|
firmwareType,
|
|
387
352
|
release,
|
|
388
353
|
});
|
|
354
|
+
const resourceDeviceType =
|
|
355
|
+
state.identity.deviceType === 'neo' ? EDeviceType.Neo : EDeviceType.Pro2;
|
|
356
|
+
const resources = DataManager.getProtocolV2Resources(resourceDeviceType);
|
|
357
|
+
let resourceStatus: 'valid' | 'outdated' | 'unknown' = 'unknown';
|
|
358
|
+
if (resources?.length) {
|
|
359
|
+
const loaderMode = state.status.mode === 'bootloader' || state.status.mode === 'romloader';
|
|
360
|
+
// Application mode rejects host access to vol0:/bundles. Resource inventory is
|
|
361
|
+
// resolved after FirmwareUpdateV4 enters a loader instead of probing here.
|
|
362
|
+
if (loaderMode) {
|
|
363
|
+
try {
|
|
364
|
+
const inventory = await readProtocolV2ResourceInventory({
|
|
365
|
+
commands: this.device.getCommands(),
|
|
366
|
+
resources,
|
|
367
|
+
});
|
|
368
|
+
resourceStatus = buildProtocolV2ResourceUpdatePlan({
|
|
369
|
+
resources,
|
|
370
|
+
inventory,
|
|
371
|
+
mode: 'bootloader-recovery',
|
|
372
|
+
}).status;
|
|
373
|
+
} catch {
|
|
374
|
+
resourceStatus = buildProtocolV2ResourceUpdatePlan({
|
|
375
|
+
resources,
|
|
376
|
+
mode: 'bootloader-recovery',
|
|
377
|
+
}).status;
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
const targetsToUpdate = [
|
|
382
|
+
...plan.targetsToUpdate,
|
|
383
|
+
...(resourceStatus === 'outdated' ? (['resource'] as const) : []),
|
|
384
|
+
];
|
|
389
385
|
const firmwareStatus = plan.status === 'unavailable' ? 'unknown' : plan.status;
|
|
390
386
|
const emptyRelease = 'none' as const;
|
|
391
387
|
|
|
@@ -406,8 +402,11 @@ export default class CheckAllFirmwareRelease extends BaseMethod {
|
|
|
406
402
|
},
|
|
407
403
|
features,
|
|
408
404
|
protocol: 'V2',
|
|
409
|
-
deviceType:
|
|
405
|
+
deviceType: state.identity.deviceType,
|
|
410
406
|
...plan,
|
|
407
|
+
resourceStatus,
|
|
408
|
+
hasUpgrade: plan.hasUpgrade || resourceStatus === 'outdated',
|
|
409
|
+
targetsToUpdate,
|
|
411
410
|
};
|
|
412
411
|
}
|
|
413
412
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { BaseMethod } from './BaseMethod';
|
|
2
|
+
|
|
3
|
+
export default class DetectDeviceConnectProtocol extends BaseMethod {
|
|
4
|
+
init() {
|
|
5
|
+
this.payload.forceProtocolDetection = true;
|
|
6
|
+
this.useDevicePassphraseState = false;
|
|
7
|
+
this.skipForceUpdateCheck = true;
|
|
8
|
+
this.unlockPolicy = 'none';
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
getSupportedProtocols() {
|
|
12
|
+
return ['V1', 'V2'] as const;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
run() {
|
|
16
|
+
return Promise.resolve(this.device.getProtocol());
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -10,7 +10,6 @@ import { UI_REQUEST } from '../constants/ui-request';
|
|
|
10
10
|
import { BaseMethod } from './BaseMethod';
|
|
11
11
|
import { validateParams } from './helpers/paramsValidator';
|
|
12
12
|
import { getBinary } from './firmware/getBinary';
|
|
13
|
-
import { BOOTLOADER_POLL_INITIALIZE_TIMEOUT_MS } from './firmware/FirmwareUpdateBaseMethod';
|
|
14
13
|
import { uploadFirmware } from './firmware/uploadFirmware';
|
|
15
14
|
import { createUiMessage } from '../events';
|
|
16
15
|
import { DeviceModelToTypes, type KnownDevice } from '../types';
|
|
@@ -79,10 +78,6 @@ export default class FirmwareUpdate extends BaseMethod<Params> {
|
|
|
79
78
|
this.checkPromise = createDeferred();
|
|
80
79
|
const env = DataManager.getSettings('env');
|
|
81
80
|
const isBleReconnect = connectId && DataManager.isBleConnect(env);
|
|
82
|
-
// Tracks the in-flight BLE probe so interval ticks never overlap: a superseded
|
|
83
|
-
// Initialize left pending on the V1 transport is exactly what later times out
|
|
84
|
-
// and used to tear down the connection mid-firmware-upload.
|
|
85
|
-
let bleProbeInFlight = false;
|
|
86
81
|
|
|
87
82
|
Log.log('FirmwareUpdate [checkDeviceToBootloader] isBleReconnect: ', isBleReconnect);
|
|
88
83
|
|
|
@@ -90,18 +85,14 @@ export default class FirmwareUpdate extends BaseMethod<Params> {
|
|
|
90
85
|
const intervalTimer: ReturnType<typeof setInterval> | undefined = setInterval(
|
|
91
86
|
async () => {
|
|
92
87
|
if (isBleReconnect) {
|
|
93
|
-
if (bleProbeInFlight) return;
|
|
94
|
-
bleProbeInFlight = true;
|
|
95
88
|
try {
|
|
96
89
|
await this.device.deviceConnector?.acquire(
|
|
97
90
|
this.device.originalDescriptor.id,
|
|
98
91
|
null,
|
|
99
|
-
true
|
|
92
|
+
true,
|
|
93
|
+
this.payload.connectProtocol ?? this.device.originalDescriptor.protocolType
|
|
100
94
|
);
|
|
101
|
-
|
|
102
|
-
// frees the slot for the next tick instead of hanging into the
|
|
103
|
-
// 30s reboot budget.
|
|
104
|
-
await this.device.initialize({ timeoutMs: BOOTLOADER_POLL_INITIALIZE_TIMEOUT_MS });
|
|
95
|
+
await this.device.initialize();
|
|
105
96
|
if (this.device.isBootloader()) {
|
|
106
97
|
clearInterval(intervalTimer);
|
|
107
98
|
this.checkPromise?.resolve(true);
|
|
@@ -109,13 +100,14 @@ export default class FirmwareUpdate extends BaseMethod<Params> {
|
|
|
109
100
|
} catch (e) {
|
|
110
101
|
// ignore error because of device is not connected
|
|
111
102
|
Log.log('catch Bluetooth error when device is restarting: ', e);
|
|
112
|
-
} finally {
|
|
113
|
-
bleProbeInFlight = false;
|
|
114
103
|
}
|
|
115
104
|
} else {
|
|
116
105
|
const deviceDiff = await this.device.deviceConnector?.enumerate();
|
|
117
106
|
const devicesDescriptor = deviceDiff?.descriptors ?? [];
|
|
118
|
-
const { deviceList } = await DevicePool.getDevices(devicesDescriptor, connectId
|
|
107
|
+
const { deviceList } = await DevicePool.getDevices(devicesDescriptor, connectId, {
|
|
108
|
+
connectProtocol:
|
|
109
|
+
this.payload.connectProtocol ?? this.device.originalDescriptor.protocolType,
|
|
110
|
+
});
|
|
119
111
|
|
|
120
112
|
if (deviceList.length === 1 && deviceList[0]?.isBootloader()) {
|
|
121
113
|
// should update current device from cache
|