Skip to content

Commit e49799d

Browse files
authored
Fix linter warnings (#899)
1 parent f11be60 commit e49799d

5 files changed

+20
-22
lines changed

Auth0/Helpers.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ func extractRedirectURL(from url: URL) -> URL? {
2020
guard let components = URLComponents(url: url, resolvingAgainstBaseURL: true) else {
2121
return nil
2222
}
23-
23+
2424
if let redirectURIString = components.queryItems?.first(where: { $0.name == "redirect_uri" || $0.name == "returnTo" })?.value,
2525
let redirectURI = URL(string: redirectURIString) {
2626
return redirectURI
2727
}
28-
28+
2929
return nil
30-
}
30+
}

Auth0/MobileWebAuth.swift

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,21 @@ import UIKit
33
import AuthenticationServices
44

55
extension UIApplication {
6-
6+
77
static func shared() -> UIApplication? {
88
return UIApplication.perform(NSSelectorFromString("sharedApplication"))?.takeUnretainedValue() as? UIApplication
99
}
10-
10+
1111
}
1212

1313
extension ASUserAgent: ASWebAuthenticationPresentationContextProviding {
14-
14+
1515
#if os(iOS)
1616
func presentationAnchor(for session: ASWebAuthenticationSession) -> ASPresentationAnchor {
1717
return UIApplication.shared()?.windows.last(where: \.isKeyWindow) ?? ASPresentationAnchor()
1818
}
1919
#endif
20-
20+
2121
#if os(visionOS)
2222
func presentationAnchor(for session: ASWebAuthenticationSession) -> ASPresentationAnchor {
2323
if let windowScene = UIApplication.shared()?.connectedScenes.first(where: { $0.activationState == .foregroundActive }) as? UIWindowScene {
@@ -26,6 +26,6 @@ extension ASUserAgent: ASWebAuthenticationPresentationContextProviding {
2626
return ASPresentationAnchor()
2727
}
2828
#endif
29-
29+
3030
}
3131
#endif

Auth0/UIWindow+TopViewController.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ extension UIWindow {
1616
}
1717
return findTopViewController(from: root)
1818
}
19-
19+
2020
private static func findTopViewController(from root: UIViewController) -> UIViewController? {
2121
if let presented = root.presentedViewController { return self.findTopViewController(from: presented) }
2222

Auth0/WebAuthError.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public struct WebAuthError: Auth0Error {
4040
/// build a valid URL.
4141
/// This error does not include a ``Auth0Error/cause-9wuyi``.
4242
public static let noBundleIdentifier: WebAuthError = .init(code: .noBundleIdentifier)
43-
43+
4444
/// There is already an active transaction at the moment; therefore, this newly initiated transaction is canceled.
4545
/// This error does not include a ``Auth0Error/cause-9wuyi``.
4646
public static let transactionActiveAlready: WebAuthError = .init(code: .transactionActiveAlready)

Auth0/WebViewProvider.swift

+10-12
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
@preconcurrency import WebKit
1212

13-
1413
/// WARNING: The use of `webViewProvider` [is not recommended](https://auth0.com/blog/oauth-2-best-practices-for-native-apps) and contravenes the guidelines of the OAuth Protocol, which advises against using web views for WebAuth.
1514
/// The recommended approach is to utilize `ASWebAuthenticationSession`. Employ the provider below only if you fully understand the associated risks and are confident in your decision.
1615
public extension WebAuthentication {
@@ -23,25 +22,24 @@ public extension WebAuthentication {
2322
}
2423

2524
class WebViewUserAgent: NSObject, WebAuthUserAgent {
26-
25+
2726
static let customSchemeRedirectionSuccessMessage = "com.auth0.webview.redirection_success"
2827
static let customSchemeRedirectionFailureMessage = "com.auth0.webview.redirection_failure"
2928
let defaultSchemesSupportedByWKWebview = ["https"]
30-
29+
3130
let request: URLRequest
3231
var webview: WKWebView!
3332
let viewController: UIViewController
3433
let redirectURL: URL
3534
let callback: WebAuthProviderCallback
36-
37-
35+
3836
init(authorizeURL: URL, redirectURL: URL, viewController: UIViewController = UIViewController(), modalPresentationStyle: UIModalPresentationStyle = .fullScreen, callback: @escaping WebAuthProviderCallback) {
3937
self.request = URLRequest(url: authorizeURL)
4038
self.redirectURL = redirectURL
4139
self.callback = callback
4240
self.viewController = viewController
4341
self.viewController.modalPresentationStyle = modalPresentationStyle
44-
42+
4543
super.init()
4644
if !defaultSchemesSupportedByWKWebview.contains(redirectURL.scheme!) {
4745
self.setupWebViewWithCustomScheme()
@@ -63,7 +61,7 @@ class WebViewUserAgent: NSObject, WebAuthUserAgent {
6361
self.viewController.view = webview
6462
webview.navigationDelegate = self
6563
}
66-
64+
6765
func start() {
6866
self.webview.load(self.request)
6967
UIWindow.topViewController?.present(self.viewController, animated: true)
@@ -81,7 +79,7 @@ class WebViewUserAgent: NSObject, WebAuthUserAgent {
8179
}
8280
}
8381
}
84-
82+
8583
public override var description: String {
8684
return String(describing: WKWebView.self)
8785
}
@@ -96,7 +94,7 @@ extension WebViewUserAgent: WKURLSchemeHandler {
9694
])
9795
urlSchemeTask.didFailWithError(error)
9896
}
99-
97+
10098
func webView(_ webView: WKWebView, stop urlSchemeTask: any WKURLSchemeTask) {
10199
let error = NSError(domain: WebViewUserAgent.customSchemeRedirectionFailureMessage, code: 400, userInfo: [
102100
NSLocalizedDescriptionKey: "WebViewProvider: WKURLSchemeHandler: Webview Resource Loading has been stopped"
@@ -116,21 +114,21 @@ extension WebViewUserAgent: WKNavigationDelegate {
116114
decisionHandler(.allow)
117115
}
118116
}
119-
117+
120118
func webView(_ webView: WKWebView, didFail navigation: WKNavigation!, withError error: any Error) {
121119
if (error as NSError).domain == WebViewUserAgent.customSchemeRedirectionSuccessMessage {
122120
return
123121
}
124122
self.finish(with: .failure(WebAuthError(code: .webViewFailure("An error occurred during a committed main frame navigation of the WebView."), cause: error)))
125123
}
126-
124+
127125
func webView(_ webView: WKWebView, didFailProvisionalNavigation navigation: WKNavigation!, withError error: any Error) {
128126
if (error as NSError).domain == WebViewUserAgent.customSchemeRedirectionSuccessMessage {
129127
return
130128
}
131129
self.finish(with: .failure(WebAuthError(code: .webViewFailure("An error occurred while starting to load data for the main frame of the WebView."), cause: error)))
132130
}
133-
131+
134132
func webViewWebContentProcessDidTerminate(_ webView: WKWebView) {
135133
self.finish(with: .failure(WebAuthError(code: .webViewFailure("The WebView's content process was terminated."))))
136134
}

0 commit comments

Comments
 (0)