Skip to content

Commit

Permalink
fix: updated @types/node-forge version and fixed `keysUtils.getRand…
Browse files Browse the repository at this point in the history
…omBytes`
  • Loading branch information
tegefaulkes committed Apr 28, 2022
1 parent 7019b12 commit 08beafc
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
6 changes: 3 additions & 3 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
Expand Up @@ -113,7 +113,7 @@
"@types/level": "^6.0.0",
"@types/nexpect": "^0.4.31",
"@types/node": "^14.14.35",
"@types/node-forge": "^0.9.7",
"@types/node-forge": "^0.10.4",
"@types/pako": "^1.0.2",
"@types/prompts": "^2.0.13",
"@types/readable-stream": "^2.3.11",
Expand Down
11 changes: 10 additions & 1 deletion src/keys/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,16 @@ function publicKeyBitSize(publicKey: PublicKey): number {
}

async function getRandomBytes(size: number): Promise<Buffer> {
return Buffer.from(random.getBytes(size), 'binary');
const p = new Promise<string>((resolve, reject) => {
random.getBytes(size, (e, bytes) => {
if (e != null) {
reject(e);
} else {
resolve(bytes);
}
});
});
return Buffer.from(await p, 'binary');
}

function getRandomBytesSync(size: number): Buffer {
Expand Down

0 comments on commit 08beafc

Please sign in to comment.