@wikiccu/nest-auth
Version:
A comprehensive authentication package for NestJS applications with Prisma and PostgreSQL
32 lines (31 loc) • 1.42 kB
TypeScript
import { ConfigService } from '@nestjs/config';
import { PrismaService } from './prisma.service';
import { JwtService } from '@nestjs/jwt';
import { SessionInfo } from '../types';
export declare class TokenService {
private readonly prisma;
private readonly jwtService;
private readonly configService;
constructor(prisma: PrismaService, jwtService: JwtService, configService: ConfigService);
generateRefreshToken(userId: string, rememberMe?: boolean): Promise<string>;
verifyRefreshToken(token: string): Promise<{
userId: string;
} | null>;
rotateRefreshToken(oldToken: string, userId: string): Promise<string>;
revokeRefreshToken(token: string): Promise<void>;
revokeAllRefreshTokens(userId: string): Promise<void>;
generatePasswordResetToken(userId: string): Promise<string>;
verifyPasswordResetToken(token: string): Promise<{
userId: string;
} | null>;
generateEmailVerificationToken(userId: string): Promise<string>;
verifyEmailVerificationToken(token: string): Promise<{
userId: string;
} | null>;
createSession(userId: string, token: string, sessionInfo: SessionInfo): Promise<void>;
getUserSessions(userId: string): Promise<any[]>;
revokeSession(sessionId: string): Promise<void>;
revokeAllSessions(userId: string): Promise<void>;
cleanupExpiredTokens(): Promise<void>;
private calculateExpirationDate;
}