UnbluAuthHelper

public class UnbluAuthHelper
  • Sends a POST request to the Unblu backend to create an authentication token using the provided credentials.

    Declaration

    Swift

    public static func createAuthenticationToken(with configuration: UnbluClientConfiguration,
                                    username: String?, password: String?, success: @escaping (AuthenticationTokenCreationResult) -> Void,failure: ((String) -> Void)?)

    Parameters

    configuration

    The Unblu client configuration containing the base URL and entry path.

    username

    The username to authenticate.

    password

    The password to authenticate.

    success

    Closure called with the authentication token string upon successful response.

    failure

    Optional closure called with an error message string if the request fails.

  • Sends a GET request to the Unblu backend using an existing authentication token, and returns the result string and authentication cookies.

    Declaration

    Swift

    public static func authenticateWithToken(with configuration: UnbluClientConfiguration,
                               authenticationToken: String, success: @escaping (String, [String: String]) -> Void,failure: ((String) -> Void)?)

    Parameters

    configuration

    The Unblu client configuration.

    authenticationToken

    A valid one-time token used for authentication.

    success

    Closure called with the raw result string and a dictionary of cookies upon success.

    failure

    Optional closure called with an error message string if the request fails.

  • Authenticates with an existing token and completes the 2FA login flow.

    This method first authenticates using the provided token to retrieve cookies, then displays a two-factor authentication web view if the authentication is successful.

    Declaration

    Swift

    public static func authenticateWithTokenAndLoginWith2FA(with configuration: UnbluClientConfiguration, token: String, uiConfig: UnbluTwoFactorAuthErrorUIConfig = .init(), completion: @escaping (Bool, [UnbluCookie]?) -> Void)

    Parameters

    configuration

    The Unblu client configuration to use.

    token

    The authentication token obtained previously.

    uiConfig

    The UnbluTwoFactorAuthUIConfig used to configure the error window’s button titles and colors.

    completion

    A closure called when the process is completed. Returns a Boolean indicating success, and an array of authentication cookies (or nil on failure).

  • Performs a full login flow including authentication token creation and two-factor authentication.

    This method creates an authentication token using the provided username and password, authenticates with that token, and if needed, presents a two-factor authentication web view.

    Declaration

    Swift

    public static func createAuthTokenAndLoginWith2FA(with configuration: UnbluClientConfiguration, username: String, password: String, uiConfig: UnbluTwoFactorAuthErrorUIConfig = .init(), completion: @escaping (Bool, [UnbluCookie]?) -> Void)

    Parameters

    configuration

    The Unblu client configuration to use.

    username

    The username for authentication.

    password

    The password for authentication.

    uiConfig

    The UnbluTwoFactorAuthUIConfig used to configure the error window’s button titles and colors.

    completion

    A closure called when the process is completed. Returns a Boolean indicating success, and an array of authentication cookies (or nil on failure).

  • Declaration

    Swift

    public static func getAuthToken(preferencesStorage: UnbluPreferencesStorage) -> String?