()
| 33 | |
| 34 | /** Mint a fresh PTY session token. */ |
| 35 | export 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. |
no test coverage detected