WebUSB | Implementation of Web API using the JSM | Runtime Evironment library

 by   ajsb85 JavaScript Version: 0.0.1 License: MPL-2.0

kandi X-RAY | WebUSB Summary

kandi X-RAY | WebUSB Summary

WebUSB is a JavaScript library typically used in Server, Runtime Evironment, Nodejs applications. WebUSB has no bugs, it has no vulnerabilities, it has a Weak Copyleft License and it has low support. You can download it from GitHub.

Expose USB devices to Gecko applications through JS c-types and the HID API library, and provide an implementation of the WebUSB specification for Web content access. Currently this is a XULRunner application, for the purpose of easily experimenting. The goal is to have the code allow for re-use in any style of Gecko-based application, eg Firefox desktop, Firefox OS or XULRunner applications. The core USB access is done through HID API (which provides cross-platform access to USB and Bluetooth. We're only using the USB part. The benefit of using HID API library is that we don't need to write OS-specific implementations in JS c-types directly.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              WebUSB has a low active ecosystem.
              It has 7 star(s) with 7 fork(s). There are 3 watchers for this library.
              OutlinedDot
              It had no major release in the last 12 months.
              There are 2 open issues and 0 have been closed. There are no pull requests.
              It has a neutral sentiment in the developer community.
              The latest version of WebUSB is 0.0.1

            kandi-Quality Quality

              WebUSB has 0 bugs and 0 code smells.

            kandi-Security Security

              WebUSB has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              WebUSB code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              WebUSB is licensed under the MPL-2.0 License. This license is Weak Copyleft.
              Weak Copyleft licenses have some restrictions, but you can use them in commercial projects.

            kandi-Reuse Reuse

              WebUSB releases are available to install and integrate.

            Top functions reviewed by kandi - BETA

            kandi has reviewed WebUSB and discovered the below as its top functions. This is intended to give you an instant insight into WebUSB implemented functionality, and help decide if they suit your requirements.
            • Show more text .
            Get all kandi verified functions for this library.

            WebUSB Key Features

            No Key Features are available at this moment for WebUSB.

            WebUSB Examples and Code Snippets

            No Code Snippets are available at this moment for WebUSB.

            Community Discussions

            QUESTION

            Chrome WebUSB controlTransferOut Results in "Transfer failed: A device attached to the system is not functioning. (0x1F)"
            Asked 2022-Apr-09 at 07:13

            I'm developing a consumer USB device that will be configured via a web interface.

            The first interface is a HID Gamepad. The second is a vendor interface where configuration will be handled.

            Running this WebUSB code, I get the following error:

            ...

            ANSWER

            Answered 2022-Apr-09 at 07:13

            This was due to a misconfiguration of my device's firmware code (didn't initialize or do any setup for the endpoints!)

            That's been fixed and I'm able to send data over properly.

            Source https://stackoverflow.com/questions/71791063

            QUESTION

            Nano Ledger S in Angular
            Asked 2022-Mar-07 at 09:43

            Today I ran into a problem while trying to connect my NANO Ledger S to my angular app.

            I've tried installing this package yet it does not seem to work due to the package throwing some errors.

            Module '"events"' can only be default-imported using the 'allowSyntheticDefaultImports' flag

            This can be fixed by putting changing the EventEmmiter import to

            import {EventEmitter} from "events";

            Now at least the app compiles, but when I to access the Devices over the TransportWebUSB class a "ERROR Error: Uncaught (in promise): ReferenceError: Buffer is not defined ReferenceError: Buffer is not defined" error is thrown in the console.

            I've tried different stuff like following this tutorial and adding

            ...

            ANSWER

            Answered 2022-Mar-07 at 09:43

            So, after a while of testing stuff and even switching to another Hardware-Wallet, I finally got it working.

            I installed the buffer package and in the polyfill.ts I added following lines:

            Source https://stackoverflow.com/questions/70952632

            QUESTION

            Understanding the WebUSB connection workflow
            Asked 2022-Mar-03 at 07:59

            I am working on an Chrome webapp that uses WebUSB running on an Android device, and am trying to understand how the connection management works.

            If I am reading the spec right, if you don't already have permission to interact with the USB device, you call requestDevice to get permission from the user to trigger the initial connection workflow. You can also call getDevices() first to see if permission has already been granted, and if so can proceed from there without going through the initial connection workflow.

            Assuming that's an accurate summary (please correct me if not!), then how does that connection information get stored and managed? If I go to chrome://usb-devices, I don't see the devices if they are not currently plugged in. If I go to Local Storage, I din't see anything that looks like a list of devices. Where does the permission-has-already-been-granted information live? Is it possible to forget connection information, manually or programmatically?

            Thanks in advance!

            ...

            ANSWER

            Answered 2022-Mar-01 at 10:27

            A call to navigator.usb.requestDevice() will prompt user to pick a USB device in a browser picker. When chosen, the browser will remember internally which devices user have granted access to. From there, when plugged in, those devices will be accessible without user prompting from a call to navigator.usb.getDevices().

            It is possible in Chrome 101 for a website to revoke access to a device by calling the forget() method on a USB device object. See https://web.dev/usb/#revoke-access

            It is also possible for a user to revoke access to a USB device directly from the browser in the "page info" bubble. See screenshot below.

            Source https://stackoverflow.com/questions/71302425

            QUESTION

            How to get Windows 10 to autoload WinUSB as driver using MS_OS_20 BOS descriptor
            Asked 2022-Feb-07 at 10:48

            I am struggling to get Windows to load the default WinUSB driver for my device. Please note that I am looking for a solution that is using BOS descriptor (and not the old 0xEE string index).

            The device enumerates and Windows tells me that it is installing the device, but the WinUSB driver is not loaded. I have tried everything that I can think of, but still I can't get Windows to load the driver. I even uninstall the device and delete the USB flags in the registry whenever I re-try, but to no avail. Is there anyone who can help me to get this to work?

            I don't want WebUSB capabilities or anything additional. This is a non-composite device.

            This is my BOS descriptor (as sent over USB):

            ...

            ANSWER

            Answered 2022-Feb-07 at 10:48

            UPDATE: when you have a non-composite device that only has a single a configuration, then you are not use any subset headers (neither 'Configuration subset header' nor 'Function subset header'). So, the correct layout in this case is:

            Source https://stackoverflow.com/questions/70998743

            QUESTION

            WebUSB access mass storage USB serial number
            Asked 2022-Jan-06 at 08:44

            I am trying to access a USB mass storage device using the WebUSB interface. I have read that USB mass storage devices cannot be accessed:

            • "For example, if the device is a USB mass storage device that interface is not claimable and if there are no other interfaces the device will be hidden." (Link)
            • "The following set of USB interface classes, which should not be claimed using the WebUSB API, will be explicitly blocked by Blink: Audio, Video, HID, Mass Storage[...]" (Link)
            • "It cannot. USB mass storage devices are claimed by the system's generic USB mass storage class driver and are therefore unavailable to the browser." (Link)

            We are currently using usb sticks for a standalone version of the app where the serial number of the usb stick is important to identify the license. For our new software I also need to access the serial number of the usb mass storage device, but best would be if I could do so in the browser.

            Google Chrome does recognise the device as can be seen here.

            But when asking for access to a device via WebUSB it is not shown in the list:

            My code is pretty straight forward:

            ...

            ANSWER

            Answered 2022-Jan-06 at 08:44

            The short answer is no.

            The internal page about:usb-internals should show you interfaces that are blocked in WebUSB. As you can see in the screenshot below, "Mass Storage" USB devices are indeed not accessible in WebUSB for security reasons.

            Source https://stackoverflow.com/questions/70591331

            QUESTION

            Availability of WebHID/WebUSB APIs on iOS
            Asked 2021-Dec-28 at 20:32

            I know WebHID/WebUSB are generally available in Google Chrome (https://caniuse.com/webhid and https://caniuse.com/?search=webusb) but are these APIs available also on the iOS version of Google Chrome? I was getting reports from users not being able to connect their devices on iOS (iPad) but unfortunately, I don't have a device to test it on and I didn't find any mentions of it online. Can anybody confirm whether these APIs are available in the iOS version of Chrome?

            ...

            ANSWER

            Answered 2021-Dec-28 at 20:32

            WebUSB and WebHID are not available in any browser on iOS.

            I don't believe it would be possible for any browser to implement them because iOS doesn't provide the APIs a native application like a web browser needs to implement them. The necessary APIs are only part of the macOS SDK.

            Source https://stackoverflow.com/questions/70504321

            QUESTION

            JavaScript - Join DataViews
            Asked 2021-Sep-15 at 17:23

            How do I join DataViews in JavaScript?

            Using WebUSB API to get data from a device:

            ...

            ANSWER

            Answered 2021-Sep-15 at 17:23

            You can concatenate the ArrayBuffer which can be get from the DataView.

            Source https://stackoverflow.com/questions/69197185

            QUESTION

            WebUSB : DOMException Acces denied
            Asked 2021-Sep-13 at 18:43

            I am trying to connect to Android phone using WebUSB with USB debugging OFF. But It return an error DOMException Acces denied. Basically, I want my PC to connect as USB client (like Keyboard or any usb device) to Android phone.

            However, Other USB devices (like USB audio device) are not giving any error. I recieve access error on device.open()

            ...

            ANSWER

            Answered 2021-Sep-13 at 18:43

            When an Android device does not have USB debugging enabled it does not provide a USB interface that Windows will allow a user-space application such as your web browser to claim. This is why you get the "Access denied" error.

            It sounds like what you are trying to do is have your computer act as a USB peripheral so that the phone connects to it as the USB host. This is not supported by most desktop USB controllers and this mode is not supported by the WebUSB API.

            Source https://stackoverflow.com/questions/69161729

            QUESTION

            How to find correct USB device configuration and interface for use in WebUSB?
            Asked 2021-Aug-17 at 08:57

            In WebUSB to connect to a device we must select a configuration and interface.
            There's also the option to using an alternate interface.

            How can I know which ones to use?
            Do I need to know this beforehand or can I try to detect for each device?

            ...

            ANSWER

            Answered 2021-Aug-17 at 08:57

            How can I know which ones to use? Do I need to know this beforehand or can I try to detect for each device?

            As https://web.dev/devices-introduction/#:~:text=human-readable%20protocol.-,With,-WebUSB%2C%20without%20clear says, without clear documentation for this device and what USB commands this device supports, it's hard but still possible with lucky guessing.

            Watch Exploring WebUSB and its exciting potential from Suz Hinton. You can also reverse-engineer this device by capturing raw USB traffic and inspecting USB descriptors with external tools like Wireshark and built-in browser tools such as the internal page about://usb-internals in Chromium-based browsers.

            Lets say I can have thermal printers and cameras for example, would I be able to detect for each one?

            Camera will likely be blocked. Inspecting your device in about://usb-internals/ will tell you as you should see "Blocked by WebUSB" when it's the case.

            Also, how can I check if a device is already claimed? Do I have to check every interface?

            In general, I'd recommend https://web.dev/usb/ and https://www.beyondlogic.org/usbnutshell/usb1.shtml to start respectively with WebUSB and USB.

            For your specific questions, device.open() and device.claimInterface() promises will fail if those actions can't be performed.

            Source https://stackoverflow.com/questions/68805470

            QUESTION

            Get list of available USB devices in WebUSB API
            Asked 2021-Jul-28 at 20:59

            In WebUSB API is there a way to get a list of all available devices?

            The situation I have here is that a computer can have more than one identical device, lets say it has 2 identical printers. I want to avoid displaying the popup asking the user to select a device so I would like to check if the device is already claimed.

            I can check if a device is already claimed by running navigator.usb.getDevices(); but this only lists devices that are already claimed, if there's an identical device that is not yet claimed I can't know.

            So the issue is that if I consider that the device is already claimed and don't show the dialog the user can't use the second device and if I never consider a device claimed I will have to show the dialog every time.

            ...

            ANSWER

            Answered 2021-Jul-28 at 20:59

            There is no API to get a list of all available devices. A site can only get access to a device (and information about that device) by asking the user for permission.

            I think there's some confusion about what navigator.usb.getDevices() does. It returns the set of connected devices the user has previously granted the site access to, whether they are claimed or not.

            What I recommend applications do is use navigator.usb.getDevices() to show the user the set of devices that are available and have an "add device" button which will call navigator.usb.requestDevice() if the user doesn't see the device they are looking for. If the user knows they have two devices and need to connect to both of them they'd click the button twice.

            Source https://stackoverflow.com/questions/68548706

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install WebUSB

            You can download it from GitHub.

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/ajsb85/WebUSB.git

          • CLI

            gh repo clone ajsb85/WebUSB

          • sshUrl

            git@github.com:ajsb85/WebUSB.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link