perf: cache jwt secret as key

This commit is contained in:
Samuel committed 2023-03-17 17:47:43 +01:00
1 parent 5b6b97e86c
commit 810f5dd84c
3 files changed
+21 -7

No files matched your search

+2 -1
View File
@@ -19,6 +19,7 @@
import jwt, { VerifyOptions } from "jsonwebtoken";
import { Config } from "./Config";
import { User } from "../entities";
import { KeyObject } from "crypto";
export const JWTOptions: VerifyOptions = { algorithms: ["HS256"] };
@@ -62,7 +63,7 @@ async function checkEmailToken(
export function checkToken(
token: string,
jwtSecret: string,
jwtSecret: string | KeyObject,
isEmailVerification = false,
): Promise<UserTokenData> {
return new Promise((res, rej) => {