/** * Arial Server - Authentication middleware * * Validates JWT tokens and attaches user info to requests */ import type { ResolvedServerConfig, ResolvedAuthConfig } from "../config/types.js"; import type { User } from "../db/types.js"; /** * Authenticated user context attached to requests */ export interface AuthContext { userId: string; username: string; tokenVersion: number; user: User; } /** * Result of authentication check */ export type AuthResult = { ok: true; context: AuthContext; } | { ok: false; error: string; status: number; }; /** * Extract Bearer token from Authorization header */ export declare function extractBearerToken(authHeader: string | null): string | null; /** * Authenticate a request using JWT */ export declare function authenticateJwt(token: string, config: ResolvedAuthConfig): AuthResult; /** * Authenticate a request using JWT */ export declare function authenticate(req: Request, config: ResolvedServerConfig): AuthResult; /** * Create an unauthorized response */ export declare function unauthorizedResponse(error: string, status?: number): Response; //# sourceMappingURL=middleware.d.ts.map