From 76733889a962047d0cbb93c284ca3dcc8c74c3fe Mon Sep 17 00:00:00 2001 From: Alexander Lisovik Date: Mon, 9 Oct 2023 11:32:48 +0400 Subject: [PATCH] Remove verify host --- Sources/WalletConnectVerify/OriginVerifier.swift | 10 +++------- Sources/WalletConnectVerify/VerifyClient.swift | 15 ++++----------- .../WalletConnectVerify/VerifyClientFactory.swift | 5 ++--- Sources/WalletConnectVerify/VerifyContext.swift | 4 +--- 4 files changed, 10 insertions(+), 24 deletions(-) diff --git a/Sources/WalletConnectVerify/OriginVerifier.swift b/Sources/WalletConnectVerify/OriginVerifier.swift index 10b403f81..0689088d2 100644 --- a/Sources/WalletConnectVerify/OriginVerifier.swift +++ b/Sources/WalletConnectVerify/OriginVerifier.swift @@ -5,15 +5,11 @@ public final class OriginVerifier { case registrationFailed } - private var verifyHost: String + private var verifyHost = "verify.walletconnect.com" /// The property is used to determine whether verify.walletconnect.org will be used /// in case verify.walletconnect.com doesn't respond for some reason (most likely due to being blocked in the user's location). private var fallback = false - - init(verifyHost: String) { - self.verifyHost = verifyHost - } - + func verifyOrigin(assertionId: String) async throws -> VerifyResponse { let sessionConfiguration = URLSessionConfiguration.default sessionConfiguration.timeoutIntervalForRequest = 5.0 @@ -27,7 +23,7 @@ public final class OriginVerifier { VerifyResponse.self, at: VerifyAPI.resolve(assertionId: assertionId) ) - guard let origin = response.origin else { + guard let _ = response.origin else { throw Errors.registrationFailed } return response diff --git a/Sources/WalletConnectVerify/VerifyClient.swift b/Sources/WalletConnectVerify/VerifyClient.swift index 37b74dfea..e528f2b60 100644 --- a/Sources/WalletConnectVerify/VerifyClient.swift +++ b/Sources/WalletConnectVerify/VerifyClient.swift @@ -14,16 +14,12 @@ public actor VerifyClient: VerifyClientProtocol { let originVerifier: OriginVerifier let assertionRegistrer: AssertionRegistrer let appAttestationRegistrer: AppAttestationRegistrer - - private let verifyHost: String init( - verifyHost: String, originVerifier: OriginVerifier, assertionRegistrer: AssertionRegistrer, appAttestationRegistrer: AppAttestationRegistrer ) { - self.verifyHost = verifyHost self.originVerifier = originVerifier self.assertionRegistrer = assertionRegistrer self.appAttestationRegistrer = appAttestationRegistrer @@ -41,21 +37,18 @@ public actor VerifyClient: VerifyClientProtocol { guard isScam == nil else { return VerifyContext( origin: origin, - validation: .scam, - verifyUrl: verifyHost + validation: .scam ) } if let origin, let originUrl = URL(string: origin), let domainUrl = URL(string: domain) { return VerifyContext( origin: origin, - validation: (originUrl.host == domainUrl.host) ? .valid : .invalid, - verifyUrl: verifyHost + validation: (originUrl.host == domainUrl.host) ? .valid : .invalid ) } else { return VerifyContext( origin: origin, - validation: .unknown, - verifyUrl: verifyHost + validation: .unknown ) } } @@ -75,7 +68,7 @@ public struct VerifyClientMock: VerifyClientProtocol { } public func createVerifyContext(origin: String?, domain: String, isScam: Bool?) -> VerifyContext { - return VerifyContext(origin: "domain.com", validation: .valid, verifyUrl: "verify.walletconnect.com") + return VerifyContext(origin: "domain.com", validation: .valid) } } diff --git a/Sources/WalletConnectVerify/VerifyClientFactory.swift b/Sources/WalletConnectVerify/VerifyClientFactory.swift index 1d00a6af1..8b230fc5f 100644 --- a/Sources/WalletConnectVerify/VerifyClientFactory.swift +++ b/Sources/WalletConnectVerify/VerifyClientFactory.swift @@ -1,8 +1,8 @@ import Foundation public class VerifyClientFactory { - public static func create(verifyHost: String = "verify.walletconnect.com") -> VerifyClient { - let originVerifier = OriginVerifier(verifyHost: verifyHost) + public static func create() -> VerifyClient { + let originVerifier = OriginVerifier() let assertionRegistrer = AssertionRegistrer() let logger = ConsoleLogger(loggingLevel: .off) let keyValueStorage = UserDefaults.standard @@ -18,7 +18,6 @@ public class VerifyClientFactory { keyAttestationService: keyAttestationService ) return VerifyClient( - verifyHost: verifyHost, originVerifier: originVerifier, assertionRegistrer: assertionRegistrer, appAttestationRegistrer: appAttestationRegistrer diff --git a/Sources/WalletConnectVerify/VerifyContext.swift b/Sources/WalletConnectVerify/VerifyContext.swift index 85382e090..e85613493 100644 --- a/Sources/WalletConnectVerify/VerifyContext.swift +++ b/Sources/WalletConnectVerify/VerifyContext.swift @@ -8,11 +8,9 @@ public struct VerifyContext: Equatable, Hashable, Codable { public let origin: String? public let validation: ValidationStatus - public let verifyUrl: String - public init(origin: String?, validation: ValidationStatus, verifyUrl: String) { + public init(origin: String?, validation: ValidationStatus) { self.origin = origin self.validation = validation - self.verifyUrl = verifyUrl } }