@trezor/connect 9.4.3-beta.1 → 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 +43 -4
- 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.js +1 -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 -1
- 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 +3 -0
- package/lib/constants/errors.d.ts +3 -0
- package/lib/constants/errors.js +3 -0
- package/lib/constants/index.d.ts +1 -0
- package/lib/constants/index.js +3 -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 +5 -5
- package/lib/data/DataManager.d.ts +0 -181
- package/lib/data/DataManager.js +40 -6
- package/lib/data/analyticsInfo.js +2 -1
- 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 +5 -4
- package/lib/data/deviceAuthenticityConfig.js +17 -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 +1 -1
- package/lib/data/version.js +1 -1
- package/lib/device/Device.d.ts +143 -36
- package/lib/device/Device.js +226 -119
- 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/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/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 +13 -19
- package/lib/impl/dynamic.js +0 -9
- 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 +13 -1
- 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 +21 -18
- package/lib/types/settings.d.ts +15 -9
- 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.js +3 -3
- package/lib/utils/deviceFeaturesUtils.js +1 -1
- 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 -63
- package/lib/types/api/checkFirmwareAuthenticity.d.ts +0 -11
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);
|
|
@@ -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 = {};
|
|
@@ -6,7 +6,7 @@ const events_1 = require("../events");
|
|
|
6
6
|
const enhanceMessageWithAnalytics = (message, data) => {
|
|
7
7
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
8
8
|
switch (message.type) {
|
|
9
|
-
case events_1.UI_REQUEST.REQUEST_CONFIRMATION:
|
|
9
|
+
case events_1.UI_REQUEST.REQUEST_CONFIRMATION: {
|
|
10
10
|
const { device } = data;
|
|
11
11
|
return {
|
|
12
12
|
...message,
|
|
@@ -29,6 +29,7 @@ const enhanceMessageWithAnalytics = (message, data) => {
|
|
|
29
29
|
},
|
|
30
30
|
},
|
|
31
31
|
};
|
|
32
|
+
}
|
|
32
33
|
default:
|
|
33
34
|
return message;
|
|
34
35
|
}
|
package/lib/data/coinInfo.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ export declare const getBitcoinNetwork: (pathOrName: DerivationPath) => ({
|
|
|
17
17
|
T2B1: string | false;
|
|
18
18
|
T3B1: string | false;
|
|
19
19
|
T3T1: string | false;
|
|
20
|
+
T3W1: string | false;
|
|
20
21
|
connect: boolean;
|
|
21
22
|
};
|
|
22
23
|
decimals: number;
|
|
@@ -75,6 +76,7 @@ export declare const getEthereumNetwork: (pathOrName: DerivationPath) => ({
|
|
|
75
76
|
T2B1: string | false;
|
|
76
77
|
T3B1: string | false;
|
|
77
78
|
T3T1: string | false;
|
|
79
|
+
T3W1: string | false;
|
|
78
80
|
connect: boolean;
|
|
79
81
|
};
|
|
80
82
|
decimals: number;
|
|
@@ -108,6 +110,7 @@ export declare const getMiscNetwork: (pathOrName: DerivationPath) => ({
|
|
|
108
110
|
T2B1: string | false;
|
|
109
111
|
T3B1: string | false;
|
|
110
112
|
T3T1: string | false;
|
|
113
|
+
T3W1: string | false;
|
|
111
114
|
connect: boolean;
|
|
112
115
|
};
|
|
113
116
|
decimals: number;
|
|
@@ -165,6 +168,7 @@ export declare const fixCoinInfoNetwork: (ci: BitcoinNetworkInfo, path: number[]
|
|
|
165
168
|
T2B1: string | false;
|
|
166
169
|
T3B1: string | false;
|
|
167
170
|
T3T1: string | false;
|
|
171
|
+
T3W1: string | false;
|
|
168
172
|
connect: boolean;
|
|
169
173
|
};
|
|
170
174
|
decimals: number;
|
|
@@ -223,6 +227,7 @@ export declare const getCoinInfoByHash: (hash: string, networkInfo: any) => {
|
|
|
223
227
|
T2B1: string | false;
|
|
224
228
|
T3B1: string | false;
|
|
225
229
|
T3T1: string | false;
|
|
230
|
+
T3W1: string | false;
|
|
226
231
|
connect: boolean;
|
|
227
232
|
};
|
|
228
233
|
decimals: number;
|
|
@@ -281,6 +286,7 @@ export declare const getCoinInfo: (currency: string) => ({
|
|
|
281
286
|
T2B1: string | false;
|
|
282
287
|
T3B1: string | false;
|
|
283
288
|
T3T1: string | false;
|
|
289
|
+
T3W1: string | false;
|
|
284
290
|
connect: boolean;
|
|
285
291
|
};
|
|
286
292
|
decimals: number;
|
|
@@ -338,6 +344,7 @@ export declare const getCoinInfo: (currency: string) => ({
|
|
|
338
344
|
T2B1: string | false;
|
|
339
345
|
T3B1: string | false;
|
|
340
346
|
T3T1: string | false;
|
|
347
|
+
T3W1: string | false;
|
|
341
348
|
connect: boolean;
|
|
342
349
|
};
|
|
343
350
|
decimals: number;
|
|
@@ -370,6 +377,7 @@ export declare const getCoinInfo: (currency: string) => ({
|
|
|
370
377
|
T2B1: string | false;
|
|
371
378
|
T3B1: string | false;
|
|
372
379
|
T3T1: string | false;
|
|
380
|
+
T3W1: string | false;
|
|
373
381
|
connect: boolean;
|
|
374
382
|
};
|
|
375
383
|
decimals: number;
|
|
@@ -414,6 +422,7 @@ export declare const getUniqueNetworks: (networks: (CoinInfo | undefined)[]) =>
|
|
|
414
422
|
T2B1: string | false;
|
|
415
423
|
T3B1: string | false;
|
|
416
424
|
T3T1: string | false;
|
|
425
|
+
T3W1: string | false;
|
|
417
426
|
connect: boolean;
|
|
418
427
|
};
|
|
419
428
|
decimals: number;
|
|
@@ -471,6 +480,7 @@ export declare const getUniqueNetworks: (networks: (CoinInfo | undefined)[]) =>
|
|
|
471
480
|
T2B1: string | false;
|
|
472
481
|
T3B1: string | false;
|
|
473
482
|
T3T1: string | false;
|
|
483
|
+
T3W1: string | false;
|
|
474
484
|
connect: boolean;
|
|
475
485
|
};
|
|
476
486
|
decimals: number;
|
|
@@ -503,6 +513,7 @@ export declare const getUniqueNetworks: (networks: (CoinInfo | undefined)[]) =>
|
|
|
503
513
|
T2B1: string | false;
|
|
504
514
|
T3B1: string | false;
|
|
505
515
|
T3T1: string | false;
|
|
516
|
+
T3W1: string | false;
|
|
506
517
|
connect: boolean;
|
|
507
518
|
};
|
|
508
519
|
decimals: number;
|
|
@@ -536,6 +547,7 @@ export declare const getAllNetworks: () => (({
|
|
|
536
547
|
T2B1: string | false;
|
|
537
548
|
T3B1: string | false;
|
|
538
549
|
T3T1: string | false;
|
|
550
|
+
T3W1: string | false;
|
|
539
551
|
connect: boolean;
|
|
540
552
|
};
|
|
541
553
|
decimals: number;
|
|
@@ -593,6 +605,7 @@ export declare const getAllNetworks: () => (({
|
|
|
593
605
|
T2B1: string | false;
|
|
594
606
|
T3B1: string | false;
|
|
595
607
|
T3T1: string | false;
|
|
608
|
+
T3W1: string | false;
|
|
596
609
|
connect: boolean;
|
|
597
610
|
};
|
|
598
611
|
decimals: number;
|
|
@@ -625,6 +638,7 @@ export declare const getAllNetworks: () => (({
|
|
|
625
638
|
T2B1: string | false;
|
|
626
639
|
T3B1: string | false;
|
|
627
640
|
T3T1: string | false;
|
|
641
|
+
T3W1: string | false;
|
|
628
642
|
connect: boolean;
|
|
629
643
|
};
|
|
630
644
|
decimals: number;
|