Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get not paired devices list? #203

Closed
qcscofield opened this issue Sep 26, 2021 · 3 comments
Closed

How to get not paired devices list? #203

qcscofield opened this issue Sep 26, 2021 · 3 comments

Comments

@qcscofield
Copy link

I used
let devices = await navigator.usb.getDevices();
to get already paired devices.
But please tell me without using "requestDevice()" how to get not paired devices list.

@reillyeon
Copy link
Collaborator

This is intentionally impossible. getDevices() only returns the devices the user has granted the site permission to access. requestDevice() allows the site to ask for permission to access additional devices. If the site could get the list of devices that the user hasn't granted it permission to access then that would leak information to the site without the user's consent.

@demonguy
Copy link

demonguy commented Sep 28, 2021

however, is it possible to add an interface to tell there is device not paired?
we developed a tool, which for convenient, directly use paired device.
However there is bug, if 2 device are connected, one device is paired and the other one is not, what we can do is

  1. never directly use paired devices. always pop up windows
  2. user will never get a chance to select unparied device is another paired device is also connected

@reillyeon
Copy link
Collaborator

Unfortunately letting the site know that there are unpaired devices would still leak too much information without user consent. My recommendation is that the site can still automatically use the paired device but give the user the option to select a different device before taking any action the user might want to select a different device for. This is generally a good idea anyways, the site shouldn't make any irreversible actions without asking the user first.

The demo site https://sowbug.github.io/weblight is built this way. It will show the current status of any paired devices on load but also provides a button for the user to select a new device.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants