@trezor/connect 9.4.7-beta.1 → 9.4.8-beta.1
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/CHANGELOG.md +56 -9
- package/README.md +1 -1
- package/lib/api/applyFlags.d.ts +1 -1
- package/lib/api/applyFlags.js +1 -1
- package/lib/api/applySettings.d.ts +1 -1
- package/lib/api/authenticateDevice.js +1 -1
- package/lib/api/authorizeCoinjoin.d.ts +1 -1
- package/lib/api/authorizeCoinjoin.js +1 -1
- package/lib/api/backupDevice.d.ts +1 -1
- package/lib/api/backupDevice.js +1 -1
- package/lib/api/binance/api/binanceGetAddress.d.ts +1 -1
- package/lib/api/binance/api/binanceGetAddress.js +3 -3
- package/lib/api/binance/api/binanceGetPublicKey.d.ts +1 -1
- package/lib/api/binance/api/binanceGetPublicKey.js +2 -2
- package/lib/api/binance/api/binanceSignTransaction.js +2 -2
- package/lib/api/binance/binanceSignTx.d.ts +1 -1
- package/lib/api/bitcoin/TransactionComposer.d.ts +1 -1
- package/lib/api/bitcoin/inputs.d.ts +1 -1
- package/lib/api/bitcoin/inputs.js +1 -1
- package/lib/api/bitcoin/outputs.js +2 -2
- package/lib/api/bitcoin/refTx.d.ts +2 -2
- package/lib/api/bitcoin/refTx.js +4 -4
- package/lib/api/bitcoin/signtx.d.ts +2 -2
- package/lib/api/bitcoin/signtxLegacy.d.ts +1 -1
- package/lib/api/bitcoin/signtxVerify.d.ts +1 -1
- package/lib/api/blockchainDisconnect.js +2 -2
- package/lib/api/blockchainEstimateFee.d.ts +1 -1
- package/lib/api/blockchainEstimateFee.js +3 -2
- package/lib/api/blockchainEvmRpcCall.js +2 -2
- package/lib/api/blockchainGetAccountBalanceHistory.d.ts +1 -1
- package/lib/api/blockchainGetAccountBalanceHistory.js +1 -1
- package/lib/api/blockchainGetCurrentFiatRates.d.ts +1 -1
- package/lib/api/blockchainGetCurrentFiatRates.js +1 -1
- package/lib/api/blockchainGetFiatRatesForTimestamps.d.ts +1 -1
- package/lib/api/blockchainGetFiatRatesForTimestamps.js +1 -1
- package/lib/api/blockchainGetInfo.js +1 -1
- package/lib/api/blockchainGetTransactions.js +1 -1
- package/lib/api/blockchainSetCustomBackend.js +1 -1
- package/lib/api/blockchainSubscribe.d.ts +1 -1
- package/lib/api/blockchainSubscribe.js +1 -1
- package/lib/api/blockchainSubscribeFiatRates.d.ts +1 -1
- package/lib/api/blockchainSubscribeFiatRates.js +1 -1
- package/lib/api/blockchainUnsubscribe.d.ts +1 -1
- package/lib/api/blockchainUnsubscribe.js +1 -1
- package/lib/api/blockchainUnsubscribeFiatRates.js +1 -1
- package/lib/api/cancelCoinjoinAuthorization.d.ts +1 -1
- package/lib/api/cardano/api/cardanoComposeTransaction.d.ts +1 -1
- package/lib/api/cardano/api/cardanoComposeTransaction.js +3 -11
- package/lib/api/cardano/api/cardanoGetAddress.d.ts +1 -1
- package/lib/api/cardano/api/cardanoGetAddress.js +4 -4
- package/lib/api/cardano/api/cardanoGetNativeScriptHash.js +2 -2
- package/lib/api/cardano/api/cardanoGetPublicKey.js +2 -2
- package/lib/api/cardano/api/cardanoSignTransaction.d.ts +3 -3
- package/lib/api/cardano/api/cardanoSignTransaction.js +4 -4
- package/lib/api/cardano/cardanoAddressParameters.js +1 -1
- package/lib/api/cardano/cardanoAuxiliaryData.js +1 -1
- package/lib/api/cardano/cardanoCertificate.js +1 -1
- package/lib/api/cardano/cardanoInputs.js +1 -1
- package/lib/api/cardano/cardanoUtils.js +30 -0
- package/lib/api/changePin.d.ts +1 -1
- package/lib/api/changePin.js +1 -1
- package/lib/api/changeWipeCode.d.ts +1 -1
- package/lib/api/cipherKeyValue.d.ts +1 -1
- package/lib/api/cipherKeyValue.js +3 -3
- package/lib/api/common/Discovery.d.ts +2 -2
- package/lib/api/common/paramsValidator.js +1 -1
- package/lib/api/composeTransaction.d.ts +3 -3
- package/lib/api/composeTransaction.js +9 -9
- package/lib/api/eos/api/eosGetPublicKey.d.ts +1 -1
- package/lib/api/eos/api/eosGetPublicKey.js +2 -2
- package/lib/api/eos/api/eosSignTransaction.d.ts +1 -1
- package/lib/api/eos/api/eosSignTransaction.js +2 -2
- package/lib/api/eos/eosSignTx.d.ts +3 -3
- package/lib/api/ethereum/api/ethereumGetAddress.d.ts +3 -3
- package/lib/api/ethereum/api/ethereumGetAddress.js +6 -6
- package/lib/api/ethereum/api/ethereumGetPublicKey.d.ts +1 -1
- package/lib/api/ethereum/api/ethereumGetPublicKey.js +3 -3
- package/lib/api/ethereum/api/ethereumSignMessage.d.ts +1 -1
- package/lib/api/ethereum/api/ethereumSignMessage.js +3 -3
- package/lib/api/ethereum/api/ethereumSignTransaction.d.ts +2 -2
- package/lib/api/ethereum/api/ethereumSignTransaction.js +4 -4
- package/lib/api/ethereum/api/ethereumSignTypedData.d.ts +2 -1
- package/lib/api/ethereum/api/ethereumSignTypedData.js +6 -6
- package/lib/api/ethereum/api/ethereumVerifyMessage.d.ts +1 -1
- package/lib/api/ethereum/api/ethereumVerifyMessage.js +2 -2
- package/lib/api/ethereum/ethereumDefinitions.d.ts +2 -2
- package/lib/api/ethereum/ethereumDefinitions.js +1 -0
- package/lib/api/firmware/getBinaryForFirmwareUpgrade.js +2 -2
- package/lib/api/firmware/parseFirmwareHeaders.d.ts +2 -1
- package/lib/api/firmware/uploadFirmware.d.ts +1 -1
- package/lib/api/firmware/uploadFirmware.js +1 -1
- package/lib/api/firmware/verifyAuthenticityProof.d.ts +1 -1
- package/lib/api/firmware/verifyEntropy.d.ts +19 -0
- package/lib/api/firmware/verifyEntropy.js +112 -0
- package/lib/api/getAccountDescriptor.js +4 -4
- package/lib/api/getAccountInfo.d.ts +21 -1
- package/lib/api/getAccountInfo.js +7 -7
- package/lib/api/getAddress.d.ts +1 -1
- package/lib/api/getAddress.js +3 -3
- package/lib/api/getCoinInfo.d.ts +3 -0
- package/lib/api/getCoinInfo.js +1 -1
- package/lib/api/getDeviceState.js +1 -1
- package/lib/api/getFirmwareHash.d.ts +1 -1
- package/lib/api/getFirmwareHash.js +1 -1
- package/lib/api/getOwnershipId.d.ts +1 -1
- package/lib/api/getOwnershipId.js +2 -2
- package/lib/api/getOwnershipProof.d.ts +1 -1
- package/lib/api/getOwnershipProof.js +2 -2
- package/lib/api/getPublicKey.d.ts +1 -1
- package/lib/api/getPublicKey.js +4 -4
- package/lib/api/loadDevice.d.ts +1 -1
- package/lib/api/loadDevice.js +1 -1
- package/lib/api/nem/api/nemGetAddress.d.ts +1 -1
- package/lib/api/nem/api/nemGetAddress.js +3 -3
- package/lib/api/nem/api/nemSignTransaction.d.ts +1 -1
- package/lib/api/nem/api/nemSignTransaction.js +2 -2
- package/lib/api/pushTransaction.js +2 -2
- package/lib/api/recoveryDevice.d.ts +1 -1
- package/lib/api/requestLogin.d.ts +1 -1
- package/lib/api/requestLogin.js +2 -2
- package/lib/api/resetDevice.d.ts +3 -1
- package/lib/api/resetDevice.js +58 -3
- package/lib/api/ripple/api/rippleGetAddress.d.ts +1 -1
- package/lib/api/ripple/api/rippleGetAddress.js +3 -3
- package/lib/api/ripple/api/rippleSignTransaction.d.ts +1 -1
- package/lib/api/ripple/api/rippleSignTransaction.js +2 -2
- package/lib/api/setBrightness.d.ts +1 -1
- package/lib/api/setBrightness.js +1 -1
- package/lib/api/setBusy.d.ts +1 -1
- package/lib/api/setBusy.js +1 -1
- package/lib/api/setProxy.js +1 -1
- package/lib/api/showDeviceTutorial.d.ts +1 -1
- package/lib/api/showDeviceTutorial.js +1 -1
- package/lib/api/signMessage.d.ts +1 -1
- package/lib/api/signMessage.js +2 -2
- package/lib/api/signTransaction.d.ts +2 -2
- package/lib/api/signTransaction.js +3 -3
- package/lib/api/solana/api/index.d.ts +1 -0
- package/lib/api/solana/api/index.js +3 -1
- package/lib/api/solana/api/solanaComposeTransaction.d.ts +25 -0
- package/lib/api/solana/api/solanaComposeTransaction.js +61 -0
- package/lib/api/solana/api/solanaGetAddress.js +2 -2
- package/lib/api/solana/api/solanaGetPublicKey.js +2 -2
- package/lib/api/solana/api/solanaSignTransaction.d.ts +9 -1
- package/lib/api/solana/api/solanaSignTransaction.js +20 -2
- package/lib/api/solana/solanaUtils.d.ts +48 -0
- package/lib/api/solana/solanaUtils.js +213 -0
- package/lib/api/stellar/api/stellarGetAddress.d.ts +1 -1
- package/lib/api/stellar/api/stellarGetAddress.js +3 -3
- package/lib/api/stellar/api/stellarSignTransaction.js +3 -3
- package/lib/api/tezos/api/tezosGetAddress.d.ts +1 -1
- package/lib/api/tezos/api/tezosGetAddress.js +3 -3
- package/lib/api/tezos/api/tezosGetPublicKey.d.ts +1 -1
- package/lib/api/tezos/api/tezosGetPublicKey.js +2 -2
- package/lib/api/tezos/api/tezosSignTransaction.d.ts +1 -1
- package/lib/api/tezos/api/tezosSignTransaction.js +2 -2
- package/lib/api/tezos/tezosSignTx.d.ts +17 -17
- package/lib/api/unlockPath.d.ts +1 -1
- package/lib/api/verifyMessage.d.ts +1 -1
- package/lib/api/verifyMessage.js +3 -3
- package/lib/backend/BackendManager.d.ts +1 -1
- package/lib/backend/BackendManager.js +1 -1
- package/lib/backend/Blockchain.d.ts +2 -2
- package/lib/backend/Blockchain.js +4 -7
- package/lib/constants/errors.d.ts +2 -0
- package/lib/constants/errors.js +4 -0
- package/lib/core/AbstractMethod.d.ts +2 -2
- package/lib/core/AbstractMethod.js +2 -1
- package/lib/core/index.d.ts +3 -3
- package/lib/core/index.js +44 -48
- package/lib/core/onCallFirmwareUpdate.d.ts +3 -8
- package/lib/core/onCallFirmwareUpdate.js +63 -21
- package/lib/data/DataManager.js +1 -5
- package/lib/data/coinInfo.d.ts +15 -131
- package/lib/data/coinInfo.js +8 -8
- package/lib/data/config.d.ts +23 -0
- package/lib/data/config.js +4 -0
- package/lib/data/connectSettings.js +1 -1
- package/lib/data/defaultFeeLevels.d.ts +2 -2
- package/lib/data/defaultFeeLevels.js +34 -14
- package/lib/data/deviceAuthenticityConfigTypes.d.ts +1 -0
- package/lib/data/deviceAuthenticityConfigTypes.js +2 -2
- package/lib/data/firmwareInfo.js +1 -1
- package/lib/data/models.js +5 -1
- package/lib/data/transportInfo.d.ts +0 -1
- package/lib/data/transportInfo.js +41 -28
- package/lib/data/udevInfo.d.ts +0 -1
- package/lib/data/udevInfo.js +2 -5
- package/lib/data/version.d.ts +1 -1
- package/lib/data/version.js +1 -1
- package/lib/device/Device.d.ts +11 -10
- package/lib/device/Device.js +39 -17
- package/lib/device/DeviceCommands.d.ts +2 -2
- package/lib/device/DeviceCommands.js +42 -27
- package/lib/device/DeviceList.d.ts +27 -22
- package/lib/device/DeviceList.js +222 -133
- package/lib/device/StateStorage.js +11 -13
- package/lib/device/prompts.js +28 -36
- package/lib/device/resolveDescriptorForTaproot.d.ts +2 -2
- package/lib/device/resolveDescriptorForTaproot.js +5 -13
- package/lib/events/blockchain.d.ts +1 -1
- package/lib/events/call.d.ts +1 -1
- package/lib/events/core.d.ts +3 -3
- package/lib/events/device.d.ts +11 -1
- package/lib/events/device.js +1 -0
- package/lib/events/popup.d.ts +2 -2
- package/lib/events/transport.d.ts +15 -9
- package/lib/events/transport.js +10 -1
- package/lib/events/ui-promise.d.ts +1 -1
- package/lib/events/ui-request.d.ts +3 -3
- package/lib/factory.d.ts +3 -2
- package/lib/factory.js +3 -1
- package/lib/impl/core-in-module.d.ts +4 -2
- package/lib/impl/core-in-module.js +9 -1
- package/lib/impl/dynamic.d.ts +4 -2
- package/lib/impl/dynamic.js +5 -4
- package/lib/index-browser.js +1 -0
- package/lib/index.js +11 -3
- package/lib/types/account.d.ts +1 -1
- package/lib/types/api/authenticateDevice.d.ts +1 -0
- package/lib/types/api/authorizeCoinjoin.d.ts +1 -1
- package/lib/types/api/authorizeCoinjoin.js +1 -1
- package/lib/types/api/binanceGetAddress.d.ts +1 -1
- package/lib/types/api/binanceGetPublicKey.d.ts +1 -1
- package/lib/types/api/blockchainEstimateFee.d.ts +1 -1
- package/lib/types/api/blockchainSetCustomBackend.d.ts +1 -1
- package/lib/types/api/blockchainSubscribe.d.ts +1 -1
- package/lib/types/api/cardanoComposeTransaction.d.ts +112 -6
- package/lib/types/api/cardanoComposeTransaction.js +77 -0
- package/lib/types/api/cardanoGetAddress.d.ts +1 -1
- package/lib/types/api/cardanoGetPublicKey.d.ts +1 -1
- package/lib/types/api/changeLanguage.d.ts +1 -1
- package/lib/types/api/cipherKeyValue.d.ts +1 -1
- package/lib/types/api/composeTransaction.d.ts +1 -1
- package/lib/types/api/eosGetPublicKey.d.ts +1 -1
- package/lib/types/api/ethereumGetAddress.d.ts +1 -1
- package/lib/types/api/ethereumGetPublicKey.d.ts +1 -1
- package/lib/types/api/ethereumSignTypedData.d.ts +1 -1
- package/lib/types/api/firmwareUpdate.d.ts +11 -2
- package/lib/types/api/getAccountDescriptor.d.ts +1 -1
- package/lib/types/api/getAccountInfo.d.ts +1 -1
- package/lib/types/api/getAddress.d.ts +2 -1
- package/lib/types/api/getCoinInfo.d.ts +1 -1
- package/lib/types/api/getDeviceState.d.ts +1 -1
- package/lib/types/api/getFeatures.d.ts +1 -1
- package/lib/types/api/getOwnershipId.d.ts +2 -1
- package/lib/types/api/getOwnershipProof.d.ts +2 -1
- package/lib/types/api/getPublicKey.d.ts +1 -1
- package/lib/types/api/index.d.ts +7 -3
- package/lib/types/api/nem/index.d.ts +1 -1
- package/lib/types/api/nemGetAddress.d.ts +1 -1
- package/lib/types/api/on.d.ts +1 -1
- package/lib/types/api/recoveryDevice.d.ts +1 -1
- package/lib/types/api/rippleGetAddress.d.ts +1 -1
- package/lib/types/api/setTransports.d.ts +4 -0
- package/lib/types/api/setTransports.js +3 -0
- package/lib/types/api/solana/index.d.ts +41 -0
- package/lib/types/api/solana/index.js +31 -1
- package/lib/types/api/solanaComposeTransaction.d.ts +4 -0
- package/lib/types/api/solanaComposeTransaction.js +3 -0
- package/lib/types/api/solanaGetAddress.d.ts +1 -1
- package/lib/types/api/solanaGetPublicKey.d.ts +1 -1
- package/lib/types/api/stellarGetAddress.d.ts +1 -1
- package/lib/types/api/tezosGetAddress.d.ts +1 -1
- package/lib/types/api/tezosGetPublicKey.d.ts +1 -1
- package/lib/types/api/unlockPath.d.ts +1 -1
- package/lib/types/coinInfo.d.ts +33 -0
- package/lib/types/coinInfo.js +8 -2
- package/lib/types/params.d.ts +1 -1
- package/lib/utils/abortablePromise.d.ts +5 -0
- package/lib/utils/abortablePromise.js +17 -0
- package/lib/utils/accountUtils.d.ts +1 -1
- package/lib/utils/accountUtils.js +1 -1
- package/lib/utils/assetUtils.js +1 -2
- package/lib/utils/assets-browser.d.ts +1 -1
- package/lib/utils/assets.js +1 -1
- package/lib/utils/assets.native.d.ts +1 -1
- package/lib/utils/deviceFeaturesUtils.d.ts +1 -1
- package/lib/utils/deviceFeaturesUtils.js +6 -12
- package/lib/utils/ethereumUtils.d.ts +3 -2
- package/lib/utils/firmwareUtils.d.ts +1 -1
- package/lib/utils/firmwareUtils.js +11 -4
- package/lib/utils/pathUtils.d.ts +1 -1
- package/lib/utils/urlUtils.js +2 -0
- package/lib/workers/workers-browser.d.ts +2 -2
- package/lib/workers/workers-browser.js +2 -2
- package/lib/workers/workers.native.d.ts +1 -1
- package/lib/workers/workers.native.js +2 -2
- package/package.json +22 -12
- package/lib/utils/promiseUtils.d.ts +0 -5
- package/lib/utils/promiseUtils.js +0 -14
package/lib/device/Device.d.ts
CHANGED
|
@@ -1,20 +1,19 @@
|
|
|
1
|
-
import { TypedEmitter } from '@trezor/utils';
|
|
2
|
-
import { Session } from '@trezor/transport';
|
|
3
1
|
import { TransportProtocol } from '@trezor/protocol';
|
|
4
|
-
import {
|
|
2
|
+
import { Session } from '@trezor/transport';
|
|
3
|
+
import { type Descriptor, type Transport } from '@trezor/transport';
|
|
4
|
+
import { TypedEmitter } from '@trezor/utils';
|
|
5
5
|
import { DeviceCommands } from './DeviceCommands';
|
|
6
6
|
import { PROTO } from '../constants';
|
|
7
|
-
import { DEVICE, DeviceButtonRequestPayload, UiResponsePin, UiResponsePassphrase, UiResponseWord } from '../events';
|
|
8
|
-
import { Device as DeviceTyped, DeviceFirmwareStatus, DeviceState, ReleaseInfo, UnavailableCapabilities, FirmwareType, VersionArray, DeviceUniquePath } from '../types';
|
|
9
7
|
import { IStateStorage } from './StateStorage';
|
|
10
8
|
import type { PromptCallback } from './prompts';
|
|
11
|
-
|
|
9
|
+
import { DEVICE, DeviceButtonRequestPayload, DeviceVersionChanged, UiResponsePassphrase, UiResponsePin, UiResponseWord } from '../events';
|
|
10
|
+
import { DeviceFirmwareStatus, DeviceState, Device as DeviceTyped, DeviceUniquePath, FirmwareType, ReleaseInfo, UnavailableCapabilities, VersionArray } from '../types';
|
|
11
|
+
type RunOptions = {
|
|
12
12
|
skipFinalReload?: boolean;
|
|
13
|
-
waiting?: boolean;
|
|
14
|
-
onlyOneActivity?: boolean;
|
|
15
|
-
cancelPopupRequest?: () => any;
|
|
16
13
|
keepSession?: boolean;
|
|
17
14
|
useCardanoDerivation?: boolean;
|
|
15
|
+
skipFirmwareChecks?: boolean;
|
|
16
|
+
skipLanguageChecks?: boolean;
|
|
18
17
|
};
|
|
19
18
|
export declare const GET_FEATURES_TIMEOUT = 3000;
|
|
20
19
|
export declare const GET_FEATURES_TIMEOUT_REACT_NATIVE = 20000;
|
|
@@ -24,6 +23,7 @@ export interface DeviceEvents {
|
|
|
24
23
|
[DEVICE.PASSPHRASE]: (device: Device, callback: PromptCallback<UiResponsePassphrase['payload']>) => void;
|
|
25
24
|
[DEVICE.PASSPHRASE_ON_DEVICE]: () => void;
|
|
26
25
|
[DEVICE.BUTTON]: (device: Device, payload: DeviceButtonRequestPayload) => void;
|
|
26
|
+
[DEVICE.FIRMWARE_VERSION_CHANGED]: (payload: DeviceVersionChanged['payload']) => void;
|
|
27
27
|
}
|
|
28
28
|
type DeviceLifecycle = typeof DEVICE.CONNECT | typeof DEVICE.CONNECT_UNACQUIRED | typeof DEVICE.DISCONNECT | typeof DEVICE.CHANGED;
|
|
29
29
|
type DeviceLifecycleListener = (lifecycle: DeviceLifecycle) => void;
|
|
@@ -36,7 +36,7 @@ type DeviceParams = {
|
|
|
36
36
|
export declare class Device extends TypedEmitter<DeviceEvents> {
|
|
37
37
|
readonly transport: Transport;
|
|
38
38
|
readonly protocol: TransportProtocol;
|
|
39
|
-
|
|
39
|
+
readonly transportPath: import("@trezor/transport/lib/types").PathPublic;
|
|
40
40
|
private readonly transportSessionOwner;
|
|
41
41
|
private readonly transportDescriptorType;
|
|
42
42
|
private session;
|
|
@@ -125,6 +125,7 @@ export declare class Device extends TypedEmitter<DeviceEvents> {
|
|
|
125
125
|
private readonly uniquePath;
|
|
126
126
|
private readonly emitLifecycle;
|
|
127
127
|
private sessionDfd?;
|
|
128
|
+
handshakeFinished: boolean;
|
|
128
129
|
constructor({ id, transport, descriptor, listener }: DeviceParams);
|
|
129
130
|
private getSessionChangePromise;
|
|
130
131
|
private waitAndCompareSession;
|
package/lib/device/Device.js
CHANGED
|
@@ -2,22 +2,23 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Device = exports.GET_FEATURES_TIMEOUT_REACT_NATIVE = exports.GET_FEATURES_TIMEOUT = void 0;
|
|
4
4
|
const crypto_1 = require("crypto");
|
|
5
|
-
const utils_1 = require("@trezor/utils");
|
|
6
5
|
const protocol_1 = require("@trezor/protocol");
|
|
7
6
|
const transport_1 = require("@trezor/transport");
|
|
7
|
+
const utils_1 = require("@trezor/utils");
|
|
8
8
|
const DeviceCommands_1 = require("./DeviceCommands");
|
|
9
9
|
const constants_1 = require("../constants");
|
|
10
|
-
const
|
|
11
|
-
const
|
|
10
|
+
const checkFirmwareRevision_1 = require("./checkFirmwareRevision");
|
|
11
|
+
const prompts_1 = require("./prompts");
|
|
12
|
+
const firmware_1 = require("../api/firmware");
|
|
12
13
|
const DataManager_1 = require("../data/DataManager");
|
|
14
|
+
const coinInfo_1 = require("../data/coinInfo");
|
|
13
15
|
const firmwareInfo_1 = require("../data/firmwareInfo");
|
|
14
|
-
const deviceFeaturesUtils_1 = require("../utils/deviceFeaturesUtils");
|
|
15
|
-
const debug_1 = require("../utils/debug");
|
|
16
|
-
const types_1 = require("../types");
|
|
17
|
-
const models_1 = require("../data/models");
|
|
18
16
|
const getLanguage_1 = require("../data/getLanguage");
|
|
19
|
-
const
|
|
20
|
-
const
|
|
17
|
+
const models_1 = require("../data/models");
|
|
18
|
+
const events_1 = require("../events");
|
|
19
|
+
const types_1 = require("../types");
|
|
20
|
+
const debug_1 = require("../utils/debug");
|
|
21
|
+
const deviceFeaturesUtils_1 = require("../utils/deviceFeaturesUtils");
|
|
21
22
|
const _log = (0, debug_1.initLog)('Device');
|
|
22
23
|
exports.GET_FEATURES_TIMEOUT = 3000;
|
|
23
24
|
exports.GET_FEATURES_TIMEOUT_REACT_NATIVE = 20000;
|
|
@@ -58,6 +59,7 @@ class Device extends utils_1.TypedEmitter {
|
|
|
58
59
|
firmwareRevision: null,
|
|
59
60
|
firmwareHash: null,
|
|
60
61
|
};
|
|
62
|
+
this.handshakeFinished = false;
|
|
61
63
|
this.emitLifecycle = listener;
|
|
62
64
|
this.protocol = protocol_1.v1;
|
|
63
65
|
this.uniquePath = id;
|
|
@@ -72,7 +74,9 @@ class Device extends utils_1.TypedEmitter {
|
|
|
72
74
|
getSessionChangePromise() {
|
|
73
75
|
if (!this.sessionDfd) {
|
|
74
76
|
this.sessionDfd = (0, utils_1.createDeferred)();
|
|
75
|
-
this.sessionDfd.promise
|
|
77
|
+
this.sessionDfd.promise
|
|
78
|
+
.catch(() => { })
|
|
79
|
+
.finally(() => {
|
|
76
80
|
this.sessionDfd = undefined;
|
|
77
81
|
});
|
|
78
82
|
}
|
|
@@ -198,6 +202,7 @@ class Device extends utils_1.TypedEmitter {
|
|
|
198
202
|
}
|
|
199
203
|
}
|
|
200
204
|
}
|
|
205
|
+
this.handshakeFinished = true;
|
|
201
206
|
return;
|
|
202
207
|
}
|
|
203
208
|
}
|
|
@@ -307,9 +312,16 @@ class Device extends utils_1.TypedEmitter {
|
|
|
307
312
|
const getFeaturesTimeout = DataManager_1.DataManager.getSettings('env') === 'react-native'
|
|
308
313
|
? exports.GET_FEATURES_TIMEOUT_REACT_NATIVE
|
|
309
314
|
: exports.GET_FEATURES_TIMEOUT;
|
|
315
|
+
let getFeaturesTimeoutId;
|
|
310
316
|
await Promise.race([
|
|
311
|
-
this.getFeatures(),
|
|
312
|
-
new Promise((_resolve, reject) =>
|
|
317
|
+
this.getFeatures().finally(() => clearTimeout(getFeaturesTimeoutId)),
|
|
318
|
+
new Promise((_resolve, reject) => {
|
|
319
|
+
getFeaturesTimeoutId = setTimeout(() => {
|
|
320
|
+
(0, prompts_1.cancelPrompt)(this, false).finally(() => {
|
|
321
|
+
reject(new Error('GetFeatures timeout'));
|
|
322
|
+
});
|
|
323
|
+
}, getFeaturesTimeout);
|
|
324
|
+
}),
|
|
313
325
|
]);
|
|
314
326
|
}
|
|
315
327
|
}
|
|
@@ -328,9 +340,12 @@ class Device extends utils_1.TypedEmitter {
|
|
|
328
340
|
return Promise.reject(constants_1.ERRORS.TypedError('Device_InitializeFailed', `Initialize failed: ${error.message}${error.code ? `, code: ${error.code}` : ''}`));
|
|
329
341
|
}
|
|
330
342
|
}
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
343
|
+
if (!options.skipFirmwareChecks) {
|
|
344
|
+
await this.checkFirmwareHashWithRetries();
|
|
345
|
+
await this.checkFirmwareRevisionWithRetries();
|
|
346
|
+
}
|
|
347
|
+
if (!options.skipLanguageChecks &&
|
|
348
|
+
((_b = this.features) === null || _b === void 0 ? void 0 : _b.language) &&
|
|
334
349
|
!this.features.language_version_matches &&
|
|
335
350
|
this.atLeast('2.7.0')) {
|
|
336
351
|
_log.info('language version mismatch. silently updating...');
|
|
@@ -509,7 +524,7 @@ class Device extends utils_1.TypedEmitter {
|
|
|
509
524
|
return { success: true };
|
|
510
525
|
}
|
|
511
526
|
catch (errorPayload) {
|
|
512
|
-
return createFailResult('other-error', errorPayload);
|
|
527
|
+
return createFailResult('other-error', (0, utils_1.serializeError)(errorPayload));
|
|
513
528
|
}
|
|
514
529
|
}
|
|
515
530
|
async checkFirmwareRevisionWithRetries() {
|
|
@@ -594,7 +609,7 @@ class Device extends utils_1.TypedEmitter {
|
|
|
594
609
|
if (!feat.model && feat.major_version === 1) {
|
|
595
610
|
feat.model = '1';
|
|
596
611
|
}
|
|
597
|
-
if (!feat.internal_model) {
|
|
612
|
+
if (!feat.internal_model || !types_1.DeviceModelInternal[feat.internal_model]) {
|
|
598
613
|
feat.internal_model = (0, deviceFeaturesUtils_1.ensureInternalModelFeature)(feat.model);
|
|
599
614
|
}
|
|
600
615
|
const version = this.getVersion();
|
|
@@ -604,6 +619,13 @@ class Device extends utils_1.TypedEmitter {
|
|
|
604
619
|
feat.patch_version,
|
|
605
620
|
];
|
|
606
621
|
if (!version || !utils_1.versionUtils.isEqual(version, newVersion)) {
|
|
622
|
+
if (version) {
|
|
623
|
+
this.emit(events_1.DEVICE.FIRMWARE_VERSION_CHANGED, {
|
|
624
|
+
oldVersion: version,
|
|
625
|
+
newVersion,
|
|
626
|
+
device: this.toMessageObject(),
|
|
627
|
+
});
|
|
628
|
+
}
|
|
607
629
|
this._unavailableCapabilities = (0, deviceFeaturesUtils_1.getUnavailableCapabilities)(feat, (0, coinInfo_1.getAllNetworks)());
|
|
608
630
|
this._firmwareStatus = (0, firmwareInfo_1.getFirmwareStatus)(feat);
|
|
609
631
|
this._firmwareRelease = (0, firmwareInfo_1.getRelease)(feat);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Transport, Session } from '@trezor/transport';
|
|
2
1
|
import { MessagesSchema as Messages } from '@trezor/protobuf';
|
|
2
|
+
import { Session, Transport } from '@trezor/transport';
|
|
3
3
|
import { Device } from './Device';
|
|
4
|
-
import type {
|
|
4
|
+
import type { BitcoinNetworkInfo, CoinInfo } from '../types';
|
|
5
5
|
import type { HDNodeResponse } from '../types/api/getPublicKey';
|
|
6
6
|
type MessageType = Messages.MessageType;
|
|
7
7
|
type MessageKey = keyof MessageType;
|
|
@@ -2,19 +2,18 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DeviceCommands = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const crypto_1 = require("crypto");
|
|
6
5
|
const protobuf_1 = require("@trezor/protobuf");
|
|
7
|
-
const utils_1 = require("@trezor/utils");
|
|
8
6
|
const schema_utils_1 = require("@trezor/schema-utils");
|
|
7
|
+
const utils_1 = require("@trezor/utils");
|
|
9
8
|
const constants_1 = require("../constants");
|
|
9
|
+
const resolveDescriptorForTaproot_1 = require("./resolveDescriptorForTaproot");
|
|
10
|
+
const coinInfo_1 = require("../data/coinInfo");
|
|
10
11
|
const events_1 = require("../events");
|
|
11
|
-
const
|
|
12
|
-
const pathUtils_1 = require("../utils/pathUtils");
|
|
12
|
+
const prompts_1 = require("./prompts");
|
|
13
13
|
const accountUtils_1 = require("../utils/accountUtils");
|
|
14
|
-
const coinInfo_1 = require("../data/coinInfo");
|
|
15
14
|
const debug_1 = require("../utils/debug");
|
|
16
|
-
const
|
|
17
|
-
const
|
|
15
|
+
const hdnodeUtils = tslib_1.__importStar(require("../utils/hdnodeUtils"));
|
|
16
|
+
const pathUtils_1 = require("../utils/pathUtils");
|
|
18
17
|
const logger = (0, debug_1.initLog)('DeviceCommands');
|
|
19
18
|
const assertType = (res, resType) => {
|
|
20
19
|
const splitResTypes = Array.isArray(resType) ? resType : resType.split('|');
|
|
@@ -22,17 +21,31 @@ const assertType = (res, resType) => {
|
|
|
22
21
|
throw constants_1.ERRORS.TypedError('Runtime', `assertType: Response of unexpected type: ${res.type}. Should be ${resType}`);
|
|
23
22
|
}
|
|
24
23
|
};
|
|
25
|
-
const generateEntropy = (len) => {
|
|
26
|
-
try {
|
|
27
|
-
return (0, crypto_1.randomBytes)(len);
|
|
28
|
-
}
|
|
29
|
-
catch {
|
|
30
|
-
throw constants_1.ERRORS.TypedError('Runtime', 'generateEntropy: Environment does not support crypto random');
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
24
|
const filterForLog = (type, msg) => {
|
|
34
|
-
const blacklist = {
|
|
25
|
+
const blacklist = {
|
|
26
|
+
PassphraseAck: {
|
|
27
|
+
passphrase: '(redacted...)',
|
|
28
|
+
},
|
|
29
|
+
CipheredKeyValue: {
|
|
30
|
+
value: '(redacted...)',
|
|
31
|
+
},
|
|
32
|
+
GetPublicKey: {
|
|
33
|
+
address_n: '(redacted...)',
|
|
34
|
+
},
|
|
35
|
+
PublicKey: {
|
|
36
|
+
node: '(redacted...)',
|
|
37
|
+
xpub: '(redacted...)',
|
|
38
|
+
},
|
|
39
|
+
DecryptedMessage: {
|
|
40
|
+
message: '(redacted...)',
|
|
41
|
+
address: '(redacted...)',
|
|
42
|
+
},
|
|
43
|
+
Features: '(redacted...)',
|
|
44
|
+
};
|
|
35
45
|
if (type in blacklist) {
|
|
46
|
+
if (typeof blacklist[type] === 'string') {
|
|
47
|
+
return blacklist[type];
|
|
48
|
+
}
|
|
36
49
|
return { ...msg, ...blacklist[type] };
|
|
37
50
|
}
|
|
38
51
|
return msg;
|
|
@@ -227,9 +240,18 @@ class DeviceCommands {
|
|
|
227
240
|
assertType(response, resType);
|
|
228
241
|
}
|
|
229
242
|
catch (error) {
|
|
230
|
-
|
|
243
|
+
const abortController = new AbortController();
|
|
244
|
+
const timeout = setTimeout(() => {
|
|
245
|
+
abortController.abort();
|
|
246
|
+
}, 500);
|
|
247
|
+
await this.transport
|
|
248
|
+
.receive({
|
|
231
249
|
session: this.transportSession,
|
|
232
250
|
protocol: this.device.protocol,
|
|
251
|
+
signal: abortController.signal,
|
|
252
|
+
})
|
|
253
|
+
.finally(() => {
|
|
254
|
+
clearTimeout(timeout);
|
|
233
255
|
});
|
|
234
256
|
throw error;
|
|
235
257
|
}
|
|
@@ -268,11 +290,6 @@ class DeviceCommands {
|
|
|
268
290
|
}
|
|
269
291
|
return this._commonCall('ButtonAck', {});
|
|
270
292
|
}
|
|
271
|
-
if (res.type === 'EntropyRequest') {
|
|
272
|
-
return this._commonCall('EntropyAck', {
|
|
273
|
-
entropy: generateEntropy(32).toString('hex'),
|
|
274
|
-
});
|
|
275
|
-
}
|
|
276
293
|
if (res.type === 'PinMatrixRequest') {
|
|
277
294
|
return (0, prompts_1.promptPin)(this.device, res.message.type).then(pin => this._commonCall('PinMatrixAck', { pin }).then(response => {
|
|
278
295
|
if (!this.device.features.unlocked) {
|
|
@@ -282,11 +299,9 @@ class DeviceCommands {
|
|
|
282
299
|
}), error => Promise.reject(error));
|
|
283
300
|
}
|
|
284
301
|
if (res.type === 'PassphraseRequest') {
|
|
285
|
-
return (0, prompts_1.promptPassphrase)(this.device).then(({ value, passphraseOnDevice }) =>
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
: this._commonCall('PassphraseAck', { on_device: true });
|
|
289
|
-
}, error => Promise.reject(error));
|
|
302
|
+
return (0, prompts_1.promptPassphrase)(this.device).then(({ value, passphraseOnDevice }) => !passphraseOnDevice
|
|
303
|
+
? this._commonCall('PassphraseAck', { passphrase: value.normalize('NFKD') })
|
|
304
|
+
: this._commonCall('PassphraseAck', { on_device: true }), error => Promise.reject(error));
|
|
290
305
|
}
|
|
291
306
|
if (res.type === 'WordRequest') {
|
|
292
307
|
return (0, prompts_1.promptWord)(this.device, res.message.type).then(word => this._commonCall('WordAck', { word }), error => Promise.reject(error));
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
+
import { TRANSPORT } from '@trezor/transport';
|
|
2
|
+
import type { TransportApiType } from '@trezor/transport/lib/transports/abstract';
|
|
1
3
|
import { TypedEmitter } from '@trezor/utils';
|
|
2
|
-
import {
|
|
3
|
-
import { DEVICE, TransportInfo } from '../events';
|
|
4
|
+
import { DEVICE, TransportError, TransportInfo } from '../events';
|
|
4
5
|
import { Device } from './Device';
|
|
5
|
-
import { ConnectSettings, DeviceUniquePath,
|
|
6
|
+
import { ConnectSettings, DeviceUniquePath, StaticSessionId } from '../types';
|
|
6
7
|
interface DeviceListEvents {
|
|
7
8
|
[TRANSPORT.START]: TransportInfo;
|
|
8
|
-
[TRANSPORT.ERROR]:
|
|
9
|
-
[DEVICE.CONNECT]:
|
|
10
|
-
[DEVICE.CONNECT_UNACQUIRED]:
|
|
11
|
-
[DEVICE.DISCONNECT]:
|
|
12
|
-
[DEVICE.CHANGED]:
|
|
9
|
+
[TRANSPORT.ERROR]: TransportError;
|
|
10
|
+
[DEVICE.CONNECT]: Device;
|
|
11
|
+
[DEVICE.CONNECT_UNACQUIRED]: Device;
|
|
12
|
+
[DEVICE.DISCONNECT]: Device;
|
|
13
|
+
[DEVICE.CHANGED]: Device;
|
|
13
14
|
}
|
|
14
15
|
export interface IDeviceList {
|
|
15
16
|
isConnected(): this is DeviceList;
|
|
16
17
|
pendingConnection(): Promise<void> | undefined;
|
|
17
|
-
setTransports: DeviceList['setTransports'];
|
|
18
18
|
addAuthPenalty: DeviceList['addAuthPenalty'];
|
|
19
19
|
removeAuthPenalty: DeviceList['removeAuthPenalty'];
|
|
20
20
|
on: DeviceList['on'];
|
|
@@ -26,42 +26,47 @@ export declare const assertDeviceListConnected: (deviceList: IDeviceList) => ass
|
|
|
26
26
|
type ConstructorParams = Pick<ConnectSettings, 'priority' | 'debug' | '_sessionsBackgroundUrl' | 'manifest'> & {
|
|
27
27
|
messages: Record<string, any>;
|
|
28
28
|
};
|
|
29
|
-
type InitParams = Pick<ConnectSettings, 'pendingTransportEvent' | 'transportReconnect'>;
|
|
29
|
+
type InitParams = Pick<ConnectSettings, 'transports' | 'pendingTransportEvent' | 'transportReconnect'>;
|
|
30
30
|
export declare class DeviceList extends TypedEmitter<DeviceListEvents> implements IDeviceList {
|
|
31
|
-
private transport;
|
|
31
|
+
private readonly transport;
|
|
32
32
|
private transports;
|
|
33
|
-
private devices;
|
|
33
|
+
private readonly devices;
|
|
34
34
|
private deviceCounter;
|
|
35
35
|
private readonly handshakeLock;
|
|
36
36
|
private readonly authPenaltyManager;
|
|
37
|
-
private initPromise?;
|
|
38
|
-
private rejectPending?;
|
|
39
37
|
private transportCommonArgs;
|
|
40
38
|
isConnected(): this is DeviceList;
|
|
41
39
|
pendingConnection(): Promise<void> | undefined;
|
|
40
|
+
getActiveTransports(): {
|
|
41
|
+
apiType: TransportApiType;
|
|
42
|
+
type: "BridgeTransport" | "NodeUsbTransport" | "WebUsbTransport" | "UdpTransport" | "NativeUsbTransport" | "BluetoothTransport";
|
|
43
|
+
version: string;
|
|
44
|
+
outdated: boolean;
|
|
45
|
+
}[];
|
|
46
|
+
private readonly locks;
|
|
47
|
+
private transportLock;
|
|
42
48
|
constructor({ messages, priority, debug, _sessionsBackgroundUrl, manifest, }: ConstructorParams);
|
|
43
|
-
private
|
|
44
|
-
|
|
49
|
+
private tryGetTransport;
|
|
50
|
+
private getOrCreateTransport;
|
|
51
|
+
private createTransports;
|
|
45
52
|
private onDeviceConnected;
|
|
46
53
|
private onDeviceDisconnected;
|
|
47
54
|
private onDeviceSessionChanged;
|
|
48
55
|
private onDeviceRequestRelease;
|
|
49
56
|
init(initParams?: InitParams): Promise<void>;
|
|
50
57
|
private createInitPromise;
|
|
51
|
-
private
|
|
58
|
+
private createReconnectDelay;
|
|
52
59
|
private selectTransport;
|
|
53
60
|
private initializeTransport;
|
|
54
61
|
private waitForDevices;
|
|
55
62
|
getDeviceCount(): number;
|
|
56
|
-
getAllDevices(): Device[];
|
|
63
|
+
getAllDevices(): readonly Device[];
|
|
57
64
|
getOnlyDevice(): Device | undefined;
|
|
58
65
|
getDeviceByPath(path: DeviceUniquePath): Device | undefined;
|
|
59
66
|
getDeviceByStaticState(state: StaticSessionId): Device | undefined;
|
|
60
|
-
transportType(): "BridgeTransport" | "NodeUsbTransport" | "WebUsbTransport" | "UdpTransport" | "NativeUsbTransport" | "BluetoothTransport";
|
|
61
|
-
getTransportInfo(): TransportInfo;
|
|
62
67
|
dispose(): Promise<void>;
|
|
63
|
-
|
|
64
|
-
enumerate(
|
|
68
|
+
private stopTransport;
|
|
69
|
+
enumerate(): Promise<void>;
|
|
65
70
|
addAuthPenalty(device: Device): void;
|
|
66
71
|
removeAuthPenalty(device: Device): void;
|
|
67
72
|
}
|