import express from "express"; import { Model, ObjectId } from "mongoose"; import { AuthOptions } from "./expressServer"; export interface User { _id: ObjectId | string; id: string; admin: boolean; /** * We support anonymous users, which do not yet have login information. * This can be helpful for pre-signup users. */ isAnonymous?: boolean; } export interface UserModel extends Model { createAnonymousUser?: (id?: string) => Promise; postCreate?: (body: any) => Promise; createStrategy(): any; serializeUser(): any; deserializeUser(): any; findByUsername(username: string, findOpts: any): any; } export declare function authenticateMiddleware(anonymous?: boolean): any; export declare function signupUser(userModel: UserModel, email: string, password: string, body?: any): Promise; /** * Generates both an access token (JWT) and a refresh token for a given user. * * This function: * - Signs the user's `_id` into a short-lived JWT (`token`) * and a long-lived refresh token (`refreshToken`). * - Supports custom expiration logic * and payload customization via `AuthOptions`. * - Reads token secrets, issuer, * and default expirations from environment variables. * - Returns `{ token, refreshToken }`, * or `{ token: null, refreshToken: null }` if the user is missing. * * It is exported to allow external implementations (such as OAuth integrations or other * authentication providers) to reuse and customize the same token generation logic. * This ensures consistent and secure token issuance across different authentication flows. */ export declare const generateTokens: (user: any, authOptions?: AuthOptions) => Promise<{ token: null; refreshToken: null; } | { token: string; refreshToken: any; }>; export declare function setupAuth(app: express.Application, userModel: UserModel): void; export declare function addAuthRoutes(app: express.Application, userModel: UserModel, authOptions?: AuthOptions): void; export declare function addMeRoutes(app: express.Application, userModel: UserModel, _authOptions?: AuthOptions): void;