@trezor/connect 9.0.10 → 9.1.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/CHANGELOG.md +13 -0
- package/README.md +19 -2
- package/lib/api/bitcoin/createPendingTx.d.ts +1 -0
- package/lib/api/bitcoin/createPendingTx.js +1 -0
- package/lib/api/cancelCoinjoinAuthorization.d.ts +7 -0
- package/lib/api/cancelCoinjoinAuthorization.js +25 -0
- package/lib/api/cardanoGetPublicKey.d.ts +1 -0
- package/lib/api/cardanoGetPublicKey.js +9 -0
- package/lib/api/cipherKeyValue.js +3 -2
- package/lib/api/getAccountInfo.d.ts +2 -0
- package/lib/api/getPublicKey.d.ts +1 -0
- package/lib/api/getPublicKey.js +9 -0
- package/lib/api/index.d.ts +2 -0
- package/lib/api/index.js +6 -2
- package/lib/api/rebootToBootloader.js +1 -1
- package/lib/api/showDeviceTutorial.d.ts +7 -0
- package/lib/api/showDeviceTutorial.js +21 -0
- package/lib/constants/errors.d.ts +0 -3
- package/lib/constants/errors.js +1 -4
- package/lib/core/index.d.ts +5 -6
- package/lib/core/index.js +44 -50
- package/lib/core/method.d.ts +1 -1
- package/lib/data/coinInfo.d.ts +0 -1
- package/lib/data/coinInfo.js +7 -14
- package/lib/data/config.js +7 -1
- package/lib/data/version.d.ts +1 -1
- package/lib/data/version.js +1 -1
- package/lib/device/Device.d.ts +16 -24
- package/lib/device/Device.js +71 -107
- package/lib/device/DeviceCommands.d.ts +4 -3
- package/lib/device/DeviceCommands.js +42 -20
- package/lib/device/DeviceList.d.ts +17 -33
- package/lib/device/DeviceList.js +230 -264
- package/lib/events/transport.d.ts +2 -9
- package/lib/events/transport.js +3 -10
- package/lib/factory.js +2 -0
- package/lib/index.js +7 -7
- package/lib/types/api/cancelCoinjoinAuthorization.d.ts +8 -0
- package/lib/types/api/cancelCoinjoinAuthorization.js +3 -0
- package/lib/types/api/index.d.ts +4 -0
- package/lib/types/api/showDeviceTutorial.d.ts +4 -0
- package/lib/types/api/showDeviceTutorial.js +3 -0
- package/lib/types/device.d.ts +1 -1
- package/lib/types/device.js +3 -0
- package/lib/types/settings.d.ts +1 -1
- package/lib/utils/debug.js +2 -1
- package/lib/utils/deviceFeaturesUtils.d.ts +2 -1
- package/lib/utils/deviceFeaturesUtils.js +12 -1
- package/lib/workers/workers-browser.d.ts +1 -3
- package/lib/workers/workers-browser.js +1 -7
- package/lib/workers/workers-react-native.d.ts +1 -3
- package/lib/workers/workers-react-native.js +1 -7
- package/lib/workers/workers.d.ts +1 -5
- package/lib/workers/workers.js +1 -5
- package/package.json +21 -18
- package/lib/device/DescriptorStream.d.ts +0 -28
- package/lib/device/DescriptorStream.js +0 -139
- package/lib/utils/objectUtils.d.ts +0 -10
- package/lib/utils/objectUtils.js +0 -37
- package/lib/workers/RNUsbPlugin.d.ts +0 -31
- package/lib/workers/RNUsbPlugin.js +0 -65
|
@@ -1,15 +1,8 @@
|
|
|
1
1
|
import type { MessageFactoryFn } from '../types/utils';
|
|
2
2
|
import type { Transport } from '@trezor/transport';
|
|
3
|
+
import { TRANSPORT } from '@trezor/transport/lib/constants';
|
|
4
|
+
export { TRANSPORT } from '@trezor/transport/lib/constants';
|
|
3
5
|
export declare const TRANSPORT_EVENT = "TRANSPORT_EVENT";
|
|
4
|
-
export declare const TRANSPORT: {
|
|
5
|
-
readonly START: "transport-start";
|
|
6
|
-
readonly ERROR: "transport-error";
|
|
7
|
-
readonly UPDATE: "transport-update";
|
|
8
|
-
readonly STREAM: "transport-stream";
|
|
9
|
-
readonly REQUEST_DEVICE: "transport-request_device";
|
|
10
|
-
readonly DISABLE_WEBUSB: "transport-disable_webusb";
|
|
11
|
-
readonly START_PENDING: "transport-start_pending";
|
|
12
|
-
};
|
|
13
6
|
export interface BridgeInfo {
|
|
14
7
|
version: number[];
|
|
15
8
|
directory: string;
|
package/lib/events/transport.js
CHANGED
|
@@ -1,17 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createTransportMessage = exports.
|
|
3
|
+
exports.createTransportMessage = exports.TRANSPORT_EVENT = exports.TRANSPORT = void 0;
|
|
4
4
|
const errors_1 = require("../constants/errors");
|
|
5
|
+
var constants_1 = require("@trezor/transport/lib/constants");
|
|
6
|
+
Object.defineProperty(exports, "TRANSPORT", { enumerable: true, get: function () { return constants_1.TRANSPORT; } });
|
|
5
7
|
exports.TRANSPORT_EVENT = 'TRANSPORT_EVENT';
|
|
6
|
-
exports.TRANSPORT = {
|
|
7
|
-
START: 'transport-start',
|
|
8
|
-
ERROR: 'transport-error',
|
|
9
|
-
UPDATE: 'transport-update',
|
|
10
|
-
STREAM: 'transport-stream',
|
|
11
|
-
REQUEST_DEVICE: 'transport-request_device',
|
|
12
|
-
DISABLE_WEBUSB: 'transport-disable_webusb',
|
|
13
|
-
START_PENDING: 'transport-start_pending',
|
|
14
|
-
};
|
|
15
8
|
const createTransportMessage = (type, payload) => ({
|
|
16
9
|
event: exports.TRANSPORT_EVENT,
|
|
17
10
|
type,
|
package/lib/factory.js
CHANGED
|
@@ -111,6 +111,8 @@ const factory = ({ eventEmitter, manifest, init, call, requestLogin, uiResponse,
|
|
|
111
111
|
applyFlags: params => call({ ...params, method: 'applyFlags' }),
|
|
112
112
|
applySettings: params => call({ ...params, method: 'applySettings' }),
|
|
113
113
|
authorizeCoinjoin: params => call({ ...params, method: 'authorizeCoinjoin' }),
|
|
114
|
+
cancelCoinjoinAuthorization: params => call({ ...params, method: 'cancelCoinjoinAuthorization' }),
|
|
115
|
+
showDeviceTutorial: params => call({ ...params, method: 'showDeviceTutorial' }),
|
|
114
116
|
backupDevice: params => call({ ...params, method: 'backupDevice' }),
|
|
115
117
|
changePin: params => call({ ...params, method: 'changePin' }),
|
|
116
118
|
firmwareUpdate: params => call({ ...params, method: 'firmwareUpdate' }),
|
package/lib/index.js
CHANGED
|
@@ -36,7 +36,7 @@ const handleMessage = (message) => {
|
|
|
36
36
|
if (!_core)
|
|
37
37
|
return;
|
|
38
38
|
if (type === events_2.UI.REQUEST_UI_WINDOW) {
|
|
39
|
-
_core.handleMessage({ event: events_2.UI_EVENT, type: events_2.POPUP.HANDSHAKE }
|
|
39
|
+
_core.handleMessage({ event: events_2.UI_EVENT, type: events_2.POPUP.HANDSHAKE });
|
|
40
40
|
return;
|
|
41
41
|
}
|
|
42
42
|
if (type === events_2.POPUP.CANCEL_POPUP_REQUEST)
|
|
@@ -84,10 +84,10 @@ function postMessage(message, usePromise = true) {
|
|
|
84
84
|
_messageID++;
|
|
85
85
|
exports.messagePromises[_messageID] = (0, utils_1.createDeferred)();
|
|
86
86
|
const { promise } = exports.messagePromises[_messageID];
|
|
87
|
-
_core.handleMessage({ ...message, id: _messageID }
|
|
87
|
+
_core.handleMessage({ ...message, id: _messageID });
|
|
88
88
|
return promise;
|
|
89
89
|
}
|
|
90
|
-
_core.handleMessage(message
|
|
90
|
+
_core.handleMessage(message);
|
|
91
91
|
}
|
|
92
92
|
const init = async (settings = {}) => {
|
|
93
93
|
var _a;
|
|
@@ -105,7 +105,7 @@ const init = async (settings = {}) => {
|
|
|
105
105
|
_settings.lazyLoad = false;
|
|
106
106
|
return;
|
|
107
107
|
}
|
|
108
|
-
_core = await (0, core_1.
|
|
108
|
+
_core = await (0, core_1.initCore)(_settings);
|
|
109
109
|
_core.on(events_2.CORE_EVENT, handleMessage);
|
|
110
110
|
await (0, core_1.initTransport)(_settings);
|
|
111
111
|
};
|
|
@@ -138,7 +138,7 @@ const uiResponse = (response) => {
|
|
|
138
138
|
throw constants_1.ERRORS.TypedError('Init_NotInitialized');
|
|
139
139
|
}
|
|
140
140
|
const { type, payload } = response;
|
|
141
|
-
_core.handleMessage({ event: events_2.UI_EVENT, type, payload }
|
|
141
|
+
_core.handleMessage({ event: events_2.UI_EVENT, type, payload });
|
|
142
142
|
};
|
|
143
143
|
const requestLogin = async (params) => {
|
|
144
144
|
if (typeof params.callback === 'function') {
|
|
@@ -152,14 +152,14 @@ const requestLogin = async (params) => {
|
|
|
152
152
|
event: events_2.UI_EVENT,
|
|
153
153
|
type: events_2.UI.LOGIN_CHALLENGE_RESPONSE,
|
|
154
154
|
payload,
|
|
155
|
-
}
|
|
155
|
+
});
|
|
156
156
|
}
|
|
157
157
|
catch (error) {
|
|
158
158
|
_core === null || _core === void 0 ? void 0 : _core.handleMessage({
|
|
159
159
|
event: events_2.UI_EVENT,
|
|
160
160
|
type: events_2.UI.LOGIN_CHALLENGE_RESPONSE,
|
|
161
161
|
payload: error.message,
|
|
162
|
-
}
|
|
162
|
+
});
|
|
163
163
|
}
|
|
164
164
|
}
|
|
165
165
|
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { PROTO } from '../../constants';
|
|
2
|
+
import type { Params, Response } from '../params';
|
|
3
|
+
interface CancelCoinjoinAuthorization {
|
|
4
|
+
preauthorized?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export declare function cancelCoinjoinAuthorization(params: Params<CancelCoinjoinAuthorization>): Response<PROTO.Success>;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=cancelCoinjoinAuthorization.d.ts.map
|
package/lib/types/api/index.d.ts
CHANGED
|
@@ -75,10 +75,14 @@ import { unlockPath } from './unlockPath';
|
|
|
75
75
|
import { verifyMessage } from './verifyMessage';
|
|
76
76
|
import { wipeDevice } from './wipeDevice';
|
|
77
77
|
import { checkFirmwareAuthenticity } from './checkFirmwareAuthenticity';
|
|
78
|
+
import { cancelCoinjoinAuthorization } from './cancelCoinjoinAuthorization';
|
|
79
|
+
import { showDeviceTutorial } from './showDeviceTutorial';
|
|
78
80
|
export interface TrezorConnect {
|
|
79
81
|
applyFlags: typeof applyFlags;
|
|
80
82
|
applySettings: typeof applySettings;
|
|
81
83
|
authorizeCoinjoin: typeof authorizeCoinjoin;
|
|
84
|
+
cancelCoinjoinAuthorization: typeof cancelCoinjoinAuthorization;
|
|
85
|
+
showDeviceTutorial: typeof showDeviceTutorial;
|
|
82
86
|
backupDevice: typeof backupDevice;
|
|
83
87
|
binanceGetAddress: typeof binanceGetAddress;
|
|
84
88
|
binanceGetPublicKey: typeof binanceGetPublicKey;
|
package/lib/types/device.d.ts
CHANGED
|
@@ -55,6 +55,7 @@ export type UnreadableDevice = {
|
|
|
55
55
|
};
|
|
56
56
|
export type Device = KnownDevice | UnknownDevice | UnreadableDevice;
|
|
57
57
|
export type Features = PROTO.Features;
|
|
58
|
+
export { DeviceModelInternal } from '@trezor/transport/lib/types/messages';
|
|
58
59
|
type FeaturesNarrowing = {
|
|
59
60
|
major_version: 2;
|
|
60
61
|
fw_major: null;
|
|
@@ -92,5 +93,4 @@ type FeaturesNarrowing = {
|
|
|
92
93
|
firmware_present: true;
|
|
93
94
|
};
|
|
94
95
|
export type StrictFeatures = Features & FeaturesNarrowing;
|
|
95
|
-
export {};
|
|
96
96
|
//# sourceMappingURL=device.d.ts.map
|
package/lib/types/device.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DeviceModelInternal = void 0;
|
|
4
|
+
var messages_1 = require("@trezor/transport/lib/types/messages");
|
|
5
|
+
Object.defineProperty(exports, "DeviceModelInternal", { enumerable: true, get: function () { return messages_1.DeviceModelInternal; } });
|
|
3
6
|
//# sourceMappingURL=device.js.map
|
package/lib/types/settings.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export interface ConnectSettings {
|
|
|
15
15
|
popup?: boolean;
|
|
16
16
|
transportReconnect?: boolean;
|
|
17
17
|
webusb?: boolean;
|
|
18
|
-
transports?: Transport['name'][];
|
|
18
|
+
transports?: (Transport['name'] | Transport)[];
|
|
19
19
|
pendingTransportEvent?: boolean;
|
|
20
20
|
lazyLoad?: boolean;
|
|
21
21
|
interactionTimeout?: number;
|
package/lib/utils/debug.js
CHANGED
|
@@ -9,6 +9,7 @@ const colors = {
|
|
|
9
9
|
DeviceList: 'color: #77ab59; background: #000;',
|
|
10
10
|
Device: 'color: #bada55; background: #000;',
|
|
11
11
|
DeviceCommands: 'color: #bada55; background: #000;',
|
|
12
|
+
'@trezor/transport': 'color: #bada55; background: #000;',
|
|
12
13
|
};
|
|
13
14
|
const MAX_ENTRIES = 100;
|
|
14
15
|
class Log {
|
|
@@ -23,7 +24,7 @@ class Log {
|
|
|
23
24
|
level,
|
|
24
25
|
prefix,
|
|
25
26
|
message: args,
|
|
26
|
-
timestamp:
|
|
27
|
+
timestamp: Date.now(),
|
|
27
28
|
});
|
|
28
29
|
if (this.messages.length > MAX_ENTRIES) {
|
|
29
30
|
this.messages.shift();
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { PROTO } from '../constants';
|
|
2
|
-
import
|
|
2
|
+
import { Features, CoinInfo, UnavailableCapabilities, DeviceModelInternal } from '../types';
|
|
3
3
|
export declare const parseCapabilities: (features?: Features) => PROTO.Capability[];
|
|
4
4
|
export declare const getUnavailableCapabilities: (features: Features, coins: CoinInfo[]) => UnavailableCapabilities;
|
|
5
5
|
export declare const parseRevision: (features: Features) => string | null;
|
|
6
|
+
export declare const ensureInternalModelFeature: (model: Features['model']) => DeviceModelInternal;
|
|
6
7
|
//# sourceMappingURL=deviceFeaturesUtils.d.ts.map
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseRevision = exports.getUnavailableCapabilities = exports.parseCapabilities = void 0;
|
|
3
|
+
exports.ensureInternalModelFeature = exports.parseRevision = exports.getUnavailableCapabilities = exports.parseCapabilities = void 0;
|
|
4
4
|
const versionUtils_1 = require("./versionUtils");
|
|
5
5
|
const config_1 = require("../data/config");
|
|
6
|
+
const types_1 = require("../types");
|
|
6
7
|
const DEFAULT_CAPABILITIES_T1 = [
|
|
7
8
|
'Capability_Bitcoin',
|
|
8
9
|
'Capability_Bitcoin_like',
|
|
@@ -112,4 +113,14 @@ const parseRevision = (features) => {
|
|
|
112
113
|
return /^([a-f0-9])*$/gi.test(revisionUtf8) ? revisionUtf8 : revision;
|
|
113
114
|
};
|
|
114
115
|
exports.parseRevision = parseRevision;
|
|
116
|
+
const ensureInternalModelFeature = (model) => {
|
|
117
|
+
switch (model.toUpperCase()) {
|
|
118
|
+
case 'T':
|
|
119
|
+
return types_1.DeviceModelInternal.T2T1;
|
|
120
|
+
case '1':
|
|
121
|
+
default:
|
|
122
|
+
return types_1.DeviceModelInternal.T1B1;
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
exports.ensureInternalModelFeature = ensureInternalModelFeature;
|
|
115
126
|
//# sourceMappingURL=deviceFeaturesUtils.js.map
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import BlockbookWorker from '@trezor/blockchain-link/lib/workers/blockbook';
|
|
2
2
|
import RippleWorker from '@trezor/blockchain-link/lib/workers/ripple';
|
|
3
3
|
import BlockfrostWorker from '@trezor/blockchain-link/lib/workers/blockfrost';
|
|
4
|
-
declare const WebUsbPlugin: () => import("packages/transport/lib/lowlevel/withSharedConnections").default;
|
|
5
|
-
declare const ReactNativeUsbPlugin: undefined;
|
|
6
4
|
declare const ElectrumWorker: undefined;
|
|
7
|
-
export {
|
|
5
|
+
export { BlockbookWorker, RippleWorker, BlockfrostWorker, ElectrumWorker };
|
|
8
6
|
//# sourceMappingURL=workers-browser.d.ts.map
|
|
@@ -1,19 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ElectrumWorker = exports.BlockfrostWorker = exports.RippleWorker = exports.BlockbookWorker =
|
|
3
|
+
exports.ElectrumWorker = exports.BlockfrostWorker = exports.RippleWorker = exports.BlockbookWorker = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const sharedConnectionWorker_1 = tslib_1.__importDefault(require("@trezor/transport/lib/lowlevel/sharedConnectionWorker"));
|
|
6
5
|
const blockbook_1 = tslib_1.__importDefault(require("@trezor/blockchain-link/lib/workers/blockbook"));
|
|
7
6
|
exports.BlockbookWorker = blockbook_1.default;
|
|
8
7
|
const ripple_1 = tslib_1.__importDefault(require("@trezor/blockchain-link/lib/workers/ripple"));
|
|
9
8
|
exports.RippleWorker = ripple_1.default;
|
|
10
9
|
const blockfrost_1 = tslib_1.__importDefault(require("@trezor/blockchain-link/lib/workers/blockfrost"));
|
|
11
10
|
exports.BlockfrostWorker = blockfrost_1.default;
|
|
12
|
-
const transport_1 = tslib_1.__importDefault(require("@trezor/transport"));
|
|
13
|
-
const WebUsbPlugin = () => new transport_1.default.Lowlevel(new transport_1.default.WebUsb(), typeof SharedWorker !== 'undefined' ? () => new sharedConnectionWorker_1.default() : null);
|
|
14
|
-
exports.WebUsbPlugin = WebUsbPlugin;
|
|
15
|
-
const ReactNativeUsbPlugin = undefined;
|
|
16
|
-
exports.ReactNativeUsbPlugin = ReactNativeUsbPlugin;
|
|
17
11
|
const ElectrumWorker = undefined;
|
|
18
12
|
exports.ElectrumWorker = ElectrumWorker;
|
|
19
13
|
//# sourceMappingURL=workers-browser.js.map
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import BlockbookWorker from '@trezor/blockchain-link/lib/workers/blockbook';
|
|
2
2
|
import RippleWorker from '@trezor/blockchain-link/lib/workers/ripple';
|
|
3
3
|
import BlockfrostWorker from '@trezor/blockchain-link/lib/workers/blockfrost';
|
|
4
|
-
declare const WebUsbPlugin: undefined;
|
|
5
4
|
declare const ElectrumWorker: undefined;
|
|
6
|
-
|
|
7
|
-
export { WebUsbPlugin, ReactNativeUsbPlugin, BlockbookWorker, RippleWorker, BlockfrostWorker, ElectrumWorker, };
|
|
5
|
+
export { BlockbookWorker, RippleWorker, BlockfrostWorker, ElectrumWorker };
|
|
8
6
|
//# sourceMappingURL=workers-react-native.d.ts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ElectrumWorker = exports.BlockfrostWorker = exports.RippleWorker = exports.BlockbookWorker =
|
|
3
|
+
exports.ElectrumWorker = exports.BlockfrostWorker = exports.RippleWorker = exports.BlockbookWorker = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const blockbook_1 = tslib_1.__importDefault(require("@trezor/blockchain-link/lib/workers/blockbook"));
|
|
6
6
|
exports.BlockbookWorker = blockbook_1.default;
|
|
@@ -8,12 +8,6 @@ const ripple_1 = tslib_1.__importDefault(require("@trezor/blockchain-link/lib/wo
|
|
|
8
8
|
exports.RippleWorker = ripple_1.default;
|
|
9
9
|
const blockfrost_1 = tslib_1.__importDefault(require("@trezor/blockchain-link/lib/workers/blockfrost"));
|
|
10
10
|
exports.BlockfrostWorker = blockfrost_1.default;
|
|
11
|
-
const transport_1 = tslib_1.__importDefault(require("@trezor/transport"));
|
|
12
|
-
const RNUsbPlugin_1 = require("./RNUsbPlugin");
|
|
13
|
-
const WebUsbPlugin = undefined;
|
|
14
|
-
exports.WebUsbPlugin = WebUsbPlugin;
|
|
15
11
|
const ElectrumWorker = undefined;
|
|
16
12
|
exports.ElectrumWorker = ElectrumWorker;
|
|
17
|
-
const ReactNativeUsbPlugin = () => new transport_1.default.Lowlevel(new RNUsbPlugin_1.ReactNativePlugin(), undefined);
|
|
18
|
-
exports.ReactNativeUsbPlugin = ReactNativeUsbPlugin;
|
|
19
13
|
//# sourceMappingURL=workers-react-native.js.map
|
package/lib/workers/workers.d.ts
CHANGED
|
@@ -2,9 +2,5 @@ import BlockbookWorker from '@trezor/blockchain-link/lib/workers/blockbook';
|
|
|
2
2
|
import RippleWorker from '@trezor/blockchain-link/lib/workers/ripple';
|
|
3
3
|
import BlockfrostWorker from '@trezor/blockchain-link/lib/workers/blockfrost';
|
|
4
4
|
import ElectrumWorker from '@trezor/blockchain-link/lib/workers/electrum';
|
|
5
|
-
|
|
6
|
-
type TransportWrapper = () => Transport;
|
|
7
|
-
declare const WebUsbPlugin: TransportWrapper | typeof undefined;
|
|
8
|
-
declare const ReactNativeUsbPlugin: TransportWrapper | typeof undefined;
|
|
9
|
-
export { WebUsbPlugin, ReactNativeUsbPlugin, BlockbookWorker, RippleWorker, BlockfrostWorker, ElectrumWorker, };
|
|
5
|
+
export { BlockbookWorker, RippleWorker, BlockfrostWorker, ElectrumWorker };
|
|
10
6
|
//# sourceMappingURL=workers.d.ts.map
|
package/lib/workers/workers.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ElectrumWorker = exports.BlockfrostWorker = exports.RippleWorker = exports.BlockbookWorker =
|
|
3
|
+
exports.ElectrumWorker = exports.BlockfrostWorker = exports.RippleWorker = exports.BlockbookWorker = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const blockbook_1 = tslib_1.__importDefault(require("@trezor/blockchain-link/lib/workers/blockbook"));
|
|
6
6
|
exports.BlockbookWorker = blockbook_1.default;
|
|
@@ -10,8 +10,4 @@ const blockfrost_1 = tslib_1.__importDefault(require("@trezor/blockchain-link/li
|
|
|
10
10
|
exports.BlockfrostWorker = blockfrost_1.default;
|
|
11
11
|
const electrum_1 = tslib_1.__importDefault(require("@trezor/blockchain-link/lib/workers/electrum"));
|
|
12
12
|
exports.ElectrumWorker = electrum_1.default;
|
|
13
|
-
const WebUsbPlugin = undefined;
|
|
14
|
-
exports.WebUsbPlugin = WebUsbPlugin;
|
|
15
|
-
const ReactNativeUsbPlugin = undefined;
|
|
16
|
-
exports.ReactNativeUsbPlugin = ReactNativeUsbPlugin;
|
|
17
13
|
//# sourceMappingURL=workers.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trezor/connect",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.1.1",
|
|
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,40 @@
|
|
|
49
49
|
"prepublish": "yarn tsx ../../scripts/prepublish.js"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@trezor/blockchain-link": "2.1.
|
|
53
|
-
"@trezor/
|
|
54
|
-
"@trezor/connect-
|
|
55
|
-
"@trezor/
|
|
56
|
-
"@trezor/
|
|
57
|
-
"@trezor/
|
|
52
|
+
"@trezor/blockchain-link": "2.1.15",
|
|
53
|
+
"@trezor/blockchain-link-types": "1.0.4",
|
|
54
|
+
"@trezor/connect-analytics": "1.0.4",
|
|
55
|
+
"@trezor/connect-common": "0.0.18",
|
|
56
|
+
"@trezor/transport": "1.1.14",
|
|
57
|
+
"@trezor/utils": "9.0.11",
|
|
58
|
+
"@trezor/utxo-lib": "1.0.9",
|
|
58
59
|
"bignumber.js": "^9.1.1",
|
|
59
60
|
"blakejs": "^1.2.1",
|
|
60
|
-
"
|
|
61
|
+
"bs58": "^5.0.0",
|
|
62
|
+
"bs58check": "^3.0.1",
|
|
63
|
+
"cross-fetch": "^3.1.6",
|
|
61
64
|
"events": "^3.3.0",
|
|
62
|
-
"randombytes": "2.1.0"
|
|
63
|
-
"tslib": "2.5.0"
|
|
65
|
+
"randombytes": "2.1.0"
|
|
64
66
|
},
|
|
65
67
|
"devDependencies": {
|
|
66
|
-
"@trezor/trezor-user-env-link": "1.0.
|
|
67
|
-
"@types/karma": "^6.3.
|
|
68
|
+
"@trezor/trezor-user-env-link": "1.0.2",
|
|
69
|
+
"@types/karma": "^6.3.4",
|
|
68
70
|
"@types/parse-uri": "^1.0.0",
|
|
69
71
|
"@types/randombytes": "^2.0.0",
|
|
70
72
|
"jest": "^29.5.0",
|
|
71
73
|
"jest-environment-jsdom": "^29.5.0",
|
|
72
|
-
"karma": "^6.4.
|
|
74
|
+
"karma": "^6.4.2",
|
|
73
75
|
"karma-babel-preprocessor": "^8.0.2",
|
|
74
|
-
"karma-chrome-launcher": "^3.
|
|
76
|
+
"karma-chrome-launcher": "^3.2.0",
|
|
75
77
|
"karma-jasmine": "^5.1.0",
|
|
76
78
|
"karma-jasmine-async": "^0.0.1",
|
|
77
79
|
"karma-sourcemap-loader": "^0.4.0",
|
|
78
80
|
"karma-webpack": "^5.0.0",
|
|
79
|
-
"rimraf": "^
|
|
80
|
-
"ts-loader": "^9.4.2",
|
|
81
|
+
"rimraf": "^5.0.1",
|
|
81
82
|
"ts-node": "^10.9.1",
|
|
82
|
-
"tsx": "^3.12.
|
|
83
|
-
"typescript": "4.9.5"
|
|
83
|
+
"tsx": "^3.12.7",
|
|
84
|
+
"typescript": "4.9.5",
|
|
85
|
+
"webpack": "^5.87.0",
|
|
86
|
+
"ws": "7.5.9"
|
|
84
87
|
}
|
|
85
88
|
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import EventEmitter from 'events';
|
|
3
|
-
import type { Transport, TrezorDeviceInfoWithSession as DeviceDescriptor } from '@trezor/transport';
|
|
4
|
-
export type DeviceDescriptorDiff = {
|
|
5
|
-
didUpdate: boolean;
|
|
6
|
-
connected: DeviceDescriptor[];
|
|
7
|
-
disconnected: DeviceDescriptor[];
|
|
8
|
-
changedSessions: DeviceDescriptor[];
|
|
9
|
-
changedDebugSessions: DeviceDescriptor[];
|
|
10
|
-
acquired: DeviceDescriptor[];
|
|
11
|
-
debugAcquired: DeviceDescriptor[];
|
|
12
|
-
released: DeviceDescriptor[];
|
|
13
|
-
debugReleased: DeviceDescriptor[];
|
|
14
|
-
descriptors: DeviceDescriptor[];
|
|
15
|
-
};
|
|
16
|
-
export declare class DescriptorStream extends EventEmitter {
|
|
17
|
-
transport: Transport;
|
|
18
|
-
listening: boolean;
|
|
19
|
-
listenTimestamp: number;
|
|
20
|
-
current: DeviceDescriptor[] | null;
|
|
21
|
-
upcoming: DeviceDescriptor[];
|
|
22
|
-
constructor(transport: Transport);
|
|
23
|
-
listen(): Promise<void>;
|
|
24
|
-
enumerate(): Promise<void>;
|
|
25
|
-
stop(): void;
|
|
26
|
-
_reportChanges(): void;
|
|
27
|
-
}
|
|
28
|
-
//# sourceMappingURL=DescriptorStream.d.ts.map
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DescriptorStream = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const events_1 = tslib_1.__importDefault(require("events"));
|
|
6
|
-
const transport_1 = require("../events/transport");
|
|
7
|
-
const device_1 = require("../events/device");
|
|
8
|
-
const debug_1 = require("../utils/debug");
|
|
9
|
-
const DataManager_1 = require("../data/DataManager");
|
|
10
|
-
const promiseUtils_1 = require("../utils/promiseUtils");
|
|
11
|
-
const logger = (0, debug_1.initLog)('DescriptorStream');
|
|
12
|
-
const getDiff = (current, descriptors) => {
|
|
13
|
-
const connected = descriptors.filter(d => current.find(x => x.path === d.path) === undefined);
|
|
14
|
-
const disconnected = current.filter(d => descriptors.find(x => x.path === d.path) === undefined);
|
|
15
|
-
const changedSessions = descriptors.filter(d => {
|
|
16
|
-
const currentDescriptor = current.find(x => x.path === d.path);
|
|
17
|
-
if (currentDescriptor) {
|
|
18
|
-
return currentDescriptor.session !== d.session;
|
|
19
|
-
}
|
|
20
|
-
return false;
|
|
21
|
-
});
|
|
22
|
-
const acquired = changedSessions.filter(d => typeof d.session === 'string');
|
|
23
|
-
const released = changedSessions.filter(d => typeof d.session !== 'string');
|
|
24
|
-
const changedDebugSessions = descriptors.filter(d => {
|
|
25
|
-
const currentDescriptor = current.find(x => x.path === d.path);
|
|
26
|
-
if (currentDescriptor) {
|
|
27
|
-
return currentDescriptor.debugSession !== d.debugSession;
|
|
28
|
-
}
|
|
29
|
-
return false;
|
|
30
|
-
});
|
|
31
|
-
const debugAcquired = changedSessions.filter(d => typeof d.debugSession === 'string');
|
|
32
|
-
const debugReleased = changedSessions.filter(d => typeof d.debugSession !== 'string');
|
|
33
|
-
const didUpdate = connected.length +
|
|
34
|
-
disconnected.length +
|
|
35
|
-
changedSessions.length +
|
|
36
|
-
changedDebugSessions.length >
|
|
37
|
-
0;
|
|
38
|
-
return {
|
|
39
|
-
connected,
|
|
40
|
-
disconnected,
|
|
41
|
-
changedSessions,
|
|
42
|
-
acquired,
|
|
43
|
-
released,
|
|
44
|
-
changedDebugSessions,
|
|
45
|
-
debugAcquired,
|
|
46
|
-
debugReleased,
|
|
47
|
-
didUpdate,
|
|
48
|
-
descriptors,
|
|
49
|
-
};
|
|
50
|
-
};
|
|
51
|
-
class DescriptorStream extends events_1.default {
|
|
52
|
-
constructor(transport) {
|
|
53
|
-
super();
|
|
54
|
-
this.listening = false;
|
|
55
|
-
this.listenTimestamp = 0;
|
|
56
|
-
this.current = null;
|
|
57
|
-
this.upcoming = [];
|
|
58
|
-
this.transport = transport;
|
|
59
|
-
}
|
|
60
|
-
async listen() {
|
|
61
|
-
const waitForEvent = this.current !== null;
|
|
62
|
-
const current = this.current || [];
|
|
63
|
-
this.listening = true;
|
|
64
|
-
let descriptors;
|
|
65
|
-
try {
|
|
66
|
-
logger.debug('Start listening', current);
|
|
67
|
-
this.listenTimestamp = new Date().getTime();
|
|
68
|
-
descriptors = waitForEvent
|
|
69
|
-
? await this.transport.listen(current)
|
|
70
|
-
: await this.transport.enumerate();
|
|
71
|
-
if (this.listening && !waitForEvent) {
|
|
72
|
-
if (descriptors.length > 0 && DataManager_1.DataManager.getSettings('pendingTransportEvent')) {
|
|
73
|
-
this.emit(transport_1.TRANSPORT.START_PENDING, descriptors.length);
|
|
74
|
-
}
|
|
75
|
-
else {
|
|
76
|
-
this.emit(transport_1.TRANSPORT.START);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
if (!this.listening)
|
|
80
|
-
return;
|
|
81
|
-
this.upcoming = descriptors;
|
|
82
|
-
logger.debug('Listen result', descriptors);
|
|
83
|
-
this._reportChanges();
|
|
84
|
-
if (this.listening)
|
|
85
|
-
this.listen();
|
|
86
|
-
}
|
|
87
|
-
catch (error) {
|
|
88
|
-
const time = new Date().getTime() - this.listenTimestamp;
|
|
89
|
-
logger.debug('Listen error', 'timestamp', time, typeof error);
|
|
90
|
-
if (time > 1100) {
|
|
91
|
-
await (0, promiseUtils_1.resolveAfter)(1000, null).promise;
|
|
92
|
-
if (this.listening)
|
|
93
|
-
this.listen();
|
|
94
|
-
}
|
|
95
|
-
else {
|
|
96
|
-
logger.warn('Transport error');
|
|
97
|
-
this.emit(transport_1.TRANSPORT.ERROR, error);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
async enumerate() {
|
|
102
|
-
if (!this.listening)
|
|
103
|
-
return;
|
|
104
|
-
try {
|
|
105
|
-
this.upcoming = await this.transport.enumerate();
|
|
106
|
-
this._reportChanges();
|
|
107
|
-
}
|
|
108
|
-
catch (error) {
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
stop() {
|
|
112
|
-
this.listening = false;
|
|
113
|
-
this.removeAllListeners();
|
|
114
|
-
}
|
|
115
|
-
_reportChanges() {
|
|
116
|
-
const diff = getDiff(this.current || [], this.upcoming);
|
|
117
|
-
this.current = this.upcoming;
|
|
118
|
-
if (diff.didUpdate && this.listening) {
|
|
119
|
-
diff.connected.forEach(d => {
|
|
120
|
-
this.emit(device_1.DEVICE.CONNECT, d);
|
|
121
|
-
});
|
|
122
|
-
diff.disconnected.forEach(d => {
|
|
123
|
-
this.emit(device_1.DEVICE.DISCONNECT, d);
|
|
124
|
-
});
|
|
125
|
-
diff.acquired.forEach(d => {
|
|
126
|
-
this.emit(device_1.DEVICE.ACQUIRED, d);
|
|
127
|
-
});
|
|
128
|
-
diff.released.forEach(d => {
|
|
129
|
-
this.emit(device_1.DEVICE.RELEASED, d);
|
|
130
|
-
});
|
|
131
|
-
diff.changedSessions.forEach(d => {
|
|
132
|
-
this.emit(device_1.DEVICE.CHANGED, d);
|
|
133
|
-
});
|
|
134
|
-
this.emit(transport_1.TRANSPORT.UPDATE, diff);
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
exports.DescriptorStream = DescriptorStream;
|
|
139
|
-
//# sourceMappingURL=DescriptorStream.js.map
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export declare function clone<T>(obj: T): T;
|
|
2
|
-
export declare function entries<T>(obj: {
|
|
3
|
-
[key: string]: T;
|
|
4
|
-
}): Array<[string, T]>;
|
|
5
|
-
export declare function deepClone(_obj: any, _hash?: any): void;
|
|
6
|
-
export declare function snapshot(obj: any): any;
|
|
7
|
-
export declare function objectValues<X>(object: {
|
|
8
|
-
[key: string]: X;
|
|
9
|
-
}): X[];
|
|
10
|
-
//# sourceMappingURL=objectUtils.d.ts.map
|
package/lib/utils/objectUtils.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.objectValues = exports.snapshot = exports.deepClone = exports.entries = exports.clone = void 0;
|
|
4
|
-
function clone(obj) {
|
|
5
|
-
const jsonString = JSON.stringify(obj);
|
|
6
|
-
if (jsonString === undefined) {
|
|
7
|
-
return obj;
|
|
8
|
-
}
|
|
9
|
-
return JSON.parse(jsonString);
|
|
10
|
-
}
|
|
11
|
-
exports.clone = clone;
|
|
12
|
-
function entries(obj) {
|
|
13
|
-
const keys = Object.keys(obj);
|
|
14
|
-
return keys.map(key => [key, obj[key]]);
|
|
15
|
-
}
|
|
16
|
-
exports.entries = entries;
|
|
17
|
-
function deepClone(_obj, _hash = new WeakMap()) {
|
|
18
|
-
}
|
|
19
|
-
exports.deepClone = deepClone;
|
|
20
|
-
function snapshot(obj) {
|
|
21
|
-
if (obj == null || typeof obj !== 'object') {
|
|
22
|
-
return obj;
|
|
23
|
-
}
|
|
24
|
-
const temp = new obj.constructor();
|
|
25
|
-
Object.keys(temp).forEach(key => {
|
|
26
|
-
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
27
|
-
temp[key] = snapshot(obj[key]);
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
return temp;
|
|
31
|
-
}
|
|
32
|
-
exports.snapshot = snapshot;
|
|
33
|
-
function objectValues(object) {
|
|
34
|
-
return Object.keys(object).map(key => object[key]);
|
|
35
|
-
}
|
|
36
|
-
exports.objectValues = objectValues;
|
|
37
|
-
//# sourceMappingURL=objectUtils.js.map
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
type TrezorDeviceInfoDebug = {
|
|
2
|
-
path: string;
|
|
3
|
-
debug: boolean;
|
|
4
|
-
};
|
|
5
|
-
interface TrezorTransport {
|
|
6
|
-
enumerate(): Promise<TrezorDeviceInfoDebug[]>;
|
|
7
|
-
acquire(path: string, debugLink: boolean): Promise<void>;
|
|
8
|
-
release(path: string, debugLink: boolean, closePort: boolean): Promise<void>;
|
|
9
|
-
write(path: string, debugLink: boolean, data: string): Promise<void>;
|
|
10
|
-
read(path: string, debugLink: boolean): Promise<{
|
|
11
|
-
data: string;
|
|
12
|
-
}>;
|
|
13
|
-
}
|
|
14
|
-
export declare class ReactNativePlugin {
|
|
15
|
-
name: string;
|
|
16
|
-
version: string;
|
|
17
|
-
debug: boolean;
|
|
18
|
-
allowsWriteAndEnumerate: boolean;
|
|
19
|
-
requestNeeded: boolean;
|
|
20
|
-
usb: TrezorTransport;
|
|
21
|
-
constructor();
|
|
22
|
-
init(debug?: boolean): Promise<void>;
|
|
23
|
-
enumerate(): Promise<TrezorDeviceInfoDebug[]>;
|
|
24
|
-
send(path: string, data: ArrayBuffer, debugLink: boolean): Promise<void>;
|
|
25
|
-
receive(path: string, debugLink: boolean): Promise<ArrayBuffer>;
|
|
26
|
-
connect(path: string, debugLink: boolean): Promise<void>;
|
|
27
|
-
disconnect(path: string, debugLink: boolean, last: boolean): Promise<void>;
|
|
28
|
-
requestDevice(): any;
|
|
29
|
-
}
|
|
30
|
-
export {};
|
|
31
|
-
//# sourceMappingURL=RNUsbPlugin.d.ts.map
|