UNPKG

@enteocode/nestjs-mfa

Version:

Implementation agnostic RFC-compliant Multi-Factor Authentication (2FA/MFA) module for NestJS with recovery code support

49 lines (48 loc) 1.71 kB
import { CipherService } from './cipher.service'; import { Namespace } from './namespace'; import { SerializerService } from './serializer/serializer.service'; import type { MfaModuleOptionsInterface } from './mfa.module.options.interface'; import type { SecretKey } from '@otplib/core'; import type { Identifier, RecoveryCode } from './types'; export declare class StorageService { private readonly cipher; private readonly serializer; private readonly logger; private readonly store; constructor(options: MfaModuleOptionsInterface, cipher: CipherService, serializer: SerializerService); /** * Checks the availability of a stored value for the user * * @protected * @param user * @param namespace */ has(user: Identifier, namespace: Namespace): Promise<boolean>; /** * Persists the given value for the user (encrypted if cipher was provided) * * @protected * @param user * @param value * @param namespace */ set(user: Identifier, value: SecretKey, namespace: Namespace.SECRET): Promise<boolean>; set(user: Identifier, value: Set<RecoveryCode>, namespace: Namespace.RECOVERY_CODES): Promise<boolean>; /** * Retrieves the stored value for the user * * @protected * @param user * @param namespace */ get(user: Identifier, namespace: Namespace.SECRET): Promise<SecretKey>; get(user: Identifier, namespace: Namespace.RECOVERY_CODES): Promise<Set<RecoveryCode>>; /** * Deletes the value for the user (if exists) * * @protected * @param user * @param namespace */ delete(user: Identifier, namespace: Namespace): Promise<boolean>; }