{"library":"pac-proxy-agent","title":"PAC Proxy Agent","description":"`pac-proxy-agent` is a Node.js module that provides an `http.Agent` implementation for resolving proxy settings using a Proxy Auto-Configuration (PAC) file. It is part of the actively maintained `proxy-agents` monorepo by TooTallNate and is currently at version `9.0.1`. This agent seamlessly integrates with Node.js's native `http` and `https` modules, automatically determining whether to use a direct connection, an HTTP proxy, an HTTPS proxy, or a SOCKS proxy based on the PAC file's logic for a given target URL. Releases typically follow the monorepo's cadence, often aligning major version bumps with Node.js LTS updates, such as the recent shift to Node.js 20. Its key differentiator is its robust and secure PAC file interpretation, leveraging `quickjs-wasi` for isolated PAC script execution.","language":"javascript","status":"active","last_verified":"Tue Apr 21","install":{"commands":["npm install pac-proxy-agent"],"cli":null},"imports":["import { PacProxyAgent } from 'pac-proxy-agent';"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import * as http from 'http';\nimport { PacProxyAgent } from 'pac-proxy-agent';\n\nconst pacFileUrl = process.env.PAC_FILE_URL ?? 'pac+https://cloudup.com/ceGH2yZ0Bjp+';\nconst targetUrl = process.env.TARGET_URL ?? 'http://nodejs.org/api/';\n\nconst agent = new PacProxyAgent(pacFileUrl);\n\nconsole.log(`Attempting to fetch ${targetUrl} using PAC file from ${pacFileUrl}`);\n\nhttp.get(targetUrl, { agent }, (res) => {\n  console.log(`Successfully connected! Status: ${res.statusCode}`);\n  console.log('Response Headers:', res.headers);\n  res.pipe(process.stdout);\n}).on('error', (err) => {\n  console.error('Error fetching URL:', err.message);\n  process.exit(1);\n});","lang":"typescript","description":"Demonstrates initializing `PacProxyAgent` with a PAC file URL and using it with Node.js's built-in `http.get`.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}