@@ -10,7 +10,8 @@ import Combine
1010import  SwiftUI
1111import  WebKit
1212
13- public  class  OAWebViewCoordinator :  NSObject ,  WKNavigationDelegate  { 
13+ @MainActor  
14+ public  class  OAWebViewCoordinator :  NSObject  { 
1415
1516    var  webView :  OAWebView 
1617
@@ -26,20 +27,6 @@ public class OAWebViewCoordinator: NSObject, WKNavigationDelegate {
2627        super. init ( ) 
2728    } 
2829
29-     public  func  webView( _ webView:  WKWebView ,  decidePolicyFor navigationAction:  WKNavigationAction ,  decisionHandler:  @escaping  ( WKNavigationActionPolicy )  ->  Void )  { 
30-         guard  let  url =  navigationAction. request. url else  { 
31-             decisionHandler ( . cancel) 
32-             return 
33-         } 
34-         switch  oauth. state { 
35-         case  . empty,  . requestingAccessToken,  . authorized: 
36-             break 
37-         case  . authorizing( let  provider) : 
38-             handle ( url:  url,  provider:  provider) 
39-         } 
40-         decisionHandler ( . allow) 
41-     } 
42- 
4330    /// Handles the authorization url for the specified provider.
4431    /// - Parameters:
4532    ///   - url: the url to handle
@@ -74,4 +61,21 @@ public class OAWebViewCoordinator: NSObject, WKNavigationDelegate {
7461        } 
7562    } 
7663} 
64+ 
65+ extension  OAWebViewCoordinator :  WKNavigationDelegate  { 
66+ 
67+     public  func  webView( _ webView:  WKWebView ,  decidePolicyFor navigationAction:  WKNavigationAction )  async  ->  WKNavigationActionPolicy  { 
68+         guard  let  url =  navigationAction. request. url else  { 
69+             return  . cancel
70+         } 
71+         switch  oauth. state { 
72+         case  . empty,  . requestingAccessToken,  . authorized: 
73+             break 
74+         case  . authorizing( let  provider) : 
75+             handle ( url:  url,  provider:  provider) 
76+         } 
77+         return  . allow
78+     } 
79+ } 
80+ 
7781#endif 
0 commit comments