Skip to content

Commit 34e8fd1

Browse files
authored
Merge branch 'master' into 567/user-data-dir-config
2 parents 615e898 + be0c3eb commit 34e8fd1

File tree

9 files changed

+41
-12
lines changed

9 files changed

+41
-12
lines changed

.env.sample

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ SERVER_BENCHMARKING = false
3232
# SERVER PROXY CONFIG
3333
SERVER_PROXY_HOST =
3434
SERVER_PROXY_PORT =
35+
SERVER_PROXY_USERNAME =
36+
SERVER_PROXY_PASSWORD =
3537
SERVER_PROXY_TIMEOUT = 5000
3638

3739
# SERVER RATE LIMITING CONFIG

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ _Fixes:_
1111
- Fixed an issue where the chart constructor was sometimes incorrectly set, causing the export to fail
1212
- Added referrers to CDN cache fetches on first startup/install.
1313
- Fixed an issue that would sometimes cause cause a crash due to fail due to `Accept-Ranges` headers
14+
- Fixed the warning message when the the default `resources.json` file is not found.
15+
- Fixed the problem with the lack of the `instr` value, when the `options` is set instead
16+
17+
_New Features:_
18+
19+
- Added proxy authentication [(#631)](https://github.com/highcharts/node-export-server/issues/631).
1420

1521
_New features:_
1622

README.md

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

329331
- `SERVER_PROXY_HOST`: The host of the proxy server to use, if it exists (defaults to ``).
330332
- `SERVER_PROXY_PORT`: The port of the proxy server to use, if it exists (defaults to ``).
333+
- `SERVER_PROXY_USERNAME`: If used proxy with authentication, need to pass username and password (defaults to ``).
334+
- `SERVER_PROXY_PASSWORD`: If used proxy with authentication, need to pass username and password (defaults to ``).
331335
- `SERVER_PROXY_TIMEOUT`: The timeout for the proxy server to use, if it exists (defaults to ``).
332336

333337
### Server Rate Limiting Config
@@ -424,6 +428,8 @@ _Available options:_
424428
- `--serverBenchmarking`: Indicates whether to display the duration, in milliseconds, of specific actions that occur on the server while serving a request (defaults to `false`).
425429
- `--proxyHost`: The host of the proxy server to use, if it exists (defaults to `false`).
426430
- `--proxyPort`: The port of the proxy server to use, if it exists (defaults to `false`).
431+
- `--proxyUsername`: If you want your proxy to be authenticated, pass the username with password (defaults to `false`).
432+
- `--proxyPassword`: If you want your proxy to be authenticated, pass the username with password (defaults to `false`).
427433
- `--proxyTimeout`: The timeout for the proxy server to use, if it exists (defaults to `5000`).
428434
- `--enableRateLimiting`: Enables rate limiting for the server (defaults to `false`).
429435
- `--maxRequests`: The maximum number of requests allowed in one minute (defaults to `10`).

dist/index.esm.js

Lines changed: 1 addition & 2 deletions
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: 1 addition & 0 deletions
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/chart.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ export const startExport = async (settings, endCallback) => {
9797
try {
9898
log(4, '[chart] Attempting to export from a raw input.');
9999

100+
// Use whichever one is available
101+
exportOptions.instr = exportOptions.instr || exportOptions.options;
102+
100103
// Perform a direct inject when forced
101104
if (toBoolean(options.customLogic?.allowCodeExecution)) {
102105
return doStraightInject(options, endCallback);
@@ -321,11 +324,7 @@ const doExport = async (options, chartJson, endCallback, svg) => {
321324
toBoolean(options.customLogic.allowFileResources)
322325
);
323326
} catch (error) {
324-
logWithStack(
325-
2,
326-
error,
327-
`[chart] Unable to load the default resources.json file.`
328-
);
327+
log(2, `[chart] Unable to load the default resources.json file.`);
329328
}
330329
}
331330
}

lib/envs.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,8 @@ export const Config = z.object({
169169
// server proxy
170170
SERVER_PROXY_HOST: v.string(),
171171
SERVER_PROXY_PORT: v.positiveNum(),
172+
SERVER_PROXY_USERNAME: v.string(),
173+
SERVER_PROXY_PASSWORD: v.string(),
172174
SERVER_PROXY_TIMEOUT: v.nonNegativeNum(),
173175

174176
// server rate limiting

lib/schemas/config.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,20 @@ export const defaultConfig = {
406406
cliName: 'proxyPort',
407407
description: 'The port of the proxy server to use, if it exists.'
408408
},
409+
username: {
410+
value: false,
411+
type: 'string',
412+
envLink: 'SERVER_PROXY_USERNAME',
413+
cliName: 'proxyUsername',
414+
description: 'The username for the proxy server, if it exists.'
415+
},
416+
password: {
417+
value: false,
418+
type: 'string',
419+
envLink: 'SERVER_PROXY_PASSWORD',
420+
cliName: 'proxyPassword',
421+
description: 'The password for the proxy server, if it exists.'
422+
},
409423
timeout: {
410424
value: 5000,
411425
type: 'number',

0 commit comments

Comments
 (0)