mirror of
https://github.com/screentinker/screentinker.git
synced 2026-08-16 15:23:16 -06:00
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 <fabianma7@gmail.com>
This commit is contained in:
parent
570f7919e0
commit
c63af0e6bd
|
|
@ -1178,14 +1178,25 @@
|
||||||
|
|
||||||
function register() {
|
function register() {
|
||||||
const data = {};
|
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;
|
data.device_id = config.deviceId;
|
||||||
if (config.deviceToken) data.device_token = config.deviceToken;
|
if (config.deviceToken) data.device_token = config.deviceToken;
|
||||||
} else {
|
}
|
||||||
|
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));
|
const code = String(Math.floor(100000 + Math.random() * 900000));
|
||||||
config.pairingCode = code;
|
config.pairingCode = code;
|
||||||
saveConfig(config);
|
saveConfig(config);
|
||||||
data.pairing_code = code;
|
}
|
||||||
|
data.pairing_code = config.pairingCode;
|
||||||
}
|
}
|
||||||
data.device_info = {
|
data.device_info = {
|
||||||
android_version: 'Web/' + navigator.userAgent.split(' ').pop(),
|
android_version: 'Web/' + navigator.userAgent.split(' ').pop(),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue