diff --git a/Sources/AppAuthKit/Authentication.swift b/Sources/AppAuthKit/Authentication.swift index e3a1a58..3ceb66c 100644 --- a/Sources/AppAuthKit/Authentication.swift +++ b/Sources/AppAuthKit/Authentication.swift @@ -10,7 +10,9 @@ import Foundation public protocol Authentication { // MARK: - Methods - func startPasswordless(email: String) -> FusionRequest + func startPasswordless(email: String) -> FusionRequest + + func sendPasswordless(code: String) -> FusionRequest func login(otp: String) -> FusionRequest diff --git a/Sources/AppAuthKit/Domain/OtpCode.swift b/Sources/AppAuthKit/Domain/OtpCode.swift new file mode 100644 index 0000000..2d629bc --- /dev/null +++ b/Sources/AppAuthKit/Domain/OtpCode.swift @@ -0,0 +1,5 @@ +import Foundation + +public final class OtpCode: Codable { + public let code: String +} diff --git a/Sources/AppAuthKit/FusionAuthAuthentication.swift b/Sources/AppAuthKit/FusionAuthAuthentication.swift index f78c6d9..5b62a24 100644 --- a/Sources/AppAuthKit/FusionAuthAuthentication.swift +++ b/Sources/AppAuthKit/FusionAuthAuthentication.swift @@ -39,12 +39,26 @@ public struct FusionAuthAuthentication: Authentication { self.session = session } - public func startPasswordless(email: String) -> FusionRequest { + public func startPasswordless(email: String) -> FusionRequest { let url = URL(string: "/api/passwordless/start", relativeTo: self.url)! let payload: [String: Any] = [ "applicationId": clientId, "loginId": email ] + return FusionRequest(session: session, + url: url, + method: "POST", + handle: codable, + parameters: payload, + contentType: .json) + .headers(["Authorization": apiKey]) + } + + public func sendPasswordless(code: String) -> FusionRequest { + let url = URL(string: "/api/passwordless/send", relativeTo: self.url)! + let payload: [String: Any] = [ + "code": code + ] return FusionRequest(session: session, url: url, method: "POST",