{"name":"agent-base","version":"9.0.0","type":"module","description":"Turn a function into an `http.Agent` instance","exports":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"repository":{"type":"git","url":"git+https://github.com/TooTallNate/proxy-agents.git","directory":"packages/agent-base"},"keywords":["http","agent","base","barebones","https"],"author":{"name":"Nathan Rajlich","email":"nathan@tootallnate.net","url":"http://n8.io/"},"license":"MIT","devDependencies":{"@types/debug":"^4.1.7","@types/node":"^22.13.0","@types/semver":"^7.3.13","@types/ws":"^8.5.4","async-listen":"^3.0.0","typescript":"^5.1.6","ws":"^8.13.0","tsconfig":"0.0.0"},"engines":{"node":">= 20"},"scripts":{"build":"tsc","test":"vitest","lint":"eslint . --ext .ts","pack":"node ../../scripts/pack.mjs"},"_id":"agent-base@9.0.0","bugs":{"url":"https://github.com/TooTallNate/proxy-agents/issues"},"homepage":"https://github.com/TooTallNate/proxy-agents#readme","_integrity":"sha512-TQf59BsZnytt8GdJKLPfUZ54g/iaUL2OWDSFCCvMOhsHduDQxO8xC4PNeyIkVcA5KwL2phPSv0douC0fgWzmnA==","_resolved":"/tmp/35de566a46985c335abb3c36adc7632e/agent-base-9.0.0.tgz","_from":"file:agent-base-9.0.0.tgz","_nodeVersion":"20.20.1","_npmVersion":"11.12.1","dist":{"integrity":"sha512-TQf59BsZnytt8GdJKLPfUZ54g/iaUL2OWDSFCCvMOhsHduDQxO8xC4PNeyIkVcA5KwL2phPSv0douC0fgWzmnA==","shasum":"ec9efb08314e1e75b0852d74aabf9a387f99834e","tarball":"http://registry-npm.ywwl.com/agent-base/download/agent-base-9.0.0.tgz","fileCount":11,"unpackedSize":21009,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/agent-base@9.0.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCy3iMjwgQEuTOa6HP6Z8rcloxwEJ8bwYjY+JEjVSwbQQIhALdbXkwSQOK8paTBvRi0fDjLluuxQVHWEtciF5KOP97C"}],"size":6984,"noattachment":false,"key":"/agent-base/-/agent-base-9.0.0.tgz"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:4f73d455-a0ca-46c3-88be-b7d7eb6d7e41"}},"directories":{},"maintainers":[{"name":"tootallnate","email":"nathan@tootallnate.net"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/agent-base_9.0.0_1775026654098_0.19517685027463738"},"_hasShrinkwrap":false,"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":1775026654221,"_cnpm_publish_time":1775026654221,"dist-tags":{"latest":"9.0.0"}}