diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 7a1dc551999..7ca9ed388c6 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -182,6 +182,9 @@ importers: http-errors: specifier: ^2.0.0 version: 2.0.0 + https-proxy-agent: + specifier: ^7.0.6 + version: 7.0.6 jose: specifier: ^5.10.0 version: 5.10.0 @@ -7510,7 +7513,7 @@ snapshots: transitivePeerDependencies: - supports-color - eslint-module-utils@2.12.0(@typescript-eslint/parser@7.18.0(eslint@9.24.0)(typescript@5.8.3))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.10.0)(eslint@9.24.0): + eslint-module-utils@2.12.0(@typescript-eslint/parser@7.18.0(eslint@9.24.0)(typescript@5.8.3))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.10.0(eslint-plugin-import@2.31.0)(eslint@9.24.0))(eslint@9.24.0): dependencies: debug: 3.2.7 optionalDependencies: @@ -7550,7 +7553,7 @@ snapshots: doctrine: 2.1.0 eslint: 9.24.0 eslint-import-resolver-node: 0.3.9 - eslint-module-utils: 2.12.0(@typescript-eslint/parser@7.18.0(eslint@9.24.0)(typescript@5.8.3))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.10.0)(eslint@9.24.0) + eslint-module-utils: 2.12.0(@typescript-eslint/parser@7.18.0(eslint@9.24.0)(typescript@5.8.3))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.10.0(eslint-plugin-import@2.31.0)(eslint@9.24.0))(eslint@9.24.0) hasown: 2.0.2 is-core-module: 2.16.1 is-glob: 4.0.3 diff --git a/src/node/hooks/express/adminplugins.ts b/src/node/hooks/express/adminplugins.ts index 4dcb8a0abcb..178e6187f07 100644 --- a/src/node/hooks/express/adminplugins.ts +++ b/src/node/hooks/express/adminplugins.ts @@ -5,9 +5,10 @@ import {ErrorCaused} from "../../types/ErrorCaused"; import {QueryType} from "../../types/QueryType"; import {getAvailablePlugins, install, search, uninstall} from "../../../static/js/pluginfw/installer"; -import {PackageData} from "../../types/PackageInfo"; +import {PackageData, PackageInfo} from "../../types/PackageInfo"; import semver from 'semver'; import log4js from 'log4js'; +import {MapArrayType} from "../../types/MapType"; const pluginDefs = require('../../../static/js/pluginfw/plugin_defs'); const logger = log4js.getLogger('adminPlugins'); @@ -21,7 +22,13 @@ exports.socketio = (hookName:string, args:ArgsExpressType, cb:Function) => { if (!isAdmin) return; const checkPluginForUpdates = async () => { - const results = await getAvailablePlugins(/* maxCacheAge:*/ 60 * 10); + let results: MapArrayType + try { + results = await getAvailablePlugins(/* maxCacheAge:*/ 60 * 10); + } catch (error) { + console.error('Error checking for plugin updates:', error); + return []; + } return Object.keys(pluginDefs.plugins).filter((plugin) => { if (!results[plugin]) return false; diff --git a/src/node/server.ts b/src/node/server.ts index 507ed5f7958..f81cabdc24d 100755 --- a/src/node/server.ts +++ b/src/node/server.ts @@ -42,6 +42,10 @@ if (settings.dumpOnUncleanExit) { const addProxyToAxios = (url: URL) => { axios.defaults.proxy = { host: url.hostname, + auth: { + username: url.username, + password: url.password, + }, port: Number(url.port), protocol: url.protocol, } diff --git a/src/package.json b/src/package.json index bce094234e3..0bf8007241d 100644 --- a/src/package.json +++ b/src/package.json @@ -49,6 +49,7 @@ "jsdom": "^26.0.0", "jsonminify": "0.4.2", "jsonwebtoken": "^9.0.2", + "jwt-decode": "^4.0.0", "languages4translatewiki": "0.1.3", "live-plugin-manager": "^1.0.0", "lodash.clonedeep": "4.5.0", @@ -70,7 +71,6 @@ "socket.io-client": "^4.8.1", "superagent": "10.2.0", "swagger-ui-express": "^5.0.1", - "jwt-decode": "^4.0.0", "tinycon": "0.6.8", "tsx": "4.19.3", "ueberdb2": "^5.0.6", diff --git a/src/static/js/pluginfw/installer.ts b/src/static/js/pluginfw/installer.ts index c605378e1bd..98590e9e585 100644 --- a/src/static/js/pluginfw/installer.ts +++ b/src/static/js/pluginfw/installer.ts @@ -162,23 +162,18 @@ export const install = async (pluginName: string, cb:Function|null = null) => { export let availablePlugins:MapArrayType|null = null; let cacheTimestamp = 0; -export const getAvailablePlugins = (maxCacheAge: number|false) => { +export const getAvailablePlugins = async (maxCacheAge: number | false) => { const nowTimestamp = Math.round(Date.now() / 1000); - return new Promise>(async (resolve, reject) => { - // check cache age before making any request - if (availablePlugins && maxCacheAge && (nowTimestamp - cacheTimestamp) <= maxCacheAge) { - return resolve(availablePlugins); - } + // check cache age before making any request + if (availablePlugins && maxCacheAge && (nowTimestamp - cacheTimestamp) <= maxCacheAge) { + return availablePlugins; + } - await axios.get(`${settings.updateServer}/plugins.json`, {headers}) - .then((pluginsLoaded:AxiosResponse>) => { - availablePlugins = pluginsLoaded.data; - cacheTimestamp = nowTimestamp; - resolve(availablePlugins); - }) - .catch(async (err) => reject(err)); - }); + const pluginsLoaded: AxiosResponse> = await axios.get(`${settings.updateServer}/plugins.json`, {headers}) + availablePlugins = pluginsLoaded.data; + cacheTimestamp = nowTimestamp; + return availablePlugins; }; @@ -211,4 +206,7 @@ export const search = (searchTerm: string, maxCacheAge: number) => getAvailableP return res; } -); +).catch((err)=>{ + logger.error(`Error searching plugins: ${err}`); + return {} as MapArrayType; +});