diff --git a/MagicSDK.podspec b/MagicSDK.podspec index 19ce35d..97944b9 100644 --- a/MagicSDK.podspec +++ b/MagicSDK.podspec @@ -3,7 +3,7 @@ # Pod::Spec.new do |s| s.name = 'MagicSDK' - s.version = '9.1.1' + s.version = '10.0.0' s.summary = 'Magic IOS SDK' s.description = <<-DESC diff --git a/Sources/MagicSDK/Modules/User/RecoveryFactor.swift b/Sources/MagicSDK/Modules/User/RecoveryFactor.swift new file mode 100644 index 0000000..41205fc --- /dev/null +++ b/Sources/MagicSDK/Modules/User/RecoveryFactor.swift @@ -0,0 +1,24 @@ +// +// UserResponse.swift +// Magic +// +// Created by Romin Halltari on 11/22/2023. +// Copyright © 2020 Magic Labs Inc. All rights reserved. +// + + +import Foundation + +public class RecoveryFactor: Codable { + public var value: String + public var type: RecoveryMethodType + + public init(value: String, type: RecoveryMethodType) { + self.value = value + self.type = type + } + + public var description: String { + return "value: \(value)\ntype: \(type.rawValue)\n" + } +} diff --git a/Sources/MagicSDK/Modules/User/RecoveryMethodType.swift b/Sources/MagicSDK/Modules/User/RecoveryMethodType.swift new file mode 100644 index 0000000..324d198 --- /dev/null +++ b/Sources/MagicSDK/Modules/User/RecoveryMethodType.swift @@ -0,0 +1,17 @@ +// +// RecoveryMethodType.swift +// Magic +// +// Created by Romin Halltari on 11/22/2023. +// Copyright © 2020 Magic Labs Inc. All rights reserved. +// + +import Foundation + +public enum RecoveryMethodType: String, Codable { + case phoneNumber = "PHONE_NUMBER" + + public var description: String { + return rawValue.lowercased() + } +} diff --git a/Sources/MagicSDK/Modules/User/UserMethod.swift b/Sources/MagicSDK/Modules/User/UserMethod.swift index 34f5ca7..cad7cb6 100644 --- a/Sources/MagicSDK/Modules/User/UserMethod.swift +++ b/Sources/MagicSDK/Modules/User/UserMethod.swift @@ -13,7 +13,7 @@ internal enum UserMethod: String, CaseIterable { // Auth case magic_auth_get_id_token case magic_auth_generate_id_token - case magic_auth_get_metadata + case magic_get_info case magic_auth_logout case magic_auth_settings case magic_auth_update_email diff --git a/Sources/MagicSDK/Modules/User/UserModule.swift b/Sources/MagicSDK/Modules/User/UserModule.swift index 612a8a0..5c0c4b2 100644 --- a/Sources/MagicSDK/Modules/User/UserModule.swift +++ b/Sources/MagicSDK/Modules/User/UserModule.swift @@ -60,22 +60,22 @@ public class UserModule: BaseModule { /** - Get Metadata + Get Info */ - public func getMetadata(response: @escaping Web3ResponseCompletion) { + public func getInfo(response: @escaping Web3ResponseCompletion) { if #available(iOS 14.0, *) { - UserModule.logger.warning("getMetadata: \(BaseWarningLog.MA_Method)") + UserModule.logger.warning("getInfo: \(BaseWarningLog.MA_Method)") } else { - print("getMetadata: \(BaseWarningLog.MA_Method)") + print("getInfo: \(BaseWarningLog.MA_Method)") } - let request = BasicRPCRequest(method: UserMethod.magic_auth_get_metadata.rawValue, params: []) + let request = BasicRPCRequest(method: UserMethod.magic_get_info.rawValue, params: []) return self.provider.send(request: request, response: response) } - public func getMetadata() -> Promise { + public func getInfo() -> Promise { return Promise { resolver in - getMetadata(response: promiseResolver(resolver)) + getInfo(response: promiseResolver(resolver)) } } @@ -141,7 +141,7 @@ public class UserModule: BaseModule { /** showSettings */ - public func showSettings(response: @escaping Web3ResponseCompletion) { + public func showSettings(response: @escaping Web3ResponseCompletion) { if #available(iOS 14.0, *) { UserModule.logger.warning("showSettings: \(BaseWarningLog.MA_Method)") } else { @@ -152,7 +152,7 @@ public class UserModule: BaseModule { self.provider.send(request: request, response: response) } - public func showSettings() -> Promise { + public func showSettings() -> Promise { return Promise { resolver in showSettings(response: promiseResolver(resolver)) } diff --git a/Sources/MagicSDK/Modules/User/UserResponse.swift b/Sources/MagicSDK/Modules/User/UserResponse.swift index ba6c2fb..f5eb89b 100644 --- a/Sources/MagicSDK/Modules/User/UserResponse.swift +++ b/Sources/MagicSDK/Modules/User/UserResponse.swift @@ -12,10 +12,23 @@ import MagicSDK_Web3 public protocol MagicResponse: Codable {} /// Get Id Token configuration -public struct UserMetadata: MagicResponse { +public struct UserInfo: MagicResponse { public let issuer: String? public let publicAddress: String? public let email: String? public let phoneNumber: String? + public let isMfaEnabled: Bool + public let recoveryFactors: [RecoveryFactor] + + public var description: String { + return """ + issuer: \(issuer ?? "nil") + publicAddress: \(publicAddress ?? "nil") + email: \(email ?? "nil") + phoneNumber: \(phoneNumber ?? "nil") + isMfaEnabled: \(isMfaEnabled) + recoveryFactors: \(recoveryFactors) + """ + } }