Skip to content

Commit 4d6a955

Browse files
committedFeb 10, 2025·
Added proxy authentication, touch #631.
1 parent 48d3794 commit 4d6a955

12 files changed

+39
-18
lines changed
 

‎.env.sample

+2
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

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# 4.0.3
2+
3+
_New Features:_
4+
5+
- Added proxy authentication [(#631)](https://github.com/highcharts/node-export-server/issues/631).
6+
17
# 4.0.2
28

39
_Hotfix_:

‎README.md

+6
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,8 @@ The format, along with its default values, is as follows (using the recommended
217217
"proxy": {
218218
"host": "",
219219
"port": 8080,
220+
"username": false,
221+
"password": false,
220222
"timeout": 5000
221223
},
222224
"rateLimiting": {
@@ -321,6 +323,8 @@ These variables are set in your environment and take precedence over options fro
321323

322324
- `SERVER_PROXY_HOST`: The host of the proxy server to use, if it exists (defaults to ``).
323325
- `SERVER_PROXY_PORT`: The port of the proxy server to use, if it exists (defaults to ``).
326+
- `SERVER_PROXY_USERNAME`: If used proxy with authentication, need to pass username and password (defaults to ``).
327+
- `SERVER_PROXY_PASSWORD`: If used proxy with authentication, need to pass username and password (defaults to ``).
324328
- `SERVER_PROXY_TIMEOUT`: The timeout for the proxy server to use, if it exists (defaults to ``).
325329

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

‎dist/index.cjs

-2
This file was deleted.

‎dist/index.esm.js

-2
This file was deleted.

‎dist/index.esm.js.map

-1
This file was deleted.

‎lib/cache.js

+5-5
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

+2
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/highcharts.js

+1-5
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,7 @@ export async function triggerExport(chartOptions, options, displayErrors) {
124124
let constr = options.export.constr || 'chart';
125125
constr = typeof Highcharts[constr] !== 'undefined' ? constr : 'chart';
126126

127-
Highcharts[constr](
128-
'container',
129-
finalOptions,
130-
finalCallback
131-
);
127+
Highcharts[constr]('container', finalOptions, finalCallback);
132128

133129
// Get the current global options
134130
const defaultOptions = getOptions();

‎lib/schemas/config.js

+14
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,20 @@ export const defaultConfig = {
392392
cliName: 'proxyPort',
393393
description: 'The port of the proxy server to use, if it exists.'
394394
},
395+
username: {
396+
value: false,
397+
type: 'string',
398+
envLink: 'SERVER_PROXY_USERNAME',
399+
cliName: 'proxyUsername',
400+
description: 'The username for the proxy server, if it exists.'
401+
},
402+
password: {
403+
value: false,
404+
type: 'string',
405+
envLink: 'SERVER_PROXY_PASSWORD',
406+
cliName: 'proxyPassword',
407+
description: 'The password for the proxy server, if it exists.'
408+
},
395409
timeout: {
396410
value: 5000,
397411
type: 'number',

‎package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"author": "Highsoft AS <support@highcharts.com> (http://www.highcharts.com/about)",
44
"license": "MIT",
55
"type": "module",
6-
"version": "4.0.2",
6+
"version": "4.0.3",
77
"main": "./dist/index.esm.js",
88
"engines": {
99
"node": ">=18.12.0"

0 commit comments

Comments
 (0)
Please sign in to comment.