authrix
Version:
Lightweight, flexible authentication library for Node.js and TypeScript.
54 lines (51 loc) • 1.61 kB
TypeScript
interface LogoutOptions {
invalidateAllSessions?: boolean;
clearRememberMe?: boolean;
redirectUrl?: string;
extraClear?: string[];
}
interface LogoutResult {
success: boolean;
message: string;
cookiesToClear: Array<{
name: string;
options: {
httpOnly: boolean;
secure: boolean;
sameSite: "lax" | "strict" | "none";
path: string;
expires: Date;
domain?: string;
};
}>;
redirectUrl?: string;
}
/**
* Framework-agnostic logout function with enhanced security features
*/
declare function logoutCore(options?: LogoutOptions): LogoutResult;
interface SessionUser {
id: string;
email: string;
username?: string;
firstName?: string;
lastName?: string;
emailVerified?: boolean;
createdAt?: Date;
lastLoginAt?: Date;
}
interface SessionValidationOptions {
requireEmailVerification?: boolean;
updateLastSeen?: boolean;
includeUserProfile?: boolean;
}
/**
* Framework-agnostic function to get current user from token
* Enhanced with better error handling and optional user profile data
*/
declare function getCurrentUserFromToken(token: string | null, options?: SessionValidationOptions): Promise<SessionUser | null>;
/**
* Framework-agnostic function to check if token is valid
*/
declare function isTokenValid(token: string | null, options?: SessionValidationOptions): Promise<boolean>;
export { type LogoutResult as L, type SessionUser as S, type LogoutOptions as a, getCurrentUserFromToken as g, isTokenValid as i, logoutCore as l };