fix(player): send device_id/token on reconnect before pairing (#164)
Some checks are pending
CI / Unit tests (node --test) (push) Waiting to run
CI / OpenAPI spec lint (push) Waiting to run
CI / Android unit tests (Kotlin schedule evaluator vectors) (push) Waiting to run
CI / Boot smoke + version check (push) Waiting to run

When the web player socket reconnects before the device is paired,
register() omitted device_id and device_token (gated behind config.paired).
This caused the server's fingerprint reclaim guard to treat the reconnect
as a fresh anonymous registration with a colliding fingerprint, firing
device:auth-error.

Now device_id and device_token are sent whenever they exist, regardless
of paired status. The pairing code is also reused across reconnects
instead of generating a new random code each time.

Closes #163

Co-authored-by: BlazzzPlay <fabianma7@gmail.com>
This commit is contained in:
Fabian Mendoza 2026-07-10 14:04:18 -04:00 committed by GitHub
parent 570f7919e0
commit c63af0e6bd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1178,14 +1178,25 @@
function register() {
const data = {};
if (config.deviceId && config.paired) {
// #163: always send device identity when we have it, regardless of paired
// status. Before this fix, a reconnect before pairing would omit device_id
// and device_token, causing the server's fingerprint reclaim guard to fire
// device:auth-error ("Authentication failed. Please re-pair this device.")
// because the same browser fingerprint looked like a reinstall attack.
if (config.deviceId) {
data.device_id = config.deviceId;
if (config.deviceToken) data.device_token = config.deviceToken;
} else {
const code = String(Math.floor(100000 + Math.random() * 900000));
config.pairingCode = code;
saveConfig(config);
data.pairing_code = code;
}
if (!config.paired) {
// Reuse the existing pairing code across reconnects so the operator
// doesn't see a new code every time the socket flaps. Only generate a
// fresh one on the very first registration when no code exists yet.
if (!config.pairingCode) {
const code = String(Math.floor(100000 + Math.random() * 900000));
config.pairingCode = code;
saveConfig(config);
}
data.pairing_code = config.pairingCode;
}
data.device_info = {
android_version: 'Web/' + navigator.userAgent.split(' ').pop(),