From 3e608d0369e03ad57d0fd960309e15cbbaf567c7 Mon Sep 17 00:00:00 2001 From: Yll Fejziu Date: Thu, 2 May 2024 15:36:41 +0200 Subject: [PATCH] Update docs --- README.md | 18 ++++++------------ Sources/Apple/AppleAuthenticator.swift | 4 ++-- Sources/Facebook/FacebookAuthenticator.swift | 2 +- Sources/Google/GoogleAuthenticator.swift | 2 +- Sources/LinkedIn/LinkedInAuthenticator.swift | 2 +- 5 files changed, 11 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 2009216..4ac93f9 100644 --- a/README.md +++ b/README.md @@ -54,19 +54,13 @@ let manager = SocialAuthenticationManager(authenticators: [AppleAuthenticator(), // signIn user with Apple let appleAuthenticator = manager.authenticator(for: AppleAuthenticator.self) -appleAuthenticator? +let result = try await appleAuthenticator? .signIn(from: , with: .random(length: 32)) - .finally { - // handle result - } // signIn user with Facebook let facebookAuthenticator = manager.authenticator(for: FacebookAuthenticator.self) -facebookAuthenticator? +let result = try await facebookAuthenticator? .signIn(from: , with: [.email]) - .finally { - // handle result - } // return currently authenticated authenticator let authenticated: Authenticator? = manager.authenticator @@ -123,11 +117,11 @@ You can easily add new authenticator that is not built-in with PovioKitAuth pack ```swift final class SnapchatAuthenticator: Authenticator { - public func signIn(from presentingViewController: UIViewController) -> Promise { - Promise { seal in + public func signIn(from presentingViewController: UIViewController) async throws -> Response { + try await withCheckedThrowingContinuation { continuation in SCSDKLoginClient.login(from: presentingViewController) { [weak self] success, error in guard success, error == nil else { - seal.reject(with: error) + continuation.resume(throwing: error) return } @@ -135,7 +129,7 @@ final class SnapchatAuthenticator: Authenticator { let variables = ["page": "bitmoji"] SCSDKLoginClient.fetchUserData(withQuery: query, variables: variables) { resources in ... - seal.resolve(with: response) + continuation.resume(returning: response) } } } diff --git a/Sources/Apple/AppleAuthenticator.swift b/Sources/Apple/AppleAuthenticator.swift index be1ea32..9bd1fcd 100644 --- a/Sources/Apple/AppleAuthenticator.swift +++ b/Sources/Apple/AppleAuthenticator.swift @@ -33,7 +33,7 @@ public final class AppleAuthenticator: NSObject { extension AppleAuthenticator: Authenticator { /// SignIn user /// - /// Will asynchronously return the `Response` object on success or with `Error` on error. + /// Will asynchronously return the `Response` object on success or `Error` on error. public func signIn(from presentingViewController: UIViewController) async throws -> Response { try await appleSignIn(on: presentingViewController, with: nil) } @@ -41,7 +41,7 @@ extension AppleAuthenticator: Authenticator { /// SignIn user with `nonce` value /// /// Nonce is usually needed when doing auth with an external auth provider (e.g. firebase). - /// Will asynchronously return the `Response` object on success or with `Error` on error. + /// Will asynchronously return the `Response` object on success or `Error` on error. public func signIn(from presentingViewController: UIViewController, with nonce: Nonce) async throws -> Response { try await appleSignIn(on: presentingViewController, with: nonce) } diff --git a/Sources/Facebook/FacebookAuthenticator.swift b/Sources/Facebook/FacebookAuthenticator.swift index 9dbde38..9fa07c7 100644 --- a/Sources/Facebook/FacebookAuthenticator.swift +++ b/Sources/Facebook/FacebookAuthenticator.swift @@ -24,7 +24,7 @@ extension FacebookAuthenticator: Authenticator { /// SignIn user. /// /// The `permissions` to use when doing a sign in. - /// Will asynchronously return the `Response` object on success or with `Error` on error. + /// Will asynchronously return the `Response` object on success or `Error` on error. public func signIn( from presentingViewController: UIViewController, with permissions: [Permission] = [.email, .publicProfile]) async throws -> Response diff --git a/Sources/Google/GoogleAuthenticator.swift b/Sources/Google/GoogleAuthenticator.swift index f5bb91d..1ae9c77 100644 --- a/Sources/Google/GoogleAuthenticator.swift +++ b/Sources/Google/GoogleAuthenticator.swift @@ -22,7 +22,7 @@ public final class GoogleAuthenticator { extension GoogleAuthenticator: Authenticator { /// SignIn user. /// - /// Will asynchronously return the `Response` object on success or with `Error` on error. + /// Will asynchronously return the `Response` object on success or `Error` on error. public func signIn(from presentingViewController: UIViewController, hint: String? = .none, additionalScopes: [String]? = .none) async throws -> Response { diff --git a/Sources/LinkedIn/LinkedInAuthenticator.swift b/Sources/LinkedIn/LinkedInAuthenticator.swift index cfb8ca7..d9cba82 100644 --- a/Sources/LinkedIn/LinkedInAuthenticator.swift +++ b/Sources/LinkedIn/LinkedInAuthenticator.swift @@ -25,7 +25,7 @@ public final class LinkedInAuthenticator { extension LinkedInAuthenticator: Authenticator { /// SignIn user. /// - /// Will return promise with the `Response` object on success or with `Error` on error. + /// Will asynchronously return the `Response` object on success or `Error` on error. public func signIn(authCode: String, configuration: Configuration) async throws -> Response { let authRequest: LinkedInAPI.LinkedInAuthRequest = .init( code: authCode,