@trezor/connect 9.1.3 → 9.1.4

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 (58) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/README.md +3 -1
  3. package/lib/api/bitcoin/TransactionComposer.js +1 -9
  4. package/lib/api/bitcoin/inputs.d.ts +2 -2
  5. package/lib/api/bitcoin/outputs.d.ts +2 -2
  6. package/lib/api/cardanoGetPublicKey.d.ts +6 -2
  7. package/lib/api/cardanoGetPublicKey.js +7 -1
  8. package/lib/api/checkFirmwareAuthenticity.js +2 -3
  9. package/lib/api/common/paramsValidator.js +7 -7
  10. package/lib/api/eos/eosSignTx.js +1 -1
  11. package/lib/api/firmwareUpdate.js +2 -3
  12. package/lib/api/getAccountInfo.d.ts +1 -1
  13. package/lib/api/getAccountInfo.js +5 -1
  14. package/lib/api/getPublicKey.d.ts +2 -1
  15. package/lib/api/getPublicKey.js +7 -1
  16. package/lib/api/signTransaction.js +1 -1
  17. package/lib/core/AbstractMethod.d.ts +4 -4
  18. package/lib/core/AbstractMethod.js +4 -3
  19. package/lib/core/index.js +12 -9
  20. package/lib/data/coinInfo.d.ts +5 -5
  21. package/lib/data/coinInfo.js +1 -1
  22. package/lib/data/config.js +4 -5
  23. package/lib/data/firmwareInfo.js +2 -3
  24. package/lib/data/models.d.ts +18 -0
  25. package/lib/data/models.js +21 -0
  26. package/lib/data/version.d.ts +1 -1
  27. package/lib/data/version.js +1 -1
  28. package/lib/device/Device.d.ts +4 -2
  29. package/lib/device/Device.js +29 -14
  30. package/lib/device/DeviceCommands.js +4 -4
  31. package/lib/device/DeviceList.d.ts +1 -1
  32. package/lib/device/DeviceList.js +6 -0
  33. package/lib/events/ui-promise.d.ts +10 -2
  34. package/lib/types/api/authorizeCoinjoin.d.ts +2 -2
  35. package/lib/types/api/binance/index.d.ts +2 -1
  36. package/lib/types/api/bitcoin/index.d.ts +6 -5
  37. package/lib/types/api/cardano/index.d.ts +12 -12
  38. package/lib/types/api/cipherKeyValue.d.ts +2 -2
  39. package/lib/types/api/eos/index.d.ts +3 -2
  40. package/lib/types/api/ethereum/index.d.ts +5 -4
  41. package/lib/types/api/getAccountInfo.d.ts +1 -0
  42. package/lib/types/api/getOwnershipId.d.ts +2 -2
  43. package/lib/types/api/getOwnershipProof.d.ts +2 -2
  44. package/lib/types/api/nem/index.d.ts +2 -1
  45. package/lib/types/api/ripple/index.d.ts +2 -1
  46. package/lib/types/api/stellar/index.d.ts +2 -1
  47. package/lib/types/api/tezos/index.d.ts +3 -2
  48. package/lib/types/api/unlockPath.d.ts +2 -2
  49. package/lib/types/device.d.ts +6 -0
  50. package/lib/types/firmware.d.ts +2 -2
  51. package/lib/types/params.d.ts +14 -2
  52. package/lib/utils/deviceFeaturesUtils.js +4 -4
  53. package/lib/utils/pathUtils.d.ts +3 -3
  54. package/package.json +11 -13
  55. package/lib/utils/deferred.d.ts +0 -18
  56. package/lib/utils/deferred.js +0 -66
  57. package/lib/utils/versionUtils.d.ts +0 -8
  58. package/lib/utils/versionUtils.js +0 -75
@@ -2,16 +2,16 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Device = void 0;
4
4
  const typedEventEmitter_1 = require("@trezor/utils/lib/typedEventEmitter");
5
+ const utils_1 = require("@trezor/utils");
5
6
  const DeviceCommands_1 = require("./DeviceCommands");
6
7
  const constants_1 = require("../constants");
7
8
  const events_1 = require("../events");
8
9
  const coinInfo_1 = require("../data/coinInfo");
9
10
  const firmwareInfo_1 = require("../data/firmwareInfo");
10
11
  const deviceFeaturesUtils_1 = require("../utils/deviceFeaturesUtils");
11
- const versionUtils_1 = require("../utils/versionUtils");
12
- const deferred_1 = require("../utils/deferred");
13
12
  const debug_1 = require("../utils/debug");
14
13
  const types_1 = require("../types");
14
+ const models_1 = require("../data/models");
15
15
  const _log = (0, debug_1.initLog)('Device');
16
16
  const parseRunOptions = (options) => {
17
17
  if (!options)
@@ -32,9 +32,10 @@ class Device extends typedEventEmitter_1.TypedEmitter {
32
32
  this.externalState = [];
33
33
  this.unavailableCapabilities = {};
34
34
  this.networkTypeState = [];
35
+ this.name = 'Trezor';
35
36
  this.transport = transport;
36
37
  this.originalDescriptor = descriptor;
37
- this.firstRunPromise = (0, deferred_1.create)();
38
+ this.firstRunPromise = (0, utils_1.createDeferred)();
38
39
  }
39
40
  static fromDescriptor(transport, originalDescriptor) {
40
41
  const descriptor = { ...originalDescriptor, session: null };
@@ -64,7 +65,7 @@ class Device extends typedEventEmitter_1.TypedEmitter {
64
65
  if (!acquireResult.success) {
65
66
  if (this.runPromise) {
66
67
  this.runPromise.reject(new Error(acquireResult.error));
67
- this.runPromise = null;
68
+ delete this.runPromise;
68
69
  }
69
70
  throw acquireResult.error;
70
71
  }
@@ -105,7 +106,7 @@ class Device extends typedEventEmitter_1.TypedEmitter {
105
106
  }
106
107
  async cleanup() {
107
108
  this.removeAllListeners();
108
- this.runPromise = null;
109
+ delete this.runPromise;
109
110
  await this.release();
110
111
  }
111
112
  run(fn, options) {
@@ -114,8 +115,9 @@ class Device extends typedEventEmitter_1.TypedEmitter {
114
115
  throw constants_1.ERRORS.TypedError('Device_CallInProgress');
115
116
  }
116
117
  options = parseRunOptions(options);
117
- this.runPromise = (0, deferred_1.create)(this._runInner.bind(this, fn, options));
118
- return this.runPromise.promise;
118
+ const runPromise = (0, utils_1.createDeferred)();
119
+ this.runPromise = runPromise;
120
+ return Promise.race([this._runInner(fn, options), runPromise.promise]);
119
121
  }
120
122
  async override(error) {
121
123
  if (this.acquirePromise) {
@@ -132,7 +134,7 @@ class Device extends typedEventEmitter_1.TypedEmitter {
132
134
  _log.debug('interruptionFromUser');
133
135
  if (this.runPromise) {
134
136
  this.runPromise.reject(error);
135
- this.runPromise = null;
137
+ delete this.runPromise;
136
138
  }
137
139
  if (this.commands) {
138
140
  await this.commands.cancel();
@@ -145,7 +147,7 @@ class Device extends typedEventEmitter_1.TypedEmitter {
145
147
  }
146
148
  if (this.runPromise) {
147
149
  this.runPromise.reject(constants_1.ERRORS.TypedError('Device_UsedElsewhere'));
148
- this.runPromise = null;
150
+ delete this.runPromise;
149
151
  }
150
152
  this.transport.releaseDevice(this.originalDescriptor.path);
151
153
  }
@@ -173,7 +175,7 @@ class Device extends typedEventEmitter_1.TypedEmitter {
173
175
  return this._runInner(() => Promise.resolve({}), options);
174
176
  }
175
177
  this.inconsistent = true;
176
- this.runPromise = null;
178
+ delete this.runPromise;
177
179
  return Promise.reject(constants_1.ERRORS.TypedError('Device_InitializeFailed', `Initialize failed: ${error.message} ${error.code ? `, code: ${error.code}` : ''}`));
178
180
  }
179
181
  }
@@ -197,7 +199,7 @@ class Device extends typedEventEmitter_1.TypedEmitter {
197
199
  if (this.runPromise) {
198
200
  this.runPromise.resolve();
199
201
  }
200
- this.runPromise = null;
202
+ delete this.runPromise;
201
203
  if (!this.loaded) {
202
204
  this.loaded = true;
203
205
  this.firstRunPromise.resolve(true);
@@ -305,7 +307,8 @@ class Device extends typedEventEmitter_1.TypedEmitter {
305
307
  const capabilitiesDidChange = this.features &&
306
308
  this.features.capabilities &&
307
309
  this.features.capabilities.join('') !== capabilities.join('');
308
- if ((0, versionUtils_1.versionCompare)(version, this.getVersion()) !== 0 || capabilitiesDidChange) {
310
+ if (!utils_1.versionUtils.isEqual(version.join('.'), this.getVersion().join('.')) ||
311
+ capabilitiesDidChange) {
309
312
  this.unavailableCapabilities = (0, deviceFeaturesUtils_1.getUnavailableCapabilities)(feat, (0, coinInfo_1.getAllNetworks)());
310
313
  this.firmwareStatus = (0, firmwareInfo_1.getFirmwareStatus)(feat);
311
314
  this.firmwareRelease = (0, firmwareInfo_1.getRelease)(feat);
@@ -332,6 +335,14 @@ class Device extends typedEventEmitter_1.TypedEmitter {
332
335
  ? types_1.FirmwareType.BitcoinOnly
333
336
  : types_1.FirmwareType.Regular;
334
337
  }
338
+ const deviceInfo = models_1.models[feat.internal_model];
339
+ this.name = deviceInfo.name;
340
+ if (feat === null || feat === void 0 ? void 0 : feat.unit_color) {
341
+ const deviceUnitColor = feat.unit_color.toString();
342
+ if (deviceUnitColor in deviceInfo.colors) {
343
+ this.color = deviceInfo.colors[deviceUnitColor].toLowerCase();
344
+ }
345
+ }
335
346
  }
336
347
  isUnacquired() {
337
348
  return this.features === undefined;
@@ -340,7 +351,7 @@ class Device extends typedEventEmitter_1.TypedEmitter {
340
351
  _log.debug('Disconnect cleanup');
341
352
  this.activitySessionID = null;
342
353
  this.interruptionFromUser(constants_1.ERRORS.TypedError('Device_Disconnected'));
343
- this.runPromise = null;
354
+ delete this.runPromise;
344
355
  }
345
356
  isBootloader() {
346
357
  return this.features && !!this.features.bootloader_mode;
@@ -367,7 +378,7 @@ class Device extends typedEventEmitter_1.TypedEmitter {
367
378
  if (!this.features)
368
379
  return false;
369
380
  const modelVersion = typeof versions === 'string' ? versions : versions[this.features.major_version - 1];
370
- return (0, versionUtils_1.versionCompare)(this.getVersion(), modelVersion) >= 0;
381
+ return utils_1.versionUtils.isNewerOrEqual(this.getVersion().join('.'), modelVersion);
371
382
  }
372
383
  isUsed() {
373
384
  return typeof this.originalDescriptor.session === 'string';
@@ -443,6 +454,7 @@ class Device extends typedEventEmitter_1.TypedEmitter {
443
454
  path: this.originalDescriptor.path,
444
455
  error: this.unreadableError,
445
456
  label: 'Unreadable device',
457
+ name: this.name,
446
458
  };
447
459
  }
448
460
  if (this.isUnacquired()) {
@@ -450,6 +462,7 @@ class Device extends typedEventEmitter_1.TypedEmitter {
450
462
  type: 'unacquired',
451
463
  path: this.originalDescriptor.path,
452
464
  label: 'Unacquired device',
465
+ name: this.name,
453
466
  };
454
467
  }
455
468
  const defaultLabel = 'My Trezor';
@@ -465,6 +478,8 @@ class Device extends typedEventEmitter_1.TypedEmitter {
465
478
  state: this.getExternalState(),
466
479
  status,
467
480
  mode: this.getMode(),
481
+ name: this.name,
482
+ color: this.color,
468
483
  firmware: this.firmwareStatus,
469
484
  firmwareRelease: this.firmwareRelease,
470
485
  firmwareType: this.firmwareType,
@@ -2,13 +2,13 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DeviceCommands = void 0;
4
4
  const tslib_1 = require("tslib");
5
- const randombytes_1 = tslib_1.__importDefault(require("randombytes"));
5
+ const crypto_1 = require("crypto");
6
+ const utils_1 = require("@trezor/utils");
6
7
  const constants_1 = require("../constants");
7
8
  const events_1 = require("../events");
8
9
  const hdnodeUtils = tslib_1.__importStar(require("../utils/hdnodeUtils"));
9
10
  const pathUtils_1 = require("../utils/pathUtils");
10
11
  const accountUtils_1 = require("../utils/accountUtils");
11
- const versionUtils_1 = require("../utils/versionUtils");
12
12
  const coinInfo_1 = require("../data/coinInfo");
13
13
  const debug_1 = require("../utils/debug");
14
14
  const logger = (0, debug_1.initLog)('DeviceCommands');
@@ -20,7 +20,7 @@ const assertType = (res, resType) => {
20
20
  };
21
21
  const generateEntropy = (len) => {
22
22
  try {
23
- return (0, randombytes_1.default)(len);
23
+ return (0, crypto_1.randomBytes)(len);
24
24
  }
25
25
  catch (err) {
26
26
  throw constants_1.ERRORS.TypedError('Runtime', 'generateEntropy: Environment does not support crypto random');
@@ -493,7 +493,7 @@ class DeviceCommands {
493
493
  return;
494
494
  }
495
495
  const { name, version } = this.transport;
496
- if (name === 'BridgeTransport' && (0, versionUtils_1.versionCompare)(version, '2.0.28') < 1) {
496
+ if (name === 'BridgeTransport' && !utils_1.versionUtils.isNewer(version, '2.0.28')) {
497
497
  try {
498
498
  await this.device.legacyForceRelease();
499
499
  }
@@ -39,7 +39,7 @@ export declare class DeviceList extends TypedEmitter<DeviceListEvents> {
39
39
  asArray(): DeviceTyped[];
40
40
  allDevices(): Device[];
41
41
  length(): number;
42
- transportType(): "BridgeTransport" | "NodeUsbTransport" | "WebUsbTransport";
42
+ transportType(): "BridgeTransport" | "NodeUsbTransport" | "WebUsbTransport" | "UdpTransport";
43
43
  getTransportInfo(): TransportInfo;
44
44
  dispose(): Promise<void>;
45
45
  disconnectDevices(): void;
@@ -49,6 +49,12 @@ class DeviceList extends typedEventEmitter_1.TypedEmitter {
49
49
  logger: transportLogger,
50
50
  }));
51
51
  break;
52
+ case 'UdpTransport':
53
+ this.transports.push(new transport_1.UdpTransport({
54
+ logger: transportLogger,
55
+ messages: this.messages,
56
+ }));
57
+ break;
52
58
  default:
53
59
  throw constants_1.ERRORS.TypedError('Runtime', `DeviceList.init: transports[] of unexpected type: ${transportType}`);
54
60
  }
@@ -1,12 +1,20 @@
1
+ import type { Deferred } from '@trezor/utils';
1
2
  import type { DEVICE } from './device';
2
3
  import type { Device } from '../device/Device';
3
4
  import type { UiResponseEvent } from './ui-response';
4
- import type { Deferred } from '../utils/deferred';
5
5
  export type UiPromiseResponse = UiResponseEvent | {
6
6
  type: typeof DEVICE.DISCONNECT;
7
7
  payload?: undefined;
8
8
  };
9
9
  export type UiPromise<T extends UiPromiseResponse['type']> = Deferred<Extract<UiPromiseResponse, {
10
10
  type: T;
11
- }>, T, Device>;
11
+ }>, T> & {
12
+ device?: Device;
13
+ };
14
+ type UiPromiseMap = {
15
+ [T in UiPromiseResponse['type']]: UiPromise<T>;
16
+ };
17
+ export type AnyUiPromise = UiPromiseMap[UiPromiseResponse['type']];
18
+ export type UiPromiseCreator = <T extends UiPromiseResponse['type']>(type: T, device?: Device) => UiPromise<T>;
19
+ export {};
12
20
  //# sourceMappingURL=ui-promise.d.ts.map
@@ -1,7 +1,7 @@
1
1
  import type { PROTO } from '../../constants';
2
- import type { Params, Response } from '../params';
2
+ import type { Params, Response, DerivationPath } from '../params';
3
3
  export interface AuthorizeCoinjoin {
4
- path: string | number[];
4
+ path: DerivationPath;
5
5
  coordinator: string;
6
6
  maxRounds: number;
7
7
  maxCoordinatorFeeRate: number;
@@ -1,4 +1,5 @@
1
1
  import type { PROTO } from '../../../constants';
2
+ import type { DerivationPath } from '../../params';
2
3
  export interface BinanceSDKTransaction {
3
4
  chain_id: string;
4
5
  account_number?: number;
@@ -23,7 +24,7 @@ export interface BinancePreparedTransaction extends BinanceSDKTransaction {
23
24
  source: number;
24
25
  }
25
26
  export interface BinanceSignTransaction {
26
- path: string | number[];
27
+ path: DerivationPath;
27
28
  transaction: BinanceSDKTransaction;
28
29
  }
29
30
  //# sourceMappingURL=index.d.ts.map
@@ -1,9 +1,10 @@
1
- import type { PROTO } from '../../../constants';
2
1
  import type { AccountAddresses } from '@trezor/blockchain-link';
3
2
  import type { Transaction as BlockbookTransaction } from '@trezor/blockchain-link-types/lib/blockbook';
4
- import { AccountTransaction } from '../../account';
3
+ import type { PROTO } from '../../../constants';
4
+ import type { AccountTransaction } from '../../account';
5
+ import type { DerivationPath, ProtoWithDerivationPath } from '../../params';
5
6
  export interface SignMessage {
6
- path: string | number[];
7
+ path: DerivationPath;
7
8
  coin: string;
8
9
  message: string;
9
10
  hex?: boolean;
@@ -50,8 +51,8 @@ export interface TransactionOptions {
50
51
  coinjoin_request?: PROTO.CoinJoinRequest;
51
52
  }
52
53
  export interface SignTransaction {
53
- inputs: PROTO.TxInputType[];
54
- outputs: PROTO.TxOutputType[];
54
+ inputs: ProtoWithDerivationPath<PROTO.TxInputType>[];
55
+ outputs: ProtoWithDerivationPath<PROTO.TxOutputType>[];
55
56
  paymentRequests?: PROTO.TxAckPaymentRequest[];
56
57
  refTxs?: RefTransaction[];
57
58
  account?: {
@@ -1,5 +1,5 @@
1
1
  import type { PROTO } from '../../../constants';
2
- import type { GetPublicKey, PublicKey } from '../../params';
2
+ import type { GetPublicKey, PublicKey, DerivationPath } from '../../params';
3
3
  export interface CardanoCertificatePointer {
4
4
  blockIndex: number;
5
5
  txIndex: number;
@@ -7,8 +7,8 @@ export interface CardanoCertificatePointer {
7
7
  }
8
8
  export interface CardanoAddressParameters {
9
9
  addressType: PROTO.CardanoAddressType;
10
- path?: string | number[];
11
- stakingPath?: string | number[];
10
+ path?: DerivationPath;
11
+ stakingPath?: DerivationPath;
12
12
  stakingKeyHash?: string;
13
13
  certificatePointer?: CardanoCertificatePointer;
14
14
  paymentScriptHash?: string;
@@ -34,7 +34,7 @@ export interface CardanoNativeScript {
34
34
  type: PROTO.CardanoNativeScriptType;
35
35
  scripts?: CardanoNativeScript[];
36
36
  keyHash?: string;
37
- keyPath?: string | number[];
37
+ keyPath?: DerivationPath;
38
38
  requiredSignaturesCount?: number;
39
39
  invalidBefore?: string;
40
40
  invalidHereafter?: string;
@@ -54,7 +54,7 @@ export interface CardanoPublicKey extends PublicKey {
54
54
  node: PROTO.HDNodeType;
55
55
  }
56
56
  export interface CardanoInput {
57
- path?: string | number[];
57
+ path?: DerivationPath;
58
58
  prev_hash: string;
59
59
  prev_index: number;
60
60
  }
@@ -80,7 +80,7 @@ export type CardanoOutput = ({
80
80
  referenceScript?: string;
81
81
  };
82
82
  export interface CardanoPoolOwner {
83
- stakingKeyPath?: string | number[];
83
+ stakingKeyPath?: DerivationPath;
84
84
  stakingKeyHash?: string;
85
85
  }
86
86
  export interface CardanoPoolRelay {
@@ -111,26 +111,26 @@ export interface CardanoPoolParameters {
111
111
  }
112
112
  export interface CardanoCertificate {
113
113
  type: PROTO.CardanoCertificateType;
114
- path?: string | number[];
114
+ path?: DerivationPath;
115
115
  pool?: string;
116
116
  poolParameters?: CardanoPoolParameters;
117
117
  scriptHash?: string;
118
118
  keyHash?: string;
119
119
  }
120
120
  export interface CardanoWithdrawal {
121
- path?: string | number[];
121
+ path?: DerivationPath;
122
122
  amount: string;
123
123
  scriptHash?: string;
124
124
  keyHash?: string;
125
125
  }
126
126
  export type CardanoMint = CardanoAssetGroup[];
127
127
  export interface CardanoCollateralInput {
128
- path?: string | number[];
128
+ path?: DerivationPath;
129
129
  prev_hash: string;
130
130
  prev_index: number;
131
131
  }
132
132
  export interface CardanoRequiredSigner {
133
- keyPath?: string | number[];
133
+ keyPath?: DerivationPath;
134
134
  keyHash?: string;
135
135
  }
136
136
  export interface CardanoReferenceInput {
@@ -143,7 +143,7 @@ export interface CardanoCVoteRegistrationDelegation {
143
143
  }
144
144
  export interface CardanoCVoteRegistrationParameters {
145
145
  votePublicKey?: string;
146
- stakingPath: string | number[];
146
+ stakingPath: DerivationPath;
147
147
  paymentAddressParameters?: CardanoAddressParameters;
148
148
  nonce: string;
149
149
  format?: PROTO.CardanoCVoteRegistrationFormat;
@@ -171,7 +171,7 @@ export interface CardanoSignTransaction {
171
171
  collateralReturn?: CardanoOutput;
172
172
  totalCollateral?: string;
173
173
  referenceInputs?: CardanoReferenceInput[];
174
- additionalWitnessRequests?: (string | number[])[];
174
+ additionalWitnessRequests?: DerivationPath[];
175
175
  protocolMagic: number;
176
176
  networkId: number;
177
177
  signingMode: PROTO.CardanoTxSigningMode;
@@ -1,7 +1,7 @@
1
1
  /// <reference types="node" />
2
- import type { Params, BundledParams, Response } from '../params';
2
+ import type { Params, BundledParams, Response, DerivationPath } from '../params';
3
3
  export interface CipherKeyValue {
4
- path: string | number[];
4
+ path: DerivationPath;
5
5
  key: string;
6
6
  value: string | Buffer;
7
7
  encrypt?: boolean;
@@ -1,4 +1,5 @@
1
- import { PROTO } from '../../../constants';
1
+ import type { PROTO } from '../../../constants';
2
+ import type { DerivationPath } from '../../params';
2
3
  export interface EosPublicKey {
3
4
  wifPublicKey: string;
4
5
  rawPublicKey: string;
@@ -109,7 +110,7 @@ export interface EosSDKTransaction {
109
110
  })>;
110
111
  }
111
112
  export interface EosSignTransaction {
112
- path: string | number[];
113
+ path: DerivationPath;
113
114
  transaction: EosSDKTransaction;
114
115
  }
115
116
  //# sourceMappingURL=index.d.ts.map
@@ -1,5 +1,6 @@
1
+ import type { DerivationPath } from '../../params';
1
2
  export interface EthereumSignMessage {
2
- path: string | number[];
3
+ path: DerivationPath;
3
4
  message: string;
4
5
  hex?: boolean;
5
6
  }
@@ -32,7 +33,7 @@ export interface EthereumTransactionEIP1559 {
32
33
  accessList?: EthereumAccessList[];
33
34
  }
34
35
  export interface EthereumSignTransaction {
35
- path: string | number[];
36
+ path: DerivationPath;
36
37
  transaction: EthereumTransaction | EthereumTransactionEIP1559;
37
38
  }
38
39
  export interface EthereumSignedTx {
@@ -63,14 +64,14 @@ export interface EthereumSignTypedDataMessage<T extends EthereumSignTypedDataTyp
63
64
  };
64
65
  }
65
66
  export interface EthereumSignTypedData<T extends EthereumSignTypedDataTypes> {
66
- path: string | number[];
67
+ path: DerivationPath;
67
68
  data: EthereumSignTypedDataMessage<T>;
68
69
  metamask_v4_compat: boolean;
69
70
  domain_separator_hash?: undefined;
70
71
  message_hash?: undefined;
71
72
  }
72
73
  export interface EthereumSignTypedHash<T extends EthereumSignTypedDataTypes> {
73
- path: string | number[];
74
+ path: DerivationPath;
74
75
  data: EthereumSignTypedDataMessage<T>;
75
76
  metamask_v4_compat: boolean;
76
77
  domain_separator_hash: string;
@@ -8,6 +8,7 @@ export interface GetAccountInfo extends Omit<BlockchainLinkParams<'getAccountInf
8
8
  descriptor?: string;
9
9
  defaultAccountType?: DiscoveryAccountType;
10
10
  derivationType?: PROTO.CardanoDerivationType;
11
+ suppressBackupWarning?: boolean;
11
12
  }
12
13
  export declare function getAccountInfo(params: Params<GetAccountInfo>): Response<AccountInfo>;
13
14
  export declare function getAccountInfo(params: BundledParams<GetAccountInfo>): Response<(AccountInfo | null)[]>;
@@ -1,7 +1,7 @@
1
1
  import type { PROTO } from '../../constants';
2
- import type { Params, BundledParams, Response } from '../params';
2
+ import type { Params, BundledParams, Response, DerivationPath } from '../params';
3
3
  export interface GetOwnershipId {
4
- path: string | number[];
4
+ path: DerivationPath;
5
5
  coin?: string;
6
6
  multisig?: PROTO.MultisigRedeemScriptType;
7
7
  scriptType?: PROTO.InternalInputScriptType;
@@ -1,7 +1,7 @@
1
1
  import type { PROTO } from '../../constants';
2
- import type { Params, BundledParams, Response } from '../params';
2
+ import type { Params, BundledParams, Response, DerivationPath } from '../params';
3
3
  export interface GetOwnershipProof {
4
- path: string | number[];
4
+ path: DerivationPath;
5
5
  coin?: string;
6
6
  multisig?: PROTO.MultisigRedeemScriptType;
7
7
  scriptType?: PROTO.InternalInputScriptType;
@@ -1,4 +1,5 @@
1
1
  import type { PROTO, NEM } from '../../../constants';
2
+ import type { DerivationPath } from '../../params';
2
3
  export interface MosaicID {
3
4
  namespaceId: string;
4
5
  name: string;
@@ -84,7 +85,7 @@ export type NEMMultisigTransaction = TransactionCommon & {
84
85
  };
85
86
  export type NEMTransaction = NEMRegularTransaction | NEMMultisigTransaction;
86
87
  export interface NEMSignTransaction {
87
- path: string | number[];
88
+ path: DerivationPath;
88
89
  transaction: NEMTransaction;
89
90
  }
90
91
  //# sourceMappingURL=index.d.ts.map
@@ -1,3 +1,4 @@
1
+ import type { DerivationPath } from '../../params';
1
2
  export interface RipplePayment {
2
3
  amount: string;
3
4
  destination: string;
@@ -11,7 +12,7 @@ export interface RippleTransaction {
11
12
  payment: RipplePayment;
12
13
  }
13
14
  export interface RippleSignTransaction {
14
- path: string | number[];
15
+ path: DerivationPath;
15
16
  transaction: RippleTransaction;
16
17
  }
17
18
  export interface RippleSignedTx {
@@ -1,5 +1,6 @@
1
1
  /// <reference types="node" />
2
2
  import type { PROTO } from '../../../constants';
3
+ import type { DerivationPath } from '../../params';
3
4
  export interface StellarAsset {
4
5
  type: PROTO.StellarAssetType;
5
6
  code?: string;
@@ -142,7 +143,7 @@ export interface StellarTransaction {
142
143
  operations: StellarOperation[];
143
144
  }
144
145
  export interface StellarSignTransaction {
145
- path: string | number[];
146
+ path: DerivationPath;
146
147
  networkPassphrase: string;
147
148
  transaction: StellarTransaction;
148
149
  }
@@ -1,3 +1,4 @@
1
+ import type { DerivationPath } from '../../params';
1
2
  export interface TezosRevealOperation {
2
3
  source: string;
3
4
  fee: number;
@@ -30,7 +31,7 @@ export interface TezosOriginationOperation {
30
31
  source: string;
31
32
  balance: number;
32
33
  delegate?: string;
33
- script: string | number[];
34
+ script: DerivationPath;
34
35
  fee: number;
35
36
  counter: number;
36
37
  gas_limit: number;
@@ -51,7 +52,7 @@ export interface TezosOperation {
51
52
  delegation?: TezosDelegationOperation;
52
53
  }
53
54
  export interface TezosSignTransaction {
54
- path: string | number[];
55
+ path: DerivationPath;
55
56
  branch: string;
56
57
  operation: TezosOperation;
57
58
  }
@@ -1,7 +1,7 @@
1
1
  import type { PROTO } from '../../constants';
2
- import type { Params, Response } from '../params';
2
+ import type { Params, Response, DerivationPath } from '../params';
3
3
  export interface UnlockPathParams {
4
- path: string | number[];
4
+ path: DerivationPath;
5
5
  mac?: string;
6
6
  }
7
7
  export declare function unlockPath(params: Params<UnlockPathParams>): Response<PROTO.UnlockPath>;
@@ -20,6 +20,8 @@ export type KnownDevice = {
20
20
  firmware: DeviceFirmwareStatus;
21
21
  firmwareRelease?: ReleaseInfo | null;
22
22
  firmwareType?: FirmwareType;
23
+ name: string;
24
+ color?: string;
23
25
  status: DeviceStatus;
24
26
  mode: DeviceMode;
25
27
  state?: string;
@@ -36,6 +38,8 @@ export type UnknownDevice = {
36
38
  firmware?: typeof undefined;
37
39
  firmwareRelease?: typeof undefined;
38
40
  firmwareType?: typeof undefined;
41
+ name: string;
42
+ color?: typeof undefined;
39
43
  status?: typeof undefined;
40
44
  mode?: typeof undefined;
41
45
  state?: typeof undefined;
@@ -51,6 +55,8 @@ export type UnreadableDevice = {
51
55
  firmware?: typeof undefined;
52
56
  firmwareRelease?: typeof undefined;
53
57
  firmwareType?: typeof undefined;
58
+ name: string;
59
+ color?: typeof undefined;
54
60
  status?: typeof undefined;
55
61
  mode?: typeof undefined;
56
62
  state?: typeof undefined;
@@ -8,13 +8,13 @@ export interface FirmwareRange {
8
8
  max: string;
9
9
  };
10
10
  }
11
- export type VersionArray = [1 | 2, number, number];
11
+ export type VersionArray = [number, number, number];
12
12
  export type FirmwareRelease = {
13
13
  required: boolean;
14
14
  url: string;
15
15
  fingerprint: string;
16
16
  changelog: string;
17
- min_bridge_version: [number, number, number];
17
+ min_bridge_version: VersionArray;
18
18
  version: VersionArray;
19
19
  min_firmware_version: VersionArray;
20
20
  min_bootloader_version: VersionArray;
@@ -34,8 +34,19 @@ export interface Success<T> {
34
34
  payload: T;
35
35
  }
36
36
  export type Response<T> = Promise<Success<T> | Unsuccessful>;
37
+ export type DerivationPath = string | number[];
38
+ type ProtoWithExtendedAddressN<T, A, R> = Omit<Extract<T, {
39
+ address_n: A;
40
+ }>, 'address_n'> & {
41
+ address_n: R;
42
+ };
43
+ type ProtoWithoutAddressN<T, A> = Exclude<T, {
44
+ address_n: A;
45
+ }>;
46
+ export type ProtoWithDerivationPath<T> = ProtoWithoutAddressN<T, number[]> | ProtoWithExtendedAddressN<T, number[], DerivationPath>;
47
+ export type ProtoWithAddressN<P extends ProtoWithDerivationPath<any>> = P extends ProtoWithDerivationPath<infer T> ? T : unknown;
37
48
  export interface GetAddress {
38
- path: string | number[];
49
+ path: DerivationPath;
39
50
  address?: string;
40
51
  showOnTrezor?: boolean;
41
52
  }
@@ -45,8 +56,9 @@ export interface Address {
45
56
  serializedPath: string;
46
57
  }
47
58
  export interface GetPublicKey {
48
- path: string | number[];
59
+ path: DerivationPath;
49
60
  showOnTrezor?: boolean;
61
+ suppressBackupWarning?: boolean;
50
62
  }
51
63
  export interface PublicKey {
52
64
  publicKey: string;