Gathering detailed insights and metrics for hpagent
Gathering detailed insights and metrics for hpagent
A ready to use http and https agent for working with proxies that keeps connections alive!
npm install hpagent
Typescript
Module System
Min. Node Version
Node Version
NPM Version
98.3
Supply Chain
100
Quality
75.6
Maintenance
100
Vulnerability
100
License
JavaScript (98.61%)
TypeScript (1.24%)
Shell (0.15%)
Total Downloads
256,658,148
Last Day
461,244
Last Week
2,095,751
Last Month
9,272,872
Last Year
114,264,615
185 Stars
35 Commits
37 Forks
5 Watching
5 Branches
8 Contributors
Minified
Minified + Gzipped
Latest Version
1.2.0
Package Id
hpagent@1.2.0
Unpacked Size
72.14 kB
Size
7.54 kB
File Count
21
NPM Version
8.5.0
Node Version
16.14.2
Cumulative downloads
Total Downloads
Last day
-6.8%
461,244
Compared to previous day
Last week
-14.4%
2,095,751
Compared to previous week
Last month
4.5%
9,272,872
Compared to previous month
Last year
44.5%
114,264,615
Compared to previous year
8
A ready to use http and https agent for working with proxies that keeps connections alive!
npm install hpagent
Based on your infrastructure, you should use the http agent or the https agent. The following table will help you picking the right one.
Type | Proxy | Server |
---|---|---|
HttpProxyAgent | HTTP | HTTP |
HttpProxyAgent | HTTPS | HTTP |
HttpsProxyAgent | HTTP | HTTPS |
HttpsProxyAgent | HTTPS | HTTPS |
1const { HttpProxyAgent, HttpsProxyAgent } = require('hpagent')
Once 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.
1const http = require('http') 2const { HttpProxyAgent } = require('hpagent') 3 4const agent = new HttpProxyAgent({ 5 keepAlive: true, 6 keepAliveMsecs: 1000, 7 maxSockets: 256, 8 maxFreeSockets: 256, 9 proxy: 'http://localhost:8080' 10}) 11 12http.get('http://localhost:9200', { agent }) 13 .on('response', console.log) 14 .end()
If your proxy requires basic authentication, you can configure it in the proxy url:
1const http = require('http') 2const { HttpProxyAgent } = require('hpagent') 3 4const agent = new HttpProxyAgent({ 5 keepAlive: true, 6 keepAliveMsecs: 1000, 7 maxSockets: 256, 8 maxFreeSockets: 256, 9 proxy: 'http://user:pwd@localhost:8080' 10}) 11 12http.get('http://localhost:9200', { agent }) 13 .on('response', console.log) 14 .end()
You can also pass custom options intended only for the proxy CONNECT request with the proxyConnectOptions
option,
such as headers or tls.connect()
options:
1const fs = require('fs') 2const http = require('http') 3const { HttpProxyAgent } = require('hpagent') 4 5const agent = new HttpProxyAgent({ 6 keepAlive: true, 7 keepAliveMsecs: 1000, 8 maxSockets: 256, 9 maxFreeSockets: 256, 10 proxy: 'https://localhost:8080', 11 proxyConnectOptions: { 12 headers: { 13 'Proxy-Authorization': 'Basic YWxhZGRpbjpvcGVuc2VzYW1l', 14 }, 15 ca: [ fs.readFileSync('custom-proxy-cert.pem') ] 16 } 17}) 18 19http.get('http://localhost:9200', { agent }) 20 .on('response', console.log) 21 .end()
Following you can find the list of userland http libraries that are tested with this agent.
1got('http://localhost:9200', {
2 agent: {
3 http: new HttpProxyAgent({
4 keepAlive: true,
5 keepAliveMsecs: 1000,
6 maxSockets: 256,
7 maxFreeSockets: 256,
8 scheduling: 'lifo',
9 proxy: 'http://localhost:8080'
10 })
11 }
12})
1needle('get', 'http://localhost:9200', {
2 agent: new HttpProxyAgent({
3 keepAlive: true,
4 keepAliveMsecs: 1000,
5 maxSockets: 256,
6 maxFreeSockets: 256,
7 scheduling: 'lifo',
8 proxy: 'http://localhost:8080'
9 })
10})
1fetch('http://localhost:9200', {
2 agent: new HttpProxyAgent({
3 keepAlive: true,
4 keepAliveMsecs: 1000,
5 maxSockets: 256,
6 maxFreeSockets: 256,
7 scheduling: 'lifo',
8 proxy: 'http://localhost:8080'
9 })
10})
1sget.concat({
2 url: `http://${server.address().address}:${server.address().port}`,
3 agent: new HttpProxyAgent({
4 keepAlive: true,
5 keepAliveMsecs: 1000,
6 maxSockets: 256,
7 maxFreeSockets: 256,
8 scheduling: 'lifo',
9 proxy: `https://${proxy.address().address}:${proxy.address().port}`
10 })
11}, function (err, response, data) {
12 // handle the response
13})
This software is licensed under the MIT.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
Found 6/23 approved changesets -- score normalized to 2
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-01-27
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More