@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
91 lines (90 loc) • 2.86 kB
TypeScript
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;
timeout: number;
}): 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;
};
twoFactorTimeout: number;
}>;
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;
};
twoFactorTimeout: number;
}>;
private getOrCreateUser;
private removeOutdateTwoFactorCode;
}