@journeyapps/https-proxy-socket 0.2.2 → 1.0.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.
Files changed (72) hide show
  1. package/README.md +105 -51
  2. package/lib/{HttpsProxySocket.d.ts → cjs/HttpsProxySocket.d.ts} +6 -6
  3. package/lib/cjs/HttpsProxySocket.d.ts.map +1 -0
  4. package/lib/{HttpsProxySocket.js → cjs/HttpsProxySocket.js} +64 -33
  5. package/lib/cjs/HttpsProxySocket.js.map +1 -0
  6. package/lib/cjs/ProxyAgent.d.ts +11 -0
  7. package/lib/cjs/ProxyAgent.d.ts.map +1 -0
  8. package/lib/cjs/ProxyAgent.js +67 -0
  9. package/lib/cjs/ProxyAgent.js.map +1 -0
  10. package/lib/cjs/bin/mongoReplicas.d.ts +3 -0
  11. package/lib/cjs/bin/mongoReplicas.d.ts.map +1 -0
  12. package/lib/cjs/bin/mongoReplicas.js +26 -0
  13. package/lib/cjs/bin/mongoReplicas.js.map +1 -0
  14. package/lib/cjs/createProxyAgent.d.ts +11 -0
  15. package/lib/cjs/createProxyAgent.d.ts.map +1 -0
  16. package/lib/cjs/createProxyAgent.js +14 -0
  17. package/lib/cjs/createProxyAgent.js.map +1 -0
  18. package/lib/cjs/index.d.ts +3 -0
  19. package/lib/cjs/index.d.ts.map +1 -0
  20. package/lib/cjs/index.js +19 -0
  21. package/lib/cjs/index.js.map +1 -0
  22. package/lib/cjs/mongoPatch.d.ts +16 -0
  23. package/lib/cjs/mongoPatch.d.ts.map +1 -0
  24. package/lib/cjs/mongoPatch.js +58 -0
  25. package/lib/cjs/mongoPatch.js.map +1 -0
  26. package/lib/cjs/utils/parseOptions.d.ts +3 -0
  27. package/lib/cjs/utils/parseOptions.d.ts.map +1 -0
  28. package/lib/cjs/utils/parseOptions.js +16 -0
  29. package/lib/cjs/utils/parseOptions.js.map +1 -0
  30. package/lib/cjs/utils/setServername.d.ts +3 -0
  31. package/lib/cjs/utils/setServername.d.ts.map +1 -0
  32. package/lib/cjs/utils/setServername.js +47 -0
  33. package/lib/cjs/utils/setServername.js.map +1 -0
  34. package/lib/esm/HttpsProxySocket.d.ts +42 -0
  35. package/lib/esm/HttpsProxySocket.d.ts.map +1 -0
  36. package/lib/esm/HttpsProxySocket.js +197 -0
  37. package/lib/esm/HttpsProxySocket.js.map +1 -0
  38. package/lib/esm/ProxyAgent.d.ts +11 -0
  39. package/lib/esm/ProxyAgent.d.ts.map +1 -0
  40. package/lib/esm/ProxyAgent.js +67 -0
  41. package/lib/esm/ProxyAgent.js.map +1 -0
  42. package/lib/esm/bin/mongoReplicas.d.ts +3 -0
  43. package/lib/esm/bin/mongoReplicas.d.ts.map +1 -0
  44. package/lib/esm/bin/mongoReplicas.js +26 -0
  45. package/lib/esm/bin/mongoReplicas.js.map +1 -0
  46. package/lib/esm/createProxyAgent.d.ts +11 -0
  47. package/lib/esm/createProxyAgent.d.ts.map +1 -0
  48. package/lib/esm/createProxyAgent.js +14 -0
  49. package/lib/esm/createProxyAgent.js.map +1 -0
  50. package/lib/esm/index.d.ts +3 -0
  51. package/lib/esm/index.d.ts.map +1 -0
  52. package/lib/esm/index.js +19 -0
  53. package/lib/esm/index.js.map +1 -0
  54. package/lib/esm/mongoPatch.d.ts +16 -0
  55. package/lib/esm/mongoPatch.d.ts.map +1 -0
  56. package/lib/esm/mongoPatch.js +58 -0
  57. package/lib/esm/mongoPatch.js.map +1 -0
  58. package/lib/esm/utils/parseOptions.d.ts +3 -0
  59. package/lib/esm/utils/parseOptions.d.ts.map +1 -0
  60. package/lib/esm/utils/parseOptions.js +16 -0
  61. package/lib/esm/utils/parseOptions.js.map +1 -0
  62. package/lib/esm/utils/setServername.d.ts +3 -0
  63. package/lib/esm/utils/setServername.d.ts.map +1 -0
  64. package/lib/esm/utils/setServername.js +47 -0
  65. package/lib/esm/utils/setServername.js.map +1 -0
  66. package/package.json +39 -21
  67. package/lib/index.d.ts +0 -2
  68. package/lib/index.js +0 -7
  69. package/lib/proxyAgent.d.ts +0 -11
  70. package/lib/proxyAgent.js +0 -43
  71. package/lib/tediousPatch.d.ts +0 -8
  72. package/lib/tediousPatch.js +0 -34
@@ -0,0 +1,58 @@
1
+ "use strict";
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.useProxyForMongo = useProxyForMongo;
37
+ const socks = __importStar(require("socks"));
38
+ const HttpsProxySocket_js_1 = require("./HttpsProxySocket.js");
39
+ /**
40
+ * The patch should be called before instantiating the MongoClient
41
+ * @param config - The configuration for the proxy
42
+ */
43
+ function useProxyForMongo(config) {
44
+ let socket;
45
+ socks.SocksClient.createConnection = async (options, callback) => {
46
+ const proxy = new HttpsProxySocket_js_1.HttpsProxySocket(`https://${config.proxy}`, { auth: config.auth });
47
+ return new Promise(async (resolve, reject) => {
48
+ socket = await proxy.connect({ host: options.destination.host, port: options.destination.port });
49
+ resolve({
50
+ socket,
51
+ });
52
+ });
53
+ };
54
+ return {
55
+ close: () => socket?.end(),
56
+ };
57
+ }
58
+ //# sourceMappingURL=mongoPatch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mongoPatch.js","sourceRoot":"","sources":["../../src/mongoPatch.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA,4CAcC;AA5BD,6CAA+B;AAE/B,+DAAyD;AAQzD;;;GAGG;AACH,SAAgB,gBAAgB,CAAC,MAAc;IAC7C,IAAI,MAAqB,CAAC;IAC1B,KAAK,CAAC,WAAW,CAAC,gBAAgB,GAAG,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE;QAC/D,MAAM,KAAK,GAAG,IAAI,sCAAgB,CAAC,WAAW,MAAM,CAAC,KAAK,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;QACrF,OAAO,IAAI,OAAO,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE;YAC3C,MAAM,GAAG,MAAM,KAAK,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,WAAW,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC,CAAC;YACjG,OAAO,CAAC;gBACN,MAAM;aACP,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;IACF,OAAO;QACL,KAAK,EAAE,GAAG,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE;KAC3B,CAAC;AACJ,CAAC"}
@@ -0,0 +1,3 @@
1
+ import tls from 'tls';
2
+ export declare function parseOptions(options: tls.ConnectionOptions | string): tls.ConnectionOptions;
3
+ //# sourceMappingURL=parseOptions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parseOptions.d.ts","sourceRoot":"","sources":["../../../src/utils/parseOptions.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,KAAK,CAAC;AAEtB,wBAAgB,YAAY,CAAC,OAAO,EAAE,GAAG,CAAC,iBAAiB,GAAG,MAAM,yBAUnE"}
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseOptions = parseOptions;
4
+ function parseOptions(options) {
5
+ if (typeof options != 'string') {
6
+ return options;
7
+ }
8
+ else {
9
+ const parsedOptions = new URL(options);
10
+ return {
11
+ host: parsedOptions.hostname || parsedOptions.host,
12
+ port: parseInt(parsedOptions.port || '443'),
13
+ };
14
+ }
15
+ }
16
+ //# sourceMappingURL=parseOptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parseOptions.js","sourceRoot":"","sources":["../../../src/utils/parseOptions.ts"],"names":[],"mappings":";;AAEA,oCAUC;AAVD,SAAgB,YAAY,CAAC,OAAuC;IAClE,IAAI,OAAO,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC/B,OAAO,OAAO,CAAC;IACjB,CAAC;SAAM,CAAC;QACN,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC;QACvC,OAAO;YACL,IAAI,EAAE,aAAa,CAAC,QAAQ,IAAI,aAAa,CAAC,IAAI;YAClD,IAAI,EAAE,QAAQ,CAAC,aAAa,CAAC,IAAI,IAAI,KAAK,CAAC;SAC5C,CAAC;IACJ,CAAC;AACH,CAAC"}
@@ -0,0 +1,3 @@
1
+ import * as tls from 'tls';
2
+ export declare function setServername(options: tls.ConnectionOptions): tls.ConnectionOptions;
3
+ //# sourceMappingURL=setServername.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setServername.d.ts","sourceRoot":"","sources":["../../../src/utils/setServername.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAE3B,wBAAgB,aAAa,CAAC,OAAO,EAAE,GAAG,CAAC,iBAAiB,yBAQ3D"}
@@ -0,0 +1,47 @@
1
+ "use strict";
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.setServername = setServername;
37
+ const net = __importStar(require("net"));
38
+ function setServername(options) {
39
+ if (options.servername === undefined && options.host && !net.isIP(options.host)) {
40
+ return {
41
+ ...options,
42
+ servername: options.host,
43
+ };
44
+ }
45
+ return options;
46
+ }
47
+ //# sourceMappingURL=setServername.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setServername.js","sourceRoot":"","sources":["../../../src/utils/setServername.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,sCAQC;AAXD,yCAA2B;AAG3B,SAAgB,aAAa,CAAC,OAA8B;IAC1D,IAAI,OAAO,CAAC,UAAU,KAAK,SAAS,IAAI,OAAO,CAAC,IAAI,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QAChF,OAAO;YACL,GAAG,OAAO;YACV,UAAU,EAAE,OAAO,CAAC,IAAI;SACzB,CAAC;IACJ,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -0,0 +1,42 @@
1
+ import * as tls from 'tls';
2
+ export interface HttpsProxyConfig extends tls.ConnectionOptions {
3
+ headers?: {
4
+ [key: string]: string;
5
+ };
6
+ auth?: string;
7
+ }
8
+ export interface ConnectionOptions {
9
+ host: string;
10
+ port: number;
11
+ }
12
+ /**
13
+ * The HttpsProxySocket class allows creating Socket connections via an HTTPS proxy.
14
+ * HTTP proxies are not supported.
15
+ * For http(s) requests, use HttpsProxyAgent as a wrapper around this.
16
+ */
17
+ export declare class HttpsProxySocket {
18
+ proxy: tls.ConnectionOptions;
19
+ proxyConfig: HttpsProxyConfig;
20
+ /**
21
+ *
22
+ * @param options - The connection options to the proxy. At least host and port are required.
23
+ * Use {rejectUnauthorized: true} to ignore certificates for the proxy (not the endpoint).
24
+ * @param proxyConfig - { auth: 'username:password' } for basic auth.
25
+ * { headers: {key: 'value'} } for custom headers.
26
+ */
27
+ constructor(options: tls.ConnectionOptions | string, proxyConfig?: HttpsProxyConfig);
28
+ /**
29
+ * Create a new Socket connection.
30
+ *
31
+ * @param options - host and port
32
+ */
33
+ connect(options: ConnectionOptions): Promise<tls.TLSSocket>;
34
+ /**
35
+ * Construct an agent for http(s) requests.
36
+ *
37
+ * @param options - to set additional TLS options for https requests, e.g. rejectUnauthorized
38
+ */
39
+ agent(options?: tls.ConnectionOptions): import("./ProxyAgent").ProxyAgent;
40
+ private _connect;
41
+ }
42
+ //# sourceMappingURL=HttpsProxySocket.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HttpsProxySocket.d.ts","sourceRoot":"","sources":["../../src/HttpsProxySocket.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAS3B,MAAM,WAAW,gBAAiB,SAAQ,GAAG,CAAC,iBAAiB;IAC7D,OAAO,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;IACpC,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;GAIG;AACH,qBAAa,gBAAgB;IAC3B,KAAK,EAAE,GAAG,CAAC,iBAAiB,CAAC;IAC7B,WAAW,EAAE,gBAAgB,CAAC;IAE9B;;;;;;OAMG;gBACS,OAAO,EAAE,GAAG,CAAC,iBAAiB,GAAG,MAAM,EAAE,WAAW,CAAC,EAAE,gBAAgB;IAWnF;;;;OAIG;IACH,OAAO,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC;IAe3D;;;;OAIG;IACH,KAAK,CAAC,OAAO,CAAC,EAAE,GAAG,CAAC,iBAAiB;IAIrC,OAAO,CAAC,QAAQ;CAsHjB"}
@@ -0,0 +1,197 @@
1
+ "use strict";
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.HttpsProxySocket = void 0;
37
+ const tls = __importStar(require("tls"));
38
+ const createProxyAgent_1 = require("./createProxyAgent");
39
+ const setServername_1 = require("./utils/setServername");
40
+ const parseOptions_1 = require("./utils/parseOptions");
41
+ const util_1 = require("util");
42
+ const debug = (0, util_1.debug)('https-proxy');
43
+ /**
44
+ * The HttpsProxySocket class allows creating Socket connections via an HTTPS proxy.
45
+ * HTTP proxies are not supported.
46
+ * For http(s) requests, use HttpsProxyAgent as a wrapper around this.
47
+ */
48
+ class HttpsProxySocket {
49
+ proxy;
50
+ proxyConfig;
51
+ /**
52
+ *
53
+ * @param options - The connection options to the proxy. At least host and port are required.
54
+ * Use {rejectUnauthorized: true} to ignore certificates for the proxy (not the endpoint).
55
+ * @param proxyConfig - { auth: 'username:password' } for basic auth.
56
+ * { headers: {key: 'value'} } for custom headers.
57
+ */
58
+ constructor(options, proxyConfig) {
59
+ const sanitizedOptions = (0, parseOptions_1.parseOptions)(options);
60
+ if (!options) {
61
+ throw new Error('an HTTP(S) proxy server `host` and `port` must be specified!');
62
+ }
63
+ debug('creating new HttpsProxyAgent instance: %o', sanitizedOptions);
64
+ this.proxyConfig = proxyConfig || {};
65
+ this.proxy = sanitizedOptions;
66
+ }
67
+ /**
68
+ * Create a new Socket connection.
69
+ *
70
+ * @param options - host and port
71
+ */
72
+ connect(options) {
73
+ return new Promise(async (resolve, reject) => {
74
+ this._connect(options, (error, socket) => {
75
+ if (error) {
76
+ reject(error);
77
+ }
78
+ else {
79
+ if (!socket) {
80
+ return reject(new Error('No socket returned from proxy'));
81
+ }
82
+ resolve(socket);
83
+ }
84
+ });
85
+ });
86
+ }
87
+ /**
88
+ * Construct an agent for http(s) requests.
89
+ *
90
+ * @param options - to set additional TLS options for https requests, e.g. rejectUnauthorized
91
+ */
92
+ agent(options) {
93
+ return (0, createProxyAgent_1.createProxyAgent)(this, options);
94
+ }
95
+ _connect(opts, cb) {
96
+ const proxy = this.proxy;
97
+ // create a socket connection to the proxy server
98
+ const socket = tls.connect((0, setServername_1.setServername)(proxy));
99
+ // we need to buffer any HTTP traffic that happens with the proxy before we get
100
+ // the CONNECT response, so that if the response is anything other than an "200"
101
+ // response code, then we can re-play the "data" events on the socket once the
102
+ // HTTP parser is hooked up...
103
+ let buffers = [];
104
+ let buffersLength = 0;
105
+ function read() {
106
+ var b = socket.read();
107
+ if (b) {
108
+ ondata(b);
109
+ }
110
+ else {
111
+ socket.once('readable', read);
112
+ }
113
+ }
114
+ function cleanup() {
115
+ socket.removeListener('data', ondata);
116
+ socket.removeListener('end', onend);
117
+ socket.removeListener('error', onerror);
118
+ socket.removeListener('close', onclose);
119
+ socket.removeListener('readable', read);
120
+ }
121
+ function onclose(err) {
122
+ debug('onclose had error %o', err);
123
+ }
124
+ function onend() {
125
+ debug('onend');
126
+ }
127
+ function onerror(err) {
128
+ cleanup();
129
+ cb(err, null);
130
+ }
131
+ const END_OF_HEADERS = '\r\n\r\n';
132
+ function ondata(b) {
133
+ buffers.push(b);
134
+ buffersLength += b.length;
135
+ // Headers (including URLs) are generally ISO-8859-1 or ASCII.
136
+ // The subset used by an HTTPS proxy should always be safe as ASCII.
137
+ const buffered = Buffer.concat(buffers, buffersLength);
138
+ const str = buffered.toString('ascii');
139
+ if (str.indexOf(END_OF_HEADERS) < 0) {
140
+ // keep buffering
141
+ debug('have not received end of HTTP headers yet...');
142
+ if (socket.readable) {
143
+ read();
144
+ }
145
+ else {
146
+ socket.once('data', ondata);
147
+ }
148
+ return;
149
+ }
150
+ const firstLine = str.substring(0, str.indexOf('\r\n'));
151
+ const statusCode = parseInt(firstLine.split(' ')[1], 10);
152
+ debug('got proxy server response: %o', firstLine);
153
+ if (200 == statusCode) {
154
+ // 200 Connected status code!
155
+ const sock = socket;
156
+ // nullify the buffered data since we won't be needing it
157
+ buffers = [];
158
+ cleanup();
159
+ cb(null, sock);
160
+ }
161
+ else {
162
+ // some other status code that's not 200... need to re-play the HTTP header
163
+ // "data" events onto the socket once the HTTP machinery is attached so that
164
+ // the user can parse and handle the error status code
165
+ cleanup();
166
+ // nullify the buffered data since we won't be needing it
167
+ buffers = [];
168
+ cleanup();
169
+ socket.end();
170
+ cb(new Error('Proxy connection failed: ' + firstLine), null);
171
+ }
172
+ }
173
+ socket.on('error', onerror);
174
+ socket.on('close', onclose);
175
+ socket.on('end', onend);
176
+ if (socket.readable) {
177
+ read();
178
+ }
179
+ else {
180
+ socket.once('data', ondata);
181
+ }
182
+ const host = `${opts.host}:${opts.port}`;
183
+ let msg = 'CONNECT ' + host + ' HTTP/1.1\r\n';
184
+ const headers = Object.assign({}, this.proxyConfig.headers);
185
+ if (this.proxyConfig.auth) {
186
+ headers['Proxy-Authorization'] = 'Basic ' + Buffer.from(this.proxyConfig.auth).toString('base64');
187
+ }
188
+ headers['Host'] = host;
189
+ headers['Connection'] = 'close';
190
+ Object.keys(headers).forEach(function (name) {
191
+ msg += name + ': ' + headers[name] + '\r\n';
192
+ });
193
+ socket.write(msg + '\r\n');
194
+ }
195
+ }
196
+ exports.HttpsProxySocket = HttpsProxySocket;
197
+ //# sourceMappingURL=HttpsProxySocket.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HttpsProxySocket.js","sourceRoot":"","sources":["../../src/HttpsProxySocket.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yCAA2B;AAC3B,yDAAsD;AACtD,yDAAsD;AACtD,uDAAoD;AAEpD,+BAA0C;AAE1C,MAAM,KAAK,GAAG,IAAA,YAAS,EAAC,aAAa,CAAC,CAAC;AAYvC;;;;GAIG;AACH,MAAa,gBAAgB;IAC3B,KAAK,CAAwB;IAC7B,WAAW,CAAmB;IAE9B;;;;;;OAMG;IACH,YAAY,OAAuC,EAAE,WAA8B;QACjF,MAAM,gBAAgB,GAAG,IAAA,2BAAY,EAAC,OAAO,CAAC,CAAC;QAC/C,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,8DAA8D,CAAC,CAAC;QAClF,CAAC;QACD,KAAK,CAAC,2CAA2C,EAAE,gBAAgB,CAAC,CAAC;QAErE,IAAI,CAAC,WAAW,GAAG,WAAW,IAAI,EAAE,CAAC;QACrC,IAAI,CAAC,KAAK,GAAG,gBAAyC,CAAC;IACzD,CAAC;IAED;;;;OAIG;IACH,OAAO,CAAC,OAA0B;QAChC,OAAO,IAAI,OAAO,CAAgB,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE;YAC1D,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE;gBACvC,IAAI,KAAK,EAAE,CAAC;oBACV,MAAM,CAAC,KAAK,CAAC,CAAC;gBAChB,CAAC;qBAAM,CAAC;oBACN,IAAI,CAAC,MAAM,EAAE,CAAC;wBACZ,OAAO,MAAM,CAAC,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC,CAAC;oBAC5D,CAAC;oBACD,OAAO,CAAC,MAAM,CAAC,CAAC;gBAClB,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AY,CAAC,GAAG,OAAO,CAAC;QAChC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,UAAU,IAAI;YACzC,GAAG,IAAI,IAAI,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;QAC9C,CAAC,CAAC,CAAC;QAEH,MAAM,CAAC,KAAK,CAAC,GAAG,GAAG,MAAM,CAAC,CAAC;IAC7B,CAAC;CACF;AAzKD,4CAyKC"}
@@ -0,0 +1,11 @@
1
+ import { Agent, AgentConnectOpts } from 'agent-base';
2
+ import * as http from 'http';
3
+ import * as tls from 'tls';
4
+ import { HttpsProxySocket } from './HttpsProxySocket';
5
+ export declare class ProxyAgent extends Agent {
6
+ proxy: HttpsProxySocket;
7
+ agentOptions?: http.AgentOptions | undefined;
8
+ constructor(proxy: HttpsProxySocket, agentOptions?: http.AgentOptions | undefined);
9
+ connect(req: http.ClientRequest, options: AgentConnectOpts): Promise<tls.TLSSocket>;
10
+ }
11
+ //# sourceMappingURL=ProxyAgent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProxyAgent.d.ts","sourceRoot":"","sources":["../../src/ProxyAgent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAC3B,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,qBAAa,UAAW,SAAQ,KAAK;IAE1B,KAAK,EAAE,gBAAgB;IACvB,YAAY,CAAC,EAAE,IAAI,CAAC,YAAY;gBADhC,KAAK,EAAE,gBAAgB,EACvB,YAAY,CAAC,EAAE,IAAI,CAAC,YAAY,YAAA;IAInC,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,aAAa,EAAE,OAAO,EAAE,gBAAgB;CAiBjE"}
@@ -0,0 +1,67 @@
1
+ "use strict";
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.ProxyAgent = void 0;
37
+ const agent_base_1 = require("agent-base");
38
+ const tls = __importStar(require("tls"));
39
+ class ProxyAgent extends agent_base_1.Agent {
40
+ proxy;
41
+ agentOptions;
42
+ constructor(proxy, agentOptions) {
43
+ super(agentOptions);
44
+ this.proxy = proxy;
45
+ this.agentOptions = agentOptions;
46
+ }
47
+ async connect(req, options) {
48
+ const socket = await this.proxy.connect(options);
49
+ if (options.secureEndpoint) {
50
+ let tlsOptions = {
51
+ socket: socket,
52
+ servername: options.servername || options.host,
53
+ };
54
+ if (typeof options.rejectUnauthorized != 'undefined') {
55
+ tlsOptions.rejectUnauthorized = options.rejectUnauthorized;
56
+ }
57
+ Object.assign(tlsOptions, this.agentOptions);
58
+ return tls.connect(tlsOptions);
59
+ }
60
+ else {
61
+ socket.resume();
62
+ return socket;
63
+ }
64
+ }
65
+ }
66
+ exports.ProxyAgent = ProxyAgent;
67
+ //# sourceMappingURL=ProxyAgent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProxyAgent.js","sourceRoot":"","sources":["../../src/ProxyAgent.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAAqD;AAErD,yCAA2B;AAG3B,MAAa,UAAW,SAAQ,kBAAK;IAE1B;IACA;IAFT,YACS,KAAuB,EACvB,YAAgC;QAEvC,KAAK,CAAC,YAAY,CAAC,CAAC;QAHb,UAAK,GAAL,KAAK,CAAkB;QACvB,iBAAY,GAAZ,YAAY,CAAoB;IAGzC,CAAC;IACD,KAAK,CAAC,OAAO,CAAC,GAAuB,EAAE,OAAyB;QAC9D,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,OAAc,CAAC,CAAC;QACxD,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC;YAC3B,IAAI,UAAU,GAA0B;gBACtC,MAAM,EAAE,MAAM;gBACd,UAAU,EAAE,OAAO,CAAC,UAAU,IAAI,OAAO,CAAC,IAAI;aAC/C,CAAC;YACF,IAAI,OAAO,OAAO,CAAC,kBAAkB,IAAI,WAAW,EAAE,CAAC;gBACrD,UAAU,CAAC,kBAAkB,GAAG,OAAO,CAAC,kBAAkB,CAAC;YAC7D,CAAC;YACD,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;YAC7C,OAAO,GAAG,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QACjC,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,MAAM,EAAE,CAAC;YAChB,OAAO,MAAM,CAAC;QAChB,CAAC;IACH,CAAC;CACF;AAxBD,gCAwBC"}
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=mongoReplicas.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mongoReplicas.d.ts","sourceRoot":"","sources":["../../../src/bin/mongoReplicas.ts"],"names":[],"mappings":""}
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ const promises_1 = require("dns/promises");
5
+ /**
6
+ * NPX script to resolve MongoDB SRV records.
7
+ * @example npx @journeyapps/https-proxy-socket mongo-replicas mongodb+srv://<username>:<password>@cluster1.vlnzcbp.mongodb.net
8
+ * @example npx @journeyapps/https-proxy-socket mongo-replicas mongodb+srv://cluster1.vlnzcbp.mongodb.net
9
+ *
10
+ * @returns An object with a `replicas` property containing the resolved host:port pairs.
11
+ */
12
+ async function mongoReplicas() {
13
+ const srvUrl = process.argv[3];
14
+ const url = new URL(srvUrl);
15
+ if (url.protocol !== 'mongodb+srv:') {
16
+ throw new Error('URL must start with mongodb+srv://');
17
+ }
18
+ const hostname = url.hostname;
19
+ const srvRecords = await (0, promises_1.resolveSrv)(`_mongodb._tcp.${hostname}`);
20
+ const targets = srvRecords.map((r) => `${r.name}:${r.port}`);
21
+ return { replicas: targets.join(',') };
22
+ }
23
+ mongoReplicas()
24
+ .then((result) => console.log(result))
25
+ .catch((error) => console.error(error));
26
+ //# sourceMappingURL=mongoReplicas.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mongoReplicas.js","sourceRoot":"","sources":["../../../src/bin/mongoReplicas.ts"],"names":[],"mappings":";;;AACA,2CAA0C;AAE1C;;;;;;GAMG;AACH,KAAK,UAAU,aAAa;IAC1B,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAC/B,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC;IAC5B,IAAI,GAAG,CAAC,QAAQ,KAAK,cAAc,EAAE,CAAC;QACpC,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;IACxD,CAAC;IACD,MAAM,QAAQ,GAAG,GAAG,CAAC,QAAQ,CAAC;IAC9B,MAAM,UAAU,GAAG,MAAM,IAAA,qBAAU,EAAC,iBAAiB,QAAQ,EAAE,CAAC,CAAC;IACjE,MAAM,OAAO,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;IAC7D,OAAO,EAAE,QAAQ,EAAE,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;AACzC,CAAC;AAED,aAAa,EAAE;KACZ,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;KACrC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { HttpsProxySocket } from './HttpsProxySocket.js';
2
+ import { ProxyAgent } from './ProxyAgent';
3
+ import * as http from 'node:http';
4
+ /**
5
+ * Construct an agent for http(s) requests. Mostly for testing purposes.
6
+ *
7
+ * @param proxy - the proxy to use
8
+ * @param options - to set additional TLS options for https requests, e.g. rejectUnauthorized
9
+ */
10
+ export declare function createProxyAgent(proxy: HttpsProxySocket, options?: http.AgentOptions): ProxyAgent;
11
+ //# sourceMappingURL=createProxyAgent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createProxyAgent.d.ts","sourceRoot":"","sources":["../../src/createProxyAgent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,gBAAgB,EAAE,OAAO,CAAC,EAAE,IAAI,CAAC,YAAY,cAEpF"}
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createProxyAgent = createProxyAgent;
4
+ const ProxyAgent_1 = require("./ProxyAgent");
5
+ /**
6
+ * Construct an agent for http(s) requests. Mostly for testing purposes.
7
+ *
8
+ * @param proxy - the proxy to use
9
+ * @param options - to set additional TLS options for https requests, e.g. rejectUnauthorized
10
+ */
11
+ function createProxyAgent(proxy, options) {
12
+ return new ProxyAgent_1.ProxyAgent(proxy, options);
13
+ }
14
+ //# sourceMappingURL=createProxyAgent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createProxyAgent.js","sourceRoot":"","sources":["../../src/createProxyAgent.ts"],"names":[],"mappings":";;AAUA,4CAEC;AAXD,6CAA0C;AAG1C;;;;;GAKG;AACH,SAAgB,gBAAgB,CAAC,KAAuB,EAAE,OAA2B;IACnF,OAAO,IAAI,uBAAU,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;AACxC,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from './HttpsProxySocket.js';
2
+ export * from './mongoPatch.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,iBAAiB,CAAC"}
@@ -0,0 +1,19 @@
1
+ "use strict";
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
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./HttpsProxySocket.js"), exports);
18
+ __exportStar(require("./mongoPatch.js"), exports);
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wDAAsC;AACtC,kDAAgC"}
@@ -0,0 +1,16 @@
1
+ import * as tls from 'tls';
2
+ interface Config {
3
+ /** The journey apps cc egress token */
4
+ auth: string;
5
+ /** The journey apps cc egress proxy domain */
6
+ proxy: string;
7
+ }
8
+ /**
9
+ * The patch should be called before instantiating the MongoClient
10
+ * @param config - The configuration for the proxy
11
+ */
12
+ export declare function useProxyForMongo(config: Config): {
13
+ close: () => tls.TLSSocket;
14
+ };
15
+ export {};
16
+ //# sourceMappingURL=mongoPatch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mongoPatch.d.ts","sourceRoot":"","sources":["../../src/mongoPatch.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAG3B,UAAU,MAAM;IACd,uCAAuC;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,8CAA8C;IAC9C,KAAK,EAAE,MAAM,CAAC;CACf;AACD;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM;;EAc9C"}