MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / issueSession

Function issueSession

telemetry-dashboard/src/auth.ts:97–107  ·  view source on GitHub ↗
(env: Env)

Source from the content-addressed store, hash-verified

95}
96
97export async function issueSession(env: Env): Promise<string> {
98 const now = Math.floor(Date.now() / 1000);
99 const payload: SessionPayload = {
100 v: SESSION_VERSION,
101 iat: now,
102 exp: now + SESSION_TTL_SECONDS,
103 pw: await passwordFingerprint(env.ADMIN_PASSWORD),
104 };
105 const encoded = base64UrlEncode(encoder.encode(JSON.stringify(payload)));
106 return `${encoded}.${base64UrlEncode(await sign(env.SESSION_SECRET, encoded))}`;
107}
108
109export async function hasValidSession(env: Env, request: Request): Promise<boolean> {
110 if (!env.ADMIN_PASSWORD || !env.SESSION_SECRET) return false;

Callers 1

handleLoginSubmitFunction · 0.90

Calls 3

passwordFingerprintFunction · 0.85
base64UrlEncodeFunction · 0.85
signFunction · 0.85

Tested by

no test coverage detected