/** * @fileoverview Authentication module - token-based auth for external access * @module mobile/auth * @version 1.5.0 * * Provides authentication for requests from outside localhost. * Uses MAMA_AUTH_TOKEN environment variable for simple token auth. * * @example * import { authenticate, isLocalhost } from './auth'; * if (!authenticate(req)) { * res.writeHead(401); * res.end('Unauthorized'); * } */ import type { IncomingMessage, ServerResponse } from 'http'; interface WebSocketLike { close(code?: number, reason?: string): void; } /** * Environment variable for auth token */ export declare const AUTH_TOKEN: string | undefined; /** * Check if request is from localhost * @param req - HTTP request * @returns True if from localhost */ export declare function isLocalhost(req: IncomingMessage): boolean; /** * Authenticate an HTTP request * @param req - HTTP request * @returns True if authenticated */ export declare function authenticate(req: IncomingMessage): boolean; /** * Authenticate a WebSocket upgrade request * @param req - HTTP upgrade request * @param ws - WebSocket connection * @returns True if authenticated, closes ws if not */ export declare function authenticateWebSocket(req: IncomingMessage, ws: WebSocketLike): boolean; /** * Middleware function type */ type MiddlewareNext = () => void; /** * Create authentication middleware for HTTP routes * @returns Middleware function */ export declare function createAuthMiddleware(): (req: IncomingMessage, res: ServerResponse, next: MiddlewareNext) => void; export {}; //# sourceMappingURL=auth.d.ts.map