async function getGlobalPbivizCerts()

in lib/CertificateTools.js [285:308]


async function getGlobalPbivizCerts() {
    let options = {};
    try {
        let location = (await exec('npm ls -g powerbi-visuals-tools')).split("\n")[0];
        let certPath = path.join(location, "node_modules", "powerbi-visuals-tools", config.server.certificate);
        let keyPath = path.join(location, "node_modules", "powerbi-visuals-tools", config.server.privateKey);
        let pfxPath = path.join(location, "node_modules", "powerbi-visuals-tools", config.server.pfx);
        let globalPbiviConfig = path.join(location, "node_modules", "powerbi-visuals-tools", "config.json");
        options.passphrase = fs.existsSync(globalPbiviConfig) && fs.readJSONSync(globalPbiviConfig).server.passphrase;

        let CertFileVerified = await veryfyCertFile(keyPath, certPath, pfxPath, options.passphrase);

        options.cert = fs.existsSync(certPath) && certPath;
        options.key = fs.existsSync(keyPath) && keyPath;
        options.pfx = fs.existsSync(pfxPath) && CertFileVerified && pfxPath;
    }
    catch (err) {
        ConsoleWriter.warn(`Global certificate error: ${err}`);
    }
    if (!options.cert && !options.pfx) {
        ConsoleWriter.warn(`Global instance of valid pbiviz certificate not found.`);
    }
    return options;
}