Skip to content

Conversation

@lukasIO
Copy link
Contributor

@lukasIO lukasIO commented Jul 8, 2025

depends on livekit/protocol#1127

Most importantly for a frictionless adoption this PR ships decryption support.
This means if at a later stage encryption will be turned on by default, all clients that have the decryption support from this PR will continue to work.

@changeset-bot
Copy link

changeset-bot bot commented Jul 8, 2025

🦋 Changeset detected

Latest commit: 57037da

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
livekit-client Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@lukasIO lukasIO changed the title data channel e2ee Add e2ee for data channel messages Aug 15, 2025
@lukasIO lukasIO requested review from a team and bcherry August 15, 2025 10:19
@lukasIO lukasIO marked this pull request as ready for review August 15, 2025 10:20
@lukasIO lukasIO removed the request for review from bcherry August 15, 2025 10:21
@cloudwebrtc
Copy link
Contributor

Quick question @lukasIO, is it necessary to do a key ratchet attempt after data decrypt fails?

@lukasIO
Copy link
Contributor Author

lukasIO commented Aug 18, 2025

oh, that's a good point. I'll look at adding that!

Copy link
Contributor

@bcherry bcherry left a comment

Choose a reason for hiding this comment

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

lgtm besides the todo.

src/room/Room.ts Outdated
const dcEncryptionEnabled = false;
const e2eeOptions = this.options.e2ee;

// TODO(dc-e2ee): add this back in
Copy link
Contributor

Choose a reason for hiding this comment

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

is this important in this PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this needs to be uncommented once we expose the options.encryption field.

Because this PR doesn't actually declare that, we leave the logic commented out

Copy link

Choose a reason for hiding this comment

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

@lukasIO are you okay with creating the "new" options type right now and making it internal? I need that mostly for integration tests (to drive the feature), but maybe that's more elegant than the opt-in flag dcEnabled.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

for testing or in general?

I've been thinking more about the "general" route and I think we should go forward with exposing a new options field now and deprecating the old one. v3 will remove the old one then.

Copy link

Choose a reason for hiding this comment

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

Yup, deprecating now makes much more sense, as e.g. you can deprecate old events/delegates as well, without changing the signatures "silently" so people no longer get their events (enriched with EncryptionType)

export function asEncryptablePacket(packet: DataPacket): EncryptedPacketPayload | undefined {
if (
packet.value?.case !== 'sipDtmf' &&
packet.value?.case !== 'metrics' &&
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In theory yes, the question is how that would handled for the dashboard were you'd want to see the metrics

@github-actions
Copy link
Contributor

github-actions bot commented Aug 27, 2025

size-limit report 📦

Path Size
dist/livekit-client.esm.mjs 81.56 KB (0%)
dist/livekit-client.umd.js 87.63 KB (0%)


private dataChannelEncryptionEnabled: boolean;

constructor(options: E2EEManagerOptions, dcEncryptionEnabled: boolean) {
Copy link

Choose a reason for hiding this comment

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

Do we really need to expose dcEncryptionEnabled here, or just assign based on the type of options (old vs new)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

in JS E2EEManager is an internal class, so this is not really a big concern to me.
We can of course also make it part of the E2EEManagerOptions

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah, I see why I didn't do this in the first place, as the E2EEManagerOptions are actually exposed to users under an alias right now.

@lukasIO lukasIO merged commit 5125d01 into main Sep 15, 2025
5 checks passed
@lukasIO lukasIO deleted the lukas/dc-encrypt branch September 15, 2025 12:02
pblazej added a commit to livekit/client-sdk-swift that referenced this pull request Oct 1, 2025
- Adds data channel encryption based on
livekit/client-sdk-js#1595
- Adds `currentKey` state to `BaseKeyProvider`
- It was missing comparing to other platforms, and we cannot explicitly
default to `0`
- Adds some integration tests, as most of the _crypto_ stuff is tested
by webrtc
- Existing hi-level tests e.g. data streams will get a `sharedKey` by
default 🎉

### Migration/deprecations
- Replace `E2EEOptions` with `EncryptionOptions` (1:1)
- Add `EncryptionType` parameter to `Room/ParticipantDelegate` methods

---------

Co-authored-by: Hiroshi Horie <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants