@trezor/connect 9.3.1-beta.2 → 9.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +90 -76
- package/README.md +1 -1
- package/lib/api/getAccountInfo.d.ts +2 -0
- package/lib/backend/Blockchain.js +0 -3
- package/lib/core/index.d.ts +14 -2
- package/lib/core/index.js +242 -208
- package/lib/data/DataManager.d.ts +5 -0
- package/lib/data/config.d.ts +5 -0
- package/lib/data/config.js +5 -0
- package/lib/data/downloadReleasesMetadata.d.ts +7 -0
- package/lib/data/downloadReleasesMetadata.js +15 -0
- package/lib/data/version.d.ts +1 -1
- package/lib/data/version.js +1 -1
- package/lib/device/Device.d.ts +4 -2
- package/lib/device/Device.js +31 -1
- package/lib/device/DeviceList.d.ts +1 -2
- package/lib/device/DeviceList.js +6 -5
- package/lib/device/calculateRevisionForDevice.d.ts +8 -0
- package/lib/device/calculateRevisionForDevice.js +21 -0
- package/lib/device/checkFirmwareRevision.d.ts +11 -0
- package/lib/device/checkFirmwareRevision.js +65 -0
- package/lib/types/device.d.ts +9 -0
- package/lib/types/firmware.d.ts +1 -0
- package/lib/utils/assets-browser.d.ts +1 -1
- package/lib/utils/assets-browser.js +3 -2
- package/lib/utils/assets.d.ts +3 -3
- package/lib/utils/assets.js +3 -3
- package/lib/utils/deviceFeaturesUtils.js +22 -6
- package/package.json +11 -11
package/lib/data/config.d.ts
CHANGED
package/lib/data/config.js
CHANGED
|
@@ -128,6 +128,11 @@ exports.config = {
|
|
|
128
128
|
download: 'https://www.microsoft.com/en-us/edge',
|
|
129
129
|
update: 'https://www.microsoft.com/en-us/edge',
|
|
130
130
|
},
|
|
131
|
+
opera: {
|
|
132
|
+
version: 95,
|
|
133
|
+
download: 'https://www.opera.com/download',
|
|
134
|
+
update: 'https://www.opera.com/download',
|
|
135
|
+
},
|
|
131
136
|
},
|
|
132
137
|
supportedFirmware: [
|
|
133
138
|
{
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { FirmwareRelease } from '../types';
|
|
2
|
+
type DownloadReleasesMetadataParams = {
|
|
3
|
+
internal_model: string;
|
|
4
|
+
};
|
|
5
|
+
export declare const downloadReleasesMetadata: ({ internal_model, }: DownloadReleasesMetadataParams) => Promise<FirmwareRelease[]>;
|
|
6
|
+
export {};
|
|
7
|
+
//# sourceMappingURL=downloadReleasesMetadata.d.ts.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.downloadReleasesMetadata = void 0;
|
|
4
|
+
const assets_1 = require("../utils/assets");
|
|
5
|
+
const firmwareUtils_1 = require("../utils/firmwareUtils");
|
|
6
|
+
const downloadReleasesMetadata = async ({ internal_model, }) => {
|
|
7
|
+
const url = `https://data.trezor.io/firmware/${internal_model.toLowerCase()}/releases.json`;
|
|
8
|
+
const response = (await (0, assets_1.httpRequest)(url, 'json', { signal: AbortSignal.timeout(10000) }, true));
|
|
9
|
+
if ((0, firmwareUtils_1.isValidReleases)(response)) {
|
|
10
|
+
return response;
|
|
11
|
+
}
|
|
12
|
+
return [];
|
|
13
|
+
};
|
|
14
|
+
exports.downloadReleasesMetadata = downloadReleasesMetadata;
|
|
15
|
+
//# sourceMappingURL=downloadReleasesMetadata.js.map
|
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.CONTENT_SCRIPT_VERSION = exports.DEFAULT_DOMAIN = exports.VERSION = void 0;
|
|
4
|
-
exports.VERSION = '9.
|
|
4
|
+
exports.VERSION = '9.4.0';
|
|
5
5
|
const versionN = exports.VERSION.split('.').map(s => parseInt(s, 10));
|
|
6
6
|
const isBeta = exports.VERSION.includes('beta');
|
|
7
7
|
exports.DEFAULT_DOMAIN = isBeta
|
package/lib/device/Device.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { DeviceCommands, PassphrasePromptResponse } from './DeviceCommands';
|
|
|
5
5
|
import { PROTO, NETWORK } from '../constants';
|
|
6
6
|
import { DEVICE, DeviceButtonRequestPayload } from '../events';
|
|
7
7
|
import { type Transport, type Descriptor } from '@trezor/transport';
|
|
8
|
-
import { Device as DeviceTyped, DeviceFirmwareStatus, Features, ReleaseInfo, UnavailableCapabilities, FirmwareType } from '../types';
|
|
8
|
+
import { Device as DeviceTyped, DeviceFirmwareStatus, Features, ReleaseInfo, UnavailableCapabilities, FirmwareType, VersionArray, KnownDevice } from '../types';
|
|
9
9
|
export type RunOptions = {
|
|
10
10
|
skipFinalReload?: boolean;
|
|
11
11
|
waiting?: boolean;
|
|
@@ -52,6 +52,7 @@ export declare class Device extends TypedEmitter<DeviceEvents> {
|
|
|
52
52
|
name: string;
|
|
53
53
|
color?: string;
|
|
54
54
|
availableTranslations: string[];
|
|
55
|
+
authenticityChecks: NonNullable<KnownDevice['authenticityChecks']>;
|
|
55
56
|
constructor(transport: Transport, descriptor: Descriptor);
|
|
56
57
|
static fromDescriptor(transport: Transport, originalDescriptor: Descriptor): Device;
|
|
57
58
|
static createUnacquired(transport: Transport, descriptor: Descriptor, unreadableError?: string): Device;
|
|
@@ -73,6 +74,7 @@ export declare class Device extends TypedEmitter<DeviceEvents> {
|
|
|
73
74
|
validateState(preauthorized?: boolean): Promise<string | undefined>;
|
|
74
75
|
initialize(useCardanoDerivation: boolean): Promise<void>;
|
|
75
76
|
getFeatures(): Promise<void>;
|
|
77
|
+
checkFirmwareRevision(): Promise<void>;
|
|
76
78
|
changeLanguage({ language, binary, }: {
|
|
77
79
|
language?: undefined;
|
|
78
80
|
binary: ArrayBuffer;
|
|
@@ -90,7 +92,7 @@ export declare class Device extends TypedEmitter<DeviceEvents> {
|
|
|
90
92
|
isInitialized(): boolean;
|
|
91
93
|
isSeedless(): boolean;
|
|
92
94
|
isInconsistent(): boolean;
|
|
93
|
-
getVersion():
|
|
95
|
+
getVersion(): VersionArray | [];
|
|
94
96
|
atLeast(versions: string[] | string): boolean;
|
|
95
97
|
isUsed(): boolean;
|
|
96
98
|
isUsedHere(): boolean;
|
package/lib/device/Device.js
CHANGED
|
@@ -15,6 +15,7 @@ const transport_1 = require("@trezor/transport");
|
|
|
15
15
|
const types_1 = require("../types");
|
|
16
16
|
const models_1 = require("../data/models");
|
|
17
17
|
const getLanguage_1 = require("../data/getLanguage");
|
|
18
|
+
const checkFirmwareRevision_1 = require("./checkFirmwareRevision");
|
|
18
19
|
const _log = (0, debug_1.initLog)('Device');
|
|
19
20
|
exports.GET_FEATURES_TIMEOUT = 3000;
|
|
20
21
|
exports.GET_FEATURES_TIMEOUT_REACT_NATIVE = 20000;
|
|
@@ -39,6 +40,9 @@ class Device extends utils_1.TypedEmitter {
|
|
|
39
40
|
this.networkTypeState = [];
|
|
40
41
|
this.name = 'Trezor';
|
|
41
42
|
this.availableTranslations = [];
|
|
43
|
+
this.authenticityChecks = {
|
|
44
|
+
firmwareRevision: null,
|
|
45
|
+
};
|
|
42
46
|
if (transport.name === 'BridgeTransport') {
|
|
43
47
|
this.protocol = protocol_1.bridge;
|
|
44
48
|
}
|
|
@@ -187,7 +191,8 @@ class Device extends utils_1.TypedEmitter {
|
|
|
187
191
|
}
|
|
188
192
|
}
|
|
189
193
|
catch (error) {
|
|
190
|
-
if (!this.inconsistent &&
|
|
194
|
+
if (!this.inconsistent &&
|
|
195
|
+
(error.message === 'GetFeatures timeout' || error.message === 'Unknown message')) {
|
|
191
196
|
this.inconsistent = true;
|
|
192
197
|
return this._runInner(() => Promise.resolve({}), options);
|
|
193
198
|
}
|
|
@@ -304,6 +309,11 @@ class Device extends utils_1.TypedEmitter {
|
|
|
304
309
|
async getFeatures() {
|
|
305
310
|
const { message } = await this.getCommands().typedCall('GetFeatures', 'Features', {});
|
|
306
311
|
this._updateFeatures(message);
|
|
312
|
+
if (this.authenticityChecks.firmwareRevision === null ||
|
|
313
|
+
(this.authenticityChecks.firmwareRevision.success === false &&
|
|
314
|
+
this.authenticityChecks.firmwareRevision.error === 'cannot-perform-check-offline')) {
|
|
315
|
+
await this.checkFirmwareRevision();
|
|
316
|
+
}
|
|
307
317
|
if (!this.features.language_version_matches &&
|
|
308
318
|
this.features.language &&
|
|
309
319
|
this.atLeast('2.7.0')) {
|
|
@@ -316,6 +326,25 @@ class Device extends utils_1.TypedEmitter {
|
|
|
316
326
|
}
|
|
317
327
|
}
|
|
318
328
|
}
|
|
329
|
+
async checkFirmwareRevision() {
|
|
330
|
+
const firmwareVersion = this.getVersion();
|
|
331
|
+
if (firmwareVersion.length === 0 || !this.features) {
|
|
332
|
+
return;
|
|
333
|
+
}
|
|
334
|
+
if (this.features.bootloader_mode === true) {
|
|
335
|
+
return;
|
|
336
|
+
}
|
|
337
|
+
const releases = (0, firmwareInfo_1.getReleases)(this.features.internal_model);
|
|
338
|
+
const release = releases.find(r => firmwareVersion &&
|
|
339
|
+
utils_1.versionUtils.isVersionArray(firmwareVersion) &&
|
|
340
|
+
utils_1.versionUtils.isEqual(r.version, firmwareVersion));
|
|
341
|
+
this.authenticityChecks.firmwareRevision = await (0, checkFirmwareRevision_1.checkFirmwareRevision)({
|
|
342
|
+
internalModel: this.features.internal_model,
|
|
343
|
+
deviceRevision: this.features.revision,
|
|
344
|
+
firmwareVersion,
|
|
345
|
+
expectedRevision: release === null || release === void 0 ? void 0 : release.firmware_revision,
|
|
346
|
+
});
|
|
347
|
+
}
|
|
319
348
|
async changeLanguage({ language, binary, }) {
|
|
320
349
|
if (language === 'en-US') {
|
|
321
350
|
return this._uploadTranslationData(null);
|
|
@@ -550,6 +579,7 @@ class Device extends utils_1.TypedEmitter {
|
|
|
550
579
|
features: this.features,
|
|
551
580
|
unavailableCapabilities: this.unavailableCapabilities,
|
|
552
581
|
availableTranslations: this.availableTranslations,
|
|
582
|
+
authenticityChecks: this.authenticityChecks,
|
|
553
583
|
};
|
|
554
584
|
}
|
|
555
585
|
async legacyForceRelease() {
|
|
@@ -15,7 +15,6 @@ interface DeviceListEvents {
|
|
|
15
15
|
}
|
|
16
16
|
export interface IDeviceList {
|
|
17
17
|
isConnected(): this is DeviceList;
|
|
18
|
-
assertConnected(): asserts this is DeviceList;
|
|
19
18
|
pendingConnection(): Promise<void> | undefined;
|
|
20
19
|
setTransports: DeviceList['setTransports'];
|
|
21
20
|
addAuthPenalty: DeviceList['addAuthPenalty'];
|
|
@@ -25,6 +24,7 @@ export interface IDeviceList {
|
|
|
25
24
|
init: DeviceList['init'];
|
|
26
25
|
dispose: DeviceList['dispose'];
|
|
27
26
|
}
|
|
27
|
+
export declare const assertDeviceListConnected: (deviceList: IDeviceList) => asserts deviceList is DeviceList;
|
|
28
28
|
type ConstructorParams = Pick<ConnectSettings, 'priority' | 'debug'> & {
|
|
29
29
|
messages: Record<string, any>;
|
|
30
30
|
};
|
|
@@ -39,7 +39,6 @@ export declare class DeviceList extends TypedEmitter<DeviceListEvents> implement
|
|
|
39
39
|
private rejectPending?;
|
|
40
40
|
private transportCommonArgs;
|
|
41
41
|
isConnected(): this is DeviceList;
|
|
42
|
-
assertConnected(): asserts this is DeviceList;
|
|
43
42
|
pendingConnection(): Promise<void> | undefined;
|
|
44
43
|
constructor({ messages, priority, debug }: ConstructorParams);
|
|
45
44
|
private createTransport;
|
package/lib/device/DeviceList.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DeviceList = void 0;
|
|
3
|
+
exports.DeviceList = exports.assertDeviceListConnected = void 0;
|
|
4
4
|
const utils_1 = require("@trezor/utils");
|
|
5
5
|
const transport_1 = require("@trezor/transport");
|
|
6
6
|
const constants_1 = require("../constants");
|
|
@@ -30,14 +30,15 @@ const createAuthPenaltyManager = (priority) => {
|
|
|
30
30
|
const clear = () => Object.keys(penalizedDevices).forEach(key => delete penalizedDevices[key]);
|
|
31
31
|
return { get, add, remove, clear };
|
|
32
32
|
};
|
|
33
|
+
const assertDeviceListConnected = deviceList => {
|
|
34
|
+
if (!deviceList.isConnected())
|
|
35
|
+
throw constants_1.ERRORS.TypedError('Transport_Missing');
|
|
36
|
+
};
|
|
37
|
+
exports.assertDeviceListConnected = assertDeviceListConnected;
|
|
33
38
|
class DeviceList extends utils_1.TypedEmitter {
|
|
34
39
|
isConnected() {
|
|
35
40
|
return !!this.transport;
|
|
36
41
|
}
|
|
37
|
-
assertConnected() {
|
|
38
|
-
if (!this.transport)
|
|
39
|
-
throw constants_1.ERRORS.TypedError('Transport_Missing');
|
|
40
|
-
}
|
|
41
42
|
pendingConnection() {
|
|
42
43
|
return this.initPromise;
|
|
43
44
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { VersionArray } from '../exports';
|
|
2
|
+
type calculateRevisionForDeviceParams = {
|
|
3
|
+
commitRevision: string;
|
|
4
|
+
version: VersionArray;
|
|
5
|
+
};
|
|
6
|
+
export declare const calculateRevisionForDevice: ({ commitRevision, version, }: calculateRevisionForDeviceParams) => string;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=calculateRevisionForDevice.d.ts.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.calculateRevisionForDevice = void 0;
|
|
4
|
+
const versionUtils_1 = require("@trezor/utils/lib/versionUtils");
|
|
5
|
+
const calculateRevisionForDevice = ({ commitRevision, version, }) => {
|
|
6
|
+
if ((0, versionUtils_1.isNewer)(version, '2.4.0')) {
|
|
7
|
+
return commitRevision;
|
|
8
|
+
}
|
|
9
|
+
if ((0, versionUtils_1.isNewer)(version, '2.2.0')) {
|
|
10
|
+
return commitRevision.slice(0, 9);
|
|
11
|
+
}
|
|
12
|
+
if ((0, versionUtils_1.isNewer)(version, '2.1.8')) {
|
|
13
|
+
return commitRevision;
|
|
14
|
+
}
|
|
15
|
+
if ((0, versionUtils_1.isNewer)(version, '2.0.0')) {
|
|
16
|
+
return commitRevision.slice(0, 8);
|
|
17
|
+
}
|
|
18
|
+
return commitRevision;
|
|
19
|
+
};
|
|
20
|
+
exports.calculateRevisionForDevice = calculateRevisionForDevice;
|
|
21
|
+
//# sourceMappingURL=calculateRevisionForDevice.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { PROTO } from '../constants';
|
|
2
|
+
import { VersionArray } from '../types';
|
|
3
|
+
import { FirmwareRevisionCheckResult } from '../types/device';
|
|
4
|
+
export type CheckFirmwareRevisionParams = {
|
|
5
|
+
firmwareVersion: VersionArray;
|
|
6
|
+
internalModel: PROTO.DeviceModelInternal;
|
|
7
|
+
deviceRevision: string | null;
|
|
8
|
+
expectedRevision: string | undefined;
|
|
9
|
+
};
|
|
10
|
+
export declare const checkFirmwareRevision: ({ firmwareVersion, internalModel, deviceRevision, expectedRevision, }: CheckFirmwareRevisionParams) => Promise<FirmwareRevisionCheckResult>;
|
|
11
|
+
//# sourceMappingURL=checkFirmwareRevision.d.ts.map
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.checkFirmwareRevision = void 0;
|
|
4
|
+
const versionUtils_1 = require("@trezor/utils/lib/versionUtils");
|
|
5
|
+
const downloadReleasesMetadata_1 = require("../data/downloadReleasesMetadata");
|
|
6
|
+
const device_1 = require("../types/device");
|
|
7
|
+
const calculateRevisionForDevice_1 = require("./calculateRevisionForDevice");
|
|
8
|
+
const getOnlineReleaseMetadata = async ({ firmwareVersion, internalModel, }) => {
|
|
9
|
+
const onlineReleases = await (0, downloadReleasesMetadata_1.downloadReleasesMetadata)({ internal_model: internalModel });
|
|
10
|
+
return onlineReleases.find(onlineRelease => (0, versionUtils_1.isEqual)(onlineRelease.version, firmwareVersion));
|
|
11
|
+
};
|
|
12
|
+
const failFirmwareRevisionCheck = (error) => ({ success: false, error });
|
|
13
|
+
const doRevisionsMatch = ({ deviceRevision, expectedCommitRevision, firmwareVersion, }) => {
|
|
14
|
+
if (deviceRevision === null) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
const adjustedExpected = (0, calculateRevisionForDevice_1.calculateRevisionForDevice)({
|
|
18
|
+
commitRevision: expectedCommitRevision,
|
|
19
|
+
version: firmwareVersion,
|
|
20
|
+
});
|
|
21
|
+
return adjustedExpected === deviceRevision;
|
|
22
|
+
};
|
|
23
|
+
const checkFirmwareRevision = async ({ firmwareVersion, internalModel, deviceRevision, expectedRevision, }) => {
|
|
24
|
+
if (internalModel !== device_1.DeviceModelInternal.T2T1 && internalModel !== device_1.DeviceModelInternal.T1B1) {
|
|
25
|
+
return { success: true };
|
|
26
|
+
}
|
|
27
|
+
if (expectedRevision === undefined) {
|
|
28
|
+
if (firmwareVersion.length !== 3) {
|
|
29
|
+
return failFirmwareRevisionCheck('firmware-version-unknown');
|
|
30
|
+
}
|
|
31
|
+
try {
|
|
32
|
+
const onlineRelease = await getOnlineReleaseMetadata({
|
|
33
|
+
firmwareVersion,
|
|
34
|
+
internalModel,
|
|
35
|
+
});
|
|
36
|
+
if ((onlineRelease === null || onlineRelease === void 0 ? void 0 : onlineRelease.firmware_revision) === undefined) {
|
|
37
|
+
return failFirmwareRevisionCheck('firmware-version-unknown');
|
|
38
|
+
}
|
|
39
|
+
if (!doRevisionsMatch({
|
|
40
|
+
deviceRevision,
|
|
41
|
+
expectedCommitRevision: onlineRelease.firmware_revision,
|
|
42
|
+
firmwareVersion,
|
|
43
|
+
})) {
|
|
44
|
+
return failFirmwareRevisionCheck('revision-mismatch');
|
|
45
|
+
}
|
|
46
|
+
return { success: true };
|
|
47
|
+
}
|
|
48
|
+
catch (e) {
|
|
49
|
+
return {
|
|
50
|
+
success: false,
|
|
51
|
+
error: 'cannot-perform-check-offline',
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
if (!doRevisionsMatch({
|
|
56
|
+
deviceRevision,
|
|
57
|
+
expectedCommitRevision: expectedRevision,
|
|
58
|
+
firmwareVersion,
|
|
59
|
+
})) {
|
|
60
|
+
return failFirmwareRevisionCheck('revision-mismatch');
|
|
61
|
+
}
|
|
62
|
+
return { success: true };
|
|
63
|
+
};
|
|
64
|
+
exports.checkFirmwareRevision = checkFirmwareRevision;
|
|
65
|
+
//# sourceMappingURL=checkFirmwareRevision.js.map
|
package/lib/types/device.d.ts
CHANGED
|
@@ -11,6 +11,12 @@ export declare enum FirmwareType {
|
|
|
11
11
|
export type UnavailableCapabilities = {
|
|
12
12
|
[key: string]: UnavailableCapability;
|
|
13
13
|
};
|
|
14
|
+
export type FirmwareRevisionCheckResult = {
|
|
15
|
+
success: true;
|
|
16
|
+
} | {
|
|
17
|
+
success: false;
|
|
18
|
+
error: 'revision-mismatch' | 'firmware-version-unknown' | 'firmware-version-unknown' | 'cannot-perform-check-offline';
|
|
19
|
+
};
|
|
14
20
|
export type KnownDevice = {
|
|
15
21
|
type: 'acquired';
|
|
16
22
|
id: string | null;
|
|
@@ -28,6 +34,9 @@ export type KnownDevice = {
|
|
|
28
34
|
features: PROTO.Features;
|
|
29
35
|
unavailableCapabilities: UnavailableCapabilities;
|
|
30
36
|
availableTranslations: string[];
|
|
37
|
+
authenticityChecks?: {
|
|
38
|
+
firmwareRevision: FirmwareRevisionCheckResult | null;
|
|
39
|
+
};
|
|
31
40
|
};
|
|
32
41
|
export type UnknownDevice = {
|
|
33
42
|
type: 'unacquired';
|
package/lib/types/firmware.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ export type FirmwareRelease = {
|
|
|
10
10
|
fingerprint: string;
|
|
11
11
|
changelog: string | string[];
|
|
12
12
|
changelog_bitcoinonly?: string | string[];
|
|
13
|
+
firmware_revision?: string;
|
|
13
14
|
version: VersionArray;
|
|
14
15
|
min_firmware_version: VersionArray;
|
|
15
16
|
min_bootloader_version: VersionArray;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const httpRequest: (url: string, type?: 'text' | 'binary' | 'json') => Promise<any>;
|
|
1
|
+
export declare const httpRequest: (url: string, type?: 'text' | 'binary' | 'json', options?: RequestInit) => Promise<any>;
|
|
2
2
|
//# sourceMappingURL=assets-browser.d.ts.map
|
|
@@ -3,8 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.httpRequest = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const cross_fetch_1 = tslib_1.__importDefault(require("cross-fetch"));
|
|
6
|
-
const httpRequest = async (url, type = 'text') => {
|
|
7
|
-
const
|
|
6
|
+
const httpRequest = async (url, type = 'text', options) => {
|
|
7
|
+
const init = { ...options, credentials: 'same-origin' };
|
|
8
|
+
const response = await (0, cross_fetch_1.default)(url, init);
|
|
8
9
|
if (response.ok) {
|
|
9
10
|
if (type === 'json') {
|
|
10
11
|
const txt = await response.text();
|
package/lib/utils/assets.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare function httpRequest(url: string, type: 'text'): Promise<string>;
|
|
2
|
-
export declare function httpRequest(url: string, type: 'binary'): Promise<ArrayBuffer>;
|
|
3
|
-
export declare function httpRequest(url: string, type: 'json'): Promise<Record<string, any>>;
|
|
1
|
+
export declare function httpRequest(url: string, type: 'text', options?: RequestInit, skipLocalForceDownload?: boolean): Promise<string>;
|
|
2
|
+
export declare function httpRequest(url: string, type: 'binary', options?: RequestInit, skipLocalForceDownload?: boolean): Promise<ArrayBuffer>;
|
|
3
|
+
export declare function httpRequest(url: string, type: 'json', options?: RequestInit, skipLocalForceDownload?: boolean): Promise<Record<string, any>>;
|
|
4
4
|
//# sourceMappingURL=assets.d.ts.map
|
package/lib/utils/assets.js
CHANGED
|
@@ -9,10 +9,10 @@ const assetUtils_1 = require("./assetUtils");
|
|
|
9
9
|
if (global && typeof global.fetch !== 'function') {
|
|
10
10
|
global.fetch = cross_fetch_1.default;
|
|
11
11
|
}
|
|
12
|
-
function httpRequest(url, type) {
|
|
13
|
-
const asset = (0, assetUtils_1.getAssetByUrl)(url);
|
|
12
|
+
function httpRequest(url, type, options, skipLocalForceDownload) {
|
|
13
|
+
const asset = skipLocalForceDownload ? null : (0, assetUtils_1.getAssetByUrl)(url);
|
|
14
14
|
if (!asset) {
|
|
15
|
-
return /^https?/.test(url) ? (0, assets_browser_1.httpRequest)(url, type) : fs_1.promises.readFile(url);
|
|
15
|
+
return /^https?/.test(url) ? (0, assets_browser_1.httpRequest)(url, type, options) : fs_1.promises.readFile(url);
|
|
16
16
|
}
|
|
17
17
|
return asset;
|
|
18
18
|
}
|
|
@@ -44,10 +44,22 @@ const getUnavailableCapabilities = (features, coins) => {
|
|
|
44
44
|
return list;
|
|
45
45
|
const fw = [features.major_version, features.minor_version, features.patch_version].join('.');
|
|
46
46
|
const key = features.internal_model;
|
|
47
|
+
const duplicatedShortcuts = ['bnb'];
|
|
47
48
|
const supported = coins.filter(info => {
|
|
48
49
|
if (!info.support || info.support[key] === false) {
|
|
49
|
-
|
|
50
|
-
|
|
50
|
+
const shortcut = info.shortcut.toLowerCase();
|
|
51
|
+
if (!duplicatedShortcuts.includes(shortcut)) {
|
|
52
|
+
list[shortcut] = 'no-support';
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
const occurrences = coins.filter(coin => shortcut == coin.shortcut.toLowerCase());
|
|
57
|
+
const allUnsupported = occurrences.every(info => !info.support || info.support[key] === false);
|
|
58
|
+
if (allUnsupported) {
|
|
59
|
+
list[shortcut] = 'no-support';
|
|
60
|
+
}
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
51
63
|
}
|
|
52
64
|
return true;
|
|
53
65
|
});
|
|
@@ -64,14 +76,18 @@ const getUnavailableCapabilities = (features, coins) => {
|
|
|
64
76
|
if (info.type === 'nem') {
|
|
65
77
|
return !capabilities.includes('Capability_NEM');
|
|
66
78
|
}
|
|
67
|
-
if (info.shortcut === 'BNB')
|
|
79
|
+
if (info.shortcut === 'BNB' && info.type === 'misc') {
|
|
68
80
|
return !capabilities.includes('Capability_Binance');
|
|
69
|
-
|
|
81
|
+
}
|
|
82
|
+
if (info.shortcut === 'ADA' || info.shortcut === 'tADA') {
|
|
70
83
|
return !capabilities.includes('Capability_Cardano');
|
|
71
|
-
|
|
84
|
+
}
|
|
85
|
+
if (info.shortcut === 'XRP' || info.shortcut === 'tXRP') {
|
|
72
86
|
return !capabilities.includes('Capability_Ripple');
|
|
73
|
-
|
|
87
|
+
}
|
|
88
|
+
if (info.shortcut === 'SOL' || info.shortcut === 'DSOL') {
|
|
74
89
|
return !capabilities.includes('Capability_Solana');
|
|
90
|
+
}
|
|
75
91
|
return !capabilities.includes(`Capability_${info.name}`);
|
|
76
92
|
});
|
|
77
93
|
unavailable.forEach(info => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trezor/connect",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.4.0",
|
|
4
4
|
"author": "Trezor <info@trezor.io>",
|
|
5
5
|
"homepage": "https://github.com/trezor/trezor-suite/tree/develop/packages/connect",
|
|
6
6
|
"description": "High-level javascript interface for Trezor hardware wallet.",
|
|
@@ -71,16 +71,16 @@
|
|
|
71
71
|
"@ethereumjs/common": "^4.3.0",
|
|
72
72
|
"@ethereumjs/tx": "^5.3.0",
|
|
73
73
|
"@fivebinaries/coin-selection": "2.2.1",
|
|
74
|
-
"@trezor/blockchain-link": "2.
|
|
75
|
-
"@trezor/blockchain-link-types": "1.
|
|
76
|
-
"@trezor/connect-analytics": "1.
|
|
77
|
-
"@trezor/connect-common": "0.
|
|
78
|
-
"@trezor/protobuf": "1.
|
|
79
|
-
"@trezor/protocol": "1.
|
|
80
|
-
"@trezor/schema-utils": "1.
|
|
81
|
-
"@trezor/transport": "1.
|
|
82
|
-
"@trezor/utils": "9.
|
|
83
|
-
"@trezor/utxo-lib": "2.
|
|
74
|
+
"@trezor/blockchain-link": "2.3.0",
|
|
75
|
+
"@trezor/blockchain-link-types": "1.2.0",
|
|
76
|
+
"@trezor/connect-analytics": "1.2.0",
|
|
77
|
+
"@trezor/connect-common": "0.2.0",
|
|
78
|
+
"@trezor/protobuf": "1.2.0",
|
|
79
|
+
"@trezor/protocol": "1.2.0",
|
|
80
|
+
"@trezor/schema-utils": "1.2.0",
|
|
81
|
+
"@trezor/transport": "1.3.0",
|
|
82
|
+
"@trezor/utils": "9.2.0",
|
|
83
|
+
"@trezor/utxo-lib": "2.2.0",
|
|
84
84
|
"blakejs": "^1.2.1",
|
|
85
85
|
"bs58": "^5.0.0",
|
|
86
86
|
"bs58check": "^3.0.1",
|