@journeyapps/https-proxy-socket 0.0.0-dev-20260127080124
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.txt +7 -0
- package/README.md +119 -0
- package/lib/cjs/HttpsProxySocket.d.ts +42 -0
- package/lib/cjs/HttpsProxySocket.d.ts.map +1 -0
- package/lib/cjs/HttpsProxySocket.js +197 -0
- package/lib/cjs/HttpsProxySocket.js.map +1 -0
- package/lib/cjs/ProxyAgent.d.ts +11 -0
- package/lib/cjs/ProxyAgent.d.ts.map +1 -0
- package/lib/cjs/ProxyAgent.js +67 -0
- package/lib/cjs/ProxyAgent.js.map +1 -0
- 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/createProxyAgent.d.ts +11 -0
- package/lib/cjs/createProxyAgent.d.ts.map +1 -0
- package/lib/cjs/createProxyAgent.js +14 -0
- package/lib/cjs/createProxyAgent.js.map +1 -0
- package/lib/cjs/index.d.ts +3 -0
- package/lib/cjs/index.d.ts.map +1 -0
- package/lib/cjs/index.js +19 -0
- package/lib/cjs/index.js.map +1 -0
- package/lib/cjs/mongoPatch.d.ts +15 -0
- package/lib/cjs/mongoPatch.d.ts.map +1 -0
- package/lib/cjs/mongoPatch.js +64 -0
- package/lib/cjs/mongoPatch.js.map +1 -0
- package/lib/cjs/utils/parseOptions.d.ts +3 -0
- package/lib/cjs/utils/parseOptions.d.ts.map +1 -0
- package/lib/cjs/utils/parseOptions.js +16 -0
- package/lib/cjs/utils/parseOptions.js.map +1 -0
- package/lib/cjs/utils/setServername.d.ts +3 -0
- package/lib/cjs/utils/setServername.d.ts.map +1 -0
- package/lib/cjs/utils/setServername.js +47 -0
- package/lib/cjs/utils/setServername.js.map +1 -0
- package/lib/esm/HttpsProxySocket.d.ts +42 -0
- package/lib/esm/HttpsProxySocket.d.ts.map +1 -0
- package/lib/esm/HttpsProxySocket.js +197 -0
- package/lib/esm/HttpsProxySocket.js.map +1 -0
- package/lib/esm/ProxyAgent.d.ts +11 -0
- package/lib/esm/ProxyAgent.d.ts.map +1 -0
- package/lib/esm/ProxyAgent.js +67 -0
- package/lib/esm/ProxyAgent.js.map +1 -0
- 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/createProxyAgent.d.ts +11 -0
- package/lib/esm/createProxyAgent.d.ts.map +1 -0
- package/lib/esm/createProxyAgent.js +14 -0
- package/lib/esm/createProxyAgent.js.map +1 -0
- package/lib/esm/index.d.ts +3 -0
- package/lib/esm/index.d.ts.map +1 -0
- package/lib/esm/index.js +19 -0
- package/lib/esm/index.js.map +1 -0
- package/lib/esm/mongoPatch.d.ts +15 -0
- package/lib/esm/mongoPatch.d.ts.map +1 -0
- package/lib/esm/mongoPatch.js +64 -0
- package/lib/esm/mongoPatch.js.map +1 -0
- package/lib/esm/utils/parseOptions.d.ts +3 -0
- package/lib/esm/utils/parseOptions.d.ts.map +1 -0
- package/lib/esm/utils/parseOptions.js +16 -0
- package/lib/esm/utils/parseOptions.js.map +1 -0
- package/lib/esm/utils/setServername.d.ts +3 -0
- package/lib/esm/utils/setServername.d.ts.map +1 -0
- package/lib/esm/utils/setServername.js +47 -0
- package/lib/esm/utils/setServername.js.map +1 -0
- package/package.json +54 -0
package/LICENSE.txt
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Copyright 2020 Journey Mobile, Inc.
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
+
|
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
# https-proxy-socket
|
|
2
|
+
|
|
3
|
+
Node library to enable opening Socket connections via an HTTPS proxy.
|
|
4
|
+
|
|
5
|
+
Based on the implementation in https://github.com/TooTallNate/node-https-proxy-agent,
|
|
6
|
+
but adapted to expose raw Sockets, instead of just http/https requests.
|
|
7
|
+
|
|
8
|
+
## Proxy for Node mssql (tedious)
|
|
9
|
+
The useProxyForTedious has been removed, if you require this functionality please use v0.2.2 instead.
|
|
10
|
+
|
|
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
|
+
```
|
|
17
|
+
|
|
18
|
+
## Usage - node-fetch
|
|
19
|
+
|
|
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
|
+
```
|
|
44
|
+
|
|
45
|
+
## Usage - Direct socket
|
|
46
|
+
|
|
47
|
+
```javascript
|
|
48
|
+
import { HttpsProxySocket } from '@journeyapps/https-proxy-socket';
|
|
49
|
+
const proxy = new HttpsProxySocket('https://my-proxy.test');
|
|
50
|
+
|
|
51
|
+
const socket = await proxy.connect({ host: 'myhost.test', port: 1234 });
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Usage - MongoDB
|
|
55
|
+
|
|
56
|
+
The socks package needs to be added to your package.json dependencies for this to work.
|
|
57
|
+
See the MongoDB documentation for details: https://www.mongodb.com/docs/drivers/node/current/security/socks/
|
|
58
|
+
|
|
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
|
+
|
|
97
|
+
## JourneyApps MongoDB Token
|
|
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.
|
|
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.
|
|
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
|
+
|
|
103
|
+
```bash
|
|
104
|
+
# your SRV is mongodb+srv://<username>:<password>@cluster1.vlnzcbp.mongodb.net
|
|
105
|
+
# You can run it with the included credentials
|
|
106
|
+
npx @journeyapps/https-proxy-socket mongo-replicas mongodb+srv://your_username:your_password@cluster1.vlnzcbp.mongodb.net
|
|
107
|
+
# Or without
|
|
108
|
+
npx @journeyapps/https-proxy-socket mongo-replicas mongodb+srv://cluster1.vlnzcbp.mongodb.net
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
This will output the below to your console:
|
|
112
|
+
|
|
113
|
+
```javascript
|
|
114
|
+
{
|
|
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';
|
|
116
|
+
}
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
When requesting the token from JourneyApps support, please provide the replicas string as well.
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import * as tls from 'tls';
|
|
2
|
+
export interface HttpsProxyConfig extends tls.ConnectionOptions {
|
|
3
|
+
headers?: {
|
|
4
|
+
[key: string]: string;
|
|
5
|
+
};
|
|
6
|
+
auth?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface ConnectionOptions {
|
|
9
|
+
host: string;
|
|
10
|
+
port: number;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* The HttpsProxySocket class allows creating Socket connections via an HTTPS proxy.
|
|
14
|
+
* HTTP proxies are not supported.
|
|
15
|
+
* For http(s) requests, use HttpsProxyAgent as a wrapper around this.
|
|
16
|
+
*/
|
|
17
|
+
export declare class HttpsProxySocket {
|
|
18
|
+
proxy: tls.ConnectionOptions;
|
|
19
|
+
proxyConfig: HttpsProxyConfig;
|
|
20
|
+
/**
|
|
21
|
+
*
|
|
22
|
+
* @param options - The connection options to the proxy. At least host and port are required.
|
|
23
|
+
* Use {rejectUnauthorized: true} to ignore certificates for the proxy (not the endpoint).
|
|
24
|
+
* @param proxyConfig - { auth: 'username:password' } for basic auth.
|
|
25
|
+
* { headers: {key: 'value'} } for custom headers.
|
|
26
|
+
*/
|
|
27
|
+
constructor(options: tls.ConnectionOptions | string, proxyConfig?: HttpsProxyConfig);
|
|
28
|
+
/**
|
|
29
|
+
* Create a new Socket connection.
|
|
30
|
+
*
|
|
31
|
+
* @param options - host and port
|
|
32
|
+
*/
|
|
33
|
+
connect(options: ConnectionOptions): Promise<tls.TLSSocket>;
|
|
34
|
+
/**
|
|
35
|
+
* Construct an agent for http(s) requests.
|
|
36
|
+
*
|
|
37
|
+
* @param options - to set additional TLS options for https requests, e.g. rejectUnauthorized
|
|
38
|
+
*/
|
|
39
|
+
agent(options?: tls.ConnectionOptions): import("./ProxyAgent").ProxyAgent;
|
|
40
|
+
private _connect;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=HttpsProxySocket.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HttpsProxySocket.d.ts","sourceRoot":"","sources":["../../src/HttpsProxySocket.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAS3B,MAAM,WAAW,gBAAiB,SAAQ,GAAG,CAAC,iBAAiB;IAC7D,OAAO,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;IACpC,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;GAIG;AACH,qBAAa,gBAAgB;IAC3B,KAAK,EAAE,GAAG,CAAC,iBAAiB,CAAC;IAC7B,WAAW,EAAE,gBAAgB,CAAC;IAE9B;;;;;;OAMG;gBACS,OAAO,EAAE,GAAG,CAAC,iBAAiB,GAAG,MAAM,EAAE,WAAW,CAAC,EAAE,gBAAgB;IAWnF;;;;OAIG;IACH,OAAO,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC;IAe3D;;;;OAIG;IACH,KAAK,CAAC,OAAO,CAAC,EAAE,GAAG,CAAC,iBAAiB;IAIrC,OAAO,CAAC,QAAQ;CAsHjB"}
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.HttpsProxySocket = void 0;
|
|
37
|
+
const tls = __importStar(require("tls"));
|
|
38
|
+
const createProxyAgent_1 = require("./createProxyAgent");
|
|
39
|
+
const setServername_1 = require("./utils/setServername");
|
|
40
|
+
const parseOptions_1 = require("./utils/parseOptions");
|
|
41
|
+
const util_1 = require("util");
|
|
42
|
+
const debug = (0, util_1.debug)('https-proxy');
|
|
43
|
+
/**
|
|
44
|
+
* The HttpsProxySocket class allows creating Socket connections via an HTTPS proxy.
|
|
45
|
+
* HTTP proxies are not supported.
|
|
46
|
+
* For http(s) requests, use HttpsProxyAgent as a wrapper around this.
|
|
47
|
+
*/
|
|
48
|
+
class HttpsProxySocket {
|
|
49
|
+
proxy;
|
|
50
|
+
proxyConfig;
|
|
51
|
+
/**
|
|
52
|
+
*
|
|
53
|
+
* @param options - The connection options to the proxy. At least host and port are required.
|
|
54
|
+
* Use {rejectUnauthorized: true} to ignore certificates for the proxy (not the endpoint).
|
|
55
|
+
* @param proxyConfig - { auth: 'username:password' } for basic auth.
|
|
56
|
+
* { headers: {key: 'value'} } for custom headers.
|
|
57
|
+
*/
|
|
58
|
+
constructor(options, proxyConfig) {
|
|
59
|
+
const sanitizedOptions = (0, parseOptions_1.parseOptions)(options);
|
|
60
|
+
if (!options) {
|
|
61
|
+
throw new Error('an HTTP(S) proxy server `host` and `port` must be specified!');
|
|
62
|
+
}
|
|
63
|
+
debug('creating new HttpsProxyAgent instance: %o', sanitizedOptions);
|
|
64
|
+
this.proxyConfig = proxyConfig || {};
|
|
65
|
+
this.proxy = sanitizedOptions;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Create a new Socket connection.
|
|
69
|
+
*
|
|
70
|
+
* @param options - host and port
|
|
71
|
+
*/
|
|
72
|
+
connect(options) {
|
|
73
|
+
return new Promise(async (resolve, reject) => {
|
|
74
|
+
this._connect(options, (error, socket) => {
|
|
75
|
+
if (error) {
|
|
76
|
+
reject(error);
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
if (!socket) {
|
|
80
|
+
return reject(new Error('No socket returned from proxy'));
|
|
81
|
+
}
|
|
82
|
+
resolve(socket);
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Construct an agent for http(s) requests.
|
|
89
|
+
*
|
|
90
|
+
* @param options - to set additional TLS options for https requests, e.g. rejectUnauthorized
|
|
91
|
+
*/
|
|
92
|
+
agent(options) {
|
|
93
|
+
return (0, createProxyAgent_1.createProxyAgent)(this, options);
|
|
94
|
+
}
|
|
95
|
+
_connect(opts, cb) {
|
|
96
|
+
const proxy = this.proxy;
|
|
97
|
+
// create a socket connection to the proxy server
|
|
98
|
+
const socket = tls.connect((0, setServername_1.setServername)(proxy));
|
|
99
|
+
// we need to buffer any HTTP traffic that happens with the proxy before we get
|
|
100
|
+
// the CONNECT response, so that if the response is anything other than an "200"
|
|
101
|
+
// response code, then we can re-play the "data" events on the socket once the
|
|
102
|
+
// HTTP parser is hooked up...
|
|
103
|
+
let buffers = [];
|
|
104
|
+
let buffersLength = 0;
|
|
105
|
+
function read() {
|
|
106
|
+
var b = socket.read();
|
|
107
|
+
if (b) {
|
|
108
|
+
ondata(b);
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
socket.once('readable', read);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
function cleanup() {
|
|
115
|
+
socket.removeListener('data', ondata);
|
|
116
|
+
socket.removeListener('end', onend);
|
|
117
|
+
socket.removeListener('error', onerror);
|
|
118
|
+
socket.removeListener('close', onclose);
|
|
119
|
+
socket.removeListener('readable', read);
|
|
120
|
+
}
|
|
121
|
+
function onclose(err) {
|
|
122
|
+
debug('onclose had error %o', err);
|
|
123
|
+
}
|
|
124
|
+
function onend() {
|
|
125
|
+
debug('onend');
|
|
126
|
+
}
|
|
127
|
+
function onerror(err) {
|
|
128
|
+
cleanup();
|
|
129
|
+
cb(err, null);
|
|
130
|
+
}
|
|
131
|
+
const END_OF_HEADERS = '\r\n\r\n';
|
|
132
|
+
function ondata(b) {
|
|
133
|
+
buffers.push(b);
|
|
134
|
+
buffersLength += b.length;
|
|
135
|
+
// Headers (including URLs) are generally ISO-8859-1 or ASCII.
|
|
136
|
+
// The subset used by an HTTPS proxy should always be safe as ASCII.
|
|
137
|
+
const buffered = Buffer.concat(buffers, buffersLength);
|
|
138
|
+
const str = buffered.toString('ascii');
|
|
139
|
+
if (str.indexOf(END_OF_HEADERS) < 0) {
|
|
140
|
+
// keep buffering
|
|
141
|
+
debug('have not received end of HTTP headers yet...');
|
|
142
|
+
if (socket.readable) {
|
|
143
|
+
read();
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
socket.once('data', ondata);
|
|
147
|
+
}
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
const firstLine = str.substring(0, str.indexOf('\r\n'));
|
|
151
|
+
const statusCode = parseInt(firstLine.split(' ')[1], 10);
|
|
152
|
+
debug('got proxy server response: %o', firstLine);
|
|
153
|
+
if (200 == statusCode) {
|
|
154
|
+
// 200 Connected status code!
|
|
155
|
+
const sock = socket;
|
|
156
|
+
// nullify the buffered data since we won't be needing it
|
|
157
|
+
buffers = [];
|
|
158
|
+
cleanup();
|
|
159
|
+
cb(null, sock);
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
// some other status code that's not 200... need to re-play the HTTP header
|
|
163
|
+
// "data" events onto the socket once the HTTP machinery is attached so that
|
|
164
|
+
// the user can parse and handle the error status code
|
|
165
|
+
cleanup();
|
|
166
|
+
// nullify the buffered data since we won't be needing it
|
|
167
|
+
buffers = [];
|
|
168
|
+
cleanup();
|
|
169
|
+
socket.end();
|
|
170
|
+
cb(new Error('Proxy connection failed: ' + firstLine), null);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
socket.on('error', onerror);
|
|
174
|
+
socket.on('close', onclose);
|
|
175
|
+
socket.on('end', onend);
|
|
176
|
+
if (socket.readable) {
|
|
177
|
+
read();
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
socket.once('data', ondata);
|
|
181
|
+
}
|
|
182
|
+
const host = `${opts.host}:${opts.port}`;
|
|
183
|
+
let msg = 'CONNECT ' + host + ' HTTP/1.1\r\n';
|
|
184
|
+
const headers = Object.assign({}, this.proxyConfig.headers);
|
|
185
|
+
if (this.proxyConfig.auth) {
|
|
186
|
+
headers['Proxy-Authorization'] = 'Basic ' + Buffer.from(this.proxyConfig.auth).toString('base64');
|
|
187
|
+
}
|
|
188
|
+
headers['Host'] = host;
|
|
189
|
+
headers['Connection'] = 'close';
|
|
190
|
+
Object.keys(headers).forEach(function (name) {
|
|
191
|
+
msg += name + ': ' + headers[name] + '\r\n';
|
|
192
|
+
});
|
|
193
|
+
socket.write(msg + '\r\n');
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
exports.HttpsProxySocket = HttpsProxySocket;
|
|
197
|
+
//# sourceMappingURL=HttpsProxySocket.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HttpsProxySocket.js","sourceRoot":"","sources":["../../src/HttpsProxySocket.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yCAA2B;AAC3B,yDAAsD;AACtD,yDAAsD;AACtD,uDAAoD;AAEpD,+BAA0C;AAE1C,MAAM,KAAK,GAAG,IAAA,YAAS,EAAC,aAAa,CAAC,CAAC;AAYvC;;;;GAIG;AACH,MAAa,gBAAgB;IAC3B,KAAK,CAAwB;IAC7B,WAAW,CAAmB;IAE9B;;;;;;OAMG;IACH,YAAY,OAAuC,EAAE,WAA8B;QACjF,MAAM,gBAAgB,GAAG,IAAA,2BAAY,EAAC,OAAO,CAAC,CAAC;QAC/C,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,8DAA8D,CAAC,CAAC;QAClF,CAAC;QACD,KAAK,CAAC,2CAA2C,EAAE,gBAAgB,CAAC,CAAC;QAErE,IAAI,CAAC,WAAW,GAAG,WAAW,IAAI,EAAE,CAAC;QACrC,IAAI,CAAC,KAAK,GAAG,gBAAyC,CAAC;IACzD,CAAC;IAED;;;;OAIG;IACH,OAAO,CAAC,OAA0B;QAChC,OAAO,IAAI,OAAO,CAAgB,KAAK,EAAE,OAAO,EAA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CAAC,MAAM,CAAC,EAAE,EAAE,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;QAC5D,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"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.ProxyAgent = void 0;
|
|
37
|
+
const agent_base_1 = require("agent-base");
|
|
38
|
+
const tls = __importStar(require("tls"));
|
|
39
|
+
class ProxyAgent extends agent_base_1.Agent {
|
|
40
|
+
proxy;
|
|
41
|
+
agentOptions;
|
|
42
|
+
constructor(proxy, agentOptions) {
|
|
43
|
+
super(agentOptions);
|
|
44
|
+
this.proxy = proxy;
|
|
45
|
+
this.agentOptions = agentOptions;
|
|
46
|
+
}
|
|
47
|
+
async connect(req, options) {
|
|
48
|
+
const socket = await this.proxy.connect(options);
|
|
49
|
+
if (options.secureEndpoint) {
|
|
50
|
+
let tlsOptions = {
|
|
51
|
+
socket: socket,
|
|
52
|
+
servername: options.servername || options.host,
|
|
53
|
+
};
|
|
54
|
+
if (typeof options.rejectUnauthorized != 'undefined') {
|
|
55
|
+
tlsOptions.rejectUnauthorized = options.rejectUnauthorized;
|
|
56
|
+
}
|
|
57
|
+
Object.assign(tlsOptions, this.agentOptions);
|
|
58
|
+
return tls.connect(tlsOptions);
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
socket.resume();
|
|
62
|
+
return socket;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
exports.ProxyAgent = ProxyAgent;
|
|
67
|
+
//# sourceMappingURL=ProxyAgent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProxyAgent.js","sourceRoot":"","sources":["../../src/ProxyAgent.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAAqD;AAErD,yCAA2B;AAG3B,MAAa,UAAW,SAAQ,kBAAK;IAE1B;IACA;IAFT,YACS,KAAuB,EACvB,YAAgC;QAEvC,KAAK,CAAC,YAAY,CAAC,CAAC;QAHb,UAAK,GAAL,KAAK,CAAkB;QACvB,iBAAY,GAAZ,YAAY,CAAoB;IAGzC,CAAC;IACD,KAAK,CAAC,OAAO,CAAC,GAAuB,EAAE,OAAyB;QAC9D,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,OAAc,CAAC,CAAC;QACxD,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC;YAC3B,IAAI,UAAU,GAA0B;gBACtC,MAAM,EAAE,MAAM;gBACd,UAAU,EAAE,OAAO,CAAC,UAAU,IAAI,OAAO,CAAC,IAAI;aAC/C,CAAC;YACF,IAAI,OAAO,OAAO,CAAC,kBAAkB,IAAI,WAAW,EAAE,CAAC;gBACrD,UAAU,CAAC,kBAAkB,GAAG,OAAO,CAAC,kBAAkB,CAAC;YAC7D,CAAC;YACD,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;YAC7C,OAAO,GAAG,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QACjC,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,MAAM,EAAE,CAAC;YAChB,OAAO,MAAM,CAAC;QAChB,CAAC;IACH,CAAC;CACF;AAxBD,gCAwBC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mongoReplicas.d.ts","sourceRoot":"","sources":["../../../src/bin/mongoReplicas.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const promises_1 = require("dns/promises");
|
|
5
|
+
/**
|
|
6
|
+
* NPX script to resolve MongoDB SRV records.
|
|
7
|
+
* @example npx @journeyapps/https-proxy-socket mongo-replicas mongodb+srv://<username>:<password>@cluster1.vlnzcbp.mongodb.net
|
|
8
|
+
* @example npx @journeyapps/https-proxy-socket mongo-replicas mongodb+srv://cluster1.vlnzcbp.mongodb.net
|
|
9
|
+
*
|
|
10
|
+
* @returns An object with a `replicas` property containing the resolved host:port pairs.
|
|
11
|
+
*/
|
|
12
|
+
async function mongoReplicas() {
|
|
13
|
+
const srvUrl = process.argv[3];
|
|
14
|
+
const url = new URL(srvUrl);
|
|
15
|
+
if (url.protocol !== 'mongodb+srv:') {
|
|
16
|
+
throw new Error('URL must start with mongodb+srv://');
|
|
17
|
+
}
|
|
18
|
+
const hostname = url.hostname;
|
|
19
|
+
const srvRecords = await (0, promises_1.resolveSrv)(`_mongodb._tcp.${hostname}`);
|
|
20
|
+
const targets = srvRecords.map((r) => `${r.name}:${r.port}`);
|
|
21
|
+
return { replicas: targets.join(',') };
|
|
22
|
+
}
|
|
23
|
+
mongoReplicas()
|
|
24
|
+
.then((result) => console.log(result))
|
|
25
|
+
.catch((error) => console.error(error));
|
|
26
|
+
//# sourceMappingURL=mongoReplicas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mongoReplicas.js","sourceRoot":"","sources":["../../../src/bin/mongoReplicas.ts"],"names":[],"mappings":";;;AACA,2CAA0C;AAE1C;;;;;;GAMG;AACH,KAAK,UAAU,aAAa;IAC1B,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAC/B,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC;IAC5B,IAAI,GAAG,CAAC,QAAQ,KAAK,cAAc,EAAE,CAAC;QACpC,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;IACxD,CAAC;IACD,MAAM,QAAQ,GAAG,GAAG,CAAC,QAAQ,CAAC;IAC9B,MAAM,UAAU,GAAG,MAAM,IAAA,qBAAU,EAAC,iBAAiB,QAAQ,EAAE,CAAC,CAAC;IACjE,MAAM,OAAO,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;IAC7D,OAAO,EAAE,QAAQ,EAAE,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;AACzC,CAAC;AAED,aAAa,EAAE;KACZ,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;KACrC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { HttpsProxySocket } from './HttpsProxySocket.js';
|
|
2
|
+
import { ProxyAgent } from './ProxyAgent';
|
|
3
|
+
import * as http from 'node:http';
|
|
4
|
+
/**
|
|
5
|
+
* Construct an agent for http(s) requests. Mostly for testing purposes.
|
|
6
|
+
*
|
|
7
|
+
* @param proxy - the proxy to use
|
|
8
|
+
* @param options - to set additional TLS options for https requests, e.g. rejectUnauthorized
|
|
9
|
+
*/
|
|
10
|
+
export declare function createProxyAgent(proxy: HttpsProxySocket, options?: http.AgentOptions): ProxyAgent;
|
|
11
|
+
//# sourceMappingURL=createProxyAgent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createProxyAgent.d.ts","sourceRoot":"","sources":["../../src/createProxyAgent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,gBAAgB,EAAE,OAAO,CAAC,EAAE,IAAI,CAAC,YAAY,cAEpF"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createProxyAgent = createProxyAgent;
|
|
4
|
+
const ProxyAgent_1 = require("./ProxyAgent");
|
|
5
|
+
/**
|
|
6
|
+
* Construct an agent for http(s) requests. Mostly for testing purposes.
|
|
7
|
+
*
|
|
8
|
+
* @param proxy - the proxy to use
|
|
9
|
+
* @param options - to set additional TLS options for https requests, e.g. rejectUnauthorized
|
|
10
|
+
*/
|
|
11
|
+
function createProxyAgent(proxy, options) {
|
|
12
|
+
return new ProxyAgent_1.ProxyAgent(proxy, options);
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=createProxyAgent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createProxyAgent.js","sourceRoot":"","sources":["../../src/createProxyAgent.ts"],"names":[],"mappings":";;AAUA,4CAEC;AAXD,6CAA0C;AAG1C;;;;;GAKG;AACH,SAAgB,gBAAgB,CAAC,KAAuB,EAAE,OAA2B;IACnF,OAAO,IAAI,uBAAU,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;AACxC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
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
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./HttpsProxySocket.js"), exports);
|
|
18
|
+
__exportStar(require("./mongoPatch.js"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wDAAsC;AACtC,kDAAgC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
interface Config {
|
|
2
|
+
/** The journey apps cc egress token */
|
|
3
|
+
auth: string;
|
|
4
|
+
/** The journey apps cc egress proxy domain */
|
|
5
|
+
proxy: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* The patch should be called before instantiating the MongoClient
|
|
9
|
+
* @param config - The configuration for the proxy
|
|
10
|
+
*/
|
|
11
|
+
export declare function useProxyForMongo(config: Config): {
|
|
12
|
+
close: () => Promise<void>;
|
|
13
|
+
};
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=mongoPatch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mongoPatch.d.ts","sourceRoot":"","sources":["../../src/mongoPatch.ts"],"names":[],"mappings":"AAIA,UAAU,MAAM;IACd,uCAAuC;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,8CAA8C;IAC9C,KAAK,EAAE,MAAM,CAAC;CACf;AACD;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM;;EAoB9C"}
|