@trezor/connect 9.0.0-beta.6 → 9.0.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/README.md +32 -19
- package/lib/api/binanceSignTransaction.js +1 -1
- package/lib/api/bitcoin/Fees.js +1 -1
- package/lib/api/bitcoin/TransactionComposer.js +1 -1
- package/lib/api/bitcoin/index.js +9 -9
- package/lib/api/bitcoin/refTx.d.ts +2 -2
- package/lib/api/checkFirmwareAuthenticity.d.ts +10 -0
- package/lib/api/checkFirmwareAuthenticity.js +44 -0
- package/lib/api/common/Discovery.js +1 -1
- package/lib/api/common/paramsValidator.d.ts +1 -1
- package/lib/api/composeTransaction.js +2 -2
- package/lib/api/eos/eosSignTx.js +1 -1
- package/lib/api/eosSignTransaction.js +1 -1
- package/lib/api/ethereum/__fixtures__/ethereumSignTypedData.js +1 -1
- package/lib/api/ethereum/ethereumSignTx.d.ts +2 -2
- package/lib/api/ethereum/ethereumSignTypedData.js +1 -1
- package/lib/api/ethereumSignTransaction.js +1 -1
- package/lib/api/firmware/calculateFirmwareHash.d.ts +1 -1
- package/lib/api/firmwareUpdate.js +1 -1
- package/lib/api/index.d.ts +1 -1
- package/lib/api/index.js +4 -4
- package/lib/api/nemSignTransaction.js +1 -1
- package/lib/api/signTransaction.js +1 -1
- package/lib/api/stellarSignTransaction.js +1 -1
- package/lib/api/tezos/tezosSignTx.js +1 -1
- package/lib/api/tezosSignTransaction.js +1 -1
- package/lib/backend/BlockchainLink.js +1 -1
- package/lib/constants/errors.d.ts +1 -2
- package/lib/constants/errors.js +0 -1
- package/lib/constants/index.js +5 -5
- package/lib/core/AbstractMethod.d.ts +0 -1
- package/lib/core/AbstractMethod.js +1 -2
- package/lib/core/index.d.ts +1 -1
- package/lib/core/index.js +1 -14
- package/lib/core/method.d.ts +1 -1
- package/lib/core/method.js +1 -1
- package/lib/data/DataManager.d.ts +2 -4
- package/lib/data/DataManager.js +4 -9
- package/lib/data/config.d.ts +1 -7
- package/lib/data/config.js +1 -9
- package/lib/data/connectSettings.d.ts +1 -1
- package/lib/data/version.d.ts +1 -1
- package/lib/data/version.js +1 -1
- package/lib/device/AbortController.js +1 -1
- package/lib/device/DescriptorStream.js +1 -1
- package/lib/device/Device.d.ts +1 -0
- package/lib/device/Device.js +9 -1
- package/lib/device/DeviceCommands.js +2 -2
- package/lib/device/DeviceList.d.ts +1 -5
- package/lib/device/DeviceList.js +7 -35
- package/lib/events/index.d.ts +0 -2
- package/lib/events/index.js +10 -10
- package/lib/events/ui-request.d.ts +1 -9
- package/lib/events/ui-request.js +0 -1
- package/lib/events/ui-response.d.ts +1 -10
- package/lib/events/ui-response.js +0 -1
- package/lib/exports.js +3 -3
- package/lib/factory.d.ts +1 -2
- package/lib/factory.js +2 -2
- package/lib/index-browser.js +1 -2
- package/lib/index.js +2 -35
- package/lib/types/api/checkFirmwareAuthenticity.d.ts +8 -0
- package/lib/types/api/{customMessage.js → checkFirmwareAuthenticity.js} +1 -1
- package/lib/types/api/index.d.ts +2 -2
- package/lib/types/device.d.ts +4 -0
- package/lib/types/index.js +15 -15
- package/lib/utils/__fixtures__/accountUtils.js +1 -1
- package/lib/utils/__fixtures__/ethereumUtils.js +1 -1
- package/lib/utils/__fixtures__/formatUtils.js +1 -1
- package/lib/utils/accountUtils.d.ts +2 -2
- package/lib/utils/assets-browser.js +1 -1
- package/lib/utils/assets.js +1 -1
- package/lib/utils/browserUtils.js +1 -1
- package/lib/utils/debug.d.ts +2 -2
- package/lib/utils/deviceFeaturesUtils.d.ts +1 -1
- package/lib/utils/ethereumUtils.d.ts +1 -1
- package/lib/utils/formatUtils.js +1 -1
- package/lib/utils/hdnodeUtils.d.ts +1 -1
- package/lib/utils/pathUtils.d.ts +2 -2
- package/lib/workers/workers-browser.js +5 -5
- package/lib/workers/workers-react-native.js +4 -4
- package/lib/workers/workers.js +4 -4
- package/package.json +16 -13
- package/lib/api/customMessage.d.ts +0 -13
- package/lib/api/customMessage.js +0 -56
- package/lib/types/api/customMessage.d.ts +0 -12
|
@@ -6,11 +6,9 @@ declare type AssetCollection = {
|
|
|
6
6
|
export declare class DataManager {
|
|
7
7
|
static assets: AssetCollection;
|
|
8
8
|
static settings: ConnectSettings;
|
|
9
|
-
static messages
|
|
10
|
-
[key: string]: JSON;
|
|
11
|
-
};
|
|
9
|
+
private static messages;
|
|
12
10
|
static load(settings: ConnectSettings, withAssets?: boolean): Promise<void>;
|
|
13
|
-
static getProtobufMessages(
|
|
11
|
+
static getProtobufMessages(): JSON;
|
|
14
12
|
static isWhitelisted(origin: string): {
|
|
15
13
|
origin: string;
|
|
16
14
|
priority: number;
|
package/lib/data/DataManager.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DataManager = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const parse_uri_1 =
|
|
5
|
+
const parse_uri_1 = tslib_1.__importDefault(require("parse-uri"));
|
|
6
6
|
const assets_1 = require("../utils/assets");
|
|
7
7
|
const connectSettings_1 = require("./connectSettings");
|
|
8
8
|
const coinInfo_1 = require("./coinInfo");
|
|
@@ -40,18 +40,14 @@ class DataManager {
|
|
|
40
40
|
this.assets[asset.name] = json;
|
|
41
41
|
});
|
|
42
42
|
await Promise.all(assetPromises);
|
|
43
|
-
|
|
44
|
-
const json = await (0, assets_1.httpRequest)(`${protobuf.json}${ts}`, 'json');
|
|
45
|
-
this.messages[protobuf.name] = json;
|
|
46
|
-
});
|
|
47
|
-
await Promise.all(protobufPromises);
|
|
43
|
+
this.messages = await (0, assets_1.httpRequest)(`${config_1.config.messages}${ts}`, 'json');
|
|
48
44
|
(0, transportInfo_1.parseBridgeJSON)(this.assets.bridge);
|
|
49
45
|
(0, coinInfo_1.parseCoinsJson)(this.assets.coins);
|
|
50
46
|
(0, firmwareInfo_1.parseFirmware)(this.assets['firmware-t1'], 1);
|
|
51
47
|
(0, firmwareInfo_1.parseFirmware)(this.assets['firmware-t2'], 2);
|
|
52
48
|
}
|
|
53
|
-
static getProtobufMessages(
|
|
54
|
-
return this.messages
|
|
49
|
+
static getProtobufMessages() {
|
|
50
|
+
return this.messages;
|
|
55
51
|
}
|
|
56
52
|
static isWhitelisted(origin) {
|
|
57
53
|
const uri = (0, parse_uri_1.default)(origin);
|
|
@@ -94,5 +90,4 @@ class DataManager {
|
|
|
94
90
|
}
|
|
95
91
|
exports.DataManager = DataManager;
|
|
96
92
|
DataManager.assets = {};
|
|
97
|
-
DataManager.messages = {};
|
|
98
93
|
//# sourceMappingURL=DataManager.js.map
|
package/lib/data/config.d.ts
CHANGED
package/lib/data/config.js
CHANGED
|
@@ -63,15 +63,7 @@ exports.config = {
|
|
|
63
63
|
url: './data/firmware/2/releases.json',
|
|
64
64
|
},
|
|
65
65
|
],
|
|
66
|
-
messages:
|
|
67
|
-
{
|
|
68
|
-
name: 'default',
|
|
69
|
-
range: {
|
|
70
|
-
min: ['1.0.0', '2.0.0'],
|
|
71
|
-
},
|
|
72
|
-
json: './data/messages/messages.json',
|
|
73
|
-
},
|
|
74
|
-
],
|
|
66
|
+
messages: './data/messages/messages.json',
|
|
75
67
|
supportedBrowsers: {
|
|
76
68
|
chrome: {
|
|
77
69
|
version: 59,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ConnectSettings } from '../types';
|
|
2
2
|
export declare const DEFAULT_PRIORITY = 2;
|
|
3
3
|
export declare const getEnv: () => "web" | "webextension" | "electron" | "react-native";
|
|
4
|
-
export declare const corsValidator: (url?: string
|
|
4
|
+
export declare const corsValidator: (url?: string) => string | undefined;
|
|
5
5
|
export declare const parseConnectSettings: (input?: Partial<ConnectSettings>) => ConnectSettings;
|
|
6
6
|
//# sourceMappingURL=connectSettings.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.DEFAULT_DOMAIN = exports.VERSION = void 0;
|
|
4
|
-
exports.VERSION = '9.0.
|
|
4
|
+
exports.VERSION = '9.0.1';
|
|
5
5
|
const versionN = exports.VERSION.split('.').map(s => parseInt(s, 10));
|
|
6
6
|
exports.DEFAULT_DOMAIN = `https://connect.trezor.io/${versionN[0]}/`;
|
|
7
7
|
//# sourceMappingURL=version.js.map
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getAbortController = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const events_1 =
|
|
5
|
+
const events_1 = tslib_1.__importDefault(require("events"));
|
|
6
6
|
class AbortSignal {
|
|
7
7
|
constructor() {
|
|
8
8
|
this.aborted = false;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DescriptorStream = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const events_1 =
|
|
5
|
+
const events_1 = tslib_1.__importDefault(require("events"));
|
|
6
6
|
const transport_1 = require("../events/transport");
|
|
7
7
|
const device_1 = require("../events/device");
|
|
8
8
|
const debug_1 = require("../utils/debug");
|
package/lib/device/Device.d.ts
CHANGED
|
@@ -51,6 +51,7 @@ export declare class Device extends EventEmitter {
|
|
|
51
51
|
externalState: string[];
|
|
52
52
|
unavailableCapabilities: UnavailableCapabilities;
|
|
53
53
|
networkTypeState: NETWORK.NetworkType[];
|
|
54
|
+
firmwareType: 'regular' | 'bitcoin-only';
|
|
54
55
|
constructor(transport: Transport, descriptor: DeviceDescriptor);
|
|
55
56
|
static fromDescriptor(transport: Transport, originalDescriptor: DeviceDescriptor): Device;
|
|
56
57
|
static createUnacquired(transport: Transport, descriptor: DeviceDescriptor, unreadableError?: string): Device;
|
package/lib/device/Device.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Device = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const events_1 =
|
|
5
|
+
const events_1 = tslib_1.__importDefault(require("events"));
|
|
6
6
|
const DeviceCommands_1 = require("./DeviceCommands");
|
|
7
7
|
const constants_1 = require("../constants");
|
|
8
8
|
const events_2 = require("../events");
|
|
@@ -31,6 +31,7 @@ class Device extends events_1.default {
|
|
|
31
31
|
this.externalState = [];
|
|
32
32
|
this.unavailableCapabilities = {};
|
|
33
33
|
this.networkTypeState = [];
|
|
34
|
+
this.firmwareType = 'regular';
|
|
34
35
|
this.transport = transport;
|
|
35
36
|
this.originalDescriptor = descriptor;
|
|
36
37
|
this.firstRunPromise = (0, deferred_1.create)();
|
|
@@ -305,6 +306,12 @@ class Device extends events_1.default {
|
|
|
305
306
|
feat.revision = revision;
|
|
306
307
|
this.features = feat;
|
|
307
308
|
this.featuresNeedsReload = false;
|
|
309
|
+
this.firmwareType =
|
|
310
|
+
feat.capabilities &&
|
|
311
|
+
feat.capabilities.length > 0 &&
|
|
312
|
+
!feat.capabilities.includes('Capability_Bitcoin_like')
|
|
313
|
+
? 'bitcoin-only'
|
|
314
|
+
: 'regular';
|
|
308
315
|
}
|
|
309
316
|
isUnacquired() {
|
|
310
317
|
return this.features === undefined;
|
|
@@ -482,6 +489,7 @@ class Device extends events_1.default {
|
|
|
482
489
|
mode: this.getMode(),
|
|
483
490
|
firmware: this.firmwareStatus,
|
|
484
491
|
firmwareRelease: this.firmwareRelease,
|
|
492
|
+
firmwareType: this.firmwareType,
|
|
485
493
|
features: this.features,
|
|
486
494
|
unavailableCapabilities: this.unavailableCapabilities,
|
|
487
495
|
};
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DeviceCommands = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const randombytes_1 =
|
|
5
|
+
const randombytes_1 = tslib_1.__importDefault(require("randombytes"));
|
|
6
6
|
const constants_1 = require("../constants");
|
|
7
7
|
const events_1 = require("../events");
|
|
8
|
-
const hdnodeUtils =
|
|
8
|
+
const hdnodeUtils = tslib_1.__importStar(require("../utils/hdnodeUtils"));
|
|
9
9
|
const pathUtils_1 = require("../utils/pathUtils");
|
|
10
10
|
const accountUtils_1 = require("../utils/accountUtils");
|
|
11
11
|
const versionUtils_1 = require("../utils/versionUtils");
|
|
@@ -39,9 +39,7 @@ export declare class DeviceList extends EventEmitter {
|
|
|
39
39
|
creatingDevicesDescriptors: {
|
|
40
40
|
[k: string]: DeviceDescriptor;
|
|
41
41
|
};
|
|
42
|
-
|
|
43
|
-
currentMessages: JSON | Record<string, any>;
|
|
44
|
-
hasCustomMessages: boolean;
|
|
42
|
+
messages: JSON | Record<string, any>;
|
|
45
43
|
transportStartPending: number;
|
|
46
44
|
penalizedDevices: {
|
|
47
45
|
[deviceID: string]: number;
|
|
@@ -49,8 +47,6 @@ export declare class DeviceList extends EventEmitter {
|
|
|
49
47
|
fetchController?: Controller | null;
|
|
50
48
|
constructor();
|
|
51
49
|
init(): Promise<void>;
|
|
52
|
-
reconfigure(messages: JSON | Record<string, any> | number[], custom?: boolean): Promise<void>;
|
|
53
|
-
restoreMessages(): Promise<void>;
|
|
54
50
|
resolveTransportEvent(): void;
|
|
55
51
|
waitForTransportFirstEvent(): Promise<void>;
|
|
56
52
|
_initStream(): void;
|
package/lib/device/DeviceList.js
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getDeviceList = exports.DeviceList = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const events_1 =
|
|
6
|
-
const transport_1 =
|
|
7
|
-
const cross_fetch_1 =
|
|
5
|
+
const events_1 = tslib_1.__importDefault(require("events"));
|
|
6
|
+
const transport_1 = tslib_1.__importDefault(require("@trezor/transport"));
|
|
7
|
+
const cross_fetch_1 = tslib_1.__importDefault(require("cross-fetch"));
|
|
8
8
|
const constants_1 = require("../constants");
|
|
9
9
|
const events_2 = require("../events");
|
|
10
10
|
const DescriptorStream_1 = require("./DescriptorStream");
|
|
@@ -19,11 +19,10 @@ const { BridgeV2, Fallback } = transport_1.default;
|
|
|
19
19
|
const _log = (0, debug_1.initLog)('DeviceList');
|
|
20
20
|
class DeviceList extends events_1.default {
|
|
21
21
|
constructor() {
|
|
22
|
-
var _a
|
|
22
|
+
var _a;
|
|
23
23
|
super();
|
|
24
24
|
this.devices = {};
|
|
25
25
|
this.creatingDevicesDescriptors = {};
|
|
26
|
-
this.hasCustomMessages = false;
|
|
27
26
|
this.transportStartPending = 0;
|
|
28
27
|
this.penalizedDevices = {};
|
|
29
28
|
const { env, webusb } = DataManager_1.DataManager.settings;
|
|
@@ -38,7 +37,7 @@ class DeviceList extends events_1.default {
|
|
|
38
37
|
this.fetchController = (0, AbortController_1.getAbortController)();
|
|
39
38
|
const { signal } = this.fetchController;
|
|
40
39
|
const fetchWithSignal = (args, options = {}) => (0, cross_fetch_1.default)(args, { ...options, signal });
|
|
41
|
-
const isNode = ((
|
|
40
|
+
const isNode = !!((_a = process === null || process === void 0 ? void 0 : process.release) === null || _a === void 0 ? void 0 : _a.name) && process.release.name.search(/node|io\.js/) !== -1;
|
|
42
41
|
BridgeV2.setFetch(fetchWithSignal, isNode);
|
|
43
42
|
transports.push(bridge);
|
|
44
43
|
}
|
|
@@ -46,8 +45,7 @@ class DeviceList extends events_1.default {
|
|
|
46
45
|
transports.push((0, workers_1.WebUsbPlugin)());
|
|
47
46
|
}
|
|
48
47
|
this.transport = new Fallback(transports);
|
|
49
|
-
this.
|
|
50
|
-
this.currentMessages = this.defaultMessages;
|
|
48
|
+
this.messages = DataManager_1.DataManager.getProtobufMessages();
|
|
51
49
|
}
|
|
52
50
|
async init() {
|
|
53
51
|
const { transport } = this;
|
|
@@ -55,7 +53,7 @@ class DeviceList extends events_1.default {
|
|
|
55
53
|
_log.debug('Initializing transports');
|
|
56
54
|
await transport.init(_log.enabled);
|
|
57
55
|
_log.debug('Configuring transports');
|
|
58
|
-
await transport.configure(JSON.stringify(this.
|
|
56
|
+
await transport.configure(JSON.stringify(this.messages));
|
|
59
57
|
_log.debug('Configuring transports done');
|
|
60
58
|
const { activeName } = transport;
|
|
61
59
|
if (activeName === 'LowlevelTransportWithSharedConnections') {
|
|
@@ -69,32 +67,6 @@ class DeviceList extends events_1.default {
|
|
|
69
67
|
this.emit(events_2.TRANSPORT.ERROR, error);
|
|
70
68
|
}
|
|
71
69
|
}
|
|
72
|
-
async reconfigure(messages, custom) {
|
|
73
|
-
if (Array.isArray(messages)) {
|
|
74
|
-
messages = DataManager_1.DataManager.getProtobufMessages(messages);
|
|
75
|
-
}
|
|
76
|
-
if (this.currentMessages === messages || !messages)
|
|
77
|
-
return;
|
|
78
|
-
try {
|
|
79
|
-
await this.transport.configure(JSON.stringify(messages));
|
|
80
|
-
this.currentMessages = messages;
|
|
81
|
-
this.hasCustomMessages = typeof custom === 'boolean' ? custom : false;
|
|
82
|
-
}
|
|
83
|
-
catch (error) {
|
|
84
|
-
throw constants_1.ERRORS.TypedError('Transport_InvalidProtobuf', error.message);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
async restoreMessages() {
|
|
88
|
-
if (!this.hasCustomMessages)
|
|
89
|
-
return;
|
|
90
|
-
try {
|
|
91
|
-
await this.transport.configure(JSON.stringify(this.defaultMessages));
|
|
92
|
-
this.hasCustomMessages = false;
|
|
93
|
-
}
|
|
94
|
-
catch (error) {
|
|
95
|
-
throw constants_1.ERRORS.TypedError('Transport_InvalidProtobuf', error.message);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
70
|
resolveTransportEvent() {
|
|
99
71
|
this.transportStartPending--;
|
|
100
72
|
if (this.transportStartPending === 0) {
|
package/lib/events/index.d.ts
CHANGED
|
@@ -19,7 +19,6 @@ export declare const UI: {
|
|
|
19
19
|
readonly RECEIVE_WORD: "ui-receive_word";
|
|
20
20
|
readonly INVALID_PASSPHRASE_ACTION: "ui-invalid_passphrase_action";
|
|
21
21
|
readonly CHANGE_SETTINGS: "ui-change_settings";
|
|
22
|
-
readonly CUSTOM_MESSAGE_RESPONSE: "ui-custom_response";
|
|
23
22
|
readonly LOGIN_CHALLENGE_RESPONSE: "ui-login_challenge_response";
|
|
24
23
|
readonly TRANSPORT: "ui-no_transport";
|
|
25
24
|
readonly BOOTLOADER: "ui-device_bootloader_mode";
|
|
@@ -54,7 +53,6 @@ export declare const UI: {
|
|
|
54
53
|
readonly REQUEST_BUTTON: "ui-button";
|
|
55
54
|
readonly REQUEST_WORD: "ui-request_word";
|
|
56
55
|
readonly LOGIN_CHALLENGE_REQUEST: "ui-login_challenge_request";
|
|
57
|
-
readonly CUSTOM_MESSAGE_REQUEST: "ui-custom_request";
|
|
58
56
|
readonly BUNDLE_PROGRESS: "ui-bundle_progress";
|
|
59
57
|
readonly ADDRESS_VALIDATION: "ui-address_validation";
|
|
60
58
|
readonly IFRAME_FAILURE: "ui-iframe_failure";
|
package/lib/events/index.js
CHANGED
|
@@ -4,16 +4,16 @@ exports.UI = void 0;
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const ui_request_1 = require("./ui-request");
|
|
6
6
|
const ui_response_1 = require("./ui-response");
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
7
|
+
tslib_1.__exportStar(require("./blockchain"), exports);
|
|
8
|
+
tslib_1.__exportStar(require("./call"), exports);
|
|
9
|
+
tslib_1.__exportStar(require("./core"), exports);
|
|
10
|
+
tslib_1.__exportStar(require("./device"), exports);
|
|
11
|
+
tslib_1.__exportStar(require("./iframe"), exports);
|
|
12
|
+
tslib_1.__exportStar(require("./popup"), exports);
|
|
13
|
+
tslib_1.__exportStar(require("./transport"), exports);
|
|
14
|
+
tslib_1.__exportStar(require("./ui-promise"), exports);
|
|
15
|
+
tslib_1.__exportStar(require("./ui-request"), exports);
|
|
16
|
+
tslib_1.__exportStar(require("./ui-response"), exports);
|
|
17
17
|
exports.UI = {
|
|
18
18
|
...ui_request_1.UI_REQUEST,
|
|
19
19
|
...ui_response_1.UI_RESPONSE,
|
|
@@ -39,7 +39,6 @@ export declare const UI_REQUEST: {
|
|
|
39
39
|
readonly REQUEST_BUTTON: "ui-button";
|
|
40
40
|
readonly REQUEST_WORD: "ui-request_word";
|
|
41
41
|
readonly LOGIN_CHALLENGE_REQUEST: "ui-login_challenge_request";
|
|
42
|
-
readonly CUSTOM_MESSAGE_REQUEST: "ui-custom_request";
|
|
43
42
|
readonly BUNDLE_PROGRESS: "ui-bundle_progress";
|
|
44
43
|
readonly ADDRESS_VALIDATION: "ui-address_validation";
|
|
45
44
|
readonly IFRAME_FAILURE: "ui-iframe_failure";
|
|
@@ -163,14 +162,7 @@ export interface FirmwareProgress {
|
|
|
163
162
|
progress: number;
|
|
164
163
|
};
|
|
165
164
|
}
|
|
166
|
-
export
|
|
167
|
-
type: typeof UI_REQUEST.CUSTOM_MESSAGE_REQUEST;
|
|
168
|
-
payload: {
|
|
169
|
-
type: string;
|
|
170
|
-
message: object;
|
|
171
|
-
};
|
|
172
|
-
}
|
|
173
|
-
export declare type UiEvent = UiRequestWithoutPayload | UiRequestDeviceAction | UiRequestButton | UiRequestPermission | UiRequestConfirmation | UiRequestSelectDevice | UiRequestUnexpectedDeviceMode | UiRequestSelectAccount | UiRequestSelectFee | UpdateCustomFee | BundleProgress<any> | FirmwareProgress | FirmwareException | UiRequestAddressValidation | UiRequestCustomMessage | UiRequestSetOperation | TransportDisableWebUSB;
|
|
165
|
+
export declare type UiEvent = UiRequestWithoutPayload | UiRequestDeviceAction | UiRequestButton | UiRequestPermission | UiRequestConfirmation | UiRequestSelectDevice | UiRequestUnexpectedDeviceMode | UiRequestSelectAccount | UiRequestSelectFee | UpdateCustomFee | BundleProgress<any> | FirmwareProgress | FirmwareException | UiRequestAddressValidation | UiRequestSetOperation | TransportDisableWebUSB;
|
|
174
166
|
export declare type UiEventMessage = UiEvent & {
|
|
175
167
|
event: typeof UI_EVENT;
|
|
176
168
|
};
|
package/lib/events/ui-request.js
CHANGED
|
@@ -36,7 +36,6 @@ exports.UI_REQUEST = {
|
|
|
36
36
|
REQUEST_BUTTON: 'ui-button',
|
|
37
37
|
REQUEST_WORD: 'ui-request_word',
|
|
38
38
|
LOGIN_CHALLENGE_REQUEST: 'ui-login_challenge_request',
|
|
39
|
-
CUSTOM_MESSAGE_REQUEST: 'ui-custom_request',
|
|
40
39
|
BUNDLE_PROGRESS: 'ui-bundle_progress',
|
|
41
40
|
ADDRESS_VALIDATION: 'ui-address_validation',
|
|
42
41
|
IFRAME_FAILURE: 'ui-iframe_failure',
|
|
@@ -13,7 +13,6 @@ export declare const UI_RESPONSE: {
|
|
|
13
13
|
readonly RECEIVE_WORD: "ui-receive_word";
|
|
14
14
|
readonly INVALID_PASSPHRASE_ACTION: "ui-invalid_passphrase_action";
|
|
15
15
|
readonly CHANGE_SETTINGS: "ui-change_settings";
|
|
16
|
-
readonly CUSTOM_MESSAGE_RESPONSE: "ui-custom_response";
|
|
17
16
|
readonly LOGIN_CHALLENGE_RESPONSE: "ui-login_challenge_response";
|
|
18
17
|
};
|
|
19
18
|
export interface UiResponsePopupHandshake {
|
|
@@ -74,14 +73,6 @@ export interface UiResponseFee {
|
|
|
74
73
|
value: string;
|
|
75
74
|
};
|
|
76
75
|
}
|
|
77
|
-
export interface UiResponseCustomMessage {
|
|
78
|
-
type: typeof UI_RESPONSE.CUSTOM_MESSAGE_RESPONSE;
|
|
79
|
-
payload: {
|
|
80
|
-
type: string;
|
|
81
|
-
message: any;
|
|
82
|
-
params?: any;
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
76
|
export interface UiResponseLoginChallenge {
|
|
86
77
|
type: typeof UI_RESPONSE.LOGIN_CHALLENGE_RESPONSE;
|
|
87
78
|
payload: {
|
|
@@ -89,7 +80,7 @@ export interface UiResponseLoginChallenge {
|
|
|
89
80
|
challengeVisual: string;
|
|
90
81
|
};
|
|
91
82
|
}
|
|
92
|
-
export declare type UiResponseEvent = UiResponsePopupHandshake | UiResponsePermission | UiResponseConfirmation | UiResponseDevice | UiResponsePin | UiResponseWord | UiResponsePassphrase | UiResponsePassphraseAction | UiResponseAccount | UiResponseFee | UiResponseLoginChallenge
|
|
83
|
+
export declare type UiResponseEvent = UiResponsePopupHandshake | UiResponsePermission | UiResponseConfirmation | UiResponseDevice | UiResponsePin | UiResponseWord | UiResponsePassphrase | UiResponsePassphraseAction | UiResponseAccount | UiResponseFee | UiResponseLoginChallenge;
|
|
93
84
|
export declare type UiResponseMessage = UiResponseEvent & {
|
|
94
85
|
event: typeof UI_EVENT;
|
|
95
86
|
};
|
|
@@ -13,7 +13,6 @@ exports.UI_RESPONSE = {
|
|
|
13
13
|
RECEIVE_WORD: 'ui-receive_word',
|
|
14
14
|
INVALID_PASSPHRASE_ACTION: 'ui-invalid_passphrase_action',
|
|
15
15
|
CHANGE_SETTINGS: 'ui-change_settings',
|
|
16
|
-
CUSTOM_MESSAGE_RESPONSE: 'ui-custom_response',
|
|
17
16
|
LOGIN_CHALLENGE_RESPONSE: 'ui-login_challenge_response',
|
|
18
17
|
};
|
|
19
18
|
const createUiResponse = (type, payload) => ({
|
package/lib/exports.js
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.parseConnectSettings = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
tslib_1.__exportStar(require("./constants"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./events"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./types"), exports);
|
|
8
8
|
var connectSettings_1 = require("./data/connectSettings");
|
|
9
9
|
Object.defineProperty(exports, "parseConnectSettings", { enumerable: true, get: function () { return connectSettings_1.parseConnectSettings; } });
|
|
10
10
|
//# sourceMappingURL=exports.js.map
|
package/lib/factory.d.ts
CHANGED
|
@@ -7,7 +7,6 @@ interface Dependencies {
|
|
|
7
7
|
eventEmitter: EventEmitter;
|
|
8
8
|
manifest: TrezorConnect['manifest'];
|
|
9
9
|
init: TrezorConnect['init'];
|
|
10
|
-
customMessage: TrezorConnect['customMessage'];
|
|
11
10
|
requestLogin: TrezorConnect['requestLogin'];
|
|
12
11
|
uiResponse: TrezorConnect['uiResponse'];
|
|
13
12
|
renderWebUSBButton: TrezorConnect['renderWebUSBButton'];
|
|
@@ -15,6 +14,6 @@ interface Dependencies {
|
|
|
15
14
|
cancel: TrezorConnect['cancel'];
|
|
16
15
|
dispose: TrezorConnect['dispose'];
|
|
17
16
|
}
|
|
18
|
-
export declare const factory: ({ eventEmitter, manifest, init, call,
|
|
17
|
+
export declare const factory: ({ eventEmitter, manifest, init, call, requestLogin, uiResponse, renderWebUSBButton, disableWebUSB, cancel, dispose, }: Dependencies) => TrezorConnect;
|
|
19
18
|
export {};
|
|
20
19
|
//# sourceMappingURL=factory.d.ts.map
|
package/lib/factory.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.factory = void 0;
|
|
4
4
|
const events_1 = require("./events");
|
|
5
|
-
const factory = ({ eventEmitter, manifest, init, call,
|
|
5
|
+
const factory = ({ eventEmitter, manifest, init, call, requestLogin, uiResponse, renderWebUSBButton, disableWebUSB, cancel, dispose, }) => {
|
|
6
6
|
const api = {
|
|
7
7
|
manifest,
|
|
8
8
|
init,
|
|
@@ -33,7 +33,6 @@ const factory = ({ eventEmitter, manifest, init, call, customMessage, requestLog
|
|
|
33
33
|
blockchainSubscribeFiatRates: params => call({ ...params, method: 'blockchainSubscribeFiatRates' }),
|
|
34
34
|
blockchainUnsubscribe: params => call({ ...params, method: 'blockchainUnsubscribe' }),
|
|
35
35
|
blockchainUnsubscribeFiatRates: params => call({ ...params, method: 'blockchainUnsubscribeFiatRates' }),
|
|
36
|
-
customMessage: params => customMessage(params),
|
|
37
36
|
requestLogin: params => requestLogin(params),
|
|
38
37
|
cardanoGetAddress: params => call({
|
|
39
38
|
...params,
|
|
@@ -107,6 +106,7 @@ const factory = ({ eventEmitter, manifest, init, call, customMessage, requestLog
|
|
|
107
106
|
verifyMessage: params => call({ ...params, method: 'verifyMessage' }),
|
|
108
107
|
resetDevice: params => call({ ...params, method: 'resetDevice' }),
|
|
109
108
|
wipeDevice: params => call({ ...params, method: 'wipeDevice' }),
|
|
109
|
+
checkFirmwareAuthenticity: params => call({ ...params, method: 'checkFirmwareAuthenticity' }),
|
|
110
110
|
applyFlags: params => call({ ...params, method: 'applyFlags' }),
|
|
111
111
|
applySettings: params => call({ ...params, method: 'applySettings' }),
|
|
112
112
|
authorizeCoinJoin: params => call({ ...params, method: 'authorizeCoinJoin' }),
|
package/lib/index-browser.js
CHANGED
|
@@ -16,7 +16,6 @@ const TrezorConnect = (0, factory_1.factory)({
|
|
|
16
16
|
manifest: fallback,
|
|
17
17
|
init: fallback,
|
|
18
18
|
call: fallback,
|
|
19
|
-
customMessage: fallback,
|
|
20
19
|
requestLogin: fallback,
|
|
21
20
|
uiResponse: fallback,
|
|
22
21
|
renderWebUSBButton: fallback,
|
|
@@ -25,5 +24,5 @@ const TrezorConnect = (0, factory_1.factory)({
|
|
|
25
24
|
dispose: fallback,
|
|
26
25
|
});
|
|
27
26
|
exports.default = TrezorConnect;
|
|
28
|
-
|
|
27
|
+
tslib_1.__exportStar(require("./exports"), exports);
|
|
29
28
|
//# sourceMappingURL=index-browser.js.map
|
package/lib/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.messagePromises = exports.eventEmitter = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const events_1 =
|
|
5
|
+
const events_1 = tslib_1.__importDefault(require("events"));
|
|
6
6
|
const utils_1 = require("@trezor/utils");
|
|
7
7
|
const core_1 = require("./core");
|
|
8
8
|
const factory_1 = require("./factory");
|
|
@@ -132,16 +132,6 @@ const call = async (params) => {
|
|
|
132
132
|
return (0, events_2.createErrorMessage)(error);
|
|
133
133
|
}
|
|
134
134
|
};
|
|
135
|
-
const customMessageResponse = (payload) => {
|
|
136
|
-
if (!_core) {
|
|
137
|
-
return Promise.resolve((0, events_2.createErrorMessage)(constants_1.ERRORS.TypedError('Init_NotInitialized')));
|
|
138
|
-
}
|
|
139
|
-
_core.handleMessage({
|
|
140
|
-
event: events_2.UI_EVENT,
|
|
141
|
-
type: events_2.UI.CUSTOM_MESSAGE_RESPONSE,
|
|
142
|
-
payload,
|
|
143
|
-
}, true);
|
|
144
|
-
};
|
|
145
135
|
const uiResponse = (response) => {
|
|
146
136
|
if (!_core) {
|
|
147
137
|
throw constants_1.ERRORS.TypedError('Init_NotInitialized');
|
|
@@ -149,28 +139,6 @@ const uiResponse = (response) => {
|
|
|
149
139
|
const { type, payload } = response;
|
|
150
140
|
_core.handleMessage({ event: events_2.UI_EVENT, type, payload }, true);
|
|
151
141
|
};
|
|
152
|
-
const customMessage = async (params) => {
|
|
153
|
-
if (typeof params.callback !== 'function') {
|
|
154
|
-
return (0, events_2.createErrorMessage)(constants_1.ERRORS.TypedError('Method_CustomMessage_Callback'));
|
|
155
|
-
}
|
|
156
|
-
const { callback } = params;
|
|
157
|
-
const customMessageListener = async (event) => {
|
|
158
|
-
const { data } = event;
|
|
159
|
-
if (data && data.type === events_2.UI.CUSTOM_MESSAGE_REQUEST) {
|
|
160
|
-
const payload = await callback(data.payload);
|
|
161
|
-
if (payload) {
|
|
162
|
-
customMessageResponse(payload);
|
|
163
|
-
}
|
|
164
|
-
else {
|
|
165
|
-
customMessageResponse({ message: 'release' });
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
};
|
|
169
|
-
_core === null || _core === void 0 ? void 0 : _core.on(events_2.CORE_EVENT, customMessageListener);
|
|
170
|
-
const response = await call({ method: 'customMessage', ...params, callback: null });
|
|
171
|
-
_core === null || _core === void 0 ? void 0 : _core.removeListener(events_2.CORE_EVENT, customMessageListener);
|
|
172
|
-
return response;
|
|
173
|
-
};
|
|
174
142
|
const requestLogin = async (params) => {
|
|
175
143
|
if (typeof params.callback === 'function') {
|
|
176
144
|
const { callback } = params;
|
|
@@ -223,7 +191,6 @@ const TrezorConnect = (0, factory_1.factory)({
|
|
|
223
191
|
manifest,
|
|
224
192
|
init,
|
|
225
193
|
call,
|
|
226
|
-
customMessage,
|
|
227
194
|
requestLogin,
|
|
228
195
|
uiResponse,
|
|
229
196
|
renderWebUSBButton,
|
|
@@ -232,5 +199,5 @@ const TrezorConnect = (0, factory_1.factory)({
|
|
|
232
199
|
dispose,
|
|
233
200
|
});
|
|
234
201
|
exports.default = TrezorConnect;
|
|
235
|
-
|
|
202
|
+
tslib_1.__exportStar(require("./exports"), exports);
|
|
236
203
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Response, CommonParams } from '../params';
|
|
2
|
+
export interface CheckFirmwareAuthenticityResponse {
|
|
3
|
+
expectedFirmwareHash: string;
|
|
4
|
+
actualFirmwareHash: string;
|
|
5
|
+
valid: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare function checkFirmwareAuthenticity(params: CommonParams): Response<CheckFirmwareAuthenticityResponse>;
|
|
8
|
+
//# sourceMappingURL=checkFirmwareAuthenticity.d.ts.map
|
package/lib/types/api/index.d.ts
CHANGED
|
@@ -24,7 +24,6 @@ import { cardanoSignTransaction } from './cardanoSignTransaction';
|
|
|
24
24
|
import { changePin } from './changePin';
|
|
25
25
|
import { cipherKeyValue } from './cipherKeyValue';
|
|
26
26
|
import { composeTransaction } from './composeTransaction';
|
|
27
|
-
import { customMessage } from './customMessage';
|
|
28
27
|
import { disableWebUSB } from './disableWebUSB';
|
|
29
28
|
import { dispose } from './dispose';
|
|
30
29
|
import { eosGetPublicKey } from './eosGetPublicKey';
|
|
@@ -72,6 +71,7 @@ import { tezosSignTransaction } from './tezosSignTransaction';
|
|
|
72
71
|
import { uiResponse } from './uiResponse';
|
|
73
72
|
import { verifyMessage } from './verifyMessage';
|
|
74
73
|
import { wipeDevice } from './wipeDevice';
|
|
74
|
+
import { checkFirmwareAuthenticity } from './checkFirmwareAuthenticity';
|
|
75
75
|
export interface TrezorConnect {
|
|
76
76
|
applyFlags: typeof applyFlags;
|
|
77
77
|
applySettings: typeof applySettings;
|
|
@@ -99,7 +99,6 @@ export interface TrezorConnect {
|
|
|
99
99
|
changePin: typeof changePin;
|
|
100
100
|
cipherKeyValue: typeof cipherKeyValue;
|
|
101
101
|
composeTransaction: typeof composeTransaction;
|
|
102
|
-
customMessage: typeof customMessage;
|
|
103
102
|
disableWebUSB: typeof disableWebUSB;
|
|
104
103
|
dispose: typeof dispose;
|
|
105
104
|
eosGetPublicKey: typeof eosGetPublicKey;
|
|
@@ -147,5 +146,6 @@ export interface TrezorConnect {
|
|
|
147
146
|
uiResponse: typeof uiResponse;
|
|
148
147
|
verifyMessage: typeof verifyMessage;
|
|
149
148
|
wipeDevice: typeof wipeDevice;
|
|
149
|
+
checkFirmwareAuthenticity: typeof checkFirmwareAuthenticity;
|
|
150
150
|
}
|
|
151
151
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/types/device.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export declare type DeviceStatus = 'available' | 'occupied' | 'used';
|
|
|
4
4
|
export declare type DeviceMode = 'normal' | 'bootloader' | 'initialize' | 'seedless';
|
|
5
5
|
export declare type DeviceFirmwareStatus = 'valid' | 'outdated' | 'required' | 'unknown' | 'none';
|
|
6
6
|
export declare type UnavailableCapability = 'no-capability' | 'no-support' | 'update-required' | 'trezor-connect-outdated';
|
|
7
|
+
export declare type FirmwareType = 'bitcoin-only' | 'regular';
|
|
7
8
|
export declare type UnavailableCapabilities = {
|
|
8
9
|
[key: string]: UnavailableCapability;
|
|
9
10
|
};
|
|
@@ -15,6 +16,7 @@ export declare type KnownDevice = {
|
|
|
15
16
|
error?: typeof undefined;
|
|
16
17
|
firmware: DeviceFirmwareStatus;
|
|
17
18
|
firmwareRelease?: ReleaseInfo | null;
|
|
19
|
+
firmwareType?: FirmwareType;
|
|
18
20
|
status: DeviceStatus;
|
|
19
21
|
mode: DeviceMode;
|
|
20
22
|
state?: string;
|
|
@@ -30,6 +32,7 @@ export declare type UnknownDevice = {
|
|
|
30
32
|
features?: typeof undefined;
|
|
31
33
|
firmware?: typeof undefined;
|
|
32
34
|
firmwareRelease?: typeof undefined;
|
|
35
|
+
firmwareType?: typeof undefined;
|
|
33
36
|
status?: typeof undefined;
|
|
34
37
|
mode?: typeof undefined;
|
|
35
38
|
state?: typeof undefined;
|
|
@@ -44,6 +47,7 @@ export declare type UnreadableDevice = {
|
|
|
44
47
|
features?: typeof undefined;
|
|
45
48
|
firmware?: typeof undefined;
|
|
46
49
|
firmwareRelease?: typeof undefined;
|
|
50
|
+
firmwareType?: typeof undefined;
|
|
47
51
|
status?: typeof undefined;
|
|
48
52
|
mode?: typeof undefined;
|
|
49
53
|
state?: typeof undefined;
|