Remove browser specific code
This commit is contained in:
parent
de53915150
commit
f544c289da
|
@ -6,26 +6,9 @@ type Bls = typeof bls;
|
|||
let blsGlobal: Bls | null = null;
|
||||
let blsGlobalPromise: Promise<void> | null = null;
|
||||
|
||||
// Patch to fix multiVerify() calls on a browser with polyfilled NodeJS crypto
|
||||
declare global {
|
||||
// eslint-disable-next-line @typescript-eslint/interface-name-prefix
|
||||
interface Window {
|
||||
msCrypto: typeof window["crypto"];
|
||||
}
|
||||
}
|
||||
|
||||
export async function setupBls(): Promise<void> {
|
||||
if (!blsGlobal) {
|
||||
await bls.init(bls.BLS12_381);
|
||||
|
||||
// Patch to fix multiVerify() calls on a browser with polyfilled NodeJS crypto
|
||||
if (typeof window === "object") {
|
||||
const crypto = window.crypto || window.msCrypto;
|
||||
// getRandomValues is not typed in `bls-eth-wasm` because it's not meant to be exposed
|
||||
// @ts-ignore
|
||||
bls.getRandomValues = (x) => crypto.getRandomValues(x);
|
||||
}
|
||||
|
||||
blsGlobal = bls;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
"target": "esnext",
|
||||
"module": "commonjs",
|
||||
"pretty": true,
|
||||
"lib": ["esnext.bigint", "DOM"],
|
||||
"lib": ["esnext.bigint"],
|
||||
"typeRoots": ["./node_modules/@types"],
|
||||
"declaration": true,
|
||||
"strict": true,
|
||||
|
|
Reference in New Issue