Refresh HiveGrid Cloud reference snapshot

This commit is contained in:
david committed 2026-08-03 15:31:14 +02:00
1 parent 5e99e14772
commit 7f88026f79
5955 files changed
+1177325 -188362

No files matched your search

@@ -5,19 +5,15 @@
* browser instance and the URL it is about to audit.
*
* Auth strategy:
* - For public/marketing routes (no `/app` or `/admin` prefix) we do not
* attempt login; the script is a no-op so audits still run.
* - For `/app/*` and `/admin/*` routes the script POSTs the HiveGrid
* session cookie (provisioned by the staging Lighthouse runner via
* `LIGHTHOUSE_SESSION_COOKIE`) directly into the browser context. This
* mirrors the spec's "auth-via-cookie" strategy and avoids brittle UI
* login flows.
* - The cookie is injected only when the audited hostname matches the
* configured cookie host. This supports host-aware tenant paths without
* ever reusing an app credential on the admin sibling host.
*
* Required env vars (set by the CI workflow):
* - `LIGHTHOUSE_SESSION_COOKIE` — value of the staging session cookie for a
* Lighthouse test user. Minted by the CI workflow before LHCI starts.
* - `LIGHTHOUSE_SESSION_COOKIE_NAME` (optional) — session cookie name.
* Defaults to `hivegrid_session`.
* Defaults to `__Host-hivegrid_app_session`.
* - `LIGHTHOUSE_COOKIE_DOMAIN` (optional) — overrides the cookie domain.
* Defaults to the host of the audited URL.
*
@@ -27,26 +23,34 @@
/** @type {(browser: import('puppeteer').Browser, ctx: { url: string, options: object }) => Promise<void>} */
module.exports = async (browser, context) => {
const sessionCookie = process.env.LIGHTHOUSE_SESSION_COOKIE;
const sessionCookieName = process.env.LIGHTHOUSE_SESSION_COOKIE_NAME || "hivegrid_session";
const sessionCookieName = process.env.LIGHTHOUSE_SESSION_COOKIE_NAME || "__Host-hivegrid_app_session";
const targetUrl = context && context.url ? context.url : "";
const isAuthenticatedRoute = /\/(app|admin)(\/|$)/.test(new URL(targetUrl).pathname);
if (!isAuthenticatedRoute || !sessionCookie) {
if (!targetUrl || !sessionCookie) {
return;
}
const parsed = new URL(targetUrl);
const domain = process.env.LIGHTHOUSE_COOKIE_DOMAIN || parsed.hostname;
if (parsed.hostname !== domain) {
return;
}
// Set the session cookie before LHCI navigates to the URL.
const page = await browser.newPage();
await page.setCookie({
const cookie = {
name: sessionCookieName,
value: sessionCookie,
domain,
path: "/",
httpOnly: true,
secure: parsed.protocol === "https:",
});
};
if (sessionCookieName.startsWith("__Host-")) {
// Puppeteer must receive a URL rather than a Domain attribute; the latter
// would invalidate the browser-enforced __Host- contract.
cookie.url = parsed.origin;
} else {
cookie.domain = domain;
}
await page.setCookie(cookie);
await page.close();
};