Skip to content

Commit cc8a02e

Browse files
authored
Merge branch 'master' into 564/instr-and-resources-error
2 parents a557d17 + 02119e9 commit cc8a02e

File tree

9 files changed

+36
-7
lines changed

9 files changed

+36
-7
lines changed

.env.sample

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ SERVER_BENCHMARKING = false
2929
# SERVER PROXY CONFIG
3030
SERVER_PROXY_HOST =
3131
SERVER_PROXY_PORT =
32+
SERVER_PROXY_USERNAME =
33+
SERVER_PROXY_PASSWORD =
3234
SERVER_PROXY_TIMEOUT = 5000
3335

3436
# SERVER RATE LIMITING CONFIG

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ _Fixes:_
1414
- Fixed the warning message when the the default `resources.json` file is not found.
1515
- Fixed the problem with the lack of the `instr` value, when the `options` is set instead
1616

17+
_New Features:_
18+
19+
- Added proxy authentication [(#631)](https://github.com/highcharts/node-export-server/issues/631).
20+
1721
# 4.0.2
1822

1923
_Hotfix_:

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,8 @@ The format, along with its default values, is as follows (using the recommended
218218
"proxy": {
219219
"host": "",
220220
"port": 8080,
221+
"username": false,
222+
"password": false,
221223
"timeout": 5000
222224
},
223225
"rateLimiting": {
@@ -323,6 +325,8 @@ These variables are set in your environment and take precedence over options fro
323325

324326
- `SERVER_PROXY_HOST`: The host of the proxy server to use, if it exists (defaults to ``).
325327
- `SERVER_PROXY_PORT`: The port of the proxy server to use, if it exists (defaults to ``).
328+
- `SERVER_PROXY_USERNAME`: If used proxy with authentication, need to pass username and password (defaults to ``).
329+
- `SERVER_PROXY_PASSWORD`: If used proxy with authentication, need to pass username and password (defaults to ``).
326330
- `SERVER_PROXY_TIMEOUT`: The timeout for the proxy server to use, if it exists (defaults to ``).
327331

328332
### Server Rate Limiting Config
@@ -419,6 +423,8 @@ _Available options:_
419423
- `--serverBenchmarking`: Indicates whether to display the duration, in milliseconds, of specific actions that occur on the server while serving a request (defaults to `false`).
420424
- `--proxyHost`: The host of the proxy server to use, if it exists (defaults to `false`).
421425
- `--proxyPort`: The port of the proxy server to use, if it exists (defaults to `false`).
426+
- `--proxyUsername`: If you want your proxy to be authenticated, pass the username with password (defaults to `false`).
427+
- `--proxyPassword`: If you want your proxy to be authenticated, pass the username with password (defaults to `false`).
422428
- `--proxyTimeout`: The timeout for the proxy server to use, if it exists (defaults to `5000`).
423429
- `--enableRateLimiting`: Enables rate limiting for the server (defaults to `false`).
424430
- `--maxRequests`: The maximum number of requests allowed in one minute (defaults to `10`).

dist/index.cjs

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

dist/index.esm.js

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.esm.js.map

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/cache.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -174,15 +174,15 @@ export const fetchScripts = async (
174174
) => {
175175
// Configure proxy if exists
176176
let proxyAgent;
177-
const proxyHost = proxyOptions.host;
178-
const proxyPort = proxyOptions.port;
177+
const { host, port, username, password } = proxyOptions;
179178

180179
// Try to create a Proxy Agent
181-
if (proxyHost && proxyPort) {
180+
if (host && port) {
182181
try {
183182
proxyAgent = new HttpsProxyAgent({
184-
host: proxyHost,
185-
port: proxyPort
183+
host,
184+
port,
185+
...(username && password ? { username, password } : {})
186186
});
187187
} catch (error) {
188188
throw new ExportError('[cache] Could not create a Proxy Agent.').setError(

lib/envs.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,8 @@ export const Config = z.object({
148148
// server proxy
149149
SERVER_PROXY_HOST: v.string(),
150150
SERVER_PROXY_PORT: v.positiveNum(),
151+
SERVER_PROXY_USERNAME: v.string(),
152+
SERVER_PROXY_PASSWORD: v.string(),
151153
SERVER_PROXY_TIMEOUT: v.nonNegativeNum(),
152154

153155
// server rate limiting

lib/schemas/config.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,20 @@ export const defaultConfig = {
401401
cliName: 'proxyPort',
402402
description: 'The port of the proxy server to use, if it exists.'
403403
},
404+
username: {
405+
value: false,
406+
type: 'string',
407+
envLink: 'SERVER_PROXY_USERNAME',
408+
cliName: 'proxyUsername',
409+
description: 'The username for the proxy server, if it exists.'
410+
},
411+
password: {
412+
value: false,
413+
type: 'string',
414+
envLink: 'SERVER_PROXY_PASSWORD',
415+
cliName: 'proxyPassword',
416+
description: 'The password for the proxy server, if it exists.'
417+
},
404418
timeout: {
405419
value: 5000,
406420
type: 'number',

0 commit comments

Comments
 (0)