Skip to content

Commit de41411

Browse files
committed
Merge commit 'refs/pull/100/head' of github.com:BitBoxSwiss/bitbox-api-rs
2 parents 1e093d4 + 3adfd32 commit de41411

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

webhid.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,14 @@ class MessageQueue {
3636
export async function getWebHIDDevice(vendorId, productId, onCloseCb) {
3737
let device;
3838
try {
39-
const devices = await navigator.hid.requestDevice({filters: [{vendorId, productId}]});
39+
// Try to get directly the device. This will work without prompting user
40+
// permission if it has already been validated before on the current website.
41+
let devices = await navigator.hid.getDevices({filters: [{vendorId, productId}]});
42+
if (devices.length == 0){
43+
// If direct access failed, which happen for new websites, ask user
44+
// confirmation.
45+
devices = await navigator.hid.requestDevice({filters: [{vendorId, productId}]});
46+
}
4047
const d = devices[0];
4148
// Filter out other products that might be in the list presented by the Browser.
4249
if (d.productName.includes('BitBox02')) {

0 commit comments

Comments
 (0)