@trezor/connect 9.0.6 → 9.0.8

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 (97) hide show
  1. package/CHANGELOG.md +22 -2
  2. package/README.md +1 -1
  3. package/lib/api/authorizeCoinjoin.d.ts +7 -0
  4. package/lib/api/{authorizeCoinJoin.js → authorizeCoinjoin.js} +3 -3
  5. package/lib/api/bitcoin/createPendingTx.d.ts +35 -0
  6. package/lib/api/bitcoin/createPendingTx.js +60 -0
  7. package/lib/api/bitcoin/index.d.ts +1 -0
  8. package/lib/api/bitcoin/index.js +1 -0
  9. package/lib/api/blockchainGetAccountBalanceHistory.d.ts +1 -1
  10. package/lib/api/blockchainGetCurrentFiatRates.d.ts +2 -1
  11. package/lib/api/blockchainGetCurrentFiatRates.js +6 -1
  12. package/lib/api/blockchainGetFiatRatesForTimestamps.d.ts +3 -1
  13. package/lib/api/blockchainGetFiatRatesForTimestamps.js +9 -1
  14. package/lib/api/blockchainGetTransactions.d.ts +1 -1
  15. package/lib/api/cardano/cardanoAuxiliaryData.js +43 -23
  16. package/lib/api/cardanoSignTransaction.d.ts +2 -1
  17. package/lib/api/cardanoSignTransaction.js +21 -11
  18. package/lib/api/composeTransaction.js +2 -2
  19. package/lib/api/ethereum/ethereumDefinitions.d.ts +7 -0
  20. package/lib/api/ethereum/ethereumDefinitions.js +43 -0
  21. package/lib/api/ethereum/ethereumSignTx.d.ts +3 -2
  22. package/lib/api/ethereum/ethereumSignTx.js +4 -2
  23. package/lib/api/ethereumGetAddress.d.ts +2 -1
  24. package/lib/api/ethereumGetAddress.js +19 -2
  25. package/lib/api/ethereumSignMessage.js +13 -0
  26. package/lib/api/ethereumSignTransaction.js +10 -3
  27. package/lib/api/ethereumSignTypedData.js +13 -0
  28. package/lib/api/firmware/getBinary.d.ts +3 -12
  29. package/lib/api/firmware/getBinary.js +5 -9
  30. package/lib/api/firmwareUpdate.d.ts +3 -2
  31. package/lib/api/firmwareUpdate.js +4 -5
  32. package/lib/api/getAccountInfo.d.ts +8 -8
  33. package/lib/api/getAccountInfo.js +1 -1
  34. package/lib/api/index.d.ts +1 -1
  35. package/lib/api/index.js +3 -3
  36. package/lib/api/setBusy.js +1 -4
  37. package/lib/api/setProxy.js +1 -1
  38. package/lib/api/signTransaction.d.ts +2 -1
  39. package/lib/api/signTransaction.js +12 -2
  40. package/lib/api/unlockPath.js +1 -4
  41. package/lib/backend/Blockchain.d.ts +3 -0
  42. package/lib/core/AbstractMethod.d.ts +1 -0
  43. package/lib/core/AbstractMethod.js +9 -0
  44. package/lib/core/index.d.ts +1 -1
  45. package/lib/core/index.js +24 -11
  46. package/lib/core/method.d.ts +1 -1
  47. package/lib/data/DataManager.d.ts +92 -15
  48. package/lib/data/DataManager.js +3 -53
  49. package/lib/data/config.js +9 -3
  50. package/lib/data/connectSettings.d.ts +0 -1
  51. package/lib/data/connectSettings.js +14 -58
  52. package/lib/data/firmwareInfo.js +48 -46
  53. package/lib/data/transportInfo.d.ts +1 -0
  54. package/lib/data/transportInfo.js +14 -1
  55. package/lib/data/udevInfo.d.ts +1 -0
  56. package/lib/data/udevInfo.js +14 -1
  57. package/lib/data/version.d.ts +1 -1
  58. package/lib/data/version.js +1 -1
  59. package/lib/device/DescriptorStream.js +1 -1
  60. package/lib/device/Device.js +1 -2
  61. package/lib/device/DeviceCommands.d.ts +1 -1
  62. package/lib/device/DeviceCommands.js +6 -7
  63. package/lib/device/DeviceList.d.ts +1 -2
  64. package/lib/device/DeviceList.js +27 -19
  65. package/lib/events/iframe.d.ts +2 -1
  66. package/lib/events/popup.d.ts +2 -1
  67. package/lib/events/transport.d.ts +2 -1
  68. package/lib/factory.js +1 -1
  69. package/lib/index.js +5 -4
  70. package/lib/types/api/{authorizeCoinJoin.d.ts → authorizeCoinjoin.d.ts} +3 -3
  71. package/lib/types/api/{authorizeCoinJoin.js → authorizeCoinjoin.js} +1 -1
  72. package/lib/types/api/bitcoin/index.d.ts +4 -0
  73. package/lib/types/api/cardano/index.d.ts +10 -9
  74. package/lib/types/api/firmwareUpdate.d.ts +2 -1
  75. package/lib/types/api/index.d.ts +2 -2
  76. package/lib/types/firmware.d.ts +2 -3
  77. package/lib/types/index.d.ts +1 -1
  78. package/lib/types/params.d.ts +1 -0
  79. package/lib/types/settings.d.ts +12 -1
  80. package/lib/utils/firmwareUtils.d.ts +0 -1
  81. package/lib/utils/firmwareUtils.js +1 -9
  82. package/lib/utils/pathUtils.d.ts +1 -0
  83. package/lib/utils/pathUtils.js +3 -1
  84. package/lib/utils/promiseUtils.d.ts +5 -1
  85. package/lib/utils/promiseUtils.js +7 -3
  86. package/lib/utils/urlUtils.d.ts +2 -1
  87. package/lib/utils/urlUtils.js +18 -3
  88. package/lib/utils/versionUtils.d.ts +3 -1
  89. package/lib/utils/versionUtils.js +5 -2
  90. package/package.json +16 -16
  91. package/lib/api/authorizeCoinJoin.d.ts +0 -7
  92. package/lib/device/AbortController.d.ts +0 -21
  93. package/lib/device/AbortController.js +0 -40
  94. package/lib/utils/browserUtils.d.ts +0 -21
  95. package/lib/utils/browserUtils.js +0 -100
  96. package/lib/utils/windowsUtils.d.ts +0 -2
  97. package/lib/utils/windowsUtils.js +0 -6
@@ -14,9 +14,9 @@ const transportInfo_1 = require("../data/transportInfo");
14
14
  const debug_1 = require("../utils/debug");
15
15
  const promiseUtils_1 = require("../utils/promiseUtils");
16
16
  const workers_1 = require("../workers/workers");
17
- const AbortController_1 = require("./AbortController");
18
17
  const { BridgeV2, Fallback } = transport_1.default;
19
18
  const _log = (0, debug_1.initLog)('DeviceList');
19
+ let autoResolveTransportEventTimeout;
20
20
  class DeviceList extends events_1.default {
21
21
  constructor() {
22
22
  var _a;
@@ -25,23 +25,27 @@ class DeviceList extends events_1.default {
25
25
  this.creatingDevicesDescriptors = {};
26
26
  this.transportStartPending = 0;
27
27
  this.penalizedDevices = {};
28
- const { env, webusb } = DataManager_1.DataManager.settings;
28
+ const env = DataManager_1.DataManager.getSettings('env');
29
+ let transportSettings = DataManager_1.DataManager.getSettings('transports');
29
30
  const transports = [];
31
+ if (!(transportSettings === null || transportSettings === void 0 ? void 0 : transportSettings.length)) {
32
+ transportSettings = ['BridgeTransport'];
33
+ }
30
34
  if (env === 'react-native' && typeof workers_1.ReactNativeUsbPlugin !== 'undefined') {
31
35
  transports.push((0, workers_1.ReactNativeUsbPlugin)());
32
36
  }
33
- else {
37
+ else if (transportSettings === null || transportSettings === void 0 ? void 0 : transportSettings.includes('BridgeTransport')) {
34
38
  const bridgeLatestVersion = (0, transportInfo_1.getBridgeInfo)().version.join('.');
35
39
  const bridge = new BridgeV2(undefined, undefined);
36
40
  bridge.setBridgeLatestVersion(bridgeLatestVersion);
37
- this.fetchController = (0, AbortController_1.getAbortController)();
41
+ this.fetchController = new AbortController();
38
42
  const { signal } = this.fetchController;
39
43
  const fetchWithSignal = (args, options = {}) => (0, cross_fetch_1.default)(args, { ...options, signal });
40
44
  const isNode = !!((_a = process === null || process === void 0 ? void 0 : process.release) === null || _a === void 0 ? void 0 : _a.name) && process.release.name.search(/node|io\.js/) !== -1;
41
45
  BridgeV2.setFetch(fetchWithSignal, isNode);
42
46
  transports.push(bridge);
43
47
  }
44
- if (webusb && typeof workers_1.WebUsbPlugin !== 'undefined') {
48
+ if ((transportSettings === null || transportSettings === void 0 ? void 0 : transportSettings.includes('WebUsbTransport')) && typeof workers_1.WebUsbPlugin !== 'undefined') {
45
49
  transports.push((0, workers_1.WebUsbPlugin)());
46
50
  }
47
51
  this.transport = new Fallback(transports);
@@ -56,7 +60,7 @@ class DeviceList extends events_1.default {
56
60
  await transport.configure(JSON.stringify(this.messages));
57
61
  _log.debug('Configuring transports done');
58
62
  const { activeName } = transport;
59
- if (activeName === 'LowlevelTransportWithSharedConnections') {
63
+ if (activeName === 'WebUsbTransport') {
60
64
  this.transportPlugin = transport.activeTransport.plugin;
61
65
  }
62
66
  await this._initStream();
@@ -88,9 +92,15 @@ class DeviceList extends events_1.default {
88
92
  const stream = new DescriptorStream_1.DescriptorStream(this.transport);
89
93
  stream.on(events_2.TRANSPORT.START_PENDING, (pending) => {
90
94
  this.transportStartPending = pending;
95
+ autoResolveTransportEventTimeout = setTimeout(() => {
96
+ this.resolveTransportEvent();
97
+ }, 5000);
91
98
  });
92
99
  stream.on(events_2.TRANSPORT.START, () => {
93
100
  this.emit(events_2.TRANSPORT.START, this.getTransportInfo());
101
+ if (autoResolveTransportEventTimeout) {
102
+ clearTimeout(autoResolveTransportEventTimeout);
103
+ }
94
104
  });
95
105
  stream.on(events_2.TRANSPORT.UPDATE, (diff) => {
96
106
  new DiffHandler(this, diff).handle();
@@ -156,15 +166,9 @@ class DeviceList extends events_1.default {
156
166
  return this.asArray().length;
157
167
  }
158
168
  transportType() {
159
- const { transport, transportPlugin } = this;
169
+ const { transport } = this;
160
170
  const { activeName } = transport;
161
- if (activeName === 'BridgeTransport') {
162
- return 'bridge';
163
- }
164
- if (transportPlugin) {
165
- return transportPlugin.name;
166
- }
167
- return transport.name;
171
+ return activeName || 'UnknownTransport';
168
172
  }
169
173
  getTransportInfo() {
170
174
  return {
@@ -178,6 +182,9 @@ class DeviceList extends events_1.default {
178
182
  if (this.stream) {
179
183
  this.stream.stop();
180
184
  }
185
+ if (autoResolveTransportEventTimeout) {
186
+ clearTimeout(autoResolveTransportEventTimeout);
187
+ }
181
188
  await Promise.all(this.allDevices().map(device => device.dispose()));
182
189
  if (this.transport) {
183
190
  this.transport.stop();
@@ -238,20 +245,21 @@ class CreateDeviceHandler {
238
245
  this.path = descriptor.path.toString();
239
246
  }
240
247
  async handle() {
248
+ var _a;
241
249
  this.list.creatingDevicesDescriptors[this.path] = this.descriptor;
242
250
  try {
243
251
  await this._takeAndCreateDevice();
244
252
  }
245
253
  catch (error) {
246
254
  _log.debug('Cannot create device', error);
247
- if (error.code === 'Device_NotFound') {
255
+ if (error.code === 'Device_NotFound' || error.message === 'device not found') {
248
256
  }
249
257
  else if (error.message === constants_1.ERRORS.WRONG_PREVIOUS_SESSION_ERROR_MESSAGE ||
250
258
  error.toString() === constants_1.ERRORS.WEBUSB_ERROR_MESSAGE) {
251
259
  this.list.enumerate();
252
260
  this._handleUsedElsewhere();
253
261
  }
254
- else if (error.message.indexOf(constants_1.ERRORS.LIBUSB_ERROR_MESSAGE) >= 0) {
262
+ else if (((_a = error.message) === null || _a === void 0 ? void 0 : _a.indexOf(constants_1.ERRORS.LIBUSB_ERROR_MESSAGE)) >= 0) {
255
263
  const device = this.list._createUnreadableDevice(this.list.creatingDevicesDescriptors[this.path], error.message);
256
264
  this.list.devices[this.path] = device;
257
265
  this.list.emit(events_2.DEVICE.CONNECT_UNACQUIRED, device.toMessageObject());
@@ -263,7 +271,7 @@ class CreateDeviceHandler {
263
271
  this._handleUsedElsewhere();
264
272
  }
265
273
  else {
266
- await (0, promiseUtils_1.resolveAfter)(501, null);
274
+ await (0, promiseUtils_1.resolveAfter)(501, null).promise;
267
275
  await this.handle();
268
276
  }
269
277
  }
@@ -337,7 +345,7 @@ class DiffHandler {
337
345
  const penalty = this.list.getAuthPenalty();
338
346
  _log.debug('Connected', priority, penalty, descriptor.session, this.list.devices);
339
347
  if (priority || penalty) {
340
- await (0, promiseUtils_1.resolveAfter)(501 + penalty + 100 * priority, null);
348
+ await (0, promiseUtils_1.resolveAfter)(501 + penalty + 100 * priority, null).promise;
341
349
  }
342
350
  if (descriptor.session == null) {
343
351
  await this.list._createAndSaveDevice(descriptor);
@@ -363,7 +371,7 @@ class DiffHandler {
363
371
  const device = this.list.devices[path];
364
372
  if (device) {
365
373
  if (device.isUnacquired() && !device.isInconsistent()) {
366
- await (0, promiseUtils_1.resolveAfter)(501, null);
374
+ await (0, promiseUtils_1.resolveAfter)(501, null).promise;
367
375
  _log.debug('Create device from unacquired', device);
368
376
  await this.list._createAndSaveDevice(descriptor);
369
377
  }
@@ -1,5 +1,5 @@
1
1
  import { UI_EVENT } from './ui-request';
2
- import type { ConnectSettings } from '../types';
2
+ import type { ConnectSettings, SystemInfo } from '../types';
3
3
  import type { MessageFactoryFn } from '../types/utils';
4
4
  export declare const IFRAME: {
5
5
  readonly BOOTSTRAP: "iframe-bootstrap";
@@ -19,6 +19,7 @@ export interface IFrameLoaded {
19
19
  type: typeof IFRAME.LOADED;
20
20
  payload: {
21
21
  useBroadcastChannel: boolean;
22
+ systemInfo: SystemInfo;
22
23
  };
23
24
  }
24
25
  export interface IFrameInit {
@@ -1,6 +1,6 @@
1
1
  import { UI_EVENT } from './ui-request';
2
2
  import type { TransportInfo } from './transport';
3
- import type { ConnectSettings } from '../types';
3
+ import type { ConnectSettings, SystemInfo } from '../types';
4
4
  import type { MessageFactoryFn } from '../types/utils';
5
5
  export declare const POPUP: {
6
6
  readonly BOOTSTRAP: "popup-bootstrap";
@@ -18,6 +18,7 @@ export interface PopupInit {
18
18
  payload: {
19
19
  settings: ConnectSettings;
20
20
  useBroadcastChannel: boolean;
21
+ systemInfo: SystemInfo;
21
22
  };
22
23
  }
23
24
  export interface PopupHandshake {
@@ -1,4 +1,5 @@
1
1
  import type { MessageFactoryFn } from '../types/utils';
2
+ import type { Transport } from '@trezor/transport';
2
3
  export declare const TRANSPORT_EVENT = "TRANSPORT_EVENT";
3
4
  export declare const TRANSPORT: {
4
5
  readonly START: "transport-start";
@@ -32,7 +33,7 @@ export interface UdevInfo {
32
33
  }[];
33
34
  }
34
35
  export interface TransportInfo {
35
- type: string;
36
+ type: Transport['name'];
36
37
  version: string;
37
38
  outdated: boolean;
38
39
  bridge?: BridgeInfo;
package/lib/factory.js CHANGED
@@ -110,7 +110,7 @@ const factory = ({ eventEmitter, manifest, init, call, requestLogin, uiResponse,
110
110
  checkFirmwareAuthenticity: params => call({ ...params, method: 'checkFirmwareAuthenticity' }),
111
111
  applyFlags: params => call({ ...params, method: 'applyFlags' }),
112
112
  applySettings: params => call({ ...params, method: 'applySettings' }),
113
- authorizeCoinJoin: params => call({ ...params, method: 'authorizeCoinJoin' }),
113
+ authorizeCoinjoin: params => call({ ...params, method: 'authorizeCoinjoin' }),
114
114
  backupDevice: params => call({ ...params, method: 'backupDevice' }),
115
115
  changePin: params => call({ ...params, method: 'changePin' }),
116
116
  firmwareUpdate: params => call({ ...params, method: 'firmwareUpdate' }),
package/lib/index.js CHANGED
@@ -90,16 +90,17 @@ function postMessage(message, usePromise = true) {
90
90
  _core.handleMessage(message, true);
91
91
  }
92
92
  const init = async (settings = {}) => {
93
+ var _a;
93
94
  if (_core) {
94
95
  throw constants_1.ERRORS.TypedError('Init_AlreadyInitialized');
95
96
  }
96
- _settings = (0, connectSettings_1.parseConnectSettings)({ ..._settings, ...settings });
97
- _settings.origin = 'http://node.trezor.io/';
98
- _settings.popup = false;
99
- _settings.env = 'node';
97
+ _settings = (0, connectSettings_1.parseConnectSettings)({ ..._settings, ...settings, popup: false });
100
98
  if (!_settings.manifest) {
101
99
  throw constants_1.ERRORS.TypedError('Init_ManifestMissing');
102
100
  }
101
+ if (!((_a = _settings.transports) === null || _a === void 0 ? void 0 : _a.length)) {
102
+ _settings.transports = ['BridgeTransport'];
103
+ }
103
104
  if (_settings.lazyLoad) {
104
105
  _settings.lazyLoad = false;
105
106
  return;
@@ -1,6 +1,6 @@
1
1
  import type { PROTO } from '../../constants';
2
2
  import type { Params, Response } from '../params';
3
- export interface AuthorizeCoinJoin {
3
+ export interface AuthorizeCoinjoin {
4
4
  path: string | number[];
5
5
  coordinator: string;
6
6
  maxRounds: number;
@@ -11,5 +11,5 @@ export interface AuthorizeCoinJoin {
11
11
  amountUnit?: PROTO.AmountUnit;
12
12
  preauthorized?: boolean;
13
13
  }
14
- export declare function authorizeCoinJoin(params: Params<AuthorizeCoinJoin>): Response<PROTO.Success>;
15
- //# sourceMappingURL=authorizeCoinJoin.d.ts.map
14
+ export declare function authorizeCoinjoin(params: Params<AuthorizeCoinjoin>): Response<PROTO.Success>;
15
+ //# sourceMappingURL=authorizeCoinjoin.d.ts.map
@@ -1,3 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=authorizeCoinJoin.js.map
3
+ //# sourceMappingURL=authorizeCoinjoin.js.map
@@ -1,5 +1,7 @@
1
1
  import type { PROTO } from '../../../constants';
2
2
  import type { AccountAddresses } from '@trezor/blockchain-link';
3
+ import type { Transaction as BlockbookTransaction } from '@trezor/blockchain-link-types/lib/blockbook';
4
+ import { AccountUtxo } from '../../account';
3
5
  export interface SignMessage {
4
6
  path: string | number[];
5
7
  coin: string;
@@ -54,6 +56,7 @@ export interface SignTransaction {
54
56
  refTxs?: RefTransaction[];
55
57
  account?: {
56
58
  addresses: AccountAddresses;
59
+ utxo: AccountUtxo[];
57
60
  };
58
61
  coin: string;
59
62
  locktime?: number;
@@ -76,6 +79,7 @@ export type SignedTransaction = {
76
79
  serializedTx: string;
77
80
  witnesses?: (string | undefined)[];
78
81
  txid?: string;
82
+ signedTransaction?: BlockbookTransaction;
79
83
  };
80
84
  export interface VerifyMessage {
81
85
  address: string;
@@ -137,22 +137,23 @@ export interface CardanoReferenceInput {
137
137
  prev_hash: string;
138
138
  prev_index: number;
139
139
  }
140
- export interface CardanoGovernanceRegistrationDelegation {
141
- votingPublicKey: string;
140
+ export interface CardanoCVoteRegistrationDelegation {
141
+ votePublicKey: string;
142
142
  weight: number;
143
143
  }
144
- export interface CardanoGovernanceRegistrationParameters {
145
- votingPublicKey?: string;
144
+ export interface CardanoCVoteRegistrationParameters {
145
+ votePublicKey?: string;
146
146
  stakingPath: string | number[];
147
- rewardAddressParameters: CardanoAddressParameters;
147
+ paymentAddressParameters?: CardanoAddressParameters;
148
148
  nonce: string;
149
- format?: PROTO.CardanoGovernanceRegistrationFormat;
150
- delegations?: CardanoGovernanceRegistrationDelegation[];
149
+ format?: PROTO.CardanoCVoteRegistrationFormat;
150
+ delegations?: CardanoCVoteRegistrationDelegation[];
151
151
  votingPurpose?: number;
152
+ paymentAddress?: string;
152
153
  }
153
154
  export interface CardanoAuxiliaryData {
154
155
  hash?: string;
155
- governanceRegistrationParameters?: CardanoGovernanceRegistrationParameters;
156
+ cVoteRegistrationParameters?: CardanoCVoteRegistrationParameters;
156
157
  }
157
158
  export interface CardanoSignTransaction {
158
159
  inputs: CardanoInput[];
@@ -186,7 +187,7 @@ export interface CardanoSignedTxWitness {
186
187
  export interface CardanoAuxiliaryDataSupplement {
187
188
  type: PROTO.CardanoTxAuxiliaryDataSupplementType;
188
189
  auxiliaryDataHash: string;
189
- governanceSignature?: string;
190
+ cVoteRegistrationSignature?: string;
190
191
  }
191
192
  export interface CardanoSignedTxData {
192
193
  hash: string;
@@ -1,3 +1,4 @@
1
+ import type { IntermediaryVersion } from '../firmware';
1
2
  import type { Params, Response } from '../params';
2
3
  export interface FirmwareUpdateBinary {
3
4
  binary: ArrayBuffer;
@@ -6,7 +7,7 @@ export interface FirmwareUpdate {
6
7
  version: number[];
7
8
  btcOnly?: boolean;
8
9
  baseUrl?: string;
9
- intermediary?: boolean;
10
+ intermediaryVersion?: IntermediaryVersion;
10
11
  }
11
12
  export interface FirmwareUpdateResponse {
12
13
  hash: string;
@@ -1,6 +1,6 @@
1
1
  import { applyFlags } from './applyFlags';
2
2
  import { applySettings } from './applySettings';
3
- import { authorizeCoinJoin } from './authorizeCoinJoin';
3
+ import { authorizeCoinjoin } from './authorizeCoinjoin';
4
4
  import { backupDevice } from './backupDevice';
5
5
  import { binanceGetAddress } from './binanceGetAddress';
6
6
  import { binanceGetPublicKey } from './binanceGetPublicKey';
@@ -78,7 +78,7 @@ import { checkFirmwareAuthenticity } from './checkFirmwareAuthenticity';
78
78
  export interface TrezorConnect {
79
79
  applyFlags: typeof applyFlags;
80
80
  applySettings: typeof applySettings;
81
- authorizeCoinJoin: typeof authorizeCoinJoin;
81
+ authorizeCoinjoin: typeof authorizeCoinjoin;
82
82
  backupDevice: typeof backupDevice;
83
83
  binanceGetAddress: typeof binanceGetAddress;
84
84
  binanceGetPublicKey: typeof binanceGetPublicKey;
@@ -22,15 +22,14 @@ export type FirmwareRelease = {
22
22
  url_bitcoinonly?: string;
23
23
  fingerprint_bitcoinonly?: string;
24
24
  notes?: string;
25
- rollout?: number;
26
25
  channel?: string;
27
26
  };
27
+ export type IntermediaryVersion = 1 | 2 | 3;
28
28
  export type ReleaseInfo = {
29
29
  changelog: FirmwareRelease[] | null;
30
30
  release: FirmwareRelease;
31
- isLatest: boolean;
32
- latest: FirmwareRelease;
33
31
  isRequired: boolean | null;
34
32
  isNewer: boolean | null;
33
+ intermediaryVersion?: IntermediaryVersion;
35
34
  };
36
35
  //# sourceMappingURL=firmware.d.ts.map
@@ -15,5 +15,5 @@ export * from './api/stellar';
15
15
  export * from './api/tezos';
16
16
  export type { ComposeOutput, PrecomposedTransaction } from './api/composeTransaction';
17
17
  export type { RecoveryDevice } from './api/recoveryDevice';
18
- export type { TokenInfo, Transaction as AccountTransaction, Target as TransactionTarget, AccountBalanceHistory as BlockchainAccountBalanceHistory, } from '@trezor/blockchain-link';
18
+ export type { TokenInfo, TokenTransfer, InternalTransfer, FiatRates, Transaction as AccountTransaction, Target as TransactionTarget, AccountBalanceHistory as BlockchainAccountBalanceHistory, } from '@trezor/blockchain-link';
19
19
  //# sourceMappingURL=index.d.ts.map
@@ -8,6 +8,7 @@ export interface CommonParams {
8
8
  useEventListener?: boolean;
9
9
  allowSeedlessDevice?: boolean;
10
10
  keepSession?: boolean;
11
+ override?: boolean;
11
12
  skipFinalReload?: boolean;
12
13
  useCardanoDerivation?: boolean;
13
14
  }
@@ -1,4 +1,5 @@
1
1
  import type { BlockchainSettings } from '@trezor/blockchain-link';
2
+ import type { Transport } from '@trezor/transport';
2
3
  export interface Manifest {
3
4
  appUrl: string;
4
5
  email: string;
@@ -13,6 +14,7 @@ export interface ConnectSettings {
13
14
  popup?: boolean;
14
15
  transportReconnect?: boolean;
15
16
  webusb?: boolean;
17
+ transports?: Transport['name'][];
16
18
  pendingTransportEvent?: boolean;
17
19
  lazyLoad?: boolean;
18
20
  interactionTimeout?: number;
@@ -24,10 +26,19 @@ export interface ConnectSettings {
24
26
  version: string;
25
27
  priority: number;
26
28
  trustedHost: boolean;
27
- supportedBrowser?: boolean;
28
29
  extension?: string;
29
30
  env: 'node' | 'web' | 'webextension' | 'electron' | 'react-native';
30
31
  timestamp: number;
31
32
  proxy?: Proxy;
32
33
  }
34
+ export interface SystemInfo {
35
+ os: {
36
+ family?: 'Linux' | 'MacOS' | 'Windows';
37
+ mobile: boolean;
38
+ };
39
+ browser: {
40
+ supported: boolean;
41
+ outdated: boolean;
42
+ };
43
+ }
33
44
  //# sourceMappingURL=settings.d.ts.map
@@ -1,7 +1,6 @@
1
1
  import type { Features, StrictFeatures, FirmwareRelease, VersionArray } from '../types';
2
2
  export declare const isStrictFeatures: (extFeatures: Features) => extFeatures is StrictFeatures;
3
3
  export declare const isValidReleases: (extReleases: any) => extReleases is FirmwareRelease[];
4
- export declare const getScore: (device_id: string) => number;
5
4
  export declare const filterSafeListByBootloader: (releasesList: FirmwareRelease[], bootloaderVersion: VersionArray) => FirmwareRelease[];
6
5
  export declare const filterSafeListByFirmware: (releasesList: FirmwareRelease[], firmwareVersion: VersionArray) => FirmwareRelease[];
7
6
  //# sourceMappingURL=firmwareUtils.d.ts.map
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.filterSafeListByFirmware = exports.filterSafeListByBootloader = exports.getScore = exports.isValidReleases = exports.isStrictFeatures = void 0;
4
- const crypto_1 = require("crypto");
3
+ exports.filterSafeListByFirmware = exports.filterSafeListByBootloader = exports.isValidReleases = exports.isStrictFeatures = void 0;
5
4
  const utils_1 = require("@trezor/utils");
6
5
  const isStrictFeatures = (extFeatures) => [1, 2].includes(extFeatures.major_version) &&
7
6
  (extFeatures.firmware_present === false ||
@@ -11,13 +10,6 @@ exports.isStrictFeatures = isStrictFeatures;
11
10
  const isValidReleases = (extReleases) => Array.isArray(extReleases) &&
12
11
  extReleases.every(release => release.version && release.min_firmware_version && release.min_bootloader_version);
13
12
  exports.isValidReleases = isValidReleases;
14
- const getScore = (device_id) => {
15
- const hash = (0, crypto_1.createHash)('sha256');
16
- hash.update(device_id);
17
- const output = parseInt(hash.digest('hex'), 16) / 2 ** 256;
18
- return Math.round(output * 100) / 100;
19
- };
20
- exports.getScore = getScore;
21
13
  const filterSafeListByBootloader = (releasesList, bootloaderVersion) => releasesList.filter(item => (!item.min_bootloader_version ||
22
14
  utils_1.versionUtils.isNewerOrEqual(bootloaderVersion, item.min_bootloader_version)) &&
23
15
  (!item.bootloader_version ||
@@ -3,6 +3,7 @@ import type { CoinInfo } from '../types';
3
3
  export declare const HD_HARDENED = 2147483648;
4
4
  export declare const toHardened: (n: number) => number;
5
5
  export declare const fromHardened: (n: number) => number;
6
+ export declare const getSlip44ByPath: (path: number[]) => number;
6
7
  export declare const getHDPath: (path: string) => number[];
7
8
  export declare const isSegwitPath: (path: number[] | undefined) => boolean;
8
9
  export declare const isBech32Path: (path: number[] | undefined) => boolean;
@@ -1,12 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getLabel = exports.fixPath = exports.getIndexFromPath = exports.getPathFromIndex = exports.getSerializedPath = exports.validatePath = exports.getOutputScriptType = exports.getScriptType = exports.getAccountType = exports.isTaprootPath = exports.isBech32Path = exports.isSegwitPath = exports.getHDPath = exports.fromHardened = exports.toHardened = exports.HD_HARDENED = void 0;
3
+ exports.getLabel = exports.fixPath = exports.getIndexFromPath = exports.getPathFromIndex = exports.getSerializedPath = exports.validatePath = exports.getOutputScriptType = exports.getScriptType = exports.getAccountType = exports.isTaprootPath = exports.isBech32Path = exports.isSegwitPath = exports.getHDPath = exports.getSlip44ByPath = exports.fromHardened = exports.toHardened = exports.HD_HARDENED = void 0;
4
4
  const constants_1 = require("../constants");
5
5
  exports.HD_HARDENED = 0x80000000;
6
6
  const toHardened = (n) => (n | exports.HD_HARDENED) >>> 0;
7
7
  exports.toHardened = toHardened;
8
8
  const fromHardened = (n) => (n & ~exports.HD_HARDENED) >>> 0;
9
9
  exports.fromHardened = fromHardened;
10
+ const getSlip44ByPath = (path) => (0, exports.fromHardened)(path[1]);
11
+ exports.getSlip44ByPath = getSlip44ByPath;
10
12
  const PATH_NOT_VALID = constants_1.ERRORS.TypedError('Method_InvalidParameter', 'Not a valid path');
11
13
  const PATH_NEGATIVE_VALUES = constants_1.ERRORS.TypedError('Method_InvalidParameter', 'Path cannot contain negative values');
12
14
  const getHDPath = (path) => {
@@ -1,2 +1,6 @@
1
- export declare const resolveAfter: (msec: number, value?: any) => Promise<any>;
1
+ /// <reference types="node" />
2
+ export declare const resolveAfter: (msec: number, value?: any) => {
3
+ promise: Promise<any>;
4
+ timeout: NodeJS.Timeout | undefined;
5
+ };
2
6
  //# sourceMappingURL=promiseUtils.d.ts.map
@@ -1,8 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.resolveAfter = void 0;
4
- const resolveAfter = (msec, value) => new Promise(resolve => {
5
- setTimeout(resolve, msec, value);
6
- });
4
+ const resolveAfter = (msec, value) => {
5
+ let timeout;
6
+ const promise = new Promise(resolve => {
7
+ timeout = setTimeout(resolve, msec, value);
8
+ });
9
+ return { promise, timeout };
10
+ };
7
11
  exports.resolveAfter = resolveAfter;
8
12
  //# sourceMappingURL=promiseUtils.js.map
@@ -1,4 +1,5 @@
1
- export declare const getOrigin: (url: string) => string;
1
+ export declare const getOrigin: (url: unknown) => string;
2
+ export declare const getHost: (url: unknown) => string | undefined;
2
3
  export declare const getOnionDomain: <T extends string | string[]>(url: T, dict: {
3
4
  [domain: string]: string;
4
5
  }) => T;
@@ -1,15 +1,30 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getOnionDomain = exports.getOrigin = void 0;
3
+ exports.getOnionDomain = exports.getHost = exports.getOrigin = void 0;
4
4
  const getOrigin = (url) => {
5
+ var _a;
5
6
  if (typeof url !== 'string')
6
7
  return 'unknown';
7
8
  if (url.indexOf('file://') === 0)
8
9
  return 'file://';
9
- const parts = url.match(/^.+\:\/\/[^\/]+/);
10
- return Array.isArray(parts) && parts.length > 0 ? parts[0] : 'unknown';
10
+ const [origin] = (_a = url.match(/^https?:\/\/[^/]+/)) !== null && _a !== void 0 ? _a : [];
11
+ return origin !== null && origin !== void 0 ? origin : 'unknown';
11
12
  };
12
13
  exports.getOrigin = getOrigin;
14
+ const getHost = (url) => {
15
+ var _a;
16
+ if (typeof url !== 'string')
17
+ return;
18
+ const [, , uri] = (_a = url.match(/^(https?):\/\/([^:/]+)?/i)) !== null && _a !== void 0 ? _a : [];
19
+ if (uri) {
20
+ const parts = uri.split('.');
21
+ return parts.length > 2
22
+ ?
23
+ parts.slice(parts.length - 2, parts.length).join('.')
24
+ : uri;
25
+ }
26
+ };
27
+ exports.getHost = getHost;
13
28
  const getOnionDomain = (url, dict) => {
14
29
  var _a;
15
30
  if (Array.isArray(url)) {
@@ -1,5 +1,7 @@
1
+ import type { VersionArray } from '../types';
1
2
  export declare const isValidVersionString: (version: string) => boolean;
2
- export declare const isValidVersionArray: (version: number[]) => boolean;
3
+ export declare const isValidVersionArray: (version: (number | null)[]) => boolean;
4
+ export declare const isVersionArray: (arr: (number | null)[]) => arr is VersionArray;
3
5
  export declare const normalizeVersionArray: (version: number[]) => number[];
4
6
  export declare const versionSplit: (version: string) => number[];
5
7
  export declare const versionCompare: (a: string | number[], b: string | number[]) => 1 | 0 | -1;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.versionCompare = exports.versionSplit = exports.normalizeVersionArray = exports.isValidVersionArray = exports.isValidVersionString = void 0;
3
+ exports.versionCompare = exports.versionSplit = exports.normalizeVersionArray = exports.isVersionArray = exports.isValidVersionArray = exports.isValidVersionString = void 0;
4
4
  const VER_NUMS = 3;
5
5
  const versionRegex = new RegExp(/^[0-9]{1,3}(\.[0-9]{1,3}){0,2}$/);
6
6
  const isValidVersionString = (version) => versionRegex.test(version);
@@ -16,13 +16,16 @@ const isValidVersionArray = (version) => {
16
16
  return false;
17
17
  }
18
18
  for (let i = 0; i < version.length; i++) {
19
- if (typeof version[i] !== 'number' || version[i] < 0) {
19
+ const versionNumber = version[i];
20
+ if (typeof versionNumber !== 'number' || versionNumber === null || versionNumber < 0) {
20
21
  return false;
21
22
  }
22
23
  }
23
24
  return true;
24
25
  };
25
26
  exports.isValidVersionArray = isValidVersionArray;
27
+ const isVersionArray = (arr) => (0, exports.isValidVersionArray)(arr);
28
+ exports.isVersionArray = isVersionArray;
26
29
  const normalizeVersionArray = (version) => {
27
30
  if (version.length === VER_NUMS) {
28
31
  return version;