From 5d5189c554bf30be5a60dbb65339c8ecdf20affd Mon Sep 17 00:00:00 2001
From: metalurgical <97008724+metalurgical@users.noreply.github.com>
Date: Mon, 17 Jun 2024 03:57:31 +0200
Subject: [PATCH] update

---
 CustomAuthDemo/CustomAuthDemo/ContentView.swift  |  2 +-
 Sources/CustomAuth/Handlers/HandlerFactory.swift | 15 +++++++--------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/CustomAuthDemo/CustomAuthDemo/ContentView.swift b/CustomAuthDemo/CustomAuthDemo/ContentView.swift
index 1da0bc3..3fa86e9 100644
--- a/CustomAuthDemo/CustomAuthDemo/ContentView.swift
+++ b/CustomAuthDemo/CustomAuthDemo/ContentView.swift
@@ -14,7 +14,7 @@ struct ContentView: View {
                         let customAuth = try CustomAuth(config: customAuthArgs)
                         let torusLoginResponse = try await customAuth.triggerLogin(args: sub)
                         let encoded = try JSONEncoder().encode(torusLoginResponse)
-                        debugPrint(encoded)
+                        debugPrint(String(data: encoded, encoding: .utf8)!)
                     } catch {
                         debugPrint(error)
                     }
diff --git a/Sources/CustomAuth/Handlers/HandlerFactory.swift b/Sources/CustomAuth/Handlers/HandlerFactory.swift
index a737bb3..a32e339 100644
--- a/Sources/CustomAuth/Handlers/HandlerFactory.swift
+++ b/Sources/CustomAuth/Handlers/HandlerFactory.swift
@@ -12,17 +12,15 @@ public class HandlerFactory {
             throw CASDKError.invalidClientID
         }
 
-        let domain = params.jwtParams?.domain
-
         switch params.typeOfLogin {
         case .google:
-            return try GoogleLoginHandler(clientId: params.clientId, verifier: params.verifier, urlScheme: params.urlScheme, redirectURL: params.redirectURL, typeOfLogin: params.typeOfLogin)
+            return try GoogleLoginHandler(clientId: params.clientId, verifier: params.verifier, urlScheme: params.urlScheme, redirectURL: params.redirectURL, typeOfLogin: params.typeOfLogin, jwtParams: params.jwtParams, customState: params.customState)
         case .facebook:
-            return try FacebookLoginHandler(clientId: params.clientId, verifier: params.verifier, urlScheme: params.urlScheme, redirectURL: params.redirectURL, typeOfLogin: params.typeOfLogin)
+            return try FacebookLoginHandler(clientId: params.clientId, verifier: params.verifier, urlScheme: params.urlScheme, redirectURL: params.redirectURL, typeOfLogin: params.typeOfLogin, jwtParams: params.jwtParams, customState: params.customState)
         case .reddit:
-            return try RedditLoginHandler(clientId: params.clientId, verifier: params.verifier, urlScheme: params.urlScheme, redirectURL: params.redirectURL, typeOfLogin: params.typeOfLogin)
+            return try RedditLoginHandler(clientId: params.clientId, verifier: params.verifier, urlScheme: params.urlScheme, redirectURL: params.redirectURL, typeOfLogin: params.typeOfLogin, jwtParams: params.jwtParams, customState: params.customState)
         case .twitch:
-            return try TwitchLoginHandler(clientId: params.clientId, verifier: params.verifier, urlScheme: params.urlScheme, redirectURL: params.redirectURL, typeOfLogin: params.typeOfLogin)
+            return try TwitchLoginHandler(clientId: params.clientId, verifier: params.verifier, urlScheme: params.urlScheme, redirectURL: params.redirectURL, typeOfLogin: params.typeOfLogin, jwtParams: params.jwtParams, customState: params.customState)
         case .apple: break
         case .github: break
         case .linkedin: break
@@ -34,13 +32,14 @@ public class HandlerFactory {
         }
 
         if params.jwtParams?.id_token == nil || params.jwtParams?.access_token == nil {
-            return try MockLoginHandler(clientId: params.clientId, verifier: params.verifier, urlScheme: params.urlScheme, redirectURL: params.redirectURL, typeOfLogin: params.typeOfLogin)
+            return try MockLoginHandler(clientId: params.clientId, verifier: params.verifier, urlScheme: params.urlScheme, redirectURL: params.redirectURL, typeOfLogin: params.typeOfLogin, jwtParams: params.jwtParams, customState: params.customState)
         }
 
+        let domain = params.jwtParams?.domain
         if domain == nil {
             throw CASDKError.invalidAuth0Options
         }
 
-        return try JWTLoginHandler(clientId: params.clientId, verifier: params.verifier, urlScheme: params.urlScheme, redirectURL: params.redirectURL, typeOfLogin: params.typeOfLogin)
+        return try JWTLoginHandler(clientId: params.clientId, verifier: params.verifier, urlScheme: params.urlScheme, redirectURL: params.redirectURL, typeOfLogin: params.typeOfLogin, jwtParams: params.jwtParams, customState: params.customState)
     }
 }