Serve built Workers directly through pinned Miniflare with persistent D1-compatible storage and startup migrations. Build and verify Docker images in CI; publish main checkpoints to GHCR for manual TrueNAS updates on port 33046. Preserve explicit public-origin checks and LAN-compatible cryptographic operation IDs. Validation: 5,153 offline tests, typecheck, lint and build; 49 HTTP integration cases; HTTPS-origin create/join/chat/seat protection, foreign-origin rejection, exact saved-seat restart and browser asset serving. Independent persistence/proxy review completed. Clean Docker CI and actual NAS installation follow this source checkpoint.
16 lines
597 B
TypeScript
16 lines
597 B
TypeScript
/** UUID v4 for browser operations, including private LAN HTTP origins. */
|
|
export function randomId(): string {
|
|
// Unlike randomUUID(), getRandomValues is available outside secure contexts.
|
|
const bytes = globalThis.crypto.getRandomValues(new Uint8Array(16));
|
|
bytes[6] = (bytes[6] & 0x0f) | 0x40;
|
|
bytes[8] = (bytes[8] & 0x3f) | 0x80;
|
|
const hex = Array.from(bytes, (byte) => byte.toString(16).padStart(2, '0'));
|
|
return [
|
|
hex.slice(0, 4).join(''),
|
|
hex.slice(4, 6).join(''),
|
|
hex.slice(6, 8).join(''),
|
|
hex.slice(8, 10).join(''),
|
|
hex.slice(10).join(''),
|
|
].join('-');
|
|
}
|