[SDK] Match LiveKit participants against all backend identities

A member authenticated through the legacy JWT endpoint publishes under a
`user:device` identity, while one authenticated through the default
endpoint publishes under a hashed identity. Both are listed in the
membership's backend identities, so match against the whole list rather
than only the primary one.

On the SDK this is RTCMember.backendIdentities, which the LiveKit backend matches media and data packets against; the harness keys its tiles by the membership id, which the backend identity no longer tells apart.

(cherry picked from commit c9aad2a2b3279782d101c9bc6c80af0417ccbb92)
This commit is contained in:
Robin
2026-10-13 13:00:58 +02:00
committed by Timo K.
parent 7685947a69
commit de8b5d98ec
5 changed files with 28 additions and 19 deletions
+2 -2
View File
@@ -218,8 +218,8 @@ export function createRTCParticipation(
// ever hears from attested members
const data$ = backend.data$.pipe(
map(({ senderId, topic, text }): DataMessage | null => {
const member = remoteMembers$.value.find(
(m) => m.rtcBackendIdentity === senderId,
const member = remoteMembers$.value.find((m) =>
m.backendIdentities.includes(senderId),
);
if (member === undefined) {
logger.warn(`Dropping data from ${senderId}: not a member`);
+13 -9
View File
@@ -259,20 +259,24 @@ export type ResolvedTransport =
export interface RTCMember {
local: boolean;
/**
* The identity this member has on the media backend's transport: the
* participant identity the SFU sees, and the sender of its data packets. The
* SDK uses it to match what arrives on the transport back to the member; a
* host needs it only as a stable key per membership or as a debug label.
*
* Today it is read off the membership, where the js-sdk computes it:
* `${userId}:${deviceId}` before sticky events, a hash of `memberId` in
* Matrix 2.0 mode. Eventually the backend will derive it itself, so treat it
* as opaque.
* The identity this member is known by on its transport for matching
* purposes, read off the membership: `${userId}:${deviceId}`. A stable key
* per membership and a debug label for a host; the SDK matches media
* against `backendIdentities`, not this.
*/
rtcBackendIdentity: string;
userId: string;
deviceId: string;
/** The membership's own id; what the Matrix 2.0 identity is derived from. */
/**
* Every identity this member may publish under on its transport: the
* participant identity the SFU sees, and the sender of its data packets.
* One per authentication flow the member's transport allows, so a
* transport with both a `url` and a `livekit_service_url` lists the hashed
* and the legacy identity, and the backend matches whichever shows up.
* Opaque to a host.
*/
backendIdentities: readonly string[];
memberId: string;
/** Which transport this member is on; undefined when the membership has none. */
transport$: Behavior<TransportMetadata | undefined>;
+4 -2
View File
@@ -46,12 +46,14 @@ export function createRTCMember(
membership$: Behavior<CallMembership>,
{ metadata, transports, own }: MemberContext,
): RTCMember {
const { userId, deviceId, memberId, rtcBackendIdentity } = membership$.value;
const { userId, deviceId, memberId, rtcBackendIdentity, backendIdentities } =
membership$.value;
return {
local: userId === own.userId && deviceId === own.deviceId,
// Read off the membership for now; the backend will derive it once the
// Read off the membership for now; the backend will derive them once the
// identity scheme is its own and not the js-sdk's
rtcBackendIdentity,
backendIdentities,
userId,
deviceId,
memberId,
+6 -3
View File
@@ -164,6 +164,8 @@ export function mockRtcMembership(
deviceId: string,
customOverwrites?: {
rtcBackendIdentity?: string;
/** Every identity the member may have on its transport, where more than one. */
backendIdentities?: string[];
callId?: string;
fociPreferred?: Transport[];
focusActive?: LivekitFocusSelection;
@@ -199,11 +201,12 @@ export function mockRtcMembership(
content: data,
});
const membershipData = CallMembership.membershipDataFromMatrixEvent(event);
const backendIdentity = rtcBackendIdentity ?? `${userId}:${deviceId}`;
const cms = new CallMembership(
event,
membershipData,
rtcBackendIdentity ?? `${userId}:${deviceId}`,
CallMembership.membershipDataFromMatrixEvent(event),
customOverwrites?.backendIdentities ?? [backendIdentity],
backendIdentity,
);
vi.mocked(cms).getTransport = vi.fn().mockReturnValue(fociPreferred[0]);