import type { NextFunction, Response } from 'express'; import type { AppUser } from '../../../models/User.ts'; import type { FrameworkRequest } from '../HttpServer.ts'; import type { GetUserByTokenAppInfo } from '../middleware/GetUserByToken.ts'; import AbstractMiddleware from './AbstractMiddleware.ts'; declare class AuthMiddleware extends AbstractMiddleware { static get description(): string; static get requiresAuth(): boolean; /** * Type-only phantom (codegen reads it; runtime ignores it — see * `GetUserByToken.provides`). Auth rejects unauthenticated requests at * runtime, so past this point `appInfo.user` is guaranteed present. Declaring * it as a *required* `user` narrows the optional `user?` that * `GetUserByToken` contributes: `UnionAppInfoProvides` intersects the shapes, * and `{ user?: U } & { user: U }` collapses to `{ user: U }`. Handlers * behind `Auth` then read `appInfo.user` without a guard. */ static get provides(): { user: AppUser; }; middleware(req: FrameworkRequest & GetUserByTokenAppInfo, _res: Response, next: NextFunction): Promise; } export default AuthMiddleware;