From 00d04876d4d3de76e13dbe187db9efcfd41680cf Mon Sep 17 00:00:00 2001 From: Panthevm Date: Wed, 20 May 2026 18:09:22 +0300 Subject: [PATCH] Fix: use generateId() instead of direct crypto.randomUUID() Two call sites used crypto.randomUUID() directly, which throws TypeError in non-secure contexts (plain HTTP, not localhost): - src/routes/rest.tsx:366 (REST console upsertHeader) - src/components/DataLineage/sidebar.tsx:60 (DataLineage SkeletonRows) The safe generateId() wrapper in utils.ts falls back to a Math.random based UUIDv4 string when crypto.randomUUID is unavailable. Closes HealthSamurai/sansara#7679 --- src/components/DataLineage/sidebar.tsx | 3 ++- src/routes/rest.tsx | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/components/DataLineage/sidebar.tsx b/src/components/DataLineage/sidebar.tsx index 77d5abf..a3da3de 100644 --- a/src/components/DataLineage/sidebar.tsx +++ b/src/components/DataLineage/sidebar.tsx @@ -7,6 +7,7 @@ import { ChevronRight, Plus } from "lucide-react"; import * as React from "react"; import { type AidboxClientR5, useAidboxClient } from "../../AidboxClient"; import { useLocalStorage } from "../../hooks"; +import { generateId } from "../../utils"; const SQL_QUERY_TYPE_TOKEN = "https://sql-on-fhir.org/ig/CodeSystem/LibraryTypesCodes|sql-query"; @@ -57,7 +58,7 @@ function SkeletonRows({ count }: { count: number }) { const rows = React.useMemo( () => Array.from({ length: count }, () => ({ - id: crypto.randomUUID(), + id: generateId(), width: SKELETON_WIDTHS[Math.floor(Math.random() * SKELETON_WIDTHS.length)], })), diff --git a/src/routes/rest.tsx b/src/routes/rest.tsx index 1a160bb..39fc794 100644 --- a/src/routes/rest.tsx +++ b/src/routes/rest.tsx @@ -363,7 +363,7 @@ function upsertHeader( return; } const newHeader = { - id: crypto.randomUUID(), + id: generateId(), name: headerName, value, enabled: true,