@trezor/connect 9.1.12 → 9.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. package/CHANGELOG.md +69 -0
  2. package/README.md +1 -1
  3. package/lib/api/binance/api/binanceSignTransaction.d.ts +1 -1
  4. package/lib/api/binance/binanceSignTx.d.ts +1 -1
  5. package/lib/api/bitcoin/Fees.d.ts +2 -2
  6. package/lib/api/bitcoin/TransactionComposer.d.ts +2 -2
  7. package/lib/api/bitcoin/refTx.js +3 -4
  8. package/lib/api/blockchainGetCurrentFiatRates.d.ts +1 -1
  9. package/lib/api/blockchainGetFiatRatesForTimestamps.d.ts +1 -1
  10. package/lib/api/cardano/cardanoOutputs.d.ts +1 -1
  11. package/lib/api/cardano/cardanoTokenBundle.d.ts +2 -2
  12. package/lib/api/changeLanguage.d.ts +11 -0
  13. package/lib/api/changeLanguage.js +73 -0
  14. package/lib/api/common/paramsValidator.js +4 -5
  15. package/lib/api/eos/eosSignTx.d.ts +58 -58
  16. package/lib/api/ethereum/api/ethereumGetPublicKey.d.ts +6 -6
  17. package/lib/api/ethereum/api/ethereumSignMessage.d.ts +2 -2
  18. package/lib/api/ethereum/api/ethereumSignTransaction.d.ts +2 -2
  19. package/lib/api/ethereum/api/ethereumSignTypedData.d.ts +6 -6
  20. package/lib/api/ethereum/api/ethereumSignTypedData.js +2 -2
  21. package/lib/api/ethereum/ethereumDefinitions.d.ts +2 -2
  22. package/lib/api/ethereum/ethereumSignTx.d.ts +3 -3
  23. package/lib/api/firmware/getBinary.d.ts +1 -1
  24. package/lib/api/firmware/getBinary.js +4 -5
  25. package/lib/api/firmware/modifyFirmware.js +2 -3
  26. package/lib/api/firmware/verifyAuthenticityProof.js +3 -3
  27. package/lib/api/getAccountInfo.d.ts +2 -0
  28. package/lib/api/getCoinInfo.d.ts +22 -22
  29. package/lib/api/getFeatures.d.ts +11 -11
  30. package/lib/api/getPublicKey.d.ts +6 -6
  31. package/lib/api/index.d.ts +1 -0
  32. package/lib/api/index.js +3 -1
  33. package/lib/api/nem/nemSignTx.d.ts +13 -13
  34. package/lib/api/rebootToBootloader.d.ts +2 -1
  35. package/lib/api/rebootToBootloader.js +10 -1
  36. package/lib/api/recoveryDevice.d.ts +1 -0
  37. package/lib/api/recoveryDevice.js +3 -0
  38. package/lib/api/stellar/stellarSignTx.d.ts +1 -1
  39. package/lib/api/stellar/stellarSignTx.js +6 -0
  40. package/lib/api/tezos/tezosSignTx.d.ts +18 -18
  41. package/lib/backend/BackendManager.d.ts +5 -2
  42. package/lib/backend/BackendManager.js +54 -20
  43. package/lib/backend/Blockchain.d.ts +6 -6
  44. package/lib/backend/Blockchain.js +37 -27
  45. package/lib/constants/index.d.ts +1 -1
  46. package/lib/constants/index.js +2 -1
  47. package/lib/core/AbstractMethod.d.ts +1 -1
  48. package/lib/core/AbstractMethod.js +3 -4
  49. package/lib/core/index.js +23 -11
  50. package/lib/data/DataManager.d.ts +2 -2
  51. package/lib/data/coinInfo.d.ts +117 -117
  52. package/lib/data/coinInfo.js +6 -6
  53. package/lib/data/config.js +1 -1
  54. package/lib/data/connectSettings.js +3 -0
  55. package/lib/data/deviceAuthenticityConfig.js +4 -1
  56. package/lib/data/firmwareInfo.d.ts +1 -1
  57. package/lib/data/firmwareInfo.js +14 -12
  58. package/lib/data/version.d.ts +1 -1
  59. package/lib/data/version.js +1 -1
  60. package/lib/device/Device.d.ts +5 -4
  61. package/lib/device/Device.js +13 -11
  62. package/lib/device/DeviceCommands.d.ts +7 -7
  63. package/lib/device/DeviceCommands.js +4 -4
  64. package/lib/device/DeviceList.d.ts +1 -1
  65. package/lib/device/DeviceList.js +3 -3
  66. package/lib/events/blockchain.d.ts +10 -2
  67. package/lib/events/blockchain.js +1 -0
  68. package/lib/events/call.d.ts +2 -2
  69. package/lib/events/core.d.ts +4 -0
  70. package/lib/events/popup.d.ts +13 -1
  71. package/lib/events/ui-promise.d.ts +1 -1
  72. package/lib/events/webextension.d.ts +1 -0
  73. package/lib/events/webextension.js +1 -0
  74. package/lib/factory.js +1 -0
  75. package/lib/index.js +2 -2
  76. package/lib/types/api/applySettings.d.ts +6 -6
  77. package/lib/types/api/binance/index.d.ts +10 -10
  78. package/lib/types/api/cardano/index.d.ts +4 -4
  79. package/lib/types/api/changeLanguage.d.ts +15 -0
  80. package/lib/types/api/changeLanguage.js +17 -0
  81. package/lib/types/api/cipherKeyValue.d.ts +2 -2
  82. package/lib/types/api/eos/index.d.ts +3 -3
  83. package/lib/types/api/ethereum/index.d.ts +3 -3
  84. package/lib/types/api/firmwareUpdate.d.ts +1 -1
  85. package/lib/types/api/getAddress.d.ts +5 -5
  86. package/lib/types/api/index.d.ts +2 -0
  87. package/lib/types/api/nem/index.d.ts +7 -7
  88. package/lib/types/api/rebootToBootloader.d.ts +2 -2
  89. package/lib/types/api/recoveryDevice.d.ts +1 -1
  90. package/lib/types/api/stellar/index.d.ts +169 -146
  91. package/lib/types/api/stellar/index.js +13 -1
  92. package/lib/types/device.d.ts +4 -1
  93. package/lib/types/device.js +2 -2
  94. package/lib/types/firmware.d.ts +2 -0
  95. package/lib/types/index.d.ts +1 -1
  96. package/lib/types/settings.d.ts +1 -0
  97. package/lib/utils/assets-browser.d.ts +1 -1
  98. package/lib/utils/assets.d.ts +3 -1
  99. package/lib/utils/assets.js +2 -2
  100. package/lib/utils/deviceFeaturesUtils.js +4 -5
  101. package/lib/utils/firmwareUtils.js +4 -5
  102. package/lib/utils/hdnodeUtils.d.ts +3 -3
  103. package/lib/utils/pathUtils.d.ts +3 -3
  104. package/lib/utils/urlUtils.js +3 -3
  105. package/package.json +26 -28
@@ -6,7 +6,7 @@ export interface GetInfoProps {
6
6
  releases: FirmwareRelease[];
7
7
  }
8
8
  export declare const getInfo: ({ features, releases }: GetInfoProps) => ReleaseInfo | null;
9
- export declare const getFirmwareStatus: (features: Features) => "custom" | "valid" | "outdated" | "required" | "unknown" | "none";
9
+ export declare const getFirmwareStatus: (features: Features) => "unknown" | "custom" | "valid" | "outdated" | "required" | "none";
10
10
  export declare const getRelease: (features: Features) => ReleaseInfo | null;
11
11
  export declare const getReleases: (deviceModel: DeviceModelInternal) => FirmwareRelease[];
12
12
  //# sourceMappingURL=firmwareInfo.d.ts.map
@@ -1,8 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getReleases = exports.getRelease = exports.getFirmwareStatus = exports.getInfo = exports.parseFirmware = void 0;
4
- const tslib_1 = require("tslib");
5
- const versionUtils = tslib_1.__importStar(require("@trezor/utils/lib/versionUtils"));
4
+ const utils_1 = require("@trezor/utils");
6
5
  const firmwareUtils_1 = require("../utils/firmwareUtils");
7
6
  const types_1 = require("../types");
8
7
  const releases = {
@@ -25,7 +24,7 @@ const getChangelog = (releases, features) => {
25
24
  return null;
26
25
  }
27
26
  if (features.firmware_present && features.major_version === 2) {
28
- return releases.filter(r => versionUtils.isNewer(r.version, [
27
+ return releases.filter(r => utils_1.versionUtils.isNewer(r.version, [
29
28
  features.fw_major,
30
29
  features.fw_minor,
31
30
  features.fw_patch,
@@ -33,7 +32,7 @@ const getChangelog = (releases, features) => {
33
32
  }
34
33
  return releases;
35
34
  }
36
- return releases.filter(r => versionUtils.isNewer(r.version, [
35
+ return releases.filter(r => utils_1.versionUtils.isNewer(r.version, [
37
36
  features.major_version,
38
37
  features.minor_version,
39
38
  features.patch_version,
@@ -43,7 +42,7 @@ const isNewer = (release, features) => {
43
42
  if (features.major_version === 1 && features.bootloader_mode) {
44
43
  return null;
45
44
  }
46
- return versionUtils.isNewer(release.version, [
45
+ return utils_1.versionUtils.isNewer(release.version, [
47
46
  features.major_version,
48
47
  features.minor_version,
49
48
  features.patch_version,
@@ -54,14 +53,14 @@ const isRequired = (changelog) => {
54
53
  return null;
55
54
  return changelog.some(item => item.required);
56
55
  };
57
- const isEqual = (release, latest) => versionUtils.isEqual(release.version, latest.version);
56
+ const isEqual = (release, latest) => utils_1.versionUtils.isEqual(release.version, latest.version);
58
57
  const getT1BootloaderVersion = (releases, features) => {
59
58
  const { bootloader_mode, major_version, minor_version, patch_version } = features;
60
59
  const versionArray = [major_version, minor_version, patch_version];
61
60
  if (bootloader_mode) {
62
61
  return versionArray;
63
62
  }
64
- const release = releases.find(({ version }) => versionUtils.isEqual(version, versionArray));
63
+ const release = releases.find(({ version }) => utils_1.versionUtils.isEqual(version, versionArray));
65
64
  return (release === null || release === void 0 ? void 0 : release.bootloader_version) || [1, 0, 0];
66
65
  };
67
66
  const getIntermediaryVersion = (releases, features, offerLatest) => {
@@ -69,10 +68,10 @@ const getIntermediaryVersion = (releases, features, offerLatest) => {
69
68
  return;
70
69
  }
71
70
  const bootloaderVersion = getT1BootloaderVersion(releases, features);
72
- if (versionUtils.isNewerOrEqual(bootloaderVersion, [1, 12, 0])) {
71
+ if (utils_1.versionUtils.isNewerOrEqual(bootloaderVersion, [1, 12, 0])) {
73
72
  return 3;
74
73
  }
75
- if (versionUtils.isNewerOrEqual(bootloaderVersion, [1, 8, 0])) {
74
+ if (utils_1.versionUtils.isNewerOrEqual(bootloaderVersion, [1, 8, 0])) {
76
75
  return 2;
77
76
  }
78
77
  return 1;
@@ -80,12 +79,12 @@ const getIntermediaryVersion = (releases, features, offerLatest) => {
80
79
  const getSafeReleases = ({ features, releases }) => {
81
80
  const { bootloader_mode, major_version, minor_version, patch_version, fw_major, fw_minor, fw_patch, } = features;
82
81
  const firmwareVersion = [major_version, minor_version, patch_version];
83
- if (!versionUtils.isVersionArray(firmwareVersion)) {
82
+ if (!utils_1.versionUtils.isVersionArray(firmwareVersion)) {
84
83
  return [];
85
84
  }
86
85
  if (major_version === 2 && bootloader_mode) {
87
86
  const fwVersion = [fw_major, fw_minor, fw_patch];
88
- if (versionUtils.isVersionArray(fwVersion)) {
87
+ if (utils_1.versionUtils.isVersionArray(fwVersion)) {
89
88
  return (0, firmwareUtils_1.filterSafeListByFirmware)(releases, fwVersion);
90
89
  }
91
90
  return (0, firmwareUtils_1.filterSafeListByBootloader)(releases, firmwareVersion);
@@ -113,13 +112,16 @@ const getInfo = ({ features, releases }) => {
113
112
  const releasesParsed = features.major_version === 1 ? releases : releasesSafe;
114
113
  const changelog = getChangelog(releasesParsed, features);
115
114
  const release = releasesParsed[0];
115
+ const prevRelease = releasesParsed[1];
116
116
  const intermediaryVersion = getIntermediaryVersion(releases, features, isEqual(releasesSafe[0], latest));
117
+ const isNewerResult = isNewer(latest, features);
117
118
  return {
118
119
  changelog,
119
120
  release,
120
121
  isRequired: isRequired(changelog),
121
- isNewer: isNewer(latest, features),
122
+ isNewer: isNewerResult,
122
123
  intermediaryVersion,
124
+ translations: isNewerResult ? prevRelease.translations : release.translations,
123
125
  };
124
126
  };
125
127
  exports.getInfo = getInfo;
@@ -1,3 +1,3 @@
1
- export declare const VERSION = "9.1.12";
1
+ export declare const VERSION = "9.2.0";
2
2
  export declare const DEFAULT_DOMAIN: string;
3
3
  //# sourceMappingURL=version.d.ts.map
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DEFAULT_DOMAIN = exports.VERSION = void 0;
4
- exports.VERSION = '9.1.12';
4
+ exports.VERSION = '9.2.0';
5
5
  const versionN = exports.VERSION.split('.').map(s => parseInt(s, 10));
6
6
  exports.DEFAULT_DOMAIN = `https://connect.trezor.io/${versionN[0]}/`;
7
7
  //# sourceMappingURL=version.js.map
@@ -1,5 +1,5 @@
1
- import { TypedEmitter } from '@trezor/utils/lib/typedEventEmitter';
2
- import { Deferred } from '@trezor/utils/lib/createDeferred';
1
+ import { TypedEmitter } from '@trezor/utils';
2
+ import { Deferred } from '@trezor/utils';
3
3
  import { TransportProtocol } from '@trezor/protocol';
4
4
  import { DeviceCommands, PassphrasePromptResponse } from './DeviceCommands';
5
5
  import { PROTO, NETWORK } from '../constants';
@@ -49,6 +49,7 @@ export declare class Device extends TypedEmitter<DeviceEvents> {
49
49
  firmwareType?: FirmwareType;
50
50
  name: string;
51
51
  color?: string;
52
+ availableTranslations: string[];
52
53
  constructor(transport: Transport, descriptor: Descriptor);
53
54
  static fromDescriptor(transport: Transport, originalDescriptor: Descriptor): Device;
54
55
  static createUnacquired(transport: Transport, descriptor: Descriptor, unreadableError?: string): Device;
@@ -78,7 +79,7 @@ export declare class Device extends TypedEmitter<DeviceEvents> {
78
79
  isInitialized(): boolean;
79
80
  isSeedless(): boolean;
80
81
  isInconsistent(): boolean;
81
- getVersion(): never[] | [number, number, number];
82
+ getVersion(): [number, number, number] | never[];
82
83
  atLeast(versions: string[] | string): boolean;
83
84
  isUsed(): boolean;
84
85
  isUsedHere(): boolean;
@@ -89,7 +90,7 @@ export declare class Device extends TypedEmitter<DeviceEvents> {
89
90
  getDevicePath(): string;
90
91
  isT1(): boolean;
91
92
  hasUnexpectedMode(allow: string[], require: string[]): "ui-device_bootloader_mode" | "ui-device_not_in_bootloader_mode" | "ui-device_not_initialized" | "ui-device_seedless" | null;
92
- dispose(): import("@trezor/transport/lib/types").AbortableCall<void, "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" | "session not found"> | undefined;
93
+ dispose(): import("@trezor/transport/lib/types").AbortableCall<void, "Aborted by signal" | "Aborted by timeout" | "Network request failed" | "Wrong result type." | "device disconnected during action" | "unexpected error" | "This transport can not be used in this environment" | "device not found" | "Unable to open device" | "wrong previous session" | "session not found"> | undefined;
93
94
  getMode(): "normal" | "bootloader" | "initialize" | "seedless";
94
95
  toMessageObject(): DeviceTyped;
95
96
  legacyForceRelease(): Promise<void>;
@@ -1,10 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Device = void 0;
4
- const tslib_1 = require("tslib");
5
- const typedEventEmitter_1 = require("@trezor/utils/lib/typedEventEmitter");
6
- const createDeferred_1 = require("@trezor/utils/lib/createDeferred");
7
- const versionUtils = tslib_1.__importStar(require("@trezor/utils/lib/versionUtils"));
4
+ const utils_1 = require("@trezor/utils");
5
+ const utils_2 = require("@trezor/utils");
6
+ const utils_3 = require("@trezor/utils");
8
7
  const protocol_1 = require("@trezor/protocol");
9
8
  const DeviceCommands_1 = require("./DeviceCommands");
10
9
  const constants_1 = require("../constants");
@@ -21,7 +20,7 @@ const parseRunOptions = (options) => {
21
20
  options = {};
22
21
  return options;
23
22
  };
24
- class Device extends typedEventEmitter_1.TypedEmitter {
23
+ class Device extends utils_1.TypedEmitter {
25
24
  constructor(transport, descriptor) {
26
25
  super();
27
26
  this.featuresNeedsReload = false;
@@ -36,6 +35,7 @@ class Device extends typedEventEmitter_1.TypedEmitter {
36
35
  this.unavailableCapabilities = {};
37
36
  this.networkTypeState = [];
38
37
  this.name = 'Trezor';
38
+ this.availableTranslations = [];
39
39
  if (transport.name === 'BridgeTransport') {
40
40
  this.protocol = protocol_1.bridge;
41
41
  }
@@ -44,7 +44,7 @@ class Device extends typedEventEmitter_1.TypedEmitter {
44
44
  }
45
45
  this.transport = transport;
46
46
  this.originalDescriptor = descriptor;
47
- this.firstRunPromise = (0, createDeferred_1.createDeferred)();
47
+ this.firstRunPromise = (0, utils_2.createDeferred)();
48
48
  }
49
49
  static fromDescriptor(transport, originalDescriptor) {
50
50
  const descriptor = { ...originalDescriptor, session: null };
@@ -124,7 +124,7 @@ class Device extends typedEventEmitter_1.TypedEmitter {
124
124
  throw constants_1.ERRORS.TypedError('Device_CallInProgress');
125
125
  }
126
126
  options = parseRunOptions(options);
127
- const runPromise = (0, createDeferred_1.createDeferred)();
127
+ const runPromise = (0, utils_2.createDeferred)();
128
128
  this.runPromise = runPromise;
129
129
  this._runInner(fn, options).catch(err => {
130
130
  runPromise.reject(err);
@@ -311,7 +311,7 @@ class Device extends typedEventEmitter_1.TypedEmitter {
311
311
  this._updateFeatures(message);
312
312
  }
313
313
  _updateFeatures(feat) {
314
- var _a, _b;
314
+ var _a, _b, _c, _d;
315
315
  const capabilities = (0, deviceFeaturesUtils_1.parseCapabilities)(feat);
316
316
  feat.capabilities = capabilities;
317
317
  if (this.features && this.features.session_id && !feat.session_id) {
@@ -331,10 +331,11 @@ class Device extends typedEventEmitter_1.TypedEmitter {
331
331
  feat.minor_version,
332
332
  feat.patch_version,
333
333
  ];
334
- if (!versionUtils.isEqual(version, this.getVersion())) {
334
+ if (!utils_3.versionUtils.isEqual(version, this.getVersion())) {
335
335
  this.unavailableCapabilities = (0, deviceFeaturesUtils_1.getUnavailableCapabilities)(feat, (0, coinInfo_1.getAllNetworks)());
336
336
  this.firmwareStatus = (0, firmwareInfo_1.getFirmwareStatus)(feat);
337
337
  this.firmwareRelease = (0, firmwareInfo_1.getRelease)(feat);
338
+ this.availableTranslations = (_c = (_b = this.firmwareRelease) === null || _b === void 0 ? void 0 : _b.translations) !== null && _c !== void 0 ? _c : [];
338
339
  }
339
340
  this.features = feat;
340
341
  this.featuresNeedsReload = false;
@@ -352,7 +353,7 @@ class Device extends typedEventEmitter_1.TypedEmitter {
352
353
  ? types_1.FirmwareType.BitcoinOnly
353
354
  : types_1.FirmwareType.Regular;
354
355
  }
355
- const deviceInfo = (_b = models_1.models[feat.internal_model]) !== null && _b !== void 0 ? _b : {
356
+ const deviceInfo = (_d = models_1.models[feat.internal_model]) !== null && _d !== void 0 ? _d : {
356
357
  name: `Unknown ${feat.internal_model}`,
357
358
  colors: {},
358
359
  };
@@ -398,7 +399,7 @@ class Device extends typedEventEmitter_1.TypedEmitter {
398
399
  if (!this.features)
399
400
  return false;
400
401
  const modelVersion = typeof versions === 'string' ? versions : versions[this.features.major_version - 1];
401
- return versionUtils.isNewerOrEqual(this.getVersion().join('.'), modelVersion);
402
+ return utils_3.versionUtils.isNewerOrEqual(this.getVersion().join('.'), modelVersion);
402
403
  }
403
404
  isUsed() {
404
405
  return typeof this.originalDescriptor.session === 'string';
@@ -505,6 +506,7 @@ class Device extends typedEventEmitter_1.TypedEmitter {
505
506
  firmwareType: this.firmwareType,
506
507
  features: this.features,
507
508
  unavailableCapabilities: this.unavailableCapabilities,
509
+ availableTranslations: this.availableTranslations,
508
510
  };
509
511
  }
510
512
  async legacyForceRelease() {
@@ -1,5 +1,5 @@
1
1
  import { Transport } from '@trezor/transport';
2
- import * as Messages from '@trezor/protobuf/lib/messages-schema';
2
+ import { MessagesSchema as Messages } from '@trezor/protobuf';
3
3
  import type { Device } from './Device';
4
4
  import type { CoinInfo, BitcoinNetworkInfo } from '../types';
5
5
  import type { HDNodeResponse } from '../types/api/getPublicKey';
@@ -49,24 +49,24 @@ export declare class DeviceCommands {
49
49
  }): Promise<{
50
50
  xpubSegwit?: string | undefined;
51
51
  path: number[];
52
- publicKey: string;
53
- serializedPath: string;
54
52
  depth: number;
55
53
  fingerprint: number;
54
+ xpub: string;
55
+ publicKey: string;
56
+ serializedPath: string;
56
57
  chainCode: string;
57
58
  childNum: number;
58
- xpub: string;
59
59
  }>;
60
60
  getBitcoinHDNode(path: number[], coinInfo?: BitcoinNetworkInfo, validation?: boolean): Promise<{
61
61
  xpubSegwit?: string | undefined;
62
62
  path: number[];
63
- publicKey: string;
64
- serializedPath: string;
65
63
  depth: number;
66
64
  fingerprint: number;
65
+ xpub: string;
66
+ publicKey: string;
67
+ serializedPath: string;
67
68
  chainCode: string;
68
69
  childNum: number;
69
- xpub: string;
70
70
  }>;
71
71
  getAddress({ address_n, show_display, multisig, script_type, chunkify }: Messages.GetAddress, coinInfo: BitcoinNetworkInfo): Promise<{
72
72
  path: number[];
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DeviceCommands = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const crypto_1 = require("crypto");
6
- const Messages = tslib_1.__importStar(require("@trezor/protobuf/lib/messages-schema"));
7
- const versionUtils = tslib_1.__importStar(require("@trezor/utils/lib/versionUtils"));
6
+ const protobuf_1 = require("@trezor/protobuf");
7
+ const utils_1 = require("@trezor/utils");
8
8
  const constants_1 = require("../constants");
9
9
  const events_1 = require("../events");
10
10
  const hdnodeUtils = tslib_1.__importStar(require("../utils/hdnodeUtils"));
@@ -264,7 +264,7 @@ class DeviceCommands {
264
264
  if (this.disposed) {
265
265
  throw constants_1.ERRORS.TypedError('Runtime', 'typedCall: DeviceCommands already disposed');
266
266
  }
267
- (0, schema_utils_1.Assert)(Messages.MessageType.properties[type], msg !== null && msg !== void 0 ? msg : {});
267
+ (0, schema_utils_1.Assert)(protobuf_1.MessagesSchema.MessageType.properties[type], msg !== null && msg !== void 0 ? msg : {});
268
268
  const response = await this._commonCall(type, msg);
269
269
  try {
270
270
  assertType(response, resType);
@@ -511,7 +511,7 @@ class DeviceCommands {
511
511
  return;
512
512
  }
513
513
  const { name, version } = this.transport;
514
- if (name === 'BridgeTransport' && !versionUtils.isNewer(version, '2.0.28')) {
514
+ if (name === 'BridgeTransport' && !utils_1.versionUtils.isNewer(version, '2.0.28')) {
515
515
  try {
516
516
  await this.device.legacyForceRelease();
517
517
  }
@@ -1,4 +1,4 @@
1
- import { TypedEmitter } from '@trezor/utils/lib/typedEventEmitter';
1
+ import { TypedEmitter } from '@trezor/utils';
2
2
  import { Transport, TRANSPORT, Descriptor } from '@trezor/transport';
3
3
  import { DEVICE, TransportInfo } from '../events';
4
4
  import { Device } from './Device';
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DeviceList = void 0;
4
- const typedEventEmitter_1 = require("@trezor/utils/lib/typedEventEmitter");
4
+ const utils_1 = require("@trezor/utils");
5
5
  const transport_1 = require("@trezor/transport");
6
6
  const constants_1 = require("../constants");
7
7
  const events_1 = require("../events");
@@ -12,7 +12,7 @@ const debug_1 = require("../utils/debug");
12
12
  const promiseUtils_1 = require("../utils/promiseUtils");
13
13
  const _log = (0, debug_1.initLog)('DeviceList');
14
14
  let autoResolveTransportEventTimeout;
15
- class DeviceList extends typedEventEmitter_1.TypedEmitter {
15
+ class DeviceList extends utils_1.TypedEmitter {
16
16
  constructor() {
17
17
  super();
18
18
  this.transports = [];
@@ -152,8 +152,8 @@ class DeviceList extends typedEventEmitter_1.TypedEmitter {
152
152
  d.forEach(descriptor => {
153
153
  const path = descriptor.path.toString();
154
154
  const device = this.devices[path];
155
- _log.debug('Event', e, device.toMessageObject());
156
155
  if (device) {
156
+ _log.debug('Event', e, device.toMessageObject());
157
157
  this.emit(e, device.toMessageObject());
158
158
  }
159
159
  });
@@ -1,9 +1,10 @@
1
- import type { ServerInfo, BlockEvent, FiatRates, NotificationEvent } from '@trezor/blockchain-link';
1
+ import type { ServerInfo, BlockEvent, FiatRatesLegacy, NotificationEvent } from '@trezor/blockchain-link';
2
2
  import type { CoinInfo } from '../types/coinInfo';
3
3
  import type { MessageFactoryFn } from '../types/utils';
4
4
  export declare const BLOCKCHAIN_EVENT = "BLOCKCHAIN_EVENT";
5
5
  export declare const BLOCKCHAIN: {
6
6
  readonly CONNECT: "blockchain-connect";
7
+ readonly RECONNECTING: "blockchain-reconnecting";
7
8
  readonly ERROR: "blockchain-error";
8
9
  readonly BLOCK: "blockchain-block";
9
10
  readonly NOTIFICATION: "blockchain-notification";
@@ -15,6 +16,10 @@ export interface BlockchainInfo extends ServerInfo {
15
16
  reserve?: string;
16
17
  };
17
18
  }
19
+ export interface BlockchainReconnecting {
20
+ coin: CoinInfo;
21
+ time: number;
22
+ }
18
23
  export interface BlockchainError {
19
24
  coin: CoinInfo;
20
25
  error: string;
@@ -29,11 +34,14 @@ export interface BlockchainNotification {
29
34
  }
30
35
  export interface BlockchainFiatRatesUpdate {
31
36
  coin: CoinInfo;
32
- rates: FiatRates;
37
+ rates: FiatRatesLegacy;
33
38
  }
34
39
  export type BlockchainEvent = {
35
40
  type: typeof BLOCKCHAIN.CONNECT;
36
41
  payload: BlockchainInfo;
42
+ } | {
43
+ type: typeof BLOCKCHAIN.RECONNECTING;
44
+ payload: BlockchainReconnecting;
37
45
  } | {
38
46
  type: typeof BLOCKCHAIN.ERROR;
39
47
  payload: BlockchainError;
@@ -4,6 +4,7 @@ exports.createBlockchainMessage = exports.BLOCKCHAIN = exports.BLOCKCHAIN_EVENT
4
4
  exports.BLOCKCHAIN_EVENT = 'BLOCKCHAIN_EVENT';
5
5
  exports.BLOCKCHAIN = {
6
6
  CONNECT: 'blockchain-connect',
7
+ RECONNECTING: 'blockchain-reconnecting',
7
8
  ERROR: 'blockchain-error',
8
9
  BLOCK: 'blockchain-block',
9
10
  NOTIFICATION: 'blockchain-notification',
@@ -1,10 +1,10 @@
1
1
  import type { IFRAME } from './iframe';
2
2
  import type { TrezorConnect } from '../types/api';
3
3
  import type { CommonParams } from '../types/params';
4
- type UnwrappedResponse<T> = T extends Promise<infer R> ? R extends {
4
+ type UnwrappedResponse<T> = T extends Promise<infer R> ? (R extends {
5
5
  success: true;
6
6
  payload: infer P;
7
- } ? P : never : void;
7
+ } ? P : never) : void;
8
8
  type OverloadedMethod<T, E extends Record<string, string>> = T extends {
9
9
  (params: infer P1): infer R1;
10
10
  (params: infer P2): infer R2;
@@ -11,6 +11,10 @@ export declare const CORE_EVENT = "CORE_EVENT";
11
11
  export type CoreRequestMessage = PopupClosedMessage | PopupAnalyticsResponse | TransportDisableWebUSB | TransportRequestWebUSBDevice | UiResponseEvent | IFrameInit | IFrameCallMessage | IFrameLogRequest;
12
12
  export type CoreEventMessage = {
13
13
  success?: boolean;
14
+ channel?: {
15
+ here: string;
16
+ peer: string;
17
+ };
14
18
  } & (BlockchainEventMessage | DeviceEventMessage | TransportEventMessage | UiEventMessage | MethodResponseMessage | IFrameEventMessage | PopupEventMessage);
15
19
  export declare const parseMessage: <T extends CoreRequestMessage | CoreEventMessage = never>(messageData: any) => T;
16
20
  export declare const createErrorMessage: (error: Error & {
@@ -64,10 +64,22 @@ export interface PopupContentScriptLoaded {
64
64
  id: string;
65
65
  };
66
66
  }
67
+ export interface PopupExtensionUsbPermissions {
68
+ type: typeof POPUP.EXTENSION_USB_PERMISSIONS;
69
+ payload: typeof undefined;
70
+ }
71
+ export interface PopupBootstrap {
72
+ type: typeof POPUP.BOOTSTRAP;
73
+ payload: typeof undefined;
74
+ }
75
+ export interface PopupCloseWindow {
76
+ type: typeof POPUP.CLOSE_WINDOW;
77
+ payload: typeof undefined;
78
+ }
67
79
  export type PopupEvent = {
68
80
  type: typeof POPUP.LOADED | typeof POPUP.CORE_LOADED | typeof POPUP.CANCEL_POPUP_REQUEST;
69
81
  payload?: typeof undefined;
70
- } | PopupInit | PopupHandshake | PopupError | PopupContentScriptLoaded | PopupMethodInfo;
82
+ } | PopupInit | PopupHandshake | PopupError | PopupContentScriptLoaded | PopupMethodInfo | PopupExtensionUsbPermissions | PopupBootstrap | PopupCloseWindow | PopupClosedMessage;
71
83
  export type PopupEventMessage = PopupEvent & {
72
84
  event: typeof UI_EVENT;
73
85
  };
@@ -1,4 +1,4 @@
1
- import type { Deferred } from '@trezor/utils/lib/createDeferred';
1
+ import type { Deferred } from '@trezor/utils';
2
2
  import type { DEVICE } from './device';
3
3
  import type { Device } from '../device/Device';
4
4
  import type { UiResponseEvent } from './ui-response';
@@ -3,5 +3,6 @@ export declare const WEBEXTENSION: {
3
3
  USB_PERMISSIONS_INIT: string;
4
4
  USB_PERMISSIONS_CLOSE: string;
5
5
  USB_PERMISSIONS_FINISHED: string;
6
+ CHANNEL_HANDSHAKE_CONFIRM: string;
6
7
  };
7
8
  //# sourceMappingURL=webextension.d.ts.map
@@ -6,5 +6,6 @@ exports.WEBEXTENSION = {
6
6
  USB_PERMISSIONS_INIT: 'usb-permissions-init',
7
7
  USB_PERMISSIONS_CLOSE: 'usb-permissions-close',
8
8
  USB_PERMISSIONS_FINISHED: 'usb-permissions-finished',
9
+ CHANNEL_HANDSHAKE_CONFIRM: 'channel-handshake-confirm',
9
10
  };
10
11
  //# sourceMappingURL=webextension.js.map
package/lib/factory.js CHANGED
@@ -120,6 +120,7 @@ const factory = ({ eventEmitter, manifest, init, call, requestLogin, uiResponse,
120
120
  cancelCoinjoinAuthorization: params => call({ ...params, method: 'cancelCoinjoinAuthorization' }),
121
121
  showDeviceTutorial: params => call({ ...params, method: 'showDeviceTutorial' }),
122
122
  backupDevice: params => call({ ...params, method: 'backupDevice' }),
123
+ changeLanguage: params => call({ ...params, method: 'changeLanguage' }),
123
124
  changePin: params => call({ ...params, method: 'changePin' }),
124
125
  changeWipeCode: params => call({ ...params, method: 'changeWipeCode' }),
125
126
  firmwareUpdate: params => call({ ...params, method: 'firmwareUpdate' }),
package/lib/index.js CHANGED
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.eventEmitter = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const events_1 = tslib_1.__importDefault(require("events"));
6
- const createDeferredManager_1 = require("@trezor/utils/lib/createDeferredManager");
6
+ const utils_1 = require("@trezor/utils");
7
7
  const core_1 = require("./core");
8
8
  const factory_1 = require("./factory");
9
9
  const connectSettings_1 = require("./data/connectSettings");
@@ -14,7 +14,7 @@ exports.eventEmitter = new events_1.default();
14
14
  const _log = (0, debug_1.initLog)('@trezor/connect');
15
15
  let _settings = (0, connectSettings_1.parseConnectSettings)();
16
16
  let _core = null;
17
- const messagePromises = (0, createDeferredManager_1.createDeferredManager)({ initialId: 1 });
17
+ const messagePromises = (0, utils_1.createDeferredManager)({ initialId: 1 });
18
18
  const manifest = (data) => {
19
19
  _settings = (0, connectSettings_1.parseConnectSettings)({
20
20
  ..._settings,
@@ -3,18 +3,18 @@ import { PROTO } from '../../constants';
3
3
  import type { Params, Response } from '../params';
4
4
  export type ApplySettings = Static<typeof ApplySettings>;
5
5
  export declare const ApplySettings: import("@sinclair/typebox").TObject<{
6
- passphrase_source: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
7
6
  language: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
8
7
  label: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
9
- use_passphrase: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
10
- homescreen: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
11
- _passphrase_source: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
8
+ passphrase_always_on_device: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
9
+ safety_checks: import("@sinclair/typebox").TOptional<import("@trezor/schema-utils/src/custom-types/keyof-enum").TKeyOfEnum<typeof PROTO.Enum_SafetyCheckLevel>>;
12
10
  auto_lock_delay_ms: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
13
11
  display_rotation: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
14
- passphrase_always_on_device: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
15
- safety_checks: import("@sinclair/typebox").TOptional<import("@trezor/schema-utils/lib/custom-types/keyof-enum").TKeyOfEnum<typeof PROTO.Enum_SafetyCheckLevel>>;
16
12
  experimental_features: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
17
13
  hide_passphrase_from_host: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
14
+ use_passphrase: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
15
+ homescreen: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
16
+ _passphrase_source: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
17
+ passphrase_source: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
18
18
  }>;
19
19
  export declare function applySettings(params: Params<ApplySettings>): Response<PROTO.Success>;
20
20
  //# sourceMappingURL=applySettings.d.ts.map
@@ -11,14 +11,14 @@ export declare const BinanceSDKTransaction: import("@sinclair/typebox").TObject<
11
11
  inputs: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
12
12
  address: import("@sinclair/typebox").TString;
13
13
  coins: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
14
- amount: import("@trezor/schema-utils/lib/custom-types/uint").TUint;
14
+ amount: import("@trezor/schema-utils/src/custom-types/uint").TUint;
15
15
  denom: import("@sinclair/typebox").TString;
16
16
  }>>;
17
17
  }>>;
18
18
  outputs: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
19
19
  address: import("@sinclair/typebox").TString;
20
20
  coins: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
21
- amount: import("@trezor/schema-utils/lib/custom-types/uint").TUint;
21
+ amount: import("@trezor/schema-utils/src/custom-types/uint").TUint;
22
22
  denom: import("@sinclair/typebox").TString;
23
23
  }>>;
24
24
  }>>;
@@ -45,14 +45,14 @@ export declare const BinancePreparedMessage: import("@sinclair/typebox").TUnion<
45
45
  inputs: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
46
46
  address: import("@sinclair/typebox").TString;
47
47
  coins: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
48
- amount: import("@trezor/schema-utils/lib/custom-types/uint").TUint;
48
+ amount: import("@trezor/schema-utils/src/custom-types/uint").TUint;
49
49
  denom: import("@sinclair/typebox").TString;
50
50
  }>>;
51
51
  }>>;
52
52
  outputs: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
53
53
  address: import("@sinclair/typebox").TString;
54
54
  coins: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
55
- amount: import("@trezor/schema-utils/lib/custom-types/uint").TUint;
55
+ amount: import("@trezor/schema-utils/src/custom-types/uint").TUint;
56
56
  denom: import("@sinclair/typebox").TString;
57
57
  }>>;
58
58
  }>>;
@@ -88,14 +88,14 @@ export declare const BinancePreparedTransaction: import("@sinclair/typebox").TIn
88
88
  inputs: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
89
89
  address: import("@sinclair/typebox").TString;
90
90
  coins: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
91
- amount: import("@trezor/schema-utils/lib/custom-types/uint").TUint;
91
+ amount: import("@trezor/schema-utils/src/custom-types/uint").TUint;
92
92
  denom: import("@sinclair/typebox").TString;
93
93
  }>>;
94
94
  }>>;
95
95
  outputs: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
96
96
  address: import("@sinclair/typebox").TString;
97
97
  coins: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
98
- amount: import("@trezor/schema-utils/lib/custom-types/uint").TUint;
98
+ amount: import("@trezor/schema-utils/src/custom-types/uint").TUint;
99
99
  denom: import("@sinclair/typebox").TString;
100
100
  }>>;
101
101
  }>>;
@@ -121,14 +121,14 @@ export declare const BinancePreparedTransaction: import("@sinclair/typebox").TIn
121
121
  inputs: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
122
122
  address: import("@sinclair/typebox").TString;
123
123
  coins: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
124
- amount: import("@trezor/schema-utils/lib/custom-types/uint").TUint;
124
+ amount: import("@trezor/schema-utils/src/custom-types/uint").TUint;
125
125
  denom: import("@sinclair/typebox").TString;
126
126
  }>>;
127
127
  }>>;
128
128
  outputs: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
129
129
  address: import("@sinclair/typebox").TString;
130
130
  coins: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
131
- amount: import("@trezor/schema-utils/lib/custom-types/uint").TUint;
131
+ amount: import("@trezor/schema-utils/src/custom-types/uint").TUint;
132
132
  denom: import("@sinclair/typebox").TString;
133
133
  }>>;
134
134
  }>>;
@@ -170,14 +170,14 @@ export declare const BinanceSignTransaction: import("@sinclair/typebox").TObject
170
170
  inputs: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
171
171
  address: import("@sinclair/typebox").TString;
172
172
  coins: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
173
- amount: import("@trezor/schema-utils/lib/custom-types/uint").TUint;
173
+ amount: import("@trezor/schema-utils/src/custom-types/uint").TUint;
174
174
  denom: import("@sinclair/typebox").TString;
175
175
  }>>;
176
176
  }>>;
177
177
  outputs: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
178
178
  address: import("@sinclair/typebox").TString;
179
179
  coins: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
180
- amount: import("@trezor/schema-utils/lib/custom-types/uint").TUint;
180
+ amount: import("@trezor/schema-utils/src/custom-types/uint").TUint;
181
181
  denom: import("@sinclair/typebox").TString;
182
182
  }>>;
183
183
  }>>;