20216b37c6
Replaces the per-device DeviceRecord lookup with a per-user discriminated union (loading | needs-setup | needs-unlock | unlocked). Heartbeat block deleted (telemetry no longer device-bound); webPush keyed by install-id.
20 lines
724 B
TypeScript
20 lines
724 B
TypeScript
// Per-install browser identifier. Replaces the legacy per-device crypto
|
|
// identity for non-crypto bookkeeping (push tokens, message sender_device_id
|
|
// metadata) where we just need a stable, opaque id for this browser/install.
|
|
//
|
|
// The user-key model has no device-bound crypto; the `devices` table and
|
|
// `messages.sender_device_id` column still exist but they're now plain
|
|
// telemetry. Using a localStorage UUID keeps the column populated without
|
|
// any of the old key-management overhead.
|
|
|
|
const KEY = 'chatapp.installId';
|
|
|
|
export function ensureInstallId(): string {
|
|
let id = window.localStorage.getItem(KEY);
|
|
if (!id) {
|
|
id = crypto.randomUUID();
|
|
window.localStorage.setItem(KEY, id);
|
|
}
|
|
return id;
|
|
}
|