(token: string | undefined, url: string, cookieHeader: string | undefined)
| 54 | * set the access cookie. Pure → unit-testable. A `?k=<token>` match authorizes AND issues |
| 55 | * a cookie so the follow-up SSE / reload requests (which carry no query) stay authorized. */ |
| 56 | export function checkLiveAuth(token: string | undefined, url: string, cookieHeader: string | undefined): |
| 57 | { ok: boolean; setCookie: boolean } { |
| 58 | if (!token) return { ok: true, setCookie: false }; |
| 59 | const q = url.match(/[?&]k=([^&]+)/); |
| 60 | if (q && decodeURIComponent(q[1]!) === token) return { ok: true, setCookie: true }; |
| 61 | const c = (cookieHeader ?? '').match(/(?:^|;\s*)qx_live=([^;]+)/); |
| 62 | if (c && decodeURIComponent(c[1]!) === token) return { ok: true, setCookie: false }; |
| 63 | return { ok: false, setCookie: false }; |
| 64 | } |
| 65 | |
| 66 | /** sha1 of the served HTML — the single comparison that correctly dedupes updates, |
| 67 | * rollbacks (same source, moved pointer), no-op rewrites, and the error overlay. */ |
no outgoing calls
no test coverage detected