Преглед изворни кода

e2ee: avoid CORS issues with the worker bundle

master
Saúl Ibarra Corretgé пре 4 година
родитељ
комит
f761413976
1 измењених фајлова са 8 додато и 2 уклоњено
  1. 8
    2
      modules/e2ee/E2EEContext.js

+ 8
- 2
modules/e2ee/E2EEContext.js Прегледај датотеку

@@ -45,8 +45,14 @@ export default class E2EEcontext {
45 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 56
         this._worker.onerror = e => logger.onerror(e);
51 57
 
52 58
         // Initialize the salt and convert it once.

Loading…
Откажи
Сачувај