Skip to content

Commit

Permalink
Fixed error in import of crypto (#480)
Browse files Browse the repository at this point in the history
* Fixed error in import

* Updated release pipeline to run from different branches

* Updated pipeline

* Bump version

* Fixed error with broken crypto method
  • Loading branch information
AleksSavelev authored Aug 29, 2023
1 parent 3151ab4 commit ba6385d
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 8 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
Expand Down
2 changes: 2 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -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.1.0
* New flag `--skip-api` to skip verifying api version. It might produce different errors in visual, so use it only in some specific cases (ex. installing something during the build process brakes packages managed by monorepo managers).
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "powerbi-visuals-tools",
"version": "5.1.0",
"version": "5.1.1",
"description": "Command line tool for creating and publishing visuals for Power BI",
"main": "./bin/pbiviz.js",
"type": "module",
Expand Down
14 changes: 9 additions & 5 deletions src/CertificateTools.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-case-declarations */
/*
* Power BI Visual CLI
*
Expand Down Expand Up @@ -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';

Expand Down Expand Up @@ -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);
Expand All @@ -160,7 +158,13 @@ export async function createCertFile(config, open) {
}
break;
}
passphrase = (crypto.getRandomValues || <typeof 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 /
Expand Down

0 comments on commit ba6385d

Please sign in to comment.