oweme/apps/web/src/lib/events.ts
agent 8fbbb4933e Add Svelte web client and service worker
Mobile-first PWA: groups via key-in-fragment links, encrypted outbox and
sync over SSE, all split modes, currencies with ECB rate prefill, photos,
comments, history and rewind, stats, recurring expenses, CSV and backup,
EN/CS, dark/light theme, Web Push decrypted in the service worker.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013FYo6JSV1fDU1fm3LU77iF
2026-10-09 19:59:16 +00:00

17 lines
645 B
TypeScript

// Decrypting a stored event. Plain module (no runes) so the service worker
// can use it too.
import type { EventPlaintext, GroupEvent } from '@oweme/core';
import { decryptJson, type GroupKeys } from './crypto.ts';
export async function decryptEvent(
keys: GroupKeys,
groupId: string,
e: { id: string; seq: number | null; deviceId: string; iv: string; ct: string },
): Promise<GroupEvent | null> {
try {
const p = await decryptJson<EventPlaintext>(keys.encKey, e.iv, e.ct, `${groupId}|${e.id}`);
return { ...p, id: e.id, seq: e.seq, deviceId: e.deviceId };
} catch {
return null; // wrong key or tampered: skip it
}
}