@@ -30,7 +30,7 @@ const ROOM_ID = "!room:id";
30
30
*
31
31
* @return {object } sync response
32
32
*/
33
- function getSyncResponse ( roomMembers ) {
33
+ function getSyncResponse ( roomMembers : string [ ] ) {
34
34
const stateEvents = [
35
35
testUtils . mkEvent ( {
36
36
type : 'm.room.encryption' ,
@@ -43,12 +43,10 @@ function getSyncResponse(roomMembers) {
43
43
44
44
Array . prototype . push . apply (
45
45
stateEvents ,
46
- roomMembers . map (
47
- ( m ) => testUtils . mkMembership ( {
48
- mship : 'join' ,
49
- sender : m ,
50
- } ) ,
51
- ) ,
46
+ roomMembers . map ( ( m ) => testUtils . mkMembership ( {
47
+ mship : 'join' ,
48
+ sender : m ,
49
+ } ) ) ,
52
50
) ;
53
51
54
52
const syncResponse = {
@@ -73,8 +71,8 @@ describe("DeviceList management:", function() {
73
71
return ;
74
72
}
75
73
76
- let sessionStoreBackend ;
77
- let aliceTestClient ;
74
+ let aliceTestClient : TestClient ;
75
+ let sessionStoreBackend : Storage ;
78
76
79
77
async function createTestClient ( ) {
80
78
const testClient = new TestClient (
@@ -97,7 +95,10 @@ describe("DeviceList management:", function() {
97
95
} ) ;
98
96
99
97
it ( "Alice shouldn't do a second /query for non-e2e-capable devices" , function ( ) {
100
- aliceTestClient . expectKeyQuery ( { device_keys : { '@alice:localhost' : { } } } ) ;
98
+ aliceTestClient . expectKeyQuery ( {
99
+ device_keys : { '@alice:localhost' : { } } ,
100
+ failures : { } ,
101
+ } ) ;
101
102
return aliceTestClient . start ( ) . then ( function ( ) {
102
103
const syncResponse = getSyncResponse ( [ '@bob:xyz' ] ) ;
103
104
aliceTestClient . httpBackend . when ( 'GET' , '/sync' ) . respond ( 200 , syncResponse ) ;
@@ -138,7 +139,10 @@ describe("DeviceList management:", function() {
138
139
139
140
it . skip ( "We should not get confused by out-of-order device query responses" , ( ) => {
140
141
// https://github.com/vector-im/element-web/issues/3126
141
- aliceTestClient . expectKeyQuery ( { device_keys : { '@alice:localhost' : { } } } ) ;
142
+ aliceTestClient . expectKeyQuery ( {
143
+ device_keys : { '@alice:localhost' : { } } ,
144
+ failures : { } ,
145
+ } ) ;
142
146
return aliceTestClient . start ( ) . then ( ( ) => {
143
147
aliceTestClient . httpBackend . when ( 'GET' , '/sync' ) . respond (
144
148
200 , getSyncResponse ( [ '@bob:xyz' , '@chris:abc' ] ) ) ;
@@ -164,11 +168,12 @@ describe("DeviceList management:", function() {
164
168
aliceTestClient . httpBackend . flush ( '/keys/query' , 1 ) . then (
165
169
( ) => aliceTestClient . httpBackend . flush ( '/send/' , 1 ) ,
166
170
) ,
167
- aliceTestClient . client . crypto . deviceList . saveIfDirty ( ) ,
171
+ aliceTestClient . client . crypto ! . deviceList . saveIfDirty ( ) ,
168
172
] ) ;
169
173
} ) . then ( ( ) => {
170
- aliceTestClient . client . cryptoStore . getEndToEndDeviceData ( null , ( data ) => {
171
- expect ( data . syncToken ) . toEqual ( 1 ) ;
174
+ // @ts -ignore accessing a protected field
175
+ aliceTestClient . client . cryptoStore ! . getEndToEndDeviceData ( null , ( data ) => {
176
+ expect ( data ! . syncToken ) . toEqual ( 1 ) ;
172
177
} ) ;
173
178
174
179
// invalidate bob's and chris's device lists in separate syncs
@@ -201,15 +206,16 @@ describe("DeviceList management:", function() {
201
206
return aliceTestClient . httpBackend . flush ( '/keys/query' , 1 ) ;
202
207
} ) . then ( ( flushed ) => {
203
208
expect ( flushed ) . toEqual ( 0 ) ;
204
- return aliceTestClient . client . crypto . deviceList . saveIfDirty ( ) ;
209
+ return aliceTestClient . client . crypto ! . deviceList . saveIfDirty ( ) ;
205
210
} ) . then ( ( ) => {
206
- aliceTestClient . client . cryptoStore . getEndToEndDeviceData ( null , ( data ) => {
207
- const bobStat = data . trackingStatus [ '@bob:xyz' ] ;
211
+ // @ts -ignore accessing a protected field
212
+ aliceTestClient . client . cryptoStore ! . getEndToEndDeviceData ( null , ( data ) => {
213
+ const bobStat = data ! . trackingStatus [ '@bob:xyz' ] ;
208
214
if ( bobStat != 1 && bobStat != 2 ) {
209
215
throw new Error ( 'Unexpected status for bob: wanted 1 or 2, got ' +
210
216
bobStat ) ;
211
217
}
212
- const chrisStat = data . trackingStatus [ '@chris:abc' ] ;
218
+ const chrisStat = data ! . trackingStatus [ '@chris:abc' ] ;
213
219
if ( chrisStat != 1 && chrisStat != 2 ) {
214
220
throw new Error (
215
221
'Unexpected status for chris: wanted 1 or 2, got ' + chrisStat ,
@@ -234,12 +240,13 @@ describe("DeviceList management:", function() {
234
240
// wait for the client to stop processing the response
235
241
return aliceTestClient . client . downloadKeys ( [ '@bob:xyz' ] ) ;
236
242
} ) . then ( ( ) => {
237
- return aliceTestClient . client . crypto . deviceList . saveIfDirty ( ) ;
243
+ return aliceTestClient . client . crypto ! . deviceList . saveIfDirty ( ) ;
238
244
} ) . then ( ( ) => {
239
- aliceTestClient . client . cryptoStore . getEndToEndDeviceData ( null , ( data ) => {
240
- const bobStat = data . trackingStatus [ '@bob:xyz' ] ;
245
+ // @ts -ignore accessing a protected field
246
+ aliceTestClient . client . cryptoStore ! . getEndToEndDeviceData ( null , ( data ) => {
247
+ const bobStat = data ! . trackingStatus [ '@bob:xyz' ] ;
241
248
expect ( bobStat ) . toEqual ( 3 ) ;
242
- const chrisStat = data . trackingStatus [ '@chris:abc' ] ;
249
+ const chrisStat = data ! . trackingStatus [ '@chris:abc' ] ;
243
250
if ( chrisStat != 1 && chrisStat != 2 ) {
244
251
throw new Error (
245
252
'Unexpected status for chris: wanted 1 or 2, got ' + bobStat ,
@@ -255,15 +262,16 @@ describe("DeviceList management:", function() {
255
262
// wait for the client to stop processing the response
256
263
return aliceTestClient . client . downloadKeys ( [ '@chris:abc' ] ) ;
257
264
} ) . then ( ( ) => {
258
- return aliceTestClient . client . crypto . deviceList . saveIfDirty ( ) ;
265
+ return aliceTestClient . client . crypto ! . deviceList . saveIfDirty ( ) ;
259
266
} ) . then ( ( ) => {
260
- aliceTestClient . client . cryptoStore . getEndToEndDeviceData ( null , ( data ) => {
261
- const bobStat = data . trackingStatus [ '@bob:xyz' ] ;
262
- const chrisStat = data . trackingStatus [ '@bob:xyz' ] ;
267
+ // @ts -ignore accessing a protected field
268
+ aliceTestClient . client . cryptoStore ! . getEndToEndDeviceData ( null , ( data ) => {
269
+ const bobStat = data ! . trackingStatus [ '@bob:xyz' ] ;
270
+ const chrisStat = data ! . trackingStatus [ '@bob:xyz' ] ;
263
271
264
272
expect ( bobStat ) . toEqual ( 3 ) ;
265
273
expect ( chrisStat ) . toEqual ( 3 ) ;
266
- expect ( data . syncToken ) . toEqual ( 3 ) ;
274
+ expect ( data ! . syncToken ) . toEqual ( 3 ) ;
267
275
} ) ;
268
276
} ) ;
269
277
} ) ;
@@ -285,10 +293,11 @@ describe("DeviceList management:", function() {
285
293
} ,
286
294
) ;
287
295
await aliceTestClient . httpBackend . flush ( '/keys/query' , 1 ) ;
288
- await aliceTestClient . client . crypto . deviceList . saveIfDirty ( ) ;
296
+ await aliceTestClient . client . crypto ! . deviceList . saveIfDirty ( ) ;
289
297
290
- aliceTestClient . client . cryptoStore . getEndToEndDeviceData ( null , ( data ) => {
291
- const bobStat = data . trackingStatus [ '@bob:xyz' ] ;
298
+ // @ts -ignore accessing a protected field
299
+ aliceTestClient . client . cryptoStore ! . getEndToEndDeviceData ( null , ( data ) => {
300
+ const bobStat = data ! . trackingStatus [ '@bob:xyz' ] ;
292
301
293
302
// Alice should be tracking bob's device list
294
303
expect ( bobStat ) . toBeGreaterThan (
@@ -322,10 +331,11 @@ describe("DeviceList management:", function() {
322
331
) ;
323
332
324
333
await aliceTestClient . flushSync ( ) ;
325
- await aliceTestClient . client . crypto . deviceList . saveIfDirty ( ) ;
334
+ await aliceTestClient . client . crypto ! . deviceList . saveIfDirty ( ) ;
326
335
327
- aliceTestClient . client . cryptoStore . getEndToEndDeviceData ( null , ( data ) => {
328
- const bobStat = data . trackingStatus [ '@bob:xyz' ] ;
336
+ // @ts -ignore accessing a protected field
337
+ aliceTestClient . client . cryptoStore ! . getEndToEndDeviceData ( null , ( data ) => {
338
+ const bobStat = data ! . trackingStatus [ '@bob:xyz' ] ;
329
339
330
340
// Alice should have marked bob's device list as untracked
331
341
expect ( bobStat ) . toEqual (
@@ -359,15 +369,14 @@ describe("DeviceList management:", function() {
359
369
) ;
360
370
361
371
await aliceTestClient . flushSync ( ) ;
362
- await aliceTestClient . client . crypto . deviceList . saveIfDirty ( ) ;
372
+ await aliceTestClient . client . crypto ! . deviceList . saveIfDirty ( ) ;
363
373
364
- aliceTestClient . client . cryptoStore . getEndToEndDeviceData ( null , ( data ) => {
365
- const bobStat = data . trackingStatus [ '@bob:xyz' ] ;
374
+ // @ts -ignore accessing a protected field
375
+ aliceTestClient . client . cryptoStore ! . getEndToEndDeviceData ( null , ( data ) => {
376
+ const bobStat = data ! . trackingStatus [ '@bob:xyz' ] ;
366
377
367
378
// Alice should have marked bob's device list as untracked
368
- expect ( bobStat ) . toEqual (
369
- 0 ,
370
- ) ;
379
+ expect ( bobStat ) . toEqual ( 0 ) ;
371
380
} ) ;
372
381
} ) ;
373
382
@@ -388,9 +397,7 @@ describe("DeviceList management:", function() {
388
397
const bobStat = data ! . trackingStatus [ '@bob:xyz' ] ;
389
398
390
399
// Alice should have marked bob's device list as untracked
391
- expect ( bobStat ) . toEqual (
392
- 0 ,
393
- ) ;
400
+ expect ( bobStat ) . toEqual ( 0 ) ;
394
401
} ) ;
395
402
} finally {
396
403
anotherTestClient . stop ( ) ;
0 commit comments