@next-nest-auth/nestauth
Version:
NestAuth is an authentication solution for NestJS applications, designed to handle user login, session management, and token-based authentication (JWT). It integrates seamlessly with Next.js and other frontends to provide a unified authentication system,
40 lines (34 loc) • 991 B
text/typescript
import { Type } from "@nestjs/common";
export interface NestAuthModuleOptions {
UserModule: Type<any>;
UserService: Type<NestAuthInterface>;
jwtSecret: string;
jwtExpiresIn?: string;
jwtRefreshTokenExpiresIn?: string;
}
export type JwtPayloadType = {
sub: number;
name?: string;
email?: string;
username?: string;
role?: string;
pic?: string;
macId?: string;
};
export type SocialProfileType = {
id: string;
email: string;
firstName: string;
lastName: string;
picture: string;
accessToken: string;
refreshToken: string;
};
export type GoogleProfileType = SocialProfileType;
export type FacebookProfileType = SocialProfileType;
export interface NestAuthInterface {
validateUser(params: any): Promise<JwtPayloadType>;
getUserById(id: number): Promise<JwtPayloadType>;
google?(params: GoogleProfileType): Promise<JwtPayloadType>;
facebook?(params: FacebookProfileType): Promise<JwtPayloadType>;
}