{"library":"playwright-client-certificate-login","title":"Playwright Client Certificate Authentication","description":"playwright-client-certificate-login is a Node.js utility, currently at version 0.0.3, designed to streamline client certificate-based authentication within Playwright automation scripts. It abstracts the complexities of configuring Playwright's browser context to utilize PFX/PKCS12 files or separate PEM certificate and key files, including their associated passphrases. The library provides a `CertificateAuthSession` class that manages the entire authentication process, from launching a browser and navigating to the specified URL, to making the authenticated browser context, page, cookies, and headers accessible. Given its early version, the package is in active development with an implied irregular release cadence, primarily focusing on robust client certificate handling for scenarios such as SAP BTP and other enterprise authentication systems.","language":"javascript","status":"active","last_verified":"Tue Apr 21","install":{"commands":["npm install playwright-client-certificate-login"],"cli":null},"imports":["import { CertificateAuthSession } from 'playwright-client-certificate-login';"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { CertificateAuthSession } from 'playwright-client-certificate-login';\nimport path from 'path';\n\nasync function authenticateWithCert() {\n  const pfxPath = process.env.PFX_CERT_PATH ?? path.resolve(__dirname, './your-certificate.pfx');\n  const passphrase = process.env.CERT_PASSPHRASE ?? 'your-certificate-passphrase';\n\n  if (!pfxPath || !passphrase) {\n    console.error('Environment variables PFX_CERT_PATH and CERT_PASSPHRASE must be set, or provide hardcoded defaults.');\n    return;\n  }\n\n  const options = {\n    origin: 'https://your-secure-domain.com',\n    url: 'https://your-secure-domain.com/dashboard',\n    pfxPath: pfxPath,\n    passphrase: passphrase\n  };\n\n  const session = new CertificateAuthSession(options);\n  try {\n    console.log('Attempting authentication...');\n    await session.authenticate();\n\n    const cookies = await session.getCookies();\n    const headers = session.getHeaders();\n    console.log('Authentication successful. Cookies:', cookies.map(c => c.name));\n    console.log('Prepared Headers:', headers);\n\n    // Example: Interact with the authenticated page\n    const page = session.getPage();\n    await page.screenshot({ path: 'authenticated-dashboard.png' });\n    console.log('Screenshot taken: authenticated-dashboard.png');\n\n  } catch (error) {\n    console.error('Authentication failed:', error);\n  } finally {\n    console.log('Closing browser session.');\n    await session.close();\n  }\n}\n\nauthenticateWithCert();","lang":"typescript","description":"Demonstrates authenticating to a web application using a PFX client certificate, capturing cookies, headers, and taking a screenshot of the authenticated page.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}