@trezor/connect 9.3.1-beta.1 → 9.3.1-beta.2
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 +88 -30
- package/README.md +1 -1
- package/lib/api/ethereum/api/ethereumSignTypedData.js +3 -1
- package/lib/core/index.js +72 -107
- package/lib/data/version.d.ts +2 -1
- package/lib/data/version.js +3 -2
- package/lib/device/Device.d.ts +1 -0
- package/lib/device/Device.js +8 -3
- package/lib/device/DeviceCommands.js +1 -1
- package/lib/device/DeviceList.d.ts +42 -27
- package/lib/device/DeviceList.js +249 -233
- package/lib/events/popup.d.ts +1 -0
- package/lib/utils/promiseUtils.d.ts +3 -3
- package/lib/utils/promiseUtils.js +7 -5
- package/package.json +14 -14
package/CHANGELOG.md
CHANGED
|
@@ -1,15 +1,73 @@
|
|
|
1
1
|
| Package | Stable | Canary |
|
|
2
2
|
| :------------------------------: | :----: | :----------: |
|
|
3
|
-
| npm @trezor/connect | 9.3.0 | 9.3.1-beta.
|
|
4
|
-
| npm @trezor/connect-web | 9.3.0 | 9.3.1-beta.
|
|
5
|
-
| npm @trezor/connect-webextension | 9.3.0 | 9.3.1-beta.
|
|
3
|
+
| npm @trezor/connect | 9.3.0 | 9.3.1-beta.2 |
|
|
4
|
+
| npm @trezor/connect-web | 9.3.0 | 9.3.1-beta.2 |
|
|
5
|
+
| npm @trezor/connect-webextension | 9.3.0 | 9.3.1-beta.2 |
|
|
6
6
|
|
|
7
7
|
| Deployment | Stable | Canary |
|
|
8
8
|
| :----------------: | :----: | :----------: |
|
|
9
|
-
| connect.trezor.io/ | 9.3.0 | 9.3.1-beta.
|
|
9
|
+
| connect.trezor.io/ | 9.3.0 | 9.3.1-beta.2 |
|
|
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.3.1-beta.2
|
|
14
|
+
|
|
15
|
+
- refactor(connect): removed initDeviceList, move transportReconnect inside DeviceList, make DeviceList reusable, device list constructor not throwing, singleton-like DeviceList, separate onTransportUpdate, pendingTransportEvent improved, improve DeviceList init flow (f4b3694, 02215de, b53259b, e8c6c25, e395dc8, 6509e5c, 3e30d64, d173966, 50cbbea, 1a81d89, 4780c51, 75bfe75, 83c0cb3, 73261c8, f2167bf, bb7dfee)
|
|
16
|
+
- fix(connect): correctly wait for device selection in case of overriding (0c7a3bd)
|
|
17
|
+
- fix(connect): Fork old PassphraseTypeCard to connect (155afda)
|
|
18
|
+
- fix(connect): longer timeout for getFeatures due to suite-native performance issue (0910ab7)
|
|
19
|
+
- fix(connect): handle malformed EIP-712 data (d111006)
|
|
20
|
+
- fix(connect): remove superfluous space from error message (81be584)
|
|
21
|
+
- fix(connect): correctly await transport.receive (31c8519)
|
|
22
|
+
- fix(connect): proper pendingTransportEvent waiting (baa4144)
|
|
23
|
+
- chore(connect): add a comment to legacy code (a23a365)
|
|
24
|
+
|
|
25
|
+
## connect-web
|
|
26
|
+
|
|
27
|
+
- don't fallback to core in popup with no webusb (7120e83)
|
|
28
|
+
- clean up in popupmanager when useUi=false (9bc2ea9)
|
|
29
|
+
|
|
30
|
+
## connect-popup
|
|
31
|
+
|
|
32
|
+
- add missing device icons (9fdd1d7)
|
|
33
|
+
|
|
34
|
+
## connect-webextension
|
|
35
|
+
|
|
36
|
+
- Allow multiple content script extension conflicts (348b32a)
|
|
37
|
+
|
|
38
|
+
## connect-explorer
|
|
39
|
+
|
|
40
|
+
- wrong default coreMode in settings (3a81f14)
|
|
41
|
+
- don't validate connectSrc in webextension (8737d47)
|
|
42
|
+
- add link to new webextension example (86a13b1)
|
|
43
|
+
|
|
44
|
+
## Dependencies update
|
|
45
|
+
|
|
46
|
+
- bump react-intl from 6.6.2 to 6.6.8
|
|
47
|
+
- bump @types/chrome from 0.0.260 to 0.0.269
|
|
48
|
+
- bump playwright from 1.41.2 to 1.45.3
|
|
49
|
+
- bump webpack-merge from 5.10.0 to 6.0.1
|
|
50
|
+
- bump webpack-dev-server from 4.15.1 to 5.0.4
|
|
51
|
+
- bump @babel/preset-typescript from 7.23.3 to 7.24.7
|
|
52
|
+
- bump @babel/preset-react from 7.23.3 to 7.24.7
|
|
53
|
+
- bump webpack from 5.90.1 to 5.93.0
|
|
54
|
+
- bump rimraf from 5.0.5 to 6.0.1
|
|
55
|
+
- bump txs from 4.7.0 to 4.16.2
|
|
56
|
+
|
|
57
|
+
- npm-prerelease: @trezor/blockchain-link 2.2.1-beta.2
|
|
58
|
+
- npm-prerelease: @trezor/blockchain-link-utils 1.1.1-beta.2
|
|
59
|
+
- npm-prerelease: @trezor/blockchain-link-types 1.1.1-beta.2
|
|
60
|
+
- npm-prerelease: @trezor/analytics 1.1.1-beta.1
|
|
61
|
+
- npm-prerelease: @trezor/connect-common 0.1.1-beta.2
|
|
62
|
+
- npm-prerelease: @trezor/env-utils 1.1.1-beta.1
|
|
63
|
+
- npm-prerelease: @trezor/transport 1.2.1-beta.2
|
|
64
|
+
- npm-prerelease: @trezor/protobuf 1.1.1-beta.2
|
|
65
|
+
- npm-prerelease: @trezor/schema-utils 1.1.1-beta.1
|
|
66
|
+
- npm-prerelease: @trezor/protocol 1.1.1-beta.1
|
|
67
|
+
- npm-prerelease: @trezor/utxo-lib 2.1.1-beta.1
|
|
68
|
+
- npm-prerelease: @trezor/utils 9.1.1-beta.2
|
|
69
|
+
- npm-release: @trezor/connect 9.3.1-beta.2
|
|
70
|
+
|
|
13
71
|
# 9.3.1-beta.1
|
|
14
72
|
|
|
15
73
|
We introduce a new init option `coreMode`, which allows websites to interact either using the existing `iframe` mode or the new `popup` mode. The `popup` mode is allows to use WebUSB even on third-party websites, which is not possible with the `iframe` mode. By default, the `coreMode` is set to `auto`, which means that the library will automatically choose the best mode based on the environment. More information can be found in [init method documentation](https://connect.trezor.io/9.3.1-beta.1/methods/other/init/).
|
|
@@ -20,50 +78,50 @@ AuthenticateDevice verify CA cert extensions (4ba4445)
|
|
|
20
78
|
|
|
21
79
|
Add support for T3B1 (f7f1705)
|
|
22
80
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
81
|
+
- chore(connect): Add Ambire Browser Extension to knownHosts (cbe81ab)
|
|
82
|
+
- chore(connect): remove ethereum-cryptography (18851d1)
|
|
83
|
+
- chore(connect): split public and internal settings type (3aab4ea)
|
|
84
|
+
- chore(connect): remove useCoreInPopup from explorer and tests (fee60c1)
|
|
85
|
+
- chore(connect): add new CA pubkeys and update timestamp (48ec951)
|
|
86
|
+
- chore(connect): refactoring of the CheckFirmwareAuthenticity to support local binary (and wont download it from web, when its available in the suite) (82ab513)
|
|
87
|
+
- docs(connect): describe coreMode (a5238d6)
|
|
88
|
+
- fix(connect): disallow interaction-less fw update when switching fw type (4936939)
|
|
89
|
+
- fix(connect): validate x509 asn1 component (bc13fe2)
|
|
90
|
+
- fix(connect): handle missing language binary (954dbb9)
|
|
91
|
+
- fix(connect): proceed with fw install even when language data fails to download (b40d1b7)
|
|
92
|
+
- test(connect): x509 extensions parser (163c82c)
|
|
93
|
+
- test(connect): update to min version fw 1.0.9 and 2.3.0 (544c311)
|
|
36
94
|
|
|
37
95
|
## connect-ui
|
|
38
96
|
|
|
39
|
-
|
|
97
|
+
- remove bridge references, deeplink to suite desktop (98e98a4)
|
|
40
98
|
|
|
41
99
|
## connect-plugin-stellar
|
|
42
100
|
|
|
43
|
-
|
|
44
|
-
|
|
101
|
+
- update stellar sdk (89cf20e)
|
|
102
|
+
- update trends libs (70b9c11)
|
|
45
103
|
|
|
46
104
|
## connect-web
|
|
47
105
|
|
|
48
|
-
|
|
49
|
-
|
|
106
|
+
- default coreMode to auto (e45d47e)
|
|
107
|
+
- automatic fallback to core in popup (e4e1fcc)
|
|
50
108
|
|
|
51
109
|
## connect-webextension
|
|
52
110
|
|
|
53
|
-
|
|
111
|
+
- link changelog to the one in connect (a02ec72)
|
|
54
112
|
|
|
55
113
|
## connect-explorer
|
|
56
114
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
115
|
+
- applySettings optional values (0bcd83a)
|
|
116
|
+
- hide extra headings from toc in homepage (14f89c4)
|
|
117
|
+
- show success message in settings (0ca7c0c)
|
|
118
|
+
- remove MTT for firmwareUpdate (ebbe96c)
|
|
119
|
+
- bad styled-components prop (e2b7fc7)
|
|
62
120
|
|
|
63
121
|
## connect-common
|
|
64
122
|
|
|
65
|
-
|
|
66
|
-
|
|
123
|
+
- add new fw 2.8.0 (314052b)
|
|
124
|
+
- fw version 1.9.0 and 2.3.0 required (ee623e4)
|
|
67
125
|
|
|
68
126
|
# 9.3.0
|
|
69
127
|
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @trezor/connect
|
|
2
2
|
|
|
3
|
-
API version 9.3.1-beta.
|
|
3
|
+
API version 9.3.1-beta.2
|
|
4
4
|
|
|
5
5
|
[](https://github.com/trezor/trezor-suite/actions/workflows/test-connect.yml)
|
|
6
6
|
[](https://www.npmjs.org/package/@trezor/connect)
|
|
@@ -150,7 +150,9 @@ class EthereumSignTypedData extends AbstractMethod_1.AbstractMethod {
|
|
|
150
150
|
memberTypeName = memberTypeDefinition.type;
|
|
151
151
|
memberData = memberData[memberTypeDefinition.name];
|
|
152
152
|
}
|
|
153
|
-
|
|
153
|
+
if (memberData === null || memberData === undefined) {
|
|
154
|
+
cmd.typedCall('Cancel', 'Success');
|
|
155
|
+
throw constants_1.ERRORS.TypedError('Runtime', `Value from member path ${member_path} is missing in the data object`);
|
|
154
156
|
}
|
|
155
157
|
}
|
|
156
158
|
let encodedData;
|
package/lib/core/index.js
CHANGED
|
@@ -24,7 +24,7 @@ let _core;
|
|
|
24
24
|
let _deviceList;
|
|
25
25
|
const _callMethods = [];
|
|
26
26
|
let _interactionTimeout;
|
|
27
|
-
let
|
|
27
|
+
let _deviceListInitReject;
|
|
28
28
|
let _overridePromise;
|
|
29
29
|
const methodSynchronize = (0, utils_2.getSynchronize)();
|
|
30
30
|
let waitForFirstMethod = (0, utils_1.createDeferred)();
|
|
@@ -51,13 +51,8 @@ const interactionTimeout = () => _interactionTimeout.start(() => {
|
|
|
51
51
|
});
|
|
52
52
|
const uiPromises = (0, uiPromiseManager_1.createUiPromiseManager)(interactionTimeout);
|
|
53
53
|
const initDevice = async (devicePath) => {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
57
|
-
await _deviceList.transportFirstEventPromise;
|
|
58
|
-
if (!_deviceList) {
|
|
59
|
-
throw constants_1.ERRORS.TypedError('Transport_Missing');
|
|
60
|
-
}
|
|
54
|
+
await _deviceList.pendingConnection();
|
|
55
|
+
_deviceList.assertConnected();
|
|
61
56
|
const isWebUsb = _deviceList.transportType() === 'WebUsbTransport';
|
|
62
57
|
let device;
|
|
63
58
|
let showDeviceSelection = isWebUsb;
|
|
@@ -91,9 +86,7 @@ const initDevice = async (devicePath) => {
|
|
|
91
86
|
if (showDeviceSelection) {
|
|
92
87
|
uiPromises.create(events_2.UI.RECEIVE_DEVICE);
|
|
93
88
|
await waitForPopup();
|
|
94
|
-
|
|
95
|
-
throw constants_1.ERRORS.TypedError('Transport_Missing');
|
|
96
|
-
}
|
|
89
|
+
_deviceList.assertConnected();
|
|
97
90
|
const devices = _deviceList.asArray();
|
|
98
91
|
if (devices.length === 1 &&
|
|
99
92
|
devices[0].type !== 'unreadable' &&
|
|
@@ -123,6 +116,9 @@ const initDevice = async (devicePath) => {
|
|
|
123
116
|
}
|
|
124
117
|
}
|
|
125
118
|
}
|
|
119
|
+
else if (uiPromises.exists(events_2.UI.RECEIVE_DEVICE)) {
|
|
120
|
+
await uiPromises.get(events_2.UI.RECEIVE_DEVICE);
|
|
121
|
+
}
|
|
126
122
|
if (!device) {
|
|
127
123
|
throw constants_1.ERRORS.TypedError('Device_NotFound');
|
|
128
124
|
}
|
|
@@ -332,8 +328,10 @@ const onCall = async (message) => {
|
|
|
332
328
|
postMessage(messageResponse);
|
|
333
329
|
return Promise.resolve();
|
|
334
330
|
}
|
|
335
|
-
if (!_deviceList && !
|
|
336
|
-
|
|
331
|
+
if (!_deviceList.isConnected() && !_deviceList.pendingConnection()) {
|
|
332
|
+
const { transports, pendingTransportEvent } = DataManager_1.DataManager.getSettings();
|
|
333
|
+
_deviceList.setTransports(transports);
|
|
334
|
+
await _deviceList.init({ pendingTransportEvent });
|
|
337
335
|
}
|
|
338
336
|
if (method.isManagementRestricted()) {
|
|
339
337
|
postMessage((0, events_2.createPopupMessage)(events_2.POPUP.CANCEL_POPUP_REQUEST));
|
|
@@ -433,11 +431,12 @@ const onCall = async (message) => {
|
|
|
433
431
|
});
|
|
434
432
|
}
|
|
435
433
|
catch (error) {
|
|
436
|
-
if (
|
|
434
|
+
if (error.code === 'Device_Disconnected') {
|
|
437
435
|
_deviceList.addAuthPenalty(device);
|
|
438
436
|
}
|
|
439
437
|
if (method) {
|
|
440
|
-
if (_deviceList
|
|
438
|
+
if (_deviceList.isConnected() &&
|
|
439
|
+
error.message === transport_1.TRANSPORT_ERROR.SESSION_WRONG_PREVIOUS) {
|
|
441
440
|
await _deviceList.enumerate();
|
|
442
441
|
}
|
|
443
442
|
messageResponse = (0, events_2.createResponseMessage)(method.responseID, false, { error });
|
|
@@ -466,10 +465,8 @@ const onCall = async (message) => {
|
|
|
466
465
|
if (method) {
|
|
467
466
|
method.dispose();
|
|
468
467
|
}
|
|
469
|
-
if (
|
|
470
|
-
|
|
471
|
-
_deviceList.removeAuthPenalty(device);
|
|
472
|
-
}
|
|
468
|
+
if (response.success) {
|
|
469
|
+
_deviceList.removeAuthPenalty(device);
|
|
473
470
|
}
|
|
474
471
|
if (!useCoreInPopup) {
|
|
475
472
|
postMessage(response);
|
|
@@ -541,7 +538,7 @@ const onPopupClosed = (customErrorMessage) => {
|
|
|
541
538
|
const error = customErrorMessage
|
|
542
539
|
? constants_1.ERRORS.TypedError('Method_Cancel', customErrorMessage)
|
|
543
540
|
: constants_1.ERRORS.TypedError('Method_Interrupted');
|
|
544
|
-
if (_deviceList && _deviceList.asArray().length > 0) {
|
|
541
|
+
if (_deviceList.isConnected() && _deviceList.asArray().length > 0) {
|
|
545
542
|
_deviceList.allDevices().forEach(d => {
|
|
546
543
|
d.keepSession = false;
|
|
547
544
|
if (d.isUsedHere()) {
|
|
@@ -567,7 +564,7 @@ const onPopupClosed = (customErrorMessage) => {
|
|
|
567
564
|
};
|
|
568
565
|
const handleDeviceSelectionChanges = (interruptDevice) => {
|
|
569
566
|
const promiseExists = uiPromises.exists(events_2.UI.RECEIVE_DEVICE);
|
|
570
|
-
if (promiseExists && _deviceList) {
|
|
567
|
+
if (promiseExists && _deviceList.isConnected()) {
|
|
571
568
|
const list = _deviceList.asArray();
|
|
572
569
|
const isWebUsb = _deviceList.transportType() === 'WebUsbTransport';
|
|
573
570
|
if (list.length === 1 && !isWebUsb) {
|
|
@@ -592,62 +589,29 @@ const handleDeviceSelectionChanges = (interruptDevice) => {
|
|
|
592
589
|
}
|
|
593
590
|
}
|
|
594
591
|
};
|
|
595
|
-
const
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
});
|
|
616
|
-
_deviceList.on(transport_1.TRANSPORT.ERROR, error => {
|
|
617
|
-
_log.warn('TRANSPORT.ERROR', error);
|
|
618
|
-
if (_deviceList) {
|
|
619
|
-
_deviceList.disconnectDevices();
|
|
620
|
-
_deviceList.dispose();
|
|
621
|
-
}
|
|
622
|
-
_deviceList = undefined;
|
|
623
|
-
postMessage((0, events_2.createTransportMessage)(transport_1.TRANSPORT.ERROR, { error }));
|
|
624
|
-
if (transportReconnect) {
|
|
625
|
-
const { promise, timeout } = (0, promiseUtils_1.resolveAfter)(1000, null);
|
|
626
|
-
_deviceListInitTimeout = timeout;
|
|
627
|
-
promise.then(() => {
|
|
628
|
-
initDeviceList(transportReconnect);
|
|
629
|
-
});
|
|
630
|
-
}
|
|
631
|
-
});
|
|
632
|
-
_deviceList.on(transport_1.TRANSPORT.START, transportType => postMessage((0, events_2.createTransportMessage)(transport_1.TRANSPORT.START, transportType)));
|
|
633
|
-
_deviceList.init();
|
|
634
|
-
if (_deviceList) {
|
|
635
|
-
await _deviceList.waitForTransportFirstEvent();
|
|
636
|
-
}
|
|
637
|
-
}
|
|
638
|
-
catch (error) {
|
|
639
|
-
_deviceList = undefined;
|
|
592
|
+
const createDeviceList = (params) => {
|
|
593
|
+
const deviceList = new DeviceList_1.DeviceList(params);
|
|
594
|
+
deviceList.on(events_2.DEVICE.CONNECT, device => {
|
|
595
|
+
handleDeviceSelectionChanges();
|
|
596
|
+
postMessage((0, events_2.createDeviceMessage)(events_2.DEVICE.CONNECT, device));
|
|
597
|
+
});
|
|
598
|
+
deviceList.on(events_2.DEVICE.CONNECT_UNACQUIRED, device => {
|
|
599
|
+
handleDeviceSelectionChanges();
|
|
600
|
+
postMessage((0, events_2.createDeviceMessage)(events_2.DEVICE.CONNECT_UNACQUIRED, device));
|
|
601
|
+
});
|
|
602
|
+
deviceList.on(events_2.DEVICE.DISCONNECT, device => {
|
|
603
|
+
handleDeviceSelectionChanges(device);
|
|
604
|
+
postMessage((0, events_2.createDeviceMessage)(events_2.DEVICE.DISCONNECT, device));
|
|
605
|
+
});
|
|
606
|
+
deviceList.on(events_2.DEVICE.CHANGED, device => {
|
|
607
|
+
postMessage((0, events_2.createDeviceMessage)(events_2.DEVICE.CHANGED, device));
|
|
608
|
+
});
|
|
609
|
+
deviceList.on(transport_1.TRANSPORT.START, transportType => postMessage((0, events_2.createTransportMessage)(transport_1.TRANSPORT.START, transportType)));
|
|
610
|
+
deviceList.on(transport_1.TRANSPORT.ERROR, error => {
|
|
611
|
+
_log.warn('TRANSPORT.ERROR', error);
|
|
640
612
|
postMessage((0, events_2.createTransportMessage)(transport_1.TRANSPORT.ERROR, { error }));
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
}
|
|
644
|
-
else {
|
|
645
|
-
const { promise, timeout } = (0, promiseUtils_1.resolveAfter)(3000, null);
|
|
646
|
-
_deviceListInitTimeout = timeout;
|
|
647
|
-
await promise;
|
|
648
|
-
await initDeviceList(transportReconnect);
|
|
649
|
-
}
|
|
650
|
-
}
|
|
613
|
+
});
|
|
614
|
+
return deviceList;
|
|
651
615
|
};
|
|
652
616
|
class Core extends events_1.default {
|
|
653
617
|
constructor() {
|
|
@@ -668,7 +632,9 @@ class Core extends events_1.default {
|
|
|
668
632
|
disableWebUSBTransport();
|
|
669
633
|
break;
|
|
670
634
|
case transport_1.TRANSPORT.REQUEST_DEVICE:
|
|
671
|
-
|
|
635
|
+
if (_deviceList.isConnected()) {
|
|
636
|
+
_deviceList.enumerate();
|
|
637
|
+
}
|
|
672
638
|
break;
|
|
673
639
|
case transport_1.TRANSPORT.GET_INFO:
|
|
674
640
|
postMessage((0, events_2.createResponseMessage)(message.id, true, this.getTransportInfo()));
|
|
@@ -687,6 +653,7 @@ class Core extends events_1.default {
|
|
|
687
653
|
break;
|
|
688
654
|
case events_2.IFRAME.CALL:
|
|
689
655
|
if (message.payload.method === 'firmwareUpdate') {
|
|
656
|
+
_deviceList.assertConnected();
|
|
690
657
|
(0, onCallFirmwareUpdate_1.onCallFirmwareUpdate)({
|
|
691
658
|
params: message.payload,
|
|
692
659
|
context: {
|
|
@@ -714,30 +681,24 @@ class Core extends events_1.default {
|
|
|
714
681
|
}
|
|
715
682
|
dispose() {
|
|
716
683
|
(0, BlockchainLink_1.dispose)();
|
|
717
|
-
|
|
718
|
-
clearTimeout(_deviceListInitTimeout);
|
|
719
|
-
}
|
|
684
|
+
_deviceListInitReject === null || _deviceListInitReject === void 0 ? void 0 : _deviceListInitReject(new Error('Disposed during initialization'));
|
|
720
685
|
this.removeAllListeners();
|
|
721
686
|
this.abortController.abort();
|
|
722
|
-
|
|
723
|
-
_deviceList.dispose();
|
|
724
|
-
}
|
|
687
|
+
_deviceList.dispose();
|
|
725
688
|
}
|
|
726
689
|
async getCurrentMethod() {
|
|
727
690
|
await waitForFirstMethod.promise;
|
|
728
691
|
return await methodSynchronize(() => _callMethods[0]);
|
|
729
692
|
}
|
|
730
693
|
getTransportInfo() {
|
|
731
|
-
if (
|
|
732
|
-
return
|
|
694
|
+
if (_deviceList.isConnected()) {
|
|
695
|
+
return _deviceList.getTransportInfo();
|
|
733
696
|
}
|
|
734
|
-
return _deviceList.getTransportInfo();
|
|
735
697
|
}
|
|
736
698
|
enumerate() {
|
|
737
|
-
if (
|
|
738
|
-
|
|
699
|
+
if (_deviceList.isConnected()) {
|
|
700
|
+
_deviceList.enumerate();
|
|
739
701
|
}
|
|
740
|
-
_deviceList.enumerate();
|
|
741
702
|
}
|
|
742
703
|
async init(settings, onCoreEvent, logWriterFactory) {
|
|
743
704
|
if (logWriterFactory) {
|
|
@@ -745,8 +706,11 @@ class Core extends events_1.default {
|
|
|
745
706
|
}
|
|
746
707
|
try {
|
|
747
708
|
await DataManager_1.DataManager.load(settings);
|
|
748
|
-
|
|
709
|
+
const { debug, priority } = DataManager_1.DataManager.getSettings();
|
|
710
|
+
const messages = DataManager_1.DataManager.getProtobufMessages();
|
|
711
|
+
(0, debug_1.enableLog)(debug);
|
|
749
712
|
_core = this;
|
|
713
|
+
_deviceList = createDeviceList({ debug, messages, priority });
|
|
750
714
|
_interactionTimeout = new interactionTimeout_1.InteractionTimeout(settings.popup ? settings.interactionTimeout : 0);
|
|
751
715
|
this.on(events_2.CORE_EVENT, onCoreEvent);
|
|
752
716
|
}
|
|
@@ -754,43 +718,44 @@ class Core extends events_1.default {
|
|
|
754
718
|
_log.error('init', error);
|
|
755
719
|
throw error;
|
|
756
720
|
}
|
|
721
|
+
const { transports, pendingTransportEvent, transportReconnect, coreMode } = DataManager_1.DataManager.getSettings();
|
|
757
722
|
try {
|
|
758
|
-
|
|
759
|
-
DataManager_1.DataManager.getSettings('coreMode') === 'auto') {
|
|
760
|
-
await initDeviceList(false);
|
|
761
|
-
}
|
|
762
|
-
else {
|
|
763
|
-
initDeviceList(true);
|
|
764
|
-
}
|
|
723
|
+
_deviceList.setTransports(transports);
|
|
765
724
|
}
|
|
766
725
|
catch (error) {
|
|
767
|
-
_log.error('
|
|
726
|
+
_log.error('setTransports', error);
|
|
727
|
+
postMessage((0, events_2.createTransportMessage)(transport_1.TRANSPORT.ERROR, { error }));
|
|
768
728
|
throw error;
|
|
769
729
|
}
|
|
730
|
+
_deviceList.init({ pendingTransportEvent, transportReconnect });
|
|
731
|
+
if (!transportReconnect || coreMode === 'auto') {
|
|
732
|
+
await _deviceList.pendingConnection();
|
|
733
|
+
}
|
|
770
734
|
}
|
|
771
735
|
}
|
|
772
736
|
exports.Core = Core;
|
|
773
737
|
const disableWebUSBTransport = async () => {
|
|
774
|
-
|
|
775
|
-
if (!_deviceList)
|
|
738
|
+
if (!_deviceList.isConnected())
|
|
776
739
|
return;
|
|
777
740
|
if (_deviceList.transportType() !== 'WebUsbTransport')
|
|
778
741
|
return;
|
|
779
|
-
const
|
|
780
|
-
if (
|
|
781
|
-
const transportStr =
|
|
742
|
+
const { transports, pendingTransportEvent, transportReconnect } = DataManager_1.DataManager.getSettings();
|
|
743
|
+
if (transports) {
|
|
744
|
+
const transportStr = transports === null || transports === void 0 ? void 0 : transports.filter(transport => typeof transport !== 'object');
|
|
782
745
|
if (transportStr.includes('WebUsbTransport')) {
|
|
783
|
-
|
|
746
|
+
transports.splice(transports.indexOf('WebUsbTransport'), 1);
|
|
784
747
|
}
|
|
785
748
|
if (!transportStr.includes('BridgeTransport')) {
|
|
786
|
-
|
|
749
|
+
transports.unshift('BridgeTransport');
|
|
787
750
|
}
|
|
788
751
|
}
|
|
789
752
|
try {
|
|
790
|
-
_deviceList.
|
|
791
|
-
|
|
753
|
+
_deviceList.cleanup();
|
|
754
|
+
_deviceList.setTransports(transports);
|
|
755
|
+
await _deviceList.init({ pendingTransportEvent, transportReconnect });
|
|
792
756
|
}
|
|
793
757
|
catch (error) {
|
|
758
|
+
postMessage((0, events_2.createTransportMessage)(transport_1.TRANSPORT.ERROR, { error }));
|
|
794
759
|
}
|
|
795
760
|
};
|
|
796
761
|
const initCore = async (settings, onCoreEvent, logWriterFactory) => {
|
package/lib/data/version.d.ts
CHANGED
package/lib/data/version.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DEFAULT_DOMAIN = exports.VERSION = void 0;
|
|
4
|
-
exports.VERSION = '9.3.1-beta.
|
|
3
|
+
exports.CONTENT_SCRIPT_VERSION = exports.DEFAULT_DOMAIN = exports.VERSION = void 0;
|
|
4
|
+
exports.VERSION = '9.3.1-beta.2';
|
|
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
|
|
8
8
|
? `https://connect.trezor.io/${exports.VERSION}/`
|
|
9
9
|
: `https://connect.trezor.io/${versionN[0]}/`;
|
|
10
|
+
exports.CONTENT_SCRIPT_VERSION = 1;
|
|
10
11
|
//# sourceMappingURL=version.js.map
|
package/lib/device/Device.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ export type RunOptions = {
|
|
|
15
15
|
useCardanoDerivation?: boolean;
|
|
16
16
|
};
|
|
17
17
|
export declare const GET_FEATURES_TIMEOUT = 3000;
|
|
18
|
+
export declare const GET_FEATURES_TIMEOUT_REACT_NATIVE = 20000;
|
|
18
19
|
export interface DeviceEvents {
|
|
19
20
|
[DEVICE.PIN]: (device: Device, b: PROTO.PinMatrixRequestType | undefined, callback: (err: any, pin: string) => void) => void;
|
|
20
21
|
[DEVICE.WORD]: (device: Device, b: PROTO.WordRequestType, callback: (err: any, word: string) => void) => void;
|
package/lib/device/Device.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Device = exports.GET_FEATURES_TIMEOUT = void 0;
|
|
3
|
+
exports.Device = exports.GET_FEATURES_TIMEOUT_REACT_NATIVE = exports.GET_FEATURES_TIMEOUT = void 0;
|
|
4
4
|
const utils_1 = require("@trezor/utils");
|
|
5
5
|
const protocol_1 = require("@trezor/protocol");
|
|
6
6
|
const DeviceCommands_1 = require("./DeviceCommands");
|
|
7
7
|
const constants_1 = require("../constants");
|
|
8
8
|
const events_1 = require("../events");
|
|
9
9
|
const coinInfo_1 = require("../data/coinInfo");
|
|
10
|
+
const DataManager_1 = require("../data/DataManager");
|
|
10
11
|
const firmwareInfo_1 = require("../data/firmwareInfo");
|
|
11
12
|
const deviceFeaturesUtils_1 = require("../utils/deviceFeaturesUtils");
|
|
12
13
|
const debug_1 = require("../utils/debug");
|
|
@@ -16,6 +17,7 @@ const models_1 = require("../data/models");
|
|
|
16
17
|
const getLanguage_1 = require("../data/getLanguage");
|
|
17
18
|
const _log = (0, debug_1.initLog)('Device');
|
|
18
19
|
exports.GET_FEATURES_TIMEOUT = 3000;
|
|
20
|
+
exports.GET_FEATURES_TIMEOUT_REACT_NATIVE = 20000;
|
|
19
21
|
const parseRunOptions = (options) => {
|
|
20
22
|
if (!options)
|
|
21
23
|
options = {};
|
|
@@ -175,9 +177,12 @@ class Device extends utils_1.TypedEmitter {
|
|
|
175
177
|
await this.initialize(!!options.useCardanoDerivation);
|
|
176
178
|
}
|
|
177
179
|
else {
|
|
180
|
+
const getFeaturesTimeout = DataManager_1.DataManager.getSettings('env') === 'react-native'
|
|
181
|
+
? exports.GET_FEATURES_TIMEOUT_REACT_NATIVE
|
|
182
|
+
: exports.GET_FEATURES_TIMEOUT;
|
|
178
183
|
await Promise.race([
|
|
179
184
|
this.getFeatures(),
|
|
180
|
-
new Promise((_resolve, reject) => setTimeout(() => reject(new Error('GetFeatures timeout')),
|
|
185
|
+
new Promise((_resolve, reject) => setTimeout(() => reject(new Error('GetFeatures timeout')), getFeaturesTimeout)),
|
|
181
186
|
]);
|
|
182
187
|
}
|
|
183
188
|
}
|
|
@@ -191,7 +196,7 @@ class Device extends utils_1.TypedEmitter {
|
|
|
191
196
|
}
|
|
192
197
|
this.inconsistent = true;
|
|
193
198
|
delete this.runPromise;
|
|
194
|
-
return Promise.reject(constants_1.ERRORS.TypedError('Device_InitializeFailed', `Initialize failed: ${error.message}
|
|
199
|
+
return Promise.reject(constants_1.ERRORS.TypedError('Device_InitializeFailed', `Initialize failed: ${error.message}${error.code ? `, code: ${error.code}` : ''}`));
|
|
195
200
|
}
|
|
196
201
|
}
|
|
197
202
|
if (options.keepSession) {
|