File tree Expand file tree Collapse file tree 2 files changed +18
-10
lines changed
Expand file tree Collapse file tree 2 files changed +18
-10
lines changed Original file line number Diff line number Diff line change @@ -84,21 +84,17 @@ export class ManagedKeyHandler extends KeyHandler {
8484 if ( enabled ) {
8585 // Initialize Olm sessions with all participants.
8686 await this . _olmAdapter . initSessions ( ) ;
87-
8887 logger . debug ( 'All Olm sessions established, proceeding with key distribution' ) ;
89- } else {
90- this . _olmAdapter . clearAllParticipantsSessions ( ) ;
9188 }
92-
93- // Generate a random key in case we are enabling.
9489 this . _key = enabled ? this . _generateKey ( ) : false ;
95-
96- // Send it to others using the E2EE olm channel.
97- // At this point, all sessions should be ready.
9890 const index = await this . _olmAdapter . updateKey ( this . _key ) ;
9991
100- // Set our key so we begin encrypting.
10192 this . e2eeCtx . setKey ( this . conference . myUserId ( ) , this . _key , index ) ;
93+
94+ // Clear sessions after key distribution when disabling.
95+ if ( ! enabled ) {
96+ this . _olmAdapter . clearAllParticipantsSessions ( ) ;
97+ }
10298 }
10399
104100 /**
Original file line number Diff line number Diff line change @@ -240,7 +240,7 @@ export class OlmAdapter extends Listenable {
240240 }
241241
242242 /**
243- * Frees the olmData session for the given participant.
243+ * Frees the olmData session for the given participant and clears all session-related state .
244244 *
245245 */
246246 clearParticipantSession ( participant ) {
@@ -250,6 +250,16 @@ export class OlmAdapter extends Listenable {
250250 olmData . session . free ( ) ;
251251 olmData . session = undefined ;
252252 }
253+
254+ // Clear all session-related state to allow clean re-initialization
255+ olmData . pendingSessionUuid = undefined ;
256+ olmData . lastKey = undefined ;
257+
258+ // Clean up SAS verification if active
259+ if ( olmData . sasVerification ?. sas ) {
260+ olmData . sasVerification . sas . free ( ) ;
261+ }
262+ olmData . sasVerification = undefined ;
253263 }
254264
255265 /**
@@ -260,6 +270,8 @@ export class OlmAdapter extends Listenable {
260270 for ( const participant of this . _conf . getParticipants ( ) ) {
261271 this . clearParticipantSession ( participant ) ;
262272 }
273+ this . _reqs . clear ( ) ;
274+ this . _sessionInitialization = undefined ;
263275 }
264276
265277 /**
You can’t perform that action at this time.
0 commit comments