Skip to content

Commit f94696d

Browse files
CSantosMlukasIO
andauthored
Fix: EncryptionError Event Now Exposes Participant Identity (#1723)
Co-authored-by: lukasIO <mail@lukasseiler.de>
1 parent ad1aa3c commit f94696d

File tree

6 files changed

+20
-8
lines changed

6 files changed

+20
-8
lines changed

.changeset/fast-rings-cover.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"livekit-client": patch
3+
---
4+
5+
Add participant as an optional parameter to EncryptionError events emitted on room level

src/e2ee/E2eeManager.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ export class E2EEManager
144144
switch (kind) {
145145
case 'error':
146146
log.error(data.error.message);
147-
this.emit(EncryptionEvent.EncryptionError, data.error);
147+
this.emit(EncryptionEvent.EncryptionError, data.error, data.participantIdentity);
148148
break;
149149
case 'initAck':
150150
if (data.enabled) {
@@ -208,7 +208,7 @@ export class E2EEManager
208208

209209
private onWorkerError = (ev: ErrorEvent) => {
210210
log.error('e2ee worker encountered an error:', { error: ev.error });
211-
this.emit(EncryptionEvent.EncryptionError, ev.error);
211+
this.emit(EncryptionEvent.EncryptionError, ev.error, undefined);
212212
};
213213

214214
public setupEngine(engine: RTCEngine) {

src/e2ee/events.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export type E2EEManagerCallbacks = {
4545
enabled: boolean,
4646
participant: Participant,
4747
) => void;
48-
[EncryptionEvent.EncryptionError]: (error: Error) => void;
48+
[EncryptionEvent.EncryptionError]: (error: Error, participantIdentity?: string) => void;
4949
};
5050

5151
export type CryptorCallbacks = {

src/e2ee/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ export interface ErrorMessage extends BaseMessage {
9191
kind: 'error';
9292
data: {
9393
error: Error;
94+
participantIdentity?: string;
9495
};
9596
}
9697

src/e2ee/worker/e2ee.worker.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,10 @@ function setupCryptorErrorEvents(cryptor: FrameCryptor) {
279279
cryptor.on(CryptorEvent.Error, (error) => {
280280
const msg: ErrorMessage = {
281281
kind: 'error',
282-
data: { error: new Error(`${CryptorErrorReason[error.reason]}: ${error.message}`) },
282+
data: {
283+
error: new Error(`${CryptorErrorReason[error.reason]}: ${error.message}`),
284+
participantIdentity: error.participantIdentity,
285+
},
283286
};
284287
postMessage(msg);
285288
});

src/room/Room.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -384,9 +384,12 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
384384
this.emit(RoomEvent.ParticipantEncryptionStatusChanged, enabled, participant);
385385
},
386386
);
387-
this.e2eeManager.on(EncryptionEvent.EncryptionError, (error) =>
388-
this.emit(RoomEvent.EncryptionError, error),
389-
);
387+
this.e2eeManager.on(EncryptionEvent.EncryptionError, (error, participantIdentity) => {
388+
const participant = participantIdentity
389+
? this.getParticipantByIdentity(participantIdentity)
390+
: undefined;
391+
this.emit(RoomEvent.EncryptionError, error, participant);
392+
});
390393
this.e2eeManager?.setup(this);
391394
}
392395
}
@@ -2698,7 +2701,7 @@ export type RoomEventCallbacks = {
26982701
signalConnected: () => void;
26992702
recordingStatusChanged: (recording: boolean) => void;
27002703
participantEncryptionStatusChanged: (encrypted: boolean, participant?: Participant) => void;
2701-
encryptionError: (error: Error) => void;
2704+
encryptionError: (error: Error, participant?: Participant) => void;
27022705
dcBufferStatusChanged: (isLow: boolean, kind: DataPacket_Kind) => void;
27032706
activeDeviceChanged: (kind: MediaDeviceKind, deviceId: string) => void;
27042707
chatMessage: (message: ChatMessage, participant?: RemoteParticipant | LocalParticipant) => void;

0 commit comments

Comments
 (0)