// Locally-cached list of claims the user has generated. Persists // across reloads so the user can come back later and see what they've // signed (and for which channel). Does NOT verify publication — // that's the verifier's job; the SPA just records what was generated. import { get, set } from "idb-keyval"; import type { SignedClaimEnvelope } from "./kez.js"; const KEY = "kez-chat:claims"; export interface StoredClaim { id: string; // random local id envelope: SignedClaimEnvelope; channel: string; // "github", "dns", "web", ... published_at?: string; // user marked it published notes?: string; } export async function listClaims(): Promise { return (await get(KEY)) ?? []; } export async function addClaim(claim: StoredClaim): Promise { const existing = await listClaims(); existing.push(claim); await set(KEY, existing); } export async function markPublished(id: string): Promise { const existing = await listClaims(); const target = existing.find((c) => c.id === id); if (target) { target.published_at = new Date().toISOString(); await set(KEY, existing); } } export async function removeClaim(id: string): Promise { const existing = await listClaims(); await set( KEY, existing.filter((c) => c.id !== id), ); }