@ffflorian/https-proxy 1.5.0 → 1.5.2

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/HttpsProxy.js CHANGED
@@ -1,11 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HttpsProxy = void 0;
3
4
  const basicAuth = require("basic-auth");
4
5
  const http = require("http");
5
6
  const logdown = require("logdown");
6
7
  const net = require("net");
7
8
  const compare = require("tsscmp");
8
9
  const url = require("url");
10
+ const http_status_codes_1 = require("http-status-codes");
9
11
  const defaultOptions = {
10
12
  password: '',
11
13
  port: 8080,
@@ -19,13 +21,13 @@ class HttpsProxy {
19
21
  const authorizationHeader = req.headers['proxy-authorization'];
20
22
  if (this.authenticationEnabled) {
21
23
  if (!authorizationHeader) {
22
- clientSocket.write(this.getClosingProxyMessage(407, 'Proxy Authentication Required'));
24
+ clientSocket.write(this.getClosingProxyMessage(http_status_codes_1.StatusCodes.PROXY_AUTHENTICATION_REQUIRED, 'Proxy Authentication Required'));
23
25
  clientSocket.end('\r\n\r\n');
24
26
  this.logger.warn(`Responded to proxy request from "${clientSocket.remoteAddress}" with authorization request`);
25
27
  return;
26
28
  }
27
29
  if (!this.validateAuthorization(authorizationHeader)) {
28
- clientSocket.write(this.getClosingProxyMessage(401, 'Unauthorized'));
30
+ clientSocket.write(this.getClosingProxyMessage(http_status_codes_1.StatusCodes.UNAUTHORIZED, 'Unauthorized'));
29
31
  clientSocket.end('\r\n\r\n');
30
32
  this.logger.warn(`Rejected proxy request with invalid authorization from "${clientSocket.remoteAddress}".`);
31
33
  return;
@@ -39,7 +41,7 @@ class HttpsProxy {
39
41
  this.logger.warn(`Rejected proxy request without hostname from "${clientSocket.remoteAddress}".`);
40
42
  return;
41
43
  }
42
- const serverSocket = net.connect({ port: parsedPort, host: hostname });
44
+ const serverSocket = net.connect({ host: hostname, port: parsedPort });
43
45
  clientSocket
44
46
  .on('end', () => {
45
47
  if (serverSocket) {
@@ -75,7 +77,7 @@ class HttpsProxy {
75
77
  };
76
78
  this.onCreate = (req, res) => {
77
79
  // discard all request to proxy server except HTTP/1.1 CONNECT method
78
- res.writeHead(400, { 'Content-Type': 'text/plain' });
80
+ res.writeHead(http_status_codes_1.StatusCodes.BAD_REQUEST, { 'Content-Type': 'text/plain' });
79
81
  res.end('Bad Request');
80
82
  this.logger.warn(`Rejected "${req.method}" request from "${req.socket.remoteAddress}"`);
81
83
  };
@@ -99,6 +101,7 @@ class HttpsProxy {
99
101
  getClosingProxyMessage(code, httpMessage) {
100
102
  return [
101
103
  `HTTP/1.1 ${code} ${httpMessage}`,
104
+ `Date: ${new Date().toUTCString()}`,
102
105
  'Proxy-Authenticate: Basic realm="proxy"',
103
106
  'Proxy-Connection: close',
104
107
  ].join('\r\n');
package/HttpsProxy.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"HttpsProxy.js","sourceRoot":"","sources":["../src/HttpsProxy.ts"],"names":[],"mappings":";;AAAA,wCAAwC;AACxC,6BAA6B;AAC7B,mCAAmC;AACnC,2BAA2B;AAC3B,kCAAmC;AACnC,2BAA2B;AAoB3B,MAAM,cAAc,GAAoC;IACtD,QAAQ,EAAE,EAAE;IACZ,IAAI,EAAE,IAAI;IACV,MAAM,EAAE,EAAE;IACV,QAAQ,EAAE,EAAE;CACb,CAAC;AAEF,MAAa,UAAU;IAMrB,YAAY,OAAyC;QAgCpC,cAAS,GAAG,CAAC,GAAyB,EAAE,YAAwB,EAAQ,EAAE;YACzF,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,aAAa,EAAE,YAAY,CAAC,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC;YAE3F,MAAM,mBAAmB,GAAG,GAAG,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC;YAE/D,IAAI,IAAI,CAAC,qBAAqB,EAAE;gBAC9B,IAAI,CAAC,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com/ffflorian/https-proxy/actions/) [![npm version](https://img.shields.io/npm/v/@ffflorian/https-proxy.svg?style=flat)](https://www.npmjs.com/package/@ffflorian/https-proxy) [![Dependabot Status](https://api.dependabot.com/badges/status?host=github&repo=ffflorian/https-proxy)](https://dependabot.com)
1
+ # https-proxy [![npm version](https://img.shields.io/npm/v/@ffflorian/https-proxy.svg?style=flat)](https://www.npmjs.com/package/@ffflorian/https-proxy)
2
2
 
3
3
  A simple HTTPS proxy for Node.js with authentication support.
4
4
 
package/cli.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict";
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- const program = require("commander");
4
+ const commander_1 = require("commander");
5
5
  const fs = require("fs");
6
6
  const path = require("path");
7
7
  const HttpsProxy_1 = require("./HttpsProxy");
@@ -11,19 +11,21 @@ const packageJsonPath = fs.existsSync(defaultPackageJsonPath)
11
11
  : path.join(__dirname, '../package.json');
12
12
  const packageJson = fs.readFileSync(packageJsonPath, 'utf-8');
13
13
  const { description, name, version } = JSON.parse(packageJson);
14
- program
14
+ commander_1.program
15
15
  .name(name.replace(/^@[^/]+\//, ''))
16
16
  .description(`${description}\nIf password and username are not set, no authentication will be required.`)
17
17
  .option('-p, --password <password>', 'set the password')
18
- .option('-P, --port <port>', 'set the port', 8080)
18
+ .option('-P, --port <port>', 'set the port', '8080')
19
19
  .option('-t, --target <url>', 'set the target URL to forward users to')
20
20
  .option('-u, --username <username>', 'set the username')
21
21
  .version(version, '-v, --version')
22
22
  .parse(process.argv);
23
- if ((program.password && !program.username) || (!program.password && program.username)) {
23
+ const commanderOptions = commander_1.program.opts();
24
+ if ((commanderOptions.password && !commanderOptions.username) ||
25
+ (!commanderOptions.password && commanderOptions.username)) {
24
26
  console.error('Password and username are both required for authentication.');
25
- program.outputHelp();
27
+ commander_1.program.outputHelp();
26
28
  process.exit(1);
27
29
  }
28
- new HttpsProxy_1.HttpsProxy(Object.assign(Object.assign(Object.assign(Object.assign({}, (program.password && { password: program.password })), (program.port && { port: program.port })), (program.target && { target: program.target })), (program.username && { username: program.username }))).start();
30
+ new HttpsProxy_1.HttpsProxy(Object.assign(Object.assign(Object.assign(Object.assign({}, (commanderOptions.password && { password: commanderOptions.password })), (commanderOptions.port && { port: commanderOptions.port })), (commanderOptions.target && { target: commanderOptions.target })), (commanderOptions.username && { username: commanderOptions.username }))).start();
29
31
  //# sourceMappingURL=cli.js.map
package/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;AAEA,qCAAqC;AACrC,yBAAyB;AACzB,6BAA6B;AAE7B,6CAAwC;AAExC,MAAM,sBAAsB,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC;AACpE,MAAM,eAAe,GAAG,EAAE,CAAC,UAAU,CAAC,sBAAsB,CAAC;IAC3D,CAAC,CAAC,sBAAsB;IACxB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,iBAAiB,CAAC,CAAC;AAE5C,MAAM,WAAW,GAAG,EAAE,CAAC,YAAY,CAAC,eAAe,EAAE,OAAO,CAAC,CAAC;AAC9D,MAAM,EAAC,WAAW,EAAE,IAAI,EAAE,OAAO,EAAC,GAAyD,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;AAEnH,OAAO;KACJ,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;KACnC,WAAW,CAAC,GAAG,WAAW,6EAA6E,CAAC;KACxG,MAAM,CAAC,2BAA2B,EAAE,kBAAkB,CAAC;KACvD,MAAM,CAAC,mBAAmB,EAAE,cAAc,EAAE,IAAI,CAAC;KACjD,MAAM,CAAC,oBAAoB,EAAE,wCAAwC,CAAC;KACtE,MAAM,CAAC,2BAA2B,EAAE,kBAAkB,CAAC;KACvD,OAAO,CAAC,OAAO,EAAE,eAAe,C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AAC,KAAK,EAAE,CAAC"}
package/index.js CHANGED
@@ -1,7 +1,18 @@
1
1
  "use strict";
2
- function __export(m) {
3
- for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
4
- }
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
5
16
  Object.defineProperty(exports, "__esModule", { value: true });
6
- __export(require("./HttpsProxy"));
17
+ __exportStar(require("./HttpsProxy"), exports);
7
18
  //# sourceMappingURL=index.js.map
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;AAAA,kCAA6B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B"}
package/package.json CHANGED
@@ -1,37 +1,21 @@
1
1
  {
2
- "author": "Florian Keller <github@floriankeller.de>",
2
+ "author": "Florian Imdahl <git@ffflorian.de>",
3
3
  "bin": {
4
4
  "https-proxy": "cli.js"
5
5
  },
6
6
  "dependencies": {
7
7
  "basic-auth": "2.0.1",
8
- "commander": "4.0.1",
9
- "logdown": "3.2.8",
8
+ "commander": "10.0.0",
9
+ "http-status-codes": "2.2.0",
10
+ "logdown": "3.3.1",
10
11
  "tsscmp": "1.0.6"
11
12
  },
12
13
  "description": "A simple HTTPS proxy for Node.js with authentication support.",
13
14
  "devDependencies": {
14
- "@ffflorian/prettier-config": "0.0.5",
15
- "@ffflorian/semantic-release-config": "0.1.4",
16
- "@ffflorian/tslint-config": "0.7.0",
17
- "@semantic-release/changelog": "3.0.5",
18
- "@semantic-release/git": "7.0.18",
19
- "@types/basic-auth": "1.1.2",
20
- "@types/jasmine": "3.4.6",
21
- "@types/node": "~12",
15
+ "@types/basic-auth": "1.1.3",
22
16
  "@types/tsscmp": "1.0.0",
23
- "husky": "3.1.0",
24
- "jasmine": "3.5.0",
25
- "lint-staged": "9.4.3",
26
- "prettier": "1.19.1",
27
- "publish-flat": "1.3.4",
28
- "rimraf": "3.0.0",
29
- "semantic-release": "15.13.31",
30
- "ts-node": "8.5.2",
31
- "tslint": "5.20.1",
32
- "tslint-config-prettier": "1.18.0",
33
- "tslint-plugin-prettier": "2.0.1",
34
- "typescript": "3.7.2"
17
+ "rimraf": "4.1.2",
18
+ "typescript": "4.9.5"
35
19
  },
36
20
  "engines": {
37
21
  "node": ">= 10.9"
@@ -51,50 +35,21 @@
51
35
  "cli",
52
36
  "typescript"
53
37
  ],
54
- "husky": {
55
- "hooks": {
56
- "pre-commit": "lint-staged"
57
- }
58
- },
59
38
  "license": "GPL-3.0",
60
- "lint-staged": {
61
- "*.{json,md,yml}": [
62
- "prettier --write",
63
- "git add"
64
- ],
65
- "spec/**/*.ts": [
66
- "tslint --project tsconfig.jasmine.json --fix",
67
- "git add"
68
- ],
69
- "src/**/*.ts": [
70
- "tslint --project tsconfig.json --fix",
71
- "git add"
72
- ]
73
- },
74
39
  "main": "index.js",
75
40
  "name": "@ffflorian/https-proxy",
76
- "prettier": "@ffflorian/prettier-config",
77
- "release": {
78
- "extends": "@ffflorian/semantic-release-config"
41
+ "publishConfig": {
42
+ "directory": "flattened"
79
43
  },
80
- "repository": "https://github.com/ffflorian/https-proxy.git",
44
+ "repository": "https://github.com/ffflorian/node-packages/tree/main/packages/https-proxy",
81
45
  "scripts": {
82
46
  "build": "tsc",
83
47
  "clean": "rimraf dist",
84
48
  "dist": "yarn clean && yarn build",
85
- "fix": "yarn fix:other && yarn fix:ts",
86
- "fix:other": "yarn prettier --write",
87
- "fix:ts": "yarn lint:ts --fix && yarn lint:ts:spec --fix",
88
- "flatten": "publish-flat -o flattened",
89
- "lint": "yarn lint:ts && yarn lint:ts:spec && yarn lint:other",
90
- "lint:other": "yarn prettier --list-different",
91
- "lint:ts": "tslint --project tsconfig.json",
92
- "lint:ts:spec": "tslint --project tsconfig.jasmine.json",
93
- "postversion": "node ../node_modules/publish-flat/cli-copy.js -i package.json -o ../package.json version",
94
- "prettier": "prettier \"*.{json,md,yml}\"",
95
- "release": "semantic-release",
49
+ "flatten": "node ../publish-flat/dist/cli.js -o flattened",
50
+ "postversion": "node ../publish-flat/dist/cli-copy.js -o flattened/package.json version",
96
51
  "start": "ts-node src/cli.ts",
97
- "test": "ts-node -P tsconfig.jasmine.json node_modules/.bin/jasmine"
52
+ "test": "ts-node -P tsconfig.jasmine.json ../../node_modules/.bin/jasmine"
98
53
  },
99
- "version": "1.5.0"
54
+ "version": "1.5.2"
100
55
  }
package/CHANGELOG.md DELETED
@@ -1,47 +0,0 @@
1
- ## [1.4.2](https://github.com/ffflorian/https-proxy/compare/v1.4.1...v1.4.2) (2019-10-01)
2
-
3
- ### Bug Fixes
4
-
5
- - Log authentication status ([82ca878](https://github.com/ffflorian/https-proxy/commit/82ca878))
6
-
7
- ## [1.4.1](https://github.com/ffflorian/https-proxy/compare/v1.4.0...v1.4.1) (2019-10-01)
8
-
9
- ### Bug Fixes
10
-
11
- - Better log message for HTTP status 407 ([85e56ce](https://github.com/ffflorian/https-proxy/commit/85e56ce))
12
-
13
- # [1.4.0](https://github.com/ffflorian/https-proxy/compare/v1.3.2...v1.4.0) (2019-10-01)
14
-
15
- ### Features
16
-
17
- - Make authentication optional ([27558f5](https://github.com/ffflorian/https-proxy/commit/27558f5))
18
-
19
- ## [1.3.2](https://github.com/ffflorian/https-proxy/compare/v1.3.1...v1.3.2) (2019-10-01)
20
-
21
- ### Bug Fixes
22
-
23
- - Correct log message for HTTP status 407 ([9b2d950](https://github.com/ffflorian/https-proxy/commit/9b2d950))
24
-
25
- ## [1.3.1](https://github.com/ffflorian/https-proxy/compare/v1.3.0...v1.3.1) (2019-09-06)
26
-
27
- ### Bug Fixes
28
-
29
- - Read correct package.json ([b503b72](https://github.com/ffflorian/https-proxy/commit/b503b72))
30
-
31
- # [1.3.0](https://github.com/ffflorian/https-proxy/compare/v1.2.0...v1.3.0) (2019-09-06)
32
-
33
- ### Features
34
-
35
- - Publish flattened ([548c4f9](https://github.com/ffflorian/https-proxy/commit/548c4f9))
36
-
37
- # [1.2.0](https://github.com/ffflorian/https-proxy/compare/v1.1.0...v1.2.0) (2019-09-03)
38
-
39
- ### Features
40
-
41
- - Add logging ([ec3bd57](https://github.com/ffflorian/https-proxy/commit/ec3bd57))
42
-
43
- # [1.1.0](https://github.com/ffflorian/https-proxy/compare/v1.0.0...v1.1.0) (2019-09-03)
44
-
45
- ### Features
46
-
47
- - Add target ([ef814b3](https://github.com/ffflorian/https-proxy/commit/ef814b3))