@trezor/connect 9.2.4-beta.1 → 9.2.4-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,10 +1,44 @@
1
1
  | Package | stable | canary |
2
2
  | -------------------------------- | :----: | :----------: |
3
- | npm @trezor/connect | 9.2.2 | 9.2.4-beta.1 |
4
- | npm @trezor/connect-web | 9.2.2 | 9.2.4-beta.1 |
5
- | npm @trezor/connect-webextension | 9.2.2 | 9.2.4-beta.1 |
3
+ | npm @trezor/connect | 9.2.2 | 9.2.4-beta.2 |
4
+ | npm @trezor/connect-web | 9.2.2 | 9.2.4-beta.2 |
5
+ | npm @trezor/connect-webextension | 9.2.2 | 9.2.4-beta.2 |
6
6
  | connect.trezor.io/9 | 9.2.2 | x |
7
7
 
8
+ # 9.2.4-beta.2
9
+
10
+ - chore(connect): re-add feature support checking in cardanoSignTransaction (acf9ffc2cb)
11
+ - chore(connect): fw-update: add error message when binary is too small (b0c1173f8d)
12
+ - chore(connect): remove legacyresults from cardano fixtures (acd9e1e510)
13
+ - chore(connect): bump fw versions required for cardano (c3d96b3ca7)
14
+ - chore(connect): remove validation in cardanoSignTransaction, cardanoAddressParameters, cardanoGetAddress, device.validateState (33efb4b8bd,013047bdb1, 21fadd17a6, 29311b5d61)
15
+ - feat(connect): use full version in URL when beta (26c70f48f7)
16
+ - fix(connect): simultaneous read of connected devices (f181c988a4)
17
+ - chore(connect): DeviceList now has two params - full settings object and messages (b6167266c9)
18
+ - chore(connect): remove DataManager from DeviceList (afc8760213)
19
+ - chore(connect): remove DataManager dependency from DeviceList constructor (7971515d71)
20
+ - chore(connect): simplify reduce code duplication in DeviceList (0cf8a04ed0)
21
+
22
+ ## connect-explorer
23
+
24
+ - fix(connect-explorer): method testing tool scrollbars (f15f6487d8)
25
+ - fix(connect-explorer): support GitHub emoji (fda80e5aa3)
26
+
27
+ ## connect-popup
28
+
29
+ - fix(connect-popup): use PassphraseTypeCardLegacy (629d6f8671)
30
+
31
+ ## transport
32
+
33
+ - feat(transport): make signal required param in constructor (4b82f8d505)
34
+
35
+ ## Dependencies update
36
+
37
+ - npm-release: @trezor/blockchain-link 2.1.30-beta.2
38
+ - npm-release: @trezor/blockchain-link-types 1.0.17-beta.2
39
+ - npm-release: @trezor/connect-analytics 1.0.15-beta.1
40
+ - npm-release: @trezor/transport 1.1.29-beta.1
41
+
8
42
  # 9.2.4-beta.1
9
43
 
10
44
  - feat(connect): BackupDevice now has params (4120912)
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @trezor/connect
2
2
 
3
- API version 9.2.4-beta.1
3
+ API version 9.2.4-beta.2
4
4
 
5
5
  [![Build Status](https://github.com/trezor/trezor-suite/actions/workflows/connect-test.yml/badge.svg)](https://github.com/trezor/trezor-suite/actions/workflows/connect-test.yml)
6
6
  [![NPM](https://img.shields.io/npm/v/@trezor/connect.svg)](https://www.npmjs.org/package/@trezor/connect)
@@ -10,7 +10,7 @@ export default class BlockchainGetCurrentFiatRates extends AbstractMethod<'block
10
10
  init(): void;
11
11
  run(): Promise<{
12
12
  ts: number;
13
- rates: import("@trezor/blockchain-link-types/lib/common").FiatRatesLegacy;
13
+ rates: import("@trezor/blockchain-link-types/lib/common").FiatRatesBySymbol;
14
14
  }>;
15
15
  }
16
16
  export {};
@@ -12,7 +12,7 @@ export default class BlockchainGetFiatRatesForTimestamps extends AbstractMethod<
12
12
  run(): Promise<{
13
13
  tickers: {
14
14
  ts: number;
15
- rates: import("@trezor/blockchain-link-types/lib/common").FiatRatesLegacy;
15
+ rates: import("@trezor/blockchain-link-types/lib/common").FiatRatesBySymbol;
16
16
  }[];
17
17
  }>;
18
18
  }
@@ -20,7 +20,6 @@ export default class CardanoGetAddress extends AbstractMethod<'cardanoGetAddress
20
20
  _call({ address_parameters, protocol_magic, network_id, derivation_type, show_display, chunkify, }: Params): Promise<{
21
21
  address: string;
22
22
  }>;
23
- _ensureFirmwareSupportsBatch(batch: Params): void;
24
23
  run(): Promise<import("../../../types").CardanoAddress | import("../../../types").CardanoAddress[]>;
25
24
  }
26
25
  export {};
@@ -79,27 +79,11 @@ class CardanoGetAddress extends AbstractMethod_1.AbstractMethod {
79
79
  });
80
80
  return response.message;
81
81
  }
82
- _ensureFirmwareSupportsBatch(batch) {
83
- const SCRIPT_ADDRESSES_TYPES = [
84
- constants_1.PROTO.CardanoAddressType.BASE_SCRIPT_KEY,
85
- constants_1.PROTO.CardanoAddressType.BASE_KEY_SCRIPT,
86
- constants_1.PROTO.CardanoAddressType.BASE_SCRIPT_SCRIPT,
87
- constants_1.PROTO.CardanoAddressType.POINTER_SCRIPT,
88
- constants_1.PROTO.CardanoAddressType.ENTERPRISE_SCRIPT,
89
- constants_1.PROTO.CardanoAddressType.REWARD_SCRIPT,
90
- ];
91
- if (SCRIPT_ADDRESSES_TYPES.includes(batch.address_parameters.address_type)) {
92
- if (!this.device.atLeast(['0', '2.4.3'])) {
93
- throw constants_1.ERRORS.TypedError('Method_InvalidParameter', `Address type not supported by device firmware`);
94
- }
95
- }
96
- }
97
82
  async run() {
98
83
  const responses = [];
99
84
  for (let i = 0; i < this.params.length; i++) {
100
85
  const batch = this.params[i];
101
- this._ensureFirmwareSupportsBatch(batch);
102
- batch.address_parameters = (0, cardanoAddressParameters_1.modifyAddressParametersForBackwardsCompatibility)(this.device, batch.address_parameters);
86
+ batch.address_parameters = (0, cardanoAddressParameters_1.modifyAddressParametersForBackwardsCompatibility)(batch.address_parameters);
103
87
  if (batch.show_display) {
104
88
  const silent = await this._call({
105
89
  ...batch,
@@ -5,19 +5,7 @@ import type { OutputWithData } from '../cardanoOutputs';
5
5
  import { PROTO } from '../../../constants';
6
6
  import { type CardanoSignedTxData } from '../../../types/api/cardano';
7
7
  import type { AssetGroupWithTokens } from '../cardanoTokenBundle';
8
- declare const CardanoSignTransactionFeatures: Readonly<{
9
- TransactionStreaming: string[];
10
- TokenMinting: string[];
11
- Multisig: string[];
12
- NetworkIdInTxBody: string[];
13
- OutputDatumHash: string[];
14
- ScriptDataHash: string[];
15
- Plutus: string[];
16
- KeyHashStakeCredential: string[];
17
- Babbage: string[];
18
- CIP36Registration: string[];
19
- CIP36RegistrationExternalPaymentAddress: string[];
20
- }>;
8
+ declare const CardanoSignTransactionFeatures: Readonly<{}>;
21
9
  export type CardanoSignTransactionParams = {
22
10
  signingMode: PROTO.CardanoTxSigningMode;
23
11
  inputsWithPath: InputWithPath[];
@@ -14,19 +14,7 @@ const cardano_1 = require("../../../types/api/cardano");
14
14
  const cardanoWitnesses_1 = require("../cardanoWitnesses");
15
15
  const cardanoTokenBundle_1 = require("../cardanoTokenBundle");
16
16
  const schema_utils_1 = require("@trezor/schema-utils");
17
- const CardanoSignTransactionFeatures = Object.freeze({
18
- TransactionStreaming: ['0', '2.4.2'],
19
- TokenMinting: ['0', '2.4.3'],
20
- Multisig: ['0', '2.4.3'],
21
- NetworkIdInTxBody: ['0', '2.4.4'],
22
- OutputDatumHash: ['0', '2.4.4'],
23
- ScriptDataHash: ['0', '2.4.4'],
24
- Plutus: ['0', '2.4.4'],
25
- KeyHashStakeCredential: ['0', '2.4.4'],
26
- Babbage: ['0', '2.5.2'],
27
- CIP36Registration: ['0', '2.5.3'],
28
- CIP36RegistrationExternalPaymentAddress: ['0', '2.5.4'],
29
- });
17
+ const CardanoSignTransactionFeatures = Object.freeze({});
30
18
  class CardanoSignTransaction extends AbstractMethod_1.AbstractMethod {
31
19
  init() {
32
20
  this.requiredPermissions = ['read', 'write'];
@@ -138,67 +126,6 @@ class CardanoSignTransaction extends AbstractMethod_1.AbstractMethod {
138
126
  }
139
127
  }
140
128
  _ensureFirmwareSupportsParams() {
141
- var _a;
142
- const { params } = this;
143
- this._ensureFeatureIsSupported('TransactionStreaming');
144
- params.certificatesWithPoolOwnersAndRelays.forEach(({ certificate }) => {
145
- if (certificate.key_hash) {
146
- this._ensureFeatureIsSupported('KeyHashStakeCredential');
147
- }
148
- });
149
- params.outputsWithData.forEach(({ output }) => {
150
- if (output.datum_hash) {
151
- this._ensureFeatureIsSupported('OutputDatumHash');
152
- }
153
- });
154
- params.withdrawals.forEach(withdrawal => {
155
- if (withdrawal.key_hash) {
156
- this._ensureFeatureIsSupported('KeyHashStakeCredential');
157
- }
158
- });
159
- if (params.mint.length > 0) {
160
- this._ensureFeatureIsSupported('TokenMinting');
161
- }
162
- if (params.additionalWitnessRequests.length > 0 ||
163
- params.signingMode === constants_1.PROTO.CardanoTxSigningMode.MULTISIG_TRANSACTION) {
164
- this._ensureFeatureIsSupported('Multisig');
165
- }
166
- if (params.includeNetworkId) {
167
- this._ensureFeatureIsSupported('NetworkIdInTxBody');
168
- }
169
- if (params.scriptDataHash) {
170
- this._ensureFeatureIsSupported('ScriptDataHash');
171
- }
172
- if (params.signingMode === constants_1.PROTO.CardanoTxSigningMode.PLUTUS_TRANSACTION) {
173
- this._ensureFeatureIsSupported('Plutus');
174
- }
175
- params.outputsWithData.forEach(({ output, inlineDatum, referenceScript }) => {
176
- if (output.format === constants_1.PROTO.CardanoTxOutputSerializationFormat.MAP_BABBAGE ||
177
- inlineDatum ||
178
- referenceScript) {
179
- this._ensureFeatureIsSupported('Babbage');
180
- }
181
- });
182
- if (params.collateralReturnWithData ||
183
- params.totalCollateral != null ||
184
- params.referenceInputs.length > 0) {
185
- this._ensureFeatureIsSupported('Babbage');
186
- }
187
- if (params.requiredSigners.length > 0 &&
188
- params.signingMode !== constants_1.PROTO.CardanoTxSigningMode.PLUTUS_TRANSACTION) {
189
- this._ensureFeatureIsSupported('Babbage');
190
- }
191
- if ((_a = params.auxiliaryData) === null || _a === void 0 ? void 0 : _a.cvote_registration_parameters) {
192
- const { format, delegations, voting_purpose, payment_address } = params.auxiliaryData.cvote_registration_parameters;
193
- if (format === constants_1.PROTO.CardanoCVoteRegistrationFormat.CIP36 ||
194
- (delegations === null || delegations === void 0 ? void 0 : delegations.length) ||
195
- voting_purpose != null) {
196
- this._ensureFeatureIsSupported('CIP36Registration');
197
- }
198
- if (payment_address) {
199
- this._ensureFeatureIsSupported('CIP36RegistrationExternalPaymentAddress');
200
- }
201
- }
202
129
  }
203
130
  async _sign_tx() {
204
131
  const typedCall = this.device.getCommands().typedCall.bind(this.device.getCommands());
@@ -251,7 +178,7 @@ class CardanoSignTransaction extends AbstractMethod_1.AbstractMethod {
251
178
  if (this.params.auxiliaryData) {
252
179
  const { cvote_registration_parameters } = this.params.auxiliaryData;
253
180
  if (cvote_registration_parameters) {
254
- this.params.auxiliaryData = (0, cardanoAuxiliaryData_1.modifyAuxiliaryDataForBackwardsCompatibility)(this.device, this.params.auxiliaryData);
181
+ this.params.auxiliaryData = (0, cardanoAuxiliaryData_1.modifyAuxiliaryDataForBackwardsCompatibility)(this.params.auxiliaryData);
255
182
  }
256
183
  const { message } = await typedCall('CardanoTxAuxiliaryData', 'CardanoTxAuxiliaryDataSupplement', this.params.auxiliaryData);
257
184
  const auxiliaryDataType = constants_1.PROTO.CardanoTxAuxiliaryDataSupplementType[message.type];
@@ -1,8 +1,7 @@
1
1
  import { PROTO } from '../../constants';
2
- import type { Device } from '../../device/Device';
3
2
  import { CardanoAddressParameters } from '../../types/api/cardano';
4
3
  export declare const validateAddressParameters: (addressParameters: CardanoAddressParameters) => void;
5
- export declare const modifyAddressParametersForBackwardsCompatibility: (device: Device, address_parameters: PROTO.CardanoAddressParametersType) => PROTO.CardanoAddressParametersType;
4
+ export declare const modifyAddressParametersForBackwardsCompatibility: (address_parameters: PROTO.CardanoAddressParametersType) => PROTO.CardanoAddressParametersType;
6
5
  export declare const addressParametersToProto: (addressParameters: CardanoAddressParameters) => PROTO.CardanoAddressParametersType;
7
6
  export declare const addressParametersFromProto: (addressParameters: PROTO.CardanoAddressParametersType) => CardanoAddressParameters;
8
7
  //# sourceMappingURL=cardanoAddressParameters.d.ts.map
@@ -15,21 +15,15 @@ const validateAddressParameters = (addressParameters) => {
15
15
  }
16
16
  };
17
17
  exports.validateAddressParameters = validateAddressParameters;
18
- const modifyAddressParametersForBackwardsCompatibility = (device, address_parameters) => {
18
+ const modifyAddressParametersForBackwardsCompatibility = (address_parameters) => {
19
19
  if (address_parameters.address_type === constants_1.PROTO.CardanoAddressType.REWARD) {
20
20
  let { address_n, address_n_staking } = address_parameters;
21
21
  if (address_n.length > 0 && address_n_staking.length > 0) {
22
22
  throw constants_1.ERRORS.TypedError('Method_InvalidParameter', `Only stakingPath is allowed for CardanoAddressType.REWARD`);
23
23
  }
24
- if (device.atLeast(['0', '2.4.3'])) {
25
- if (address_n.length > 0) {
26
- address_n_staking = address_n;
27
- address_n = [];
28
- }
29
- }
30
- else if (address_n_staking.length > 0) {
31
- address_n = address_n_staking;
32
- address_n_staking = [];
24
+ if (address_n.length > 0) {
25
+ address_n_staking = address_n;
26
+ address_n = [];
33
27
  }
34
28
  return {
35
29
  ...address_parameters,
@@ -1,6 +1,5 @@
1
- import type { Device } from '../../device/Device';
2
1
  import { PROTO } from '../../constants';
3
2
  import { CardanoAuxiliaryData } from '../../types/api/cardano';
4
3
  export declare const transformAuxiliaryData: (auxiliaryData: CardanoAuxiliaryData) => PROTO.CardanoTxAuxiliaryData;
5
- export declare const modifyAuxiliaryDataForBackwardsCompatibility: (device: Device, auxiliary_data: PROTO.CardanoTxAuxiliaryData) => PROTO.CardanoTxAuxiliaryData;
4
+ export declare const modifyAuxiliaryDataForBackwardsCompatibility: (auxiliary_data: PROTO.CardanoTxAuxiliaryData) => PROTO.CardanoTxAuxiliaryData;
6
5
  //# sourceMappingURL=cardanoAuxiliaryData.d.ts.map
@@ -62,11 +62,11 @@ const transformAuxiliaryData = (auxiliaryData) => {
62
62
  };
63
63
  };
64
64
  exports.transformAuxiliaryData = transformAuxiliaryData;
65
- const modifyAuxiliaryDataForBackwardsCompatibility = (device, auxiliary_data) => {
65
+ const modifyAuxiliaryDataForBackwardsCompatibility = (auxiliary_data) => {
66
66
  const { cvote_registration_parameters } = auxiliary_data;
67
67
  if (cvote_registration_parameters === null || cvote_registration_parameters === void 0 ? void 0 : cvote_registration_parameters.payment_address_parameters) {
68
68
  cvote_registration_parameters.payment_address_parameters =
69
- (0, cardanoAddressParameters_1.modifyAddressParametersForBackwardsCompatibility)(device, cvote_registration_parameters.payment_address_parameters);
69
+ (0, cardanoAddressParameters_1.modifyAddressParametersForBackwardsCompatibility)(cvote_registration_parameters.payment_address_parameters);
70
70
  return {
71
71
  ...auxiliary_data,
72
72
  cvote_registration_parameters,
@@ -31,7 +31,7 @@ export declare class Blockchain {
31
31
  token?: string;
32
32
  }): Promise<{
33
33
  ts: number;
34
- rates: import("@trezor/blockchain-link").FiatRatesLegacy;
34
+ rates: import("@trezor/blockchain-link").FiatRatesBySymbol;
35
35
  }>;
36
36
  getFiatRatesForTimestamps(params: {
37
37
  currencies?: string[];
@@ -40,7 +40,7 @@ export declare class Blockchain {
40
40
  }): Promise<{
41
41
  tickers: {
42
42
  ts: number;
43
- rates: import("@trezor/blockchain-link").FiatRatesLegacy;
43
+ rates: import("@trezor/blockchain-link").FiatRatesBySymbol;
44
44
  }[];
45
45
  }>;
46
46
  getAccountBalanceHistory(params: BlockchainLinkParams<'getAccountBalanceHistory'>): Promise<import("@trezor/blockchain-link").AccountBalanceHistory[]>;
package/lib/core/index.js CHANGED
@@ -126,10 +126,10 @@ const initDevice = async (devicePath) => {
126
126
  return device;
127
127
  };
128
128
  const MAX_PIN_TRIES = 3;
129
- const getInvalidDeviceState = async (device, network, preauthorized) => {
129
+ const getInvalidDeviceState = async (device, preauthorized) => {
130
130
  for (let i = 0; i < MAX_PIN_TRIES - 1; ++i) {
131
131
  try {
132
- return await device.validateState(network, preauthorized);
132
+ return await device.validateState(preauthorized);
133
133
  }
134
134
  catch (error) {
135
135
  if (error.message.includes('PIN invalid')) {
@@ -140,7 +140,7 @@ const getInvalidDeviceState = async (device, network, preauthorized) => {
140
140
  }
141
141
  }
142
142
  }
143
- return device.validateState(network, preauthorized);
143
+ return device.validateState(preauthorized);
144
144
  };
145
145
  const inner = async (method, device) => {
146
146
  var _a;
@@ -232,7 +232,7 @@ const inner = async (method, device) => {
232
232
  const isDeviceUnlocked = device.features.unlocked;
233
233
  if (method.useDeviceState) {
234
234
  try {
235
- let invalidDeviceState = await getInvalidDeviceState(device, method.network, method.preauthorized);
235
+ let invalidDeviceState = await getInvalidDeviceState(device, method.preauthorized);
236
236
  if (isUsingPopup) {
237
237
  while (invalidDeviceState) {
238
238
  const uiPromise = uiPromises.create(events_2.UI.INVALID_PASSPHRASE_ACTION, device);
@@ -243,7 +243,7 @@ const inner = async (method, device) => {
243
243
  if (uiResp.payload) {
244
244
  device.setInternalState(undefined);
245
245
  await device.initialize(method.useEmptyPassphrase, method.useCardanoDerivation);
246
- invalidDeviceState = await getInvalidDeviceState(device, method.network, method.preauthorized);
246
+ invalidDeviceState = await getInvalidDeviceState(device, method.preauthorized);
247
247
  }
248
248
  else {
249
249
  device.setExternalState(invalidDeviceState);
@@ -587,7 +587,10 @@ const handleDeviceSelectionChanges = (interruptDevice) => {
587
587
  };
588
588
  const initDeviceList = async (transportReconnect) => {
589
589
  try {
590
- _deviceList = new DeviceList_1.DeviceList();
590
+ _deviceList = new DeviceList_1.DeviceList({
591
+ settings: DataManager_1.DataManager.getSettings(),
592
+ messages: DataManager_1.DataManager.getProtobufMessages(),
593
+ });
591
594
  _deviceList.on(events_2.DEVICE.CONNECT, device => {
592
595
  handleDeviceSelectionChanges();
593
596
  postMessage((0, events_2.createDeviceMessage)(events_2.DEVICE.CONNECT, device));
@@ -119,7 +119,14 @@ const getBinaryHelper = (device, params, log, postMessage, intermediaryVersion)
119
119
  version: device.firmwareRelease.release.version,
120
120
  btcOnly,
121
121
  intermediaryVersion,
122
- }).then(res => {
122
+ })
123
+ .then(res => {
124
+ if (res.byteLength < 200) {
125
+ throw constants_1.ERRORS.TypedError('Runtime', 'Firmware binary is too small');
126
+ }
127
+ return res;
128
+ })
129
+ .then(res => {
123
130
  postMessage((0, events_1.createUiMessage)(events_1.UI.FIRMWARE_PROGRESS, {
124
131
  device: device.toMessageObject(),
125
132
  operation: 'downloading',
@@ -56,6 +56,16 @@ export declare class DataManager {
56
56
  download: string;
57
57
  update: string;
58
58
  };
59
+ brave: {
60
+ version: number;
61
+ download: string;
62
+ update: string;
63
+ };
64
+ edge: {
65
+ version: number;
66
+ download: string;
67
+ update: string;
68
+ };
59
69
  };
60
70
  supportedFirmware: ({
61
71
  coin: string[];
@@ -44,6 +44,16 @@ export declare const config: {
44
44
  download: string;
45
45
  update: string;
46
46
  };
47
+ brave: {
48
+ version: number;
49
+ download: string;
50
+ update: string;
51
+ };
52
+ edge: {
53
+ version: number;
54
+ download: string;
55
+ update: string;
56
+ };
47
57
  };
48
58
  supportedFirmware: ({
49
59
  coin: string[];
@@ -103,6 +103,16 @@ exports.config = {
103
103
  download: 'https://www.mozilla.org/en-US/firefox/new/',
104
104
  update: 'https://support.mozilla.org/en-US/kb/update-firefox-latest-version',
105
105
  },
106
+ brave: {
107
+ version: 59,
108
+ download: 'https://brave.com/download/',
109
+ update: 'https://brave.com/download/',
110
+ },
111
+ edge: {
112
+ version: 79,
113
+ download: 'https://www.microsoft.com/en-us/edge',
114
+ update: 'https://www.microsoft.com/en-us/edge',
115
+ },
106
116
  },
107
117
  supportedFirmware: [
108
118
  {
@@ -140,18 +150,18 @@ exports.config = {
140
150
  },
141
151
  {
142
152
  methods: ['cardanoGetAddress', 'cardanoGetPublicKey'],
143
- min: { T1B1: '0', T2T1: '2.3.2' },
144
- comment: ['Shelley fork support since firmware 2.3.2'],
153
+ min: { T1B1: '0', T2T1: '2.4.3' },
154
+ comment: ['Since 2.4.3 Cardano derivation behavior has changed'],
145
155
  },
146
156
  {
147
157
  methods: ['cardanoSignTransaction'],
148
- min: { T1B1: '0', T2T1: '2.4.2' },
149
- comment: ['Non-streamed signing no longer supported'],
158
+ min: { T1B1: '0', T2T1: '2.6.0' },
159
+ comment: ['Before 2.6.0 not all Cardano transactions were supported'],
150
160
  },
151
161
  {
152
162
  methods: ['cardanoGetNativeScriptHash'],
153
163
  min: { T1B1: '0', T2T1: '2.4.3' },
154
- comment: ['Cardano GetNativeScriptHash call added in 2.4.3'],
164
+ comment: ['Since 2.4.3 Cardano derivation behavior has changed'],
155
165
  },
156
166
  {
157
167
  methods: ['tezosSignTransaction'],
@@ -1,3 +1,3 @@
1
- export declare const VERSION = "9.2.4-beta.1";
1
+ export declare const VERSION = "9.2.4-beta.2";
2
2
  export declare const DEFAULT_DOMAIN: string;
3
3
  //# sourceMappingURL=version.d.ts.map
@@ -1,7 +1,10 @@
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.2.4-beta.1';
4
+ exports.VERSION = '9.2.4-beta.2';
5
5
  const versionN = exports.VERSION.split('.').map(s => parseInt(s, 10));
6
- exports.DEFAULT_DOMAIN = `https://connect.trezor.io/${versionN[0]}/`;
6
+ const isBeta = exports.VERSION.includes('beta');
7
+ exports.DEFAULT_DOMAIN = isBeta
8
+ ? `https://connect.trezor.io/${exports.VERSION}/`
9
+ : `https://connect.trezor.io/${versionN[0]}/`;
7
10
  //# sourceMappingURL=version.js.map
@@ -70,7 +70,7 @@ export declare class Device extends TypedEmitter<DeviceEvents> {
70
70
  getInternalState(): string;
71
71
  setExternalState(state?: string): void;
72
72
  getExternalState(): string;
73
- validateState(networkType?: NETWORK.NetworkType, preauthorized?: boolean): Promise<string | undefined>;
73
+ validateState(preauthorized?: boolean): Promise<string | undefined>;
74
74
  useLegacyPassphrase(): boolean;
75
75
  initialize(useEmptyPassphrase: boolean, useCardanoDerivation: boolean): Promise<void>;
76
76
  getFeatures(): Promise<void>;
@@ -265,7 +265,7 @@ class Device extends utils_1.TypedEmitter {
265
265
  getExternalState() {
266
266
  return this.externalState[this.instance];
267
267
  }
268
- async validateState(networkType, preauthorized = false) {
268
+ async validateState(preauthorized = false) {
269
269
  if (!this.features)
270
270
  return;
271
271
  if (!this.features.unlocked && preauthorized) {
@@ -274,7 +274,7 @@ class Device extends utils_1.TypedEmitter {
274
274
  }
275
275
  }
276
276
  const expectedState = this.getExternalState();
277
- const state = await this.getCommands().getDeviceState(networkType);
277
+ const state = await this.getCommands().getDeviceState();
278
278
  const uniqueState = `${state}@${this.features.device_id || 'device_id'}:${this.instance}`;
279
279
  if (!this.useLegacyPassphrase() && this.features.session_id) {
280
280
  this.setInternalState(this.features.session_id);
@@ -71,13 +71,13 @@ export declare class DeviceCommands {
71
71
  }>;
72
72
  ethereumGetPublicKey({ address_n, show_display, }: Messages.EthereumGetPublicKey): Promise<HDNodeResponse>;
73
73
  preauthorize(throwError: boolean): Promise<boolean>;
74
- getDeviceState(networkType?: string): Promise<string>;
74
+ getDeviceState(): Promise<string>;
75
75
  private call;
76
76
  typedCall<T extends MessageKey, R extends MessageKey[]>(type: T, resType: R, msg?: MessageType[T]): Promise<TypedCallResponseMap[R[number]]>;
77
77
  typedCall<T extends MessageKey, R extends MessageKey>(type: T, resType: R, msg?: MessageType[T]): Promise<TypedResponseMessage<R>>;
78
78
  _commonCall(type: MessageKey, msg?: DefaultMessageResponse['message']): Promise<DefaultMessageResponse>;
79
79
  _filterCommonTypes(res: DefaultMessageResponse): Promise<DefaultMessageResponse>;
80
- _getAddressForNetworkType(networkType?: string): Promise<string>;
80
+ private _getAddress;
81
81
  _promptPin(type?: Messages.PinMatrixRequestType): Promise<string>;
82
82
  _promptPassphrase(): Promise<PassphrasePromptResponse>;
83
83
  _promptWord(type: Messages.WordRequestType): Promise<string>;
@@ -197,11 +197,8 @@ class DeviceCommands {
197
197
  return false;
198
198
  }
199
199
  }
200
- getDeviceState(networkType) {
201
- if (!this.device.atLeast('2.4.3')) {
202
- return this._getAddressForNetworkType(networkType);
203
- }
204
- return this._getAddressForNetworkType();
200
+ getDeviceState() {
201
+ return this._getAddress();
205
202
  }
206
203
  async call(type, msg = {}) {
207
204
  logger.debug('Sending', type, filterForLog(type, msg));
@@ -324,30 +321,13 @@ class DeviceCommands {
324
321
  }
325
322
  return Promise.resolve(res);
326
323
  }
327
- async _getAddressForNetworkType(networkType) {
328
- switch (networkType) {
329
- case constants_1.NETWORK.TYPES.cardano: {
330
- const { message } = await this.typedCall('CardanoGetAddress', 'CardanoAddress', {
331
- address_parameters: {
332
- address_type: 8,
333
- address_n: [(0, pathUtils_1.toHardened)(44), (0, pathUtils_1.toHardened)(1815), (0, pathUtils_1.toHardened)(0), 0, 0],
334
- address_n_staking: [],
335
- },
336
- protocol_magic: 42,
337
- network_id: 0,
338
- derivation_type: 2,
339
- });
340
- return message.address;
341
- }
342
- default: {
343
- const { message } = await this.typedCall('GetAddress', 'Address', {
344
- address_n: [(0, pathUtils_1.toHardened)(44), (0, pathUtils_1.toHardened)(1), (0, pathUtils_1.toHardened)(0), 0, 0],
345
- coin_name: 'Testnet',
346
- script_type: 'SPENDADDRESS',
347
- });
348
- return message.address;
349
- }
350
- }
324
+ async _getAddress() {
325
+ const { message } = await this.typedCall('GetAddress', 'Address', {
326
+ address_n: [(0, pathUtils_1.toHardened)(44), (0, pathUtils_1.toHardened)(1), (0, pathUtils_1.toHardened)(0), 0, 0],
327
+ coin_name: 'Testnet',
328
+ script_type: 'SPENDADDRESS',
329
+ });
330
+ return message.address;
351
331
  }
352
332
  _promptPin(type) {
353
333
  return new Promise((resolve, reject) => {
@@ -2,7 +2,7 @@ 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';
5
- import type { Device as DeviceTyped } from '../types';
5
+ import type { ConnectSettings, Device as DeviceTyped } from '../types';
6
6
  interface DeviceListEvents {
7
7
  [TRANSPORT.START]: TransportInfo;
8
8
  [TRANSPORT.ERROR]: string;
@@ -19,7 +19,6 @@ export declare class DeviceList extends TypedEmitter<DeviceListEvents> {
19
19
  devices: {
20
20
  [path: string]: Device;
21
21
  };
22
- messages: JSON | Record<string, any>;
23
22
  creatingDevicesDescriptors: {
24
23
  [k: string]: Descriptor;
25
24
  };
@@ -28,7 +27,11 @@ export declare class DeviceList extends TypedEmitter<DeviceListEvents> {
28
27
  [deviceID: string]: number;
29
28
  };
30
29
  transportFirstEventPromise: Promise<void> | undefined;
31
- constructor();
30
+ private settings;
31
+ constructor({ settings, messages, }: {
32
+ settings: ConnectSettings;
33
+ messages: Record<string, any>;
34
+ });
32
35
  init(): Promise<void>;
33
36
  private resolveTransportEvent;
34
37
  waitForTransportFirstEvent(): Promise<void>;
@@ -6,62 +6,62 @@ const transport_1 = require("@trezor/transport");
6
6
  const constants_1 = require("../constants");
7
7
  const events_1 = require("../events");
8
8
  const Device_1 = require("./Device");
9
- const DataManager_1 = require("../data/DataManager");
10
9
  const transportInfo_1 = require("../data/transportInfo");
11
10
  const debug_1 = require("../utils/debug");
12
11
  const promiseUtils_1 = require("../utils/promiseUtils");
13
12
  const _log = (0, debug_1.initLog)('DeviceList');
14
13
  let autoResolveTransportEventTimeout;
15
14
  class DeviceList extends utils_1.TypedEmitter {
16
- constructor() {
15
+ constructor({ settings, messages, }) {
17
16
  super();
18
17
  this.transports = [];
19
18
  this.devices = {};
20
19
  this.creatingDevicesDescriptors = {};
21
20
  this.transportStartPending = 0;
22
21
  this.penalizedDevices = {};
23
- let { transports } = DataManager_1.DataManager.getSettings();
24
- const { debug } = DataManager_1.DataManager.getSettings();
25
- this.messages = DataManager_1.DataManager.getProtobufMessages();
26
- if (!(transports === null || transports === void 0 ? void 0 : transports.length)) {
27
- transports = ['BridgeTransport'];
22
+ this.settings = settings;
23
+ const transports = [...(settings.transports || [])];
24
+ if (!transports.length) {
25
+ transports.push('BridgeTransport');
28
26
  }
29
- const transportLogger = (0, debug_1.initLog)('@trezor/transport', debug);
27
+ const transportLogger = (0, debug_1.initLog)('@trezor/transport', this.settings.debug);
28
+ const abortController = new AbortController();
29
+ const transportCommonArgs = {
30
+ messages,
31
+ logger: transportLogger,
32
+ signal: abortController.signal,
33
+ };
30
34
  transports.forEach(transportType => {
31
35
  if (typeof transportType === 'string') {
32
36
  switch (transportType) {
33
37
  case 'WebUsbTransport':
34
- this.transports.push(new transport_1.WebUsbTransport({
35
- messages: this.messages,
36
- logger: transportLogger,
37
- }));
38
+ this.transports.push(new transport_1.WebUsbTransport(transportCommonArgs));
38
39
  break;
39
40
  case 'NodeUsbTransport':
40
- this.transports.push(new transport_1.NodeUsbTransport({
41
- messages: this.messages,
42
- logger: transportLogger,
43
- }));
41
+ this.transports.push(new transport_1.NodeUsbTransport(transportCommonArgs));
44
42
  break;
45
43
  case 'BridgeTransport':
46
44
  this.transports.push(new transport_1.BridgeTransport({
47
45
  latestVersion: (0, transportInfo_1.getBridgeInfo)().version.join('.'),
48
- messages: this.messages,
49
- logger: transportLogger,
46
+ ...transportCommonArgs,
50
47
  }));
51
48
  break;
52
49
  case 'UdpTransport':
53
- this.transports.push(new transport_1.UdpTransport({
54
- logger: transportLogger,
55
- messages: this.messages,
56
- }));
50
+ this.transports.push(new transport_1.UdpTransport(transportCommonArgs));
57
51
  break;
58
52
  default:
59
53
  throw constants_1.ERRORS.TypedError('Runtime', `DeviceList.init: transports[] of unexpected type: ${transportType}`);
60
54
  }
61
55
  }
56
+ else if (typeof transportType === 'function' && 'prototype' in transportType) {
57
+ const transportInstance = new transportType(transportCommonArgs);
58
+ if ((0, transport_1.isTransportInstance)(transportInstance)) {
59
+ this.transports.push(transportInstance);
60
+ }
61
+ }
62
62
  else if ((0, transport_1.isTransportInstance)(transportType)) {
63
63
  if (!transportType.getMessage()) {
64
- transportType.updateMessages(this.messages);
64
+ transportType.updateMessages(messages);
65
65
  }
66
66
  this.transports.push(transportType);
67
67
  }
@@ -102,7 +102,7 @@ class DeviceList extends utils_1.TypedEmitter {
102
102
  diff.connected.forEach(async (descriptor) => {
103
103
  const path = descriptor.path.toString();
104
104
  this.creatingDevicesDescriptors[path] = descriptor;
105
- const priority = DataManager_1.DataManager.getSettings('priority');
105
+ const { priority } = this.settings;
106
106
  const penalty = this.getAuthPenalty();
107
107
  if (priority || penalty) {
108
108
  await (0, promiseUtils_1.resolveAfter)(501 + penalty + 100 * priority, null).promise;
@@ -188,7 +188,7 @@ class DeviceList extends utils_1.TypedEmitter {
188
188
  return;
189
189
  }
190
190
  const descriptors = enumerateResult.payload;
191
- if (descriptors.length > 0 && DataManager_1.DataManager.getSettings('pendingTransportEvent')) {
191
+ if (descriptors.length > 0 && this.settings.pendingTransportEvent) {
192
192
  this.transportStartPending = descriptors.length;
193
193
  this.on(events_1.DEVICE.CONNECT, this.resolveTransportEvent.bind(this));
194
194
  this.on(events_1.DEVICE.CONNECT_UNACQUIRED, this.resolveTransportEvent.bind(this));
@@ -329,6 +329,7 @@ class DeviceList extends utils_1.TypedEmitter {
329
329
  error.message === transport_1.TRANSPORT_ERROR.DEVICE_NOT_FOUND ||
330
330
  error.message === transport_1.TRANSPORT_ERROR.DEVICE_DISCONNECTED_DURING_ACTION ||
331
331
  error.message === transport_1.TRANSPORT_ERROR.UNEXPECTED_ERROR ||
332
+ error.message === transport_1.TRANSPORT_ERROR.DESCRIPTOR_NOT_FOUND ||
332
333
  error.message === transport_1.TRANSPORT_ERROR.HTTP_ERROR) {
333
334
  delete this.devices[path];
334
335
  }
@@ -1,4 +1,4 @@
1
- import type { ServerInfo, BlockEvent, FiatRatesLegacy, NotificationEvent } from '@trezor/blockchain-link';
1
+ import type { ServerInfo, BlockEvent, FiatRatesBySymbol, 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";
@@ -37,7 +37,7 @@ export interface BlockchainNotification {
37
37
  }
38
38
  export interface BlockchainFiatRatesUpdate {
39
39
  coin: CoinInfo;
40
- rates: FiatRatesLegacy;
40
+ rates: FiatRatesBySymbol;
41
41
  }
42
42
  export type BlockchainEvent = {
43
43
  type: typeof BLOCKCHAIN.CONNECT;
@@ -19,5 +19,5 @@ export type { ComposeOutput, PrecomposeResultError, PrecomposeResultNonFinal, Pr
19
19
  export type { PrecomposedTransactionCardano, PrecomposedTransactionErrorCardano, PrecomposedTransactionFinalCardano, PrecomposedTransactionNonFinalCardano, } from './api/cardanoComposeTransaction';
20
20
  export type { RecoveryDevice } from './api/recoveryDevice';
21
21
  export type { AuthenticateDeviceResult } from './api/authenticateDevice';
22
- export type { TokenInfo, TokenTransfer, InternalTransfer, FiatRatesLegacy, Target as TransactionTarget, AccountBalanceHistory as BlockchainAccountBalanceHistory, } from '@trezor/blockchain-link';
22
+ export type { TokenInfo, TokenTransfer, InternalTransfer, FiatRatesBySymbol, Target as TransactionTarget, AccountBalanceHistory as BlockchainAccountBalanceHistory, } from '@trezor/blockchain-link';
23
23
  //# sourceMappingURL=index.d.ts.map
@@ -15,7 +15,7 @@ export interface ConnectSettings {
15
15
  popup?: boolean;
16
16
  transportReconnect?: boolean;
17
17
  webusb?: boolean;
18
- transports?: (Transport['name'] | Transport)[];
18
+ transports?: (Transport['name'] | Transport | (new (...args: any[]) => Transport))[];
19
19
  pendingTransportEvent?: boolean;
20
20
  lazyLoad?: boolean;
21
21
  interactionTimeout?: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trezor/connect",
3
- "version": "9.2.4-beta.1",
3
+ "version": "9.2.4-beta.2",
4
4
  "author": "Trezor <info@trezor.io>",
5
5
  "homepage": "https://github.com/trezor/trezor-suite/tree/develop/packages/connect",
6
6
  "description": "High-level javascript interface for Trezor hardware wallet.",
@@ -70,14 +70,14 @@
70
70
  "@ethereumjs/common": "^4.2.0",
71
71
  "@ethereumjs/tx": "^5.2.1",
72
72
  "@fivebinaries/coin-selection": "2.2.1",
73
- "@trezor/blockchain-link": "2.1.29",
74
- "@trezor/blockchain-link-types": "1.0.17-beta.1",
75
- "@trezor/connect-analytics": "1.0.14",
73
+ "@trezor/blockchain-link": "2.1.30-beta.2",
74
+ "@trezor/blockchain-link-types": "1.0.17-beta.2",
75
+ "@trezor/connect-analytics": "1.0.15-beta.1",
76
76
  "@trezor/connect-common": "0.0.33-beta.1",
77
77
  "@trezor/protobuf": "1.0.13-beta.1",
78
78
  "@trezor/protocol": "1.0.9-beta.1",
79
79
  "@trezor/schema-utils": "1.0.4-beta.1",
80
- "@trezor/transport": "1.1.28",
80
+ "@trezor/transport": "1.1.29-beta.1",
81
81
  "@trezor/utils": "9.0.23",
82
82
  "@trezor/utxo-lib": "2.0.9",
83
83
  "bignumber.js": "^9.1.2",