@aikidosec/broker-client 1.0.12 → 1.0.14
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/app/client.js +9 -2
- package/app/config.js +9 -0
- package/package.json +1 -1
package/app/client.js
CHANGED
|
@@ -12,7 +12,7 @@ import { Address4, Address6 } from 'ip-address';
|
|
|
12
12
|
import dns from 'native-dns';
|
|
13
13
|
import { ResourceManager } from './resourceManager.js';
|
|
14
14
|
import { HttpsProxyAgent } from 'https-proxy-agent';
|
|
15
|
-
import { getClientId, setClientIdCache, getServerUrl, getClientSecret } from './config.js';
|
|
15
|
+
import { getClientId, setClientIdCache, getServerUrl, getClientSecret, getShouldRejectUnauthorized } from './config.js';
|
|
16
16
|
import { registerStreamingHandlers } from './streaming/handlers.js';
|
|
17
17
|
import { initStreamingResponse } from './streaming/initStreamingResponse.js';
|
|
18
18
|
import { startStaleStreamCleanup, cleanupAllStreams } from './streaming/cleanup.js';
|
|
@@ -231,7 +231,13 @@ function isInternalUrl(url) {
|
|
|
231
231
|
|
|
232
232
|
let agent;
|
|
233
233
|
if (process.env.HTTPS_PROXY || process.env.ALL_PROXY) {
|
|
234
|
-
|
|
234
|
+
const agentProxyEnv = {}
|
|
235
|
+
if (process.env.NO_PROXY) {
|
|
236
|
+
// when the NO_PROXY env var is set, we need to set it for the proxyEnv specifically of this agent so it is taken into account
|
|
237
|
+
agentProxyEnv["NO_PROXY"] = process.env.NO_PROXY;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
agent = new HttpsProxyAgent(process.env.HTTPS_PROXY || process.env.ALL_PROXY, { proxyEnv: agentProxyEnv });
|
|
235
241
|
}
|
|
236
242
|
|
|
237
243
|
// Create Socket.IO client
|
|
@@ -246,6 +252,7 @@ const socket = io(SERVER_URL, {
|
|
|
246
252
|
reconnectionDelay: 1000,
|
|
247
253
|
reconnectionDelayMax: 30000,
|
|
248
254
|
randomizationFactor: 0.5,
|
|
255
|
+
rejectUnauthorized: getShouldRejectUnauthorized(),
|
|
249
256
|
tryAllTransports: true, // if we don't, it won't try to fallback from websocket to polling
|
|
250
257
|
autoConnect: false, // Don't connect until after registration
|
|
251
258
|
withCredentials: true, // make sure cookies work for sticky sessions
|
package/app/config.js
CHANGED
|
@@ -63,3 +63,12 @@ export function setClientIdCache(clientId) {
|
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
+
/**
|
|
67
|
+
* gets the value of the NODE_TLS_REJECT_UNAUTHORIZED env var to disable rejected requests from self-signed certificates
|
|
68
|
+
* used to pass to the socket.io client
|
|
69
|
+
*/
|
|
70
|
+
export function getShouldRejectUnauthorized() {
|
|
71
|
+
const envVarValue = process.env.NODE_TLS_REJECT_UNAUTHORIZED;
|
|
72
|
+
if (envVarValue === "0") return false;
|
|
73
|
+
return true;
|
|
74
|
+
}
|
package/package.json
CHANGED