UNPKG

alapa

Version:

A cutting-edge web development framework designed to revolutionize the way developers build modern web applications.

38 lines (37 loc) 1.3 kB
import { Request, Response } from "express"; export interface LoginResponse { success: boolean; message?: string; destination?: string; } export interface AttemptResponse<U = any> { success: boolean; reason?: string; errorMessage?: string; user?: U; } export interface ApiBaseAuthResponse { success: boolean; token?: string; user?: any; expiresAt?: Date; error?: { message?: string; reasons?: string; }; } type WhenCallback = <U = any>(user: U) => Promise<AttemptResponse<U>>; export declare class Auth { static user: any; static check(req: Request): Promise<boolean>; static apiBasicAuth(username: string, password: string): Promise<ApiBaseAuthResponse>; private static getUserFromDB; private static authenticate; static withCookies(user: any, req: Request, res: Response): Promise<LoginResponse>; static attempt<U = any>(username: string, password: string, ...when: WhenCallback[]): Promise<AttemptResponse<U>>; static login: (user: any, req: Request, res: Response, rememberMe?: boolean) => Promise<LoginResponse>; static logout: (req: Request, res: Response, destroySession?: boolean) => Promise<boolean>; static get isAdmin(): boolean; static get userRole(): string; } export {};