diff --git a/.changeset/nasty-starfishes-hear.md b/.changeset/nasty-starfishes-hear.md new file mode 100644 index 00000000..79f994c0 --- /dev/null +++ b/.changeset/nasty-starfishes-hear.md @@ -0,0 +1,5 @@ +--- +"@livekit/rtc-node": patch +--- + +e2ee: types can include undefined diff --git a/packages/livekit-rtc/src/e2ee.ts b/packages/livekit-rtc/src/e2ee.ts index d315f6f5..2de00256 100644 --- a/packages/livekit-rtc/src/e2ee.ts +++ b/packages/livekit-rtc/src/e2ee.ts @@ -30,9 +30,9 @@ const DEFAULT_FAILURE_TOLERANCE = -1; export interface KeyProviderOptions { sharedKey?: Uint8Array; - ratchetSalt: Uint8Array; - ratchetWindowSize: number; - failureTolerance: number; + ratchetSalt?: Uint8Array; + ratchetWindowSize?: number; + failureTolerance?: number; } export const defaultKeyProviderOptions: KeyProviderOptions = { @@ -43,7 +43,7 @@ export const defaultKeyProviderOptions: KeyProviderOptions = { export interface E2EEOptions { keyProviderOptions: KeyProviderOptions; - encryptionType: EncryptionType; + encryptionType?: EncryptionType; } export const defaultE2EEOptions: E2EEOptions = { @@ -247,7 +247,7 @@ export class FrameCryptor { export class E2EEManager { private roomHandle = BigInt(0); private options: E2EEOptions; - private keyProvider?: KeyProvider; + private keyProvider: KeyProvider; enabled: boolean; diff --git a/packages/livekit-rtc/src/room.ts b/packages/livekit-rtc/src/room.ts index 0d81f05b..182460b6 100644 --- a/packages/livekit-rtc/src/room.ts +++ b/packages/livekit-rtc/src/room.ts @@ -4,7 +4,7 @@ import type { TypedEventEmitter as TypedEmitter } from '@livekit/typed-emitter'; import EventEmitter from 'events'; import type { E2EEOptions } from './e2ee.js'; -import { E2EEManager } from './e2ee.js'; +import { E2EEManager, defaultE2EEOptions } from './e2ee.js'; import { FfiClient, FfiClientEvent, FfiHandle } from './ffi_client.js'; import type { Participant } from './participant.js'; import { LocalParticipant, RemoteParticipant } from './participant.js'; @@ -94,6 +94,7 @@ export class Room extends (EventEmitter as new () => TypedEmitter async connect(url: string, token: string, opts?: RoomOptions) { const options = { ...defaultRoomOptions, ...opts }; + options.e2ee = { ...defaultE2EEOptions, ...options.e2ee }; const req = new ConnectRequest({ url: url, @@ -115,15 +116,7 @@ export class Room extends (EventEmitter as new () => TypedEmitter switch (cb.message.case) { case 'result': this.ffiHandle = new FfiHandle(cb.message.value.room!.handle!.id!); - this.e2eeManager = new E2EEManager(this.ffiHandle.handle, { - keyProviderOptions: { - sharedKey: options.e2ee?.keyProviderOptions?.sharedKey, - ratchetSalt: options.e2ee!.keyProviderOptions!.ratchetSalt!, - ratchetWindowSize: options.e2ee!.keyProviderOptions!.ratchetWindowSize!, - failureTolerance: options.e2ee!.keyProviderOptions!.failureTolerance!, - }, - encryptionType: options.e2ee!.encryptionType!, - }); + this.e2eeManager = new E2EEManager(this.ffiHandle.handle, options.e2ee); this.info = cb.message.value.room!.info; this.connectionState = ConnectionState.CONN_CONNECTED;