Chrome WebUSB not recognizing devices (CAC cards, smart cards) - javascript

I have made a script to load all of the USB devices connected to Chrome using chrome.usb.getDevices. So far, it has listed a second-generation iPod touch as well as a mouse, keyboard, and two unknown items from Intel. However, it has not recognized any USB flash drives, and it does not recognize any Smart Cards that I have. I've also installed Chrome's Smart Card Connector app into Chrome, but I can still not get Chrome to recognize these Smart Cards. I can't continue to use Java nor ActiveX to for smartcard interactions in the browser. How can I get CAC/smartcard authentication through the browser without having to install a slew of other dependencies?
Edit: I also installed WinUSB as their drivers in place of their default HID drivers, but the results remained.

This Chrome USB Devices states that not all USB devices are supported and can be read:
Caveats
Not all devices can be accessed through the USB API. In general,
devices are not accessible because either the Operating System's
kernel or a native driver holds them off from user space code. Some
examples are devices with HID profiles on OSX systems, and USB pen
drives.
On most Linux systems, USB devices are mapped with read-only
permissions by default. To open a device through this API, your user
will need to have write access to it too. A simple solution is to set
a udev rule. Create a file /etc/udev/rules.d/50-yourdevicename.rules
with the following content:
SUBSYSTEM=="usb", ATTR{idVendor}=="[yourdevicevendor]", MODE="0664", GROUP="plugdev"

Related

When should one use WebHID as opposed to WebUSB?

I have a proprietary USB device that has a flashing functionality over USB. I would like to replicate this flashing functionality from within the browser, but I am not certain what API to use.
Visiting chrome://usb-internals/ to inspect my device gives me the following information:
The device advertises itself with class code 8: mass storage. The device does not show up in my file system, e.g. it is not a normal USB pendrive. According to this StackOverflow answer, WebUSB is blocked from accessing mass storage devices due to security reasons, and I should use WebHID instead.
Using WebHID, however, still did not allow me to connect to my device. This is the sample code I used:
const filter = [
{
vendorId: 0xabcd, // correct VID:PID obtained via lsusb
productId: 0x1234
}
];
const [device] = await navigator.hid.requestDevice({ filter });
Furthermore, visiting chrome://device-log/ makes a distinct difference between USB and HID devices. When I plug in a mouse, for example, the Chrome device log shows that a USB HID device connected. When I plug in a USB pendrive, I get two lines in the debug log: one HID device, one mass storage device. When I plug in my proprietary drive, I get a single line: USB Mass Storage device.
How could I convince WebHID to make a connection to my proprietary mass storage device?
Not possible without major changes:
USB mss storage uses bulk endpoints, HID is transferred via Control and Interrupt end points.
You can implement both Mass storage and HID on a single USB device (with an IAD), but the bootloader code for HID would look significantly different from the mass storage one.
USB pendrives don't usually support HID unless there is an LED or button present.
You could install a WinUSB driver for the device (Zadig makes it very easy) and then connect to the device using WebUSB.
In case you need to write your own SCSI layer, here's how we did it for a blood glucose meter that also mounts as a mass storage device to transfer data.

How to initiate a new device pairing using the Chrome web bluetooth API?

Using navigator.bluetooth.requestDevice(), I can access bluetooth devices I've already set up a pair with using native OSX bluetooth pairing, but no previously-unpaired devices appear, even when their attributes match my generic query. Available devices show up in a Chrome modal requesting user consent to pair, but the only device that shows up is the one I've already paired with.
Am I misunderstanding the intended use case here, or is there another way to establish a connection with a nearby (previously unpaired) device from Chrome?
Docs: https://webbluetoothcg.github.io/web-bluetooth/
(See Example 2)
function bluetoothConnect() {
navigator.bluetooth.requestDevice({filters: [{services: ['generic_access']}]})
.then(device => {console.log(`Connected to: ${device.name}`)})
.catch(console.error);
}
First, Mac OS X is not yet fully implemented as we speak. Only discovery and GATT server connect/disconnect are working for now. See the Chrome Implementation status at https://github.com/WebBluetoothCG/web-bluetooth/blob/gh-pages/implementation-status.md. Check out Chrome OS, Linux and Android M (Android Lollipop workaround).
Regarding your specific issue, I believe that generic_access is not broadcasted by a nearby BLE device but is found because you've already paired (cached) this device. If your device is named "foo" for instance, you can go to https://googlechrome.github.io/samples/web-bluetooth/device-info.html and fill "foo" as the Device Name and hit "Get Bluetooth Device Info" button.
I would recommend you give a try to all Web Bluetooth samples at https://googlechrome.github.io/samples/web-bluetooth/index.html as well.
To complement the other answer, please be aware of the Chrome's chrome://bluetooth-internals tab/tool. This tool can not only list available devices and their services (which I don't think you can do with the Web Bluetooth API unless you requested the services in optionalServices or filters/services) and the characteristics of those services.
In the device list, there is a Forget button which becomes active once you connect to the devices GATT server using the Inspect button. This should allow you to full unpair and pair again in cases where you need to test the flow end to end.
Edit: Actually after doing some experimentation around this, the device still remains paired even after using the Forget button. Probably a bug in Chrome, however, the cache of the paired devices seems to be per-profile. This means the real answer is to:
Use the Incognito mode and in there the pairing flow will initiate from the get-go for each new Incognito session.

Discover devices vendor and model on a local network

I need to find out if it's possible and if so, what is the API for that.
The required scenario:
connect to a wifi network.
from an android app or using javascript from a webpage find out the make and model of devices that are connected to the same router.
I found a way to find the IP addresses, and I saw that Find app can see the manufacturers, but can't tell if it's a mobile device, a tablet, a laptop or a printer.
I thought that a possible way would be to use jmDNS (which I can't get my android project to compile with), and service discovery, but I'm not sure that it will tell me if the device is a tablet or a smartphone.
For Android I can also think of the linux build number to search against a device list compatible with that build. However, I'm not sure about Apple devices.
Is there a way to do that or am I wasting my time?
If there is, will it work in Android or with JS?
Thanks.

Screen reader can't read content on node-webkit app

We're using node-webkit for packaging an app made with HTML5 and js. Everything has been working well but now when we try to read the content using a screen reader (Apple VoiceOver or Jaws), the content seems inaccessible.
The screen reader is able to read the window's buttons and the window's title but can't read the HTML inside the app. Actually it doesn't work with the sample page that came out of the box with node-webkit so is not a problem of our app.
Any ideas or alternatives? Thanks!
Each platform (OS) like Windows, OS X and Linux(es) (and Android and iOS and countless others on mobile) has its own accessibility API. For example Windows Automation API on Windows 7 and 8 (open source softwares use IAccessible2 but it seems to be a useful extra layer to it. Whatever)
A software like a browser must communicate with the OS what it is doing via this API (it could be an email client, a spreadsheet, a file explorer, etc).
The OS will filter (examples: if it's not the active window, if a system thing happens like removal of a USB key or new notification)
This accessibility API will then inform assistive technologies (AT) like a screen reader (SR) of what's happening. A SR being a complex software with user configuration, it'll also filter, adapt, output via a speech synthesis and/or a Braille display, etc from what it was fed.
Though I'm only accustomed to web accessibility and not in anything related to software, browsers, APIs and their internal working (so I could be very wrong, sorry) I guess the communication related to accessibility from "WebKit" to the OS (and there's "WebKit" on Windows, OS X, maybe still Linux, etc) is managed by Chrome the software (and vanilla Chromium the software from Chromium the project), NOT WebKit the rendering engine. node-webkit is made around Chromium but does it pass along the messages related to accessibility API? If it does or can, you should have the same accessibility as in Chromium (good luck with that, compared to Firefox and IE). If it doesn't, that's a black box.
One would then need to add all this accessibility API management to make it work! Maybe it's just an option in node-webkit?
If you want to verify if anything goes out of a software related to an accessibility API, you can test with aViewer from The Paciello Group.
May be related: Blink accessibility (Chromium project)

Is there a way to access Bluetooth connected devices in browser?

Is there a way to access Bluetooth connected devices in browser?
I am trying to build a demo system utilizing leap motion for a university project and was planning to build the interface in HTML because leap motion supports JavaScript.
I want the system to have full control over Bluetooth calling on a phone. As most in-car systems currently do; i.e. accept call, decline, make call & view contacts(if possible)
You might want to check out the Chrome Bluetooth API, though it appears you need to have a development version of Chrome installed: https://developer.chrome.com/apps/bluetooth
After a trial during January 2017, this is now available in Chrome. Read this article by François Beaufort in developers.google.com: https://developers.google.com/web/updates/2015/07/interact-with-ble-devices-on-the-web
You can do it with the Bluetooth Web API:
navigator.bluetooth.requestDevice({acceptAllDevices: true}).then(out => console.log(out))
Annoyingly it seems like the browser needs Bluetooth permission, and calling the code above fails with `Bluetooth permission has been blocked otherwise.
To allow bluetooth for macOS, add the app to System Preferences > Security & Privacy > Privacy > Bluetooth > Plus Button:

Categories

Resources