Bladeren bron

fix(e2ee): destroys olm session on disabling e2ee

tags/v0.0.2
tmoldovan8x8 4 jaren geleden
bovenliggende
commit
dd902dd33d
No account linked to committer's email address
3 gewijzigde bestanden met toevoegingen van 18 en 23 verwijderingen
  1. 0
    12
      modules/e2ee/Context.js
  2. 6
    10
      modules/e2ee/E2EEncryption.js
  3. 12
    1
      modules/e2ee/OlmAdapter.js

+ 0
- 12
modules/e2ee/Context.js Bestand weergeven

@@ -250,8 +250,6 @@ export class Context {
250 250
 
251 251
             encodedFrame.data = newData;
252 252
         } catch (error) {
253
-            console.error(error);
254
-
255 253
             if (ratchetCount < RATCHET_WINDOW_SIZE) {
256 254
                 material = await importKey(await ratchet(material));
257 255
 
@@ -266,16 +264,6 @@ export class Context {
266 264
             }
267 265
 
268 266
             // TODO: notify the application about error status.
269
-
270
-            // TODO: For video we need a better strategy since we do not want to based any
271
-            // non-error frames on a garbage keyframe.
272
-            if (encodedFrame.type === undefined) { // audio, replace with silence.
273
-                const newData = new ArrayBuffer(3);
274
-                const newUint8 = new Uint8Array(newData);
275
-
276
-                newUint8.set([ 0xd8, 0xff, 0xfe ]); // opus silence frame.
277
-                encodedFrame.data = newData;
278
-            }
279 267
         }
280 268
 
281 269
         return encodedFrame;

+ 6
- 10
modules/e2ee/E2EEncryption.js Bestand weergeven

@@ -31,7 +31,6 @@ export class E2EEncryption {
31 31
 
32 32
         this._conferenceJoined = false;
33 33
         this._enabled = false;
34
-        this._initialized = false;
35 34
         this._key = undefined;
36 35
         this._enabling = undefined;
37 36
 
@@ -130,19 +129,16 @@ export class E2EEncryption {
130 129
 
131 130
         if (enabled) {
132 131
             await this._olmAdapter.initSessions();
132
+        } else {
133
+            for (const participant of this.conference.getParticipants()) {
134
+                this._e2eeCtx.cleanup(participant.getId());
135
+            }
136
+            this._olmAdapter.clearAllParticipantsSessions();
133 137
         }
134 138
 
135 139
         this.conference.setLocalParticipantProperty('e2ee.enabled', enabled);
136 140
 
137
-        if (!this._initialized && enabled) {
138
-            // Need to re-create the peerconnections in order to apply the insertable streams constraint.
139
-            // TODO: this was necessary due to some audio issues when indertable streams are used
140
-            // even though encryption is not performed. This should be fixed in the browser eventually.
141
-            // https://bugs.chromium.org/p/chromium/issues/detail?id=1103280
142
-            this.conference._restartMediaSessions();
143
-
144
-            this._initialized = true;
145
-        }
141
+        this.conference._restartMediaSessions();
146 142
 
147 143
         // Generate a random key in case we are enabling.
148 144
         this._key = enabled ? this._generateKey() : false;

+ 12
- 1
modules/e2ee/OlmAdapter.js Bestand weergeven

@@ -82,7 +82,7 @@ export class OlmAdapter extends Listenable {
82 82
      */
83 83
     async initSessions() {
84 84
         if (this._sessionInitialization) {
85
-            throw new Error('OlmAdapte initSessions called multiple times');
85
+            throw new Error('OlmAdapter initSessions called multiple times');
86 86
         } else {
87 87
             this._sessionInitialization = new Deferred();
88 88
 
@@ -198,6 +198,17 @@ export class OlmAdapter extends Listenable {
198 198
         }
199 199
     }
200 200
 
201
+
202
+    /**
203
+     * Frees the olmData sessions for all participants.
204
+     *
205
+     */
206
+    clearAllParticipantsSessions() {
207
+        for (const participant of this._conf.getParticipants()) {
208
+            this.clearParticipantSession(participant);
209
+        }
210
+    }
211
+
201 212
     /**
202 213
      * Internal helper to bootstrap the olm library.
203 214
      *

Laden…
Annuleren
Opslaan