UNPKG

@nestjs-mod/two-factor

Version:

Two factor module with an error filter, guard, controller, database migrations and rest-sdk for work with module from other nodejs appliaction

89 lines (88 loc) 2.79 kB
import * as OTPAuth from 'otpauth'; import { TwoFactorUserDto } from './generated/rest-dto/two-factor-user.dto'; import { PrismaClient } from './generated/prisma-client'; import { TwoFactorEventsService } from './two-factor-events.service'; import { TwoFactorConfiguration } from './two-factor.configuration'; export declare class TwoFactorService { private readonly prismaClient; private readonly twoFactorConfiguration; private readonly twoFactorEventsService; private readonly logger; constructor(prismaClient: PrismaClient, twoFactorConfiguration: TwoFactorConfiguration, twoFactorEventsService: TwoFactorEventsService); getTotp(options: { username?: string; secret: string; }): Promise<OTPAuth.TOTP>; generateCode(options: { type: string; operationName: string; externalUserId: string; externalTenantId: string; externalUsername?: string; repetition?: boolean; }): Promise<{ twoFactorUser: TwoFactorUserDto; twoFactorCode: { TwoFactorUser: { id: string; externalTenantId: string; createdAt: Date; updatedAt: Date; username: string | null; secret: string; externalUserId: string; }; } & { type: string; id: string; operationName: string; code: string; used: boolean; outdated: boolean; externalTenantId: string; createdAt: Date; updatedAt: Date; userId: string; }; code: string; }>; validateCode(options: { operationName: string; code: string; externalTenantId: string; }): Promise<{ twoFactorUser: { id: string; externalTenantId: string; createdAt: Date; updatedAt: Date; username: string | null; secret: string; externalUserId: string; }; twoFactorCode: { TwoFactorUser: { id: string; externalTenantId: string; createdAt: Date; updatedAt: Date; username: string | null; secret: string; externalUserId: string; }; } & { type: string; id: string; operationName: string; code: string; used: boolean; outdated: boolean; externalTenantId: string; createdAt: Date; updatedAt: Date; userId: string; }; }>; private getOrCreateUser; private removeOutdateTwoFactorCode; }