Skip to content
Draft
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
5 changes: 5 additions & 0 deletions .changeset/e2ee-local-cryptor-enabled.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@livekit/react-native': patch
---

Add `setLocalParticipantCryptorEnabled` to `RNE2EEManager`, deprecate `setParticipantCryptorEnabled`, and set up the sender cryptor from the local E2EE setting
34 changes: 20 additions & 14 deletions src/e2ee/RNE2EEManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,8 @@ export default class RNE2EEManager
if (!this.room) {
throw new TypeError(`expected room to be present on signal connect`);
}
this.setParticipantCryptorEnabled(
this.room.localParticipant.isE2EEEnabled,
this.room.localParticipant.identity
this.setLocalParticipantCryptorEnabled(
this.room.localParticipant.isE2EEEnabled
);
});
}
Expand All @@ -118,7 +117,7 @@ export default class RNE2EEManager
publication: LocalTrackPublication,
participant: LocalParticipant
) {
if (!publication.isEncrypted) {
if (!participant.isE2EEEnabled) {
return;
}

Expand Down Expand Up @@ -285,20 +284,27 @@ export default class RNE2EEManager
setupEngine(_engine: RTCEngine): void {
// No-op
}

/** Sets whether the local participant encrypts. */
setLocalParticipantCryptorEnabled(enabled: boolean): void {
if (!this.room) {
throw TypeError(`couldn't set encryption status, room not set up`);
}
this.encryptionEnabled = enabled;
this.emit(
EncryptionEvent.ParticipantEncryptionStatusChanged,
enabled,
this.room.localParticipant
);
}

/** @deprecated use `setLocalParticipantCryptorEnabled` */
setParticipantCryptorEnabled(
enabled: boolean,
participantIdentity: string
): void {
if (
this.encryptionEnabled !== enabled &&
participantIdentity === this.room?.localParticipant.identity
) {
this.encryptionEnabled = enabled;
this.emit(
EncryptionEvent.ParticipantEncryptionStatusChanged,
enabled,
this.room!.localParticipant
);
if (participantIdentity === this.room?.localParticipant.identity) {
this.setLocalParticipantCryptorEnabled(enabled);
} else {
const participant =
this.room?.getParticipantByIdentity(participantIdentity);
Expand Down
Loading