@@ -20,7 +20,7 @@ import { DEFAULT_EXPIRE_DURATION, type SessionMembershipData } from "../../../sr
20
20
import { MatrixRTCSession , MatrixRTCSessionEvent } from "../../../src/matrixrtc/MatrixRTCSession" ;
21
21
import { type EncryptionKeysEventContent } from "../../../src/matrixrtc/types" ;
22
22
import { secureRandomString } from "../../../src/randomstring" ;
23
- import { makeMockEvent , makeMockRoom , makeMockRoomState , membershipTemplate } from "./mocks" ;
23
+ import { makeMockEvent , makeMockRoom , makeMockRoomState , membershipTemplate , makeKey } from "./mocks" ;
24
24
25
25
const mockFocus = { type : "mock" } ;
26
26
@@ -534,12 +534,7 @@ describe("MatrixRTCSession", () => {
534
534
{
535
535
call_id : "" ,
536
536
device_id : "AAAAAAA" ,
537
- keys : [
538
- {
539
- index : 0 ,
540
- key : expect . stringMatching ( ".*" ) ,
541
- } ,
542
- ] ,
537
+ keys : [ makeKey ( 0 , expect . stringMatching ( ".*" ) ) ] ,
543
538
sent_ts : Date . now ( ) ,
544
539
} ,
545
540
) ;
@@ -742,12 +737,7 @@ describe("MatrixRTCSession", () => {
742
737
{
743
738
call_id : "" ,
744
739
device_id : "AAAAAAA" ,
745
- keys : [
746
- {
747
- index : 0 ,
748
- key : expect . stringMatching ( ".*" ) ,
749
- } ,
750
- ] ,
740
+ keys : [ makeKey ( 0 , expect . stringMatching ( ".*" ) ) ] ,
751
741
sent_ts : Date . now ( ) ,
752
742
} ,
753
743
) ;
@@ -796,12 +786,7 @@ describe("MatrixRTCSession", () => {
796
786
{
797
787
call_id : "" ,
798
788
device_id : "AAAAAAA" ,
799
- keys : [
800
- {
801
- index : 0 ,
802
- key : expect . stringMatching ( ".*" ) ,
803
- } ,
804
- ] ,
789
+ keys : [ makeKey ( 0 , expect . stringMatching ( ".*" ) ) ] ,
805
790
sent_ts : Date . now ( ) ,
806
791
} ,
807
792
) ;
@@ -834,12 +819,7 @@ describe("MatrixRTCSession", () => {
834
819
{
835
820
call_id : "" ,
836
821
device_id : "AAAAAAA" ,
837
- keys : [
838
- {
839
- index : 0 ,
840
- key : expect . stringMatching ( ".*" ) ,
841
- } ,
842
- ] ,
822
+ keys : [ makeKey ( 0 , expect . stringMatching ( ".*" ) ) ] ,
843
823
sent_ts : Date . now ( ) ,
844
824
} ,
845
825
) ;
@@ -996,12 +976,7 @@ describe("MatrixRTCSession", () => {
996
976
makeMockEvent ( "io.element.call.encryption_keys" , "@bob:example.org" , "1234roomId" , {
997
977
device_id : "bobsphone" ,
998
978
call_id : "" ,
999
- keys : [
1000
- {
1001
- index : 0 ,
1002
- key : "dGhpcyBpcyB0aGUga2V5" ,
1003
- } ,
1004
- ] ,
979
+ keys : [ makeKey ( 0 , "dGhpcyBpcyB0aGUga2V5" ) ] ,
1005
980
} ) ,
1006
981
) ;
1007
982
await jest . advanceTimersToNextTimerAsync ( ) ;
@@ -1026,12 +1001,7 @@ describe("MatrixRTCSession", () => {
1026
1001
makeMockEvent ( "io.element.call.encryption_keys" , "@bob:example.org" , "1234roomId" , {
1027
1002
device_id : "bobsphone" ,
1028
1003
call_id : "" ,
1029
- keys : [
1030
- {
1031
- index : 4 ,
1032
- key : "dGhpcyBpcyB0aGUga2V5" ,
1033
- } ,
1034
- ] ,
1004
+ keys : [ makeKey ( 4 , "dGhpcyBpcyB0aGUga2V5" ) ] ,
1035
1005
} ) ,
1036
1006
) ;
1037
1007
await jest . advanceTimersToNextTimerAsync ( ) ;
@@ -1057,12 +1027,7 @@ describe("MatrixRTCSession", () => {
1057
1027
makeMockEvent ( "io.element.call.encryption_keys" , "@bob:example.org" , "1234roomId" , {
1058
1028
device_id : "bobsphone" ,
1059
1029
call_id : "" ,
1060
- keys : [
1061
- {
1062
- index : 0 ,
1063
- key : "dGhpcyBpcyB0aGUga2V5" ,
1064
- } ,
1065
- ] ,
1030
+ keys : [ makeKey ( 0 , "dGhpcyBpcyB0aGUga2V5" ) ] ,
1066
1031
} ) ,
1067
1032
) ;
1068
1033
await jest . advanceTimersToNextTimerAsync ( ) ;
@@ -1083,12 +1048,7 @@ describe("MatrixRTCSession", () => {
1083
1048
makeMockEvent ( "io.element.call.encryption_keys" , "@bob:example.org" , "1234roomId" , {
1084
1049
device_id : "bobsphone" ,
1085
1050
call_id : "" ,
1086
- keys : [
1087
- {
1088
- index : 4 ,
1089
- key : "dGhpcyBpcyB0aGUga2V5" ,
1090
- } ,
1091
- ] ,
1051
+ keys : [ makeKey ( 4 , "dGhpcyBpcyB0aGUga2V5" ) ] ,
1092
1052
} ) ,
1093
1053
) ;
1094
1054
await jest . advanceTimersToNextTimerAsync ( ) ;
@@ -1122,12 +1082,7 @@ describe("MatrixRTCSession", () => {
1122
1082
{
1123
1083
device_id : "bobsphone" ,
1124
1084
call_id : "" ,
1125
- keys : [
1126
- {
1127
- index : 0 ,
1128
- key : encodeBase64 ( Buffer . from ( "newer key" , "utf-8" ) ) ,
1129
- } ,
1130
- ] ,
1085
+ keys : [ makeKey ( 0 , encodeBase64 ( Buffer . from ( "newer key" , "utf-8" ) ) ) ] ,
1131
1086
} ,
1132
1087
2000 ,
1133
1088
) ,
@@ -1141,12 +1096,7 @@ describe("MatrixRTCSession", () => {
1141
1096
{
1142
1097
device_id : "bobsphone" ,
1143
1098
call_id : "" ,
1144
- keys : [
1145
- {
1146
- index : 0 ,
1147
- key : encodeBase64 ( Buffer . from ( "newer key" , "utf-8" ) ) ,
1148
- } ,
1149
- ] ,
1099
+ keys : [ makeKey ( 0 , encodeBase64 ( Buffer . from ( "newer key" , "utf-8" ) ) ) ] ,
1150
1100
} ,
1151
1101
2000 ,
1152
1102
) ,
@@ -1159,12 +1109,7 @@ describe("MatrixRTCSession", () => {
1159
1109
{
1160
1110
device_id : "bobsphone" ,
1161
1111
call_id : "" ,
1162
- keys : [
1163
- {
1164
- index : 0 ,
1165
- key : encodeBase64 ( Buffer . from ( "older key" , "utf-8" ) ) ,
1166
- } ,
1167
- ] ,
1112
+ keys : [ makeKey ( 0 , encodeBase64 ( Buffer . from ( "older key" , "utf-8" ) ) ) ] ,
1168
1113
} ,
1169
1114
1000 ,
1170
1115
) ,
@@ -1196,12 +1141,7 @@ describe("MatrixRTCSession", () => {
1196
1141
{
1197
1142
device_id : "bobsphone" ,
1198
1143
call_id : "" ,
1199
- keys : [
1200
- {
1201
- index : 0 ,
1202
- key : encodeBase64 ( Buffer . from ( "first key" , "utf-8" ) ) ,
1203
- } ,
1204
- ] ,
1144
+ keys : [ makeKey ( 0 , encodeBase64 ( Buffer . from ( "older key" , "utf-8" ) ) ) ] ,
1205
1145
} ,
1206
1146
1000 ,
1207
1147
) ,
@@ -1215,12 +1155,7 @@ describe("MatrixRTCSession", () => {
1215
1155
{
1216
1156
device_id : "bobsphone" ,
1217
1157
call_id : "" ,
1218
- keys : [
1219
- {
1220
- index : 0 ,
1221
- key : encodeBase64 ( Buffer . from ( "second key" , "utf-8" ) ) ,
1222
- } ,
1223
- ] ,
1158
+ keys : [ makeKey ( 0 , encodeBase64 ( Buffer . from ( "second key" , "utf-8" ) ) ) ] ,
1224
1159
} ,
1225
1160
1000 ,
1226
1161
) ,
@@ -1247,12 +1182,7 @@ describe("MatrixRTCSession", () => {
1247
1182
makeMockEvent ( "io.element.call.encryption_keys" , client . getUserId ( ) ! , "1234roomId" , {
1248
1183
device_id : client . getDeviceId ( ) ,
1249
1184
call_id : "" ,
1250
- keys : [
1251
- {
1252
- index : 4 ,
1253
- key : "dGhpcyBpcyB0aGUga2V5" ,
1254
- } ,
1255
- ] ,
1185
+ keys : [ makeKey ( 4 , "dGhpcyBpcyB0aGUga2V5" ) ] ,
1256
1186
} ) ,
1257
1187
) ;
1258
1188
@@ -1281,12 +1211,7 @@ describe("MatrixRTCSession", () => {
1281
1211
{
1282
1212
device_id : "bobsphone" ,
1283
1213
call_id : "" ,
1284
- keys : [
1285
- {
1286
- index : 0 ,
1287
- key : "dGhpcyBpcyB0aGUga2V5" ,
1288
- } ,
1289
- ] ,
1214
+ keys : [ makeKey ( 0 , "dGhpcyBpcyB0aGUga2V5" ) ] ,
1290
1215
} ,
1291
1216
0 ,
1292
1217
) ,
@@ -1301,12 +1226,7 @@ describe("MatrixRTCSession", () => {
1301
1226
makeMockEvent ( "io.element.call.encryption_keys" , "@bob:example.org" , "1234roomId" , {
1302
1227
device_id : "bobsphone" ,
1303
1228
call_id : "" ,
1304
- keys : [
1305
- {
1306
- index : 0 ,
1307
- key : "dGhpcyBpcyB0aGUga2V5" ,
1308
- } ,
1309
- ] ,
1229
+ keys : [ makeKey ( 0 , "dGhpcyBpcyB0aGUga2V5" ) ] ,
1310
1230
sent_ts : 0 ,
1311
1231
} ) ,
1312
1232
) ;
@@ -1319,12 +1239,7 @@ describe("MatrixRTCSession", () => {
1319
1239
makeMockEvent ( "io.element.call.encryption_keys" , "@bob:example.org" , "1234roomId" , {
1320
1240
device_id : "bobsphone" ,
1321
1241
call_id : "" ,
1322
- keys : [
1323
- {
1324
- index : 0 ,
1325
- key : "dGhpcyBpcyB0aGUga2V5" ,
1326
- } ,
1327
- ] ,
1242
+ keys : [ makeKey ( 0 , "dGhpcyBpcyB0aGUga2V5" ) ] ,
1328
1243
sent_ts : 1000 ,
1329
1244
} ) ,
1330
1245
) ;
0 commit comments