@trezor/connect 9.4.2 → 9.4.3-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +90 -9
- package/README.md +1 -1
- package/lib/api/applyFlags.js +1 -1
- package/lib/api/applySettings.js +1 -1
- package/lib/api/authenticateDevice.js +1 -1
- package/lib/api/authorizeCoinjoin.js +1 -1
- package/lib/api/backupDevice.js +1 -1
- package/lib/api/binance/api/binanceGetAddress.js +2 -1
- package/lib/api/binance/api/binanceGetPublicKey.js +2 -1
- package/lib/api/binance/api/binanceSignTransaction.js +2 -1
- package/lib/api/binance/binanceSignTx.js +1 -1
- package/lib/api/bitcoin/Fees.js +2 -2
- package/lib/api/bitcoin/TransactionComposer.d.ts +3 -3
- package/lib/api/bitcoin/TransactionComposer.js +2 -2
- package/lib/api/bitcoin/refTx.js +1 -1
- package/lib/api/blockchainDisconnect.js +1 -1
- package/lib/api/blockchainEvmRpcCall.d.ts +16 -0
- package/lib/api/blockchainEvmRpcCall.js +45 -0
- package/lib/api/cancelCoinjoinAuthorization.js +1 -1
- package/lib/api/cardano/api/cardanoGetAddress.js +2 -1
- package/lib/api/cardano/api/cardanoGetNativeScriptHash.js +2 -1
- package/lib/api/cardano/api/cardanoGetPublicKey.js +2 -1
- package/lib/api/cardano/api/cardanoSignTransaction.js +2 -1
- package/lib/api/cardano/cardanoAddressParameters.js +1 -1
- package/lib/api/cardano/cardanoAuxiliaryData.js +1 -1
- package/lib/api/cardano/cardanoCertificate.js +1 -1
- package/lib/api/cardano/cardanoInputs.d.ts +8 -8
- package/lib/api/cardano/cardanoInputs.js +1 -1
- package/lib/api/cardano/cardanoOutputs.d.ts +22 -22
- package/lib/api/cardano/cardanoOutputs.js +1 -1
- package/lib/api/cardano/cardanoTokenBundle.d.ts +6 -6
- package/lib/api/cardano/cardanoTokenBundle.js +1 -1
- package/lib/api/changeLanguage.js +1 -1
- package/lib/api/changePin.js +1 -1
- package/lib/api/cipherKeyValue.js +1 -1
- package/lib/api/common/paramsValidator.js +1 -1
- package/lib/api/composeTransaction.d.ts +9 -3
- package/lib/api/composeTransaction.js +7 -4
- package/lib/api/eos/api/eosGetPublicKey.js +2 -1
- package/lib/api/eos/api/eosSignTransaction.js +2 -1
- package/lib/api/eos/eosSignTx.d.ts +3 -3
- package/lib/api/ethereum/api/ethereumGetAddress.js +2 -1
- package/lib/api/ethereum/api/ethereumGetPublicKey.js +2 -1
- package/lib/api/ethereum/api/ethereumSignMessage.d.ts +1 -1
- package/lib/api/ethereum/api/ethereumSignMessage.js +2 -1
- package/lib/api/ethereum/api/ethereumSignTransaction.d.ts +1 -1
- package/lib/api/ethereum/api/ethereumSignTransaction.js +13 -7
- package/lib/api/ethereum/api/ethereumSignTypedData.d.ts +58 -57
- package/lib/api/ethereum/api/ethereumSignTypedData.js +3 -2
- package/lib/api/ethereum/api/ethereumVerifyMessage.js +2 -1
- package/lib/api/ethereum/ethereumDefinitions.d.ts +21 -21
- package/lib/api/ethereum/ethereumDefinitions.js +6 -5
- package/lib/api/firmware/getBinary.d.ts +4 -5
- package/lib/api/firmware/getBinary.js +12 -13
- package/lib/api/firmware/getBinaryForFirmwareUpgrade.d.ts +3 -3
- package/lib/api/firmware/getBinaryForFirmwareUpgrade.js +2 -2
- package/lib/api/firmware/index.d.ts +1 -1
- package/lib/api/firmware/index.js +2 -1
- package/lib/api/firmware/x509certificate.js +3 -5
- package/lib/api/getAccountDescriptor.js +1 -1
- package/lib/api/getAddress.js +1 -1
- package/lib/api/getCoinInfo.d.ts +3 -0
- package/lib/api/getCoinInfo.js +1 -1
- package/lib/api/getFirmwareHash.js +1 -1
- package/lib/api/getOwnershipId.js +1 -1
- package/lib/api/getOwnershipProof.js +1 -1
- package/lib/api/getPublicKey.js +1 -1
- package/lib/api/index.d.ts +2 -1
- package/lib/api/index.js +5 -3
- package/lib/api/loadDevice.d.ts +14 -0
- package/lib/api/loadDevice.js +44 -0
- package/lib/api/nem/api/nemGetAddress.js +2 -1
- package/lib/api/nem/api/nemSignTransaction.js +2 -1
- package/lib/api/pushTransaction.js +1 -1
- package/lib/api/rebootToBootloader.js +1 -1
- package/lib/api/recoveryDevice.js +1 -1
- package/lib/api/requestLogin.js +1 -1
- package/lib/api/resetDevice.js +1 -2
- package/lib/api/ripple/api/rippleGetAddress.js +2 -1
- package/lib/api/ripple/api/rippleSignTransaction.js +2 -1
- package/lib/api/setBrightness.js +1 -1
- package/lib/api/setBusy.js +1 -1
- package/lib/api/signMessage.js +1 -1
- package/lib/api/solana/api/solanaGetAddress.js +2 -1
- package/lib/api/solana/api/solanaGetPublicKey.js +2 -1
- package/lib/api/solana/api/solanaSignTransaction.js +2 -1
- package/lib/api/stellar/api/stellarGetAddress.js +2 -1
- package/lib/api/stellar/api/stellarSignTransaction.js +2 -1
- package/lib/api/stellar/stellarSignTx.js +1 -1
- package/lib/api/tezos/api/tezosGetAddress.js +2 -1
- package/lib/api/tezos/api/tezosGetPublicKey.js +2 -1
- package/lib/api/tezos/api/tezosSignTransaction.js +2 -1
- package/lib/api/tezos/tezosSignTx.js +1 -1
- package/lib/api/unlockPath.js +1 -1
- package/lib/api/verifyMessage.js +1 -1
- package/lib/backend/Blockchain.d.ts +3 -0
- package/lib/backend/Blockchain.js +6 -6
- package/lib/constants/errors.d.ts +49 -38
- package/lib/constants/errors.js +10 -0
- package/lib/constants/firmware.d.ts +2 -0
- package/lib/constants/firmware.js +5 -0
- package/lib/constants/index.d.ts +2 -0
- package/lib/constants/index.js +4 -1
- package/lib/constants/nem.d.ts +3 -3
- package/lib/constants/utxo.d.ts +3 -0
- package/lib/constants/utxo.js +5 -0
- package/lib/core/AbstractMethod.d.ts +13 -5
- package/lib/core/AbstractMethod.js +50 -24
- package/lib/core/index.js +41 -30
- package/lib/core/onCallFirmwareUpdate.d.ts +2 -2
- package/lib/core/onCallFirmwareUpdate.js +6 -6
- package/lib/data/DataManager.d.ts +0 -181
- package/lib/data/DataManager.js +40 -6
- package/lib/data/analyticsInfo.js +4 -2
- package/lib/data/coinInfo.d.ts +14 -0
- package/lib/data/config.d.ts +20 -22
- package/lib/data/config.js +15 -40
- package/lib/data/connectSettings.js +10 -4
- package/lib/data/deviceAuthenticityConfig.js +20 -0
- package/lib/data/deviceAuthenticityConfigTypes.d.ts +32 -23
- package/lib/data/firmwareInfo.d.ts +1 -1
- package/lib/data/models.d.ts +9 -0
- package/lib/data/models.js +9 -0
- package/lib/data/version.d.ts +2 -1
- package/lib/data/version.js +3 -2
- package/lib/device/Device.d.ts +144 -36
- package/lib/device/Device.js +270 -113
- package/lib/device/DeviceCommands.js +4 -4
- package/lib/device/DeviceList.d.ts +13 -21
- package/lib/device/DeviceList.js +54 -168
- package/lib/device/checkFirmwareRevision.js +4 -4
- package/lib/device/prompts.js +3 -2
- package/lib/device/resolveDescriptorForTaproot.d.ts +1 -1
- package/lib/events/call.d.ts +5 -5
- package/lib/events/call.js +2 -2
- package/lib/events/core.d.ts +4 -3
- package/lib/events/device.d.ts +0 -6
- package/lib/events/device.js +0 -6
- package/lib/events/transport.d.ts +1 -1
- package/lib/factory.d.ts +6 -6
- package/lib/factory.js +132 -136
- package/lib/impl/dynamic.d.ts +33 -0
- package/lib/impl/dynamic.js +75 -0
- package/lib/index-browser.d.ts +3 -1
- package/lib/index-browser.js +0 -3
- package/lib/index.d.ts +3 -1
- package/lib/index.js +1 -13
- package/lib/types/api/applySettings.d.ts +13 -13
- package/lib/types/api/authenticateDevice.d.ts +33 -24
- package/lib/types/api/authorizeCoinjoin.d.ts +10 -10
- package/lib/types/api/binance/index.d.ts +143 -143
- package/lib/types/api/binance/index.js +1 -1
- package/lib/types/api/bitcoin/index.d.ts +11 -11
- package/lib/types/api/bitcoin/index.js +1 -1
- package/lib/types/api/blockchainEvmRpcCall.d.ts +4 -0
- package/lib/types/api/{checkFirmwareAuthenticity.js → blockchainEvmRpcCall.js} +1 -1
- package/lib/types/api/cancelCoinjoinAuthorization.d.ts +1 -1
- package/lib/types/api/cardano/index.d.ts +507 -507
- package/lib/types/api/changeLanguage.d.ts +6 -6
- package/lib/types/api/cipherKeyValue.d.ts +8 -8
- package/lib/types/api/cipherKeyValue.js +1 -1
- package/lib/types/api/composeTransaction.d.ts +13 -7
- package/lib/types/api/eos/index.d.ts +525 -525
- package/lib/types/api/eos/index.js +1 -1
- package/lib/types/api/ethereum/index.d.ts +100 -100
- package/lib/types/api/firmwareUpdate.d.ts +5 -5
- package/lib/types/api/getAccountDescriptor.d.ts +4 -4
- package/lib/types/api/getAddress.d.ts +32 -32
- package/lib/types/api/getOwnershipId.d.ts +24 -24
- package/lib/types/api/getOwnershipProof.d.ts +28 -28
- package/lib/types/api/getPublicKey.d.ts +24 -24
- package/lib/types/api/getPublicKey.js +1 -1
- package/lib/types/api/index.d.ts +4 -8
- package/lib/types/api/init.d.ts +4 -2
- package/lib/types/api/loadDevice.d.ts +4 -0
- package/lib/types/api/loadDevice.js +3 -0
- package/lib/types/api/nem/index.d.ts +612 -612
- package/lib/types/api/nem/index.js +1 -1
- package/lib/types/api/nemGetAddress.d.ts +6 -6
- package/lib/types/api/pushTransaction.d.ts +3 -3
- package/lib/types/api/recoveryDevice.d.ts +9 -9
- package/lib/types/api/requestLogin.d.ts +25 -25
- package/lib/types/api/ripple/index.d.ts +21 -21
- package/lib/types/api/ripple/index.js +1 -1
- package/lib/types/api/solana/index.d.ts +23 -23
- package/lib/types/api/solana/index.js +1 -1
- package/lib/types/api/stellar/index.d.ts +582 -582
- package/lib/types/api/stellar/index.js +1 -1
- package/lib/types/api/tezos/index.d.ts +120 -120
- package/lib/types/api/tezos/index.js +1 -1
- package/lib/types/api/unlockPath.d.ts +2 -2
- package/lib/types/coinInfo.d.ts +231 -224
- package/lib/types/device.d.ts +33 -14
- package/lib/types/device.js +3 -1
- package/lib/types/fees.d.ts +19 -19
- package/lib/types/firmware.d.ts +1 -1
- package/lib/types/params.d.ts +23 -19
- package/lib/types/settings.d.ts +17 -10
- package/lib/types/utils.d.ts +1 -0
- package/lib/types/utils.js +3 -0
- package/lib/utils/addressUtils.js +2 -2
- package/lib/utils/assetUtils.d.ts +1 -1
- package/lib/utils/assetUtils.js +6 -6
- package/lib/utils/assets.js +1 -1
- package/lib/utils/assets.native.js +1 -1
- package/lib/utils/deviceFeaturesUtils.js +1 -1
- package/lib/utils/proxy-event-emitter.d.ts +21 -0
- package/lib/utils/proxy-event-emitter.js +65 -0
- package/lib/utils/uiPromiseManager.d.ts +2 -1
- package/lib/utils/uiPromiseManager.js +3 -3
- package/package.json +12 -12
- package/lib/api/checkFirmwareAuthenticity.d.ts +0 -11
- package/lib/api/checkFirmwareAuthenticity.js +0 -56
- package/lib/types/api/checkFirmwareAuthenticity.d.ts +0 -11
|
@@ -3,21 +3,21 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.AbstractMethod = exports.DEFAULT_FIRMWARE_RANGE = void 0;
|
|
4
4
|
const connect_common_1 = require("@trezor/connect-common");
|
|
5
5
|
const utils_1 = require("@trezor/utils");
|
|
6
|
-
const DataManager_1 = require("../data/DataManager");
|
|
7
6
|
const constants_1 = require("../constants");
|
|
8
7
|
const events_1 = require("../events");
|
|
9
8
|
const urlUtils_1 = require("../utils/urlUtils");
|
|
10
|
-
const
|
|
9
|
+
const config_1 = require("../data/config");
|
|
11
10
|
exports.DEFAULT_FIRMWARE_RANGE = {
|
|
12
11
|
T1B1: { min: '1.0.0', max: '0' },
|
|
13
12
|
T2T1: { min: '2.0.0', max: '0' },
|
|
14
13
|
T2B1: { min: '2.6.1', max: '0' },
|
|
15
14
|
T3B1: { min: '2.8.1', max: '0' },
|
|
16
15
|
T3T1: { min: '2.7.1', max: '0' },
|
|
16
|
+
T3W1: { min: '2.7.1', max: '0' },
|
|
17
17
|
};
|
|
18
18
|
function validateStaticSessionId(input) {
|
|
19
19
|
if (typeof input !== 'string')
|
|
20
|
-
throw
|
|
20
|
+
throw constants_1.ERRORS.TypedError('Method_InvalidParameter', 'DeviceState: invalid staticSessionId: ' + input);
|
|
21
21
|
const [firstTestnetAddress, rest] = input.split('@');
|
|
22
22
|
const [deviceId, instance] = rest.split(':');
|
|
23
23
|
if (typeof firstTestnetAddress === 'string' &&
|
|
@@ -26,7 +26,26 @@ function validateStaticSessionId(input) {
|
|
|
26
26
|
Number.parseInt(instance) >= 0) {
|
|
27
27
|
return input;
|
|
28
28
|
}
|
|
29
|
-
throw
|
|
29
|
+
throw constants_1.ERRORS.TypedError('Method_InvalidParameter', 'DeviceState: invalid staticSessionId: ' + input);
|
|
30
|
+
}
|
|
31
|
+
function validateDeviceState(input) {
|
|
32
|
+
if (typeof input === 'string') {
|
|
33
|
+
return { staticSessionId: validateStaticSessionId(input) };
|
|
34
|
+
}
|
|
35
|
+
if (input && typeof input === 'object') {
|
|
36
|
+
const state = {};
|
|
37
|
+
if ('staticSessionId' in input) {
|
|
38
|
+
state.staticSessionId = validateStaticSessionId(input.staticSessionId);
|
|
39
|
+
}
|
|
40
|
+
if ('sessionId' in input && typeof input.sessionId === 'string') {
|
|
41
|
+
state.sessionId = input.sessionId;
|
|
42
|
+
}
|
|
43
|
+
if ('deriveCardano' in input && typeof input.deriveCardano === 'boolean') {
|
|
44
|
+
state.deriveCardano = input.deriveCardano;
|
|
45
|
+
}
|
|
46
|
+
return state;
|
|
47
|
+
}
|
|
48
|
+
return undefined;
|
|
30
49
|
}
|
|
31
50
|
class AbstractMethod {
|
|
32
51
|
get info() {
|
|
@@ -36,20 +55,14 @@ class AbstractMethod {
|
|
|
36
55
|
return undefined;
|
|
37
56
|
}
|
|
38
57
|
constructor(message) {
|
|
39
|
-
var _a, _b
|
|
58
|
+
var _a, _b;
|
|
59
|
+
this.requiredDeviceCapabilities = [];
|
|
40
60
|
const { payload } = message;
|
|
41
61
|
this.name = payload.method;
|
|
42
62
|
this.payload = payload;
|
|
43
63
|
this.responseID = message.id || 0;
|
|
44
64
|
this.devicePath = (_a = payload.device) === null || _a === void 0 ? void 0 : _a.path;
|
|
45
|
-
this.deviceState =
|
|
46
|
-
typeof ((_b = payload.device) === null || _b === void 0 ? void 0 : _b.state) === 'string'
|
|
47
|
-
? { staticSessionId: validateStaticSessionId(payload.device.state) }
|
|
48
|
-
: ((_d = (_c = payload.device) === null || _c === void 0 ? void 0 : _c.state) === null || _d === void 0 ? void 0 : _d.staticSessionId)
|
|
49
|
-
? {
|
|
50
|
-
staticSessionId: validateStaticSessionId(payload.device.state.staticSessionId),
|
|
51
|
-
}
|
|
52
|
-
: undefined;
|
|
65
|
+
this.deviceState = validateDeviceState((_b = payload.device) === null || _b === void 0 ? void 0 : _b.state);
|
|
53
66
|
this.hasExpectedDeviceState = payload.device
|
|
54
67
|
? Object.prototype.hasOwnProperty.call(payload.device, 'state')
|
|
55
68
|
: false;
|
|
@@ -88,20 +101,19 @@ class AbstractMethod {
|
|
|
88
101
|
}
|
|
89
102
|
setDevice(device) {
|
|
90
103
|
this.device = device;
|
|
91
|
-
this.devicePath = device.
|
|
104
|
+
this.devicePath = device.getUniquePath();
|
|
92
105
|
const originalFn = this.createUiPromise;
|
|
93
106
|
this.createUiPromise = (t, d) => originalFn(t, d || device);
|
|
94
107
|
}
|
|
95
|
-
getOriginPermissions() {
|
|
108
|
+
getOriginPermissions({ origin }) {
|
|
96
109
|
var _a;
|
|
97
|
-
const origin = DataManager_1.DataManager.getSettings('origin');
|
|
98
110
|
if (!origin) {
|
|
99
111
|
return [];
|
|
100
112
|
}
|
|
101
113
|
return ((_a = connect_common_1.storage.loadForOrigin(origin)) === null || _a === void 0 ? void 0 : _a.permissions) || [];
|
|
102
114
|
}
|
|
103
|
-
checkPermissions() {
|
|
104
|
-
const originPermissions = this.getOriginPermissions();
|
|
115
|
+
checkPermissions({ origin }) {
|
|
116
|
+
const originPermissions = this.getOriginPermissions({ origin });
|
|
105
117
|
let notPermitted = [...this.requiredPermissions];
|
|
106
118
|
if (originPermissions.length > 0) {
|
|
107
119
|
notPermitted = notPermitted.filter(np => {
|
|
@@ -111,8 +123,8 @@ class AbstractMethod {
|
|
|
111
123
|
}
|
|
112
124
|
this.requiredPermissions = notPermitted;
|
|
113
125
|
}
|
|
114
|
-
savePermissions(temporary = false) {
|
|
115
|
-
const originPermissions = this.getOriginPermissions();
|
|
126
|
+
savePermissions(temporary = false, { origin }) {
|
|
127
|
+
const originPermissions = this.getOriginPermissions({ origin });
|
|
116
128
|
let permissionsToSave = this.requiredPermissions.map(p => ({
|
|
117
129
|
type: p,
|
|
118
130
|
device: this.device.features.device_id || undefined,
|
|
@@ -130,7 +142,6 @@ class AbstractMethod {
|
|
|
130
142
|
return !granted;
|
|
131
143
|
});
|
|
132
144
|
}
|
|
133
|
-
const origin = DataManager_1.DataManager.getSettings('origin');
|
|
134
145
|
connect_common_1.storage.saveForOrigin(state => ({
|
|
135
146
|
...state,
|
|
136
147
|
permissions: [...(state.permissions || []), ...permissionsToSave],
|
|
@@ -167,14 +178,29 @@ class AbstractMethod {
|
|
|
167
178
|
return events_1.UI.FIRMWARE_NOT_COMPATIBLE;
|
|
168
179
|
}
|
|
169
180
|
}
|
|
170
|
-
isManagementRestricted() {
|
|
171
|
-
const { popup, origin } = DataManager_1.DataManager.getSettings();
|
|
181
|
+
isManagementRestricted({ popup, origin }) {
|
|
172
182
|
if (popup && this.requiredPermissions.includes('management')) {
|
|
173
183
|
const host = (0, urlUtils_1.getHost)(origin);
|
|
174
|
-
const allowed =
|
|
184
|
+
const allowed = config_1.config.management.find(item => item.origin === host || item.origin === origin);
|
|
175
185
|
return !allowed;
|
|
176
186
|
}
|
|
177
187
|
}
|
|
188
|
+
getMethodInfo() {
|
|
189
|
+
return {
|
|
190
|
+
useDevice: this.useDevice,
|
|
191
|
+
useDeviceState: this.useDeviceState,
|
|
192
|
+
name: this.name,
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
checkDeviceCapability() {
|
|
196
|
+
const deviceHasAllRequiredCapabilities = (this.requiredDeviceCapabilities || []).every(capability => this.device.features.capabilities.includes(capability));
|
|
197
|
+
if (!deviceHasAllRequiredCapabilities) {
|
|
198
|
+
if (this.device.firmwareType === 'bitcoin-only') {
|
|
199
|
+
throw constants_1.ERRORS.TypedError('Device_MissingCapabilityBtcOnly', `Trezor has Bitcoin-only firmware installed, which does not support this operation. Please install Universal firmware through Trezor Suite.`);
|
|
200
|
+
}
|
|
201
|
+
throw constants_1.ERRORS.TypedError('Device_MissingCapability', 'Device does not have capability to call this method. Make sure you have the latest firmware installed.');
|
|
202
|
+
}
|
|
203
|
+
}
|
|
178
204
|
dispose() { }
|
|
179
205
|
}
|
|
180
206
|
exports.AbstractMethod = AbstractMethod;
|
package/lib/core/index.js
CHANGED
|
@@ -5,7 +5,6 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const events_1 = tslib_1.__importDefault(require("events"));
|
|
6
6
|
const transport_1 = require("@trezor/transport");
|
|
7
7
|
const utils_1 = require("@trezor/utils");
|
|
8
|
-
const utils_2 = require("@trezor/utils");
|
|
9
8
|
const connect_common_1 = require("@trezor/connect-common");
|
|
10
9
|
const DataManager_1 = require("../data/DataManager");
|
|
11
10
|
const DeviceList_1 = require("../device/DeviceList");
|
|
@@ -39,7 +38,7 @@ const initDevice = async (context, devicePath) => {
|
|
|
39
38
|
const origin = DataManager_1.DataManager.getSettings('origin');
|
|
40
39
|
const useCoreInPopup = DataManager_1.DataManager.getSettings('useCoreInPopup');
|
|
41
40
|
const { preferredDevice } = connect_common_1.storage.load().origin[origin] || {};
|
|
42
|
-
const preferredDeviceInList = preferredDevice && deviceList.
|
|
41
|
+
const preferredDeviceInList = preferredDevice && deviceList.getDeviceByPath(preferredDevice.path);
|
|
43
42
|
if (preferredDevice && !preferredDeviceInList) {
|
|
44
43
|
connect_common_1.storage.save(store => {
|
|
45
44
|
store.origin[origin] = { ...store.origin[origin], preferredDevice: undefined };
|
|
@@ -47,16 +46,16 @@ const initDevice = async (context, devicePath) => {
|
|
|
47
46
|
});
|
|
48
47
|
}
|
|
49
48
|
if (devicePath) {
|
|
50
|
-
device = deviceList.
|
|
49
|
+
device = deviceList.getDeviceByPath(devicePath);
|
|
51
50
|
showDeviceSelection =
|
|
52
|
-
!device ||
|
|
51
|
+
!device || device.isUnreadable() || (device.isUnacquired() && !!isUsingPopup);
|
|
53
52
|
}
|
|
54
53
|
else {
|
|
55
|
-
const
|
|
56
|
-
if (
|
|
57
|
-
device =
|
|
54
|
+
const onlyDevice = deviceList.getOnlyDevice();
|
|
55
|
+
if (onlyDevice && (!isWebUsb || !isUsingPopup)) {
|
|
56
|
+
device = onlyDevice;
|
|
58
57
|
showDeviceSelection =
|
|
59
|
-
|
|
58
|
+
device.isUnreadable() || device.isUnacquired() || !!useCoreInPopup;
|
|
60
59
|
}
|
|
61
60
|
else {
|
|
62
61
|
showDeviceSelection = true;
|
|
@@ -66,18 +65,18 @@ const initDevice = async (context, devicePath) => {
|
|
|
66
65
|
uiPromises.create(events_2.UI.RECEIVE_DEVICE);
|
|
67
66
|
await waitForPopup(context);
|
|
68
67
|
(0, DeviceList_1.assertDeviceListConnected)(deviceList);
|
|
69
|
-
const
|
|
70
|
-
if (
|
|
71
|
-
|
|
72
|
-
|
|
68
|
+
const onlyDevice = deviceList.getOnlyDevice();
|
|
69
|
+
if (onlyDevice &&
|
|
70
|
+
!onlyDevice.isUnreadable() &&
|
|
71
|
+
!onlyDevice.isUnacquired() &&
|
|
73
72
|
!isWebUsb &&
|
|
74
73
|
!useCoreInPopup) {
|
|
75
|
-
device =
|
|
74
|
+
device = onlyDevice;
|
|
76
75
|
}
|
|
77
76
|
else {
|
|
78
77
|
sendCoreMessage((0, events_2.createUiMessage)(events_2.UI.SELECT_DEVICE, {
|
|
79
78
|
webusb: isWebUsb,
|
|
80
|
-
devices: deviceList.
|
|
79
|
+
devices: deviceList.getAllDevices().map(d => d.toMessageObject()),
|
|
81
80
|
}));
|
|
82
81
|
if (uiPromises.exists(events_2.UI.RECEIVE_DEVICE)) {
|
|
83
82
|
const { payload } = await uiPromises.get(events_2.UI.RECEIVE_DEVICE);
|
|
@@ -91,7 +90,7 @@ const initDevice = async (context, devicePath) => {
|
|
|
91
90
|
return store;
|
|
92
91
|
});
|
|
93
92
|
}
|
|
94
|
-
device = deviceList.
|
|
93
|
+
device = deviceList.getDeviceByPath(payload.device.path);
|
|
95
94
|
}
|
|
96
95
|
}
|
|
97
96
|
}
|
|
@@ -150,7 +149,7 @@ const inner = async (context, method, device) => {
|
|
|
150
149
|
}
|
|
151
150
|
const unexpectedMode = device.hasUnexpectedMode(method.allowDeviceMode, method.requireDeviceMode);
|
|
152
151
|
if (unexpectedMode) {
|
|
153
|
-
device.
|
|
152
|
+
device.releaseTransportSession();
|
|
154
153
|
if (isUsingPopup) {
|
|
155
154
|
await waitForPopup(context);
|
|
156
155
|
sendCoreMessage((0, events_2.createUiMessage)(unexpectedMode, device.toMessageObject()));
|
|
@@ -159,7 +158,8 @@ const inner = async (context, method, device) => {
|
|
|
159
158
|
}
|
|
160
159
|
return Promise.reject(constants_1.ERRORS.TypedError('Device_ModeException', unexpectedMode));
|
|
161
160
|
}
|
|
162
|
-
method.
|
|
161
|
+
method.checkDeviceCapability();
|
|
162
|
+
method.checkPermissions({ origin: DataManager_1.DataManager.getSettings('origin') });
|
|
163
163
|
if (!trustedHost && method.requiredPermissions.length > 0) {
|
|
164
164
|
await waitForPopup(context);
|
|
165
165
|
const uiPromise = uiPromises.create(events_2.UI.RECEIVE_PERMISSION, device);
|
|
@@ -169,7 +169,7 @@ const inner = async (context, method, device) => {
|
|
|
169
169
|
}));
|
|
170
170
|
const { granted, remember } = await uiPromise.promise.then(({ payload }) => payload);
|
|
171
171
|
if (granted) {
|
|
172
|
-
method.savePermissions(!remember);
|
|
172
|
+
method.savePermissions(!remember, { origin: DataManager_1.DataManager.getSettings('origin') });
|
|
173
173
|
}
|
|
174
174
|
else {
|
|
175
175
|
return Promise.reject(constants_1.ERRORS.TypedError('Method_PermissionsNotGranted'));
|
|
@@ -288,6 +288,11 @@ const onCall = async (context, message) => {
|
|
|
288
288
|
sendCoreMessage((0, events_2.createResponseMessage)(responseID, false, { error }));
|
|
289
289
|
return Promise.resolve();
|
|
290
290
|
}
|
|
291
|
+
if (method.payload.__info) {
|
|
292
|
+
const response = method.getMethodInfo();
|
|
293
|
+
sendCoreMessage((0, events_2.createResponseMessage)(method.responseID, true, response));
|
|
294
|
+
return Promise.resolve();
|
|
295
|
+
}
|
|
291
296
|
if (!method.useDevice) {
|
|
292
297
|
try {
|
|
293
298
|
if (method.useUi) {
|
|
@@ -304,7 +309,7 @@ const onCall = async (context, message) => {
|
|
|
304
309
|
}
|
|
305
310
|
return Promise.resolve();
|
|
306
311
|
}
|
|
307
|
-
if (method.isManagementRestricted()) {
|
|
312
|
+
if (method.isManagementRestricted({ origin: DataManager_1.DataManager.getSettings('origin') })) {
|
|
308
313
|
sendCoreMessage((0, events_2.createPopupMessage)(events_2.POPUP.CANCEL_POPUP_REQUEST));
|
|
309
314
|
sendCoreMessage((0, events_2.createResponseMessage)(responseID, false, {
|
|
310
315
|
error: constants_1.ERRORS.TypedError('Method_NotAllowed'),
|
|
@@ -314,7 +319,7 @@ const onCall = async (context, message) => {
|
|
|
314
319
|
return await onCallDevice(context, message, method);
|
|
315
320
|
};
|
|
316
321
|
const onCallDevice = async (context, message, method) => {
|
|
317
|
-
var _a;
|
|
322
|
+
var _a, _b;
|
|
318
323
|
const { deviceList, callMethods, getOverridePromise, setOverridePromise, sendCoreMessage } = context;
|
|
319
324
|
const responseID = message.id;
|
|
320
325
|
const { origin, env, useCoreInPopup } = DataManager_1.DataManager.getSettings();
|
|
@@ -416,6 +421,11 @@ const onCallDevice = async (context, message, method) => {
|
|
|
416
421
|
if (getOverridePromise()) {
|
|
417
422
|
await getOverridePromise();
|
|
418
423
|
}
|
|
424
|
+
if (method.keepSession &&
|
|
425
|
+
method.deviceState &&
|
|
426
|
+
method.deviceState.sessionId !== ((_b = device.getState()) === null || _b === void 0 ? void 0 : _b.sessionId)) {
|
|
427
|
+
sendCoreMessage((0, events_2.createDeviceMessage)(events_2.DEVICE.CHANGED, device.toMessageObject()));
|
|
428
|
+
}
|
|
419
429
|
const response = messageResponse;
|
|
420
430
|
if (response) {
|
|
421
431
|
if (method.name === 'rebootToBootloader' && response.success) {
|
|
@@ -423,7 +433,7 @@ const onCallDevice = async (context, message, method) => {
|
|
|
423
433
|
try {
|
|
424
434
|
await device.run(() => Promise.resolve(), { skipFinalReload: true });
|
|
425
435
|
}
|
|
426
|
-
catch
|
|
436
|
+
catch {
|
|
427
437
|
}
|
|
428
438
|
}
|
|
429
439
|
await device.cleanup();
|
|
@@ -523,9 +533,9 @@ const onPopupClosed = (context, customErrorMessage) => {
|
|
|
523
533
|
const error = customErrorMessage
|
|
524
534
|
? constants_1.ERRORS.TypedError('Method_Cancel', customErrorMessage)
|
|
525
535
|
: constants_1.ERRORS.TypedError('Method_Interrupted');
|
|
526
|
-
if (deviceList.isConnected() && deviceList.
|
|
527
|
-
deviceList.
|
|
528
|
-
d.
|
|
536
|
+
if (deviceList.isConnected() && deviceList.getDeviceCount() > 0) {
|
|
537
|
+
deviceList.getAllDevices().forEach(d => {
|
|
538
|
+
d.releaseTransportSession();
|
|
529
539
|
if (d.isUsedHere()) {
|
|
530
540
|
setOverridePromise(d.interruptionFromUser(error));
|
|
531
541
|
}
|
|
@@ -551,18 +561,18 @@ const handleDeviceSelectionChanges = (context, interruptDevice) => {
|
|
|
551
561
|
const { uiPromises, deviceList, sendCoreMessage } = context;
|
|
552
562
|
const promiseExists = uiPromises.exists(events_2.UI.RECEIVE_DEVICE);
|
|
553
563
|
if (promiseExists && deviceList.isConnected()) {
|
|
554
|
-
const
|
|
564
|
+
const onlyDevice = deviceList.getOnlyDevice();
|
|
555
565
|
const isWebUsb = deviceList.transportType() === 'WebUsbTransport';
|
|
556
|
-
if (
|
|
566
|
+
if (onlyDevice && !isWebUsb) {
|
|
557
567
|
uiPromises.resolve({
|
|
558
568
|
type: events_2.UI.RECEIVE_DEVICE,
|
|
559
|
-
payload: { device:
|
|
569
|
+
payload: { device: onlyDevice.toMessageObject() },
|
|
560
570
|
});
|
|
561
571
|
}
|
|
562
572
|
else {
|
|
563
573
|
sendCoreMessage((0, events_2.createUiMessage)(events_2.UI.SELECT_DEVICE, {
|
|
564
574
|
webusb: isWebUsb,
|
|
565
|
-
devices:
|
|
575
|
+
devices: deviceList.getAllDevices().map(d => d.toMessageObject()),
|
|
566
576
|
}));
|
|
567
577
|
}
|
|
568
578
|
}
|
|
@@ -604,7 +614,7 @@ class Core extends events_1.default {
|
|
|
604
614
|
this.abortController = new AbortController();
|
|
605
615
|
this.callMethods = [];
|
|
606
616
|
this.popupPromise = (0, popupPromiseManager_1.createPopupPromiseManager)();
|
|
607
|
-
this.methodSynchronize = (0,
|
|
617
|
+
this.methodSynchronize = (0, utils_1.getSynchronize)();
|
|
608
618
|
this.uiPromises = (0, uiPromiseManager_1.createUiPromiseManager)(() => startInteractionTimeout(this.getCoreContext()));
|
|
609
619
|
this.waitForFirstMethod = (0, utils_1.createDeferred)();
|
|
610
620
|
}
|
|
@@ -741,7 +751,7 @@ class Core extends events_1.default {
|
|
|
741
751
|
const onCoreEventThrottled = (message) => throttlePromise.promise.then(() => onCoreEvent(message));
|
|
742
752
|
try {
|
|
743
753
|
await DataManager_1.DataManager.load(settings);
|
|
744
|
-
const { debug, priority, _sessionsBackgroundUrl } = DataManager_1.DataManager.getSettings();
|
|
754
|
+
const { debug, priority, _sessionsBackgroundUrl, manifest } = DataManager_1.DataManager.getSettings();
|
|
745
755
|
const messages = DataManager_1.DataManager.getProtobufMessages();
|
|
746
756
|
(0, debug_1.enableLog)(debug);
|
|
747
757
|
this._interactionTimeout = new interactionTimeout_1.InteractionTimeout(settings.popup ? settings.interactionTimeout : 0);
|
|
@@ -750,6 +760,7 @@ class Core extends events_1.default {
|
|
|
750
760
|
messages,
|
|
751
761
|
priority,
|
|
752
762
|
_sessionsBackgroundUrl,
|
|
763
|
+
manifest,
|
|
753
764
|
});
|
|
754
765
|
initDeviceList(this.getCoreContext());
|
|
755
766
|
this.on(events_2.CORE_EVENT, onCoreEventThrottled);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DeviceList } from '../device/DeviceList';
|
|
2
2
|
import { CoreEventMessage } from '../events';
|
|
3
|
-
import { CommonParams } from '../types';
|
|
3
|
+
import { CommonParams, DeviceUniquePath } from '../types';
|
|
4
4
|
import type { Log } from '../utils/debug';
|
|
5
5
|
import type { Device } from '../device/Device';
|
|
6
6
|
type PostMessage = (message: CoreEventMessage) => void;
|
|
@@ -13,7 +13,7 @@ export type Params = {
|
|
|
13
13
|
type Context = {
|
|
14
14
|
deviceList: DeviceList;
|
|
15
15
|
postMessage: PostMessage;
|
|
16
|
-
initDevice: (path?:
|
|
16
|
+
initDevice: (path?: DeviceUniquePath) => Promise<Device>;
|
|
17
17
|
log: Log;
|
|
18
18
|
abortSignal: AbortSignal;
|
|
19
19
|
};
|
|
@@ -3,11 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.onCallFirmwareUpdate = void 0;
|
|
4
4
|
const crypto_1 = require("crypto");
|
|
5
5
|
const utils_1 = require("@trezor/utils");
|
|
6
|
+
const versionUtils_1 = require("@trezor/utils/lib/versionUtils");
|
|
6
7
|
const events_1 = require("../events");
|
|
7
8
|
const firmware_1 = require("../api/firmware");
|
|
8
9
|
const firmwareInfo_1 = require("../data/firmwareInfo");
|
|
9
10
|
const constants_1 = require("../constants");
|
|
10
|
-
const versionUtils_1 = require("@trezor/utils/lib/versionUtils");
|
|
11
11
|
const registerEvents = (device, postMessage) => {
|
|
12
12
|
device.on(events_1.DEVICE.BUTTON, (_d, request) => {
|
|
13
13
|
postMessage((0, events_1.createDeviceMessage)(events_1.DEVICE.BUTTON, {
|
|
@@ -44,10 +44,10 @@ const waitForReconnectedDevice = async ({ bootloader, method, intermediary }, {
|
|
|
44
44
|
}));
|
|
45
45
|
await (0, utils_1.createTimeoutPromise)(2000);
|
|
46
46
|
try {
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
reconnectedDevice = deviceList.getOnlyDevice();
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
49
50
|
}
|
|
50
|
-
catch { }
|
|
51
51
|
i++;
|
|
52
52
|
log.debug('onCallFirmwareUpdate', 'waiting for device to reconnect', i);
|
|
53
53
|
} while (!abortSignal.aborted &&
|
|
@@ -167,7 +167,7 @@ const onCallFirmwareUpdate = async ({ params, context: { deviceList, postMessage
|
|
|
167
167
|
if (!device.firmwareRelease) {
|
|
168
168
|
throw constants_1.ERRORS.TypedError('Runtime', 'device.firmwareRelease is not set');
|
|
169
169
|
}
|
|
170
|
-
if (deviceList.
|
|
170
|
+
if (deviceList.getDeviceCount() > 1) {
|
|
171
171
|
throw constants_1.ERRORS.TypedError('Device_MultipleNotSupported', 'Firmware update allowed with only 1 device connected');
|
|
172
172
|
}
|
|
173
173
|
log.debug('onCallFirmwareUpdate', 'device', device);
|
|
@@ -255,7 +255,7 @@ const onCallFirmwareUpdate = async ({ params, context: { deviceList, postMessage
|
|
|
255
255
|
log.error('onCallFirmwareUpdate', 'changeLanguage failed silently: ', err);
|
|
256
256
|
}
|
|
257
257
|
}
|
|
258
|
-
const checkSupported = reconnectedDevice.atLeast(
|
|
258
|
+
const checkSupported = reconnectedDevice.atLeast(constants_1.FIRMWARE.FW_HASH_SUPPORTED_VERSIONS) && !params.binary;
|
|
259
259
|
if (checkSupported) {
|
|
260
260
|
try {
|
|
261
261
|
log.debug('onCallFirmwareUpdate', 'getFirmwareHash supported, proceed with check', stripped);
|
|
@@ -10,187 +10,6 @@ export declare class DataManager {
|
|
|
10
10
|
static getProtobufMessages(): Record<string, any>;
|
|
11
11
|
static getSettings(key?: undefined): ConnectSettings;
|
|
12
12
|
static getSettings<T extends keyof ConnectSettings>(key: T): ConnectSettings[T];
|
|
13
|
-
static getConfig(): {
|
|
14
|
-
webusb: {
|
|
15
|
-
vendorId: number;
|
|
16
|
-
productId: number;
|
|
17
|
-
}[];
|
|
18
|
-
whitelist: {
|
|
19
|
-
origin: string;
|
|
20
|
-
priority: number;
|
|
21
|
-
}[];
|
|
22
|
-
management: {
|
|
23
|
-
origin: string;
|
|
24
|
-
}[];
|
|
25
|
-
knownHosts: {
|
|
26
|
-
origin: string;
|
|
27
|
-
label: string;
|
|
28
|
-
icon: string;
|
|
29
|
-
}[];
|
|
30
|
-
onionDomains: {
|
|
31
|
-
'trezor.io': string;
|
|
32
|
-
};
|
|
33
|
-
assets: {
|
|
34
|
-
name: string;
|
|
35
|
-
url: string;
|
|
36
|
-
}[];
|
|
37
|
-
messages: string;
|
|
38
|
-
supportedBrowsers: {
|
|
39
|
-
chrome: {
|
|
40
|
-
version: number;
|
|
41
|
-
download: string;
|
|
42
|
-
update: string;
|
|
43
|
-
};
|
|
44
|
-
chromium: {
|
|
45
|
-
version: number;
|
|
46
|
-
download: string;
|
|
47
|
-
update: string;
|
|
48
|
-
};
|
|
49
|
-
electron: {
|
|
50
|
-
version: number;
|
|
51
|
-
download: string;
|
|
52
|
-
update: string;
|
|
53
|
-
};
|
|
54
|
-
firefox: {
|
|
55
|
-
version: number;
|
|
56
|
-
download: string;
|
|
57
|
-
update: string;
|
|
58
|
-
};
|
|
59
|
-
brave: {
|
|
60
|
-
version: number;
|
|
61
|
-
download: string;
|
|
62
|
-
update: string;
|
|
63
|
-
};
|
|
64
|
-
edge: {
|
|
65
|
-
version: number;
|
|
66
|
-
download: string;
|
|
67
|
-
update: string;
|
|
68
|
-
};
|
|
69
|
-
opera: {
|
|
70
|
-
version: number;
|
|
71
|
-
download: string;
|
|
72
|
-
update: string;
|
|
73
|
-
};
|
|
74
|
-
};
|
|
75
|
-
supportedFirmware: ({
|
|
76
|
-
coin: string[];
|
|
77
|
-
methods: string[];
|
|
78
|
-
min: {
|
|
79
|
-
T1B1: string;
|
|
80
|
-
T2T1: string;
|
|
81
|
-
T2B1?: undefined;
|
|
82
|
-
T3B1?: undefined;
|
|
83
|
-
T3T1?: undefined;
|
|
84
|
-
};
|
|
85
|
-
max: undefined;
|
|
86
|
-
comment: string[];
|
|
87
|
-
capabilities?: undefined;
|
|
88
|
-
} | {
|
|
89
|
-
coin: string[];
|
|
90
|
-
min: {
|
|
91
|
-
T1B1: string;
|
|
92
|
-
T2T1: string;
|
|
93
|
-
T2B1?: undefined;
|
|
94
|
-
T3B1?: undefined;
|
|
95
|
-
T3T1?: undefined;
|
|
96
|
-
};
|
|
97
|
-
comment: string[];
|
|
98
|
-
methods?: undefined;
|
|
99
|
-
max?: undefined;
|
|
100
|
-
capabilities?: undefined;
|
|
101
|
-
} | {
|
|
102
|
-
methods: string[];
|
|
103
|
-
min: {
|
|
104
|
-
T1B1: string;
|
|
105
|
-
T2T1: string;
|
|
106
|
-
T2B1?: undefined;
|
|
107
|
-
T3B1?: undefined;
|
|
108
|
-
T3T1?: undefined;
|
|
109
|
-
};
|
|
110
|
-
comment: string[];
|
|
111
|
-
coin?: undefined;
|
|
112
|
-
max?: undefined;
|
|
113
|
-
capabilities?: undefined;
|
|
114
|
-
} | {
|
|
115
|
-
capabilities: string[];
|
|
116
|
-
min: {
|
|
117
|
-
T1B1: string;
|
|
118
|
-
T2T1: string;
|
|
119
|
-
T2B1?: undefined;
|
|
120
|
-
T3B1?: undefined;
|
|
121
|
-
T3T1?: undefined;
|
|
122
|
-
};
|
|
123
|
-
comment: string[];
|
|
124
|
-
coin?: undefined;
|
|
125
|
-
methods?: undefined;
|
|
126
|
-
max?: undefined;
|
|
127
|
-
} | {
|
|
128
|
-
coin: string[];
|
|
129
|
-
methods: string[];
|
|
130
|
-
min: {
|
|
131
|
-
T1B1: string;
|
|
132
|
-
T2T1: string;
|
|
133
|
-
T2B1?: undefined;
|
|
134
|
-
T3B1?: undefined;
|
|
135
|
-
T3T1?: undefined;
|
|
136
|
-
};
|
|
137
|
-
comment: string[];
|
|
138
|
-
max?: undefined;
|
|
139
|
-
capabilities?: undefined;
|
|
140
|
-
} | {
|
|
141
|
-
capabilities: string[];
|
|
142
|
-
methods: string[];
|
|
143
|
-
min: {
|
|
144
|
-
T1B1: string;
|
|
145
|
-
T2T1: string;
|
|
146
|
-
T2B1?: undefined;
|
|
147
|
-
T3B1?: undefined;
|
|
148
|
-
T3T1?: undefined;
|
|
149
|
-
};
|
|
150
|
-
coin?: undefined;
|
|
151
|
-
max?: undefined;
|
|
152
|
-
comment?: undefined;
|
|
153
|
-
} | {
|
|
154
|
-
methods: string[];
|
|
155
|
-
min: {
|
|
156
|
-
T1B1: string;
|
|
157
|
-
T2T1: string;
|
|
158
|
-
T2B1: string;
|
|
159
|
-
T3B1: string;
|
|
160
|
-
T3T1: string;
|
|
161
|
-
};
|
|
162
|
-
coin?: undefined;
|
|
163
|
-
max?: undefined;
|
|
164
|
-
comment?: undefined;
|
|
165
|
-
capabilities?: undefined;
|
|
166
|
-
} | {
|
|
167
|
-
methods: string[];
|
|
168
|
-
min: {
|
|
169
|
-
T1B1: string;
|
|
170
|
-
T2T1: string;
|
|
171
|
-
T2B1?: undefined;
|
|
172
|
-
T3B1?: undefined;
|
|
173
|
-
T3T1?: undefined;
|
|
174
|
-
};
|
|
175
|
-
coin?: undefined;
|
|
176
|
-
max?: undefined;
|
|
177
|
-
comment?: undefined;
|
|
178
|
-
capabilities?: undefined;
|
|
179
|
-
} | {
|
|
180
|
-
capabilities: string[];
|
|
181
|
-
min: {
|
|
182
|
-
T1B1: string;
|
|
183
|
-
T2T1: string;
|
|
184
|
-
T2B1: string;
|
|
185
|
-
T3B1: string;
|
|
186
|
-
T3T1: string;
|
|
187
|
-
};
|
|
188
|
-
comment: string[];
|
|
189
|
-
coin?: undefined;
|
|
190
|
-
methods?: undefined;
|
|
191
|
-
max?: undefined;
|
|
192
|
-
})[];
|
|
193
|
-
};
|
|
194
13
|
}
|
|
195
14
|
export {};
|
|
196
15
|
//# sourceMappingURL=DataManager.d.ts.map
|
package/lib/data/DataManager.js
CHANGED
|
@@ -5,20 +5,57 @@ const assets_1 = require("../utils/assets");
|
|
|
5
5
|
const coinInfo_1 = require("./coinInfo");
|
|
6
6
|
const firmwareInfo_1 = require("./firmwareInfo");
|
|
7
7
|
const transportInfo_1 = require("./transportInfo");
|
|
8
|
-
const config_1 = require("./config");
|
|
9
8
|
const types_1 = require("../types");
|
|
9
|
+
const assets = [
|
|
10
|
+
{
|
|
11
|
+
name: 'coins',
|
|
12
|
+
url: './data/coins.json',
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
name: 'coinsEth',
|
|
16
|
+
url: './data/coins-eth.json',
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
name: 'bridge',
|
|
20
|
+
url: './data/bridge/releases.json',
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
name: 'firmware-t1b1',
|
|
24
|
+
url: './data/firmware/t1b1/releases.json',
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
name: 'firmware-t2t1',
|
|
28
|
+
url: './data/firmware/t2t1/releases.json',
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
name: 'firmware-t2b1',
|
|
32
|
+
url: './data/firmware/t2b1/releases.json',
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
name: 'firmware-t3b1',
|
|
36
|
+
url: './data/firmware/t3b1/releases.json',
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
name: 'firmware-t3t1',
|
|
40
|
+
url: './data/firmware/t3t1/releases.json',
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
name: 'firmware-t3tw1',
|
|
44
|
+
url: './data/firmware/t3w1/releases.json',
|
|
45
|
+
},
|
|
46
|
+
];
|
|
10
47
|
class DataManager {
|
|
11
48
|
static async load(settings, withAssets = true) {
|
|
12
49
|
const ts = settings.env === 'web' ? `?r=${settings.timestamp}` : '';
|
|
13
50
|
this.settings = settings;
|
|
14
51
|
if (!withAssets)
|
|
15
52
|
return;
|
|
16
|
-
const assetPromises =
|
|
53
|
+
const assetPromises = assets.map(async (asset) => {
|
|
17
54
|
const json = await (0, assets_1.httpRequest)(`${asset.url}${ts}`, 'json');
|
|
18
55
|
this.assets[asset.name] = json;
|
|
19
56
|
});
|
|
20
57
|
await Promise.all(assetPromises);
|
|
21
|
-
this.messages = await (0, assets_1.httpRequest)(
|
|
58
|
+
this.messages = await (0, assets_1.httpRequest)('./data/messages/messages.json', 'json');
|
|
22
59
|
(0, transportInfo_1.parseBridgeJSON)(this.assets.bridge);
|
|
23
60
|
(0, coinInfo_1.parseCoinsJson)({
|
|
24
61
|
...this.assets.coins,
|
|
@@ -43,9 +80,6 @@ class DataManager {
|
|
|
43
80
|
}
|
|
44
81
|
return this.settings;
|
|
45
82
|
}
|
|
46
|
-
static getConfig() {
|
|
47
|
-
return config_1.config;
|
|
48
|
-
}
|
|
49
83
|
}
|
|
50
84
|
exports.DataManager = DataManager;
|
|
51
85
|
DataManager.assets = {};
|