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

View File

@@ -150,6 +150,18 @@ export const pushNotifications = pgTable('push_notifications', {
updatedAt: timestamp('updated_at', { withTimezone: true }).defaultNow().notNull(),
});
export const auditLogs = pgTable('audit_logs', {
id: uuid('id').defaultRandom().primaryKey(),
ownerUserId: uuid('owner_user_id').notNull().references(() => users.id),
actorDeviceId: uuid('actor_device_id').references(() => devices.id),
action: varchar('action', { length: 128 }).notNull(),
targetType: varchar('target_type', { length: 64 }).notNull(),
targetId: varchar('target_id', { length: 255 }).notNull(),
metadata: jsonb('metadata').$type<Record<string, unknown> | null>().default(null),
ipAddress: text('ip_address'),
createdAt: timestamp('created_at', { withTimezone: true }).defaultNow().notNull(),
});
export const accounts = pgTable('account', {
id: uuid('id').defaultRandom().primaryKey(),
userId: uuid('user_id').notNull().references(() => users.id),
@@ -197,6 +209,7 @@ export const schema = {
videos,
notifications,
pushNotifications,
auditLogs,
accounts,
sessions,
verifications,