SwiftagramCrypto Documentation

Structure Authenticator

public struct Authenticator  

A struct defining an instance capable of starting the authentication flow for a given user.

Nested Types

Authenticator.Error

An enum listing some authentication-specific errors.

Authenticator.Key

A class defining an instance used for Secret management.

Authenticator.Keys

A class defining an instance used for Secrets management.

Authenticator.Group

An enum listing all authentication implementations.

Initializers

init(storage:​)

public init<S: Storage>(storage: S) where S.Item == Secret  

Init.

Parameters

storage S

A valid Storage.

client

A valid Client. Defaults to .default.

Properties

secrets

var secrets: Keys  

Return a manager for all Secrets.

storage

public let storage: AnyStorage<Secret>

The underlying storage.

transient

static var transient: Authenticator  

The default transient Authenticator.

user​Defaults

static var userDefaults: Authenticator  

The default user defaults-backed Authenticator.

keychain

static var keychain: Authenticator  

The default keychain-backed Authenticator.

Methods

secret(_:​)

func secret(_ label: String) -> Key  

Return a specific Secret manager.

Parameters

label String

A valid String.

Returns

A valid Key.

secret(_:​)

func secret(_ secret: Secret) -> Key  

Return a specific Secret manager.

Parameters

secret Secret

A valid Secret.

Returns

A valid Key.

secrets(_:​)

func secrets<C: Collection>(_ labels: C) -> Keys where C.Element == String  

Return some specific Secrets manager.

Parameters

labels C

A collection of Strings.

Returns

Some valid Keys.

secrets(_:​)

func secrets<C: Collection>(_ secrets: C) -> Keys where C.Element == Secret  

Return some specific Secrets manager.

Parameters

secrets C

A collection of Secrets.

Returns

Some valid Keys.

user​Defaults(_:​)

static func userDefaults(_ userDefaultsStorage: UserDefaultsStorage<Secret>) -> Authenticator  

A user defaults-backed Authenticator with a specific Client.

Parameters

user​Defaults​Storage User​Defaults​Storage<Secret>

A valid UserDefaultsStorage.

Returns

A valid Authenticator.

visual(_:​)

func visual(_ transformer: @escaping (_ webView: WKWebView, _ completion: @escaping () -> Void) -> Void) -> Group.Visual  

Authenticate using a WKWebView. You're responsibile for adding the web view to your view hierarchy and calling the completion handler.

Parameters

transformer @escaping (_ web​View:​ WKWeb​View, _ completion:​ @escaping () -> Void) -> Void

A valid web view transformer.

Returns

A valid Group.Visual.

visual(_:​)

func visual(_ transformer: @escaping (_ webView: WKWebView) -> Void) -> Group.Visual  

Authenticate using a WKWebView. You're responsible for adding the web view to your view hierarchy.

Parameters

transformer @escaping (_ web​View:​ WKWeb​View) -> Void

A valid web view transformer.

Returns

A valid Group.Visual.

visual(filling:​)

func visual(filling superview: UIView) -> Group.Visual  

Authenticate using a WKWebView. The web view will be added as a child of superview.

Parameters

superview UIView

A valid UIView.

Returns

A valid Group.Visual.

keychain(_:​)

static func keychain(_ keychainStorage: KeychainStorage<Secret>) -> Authenticator  

A keychain-backed Authenticator.

Parameters

keychain

A valid KeychainStorage.

Returns

A valid Authenticator.

basic(username:​password:​)

func basic(username: String, password: String) -> Group.Basic  

Authenticate using username and password.

2FA is supported in code and it will be handled as an Error in the authentication stream, returning a TwoFactorComposer authenticator.

Parameters

username String

A valid String.

password String

A valid String.

Returns

A valid Group.Basic.