@onekeyfe/hd-core 1.2.0-alpha.66 → 1.2.0-alpha.67
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 +0 -313
- package/__tests__/DeviceCommands.test.ts +13 -59
- package/__tests__/DeviceEventRegistration.test.ts +0 -6
- package/__tests__/check-all-firmware-release-protocol-v2.test.ts +3 -198
- package/__tests__/connectSettings.test.ts +47 -5
- package/__tests__/device-initialize-timeout.test.ts +56 -0
- package/__tests__/device-lifecycle-events.test.ts +3 -105
- package/__tests__/device-pool-state.test.ts +0 -22
- package/__tests__/device-settings.test.ts +18 -39
- package/__tests__/device-state-contract.test.ts +0 -1
- package/__tests__/device-state-mapper.test.ts +1 -13
- package/__tests__/device-utils.test.ts +1 -48
- package/__tests__/deviceSettings.test.ts +1 -11
- package/__tests__/firmware-update/check-all-firmware-release.test.ts +175 -0
- package/__tests__/firmware-update/device-update-bootloader.test.ts +87 -0
- package/__tests__/firmware-update/firmware-artifact-source.test.ts +119 -0
- package/__tests__/firmware-update/firmware-host-binding.test.ts +70 -0
- package/__tests__/firmware-update/firmware-preparation-error.test.ts +27 -0
- package/__tests__/firmware-update/firmware-update-bootloader-poll.test.ts +200 -0
- package/__tests__/firmware-update/firmware-update-capabilities.test.ts +13 -0
- package/__tests__/firmware-update/firmware-update-plan-bootloader-identity.test.ts +394 -0
- package/__tests__/firmware-update/firmware-update-plan.test.ts +593 -0
- package/__tests__/firmware-update/firmware-update-prepared-plan.test.ts +231 -0
- package/__tests__/firmware-update/firmware-update-v2-download-before-boot.test.ts +59 -31
- package/__tests__/firmware-update/firmware-update-v3-reconnect.test.ts +58 -0
- package/__tests__/firmware-update/firmware-upload-source.test.ts +70 -0
- package/__tests__/get-device-state.test.ts +12 -132
- package/__tests__/homescreen.test.ts +1 -41
- package/__tests__/kaspa-use-tweak-pro2.test.ts +2 -2
- package/__tests__/kaspaSignTransaction.test.ts +26 -3
- package/__tests__/logBlockEvent.test.ts +1 -1
- package/__tests__/method-protocol-support.test.ts +0 -19
- package/__tests__/open-wallet-session.test.ts +37 -568
- package/__tests__/protocol-v2-unlock-policy.test.ts +37 -300
- package/__tests__/protocol-v2.test.ts +1153 -1458
- package/__tests__/protocolV2FileWrite.test.ts +0 -152
- package/__tests__/protocolV2UiInteraction.test.ts +0 -63
- package/__tests__/public-pro2-api-boundary.test.ts +0 -1
- package/__tests__/search-devices.test.ts +3 -12
- package/__tests__/tron-sign-message-init.test.ts +2 -2
- package/dist/api/BaseMethod.d.ts +1 -3
- package/dist/api/BaseMethod.d.ts.map +1 -1
- package/dist/api/CheckAllFirmwareRelease.d.ts +1 -2
- package/dist/api/CheckAllFirmwareRelease.d.ts.map +1 -1
- package/dist/api/FirmwareUpdate.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV2.d.ts +10 -0
- package/dist/api/FirmwareUpdateV2.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV3.d.ts +7 -3
- package/dist/api/FirmwareUpdateV3.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV4.d.ts +27 -13
- 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 +5 -1
- package/dist/api/device/DeviceUpdateBootloader.d.ts.map +1 -1
- package/dist/api/firmware/FirmwareArtifactSource.d.ts +25 -0
- package/dist/api/firmware/FirmwareArtifactSource.d.ts.map +1 -0
- package/dist/api/firmware/FirmwareHostBinding.d.ts +6 -0
- package/dist/api/firmware/FirmwareHostBinding.d.ts.map +1 -0
- package/dist/api/firmware/FirmwarePreparationError.d.ts +3 -0
- package/dist/api/firmware/FirmwarePreparationError.d.ts.map +1 -0
- package/dist/api/firmware/FirmwareUpdateBaseMethod.d.ts +11 -4
- package/dist/api/firmware/FirmwareUpdateBaseMethod.d.ts.map +1 -1
- package/dist/api/firmware/FirmwareUpdateCapabilities.d.ts +3 -0
- package/dist/api/firmware/FirmwareUpdateCapabilities.d.ts.map +1 -0
- package/dist/api/firmware/FirmwareUpdatePlan.d.ts +25 -0
- package/dist/api/firmware/FirmwareUpdatePlan.d.ts.map +1 -0
- package/dist/api/firmware/FirmwareUpdatePreparedPlan.d.ts +32 -0
- package/dist/api/firmware/FirmwareUpdatePreparedPlan.d.ts.map +1 -0
- package/dist/api/firmware/getBinary.d.ts +7 -0
- package/dist/api/firmware/getBinary.d.ts.map +1 -1
- package/dist/api/firmware/progressThrottle.d.ts +3 -0
- package/dist/api/firmware/progressThrottle.d.ts.map +1 -0
- package/dist/api/firmware/updateBootloader.d.ts +2 -0
- package/dist/api/firmware/updateBootloader.d.ts.map +1 -1
- package/dist/api/firmware/uploadFirmware.d.ts +9 -1
- package/dist/api/firmware/uploadFirmware.d.ts.map +1 -1
- package/dist/api/helpers/protocolV2FileWrite.d.ts +0 -9
- package/dist/api/helpers/protocolV2FileWrite.d.ts.map +1 -1
- package/dist/api/index.d.ts +0 -2
- 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/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 +0 -2
- package/dist/core/deviceEventRegistration.d.ts.map +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/data-manager/DataManager.d.ts +4 -9
- 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 +6 -29
- 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 +1 -2
- 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 +0 -4
- 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 +2 -4
- package/dist/events/ui-promise.d.ts.map +1 -1
- package/dist/events/ui-request.d.ts +2 -31
- package/dist/events/ui-request.d.ts.map +1 -1
- package/dist/events/ui-response.d.ts +2 -10
- package/dist/events/ui-response.d.ts.map +1 -1
- package/dist/index.d.ts +247 -243
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3773 -3054
- package/dist/inject.d.ts +1 -6
- package/dist/inject.d.ts.map +1 -1
- package/dist/lowLevelInject.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/features.d.ts +4 -0
- 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/lockedError.d.ts +2 -0
- package/dist/protocols/protocol-v2/lockedError.d.ts.map +1 -0
- package/dist/protocols/protocol-v2/uiInteraction.d.ts +4 -7
- package/dist/protocols/protocol-v2/uiInteraction.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/unlockPolicy.d.ts +3 -1
- package/dist/protocols/protocol-v2/unlockPolicy.d.ts.map +1 -1
- package/dist/protocols/protocol-v2/unlockRetry.d.ts +10 -0
- package/dist/protocols/protocol-v2/unlockRetry.d.ts.map +1 -0
- package/dist/protocols/protocol-v2/walletSession.d.ts +1 -6
- 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 +5 -3
- package/dist/types/api/checkAllFirmwareRelease.d.ts.map +1 -1
- package/dist/types/api/deviceUnlock.d.ts +1 -5
- package/dist/types/api/deviceUnlock.d.ts.map +1 -1
- package/dist/types/api/deviceUpdateBootloader.d.ts +6 -0
- package/dist/types/api/deviceUpdateBootloader.d.ts.map +1 -1
- package/dist/types/api/export.d.ts +4 -2
- package/dist/types/api/export.d.ts.map +1 -1
- package/dist/types/api/firmwareUpdate.d.ts +70 -4
- package/dist/types/api/firmwareUpdate.d.ts.map +1 -1
- package/dist/types/api/firmwareUpdateCapabilities.d.ts +9 -0
- package/dist/types/api/firmwareUpdateCapabilities.d.ts.map +1 -0
- package/dist/types/api/firmwareUpdatePlan.d.ts +28 -0
- package/dist/types/api/firmwareUpdatePlan.d.ts.map +1 -0
- package/dist/types/api/firmwareUpdatePreparedPlan.d.ts +42 -0
- package/dist/types/api/firmwareUpdatePreparedPlan.d.ts.map +1 -0
- package/dist/types/api/index.d.ts +10 -7
- package/dist/types/api/index.d.ts.map +1 -1
- package/dist/types/api/protocolV2.d.ts +0 -3
- 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 +0 -1
- package/dist/types/params.d.ts.map +1 -1
- package/dist/types/settings.d.ts +21 -38
- package/dist/types/settings.d.ts.map +1 -1
- package/dist/utils/deviceFeaturesCompat.d.ts +1 -0
- package/dist/utils/deviceFeaturesCompat.d.ts.map +1 -1
- package/dist/utils/deviceFeaturesUtils.d.ts +0 -4
- 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 +0 -4
- 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/pro2Wallpaper.d.ts +0 -10
- package/dist/utils/pro2Wallpaper.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/api/BaseMethod.ts +10 -8
- package/src/api/CheckAllFirmwareRelease.ts +60 -59
- package/src/api/FirmwareUpdate.ts +15 -7
- package/src/api/FirmwareUpdateV2.ts +298 -126
- package/src/api/FirmwareUpdateV3.ts +265 -63
- package/src/api/FirmwareUpdateV4.ts +1017 -602
- package/src/api/GetPassphraseState.ts +1 -7
- package/src/api/OpenWalletSession.ts +17 -71
- package/src/api/SearchDevices.ts +1 -3
- package/src/api/allnetwork/AllNetworkGetAddress.ts +21 -21
- package/src/api/allnetwork/AllNetworkGetAddressBase.ts +11 -36
- package/src/api/device/DeviceSettings.ts +4 -5
- package/src/api/device/DeviceUnlock.ts +3 -8
- package/src/api/device/DeviceUpdateBootloader.ts +125 -6
- package/src/api/firmware/FirmwareArtifactSource.ts +278 -0
- package/src/api/firmware/FirmwareHostBinding.ts +100 -0
- package/src/api/firmware/FirmwarePreparationError.ts +12 -0
- package/src/api/firmware/FirmwareUpdateBaseMethod.ts +83 -27
- package/src/api/firmware/FirmwareUpdateCapabilities.ts +9 -0
- package/src/api/firmware/FirmwareUpdatePlan.ts +772 -0
- package/src/api/firmware/FirmwareUpdatePreparedPlan.ts +449 -0
- package/src/api/firmware/progressThrottle.ts +44 -0
- package/src/api/firmware/updateBootloader.ts +19 -4
- package/src/api/firmware/uploadFirmware.ts +144 -39
- package/src/api/helpers/protocolV2FileWrite.ts +63 -202
- package/src/api/index.ts +0 -2
- package/src/api/kaspa/KaspaGetAddress.ts +1 -1
- package/src/api/kaspa/KaspaSignTransaction.ts +13 -2
- package/src/api/polkadot/networks.ts +3 -3
- package/src/api/protocol-v2/ProtocolInfoRequest.ts +1 -3
- 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 +0 -4
- package/src/core/index.ts +111 -213
- package/src/data/messages/messages-protocol-v2.json +0 -25
- package/src/data-manager/DataManager.ts +41 -113
- package/src/data-manager/TransportManager.ts +0 -6
- package/src/data-manager/connectSettings.ts +11 -0
- package/src/device/Device.ts +49 -274
- package/src/device/DeviceCommands.ts +4 -31
- package/src/device/DeviceConnector.ts +13 -33
- package/src/device/DevicePool.ts +7 -21
- package/src/deviceProfile/buildDeviceFeatures.ts +2 -2
- package/src/deviceProfile/protocolV2DeviceIdentity.ts +0 -3
- package/src/events/device.ts +0 -4
- package/src/events/logBlockEvent.ts +0 -1
- package/src/events/ui-promise.ts +2 -4
- package/src/events/ui-request.ts +2 -36
- package/src/events/ui-response.ts +2 -12
- package/src/index.ts +5 -0
- package/src/inject.ts +24 -60
- package/src/lowLevelInject.ts +8 -7
- package/src/protocols/protocol-v2/features.ts +7 -10
- package/src/protocols/protocol-v2/firmware.ts +0 -2
- package/src/protocols/protocol-v2/lockedError.ts +10 -0
- package/src/protocols/protocol-v2/uiInteraction.ts +6 -46
- package/src/protocols/protocol-v2/unlockPolicy.ts +105 -1
- package/src/protocols/protocol-v2/unlockRetry.ts +109 -0
- package/src/protocols/protocol-v2/walletSession.ts +36 -214
- package/src/topLevelInject.ts +8 -7
- package/src/types/api/checkAllFirmwareRelease.ts +5 -3
- package/src/types/api/deviceUnlock.ts +1 -12
- package/src/types/api/deviceUpdateBootloader.ts +6 -0
- package/src/types/api/export.ts +18 -1
- package/src/types/api/firmwareUpdate.ts +78 -6
- package/src/types/api/firmwareUpdateCapabilities.ts +9 -0
- package/src/types/api/firmwareUpdatePlan.ts +38 -0
- package/src/types/api/firmwareUpdatePreparedPlan.ts +53 -0
- package/src/types/api/index.ts +14 -13
- package/src/types/api/protocolV2.ts +0 -13
- package/src/types/device.ts +3 -15
- package/src/types/params.ts +1 -7
- package/src/types/settings.ts +22 -60
- package/src/utils/deviceFeaturesCompat.ts +6 -5
- package/src/utils/deviceFeaturesUtils.ts +3 -14
- package/src/utils/deviceInfoUtils.ts +0 -2
- package/src/utils/deviceSettings.ts +0 -3
- package/src/utils/homescreen.ts +6 -32
- package/src/utils/index.ts +1 -6
- package/src/utils/pro2Wallpaper.ts +8 -35
- package/__tests__/core-initialization.test.ts +0 -23
- package/__tests__/device-connector-protocol.test.ts +0 -81
- package/__tests__/deviceUploadNft.test.ts +0 -316
- package/__tests__/pro2Nft.test.ts +0 -108
- package/__tests__/protocol-binding.test.ts +0 -89
- package/__tests__/protocol-v2-resources.test.ts +0 -340
- package/__tests__/protocol-v2-ui-lifecycle.test.ts +0 -91
- package/__tests__/uiProgressThrottle.test.ts +0 -74
- package/__tests__/uiPromiseRegistry.test.ts +0 -115
- package/dist/api/DetectDeviceConnectProtocol.d.ts +0 -7
- package/dist/api/DetectDeviceConnectProtocol.d.ts.map +0 -1
- package/dist/api/protocol-v2/DeviceUploadNft.d.ts +0 -31
- package/dist/api/protocol-v2/DeviceUploadNft.d.ts.map +0 -1
- package/dist/core/uiPromiseRegistry.d.ts +0 -6
- package/dist/core/uiPromiseRegistry.d.ts.map +0 -1
- package/dist/protocols/protocol-v2/resources.d.ts +0 -30
- package/dist/protocols/protocol-v2/resources.d.ts.map +0 -1
- package/dist/protocols/protocol-v2/unlockPolicyRunner.d.ts +0 -22
- package/dist/protocols/protocol-v2/unlockPolicyRunner.d.ts.map +0 -1
- package/dist/types/api/detectDeviceConnectProtocol.d.ts +0 -4
- package/dist/types/api/detectDeviceConnectProtocol.d.ts.map +0 -1
- package/dist/utils/pro2Nft.d.ts +0 -31
- package/dist/utils/pro2Nft.d.ts.map +0 -1
- package/dist/utils/uiProgressThrottle.d.ts +0 -3
- package/dist/utils/uiProgressThrottle.d.ts.map +0 -1
- package/src/api/DetectDeviceConnectProtocol.ts +0 -18
- package/src/api/protocol-v2/DeviceUploadNft.ts +0 -197
- package/src/core/uiPromiseRegistry.ts +0 -63
- package/src/protocols/protocol-v2/resources.ts +0 -390
- package/src/protocols/protocol-v2/unlockPolicyRunner.ts +0 -131
- package/src/types/api/detectDeviceConnectProtocol.ts +0 -6
- package/src/utils/pro2Nft.ts +0 -142
- package/src/utils/uiProgressThrottle.ts +0 -63
package/src/core/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import semver from 'semver';
|
|
2
2
|
import EventEmitter from 'events';
|
|
3
|
-
import {
|
|
3
|
+
import { TRANSPORT_EVENT } from '@onekeyfe/hd-transport';
|
|
4
4
|
import {
|
|
5
5
|
ERRORS,
|
|
6
6
|
ERROR_CODES_REQUIRE_RELEASE,
|
|
@@ -26,7 +26,6 @@ import {
|
|
|
26
26
|
createRequestContext,
|
|
27
27
|
createSdkTracingContext,
|
|
28
28
|
formatRequestContext,
|
|
29
|
-
generateInstanceId,
|
|
30
29
|
getActiveRequestsByDeviceInstance,
|
|
31
30
|
updateRequestContext,
|
|
32
31
|
} from '../utils/tracing';
|
|
@@ -54,15 +53,13 @@ import {
|
|
|
54
53
|
import TransportManager from '../data-manager/TransportManager';
|
|
55
54
|
import DeviceConnector from '../device/DeviceConnector';
|
|
56
55
|
import RequestQueue from './RequestQueue';
|
|
57
|
-
import { consumeUiPromise, findUiPromiseForResponse, rejectUiPromises } from './uiPromiseRegistry';
|
|
58
56
|
import { registerHardwareUiEventListeners } from './deviceEventRegistration';
|
|
59
57
|
import { getSynchronize } from '../utils/getSynchronize';
|
|
60
|
-
import {
|
|
58
|
+
import { runMethodWithUnlockRetry } from '../protocols/protocol-v2/unlockRetry';
|
|
61
59
|
import {
|
|
62
60
|
ProtocolV2UiInteractionCoordinator,
|
|
63
61
|
isProtocolV2UiEnabled,
|
|
64
62
|
} from '../protocols/protocol-v2/uiInteraction';
|
|
65
|
-
import { createUiProgressMessageFilter } from '../utils/uiProgressThrottle';
|
|
66
63
|
|
|
67
64
|
import type { ConnectSettings, Features, KnownDevice } from '../types';
|
|
68
65
|
import type { CoreMessage, IFrameCallMessage, UiPromise, UiPromiseResponse } from '../events';
|
|
@@ -106,7 +103,6 @@ const parseInitOptions = (method?: BaseMethod): InitOptions => ({
|
|
|
106
103
|
deviceId: method?.payload.deviceId,
|
|
107
104
|
deriveCardano: method && hasDeriveCardano(method),
|
|
108
105
|
connectProtocol: method?.payload.connectProtocol,
|
|
109
|
-
forceProtocolDetection: method?.payload.forceProtocolDetection,
|
|
110
106
|
protocolV2DeviceInfoTimeoutMs: method?.payload.protocolV2DeviceInfoTimeoutMs,
|
|
111
107
|
});
|
|
112
108
|
|
|
@@ -158,12 +154,7 @@ export const callAPI = async (context: CoreContext, message: CoreMessage) => {
|
|
|
158
154
|
try {
|
|
159
155
|
method = findMethod(message as IFrameCallMessage);
|
|
160
156
|
method.connector = _connector;
|
|
161
|
-
|
|
162
|
-
method.postMessage = event => {
|
|
163
|
-
if (shouldPostMessage(event)) {
|
|
164
|
-
postMessage(event);
|
|
165
|
-
}
|
|
166
|
-
};
|
|
157
|
+
method.postMessage = postMessage;
|
|
167
158
|
method.setContext?.(context);
|
|
168
159
|
|
|
169
160
|
method.requestContext = createRequestContext(method.responseID, method.name, {
|
|
@@ -415,8 +406,6 @@ const onCallDevice = async (
|
|
|
415
406
|
|
|
416
407
|
registerHardwareUiEventListeners(device, {
|
|
417
408
|
pin: onDevicePinHandler,
|
|
418
|
-
pinOnDevice: onEnterPinOnDeviceHandler,
|
|
419
|
-
pinOnDeviceComplete: onPinOnDeviceCompleteHandler,
|
|
420
409
|
button: onDeviceButtonHandler,
|
|
421
410
|
passphrase: message.payload.useEmptyPassphrase
|
|
422
411
|
? onEmptyPassphraseHandler
|
|
@@ -432,9 +421,6 @@ const onCallDevice = async (
|
|
|
432
421
|
);
|
|
433
422
|
|
|
434
423
|
const protocolV2UiCoordinator = new ProtocolV2UiInteractionCoordinator(device, postMessage);
|
|
435
|
-
let protocolV2Operation = false;
|
|
436
|
-
let protocolV2CloseEmitted = false;
|
|
437
|
-
device.beginProtocolV2UiInteraction();
|
|
438
424
|
device.on(
|
|
439
425
|
DEVICE.SELECT_DEVICE_FOR_SWITCH_FIRMWARE_WEB_DEVICE,
|
|
440
426
|
onSelectDeviceForSwitchFirmwareWebDeviceHandler
|
|
@@ -452,7 +438,6 @@ const onCallDevice = async (
|
|
|
452
438
|
// Protocol is established from an active device response during acquire/initialize.
|
|
453
439
|
// Reject unsupported methods before any method-specific device command is sent.
|
|
454
440
|
method.assertProtocolSupported(device.getProtocol(), device.getCurrentFirmwareType());
|
|
455
|
-
protocolV2Operation = device.isProtocolV2();
|
|
456
441
|
|
|
457
442
|
// check firmware version
|
|
458
443
|
const versionRange = device.getCurrentMethodVersionRange(
|
|
@@ -562,102 +547,93 @@ const onCallDevice = async (
|
|
|
562
547
|
);
|
|
563
548
|
}
|
|
564
549
|
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
if (!device.checkDeviceId(method.deviceId)) {
|
|
572
|
-
throw ERRORS.TypedError(HardwareErrorCode.DeviceCheckDeviceIdError);
|
|
573
|
-
}
|
|
574
|
-
deviceIdCheckedDuringUnlockPreflight = true;
|
|
575
|
-
}
|
|
576
|
-
},
|
|
577
|
-
prepare: async () => {
|
|
578
|
-
if (method.deviceId && method.checkDeviceId && !deviceIdCheckedDuringUnlockPreflight) {
|
|
579
|
-
const isSameDeviceID = await checkLiveDeviceId(device, method.deviceId);
|
|
580
|
-
if (!isSameDeviceID) {
|
|
581
|
-
throw ERRORS.TypedError(HardwareErrorCode.DeviceCheckDeviceIdError);
|
|
582
|
-
}
|
|
583
|
-
}
|
|
550
|
+
if (method.deviceId && method.checkDeviceId) {
|
|
551
|
+
const isSameDeviceID = await checkLiveDeviceId(device, method.deviceId);
|
|
552
|
+
if (!isSameDeviceID) {
|
|
553
|
+
return Promise.reject(ERRORS.TypedError(HardwareErrorCode.DeviceCheckDeviceIdError));
|
|
554
|
+
}
|
|
555
|
+
}
|
|
584
556
|
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
557
|
+
/**
|
|
558
|
+
* check firmware release info
|
|
559
|
+
*/
|
|
560
|
+
method.checkFirmwareRelease();
|
|
589
561
|
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
562
|
+
/**
|
|
563
|
+
* check additional supported feature
|
|
564
|
+
*/
|
|
565
|
+
method.checkDeviceSupportFeature();
|
|
594
566
|
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
567
|
+
// reconfigure messages
|
|
568
|
+
if (_deviceList && device.features && !device.isProtocolV2()) {
|
|
569
|
+
await TransportManager.reconfigure(device.features);
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
// Check to see if it is safe to use Passphrase
|
|
573
|
+
checkPassphraseEnableState(method, device.features);
|
|
599
574
|
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
{
|
|
611
|
-
require: support.require,
|
|
612
|
-
}
|
|
613
|
-
);
|
|
575
|
+
if (shouldCheckPassphraseState(method, device)) {
|
|
576
|
+
// check version
|
|
577
|
+
const support = device.supportNewPassphrase();
|
|
578
|
+
if (!support.support) {
|
|
579
|
+
return Promise.reject(
|
|
580
|
+
ERRORS.TypedError(
|
|
581
|
+
HardwareErrorCode.DeviceNotSupportPassphrase,
|
|
582
|
+
`Device not support passphrase, please update to ${support.require}`,
|
|
583
|
+
{
|
|
584
|
+
require: support.require,
|
|
614
585
|
}
|
|
586
|
+
)
|
|
587
|
+
);
|
|
588
|
+
}
|
|
615
589
|
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
);
|
|
590
|
+
// Check Device passphrase State
|
|
591
|
+
const passphraseStateSafety = await device.checkPassphraseStateSafety(
|
|
592
|
+
method.payload?.passphraseState,
|
|
593
|
+
method.payload?.useEmptyPassphrase,
|
|
594
|
+
method.payload?.skipPassphraseCheck
|
|
595
|
+
);
|
|
623
596
|
|
|
624
|
-
|
|
625
|
-
|
|
597
|
+
// Double check, handles the special case of Touch/Pro
|
|
598
|
+
checkPassphraseEnableState(method, device.features);
|
|
626
599
|
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
600
|
+
if (!passphraseStateSafety) {
|
|
601
|
+
DevicePool.clearDeviceCache(method.payload.connectId);
|
|
602
|
+
return Promise.reject(
|
|
603
|
+
ERRORS.TypedError(HardwareErrorCode.DeviceCheckPassphraseStateError)
|
|
604
|
+
);
|
|
605
|
+
}
|
|
631
606
|
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
postMessage(createUiMessage(UI_REQUEST.CLOSE_UI_PIN_WINDOW));
|
|
636
|
-
}
|
|
637
|
-
}
|
|
607
|
+
// close pin popup window
|
|
608
|
+
postMessage(createUiMessage(UI_REQUEST.CLOSE_UI_PIN_WINDOW));
|
|
609
|
+
}
|
|
638
610
|
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
611
|
+
// Automatic check safety_check level for Kovan, Ropsten, Rinkeby, Goerli test networks.
|
|
612
|
+
try {
|
|
613
|
+
await method.checkSafetyLevelOnTestNet();
|
|
614
|
+
} catch (e) {
|
|
615
|
+
const error =
|
|
616
|
+
e instanceof HardwareError
|
|
617
|
+
? e
|
|
618
|
+
: ERRORS.TypedError(HardwareErrorCode.RuntimeError, 'open safety check failed.');
|
|
619
|
+
// messageResponse = createResponseMessage(method.responseID, false, { error });
|
|
620
|
+
// requestQueue.resolveRequest(method.responseID, messageResponse);
|
|
621
|
+
// return;
|
|
622
|
+
throw error;
|
|
623
|
+
}
|
|
647
624
|
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
625
|
+
method.device?.commands?.checkDisposed();
|
|
626
|
+
|
|
627
|
+
try {
|
|
628
|
+
const response: object = await runMethodWithUnlockRetry(
|
|
629
|
+
method,
|
|
630
|
+
device,
|
|
631
|
+
protocolV2UiCoordinator
|
|
632
|
+
);
|
|
651
633
|
messageResponse = createResponseMessage(method.responseID, true, response);
|
|
652
634
|
requestQueue.resolveRequest(method.responseID, messageResponse);
|
|
653
635
|
completeMethodRequestContext(method);
|
|
654
636
|
} catch (error) {
|
|
655
|
-
// Device.run may release the request before transport callbacks finish after a timeout.
|
|
656
|
-
// Ignore the stale callback because the caller already received the connection error.
|
|
657
|
-
if (!requestQueue.getTask(method.responseID)) {
|
|
658
|
-
Log.debug(`Call API - Ignore late inner method result`, error);
|
|
659
|
-
return;
|
|
660
|
-
}
|
|
661
637
|
Log.debug(`Call API - Inner Method Run Error`, error);
|
|
662
638
|
messageResponse = createResponseMessage(method.responseID, false, { error });
|
|
663
639
|
requestQueue.resolveRequest(method.responseID, messageResponse);
|
|
@@ -671,12 +647,7 @@ const onCallDevice = async (
|
|
|
671
647
|
throw error;
|
|
672
648
|
}
|
|
673
649
|
} finally {
|
|
674
|
-
|
|
675
|
-
protocolV2CloseEmitted = protocolV2UiCoordinator.close({
|
|
676
|
-
ensureOperationClose: protocolV2Operation,
|
|
677
|
-
protocolV2Operation,
|
|
678
|
-
});
|
|
679
|
-
}
|
|
650
|
+
protocolV2UiCoordinator.close();
|
|
680
651
|
}
|
|
681
652
|
};
|
|
682
653
|
Log.debug('Call API - Device Run: ', device.mainId);
|
|
@@ -731,15 +702,7 @@ const onCallDevice = async (
|
|
|
731
702
|
requestQueue.releaseTask(method.responseID);
|
|
732
703
|
|
|
733
704
|
if (isProtocolV2UiEnabled(method)) {
|
|
734
|
-
|
|
735
|
-
protocolV2CloseEmitted = protocolV2UiCoordinator.close({
|
|
736
|
-
ensureOperationClose: true,
|
|
737
|
-
protocolV2Operation: true,
|
|
738
|
-
});
|
|
739
|
-
}
|
|
740
|
-
if (!protocolV2CloseEmitted) {
|
|
741
|
-
closePopup();
|
|
742
|
-
}
|
|
705
|
+
closePopup();
|
|
743
706
|
}
|
|
744
707
|
|
|
745
708
|
cleanup();
|
|
@@ -902,18 +865,10 @@ function isRetryableBleProtocolV2ProbeError(method: BaseMethod, error: unknown)
|
|
|
902
865
|
*/
|
|
903
866
|
async function connectDeviceForBle(method: BaseMethod, device: Device, retryCount = 0) {
|
|
904
867
|
try {
|
|
905
|
-
if (method.payload.forceProtocolDetection && device.hasDeviceAcquire()) {
|
|
906
|
-
await device.release();
|
|
907
|
-
}
|
|
908
868
|
const shouldAcquire =
|
|
909
|
-
|
|
910
|
-
!device.hasDeviceAcquire() ||
|
|
911
|
-
!device.commands ||
|
|
912
|
-
device.commands.disposed;
|
|
869
|
+
!device.hasDeviceAcquire() || !device.commands || device.commands.disposed;
|
|
913
870
|
if (shouldAcquire) {
|
|
914
|
-
await device.acquire(method.payload.connectProtocol
|
|
915
|
-
forceProtocolDetection: method.payload.forceProtocolDetection,
|
|
916
|
-
});
|
|
871
|
+
await device.acquire(method.payload.connectProtocol);
|
|
917
872
|
}
|
|
918
873
|
if (method.payload?.onlyConnectBleDevice) {
|
|
919
874
|
if (shouldAcquire) {
|
|
@@ -1226,12 +1181,7 @@ const shouldCheckPassphraseState = (method: BaseMethod, device: Device) => {
|
|
|
1226
1181
|
};
|
|
1227
1182
|
|
|
1228
1183
|
const cleanup = () => {
|
|
1229
|
-
const pendingUiPromises = _uiPromises;
|
|
1230
1184
|
_uiPromises = [];
|
|
1231
|
-
rejectUiPromises(
|
|
1232
|
-
pendingUiPromises,
|
|
1233
|
-
ERRORS.TypedError(HardwareErrorCode.ActionCancelled, 'UI request was cancelled')
|
|
1234
|
-
);
|
|
1235
1185
|
Log.debug('Cleanup...');
|
|
1236
1186
|
};
|
|
1237
1187
|
|
|
@@ -1273,7 +1223,7 @@ const onTransportDeviceDisconnectHandler = (event: TransportDeviceDisconnectEven
|
|
|
1273
1223
|
DevicePool.emitter.emit(DEVICE.DISCONNECT, device);
|
|
1274
1224
|
};
|
|
1275
1225
|
|
|
1276
|
-
const onDevicePinHandler = (...[device, type, callback]: DeviceEvents['pin']) => {
|
|
1226
|
+
const onDevicePinHandler = async (...[device, type, callback]: DeviceEvents['pin']) => {
|
|
1277
1227
|
Log.log('request Input PIN');
|
|
1278
1228
|
// create ui promise
|
|
1279
1229
|
const uiPromise = createUiPromise(UI_RESPONSE.RECEIVE_PIN, device);
|
|
@@ -1282,14 +1232,12 @@ const onDevicePinHandler = (...[device, type, callback]: DeviceEvents['pin']) =>
|
|
|
1282
1232
|
createUiMessage(UI_REQUEST.REQUEST_PIN, {
|
|
1283
1233
|
device: device.toMessageObject() as unknown as KnownDevice,
|
|
1284
1234
|
type,
|
|
1285
|
-
responseCorrelation: uiPromise.responseCorrelation,
|
|
1286
1235
|
})
|
|
1287
1236
|
);
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
);
|
|
1237
|
+
// wait for pin
|
|
1238
|
+
const uiResp = await uiPromise.promise;
|
|
1239
|
+
// callback.apply(null, [null, pin]);
|
|
1240
|
+
callback(null, uiResp.payload);
|
|
1293
1241
|
};
|
|
1294
1242
|
|
|
1295
1243
|
export const onDeviceButtonHandler = (...[device, request]: [...DeviceEvents['button']]) => {
|
|
@@ -1317,7 +1265,7 @@ const onDeviceStateHandler = (...[_, stateEvent]: [...DeviceEvents['state']]) =>
|
|
|
1317
1265
|
postMessage(createDeviceMessage(DEVICE.STATE, stateEvent));
|
|
1318
1266
|
};
|
|
1319
1267
|
|
|
1320
|
-
const onDevicePassphraseHandler = (
|
|
1268
|
+
const onDevicePassphraseHandler = async (
|
|
1321
1269
|
...[device, requestPayload, callback]: DeviceEvents['passphrase']
|
|
1322
1270
|
) => {
|
|
1323
1271
|
Log.debug('onDevicePassphraseHandler');
|
|
@@ -1331,23 +1279,18 @@ const onDevicePassphraseHandler = (
|
|
|
1331
1279
|
source: requestPayload.source,
|
|
1332
1280
|
reason: requestPayload.reason,
|
|
1333
1281
|
expectedPassphraseState: requestPayload.expectedPassphraseState,
|
|
1334
|
-
...(requestPayload.interaction ? { interaction: requestPayload.interaction } : {}),
|
|
1335
|
-
responseCorrelation: uiPromise.responseCorrelation,
|
|
1336
1282
|
})
|
|
1337
1283
|
);
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
},
|
|
1349
|
-
error => callback({}, error)
|
|
1350
|
-
);
|
|
1284
|
+
// wait for passphrase
|
|
1285
|
+
const uiResp = await uiPromise.promise;
|
|
1286
|
+
const { value, passphraseOnDevice, save, attachPinOnDevice } = uiResp.payload;
|
|
1287
|
+
// send as PassphrasePromptResponse
|
|
1288
|
+
callback({
|
|
1289
|
+
passphrase: value.normalize('NFKD'),
|
|
1290
|
+
passphraseOnDevice,
|
|
1291
|
+
attachPinOnDevice,
|
|
1292
|
+
cache: save,
|
|
1293
|
+
});
|
|
1351
1294
|
};
|
|
1352
1295
|
|
|
1353
1296
|
const onEmptyPassphraseHandler = (...[_, , callback]: DeviceEvents['passphrase']) => {
|
|
@@ -1365,7 +1308,6 @@ const onEnterPassphraseOnDeviceHandler = (
|
|
|
1365
1308
|
passphraseState: device.passphraseState,
|
|
1366
1309
|
source: requestPayload?.source,
|
|
1367
1310
|
reason: requestPayload?.reason,
|
|
1368
|
-
...(requestPayload?.interaction ? { interaction: requestPayload.interaction } : {}),
|
|
1369
1311
|
})
|
|
1370
1312
|
);
|
|
1371
1313
|
};
|
|
@@ -1379,40 +1321,11 @@ const onEnterAttachPinOnDeviceHandler = (
|
|
|
1379
1321
|
type: 'ButtonRequest_AttachPin',
|
|
1380
1322
|
source: requestPayload?.source,
|
|
1381
1323
|
reason: requestPayload?.reason,
|
|
1382
|
-
...(requestPayload?.interaction ? { interaction: requestPayload.interaction } : {}),
|
|
1383
1324
|
})
|
|
1384
1325
|
);
|
|
1385
1326
|
};
|
|
1386
1327
|
|
|
1387
|
-
const
|
|
1388
|
-
...[device, pinType, metadata]: [...DeviceEvents['pin_on_device']]
|
|
1389
|
-
) => {
|
|
1390
|
-
postMessage(
|
|
1391
|
-
createUiMessage(UI_REQUEST.REQUEST_PIN, {
|
|
1392
|
-
device: device.toMessageObject() as KnownDevice,
|
|
1393
|
-
type:
|
|
1394
|
-
pinType === DeviceSessionPinType.AttachToPin
|
|
1395
|
-
? 'ButtonRequest_AttachPin'
|
|
1396
|
-
: 'ButtonRequest_PinEntry',
|
|
1397
|
-
source: metadata?.source,
|
|
1398
|
-
reason: metadata?.reason,
|
|
1399
|
-
deviceOnly: metadata?.deviceOnly ?? true,
|
|
1400
|
-
completion: metadata?.completion,
|
|
1401
|
-
method: metadata?.method,
|
|
1402
|
-
page: metadata?.page,
|
|
1403
|
-
operation: metadata?.operation,
|
|
1404
|
-
...(metadata?.interaction ? { interaction: metadata.interaction } : {}),
|
|
1405
|
-
})
|
|
1406
|
-
);
|
|
1407
|
-
};
|
|
1408
|
-
|
|
1409
|
-
const onPinOnDeviceCompleteHandler = (
|
|
1410
|
-
...[_, metadata]: [...DeviceEvents['pin_on_device_complete']]
|
|
1411
|
-
) => {
|
|
1412
|
-
postMessage(createUiMessage(UI_REQUEST.CLOSE_UI_PIN_WINDOW, metadata));
|
|
1413
|
-
};
|
|
1414
|
-
|
|
1415
|
-
const onSelectDeviceInBootloaderForWebDeviceHandler = (
|
|
1328
|
+
const onSelectDeviceInBootloaderForWebDeviceHandler = async (
|
|
1416
1329
|
...[device, callback]: [...DeviceEvents['select_device_in_bootloader_for_web_device']]
|
|
1417
1330
|
) => {
|
|
1418
1331
|
Log.debug('onSelectDeviceInBootloaderForWebDeviceHandler');
|
|
@@ -1422,14 +1335,11 @@ const onSelectDeviceInBootloaderForWebDeviceHandler = (
|
|
|
1422
1335
|
device: device.toMessageObject() as KnownDevice,
|
|
1423
1336
|
})
|
|
1424
1337
|
);
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
uiResp => callback(null, uiResp.payload.deviceId),
|
|
1428
|
-
error => callback(error, '')
|
|
1429
|
-
);
|
|
1338
|
+
const uiResp = await uiPromise.promise;
|
|
1339
|
+
callback(null, uiResp.payload.deviceId);
|
|
1430
1340
|
};
|
|
1431
1341
|
|
|
1432
|
-
const onSelectDeviceForSwitchFirmwareWebDeviceHandler = (
|
|
1342
|
+
const onSelectDeviceForSwitchFirmwareWebDeviceHandler = async (
|
|
1433
1343
|
...[device, callback]: [...DeviceEvents['select_device_for_switch_firmware_web_device']]
|
|
1434
1344
|
) => {
|
|
1435
1345
|
Log.debug('onSelectDeviceForSwitchFirmwareWebDeviceHandler');
|
|
@@ -1442,11 +1352,8 @@ const onSelectDeviceForSwitchFirmwareWebDeviceHandler = (
|
|
|
1442
1352
|
device: device.toMessageObject() as KnownDevice,
|
|
1443
1353
|
})
|
|
1444
1354
|
);
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
uiResp => callback(null, uiResp.payload.deviceId),
|
|
1448
|
-
error => callback(error, '')
|
|
1449
|
-
);
|
|
1355
|
+
const uiResp = await uiPromise.promise;
|
|
1356
|
+
callback(null, uiResp.payload.deviceId);
|
|
1450
1357
|
};
|
|
1451
1358
|
|
|
1452
1359
|
/**
|
|
@@ -1465,21 +1372,14 @@ const postMessage = (message: CoreMessage) => {
|
|
|
1465
1372
|
|
|
1466
1373
|
const createUiPromise = <T extends UiPromiseResponse['type']>(promiseEvent: T, device?: Device) => {
|
|
1467
1374
|
const uiPromise: UiPromise<T> = createDeferred(promiseEvent, device);
|
|
1468
|
-
if (
|
|
1469
|
-
device &&
|
|
1470
|
-
(promiseEvent === UI_RESPONSE.RECEIVE_PIN || promiseEvent === UI_RESPONSE.RECEIVE_PASSPHRASE)
|
|
1471
|
-
) {
|
|
1472
|
-
const publicDeviceId = device.toMessageObject()?.deviceId;
|
|
1473
|
-
uiPromise.responseCorrelation = {
|
|
1474
|
-
interactionId: generateInstanceId('UiResponse', device.sdkInstanceId),
|
|
1475
|
-
deviceId: publicDeviceId || device.instanceId,
|
|
1476
|
-
};
|
|
1477
|
-
}
|
|
1478
1375
|
_uiPromises.push(uiPromise as any);
|
|
1479
1376
|
|
|
1480
1377
|
return uiPromise;
|
|
1481
1378
|
};
|
|
1482
1379
|
|
|
1380
|
+
const findUiPromise = <T extends UiPromiseResponse['type']>(promiseEvent: T) =>
|
|
1381
|
+
_uiPromises.find(p => p.id === promiseEvent);
|
|
1382
|
+
|
|
1483
1383
|
const removeUiPromise = (promise: Deferred<any>) => {
|
|
1484
1384
|
_uiPromises = _uiPromises.filter(p => p !== promise);
|
|
1485
1385
|
};
|
|
@@ -1531,16 +1431,11 @@ export default class Core extends EventEmitter {
|
|
|
1531
1431
|
case UI_RESPONSE.RECEIVE_PASSPHRASE:
|
|
1532
1432
|
case UI_RESPONSE.SELECT_DEVICE_IN_BOOTLOADER_FOR_WEB_DEVICE:
|
|
1533
1433
|
case UI_RESPONSE.SELECT_DEVICE_FOR_SWITCH_FIRMWARE_WEB_DEVICE: {
|
|
1534
|
-
const uiPromise =
|
|
1434
|
+
const uiPromise = findUiPromise(message.type);
|
|
1535
1435
|
if (uiPromise) {
|
|
1536
1436
|
Log.log('receive UI Response: ', message.type);
|
|
1537
1437
|
uiPromise.resolve(message);
|
|
1538
1438
|
removeUiPromise(uiPromise);
|
|
1539
|
-
} else if (
|
|
1540
|
-
message.type === UI_RESPONSE.RECEIVE_PIN ||
|
|
1541
|
-
message.type === UI_RESPONSE.RECEIVE_PASSPHRASE
|
|
1542
|
-
) {
|
|
1543
|
-
Log.warn('Ignored unmatched or ambiguous sensitive UI response:', message.type);
|
|
1544
1439
|
}
|
|
1545
1440
|
break;
|
|
1546
1441
|
}
|
|
@@ -1668,8 +1563,12 @@ export const init = async (
|
|
|
1668
1563
|
plugin?: LowlevelTransportSharedPlugin
|
|
1669
1564
|
) => {
|
|
1670
1565
|
try {
|
|
1671
|
-
|
|
1672
|
-
|
|
1566
|
+
try {
|
|
1567
|
+
await DataManager.load(settings);
|
|
1568
|
+
initTransport(Transport, plugin);
|
|
1569
|
+
} catch {
|
|
1570
|
+
Log.error('DataManager.load error');
|
|
1571
|
+
}
|
|
1673
1572
|
enableLog(DataManager.getSettings('debug'));
|
|
1674
1573
|
if (DataManager.getSettings('env') !== 'react-native') {
|
|
1675
1574
|
setLoggerPostMessage(postMessage);
|
|
@@ -1680,7 +1579,6 @@ export const init = async (
|
|
|
1680
1579
|
return _core;
|
|
1681
1580
|
} catch (error) {
|
|
1682
1581
|
Log.error('core init', error);
|
|
1683
|
-
throw error;
|
|
1684
1582
|
}
|
|
1685
1583
|
};
|
|
1686
1584
|
|
|
@@ -470,7 +470,6 @@
|
|
|
470
470
|
"MessageType_DeviceSessionAskPin": 61202,
|
|
471
471
|
"MessageType_DeviceSessionAskPassphrase": 61203,
|
|
472
472
|
"MessageType_PortfolioUpdate": 61400,
|
|
473
|
-
"MessageType_NftUpdate": 61500,
|
|
474
473
|
"MessageType_OnboardingStatusGet": 61600,
|
|
475
474
|
"MessageType_OnboardingStatus": 61601
|
|
476
475
|
},
|
|
@@ -12201,26 +12200,11 @@
|
|
|
12201
12200
|
"DeviceSessionError_Busy": 5
|
|
12202
12201
|
}
|
|
12203
12202
|
},
|
|
12204
|
-
"DeviceSessionSeedDomain": {
|
|
12205
|
-
"values": {
|
|
12206
|
-
"SeedDomain_Standard": 1,
|
|
12207
|
-
"SeedDomain_Cardano": 2
|
|
12208
|
-
}
|
|
12209
|
-
},
|
|
12210
12203
|
"DeviceSessionGet": {
|
|
12211
12204
|
"fields": {
|
|
12212
12205
|
"session_id": {
|
|
12213
12206
|
"type": "bytes",
|
|
12214
12207
|
"id": 1
|
|
12215
|
-
},
|
|
12216
|
-
"btc_test_address": {
|
|
12217
|
-
"type": "string",
|
|
12218
|
-
"id": 2
|
|
12219
|
-
},
|
|
12220
|
-
"seed_domains": {
|
|
12221
|
-
"rule": "repeated",
|
|
12222
|
-
"type": "DeviceSessionSeedDomain",
|
|
12223
|
-
"id": 3
|
|
12224
12208
|
}
|
|
12225
12209
|
}
|
|
12226
12210
|
},
|
|
@@ -12554,15 +12538,6 @@
|
|
|
12554
12538
|
}
|
|
12555
12539
|
}
|
|
12556
12540
|
},
|
|
12557
|
-
"NftUpdate": {
|
|
12558
|
-
"fields": {
|
|
12559
|
-
"file_name_no_ext": {
|
|
12560
|
-
"rule": "required",
|
|
12561
|
-
"type": "string",
|
|
12562
|
-
"id": 1
|
|
12563
|
-
}
|
|
12564
|
-
}
|
|
12565
|
-
},
|
|
12566
12541
|
"OnboardingStep": {
|
|
12567
12542
|
"values": {
|
|
12568
12543
|
"ONBOARDING_STEP_UNKNOWN": 0,
|