fix(web): make Add Section work on insecure (plain-HTTP) origins

Both add-section paths on Settings > Home Screen called crypto.randomUUID()
unguarded. Browsers only expose randomUUID in secure contexts, so on
self-hosted servers accessed over plain HTTP the click handler threw
synchronously and the Add section button appeared dead while Cancel still
worked. api/client.ts and plexAuth.ts already carried ad-hoc fallbacks for
the same problem; extract a shared lib/uuid helper (UUIDv4 via
crypto.getRandomValues, available in insecure contexts) and use it at all
four call sites.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Quick104
2026-07-23 11:51:43 -04:00
co-authored by Claude Fable 5
parent 5d7eec7a62
commit 82379fa3e2
5 changed files with 35 additions and 24 deletions
@@ -38,6 +38,7 @@ import {
useAllUserCollections,
type CollectionOption,
} from "@/hooks/queries/useAllUserCollections";
import { randomUUID } from "@/lib/uuid";
const CATEGORY_LABELS: Record<Category, string> = {
library_staples: "Library",
@@ -142,7 +143,7 @@ export function buildProfileSectionSaveEntry({
}
return {
id: section?.id ?? crypto.randomUUID(),
id: section?.id ?? randomUUID(),
section_type: sectionType,
title: title || sectionTypeLabel(sectionType),
featured,