{"name":"hpagent","version":"1.0.0","description":"A ready to use http and https agent for working with proxies that keeps connections alive!","main":"index.js","types":"index.d.ts","exports":{".":{"require":"./index.js","import":"./index.mjs"},"./*":"./*.js"},"scripts":{"test":"standard && NODE_EXTRA_CA_CERTS=test/fixtures/certs_unit_test.pem ava -v test/*.test.js && tsd","test-ci":"standard && ava -v test/*.test.js && tsd"},"engines":{"node":">=14"},"repository":{"type":"git","url":"git+https://github.com/delvedor/hpagent.git"},"keywords":["agent","http","https","secure","proxy","alive","keep-alive"],"author":{"name":"Tomas Della Vedova"},"license":"MIT","bugs":{"url":"https://github.com/delvedor/hpagent/issues"},"homepage":"https://github.com/delvedor/hpagent#readme","tsd":{"directory":"test"},"devDependencies":{"ava":"^4.2.0","got":"^11.8.3","needle":"^3.1.0","node-fetch":"^2.6.7","proxy":"^1.0.2","simple-get":"^4.0.1","standard":"^17.0.0","tsd":"^0.20.0"},"gitHead":"bc50f54d4c91db22a3bb4816201d6253dc570951","_id":"hpagent@1.0.0","_nodeVersion":"16.14.2","_npmVersion":"8.5.0","dist":{"integrity":"sha512-SCleE2Uc1bM752ymxg8QXYGW0TWtAV4ZW3TqH1aOnyi6T6YW2xadCcclm5qeVjvMvfQ2RKNtZxO7uVb9CTPt1A==","shasum":"c68f68b3df845687dbdc4896546713ce09cc6bee","tarball":"http://registry-npm.ywwl.com/hpagent/download/hpagent-1.0.0.tgz","fileCount":18,"unpackedSize":59993,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCywf1ygXCHrohyHJETWDY1toLT+ROmuvW2oWZ7O+DzsQIhAIsLPajBtUVkprpONWlAydQWFOfUIxxhK5st7QjH+35W"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJicAzAACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmp0exAAmAMO+u/WNtt4chytcRQ1HVjzMKNBsANXVjANfci1VnmsUuj9\r\nNF+S9wz4SFY/iPcJCRlVkBsdTUCIvpkYiU+YhRLp3UQ3L6ZFxycqbGDhM+Si\r\ndaHl0XFJFs9/9fXiu+lvvBmMILgui0RsMC4UmykyYW6vrEGSAz02RwYx5IHE\r\natgAc9+LG0TU33PyzTTFshNJN6L+sRTE50dABmeyqutfahZmjqa9jfxzXkpA\r\nPky/TcK01bMbbL80LV/QOK6S1+1unEKCOnQ6Q+DjaW5ImuFngQwVB0YqrG4S\r\nGvXEB6VhFQgDDc+hTItuRrBebTUgm8xEbBVUtcUKxZo8q+LsZpcg3PRAmxOS\r\nv8D181Ab3s/tv0HsYT8PyRyuDTKClliikqJhrswmWvXlWpi/+noC/3K+FgBy\r\nW3r2FQrlKn6w9frc49zxkayqiAuz/FaJhByWMtPnEuG0GFg7TPqzsX6xELv/\r\nNjcYVsqoqLZkLS7mUV3rZaHIWEV9DwjpY2TfQdPR8tMZcHAxbOnnIxhGWgrz\r\nXW3wtxUD/oW3MbmPiUuCgy8g/2ldR/8tPsemuFrP6QSEZ5iRGoiF0925e1MN\r\nYXTIMhYY7f4zxT3RCHXPWmdp5Nh8vfQNJQAQ4MwwZvJD0iQT/ufhB587OHgQ\r\nvKBq1bWYAKyReqZLPHeEbz9WzEQqpvAsyyc=\r\n=qebt\r\n-----END PGP SIGNATURE-----\r\n","size":6572,"noattachment":false,"key":"/hpagent/-/hpagent-1.0.0.tgz"},"_npmUser":{"name":"delvedor","email":"tommydelved@gmail.com"},"directories":{},"maintainers":[{"name":"delvedor","email":"tommydelved@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/hpagent_1.0.0_1651510464576_0.5007921206038468"},"_hasShrinkwrap":false,"readme":"# hpagent\n\n[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](http://standardjs.com/)  ![build](https://github.com/delvedor/hpagent/workflows/build/badge.svg). ![npm](https://img.shields.io/npm/dm/hpagent)\n\nA ready to use http and https agent for working with proxies that keeps connections alive!\n\n## Install\n\n```\nnpm install hpagent\n```\n\n## Usage\n\nBased on your infrastructure, you should use the http agent or the https agent.\nThe following table will help you picking the right one.\n\n| Type              | Proxy  | Server |\n|-------------------|--------|--------|\n| `HttpProxyAgent`  | HTTP   | HTTP   |\n| `HttpProxyAgent`  | HTTPS  | HTTP   |\n| `HttpsProxyAgent` | HTTP   | HTTPS  |\n| `HttpsProxyAgent` | HTTPS  | HTTPS  |\n\n```js\nconst { HttpProxyAgent, HttpsProxyAgent } = require('hpagent')\n```\n\nOnce you have understood the right agent for your use case, you can instance it. It takes the same parameter of the Node.js core's http(s) agent and an additional `proxy` option, which is the url of your proxy.\n\n```js\nconst http = require('http')\nconst { HttpProxyAgent } = require('hpagent')\n\nconst agent = new HttpProxyAgent({\n  keepAlive: true,\n  keepAliveMsecs: 1000,\n  maxSockets: 256,\n  maxFreeSockets: 256,\n  proxy: 'http://localhost:8080'\n})\n\nhttp.get('http://localhost:9200', { agent })\n    .on('response', console.log)\n    .end()\n```\n\nIf your proxy requires basic authentication, you can configure it in the proxy url:\n\n```js\nconst http = require('http')\nconst { HttpProxyAgent } = require('hpagent')\n\nconst agent = new HttpProxyAgent({\n  keepAlive: true,\n  keepAliveMsecs: 1000,\n  maxSockets: 256,\n  maxFreeSockets: 256,\n  proxy: 'http://user:pwd@localhost:8080'\n})\n\nhttp.get('http://localhost:9200', { agent })\n    .on('response', console.log)\n    .end()\n```\n\nYou can also pass custom options intended only for the proxy CONNECT request with the `proxyConnectOptions` option,\nsuch as headers or `tls.connect()` options:\n\n```js\nconst fs = require('fs')\nconst http = require('http')\nconst { HttpProxyAgent } = require('hpagent')\n\nconst agent = new HttpProxyAgent({\n  keepAlive: true,\n  keepAliveMsecs: 1000,\n  maxSockets: 256,\n  maxFreeSockets: 256,\n  proxy: 'https://localhost:8080',\n  proxyConnectOptions: {\n    headers: {\n      'Proxy-Authorization': 'Basic YWxhZGRpbjpvcGVuc2VzYW1l',\n    },\n    ca: [ fs.readFileSync('custom-proxy-cert.pem') ]\n  }\n})\n\nhttp.get('http://localhost:9200', { agent })\n    .on('response', console.log)\n    .end()\n```\n\n## Integrations\n\nFollowing you can find the list of userland http libraries that are tested with this agent.\n\n### [got](https://github.com/sindresorhus/got)\n\n```js\ngot('http://localhost:9200', {\n  agent: {\n    http: new HttpProxyAgent({\n      keepAlive: true,\n      keepAliveMsecs: 1000,\n      maxSockets: 256,\n      maxFreeSockets: 256,\n      scheduling: 'lifo',\n      proxy: 'http://localhost:8080'\n    })\n  }\n})\n```\n\n### [needle](https://github.com/tomas/needle)\n\n```js\nneedle('get', 'http://localhost:9200', {\n  agent: new HttpProxyAgent({\n    keepAlive: true,\n    keepAliveMsecs: 1000,\n    maxSockets: 256,\n    maxFreeSockets: 256,\n    scheduling: 'lifo',\n    proxy: 'http://localhost:8080'\n  })\n})\n```\n\n### [node-fetch](https://github.com/node-fetch/node-fetch)\n\n```js\nfetch('http://localhost:9200', {\n  agent: new HttpProxyAgent({\n    keepAlive: true,\n    keepAliveMsecs: 1000,\n    maxSockets: 256,\n    maxFreeSockets: 256,\n    scheduling: 'lifo',\n    proxy: 'http://localhost:8080'\n  })\n})\n```\n\n### [simple-get](https://github.com/feross/simple-get)\n\n```js\nsget.concat({\n  url: `http://${server.address().address}:${server.address().port}`,\n  agent: new HttpProxyAgent({\n    keepAlive: true,\n    keepAliveMsecs: 1000,\n    maxSockets: 256,\n    maxFreeSockets: 256,\n    scheduling: 'lifo',\n    proxy: `https://${proxy.address().address}:${proxy.address().port}`\n  })\n}, function (err, response, data) {\n  // handle the response\n})\n```\n\n## License\n\nThis software is licensed under the [MIT](./LICENSE).\n","publish_time":1651510464763,"_cnpm_publish_time":1651510464763,"dist-tags":{"latest":"1.2.0"}}