MCPcopy Create free account
hub / github.com/QodeXcli/QodeX / checkLiveAuth

Function checkLiveAuth

src/artifacts/live-server.ts:56–64  ·  view source on GitHub ↗
(token: string | undefined, url: string, cookieHeader: string | undefined)

Source from the content-addressed store, hash-verified

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. */
56export 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. */

Callers 2

createLiveServerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected