{"library":"proxying-agent","title":"Node HTTP/HTTPS Forward Proxy Agent","description":"proxying-agent is a Node.js library providing an HTTP/HTTPS forward proxy agent. It is built upon Node's native `http.Agent` and offers features for transparently routing HTTP and HTTPS requests through a specified proxy server. Key capabilities include support for SSL tunneling via the HTTP CONNECT method, Basic authentication, and a beta implementation of NTLM authentication, allowing for domain-specific username formats (e.g., `domain\\username`). The library also provides a `globalize` method to easily configure all subsequent `http` and `https` requests to use a designated proxy. The current stable version is 2.4.0, released in July 2017. Due to its age, it is considered abandoned, with no active development or maintenance since its last update. This lack of recent activity suggests potential incompatibilities with newer Node.js versions and a risk of unaddressed security vulnerabilities, making it crucial for users to assess its suitability for modern applications.","language":"javascript","status":"abandoned","last_verified":"Wed Apr 22","install":{"commands":["npm install proxying-agent"],"cli":null},"imports":["const proxyingAgent = require('proxying-agent');","const { create } = require('proxying-agent');","const { globalize } = require('proxying-agent');"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"const http = require('http');\nconst https = require('https');\n\nconst proxyOptions = {\n  proxy: 'http://username:password@proxy.example.com:8080',\n  authType: 'ntlm',\n  ntlm: {\n    domain: 'MYDOMAIN',\n    workstation: process.env.WORKSTATION_NAME ?? 'my-machine' // Optional, for NTLM\n  }\n};\n\nconst proxyingAgent = require('proxying-agent').create(proxyOptions, 'https://target.example.com');\n\nconst req = https.request({\n  host: 'target.example.com',\n  port: 443,\n  method: 'GET',\n  path: '/',\n  agent: proxyingAgent\n});\n\nreq.on('socket', (socket) => {\n  // For NTLM, delay sending request data until the socket is assigned to prevent premature closure.\n  // For other auth types, you might send data immediately after req creation.\n  console.log('Socket assigned, sending request data...');\n  req.end('Hello from client!'); // No data for GET, but demonstrates the pattern\n});\n\nreq.on('response', (res) => {\n  console.log(`STATUS: ${res.statusCode}`);\n  console.log(`HEADERS: ${JSON.stringify(res.headers)}`);\n  res.setEncoding('utf8');\n  res.on('data', (chunk) => {\n    console.log(`BODY: ${chunk}`);\n  });\n  res.on('end', () => {\n    console.log('No more data in response.');\n  });\n});\n\nreq.on('error', (e) => {\n  console.error(`problem with request: ${e.message}`);\n});\n\n// If not using NTLM or delaying data, you would call req.end() directly here.\n// req.end(); // For non-NTLM or immediate data send\n","lang":"javascript","description":"This example demonstrates how to create and use `proxying-agent` with NTLM authentication for an HTTPS request, including the crucial `req.on('socket')` pattern for NTLM.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}