/** * Library containing useful function to generate and encrypt password and so on. */ import User from "../entities/user.entity"; import { Request } from "express"; /** * Encrypt a plain password. This method support async/await. * @param plainPassword the original plain text password * @return a promise with the ecrypted password */ export declare function hashPassword(plainPassword: string): Promise; /** * Verify that a plain password match with an encrypted hashPassword. * This method support async/await * @param plainPassword the plain text password * @param hashPassword the encrypted (or hashed) password * @return a promise, true if the two passwords match, false otherwise */ export declare function verifyPassword(plainPassword: string, hashPassword: string): Promise; /** * Generate a new text plain password * @return a new generated password */ export declare function generatePassword(): string; /** * Enum with self-explanatories errors for the user login method */ export declare enum UserErrors { NOT_FOUND = 1, WRONG_PASSWORD = 2 } /** * Execute the login of a user, using the standard User Entity. * @param email the user email * @param password the plain text password * @return a promise, with an error if somethink goes wrong, or the user if the login was successul */ export declare function performLogin(email: string, password: string): Promise; /** * Create a new cookie-based session for the user. * @param req the standard Express session * @param user the logged-in user */ export declare function createUserSession(req: Request, user: User): void; /** * Destoy (if any) the current user session. * @param req the standard Express session */ export declare function destroyUserSession(req: Request): void; /** * Retrieve the user from the current session * @param req the standard Express session * @return a promise, with the user if logged, or undefined */ export declare function retrieveUserFromSession(req: Request): Promise;