Remove browser specific code

This commit is contained in:
dapplion 2020-12-06 11:35:17 +00:00
parent de53915150
commit f544c289da
2 changed files with 1 additions and 18 deletions

View File

@ -6,26 +6,9 @@ type Bls = typeof bls;
let blsGlobal: Bls | null = null; let blsGlobal: Bls | null = null;
let blsGlobalPromise: Promise<void> | 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> { export async function setupBls(): Promise<void> {
if (!blsGlobal) { if (!blsGlobal) {
await bls.init(bls.BLS12_381); 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; blsGlobal = bls;
} }
} }

View File

@ -4,7 +4,7 @@
"target": "esnext", "target": "esnext",
"module": "commonjs", "module": "commonjs",
"pretty": true, "pretty": true,
"lib": ["esnext.bigint", "DOM"], "lib": ["esnext.bigint"],
"typeRoots": ["./node_modules/@types"], "typeRoots": ["./node_modules/@types"],
"declaration": true, "declaration": true,
"strict": true, "strict": true,