From 56c14945b39a6f5cd11abbd855ee7c73560d94d4 Mon Sep 17 00:00:00 2001 From: Pas <74743263+Pasithea0@users.noreply.github.com> Date: Thu, 19 Feb 2026 11:54:21 -0700 Subject: [PATCH] safely generate watch party code --- src/stores/watchParty.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/stores/watchParty.ts b/src/stores/watchParty.ts index 1d5ddbe6..4708064e 100644 --- a/src/stores/watchParty.ts +++ b/src/stores/watchParty.ts @@ -25,8 +25,10 @@ interface WatchPartyStore { } // Generate a random 4-digit code -const generateRoomCode = (): string => { - return Math.floor(1000 + Math.random() * 9000).toString(); +export const generateRoomCode = (): string => { + const array = new Uint32Array(1); + crypto.getRandomValues(array); + return (1000 + (array[0] % 9000)).toString(); }; // Helper function to reset playback rate to 1x