Skip to content

Commit

Permalink
add auth config
Browse files Browse the repository at this point in the history
  • Loading branch information
llbartekll committed Aug 19, 2022
1 parent 10a87cb commit 213736c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
16 changes: 8 additions & 8 deletions Sources/Auth/Auth.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@ import Combine
public class Auth {

public static var instance: AuthClient = {
guard let metadata = Auth.metadata else {
guard let config = Auth.config else {
fatalError("Error - you must call Auth.configure(_:) before accessing the shared instance.")
}
return AuthClientFactory.create(
metadata: metadata,
account: account,
metadata: config.metadata,
account: config.account,
relayClient: Relay.instance)
}()

private static var metadata: AppMetadata?
private static var account: Account?

private static var config: Config?

private init() { }

static public func configure(metadata: AppMetadata, account: Account?) {
Auth.metadata = metadata
Auth.account = account
Auth.config = Auth.Config(
metadata: metadata,
account: account)
}
}
8 changes: 8 additions & 0 deletions Sources/Auth/AuthConfig.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import Foundation

extension Auth {
struct Config {
let metadata: AppMetadata
let account: Account?
}
}

0 comments on commit 213736c

Please sign in to comment.