Skip to content

Commit

Permalink
refactor: use latest version of torusutils
Browse files Browse the repository at this point in the history
  • Loading branch information
metalurgical committed Oct 6, 2024
1 parent 44e222e commit 6fdf296
Show file tree
Hide file tree
Showing 11 changed files with 29 additions and 20 deletions.
10 changes: 5 additions & 5 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
{
"identity" : "fetch-node-details-swift",
"kind" : "remoteSourceControl",
"location" : "https://github.com/torusresearch/fetch-node-details-swift.git",
"location" : "https://github.com/torusresearch/fetch-node-details-swift",
"state" : {
"revision" : "4bd96c33ba8d02d9e27190c5c7cedf09cfdfd656",
"version" : "6.0.3"
"branch" : "encapsulate_torusnetwork",
"revision" : "2fcd108ea89a48f092a955017977a299129d20c7"
}
},
{
Expand Down Expand Up @@ -68,8 +68,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/torusresearch/torus-utils-swift.git",
"state" : {
"revision" : "eda55b8537a600e657d19d4c452c0a36f217883c",
"version" : "9.0.1"
"branch" : "encapsulate_torusnetwork",
"revision" : "4d01a8d07cfbde3c23b468d1f234a4a73b0ca200"
}
}
],
Expand Down
4 changes: 1 addition & 3 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,14 @@ let package = Package(
targets: ["SingleFactorAuth"])
],
dependencies: [
.package(url: "https://github.com/torusresearch/fetch-node-details-swift.git", from: "6.0.3"),
.package(url: "https://github.com/torusresearch/torus-utils-swift.git", from: "9.0.1"),
.package(url: "https://github.com/torusresearch/torus-utils-swift.git", branch: "encapsulate_torusnetwork"),
.package(url: "https://github.com/vapor/jwt-kit.git", from: "4.0.0"),
.package(url: "https://github.com/Web3Auth/session-manager-swift.git", from: "5.0.0"),
],
targets: [
.target(
name: "SingleFactorAuth",
dependencies: [
.product(name: "FetchNodeDetails", package: "fetch-node-details-swift"),
.product(name: "TorusUtils", package: "torus-utils-swift"),
.product(name: "SessionManager", package: "session-manager-swift")
]),
Expand Down
5 changes: 2 additions & 3 deletions SingleFactorAuth.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |spec|
spec.name = "SingleFactorAuth"
spec.version = "8.0.0"
spec.version = "9.0.0"
spec.ios.deployment_target = "14.0"
spec.summary = "Enable one key flow for Web3Auth"
spec.homepage = "https://github.com/Web3Auth/single-factor-auth-swift"
Expand All @@ -10,8 +10,7 @@ Pod::Spec.new do |spec|
spec.module_name = "SingleFactorAuth"
spec.source = { :git => "https://github.com/web3Auth/single-factor-auth-swift", :tag => spec.version }
spec.source_files = "Sources/SingleFactorAuth/*.{swift,json}","Sources/SingleFactorAuth/**/*.{swift,json}"
spec.dependency 'Torus-fetchNodeDetails', '~> 6.0.3'
spec.dependency 'curvelib.swift', '~> 1.0.1'
spec.dependency 'Torus-utils', '~> 9.0.1'
spec.dependency 'Torus-utils', '~> 10.0.0'
spec.dependency 'TorusSessionManager', '~> 5.0.0'
end
14 changes: 14 additions & 0 deletions Sources/SingleFactorAuth/Error.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import Foundation

public enum SFAError: Error, Equatable {
case MFAAlreadyEnabled
}

extension SFAError: LocalizedError {
public var errorDescription: String? {
switch self {
case .MFAAlreadyEnabled:
return "User has already enabled MFA"
}
}
}
4 changes: 1 addition & 3 deletions Sources/SingleFactorAuth/SFAParams.swift
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import FetchNodeDetails

public typealias Web3AuthNetwork = TorusNetwork

public class SFAParams{
private var network: TorusNetwork
private var network: Web3AuthNetwork
private var networkUrl: String
private var web3AuthClientId: String
private var sessionTime: Int
Expand Down
2 changes: 1 addition & 1 deletion Sources/SingleFactorAuth/SingleFactorAuth.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class SingleFactorAuth {
let userDetails = try await torusUtils.getUserTypeAndAddress(endpoints: details.getTorusNodeEndpoints(), verifier: loginParams.verifier, verifierId: loginParams.verifierId)

if userDetails.metadata?.upgraded == true {
throw "User already has enabled MFA"
throw SFAError.MFAAlreadyEnabled
}

if let subVerifierInfoArray = loginParams.subVerifierInfoArray, !subVerifierInfoArray.isEmpty {
Expand Down
2 changes: 1 addition & 1 deletion Tests/SingleFactorAuthTests/AquaTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ final class AquaTest: XCTestCase {
let TEST_AGGREGRATE_VERIFIER = "torus-test-health-aggregate"

override func setUp() {
singleFactorAuthArgs = SFAParams(web3AuthClientId: "CLIENT ID", network: .legacy(.AQUA))
singleFactorAuthArgs = SFAParams(web3AuthClientId: "CLIENT ID", network: .AQUA)
singleFactoreAuth = try! SingleFactorAuth(params: singleFactorAuthArgs)
}

Expand Down
2 changes: 1 addition & 1 deletion Tests/SingleFactorAuthTests/CyanTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ final class CyanTest: XCTestCase {
let TEST_AGGREGRATE_VERIFIER = "torus-test-health-aggregate"

override func setUp() {
singleFactorAuthArgs = SFAParams(web3AuthClientId: "CLIENT ID", network: .legacy(.CYAN))
singleFactorAuthArgs = SFAParams(web3AuthClientId: "CLIENT ID", network: .CYAN)
singleFactoreAuth = try! SingleFactorAuth(params: singleFactorAuthArgs)
}

Expand Down
2 changes: 1 addition & 1 deletion Tests/SingleFactorAuthTests/SapphireDevnetTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ final class SapphireDevnetTests: XCTestCase {
let TEST_AGGREGRATE_VERIFIER = "torus-test-health-aggregate"

override func setUp() {
singleFactorAuthArgs = SFAParams(web3AuthClientId: "CLIENT ID", network: .sapphire(.SAPPHIRE_DEVNET))
singleFactorAuthArgs = SFAParams(web3AuthClientId: "CLIENT ID", network: .SAPPHIRE_DEVNET)
singleFactoreAuth = try! SingleFactorAuth(params: singleFactorAuthArgs)
}

Expand Down
2 changes: 1 addition & 1 deletion Tests/SingleFactorAuthTests/SapphireMainnetTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ final class SapphireMainnetTests: XCTestCase {
let TEST_AGGREGRATE_VERIFIER = "torus-aggregate-sapphire-mainnet"

override func setUp() {
singleFactorAuthArgs = SFAParams(web3AuthClientId: "CLIENT ID", network: .sapphire(.SAPPHIRE_MAINNET))
singleFactorAuthArgs = SFAParams(web3AuthClientId: "CLIENT ID", network: .SAPPHIRE_MAINNET)
singleFactoreAuth = try! SingleFactorAuth(params: singleFactorAuthArgs)
}

Expand Down
2 changes: 1 addition & 1 deletion Tests/SingleFactorAuthTests/SingleFactorAuthTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ final class SingleFactorAuthTests: XCTestCase {
let TEST_AGGREGRATE_VERIFIER = "torus-test-health-aggregate"

override func setUp() {
singleFactorAuthArgs = SFAParams(web3AuthClientId: "CLIENT ID", network: .legacy(.TESTNET))
singleFactorAuthArgs = SFAParams(web3AuthClientId: "CLIENT ID", network: .TESTNET)
singleFactoreAuth = try! SingleFactorAuth(params: singleFactorAuthArgs)
}

Expand Down

0 comments on commit 6fdf296

Please sign in to comment.