7

I'm trying to use a card reader (https://www.ewent-online.com/tcpdf/pdf/ew/p/EW1052/) to read a Health Card.

This is the code (copy-pasted from the official doc: https://developers.google.com/web/updates/2016/03/access-usb-devices-on-the-web):

var device;

navigator['usb'].requestDevice({ filters: [] })
.then(selectedDevice => {
    device = selectedDevice;
    return device.open(); // Begin a session.
})
.then(() => device.selectConfiguration(1)) // Select configuration #1 forhe device.
.then(() => device.claimInterface(0)) // Request exclusive control over     interface #2.
.then(() => device.controlTransferOut({
    requestType: 'class',
    recipient: 'interface',
    request: 0x22,
    value: 0x01,
    index: 0x00}
)) // Ready to receive data
.then(() => device.transferIn(5, 64)) // Waiting for 64 bytes of data from endpoint #5.
.then(result => {
    let decoder = new window['TextDecoder']();
    console.log('Received: ' + decoder.decode(result.data));
})
.catch(error => {
    console.log(error);
});

The error is here:

device.claimInterface(0)

For some reason i can't access at the class. I can't figure out hot to make it work, i have read alla stackoverflow related thread without found a solution.

Thanks in advance!

Alex Ferreli
  • 548
  • 1
  • 7
  • 14

1 Answers1

9

Your device implements the USB CCID class, which is on the list of classes protected by Chrome as announced in the post below. Interfaces implementing these classes cannot be claimed through WebUSB.

https://groups.google.com/a/chromium.org/forum/#!msg/blink-dev/LZXocaeCwDw/GLfAffGLAAAJ

Reilly Grant
  • 5,590
  • 1
  • 13
  • 23
  • Thanks for the fast reply! So the device is the problem? There is another smart card reader that work without Chrome limitations? – Alex Ferreli Feb 28 '19 at 08:38