yume-chan/ya-webadb

use @yume-chan/adb-daemon-ws connect android, The device always displays a dialog asking its user to confirm the connection

Closed this issue · 3 comments

Issue Checklist

  • I'm using the library programmatically
  • For Scrcpy related issues, I have searched in Genymobile/scrcpy repository.

Library version

"@yume-chan/adb": "^0.0.21", "@yume-chan/adb-credential-web": "^0.0.21",

Environment

mac os 14.2 (23C64)

Device

android 12

Describe the bug

In fact, I already clicked Agree to connect on my phone. This demo can be reproduced:https://tango-adb.github.io/old-demo.

Update:
public key always update, Is there a way to control the public key unchanged?

`export const AdbPublicKeyAuthenticator: AdbAuthenticator = async function* (
credentialStore: AdbCredentialStore,
getNextRequest: () => Promise,
): AsyncIterable {
const packet = await getNextRequest();

if (packet.arg0 !== AdbAuthType.Token) {
    return;
}

let privateKey: AdbPrivateKey | undefined;
for await (const key of credentialStore.iterateKeys()) {
    privateKey = key;
    break;
}

if (!privateKey) {
    privateKey = await credentialStore.generateKey();
}

const publicKeyLength = adbGetPublicKeySize();
const [publicKeyBase64Length] =
    calculateBase64EncodedLength(publicKeyLength);

const nameBuffer = privateKey.name?.length
    ? encodeUtf8(privateKey.name)
    : EMPTY_UINT8_ARRAY;
const publicKeyBuffer = new Uint8Array(
    publicKeyBase64Length +
        (nameBuffer.length ? nameBuffer.length + 1 : 0) + // Space character + name
        1, // Null character
);

adbGeneratePublicKey(privateKey.buffer, publicKeyBuffer);   // !!!!!!!! always `update`
encodeBase64(publicKeyBuffer.subarray(0, publicKeyLength), publicKeyBuffer);

if (nameBuffer.length) {
    publicKeyBuffer[publicKeyBase64Length] = 0x20;
    publicKeyBuffer.set(nameBuffer, publicKeyBase64Length + 1);
}

yield {
    command: AdbCommand.Auth,
    arg0: AdbAuthType.PublicKey,
    arg1: 0,
    payload: publicKeyBuffer,
};

};`

Steps to reproduce

  1. input websocket url
  2. choose websocket url
  3. connect

adbGeneratePublicKey is deterministic, a private key will always produce the same public key.

Also, public key authentication is only used after signature authentication fails, which means your private key is untrusted by the device (or have changed) anyway.

I had encountered this issue before, where the confirmation dialog shows every time Tango wants to connect, but it resolves itself after rebooting my device.

adbGeneratePublicKey is deterministic, a private key will always produce the same public key.

Also, public key authentication is only used after signature authentication fails, which means your private key is untrusted by the device (or have changed) anyway.

I had encountered this issue before, where the confirmation dialog shows every time Tango wants to connect, but it resolves itself after rebooting my device.

OK,let me try

I think I found the bug e24102a, the generated public key for some private keys might be incorrect.

Please try version 0.0.24