mirror of
https://github.com/JohnRiceML/clawport-ui.git
synced 2026-08-14 00:47:50 +00:00
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>
16 lines
542 B
TypeScript
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)
|
|
})
|
|
}
|