From c63af0e6bd05403c9b7bb347daf8bb12a0b0661b Mon Sep 17 00:00:00 2001 From: Fabian Mendoza Date: Fri, 10 Jul 2026 14:04:18 -0400 Subject: [PATCH] fix(player): send device_id/token on reconnect before pairing (#164) 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 --- server/player/index.html | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/server/player/index.html b/server/player/index.html index 3944ae9..3a270c2 100644 --- a/server/player/index.html +++ b/server/player/index.html @@ -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(),