import { SignOptions, VerifyOptions } from "jsonwebtoken"; import { IToken } from "../interfaces"; import { Auth } from "./Auth"; import { Crypto } from "./Crypto"; /** * Authentication with JSON Web Token */ export declare class JwtAuth extends Auth { /** * Token life time in **second**. */ readonly tokenExpiration: number; token: IToken; protected crypto: Crypto; /** * Create a JWT with the given payload data. * * ```ts * const jwt = k.get(JwtAuth); * const tk = await jwt.createToken({id: "1", roles: []}); * ``` * * @param data IToken * @param options Jwt.sign options */ createToken(data: IToken, options?: SignOptions): Promise; /** * ```ts * const jwt = k.get(JwtAuth); * const tk = await jwt.createToken({id: "1", roles: []}); * * await jwt.checkToken(tk); * ``` * * ### Exceptions * * - TokenExpiredException: token is expired * - JsonWebTokenException: invalid token, ... * * @param token String jwt * @param options Jwt.verify options */ checkToken(token: string, options?: VerifyOptions): Promise; }