Skip to content

Commit d5ba438

Browse files
committed
fix(transport): usb device filtering
1 parent 5e5d8a3 commit d5ba438

File tree

1 file changed

+3
-7
lines changed
  • packages/transport/src/api

1 file changed

+3
-7
lines changed

packages/transport/src/api/usb.ts

+3-7
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,15 @@ export class UsbApi extends AbstractApi {
4242
}
4343

4444
this.usbInterface.onconnect = event => {
45-
this.devices = [...this.devices, ...this.createDevices([event.device])];
45+
const [_hidDevices, nonHidDevices] = this.filterDevices([event.device]);
46+
this.devices = [...this.devices, ...this.createDevices(nonHidDevices)];
4647
this.emit('transport-interface-change', this.devicesToDescriptors());
4748
};
4849

4950
this.usbInterface.ondisconnect = event => {
5051
const { device } = event;
5152
if (!device.serialNumber) {
52-
// this should never happen, if it does, it means, that there is something that passes
53-
// filters (TREZOR_USB_DESCRIPTORS) but does not have serial number. this could indicate error in fw
54-
this.emit('transport-interface-error', ERRORS.DEVICE_UNREADABLE);
55-
this.logger.error('device does not have serial number');
56-
53+
// trezor devices have serial number 468E58AE386B5D2EA8C572A2 or 000000000000000000000000 (for bootloader devices)
5754
return;
5855
}
5956

@@ -97,7 +94,6 @@ export class UsbApi extends AbstractApi {
9794
try {
9895
const devices = await this.usbInterface.getDevices();
9996
const [hidDevices, nonHidDevices] = this.filterDevices(devices);
100-
10197
if (hidDevices.length) {
10298
// hidDevices that do not support webusb. these are very very old. we used to emit unreadable
10399
// device for these but I am not sure if it is still worth the effort.

0 commit comments

Comments
 (0)