/** * LHCI Puppeteer Setup Script * Sets the gatekeeper session cookie before auditing */ module.exports = async (browser, context) => { const page = await browser.newPage(); // Using LHCI_URL or TARGET_URL if available const targetUrl = process.env.LHCI_URL || process.env.TARGET_URL || 'https://testing.klz-cables.com'; const gatekeeperPassword = process.env.GATEKEEPER_PASSWORD || 'klz2026'; console.log(`🔑 LHCI Auth: Setting gatekeeper cookie for ${new URL(targetUrl).hostname}...`); await page.setCookie({ name: 'klz_gatekeeper_session', value: gatekeeperPassword, domain: new URL(targetUrl).hostname, path: '/', httpOnly: true, secure: targetUrl.startsWith('https://'), }); await page.close(); };