diff --git a/types/jwt-express/index.d.ts b/types/jwt-express/index.d.ts index 7e33cc7e6b..cbae9f5b8a 100644 --- a/types/jwt-express/index.d.ts +++ b/types/jwt-express/index.d.ts @@ -218,5 +218,16 @@ declare global { interface Request { jwt: JWT; } + + interface Response { + /** + * Returns a newly created / signed JWT Object from the payload. If you are using cookies, + * it will automatically store the JWT in the cookie as well. + * + * @param payload The payload of the JWT + * @return The newly created JWT + */ + jwt(payload: any): JWT; + } } } diff --git a/types/jwt-express/jwt-express-tests.ts b/types/jwt-express/jwt-express-tests.ts index 450f835ded..fedf8137b3 100644 --- a/types/jwt-express/jwt-express-tests.ts +++ b/types/jwt-express/jwt-express-tests.ts @@ -39,6 +39,7 @@ app.use((err: jwt.JWTExpressError, req: exp.Request, res: exp.Response, next: ex jwtObj = req.jwt; req.jwt.payload; req.hostname.startsWith(""); + jwtObj = res.jwt({ }); }); jwtObj.expired.valueOf(); @@ -60,4 +61,5 @@ app.get("", (req: exp.Request, res: exp.Response, next: exp.NextFunction) => { jwtObj = req.jwt; req.jwt.payload; req.hostname.startsWith(""); + jwtObj = res.jwt({ }); });