Files
JohnRiceMLandClaude Opus 4.6 95a7bdf26f Fix crypto.randomUUID runtime error, add logo as default sidebar icon
Replace all crypto.randomUUID() calls with generateId() helper that
falls back to a Math.random-based UUID in non-secure contexts (HTTP,
older browsers). Fixes #1. Also sets the ClawPort logo as the default
sidebar icon in place of the lobster emoji.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-06 16:51:09 -06:00

16 lines
542 B
TypeScript

/**
* Generate a unique ID, with a fallback for non-secure contexts
* where crypto.randomUUID() is not available (e.g. HTTP, older browsers).
*/
export function generateId(): string {
if (typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function') {
return crypto.randomUUID()
}
// Fallback: generate a UUID v4-like string
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
const r = (Math.random() * 16) | 0
const v = c === 'x' ? r : (r & 0x3) | 0x8
return v.toString(16)
})
}