@enteocode/nestjs-mfa
Version:
Implementation agnostic RFC-compliant Multi-Factor Authentication (2FA/MFA) module for NestJS with recovery code support
51 lines (50 loc) • 1.43 kB
TypeScript
import { Base32SecretKey, SecretKey } from '@otplib/core';
import type { Token, TokenOptions } from './types';
export declare class OtpService {
/**
* Authenticator extends TOTP, usable for both purposes
*
* The only difference is that Authenticator uses Base32 encoding type
* while TOTP uses hexadecimal.
*
* @private
*/
private readonly authenticator;
/**
* Generates an RFC 3548 / RFC 4226 compliant Base32 string compatible with
* Google Authenticator
*
* @internal
*/
generateSecret(byteLength?: number): Base32SecretKey;
/**
* Generates a Time-Based One-Time Password (TOTP)
*
* If using an authenticator application, then the token is generated in
* client side.
*
* This is useful if you want to use an email as a second factor.
*
* @public
* @param secret
* @param options
*/
generateToken(secret: SecretKey, options?: TokenOptions): Token;
/**
* Generates a Key URI for authenticator app registration (optionally encoded as QR code)
*
* @public
* @param secret
* @param issuer
* @param accountName
*/
generateKeyUri(secret: SecretKey, issuer: string, accountName: string): string;
/**
* Verifies token
*
* @public
* @param secret
* @param token
*/
verify(secret: SecretKey, token: Token): boolean;
}