@@ -18,7 +18,7 @@ import { FfiClient, FfiClientEvent, FfiHandle } from './ffi_client.js';
1818import { log } from './log.js' ;
1919import type { Participant } from './participant.js' ;
2020import { LocalParticipant , RemoteParticipant } from './participant.js' ;
21- import { EncryptionState } from './proto/e2ee_pb.js' ;
21+ import { EncryptionState , EncryptionType } from './proto/e2ee_pb.js' ;
2222import type { FfiEvent } from './proto/ffi_pb.js' ;
2323import type { DisconnectReason , OwnedParticipant } from './proto/participant_pb.js' ;
2424import type { DataStream_Trailer } from './proto/room_pb.js' ;
@@ -61,14 +61,19 @@ export const defaultRtcConfiguration: RtcConfiguration = {
6161export interface RoomOptions {
6262 autoSubscribe : boolean ;
6363 dynacast : boolean ;
64+ /**
65+ * @deprecated Use `encryption` instead. See x for details
66+ */
6467 e2ee ?: E2EEOptions ;
68+ encryption ?: E2EEOptions ;
6569 rtcConfig ?: RtcConfiguration ;
6670}
6771
6872export const defaultRoomOptions = new FfiRoomOptions ( {
6973 autoSubscribe : true ,
7074 dynacast : false ,
7175 e2ee : undefined ,
76+ encryption : undefined ,
7277 rtcConfig : undefined ,
7378 adaptiveStream : false ,
7479 joinRetries : 1 ,
@@ -181,7 +186,10 @@ export class Room extends (EventEmitter as new () => TypedEmitter<RoomCallbacks>
181186 */
182187 async connect ( url : string , token : string , opts ?: RoomOptions ) {
183188 const options = { ...defaultRoomOptions , ...opts } ;
184- const e2eeOptions = { ...defaultE2EEOptions , ...options . e2ee } ;
189+ const e2eeEnabled = options . encryption || options . e2ee ;
190+ const e2eeOptions = options . encryption
191+ ? { ...defaultE2EEOptions , ...options . encryption }
192+ : { ...defaultE2EEOptions , ...options . e2ee } ;
185193
186194 const req = new ConnectRequest ( {
187195 url : url ,
@@ -207,7 +215,7 @@ export class Room extends (EventEmitter as new () => TypedEmitter<RoomCallbacks>
207215 switch ( cb . message . case ) {
208216 case 'result' :
209217 this . ffiHandle = new FfiHandle ( cb . message . value . room ! . handle ! . id ! ) ;
210- this . e2eeManager = options . e2ee && new E2EEManager ( this . ffiHandle . handle , e2eeOptions ) ;
218+ this . e2eeManager = e2eeEnabled && new E2EEManager ( this . ffiHandle . handle , e2eeOptions ) ;
211219
212220 this . info = cb . message . value . room ! . info ;
213221 this . connectionState = ConnectionState . CONN_CONNECTED ;
@@ -533,6 +541,13 @@ export class Room extends (EventEmitter as new () => TypedEmitter<RoomCallbacks>
533541 participant . info = info ;
534542 }
535543 }
544+ } else if ( ev . case === 'participantEncryptionStatusChanged' ) {
545+ const participant = this . requireParticipantByIdentity ( ev . value . participantIdentity ! ) ;
546+ this . emit (
547+ RoomEvent . ParticipantEncryptionStatusChanged ,
548+ ! ! ev . value . isEncrypted ,
549+ participant ,
550+ ) ;
536551 }
537552 } finally {
538553 unlock ( ) ;
@@ -737,12 +752,14 @@ export type RoomCallbacks = {
737752 changedAttributes : Record < string , string > ,
738753 participant : Participant ,
739754 ) => void ;
755+ participantEncryptionStatusChanged : ( isEncrypted : boolean , participant : Participant ) => void ;
740756 connectionQualityChanged : ( quality : ConnectionQuality , participant : Participant ) => void ;
741757 dataReceived : (
742758 payload : Uint8Array ,
743759 participant ?: RemoteParticipant ,
744760 kind ?: DataPacketKind ,
745761 topic ?: string ,
762+ encryptionType ?: EncryptionType ,
746763 ) => void ;
747764 chatMessage : ( message : ChatMessage , participant ?: Participant ) => void ;
748765 dtmfReceived : ( code : number , digit : string , participant : RemoteParticipant ) => void ;
@@ -776,6 +793,7 @@ export enum RoomEvent {
776793 ParticipantMetadataChanged = 'participantMetadataChanged' ,
777794 ParticipantNameChanged = 'participantNameChanged' ,
778795 ParticipantAttributesChanged = 'participantAttributesChanged' ,
796+ ParticipantEncryptionStatusChanged = 'participantEncryptionStatusChanged' ,
779797 ConnectionQualityChanged = 'connectionQualityChanged' ,
780798 DataReceived = 'dataReceived' ,
781799 ChatMessage = 'chatMessage' ,
0 commit comments