@journeyapps/https-proxy-socket 0.0.0-dev.670184a → 0.0.0-dev.70e6967
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/README.md +45 -21
- package/lib/cjs/HttpsProxySocket.js +8 -5
- package/lib/cjs/HttpsProxySocket.js.map +1 -1
- package/lib/cjs/bin/mongoReplicas.d.ts +3 -0
- package/lib/cjs/bin/mongoReplicas.d.ts.map +1 -0
- package/lib/cjs/bin/mongoReplicas.js +26 -0
- package/lib/cjs/bin/mongoReplicas.js.map +1 -0
- package/lib/cjs/index.d.ts +3 -3
- package/lib/cjs/index.d.ts.map +1 -1
- package/lib/cjs/index.js +3 -3
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/mongoPatch.js +3 -3
- package/lib/cjs/mongoPatch.js.map +1 -1
- package/lib/cjs/proxyAgent.d.ts +1 -1
- package/lib/cjs/proxyAgent.d.ts.map +1 -1
- package/lib/cjs/proxyAgent.js +2 -2
- package/lib/cjs/proxyAgent.js.map +1 -1
- package/lib/cjs/tediousPatch.d.ts +1 -1
- package/lib/cjs/tediousPatch.d.ts.map +1 -1
- package/lib/cjs/tediousPatch.js +2 -1
- package/lib/cjs/tediousPatch.js.map +1 -1
- package/lib/esm/HttpsProxySocket.js +48 -8
- package/lib/esm/HttpsProxySocket.js.map +1 -1
- package/lib/esm/bin/mongoReplicas.d.ts +3 -0
- package/lib/esm/bin/mongoReplicas.d.ts.map +1 -0
- package/lib/esm/bin/mongoReplicas.js +26 -0
- package/lib/esm/bin/mongoReplicas.js.map +1 -0
- package/lib/esm/index.d.ts +3 -3
- package/lib/esm/index.d.ts.map +1 -1
- package/lib/esm/index.js +19 -3
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/mongoPatch.js +41 -5
- package/lib/esm/mongoPatch.js.map +1 -1
- package/lib/esm/proxyAgent.d.ts +1 -1
- package/lib/esm/proxyAgent.d.ts.map +1 -1
- package/lib/esm/proxyAgent.js +44 -5
- package/lib/esm/proxyAgent.js.map +1 -1
- package/lib/esm/tediousPatch.d.ts +1 -1
- package/lib/esm/tediousPatch.d.ts.map +1 -1
- package/lib/esm/tediousPatch.js +6 -2
- package/lib/esm/tediousPatch.js.map +1 -1
- package/package.json +20 -20
package/README.md
CHANGED
|
@@ -11,48 +11,50 @@ but adapted to expose raw Sockets, instead of just http/https requests.
|
|
|
11
11
|
|
|
12
12
|
## Usage - node-fetch
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
import { HttpsProxySocket } from '@journeyapps/https-proxy-socket';
|
|
15
|
+
import fetch from 'node-fetch';
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
/** Proxy connection options */
|
|
18
18
|
const proxy = new HttpsProxySocket('https://my-proxy.test', {
|
|
19
|
-
|
|
19
|
+
/** Proxy auth and headers may be set here, for example: */
|
|
20
20
|
auth: 'myuser:mypassword' // Basic auth
|
|
21
21
|
});
|
|
22
22
|
|
|
23
23
|
const agent = proxy.agent({
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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
|
+
*/
|
|
31
33
|
});
|
|
32
34
|
|
|
33
35
|
const response = await fetch('https://myhost.test', { agent: agent });
|
|
34
36
|
|
|
35
37
|
## Usage - Direct socket
|
|
36
38
|
|
|
37
|
-
|
|
39
|
+
import { HttpsProxySocket } from '@journeyapps/https-proxy-socket';
|
|
38
40
|
const proxy = new HttpsProxySocket('https://my-proxy.test');
|
|
39
41
|
|
|
40
42
|
const socket = await proxy.connect({host: 'myhost.test', port: 1234});
|
|
41
43
|
|
|
42
44
|
## Usage - mssql
|
|
43
45
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
+
import sql from 'mssql'
|
|
47
|
+
import { HttpsProxySocket, useProxyForTedious } from '@journeyapps/https-proxy-socket';
|
|
46
48
|
|
|
47
49
|
const proxy = new HttpsProxySocket({
|
|
48
|
-
|
|
50
|
+
/** Same as above */
|
|
49
51
|
});
|
|
50
52
|
|
|
51
|
-
|
|
53
|
+
/** Register the proxy globally for tedious/mssql */
|
|
52
54
|
useProxyForTedious(proxy);
|
|
53
55
|
|
|
54
56
|
async function run() {
|
|
55
|
-
|
|
57
|
+
/** Connect using the proxy */
|
|
56
58
|
await sql.connect('mssql://username:pwd@myserver.database.windows.net/mydb?encrypt=true')
|
|
57
59
|
try {
|
|
58
60
|
const result = await sql.query`Select TOP(1) * from mytable`
|
|
@@ -76,10 +78,13 @@ See the MongoDB documentation for details: https://www.mongodb.com/docs/drivers/
|
|
|
76
78
|
const PROXY = 'us-cc-proxy.journeyapps.com'; // Or za-cc-proxy.journeyapps.com
|
|
77
79
|
const PROXY_PORT = 443
|
|
78
80
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
+
/**
|
|
82
|
+
* Register the proxy globally for MongoDB
|
|
83
|
+
* This retuens a close function to end the socket
|
|
84
|
+
*/
|
|
85
|
+
const { close } = useProxyForMongo({
|
|
81
86
|
proxy: PROXY,
|
|
82
|
-
auth: <egress_token>
|
|
87
|
+
auth: <egress_token> // See JourneyApps MongoDB Token section below
|
|
83
88
|
});
|
|
84
89
|
|
|
85
90
|
async function run() {
|
|
@@ -94,8 +99,27 @@ See the MongoDB documentation for details: https://www.mongodb.com/docs/drivers/
|
|
|
94
99
|
const results = await data.find({ index: { $lt: 5 } }).toArray();
|
|
95
100
|
console.log(results);
|
|
96
101
|
} finally {
|
|
97
|
-
|
|
102
|
+
close()
|
|
103
|
+
await client.close();
|
|
98
104
|
}
|
|
99
105
|
}
|
|
100
106
|
|
|
101
107
|
run().catch(console.error);
|
|
108
|
+
## 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.
|
|
110
|
+
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:
|
|
112
|
+
```bash
|
|
113
|
+
# your SRV is mongodb+srv://<username>:<password>@cluster1.vlnzcbp.mongodb.net
|
|
114
|
+
# You can run it with the included credentials
|
|
115
|
+
npx @journeyapps/https-proxy-socket mongo-replicas mongodb+srv://your_username:your_password@cluster1.vlnzcbp.mongodb.net
|
|
116
|
+
# Or without
|
|
117
|
+
npx @journeyapps/https-proxy-socket mongo-replicas mongodb+srv://cluster1.vlnzcbp.mongodb.net
|
|
118
|
+
```
|
|
119
|
+
This will output the below to your console:
|
|
120
|
+
```js
|
|
121
|
+
{
|
|
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'
|
|
123
|
+
}
|
|
124
|
+
```
|
|
125
|
+
When requesting the token from JourneyApps support, please provide the replicas string as well.
|
|
@@ -37,14 +37,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
37
37
|
exports.HttpsProxySocket = void 0;
|
|
38
38
|
const tls = __importStar(require("tls"));
|
|
39
39
|
const url = __importStar(require("url"));
|
|
40
|
-
const
|
|
41
|
-
const
|
|
40
|
+
const proxyAgent_js_1 = require("./proxyAgent.js");
|
|
41
|
+
const util_1 = require("util");
|
|
42
|
+
const debug = (0, util_1.debug)('https-proxy');
|
|
42
43
|
/**
|
|
43
44
|
* The HttpsProxySocket class allows creating Socket connections via an HTTPS proxy.
|
|
44
45
|
* HTTP proxies are not supported.
|
|
45
46
|
* For http(s) requests, use HttpsProxyAgent as a wrapper around this.
|
|
46
47
|
*/
|
|
47
48
|
class HttpsProxySocket {
|
|
49
|
+
proxy;
|
|
50
|
+
proxyConfig;
|
|
48
51
|
/**
|
|
49
52
|
*
|
|
50
53
|
* @param opts - The connection options to the proxy. At least host and port are required.
|
|
@@ -58,7 +61,7 @@ class HttpsProxySocket {
|
|
|
58
61
|
let parsedOptions = url.parse(opts);
|
|
59
62
|
sanitizedOptions = {
|
|
60
63
|
host: parsedOptions.hostname || parsedOptions.host,
|
|
61
|
-
port: parseInt(parsedOptions.port || '443')
|
|
64
|
+
port: parseInt(parsedOptions.port || '443'),
|
|
62
65
|
};
|
|
63
66
|
}
|
|
64
67
|
else {
|
|
@@ -84,7 +87,7 @@ class HttpsProxySocket {
|
|
|
84
87
|
}
|
|
85
88
|
else {
|
|
86
89
|
if (!socket) {
|
|
87
|
-
return reject(new Error(
|
|
90
|
+
return reject(new Error('No socket returned from proxy'));
|
|
88
91
|
}
|
|
89
92
|
resolve(socket);
|
|
90
93
|
}
|
|
@@ -97,7 +100,7 @@ class HttpsProxySocket {
|
|
|
97
100
|
* @param options - to set additional TLS options for https requests, e.g. rejectUnauthorized
|
|
98
101
|
*/
|
|
99
102
|
agent(options) {
|
|
100
|
-
return (0,
|
|
103
|
+
return (0, proxyAgent_js_1.proxyAgent)(this, options);
|
|
101
104
|
}
|
|
102
105
|
_connect(opts, cb) {
|
|
103
106
|
const proxy = this.proxy;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HttpsProxySocket.js","sourceRoot":"","sources":["../../src/HttpsProxySocket.ts"],"names":[],"mappings":";AAAA,iEAAiE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEjE,yCAA2B;AAC3B,yCAA2B;AAC3B,
|
|
1
|
+
{"version":3,"file":"HttpsProxySocket.js","sourceRoot":"","sources":["../../src/HttpsProxySocket.ts"],"names":[],"mappings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,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QACpG,CAAC;QAED,OAAO,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;QAEvB,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;AArLD,4CAqLC"}
|
|
@@ -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"}
|
package/lib/cjs/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from './HttpsProxySocket';
|
|
2
|
-
export * from './tediousPatch';
|
|
3
|
-
export * from './mongoPatch';
|
|
1
|
+
export * from './HttpsProxySocket.js';
|
|
2
|
+
export * from './tediousPatch.js';
|
|
3
|
+
export * from './mongoPatch.js';
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/cjs/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
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"}
|
package/lib/cjs/index.js
CHANGED
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./HttpsProxySocket"), exports);
|
|
18
|
-
__exportStar(require("./tediousPatch"), exports);
|
|
19
|
-
__exportStar(require("./mongoPatch"), exports);
|
|
17
|
+
__exportStar(require("./HttpsProxySocket.js"), exports);
|
|
18
|
+
__exportStar(require("./tediousPatch.js"), exports);
|
|
19
|
+
__exportStar(require("./mongoPatch.js"), exports);
|
|
20
20
|
//# sourceMappingURL=index.js.map
|
package/lib/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wDAAsC;AACtC,oDAAkC;AAClC,kDAAgC"}
|
package/lib/cjs/mongoPatch.js
CHANGED
|
@@ -35,7 +35,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.useProxyForMongo = useProxyForMongo;
|
|
37
37
|
const socks = __importStar(require("socks"));
|
|
38
|
-
const
|
|
38
|
+
const HttpsProxySocket_js_1 = require("./HttpsProxySocket.js");
|
|
39
39
|
/**
|
|
40
40
|
* The patch should be called before instantiating the MongoClient
|
|
41
41
|
* @param config - The configuration for the proxy
|
|
@@ -43,7 +43,7 @@ const HttpsProxySocket_1 = require("./HttpsProxySocket");
|
|
|
43
43
|
function useProxyForMongo(config) {
|
|
44
44
|
let socket;
|
|
45
45
|
socks.SocksClient.createConnection = async (options, callback) => {
|
|
46
|
-
const proxy = new
|
|
46
|
+
const proxy = new HttpsProxySocket_js_1.HttpsProxySocket(`https://${config.proxy}`, { auth: config.auth });
|
|
47
47
|
return new Promise(async (resolve, reject) => {
|
|
48
48
|
socket = await proxy.connect({ host: options.destination.host, port: options.destination.port });
|
|
49
49
|
resolve({
|
|
@@ -52,7 +52,7 @@ function useProxyForMongo(config) {
|
|
|
52
52
|
});
|
|
53
53
|
};
|
|
54
54
|
return {
|
|
55
|
-
close: () => socket?.end()
|
|
55
|
+
close: () => socket?.end(),
|
|
56
56
|
};
|
|
57
57
|
}
|
|
58
58
|
//# sourceMappingURL=mongoPatch.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mongoPatch.js","sourceRoot":"","sources":["../../src/mongoPatch.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA,4CAcC;AA5BD,6CAA+B;AAE/B
|
|
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"}
|
package/lib/cjs/proxyAgent.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proxyAgent.d.ts","sourceRoot":"","sources":["../../src/proxyAgent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,
|
|
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"}
|
package/lib/cjs/proxyAgent.js
CHANGED
|
@@ -46,13 +46,13 @@ const tls = __importStar(require("tls"));
|
|
|
46
46
|
* @param options - to set additional TLS options for https requests, e.g. rejectUnauthorized
|
|
47
47
|
*/
|
|
48
48
|
function proxyAgent(proxy, options) {
|
|
49
|
-
return (0, agent_base_1.default)(async (
|
|
49
|
+
return (0, agent_base_1.default)(async (_, opts) => {
|
|
50
50
|
const socket = await proxy.connect(opts);
|
|
51
51
|
if (opts.secureEndpoint) {
|
|
52
52
|
// Upgrade to TLS
|
|
53
53
|
let tlsOptions = {
|
|
54
54
|
socket: socket,
|
|
55
|
-
servername: opts.servername || opts.host
|
|
55
|
+
servername: opts.servername || opts.host,
|
|
56
56
|
};
|
|
57
57
|
if (typeof opts.rejectUnauthorized != 'undefined') {
|
|
58
58
|
// There's a difference between 'undefined' (equivalent of false) and "not set" (equivalent of true)
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tediousPatch.d.ts","sourceRoot":"","sources":["../../src/tediousPatch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,
|
|
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"}
|
package/lib/cjs/tediousPatch.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useProxyForTedious = useProxyForTedious;
|
|
4
|
-
const
|
|
4
|
+
const util_1 = require("util");
|
|
5
|
+
const debug = (0, util_1.debug)('https-proxy');
|
|
5
6
|
/**
|
|
6
7
|
* Replace the connection method on the tedious library (used by mssql)
|
|
7
8
|
* to connect via a proxy.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tediousPatch.js","sourceRoot":"","sources":["../../src/tediousPatch.ts"],"names":[],"mappings":";;AAUA,gDAWC;
|
|
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,14 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
// Based on https://github.com/TooTallNate/node-https-proxy-agent
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
+
var ownKeys = function(o) {
|
|
21
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
+
var ar = [];
|
|
23
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
+
return ar;
|
|
25
|
+
};
|
|
26
|
+
return ownKeys(o);
|
|
27
|
+
};
|
|
28
|
+
return function (mod) {
|
|
29
|
+
if (mod && mod.__esModule) return mod;
|
|
30
|
+
var result = {};
|
|
31
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
+
__setModuleDefault(result, mod);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
})();
|
|
36
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
+
exports.HttpsProxySocket = void 0;
|
|
38
|
+
const tls = __importStar(require("tls"));
|
|
39
|
+
const url = __importStar(require("url"));
|
|
40
|
+
const proxyAgent_js_1 = require("./proxyAgent.js");
|
|
41
|
+
const util_1 = require("util");
|
|
42
|
+
const debug = (0, util_1.debug)('https-proxy');
|
|
6
43
|
/**
|
|
7
44
|
* The HttpsProxySocket class allows creating Socket connections via an HTTPS proxy.
|
|
8
45
|
* HTTP proxies are not supported.
|
|
9
46
|
* For http(s) requests, use HttpsProxyAgent as a wrapper around this.
|
|
10
47
|
*/
|
|
11
|
-
|
|
48
|
+
class HttpsProxySocket {
|
|
49
|
+
proxy;
|
|
50
|
+
proxyConfig;
|
|
12
51
|
/**
|
|
13
52
|
*
|
|
14
53
|
* @param opts - The connection options to the proxy. At least host and port are required.
|
|
@@ -22,7 +61,7 @@ export class HttpsProxySocket {
|
|
|
22
61
|
let parsedOptions = url.parse(opts);
|
|
23
62
|
sanitizedOptions = {
|
|
24
63
|
host: parsedOptions.hostname || parsedOptions.host,
|
|
25
|
-
port: parseInt(parsedOptions.port || '443')
|
|
64
|
+
port: parseInt(parsedOptions.port || '443'),
|
|
26
65
|
};
|
|
27
66
|
}
|
|
28
67
|
else {
|
|
@@ -48,7 +87,7 @@ export class HttpsProxySocket {
|
|
|
48
87
|
}
|
|
49
88
|
else {
|
|
50
89
|
if (!socket) {
|
|
51
|
-
return reject(new Error(
|
|
90
|
+
return reject(new Error('No socket returned from proxy'));
|
|
52
91
|
}
|
|
53
92
|
resolve(socket);
|
|
54
93
|
}
|
|
@@ -61,7 +100,7 @@ export class HttpsProxySocket {
|
|
|
61
100
|
* @param options - to set additional TLS options for https requests, e.g. rejectUnauthorized
|
|
62
101
|
*/
|
|
63
102
|
agent(options) {
|
|
64
|
-
return proxyAgent(this, options);
|
|
103
|
+
return (0, proxyAgent_js_1.proxyAgent)(this, options);
|
|
65
104
|
}
|
|
66
105
|
_connect(opts, cb) {
|
|
67
106
|
const proxy = this.proxy;
|
|
@@ -164,4 +203,5 @@ export class HttpsProxySocket {
|
|
|
164
203
|
socket.write(msg + '\r\n');
|
|
165
204
|
}
|
|
166
205
|
}
|
|
206
|
+
exports.HttpsProxySocket = HttpsProxySocket;
|
|
167
207
|
//# sourceMappingURL=HttpsProxySocket.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HttpsProxySocket.js","sourceRoot":"","sources":["../../src/HttpsProxySocket.ts"],"names":[],"mappings":"AAAA,iEAAiE
|
|
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;QAED,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,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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e,CAAC;QAE9C,IAAI,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;QAC1D,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;QAED,OAAO,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;QAEvB,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;AArLD,4CAqLC"}
|
|
@@ -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"}
|
package/lib/esm/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from './HttpsProxySocket';
|
|
2
|
-
export * from './tediousPatch';
|
|
3
|
-
export * from './mongoPatch';
|
|
1
|
+
export * from './HttpsProxySocket.js';
|
|
2
|
+
export * from './tediousPatch.js';
|
|
3
|
+
export * from './mongoPatch.js';
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
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"}
|
package/lib/esm/index.js
CHANGED
|
@@ -1,4 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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("./tediousPatch.js"), exports);
|
|
19
|
+
__exportStar(require("./mongoPatch.js"), exports);
|
|
4
20
|
//# sourceMappingURL=index.js.map
|
package/lib/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wDAAsC;AACtC,oDAAkC;AAClC,kDAAgC"}
|
package/lib/esm/mongoPatch.js
CHANGED
|
@@ -1,13 +1,49 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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");
|
|
3
39
|
/**
|
|
4
40
|
* The patch should be called before instantiating the MongoClient
|
|
5
41
|
* @param config - The configuration for the proxy
|
|
6
42
|
*/
|
|
7
|
-
|
|
43
|
+
function useProxyForMongo(config) {
|
|
8
44
|
let socket;
|
|
9
45
|
socks.SocksClient.createConnection = async (options, callback) => {
|
|
10
|
-
const proxy = new HttpsProxySocket(`https://${config.proxy}`, { auth: config.auth });
|
|
46
|
+
const proxy = new HttpsProxySocket_js_1.HttpsProxySocket(`https://${config.proxy}`, { auth: config.auth });
|
|
11
47
|
return new Promise(async (resolve, reject) => {
|
|
12
48
|
socket = await proxy.connect({ host: options.destination.host, port: options.destination.port });
|
|
13
49
|
resolve({
|
|
@@ -16,7 +52,7 @@ export function useProxyForMongo(config) {
|
|
|
16
52
|
});
|
|
17
53
|
};
|
|
18
54
|
return {
|
|
19
|
-
close: () => socket?.end()
|
|
55
|
+
close: () => socket?.end(),
|
|
20
56
|
};
|
|
21
57
|
}
|
|
22
58
|
//# sourceMappingURL=mongoPatch.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mongoPatch.js","sourceRoot":"","sources":["../../src/mongoPatch.ts"],"names":[],"mappings":"
|
|
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"}
|
package/lib/esm/proxyAgent.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proxyAgent.d.ts","sourceRoot":"","sources":["../../src/proxyAgent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,
|
|
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"}
|
package/lib/esm/proxyAgent.js
CHANGED
|
@@ -1,19 +1,58 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.proxyAgent = proxyAgent;
|
|
40
|
+
const agent_base_1 = __importDefault(require("agent-base"));
|
|
41
|
+
const tls = __importStar(require("tls"));
|
|
3
42
|
/**
|
|
4
43
|
* Construct an agent for http(s) requests. Mostly for testing purposes.
|
|
5
44
|
*
|
|
6
45
|
* @param proxy - the proxy to use
|
|
7
46
|
* @param options - to set additional TLS options for https requests, e.g. rejectUnauthorized
|
|
8
47
|
*/
|
|
9
|
-
|
|
10
|
-
return
|
|
48
|
+
function proxyAgent(proxy, options) {
|
|
49
|
+
return (0, agent_base_1.default)(async (_, opts) => {
|
|
11
50
|
const socket = await proxy.connect(opts);
|
|
12
51
|
if (opts.secureEndpoint) {
|
|
13
52
|
// Upgrade to TLS
|
|
14
53
|
let tlsOptions = {
|
|
15
54
|
socket: socket,
|
|
16
|
-
servername: opts.servername || opts.host
|
|
55
|
+
servername: opts.servername || opts.host,
|
|
17
56
|
};
|
|
18
57
|
if (typeof opts.rejectUnauthorized != 'undefined') {
|
|
19
58
|
// There's a difference between 'undefined' (equivalent of false) and "not set" (equivalent of true)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proxyAgent.js","sourceRoot":"","sources":["../../src/proxyAgent.ts"],"names":[],"mappings":"
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tediousPatch.d.ts","sourceRoot":"","sources":["../../src/tediousPatch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,
|
|
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"}
|
package/lib/esm/tediousPatch.js
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
|
|
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');
|
|
2
6
|
/**
|
|
3
7
|
* Replace the connection method on the tedious library (used by mssql)
|
|
4
8
|
* to connect via a proxy.
|
|
5
9
|
*
|
|
6
10
|
* @param proxy - the proxy to use
|
|
7
11
|
*/
|
|
8
|
-
|
|
12
|
+
function useProxyForTedious(proxy) {
|
|
9
13
|
const { Connector } = require('tedious/lib/connector');
|
|
10
14
|
Connector.prototype.execute = async function (cb) {
|
|
11
15
|
debug(`opening sql connection to ${this.options.host}:${this.options.port}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tediousPatch.js","sourceRoot":"","sources":["../../src/tediousPatch.ts"],"names":[],"mappings":"
|
|
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"}
|
package/package.json
CHANGED
|
@@ -1,34 +1,36 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@journeyapps/https-proxy-socket",
|
|
3
|
-
"version": "0.0.0-dev.
|
|
3
|
+
"version": "0.0.0-dev.70e6967",
|
|
4
4
|
"author": "JourneyApps",
|
|
5
5
|
"repository": "journeyapps/https-proxy-socket",
|
|
6
6
|
"license": "MIT",
|
|
7
|
-
"type": "module",
|
|
8
7
|
"main": "./lib/cjs/index.js",
|
|
9
8
|
"module": "./lib/esm/index.js",
|
|
10
|
-
"types": "./lib/esm/index.d.ts",
|
|
11
9
|
"exports": {
|
|
12
10
|
".": {
|
|
13
|
-
"import":
|
|
14
|
-
|
|
11
|
+
"import": {
|
|
12
|
+
"default": "./lib/esm/index.js",
|
|
13
|
+
"types": "./lib/esm/index.d.ts"
|
|
14
|
+
},
|
|
15
|
+
"require": {
|
|
16
|
+
"default": "./lib/cjs/index.js",
|
|
17
|
+
"types": "./lib/cjs/index.d.ts"
|
|
18
|
+
}
|
|
15
19
|
}
|
|
16
20
|
},
|
|
21
|
+
"bin": {
|
|
22
|
+
"mongo-replicas": "lib/esm/bin/mongoReplicas.js"
|
|
23
|
+
},
|
|
17
24
|
"devDependencies": {
|
|
18
|
-
"@journeyapps/deploy-cli": "2.6.2",
|
|
19
|
-
"@journeyapps/formatter-cli": "^2.6.2",
|
|
20
25
|
"@types/agent-base": "^4.2.0",
|
|
21
|
-
"@types/
|
|
22
|
-
"@types/node": "^22.18.8",
|
|
23
|
-
"@types/node-fetch": "^2.1.6",
|
|
24
|
-
"assert": "^1.4.1",
|
|
26
|
+
"@types/node": "^24.7.2",
|
|
25
27
|
"lerna": "^9.0.0",
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"proxy": "^
|
|
30
|
-
"
|
|
31
|
-
"
|
|
28
|
+
"mssql": "^12.0.0",
|
|
29
|
+
"node-fetch": "^3.3.2",
|
|
30
|
+
"prettier": "^3.6.2",
|
|
31
|
+
"proxy": "^2.2.0",
|
|
32
|
+
"typescript": "^5.9.3",
|
|
33
|
+
"vitest": "^3.2.4"
|
|
32
34
|
},
|
|
33
35
|
"dependencies": {
|
|
34
36
|
"agent-base": "^6.0.2",
|
|
@@ -46,8 +48,6 @@
|
|
|
46
48
|
"build:esm": "tsc -p tsconfig.esm.json",
|
|
47
49
|
"build:cjs": "tsc -p tsconfig.cjs.json",
|
|
48
50
|
"build": "pnpm build:esm && pnpm build:cjs",
|
|
49
|
-
"test": "
|
|
50
|
-
"format": "journey-formatter format",
|
|
51
|
-
"deploy": "journey-deploy trigger"
|
|
51
|
+
"test": "vitest run"
|
|
52
52
|
}
|
|
53
53
|
}
|