reverse-proxy-middleware 0.0.16

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/LICENSE ADDED
@@ -0,0 +1,121 @@
1
+ Creative Commons Legal Code
2
+
3
+ CC0 1.0 Universal
4
+
5
+ CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
6
+ LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
7
+ ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
8
+ INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
9
+ REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
10
+ PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
11
+ THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
12
+ HEREUNDER.
13
+
14
+ Statement of Purpose
15
+
16
+ The laws of most jurisdictions throughout the world automatically confer
17
+ exclusive Copyright and Related Rights (defined below) upon the creator
18
+ and subsequent owner(s) (each and all, an "owner") of an original work of
19
+ authorship and/or a database (each, a "Work").
20
+
21
+ Certain owners wish to permanently relinquish those rights to a Work for
22
+ the purpose of contributing to a commons of creative, cultural and
23
+ scientific works ("Commons") that the public can reliably and without fear
24
+ of later claims of infringement build upon, modify, incorporate in other
25
+ works, reuse and redistribute as freely as possible in any form whatsoever
26
+ and for any purposes, including without limitation commercial purposes.
27
+ These owners may contribute to the Commons to promote the ideal of a free
28
+ culture and the further production of creative, cultural and scientific
29
+ works, or to gain reputation or greater distribution for their Work in
30
+ part through the use and efforts of others.
31
+
32
+ For these and/or other purposes and motivations, and without any
33
+ expectation of additional consideration or compensation, the person
34
+ associating CC0 with a Work (the "Affirmer"), to the extent that he or she
35
+ is an owner of Copyright and Related Rights in the Work, voluntarily
36
+ elects to apply CC0 to the Work and publicly distribute the Work under its
37
+ terms, with knowledge of his or her Copyright and Related Rights in the
38
+ Work and the meaning and intended legal effect of CC0 on those rights.
39
+
40
+ 1. Copyright and Related Rights. A Work made available under CC0 may be
41
+ protected by copyright and related or neighboring rights ("Copyright and
42
+ Related Rights"). Copyright and Related Rights include, but are not
43
+ limited to, the following:
44
+
45
+ i. the right to reproduce, adapt, distribute, perform, display,
46
+ communicate, and translate a Work;
47
+ ii. moral rights retained by the original author(s) and/or performer(s);
48
+ iii. publicity and privacy rights pertaining to a person's image or
49
+ likeness depicted in a Work;
50
+ iv. rights protecting against unfair competition in regards to a Work,
51
+ subject to the limitations in paragraph 4(a), below;
52
+ v. rights protecting the extraction, dissemination, use and reuse of data
53
+ in a Work;
54
+ vi. database rights (such as those arising under Directive 96/9/EC of the
55
+ European Parliament and of the Council of 11 March 1996 on the legal
56
+ protection of databases, and under any national implementation
57
+ thereof, including any amended or successor version of such
58
+ directive); and
59
+ vii. other similar, equivalent or corresponding rights throughout the
60
+ world based on applicable law or treaty, and any national
61
+ implementations thereof.
62
+
63
+ 2. Waiver. To the greatest extent permitted by, but not in contravention
64
+ of, applicable law, Affirmer hereby overtly, fully, permanently,
65
+ irrevocably and unconditionally waives, abandons, and surrenders all of
66
+ Affirmer's Copyright and Related Rights and associated claims and causes
67
+ of action, whether now known or unknown (including existing as well as
68
+ future claims and causes of action), in the Work (i) in all territories
69
+ worldwide, (ii) for the maximum duration provided by applicable law or
70
+ treaty (including future time extensions), (iii) in any current or future
71
+ medium and for any number of copies, and (iv) for any purpose whatsoever,
72
+ including without limitation commercial, advertising or promotional
73
+ purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
74
+ member of the public at large and to the detriment of Affirmer's heirs and
75
+ successors, fully intending that such Waiver shall not be subject to
76
+ revocation, rescission, cancellation, termination, or any other legal or
77
+ equitable action to disrupt the quiet enjoyment of the Work by the public
78
+ as contemplated by Affirmer's express Statement of Purpose.
79
+
80
+ 3. Public License Fallback. Should any part of the Waiver for any reason
81
+ be judged legally invalid or ineffective under applicable law, then the
82
+ Waiver shall be preserved to the maximum extent permitted taking into
83
+ account Affirmer's express Statement of Purpose. In addition, to the
84
+ extent the Waiver is so judged Affirmer hereby grants to each affected
85
+ person a royalty-free, non transferable, non sublicensable, non exclusive,
86
+ irrevocable and unconditional license to exercise Affirmer's Copyright and
87
+ Related Rights in the Work (i) in all territories worldwide, (ii) for the
88
+ maximum duration provided by applicable law or treaty (including future
89
+ time extensions), (iii) in any current or future medium and for any number
90
+ of copies, and (iv) for any purpose whatsoever, including without
91
+ limitation commercial, advertising or promotional purposes (the
92
+ "License"). The License shall be deemed effective as of the date CC0 was
93
+ applied by Affirmer to the Work. Should any part of the License for any
94
+ reason be judged legally invalid or ineffective under applicable law, such
95
+ partial invalidity or ineffectiveness shall not invalidate the remainder
96
+ of the License, and in such case Affirmer hereby affirms that he or she
97
+ will not (i) exercise any of his or her remaining Copyright and Related
98
+ Rights in the Work or (ii) assert any associated claims and causes of
99
+ action with respect to the Work, in either case contrary to Affirmer's
100
+ express Statement of Purpose.
101
+
102
+ 4. Limitations and Disclaimers.
103
+
104
+ a. No trademark or patent rights held by Affirmer are waived, abandoned,
105
+ surrendered, licensed or otherwise affected by this document.
106
+ b. Affirmer offers the Work as-is and makes no representations or
107
+ warranties of any kind concerning the Work, express, implied,
108
+ statutory or otherwise, including without limitation warranties of
109
+ title, merchantability, fitness for a particular purpose, non
110
+ infringement, or the absence of latent or other defects, accuracy, or
111
+ the present or absence of errors, whether or not discoverable, all to
112
+ the greatest extent permissible under applicable law.
113
+ c. Affirmer disclaims responsibility for clearing rights of other persons
114
+ that may apply to the Work or any use thereof, including without
115
+ limitation any person's Copyright and Related Rights in the Work.
116
+ Further, Affirmer disclaims responsibility for obtaining any necessary
117
+ consents, permissions or other rights required for any use of the
118
+ Work.
119
+ d. Affirmer understands and acknowledges that Creative Commons is not a
120
+ party to this document and has no duty or obligation with respect to
121
+ this CC0 or use of the Work.
package/index.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ import { Server } from './type';
2
+ declare const server: Server;
3
+ export default server;
package/index.js ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ // -*- coding: utf-8 -*-
3
+ 'use strict';if(typeof module!=='undefined'&&module!==null&&eval('typeof require')!=='undefined'&&eval('require')!==null&&'main'in eval('require')&&eval('typeof require.main')!=='undefined'&&eval('require.main')!==null){var ORIGINAL_MAIN_MODULE=module;if(module!==eval('require.main')&&'paths'in module&&'paths'in eval('require.main')&&typeof __dirname!=='undefined'&&__dirname!==null)module.paths=eval('require.main.paths').concat(module.paths.filter(function(path){return eval('require.main.paths').includes(path)}))};if(module===eval('require.main'))module.paths.unshift('/application/node_modules');(()=>{"use strict";var __webpack_modules__=[(module,__webpack_exports__,__webpack_require__)=>{__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{default:()=>__WEBPACK_DEFAULT_EXPORT__});var _babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(1),_babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default=__webpack_require__.n(_babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0__),_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(2),_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default=__webpack_require__.n(_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1__),_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2__=__webpack_require__(3),_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default=__webpack_require__.n(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2__),clientnode__WEBPACK_IMPORTED_MODULE_3__=__webpack_require__(4),clientnode__WEBPACK_IMPORTED_MODULE_3___default=__webpack_require__.n(clientnode__WEBPACK_IMPORTED_MODULE_3__),http__WEBPACK_IMPORTED_MODULE_4__=__webpack_require__(5),http__WEBPACK_IMPORTED_MODULE_4___default=__webpack_require__.n(http__WEBPACK_IMPORTED_MODULE_4__),http2__WEBPACK_IMPORTED_MODULE_5__=__webpack_require__(6),http2__WEBPACK_IMPORTED_MODULE_5___default=__webpack_require__.n(http2__WEBPACK_IMPORTED_MODULE_5__),net__WEBPACK_IMPORTED_MODULE_6__=__webpack_require__(7),net__WEBPACK_IMPORTED_MODULE_6___default=__webpack_require__.n(net__WEBPACK_IMPORTED_MODULE_6__),path__WEBPACK_IMPORTED_MODULE_7__=__webpack_require__(8),path__WEBPACK_IMPORTED_MODULE_7___default=__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_7__),tls__WEBPACK_IMPORTED_MODULE_8__=__webpack_require__(9),tls__WEBPACK_IMPORTED_MODULE_8___default=__webpack_require__.n(tls__WEBPACK_IMPORTED_MODULE_8__),_package_json__WEBPACK_IMPORTED_MODULE_9__=__webpack_require__(10);function _createForOfIteratorHelperLoose(e,r){var _="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(_)return(_=_.call(e)).next.bind(_);if(Array.isArray(e)||(_=_unsupportedIterableToArray(e))||r&&e&&"number"==typeof e.length){_&&(e=_);var t=0;return function(){return t>=e.length?{done:!0}:{done:!1,value:e[t++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(e,r){if(e){if("string"==typeof e)return _arrayLikeToArray(e,r);var _=Object.prototype.toString.call(e).slice(8,-1);return"Object"===_&&e.constructor&&(_=e.constructor.name),"Map"===_||"Set"===_?Array.from(e):"Arguments"===_||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(_)?_arrayLikeToArray(e,r):void 0}}function _arrayLikeToArray(e,r){(null==r||r>e.length)&&(r=e.length);for(var _=0,t=Array(r);_<r;_++)t[_]=e[_];return t}module=__webpack_require__.hmd(module);for(var CONFIGURATION=_package_json__WEBPACK_IMPORTED_MODULE_9__.DN,_i=0,_arr=["configuration.json","secure-configuration.json"];_i<_arr.length;_i++){var path=_arr[_i],configurationPath=(0,path__WEBPACK_IMPORTED_MODULE_7__.resolve)(process.cwd(),path);clientnode__WEBPACK_IMPORTED_MODULE_3___default().isFileSync(configurationPath)&&clientnode__WEBPACK_IMPORTED_MODULE_3___default().extend(!0,CONFIGURATION,clientnode__WEBPACK_IMPORTED_MODULE_3___default().evaluateDynamicData(eval("require('"+configurationPath+"')"),{configuration:CONFIGURATION,environment:process.env,Tools:clientnode__WEBPACK_IMPORTED_MODULE_3___default()}))}for(var APPLICATION_INTERFACES={},_i2=0,_Object$entries=Object.entries(CONFIGURATION.humanChecker.applicationInterfaces);_i2<_Object$entries.length;_i2++){var _Object$entries$_i=_Object$entries[_i2],name=_Object$entries$_i[0],checker=_Object$entries$_i[1];"base"!==name&&(APPLICATION_INTERFACES[name]=clientnode__WEBPACK_IMPORTED_MODULE_3___default().extend(!0,{},CONFIGURATION.humanChecker.applicationInterfaces.base,checker))}for(var FORWARDER={},_i3=0,_Object$entries2=Object.entries(CONFIGURATION.forwarder);_i3<_Object$entries2.length;_i3++){var _Object$entries2$_i=_Object$entries2[_i3],_name=_Object$entries2$_i[0],forwarder=_Object$entries2$_i[1];"base"!==_name&&(FORWARDER[_name]=clientnode__WEBPACK_IMPORTED_MODULE_3___default().extend(!0,{},CONFIGURATION.forwarder.base,forwarder))}var determineForwarder=function(e){for(var r=0,_=Object.entries(FORWARDER);r<_.length;r++){var t=_[r],n=t[0],o=t[1];if(o.identifier&&"string"==typeof o.identifier&&e.url===o.identifier||o.identifier instanceof RegExp&&o.identifier.test(e.url))return console.info('Determined forwarder "'+n+'."'),o}return null},hasSkipSecret=function(e){return"true"===e.headers["reverse-proxy-middleware-skip"]&&!!e.headers["reverse-proxy-middleware-skip-secret"]&&CONFIGURATION.humanChecker.skipSecrets.includes([].concat(e.headers["reverse-proxy-middleware-skip-secret"])[0])},isValid=function(){var e=_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().mark((function e(r){var _,t,n,o,a,i,s,c,u;return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!hasSkipSecret(r)){e.next=2;break}return e.abrupt("return",!0);case 2:_=0,t=Object.entries(APPLICATION_INTERFACES);case 3:if(!(_<t.length)){e.next=35;break}if(n=t[_],o=n[0],a=n[1],!(i=[].concat(r.headers[a.headerName])[0])){e.next=32;break}if(!(s=clientnode__WEBPACK_IMPORTED_MODULE_3___default().stringEvaluate("`"+a.url+"`",{clientToken:i.substring(i.indexOf(" ")+1),secret:a.secret})).error){e.next=11;break}return console.error("Error while evaluation checker url:",s.error),e.abrupt("continue",32);case 11:return c=s.result,e.prev=12,e.next=15,fetch(c,a.options);case 15:return e.next=17,e.sent.json();case 17:if(!((u=e.sent).success||"number"==typeof u.score&&u.score>=a.score)){e.next=21;break}return console.info('Request "'+c+'" ('+o+") identified as human triggered."),e.abrupt("return",!0);case 21:return console.info('Request "'+c+'" ('+o+") identified as robot triggered:",u),e.abrupt("return",!1);case 25:if(e.prev=25,e.t0=e.catch(12),console.warn('Request to "'+c+'" ('+o+") couldn't be identified asrobot or human because the recaptcha service produces the following error:",e.t0),!a.identifiyAsHumanIfServiceThrowsException){e.next=31;break}return console.info("Request will be interpret as human triggered causedby fallback configuration."),e.abrupt("return",!0);case 31:return e.abrupt("return",null);case 32:_++,e.next=3;break;case 35:return e.abrupt("return",0===Object.keys(APPLICATION_INTERFACES).length);case 36:case"end":return e.stop()}}),e,null,[[12,25]])})));return function(){return e.apply(this,arguments)}}(),reverseProxyBufferedRequest=function(e,r,_){var t=_.tls?tls__WEBPACK_IMPORTED_MODULE_8__.connect:net__WEBPACK_IMPORTED_MODULE_6__.createConnection,n=_.tls&&443!==_.port||!_.tls&&80!==_.port?":"+_.port:"",o=t(_babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default()({host:CONFIGURATION.forward.host,port:CONFIGURATION.forward.port},CONFIGURATION.forward.tls?{servername:CONFIGURATION.forward.host,rejectUnauthorized:!1}:{}),(function(){console.info("Proxy to: http"+(CONFIGURATION.forward.tls?"s":"")+"://"+CONFIGURATION.forward.host+n)}));if(o.on("error",(function(e){console.error("Proxy to server error",e)})),CONFIGURATION.forward.headerTransformation.retrieve.length){var a=!1;o.on("data",(function(r){if(a)e.write(r);else{for(var _,t,n=r.toString(),o=_createForOfIteratorHelperLoose(CONFIGURATION.forward.headerTransformation.retrieve);!(_=o()).done;)t=_.value,n=n.replace(t.source,t.target);e.write(n),a=!0}}))}else o.pipe(e);o.on("connect",(function(){for(var e,_,t=!1,a=_createForOfIteratorHelperLoose(r);!(e=a()).done;)if(_=e.value,t)o.write(_);else{var i=_.toString();CONFIGURATION.forward.tls&&(i=i.replace(/HTTP\/1\.0/i,"HTTP/1.1")),i=i.replace(/(($|\n)host: )[^\n]+/i,"$1"+CONFIGURATION.forward.host+n);for(var s,c,u=_createForOfIteratorHelperLoose(CONFIGURATION.forward.headerTransformation.send);!(s=u()).done;)c=s.value,i=i.replace(c.source,c.target);console.info("Send:\n\n"+i),o.write(i),t=!0}}))},onIncomingMessage=function(e,r){_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().mark((function _(){var t,n;return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().wrap((function(_){for(;;)switch(_.prev=_.next){case 0:return _.next=2,isValid(e);case 2:if(null!==(t=_.sent)){_.next=7;break}return r.statusCode=502,r.end(),_.abrupt("return");case 7:if(!t){_.next=13;break}return _.next=10,clientnode__WEBPACK_IMPORTED_MODULE_3___default().timeout();case 10:return(n=determineForwarder(e))?reverseProxyBufferedRequest(r.socket,e.socket.buffers,n):(console.error("No forwarder found for given request:",e),r.statusCode=502,r.end()),_.abrupt("return");case 13:r.statusCode=CONFIGURATION.humanChecker.botDetectionStatusCode,r.end();case 15:case"end":return _.stop()}}),_)})))()},onIncomingStream=function(e,r){console.info("Got stream",e,r)},server={instance:CONFIGURATION.publicKeyPath&&CONFIGURATION.privateKeyPath?(0,http2__WEBPACK_IMPORTED_MODULE_5__.createSecureServer)(CONFIGURATION.nodeServerOptions,onIncomingMessage):(0,http__WEBPACK_IMPORTED_MODULE_4__.createServer)(onIncomingMessage),streams:[],sockets:[],start:function(){server.instance.listen(CONFIGURATION.port,(function(){return console.info("Listen on port "+CONFIGURATION.port+" for incoming requests.")}))},stop:function(){server.instance.close((function(){console.info("Shut server down.")}));for(var e,r=0,_=[server.sockets,server.streams];r<_.length;r++)if(e=_[r],Array.isArray(e))for(var t,n=_createForOfIteratorHelperLoose(e);!(t=n()).done;)t.value.destroy()}};if(server.instance.on("connection",(function(e){var r=[];e.on("data",(function(e){r.push(e)})),e.buffers=r,server.sockets.push(e),e.on("close",(function(){server.sockets.splice(server.sockets.indexOf(e),1)}))})),server.instance.on("stream",(function(e,r){server.streams.push(e),onIncomingStream(e,r),e.on("close",(function(){server.streams.splice(server.streams.indexOf(e),1)}))})),__webpack_require__.c[__webpack_require__.s]===module||eval("require.main")!==__webpack_require__.c[__webpack_require__.s]){console.info("Start server with configuration:",clientnode__WEBPACK_IMPORTED_MODULE_3___default().represent(CONFIGURATION)),server.start();for(var _step5,_loop=function(){var e=_step5.value;process.on(e,(function(){console.info('\nGot "'+e+'" signal: stopping server.'),server.stop()}))},_iterator5=_createForOfIteratorHelperLoose(clientnode__WEBPACK_IMPORTED_MODULE_3__.CloseEventNames);!(_step5=_iterator5()).done;)_loop()}const __WEBPACK_DEFAULT_EXPORT__=server},e=>{e.exports=require("@babel/runtime/helpers/extends")},e=>{e.exports=require("@babel/runtime/helpers/asyncToGenerator")},e=>{e.exports=require("@babel/runtime/regenerator")},e=>{e.exports=require("clientnode")},e=>{e.exports=require("http")},e=>{e.exports=require("http2")},e=>{e.exports=require("net")},e=>{e.exports=require("path")},e=>{e.exports=require("tls")},e=>{e.exports=JSON.parse('{"DN":{"publicKeyPath":"","privateKeyPath":"","nodeServerOptions":{"allowHTTP1":true},"host":"localhost","port":8080,"forward":{"base":{"headerTransformation":{"retrieve":[],"send":[]},"host":"localhost","identifier":"","port":443,"stateAPIs":[{"name":"base","data":{},"options":{},"preExpression":"false","postExpression":"true","resultExpression":"","skipSecret":[],"url":""}],"tls":true}}}}')}],__webpack_module_cache__={};function __webpack_require__(e){var r=__webpack_module_cache__[e];if(void 0!==r)return r.exports;var _=__webpack_module_cache__[e]={id:e,loaded:!1,exports:{}};return __webpack_modules__[e](_,_.exports,__webpack_require__),_.loaded=!0,_.exports}__webpack_require__.c=__webpack_module_cache__,__webpack_require__.n=e=>{var r=e&&e.__esModule?()=>e.default:()=>e;return __webpack_require__.d(r,{a:r}),r},__webpack_require__.d=(e,r)=>{for(var _ in r)__webpack_require__.o(r,_)&&!__webpack_require__.o(e,_)&&Object.defineProperty(e,_,{enumerable:!0,get:r[_]})},__webpack_require__.hmd=e=>((e=Object.create(e)).children||(e.children=[]),Object.defineProperty(e,"exports",{enumerable:!0,set:()=>{throw new Error("ES Modules may not assign module.exports or exports.*, Use ESM export syntax, instead: "+e.id)}}),e),__webpack_require__.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),__webpack_require__.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var __webpack_exports__=__webpack_require__(__webpack_require__.s=0);module.exports=__webpack_exports__})();
package/package.json ADDED
@@ -0,0 +1,145 @@
1
+ {
2
+ "name": "reverse-proxy-middleware",
3
+ "version": "0.0.16",
4
+ "description": "A reverse proxy blocking bot requests.",
5
+ "keywords": [
6
+ "api",
7
+ "backend",
8
+ "bot-blocker",
9
+ "middleware",
10
+ "proxy",
11
+ "reverse-proxy",
12
+ "web"
13
+ ],
14
+ "homepage": "https://torben.website/reverse-proxy-middleware",
15
+ "bugs": {
16
+ "email": "info@torben.website",
17
+ "url": "https://github.com/thaibault/reverse-proxy-middleware/issues"
18
+ },
19
+ "license": "CC-BY-3.0",
20
+ "author": {
21
+ "name": "Torben Sickert",
22
+ "email": "info@torben.website",
23
+ "url": "https://torben.website"
24
+ },
25
+ "files": [
26
+ "index.d.ts",
27
+ "index.js",
28
+ "type.d.ts"
29
+ ],
30
+ "bin": {
31
+ "reverse-proxy-middleware": "index.js"
32
+ },
33
+ "repository": {
34
+ "type": "git",
35
+ "url": "https://github.com/thaibault/reverse-proxy-middleware.git"
36
+ },
37
+ "scripts": {
38
+ "build": "yarn build:types; yarn build:plain",
39
+ "build:plain": "weboptimizer build",
40
+ "build:types": "weboptimizer build:types",
41
+ "check": "yarn check:types; yarn lint",
42
+ "check:types": "weboptimizer check:types",
43
+ "clear": "weboptimizer clear",
44
+ "document": "weboptimizer document",
45
+ "lint": "weboptimizer lint",
46
+ "postversion": "yarn publish --non-interactive; git push --tags && git push",
47
+ "prepare": "yarn build",
48
+ "serve": "weboptimizer build && yarn start",
49
+ "start": "./index.js",
50
+ "update": "yarn version --patch",
51
+ "update:documentation": "documentation-website",
52
+ "watch": "weboptimizer build --watch"
53
+ },
54
+ "runkitExample": "require('@babel/runtime/package.json')\n",
55
+ "dependencies": {
56
+ "@babel/runtime": "*"
57
+ },
58
+ "devDependencies": {
59
+ "@babel/cli": "*",
60
+ "@babel/eslint-parser": "*",
61
+ "@types/node": "*",
62
+ "@typescript-eslint/eslint-plugin": "*",
63
+ "@typescript-eslint/parser": "*",
64
+ "clientnode": "*",
65
+ "documentation-website": "*",
66
+ "eslint": "*",
67
+ "eslint-config-google": "*",
68
+ "eslint-plugin-jsdoc": "*",
69
+ "jsdoc": "*",
70
+ "weboptimizer": "*"
71
+ },
72
+ "engines": {
73
+ "node": ">=17",
74
+ "npm": ">=7"
75
+ },
76
+ "resolutions": {
77
+ "@types/webpack": "https://registry.yarnpkg.com/@favware/skip-dependency/-/skip-dependency-1.1.1.tgz",
78
+ "colors": "1.4.0"
79
+ },
80
+ "sideEffects": true,
81
+ "documentationWebsite": {
82
+ "name": "reverse-proxy-middleware",
83
+ "trackingCode": ""
84
+ },
85
+ "configuration": {
86
+ "publicKeyPath": "",
87
+ "privateKeyPath": "",
88
+ "nodeServerOptions": {
89
+ "allowHTTP1": true
90
+ },
91
+ "host": "localhost",
92
+ "port": 8080,
93
+ "forward": {
94
+ "base": {
95
+ "headerTransformation": {
96
+ "retrieve": [],
97
+ "send": []
98
+ },
99
+ "host": "localhost",
100
+ "identifier": "",
101
+ "port": 443,
102
+ "stateAPIs": [
103
+ {
104
+ "name": "base",
105
+ "data": {},
106
+ "options": {},
107
+ "preExpression": "false",
108
+ "postExpression": "true",
109
+ "resultExpression": "",
110
+ "skipSecret": [],
111
+ "url": ""
112
+ }
113
+ ],
114
+ "tls": true
115
+ }
116
+ }
117
+ },
118
+ "webOptimizer": {
119
+ "assetPattern": {
120
+ "javaScript": {
121
+ "includeFilePathRegularExpression": "^(.+/)?index\\.js$",
122
+ "pattern": {
123
+ "#": "This is how we can make our main exported artefact executable.",
124
+ "__evaluate__": "`#!/usr/bin/env node\n// -*- coding: utf-8 -*-\n${self.generic.assetPattern.javaScript.pattern}if(module===eval('require.main'))module.paths.unshift('/application/node_modules');{1}`"
125
+ }
126
+ }
127
+ },
128
+ "exportFormat": {
129
+ "external": "commonjs2",
130
+ "self": "commonjs2"
131
+ },
132
+ "module": {
133
+ "optimizer": {
134
+ "babelMinify": {
135
+ "#": "To provide a logging output we need to exclude this feature.",
136
+ "__evaluate__": "self.debug ? {bundle: null, module: null} : {bundle: {transform: {removeConsole: false}}, module: {removeConsole: false}}"
137
+ }
138
+ }
139
+ },
140
+ "targetTechnology": {
141
+ "boilerplate": "node",
142
+ "payload": "node"
143
+ }
144
+ }
145
+ }
package/readme.md ADDED
@@ -0,0 +1,36 @@
1
+ <!-- !/usr/bin/env markdown
2
+ -*- coding: utf-8 -*-
3
+ region header
4
+ Copyright Torben Sickert (info["~at~"]torben.website) 16.12.2012
5
+
6
+ License
7
+ -------
8
+
9
+ This library written by Torben Sickert stand under a creative commons naming
10
+ 3.0 unported license. See https://creativecommons.org/licenses/by/3.0/deed.de
11
+ endregion -->
12
+
13
+ Project status
14
+ --------------
15
+
16
+ [![npm](https://img.shields.io/npm/v/reverse-proxy-middleware?color=%23d55e5d&label=npm%20package%20version&logoColor=%23d55e5d)](https://www.npmjs.com/package/reverse-proxy-middleware)
17
+ [![npm downloads](https://img.shields.io/npm/dy/reverse-proxy-middleware.svg)](https://www.npmjs.com/package/reverse-proxy-middleware)
18
+
19
+ [![<LABEL>](https://github.com/thaibault/reverse-proxy-middleware/actions/workflows/build.yaml/badge.svg)](https://github.com/thaibault/reverse-proxy-middleware/actions/workflows/build.yaml)
20
+ [![<LABEL>](https://github.com/thaibault/reverse-proxy-middleware/actions/workflows/check-types.yaml/badge.svg)](https://github.com/thaibault/reverse-proxy-middleware/actions/workflows/check-types.yaml)
21
+ [![<LABEL>](https://github.com/thaibault/web-node/actions/workflows/lint.yaml/badge.svg)](https://github.com/thaibault/web-node/actions/workflows/lint.yaml)
22
+ [![<LABEL>](https://github.com/thaibault/reverse-proxy-middleware/actions/workflows/build-image-periodically-2-branches.yaml/badge.svg)](https://github.com/thaibault/reverse-proxy-middleware/actions/workflows/build-image-periodically-2-branches.yaml)
23
+
24
+ [![documentation website](https://img.shields.io/website-up-down-green-red/http/torben.website/reverse-proxy-middleware.svg?label=documentation-website)](http://torben.website/reverse-proxy-middleware)
25
+
26
+ Use case
27
+ --------
28
+
29
+ ```JavaScript
30
+ TODO
31
+ ```
32
+
33
+ <!-- region modline
34
+ vim: set tabstop=4 shiftwidth=4 expandtab:
35
+ vim: foldmethod=marker foldmarker=region,endregion:
36
+ endregion -->
package/type.d.ts ADDED
@@ -0,0 +1,70 @@
1
+ /// <reference types="node" />
2
+ /// <reference types="node" />
3
+ /// <reference types="node" />
4
+ /// <reference types="node" />
5
+ import { Http2SecureServer as HTTPSecureServer, Http2Server as HttpServer, Http2ServerRequest as HTTPServerRequest, Http2Stream as HTTPStream, SecureServerOptions } from 'http2';
6
+ import { Socket as PlainSocket } from 'net';
7
+ import { TLSSocket } from 'tls';
8
+ export interface APIConfiguration {
9
+ headerName: string;
10
+ identifiyAsHumanIfServiceThrowsException: boolean;
11
+ secret: string;
12
+ score: number;
13
+ options: RequestInit;
14
+ url: string;
15
+ }
16
+ export type APIConfigurations = {
17
+ base: APIConfiguration;
18
+ [key: string]: Partial<APIConfiguration>;
19
+ };
20
+ export type ResolvedAPIConfigurations = {
21
+ [key: string]: APIConfiguration;
22
+ };
23
+ export type Socket = PlainSocket | TLSSocket;
24
+ export type BufferedSocket = Socket & {
25
+ buffers: Array<Buffer>;
26
+ };
27
+ export interface BufferedHTTPServerRequest extends HTTPServerRequest {
28
+ socket: BufferedSocket;
29
+ }
30
+ export interface HeaderTransformation {
31
+ source: string | RegExp;
32
+ target: string | ((substring: string, ...parameters: Array<unknown>) => string);
33
+ }
34
+ export interface Forwarder {
35
+ headerTransformation: {
36
+ retrieve: Array<HeaderTransformation>;
37
+ send: Array<HeaderTransformation>;
38
+ };
39
+ host: string;
40
+ identifier: RegExp | string;
41
+ port: number;
42
+ tls: boolean;
43
+ }
44
+ export type ResolvedForwarder = {
45
+ [key: string]: Forwarder;
46
+ };
47
+ export interface Configuration {
48
+ publicKeyPath: string;
49
+ privateKeyPath: string;
50
+ nodeServerOptions: SecureServerOptions;
51
+ host: string;
52
+ port: number;
53
+ forwarder: {
54
+ base: Forwarder;
55
+ [key: string]: Partial<Forwarder>;
56
+ };
57
+ humanChecker: {
58
+ applicationInterfaces: APIConfigurations;
59
+ botDetectionStatusCode: number;
60
+ skipSecrets: Array<string>;
61
+ };
62
+ }
63
+ export type HTTPServer = HttpServer | HTTPSecureServer;
64
+ export interface Server {
65
+ instance: HTTPServer;
66
+ streams: Array<HTTPStream>;
67
+ sockets: Array<Socket>;
68
+ start: () => void;
69
+ stop: () => void;
70
+ }