@trezor/connect 9.6.1-beta.1 → 9.6.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 +12 -12
- package/README.md +1 -1
- package/lib/api/eos/eosSignTx.d.ts +3 -3
- package/lib/api/getAccountInfo.d.ts +1 -1
- package/lib/api/getAddress.d.ts +1 -0
- package/lib/api/getAddress.js +1 -0
- package/lib/api/signTransaction.js +6 -1
- package/lib/backend/fees/BitcoinFeeLevels.d.ts +2 -3
- package/lib/backend/fees/BitcoinFeeLevels.js +11 -73
- package/lib/backend/fees/EthereumFeeLevels.d.ts +1 -2
- package/lib/backend/fees/EthereumFeeLevels.js +0 -1
- package/lib/backend/fees/MiscFeeLevels.d.ts +0 -2
- package/lib/backend/fees/MiscFeeLevels.js +2 -2
- package/lib/core/AbstractMethod.d.ts +1 -1
- package/lib/core/AbstractMethod.js +1 -0
- package/lib/data/defaultFeeLevels.d.ts +1 -0
- package/lib/data/defaultFeeLevels.js +4 -2
- package/lib/data/version.d.ts +1 -1
- package/lib/data/version.js +1 -1
- package/lib/device/Device.d.ts +1 -1
- package/lib/device/Device.js +12 -11
- package/lib/device/workflow/validateState.js +8 -1
- package/lib/events/index.d.ts +1 -0
- package/lib/events/ui-request.d.ts +7 -0
- package/lib/events/ui-request.js +1 -0
- package/lib/types/device.d.ts +3 -4
- package/lib/types/params.d.ts +1 -0
- package/package.json +13 -13
package/CHANGELOG.md
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
| Package | Stable |
|
|
2
|
-
| :------------------------------: | :----: |
|
|
3
|
-
| npm @trezor/connect | 9.6.
|
|
4
|
-
| npm @trezor/connect-web | 9.6.
|
|
5
|
-
| npm @trezor/connect-webextension | 9.6.
|
|
6
|
-
| npm @trezor/connect-mobile | 9.6.
|
|
1
|
+
| Package | Stable | Canary |
|
|
2
|
+
| :------------------------------: | :----: | :----: |
|
|
3
|
+
| npm @trezor/connect | 9.6.1 | - |
|
|
4
|
+
| npm @trezor/connect-web | 9.6.1 | - |
|
|
5
|
+
| npm @trezor/connect-webextension | 9.6.1 | - |
|
|
6
|
+
| npm @trezor/connect-mobile | 9.6.1 | - |
|
|
7
7
|
|
|
8
|
-
| Deployment | Stable |
|
|
9
|
-
| :----------------: | :----: |
|
|
10
|
-
| connect.trezor.io/ | 9.6.
|
|
8
|
+
| Deployment | Stable | Canary |
|
|
9
|
+
| :----------------: | :----: | :----: |
|
|
10
|
+
| connect.trezor.io/ | 9.6.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
|
|
14
|
+
# 9.6.1
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
Minor improvements and fixes regarding the [New Connect flow in Trezor Suite](https://connect.trezor.io/9/guides/new-connect-flow-in-trezor-suite/).
|
|
17
17
|
|
|
18
18
|
## Fixes
|
|
19
19
|
|
|
@@ -43,7 +43,7 @@ This is a special beta release where we allow temporarily remove firmware versio
|
|
|
43
43
|
# 9.6.0
|
|
44
44
|
|
|
45
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.
|
|
46
|
-
To learn more, please take a look at the full [New Connect flow in Trezor Suite](https://connect.trezor.io/9
|
|
46
|
+
To learn more, please take a look at the full [New Connect flow in Trezor Suite](https://connect.trezor.io/9/guides/new-connect-flow-in-trezor-suite/) article.
|
|
47
47
|
We encourage you to try out the new flow to make sure everything works as expected. If you encounter any issues, please let us know.
|
|
48
48
|
|
|
49
49
|
This requires one change in the manifest - there is an additional required field `appName` that is used in the permission prompt. Optionally, you can also provide an `appIcon` which will be shown in the future.
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @trezor/connect
|
|
2
2
|
|
|
3
|
-
API version 9.6.1
|
|
3
|
+
API version 9.6.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)
|
|
@@ -81,8 +81,8 @@ export declare const validate: (tx: EosSDKTransaction) => {
|
|
|
81
81
|
parent: string;
|
|
82
82
|
auth: {
|
|
83
83
|
keys: {
|
|
84
|
-
type?: number | undefined;
|
|
85
84
|
address_n?: number[] | undefined;
|
|
85
|
+
type?: number | undefined;
|
|
86
86
|
weight: number;
|
|
87
87
|
key: string;
|
|
88
88
|
}[];
|
|
@@ -119,8 +119,8 @@ export declare const validate: (tx: EosSDKTransaction) => {
|
|
|
119
119
|
name: string;
|
|
120
120
|
owner: {
|
|
121
121
|
keys: {
|
|
122
|
-
type?: number | undefined;
|
|
123
122
|
address_n?: number[] | undefined;
|
|
123
|
+
type?: number | undefined;
|
|
124
124
|
weight: number;
|
|
125
125
|
key: string;
|
|
126
126
|
}[];
|
|
@@ -140,8 +140,8 @@ export declare const validate: (tx: EosSDKTransaction) => {
|
|
|
140
140
|
creator: string;
|
|
141
141
|
active: {
|
|
142
142
|
keys: {
|
|
143
|
-
type?: number | undefined;
|
|
144
143
|
address_n?: number[] | undefined;
|
|
144
|
+
type?: number | undefined;
|
|
145
145
|
weight: number;
|
|
146
146
|
key: string;
|
|
147
147
|
}[];
|
|
@@ -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-device_firmware_unsupported" | "ui-device_firmware_not_compatible" | "ui-device_firmware_not_installed" | undefined;
|
|
27
|
+
checkFirmwareRange(): "ui-device_firmware_old" | "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/getAddress.d.ts
CHANGED
package/lib/api/getAddress.js
CHANGED
|
@@ -51,6 +51,11 @@ class SignTransaction extends AbstractMethod_1.AbstractMethod {
|
|
|
51
51
|
this.preauthorized = payload.preauthorized;
|
|
52
52
|
const inputs = (0, bitcoin_1.validateTrezorInputs)(payload.inputs, coinInfo);
|
|
53
53
|
const outputs = (0, bitcoin_1.validateTrezorOutputs)(payload.outputs, coinInfo);
|
|
54
|
+
if (payload.paymentRequests && payload.paymentRequests.length > 0) {
|
|
55
|
+
outputs.forEach(output => {
|
|
56
|
+
output.payment_req_index = 0;
|
|
57
|
+
});
|
|
58
|
+
}
|
|
54
59
|
if (payload.refTxs && payload.account?.transactions) {
|
|
55
60
|
console.warn('two sources of referential transactions were passed. payload.refTxs have precedence');
|
|
56
61
|
}
|
|
@@ -72,7 +77,7 @@ class SignTransaction extends AbstractMethod_1.AbstractMethod {
|
|
|
72
77
|
this.params = {
|
|
73
78
|
inputs,
|
|
74
79
|
outputs,
|
|
75
|
-
paymentRequests: payload.paymentRequests
|
|
80
|
+
paymentRequests: payload.paymentRequests ?? [],
|
|
76
81
|
refTxs,
|
|
77
82
|
addresses: payload.account ? payload.account.addresses : undefined,
|
|
78
83
|
options: {
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import type { BitcoinNetworkInfo } from '../../types';
|
|
2
2
|
import { Blockchain } from '../Blockchain';
|
|
3
|
-
import {
|
|
3
|
+
import { MiscFeeLevels } from './MiscFeeLevels';
|
|
4
4
|
export declare class BitcoinFeeLevels extends MiscFeeLevels {
|
|
5
5
|
coinInfo: BitcoinNetworkInfo;
|
|
6
|
-
longTermFeeRate
|
|
7
|
-
blocks: Blocks;
|
|
6
|
+
longTermFeeRate: string;
|
|
8
7
|
constructor(coinInfo: BitcoinNetworkInfo);
|
|
9
8
|
load(blockchain: Blockchain): Promise<{
|
|
10
9
|
feePerTx?: string | undefined;
|
|
@@ -3,88 +3,27 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.BitcoinFeeLevels = void 0;
|
|
4
4
|
const bigNumber_1 = require("@trezor/utils/lib/bigNumber");
|
|
5
5
|
const MiscFeeLevels_1 = require("./MiscFeeLevels");
|
|
6
|
-
const
|
|
7
|
-
const fee = new bigNumber_1.BigNumber(feePerUnit);
|
|
8
|
-
const lower = blocks.find(block => typeof block === 'string' && fee.gte(block));
|
|
9
|
-
if (!lower)
|
|
10
|
-
return -1;
|
|
11
|
-
return blocks.indexOf(lower);
|
|
12
|
-
};
|
|
13
|
-
const convertFeeRate = (fee, minFee) => {
|
|
14
|
-
const feePerKB = new bigNumber_1.BigNumber(fee);
|
|
15
|
-
if (feePerKB.isNaN() || feePerKB.lte('0'))
|
|
16
|
-
return;
|
|
17
|
-
const feePerB = feePerKB.div(1000);
|
|
18
|
-
if (feePerB.lt(minFee))
|
|
19
|
-
return minFee.toString();
|
|
20
|
-
return feePerB.isInteger() ? feePerB.toString() : feePerB.toFixed(2);
|
|
21
|
-
};
|
|
22
|
-
const fillGap = (from, step, size) => {
|
|
23
|
-
const fill = [];
|
|
24
|
-
for (let i = from + step; i <= from + size; i += step) {
|
|
25
|
-
fill.push(i);
|
|
26
|
-
}
|
|
27
|
-
return fill;
|
|
28
|
-
};
|
|
29
|
-
const findNearest = (requested, blocks) => {
|
|
30
|
-
if (typeof blocks[requested] === 'string')
|
|
31
|
-
return blocks[requested];
|
|
32
|
-
const len = blocks.length;
|
|
33
|
-
let index = requested;
|
|
34
|
-
while (typeof blocks[index] !== 'string' && index < len) {
|
|
35
|
-
index++;
|
|
36
|
-
}
|
|
37
|
-
if (typeof blocks[index] === 'string') {
|
|
38
|
-
return blocks[index];
|
|
39
|
-
}
|
|
40
|
-
index = requested;
|
|
41
|
-
while (typeof blocks[index] !== 'string' && index > 0) {
|
|
42
|
-
index--;
|
|
43
|
-
}
|
|
44
|
-
return blocks[index];
|
|
45
|
-
};
|
|
46
|
-
const findLowest = (blocks) => blocks
|
|
47
|
-
.slice(0)
|
|
48
|
-
.reverse()
|
|
49
|
-
.find(item => typeof item === 'string');
|
|
6
|
+
const defaultFeeLevels_1 = require("../../data/defaultFeeLevels");
|
|
50
7
|
class BitcoinFeeLevels extends MiscFeeLevels_1.MiscFeeLevels {
|
|
51
8
|
coinInfo;
|
|
52
9
|
longTermFeeRate;
|
|
53
|
-
blocks = [];
|
|
54
10
|
constructor(coinInfo) {
|
|
55
11
|
super(coinInfo);
|
|
56
12
|
this.coinInfo = coinInfo;
|
|
13
|
+
this.longTermFeeRate = defaultFeeLevels_1.DEFAULT_BITCOIN_LONGTERM_FEE_RATE;
|
|
57
14
|
}
|
|
58
15
|
async load(blockchain) {
|
|
59
|
-
let blocks = fillGap(0, 1, 10);
|
|
60
|
-
if (this.levels.length > 1) {
|
|
61
|
-
blocks = this.levels
|
|
62
|
-
.map(l => l.blocks)
|
|
63
|
-
.reduce((result, bl) => {
|
|
64
|
-
if (result.length === 0)
|
|
65
|
-
return result.concat([bl]);
|
|
66
|
-
const from = result[result.length - 1];
|
|
67
|
-
const gap = bl - from;
|
|
68
|
-
const incr = gap <= 30 ? 1 : 6;
|
|
69
|
-
const fill = fillGap(from, incr, gap);
|
|
70
|
-
return result.concat(fill);
|
|
71
|
-
}, []);
|
|
72
|
-
}
|
|
73
|
-
const oneDayBlocks = 6 * 24;
|
|
74
|
-
blocks.push(...fillGap(oneDayBlocks, oneDayBlocks / 2, oneDayBlocks * 6));
|
|
75
16
|
try {
|
|
17
|
+
const { minFee, maxFee } = this.coinInfo;
|
|
18
|
+
const blocks = this.levels.map(level => level.blocks).filter(b => b > 0);
|
|
76
19
|
const response = await blockchain.estimateFee({ blocks });
|
|
77
|
-
response.forEach(({ feePerUnit }, index) => {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
-
level.blocks = this.blocks.indexOf(updatedValue);
|
|
84
|
-
level.feePerUnit = updatedValue;
|
|
85
|
-
}
|
|
20
|
+
response.forEach(({ feePerUnit: feePerKB }, index) => {
|
|
21
|
+
const feePerB = new bigNumber_1.BigNumber(feePerKB).div(1000).toNumber();
|
|
22
|
+
if (isNaN(feePerB) || feePerB < 0)
|
|
23
|
+
return;
|
|
24
|
+
const trimmedFeePerUnit = Math.min(maxFee, Math.max(minFee, feePerB));
|
|
25
|
+
this.levels[index].feePerUnit = trimmedFeePerUnit.toString();
|
|
86
26
|
});
|
|
87
|
-
this.longTermFeeRate = findLowest(this.blocks);
|
|
88
27
|
this.wasFetchedSuccessfully = true;
|
|
89
28
|
}
|
|
90
29
|
catch {
|
|
@@ -93,11 +32,10 @@ class BitcoinFeeLevels extends MiscFeeLevels_1.MiscFeeLevels {
|
|
|
93
32
|
}
|
|
94
33
|
updateBitcoinCustomFee(feePerUnit) {
|
|
95
34
|
this.levels = this.levels.filter(l => l.label !== 'custom');
|
|
96
|
-
const blocks = findBlocksForFee(feePerUnit, this.blocks);
|
|
97
35
|
this.levels.push({
|
|
98
36
|
label: 'custom',
|
|
99
37
|
feePerUnit,
|
|
100
|
-
blocks,
|
|
38
|
+
blocks: -1,
|
|
101
39
|
});
|
|
102
40
|
}
|
|
103
41
|
}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import type { EthereumNetworkInfo } from '../../types';
|
|
2
2
|
import { Blockchain } from '../Blockchain';
|
|
3
|
-
import {
|
|
3
|
+
import { MiscFeeLevels } from './MiscFeeLevels';
|
|
4
4
|
export declare class EthereumFeeLevels extends MiscFeeLevels {
|
|
5
5
|
coinInfo: EthereumNetworkInfo;
|
|
6
|
-
blocks: Blocks;
|
|
7
6
|
constructor(coinInfo: EthereumNetworkInfo);
|
|
8
7
|
load(blockchain: Blockchain, request: Parameters<typeof blockchain.estimateFee>[0]): Promise<{
|
|
9
8
|
feePerTx?: string | undefined;
|
|
@@ -5,7 +5,6 @@ const bigNumber_1 = require("@trezor/utils/lib/bigNumber");
|
|
|
5
5
|
const MiscFeeLevels_1 = require("./MiscFeeLevels");
|
|
6
6
|
class EthereumFeeLevels extends MiscFeeLevels_1.MiscFeeLevels {
|
|
7
7
|
coinInfo;
|
|
8
|
-
blocks = [];
|
|
9
8
|
constructor(coinInfo) {
|
|
10
9
|
super(coinInfo);
|
|
11
10
|
this.coinInfo = coinInfo;
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import type { CoinInfo, FeeLevel } from '../../types';
|
|
2
2
|
import { Blockchain } from '../Blockchain';
|
|
3
|
-
export type Blocks = Array<string | undefined>;
|
|
4
3
|
export declare class MiscFeeLevels {
|
|
5
4
|
coinInfo: CoinInfo;
|
|
6
5
|
levels: FeeLevel[];
|
|
7
|
-
blocks: Blocks;
|
|
8
6
|
wasFetchedSuccessfully: boolean;
|
|
9
7
|
constructor(coinInfo: CoinInfo);
|
|
10
8
|
load(blockchain: Blockchain, request: Parameters<typeof blockchain.estimateFee>[0]): Promise<{
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MiscFeeLevels = void 0;
|
|
4
4
|
const bigNumber_1 = require("@trezor/utils/lib/bigNumber");
|
|
5
|
+
const cloneObject_1 = require("@trezor/utils/lib/cloneObject");
|
|
5
6
|
class MiscFeeLevels {
|
|
6
7
|
coinInfo;
|
|
7
8
|
levels;
|
|
8
|
-
blocks = [];
|
|
9
9
|
wasFetchedSuccessfully = false;
|
|
10
10
|
constructor(coinInfo) {
|
|
11
11
|
this.coinInfo = coinInfo;
|
|
12
|
-
this.levels = coinInfo.defaultFees;
|
|
12
|
+
this.levels = (0, cloneObject_1.cloneObject)(coinInfo.defaultFees);
|
|
13
13
|
}
|
|
14
14
|
async load(blockchain, request) {
|
|
15
15
|
try {
|
|
@@ -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-device_firmware_unsupported" | "ui-device_firmware_not_compatible" | "ui-device_firmware_not_installed" | undefined;
|
|
64
|
+
checkFirmwareRange(): "ui-device_firmware_old" | "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<{
|
|
@@ -200,6 +200,7 @@ 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;
|
|
203
204
|
}
|
|
204
205
|
if (range.max !== '0' && utils_1.versionUtils.isNewer(version, range.max)) {
|
|
205
206
|
return events_1.UI.FIRMWARE_NOT_COMPATIBLE;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getMiscFeeLevels = exports.getEthereumFeeLevels = exports.getBitcoinFeeLevels = void 0;
|
|
3
|
+
exports.getMiscFeeLevels = exports.getEthereumFeeLevels = exports.getBitcoinFeeLevels = exports.DEFAULT_BITCOIN_LONGTERM_FEE_RATE = void 0;
|
|
4
4
|
const utils_1 = require("@trezor/utils");
|
|
5
5
|
const BLOCKS_FOR_FEE_LEVEL = {
|
|
6
6
|
btc: {
|
|
@@ -10,9 +10,11 @@ const BLOCKS_FOR_FEE_LEVEL = {
|
|
|
10
10
|
low: 36,
|
|
11
11
|
},
|
|
12
12
|
};
|
|
13
|
+
const DEFAULT_BLOCK_FOR_FEE_LEVEL = 1;
|
|
13
14
|
const getDefaultBlocksForFeeLevel = (shortcut, label) => BLOCKS_FOR_FEE_LEVEL[shortcut] && BLOCKS_FOR_FEE_LEVEL[shortcut][label]
|
|
14
15
|
? BLOCKS_FOR_FEE_LEVEL[shortcut][label]
|
|
15
|
-
:
|
|
16
|
+
: DEFAULT_BLOCK_FOR_FEE_LEVEL;
|
|
17
|
+
exports.DEFAULT_BITCOIN_LONGTERM_FEE_RATE = '1';
|
|
16
18
|
const EVM_GAS_PRICE_PER_CHAIN_IN_GWEI = {
|
|
17
19
|
eth: { min: 0.1, max: 10000, defaultGas: 10, minPriorityFee: 0 },
|
|
18
20
|
pol: { min: 0.1, max: 10000000, defaultGas: 200, minPriorityFee: 30 },
|
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.DEEPLINK_VERSION = exports.CONTENT_SCRIPT_VERSION = exports.DEFAULT_DOMAIN = exports.VERSION = void 0;
|
|
4
|
-
exports.VERSION = '9.6.1
|
|
4
|
+
exports.VERSION = '9.6.1';
|
|
5
5
|
const versionN = exports.VERSION.split('.').map(s => parseInt(s, 10));
|
|
6
6
|
const isBeta = exports.VERSION.includes('beta');
|
|
7
7
|
exports.DEFAULT_DOMAIN = isBeta
|
package/lib/device/Device.d.ts
CHANGED
|
@@ -63,7 +63,7 @@ export declare class Device extends TypedEmitter<DeviceEvents> {
|
|
|
63
63
|
id: string;
|
|
64
64
|
} | undefined;
|
|
65
65
|
private thp;
|
|
66
|
-
private readonly
|
|
66
|
+
private readonly possibleHIDdevice;
|
|
67
67
|
private sessionAcquired;
|
|
68
68
|
private _protocol;
|
|
69
69
|
get protocol(): TransportProtocol;
|
package/lib/device/Device.js
CHANGED
|
@@ -28,7 +28,7 @@ class Device extends utils_1.TypedEmitter {
|
|
|
28
28
|
transportPath;
|
|
29
29
|
bluetoothProps;
|
|
30
30
|
thp;
|
|
31
|
-
|
|
31
|
+
possibleHIDdevice;
|
|
32
32
|
sessionAcquired;
|
|
33
33
|
_protocol;
|
|
34
34
|
get protocol() {
|
|
@@ -86,7 +86,7 @@ class Device extends utils_1.TypedEmitter {
|
|
|
86
86
|
this.uniquePath = id;
|
|
87
87
|
this.transport = transport;
|
|
88
88
|
this.transportPath = descriptor.path;
|
|
89
|
-
this.
|
|
89
|
+
this.possibleHIDdevice = [0, 2].includes(descriptor.type);
|
|
90
90
|
this.bluetoothProps = descriptor.id ? { id: descriptor.id } : undefined;
|
|
91
91
|
this.sessionAcquired = null;
|
|
92
92
|
transport.on(transport_1.TRANSPORT.STOPPED, this.onTransportStopped);
|
|
@@ -195,15 +195,17 @@ class Device extends utils_1.TypedEmitter {
|
|
|
195
195
|
error.message === transport_1.TRANSPORT_ERROR.DEVICE_DISCONNECTED_DURING_ACTION ||
|
|
196
196
|
error.message === transport_1.TRANSPORT_ERROR.HTTP_ERROR) {
|
|
197
197
|
}
|
|
198
|
-
else if (
|
|
199
|
-
error.message === transport_1.TRANSPORT_ERROR.
|
|
200
|
-
error.
|
|
201
|
-
|
|
198
|
+
else if ((this.possibleHIDdevice &&
|
|
199
|
+
error.message === transport_1.TRANSPORT_ERROR.INTERFACE_UNABLE_TO_OPEN_DEVICE) ||
|
|
200
|
+
error.message === transport_1.TRANSPORT_ERROR.LIBUSB_ERROR_ACCESS) {
|
|
201
|
+
this.unreadableError = error.message;
|
|
202
202
|
this.emitLifecycle(events_1.DEVICE.CONNECT_UNACQUIRED);
|
|
203
203
|
}
|
|
204
204
|
else if (error.message === transport_1.TRANSPORT_ERROR.INTERFACE_UNABLE_TO_OPEN_DEVICE ||
|
|
205
|
-
error.message
|
|
206
|
-
|
|
205
|
+
error.message === transport_1.TRANSPORT_ERROR.UNEXPECTED_ERROR ||
|
|
206
|
+
error.message === transport_1.TRANSPORT_ERROR.SESSION_WRONG_PREVIOUS ||
|
|
207
|
+
error.code === 'Device_UsedElsewhere' ||
|
|
208
|
+
error.code === 'Device_InitializeFailed') {
|
|
207
209
|
this.emitLifecycle(events_1.DEVICE.CONNECT_UNACQUIRED);
|
|
208
210
|
}
|
|
209
211
|
else {
|
|
@@ -297,8 +299,7 @@ class Device extends utils_1.TypedEmitter {
|
|
|
297
299
|
const cancelTimeout = isNative
|
|
298
300
|
? exports.GET_FEATURES_TIMEOUT_REACT_NATIVE
|
|
299
301
|
: exports.CANCEL_TIMEOUT;
|
|
300
|
-
if (['v1', 'bridge'].includes(this.protocol.name) &&
|
|
301
|
-
![0, 2].includes(this.transportDescriptorType)) {
|
|
302
|
+
if (['v1', 'bridge'].includes(this.protocol.name) && !this.possibleHIDdevice) {
|
|
302
303
|
_log.debug('sending a preventive cancel on the first encounter with the device');
|
|
303
304
|
await Promise.race([
|
|
304
305
|
this.getCurrentSession().cancelCall(),
|
|
@@ -710,7 +711,7 @@ class Device extends utils_1.TypedEmitter {
|
|
|
710
711
|
type: 'unreadable',
|
|
711
712
|
error: this.unreadableError,
|
|
712
713
|
label: 'Unreadable device',
|
|
713
|
-
|
|
714
|
+
hid: this.possibleHIDdevice,
|
|
714
715
|
};
|
|
715
716
|
}
|
|
716
717
|
if (this.isUnacquired()) {
|
|
@@ -45,7 +45,14 @@ const getInvalidDeviceState = async (context) => {
|
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
|
-
return getState(context)
|
|
48
|
+
return getState(context).catch(error => {
|
|
49
|
+
if (error.message.includes('PIN invalid')) {
|
|
50
|
+
context.method.postMessage((0, events_1.createUiMessage)(events_1.UI.INVALID_PIN_ATTEMPTS_DEPLETED, {
|
|
51
|
+
device: context.device.toMessageObject(),
|
|
52
|
+
}));
|
|
53
|
+
}
|
|
54
|
+
throw error;
|
|
55
|
+
});
|
|
49
56
|
};
|
|
50
57
|
const validateState = async (context) => {
|
|
51
58
|
const { device, method } = context;
|
package/lib/events/index.d.ts
CHANGED
|
@@ -45,6 +45,7 @@ export declare const UI: {
|
|
|
45
45
|
readonly REQUEST_CONFIRMATION: "ui-request_confirmation";
|
|
46
46
|
readonly REQUEST_PIN: "ui-request_pin";
|
|
47
47
|
readonly INVALID_PIN: "ui-invalid_pin";
|
|
48
|
+
readonly INVALID_PIN_ATTEMPTS_DEPLETED: "ui-invalid_pin_attempts_depleted";
|
|
48
49
|
readonly REQUEST_PASSPHRASE: "ui-request_passphrase";
|
|
49
50
|
readonly REQUEST_PASSPHRASE_ON_DEVICE: "ui-request_passphrase_on_device";
|
|
50
51
|
readonly INVALID_PASSPHRASE: "ui-invalid_passphrase";
|
|
@@ -30,6 +30,7 @@ export declare const UI_REQUEST: {
|
|
|
30
30
|
readonly REQUEST_CONFIRMATION: "ui-request_confirmation";
|
|
31
31
|
readonly REQUEST_PIN: "ui-request_pin";
|
|
32
32
|
readonly INVALID_PIN: "ui-invalid_pin";
|
|
33
|
+
readonly INVALID_PIN_ATTEMPTS_DEPLETED: "ui-invalid_pin_attempts_depleted";
|
|
33
34
|
readonly REQUEST_PASSPHRASE: "ui-request_passphrase";
|
|
34
35
|
readonly REQUEST_PASSPHRASE_ON_DEVICE: "ui-request_passphrase_on_device";
|
|
35
36
|
readonly INVALID_PASSPHRASE: "ui-invalid_passphrase";
|
|
@@ -89,6 +90,12 @@ export type UiRequestDeviceAction = {
|
|
|
89
90
|
device: Device;
|
|
90
91
|
type?: typeof undefined;
|
|
91
92
|
};
|
|
93
|
+
} | {
|
|
94
|
+
type: typeof UI_REQUEST.INVALID_PIN_ATTEMPTS_DEPLETED;
|
|
95
|
+
payload: {
|
|
96
|
+
device: Device;
|
|
97
|
+
type?: typeof undefined;
|
|
98
|
+
};
|
|
92
99
|
} | {
|
|
93
100
|
type: typeof UI_REQUEST.REQUEST_PASSPHRASE_ON_DEVICE;
|
|
94
101
|
payload: {
|
package/lib/events/ui-request.js
CHANGED
|
@@ -25,6 +25,7 @@ exports.UI_REQUEST = {
|
|
|
25
25
|
REQUEST_CONFIRMATION: 'ui-request_confirmation',
|
|
26
26
|
REQUEST_PIN: 'ui-request_pin',
|
|
27
27
|
INVALID_PIN: 'ui-invalid_pin',
|
|
28
|
+
INVALID_PIN_ATTEMPTS_DEPLETED: 'ui-invalid_pin_attempts_depleted',
|
|
28
29
|
REQUEST_PASSPHRASE: 'ui-request_passphrase',
|
|
29
30
|
REQUEST_PASSPHRASE_ON_DEVICE: 'ui-request_passphrase_on_device',
|
|
30
31
|
INVALID_PASSPHRASE: 'ui-invalid_passphrase',
|
package/lib/types/device.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { FeaturesNarrowing, FirmwareType } from '@trezor/device-utils';
|
|
2
2
|
import type { ThpStateSerialized } from '@trezor/protocol';
|
|
3
|
-
import { Descriptor } from '@trezor/transport';
|
|
4
3
|
import type { PROTO } from '../constants';
|
|
5
4
|
import type { ReleaseInfo } from './firmware';
|
|
6
5
|
export type DeviceStatus = 'available' | 'occupied' | 'used';
|
|
@@ -68,7 +67,7 @@ export type KnownDevice = BaseDevice & {
|
|
|
68
67
|
firmwareHash: FirmwareHashCheckResult | null;
|
|
69
68
|
};
|
|
70
69
|
transportSessionOwner?: undefined;
|
|
71
|
-
|
|
70
|
+
hid?: undefined;
|
|
72
71
|
bluetoothProps?: BluetoothDeviceProps;
|
|
73
72
|
};
|
|
74
73
|
export type UnknownDevice = BaseDevice & {
|
|
@@ -89,7 +88,7 @@ export type UnknownDevice = BaseDevice & {
|
|
|
89
88
|
unavailableCapabilities?: typeof undefined;
|
|
90
89
|
availableTranslations?: typeof undefined;
|
|
91
90
|
transportSessionOwner?: string;
|
|
92
|
-
|
|
91
|
+
hid?: undefined;
|
|
93
92
|
bluetoothProps?: BluetoothDeviceProps;
|
|
94
93
|
};
|
|
95
94
|
export type UnreadableDevice = BaseDevice & {
|
|
@@ -110,7 +109,7 @@ export type UnreadableDevice = BaseDevice & {
|
|
|
110
109
|
unavailableCapabilities?: typeof undefined;
|
|
111
110
|
availableTranslations?: typeof undefined;
|
|
112
111
|
transportSessionOwner?: undefined;
|
|
113
|
-
|
|
112
|
+
hid: boolean;
|
|
114
113
|
bluetoothProps?: BluetoothDeviceProps;
|
|
115
114
|
};
|
|
116
115
|
export type Device = KnownDevice | UnknownDevice | UnreadableDevice;
|
package/lib/types/params.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trezor/connect",
|
|
3
|
-
"version": "9.6.1
|
|
3
|
+
"version": "9.6.1",
|
|
4
4
|
"author": "Trezor <info@trezor.io>",
|
|
5
5
|
"homepage": "https://github.com/trezor/trezor-suite/tree/develop/packages/connect",
|
|
6
6
|
"description": "High-level javascript interface for Trezor hardware wallet.",
|
|
@@ -79,20 +79,20 @@
|
|
|
79
79
|
"@solana-program/token": "^0.5.1",
|
|
80
80
|
"@solana-program/token-2022": "^0.4.2",
|
|
81
81
|
"@solana/kit": "^2.1.1",
|
|
82
|
-
"@trezor/blockchain-link": "2.5.1
|
|
83
|
-
"@trezor/blockchain-link-types": "1.4.1
|
|
84
|
-
"@trezor/blockchain-link-utils": "1.4.1
|
|
85
|
-
"@trezor/connect-analytics": "1.3.4
|
|
86
|
-
"@trezor/connect-common": "0.4.1
|
|
82
|
+
"@trezor/blockchain-link": "2.5.1",
|
|
83
|
+
"@trezor/blockchain-link-types": "1.4.1",
|
|
84
|
+
"@trezor/blockchain-link-utils": "1.4.1",
|
|
85
|
+
"@trezor/connect-analytics": "1.3.4",
|
|
86
|
+
"@trezor/connect-common": "0.4.1",
|
|
87
87
|
"@trezor/crypto-utils": "1.1.3",
|
|
88
|
-
"@trezor/device-utils": "1.1.1
|
|
89
|
-
"@trezor/protobuf": "1.4.1
|
|
90
|
-
"@trezor/protocol": "1.2.7
|
|
88
|
+
"@trezor/device-utils": "1.1.1",
|
|
89
|
+
"@trezor/protobuf": "1.4.1",
|
|
90
|
+
"@trezor/protocol": "1.2.7",
|
|
91
91
|
"@trezor/schema-utils": "1.3.3",
|
|
92
|
-
"@trezor/transport": "1.5.1
|
|
93
|
-
"@trezor/type-utils": "1.1.7
|
|
94
|
-
"@trezor/utils": "9.4.1
|
|
95
|
-
"@trezor/utxo-lib": "2.4.
|
|
92
|
+
"@trezor/transport": "1.5.1",
|
|
93
|
+
"@trezor/type-utils": "1.1.7",
|
|
94
|
+
"@trezor/utils": "9.4.1",
|
|
95
|
+
"@trezor/utxo-lib": "2.4.1",
|
|
96
96
|
"blakejs": "^1.2.1",
|
|
97
97
|
"bs58": "^6.0.0",
|
|
98
98
|
"bs58check": "^4.0.0",
|