@onekeyfe/hd-core 1.2.0-alpha.67 → 1.2.0-alpha.69
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 +226 -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-firmware-targets.test.ts +33 -1
- package/__tests__/protocol-v2-resources.test.ts +343 -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 +1586 -1213
- package/__tests__/protocolV2FileWrite.test.ts +193 -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 +3 -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 -10
- 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 +15 -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 -247
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3135 -3785
- 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 -70
- 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 +78 -64
- package/src/api/DetectDeviceConnectProtocol.ts +18 -0
- package/src/api/FirmwareUpdate.ts +7 -15
- package/src/api/FirmwareUpdateV2.ts +126 -298
- package/src/api/FirmwareUpdateV3.ts +63 -265
- package/src/api/FirmwareUpdateV4.ts +645 -1018
- 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 +252 -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 +394 -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 -78
- 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 +61 -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/device-update-bootloader.test.ts +0 -87
- 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 -231
- 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,15 +170,19 @@ 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,
|
|
177
|
+
deviceType,
|
|
181
178
|
}: {
|
|
182
179
|
currentVersions: DeviceStateVersions;
|
|
183
180
|
currentVerification?: Partial<DeviceFeaturesVerify>;
|
|
181
|
+
checkFirmwareHash?: boolean;
|
|
184
182
|
remotePayloadHashes?: Readonly<Record<string, string | null>>;
|
|
185
183
|
firmwareType: EFirmwareType;
|
|
186
184
|
release: IFirmwareReleaseInfo | undefined;
|
|
185
|
+
deviceType?: 'pro2' | 'neo';
|
|
187
186
|
}): ProtocolV2FirmwareReleasePlan {
|
|
188
187
|
if (!release) {
|
|
189
188
|
return {
|
|
@@ -198,18 +197,31 @@ export function buildProtocolV2FirmwareRelease({
|
|
|
198
197
|
};
|
|
199
198
|
}
|
|
200
199
|
|
|
201
|
-
let components = getOrderedComponentEntries(release).map(([configKey, component]) =>
|
|
202
|
-
buildComponentRelease({
|
|
200
|
+
let components = getOrderedComponentEntries(release).map(([configKey, component]) => {
|
|
201
|
+
const result = buildComponentRelease({
|
|
203
202
|
configKey,
|
|
204
203
|
component,
|
|
205
204
|
currentVersions,
|
|
206
205
|
currentVerification,
|
|
206
|
+
checkFirmwareHash,
|
|
207
207
|
remotePayloadHash: Object.prototype.hasOwnProperty.call(remotePayloadHashes, configKey)
|
|
208
208
|
? remotePayloadHashes[configKey]
|
|
209
209
|
: normalizeHex(component.payloadHash),
|
|
210
210
|
releaseRequired: release.required,
|
|
211
|
-
})
|
|
212
|
-
|
|
211
|
+
});
|
|
212
|
+
if (
|
|
213
|
+
deviceType === 'neo' &&
|
|
214
|
+
(result.componentTarget === 'SE03' || result.componentTarget === 'SE04')
|
|
215
|
+
) {
|
|
216
|
+
return {
|
|
217
|
+
...result,
|
|
218
|
+
updateTarget: null,
|
|
219
|
+
status: 'unsupported' as const,
|
|
220
|
+
required: false,
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
return result;
|
|
224
|
+
});
|
|
213
225
|
if (!currentVersions.applicationP2) {
|
|
214
226
|
const applicationP1 = components.find(
|
|
215
227
|
component => component.componentTarget === 'APPLICATION_P1'
|
|
@@ -230,9 +242,6 @@ export function buildProtocolV2FirmwareRelease({
|
|
|
230
242
|
const targetsToUpdate = components.flatMap(component =>
|
|
231
243
|
component.status === 'outdated' && component.updateTarget ? [component.updateTarget] : []
|
|
232
244
|
);
|
|
233
|
-
if (targetsToUpdate.length > 0 && release.resourceBundles?.length) {
|
|
234
|
-
targetsToUpdate.push('resource');
|
|
235
|
-
}
|
|
236
245
|
const uniqueTargetsToUpdate = Array.from(new Set(targetsToUpdate));
|
|
237
246
|
const hasUpgrade = uniqueTargetsToUpdate.length > 0;
|
|
238
247
|
const required = release.required && hasUpgrade;
|
|
@@ -257,8 +266,6 @@ export function buildProtocolV2FirmwareRelease({
|
|
|
257
266
|
};
|
|
258
267
|
}
|
|
259
268
|
|
|
260
|
-
const Log = getLogger(LoggerNames.Method);
|
|
261
|
-
|
|
262
269
|
export default class CheckAllFirmwareRelease extends BaseMethod {
|
|
263
270
|
getSupportedProtocols() {
|
|
264
271
|
return ['V1', 'V2'] as const;
|
|
@@ -276,13 +283,8 @@ export default class CheckAllFirmwareRelease extends BaseMethod {
|
|
|
276
283
|
}
|
|
277
284
|
|
|
278
285
|
const { features } = this.device;
|
|
279
|
-
const {
|
|
280
|
-
|
|
281
|
-
firmwareType: firmwareTypeParams,
|
|
282
|
-
platform,
|
|
283
|
-
forceUpdateTargets,
|
|
284
|
-
} = this.payload as CheckAllFirmwareReleaseParams;
|
|
285
|
-
const validatedForceUpdateTargets = validateFirmwareUpdatePlanForceTargets(forceUpdateTargets);
|
|
286
|
+
const { checkBridgeRelease, firmwareType: firmwareTypeParams } = this
|
|
287
|
+
.payload as CheckAllFirmwareReleaseParams;
|
|
286
288
|
|
|
287
289
|
if (!features) {
|
|
288
290
|
return Promise.resolve(null);
|
|
@@ -313,32 +315,6 @@ export default class CheckAllFirmwareRelease extends BaseMethod {
|
|
|
313
315
|
firmwareType,
|
|
314
316
|
});
|
|
315
317
|
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
318
|
|
|
343
319
|
return {
|
|
344
320
|
firmware: firmwareRelease,
|
|
@@ -353,18 +329,21 @@ export default class CheckAllFirmwareRelease extends BaseMethod {
|
|
|
353
329
|
}
|
|
354
330
|
: undefined,
|
|
355
331
|
features,
|
|
356
|
-
|
|
357
|
-
} as unknown as AllFirmwareRelease;
|
|
332
|
+
} as AllFirmwareRelease;
|
|
358
333
|
}
|
|
359
334
|
|
|
360
335
|
private async runProtocolV2(): Promise<AllFirmwareRelease> {
|
|
336
|
+
const { checkFirmwareHash = false, firmwareType: firmwareTypeParam } = this
|
|
337
|
+
.payload as CheckAllFirmwareReleaseParams;
|
|
361
338
|
const state = await this.device.getDeviceState({
|
|
362
|
-
refreshSections:
|
|
339
|
+
refreshSections: checkFirmwareHash
|
|
340
|
+
? ['identity', 'versions', 'verification']
|
|
341
|
+
: ['identity', 'versions'],
|
|
363
342
|
});
|
|
364
|
-
if (state.identity.deviceType !== 'pro2') {
|
|
343
|
+
if (state.identity.deviceType !== 'pro2' && state.identity.deviceType !== 'neo') {
|
|
365
344
|
throw ERRORS.TypedError(
|
|
366
345
|
HardwareErrorCode.DeviceNotSupportMethod,
|
|
367
|
-
'checkAllFirmwareRelease requires a Pro2 device for Protocol V2'
|
|
346
|
+
'checkAllFirmwareRelease requires a Pro2 or Neo device for Protocol V2'
|
|
368
347
|
);
|
|
369
348
|
}
|
|
370
349
|
|
|
@@ -376,16 +355,48 @@ export default class CheckAllFirmwareRelease extends BaseMethod {
|
|
|
376
355
|
);
|
|
377
356
|
}
|
|
378
357
|
|
|
379
|
-
const { firmwareType: firmwareTypeParam } = this.payload as CheckAllFirmwareReleaseParams;
|
|
380
358
|
const firmwareType =
|
|
381
359
|
firmwareTypeParam ?? state.identity.firmwareType ?? EFirmwareType.Universal;
|
|
382
360
|
const release = DataManager.getFirmwareLatestRelease(features, firmwareType);
|
|
383
361
|
const plan = buildProtocolV2FirmwareRelease({
|
|
384
362
|
currentVersions: state.versions,
|
|
385
|
-
currentVerification: state.verification,
|
|
363
|
+
currentVerification: checkFirmwareHash ? state.verification : undefined,
|
|
364
|
+
checkFirmwareHash,
|
|
386
365
|
firmwareType,
|
|
387
366
|
release,
|
|
367
|
+
deviceType: state.identity.deviceType,
|
|
388
368
|
});
|
|
369
|
+
const resourceDeviceType =
|
|
370
|
+
state.identity.deviceType === 'neo' ? EDeviceType.Neo : EDeviceType.Pro2;
|
|
371
|
+
const resources = DataManager.getProtocolV2Resources(resourceDeviceType);
|
|
372
|
+
let resourceStatus: 'valid' | 'outdated' | 'unknown' = 'unknown';
|
|
373
|
+
if (resources?.length) {
|
|
374
|
+
const loaderMode = state.status.mode === 'bootloader' || state.status.mode === 'romloader';
|
|
375
|
+
// Application mode rejects host access to vol0:/bundles. Resource inventory is
|
|
376
|
+
// resolved after FirmwareUpdateV4 enters a loader instead of probing here.
|
|
377
|
+
if (loaderMode) {
|
|
378
|
+
try {
|
|
379
|
+
const inventory = await readProtocolV2ResourceInventory({
|
|
380
|
+
commands: this.device.getCommands(),
|
|
381
|
+
resources,
|
|
382
|
+
});
|
|
383
|
+
resourceStatus = buildProtocolV2ResourceUpdatePlan({
|
|
384
|
+
resources,
|
|
385
|
+
inventory,
|
|
386
|
+
mode: 'bootloader-recovery',
|
|
387
|
+
}).status;
|
|
388
|
+
} catch {
|
|
389
|
+
resourceStatus = buildProtocolV2ResourceUpdatePlan({
|
|
390
|
+
resources,
|
|
391
|
+
mode: 'bootloader-recovery',
|
|
392
|
+
}).status;
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
const targetsToUpdate = [
|
|
397
|
+
...plan.targetsToUpdate,
|
|
398
|
+
...(resourceStatus === 'outdated' ? (['resource'] as const) : []),
|
|
399
|
+
];
|
|
389
400
|
const firmwareStatus = plan.status === 'unavailable' ? 'unknown' : plan.status;
|
|
390
401
|
const emptyRelease = 'none' as const;
|
|
391
402
|
|
|
@@ -406,8 +417,11 @@ export default class CheckAllFirmwareRelease extends BaseMethod {
|
|
|
406
417
|
},
|
|
407
418
|
features,
|
|
408
419
|
protocol: 'V2',
|
|
409
|
-
deviceType:
|
|
420
|
+
deviceType: state.identity.deviceType,
|
|
410
421
|
...plan,
|
|
422
|
+
resourceStatus,
|
|
423
|
+
hasUpgrade: plan.hasUpgrade || resourceStatus === 'outdated',
|
|
424
|
+
targetsToUpdate,
|
|
411
425
|
};
|
|
412
426
|
}
|
|
413
427
|
}
|
|
@@ -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
|