mirror of
https://github.com/streamyfin/streamyfin.git
synced 2026-06-11 08:20:25 +01:00
fix(chromecast): replace Math.random with crypto.getRandomValues for session ID
This commit is contained in:
@@ -114,7 +114,14 @@ export function Chromecast({
|
|||||||
|
|
||||||
// Generate a new PlaySessionId when the content changes
|
// Generate a new PlaySessionId when the content changes
|
||||||
if (contentId !== lastContentIdRef.current) {
|
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;
|
lastContentIdRef.current = contentId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user