@journeyapps/https-proxy-socket 0.0.0-dev.6df47f0 → 0.0.0-dev.73fb7f7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/README.md +99 -81
  2. package/lib/cjs/HttpsProxySocket.d.ts +5 -5
  3. package/lib/cjs/HttpsProxySocket.d.ts.map +1 -1
  4. package/lib/cjs/HttpsProxySocket.js +16 -26
  5. package/lib/cjs/HttpsProxySocket.js.map +1 -1
  6. package/lib/cjs/ProxyAgent.d.ts +11 -0
  7. package/lib/cjs/ProxyAgent.d.ts.map +1 -0
  8. package/lib/cjs/{proxyAgent.js → ProxyAgent.js} +21 -25
  9. package/lib/cjs/ProxyAgent.js.map +1 -0
  10. package/lib/cjs/createProxyAgent.d.ts +11 -0
  11. package/lib/cjs/createProxyAgent.d.ts.map +1 -0
  12. package/lib/cjs/createProxyAgent.js +14 -0
  13. package/lib/cjs/createProxyAgent.js.map +1 -0
  14. package/lib/cjs/index.d.ts +2 -3
  15. package/lib/cjs/index.d.ts.map +1 -1
  16. package/lib/cjs/index.js +2 -3
  17. package/lib/cjs/index.js.map +1 -1
  18. package/lib/cjs/mongoPatch.js +3 -3
  19. package/lib/cjs/mongoPatch.js.map +1 -1
  20. package/lib/cjs/utils/parseOptions.d.ts +3 -0
  21. package/lib/cjs/utils/parseOptions.d.ts.map +1 -0
  22. package/lib/cjs/utils/parseOptions.js +16 -0
  23. package/lib/cjs/utils/parseOptions.js.map +1 -0
  24. package/lib/cjs/utils/setServername.d.ts +3 -0
  25. package/lib/cjs/utils/setServername.d.ts.map +1 -0
  26. package/lib/cjs/utils/setServername.js +47 -0
  27. package/lib/cjs/utils/setServername.js.map +1 -0
  28. package/lib/esm/HttpsProxySocket.d.ts +5 -5
  29. package/lib/esm/HttpsProxySocket.d.ts.map +1 -1
  30. package/lib/esm/HttpsProxySocket.js +57 -30
  31. package/lib/esm/HttpsProxySocket.js.map +1 -1
  32. package/lib/esm/ProxyAgent.d.ts +11 -0
  33. package/lib/esm/ProxyAgent.d.ts.map +1 -0
  34. package/lib/esm/ProxyAgent.js +67 -0
  35. package/lib/esm/ProxyAgent.js.map +1 -0
  36. package/lib/esm/bin/mongoReplicas.js +4 -2
  37. package/lib/esm/bin/mongoReplicas.js.map +1 -1
  38. package/lib/esm/createProxyAgent.d.ts +11 -0
  39. package/lib/esm/createProxyAgent.d.ts.map +1 -0
  40. package/lib/esm/createProxyAgent.js +14 -0
  41. package/lib/esm/createProxyAgent.js.map +1 -0
  42. package/lib/esm/index.d.ts +2 -3
  43. package/lib/esm/index.d.ts.map +1 -1
  44. package/lib/esm/index.js +18 -3
  45. package/lib/esm/index.js.map +1 -1
  46. package/lib/esm/mongoPatch.js +41 -5
  47. package/lib/esm/mongoPatch.js.map +1 -1
  48. package/lib/esm/utils/parseOptions.d.ts +3 -0
  49. package/lib/esm/utils/parseOptions.d.ts.map +1 -0
  50. package/lib/esm/utils/parseOptions.js +16 -0
  51. package/lib/esm/utils/parseOptions.js.map +1 -0
  52. package/lib/esm/utils/setServername.d.ts +3 -0
  53. package/lib/esm/utils/setServername.d.ts.map +1 -0
  54. package/lib/esm/utils/setServername.js +47 -0
  55. package/lib/esm/utils/setServername.js.map +1 -0
  56. package/package.json +3 -3
  57. package/lib/cjs/proxyAgent.d.ts +0 -11
  58. package/lib/cjs/proxyAgent.d.ts.map +0 -1
  59. package/lib/cjs/proxyAgent.js.map +0 -1
  60. package/lib/cjs/tediousPatch.d.ts +0 -9
  61. package/lib/cjs/tediousPatch.d.ts.map +0 -1
  62. package/lib/cjs/tediousPatch.js +0 -24
  63. package/lib/cjs/tediousPatch.js.map +0 -1
  64. package/lib/esm/proxyAgent.d.ts +0 -11
  65. package/lib/esm/proxyAgent.d.ts.map +0 -1
  66. package/lib/esm/proxyAgent.js +0 -32
  67. package/lib/esm/proxyAgent.js.map +0 -1
  68. package/lib/esm/tediousPatch.d.ts +0 -9
  69. package/lib/esm/tediousPatch.d.ts.map +0 -1
  70. package/lib/esm/tediousPatch.js +0 -21
  71. package/lib/esm/tediousPatch.js.map +0 -1
package/README.md CHANGED
@@ -5,97 +5,115 @@ Node library to enable opening Socket connections via an HTTPS proxy.
5
5
  Based on the implementation in https://github.com/TooTallNate/node-https-proxy-agent,
6
6
  but adapted to expose raw Sockets, instead of just http/https requests.
7
7
 
8
- ## Installation
8
+ ## Proxy for Node mssql (tedious)
9
+ The useProxyForTedious has been removed, if you require this functionality please use v0.2.2 instead.
9
10
 
10
- yarn add @journeyapps/https-proxy-socket
11
+ ## Installation
12
+ ```bash
13
+ yarn add @journeyapps/https-proxy-socket
14
+ npm install @journeyapps/https-proxy-socket
15
+ pnpm add @journeyapps/https-proxy-socket
16
+ ```
11
17
 
12
18
  ## Usage - node-fetch
13
19
 
14
- const { HttpsProxySocket } = require('@journeyapps/https-proxy-socket');
15
- const fetch = require('node-fetch');
16
-
17
- // Proxy connection options
18
- const proxy = new HttpsProxySocket('https://my-proxy.test', {
19
- // Proxy auth and headers may be set here, for example:
20
- auth: 'myuser:mypassword' // Basic auth
21
- });
22
-
23
- const agent = proxy.agent({
24
- // Additional TLS options for the host may be set here, for example:
25
- // rejectUnauthorized: false, // Disable TLS checks completely (dangerous)
26
- // ca: fs.readFileSync('my-ca-cert.pem') // Use a custom CA cert
27
-
28
- // Documentation of the available options is available here:
29
- // https://nodejs.org/api/tls.html#tls_new_tls_tlssocket_socket_options
30
- // https://nodejs.org/api/tls.html#tls_tls_createsecurecontext_options
31
- });
32
-
33
- const response = await fetch('https://myhost.test', { agent: agent });
20
+ ```javascript
21
+ import { HttpsProxySocket } from '@journeyapps/https-proxy-socket';
22
+ import fetch from 'node-fetch';
23
+
24
+ /** Proxy connection options */
25
+ const proxy = new HttpsProxySocket('https://my-proxy.test', {
26
+ /** Proxy auth and headers may be set here, for example: */
27
+ auth: 'myuser:mypassword', // Basic auth
28
+ });
29
+
30
+ const agent = proxy.agent({
31
+ /**
32
+ * Additional TLS options for the host may be set here, for example:
33
+ * rejectUnauthorized: false, // Disable TLS checks completely (dangerous)
34
+ * ca: fs.readFileSync('my-ca-cert.pem') // Use a custom CA cert
35
+ *
36
+ * Documentation of the available options is available here:
37
+ * https://nodejs.org/api/tls.html#tls_new_tls_tlssocket_socket_options
38
+ * https://nodejs.org/api/tls.html#tls_tls_createsecurecontext_options
39
+ */
40
+ });
41
+
42
+ const response = await fetch('https://myhost.test', { agent: agent });
43
+ ```
34
44
 
35
45
  ## Usage - Direct socket
36
46
 
37
- const { HttpsProxySocket } = require('@journeyapps/https-proxy-socket');
38
- const proxy = new HttpsProxySocket('https://my-proxy.test');
39
-
40
- const socket = await proxy.connect({host: 'myhost.test', port: 1234});
41
-
42
- ## Usage - mssql
43
-
44
- const sql = require('mssql')
45
- const { HttpsProxySocket, useProxyForTedious } = require('@journeyapps/https-proxy-socket');
46
-
47
- const proxy = new HttpsProxySocket({
48
- // Same as above
49
- });
50
-
51
- // Register the proxy globally for tedious/mssql
52
- useProxyForTedious(proxy);
53
-
54
- async function run() {
55
- // Connect using the proxy
56
- await sql.connect('mssql://username:pwd@myserver.database.windows.net/mydb?encrypt=true')
57
- try {
58
- const result = await sql.query`Select TOP(1) * from mytable`
59
- console.dir(result);
60
- } finally {
61
- await sql.close();
62
- }
63
- }
64
-
65
- run().catch(console.error);
47
+ ```javascript
48
+ import { HttpsProxySocket } from '@journeyapps/https-proxy-socket';
49
+ const proxy = new HttpsProxySocket('https://my-proxy.test');
66
50
 
51
+ const socket = await proxy.connect({ host: 'myhost.test', port: 1234 });
52
+ ```
67
53
 
68
54
  ## Usage - MongoDB
55
+
69
56
  The socks package needs to be added to your package.json dependencies for this to work.
70
57
  See the MongoDB documentation for details: https://www.mongodb.com/docs/drivers/node/current/security/socks/
71
58
 
72
- import * as mongo from 'mongodb';
73
- import { useProxyForMongo } from '@journeyapps/https-proxy-socket';
74
-
75
- const SRV_URI = 'mongodb+srv://<username>:<password>@cluster0.jzuewet.mongodb.net';
76
- const PROXY = 'us-cc-proxy.journeyapps.com'; // Or za-cc-proxy.journeyapps.com
77
- const PROXY_PORT = 443
78
-
79
- // Register the proxy globally for MongoDB
80
- useProxyForMongo({
81
- proxy: PROXY,
82
- auth: <egress_token>
83
- });
84
-
85
- async function run() {
86
- const client = new mongo.MongoClient(SRV_URI, {
87
- proxyPort: PROXY_PORT,
88
- proxyHost: PROXY,
89
- });
90
- try {
91
- const database = client.db('poc');
92
- const data = database.collection('data');
93
-
94
- const results = await data.find({ index: { $lt: 5 } }).toArray();
95
- console.log(results);
96
- } finally {
97
- await client.close();
98
- }
99
- }
100
-
101
- run().catch(console.error);
59
+ ```javascript
60
+
61
+ import * as mongo from 'mongodb';
62
+ import { useProxyForMongo } from '@journeyapps/https-proxy-socket';
63
+
64
+ const SRV_URI = 'mongodb+srv://<username>:<password>@cluster0.jzuewet.mongodb.net';
65
+ const PROXY = 'us-cc-proxy.journeyapps.com'; // Or za-cc-proxy.journeyapps.com
66
+ const PROXY_PORT = 443
67
+
68
+ /**
69
+ * Register the proxy globally for MongoDB
70
+ * This retuens a close function to end the socket
71
+ */
72
+ const { close } = useProxyForMongo({
73
+ proxy: PROXY,
74
+ auth: <egress_token> // See JourneyApps MongoDB Token section below
75
+ });
76
+
77
+ async function run() {
78
+ const client = new mongo.MongoClient(SRV_URI, {
79
+ proxyPort: PROXY_PORT,
80
+ proxyHost: PROXY,
81
+ });
82
+ try {
83
+ const database = client.db('poc');
84
+ const data = database.collection('data');
85
+
86
+ const results = await data.find({ index: { $lt: 5 } }).toArray();
87
+ console.log(results);
88
+ } finally {
89
+ close()
90
+ await client.close();
91
+ }
92
+ }
93
+
94
+ run().catch(console.error);
95
+ ```
96
+
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.
@@ -19,24 +19,24 @@ export declare class HttpsProxySocket {
19
19
  proxyConfig: HttpsProxyConfig;
20
20
  /**
21
21
  *
22
- * @param opts - The connection options to the proxy. At least host and port are required.
22
+ * @param options - The connection options to the proxy. At least host and port are required.
23
23
  * Use {rejectUnauthorized: true} to ignore certificates for the proxy (not the endpoint).
24
24
  * @param proxyConfig - { auth: 'username:password' } for basic auth.
25
25
  * { headers: {key: 'value'} } for custom headers.
26
26
  */
27
- constructor(opts: tls.ConnectionOptions | string, proxyConfig?: HttpsProxyConfig);
27
+ constructor(options: tls.ConnectionOptions | string, proxyConfig?: HttpsProxyConfig);
28
28
  /**
29
29
  * Create a new Socket connection.
30
30
  *
31
- * @param opts - host and port
31
+ * @param options - host and port
32
32
  */
33
- connect(opts: ConnectionOptions): Promise<tls.TLSSocket>;
33
+ connect(options: ConnectionOptions): Promise<tls.TLSSocket>;
34
34
  /**
35
35
  * Construct an agent for http(s) requests.
36
36
  *
37
37
  * @param options - to set additional TLS options for https requests, e.g. rejectUnauthorized
38
38
  */
39
- agent(options?: tls.ConnectionOptions): import("agent-base").Agent;
39
+ agent(options?: tls.ConnectionOptions): import("./ProxyAgent").ProxyAgent;
40
40
  private _connect;
41
41
  }
42
42
  //# sourceMappingURL=HttpsProxySocket.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"HttpsProxySocket.d.ts","sourceRoot":"","sources":["../../src/HttpsProxySocket.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAM3B,MAAM,WAAW,gBAAiB,SAAQ,GAAG,CAAC,iBAAiB;IAC7D,OAAO,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;IACpC,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;GAIG;AACH,qBAAa,gBAAgB;IAC3B,KAAK,EAAE,GAAG,CAAC,iBAAiB,CAAC;IAC7B,WAAW,EAAE,gBAAgB,CAAC;IAE9B;;;;;;OAMG;gBACS,IAAI,EAAE,GAAG,CAAC,iBAAiB,GAAG,MAAM,EAAE,WAAW,CAAC,EAAE,gBAAgB;IAqBhF;;;;OAIG;IACH,OAAO,CAAC,IAAI,EAAE,iBAAiB,GAAG,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC;IAexD;;;;OAIG;IACH,KAAK,CAAC,OAAO,CAAC,EAAE,GAAG,CAAC,iBAAiB;IAIrC,OAAO,CAAC,QAAQ;CAwHjB"}
1
+ {"version":3,"file":"HttpsProxySocket.d.ts","sourceRoot":"","sources":["../../src/HttpsProxySocket.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAS3B,MAAM,WAAW,gBAAiB,SAAQ,GAAG,CAAC,iBAAiB;IAC7D,OAAO,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;IACpC,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;GAIG;AACH,qBAAa,gBAAgB;IAC3B,KAAK,EAAE,GAAG,CAAC,iBAAiB,CAAC;IAC7B,WAAW,EAAE,gBAAgB,CAAC;IAE9B;;;;;;OAMG;gBACS,OAAO,EAAE,GAAG,CAAC,iBAAiB,GAAG,MAAM,EAAE,WAAW,CAAC,EAAE,gBAAgB;IAWnF;;;;OAIG;IACH,OAAO,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC;IAe3D;;;;OAIG;IACH,KAAK,CAAC,OAAO,CAAC,EAAE,GAAG,CAAC,iBAAiB;YAIvB,QAAQ;CAsHvB"}
@@ -1,5 +1,4 @@
1
1
  "use strict";
2
- // Based on https://github.com/TooTallNate/node-https-proxy-agent
3
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
3
  if (k2 === undefined) k2 = k;
5
4
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -36,8 +35,9 @@ var __importStar = (this && this.__importStar) || (function () {
36
35
  Object.defineProperty(exports, "__esModule", { value: true });
37
36
  exports.HttpsProxySocket = void 0;
38
37
  const tls = __importStar(require("tls"));
39
- const url = __importStar(require("url"));
40
- const proxyAgent_1 = require("./proxyAgent");
38
+ const createProxyAgent_1 = require("./createProxyAgent");
39
+ const setServername_1 = require("./utils/setServername");
40
+ const parseOptions_1 = require("./utils/parseOptions");
41
41
  const util_1 = require("util");
42
42
  const debug = (0, util_1.debug)('https-proxy');
43
43
  /**
@@ -50,24 +50,14 @@ class HttpsProxySocket {
50
50
  proxyConfig;
51
51
  /**
52
52
  *
53
- * @param opts - The connection options to the proxy. At least host and port are required.
53
+ * @param options - The connection options to the proxy. At least host and port are required.
54
54
  * Use {rejectUnauthorized: true} to ignore certificates for the proxy (not the endpoint).
55
55
  * @param proxyConfig - { auth: 'username:password' } for basic auth.
56
56
  * { headers: {key: 'value'} } for custom headers.
57
57
  */
58
- constructor(opts, proxyConfig) {
59
- let sanitizedOptions;
60
- if (typeof opts == 'string') {
61
- let parsedOptions = url.parse(opts);
62
- sanitizedOptions = {
63
- host: parsedOptions.hostname || parsedOptions.host,
64
- port: parseInt(parsedOptions.port || '443'),
65
- };
66
- }
67
- else {
68
- sanitizedOptions = Object.assign({}, opts);
69
- }
70
- if (!opts) {
58
+ constructor(options, proxyConfig) {
59
+ const sanitizedOptions = (0, parseOptions_1.parseOptions)(options);
60
+ if (!options) {
71
61
  throw new Error('an HTTP(S) proxy server `host` and `port` must be specified!');
72
62
  }
73
63
  debug('creating new HttpsProxyAgent instance: %o', sanitizedOptions);
@@ -77,11 +67,11 @@ class HttpsProxySocket {
77
67
  /**
78
68
  * Create a new Socket connection.
79
69
  *
80
- * @param opts - host and port
70
+ * @param options - host and port
81
71
  */
82
- connect(opts) {
83
- return new Promise((resolve, reject) => {
84
- this._connect(opts, (error, socket) => {
72
+ connect(options) {
73
+ return new Promise(async (resolve, reject) => {
74
+ await this._connect(options, (error, socket) => {
85
75
  if (error) {
86
76
  reject(error);
87
77
  }
@@ -100,12 +90,12 @@ class HttpsProxySocket {
100
90
  * @param options - to set additional TLS options for https requests, e.g. rejectUnauthorized
101
91
  */
102
92
  agent(options) {
103
- return (0, proxyAgent_1.proxyAgent)(this, options);
93
+ return (0, createProxyAgent_1.createProxyAgent)(this, options);
104
94
  }
105
- _connect(opts, cb) {
95
+ async _connect(opts, cb) {
106
96
  const proxy = this.proxy;
107
97
  // create a socket connection to the proxy server
108
- const socket = tls.connect(proxy);
98
+ const socket = tls.connect((0, setServername_1.setServername)(proxy));
109
99
  // we need to buffer any HTTP traffic that happens with the proxy before we get
110
100
  // the CONNECT response, so that if the response is anything other than an "200"
111
101
  // response code, then we can re-play the "data" events on the socket once the
@@ -190,8 +180,8 @@ class HttpsProxySocket {
190
180
  socket.once('data', ondata);
191
181
  }
192
182
  const host = `${opts.host}:${opts.port}`;
193
- var msg = 'CONNECT ' + host + ' HTTP/1.1\r\n';
194
- var headers = Object.assign({}, this.proxyConfig.headers);
183
+ let msg = 'CONNECT ' + host + ' HTTP/1.1\r\n';
184
+ const headers = Object.assign({}, this.proxyConfig.headers);
195
185
  if (this.proxyConfig.auth) {
196
186
  headers['Proxy-Authorization'] = 'Basic ' + Buffer.from(this.proxyConfig.auth).toString('base64');
197
187
  }
@@ -1 +1 @@
1
- {"version":3,"file":"HttpsProxySocket.js","sourceRoot":"","sources":["../../src/HttpsProxySocket.ts"],"names":[],"mappings":";AAAA,iEAAiE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEjE,yCAA2B;AAC3B,yCAA2B;AAC3B,6CAA0C;AAC1C,+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,gB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EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAC5B,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QAExB,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;YACpB,IAAI,EAAE,CAAC;QACT,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAC9B,CAAC;QAED,MAAM,IAAI,GAAG,GAAG,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;QACzC,IAAI,GAAG,GAAG,UAAU,GAAG,IAAI,GAAG,eAAe,CAAC;QAE9C,MAAM,OAAO,GAAG,MAAM,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"}
@@ -32,40 +32,36 @@ var __importStar = (this && this.__importStar) || (function () {
32
32
  return result;
33
33
  };
34
34
  })();
35
- var __importDefault = (this && this.__importDefault) || function (mod) {
36
- return (mod && mod.__esModule) ? mod : { "default": mod };
37
- };
38
35
  Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.proxyAgent = proxyAgent;
40
- const agent_base_1 = __importDefault(require("agent-base"));
36
+ exports.ProxyAgent = void 0;
37
+ const agent_base_1 = require("agent-base");
41
38
  const tls = __importStar(require("tls"));
42
- /**
43
- * Construct an agent for http(s) requests. Mostly for testing purposes.
44
- *
45
- * @param proxy - the proxy to use
46
- * @param options - to set additional TLS options for https requests, e.g. rejectUnauthorized
47
- */
48
- function proxyAgent(proxy, options) {
49
- return (0, agent_base_1.default)(async (req, opts) => {
50
- const socket = await proxy.connect(opts);
51
- if (opts.secureEndpoint) {
52
- // Upgrade to TLS
39
+ class ProxyAgent extends agent_base_1.Agent {
40
+ proxy;
41
+ agentOptions;
42
+ constructor(proxy, agentOptions) {
43
+ super(agentOptions);
44
+ this.proxy = proxy;
45
+ this.agentOptions = agentOptions;
46
+ }
47
+ async connect(req, options) {
48
+ const socket = await this.proxy.connect(options);
49
+ if (options.secureEndpoint) {
53
50
  let tlsOptions = {
54
51
  socket: socket,
55
- servername: opts.servername || opts.host
52
+ servername: options.servername || options.host,
56
53
  };
57
- if (typeof opts.rejectUnauthorized != 'undefined') {
58
- // There's a difference between 'undefined' (equivalent of false) and "not set" (equivalent of true)
59
- tlsOptions.rejectUnauthorized = opts.rejectUnauthorized;
54
+ if (typeof options.rejectUnauthorized != 'undefined') {
55
+ tlsOptions.rejectUnauthorized = options.rejectUnauthorized;
60
56
  }
61
- Object.assign(tlsOptions, options);
62
- const tlsSocket = tls.connect(tlsOptions);
63
- return tlsSocket;
57
+ Object.assign(tlsOptions, this.agentOptions);
58
+ return tls.connect(tlsOptions);
64
59
  }
65
60
  else {
66
61
  socket.resume();
67
62
  return socket;
68
63
  }
69
- });
64
+ }
70
65
  }
71
- //# sourceMappingURL=proxyAgent.js.map
66
+ exports.ProxyAgent = ProxyAgent;
67
+ //# sourceMappingURL=ProxyAgent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProxyAgent.js","sourceRoot":"","sources":["../../src/ProxyAgent.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAAqD;AAErD,yCAA2B;AAG3B,MAAa,UAAW,SAAQ,kBAAK;IAE1B;IACA;IAFT,YACS,KAAuB,EACvB,YAAgC;QAEvC,KAAK,CAAC,YAAY,CAAC,CAAC;QAHb,UAAK,GAAL,KAAK,CAAkB;QACvB,iBAAY,GAAZ,YAAY,CAAoB;IAGzC,CAAC;IACD,KAAK,CAAC,OAAO,CAAC,GAAuB,EAAE,OAAyB;QAC9D,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,OAAc,CAAC,CAAC;QACxD,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC;YAC3B,IAAI,UAAU,GAA0B;gBACtC,MAAM,EAAE,MAAM;gBACd,UAAU,EAAE,OAAO,CAAC,UAAU,IAAI,OAAO,CAAC,IAAI;aAC/C,CAAC;YACF,IAAI,OAAO,OAAO,CAAC,kBAAkB,IAAI,WAAW,EAAE,CAAC;gBACrD,UAAU,CAAC,kBAAkB,GAAG,OAAO,CAAC,kBAAkB,CAAC;YAC7D,CAAC;YACD,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;YAC7C,OAAO,GAAG,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QACjC,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,MAAM,EAAE,CAAC;YAChB,OAAO,MAAM,CAAC;QAChB,CAAC;IACH,CAAC;CACF;AAxBD,gCAwBC"}
@@ -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"}
@@ -1,4 +1,3 @@
1
- export * from './HttpsProxySocket';
2
- export * from './tediousPatch';
3
- export * from './mongoPatch';
1
+ export * from './HttpsProxySocket.js';
2
+ export * from './mongoPatch.js';
4
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,iBAAiB,CAAC"}
package/lib/cjs/index.js CHANGED
@@ -14,7 +14,6 @@ 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("./mongoPatch.js"), exports);
20
19
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qDAAmC;AACnC,iDAA+B;AAC/B,+CAA6B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wDAAsC;AACtC,kDAAgC"}
@@ -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 HttpsProxySocket_1 = require("./HttpsProxySocket");
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 HttpsProxySocket_1.HttpsProxySocket(`https://${config.proxy}`, { auth: config.auth });
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,yDAAsD;AAQtD;;;GAGG;AACH,SAAgB,gBAAgB,CAAC,MAAc;IAC7C,IAAI,MAAqB,CAAA;IACzB,KAAK,CAAC,WAAW,CAAC,gBAAgB,GAAG,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE;QAC/D,MAAM,KAAK,GAAG,IAAI,mCAAgB,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,CAAA;AACH,CAAC"}
1
+ {"version":3,"file":"mongoPatch.js","sourceRoot":"","sources":["../../src/mongoPatch.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA,4CAcC;AA5BD,6CAA+B;AAE/B,+DAAyD;AAQzD;;;GAGG;AACH,SAAgB,gBAAgB,CAAC,MAAc;IAC7C,IAAI,MAAqB,CAAC;IAC1B,KAAK,CAAC,WAAW,CAAC,gBAAgB,GAAG,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE;QAC/D,MAAM,KAAK,GAAG,IAAI,sCAAgB,CAAC,WAAW,MAAM,CAAC,KAAK,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;QACrF,OAAO,IAAI,OAAO,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE;YAC3C,MAAM,GAAG,MAAM,KAAK,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,WAAW,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC,CAAC;YACjG,OAAO,CAAC;gBACN,MAAM;aACP,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;IACF,OAAO;QACL,KAAK,EAAE,GAAG,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE;KAC3B,CAAC;AACJ,CAAC"}
@@ -0,0 +1,3 @@
1
+ import tls from 'tls';
2
+ export declare function parseOptions(options: tls.ConnectionOptions | string): tls.ConnectionOptions;
3
+ //# sourceMappingURL=parseOptions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parseOptions.d.ts","sourceRoot":"","sources":["../../../src/utils/parseOptions.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,KAAK,CAAC;AAEtB,wBAAgB,YAAY,CAAC,OAAO,EAAE,GAAG,CAAC,iBAAiB,GAAG,MAAM,yBAUnE"}
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseOptions = parseOptions;
4
+ function parseOptions(options) {
5
+ if (typeof options != 'string') {
6
+ return options;
7
+ }
8
+ else {
9
+ const parsedOptions = new URL(options);
10
+ return {
11
+ host: parsedOptions.hostname || parsedOptions.host,
12
+ port: parseInt(parsedOptions.port || '443'),
13
+ };
14
+ }
15
+ }
16
+ //# sourceMappingURL=parseOptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parseOptions.js","sourceRoot":"","sources":["../../../src/utils/parseOptions.ts"],"names":[],"mappings":";;AAEA,oCAUC;AAVD,SAAgB,YAAY,CAAC,OAAuC;IAClE,IAAI,OAAO,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC/B,OAAO,OAAO,CAAC;IACjB,CAAC;SAAM,CAAC;QACN,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC;QACvC,OAAO;YACL,IAAI,EAAE,aAAa,CAAC,QAAQ,IAAI,aAAa,CAAC,IAAI;YAClD,IAAI,EAAE,QAAQ,CAAC,aAAa,CAAC,IAAI,IAAI,KAAK,CAAC;SAC5C,CAAC;IACJ,CAAC;AACH,CAAC"}
@@ -0,0 +1,3 @@
1
+ import * as tls from 'tls';
2
+ export declare function setServername(options: tls.ConnectionOptions): tls.ConnectionOptions;
3
+ //# sourceMappingURL=setServername.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setServername.d.ts","sourceRoot":"","sources":["../../../src/utils/setServername.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAE3B,wBAAgB,aAAa,CAAC,OAAO,EAAE,GAAG,CAAC,iBAAiB,yBAQ3D"}
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.setServername = setServername;
37
+ const net = __importStar(require("net"));
38
+ function setServername(options) {
39
+ if (options.servername === undefined && options.host && !net.isIP(options.host)) {
40
+ return {
41
+ ...options,
42
+ servername: options.host,
43
+ };
44
+ }
45
+ return options;
46
+ }
47
+ //# sourceMappingURL=setServername.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setServername.js","sourceRoot":"","sources":["../../../src/utils/setServername.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,sCAQC;AAXD,yCAA2B;AAG3B,SAAgB,aAAa,CAAC,OAA8B;IAC1D,IAAI,OAAO,CAAC,UAAU,KAAK,SAAS,IAAI,OAAO,CAAC,IAAI,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QAChF,OAAO;YACL,GAAG,OAAO;YACV,UAAU,EAAE,OAAO,CAAC,IAAI;SACzB,CAAC;IACJ,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}