Browse Source

e2ee: avoid CORS issues with the worker bundle

master
Saúl Ibarra Corretgé 4 years ago
parent
commit
f761413976
1 changed files with 8 additions and 2 deletions
  1. 8
    2
      modules/e2ee/E2EEContext.js

+ 8
- 2
modules/e2ee/E2EEContext.js View File

45
             baseUrl = `${ljm.src.substring(0, idx)}/`;
45
             baseUrl = `${ljm.src.substring(0, idx)}/`;
46
         }
46
         }
47
 
47
 
48
-        // Initialize the E2EE worker.
49
-        this._worker = new Worker(`${baseUrl}lib-jitsi-meet.e2ee-worker.js`, { name: 'E2EE Worker' });
48
+        // Initialize the E2EE worker. In order to avoid CORS issues, start the worker and have it
49
+        // synchronously load the JS.
50
+        const workerUrl = `${baseUrl}lib-jitsi-meet.e2ee-worker.js`;
51
+        const workerBlob
52
+            = new Blob([ `importScripts("${workerUrl}");` ], { type: 'application/javascript' });
53
+        const blobUrl = window.URL.createObjectURL(workerBlob);
54
+
55
+        this._worker = new Worker(blobUrl, { name: 'E2EE Worker' });
50
         this._worker.onerror = e => logger.onerror(e);
56
         this._worker.onerror = e => logger.onerror(e);
51
 
57
 
52
         // Initialize the salt and convert it once.
58
         // Initialize the salt and convert it once.

Loading…
Cancel
Save