Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/livekit-rtc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"@datastructures-js/deque": "1.0.8",
"@livekit/mutex": "^1.0.0",
"@livekit/typed-emitter": "^3.0.0",
"@livekit/rtc-ffi-bindings": "0.12.46-dev.8",
"@livekit/rtc-ffi-bindings": "0.12.52",
"pino": "^9.0.0",
"pino-pretty": "^13.0.0"
Comment on lines 33 to 38
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR changes exported public APIs in e2ee.ts (e.g., KeyProvider.setKey signature) but packages/livekit-rtc’s package version isn’t updated here. If this package follows semver, consider bumping the version (and/or adding release notes) to reflect the breaking API change for downstream users.

Copilot uses AI. Check for mistakes.
},
Expand Down
34 changes: 31 additions & 3 deletions packages/livekit-rtc/src/e2ee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
import { FfiClient } from './ffi_client.js';

const DEFAULT_RATCHET_SALT = new TextEncoder().encode('LKFrameEncryptionKey');
const DEFAULT_RATCHET_WINDOW_SIZE = 16;
const DEFAULT_RATCHET_WINDOW_SIZE = 10;
const DEFAULT_FAILURE_TOLERANCE = -1;

export interface KeyProviderOptions {
Expand Down Expand Up @@ -123,14 +123,15 @@ export class KeyProvider {
return (res.message.value as RatchetSharedKeyResponse).newKey!;
}

setKey(participantIdentity: string, keyIndex: number) {
setKey(participantIdentity: string, key: Uint8Array, keyIndex: number) {
const req = new E2eeRequest({
roomHandle: this.roomHandle,
message: {
case: 'setKey',
value: new SetKeyRequest({
keyIndex: keyIndex,
participantIdentity: participantIdentity,
key,
}),
Comment on lines +126 to 135
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

KeyProvider.setKey is a breaking change for consumers (this class is exported from src/index.ts), since it now requires a Uint8Array key parameter and changes the method signature/semantics. Consider providing an overload/backwards-compatible alternative (or a new method name) and/or documenting the migration path so downstream users don’t unexpectedly break on upgrade.

Copilot uses AI. Check for mistakes.
},
});
Expand Down Expand Up @@ -191,12 +192,20 @@ export class KeyProvider {
export class FrameCryptor {
private roomHandle = BigInt(0);
participantIdentity: string;
trackSid: string;
keyIndex: number;
enabled: boolean;

constructor(roomHandle: bigint, participantIdentity: string, keyIndex: number, enabled: boolean) {
constructor(
roomHandle: bigint,
participantIdentity: string,
trackSid: string,
keyIndex: number,
enabled: boolean,
) {
this.roomHandle = roomHandle;
this.participantIdentity = participantIdentity;
this.trackSid = trackSid;
this.keyIndex = keyIndex;
this.enabled = enabled;
}
Expand All @@ -209,6 +218,7 @@ export class FrameCryptor {
case: 'cryptorSetEnabled',
value: new FrameCryptorSetEnabledRequest({
participantIdentity: this.participantIdentity,
trackSid: this.trackSid,
enabled: this.enabled,
}),
},
Expand All @@ -230,6 +240,7 @@ export class FrameCryptor {
case: 'cryptorSetKeyIndex',
value: new FrameCryptorSetKeyIndexRequest({
participantIdentity: this.participantIdentity,
trackSid: this.trackSid,
keyIndex: this.keyIndex,
}),
},
Expand Down Expand Up @@ -262,6 +273,22 @@ export class E2EEManager {
this.keyProvider = new KeyProvider(roomHandle, options.keyProviderOptions);
}

setKey(participantIdentity: string, key: Uint8Array, keyIndex: number) {
this.keyProvider.setKey(participantIdentity, key, keyIndex);
}

setSharedKey(sharedKey: Uint8Array, keyIndex: number) {
this.keyProvider.setSharedKey(sharedKey, keyIndex);
}

exportKey(participantIdentity: string, keyIndex: number): Uint8Array {
return this.keyProvider.exportKey(participantIdentity, keyIndex);
}

exportSharedKey(keyIndex: number): Uint8Array {
return this.keyProvider.exportSharedKey(keyIndex);
}

setEnabled(enabled: boolean) {
this.enabled = enabled;
const req = new E2eeRequest({
Expand Down Expand Up @@ -305,6 +332,7 @@ export class E2EEManager {
new FrameCryptor(
this.roomHandle,
cryptor.participantIdentity!,
cryptor.trackSid!,
cryptor.keyIndex!,
cryptor.enabled!,
),
Expand Down
50 changes: 25 additions & 25 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading