MCPcopy Create free account
hub / github.com/code100x/cms / verifyJWT

Function verifyJWT

src/middleware.ts:17–29  ·  view source on GitHub ↗
(token: string)

Source from the content-addressed store, hash-verified

15}
16
17export const verifyJWT = async (token: string): Promise<JWTPayload | null> => {
18 const secret = process.env.JWT_SECRET || '';
19
20 try {
21 const jwk = await importJWK({ k: secret, alg: 'HS256', kty: 'oct' });
22 const { payload } = await jwtVerify(token, jwk);
23
24 return payload;
25 } catch (error) {
26 console.error('Invalid token:', error);
27 return null;
28 }
29};
30
31export const withMobileAuth = async (req: RequestWithUser) => {
32 if (req.headers.get('Auth-Key')) {

Callers 1

withMobileAuthFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected