@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
|
@@ -9,31 +9,18 @@ import {
|
|
|
9
9
|
getDeviceBLEFirmwareVersion,
|
|
10
10
|
getDeviceBootloaderVersion,
|
|
11
11
|
getDeviceFirmwareVersion,
|
|
12
|
-
getDeviceUUID,
|
|
13
12
|
getLogger,
|
|
14
13
|
} from '../utils';
|
|
15
14
|
import { getBinary, getSysResourceBinary } from './firmware/getBinary';
|
|
16
|
-
import { normalizeFirmwarePreparationError } from './firmware/FirmwarePreparationError';
|
|
17
15
|
import { DataManager } from '../data-manager';
|
|
18
16
|
import { FirmwareUpdateBaseMethod } from './firmware/FirmwareUpdateBaseMethod';
|
|
19
17
|
import { DevicePool } from '../device/DevicePool';
|
|
20
18
|
import { DEVICE } from '../events';
|
|
21
19
|
import { buildProtocolV1FeaturesPayload } from '../deviceProfile';
|
|
22
|
-
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
assertFirmwareUpdatePreparedPlanBinding,
|
|
26
|
-
assertFirmwareUpdatePreparedPlanDeviceIdentity,
|
|
27
|
-
getFirmwareUpdateResourceName,
|
|
28
|
-
} from './firmware/FirmwareUpdatePreparedPlan';
|
|
29
|
-
|
|
30
|
-
import type {
|
|
31
|
-
FirmwareArtifactReference,
|
|
32
|
-
FirmwareUpdateV3Params,
|
|
33
|
-
} from '../types/api/firmwareUpdate';
|
|
20
|
+
|
|
21
|
+
import type { FirmwareUpdateV3Params } from '../types/api/firmwareUpdate';
|
|
34
22
|
import type { Deferred, EFirmwareType } from '@onekeyfe/hd-shared';
|
|
35
23
|
import type { TypedResponseMessage } from '../device/DeviceCommands';
|
|
36
|
-
import type { FirmwareByteSource } from './firmware/FirmwareArtifactSource';
|
|
37
24
|
|
|
38
25
|
const Log = getLogger(LoggerNames.Method);
|
|
39
26
|
|
|
@@ -55,8 +42,6 @@ export default class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod<FirmwareU
|
|
|
55
42
|
|
|
56
43
|
private isSwitchFirmware = false;
|
|
57
44
|
|
|
58
|
-
private artifactSources: FirmwareByteSource[] = [];
|
|
59
|
-
|
|
60
45
|
init() {
|
|
61
46
|
this.allowDeviceMode = [UI_REQUEST.BOOTLOADER, UI_REQUEST.NOT_INITIALIZE];
|
|
62
47
|
this.requireDeviceMode = [];
|
|
@@ -77,54 +62,8 @@ export default class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod<FirmwareU
|
|
|
77
62
|
{ name: 'firmwareType', type: 'string' },
|
|
78
63
|
{ name: 'platform', type: 'string' },
|
|
79
64
|
]);
|
|
80
|
-
const hostBinding =
|
|
81
|
-
payload.artifacts || payload.preparedPlan
|
|
82
|
-
? resolveFirmwareUpdateHostBinding(payload.hostBindingGeneration)
|
|
83
|
-
: undefined;
|
|
84
|
-
if (hostBinding) {
|
|
85
|
-
assertFirmwareUpdatePreparedPlanBinding({
|
|
86
|
-
preparedPlan: payload.preparedPlan,
|
|
87
|
-
executor: 'v3',
|
|
88
|
-
platform: payload.platform,
|
|
89
|
-
scopeTargets: ['bootloader', 'firmware', 'resource', 'ble'],
|
|
90
|
-
bindings: [
|
|
91
|
-
...(payload.artifacts?.bootloader
|
|
92
|
-
? [
|
|
93
|
-
{
|
|
94
|
-
target: 'bootloader' as const,
|
|
95
|
-
artifact: payload.artifacts.bootloader,
|
|
96
|
-
},
|
|
97
|
-
]
|
|
98
|
-
: []),
|
|
99
|
-
...(payload.artifacts?.firmware
|
|
100
|
-
? [
|
|
101
|
-
{
|
|
102
|
-
target: 'firmware' as const,
|
|
103
|
-
artifact: payload.artifacts.firmware,
|
|
104
|
-
},
|
|
105
|
-
]
|
|
106
|
-
: []),
|
|
107
|
-
...(payload.artifacts?.ble
|
|
108
|
-
? [
|
|
109
|
-
{
|
|
110
|
-
target: 'ble' as const,
|
|
111
|
-
artifact: payload.artifacts.ble,
|
|
112
|
-
},
|
|
113
|
-
]
|
|
114
|
-
: []),
|
|
115
|
-
...(payload.artifacts?.resourceEntries ?? []).map(
|
|
116
|
-
(entry: { entryName: string; artifact: FirmwareArtifactReference }) => ({
|
|
117
|
-
target: 'resource' as const,
|
|
118
|
-
entryName: entry.entryName,
|
|
119
|
-
artifact: entry.artifact,
|
|
120
|
-
})
|
|
121
|
-
),
|
|
122
|
-
],
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
65
|
|
|
126
66
|
this.params = {
|
|
127
|
-
preparedPlan: payload.preparedPlan,
|
|
128
67
|
bleBinary: payload.bleBinary,
|
|
129
68
|
firmwareBinary: payload.firmwareBinary,
|
|
130
69
|
forcedUpdateRes: payload.forcedUpdateRes,
|
|
@@ -135,8 +74,6 @@ export default class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod<FirmwareU
|
|
|
135
74
|
resourceBinary: payload.resourceBinary,
|
|
136
75
|
firmwareType: payload.firmwareType,
|
|
137
76
|
platform: payload.platform,
|
|
138
|
-
artifactReader: hostBinding?.artifactReader ?? payload.artifactReader,
|
|
139
|
-
artifacts: payload.artifacts,
|
|
140
77
|
};
|
|
141
78
|
}
|
|
142
79
|
|
|
@@ -160,53 +97,39 @@ export default class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod<FirmwareU
|
|
|
160
97
|
if (!features) {
|
|
161
98
|
throw ERRORS.TypedError(HardwareErrorCode.RuntimeError, 'Device features not available');
|
|
162
99
|
}
|
|
163
|
-
if (this.params.preparedPlan) {
|
|
164
|
-
assertFirmwareUpdatePreparedPlanDeviceIdentity({
|
|
165
|
-
preparedPlan: this.params.preparedPlan,
|
|
166
|
-
deviceIdentity: getDeviceUUID(features) || undefined,
|
|
167
|
-
});
|
|
168
|
-
}
|
|
169
100
|
|
|
170
101
|
const deviceFirmwareType = device.getCurrentFirmwareType();
|
|
171
102
|
const firmwareType = this.params.firmwareType ?? deviceFirmwareType;
|
|
172
103
|
this.isSwitchFirmware = firmwareType !== deviceFirmwareType;
|
|
173
104
|
|
|
174
105
|
let resourceBinary: ArrayBuffer | null = null;
|
|
175
|
-
let
|
|
176
|
-
let
|
|
177
|
-
let bootloaderSource: FirmwareByteSource | null = null;
|
|
106
|
+
let fwBinaryMap: { fileName: string; binary: ArrayBuffer }[] = [];
|
|
107
|
+
let bootloaderBinary: ArrayBuffer | null = null;
|
|
178
108
|
try {
|
|
179
109
|
this.postTipMessage(FirmwareUpdateTipMessage.StartDownloadFirmware);
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
fwSources = await this.prepareFirmwareAndBleSources(firmwareType);
|
|
184
|
-
bootloaderSource = await this.prepareBootloaderSource(firmwareType);
|
|
110
|
+
resourceBinary = await this.prepareResourceBinary(firmwareType);
|
|
111
|
+
fwBinaryMap = await this.prepareFirmwareAndBleBinary(firmwareType);
|
|
112
|
+
bootloaderBinary = await this.prepareBootloaderBinary(firmwareType);
|
|
185
113
|
this.postTipMessage(FirmwareUpdateTipMessage.FinishDownloadFirmware);
|
|
186
114
|
} catch (err) {
|
|
187
|
-
|
|
188
|
-
throw normalizeFirmwarePreparationError(err);
|
|
115
|
+
throw ERRORS.TypedError(HardwareErrorCode.FirmwareUpdateDownloadFailed, err.message ?? err);
|
|
189
116
|
}
|
|
190
117
|
|
|
191
|
-
if (!
|
|
192
|
-
await this.closeArtifactSources();
|
|
118
|
+
if (!bootloaderBinary && fwBinaryMap.length === 0) {
|
|
193
119
|
throw ERRORS.TypedError(
|
|
194
120
|
HardwareErrorCode.FirmwareUpdateDownloadFailed,
|
|
195
121
|
'No firmware to update'
|
|
196
122
|
);
|
|
197
123
|
}
|
|
198
124
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
} finally {
|
|
208
|
-
await this.closeArtifactSources();
|
|
209
|
-
}
|
|
125
|
+
await this.enterBootloaderMode();
|
|
126
|
+
|
|
127
|
+
const updateResult = await this.executeUpdate({
|
|
128
|
+
resourceBinary,
|
|
129
|
+
fwBinaryMap,
|
|
130
|
+
bootloaderBinary,
|
|
131
|
+
});
|
|
132
|
+
return updateResult;
|
|
210
133
|
}
|
|
211
134
|
|
|
212
135
|
private validateDeviceAndVersion(deviceType: EDeviceType, bootloaderVersion: string) {
|
|
@@ -226,81 +149,12 @@ export default class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod<FirmwareU
|
|
|
226
149
|
}
|
|
227
150
|
}
|
|
228
151
|
|
|
229
|
-
private async
|
|
230
|
-
binary: ArrayBuffer | undefined,
|
|
231
|
-
artifact: FirmwareArtifactReference | undefined
|
|
232
|
-
) {
|
|
233
|
-
const source = await openFirmwareByteSource({
|
|
234
|
-
binary,
|
|
235
|
-
artifact,
|
|
236
|
-
reader: this.params.artifactReader,
|
|
237
|
-
});
|
|
238
|
-
if (source) {
|
|
239
|
-
this.artifactSources.push(source);
|
|
240
|
-
}
|
|
241
|
-
return source;
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
private async closeArtifactSources() {
|
|
245
|
-
const sources = this.artifactSources.splice(0);
|
|
246
|
-
await Promise.all(sources.map(source => source.close().catch(() => undefined)));
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
private assertSdkDownloadAllowed(artifactName: string) {
|
|
250
|
-
if (
|
|
251
|
-
this.params.artifactReader ||
|
|
252
|
-
DataManager.getSettings('firmwareManifestMode') === 'external-only'
|
|
253
|
-
) {
|
|
254
|
-
throw ERRORS.TypedError(
|
|
255
|
-
HardwareErrorCode.RuntimeError,
|
|
256
|
-
`${artifactName} must be prepared by the external firmware host`,
|
|
257
|
-
{
|
|
258
|
-
firmwareUpdateCode: 'FirmwareArtifactsNotPrepared',
|
|
259
|
-
artifactName,
|
|
260
|
-
}
|
|
261
|
-
);
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
private async prepareResourceInput(firmwareType: EFirmwareType) {
|
|
266
|
-
const preparedEntries = this.params.artifacts?.resourceEntries;
|
|
267
|
-
if (preparedEntries?.length && this.params.resourceBinary) {
|
|
268
|
-
throw ERRORS.TypedError(
|
|
269
|
-
HardwareErrorCode.RuntimeError,
|
|
270
|
-
'Firmware resource input must not contain both archive binary and prepared entries'
|
|
271
|
-
);
|
|
272
|
-
}
|
|
273
|
-
if (preparedEntries?.length) {
|
|
274
|
-
const resourceEntries: Array<{ entryName: string; source: FirmwareByteSource }> = [];
|
|
275
|
-
for (const entry of preparedEntries) {
|
|
276
|
-
const resourceName = getFirmwareUpdateResourceName(entry.entryName);
|
|
277
|
-
const source = await this.openArtifactSource(undefined, entry.artifact);
|
|
278
|
-
if (!source) {
|
|
279
|
-
throw ERRORS.TypedError(
|
|
280
|
-
HardwareErrorCode.RuntimeError,
|
|
281
|
-
`Firmware resource entry ${entry.entryName} is not prepared`
|
|
282
|
-
);
|
|
283
|
-
}
|
|
284
|
-
resourceEntries.push({ entryName: resourceName, source });
|
|
285
|
-
}
|
|
286
|
-
return {
|
|
287
|
-
resourceBinary: null,
|
|
288
|
-
resourceEntries,
|
|
289
|
-
};
|
|
290
|
-
}
|
|
152
|
+
private async prepareResourceBinary(firmwareType: EFirmwareType) {
|
|
291
153
|
if (this.params.resourceBinary) {
|
|
292
|
-
return
|
|
293
|
-
resourceBinary: this.params.resourceBinary,
|
|
294
|
-
resourceEntries: [],
|
|
295
|
-
};
|
|
154
|
+
return this.params.resourceBinary;
|
|
296
155
|
}
|
|
297
156
|
const { features } = this.device;
|
|
298
|
-
if (!features)
|
|
299
|
-
return {
|
|
300
|
-
resourceBinary: null,
|
|
301
|
-
resourceEntries: [],
|
|
302
|
-
};
|
|
303
|
-
}
|
|
157
|
+
if (!features) return null;
|
|
304
158
|
const resourceUrl = DataManager.getSysResourcesLatestRelease({
|
|
305
159
|
features,
|
|
306
160
|
forcedUpdateRes: this.params.forcedUpdateRes,
|
|
@@ -308,27 +162,16 @@ export default class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod<FirmwareU
|
|
|
308
162
|
});
|
|
309
163
|
|
|
310
164
|
if (resourceUrl) {
|
|
311
|
-
|
|
312
|
-
return
|
|
313
|
-
resourceBinary: (await getSysResourceBinary(resourceUrl)).binary,
|
|
314
|
-
resourceEntries: [],
|
|
315
|
-
};
|
|
165
|
+
const resource = (await getSysResourceBinary(resourceUrl)).binary;
|
|
166
|
+
return resource;
|
|
316
167
|
}
|
|
317
168
|
Log.warn('No resource url found');
|
|
318
|
-
return
|
|
319
|
-
resourceBinary: null,
|
|
320
|
-
resourceEntries: [],
|
|
321
|
-
};
|
|
169
|
+
return null;
|
|
322
170
|
}
|
|
323
171
|
|
|
324
|
-
private async
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
if (this.params.bootloaderBinary || this.params.artifacts?.bootloader) {
|
|
328
|
-
return this.openArtifactSource(
|
|
329
|
-
this.params.bootloaderBinary,
|
|
330
|
-
this.params.artifacts?.bootloader
|
|
331
|
-
);
|
|
172
|
+
private async prepareBootloaderBinary(firmwareType: EFirmwareType): Promise<ArrayBuffer | null> {
|
|
173
|
+
if (this.params.bootloaderBinary) {
|
|
174
|
+
return this.params.bootloaderBinary;
|
|
332
175
|
}
|
|
333
176
|
const { features } = this.device;
|
|
334
177
|
if (!features) return null;
|
|
@@ -336,35 +179,23 @@ export default class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod<FirmwareU
|
|
|
336
179
|
if (this.params.bootloaderVersion) {
|
|
337
180
|
const bootResourceUrl = DataManager.getBootloaderResource(features, firmwareType);
|
|
338
181
|
if (bootResourceUrl) {
|
|
339
|
-
this.assertSdkDownloadAllowed('bootloader');
|
|
340
182
|
const bootBinary = (await getSysResourceBinary(bootResourceUrl)).binary;
|
|
341
|
-
return
|
|
183
|
+
return bootBinary;
|
|
342
184
|
}
|
|
343
185
|
}
|
|
344
186
|
return null;
|
|
345
187
|
}
|
|
346
188
|
|
|
347
|
-
private async
|
|
348
|
-
const
|
|
349
|
-
if (this.params.firmwareBinary
|
|
350
|
-
|
|
351
|
-
this.params.firmwareBinary,
|
|
352
|
-
this.params.artifacts?.firmware
|
|
353
|
-
);
|
|
354
|
-
if (!source) {
|
|
355
|
-
throw ERRORS.TypedError(
|
|
356
|
-
HardwareErrorCode.RuntimeError,
|
|
357
|
-
'Firmware artifact is not prepared'
|
|
358
|
-
);
|
|
359
|
-
}
|
|
360
|
-
fwSources.push({
|
|
189
|
+
private async prepareFirmwareAndBleBinary(firmwareType: EFirmwareType) {
|
|
190
|
+
const fwBinaryMap: { fileName: string; binary: ArrayBuffer }[] = [];
|
|
191
|
+
if (this.params.firmwareBinary) {
|
|
192
|
+
fwBinaryMap.push({
|
|
361
193
|
fileName: 'firmware.bin',
|
|
362
|
-
|
|
194
|
+
binary: this.params.firmwareBinary,
|
|
363
195
|
});
|
|
364
196
|
} else if (this.params.firmwareVersion) {
|
|
365
197
|
const { features } = this.device;
|
|
366
198
|
if (features) {
|
|
367
|
-
this.assertSdkDownloadAllowed('firmware');
|
|
368
199
|
const firmwareBinary = (
|
|
369
200
|
await getBinary({
|
|
370
201
|
features,
|
|
@@ -374,65 +205,44 @@ export default class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod<FirmwareU
|
|
|
374
205
|
firmwareType,
|
|
375
206
|
})
|
|
376
207
|
).binary;
|
|
377
|
-
|
|
378
|
-
if (!source) {
|
|
379
|
-
throw ERRORS.TypedError(
|
|
380
|
-
HardwareErrorCode.RuntimeError,
|
|
381
|
-
'Firmware binary is not prepared'
|
|
382
|
-
);
|
|
383
|
-
}
|
|
384
|
-
fwSources.push({
|
|
208
|
+
fwBinaryMap.push({
|
|
385
209
|
fileName: 'firmware.bin',
|
|
386
|
-
|
|
210
|
+
binary: firmwareBinary,
|
|
387
211
|
});
|
|
388
212
|
}
|
|
389
213
|
}
|
|
390
214
|
|
|
391
|
-
if (this.params.bleBinary
|
|
392
|
-
|
|
393
|
-
this.params.bleBinary,
|
|
394
|
-
this.params.artifacts?.ble
|
|
395
|
-
);
|
|
396
|
-
if (!source) {
|
|
397
|
-
throw ERRORS.TypedError(HardwareErrorCode.RuntimeError, 'BLE artifact is not prepared');
|
|
398
|
-
}
|
|
399
|
-
fwSources.push({
|
|
215
|
+
if (this.params.bleBinary) {
|
|
216
|
+
fwBinaryMap.push({
|
|
400
217
|
fileName: 'ble-firmware.bin',
|
|
401
|
-
|
|
218
|
+
binary: this.params.bleBinary,
|
|
402
219
|
});
|
|
403
220
|
} else if (this.params.bleVersion) {
|
|
404
221
|
const { features } = this.device;
|
|
405
222
|
if (features) {
|
|
406
|
-
this.assertSdkDownloadAllowed('ble');
|
|
407
223
|
const bleBinary = await getBinary({
|
|
408
224
|
features,
|
|
409
225
|
version: this.params.bleVersion,
|
|
410
226
|
updateType: 'ble',
|
|
411
227
|
firmwareType,
|
|
412
228
|
});
|
|
413
|
-
|
|
414
|
-
if (!source) {
|
|
415
|
-
throw ERRORS.TypedError(HardwareErrorCode.RuntimeError, 'BLE binary is not prepared');
|
|
416
|
-
}
|
|
417
|
-
fwSources.push({
|
|
229
|
+
fwBinaryMap.push({
|
|
418
230
|
fileName: 'ble-firmware.bin',
|
|
419
|
-
|
|
231
|
+
binary: bleBinary.binary,
|
|
420
232
|
});
|
|
421
233
|
}
|
|
422
234
|
}
|
|
423
|
-
return
|
|
235
|
+
return fwBinaryMap;
|
|
424
236
|
}
|
|
425
237
|
|
|
426
238
|
private async executeUpdate({
|
|
427
239
|
resourceBinary,
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
bootloaderSource,
|
|
240
|
+
fwBinaryMap,
|
|
241
|
+
bootloaderBinary,
|
|
431
242
|
}: {
|
|
432
243
|
resourceBinary: ArrayBuffer | null;
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
bootloaderSource: FirmwareByteSource | null;
|
|
244
|
+
fwBinaryMap: { fileName: string; binary: ArrayBuffer }[];
|
|
245
|
+
bootloaderBinary: ArrayBuffer | null;
|
|
436
246
|
}) {
|
|
437
247
|
let totalSize = 0;
|
|
438
248
|
let processedSize = 0;
|
|
@@ -440,14 +250,11 @@ export default class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod<FirmwareU
|
|
|
440
250
|
if (resourceBinary) {
|
|
441
251
|
totalSize += resourceBinary.byteLength;
|
|
442
252
|
}
|
|
443
|
-
for (const
|
|
444
|
-
totalSize +=
|
|
445
|
-
}
|
|
446
|
-
for (const firmware of fwSources) {
|
|
447
|
-
totalSize += firmware.source.size;
|
|
253
|
+
for (const fwbinary of fwBinaryMap) {
|
|
254
|
+
totalSize += fwbinary.binary.byteLength;
|
|
448
255
|
}
|
|
449
|
-
if (
|
|
450
|
-
totalSize +=
|
|
256
|
+
if (bootloaderBinary) {
|
|
257
|
+
totalSize += bootloaderBinary.byteLength;
|
|
451
258
|
}
|
|
452
259
|
|
|
453
260
|
this.postTipMessage(FirmwareUpdateTipMessage.StartTransferData);
|
|
@@ -470,18 +277,9 @@ export default class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod<FirmwareU
|
|
|
470
277
|
}
|
|
471
278
|
}
|
|
472
279
|
|
|
473
|
-
|
|
474
|
-
processedSize = await this.
|
|
475
|
-
|
|
476
|
-
filePath: `0:res/${entry.entryName}`,
|
|
477
|
-
processedSize,
|
|
478
|
-
totalSize,
|
|
479
|
-
});
|
|
480
|
-
}
|
|
481
|
-
|
|
482
|
-
if (bootloaderSource) {
|
|
483
|
-
processedSize = await this.emmcCommonUpdateProcessFromSource({
|
|
484
|
-
source: bootloaderSource,
|
|
280
|
+
if (bootloaderBinary) {
|
|
281
|
+
processedSize = await this.emmcCommonUpdateProcess({
|
|
282
|
+
payload: bootloaderBinary,
|
|
485
283
|
filePath: `0:boot/bootloader.bin`,
|
|
486
284
|
processedSize,
|
|
487
285
|
totalSize,
|
|
@@ -490,11 +288,11 @@ export default class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod<FirmwareU
|
|
|
490
288
|
|
|
491
289
|
await this.createUpdatesFolderIfNotExists(`0:updates/`);
|
|
492
290
|
|
|
493
|
-
for (const
|
|
494
|
-
if (
|
|
495
|
-
processedSize = await this.
|
|
496
|
-
|
|
497
|
-
filePath: `0:updates/${
|
|
291
|
+
for (const fwbinary of fwBinaryMap) {
|
|
292
|
+
if (fwbinary) {
|
|
293
|
+
processedSize = await this.emmcCommonUpdateProcess({
|
|
294
|
+
payload: fwbinary.binary,
|
|
295
|
+
filePath: `0:updates/${fwbinary.fileName}`,
|
|
498
296
|
processedSize,
|
|
499
297
|
totalSize,
|
|
500
298
|
});
|
|
@@ -705,7 +503,8 @@ export default class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod<FirmwareU
|
|
|
705
503
|
await this.device.deviceConnector?.acquire(
|
|
706
504
|
this.device.originalDescriptor.id,
|
|
707
505
|
null,
|
|
708
|
-
true
|
|
506
|
+
true,
|
|
507
|
+
this.payload.connectProtocol ?? this.device.originalDescriptor.protocolType
|
|
709
508
|
);
|
|
710
509
|
const typedCall = this.device.getCommands().typedCall.bind(this.device.getCommands());
|
|
711
510
|
await Promise.race([
|
|
@@ -742,15 +541,14 @@ export default class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod<FirmwareU
|
|
|
742
541
|
webUsbCheckCount = 0;
|
|
743
542
|
}
|
|
744
543
|
|
|
745
|
-
const { deviceList } = await DevicePool.getDevices(devicesDescriptor, this.connectId
|
|
544
|
+
const { deviceList } = await DevicePool.getDevices(devicesDescriptor, this.connectId, {
|
|
545
|
+
connectProtocol:
|
|
546
|
+
this.payload.connectProtocol ?? this.device.originalDescriptor.protocolType,
|
|
547
|
+
});
|
|
746
548
|
|
|
747
549
|
if (deviceList.length === 1) {
|
|
748
550
|
this.device.updateFromCache(deviceList[0]);
|
|
749
|
-
|
|
750
|
-
// Keep them in this polling loop instead of rejecting the active firmware run.
|
|
751
|
-
await this.device.acquire(undefined, {
|
|
752
|
-
throwOnRunPromiseError: true,
|
|
753
|
-
});
|
|
551
|
+
await this.device.acquire();
|
|
754
552
|
this.device.commands.disposed = false;
|
|
755
553
|
this.device.getCommands().mainId = this.device.mainId ?? '';
|
|
756
554
|
return;
|