swaf/src/types/Express.d.ts

55 lines
1.2 KiB
TypeScript

import {Files} from "formidable";
import {Type} from "../Utils";
import Middleware from "../Middleware";
import {FlashMessages} from "../components/SessionComponent";
import {Session, SessionData} from "express-session";
import {PasswordAuthProofSessionData} from "../auth/password/PasswordAuthProof";
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;
is_authenticated?: boolean;
auth_password_proof?: PasswordAuthProofSessionData;
csrf?: string;
}
}