@@ -38,6 +38,7 @@ import {
3838import { RTCEncryptionManager } from "../../../src/matrixrtc/RTCEncryptionManager.ts" ;
3939import { RoomStickyEventsEvent , type StickyMatrixEvent } from "../../../src/models/room-sticky-events.ts" ;
4040import { StickyEventMembershipManager } from "../../../src/matrixrtc/MembershipManager.ts" ;
41+ import { type CallMembershipIdentityParts } from "src/matrixrtc/EncryptionManager.ts" ;
4142
4243const mockFocus = { type : "mock" } ;
4344
@@ -803,11 +804,11 @@ describe("MatrixRTCSession", () => {
803804 sess ! . on ( MatrixRTCSessionEvent . EncryptionKeyChanged , encryptionKeyChangedListener ) ;
804805 sess ?. reemitEncryptionKeys ( ) ;
805806 expect ( encryptionKeyChangedListener ) . toHaveBeenCalledTimes ( 1 ) ;
806- expect ( encryptionKeyChangedListener ) . toHaveBeenCalledWith (
807- expect . any ( Uint8Array ) ,
808- 0 ,
809- "@alice:example.org:AAAAAAA " ,
810- ) ;
807+ expect ( encryptionKeyChangedListener ) . toHaveBeenCalledWith ( expect . any ( Uint8Array ) , 0 , {
808+ deviceId : "AAAAAAA" ,
809+ memberId : "@alice:example.org:AAAAAAA" ,
810+ userId : "@alice:example.org" ,
811+ } ) ;
811812 } ) ;
812813
813814 it ( "sends keys when joining" , async ( ) => {
@@ -1122,8 +1123,11 @@ describe("MatrixRTCSession", () => {
11221123 const onMyEncryptionKeyChanged = jest . fn ( ) ;
11231124 sess . on (
11241125 MatrixRTCSessionEvent . EncryptionKeyChanged ,
1125- ( _key : Uint8Array , _idx : number , participantId : string ) => {
1126- if ( participantId === `${ client . getUserId ( ) } :${ client . getDeviceId ( ) } ` ) {
1126+ ( _key : Uint8Array , _idx : number , membership : CallMembershipIdentityParts ) => {
1127+ if (
1128+ membership . userId === client . getUserId ( ) &&
1129+ membership . deviceId === client . getDeviceId ( )
1130+ ) {
11271131 onMyEncryptionKeyChanged ( ) ;
11281132 }
11291133 } ,
@@ -1312,11 +1316,11 @@ describe("MatrixRTCSession", () => {
13121316 sess ! . reemitEncryptionKeys ( ) ;
13131317
13141318 expect ( encryptionKeyChangedListener ) . toHaveBeenCalledTimes ( 2 ) ;
1315- expect ( encryptionKeyChangedListener ) . toHaveBeenCalledWith (
1316- textEncoder . encode ( "this is the key" ) ,
1317- 0 ,
1318- "@bob:example.org:bobsphone " ,
1319- ) ;
1319+ expect ( encryptionKeyChangedListener ) . toHaveBeenCalledWith ( textEncoder . encode ( "this is the key" ) , 0 , {
1320+ deviceId : "bobsphone" ,
1321+ memberId : "@bob:example.org:bobsphone" ,
1322+ userId : "@bob:example.org" ,
1323+ } ) ;
13201324 expect ( sess ! . statistics . counters . roomEventEncryptionKeysReceived ) . toEqual ( 1 ) ;
13211325 } ) ;
13221326
@@ -1337,11 +1341,11 @@ describe("MatrixRTCSession", () => {
13371341 sess ! . on ( MatrixRTCSessionEvent . EncryptionKeyChanged , encryptionKeyChangedListener ) ;
13381342 sess ! . reemitEncryptionKeys ( ) ;
13391343 expect ( encryptionKeyChangedListener ) . toHaveBeenCalledTimes ( 2 ) ;
1340- expect ( encryptionKeyChangedListener ) . toHaveBeenCalledWith (
1341- textEncoder . encode ( "this is the key" ) ,
1342- 4 ,
1343- "@bob:example.org:bobsphone " ,
1344- ) ;
1344+ expect ( encryptionKeyChangedListener ) . toHaveBeenCalledWith ( textEncoder . encode ( "this is the key" ) , 4 , {
1345+ deviceId : "bobsphone" ,
1346+ memberId : "@bob:example.org:bobsphone" ,
1347+ userId : "@bob:example.org" ,
1348+ } ) ;
13451349
13461350 expect ( sess ! . statistics . counters . roomEventEncryptionKeysReceived ) . toEqual ( 1 ) ;
13471351 } ) ;
@@ -1363,11 +1367,11 @@ describe("MatrixRTCSession", () => {
13631367 sess ! . on ( MatrixRTCSessionEvent . EncryptionKeyChanged , encryptionKeyChangedListener ) ;
13641368 sess ! . reemitEncryptionKeys ( ) ;
13651369 expect ( encryptionKeyChangedListener ) . toHaveBeenCalledTimes ( 2 ) ;
1366- expect ( encryptionKeyChangedListener ) . toHaveBeenCalledWith (
1367- textEncoder . encode ( "this is the key" ) ,
1368- 0 ,
1369- "@bob:example.org:bobsphone " ,
1370- ) ;
1370+ expect ( encryptionKeyChangedListener ) . toHaveBeenCalledWith ( textEncoder . encode ( "this is the key" ) , 0 , {
1371+ deviceId : "bobsphone" ,
1372+ memberId : "@bob:example.org:bobsphone" ,
1373+ userId : "@bob:example.org" ,
1374+ } ) ;
13711375
13721376 expect ( sess ! . statistics . counters . roomEventEncryptionKeysReceived ) . toEqual ( 1 ) ;
13731377
@@ -1383,16 +1387,16 @@ describe("MatrixRTCSession", () => {
13831387 encryptionKeyChangedListener . mockClear ( ) ;
13841388 sess ! . reemitEncryptionKeys ( ) ;
13851389 expect ( encryptionKeyChangedListener ) . toHaveBeenCalledTimes ( 3 ) ;
1386- expect ( encryptionKeyChangedListener ) . toHaveBeenCalledWith (
1387- textEncoder . encode ( "this is the key" ) ,
1388- 0 ,
1389- "@bob:example.org:bobsphone " ,
1390- ) ;
1391- expect ( encryptionKeyChangedListener ) . toHaveBeenCalledWith (
1392- textEncoder . encode ( "this is the key" ) ,
1393- 4 ,
1394- "@bob:example.org:bobsphone " ,
1395- ) ;
1390+ expect ( encryptionKeyChangedListener ) . toHaveBeenCalledWith ( textEncoder . encode ( "this is the key" ) , 0 , {
1391+ deviceId : "bobsphone" ,
1392+ memberId : "@bob:example.org:bobsphone" ,
1393+ userId : "@bob:example.org" ,
1394+ } ) ;
1395+ expect ( encryptionKeyChangedListener ) . toHaveBeenCalledWith ( textEncoder . encode ( "this is the key" ) , 4 , {
1396+ deviceId : "bobsphone" ,
1397+ memberId : "@bob:example.org:bobsphone" ,
1398+ userId : "@bob:example.org" ,
1399+ } ) ;
13961400
13971401 expect ( sess ! . statistics . counters . roomEventEncryptionKeysReceived ) . toEqual ( 2 ) ;
13981402 } ) ;
@@ -1447,11 +1451,11 @@ describe("MatrixRTCSession", () => {
14471451 sess ! . on ( MatrixRTCSessionEvent . EncryptionKeyChanged , encryptionKeyChangedListener ) ;
14481452 sess ! . reemitEncryptionKeys ( ) ;
14491453 expect ( encryptionKeyChangedListener ) . toHaveBeenCalledTimes ( 2 ) ;
1450- expect ( encryptionKeyChangedListener ) . toHaveBeenCalledWith (
1451- textEncoder . encode ( "newer key" ) ,
1452- 0 ,
1453- "@bob:example.org:bobsphone " ,
1454- ) ;
1454+ expect ( encryptionKeyChangedListener ) . toHaveBeenCalledWith ( textEncoder . encode ( "newer key" ) , 0 , {
1455+ deviceId : "bobsphone" ,
1456+ memberId : "@bob:example.org:bobsphone" ,
1457+ userId : "@bob:example.org" ,
1458+ } ) ;
14551459
14561460 expect ( sess ! . statistics . counters . roomEventEncryptionKeysReceived ) . toEqual ( 3 ) ;
14571461 } ) ;
@@ -1493,11 +1497,11 @@ describe("MatrixRTCSession", () => {
14931497 sess ! . on ( MatrixRTCSessionEvent . EncryptionKeyChanged , encryptionKeyChangedListener ) ;
14941498 sess ! . reemitEncryptionKeys ( ) ;
14951499 expect ( encryptionKeyChangedListener ) . toHaveBeenCalledTimes ( 2 ) ;
1496- expect ( encryptionKeyChangedListener ) . toHaveBeenCalledWith (
1497- textEncoder . encode ( "second key" ) ,
1498- 0 ,
1499- "@bob:example.org:bobsphone " ,
1500- ) ;
1500+ expect ( encryptionKeyChangedListener ) . toHaveBeenCalledWith ( textEncoder . encode ( "second key" ) , 0 , {
1501+ deviceId : "bobsphone" ,
1502+ memberId : "@bob:example.org:bobsphone" ,
1503+ userId : "@bob:example.org" ,
1504+ } ) ;
15011505 } ) ;
15021506
15031507 it ( "ignores keys event for the local participant" , ( ) => {
0 commit comments