-
Notifications
You must be signed in to change notification settings - Fork 110
feat(e2ee): support e2ee #631
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
71f66c9
e327a1d
14e95f6
d448aa8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 { | ||
|
|
@@ -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
|
||
| }, | ||
| }); | ||
|
|
@@ -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; | ||
| } | ||
|
|
@@ -209,6 +218,7 @@ export class FrameCryptor { | |
| case: 'cryptorSetEnabled', | ||
| value: new FrameCryptorSetEnabledRequest({ | ||
| participantIdentity: this.participantIdentity, | ||
| trackSid: this.trackSid, | ||
| enabled: this.enabled, | ||
| }), | ||
| }, | ||
|
|
@@ -230,6 +240,7 @@ export class FrameCryptor { | |
| case: 'cryptorSetKeyIndex', | ||
| value: new FrameCryptorSetKeyIndexRequest({ | ||
| participantIdentity: this.participantIdentity, | ||
| trackSid: this.trackSid, | ||
| keyIndex: this.keyIndex, | ||
| }), | ||
| }, | ||
|
|
@@ -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({ | ||
|
|
@@ -305,6 +332,7 @@ export class E2EEManager { | |
| new FrameCryptor( | ||
| this.roomHandle, | ||
| cryptor.participantIdentity!, | ||
| cryptor.trackSid!, | ||
| cryptor.keyIndex!, | ||
| cryptor.enabled!, | ||
| ), | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
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.setKeysignature) butpackages/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.