Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
metalurgical committed Sep 17, 2024
1 parent 8aa271d commit e3ec925
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 8 deletions.
8 changes: 7 additions & 1 deletion Sources/SingleFactorAuth/SFAParams.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -28,4 +30,8 @@ public class SFAParams{
public func setNetwork(network: Web3AuthNetwork) {
self.network = network
}

public func getSessionTime() -> Int {
return sessionTime
}
}
8 changes: 4 additions & 4 deletions Sources/SingleFactorAuth/SingleFactorAuth.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
2 changes: 1 addition & 1 deletion Tests/SingleFactorAuthTests/AquaTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion Tests/SingleFactorAuthTests/CyanTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion Tests/SingleFactorAuthTests/SingleFactorAuthTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit e3ec925

Please sign in to comment.