{"name":"hpagent","version":"0.1.2","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"},"./":"./"},"scripts":{"test":"standard && ava -v test/*.test.js && tsd"},"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":"^3.10.1","got":"^11.5.1","needle":"^2.5.0","node-fetch":"^2.6.0","proxy":"^1.0.2","simple-get":"^4.0.0","standard":"^16.0.1","tsd":"^0.13.1"},"gitHead":"ac3b00dcb12f39e3ae4bd81fa953759e1a40f1c6","_id":"hpagent@0.1.2","_nodeVersion":"14.15.1","_npmVersion":"6.14.8","dist":{"integrity":"sha512-ePqFXHtSQWAFXYmj+JtOTHr84iNrII4/QRlAAPPE+zqnKy4xJo7Ie1Y4kC7AdB+LxLxSTTzBMASsEcy0q8YyvQ==","shasum":"cab39c66d4df2d4377dbd212295d878deb9bdaa9","tarball":"http://registry-npm.ywwl.com/hpagent/download/hpagent-0.1.2.tgz","fileCount":20,"unpackedSize":55738,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg3Cr6CRA9TVsSAnZWagAA+eAQAISSt6b8l7ngzHYRq5QW\ngA92FBBJ4iduZIilJTlBao70q487lLLPFSc8azmaIejGk/LY0SPC7qIuDk3L\nQwmgklEixDHd9YsJ8M52NtmmfuowBXfXwPGQ52a8mSoFSfeQhzTAs55Iuf9V\ng+RnOAVX9VEmUQcDIMz6ognRA1+8u3Wu6o9+F3tmjEEotDKHIZaD0+ILDQLY\nyUJ+xXcWxNZohbiC54c4BYTScuIIkZBv3tTfXX/iPgpJvhS3Y3KeJSiHd2jm\nRO/8ToR5MRAzRBEVKDwVB4cZWo27mwC9mY+xz6+Fve4UtzqJ5NO6Fsx6X8tv\nGMl8dGcephQKh1FU51dshIL9uK6guYVedsgHJfR9PBumz1Fy9+6l4XtaXoEN\nDlIcGHWOwFLwMXwOzFcSZag2hlB+3E81x4lhs2/yQI+ujfEQZfYgmluLuVdL\nL8GGU1/X41kZ2CwgivlzI7qGL8hjL/YVbTdBFks+29YgpjQNV2TJXc1WycAP\nQ5gAQoh2J/FKZFINnboeJVtf4/6OCT9KaLe+8nerGJoUaRyxgx68ABMggAfX\nRzweENxlFozFaRpO9KKIUTsTkA9RuNPDV5PlRJGQKfCiAHxIGWaNINNhsJDQ\nEUA94lN4Eljlz1m5AHPZ/v+sguvB914v+XsdVEj+cNcGLVhbEG9Am8IOYDl6\nO1rw\r\n=9z69\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDfegQBvla9xv1b0+1TppaY+7zNvYea1DmndJofrarvoAiAbV4hDdXhkQD+0491A+JSa2CpSjne7QGOnmrIgZ8mqVA=="}],"size":8116,"noattachment":false,"key":"/hpagent/-/hpagent-0.1.2.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_0.1.2_1625041657935_0.45337638605946773"},"_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":1625041658069,"_cnpm_publish_time":1625041658069,"dist-tags":{"latest":"1.2.0"}}