Support for MSC3906 v2 (#7407)

This commit is contained in:
Hugh Nimmo-Smith
2023-04-01 11:56:56 -04:00
committed by GitHub
parent 4c2ed13e42
commit 8caad979d7
4 changed files with 52 additions and 9 deletions
@@ -18,6 +18,7 @@ import Foundation
struct QRLoginCode: Codable {
let rendezvous: RendezvousDetails
let flow: String?
let intent: String
}
@@ -42,7 +43,8 @@ struct QRLoginRendezvousPayload: Codable {
var intent: Intent?
var outcome: Outcome?
var reason: FailureReason?
// swiftformat:disable:next redundantBackticks
var protocols: [`Protocol`]?
@@ -64,6 +66,7 @@ struct QRLoginRendezvousPayload: Codable {
case type
case intent
case outcome
case reason
case homeserver
case user
case protocols
@@ -77,9 +80,18 @@ struct QRLoginRendezvousPayload: Codable {
}
enum `Type`: String, Codable {
case loginStart = "m.login.start"
case loginProgress = "m.login.progress"
/**
This is only used in MSC3906 v1 and will be removed
*/
case loginFinish = "m.login.finish"
case loginFailure = "m.login.failure"
case loginProtocol = "m.login.protocol"
case loginProtocols = "m.login.protocols"
case loginApproved = "m.login.approved"
case loginDeclined = "m.login.declined"
case loginSuccess = "m.login.success"
case loginVerified = "m.login.verified"
}
enum Intent: String, Codable {
@@ -87,6 +99,9 @@ struct QRLoginRendezvousPayload: Codable {
case loginReciprocate = "login.reciprocate"
}
/**
This is only used in MSC306 v1 and will be removed
*/
enum Outcome: String, Codable {
case success
case declined
@@ -97,4 +112,11 @@ struct QRLoginRendezvousPayload: Codable {
enum `Protocol`: String, Codable {
case loginToken = "org.matrix.msc3906.login_token"
}
enum FailureReason: String, Codable {
case cancelled
case unsupported
case e2eeSecurityError = "e2ee_security_error"
case incompatibleIntent = "incompatible_intent"
}
}