@trezor/connect 9.6.2-beta.3 → 9.6.3-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.
Files changed (139) hide show
  1. package/CHANGELOG.md +15 -6
  2. package/README.md +1 -1
  3. package/lib/api/applySettings.js +16 -1
  4. package/lib/api/bitcoin/signtx.d.ts +2 -2
  5. package/lib/api/bitcoin/signtx.js +1 -1
  6. package/lib/api/bleUnpair.js +0 -1
  7. package/lib/api/cardano/api/cardanoGetAddress.d.ts +1 -0
  8. package/lib/api/cardano/api/cardanoSignMessage.d.ts +25 -0
  9. package/lib/api/cardano/api/cardanoSignMessage.js +97 -0
  10. package/lib/api/cardano/api/index.d.ts +1 -0
  11. package/lib/api/cardano/api/index.js +3 -1
  12. package/lib/api/cardano/cardanoUtils.d.ts +1 -1
  13. package/lib/api/cardano/cardanoUtils.js +2 -2
  14. package/lib/api/discoverAccounts.js +61 -33
  15. package/lib/api/ethereum/api/ethereumGetAddress.js +1 -0
  16. package/lib/api/ethereum/api/ethereumSignTransaction.js +22 -4
  17. package/lib/api/ethereum/ethereumSignTx.d.ts +3 -2
  18. package/lib/api/ethereum/ethereumSignTx.js +4 -2
  19. package/lib/api/evoluGetNode.d.ts +11 -0
  20. package/lib/api/evoluGetNode.js +26 -0
  21. package/lib/api/firmware/calculateFirmwareHash.d.ts +2 -1
  22. package/lib/api/firmware/calculateFirmwareHash.js +17 -4
  23. package/lib/api/firmware/getBinary.d.ts +7 -6
  24. package/lib/api/firmware/getBinary.js +18 -6
  25. package/lib/api/firmware/index.d.ts +0 -2
  26. package/lib/api/firmware/index.js +1 -5
  27. package/lib/api/firmware/uploadFirmware.d.ts +10 -1
  28. package/lib/api/firmware/uploadFirmware.js +8 -7
  29. package/lib/api/getFeatures.d.ts +2 -1
  30. package/lib/api/index.d.ts +3 -0
  31. package/lib/api/index.js +8 -2
  32. package/lib/api/nem/nemSignTx.d.ts +1 -1
  33. package/lib/api/pushTransaction.d.ts +2 -1
  34. package/lib/api/pushTransaction.js +2 -1
  35. package/lib/api/resetDevice.js +2 -1
  36. package/lib/api/ripple/api/rippleGetAddress.d.ts +1 -0
  37. package/lib/api/signMessage.js +1 -1
  38. package/lib/api/signTransaction.d.ts +1 -1
  39. package/lib/api/solana/api/solanaGetAddress.d.ts +1 -0
  40. package/lib/api/solana/api/solanaGetPublicKey.d.ts +2 -0
  41. package/lib/api/solana/api/solanaGetPublicKey.js +3 -0
  42. package/lib/api/stellar/api/stellarGetAddress.d.ts +1 -0
  43. package/lib/api/tezos/api/tezosGetAddress.d.ts +1 -0
  44. package/lib/api/tezos/tezosSignTx.d.ts +1 -1
  45. package/lib/api/thpGetCredentials.d.ts +10 -0
  46. package/lib/api/thpGetCredentials.js +31 -0
  47. package/lib/api/thpRemoveCredentials.d.ts +8 -0
  48. package/lib/api/thpRemoveCredentials.js +32 -0
  49. package/lib/api/wipeDevice.js +6 -2
  50. package/lib/backend/Blockchain.d.ts +4 -4
  51. package/lib/backend/Blockchain.js +12 -11
  52. package/lib/constants/cardano.d.ts +3 -0
  53. package/lib/constants/cardano.js +5 -1
  54. package/lib/constants/errors.d.ts +12 -9
  55. package/lib/constants/errors.js +18 -24
  56. package/lib/core/AbstractMethod.d.ts +5 -24
  57. package/lib/core/AbstractMethod.js +2 -2
  58. package/lib/core/index.js +5 -1
  59. package/lib/core/onCallFirmwareUpdate.d.ts +13 -1
  60. package/lib/core/onCallFirmwareUpdate.js +158 -94
  61. package/lib/data/DataManager.d.ts +13 -1
  62. package/lib/data/DataManager.js +44 -14
  63. package/lib/data/coinInfo.d.ts +8 -84
  64. package/lib/data/coinInfo.js +6 -9
  65. package/lib/data/config.d.ts +26 -192
  66. package/lib/data/config.js +37 -1
  67. package/lib/data/connectSettings.js +7 -0
  68. package/lib/data/defaultFeeLevels.js +2 -1
  69. package/lib/data/deviceAuthenticityConfig.js +10 -1
  70. package/lib/data/firmwareInfo.d.ts +44 -11
  71. package/lib/data/firmwareInfo.js +360 -122
  72. package/lib/data/thpSettings.js +5 -2
  73. package/lib/data/version.d.ts +2 -1
  74. package/lib/data/version.js +4 -3
  75. package/lib/device/Device.d.ts +17 -7
  76. package/lib/device/Device.js +72 -115
  77. package/lib/device/DeviceCommands.d.ts +1 -0
  78. package/lib/device/DeviceCurrentSession.d.ts +41 -20
  79. package/lib/device/DeviceCurrentSession.js +18 -22
  80. package/lib/device/TransportList.js +10 -5
  81. package/lib/device/checkFirmwareRevision.d.ts +3 -2
  82. package/lib/device/checkFirmwareRevision.js +6 -11
  83. package/lib/device/thp/handshake.d.ts +4 -0
  84. package/lib/device/thp/handshake.js +88 -0
  85. package/lib/device/thp/index.d.ts +4 -1
  86. package/lib/device/thp/index.js +24 -6
  87. package/lib/device/thp/pairing.d.ts +16 -0
  88. package/lib/device/thp/pairing.js +230 -0
  89. package/lib/device/thp/session.d.ts +3 -0
  90. package/lib/device/thp/session.js +27 -0
  91. package/lib/device/thp/thpCall.d.ts +41 -0
  92. package/lib/device/thp/thpCall.js +57 -0
  93. package/lib/device/workflow/checkFirmwareHash.d.ts +10 -0
  94. package/lib/device/workflow/checkFirmwareHash.js +79 -0
  95. package/lib/device/workflow/checkFirmwareHashWithRetries.d.ts +9 -0
  96. package/lib/device/workflow/checkFirmwareHashWithRetries.js +41 -0
  97. package/lib/device/workflow/handshake.js +7 -6
  98. package/lib/device/workflow/validateState.js +53 -10
  99. package/lib/events/ui-request.d.ts +1 -1
  100. package/lib/factory.js +4 -0
  101. package/lib/tsconfig.lib.tsbuildinfo +1 -1
  102. package/lib/types/api/bitcoin/index.d.ts +1 -1
  103. package/lib/types/api/cardano/index.d.ts +62 -1
  104. package/lib/types/api/cardano/index.js +30 -1
  105. package/lib/types/api/cardanoSignMessage.d.ts +4 -0
  106. package/lib/types/api/cardanoSignMessage.js +3 -0
  107. package/lib/types/api/discoverAccounts.d.ts +17 -12
  108. package/lib/types/api/ethereum/index.d.ts +108 -0
  109. package/lib/types/api/ethereum/index.js +3 -0
  110. package/lib/types/api/evoluGetNode.d.ts +4 -0
  111. package/lib/types/api/evoluGetNode.js +3 -0
  112. package/lib/types/api/index.d.ts +8 -0
  113. package/lib/types/api/pushTransaction.d.ts +4 -1
  114. package/lib/types/api/pushTransaction.js +7 -1
  115. package/lib/types/api/solana/index.d.ts +3 -0
  116. package/lib/types/api/solana/index.js +2 -0
  117. package/lib/types/api/thpGetCredentials.d.ts +4 -0
  118. package/lib/types/api/thpGetCredentials.js +3 -0
  119. package/lib/types/api/thpRemoveCredentials.d.ts +7 -0
  120. package/lib/types/api/thpRemoveCredentials.js +3 -0
  121. package/lib/types/device.d.ts +9 -9
  122. package/lib/types/firmware.d.ts +15 -12
  123. package/lib/types/firmware.js +0 -3
  124. package/lib/types/params.d.ts +1 -0
  125. package/lib/types/settings.d.ts +7 -0
  126. package/lib/utils/assetUtils.d.ts +5 -2
  127. package/lib/utils/assetUtils.js +14 -18
  128. package/lib/utils/assets.native.js +0 -2
  129. package/lib/utils/firmwareReleaseConfigUtils.d.ts +8 -5
  130. package/lib/utils/firmwareReleaseConfigUtils.js +74 -59
  131. package/lib/utils/firmwareUtils.d.ts +8 -4
  132. package/lib/utils/firmwareUtils.js +62 -20
  133. package/lib/utils/formatUtils.d.ts +1 -0
  134. package/lib/utils/formatUtils.js +3 -2
  135. package/package.json +19 -18
  136. package/lib/api/firmware/getBinaryForFirmwareUpgrade.d.ts +0 -12
  137. package/lib/api/firmware/getBinaryForFirmwareUpgrade.js +0 -32
  138. package/lib/data/getLanguage.d.ts +0 -6
  139. package/lib/data/getLanguage.js +0 -10
@@ -1,3 +1,4 @@
1
+ import { FirmwareRelease } from '@trezor/device-utils';
1
2
  import { TransportProtocol, thp as protocolThp } from '@trezor/protocol';
2
3
  import { Session } from '@trezor/transport';
3
4
  import { type Descriptor, type Transport } from '@trezor/transport';
@@ -6,7 +7,7 @@ import { PROTO } from '../constants';
6
7
  import { TypedCallProvider } from './DeviceCurrentSession';
7
8
  import { IStateStorage } from './StateStorage';
8
9
  import { DEVICE, DeviceButtonRequestPayload, DeviceThpCredentialsChangedPayload, DeviceThpPairingPayload, DeviceVersionChanged, UiResponsePassphrase, UiResponsePin, UiResponseThpPairingTag, UiResponseWord } from '../events';
9
- import { DeviceFirmwareStatus, DeviceState, Device as DeviceTyped, DeviceUniquePath, FirmwareType, ReleaseInfo, UnavailableCapabilities, VersionArray } from '../types';
10
+ import { DeviceFirmwareStatus, DeviceState, Device as DeviceTyped, DeviceUniquePath, FirmwareHashCheckResult, FirmwareReleaseConfigInfo, FirmwareType, UnavailableCapabilities, VersionArray } from '../types';
10
11
  type RunOptions = {
11
12
  skipFinalReload?: boolean;
12
13
  keepSession?: boolean;
@@ -71,12 +72,14 @@ export declare class Device extends TypedEmitter<DeviceEvents> {
71
72
  private unreadableError?;
72
73
  private _firmwareStatus;
73
74
  get firmwareStatus(): DeviceFirmwareStatus;
74
- private _firmwareRelease?;
75
- get firmwareRelease(): ReleaseInfo | null | undefined;
75
+ private _currentRelease?;
76
+ get currentRelease(): FirmwareRelease | undefined;
77
+ private _firmwareReleaseConfigInfo?;
78
+ get firmwareReleaseConfigInfo(): FirmwareReleaseConfigInfo | undefined;
76
79
  private _features;
77
80
  get features(): {
78
- _passphrase_cached?: boolean | undefined;
79
81
  busy?: boolean | undefined;
82
+ _passphrase_cached?: boolean | undefined;
80
83
  homescreen_format?: "Toif" | "Jpeg" | "ToiG" | undefined;
81
84
  hide_passphrase_from_host?: boolean | undefined;
82
85
  unit_color?: number | undefined;
@@ -89,6 +92,7 @@ export declare class Device extends TypedEmitter<DeviceEvents> {
89
92
  haptic_feedback?: boolean | undefined;
90
93
  recovery_type?: "NormalRecovery" | "DryRun" | "UnlockRepeatedBackup" | undefined;
91
94
  optiga_sec?: number | undefined;
95
+ soc?: number | undefined;
92
96
  vendor: string;
93
97
  major_version: number;
94
98
  minor_version: number;
@@ -138,6 +142,7 @@ export declare class Device extends TypedEmitter<DeviceEvents> {
138
142
  private instance;
139
143
  private state;
140
144
  private stateStorage?;
145
+ private busy?;
141
146
  private _unavailableCapabilities;
142
147
  get unavailableCapabilities(): Readonly<UnavailableCapabilities>;
143
148
  private _firmwareType?;
@@ -201,6 +206,7 @@ export declare class Device extends TypedEmitter<DeviceEvents> {
201
206
  xpub: string;
202
207
  }>;
203
208
  ethereumGetAddress: (params: PROTO.EthereumGetAddress) => Promise<{
209
+ mac?: string | undefined;
204
210
  _old_address?: string | undefined;
205
211
  address: string;
206
212
  }>;
@@ -233,8 +239,11 @@ export declare class Device extends TypedEmitter<DeviceEvents> {
233
239
  initialize(useCardanoDerivation: boolean): Promise<void>;
234
240
  initStorage(storage: IStateStorage): void;
235
241
  getFeatures(): Promise<void>;
236
- private checkFirmwareHashWithRetries;
237
- private checkFirmwareHash;
242
+ getAuthenticityChecks(): {
243
+ firmwareRevision: import("../types").FirmwareRevisionCheckResult | null;
244
+ firmwareHash: FirmwareHashCheckResult | null;
245
+ };
246
+ setAuthenticityChecks(firmwareHash: FirmwareHashCheckResult | null): void;
238
247
  private checkFirmwareRevisionWithRetries;
239
248
  private checkFirmwareRevision;
240
249
  changeLanguage({ language, binary, }: {
@@ -247,6 +256,7 @@ export declare class Device extends TypedEmitter<DeviceEvents> {
247
256
  message: string;
248
257
  }>;
249
258
  private _uploadTranslationData;
259
+ private _updateCurrentRelease;
250
260
  private _updateFeatures;
251
261
  prompt<T extends typeof DEVICE.PIN | typeof DEVICE.PASSPHRASE | typeof DEVICE.WORD | typeof DEVICE.THP_PAIRING>(type: T, args: Omit<DeviceEvents[T], 'callback'>): Promise<Parameters<DeviceEvents[T]["callback"]>[0]>;
252
262
  isUnacquired(): boolean;
@@ -263,7 +273,7 @@ export declare class Device extends TypedEmitter<DeviceEvents> {
263
273
  getUniquePath(): DeviceUniquePath;
264
274
  isT1(): boolean;
265
275
  hasUnexpectedMode(allow: string[], require: string[]): "ui-device_bootloader_mode" | "ui-device_not_in_bootloader_mode" | "ui-device_not_initialized" | "ui-device_seedless" | null;
266
- private getMode;
276
+ private getStatus;
267
277
  toMessageObject(): DeviceTyped;
268
278
  }
269
279
  export {};
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Device = void 0;
4
- const crypto_1 = require("crypto");
5
4
  const device_utils_1 = require("@trezor/device-utils");
6
5
  const protocol_1 = require("@trezor/protocol");
7
6
  const transport_1 = require("@trezor/transport");
@@ -11,16 +10,15 @@ const constants_1 = require("../constants");
11
10
  const DeviceCurrentSession_1 = require("./DeviceCurrentSession");
12
11
  const checkFirmwareRevision_1 = require("./checkFirmwareRevision");
13
12
  const thp_1 = require("./thp");
14
- const firmware_1 = require("../api/firmware");
15
- const DataManager_1 = require("../data/DataManager");
13
+ const checkFirmwareHashWithRetries_1 = require("./workflow/checkFirmwareHashWithRetries");
16
14
  const coinInfo_1 = require("../data/coinInfo");
17
15
  const firmwareInfo_1 = require("../data/firmwareInfo");
18
- const getLanguage_1 = require("../data/getLanguage");
19
16
  const events_1 = require("../events");
20
- const types_1 = require("../types");
21
17
  const handshake_1 = require("./workflow/handshake");
18
+ const assetUtils_1 = require("../utils/assetUtils");
22
19
  const debug_1 = require("../utils/debug");
23
20
  const deviceFeaturesUtils_1 = require("../utils/deviceFeaturesUtils");
21
+ const firmwareUtils_1 = require("../utils/firmwareUtils");
24
22
  const _log = (0, debug_1.initLog)('Device');
25
23
  class Device extends utils_1.TypedEmitter {
26
24
  transport;
@@ -41,9 +39,13 @@ class Device extends utils_1.TypedEmitter {
41
39
  get firmwareStatus() {
42
40
  return this._firmwareStatus;
43
41
  }
44
- _firmwareRelease;
45
- get firmwareRelease() {
46
- return this._firmwareRelease;
42
+ _currentRelease;
43
+ get currentRelease() {
44
+ return this._currentRelease;
45
+ }
46
+ _firmwareReleaseConfigInfo;
47
+ get firmwareReleaseConfigInfo() {
48
+ return this._firmwareReleaseConfigInfo;
47
49
  }
48
50
  _features;
49
51
  get features() {
@@ -59,6 +61,7 @@ class Device extends utils_1.TypedEmitter {
59
61
  instance = 0;
60
62
  state = [];
61
63
  stateStorage = undefined;
64
+ busy;
62
65
  _unavailableCapabilities = {};
63
66
  get unavailableCapabilities() {
64
67
  return this._unavailableCapabilities;
@@ -69,7 +72,7 @@ class Device extends utils_1.TypedEmitter {
69
72
  }
70
73
  name = 'Trezor';
71
74
  color;
72
- availableTranslations = [];
75
+ availableTranslations = {};
73
76
  authenticityChecks = {
74
77
  firmwareRevision: null,
75
78
  firmwareHash: null,
@@ -256,6 +259,7 @@ class Device extends utils_1.TypedEmitter {
256
259
  return this.runPromise;
257
260
  }
258
261
  async interrupt(reason) {
262
+ await (0, thp_1.abortThpWorkflow)(this, () => this.runAbort?.abort(reason));
259
263
  await this.currentSession?.abort(reason);
260
264
  this.runAbort?.abort(reason);
261
265
  await this.currentRun;
@@ -290,6 +294,9 @@ class Device extends utils_1.TypedEmitter {
290
294
  if (this.protocol.name === 'v2') {
291
295
  const withInteraction = !!fn;
292
296
  await (0, thp_1.getThpChannel)(this, withInteraction);
297
+ if (this.getThpState()?.isAutoconnectPaired || withInteraction) {
298
+ await this.getFeatures();
299
+ }
293
300
  }
294
301
  else if (fn) {
295
302
  await this.initialize(!!options.useCardanoDerivation);
@@ -297,9 +304,13 @@ class Device extends utils_1.TypedEmitter {
297
304
  else {
298
305
  await this.getFeatures();
299
306
  }
307
+ this.busy = false;
300
308
  }
301
309
  catch (error) {
302
310
  _log.warn('Device._runInner error: ', error.message);
311
+ if (error.code === 'Failure_Busy') {
312
+ this.busy = true;
313
+ }
303
314
  if (error.code === 'Device_ThpPairingTagInvalid') {
304
315
  return Promise.reject(error);
305
316
  }
@@ -307,7 +318,7 @@ class Device extends utils_1.TypedEmitter {
307
318
  }
308
319
  }
309
320
  if (!options.skipFirmwareChecks) {
310
- await this.checkFirmwareHashWithRetries();
321
+ await (0, checkFirmwareHashWithRetries_1.checkFirmwareHashWithRetries)({ device: this, logger: _log });
311
322
  await this.checkFirmwareRevisionWithRetries();
312
323
  }
313
324
  if (!options.skipLanguageChecks &&
@@ -388,6 +399,7 @@ class Device extends utils_1.TypedEmitter {
388
399
  }
389
400
  const { message } = await this.getCurrentSession().typedCall('Initialize', 'Features', payload);
390
401
  this._updateFeatures(message);
402
+ this._updateCurrentRelease(message);
391
403
  this.setState({ deriveCardano: payload?.derive_cardano });
392
404
  }
393
405
  initStorage(storage) {
@@ -397,74 +409,13 @@ class Device extends utils_1.TypedEmitter {
397
409
  async getFeatures() {
398
410
  const { message } = await this.getCurrentSession().typedCall('GetFeatures', 'Features', {});
399
411
  this._updateFeatures(message);
412
+ this._updateCurrentRelease(message);
400
413
  }
401
- async checkFirmwareHashWithRetries() {
402
- const lastResult = this.authenticityChecks.firmwareHash;
403
- const notDoneYet = lastResult === null;
404
- const attemptsDone = lastResult?.attemptCount ?? 0;
405
- if (attemptsDone >= constants_1.FIRMWARE.HASH_CHECK_MAX_ATTEMPTS)
406
- return;
407
- const wasError = lastResult !== null && !lastResult.success;
408
- const wasErrorRetriable = wasError && (0, utils_1.isArrayMember)(lastResult.error, constants_1.FIRMWARE.HASH_CHECK_RETRIABLE_ERRORS);
409
- const lastErrorPayload = wasError ? lastResult?.errorPayload : null;
410
- if (notDoneYet || wasErrorRetriable) {
411
- const result = await this.checkFirmwareHash();
412
- this.authenticityChecks = {
413
- ...this.authenticityChecks,
414
- firmwareHash: result,
415
- };
416
- if (result === null)
417
- return;
418
- result.attemptCount = attemptsDone + 1;
419
- if (result.success && lastErrorPayload) {
420
- result.warningPayload = { lastErrorPayload, successOnAttempt: result.attemptCount };
421
- }
422
- }
414
+ getAuthenticityChecks() {
415
+ return this.authenticityChecks;
423
416
  }
424
- async checkFirmwareHash() {
425
- const createFailResult = (error, errorPayload) => ({
426
- success: false,
427
- error,
428
- errorPayload,
429
- });
430
- const baseUrl = DataManager_1.DataManager.getSettings('binFilesBaseUrl');
431
- const enabled = DataManager_1.DataManager.getSettings('enableFirmwareHashCheck');
432
- if (!enabled || baseUrl === undefined)
433
- return createFailResult('check-skipped');
434
- const firmwareVersion = this.getVersion();
435
- if (firmwareVersion === undefined || !this.features || this.features.bootloader_mode) {
436
- return null;
437
- }
438
- const checkSupported = !this.unavailableCapabilities.getFirmwareHash;
439
- if (!checkSupported)
440
- return createFailResult('check-unsupported');
441
- const release = (0, firmwareInfo_1.getReleases)(this.features.internal_model).find(r => utils_1.versionUtils.isEqual(r.version, firmwareVersion));
442
- if (release === undefined)
443
- return createFailResult('unknown-release');
444
- const btcOnly = this.firmwareType === types_1.FirmwareType.BitcoinOnly;
445
- const binary = await (0, firmware_1.getBinaryOptional)({ baseUrl, btcOnly, release });
446
- if (binary === null) {
447
- return createFailResult('check-unsupported');
448
- }
449
- if (binary.byteLength < 200) {
450
- _log.warn(`Firmware binary for hash check suspiciously small (< 200 b)`);
451
- return createFailResult('check-unsupported');
452
- }
453
- const strippedBinary = (0, firmware_1.stripFwHeaders)(binary);
454
- const { hash: expectedHash, challenge } = (0, firmware_1.calculateFirmwareHash)(this.features.major_version, strippedBinary, (0, crypto_1.randomBytes)(32));
455
- try {
456
- const deviceResponse = await this.getCurrentSession().typedCall('GetFirmwareHash', 'FirmwareHash', { challenge });
457
- if (!deviceResponse?.message?.hash) {
458
- return createFailResult('other-error', 'Device response is missing hash');
459
- }
460
- if (deviceResponse.message.hash !== expectedHash) {
461
- return createFailResult('hash-mismatch');
462
- }
463
- return { success: true };
464
- }
465
- catch (errorPayload) {
466
- return createFailResult('other-error', (0, utils_1.serializeError)(errorPayload));
467
- }
417
+ setAuthenticityChecks(firmwareHash) {
418
+ this.authenticityChecks.firmwareHash = firmwareHash;
468
419
  }
469
420
  async checkFirmwareRevisionWithRetries() {
470
421
  const lastResult = this.authenticityChecks.firmwareRevision;
@@ -477,18 +428,19 @@ class Device extends utils_1.TypedEmitter {
477
428
  }
478
429
  async checkFirmwareRevision() {
479
430
  const firmwareVersion = this.getVersion();
480
- if (!firmwareVersion || !this.features) {
431
+ if (!firmwareVersion || !this.features || !this.firmwareType) {
481
432
  return;
482
433
  }
483
- if (this.features.bootloader_mode === true) {
434
+ if (this.features && this.features.bootloader_mode === true) {
484
435
  return;
485
436
  }
486
- const release = (0, firmwareInfo_1.getRelease)(this.features.internal_model, firmwareVersion);
437
+ const release = (0, assetUtils_1.getReleaseAsset)(this.features.internal_model, firmwareVersion, this.firmwareType);
487
438
  const result = await (0, checkFirmwareRevision_1.checkFirmwareRevision)({
488
439
  internalModel: this.features.internal_model,
489
440
  deviceRevision: this.features.revision,
490
441
  firmwareVersion,
491
442
  expectedRevision: release?.firmware_revision,
443
+ firmwareType: this.firmwareType,
492
444
  });
493
445
  this.authenticityChecks = {
494
446
  ...this.authenticityChecks,
@@ -506,11 +458,14 @@ class Device extends utils_1.TypedEmitter {
506
458
  if (!version) {
507
459
  throw constants_1.ERRORS.TypedError('Runtime', 'changeLanguage: device version unknown');
508
460
  }
509
- const downloadedBinary = await (0, getLanguage_1.getLanguage)({
510
- language,
511
- version,
512
- internal_model: this.features.internal_model,
513
- });
461
+ if (!this.firmwareType) {
462
+ throw constants_1.ERRORS.TypedError('Runtime', 'changeLanguage: firmware type unknown');
463
+ }
464
+ if (!this._currentRelease) {
465
+ throw constants_1.ERRORS.TypedError('Runtime', 'changeLanguage: release not found');
466
+ }
467
+ const languageBinPath = this._currentRelease.translations[language];
468
+ const downloadedBinary = await (0, firmwareInfo_1.getLanguage)(languageBinPath);
514
469
  if (!downloadedBinary) {
515
470
  throw constants_1.ERRORS.TypedError('Runtime', 'changeLanguage: translation not found');
516
471
  }
@@ -533,6 +488,22 @@ class Device extends utils_1.TypedEmitter {
533
488
  }
534
489
  return response.message;
535
490
  }
491
+ async _updateCurrentRelease(feat) {
492
+ const newVersion = [
493
+ feat.major_version,
494
+ feat.minor_version,
495
+ feat.patch_version,
496
+ ];
497
+ const newFirmwareType = (0, firmwareUtils_1.getFirmwareType)(feat);
498
+ if (this._currentRelease &&
499
+ newFirmwareType === this.firmwareType &&
500
+ utils_1.versionUtils.isEqual(this._currentRelease.version, newVersion)) {
501
+ return;
502
+ }
503
+ const release = await (0, firmwareInfo_1.getReleaseByVersion)(feat, newVersion, newFirmwareType);
504
+ this._currentRelease = release;
505
+ this.availableTranslations = this._currentRelease?.translations ?? {};
506
+ }
536
507
  _updateFeatures(feat) {
537
508
  const capabilities = (0, deviceFeaturesUtils_1.parseCapabilities)(feat);
538
509
  feat.capabilities = capabilities;
@@ -563,25 +534,13 @@ class Device extends utils_1.TypedEmitter {
563
534
  });
564
535
  }
565
536
  this._unavailableCapabilities = (0, deviceFeaturesUtils_1.getUnavailableCapabilities)(feat, (0, coinInfo_1.getAllNetworks)());
566
- this._firmwareStatus = (0, firmwareInfo_1.getFirmwareStatus)(feat);
567
- this._firmwareRelease = (0, firmwareInfo_1.getReleaseInfo)(feat);
568
- this.availableTranslations = this.firmwareRelease?.translations ?? [];
537
+ this._firmwareStatus = (0, firmwareInfo_1.getFirmwareStatus)(feat, (0, firmwareUtils_1.getFirmwareType)(feat));
538
+ this._firmwareReleaseConfigInfo = (0, firmwareInfo_1.getFirmwareReleaseConfigInfo)(feat, (0, firmwareUtils_1.getFirmwareType)(feat));
539
+ this._currentRelease = (0, assetUtils_1.getReleaseAsset)(feat.internal_model, newVersion, (0, firmwareUtils_1.getFirmwareType)(feat));
540
+ this.availableTranslations = this._currentRelease?.translations ?? {};
569
541
  }
570
542
  this._features = feat;
571
- if (feat.fw_vendor === 'Trezor Bitcoin-only') {
572
- this._firmwareType = types_1.FirmwareType.BitcoinOnly;
573
- }
574
- else if (feat.fw_vendor === 'Trezor') {
575
- this._firmwareType = types_1.FirmwareType.Universal;
576
- }
577
- else if (this.getMode() !== 'bootloader') {
578
- this._firmwareType =
579
- feat.capabilities &&
580
- feat.capabilities.length > 0 &&
581
- !feat.capabilities.includes('Capability_Bitcoin_like')
582
- ? types_1.FirmwareType.BitcoinOnly
583
- : types_1.FirmwareType.Universal;
584
- }
543
+ this._firmwareType = (0, firmwareUtils_1.getFirmwareType)(feat);
585
544
  const deviceInfo = device_utils_1.models[feat.internal_model] ?? {
586
545
  name: `Unknown ${feat.internal_model}`,
587
546
  colors: {},
@@ -684,14 +643,14 @@ class Device extends utils_1.TypedEmitter {
684
643
  }
685
644
  return null;
686
645
  }
687
- getMode() {
688
- if (this.features.bootloader_mode)
689
- return 'bootloader';
690
- if (!this.features.initialized)
691
- return 'initialize';
692
- if (this.features.no_backup)
693
- return 'seedless';
694
- return 'normal';
646
+ getStatus() {
647
+ if (this.isUsedElsewhere())
648
+ return 'occupied';
649
+ if (this.wasUsedElsewhere)
650
+ return 'used';
651
+ if (this.busy)
652
+ return 'busy';
653
+ return 'available';
695
654
  }
696
655
  toMessageObject() {
697
656
  const { name, uniquePath: path } = this;
@@ -715,13 +674,11 @@ class Device extends utils_1.TypedEmitter {
715
674
  transportSessionOwner: this.sessionAcquired ? undefined : sessionOwner,
716
675
  bluetoothProps: this.bluetoothProps,
717
676
  thp: this.thp?.serialize(),
677
+ status: this.busy ? 'busy' : undefined,
718
678
  };
719
679
  }
720
680
  const defaultLabel = 'My Trezor';
721
681
  const label = this.features.label === '' || !this.features.label ? defaultLabel : this.features.label;
722
- const status = this.isUsedElsewhere()
723
- ? 'occupied'
724
- : (this.wasUsedElsewhere && 'used') || 'available';
725
682
  return {
726
683
  ...base,
727
684
  type: 'acquired',
@@ -729,11 +686,11 @@ class Device extends utils_1.TypedEmitter {
729
686
  label,
730
687
  _state: this.getState(),
731
688
  state: this.getState()?.staticSessionId,
732
- status,
733
- mode: this.getMode(),
689
+ status: this.getStatus(),
690
+ mode: (0, firmwareUtils_1.getFirmwareMode)(this.features),
734
691
  color: this.color,
735
692
  firmware: this.firmwareStatus,
736
- firmwareRelease: this.firmwareRelease,
693
+ firmwareReleaseConfigInfo: this.firmwareReleaseConfigInfo,
737
694
  firmwareType: this.firmwareType,
738
695
  features: this.features,
739
696
  unavailableCapabilities: this.unavailableCapabilities,
@@ -45,6 +45,7 @@ export declare const DeviceCommands: (deviceTypedCall: TypedCallProvider) => {
45
45
  xpub: string;
46
46
  }>;
47
47
  ethereumGetAddress: (params: Messages.EthereumGetAddress) => Promise<{
48
+ mac?: string | undefined;
48
49
  _old_address?: string | undefined;
49
50
  address: string;
50
51
  }>;
@@ -49,18 +49,6 @@ export declare class DeviceCurrentSession implements TypedCallProvider {
49
49
  } | {
50
50
  type: "TxOutputType";
51
51
  message: import("@trezor/protobuf/lib/messages").TxOutputType;
52
- } | {
53
- type: "PaymentRequestMemo";
54
- message: import("@trezor/protobuf/lib/messages").PaymentRequestMemo;
55
- } | {
56
- type: "TextMemo";
57
- message: import("@trezor/protobuf/lib/messages").TextMemo;
58
- } | {
59
- type: "RefundMemo";
60
- message: import("@trezor/protobuf/lib/messages").RefundMemo;
61
- } | {
62
- type: "CoinPurchaseMemo";
63
- message: import("@trezor/protobuf/lib/messages").CoinPurchaseMemo;
64
52
  } | {
65
53
  type: "TxAckInputWrapper";
66
54
  message: import("@trezor/protobuf/lib/messages").TxAckInputWrapper;
@@ -94,6 +82,9 @@ export declare class DeviceCurrentSession implements TypedCallProvider {
94
82
  } | {
95
83
  type: "CardanoAddressParametersType";
96
84
  message: import("@trezor/protobuf/lib/messages").CardanoAddressParametersType;
85
+ } | {
86
+ type: "PaymentRequest";
87
+ message: import("@trezor/protobuf/lib/messages").PaymentRequest;
97
88
  } | {
98
89
  type: "CardanoPoolMetadataType";
99
90
  message: import("@trezor/protobuf/lib/messages").CardanoPoolMetadataType;
@@ -109,6 +100,21 @@ export declare class DeviceCurrentSession implements TypedCallProvider {
109
100
  } | {
110
101
  type: "CardanoCVoteRegistrationParametersType";
111
102
  message: import("@trezor/protobuf/lib/messages").CardanoCVoteRegistrationParametersType;
103
+ } | {
104
+ type: "PaymentRequestMemo";
105
+ message: import("@trezor/protobuf/lib/messages").PaymentRequestMemo;
106
+ } | {
107
+ type: "TextMemo";
108
+ message: import("@trezor/protobuf/lib/messages").TextMemo;
109
+ } | {
110
+ type: "RefundMemo";
111
+ message: import("@trezor/protobuf/lib/messages").RefundMemo;
112
+ } | {
113
+ type: "CoinPurchaseMemo";
114
+ message: import("@trezor/protobuf/lib/messages").CoinPurchaseMemo;
115
+ } | {
116
+ type: "TextDetailsMemo";
117
+ message: import("@trezor/protobuf/lib/messages").TextDetailsMemo;
112
118
  } | {
113
119
  type: "IdentityType";
114
120
  message: import("@trezor/protobuf/lib/messages").IdentityType;
@@ -307,9 +313,6 @@ export declare class DeviceCurrentSession implements TypedCallProvider {
307
313
  } | {
308
314
  type: "TxRequest";
309
315
  message: import("@trezor/protobuf/lib/messages").TxRequest;
310
- } | {
311
- type: "TxAckPaymentRequest";
312
- message: import("@trezor/protobuf/lib/messages").TxAckPaymentRequest;
313
316
  } | {
314
317
  type: "TxAck";
315
318
  message: import("@trezor/protobuf/lib/messages").TxAck;
@@ -442,6 +445,18 @@ export declare class DeviceCurrentSession implements TypedCallProvider {
442
445
  } | {
443
446
  type: "CardanoSignTxFinished";
444
447
  message: import("@trezor/protobuf/lib/messages").CardanoSignTxFinished;
448
+ } | {
449
+ type: "CardanoSignMessageInit";
450
+ message: import("@trezor/protobuf/lib/messages").CardanoSignMessageInit;
451
+ } | {
452
+ type: "CardanoMessageDataRequest";
453
+ message: import("@trezor/protobuf/lib/messages").CardanoMessageDataRequest;
454
+ } | {
455
+ type: "CardanoMessageDataResponse";
456
+ message: import("@trezor/protobuf/lib/messages").CardanoMessageDataResponse;
457
+ } | {
458
+ type: "CardanoMessageSignature";
459
+ message: import("@trezor/protobuf/lib/messages").CardanoMessageSignature;
445
460
  } | {
446
461
  type: "Success";
447
462
  message: import("@trezor/protobuf/lib/messages").Success;
@@ -472,15 +487,15 @@ export declare class DeviceCurrentSession implements TypedCallProvider {
472
487
  } | {
473
488
  type: "ECDHSessionKey";
474
489
  message: import("@trezor/protobuf/lib/messages").ECDHSessionKey;
490
+ } | {
491
+ type: "PaymentNotification";
492
+ message: import("@trezor/protobuf/lib/messages").PaymentNotification;
475
493
  } | {
476
494
  type: "DebugLinkGetPairingInfo";
477
495
  message: import("@trezor/protobuf/lib/messages").DebugLinkGetPairingInfo;
478
496
  } | {
479
497
  type: "DebugLinkPairingInfo";
480
498
  message: import("@trezor/protobuf/lib/messages").DebugLinkPairingInfo;
481
- } | {
482
- type: "DebugLinkToggleThpPairingDialog";
483
- message: import("@trezor/protobuf/lib/messages").DebugLinkToggleThpPairingDialog;
484
499
  } | {
485
500
  type: "DebugLinkResetDebugEvents";
486
501
  message: import("@trezor/protobuf/lib/messages").DebugLinkResetDebugEvents;
@@ -574,6 +589,12 @@ export declare class DeviceCurrentSession implements TypedCallProvider {
574
589
  } | {
575
590
  type: "EthereumTypedDataSignature";
576
591
  message: import("@trezor/protobuf/lib/messages").EthereumTypedDataSignature;
592
+ } | {
593
+ type: "EvoluGetNode";
594
+ message: import("@trezor/protobuf/lib/messages").EvoluGetNode;
595
+ } | {
596
+ type: "EvoluNode";
597
+ message: import("@trezor/protobuf/lib/messages").EvoluNode;
577
598
  } | {
578
599
  type: "Initialize";
579
600
  message: import("@trezor/protobuf/lib/messages").Initialize;
@@ -835,14 +856,14 @@ export declare class DeviceCurrentSession implements TypedCallProvider {
835
856
  }>;
836
857
  private needCancelWorkaround;
837
858
  private callLoop;
838
- call<T extends Messages.MessageKey>(name: T, data: Messages.MessagePayload<T>, options?: AbortableOptions): Promise<{
859
+ call(name: string, data: Record<string, unknown>, options?: AbortableOptions): Promise<{
839
860
  success: false;
840
861
  error: Error;
841
862
  } | {
842
863
  success: true;
843
864
  payload: MessageResponse;
844
865
  }>;
845
- send<T extends Messages.MessageKey>(name: T, data: Messages.MessagePayload<T>, options?: AbortableOptions): Promise<{
866
+ send(name: string, data: Record<string, unknown>, options?: AbortableOptions): Promise<{
846
867
  success: false;
847
868
  error: Error;
848
869
  } | {