swaf/src/types/Express.d.ts

56 lines
1.2 KiB
TypeScript

import {Session, SessionData} from "express-session";
import {Files} from "formidable";
import {PasswordAuthProofSessionData} from "../auth/password/PasswordAuthProof.js";
import {FlashMessages} from "../components/SessionComponent.js";
import Middleware from "../Middleware.js";
import {Type} from "../Utils.js";
declare global {
namespace Express {
export interface Request {
getSession(): Session & Partial<SessionData>;
getSessionOptional(): Session & Partial<SessionData> | undefined;
files: Files;
middlewares: Middleware[];
as<M extends Middleware>(type: Type<M>): M;
flash(): FlashMessages;
flash(message: string): unknown[];
flash(event: string, message: unknown): void;
getPreviousUrl(): string | null;
getIntendedUrl(): string | null;
}
}
}
declare module 'express-session' {
interface SessionData {
id?: string;
previousUrl?: string;
wantsSessionPersistence?: boolean;
persistent?: boolean;
isAuthenticated?: boolean;
authPasswordProof?: PasswordAuthProofSessionData;
csrf?: string;
}
}