Fix borwser env for tornado snarkjs

This commit is contained in:
ahmed korim 2022-04-05 13:50:30 +02:00
parent fe9f4119c4
commit a0a680ea80
3 changed files with 286 additions and 112 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -22,9 +22,15 @@ const bigInt = require("big-integer");
const groth16_wasm = require("../build/groth16_wasm.js"); const groth16_wasm = require("../build/groth16_wasm.js");
const assert = require("assert"); const assert = require("assert");
const inBrowser = (typeof window !== "undefined"); const inBrowser = (typeof window !== "undefined") || process && process.env && process.env.FOR_BROWSER === "true";
let NodeWorker; let NodeWorker;
let NodeCrypto; let NodeCrypto;
// eslint-disable-next-line no-console
console.log(`Running in browser ${inBrowser}`);
if (!inBrowser) { if (!inBrowser) {
NodeWorker = require("worker_threads").Worker; NodeWorker = require("worker_threads").Worker;
NodeCrypto = require("crypto"); NodeCrypto = require("crypto");