Просмотр исходного кода

bugfix(e2ee): frees olm session and rotates key when remote participant disabled e2ee

dev1
tmoldovan8x8 4 лет назад
Родитель
Сommit
49c4e75f37
Аккаунт пользователя с таким Email не найден
2 измененных файлов: 21 добавлений и 6 удалений
  1. 7
    0
      modules/e2ee/E2EEncryption.js
  2. 14
    6
      modules/e2ee/OlmAdapter.js

+ 7
- 0
modules/e2ee/E2EEncryption.js Просмотреть файл

263
         case 'e2ee.idKey':
263
         case 'e2ee.idKey':
264
             logger.debug(`Participant ${participant.getId()} updated their id key: ${newValue}`);
264
             logger.debug(`Participant ${participant.getId()} updated their id key: ${newValue}`);
265
             break;
265
             break;
266
+        case 'e2ee.enabled':
267
+            if (!newValue && this._enabled) {
268
+                this._olmAdapter.clearParticipantSession(participant);
269
+
270
+                this._rotateKey();
271
+            }
272
+            break;
266
         }
273
         }
267
     }
274
     }
268
 
275
 

+ 14
- 6
modules/e2ee/OlmAdapter.js Просмотреть файл

185
         return this._keyIndex;
185
         return this._keyIndex;
186
     }
186
     }
187
 
187
 
188
+    /**
189
+     * Frees the olmData session for the given participant.
190
+     *
191
+     */
192
+    clearParticipantSession(participant) {
193
+        const olmData = this._getParticipantOlmData(participant);
194
+
195
+        if (olmData.session) {
196
+            olmData.session.free();
197
+            olmData.session = undefined;
198
+        }
199
+    }
200
+
188
     /**
201
     /**
189
      * Internal helper to bootstrap the olm library.
202
      * Internal helper to bootstrap the olm library.
190
      *
203
      *
440
     _onParticipantLeft(id, participant) {
453
     _onParticipantLeft(id, participant) {
441
         logger.debug(`Participant ${id} left`);
454
         logger.debug(`Participant ${id} left`);
442
 
455
 
443
-        const olmData = this._getParticipantOlmData(participant);
444
-
445
-        if (olmData.session) {
446
-            olmData.session.free();
447
-            olmData.session = undefined;
448
-        }
456
+        this.clearParticipantSession(participant);
449
     }
457
     }
450
 
458
 
451
     /**
459
     /**

Загрузка…
Отмена
Сохранить