@trezor/connect 9.1.3 → 9.1.4
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 +19 -0
- package/README.md +3 -1
- package/lib/api/bitcoin/TransactionComposer.js +1 -9
- package/lib/api/bitcoin/inputs.d.ts +2 -2
- package/lib/api/bitcoin/outputs.d.ts +2 -2
- package/lib/api/cardanoGetPublicKey.d.ts +6 -2
- package/lib/api/cardanoGetPublicKey.js +7 -1
- package/lib/api/checkFirmwareAuthenticity.js +2 -3
- package/lib/api/common/paramsValidator.js +7 -7
- package/lib/api/eos/eosSignTx.js +1 -1
- package/lib/api/firmwareUpdate.js +2 -3
- package/lib/api/getAccountInfo.d.ts +1 -1
- package/lib/api/getAccountInfo.js +5 -1
- package/lib/api/getPublicKey.d.ts +2 -1
- package/lib/api/getPublicKey.js +7 -1
- package/lib/api/signTransaction.js +1 -1
- package/lib/core/AbstractMethod.d.ts +4 -4
- package/lib/core/AbstractMethod.js +4 -3
- package/lib/core/index.js +12 -9
- package/lib/data/coinInfo.d.ts +5 -5
- package/lib/data/coinInfo.js +1 -1
- package/lib/data/config.js +4 -5
- package/lib/data/firmwareInfo.js +2 -3
- package/lib/data/models.d.ts +18 -0
- package/lib/data/models.js +21 -0
- package/lib/data/version.d.ts +1 -1
- package/lib/data/version.js +1 -1
- package/lib/device/Device.d.ts +4 -2
- package/lib/device/Device.js +29 -14
- package/lib/device/DeviceCommands.js +4 -4
- package/lib/device/DeviceList.d.ts +1 -1
- package/lib/device/DeviceList.js +6 -0
- package/lib/events/ui-promise.d.ts +10 -2
- package/lib/types/api/authorizeCoinjoin.d.ts +2 -2
- package/lib/types/api/binance/index.d.ts +2 -1
- package/lib/types/api/bitcoin/index.d.ts +6 -5
- package/lib/types/api/cardano/index.d.ts +12 -12
- package/lib/types/api/cipherKeyValue.d.ts +2 -2
- package/lib/types/api/eos/index.d.ts +3 -2
- package/lib/types/api/ethereum/index.d.ts +5 -4
- package/lib/types/api/getAccountInfo.d.ts +1 -0
- package/lib/types/api/getOwnershipId.d.ts +2 -2
- package/lib/types/api/getOwnershipProof.d.ts +2 -2
- package/lib/types/api/nem/index.d.ts +2 -1
- package/lib/types/api/ripple/index.d.ts +2 -1
- package/lib/types/api/stellar/index.d.ts +2 -1
- package/lib/types/api/tezos/index.d.ts +3 -2
- package/lib/types/api/unlockPath.d.ts +2 -2
- package/lib/types/device.d.ts +6 -0
- package/lib/types/firmware.d.ts +2 -2
- package/lib/types/params.d.ts +14 -2
- package/lib/utils/deviceFeaturesUtils.js +4 -4
- package/lib/utils/pathUtils.d.ts +3 -3
- package/package.json +11 -13
- package/lib/utils/deferred.d.ts +0 -18
- package/lib/utils/deferred.js +0 -66
- package/lib/utils/versionUtils.d.ts +0 -8
- package/lib/utils/versionUtils.js +0 -75
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
# 9.1.4
|
|
2
|
+
|
|
3
|
+
- feat(connect-popup): add metamask extension id to known third party (f137b3e4d6)
|
|
4
|
+
- test(connect): composeTransaction fix doge fee (69a92483c6)
|
|
5
|
+
- refactor(connect): remove doge fee branch (c79f3f25d8)
|
|
6
|
+
- feat(transport): udp support for transport methods (65e617195c)
|
|
7
|
+
- fix(connect): accept signTransaction inputs/outputs with `address_n: string` (82910e0766)
|
|
8
|
+
- fix(connect-explorer, connect-popup): add favicon (cafb574ada, c6071123f3)
|
|
9
|
+
- feat(connect-popup): use trezor icons with display off from suite-data (1c806519a7)
|
|
10
|
+
- feat(connect): trezor color in device object (31535e2b0f)
|
|
11
|
+
- feat(connect): trezor name in device object (a0ecb66390)
|
|
12
|
+
- feat(connect-common): copy models.json from submodules (6d80197523)
|
|
13
|
+
- fix(connect-iframe): device event not propagating to host (d35e37863a)
|
|
14
|
+
- feat(connect, suite): unify no backup warning button text (375f3fa1a1)
|
|
15
|
+
- feat(connect): add suppressBackupWarning param to getPublicKey and getAccountInfo (2c2698d8af)
|
|
16
|
+
- fix(type-check): connect-web includes connect-iframe package.json (f9f576ab66)
|
|
17
|
+
- fix(connect-iframe): method.initAsync method superfluous call (37ace99a5d)
|
|
18
|
+
- fix(connect-iframe): define plugin in build to support analytics (c793ce358c)
|
|
19
|
+
|
|
1
20
|
# 9.1.3
|
|
2
21
|
|
|
3
22
|
- fix(connect): correct import of internal connect dependency (https://github.com/trezor/trezor-suite/issues/9389)
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @trezor/connect
|
|
2
2
|
|
|
3
|
-
API version 9.1.
|
|
3
|
+
API version 9.1.4
|
|
4
4
|
|
|
5
5
|
[](https://github.com/trezor/trezor-suite/actions/workflows/connect-test.yml)
|
|
6
6
|
[](https://www.npmjs.org/package/@trezor/connect)
|
|
@@ -47,6 +47,8 @@ Version 9 is available as `@trezor/connect` and `@trezor/connect-web` npm packag
|
|
|
47
47
|
|
|
48
48
|
New major version is released when there are breaking changes on API level. Previous major version will be maintained for 12 months and after this period it can be taken down without notice.
|
|
49
49
|
|
|
50
|
+
Current major version 9 is being developed on top of `develop` branch. When there is a new major version a new branch should be created (`v-<major-version>`) and mantained separately.
|
|
51
|
+
|
|
50
52
|
### Minor version
|
|
51
53
|
|
|
52
54
|
Minor versions are released when there are:
|
|
@@ -121,14 +121,6 @@ class TransactionComposer {
|
|
|
121
121
|
const changeAddress = addresses.change.find(a => !a.transfers) ||
|
|
122
122
|
addresses.change[addresses.change.length - 1];
|
|
123
123
|
const changeId = (0, pathUtils_1.getHDPath)(changeAddress.path).slice(-1)[0];
|
|
124
|
-
const enhancement = {
|
|
125
|
-
baseFee,
|
|
126
|
-
floorBaseFee: false,
|
|
127
|
-
dustOutputFee: 0,
|
|
128
|
-
};
|
|
129
|
-
if (coinInfo.shortcut === 'DOGE') {
|
|
130
|
-
enhancement.dustOutputFee = 1000000;
|
|
131
|
-
}
|
|
132
124
|
return (0, utxo_lib_1.composeTx)({
|
|
133
125
|
txType: account.type,
|
|
134
126
|
utxos: this.utxos,
|
|
@@ -142,7 +134,7 @@ class TransactionComposer {
|
|
|
142
134
|
changeId,
|
|
143
135
|
changeAddress: changeAddress.address,
|
|
144
136
|
dustThreshold: coinInfo.dustLimit,
|
|
145
|
-
|
|
137
|
+
baseFee,
|
|
146
138
|
});
|
|
147
139
|
}
|
|
148
140
|
dispose() {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { ComposedTxInput } from '@trezor/utxo-lib';
|
|
2
2
|
import type { TypedRawTransaction } from '@trezor/blockchain-link';
|
|
3
|
-
import type { BitcoinNetworkInfo } from '../../types';
|
|
3
|
+
import type { BitcoinNetworkInfo, ProtoWithDerivationPath } from '../../types';
|
|
4
4
|
import type { PROTO } from '../../constants';
|
|
5
|
-
export declare const validateTrezorInputs: (inputs: PROTO.TxInputType[], coinInfo: BitcoinNetworkInfo) => PROTO.TxInputType[];
|
|
5
|
+
export declare const validateTrezorInputs: (inputs: ProtoWithDerivationPath<PROTO.TxInputType>[], coinInfo: BitcoinNetworkInfo) => PROTO.TxInputType[];
|
|
6
6
|
export declare const enhanceTrezorInputs: (inputs: PROTO.TxInputType[], rawTxs: TypedRawTransaction[]) => void;
|
|
7
7
|
export declare const inputToTrezor: (input: ComposedTxInput, sequence: number) => PROTO.TxInputType;
|
|
8
8
|
//# sourceMappingURL=inputs.d.ts.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { ComposeOutput as UtxoLibOutput, ComposedTxOutput } from '@trezor/utxo-lib';
|
|
2
2
|
import { PROTO } from '../../constants';
|
|
3
|
-
import type { BitcoinNetworkInfo } from '../../types';
|
|
3
|
+
import type { BitcoinNetworkInfo, ProtoWithDerivationPath } from '../../types';
|
|
4
4
|
import type { ComposeOutput } from '../../types/api/composeTransaction';
|
|
5
|
-
export declare const validateTrezorOutputs: (outputs: PROTO.TxOutputType[], coinInfo: BitcoinNetworkInfo) => PROTO.TxOutputType[];
|
|
5
|
+
export declare const validateTrezorOutputs: (outputs: ProtoWithDerivationPath<PROTO.TxOutputType>[], coinInfo: BitcoinNetworkInfo) => PROTO.TxOutputType[];
|
|
6
6
|
export declare const validateHDOutput: (output: ComposeOutput, coinInfo: BitcoinNetworkInfo) => UtxoLibOutput;
|
|
7
7
|
export declare const outputToTrezor: (output: ComposedTxOutput, _coinInfo: BitcoinNetworkInfo) => PROTO.TxOutputType;
|
|
8
8
|
//# sourceMappingURL=outputs.d.ts.map
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import { PROTO } from '../constants';
|
|
2
2
|
import { AbstractMethod } from '../core/AbstractMethod';
|
|
3
|
-
|
|
3
|
+
interface Params extends PROTO.CardanoGetPublicKey {
|
|
4
|
+
suppressBackupWarning?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export default class CardanoGetPublicKey extends AbstractMethod<'cardanoGetPublicKey', Params[]> {
|
|
4
7
|
hasBundle?: boolean;
|
|
5
8
|
confirmed?: boolean;
|
|
6
9
|
init(): void;
|
|
7
10
|
get info(): string;
|
|
8
11
|
confirmation(): Promise<boolean>;
|
|
9
|
-
noBackupConfirmation(): Promise<boolean>;
|
|
12
|
+
noBackupConfirmation(allowSuppression?: boolean): Promise<boolean>;
|
|
10
13
|
run(): Promise<import("..").CardanoPublicKey | import("..").CardanoPublicKey[]>;
|
|
11
14
|
}
|
|
15
|
+
export {};
|
|
12
16
|
//# sourceMappingURL=cardanoGetPublicKey.d.ts.map
|
|
@@ -20,6 +20,7 @@ class CardanoGetPublicKey extends AbstractMethod_1.AbstractMethod {
|
|
|
20
20
|
{ name: 'path', required: true },
|
|
21
21
|
{ name: 'derivationType', type: 'number' },
|
|
22
22
|
{ name: 'showOnTrezor', type: 'boolean' },
|
|
23
|
+
{ name: 'suppressBackupWarning', type: 'boolean' },
|
|
23
24
|
]);
|
|
24
25
|
const path = (0, pathUtils_1.validatePath)(batch.path, 3);
|
|
25
26
|
return {
|
|
@@ -28,6 +29,7 @@ class CardanoGetPublicKey extends AbstractMethod_1.AbstractMethod {
|
|
|
28
29
|
? batch.derivationType
|
|
29
30
|
: constants_1.PROTO.CardanoDerivationType.ICARUS_TREZOR,
|
|
30
31
|
show_display: typeof batch.showOnTrezor === 'boolean' ? batch.showOnTrezor : false,
|
|
32
|
+
suppress_backup_warning: batch.suppressBackupWarning,
|
|
31
33
|
};
|
|
32
34
|
});
|
|
33
35
|
}
|
|
@@ -54,7 +56,11 @@ class CardanoGetPublicKey extends AbstractMethod_1.AbstractMethod {
|
|
|
54
56
|
this.confirmed = uiResp.payload;
|
|
55
57
|
return this.confirmed;
|
|
56
58
|
}
|
|
57
|
-
async noBackupConfirmation() {
|
|
59
|
+
async noBackupConfirmation(allowSuppression) {
|
|
60
|
+
if (allowSuppression &&
|
|
61
|
+
this.params.every(batch => batch.suppressBackupWarning || !batch.show_display)) {
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
58
64
|
await this.getPopupPromise().promise;
|
|
59
65
|
const uiPromise = this.createUiPromise(events_1.UI.RECEIVE_CONFIRMATION);
|
|
60
66
|
this.postMessage((0, events_1.createUiMessage)(events_1.UI.REQUEST_CONFIRMATION, {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
4
|
-
const randombytes_1 = tslib_1.__importDefault(require("randombytes"));
|
|
3
|
+
const crypto_1 = require("crypto");
|
|
5
4
|
const AbstractMethod_1 = require("../core/AbstractMethod");
|
|
6
5
|
const firmware_1 = require("./firmware");
|
|
7
6
|
const firmwareInfo_1 = require("../data/firmwareInfo");
|
|
@@ -28,7 +27,7 @@ class CheckFirmwareAuthenticity extends AbstractMethod_1.AbstractMethod {
|
|
|
28
27
|
if (!fw) {
|
|
29
28
|
throw constants_1.ERRORS.TypedError('Runtime', 'checkFirmwareAuthenticity: firmware binary not found');
|
|
30
29
|
}
|
|
31
|
-
const { hash: expectedFirmwareHash, challenge } = (0, firmware_1.calculateFirmwareHash)(device.features.major_version, (0, firmware_1.stripFwHeaders)(fw), (0,
|
|
30
|
+
const { hash: expectedFirmwareHash, challenge } = (0, firmware_1.calculateFirmwareHash)(device.features.major_version, (0, firmware_1.stripFwHeaders)(fw), (0, crypto_1.randomBytes)(32));
|
|
32
31
|
const result = await this.device
|
|
33
32
|
.getCommands()
|
|
34
33
|
.typedCall('GetFirmwareHash', 'FirmwareHash', {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getFirmwareRange = exports.validateCoinPath = exports.validateParams = void 0;
|
|
4
|
+
const utils_1 = require("@trezor/utils");
|
|
4
5
|
const constants_1 = require("../../constants");
|
|
5
6
|
const pathUtils_1 = require("../../utils/pathUtils");
|
|
6
|
-
const versionUtils_1 = require("../../utils/versionUtils");
|
|
7
7
|
const config_1 = require("../../data/config");
|
|
8
8
|
const invalidParameter = (message) => constants_1.ERRORS.TypedError('Method_InvalidParameter', message);
|
|
9
9
|
function validateParams(params, schema) {
|
|
@@ -73,13 +73,13 @@ const getFirmwareRange = (method, coinInfo, currentRange) => {
|
|
|
73
73
|
if (!coinInfo.support || typeof coinInfo.support.trezor1 !== 'string') {
|
|
74
74
|
current['1'].min = '0';
|
|
75
75
|
}
|
|
76
|
-
else if (
|
|
76
|
+
else if (utils_1.versionUtils.isNewer(coinInfo.support.trezor1, current['1'].min)) {
|
|
77
77
|
current['1'].min = coinInfo.support.trezor1;
|
|
78
78
|
}
|
|
79
79
|
if (!coinInfo.support || typeof coinInfo.support.trezor2 !== 'string') {
|
|
80
80
|
current['2'].min = '0';
|
|
81
81
|
}
|
|
82
|
-
else if (
|
|
82
|
+
else if (utils_1.versionUtils.isNewer(coinInfo.support.trezor2, current['2'].min)) {
|
|
83
83
|
current['2'].min = coinInfo.support.trezor2;
|
|
84
84
|
}
|
|
85
85
|
}
|
|
@@ -111,12 +111,12 @@ const getFirmwareRange = (method, coinInfo, currentRange) => {
|
|
|
111
111
|
const [t1, t2] = min;
|
|
112
112
|
if (t1 === '0' ||
|
|
113
113
|
current['1'].min === '0' ||
|
|
114
|
-
|
|
114
|
+
!utils_1.versionUtils.isNewerOrEqual(current['1'].min, t1)) {
|
|
115
115
|
current['1'].min = t1;
|
|
116
116
|
}
|
|
117
117
|
if (t2 === '0' ||
|
|
118
118
|
current['2'].min === '0' ||
|
|
119
|
-
|
|
119
|
+
!utils_1.versionUtils.isNewerOrEqual(current['2'].min, t2)) {
|
|
120
120
|
current['2'].min = t2;
|
|
121
121
|
}
|
|
122
122
|
}
|
|
@@ -124,12 +124,12 @@ const getFirmwareRange = (method, coinInfo, currentRange) => {
|
|
|
124
124
|
const [t1, t2] = max;
|
|
125
125
|
if (t1 === '0' ||
|
|
126
126
|
current['1'].max === '0' ||
|
|
127
|
-
|
|
127
|
+
!utils_1.versionUtils.isNewerOrEqual(current['1'].max, t1)) {
|
|
128
128
|
current['1'].max = t1;
|
|
129
129
|
}
|
|
130
130
|
if (t2 === '0' ||
|
|
131
131
|
current['2'].max === '0' ||
|
|
132
|
-
|
|
132
|
+
!utils_1.versionUtils.isNewerOrEqual(current['2'].max, t2)) {
|
|
133
133
|
current['2'].max = t2;
|
|
134
134
|
}
|
|
135
135
|
}
|
package/lib/api/eos/eosSignTx.js
CHANGED
|
@@ -102,7 +102,7 @@ const parseAuth = (a) => {
|
|
|
102
102
|
const key = Buffer.from(bs58.decode(pk.substring(len)));
|
|
103
103
|
return {
|
|
104
104
|
type: 0,
|
|
105
|
-
key: key.
|
|
105
|
+
key: key.subarray(0, key.length - 4).toString('hex'),
|
|
106
106
|
};
|
|
107
107
|
};
|
|
108
108
|
return {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
4
|
-
const randombytes_1 = tslib_1.__importDefault(require("randombytes"));
|
|
3
|
+
const crypto_1 = require("crypto");
|
|
5
4
|
const AbstractMethod_1 = require("../core/AbstractMethod");
|
|
6
5
|
const constants_1 = require("../constants");
|
|
7
6
|
const events_1 = require("../events");
|
|
@@ -76,7 +75,7 @@ class FirmwareUpdate extends AbstractMethod_1.AbstractMethod {
|
|
|
76
75
|
}
|
|
77
76
|
const stripped = (0, firmware_1.stripFwHeaders)(binary);
|
|
78
77
|
await (0, firmware_1.uploadFirmware)(this.device.getCommands().typedCall.bind(this.device.getCommands()), this.postMessage, device, { payload: (0, firmware_1.shouldStripFwHeaders)(device.features) ? stripped : binary });
|
|
79
|
-
return (0, firmware_1.calculateFirmwareHash)(device.features.major_version, stripped, (0,
|
|
78
|
+
return (0, firmware_1.calculateFirmwareHash)(device.features.major_version, stripped, (0, crypto_1.randomBytes)(32));
|
|
80
79
|
}
|
|
81
80
|
}
|
|
82
81
|
exports.default = FirmwareUpdate;
|
|
@@ -13,7 +13,7 @@ export default class GetAccountInfo extends AbstractMethod<'getAccountInfo', Req
|
|
|
13
13
|
init(): void;
|
|
14
14
|
get info(): string;
|
|
15
15
|
confirmation(): Promise<boolean>;
|
|
16
|
-
noBackupConfirmation(): Promise<boolean>;
|
|
16
|
+
noBackupConfirmation(allowSuppression?: boolean): Promise<boolean>;
|
|
17
17
|
checkFirmwareRange(isUsingPopup: boolean): Promise<"ui-device_firmware_old" | "ui-device_firmware_unsupported" | "ui-device_firmware_not_compatible" | "ui-device_firmware_not_installed" | undefined>;
|
|
18
18
|
run(): Promise<AccountInfo | (AccountInfo | null)[] | {
|
|
19
19
|
utxo: AccountUtxo[] | undefined;
|
|
@@ -41,6 +41,7 @@ class GetAccountInfo extends AbstractMethod_1.AbstractMethod {
|
|
|
41
41
|
{ name: 'marker', type: 'object' },
|
|
42
42
|
{ name: 'defaultAccountType', type: 'string' },
|
|
43
43
|
{ name: 'derivationType', type: 'number' },
|
|
44
|
+
{ name: 'suppressBackupWarning', type: 'boolean' },
|
|
44
45
|
]);
|
|
45
46
|
const coinInfo = (0, coinInfo_1.getCoinInfo)(batch.coin);
|
|
46
47
|
if (!coinInfo) {
|
|
@@ -119,7 +120,10 @@ class GetAccountInfo extends AbstractMethod_1.AbstractMethod {
|
|
|
119
120
|
const uiResp = await uiPromise.promise;
|
|
120
121
|
return uiResp.payload;
|
|
121
122
|
}
|
|
122
|
-
async noBackupConfirmation() {
|
|
123
|
+
async noBackupConfirmation(allowSuppression) {
|
|
124
|
+
if (allowSuppression && this.params.every(batch => batch.suppressBackupWarning)) {
|
|
125
|
+
return true;
|
|
126
|
+
}
|
|
123
127
|
await this.getPopupPromise().promise;
|
|
124
128
|
const uiPromise = this.createUiPromise(events_1.UI.RECEIVE_CONFIRMATION);
|
|
125
129
|
this.postMessage((0, events_1.createUiMessage)(events_1.UI.REQUEST_CONFIRMATION, {
|
|
@@ -3,6 +3,7 @@ import type { BitcoinNetworkInfo } from '../types';
|
|
|
3
3
|
import type { PROTO } from '../constants';
|
|
4
4
|
type Params = PROTO.GetPublicKey & {
|
|
5
5
|
coinInfo?: BitcoinNetworkInfo;
|
|
6
|
+
suppressBackupWarning?: boolean;
|
|
6
7
|
unlockPath?: PROTO.UnlockPath;
|
|
7
8
|
};
|
|
8
9
|
export default class GetPublicKey extends AbstractMethod<'getPublicKey', Params[]> {
|
|
@@ -11,7 +12,7 @@ export default class GetPublicKey extends AbstractMethod<'getPublicKey', Params[
|
|
|
11
12
|
init(): void;
|
|
12
13
|
get info(): string;
|
|
13
14
|
confirmation(): Promise<boolean>;
|
|
14
|
-
noBackupConfirmation(): Promise<boolean>;
|
|
15
|
+
noBackupConfirmation(allowSuppression?: boolean): Promise<boolean>;
|
|
15
16
|
run(): Promise<import("../types/api/getPublicKey").HDNodeResponse | import("../types/api/getPublicKey").HDNodeResponse[]>;
|
|
16
17
|
}
|
|
17
18
|
export {};
|
package/lib/api/getPublicKey.js
CHANGED
|
@@ -24,6 +24,7 @@ class GetPublicKey extends AbstractMethod_1.AbstractMethod {
|
|
|
24
24
|
{ name: 'ignoreXpubMagic', type: 'boolean' },
|
|
25
25
|
{ name: 'ecdsaCurveName', type: 'boolean' },
|
|
26
26
|
{ name: 'unlockPath', type: 'object' },
|
|
27
|
+
{ name: 'suppressBackupWarning', type: 'boolean' },
|
|
27
28
|
]);
|
|
28
29
|
if (batch.unlockPath) {
|
|
29
30
|
(0, paramsValidator_1.validateParams)(batch.unlockPath, [
|
|
@@ -54,6 +55,7 @@ class GetPublicKey extends AbstractMethod_1.AbstractMethod {
|
|
|
54
55
|
ecdsa_curve_name: batch.ecdsaCurveName,
|
|
55
56
|
coinInfo,
|
|
56
57
|
unlockPath: batch.unlockPath,
|
|
58
|
+
suppress_backup_warning: batch.suppressBackupWarning,
|
|
57
59
|
};
|
|
58
60
|
});
|
|
59
61
|
}
|
|
@@ -80,7 +82,11 @@ class GetPublicKey extends AbstractMethod_1.AbstractMethod {
|
|
|
80
82
|
this.confirmed = uiResp.payload;
|
|
81
83
|
return this.confirmed;
|
|
82
84
|
}
|
|
83
|
-
async noBackupConfirmation() {
|
|
85
|
+
async noBackupConfirmation(allowSuppression) {
|
|
86
|
+
if (allowSuppression &&
|
|
87
|
+
this.params.every(batch => batch.suppressBackupWarning || !batch.show_display)) {
|
|
88
|
+
return true;
|
|
89
|
+
}
|
|
84
90
|
await this.getPopupPromise().promise;
|
|
85
91
|
const uiPromise = this.createUiPromise(events_1.UI.RECEIVE_CONFIRMATION);
|
|
86
92
|
this.postMessage((0, events_1.createUiMessage)(events_1.UI.REQUEST_CONFIRMATION, {
|
|
@@ -70,7 +70,7 @@ class SignTransaction extends AbstractMethod_1.AbstractMethod {
|
|
|
70
70
|
}
|
|
71
71
|
this.params = {
|
|
72
72
|
inputs,
|
|
73
|
-
outputs
|
|
73
|
+
outputs,
|
|
74
74
|
paymentRequests: payload.paymentRequests || [],
|
|
75
75
|
refTxs,
|
|
76
76
|
addresses: payload.account ? payload.account.addresses : undefined,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { Deferred } from '@trezor/utils';
|
|
1
2
|
import { NETWORK } from '../constants';
|
|
2
|
-
import { CallMethodPayload, CallMethodResponse, UiRequestButtonData,
|
|
3
|
-
import { Deferred } from '../utils/deferred';
|
|
3
|
+
import { CallMethodPayload, CallMethodResponse, UiRequestButtonData, UiPromiseCreator, PostMessage } from '../events';
|
|
4
4
|
import type { Device } from '../device/Device';
|
|
5
5
|
import type { FirmwareRange } from '../types';
|
|
6
6
|
export type Payload<M> = Extract<CallMethodPayload, {
|
|
@@ -37,11 +37,11 @@ export declare abstract class AbstractMethod<Name extends CallMethodPayload['met
|
|
|
37
37
|
network: NETWORK.NetworkType;
|
|
38
38
|
useCardanoDerivation: boolean;
|
|
39
39
|
confirmation?(): Promise<boolean | undefined>;
|
|
40
|
-
noBackupConfirmation?(): Promise<boolean>;
|
|
40
|
+
noBackupConfirmation?(allowSuppression?: boolean): Promise<boolean>;
|
|
41
41
|
getButtonRequestData?(code: string): UiRequestButtonData | undefined;
|
|
42
42
|
postMessage: PostMessage;
|
|
43
43
|
getPopupPromise: () => Deferred<void>;
|
|
44
|
-
createUiPromise:
|
|
44
|
+
createUiPromise: UiPromiseCreator;
|
|
45
45
|
removeUiPromise: (promise: Deferred<any>) => void;
|
|
46
46
|
initAsync?(): Promise<void>;
|
|
47
47
|
initAsyncPromise?: Promise<void>;
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AbstractMethod = void 0;
|
|
4
4
|
const connect_common_1 = require("@trezor/connect-common");
|
|
5
|
+
const utils_1 = require("@trezor/utils");
|
|
5
6
|
const DataManager_1 = require("../data/DataManager");
|
|
6
7
|
const constants_1 = require("../constants");
|
|
7
8
|
const events_1 = require("../events");
|
|
8
|
-
const versionUtils_1 = require("../utils/versionUtils");
|
|
9
9
|
const urlUtils_1 = require("../utils/urlUtils");
|
|
10
10
|
class AbstractMethod {
|
|
11
11
|
get info() {
|
|
@@ -139,10 +139,11 @@ class AbstractMethod {
|
|
|
139
139
|
if (range.min === '0') {
|
|
140
140
|
return events_1.UI.FIRMWARE_NOT_SUPPORTED;
|
|
141
141
|
}
|
|
142
|
-
if (device.firmwareStatus === 'required' ||
|
|
142
|
+
if (device.firmwareStatus === 'required' ||
|
|
143
|
+
!utils_1.versionUtils.isNewerOrEqual(version.join('.'), range.min)) {
|
|
143
144
|
return events_1.UI.FIRMWARE_OLD;
|
|
144
145
|
}
|
|
145
|
-
if (range.max !== '0' && (
|
|
146
|
+
if (range.max !== '0' && utils_1.versionUtils.isNewer(version.join('.'), range.max)) {
|
|
146
147
|
if (isUsingPopup) {
|
|
147
148
|
await this.getPopupPromise().promise;
|
|
148
149
|
const uiPromise = this.createUiPromise(events_1.UI.RECEIVE_CONFIRMATION);
|
package/lib/core/index.js
CHANGED
|
@@ -4,13 +4,13 @@ exports.initTransport = exports.initCore = exports.Core = exports.onCall = expor
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const events_1 = tslib_1.__importDefault(require("events"));
|
|
6
6
|
const transport_1 = require("@trezor/transport");
|
|
7
|
+
const utils_1 = require("@trezor/utils");
|
|
7
8
|
const DataManager_1 = require("../data/DataManager");
|
|
8
9
|
const DeviceList_1 = require("../device/DeviceList");
|
|
9
10
|
const analyticsInfo_1 = require("../data/analyticsInfo");
|
|
10
11
|
const constants_1 = require("../constants");
|
|
11
12
|
const events_2 = require("../events");
|
|
12
13
|
const method_1 = require("./method");
|
|
13
|
-
const deferred_1 = require("../utils/deferred");
|
|
14
14
|
const promiseUtils_1 = require("../utils/promiseUtils");
|
|
15
15
|
const debug_1 = require("../utils/debug");
|
|
16
16
|
const BlockchainLink_1 = require("../backend/BlockchainLink");
|
|
@@ -18,7 +18,7 @@ const interactionTimeout_1 = require("../utils/interactionTimeout");
|
|
|
18
18
|
let _core;
|
|
19
19
|
let _deviceList;
|
|
20
20
|
let _popupPromise;
|
|
21
|
-
|
|
21
|
+
const _uiPromises = [];
|
|
22
22
|
const _callMethods = [];
|
|
23
23
|
let _preferredDevice;
|
|
24
24
|
let _interactionTimeout;
|
|
@@ -39,7 +39,7 @@ const getPopupPromise = (requestWindow = true) => {
|
|
|
39
39
|
postMessage((0, events_2.createUiMessage)(events_2.UI.REQUEST_UI_WINDOW));
|
|
40
40
|
}
|
|
41
41
|
if (!_popupPromise) {
|
|
42
|
-
_popupPromise = (0,
|
|
42
|
+
_popupPromise = (0, utils_1.createDeferred)();
|
|
43
43
|
}
|
|
44
44
|
return _popupPromise;
|
|
45
45
|
};
|
|
@@ -47,14 +47,17 @@ const interactionTimeout = () => _interactionTimeout.start(() => {
|
|
|
47
47
|
onPopupClosed('Interaction timeout');
|
|
48
48
|
});
|
|
49
49
|
const createUiPromise = (promiseEvent, device) => {
|
|
50
|
-
const uiPromise =
|
|
50
|
+
const uiPromise = {
|
|
51
|
+
...(0, utils_1.createDeferred)(promiseEvent),
|
|
52
|
+
device,
|
|
53
|
+
};
|
|
51
54
|
_uiPromises.push(uiPromise);
|
|
52
55
|
interactionTimeout();
|
|
53
56
|
return uiPromise;
|
|
54
57
|
};
|
|
55
58
|
const findUiPromise = (promiseEvent) => _uiPromises.find(p => p.id === promiseEvent);
|
|
56
59
|
const removeUiPromise = (promise) => {
|
|
57
|
-
_uiPromises
|
|
60
|
+
_uiPromises.splice(0).push(..._uiPromises.filter(p => p !== promise));
|
|
58
61
|
};
|
|
59
62
|
const handleMessage = (message) => {
|
|
60
63
|
_log.debug('handleMessage', message);
|
|
@@ -292,7 +295,7 @@ const onCall = async (message) => {
|
|
|
292
295
|
}
|
|
293
296
|
const deviceNeedsBackup = device.features.needs_backup;
|
|
294
297
|
if (deviceNeedsBackup && typeof method.noBackupConfirmation === 'function') {
|
|
295
|
-
const permitted = await method.noBackupConfirmation();
|
|
298
|
+
const permitted = await method.noBackupConfirmation(!isUsingPopup);
|
|
296
299
|
if (!permitted) {
|
|
297
300
|
return Promise.reject(constants_1.ERRORS.TypedError('Method_PermissionsNotGranted'));
|
|
298
301
|
}
|
|
@@ -410,7 +413,7 @@ const onCall = async (message) => {
|
|
|
410
413
|
exports.onCall = onCall;
|
|
411
414
|
const cleanup = () => {
|
|
412
415
|
_popupPromise = undefined;
|
|
413
|
-
_uiPromises
|
|
416
|
+
_uiPromises.splice(0);
|
|
414
417
|
_interactionTimeout.stop();
|
|
415
418
|
_log.debug('Cleanup...');
|
|
416
419
|
};
|
|
@@ -498,7 +501,7 @@ const onPopupClosed = (customErrorMessage) => {
|
|
|
498
501
|
_uiPromises.forEach(p => {
|
|
499
502
|
p.reject(error);
|
|
500
503
|
});
|
|
501
|
-
_uiPromises
|
|
504
|
+
_uiPromises.splice(0);
|
|
502
505
|
}
|
|
503
506
|
if (_popupPromise) {
|
|
504
507
|
_popupPromise.reject(error);
|
|
@@ -530,7 +533,7 @@ const handleDeviceSelectionChanges = (interruptDevice) => {
|
|
|
530
533
|
const { path } = interruptDevice;
|
|
531
534
|
let shouldClosePopup = false;
|
|
532
535
|
_uiPromises.forEach(p => {
|
|
533
|
-
if (p.
|
|
536
|
+
if (p.device && p.device.getDevicePath() === path) {
|
|
534
537
|
if (p.id === events_2.DEVICE.DISCONNECT) {
|
|
535
538
|
p.resolve({ type: events_2.DEVICE.DISCONNECT });
|
|
536
539
|
}
|
package/lib/data/coinInfo.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { CoinInfo, BitcoinNetworkInfo, EthereumNetworkInfo, MiscNetworkInfo } from '../types
|
|
2
|
-
export declare const getBitcoinNetwork: (pathOrName:
|
|
3
|
-
export declare const getEthereumNetwork: (pathOrName:
|
|
4
|
-
export declare const getMiscNetwork: (pathOrName:
|
|
1
|
+
import type { CoinInfo, BitcoinNetworkInfo, EthereumNetworkInfo, MiscNetworkInfo, DerivationPath } from '../types';
|
|
2
|
+
export declare const getBitcoinNetwork: (pathOrName: DerivationPath) => BitcoinNetworkInfo | undefined;
|
|
3
|
+
export declare const getEthereumNetwork: (pathOrName: DerivationPath) => EthereumNetworkInfo | undefined;
|
|
4
|
+
export declare const getMiscNetwork: (pathOrName: DerivationPath) => MiscNetworkInfo | undefined;
|
|
5
5
|
export declare const getSegwitNetwork: (coin: BitcoinNetworkInfo) => {
|
|
6
6
|
bip32: {
|
|
7
7
|
public: number;
|
|
@@ -35,7 +35,7 @@ export declare const ethereumNetworkInfoBase: {
|
|
|
35
35
|
minFee: number;
|
|
36
36
|
maxFee: number;
|
|
37
37
|
dustLimit: number;
|
|
38
|
-
defaultFees: import("
|
|
38
|
+
defaultFees: import("../types").FeeLevel[];
|
|
39
39
|
type: "ethereum";
|
|
40
40
|
decimals: number;
|
|
41
41
|
};
|
package/lib/data/coinInfo.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getAllNetworks = exports.getUniqueNetworks = exports.parseCoinsJson = exports.ethereumNetworkInfoBase = exports.getCoinName = exports.getCoinInfo = exports.getCoinInfoByHash = exports.fixCoinInfoNetwork = exports.getBech32Network = exports.getSegwitNetwork = exports.getMiscNetwork = exports.getEthereumNetwork = exports.getBitcoinNetwork = void 0;
|
|
4
|
+
const utils_1 = require("@trezor/utils");
|
|
4
5
|
const defaultFeeLevels_1 = require("./defaultFeeLevels");
|
|
5
6
|
const constants_1 = require("../constants");
|
|
6
7
|
const pathUtils_1 = require("../utils/pathUtils");
|
|
7
|
-
const utils_1 = require("@trezor/utils");
|
|
8
8
|
const bitcoinNetworks = [];
|
|
9
9
|
const ethereumNetworks = [];
|
|
10
10
|
const miscNetworks = [];
|
package/lib/data/config.js
CHANGED
|
@@ -21,19 +21,18 @@ exports.config = {
|
|
|
21
21
|
icon: '',
|
|
22
22
|
},
|
|
23
23
|
{ origin: 'niebkpllfhmpfbffbfifagfgoamhpflf', label: 'Trezor Password Manager', icon: '' },
|
|
24
|
-
{ origin: 'trezor-connect@trezor.io', label: 'Trezor Connect FF Extension', icon: '' },
|
|
25
24
|
{
|
|
26
|
-
origin: '
|
|
27
|
-
label: '
|
|
25
|
+
origin: 'mnpfhpndmjholfdlhpkjfmjkgppmodaf',
|
|
26
|
+
label: 'MetaMask',
|
|
28
27
|
icon: '',
|
|
29
28
|
},
|
|
30
29
|
{
|
|
31
|
-
origin: '
|
|
30
|
+
origin: 'webextension@metamask.io',
|
|
32
31
|
label: 'MetaMask',
|
|
33
32
|
icon: '',
|
|
34
33
|
},
|
|
35
34
|
{
|
|
36
|
-
origin: '
|
|
35
|
+
origin: 'nkbihfbeogaeaoehlefnkodbefgpgknn',
|
|
37
36
|
label: 'MetaMask',
|
|
38
37
|
icon: '',
|
|
39
38
|
},
|
package/lib/data/firmwareInfo.js
CHANGED
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getReleases = exports.getRelease = exports.getFirmwareStatus = exports.getInfo = exports.parseFirmware = void 0;
|
|
4
4
|
const utils_1 = require("@trezor/utils");
|
|
5
5
|
const firmwareUtils_1 = require("../utils/firmwareUtils");
|
|
6
|
-
const versionUtils_1 = require("../utils/versionUtils");
|
|
7
6
|
const releases = {};
|
|
8
7
|
releases[1] = [];
|
|
9
8
|
releases[2] = [];
|
|
@@ -77,12 +76,12 @@ const getIntermediaryVersion = (releases, features, offerLatest) => {
|
|
|
77
76
|
const getSafeReleases = ({ features, releases }) => {
|
|
78
77
|
const { bootloader_mode, major_version, minor_version, patch_version, fw_major, fw_minor, fw_patch, } = features;
|
|
79
78
|
const firmwareVersion = [major_version, minor_version, patch_version];
|
|
80
|
-
if (!
|
|
79
|
+
if (!utils_1.versionUtils.isVersionArray(firmwareVersion)) {
|
|
81
80
|
return [];
|
|
82
81
|
}
|
|
83
82
|
if (major_version === 2 && bootloader_mode) {
|
|
84
83
|
const fwVersion = [fw_major, fw_minor, fw_patch];
|
|
85
|
-
if (
|
|
84
|
+
if (utils_1.versionUtils.isVersionArray(fwVersion)) {
|
|
86
85
|
return (0, firmwareUtils_1.filterSafeListByFirmware)(releases, fwVersion);
|
|
87
86
|
}
|
|
88
87
|
return (0, firmwareUtils_1.filterSafeListByBootloader)(releases, firmwareVersion);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare const models: {
|
|
2
|
+
T1B1: {
|
|
3
|
+
name: string;
|
|
4
|
+
colors: {};
|
|
5
|
+
};
|
|
6
|
+
T2T1: {
|
|
7
|
+
name: string;
|
|
8
|
+
colors: {};
|
|
9
|
+
};
|
|
10
|
+
T2B1: {
|
|
11
|
+
name: string;
|
|
12
|
+
colors: {
|
|
13
|
+
'0': string;
|
|
14
|
+
'1': string;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=models.d.ts.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.models = void 0;
|
|
4
|
+
exports.models = {
|
|
5
|
+
T1B1: {
|
|
6
|
+
name: 'Trezor Model One',
|
|
7
|
+
colors: {},
|
|
8
|
+
},
|
|
9
|
+
T2T1: {
|
|
10
|
+
name: 'Trezor Model T',
|
|
11
|
+
colors: {},
|
|
12
|
+
},
|
|
13
|
+
T2B1: {
|
|
14
|
+
name: 'Trezor Model R',
|
|
15
|
+
colors: {
|
|
16
|
+
'0': 'Black',
|
|
17
|
+
'1': 'White',
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=models.js.map
|
package/lib/data/version.d.ts
CHANGED
package/lib/data/version.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DEFAULT_DOMAIN = exports.VERSION = void 0;
|
|
4
|
-
exports.VERSION = '9.1.
|
|
4
|
+
exports.VERSION = '9.1.4';
|
|
5
5
|
const versionN = exports.VERSION.split('.').map(s => parseInt(s, 10));
|
|
6
6
|
exports.DEFAULT_DOMAIN = `https://connect.trezor.io/${versionN[0]}/`;
|
|
7
7
|
//# sourceMappingURL=version.js.map
|
package/lib/device/Device.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { TypedEmitter } from '@trezor/utils/lib/typedEventEmitter';
|
|
2
|
+
import { Deferred } from '@trezor/utils';
|
|
2
3
|
import { DeviceCommands } from './DeviceCommands';
|
|
3
4
|
import { PROTO, NETWORK } from '../constants';
|
|
4
5
|
import { DEVICE, DeviceButtonRequestPayload } from '../events';
|
|
5
|
-
import { Deferred } from '../utils/deferred';
|
|
6
6
|
import type { Transport, Descriptor } from '@trezor/transport';
|
|
7
7
|
import { Device as DeviceTyped, DeviceFirmwareStatus, Features, ReleaseInfo, UnavailableCapabilities, FirmwareType } from '../types';
|
|
8
8
|
export type RunOptions = {
|
|
@@ -32,7 +32,7 @@ export declare class Device extends TypedEmitter<DeviceEvents> {
|
|
|
32
32
|
featuresNeedsReload: boolean;
|
|
33
33
|
acquirePromise?: ReturnType<Transport['acquire']>;
|
|
34
34
|
releasePromise?: ReturnType<Transport['release']>;
|
|
35
|
-
runPromise?: Deferred<void
|
|
35
|
+
runPromise?: Deferred<void>;
|
|
36
36
|
loaded: boolean;
|
|
37
37
|
inconsistent: boolean;
|
|
38
38
|
firstRunPromise: Deferred<boolean>;
|
|
@@ -45,6 +45,8 @@ export declare class Device extends TypedEmitter<DeviceEvents> {
|
|
|
45
45
|
unavailableCapabilities: UnavailableCapabilities;
|
|
46
46
|
networkTypeState: NETWORK.NetworkType[];
|
|
47
47
|
firmwareType?: FirmwareType;
|
|
48
|
+
name: string;
|
|
49
|
+
color?: string;
|
|
48
50
|
constructor(transport: Transport, descriptor: Descriptor);
|
|
49
51
|
static fromDescriptor(transport: Transport, originalDescriptor: Descriptor): Device;
|
|
50
52
|
static createUnacquired(transport: Transport, descriptor: Descriptor, unreadableError?: string): Device;
|