jwt-node-auth
Version:
This is a NodeJS authentication package using JWT in the background. This package let you generate a JWT Token and Verify the token on a fly.
26 lines (18 loc) • 794 B
TypeScript
import { VerifyOptions, SignOptions } from "jsonwebtoken";
declare module "jsonwebtoken" {
interface JwtPayload {
[key: string]: any;
}
function verify(token: string, secretOrPublicKey: string | Buffer, options?: VerifyOptions): JwtPayload | string;
function sign(payload: string | Buffer | object, secretOrPrivateKey: string | Buffer, options?: SignOptions): string;
}
import { Request, Response, NextFunction } from "express";
interface CustomRequest extends Request {
user: Record<string, any>;
}
declare class NodeAuth {
constructor(secret: string, expires: number);
requireAuth(req: CustomRequest, res: Response, next: NextFunction): void;
getSignedJwtToken(payload: {}): Promise<string>;
}
export default NodeAuth;