{"name":"agent-base","version":"7.1.3","keywords":["http","agent","base","barebones","https"],"author":{"url":"http://n8.io/","name":"Nathan Rajlich","email":"nathan@tootallnate.net"},"license":"MIT","_id":"agent-base@7.1.3","maintainers":[{"name":"tootallnate","email":"nathan@tootallnate.net"}],"homepage":"https://github.com/TooTallNate/proxy-agents#readme","bugs":{"url":"https://github.com/TooTallNate/proxy-agents/issues"},"dist":{"shasum":"29435eb821bc4194633a5b89e5bc4703bafc25a1","tarball":"http://registry-npm.ywwl.com/agent-base/download/agent-base-7.1.3.tgz","fileCount":12,"integrity":"sha512-jRR5wdylq8CkOe6hei19GGZnxM6rBGwFl3Bg0YItGDimvjGtAvdZk4Pu6Cl4u4Igsws4a1fd1Vq3ezrhn4KmFw==","signatures":[{"sig":"MEUCIGPXvJWij+sL0uBz+jG5jqDD/Cq6tbJ47abDAe1nuBMJAiEAyYLnJ1AjcCuGMxYYrsmaFfrdKAk52YVoZqK886o44PA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":31548,"size":7840,"noattachment":false,"key":"/agent-base/-/agent-base-7.1.3.tgz"},"main":"./dist/index.js","_from":"file:agent-base-7.1.3.tgz","types":"./dist/index.d.ts","engines":{"node":">= 14"},"scripts":{"lint":"eslint . --ext .ts","pack":"node ../../scripts/pack.mjs","test":"jest --env node --verbose --bail","build":"tsc"},"_npmUser":{"name":"tootallnate","email":"nathan@tootallnate.net"},"_resolved":"/tmp/0708188976c1b804614f97606b4b448d/agent-base-7.1.3.tgz","_integrity":"sha512-jRR5wdylq8CkOe6hei19GGZnxM6rBGwFl3Bg0YItGDimvjGtAvdZk4Pu6Cl4u4Igsws4a1fd1Vq3ezrhn4KmFw==","repository":{"url":"git+https://github.com/TooTallNate/proxy-agents.git","type":"git","directory":"packages/agent-base"},"_npmVersion":"10.8.2","description":"Turn a function into an `http.Agent` instance","directories":{},"_nodeVersion":"20.18.1","_hasShrinkwrap":false,"devDependencies":{"ws":"^5.2.4","jest":"^29.5.0","ts-jest":"^29.1.0","tsconfig":"0.0.0","@types/ws":"^6.0.4","typescript":"^5.0.4","@types/jest":"^29.5.1","@types/node":"^14.18.45","@types/debug":"^4.1.7","async-listen":"^3.0.0","@types/semver":"^7.3.13"},"_npmOperationalInternal":{"tmp":"tmp/agent-base_7.1.3_1733630651319_0.4296383757785176","host":"s3://npm-registry-packages"},"readme":"agent-base\n==========\n### Turn a function into an [`http.Agent`][http.Agent] instance\n\nThis module is a thin wrapper around the base `http.Agent` class.\n\nIt provides an abstract class that must define a `connect()` function,\nwhich is responsible for creating the underlying socket that the HTTP\nclient requests will use.\n\nThe `connect()` function may return an arbitrary `Duplex` stream, or\nanother `http.Agent` instance to delegate the request to, and may be\nasynchronous (by defining an `async` function).\n\nInstances of this agent can be used with the `http` and `https`\nmodules. To differentiate, the options parameter in the `connect()`\nfunction includes a `secureEndpoint` property, which can be checked\nto determine what type of socket should be returned.\n\n#### Some subclasses:\n\nHere are some more interesting uses of `agent-base`.\nSend a pull request to list yours!\n\n * [`http-proxy-agent`][http-proxy-agent]: An HTTP(s) proxy `http.Agent` implementation for HTTP endpoints\n * [`https-proxy-agent`][https-proxy-agent]: An HTTP(s) proxy `http.Agent` implementation for HTTPS endpoints\n * [`pac-proxy-agent`][pac-proxy-agent]: A PAC file proxy `http.Agent` implementation for HTTP and HTTPS\n * [`socks-proxy-agent`][socks-proxy-agent]: A SOCKS proxy `http.Agent` implementation for HTTP and HTTPS\n\nExample\n-------\n\nHere's a minimal example that creates a new `net.Socket` or `tls.Socket`\nbased on the `secureEndpoint` property. This agent can be used with both\nthe `http` and `https` modules.\n\n```ts\nimport * as net from 'net';\nimport * as tls from 'tls';\nimport * as http from 'http';\nimport { Agent } from 'agent-base';\n\nclass MyAgent extends Agent {\n  connect(req, opts) {\n    // `secureEndpoint` is true when using the \"https\" module\n    if (opts.secureEndpoint) {\n      return tls.connect(opts);\n    } else {\n      return net.connect(opts);\n    }\n  }\n});\n\n// Keep alive enabled means that `connect()` will only be\n// invoked when a new connection needs to be created\nconst agent = new MyAgent({ keepAlive: true });\n\n// Pass the `agent` option when creating the HTTP request\nhttp.get('http://nodejs.org/api/', { agent }, (res) => {\n  console.log('\"response\" event!', res.headers);\n  res.pipe(process.stdout);\n});\n```\n\n[http-proxy-agent]: ../http-proxy-agent\n[https-proxy-agent]: ../https-proxy-agent\n[pac-proxy-agent]: ../pac-proxy-agent\n[socks-proxy-agent]: ../socks-proxy-agent\n[http.Agent]: https://nodejs.org/api/http.html#http_class_http_agent\n","publish_time":1733630651531,"_cnpm_publish_time":1733630651531,"dist-tags":{"latest":"9.0.0"}}