Refactor security functions

This commit is contained in:
gpt-engineer-app[bot]
2025-10-14 19:38:36 +00:00
parent 1554254c82
commit 95972a0b22
9 changed files with 638 additions and 89 deletions

View File

@@ -72,3 +72,51 @@ export interface AuthServiceResponse<T = void> {
data?: T;
error?: string;
}
/**
* Authentication session from Supabase with hashed IP
*/
export interface AuthSession {
id: string;
created_at: string;
updated_at: string;
refreshed_at: string | null;
user_agent: string | null;
ip: string | null; // Pre-hashed by database function
not_after: string | null;
aal: AALLevel | null;
}
/**
* Security-sensitive operations that may require additional verification
*/
export type SecurityOperation =
| 'password_change'
| 'identity_disconnect'
| 'identity_connect'
| 'session_revoke'
| 'mfa_enroll'
| 'mfa_unenroll';
/**
* Rate limit information for security operations
*/
export interface RateLimitInfo {
operation: SecurityOperation;
allowed: boolean;
attemptsRemaining: number;
resetAt: Date;
currentAttempts: number;
maxAttempts: number;
}
/**
* Security operation context for logging
*/
export interface SecurityContext {
operation: SecurityOperation;
userId?: string;
targetUserId?: string;
requiresMFA?: boolean;
metadata?: Record<string, any>;
}