Skip to content

Commit

Permalink
fix: removed dep from window object (#112)
Browse files Browse the repository at this point in the history
* fix: removed dep from `window` object

* fix: use env crypto instead of external package

* Pin to last known good version

* fix: removed dep from `window` object

* fix: use env crypto instead of external package
  • Loading branch information
shamoilarsi authored Jun 2, 2023
1 parent 3dd50ff commit 8821446
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src_ts/rand.browser.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
function get4RandomBytes(): Uint8Array {
const bytes = new Uint8Array(4);
window.crypto.getRandomValues(bytes);

if (typeof crypto === "undefined") {
throw new Error(
"The crypto object is unavailable. This may occur if your environment does not support the Web Cryptography API."
);
}

crypto.getRandomValues(bytes);
return bytes;
}

Expand Down

0 comments on commit 8821446

Please sign in to comment.