1
1
/*
2
- Copyright 2022 The Matrix.org Foundation C.I.C.
2
+ Copyright 2023 The Matrix.org Foundation C.I.C.
3
3
4
4
Licensed under the Apache License, Version 2.0 (the "License");
5
5
you may not use this file except in compliance with the License.
@@ -17,7 +17,13 @@ limitations under the License.
17
17
import MockHttpBackend from "matrix-mock-request" ;
18
18
19
19
import "../../olm-loader" ;
20
- import { MSC3906Rendezvous , RendezvousCode , RendezvousFailureReason , RendezvousIntent } from "../../../src/rendezvous" ;
20
+ import {
21
+ MSC3906Rendezvous ,
22
+ RendezvousCode ,
23
+ RendezvousFailureReason ,
24
+ RendezvousIntent ,
25
+ SETUP_ADDITIONAL_DEVICE_FLOW_V2 ,
26
+ } from "../../../src/rendezvous" ;
21
27
import {
22
28
ECDHv2RendezvousCode as ECDHRendezvousCode ,
23
29
MSC3903ECDHPayload ,
@@ -86,7 +92,7 @@ function makeTransport(name: string, uri = "https://test.rz/123456") {
86
92
return new DummyTransport < any , MSC3903ECDHPayload > ( name , { type : "http.v1" , uri } ) ;
87
93
}
88
94
89
- describe ( "Rendezvous " , function ( ) {
95
+ describe ( "RendezvousV2 " , function ( ) {
90
96
beforeAll ( async function ( ) {
91
97
await global . Olm . init ( ) ;
92
98
} ) ;
@@ -143,6 +149,7 @@ describe("Rendezvous", function () {
143
149
const code = JSON . parse ( aliceRz . code ! ) as RendezvousCode ;
144
150
145
151
expect ( code . intent ) . toEqual ( RendezvousIntent . RECIPROCATE_LOGIN_ON_EXISTING_DEVICE ) ;
152
+ expect ( code . flow ) . toEqual ( SETUP_ADDITIONAL_DEVICE_FLOW_V2 . name ) ;
146
153
expect ( code . rendezvous ?. algorithm ) . toEqual ( "org.matrix.msc3903.rendezvous.v2.curve25519-aes-sha256" ) ;
147
154
expect ( code . rendezvous ?. transport . type ) . toEqual ( "org.matrix.msc3886.http.v1" ) ;
148
155
expect ( ( code . rendezvous ?. transport as MSC3886SimpleHttpRendezvousTransportDetails ) . uri ) . toEqual (
@@ -201,8 +208,7 @@ describe("Rendezvous", function () {
201
208
202
209
const bobStartPromise = ( async ( ) => {
203
210
const bobChecksum = await bobEcdh . connect ( ) ;
204
- logger . info ( `Bob checksums is ${ bobChecksum } now sending intent` ) ;
205
- // await bobEcdh.send({ type: 'm.login.progress', intent: RendezvousIntent.LOGIN_ON_NEW_DEVICE });
211
+ logger . info ( `Bob checksums is ${ bobChecksum } ` ) ;
206
212
207
213
// wait for protocols
208
214
logger . info ( "Bob waiting for protocols" ) ;
@@ -211,16 +217,16 @@ describe("Rendezvous", function () {
211
217
logger . info ( `Bob protocols: ${ JSON . stringify ( protocols ) } ` ) ;
212
218
213
219
expect ( protocols ) . toEqual ( {
214
- type : "m.login.finish " ,
215
- outcome : "unsupported" ,
220
+ type : "m.login.failure " ,
221
+ reason : "unsupported" ,
216
222
} ) ;
217
223
} ) ( ) ;
218
224
219
225
await aliceStartProm ;
220
226
await bobStartPromise ;
221
227
} ) ;
222
228
223
- it ( "new device declines protocol with outcome unsupported" , async function ( ) {
229
+ it ( "new device declines protocol with reason unsupported" , async function ( ) {
224
230
const aliceTransport = makeTransport ( "Alice" , "https://test.rz/123456" ) ;
225
231
const bobTransport = makeTransport ( "Bob" , "https://test.rz/999999" ) ;
226
232
transports . push ( aliceTransport , bobTransport ) ;
@@ -256,7 +262,6 @@ describe("Rendezvous", function () {
256
262
const bobStartPromise = ( async ( ) => {
257
263
const bobChecksum = await bobEcdh . connect ( ) ;
258
264
logger . info ( `Bob checksums is ${ bobChecksum } now sending intent` ) ;
259
- // await bobEcdh.send({ type: 'm.login.progress', intent: RendezvousIntent.LOGIN_ON_NEW_DEVICE });
260
265
261
266
// wait for protocols
262
267
logger . info ( "Bob waiting for protocols" ) ;
@@ -265,11 +270,11 @@ describe("Rendezvous", function () {
265
270
logger . info ( `Bob protocols: ${ JSON . stringify ( protocols ) } ` ) ;
266
271
267
272
expect ( protocols ) . toEqual ( {
268
- type : "m.login.progress " ,
273
+ type : "m.login.protocols " ,
269
274
protocols : [ "org.matrix.msc3906.login_token" ] ,
270
275
} ) ;
271
276
272
- await bobEcdh . send ( { type : "m.login.finish " , outcome : "unsupported" } ) ;
277
+ await bobEcdh . send ( { type : "m.login.failure " , reason : "unsupported" } ) ;
273
278
} ) ( ) ;
274
279
275
280
await aliceStartProm ;
@@ -313,8 +318,7 @@ describe("Rendezvous", function () {
313
318
314
319
const bobStartPromise = ( async ( ) => {
315
320
const bobChecksum = await bobEcdh . connect ( ) ;
316
- logger . info ( `Bob checksums is ${ bobChecksum } now sending intent` ) ;
317
- // await bobEcdh.send({ type: 'm.login.progress', intent: RendezvousIntent.LOGIN_ON_NEW_DEVICE });
321
+ logger . info ( `Bob checksums is ${ bobChecksum } ` ) ;
318
322
319
323
// wait for protocols
320
324
logger . info ( "Bob waiting for protocols" ) ;
@@ -323,11 +327,11 @@ describe("Rendezvous", function () {
323
327
logger . info ( `Bob protocols: ${ JSON . stringify ( protocols ) } ` ) ;
324
328
325
329
expect ( protocols ) . toEqual ( {
326
- type : "m.login.progress " ,
330
+ type : "m.login.protocols " ,
327
331
protocols : [ "org.matrix.msc3906.login_token" ] ,
328
332
} ) ;
329
333
330
- await bobEcdh . send ( { type : "m.login.progress " , protocol : "bad protocol" } ) ;
334
+ await bobEcdh . send ( { type : "m.login.protocol " , protocol : "bad protocol" } ) ;
331
335
} ) ( ) ;
332
336
333
337
await aliceStartProm ;
@@ -371,8 +375,7 @@ describe("Rendezvous", function () {
371
375
372
376
const bobStartPromise = ( async ( ) => {
373
377
const bobChecksum = await bobEcdh . connect ( ) ;
374
- logger . info ( `Bob checksums is ${ bobChecksum } now sending intent` ) ;
375
- // await bobEcdh.send({ type: 'm.login.progress', intent: RendezvousIntent.LOGIN_ON_NEW_DEVICE });
378
+ logger . info ( `Bob checksums is ${ bobChecksum } ` ) ;
376
379
377
380
// wait for protocols
378
381
logger . info ( "Bob waiting for protocols" ) ;
@@ -381,19 +384,19 @@ describe("Rendezvous", function () {
381
384
logger . info ( `Bob protocols: ${ JSON . stringify ( protocols ) } ` ) ;
382
385
383
386
expect ( protocols ) . toEqual ( {
384
- type : "m.login.progress " ,
387
+ type : "m.login.protocols " ,
385
388
protocols : [ "org.matrix.msc3906.login_token" ] ,
386
389
} ) ;
387
390
388
- await bobEcdh . send ( { type : "m.login.progress " , protocol : "org.matrix.msc3906.login_token" } ) ;
391
+ await bobEcdh . send ( { type : "m.login.protocol " , protocol : "org.matrix.msc3906.login_token" } ) ;
389
392
} ) ( ) ;
390
393
391
394
await aliceStartProm ;
392
395
await bobStartPromise ;
393
396
394
397
await aliceRz . declineLoginOnExistingDevice ( ) ;
395
398
const loginToken = await bobEcdh . receive ( ) ;
396
- expect ( loginToken ) . toEqual ( { type : "m.login.finish" , outcome : " declined" } ) ;
399
+ expect ( loginToken ) . toEqual ( { type : "m.login.declined" } ) ;
397
400
} ) ;
398
401
399
402
it ( "approve on existing device + no verification" , async function ( ) {
@@ -431,8 +434,7 @@ describe("Rendezvous", function () {
431
434
432
435
const bobStartPromise = ( async ( ) => {
433
436
const bobChecksum = await bobEcdh . connect ( ) ;
434
- logger . info ( `Bob checksums is ${ bobChecksum } now sending intent` ) ;
435
- // await bobEcdh.send({ type: 'm.login.progress', intent: RendezvousIntent.LOGIN_ON_NEW_DEVICE });
437
+ logger . info ( `Bob checksums is ${ bobChecksum } ` ) ;
436
438
437
439
// wait for protocols
438
440
logger . info ( "Bob waiting for protocols" ) ;
@@ -441,11 +443,11 @@ describe("Rendezvous", function () {
441
443
logger . info ( `Bob protocols: ${ JSON . stringify ( protocols ) } ` ) ;
442
444
443
445
expect ( protocols ) . toEqual ( {
444
- type : "m.login.progress " ,
446
+ type : "m.login.protocols " ,
445
447
protocols : [ "org.matrix.msc3906.login_token" ] ,
446
448
} ) ;
447
449
448
- await bobEcdh . send ( { type : "m.login.progress " , protocol : "org.matrix.msc3906.login_token" } ) ;
450
+ await bobEcdh . send ( { type : "m.login.protocol " , protocol : "org.matrix.msc3906.login_token" } ) ;
449
451
} ) ( ) ;
450
452
451
453
await aliceStartProm ;
@@ -455,8 +457,8 @@ describe("Rendezvous", function () {
455
457
456
458
const bobCompleteProm = ( async ( ) => {
457
459
const loginToken = await bobEcdh . receive ( ) ;
458
- expect ( loginToken ) . toEqual ( { type : "m.login.progress " , login_token : "token" , homeserver : alice . baseUrl } ) ;
459
- await bobEcdh . send ( { type : "m.login.finish" , outcome : " success" } ) ;
460
+ expect ( loginToken ) . toEqual ( { type : "m.login.approved " , login_token : "token" , homeserver : alice . baseUrl } ) ;
461
+ await bobEcdh . send ( { type : "m.login.success" } ) ;
460
462
} ) ( ) ;
461
463
462
464
await confirmProm ;
@@ -505,8 +507,7 @@ describe("Rendezvous", function () {
505
507
506
508
const bobStartPromise = ( async ( ) => {
507
509
const bobChecksum = await bobEcdh . connect ( ) ;
508
- logger . info ( `Bob checksums is ${ bobChecksum } now sending intent` ) ;
509
- // await bobEcdh.send({ type: 'm.login.progress', intent: RendezvousIntent.LOGIN_ON_NEW_DEVICE });
510
+ logger . info ( `Bob checksums is ${ bobChecksum } ` ) ;
510
511
511
512
// wait for protocols
512
513
logger . info ( "Bob waiting for protocols" ) ;
@@ -515,11 +516,11 @@ describe("Rendezvous", function () {
515
516
logger . info ( `Bob protocols: ${ JSON . stringify ( protocols ) } ` ) ;
516
517
517
518
expect ( protocols ) . toEqual ( {
518
- type : "m.login.progress " ,
519
+ type : "m.login.protocols " ,
519
520
protocols : [ "org.matrix.msc3906.login_token" ] ,
520
521
} ) ;
521
522
522
- await bobEcdh . send ( { type : "m.login.progress " , protocol : "org.matrix.msc3906.login_token" } ) ;
523
+ await bobEcdh . send ( { type : "m.login.protocol " , protocol : "org.matrix.msc3906.login_token" } ) ;
523
524
} ) ( ) ;
524
525
525
526
await aliceStartProm ;
@@ -529,8 +530,8 @@ describe("Rendezvous", function () {
529
530
530
531
const bobLoginProm = ( async ( ) => {
531
532
const loginToken = await bobEcdh . receive ( ) ;
532
- expect ( loginToken ) . toEqual ( { type : "m.login.progress " , login_token : "token" , homeserver : alice . baseUrl } ) ;
533
- await bobEcdh . send ( { type : "m.login.finish" , outcome : " success", device_id : "BOB" , device_key : "bbbb" } ) ;
533
+ expect ( loginToken ) . toEqual ( { type : "m.login.approved " , login_token : "token" , homeserver : alice . baseUrl } ) ;
534
+ await bobEcdh . send ( { type : "m.login.success" , device_id : "BOB" , device_key : "bbbb" } ) ;
534
535
} ) ( ) ;
535
536
536
537
expect ( await confirmProm ) . toEqual ( "BOB" ) ;
@@ -556,8 +557,7 @@ describe("Rendezvous", function () {
556
557
const bobVerifyProm = ( async ( ) => {
557
558
const verified = await bobEcdh . receive ( ) ;
558
559
expect ( verified ) . toEqual ( {
559
- type : "m.login.finish" ,
560
- outcome : "verified" ,
560
+ type : "m.login.verified" ,
561
561
verifying_device_id : "ALICE" ,
562
562
verifying_device_key : "aaaa" ,
563
563
master_key : "mmmmm" ,
0 commit comments