File tree 1 file changed +8
-1
lines changed
1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -36,7 +36,14 @@ class MessageQueue {
36
36
export async function getWebHIDDevice ( vendorId , productId , onCloseCb ) {
37
37
let device ;
38
38
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
+ }
40
47
const d = devices [ 0 ] ;
41
48
// Filter out other products that might be in the list presented by the Browser.
42
49
if ( d . productName . includes ( 'BitBox02' ) ) {
You can’t perform that action at this time.
0 commit comments