WebUSB API requires [secure context](https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts)(HTTPS).
@@ -23,19 +26,19 @@ Chrome will treat `localhost` as secure, but if you want to access a dev server
## Use in Node.js
Node.js doesn't have native support for WebUSB API. However, all methods in this package have a `usbManager` parameter, which can be used to provide a WebUSB compatible implementation.
Node.js doesn't have native support for WebUSB API, but the [`usb`](https://www.npmjs.com/package/usb) NPM package has a `webusb` export that provides a WebUSB compatible API.
For example, the [`usb`](https://www.npmjs.com/package/usb) NPM package has a `webusb`export that can be used here.
The constructors of `AdbWebUsbBackend`, `AdbWebUsbBackendManager` and `AdbWebUsbBackendWatcher` all have a `usb`parameter that can be used to specify the WebUSB API implementation.
@@ -45,37 +48,60 @@ Create a new instance of `AdbWebBackend` using a `USBDevice` instance you alread
The `filters` parameter specifies the `classCode`, `subclassCode` and `protocolCode` to use when searching for ADB interface. The default value is `[{ classCode: 0xff, subclassCode: 0x42, protocolCode: 0x1 }]`, defined by Google.
### `isSupported()`
### `connect`
```ts
publicasyncconnect():Promise<
ReadableWritablePair<AdbPacketData,AdbPacketInit>
>
```
Claim the device and create a pair of `AdbPacket` streams to the ADB interface.
Request access to a connected device from browser. The browser will display a list of devices to the user and let them choose one.
Only available in browsers that support WebUSB API (When `isSupported()` returns `true`).
Request access to a connected device.
This is a convince method for `usb.requestDevice()`.
The `filters` parameter must have `classCode`, `subclassCode` and `protocolCode` fields for selecting the ADB interface. It can also have `vendorId`, `productId` or `serialNumber` fields to limit the displayed device list.
Returns an `AdbWebUsbBackend` instance, or `undefined` if the user cancelled the picker.