16 lines
734 B
JavaScript
16 lines
734 B
JavaScript
/* =====================================================================
|
|
audit.js — Aktivitätsprotokoll
|
|
WICHTIG: Codes dürfen hier NIEMALS im Klartext (oder auch nur
|
|
teilweise) auftauchen. `detail` ist für zusätzlichen, unkritischen
|
|
Kontext gedacht (z.B. "role: rechte-hand"), niemals für Geheimnisse.
|
|
===================================================================== */
|
|
import { nowIso } from "./crypto.js";
|
|
|
|
export async function logAction(env, actor, action, target, detail) {
|
|
await env.DB.prepare(
|
|
`INSERT INTO audit_log (actor, action, target, detail, created_at) VALUES (?, ?, ?, ?, ?)`
|
|
)
|
|
.bind(actor, action, target || null, detail ? JSON.stringify(detail) : null, nowIso())
|
|
.run();
|
|
}
|