import { AuthenticationService, User, DatabaseInterface, ConnectionInformations, AuthenticatorService, Authenticator, MfaChallenge } from '@accounts/types'; import { AccountsServer } from '@accounts/server'; import { ErrorMessages } from './types'; export interface AccountsMfaOptions { /** * Accounts mfa module errors */ errors?: ErrorMessages; /** * Factors used for mfa */ factors: { [key: string]: AuthenticatorService | undefined; }; /** * Expressed in milliseconds or a string describing a time span zeit/ms. * Default to '5m'. */ expiresIn?: string | number; } interface AccountsMfaAuthenticateParams { mfaToken: string; } export declare class AccountsMfa implements AuthenticationService { serviceName: string; server: AccountsServer; private options; private db; private factors; constructor(options: AccountsMfaOptions); setStore(store: DatabaseInterface): void; /** * @throws {@link AuthenticateErrors} */ authenticate(params: AccountsMfaAuthenticateParams, infos: ConnectionInformations): Promise; /** * @description Request a challenge for the MFA authentication. * @param {string} mfaToken - A valid mfa token you obtained during the login process. * @param {string} authenticatorId - The ID of the authenticator to challenge. * @param {ConnectionInformations} infos - User connection informations. * @throws {@link ChallengeErrors} */ challenge(mfaToken: string, authenticatorId: string, infos: ConnectionInformations): Promise; /** * @description Start the association of a new authenticator. * @param {string} userId - User id to link the new authenticator. * @param {string} serviceName - Service name of the authenticator service. * @param {any} params - Params for the the authenticator service. * @param {ConnectionInformations} infos - User connection informations. * @throws {@link AssociateError} */ associate(userId: string, factorName: string, params: any, infos: ConnectionInformations): Promise; /** * @description Start the association of a new authenticator, this method is called when the user is * enforced to associate an authenticator before the first login. * @param {string} userId - User id to link the new authenticator. * @param {string} serviceName - Service name of the authenticator service. * @param {any} params - Params for the the authenticator service. * @param {ConnectionInformations} infos - User connection informations. * @throws {@link AssociateByMfaTokenError} */ associateByMfaToken(mfaToken: string, factorName: string, params: any, infos: ConnectionInformations): Promise; /** * @description Return the list of the active and inactive authenticators for this user. * The authenticators objects are whitelisted to not expose any sensitive informations to the client. * If you want to get all the fields from the database, use the database `findUserAuthenticators` method directly. * @param {string} userId - User id linked to the authenticators. */ findUserAuthenticators(userId: string): Promise; /** * @description Return the list of the active authenticators for this user. * @param {string} mfaToken - A valid mfa token you obtained during the login process. * @throws {@link FindUserAuthenticatorsByMfaTokenError} */ findUserAuthenticatorsByMfaToken(mfaToken: string): Promise; isMfaChallengeValid(mfaChallenge: MfaChallenge): boolean; } export {};