Custom Authentication Processor
For advanced use cases that require custom authentication logic, you can provide your own AdbDaemonAuthProcessor implementation instead of using the default credential manager-based flow.
When you pass a custom processor to adbDaemonAuthenticate, it completely replaces the default authentication processor. This gives you full control over how authentication packets are handled during the handshake process.
Interface
interface AdbDaemonAuthProcessor {
process(packet: AdbPacketData): Promise<AdbPacketData>;
close?(): MaybePromiseLike<undefined>;
}
process(packet)
The main method that processes incoming ADB packets during authentication. It should return a response packet to send back to the device.
close()
An optional cleanup method that gets called when authentication completes or fails.
Example
When using a custom authentication processor:
- JavaScript
- TypeScript
import { adbDaemonAuthenticate } from "@yume-chan/adb";
const transport = await adbDaemonAuthenticate({
serial: device.serial,
connection,
processor: customAuthProcessor,
});
import type {
AdbDaemonAuthProcessor,
AdbDaemonTransport,
AdbPacketData,
AdbPacketInit,
} from "@yume-chan/adb";
import type { Consumable, ReadableWritablePair } from "@yume-chan/stream-extra";
import { adbDaemonAuthenticate } from "@yume-chan/adb";
import { AdbDaemonWebUsbDevice } from "@yume-chan/adb-daemon-webusb";
declare const device: AdbDaemonWebUsbDevice;
declare const connection: ReadableWritablePair<AdbPacketData, Consumable<AdbPacketInit>>;
declare const customAuthProcessor: AdbDaemonAuthProcessor;
const transport: AdbDaemonTransport = await adbDaemonAuthenticate({
serial: device.serial,
connection,
processor: customAuthProcessor,
});
This approach allows for completely custom authentication logic when the default flow is insufficient.
After authentication, see Create an Adb Instance to create a higher-level ADB client.