@trezor/connect 9.2.5-beta.1 → 9.3.0
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 +71 -18
- package/README.md +2 -2
- package/lib/api/solana/api/solanaGetAddress.d.ts +1 -1
- package/lib/api/solana/api/solanaGetAddress.js +1 -1
- package/lib/core/coreManager.d.ts +16 -0
- package/lib/core/coreManager.js +55 -0
- package/lib/core/index.d.ts +7 -1
- package/lib/core/index.js +43 -31
- package/lib/data/models.js +4 -4
- package/lib/data/version.d.ts +1 -1
- package/lib/data/version.js +1 -1
- package/lib/device/Device.js +5 -0
- package/lib/device/DeviceList.js +2 -0
- package/lib/factory.d.ts +2 -3
- package/lib/index.js +27 -29
- package/package.json +14 -15
package/CHANGELOG.md
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
| Package | Stable |
|
|
2
|
-
| :------------------------------: | :----: |
|
|
3
|
-
| npm @trezor/connect | 9.
|
|
4
|
-
| npm @trezor/connect-web | 9.
|
|
5
|
-
| npm @trezor/connect-webextension | 9.
|
|
1
|
+
| Package | Stable | Canary |
|
|
2
|
+
| :------------------------------: | :----: | :----: |
|
|
3
|
+
| npm @trezor/connect | 9.3.0 | - |
|
|
4
|
+
| npm @trezor/connect-web | 9.3.0 | - |
|
|
5
|
+
| npm @trezor/connect-webextension | 9.3.0 | - |
|
|
6
6
|
|
|
7
|
-
| Deployment
|
|
8
|
-
|
|
|
9
|
-
| connect.trezor.io/
|
|
7
|
+
| Deployment | Stable | Canary |
|
|
8
|
+
| :----------------: | :----: | :----: |
|
|
9
|
+
| connect.trezor.io/ | 9.3.0 | - |
|
|
10
10
|
|
|
11
|
-
Use the persistent link connect.trezor.io/9 to access the latest stable version of Connect Explorer.
|
|
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.
|
|
13
|
+
# 9.3.0
|
|
14
14
|
|
|
15
15
|
Improved reliability of popup handshake mechanism.
|
|
16
16
|
Improved compatibility with webextensions using TrezorConnect inside offscreen (eg. Metamask).
|
|
@@ -27,9 +27,36 @@ Minor fixes in Connect Explorer and documentation.
|
|
|
27
27
|
- chore(connect): center changelog version table (93fab15)
|
|
28
28
|
- chore(connect): change name in changelog table (bbc5499)
|
|
29
29
|
- chore(connect): remove canary from changelog
|
|
30
|
+
- fix(connect): race condition when closing and opening popup subsequently (e0e51c7)
|
|
31
|
+
- chore(connect): implement required descriptor.type (9ef657f)
|
|
32
|
+
- docs(connect): Explorer landing page update (7db29e9)
|
|
33
|
+
- fix(connect): deviceList may become undefined after init transport (firefox) (322651b)
|
|
34
|
+
- fix(connect): Core with pending initialization (3f8e405)
|
|
35
|
+
- fix(connect): preserve DEVICE.ACQUIRED listeners after unsuccessful workflow (4cede4e)
|
|
36
|
+
- fix(connect): don't save state with legacy passphrase (af90317)
|
|
37
|
+
- feat(connect): new T3T1 colors (0797090)
|
|
38
|
+
- chores: 583fbd0, a27a385, 6c789d2
|
|
39
|
+
|
|
40
|
+
## connect-explorer
|
|
41
|
+
|
|
42
|
+
- readme pages (be0f933)
|
|
43
|
+
- getFeatures (0f9d057)
|
|
44
|
+
- don't change affected fields in manual mode (2c7143e)
|
|
45
|
+
- canary release explanation in changelog (6cf1eae)
|
|
46
|
+
- theme: steps colors (1f7a9e4)
|
|
47
|
+
- delete deprecated webusb parameter from init docs (a92429e)
|
|
48
|
+
- zoomable and dark mode illustrations (8d55ed1)
|
|
49
|
+
- some attributes were not passed trough the proxy (5cb6a26)
|
|
50
|
+
- MTT content max height (c8796b4)
|
|
51
|
+
- add links in changelog page (8dabb30)
|
|
52
|
+
- remove nextra reference from webextension, show amountUnit in signTransaction and fix favicon path
|
|
30
53
|
|
|
31
54
|
## connect-web
|
|
32
55
|
|
|
56
|
+
- publish trezor-usb-permissions.html in NPM (c8628ea)
|
|
57
|
+
- refactor into classes (fc7a45b)
|
|
58
|
+
- core-in-popup mode (52891f3)
|
|
59
|
+
- passphrase missmatch resets the flow now (d55ff1c)
|
|
33
60
|
- close on popup cancellation, legacy mode for handshake
|
|
34
61
|
- check if chrome.tabs really available in webextension env
|
|
35
62
|
|
|
@@ -37,22 +64,48 @@ Minor fixes in Connect Explorer and documentation.
|
|
|
37
64
|
|
|
38
65
|
- handshake handling issues
|
|
39
66
|
|
|
40
|
-
## connect-
|
|
67
|
+
## connect-webextension
|
|
41
68
|
|
|
42
|
-
-
|
|
69
|
+
- stop publishing Trezor connect webextension proxy (5df3ae0)
|
|
70
|
+
- bundle content script to work properly with ES6 modules (fff7eaf)
|
|
71
|
+
|
|
72
|
+
## connect-examples
|
|
73
|
+
|
|
74
|
+
- Improve the mv3 sw example to be make it easier for 3rd parties to understand how to integrate connect-webextension (884ec96, a0c0706)
|
|
75
|
+
|
|
76
|
+
## connect-common
|
|
77
|
+
|
|
78
|
+
- edit firmware changelogs (3637a56)
|
|
79
|
+
- firmware release url (0166df5)
|
|
80
|
+
- update firmware binaries to 2.7.2 (6392328)
|
|
81
|
+
- T3T1 support (9d0adae)
|
|
43
82
|
|
|
44
83
|
## connect-popup
|
|
45
84
|
|
|
46
85
|
- temporary workaround for CONTENT_SCRIPT_LOADED and handling of CONTENT_SCRIPT_LOADED
|
|
47
86
|
|
|
87
|
+
## connect-ui
|
|
88
|
+
|
|
89
|
+
- install bridge title align (19c5781)
|
|
90
|
+
|
|
48
91
|
## Dependencies update
|
|
49
92
|
|
|
50
|
-
-
|
|
51
|
-
|
|
52
|
-
- npm-release: @trezor/
|
|
53
|
-
- npm-release: @trezor/
|
|
54
|
-
- npm-release: @trezor/
|
|
55
|
-
- npm-release: @trezor/utils
|
|
93
|
+
- bump ws from 8.16.0 to 8.17.1 (bc5b787)
|
|
94
|
+
|
|
95
|
+
- npm-release: @trezor/blockchain-link 2.2.0
|
|
96
|
+
- npm-release: @trezor/blockchain-link-utils 1.1.0
|
|
97
|
+
- npm-release: @trezor/blockchain-link-types 1.1.0
|
|
98
|
+
- npm-release: @trezor/type-utils 1.1.0
|
|
99
|
+
- npm-release: @trezor/connect-analytics 1.1.0
|
|
100
|
+
- npm-release: @trezor/analytics 1.1.0
|
|
101
|
+
- npm-release: @trezor/connect-common 0.1.0
|
|
102
|
+
- npm-release: @trezor/env-utils 1.1.0
|
|
103
|
+
- npm-release: @trezor/transport 1.2.0
|
|
104
|
+
- npm-release: @trezor/protobuf 1.1.0
|
|
105
|
+
- npm-release: @trezor/schema-utils 1.1.0
|
|
106
|
+
- npm-release: @trezor/protocol 1.1.0
|
|
107
|
+
- npm-release: @trezor/utxo-lib 2.1.0
|
|
108
|
+
- npm-release: @trezor/utils 9.1.0
|
|
56
109
|
|
|
57
110
|
# 9.2.4
|
|
58
111
|
|
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# @trezor/connect
|
|
2
2
|
|
|
3
|
-
API version 9.
|
|
3
|
+
API version 9.3.0
|
|
4
4
|
|
|
5
|
-
[](https://github.com/trezor/trezor-suite/actions/workflows/test-connect.yml)
|
|
6
6
|
[](https://www.npmjs.org/package/@trezor/connect)
|
|
7
7
|
[](https://snyk.io/test/github/trezor/trezor-suite?targetFile=packages/connect/package.json)
|
|
8
8
|
|
|
@@ -7,7 +7,7 @@ export default class SolanaGetAddress extends AbstractMethod<'solanaGetAddress',
|
|
|
7
7
|
hasBundle?: boolean;
|
|
8
8
|
progress: number;
|
|
9
9
|
init(): void;
|
|
10
|
-
get info(): "Export
|
|
10
|
+
get info(): "Export Solana address" | "Export multiple Solana addresses";
|
|
11
11
|
getButtonRequestData(code: string): {
|
|
12
12
|
type: "address";
|
|
13
13
|
serializedPath: string;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { EventEmitter } from 'events';
|
|
3
|
+
import { CoreEventMessage } from '../events';
|
|
4
|
+
import { ConnectSettings } from '../types';
|
|
5
|
+
type CoreInstance = EventEmitter & {
|
|
6
|
+
init: (settings: ConnectSettings, onCoreEvent: (message: CoreEventMessage) => void, ...rest: any[]) => Promise<void>;
|
|
7
|
+
dispose: () => any;
|
|
8
|
+
};
|
|
9
|
+
export declare const initCoreManager: <Core extends CoreInstance>(core: Core) => {
|
|
10
|
+
getOrInitCore: (...[settings, onCoreEvent, ...rest]: Parameters<Core["init"]>) => Promise<Core>;
|
|
11
|
+
getCore: () => Core | undefined;
|
|
12
|
+
getInitPromise: () => Promise<Core> | undefined;
|
|
13
|
+
dispose: () => void;
|
|
14
|
+
};
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=coreManager.d.ts.map
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.initCoreManager = void 0;
|
|
4
|
+
const utils_1 = require("@trezor/utils");
|
|
5
|
+
const events_1 = require("../events");
|
|
6
|
+
const initCoreManager = (core) => {
|
|
7
|
+
const state = {};
|
|
8
|
+
let initDfd;
|
|
9
|
+
const getOrInitCore = (...[settings, onCoreEvent, ...rest]) => {
|
|
10
|
+
if (state.core)
|
|
11
|
+
return Promise.resolve(state.core);
|
|
12
|
+
if (state.initPromise)
|
|
13
|
+
return state.initPromise;
|
|
14
|
+
const eventThrottle = async (...args) => {
|
|
15
|
+
if (state.initPromise) {
|
|
16
|
+
const core = await state.initPromise.catch(() => { });
|
|
17
|
+
if (!core)
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
onCoreEvent(...args);
|
|
21
|
+
};
|
|
22
|
+
const dfd = (0, utils_1.createDeferred)();
|
|
23
|
+
initDfd = dfd;
|
|
24
|
+
state.initPromise = dfd.promise;
|
|
25
|
+
core.init(settings, eventThrottle, ...rest)
|
|
26
|
+
.then(() => {
|
|
27
|
+
core.on(events_1.CORE_EVENT, onCoreEvent);
|
|
28
|
+
core.off(events_1.CORE_EVENT, eventThrottle);
|
|
29
|
+
state.core = core;
|
|
30
|
+
dfd.resolve(core);
|
|
31
|
+
})
|
|
32
|
+
.catch(dfd.reject)
|
|
33
|
+
.finally(() => {
|
|
34
|
+
initDfd = undefined;
|
|
35
|
+
delete state.initPromise;
|
|
36
|
+
});
|
|
37
|
+
return dfd.promise;
|
|
38
|
+
};
|
|
39
|
+
const dispose = () => {
|
|
40
|
+
var _a;
|
|
41
|
+
initDfd === null || initDfd === void 0 ? void 0 : initDfd.reject(new Error('Core disposed'));
|
|
42
|
+
initDfd = undefined;
|
|
43
|
+
(_a = state.core) === null || _a === void 0 ? void 0 : _a.dispose();
|
|
44
|
+
delete state.initPromise;
|
|
45
|
+
delete state.core;
|
|
46
|
+
};
|
|
47
|
+
return {
|
|
48
|
+
getOrInitCore,
|
|
49
|
+
getCore: () => state.core,
|
|
50
|
+
getInitPromise: () => state.initPromise,
|
|
51
|
+
dispose,
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
exports.initCoreManager = initCoreManager;
|
|
55
|
+
//# sourceMappingURL=coreManager.js.map
|
package/lib/core/index.d.ts
CHANGED
|
@@ -11,6 +11,12 @@ export declare class Core extends EventEmitter {
|
|
|
11
11
|
getCurrentMethod(): Promise<AbstractMethod<any, undefined>>;
|
|
12
12
|
getTransportInfo(): TransportInfo | undefined;
|
|
13
13
|
enumerate(): void;
|
|
14
|
+
init(settings: ConnectSettings, onCoreEvent: (message: CoreEventMessage) => void, logWriterFactory?: () => LogWriter | undefined): Promise<void>;
|
|
14
15
|
}
|
|
15
|
-
export declare const
|
|
16
|
+
export declare const initCoreState: () => {
|
|
17
|
+
getOrInitCore: (settings: ConnectSettings, onCoreEvent: (message: CoreEventMessage) => void, logWriterFactory?: (() => LogWriter | undefined) | undefined) => Promise<Core>;
|
|
18
|
+
getCore: () => Core | undefined;
|
|
19
|
+
getInitPromise: () => Promise<Core> | undefined;
|
|
20
|
+
dispose: () => void;
|
|
21
|
+
};
|
|
16
22
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/core/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.initCoreState = exports.Core = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const events_1 = tslib_1.__importDefault(require("events"));
|
|
6
6
|
const transport_1 = require("@trezor/transport");
|
|
@@ -20,6 +20,7 @@ const debug_1 = require("../utils/debug");
|
|
|
20
20
|
const BlockchainLink_1 = require("../backend/BlockchainLink");
|
|
21
21
|
const interactionTimeout_1 = require("../utils/interactionTimeout");
|
|
22
22
|
const onCallFirmwareUpdate_1 = require("./onCallFirmwareUpdate");
|
|
23
|
+
const coreManager_1 = require("./coreManager");
|
|
23
24
|
let _core;
|
|
24
25
|
let _deviceList;
|
|
25
26
|
const _callMethods = [];
|
|
@@ -55,6 +56,9 @@ const initDevice = async (devicePath) => {
|
|
|
55
56
|
throw constants_1.ERRORS.TypedError('Transport_Missing');
|
|
56
57
|
}
|
|
57
58
|
await _deviceList.transportFirstEventPromise;
|
|
59
|
+
if (!_deviceList) {
|
|
60
|
+
throw constants_1.ERRORS.TypedError('Transport_Missing');
|
|
61
|
+
}
|
|
58
62
|
const isWebUsb = _deviceList.transportType() === 'WebUsbTransport';
|
|
59
63
|
let device;
|
|
60
64
|
let showDeviceSelection = isWebUsb;
|
|
@@ -456,6 +460,9 @@ const onCall = async (message) => {
|
|
|
456
460
|
}
|
|
457
461
|
}
|
|
458
462
|
await device.cleanup();
|
|
463
|
+
if (useCoreInPopup) {
|
|
464
|
+
postMessage(response);
|
|
465
|
+
}
|
|
459
466
|
closePopup();
|
|
460
467
|
cleanup();
|
|
461
468
|
if (method) {
|
|
@@ -466,7 +473,9 @@ const onCall = async (message) => {
|
|
|
466
473
|
_deviceList.removeAuthPenalty(device);
|
|
467
474
|
}
|
|
468
475
|
}
|
|
469
|
-
|
|
476
|
+
if (!useCoreInPopup) {
|
|
477
|
+
postMessage(response);
|
|
478
|
+
}
|
|
470
479
|
}
|
|
471
480
|
}
|
|
472
481
|
};
|
|
@@ -654,6 +663,7 @@ class Core extends events_1.default {
|
|
|
654
663
|
popupPromise.resolve();
|
|
655
664
|
break;
|
|
656
665
|
case events_2.POPUP.CLOSED:
|
|
666
|
+
popupPromise.clear();
|
|
657
667
|
onPopupClosed(message.payload ? message.payload.error : null);
|
|
658
668
|
break;
|
|
659
669
|
case transport_1.TRANSPORT.DISABLE_WEBUSB:
|
|
@@ -728,38 +738,36 @@ class Core extends events_1.default {
|
|
|
728
738
|
}
|
|
729
739
|
_deviceList.enumerate();
|
|
730
740
|
}
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
if (logWriterFactory) {
|
|
735
|
-
(0, debug_1.setLogWriter)(logWriterFactory);
|
|
736
|
-
}
|
|
737
|
-
try {
|
|
738
|
-
await DataManager_1.DataManager.load(settings);
|
|
739
|
-
(0, debug_1.enableLog)(DataManager_1.DataManager.getSettings('debug'));
|
|
740
|
-
_core = new Core();
|
|
741
|
-
_interactionTimeout = new interactionTimeout_1.InteractionTimeout(settings.popup ? settings.interactionTimeout : 0);
|
|
742
|
-
_core.on(events_2.CORE_EVENT, onCoreEvent);
|
|
743
|
-
}
|
|
744
|
-
catch (error) {
|
|
745
|
-
_log.error('init', error);
|
|
746
|
-
throw error;
|
|
747
|
-
}
|
|
748
|
-
try {
|
|
749
|
-
if (!DataManager_1.DataManager.getSettings('transportReconnect')) {
|
|
750
|
-
await initDeviceList(false);
|
|
741
|
+
async init(settings, onCoreEvent, logWriterFactory) {
|
|
742
|
+
if (logWriterFactory) {
|
|
743
|
+
(0, debug_1.setLogWriter)(logWriterFactory);
|
|
751
744
|
}
|
|
752
|
-
|
|
753
|
-
|
|
745
|
+
try {
|
|
746
|
+
await DataManager_1.DataManager.load(settings);
|
|
747
|
+
(0, debug_1.enableLog)(DataManager_1.DataManager.getSettings('debug'));
|
|
748
|
+
_core = this;
|
|
749
|
+
_interactionTimeout = new interactionTimeout_1.InteractionTimeout(settings.popup ? settings.interactionTimeout : 0);
|
|
750
|
+
this.on(events_2.CORE_EVENT, onCoreEvent);
|
|
751
|
+
}
|
|
752
|
+
catch (error) {
|
|
753
|
+
_log.error('init', error);
|
|
754
|
+
throw error;
|
|
755
|
+
}
|
|
756
|
+
try {
|
|
757
|
+
if (!DataManager_1.DataManager.getSettings('transportReconnect')) {
|
|
758
|
+
await initDeviceList(false);
|
|
759
|
+
}
|
|
760
|
+
else {
|
|
761
|
+
initDeviceList(true);
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
catch (error) {
|
|
765
|
+
_log.error('initTransport', error);
|
|
766
|
+
throw error;
|
|
754
767
|
}
|
|
755
768
|
}
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
throw error;
|
|
759
|
-
}
|
|
760
|
-
return _core;
|
|
761
|
-
};
|
|
762
|
-
exports.initCore = initCore;
|
|
769
|
+
}
|
|
770
|
+
exports.Core = Core;
|
|
763
771
|
const disableWebUSBTransport = async () => {
|
|
764
772
|
var _a;
|
|
765
773
|
if (!_deviceList)
|
|
@@ -783,4 +791,8 @@ const disableWebUSBTransport = async () => {
|
|
|
783
791
|
catch (error) {
|
|
784
792
|
}
|
|
785
793
|
};
|
|
794
|
+
const initCoreState = () => {
|
|
795
|
+
return (0, coreManager_1.initCoreManager)(new Core());
|
|
796
|
+
};
|
|
797
|
+
exports.initCoreState = initCoreState;
|
|
786
798
|
//# sourceMappingURL=index.js.map
|
package/lib/data/models.js
CHANGED
|
@@ -23,10 +23,10 @@ exports.models = {
|
|
|
23
23
|
T3T1: {
|
|
24
24
|
name: 'Trezor Safe 5',
|
|
25
25
|
colors: {
|
|
26
|
-
'1': '
|
|
27
|
-
'2': '
|
|
28
|
-
'3': '
|
|
29
|
-
'4': '
|
|
26
|
+
'1': 'Black Graphite',
|
|
27
|
+
'2': 'Violet Ore',
|
|
28
|
+
'3': 'Green Beryl',
|
|
29
|
+
'4': 'Bitcoin Orange',
|
|
30
30
|
},
|
|
31
31
|
},
|
|
32
32
|
};
|
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.
|
|
4
|
+
exports.VERSION = '9.3.0';
|
|
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.js
CHANGED
|
@@ -112,9 +112,11 @@ class Device extends utils_1.TypedEmitter {
|
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
114
|
async cleanup() {
|
|
115
|
+
const acquiredListeners = this.listeners(events_1.DEVICE.ACQUIRED);
|
|
115
116
|
this.removeAllListeners();
|
|
116
117
|
delete this.runPromise;
|
|
117
118
|
await this.release();
|
|
119
|
+
acquiredListeners.forEach(l => this.once(events_1.DEVICE.ACQUIRED, l));
|
|
118
120
|
}
|
|
119
121
|
run(fn, options) {
|
|
120
122
|
if (this.runPromise) {
|
|
@@ -245,6 +247,9 @@ class Device extends utils_1.TypedEmitter {
|
|
|
245
247
|
}
|
|
246
248
|
else if (state !== this.internalState[this.instance]) {
|
|
247
249
|
this.internalState[this.instance] = state;
|
|
250
|
+
if (this.useLegacyPassphrase() && this.isT1()) {
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
248
253
|
this.emit(events_1.DEVICE.SAVE_STATE, state);
|
|
249
254
|
}
|
|
250
255
|
}
|
package/lib/device/DeviceList.js
CHANGED
|
@@ -175,6 +175,7 @@ class DeviceList extends utils_1.TypedEmitter {
|
|
|
175
175
|
session: d.session,
|
|
176
176
|
path: d.path,
|
|
177
177
|
product: d.product,
|
|
178
|
+
type: d.type,
|
|
178
179
|
};
|
|
179
180
|
}
|
|
180
181
|
});
|
|
@@ -293,6 +294,7 @@ class DeviceList extends utils_1.TypedEmitter {
|
|
|
293
294
|
session: d.session,
|
|
294
295
|
path: d.path,
|
|
295
296
|
product: d.product,
|
|
297
|
+
type: d.type,
|
|
296
298
|
};
|
|
297
299
|
this.devices[d.path].activitySessionID = d.session;
|
|
298
300
|
}
|
package/lib/factory.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import type { EventEmitter } from 'events';
|
|
3
3
|
import type { TrezorConnect } from './types';
|
|
4
4
|
import type { CallMethod } from './events/call';
|
|
5
|
-
interface
|
|
5
|
+
export interface ConnectFactoryDependencies {
|
|
6
6
|
call: CallMethod;
|
|
7
7
|
eventEmitter: EventEmitter;
|
|
8
8
|
manifest: TrezorConnect['manifest'];
|
|
@@ -15,6 +15,5 @@ interface Dependencies {
|
|
|
15
15
|
cancel: TrezorConnect['cancel'];
|
|
16
16
|
dispose: TrezorConnect['dispose'];
|
|
17
17
|
}
|
|
18
|
-
export declare const factory: ({ eventEmitter, manifest, init, call, requestLogin, uiResponse, renderWebUSBButton, disableWebUSB, requestWebUSBDevice, cancel, dispose, }:
|
|
19
|
-
export {};
|
|
18
|
+
export declare const factory: ({ eventEmitter, manifest, init, call, requestLogin, uiResponse, renderWebUSBButton, disableWebUSB, requestWebUSBDevice, cancel, dispose, }: ConnectFactoryDependencies) => TrezorConnect;
|
|
20
19
|
//# sourceMappingURL=factory.d.ts.map
|
package/lib/index.js
CHANGED
|
@@ -13,7 +13,7 @@ const constants_1 = require("./constants");
|
|
|
13
13
|
exports.eventEmitter = new events_1.default();
|
|
14
14
|
const _log = (0, debug_1.initLog)('@trezor/connect');
|
|
15
15
|
let _settings = (0, connectSettings_1.parseConnectSettings)();
|
|
16
|
-
|
|
16
|
+
const coreManager = (0, core_1.initCoreState)();
|
|
17
17
|
const messagePromises = (0, utils_1.createDeferredManager)({ initialId: 1 });
|
|
18
18
|
const manifest = (data) => {
|
|
19
19
|
_settings = (0, connectSettings_1.parseConnectSettings)({
|
|
@@ -24,17 +24,13 @@ const manifest = (data) => {
|
|
|
24
24
|
const dispose = () => {
|
|
25
25
|
exports.eventEmitter.removeAllListeners();
|
|
26
26
|
_settings = (0, connectSettings_1.parseConnectSettings)();
|
|
27
|
-
|
|
28
|
-
_core.dispose();
|
|
29
|
-
_core = null;
|
|
30
|
-
}
|
|
27
|
+
coreManager.dispose();
|
|
31
28
|
};
|
|
32
|
-
const
|
|
29
|
+
const onCoreEvent = (message) => {
|
|
30
|
+
var _a;
|
|
33
31
|
const { event, type, payload } = message;
|
|
34
|
-
if (!_core)
|
|
35
|
-
return;
|
|
36
32
|
if (type === events_2.UI.REQUEST_UI_WINDOW) {
|
|
37
|
-
|
|
33
|
+
(_a = coreManager.getCore()) === null || _a === void 0 ? void 0 : _a.handleMessage({ type: events_2.POPUP.HANDSHAKE });
|
|
38
34
|
return;
|
|
39
35
|
}
|
|
40
36
|
if (type === events_2.POPUP.CANCEL_POPUP_REQUEST)
|
|
@@ -70,7 +66,7 @@ const handleMessage = (message) => {
|
|
|
70
66
|
};
|
|
71
67
|
const init = async (settings = {}) => {
|
|
72
68
|
var _a;
|
|
73
|
-
if (
|
|
69
|
+
if (coreManager.getCore() || coreManager.getInitPromise()) {
|
|
74
70
|
throw constants_1.ERRORS.TypedError('Init_AlreadyInitialized');
|
|
75
71
|
}
|
|
76
72
|
_settings = (0, connectSettings_1.parseConnectSettings)({ ..._settings, ...settings, popup: false });
|
|
@@ -84,23 +80,22 @@ const init = async (settings = {}) => {
|
|
|
84
80
|
_settings.lazyLoad = false;
|
|
85
81
|
return;
|
|
86
82
|
}
|
|
87
|
-
|
|
83
|
+
await coreManager.getOrInitCore(_settings, onCoreEvent);
|
|
88
84
|
};
|
|
89
85
|
const call = async (params) => {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
catch (error) {
|
|
95
|
-
return (0, events_2.createErrorMessage)(error);
|
|
86
|
+
let core;
|
|
87
|
+
try {
|
|
88
|
+
if (!coreManager.getCore() && !coreManager.getInitPromise()) {
|
|
89
|
+
await init();
|
|
96
90
|
}
|
|
91
|
+
core = await coreManager.getOrInitCore(_settings, onCoreEvent);
|
|
92
|
+
}
|
|
93
|
+
catch (error) {
|
|
94
|
+
return (0, events_2.createErrorMessage)(error);
|
|
97
95
|
}
|
|
98
96
|
try {
|
|
99
|
-
if (!_core) {
|
|
100
|
-
throw constants_1.ERRORS.TypedError('Runtime', 'postMessage: _core not found');
|
|
101
|
-
}
|
|
102
97
|
const { promiseId, promise } = messagePromises.create();
|
|
103
|
-
|
|
98
|
+
core.handleMessage({
|
|
104
99
|
type: events_2.IFRAME.CALL,
|
|
105
100
|
payload: params,
|
|
106
101
|
id: promiseId,
|
|
@@ -117,49 +112,52 @@ const call = async (params) => {
|
|
|
117
112
|
}
|
|
118
113
|
};
|
|
119
114
|
const uiResponse = (response) => {
|
|
120
|
-
|
|
115
|
+
const core = coreManager.getCore();
|
|
116
|
+
if (!core) {
|
|
121
117
|
throw constants_1.ERRORS.TypedError('Init_NotInitialized');
|
|
122
118
|
}
|
|
123
|
-
|
|
119
|
+
core.handleMessage(response);
|
|
124
120
|
};
|
|
125
121
|
const requestLogin = async (params) => {
|
|
126
122
|
if (typeof params.callback === 'function') {
|
|
127
123
|
const { callback } = params;
|
|
124
|
+
const core = coreManager.getCore();
|
|
128
125
|
const loginChallengeListener = async (event) => {
|
|
129
126
|
const { data } = event;
|
|
130
127
|
if (data && data.type === events_2.UI.LOGIN_CHALLENGE_REQUEST) {
|
|
131
128
|
try {
|
|
132
129
|
const payload = await callback();
|
|
133
|
-
|
|
130
|
+
core === null || core === void 0 ? void 0 : core.handleMessage({
|
|
134
131
|
type: events_2.UI.LOGIN_CHALLENGE_RESPONSE,
|
|
135
132
|
payload,
|
|
136
133
|
});
|
|
137
134
|
}
|
|
138
135
|
catch (error) {
|
|
139
|
-
|
|
136
|
+
core === null || core === void 0 ? void 0 : core.handleMessage({
|
|
140
137
|
type: events_2.UI.LOGIN_CHALLENGE_RESPONSE,
|
|
141
138
|
payload: error.message,
|
|
142
139
|
});
|
|
143
140
|
}
|
|
144
141
|
}
|
|
145
142
|
};
|
|
146
|
-
|
|
143
|
+
core === null || core === void 0 ? void 0 : core.on(events_2.CORE_EVENT, loginChallengeListener);
|
|
147
144
|
const response = await call({
|
|
148
145
|
method: 'requestLogin',
|
|
149
146
|
...params,
|
|
150
147
|
asyncChallenge: true,
|
|
151
148
|
callback: null,
|
|
152
149
|
});
|
|
153
|
-
|
|
150
|
+
core === null || core === void 0 ? void 0 : core.removeListener(events_2.CORE_EVENT, loginChallengeListener);
|
|
154
151
|
return response;
|
|
155
152
|
}
|
|
156
153
|
return call({ method: 'requestLogin', ...params });
|
|
157
154
|
};
|
|
158
155
|
const cancel = (error) => {
|
|
159
|
-
|
|
156
|
+
const core = coreManager.getCore();
|
|
157
|
+
if (!core) {
|
|
160
158
|
throw constants_1.ERRORS.TypedError('Runtime', 'postMessage: _core not found');
|
|
161
159
|
}
|
|
162
|
-
|
|
160
|
+
core.handleMessage({
|
|
163
161
|
type: events_2.POPUP.CLOSED,
|
|
164
162
|
payload: error ? { error } : null,
|
|
165
163
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trezor/connect",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.3.0",
|
|
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.",
|
|
@@ -54,6 +54,7 @@
|
|
|
54
54
|
"scripts": {
|
|
55
55
|
"lint:js": "yarn g:eslint '**/*.{ts,tsx,js}'",
|
|
56
56
|
"test:unit": "jest --version && jest",
|
|
57
|
+
"depcheck": "yarn g:depcheck",
|
|
57
58
|
"type-check": "yarn g:tsc --build",
|
|
58
59
|
"build:lib": "yarn g:rimraf ./lib && yarn g:tsc --build tsconfig.lib.json && ../../scripts/replace-imports.sh ./lib",
|
|
59
60
|
"version:prerelease": "yarn g:tsx scripts/bump-version.ts prerelease",
|
|
@@ -70,26 +71,24 @@
|
|
|
70
71
|
"@ethereumjs/common": "^4.2.0",
|
|
71
72
|
"@ethereumjs/tx": "^5.2.1",
|
|
72
73
|
"@fivebinaries/coin-selection": "2.2.1",
|
|
73
|
-
"@trezor/blockchain-link": "2.
|
|
74
|
-
"@trezor/blockchain-link-types": "1.0
|
|
75
|
-
"@trezor/connect-analytics": "1.0
|
|
76
|
-
"@trezor/connect-common": "0.0
|
|
77
|
-
"@trezor/protobuf": "1.0
|
|
78
|
-
"@trezor/protocol": "1.0
|
|
79
|
-
"@trezor/schema-utils": "1.0
|
|
80
|
-
"@trezor/transport": "1.
|
|
81
|
-
"@trezor/utils": "9.0
|
|
82
|
-
"@trezor/utxo-lib": "2.0
|
|
74
|
+
"@trezor/blockchain-link": "2.2.0",
|
|
75
|
+
"@trezor/blockchain-link-types": "1.1.0",
|
|
76
|
+
"@trezor/connect-analytics": "1.1.0",
|
|
77
|
+
"@trezor/connect-common": "0.1.0",
|
|
78
|
+
"@trezor/protobuf": "1.1.0",
|
|
79
|
+
"@trezor/protocol": "1.1.0",
|
|
80
|
+
"@trezor/schema-utils": "1.1.0",
|
|
81
|
+
"@trezor/transport": "1.2.0",
|
|
82
|
+
"@trezor/utils": "9.1.0",
|
|
83
|
+
"@trezor/utxo-lib": "2.1.0",
|
|
83
84
|
"blakejs": "^1.2.1",
|
|
84
85
|
"bs58": "^5.0.0",
|
|
85
86
|
"bs58check": "^3.0.1",
|
|
86
|
-
"cross-fetch": "^4.0.0"
|
|
87
|
-
"events": "^3.3.0"
|
|
87
|
+
"cross-fetch": "^4.0.0"
|
|
88
88
|
},
|
|
89
89
|
"devDependencies": {
|
|
90
90
|
"@trezor/trezor-user-env-link": "1.0.2",
|
|
91
91
|
"@types/karma": "^6.3.8",
|
|
92
|
-
"@types/parse-uri": "^1.0.2",
|
|
93
92
|
"babel-loader": "^9.1.3",
|
|
94
93
|
"ethereum-cryptography": "^2.1.3",
|
|
95
94
|
"jest": "29.7.0",
|
|
@@ -104,7 +103,7 @@
|
|
|
104
103
|
"ts-node": "^10.9.1",
|
|
105
104
|
"tsx": "^4.7.0",
|
|
106
105
|
"webpack": "^5.90.1",
|
|
107
|
-
"ws": "^8.
|
|
106
|
+
"ws": "^8.17.1"
|
|
108
107
|
},
|
|
109
108
|
"peerDependencies": {
|
|
110
109
|
"tslib": "^2.6.2"
|