@trezor/connect 9.1.4 → 9.1.5
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 +17 -0
- package/README.md +1 -1
- package/lib/api/authenticateDevice.d.ts +7 -0
- package/lib/api/authenticateDevice.js +51 -0
- package/lib/api/checkFirmwareAuthenticity.js +7 -5
- package/lib/api/common/paramsValidator.js +45 -51
- package/lib/api/ethereum/ethereumDefinitions.js +3 -2
- package/lib/api/firmware/getBinary.js +1 -1
- package/lib/api/firmware/verifyAuthenticityProof.d.ts +14 -0
- package/lib/api/firmware/verifyAuthenticityProof.js +103 -0
- package/lib/api/firmware/x509certificate.d.ts +73 -0
- package/lib/api/firmware/x509certificate.js +203 -0
- package/lib/api/firmwareUpdate.js +2 -1
- package/lib/api/getAccountInfo.js +1 -5
- package/lib/api/getFirmwareHash.js +1 -4
- package/lib/api/index.d.ts +1 -0
- package/lib/api/index.js +4 -2
- package/lib/api/rebootToBootloader.js +1 -4
- package/lib/core/AbstractMethod.d.ts +1 -0
- package/lib/core/AbstractMethod.js +11 -10
- package/lib/core/index.d.ts +3 -2
- package/lib/core/index.js +11 -3
- package/lib/core/method.d.ts +1 -1
- package/lib/data/DataManager.d.ts +53 -7
- package/lib/data/DataManager.js +4 -2
- package/lib/data/config.d.ts +52 -6
- package/lib/data/config.js +35 -23
- package/lib/data/connectSettings.js +3 -0
- package/lib/data/deviceAuthenticityConfig.d.ts +15 -0
- package/lib/data/deviceAuthenticityConfig.js +26 -0
- package/lib/data/firmwareInfo.d.ts +3 -2
- package/lib/data/firmwareInfo.js +17 -8
- package/lib/data/models.d.ts +4 -1
- package/lib/data/models.js +6 -3
- package/lib/data/version.d.ts +1 -1
- package/lib/data/version.js +1 -1
- package/lib/device/Device.d.ts +1 -1
- package/lib/device/Device.js +11 -11
- package/lib/device/DeviceList.d.ts +1 -0
- package/lib/device/DeviceList.js +4 -3
- package/lib/events/iframe.d.ts +7 -1
- package/lib/events/iframe.js +1 -0
- package/lib/factory.js +1 -0
- package/lib/types/api/authenticateDevice.d.ts +21 -0
- package/lib/types/api/authenticateDevice.js +3 -0
- package/lib/types/api/index.d.ts +2 -0
- package/lib/types/coinInfo.d.ts +3 -2
- package/lib/types/firmware.d.ts +6 -2
- package/lib/types/index.d.ts +1 -0
- package/lib/utils/assetUtils.js +6 -4
- package/lib/utils/debug.d.ts +9 -3
- package/lib/utils/debug.js +50 -17
- package/lib/utils/deviceFeaturesUtils.js +3 -3
- package/package.json +13 -10
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deviceAuthenticityConfig = void 0;
|
|
4
|
+
exports.deviceAuthenticityConfig = {
|
|
5
|
+
version: 1,
|
|
6
|
+
timestamp: '2023-10-24T10:00:00+00:00',
|
|
7
|
+
T2B1: {
|
|
8
|
+
rootPubKeys: [
|
|
9
|
+
'04ca97480ac0d7b1e6efafe518cd433cec2bf8ab9822d76eafd34363b55d63e60380bff20acc75cde03cffcb50ab6f8ce70c878e37ebc58ff7cca0a83b16b15fa5',
|
|
10
|
+
],
|
|
11
|
+
caPubKeys: [
|
|
12
|
+
'04b12efa295ad825a534b7c0bf276e93ad116434426763fa87bfa8a2f12e726906dcf566813f62eba8f8795f94dba0391c53682809cbbd7e4ba01d960b4f1c68f1',
|
|
13
|
+
'04cb87d4c5d0fd5854e829f4c1b666e49a86c25c88a904c0feb66f1338faed0d7760010d7ea1a6474cbcfe1143bd4b5397a4e8b7fe86899113caecf42a984b0c0f',
|
|
14
|
+
'0450c45878b2c6403a5a16e97a8957dc3ea36919bce9321b357f6e7ebe6257ee54102a2c2fa5cefed1dabc498fc76dc0bcf3c3a8a415eac7cc32e7c18185f25b0d',
|
|
15
|
+
],
|
|
16
|
+
debug: {
|
|
17
|
+
rootPubKeys: [
|
|
18
|
+
'047f77368dea2d4d61e989f474a56723c3212dacf8a808d8795595ef38441427c4389bc454f02089d7f08b873005e4c28d432468997871c0bf286fd3861e21e96a',
|
|
19
|
+
],
|
|
20
|
+
caPubKeys: [
|
|
21
|
+
'04ba6084cb9fba7c86d5d5a86108a91d55a27056da4eabbedde88a95e1cae8bce3620889167aaf7f2db166998f950984aa195e868f96e22803c3cd991be31d39e7',
|
|
22
|
+
],
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=deviceAuthenticityConfig.js.map
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Features, FirmwareRelease, ReleaseInfo } from '../types';
|
|
2
|
-
|
|
2
|
+
import { DeviceModelInternal } from '../types';
|
|
3
|
+
export declare const parseFirmware: (json: any, deviceModel: DeviceModelInternal) => void;
|
|
3
4
|
export interface GetInfoProps {
|
|
4
5
|
features: Features;
|
|
5
6
|
releases: FirmwareRelease[];
|
|
@@ -7,5 +8,5 @@ export interface GetInfoProps {
|
|
|
7
8
|
export declare const getInfo: ({ features, releases }: GetInfoProps) => ReleaseInfo | null;
|
|
8
9
|
export declare const getFirmwareStatus: (features: Features) => "valid" | "outdated" | "required" | "unknown" | "none";
|
|
9
10
|
export declare const getRelease: (features: Features) => ReleaseInfo | null;
|
|
10
|
-
export declare const getReleases: (
|
|
11
|
+
export declare const getReleases: (deviceModel: DeviceModelInternal) => FirmwareRelease[];
|
|
11
12
|
//# sourceMappingURL=firmwareInfo.d.ts.map
|
package/lib/data/firmwareInfo.js
CHANGED
|
@@ -3,13 +3,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getReleases = exports.getRelease = exports.getFirmwareStatus = exports.getInfo = exports.parseFirmware = void 0;
|
|
4
4
|
const utils_1 = require("@trezor/utils");
|
|
5
5
|
const firmwareUtils_1 = require("../utils/firmwareUtils");
|
|
6
|
-
const
|
|
7
|
-
releases
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
const types_1 = require("../types");
|
|
7
|
+
const releases = {
|
|
8
|
+
[types_1.DeviceModelInternal.T1B1]: [],
|
|
9
|
+
[types_1.DeviceModelInternal.T2T1]: [],
|
|
10
|
+
[types_1.DeviceModelInternal.T2B1]: [],
|
|
11
|
+
};
|
|
12
|
+
const parseFirmware = (json, deviceModel) => {
|
|
10
13
|
Object.keys(json).forEach(key => {
|
|
11
14
|
const release = json[key];
|
|
12
|
-
releases[
|
|
15
|
+
releases[deviceModel].push({
|
|
13
16
|
...release,
|
|
14
17
|
});
|
|
15
18
|
});
|
|
@@ -123,7 +126,10 @@ const getFirmwareStatus = (features) => {
|
|
|
123
126
|
if (features.major_version === 1 && features.bootloader_mode) {
|
|
124
127
|
return 'unknown';
|
|
125
128
|
}
|
|
126
|
-
const info = (0, exports.getInfo)({
|
|
129
|
+
const info = (0, exports.getInfo)({
|
|
130
|
+
features,
|
|
131
|
+
releases: releases[features === null || features === void 0 ? void 0 : features.internal_model],
|
|
132
|
+
});
|
|
127
133
|
if (!info)
|
|
128
134
|
return 'unknown';
|
|
129
135
|
if (info.isRequired)
|
|
@@ -133,8 +139,11 @@ const getFirmwareStatus = (features) => {
|
|
|
133
139
|
return 'valid';
|
|
134
140
|
};
|
|
135
141
|
exports.getFirmwareStatus = getFirmwareStatus;
|
|
136
|
-
const getRelease = (features) => (0, exports.getInfo)({
|
|
142
|
+
const getRelease = (features) => (0, exports.getInfo)({
|
|
143
|
+
features,
|
|
144
|
+
releases: releases[features === null || features === void 0 ? void 0 : features.internal_model],
|
|
145
|
+
});
|
|
137
146
|
exports.getRelease = getRelease;
|
|
138
|
-
const getReleases = (
|
|
147
|
+
const getReleases = (deviceModel) => releases[deviceModel];
|
|
139
148
|
exports.getReleases = getReleases;
|
|
140
149
|
//# sourceMappingURL=firmwareInfo.js.map
|
package/lib/data/models.d.ts
CHANGED
package/lib/data/models.js
CHANGED
|
@@ -11,10 +11,13 @@ exports.models = {
|
|
|
11
11
|
colors: {},
|
|
12
12
|
},
|
|
13
13
|
T2B1: {
|
|
14
|
-
name: 'Trezor
|
|
14
|
+
name: 'Trezor Safe 3',
|
|
15
15
|
colors: {
|
|
16
|
-
'
|
|
17
|
-
'
|
|
16
|
+
'1': 'Cosmic Black',
|
|
17
|
+
'2': 'Stellar Silver',
|
|
18
|
+
'3': 'Solar Gold',
|
|
19
|
+
'4': 'Galactic Rose',
|
|
20
|
+
'5': 'Bitcoin Orange',
|
|
18
21
|
},
|
|
19
22
|
},
|
|
20
23
|
};
|
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.1.
|
|
4
|
+
exports.VERSION = '9.1.5';
|
|
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
|
@@ -76,7 +76,7 @@ export declare class Device extends TypedEmitter<DeviceEvents> {
|
|
|
76
76
|
isInitialized(): boolean;
|
|
77
77
|
isSeedless(): boolean;
|
|
78
78
|
isInconsistent(): boolean;
|
|
79
|
-
getVersion():
|
|
79
|
+
getVersion(): never[] | [number, number, number];
|
|
80
80
|
atLeast(versions: string[] | string): boolean;
|
|
81
81
|
isUsed(): boolean;
|
|
82
82
|
isUsedHere(): boolean;
|
package/lib/device/Device.js
CHANGED
|
@@ -303,16 +303,6 @@ class Device extends typedEventEmitter_1.TypedEmitter {
|
|
|
303
303
|
var _a;
|
|
304
304
|
const capabilities = (0, deviceFeaturesUtils_1.parseCapabilities)(feat);
|
|
305
305
|
feat.capabilities = capabilities;
|
|
306
|
-
const version = [feat.major_version, feat.minor_version, feat.patch_version];
|
|
307
|
-
const capabilitiesDidChange = this.features &&
|
|
308
|
-
this.features.capabilities &&
|
|
309
|
-
this.features.capabilities.join('') !== capabilities.join('');
|
|
310
|
-
if (!utils_1.versionUtils.isEqual(version.join('.'), this.getVersion().join('.')) ||
|
|
311
|
-
capabilitiesDidChange) {
|
|
312
|
-
this.unavailableCapabilities = (0, deviceFeaturesUtils_1.getUnavailableCapabilities)(feat, (0, coinInfo_1.getAllNetworks)());
|
|
313
|
-
this.firmwareStatus = (0, firmwareInfo_1.getFirmwareStatus)(feat);
|
|
314
|
-
this.firmwareRelease = (0, firmwareInfo_1.getRelease)(feat);
|
|
315
|
-
}
|
|
316
306
|
if (this.features && this.features.session_id && !feat.session_id) {
|
|
317
307
|
feat.session_id = this.features.session_id;
|
|
318
308
|
}
|
|
@@ -325,6 +315,16 @@ class Device extends typedEventEmitter_1.TypedEmitter {
|
|
|
325
315
|
if (!feat.internal_model) {
|
|
326
316
|
feat.internal_model = (0, deviceFeaturesUtils_1.ensureInternalModelFeature)(feat.model);
|
|
327
317
|
}
|
|
318
|
+
const version = [
|
|
319
|
+
feat.major_version,
|
|
320
|
+
feat.minor_version,
|
|
321
|
+
feat.patch_version,
|
|
322
|
+
];
|
|
323
|
+
if (!utils_1.versionUtils.isEqual(version, this.getVersion())) {
|
|
324
|
+
this.unavailableCapabilities = (0, deviceFeaturesUtils_1.getUnavailableCapabilities)(feat, (0, coinInfo_1.getAllNetworks)());
|
|
325
|
+
this.firmwareStatus = (0, firmwareInfo_1.getFirmwareStatus)(feat);
|
|
326
|
+
this.firmwareRelease = (0, firmwareInfo_1.getRelease)(feat);
|
|
327
|
+
}
|
|
328
328
|
this.features = feat;
|
|
329
329
|
this.featuresNeedsReload = false;
|
|
330
330
|
if (this.getMode() !== 'bootloader') {
|
|
@@ -340,7 +340,7 @@ class Device extends typedEventEmitter_1.TypedEmitter {
|
|
|
340
340
|
if (feat === null || feat === void 0 ? void 0 : feat.unit_color) {
|
|
341
341
|
const deviceUnitColor = feat.unit_color.toString();
|
|
342
342
|
if (deviceUnitColor in deviceInfo.colors) {
|
|
343
|
-
this.color = deviceInfo.colors[deviceUnitColor]
|
|
343
|
+
this.color = deviceInfo.colors[deviceUnitColor];
|
|
344
344
|
}
|
|
345
345
|
}
|
|
346
346
|
}
|
|
@@ -27,6 +27,7 @@ export declare class DeviceList extends TypedEmitter<DeviceListEvents> {
|
|
|
27
27
|
penalizedDevices: {
|
|
28
28
|
[deviceID: string]: number;
|
|
29
29
|
};
|
|
30
|
+
transportFirstEventPromise: Promise<void> | undefined;
|
|
30
31
|
constructor();
|
|
31
32
|
init(): Promise<void>;
|
|
32
33
|
private resolveTransportEvent;
|
package/lib/device/DeviceList.js
CHANGED
|
@@ -126,7 +126,7 @@ class DeviceList extends typedEventEmitter_1.TypedEmitter {
|
|
|
126
126
|
await (0, promiseUtils_1.resolveAfter)(1000, null).promise;
|
|
127
127
|
if (device) {
|
|
128
128
|
if (!device.isUsed() && device.isUnacquired() && !device.isInconsistent()) {
|
|
129
|
-
_log.debug('Create device from unacquired', device);
|
|
129
|
+
_log.debug('Create device from unacquired', device.toMessageObject());
|
|
130
130
|
await this._createAndSaveDevice(descriptor);
|
|
131
131
|
}
|
|
132
132
|
}
|
|
@@ -149,7 +149,7 @@ class DeviceList extends typedEventEmitter_1.TypedEmitter {
|
|
|
149
149
|
d.forEach(descriptor => {
|
|
150
150
|
const path = descriptor.path.toString();
|
|
151
151
|
const device = this.devices[path];
|
|
152
|
-
_log.debug('Event', e, device);
|
|
152
|
+
_log.debug('Event', e, device.toMessageObject());
|
|
153
153
|
if (device) {
|
|
154
154
|
this.emit(e, device.toMessageObject());
|
|
155
155
|
}
|
|
@@ -210,7 +210,7 @@ class DeviceList extends typedEventEmitter_1.TypedEmitter {
|
|
|
210
210
|
}
|
|
211
211
|
}
|
|
212
212
|
async waitForTransportFirstEvent() {
|
|
213
|
-
|
|
213
|
+
this.transportFirstEventPromise = new Promise(resolve => {
|
|
214
214
|
const handler = () => {
|
|
215
215
|
this.removeListener(transport_1.TRANSPORT.START, handler);
|
|
216
216
|
this.removeListener(transport_1.TRANSPORT.ERROR, handler);
|
|
@@ -219,6 +219,7 @@ class DeviceList extends typedEventEmitter_1.TypedEmitter {
|
|
|
219
219
|
this.on(transport_1.TRANSPORT.START, handler);
|
|
220
220
|
this.on(transport_1.TRANSPORT.ERROR, handler);
|
|
221
221
|
});
|
|
222
|
+
await this.transportFirstEventPromise;
|
|
222
223
|
}
|
|
223
224
|
async _createAndSaveDevice(descriptor) {
|
|
224
225
|
_log.debug('Creating Device', descriptor);
|
package/lib/events/iframe.d.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { UI_EVENT } from './ui-request';
|
|
2
2
|
import type { ConnectSettings, SystemInfo } from '../types';
|
|
3
3
|
import type { MessageFactoryFn } from '../types/utils';
|
|
4
|
+
import { LogMessage } from '../utils/debug';
|
|
4
5
|
export declare const IFRAME: {
|
|
5
6
|
readonly BOOTSTRAP: "iframe-bootstrap";
|
|
6
7
|
readonly LOADED: "iframe-loaded";
|
|
7
8
|
readonly INIT: "iframe-init";
|
|
8
9
|
readonly ERROR: "iframe-error";
|
|
9
10
|
readonly CALL: "iframe-call";
|
|
11
|
+
readonly LOG: "iframe-log";
|
|
10
12
|
};
|
|
11
13
|
export interface IFrameError {
|
|
12
14
|
type: typeof IFRAME.ERROR;
|
|
@@ -29,10 +31,14 @@ export interface IFrameInit {
|
|
|
29
31
|
extension?: string;
|
|
30
32
|
};
|
|
31
33
|
}
|
|
34
|
+
export interface IFrameLogRequest {
|
|
35
|
+
type: typeof IFRAME.LOG;
|
|
36
|
+
payload: LogMessage;
|
|
37
|
+
}
|
|
32
38
|
export type IFrameEvent = {
|
|
33
39
|
type: typeof IFRAME.BOOTSTRAP;
|
|
34
40
|
payload?: typeof undefined;
|
|
35
|
-
} | IFrameLoaded | IFrameInit | IFrameError;
|
|
41
|
+
} | IFrameLoaded | IFrameInit | IFrameLogRequest | IFrameError;
|
|
36
42
|
export type IFrameEventMessage = IFrameEvent & {
|
|
37
43
|
event: typeof UI_EVENT;
|
|
38
44
|
};
|
package/lib/events/iframe.js
CHANGED
package/lib/factory.js
CHANGED
|
@@ -110,6 +110,7 @@ const factory = ({ eventEmitter, manifest, init, call, requestLogin, uiResponse,
|
|
|
110
110
|
checkFirmwareAuthenticity: params => call({ ...params, method: 'checkFirmwareAuthenticity' }),
|
|
111
111
|
applyFlags: params => call({ ...params, method: 'applyFlags' }),
|
|
112
112
|
applySettings: params => call({ ...params, method: 'applySettings' }),
|
|
113
|
+
authenticateDevice: params => call({ ...params, method: 'authenticateDevice' }),
|
|
113
114
|
authorizeCoinjoin: params => call({ ...params, method: 'authorizeCoinjoin' }),
|
|
114
115
|
cancelCoinjoinAuthorization: params => call({ ...params, method: 'cancelCoinjoinAuthorization' }),
|
|
115
116
|
showDeviceTutorial: params => call({ ...params, method: 'showDeviceTutorial' }),
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { DeviceAuthenticityConfig } from '../../data/deviceAuthenticityConfig';
|
|
2
|
+
import type { Params, Response } from '../params';
|
|
3
|
+
export interface AuthenticateDeviceParams {
|
|
4
|
+
config?: DeviceAuthenticityConfig;
|
|
5
|
+
allowDebugKeys?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export type AuthenticateDeviceResult = {
|
|
8
|
+
valid: true;
|
|
9
|
+
caPubKey: string;
|
|
10
|
+
debugKey?: boolean;
|
|
11
|
+
configExpired?: typeof undefined;
|
|
12
|
+
error?: typeof undefined;
|
|
13
|
+
} | {
|
|
14
|
+
valid: false;
|
|
15
|
+
caPubKey: string;
|
|
16
|
+
debugKey?: boolean;
|
|
17
|
+
configExpired?: boolean;
|
|
18
|
+
error: 'ROOT_PUBKEY_NOT_FOUND' | 'CA_PUBKEY_NOT_FOUND' | 'INVALID_DEVICE_MODEL' | 'INVALID_DEVICE_CERTIFICATE' | 'INVALID_DEVICE_SIGNATURE';
|
|
19
|
+
};
|
|
20
|
+
export declare function authenticateDevice(params: Params<AuthenticateDeviceParams>): Response<AuthenticateDeviceResult>;
|
|
21
|
+
//# sourceMappingURL=authenticateDevice.d.ts.map
|
package/lib/types/api/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { applyFlags } from './applyFlags';
|
|
2
2
|
import { applySettings } from './applySettings';
|
|
3
|
+
import { authenticateDevice } from './authenticateDevice';
|
|
3
4
|
import { authorizeCoinjoin } from './authorizeCoinjoin';
|
|
4
5
|
import { backupDevice } from './backupDevice';
|
|
5
6
|
import { binanceGetAddress } from './binanceGetAddress';
|
|
@@ -80,6 +81,7 @@ import { showDeviceTutorial } from './showDeviceTutorial';
|
|
|
80
81
|
export interface TrezorConnect {
|
|
81
82
|
applyFlags: typeof applyFlags;
|
|
82
83
|
applySettings: typeof applySettings;
|
|
84
|
+
authenticateDevice: typeof authenticateDevice;
|
|
83
85
|
authorizeCoinjoin: typeof authorizeCoinjoin;
|
|
84
86
|
cancelCoinjoinAuthorization: typeof cancelCoinjoinAuthorization;
|
|
85
87
|
showDeviceTutorial: typeof showDeviceTutorial;
|
package/lib/types/coinInfo.d.ts
CHANGED
package/lib/types/firmware.d.ts
CHANGED
package/lib/types/index.d.ts
CHANGED
|
@@ -16,5 +16,6 @@ export * from './api/stellar';
|
|
|
16
16
|
export * from './api/tezos';
|
|
17
17
|
export type { ComposeOutput, PrecomposedTransaction } from './api/composeTransaction';
|
|
18
18
|
export type { RecoveryDevice } from './api/recoveryDevice';
|
|
19
|
+
export type { AuthenticateDeviceResult } from './api/authenticateDevice';
|
|
19
20
|
export type { TokenInfo, TokenTransfer, InternalTransfer, FiatRates, Target as TransactionTarget, AccountBalanceHistory as BlockchainAccountBalanceHistory, } from '@trezor/blockchain-link';
|
|
20
21
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/utils/assetUtils.js
CHANGED
|
@@ -10,10 +10,12 @@ const getAssetByUrl = (url) => {
|
|
|
10
10
|
return require('@trezor/connect-common/files/coins-eth.json');
|
|
11
11
|
case './data/bridge/releases.json':
|
|
12
12
|
return require('@trezor/connect-common/files/bridge/releases.json');
|
|
13
|
-
case './data/firmware/
|
|
14
|
-
return require('@trezor/connect-common/files/firmware/
|
|
15
|
-
case './data/firmware/
|
|
16
|
-
return require('@trezor/connect-common/files/firmware/
|
|
13
|
+
case './data/firmware/t1b1/releases.json':
|
|
14
|
+
return require('@trezor/connect-common/files/firmware/t1b1/releases.json');
|
|
15
|
+
case './data/firmware/t2t1/releases.json':
|
|
16
|
+
return require('@trezor/connect-common/files/firmware/t2t1/releases.json');
|
|
17
|
+
case './data/firmware/t2b1/releases.json':
|
|
18
|
+
return require('@trezor/connect-common/files/firmware/t2b1/releases.json');
|
|
17
19
|
case './data/messages/messages.json':
|
|
18
20
|
return require('@trezor/protobuf/messages.json');
|
|
19
21
|
default:
|
package/lib/utils/debug.d.ts
CHANGED
|
@@ -1,22 +1,28 @@
|
|
|
1
|
-
type LogMessage = {
|
|
1
|
+
export type LogMessage = {
|
|
2
2
|
level: string;
|
|
3
3
|
prefix: string;
|
|
4
4
|
message: any[];
|
|
5
5
|
timestamp: number;
|
|
6
6
|
};
|
|
7
|
+
export type LogWriter = {
|
|
8
|
+
add: (message: LogMessage) => void;
|
|
9
|
+
};
|
|
7
10
|
declare class Log {
|
|
8
11
|
prefix: string;
|
|
9
12
|
enabled: boolean;
|
|
10
13
|
css: string;
|
|
11
14
|
messages: LogMessage[];
|
|
12
|
-
|
|
15
|
+
logWriter: LogWriter | undefined;
|
|
16
|
+
constructor(prefix: string, enabled: boolean, logWriter?: LogWriter);
|
|
13
17
|
addMessage(level: string, prefix: string, ...args: any[]): void;
|
|
18
|
+
setWriter(logWriter: any): void;
|
|
14
19
|
log(...args: any[]): void;
|
|
15
20
|
error(...args: any[]): void;
|
|
16
21
|
warn(...args: any[]): void;
|
|
17
22
|
debug(...args: any[]): void;
|
|
18
23
|
}
|
|
19
|
-
export declare const initLog: (prefix: string, enabled?: boolean) => Log;
|
|
24
|
+
export declare const initLog: (prefix: string, enabled?: boolean, logWriter?: LogWriter) => Log;
|
|
25
|
+
export declare const setLogWriter: (logWriterFactory: () => LogWriter | undefined) => void;
|
|
20
26
|
export declare const enableLog: (enabled?: boolean) => void;
|
|
21
27
|
export declare const enableLogByPrefix: (prefix: string, enabled: boolean) => void;
|
|
22
28
|
export declare const getLog: () => LogMessage[];
|
package/lib/utils/debug.js
CHANGED
|
@@ -1,51 +1,73 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getLog = exports.enableLogByPrefix = exports.enableLog = exports.initLog = void 0;
|
|
3
|
+
exports.getLog = exports.enableLogByPrefix = exports.enableLog = exports.setLogWriter = exports.initLog = void 0;
|
|
4
|
+
const green = '#bada55';
|
|
5
|
+
const blue = '#20abd8';
|
|
6
|
+
const orange = '#f4a744';
|
|
7
|
+
const yellow = '#fbd948';
|
|
4
8
|
const colors = {
|
|
5
|
-
'@trezor/connect':
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
DeviceList:
|
|
10
|
-
Device:
|
|
11
|
-
DeviceCommands:
|
|
12
|
-
'@trezor/transport':
|
|
9
|
+
'@trezor/connect': `color: ${blue}; background: #000;`,
|
|
10
|
+
'@trezor/connect-web': `color: ${blue}; background: #000;`,
|
|
11
|
+
IFrame: `color: ${orange}; background: #000;`,
|
|
12
|
+
Core: `color: ${orange}; background: #000;`,
|
|
13
|
+
DeviceList: `color: ${green}; background: #000;`,
|
|
14
|
+
Device: `color: ${green}; background: #000;`,
|
|
15
|
+
DeviceCommands: `color: ${green}; background: #000;`,
|
|
16
|
+
'@trezor/transport': `color: ${green}; background: #000;`,
|
|
17
|
+
InteractionTimeout: `color: ${green}; background: #000;`,
|
|
18
|
+
'@trezor/connect-popup': `color: ${yellow}; background: #000;`,
|
|
13
19
|
};
|
|
14
20
|
const MAX_ENTRIES = 100;
|
|
15
21
|
class Log {
|
|
16
|
-
constructor(prefix, enabled) {
|
|
22
|
+
constructor(prefix, enabled, logWriter) {
|
|
17
23
|
this.prefix = prefix;
|
|
18
24
|
this.enabled = enabled;
|
|
19
25
|
this.messages = [];
|
|
20
26
|
this.css = typeof window !== 'undefined' && colors[prefix] ? colors[prefix] : '';
|
|
27
|
+
if (logWriter) {
|
|
28
|
+
this.logWriter = logWriter;
|
|
29
|
+
}
|
|
21
30
|
}
|
|
22
31
|
addMessage(level, prefix, ...args) {
|
|
23
|
-
|
|
32
|
+
const message = {
|
|
24
33
|
level,
|
|
25
34
|
prefix,
|
|
35
|
+
css: this.css,
|
|
26
36
|
message: args,
|
|
27
37
|
timestamp: Date.now(),
|
|
28
|
-
}
|
|
38
|
+
};
|
|
39
|
+
this.messages.push(message);
|
|
40
|
+
if (this.logWriter) {
|
|
41
|
+
try {
|
|
42
|
+
this.logWriter.add(message);
|
|
43
|
+
}
|
|
44
|
+
catch (err) {
|
|
45
|
+
console.error('There was an error adding log message', err, message);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
29
48
|
if (this.messages.length > MAX_ENTRIES) {
|
|
30
49
|
this.messages.shift();
|
|
31
50
|
}
|
|
32
51
|
}
|
|
52
|
+
setWriter(logWriter) {
|
|
53
|
+
this.logWriter = logWriter;
|
|
54
|
+
}
|
|
33
55
|
log(...args) {
|
|
34
56
|
this.addMessage('log', this.prefix, ...args);
|
|
35
57
|
if (this.enabled) {
|
|
36
|
-
console.log(this.prefix, ...args);
|
|
58
|
+
console.log(`%c${this.prefix}`, this.css, ...args);
|
|
37
59
|
}
|
|
38
60
|
}
|
|
39
61
|
error(...args) {
|
|
40
62
|
this.addMessage('error', this.prefix, ...args);
|
|
41
63
|
if (this.enabled) {
|
|
42
|
-
console.error(this.prefix, ...args);
|
|
64
|
+
console.error(`%c${this.prefix}`, this.css, ...args);
|
|
43
65
|
}
|
|
44
66
|
}
|
|
45
67
|
warn(...args) {
|
|
46
68
|
this.addMessage('warn', this.prefix, ...args);
|
|
47
69
|
if (this.enabled) {
|
|
48
|
-
console.warn(this.prefix, ...args);
|
|
70
|
+
console.warn(`%c${this.prefix}`, this.css, ...args);
|
|
49
71
|
}
|
|
50
72
|
}
|
|
51
73
|
debug(...args) {
|
|
@@ -61,12 +83,23 @@ class Log {
|
|
|
61
83
|
}
|
|
62
84
|
}
|
|
63
85
|
const _logs = {};
|
|
64
|
-
|
|
65
|
-
|
|
86
|
+
let writer;
|
|
87
|
+
const initLog = (prefix, enabled, logWriter) => {
|
|
88
|
+
const instanceWriter = logWriter || writer;
|
|
89
|
+
const instance = new Log(prefix, !!enabled, instanceWriter);
|
|
66
90
|
_logs[prefix] = instance;
|
|
67
91
|
return instance;
|
|
68
92
|
};
|
|
69
93
|
exports.initLog = initLog;
|
|
94
|
+
const setLogWriter = (logWriterFactory) => {
|
|
95
|
+
Object.keys(_logs).forEach(key => {
|
|
96
|
+
writer = logWriterFactory();
|
|
97
|
+
if (writer) {
|
|
98
|
+
_logs[key].setWriter(writer);
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
};
|
|
102
|
+
exports.setLogWriter = setLogWriter;
|
|
70
103
|
const enableLog = (enabled) => {
|
|
71
104
|
Object.keys(_logs).forEach(key => {
|
|
72
105
|
_logs[key].enabled = !!enabled;
|
|
@@ -43,7 +43,7 @@ const getUnavailableCapabilities = (features, coins) => {
|
|
|
43
43
|
if (!capabilities)
|
|
44
44
|
return list;
|
|
45
45
|
const fw = [features.major_version, features.minor_version, features.patch_version];
|
|
46
|
-
const key =
|
|
46
|
+
const key = features.internal_model;
|
|
47
47
|
const supported = coins.filter(info => {
|
|
48
48
|
if (!info.support || typeof info.support[key] !== 'string') {
|
|
49
49
|
list[info.shortcut.toLowerCase()] = 'no-support';
|
|
@@ -86,8 +86,8 @@ const getUnavailableCapabilities = (features, coins) => {
|
|
|
86
86
|
config_1.config.supportedFirmware.forEach(s => {
|
|
87
87
|
if (!s.capabilities)
|
|
88
88
|
return;
|
|
89
|
-
const min = s.min ? s.min[
|
|
90
|
-
const max = s.max ? s.max[
|
|
89
|
+
const min = s.min ? s.min[key] : null;
|
|
90
|
+
const max = s.max ? s.max[key] : null;
|
|
91
91
|
if (min && (min === '0' || utils_1.versionUtils.isNewer(min, fw.join('.')))) {
|
|
92
92
|
const value = min === '0' ? 'no-support' : 'update-required';
|
|
93
93
|
s.capabilities.forEach(m => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trezor/connect",
|
|
3
|
-
"version": "9.1.
|
|
3
|
+
"version": "9.1.5",
|
|
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,15 +49,15 @@
|
|
|
49
49
|
"prepublish": "yarn tsx ../../scripts/prepublish.js"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@trezor/blockchain-link": "2.1.
|
|
53
|
-
"@trezor/blockchain-link-types": "1.0.
|
|
54
|
-
"@trezor/connect-analytics": "1.0.
|
|
55
|
-
"@trezor/connect-common": "0.0.
|
|
56
|
-
"@trezor/protobuf": "1.0.
|
|
57
|
-
"@trezor/protocol": "1.0.
|
|
58
|
-
"@trezor/transport": "1.1.
|
|
59
|
-
"@trezor/utils": "9.0.
|
|
60
|
-
"@trezor/utxo-lib": "1.0.
|
|
52
|
+
"@trezor/blockchain-link": "2.1.18",
|
|
53
|
+
"@trezor/blockchain-link-types": "1.0.7",
|
|
54
|
+
"@trezor/connect-analytics": "1.0.8",
|
|
55
|
+
"@trezor/connect-common": "0.0.22",
|
|
56
|
+
"@trezor/protobuf": "1.0.2",
|
|
57
|
+
"@trezor/protocol": "1.0.2",
|
|
58
|
+
"@trezor/transport": "1.1.17",
|
|
59
|
+
"@trezor/utils": "9.0.14",
|
|
60
|
+
"@trezor/utxo-lib": "1.0.12",
|
|
61
61
|
"bignumber.js": "^9.1.1",
|
|
62
62
|
"blakejs": "^1.2.1",
|
|
63
63
|
"bs58": "^5.0.0",
|
|
@@ -84,5 +84,8 @@
|
|
|
84
84
|
"typescript": "4.9.5",
|
|
85
85
|
"webpack": "^5.87.0",
|
|
86
86
|
"ws": "7.5.9"
|
|
87
|
+
},
|
|
88
|
+
"peerDependencies": {
|
|
89
|
+
"tslib": "^2.6.2"
|
|
87
90
|
}
|
|
88
91
|
}
|