MCPcopy Create free account
hub / github.com/bewcloud/bewcloud / verifyAuthJwt

Function verifyAuthJwt

lib/auth.ts:41–53  ·  view source on GitHub ↗
(key: CryptoKey, jwt: string)

Source from the content-addressed store, hash-verified

39}
40
41export async function verifyAuthJwt<T = JwtData>(key: CryptoKey, jwt: string): Promise<T> {
42 const jwtParts = jwt.split('.');
43 if (jwtParts.length !== 3) {
44 throw new Error('Malformed JWT');
45 }
46
47 const data = textToData(jwtParts[0] + '.' + jwtParts[1]);
48 if (await crypto.subtle.verify({ name: 'HMAC' }, key, decodeBase64Url(jwtParts[2]), data) === true) {
49 return JSON.parse(dataToText(decodeBase64Url(jwtParts[1]))) as T;
50 }
51
52 throw new Error('Invalid JWT');
53}
54
55export async function resolveCookieDomain(request: Request) {
56 const config = await AppConfig.getConfig();

Callers 2

getDataFromCookieMethod · 0.90
getDataFromCookieFunction · 0.85

Calls 3

textToDataFunction · 0.85
dataToTextFunction · 0.85
parseMethod · 0.45

Tested by

no test coverage detected