@trezor/connect 9.4.4 → 9.4.5
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 +30 -4
- package/README.md +1 -1
- package/lib/api/bitcoin/signtx.js +1 -1
- package/lib/api/bitcoin/signtxLegacy.js +1 -1
- package/lib/api/blockchainGetInfo.d.ts +12 -0
- package/lib/api/blockchainGetInfo.js +33 -0
- package/lib/api/getAccountInfo.js +1 -0
- package/lib/api/getFeatures.d.ts +1 -1
- package/lib/api/index.d.ts +1 -0
- package/lib/api/index.js +3 -1
- package/lib/backend/Blockchain.js +1 -1
- package/lib/constants/errors.js +3 -0
- package/lib/core/AbstractMethod.d.ts +23 -0
- package/lib/core/AbstractMethod.js +3 -0
- package/lib/data/DataManager.d.ts +1 -1
- package/lib/data/DataManager.js +18 -47
- package/lib/data/models.d.ts +6 -48
- package/lib/data/version.d.ts +1 -1
- package/lib/data/version.js +1 -1
- package/lib/device/Device.d.ts +4 -70
- package/lib/device/Device.js +16 -15
- package/lib/device/DeviceCommands.d.ts +1 -37
- package/lib/device/DeviceCommands.js +1 -1
- package/lib/factory.js +1 -0
- package/lib/impl/core-in-module.d.ts +39 -0
- package/lib/impl/core-in-module.js +218 -0
- package/lib/types/api/applySettings.d.ts +1 -1
- package/lib/types/api/blockchainGetInfo.d.ts +4 -0
- package/lib/types/api/blockchainGetInfo.js +3 -0
- package/lib/types/api/index.d.ts +2 -0
- package/lib/types/device.d.ts +2 -0
- package/lib/types/settings.d.ts +1 -1
- package/lib/utils/assetUtils.d.ts +2 -0
- package/lib/utils/assetUtils.js +3 -3
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,15 +1,41 @@
|
|
|
1
1
|
| Package | Stable | Canary |
|
|
2
2
|
| :------------------------------: | :----: | :----: |
|
|
3
|
-
| npm @trezor/connect | 9.4.
|
|
4
|
-
| npm @trezor/connect-web | 9.4.
|
|
5
|
-
| npm @trezor/connect-webextension | 9.4.
|
|
3
|
+
| npm @trezor/connect | 9.4.5 | - |
|
|
4
|
+
| npm @trezor/connect-web | 9.4.5 | - |
|
|
5
|
+
| npm @trezor/connect-webextension | 9.4.5 | - |
|
|
6
6
|
|
|
7
7
|
| Deployment | Stable | Canary |
|
|
8
8
|
| :----------------: | :----: | :----: |
|
|
9
|
-
| connect.trezor.io/ | 9.4.
|
|
9
|
+
| connect.trezor.io/ | 9.4.5 | - |
|
|
10
10
|
|
|
11
11
|
Use the persistent link [connect.trezor.io/9](https://connect.trezor.io/9/) to access the latest stable version of Connect Explorer.
|
|
12
12
|
|
|
13
|
+
# 9.4.5
|
|
14
|
+
|
|
15
|
+
We’ve reverted the default setting for nVersion in Connect back to nVersion=1. Since this might be a breaking change we are going to implement it in Connect 10. (05af037)
|
|
16
|
+
|
|
17
|
+
## Feature
|
|
18
|
+
|
|
19
|
+
- add blockchainGetInfo method (0bd3068)
|
|
20
|
+
- types - export DisplayRotation type (6744666)
|
|
21
|
+
- new way of using connect as a module in web (without iframe). This is meant for internal use for suite.trezor.io application.
|
|
22
|
+
|
|
23
|
+
## Fixes
|
|
24
|
+
|
|
25
|
+
- add typesafe map types to models config for device names and variants (4d24e2b)
|
|
26
|
+
chore(connect): default to nversion=1 again
|
|
27
|
+
|
|
28
|
+
## Dependencies updated
|
|
29
|
+
|
|
30
|
+
- npm-release: @trezor/blockchain-link 2.3.4
|
|
31
|
+
- npm-release: @trezor/blockchain-link-utils 1.2.4
|
|
32
|
+
- npm-release: @trezor/analytics 1.2.4
|
|
33
|
+
- npm-release: @trezor/connect-common 0.2.5
|
|
34
|
+
- npm-release: @trezor/transport 1.3.5
|
|
35
|
+
- npm-release: @trezor/protobuf 1.2.5
|
|
36
|
+
- npm-release: @trezor/utxo-lib 2.2.4
|
|
37
|
+
- npm-release: @trezor/utils 9.2.4
|
|
38
|
+
|
|
13
39
|
# 9.4.4
|
|
14
40
|
|
|
15
41
|
This release among other improvements fixes a bug in ethereum serialization of empty strings as hex that was causing issues when signing that was caused by @ethereumjs libs update (2d6465f, d6bc8c5020) in 9.4.3.
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @trezor/connect
|
|
2
2
|
|
|
3
|
-
API version 9.4.
|
|
3
|
+
API version 9.4.5
|
|
4
4
|
|
|
5
5
|
[](https://github.com/trezor/trezor-suite/actions/workflows/test-connect.yml)
|
|
6
6
|
[](https://www.npmjs.org/package/@trezor/connect)
|
|
@@ -142,7 +142,7 @@ const processTxRequest = async (props) => {
|
|
|
142
142
|
const signTx = async ({ typedCall, inputs, outputs, paymentRequests, refTxs, options, coinInfo, }) => {
|
|
143
143
|
const { message } = await typedCall('SignTx', 'TxRequest', {
|
|
144
144
|
...options,
|
|
145
|
-
version: options.version === undefined && coinInfo.isBitcoin ?
|
|
145
|
+
version: options.version === undefined && coinInfo.isBitcoin ? 1 : options.version,
|
|
146
146
|
inputs_count: inputs.length,
|
|
147
147
|
outputs_count: outputs.length,
|
|
148
148
|
coin_name: coinInfo.name,
|
|
@@ -114,7 +114,7 @@ const processTxRequest = async (props) => {
|
|
|
114
114
|
const signTxLegacy = async ({ typedCall, inputs, outputs, refTxs, options, coinInfo, }) => {
|
|
115
115
|
const { message } = await typedCall('SignTx', 'TxRequest', {
|
|
116
116
|
...options,
|
|
117
|
-
version: options.version === undefined && coinInfo.isBitcoin ?
|
|
117
|
+
version: options.version === undefined && coinInfo.isBitcoin ? 1 : options.version,
|
|
118
118
|
inputs_count: inputs.length,
|
|
119
119
|
outputs_count: outputs.length,
|
|
120
120
|
coin_name: coinInfo.name,
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { AbstractMethod } from '../core/AbstractMethod';
|
|
2
|
+
import type { CoinInfo } from '../types';
|
|
3
|
+
type Params = {
|
|
4
|
+
coinInfo: CoinInfo;
|
|
5
|
+
identity?: string;
|
|
6
|
+
};
|
|
7
|
+
export default class BlockchainGetInfo extends AbstractMethod<'blockchainGetInfo', Params> {
|
|
8
|
+
init(): void;
|
|
9
|
+
run(): Promise<import("@trezor/blockchain-link-types").ServerInfo>;
|
|
10
|
+
}
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=blockchainGetInfo.d.ts.map
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const AbstractMethod_1 = require("../core/AbstractMethod");
|
|
4
|
+
const paramsValidator_1 = require("./common/paramsValidator");
|
|
5
|
+
const constants_1 = require("../constants");
|
|
6
|
+
const BlockchainLink_1 = require("../backend/BlockchainLink");
|
|
7
|
+
const coinInfo_1 = require("../data/coinInfo");
|
|
8
|
+
class BlockchainGetInfo extends AbstractMethod_1.AbstractMethod {
|
|
9
|
+
init() {
|
|
10
|
+
this.useDevice = false;
|
|
11
|
+
this.useUi = false;
|
|
12
|
+
const { payload } = this;
|
|
13
|
+
(0, paramsValidator_1.validateParams)(payload, [
|
|
14
|
+
{ name: 'coin', type: 'string', required: true },
|
|
15
|
+
{ name: 'identity', type: 'string' },
|
|
16
|
+
]);
|
|
17
|
+
const coinInfo = (0, coinInfo_1.getCoinInfo)(payload.coin);
|
|
18
|
+
if (!coinInfo) {
|
|
19
|
+
throw constants_1.ERRORS.TypedError('Method_UnknownCoin');
|
|
20
|
+
}
|
|
21
|
+
(0, BlockchainLink_1.isBackendSupported)(coinInfo);
|
|
22
|
+
this.params = {
|
|
23
|
+
coinInfo,
|
|
24
|
+
identity: payload.identity,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
async run() {
|
|
28
|
+
const backend = await (0, BlockchainLink_1.initBlockchain)(this.params.coinInfo, this.postMessage, this.params.identity);
|
|
29
|
+
return backend.getNetworkInfo();
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.default = BlockchainGetInfo;
|
|
33
|
+
//# sourceMappingURL=blockchainGetInfo.js.map
|
|
@@ -68,6 +68,7 @@ class GetAccountInfo extends AbstractMethod_1.AbstractMethod {
|
|
|
68
68
|
};
|
|
69
69
|
});
|
|
70
70
|
this.useDevice = willUseDevice;
|
|
71
|
+
this.useDeviceState = willUseDevice;
|
|
71
72
|
this.useUi = willUseDevice;
|
|
72
73
|
this.noBackupConfirmationMode = this.params.every(batch => batch.suppressBackupWarning)
|
|
73
74
|
? 'popup-only'
|
package/lib/api/getFeatures.d.ts
CHANGED
|
@@ -51,7 +51,7 @@ export default class GetFeatures extends AbstractMethod<'getFeatures'> {
|
|
|
51
51
|
passphrase_always_on_device: boolean | null;
|
|
52
52
|
safety_checks: "Strict" | "PromptAlways" | "PromptTemporarily" | null;
|
|
53
53
|
auto_lock_delay_ms: number | null;
|
|
54
|
-
display_rotation:
|
|
54
|
+
display_rotation: "North" | "East" | "South" | "West" | null;
|
|
55
55
|
experimental_features: boolean | null;
|
|
56
56
|
internal_model: import("@trezor/protobuf").DeviceModelInternal;
|
|
57
57
|
}>;
|
package/lib/api/index.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export { default as blockchainDisconnect } from './blockchainDisconnect';
|
|
|
9
9
|
export { default as blockchainEstimateFee } from './blockchainEstimateFee';
|
|
10
10
|
export { default as blockchainGetAccountBalanceHistory } from './blockchainGetAccountBalanceHistory';
|
|
11
11
|
export { default as blockchainGetCurrentFiatRates } from './blockchainGetCurrentFiatRates';
|
|
12
|
+
export { default as blockchainGetInfo } from './blockchainGetInfo';
|
|
12
13
|
export { default as blockchainEvmRpcCall } from './blockchainEvmRpcCall';
|
|
13
14
|
export { default as blockchainGetFiatRatesForTimestamps } from './blockchainGetFiatRatesForTimestamps';
|
|
14
15
|
export { default as blockchainGetTransactions } from './blockchainGetTransactions';
|
package/lib/api/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.wipeDevice = exports.verifyMessage = 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.getFirmwareHash = exports.getFeatures = exports.getDeviceState = exports.getCoinInfo = exports.getAddress = exports.getAccountInfo = exports.getAccountDescriptor = 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.blockchainGetCurrentFiatRates = exports.blockchainGetAccountBalanceHistory = exports.blockchainEstimateFee = exports.blockchainDisconnect = exports.backupDevice = exports.showDeviceTutorial = exports.cancelCoinjoinAuthorization = exports.authorizeCoinjoin = exports.authenticateDevice = exports.applySettings = exports.applyFlags = void 0;
|
|
3
|
+
exports.wipeDevice = exports.verifyMessage = 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.getFirmwareHash = exports.getFeatures = exports.getDeviceState = exports.getCoinInfo = exports.getAddress = exports.getAccountInfo = exports.getAccountDescriptor = 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.backupDevice = exports.showDeviceTutorial = exports.cancelCoinjoinAuthorization = exports.authorizeCoinjoin = exports.authenticateDevice = exports.applySettings = exports.applyFlags = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
var applyFlags_1 = require("./applyFlags");
|
|
6
6
|
Object.defineProperty(exports, "applyFlags", { enumerable: true, get: function () { return tslib_1.__importDefault(applyFlags_1).default; } });
|
|
@@ -24,6 +24,8 @@ var blockchainGetAccountBalanceHistory_1 = require("./blockchainGetAccountBalanc
|
|
|
24
24
|
Object.defineProperty(exports, "blockchainGetAccountBalanceHistory", { enumerable: true, get: function () { return tslib_1.__importDefault(blockchainGetAccountBalanceHistory_1).default; } });
|
|
25
25
|
var blockchainGetCurrentFiatRates_1 = require("./blockchainGetCurrentFiatRates");
|
|
26
26
|
Object.defineProperty(exports, "blockchainGetCurrentFiatRates", { enumerable: true, get: function () { return tslib_1.__importDefault(blockchainGetCurrentFiatRates_1).default; } });
|
|
27
|
+
var blockchainGetInfo_1 = require("./blockchainGetInfo");
|
|
28
|
+
Object.defineProperty(exports, "blockchainGetInfo", { enumerable: true, get: function () { return tslib_1.__importDefault(blockchainGetInfo_1).default; } });
|
|
27
29
|
var blockchainEvmRpcCall_1 = require("./blockchainEvmRpcCall");
|
|
28
30
|
Object.defineProperty(exports, "blockchainEvmRpcCall", { enumerable: true, get: function () { return tslib_1.__importDefault(blockchainEvmRpcCall_1).default; } });
|
|
29
31
|
var blockchainGetFiatRatesForTimestamps_1 = require("./blockchainGetFiatRatesForTimestamps");
|
package/lib/constants/errors.js
CHANGED
|
@@ -62,6 +62,9 @@ const serializeError = (payload) => {
|
|
|
62
62
|
if (payload && payload.error instanceof Error) {
|
|
63
63
|
return { error: payload.error.message, code: payload.error.code };
|
|
64
64
|
}
|
|
65
|
+
if (payload instanceof TrezorError) {
|
|
66
|
+
return { error: payload.message, code: payload.code };
|
|
67
|
+
}
|
|
65
68
|
return payload;
|
|
66
69
|
};
|
|
67
70
|
exports.serializeError = serializeError;
|
|
@@ -11,6 +11,14 @@ export type Payload<M> = Extract<CallMethodPayload, {
|
|
|
11
11
|
export type MethodReturnType<M extends CallMethodPayload['method']> = CallMethodResponse<M>;
|
|
12
12
|
export type MethodPermission = 'read' | 'write' | 'management' | 'push_tx';
|
|
13
13
|
export type DeviceMode = typeof UI.SEEDLESS | typeof UI.BOOTLOADER | typeof UI.INITIALIZE;
|
|
14
|
+
export interface MethodInfo {
|
|
15
|
+
useDevice: boolean;
|
|
16
|
+
useDeviceState: boolean;
|
|
17
|
+
name: string;
|
|
18
|
+
requiredPermissions: MethodPermission[];
|
|
19
|
+
info: string;
|
|
20
|
+
confirmation?: UiRequestConfirmation['payload'];
|
|
21
|
+
}
|
|
14
22
|
export declare const DEFAULT_FIRMWARE_RANGE: FirmwareRange;
|
|
15
23
|
export declare abstract class AbstractMethod<Name extends CallMethodPayload['method'], Params = undefined> {
|
|
16
24
|
responseID: number;
|
|
@@ -60,6 +68,21 @@ export declare abstract class AbstractMethod<Name extends CallMethodPayload['met
|
|
|
60
68
|
useDevice: boolean;
|
|
61
69
|
useDeviceState: boolean;
|
|
62
70
|
name: Name;
|
|
71
|
+
requiredPermissions: MethodPermission[];
|
|
72
|
+
info: string;
|
|
73
|
+
confirmation: {
|
|
74
|
+
view: "no-backup" | "export-xpub" | "export-address" | "export-account-info" | "device-management";
|
|
75
|
+
label?: string;
|
|
76
|
+
customConfirmButton?: {
|
|
77
|
+
className: string;
|
|
78
|
+
label: string;
|
|
79
|
+
};
|
|
80
|
+
customCancelButton?: {
|
|
81
|
+
className: string;
|
|
82
|
+
label: string;
|
|
83
|
+
};
|
|
84
|
+
analytics?: import("@trezor/connect-analytics").EventTypeDeviceSelected;
|
|
85
|
+
} | undefined;
|
|
63
86
|
};
|
|
64
87
|
checkDeviceCapability(): void;
|
|
65
88
|
abstract run(): Promise<MethodReturnType<Name>>;
|
|
@@ -188,6 +188,9 @@ class AbstractMethod {
|
|
|
188
188
|
useDevice: this.useDevice,
|
|
189
189
|
useDeviceState: this.useDeviceState,
|
|
190
190
|
name: this.name,
|
|
191
|
+
requiredPermissions: this.requiredPermissions,
|
|
192
|
+
info: this.info,
|
|
193
|
+
confirmation: this.confirmation,
|
|
191
194
|
};
|
|
192
195
|
}
|
|
193
196
|
checkDeviceCapability() {
|
|
@@ -6,7 +6,7 @@ export declare class DataManager {
|
|
|
6
6
|
static assets: AssetCollection;
|
|
7
7
|
private static settings;
|
|
8
8
|
private static messages;
|
|
9
|
-
static load(settings: ConnectSettings, withAssets?: boolean):
|
|
9
|
+
static load(settings: ConnectSettings, withAssets?: boolean): void;
|
|
10
10
|
static getProtobufMessages(): Record<string, any>;
|
|
11
11
|
static getSettings(key?: undefined): ConnectSettings;
|
|
12
12
|
static getSettings<T extends keyof ConnectSettings>(key: T): ConnectSettings[T];
|
package/lib/data/DataManager.js
CHANGED
|
@@ -1,61 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DataManager = void 0;
|
|
4
|
-
const
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const coins_json_1 = tslib_1.__importDefault(require("@trezor/connect-common/files/coins.json"));
|
|
6
|
+
const coins_eth_json_1 = tslib_1.__importDefault(require("@trezor/connect-common/files/coins-eth.json"));
|
|
7
|
+
const releases_json_1 = tslib_1.__importDefault(require("@trezor/connect-common/files/bridge/releases.json"));
|
|
8
|
+
const messages_json_1 = tslib_1.__importDefault(require("@trezor/protobuf/messages.json"));
|
|
5
9
|
const coinInfo_1 = require("./coinInfo");
|
|
6
10
|
const firmwareInfo_1 = require("./firmwareInfo");
|
|
7
11
|
const transportInfo_1 = require("./transportInfo");
|
|
8
12
|
const types_1 = require("../types");
|
|
9
|
-
const
|
|
10
|
-
{
|
|
11
|
-
name: 'coins',
|
|
12
|
-
url: './data/coins.json',
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
name: 'coinsEth',
|
|
16
|
-
url: './data/coins-eth.json',
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
name: 'bridge',
|
|
20
|
-
url: './data/bridge/releases.json',
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
name: 'firmware-t1b1',
|
|
24
|
-
url: './data/firmware/t1b1/releases.json',
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
name: 'firmware-t2t1',
|
|
28
|
-
url: './data/firmware/t2t1/releases.json',
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
name: 'firmware-t2b1',
|
|
32
|
-
url: './data/firmware/t2b1/releases.json',
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
name: 'firmware-t3b1',
|
|
36
|
-
url: './data/firmware/t3b1/releases.json',
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
name: 'firmware-t3t1',
|
|
40
|
-
url: './data/firmware/t3t1/releases.json',
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
name: 'firmware-t3tw1',
|
|
44
|
-
url: './data/firmware/t3w1/releases.json',
|
|
45
|
-
},
|
|
46
|
-
];
|
|
13
|
+
const assetUtils_1 = require("../utils/assetUtils");
|
|
47
14
|
class DataManager {
|
|
48
|
-
static
|
|
49
|
-
const ts = settings.env === 'web' ? `?r=${settings.timestamp}` : '';
|
|
15
|
+
static load(settings, withAssets = true) {
|
|
50
16
|
this.settings = settings;
|
|
51
17
|
if (!withAssets)
|
|
52
18
|
return;
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
19
|
+
const assetsMap = {
|
|
20
|
+
coins: coins_json_1.default,
|
|
21
|
+
coinsEth: coins_eth_json_1.default,
|
|
22
|
+
bridge: releases_json_1.default,
|
|
23
|
+
...Object.fromEntries(Object.entries(assetUtils_1.firmwareAssets).map(([key, value]) => [
|
|
24
|
+
`firmware-${key.toLowerCase()}`,
|
|
25
|
+
value,
|
|
26
|
+
])),
|
|
27
|
+
};
|
|
28
|
+
Object.assign(this.assets, assetsMap);
|
|
59
29
|
(0, transportInfo_1.parseBridgeJSON)(this.assets.bridge);
|
|
60
30
|
(0, coinInfo_1.parseCoinsJson)({
|
|
61
31
|
...this.assets.coins,
|
|
@@ -83,4 +53,5 @@ class DataManager {
|
|
|
83
53
|
}
|
|
84
54
|
exports.DataManager = DataManager;
|
|
85
55
|
DataManager.assets = {};
|
|
56
|
+
DataManager.messages = messages_json_1.default;
|
|
86
57
|
//# sourceMappingURL=DataManager.js.map
|
package/lib/data/models.d.ts
CHANGED
|
@@ -1,50 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
};
|
|
6
|
-
T2T1: {
|
|
7
|
-
name: string;
|
|
8
|
-
colors: {};
|
|
9
|
-
};
|
|
10
|
-
T2B1: {
|
|
11
|
-
name: string;
|
|
12
|
-
colors: {
|
|
13
|
-
'1': string;
|
|
14
|
-
'2': string;
|
|
15
|
-
'3': string;
|
|
16
|
-
'4': string;
|
|
17
|
-
'5': string;
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
|
-
T3B1: {
|
|
21
|
-
name: string;
|
|
22
|
-
colors: {
|
|
23
|
-
'1': string;
|
|
24
|
-
'2': string;
|
|
25
|
-
'3': string;
|
|
26
|
-
'4': string;
|
|
27
|
-
'5': string;
|
|
28
|
-
};
|
|
29
|
-
};
|
|
30
|
-
T3T1: {
|
|
31
|
-
name: string;
|
|
32
|
-
colors: {
|
|
33
|
-
'1': string;
|
|
34
|
-
'2': string;
|
|
35
|
-
'3': string;
|
|
36
|
-
'4': string;
|
|
37
|
-
'5': string;
|
|
38
|
-
};
|
|
39
|
-
};
|
|
40
|
-
T3W1: {
|
|
41
|
-
name: string;
|
|
42
|
-
colors: {
|
|
43
|
-
'1': string;
|
|
44
|
-
'2': string;
|
|
45
|
-
'3': string;
|
|
46
|
-
'4': string;
|
|
47
|
-
};
|
|
48
|
-
};
|
|
1
|
+
import { DeviceModelInternal } from '@trezor/protobuf';
|
|
2
|
+
type ModelConfig = {
|
|
3
|
+
name: string;
|
|
4
|
+
colors: Record<string, string>;
|
|
49
5
|
};
|
|
6
|
+
export declare const models: Record<DeviceModelInternal, ModelConfig>;
|
|
7
|
+
export {};
|
|
50
8
|
//# sourceMappingURL=models.d.ts.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.DEEPLINK_VERSION = exports.CONTENT_SCRIPT_VERSION = exports.DEFAULT_DOMAIN = exports.VERSION = void 0;
|
|
4
|
-
exports.VERSION = '9.4.
|
|
4
|
+
exports.VERSION = '9.4.5';
|
|
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
|
@@ -97,7 +97,7 @@ export declare class Device extends TypedEmitter<DeviceEvents> {
|
|
|
97
97
|
passphrase_always_on_device: boolean | null;
|
|
98
98
|
safety_checks: "Strict" | "PromptAlways" | "PromptTemporarily" | null;
|
|
99
99
|
auto_lock_delay_ms: number | null;
|
|
100
|
-
display_rotation:
|
|
100
|
+
display_rotation: "North" | "East" | "South" | "West" | null;
|
|
101
101
|
experimental_features: boolean | null;
|
|
102
102
|
internal_model: PROTO.DeviceModelInternal;
|
|
103
103
|
};
|
|
@@ -128,41 +128,8 @@ export declare class Device extends TypedEmitter<DeviceEvents> {
|
|
|
128
128
|
constructor({ id, transport, descriptor, listener }: DeviceParams);
|
|
129
129
|
private getSessionChangePromise;
|
|
130
130
|
private waitAndCompareSession;
|
|
131
|
-
acquire(): import("@trezor/transport/lib/types").AsyncResultWithTypedError<Session, "Network request failed" | "Wrong result type." | "device disconnected during action" | "unexpected error" | "Aborted by timeout" | "Aborted by signal" | "This transport can not be used in this environment" | "device not found" | "Unable to open device" | "
|
|
132
|
-
release(): Promise<
|
|
133
|
-
success: false;
|
|
134
|
-
error: "session not found";
|
|
135
|
-
} | {
|
|
136
|
-
success: false;
|
|
137
|
-
error: "Network request failed";
|
|
138
|
-
} | {
|
|
139
|
-
success: false;
|
|
140
|
-
error: "Wrong result type.";
|
|
141
|
-
} | {
|
|
142
|
-
success: false;
|
|
143
|
-
error: "device disconnected during action";
|
|
144
|
-
} | {
|
|
145
|
-
success: false;
|
|
146
|
-
error: "unexpected error";
|
|
147
|
-
} | {
|
|
148
|
-
success: false;
|
|
149
|
-
error: "Aborted by timeout";
|
|
150
|
-
} | {
|
|
151
|
-
success: false;
|
|
152
|
-
error: "Aborted by signal";
|
|
153
|
-
} | {
|
|
154
|
-
success: false;
|
|
155
|
-
error: "This transport can not be used in this environment";
|
|
156
|
-
} | {
|
|
157
|
-
success: false;
|
|
158
|
-
error: "device not found";
|
|
159
|
-
} | {
|
|
160
|
-
success: false;
|
|
161
|
-
error: "Unable to open device";
|
|
162
|
-
} | {
|
|
163
|
-
success: false;
|
|
164
|
-
error: "wrong previous session";
|
|
165
|
-
} | import("@trezor/transport/lib/types").Success<null> | undefined>;
|
|
131
|
+
acquire(): import("@trezor/transport/lib/types").AsyncResultWithTypedError<Session, "Network request failed" | "Wrong result type." | "device disconnected during action" | "unexpected error" | "Aborted by timeout" | "Aborted by signal" | "This transport can not be used in this environment" | "device not found" | "Unable to open device" | "descriptor not found" | "wrong previous session">;
|
|
132
|
+
release(): Promise<import("@trezor/transport/lib/types").Success<null> | import("@trezor/transport/lib/types").ErrorGeneric<"session not found" | "Network request failed" | "Wrong result type." | "device disconnected during action" | "unexpected error" | "Aborted by timeout" | "Aborted by signal" | "This transport can not be used in this environment" | "device not found" | "Unable to open device" | "wrong previous session"> | undefined>;
|
|
166
133
|
releaseTransportSession(): void;
|
|
167
134
|
cleanup(): Promise<void>;
|
|
168
135
|
handshake(delay?: number): Promise<void>;
|
|
@@ -215,40 +182,7 @@ export declare class Device extends TypedEmitter<DeviceEvents> {
|
|
|
215
182
|
getUniquePath(): DeviceUniquePath;
|
|
216
183
|
isT1(): boolean;
|
|
217
184
|
hasUnexpectedMode(allow: string[], require: string[]): "ui-device_bootloader_mode" | "ui-device_not_in_bootloader_mode" | "ui-device_not_initialized" | "ui-device_seedless" | null;
|
|
218
|
-
dispose(): Promise<
|
|
219
|
-
success: false;
|
|
220
|
-
error: "session not found";
|
|
221
|
-
} | {
|
|
222
|
-
success: false;
|
|
223
|
-
error: "Network request failed";
|
|
224
|
-
} | {
|
|
225
|
-
success: false;
|
|
226
|
-
error: "Wrong result type.";
|
|
227
|
-
} | {
|
|
228
|
-
success: false;
|
|
229
|
-
error: "device disconnected during action";
|
|
230
|
-
} | {
|
|
231
|
-
success: false;
|
|
232
|
-
error: "unexpected error";
|
|
233
|
-
} | {
|
|
234
|
-
success: false;
|
|
235
|
-
error: "Aborted by timeout";
|
|
236
|
-
} | {
|
|
237
|
-
success: false;
|
|
238
|
-
error: "Aborted by signal";
|
|
239
|
-
} | {
|
|
240
|
-
success: false;
|
|
241
|
-
error: "This transport can not be used in this environment";
|
|
242
|
-
} | {
|
|
243
|
-
success: false;
|
|
244
|
-
error: "device not found";
|
|
245
|
-
} | {
|
|
246
|
-
success: false;
|
|
247
|
-
error: "Unable to open device";
|
|
248
|
-
} | {
|
|
249
|
-
success: false;
|
|
250
|
-
error: "wrong previous session";
|
|
251
|
-
} | import("@trezor/transport/lib/types").Success<null> | undefined>;
|
|
185
|
+
dispose(): Promise<import("@trezor/transport/lib/types").Success<null> | import("@trezor/transport/lib/types").ErrorGeneric<"session not found" | "Network request failed" | "Wrong result type." | "device disconnected during action" | "unexpected error" | "Aborted by timeout" | "Aborted by signal" | "This transport can not be used in this environment" | "device not found" | "Unable to open device" | "wrong previous session"> | undefined>;
|
|
252
186
|
getMode(): "normal" | "bootloader" | "initialize" | "seedless";
|
|
253
187
|
toMessageObject(): DeviceTyped;
|
|
254
188
|
}
|
package/lib/device/Device.js
CHANGED
|
@@ -449,7 +449,11 @@ class Device extends utils_1.TypedEmitter {
|
|
|
449
449
|
}
|
|
450
450
|
async checkFirmwareHash() {
|
|
451
451
|
var _a;
|
|
452
|
-
const createFailResult = (error) => ({
|
|
452
|
+
const createFailResult = (error, errorPayload) => ({
|
|
453
|
+
success: false,
|
|
454
|
+
error,
|
|
455
|
+
errorPayload,
|
|
456
|
+
});
|
|
453
457
|
const baseUrl = DataManager_1.DataManager.getSettings('binFilesBaseUrl');
|
|
454
458
|
const enabled = DataManager_1.DataManager.getSettings('enableFirmwareHashCheck');
|
|
455
459
|
if (!enabled || baseUrl === undefined)
|
|
@@ -475,22 +479,19 @@ class Device extends utils_1.TypedEmitter {
|
|
|
475
479
|
}
|
|
476
480
|
const strippedBinary = (0, firmware_1.stripFwHeaders)(binary);
|
|
477
481
|
const { hash: expectedHash, challenge } = (0, firmware_1.calculateFirmwareHash)(this.features.major_version, strippedBinary, (0, crypto_1.randomBytes)(32));
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
});
|
|
482
|
+
try {
|
|
483
|
+
const deviceResponse = await this.getCommands().typedCall('GetFirmwareHash', 'FirmwareHash', { challenge });
|
|
484
|
+
if (!((_a = deviceResponse === null || deviceResponse === void 0 ? void 0 : deviceResponse.message) === null || _a === void 0 ? void 0 : _a.hash)) {
|
|
485
|
+
return createFailResult('other-error', 'Device response is missing hash');
|
|
483
486
|
}
|
|
484
|
-
|
|
485
|
-
return
|
|
487
|
+
if (deviceResponse.message.hash !== expectedHash) {
|
|
488
|
+
return createFailResult('hash-mismatch');
|
|
486
489
|
}
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
return createFailResult('other-error');
|
|
491
|
-
|
|
492
|
-
return createFailResult('hash-mismatch');
|
|
493
|
-
return { success: true };
|
|
490
|
+
return { success: true };
|
|
491
|
+
}
|
|
492
|
+
catch (errorPayload) {
|
|
493
|
+
return createFailResult('other-error', errorPayload);
|
|
494
|
+
}
|
|
494
495
|
}
|
|
495
496
|
async checkFirmwareRevision() {
|
|
496
497
|
const firmwareVersion = this.getVersion();
|
|
@@ -80,43 +80,7 @@ export declare class DeviceCommands {
|
|
|
80
80
|
cancelWithFallback(): Promise<{
|
|
81
81
|
readonly success: false;
|
|
82
82
|
readonly error: "session not found";
|
|
83
|
-
} | import("@trezor/transport/lib/types").Success<import("@trezor/protobuf").MessageFromTrezor> |
|
|
84
|
-
success: false;
|
|
85
|
-
error: "Network request failed";
|
|
86
|
-
} | {
|
|
87
|
-
success: false;
|
|
88
|
-
error: "Wrong result type.";
|
|
89
|
-
} | {
|
|
90
|
-
success: false;
|
|
91
|
-
error: "other call in progress";
|
|
92
|
-
} | {
|
|
93
|
-
success: false;
|
|
94
|
-
error: "Malformed protocol format";
|
|
95
|
-
} | {
|
|
96
|
-
success: false;
|
|
97
|
-
error: "device disconnected during action";
|
|
98
|
-
} | {
|
|
99
|
-
success: false;
|
|
100
|
-
error: "unexpected error";
|
|
101
|
-
} | {
|
|
102
|
-
success: false;
|
|
103
|
-
error: "Aborted by timeout";
|
|
104
|
-
} | {
|
|
105
|
-
success: false;
|
|
106
|
-
error: "Aborted by signal";
|
|
107
|
-
} | {
|
|
108
|
-
success: false;
|
|
109
|
-
error: "This transport can not be used in this environment";
|
|
110
|
-
} | {
|
|
111
|
-
success: false;
|
|
112
|
-
error: "device not found";
|
|
113
|
-
} | {
|
|
114
|
-
success: false;
|
|
115
|
-
error: "Unable to open device";
|
|
116
|
-
} | {
|
|
117
|
-
success: false;
|
|
118
|
-
error: "A transfer error has occurred.";
|
|
119
|
-
} | import("@trezor/transport/lib/types").Success<undefined> | undefined>;
|
|
83
|
+
} | import("@trezor/transport/lib/types").Success<import("@trezor/protobuf").MessageFromTrezor> | import("@trezor/transport/lib/types").ErrorGeneric<"session not found" | "Network request failed" | "Wrong result type." | "other call in progress" | "Malformed protocol format" | "device disconnected during action" | "unexpected error" | "Aborted by timeout" | "Aborted by signal" | "This transport can not be used in this environment" | "device not found" | "Unable to open device" | "A transfer error has occurred."> | import("@trezor/transport/lib/types").Success<undefined> | undefined>;
|
|
120
84
|
cancel(): Promise<void>;
|
|
121
85
|
}
|
|
122
86
|
export type TypedCall = DeviceCommands['typedCall'];
|
|
@@ -211,7 +211,7 @@ class DeviceCommands {
|
|
|
211
211
|
const res = await this.callPromise;
|
|
212
212
|
this.callPromise = undefined;
|
|
213
213
|
if (!res.success) {
|
|
214
|
-
logger.warn('Received error', res.error);
|
|
214
|
+
logger.warn('Received error', res.error, res.message);
|
|
215
215
|
throw new Error(res.error);
|
|
216
216
|
}
|
|
217
217
|
logger.debug('Received', res.payload.type, filterForLog(res.payload.type, res.payload.message));
|
package/lib/factory.js
CHANGED
|
@@ -23,6 +23,7 @@ const factory = ({ eventEmitter, manifest, init, call, requestLogin, uiResponse,
|
|
|
23
23
|
blockchainGetAccountBalanceHistory: params => call({ ...params, method: 'blockchainGetAccountBalanceHistory' }),
|
|
24
24
|
blockchainGetCurrentFiatRates: params => call({ ...params, method: 'blockchainGetCurrentFiatRates' }),
|
|
25
25
|
blockchainGetFiatRatesForTimestamps: params => call({ ...params, method: 'blockchainGetFiatRatesForTimestamps' }),
|
|
26
|
+
blockchainGetInfo: params => call({ ...params, method: 'blockchainGetInfo' }),
|
|
26
27
|
blockchainEvmRpcCall: params => call({ ...params, method: 'blockchainEvmRpcCall' }),
|
|
27
28
|
blockchainDisconnect: params => call({ ...params, method: 'blockchainDisconnect' }),
|
|
28
29
|
blockchainEstimateFee: params => call({ ...params, method: 'blockchainEstimateFee' }),
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import EventEmitter from 'events';
|
|
2
|
+
import { UiResponseEvent, CallMethodPayload, CoreRequestMessage } from '../events';
|
|
3
|
+
import type { ConnectSettings, ConnectSettingsPublic, DeviceIdentity, Manifest } from '../types';
|
|
4
|
+
import { ConnectFactoryDependencies } from '../factory';
|
|
5
|
+
export declare class CoreInModule implements ConnectFactoryDependencies<ConnectSettingsPublic> {
|
|
6
|
+
eventEmitter: EventEmitter<[never]>;
|
|
7
|
+
_settings: ConnectSettings;
|
|
8
|
+
private _coreManager?;
|
|
9
|
+
private _log;
|
|
10
|
+
private _messagePromises;
|
|
11
|
+
private readonly boundOnCoreEvent;
|
|
12
|
+
constructor();
|
|
13
|
+
private initCoreManager;
|
|
14
|
+
manifest(data: Manifest): void;
|
|
15
|
+
dispose(): Promise<undefined>;
|
|
16
|
+
cancel(error?: string): void;
|
|
17
|
+
handleCoreMessage(message: CoreRequestMessage): void;
|
|
18
|
+
private onCoreEvent;
|
|
19
|
+
init(settings?: Partial<ConnectSettings>): Promise<void>;
|
|
20
|
+
private initSettings;
|
|
21
|
+
initCore(): any;
|
|
22
|
+
call(params: CallMethodPayload): Promise<import("../types").Unsuccessful | {
|
|
23
|
+
id: number;
|
|
24
|
+
success: boolean;
|
|
25
|
+
payload: any;
|
|
26
|
+
device?: DeviceIdentity;
|
|
27
|
+
}>;
|
|
28
|
+
uiResponse(response: UiResponseEvent): void;
|
|
29
|
+
requestLogin(params: any): Promise<import("../types").Unsuccessful | {
|
|
30
|
+
id: number;
|
|
31
|
+
success: boolean;
|
|
32
|
+
payload: any;
|
|
33
|
+
device?: DeviceIdentity;
|
|
34
|
+
}>;
|
|
35
|
+
}
|
|
36
|
+
export declare const TrezorConnect: Omit<import("../types").TrezorConnect, "init"> & {
|
|
37
|
+
init: import("../types/api/init").InitType<Record<string, any>>;
|
|
38
|
+
} & Record<string, any>;
|
|
39
|
+
//# sourceMappingURL=core-in-module.d.ts.map
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TrezorConnect = exports.CoreInModule = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const events_1 = tslib_1.__importDefault(require("events"));
|
|
6
|
+
const utils_1 = require("@trezor/utils");
|
|
7
|
+
const ERRORS = tslib_1.__importStar(require("../constants/errors"));
|
|
8
|
+
const events_2 = require("../events");
|
|
9
|
+
const factory_1 = require("../factory");
|
|
10
|
+
const debug_1 = require("../utils/debug");
|
|
11
|
+
const connectSettings_1 = require("../data/connectSettings");
|
|
12
|
+
class CoreInModule {
|
|
13
|
+
constructor() {
|
|
14
|
+
this.eventEmitter = new events_1.default();
|
|
15
|
+
this.boundOnCoreEvent = this.onCoreEvent.bind(this);
|
|
16
|
+
this.initSettings = (settings = {}) => {
|
|
17
|
+
var _a;
|
|
18
|
+
this._settings = (0, connectSettings_1.parseConnectSettings)({
|
|
19
|
+
...this._settings,
|
|
20
|
+
...settings,
|
|
21
|
+
popup: false,
|
|
22
|
+
});
|
|
23
|
+
if (!this._settings.manifest) {
|
|
24
|
+
throw ERRORS.TypedError('Init_ManifestMissing');
|
|
25
|
+
}
|
|
26
|
+
if (!((_a = this._settings.transports) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
27
|
+
this._settings.transports = ['BridgeTransport'];
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
this._settings = (0, connectSettings_1.parseConnectSettings)();
|
|
31
|
+
this._log = (0, debug_1.initLog)('@trezor/connect-web');
|
|
32
|
+
this._messagePromises = (0, utils_1.createDeferredManager)({ initialId: 1 });
|
|
33
|
+
}
|
|
34
|
+
async initCoreManager() {
|
|
35
|
+
const { connectSrc } = this._settings;
|
|
36
|
+
const { initCoreState, initTransport } = await Promise.resolve(`${`${connectSrc}js/core.js`}`).then(s => tslib_1.__importStar(require(s))).catch(_err => {
|
|
37
|
+
this._log.error('_err', _err);
|
|
38
|
+
});
|
|
39
|
+
if (!initCoreState)
|
|
40
|
+
return;
|
|
41
|
+
if (initTransport) {
|
|
42
|
+
this._log.debug('initiating transport with settings: ', this._settings);
|
|
43
|
+
await initTransport(this._settings);
|
|
44
|
+
}
|
|
45
|
+
this._coreManager = initCoreState();
|
|
46
|
+
return this._coreManager;
|
|
47
|
+
}
|
|
48
|
+
manifest(data) {
|
|
49
|
+
this._settings = (0, connectSettings_1.parseConnectSettings)({
|
|
50
|
+
...this._settings,
|
|
51
|
+
manifest: data,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
dispose() {
|
|
55
|
+
this.eventEmitter.removeAllListeners();
|
|
56
|
+
this._settings = (0, connectSettings_1.parseConnectSettings)();
|
|
57
|
+
if (this._coreManager) {
|
|
58
|
+
this._coreManager.dispose();
|
|
59
|
+
}
|
|
60
|
+
return Promise.resolve(undefined);
|
|
61
|
+
}
|
|
62
|
+
cancel(error) {
|
|
63
|
+
if (this._coreManager) {
|
|
64
|
+
const core = this._coreManager.get();
|
|
65
|
+
if (!core) {
|
|
66
|
+
throw ERRORS.TypedError('Runtime', 'postMessage: _core not found');
|
|
67
|
+
}
|
|
68
|
+
this.handleCoreMessage({
|
|
69
|
+
type: events_2.POPUP.CLOSED,
|
|
70
|
+
payload: error ? { error } : null,
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
handleCoreMessage(message) {
|
|
75
|
+
const core = this._coreManager.get();
|
|
76
|
+
if (!core) {
|
|
77
|
+
throw ERRORS.TypedError('Runtime', 'postMessage: _core not found');
|
|
78
|
+
}
|
|
79
|
+
core.handleMessage(message);
|
|
80
|
+
}
|
|
81
|
+
onCoreEvent(rawMessage) {
|
|
82
|
+
var _a;
|
|
83
|
+
const message = (0, utils_1.cloneObject)(rawMessage);
|
|
84
|
+
const { event, type, payload } = message;
|
|
85
|
+
if (type === events_2.UI.REQUEST_UI_WINDOW) {
|
|
86
|
+
(_a = this._coreManager.get()) === null || _a === void 0 ? void 0 : _a.handleMessage({ type: events_2.POPUP.HANDSHAKE });
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
if (type === events_2.POPUP.CANCEL_POPUP_REQUEST)
|
|
90
|
+
return;
|
|
91
|
+
switch (event) {
|
|
92
|
+
case events_2.RESPONSE_EVENT: {
|
|
93
|
+
const { id = 0, success, device } = message;
|
|
94
|
+
const resolved = this._messagePromises.resolve(id, {
|
|
95
|
+
id,
|
|
96
|
+
success,
|
|
97
|
+
payload,
|
|
98
|
+
device,
|
|
99
|
+
});
|
|
100
|
+
if (!resolved)
|
|
101
|
+
this._log.warn(`Unknown message id ${id}`);
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
104
|
+
case events_2.DEVICE_EVENT:
|
|
105
|
+
this.eventEmitter.emit(event, message);
|
|
106
|
+
this.eventEmitter.emit(type, payload);
|
|
107
|
+
break;
|
|
108
|
+
case events_2.TRANSPORT_EVENT:
|
|
109
|
+
this.eventEmitter.emit(event, message);
|
|
110
|
+
this.eventEmitter.emit(type, payload);
|
|
111
|
+
break;
|
|
112
|
+
case events_2.BLOCKCHAIN_EVENT:
|
|
113
|
+
this.eventEmitter.emit(event, message);
|
|
114
|
+
this.eventEmitter.emit(type, payload);
|
|
115
|
+
break;
|
|
116
|
+
case events_2.UI_EVENT:
|
|
117
|
+
this.eventEmitter.emit(event, message);
|
|
118
|
+
this.eventEmitter.emit(type, payload);
|
|
119
|
+
break;
|
|
120
|
+
default:
|
|
121
|
+
this._log.warn('Undefined message', event, message);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
async init(settings = {}) {
|
|
125
|
+
var _a;
|
|
126
|
+
if (this._coreManager && (this._coreManager.get() || this._coreManager.getPending())) {
|
|
127
|
+
throw ERRORS.TypedError('Init_AlreadyInitialized');
|
|
128
|
+
}
|
|
129
|
+
this._settings = (0, connectSettings_1.parseConnectSettings)({ ...this._settings, ...settings });
|
|
130
|
+
if (!this._settings.manifest) {
|
|
131
|
+
throw ERRORS.TypedError('Init_ManifestMissing');
|
|
132
|
+
}
|
|
133
|
+
this._settings.lazyLoad = true;
|
|
134
|
+
if (!((_a = this._settings.transports) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
135
|
+
this._settings.transports = ['BridgeTransport', 'WebUsbTransport'];
|
|
136
|
+
}
|
|
137
|
+
if (!this._coreManager) {
|
|
138
|
+
this._coreManager = await this.initCoreManager();
|
|
139
|
+
await this._coreManager.getOrInit(this._settings, this.boundOnCoreEvent);
|
|
140
|
+
}
|
|
141
|
+
this._log.enabled = !!this._settings.debug;
|
|
142
|
+
}
|
|
143
|
+
initCore() {
|
|
144
|
+
this.initSettings({ lazyLoad: false });
|
|
145
|
+
return this._coreManager.getOrInit(this._settings, this.boundOnCoreEvent);
|
|
146
|
+
}
|
|
147
|
+
async call(params) {
|
|
148
|
+
try {
|
|
149
|
+
const { promiseId, promise } = this._messagePromises.create();
|
|
150
|
+
const payload = (0, utils_1.cloneObjectCyclic)(params);
|
|
151
|
+
this.handleCoreMessage({
|
|
152
|
+
type: events_2.IFRAME.CALL,
|
|
153
|
+
id: promiseId,
|
|
154
|
+
payload,
|
|
155
|
+
});
|
|
156
|
+
const response = (0, utils_1.cloneObject)(await promise);
|
|
157
|
+
return response !== null && response !== void 0 ? response : (0, events_2.createErrorMessage)(ERRORS.TypedError('Method_NoResponse'));
|
|
158
|
+
}
|
|
159
|
+
catch (error) {
|
|
160
|
+
this._log.error('call', error);
|
|
161
|
+
return (0, events_2.createErrorMessage)(error);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
uiResponse(response) {
|
|
165
|
+
const core = this._coreManager.get();
|
|
166
|
+
if (!core) {
|
|
167
|
+
throw ERRORS.TypedError('Runtime', 'postMessage: _core not found');
|
|
168
|
+
}
|
|
169
|
+
this.handleCoreMessage(response);
|
|
170
|
+
}
|
|
171
|
+
async requestLogin(params) {
|
|
172
|
+
if (typeof params.callback === 'function') {
|
|
173
|
+
const { callback } = params;
|
|
174
|
+
const core = this._coreManager.get();
|
|
175
|
+
const loginChallengeListener = async (event) => {
|
|
176
|
+
const { data } = event;
|
|
177
|
+
if (data && data.type === events_2.UI.LOGIN_CHALLENGE_REQUEST) {
|
|
178
|
+
try {
|
|
179
|
+
const payload = await callback();
|
|
180
|
+
this.handleCoreMessage({
|
|
181
|
+
type: events_2.UI.LOGIN_CHALLENGE_RESPONSE,
|
|
182
|
+
payload,
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
catch (error) {
|
|
186
|
+
this.handleCoreMessage({
|
|
187
|
+
type: events_2.UI.LOGIN_CHALLENGE_RESPONSE,
|
|
188
|
+
payload: error.message,
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
core === null || core === void 0 ? void 0 : core.on(events_2.CORE_EVENT, loginChallengeListener);
|
|
194
|
+
const response = await this.call({
|
|
195
|
+
method: 'requestLogin',
|
|
196
|
+
...params,
|
|
197
|
+
asyncChallenge: true,
|
|
198
|
+
callback: null,
|
|
199
|
+
});
|
|
200
|
+
core === null || core === void 0 ? void 0 : core.removeListener(events_2.CORE_EVENT, loginChallengeListener);
|
|
201
|
+
return response;
|
|
202
|
+
}
|
|
203
|
+
return this.call({ method: 'requestLogin', ...params });
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
exports.CoreInModule = CoreInModule;
|
|
207
|
+
const impl = new CoreInModule();
|
|
208
|
+
exports.TrezorConnect = (0, factory_1.factory)({
|
|
209
|
+
eventEmitter: impl.eventEmitter,
|
|
210
|
+
manifest: impl.manifest.bind(impl),
|
|
211
|
+
init: impl.init.bind(impl),
|
|
212
|
+
call: impl.call.bind(impl),
|
|
213
|
+
requestLogin: impl.requestLogin.bind(impl),
|
|
214
|
+
uiResponse: impl.uiResponse.bind(impl),
|
|
215
|
+
cancel: impl.cancel.bind(impl),
|
|
216
|
+
dispose: impl.dispose.bind(impl),
|
|
217
|
+
});
|
|
218
|
+
//# sourceMappingURL=core-in-module.js.map
|
|
@@ -8,7 +8,7 @@ export declare const ApplySettings: import("@trezor/schema-utils").TObject<{
|
|
|
8
8
|
passphrase_always_on_device: import("@trezor/schema-utils").TOptional<import("@trezor/schema-utils").TBoolean>;
|
|
9
9
|
safety_checks: import("@trezor/schema-utils").TOptional<import("@trezor/schema-utils/lib/custom-types/keyof-enum").TKeyOfEnum<typeof PROTO.Enum_SafetyCheckLevel>>;
|
|
10
10
|
auto_lock_delay_ms: import("@trezor/schema-utils").TOptional<import("@trezor/schema-utils").TNumber>;
|
|
11
|
-
display_rotation: import("@trezor/schema-utils").TOptional<import("@trezor/schema-utils").
|
|
11
|
+
display_rotation: import("@trezor/schema-utils").TOptional<import("@trezor/schema-utils/lib/custom-types/keyof-enum").TKeyOfEnum<typeof PROTO.Enum_DisplayRotation>>;
|
|
12
12
|
experimental_features: import("@trezor/schema-utils").TOptional<import("@trezor/schema-utils").TBoolean>;
|
|
13
13
|
hide_passphrase_from_host: import("@trezor/schema-utils").TOptional<import("@trezor/schema-utils").TBoolean>;
|
|
14
14
|
haptic_feedback: import("@trezor/schema-utils").TOptional<import("@trezor/schema-utils").TBoolean>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { BlockchainLinkResponse } from '@trezor/blockchain-link';
|
|
2
|
+
import type { CommonParamsWithCoin, Response } from '../params';
|
|
3
|
+
export declare function blockchainGetInfo(params: CommonParamsWithCoin): Response<BlockchainLinkResponse<'getInfo'>>;
|
|
4
|
+
//# sourceMappingURL=blockchainGetInfo.d.ts.map
|
package/lib/types/api/index.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ import { blockchainDisconnect } from './blockchainDisconnect';
|
|
|
10
10
|
import { blockchainEstimateFee } from './blockchainEstimateFee';
|
|
11
11
|
import { blockchainGetAccountBalanceHistory } from './blockchainGetAccountBalanceHistory';
|
|
12
12
|
import { blockchainGetCurrentFiatRates } from './blockchainGetCurrentFiatRates';
|
|
13
|
+
import { blockchainGetInfo } from './blockchainGetInfo';
|
|
13
14
|
import { blockchainEvmRpcCall } from './blockchainEvmRpcCall';
|
|
14
15
|
import { blockchainGetFiatRatesForTimestamps } from './blockchainGetFiatRatesForTimestamps';
|
|
15
16
|
import { blockchainGetTransactions } from './blockchainGetTransactions';
|
|
@@ -98,6 +99,7 @@ export interface TrezorConnect {
|
|
|
98
99
|
blockchainEstimateFee: typeof blockchainEstimateFee;
|
|
99
100
|
blockchainGetAccountBalanceHistory: typeof blockchainGetAccountBalanceHistory;
|
|
100
101
|
blockchainGetCurrentFiatRates: typeof blockchainGetCurrentFiatRates;
|
|
102
|
+
blockchainGetInfo: typeof blockchainGetInfo;
|
|
101
103
|
blockchainEvmRpcCall: typeof blockchainEvmRpcCall;
|
|
102
104
|
blockchainGetFiatRatesForTimestamps: typeof blockchainGetFiatRatesForTimestamps;
|
|
103
105
|
blockchainGetTransactions: typeof blockchainGetTransactions;
|
package/lib/types/device.d.ts
CHANGED
|
@@ -31,6 +31,7 @@ export type FirmwareHashCheckResult = {
|
|
|
31
31
|
} | {
|
|
32
32
|
success: false;
|
|
33
33
|
error: FirmwareHashCheckError;
|
|
34
|
+
errorPayload?: unknown;
|
|
34
35
|
};
|
|
35
36
|
export type DeviceUniquePath = string & {
|
|
36
37
|
__type: 'DeviceUniquePath';
|
|
@@ -104,6 +105,7 @@ export type UnreadableDevice = BaseDevice & {
|
|
|
104
105
|
export type Device = KnownDevice | UnknownDevice | UnreadableDevice;
|
|
105
106
|
export type Features = PROTO.Features;
|
|
106
107
|
export { DeviceModelInternal } from '@trezor/protobuf';
|
|
108
|
+
export type DisplayRotation = PROTO.DisplayRotation;
|
|
107
109
|
type FeaturesNarrowing = {
|
|
108
110
|
major_version: 2;
|
|
109
111
|
fw_major: null;
|
package/lib/types/settings.d.ts
CHANGED
|
@@ -39,7 +39,7 @@ export interface ConnectSettingsInternal {
|
|
|
39
39
|
export interface ConnectSettingsWeb {
|
|
40
40
|
hostLabel?: string;
|
|
41
41
|
hostIcon?: string;
|
|
42
|
-
coreMode?: 'auto' | 'popup' | 'iframe' | 'deeplink';
|
|
42
|
+
coreMode?: 'auto' | 'popup' | 'iframe' | 'deeplink' | 'suite-desktop';
|
|
43
43
|
}
|
|
44
44
|
export interface ConnectSettingsWebextension {
|
|
45
45
|
_extendWebextensionLifetime?: boolean;
|
package/lib/utils/assetUtils.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.tryLocalAssetRequire = void 0;
|
|
3
|
+
exports.tryLocalAssetRequire = exports.firmwareAssets = void 0;
|
|
4
4
|
const utils_1 = require("@trezor/utils");
|
|
5
5
|
const types_1 = require("../types");
|
|
6
6
|
const isDeviceModel = (model) => (0, utils_1.isArrayMember)(model, Object.values(types_1.DeviceModelInternal));
|
|
7
|
-
|
|
7
|
+
exports.firmwareAssets = {
|
|
8
8
|
[types_1.DeviceModelInternal.T1B1]: require('@trezor/connect-common/files/firmware/t1b1/releases.json'),
|
|
9
9
|
[types_1.DeviceModelInternal.T2T1]: require('@trezor/connect-common/files/firmware/t2t1/releases.json'),
|
|
10
10
|
[types_1.DeviceModelInternal.T2B1]: require('@trezor/connect-common/files/firmware/t2b1/releases.json'),
|
|
@@ -28,7 +28,7 @@ const tryLocalAssetRequire = (url) => {
|
|
|
28
28
|
if (firmwareMatch) {
|
|
29
29
|
const modelKey = firmwareMatch[1].toUpperCase();
|
|
30
30
|
if (isDeviceModel(modelKey)) {
|
|
31
|
-
return firmwareAssets[modelKey];
|
|
31
|
+
return exports.firmwareAssets[modelKey];
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
return null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trezor/connect",
|
|
3
|
-
"version": "9.4.
|
|
3
|
+
"version": "9.4.5",
|
|
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.",
|
|
@@ -72,16 +72,16 @@
|
|
|
72
72
|
"@ethereumjs/common": "^4.4.0",
|
|
73
73
|
"@ethereumjs/tx": "^5.4.0",
|
|
74
74
|
"@fivebinaries/coin-selection": "2.2.1",
|
|
75
|
-
"@trezor/blockchain-link": "2.3.
|
|
75
|
+
"@trezor/blockchain-link": "2.3.4",
|
|
76
76
|
"@trezor/blockchain-link-types": "1.2.3",
|
|
77
77
|
"@trezor/connect-analytics": "1.2.3",
|
|
78
|
-
"@trezor/connect-common": "0.2.
|
|
79
|
-
"@trezor/protobuf": "1.2.
|
|
78
|
+
"@trezor/connect-common": "0.2.5",
|
|
79
|
+
"@trezor/protobuf": "1.2.5",
|
|
80
80
|
"@trezor/protocol": "1.2.2",
|
|
81
81
|
"@trezor/schema-utils": "1.2.3",
|
|
82
|
-
"@trezor/transport": "1.3.
|
|
83
|
-
"@trezor/utils": "9.2.
|
|
84
|
-
"@trezor/utxo-lib": "2.2.
|
|
82
|
+
"@trezor/transport": "1.3.5",
|
|
83
|
+
"@trezor/utils": "9.2.4",
|
|
84
|
+
"@trezor/utxo-lib": "2.2.4",
|
|
85
85
|
"blakejs": "^1.2.1",
|
|
86
86
|
"bs58": "^6.0.0",
|
|
87
87
|
"bs58check": "^4.0.0",
|