@trezor/connect 9.5.3 → 9.5.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 +38 -4
- package/README.md +1 -1
- package/lib/api/binance/api/binanceSignTransaction.js +1 -1
- package/lib/api/bitcoin/BitcoinFees.d.ts +4 -6
- package/lib/api/bitcoin/BitcoinFees.js +8 -2
- package/lib/api/bitcoin/signtxVerify.d.ts +1 -1
- package/lib/api/bitcoin/signtxVerify.js +3 -3
- package/lib/api/blockchainEstimateFee.js +13 -13
- package/lib/api/cardano/api/cardanoSignTransaction.js +1 -1
- package/lib/api/common/Discovery.d.ts +4 -4
- package/lib/api/common/Discovery.js +3 -4
- package/lib/api/common/MiscFees.d.ts +5 -9
- package/lib/api/common/MiscFees.js +6 -21
- package/lib/api/composeTransaction.js +4 -3
- package/lib/api/eos/api/eosSignTransaction.js +1 -1
- package/lib/api/eos/eosSignTx.d.ts +2 -2
- package/lib/api/ethereum/EthereumFees.d.ts +5 -8
- package/lib/api/ethereum/EthereumFees.js +24 -38
- package/lib/api/ethereum/api/ethereumGetAddress.d.ts +1 -5
- package/lib/api/ethereum/api/ethereumGetAddress.js +7 -8
- package/lib/api/ethereum/api/ethereumGetPublicKey.d.ts +11 -7
- package/lib/api/ethereum/api/ethereumGetPublicKey.js +12 -5
- package/lib/api/ethereum/api/ethereumSignTransaction.js +2 -2
- package/lib/api/ethereum/api/ethereumSignTypedData.d.ts +2 -4
- package/lib/api/ethereum/api/ethereumSignTypedData.js +1 -1
- package/lib/api/firmware/uploadFirmware.d.ts +2 -2
- package/lib/api/getAccountDescriptor.js +1 -3
- package/lib/api/getAccountInfo.js +4 -9
- package/lib/api/getAddress.js +6 -7
- package/lib/api/getCoinInfo.d.ts +12 -18
- package/lib/api/getPublicKey.d.ts +11 -7
- package/lib/api/resetDevice.js +1 -3
- package/lib/api/signTransaction.js +3 -3
- package/lib/api/stellar/api/stellarSignTransaction.js +1 -1
- package/lib/constants/errors.d.ts +1 -2
- package/lib/constants/errors.js +8 -3
- package/lib/core/index.js +36 -15
- package/lib/core/onCallFirmwareUpdate.js +6 -3
- package/lib/data/coinInfo.d.ts +44 -66
- package/lib/data/config.d.ts +10 -0
- package/lib/data/config.js +10 -0
- package/lib/data/deviceAuthenticityConfig.js +4 -1
- package/lib/data/version.d.ts +1 -1
- package/lib/data/version.js +1 -1
- package/lib/device/Device.d.ts +82 -16
- package/lib/device/Device.js +51 -61
- package/lib/device/DeviceCommands.d.ts +37 -4549
- package/lib/device/DeviceCommands.js +55 -264
- package/lib/device/DeviceCurrentSession.d.ts +4531 -0
- package/lib/device/DeviceCurrentSession.js +209 -0
- package/lib/device/DeviceList.js +4 -6
- package/lib/device/TransportManager.d.ts +1 -1
- package/lib/device/TransportManager.js +5 -4
- package/lib/events/ui-response.d.ts +3 -3
- package/lib/impl/dynamic.d.ts +4 -1
- package/lib/impl/dynamic.js +17 -4
- package/lib/tsconfig.lib.tsbuildinfo +1 -1
- package/lib/types/api/getPublicKey.d.ts +5 -3
- package/lib/types/api/getPublicKey.js +13 -12
- package/lib/types/coinInfo.d.ts +12 -24
- package/lib/types/fees.d.ts +2 -11
- package/lib/types/fees.js +3 -11
- package/lib/utils/versionCheck.js +1 -1
- package/package.json +9 -9
- package/lib/device/prompts.d.ts +0 -866
- package/lib/device/prompts.js +0 -60
|
@@ -76,16 +76,14 @@ declare const Params: import("@trezor/schema-utils").TIntersect<[import("@trezor
|
|
|
76
76
|
maxFee: import("@trezor/schema-utils").TNumber;
|
|
77
77
|
defaultFees: import("@trezor/schema-utils").TArray<import("@trezor/schema-utils").TObject<{
|
|
78
78
|
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
|
-
feePerUnit: import("@trezor/schema-utils").TString;
|
|
80
79
|
blocks: import("@trezor/schema-utils").TNumber;
|
|
81
|
-
|
|
80
|
+
feePerUnit: import("@trezor/schema-utils").TString;
|
|
82
81
|
feePerTx: import("@trezor/schema-utils").TOptional<import("@trezor/schema-utils").TString>;
|
|
82
|
+
feeLimit: import("@trezor/schema-utils").TOptional<import("@trezor/schema-utils").TString>;
|
|
83
83
|
baseFeePerGas: import("@trezor/schema-utils").TOptional<import("@trezor/schema-utils").TString>;
|
|
84
84
|
maxFeePerGas: import("@trezor/schema-utils").TOptional<import("@trezor/schema-utils").TString>;
|
|
85
|
-
effectiveGasPrice: import("@trezor/schema-utils").TOptional<import("@trezor/schema-utils").TString>;
|
|
86
85
|
maxPriorityFeePerGas: import("@trezor/schema-utils").TOptional<import("@trezor/schema-utils").TString>;
|
|
87
86
|
maxWaitTimeEstimate: import("@trezor/schema-utils").TOptional<import("@trezor/schema-utils").TNumber>;
|
|
88
|
-
minWaitTimeEstimate: import("@trezor/schema-utils").TOptional<import("@trezor/schema-utils").TNumber>;
|
|
89
87
|
}>>;
|
|
90
88
|
}>, import("@trezor/schema-utils").TObject<{
|
|
91
89
|
type: import("@trezor/schema-utils").TLiteral<"ethereum">;
|
|
@@ -153,7 +153,7 @@ class EthereumSignTypedData extends AbstractMethod_1.AbstractMethod {
|
|
|
153
153
|
memberData = memberData[memberTypeDefinition.name];
|
|
154
154
|
}
|
|
155
155
|
if (memberData === null || memberData === undefined) {
|
|
156
|
-
|
|
156
|
+
this.device.getCurrentSession().cancelCall();
|
|
157
157
|
throw constants_1.ERRORS.TypedError('Runtime', `Value from member path ${member_path} is missing in the data object`);
|
|
158
158
|
}
|
|
159
159
|
}
|
|
@@ -3,11 +3,11 @@ import type { Device } from '../../device/Device';
|
|
|
3
3
|
import type { TypedCall } from '../../device/DeviceCommands';
|
|
4
4
|
import { CoreEventMessage } from '../../events';
|
|
5
5
|
export declare const uploadFirmware: (typedCall: TypedCall, postMessage: (message: CoreEventMessage) => void, device: Device, { payload }: PROTO.FirmwareUpload) => Promise<{
|
|
6
|
+
message: string;
|
|
7
|
+
} | {
|
|
6
8
|
type: "Success";
|
|
7
9
|
message: {
|
|
8
10
|
message: string;
|
|
9
11
|
};
|
|
10
|
-
} | {
|
|
11
|
-
message: string;
|
|
12
12
|
}>;
|
|
13
13
|
//# sourceMappingURL=uploadFirmware.d.ts.map
|
|
@@ -109,9 +109,7 @@ class GetAccountDescriptor extends AbstractMethod_1.AbstractMethod {
|
|
|
109
109
|
try {
|
|
110
110
|
const { descriptor, address_n, legacyXpub } = await this.device
|
|
111
111
|
.getCommands()
|
|
112
|
-
.getAccountDescriptor(request.coinInfo, request.address_n,
|
|
113
|
-
? request.derivationType
|
|
114
|
-
: constants_1.PROTO.CardanoDerivationType.ICARUS_TREZOR);
|
|
112
|
+
.getAccountDescriptor(request.coinInfo, request.address_n, request.derivationType);
|
|
115
113
|
const response = {
|
|
116
114
|
descriptor,
|
|
117
115
|
path: (0, pathUtils_1.getSerializedPath)(address_n),
|
|
@@ -144,7 +144,7 @@ class GetAccountInfo extends AbstractMethod_1.AbstractMethod {
|
|
|
144
144
|
}
|
|
145
145
|
const responses = [];
|
|
146
146
|
const sendProgress = (progress, response, error) => {
|
|
147
|
-
if (!this.hasBundle ||
|
|
147
|
+
if (!this.hasBundle || this.device?.getCurrentSession().isDisposed())
|
|
148
148
|
return;
|
|
149
149
|
this.postMessage((0, events_1.createUiMessage)(events_1.UI.BUNDLE_PROGRESS, {
|
|
150
150
|
total: this.params.length,
|
|
@@ -165,9 +165,7 @@ class GetAccountInfo extends AbstractMethod_1.AbstractMethod {
|
|
|
165
165
|
try {
|
|
166
166
|
const accountDescriptor = await this.device
|
|
167
167
|
.getCommands()
|
|
168
|
-
.getAccountDescriptor(request.coinInfo, address_n,
|
|
169
|
-
? request.derivationType
|
|
170
|
-
: constants_1.PROTO.CardanoDerivationType.ICARUS_TREZOR);
|
|
168
|
+
.getAccountDescriptor(request.coinInfo, address_n, request.derivationType);
|
|
171
169
|
if (accountDescriptor) {
|
|
172
170
|
descriptor = accountDescriptor.descriptor;
|
|
173
171
|
legacyXpub = accountDescriptor.legacyXpub;
|
|
@@ -244,15 +242,12 @@ class GetAccountInfo extends AbstractMethod_1.AbstractMethod {
|
|
|
244
242
|
return this.hasBundle ? responses : responses[0];
|
|
245
243
|
}
|
|
246
244
|
async discover(request) {
|
|
247
|
-
const { coinInfo, identity, defaultAccountType } = request;
|
|
245
|
+
const { coinInfo, identity, defaultAccountType, derivationType } = request;
|
|
248
246
|
const blockchain = await (0, BlockchainLink_1.initBlockchain)(coinInfo, this.postMessage, identity);
|
|
249
247
|
const dfd = this.createUiPromise(events_1.UI.RECEIVE_ACCOUNT);
|
|
250
248
|
const discovery = new Discovery_1.Discovery({
|
|
251
249
|
blockchain,
|
|
252
|
-
|
|
253
|
-
derivationType: typeof request.derivationType !== 'undefined'
|
|
254
|
-
? request.derivationType
|
|
255
|
-
: constants_1.PROTO.CardanoDerivationType.ICARUS_TREZOR,
|
|
250
|
+
getDescriptor: path => this.device.getCommands().getAccountDescriptor(coinInfo, path, derivationType),
|
|
256
251
|
});
|
|
257
252
|
discovery.on('progress', accounts => {
|
|
258
253
|
this.postMessage((0, events_1.createUiMessage)(events_1.UI.SELECT_ACCOUNT, {
|
package/lib/api/getAddress.js
CHANGED
|
@@ -94,13 +94,12 @@ class GetAddress extends AbstractMethod_1.AbstractMethod {
|
|
|
94
94
|
if (unlockPath) {
|
|
95
95
|
await cmd.unlockPath(unlockPath);
|
|
96
96
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
}, coinInfo);
|
|
97
|
+
const response = await cmd.getAddress({ address_n, show_display, multisig, script_type, chunkify }, coinInfo);
|
|
98
|
+
return {
|
|
99
|
+
path: address_n,
|
|
100
|
+
serializedPath: (0, pathUtils_1.getSerializedPath)(address_n),
|
|
101
|
+
address: response.address,
|
|
102
|
+
};
|
|
104
103
|
}
|
|
105
104
|
async run() {
|
|
106
105
|
const responses = [];
|
package/lib/api/getCoinInfo.d.ts
CHANGED
|
@@ -29,17 +29,15 @@ export default class GetCoinInfo extends AbstractMethod<'getCoinInfo', Params> {
|
|
|
29
29
|
};
|
|
30
30
|
decimals: number;
|
|
31
31
|
defaultFees: {
|
|
32
|
+
feePerTx?: string | undefined;
|
|
33
|
+
feeLimit?: string | undefined;
|
|
34
|
+
baseFeePerGas?: string | undefined;
|
|
32
35
|
maxFeePerGas?: string | undefined;
|
|
33
36
|
maxPriorityFeePerGas?: string | undefined;
|
|
34
37
|
maxWaitTimeEstimate?: number | undefined;
|
|
35
|
-
minWaitTimeEstimate?: number | undefined;
|
|
36
|
-
feeLimit?: string | undefined;
|
|
37
|
-
feePerTx?: string | undefined;
|
|
38
|
-
baseFeePerGas?: string | undefined;
|
|
39
|
-
effectiveGasPrice?: string | undefined;
|
|
40
38
|
label: "normal" | "custom" | "high" | "economy" | "low";
|
|
41
|
-
feePerUnit: string;
|
|
42
39
|
blocks: number;
|
|
40
|
+
feePerUnit: string;
|
|
43
41
|
}[];
|
|
44
42
|
} & {
|
|
45
43
|
cashAddrPrefix?: string | undefined;
|
|
@@ -94,17 +92,15 @@ export default class GetCoinInfo extends AbstractMethod<'getCoinInfo', Params> {
|
|
|
94
92
|
};
|
|
95
93
|
decimals: number;
|
|
96
94
|
defaultFees: {
|
|
95
|
+
feePerTx?: string | undefined;
|
|
96
|
+
feeLimit?: string | undefined;
|
|
97
|
+
baseFeePerGas?: string | undefined;
|
|
97
98
|
maxFeePerGas?: string | undefined;
|
|
98
99
|
maxPriorityFeePerGas?: string | undefined;
|
|
99
100
|
maxWaitTimeEstimate?: number | undefined;
|
|
100
|
-
minWaitTimeEstimate?: number | undefined;
|
|
101
|
-
feeLimit?: string | undefined;
|
|
102
|
-
feePerTx?: string | undefined;
|
|
103
|
-
baseFeePerGas?: string | undefined;
|
|
104
|
-
effectiveGasPrice?: string | undefined;
|
|
105
101
|
label: "normal" | "custom" | "high" | "economy" | "low";
|
|
106
|
-
feePerUnit: string;
|
|
107
102
|
blocks: number;
|
|
103
|
+
feePerUnit: string;
|
|
108
104
|
}[];
|
|
109
105
|
} & {
|
|
110
106
|
network?: undefined;
|
|
@@ -134,17 +130,15 @@ export default class GetCoinInfo extends AbstractMethod<'getCoinInfo', Params> {
|
|
|
134
130
|
};
|
|
135
131
|
decimals: number;
|
|
136
132
|
defaultFees: {
|
|
133
|
+
feePerTx?: string | undefined;
|
|
134
|
+
feeLimit?: string | undefined;
|
|
135
|
+
baseFeePerGas?: string | undefined;
|
|
137
136
|
maxFeePerGas?: string | undefined;
|
|
138
137
|
maxPriorityFeePerGas?: string | undefined;
|
|
139
138
|
maxWaitTimeEstimate?: number | undefined;
|
|
140
|
-
minWaitTimeEstimate?: number | undefined;
|
|
141
|
-
feeLimit?: string | undefined;
|
|
142
|
-
feePerTx?: string | undefined;
|
|
143
|
-
baseFeePerGas?: string | undefined;
|
|
144
|
-
effectiveGasPrice?: string | undefined;
|
|
145
139
|
label: "normal" | "custom" | "high" | "economy" | "low";
|
|
146
|
-
feePerUnit: string;
|
|
147
140
|
blocks: number;
|
|
141
|
+
feePerUnit: string;
|
|
148
142
|
}[];
|
|
149
143
|
} & {
|
|
150
144
|
network?: undefined;
|
|
@@ -14,29 +14,33 @@ export default class GetPublicKey extends AbstractMethod<'getPublicKey', Params[
|
|
|
14
14
|
view: "export-xpub";
|
|
15
15
|
label: string;
|
|
16
16
|
};
|
|
17
|
-
run(): Promise<{
|
|
18
|
-
xpubSegwit?: string | undefined;
|
|
19
|
-
descriptorChecksum?: string | undefined;
|
|
17
|
+
run(): Promise<({
|
|
20
18
|
path: number[];
|
|
21
19
|
publicKey: string;
|
|
22
20
|
serializedPath: string;
|
|
21
|
+
} & {
|
|
22
|
+
descriptor?: string | undefined;
|
|
23
|
+
xpubSegwit?: string | undefined;
|
|
24
|
+
descriptorChecksum?: string | undefined;
|
|
23
25
|
depth: number;
|
|
24
26
|
fingerprint: number;
|
|
25
27
|
chainCode: string;
|
|
26
28
|
childNum: number;
|
|
27
29
|
xpub: string;
|
|
28
|
-
} | {
|
|
29
|
-
xpubSegwit?: string | undefined;
|
|
30
|
-
descriptorChecksum?: string | undefined;
|
|
30
|
+
}) | ({
|
|
31
31
|
path: number[];
|
|
32
32
|
publicKey: string;
|
|
33
33
|
serializedPath: string;
|
|
34
|
+
} & {
|
|
35
|
+
descriptor?: string | undefined;
|
|
36
|
+
xpubSegwit?: string | undefined;
|
|
37
|
+
descriptorChecksum?: string | undefined;
|
|
34
38
|
depth: number;
|
|
35
39
|
fingerprint: number;
|
|
36
40
|
chainCode: string;
|
|
37
41
|
childNum: number;
|
|
38
42
|
xpub: string;
|
|
39
|
-
}[]>;
|
|
43
|
+
})[]>;
|
|
40
44
|
}
|
|
41
45
|
export {};
|
|
42
46
|
//# sourceMappingURL=getPublicKey.d.ts.map
|
package/lib/api/resetDevice.js
CHANGED
|
@@ -6,7 +6,6 @@ const utils_1 = require("@trezor/utils");
|
|
|
6
6
|
const verifyEntropy_1 = require("../api/firmware/verifyEntropy");
|
|
7
7
|
const constants_1 = require("../constants");
|
|
8
8
|
const AbstractMethod_1 = require("../core/AbstractMethod");
|
|
9
|
-
const prompts_1 = require("../device/prompts");
|
|
10
9
|
const events_1 = require("../events");
|
|
11
10
|
const paramsValidator_1 = require("./common/paramsValidator");
|
|
12
11
|
const pathUtils_1 = require("../utils/pathUtils");
|
|
@@ -70,8 +69,7 @@ class ResetDevice extends AbstractMethod_1.AbstractMethod {
|
|
|
70
69
|
xpubs,
|
|
71
70
|
});
|
|
72
71
|
if (res.error) {
|
|
73
|
-
await
|
|
74
|
-
});
|
|
72
|
+
await this.device.getCurrentSession().cancelCall();
|
|
75
73
|
throw new Error(res.error);
|
|
76
74
|
}
|
|
77
75
|
return currentData;
|
|
@@ -162,17 +162,17 @@ class SignTransaction extends AbstractMethod_1.AbstractMethod {
|
|
|
162
162
|
const response = await signTxMethod({
|
|
163
163
|
...params,
|
|
164
164
|
refTxs,
|
|
165
|
-
typedCall: device.getCommands().typedCall
|
|
165
|
+
typedCall: device.getCommands().typedCall,
|
|
166
166
|
});
|
|
167
167
|
if (!response.serializedTx) {
|
|
168
168
|
return response;
|
|
169
169
|
}
|
|
170
170
|
let bitcoinTx;
|
|
171
171
|
if (params.options.decred_staking_ticket) {
|
|
172
|
-
await (0, bitcoin_1.verifyTicketTx)(device.getCommands().getHDNode
|
|
172
|
+
await (0, bitcoin_1.verifyTicketTx)(device.getCommands().getHDNode, params.inputs, params.outputs, response.serializedTx, params.coinInfo);
|
|
173
173
|
}
|
|
174
174
|
else {
|
|
175
|
-
bitcoinTx = await (0, bitcoin_1.verifyTx)(device.getCommands().getHDNode
|
|
175
|
+
bitcoinTx = await (0, bitcoin_1.verifyTx)(device.getCommands().getHDNode, params.inputs, params.outputs, response.serializedTx, params.coinInfo, params.unlockPath);
|
|
176
176
|
if (bitcoinTx.hasWitnesses()) {
|
|
177
177
|
response.witnesses = bitcoinTx.ins.map((_, i) => bitcoinTx?.getWitness(i)?.toString('hex'));
|
|
178
178
|
}
|
|
@@ -52,7 +52,7 @@ class StellarSignTransaction extends AbstractMethod_1.AbstractMethod {
|
|
|
52
52
|
}
|
|
53
53
|
async run() {
|
|
54
54
|
this._ensureFirmwareSupportsParams();
|
|
55
|
-
const response = await helper.stellarSignTx(this.device.getCommands().typedCall
|
|
55
|
+
const response = await helper.stellarSignTx(this.device.getCommands().typedCall, this.params.path, this.params.networkPassphrase, this.params.transaction);
|
|
56
56
|
return {
|
|
57
57
|
publicKey: response.public_key,
|
|
58
58
|
signature: response.signature,
|
|
@@ -5,8 +5,8 @@ export declare const ERROR_CODES: {
|
|
|
5
5
|
readonly Init_IframeTimeout: "Iframe timeout";
|
|
6
6
|
readonly Init_ManifestMissing: "Manifest not set. Read more at https://github.com/trezor/trezor-suite/blob/develop/docs/packages/connect/index.md";
|
|
7
7
|
readonly Popup_ConnectionMissing: "Unable to establish connection with iframe";
|
|
8
|
+
readonly Desktop_ConnectionMissing: "Unable to establish connection with Suite";
|
|
8
9
|
readonly Transport_Missing: "Transport is missing";
|
|
9
|
-
readonly Transport_InvalidProtobuf: "";
|
|
10
10
|
readonly Method_InvalidPackage: "This package is not suitable to work with browser. Use @trezor/connect-web package instead";
|
|
11
11
|
readonly Method_InvalidParameter: "";
|
|
12
12
|
readonly Method_NotAllowed: "Method not allowed for this configuration";
|
|
@@ -15,7 +15,6 @@ export declare const ERROR_CODES: {
|
|
|
15
15
|
readonly Method_Interrupted: "Popup closed";
|
|
16
16
|
readonly Method_UnknownCoin: "Coin not found";
|
|
17
17
|
readonly Method_AddressNotMatch: "Addresses do not match";
|
|
18
|
-
readonly Method_FirmwareUpdate_DownloadFailed: "Failed to download firmware binary";
|
|
19
18
|
readonly Method_Discovery_BundleException: "";
|
|
20
19
|
readonly Method_Override: "override";
|
|
21
20
|
readonly Method_NoResponse: "Call resolved without response";
|
package/lib/constants/errors.js
CHANGED
|
@@ -8,8 +8,8 @@ exports.ERROR_CODES = {
|
|
|
8
8
|
Init_IframeTimeout: 'Iframe timeout',
|
|
9
9
|
Init_ManifestMissing: 'Manifest not set. Read more at https://github.com/trezor/trezor-suite/blob/develop/docs/packages/connect/index.md',
|
|
10
10
|
Popup_ConnectionMissing: 'Unable to establish connection with iframe',
|
|
11
|
+
Desktop_ConnectionMissing: 'Unable to establish connection with Suite',
|
|
11
12
|
Transport_Missing: 'Transport is missing',
|
|
12
|
-
Transport_InvalidProtobuf: '',
|
|
13
13
|
Method_InvalidPackage: 'This package is not suitable to work with browser. Use @trezor/connect-web package instead',
|
|
14
14
|
Method_InvalidParameter: '',
|
|
15
15
|
Method_NotAllowed: 'Method not allowed for this configuration',
|
|
@@ -18,7 +18,6 @@ exports.ERROR_CODES = {
|
|
|
18
18
|
Method_Interrupted: 'Popup closed',
|
|
19
19
|
Method_UnknownCoin: 'Coin not found',
|
|
20
20
|
Method_AddressNotMatch: 'Addresses do not match',
|
|
21
|
-
Method_FirmwareUpdate_DownloadFailed: 'Failed to download firmware binary',
|
|
22
21
|
Method_Discovery_BundleException: '',
|
|
23
22
|
Method_Override: 'override',
|
|
24
23
|
Method_NoResponse: 'Call resolved without response',
|
|
@@ -71,7 +70,13 @@ const serializeError = (payload) => {
|
|
|
71
70
|
if (payload instanceof TrezorError) {
|
|
72
71
|
return { error: payload.message, code: payload.code };
|
|
73
72
|
}
|
|
74
|
-
|
|
73
|
+
if (payload instanceof Error) {
|
|
74
|
+
return {
|
|
75
|
+
error: payload.message,
|
|
76
|
+
code: 'code' in payload ? payload.code : 'Failure_UnknownCode',
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
return { ...payload };
|
|
75
80
|
};
|
|
76
81
|
exports.serializeError = serializeError;
|
|
77
82
|
exports.LIBUSB_ERROR_MESSAGE = 'LIBUSB_ERROR';
|
package/lib/core/index.js
CHANGED
|
@@ -460,7 +460,7 @@ const closePopup = ({ popupPromise, sendCoreMessage }) => {
|
|
|
460
460
|
}
|
|
461
461
|
sendCoreMessage((0, events_2.createUiMessage)(events_2.UI.CLOSE_UI_WINDOW));
|
|
462
462
|
};
|
|
463
|
-
const onDeviceButtonHandler = (context, method) => async ({
|
|
463
|
+
const onDeviceButtonHandler = (device, context, method) => async ({ payload: request }) => {
|
|
464
464
|
const { sendCoreMessage } = context;
|
|
465
465
|
const addressRequest = request.code === 'ButtonRequest_Address';
|
|
466
466
|
if (!addressRequest || (addressRequest && method?.useUi)) {
|
|
@@ -480,54 +480,75 @@ const onDeviceButtonHandler = (context, method) => async ({ device, payload: req
|
|
|
480
480
|
sendCoreMessage((0, events_2.createUiMessage)(events_2.UI.ADDRESS_VALIDATION, data));
|
|
481
481
|
}
|
|
482
482
|
};
|
|
483
|
-
const onDevicePinHandler = (context) => async ({
|
|
483
|
+
const onDevicePinHandler = (device, context) => async ({ type, callback }) => {
|
|
484
484
|
const { uiPromises, sendCoreMessage } = context;
|
|
485
485
|
await waitForPopup(context);
|
|
486
486
|
const uiPromise = uiPromises.create(events_2.UI.RECEIVE_PIN, device);
|
|
487
487
|
sendCoreMessage((0, events_2.createUiMessage)(events_2.UI.REQUEST_PIN, { device: device.toMessageObject(), type }));
|
|
488
488
|
try {
|
|
489
489
|
const uiResp = await uiPromise.promise;
|
|
490
|
-
|
|
490
|
+
if (uiResp.payload == null) {
|
|
491
|
+
callback({ success: false, error: new Error(`${events_2.UI.RECEIVE_PIN} missing payload`) });
|
|
492
|
+
}
|
|
493
|
+
else {
|
|
494
|
+
callback({ success: true, payload: uiResp.payload });
|
|
495
|
+
}
|
|
491
496
|
}
|
|
492
497
|
catch (error) {
|
|
493
|
-
callback(
|
|
498
|
+
callback({ success: false, error });
|
|
494
499
|
}
|
|
495
500
|
};
|
|
496
|
-
const onDeviceWordHandler = (context) => async ({
|
|
501
|
+
const onDeviceWordHandler = (device, context) => async ({ type, callback }) => {
|
|
497
502
|
const { uiPromises, sendCoreMessage } = context;
|
|
498
503
|
await waitForPopup(context);
|
|
499
504
|
const uiPromise = uiPromises.create(events_2.UI.RECEIVE_WORD, device);
|
|
500
505
|
sendCoreMessage((0, events_2.createUiMessage)(events_2.UI.REQUEST_WORD, { device: device.toMessageObject(), type }));
|
|
501
506
|
try {
|
|
502
507
|
const uiResp = await uiPromise.promise;
|
|
503
|
-
|
|
508
|
+
if (uiResp.payload == null) {
|
|
509
|
+
callback({
|
|
510
|
+
success: false,
|
|
511
|
+
error: new Error(`${events_2.UI.RECEIVE_WORD} missing payload`),
|
|
512
|
+
});
|
|
513
|
+
}
|
|
514
|
+
else {
|
|
515
|
+
callback({ success: true, payload: uiResp.payload });
|
|
516
|
+
}
|
|
504
517
|
}
|
|
505
518
|
catch (error) {
|
|
506
|
-
callback(
|
|
519
|
+
callback({ success: false, error });
|
|
507
520
|
}
|
|
508
521
|
};
|
|
509
|
-
const onDevicePassphraseHandler = (context) => async ({
|
|
522
|
+
const onDevicePassphraseHandler = (device, context) => async ({ callback }) => {
|
|
510
523
|
const { uiPromises, sendCoreMessage } = context;
|
|
511
524
|
await waitForPopup(context);
|
|
512
525
|
const uiPromise = uiPromises.create(events_2.UI.RECEIVE_PASSPHRASE, device);
|
|
513
526
|
sendCoreMessage((0, events_2.createUiMessage)(events_2.UI.REQUEST_PASSPHRASE, { device: device.toMessageObject() }));
|
|
514
527
|
try {
|
|
515
528
|
const uiResp = await uiPromise.promise;
|
|
516
|
-
|
|
529
|
+
if (uiResp.payload == null) {
|
|
530
|
+
callback({
|
|
531
|
+
success: false,
|
|
532
|
+
error: new Error(`${events_2.UI.RECEIVE_PASSPHRASE} missing payload`),
|
|
533
|
+
});
|
|
534
|
+
}
|
|
535
|
+
else {
|
|
536
|
+
callback({ success: true, payload: uiResp.payload });
|
|
537
|
+
}
|
|
517
538
|
}
|
|
518
539
|
catch (error) {
|
|
519
|
-
callback(
|
|
540
|
+
callback({ success: false, error });
|
|
520
541
|
}
|
|
521
542
|
};
|
|
522
543
|
const onEmptyPassphraseHandler = () => ({ callback }) => {
|
|
523
|
-
callback({ value: '' });
|
|
544
|
+
callback({ success: true, payload: { value: '' } });
|
|
524
545
|
};
|
|
525
546
|
const registerDeviceEvents = (context, method) => (device) => {
|
|
526
547
|
device.removeAllListeners();
|
|
527
|
-
device.on(events_2.DEVICE.BUTTON, onDeviceButtonHandler(context, method));
|
|
528
|
-
device.on(events_2.DEVICE.PIN, onDevicePinHandler(context));
|
|
529
|
-
device.on(events_2.DEVICE.WORD, onDeviceWordHandler(context));
|
|
530
|
-
device.on(events_2.DEVICE.PASSPHRASE, (method?.useEmptyPassphrase ? onEmptyPassphraseHandler : onDevicePassphraseHandler)(context));
|
|
548
|
+
device.on(events_2.DEVICE.BUTTON, onDeviceButtonHandler(device, context, method));
|
|
549
|
+
device.on(events_2.DEVICE.PIN, onDevicePinHandler(device, context));
|
|
550
|
+
device.on(events_2.DEVICE.WORD, onDeviceWordHandler(device, context));
|
|
551
|
+
device.on(events_2.DEVICE.PASSPHRASE, (method?.useEmptyPassphrase ? onEmptyPassphraseHandler : onDevicePassphraseHandler)(device, context));
|
|
531
552
|
device.on(events_2.DEVICE.PASSPHRASE_ON_DEVICE, () => {
|
|
532
553
|
context.sendCoreMessage((0, events_2.createUiMessage)(events_2.UI.REQUEST_PASSPHRASE_ON_DEVICE, {
|
|
533
554
|
device: device.toMessageObject(),
|
|
@@ -95,7 +95,8 @@ const getInstallationParams = (device, params) => {
|
|
|
95
95
|
const upgrade = device.atLeast('2.6.3') && isUpdatingToNewerVersion && isUpdatingToEqualFirmwareType;
|
|
96
96
|
const manual = !device.atLeast(['1.10.0', '2.6.0']) && !upgrade;
|
|
97
97
|
const language = device.atLeast('2.7.0') &&
|
|
98
|
-
device.features.internal_model !== constants_1.PROTO.DeviceModelInternal.T2T1
|
|
98
|
+
device.features.internal_model !== constants_1.PROTO.DeviceModelInternal.T2T1 &&
|
|
99
|
+
device.features.internal_model !== constants_1.PROTO.DeviceModelInternal.T3T1;
|
|
99
100
|
return {
|
|
100
101
|
manual,
|
|
101
102
|
upgrade,
|
|
@@ -230,7 +231,7 @@ const onCallFirmwareUpdate = async ({ params, context, }) => {
|
|
|
230
231
|
const bootloaderVersion = reconnectedDevice.getVersion();
|
|
231
232
|
await reconnectedDevice.initialize(false);
|
|
232
233
|
let stripped = (0, firmware_1.stripFwHeaders)(binary);
|
|
233
|
-
await (0, firmware_1.uploadFirmware)(reconnectedDevice.getCommands().typedCall
|
|
234
|
+
await (0, firmware_1.uploadFirmware)(reconnectedDevice.getCommands().typedCall, postMessage, reconnectedDevice, { payload: !intermediary && (0, firmware_1.shouldStripFwHeaders)(device.features) ? stripped : binary });
|
|
234
235
|
log.info('onCallFirmwareUpdate', 'firmware uploaded');
|
|
235
236
|
if (intermediary) {
|
|
236
237
|
log.info('onCallFirmwareUpdate', '...but it was the intermediary firmware, so one more go');
|
|
@@ -238,7 +239,7 @@ const onCallFirmwareUpdate = async ({ params, context, }) => {
|
|
|
238
239
|
binaryInfo = await getBinaryHelper(reconnectedDevice, params, log, postMessage, btcOnly);
|
|
239
240
|
stripped = (0, firmware_1.stripFwHeaders)(binaryInfo.binary);
|
|
240
241
|
await reconnectedDevice.initialize(false);
|
|
241
|
-
await (0, firmware_1.uploadFirmware)(reconnectedDevice.getCommands().typedCall
|
|
242
|
+
await (0, firmware_1.uploadFirmware)(reconnectedDevice.getCommands().typedCall, postMessage, reconnectedDevice, { payload: stripped });
|
|
242
243
|
}
|
|
243
244
|
reconnectedDevice = await waitForReconnectedDevice({ bootloader: false, method: 'wait' }, { ...context, device: reconnectedDevice });
|
|
244
245
|
if (reconnectedDevice.atLeast('2.7.0') &&
|
|
@@ -259,6 +260,8 @@ const onCallFirmwareUpdate = async ({ params, context, }) => {
|
|
|
259
260
|
const { binaryVersion, releaseVersion } = binaryInfo;
|
|
260
261
|
const assertBinaryVersion = (0, versionUtils_1.isEqual)(installedVersion, binaryVersion);
|
|
261
262
|
const assertReleaseVersion = releaseVersion ? (0, versionUtils_1.isEqual)(installedVersion, releaseVersion) : true;
|
|
263
|
+
await reconnectedDevice.release();
|
|
264
|
+
log.info('onCallFirmwareUpdate', `firmware updated to version ${installedVersion}`);
|
|
262
265
|
return {
|
|
263
266
|
versionCheck: assertBinaryVersion && assertReleaseVersion,
|
|
264
267
|
bootloaderVersion,
|