yume-chan/ya-webadb

Add name for public key so it will not be displayed as "nouser@nohostname"

RikkaW opened this issue · 1 comments

RikkaW commented

The name is displayed in "Developer options" - "Wireless debugging" - "Paired devices".

image

The current implementation does not set the name of the key, so its name is displayed as "nouser@nohostname". If there are more than one, the user cannot distinguish the source of the key.

The method of adding a name is quite simple, just add " name" at the end of publicKeyBuffer (note the space before name).

const publicKeyBuffer = new Uint8Array(
publicKeyBase64Length + 1, // Null character
);
adbGeneratePublicKey(privateKey, publicKeyBuffer);
encodeBase64(publicKeyBuffer.subarray(0, publicKeyLength), publicKeyBuffer);

const name = " webadb"; // a space is required
const publicKeyBuffer = new Uint8Array(publicKeyBase64Length + name.length + 1);
// ... 
publicKeyBuffer.set(Uint8Array.from(Array.from(name).map(letter => letter.charCodeAt(0))), publicKeyBase64Length);

image

Because I don't know how to pass the name is better, so I cannot send a pull request x_x

I changed the return type of AdbCredentialStore#iterateKeys to include an optional name field. Developers can provide their own AdbCredentialStore implementations to specify the name.

The reference implementation @yume-chan/adb-credential-web will set name to Tango@<hostname> (e.g. Tango@www.tangoapp.dev).