authrix
Version:
Lightweight, flexible authentication library for Node.js and TypeScript.
96 lines (87 loc) • 2.63 kB
TypeScript
import { Response, Request, NextFunction } from 'express';
export { a as authConfig, g as getAuthrixStatus, i as initAuth, b as isAuthrixInitialized } from './index-Bwhj_bJW.js';
export { A as AuthDbAdapter, a as AuthUser } from './db-R-GJxQGc.js';
declare function signupCore(email: string, password: string): Promise<{
user: {
id: string;
email: string;
};
token: string;
cookieOptions: {
httpOnly: boolean;
secure: boolean;
maxAge: number;
sameSite: "lax";
path: string;
};
}>;
declare function signup(email: string, password: string, res: Response): Promise<{
id: string;
email: string;
}>;
declare function signinCore(email: string, password: string): Promise<{
user: {
id: string;
email: string;
};
token: string;
cookieOptions: {
httpOnly: boolean;
secure: boolean;
maxAge: number;
sameSite: "lax";
path: string;
};
}>;
declare function signin(email: string, password: string, res: Response): Promise<{
id: string;
email: string;
}>;
declare function logoutCore(): {
cookieName: string;
cookieOptions: {
httpOnly: boolean;
secure: boolean;
sameSite: "lax";
path: string;
expires: Date;
};
message: string;
};
declare function logout(res: any): {
message: string;
};
declare function getCurrentUserFromToken(token: string | null): Promise<{
id: string;
email: string;
createdAt: Date | undefined;
} | null>;
declare function getCurrentUser(req: Request): Promise<{
id: string;
email: string;
createdAt: Date | undefined;
} | null>;
declare function isTokenValid(token: string | null): Promise<boolean>;
declare function isAuthenticated(req: Request): Promise<boolean>;
interface AuthenticatedRequest$1 extends Request {
user?: {
id: string;
email: string;
};
}
declare function requireAuth(req: AuthenticatedRequest$1, res: Response, next: NextFunction): Promise<void>;
interface AuthenticatedRequest extends Request {
user?: {
id: string;
email: string;
createdAt?: Date;
};
}
declare function authMiddleware(req: AuthenticatedRequest, res: Response, next: NextFunction): Promise<void>;
interface TokenPayload {
id: string;
email: string;
iat?: number;
exp?: number;
}
export { type AuthenticatedRequest, type TokenPayload, authMiddleware, getCurrentUser, getCurrentUserFromToken, isAuthenticated, isTokenValid, logout, logoutCore, requireAuth, signin, signinCore, signup, signupCore };