refactor(desktop): AuthContext exposes userKeyState instead of device record
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.
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
// 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;
|
||||
}
|
||||
Reference in New Issue
Block a user