From a55afefbdcac56f3504635b503b8fa7b96325105 Mon Sep 17 00:00:00 2001 From: Martin Madsen Date: Fri, 26 Jul 2024 00:03:53 +0200 Subject: [PATCH 1/8] Adjust package.json for distribution --- package.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/package.json b/package.json index fffe9b8b..66a85307 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ "require": "./dist/index.cjs" } }, + "files": ["dist", "bin", "templates", "install.js", "lib"], "repository": { "url": "https://github.com/highcharts/node-export-server", "type": "git" @@ -35,6 +36,7 @@ "node-tests": "node ./tests/node/node_test_runner.js", "node-tests-single": "node ./tests/node/node_test_runner_single.js", "prepare": "husky || true", + "prepack": "npm run build", "build": "rollup -c", "unit:test": "node --experimental-vm-modules node_modules/jest/bin/jest.js" }, From 57787f4e135c6b0a164e1dc35cc3b7edfea01d81 Mon Sep 17 00:00:00 2001 From: Dietrich Streifert Date: Wed, 31 Jul 2024 15:53:03 +0200 Subject: [PATCH 2/8] Make userOptions of the chart available within customCode context Make the chart options available again in the customCode context which is compatible to the previous, phantomjs/node export server. Fixes https://github.com/highcharts/node-export-server/issues/548 --- lib/highcharts.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/highcharts.js b/lib/highcharts.js index 76afd976..e82a2213 100644 --- a/lib/highcharts.js +++ b/lib/highcharts.js @@ -41,11 +41,6 @@ export async function triggerExport(chartOptions, options, displayErrors) { // prevent from polluting other exports that can happen on the same page Highcharts.setOptionsObj = merge(false, {}, getOptions()); - // Trigger custom code - if (options.customLogic.customCode) { - new Function(options.customLogic.customCode)(); - } - // By default animation is disabled const chart = { animation: false @@ -100,6 +95,11 @@ export async function triggerExport(chartOptions, options, displayErrors) { const userOptions = options.export.strInj ? new Function(`return ${options.export.strInj}`)() : chartOptions; + + // Trigger custom code + if (options.customLogic.customCode) { + new Function('options', options.customLogic.customCode)(userOptions); + } // Merge the globalOptions, themeOptions, options from the wrapped // setOptions function and user options to create the final options object From 7be35f42eceab35ed4ec11efc9b5f306b2bfa8a4 Mon Sep 17 00:00:00 2001 From: Dietrich Streifert Date: Fri, 2 Aug 2024 15:07:58 +0200 Subject: [PATCH 3/8] Update CHANGELOG.md --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index be50937b..10f9ee88 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# 4.1.0 + +_Fixes:_ + +- Made chart userOptions available within `customCode` as variable `options` [(#551)](https://github.com/highcharts/node-export-server/issues/551). + # 4.0.0 _Breaking Changes:_ From 79bef502c45feceaa146cc2cfbebbc21c9509689 Mon Sep 17 00:00:00 2001 From: "Chris M. Vasseng" Date: Mon, 5 Aug 2024 09:40:47 +0200 Subject: [PATCH 4/8] v4.0.1 --- CHANGELOG.md | 6 ++++++ package.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index be50937b..6e0f635d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# 4.0.1 + +_Hotfix_: + +- Fixed missing 'dist' bundle in 4.0.0 on NPM. + # 4.0.0 _Breaking Changes:_ diff --git a/package.json b/package.json index 66a85307..73fa2248 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "author": "Highsoft AS (http://www.highcharts.com/about)", "license": "MIT", "type": "module", - "version": "4.0.0", + "version": "4.0.1", "main": "./dist/index.esm.js", "engines": { "node": ">=18.12.0" From ca80ae083a58c5a97d6f4fb0b5eb6c787ef0f7ef Mon Sep 17 00:00:00 2001 From: PawelDalek Date: Mon, 5 Aug 2024 11:23:46 +0200 Subject: [PATCH 5/8] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b84f0216..2ebff2f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -# 4.1.0 +# 4.0.2 _Fixes:_ From 88cb2ac23b2cdc6859386b1dfc7622269e2d8cdb Mon Sep 17 00:00:00 2001 From: jszuminski Date: Mon, 5 Aug 2024 13:49:27 +0200 Subject: [PATCH 6/8] Add necessary msg and public directory to distribution. --- package.json | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 73fa2248..b9c9d642 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,15 @@ "require": "./dist/index.cjs" } }, - "files": ["dist", "bin", "templates", "install.js", "lib"], + "files": [ + "dist", + "bin", + "templates", + "install.js", + "lib", + "msg", + "public" + ], "repository": { "url": "https://github.com/highcharts/node-export-server", "type": "git" From fc10da5a8d862ce3ad32df805753604d053fa0a4 Mon Sep 17 00:00:00 2001 From: PaulDalek Date: Mon, 5 Aug 2024 14:24:54 +0200 Subject: [PATCH 7/8] Small corrections. --- CHANGELOG.md | 4 ++++ package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2ebff2f1..9254b1bb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # 4.0.2 +_Hotfix_: + +- Fixed missing 'msg' and 'public' bundle in 4.0.1 on NPM. + _Fixes:_ - Made chart userOptions available within `customCode` as variable `options` [(#551)](https://github.com/highcharts/node-export-server/issues/551). diff --git a/package-lock.json b/package-lock.json index 63ce1fdb..172be3fe 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "highcharts-export-server", - "version": "4.0.0", + "version": "4.0.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "highcharts-export-server", - "version": "4.0.0", + "version": "4.0.2", "hasInstallScript": true, "license": "MIT", "dependencies": { diff --git a/package.json b/package.json index b9c9d642..1ece8de2 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "author": "Highsoft AS (http://www.highcharts.com/about)", "license": "MIT", "type": "module", - "version": "4.0.1", + "version": "4.0.2", "main": "./dist/index.esm.js", "engines": { "node": ">=18.12.0" From 10865d4f46e56dbb631f4421e1d1885777667a63 Mon Sep 17 00:00:00 2001 From: jszuminski Date: Wed, 21 Aug 2024 09:50:18 +0200 Subject: [PATCH 8/8] Introduce proxy username, proxy password options for proxy auth. --- .env.sample | 2 ++ README.md | 4 ++++ lib/cache.js | 10 +++++----- lib/envs.js | 2 ++ lib/highcharts.js | 2 +- lib/schemas/config.js | 14 ++++++++++++++ 6 files changed, 28 insertions(+), 6 deletions(-) diff --git a/.env.sample b/.env.sample index 7283f259..cf774945 100644 --- a/.env.sample +++ b/.env.sample @@ -29,6 +29,8 @@ SERVER_BENCHMARKING = false # SERVER PROXY CONFIG SERVER_PROXY_HOST = SERVER_PROXY_PORT = +SERVER_PROXY_USERNAME = +SERVER_PROXY_PASSWORD = SERVER_PROXY_TIMEOUT = 5000 # SERVER RATE LIMITING CONFIG diff --git a/README.md b/README.md index effeb48f..d7d220c3 100644 --- a/README.md +++ b/README.md @@ -319,6 +319,8 @@ These variables are set in your environment and take precedence over options fro - `SERVER_PROXY_HOST`: The host of the proxy server to use, if it exists (defaults to ``). - `SERVER_PROXY_PORT`: The port of the proxy server to use, if it exists (defaults to ``). +- `SERVER_PROXY_USERNAME`: If used proxy with authentication, need to pass username and password (optional, defaults to `false`). +- `SERVER_PROXY_PASSWORD`: If used proxy with authentication, need to pass username and password (optional, defaults to `false`). - `SERVER_PROXY_TIMEOUT`: The timeout for the proxy server to use, if it exists (defaults to ``). ### Server Rate Limiting Config @@ -414,6 +416,8 @@ _Available options:_ - `--serverBenchmarking`: Indicates whether to display the duration, in milliseconds, of specific actions that occur on the server while serving a request (defaults to `false`). - `--proxyHost`: The host of the proxy server to use, if it exists (defaults to `false`). - `--proxyPort`: The port of the proxy server to use, if it exists (defaults to `false`). +- `--proxyUsername`: If you want your proxy to be authenticated, pass the username with password (defaults to `false`). +- `--proxyPassword`: If you want your proxy to be authenticated, pass the username with password (defaults to `false`). - `--proxyTimeout`: The timeout for the proxy server to use, if it exists (defaults to `5000`). - `--enableRateLimiting`: Enables rate limiting for the server (defaults to `false`). - `--maxRequests`: The maximum number of requests allowed in one minute (defaults to `10`). diff --git a/lib/cache.js b/lib/cache.js index cd712a15..fea7c051 100644 --- a/lib/cache.js +++ b/lib/cache.js @@ -174,15 +174,15 @@ export const fetchScripts = async ( ) => { // Configure proxy if exists let proxyAgent; - const proxyHost = proxyOptions.host; - const proxyPort = proxyOptions.port; + const { host, port, username, password } = proxyOptions; // Try to create a Proxy Agent - if (proxyHost && proxyPort) { + if (host && port) { try { proxyAgent = new HttpsProxyAgent({ - host: proxyHost, - port: proxyPort + host, + port, + ...(username && password ? { username, password } : {}) }); } catch (error) { throw new ExportError('[cache] Could not create a Proxy Agent.').setError( diff --git a/lib/envs.js b/lib/envs.js index 885d7f07..4e37afb9 100644 --- a/lib/envs.js +++ b/lib/envs.js @@ -148,6 +148,8 @@ export const Config = z.object({ // server proxy SERVER_PROXY_HOST: v.string(), SERVER_PROXY_PORT: v.positiveNum(), + SERVER_PROXY_USERNAME: v.string(), + SERVER_PROXY_PASSWORD: v.string(), SERVER_PROXY_TIMEOUT: v.nonNegativeNum(), // server rate limiting diff --git a/lib/highcharts.js b/lib/highcharts.js index e82a2213..5e4b1df6 100644 --- a/lib/highcharts.js +++ b/lib/highcharts.js @@ -95,7 +95,7 @@ export async function triggerExport(chartOptions, options, displayErrors) { const userOptions = options.export.strInj ? new Function(`return ${options.export.strInj}`)() : chartOptions; - + // Trigger custom code if (options.customLogic.customCode) { new Function('options', options.customLogic.customCode)(userOptions); diff --git a/lib/schemas/config.js b/lib/schemas/config.js index 50600dfd..29e7075d 100644 --- a/lib/schemas/config.js +++ b/lib/schemas/config.js @@ -392,6 +392,20 @@ export const defaultConfig = { cliName: 'proxyPort', description: 'The port of the proxy server to use, if it exists.' }, + username: { + value: false, + type: 'string', + envLink: 'SERVER_PROXY_USERNAME', + cliName: 'proxyUsername', + description: 'The username for the proxy server, if it exists.' + }, + password: { + value: false, + type: 'string', + envLink: 'SERVER_PROXY_PASSWORD', + cliName: 'proxyPassword', + description: 'The password for the proxy server, if it exists.' + }, timeout: { value: 5000, type: 'number',