@trezor/connect 9.3.0 → 9.3.1-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.
Files changed (60) hide show
  1. package/CHANGELOG.md +121 -8
  2. package/README.md +1 -1
  3. package/lib/api/checkFirmwareAuthenticity.d.ts +2 -1
  4. package/lib/api/checkFirmwareAuthenticity.js +34 -26
  5. package/lib/api/ethereum/api/ethereumSignTypedData.d.ts +1 -0
  6. package/lib/api/ethereum/api/ethereumSignTypedData.js +3 -1
  7. package/lib/api/ethereum/ethereumDefinitions.js +1 -0
  8. package/lib/api/firmware/getBinary.d.ts +4 -4
  9. package/lib/api/firmware/getBinary.js +4 -15
  10. package/lib/api/firmware/getBinaryForFirmwareUpgrade.d.ts +11 -0
  11. package/lib/api/firmware/getBinaryForFirmwareUpgrade.js +32 -0
  12. package/lib/api/firmware/index.d.ts +1 -0
  13. package/lib/api/firmware/index.js +3 -1
  14. package/lib/api/firmware/verifyAuthenticityProof.d.ts +1 -1
  15. package/lib/api/firmware/verifyAuthenticityProof.js +37 -2
  16. package/lib/api/firmware/x509certificate.d.ts +20 -6
  17. package/lib/api/firmware/x509certificate.js +82 -13
  18. package/lib/api/getCoinInfo.d.ts +3 -0
  19. package/lib/api/getFeatures.d.ts +1 -0
  20. package/lib/backend/Blockchain.js +10 -1
  21. package/lib/core/AbstractMethod.js +1 -0
  22. package/lib/core/index.d.ts +3 -3
  23. package/lib/core/index.js +93 -111
  24. package/lib/core/onCallFirmwareUpdate.js +25 -14
  25. package/lib/data/DataManager.d.ts +11 -0
  26. package/lib/data/DataManager.js +1 -1
  27. package/lib/data/coinInfo.d.ts +14 -0
  28. package/lib/data/config.d.ts +11 -0
  29. package/lib/data/config.js +17 -1
  30. package/lib/data/connectSettings.js +3 -2
  31. package/lib/data/deviceAuthenticityConfig.d.ts +1 -28
  32. package/lib/data/deviceAuthenticityConfig.js +25 -24
  33. package/lib/data/deviceAuthenticityConfigTypes.d.ts +38 -0
  34. package/lib/data/deviceAuthenticityConfigTypes.js +28 -0
  35. package/lib/data/models.d.ts +10 -0
  36. package/lib/data/models.js +12 -10
  37. package/lib/data/version.d.ts +2 -1
  38. package/lib/data/version.js +3 -2
  39. package/lib/device/Device.d.ts +2 -3
  40. package/lib/device/Device.js +15 -24
  41. package/lib/device/DeviceCommands.js +2 -27
  42. package/lib/device/DeviceList.d.ts +42 -27
  43. package/lib/device/DeviceList.js +249 -233
  44. package/lib/events/core.d.ts +2 -2
  45. package/lib/events/popup.d.ts +1 -0
  46. package/lib/events/transport.d.ts +5 -0
  47. package/lib/index.js +20 -20
  48. package/lib/types/api/authenticateDevice.d.ts +9 -0
  49. package/lib/types/api/authenticateDevice.js +2 -2
  50. package/lib/types/api/checkFirmwareAuthenticity.d.ts +4 -1
  51. package/lib/types/api/init.d.ts +2 -2
  52. package/lib/types/coinInfo.d.ts +7 -0
  53. package/lib/types/firmware.d.ts +2 -2
  54. package/lib/types/settings.d.ts +7 -3
  55. package/lib/utils/assetUtils.js +1 -0
  56. package/lib/utils/promiseUtils.d.ts +3 -3
  57. package/lib/utils/promiseUtils.js +7 -5
  58. package/package.json +16 -17
  59. package/lib/core/coreManager.d.ts +0 -16
  60. package/lib/core/coreManager.js +0 -55
@@ -230,7 +230,7 @@ class DeviceCommands {
230
230
  await this.transport.receive({
231
231
  session: this.sessionId,
232
232
  protocol: this.device.protocol,
233
- });
233
+ }).promise;
234
234
  throw error;
235
235
  }
236
236
  return response;
@@ -260,9 +260,6 @@ class DeviceCommands {
260
260
  }
261
261
  if (res.type === 'ButtonRequest') {
262
262
  this._cancelableRequestBySend = true;
263
- if (res.message.code === '_Deprecated_ButtonRequest_PassphraseType') {
264
- res.message.code = 'ButtonRequest_PassphraseType';
265
- }
266
263
  if (res.message.code === 'ButtonRequest_PassphraseEntry') {
267
264
  this.device.emit(events_1.DEVICE.PASSPHRASE_ON_DEVICE);
268
265
  }
@@ -285,25 +282,8 @@ class DeviceCommands {
285
282
  }), () => this._commonCall('Cancel', {}));
286
283
  }
287
284
  if (res.type === 'PassphraseRequest') {
288
- const state = this.device.getInternalState();
289
- const legacy = this.device.useLegacyPassphrase();
290
- const legacyT1 = legacy && this.device.isT1();
291
- if (legacyT1 && typeof state === 'string') {
292
- return this._commonCall('PassphraseAck', { passphrase: state });
293
- }
294
- if (legacy && res.message._on_device) {
295
- this.device.emit(events_1.DEVICE.PASSPHRASE_ON_DEVICE);
296
- return this._commonCall('PassphraseAck', { _state: state });
297
- }
298
285
  return this._promptPassphrase().then(response => {
299
- const { passphrase, passphraseOnDevice, cache } = response;
300
- if (legacyT1) {
301
- this.device.setInternalState(cache ? passphrase : undefined);
302
- return this._commonCall('PassphraseAck', { passphrase });
303
- }
304
- if (legacy) {
305
- return this._commonCall('PassphraseAck', { passphrase, _state: state });
306
- }
286
+ const { passphrase, passphraseOnDevice } = response;
307
287
  return !passphraseOnDevice
308
288
  ? this._commonCall('PassphraseAck', { passphrase })
309
289
  : this._commonCall('PassphraseAck', { on_device: true });
@@ -311,11 +291,6 @@ class DeviceCommands {
311
291
  throw err || e;
312
292
  }));
313
293
  }
314
- if (res.type === 'Deprecated_PassphraseStateRequest') {
315
- const { state } = res.message;
316
- this.device.setInternalState(state);
317
- return this._commonCall('Deprecated_PassphraseStateAck', {});
318
- }
319
294
  if (res.type === 'WordRequest') {
320
295
  return this._promptWord(res.message.type).then(word => this._commonCall('WordAck', { word }), () => this._commonCall('Cancel', {}));
321
296
  }
@@ -1,5 +1,5 @@
1
1
  import { TypedEmitter } from '@trezor/utils';
2
- import { Transport, TRANSPORT, Descriptor } from '@trezor/transport';
2
+ import { Transport, TRANSPORT } from '@trezor/transport';
3
3
  import { DEVICE, TransportInfo } from '../events';
4
4
  import { Device } from './Device';
5
5
  import type { ConnectSettings, Device as DeviceTyped } from '../types';
@@ -13,28 +13,44 @@ interface DeviceListEvents {
13
13
  [DEVICE.RELEASED]: DeviceTyped;
14
14
  [DEVICE.ACQUIRED]: DeviceTyped;
15
15
  }
16
- export declare class DeviceList extends TypedEmitter<DeviceListEvents> {
17
- transport: Transport;
18
- transports: Transport[];
19
- devices: {
20
- [path: string]: Device;
21
- };
22
- creatingDevicesDescriptors: {
23
- [k: string]: Descriptor;
24
- };
25
- transportStartPending: number;
26
- penalizedDevices: {
27
- [deviceID: string]: number;
28
- };
29
- transportFirstEventPromise: Promise<void> | undefined;
30
- private settings;
31
- constructor({ settings, messages, }: {
32
- settings: ConnectSettings;
33
- messages: Record<string, any>;
34
- });
35
- init(): Promise<void>;
36
- private resolveTransportEvent;
37
- waitForTransportFirstEvent(): Promise<void>;
16
+ export interface IDeviceList {
17
+ isConnected(): this is DeviceList;
18
+ assertConnected(): asserts this is DeviceList;
19
+ pendingConnection(): Promise<void> | undefined;
20
+ setTransports: DeviceList['setTransports'];
21
+ addAuthPenalty: DeviceList['addAuthPenalty'];
22
+ removeAuthPenalty: DeviceList['removeAuthPenalty'];
23
+ on: DeviceList['on'];
24
+ once: DeviceList['once'];
25
+ init: DeviceList['init'];
26
+ dispose: DeviceList['dispose'];
27
+ }
28
+ type ConstructorParams = Pick<ConnectSettings, 'priority' | 'debug'> & {
29
+ messages: Record<string, any>;
30
+ };
31
+ type InitParams = Pick<ConnectSettings, 'pendingTransportEvent' | 'transportReconnect'>;
32
+ export declare class DeviceList extends TypedEmitter<DeviceListEvents> implements IDeviceList {
33
+ private transport;
34
+ private transports;
35
+ private devices;
36
+ private creatingDevicesDescriptors;
37
+ private readonly authPenaltyManager;
38
+ private initPromise?;
39
+ private rejectPending?;
40
+ private transportCommonArgs;
41
+ isConnected(): this is DeviceList;
42
+ assertConnected(): asserts this is DeviceList;
43
+ pendingConnection(): Promise<void> | undefined;
44
+ constructor({ messages, priority, debug }: ConstructorParams);
45
+ private createTransport;
46
+ setTransports(transports: ConnectSettings['transports']): void;
47
+ private onTransportUpdate;
48
+ init(initParams?: InitParams): Promise<void>;
49
+ private createInitPromise;
50
+ private createReconnectPromise;
51
+ private selectTransport;
52
+ private initializeTransport;
53
+ private waitForDevices;
38
54
  private _createAndSaveDevice;
39
55
  private _createUnacquiredDevice;
40
56
  private _createUnreadableDevice;
@@ -45,11 +61,10 @@ export declare class DeviceList extends TypedEmitter<DeviceListEvents> {
45
61
  length(): number;
46
62
  transportType(): "BridgeTransport" | "NodeUsbTransport" | "WebUsbTransport" | "UdpTransport";
47
63
  getTransportInfo(): TransportInfo;
48
- dispose(): void;
49
- disconnectDevices(): void;
50
- enumerate(): Promise<void>;
64
+ dispose(): Promise<void>;
65
+ cleanup(): Promise<void>;
66
+ enumerate(transport?: Transport): Promise<void>;
51
67
  addAuthPenalty(device: Device): void;
52
- private getAuthPenalty;
53
68
  removeAuthPenalty(device: Device): void;
54
69
  private handle;
55
70
  private _takeAndCreateDevice;