ya-webadb/packages/adb-backend-web
Simon Chan 90a1b1b331 v0.0.5
2021-01-14 12:04:32 +08:00
..
src feat(demo): forward some keys to device 2020-12-31 14:49:18 +08:00
LICENSE chore: rename adb-webusb to adb-backend-web 2020-09-18 21:01:28 +08:00
package-lock.json v0.0.5 2021-01-14 12:04:32 +08:00
package.json v0.0.5 2021-01-14 12:04:32 +08:00
README.md doc: add more documentation for each packages 2020-09-18 21:06:28 +08:00
tsconfig.json chore(adb): prepare for publish 2021-01-05 23:38:36 +08:00

@yume-chan/adb-backend-web

Backend for @yume-chan/adb using Web technologies.

Note

WebUSB API requires a secure context (basically means HTTPS).

Chrome will treat localhost as secure, but if you want to access a dev server running on another machine, you need to add the domain to the allowlist:

  1. Open chrome://flags/#unsafely-treat-insecure-origin-as-secure
  2. Add the protocol and domain part of your url (e.g. http://192.168.0.100:9000) to the input box
  3. Choose Enable from the dropdown menu
  4. Restart your browser

pickDevice

static async pickDevice(): Promise<AdbWebBackend | undefined>

WebUSB API (MDN) (Spec)

Request browser to present a list of connected Android devices to let the user choose from.

Returns undefined if the user canceled the picker.

fromDevice

static async fromDevice(device: USBDevice): Promise<AdbWebBackend>

WebUSB API (MDN) (Spec)

Create an AdbWebBackend instance from an exist USBDevice instance.

read/write

WebUSB API (MDN) (Spec)

Read/write data from/to the underlying USBDevice instance.

generateKey

Web Crypto API (MDN)

Web Storage API (MDN)

Generate a RSA private key and store it into LocalStorage.

iterateKeys

Return the stored RSA private key. (This backend only supports a single key)

encodeUtf8/decodeUtf8

Encode/decode string in UTF-8 with TextEncoder (MDN) and TextDecoder (MDN).