@trezor/connect 9.1.5 → 9.1.7
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 +66 -0
- package/README.md +1 -1
- package/lib/api/{binanceGetAddress.d.ts → binance/api/binanceGetAddress.d.ts} +4 -4
- package/lib/api/{binanceGetAddress.js → binance/api/binanceGetAddress.js} +10 -7
- package/lib/api/{binanceGetPublicKey.d.ts → binance/api/binanceGetPublicKey.d.ts} +3 -3
- package/lib/api/{binanceGetPublicKey.js → binance/api/binanceGetPublicKey.js} +5 -5
- package/lib/api/{binanceSignTransaction.d.ts → binance/api/binanceSignTransaction.d.ts} +3 -2
- package/lib/api/{binanceSignTransaction.js → binance/api/binanceSignTransaction.js} +8 -6
- package/lib/api/binance/api/index.d.ts +4 -0
- package/lib/api/binance/api/index.js +13 -0
- package/lib/api/binance/binanceSignTx.d.ts +1 -1
- package/lib/api/binance/binanceSignTx.js +2 -1
- package/lib/api/bitcoin/TransactionComposer.d.ts +4 -4
- package/lib/api/bitcoin/TransactionComposer.js +4 -18
- package/lib/api/bitcoin/inputs.d.ts +2 -2
- package/lib/api/bitcoin/inputs.js +4 -5
- package/lib/api/bitcoin/outputs.d.ts +4 -4
- package/lib/api/bitcoin/outputs.js +14 -23
- package/lib/api/blockchainEstimateFee.d.ts +2 -2
- package/lib/api/cardano/api/cardanoComposeTransaction.d.ts +8 -0
- package/lib/api/cardano/api/cardanoComposeTransaction.js +69 -0
- package/lib/api/{cardanoGetAddress.d.ts → cardano/api/cardanoGetAddress.d.ts} +4 -4
- package/lib/api/{cardanoGetAddress.js → cardano/api/cardanoGetAddress.js} +11 -8
- package/lib/api/{cardanoGetNativeScriptHash.d.ts → cardano/api/cardanoGetNativeScriptHash.d.ts} +3 -3
- package/lib/api/{cardanoGetNativeScriptHash.js → cardano/api/cardanoGetNativeScriptHash.js} +5 -5
- package/lib/api/{cardanoGetPublicKey.d.ts → cardano/api/cardanoGetPublicKey.d.ts} +3 -3
- package/lib/api/{cardanoGetPublicKey.js → cardano/api/cardanoGetPublicKey.js} +6 -6
- package/lib/api/{cardanoSignTransaction.d.ts → cardano/api/cardanoSignTransaction.d.ts} +19 -8
- package/lib/api/{cardanoSignTransaction.js → cardano/api/cardanoSignTransaction.js} +33 -13
- package/lib/api/cardano/api/index.d.ts +6 -0
- package/lib/api/cardano/api/index.js +17 -0
- package/lib/api/cardano/cardanoUtils.d.ts +6 -0
- package/lib/api/cardano/cardanoUtils.js +64 -1
- package/lib/api/common/paramsValidator.js +5 -3
- package/lib/api/composeTransaction.d.ts +5 -5
- package/lib/api/composeTransaction.js +14 -19
- package/lib/api/eos/api/eosGetPublicKey.d.ts +11 -0
- package/lib/api/{eosGetPublicKey.js → eos/api/eosGetPublicKey.js} +7 -5
- package/lib/api/{eosSignTransaction.d.ts → eos/api/eosSignTransaction.d.ts} +3 -2
- package/lib/api/{eosSignTransaction.js → eos/api/eosSignTransaction.js} +8 -6
- package/lib/api/eos/api/index.d.ts +3 -0
- package/lib/api/eos/api/index.js +11 -0
- package/lib/api/eos/eosSignTx.d.ts +1 -1
- package/lib/api/eos/eosSignTx.js +2 -1
- package/lib/api/{ethereumGetAddress.d.ts → ethereum/api/ethereumGetAddress.d.ts} +5 -5
- package/lib/api/{ethereumGetAddress.js → ethereum/api/ethereumGetAddress.js} +13 -10
- package/lib/api/ethereum/api/ethereumGetPublicKey.d.ts +16 -0
- package/lib/api/{ethereumGetPublicKey.js → ethereum/api/ethereumGetPublicKey.js} +6 -6
- package/lib/api/{ethereumSignMessage.d.ts → ethereum/api/ethereumSignMessage.d.ts} +3 -3
- package/lib/api/{ethereumSignMessage.js → ethereum/api/ethereumSignMessage.js} +7 -7
- package/lib/api/{ethereumSignTransaction.d.ts → ethereum/api/ethereumSignTransaction.d.ts} +12 -9
- package/lib/api/{ethereumSignTransaction.js → ethereum/api/ethereumSignTransaction.js} +38 -43
- package/lib/api/{ethereumSignTypedData.d.ts → ethereum/api/ethereumSignTypedData.d.ts} +3 -3
- package/lib/api/{ethereumSignTypedData.js → ethereum/api/ethereumSignTypedData.js} +10 -10
- package/lib/api/{ethereumVerifyMessage.d.ts → ethereum/api/ethereumVerifyMessage.d.ts} +2 -2
- package/lib/api/{ethereumVerifyMessage.js → ethereum/api/ethereumVerifyMessage.js} +3 -3
- package/lib/api/ethereum/api/index.d.ts +7 -0
- package/lib/api/ethereum/api/index.js +19 -0
- package/lib/api/ethereum/ethereumSignTx.d.ts +4 -2
- package/lib/api/ethereum/ethereumSignTx.js +19 -3
- package/lib/api/firmware/verifyAuthenticityProof.js +1 -1
- package/lib/api/firmware/x509certificate.d.ts +1 -0
- package/lib/api/firmware/x509certificate.js +34 -2
- package/lib/api/getAccountDescriptor.d.ts +20 -0
- package/lib/api/getAccountDescriptor.js +162 -0
- package/lib/api/getAccountInfo.d.ts +2 -0
- package/lib/api/getAddress.d.ts +1 -1
- package/lib/api/getAddress.js +4 -1
- package/lib/api/index.d.ts +1 -24
- package/lib/api/index.js +3 -50
- package/lib/api/nem/api/index.d.ts +3 -0
- package/lib/api/nem/api/index.js +11 -0
- package/lib/api/{nemGetAddress.d.ts → nem/api/nemGetAddress.d.ts} +4 -4
- package/lib/api/{nemGetAddress.js → nem/api/nemGetAddress.js} +10 -7
- package/lib/api/{nemSignTransaction.d.ts → nem/api/nemSignTransaction.d.ts} +2 -2
- package/lib/api/{nemSignTransaction.js → nem/api/nemSignTransaction.js} +7 -6
- package/lib/api/nem/nemSignTx.d.ts +1 -1
- package/lib/api/nem/nemSignTx.js +2 -1
- package/lib/api/ripple/api/index.d.ts +3 -0
- package/lib/api/ripple/api/index.js +11 -0
- package/lib/api/{rippleGetAddress.d.ts → ripple/api/rippleGetAddress.d.ts} +4 -4
- package/lib/api/{rippleGetAddress.js → ripple/api/rippleGetAddress.js} +10 -7
- package/lib/api/{rippleSignTransaction.d.ts → ripple/api/rippleSignTransaction.d.ts} +2 -2
- package/lib/api/{rippleSignTransaction.js → ripple/api/rippleSignTransaction.js} +7 -5
- package/lib/api/signTransaction.js +2 -0
- package/lib/api/solana/additionalInfo.d.ts +10 -0
- package/lib/api/solana/additionalInfo.js +33 -0
- package/lib/api/solana/api/index.d.ts +4 -0
- package/lib/api/solana/api/index.js +13 -0
- package/lib/api/solana/api/solanaGetAddress.d.ts +23 -0
- package/lib/api/solana/api/solanaGetAddress.js +133 -0
- package/lib/api/solana/api/solanaGetPublicKey.d.ts +12 -0
- package/lib/api/solana/api/solanaGetPublicKey.js +83 -0
- package/lib/api/solana/api/solanaSignTransaction.d.ts +10 -0
- package/lib/api/solana/api/solanaSignTransaction.js +34 -0
- package/lib/api/stellar/api/index.d.ts +3 -0
- package/lib/api/stellar/api/index.js +11 -0
- package/lib/api/{stellarGetAddress.d.ts → stellar/api/stellarGetAddress.d.ts} +4 -4
- package/lib/api/{stellarGetAddress.js → stellar/api/stellarGetAddress.js} +10 -7
- package/lib/api/{stellarSignTransaction.d.ts → stellar/api/stellarSignTransaction.d.ts} +2 -2
- package/lib/api/{stellarSignTransaction.js → stellar/api/stellarSignTransaction.js} +6 -6
- package/lib/api/tezos/api/index.d.ts +4 -0
- package/lib/api/tezos/api/index.js +13 -0
- package/lib/api/{tezosGetAddress.d.ts → tezos/api/tezosGetAddress.d.ts} +4 -4
- package/lib/api/{tezosGetAddress.js → tezos/api/tezosGetAddress.js} +10 -7
- package/lib/api/{tezosGetPublicKey.d.ts → tezos/api/tezosGetPublicKey.d.ts} +3 -3
- package/lib/api/{tezosGetPublicKey.js → tezos/api/tezosGetPublicKey.js} +7 -5
- package/lib/api/{tezosSignTransaction.d.ts → tezos/api/tezosSignTransaction.d.ts} +2 -2
- package/lib/api/{tezosSignTransaction.js → tezos/api/tezosSignTransaction.js} +5 -5
- package/lib/api/tezos/tezosSignTx.d.ts +1 -1
- package/lib/api/tezos/tezosSignTx.js +2 -1
- package/lib/backend/Blockchain.js +3 -0
- package/lib/constants/cardano.js +2 -2
- package/lib/constants/nem.js +3 -3
- package/lib/constants/network.d.ts +3 -0
- package/lib/constants/network.js +13 -1
- package/lib/core/AbstractMethod.js +3 -0
- package/lib/core/index.d.ts +3 -1
- package/lib/core/index.js +17 -4
- package/lib/core/method.d.ts +2 -2
- package/lib/core/method.js +8 -2
- package/lib/core/method.native.d.ts +5 -0
- package/lib/core/method.native.js +34 -0
- package/lib/data/DataManager.d.ts +22 -0
- package/lib/data/config.d.ts +22 -0
- package/lib/data/config.js +12 -1
- package/lib/data/connectSettings.js +4 -0
- package/lib/data/defaultFeeLevels.js +9 -0
- package/lib/data/deviceAuthenticityConfig.js +4 -1
- package/lib/data/firmwareInfo.d.ts +1 -1
- package/lib/data/firmwareInfo.js +4 -1
- package/lib/data/version.d.ts +1 -1
- package/lib/data/version.js +1 -1
- package/lib/device/Device.d.ts +3 -1
- package/lib/device/Device.js +23 -4
- package/lib/device/DeviceCommands.d.ts +2 -2
- package/lib/device/DeviceCommands.js +19 -3
- package/lib/device/DeviceList.js +4 -1
- package/lib/events/popup.d.ts +19 -3
- package/lib/events/popup.js +3 -0
- package/lib/events/ui-request.d.ts +1 -1
- package/lib/factory.js +5 -0
- package/lib/types/api/binance/index.d.ts +1 -0
- package/lib/types/api/bitcoin/index.d.ts +2 -0
- package/lib/types/api/cardano/index.d.ts +2 -0
- package/lib/types/api/cardanoComposeTransaction.d.ts +44 -0
- package/lib/types/api/cardanoComposeTransaction.js +3 -0
- package/lib/types/api/cardanoSignTransaction.d.ts +9 -0
- package/lib/types/api/composeTransaction.d.ts +28 -54
- package/lib/types/api/eos/index.d.ts +1 -0
- package/lib/types/api/ethereum/index.d.ts +2 -0
- package/lib/types/api/getAccountDescriptor.d.ts +16 -0
- package/lib/types/api/getAccountDescriptor.js +3 -0
- package/lib/types/api/index.d.ts +10 -0
- package/lib/types/api/nem/index.d.ts +1 -0
- package/lib/types/api/ripple/index.d.ts +1 -0
- package/lib/types/api/solana/index.d.ts +22 -0
- package/lib/types/api/solana/index.js +3 -0
- package/lib/types/api/solanaGetAddress.d.ts +4 -0
- package/lib/types/api/solanaGetAddress.js +3 -0
- package/lib/types/api/solanaGetPublicKey.d.ts +5 -0
- package/lib/types/api/solanaGetPublicKey.js +3 -0
- package/lib/types/api/solanaSignTransaction.d.ts +4 -0
- package/lib/types/api/solanaSignTransaction.js +3 -0
- package/lib/types/api/tezos/index.d.ts +1 -0
- package/lib/types/coinInfo.d.ts +5 -16
- package/lib/types/device.d.ts +1 -1
- package/lib/types/device.js +1 -1
- package/lib/types/index.d.ts +3 -1
- package/lib/types/index.js +1 -0
- package/lib/types/params.d.ts +3 -0
- package/lib/types/settings.d.ts +1 -0
- package/lib/utils/debug.d.ts +6 -3
- package/lib/utils/debug.js +13 -7
- package/lib/utils/deviceFeaturesUtils.js +8 -5
- package/lib/utils/formatUtils.d.ts +2 -0
- package/lib/utils/formatUtils.js +19 -1
- package/lib/workers/workers-browser.d.ts +2 -1
- package/lib/workers/workers-browser.js +3 -1
- package/lib/workers/workers-react-native.d.ts +2 -1
- package/lib/workers/workers-react-native.js +3 -1
- package/lib/workers/workers.d.ts +8 -5
- package/lib/workers/workers.js +34 -10
- package/package.json +22 -19
- package/lib/api/eosGetPublicKey.d.ts +0 -11
- package/lib/api/ethereumGetPublicKey.d.ts +0 -16
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { AbstractMethod } from '
|
|
2
|
-
import { PROTO } from '
|
|
3
|
-
import type { EthereumNetworkInfo } from '
|
|
1
|
+
import { AbstractMethod } from '../../../core/AbstractMethod';
|
|
2
|
+
import { PROTO } from '../../../constants';
|
|
3
|
+
import type { EthereumNetworkInfo } from '../../../types';
|
|
4
4
|
type Params = PROTO.EthereumGetAddress & {
|
|
5
5
|
address?: string;
|
|
6
6
|
network?: EthereumNetworkInfo;
|
|
@@ -20,12 +20,12 @@ export default class EthereumGetAddress extends AbstractMethod<'ethereumGetAddre
|
|
|
20
20
|
} | undefined;
|
|
21
21
|
confirmation(): Promise<boolean>;
|
|
22
22
|
noBackupConfirmation(): Promise<boolean>;
|
|
23
|
-
_call({ address_n, show_display, encoded_network }: Params): Promise<{
|
|
23
|
+
_call({ address_n, show_display, encoded_network, chunkify }: Params): Promise<{
|
|
24
24
|
path: number[];
|
|
25
25
|
serializedPath: string;
|
|
26
26
|
address: string;
|
|
27
27
|
}>;
|
|
28
|
-
run(): Promise<import("
|
|
28
|
+
run(): Promise<import("../../../types").Address | import("../../../types").Address[]>;
|
|
29
29
|
}
|
|
30
30
|
export {};
|
|
31
31
|
//# sourceMappingURL=ethereumGetAddress.d.ts.map
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const AbstractMethod_1 = require("
|
|
4
|
-
const paramsValidator_1 = require("
|
|
5
|
-
const pathUtils_1 = require("
|
|
6
|
-
const ethereumUtils_1 = require("
|
|
7
|
-
const coinInfo_1 = require("
|
|
8
|
-
const formatUtils_1 = require("
|
|
9
|
-
const constants_1 = require("
|
|
10
|
-
const events_1 = require("
|
|
11
|
-
const ethereumDefinitions_1 = require("
|
|
3
|
+
const AbstractMethod_1 = require("../../../core/AbstractMethod");
|
|
4
|
+
const paramsValidator_1 = require("../../common/paramsValidator");
|
|
5
|
+
const pathUtils_1 = require("../../../utils/pathUtils");
|
|
6
|
+
const ethereumUtils_1 = require("../../../utils/ethereumUtils");
|
|
7
|
+
const coinInfo_1 = require("../../../data/coinInfo");
|
|
8
|
+
const formatUtils_1 = require("../../../utils/formatUtils");
|
|
9
|
+
const constants_1 = require("../../../constants");
|
|
10
|
+
const events_1 = require("../../../events");
|
|
11
|
+
const ethereumDefinitions_1 = require("../ethereumDefinitions");
|
|
12
12
|
class EthereumGetAddress extends AbstractMethod_1.AbstractMethod {
|
|
13
13
|
constructor() {
|
|
14
14
|
super(...arguments);
|
|
@@ -29,6 +29,7 @@ class EthereumGetAddress extends AbstractMethod_1.AbstractMethod {
|
|
|
29
29
|
{ name: 'path', required: true },
|
|
30
30
|
{ name: 'address', type: 'string' },
|
|
31
31
|
{ name: 'showOnTrezor', type: 'boolean' },
|
|
32
|
+
{ name: 'chunkify', type: 'boolean' },
|
|
32
33
|
]);
|
|
33
34
|
const path = (0, pathUtils_1.validatePath)(batch.path, 3);
|
|
34
35
|
const network = (0, coinInfo_1.getEthereumNetwork)(path);
|
|
@@ -38,6 +39,7 @@ class EthereumGetAddress extends AbstractMethod_1.AbstractMethod {
|
|
|
38
39
|
show_display: typeof batch.showOnTrezor === 'boolean' ? batch.showOnTrezor : true,
|
|
39
40
|
address: batch.address,
|
|
40
41
|
network,
|
|
42
|
+
chunkify: typeof batch.chunkify === 'boolean' ? batch.chunkify : false,
|
|
41
43
|
};
|
|
42
44
|
});
|
|
43
45
|
const useEventListener = payload.useEventListener &&
|
|
@@ -106,12 +108,13 @@ class EthereumGetAddress extends AbstractMethod_1.AbstractMethod {
|
|
|
106
108
|
const uiResp = await uiPromise.promise;
|
|
107
109
|
return uiResp.payload;
|
|
108
110
|
}
|
|
109
|
-
_call({ address_n, show_display, encoded_network }) {
|
|
111
|
+
_call({ address_n, show_display, encoded_network, chunkify }) {
|
|
110
112
|
const cmd = this.device.getCommands();
|
|
111
113
|
return cmd.ethereumGetAddress({
|
|
112
114
|
address_n,
|
|
113
115
|
show_display,
|
|
114
116
|
encoded_network,
|
|
117
|
+
chunkify,
|
|
115
118
|
});
|
|
116
119
|
}
|
|
117
120
|
async run() {
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { AbstractMethod } from '../../../core/AbstractMethod';
|
|
2
|
+
import type { PROTO } from '../../../constants';
|
|
3
|
+
import type { EthereumNetworkInfo } from '../../../types';
|
|
4
|
+
type Params = PROTO.EthereumGetPublicKey & {
|
|
5
|
+
network?: EthereumNetworkInfo;
|
|
6
|
+
};
|
|
7
|
+
export default class EthereumGetPublicKey extends AbstractMethod<'ethereumGetPublicKey', Params[]> {
|
|
8
|
+
hasBundle?: boolean;
|
|
9
|
+
confirmed?: boolean;
|
|
10
|
+
init(): void;
|
|
11
|
+
get info(): string;
|
|
12
|
+
confirmation(): Promise<boolean>;
|
|
13
|
+
run(): Promise<import("../../../types/api/getPublicKey").HDNodeResponse | import("../../../types/api/getPublicKey").HDNodeResponse[]>;
|
|
14
|
+
}
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=ethereumGetPublicKey.d.ts.map
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const AbstractMethod_1 = require("
|
|
4
|
-
const paramsValidator_1 = require("
|
|
5
|
-
const pathUtils_1 = require("
|
|
6
|
-
const ethereumUtils_1 = require("
|
|
7
|
-
const coinInfo_1 = require("
|
|
8
|
-
const events_1 = require("
|
|
3
|
+
const AbstractMethod_1 = require("../../../core/AbstractMethod");
|
|
4
|
+
const paramsValidator_1 = require("../../common/paramsValidator");
|
|
5
|
+
const pathUtils_1 = require("../../../utils/pathUtils");
|
|
6
|
+
const ethereumUtils_1 = require("../../../utils/ethereumUtils");
|
|
7
|
+
const coinInfo_1 = require("../../../data/coinInfo");
|
|
8
|
+
const events_1 = require("../../../events");
|
|
9
9
|
class EthereumGetPublicKey extends AbstractMethod_1.AbstractMethod {
|
|
10
10
|
init() {
|
|
11
11
|
this.requiredPermissions = ['read'];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { AbstractMethod } from '
|
|
2
|
-
import type { PROTO } from '
|
|
3
|
-
import type { EthereumNetworkInfo } from '
|
|
1
|
+
import { AbstractMethod } from '../../../core/AbstractMethod';
|
|
2
|
+
import type { PROTO } from '../../../constants';
|
|
3
|
+
import type { EthereumNetworkInfo } from '../../../types';
|
|
4
4
|
import type { EthereumDefinitions } from '@trezor/protobuf/lib/messages';
|
|
5
5
|
type Params = PROTO.EthereumSignMessage & {
|
|
6
6
|
network?: EthereumNetworkInfo;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const AbstractMethod_1 = require("
|
|
4
|
-
const paramsValidator_1 = require("
|
|
5
|
-
const pathUtils_1 = require("
|
|
6
|
-
const coinInfo_1 = require("
|
|
7
|
-
const ethereumUtils_1 = require("
|
|
8
|
-
const formatUtils_1 = require("
|
|
9
|
-
const ethereumDefinitions_1 = require("
|
|
3
|
+
const AbstractMethod_1 = require("../../../core/AbstractMethod");
|
|
4
|
+
const paramsValidator_1 = require("../../common/paramsValidator");
|
|
5
|
+
const pathUtils_1 = require("../../../utils/pathUtils");
|
|
6
|
+
const coinInfo_1 = require("../../../data/coinInfo");
|
|
7
|
+
const ethereumUtils_1 = require("../../../utils/ethereumUtils");
|
|
8
|
+
const formatUtils_1 = require("../../../utils/formatUtils");
|
|
9
|
+
const ethereumDefinitions_1 = require("../ethereumDefinitions");
|
|
10
10
|
class EthereumSignMessage extends AbstractMethod_1.AbstractMethod {
|
|
11
11
|
init() {
|
|
12
12
|
this.requiredPermissions = ['read', 'write'];
|
|
@@ -1,22 +1,25 @@
|
|
|
1
|
-
import { AbstractMethod } from '
|
|
2
|
-
import type { EthereumTransaction, EthereumTransactionEIP1559 } from '
|
|
3
|
-
import type { EthereumNetworkInfo } from '
|
|
1
|
+
import { AbstractMethod } from '../../../core/AbstractMethod';
|
|
2
|
+
import type { EthereumTransaction, EthereumTransactionEIP1559 } from '../../../types/api/ethereum';
|
|
3
|
+
import type { EthereumNetworkInfo } from '../../../types';
|
|
4
4
|
import type { EthereumDefinitions } from '@trezor/protobuf/lib/messages';
|
|
5
5
|
type Params = {
|
|
6
6
|
path: number[];
|
|
7
|
-
tx: ({
|
|
8
|
-
type: 'legacy';
|
|
9
|
-
} & EthereumTransaction) | ({
|
|
10
|
-
type: 'eip1559';
|
|
11
|
-
} & EthereumTransactionEIP1559);
|
|
12
7
|
network?: EthereumNetworkInfo;
|
|
13
8
|
definitions?: EthereumDefinitions;
|
|
14
|
-
|
|
9
|
+
chunkify: boolean;
|
|
10
|
+
} & ({
|
|
11
|
+
type: 'legacy';
|
|
12
|
+
tx: EthereumTransaction;
|
|
13
|
+
} | {
|
|
14
|
+
type: 'eip1559';
|
|
15
|
+
tx: EthereumTransactionEIP1559;
|
|
16
|
+
});
|
|
15
17
|
export default class EthereumSignTransaction extends AbstractMethod<'ethereumSignTransaction', Params> {
|
|
16
18
|
init(): void;
|
|
17
19
|
initAsync(): Promise<void>;
|
|
18
20
|
get info(): string;
|
|
19
21
|
run(): Promise<{
|
|
22
|
+
serializedTx: string;
|
|
20
23
|
v: string;
|
|
21
24
|
r: string;
|
|
22
25
|
s: string;
|
|
@@ -1,30 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
-
const AbstractMethod_1 = require("
|
|
5
|
-
const paramsValidator_1 = require("
|
|
6
|
-
const pathUtils_1 = require("
|
|
7
|
-
const coinInfo_1 = require("
|
|
8
|
-
const ethereumUtils_1 = require("
|
|
9
|
-
const formatUtils_1 = require("
|
|
10
|
-
const helper = tslib_1.__importStar(require("
|
|
11
|
-
const ethereumDefinitions_1 = require("
|
|
12
|
-
const strip = value => {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
stripped = `0${stripped}`;
|
|
17
|
-
}
|
|
18
|
-
return stripped;
|
|
19
|
-
}
|
|
20
|
-
if (Array.isArray(value)) {
|
|
21
|
-
return value.map(strip);
|
|
22
|
-
}
|
|
23
|
-
if (typeof value === 'object') {
|
|
24
|
-
return Object.entries(value).reduce((acc, [k, v]) => ({ ...acc, [k]: strip(v) }), {});
|
|
4
|
+
const AbstractMethod_1 = require("../../../core/AbstractMethod");
|
|
5
|
+
const paramsValidator_1 = require("../../common/paramsValidator");
|
|
6
|
+
const pathUtils_1 = require("../../../utils/pathUtils");
|
|
7
|
+
const coinInfo_1 = require("../../../data/coinInfo");
|
|
8
|
+
const ethereumUtils_1 = require("../../../utils/ethereumUtils");
|
|
9
|
+
const formatUtils_1 = require("../../../utils/formatUtils");
|
|
10
|
+
const helper = tslib_1.__importStar(require("../ethereumSignTx"));
|
|
11
|
+
const ethereumDefinitions_1 = require("../ethereumDefinitions");
|
|
12
|
+
const strip = (0, formatUtils_1.deepTransform)(value => {
|
|
13
|
+
let stripped = (0, formatUtils_1.stripHexPrefix)(value);
|
|
14
|
+
if (stripped.length % 2 !== 0) {
|
|
15
|
+
stripped = `0${stripped}`;
|
|
25
16
|
}
|
|
26
|
-
return
|
|
27
|
-
};
|
|
17
|
+
return stripped;
|
|
18
|
+
});
|
|
28
19
|
class EthereumSignTransaction extends AbstractMethod_1.AbstractMethod {
|
|
29
20
|
init() {
|
|
30
21
|
this.requiredPermissions = ['read', 'write'];
|
|
@@ -32,14 +23,16 @@ class EthereumSignTransaction extends AbstractMethod_1.AbstractMethod {
|
|
|
32
23
|
(0, paramsValidator_1.validateParams)(payload, [
|
|
33
24
|
{ name: 'path', required: true },
|
|
34
25
|
{ name: 'transaction', required: true },
|
|
26
|
+
{ name: 'chunkify', type: 'boolean' },
|
|
35
27
|
]);
|
|
36
28
|
const path = (0, pathUtils_1.validatePath)(payload.path, 3);
|
|
37
29
|
const network = (0, coinInfo_1.getEthereumNetwork)(path);
|
|
30
|
+
const chunkify = typeof payload.chunkify === 'boolean' ? payload.chunkify : false;
|
|
38
31
|
const tx = payload.transaction;
|
|
39
|
-
const isEIP1559 = tx.maxFeePerGas && tx.maxPriorityFeePerGas;
|
|
32
|
+
const isEIP1559 = typeof tx.maxFeePerGas === 'string' && typeof tx.maxPriorityFeePerGas === 'string';
|
|
40
33
|
this.firmwareRange = (0, paramsValidator_1.getFirmwareRange)(isEIP1559 ? 'eip1559' : this.name, network, this.firmwareRange);
|
|
41
|
-
|
|
42
|
-
|
|
34
|
+
if (isEIP1559) {
|
|
35
|
+
(0, paramsValidator_1.validateParams)(tx, [
|
|
43
36
|
{ name: 'to', type: 'string', required: true },
|
|
44
37
|
{ name: 'value', type: 'string', required: true },
|
|
45
38
|
{ name: 'gasLimit', type: 'string', required: true },
|
|
@@ -48,8 +41,11 @@ class EthereumSignTransaction extends AbstractMethod_1.AbstractMethod {
|
|
|
48
41
|
{ name: 'nonce', type: 'string', required: true },
|
|
49
42
|
{ name: 'data', type: 'string' },
|
|
50
43
|
{ name: 'chainId', type: 'number', required: true },
|
|
51
|
-
]
|
|
52
|
-
:
|
|
44
|
+
]);
|
|
45
|
+
this.params = { path, network, type: 'eip1559', tx: strip(tx), chunkify };
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
(0, paramsValidator_1.validateParams)(tx, [
|
|
53
49
|
{ name: 'to', type: 'string', required: true },
|
|
54
50
|
{ name: 'value', type: 'string', required: true },
|
|
55
51
|
{ name: 'gasLimit', type: 'string', required: true },
|
|
@@ -58,19 +54,12 @@ class EthereumSignTransaction extends AbstractMethod_1.AbstractMethod {
|
|
|
58
54
|
{ name: 'data', type: 'string' },
|
|
59
55
|
{ name: 'chainId', type: 'number' },
|
|
60
56
|
{ name: 'txType', type: 'number' },
|
|
61
|
-
];
|
|
62
|
-
|
|
57
|
+
]);
|
|
58
|
+
this.params = { path, network, type: 'legacy', tx: strip(tx), chunkify };
|
|
59
|
+
}
|
|
63
60
|
if (typeof tx.chainId !== 'number') {
|
|
64
61
|
console.warn('TrezorConnect.ethereumSignTransaction: Missing chainId parameter!');
|
|
65
62
|
}
|
|
66
|
-
this.params = {
|
|
67
|
-
path,
|
|
68
|
-
tx: {
|
|
69
|
-
type: isEIP1559 ? 'eip1559' : 'legacy',
|
|
70
|
-
...strip(tx),
|
|
71
|
-
},
|
|
72
|
-
network,
|
|
73
|
-
};
|
|
74
63
|
}
|
|
75
64
|
async initAsync() {
|
|
76
65
|
if (this.params.tx.chainId === 1 && !this.params.tx.data) {
|
|
@@ -91,11 +80,17 @@ class EthereumSignTransaction extends AbstractMethod_1.AbstractMethod {
|
|
|
91
80
|
get info() {
|
|
92
81
|
return (0, ethereumUtils_1.getNetworkLabel)('Sign #NETWORK transaction', this.params.network);
|
|
93
82
|
}
|
|
94
|
-
run() {
|
|
95
|
-
const { tx, definitions } = this.params;
|
|
96
|
-
|
|
97
|
-
? helper.ethereumSignTxEIP1559(this.device.getCommands().typedCall.bind(this.device.getCommands()), this.params.path, tx.to, tx.value, tx.gasLimit, tx.maxFeePerGas, tx.maxPriorityFeePerGas, tx.nonce, tx.chainId, tx.data, tx.accessList, definitions)
|
|
98
|
-
: helper.ethereumSignTx(this.device.getCommands().typedCall.bind(this.device.getCommands()), this.params.path, tx.to, tx.value, tx.gasLimit, tx.gasPrice, tx.nonce, tx.chainId, tx.data, tx.txType, definitions);
|
|
83
|
+
async run() {
|
|
84
|
+
const { type, tx, definitions, chunkify } = this.params;
|
|
85
|
+
const signature = type === 'eip1559'
|
|
86
|
+
? await helper.ethereumSignTxEIP1559(this.device.getCommands().typedCall.bind(this.device.getCommands()), this.params.path, tx.to, tx.value, tx.gasLimit, tx.maxFeePerGas, tx.maxPriorityFeePerGas, tx.nonce, tx.chainId, chunkify, tx.data, tx.accessList, definitions)
|
|
87
|
+
: await helper.ethereumSignTx(this.device.getCommands().typedCall.bind(this.device.getCommands()), this.params.path, tx.to, tx.value, tx.gasLimit, tx.gasPrice, tx.nonce, tx.chainId, chunkify, tx.data, tx.txType, definitions);
|
|
88
|
+
const serializedTx = helper.serializeEthereumTx({
|
|
89
|
+
...tx,
|
|
90
|
+
...signature,
|
|
91
|
+
type: type === 'legacy' ? 0 : 2,
|
|
92
|
+
}, tx.chainId);
|
|
93
|
+
return { ...signature, serializedTx };
|
|
99
94
|
}
|
|
100
95
|
}
|
|
101
96
|
exports.default = EthereumSignTransaction;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { AbstractMethod } from '
|
|
2
|
-
import type { EthereumSignTypedDataTypes, EthereumSignTypedData as EthereumSignTypedDataParams, EthereumSignTypedHash as EthereumSignTypedHashParams } from '
|
|
3
|
-
import type { EthereumNetworkInfo } from '
|
|
1
|
+
import { AbstractMethod } from '../../../core/AbstractMethod';
|
|
2
|
+
import type { EthereumSignTypedDataTypes, EthereumSignTypedData as EthereumSignTypedDataParams, EthereumSignTypedHash as EthereumSignTypedHashParams } from '../../../types/api/ethereum';
|
|
3
|
+
import type { EthereumNetworkInfo } from '../../../types';
|
|
4
4
|
import type { EthereumDefinitions } from '@trezor/protobuf/lib/messages';
|
|
5
5
|
type Params = (Omit<EthereumSignTypedDataParams<EthereumSignTypedDataTypes>, 'path'> | Omit<EthereumSignTypedHashParams<EthereumSignTypedDataTypes>, 'path'>) & {
|
|
6
6
|
address_n: number[];
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const AbstractMethod_1 = require("
|
|
4
|
-
const paramsValidator_1 = require("
|
|
5
|
-
const pathUtils_1 = require("
|
|
6
|
-
const coinInfo_1 = require("
|
|
7
|
-
const ethereumUtils_1 = require("
|
|
8
|
-
const constants_1 = require("
|
|
9
|
-
const ethereumSignTypedData_1 = require("
|
|
10
|
-
const formatUtils_1 = require("
|
|
11
|
-
const ethereumDefinitions_1 = require("
|
|
12
|
-
const types_1 = require("
|
|
3
|
+
const AbstractMethod_1 = require("../../../core/AbstractMethod");
|
|
4
|
+
const paramsValidator_1 = require("../../common/paramsValidator");
|
|
5
|
+
const pathUtils_1 = require("../../../utils/pathUtils");
|
|
6
|
+
const coinInfo_1 = require("../../../data/coinInfo");
|
|
7
|
+
const ethereumUtils_1 = require("../../../utils/ethereumUtils");
|
|
8
|
+
const constants_1 = require("../../../constants");
|
|
9
|
+
const ethereumSignTypedData_1 = require("../ethereumSignTypedData");
|
|
10
|
+
const formatUtils_1 = require("../../../utils/formatUtils");
|
|
11
|
+
const ethereumDefinitions_1 = require("../ethereumDefinitions");
|
|
12
|
+
const types_1 = require("../../../types");
|
|
13
13
|
class EthereumSignTypedData extends AbstractMethod_1.AbstractMethod {
|
|
14
14
|
init() {
|
|
15
15
|
this.requiredPermissions = ['read', 'write'];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AbstractMethod } from '
|
|
2
|
-
import type { PROTO } from '
|
|
1
|
+
import { AbstractMethod } from '../../../core/AbstractMethod';
|
|
2
|
+
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;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const AbstractMethod_1 = require("
|
|
4
|
-
const paramsValidator_1 = require("
|
|
5
|
-
const formatUtils_1 = require("
|
|
3
|
+
const AbstractMethod_1 = require("../../../core/AbstractMethod");
|
|
4
|
+
const paramsValidator_1 = require("../../common/paramsValidator");
|
|
5
|
+
const formatUtils_1 = require("../../../utils/formatUtils");
|
|
6
6
|
class EthereumVerifyMessage extends AbstractMethod_1.AbstractMethod {
|
|
7
7
|
init() {
|
|
8
8
|
this.requiredPermissions = ['read', 'write'];
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { default as ethereumGetAddress } from './ethereumGetAddress';
|
|
2
|
+
export { default as ethereumGetPublicKey } from './ethereumGetPublicKey';
|
|
3
|
+
export { default as ethereumSignMessage } from './ethereumSignMessage';
|
|
4
|
+
export { default as ethereumSignTransaction } from './ethereumSignTransaction';
|
|
5
|
+
export { default as ethereumSignTypedData } from './ethereumSignTypedData';
|
|
6
|
+
export { default as ethereumVerifyMessage } from './ethereumVerifyMessage';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ethereumVerifyMessage = exports.ethereumSignTypedData = exports.ethereumSignTransaction = exports.ethereumSignMessage = exports.ethereumGetPublicKey = exports.ethereumGetAddress = void 0;
|
|
7
|
+
var ethereumGetAddress_1 = require("./ethereumGetAddress");
|
|
8
|
+
Object.defineProperty(exports, "ethereumGetAddress", { enumerable: true, get: function () { return __importDefault(ethereumGetAddress_1).default; } });
|
|
9
|
+
var ethereumGetPublicKey_1 = require("./ethereumGetPublicKey");
|
|
10
|
+
Object.defineProperty(exports, "ethereumGetPublicKey", { enumerable: true, get: function () { return __importDefault(ethereumGetPublicKey_1).default; } });
|
|
11
|
+
var ethereumSignMessage_1 = require("./ethereumSignMessage");
|
|
12
|
+
Object.defineProperty(exports, "ethereumSignMessage", { enumerable: true, get: function () { return __importDefault(ethereumSignMessage_1).default; } });
|
|
13
|
+
var ethereumSignTransaction_1 = require("./ethereumSignTransaction");
|
|
14
|
+
Object.defineProperty(exports, "ethereumSignTransaction", { enumerable: true, get: function () { return __importDefault(ethereumSignTransaction_1).default; } });
|
|
15
|
+
var ethereumSignTypedData_1 = require("./ethereumSignTypedData");
|
|
16
|
+
Object.defineProperty(exports, "ethereumSignTypedData", { enumerable: true, get: function () { return __importDefault(ethereumSignTypedData_1).default; } });
|
|
17
|
+
var ethereumVerifyMessage_1 = require("./ethereumVerifyMessage");
|
|
18
|
+
Object.defineProperty(exports, "ethereumVerifyMessage", { enumerable: true, get: function () { return __importDefault(ethereumVerifyMessage_1).default; } });
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
+
import { FeeMarketEIP1559TxData, LegacyTxData } from '@ethereumjs/tx';
|
|
1
2
|
import { EthereumDefinitions } from '@trezor/protobuf/lib/messages';
|
|
2
3
|
import type { TypedCall } from '../../device/DeviceCommands';
|
|
3
4
|
import type { EthereumAccessList } from '../../types/api/ethereum';
|
|
4
|
-
export declare const
|
|
5
|
+
export declare const serializeEthereumTx: (txData: LegacyTxData | FeeMarketEIP1559TxData, chainId: number) => string;
|
|
6
|
+
export declare const ethereumSignTx: (typedCall: TypedCall, address_n: number[], to: string, value: string, gas_limit: string, gas_price: string, nonce: string, chain_id: number, chunkify: boolean, data?: string, tx_type?: number, definitions?: EthereumDefinitions) => Promise<{
|
|
5
7
|
v: string;
|
|
6
8
|
r: string;
|
|
7
9
|
s: string;
|
|
8
10
|
}>;
|
|
9
|
-
export declare const ethereumSignTxEIP1559: (typedCall: TypedCall, address_n: number[], to: string, value: string, gas_limit: string, max_gas_fee: string, max_priority_fee: string, nonce: string, chain_id: number, data?: string, access_list?: EthereumAccessList[], definitions?: EthereumDefinitions) => Promise<{
|
|
11
|
+
export declare const ethereumSignTxEIP1559: (typedCall: TypedCall, address_n: number[], to: string, value: string, gas_limit: string, max_gas_fee: string, max_priority_fee: string, nonce: string, chain_id: number, chunkify: boolean, data?: string, access_list?: EthereumAccessList[], definitions?: EthereumDefinitions) => Promise<{
|
|
10
12
|
v: string;
|
|
11
13
|
r: string;
|
|
12
14
|
s: string;
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ethereumSignTxEIP1559 = exports.ethereumSignTx = void 0;
|
|
3
|
+
exports.ethereumSignTxEIP1559 = exports.ethereumSignTx = exports.serializeEthereumTx = void 0;
|
|
4
|
+
const common_1 = require("@ethereumjs/common");
|
|
5
|
+
const tx_1 = require("@ethereumjs/tx");
|
|
4
6
|
const constants_1 = require("../../constants");
|
|
7
|
+
const formatUtils_1 = require("../../utils/formatUtils");
|
|
5
8
|
const splitString = (str, len) => {
|
|
6
9
|
if (str == null) {
|
|
7
10
|
return ['', ''];
|
|
@@ -31,13 +34,24 @@ const processTxRequest = async (typedCall, request, data, chain_id) => {
|
|
|
31
34
|
const response = await typedCall('EthereumTxAck', 'EthereumTxRequest', { data_chunk: first });
|
|
32
35
|
return processTxRequest(typedCall, response.message, rest, chain_id);
|
|
33
36
|
};
|
|
37
|
+
const deepHexPrefix = (0, formatUtils_1.deepTransform)(formatUtils_1.addHexPrefix);
|
|
38
|
+
const serializeEthereumTx = (txData, chainId) => {
|
|
39
|
+
const txOptions = chainId === 61
|
|
40
|
+
? {
|
|
41
|
+
common: common_1.Common.custom({ name: 'ethereum-classic', networkId: 1, chainId: 61 }, { baseChain: common_1.Chain.Mainnet, hardfork: common_1.Hardfork.Petersburg }),
|
|
42
|
+
}
|
|
43
|
+
: { chain: chainId };
|
|
44
|
+
const ethTx = tx_1.TransactionFactory.fromTxData(deepHexPrefix(txData), txOptions);
|
|
45
|
+
return `0x${Buffer.from(ethTx.serialize()).toString('hex')}`;
|
|
46
|
+
};
|
|
47
|
+
exports.serializeEthereumTx = serializeEthereumTx;
|
|
34
48
|
const stripLeadingZeroes = (str) => {
|
|
35
49
|
while (/^00/.test(str)) {
|
|
36
50
|
str = str.slice(2);
|
|
37
51
|
}
|
|
38
52
|
return str;
|
|
39
53
|
};
|
|
40
|
-
const ethereumSignTx = async (typedCall, address_n, to, value, gas_limit, gas_price, nonce, chain_id, data, tx_type, definitions) => {
|
|
54
|
+
const ethereumSignTx = async (typedCall, address_n, to, value, gas_limit, gas_price, nonce, chain_id, chunkify, data, tx_type, definitions) => {
|
|
41
55
|
const length = data == null ? 0 : data.length / 2;
|
|
42
56
|
const [first, rest] = splitString(data, 1024 * 2);
|
|
43
57
|
let message = {
|
|
@@ -49,6 +63,7 @@ const ethereumSignTx = async (typedCall, address_n, to, value, gas_limit, gas_pr
|
|
|
49
63
|
to,
|
|
50
64
|
value: stripLeadingZeroes(value),
|
|
51
65
|
definitions,
|
|
66
|
+
chunkify,
|
|
52
67
|
};
|
|
53
68
|
if (length !== 0) {
|
|
54
69
|
message = {
|
|
@@ -67,7 +82,7 @@ const ethereumSignTx = async (typedCall, address_n, to, value, gas_limit, gas_pr
|
|
|
67
82
|
return processTxRequest(typedCall, response.message, rest, chain_id);
|
|
68
83
|
};
|
|
69
84
|
exports.ethereumSignTx = ethereumSignTx;
|
|
70
|
-
const ethereumSignTxEIP1559 = async (typedCall, address_n, to, value, gas_limit, max_gas_fee, max_priority_fee, nonce, chain_id, data, access_list, definitions) => {
|
|
85
|
+
const ethereumSignTxEIP1559 = async (typedCall, address_n, to, value, gas_limit, max_gas_fee, max_priority_fee, nonce, chain_id, chunkify, data, access_list, definitions) => {
|
|
71
86
|
const length = data == null ? 0 : data.length / 2;
|
|
72
87
|
const [first, rest] = splitString(data, 1024 * 2);
|
|
73
88
|
const message = {
|
|
@@ -86,6 +101,7 @@ const ethereumSignTxEIP1559 = async (typedCall, address_n, to, value, gas_limit,
|
|
|
86
101
|
storage_keys: a.storageKeys,
|
|
87
102
|
})),
|
|
88
103
|
definitions,
|
|
104
|
+
chunkify,
|
|
89
105
|
};
|
|
90
106
|
const response = await typedCall('EthereumSignTxEIP1559', 'EthereumTxRequest', message);
|
|
91
107
|
return processTxRequest(typedCall, response.message, rest);
|
|
@@ -68,7 +68,7 @@ const verifyAuthenticityProof = async ({ certificates, signature, challenge, con
|
|
|
68
68
|
utils_1.bufferUtils.getChunkSize(challenge.length),
|
|
69
69
|
challenge,
|
|
70
70
|
]);
|
|
71
|
-
const isSignatureValid = await verifySignature(Buffer.from(deviceCert.tbsCertificate.subjectPublicKeyInfo.bits.bytes), prefixedChallenge, Buffer.from(signature, 'hex'));
|
|
71
|
+
const isSignatureValid = await verifySignature(Buffer.from(deviceCert.tbsCertificate.subjectPublicKeyInfo.bits.bytes), prefixedChallenge, (0, x509certificate_1.fixSignature)(Buffer.from(signature, 'hex')));
|
|
72
72
|
if (rootPubKey && isDeviceCertValid && isSignatureValid) {
|
|
73
73
|
if ((!isDebugRootPubKey && !caPubKeys.includes(caPubKey)) ||
|
|
74
74
|
(isDebugRootPubKey && !(debug === null || debug === void 0 ? void 0 : debug.caPubKeys.includes(caPubKey)))) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseCertificate = exports.parseName = void 0;
|
|
3
|
+
exports.parseCertificate = exports.parseName = exports.fixSignature = void 0;
|
|
4
4
|
const derToAsn1 = (byteArray) => {
|
|
5
5
|
let position = 0;
|
|
6
6
|
function getTag() {
|
|
@@ -76,13 +76,45 @@ const derBitStringValue = (byteArray) => ({
|
|
|
76
76
|
unusedBits: byteArray[0],
|
|
77
77
|
bytes: byteArray.subarray(1),
|
|
78
78
|
});
|
|
79
|
+
const fixSignature = (byteArray) => {
|
|
80
|
+
const asn1 = derToAsn1(byteArray);
|
|
81
|
+
if (asn1.cls !== 0 || asn1.tag !== 16 || !asn1.structured) {
|
|
82
|
+
throw new Error('Bad signature. Not a SEQUENCE.');
|
|
83
|
+
}
|
|
84
|
+
const items = derToAsn1List(asn1.contents);
|
|
85
|
+
let newLength = 0;
|
|
86
|
+
const fixedItems = items.map(chunk => {
|
|
87
|
+
const index = chunk.contents.findIndex(value => value > 0x00);
|
|
88
|
+
const data = chunk.contents.subarray(index);
|
|
89
|
+
const offset = data[0] >= 0x80 ? 1 : 0;
|
|
90
|
+
const chunkLength = data.length + offset;
|
|
91
|
+
const newChunk = new Uint8Array(chunkLength + 2);
|
|
92
|
+
newChunk.set([chunk.raw[0], chunkLength]);
|
|
93
|
+
if (offset > 0) {
|
|
94
|
+
newChunk.set([0], 2);
|
|
95
|
+
}
|
|
96
|
+
newChunk.set(data, 2 + offset);
|
|
97
|
+
newLength += newChunk.length;
|
|
98
|
+
return newChunk;
|
|
99
|
+
});
|
|
100
|
+
const signature = new Uint8Array(newLength + 2);
|
|
101
|
+
signature.set([byteArray[0], newLength]);
|
|
102
|
+
let signatureOffset = 2;
|
|
103
|
+
fixedItems.forEach(item => {
|
|
104
|
+
signature.set(item, signatureOffset);
|
|
105
|
+
signatureOffset += item.length;
|
|
106
|
+
});
|
|
107
|
+
return signature;
|
|
108
|
+
};
|
|
109
|
+
exports.fixSignature = fixSignature;
|
|
79
110
|
const parseSignatureValue = (asn1) => {
|
|
80
111
|
if (asn1.cls !== 0 || asn1.tag !== 3 || asn1.structured) {
|
|
81
112
|
throw new Error('Bad signature value. Not a BIT STRING.');
|
|
82
113
|
}
|
|
114
|
+
const { unusedBits, bytes } = derBitStringValue(asn1.contents);
|
|
83
115
|
return {
|
|
84
116
|
asn1,
|
|
85
|
-
bits:
|
|
117
|
+
bits: { unusedBits, bytes: (0, exports.fixSignature)(bytes) },
|
|
86
118
|
};
|
|
87
119
|
};
|
|
88
120
|
const derObjectIdentifierValue = (byteArray) => {
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { AbstractMethod } from '../core/AbstractMethod';
|
|
2
|
+
import type { CoinInfo } from '../types';
|
|
3
|
+
import type { GetAccountDescriptorParams, GetAccountDescriptorResponse } from '../types/api/getAccountDescriptor';
|
|
4
|
+
type Request = GetAccountDescriptorParams & {
|
|
5
|
+
address_n: number[];
|
|
6
|
+
coinInfo: CoinInfo;
|
|
7
|
+
};
|
|
8
|
+
export default class GetAccountDescriptor extends AbstractMethod<'getAccountDescriptor', Request[]> {
|
|
9
|
+
disposed: boolean;
|
|
10
|
+
hasBundle?: boolean;
|
|
11
|
+
init(): void;
|
|
12
|
+
get info(): string;
|
|
13
|
+
confirmation(): Promise<boolean>;
|
|
14
|
+
noBackupConfirmation(allowSuppression?: boolean): Promise<boolean>;
|
|
15
|
+
checkFirmwareRange(_isUsingPopup: boolean): Promise<undefined>;
|
|
16
|
+
run(): Promise<GetAccountDescriptorResponse | (GetAccountDescriptorResponse | null)[]>;
|
|
17
|
+
dispose(): void;
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=getAccountDescriptor.d.ts.map
|