@trezor/connect 9.4.3-beta.1 → 9.4.3-beta.2
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 +43 -4
- package/README.md +1 -1
- package/lib/api/applyFlags.js +1 -1
- package/lib/api/applySettings.js +1 -1
- package/lib/api/authenticateDevice.js +1 -1
- package/lib/api/authorizeCoinjoin.js +1 -1
- package/lib/api/backupDevice.js +1 -1
- package/lib/api/binance/api/binanceGetAddress.js +2 -1
- package/lib/api/binance/api/binanceGetPublicKey.js +2 -1
- package/lib/api/binance/api/binanceSignTransaction.js +2 -1
- package/lib/api/binance/binanceSignTx.js +1 -1
- package/lib/api/bitcoin/Fees.js +2 -2
- package/lib/api/bitcoin/TransactionComposer.d.ts +3 -3
- package/lib/api/bitcoin/TransactionComposer.js +2 -2
- package/lib/api/bitcoin/refTx.js +1 -1
- package/lib/api/blockchainDisconnect.js +1 -1
- package/lib/api/blockchainEvmRpcCall.d.ts +16 -0
- package/lib/api/blockchainEvmRpcCall.js +45 -0
- package/lib/api/cancelCoinjoinAuthorization.js +1 -1
- package/lib/api/cardano/api/cardanoGetAddress.js +2 -1
- package/lib/api/cardano/api/cardanoGetNativeScriptHash.js +2 -1
- package/lib/api/cardano/api/cardanoGetPublicKey.js +2 -1
- package/lib/api/cardano/api/cardanoSignTransaction.js +2 -1
- 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.d.ts +8 -8
- package/lib/api/cardano/cardanoInputs.js +1 -1
- package/lib/api/cardano/cardanoOutputs.d.ts +22 -22
- package/lib/api/cardano/cardanoOutputs.js +1 -1
- package/lib/api/cardano/cardanoTokenBundle.d.ts +6 -6
- package/lib/api/cardano/cardanoTokenBundle.js +1 -1
- package/lib/api/changeLanguage.js +1 -1
- package/lib/api/changePin.js +1 -1
- package/lib/api/cipherKeyValue.js +1 -1
- package/lib/api/common/paramsValidator.js +1 -1
- package/lib/api/composeTransaction.d.ts +9 -3
- package/lib/api/composeTransaction.js +7 -4
- package/lib/api/eos/api/eosGetPublicKey.js +2 -1
- package/lib/api/eos/api/eosSignTransaction.js +2 -1
- package/lib/api/eos/eosSignTx.d.ts +3 -3
- package/lib/api/ethereum/api/ethereumGetAddress.js +2 -1
- package/lib/api/ethereum/api/ethereumGetPublicKey.js +2 -1
- package/lib/api/ethereum/api/ethereumSignMessage.d.ts +1 -1
- package/lib/api/ethereum/api/ethereumSignMessage.js +2 -1
- package/lib/api/ethereum/api/ethereumSignTransaction.d.ts +1 -1
- package/lib/api/ethereum/api/ethereumSignTransaction.js +13 -7
- package/lib/api/ethereum/api/ethereumSignTypedData.d.ts +58 -57
- package/lib/api/ethereum/api/ethereumSignTypedData.js +3 -2
- package/lib/api/ethereum/api/ethereumVerifyMessage.js +2 -1
- package/lib/api/ethereum/ethereumDefinitions.d.ts +21 -21
- package/lib/api/ethereum/ethereumDefinitions.js +6 -5
- package/lib/api/firmware/getBinary.js +1 -1
- package/lib/api/firmware/x509certificate.js +3 -5
- package/lib/api/getAccountDescriptor.js +1 -1
- package/lib/api/getAddress.js +1 -1
- package/lib/api/getCoinInfo.d.ts +3 -0
- package/lib/api/getCoinInfo.js +1 -1
- package/lib/api/getFirmwareHash.js +1 -1
- package/lib/api/getOwnershipId.js +1 -1
- package/lib/api/getOwnershipProof.js +1 -1
- package/lib/api/getPublicKey.js +1 -1
- package/lib/api/index.d.ts +2 -1
- package/lib/api/index.js +5 -3
- package/lib/api/loadDevice.d.ts +14 -0
- package/lib/api/loadDevice.js +44 -0
- package/lib/api/nem/api/nemGetAddress.js +2 -1
- package/lib/api/nem/api/nemSignTransaction.js +2 -1
- package/lib/api/pushTransaction.js +1 -1
- package/lib/api/rebootToBootloader.js +1 -1
- package/lib/api/recoveryDevice.js +1 -1
- package/lib/api/requestLogin.js +1 -1
- package/lib/api/resetDevice.js +1 -1
- package/lib/api/ripple/api/rippleGetAddress.js +2 -1
- package/lib/api/ripple/api/rippleSignTransaction.js +2 -1
- package/lib/api/setBrightness.js +1 -1
- package/lib/api/setBusy.js +1 -1
- package/lib/api/signMessage.js +1 -1
- package/lib/api/solana/api/solanaGetAddress.js +2 -1
- package/lib/api/solana/api/solanaGetPublicKey.js +2 -1
- package/lib/api/solana/api/solanaSignTransaction.js +2 -1
- package/lib/api/stellar/api/stellarGetAddress.js +2 -1
- package/lib/api/stellar/api/stellarSignTransaction.js +2 -1
- package/lib/api/stellar/stellarSignTx.js +1 -1
- package/lib/api/tezos/api/tezosGetAddress.js +2 -1
- package/lib/api/tezos/api/tezosGetPublicKey.js +2 -1
- package/lib/api/tezos/api/tezosSignTransaction.js +2 -1
- package/lib/api/tezos/tezosSignTx.js +1 -1
- package/lib/api/unlockPath.js +1 -1
- package/lib/api/verifyMessage.js +1 -1
- package/lib/backend/Blockchain.d.ts +3 -0
- package/lib/backend/Blockchain.js +3 -0
- package/lib/constants/errors.d.ts +3 -0
- package/lib/constants/errors.js +3 -0
- package/lib/constants/index.d.ts +1 -0
- package/lib/constants/index.js +3 -1
- package/lib/constants/nem.d.ts +3 -3
- package/lib/constants/utxo.d.ts +3 -0
- package/lib/constants/utxo.js +5 -0
- package/lib/core/AbstractMethod.d.ts +13 -5
- package/lib/core/AbstractMethod.js +50 -24
- package/lib/core/index.js +41 -30
- package/lib/core/onCallFirmwareUpdate.d.ts +2 -2
- package/lib/core/onCallFirmwareUpdate.js +5 -5
- package/lib/data/DataManager.d.ts +0 -181
- package/lib/data/DataManager.js +40 -6
- package/lib/data/analyticsInfo.js +2 -1
- package/lib/data/coinInfo.d.ts +14 -0
- package/lib/data/config.d.ts +20 -22
- package/lib/data/config.js +15 -40
- package/lib/data/connectSettings.js +5 -4
- package/lib/data/deviceAuthenticityConfig.js +17 -0
- package/lib/data/deviceAuthenticityConfigTypes.d.ts +32 -23
- package/lib/data/firmwareInfo.d.ts +1 -1
- package/lib/data/models.d.ts +9 -0
- package/lib/data/models.js +9 -0
- package/lib/data/version.d.ts +1 -1
- package/lib/data/version.js +1 -1
- package/lib/device/Device.d.ts +143 -36
- package/lib/device/Device.js +226 -119
- package/lib/device/DeviceCommands.js +4 -4
- package/lib/device/DeviceList.d.ts +13 -21
- package/lib/device/DeviceList.js +54 -168
- package/lib/device/prompts.js +3 -2
- package/lib/device/resolveDescriptorForTaproot.d.ts +1 -1
- package/lib/events/call.d.ts +5 -5
- package/lib/events/call.js +2 -2
- package/lib/events/device.d.ts +0 -6
- package/lib/events/device.js +0 -6
- package/lib/events/transport.d.ts +1 -1
- package/lib/factory.d.ts +6 -6
- package/lib/factory.js +132 -136
- package/lib/impl/dynamic.d.ts +13 -19
- package/lib/impl/dynamic.js +0 -9
- package/lib/index-browser.d.ts +3 -1
- package/lib/index-browser.js +0 -3
- package/lib/index.d.ts +3 -1
- package/lib/index.js +1 -13
- package/lib/types/api/applySettings.d.ts +13 -13
- package/lib/types/api/authenticateDevice.d.ts +33 -24
- package/lib/types/api/authorizeCoinjoin.d.ts +10 -10
- package/lib/types/api/binance/index.d.ts +143 -143
- package/lib/types/api/binance/index.js +1 -1
- package/lib/types/api/bitcoin/index.d.ts +11 -11
- package/lib/types/api/bitcoin/index.js +1 -1
- package/lib/types/api/blockchainEvmRpcCall.d.ts +4 -0
- package/lib/types/api/{checkFirmwareAuthenticity.js → blockchainEvmRpcCall.js} +1 -1
- package/lib/types/api/cancelCoinjoinAuthorization.d.ts +1 -1
- package/lib/types/api/cardano/index.d.ts +507 -507
- package/lib/types/api/changeLanguage.d.ts +6 -6
- package/lib/types/api/cipherKeyValue.d.ts +8 -8
- package/lib/types/api/cipherKeyValue.js +1 -1
- package/lib/types/api/composeTransaction.d.ts +13 -7
- package/lib/types/api/eos/index.d.ts +525 -525
- package/lib/types/api/eos/index.js +1 -1
- package/lib/types/api/ethereum/index.d.ts +100 -100
- package/lib/types/api/firmwareUpdate.d.ts +5 -5
- package/lib/types/api/getAccountDescriptor.d.ts +4 -4
- package/lib/types/api/getAddress.d.ts +32 -32
- package/lib/types/api/getOwnershipId.d.ts +24 -24
- package/lib/types/api/getOwnershipProof.d.ts +28 -28
- package/lib/types/api/getPublicKey.d.ts +24 -24
- package/lib/types/api/getPublicKey.js +1 -1
- package/lib/types/api/index.d.ts +4 -8
- package/lib/types/api/init.d.ts +4 -2
- package/lib/types/api/loadDevice.d.ts +4 -0
- package/lib/types/api/loadDevice.js +3 -0
- package/lib/types/api/nem/index.d.ts +612 -612
- package/lib/types/api/nem/index.js +1 -1
- package/lib/types/api/nemGetAddress.d.ts +6 -6
- package/lib/types/api/pushTransaction.d.ts +3 -3
- package/lib/types/api/recoveryDevice.d.ts +9 -9
- package/lib/types/api/requestLogin.d.ts +25 -25
- package/lib/types/api/ripple/index.d.ts +21 -21
- package/lib/types/api/ripple/index.js +1 -1
- package/lib/types/api/solana/index.d.ts +23 -23
- package/lib/types/api/solana/index.js +1 -1
- package/lib/types/api/stellar/index.d.ts +582 -582
- package/lib/types/api/stellar/index.js +1 -1
- package/lib/types/api/tezos/index.d.ts +120 -120
- package/lib/types/api/tezos/index.js +1 -1
- package/lib/types/api/unlockPath.d.ts +2 -2
- package/lib/types/coinInfo.d.ts +231 -224
- package/lib/types/device.d.ts +13 -1
- package/lib/types/device.js +3 -1
- package/lib/types/fees.d.ts +19 -19
- package/lib/types/firmware.d.ts +1 -1
- package/lib/types/params.d.ts +21 -18
- package/lib/types/settings.d.ts +15 -9
- package/lib/types/utils.d.ts +1 -0
- package/lib/types/utils.js +3 -0
- package/lib/utils/addressUtils.js +2 -2
- package/lib/utils/assetUtils.js +3 -3
- package/lib/utils/deviceFeaturesUtils.js +1 -1
- package/lib/utils/uiPromiseManager.d.ts +2 -1
- package/lib/utils/uiPromiseManager.js +3 -3
- package/package.json +12 -12
- package/lib/api/checkFirmwareAuthenticity.d.ts +0 -11
- package/lib/api/checkFirmwareAuthenticity.js +0 -63
- package/lib/types/api/checkFirmwareAuthenticity.d.ts +0 -11
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const schema_utils_1 = require("@trezor/schema-utils");
|
|
3
4
|
const AbstractMethod_1 = require("../../../core/AbstractMethod");
|
|
4
5
|
const paramsValidator_1 = require("../../common/paramsValidator");
|
|
5
6
|
const coinInfo_1 = require("../../../data/coinInfo");
|
|
6
7
|
const pathUtils_1 = require("../../../utils/pathUtils");
|
|
7
8
|
const constants_1 = require("../../../constants");
|
|
8
9
|
const events_1 = require("../../../events");
|
|
9
|
-
const schema_utils_1 = require("@trezor/schema-utils");
|
|
10
10
|
const types_1 = require("../../../types");
|
|
11
11
|
const getAddress_1 = require("../../../types/api/getAddress");
|
|
12
12
|
class StellarGetAddress extends AbstractMethod_1.AbstractMethod {
|
|
@@ -17,6 +17,7 @@ class StellarGetAddress extends AbstractMethod_1.AbstractMethod {
|
|
|
17
17
|
init() {
|
|
18
18
|
this.noBackupConfirmationMode = 'always';
|
|
19
19
|
this.requiredPermissions = ['read'];
|
|
20
|
+
this.requiredDeviceCapabilities = ['Capability_Stellar'];
|
|
20
21
|
this.firmwareRange = (0, paramsValidator_1.getFirmwareRange)(this.name, (0, coinInfo_1.getMiscNetwork)('Stellar'), this.firmwareRange);
|
|
21
22
|
this.hasBundle = !!this.payload.bundle;
|
|
22
23
|
const payload = !this.payload.bundle
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
+
const schema_utils_1 = require("@trezor/schema-utils");
|
|
4
5
|
const AbstractMethod_1 = require("../../../core/AbstractMethod");
|
|
5
6
|
const paramsValidator_1 = require("../../common/paramsValidator");
|
|
6
7
|
const coinInfo_1 = require("../../../data/coinInfo");
|
|
@@ -8,7 +9,6 @@ const pathUtils_1 = require("../../../utils/pathUtils");
|
|
|
8
9
|
const helper = tslib_1.__importStar(require("../stellarSignTx"));
|
|
9
10
|
const constants_1 = require("../../../constants");
|
|
10
11
|
const stellar_1 = require("../../../types/api/stellar");
|
|
11
|
-
const schema_utils_1 = require("@trezor/schema-utils");
|
|
12
12
|
const StellarSignTransactionFeatures = Object.freeze({
|
|
13
13
|
manageBuyOffer: ['1.10.4', '2.4.3'],
|
|
14
14
|
pathPaymentStrictSend: ['1.10.4', '2.4.3'],
|
|
@@ -16,6 +16,7 @@ const StellarSignTransactionFeatures = Object.freeze({
|
|
|
16
16
|
class StellarSignTransaction extends AbstractMethod_1.AbstractMethod {
|
|
17
17
|
init() {
|
|
18
18
|
this.requiredPermissions = ['read', 'write'];
|
|
19
|
+
this.requiredDeviceCapabilities = ['Capability_Stellar'];
|
|
19
20
|
this.firmwareRange = (0, paramsValidator_1.getFirmwareRange)(this.name, (0, coinInfo_1.getMiscNetwork)('Stellar'), this.firmwareRange);
|
|
20
21
|
const { payload } = this;
|
|
21
22
|
(0, schema_utils_1.AssertWeak)(stellar_1.StellarSignTransaction, payload);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.stellarSignTx = void 0;
|
|
4
|
+
const schema_utils_1 = require("@trezor/schema-utils");
|
|
4
5
|
const constants_1 = require("../../constants");
|
|
5
6
|
const stellar_1 = require("../../types/api/stellar");
|
|
6
|
-
const schema_utils_1 = require("@trezor/schema-utils");
|
|
7
7
|
const processTxRequest = async (typedCall, operations, index) => {
|
|
8
8
|
const lastOp = index + 1 >= operations.length;
|
|
9
9
|
const { type, ...op } = operations[index];
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const schema_utils_1 = require("@trezor/schema-utils");
|
|
3
4
|
const AbstractMethod_1 = require("../../../core/AbstractMethod");
|
|
4
5
|
const paramsValidator_1 = require("../../common/paramsValidator");
|
|
5
6
|
const coinInfo_1 = require("../../../data/coinInfo");
|
|
6
7
|
const pathUtils_1 = require("../../../utils/pathUtils");
|
|
7
8
|
const constants_1 = require("../../../constants");
|
|
8
9
|
const events_1 = require("../../../events");
|
|
9
|
-
const schema_utils_1 = require("@trezor/schema-utils");
|
|
10
10
|
const types_1 = require("../../../types");
|
|
11
11
|
const getAddress_1 = require("../../../types/api/getAddress");
|
|
12
12
|
class TezosGetAddress extends AbstractMethod_1.AbstractMethod {
|
|
@@ -17,6 +17,7 @@ class TezosGetAddress extends AbstractMethod_1.AbstractMethod {
|
|
|
17
17
|
init() {
|
|
18
18
|
this.noBackupConfirmationMode = 'always';
|
|
19
19
|
this.requiredPermissions = ['read'];
|
|
20
|
+
this.requiredDeviceCapabilities = ['Capability_Tezos'];
|
|
20
21
|
this.firmwareRange = (0, paramsValidator_1.getFirmwareRange)(this.name, (0, coinInfo_1.getMiscNetwork)('Tezos'), this.firmwareRange);
|
|
21
22
|
this.hasBundle = !!this.payload.bundle;
|
|
22
23
|
const payload = !this.payload.bundle
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const schema_utils_1 = require("@trezor/schema-utils");
|
|
3
4
|
const AbstractMethod_1 = require("../../../core/AbstractMethod");
|
|
4
5
|
const paramsValidator_1 = require("../../common/paramsValidator");
|
|
5
6
|
const coinInfo_1 = require("../../../data/coinInfo");
|
|
6
7
|
const pathUtils_1 = require("../../../utils/pathUtils");
|
|
7
8
|
const events_1 = require("../../../events");
|
|
8
|
-
const schema_utils_1 = require("@trezor/schema-utils");
|
|
9
9
|
const types_1 = require("../../../types");
|
|
10
10
|
class TezosGetPublicKey extends AbstractMethod_1.AbstractMethod {
|
|
11
11
|
init() {
|
|
12
12
|
this.requiredPermissions = ['read'];
|
|
13
|
+
this.requiredDeviceCapabilities = ['Capability_Tezos'];
|
|
13
14
|
this.firmwareRange = (0, paramsValidator_1.getFirmwareRange)(this.name, (0, coinInfo_1.getMiscNetwork)('Tezos'), this.firmwareRange);
|
|
14
15
|
this.hasBundle = !!this.payload.bundle;
|
|
15
16
|
const payload = !this.payload.bundle
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
+
const schema_utils_1 = require("@trezor/schema-utils");
|
|
4
5
|
const AbstractMethod_1 = require("../../../core/AbstractMethod");
|
|
5
6
|
const paramsValidator_1 = require("../../common/paramsValidator");
|
|
6
7
|
const coinInfo_1 = require("../../../data/coinInfo");
|
|
7
8
|
const pathUtils_1 = require("../../../utils/pathUtils");
|
|
8
9
|
const helper = tslib_1.__importStar(require("../tezosSignTx"));
|
|
9
|
-
const schema_utils_1 = require("@trezor/schema-utils");
|
|
10
10
|
const tezos_1 = require("../../../types/api/tezos");
|
|
11
11
|
class TezosSignTransaction extends AbstractMethod_1.AbstractMethod {
|
|
12
12
|
init() {
|
|
13
13
|
this.requiredPermissions = ['read', 'write'];
|
|
14
|
+
this.requiredDeviceCapabilities = ['Capability_Tezos'];
|
|
14
15
|
this.firmwareRange = (0, paramsValidator_1.getFirmwareRange)(this.name, (0, coinInfo_1.getMiscNetwork)('Tezos'), this.firmwareRange);
|
|
15
16
|
const { payload } = this;
|
|
16
17
|
(0, schema_utils_1.AssertWeak)(tezos_1.TezosSignTransaction, payload);
|
|
@@ -3,9 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.createTx = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const bs58check_1 = tslib_1.__importDefault(require("bs58check"));
|
|
6
|
+
const schema_utils_1 = require("@trezor/schema-utils");
|
|
6
7
|
const constants_1 = require("../../constants");
|
|
7
8
|
const tezos_1 = require("../../types/api/tezos");
|
|
8
|
-
const schema_utils_1 = require("@trezor/schema-utils");
|
|
9
9
|
const PREFIX = {
|
|
10
10
|
B: new Uint8Array([1, 52]),
|
|
11
11
|
tz1: new Uint8Array([6, 161, 159]),
|
package/lib/api/unlockPath.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const schema_utils_1 = require("@trezor/schema-utils");
|
|
3
4
|
const AbstractMethod_1 = require("../core/AbstractMethod");
|
|
4
5
|
const pathUtils_1 = require("../utils/pathUtils");
|
|
5
6
|
const paramsValidator_1 = require("./common/paramsValidator");
|
|
6
|
-
const schema_utils_1 = require("@trezor/schema-utils");
|
|
7
7
|
const unlockPath_1 = require("../types/api/unlockPath");
|
|
8
8
|
class UnlockPath extends AbstractMethod_1.AbstractMethod {
|
|
9
9
|
init() {
|
package/lib/api/verifyMessage.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const schema_utils_1 = require("@trezor/schema-utils");
|
|
3
4
|
const AbstractMethod_1 = require("../core/AbstractMethod");
|
|
4
5
|
const paramsValidator_1 = require("./common/paramsValidator");
|
|
5
6
|
const coinInfo_1 = require("../data/coinInfo");
|
|
@@ -7,7 +8,6 @@ const pathUtils_1 = require("../utils/pathUtils");
|
|
|
7
8
|
const formatUtils_1 = require("../utils/formatUtils");
|
|
8
9
|
const constants_1 = require("../constants");
|
|
9
10
|
const types_1 = require("../types");
|
|
10
|
-
const schema_utils_1 = require("@trezor/schema-utils");
|
|
11
11
|
class VerifyMessage extends AbstractMethod_1.AbstractMethod {
|
|
12
12
|
init() {
|
|
13
13
|
this.requiredPermissions = ['read', 'write'];
|
|
@@ -47,6 +47,9 @@ export declare class Blockchain {
|
|
|
47
47
|
getNetworkInfo(): Promise<ServerInfo>;
|
|
48
48
|
getAccountInfo(request: BlockchainLinkParams<'getAccountInfo'>): Promise<import("@trezor/blockchain-link").AccountInfo>;
|
|
49
49
|
getAccountUtxo(descriptor: string): Promise<import("@trezor/blockchain-link").Utxo[]>;
|
|
50
|
+
rpcCall(params: BlockchainLinkParams<'rpcCall'>): Promise<{
|
|
51
|
+
data: string;
|
|
52
|
+
}>;
|
|
50
53
|
estimateFee(request: Parameters<typeof this.link.estimateFee>[0]): Promise<{
|
|
51
54
|
feePerUnit: string;
|
|
52
55
|
feePerTx?: string;
|
|
@@ -141,6 +141,9 @@ class Blockchain {
|
|
|
141
141
|
getAccountUtxo(descriptor) {
|
|
142
142
|
return this.link.getAccountUtxo(descriptor);
|
|
143
143
|
}
|
|
144
|
+
rpcCall(params) {
|
|
145
|
+
return this.link.rpcCall(params);
|
|
146
|
+
}
|
|
144
147
|
async estimateFee(request) {
|
|
145
148
|
const { blocks } = request;
|
|
146
149
|
const useCache = !request.specific && Array.isArray(blocks) && blocks.length > 0;
|
|
@@ -34,10 +34,13 @@ export declare const ERROR_CODES: {
|
|
|
34
34
|
readonly Device_InvalidState: "Passphrase is incorrect";
|
|
35
35
|
readonly Device_CallInProgress: "Device call in progress";
|
|
36
36
|
readonly Device_MultipleNotSupported: "Multiple devices are not supported";
|
|
37
|
+
readonly Device_MissingCapability: "Device is missing capability";
|
|
38
|
+
readonly Device_MissingCapabilityBtcOnly: "Device is missing capability (BTC only)";
|
|
37
39
|
readonly Failure_ActionCancelled: "Action cancelled by user";
|
|
38
40
|
readonly Failure_FirmwareError: "Firmware installation failed";
|
|
39
41
|
readonly Failure_UnknownCode: "Unknown error";
|
|
40
42
|
readonly Failure_PinCancelled: "PIN cancelled";
|
|
43
|
+
readonly Failure_PinInvalid: "PIN invalid";
|
|
41
44
|
readonly Failure_PinMismatch: "PIN mismatch";
|
|
42
45
|
readonly Failure_WipeCodeMismatch: "Wipe code mismatch";
|
|
43
46
|
readonly Deeplink_VersionMismatch: "Not compatible with current version of the app";
|
package/lib/constants/errors.js
CHANGED
|
@@ -37,10 +37,13 @@ exports.ERROR_CODES = {
|
|
|
37
37
|
Device_InvalidState: 'Passphrase is incorrect',
|
|
38
38
|
Device_CallInProgress: 'Device call in progress',
|
|
39
39
|
Device_MultipleNotSupported: 'Multiple devices are not supported',
|
|
40
|
+
Device_MissingCapability: 'Device is missing capability',
|
|
41
|
+
Device_MissingCapabilityBtcOnly: 'Device is missing capability (BTC only)',
|
|
40
42
|
Failure_ActionCancelled: 'Action cancelled by user',
|
|
41
43
|
Failure_FirmwareError: 'Firmware installation failed',
|
|
42
44
|
Failure_UnknownCode: 'Unknown error',
|
|
43
45
|
Failure_PinCancelled: 'PIN cancelled',
|
|
46
|
+
Failure_PinInvalid: 'PIN invalid',
|
|
44
47
|
Failure_PinMismatch: 'PIN mismatch',
|
|
45
48
|
Failure_WipeCodeMismatch: 'Wipe code mismatch',
|
|
46
49
|
Deeplink_VersionMismatch: 'Not compatible with current version of the app',
|
package/lib/constants/index.d.ts
CHANGED
|
@@ -3,5 +3,6 @@ export * as NETWORK from './network';
|
|
|
3
3
|
export * as CARDANO from './cardano';
|
|
4
4
|
export * as NEM from './nem';
|
|
5
5
|
export * as FIRMWARE from './firmware';
|
|
6
|
+
export { DEFAULT_SORTING_STRATEGY } from './utxo';
|
|
6
7
|
export { MessagesSchema as PROTO } from '@trezor/protobuf';
|
|
7
8
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/constants/index.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PROTO = exports.FIRMWARE = exports.NEM = exports.CARDANO = exports.NETWORK = exports.ERRORS = void 0;
|
|
3
|
+
exports.PROTO = exports.DEFAULT_SORTING_STRATEGY = exports.FIRMWARE = exports.NEM = exports.CARDANO = exports.NETWORK = exports.ERRORS = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
exports.ERRORS = tslib_1.__importStar(require("./errors"));
|
|
6
6
|
exports.NETWORK = tslib_1.__importStar(require("./network"));
|
|
7
7
|
exports.CARDANO = tslib_1.__importStar(require("./cardano"));
|
|
8
8
|
exports.NEM = tslib_1.__importStar(require("./nem"));
|
|
9
9
|
exports.FIRMWARE = tslib_1.__importStar(require("./firmware"));
|
|
10
|
+
var utxo_1 = require("./utxo");
|
|
11
|
+
Object.defineProperty(exports, "DEFAULT_SORTING_STRATEGY", { enumerable: true, get: function () { return utxo_1.DEFAULT_SORTING_STRATEGY; } });
|
|
10
12
|
var protobuf_1 = require("@trezor/protobuf");
|
|
11
13
|
Object.defineProperty(exports, "PROTO", { enumerable: true, get: function () { return protobuf_1.MessagesSchema; } });
|
|
12
14
|
//# sourceMappingURL=index.js.map
|
package/lib/constants/nem.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export declare enum Networks {
|
|
|
5
5
|
mijin = 96
|
|
6
6
|
}
|
|
7
7
|
export type EnumNetworks = Static<typeof EnumNetworks>;
|
|
8
|
-
export declare const EnumNetworks: import("@
|
|
8
|
+
export declare const EnumNetworks: import("@trezor/schema-utils").TEnum<typeof Networks>;
|
|
9
9
|
export declare enum TxType {
|
|
10
10
|
TRANSFER = 257,
|
|
11
11
|
COSIGNING = 258,
|
|
@@ -18,12 +18,12 @@ export declare enum TxType {
|
|
|
18
18
|
SUPPLY_CHANGE = 16386
|
|
19
19
|
}
|
|
20
20
|
export type EnumTxType = Static<typeof EnumTxType>;
|
|
21
|
-
export declare const EnumTxType: import("@
|
|
21
|
+
export declare const EnumTxType: import("@trezor/schema-utils").TEnum<typeof TxType>;
|
|
22
22
|
export declare enum TxVersion {
|
|
23
23
|
mainnet = 1744830464,
|
|
24
24
|
testnet = -1744830464,
|
|
25
25
|
mijin = 1610612736
|
|
26
26
|
}
|
|
27
27
|
export type EnumTxVersion = Static<typeof EnumTxVersion>;
|
|
28
|
-
export declare const EnumTxVersion: import("@
|
|
28
|
+
export declare const EnumTxVersion: import("@trezor/schema-utils").TEnum<typeof TxVersion>;
|
|
29
29
|
//# sourceMappingURL=nem.d.ts.map
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { Capability } from '@trezor/protobuf/lib/messages';
|
|
1
2
|
import { NETWORK } from '../constants';
|
|
2
3
|
import { UI, CallMethodPayload, CallMethodResponse, UiRequestButtonData, UiPromiseCreator, CoreEventMessage, UiRequestConfirmation } from '../events';
|
|
3
4
|
import type { Device } from '../device/Device';
|
|
4
|
-
import type { FirmwareRange, DeviceState } from '../types';
|
|
5
|
+
import type { FirmwareRange, DeviceState, DeviceUniquePath, ConnectSettings } from '../types';
|
|
5
6
|
export type Payload<M> = Extract<CallMethodPayload, {
|
|
6
7
|
method: M;
|
|
7
8
|
}> & {
|
|
@@ -15,7 +16,7 @@ export declare abstract class AbstractMethod<Name extends CallMethodPayload['met
|
|
|
15
16
|
responseID: number;
|
|
16
17
|
device: Device;
|
|
17
18
|
params: Params;
|
|
18
|
-
devicePath?:
|
|
19
|
+
devicePath?: DeviceUniquePath;
|
|
19
20
|
deviceState?: DeviceState;
|
|
20
21
|
hasExpectedDeviceState: boolean;
|
|
21
22
|
keepSession: boolean;
|
|
@@ -37,6 +38,7 @@ export declare abstract class AbstractMethod<Name extends CallMethodPayload['met
|
|
|
37
38
|
requiredPermissions: MethodPermission[];
|
|
38
39
|
allowDeviceMode: DeviceMode[];
|
|
39
40
|
requireDeviceMode: DeviceMode[];
|
|
41
|
+
requiredDeviceCapabilities: Capability[];
|
|
40
42
|
network: NETWORK.NetworkType;
|
|
41
43
|
useCardanoDerivation: boolean;
|
|
42
44
|
noBackupConfirmationMode: 'never' | 'always' | 'popup-only';
|
|
@@ -50,11 +52,17 @@ export declare abstract class AbstractMethod<Name extends CallMethodPayload['met
|
|
|
50
52
|
});
|
|
51
53
|
setDevice(device: Device): void;
|
|
52
54
|
private getOriginPermissions;
|
|
53
|
-
checkPermissions(): void;
|
|
54
|
-
savePermissions(temporary
|
|
55
|
+
checkPermissions({ origin }: Pick<ConnectSettings, 'origin'>): void;
|
|
56
|
+
savePermissions(temporary: boolean | undefined, { origin }: Pick<ConnectSettings, 'origin'>): void;
|
|
55
57
|
checkFirmwareRange(): "ui-device_firmware_old" | "ui-device_firmware_unsupported" | "ui-device_firmware_not_compatible" | "ui-device_firmware_not_installed" | undefined;
|
|
56
|
-
isManagementRestricted(): boolean | undefined;
|
|
58
|
+
isManagementRestricted({ popup, origin }: Pick<ConnectSettings, 'popup' | 'origin'>): boolean | undefined;
|
|
57
59
|
abstract init(): void;
|
|
60
|
+
getMethodInfo(): {
|
|
61
|
+
useDevice: boolean;
|
|
62
|
+
useDeviceState: boolean;
|
|
63
|
+
name: Name;
|
|
64
|
+
};
|
|
65
|
+
checkDeviceCapability(): void;
|
|
58
66
|
abstract run(): Promise<MethodReturnType<Name>>;
|
|
59
67
|
dispose(): void;
|
|
60
68
|
}
|
|
@@ -3,21 +3,21 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.AbstractMethod = exports.DEFAULT_FIRMWARE_RANGE = void 0;
|
|
4
4
|
const connect_common_1 = require("@trezor/connect-common");
|
|
5
5
|
const utils_1 = require("@trezor/utils");
|
|
6
|
-
const DataManager_1 = require("../data/DataManager");
|
|
7
6
|
const constants_1 = require("../constants");
|
|
8
7
|
const events_1 = require("../events");
|
|
9
8
|
const urlUtils_1 = require("../utils/urlUtils");
|
|
10
|
-
const
|
|
9
|
+
const config_1 = require("../data/config");
|
|
11
10
|
exports.DEFAULT_FIRMWARE_RANGE = {
|
|
12
11
|
T1B1: { min: '1.0.0', max: '0' },
|
|
13
12
|
T2T1: { min: '2.0.0', max: '0' },
|
|
14
13
|
T2B1: { min: '2.6.1', max: '0' },
|
|
15
14
|
T3B1: { min: '2.8.1', max: '0' },
|
|
16
15
|
T3T1: { min: '2.7.1', max: '0' },
|
|
16
|
+
T3W1: { min: '2.7.1', max: '0' },
|
|
17
17
|
};
|
|
18
18
|
function validateStaticSessionId(input) {
|
|
19
19
|
if (typeof input !== 'string')
|
|
20
|
-
throw
|
|
20
|
+
throw constants_1.ERRORS.TypedError('Method_InvalidParameter', 'DeviceState: invalid staticSessionId: ' + input);
|
|
21
21
|
const [firstTestnetAddress, rest] = input.split('@');
|
|
22
22
|
const [deviceId, instance] = rest.split(':');
|
|
23
23
|
if (typeof firstTestnetAddress === 'string' &&
|
|
@@ -26,7 +26,26 @@ function validateStaticSessionId(input) {
|
|
|
26
26
|
Number.parseInt(instance) >= 0) {
|
|
27
27
|
return input;
|
|
28
28
|
}
|
|
29
|
-
throw
|
|
29
|
+
throw constants_1.ERRORS.TypedError('Method_InvalidParameter', 'DeviceState: invalid staticSessionId: ' + input);
|
|
30
|
+
}
|
|
31
|
+
function validateDeviceState(input) {
|
|
32
|
+
if (typeof input === 'string') {
|
|
33
|
+
return { staticSessionId: validateStaticSessionId(input) };
|
|
34
|
+
}
|
|
35
|
+
if (input && typeof input === 'object') {
|
|
36
|
+
const state = {};
|
|
37
|
+
if ('staticSessionId' in input) {
|
|
38
|
+
state.staticSessionId = validateStaticSessionId(input.staticSessionId);
|
|
39
|
+
}
|
|
40
|
+
if ('sessionId' in input && typeof input.sessionId === 'string') {
|
|
41
|
+
state.sessionId = input.sessionId;
|
|
42
|
+
}
|
|
43
|
+
if ('deriveCardano' in input && typeof input.deriveCardano === 'boolean') {
|
|
44
|
+
state.deriveCardano = input.deriveCardano;
|
|
45
|
+
}
|
|
46
|
+
return state;
|
|
47
|
+
}
|
|
48
|
+
return undefined;
|
|
30
49
|
}
|
|
31
50
|
class AbstractMethod {
|
|
32
51
|
get info() {
|
|
@@ -36,20 +55,14 @@ class AbstractMethod {
|
|
|
36
55
|
return undefined;
|
|
37
56
|
}
|
|
38
57
|
constructor(message) {
|
|
39
|
-
var _a, _b
|
|
58
|
+
var _a, _b;
|
|
59
|
+
this.requiredDeviceCapabilities = [];
|
|
40
60
|
const { payload } = message;
|
|
41
61
|
this.name = payload.method;
|
|
42
62
|
this.payload = payload;
|
|
43
63
|
this.responseID = message.id || 0;
|
|
44
64
|
this.devicePath = (_a = payload.device) === null || _a === void 0 ? void 0 : _a.path;
|
|
45
|
-
this.deviceState =
|
|
46
|
-
typeof ((_b = payload.device) === null || _b === void 0 ? void 0 : _b.state) === 'string'
|
|
47
|
-
? { staticSessionId: validateStaticSessionId(payload.device.state) }
|
|
48
|
-
: ((_d = (_c = payload.device) === null || _c === void 0 ? void 0 : _c.state) === null || _d === void 0 ? void 0 : _d.staticSessionId)
|
|
49
|
-
? {
|
|
50
|
-
staticSessionId: validateStaticSessionId(payload.device.state.staticSessionId),
|
|
51
|
-
}
|
|
52
|
-
: undefined;
|
|
65
|
+
this.deviceState = validateDeviceState((_b = payload.device) === null || _b === void 0 ? void 0 : _b.state);
|
|
53
66
|
this.hasExpectedDeviceState = payload.device
|
|
54
67
|
? Object.prototype.hasOwnProperty.call(payload.device, 'state')
|
|
55
68
|
: false;
|
|
@@ -88,20 +101,19 @@ class AbstractMethod {
|
|
|
88
101
|
}
|
|
89
102
|
setDevice(device) {
|
|
90
103
|
this.device = device;
|
|
91
|
-
this.devicePath = device.
|
|
104
|
+
this.devicePath = device.getUniquePath();
|
|
92
105
|
const originalFn = this.createUiPromise;
|
|
93
106
|
this.createUiPromise = (t, d) => originalFn(t, d || device);
|
|
94
107
|
}
|
|
95
|
-
getOriginPermissions() {
|
|
108
|
+
getOriginPermissions({ origin }) {
|
|
96
109
|
var _a;
|
|
97
|
-
const origin = DataManager_1.DataManager.getSettings('origin');
|
|
98
110
|
if (!origin) {
|
|
99
111
|
return [];
|
|
100
112
|
}
|
|
101
113
|
return ((_a = connect_common_1.storage.loadForOrigin(origin)) === null || _a === void 0 ? void 0 : _a.permissions) || [];
|
|
102
114
|
}
|
|
103
|
-
checkPermissions() {
|
|
104
|
-
const originPermissions = this.getOriginPermissions();
|
|
115
|
+
checkPermissions({ origin }) {
|
|
116
|
+
const originPermissions = this.getOriginPermissions({ origin });
|
|
105
117
|
let notPermitted = [...this.requiredPermissions];
|
|
106
118
|
if (originPermissions.length > 0) {
|
|
107
119
|
notPermitted = notPermitted.filter(np => {
|
|
@@ -111,8 +123,8 @@ class AbstractMethod {
|
|
|
111
123
|
}
|
|
112
124
|
this.requiredPermissions = notPermitted;
|
|
113
125
|
}
|
|
114
|
-
savePermissions(temporary = false) {
|
|
115
|
-
const originPermissions = this.getOriginPermissions();
|
|
126
|
+
savePermissions(temporary = false, { origin }) {
|
|
127
|
+
const originPermissions = this.getOriginPermissions({ origin });
|
|
116
128
|
let permissionsToSave = this.requiredPermissions.map(p => ({
|
|
117
129
|
type: p,
|
|
118
130
|
device: this.device.features.device_id || undefined,
|
|
@@ -130,7 +142,6 @@ class AbstractMethod {
|
|
|
130
142
|
return !granted;
|
|
131
143
|
});
|
|
132
144
|
}
|
|
133
|
-
const origin = DataManager_1.DataManager.getSettings('origin');
|
|
134
145
|
connect_common_1.storage.saveForOrigin(state => ({
|
|
135
146
|
...state,
|
|
136
147
|
permissions: [...(state.permissions || []), ...permissionsToSave],
|
|
@@ -167,14 +178,29 @@ class AbstractMethod {
|
|
|
167
178
|
return events_1.UI.FIRMWARE_NOT_COMPATIBLE;
|
|
168
179
|
}
|
|
169
180
|
}
|
|
170
|
-
isManagementRestricted() {
|
|
171
|
-
const { popup, origin } = DataManager_1.DataManager.getSettings();
|
|
181
|
+
isManagementRestricted({ popup, origin }) {
|
|
172
182
|
if (popup && this.requiredPermissions.includes('management')) {
|
|
173
183
|
const host = (0, urlUtils_1.getHost)(origin);
|
|
174
|
-
const allowed =
|
|
184
|
+
const allowed = config_1.config.management.find(item => item.origin === host || item.origin === origin);
|
|
175
185
|
return !allowed;
|
|
176
186
|
}
|
|
177
187
|
}
|
|
188
|
+
getMethodInfo() {
|
|
189
|
+
return {
|
|
190
|
+
useDevice: this.useDevice,
|
|
191
|
+
useDeviceState: this.useDeviceState,
|
|
192
|
+
name: this.name,
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
checkDeviceCapability() {
|
|
196
|
+
const deviceHasAllRequiredCapabilities = (this.requiredDeviceCapabilities || []).every(capability => this.device.features.capabilities.includes(capability));
|
|
197
|
+
if (!deviceHasAllRequiredCapabilities) {
|
|
198
|
+
if (this.device.firmwareType === 'bitcoin-only') {
|
|
199
|
+
throw constants_1.ERRORS.TypedError('Device_MissingCapabilityBtcOnly', `Trezor has Bitcoin-only firmware installed, which does not support this operation. Please install Universal firmware through Trezor Suite.`);
|
|
200
|
+
}
|
|
201
|
+
throw constants_1.ERRORS.TypedError('Device_MissingCapability', 'Device does not have capability to call this method. Make sure you have the latest firmware installed.');
|
|
202
|
+
}
|
|
203
|
+
}
|
|
178
204
|
dispose() { }
|
|
179
205
|
}
|
|
180
206
|
exports.AbstractMethod = AbstractMethod;
|