@re-auth/http-adapters
Version:
HTTP adapters for ReAuth authentication framework
48 lines • 1.59 kB
TypeScript
import { Request, Response, NextFunction, Router } from 'express';
import { ReAuthEngine, Entity, AuthToken } from '@re-auth/reauth';
export interface ExpressAuthConfig {
path?: string;
cookieName?: string;
cookieOptions?: {
httpOnly?: boolean;
secure?: boolean;
sameSite?: 'strict' | 'lax' | 'none' | boolean;
maxAge?: number;
domain?: string;
path?: string;
};
}
export declare class ExpressAuthAdapter {
private router;
private engine;
private config;
constructor(engine: ReAuthEngine, config?: ExpressAuthConfig);
private setupMiddleware;
private setupRoutes;
private createStepHandler;
private extractInputs;
private handleStepResponse;
private getStatusCode;
private errorResponse;
private requireAuth;
private extractToken;
getRouter(): Router;
protect(options?: ProtectOptions): (req: Request, res: Response, next: NextFunction) => Promise<Response<any, Record<string, any>> | undefined>;
}
interface ProtectOptions {
roles?: string[];
authorize?: (entity: Entity, request: Request, response: Response, next: NextFunction) => Promise<boolean> | boolean;
}
export declare function createExpressAdapter(engine: ReAuthEngine, config?: ExpressAuthConfig): Router;
declare global {
namespace Express {
interface Request {
user?: Entity;
token?: AuthToken;
isAuthenticated(): boolean;
}
}
}
export default createExpressAdapter;
export * from './express-adapter-v2';
//# sourceMappingURL=index.d.ts.map