MCPcopy
hub / github.com/garrytan/gstack / mintPtySessionToken

Function mintPtySessionToken

browse/src/pty-session-cookie.ts:35–42  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

33
34/** Mint a fresh PTY session token. */
35export function mintPtySessionToken(): { token: string; expiresAt: number } {
36 const token = crypto.randomBytes(32).toString('base64url');
37 const now = Date.now();
38 const expiresAt = now + TTL_MS;
39 sessions.set(token, { createdAt: now, expiresAt });
40 pruneExpired(now);
41 return { token, expiresAt };
42}
43
44/**
45 * Validate a token. Returns true only if the token exists AND is not expired.

Callers 2

makeFetchHandlerFunction · 0.90

Calls 2

setMethod · 0.80
pruneExpiredFunction · 0.70

Tested by

no test coverage detected