{"name":"agent-base","version":"8.0.0","keywords":["http","agent","base","barebones","https"],"author":{"url":"http://n8.io/","name":"Nathan Rajlich","email":"nathan@tootallnate.net"},"license":"MIT","_id":"agent-base@8.0.0","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":"3eb7c2c198ccb93368c77969530594e725b804b5","tarball":"http://registry-npm.ywwl.com/agent-base/download/agent-base-8.0.0.tgz","fileCount":11,"integrity":"sha512-QT8i0hCz6C/KQ+KTAbSNwCHDGdmUJl2tp2ZpNlGSWCfhUNVbYG2WLE3MdZGBAgXPV4GAvjGMxo+C1hroyxmZEg==","signatures":[{"sig":"MEMCIDtBCOkAABAg72RCDA8rILJtt/yran3r2nrvoxDNR+gyAh9WnXlnd6tBtyCwZDoHCK7S2WIfhjr0JNndumf0I8GS","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/agent-base@8.0.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":21098,"size":6992,"noattachment":false,"key":"/agent-base/-/agent-base-8.0.0.tgz"},"type":"module","_from":"file:agent-base-8.0.0.tgz","engines":{"node":">= 14"},"exports":{"import":{"types":"./dist/index.d.ts","default":"./dist/index.js"}},"scripts":{"lint":"eslint . --ext .ts","pack":"node ../../scripts/pack.mjs","test":"vitest","build":"tsc"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:4f73d455-a0ca-46c3-88be-b7d7eb6d7e41"}},"_resolved":"/tmp/82768b7027542d3f195a687e673a50a6/agent-base-8.0.0.tgz","_integrity":"sha512-QT8i0hCz6C/KQ+KTAbSNwCHDGdmUJl2tp2ZpNlGSWCfhUNVbYG2WLE3MdZGBAgXPV4GAvjGMxo+C1hroyxmZEg==","repository":{"url":"git+https://github.com/TooTallNate/proxy-agents.git","type":"git","directory":"packages/agent-base"},"_npmVersion":"11.11.0","description":"Turn a function into an `http.Agent` instance","directories":{},"_nodeVersion":"20.20.0","_hasShrinkwrap":false,"devDependencies":{"ws":"^8.13.0","tsconfig":"0.0.0","@types/ws":"^8.5.4","typescript":"^5.1.6","@types/node":"^22.13.0","@types/debug":"^4.1.7","async-listen":"^3.0.0","@types/semver":"^7.3.13"},"_npmOperationalInternal":{"tmp":"tmp/agent-base_8.0.0_1773248304336_0.716893543406804","host":"s3://npm-registry-packages-npm-production"},"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":1773248304478,"_cnpm_publish_time":1773248304478,"dist-tags":{"latest":"9.0.0"}}