@trezor/connect 9.1.9 → 9.1.11
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 +16 -0
- package/README.md +1 -1
- package/lib/api/applyFlags.d.ts +4 -2
- package/lib/api/applyFlags.js +3 -2
- package/lib/api/applySettings.d.ts +4 -2
- package/lib/api/applySettings.js +3 -13
- package/lib/api/authenticateDevice.js +3 -11
- package/lib/api/authorizeCoinjoin.d.ts +3 -1
- package/lib/api/authorizeCoinjoin.js +3 -11
- package/lib/api/backupDevice.d.ts +3 -1
- package/lib/api/binance/api/binanceGetAddress.d.ts +4 -2
- package/lib/api/binance/api/binanceGetAddress.js +4 -10
- package/lib/api/binance/api/binanceGetPublicKey.d.ts +9 -1
- package/lib/api/binance/api/binanceGetPublicKey.js +3 -5
- package/lib/api/binance/api/binanceSignTransaction.d.ts +4 -1
- package/lib/api/binance/api/binanceSignTransaction.js +5 -6
- package/lib/api/binance/binanceSignTx.d.ts +84 -3
- package/lib/api/binance/binanceSignTx.js +3 -26
- package/lib/api/bitcoin/Fees.d.ts +14 -2
- package/lib/api/bitcoin/TransactionComposer.d.ts +13 -2
- package/lib/api/bitcoin/refTx.d.ts +2 -2
- package/lib/api/bitcoin/refTx.js +22 -24
- package/lib/api/bitcoin/signtxVerify.d.ts +1 -1
- package/lib/api/blockchainDisconnect.d.ts +1 -1
- package/lib/api/blockchainDisconnect.js +3 -2
- package/lib/api/blockchainGetAccountBalanceHistory.d.ts +1 -1
- package/lib/api/blockchainGetCurrentFiatRates.d.ts +1 -1
- package/lib/api/blockchainGetFiatRatesForTimestamps.d.ts +1 -1
- package/lib/api/blockchainGetTransactions.d.ts +1 -1
- package/lib/api/cancelCoinjoinAuthorization.d.ts +3 -1
- package/lib/api/cancelCoinjoinAuthorization.js +3 -0
- package/lib/api/cardano/api/cardanoGetAddress.d.ts +4 -2
- package/lib/api/cardano/api/cardanoGetAddress.js +4 -13
- package/lib/api/cardano/api/cardanoGetNativeScriptHash.d.ts +1 -1
- package/lib/api/cardano/api/cardanoGetNativeScriptHash.js +3 -13
- package/lib/api/cardano/api/cardanoGetPublicKey.d.ts +1 -1
- package/lib/api/cardano/api/cardanoGetPublicKey.js +4 -7
- package/lib/api/cardano/api/cardanoSignTransaction.d.ts +26 -4
- package/lib/api/cardano/api/cardanoSignTransaction.js +15 -46
- package/lib/api/cardano/cardanoAddressParameters.d.ts +1 -1
- package/lib/api/cardano/cardanoAddressParameters.js +3 -14
- package/lib/api/cardano/cardanoAuxiliaryData.d.ts +1 -1
- package/lib/api/cardano/cardanoAuxiliaryData.js +5 -20
- package/lib/api/cardano/cardanoCertificate.d.ts +1 -1
- package/lib/api/cardano/cardanoCertificate.js +20 -59
- package/lib/api/cardano/cardanoInputs.d.ts +20 -8
- package/lib/api/cardano/cardanoInputs.js +18 -14
- package/lib/api/cardano/cardanoOutputs.d.ts +31 -2
- package/lib/api/cardano/cardanoOutputs.js +14 -11
- package/lib/api/cardano/cardanoTokenBundle.d.ts +11 -6
- package/lib/api/cardano/cardanoTokenBundle.js +9 -21
- package/lib/api/changePin.d.ts +4 -2
- package/lib/api/changePin.js +3 -2
- package/lib/api/changeWipeCode.d.ts +3 -1
- package/lib/api/cipherKeyValue.d.ts +5 -1
- package/lib/api/cipherKeyValue.js +13 -21
- package/lib/api/common/paramsValidator.js +5 -4
- package/lib/api/eos/api/eosGetPublicKey.d.ts +11 -1
- package/lib/api/eos/api/eosGetPublicKey.js +3 -6
- package/lib/api/eos/api/eosSignTransaction.js +3 -5
- package/lib/api/eos/eosSignTx.d.ts +160 -2
- package/lib/api/ethereum/api/ethereumGetAddress.js +4 -10
- package/lib/api/ethereum/api/ethereumGetPublicKey.d.ts +21 -1
- package/lib/api/ethereum/api/ethereumGetPublicKey.js +3 -5
- package/lib/api/ethereum/api/ethereumSignMessage.d.ts +6 -3
- package/lib/api/ethereum/api/ethereumSignMessage.js +3 -5
- package/lib/api/ethereum/api/ethereumSignTransaction.d.ts +2 -2
- package/lib/api/ethereum/api/ethereumSignTransaction.js +3 -25
- package/lib/api/ethereum/api/ethereumSignTypedData.d.ts +83 -3
- package/lib/api/ethereum/api/ethereumSignTypedData.js +20 -12
- package/lib/api/ethereum/api/ethereumVerifyMessage.d.ts +3 -1
- package/lib/api/ethereum/api/ethereumVerifyMessage.js +3 -6
- package/lib/api/ethereum/ethereumDefinitions.d.ts +37 -19
- package/lib/api/ethereum/ethereumDefinitions.js +21 -15
- package/lib/api/ethereum/ethereumSignTx.d.ts +1 -1
- package/lib/api/firmware/getBinary.js +5 -4
- package/lib/api/firmware/modifyFirmware.js +3 -2
- package/lib/api/firmware/uploadFirmware.d.ts +3 -1
- package/lib/api/firmware/verifyAuthenticityProof.js +3 -3
- package/lib/api/firmwareUpdate.js +10 -15
- package/lib/api/getAccountDescriptor.d.ts +2 -2
- package/lib/api/getAccountDescriptor.js +4 -7
- package/lib/api/getAccountInfo.d.ts +8 -8
- package/lib/api/getAddress.d.ts +8 -2
- package/lib/api/getAddress.js +10 -20
- package/lib/api/getCoinInfo.d.ts +117 -2
- package/lib/api/getCoinInfo.js +3 -2
- package/lib/api/getFeatures.d.ts +49 -1
- package/lib/api/getFirmwareHash.d.ts +3 -1
- package/lib/api/getFirmwareHash.js +3 -1
- package/lib/api/getOwnershipId.js +4 -7
- package/lib/api/getOwnershipProof.js +4 -11
- package/lib/api/getPublicKey.d.ts +21 -1
- package/lib/api/getPublicKey.js +4 -18
- package/lib/api/nem/api/nemGetAddress.d.ts +4 -2
- package/lib/api/nem/api/nemGetAddress.js +4 -11
- package/lib/api/nem/api/nemSignTransaction.d.ts +4 -1
- package/lib/api/nem/api/nemSignTransaction.js +7 -5
- package/lib/api/nem/nemSignTx.d.ts +75 -1
- package/lib/api/pushTransaction.js +3 -5
- package/lib/api/rebootToBootloader.d.ts +3 -1
- package/lib/api/recoveryDevice.d.ts +3 -1
- package/lib/api/recoveryDevice.js +3 -12
- package/lib/api/requestLogin.js +7 -9
- package/lib/api/resetDevice.d.ts +3 -1
- package/lib/api/resetDevice.js +3 -12
- package/lib/api/ripple/api/rippleGetAddress.d.ts +4 -2
- package/lib/api/ripple/api/rippleGetAddress.js +4 -10
- package/lib/api/ripple/api/rippleSignTransaction.js +3 -17
- package/lib/api/setBusy.d.ts +3 -1
- package/lib/api/setBusy.js +3 -1
- package/lib/api/showDeviceTutorial.d.ts +3 -1
- package/lib/api/signMessage.d.ts +4 -1
- package/lib/api/signMessage.js +3 -7
- package/lib/api/solana/additionalInfo.js +3 -14
- package/lib/api/solana/api/solanaGetAddress.d.ts +4 -2
- package/lib/api/solana/api/solanaGetAddress.js +4 -7
- package/lib/api/solana/api/solanaGetPublicKey.d.ts +13 -1
- package/lib/api/solana/api/solanaGetPublicKey.js +3 -5
- package/lib/api/solana/api/solanaSignTransaction.js +3 -4
- package/lib/api/stellar/api/stellarGetAddress.d.ts +4 -2
- package/lib/api/stellar/api/stellarGetAddress.js +4 -10
- package/lib/api/stellar/api/stellarSignTransaction.js +3 -5
- package/lib/api/stellar/stellarSignTx.d.ts +5 -3
- package/lib/api/stellar/stellarSignTx.js +3 -15
- package/lib/api/tezos/api/tezosGetAddress.d.ts +4 -2
- package/lib/api/tezos/api/tezosGetAddress.js +4 -10
- package/lib/api/tezos/api/tezosGetPublicKey.d.ts +9 -1
- package/lib/api/tezos/api/tezosGetPublicKey.js +3 -6
- package/lib/api/tezos/api/tezosSignTransaction.d.ts +5 -1
- package/lib/api/tezos/api/tezosSignTransaction.js +3 -5
- package/lib/api/tezos/tezosSignTx.d.ts +70 -2
- package/lib/api/tezos/tezosSignTx.js +3 -44
- package/lib/api/unlockPath.js +3 -4
- package/lib/api/verifyMessage.d.ts +3 -1
- package/lib/api/verifyMessage.js +3 -7
- package/lib/api/wipeDevice.d.ts +3 -1
- package/lib/constants/index.d.ts +1 -1
- package/lib/constants/index.js +1 -1
- package/lib/constants/nem.d.ts +7 -0
- package/lib/constants/nem.js +5 -1
- package/lib/core/AbstractMethod.d.ts +1 -1
- package/lib/core/AbstractMethod.js +4 -3
- package/lib/core/index.js +4 -4
- package/lib/data/coinInfo.d.ts +588 -12
- package/lib/data/coinInfo.js +6 -6
- package/lib/data/config.js +5 -0
- package/lib/data/deviceAuthenticityConfig.d.ts +19 -13
- package/lib/data/deviceAuthenticityConfig.js +23 -1
- package/lib/data/firmwareInfo.js +11 -10
- package/lib/data/version.d.ts +1 -1
- package/lib/data/version.js +1 -1
- package/lib/device/Device.d.ts +2 -6
- package/lib/device/Device.js +8 -27
- package/lib/device/DeviceCommands.d.ts +36 -4
- package/lib/device/DeviceCommands.js +5 -2
- package/lib/device/DeviceList.js +1 -1
- package/lib/events/ui-promise.d.ts +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +2 -2
- package/lib/types/api/applySettings.d.ts +18 -2
- package/lib/types/api/applySettings.js +9 -0
- package/lib/types/api/authenticateDevice.d.ts +22 -5
- package/lib/types/api/authenticateDevice.js +7 -0
- package/lib/types/api/authorizeCoinjoin.d.ts +15 -13
- package/lib/types/api/authorizeCoinjoin.js +15 -0
- package/lib/types/api/binance/index.d.ts +203 -30
- package/lib/types/api/binance/index.js +48 -0
- package/lib/types/api/bitcoin/index.d.ts +18 -15
- package/lib/types/api/bitcoin/index.js +17 -0
- package/lib/types/api/cancelCoinjoinAuthorization.d.ts +5 -4
- package/lib/types/api/cancelCoinjoinAuthorization.js +5 -0
- package/lib/types/api/cardano/index.d.ts +685 -187
- package/lib/types/api/cardano/index.js +208 -0
- package/lib/types/api/cardanoSignTransaction.d.ts +5 -8
- package/lib/types/api/cipherKeyValue.d.ts +12 -11
- package/lib/types/api/cipherKeyValue.js +12 -0
- package/lib/types/api/eos/index.d.ts +783 -116
- package/lib/types/api/eos/index.js +177 -0
- package/lib/types/api/ethereum/index.d.ts +163 -57
- package/lib/types/api/ethereum/index.js +90 -0
- package/lib/types/api/firmwareUpdate.d.ts +11 -11
- package/lib/types/api/firmwareUpdate.js +15 -0
- package/lib/types/api/getAccountDescriptor.d.ts +10 -8
- package/lib/types/api/getAccountDescriptor.js +10 -0
- package/lib/types/api/getAddress.d.ts +42 -9
- package/lib/types/api/getAddress.js +14 -0
- package/lib/types/api/getOwnershipId.d.ts +33 -8
- package/lib/types/api/getOwnershipId.js +10 -0
- package/lib/types/api/getOwnershipProof.d.ts +37 -12
- package/lib/types/api/getOwnershipProof.js +14 -0
- package/lib/types/api/getPublicKey.d.ts +31 -21
- package/lib/types/api/getPublicKey.js +26 -0
- package/lib/types/api/nem/index.d.ts +841 -91
- package/lib/types/api/nem/index.js +130 -0
- package/lib/types/api/pushTransaction.d.ts +6 -4
- package/lib/types/api/pushTransaction.js +6 -0
- package/lib/types/api/recoveryDevice.d.ts +14 -4
- package/lib/types/api/recoveryDevice.js +9 -0
- package/lib/types/api/requestLogin.d.ts +38 -13
- package/lib/types/api/requestLogin.js +15 -0
- package/lib/types/api/resetDevice.d.ts +15 -13
- package/lib/types/api/resetDevice.js +9 -0
- package/lib/types/api/ripple/index.d.ts +40 -22
- package/lib/types/api/ripple/index.js +24 -0
- package/lib/types/api/solana/index.d.ts +42 -21
- package/lib/types/api/solana/index.js +26 -0
- package/lib/types/api/stellar/index.d.ts +890 -180
- package/lib/types/api/stellar/index.js +249 -0
- package/lib/types/api/tezos/index.d.ts +162 -59
- package/lib/types/api/tezos/index.js +61 -0
- package/lib/types/api/unlockPath.d.ts +7 -5
- package/lib/types/api/unlockPath.js +7 -0
- package/lib/types/coinInfo.d.ts +273 -56
- package/lib/types/coinInfo.js +81 -0
- package/lib/types/device.d.ts +1 -1
- package/lib/types/device.js +2 -2
- package/lib/types/fees.d.ts +29 -25
- package/lib/types/fees.js +36 -0
- package/lib/types/firmware.d.ts +1 -0
- package/lib/types/firmware.js +3 -0
- package/lib/types/params.d.ts +26 -17
- package/lib/types/params.js +23 -0
- package/lib/utils/deviceFeaturesUtils.js +5 -4
- package/lib/utils/firmwareUtils.js +5 -4
- package/lib/utils/hdnodeUtils.d.ts +191 -1
- package/lib/utils/pathUtils.d.ts +191 -1
- package/lib/utils/urlUtils.js +3 -3
- package/package.json +10 -9
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AbstractMethod } from '../../../core/AbstractMethod';
|
|
2
2
|
import type { PROTO } from '../../../constants';
|
|
3
|
-
import
|
|
4
|
-
import type { EthereumDefinitions } from '@trezor/protobuf/lib/messages';
|
|
3
|
+
import { EthereumNetworkInfo } from '../../../types';
|
|
4
|
+
import type { EthereumDefinitions } from '@trezor/protobuf/lib/messages-schema';
|
|
5
5
|
type Params = PROTO.EthereumSignMessage & {
|
|
6
6
|
network?: EthereumNetworkInfo;
|
|
7
7
|
definitions?: EthereumDefinitions;
|
|
@@ -10,7 +10,10 @@ export default class EthereumSignMessage extends AbstractMethod<'ethereumSignMes
|
|
|
10
10
|
init(): void;
|
|
11
11
|
initAsync(): Promise<void>;
|
|
12
12
|
get info(): string;
|
|
13
|
-
run(): Promise<
|
|
13
|
+
run(): Promise<{
|
|
14
|
+
address: string;
|
|
15
|
+
signature: string;
|
|
16
|
+
}>;
|
|
14
17
|
}
|
|
15
18
|
export {};
|
|
16
19
|
//# sourceMappingURL=ethereumSignMessage.d.ts.map
|
|
@@ -7,15 +7,13 @@ const coinInfo_1 = require("../../../data/coinInfo");
|
|
|
7
7
|
const ethereumUtils_1 = require("../../../utils/ethereumUtils");
|
|
8
8
|
const formatUtils_1 = require("../../../utils/formatUtils");
|
|
9
9
|
const ethereumDefinitions_1 = require("../ethereumDefinitions");
|
|
10
|
+
const types_1 = require("../../../types");
|
|
11
|
+
const schema_utils_1 = require("@trezor/schema-utils");
|
|
10
12
|
class EthereumSignMessage extends AbstractMethod_1.AbstractMethod {
|
|
11
13
|
init() {
|
|
12
14
|
this.requiredPermissions = ['read', 'write'];
|
|
13
15
|
const { payload } = this;
|
|
14
|
-
(0,
|
|
15
|
-
{ name: 'path', required: true },
|
|
16
|
-
{ name: 'message', type: 'string', required: true },
|
|
17
|
-
{ name: 'hex', type: 'boolean' },
|
|
18
|
-
]);
|
|
16
|
+
(0, schema_utils_1.Assert)(types_1.EthereumSignMessage, payload);
|
|
19
17
|
const path = (0, pathUtils_1.validatePath)(payload.path, 3);
|
|
20
18
|
const network = (0, coinInfo_1.getEthereumNetwork)(path);
|
|
21
19
|
this.firmwareRange = (0, paramsValidator_1.getFirmwareRange)(this.name, network, this.firmwareRange);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AbstractMethod } from '../../../core/AbstractMethod';
|
|
2
2
|
import type { EthereumTransaction, EthereumTransactionEIP1559 } from '../../../types/api/ethereum';
|
|
3
|
-
import
|
|
4
|
-
import type { EthereumDefinitions } from '@trezor/protobuf/lib/messages';
|
|
3
|
+
import { EthereumNetworkInfo } from '../../../types';
|
|
4
|
+
import type { EthereumDefinitions } from '@trezor/protobuf/lib/messages-schema';
|
|
5
5
|
type Params = {
|
|
6
6
|
path: number[];
|
|
7
7
|
network?: EthereumNetworkInfo;
|
|
@@ -9,6 +9,8 @@ const ethereumUtils_1 = require("../../../utils/ethereumUtils");
|
|
|
9
9
|
const formatUtils_1 = require("../../../utils/formatUtils");
|
|
10
10
|
const helper = tslib_1.__importStar(require("../ethereumSignTx"));
|
|
11
11
|
const ethereumDefinitions_1 = require("../ethereumDefinitions");
|
|
12
|
+
const types_1 = require("../../../types");
|
|
13
|
+
const schema_utils_1 = require("@trezor/schema-utils");
|
|
12
14
|
const strip = (0, formatUtils_1.deepTransform)(value => {
|
|
13
15
|
let stripped = (0, formatUtils_1.stripHexPrefix)(value);
|
|
14
16
|
if (stripped.length % 2 !== 0) {
|
|
@@ -20,11 +22,7 @@ class EthereumSignTransaction extends AbstractMethod_1.AbstractMethod {
|
|
|
20
22
|
init() {
|
|
21
23
|
this.requiredPermissions = ['read', 'write'];
|
|
22
24
|
const { payload } = this;
|
|
23
|
-
(0,
|
|
24
|
-
{ name: 'path', required: true },
|
|
25
|
-
{ name: 'transaction', required: true },
|
|
26
|
-
{ name: 'chunkify', type: 'boolean' },
|
|
27
|
-
]);
|
|
25
|
+
(0, schema_utils_1.Assert)(types_1.EthereumSignTransaction, payload);
|
|
28
26
|
const path = (0, pathUtils_1.validatePath)(payload.path, 3);
|
|
29
27
|
const network = (0, coinInfo_1.getEthereumNetwork)(path);
|
|
30
28
|
const chunkify = typeof payload.chunkify === 'boolean' ? payload.chunkify : false;
|
|
@@ -32,29 +30,9 @@ class EthereumSignTransaction extends AbstractMethod_1.AbstractMethod {
|
|
|
32
30
|
const isEIP1559 = typeof tx.maxFeePerGas === 'string' && typeof tx.maxPriorityFeePerGas === 'string';
|
|
33
31
|
this.firmwareRange = (0, paramsValidator_1.getFirmwareRange)(isEIP1559 ? 'eip1559' : this.name, network, this.firmwareRange);
|
|
34
32
|
if (isEIP1559) {
|
|
35
|
-
(0, paramsValidator_1.validateParams)(tx, [
|
|
36
|
-
{ name: 'to', type: 'string', required: true },
|
|
37
|
-
{ name: 'value', type: 'string', required: true },
|
|
38
|
-
{ name: 'gasLimit', type: 'string', required: true },
|
|
39
|
-
{ name: 'maxFeePerGas', type: 'string', required: true },
|
|
40
|
-
{ name: 'maxPriorityFeePerGas', type: 'string', required: true },
|
|
41
|
-
{ name: 'nonce', type: 'string', required: true },
|
|
42
|
-
{ name: 'data', type: 'string' },
|
|
43
|
-
{ name: 'chainId', type: 'number', required: true },
|
|
44
|
-
]);
|
|
45
33
|
this.params = { path, network, type: 'eip1559', tx: strip(tx), chunkify };
|
|
46
34
|
}
|
|
47
35
|
else {
|
|
48
|
-
(0, paramsValidator_1.validateParams)(tx, [
|
|
49
|
-
{ name: 'to', type: 'string', required: true },
|
|
50
|
-
{ name: 'value', type: 'string', required: true },
|
|
51
|
-
{ name: 'gasLimit', type: 'string', required: true },
|
|
52
|
-
{ name: 'gasPrice', type: 'string', required: true },
|
|
53
|
-
{ name: 'nonce', type: 'string', required: true },
|
|
54
|
-
{ name: 'data', type: 'string' },
|
|
55
|
-
{ name: 'chainId', type: 'number' },
|
|
56
|
-
{ name: 'txType', type: 'number' },
|
|
57
|
-
]);
|
|
58
36
|
this.params = { path, network, type: 'legacy', tx: strip(tx), chunkify };
|
|
59
37
|
}
|
|
60
38
|
if (typeof tx.chainId !== 'number') {
|
|
@@ -1,12 +1,92 @@
|
|
|
1
1
|
import { AbstractMethod } from '../../../core/AbstractMethod';
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
2
|
+
import { EthereumSignTypedDataTypes, EthereumSignTypedData as EthereumSignTypedDataParams, EthereumSignTypedHash as EthereumSignTypedHashParams } from '../../../types/api/ethereum';
|
|
3
|
+
import { EthereumNetworkInfo } from '../../../types';
|
|
4
|
+
import { EthereumDefinitions } from '@trezor/protobuf/lib/messages-schema';
|
|
5
5
|
type Params = (Omit<EthereumSignTypedDataParams<EthereumSignTypedDataTypes>, 'path'> | Omit<EthereumSignTypedHashParams<EthereumSignTypedDataTypes>, 'path'>) & {
|
|
6
6
|
address_n: number[];
|
|
7
7
|
network?: EthereumNetworkInfo;
|
|
8
8
|
definitions?: EthereumDefinitions;
|
|
9
9
|
};
|
|
10
|
+
declare const Params: import("@sinclair/typebox").TIntersect<[import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
|
|
11
|
+
data: import("@sinclair/typebox").TObject<{
|
|
12
|
+
types: import("@sinclair/typebox").TObject<{
|
|
13
|
+
EIP712Domain: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
|
|
14
|
+
name: import("@sinclair/typebox").TString;
|
|
15
|
+
type: import("@sinclair/typebox").TString;
|
|
16
|
+
}>>;
|
|
17
|
+
}>;
|
|
18
|
+
primaryType: import("@sinclair/typebox").TString;
|
|
19
|
+
domain: import("@sinclair/typebox").TObject<{
|
|
20
|
+
name: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
21
|
+
version: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
22
|
+
chainId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TNumber, import("@sinclair/typebox").TBigInt, import("@sinclair/typebox").TString]>>;
|
|
23
|
+
verifyingContract: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
24
|
+
salt: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@trezor/schema-utils/lib/custom-types/array-buffer").TArrayBuffer, import("@sinclair/typebox").TString]>>;
|
|
25
|
+
}>;
|
|
26
|
+
message: import("@sinclair/typebox").TObject<{}>;
|
|
27
|
+
}>;
|
|
28
|
+
metamask_v4_compat: import("@sinclair/typebox").TBoolean;
|
|
29
|
+
domain_separator_hash: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUndefined>;
|
|
30
|
+
message_hash: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUndefined>;
|
|
31
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
32
|
+
data: import("@sinclair/typebox").TObject<{
|
|
33
|
+
types: import("@sinclair/typebox").TObject<{
|
|
34
|
+
EIP712Domain: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
|
|
35
|
+
name: import("@sinclair/typebox").TString;
|
|
36
|
+
type: import("@sinclair/typebox").TString;
|
|
37
|
+
}>>;
|
|
38
|
+
}>;
|
|
39
|
+
primaryType: import("@sinclair/typebox").TString;
|
|
40
|
+
domain: import("@sinclair/typebox").TObject<{
|
|
41
|
+
name: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
42
|
+
version: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
43
|
+
chainId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TNumber, import("@sinclair/typebox").TBigInt, import("@sinclair/typebox").TString]>>;
|
|
44
|
+
verifyingContract: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
45
|
+
salt: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@trezor/schema-utils/lib/custom-types/array-buffer").TArrayBuffer, import("@sinclair/typebox").TString]>>;
|
|
46
|
+
}>;
|
|
47
|
+
message: import("@sinclair/typebox").TObject<{}>;
|
|
48
|
+
}>;
|
|
49
|
+
metamask_v4_compat: import("@sinclair/typebox").TBoolean;
|
|
50
|
+
domain_separator_hash: import("@sinclair/typebox").TString;
|
|
51
|
+
message_hash: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
52
|
+
}>]>, import("@sinclair/typebox").TObject<{
|
|
53
|
+
address_n: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TNumber>;
|
|
54
|
+
network: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TIntersect<[import("@sinclair/typebox").TObject<{
|
|
55
|
+
label: import("@sinclair/typebox").TString;
|
|
56
|
+
name: import("@sinclair/typebox").TString;
|
|
57
|
+
shortcut: import("@sinclair/typebox").TString;
|
|
58
|
+
slip44: import("@sinclair/typebox").TNumber;
|
|
59
|
+
support: import("@sinclair/typebox").TObject<{
|
|
60
|
+
connect: import("@sinclair/typebox").TBoolean;
|
|
61
|
+
T1B1: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TLiteral<false>]>;
|
|
62
|
+
T2T1: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TLiteral<false>]>;
|
|
63
|
+
T2B1: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TLiteral<false>]>;
|
|
64
|
+
}>;
|
|
65
|
+
decimals: import("@sinclair/typebox").TNumber;
|
|
66
|
+
blockchainLink: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
|
|
67
|
+
type: import("@sinclair/typebox").TString;
|
|
68
|
+
url: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>;
|
|
69
|
+
}>>;
|
|
70
|
+
blockTime: import("@sinclair/typebox").TNumber;
|
|
71
|
+
minFee: import("@sinclair/typebox").TNumber;
|
|
72
|
+
maxFee: import("@sinclair/typebox").TNumber;
|
|
73
|
+
defaultFees: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
|
|
74
|
+
label: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"high">, import("@sinclair/typebox").TLiteral<"normal">, import("@sinclair/typebox").TLiteral<"economy">, import("@sinclair/typebox").TLiteral<"low">, import("@sinclair/typebox").TLiteral<"custom">]>;
|
|
75
|
+
feePerUnit: import("@sinclair/typebox").TString;
|
|
76
|
+
blocks: import("@sinclair/typebox").TNumber;
|
|
77
|
+
feeLimit: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
78
|
+
feePerTx: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
79
|
+
}>>;
|
|
80
|
+
}>, import("@sinclair/typebox").TObject<{
|
|
81
|
+
type: import("@sinclair/typebox").TLiteral<"ethereum">;
|
|
82
|
+
chainId: import("@sinclair/typebox").TNumber;
|
|
83
|
+
network: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUndefined>;
|
|
84
|
+
}>]>>;
|
|
85
|
+
definitions: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
|
|
86
|
+
encoded_network: import("@sinclair/typebox").TOptional<import("@trezor/schema-utils/lib/custom-types/array-buffer").TArrayBuffer>;
|
|
87
|
+
encoded_token: import("@sinclair/typebox").TOptional<import("@trezor/schema-utils/lib/custom-types/array-buffer").TArrayBuffer>;
|
|
88
|
+
}>>;
|
|
89
|
+
}>]>;
|
|
10
90
|
export default class EthereumSignTypedData extends AbstractMethod<'ethereumSignTypedData', Params> {
|
|
11
91
|
init(): void;
|
|
12
92
|
initAsync(): Promise<void>;
|
|
@@ -6,21 +6,29 @@ const pathUtils_1 = require("../../../utils/pathUtils");
|
|
|
6
6
|
const coinInfo_1 = require("../../../data/coinInfo");
|
|
7
7
|
const ethereumUtils_1 = require("../../../utils/ethereumUtils");
|
|
8
8
|
const constants_1 = require("../../../constants");
|
|
9
|
+
const ethereum_1 = require("../../../types/api/ethereum");
|
|
9
10
|
const ethereumSignTypedData_1 = require("../ethereumSignTypedData");
|
|
10
11
|
const formatUtils_1 = require("../../../utils/formatUtils");
|
|
11
12
|
const ethereumDefinitions_1 = require("../ethereumDefinitions");
|
|
12
13
|
const types_1 = require("../../../types");
|
|
14
|
+
const messages_schema_1 = require("@trezor/protobuf/lib/messages-schema");
|
|
15
|
+
const schema_utils_1 = require("@trezor/schema-utils");
|
|
16
|
+
const Params = schema_utils_1.Type.Intersect([
|
|
17
|
+
schema_utils_1.Type.Union([
|
|
18
|
+
schema_utils_1.Type.Omit(ethereum_1.EthereumSignTypedData, schema_utils_1.Type.Literal('path')),
|
|
19
|
+
schema_utils_1.Type.Omit(ethereum_1.EthereumSignTypedHash, schema_utils_1.Type.Literal('path')),
|
|
20
|
+
]),
|
|
21
|
+
schema_utils_1.Type.Object({
|
|
22
|
+
address_n: schema_utils_1.Type.Array(schema_utils_1.Type.Number()),
|
|
23
|
+
network: schema_utils_1.Type.Optional(types_1.EthereumNetworkInfo),
|
|
24
|
+
definitions: schema_utils_1.Type.Optional(messages_schema_1.EthereumDefinitions),
|
|
25
|
+
}),
|
|
26
|
+
]);
|
|
13
27
|
class EthereumSignTypedData extends AbstractMethod_1.AbstractMethod {
|
|
14
28
|
init() {
|
|
15
29
|
this.requiredPermissions = ['read', 'write'];
|
|
16
30
|
const { payload } = this;
|
|
17
|
-
(0,
|
|
18
|
-
{ name: 'path', required: true },
|
|
19
|
-
{ name: 'metamask_v4_compat', type: 'boolean', required: true },
|
|
20
|
-
{ name: 'data', type: 'object', required: true },
|
|
21
|
-
{ name: 'domain_separator_hash', type: 'string' },
|
|
22
|
-
{ name: 'message_hash', type: 'string' },
|
|
23
|
-
]);
|
|
31
|
+
(0, schema_utils_1.Assert)(schema_utils_1.Type.Union([ethereum_1.EthereumSignTypedData, ethereum_1.EthereumSignTypedHash]), payload);
|
|
24
32
|
const path = (0, pathUtils_1.validatePath)(payload.path, 3);
|
|
25
33
|
const network = (0, coinInfo_1.getEthereumNetwork)(path);
|
|
26
34
|
this.firmwareRange = (0, paramsValidator_1.getFirmwareRange)(this.name, network, this.firmwareRange);
|
|
@@ -68,14 +76,14 @@ class EthereumSignTypedData extends AbstractMethod_1.AbstractMethod {
|
|
|
68
76
|
const cmd = this.device.getCommands();
|
|
69
77
|
const { address_n, definitions } = this.params;
|
|
70
78
|
if (this.device.features.internal_model === types_1.DeviceModelInternal.T1B1) {
|
|
71
|
-
(0,
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
79
|
+
(0, schema_utils_1.Assert)(schema_utils_1.Type.Object({
|
|
80
|
+
domain_separator_hash: schema_utils_1.Type.String(),
|
|
81
|
+
message_hash: schema_utils_1.Type.Optional(schema_utils_1.Type.String()),
|
|
82
|
+
}), this.params);
|
|
75
83
|
const { domain_separator_hash, message_hash } = this.params;
|
|
76
84
|
const response = await cmd.typedCall('EthereumSignTypedHash', 'EthereumTypedDataSignature', {
|
|
77
85
|
address_n,
|
|
78
|
-
domain_separator_hash
|
|
86
|
+
domain_separator_hash,
|
|
79
87
|
message_hash,
|
|
80
88
|
encoded_network: definitions === null || definitions === void 0 ? void 0 : definitions.encoded_network,
|
|
81
89
|
});
|
|
@@ -3,6 +3,8 @@ import type { PROTO } from '../../../constants';
|
|
|
3
3
|
export default class EthereumVerifyMessage extends AbstractMethod<'ethereumVerifyMessage', PROTO.EthereumVerifyMessage> {
|
|
4
4
|
init(): void;
|
|
5
5
|
get info(): string;
|
|
6
|
-
run(): Promise<
|
|
6
|
+
run(): Promise<{
|
|
7
|
+
message: string;
|
|
8
|
+
}>;
|
|
7
9
|
}
|
|
8
10
|
//# sourceMappingURL=ethereumVerifyMessage.d.ts.map
|
|
@@ -3,17 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const AbstractMethod_1 = require("../../../core/AbstractMethod");
|
|
4
4
|
const paramsValidator_1 = require("../../common/paramsValidator");
|
|
5
5
|
const formatUtils_1 = require("../../../utils/formatUtils");
|
|
6
|
+
const schema_utils_1 = require("@trezor/schema-utils");
|
|
7
|
+
const types_1 = require("../../../types");
|
|
6
8
|
class EthereumVerifyMessage extends AbstractMethod_1.AbstractMethod {
|
|
7
9
|
init() {
|
|
8
10
|
this.requiredPermissions = ['read', 'write'];
|
|
9
11
|
this.firmwareRange = (0, paramsValidator_1.getFirmwareRange)(this.name, null, this.firmwareRange);
|
|
10
12
|
const { payload } = this;
|
|
11
|
-
(0,
|
|
12
|
-
{ name: 'address', type: 'string', required: true },
|
|
13
|
-
{ name: 'signature', type: 'string', required: true },
|
|
14
|
-
{ name: 'message', type: 'string', required: true },
|
|
15
|
-
{ name: 'hex', type: 'boolean' },
|
|
16
|
-
]);
|
|
13
|
+
(0, schema_utils_1.Assert)(types_1.EthereumVerifyMessage, payload);
|
|
17
14
|
const messageHex = payload.hex
|
|
18
15
|
? (0, formatUtils_1.messageToHex)(payload.message)
|
|
19
16
|
: Buffer.from(payload.message, 'utf8').toString('hex');
|
|
@@ -1,28 +1,46 @@
|
|
|
1
|
-
import { EthereumDefinitions } from '@trezor/protobuf/lib/messages';
|
|
1
|
+
import { EthereumDefinitions } from '@trezor/protobuf/lib/messages-schema';
|
|
2
2
|
import { EthereumNetworkInfo } from '../../types';
|
|
3
|
+
import { Static } from '@trezor/schema-utils';
|
|
3
4
|
interface GetEthereumDefinitions {
|
|
4
5
|
chainId?: number;
|
|
5
6
|
slip44?: number;
|
|
6
7
|
contractAddress?: string;
|
|
7
8
|
}
|
|
8
|
-
export declare const getEthereumDefinitions: ({ chainId, slip44, contractAddress, }: GetEthereumDefinitions) => Promise<
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
9
|
+
export declare const getEthereumDefinitions: ({ chainId, slip44, contractAddress, }: GetEthereumDefinitions) => Promise<{
|
|
10
|
+
encoded_network?: ArrayBuffer | undefined;
|
|
11
|
+
encoded_token?: ArrayBuffer | undefined;
|
|
12
|
+
}>;
|
|
13
|
+
export type EthereumNetworkDefinitionDecoded = Static<typeof EthereumNetworkDefinitionDecoded>;
|
|
14
|
+
export declare const EthereumNetworkDefinitionDecoded: import("@sinclair/typebox").TObject<{
|
|
15
|
+
chain_id: import("@sinclair/typebox").TNumber;
|
|
16
|
+
name: import("@sinclair/typebox").TString;
|
|
17
|
+
slip44: import("@sinclair/typebox").TNumber;
|
|
18
|
+
symbol: import("@sinclair/typebox").TString;
|
|
19
|
+
}>;
|
|
20
|
+
export type EthereumTokenDefinitionDecoded = Static<typeof EthereumTokenDefinitionDecoded>;
|
|
21
|
+
export declare const EthereumTokenDefinitionDecoded: import("@sinclair/typebox").TObject<{
|
|
22
|
+
address: import("@sinclair/typebox").TString;
|
|
23
|
+
chain_id: import("@sinclair/typebox").TNumber;
|
|
24
|
+
decimals: import("@sinclair/typebox").TNumber;
|
|
25
|
+
name: import("@sinclair/typebox").TString;
|
|
26
|
+
symbol: import("@sinclair/typebox").TString;
|
|
27
|
+
}>;
|
|
28
|
+
export type EthereumDefinitionDecoded = Static<typeof EthereumDefinitionDecoded>;
|
|
29
|
+
export declare const EthereumDefinitionDecoded: import("@sinclair/typebox").TObject<{
|
|
30
|
+
network: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
|
|
31
|
+
chain_id: import("@sinclair/typebox").TNumber;
|
|
32
|
+
name: import("@sinclair/typebox").TString;
|
|
33
|
+
slip44: import("@sinclair/typebox").TNumber;
|
|
34
|
+
symbol: import("@sinclair/typebox").TString;
|
|
35
|
+
}>>;
|
|
36
|
+
token: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
|
|
37
|
+
address: import("@sinclair/typebox").TString;
|
|
38
|
+
chain_id: import("@sinclair/typebox").TNumber;
|
|
39
|
+
decimals: import("@sinclair/typebox").TNumber;
|
|
40
|
+
name: import("@sinclair/typebox").TString;
|
|
41
|
+
symbol: import("@sinclair/typebox").TString;
|
|
42
|
+
}>>;
|
|
43
|
+
}>;
|
|
26
44
|
export declare const decodeEthereumDefinition: (encodedDefinition: EthereumDefinitions) => EthereumDefinitionDecoded;
|
|
27
45
|
export declare const ethereumNetworkInfoFromDefinition: (definition: EthereumNetworkDefinitionDecoded) => EthereumNetworkInfo;
|
|
28
46
|
export {};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ethereumNetworkInfoFromDefinition = exports.decodeEthereumDefinition = exports.getEthereumDefinitions = void 0;
|
|
3
|
+
exports.ethereumNetworkInfoFromDefinition = exports.decodeEthereumDefinition = exports.EthereumDefinitionDecoded = exports.EthereumTokenDefinitionDecoded = exports.EthereumNetworkDefinitionDecoded = exports.getEthereumDefinitions = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const cross_fetch_1 = tslib_1.__importDefault(require("cross-fetch"));
|
|
6
6
|
const protocol_1 = require("@trezor/protocol");
|
|
7
7
|
const protobuf_1 = require("@trezor/protobuf");
|
|
8
8
|
const DataManager_1 = require("../../data/DataManager");
|
|
9
|
-
const paramsValidator_1 = require("../common/paramsValidator");
|
|
10
9
|
const coinInfo_1 = require("../../data/coinInfo");
|
|
10
|
+
const schema_utils_1 = require("@trezor/schema-utils");
|
|
11
11
|
const getEthereumDefinitions = async ({ chainId, slip44, contractAddress, }) => {
|
|
12
12
|
const definitions = {};
|
|
13
13
|
if (!chainId && !slip44) {
|
|
@@ -45,6 +45,23 @@ const getEthereumDefinitions = async ({ chainId, slip44, contractAddress, }) =>
|
|
|
45
45
|
return definitions;
|
|
46
46
|
};
|
|
47
47
|
exports.getEthereumDefinitions = getEthereumDefinitions;
|
|
48
|
+
exports.EthereumNetworkDefinitionDecoded = schema_utils_1.Type.Object({
|
|
49
|
+
chain_id: schema_utils_1.Type.Number(),
|
|
50
|
+
name: schema_utils_1.Type.String(),
|
|
51
|
+
slip44: schema_utils_1.Type.Number(),
|
|
52
|
+
symbol: schema_utils_1.Type.String(),
|
|
53
|
+
});
|
|
54
|
+
exports.EthereumTokenDefinitionDecoded = schema_utils_1.Type.Object({
|
|
55
|
+
address: schema_utils_1.Type.String(),
|
|
56
|
+
chain_id: schema_utils_1.Type.Number(),
|
|
57
|
+
decimals: schema_utils_1.Type.Number(),
|
|
58
|
+
name: schema_utils_1.Type.String(),
|
|
59
|
+
symbol: schema_utils_1.Type.String(),
|
|
60
|
+
});
|
|
61
|
+
exports.EthereumDefinitionDecoded = schema_utils_1.Type.Object({
|
|
62
|
+
network: schema_utils_1.Type.Optional(exports.EthereumNetworkDefinitionDecoded),
|
|
63
|
+
token: schema_utils_1.Type.Optional(exports.EthereumTokenDefinitionDecoded),
|
|
64
|
+
});
|
|
48
65
|
const decodeEthereumDefinition = (encodedDefinition) => {
|
|
49
66
|
const decoded = {
|
|
50
67
|
network: undefined,
|
|
@@ -62,22 +79,11 @@ const decodeEthereumDefinition = (encodedDefinition) => {
|
|
|
62
79
|
const Message = proto.lookupType(type);
|
|
63
80
|
const decodedDefinition = (0, protobuf_1.decode)(Message, protobufPayload);
|
|
64
81
|
if (key === 'encoded_network') {
|
|
65
|
-
(0,
|
|
66
|
-
{ name: 'chain_id', type: 'number', required: true },
|
|
67
|
-
{ name: 'name', type: 'string', required: true },
|
|
68
|
-
{ name: 'slip44', type: 'number', required: true },
|
|
69
|
-
{ name: 'symbol', type: 'string', required: true },
|
|
70
|
-
]);
|
|
82
|
+
(0, schema_utils_1.Assert)(exports.EthereumNetworkDefinitionDecoded, decodedDefinition);
|
|
71
83
|
decoded.network = decodedDefinition;
|
|
72
84
|
}
|
|
73
85
|
else if (key === 'encoded_token') {
|
|
74
|
-
(0,
|
|
75
|
-
{ name: 'address', type: 'string', required: true },
|
|
76
|
-
{ name: 'chain_id', type: 'number', required: true },
|
|
77
|
-
{ name: 'name', type: 'string', required: true },
|
|
78
|
-
{ name: 'decimals', type: 'number', required: true },
|
|
79
|
-
{ name: 'symbol', type: 'string', required: true },
|
|
80
|
-
]);
|
|
86
|
+
(0, schema_utils_1.Assert)(exports.EthereumTokenDefinitionDecoded, decodedDefinition);
|
|
81
87
|
decoded.token = decodedDefinition;
|
|
82
88
|
}
|
|
83
89
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FeeMarketEIP1559TxData, LegacyTxData } from '@ethereumjs/tx';
|
|
2
|
-
import { EthereumDefinitions } from '@trezor/protobuf/lib/messages';
|
|
2
|
+
import { EthereumDefinitions } from '@trezor/protobuf/lib/messages-schema';
|
|
3
3
|
import type { TypedCall } from '../../device/DeviceCommands';
|
|
4
4
|
import type { EthereumAccessList } from '../../types/api/ethereum';
|
|
5
5
|
export declare const serializeEthereumTx: (txData: LegacyTxData | FeeMarketEIP1559TxData, chainId: number) => string;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getBinary = void 0;
|
|
4
|
-
const
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const versionUtils = tslib_1.__importStar(require("@trezor/utils/lib/versionUtils"));
|
|
5
6
|
const assets_1 = require("../../utils/assets");
|
|
6
7
|
const firmwareUtils_1 = require("../../utils/firmwareUtils");
|
|
7
8
|
const firmwareInfo_1 = require("../../data/firmwareInfo");
|
|
@@ -14,15 +15,15 @@ const getBinary = ({ features, releases, baseUrl, version, btcOnly, intermediary
|
|
|
14
15
|
}
|
|
15
16
|
const infoByBootloader = (0, firmwareInfo_1.getInfo)({ features, releases });
|
|
16
17
|
const releaseByFirmware = releases.find(r => version &&
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
versionUtils.isVersionArray(version) &&
|
|
19
|
+
versionUtils.isEqual(r.version, version));
|
|
19
20
|
if (!infoByBootloader || !releaseByFirmware) {
|
|
20
21
|
throw new Error('no firmware found for this device');
|
|
21
22
|
}
|
|
22
23
|
if (btcOnly && !releaseByFirmware.url_bitcoinonly) {
|
|
23
24
|
throw new Error(`firmware version ${version} does not exist in btc only variant`);
|
|
24
25
|
}
|
|
25
|
-
if (!
|
|
26
|
+
if (!versionUtils.isEqual(releaseByFirmware.version, infoByBootloader.release.version)) {
|
|
26
27
|
throw new Error('version provided as param does not match firmware version found by features in bootloader');
|
|
27
28
|
}
|
|
28
29
|
const fwUrl = releaseByFirmware[btcOnly ? 'url_bitcoinonly' : 'url'];
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.stripFwHeaders = exports.shouldStripFwHeaders = void 0;
|
|
4
|
-
const
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const versionUtils = tslib_1.__importStar(require("@trezor/utils/lib/versionUtils"));
|
|
5
6
|
const shouldStripFwHeaders = (features) => {
|
|
6
7
|
if (features.major_version === 2)
|
|
7
8
|
return false;
|
|
8
|
-
return
|
|
9
|
+
return versionUtils.isNewerOrEqual([features.major_version, features.minor_version, features.patch_version], [1, 8, 0]);
|
|
9
10
|
};
|
|
10
11
|
exports.shouldStripFwHeaders = shouldStripFwHeaders;
|
|
11
12
|
const stripFwHeaders = (fw) => {
|
|
@@ -2,5 +2,7 @@ import { PostMessage } from '../../events';
|
|
|
2
2
|
import { PROTO } from '../../constants';
|
|
3
3
|
import type { Device } from '../../device/Device';
|
|
4
4
|
import type { TypedCall } from '../../device/DeviceCommands';
|
|
5
|
-
export declare const uploadFirmware: (typedCall: TypedCall, postMessage: PostMessage, device: Device, { payload }: PROTO.FirmwareUpload) => Promise<
|
|
5
|
+
export declare const uploadFirmware: (typedCall: TypedCall, postMessage: PostMessage, device: Device, { payload }: PROTO.FirmwareUpload) => Promise<{
|
|
6
|
+
message: string;
|
|
7
|
+
}>;
|
|
6
8
|
//# sourceMappingURL=uploadFirmware.d.ts.map
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.verifyAuthenticityProof = exports.getRandomChallenge = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const crypto = tslib_1.__importStar(require("crypto"));
|
|
6
|
-
const
|
|
6
|
+
const bufferUtils = tslib_1.__importStar(require("@trezor/utils/lib/bufferUtils"));
|
|
7
7
|
const x509certificate_1 = require("./x509certificate");
|
|
8
8
|
const verifySignature = async (rawKey, data, signature) => {
|
|
9
9
|
const signer = crypto.createVerify('sha256');
|
|
@@ -63,9 +63,9 @@ const verifyAuthenticityProof = async ({ certificates, signature, challenge, con
|
|
|
63
63
|
const isDeviceCertValid = await verifySignature(Buffer.from(caCert.tbsCertificate.subjectPublicKeyInfo.bits.bytes), deviceCert.tbsCertificate.asn1.raw, deviceCert.signatureValue.bits.bytes);
|
|
64
64
|
const challengePrefix = Buffer.from('AuthenticateDevice:');
|
|
65
65
|
const prefixedChallenge = Buffer.concat([
|
|
66
|
-
|
|
66
|
+
bufferUtils.getChunkSize(challengePrefix.length),
|
|
67
67
|
challengePrefix,
|
|
68
|
-
|
|
68
|
+
bufferUtils.getChunkSize(challenge.length),
|
|
69
69
|
challenge,
|
|
70
70
|
]);
|
|
71
71
|
const isSignatureValid = await verifySignature(Buffer.from(deviceCert.tbsCertificate.subjectPublicKeyInfo.bits.bytes), prefixedChallenge, (0, x509certificate_1.fixSignature)(Buffer.from(signature, 'hex')));
|
|
@@ -5,8 +5,9 @@ const AbstractMethod_1 = require("../core/AbstractMethod");
|
|
|
5
5
|
const constants_1 = require("../constants");
|
|
6
6
|
const events_1 = require("../events");
|
|
7
7
|
const firmware_1 = require("./firmware");
|
|
8
|
-
const paramsValidator_1 = require("./common/paramsValidator");
|
|
9
8
|
const firmwareInfo_1 = require("../data/firmwareInfo");
|
|
9
|
+
const schema_utils_1 = require("@trezor/schema-utils");
|
|
10
|
+
const firmwareUpdate_1 = require("../types/api/firmwareUpdate");
|
|
10
11
|
class FirmwareUpdate extends AbstractMethod_1.AbstractMethod {
|
|
11
12
|
init() {
|
|
12
13
|
this.useEmptyPassphrase = true;
|
|
@@ -16,14 +17,14 @@ class FirmwareUpdate extends AbstractMethod_1.AbstractMethod {
|
|
|
16
17
|
this.useDeviceState = false;
|
|
17
18
|
this.skipFirmwareCheck = true;
|
|
18
19
|
const { payload } = this;
|
|
19
|
-
(0,
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
(0, schema_utils_1.Assert)(firmwareUpdate_1.FirmwareUpdate, payload);
|
|
21
|
+
if (payload.binary) {
|
|
22
|
+
this.params = {
|
|
23
|
+
...this.params,
|
|
24
|
+
binary: payload.binary,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
27
28
|
this.params = {
|
|
28
29
|
version: payload.version,
|
|
29
30
|
btcOnly: payload.btcOnly,
|
|
@@ -31,12 +32,6 @@ class FirmwareUpdate extends AbstractMethod_1.AbstractMethod {
|
|
|
31
32
|
intermediaryVersion: payload.intermediaryVersion,
|
|
32
33
|
};
|
|
33
34
|
}
|
|
34
|
-
if ('binary' in payload) {
|
|
35
|
-
this.params = {
|
|
36
|
-
...this.params,
|
|
37
|
-
binary: payload.binary,
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
35
|
}
|
|
41
36
|
async confirmation() {
|
|
42
37
|
await this.getPopupPromise().promise;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AbstractMethod } from '../core/AbstractMethod';
|
|
2
|
-
import type
|
|
3
|
-
import
|
|
2
|
+
import { type CoinInfo } from '../types';
|
|
3
|
+
import { GetAccountDescriptorParams, GetAccountDescriptorResponse } from '../types/api/getAccountDescriptor';
|
|
4
4
|
type Request = GetAccountDescriptorParams & {
|
|
5
5
|
address_n: number[];
|
|
6
6
|
coinInfo: CoinInfo;
|
|
@@ -7,6 +7,9 @@ const accountUtils_1 = require("../utils/accountUtils");
|
|
|
7
7
|
const coinInfo_1 = require("../data/coinInfo");
|
|
8
8
|
const constants_1 = require("../constants");
|
|
9
9
|
const events_1 = require("../events");
|
|
10
|
+
const types_1 = require("../types");
|
|
11
|
+
const getAccountDescriptor_1 = require("../types/api/getAccountDescriptor");
|
|
12
|
+
const schema_utils_1 = require("@trezor/schema-utils");
|
|
10
13
|
class GetAccountDescriptor extends AbstractMethod_1.AbstractMethod {
|
|
11
14
|
constructor() {
|
|
12
15
|
super(...arguments);
|
|
@@ -20,14 +23,8 @@ class GetAccountDescriptor extends AbstractMethod_1.AbstractMethod {
|
|
|
20
23
|
const payload = !this.payload.bundle
|
|
21
24
|
? { ...this.payload, bundle: [this.payload] }
|
|
22
25
|
: this.payload;
|
|
23
|
-
(0,
|
|
26
|
+
(0, schema_utils_1.Assert)((0, types_1.Bundle)(getAccountDescriptor_1.GetAccountDescriptorParams), payload);
|
|
24
27
|
this.params = payload.bundle.map(batch => {
|
|
25
|
-
(0, paramsValidator_1.validateParams)(batch, [
|
|
26
|
-
{ name: 'coin', type: 'string', required: true },
|
|
27
|
-
{ name: 'path', type: 'string', required: true },
|
|
28
|
-
{ name: 'derivationType', type: 'number' },
|
|
29
|
-
{ name: 'suppressBackupWarning', type: 'boolean' },
|
|
30
|
-
]);
|
|
31
28
|
const coinInfo = (0, coinInfo_1.getCoinInfo)(batch.coin);
|
|
32
29
|
if (!coinInfo) {
|
|
33
30
|
throw constants_1.ERRORS.TypedError('Method_UnknownCoin');
|