@@ -46,6 +46,11 @@ import {
46
46
* XXX In the future we want to distribute a ratcheted key not the current one for new joiners.
47
47
*/
48
48
export class RTCEncryptionManager implements IEncryptionManager {
49
+ // This is a stop-gap solution for now. The preferred way to handle this case would be instead
50
+ // to create a NoOpEncryptionManager that does nothing and use it for the session.
51
+ // This will be done when removing the legacy EncryptionManager.
52
+ private manageMediaKeys = false ;
53
+
49
54
/**
50
55
* Store the key rings for each participant.
51
56
* The encryption manager stores the keys because the application layer might not be ready yet to handle the keys.
@@ -126,6 +131,8 @@ export class RTCEncryptionManager implements IEncryptionManager {
126
131
}
127
132
128
133
public join ( joinConfig : EncryptionConfig | undefined ) : void {
134
+ this . manageMediaKeys = joinConfig ?. manageMediaKeys ?? true ; // default to true
135
+
129
136
this . logger ?. info ( `Joining room` ) ;
130
137
this . useKeyDelay = joinConfig ?. useKeyDelay ?? 1000 ;
131
138
this . keyRotationGracePeriodMs = joinConfig ?. keyRotationGracePeriodMs ?? 10_000 ;
@@ -174,6 +181,10 @@ export class RTCEncryptionManager implements IEncryptionManager {
174
181
* the calls will be coalesced to a single new distribution (that will start just after the current one has completed).
175
182
*/
176
183
private ensureKeyDistribution ( ) : void {
184
+ // `manageMediaKeys` is a stop-gap solution for now. The preferred way to handle this case would be instead
185
+ // to create a NoOpEncryptionManager that does nothing and use it for the session.
186
+ // This will be done when removing the legacy EncryptionManager.
187
+ if ( ! this . manageMediaKeys ) return ;
177
188
if ( this . currentKeyDistributionPromise == null ) {
178
189
this . logger ?. debug ( `No active rollout, start a new one` ) ;
179
190
// start a rollout
@@ -196,6 +207,15 @@ export class RTCEncryptionManager implements IEncryptionManager {
196
207
}
197
208
198
209
public onNewKeyReceived : KeyTransportEventListener = ( userId , deviceId , keyBase64Encoded , index , timestamp ) => {
210
+ // `manageMediaKeys` is a stop-gap solution for now. The preferred way to handle this case would be instead
211
+ // to create a NoOpEncryptionManager that does nothing and use it for the session.
212
+ // This will be done when removing the legacy EncryptionManager.
213
+ if ( ! this . manageMediaKeys ) {
214
+ this . logger ?. warn (
215
+ `Received key over transport ${ userId } :${ deviceId } at index ${ index } but media keys are disabled` ,
216
+ ) ;
217
+ return ;
218
+ }
199
219
this . logger ?. debug ( `Received key over transport ${ userId } :${ deviceId } at index ${ index } ` ) ;
200
220
201
221
// We received a new key, notify the video layer of this new key so that it can decrypt the frames properly.
0 commit comments