From e3085ea7a20f345bd3cfd3ebc80cd681414a85c3 Mon Sep 17 00:00:00 2001 From: ordinarthur <@arthurbarre.js@gmail.com> Date: Tue, 14 Apr 2026 11:53:03 +0200 Subject: [PATCH] feat: local device profile replaces animal naming - Users set their own device name and optional profile photo - Profile persisted in localStorage, no account needed - Auto-detect device type from user agent - Server validates client-provided profile defensively - PeerAvatar shows photo or device icon - ProfileSetup modal on first visit, editable from header --- server/src/index.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/server/src/index.ts b/server/src/index.ts index 580a5de..742c6ae 100644 --- a/server/src/index.ts +++ b/server/src/index.ts @@ -113,14 +113,15 @@ function checkMessageRate(client: Client): boolean { } /** Sanitize client-provided display name */ -function sanitizeName(name: string): string { +function sanitizeName(name: unknown): string { + if (typeof name !== "string") return "Appareil"; return name.trim().slice(0, 30) || "Appareil"; } /** Validate device type */ -function validateDeviceType(dt: string): DeviceType { +function validateDeviceType(dt: unknown): DeviceType { const valid: DeviceType[] = ["phone", "tablet", "laptop", "desktop"]; - return valid.includes(dt as DeviceType) ? (dt as DeviceType) : "laptop"; + return typeof dt === "string" && valid.includes(dt as DeviceType) ? (dt as DeviceType) : "laptop"; } /** Validate avatar (must be a small data URL or undefined) */