@trezor/connect 9.0.10 → 9.0.11
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 +4 -0
- package/README.md +1 -1
- package/lib/data/version.d.ts +1 -1
- package/lib/data/version.js +1 -1
- package/lib/device/Device.d.ts +8 -14
- package/lib/device/Device.js +38 -39
- package/lib/device/DeviceCommands.js +2 -2
- package/lib/device/DeviceList.d.ts +2 -8
- package/lib/device/DeviceList.js +31 -31
- package/package.json +14 -14
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @trezor/connect
|
|
2
2
|
|
|
3
|
-
API version 9.0.
|
|
3
|
+
API version 9.0.11
|
|
4
4
|
|
|
5
5
|
[](https://github.com/trezor/trezor-suite/actions/workflows/connect-test.yml)
|
|
6
6
|
[](https://www.npmjs.org/package/@trezor/connect)
|
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.11';
|
|
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
|
package/lib/device/Device.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import EventEmitter from 'events';
|
|
1
|
+
import { TypedEmitter } from '@trezor/utils/lib/typedEventEmitter';
|
|
3
2
|
import { DeviceCommands } from './DeviceCommands';
|
|
4
3
|
import { PROTO, NETWORK } from '../constants';
|
|
5
4
|
import { DEVICE, DeviceButtonRequestPayload } from '../events';
|
|
@@ -16,19 +15,14 @@ export type RunOptions = {
|
|
|
16
15
|
useCardanoDerivation?: boolean;
|
|
17
16
|
};
|
|
18
17
|
export interface DeviceEvents {
|
|
19
|
-
[DEVICE.PIN]:
|
|
20
|
-
[DEVICE.WORD]:
|
|
21
|
-
[DEVICE.PASSPHRASE]:
|
|
22
|
-
[DEVICE.PASSPHRASE_ON_DEVICE]:
|
|
23
|
-
[DEVICE.BUTTON]:
|
|
24
|
-
[DEVICE.ACQUIRED]:
|
|
18
|
+
[DEVICE.PIN]: (device: Device, b: PROTO.PinMatrixRequestType | undefined, callback: (err: any, pin: string) => void) => void;
|
|
19
|
+
[DEVICE.WORD]: (device: Device, b: PROTO.WordRequestType, callback: (err: any, word: string) => void) => void;
|
|
20
|
+
[DEVICE.PASSPHRASE]: (device: Device, callback: (response: any) => void) => void;
|
|
21
|
+
[DEVICE.PASSPHRASE_ON_DEVICE]: () => void;
|
|
22
|
+
[DEVICE.BUTTON]: (device: Device, payload: DeviceButtonRequestPayload) => void;
|
|
23
|
+
[DEVICE.ACQUIRED]: () => void;
|
|
25
24
|
}
|
|
26
|
-
export
|
|
27
|
-
on<K extends keyof DeviceEvents>(type: K, listener: (...event: DeviceEvents[K]) => void): this;
|
|
28
|
-
off<K extends keyof DeviceEvents>(type: K, listener: (...event: DeviceEvents[K]) => void): this;
|
|
29
|
-
emit<K extends keyof DeviceEvents>(type: K, ...args: DeviceEvents[K]): boolean;
|
|
30
|
-
}
|
|
31
|
-
export declare class Device extends EventEmitter {
|
|
25
|
+
export declare class Device extends TypedEmitter<DeviceEvents> {
|
|
32
26
|
transport: Transport;
|
|
33
27
|
originalDescriptor: DeviceDescriptor;
|
|
34
28
|
unreadableError?: string;
|
package/lib/device/Device.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Device = void 0;
|
|
4
|
-
const
|
|
5
|
-
const events_1 = tslib_1.__importDefault(require("events"));
|
|
4
|
+
const typedEventEmitter_1 = require("@trezor/utils/lib/typedEventEmitter");
|
|
6
5
|
const DeviceCommands_1 = require("./DeviceCommands");
|
|
7
6
|
const constants_1 = require("../constants");
|
|
8
|
-
const
|
|
7
|
+
const events_1 = require("../events");
|
|
9
8
|
const coinInfo_1 = require("../data/coinInfo");
|
|
10
9
|
const firmwareInfo_1 = require("../data/firmwareInfo");
|
|
11
10
|
const deviceFeaturesUtils_1 = require("../utils/deviceFeaturesUtils");
|
|
@@ -18,7 +17,7 @@ const parseRunOptions = (options) => {
|
|
|
18
17
|
options = {};
|
|
19
18
|
return options;
|
|
20
19
|
};
|
|
21
|
-
class Device extends
|
|
20
|
+
class Device extends typedEventEmitter_1.TypedEmitter {
|
|
22
21
|
constructor(transport, descriptor) {
|
|
23
22
|
super();
|
|
24
23
|
this.featuresNeedsReload = false;
|
|
@@ -53,8 +52,8 @@ class Device extends events_1.default {
|
|
|
53
52
|
return device;
|
|
54
53
|
}
|
|
55
54
|
async acquire() {
|
|
56
|
-
this.deferredActions[
|
|
57
|
-
this.deferredActions[
|
|
55
|
+
this.deferredActions[events_1.DEVICE.ACQUIRE] = (0, deferred_1.create)();
|
|
56
|
+
this.deferredActions[events_1.DEVICE.ACQUIRED] = (0, deferred_1.create)();
|
|
58
57
|
try {
|
|
59
58
|
const sessionID = await this.transport.acquire({
|
|
60
59
|
path: this.originalDescriptor.path,
|
|
@@ -62,17 +61,17 @@ class Device extends events_1.default {
|
|
|
62
61
|
}, false);
|
|
63
62
|
_log.debug('Expected session id:', sessionID);
|
|
64
63
|
this.activitySessionID = sessionID;
|
|
65
|
-
this.deferredActions[
|
|
66
|
-
delete this.deferredActions[
|
|
64
|
+
this.deferredActions[events_1.DEVICE.ACQUIRED].resolve();
|
|
65
|
+
delete this.deferredActions[events_1.DEVICE.ACQUIRED];
|
|
67
66
|
if (this.commands) {
|
|
68
67
|
this.commands.dispose();
|
|
69
68
|
}
|
|
70
69
|
this.commands = new DeviceCommands_1.DeviceCommands(this, this.transport, sessionID);
|
|
71
|
-
this.deferredActions[
|
|
70
|
+
this.deferredActions[events_1.DEVICE.RELEASE] = (0, deferred_1.create)();
|
|
72
71
|
}
|
|
73
72
|
catch (error) {
|
|
74
|
-
this.deferredActions[
|
|
75
|
-
delete this.deferredActions[
|
|
73
|
+
this.deferredActions[events_1.DEVICE.ACQUIRED].resolve();
|
|
74
|
+
delete this.deferredActions[events_1.DEVICE.ACQUIRED];
|
|
76
75
|
if (this.runPromise) {
|
|
77
76
|
this.runPromise.reject(error);
|
|
78
77
|
}
|
|
@@ -97,8 +96,8 @@ class Device extends events_1.default {
|
|
|
97
96
|
}
|
|
98
97
|
try {
|
|
99
98
|
await this.transport.release(this.activitySessionID, false, false);
|
|
100
|
-
if (this.deferredActions[
|
|
101
|
-
await this.deferredActions[
|
|
99
|
+
if (this.deferredActions[events_1.DEVICE.RELEASE])
|
|
100
|
+
await this.deferredActions[events_1.DEVICE.RELEASE].promise;
|
|
102
101
|
}
|
|
103
102
|
catch (err) {
|
|
104
103
|
}
|
|
@@ -119,14 +118,14 @@ class Device extends events_1.default {
|
|
|
119
118
|
return this.runPromise.promise;
|
|
120
119
|
}
|
|
121
120
|
async override(error) {
|
|
122
|
-
if (this.deferredActions[
|
|
123
|
-
await this.deferredActions[
|
|
121
|
+
if (this.deferredActions[events_1.DEVICE.ACQUIRE]) {
|
|
122
|
+
await this.deferredActions[events_1.DEVICE.ACQUIRE].promise;
|
|
124
123
|
}
|
|
125
124
|
if (this.runPromise) {
|
|
126
125
|
await this.interruptionFromUser(error);
|
|
127
126
|
}
|
|
128
|
-
if (!this.keepSession && this.deferredActions[
|
|
129
|
-
await this.deferredActions[
|
|
127
|
+
if (!this.keepSession && this.deferredActions[events_1.DEVICE.RELEASE]) {
|
|
128
|
+
await this.deferredActions[events_1.DEVICE.RELEASE].promise;
|
|
130
129
|
}
|
|
131
130
|
}
|
|
132
131
|
async interruptionFromUser(error) {
|
|
@@ -171,7 +170,7 @@ class Device extends events_1.default {
|
|
|
171
170
|
return this._runInner(() => Promise.resolve({}), options);
|
|
172
171
|
}
|
|
173
172
|
this.inconsistent = true;
|
|
174
|
-
await this.deferredActions[
|
|
173
|
+
await this.deferredActions[events_1.DEVICE.ACQUIRE].promise;
|
|
175
174
|
this.runPromise = null;
|
|
176
175
|
return Promise.reject(constants_1.ERRORS.TypedError('Device_InitializeFailed', `Initialize failed: ${error.message}, code: ${error.code}`));
|
|
177
176
|
}
|
|
@@ -179,7 +178,7 @@ class Device extends events_1.default {
|
|
|
179
178
|
if (options.keepSession) {
|
|
180
179
|
this.keepSession = true;
|
|
181
180
|
}
|
|
182
|
-
await this.deferredActions[
|
|
181
|
+
await this.deferredActions[events_1.DEVICE.ACQUIRE].promise;
|
|
183
182
|
if (fn) {
|
|
184
183
|
await fn();
|
|
185
184
|
}
|
|
@@ -335,21 +334,21 @@ class Device extends events_1.default {
|
|
|
335
334
|
if (!originalSession && !upcomingSession && !this.activitySessionID) {
|
|
336
335
|
return;
|
|
337
336
|
}
|
|
338
|
-
if (this.deferredActions[
|
|
339
|
-
await this.deferredActions[
|
|
337
|
+
if (this.deferredActions[events_1.DEVICE.ACQUIRED]) {
|
|
338
|
+
await this.deferredActions[events_1.DEVICE.ACQUIRED].promise;
|
|
340
339
|
}
|
|
341
340
|
if (!upcomingSession) {
|
|
342
|
-
if (this.listeners(
|
|
343
|
-
this.emit(
|
|
341
|
+
if (this.listeners(events_1.DEVICE.ACQUIRED).length > 0) {
|
|
342
|
+
this.emit(events_1.DEVICE.ACQUIRED);
|
|
344
343
|
}
|
|
345
344
|
}
|
|
346
345
|
const methodStillRunning = this.commands && !this.commands.disposed;
|
|
347
346
|
if (!upcomingSession && !methodStillRunning) {
|
|
348
347
|
if (originalSession === this.activitySessionID) {
|
|
349
348
|
_log.debug('Session released by this app');
|
|
350
|
-
if (this.deferredActions[
|
|
351
|
-
this.deferredActions[
|
|
352
|
-
delete this.deferredActions[
|
|
349
|
+
if (this.deferredActions[events_1.DEVICE.RELEASE]) {
|
|
350
|
+
this.deferredActions[events_1.DEVICE.RELEASE].resolve();
|
|
351
|
+
delete this.deferredActions[events_1.DEVICE.RELEASE];
|
|
353
352
|
}
|
|
354
353
|
this.activitySessionID = null;
|
|
355
354
|
}
|
|
@@ -361,8 +360,8 @@ class Device extends events_1.default {
|
|
|
361
360
|
}
|
|
362
361
|
else if (upcomingSession === this.activitySessionID) {
|
|
363
362
|
_log.debug('Session acquired by this app');
|
|
364
|
-
if (this.deferredActions[
|
|
365
|
-
this.deferredActions[
|
|
363
|
+
if (this.deferredActions[events_1.DEVICE.ACQUIRE]) {
|
|
364
|
+
this.deferredActions[events_1.DEVICE.ACQUIRE].resolve();
|
|
366
365
|
}
|
|
367
366
|
}
|
|
368
367
|
else {
|
|
@@ -373,9 +372,9 @@ class Device extends events_1.default {
|
|
|
373
372
|
}
|
|
374
373
|
disconnect() {
|
|
375
374
|
_log.debug('Disconnect cleanup');
|
|
376
|
-
if (this.deferredActions[
|
|
377
|
-
this.deferredActions[
|
|
378
|
-
delete this.deferredActions[
|
|
375
|
+
if (this.deferredActions[events_1.DEVICE.RELEASE]) {
|
|
376
|
+
this.deferredActions[events_1.DEVICE.RELEASE].resolve();
|
|
377
|
+
delete this.deferredActions[events_1.DEVICE.RELEASE];
|
|
379
378
|
}
|
|
380
379
|
this.interruptionFromUser(constants_1.ERRORS.TypedError('Device_Disconnected'));
|
|
381
380
|
this.runPromise = null;
|
|
@@ -433,17 +432,17 @@ class Device extends events_1.default {
|
|
|
433
432
|
}
|
|
434
433
|
hasUnexpectedMode(allow, require) {
|
|
435
434
|
if (this.features) {
|
|
436
|
-
if (this.isBootloader() && !allow.includes(
|
|
437
|
-
return
|
|
435
|
+
if (this.isBootloader() && !allow.includes(events_1.UI.BOOTLOADER)) {
|
|
436
|
+
return events_1.UI.BOOTLOADER;
|
|
438
437
|
}
|
|
439
|
-
if (!this.isInitialized() && !allow.includes(
|
|
440
|
-
return
|
|
438
|
+
if (!this.isInitialized() && !allow.includes(events_1.UI.INITIALIZE)) {
|
|
439
|
+
return events_1.UI.INITIALIZE;
|
|
441
440
|
}
|
|
442
|
-
if (this.isSeedless() && !allow.includes(
|
|
443
|
-
return
|
|
441
|
+
if (this.isSeedless() && !allow.includes(events_1.UI.SEEDLESS)) {
|
|
442
|
+
return events_1.UI.SEEDLESS;
|
|
444
443
|
}
|
|
445
|
-
if (!this.isBootloader() && require.includes(
|
|
446
|
-
return
|
|
444
|
+
if (!this.isBootloader() && require.includes(events_1.UI.BOOTLOADER)) {
|
|
445
|
+
return events_1.UI.NOT_IN_BOOTLOADER;
|
|
447
446
|
}
|
|
448
447
|
}
|
|
449
448
|
return null;
|
|
@@ -293,7 +293,7 @@ class DeviceCommands {
|
|
|
293
293
|
res.message.code = 'ButtonRequest_PassphraseType';
|
|
294
294
|
}
|
|
295
295
|
if (res.message.code === 'ButtonRequest_PassphraseEntry') {
|
|
296
|
-
this.device.emit(events_1.DEVICE.PASSPHRASE_ON_DEVICE
|
|
296
|
+
this.device.emit(events_1.DEVICE.PASSPHRASE_ON_DEVICE);
|
|
297
297
|
}
|
|
298
298
|
else {
|
|
299
299
|
this.device.emit(events_1.DEVICE.BUTTON, this.device, res.message);
|
|
@@ -316,7 +316,7 @@ class DeviceCommands {
|
|
|
316
316
|
return this._commonCall('PassphraseAck', { passphrase: state });
|
|
317
317
|
}
|
|
318
318
|
if (legacy && res.message._on_device) {
|
|
319
|
-
this.device.emit(events_1.DEVICE.PASSPHRASE_ON_DEVICE
|
|
319
|
+
this.device.emit(events_1.DEVICE.PASSPHRASE_ON_DEVICE);
|
|
320
320
|
return this._commonCall('PassphraseAck', { _state: state });
|
|
321
321
|
}
|
|
322
322
|
return this._promptPassphrase().then(response => {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import EventEmitter from 'events';
|
|
1
|
+
import { TypedEmitter } from '@trezor/utils/lib/typedEventEmitter';
|
|
3
2
|
import { Transport, TrezorDeviceInfoWithSession as DeviceDescriptor } from '@trezor/transport';
|
|
4
3
|
import { TRANSPORT, DEVICE, TransportInfo } from '../events';
|
|
5
4
|
import { DescriptorStream } from './DescriptorStream';
|
|
@@ -23,12 +22,7 @@ interface DeviceListEvents {
|
|
|
23
22
|
[DEVICE.RELEASED]: DeviceTyped;
|
|
24
23
|
[DEVICE.ACQUIRED]: DeviceTyped;
|
|
25
24
|
}
|
|
26
|
-
export
|
|
27
|
-
on<K extends keyof DeviceListEvents>(type: K, listener: (event: DeviceListEvents[K]) => void): this;
|
|
28
|
-
off<K extends keyof DeviceListEvents>(type: K, listener: (event: DeviceListEvents[K]) => void): this;
|
|
29
|
-
emit<K extends keyof DeviceListEvents>(type: K, args: DeviceListEvents[K]): boolean;
|
|
30
|
-
}
|
|
31
|
-
export declare class DeviceList extends EventEmitter {
|
|
25
|
+
export declare class DeviceList extends TypedEmitter<DeviceListEvents> {
|
|
32
26
|
transport: Transport;
|
|
33
27
|
transportPlugin: LowLevelPlugin | typeof undefined;
|
|
34
28
|
stream: DescriptorStream;
|
package/lib/device/DeviceList.js
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
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
|
|
5
|
+
const typedEventEmitter_1 = require("@trezor/utils/lib/typedEventEmitter");
|
|
6
6
|
const transport_1 = tslib_1.__importDefault(require("@trezor/transport"));
|
|
7
7
|
const cross_fetch_1 = tslib_1.__importDefault(require("cross-fetch"));
|
|
8
8
|
const constants_1 = require("../constants");
|
|
9
|
-
const
|
|
9
|
+
const events_1 = require("../events");
|
|
10
10
|
const DescriptorStream_1 = require("./DescriptorStream");
|
|
11
11
|
const Device_1 = require("./Device");
|
|
12
12
|
const DataManager_1 = require("../data/DataManager");
|
|
@@ -17,7 +17,7 @@ const workers_1 = require("../workers/workers");
|
|
|
17
17
|
const { BridgeV2, Fallback } = transport_1.default;
|
|
18
18
|
const _log = (0, debug_1.initLog)('DeviceList');
|
|
19
19
|
let autoResolveTransportEventTimeout;
|
|
20
|
-
class DeviceList extends
|
|
20
|
+
class DeviceList extends typedEventEmitter_1.TypedEmitter {
|
|
21
21
|
constructor() {
|
|
22
22
|
var _a;
|
|
23
23
|
super();
|
|
@@ -64,49 +64,49 @@ class DeviceList extends events_1.default {
|
|
|
64
64
|
this.transportPlugin = transport.activeTransport.plugin;
|
|
65
65
|
}
|
|
66
66
|
await this._initStream();
|
|
67
|
-
this.on(
|
|
68
|
-
this.on(
|
|
67
|
+
this.on(events_1.DEVICE.CONNECT, this.resolveTransportEvent.bind(this));
|
|
68
|
+
this.on(events_1.DEVICE.CONNECT_UNACQUIRED, this.resolveTransportEvent.bind(this));
|
|
69
69
|
}
|
|
70
70
|
catch (error) {
|
|
71
|
-
this.emit(
|
|
71
|
+
this.emit(events_1.TRANSPORT.ERROR, error);
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
74
|
resolveTransportEvent() {
|
|
75
75
|
this.transportStartPending--;
|
|
76
76
|
if (this.transportStartPending === 0) {
|
|
77
|
-
this.stream.emit(
|
|
77
|
+
this.stream.emit(events_1.TRANSPORT.START);
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
80
|
async waitForTransportFirstEvent() {
|
|
81
81
|
await new Promise(resolve => {
|
|
82
82
|
const handler = () => {
|
|
83
|
-
this.removeListener(
|
|
84
|
-
this.removeListener(
|
|
83
|
+
this.removeListener(events_1.TRANSPORT.START, handler);
|
|
84
|
+
this.removeListener(events_1.TRANSPORT.ERROR, handler);
|
|
85
85
|
resolve();
|
|
86
86
|
};
|
|
87
|
-
this.on(
|
|
88
|
-
this.on(
|
|
87
|
+
this.on(events_1.TRANSPORT.START, handler);
|
|
88
|
+
this.on(events_1.TRANSPORT.ERROR, handler);
|
|
89
89
|
});
|
|
90
90
|
}
|
|
91
91
|
_initStream() {
|
|
92
92
|
const stream = new DescriptorStream_1.DescriptorStream(this.transport);
|
|
93
|
-
stream.on(
|
|
93
|
+
stream.on(events_1.TRANSPORT.START_PENDING, (pending) => {
|
|
94
94
|
this.transportStartPending = pending;
|
|
95
95
|
autoResolveTransportEventTimeout = setTimeout(() => {
|
|
96
96
|
this.resolveTransportEvent();
|
|
97
97
|
}, 5000);
|
|
98
98
|
});
|
|
99
|
-
stream.on(
|
|
100
|
-
this.emit(
|
|
99
|
+
stream.on(events_1.TRANSPORT.START, () => {
|
|
100
|
+
this.emit(events_1.TRANSPORT.START, this.getTransportInfo());
|
|
101
101
|
if (autoResolveTransportEventTimeout) {
|
|
102
102
|
clearTimeout(autoResolveTransportEventTimeout);
|
|
103
103
|
}
|
|
104
104
|
});
|
|
105
|
-
stream.on(
|
|
105
|
+
stream.on(events_1.TRANSPORT.UPDATE, (diff) => {
|
|
106
106
|
new DiffHandler(this, diff).handle();
|
|
107
107
|
});
|
|
108
|
-
stream.on(
|
|
109
|
-
this.emit(
|
|
108
|
+
stream.on(events_1.TRANSPORT.ERROR, error => {
|
|
109
|
+
this.emit(events_1.TRANSPORT.ERROR, error);
|
|
110
110
|
stream.stop();
|
|
111
111
|
});
|
|
112
112
|
stream.listen();
|
|
@@ -123,16 +123,16 @@ class DeviceList extends events_1.default {
|
|
|
123
123
|
debug: false,
|
|
124
124
|
}, 'HID_DEVICE');
|
|
125
125
|
this.devices[UNREADABLE_PATH] = device;
|
|
126
|
-
this.emit(
|
|
126
|
+
this.emit(events_1.DEVICE.CONNECT_UNACQUIRED, device.toMessageObject());
|
|
127
127
|
}
|
|
128
128
|
else {
|
|
129
129
|
const device = this.devices[UNREADABLE_PATH];
|
|
130
130
|
delete this.devices[UNREADABLE_PATH];
|
|
131
|
-
this.emit(
|
|
131
|
+
this.emit(events_1.DEVICE.DISCONNECT, device.toMessageObject());
|
|
132
132
|
}
|
|
133
133
|
});
|
|
134
134
|
}
|
|
135
|
-
this.emit(
|
|
135
|
+
this.emit(events_1.TRANSPORT.STREAM, stream);
|
|
136
136
|
}
|
|
137
137
|
async _createAndSaveDevice(descriptor) {
|
|
138
138
|
_log.debug('Creating Device', descriptor);
|
|
@@ -141,8 +141,8 @@ class DeviceList extends events_1.default {
|
|
|
141
141
|
_createUnacquiredDevice(descriptor) {
|
|
142
142
|
_log.debug('Creating Unacquired Device', descriptor);
|
|
143
143
|
const device = Device_1.Device.createUnacquired(this.transport, descriptor);
|
|
144
|
-
device.once(
|
|
145
|
-
this.emit(
|
|
144
|
+
device.once(events_1.DEVICE.ACQUIRED, () => {
|
|
145
|
+
this.emit(events_1.DEVICE.CONNECT, device.toMessageObject());
|
|
146
146
|
});
|
|
147
147
|
return device;
|
|
148
148
|
}
|
|
@@ -196,7 +196,7 @@ class DeviceList extends events_1.default {
|
|
|
196
196
|
}
|
|
197
197
|
disconnectDevices() {
|
|
198
198
|
this.allDevices().forEach(device => {
|
|
199
|
-
this.emit(
|
|
199
|
+
this.emit(events_1.DEVICE.DISCONNECT, device.toMessageObject());
|
|
200
200
|
});
|
|
201
201
|
}
|
|
202
202
|
enumerate() {
|
|
@@ -262,7 +262,7 @@ class CreateDeviceHandler {
|
|
|
262
262
|
else if (((_a = error.message) === null || _a === void 0 ? void 0 : _a.indexOf(constants_1.ERRORS.LIBUSB_ERROR_MESSAGE)) >= 0) {
|
|
263
263
|
const device = this.list._createUnreadableDevice(this.list.creatingDevicesDescriptors[this.path], error.message);
|
|
264
264
|
this.list.devices[this.path] = device;
|
|
265
|
-
this.list.emit(
|
|
265
|
+
this.list.emit(events_1.DEVICE.CONNECT_UNACQUIRED, device.toMessageObject());
|
|
266
266
|
}
|
|
267
267
|
else if (error.code === 'Device_InitializeFailed') {
|
|
268
268
|
this._handleUsedElsewhere();
|
|
@@ -281,12 +281,12 @@ class CreateDeviceHandler {
|
|
|
281
281
|
const device = Device_1.Device.fromDescriptor(this.list.transport, this.descriptor);
|
|
282
282
|
this.list.devices[this.path] = device;
|
|
283
283
|
await device.run();
|
|
284
|
-
this.list.emit(
|
|
284
|
+
this.list.emit(events_1.DEVICE.CONNECT, device.toMessageObject());
|
|
285
285
|
}
|
|
286
286
|
_handleUsedElsewhere() {
|
|
287
287
|
const device = this.list._createUnacquiredDevice(this.list.creatingDevicesDescriptors[this.path]);
|
|
288
288
|
this.list.devices[this.path] = device;
|
|
289
|
-
this.list.emit(
|
|
289
|
+
this.list.emit(events_1.DEVICE.CONNECT_UNACQUIRED, device.toMessageObject());
|
|
290
290
|
}
|
|
291
291
|
}
|
|
292
292
|
class DiffHandler {
|
|
@@ -316,15 +316,15 @@ class DiffHandler {
|
|
|
316
316
|
const events = [
|
|
317
317
|
{
|
|
318
318
|
d: this.diff.changedSessions,
|
|
319
|
-
e:
|
|
319
|
+
e: events_1.DEVICE.CHANGED,
|
|
320
320
|
},
|
|
321
321
|
{
|
|
322
322
|
d: this.diff.acquired,
|
|
323
|
-
e:
|
|
323
|
+
e: events_1.DEVICE.ACQUIRED,
|
|
324
324
|
},
|
|
325
325
|
{
|
|
326
326
|
d: this.diff.released,
|
|
327
|
-
e:
|
|
327
|
+
e: events_1.DEVICE.RELEASED,
|
|
328
328
|
},
|
|
329
329
|
];
|
|
330
330
|
events.forEach(({ d, e }) => {
|
|
@@ -353,7 +353,7 @@ class DiffHandler {
|
|
|
353
353
|
else {
|
|
354
354
|
const device = await this.list._createUnacquiredDevice(descriptor);
|
|
355
355
|
this.list.devices[path] = device;
|
|
356
|
-
this.list.emit(
|
|
356
|
+
this.list.emit(events_1.DEVICE.CONNECT_UNACQUIRED, device.toMessageObject());
|
|
357
357
|
}
|
|
358
358
|
});
|
|
359
359
|
}
|
|
@@ -385,7 +385,7 @@ class DiffHandler {
|
|
|
385
385
|
if (device != null) {
|
|
386
386
|
device.disconnect();
|
|
387
387
|
delete this.list.devices[path];
|
|
388
|
-
this.list.emit(
|
|
388
|
+
this.list.emit(events_1.DEVICE.DISCONNECT, device.toMessageObject());
|
|
389
389
|
}
|
|
390
390
|
});
|
|
391
391
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trezor/connect",
|
|
3
|
-
"version": "9.0.
|
|
3
|
+
"version": "9.0.11",
|
|
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.",
|
|
@@ -49,37 +49,37 @@
|
|
|
49
49
|
"prepublish": "yarn tsx ../../scripts/prepublish.js"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@trezor/blockchain-link": "2.1.
|
|
53
|
-
"@trezor/connect-analytics": "1.0.
|
|
54
|
-
"@trezor/connect-common": "0.0.
|
|
55
|
-
"@trezor/transport": "1.1.
|
|
56
|
-
"@trezor/utils": "9.0.
|
|
57
|
-
"@trezor/utxo-lib": "1.0.
|
|
52
|
+
"@trezor/blockchain-link": "2.1.13",
|
|
53
|
+
"@trezor/connect-analytics": "1.0.2",
|
|
54
|
+
"@trezor/connect-common": "0.0.16",
|
|
55
|
+
"@trezor/transport": "1.1.12",
|
|
56
|
+
"@trezor/utils": "9.0.9",
|
|
57
|
+
"@trezor/utxo-lib": "1.0.7",
|
|
58
58
|
"bignumber.js": "^9.1.1",
|
|
59
59
|
"blakejs": "^1.2.1",
|
|
60
|
-
"cross-fetch": "^3.1.
|
|
60
|
+
"cross-fetch": "^3.1.6",
|
|
61
61
|
"events": "^3.3.0",
|
|
62
62
|
"randombytes": "2.1.0",
|
|
63
|
-
"tslib": "2.5.
|
|
63
|
+
"tslib": "2.5.2"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
|
-
"@trezor/trezor-user-env-link": "1.0.
|
|
66
|
+
"@trezor/trezor-user-env-link": "1.0.2",
|
|
67
67
|
"@types/karma": "^6.3.3",
|
|
68
68
|
"@types/parse-uri": "^1.0.0",
|
|
69
69
|
"@types/randombytes": "^2.0.0",
|
|
70
70
|
"jest": "^29.5.0",
|
|
71
71
|
"jest-environment-jsdom": "^29.5.0",
|
|
72
|
-
"karma": "^6.4.
|
|
72
|
+
"karma": "^6.4.2",
|
|
73
73
|
"karma-babel-preprocessor": "^8.0.2",
|
|
74
|
-
"karma-chrome-launcher": "^3.
|
|
74
|
+
"karma-chrome-launcher": "^3.2.0",
|
|
75
75
|
"karma-jasmine": "^5.1.0",
|
|
76
76
|
"karma-jasmine-async": "^0.0.1",
|
|
77
77
|
"karma-sourcemap-loader": "^0.4.0",
|
|
78
78
|
"karma-webpack": "^5.0.0",
|
|
79
|
-
"rimraf": "^
|
|
79
|
+
"rimraf": "^5.0.1",
|
|
80
80
|
"ts-loader": "^9.4.2",
|
|
81
81
|
"ts-node": "^10.9.1",
|
|
82
|
-
"tsx": "^3.12.
|
|
82
|
+
"tsx": "^3.12.7",
|
|
83
83
|
"typescript": "4.9.5"
|
|
84
84
|
}
|
|
85
85
|
}
|