File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -36,7 +36,14 @@ class MessageQueue {
3636export 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' ) ) {
You can’t perform that action at this time.
0 commit comments