44import type { TypedEventEmitter as TypedEmitter } from '@livekit/typed-emitter' ;
55import EventEmitter from 'events' ;
66import type { E2EEOptions } from './e2ee.js' ;
7- import { E2EEManager } from './e2ee.js' ;
7+ import { E2EEManager , defaultE2EEOptions } from './e2ee.js' ;
88import { FfiClient , FfiClientEvent , FfiHandle } from './ffi_client.js' ;
99import type { Participant } from './participant.js' ;
1010import { LocalParticipant , RemoteParticipant } from './participant.js' ;
@@ -94,6 +94,7 @@ export class Room extends (EventEmitter as new () => TypedEmitter<RoomCallbacks>
9494
9595 async connect ( url : string , token : string , opts ?: RoomOptions ) {
9696 const options = { ...defaultRoomOptions , ...opts } ;
97+ options . e2ee = { ...defaultE2EEOptions , ...options . e2ee } ;
9798
9899 const req = new ConnectRequest ( {
99100 url : url ,
@@ -115,15 +116,7 @@ export class Room extends (EventEmitter as new () => TypedEmitter<RoomCallbacks>
115116 switch ( cb . message . case ) {
116117 case 'result' :
117118 this . ffiHandle = new FfiHandle ( cb . message . value . room ! . handle ! . id ! ) ;
118- this . e2eeManager = new E2EEManager ( this . ffiHandle . handle , {
119- keyProviderOptions : {
120- sharedKey : options . e2ee ?. keyProviderOptions ?. sharedKey ,
121- ratchetSalt : options . e2ee ! . keyProviderOptions ! . ratchetSalt ! ,
122- ratchetWindowSize : options . e2ee ! . keyProviderOptions ! . ratchetWindowSize ! ,
123- failureTolerance : options . e2ee ! . keyProviderOptions ! . failureTolerance ! ,
124- } ,
125- encryptionType : options . e2ee ! . encryptionType ! ,
126- } ) ;
119+ this . e2eeManager = new E2EEManager ( this . ffiHandle . handle , options . e2ee ) ;
127120
128121 this . info = cb . message . value . room ! . info ;
129122 this . connectionState = ConnectionState . CONN_CONNECTED ;
0 commit comments