diff --git a/Sources/SingleFactorAuth/SFAParams.swift b/Sources/SingleFactorAuth/SFAParams.swift index 0e745cb..a198290 100644 --- a/Sources/SingleFactorAuth/SFAParams.swift +++ b/Sources/SingleFactorAuth/SFAParams.swift @@ -6,11 +6,13 @@ public class SFAParams{ private var network: TorusNetwork private var networkUrl: String private var web3AuthClientId: String + private var sessionTime: Int - public init(web3AuthClientId: String, network: Web3AuthNetwork, networkUrl: String = "") { + public init(web3AuthClientId: String, network: Web3AuthNetwork, sessionTime: Int = 86400, networkUrl: String = "") { self.network = network self.networkUrl = networkUrl self.web3AuthClientId = web3AuthClientId + self.sessionTime = sessionTime } public func getWeb3AuthClientId() -> String { @@ -28,4 +30,8 @@ public class SFAParams{ public func setNetwork(network: Web3AuthNetwork) { self.network = network } + + public func getSessionTime() -> Int { + return sessionTime + } } diff --git a/Sources/SingleFactorAuth/SingleFactorAuth.swift b/Sources/SingleFactorAuth/SingleFactorAuth.swift index 73ae6d8..37ebe79 100644 --- a/Sources/SingleFactorAuth/SingleFactorAuth.swift +++ b/Sources/SingleFactorAuth/SingleFactorAuth.swift @@ -13,10 +13,10 @@ public class SingleFactorAuth { let torusUtils: TorusUtils private var sessionManager: SessionManager - public init(singleFactorAuthArgs: SFAParams, sessionTime: Int) throws { - sessionManager = SessionManager(sessionTime: sessionTime, allowedOrigin: Bundle.main.bundleIdentifier ?? "single-factor-auth-swift") - nodeDetailManager = NodeDetailManager(network: singleFactorAuthArgs.getNetwork()) - let torusOptions = TorusOptions(clientId: singleFactorAuthArgs.getWeb3AuthClientId(), network: singleFactorAuthArgs.getNetwork(), enableOneKey: true) + public init(params: SFAParams) throws { + sessionManager = SessionManager(sessionTime: params.getSessionTime(), allowedOrigin: Bundle.main.bundleIdentifier ?? "single-factor-auth-swift") + nodeDetailManager = NodeDetailManager(network: params.getNetwork()) + let torusOptions = TorusOptions(clientId: params.getWeb3AuthClientId(), network: params.getNetwork(), enableOneKey: true) try torusUtils = TorusUtils(params: torusOptions) } diff --git a/Tests/SingleFactorAuthTests/AquaTest.swift b/Tests/SingleFactorAuthTests/AquaTest.swift index d569929..a08100b 100644 --- a/Tests/SingleFactorAuthTests/AquaTest.swift +++ b/Tests/SingleFactorAuthTests/AquaTest.swift @@ -15,7 +15,7 @@ final class AquaTest: XCTestCase { override func setUp() { singleFactorAuthArgs = SFAParams(web3AuthClientId: "CLIENT ID", network: .legacy(.AQUA)) - singleFactoreAuth = try! SingleFactorAuth(singleFactorAuthArgs: singleFactorAuthArgs, sessionTime: 86400) + singleFactoreAuth = try! SingleFactorAuth(params: singleFactorAuthArgs) } func testConnect() async throws { diff --git a/Tests/SingleFactorAuthTests/CyanTest.swift b/Tests/SingleFactorAuthTests/CyanTest.swift index d10a958..56b1cf2 100644 --- a/Tests/SingleFactorAuthTests/CyanTest.swift +++ b/Tests/SingleFactorAuthTests/CyanTest.swift @@ -14,7 +14,7 @@ final class CyanTest: XCTestCase { override func setUp() { singleFactorAuthArgs = SFAParams(web3AuthClientId: "CLIENT ID", network: .legacy(.CYAN)) - singleFactoreAuth = try! SingleFactorAuth(singleFactorAuthArgs: singleFactorAuthArgs, sessionTime: 86400) + singleFactoreAuth = try! SingleFactorAuth(params: singleFactorAuthArgs) } func testConnect() async throws { diff --git a/Tests/SingleFactorAuthTests/SingleFactorAuthTests.swift b/Tests/SingleFactorAuthTests/SingleFactorAuthTests.swift index 618281a..4e08843 100644 --- a/Tests/SingleFactorAuthTests/SingleFactorAuthTests.swift +++ b/Tests/SingleFactorAuthTests/SingleFactorAuthTests.swift @@ -14,7 +14,7 @@ final class SingleFactorAuthTests: XCTestCase { override func setUp() { singleFactorAuthArgs = SFAParams(web3AuthClientId: "CLIENT ID", network: .legacy(.TESTNET)) - singleFactoreAuth = try! SingleFactorAuth(singleFactorAuthArgs: singleFactorAuthArgs, sessionTime: 86400) + singleFactoreAuth = try! SingleFactorAuth(params: singleFactorAuthArgs) } func testConnect() async throws {