/* ===================================================================== audit.js — Aktivitätsprotokoll. 1:1 portiert, D1 → better-sqlite3. WICHTIG: Codes dürfen hier NIEMALS im Klartext auftauchen. ===================================================================== */ import { db } from "../db.js"; import { nowIso } from "./crypto.js"; export function logAction(actor, action, target, detail) { db.prepare(`INSERT INTO audit_log (actor, action, target, detail, created_at) VALUES (?, ?, ?, ?, ?)`).run( actor, action, target || null, detail ? JSON.stringify(detail) : null, nowIso() ); }