@trezor/connect 9.4.8-beta.1 → 9.5.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +33 -6
- package/README.md +1 -1
- package/lib/api/authorizeCoinjoin.js +1 -1
- package/lib/api/binance/api/binanceGetAddress.js +2 -4
- package/lib/api/binance/api/binanceGetPublicKey.js +1 -0
- package/lib/api/binance/api/binanceSignTransaction.js +1 -2
- package/lib/api/bitcoin/Fees.js +4 -1
- package/lib/api/bitcoin/TransactionComposer.js +9 -2
- package/lib/api/bitcoin/enhanceSignTx.js +1 -2
- package/lib/api/bitcoin/refTx.js +4 -6
- package/lib/api/blockchainDisconnect.js +1 -1
- package/lib/api/blockchainSubscribe.js +1 -2
- package/lib/api/blockchainUnsubscribe.js +1 -2
- package/lib/api/cardano/api/cardanoComposeTransaction.js +1 -1
- package/lib/api/cardano/api/cardanoGetAddress.js +2 -4
- package/lib/api/cardano/api/cardanoGetPublicKey.js +1 -0
- package/lib/api/cardano/cardanoAuxiliaryData.js +2 -2
- package/lib/api/cardano/cardanoUtils.js +5 -6
- package/lib/api/cipherKeyValue.js +1 -0
- package/lib/api/common/Discovery.js +16 -1
- package/lib/api/common/paramsValidator.js +2 -2
- package/lib/api/composeTransaction.js +6 -6
- package/lib/api/eos/api/eosGetPublicKey.js +1 -0
- package/lib/api/ethereum/api/ethereumGetAddress.js +2 -4
- package/lib/api/ethereum/api/ethereumGetPublicKey.js +1 -0
- package/lib/api/ethereum/api/ethereumSignMessage.js +1 -2
- package/lib/api/ethereum/api/ethereumSignTransaction.js +1 -1
- package/lib/api/ethereum/api/ethereumSignTypedData.js +1 -1
- package/lib/api/ethereum/ethereumDefinitions.js +2 -2
- package/lib/api/ethereum/ethereumSignTx.d.ts +2 -2
- package/lib/api/ethereum/ethereumSignTx.js +3 -2
- package/lib/api/firmware/verifyAuthenticityProof.js +3 -3
- package/lib/api/getAccountDescriptor.js +2 -4
- package/lib/api/getAccountInfo.js +4 -5
- package/lib/api/getAddress.js +5 -8
- package/lib/api/getDeviceState.js +1 -1
- package/lib/api/getOwnershipId.js +1 -0
- package/lib/api/getOwnershipProof.js +1 -0
- package/lib/api/getPublicKey.js +3 -2
- package/lib/api/nem/api/nemGetAddress.js +2 -4
- package/lib/api/nem/api/nemSignTransaction.js +1 -2
- package/lib/api/requestLogin.js +1 -0
- package/lib/api/ripple/api/rippleGetAddress.js +2 -4
- package/lib/api/signMessage.js +1 -2
- package/lib/api/signTransaction.js +6 -8
- package/lib/api/solana/additionalInfo.js +2 -3
- package/lib/api/solana/api/solanaComposeTransaction.js +2 -3
- package/lib/api/solana/api/solanaGetAddress.js +2 -4
- package/lib/api/solana/api/solanaGetPublicKey.js +1 -0
- package/lib/api/solana/solanaUtils.js +6 -5
- package/lib/api/stellar/api/stellarGetAddress.js +2 -4
- package/lib/api/tezos/api/tezosGetAddress.js +2 -4
- package/lib/api/tezos/api/tezosGetPublicKey.js +1 -0
- package/lib/backend/BackendManager.js +11 -16
- package/lib/backend/Blockchain.js +10 -4
- package/lib/backend/BlockchainLink.js +1 -1
- package/lib/constants/errors.js +2 -0
- package/lib/core/AbstractMethod.js +30 -5
- package/lib/core/index.js +24 -34
- package/lib/core/onCallFirmwareUpdate.d.ts +3 -2
- package/lib/core/onCallFirmwareUpdate.js +12 -59
- package/lib/data/DataManager.js +3 -2
- package/lib/data/analyticsInfo.js +10 -11
- package/lib/data/connectSettings.js +1 -2
- package/lib/data/defaultFeeLevels.js +4 -7
- package/lib/data/deviceAuthenticityConfig.js +16 -1
- package/lib/data/firmwareInfo.js +5 -6
- package/lib/data/version.d.ts +1 -1
- package/lib/data/version.js +1 -1
- package/lib/device/Device.d.ts +10 -2
- package/lib/device/Device.js +73 -56
- package/lib/device/DeviceCommands.d.ts +5 -1
- package/lib/device/DeviceCommands.js +7 -2
- package/lib/device/DeviceList.d.ts +2 -0
- package/lib/device/DeviceList.js +44 -24
- package/lib/device/StateStorage.js +5 -6
- package/lib/device/checkFirmwareRevision.js +11 -6
- package/lib/device/prompts.js +4 -7
- package/lib/events/call.d.ts +1 -0
- package/lib/events/call.js +3 -3
- package/lib/impl/core-in-module.js +25 -23
- package/lib/impl/dynamic.js +7 -1
- package/lib/index.js +9 -12
- package/lib/types/api/ethereum/index.d.ts +4 -4
- package/lib/types/api/ethereum/index.js +2 -2
- package/lib/types/api/firmwareUpdate.d.ts +1 -8
- package/lib/utils/assets.js +1 -1
- package/lib/utils/assets.native.js +1 -1
- package/lib/utils/hdnodeUtils.js +1 -2
- package/lib/utils/interactionTimeout.js +2 -2
- package/lib/utils/popupPromiseManager.js +2 -2
- package/lib/utils/proxy-event-emitter.js +1 -0
- package/lib/utils/uiPromiseManager.js +3 -4
- package/lib/utils/urlUtils.js +5 -8
- package/package.json +12 -12
- package/lib/utils/abortablePromise.d.ts +0 -5
- package/lib/utils/abortablePromise.js +0 -17
package/lib/core/index.js
CHANGED
|
@@ -28,7 +28,6 @@ const startInteractionTimeout = (context) => context.interactionTimeout.start(()
|
|
|
28
28
|
onPopupClosed(context, 'Interaction timeout');
|
|
29
29
|
});
|
|
30
30
|
const initDevice = async (context, methodCallDevice) => {
|
|
31
|
-
var _a;
|
|
32
31
|
const { uiPromises, deviceList, sendCoreMessage } = context;
|
|
33
32
|
(0, DeviceList_1.assertDeviceListConnected)(deviceList);
|
|
34
33
|
const isWebUsb = deviceList.getActiveTransports().some(t => t.type === 'WebUsbTransport');
|
|
@@ -38,11 +37,11 @@ const initDevice = async (context, methodCallDevice) => {
|
|
|
38
37
|
const origin = DataManager_1.DataManager.getSettings('origin');
|
|
39
38
|
const useCoreInPopup = DataManager_1.DataManager.getSettings('useCoreInPopup');
|
|
40
39
|
const { preferredDevice } = connect_common_1.storage.load().origin[origin] || {};
|
|
41
|
-
const preferredDeviceInList =
|
|
42
|
-
if (
|
|
40
|
+
const preferredDeviceInList = preferredDevice?.state && deviceList.getDeviceByStaticState(preferredDevice.state);
|
|
41
|
+
if (methodCallDevice?.state?.staticSessionId) {
|
|
43
42
|
device = deviceList.getDeviceByStaticState(methodCallDevice.state.staticSessionId);
|
|
44
43
|
}
|
|
45
|
-
else if (methodCallDevice
|
|
44
|
+
else if (methodCallDevice?.path) {
|
|
46
45
|
device = deviceList.getDeviceByPath(methodCallDevice.path);
|
|
47
46
|
}
|
|
48
47
|
if (preferredDevice && !device) {
|
|
@@ -129,10 +128,9 @@ const getInvalidDeviceState = async ({ sendCoreMessage }, device, preauthorized)
|
|
|
129
128
|
return device.validateState(preauthorized);
|
|
130
129
|
};
|
|
131
130
|
const inner = async (context, method, device) => {
|
|
132
|
-
var _a;
|
|
133
131
|
const { uiPromises, sendCoreMessage } = context;
|
|
134
132
|
const trustedHost = DataManager_1.DataManager.getSettings('trustedHost');
|
|
135
|
-
const isUsingPopup =
|
|
133
|
+
const isUsingPopup = DataManager_1.DataManager.getSettings('popup') ?? false;
|
|
136
134
|
const firmwareException = method.checkFirmwareRange();
|
|
137
135
|
if (firmwareException) {
|
|
138
136
|
if (isUsingPopup) {
|
|
@@ -274,14 +272,13 @@ const onCall = async (context, message) => {
|
|
|
274
272
|
let method;
|
|
275
273
|
try {
|
|
276
274
|
method = await methodSynchronize(async () => {
|
|
277
|
-
var _a;
|
|
278
275
|
_log.debug('loading method...');
|
|
279
276
|
const method2 = await (0, method_1.getMethod)(message);
|
|
280
277
|
_log.debug('method selected', method2.name);
|
|
281
278
|
method2.postMessage = sendCoreMessage;
|
|
282
279
|
method2.createUiPromise = uiPromises.create;
|
|
283
280
|
method2.init();
|
|
284
|
-
await
|
|
281
|
+
await method2.initAsync?.();
|
|
285
282
|
return method2;
|
|
286
283
|
});
|
|
287
284
|
resolveWaitForFirstMethod();
|
|
@@ -323,7 +320,6 @@ const onCall = async (context, message) => {
|
|
|
323
320
|
return await onCallDevice(context, message, method);
|
|
324
321
|
};
|
|
325
322
|
const onCallDevice = async (context, message, method) => {
|
|
326
|
-
var _a, _b, _c;
|
|
327
323
|
const { deviceList, callMethods, getOverridePromise, setOverridePromise, sendCoreMessage } = context;
|
|
328
324
|
const responseID = message.id;
|
|
329
325
|
const { origin, env, useCoreInPopup, transports } = DataManager_1.DataManager.getSettings();
|
|
@@ -357,12 +353,9 @@ const onCallDevice = async (context, message, method) => {
|
|
|
357
353
|
}
|
|
358
354
|
const device = tempDevice;
|
|
359
355
|
method.setDevice(device);
|
|
360
|
-
const previousCall = callMethods.filter(call =>
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
call !== method &&
|
|
364
|
-
((_a = call.device) === null || _a === void 0 ? void 0 : _a.getUniquePath()) === method.device.getUniquePath();
|
|
365
|
-
});
|
|
356
|
+
const previousCall = callMethods.filter(call => call &&
|
|
357
|
+
call !== method &&
|
|
358
|
+
call.device?.getUniquePath() === method.device.getUniquePath());
|
|
366
359
|
if (previousCall.length > 0 && method.overridePreviousCall) {
|
|
367
360
|
previousCall.forEach(call => {
|
|
368
361
|
call.overridden = true;
|
|
@@ -386,7 +379,7 @@ const onCallDevice = async (context, message, method) => {
|
|
|
386
379
|
throw constants_1.ERRORS.TypedError('Device_CallInProgress');
|
|
387
380
|
}
|
|
388
381
|
}
|
|
389
|
-
device.setInstance(
|
|
382
|
+
device.setInstance(message.payload.device?.instance);
|
|
390
383
|
if (method.hasExpectedDeviceState) {
|
|
391
384
|
device.setState(method.deviceState);
|
|
392
385
|
}
|
|
@@ -435,14 +428,14 @@ const onCallDevice = async (context, message, method) => {
|
|
|
435
428
|
}
|
|
436
429
|
if (method.keepSession &&
|
|
437
430
|
method.deviceState &&
|
|
438
|
-
method.deviceState.sessionId !==
|
|
431
|
+
method.deviceState.sessionId !== device.getState()?.sessionId) {
|
|
439
432
|
sendCoreMessage((0, events_2.createDeviceMessage)(events_2.DEVICE.CHANGED, device.toMessageObject()));
|
|
440
433
|
}
|
|
441
434
|
const response = messageResponse;
|
|
442
435
|
if (response) {
|
|
443
436
|
const shouldReleaseSession = response.success ||
|
|
444
437
|
(!response.success &&
|
|
445
|
-
|
|
438
|
+
response?.payload?.error !== 'device disconnected during action');
|
|
446
439
|
await device.cleanup(shouldReleaseSession);
|
|
447
440
|
if (useCoreInPopup) {
|
|
448
441
|
sendCoreMessage(response);
|
|
@@ -616,22 +609,20 @@ const initDeviceList = (context) => {
|
|
|
616
609
|
});
|
|
617
610
|
};
|
|
618
611
|
class Core extends events_1.default {
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
}
|
|
612
|
+
abortController = new AbortController();
|
|
613
|
+
callMethods = [];
|
|
614
|
+
popupPromise = (0, popupPromiseManager_1.createPopupPromiseManager)();
|
|
615
|
+
methodSynchronize = (0, utils_1.getSynchronize)();
|
|
616
|
+
uiPromises = (0, uiPromiseManager_1.createUiPromiseManager)(() => startInteractionTimeout(this.getCoreContext()));
|
|
617
|
+
overridePromise;
|
|
618
|
+
waitForFirstMethod = (0, utils_1.createDeferred)();
|
|
619
|
+
_interactionTimeout;
|
|
628
620
|
get interactionTimeout() {
|
|
629
|
-
|
|
630
|
-
return (_a = this._interactionTimeout) !== null && _a !== void 0 ? _a : (0, utils_1.throwError)('Core not initialized: interactionTimeout');
|
|
621
|
+
return this._interactionTimeout ?? (0, utils_1.throwError)('Core not initialized: interactionTimeout');
|
|
631
622
|
}
|
|
623
|
+
_deviceList;
|
|
632
624
|
get deviceList() {
|
|
633
|
-
|
|
634
|
-
return (_a = this._deviceList) !== null && _a !== void 0 ? _a : (0, utils_1.throwError)('Core not initialized: deviceList');
|
|
625
|
+
return this._deviceList ?? (0, utils_1.throwError)('Core not initialized: deviceList');
|
|
635
626
|
}
|
|
636
627
|
sendCoreMessage(message) {
|
|
637
628
|
if (message.event === events_2.RESPONSE_EVENT) {
|
|
@@ -667,8 +658,7 @@ class Core extends events_1.default {
|
|
|
667
658
|
};
|
|
668
659
|
}
|
|
669
660
|
handleMessage(message) {
|
|
670
|
-
|
|
671
|
-
_log.debug('handleMessage', message);
|
|
661
|
+
_log.debug('handleMessage', message.type);
|
|
672
662
|
switch (message.type) {
|
|
673
663
|
case events_2.POPUP.HANDSHAKE:
|
|
674
664
|
this.popupPromise.resolve();
|
|
@@ -679,7 +669,7 @@ class Core extends events_1.default {
|
|
|
679
669
|
break;
|
|
680
670
|
case transport_1.TRANSPORT.DISABLE_WEBUSB: {
|
|
681
671
|
const settings = DataManager_1.DataManager.getSettings();
|
|
682
|
-
const transports =
|
|
672
|
+
const transports = settings.transports?.filter(t => t !== 'WebUsbTransport');
|
|
683
673
|
if (transports && !transports.includes('BridgeTransport')) {
|
|
684
674
|
transports.unshift('BridgeTransport');
|
|
685
675
|
}
|
|
@@ -18,9 +18,10 @@ type Context = {
|
|
|
18
18
|
log: Log;
|
|
19
19
|
abortSignal: AbortSignal;
|
|
20
20
|
};
|
|
21
|
-
|
|
21
|
+
type OnCallFirmwareUpdateParams = {
|
|
22
22
|
params: Params;
|
|
23
23
|
context: Context;
|
|
24
|
-
}
|
|
24
|
+
};
|
|
25
|
+
export declare const onCallFirmwareUpdate: ({ params, context: { deviceList, postMessage, initDevice, log, abortSignal }, }: OnCallFirmwareUpdateParams) => Promise<FirmwareUpdateResponse>;
|
|
25
26
|
export {};
|
|
26
27
|
//# sourceMappingURL=onCallFirmwareUpdate.d.ts.map
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.onCallFirmwareUpdate = void 0;
|
|
4
|
-
const crypto_1 = require("crypto");
|
|
5
4
|
const utils_1 = require("@trezor/utils");
|
|
6
5
|
const versionUtils_1 = require("@trezor/utils/lib/versionUtils");
|
|
7
6
|
const firmware_1 = require("../api/firmware");
|
|
@@ -42,7 +41,7 @@ const waitForReconnectedDevice = async ({ bootloader, method, intermediary }, {
|
|
|
42
41
|
target,
|
|
43
42
|
i,
|
|
44
43
|
}));
|
|
45
|
-
await (0, utils_1.
|
|
44
|
+
await (0, utils_1.resolveAfter)(2000);
|
|
46
45
|
try {
|
|
47
46
|
reconnectedDevice = deviceList.getOnlyDevice();
|
|
48
47
|
}
|
|
@@ -64,7 +63,7 @@ const waitForReconnectedDevice = async ({ bootloader, method, intermediary }, {
|
|
|
64
63
|
i++;
|
|
65
64
|
log.debug('onCallFirmwareUpdate', '...still waiting for device to reconnect', i);
|
|
66
65
|
} while (!abortSignal.aborted &&
|
|
67
|
-
(!
|
|
66
|
+
(!reconnectedDevice?.features ||
|
|
68
67
|
bootloader === !reconnectedDevice.features.bootloader_mode ||
|
|
69
68
|
(intermediary &&
|
|
70
69
|
!(0, versionUtils_1.isNewer)([
|
|
@@ -87,14 +86,13 @@ const waitForReconnectedDevice = async ({ bootloader, method, intermediary }, {
|
|
|
87
86
|
return reconnectedDevice;
|
|
88
87
|
};
|
|
89
88
|
const getInstallationParams = (device, params) => {
|
|
90
|
-
|
|
91
|
-
const btcOnly = (_a = params.btcOnly) !== null && _a !== void 0 ? _a : device.firmwareType === 'bitcoin-only';
|
|
89
|
+
const btcOnly = params.btcOnly ?? device.firmwareType === 'bitcoin-only';
|
|
92
90
|
if (!device.features.bootloader_mode) {
|
|
93
91
|
const version = params.binary
|
|
94
92
|
? (0, firmware_1.parseFirmwareHeaders)(Buffer.from(params.binary)).version
|
|
95
93
|
: undefined;
|
|
96
94
|
const isUpdatingToNewerVersion = !version
|
|
97
|
-
?
|
|
95
|
+
? device.firmwareRelease?.isNewer
|
|
98
96
|
: (0, versionUtils_1.isNewer)(version, [
|
|
99
97
|
device.features.major_version,
|
|
100
98
|
device.features.minor_version,
|
|
@@ -123,7 +121,6 @@ const getInstallationParams = (device, params) => {
|
|
|
123
121
|
};
|
|
124
122
|
const getFwHeader = (binary) => Buffer.from(binary.slice(0, 6000)).toString('hex');
|
|
125
123
|
const getBinaryHelper = (device, params, log, postMessage, btcOnly) => {
|
|
126
|
-
var _a;
|
|
127
124
|
if (params.binary) {
|
|
128
125
|
return {
|
|
129
126
|
binary: params.binary,
|
|
@@ -143,7 +140,7 @@ const getBinaryHelper = (device, params, log, postMessage, btcOnly) => {
|
|
|
143
140
|
}));
|
|
144
141
|
return (0, firmware_1.getBinaryForFirmwareUpgrade)({
|
|
145
142
|
features: device.features,
|
|
146
|
-
releases: (0, firmwareInfo_1.getReleases)(
|
|
143
|
+
releases: (0, firmwareInfo_1.getReleases)(device.features?.internal_model),
|
|
147
144
|
baseUrl: params.baseUrl || 'https://data.trezor.io',
|
|
148
145
|
version,
|
|
149
146
|
btcOnly,
|
|
@@ -168,29 +165,9 @@ const getBinaryHelper = (device, params, log, postMessage, btcOnly) => {
|
|
|
168
165
|
};
|
|
169
166
|
});
|
|
170
167
|
};
|
|
171
|
-
const firmwareCheck = async (reconnectedDevice, device, stripped, postMessage) => {
|
|
172
|
-
postMessage((0, events_1.createUiMessage)(events_1.UI.FIRMWARE_PROGRESS, {
|
|
173
|
-
device: device.toMessageObject(),
|
|
174
|
-
operation: 'validating',
|
|
175
|
-
progress: 0,
|
|
176
|
-
}));
|
|
177
|
-
const { hash, challenge } = (0, firmware_1.calculateFirmwareHash)(device.features.major_version, stripped, (0, crypto_1.randomBytes)(32));
|
|
178
|
-
const getFirmwareHashResponse = await reconnectedDevice
|
|
179
|
-
.getCommands()
|
|
180
|
-
.typedCall('GetFirmwareHash', 'FirmwareHash', { challenge });
|
|
181
|
-
postMessage((0, events_1.createUiMessage)(events_1.UI.FIRMWARE_PROGRESS, {
|
|
182
|
-
device: device.toMessageObject(),
|
|
183
|
-
operation: 'validating',
|
|
184
|
-
progress: 100,
|
|
185
|
-
}));
|
|
186
|
-
return (getFirmwareHashResponse.message !== 'Unknown message' &&
|
|
187
|
-
getFirmwareHashResponse.message !== 'Unexpected message' &&
|
|
188
|
-
getFirmwareHashResponse.message.hash === hash);
|
|
189
|
-
};
|
|
190
168
|
const onCallFirmwareUpdate = async ({ params, context: { deviceList, postMessage, initDevice, log, abortSignal }, }) => {
|
|
191
|
-
var _a, _b;
|
|
192
169
|
log.debug('onCallFirmwareUpdate with params: ', params);
|
|
193
|
-
const device = await initDevice(
|
|
170
|
+
const device = await initDevice(params?.device?.path);
|
|
194
171
|
if (deviceList.getDeviceCount() > 1) {
|
|
195
172
|
throw constants_1.ERRORS.TypedError('Device_MultipleNotSupported', 'Firmware update allowed with only 1 device connected');
|
|
196
173
|
}
|
|
@@ -239,7 +216,7 @@ const onCallFirmwareUpdate = async ({ params, context: { deviceList, postMessage
|
|
|
239
216
|
await device.getCommands().typedCall('RebootToBootloader', 'Success', rebootParams);
|
|
240
217
|
}
|
|
241
218
|
else {
|
|
242
|
-
let rebootResponse = await device.getCommands().typedCall('RebootToBootloader', ['TranslationDataRequest', 'Success'], { ...rebootParams, language_data_length: languageBlob
|
|
219
|
+
let rebootResponse = await device.getCommands().typedCall('RebootToBootloader', ['TranslationDataRequest', 'Success'], { ...rebootParams, language_data_length: languageBlob?.byteLength });
|
|
243
220
|
log.debug('onCallFirmwareUpdate', 'RebootToBootloader response', rebootResponse.message);
|
|
244
221
|
while (languageBlob && rebootResponse.type !== 'Success') {
|
|
245
222
|
const start = rebootResponse.message.data_offset;
|
|
@@ -251,23 +228,23 @@ const onCallFirmwareUpdate = async ({ params, context: { deviceList, postMessage
|
|
|
251
228
|
log.info('onCallFirmwareUpdate', 'waiting for disconnected event after rebootToBootloader...');
|
|
252
229
|
await disconnectedPromise;
|
|
253
230
|
if (device.features.major_version === 1) {
|
|
254
|
-
await (0, utils_1.
|
|
231
|
+
await (0, utils_1.resolveAfter)(2000);
|
|
255
232
|
}
|
|
256
233
|
reconnectedDevice = await waitForReconnectedDevice({ bootloader: true, method: 'auto' }, { deviceList, device, log, postMessage, abortSignal });
|
|
257
234
|
}
|
|
258
|
-
const intermediary = !params.binary &&
|
|
235
|
+
const intermediary = !params.binary && device.firmwareRelease?.intermediaryVersion;
|
|
259
236
|
const bootloaderVersion = reconnectedDevice.getVersion();
|
|
260
237
|
await reconnectedDevice.initialize(false);
|
|
261
238
|
let stripped = (0, firmware_1.stripFwHeaders)(binary);
|
|
262
239
|
await (0, firmware_1.uploadFirmware)(reconnectedDevice.getCommands().typedCall.bind(reconnectedDevice.getCommands()), postMessage, reconnectedDevice, { payload: !intermediary && (0, firmware_1.shouldStripFwHeaders)(device.features) ? stripped : binary });
|
|
263
|
-
|
|
240
|
+
log.info('onCallFirmwareUpdate', 'firmware uploaded');
|
|
264
241
|
if (intermediary) {
|
|
242
|
+
log.info('onCallFirmwareUpdate', '...but it was the intermediary firmware, so one more go');
|
|
265
243
|
reconnectedDevice = await waitForReconnectedDevice({ bootloader: true, method: 'manual', intermediary: true }, { deviceList, device: reconnectedDevice, log, postMessage, abortSignal });
|
|
266
244
|
binaryInfo = await getBinaryHelper(reconnectedDevice, params, log, postMessage, btcOnly);
|
|
267
245
|
stripped = (0, firmware_1.stripFwHeaders)(binaryInfo.binary);
|
|
268
246
|
await reconnectedDevice.initialize(false);
|
|
269
247
|
await (0, firmware_1.uploadFirmware)(reconnectedDevice.getCommands().typedCall.bind(reconnectedDevice.getCommands()), postMessage, reconnectedDevice, { payload: stripped });
|
|
270
|
-
await reconnectedDevice.release();
|
|
271
248
|
}
|
|
272
249
|
reconnectedDevice = await waitForReconnectedDevice({ bootloader: false, method: 'wait' }, { deviceList, device: reconnectedDevice, log, postMessage, abortSignal });
|
|
273
250
|
if (reconnectedDevice.atLeast('2.7.0') &&
|
|
@@ -281,8 +258,6 @@ const onCallFirmwareUpdate = async ({ params, context: { deviceList, postMessage
|
|
|
281
258
|
log.error('onCallFirmwareUpdate', 'changeLanguage failed silently: ', err);
|
|
282
259
|
}
|
|
283
260
|
}
|
|
284
|
-
const checkSupported = reconnectedDevice.atLeast(constants_1.FIRMWARE.FW_HASH_SUPPORTED_VERSIONS) && !params.binary;
|
|
285
|
-
let check;
|
|
286
261
|
const installedVersion = reconnectedDevice.getVersion();
|
|
287
262
|
if (!bootloaderVersion || !installedVersion) {
|
|
288
263
|
throw constants_1.ERRORS.TypedError('Runtime', 'reconnectedDevice.installedVersion is not set');
|
|
@@ -290,35 +265,13 @@ const onCallFirmwareUpdate = async ({ params, context: { deviceList, postMessage
|
|
|
290
265
|
const { binaryVersion, releaseVersion } = binaryInfo;
|
|
291
266
|
const assertBinaryVersion = (0, versionUtils_1.isEqual)(installedVersion, binaryVersion);
|
|
292
267
|
const assertReleaseVersion = releaseVersion ? (0, versionUtils_1.isEqual)(installedVersion, releaseVersion) : true;
|
|
293
|
-
|
|
268
|
+
return {
|
|
294
269
|
versionCheck: assertBinaryVersion && assertReleaseVersion,
|
|
295
270
|
bootloaderVersion,
|
|
296
271
|
installedVersion,
|
|
297
272
|
binaryVersion,
|
|
298
273
|
releaseVersion,
|
|
299
274
|
};
|
|
300
|
-
if (checkSupported) {
|
|
301
|
-
try {
|
|
302
|
-
log.debug('onCallFirmwareUpdate', 'getFirmwareHash supported, proceed with check', stripped);
|
|
303
|
-
const isValid = await firmwareCheck(reconnectedDevice, device, stripped, postMessage);
|
|
304
|
-
await reconnectedDevice.release();
|
|
305
|
-
if (isValid) {
|
|
306
|
-
log.debug('onCallFirmwareUpdate', 'installed fw hash and calculated hash match');
|
|
307
|
-
check = 'valid';
|
|
308
|
-
}
|
|
309
|
-
else {
|
|
310
|
-
check = 'mismatch';
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
catch (err) {
|
|
314
|
-
return { check: 'other-error', checkError: err.message, ...versionDetails };
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
else {
|
|
318
|
-
await reconnectedDevice.release();
|
|
319
|
-
check = 'omitted';
|
|
320
|
-
}
|
|
321
|
-
return { check, ...versionDetails };
|
|
322
275
|
};
|
|
323
276
|
exports.onCallFirmwareUpdate = onCallFirmwareUpdate;
|
|
324
277
|
//# sourceMappingURL=onCallFirmwareUpdate.js.map
|
package/lib/data/DataManager.js
CHANGED
|
@@ -10,6 +10,9 @@ const firmwareInfo_1 = require("./firmwareInfo");
|
|
|
10
10
|
const types_1 = require("../types");
|
|
11
11
|
const assetUtils_1 = require("../utils/assetUtils");
|
|
12
12
|
class DataManager {
|
|
13
|
+
static assets = {};
|
|
14
|
+
static settings;
|
|
15
|
+
static messages = messages_json_1.default;
|
|
13
16
|
static load(settings, withAssets = true) {
|
|
14
17
|
this.settings = settings;
|
|
15
18
|
if (!withAssets)
|
|
@@ -48,6 +51,4 @@ class DataManager {
|
|
|
48
51
|
}
|
|
49
52
|
}
|
|
50
53
|
exports.DataManager = DataManager;
|
|
51
|
-
DataManager.assets = {};
|
|
52
|
-
DataManager.messages = messages_json_1.default;
|
|
53
54
|
//# sourceMappingURL=DataManager.js.map
|
|
@@ -4,7 +4,6 @@ exports.enhanceMessageWithAnalytics = void 0;
|
|
|
4
4
|
const connect_analytics_1 = require("@trezor/connect-analytics");
|
|
5
5
|
const events_1 = require("../events");
|
|
6
6
|
const enhanceMessageWithAnalytics = (message, data) => {
|
|
7
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
8
7
|
switch (message.type) {
|
|
9
8
|
case events_1.UI_REQUEST.REQUEST_CONFIRMATION: {
|
|
10
9
|
const { device } = data;
|
|
@@ -15,16 +14,16 @@ const enhanceMessageWithAnalytics = (message, data) => {
|
|
|
15
14
|
analytics: {
|
|
16
15
|
type: connect_analytics_1.EventType.DeviceSelected,
|
|
17
16
|
payload: {
|
|
18
|
-
mode:
|
|
19
|
-
pinProtection:
|
|
20
|
-
passphraseProtection:
|
|
21
|
-
backupType:
|
|
22
|
-
language:
|
|
23
|
-
model:
|
|
24
|
-
vendor:
|
|
25
|
-
firmwareRevision:
|
|
26
|
-
firmwareType:
|
|
27
|
-
bootloaderHash:
|
|
17
|
+
mode: device?.mode || '',
|
|
18
|
+
pinProtection: device?.features?.pin_protection || '',
|
|
19
|
+
passphraseProtection: device?.features?.passphrase_protection || '',
|
|
20
|
+
backupType: device?.features?.backup_type || 'Bip39',
|
|
21
|
+
language: device?.features?.language || '',
|
|
22
|
+
model: device?.features?.internal_model || '',
|
|
23
|
+
vendor: device?.features?.vendor || '',
|
|
24
|
+
firmwareRevision: device?.features?.revision || '',
|
|
25
|
+
firmwareType: device?.firmwareType || '',
|
|
26
|
+
bootloaderHash: device?.features?.bootloader_hash || '',
|
|
28
27
|
},
|
|
29
28
|
},
|
|
30
29
|
},
|
|
@@ -50,7 +50,6 @@ const corsValidator = (url) => {
|
|
|
50
50
|
};
|
|
51
51
|
exports.corsValidator = corsValidator;
|
|
52
52
|
const parseConnectSettings = (input = {}) => {
|
|
53
|
-
var _a;
|
|
54
53
|
const settings = { ...initialSettings };
|
|
55
54
|
if ('debug' in input) {
|
|
56
55
|
if (typeof input.debug === 'boolean') {
|
|
@@ -63,7 +62,7 @@ const parseConnectSettings = (input = {}) => {
|
|
|
63
62
|
if (input.trustedHost === false) {
|
|
64
63
|
settings.trustedHost = input.trustedHost;
|
|
65
64
|
}
|
|
66
|
-
if (typeof input.connectSrc === 'string' &&
|
|
65
|
+
if (typeof input.connectSrc === 'string' && input.connectSrc?.startsWith('http')) {
|
|
67
66
|
settings.connectSrc = (0, exports.corsValidator)(input.connectSrc);
|
|
68
67
|
}
|
|
69
68
|
else if (settings.trustedHost) {
|
|
@@ -21,13 +21,10 @@ const EVM_GAS_PRICE_PER_CHAIN_IN_GWEI = {
|
|
|
21
21
|
arb: { min: 0.001, max: 1000, defaultGas: 0.01 },
|
|
22
22
|
op: { min: 0.000000001, max: 1000, defaultGas: 0.01 },
|
|
23
23
|
};
|
|
24
|
-
const getEvmChainGweiGasPrice = (chain) => {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
max: 10000,
|
|
29
|
-
defaultGas: 5,
|
|
30
|
-
};
|
|
24
|
+
const getEvmChainGweiGasPrice = (chain) => EVM_GAS_PRICE_PER_CHAIN_IN_GWEI[chain] ?? {
|
|
25
|
+
min: 0.000000001,
|
|
26
|
+
max: 10000,
|
|
27
|
+
defaultGas: 5,
|
|
31
28
|
};
|
|
32
29
|
const getBitcoinFeeLevels = (coin) => {
|
|
33
30
|
const defaultFees = coin.default_fee_b;
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.deviceAuthenticityConfig = void 0;
|
|
4
4
|
exports.deviceAuthenticityConfig = {
|
|
5
5
|
version: 1,
|
|
6
|
-
timestamp: '
|
|
6
|
+
timestamp: '2025-02-06T12:00:00.000Z',
|
|
7
7
|
T2B1: {
|
|
8
8
|
rootPubKeys: [
|
|
9
9
|
'04ca97480ac0d7b1e6efafe518cd433cec2bf8ab9822d76eafd34363b55d63e60380bff20acc75cde03cffcb50ab6f8ce70c878e37ebc58ff7cca0a83b16b15fa5',
|
|
@@ -75,6 +75,12 @@ exports.deviceAuthenticityConfig = {
|
|
|
75
75
|
'0424759a6f4f2bd7ba1c32830c4260248fab48549c7b53b373fcf7d2a881f8198cae63f3d80028596f5f78073251b022c3ff0a7273e2b63e8d2cda0556b416f3d3',
|
|
76
76
|
'04ca8ae9f668b58e0ca4f14a5681d60e8dba7404192c034256304bc26fc6f059ef50fbc9667b7df704ef5010c788534e2416451b282f49ce0f75c64b5e23faac8a',
|
|
77
77
|
'04f02f0ec41b2a19ce25b954f2a915035f45ce592f7d1f2252a41aa9dd7bcbb6a0be9442a3946ee9aa900c1201c595140999d445d912755bd75da070a1a2b7fac7',
|
|
78
|
+
'04256936d48d9b60713b65f73a078cb8564f150e3986dfbf396d59b8b2a82cb8b6e33c145642d2993cbd6fa1d0e3efddc23d1b802fa786bb3e287f992d0079b66a',
|
|
79
|
+
'04a4184699bf9965477f8c501dfc1649c536e5ec6642fc94c1e5503c153fd0caf292ae7fc9ece20b21cf5b754efe00fa1735a1d9171ae75a040f3f55b71fa83ddd',
|
|
80
|
+
'04ffa3c5c61bf0065d053fd6f0ed8ffdddc6816ff7efa7aa30c04141522f067626f387167f0d7e6586b9ade993c5b7c33840df45db9230ed6ad31a5550bd109a36',
|
|
81
|
+
'04476f0184085862bd38a7f39ef03be6915d7c1b0626c263f6f6c9bc5575c41f81f77d9c69eb16ce8ad7b0d11f3de937931adc9f35ea1f007b81a571ae036ef8c3',
|
|
82
|
+
'046ecbbc4316c0a1247b91103a6f2a3bbd746c04bf47c9ea52dce3735c8ba04df088d3ce66cc8fea0063c344268e03f9d7cce35c8381747d4df4ba4491a178c382',
|
|
83
|
+
'04c341d6af7e960f4c2926035d1f7f8164be244e87742924ef0dddf430e89521846673ed009884146042b79b02dd00c7a2d708f6dc33d43cc6d5073edc17a71376',
|
|
78
84
|
],
|
|
79
85
|
debug: {
|
|
80
86
|
rootPubKeys: [],
|
|
@@ -113,6 +119,15 @@ exports.deviceAuthenticityConfig = {
|
|
|
113
119
|
'040f69618522bcdc4f4dbc8705d45fae21cc6305dfa4c8244382b057f359fb6042b4888474176dbd921fef937ba9aa1f3800012f9d325be81d8db454b249107106',
|
|
114
120
|
'049d8c7af7ea30b6baabf692f69980c0a3d388fdfde905e46ce535b39915b8c6f2c07a643c7a046029d27f58643423cd5a798caa6df3ee11d5d5e9dfdc7a61ed16',
|
|
115
121
|
'04eddb271cbe838a96cab86fdd19dc2bdfb466ab7c62f1ef834554bc7c9e6c1136dc093b732d55d28346ba306f80cf6c1ba980402d762dba15457a9b3025223bd7',
|
|
122
|
+
'043306644c3934ca5540cfd061a59bbf2f9c6842de588baf83f35e4e537a4b06dd284488e15055ecdaa5a68c05448542695b893009f9021a04110f86d6a6dbbc52',
|
|
123
|
+
'0483d95889c24f5e00f98803d82246eb43aefaa7fb3641750dc60cb45d0df350d1ca71f759d0b1e8f75ffa7c09ed53f17f492890a2529b396e3158a1a2802a4207',
|
|
124
|
+
'04dfab03c1e3e2c56c9c5a2aca3a65d6106e75a6364550a76e6c05e8310cbf7a6cb5e1ab6bfbce75019dc2d2a742251da8ad34689f48d163b6daac2b8f63c3b2b0',
|
|
125
|
+
'0430784bf46bdc12f9478c58355b05976569a603cfc9425f97fba52d0302d2a425c83e15a848e2d20100b439182064a135d287dcda7004f86219557be3c314d91a',
|
|
126
|
+
'043dc0a6be47922777363845c71d77ed41a739e570f6a2ccc44650386accd3a64e7b6196fc93cd93dbd0fcfb8e79537f07f5bf0e197b80e00559bc08bb881940e3',
|
|
127
|
+
'04aebb2ca7ead04b17af733cf94339f31386db629310054d6af5c696a0693e4afc7ab414422562f9a7312783e28833c2802c1cefb96af0a8528f12f5d395c82c05',
|
|
128
|
+
'045f5f8c0f6665149630f001871e0f5baec0633d3452da2f6c0b5a6585429525e47704eb79b2dfb8a628e429016a8f426ead61e8623be69d242553c4d67725c4f0',
|
|
129
|
+
'0459a992145ffbe5f18123380427208dc940fc946648530e516328e3b511a1fc8e920287e51aa1bbae5d015587164acabe52b04d4d48cab2d8b0415b651ffb372f',
|
|
130
|
+
'040925ae014e1fc43bdaadb1a2596f69bb5ea6bb42e8c295600940607788b2673d89eba89a0a3a2c8e46a66356f45e462f5bd84fc0254dae37c2543a837701587e',
|
|
116
131
|
],
|
|
117
132
|
debug: {
|
|
118
133
|
rootPubKeys: [
|
package/lib/data/firmwareInfo.js
CHANGED
|
@@ -7,9 +7,8 @@ const firmwareUtils_1 = require("../utils/firmwareUtils");
|
|
|
7
7
|
const releases = Object.values(types_1.DeviceModelInternal).reduce((acc, key) => ({ ...acc, [key]: [] }), {});
|
|
8
8
|
const parseFirmware = (json, deviceModel) => {
|
|
9
9
|
Object.keys(json).forEach(key => {
|
|
10
|
-
var _a;
|
|
11
10
|
const release = json[key];
|
|
12
|
-
|
|
11
|
+
releases[deviceModel]?.push({
|
|
13
12
|
...release,
|
|
14
13
|
});
|
|
15
14
|
});
|
|
@@ -60,7 +59,7 @@ const getT1BootloaderVersion = (releases2, features) => {
|
|
|
60
59
|
return versionArray;
|
|
61
60
|
}
|
|
62
61
|
const release = releases2.find(({ version }) => utils_1.versionUtils.isEqual(version, versionArray));
|
|
63
|
-
return
|
|
62
|
+
return release?.bootloader_version || [1, 0, 0];
|
|
64
63
|
};
|
|
65
64
|
const getIntermediaryVersion = (releases2, features, offerLatest) => {
|
|
66
65
|
if (features.major_version !== 1 || offerLatest) {
|
|
@@ -120,7 +119,7 @@ const getInfo = ({ features, releases }) => {
|
|
|
120
119
|
isRequired: isRequired(changelog),
|
|
121
120
|
isNewer: isNewerResult,
|
|
122
121
|
intermediaryVersion,
|
|
123
|
-
translations: isNewerResult ? prevRelease
|
|
122
|
+
translations: isNewerResult ? prevRelease?.translations : release?.translations,
|
|
124
123
|
};
|
|
125
124
|
};
|
|
126
125
|
exports.getInfo = getInfo;
|
|
@@ -133,7 +132,7 @@ const getFirmwareStatus = (features) => {
|
|
|
133
132
|
}
|
|
134
133
|
const info = (0, exports.getInfo)({
|
|
135
134
|
features,
|
|
136
|
-
releases: (0, exports.getReleases)(features
|
|
135
|
+
releases: (0, exports.getReleases)(features?.internal_model),
|
|
137
136
|
});
|
|
138
137
|
if (!info)
|
|
139
138
|
return 'custom';
|
|
@@ -146,7 +145,7 @@ const getFirmwareStatus = (features) => {
|
|
|
146
145
|
exports.getFirmwareStatus = getFirmwareStatus;
|
|
147
146
|
const getRelease = (features) => (0, exports.getInfo)({
|
|
148
147
|
features,
|
|
149
|
-
releases: (0, exports.getReleases)(features
|
|
148
|
+
releases: (0, exports.getReleases)(features?.internal_model),
|
|
150
149
|
});
|
|
151
150
|
exports.getRelease = getRelease;
|
|
152
151
|
//# sourceMappingURL=firmwareInfo.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.DEEPLINK_VERSION = exports.CONTENT_SCRIPT_VERSION = exports.DEFAULT_DOMAIN = exports.VERSION = void 0;
|
|
4
|
-
exports.VERSION = '9.
|
|
4
|
+
exports.VERSION = '9.5.0-beta.1';
|
|
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
|
@@ -130,7 +130,11 @@ export declare class Device extends TypedEmitter<DeviceEvents> {
|
|
|
130
130
|
private getSessionChangePromise;
|
|
131
131
|
private waitAndCompareSession;
|
|
132
132
|
acquire(): import("@trezor/transport/lib/types").AsyncResultWithTypedError<Session, "Network request failed" | "Wrong result type." | "device disconnected during action" | "unexpected error" | "Aborted by timeout" | "Aborted by signal" | "This transport can not be used in this environment" | "device not found" | "Unable to open device" | "descriptor not found" | "wrong previous session" | "LIBUSB_ERROR_ACCESS">;
|
|
133
|
-
release(): Promise<import("@trezor/transport/lib/types").Success<null> |
|
|
133
|
+
release(): Promise<import("@trezor/transport/lib/types").Success<null> | {
|
|
134
|
+
success: false;
|
|
135
|
+
error: "session not found" | "Network request failed" | "Wrong result type." | "device disconnected during action" | "unexpected error" | "Aborted by timeout" | "Aborted by signal" | "This transport can not be used in this environment" | "device not found" | "Unable to open device" | "wrong previous session";
|
|
136
|
+
message?: string;
|
|
137
|
+
} | undefined>;
|
|
134
138
|
releaseTransportSession(): void;
|
|
135
139
|
cleanup(release?: boolean): Promise<void>;
|
|
136
140
|
handshake(delay?: number): Promise<void>;
|
|
@@ -185,7 +189,11 @@ export declare class Device extends TypedEmitter<DeviceEvents> {
|
|
|
185
189
|
getUniquePath(): DeviceUniquePath;
|
|
186
190
|
isT1(): boolean;
|
|
187
191
|
hasUnexpectedMode(allow: string[], require: string[]): "ui-device_bootloader_mode" | "ui-device_not_in_bootloader_mode" | "ui-device_not_initialized" | "ui-device_seedless" | null;
|
|
188
|
-
dispose(): Promise<import("@trezor/transport/lib/types").Success<null> |
|
|
192
|
+
dispose(): Promise<import("@trezor/transport/lib/types").Success<null> | {
|
|
193
|
+
success: false;
|
|
194
|
+
error: "session not found" | "Network request failed" | "Wrong result type." | "device disconnected during action" | "unexpected error" | "Aborted by timeout" | "Aborted by signal" | "This transport can not be used in this environment" | "device not found" | "Unable to open device" | "wrong previous session";
|
|
195
|
+
message?: string;
|
|
196
|
+
} | undefined>;
|
|
189
197
|
private getMode;
|
|
190
198
|
toMessageObject(): DeviceTyped;
|
|
191
199
|
}
|