@aikidosec/firewall
Version:
Zen by Aikido is an embedded Application Firewall that autonomously protects Node.js apps against common and critical attacks, provides rate limiting, detects malicious traffic (including bots), and more.
22 lines (21 loc) • 755 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getPackageVersion = getPackageVersion;
const getPackageVersionFromPath_1 = require("../agent/hooks/instrumentation/getPackageVersionFromPath");
const getModuleInfoFromPath_1 = require("../agent/hooks/getModuleInfoFromPath");
/**
* Get the installed version of a package
*/
function getPackageVersion(pkg) {
try {
const entrypoint = require.resolve(pkg);
const moduleInfo = (0, getModuleInfoFromPath_1.getModuleInfoFromPath)(entrypoint);
if (!moduleInfo) {
return undefined;
}
return (0, getPackageVersionFromPath_1.getPackageVersionFromPath)(moduleInfo.base);
}
catch {
return undefined;
}
}