import type { Request, Response } from "express"; import { Types } from "mongoose"; export interface SocialProviderConfig { clientId: string; clientSecret: string; redirectUri: string; } export interface SocialConfig { google?: SocialProviderConfig; facebook?: SocialProviderConfig; linkedin?: SocialProviderConfig; } export interface I_SocialUser { name: string; email: string; avatar?: string; provider: string; provider_id?: string; } export interface I_UserObject { _id?: string | Types.ObjectId; name: string; email: string; avatar?: string; role?: string; [key: string]: unknown; } export interface I_LoginSuccess { req: Request; res: Response; user: I_UserObject; provider: string; accessToken: string; } export interface I_OAuthSuccess { user: I_UserObject; provider: string; accessToken: string; rawProfile: unknown; } export interface I_OAuthError { provider: string; error: unknown; code?: string; requestBody: unknown; } export interface I_TokenIssued { user: I_UserObject; provider: string; accessToken: string; rawProfile?: unknown; } export interface I_LoginError { provider: string; error: unknown; requestBody: unknown; } export interface I_TokenError { error: unknown; token?: string; context?: string; } export interface I_Logout { req: Request; res: Response; user: I_UserObject; token: string; } export interface I_TokenBlacklisted { token: string; user?: I_UserObject; reason?: string; } export interface I_TokenRefresh { oldToken: string; newToken: string; user: I_UserObject; } export interface I_SessionTimeout { user?: I_UserObject; token: string; reason: 'expired' | 'invalid' | 'blacklisted' | 'missing'; occurredAt?: Date; } export interface I_Profile { id?: string; sub?: string; name?: string; given_name?: string; family_name?: string; email?: string; picture?: string; avatar_url?: string; [key: string]: unknown; } export interface I_MapProfileToUser { profile: I_Profile; provider: string; } export interface I_AuthHooks { onLoginSuccess?: (context: I_LoginSuccess) => Promise; onOAuthSuccess?: (context: I_OAuthSuccess) => Promise; onOAuthError?: (context: I_OAuthError) => Promise; onTokenIssued?: (context: I_TokenIssued) => Promise; onLoginError?: (context: I_LoginError) => Promise; onTokenError?: (context: I_TokenError) => Promise; onLogout?: (context: I_Logout) => Promise; onTokenBlacklisted?: (context: I_TokenBlacklisted) => Promise; onTokenRefresh?: (context: I_TokenRefresh) => Promise; onSessionTimeout?: (context: I_SessionTimeout) => Promise; mapProfileToUser?: (context: I_MapProfileToUser) => Promise; transformUser?: (user: I_UserObject) => Promise; }