fix: proper browser env check...

This commit is contained in:
ppe
2022-09-20 14:00:13 +02:00
parent 1d0c1a4688
commit 053ceaf3ea

View File

@@ -78,9 +78,11 @@ export function bufToBn(buf: Buffer) {
}
export function isomorphicRandomUUID() {
if (self.crypto) {
if (isBrowser() && self.crypto) {
return self.crypto.randomUUID();
} else {
return randomUUID();
}
}
const isBrowser = new Function("try {return this===window;}catch(e){ return false;}");