@journeyapps/https-proxy-socket 0.0.0-dev.70e6967 → 0.0.0-dev.73fb7f7

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 (62) hide show
  1. package/README.md +86 -92
  2. package/lib/cjs/HttpsProxySocket.d.ts +5 -5
  3. package/lib/cjs/HttpsProxySocket.d.ts.map +1 -1
  4. package/lib/cjs/HttpsProxySocket.js +16 -26
  5. package/lib/cjs/HttpsProxySocket.js.map +1 -1
  6. package/lib/cjs/ProxyAgent.d.ts +11 -0
  7. package/lib/cjs/ProxyAgent.d.ts.map +1 -0
  8. package/lib/{esm/proxyAgent.js → cjs/ProxyAgent.js} +21 -25
  9. package/lib/cjs/ProxyAgent.js.map +1 -0
  10. package/lib/cjs/{proxyAgent.d.ts → createProxyAgent.d.ts} +4 -4
  11. package/lib/cjs/createProxyAgent.d.ts.map +1 -0
  12. package/lib/cjs/createProxyAgent.js +14 -0
  13. package/lib/cjs/createProxyAgent.js.map +1 -0
  14. package/lib/cjs/index.d.ts +0 -1
  15. package/lib/cjs/index.d.ts.map +1 -1
  16. package/lib/cjs/index.js +0 -1
  17. package/lib/cjs/index.js.map +1 -1
  18. package/lib/cjs/utils/parseOptions.d.ts +3 -0
  19. package/lib/cjs/utils/parseOptions.d.ts.map +1 -0
  20. package/lib/cjs/utils/parseOptions.js +16 -0
  21. package/lib/cjs/utils/parseOptions.js.map +1 -0
  22. package/lib/cjs/utils/setServername.d.ts +3 -0
  23. package/lib/cjs/utils/setServername.d.ts.map +1 -0
  24. package/lib/cjs/utils/setServername.js +47 -0
  25. package/lib/cjs/utils/setServername.js.map +1 -0
  26. package/lib/esm/HttpsProxySocket.d.ts +5 -5
  27. package/lib/esm/HttpsProxySocket.d.ts.map +1 -1
  28. package/lib/esm/HttpsProxySocket.js +16 -26
  29. package/lib/esm/HttpsProxySocket.js.map +1 -1
  30. package/lib/esm/ProxyAgent.d.ts +11 -0
  31. package/lib/esm/ProxyAgent.d.ts.map +1 -0
  32. package/lib/{cjs/proxyAgent.js → esm/ProxyAgent.js} +21 -25
  33. package/lib/esm/ProxyAgent.js.map +1 -0
  34. package/lib/esm/{proxyAgent.d.ts → createProxyAgent.d.ts} +4 -4
  35. package/lib/esm/createProxyAgent.d.ts.map +1 -0
  36. package/lib/esm/createProxyAgent.js +14 -0
  37. package/lib/esm/createProxyAgent.js.map +1 -0
  38. package/lib/esm/index.d.ts +0 -1
  39. package/lib/esm/index.d.ts.map +1 -1
  40. package/lib/esm/index.js +0 -1
  41. package/lib/esm/index.js.map +1 -1
  42. package/lib/esm/utils/parseOptions.d.ts +3 -0
  43. package/lib/esm/utils/parseOptions.d.ts.map +1 -0
  44. package/lib/esm/utils/parseOptions.js +16 -0
  45. package/lib/esm/utils/parseOptions.js.map +1 -0
  46. package/lib/esm/utils/setServername.d.ts +3 -0
  47. package/lib/esm/utils/setServername.d.ts.map +1 -0
  48. package/lib/esm/utils/setServername.js +47 -0
  49. package/lib/esm/utils/setServername.js.map +1 -0
  50. package/package.json +3 -3
  51. package/lib/cjs/proxyAgent.d.ts.map +0 -1
  52. package/lib/cjs/proxyAgent.js.map +0 -1
  53. package/lib/cjs/tediousPatch.d.ts +0 -9
  54. package/lib/cjs/tediousPatch.d.ts.map +0 -1
  55. package/lib/cjs/tediousPatch.js +0 -25
  56. package/lib/cjs/tediousPatch.js.map +0 -1
  57. package/lib/esm/proxyAgent.d.ts.map +0 -1
  58. package/lib/esm/proxyAgent.js.map +0 -1
  59. package/lib/esm/tediousPatch.d.ts +0 -9
  60. package/lib/esm/tediousPatch.d.ts.map +0 -1
  61. package/lib/esm/tediousPatch.js +0 -25
  62. package/lib/esm/tediousPatch.js.map +0 -1
package/README.md CHANGED
@@ -5,110 +5,101 @@ Node library to enable opening Socket connections via an HTTPS proxy.
5
5
  Based on the implementation in https://github.com/TooTallNate/node-https-proxy-agent,
6
6
  but adapted to expose raw Sockets, instead of just http/https requests.
7
7
 
8
- ## Installation
8
+ ## Proxy for Node mssql (tedious)
9
+ The useProxyForTedious has been removed, if you require this functionality please use v0.2.2 instead.
9
10
 
10
- yarn add @journeyapps/https-proxy-socket
11
+ ## Installation
12
+ ```bash
13
+ yarn add @journeyapps/https-proxy-socket
14
+ npm install @journeyapps/https-proxy-socket
15
+ pnpm add @journeyapps/https-proxy-socket
16
+ ```
11
17
 
12
18
  ## Usage - node-fetch
13
19
 
14
- import { HttpsProxySocket } from '@journeyapps/https-proxy-socket';
15
- import fetch from 'node-fetch';
16
-
17
- /** Proxy connection options */
18
- const proxy = new HttpsProxySocket('https://my-proxy.test', {
19
- /** Proxy auth and headers may be set here, for example: */
20
- auth: 'myuser:mypassword' // Basic auth
21
- });
22
-
23
- const agent = proxy.agent({
24
- /**
25
- * Additional TLS options for the host may be set here, for example:
26
- * rejectUnauthorized: false, // Disable TLS checks completely (dangerous)
27
- * ca: fs.readFileSync('my-ca-cert.pem') // Use a custom CA cert
28
- *
29
- * Documentation of the available options is available here:
30
- * https://nodejs.org/api/tls.html#tls_new_tls_tlssocket_socket_options
31
- * https://nodejs.org/api/tls.html#tls_tls_createsecurecontext_options
32
- */
33
- });
34
-
35
- const response = await fetch('https://myhost.test', { agent: agent });
20
+ ```javascript
21
+ import { HttpsProxySocket } from '@journeyapps/https-proxy-socket';
22
+ import fetch from 'node-fetch';
23
+
24
+ /** Proxy connection options */
25
+ const proxy = new HttpsProxySocket('https://my-proxy.test', {
26
+ /** Proxy auth and headers may be set here, for example: */
27
+ auth: 'myuser:mypassword', // Basic auth
28
+ });
29
+
30
+ const agent = proxy.agent({
31
+ /**
32
+ * Additional TLS options for the host may be set here, for example:
33
+ * rejectUnauthorized: false, // Disable TLS checks completely (dangerous)
34
+ * ca: fs.readFileSync('my-ca-cert.pem') // Use a custom CA cert
35
+ *
36
+ * Documentation of the available options is available here:
37
+ * https://nodejs.org/api/tls.html#tls_new_tls_tlssocket_socket_options
38
+ * https://nodejs.org/api/tls.html#tls_tls_createsecurecontext_options
39
+ */
40
+ });
41
+
42
+ const response = await fetch('https://myhost.test', { agent: agent });
43
+ ```
36
44
 
37
45
  ## Usage - Direct socket
38
46
 
39
- import { HttpsProxySocket } from '@journeyapps/https-proxy-socket';
40
- const proxy = new HttpsProxySocket('https://my-proxy.test');
41
-
42
- const socket = await proxy.connect({host: 'myhost.test', port: 1234});
43
-
44
- ## Usage - mssql
45
-
46
- import sql from 'mssql'
47
- import { HttpsProxySocket, useProxyForTedious } from '@journeyapps/https-proxy-socket';
48
-
49
- const proxy = new HttpsProxySocket({
50
- /** Same as above */
51
- });
52
-
53
- /** Register the proxy globally for tedious/mssql */
54
- useProxyForTedious(proxy);
55
-
56
- async function run() {
57
- /** Connect using the proxy */
58
- await sql.connect('mssql://username:pwd@myserver.database.windows.net/mydb?encrypt=true')
59
- try {
60
- const result = await sql.query`Select TOP(1) * from mytable`
61
- console.dir(result);
62
- } finally {
63
- await sql.close();
64
- }
65
- }
66
-
67
- run().catch(console.error);
47
+ ```javascript
48
+ import { HttpsProxySocket } from '@journeyapps/https-proxy-socket';
49
+ const proxy = new HttpsProxySocket('https://my-proxy.test');
68
50
 
51
+ const socket = await proxy.connect({ host: 'myhost.test', port: 1234 });
52
+ ```
69
53
 
70
54
  ## Usage - MongoDB
55
+
71
56
  The socks package needs to be added to your package.json dependencies for this to work.
72
57
  See the MongoDB documentation for details: https://www.mongodb.com/docs/drivers/node/current/security/socks/
73
58
 
74
- import * as mongo from 'mongodb';
75
- import { useProxyForMongo } from '@journeyapps/https-proxy-socket';
76
-
77
- const SRV_URI = 'mongodb+srv://<username>:<password>@cluster0.jzuewet.mongodb.net';
78
- const PROXY = 'us-cc-proxy.journeyapps.com'; // Or za-cc-proxy.journeyapps.com
79
- const PROXY_PORT = 443
80
-
81
- /**
82
- * Register the proxy globally for MongoDB
83
- * This retuens a close function to end the socket
84
- */
85
- const { close } = useProxyForMongo({
86
- proxy: PROXY,
87
- auth: <egress_token> // See JourneyApps MongoDB Token section below
88
- });
89
-
90
- async function run() {
91
- const client = new mongo.MongoClient(SRV_URI, {
92
- proxyPort: PROXY_PORT,
93
- proxyHost: PROXY,
94
- });
95
- try {
96
- const database = client.db('poc');
97
- const data = database.collection('data');
98
-
99
- const results = await data.find({ index: { $lt: 5 } }).toArray();
100
- console.log(results);
101
- } finally {
102
- close()
103
- await client.close();
104
- }
105
- }
106
-
107
- run().catch(console.error);
59
+ ```javascript
60
+
61
+ import * as mongo from 'mongodb';
62
+ import { useProxyForMongo } from '@journeyapps/https-proxy-socket';
63
+
64
+ const SRV_URI = 'mongodb+srv://<username>:<password>@cluster0.jzuewet.mongodb.net';
65
+ const PROXY = 'us-cc-proxy.journeyapps.com'; // Or za-cc-proxy.journeyapps.com
66
+ const PROXY_PORT = 443
67
+
68
+ /**
69
+ * Register the proxy globally for MongoDB
70
+ * This retuens a close function to end the socket
71
+ */
72
+ const { close } = useProxyForMongo({
73
+ proxy: PROXY,
74
+ auth: <egress_token> // See JourneyApps MongoDB Token section below
75
+ });
76
+
77
+ async function run() {
78
+ const client = new mongo.MongoClient(SRV_URI, {
79
+ proxyPort: PROXY_PORT,
80
+ proxyHost: PROXY,
81
+ });
82
+ try {
83
+ const database = client.db('poc');
84
+ const data = database.collection('data');
85
+
86
+ const results = await data.find({ index: { $lt: 5 } }).toArray();
87
+ console.log(results);
88
+ } finally {
89
+ close()
90
+ await client.close();
91
+ }
92
+ }
93
+
94
+ run().catch(console.error);
95
+ ```
96
+
108
97
  ## JourneyApps MongoDB Token
109
- Using Mongo Atlas usually means the connection is a SRV string. Under the hood Mongo driver converts this to a standard connection string.
98
+
99
+ Using Mongo Atlas usually means the connection is a SRV string. Under the hood Mongo driver converts this to a standard connection string.
110
100
  When the driver opens socket connections it will have one for each replica set member. These connections will need to be allowed by the CloudCode egress proxy to work.
111
- Prior contacting JourneyApps support, get your SRV string and run the following:
101
+ Before contacting JourneyApps support to get your egress token, retrieve your SRV string from Atlas and run the following commands to get the replicas domains:
102
+
112
103
  ```bash
113
104
  # your SRV is mongodb+srv://<username>:<password>@cluster1.vlnzcbp.mongodb.net
114
105
  # You can run it with the included credentials
@@ -116,10 +107,13 @@ npx @journeyapps/https-proxy-socket mongo-replicas mongodb+srv://your_username:y
116
107
  # Or without
117
108
  npx @journeyapps/https-proxy-socket mongo-replicas mongodb+srv://cluster1.vlnzcbp.mongodb.net
118
109
  ```
110
+
119
111
  This will output the below to your console:
120
- ```js
112
+
113
+ ```javascript
121
114
  {
122
- replicas: 'ac-mayaavr-shard-00-02.vlnzcbp.mongodb.net:27017,ac-mayaavr-shard-00-01.vlnzcbp.mongodb.net:27017,ac-mayaavr-shard-00-00.vlnzcbp.mongodb.net:27017'
115
+ replicas: 'ac-mayaavr-shard-00-02.vlnzcbp.mongodb.net:27017,ac-mayaavr-shard-00-01.vlnzcbp.mongodb.net:27017,ac-mayaavr-shard-00-00.vlnzcbp.mongodb.net:27017';
123
116
  }
124
117
  ```
125
- When requesting the token from JourneyApps support, please provide the replicas string as well.
118
+
119
+ When requesting the token from JourneyApps support, please provide the replicas string as well.
@@ -19,24 +19,24 @@ export declare class HttpsProxySocket {
19
19
  proxyConfig: HttpsProxyConfig;
20
20
  /**
21
21
  *
22
- * @param opts - The connection options to the proxy. At least host and port are required.
22
+ * @param options - The connection options to the proxy. At least host and port are required.
23
23
  * Use {rejectUnauthorized: true} to ignore certificates for the proxy (not the endpoint).
24
24
  * @param proxyConfig - { auth: 'username:password' } for basic auth.
25
25
  * { headers: {key: 'value'} } for custom headers.
26
26
  */
27
- constructor(opts: tls.ConnectionOptions | string, proxyConfig?: HttpsProxyConfig);
27
+ constructor(options: tls.ConnectionOptions | string, proxyConfig?: HttpsProxyConfig);
28
28
  /**
29
29
  * Create a new Socket connection.
30
30
  *
31
- * @param opts - host and port
31
+ * @param options - host and port
32
32
  */
33
- connect(opts: ConnectionOptions): Promise<tls.TLSSocket>;
33
+ connect(options: ConnectionOptions): Promise<tls.TLSSocket>;
34
34
  /**
35
35
  * Construct an agent for http(s) requests.
36
36
  *
37
37
  * @param options - to set additional TLS options for https requests, e.g. rejectUnauthorized
38
38
  */
39
- agent(options?: tls.ConnectionOptions): import("agent-base").Agent;
39
+ agent(options?: tls.ConnectionOptions): import("./ProxyAgent").ProxyAgent;
40
40
  private _connect;
41
41
  }
42
42
  //# sourceMappingURL=HttpsProxySocket.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"HttpsProxySocket.d.ts","sourceRoot":"","sources":["../../src/HttpsProxySocket.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAM3B,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,IAAI,EAAE,GAAG,CAAC,iBAAiB,GAAG,MAAM,EAAE,WAAW,CAAC,EAAE,gBAAgB;IAqBhF;;;;OAIG;IACH,OAAO,CAAC,IAAI,EAAE,iBAAiB,GAAG,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC;IAexD;;;;OAIG;IACH,KAAK,CAAC,OAAO,CAAC,EAAE,GAAG,CAAC,iBAAiB;IAIrC,OAAO,CAAC,QAAQ;CAwHjB"}
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;YAIvB,QAAQ;CAsHvB"}
@@ -1,5 +1,4 @@
1
1
  "use strict";
2
- // Based on https://github.com/TooTallNate/node-https-proxy-agent
3
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
3
  if (k2 === undefined) k2 = k;
5
4
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -36,8 +35,9 @@ var __importStar = (this && this.__importStar) || (function () {
36
35
  Object.defineProperty(exports, "__esModule", { value: true });
37
36
  exports.HttpsProxySocket = void 0;
38
37
  const tls = __importStar(require("tls"));
39
- const url = __importStar(require("url"));
40
- const proxyAgent_js_1 = require("./proxyAgent.js");
38
+ const createProxyAgent_1 = require("./createProxyAgent");
39
+ const setServername_1 = require("./utils/setServername");
40
+ const parseOptions_1 = require("./utils/parseOptions");
41
41
  const util_1 = require("util");
42
42
  const debug = (0, util_1.debug)('https-proxy');
43
43
  /**
@@ -50,24 +50,14 @@ class HttpsProxySocket {
50
50
  proxyConfig;
51
51
  /**
52
52
  *
53
- * @param opts - The connection options to the proxy. At least host and port are required.
53
+ * @param options - The connection options to the proxy. At least host and port are required.
54
54
  * Use {rejectUnauthorized: true} to ignore certificates for the proxy (not the endpoint).
55
55
  * @param proxyConfig - { auth: 'username:password' } for basic auth.
56
56
  * { headers: {key: 'value'} } for custom headers.
57
57
  */
58
- constructor(opts, proxyConfig) {
59
- let sanitizedOptions;
60
- if (typeof opts == 'string') {
61
- let parsedOptions = url.parse(opts);
62
- sanitizedOptions = {
63
- host: parsedOptions.hostname || parsedOptions.host,
64
- port: parseInt(parsedOptions.port || '443'),
65
- };
66
- }
67
- else {
68
- sanitizedOptions = Object.assign({}, opts);
69
- }
70
- if (!opts) {
58
+ constructor(options, proxyConfig) {
59
+ const sanitizedOptions = (0, parseOptions_1.parseOptions)(options);
60
+ if (!options) {
71
61
  throw new Error('an HTTP(S) proxy server `host` and `port` must be specified!');
72
62
  }
73
63
  debug('creating new HttpsProxyAgent instance: %o', sanitizedOptions);
@@ -77,11 +67,11 @@ class HttpsProxySocket {
77
67
  /**
78
68
  * Create a new Socket connection.
79
69
  *
80
- * @param opts - host and port
70
+ * @param options - host and port
81
71
  */
82
- connect(opts) {
83
- return new Promise((resolve, reject) => {
84
- this._connect(opts, (error, socket) => {
72
+ connect(options) {
73
+ return new Promise(async (resolve, reject) => {
74
+ await this._connect(options, (error, socket) => {
85
75
  if (error) {
86
76
  reject(error);
87
77
  }
@@ -100,12 +90,12 @@ class HttpsProxySocket {
100
90
  * @param options - to set additional TLS options for https requests, e.g. rejectUnauthorized
101
91
  */
102
92
  agent(options) {
103
- return (0, proxyAgent_js_1.proxyAgent)(this, options);
93
+ return (0, createProxyAgent_1.createProxyAgent)(this, options);
104
94
  }
105
- _connect(opts, cb) {
95
+ async _connect(opts, cb) {
106
96
  const proxy = this.proxy;
107
97
  // create a socket connection to the proxy server
108
- const socket = tls.connect(proxy);
98
+ const socket = tls.connect((0, setServername_1.setServername)(proxy));
109
99
  // we need to buffer any HTTP traffic that happens with the proxy before we get
110
100
  // the CONNECT response, so that if the response is anything other than an "200"
111
101
  // response code, then we can re-play the "data" events on the socket once the
@@ -190,8 +180,8 @@ class HttpsProxySocket {
190
180
  socket.once('data', ondata);
191
181
  }
192
182
  const host = `${opts.host}:${opts.port}`;
193
- var msg = 'CONNECT ' + host + ' HTTP/1.1\r\n';
194
- var headers = Object.assign({}, this.proxyConfig.headers);
183
+ let msg = 'CONNECT ' + host + ' HTTP/1.1\r\n';
184
+ const headers = Object.assign({}, this.proxyConfig.headers);
195
185
  if (this.proxyConfig.auth) {
196
186
  headers['Proxy-Authorization'] = 'Basic ' + Buffer.from(this.proxyConfig.auth).toString('base64');
197
187
  }
@@ -1 +1 @@
1
- {"version":3,"file":"HttpsProxySocket.js","sourceRoot":"","sources":["../../src/HttpsProxySocket.ts"],"names":[],"mappings":";AAAA,iEAAiE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEjE,yCAA2B;AAC3B,yCAA2B;AAC3B,mDAA6C;AAC7C,+BAA0C;AAC1C,MAAM,KAAK,GAAG,IAAA,YAAS,EAAC,aAAa,CAAC,CAAC;AAYvC;;;;GAIG;AACH,MAAa,gBAAgB;IAC3B,KAAK,CAAwB;IAC7B,WAAW,CAAmB;IAE9B;;;;;;OAMG;IACH,YAAY,IAAoC,EAAE,WAA8B;QAC9E,IAAI,gBAAgB,CAAC;QACrB,IAAI,OAAO,IAAI,IAAI,QAAQ,EAAE,CAAC;YAC5B,IAAI,aAAa,GAAG,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YACpC,gBAAgB,GAAG;gBACjB,IAAI,EAAE,aAAa,CAAC,QAAQ,IAAI,aAAa,CAAC,IAAI;gBAClD,IAAI,EAAE,QAAQ,CAAC,aAAa,CAAC,IAAI,IAAI,KAAK,CAAC;aAC5C,CAAC;QACJ,CAAC;aAAM,CAAC;YACN,gBAAgB,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;QAC7C,CAAC;Q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
@@ -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"}
@@ -32,40 +32,36 @@ var __importStar = (this && this.__importStar) || (function () {
32
32
  return result;
33
33
  };
34
34
  })();
35
- var __importDefault = (this && this.__importDefault) || function (mod) {
36
- return (mod && mod.__esModule) ? mod : { "default": mod };
37
- };
38
35
  Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.proxyAgent = proxyAgent;
40
- const agent_base_1 = __importDefault(require("agent-base"));
36
+ exports.ProxyAgent = void 0;
37
+ const agent_base_1 = require("agent-base");
41
38
  const tls = __importStar(require("tls"));
42
- /**
43
- * Construct an agent for http(s) requests. Mostly for testing purposes.
44
- *
45
- * @param proxy - the proxy to use
46
- * @param options - to set additional TLS options for https requests, e.g. rejectUnauthorized
47
- */
48
- function proxyAgent(proxy, options) {
49
- return (0, agent_base_1.default)(async (_, opts) => {
50
- const socket = await proxy.connect(opts);
51
- if (opts.secureEndpoint) {
52
- // Upgrade to 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) {
53
50
  let tlsOptions = {
54
51
  socket: socket,
55
- servername: opts.servername || opts.host,
52
+ servername: options.servername || options.host,
56
53
  };
57
- if (typeof opts.rejectUnauthorized != 'undefined') {
58
- // There's a difference between 'undefined' (equivalent of false) and "not set" (equivalent of true)
59
- tlsOptions.rejectUnauthorized = opts.rejectUnauthorized;
54
+ if (typeof options.rejectUnauthorized != 'undefined') {
55
+ tlsOptions.rejectUnauthorized = options.rejectUnauthorized;
60
56
  }
61
- Object.assign(tlsOptions, options);
62
- const tlsSocket = tls.connect(tlsOptions);
63
- return tlsSocket;
57
+ Object.assign(tlsOptions, this.agentOptions);
58
+ return tls.connect(tlsOptions);
64
59
  }
65
60
  else {
66
61
  socket.resume();
67
62
  return socket;
68
63
  }
69
- });
64
+ }
70
65
  }
71
- //# sourceMappingURL=proxyAgent.js.map
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"}
@@ -1,11 +1,11 @@
1
1
  import { HttpsProxySocket } from './HttpsProxySocket.js';
2
- import agentBase from 'agent-base';
3
- import * as tls from 'tls';
2
+ import { ProxyAgent } from './ProxyAgent';
3
+ import * as http from 'node:http';
4
4
  /**
5
5
  * Construct an agent for http(s) requests. Mostly for testing purposes.
6
6
  *
7
7
  * @param proxy - the proxy to use
8
8
  * @param options - to set additional TLS options for https requests, e.g. rejectUnauthorized
9
9
  */
10
- export declare function proxyAgent(proxy: HttpsProxySocket, options?: tls.ConnectionOptions): agentBase.Agent;
11
- //# sourceMappingURL=proxyAgent.d.ts.map
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"}
@@ -1,4 +1,3 @@
1
1
  export * from './HttpsProxySocket.js';
2
- export * from './tediousPatch.js';
3
2
  export * from './mongoPatch.js';
4
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,iBAAiB,CAAC"}
package/lib/cjs/index.js CHANGED
@@ -15,6 +15,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./HttpsProxySocket.js"), exports);
18
- __exportStar(require("./tediousPatch.js"), exports);
19
18
  __exportStar(require("./mongoPatch.js"), exports);
20
19
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wDAAsC;AACtC,oDAAkC;AAClC,kDAAgC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wDAAsC;AACtC,kDAAgC"}
@@ -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"}
@@ -19,24 +19,24 @@ export declare class HttpsProxySocket {
19
19
  proxyConfig: HttpsProxyConfig;
20
20
  /**
21
21
  *
22
- * @param opts - The connection options to the proxy. At least host and port are required.
22
+ * @param options - The connection options to the proxy. At least host and port are required.
23
23
  * Use {rejectUnauthorized: true} to ignore certificates for the proxy (not the endpoint).
24
24
  * @param proxyConfig - { auth: 'username:password' } for basic auth.
25
25
  * { headers: {key: 'value'} } for custom headers.
26
26
  */
27
- constructor(opts: tls.ConnectionOptions | string, proxyConfig?: HttpsProxyConfig);
27
+ constructor(options: tls.ConnectionOptions | string, proxyConfig?: HttpsProxyConfig);
28
28
  /**
29
29
  * Create a new Socket connection.
30
30
  *
31
- * @param opts - host and port
31
+ * @param options - host and port
32
32
  */
33
- connect(opts: ConnectionOptions): Promise<tls.TLSSocket>;
33
+ connect(options: ConnectionOptions): Promise<tls.TLSSocket>;
34
34
  /**
35
35
  * Construct an agent for http(s) requests.
36
36
  *
37
37
  * @param options - to set additional TLS options for https requests, e.g. rejectUnauthorized
38
38
  */
39
- agent(options?: tls.ConnectionOptions): import("agent-base").Agent;
39
+ agent(options?: tls.ConnectionOptions): import("./ProxyAgent").ProxyAgent;
40
40
  private _connect;
41
41
  }
42
42
  //# sourceMappingURL=HttpsProxySocket.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"HttpsProxySocket.d.ts","sourceRoot":"","sources":["../../src/HttpsProxySocket.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAM3B,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,qBA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  "use strict";
2
- // Based on https://github.com/TooTallNate/node-https-proxy-agent
3
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
3
  if (k2 === undefined) k2 = k;
5
4
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -36,8 +35,9 @@ var __importStar = (this && this.__importStar) || (function () {
36
35
  Object.defineProperty(exports, "__esModule", { value: true });
37
36
  exports.HttpsProxySocket = void 0;
38
37
  const tls = __importStar(require("tls"));
39
- const url = __importStar(require("url"));
40
- const proxyAgent_js_1 = require("./proxyAgent.js");
38
+ const createProxyAgent_1 = require("./createProxyAgent");
39
+ const setServername_1 = require("./utils/setServername");
40
+ const parseOptions_1 = require("./utils/parseOptions");
41
41
  const util_1 = require("util");
42
42
  const debug = (0, util_1.debug)('https-proxy');
43
43
  /**
@@ -50,24 +50,14 @@ class HttpsProxySocket {
50
50
  proxyConfig;
51
51
  /**
52
52
  *
53
- * @param opts - The connection options to the proxy. At least host and port are required.
53
+ * @param options - The connection options to the proxy. At least host and port are required.
54
54
  * Use {rejectUnauthorized: true} to ignore certificates for the proxy (not the endpoint).
55
55
  * @param proxyConfig - { auth: 'username:password' } for basic auth.
56
56
  * { headers: {key: 'value'} } for custom headers.
57
57
  */
58
- constructor(opts, proxyConfig) {
59
- let sanitizedOptions;
60
- if (typeof opts == 'string') {
61
- let parsedOptions = url.parse(opts);
62
- sanitizedOptions = {
63
- host: parsedOptions.hostname || parsedOptions.host,
64
- port: parseInt(parsedOptions.port || '443'),
65
- };
66
- }
67
- else {
68
- sanitizedOptions = Object.assign({}, opts);
69
- }
70
- if (!opts) {
58
+ constructor(options, proxyConfig) {
59
+ const sanitizedOptions = (0, parseOptions_1.parseOptions)(options);
60
+ if (!options) {
71
61
  throw new Error('an HTTP(S) proxy server `host` and `port` must be specified!');
72
62
  }
73
63
  debug('creating new HttpsProxyAgent instance: %o', sanitizedOptions);
@@ -77,11 +67,11 @@ class HttpsProxySocket {
77
67
  /**
78
68
  * Create a new Socket connection.
79
69
  *
80
- * @param opts - host and port
70
+ * @param options - host and port
81
71
  */
82
- connect(opts) {
83
- return new Promise((resolve, reject) => {
84
- this._connect(opts, (error, socket) => {
72
+ connect(options) {
73
+ return new Promise(async (resolve, reject) => {
74
+ await this._connect(options, (error, socket) => {
85
75
  if (error) {
86
76
  reject(error);
87
77
  }
@@ -100,12 +90,12 @@ class HttpsProxySocket {
100
90
  * @param options - to set additional TLS options for https requests, e.g. rejectUnauthorized
101
91
  */
102
92
  agent(options) {
103
- return (0, proxyAgent_js_1.proxyAgent)(this, options);
93
+ return (0, createProxyAgent_1.createProxyAgent)(this, options);
104
94
  }
105
- _connect(opts, cb) {
95
+ async _connect(opts, cb) {
106
96
  const proxy = this.proxy;
107
97
  // create a socket connection to the proxy server
108
- const socket = tls.connect(proxy);
98
+ const socket = tls.connect((0, setServername_1.setServername)(proxy));
109
99
  // we need to buffer any HTTP traffic that happens with the proxy before we get
110
100
  // the CONNECT response, so that if the response is anything other than an "200"
111
101
  // response code, then we can re-play the "data" events on the socket once the
@@ -190,8 +180,8 @@ class HttpsProxySocket {
190
180
  socket.once('data', ondata);
191
181
  }
192
182
  const host = `${opts.host}:${opts.port}`;
193
- var msg = 'CONNECT ' + host + ' HTTP/1.1\r\n';
194
- var headers = Object.assign({}, this.proxyConfig.headers);
183
+ let msg = 'CONNECT ' + host + ' HTTP/1.1\r\n';
184
+ const headers = Object.assign({}, this.proxyConfig.headers);
195
185
  if (this.proxyConfig.auth) {
196
186
  headers['Proxy-Authorization'] = 'Basic ' + Buffer.from(this.proxyConfig.auth).toString('base64');
197
187
  }
@@ -1 +1 @@
1
- {"version":3,"file":"HttpsProxySocket.js","sourceRoot":"","sources":["../../src/HttpsProxySocket.ts"],"names":[],"mappings":";AAAA,iEAAiE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEjE,yCAA2B;AAC3B,yCAA2B;AAC3B,mDAA6C;AAC7C,+BAA0C;AAC1C,MAAM,KAAK,GAA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5D,IAAI,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC;YAC1B,OAAO,CAAC,qBAAqB,CAAC,GAAG,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QACpG,CAAC;QACD,OAAO,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;QACvB,OAAO,CAAC,YAAY,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"}
@@ -32,40 +32,36 @@ var __importStar = (this && this.__importStar) || (function () {
32
32
  return result;
33
33
  };
34
34
  })();
35
- var __importDefault = (this && this.__importDefault) || function (mod) {
36
- return (mod && mod.__esModule) ? mod : { "default": mod };
37
- };
38
35
  Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.proxyAgent = proxyAgent;
40
- const agent_base_1 = __importDefault(require("agent-base"));
36
+ exports.ProxyAgent = void 0;
37
+ const agent_base_1 = require("agent-base");
41
38
  const tls = __importStar(require("tls"));
42
- /**
43
- * Construct an agent for http(s) requests. Mostly for testing purposes.
44
- *
45
- * @param proxy - the proxy to use
46
- * @param options - to set additional TLS options for https requests, e.g. rejectUnauthorized
47
- */
48
- function proxyAgent(proxy, options) {
49
- return (0, agent_base_1.default)(async (_, opts) => {
50
- const socket = await proxy.connect(opts);
51
- if (opts.secureEndpoint) {
52
- // Upgrade to 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) {
53
50
  let tlsOptions = {
54
51
  socket: socket,
55
- servername: opts.servername || opts.host,
52
+ servername: options.servername || options.host,
56
53
  };
57
- if (typeof opts.rejectUnauthorized != 'undefined') {
58
- // There's a difference between 'undefined' (equivalent of false) and "not set" (equivalent of true)
59
- tlsOptions.rejectUnauthorized = opts.rejectUnauthorized;
54
+ if (typeof options.rejectUnauthorized != 'undefined') {
55
+ tlsOptions.rejectUnauthorized = options.rejectUnauthorized;
60
56
  }
61
- Object.assign(tlsOptions, options);
62
- const tlsSocket = tls.connect(tlsOptions);
63
- return tlsSocket;
57
+ Object.assign(tlsOptions, this.agentOptions);
58
+ return tls.connect(tlsOptions);
64
59
  }
65
60
  else {
66
61
  socket.resume();
67
62
  return socket;
68
63
  }
69
- });
64
+ }
70
65
  }
71
- //# sourceMappingURL=proxyAgent.js.map
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"}
@@ -1,11 +1,11 @@
1
1
  import { HttpsProxySocket } from './HttpsProxySocket.js';
2
- import agentBase from 'agent-base';
3
- import * as tls from 'tls';
2
+ import { ProxyAgent } from './ProxyAgent';
3
+ import * as http from 'node:http';
4
4
  /**
5
5
  * Construct an agent for http(s) requests. Mostly for testing purposes.
6
6
  *
7
7
  * @param proxy - the proxy to use
8
8
  * @param options - to set additional TLS options for https requests, e.g. rejectUnauthorized
9
9
  */
10
- export declare function proxyAgent(proxy: HttpsProxySocket, options?: tls.ConnectionOptions): agentBase.Agent;
11
- //# sourceMappingURL=proxyAgent.d.ts.map
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"}
@@ -1,4 +1,3 @@
1
1
  export * from './HttpsProxySocket.js';
2
- export * from './tediousPatch.js';
3
2
  export * from './mongoPatch.js';
4
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,iBAAiB,CAAC"}
package/lib/esm/index.js CHANGED
@@ -15,6 +15,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./HttpsProxySocket.js"), exports);
18
- __exportStar(require("./tediousPatch.js"), exports);
19
18
  __exportStar(require("./mongoPatch.js"), exports);
20
19
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wDAAsC;AACtC,oDAAkC;AAClC,kDAAgC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wDAAsC;AACtC,kDAAgC"}
@@ -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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@journeyapps/https-proxy-socket",
3
- "version": "0.0.0-dev.70e6967",
3
+ "version": "0.0.0-dev.73fb7f7",
4
4
  "author": "JourneyApps",
5
5
  "repository": "journeyapps/https-proxy-socket",
6
6
  "license": "MIT",
@@ -24,8 +24,8 @@
24
24
  "devDependencies": {
25
25
  "@types/agent-base": "^4.2.0",
26
26
  "@types/node": "^24.7.2",
27
+ "async-listen": "^3.1.0",
27
28
  "lerna": "^9.0.0",
28
- "mssql": "^12.0.0",
29
29
  "node-fetch": "^3.3.2",
30
30
  "prettier": "^3.6.2",
31
31
  "proxy": "^2.2.0",
@@ -33,7 +33,7 @@
33
33
  "vitest": "^3.2.4"
34
34
  },
35
35
  "dependencies": {
36
- "agent-base": "^6.0.2",
36
+ "agent-base": "^7.1.4",
37
37
  "socks": "^2.8.7"
38
38
  },
39
39
  "files": [
@@ -1 +0,0 @@
1
- {"version":3,"file":"proxyAgent.d.ts","sourceRoot":"","sources":["../../src/pro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B,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -1,9 +0,0 @@
1
- import { HttpsProxySocket } from './HttpsProxySocket.js';
2
- /**
3
- * Replace the connection method on the tedious library (used by mssql)
4
- * to connect via a proxy.
5
- *
6
- * @param proxy - the proxy to use
7
- */
8
- export declare function useProxyForTedious(proxy: HttpsProxySocket): void;
9
- //# sourceMappingURL=tediousPatch.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tediousPatch.d.ts","sourceRoot":"","sources":["../../src/tediousPatch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAIzD;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,gBAAgB,QAWzD"}
@@ -1,25 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useProxyForTedious = useProxyForTedious;
4
- const util_1 = require("util");
5
- const debug = (0, util_1.debug)('https-proxy');
6
- /**
7
- * Replace the connection method on the tedious library (used by mssql)
8
- * to connect via a proxy.
9
- *
10
- * @param proxy - the proxy to use
11
- */
12
- function useProxyForTedious(proxy) {
13
- const { Connector } = require('tedious/lib/connector');
14
- Connector.prototype.execute = async function (cb) {
15
- debug(`opening sql connection to ${this.options.host}:${this.options.port}`);
16
- try {
17
- const socket = await proxy.connect(this.options);
18
- cb(null, socket);
19
- }
20
- catch (error) {
21
- cb(error);
22
- }
23
- };
24
- }
25
- //# sourceMappingURL=tediousPatch.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tediousPatch.js","sourceRoot":"","sources":["../../src/tediousPatch.ts"],"names":[],"mappings":";;AAUA,gDAWC;AApBD,+BAA0C;AAC1C,MAAM,KAAK,GAAG,IAAA,YAAS,EAAC,aAAa,CAAC,CAAC;AAEvC;;;;;GAKG;AACH,SAAgB,kBAAkB,CAAC,KAAuB;IACxD,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC;IACvD,SAAS,CAAC,SAAS,CAAC,OAAO,GAAG,KAAK,WAAW,EAAO;QACnD,KAAK,CAAC,6BAA6B,IAAI,CAAC,OAAO,CAAC,IAAI,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;QAC7E,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YACjD,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QACnB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,EAAE,CAAC,KAAK,CAAC,CAAC;QACZ,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"proxyAgent.d.ts","sourceRoot":"","sources":["../../src/proxyAgent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,SAAS,MAAM,YAAY,CAAC;AACnC,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAE3B;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,gBAAgB,EAAE,OAAO,CAAC,EAAE,GAAG,CAAC,iBAAiB,mBAsBlF"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"proxyAgent.js","sourceRoot":"","sources":["../../src/proxyAgent.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUA,gCAsBC;AA/BD,4DAAmC;AACnC,yCAA2B;AAE3B;;;;;GAKG;AACH,SAAgB,UAAU,CAAC,KAAuB,EAAE,OAA+B;IACjF,OAAO,IAAA,oBAAS,EAAC,KAAK,EAAE,CAAC,EAAE,IAAS,EAAE,EAAE;QACtC,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAEzC,IAAI,IAAI,CAAC,cAAc,EAAE,CAAC;YACxB,iBAAiB;YACjB,IAAI,UAAU,GAA0B;gBACtC,MAAM,EAAE,MAAM;gBACd,UAAU,EAAE,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,IAAI;aACzC,CAAC;YACF,IAAI,OAAO,IAAI,CAAC,kBAAkB,IAAI,WAAW,EAAE,CAAC;gBAClD,oGAAoG;gBACpG,UAAU,CAAC,kBAAkB,GAAG,IAAI,CAAC,kBAAkB,CAAC;YAC1D,CAAC;YACD,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;YACnC,MAAM,SAAS,GAAG,GAAG,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;YAC1C,OAAO,SAAS,CAAC;QACnB,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,MAAM,EAAE,CAAC;YAChB,OAAO,MAAM,CAAC;QAChB,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -1,9 +0,0 @@
1
- import { HttpsProxySocket } from './HttpsProxySocket.js';
2
- /**
3
- * Replace the connection method on the tedious library (used by mssql)
4
- * to connect via a proxy.
5
- *
6
- * @param proxy - the proxy to use
7
- */
8
- export declare function useProxyForTedious(proxy: HttpsProxySocket): void;
9
- //# sourceMappingURL=tediousPatch.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tediousPatch.d.ts","sourceRoot":"","sources":["../../src/tediousPatch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAIzD;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,gBAAgB,QAWzD"}
@@ -1,25 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useProxyForTedious = useProxyForTedious;
4
- const util_1 = require("util");
5
- const debug = (0, util_1.debug)('https-proxy');
6
- /**
7
- * Replace the connection method on the tedious library (used by mssql)
8
- * to connect via a proxy.
9
- *
10
- * @param proxy - the proxy to use
11
- */
12
- function useProxyForTedious(proxy) {
13
- const { Connector } = require('tedious/lib/connector');
14
- Connector.prototype.execute = async function (cb) {
15
- debug(`opening sql connection to ${this.options.host}:${this.options.port}`);
16
- try {
17
- const socket = await proxy.connect(this.options);
18
- cb(null, socket);
19
- }
20
- catch (error) {
21
- cb(error);
22
- }
23
- };
24
- }
25
- //# sourceMappingURL=tediousPatch.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tediousPatch.js","sourceRoot":"","sources":["../../src/tediousPatch.ts"],"names":[],"mappings":";;AAUA,gDAWC;AApBD,+BAA0C;AAC1C,MAAM,KAAK,GAAG,IAAA,YAAS,EAAC,aAAa,CAAC,CAAC;AAEvC;;;;;GAKG;AACH,SAAgB,kBAAkB,CAAC,KAAuB;IACxD,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC;IACvD,SAAS,CAAC,SAAS,CAAC,OAAO,GAAG,KAAK,WAAW,EAAO;QACnD,KAAK,CAAC,6BAA6B,IAAI,CAAC,OAAO,CAAC,IAAI,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;QAC7E,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YACjD,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QACnB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,EAAE,CAAC,KAAK,CAAC,CAAC;QACZ,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}