@journeyapps/https-proxy-socket 0.2.2 → 1.0.1
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 +105 -51
- package/lib/{HttpsProxySocket.d.ts → cjs/HttpsProxySocket.d.ts} +6 -6
- package/lib/cjs/HttpsProxySocket.d.ts.map +1 -0
- package/lib/{HttpsProxySocket.js → cjs/HttpsProxySocket.js} +65 -34
- 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 +70 -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 +70 -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 +39 -21
- package/lib/index.d.ts +0 -2
- package/lib/index.js +0 -7
- package/lib/proxyAgent.d.ts +0 -11
- package/lib/proxyAgent.js +0 -43
- package/lib/tediousPatch.d.ts +0 -8
- package/lib/tediousPatch.js +0 -34
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.useProxyForMongo = useProxyForMongo;
|
|
37
|
+
const socks = __importStar(require("socks"));
|
|
38
|
+
const HttpsProxySocket_js_1 = require("./HttpsProxySocket.js");
|
|
39
|
+
/**
|
|
40
|
+
* The patch should be called before instantiating the MongoClient
|
|
41
|
+
* @param config - The configuration for the proxy
|
|
42
|
+
*/
|
|
43
|
+
function useProxyForMongo(config) {
|
|
44
|
+
let sockets = [];
|
|
45
|
+
socks.SocksClient.createConnection = async (options, callback) => {
|
|
46
|
+
const socket = await new HttpsProxySocket_js_1.HttpsProxySocket({ socket: options.existing_socket }, { auth: config.auth }).connect({
|
|
47
|
+
host: options.destination.host,
|
|
48
|
+
port: options.destination.port,
|
|
49
|
+
});
|
|
50
|
+
socket.on('timeout', () => {
|
|
51
|
+
console.error('Socket timeout');
|
|
52
|
+
});
|
|
53
|
+
sockets.push(socket);
|
|
54
|
+
return {
|
|
55
|
+
socket,
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
return {
|
|
59
|
+
close: async () => {
|
|
60
|
+
await Promise.all(sockets.map((socket) => new Promise((resolve) => {
|
|
61
|
+
socket.once('close', () => {
|
|
62
|
+
resolve();
|
|
63
|
+
});
|
|
64
|
+
socket.destroySoon();
|
|
65
|
+
})));
|
|
66
|
+
sockets = [];
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=mongoPatch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mongoPatch.js","sourceRoot":"","sources":["../../src/mongoPatch.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAeA,4CAgCC;AA/CD,6CAA+B;AAE/B,+DAAyD;AASzD;;;GAGG;AACH,SAAgB,gBAAgB,CAAC,MAAc;IAC7C,IAAI,OAAO,GAAoB,EAAE,CAAC;IAClC,KAAK,CAAC,WAAW,CAAC,gBAAgB,GAAG,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE;QAC/D,MAAM,MAAM,GAAG,MAAM,IAAI,sCAAgB,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,eAAe,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC;YAC5G,IAAI,EAAE,OAAO,CAAC,WAAW,CAAC,IAAI;YAC9B,IAAI,EAAE,OAAO,CAAC,WAAW,CAAC,IAAI;SAC/B,CAAC,CAAC;QAEH,MAAM,CAAC,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE;YACxB,OAAO,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;QAClC,CAAC,CAAC,CAAC;QACH,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACrB,OAAO;YACL,MAAM;SACP,CAAC;IACJ,CAAC,CAAC;IACF,OAAO;QACL,KAAK,EAAE,KAAK,IAAI,EAAE;YAChB,MAAM,OAAO,CAAC,GAAG,CACf,OAAO,CAAC,GAAG,CACT,CAAC,MAAM,EAAE,EAAE,CACT,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE;gBAC5B,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE;oBACxB,OAAO,EAAE,CAAC;gBACZ,CAAC,CAAC,CAAC;gBACH,MAAM,CAAC,WAAW,EAAE,CAAC;YACvB,CAAC,CAAC,CACL,CACF,CAAC;YACF,OAAO,GAAG,EAAE,CAAC;QACf,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -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 @@
|
|
|
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,36 +1,54 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@journeyapps/https-proxy-socket",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"author": "JourneyApps",
|
|
5
5
|
"repository": "journeyapps/https-proxy-socket",
|
|
6
6
|
"license": "MIT",
|
|
7
|
-
"
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
"
|
|
11
|
-
|
|
7
|
+
"main": "./lib/cjs/index.js",
|
|
8
|
+
"module": "./lib/esm/index.js",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
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
|
+
}
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"bin": {
|
|
22
|
+
"mongo-replicas": "lib/esm/bin/mongoReplicas.js"
|
|
12
23
|
},
|
|
13
24
|
"devDependencies": {
|
|
14
|
-
"@
|
|
15
|
-
"@journeyapps/formatter-cli": "^2.6.2",
|
|
25
|
+
"@changesets/cli": "^2.29.7",
|
|
16
26
|
"@types/agent-base": "^4.2.0",
|
|
17
|
-
"@types/
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"ts-node": "^8.0.2",
|
|
26
|
-
"typescript": "^3.7.5"
|
|
27
|
+
"@types/node": "^24.7.2",
|
|
28
|
+
"async-listen": "^3.1.0",
|
|
29
|
+
"lerna": "^9.0.0",
|
|
30
|
+
"node-fetch": "^3.3.2",
|
|
31
|
+
"prettier": "^3.6.2",
|
|
32
|
+
"proxy": "^2.2.0",
|
|
33
|
+
"typescript": "^5.9.3",
|
|
34
|
+
"vitest": "^3.2.4"
|
|
27
35
|
},
|
|
28
|
-
"main": "./lib/index.js",
|
|
29
36
|
"dependencies": {
|
|
30
|
-
"agent-base": "^
|
|
37
|
+
"agent-base": "^7.1.4",
|
|
38
|
+
"socks": "^2.8.7"
|
|
31
39
|
},
|
|
32
40
|
"files": [
|
|
33
41
|
"/README.md",
|
|
34
42
|
"/lib"
|
|
35
|
-
]
|
|
43
|
+
],
|
|
44
|
+
"scripts": {
|
|
45
|
+
"ci:publish": "changeset publish && git push --follow-tags",
|
|
46
|
+
"ci:version": "changeset version && pnpm install --no-frozen-lockfile",
|
|
47
|
+
"clean": "rm -rf ./lib && tsc -b --clean",
|
|
48
|
+
"clean:modules": "rm -rf node_modules",
|
|
49
|
+
"build:esm": "tsc -p tsconfig.esm.json",
|
|
50
|
+
"build:cjs": "tsc -p tsconfig.cjs.json",
|
|
51
|
+
"build": "pnpm build:esm && pnpm build:cjs",
|
|
52
|
+
"test": "vitest run"
|
|
53
|
+
}
|
|
36
54
|
}
|
package/lib/index.d.ts
DELETED
package/lib/index.js
DELETED
package/lib/proxyAgent.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { HttpsProxySocket } from './HttpsProxySocket';
|
|
3
|
-
import * as agentBase from 'agent-base';
|
|
4
|
-
import * as tls from 'tls';
|
|
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
|
-
export declare function proxyAgent(proxy: HttpsProxySocket, options?: tls.ConnectionOptions): agentBase.Agent;
|
package/lib/proxyAgent.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
const agentBase = require("agent-base");
|
|
13
|
-
const tls = require("tls");
|
|
14
|
-
/**
|
|
15
|
-
* Construct an agent for http(s) requests. Mostly for testing purposes.
|
|
16
|
-
*
|
|
17
|
-
* @param proxy - the proxy to use
|
|
18
|
-
* @param options - to set additional TLS options for https requests, e.g. rejectUnauthorized
|
|
19
|
-
*/
|
|
20
|
-
function proxyAgent(proxy, options) {
|
|
21
|
-
return agentBase((req, opts) => __awaiter(this, void 0, void 0, function* () {
|
|
22
|
-
const socket = yield proxy.connect(opts);
|
|
23
|
-
if (opts.secureEndpoint) {
|
|
24
|
-
// Upgrade to TLS
|
|
25
|
-
let tlsOptions = {
|
|
26
|
-
socket: socket,
|
|
27
|
-
servername: opts.servername || opts.host
|
|
28
|
-
};
|
|
29
|
-
if (typeof opts.rejectUnauthorized != 'undefined') {
|
|
30
|
-
// There's a difference between 'undefined' (equivalent of false) and "not set" (equivalent of true)
|
|
31
|
-
tlsOptions.rejectUnauthorized = opts.rejectUnauthorized;
|
|
32
|
-
}
|
|
33
|
-
Object.assign(tlsOptions, options);
|
|
34
|
-
const tlsSocket = tls.connect(tlsOptions);
|
|
35
|
-
return tlsSocket;
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
socket.resume();
|
|
39
|
-
return socket;
|
|
40
|
-
}
|
|
41
|
-
}));
|
|
42
|
-
}
|
|
43
|
-
exports.proxyAgent = proxyAgent;
|
package/lib/tediousPatch.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { HttpsProxySocket } from './HttpsProxySocket';
|
|
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;
|
package/lib/tediousPatch.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
const debug = require('debug')('https-proxy');
|
|
13
|
-
/**
|
|
14
|
-
* Replace the connection method on the tedious library (used by mssql)
|
|
15
|
-
* to connect via a proxy.
|
|
16
|
-
*
|
|
17
|
-
* @param proxy - the proxy to use
|
|
18
|
-
*/
|
|
19
|
-
function useProxyForTedious(proxy) {
|
|
20
|
-
const { Connector } = require('tedious/lib/connector');
|
|
21
|
-
Connector.prototype.execute = function (cb) {
|
|
22
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
-
debug(`opening sql connection to ${this.options.host}:${this.options.port}`);
|
|
24
|
-
try {
|
|
25
|
-
const socket = yield proxy.connect(this.options);
|
|
26
|
-
cb(null, socket);
|
|
27
|
-
}
|
|
28
|
-
catch (error) {
|
|
29
|
-
cb(error);
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
exports.useProxyForTedious = useProxyForTedious;
|