feat(security): add phase8 hardening with rate limits, audit logs, and auth-first simulator flow

This commit is contained in:
2026-01-24 18:45:00 +00:00
parent 6d6c77f77e
commit f6d66c3650
11 changed files with 355 additions and 5 deletions

22
Backend/services/audit.ts Normal file
View File

@@ -0,0 +1,22 @@
import { db } from '../db/client';
import { auditLogs } from '../db/schema';
export const writeAuditLog = async (entry: {
ownerUserId: string;
action: string;
targetType: string;
targetId: string;
actorDeviceId?: string;
metadata?: Record<string, unknown>;
ipAddress?: string;
}): Promise<void> => {
await db.insert(auditLogs).values({
ownerUserId: entry.ownerUserId,
actorDeviceId: entry.actorDeviceId,
action: entry.action,
targetType: entry.targetType,
targetId: entry.targetId,
metadata: entry.metadata ?? null,
ipAddress: entry.ipAddress,
});
};