@trezor/connect 9.6.0 → 9.6.1-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +36 -7
- package/README.md +1 -1
- package/lib/api/blockchainEstimateFee.js +1 -0
- package/lib/api/discoverAccounts.js +10 -2
- package/lib/api/ethereum/api/ethereumSignMessage.js +1 -1
- package/lib/api/ethereum/api/ethereumSignTypedData.d.ts +1 -1
- package/lib/api/firmware/getBinary.js +2 -2
- package/lib/api/getAccountInfo.d.ts +1 -1
- package/lib/api/getCoinInfo.d.ts +3 -3
- package/lib/api/getNonce.d.ts +9 -0
- package/lib/api/getNonce.js +15 -0
- package/lib/api/index.d.ts +1 -0
- package/lib/api/index.js +4 -2
- package/lib/api/nem/nemSignTx.d.ts +1 -1
- package/lib/api/resetDevice.d.ts +2 -3
- package/lib/api/resetDevice.js +47 -49
- package/lib/api/signMessage.js +1 -1
- package/lib/backend/Blockchain.d.ts +1 -0
- package/lib/backend/fees/BitcoinFeeLevels.d.ts +0 -1
- package/lib/backend/fees/EthereumFeeLevels.d.ts +0 -1
- package/lib/backend/fees/EthereumFeeLevels.js +8 -4
- package/lib/backend/fees/MiscFeeLevels.d.ts +0 -1
- package/lib/constants/errors.d.ts +1 -0
- package/lib/constants/errors.js +1 -0
- package/lib/core/AbstractMethod.d.ts +2 -2
- package/lib/core/AbstractMethod.js +0 -1
- package/lib/core/index.js +43 -53
- package/lib/core/onCallFirmwareUpdate.js +2 -2
- package/lib/data/coinInfo.d.ts +11 -11
- package/lib/data/coinInfo.js +1 -1
- package/lib/data/connectSettings.js +0 -3
- package/lib/data/defaultFeeLevels.d.ts +2 -1
- package/lib/data/defaultFeeLevels.js +18 -10
- package/lib/data/deviceAuthenticityConfig.js +4 -1
- package/lib/data/firmwareInfo.d.ts +1 -0
- package/lib/data/firmwareInfo.js +14 -1
- package/lib/data/version.d.ts +1 -1
- package/lib/data/version.js +1 -1
- package/lib/device/Device.d.ts +19 -20
- package/lib/device/Device.js +66 -112
- package/lib/device/DeviceCurrentSession.d.ts +441 -4027
- package/lib/device/DeviceCurrentSession.js +75 -44
- package/lib/device/DeviceList.d.ts +3 -8
- package/lib/device/DeviceList.js +21 -77
- package/lib/device/TransportManager.d.ts +2 -6
- package/lib/device/TransportManager.js +11 -7
- package/lib/device/checkFirmwareRevision.js +2 -2
- package/lib/device/workflow/index.d.ts +2 -0
- package/lib/device/workflow/index.js +6 -0
- package/lib/device/workflow/validateState.d.ts +3 -0
- package/lib/device/workflow/validateState.js +90 -0
- package/lib/events/device.d.ts +19 -1
- package/lib/events/device.js +2 -0
- package/lib/events/index.d.ts +3 -0
- package/lib/events/ui-request.d.ts +17 -3
- package/lib/events/ui-request.js +2 -0
- package/lib/events/ui-response.d.ts +11 -1
- package/lib/events/ui-response.js +1 -0
- package/lib/factory.js +1 -0
- package/lib/tsconfig.lib.tsbuildinfo +1 -1
- package/lib/types/api/applySettings.d.ts +1 -0
- package/lib/types/api/discoverAccounts.d.ts +17 -4
- package/lib/types/api/discoverAccounts.js +2 -0
- package/lib/types/api/getNonce.d.ts +4 -0
- package/lib/types/api/getNonce.js +3 -0
- package/lib/types/api/index.d.ts +2 -0
- package/lib/types/coinInfo.d.ts +6 -6
- package/lib/types/coinInfo.js +2 -0
- package/lib/types/fees.d.ts +1 -1
- package/lib/types/fees.js +1 -1
- package/lib/types/settings.d.ts +0 -1
- package/lib/types/workflow.d.ts +8 -0
- package/lib/types/workflow.js +3 -0
- package/lib/utils/formatUtils.d.ts +1 -0
- package/lib/utils/formatUtils.js +9 -1
- package/lib/utils/uiPromiseManager.d.ts +2 -0
- package/package.json +16 -16
- package/lib/data/downloadReleasesMetadata.d.ts +0 -7
- package/lib/data/downloadReleasesMetadata.js +0 -18
- package/lib/data/models.d.ts +0 -8
- package/lib/data/models.js +0 -49
package/CHANGELOG.md
CHANGED
|
@@ -1,16 +1,45 @@
|
|
|
1
1
|
| Package | Stable | Canary |
|
|
2
2
|
| :------------------------------: | :----: | :----------: |
|
|
3
|
-
| npm @trezor/connect | 9.6.0 |
|
|
4
|
-
| npm @trezor/connect-web | 9.6.0 |
|
|
5
|
-
| npm @trezor/connect-webextension | 9.6.0 |
|
|
6
|
-
| npm @trezor/connect-mobile |
|
|
3
|
+
| npm @trezor/connect | 9.6.0 | 9.6.1-beta.1 |
|
|
4
|
+
| npm @trezor/connect-web | 9.6.0 | 9.6.1-beta.1 |
|
|
5
|
+
| npm @trezor/connect-webextension | 9.6.0 | 9.6.1-beta.1 |
|
|
6
|
+
| npm @trezor/connect-mobile | 9.6.0 | 9.6.1-beta.1 |
|
|
7
7
|
|
|
8
|
-
| Deployment | Stable |
|
|
9
|
-
| :----------------: | :----: |
|
|
10
|
-
| connect.trezor.io/ | 9.6.0 |
|
|
8
|
+
| Deployment | Stable | Canary |
|
|
9
|
+
| :----------------: | :----: | :----------: |
|
|
10
|
+
| connect.trezor.io/ | 9.6.0 | 9.6.1-beta.1 |
|
|
11
11
|
|
|
12
12
|
Use the persistent link [connect.trezor.io/9](https://connect.trezor.io/9/) to access the latest stable version of Connect Explorer.
|
|
13
13
|
|
|
14
|
+
# 9.6.1-beta.1
|
|
15
|
+
|
|
16
|
+
This is a special beta release where we allow temporarily remove firmware version check. We do so to let users stuck with old devices that can't update their firmwares to send their funds out.
|
|
17
|
+
|
|
18
|
+
## Fixes
|
|
19
|
+
|
|
20
|
+
- Webusb sync between tabs in browser fixed in connect-popup (dd50a1a, f558513, cdd73c5)
|
|
21
|
+
- fix(connect-web): empty settings in init in suite-desktop mode (3f61be1)
|
|
22
|
+
|
|
23
|
+
## Features
|
|
24
|
+
|
|
25
|
+
- Works on the new communication protocol continue:
|
|
26
|
+
- feat(connect): add ThpState and ThpMessageResponse to DeviceCurrentSession (5919fe9)
|
|
27
|
+
- feat(connect): add UI response for THP pairing tag (6084994)
|
|
28
|
+
- feat(connect): add getNonce (72a1417)
|
|
29
|
+
- feat(connect): decode hex in message signing (2f41cc6)
|
|
30
|
+
- feat(connect-mobile): add appName and appIcon to deeplink (7f96299)
|
|
31
|
+
- feat(connect-explorer): add appIcon (04dd6d6)
|
|
32
|
+
- feat(connect): add backendType to discovery progress events (a3b804e)
|
|
33
|
+
- feat(connect): track npmVersion in analytics (6cc1058)
|
|
34
|
+
|
|
35
|
+
## Chores
|
|
36
|
+
|
|
37
|
+
- chore: update jest to v30 (6d27a2c)
|
|
38
|
+
- chore: update trends deps (a9f0997)
|
|
39
|
+
- chore: add/remove used/unused packages (60fb96b)
|
|
40
|
+
- chore: add missing workspace libs (bc6a681)
|
|
41
|
+
- refactor(connect): split Device related code to workflow modules (dd9ffde)
|
|
42
|
+
|
|
14
43
|
# 9.6.0
|
|
15
44
|
|
|
16
45
|
Starting with Connect version 9.6.0, we are introducing a new integration with Trezor Suite. The new flow is designed to provide a more seamless and user-friendly experience for users interacting with Trezor devices.
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @trezor/connect
|
|
2
2
|
|
|
3
|
-
API version 9.6.
|
|
3
|
+
API version 9.6.1-beta.1
|
|
4
4
|
|
|
5
5
|
[](https://github.com/trezor/trezor-suite/actions/workflows/test-connect.yml)
|
|
6
6
|
[](https://www.npmjs.org/package/@trezor/connect)
|
|
@@ -51,6 +51,7 @@ class BlockchainEstimateFee extends AbstractMethod_1.AbstractMethod {
|
|
|
51
51
|
blockTime: coinInfo.blockTime,
|
|
52
52
|
minFee: coinInfo.minFee,
|
|
53
53
|
maxFee: coinInfo.maxFee,
|
|
54
|
+
minPriorityFee: coinInfo.minPriorityFee,
|
|
54
55
|
dustLimit: coinInfo.type === 'bitcoin' ? coinInfo.dustLimit : undefined,
|
|
55
56
|
levels: [],
|
|
56
57
|
};
|
|
@@ -157,7 +157,15 @@ class DiscoverAccounts extends AbstractMethod_1.AbstractMethod {
|
|
|
157
157
|
? []
|
|
158
158
|
: await blockchain.getAccountUtxo(descriptor);
|
|
159
159
|
this.updateProgress(accountKey, index + 1, info.empty);
|
|
160
|
-
this.sendProgress({
|
|
160
|
+
this.sendProgress({
|
|
161
|
+
...info,
|
|
162
|
+
descriptor,
|
|
163
|
+
...descRest,
|
|
164
|
+
utxo,
|
|
165
|
+
...accountKey,
|
|
166
|
+
index,
|
|
167
|
+
backendType: request.coinInfo.blockchainLink?.type,
|
|
168
|
+
});
|
|
161
169
|
if (info.empty) {
|
|
162
170
|
await descPromise.catch(() => { });
|
|
163
171
|
return { nonempty: index - skip };
|
|
@@ -166,7 +174,7 @@ class DiscoverAccounts extends AbstractMethod_1.AbstractMethod {
|
|
|
166
174
|
catch (error) {
|
|
167
175
|
descPromise.catch(() => { });
|
|
168
176
|
this.updateProgress(accountKey, index + 1, true);
|
|
169
|
-
this.sendProgress({ ...accountKey, index, error: error.message });
|
|
177
|
+
this.sendProgress({ ...accountKey, index, error: error.message, code: error.code });
|
|
170
178
|
return { nonempty: index - skip, error };
|
|
171
179
|
}
|
|
172
180
|
index++;
|
|
@@ -44,7 +44,7 @@ class EthereumSignMessage extends AbstractMethod_1.AbstractMethod {
|
|
|
44
44
|
type: 'message',
|
|
45
45
|
coin: this.params.network?.shortcut ?? 'ETH',
|
|
46
46
|
serializedPath: (0, pathUtils_1.getSerializedPath)(this.params.address_n),
|
|
47
|
-
message: this.payload.message,
|
|
47
|
+
message: this.payload.hex ? (0, formatUtils_1.hexToText)(this.payload.message) : this.payload.message,
|
|
48
48
|
};
|
|
49
49
|
}
|
|
50
50
|
}
|
|
@@ -74,6 +74,7 @@ declare const Params: import("@trezor/schema-utils").TIntersect<[import("@trezor
|
|
|
74
74
|
blockTime: import("@trezor/schema-utils").TNumber;
|
|
75
75
|
minFee: import("@trezor/schema-utils").TNumber;
|
|
76
76
|
maxFee: import("@trezor/schema-utils").TNumber;
|
|
77
|
+
minPriorityFee: import("@trezor/schema-utils").TNumber;
|
|
77
78
|
defaultFees: import("@trezor/schema-utils").TArray<import("@trezor/schema-utils").TObject<{
|
|
78
79
|
label: import("@trezor/schema-utils").TUnion<[import("@trezor/schema-utils").TLiteral<"high">, import("@trezor/schema-utils").TLiteral<"normal">, import("@trezor/schema-utils").TLiteral<"economy">, import("@trezor/schema-utils").TLiteral<"low">, import("@trezor/schema-utils").TLiteral<"custom">]>;
|
|
79
80
|
blocks: import("@trezor/schema-utils").TNumber;
|
|
@@ -83,7 +84,6 @@ declare const Params: import("@trezor/schema-utils").TIntersect<[import("@trezor
|
|
|
83
84
|
baseFeePerGas: import("@trezor/schema-utils").TOptional<import("@trezor/schema-utils").TString>;
|
|
84
85
|
maxFeePerGas: import("@trezor/schema-utils").TOptional<import("@trezor/schema-utils").TString>;
|
|
85
86
|
maxPriorityFeePerGas: import("@trezor/schema-utils").TOptional<import("@trezor/schema-utils").TString>;
|
|
86
|
-
maxWaitTimeEstimate: import("@trezor/schema-utils").TOptional<import("@trezor/schema-utils").TNumber>;
|
|
87
87
|
}>>;
|
|
88
88
|
}>, import("@trezor/schema-utils").TObject<{
|
|
89
89
|
type: import("@trezor/schema-utils").TLiteral<"ethereum">;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getBinaryOptional = exports.getBinary = void 0;
|
|
4
|
+
const utils_1 = require("@trezor/utils");
|
|
4
5
|
const assets_1 = require("../../utils/assets");
|
|
5
|
-
const ALL_SLASHES_AT_THE_END_REGEX = /\/+$/;
|
|
6
6
|
const getBinary = ({ baseUrl, btcOnly, release }) => {
|
|
7
7
|
const fwUrl = release[btcOnly ? 'url_bitcoinonly' : 'url'];
|
|
8
|
-
const sanitizedBaseUrl =
|
|
8
|
+
const sanitizedBaseUrl = (0, utils_1.removeTrailingSlashes)(baseUrl);
|
|
9
9
|
const url = `${sanitizedBaseUrl}/${fwUrl}`;
|
|
10
10
|
return (0, assets_1.httpRequest)(url, 'binary');
|
|
11
11
|
};
|
|
@@ -24,7 +24,7 @@ export default class GetAccountInfo extends AbstractMethod<'getAccountInfo', Req
|
|
|
24
24
|
label: string;
|
|
25
25
|
customConfirmButton?: undefined;
|
|
26
26
|
};
|
|
27
|
-
checkFirmwareRange(): "ui-
|
|
27
|
+
checkFirmwareRange(): "ui-device_firmware_unsupported" | "ui-device_firmware_not_compatible" | "ui-device_firmware_not_installed" | undefined;
|
|
28
28
|
run(): Promise<AccountInfo | (AccountInfo | null)[] | {
|
|
29
29
|
utxo: AccountUtxo[] | undefined;
|
|
30
30
|
descriptor: string;
|
package/lib/api/getCoinInfo.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export default class GetCoinInfo extends AbstractMethod<'getCoinInfo', Params> {
|
|
|
14
14
|
blockTime: number;
|
|
15
15
|
minFee: number;
|
|
16
16
|
maxFee: number;
|
|
17
|
+
minPriorityFee: number;
|
|
17
18
|
name: string;
|
|
18
19
|
shortcut: string;
|
|
19
20
|
slip44: number;
|
|
@@ -34,7 +35,6 @@ export default class GetCoinInfo extends AbstractMethod<'getCoinInfo', Params> {
|
|
|
34
35
|
baseFeePerGas?: string | undefined;
|
|
35
36
|
maxFeePerGas?: string | undefined;
|
|
36
37
|
maxPriorityFeePerGas?: string | undefined;
|
|
37
|
-
maxWaitTimeEstimate?: number | undefined;
|
|
38
38
|
label: "normal" | "custom" | "high" | "economy" | "low";
|
|
39
39
|
blocks: number;
|
|
40
40
|
feePerUnit: string;
|
|
@@ -77,6 +77,7 @@ export default class GetCoinInfo extends AbstractMethod<'getCoinInfo', Params> {
|
|
|
77
77
|
blockTime: number;
|
|
78
78
|
minFee: number;
|
|
79
79
|
maxFee: number;
|
|
80
|
+
minPriorityFee: number;
|
|
80
81
|
name: string;
|
|
81
82
|
shortcut: string;
|
|
82
83
|
slip44: number;
|
|
@@ -97,7 +98,6 @@ export default class GetCoinInfo extends AbstractMethod<'getCoinInfo', Params> {
|
|
|
97
98
|
baseFeePerGas?: string | undefined;
|
|
98
99
|
maxFeePerGas?: string | undefined;
|
|
99
100
|
maxPriorityFeePerGas?: string | undefined;
|
|
100
|
-
maxWaitTimeEstimate?: number | undefined;
|
|
101
101
|
label: "normal" | "custom" | "high" | "economy" | "low";
|
|
102
102
|
blocks: number;
|
|
103
103
|
feePerUnit: string;
|
|
@@ -115,6 +115,7 @@ export default class GetCoinInfo extends AbstractMethod<'getCoinInfo', Params> {
|
|
|
115
115
|
blockTime: number;
|
|
116
116
|
minFee: number;
|
|
117
117
|
maxFee: number;
|
|
118
|
+
minPriorityFee: number;
|
|
118
119
|
name: string;
|
|
119
120
|
shortcut: string;
|
|
120
121
|
slip44: number;
|
|
@@ -135,7 +136,6 @@ export default class GetCoinInfo extends AbstractMethod<'getCoinInfo', Params> {
|
|
|
135
136
|
baseFeePerGas?: string | undefined;
|
|
136
137
|
maxFeePerGas?: string | undefined;
|
|
137
138
|
maxPriorityFeePerGas?: string | undefined;
|
|
138
|
-
maxWaitTimeEstimate?: number | undefined;
|
|
139
139
|
label: "normal" | "custom" | "high" | "economy" | "low";
|
|
140
140
|
blocks: number;
|
|
141
141
|
feePerUnit: string;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { PROTO } from '../constants';
|
|
2
|
+
import { AbstractMethod } from '../core/AbstractMethod';
|
|
3
|
+
export default class GetNonce extends AbstractMethod<'getNonce', PROTO.GetNonce> {
|
|
4
|
+
init(): void;
|
|
5
|
+
run(): Promise<{
|
|
6
|
+
nonce: string;
|
|
7
|
+
}>;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=getNonce.d.ts.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const AbstractMethod_1 = require("../core/AbstractMethod");
|
|
4
|
+
class GetNonce extends AbstractMethod_1.AbstractMethod {
|
|
5
|
+
init() {
|
|
6
|
+
this.useDeviceState = false;
|
|
7
|
+
}
|
|
8
|
+
async run() {
|
|
9
|
+
const cmd = this.device.getCommands();
|
|
10
|
+
const response = await cmd.typedCall('GetNonce', 'Nonce');
|
|
11
|
+
return response.message;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.default = GetNonce;
|
|
15
|
+
//# sourceMappingURL=getNonce.js.map
|
package/lib/api/index.d.ts
CHANGED
|
@@ -32,6 +32,7 @@ export { default as getCoinInfo } from './getCoinInfo';
|
|
|
32
32
|
export { default as getDeviceState } from './getDeviceState';
|
|
33
33
|
export { default as getFeatures } from './getFeatures';
|
|
34
34
|
export { default as getFirmwareHash } from './getFirmwareHash';
|
|
35
|
+
export { default as getNonce } from './getNonce';
|
|
35
36
|
export { default as getOwnershipId } from './getOwnershipId';
|
|
36
37
|
export { default as getOwnershipProof } from './getOwnershipProof';
|
|
37
38
|
export { default as getPublicKey } from './getPublicKey';
|
package/lib/api/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.wipeDevice = void 0;
|
|
3
|
+
exports.unlockPath = exports.signTransaction = exports.signMessage = exports.setProxy = exports.setBusy = exports.setBrightness = exports.loadDevice = exports.resetDevice = exports.requestLogin = exports.recoveryDevice = exports.pushTransaction = exports.getSettings = exports.getPublicKey = exports.getOwnershipProof = exports.getOwnershipId = exports.getNonce = exports.getFirmwareHash = exports.getFeatures = exports.getDeviceState = exports.getCoinInfo = exports.getAddress = exports.getAccountInfo = exports.getAccountDescriptor = exports.discoverAccounts = exports.composeTransaction = exports.cipherKeyValue = exports.changeWipeCode = exports.changePin = exports.changeLanguage = exports.blockchainUnsubscribeFiatRates = exports.blockchainUnsubscribe = exports.blockchainSubscribeFiatRates = exports.blockchainSubscribe = exports.blockchainSetCustomBackend = exports.blockchainGetTransactions = exports.blockchainGetFiatRatesForTimestamps = exports.blockchainEvmRpcCall = exports.blockchainGetInfo = exports.blockchainGetCurrentFiatRates = exports.blockchainGetAccountBalanceHistory = exports.blockchainEstimateFee = exports.blockchainDisconnect = exports.bleUnpair = exports.backupDevice = exports.showDeviceTutorial = exports.cancelCoinjoinAuthorization = exports.authorizeCoinjoin = exports.authenticateDevice = exports.applySettings = exports.applyFlags = void 0;
|
|
4
|
+
exports.wipeDevice = exports.verifyMessage = void 0;
|
|
5
5
|
const tslib_1 = require("tslib");
|
|
6
6
|
var applyFlags_1 = require("./applyFlags");
|
|
7
7
|
Object.defineProperty(exports, "applyFlags", { enumerable: true, get: function () { return tslib_1.__importDefault(applyFlags_1).default; } });
|
|
@@ -71,6 +71,8 @@ var getFeatures_1 = require("./getFeatures");
|
|
|
71
71
|
Object.defineProperty(exports, "getFeatures", { enumerable: true, get: function () { return tslib_1.__importDefault(getFeatures_1).default; } });
|
|
72
72
|
var getFirmwareHash_1 = require("./getFirmwareHash");
|
|
73
73
|
Object.defineProperty(exports, "getFirmwareHash", { enumerable: true, get: function () { return tslib_1.__importDefault(getFirmwareHash_1).default; } });
|
|
74
|
+
var getNonce_1 = require("./getNonce");
|
|
75
|
+
Object.defineProperty(exports, "getNonce", { enumerable: true, get: function () { return tslib_1.__importDefault(getNonce_1).default; } });
|
|
74
76
|
var getOwnershipId_1 = require("./getOwnershipId");
|
|
75
77
|
Object.defineProperty(exports, "getOwnershipId", { enumerable: true, get: function () { return tslib_1.__importDefault(getOwnershipId_1).default; } });
|
|
76
78
|
var getOwnershipProof_1 = require("./getOwnershipProof");
|
|
@@ -37,13 +37,13 @@ export declare const createTx: (tx: $T.NEMTransaction, address_n: number[], chun
|
|
|
37
37
|
levy?: PROTO.NEMMosaicLevy | undefined;
|
|
38
38
|
divisibility?: number | undefined;
|
|
39
39
|
transferable?: boolean | undefined;
|
|
40
|
+
networks?: number[] | undefined;
|
|
40
41
|
ticker?: string | undefined;
|
|
41
42
|
levy_address?: string | undefined;
|
|
42
43
|
levy_namespace?: string | undefined;
|
|
43
44
|
levy_mosaic?: string | undefined;
|
|
44
45
|
supply?: number | undefined;
|
|
45
46
|
mutable_supply?: boolean | undefined;
|
|
46
|
-
networks?: number[] | undefined;
|
|
47
47
|
description: string;
|
|
48
48
|
namespace: string;
|
|
49
49
|
mosaic: string;
|
package/lib/api/resetDevice.d.ts
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import { PROTO } from '../constants';
|
|
2
2
|
import { AbstractMethod } from '../core/AbstractMethod';
|
|
3
3
|
export default class ResetDevice extends AbstractMethod<'resetDevice', PROTO.ResetDevice> {
|
|
4
|
-
private isEntropyCheckSuccessful;
|
|
5
4
|
init(): void;
|
|
6
5
|
get info(): string;
|
|
7
6
|
get confirmation(): {
|
|
8
7
|
view: "device-management";
|
|
9
8
|
label: string;
|
|
10
9
|
};
|
|
11
|
-
private
|
|
12
|
-
private
|
|
10
|
+
private resetDeviceWorkflow;
|
|
11
|
+
private entropyCheckWorkflow;
|
|
13
12
|
run(): Promise<{
|
|
14
13
|
message: string;
|
|
15
14
|
}>;
|
package/lib/api/resetDevice.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const schema_utils_1 = require("@trezor/schema-utils");
|
|
4
|
-
const errors_groups_1 = require("@trezor/transport/lib/errors-groups");
|
|
5
4
|
const utils_1 = require("@trezor/utils");
|
|
6
5
|
const verifyEntropy_1 = require("../api/firmware/verifyEntropy");
|
|
7
6
|
const constants_1 = require("../constants");
|
|
@@ -10,7 +9,6 @@ const events_1 = require("../events");
|
|
|
10
9
|
const paramsValidator_1 = require("./common/paramsValidator");
|
|
11
10
|
const pathUtils_1 = require("../utils/pathUtils");
|
|
12
11
|
class ResetDevice extends AbstractMethod_1.AbstractMethod {
|
|
13
|
-
isEntropyCheckSuccessful = false;
|
|
14
12
|
init() {
|
|
15
13
|
this.allowDeviceMode = [events_1.UI.INITIALIZE, events_1.UI.SEEDLESS];
|
|
16
14
|
this.useDeviceState = false;
|
|
@@ -40,65 +38,65 @@ class ResetDevice extends AbstractMethod_1.AbstractMethod {
|
|
|
40
38
|
label: 'Do you really you want to create a new wallet?',
|
|
41
39
|
};
|
|
42
40
|
}
|
|
43
|
-
async
|
|
41
|
+
async resetDeviceWorkflow() {
|
|
44
42
|
const cmd = this.device.getCommands();
|
|
45
43
|
const entropy = (0, verifyEntropy_1.generateEntropy)(32).toString('hex');
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
await cmd.typedCall('EntropyAck', ['EntropyCheckReady', 'Success'], { entropy });
|
|
49
|
-
return {
|
|
50
|
-
...entropyRequest.message,
|
|
51
|
-
host_entropy: entropy,
|
|
52
|
-
};
|
|
44
|
+
await cmd.typedCall('ResetDevice', 'EntropyRequest', this.params);
|
|
45
|
+
await cmd.typedCall('EntropyAck', 'Success', { entropy });
|
|
53
46
|
}
|
|
54
|
-
async
|
|
47
|
+
async entropyCheckWorkflow() {
|
|
55
48
|
const cmd = this.device.getCommands();
|
|
56
49
|
const paths = ["m/84'/0'/0'", "m/44'/60'/0'"];
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
50
|
+
const handleErr = (error) => {
|
|
51
|
+
throw error.cause === 'transport-error'
|
|
52
|
+
? error
|
|
53
|
+
: constants_1.ERRORS.TypedError('Failure_EntropyCheck', error.message);
|
|
54
|
+
};
|
|
55
|
+
let entropy = (0, verifyEntropy_1.generateEntropy)(32).toString('hex');
|
|
56
|
+
let commitment = await cmd
|
|
57
|
+
.typedCall('ResetDevice', 'EntropyRequest', this.params)
|
|
58
|
+
.then(response => response.message.entropy_commitment);
|
|
59
|
+
await cmd.typedCall('EntropyAck', 'EntropyCheckReady', { entropy });
|
|
60
|
+
const tries = (0, utils_1.getRandomInt)(1, 5);
|
|
61
|
+
for (let i = 0; i < tries; i++) {
|
|
62
|
+
const xpubs = {};
|
|
63
|
+
for (const path of paths) {
|
|
64
|
+
const pubKey = await cmd
|
|
65
|
+
.getPublicKey({ address_n: (0, pathUtils_1.validatePath)(path) })
|
|
66
|
+
.catch(handleErr);
|
|
67
|
+
xpubs[path] = pubKey.xpub;
|
|
68
|
+
}
|
|
69
|
+
const { prev_entropy, entropy_commitment } = await cmd
|
|
70
|
+
.typedCall('EntropyCheckContinue', 'EntropyRequest', {})
|
|
71
|
+
.then(response => response.message)
|
|
72
|
+
.catch(handleErr);
|
|
73
|
+
const res = await (0, verifyEntropy_1.verifyEntropy)({
|
|
74
|
+
type: this.params.backup_type,
|
|
75
|
+
strength: this.params.strength,
|
|
76
|
+
commitment,
|
|
77
|
+
hostEntropy: entropy,
|
|
78
|
+
trezorEntropy: prev_entropy,
|
|
79
|
+
xpubs,
|
|
80
|
+
});
|
|
81
|
+
if (res.error) {
|
|
82
|
+
await this.device.getCurrentSession().cancelCall();
|
|
83
|
+
throw constants_1.ERRORS.TypedError('Failure_EntropyCheck', res.error);
|
|
84
|
+
}
|
|
85
|
+
entropy = (0, verifyEntropy_1.generateEntropy)(32).toString('hex');
|
|
86
|
+
commitment = entropy_commitment;
|
|
87
|
+
await cmd.typedCall('EntropyAck', 'EntropyCheckReady', { entropy }).catch(handleErr);
|
|
75
88
|
}
|
|
76
|
-
|
|
89
|
+
await cmd.typedCall('EntropyCheckContinue', 'Success', { finish: true });
|
|
77
90
|
}
|
|
78
91
|
async run() {
|
|
79
|
-
const cmd = this.device.getCommands();
|
|
80
92
|
if (this.params.entropy_check && this.device.unavailableCapabilities['entropyCheck']) {
|
|
81
93
|
this.params.entropy_check = false;
|
|
82
94
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
if (this.params.entropy_check) {
|
|
86
|
-
const tries = (0, utils_1.getRandomInt)(1, 5);
|
|
87
|
-
for (let i = 0; i < tries; i++) {
|
|
88
|
-
entropyData = await this.entropyCheck(entropyData);
|
|
89
|
-
}
|
|
90
|
-
this.isEntropyCheckSuccessful = true;
|
|
91
|
-
await cmd.typedCall('EntropyCheckContinue', 'Success', { finish: true });
|
|
92
|
-
}
|
|
95
|
+
if (this.params.entropy_check) {
|
|
96
|
+
await this.entropyCheckWorkflow();
|
|
93
97
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
errors_groups_1.ERRORS_WITHOUT_DEVICE_INTERACTION.includes(error.message)) {
|
|
97
|
-
throw error;
|
|
98
|
-
}
|
|
99
|
-
if (this.isEntropyCheckSuccessful === true)
|
|
100
|
-
throw error;
|
|
101
|
-
throw constants_1.ERRORS.TypedError('Failure_EntropyCheck', error.message);
|
|
98
|
+
else {
|
|
99
|
+
await this.resetDeviceWorkflow();
|
|
102
100
|
}
|
|
103
101
|
return { message: 'Success' };
|
|
104
102
|
}
|
package/lib/api/signMessage.js
CHANGED
|
@@ -44,7 +44,7 @@ class SignMessage extends AbstractMethod_1.AbstractMethod {
|
|
|
44
44
|
type: 'message',
|
|
45
45
|
serializedPath: (0, pathUtils_1.getSerializedPath)(this.params.address_n.slice(0, 4)),
|
|
46
46
|
coin: this.coinInfo?.shortcut ?? 'BTC',
|
|
47
|
-
message: this.payload.message,
|
|
47
|
+
message: this.payload.hex ? (0, formatUtils_1.hexToText)(this.payload.message) : this.payload.message,
|
|
48
48
|
};
|
|
49
49
|
}
|
|
50
50
|
}
|
|
@@ -51,6 +51,7 @@ export declare class Blockchain {
|
|
|
51
51
|
estimateFee(request: Parameters<typeof this.link.estimateFee>[0]): Promise<{
|
|
52
52
|
feePerUnit: string;
|
|
53
53
|
feePerTx?: string;
|
|
54
|
+
feePayer?: string;
|
|
54
55
|
feeLimit?: string;
|
|
55
56
|
eip1559?: import("@trezor/blockchain-link-types/lib/blockbook-api").Eip1559Fees;
|
|
56
57
|
}[]>;
|
|
@@ -12,7 +12,6 @@ export declare class BitcoinFeeLevels extends MiscFeeLevels {
|
|
|
12
12
|
baseFeePerGas?: string | undefined;
|
|
13
13
|
maxFeePerGas?: string | undefined;
|
|
14
14
|
maxPriorityFeePerGas?: string | undefined;
|
|
15
|
-
maxWaitTimeEstimate?: number | undefined;
|
|
16
15
|
label: "normal" | "custom" | "high" | "economy" | "low";
|
|
17
16
|
blocks: number;
|
|
18
17
|
feePerUnit: string;
|
|
@@ -11,7 +11,6 @@ export declare class EthereumFeeLevels extends MiscFeeLevels {
|
|
|
11
11
|
baseFeePerGas?: string | undefined;
|
|
12
12
|
maxFeePerGas?: string | undefined;
|
|
13
13
|
maxPriorityFeePerGas?: string | undefined;
|
|
14
|
-
maxWaitTimeEstimate?: number | undefined;
|
|
15
14
|
label: "normal" | "custom" | "high" | "economy" | "low";
|
|
16
15
|
blocks: number;
|
|
17
16
|
feePerUnit: string;
|
|
@@ -19,21 +19,25 @@ class EthereumFeeLevels extends MiscFeeLevels_1.MiscFeeLevels {
|
|
|
19
19
|
const feeInWei = new bigNumber_1.BigNumber(response.feePerUnit).toNumber();
|
|
20
20
|
const feePerUnit = Math.min(maxFeeInWei, Math.max(minFeeInWei, feeInWei)).toString();
|
|
21
21
|
if (eip1559?.baseFeePerGas) {
|
|
22
|
+
const minMaxPriorityFeePerGas = new bigNumber_1.BigNumber(this.coinInfo.minPriorityFee)
|
|
23
|
+
.multipliedBy('1e+9')
|
|
24
|
+
.toNumber();
|
|
22
25
|
const levels = ['low', 'medium', 'high'].map(levelKey => {
|
|
23
26
|
const level = eip1559[levelKey];
|
|
24
27
|
const label = levelKey === 'medium' ? 'normal' : levelKey;
|
|
25
28
|
if (!level?.maxFeePerGas || !level?.maxPriorityFeePerGas) {
|
|
26
29
|
return null;
|
|
27
30
|
}
|
|
31
|
+
const maxFeePerGas = bigNumber_1.BigNumber.max(this.coinInfo.minFee, level.maxFeePerGas, minMaxPriorityFeePerGas).toString();
|
|
32
|
+
const maxPriorityFeePerGas = bigNumber_1.BigNumber.max(minMaxPriorityFeePerGas, bigNumber_1.BigNumber.min(maxFeePerGas, level.maxPriorityFeePerGas)).toString();
|
|
28
33
|
return {
|
|
29
34
|
label,
|
|
30
35
|
feePerUnit,
|
|
31
36
|
feeLimit: response.feeLimit,
|
|
32
|
-
blocks:
|
|
37
|
+
blocks: Math.ceil(Math.max(1, (level?.maxWaitTimeEstimate || 0) / 1000 / this.coinInfo.blockTime)),
|
|
33
38
|
baseFeePerGas: eip1559.baseFeePerGas,
|
|
34
|
-
maxFeePerGas
|
|
35
|
-
maxPriorityFeePerGas
|
|
36
|
-
maxWaitTimeEstimate: level?.maxWaitTimeEstimate,
|
|
39
|
+
maxFeePerGas,
|
|
40
|
+
maxPriorityFeePerGas,
|
|
37
41
|
};
|
|
38
42
|
});
|
|
39
43
|
this.levels = levels.filter(level => level);
|
|
@@ -13,7 +13,6 @@ export declare class MiscFeeLevels {
|
|
|
13
13
|
baseFeePerGas?: string | undefined;
|
|
14
14
|
maxFeePerGas?: string | undefined;
|
|
15
15
|
maxPriorityFeePerGas?: string | undefined;
|
|
16
|
-
maxWaitTimeEstimate?: number | undefined;
|
|
17
16
|
label: "normal" | "custom" | "high" | "economy" | "low";
|
|
18
17
|
blocks: number;
|
|
19
18
|
feePerUnit: string;
|
|
@@ -35,6 +35,7 @@ export declare const ERROR_CODES: {
|
|
|
35
35
|
readonly Device_MultipleNotSupported: "Multiple devices are not supported";
|
|
36
36
|
readonly Device_MissingCapability: "Device is missing capability";
|
|
37
37
|
readonly Device_MissingCapabilityBtcOnly: "Device is missing capability (BTC only)";
|
|
38
|
+
readonly Device_ThpPairingTagInvalid: "Pairing tag mismatch";
|
|
38
39
|
readonly Failure_ActionCancelled: "Action cancelled by user";
|
|
39
40
|
readonly Failure_FirmwareError: "Firmware installation failed";
|
|
40
41
|
readonly Failure_UnknownCode: "Unknown error";
|
package/lib/constants/errors.js
CHANGED
|
@@ -38,6 +38,7 @@ exports.ERROR_CODES = {
|
|
|
38
38
|
Device_MultipleNotSupported: 'Multiple devices are not supported',
|
|
39
39
|
Device_MissingCapability: 'Device is missing capability',
|
|
40
40
|
Device_MissingCapabilityBtcOnly: 'Device is missing capability (BTC only)',
|
|
41
|
+
Device_ThpPairingTagInvalid: 'Pairing tag mismatch',
|
|
41
42
|
Failure_ActionCancelled: 'Action cancelled by user',
|
|
42
43
|
Failure_FirmwareError: 'Firmware installation failed',
|
|
43
44
|
Failure_UnknownCode: 'Unknown error',
|
|
@@ -61,7 +61,7 @@ export declare abstract class AbstractMethod<Name extends CallMethodPayload['met
|
|
|
61
61
|
private getOriginPermissions;
|
|
62
62
|
checkPermissions({ origin }: Pick<ConnectSettings, 'origin'>): void;
|
|
63
63
|
savePermissions(temporary: boolean | undefined, { origin }: Pick<ConnectSettings, 'origin'>): void;
|
|
64
|
-
checkFirmwareRange(): "ui-
|
|
64
|
+
checkFirmwareRange(): "ui-device_firmware_unsupported" | "ui-device_firmware_not_compatible" | "ui-device_firmware_not_installed" | undefined;
|
|
65
65
|
isManagementRestricted({ popup, origin }: Pick<ConnectSettings, 'popup' | 'origin'>): boolean | undefined;
|
|
66
66
|
abstract init(): void;
|
|
67
67
|
getMethodInfo(): Promise<{
|
|
@@ -72,7 +72,7 @@ export declare abstract class AbstractMethod<Name extends CallMethodPayload['met
|
|
|
72
72
|
requiredPermissions: MethodPermission[];
|
|
73
73
|
info: string;
|
|
74
74
|
confirmation: {
|
|
75
|
-
view: "no-backup" | "export-xpub" | "export-address" | "export-account-info" | "device-management";
|
|
75
|
+
view: "thp-pairing-start" | "thp-pairing-failed" | "no-backup" | "export-xpub" | "export-address" | "export-account-info" | "device-management";
|
|
76
76
|
label?: string;
|
|
77
77
|
customConfirmButton?: {
|
|
78
78
|
className: string;
|
|
@@ -200,7 +200,6 @@ class AbstractMethod {
|
|
|
200
200
|
this.name !== 'recoveryDevice' &&
|
|
201
201
|
(device.firmwareStatus === 'required' ||
|
|
202
202
|
!utils_1.versionUtils.isNewerOrEqual(version, range.min))) {
|
|
203
|
-
return events_1.UI.FIRMWARE_OLD;
|
|
204
203
|
}
|
|
205
204
|
if (range.max !== '0' && utils_1.versionUtils.isNewer(version, range.max)) {
|
|
206
205
|
return events_1.UI.FIRMWARE_NOT_COMPATIBLE;
|