diff --git a/src/node/security/crypto.js b/src/node/security/crypto.js index ebe918509..95b3986fe 100644 --- a/src/node/security/crypto.js +++ b/src/node/security/crypto.js @@ -1,15 +1,18 @@ 'use strict'; const crypto = require('crypto'); -const util = require('util'); +const newMethod = async (...args) => new Promise((resolve) => crypto.hkdf(...args, resolve)); /** * Promisified version of Node.js's crypto.hkdf. */ -exports.hkdf = util.promisify(crypto.hkdf); +exports.hkdf = newMethod; + +const newMethod2 = async (...args) => new Promise((resolve) => crypto.randomBytes(...args, + resolve)); /** * Promisified version of Node.js's crypto.randomBytes */ -exports.randomBytes = util.promisify(crypto.randomBytes); \ No newline at end of file +exports.randomBytes = newMethod2; diff --git a/src/static/js/pluginfw/plugins.js b/src/static/js/pluginfw/plugins.js index 73b72acf8..debb4b0e4 100644 --- a/src/static/js/pluginfw/plugins.js +++ b/src/static/js/pluginfw/plugins.js @@ -113,20 +113,17 @@ exports.getPackages = async () => { // unset or set to `development`) because otherwise `npm ls` will not mention any packages // that are not included in `package.json` (which is expected to not exist). const commandExists = require('command-exists').sync; - if (commandExists('bun')) { - const file = Bun.readFile('package.json'); - - const text = await file.text(); - const parsedJSON = JSON.parse(text); - const dependencies = parsedJSON.dependencies; - await Promise.all(Object.entries(dependencies).map(async (pkg) => { - const info = Object(); + if (commandExists('npm')) { + const cmd = ['npm', 'ls', '--long', '--json', '--depth=0', '--no-production']; + const {dependencies = {}} = JSON.parse(await runCmd(cmd, {stdio: [null, 'string']})); + await Promise.all(Object.entries(dependencies).map(async ([pkg, info]) => { if (!pkg.startsWith(exports.prefix)) { delete dependencies[pkg]; return; } - info.realPath = `${cwd}/node_modules/${pkg}`; + info.realPath = await fs.realpath(info.path); })); + return dependencies; } else { const cmd = ['npm', 'ls', '--long', '--json', '--depth=0', '--no-production']; const {dependencies = {}} = JSON.parse(await runCmd(cmd, {stdio: [null, 'string']}));