Add initial implementation of the LoginWizard.

This commit is contained in:
Doug
2022-05-19 12:53:46 +01:00
committed by Doug
parent 7dbe5b17e9
commit ac755f11f5
10 changed files with 391 additions and 29 deletions

View File

@@ -17,7 +17,7 @@
import Foundation
/// The parameters used for registration requests.
struct RegistrationParameters: Codable {
struct RegistrationParameters: DictionaryEncodable {
/// Authentication parameters
var auth: AuthenticationParameters?
@@ -41,22 +41,10 @@ struct RegistrationParameters: Codable {
case initialDeviceDisplayName = "initial_device_display_name"
case xShowMSISDN = "x_show_msisdn"
}
/// The parameters as a JSON dictionary for use in MXRestClient.
func dictionary() throws -> [String: Any] {
let jsonData = try JSONEncoder().encode(self)
let object = try JSONSerialization.jsonObject(with: jsonData)
guard let dictionary = object as? [String: Any] else {
MXLog.error("[RegistrationParameters] dictionary: Unexpected type decoded \(type(of: object)). Expected a Dictionary.")
throw AuthenticationError.dictionaryError
}
return dictionary
}
}
/// The data passed to the `auth` parameter in registration requests.
struct AuthenticationParameters: Codable {
/// The data passed to the `auth` parameter in authentication requests.
struct AuthenticationParameters: Encodable {
/// The type of authentication taking place. The identifier from `MXLoginFlowType`.
let type: String