Skip to content

Commit aca0c42

Browse files
author
aoife cassidy
authored
fix(e2ee): fix types (#376)
1 parent 81b2d3c commit aca0c42

File tree

3 files changed

+13
-15
lines changed

3 files changed

+13
-15
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@livekit/rtc-node": patch
3+
---
4+
5+
e2ee: types can include undefined

packages/livekit-rtc/src/e2ee.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ const DEFAULT_FAILURE_TOLERANCE = -1;
3030

3131
export interface KeyProviderOptions {
3232
sharedKey?: Uint8Array;
33-
ratchetSalt: Uint8Array;
34-
ratchetWindowSize: number;
35-
failureTolerance: number;
33+
ratchetSalt?: Uint8Array;
34+
ratchetWindowSize?: number;
35+
failureTolerance?: number;
3636
}
3737

3838
export const defaultKeyProviderOptions: KeyProviderOptions = {
@@ -43,7 +43,7 @@ export const defaultKeyProviderOptions: KeyProviderOptions = {
4343

4444
export interface E2EEOptions {
4545
keyProviderOptions: KeyProviderOptions;
46-
encryptionType: EncryptionType;
46+
encryptionType?: EncryptionType;
4747
}
4848

4949
export const defaultE2EEOptions: E2EEOptions = {
@@ -247,7 +247,7 @@ export class FrameCryptor {
247247
export class E2EEManager {
248248
private roomHandle = BigInt(0);
249249
private options: E2EEOptions;
250-
private keyProvider?: KeyProvider;
250+
private keyProvider: KeyProvider;
251251

252252
enabled: boolean;
253253

packages/livekit-rtc/src/room.ts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import type { TypedEventEmitter as TypedEmitter } from '@livekit/typed-emitter';
55
import EventEmitter from 'events';
66
import type { E2EEOptions } from './e2ee.js';
7-
import { E2EEManager } from './e2ee.js';
7+
import { E2EEManager, defaultE2EEOptions } from './e2ee.js';
88
import { FfiClient, FfiClientEvent, FfiHandle } from './ffi_client.js';
99
import type { Participant } from './participant.js';
1010
import { 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

Comments
 (0)