aboutsummaryrefslogtreecommitdiff
path: root/src/crypto/browserWorkerEntry.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/crypto/browserWorkerEntry.ts')
-rw-r--r--src/crypto/browserWorkerEntry.ts52
1 files changed, 1 insertions, 51 deletions
diff --git a/src/crypto/browserWorkerEntry.ts b/src/crypto/browserWorkerEntry.ts
index d133e93cc..5ac762c13 100644
--- a/src/crypto/browserWorkerEntry.ts
+++ b/src/crypto/browserWorkerEntry.ts
@@ -23,61 +23,11 @@
*/
import { CryptoImplementation } from "./cryptoImplementation";
-import { EmscEnvironment } from "./emscInterface";
const worker: Worker = (self as any) as Worker;
-class BrowserEmscriptenLoader {
- private cachedEmscEnvironment: EmscEnvironment | undefined = undefined;
- private cachedEmscEnvironmentPromise:
- | Promise<EmscEnvironment>
- | undefined = undefined;
-
- async getEmscriptenEnvironment(): Promise<EmscEnvironment> {
-
- if (this.cachedEmscEnvironment) {
- return this.cachedEmscEnvironment;
- }
-
- if (this.cachedEmscEnvironmentPromise) {
- return this.cachedEmscEnvironmentPromise;
- }
-
- console.log("loading emscripten lib with 'importScripts'");
- // @ts-ignore
- self.TalerEmscriptenLib = {};
- // @ts-ignore
- importScripts('/emscripten/taler-emscripten-lib.js')
- // @ts-ignore
- if (!self.TalerEmscriptenLib) {
- throw Error("can't import taler emscripten lib");
- }
- const locateFile = (path: string, scriptDir: string) => {
- console.log("locating file", "path", path, "scriptDir", scriptDir);
- // This is quite hacky and assumes that our scriptDir is dist/
- return scriptDir + "../emscripten/" + path;
- };
- console.log("instantiating TalerEmscriptenLib");
- // @ts-ignore
- const lib = self.TalerEmscriptenLib({ locateFile });
- return new Promise((resolve, reject) => {
- lib.then((mod: any) => {
- this.cachedEmscEnvironmentPromise = undefined;
- const emsc = new EmscEnvironment(mod);
- this.cachedEmscEnvironment = new EmscEnvironment(mod);
- console.log("emscripten module fully loaded");
- resolve(emsc);
- });
- });
- }
-}
-
-let loader = new BrowserEmscriptenLoader();
-
async function handleRequest(operation: string, id: number, args: string[]) {
- let emsc = await loader.getEmscriptenEnvironment();
-
- const impl = new CryptoImplementation(emsc);
+ const impl = new CryptoImplementation();
if (!(operation in impl)) {
console.error(`crypto operation '${operation}' not found`);