import type { User, AuthResult } from './entities'; /** * Repository interface that the data layer must implement * Following clean architecture principles - domain defines the contract */ export interface IAuthRepository { // F.ID.004: DPoP initialization initializeDPoP(): Promise; // F.ID.001: Login flows exchangeCredentialsForToken(creds: Credentials, pubKey: string): Promise; // F.ID.002: Verification flows sendOTPVerification(phoneNumber: string): Promise; verifyOTP(phoneNumber: string, code: string): Promise; sendEmailVerification(email: string): Promise; verifyEmail(email: string, token: string): Promise; // Magic Links (F.ID.006 - Enhanced security) generateMagicLink(email: string): Promise; verifyMagicLink(token: string, nonce: string): Promise; // F.ID.007: Federated login authenticateWithProvider(provider: 'google' | 'apple', token: string): Promise; // Session management storeSession(session: UserSession): Promise; getSession(): Promise; refreshSession(refreshToken: string): Promise; revokeSession(): Promise; // F.ID.005: Remember me functionality enableRememberMe(duration: number): Promise; disableRememberMe(): Promise; } /** * Trust/Risk assessment interface */ export interface ITrustRepository { calculateRiskScore(): Promise<{ score: number; signals: Record }>; performDeviceAttestation(): Promise; } export interface Credentials { identifier: string; // email or phone password?: string; biometricSignature?: string; deviceId: string; } export interface UserSession { userId: string; accessToken: string; refreshToken: string; expiresAt: string; user: User; riskScore?: number; requiresStepUp?: boolean; } export interface BiometricConfig { enabled: boolean; fallbackToPassword: boolean; promptMessage: string; } export interface AuthConfig { requireEmailVerification: boolean; requirePhoneVerification: boolean; biometrics: BiometricConfig; rememberMeDays: number; maxLoginAttempts: number; lockoutDurationMinutes: number; }