diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 123e5931..c863621d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -12,6 +12,8 @@ jobs: GH_TOKEN: ${{secrets.GH_TOKEN}} steps: - uses: actions/checkout@v2 + with: + ref: ${{ vars.BRANCH_NAME }} - name: Add config details run: | git config --global user.name ${{secrets.NAME}} diff --git a/Changelog.md b/Changelog.md index e137315d..e4547327 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,6 +1,8 @@ # Change Log - PowerBI Visual Tools (pbiviz) This page contains information about changes to the PowerBI Visual Tools (pbiviz). +## 5.1.1 +* Updated crypto import to fix error in old Node versions ## 5.2.0 * Integrated PAC validation diff --git a/src/CertificateTools.ts b/src/CertificateTools.ts index 19fde662..a2736818 100644 --- a/src/CertificateTools.ts +++ b/src/CertificateTools.ts @@ -1,3 +1,4 @@ +/* eslint-disable no-case-declarations */ /* * Power BI Visual CLI * @@ -30,7 +31,7 @@ import { exec as nodeExec } from 'child_process'; import fs from 'fs-extra'; import os from 'os'; import path from 'path'; -import crypto, { webcrypto } from "crypto" +import crypto from "crypto" import { getRootPath, readJsonFromRoot } from './utils.js'; import ConsoleWriter from './ConsoleWriter.js'; @@ -134,11 +135,8 @@ export async function createCertFile(config, open) { } break; case "win32": - // eslint-disable-next-line no-case-declarations - let passphrase = ""; // for windows 7 and others // 6.1 - Windows 7 - // eslint-disable-next-line no-case-declarations const osVersion = os.release().split("."); if ((Number(osVersion[0]) === 6 && Number(osVersion[1]) === 1) || Number(osVersion[0]) < 6) { await removeCertFiles(certPath, keyPath, pfxPath); @@ -160,7 +158,13 @@ export async function createCertFile(config, open) { } break; } - passphrase = (crypto.getRandomValues || webcrypto.getRandomValues)(new Uint32Array(1))[0].toString().substring(2); + let randomValues: Uint32Array; + if(crypto.getRandomValues !== undefined){ + randomValues = crypto.getRandomValues(new Uint32Array(1)); + } else { + randomValues = crypto.webcrypto.getRandomValues(new Uint32Array(1)); + } + const passphrase = randomValues[0].toString().substring(2); config.server.passphrase = passphrase; fs.writeFileSync(path.join(rootPath, confPath), JSON.stringify(config)); // for windows 8 / 8.1 / server 2012 R2 /