From 5cbbd9dbb676ab9401330c35e740e0b8bc997a56 Mon Sep 17 00:00:00 2001 From: Uruk Date: Mon, 9 Feb 2026 22:08:29 +0100 Subject: [PATCH] fix(chromecast): replace Math.random with crypto.getRandomValues for session ID --- components/Chromecast.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/components/Chromecast.tsx b/components/Chromecast.tsx index 7a5e90a9..87baa80d 100644 --- a/components/Chromecast.tsx +++ b/components/Chromecast.tsx @@ -114,7 +114,14 @@ export function Chromecast({ // Generate a new PlaySessionId when the content changes if (contentId !== lastContentIdRef.current) { - playSessionIdRef.current = `${contentId}-${Date.now()}-${Math.random().toString(36).substring(2, 9)}`; + const randomBytes = new Uint8Array(7); + crypto.getRandomValues(randomBytes); + const randomSuffix = Array.from(randomBytes, (b) => + b.toString(36).padStart(2, "0"), + ) + .join("") + .substring(0, 9); + playSessionIdRef.current = `${contentId}-${Date.now()}-${randomSuffix}`; lastContentIdRef.current = contentId; }