@mercury-labs/nest-auth
Version:
Mercury framework auth library. It supports local auth, jwt with both bearer token and cookie, basic auth.
24 lines (23 loc) • 1.24 kB
TypeScript
import { JwtService } from '@nestjs/jwt';
import { Observable } from 'rxjs';
import type { IAuthDefinitions, IAuthUserEntityForResponse, IJwtPayload } from '../index';
import { HashTextService } from './hash-text.service';
export interface IJwtTokenResponse {
accessToken: string;
refreshToken: string;
expiryDate: Date;
refreshTokenExpiryDate: Date;
}
export declare class TokenService {
readonly authDefinitions: IAuthDefinitions;
readonly jwtService: JwtService;
readonly hashTextService: HashTextService;
constructor(authDefinitions: IAuthDefinitions, jwtService: JwtService, hashTextService: HashTextService);
generateTokenResponse(userInfo: IAuthUserEntityForResponse): Observable<IJwtTokenResponse>;
generateJwtToken(userInfo: IAuthUserEntityForResponse, expiresIn: string | number): Observable<string>;
generateAccessToken(userInfo: IAuthUserEntityForResponse): Observable<string>;
decodeAccessToken(token: string): IJwtPayload | undefined;
decodeTokenFromRawDecoded(rawPayload: IJwtPayload): IJwtPayload | undefined;
generateRefreshToken(userInfo: IAuthUserEntityForResponse): Observable<string>;
decodeRefreshToken(refreshToken: string): IJwtPayload | undefined;
}