(req: http.IncomingMessage)
| 269 | } |
| 270 | |
| 271 | private isValidSession(req: http.IncomingMessage): boolean { |
| 272 | const cookie = req.headers.cookie ?? ""; |
| 273 | const re = new RegExp(`${this.cookieName}=([a-f0-9]+)`); |
| 274 | const match = cookie.match(re); |
| 275 | if (!match) return false; |
| 276 | const expiry = this.auth.sessions.get(match[1]); |
| 277 | if (!expiry) return false; |
| 278 | if (Date.now() > expiry) { this.auth.sessions.delete(match[1]); return false; } |
| 279 | return true; |
| 280 | } |
| 281 | |
| 282 | private get needsSetup(): boolean { |
| 283 | return this.auth.passwordHash === null; |
no test coverage detected