cdk-ecr-deployment 2.1.3 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.jsii +43 -23
- package/API.md +2 -0
- package/changelog.md +3 -3
- package/lambda/Dockerfile +2 -2
- package/lambda/go.mod +2 -0
- package/lambda/go.sum +4 -2
- package/lambda/install.js +11 -9
- package/lib/index.d.ts +11 -0
- package/lib/index.js +12 -8
- package/node_modules/hpagent/.github/dependabot.yml +8 -0
- package/node_modules/hpagent/.github/workflows/build.yml +29 -0
- package/node_modules/hpagent/LICENSE +21 -0
- package/node_modules/hpagent/README.md +138 -0
- package/node_modules/hpagent/index.d.ts +26 -0
- package/node_modules/hpagent/index.js +101 -0
- package/node_modules/hpagent/index.mjs +5 -0
- package/node_modules/hpagent/package.json +49 -0
- package/node_modules/hpagent/test/got.test.js +111 -0
- package/node_modules/hpagent/test/http-http.test.js +351 -0
- package/node_modules/hpagent/test/http-https.test.js +313 -0
- package/node_modules/hpagent/test/https-http.test.js +313 -0
- package/node_modules/hpagent/test/https-https.test.js +313 -0
- package/node_modules/hpagent/test/index.test-d.ts +45 -0
- package/node_modules/hpagent/test/needle.test.js +103 -0
- package/node_modules/hpagent/test/node-fetch.test.js +103 -0
- package/node_modules/hpagent/test/simple-get.test.js +139 -0
- package/node_modules/hpagent/test/ssl.cert +19 -0
- package/node_modules/hpagent/test/ssl.key +27 -0
- package/node_modules/hpagent/test/utils.js +59 -0
- package/package.json +5 -3
- package/releasetag.txt +1 -1
- package/version.txt +1 -1
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
# hpagent
|
|
2
|
+
|
|
3
|
+
[](http://standardjs.com/) 
|
|
4
|
+
|
|
5
|
+
A ready to use http and https agent for working with proxies that keeps connections alive!
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
npm install hpagent
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
Based on your infrastructure, you should use the http agent or the https agent.
|
|
16
|
+
The following table will help you picking the right one.
|
|
17
|
+
|
|
18
|
+
| Type | Proxy | Server |
|
|
19
|
+
|-------------------|--------|--------|
|
|
20
|
+
| `HttpProxyAgent` | HTTP | HTTP |
|
|
21
|
+
| `HttpProxyAgent` | HTTPS | HTTP |
|
|
22
|
+
| `HttpsProxyAgent` | HTTP | HTTPS |
|
|
23
|
+
| `HttpsProxyAgent` | HTTPS | HTTPS |
|
|
24
|
+
|
|
25
|
+
```js
|
|
26
|
+
const { HttpProxyAgent, HttpsProxyAgent } = require('hpagent')
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
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.
|
|
30
|
+
|
|
31
|
+
```js
|
|
32
|
+
const http = require('http')
|
|
33
|
+
const { HttpProxyAgent } = require('hpagent')
|
|
34
|
+
|
|
35
|
+
const agent = new HttpProxyAgent({
|
|
36
|
+
keepAlive: true,
|
|
37
|
+
keepAliveMsecs: 1000,
|
|
38
|
+
maxSockets: 256,
|
|
39
|
+
maxFreeSockets: 256,
|
|
40
|
+
proxy: 'http://localhost:8080'
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
http.get('http://localhost:9200', { agent })
|
|
44
|
+
.on('response', console.log)
|
|
45
|
+
.end()
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
If your proxy requires basic authentication, you can configure it in the proxy url:
|
|
49
|
+
|
|
50
|
+
```js
|
|
51
|
+
const http = require('http')
|
|
52
|
+
const { HttpProxyAgent } = require('hpagent')
|
|
53
|
+
|
|
54
|
+
const agent = new HttpProxyAgent({
|
|
55
|
+
keepAlive: true,
|
|
56
|
+
keepAliveMsecs: 1000,
|
|
57
|
+
maxSockets: 256,
|
|
58
|
+
maxFreeSockets: 256,
|
|
59
|
+
proxy: 'http://user:pwd@localhost:8080'
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
http.get('http://localhost:9200', { agent })
|
|
63
|
+
.on('response', console.log)
|
|
64
|
+
.end()
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Integrations
|
|
68
|
+
|
|
69
|
+
Following you can find the list of userland http libraries that are tested with this agent.
|
|
70
|
+
|
|
71
|
+
### [got](https://github.com/sindresorhus/got)
|
|
72
|
+
|
|
73
|
+
```js
|
|
74
|
+
got('http://localhost:9200', {
|
|
75
|
+
agent: {
|
|
76
|
+
http: new HttpProxyAgent({
|
|
77
|
+
keepAlive: true,
|
|
78
|
+
keepAliveMsecs: 1000,
|
|
79
|
+
maxSockets: 256,
|
|
80
|
+
maxFreeSockets: 256,
|
|
81
|
+
scheduling: 'lifo',
|
|
82
|
+
proxy: 'http://localhost:8080'
|
|
83
|
+
})
|
|
84
|
+
}
|
|
85
|
+
})
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### [needle](https://github.com/tomas/needle)
|
|
89
|
+
|
|
90
|
+
```js
|
|
91
|
+
needle('get', 'http://localhost:9200', {
|
|
92
|
+
agent: new HttpProxyAgent({
|
|
93
|
+
keepAlive: true,
|
|
94
|
+
keepAliveMsecs: 1000,
|
|
95
|
+
maxSockets: 256,
|
|
96
|
+
maxFreeSockets: 256,
|
|
97
|
+
scheduling: 'lifo',
|
|
98
|
+
proxy: 'http://localhost:8080'
|
|
99
|
+
})
|
|
100
|
+
})
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### [node-fetch](https://github.com/node-fetch/node-fetch)
|
|
104
|
+
|
|
105
|
+
```js
|
|
106
|
+
fetch('http://localhost:9200', {
|
|
107
|
+
agent: new HttpProxyAgent({
|
|
108
|
+
keepAlive: true,
|
|
109
|
+
keepAliveMsecs: 1000,
|
|
110
|
+
maxSockets: 256,
|
|
111
|
+
maxFreeSockets: 256,
|
|
112
|
+
scheduling: 'lifo',
|
|
113
|
+
proxy: 'http://localhost:8080'
|
|
114
|
+
})
|
|
115
|
+
})
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### [simple-get](https://github.com/feross/simple-get)
|
|
119
|
+
|
|
120
|
+
```js
|
|
121
|
+
sget.concat({
|
|
122
|
+
url: `http://${server.address().address}:${server.address().port}`,
|
|
123
|
+
agent: new HttpProxyAgent({
|
|
124
|
+
keepAlive: true,
|
|
125
|
+
keepAliveMsecs: 1000,
|
|
126
|
+
maxSockets: 256,
|
|
127
|
+
maxFreeSockets: 256,
|
|
128
|
+
scheduling: 'lifo',
|
|
129
|
+
proxy: `https://${proxy.address().address}:${proxy.address().port}`
|
|
130
|
+
})
|
|
131
|
+
}, function (err, response, data) {
|
|
132
|
+
// handle the response
|
|
133
|
+
})
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## License
|
|
137
|
+
|
|
138
|
+
This software is licensed under the [MIT](./LICENSE).
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import * as http from 'http'
|
|
2
|
+
import * as https from 'https'
|
|
3
|
+
import { URL } from 'url'
|
|
4
|
+
|
|
5
|
+
declare class HttpProxyAgent extends http.Agent {
|
|
6
|
+
constructor(options: HttpProxyAgentOptions)
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
interface HttpProxyAgentOptions extends http.AgentOptions {
|
|
10
|
+
proxy: string | URL
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
declare class HttpsProxyAgent extends https.Agent {
|
|
14
|
+
constructor(options: HttpsProxyAgentOptions)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
interface HttpsProxyAgentOptions extends https.AgentOptions {
|
|
18
|
+
proxy: string | URL
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export {
|
|
22
|
+
HttpProxyAgent,
|
|
23
|
+
HttpProxyAgentOptions,
|
|
24
|
+
HttpsProxyAgent,
|
|
25
|
+
HttpsProxyAgentOptions
|
|
26
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const https = require('https')
|
|
4
|
+
const http = require('http')
|
|
5
|
+
const { URL } = require('url')
|
|
6
|
+
|
|
7
|
+
class HttpProxyAgent extends http.Agent {
|
|
8
|
+
constructor (options) {
|
|
9
|
+
const { proxy, ...opts } = options
|
|
10
|
+
super(opts)
|
|
11
|
+
this.proxy = typeof proxy === 'string'
|
|
12
|
+
? new URL(proxy)
|
|
13
|
+
: proxy
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
createConnection (options, callback) {
|
|
17
|
+
const requestOptions = {
|
|
18
|
+
method: 'CONNECT',
|
|
19
|
+
host: this.proxy.hostname,
|
|
20
|
+
port: this.proxy.port,
|
|
21
|
+
path: `${options.host}:${options.port}`,
|
|
22
|
+
setHost: false,
|
|
23
|
+
headers: { connection: this.keepAlive ? 'keep-alive' : 'close', host: `${options.host}:${options.port}` },
|
|
24
|
+
agent: false
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (this.proxy.username || this.proxy.password) {
|
|
28
|
+
const base64 = Buffer.from(`${this.proxy.username || ''}:${this.proxy.password || ''}`).toString('base64')
|
|
29
|
+
requestOptions.headers['proxy-authorization'] = `Basic ${base64}`
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const request = (this.proxy.protocol === 'http:' ? http : https).request(requestOptions)
|
|
33
|
+
request.once('connect', (response, socket, head) => {
|
|
34
|
+
request.removeAllListeners()
|
|
35
|
+
socket.removeAllListeners()
|
|
36
|
+
if (response.statusCode === 200) {
|
|
37
|
+
callback(null, socket)
|
|
38
|
+
} else {
|
|
39
|
+
callback(new Error(`Bad response: ${response.statusCode}`), null)
|
|
40
|
+
}
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
request.once('error', err => {
|
|
44
|
+
request.removeAllListeners()
|
|
45
|
+
callback(err, null)
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
request.end()
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
class HttpsProxyAgent extends https.Agent {
|
|
53
|
+
constructor (options) {
|
|
54
|
+
const { proxy, ...opts } = options
|
|
55
|
+
super(opts)
|
|
56
|
+
this.proxy = typeof proxy === 'string'
|
|
57
|
+
? new URL(proxy)
|
|
58
|
+
: proxy
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
createConnection (options, callback) {
|
|
62
|
+
const requestOptions = {
|
|
63
|
+
method: 'CONNECT',
|
|
64
|
+
host: this.proxy.hostname,
|
|
65
|
+
port: this.proxy.port,
|
|
66
|
+
path: `${options.host}:${options.port}`,
|
|
67
|
+
setHost: false,
|
|
68
|
+
headers: { connection: this.keepAlive ? 'keep-alive' : 'close', host: `${options.host}:${options.port}` },
|
|
69
|
+
agent: false
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (this.proxy.username || this.proxy.password) {
|
|
73
|
+
const base64 = Buffer.from(`${this.proxy.username || ''}:${this.proxy.password || ''}`).toString('base64')
|
|
74
|
+
requestOptions.headers['proxy-authorization'] = `Basic ${base64}`
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const request = (this.proxy.protocol === 'http:' ? http : https).request(requestOptions)
|
|
78
|
+
request.once('connect', (response, socket, head) => {
|
|
79
|
+
request.removeAllListeners()
|
|
80
|
+
socket.removeAllListeners()
|
|
81
|
+
if (response.statusCode === 200) {
|
|
82
|
+
const secureSocket = super.createConnection({ ...options, socket })
|
|
83
|
+
callback(null, secureSocket)
|
|
84
|
+
} else {
|
|
85
|
+
callback(new Error(`Bad response: ${response.statusCode}`), null)
|
|
86
|
+
}
|
|
87
|
+
})
|
|
88
|
+
|
|
89
|
+
request.once('error', err => {
|
|
90
|
+
request.removeAllListeners()
|
|
91
|
+
callback(err, null)
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
request.end()
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
module.exports = {
|
|
99
|
+
HttpProxyAgent,
|
|
100
|
+
HttpsProxyAgent
|
|
101
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "hpagent",
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"description": "A ready to use http and https agent for working with proxies that keeps connections alive!",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"types": "index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"require": "./index.js",
|
|
10
|
+
"import": "./index.mjs"
|
|
11
|
+
},
|
|
12
|
+
"./": "./"
|
|
13
|
+
},
|
|
14
|
+
"scripts": {
|
|
15
|
+
"test": "standard && ava -v test/*.test.js && tsd"
|
|
16
|
+
},
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git+https://github.com/delvedor/hpagent.git"
|
|
20
|
+
},
|
|
21
|
+
"keywords": [
|
|
22
|
+
"agent",
|
|
23
|
+
"http",
|
|
24
|
+
"https",
|
|
25
|
+
"secure",
|
|
26
|
+
"proxy",
|
|
27
|
+
"alive",
|
|
28
|
+
"keep-alive"
|
|
29
|
+
],
|
|
30
|
+
"author": "Tomas Della Vedova",
|
|
31
|
+
"license": "MIT",
|
|
32
|
+
"bugs": {
|
|
33
|
+
"url": "https://github.com/delvedor/hpagent/issues"
|
|
34
|
+
},
|
|
35
|
+
"homepage": "https://github.com/delvedor/hpagent#readme",
|
|
36
|
+
"tsd": {
|
|
37
|
+
"directory": "test"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"ava": "^3.10.1",
|
|
41
|
+
"got": "^11.5.1",
|
|
42
|
+
"needle": "^2.5.0",
|
|
43
|
+
"node-fetch": "^2.6.0",
|
|
44
|
+
"proxy": "^1.0.2",
|
|
45
|
+
"simple-get": "^4.0.0",
|
|
46
|
+
"standard": "^16.0.1",
|
|
47
|
+
"tsd": "^0.13.1"
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const got = require('got')
|
|
4
|
+
const test = require('ava')
|
|
5
|
+
const {
|
|
6
|
+
createServer,
|
|
7
|
+
createSecureServer,
|
|
8
|
+
createProxy,
|
|
9
|
+
createSecureProxy
|
|
10
|
+
} = require('./utils')
|
|
11
|
+
const { HttpProxyAgent, HttpsProxyAgent } = require('../')
|
|
12
|
+
|
|
13
|
+
test('http to http', async t => {
|
|
14
|
+
const server = await createServer()
|
|
15
|
+
const proxy = await createProxy()
|
|
16
|
+
server.on('request', (req, res) => res.end('ok'))
|
|
17
|
+
|
|
18
|
+
const response = await got(`http://${server.address().address}:${server.address().port}`, {
|
|
19
|
+
agent: {
|
|
20
|
+
http: new HttpProxyAgent({
|
|
21
|
+
keepAlive: true,
|
|
22
|
+
keepAliveMsecs: 1000,
|
|
23
|
+
maxSockets: 256,
|
|
24
|
+
maxFreeSockets: 256,
|
|
25
|
+
scheduling: 'lifo',
|
|
26
|
+
proxy: `http://${proxy.address().address}:${proxy.address().port}`
|
|
27
|
+
})
|
|
28
|
+
}
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
t.is(response.body, 'ok')
|
|
32
|
+
t.is(response.statusCode, 200)
|
|
33
|
+
|
|
34
|
+
server.close()
|
|
35
|
+
proxy.close()
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
test('https to http', async t => {
|
|
39
|
+
const server = await createServer()
|
|
40
|
+
const proxy = await createSecureProxy()
|
|
41
|
+
server.on('request', (req, res) => res.end('ok'))
|
|
42
|
+
|
|
43
|
+
const response = await got(`http://${server.address().address}:${server.address().port}`, {
|
|
44
|
+
agent: {
|
|
45
|
+
http: new HttpProxyAgent({
|
|
46
|
+
keepAlive: true,
|
|
47
|
+
keepAliveMsecs: 1000,
|
|
48
|
+
maxSockets: 256,
|
|
49
|
+
maxFreeSockets: 256,
|
|
50
|
+
scheduling: 'lifo',
|
|
51
|
+
proxy: `https://${proxy.address().address}:${proxy.address().port}`
|
|
52
|
+
})
|
|
53
|
+
}
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
t.is(response.body, 'ok')
|
|
57
|
+
t.is(response.statusCode, 200)
|
|
58
|
+
|
|
59
|
+
server.close()
|
|
60
|
+
proxy.close()
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
test('http to https', async t => {
|
|
64
|
+
const server = await createSecureServer()
|
|
65
|
+
const proxy = await createProxy()
|
|
66
|
+
server.on('request', (req, res) => res.end('ok'))
|
|
67
|
+
|
|
68
|
+
const response = await got(`https://${server.address().address}:${server.address().port}`, {
|
|
69
|
+
agent: {
|
|
70
|
+
http: new HttpsProxyAgent({
|
|
71
|
+
keepAlive: true,
|
|
72
|
+
keepAliveMsecs: 1000,
|
|
73
|
+
maxSockets: 256,
|
|
74
|
+
maxFreeSockets: 256,
|
|
75
|
+
scheduling: 'lifo',
|
|
76
|
+
proxy: `http://${proxy.address().address}:${proxy.address().port}`
|
|
77
|
+
})
|
|
78
|
+
}
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
t.is(response.body, 'ok')
|
|
82
|
+
t.is(response.statusCode, 200)
|
|
83
|
+
|
|
84
|
+
server.close()
|
|
85
|
+
proxy.close()
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
test('https to https', async t => {
|
|
89
|
+
const server = await createSecureServer()
|
|
90
|
+
const proxy = await createSecureProxy()
|
|
91
|
+
server.on('request', (req, res) => res.end('ok'))
|
|
92
|
+
|
|
93
|
+
const response = await got(`https://${server.address().address}:${server.address().port}`, {
|
|
94
|
+
agent: {
|
|
95
|
+
http: new HttpsProxyAgent({
|
|
96
|
+
keepAlive: true,
|
|
97
|
+
keepAliveMsecs: 1000,
|
|
98
|
+
maxSockets: 256,
|
|
99
|
+
maxFreeSockets: 256,
|
|
100
|
+
scheduling: 'lifo',
|
|
101
|
+
proxy: `https://${proxy.address().address}:${proxy.address().port}`
|
|
102
|
+
})
|
|
103
|
+
}
|
|
104
|
+
})
|
|
105
|
+
|
|
106
|
+
t.is(response.body, 'ok')
|
|
107
|
+
t.is(response.statusCode, 200)
|
|
108
|
+
|
|
109
|
+
server.close()
|
|
110
|
+
proxy.close()
|
|
111
|
+
})
|