MCPcopy Index your code
hub / github.com/TomDoesTech/REST-API-Tutorial-Updated / verifyJwt

Function verifyJwt

src/utils/jwt.utils.ts:20–43  ·  view source on GitHub ↗
(
  token: string,
  keyName: "accessTokenPublicKey" | "refreshTokenPublicKey"
)

Source from the content-addressed store, hash-verified

18}
19
20export function verifyJwt(
21 token: string,
22 keyName: "accessTokenPublicKey" | "refreshTokenPublicKey"
23) {
24 const publicKey = Buffer.from(config.get<string>(keyName), "base64").toString(
25 "ascii"
26 );
27
28 try {
29 const decoded = jwt.verify(token, publicKey);
30 return {
31 valid: true,
32 expired: false,
33 decoded,
34 };
35 } catch (e: any) {
36 console.error(e);
37 return {
38 valid: false,
39 expired: e.message === "jwt expired",
40 decoded: null,
41 };
42 }
43}

Callers 2

deserializeUserFunction · 0.90
reIssueAccessTokenFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected