From 2964dfefb7885fa9ddf0f8a830ae21dcad1169ec Mon Sep 17 00:00:00 2001 From: Pragati Date: Mon, 29 Jan 2024 15:38:38 +0530 Subject: [PATCH 01/34] Add PhoneAuth details in Settings view --- .../SwiftApplication.plist | 4 +- .../SettingsViewController.swift | 93 +++++++++++++++++-- 2 files changed, 86 insertions(+), 11 deletions(-) diff --git a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/SwiftApplication.plist b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/SwiftApplication.plist index 50378fe58b0..cdbcd12729a 100644 --- a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/SwiftApplication.plist +++ b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/SwiftApplication.plist @@ -24,7 +24,9 @@ CFBundleURLName CFBundleURLSchemes - + + com.googleusercontent.apps.585304629422-ab795evno6vsrj7i7o1a3gi6eo01508b + CFBundleVersion diff --git a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/SettingsViewController.swift b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/SettingsViewController.swift index fc6b91e9a23..a6e1421aa38 100644 --- a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/SettingsViewController.swift +++ b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/SettingsViewController.swift @@ -186,23 +186,96 @@ extension AuthSettings: DataSourceProvidable { detailTitle: "Current Access Group")] return Section(headerDescription: "Keychain Access Groups", items: items) } + + func truncatedString(string: String, length: Int) -> String { + guard string.count > length else { return string } + + let half = (length - 3) / 2 + let startIndex = string.startIndex + let midIndex = string.index(startIndex, offsetBy: half) // Ensure correct mid index + let endIndex = string.index(startIndex, offsetBy: string.count - half) + + return "\(string[startIndex.. Void) { + let alertController = UIAlertController(title: title, message: message, preferredStyle: .alert) + + alertController.addAction(UIAlertAction(title: "OK", style: .default, handler: { _ in + let userInput = alertController.textFields?.first?.text + completion(true, userInput) + })) + + if showCancelButton { + alertController.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: { _ in + completion(false, nil) + })) + } + + alertController.addTextField(configurationHandler: nil) + + // Present the alert controller + // Make sure to present it from a view controller + // For example, if this code is inside a UIViewController, you can use `self.present(alertController, animated: true, completion: nil)` + } + + + // TODO: Add ability to click and clear both of these fields. private var phoneAuthSection: Section { - var tokenString = "No Token" - var credentialString = "No Credential" - if let token = AppManager.shared.auth().tokenManager.token { - let tokenType = token.type == .prod ? "Production" : "Sandbox" - tokenString = "token: \(token.string): type: \(tokenType)" + let items = [Item(title: APNSTokenString(), detailTitle: "APNs Token"), + Item(title: appCredentialString(), detailTitle: "App Credential")] + return Section(headerDescription: "Phone Auth - TODO toggle off", items: items) + } + + func APNSTokenString() -> String { + guard let token = AppManager.shared.auth().tokenManager.token else { + return "No APNs token" + } + + let truncatedToken = truncatedString(string: token.string, length: 19) + let tokenType = token.type == .prod ? "P" : "S" + return "\(truncatedToken)(\(tokenType))" + } + + func clearAPNSToken() { + guard let token = AppManager.shared.auth().tokenManager.token else { + return + } + + let tokenType = token.type == .prod ? "Production" : "Sandbox" + let message = "token: \(token.string)\ntype: \(tokenType)" + + self.showPromptWithTitle("Clear APNs Token?", message: message, showCancelButton: true) { (userPressedOK, userInput) in + if userPressedOK { + AppManager.shared.auth().tokenManager.token = nil + } } + } + + func appCredentialString() -> String { if let credential = AppManager.shared.auth().appCredentialManager.credential { - // TODO: Maybe use truncatedString like ObjC sample - credentialString = "\(credential.receipt)/\(credential.secret ?? "nil")" + let truncatedReceipt = truncatedString(string: credential.receipt, length: 13) + let truncatedSecret = truncatedString(string: credential.secret ?? "", length: 13) + return "\(truncatedReceipt)/\(truncatedSecret)" + } else { + return "No App Credential" } - let items = [Item(title: tokenString, detailTitle: "APNs Token"), - Item(title: credentialString, detailTitle: "App Credential")] - return Section(headerDescription: "Phone Auth - TODO toggle off", items: items) } + + + func clearAppCredential() { + if let credential = AppManager.shared.auth().appCredentialManager.credential { + let message = "receipt: \(credential.receipt)\nsecret: \(credential.secret)" + + showPromptWithTitle("Clear App Credential?", message: message, showCancelButton: true) { (userPressedOK, _) in + if userPressedOK { + AppManager.shared.auth().appCredentialManager.clearCredential() + } + } + } + } + private var languageSection: Section { let languageCode = AppManager.shared.auth().languageCode From c594c19fad850e3f1be493cac2798a166b6acb1c Mon Sep 17 00:00:00 2001 From: Pragati Date: Mon, 29 Jan 2024 15:38:38 +0530 Subject: [PATCH 02/34] undo SwiftApplication.plist changes --- .../SampleSwift/AuthenticationExample/SwiftApplication.plist | 2 -- 1 file changed, 2 deletions(-) diff --git a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/SwiftApplication.plist b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/SwiftApplication.plist index cdbcd12729a..339bc64e88f 100644 --- a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/SwiftApplication.plist +++ b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/SwiftApplication.plist @@ -24,8 +24,6 @@ CFBundleURLName CFBundleURLSchemes - - com.googleusercontent.apps.585304629422-ab795evno6vsrj7i7o1a3gi6eo01508b From 354a6ef27342726cdbc6d57ad3ad51cee72ca43f Mon Sep 17 00:00:00 2001 From: Pragati Date: Mon, 29 Jan 2024 18:11:38 +0530 Subject: [PATCH 03/34] undo SwiftApplication.plist changes --- .../SampleSwift/AuthenticationExample/SwiftApplication.plist | 1 - 1 file changed, 1 deletion(-) diff --git a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/SwiftApplication.plist b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/SwiftApplication.plist index 339bc64e88f..633b311e4b7 100644 --- a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/SwiftApplication.plist +++ b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/SwiftApplication.plist @@ -24,7 +24,6 @@ CFBundleURLName CFBundleURLSchemes - CFBundleVersion From 3ab2ac81bc59891eae91b3a388e30231107750e1 Mon Sep 17 00:00:00 2001 From: pragatimodi <110490169+pragatimodi@users.noreply.github.com> Date: Mon, 29 Jan 2024 12:44:12 +0000 Subject: [PATCH 04/34] undo SwiftApplication.plist changes --- .../SampleSwift/AuthenticationExample/SwiftApplication.plist | 1 + 1 file changed, 1 insertion(+) diff --git a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/SwiftApplication.plist b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/SwiftApplication.plist index 633b311e4b7..50378fe58b0 100644 --- a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/SwiftApplication.plist +++ b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/SwiftApplication.plist @@ -24,6 +24,7 @@ CFBundleURLName CFBundleURLSchemes + CFBundleVersion From ae27388d6672403b3d8b27fe70a04384fe42e9e5 Mon Sep 17 00:00:00 2001 From: pragatimodi <110490169+pragatimodi@users.noreply.github.com> Date: Mon, 29 Jan 2024 13:02:58 +0000 Subject: [PATCH 05/34] clang formatting --- .../SettingsViewController.swift | 56 +++++++++---------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/SettingsViewController.swift b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/SettingsViewController.swift index a6e1421aa38..3c90b23ea4c 100644 --- a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/SettingsViewController.swift +++ b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/SettingsViewController.swift @@ -186,73 +186,74 @@ extension AuthSettings: DataSourceProvidable { detailTitle: "Current Access Group")] return Section(headerDescription: "Keychain Access Groups", items: items) } - + func truncatedString(string: String, length: Int) -> String { guard string.count > length else { return string } - + let half = (length - 3) / 2 let startIndex = string.startIndex - let midIndex = string.index(startIndex, offsetBy: half) // Ensure correct mid index + let midIndex = string.index(startIndex, offsetBy: half) // Ensure correct mid index let endIndex = string.index(startIndex, offsetBy: string.count - half) - - return "\(string[startIndex.. Void) { + func showPromptWithTitle(_ title: String, message: String, showCancelButton: Bool, + completion: @escaping (Bool, String?) -> Void) { let alertController = UIAlertController(title: title, message: message, preferredStyle: .alert) - + alertController.addAction(UIAlertAction(title: "OK", style: .default, handler: { _ in let userInput = alertController.textFields?.first?.text completion(true, userInput) })) - + if showCancelButton { alertController.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: { _ in completion(false, nil) })) } - + alertController.addTextField(configurationHandler: nil) - - // Present the alert controller - // Make sure to present it from a view controller - // For example, if this code is inside a UIViewController, you can use `self.present(alertController, animated: true, completion: nil)` + + // Present the alert controller + // Make sure to present it from a view controller + // For example, if this code is inside a UIViewController, you can use + // `self.present(alertController, animated: true, completion: nil)` } - - - + // TODO: Add ability to click and clear both of these fields. private var phoneAuthSection: Section { let items = [Item(title: APNSTokenString(), detailTitle: "APNs Token"), Item(title: appCredentialString(), detailTitle: "App Credential")] return Section(headerDescription: "Phone Auth - TODO toggle off", items: items) } - + func APNSTokenString() -> String { guard let token = AppManager.shared.auth().tokenManager.token else { return "No APNs token" } - + let truncatedToken = truncatedString(string: token.string, length: 19) let tokenType = token.type == .prod ? "P" : "S" return "\(truncatedToken)(\(tokenType))" } - + func clearAPNSToken() { guard let token = AppManager.shared.auth().tokenManager.token else { return } - + let tokenType = token.type == .prod ? "Production" : "Sandbox" let message = "token: \(token.string)\ntype: \(tokenType)" - - self.showPromptWithTitle("Clear APNs Token?", message: message, showCancelButton: true) { (userPressedOK, userInput) in + + showPromptWithTitle("Clear APNs Token?", message: message, + showCancelButton: true) { userPressedOK, userInput in if userPressedOK { AppManager.shared.auth().tokenManager.token = nil } } } - + func appCredentialString() -> String { if let credential = AppManager.shared.auth().appCredentialManager.credential { let truncatedReceipt = truncatedString(string: credential.receipt, length: 13) @@ -262,13 +263,13 @@ extension AuthSettings: DataSourceProvidable { return "No App Credential" } } - - + func clearAppCredential() { if let credential = AppManager.shared.auth().appCredentialManager.credential { let message = "receipt: \(credential.receipt)\nsecret: \(credential.secret)" - - showPromptWithTitle("Clear App Credential?", message: message, showCancelButton: true) { (userPressedOK, _) in + + showPromptWithTitle("Clear App Credential?", message: message, + showCancelButton: true) { userPressedOK, _ in if userPressedOK { AppManager.shared.auth().appCredentialManager.clearCredential() } @@ -276,7 +277,6 @@ extension AuthSettings: DataSourceProvidable { } } - private var languageSection: Section { let languageCode = AppManager.shared.auth().languageCode let items = [Item(title: languageCode ?? "[none]", detailTitle: "Auth Language"), From e057b178543a9be8420eb8aa21ba4b42a3c4c223 Mon Sep 17 00:00:00 2001 From: Pragati Date: Tue, 6 Feb 2024 16:39:17 +0530 Subject: [PATCH 06/34] game center auth login --- .../ViewControllers/AuthViewController.swift | 40 +++++++++++++ .../SettingsViewController.swift | 56 +++++++++---------- 2 files changed, 68 insertions(+), 28 deletions(-) diff --git a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/AuthViewController.swift b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/AuthViewController.swift index ae7e36cb8b5..9baccf8b202 100644 --- a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/AuthViewController.swift +++ b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/AuthViewController.swift @@ -21,6 +21,7 @@ import FirebaseCore // [START google_import] import GoogleSignIn import UIKit +import GameKit // For Sign in with Apple import AuthenticationServices @@ -68,6 +69,9 @@ class AuthViewController: UIViewController, DataSourceProviderDelegate { case .twitter, .microsoft, .gitHub, .yahoo: performOAuthLoginFlow(for: provider) + + case .gameCenter: + performSignInWithGameCenter() case .emailPassword: performDemoEmailPasswordLoginFlow() @@ -207,6 +211,42 @@ class AuthViewController: UIViewController, DataSourceProviderDelegate { self.signin(with: credential) } } + + private func performSignInWithGameCenter() { + // Step 1: System Game Center Login + GKLocalPlayer.local.authenticateHandler = { viewController, error in + if let error = error { + // Handle Game Center login error + print("Error logging into Game Center: \(error.localizedDescription)") + } else if let authViewController = viewController { + // Present Game Center login UI if needed + self.present(authViewController, animated: true) + } else { + // Game Center login successful, proceed to Firebase + self.linkGameCenterToFirebase() + } + } + } + + // Step 2: Link to Firebase + private func linkGameCenterToFirebase() { + GameCenterAuthProvider.getCredential { credential, error in + if let error = error { + // Handle Firebase credential retrieval error + print("Error getting Game Center credential: \(error.localizedDescription)") + } else if let credential = credential { + Auth.auth().signIn(with: credential) { authResult, error in + if let error = error { + // Handle Firebase sign-in error + print("Error signing into Firebase with Game Center: \(error.localizedDescription)") + } else { + // Firebase sign-in successful + print("Successfully linked Game Center to Firebase") + } + } + } + } + } private func performDemoEmailPasswordLoginFlow() { let loginController = LoginController() diff --git a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/SettingsViewController.swift b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/SettingsViewController.swift index a6e1421aa38..3c90b23ea4c 100644 --- a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/SettingsViewController.swift +++ b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/SettingsViewController.swift @@ -186,73 +186,74 @@ extension AuthSettings: DataSourceProvidable { detailTitle: "Current Access Group")] return Section(headerDescription: "Keychain Access Groups", items: items) } - + func truncatedString(string: String, length: Int) -> String { guard string.count > length else { return string } - + let half = (length - 3) / 2 let startIndex = string.startIndex - let midIndex = string.index(startIndex, offsetBy: half) // Ensure correct mid index + let midIndex = string.index(startIndex, offsetBy: half) // Ensure correct mid index let endIndex = string.index(startIndex, offsetBy: string.count - half) - - return "\(string[startIndex.. Void) { + func showPromptWithTitle(_ title: String, message: String, showCancelButton: Bool, + completion: @escaping (Bool, String?) -> Void) { let alertController = UIAlertController(title: title, message: message, preferredStyle: .alert) - + alertController.addAction(UIAlertAction(title: "OK", style: .default, handler: { _ in let userInput = alertController.textFields?.first?.text completion(true, userInput) })) - + if showCancelButton { alertController.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: { _ in completion(false, nil) })) } - + alertController.addTextField(configurationHandler: nil) - - // Present the alert controller - // Make sure to present it from a view controller - // For example, if this code is inside a UIViewController, you can use `self.present(alertController, animated: true, completion: nil)` + + // Present the alert controller + // Make sure to present it from a view controller + // For example, if this code is inside a UIViewController, you can use + // `self.present(alertController, animated: true, completion: nil)` } - - - + // TODO: Add ability to click and clear both of these fields. private var phoneAuthSection: Section { let items = [Item(title: APNSTokenString(), detailTitle: "APNs Token"), Item(title: appCredentialString(), detailTitle: "App Credential")] return Section(headerDescription: "Phone Auth - TODO toggle off", items: items) } - + func APNSTokenString() -> String { guard let token = AppManager.shared.auth().tokenManager.token else { return "No APNs token" } - + let truncatedToken = truncatedString(string: token.string, length: 19) let tokenType = token.type == .prod ? "P" : "S" return "\(truncatedToken)(\(tokenType))" } - + func clearAPNSToken() { guard let token = AppManager.shared.auth().tokenManager.token else { return } - + let tokenType = token.type == .prod ? "Production" : "Sandbox" let message = "token: \(token.string)\ntype: \(tokenType)" - - self.showPromptWithTitle("Clear APNs Token?", message: message, showCancelButton: true) { (userPressedOK, userInput) in + + showPromptWithTitle("Clear APNs Token?", message: message, + showCancelButton: true) { userPressedOK, userInput in if userPressedOK { AppManager.shared.auth().tokenManager.token = nil } } } - + func appCredentialString() -> String { if let credential = AppManager.shared.auth().appCredentialManager.credential { let truncatedReceipt = truncatedString(string: credential.receipt, length: 13) @@ -262,13 +263,13 @@ extension AuthSettings: DataSourceProvidable { return "No App Credential" } } - - + func clearAppCredential() { if let credential = AppManager.shared.auth().appCredentialManager.credential { let message = "receipt: \(credential.receipt)\nsecret: \(credential.secret)" - - showPromptWithTitle("Clear App Credential?", message: message, showCancelButton: true) { (userPressedOK, _) in + + showPromptWithTitle("Clear App Credential?", message: message, + showCancelButton: true) { userPressedOK, _ in if userPressedOK { AppManager.shared.auth().appCredentialManager.clearCredential() } @@ -276,7 +277,6 @@ extension AuthSettings: DataSourceProvidable { } } - private var languageSection: Section { let languageCode = AppManager.shared.auth().languageCode let items = [Item(title: languageCode ?? "[none]", detailTitle: "Auth Language"), From b38a9882e46a3098814303170652e286af07b403 Mon Sep 17 00:00:00 2001 From: Pragati Date: Tue, 6 Feb 2024 16:43:34 +0530 Subject: [PATCH 07/34] lint --- .../ViewControllers/AuthViewController.swift | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/AuthViewController.swift b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/AuthViewController.swift index 9baccf8b202..5054a6d974c 100644 --- a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/AuthViewController.swift +++ b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/AuthViewController.swift @@ -17,11 +17,11 @@ import FBSDKLoginKit import FirebaseAuth // [START auth_import] import FirebaseCore +import GameKit // For Sign in with Google // [START google_import] import GoogleSignIn import UIKit -import GameKit // For Sign in with Apple import AuthenticationServices @@ -69,7 +69,7 @@ class AuthViewController: UIViewController, DataSourceProviderDelegate { case .twitter, .microsoft, .gitHub, .yahoo: performOAuthLoginFlow(for: provider) - + case .gameCenter: performSignInWithGameCenter() @@ -211,36 +211,36 @@ class AuthViewController: UIViewController, DataSourceProviderDelegate { self.signin(with: credential) } } - + private func performSignInWithGameCenter() { - // Step 1: System Game Center Login + // Step 1: System Game Center Login GKLocalPlayer.local.authenticateHandler = { viewController, error in if let error = error { - // Handle Game Center login error + // Handle Game Center login error print("Error logging into Game Center: \(error.localizedDescription)") } else if let authViewController = viewController { - // Present Game Center login UI if needed + // Present Game Center login UI if needed self.present(authViewController, animated: true) } else { - // Game Center login successful, proceed to Firebase + // Game Center login successful, proceed to Firebase self.linkGameCenterToFirebase() } } } - - // Step 2: Link to Firebase + + // Step 2: Link to Firebase private func linkGameCenterToFirebase() { GameCenterAuthProvider.getCredential { credential, error in if let error = error { - // Handle Firebase credential retrieval error + // Handle Firebase credential retrieval error print("Error getting Game Center credential: \(error.localizedDescription)") } else if let credential = credential { Auth.auth().signIn(with: credential) { authResult, error in if let error = error { - // Handle Firebase sign-in error + // Handle Firebase sign-in error print("Error signing into Firebase with Game Center: \(error.localizedDescription)") } else { - // Firebase sign-in successful + // Firebase sign-in successful print("Successfully linked Game Center to Firebase") } } From c4d89433e4e7ed135e9bb7102f6853e819e61384 Mon Sep 17 00:00:00 2001 From: Pragati Date: Tue, 6 Feb 2024 20:00:25 +0530 Subject: [PATCH 08/34] correct method name --- .../Auth Provider Icons/Contents.json | 6 ++--- .../Game Center.imageset/Contents.json | 21 ++++++++++++++++++ .../Game Center.imageset/game-center icon.png | Bin 0 -> 27086 bytes .../Assets.xcassets/Contents.json | 9 +++++--- .../ViewControllers/AuthViewController.swift | 4 ++-- 5 files changed, 32 insertions(+), 8 deletions(-) create mode 100644 FirebaseAuth/Tests/SampleSwift/AuthenticationExample/Assets.xcassets/Auth Provider Icons/Game Center.imageset/Contents.json create mode 100644 FirebaseAuth/Tests/SampleSwift/AuthenticationExample/Assets.xcassets/Auth Provider Icons/Game Center.imageset/game-center icon.png diff --git a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/Assets.xcassets/Auth Provider Icons/Contents.json b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/Assets.xcassets/Auth Provider Icons/Contents.json index da4a164c918..73c00596a7f 100644 --- a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/Assets.xcassets/Auth Provider Icons/Contents.json +++ b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/Assets.xcassets/Auth Provider Icons/Contents.json @@ -1,6 +1,6 @@ { "info" : { - "version" : 1, - "author" : "xcode" + "author" : "xcode", + "version" : 1 } -} \ No newline at end of file +} diff --git a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/Assets.xcassets/Auth Provider Icons/Game Center.imageset/Contents.json b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/Assets.xcassets/Auth Provider Icons/Game Center.imageset/Contents.json new file mode 100644 index 00000000000..ca69c269602 --- /dev/null +++ b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/Assets.xcassets/Auth Provider Icons/Game Center.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "game-center icon.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/Assets.xcassets/Auth Provider Icons/Game Center.imageset/game-center icon.png b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/Assets.xcassets/Auth Provider Icons/Game Center.imageset/game-center icon.png new file mode 100644 index 0000000000000000000000000000000000000000..4c96fc2e25cc5b3d40de4c06935a9269d28aefdc GIT binary patch literal 27086 zcmaI6RZtwx6D_>3I4tfC2@>2P!2<-hAMO_1-C5iH%}siRk}X(vwGbaf7q|`r_f2LW#pKCG_ymm{L5y;He4OR`6+w zo@&6u7`FlPLl3?7(d;~bAL49nYGQ5(ciH}ZAI|cQCv-vWyB9&vBb;hK9rAQH()|sW>Rn^$?|?t)71>#;$|?G< zCT+<-ic%BVNWBe3Eh9vBaCB@?sD}T9SW=?jr<@m9?(}H0AfEJuLyrn>dh& zF3eZSLH5gQ>Z>YI_zo1jR{_u?lAtvu9TL^-+aNktK@$P@NHfL}lz{CUyg_4gSvV*UX zl`}ddY+6d0_G88c-RtrF*8vk{*`$B&)dKjse3LQXRdQoKVp86}5^l*Vi&}3nZoJxc z(k>wo!)o#qHeU9R`0lMRyfrQwyZkq1yJ#mdFYDw4tO>U_DPP)5wZnTKqC;WzfGd~@ zyprv@Di+wmyDlfihPPLJ8Y2i0rtGLOF0Of!T)sjrnPFy*tWm{Y3^4hwCK*ip-*+|Y z3GlKwZZ=asuo=a5Ng=NaT)T(VVPekk{^V;N%%m3+`Tk?Tn@IZymDQX2X+|khJ;@NE z_zOAKaW}R~vSO6{Y3zLl)xU5`d=zG_S-NR!7vEX=rcB6SG}ulZ2@En$t_m#yG)m(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aseAuth/Tests/SampleSwift/AuthenticationExample/Assets.xcassets/Contents.json index da4a164c918..7f73912a483 100644 --- a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/Assets.xcassets/Contents.json +++ b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/Assets.xcassets/Contents.json @@ -1,6 +1,9 @@ { "info" : { - "version" : 1, - "author" : "xcode" + "author" : "xcode", + "version" : 1 + }, + "properties" : { + "compression-type" : "automatic" } -} \ No newline at end of file +} diff --git a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/AuthViewController.swift b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/AuthViewController.swift index 5054a6d974c..e8fb2dd546e 100644 --- a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/AuthViewController.swift +++ b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/AuthViewController.swift @@ -71,7 +71,7 @@ class AuthViewController: UIViewController, DataSourceProviderDelegate { performOAuthLoginFlow(for: provider) case .gameCenter: - performSignInWithGameCenter() + performGameCenterLoginFlow() case .emailPassword: performDemoEmailPasswordLoginFlow() @@ -212,7 +212,7 @@ class AuthViewController: UIViewController, DataSourceProviderDelegate { } } - private func performSignInWithGameCenter() { + private func performGameCenterLoginFlow() { // Step 1: System Game Center Login GKLocalPlayer.local.authenticateHandler = { viewController, error in if let error = error { From 121c65604086517de4d8bdceaf793243e3a401cf Mon Sep 17 00:00:00 2001 From: pragatimodi <110490169+pragatimodi@users.noreply.github.com> Date: Tue, 6 Feb 2024 14:38:18 +0000 Subject: [PATCH 09/34] add game center icon --- .../Auth Provider Icons/Contents.json | 6 ++--- .../Assets.xcassets/Contents.json | 9 +++---- .../SettingsViewController.swift | 24 +++++++++---------- 3 files changed, 18 insertions(+), 21 deletions(-) diff --git a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/Assets.xcassets/Auth Provider Icons/Contents.json b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/Assets.xcassets/Auth Provider Icons/Contents.json index 73c00596a7f..da4a164c918 100644 --- a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/Assets.xcassets/Auth Provider Icons/Contents.json +++ b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/Assets.xcassets/Auth Provider Icons/Contents.json @@ -1,6 +1,6 @@ { "info" : { - "author" : "xcode", - "version" : 1 + "version" : 1, + "author" : "xcode" } -} +} \ No newline at end of file diff --git a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/Assets.xcassets/Contents.json b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/Assets.xcassets/Contents.json index 7f73912a483..da4a164c918 100644 --- a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/Assets.xcassets/Contents.json +++ b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/Assets.xcassets/Contents.json @@ -1,9 +1,6 @@ { "info" : { - "author" : "xcode", - "version" : 1 - }, - "properties" : { - "compression-type" : "automatic" + "version" : 1, + "author" : "xcode" } -} +} \ No newline at end of file diff --git a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/SettingsViewController.swift b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/SettingsViewController.swift index 3c90b23ea4c..677a5748b2c 100644 --- a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/SettingsViewController.swift +++ b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/SettingsViewController.swift @@ -192,14 +192,13 @@ extension AuthSettings: DataSourceProvidable { let half = (length - 3) / 2 let startIndex = string.startIndex - let midIndex = string.index(startIndex, offsetBy: half) // Ensure correct mid index + let midIndex = string.index(startIndex, offsetBy: half) // Ensure correct mid index let endIndex = string.index(startIndex, offsetBy: string.count - half) - return "\(string[startIndex ..< midIndex])...\(string[endIndex...])" + return "\(string[startIndex.. Void) { + func showPromptWithTitle(_ title: String, message: String, showCancelButton: Bool, completion: @escaping (Bool, String?) -> Void) { let alertController = UIAlertController(title: title, message: message, preferredStyle: .alert) alertController.addAction(UIAlertAction(title: "OK", style: .default, handler: { _ in @@ -215,12 +214,13 @@ extension AuthSettings: DataSourceProvidable { alertController.addTextField(configurationHandler: nil) - // Present the alert controller - // Make sure to present it from a view controller - // For example, if this code is inside a UIViewController, you can use - // `self.present(alertController, animated: true, completion: nil)` + // Present the alert controller + // Make sure to present it from a view controller + // For example, if this code is inside a UIViewController, you can use `self.present(alertController, animated: true, completion: nil)` } + + // TODO: Add ability to click and clear both of these fields. private var phoneAuthSection: Section { let items = [Item(title: APNSTokenString(), detailTitle: "APNs Token"), @@ -246,8 +246,7 @@ extension AuthSettings: DataSourceProvidable { let tokenType = token.type == .prod ? "Production" : "Sandbox" let message = "token: \(token.string)\ntype: \(tokenType)" - showPromptWithTitle("Clear APNs Token?", message: message, - showCancelButton: true) { userPressedOK, userInput in + self.showPromptWithTitle("Clear APNs Token?", message: message, showCancelButton: true) { (userPressedOK, userInput) in if userPressedOK { AppManager.shared.auth().tokenManager.token = nil } @@ -264,12 +263,12 @@ extension AuthSettings: DataSourceProvidable { } } + func clearAppCredential() { if let credential = AppManager.shared.auth().appCredentialManager.credential { let message = "receipt: \(credential.receipt)\nsecret: \(credential.secret)" - showPromptWithTitle("Clear App Credential?", message: message, - showCancelButton: true) { userPressedOK, _ in + showPromptWithTitle("Clear App Credential?", message: message, showCancelButton: true) { (userPressedOK, _) in if userPressedOK { AppManager.shared.auth().appCredentialManager.clearCredential() } @@ -277,6 +276,7 @@ extension AuthSettings: DataSourceProvidable { } } + private var languageSection: Section { let languageCode = AppManager.shared.auth().languageCode let items = [Item(title: languageCode ?? "[none]", detailTitle: "Auth Language"), From e6b298f2bd11fe28b1110b4d54364b1ac697efc9 Mon Sep 17 00:00:00 2001 From: Pragati Date: Tue, 6 Feb 2024 20:22:55 +0530 Subject: [PATCH 10/34] add game center account linking --- .../AccountLinkingViewController.swift | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/AccountLinkingViewController.swift b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/AccountLinkingViewController.swift index 08bfba3c42d..8752e8b0e6b 100644 --- a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/AccountLinkingViewController.swift +++ b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/AccountLinkingViewController.swift @@ -14,6 +14,7 @@ import FirebaseAuth import FirebaseCore +import GameKit import UIKit // For Account Linking with Sign in with Google. @@ -93,6 +94,9 @@ class AccountLinkingViewController: UIViewController, DataSourceProviderDelegate case .twitter, .microsoft, .gitHub, .yahoo: performOAuthAccountLink(for: provider) + case .gameCenter: + performGameCenterAccountLink() + case .emailPassword: performEmailPasswordAccountLink() @@ -233,6 +237,42 @@ class AccountLinkingViewController: UIViewController, DataSourceProviderDelegate } } + private func performGameCenterAccountLink() { + // Step 1: Ensure Game Center Authentication + guard GKLocalPlayer.local.isAuthenticated else { + print("Error: Player not authenticated with Game Center.") + // TODO: Handle the 'not authenticated' scenario (e.g., prompt the user) + return + } + + // Step 2: Get Game Center Credential for Linking + GameCenterAuthProvider.getCredential { credential, error in + if let error = error { + print("Error getting Game Center credential: \(error.localizedDescription)") + // TODO: Handle the credential error + return + } + + guard let credential = credential else { + print("Error: Missing Game Center credential") + // TODO: Handle the missing credential case + return + } + + // Step 3: Link Credential with Current Firebase User + Auth.auth().currentUser?.link(with: credential) { authResult, error in + if let error = error { + print("Error linking Game Center to Firebase: \(error.localizedDescription)") + // TODO: Handle the linking error + return + } + + // Linking successful + print("Successfully linked Game Center to Firebase") + } + } + } + // MARK: - Email & Password Login Account Linking 🔥 private func performEmailPasswordAccountLink() { From 417168babf5b4ea6dbf928b5d4bfa34369208163 Mon Sep 17 00:00:00 2001 From: Pragati Date: Tue, 6 Feb 2024 20:25:42 +0530 Subject: [PATCH 11/34] lint --- .../SettingsViewController.swift | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/SettingsViewController.swift b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/SettingsViewController.swift index 677a5748b2c..3c90b23ea4c 100644 --- a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/SettingsViewController.swift +++ b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/SettingsViewController.swift @@ -192,13 +192,14 @@ extension AuthSettings: DataSourceProvidable { let half = (length - 3) / 2 let startIndex = string.startIndex - let midIndex = string.index(startIndex, offsetBy: half) // Ensure correct mid index + let midIndex = string.index(startIndex, offsetBy: half) // Ensure correct mid index let endIndex = string.index(startIndex, offsetBy: string.count - half) - return "\(string[startIndex.. Void) { + func showPromptWithTitle(_ title: String, message: String, showCancelButton: Bool, + completion: @escaping (Bool, String?) -> Void) { let alertController = UIAlertController(title: title, message: message, preferredStyle: .alert) alertController.addAction(UIAlertAction(title: "OK", style: .default, handler: { _ in @@ -214,13 +215,12 @@ extension AuthSettings: DataSourceProvidable { alertController.addTextField(configurationHandler: nil) - // Present the alert controller - // Make sure to present it from a view controller - // For example, if this code is inside a UIViewController, you can use `self.present(alertController, animated: true, completion: nil)` + // Present the alert controller + // Make sure to present it from a view controller + // For example, if this code is inside a UIViewController, you can use + // `self.present(alertController, animated: true, completion: nil)` } - - // TODO: Add ability to click and clear both of these fields. private var phoneAuthSection: Section { let items = [Item(title: APNSTokenString(), detailTitle: "APNs Token"), @@ -246,7 +246,8 @@ extension AuthSettings: DataSourceProvidable { let tokenType = token.type == .prod ? "Production" : "Sandbox" let message = "token: \(token.string)\ntype: \(tokenType)" - self.showPromptWithTitle("Clear APNs Token?", message: message, showCancelButton: true) { (userPressedOK, userInput) in + showPromptWithTitle("Clear APNs Token?", message: message, + showCancelButton: true) { userPressedOK, userInput in if userPressedOK { AppManager.shared.auth().tokenManager.token = nil } @@ -263,12 +264,12 @@ extension AuthSettings: DataSourceProvidable { } } - func clearAppCredential() { if let credential = AppManager.shared.auth().appCredentialManager.credential { let message = "receipt: \(credential.receipt)\nsecret: \(credential.secret)" - showPromptWithTitle("Clear App Credential?", message: message, showCancelButton: true) { (userPressedOK, _) in + showPromptWithTitle("Clear App Credential?", message: message, + showCancelButton: true) { userPressedOK, _ in if userPressedOK { AppManager.shared.auth().appCredentialManager.clearCredential() } @@ -276,7 +277,6 @@ extension AuthSettings: DataSourceProvidable { } } - private var languageSection: Section { let languageCode = AppManager.shared.auth().languageCode let items = [Item(title: languageCode ?? "[none]", detailTitle: "Auth Language"), From 660551cde8ce3742483cbc45a1105ac68c0495ef Mon Sep 17 00:00:00 2001 From: Pragati Date: Fri, 23 Feb 2024 11:46:20 -0800 Subject: [PATCH 12/34] add app-section --- .../Models/AuthMenu.swift | 82 +++++++-- .../Utility/Extensions.swift | 9 + .../ViewControllers/AuthViewController.swift | 160 +++++++++++++++++- 3 files changed, 238 insertions(+), 13 deletions(-) diff --git a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/Models/AuthMenu.swift b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/Models/AuthMenu.swift index b0abf158c96..471d8800d63 100644 --- a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/Models/AuthMenu.swift +++ b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/Models/AuthMenu.swift @@ -24,6 +24,7 @@ enum AuthMenu: String { case gitHub = "github.com" case yahoo = "yahoo.com" case facebook = "facebook.com" + case gameCenter = "gc.apple.com" case emailPassword = "password" case passwordless = "emailLink" case phoneNumber = "phone" @@ -31,11 +32,19 @@ enum AuthMenu: String { case custom case initRecaptcha case customAuthDomain - - /// More intuitively named getter for `rawValue`. + case getToken + case getTokenForceRefresh + case addAuthStateChangeListener + case removeLastAuthStateChangeListener + case addIdTokenChangeListener + case removeLastIdTokenChangeListener + case verifyClient + case deleteApp + + // More intuitively named getter for `rawValue`. var id: String { rawValue } - - /// The UI friendly name of the `AuthMenu`. Used for display. + + // The UI friendly name of the `AuthMenu`. Used for display. var name: String { switch self { case .settings: @@ -54,6 +63,8 @@ enum AuthMenu: String { return "Yahoo" case .facebook: return "Facebook" + case .gameCenter: + return "Game Center" case .emailPassword: return "Email & Password Login" case .passwordless: @@ -68,11 +79,27 @@ enum AuthMenu: String { return "Initialize reCAPTCHA Enterprise" case .customAuthDomain: return "Set Custom Auth Domain" + case .getToken: + return "Get Token" + case .getTokenForceRefresh: + return "Get Token Force Refresh" + case .addAuthStateChangeListener: + return "Add Auth State Change Listener" + case .removeLastAuthStateChangeListener: + return "Remove Last Auth State Change Listener" + case .addIdTokenChangeListener: + return "Add ID Token Change Listener" + case .removeLastIdTokenChangeListener: + return "Remove Last ID Token Change Listener" + case .verifyClient: + return "Verify Client" + case .deleteApp: + return "Delete App" } } - - /// Failable initializer to create an `AuthMenu` from it's corresponding `name` value. - /// - Parameter rawValue: String value representing `AuthMenu`'s name or type. + + // Failable initializer to create an `AuthMenu` from its corresponding `name` value. + // - Parameter rawValue: String value representing `AuthMenu`'s name or type. init?(rawValue: String) { switch rawValue { case "Settings": @@ -91,6 +118,8 @@ enum AuthMenu: String { self = .yahoo case "Facebook": self = .facebook + case "Game Center": + self = .gameCenter case "Email & Password Login": self = .emailPassword case "Email Link/Passwordless": @@ -105,16 +134,34 @@ enum AuthMenu: String { self = .initRecaptcha case "Set Custom Auth Domain": self = .customAuthDomain - default: return nil + case "Get Token": + self = .getToken + case "Get Token Force Refresh": + self = .getTokenForceRefresh + case "Add Auth State Change Listener": + self = .addAuthStateChangeListener + case "Remove Last Auth State Change Listener": + self = .removeLastAuthStateChangeListener + case "Add ID Token Change Listener": + self = .addIdTokenChangeListener + case "Remove Last ID Token Change Listener": + self = .removeLastIdTokenChangeListener + case "Verify Client": + self = .verifyClient + case "Delete App": + self = .deleteApp + default: + return nil } } } + // MARK: DataSourceProvidable extension AuthMenu: DataSourceProvidable { private static var providers: [AuthMenu] { - [.google, .apple, .twitter, .microsoft, .gitHub, .yahoo, .facebook] + [.google, .apple, .twitter, .microsoft, .gitHub, .yahoo, .facebook, .gameCenter] } static var settingsSection: Section { @@ -166,10 +213,25 @@ extension AuthMenu: DataSourceProvidable { let item = Item(title: customAuthDomain.name, hasNestedContent: false, image: image) return Section(headerDescription: header, items: [item]) } + + static var appSection: Section { + let header = "APP" + let items: [Item] = [ + Item(title: getToken.name), + Item(title: getTokenForceRefresh.name), + Item(title: addAuthStateChangeListener.name), + Item(title: removeLastAuthStateChangeListener.name), + Item(title: addIdTokenChangeListener.name), + Item(title: removeLastIdTokenChangeListener.name), + Item(title: verifyClient.name), + Item(title: deleteApp.name) + ] + return Section(headerDescription: header, items: items) + } static var sections: [Section] { [settingsSection, providerSection, emailPasswordSection, otherSection, recaptchaSection, - customAuthDomainSection] + customAuthDomainSection, appSection] } static var authLinkSections: [Section] { diff --git a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/Utility/Extensions.swift b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/Utility/Extensions.swift index 4f57b055574..a74e4fa368e 100644 --- a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/Utility/Extensions.swift +++ b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/Utility/Extensions.swift @@ -66,6 +66,15 @@ extension User: DataSourceProvidable { // MARK: - UIKit Extensions public extension UIViewController { + func displayInfo(title: String, message: String, style: UIAlertController.Style) { + let alert = UIAlertController(title: title, message: message, preferredStyle: style) + alert.addAction(UIAlertAction(title: "OK", style: .default, handler: nil)) + + DispatchQueue.main.async { // Ensure UI updates on the main thread + self.present(alert, animated: true, completion: nil) + } + } + func displayError(_ error: Error?, from function: StaticString = #function) { guard let error = error else { return } print("ⓧ Error in \(function): \(error.localizedDescription)") diff --git a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/AuthViewController.swift b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/AuthViewController.swift index e8fb2dd546e..74cb08181bf 100644 --- a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/AuthViewController.swift +++ b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/AuthViewController.swift @@ -31,6 +31,8 @@ private let kFacebookAppID = "ENTER APP ID HERE" class AuthViewController: UIViewController, DataSourceProviderDelegate { var dataSourceProvider: DataSourceProvider! + var authStateDidChangeListeners: [AuthStateDidChangeListenerHandle] = [] + var IDTokenDidChangeListeners: [IDTokenDidChangeListenerHandle] = [] override func loadView() { view = UITableView(frame: .zero, style: .insetGrouped) @@ -93,6 +95,32 @@ class AuthViewController: UIViewController, DataSourceProviderDelegate { case .customAuthDomain: performCustomAuthDomainFlow() + + case .getToken: + getUserTokenResult(force: false) + + case .getTokenForceRefresh: + getUserTokenResult(force: true) + + case .addAuthStateChangeListener: + addAuthStateListener() + + case .removeLastAuthStateChangeListener: + removeAuthStateListener() + + case .addIdTokenChangeListener: + addIDTokenListener() + + case .removeLastIdTokenChangeListener: + removeIDTokenListener() + + case .verifyClient: + //verifyClient() + return + case .deleteApp: + deleteApp() + + } } @@ -196,7 +224,7 @@ class AuthViewController: UIViewController, DataSourceProviderDelegate { guard error == nil else { return self.displayError(error) } guard let accessToken = AccessToken.current else { return } let credential = FacebookAuthProvider.credential(withAccessToken: accessToken.tokenString) - self.signin(with: credential) + self.signIn(with: credential) } } @@ -208,7 +236,7 @@ class AuthViewController: UIViewController, DataSourceProviderDelegate { oauthProvider.getCredentialWith(nil) { credential, error in guard error == nil else { return self.displayError(error) } guard let credential = credential else { return } - self.signin(with: credential) + self.signIn(with: credential) } } @@ -283,7 +311,7 @@ class AuthViewController: UIViewController, DataSourceProviderDelegate { navigationController?.present(navCustomAuthController, animated: true) } - private func signin(with credential: AuthCredential) { + private func appleRawNoncesignin(with credential: AuthCredential) { AppManager.shared.auth().signIn(with: credential) { result, error in guard error == nil else { return self.displayError(error) } self.transitionToUserViewController() @@ -313,6 +341,132 @@ class AuthViewController: UIViewController, DataSourceProviderDelegate { prompt.addAction(okAction) present(prompt, animated: true) } + + private func getUserTokenResult(force: Bool) { + guard let currentUser = Auth.auth().currentUser else { + print("Error: No user logged in") + return + } + + currentUser.getIDTokenResult(forcingRefresh: force, completion: { tokenResult, error in + if let error = error { + print("Error: Error refreshing token") + return // Handle error case, returning early + } + + if let tokenResult = tokenResult, let claims = tokenResult.claims as? [String: Any] { + var message = "Token refresh succeeded\n\n" + for (key, value) in claims { + message += "\(key): \(value)\n" + } + self.displayInfo(title: "Info", message: message, style: .alert) + } else { + print("Error: Unable to access claims.") + } + }) + } + + private func addAuthStateListener() { + weak var weakSelf = self + let index = authStateDidChangeListeners.count + print("Auth State Did Change Listener #\(index) was added.") + let handle = Auth.auth().addStateDidChangeListener { [weak weakSelf] (auth, user) in + guard weakSelf != nil else { return } + print("Auth State Did Change Listener #\(index) was invoked on user '\(user?.uid ?? "nil")'") + } + authStateDidChangeListeners.append(handle) + } + + private func removeAuthStateListener() { + guard !authStateDidChangeListeners.isEmpty else { + print("No remaining Auth State Did Change Listeners.") + return + } + let index = authStateDidChangeListeners.count - 1 + let handle = authStateDidChangeListeners.last! + Auth.auth().removeStateDidChangeListener(handle) + authStateDidChangeListeners.removeLast() + print("Auth State Did Change Listener #\(index) was removed.") + } + + private func addIDTokenListener() { + weak var weakSelf = self + let index = IDTokenDidChangeListeners.count + print("ID Token Did Change Listener #\(index) was added.") + let handle = Auth.auth().addIDTokenDidChangeListener { [weak weakSelf] (auth, user) in + guard weakSelf != nil else { return } + print("ID Token Did Change Listener #\(index) was invoked on user '\(user?.uid ?? "")'.") + } + IDTokenDidChangeListeners.append(handle) + } + + func removeIDTokenListener() { + guard !IDTokenDidChangeListeners.isEmpty else { + print("No remaining ID Token Did Change Listeners.") + return + } + let index = IDTokenDidChangeListeners.count - 1 + let handle = IDTokenDidChangeListeners.last! + Auth.auth().removeIDTokenDidChangeListener(handle) + IDTokenDidChangeListeners.removeLast() + print("ID Token Did Change Listener #\(index) was removed.") + } + +// func verifyClient() { +// AppManager.shared.auth().tokenManager.getTokenInternal { token, error in +// guard let token = token else { +// print("Verify iOS client failed.", error: error) +// return +// } +// +// let request = VerifyClientRequest{appToken: token.string, +// isSandbox: token.type == .sandbox, +// requestConfiguration: AppManager.auth.requestConfiguration) +// +// FIRAuthBackend.verifyClient(request) { response, error in +// guard let response = response else { +// print("Verify iOS client failed.", error: error) +// return +// } +// +// let timeout = response.suggestedTimeOutDate.timeIntervalSinceNow +// AppManager.auth.appCredentialManager.didStartVerificationWithReceipt(response.receipt, +// timeout: timeout) { credential in +// guard let credentialSecret = credential.secret else { +// print("Failed to receive remote notification to verify app identity.", error: error) +// return +// } +// +// let testPhoneNumber = "+16509964692" +// let sendCodeRequest = FIRSendVerificationCodeRequest(phoneNumber: testPhoneNumber, +// appCredential: credential, +// reCAPTCHAToken: nil, +// requestConfiguration: AppManager.auth.requestConfiguration) +// +// FIRAuthBackend.sendVerificationCode(sendCodeRequest) { _, error in +// if let error = error { +// print("Verify iOS client failed.", error: error) +// } else { +// self.logSuccess("Verify iOS client succeeded.") +// self.showMessagePrompt("Verify iOS client succeed.") +// } +// } +// } +// } +// } +// } + + + func deleteApp() { + AppManager.shared.app.delete { success in + if success { + print("App deleted successfully.") + } else { + print("Failed to delete app.") + } + } + } + // MARK: - Private Helpers From c704b1a89ccfd29be5f8cdca4ebb5c5b2f52a292 Mon Sep 17 00:00:00 2001 From: Pragati Date: Fri, 23 Feb 2024 11:49:53 -0800 Subject: [PATCH 13/34] undo accidental changes --- .../ViewControllers/AuthViewController.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/AuthViewController.swift b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/AuthViewController.swift index 74cb08181bf..b864895e56f 100644 --- a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/AuthViewController.swift +++ b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/AuthViewController.swift @@ -224,7 +224,7 @@ class AuthViewController: UIViewController, DataSourceProviderDelegate { guard error == nil else { return self.displayError(error) } guard let accessToken = AccessToken.current else { return } let credential = FacebookAuthProvider.credential(withAccessToken: accessToken.tokenString) - self.signIn(with: credential) + self.signin(with: credential) } } @@ -236,7 +236,7 @@ class AuthViewController: UIViewController, DataSourceProviderDelegate { oauthProvider.getCredentialWith(nil) { credential, error in guard error == nil else { return self.displayError(error) } guard let credential = credential else { return } - self.signIn(with: credential) + self.signin(with: credential) } } @@ -311,7 +311,7 @@ class AuthViewController: UIViewController, DataSourceProviderDelegate { navigationController?.present(navCustomAuthController, animated: true) } - private func appleRawNoncesignin(with credential: AuthCredential) { + private func signin(with credential: AuthCredential) { AppManager.shared.auth().signIn(with: credential) { result, error in guard error == nil else { return self.displayError(error) } self.transitionToUserViewController() From 22272f25eaa26f235f6c9f8834c653584a5ff266 Mon Sep 17 00:00:00 2001 From: Pragati Date: Fri, 23 Feb 2024 11:51:27 -0800 Subject: [PATCH 14/34] lint fixes --- .../Models/AuthMenu.swift | 19 ++++---- .../Utility/Extensions.swift | 4 +- .../ViewControllers/AuthViewController.swift | 48 +++++++++---------- 3 files changed, 33 insertions(+), 38 deletions(-) diff --git a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/Models/AuthMenu.swift b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/Models/AuthMenu.swift index 471d8800d63..6c6dfd23a86 100644 --- a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/Models/AuthMenu.swift +++ b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/Models/AuthMenu.swift @@ -40,11 +40,11 @@ enum AuthMenu: String { case removeLastIdTokenChangeListener case verifyClient case deleteApp - - // More intuitively named getter for `rawValue`. + + // More intuitively named getter for `rawValue`. var id: String { rawValue } - - // The UI friendly name of the `AuthMenu`. Used for display. + + // The UI friendly name of the `AuthMenu`. Used for display. var name: String { switch self { case .settings: @@ -97,9 +97,9 @@ enum AuthMenu: String { return "Delete App" } } - - // Failable initializer to create an `AuthMenu` from its corresponding `name` value. - // - Parameter rawValue: String value representing `AuthMenu`'s name or type. + + // Failable initializer to create an `AuthMenu` from its corresponding `name` value. + // - Parameter rawValue: String value representing `AuthMenu`'s name or type. init?(rawValue: String) { switch rawValue { case "Settings": @@ -156,7 +156,6 @@ enum AuthMenu: String { } } - // MARK: DataSourceProvidable extension AuthMenu: DataSourceProvidable { @@ -213,7 +212,7 @@ extension AuthMenu: DataSourceProvidable { let item = Item(title: customAuthDomain.name, hasNestedContent: false, image: image) return Section(headerDescription: header, items: [item]) } - + static var appSection: Section { let header = "APP" let items: [Item] = [ @@ -224,7 +223,7 @@ extension AuthMenu: DataSourceProvidable { Item(title: addIdTokenChangeListener.name), Item(title: removeLastIdTokenChangeListener.name), Item(title: verifyClient.name), - Item(title: deleteApp.name) + Item(title: deleteApp.name), ] return Section(headerDescription: header, items: items) } diff --git a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/Utility/Extensions.swift b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/Utility/Extensions.swift index a74e4fa368e..4ce45df4020 100644 --- a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/Utility/Extensions.swift +++ b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/Utility/Extensions.swift @@ -69,12 +69,12 @@ public extension UIViewController { func displayInfo(title: String, message: String, style: UIAlertController.Style) { let alert = UIAlertController(title: title, message: message, preferredStyle: style) alert.addAction(UIAlertAction(title: "OK", style: .default, handler: nil)) - + DispatchQueue.main.async { // Ensure UI updates on the main thread self.present(alert, animated: true, completion: nil) } } - + func displayError(_ error: Error?, from function: StaticString = #function) { guard let error = error else { return } print("ⓧ Error in \(function): \(error.localizedDescription)") diff --git a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/AuthViewController.swift b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/AuthViewController.swift index b864895e56f..8831246d55d 100644 --- a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/AuthViewController.swift +++ b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/AuthViewController.swift @@ -95,32 +95,30 @@ class AuthViewController: UIViewController, DataSourceProviderDelegate { case .customAuthDomain: performCustomAuthDomainFlow() - + case .getToken: getUserTokenResult(force: false) - + case .getTokenForceRefresh: getUserTokenResult(force: true) - + case .addAuthStateChangeListener: addAuthStateListener() - + case .removeLastAuthStateChangeListener: removeAuthStateListener() - + case .addIdTokenChangeListener: addIDTokenListener() case .removeLastIdTokenChangeListener: removeIDTokenListener() - + case .verifyClient: - //verifyClient() + // verifyClient() return case .deleteApp: deleteApp() - - } } @@ -341,19 +339,19 @@ class AuthViewController: UIViewController, DataSourceProviderDelegate { prompt.addAction(okAction) present(prompt, animated: true) } - + private func getUserTokenResult(force: Bool) { guard let currentUser = Auth.auth().currentUser else { print("Error: No user logged in") return } - + currentUser.getIDTokenResult(forcingRefresh: force, completion: { tokenResult, error in if let error = error { print("Error: Error refreshing token") return // Handle error case, returning early } - + if let tokenResult = tokenResult, let claims = tokenResult.claims as? [String: Any] { var message = "Token refresh succeeded\n\n" for (key, value) in claims { @@ -365,18 +363,18 @@ class AuthViewController: UIViewController, DataSourceProviderDelegate { } }) } - + private func addAuthStateListener() { weak var weakSelf = self let index = authStateDidChangeListeners.count print("Auth State Did Change Listener #\(index) was added.") - let handle = Auth.auth().addStateDidChangeListener { [weak weakSelf] (auth, user) in + let handle = Auth.auth().addStateDidChangeListener { [weak weakSelf] auth, user in guard weakSelf != nil else { return } print("Auth State Did Change Listener #\(index) was invoked on user '\(user?.uid ?? "nil")'") } authStateDidChangeListeners.append(handle) } - + private func removeAuthStateListener() { guard !authStateDidChangeListeners.isEmpty else { print("No remaining Auth State Did Change Listeners.") @@ -388,18 +386,18 @@ class AuthViewController: UIViewController, DataSourceProviderDelegate { authStateDidChangeListeners.removeLast() print("Auth State Did Change Listener #\(index) was removed.") } - + private func addIDTokenListener() { weak var weakSelf = self let index = IDTokenDidChangeListeners.count print("ID Token Did Change Listener #\(index) was added.") - let handle = Auth.auth().addIDTokenDidChangeListener { [weak weakSelf] (auth, user) in + let handle = Auth.auth().addIDTokenDidChangeListener { [weak weakSelf] auth, user in guard weakSelf != nil else { return } print("ID Token Did Change Listener #\(index) was invoked on user '\(user?.uid ?? "")'.") } IDTokenDidChangeListeners.append(handle) } - + func removeIDTokenListener() { guard !IDTokenDidChangeListeners.isEmpty else { print("No remaining ID Token Did Change Listeners.") @@ -411,24 +409,24 @@ class AuthViewController: UIViewController, DataSourceProviderDelegate { IDTokenDidChangeListeners.removeLast() print("ID Token Did Change Listener #\(index) was removed.") } - + // func verifyClient() { // AppManager.shared.auth().tokenManager.getTokenInternal { token, error in // guard let token = token else { // print("Verify iOS client failed.", error: error) // return // } -// +// // let request = VerifyClientRequest{appToken: token.string, // isSandbox: token.type == .sandbox, // requestConfiguration: AppManager.auth.requestConfiguration) -// +// // FIRAuthBackend.verifyClient(request) { response, error in // guard let response = response else { // print("Verify iOS client failed.", error: error) // return // } -// +// // let timeout = response.suggestedTimeOutDate.timeIntervalSinceNow // AppManager.auth.appCredentialManager.didStartVerificationWithReceipt(response.receipt, // timeout: timeout) { credential in @@ -436,13 +434,13 @@ class AuthViewController: UIViewController, DataSourceProviderDelegate { // print("Failed to receive remote notification to verify app identity.", error: error) // return // } -// +// // let testPhoneNumber = "+16509964692" // let sendCodeRequest = FIRSendVerificationCodeRequest(phoneNumber: testPhoneNumber, // appCredential: credential, // reCAPTCHAToken: nil, // requestConfiguration: AppManager.auth.requestConfiguration) -// +// // FIRAuthBackend.sendVerificationCode(sendCodeRequest) { _, error in // if let error = error { // print("Verify iOS client failed.", error: error) @@ -456,7 +454,6 @@ class AuthViewController: UIViewController, DataSourceProviderDelegate { // } // } - func deleteApp() { AppManager.shared.app.delete { success in if success { @@ -467,7 +464,6 @@ class AuthViewController: UIViewController, DataSourceProviderDelegate { } } - // MARK: - Private Helpers private func configureDataSourceProvider() { From dd5d5a9782b570641dd87568b886b6cefce05e6e Mon Sep 17 00:00:00 2001 From: Pragati Date: Fri, 23 Feb 2024 11:58:28 -0800 Subject: [PATCH 15/34] add game center to AuthMenu --- .../AuthenticationExample/Models/AuthMenu.swift | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/Models/AuthMenu.swift b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/Models/AuthMenu.swift index b0abf158c96..711c60a0680 100644 --- a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/Models/AuthMenu.swift +++ b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/Models/AuthMenu.swift @@ -24,6 +24,7 @@ enum AuthMenu: String { case gitHub = "github.com" case yahoo = "yahoo.com" case facebook = "facebook.com" + case gameCenter = "gc.apple.com" case emailPassword = "password" case passwordless = "emailLink" case phoneNumber = "phone" @@ -54,6 +55,8 @@ enum AuthMenu: String { return "Yahoo" case .facebook: return "Facebook" + case .gameCenter: + return "Game Center" case .emailPassword: return "Email & Password Login" case .passwordless: @@ -91,6 +94,8 @@ enum AuthMenu: String { self = .yahoo case "Facebook": self = .facebook + case "Game Center": + self = .gameCenter case "Email & Password Login": self = .emailPassword case "Email Link/Passwordless": @@ -114,7 +119,7 @@ enum AuthMenu: String { extension AuthMenu: DataSourceProvidable { private static var providers: [AuthMenu] { - [.google, .apple, .twitter, .microsoft, .gitHub, .yahoo, .facebook] + [.google, .apple, .twitter, .microsoft, .gitHub, .yahoo, .facebook, .gameCenter] } static var settingsSection: Section { From cd79c9744045829e99302456a1118a5541c4518a Mon Sep 17 00:00:00 2001 From: Pragati Date: Sat, 24 Feb 2024 09:01:00 -0800 Subject: [PATCH 16/34] add verifyClient() method --- .../ViewControllers/AuthViewController.swift | 106 ++++++++++-------- 1 file changed, 58 insertions(+), 48 deletions(-) diff --git a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/AuthViewController.swift b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/AuthViewController.swift index 8831246d55d..80cf8fa35af 100644 --- a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/AuthViewController.swift +++ b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/AuthViewController.swift @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +@testable import FirebaseAuth // For Sign in with Facebook import FBSDKLoginKit import FirebaseAuth @@ -115,8 +116,8 @@ class AuthViewController: UIViewController, DataSourceProviderDelegate { removeIDTokenListener() case .verifyClient: - // verifyClient() - return + verifyClient() + case .deleteApp: deleteApp() } @@ -347,7 +348,7 @@ class AuthViewController: UIViewController, DataSourceProviderDelegate { } currentUser.getIDTokenResult(forcingRefresh: force, completion: { tokenResult, error in - if let error = error { + if error != nil { print("Error: Error refreshing token") return // Handle error case, returning early } @@ -410,58 +411,67 @@ class AuthViewController: UIViewController, DataSourceProviderDelegate { print("ID Token Did Change Listener #\(index) was removed.") } -// func verifyClient() { -// AppManager.shared.auth().tokenManager.getTokenInternal { token, error in -// guard let token = token else { -// print("Verify iOS client failed.", error: error) -// return -// } -// -// let request = VerifyClientRequest{appToken: token.string, -// isSandbox: token.type == .sandbox, -// requestConfiguration: AppManager.auth.requestConfiguration) -// -// FIRAuthBackend.verifyClient(request) { response, error in -// guard let response = response else { -// print("Verify iOS client failed.", error: error) -// return -// } -// -// let timeout = response.suggestedTimeOutDate.timeIntervalSinceNow -// AppManager.auth.appCredentialManager.didStartVerificationWithReceipt(response.receipt, -// timeout: timeout) { credential in -// guard let credentialSecret = credential.secret else { -// print("Failed to receive remote notification to verify app identity.", error: error) -// return -// } -// -// let testPhoneNumber = "+16509964692" -// let sendCodeRequest = FIRSendVerificationCodeRequest(phoneNumber: testPhoneNumber, -// appCredential: credential, -// reCAPTCHAToken: nil, -// requestConfiguration: AppManager.auth.requestConfiguration) -// -// FIRAuthBackend.sendVerificationCode(sendCodeRequest) { _, error in -// if let error = error { -// print("Verify iOS client failed.", error: error) -// } else { -// self.logSuccess("Verify iOS client succeeded.") -// self.showMessagePrompt("Verify iOS client succeed.") -// } -// } -// } -// } -// } -// } + func verifyClient() { + AppManager.shared.auth().tokenManager.getTokenInternal { token, error in + if(token == nil) { + print("Verify iOS Client failed.") + return + } + let request = VerifyClientRequest( + withAppToken: token?.string, + isSandbox: token?.type == .sandbox, + requestConfiguration: AppManager.shared.auth().requestConfiguration + ) + + Task { + do { + let verifyResponse = try await AuthBackend.call(with: request) + + guard let receipt = verifyResponse.receipt, + let timeoutDate = verifyResponse.suggestedTimeOutDate else { + print("Internal Auth Error: invalid VerifyClientResponse.") + return + } + + let timeout = timeoutDate.timeIntervalSinceNow + do { + let credential = await AppManager.shared.auth().appCredentialManager.didStartVerification(withReceipt: receipt, timeout: timeout) + + guard credential.secret != nil else { + print("Failed to receive remote notification to verify App ID.") + return + } + + let testPhoneNumber = "+16509964692" + let request = SendVerificationCodeRequest( + phoneNumber: testPhoneNumber, + codeIdentity: CodeIdentity.credential(credential), + requestConfiguration: AppManager.shared.auth().requestConfiguration + ) + + do { + _ = try await AuthBackend.call(with: request) + print("Verify iOS client succeeded") + } catch { + print("Verify iOS Client failed: \(error.localizedDescription)") + } + } + } catch { + print("Verify iOS Client failed: \(error.localizedDescription)") + } + } + } + } + func deleteApp() { - AppManager.shared.app.delete { success in + AppManager.shared.app.delete({ success in if success { print("App deleted successfully.") } else { print("Failed to delete app.") } - } + }) } // MARK: - Private Helpers From 7bf243dc3e1bb40f66e40675a5e65a0b8da69e9a Mon Sep 17 00:00:00 2001 From: pragatimodi <110490169+pragatimodi@users.noreply.github.com> Date: Tue, 12 Mar 2024 22:49:30 +0000 Subject: [PATCH 17/34] fix .plist line deletion --- .../SampleSwift/AuthenticationExample/SwiftApplication.plist | 1 + 1 file changed, 1 insertion(+) diff --git a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/SwiftApplication.plist b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/SwiftApplication.plist index 633b311e4b7..50378fe58b0 100644 --- a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/SwiftApplication.plist +++ b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/SwiftApplication.plist @@ -24,6 +24,7 @@ CFBundleURLName CFBundleURLSchemes + CFBundleVersion From 9b5639c4019ec88e16cacf76f836209873050d95 Mon Sep 17 00:00:00 2001 From: pragatimodi <110490169+pragatimodi@users.noreply.github.com> Date: Tue, 12 Mar 2024 23:33:54 +0000 Subject: [PATCH 18/34] fix unit test --- .../AuthenticationExampleUITests.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FirebaseAuth/Tests/SampleSwift/AuthenticationExampleUITests/AuthenticationExampleUITests.swift b/FirebaseAuth/Tests/SampleSwift/AuthenticationExampleUITests/AuthenticationExampleUITests.swift index 1dc9bddd718..67fcf65e0d1 100644 --- a/FirebaseAuth/Tests/SampleSwift/AuthenticationExampleUITests/AuthenticationExampleUITests.swift +++ b/FirebaseAuth/Tests/SampleSwift/AuthenticationExampleUITests/AuthenticationExampleUITests.swift @@ -38,7 +38,7 @@ class AuthenticationExampleUITests: XCTestCase { func testAuthOptions() { // There are 15 sign in methods, each with its own cell - XCTAssertEqual(app.tables.cells.count, 15) + XCTAssertEqual(app.tables.cells.count, 16) } func testAuthAnonymously() { From db885d7426285d735e3f92531b11a99a80ae2d7e Mon Sep 17 00:00:00 2001 From: Pragati Date: Wed, 3 Apr 2024 13:27:04 -0700 Subject: [PATCH 19/34] style.sh changes --- .../ViewControllers/AuthViewController.swift | 30 ++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/AuthViewController.swift b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/AuthViewController.swift index 80cf8fa35af..ea6e67821bc 100644 --- a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/AuthViewController.swift +++ b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/AuthViewController.swift @@ -12,10 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -@testable import FirebaseAuth // For Sign in with Facebook import FBSDKLoginKit -import FirebaseAuth +@testable import FirebaseAuth // [START auth_import] import FirebaseCore import GameKit @@ -117,7 +116,7 @@ class AuthViewController: UIViewController, DataSourceProviderDelegate { case .verifyClient: verifyClient() - + case .deleteApp: deleteApp() } @@ -413,7 +412,7 @@ class AuthViewController: UIViewController, DataSourceProviderDelegate { func verifyClient() { AppManager.shared.auth().tokenManager.getTokenInternal { token, error in - if(token == nil) { + if token == nil { print("Verify iOS Client failed.") return } @@ -422,33 +421,37 @@ class AuthViewController: UIViewController, DataSourceProviderDelegate { isSandbox: token?.type == .sandbox, requestConfiguration: AppManager.shared.auth().requestConfiguration ) - + Task { do { let verifyResponse = try await AuthBackend.call(with: request) - + guard let receipt = verifyResponse.receipt, let timeoutDate = verifyResponse.suggestedTimeOutDate else { print("Internal Auth Error: invalid VerifyClientResponse.") return } - + let timeout = timeoutDate.timeIntervalSinceNow do { - let credential = await AppManager.shared.auth().appCredentialManager.didStartVerification(withReceipt: receipt, timeout: timeout) - + let credential = await AppManager.shared.auth().appCredentialManager + .didStartVerification( + withReceipt: receipt, + timeout: timeout + ) + guard credential.secret != nil else { print("Failed to receive remote notification to verify App ID.") return } - + let testPhoneNumber = "+16509964692" let request = SendVerificationCodeRequest( phoneNumber: testPhoneNumber, codeIdentity: CodeIdentity.credential(credential), requestConfiguration: AppManager.shared.auth().requestConfiguration ) - + do { _ = try await AuthBackend.call(with: request) print("Verify iOS client succeeded") @@ -463,15 +466,14 @@ class AuthViewController: UIViewController, DataSourceProviderDelegate { } } - func deleteApp() { - AppManager.shared.app.delete({ success in + AppManager.shared.app.delete { success in if success { print("App deleted successfully.") } else { print("Failed to delete app.") } - }) + } } // MARK: - Private Helpers From 19b6c574fafabb91c8eff56404c356a786000f58 Mon Sep 17 00:00:00 2001 From: Pragati Date: Wed, 3 Apr 2024 22:35:35 -0700 Subject: [PATCH 20/34] remove authMenu test --- .../AuthenticationExampleUITests.swift | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/FirebaseAuth/Tests/SampleSwift/AuthenticationExampleUITests/AuthenticationExampleUITests.swift b/FirebaseAuth/Tests/SampleSwift/AuthenticationExampleUITests/AuthenticationExampleUITests.swift index 67fcf65e0d1..b363d4a986e 100644 --- a/FirebaseAuth/Tests/SampleSwift/AuthenticationExampleUITests/AuthenticationExampleUITests.swift +++ b/FirebaseAuth/Tests/SampleSwift/AuthenticationExampleUITests/AuthenticationExampleUITests.swift @@ -35,11 +35,11 @@ class AuthenticationExampleUITests: XCTestCase { // Verify that Auth Example app launched successfully XCTAssertTrue(app.navigationBars["Firebase Auth"].exists) } - - func testAuthOptions() { - // There are 15 sign in methods, each with its own cell - XCTAssertEqual(app.tables.cells.count, 16) - } +// TODO: Modify this test after code refactoring, current AuthMenu items aren't necessarily sign in methods +// func testAuthOptions() { +// // There are 16 sign in methods, each with its own cell +// XCTAssertEqual(app.tables.cells.count, 16) +// } func testAuthAnonymously() { app.staticTexts["Anonymous Authentication"].tap() From b55b1f1cd0cfeae07b3148ed0908fec8a676ea57 Mon Sep 17 00:00:00 2001 From: Pragati Date: Thu, 4 Apr 2024 11:01:04 -0700 Subject: [PATCH 21/34] style --- .../AuthenticationExampleUITests.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/FirebaseAuth/Tests/SampleSwift/AuthenticationExampleUITests/AuthenticationExampleUITests.swift b/FirebaseAuth/Tests/SampleSwift/AuthenticationExampleUITests/AuthenticationExampleUITests.swift index b363d4a986e..b35893a1574 100644 --- a/FirebaseAuth/Tests/SampleSwift/AuthenticationExampleUITests/AuthenticationExampleUITests.swift +++ b/FirebaseAuth/Tests/SampleSwift/AuthenticationExampleUITests/AuthenticationExampleUITests.swift @@ -35,7 +35,8 @@ class AuthenticationExampleUITests: XCTestCase { // Verify that Auth Example app launched successfully XCTAssertTrue(app.navigationBars["Firebase Auth"].exists) } -// TODO: Modify this test after code refactoring, current AuthMenu items aren't necessarily sign in methods + + // TODO: Modify this test after code refactoring, current AuthMenu items aren't necessarily sign in methods // func testAuthOptions() { // // There are 16 sign in methods, each with its own cell // XCTAssertEqual(app.tables.cells.count, 16) From 723538653b96a05e3d4907f1458f2abb5e3b29e8 Mon Sep 17 00:00:00 2001 From: Pragati Date: Thu, 4 Apr 2024 14:30:33 -0700 Subject: [PATCH 22/34] comment out AuthMenu UI test --- .../AuthenticationExampleUITests.swift | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/FirebaseAuth/Tests/SampleSwift/AuthenticationExampleUITests/AuthenticationExampleUITests.swift b/FirebaseAuth/Tests/SampleSwift/AuthenticationExampleUITests/AuthenticationExampleUITests.swift index 67fcf65e0d1..1a0fc7b02b8 100644 --- a/FirebaseAuth/Tests/SampleSwift/AuthenticationExampleUITests/AuthenticationExampleUITests.swift +++ b/FirebaseAuth/Tests/SampleSwift/AuthenticationExampleUITests/AuthenticationExampleUITests.swift @@ -36,10 +36,11 @@ class AuthenticationExampleUITests: XCTestCase { XCTAssertTrue(app.navigationBars["Firebase Auth"].exists) } - func testAuthOptions() { - // There are 15 sign in methods, each with its own cell - XCTAssertEqual(app.tables.cells.count, 16) - } + // TODO: Modify this test after code refactoring, current AuthMenu items aren't necessarily sign in methods + // func testAuthOptions() { + // // There are 16 sign in methods, each with its own cell + // XCTAssertEqual(app.tables.cells.count, 16) + // } func testAuthAnonymously() { app.staticTexts["Anonymous Authentication"].tap() From 1c331ebf5640def5997f8dfabf8923da1c0d1739 Mon Sep 17 00:00:00 2001 From: Pragati Date: Thu, 4 Apr 2024 15:42:55 -0700 Subject: [PATCH 23/34] cleanup --- .../Auth Provider Icons/Contents.json | 6 +++--- .../Game Center.imageset/Contents.json | 2 +- .../Game Center.imageset/game-center icon.png | Bin 27086 -> 0 bytes .../Game Center.imageset/gamecontroller.png | Bin 0 -> 764 bytes .../AccountLinkingViewController.swift | 7 ------- 5 files changed, 4 insertions(+), 11 deletions(-) delete mode 100644 FirebaseAuth/Tests/SampleSwift/AuthenticationExample/Assets.xcassets/Auth Provider Icons/Game Center.imageset/game-center icon.png create mode 100644 FirebaseAuth/Tests/SampleSwift/AuthenticationExample/Assets.xcassets/Auth Provider Icons/Game Center.imageset/gamecontroller.png diff --git a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/Assets.xcassets/Auth Provider Icons/Contents.json b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/Assets.xcassets/Auth Provider Icons/Contents.json index da4a164c918..73c00596a7f 100644 --- a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/Assets.xcassets/Auth Provider Icons/Contents.json +++ b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/Assets.xcassets/Auth Provider Icons/Contents.json @@ -1,6 +1,6 @@ { "info" : { - "version" : 1, - "author" : "xcode" + "author" : "xcode", + "version" : 1 } -} \ No newline at end of file +} diff --git a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/Assets.xcassets/Auth Provider Icons/Game Center.imageset/Contents.json b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/Assets.xcassets/Auth Provider Icons/Game Center.imageset/Contents.json index ca69c269602..8cd53c205c6 100644 --- a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/Assets.xcassets/Auth Provider Icons/Game Center.imageset/Contents.json +++ b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/Assets.xcassets/Auth Provider Icons/Game Center.imageset/Contents.json @@ -5,7 +5,7 @@ "scale" : "1x" }, { - "filename" : "game-center icon.png", + "filename" : "gamecontroller.png", "idiom" : "universal", "scale" : "2x" }, diff --git a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/Assets.xcassets/Auth Provider Icons/Game Center.imageset/game-center icon.png b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/Assets.xcassets/Auth Provider Icons/Game Center.imageset/game-center icon.png deleted file mode 100644 index 4c96fc2e25cc5b3d40de4c06935a9269d28aefdc..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 27086 zcmaI6RZtwx6D_>3I4tfC2@>2P!2<-hAMO_1-C5iH%}siRk}X(vwGbaf7q|`r_f2LW#pKCG_ymm{L5y;He4OR`6+w zo@&6u7`FlPLl3?7(d;~bAL49nYGQ5(ciH}ZAI|cQCv-vWyB9&vBb;hK9rAQH()|sW>Rn^$?|?t)71>#;$|?G< zCT+<-ic%BVNWBe3Eh9vBaCB@?sD}T9SW=?jr<@m9?(}H0AfEJuLyrn>dh& zF3eZSLH5gQ>Z>YI_zo1jR{_u?lAtvu9TL^-+aNktK@$P@NHfL}lz{CUyg_4gSvV*UX zl`}ddY+6d0_G88c-RtrF*8vk{*`$B&)dKjse3LQXRdQoKVp86}5^l*Vi&}3nZoJxc z(k>wo!)o#qHeU9R`0lMRyfrQwyZkq1yJ#mdFYDw4tO>U_DPP)5wZnTKqC;WzfGd~@ zyprv@Di+wmyDlfihPPLJ8Y2i0rtGLOF0Of!T)sjrnPFy*tWm{Y3^4hwCK*ip-*+|Y z3GlKwZZ=asuo=a5Ng=NaT)T(VVPekk{^V;N%%m3+`Tk?Tn@IZymDQX2X+|khJ;@NE z_zOAKaW}R~vSO6{Y3zLl)xU5`d=zG_S-NR!7vEX=rcB6SG}ulZ2@En$t_m#yG)m(` zV-nO$ytH#-X-;D1POPIl4hzH-^b)yx1_0PWEhx^P`){KsC?IYx(US55xe5=Ex zag|H@Ngv8q-Ox(eaVvoN1&Pv|+P7r>}bI$qcAuUuZ1rvdv@9!FEH!2kIC+dl^*( z1^ndG{fO*9A)h5H|7+c)0T02Q5%DlgrGlB#dy)5AUiDb{pW)CJ2|Uw?QgsdRlA3czi#zIC5-NCwN1VL zzrGk@eMSpp|3=?Kj7NOzAti%B@^c|B=|5osZO}zGQ=2Db8o{8mRM*5Lr-y0;@O6?}kx5CpjJ&Lie8-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OwkYlq13?%>6P@B^bpAq8D7({G9|+3{okbVg zXXcO=_Azq{qxF2wkx6Acj1z~@ZUYy5{$W;+mCWHIRsa_5kGdA~=+Mu(sKeu# zl|`KE91v{Nnmct#WY9e=tUGfS{@$uf22xo(3?5r7f4%3Ui;+P>FaWsRAfM{{?S4AI z^0XDnN19MD#{2jU;QUKd7m$aEksauJx5cZQ(5Y`Qb^aVb%;?g|VQ3#a!lB9~sL{uSPNSWwCN5niaX5RWsI`U|a$rXG(GuN&GHd-xkCaZ6=uc z{{A_Mcy{Cl#Oj!Du<9Y)@&7pZ^vN{gk^20pphYG~Y5J4bVC^+gd1%2Z?SrXP*?*qk z_@Xf%ym;EPPs=gqm`KGZ*=&N*q%>kl7XBP3vv&fJJFJ%%|A0Ps+KKf;$J%kd1ShsE z%x>>9^M;ZSj;mNz&btcM#3Sdp843^y5@6Gr=x`hBpMt{fYe$X4vDN9odeBF6D8S zzJMXl{U;8C`B_GDwO)09?cjQ`Y_rw<-B>ZWaQM8#j5r#UMiRh>s3sFa(nZ*1GFl|{ z&D}S|%O}oD>nlo;ZXwS$%PcBmI7ia%A_z16SAtQs!7s2^_kqycg2s$}3^$b<+RI@C qTSU4T0Am+AAL9RI=?Z>xhPSHqe2V2B=JMZPN-7GP@2cc1zx+R^&9!I% diff --git a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/Assets.xcassets/Auth Provider Icons/Game Center.imageset/gamecontroller.png b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/Assets.xcassets/Auth Provider Icons/Game Center.imageset/gamecontroller.png new file mode 100644 index 0000000000000000000000000000000000000000..14b182a9c457c53d62bc0d28c34d4a7cda3a9a10 GIT binary patch literal 764 zcmeAS@N?(olHy`uVBq!ia0vp^vOp}v!3HFkAH8}DNHG=%xjQkeJ16rJ$Z<)H@J#dd zWzYh$IT#q*GZ|PwN`P1jh#44|7cep~18GK(*a9ZFtn312I9mv$Fh;wvfq{W3&C|s( z#DjP4)aZ`hK#}9UlDs?n3O(~?&V1&|>B?z(l-Wzu>*AE6nHsLVn*MP%8X|F1*w3zZ z37q2XbLuVY&ixA0#fvO?}=BVw{ zWN0ANc0gf8v-}5MyMxsgyyqWi*0gUbN?7-iWmlpg&snMckGi}6GKtIc99B5>O?rd8 z+)=i-HG!KgSc4xZ-C?``OLR}GSN{8TCWl=znrCicxx!Tu86jG?O`x7BP14lH>hG55 z7v=1H;jiwzEf2eSkMY`1o+nj~4=jBeUN5+J zAhlp!?FY$UCfui^%D%e(yLKqz+{6p+#q4ufo)mYp}P zP8?n;f3;3%b`fM?c!yu}RL}n{ocHK>5OR2iYxTrJLSLoHk@$ zw(JKJ&;7Dgt`vX&uWBov-deKKCS~15Lspw>d2jdorN4@Q{aJ{)TIS8QbB)yx!k&H# zn32jI(UtYfckxq8uJ@-(_ITxpn(TOyV!^$0&usPt!yk^{tD}6s<+oLCklN>Pg;{3( zU5n=LiOb!Vz5Q|RpwI8sd{$9fo6nXX+x@C0H=yQ$ZR5wf$`x-mi2nnod(=sl(`1!#c@dR6ung1ELU$6M8x5qUPl=3`X{an^LB{Ts55cElj literal 0 HcmV?d00001 diff --git a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/AccountLinkingViewController.swift b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/AccountLinkingViewController.swift index 8752e8b0e6b..b6e00dbe309 100644 --- a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/AccountLinkingViewController.swift +++ b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/AccountLinkingViewController.swift @@ -241,7 +241,6 @@ class AccountLinkingViewController: UIViewController, DataSourceProviderDelegate // Step 1: Ensure Game Center Authentication guard GKLocalPlayer.local.isAuthenticated else { print("Error: Player not authenticated with Game Center.") - // TODO: Handle the 'not authenticated' scenario (e.g., prompt the user) return } @@ -249,13 +248,11 @@ class AccountLinkingViewController: UIViewController, DataSourceProviderDelegate GameCenterAuthProvider.getCredential { credential, error in if let error = error { print("Error getting Game Center credential: \(error.localizedDescription)") - // TODO: Handle the credential error return } guard let credential = credential else { print("Error: Missing Game Center credential") - // TODO: Handle the missing credential case return } @@ -263,12 +260,8 @@ class AccountLinkingViewController: UIViewController, DataSourceProviderDelegate Auth.auth().currentUser?.link(with: credential) { authResult, error in if let error = error { print("Error linking Game Center to Firebase: \(error.localizedDescription)") - // TODO: Handle the linking error return } - - // Linking successful - print("Successfully linked Game Center to Firebase") } } } From bd47b2a45e4621dcc6a9db6233b6938b3d0c66e1 Mon Sep 17 00:00:00 2001 From: Pragati Date: Tue, 9 Apr 2024 14:17:01 -0700 Subject: [PATCH 24/34] oob section changes --- .../Models/AuthMenu.swift | 163 ++++- .../DataSourceProvider.swift | 97 +-- .../AccountLinkingViewController.swift | 4 +- .../ViewControllers/AuthViewController.swift | 686 +++++++++++++----- 4 files changed, 692 insertions(+), 258 deletions(-) diff --git a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/Models/AuthMenu.swift b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/Models/AuthMenu.swift index 6c6dfd23a86..ea3d04810e0 100644 --- a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/Models/AuthMenu.swift +++ b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/Models/AuthMenu.swift @@ -40,11 +40,19 @@ enum AuthMenu: String { case removeLastIdTokenChangeListener case verifyClient case deleteApp - - // More intuitively named getter for `rawValue`. + case actionType + case continueURL + case requestVerifyEmail + case requestPasswordReset + case resetPassword + case checkActionCode + case applyActionCode + case verifyPasswordResetCode + + // More intuitively named getter for `rawValue`. var id: String { rawValue } - - // The UI friendly name of the `AuthMenu`. Used for display. + + // The UI friendly name of the `AuthMenu`. Used for display. var name: String { switch self { case .settings: @@ -95,6 +103,23 @@ enum AuthMenu: String { return "Verify Client" case .deleteApp: return "Delete App" + // OOB + case .actionType: + return "Action Type" + case .continueURL: + return "Continue URL" + case .requestVerifyEmail: + return "Request Verify Email" + case .requestPasswordReset: + return "Request Password Reset" + case .resetPassword: + return "Reset Password" + case .checkActionCode: + return "Check Action Code" + case .applyActionCode: + return "Apply Action Code" + case .verifyPasswordResetCode: + return "Verify Password Reset Code" } } @@ -150,6 +175,52 @@ enum AuthMenu: String { self = .verifyClient case "Delete App": self = .deleteApp + case "Action Type": + self = .actionType + case "Continue URL": + self = .continueURL + case "Request Verify Email": + self = .requestVerifyEmail + case "Request Password Reset": + self = .requestPasswordReset + case "Reset Password": + self = .resetPassword + case "Check Action Code": + self = .checkActionCode + case "Apply Action Code": + self = .applyActionCode + case "Verify Password Reset Code": + self = .verifyPasswordResetCode + default: + return nil + } + } +} + +enum ActionCodeRequestType: String { + case email + case `continue` + case inApp + + var name: String { + switch self { + case .email: + return "Email Only" + case .inApp: + return "In-App + Continue URL" + case .continue: + return "Continue URL" + } + } + + init?(rawValue: String) { + switch rawValue { + case "Email Only": + self = .email + case "In-App + Continue URL": + self = .inApp + case "Continue URL": + self = .continue default: return nil } @@ -158,88 +229,102 @@ enum AuthMenu: String { // MARK: DataSourceProvidable -extension AuthMenu: DataSourceProvidable { +class AuthMenuData: DataSourceProvidable { private static var providers: [AuthMenu] { [.google, .apple, .twitter, .microsoft, .gitHub, .yahoo, .facebook, .gameCenter] - } - + } + static var settingsSection: Section { let header = "Auth Settings" - let item = Item(title: settings.name, hasNestedContent: true) + let item = Item(title: AuthMenu.settings.name, hasNestedContent: true) return Section(headerDescription: header, items: [item]) } - + static var providerSection: Section { let providers = self.providers.map { Item(title: $0.name) } let header = "Identity Providers" let footer = "Choose a login flow from one of the identity providers above." return Section(headerDescription: header, footerDescription: footer, items: providers) } - + static var emailPasswordSection: Section { let image = UIImage(named: "firebaseIcon") let header = "Email and Password Login" - let item = Item(title: emailPassword.name, hasNestedContent: true, image: image) + let item = Item(title: AuthMenu.emailPassword.name, hasNestedContent: true, image: image) return Section(headerDescription: header, items: [item]) } - + static var otherSection: Section { let lockSymbol = UIImage.systemImage("lock.slash.fill", tintColor: .systemOrange) let phoneSymbol = UIImage.systemImage("phone.fill", tintColor: .systemOrange) let anonSymbol = UIImage.systemImage("questionmark.circle.fill", tintColor: .systemOrange) let shieldSymbol = UIImage.systemImage("lock.shield.fill", tintColor: .systemOrange) - + let otherOptions = [ - Item(title: passwordless.name, image: lockSymbol), - Item(title: phoneNumber.name, image: phoneSymbol), - Item(title: anonymous.name, image: anonSymbol), - Item(title: custom.name, image: shieldSymbol), + Item(title: AuthMenu.passwordless.name, image: lockSymbol), + Item(title: AuthMenu.phoneNumber.name, image: phoneSymbol), + Item(title: AuthMenu.anonymous.name, image: anonSymbol), + Item(title: AuthMenu.custom.name, image: shieldSymbol), ] let header = "Other Authentication Methods" return Section(headerDescription: header, items: otherOptions) } - + static var recaptchaSection: Section { let image = UIImage(named: "firebaseIcon") let header = "Initialize reCAPTCHA Enterprise" - let item = Item(title: initRecaptcha.name, hasNestedContent: false, image: image) + let item = Item(title: AuthMenu.initRecaptcha.name, hasNestedContent: false, image: image) return Section(headerDescription: header, items: [item]) } - + static var customAuthDomainSection: Section { let image = UIImage(named: "firebaseIcon") let header = "Custom Auth Domain" - let item = Item(title: customAuthDomain.name, hasNestedContent: false, image: image) + let item = Item(title: AuthMenu.customAuthDomain.name, hasNestedContent: false, image: image) return Section(headerDescription: header, items: [item]) } - + static var appSection: Section { let header = "APP" let items: [Item] = [ - Item(title: getToken.name), - Item(title: getTokenForceRefresh.name), - Item(title: addAuthStateChangeListener.name), - Item(title: removeLastAuthStateChangeListener.name), - Item(title: addIdTokenChangeListener.name), - Item(title: removeLastIdTokenChangeListener.name), - Item(title: verifyClient.name), - Item(title: deleteApp.name), + Item(title: AuthMenu.getToken.name), + Item(title: AuthMenu.getTokenForceRefresh.name), + Item(title: AuthMenu.addAuthStateChangeListener.name), + Item(title: AuthMenu.removeLastAuthStateChangeListener.name), + Item(title: AuthMenu.addIdTokenChangeListener.name), + Item(title: AuthMenu.removeLastIdTokenChangeListener.name), + Item(title: AuthMenu.verifyClient.name), + Item(title: AuthMenu.deleteApp.name), ] return Section(headerDescription: header, items: items) } - - static var sections: [Section] { - [settingsSection, providerSection, emailPasswordSection, otherSection, recaptchaSection, - customAuthDomainSection, appSection] + + static var oobSection: Section { + let header = "OOB" + let items: [Item] = [ + Item(title: AuthMenu.actionType.name, detailTitle: ActionCodeRequestType.inApp.name), + Item(title: AuthMenu.continueURL.name, detailTitle: "--", isEditable: true), + Item(title: AuthMenu.requestVerifyEmail.name), + Item(title: AuthMenu.requestPasswordReset.name), + Item(title: AuthMenu.resetPassword.name), + Item(title: AuthMenu.checkActionCode.name), + Item(title: AuthMenu.applyActionCode.name), + Item(title: AuthMenu.verifyPasswordResetCode.name), + ] + return Section(headerDescription: header, items: items) } - + + static var sections: [Section] = + [settingsSection, providerSection, emailPasswordSection, otherSection, recaptchaSection, + customAuthDomainSection, appSection, oobSection] + static var authLinkSections: [Section] { - let allItems = AuthMenu.sections.flatMap { $0.items } + let allItems = AuthMenuData.sections.flatMap { $0.items } let header = "Manage linking between providers" let footer = - "Select an unchecked row to link the currently signed in user to that auth provider. To unlink the user from a linked provider, select its corresponding row marked with a checkmark." + "Select an unchecked row to link the currently signed in user to that auth provider. To unlink the user from a linked provider, select its corresponding row marked with a checkmark." return [Section(headerDescription: header, footerDescription: footer, items: allItems)] } - - var sections: [Section] { AuthMenu.sections } + + var sections: [Section] = AuthMenuData.sections } diff --git a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/Utility/DataSourceProvider/DataSourceProvider.swift b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/Utility/DataSourceProvider/DataSourceProvider.swift index 857f58dbee6..d500f07d2c3 100644 --- a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/Utility/DataSourceProvider/DataSourceProvider.swift +++ b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/Utility/DataSourceProvider/DataSourceProvider.swift @@ -1,29 +1,29 @@ -// Copyright 2020 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. + // Copyright 2020 Google LLC + // + // Licensed under the Apache License, Version 2.0 (the "License"); + // you may not use this file except in compliance with the License. + // You may obtain a copy of the License at + // + // http://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. import UIKit -/// Abstracts away view/view controller based tableview configuration by acting as a tableview's -/// datasource and delegate + /// Abstracts away view/view controller based tableview configuration by acting as a tableview's + /// datasource and delegate class DataSourceProvider: NSObject, UITableViewDataSource, - UITableViewDelegate { + UITableViewDelegate { weak var delegate: DataSourceProviderDelegate? - + private var emptyView: UIView? - + private var sections: [DataSource.Section]! - + convenience init(dataSource: [DataSource.Section]?, emptyStateView: UIView? = nil, tableView: UITableView? = nil) { self.init() @@ -32,81 +32,90 @@ class DataSourceProvider: NSObject, UITableVie tableView?.dataSource = self tableView?.delegate = self } - - // MARK: Public Section and Item Getters - + + // MARK: Public Section and Item Getters + public func section(at indexPath: IndexPath) -> DataSource.Section { return sections[indexPath.section] } - + public func item(at indexPath: IndexPath) -> DataSource.Section.Item { return sectionItem(at: indexPath) } - - // MARK: - UITableViewDataSource - + + public func updateItem(at indexPath: IndexPath, item: Item) -> DataSource.Section.Item { + return editSectionItem(at: indexPath, item: item) + } + + // MARK: - UITableViewDataSource + func numberOfSections(in tableView: UITableView) -> Int { updateBackgroundViewIfNeeded(for: tableView) - + return sections.count } - + func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return sections[section].items.count } - + func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat { return sections[section].headerDescription?.isEmpty ?? true ? 20 : 40 } - + func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? { var label = UILabel() let section = sections[section] config(&label, for: section) return label } - + func tableView(_ tableView: UITableView, titleForFooterInSection section: Int) -> String? { return sections[section].footerDescription } - + func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { var cell = tableView.dequeueReusableCell(withIdentifier: "cell") - ?? UITableViewCell(style: .subtitle, reuseIdentifier: "cell") + ?? UITableViewCell(style: .subtitle, reuseIdentifier: "cell") let item = sectionItem(at: indexPath) config(&cell, for: item) return cell } - - // MARK: - UITableViewDelegate - + + // MARK: - UITableViewDelegate + func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { tableView.deselectRow(at: indexPath, animated: true) delegate?.didSelectRowAt(indexPath, on: tableView) } - + func scrollViewDidScroll(_ scrollView: UIScrollView) { guard let tableView = scrollView as? UITableView else { return } delegate?.tableViewDidScroll(tableView) } - - // MARK: - Private Helpers - + + // MARK: - Private Helpers + private func updateBackgroundViewIfNeeded(for tableView: UITableView) { tableView.backgroundView = sections.isEmpty ? emptyView : nil tableView.isScrollEnabled = !sections.isEmpty } - + private func sectionItem(at indexPath: IndexPath) -> DataSource.Section.Item { return sections[indexPath.section].items[indexPath.row] } - + + private func editSectionItem(at indexPath: IndexPath, item: Item) -> DataSource.Section.Item { + sections[indexPath.section].items[indexPath.row] = item as! DataSource.Section.Item + return sectionItem(at: indexPath) + } + private func config(_ label: inout UILabel, for section: DataSource.Section) { label.text = section.headerDescription label.textColor = .label label.font = UIFont.boldSystemFont(ofSize: 19.0) } - + private func config(_ cell: inout UITableViewCell, for item: DataSource.Section.Item) { cell.textLabel?.text = item.title cell.textLabel?.textColor = item.textColor @@ -117,7 +126,7 @@ class DataSourceProvider: NSObject, UITableVie cell.accessoryType = item.hasNestedContent ? .disclosureIndicator : .none cell.accessoryType = item.isChecked ? .checkmark : cell.accessoryType } - + private func editableImageView() -> UIImageView { let image = UIImage(systemName: "pencil")? .withTintColor(.systemOrange, renderingMode: .alwaysOriginal) diff --git a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/AccountLinkingViewController.swift b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/AccountLinkingViewController.swift index b6e00dbe309..34bf50f0a44 100644 --- a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/AccountLinkingViewController.swift +++ b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/AccountLinkingViewController.swift @@ -28,7 +28,7 @@ import AuthenticationServices import CryptoKit class AccountLinkingViewController: UIViewController, DataSourceProviderDelegate { - var dataSourceProvider: DataSourceProvider! + var dataSourceProvider: DataSourceProvider! var tableView: UITableView { view as! UITableView } @@ -466,7 +466,7 @@ extension AccountLinkingViewController: DataSourceProvidable { var sections: [Section] { buildSections() } private func buildSections() -> [Section] { - var section = AuthMenu.authLinkSections.first! + var section = AuthMenuData.authLinkSections.first! section.items = section.items.compactMap { item -> Item? in var item = item item.hasNestedContent = false diff --git a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/AuthViewController.swift b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/AuthViewController.swift index ea6e67821bc..9fa3139dac9 100644 --- a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/AuthViewController.swift +++ b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/AuthViewController.swift @@ -1,157 +1,205 @@ -// Copyright 2020 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. + // Copyright 2020 Google LLC + // + // Licensed under the Apache License, Version 2.0 (the "License"); + // you may not use this file except in compliance with the License. + // You may obtain a copy of the License at + // + // http://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. +@testable import FirebaseAuth -// For Sign in with Facebook + // For Sign in with Facebook import FBSDKLoginKit -@testable import FirebaseAuth -// [START auth_import] + // [START auth_import] import FirebaseCore import GameKit -// For Sign in with Google -// [START google_import] + // For Sign in with Google + // [START google_import] import GoogleSignIn import UIKit -// For Sign in with Apple + // For Sign in with Apple import AuthenticationServices import CryptoKit private let kFacebookAppID = "ENTER APP ID HERE" +private let kContinueUrl = "Enter URL" class AuthViewController: UIViewController, DataSourceProviderDelegate { - var dataSourceProvider: DataSourceProvider! + // var tableView: UITableView { view as! UITableView } + var dataSourceProvider: DataSourceProvider! var authStateDidChangeListeners: [AuthStateDidChangeListenerHandle] = [] var IDTokenDidChangeListeners: [IDTokenDidChangeListenerHandle] = [] - + var actionCodeContinueURL: URL? + var actionCodeRequestType: ActionCodeRequestType = .inApp + + let spinner = UIActivityIndicatorView(style: .medium) + var tableView: UITableView { view as! UITableView } + override func loadView() { view = UITableView(frame: .zero, style: .insetGrouped) } - + override func viewDidLoad() { super.viewDidLoad() configureNavigationBar() configureDataSourceProvider() } - - // MARK: - DataSourceProviderDelegate - + + private func showSpinner() { + spinner.center = view.center + spinner.startAnimating() + view.addSubview(spinner) + } + + private func hideSpinner() { + spinner.stopAnimating() + spinner.removeFromSuperview() + } + + private func actionCodeSettings() -> ActionCodeSettings { + let settings = ActionCodeSettings() + settings.url = actionCodeContinueURL + settings.handleCodeInApp = (actionCodeRequestType == .inApp) + return settings + } + + // MARK: - DataSourceProviderDelegate + func didSelectRowAt(_ indexPath: IndexPath, on tableView: UITableView) { let item = dataSourceProvider.item(at: indexPath) - - let providerName = item.isEditable ? item.detailTitle! : item.title! - + + let providerName = item.title! + guard let provider = AuthMenu(rawValue: providerName) else { - // The row tapped has no affiliated action. + // The row tapped has no affiliated action. return } - + switch provider { case .settings: performSettings() - + case .google: performGoogleSignInFlow() - + case .apple: performAppleSignInFlow() - + case .facebook: performFacebookSignInFlow() - + case .twitter, .microsoft, .gitHub, .yahoo: performOAuthLoginFlow(for: provider) - + case .gameCenter: performGameCenterLoginFlow() - + case .emailPassword: performDemoEmailPasswordLoginFlow() - + case .passwordless: performPasswordlessLoginFlow() - + case .phoneNumber: performPhoneNumberLoginFlow() - + case .anonymous: performAnonymousLoginFlow() - + case .custom: performCustomAuthLoginFlow() - + case .initRecaptcha: performInitRecaptcha() - + case .customAuthDomain: performCustomAuthDomainFlow() - + case .getToken: getUserTokenResult(force: false) - + case .getTokenForceRefresh: getUserTokenResult(force: true) - + case .addAuthStateChangeListener: addAuthStateListener() - + case .removeLastAuthStateChangeListener: removeAuthStateListener() - + case .addIdTokenChangeListener: addIDTokenListener() - + case .removeLastIdTokenChangeListener: removeIDTokenListener() - + case .verifyClient: verifyClient() - + case .deleteApp: deleteApp() - } - } - - // MARK: - Firebase 🔥 - + + case .actionType: + toggleActionCodeRequestType(at: indexPath) + + case .continueURL: + changeActionCodeContinueURL(at: indexPath) + + case .requestVerifyEmail: + requestVerifyEmail() + + case .requestPasswordReset: + requestPasswordReset() + + case .resetPassword: + resetPassword() + + case .checkActionCode: + checkActionCode() + + case .applyActionCode: + applyActionCode() + + case .verifyPasswordResetCode: + verifyPasswordResetCode() + } + + // MARK: - Firebase 🔥 + private func performSettings() { let settingsController = SettingsViewController() navigationController?.pushViewController(settingsController, animated: true) } - + private func performGoogleSignInFlow() { - // [START headless_google_auth] + // [START headless_google_auth] guard let clientID = FirebaseApp.app()?.options.clientID else { return } - - // Create Google Sign In configuration object. - // [START_EXCLUDE silent] - // TODO: Move configuration to Info.plist - // [END_EXCLUDE] + + // Create Google Sign In configuration object. + // [START_EXCLUDE silent] + // TODO: Move configuration to Info.plist + // [END_EXCLUDE] let config = GIDConfiguration(clientID: clientID) GIDSignIn.sharedInstance.configuration = config - - // Start the sign in flow! + + // Start the sign in flow! GIDSignIn.sharedInstance.signIn(withPresenting: self) { [unowned self] result, error in guard error == nil else { - // [START_EXCLUDE] + // [START_EXCLUDE] return displayError(error) - // [END_EXCLUDE] + // [END_EXCLUDE] } - + guard let user = result?.user, let idToken = user.idToken?.tokenString else { - // [START_EXCLUDE] + // [START_EXCLUDE] let error = NSError( domain: "GIDSignInError", code: -1, @@ -160,38 +208,38 @@ class AuthViewController: UIViewController, DataSourceProviderDelegate { ] ) return displayError(error) - // [END_EXCLUDE] + // [END_EXCLUDE] } - + let credential = GoogleAuthProvider.credential(withIDToken: idToken, accessToken: user.accessToken.tokenString) - - // [START_EXCLUDE] + + // [START_EXCLUDE] signIn(with: credential) - // [END_EXCLUDE] + // [END_EXCLUDE] } - // [END headless_google_auth] + // [END headless_google_auth] } - + func signIn(with credential: AuthCredential) { - // [START signin_google_credential] + // [START signin_google_credential] AppManager.shared.auth().signIn(with: credential) { result, error in - // [START_EXCLUDE silent] + // [START_EXCLUDE silent] guard error == nil else { return self.displayError(error) } - // [END_EXCLUDE] - - // At this point, our user is signed in - // [START_EXCLUDE silent] - // so we advance to the User View Controller + // [END_EXCLUDE] + + // At this point, our user is signed in + // [START_EXCLUDE silent] + // so we advance to the User View Controller self.transitionToUserViewController() - // [END_EXCLUDE] + // [END_EXCLUDE] } - // [END signin_google_credential] + // [END signin_google_credential] } - - // For Sign in with Apple + + // For Sign in with Apple var currentNonce: String? - + private func performAppleSignInFlow() { do { let nonce = try CryptoUtils.randomNonceString() @@ -200,23 +248,23 @@ class AuthViewController: UIViewController, DataSourceProviderDelegate { let request = appleIDProvider.createRequest() request.requestedScopes = [.fullName, .email] request.nonce = CryptoUtils.sha256(nonce) - + let authorizationController = ASAuthorizationController(authorizationRequests: [request]) authorizationController.delegate = self authorizationController.presentationContextProvider = self authorizationController.performRequests() } catch { - // In the unlikely case that nonce generation fails, show error view. + // In the unlikely case that nonce generation fails, show error view. displayError(error) } } - + private func performFacebookSignInFlow() { - // The following config can also be stored in the project's .plist + // The following config can also be stored in the project's .plist Settings.shared.appID = kFacebookAppID Settings.shared.displayName = "AuthenticationExample" - - // Create a Facebook `LoginManager` instance + + // Create a Facebook `LoginManager` instance let loginManager = LoginManager() loginManager.logIn(permissions: ["email"], from: self) { result, error in guard error == nil else { return self.displayError(error) } @@ -225,10 +273,10 @@ class AuthViewController: UIViewController, DataSourceProviderDelegate { self.signin(with: credential) } } - - // Maintain a strong reference to an OAuthProvider for login + + // Maintain a strong reference to an OAuthProvider for login private var oauthProvider: OAuthProvider! - + private func performOAuthLoginFlow(for provider: AuthMenu) { oauthProvider = OAuthProvider(providerID: provider.id) oauthProvider.getCredentialWith(nil) { credential, error in @@ -237,85 +285,85 @@ class AuthViewController: UIViewController, DataSourceProviderDelegate { self.signin(with: credential) } } - + private func performGameCenterLoginFlow() { - // Step 1: System Game Center Login + // Step 1: System Game Center Login GKLocalPlayer.local.authenticateHandler = { viewController, error in if let error = error { - // Handle Game Center login error + // Handle Game Center login error print("Error logging into Game Center: \(error.localizedDescription)") } else if let authViewController = viewController { - // Present Game Center login UI if needed + // Present Game Center login UI if needed self.present(authViewController, animated: true) } else { - // Game Center login successful, proceed to Firebase + // Game Center login successful, proceed to Firebase self.linkGameCenterToFirebase() } } } - - // Step 2: Link to Firebase + + // Step 2: Link to Firebase private func linkGameCenterToFirebase() { GameCenterAuthProvider.getCredential { credential, error in if let error = error { - // Handle Firebase credential retrieval error + // Handle Firebase credential retrieval error print("Error getting Game Center credential: \(error.localizedDescription)") } else if let credential = credential { Auth.auth().signIn(with: credential) { authResult, error in if let error = error { - // Handle Firebase sign-in error + // Handle Firebase sign-in error print("Error signing into Firebase with Game Center: \(error.localizedDescription)") } else { - // Firebase sign-in successful + // Firebase sign-in successful print("Successfully linked Game Center to Firebase") } } } } } - + private func performDemoEmailPasswordLoginFlow() { let loginController = LoginController() loginController.delegate = self navigationController?.pushViewController(loginController, animated: true) } - + private func performPasswordlessLoginFlow() { let passwordlessViewController = PasswordlessViewController() passwordlessViewController.delegate = self let navPasswordlessAuthController = - UINavigationController(rootViewController: passwordlessViewController) + UINavigationController(rootViewController: passwordlessViewController) navigationController?.present(navPasswordlessAuthController, animated: true) } - + private func performPhoneNumberLoginFlow() { let phoneAuthViewController = PhoneAuthViewController() phoneAuthViewController.delegate = self let navPhoneAuthController = UINavigationController(rootViewController: phoneAuthViewController) navigationController?.present(navPhoneAuthController, animated: true) } - + private func performAnonymousLoginFlow() { AppManager.shared.auth().signInAnonymously { result, error in guard error == nil else { return self.displayError(error) } self.transitionToUserViewController() } } - + private func performCustomAuthLoginFlow() { let customAuthController = CustomAuthViewController() customAuthController.delegate = self let navCustomAuthController = UINavigationController(rootViewController: customAuthController) navigationController?.present(navCustomAuthController, animated: true) } - + private func signin(with credential: AuthCredential) { AppManager.shared.auth().signIn(with: credential) { result, error in guard error == nil else { return self.displayError(error) } self.transitionToUserViewController() } } - + private func performInitRecaptcha() { Task { do { @@ -326,32 +374,25 @@ class AuthViewController: UIViewController, DataSourceProviderDelegate { } } } - + private func performCustomAuthDomainFlow() { - let prompt = UIAlertController(title: nil, message: "Enter Custom Auth Domain For Auth:", - preferredStyle: .alert) - prompt.addTextField() - let okAction = UIAlertAction(title: "OK", style: .default) { action in - let domain = prompt.textFields?[0].text ?? "" - AppManager.shared.auth().customAuthDomain = domain - print("Successfully set auth domain to: \(domain)") - } - prompt.addAction(okAction) - present(prompt, animated: true) + showTextInputPrompt(with: "Enter Custom Auth Domain For Auth: ", completion: { newDomain in + AppManager.shared.auth().customAuthDomain = newDomain + }) } - + private func getUserTokenResult(force: Bool) { guard let currentUser = Auth.auth().currentUser else { print("Error: No user logged in") return } - + currentUser.getIDTokenResult(forcingRefresh: force, completion: { tokenResult, error in if error != nil { print("Error: Error refreshing token") return // Handle error case, returning early } - + if let tokenResult = tokenResult, let claims = tokenResult.claims as? [String: Any] { var message = "Token refresh succeeded\n\n" for (key, value) in claims { @@ -363,7 +404,7 @@ class AuthViewController: UIViewController, DataSourceProviderDelegate { } }) } - + private func addAuthStateListener() { weak var weakSelf = self let index = authStateDidChangeListeners.count @@ -374,7 +415,7 @@ class AuthViewController: UIViewController, DataSourceProviderDelegate { } authStateDidChangeListeners.append(handle) } - + private func removeAuthStateListener() { guard !authStateDidChangeListeners.isEmpty else { print("No remaining Auth State Did Change Listeners.") @@ -386,7 +427,7 @@ class AuthViewController: UIViewController, DataSourceProviderDelegate { authStateDidChangeListeners.removeLast() print("Auth State Did Change Listener #\(index) was removed.") } - + private func addIDTokenListener() { weak var weakSelf = self let index = IDTokenDidChangeListeners.count @@ -397,8 +438,8 @@ class AuthViewController: UIViewController, DataSourceProviderDelegate { } IDTokenDidChangeListeners.append(handle) } - - func removeIDTokenListener() { + + private func removeIDTokenListener() { guard !IDTokenDidChangeListeners.isEmpty else { print("No remaining ID Token Did Change Listeners.") return @@ -409,8 +450,8 @@ class AuthViewController: UIViewController, DataSourceProviderDelegate { IDTokenDidChangeListeners.removeLast() print("ID Token Did Change Listener #\(index) was removed.") } - - func verifyClient() { + + private func verifyClient() { AppManager.shared.auth().tokenManager.getTokenInternal { token, error in if token == nil { print("Verify iOS Client failed.") @@ -421,17 +462,17 @@ class AuthViewController: UIViewController, DataSourceProviderDelegate { isSandbox: token?.type == .sandbox, requestConfiguration: AppManager.shared.auth().requestConfiguration ) - + Task { do { let verifyResponse = try await AuthBackend.call(with: request) - + guard let receipt = verifyResponse.receipt, let timeoutDate = verifyResponse.suggestedTimeOutDate else { print("Internal Auth Error: invalid VerifyClientResponse.") return } - + let timeout = timeoutDate.timeIntervalSinceNow do { let credential = await AppManager.shared.auth().appCredentialManager @@ -439,19 +480,19 @@ class AuthViewController: UIViewController, DataSourceProviderDelegate { withReceipt: receipt, timeout: timeout ) - + guard credential.secret != nil else { print("Failed to receive remote notification to verify App ID.") return } - + let testPhoneNumber = "+16509964692" let request = SendVerificationCodeRequest( phoneNumber: testPhoneNumber, codeIdentity: CodeIdentity.credential(credential), requestConfiguration: AppManager.shared.auth().requestConfiguration ) - + do { _ = try await AuthBackend.call(with: request) print("Verify iOS client succeeded") @@ -465,8 +506,8 @@ class AuthViewController: UIViewController, DataSourceProviderDelegate { } } } - - func deleteApp() { + + private func deleteApp() { AppManager.shared.app.delete { success in if success { print("App deleted successfully.") @@ -475,15 +516,314 @@ class AuthViewController: UIViewController, DataSourceProviderDelegate { } } } - - // MARK: - Private Helpers - + + private func toggleActionCodeRequestType(at indexPath: IndexPath) { + switch actionCodeRequestType { + case .inApp: + actionCodeRequestType = .continue + case .continue: + actionCodeRequestType = .email + case .email: + actionCodeRequestType = .inApp + } + dataSourceProvider.updateItem( + at: indexPath, + item: Item(title: AuthMenu.actionType.name, detailTitle: actionCodeRequestType.name) + ) + tableView.reloadData() + } + + private func changeActionCodeContinueURL(at indexPath: IndexPath) { + showTextInputPrompt(with: "Continue URL:", completion: { newContinueURL in + self.actionCodeContinueURL = URL(string: newContinueURL) + print("Successfully set Continue URL to: \(newContinueURL)") + self.dataSourceProvider.updateItem( + at: indexPath, + item: Item( + title: AuthMenu.continueURL.name, + detailTitle: self.actionCodeContinueURL?.absoluteString, + isEditable: true + ) + ) + self.tableView.reloadData() + }) + } + + private func requestVerifyEmail() { + showSpinner() + let completionHandler: (Error?) -> Void = { [weak self] error in + guard let self = self else { return } + self.hideSpinner() + + if let error = error { + let errorMessage = "Error sending verification email: \(error.localizedDescription)" + showAlert(for: errorMessage) + print(errorMessage) + } else { + let successMessage = "Verification email sent successfully!" + showAlert(for: successMessage) + print(successMessage) + } + } + if actionCodeRequestType == .email { + AppManager.shared.auth().currentUser?.sendEmailVerification(completion: completionHandler) + } else { + if actionCodeContinueURL == nil { + print("Error: Action code continue URL is nil.") + return + } + AppManager.shared.auth().currentUser?.sendEmailVerification( + with: actionCodeSettings(), + completion: completionHandler + ) + } + } + + func requestPasswordReset() { + showTextInputPrompt(with: "Email:", completion: { email in + print("Sending password reset link to: \(email)") + self.showSpinner() + let completionHandler: (Error?) -> Void = { [weak self] error in + guard let self = self else { return } + self.hideSpinner() + if let error = error { + print("Request password reset failed: \(error)") + showAlert(for: error.localizedDescription) + return + } + print("Request password reset succeeded.") + showAlert(for: "Sent!") + } + if self.actionCodeRequestType == .email { + AppManager.shared.auth().sendPasswordReset(withEmail: email, completion: completionHandler) + } else { + guard let actionCodeContinueURL = self.actionCodeContinueURL else { + print("Error: Action code continue URL is nil.") + return + } + AppManager.shared.auth().sendPasswordReset( + withEmail: email, + actionCodeSettings: self.actionCodeSettings(), + completion: completionHandler + ) + } + }) + } + + private func resetPassword() { + showSpinner() + let completionHandler: (Error?) -> Void = { [weak self] error in + guard let self = self else { return } + self.hideSpinner() + if let error = error { + print("Password reset failed \(error)") + showAlert(for: error.localizedDescription) + return + } + print("Password reset succeeded") + showAlert(for: "Password reset succeeded!") + } + showTextInputPrompt(with: "OOB Code:") { + code in + self.showTextInputPrompt(with: "New Password") { + password in + AppManager.shared.auth().confirmPasswordReset( + withCode: code, + newPassword: password, + completion: completionHandler + ) + } + } + } + + private func nameForActionCodeOperation(_ operation: ActionCodeOperation) -> String { + switch operation { + case .verifyEmail: + return "Verify Email" + case .recoverEmail: + return "Recover Email" + case .passwordReset: + return "Password Reset" + case .emailLink: + return "Email Sign-In Link" + case .verifyAndChangeEmail: + return "Verify Before Change Email" + case .revertSecondFactorAddition: + return "Revert Second Factor Addition" + case .unknown: + return "Unknown action" + } + } + + private func checkActionCode() { + showSpinner() + let completionHandler: (ActionCodeInfo?, Error?) -> Void = { [weak self] info, error in + guard let self = self else { return } + self.hideSpinner() + if let error = error { + print("Check action code failed: \(error)") + showAlert(for: error.localizedDescription) + return + } + guard let info = info else { return } + print("Check action code succeeded") + let email = info.email + let previousEmail = info.previousEmail + let message = previousEmail != nil ? "\(previousEmail!) -> \(email)" : email + let operation = self.nameForActionCodeOperation(info.operation) + showAlert(for: operation) + } + showTextInputPrompt(with: "OOB Code:") { + oobCode in + AppManager.shared.auth().checkActionCode(oobCode, completion: completionHandler) + } + } + + private func applyActionCode() { + showSpinner() + let completionHandler: (Error?) -> Void = { [weak self] error in + guard let self = self else { return } + self.hideSpinner() + if let error = error { + print("Apply action code failed \(error)") + showAlert(for: error.localizedDescription) + return + } + print("Apply action code succeeded") + showAlert(for: "Action code was properly applied") + } + showTextInputPrompt(with: "OOB Code: ") { + oobCode in + AppManager.shared.auth().applyActionCode(oobCode, completion: completionHandler) + } + } + + private func verifyPasswordResetCode() { + showSpinner() + let completionHandler: (String?, Error?) -> Void = { [weak self] email, error in + guard let self = self else { return } + self.hideSpinner() + if let error = error { + print("Verify password reset code failed \(error)") + showAlert(for: error.localizedDescription) + return + } + print("Verify password resest code succeeded.") + showAlert(for: "Code verified for email: \(email)") + } + showTextInputPrompt(with: "OOB Code: ") { + oobCode in + AppManager.shared.auth().verifyPasswordResetCode(oobCode, completion: completionHandler) + } + } + + // MARK: - Private Helpers + + private func showTextInputPrompt(with message: String, completion: ((String) -> Void)? = nil) { + let editController = UIAlertController( + title: message, + message: nil, + preferredStyle: .alert + ) + editController.addTextField() + + let saveHandler: (UIAlertAction) -> Void = { _ in + let text = editController.textFields?.first?.text ?? "" + completion?(text) + // completion?() + } + + let cancelHandler: (UIAlertAction) -> Void = { _ in + completion?("") + // completion?() + } + + editController.addAction(UIAlertAction(title: "Save", style: .default, handler: saveHandler)) + editController.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: cancelHandler)) + + // Assuming `self` is a view controller + present(editController, animated: true, completion: nil) + } + + private func showQRCodePromptWithTextInput(with message: String, url: String, completion: ((String) -> Void)? = nil) { + // Create a UIAlertController + let alertController = UIAlertController(title: "QR Code Prompt", message: message, preferredStyle: .alert) + + // Add a text field for input + alertController.addTextField { (textField) in + textField.placeholder = "Enter text" + } + + // Create a UIImage from the URL + guard let image = generateQRCode(from: url) else { + print("Failed to generate QR code") + return + } + + // Create an image view to display the QR code + let imageView = UIImageView(image: image) + imageView.contentMode = .scaleAspectFit + imageView.translatesAutoresizingMaskIntoConstraints = false + + // Add the image view to the alert controller + alertController.view.addSubview(imageView) + + // Add constraints to position the image view + NSLayoutConstraint.activate([ + imageView.topAnchor.constraint(equalTo: alertController.view.topAnchor, constant: 20), + imageView.centerXAnchor.constraint(equalTo: alertController.view.centerXAnchor), + imageView.widthAnchor.constraint(equalToConstant: 200), + imageView.heightAnchor.constraint(equalToConstant: 200) + ]) + + // Add actions + let cancelAction = UIAlertAction(title: "Cancel", style: .cancel, handler: nil) + let submitAction = UIAlertAction(title: "Submit", style: .default) { (_) in + if let text = alertController.textFields?.first?.text { + completion?(text) + } + } + + alertController.addAction(cancelAction) + alertController.addAction(submitAction) + + // Present the alert controller + UIApplication.shared.windows.first?.rootViewController?.present(alertController, animated: true, completion: nil) + } + + // Function to generate QR code from a string + private func generateQRCode(from string: String) -> UIImage? { + let data = string.data(using: String.Encoding.ascii) + + if let filter = CIFilter(name: "CIQRCodeGenerator") { + filter.setValue(data, forKey: "inputMessage") + let transform = CGAffineTransform(scaleX: 10, y: 10) + + if let output = filter.outputImage?.transformed(by: transform) { + return UIImage(ciImage: output) + } + } + + return nil + } + + func showAlert(for message: String) { + let alertController = UIAlertController( + title: message, + message: nil, + preferredStyle: .alert + ) + alertController.addAction(UIAlertAction(title: "OK", style: UIAlertAction.Style.default)) + } + private func configureDataSourceProvider() { - let tableView = view as! UITableView - dataSourceProvider = DataSourceProvider(dataSource: AuthMenu.sections, tableView: tableView) + dataSourceProvider = DataSourceProvider( + dataSource: AuthMenuData.sections, + tableView: tableView + ) dataSourceProvider.delegate = self } - + private func configureNavigationBar() { navigationItem.title = "Firebase Auth" guard let navigationBar = navigationController?.navigationBar else { return } @@ -491,9 +831,9 @@ class AuthViewController: UIViewController, DataSourceProviderDelegate { navigationBar.titleTextAttributes = [.foregroundColor: UIColor.systemOrange] navigationBar.largeTitleTextAttributes = [.foregroundColor: UIColor.systemOrange] } - + private func transitionToUserViewController() { - // UserViewController is at index 1 in the tabBarController.viewControllers array + // UserViewController is at index 1 in the tabBarController.viewControllers array tabBarController?.transitionToViewController(atIndex: 1) } } @@ -503,15 +843,15 @@ class AuthViewController: UIViewController, DataSourceProviderDelegate { extension AuthViewController: LoginDelegate { public func loginDidOccur() { transitionToUserViewController() - } + } } // MARK: - Implementing Sign in with Apple with Firebase extension AuthViewController: ASAuthorizationControllerDelegate, - ASAuthorizationControllerPresentationContextProviding { + ASAuthorizationControllerPresentationContextProviding { // MARK: ASAuthorizationControllerDelegate - + func authorizationController(controller: ASAuthorizationController, didCompleteWithAuthorization authorization: ASAuthorization) { guard let appleIDCredential = authorization.credential as? ASAuthorizationAppleIDCredential @@ -519,11 +859,11 @@ extension AuthViewController: ASAuthorizationControllerDelegate, print("Unable to retrieve AppleIDCredential") return } - + guard let nonce = currentNonce else { fatalError("Invalid state: A login callback was received, but no login request was sent.") } - + guard let appleIDToken = appleIDCredential.identityToken else { print("Unable to fetch identity token") return @@ -536,39 +876,39 @@ extension AuthViewController: ASAuthorizationControllerDelegate, print("Unable to serialize token string from data: \(appleIDToken.debugDescription)") return } - + guard let _ = String(data: appleAuthCode, encoding: .utf8) else { print("Unable to serialize auth code string from data: \(appleAuthCode.debugDescription)") return } - - // use this call to create the authentication credential and set the user's full name + + // use this call to create the authentication credential and set the user's full name let credential = OAuthProvider.appleCredential(withIDToken: idTokenString, rawNonce: nonce, fullName: appleIDCredential.fullName) - + AppManager.shared.auth().signIn(with: credential) { result, error in - // Error. If error.code == .MissingOrInvalidNonce, make sure - // you're sending the SHA256-hashed nonce as a hex string with - // your request to Apple. + // Error. If error.code == .MissingOrInvalidNonce, make sure + // you're sending the SHA256-hashed nonce as a hex string with + // your request to Apple. guard error == nil else { return self.displayError(error) } - - // At this point, our user is signed in - // so we advance to the User View Controller + + // At this point, our user is signed in + // so we advance to the User View Controller self.transitionToUserViewController() } } - + func authorizationController(controller: ASAuthorizationController, didCompleteWithError error: Error) { - // Ensure that you have: - // - enabled `Sign in with Apple` on the Firebase console - // - added the `Sign in with Apple` capability for this project + // Ensure that you have: + // - enabled `Sign in with Apple` on the Firebase console + // - added the `Sign in with Apple` capability for this project print("Sign in with Apple failed: \(error)") } - - // MARK: ASAuthorizationControllerPresentationContextProviding - + + // MARK: ASAuthorizationControllerPresentationContextProviding + func presentationAnchor(for controller: ASAuthorizationController) -> ASPresentationAnchor { return view.window! } From 23e78990dd2a00aa52fa9de9d7663e30cc6d21a0 Mon Sep 17 00:00:00 2001 From: Pragati Date: Tue, 9 Apr 2024 14:23:54 -0700 Subject: [PATCH 25/34] lint --- .../Models/AuthMenu.swift | 44 ++++----- .../DataSourceProvider.swift | 92 +++++++++---------- 2 files changed, 68 insertions(+), 68 deletions(-) diff --git a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/Models/AuthMenu.swift b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/Models/AuthMenu.swift index ea3d04810e0..cd7cb7a0e59 100644 --- a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/Models/AuthMenu.swift +++ b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/Models/AuthMenu.swift @@ -48,11 +48,11 @@ enum AuthMenu: String { case checkActionCode case applyActionCode case verifyPasswordResetCode - - // More intuitively named getter for `rawValue`. + + // More intuitively named getter for `rawValue`. var id: String { rawValue } - - // The UI friendly name of the `AuthMenu`. Used for display. + + // The UI friendly name of the `AuthMenu`. Used for display. var name: String { switch self { case .settings: @@ -201,7 +201,7 @@ enum ActionCodeRequestType: String { case email case `continue` case inApp - + var name: String { switch self { case .email: @@ -212,7 +212,7 @@ enum ActionCodeRequestType: String { return "Continue URL" } } - + init?(rawValue: String) { switch rawValue { case "Email Only": @@ -232,34 +232,34 @@ enum ActionCodeRequestType: String { class AuthMenuData: DataSourceProvidable { private static var providers: [AuthMenu] { [.google, .apple, .twitter, .microsoft, .gitHub, .yahoo, .facebook, .gameCenter] - } - + } + static var settingsSection: Section { let header = "Auth Settings" let item = Item(title: AuthMenu.settings.name, hasNestedContent: true) return Section(headerDescription: header, items: [item]) } - + static var providerSection: Section { let providers = self.providers.map { Item(title: $0.name) } let header = "Identity Providers" let footer = "Choose a login flow from one of the identity providers above." return Section(headerDescription: header, footerDescription: footer, items: providers) } - + static var emailPasswordSection: Section { let image = UIImage(named: "firebaseIcon") let header = "Email and Password Login" let item = Item(title: AuthMenu.emailPassword.name, hasNestedContent: true, image: image) return Section(headerDescription: header, items: [item]) } - + static var otherSection: Section { let lockSymbol = UIImage.systemImage("lock.slash.fill", tintColor: .systemOrange) let phoneSymbol = UIImage.systemImage("phone.fill", tintColor: .systemOrange) let anonSymbol = UIImage.systemImage("questionmark.circle.fill", tintColor: .systemOrange) let shieldSymbol = UIImage.systemImage("lock.shield.fill", tintColor: .systemOrange) - + let otherOptions = [ Item(title: AuthMenu.passwordless.name, image: lockSymbol), Item(title: AuthMenu.phoneNumber.name, image: phoneSymbol), @@ -269,21 +269,21 @@ class AuthMenuData: DataSourceProvidable { let header = "Other Authentication Methods" return Section(headerDescription: header, items: otherOptions) } - + static var recaptchaSection: Section { let image = UIImage(named: "firebaseIcon") let header = "Initialize reCAPTCHA Enterprise" let item = Item(title: AuthMenu.initRecaptcha.name, hasNestedContent: false, image: image) return Section(headerDescription: header, items: [item]) } - + static var customAuthDomainSection: Section { let image = UIImage(named: "firebaseIcon") let header = "Custom Auth Domain" let item = Item(title: AuthMenu.customAuthDomain.name, hasNestedContent: false, image: image) return Section(headerDescription: header, items: [item]) } - + static var appSection: Section { let header = "APP" let items: [Item] = [ @@ -298,7 +298,7 @@ class AuthMenuData: DataSourceProvidable { ] return Section(headerDescription: header, items: items) } - + static var oobSection: Section { let header = "OOB" let items: [Item] = [ @@ -313,18 +313,18 @@ class AuthMenuData: DataSourceProvidable { ] return Section(headerDescription: header, items: items) } - + static var sections: [Section] = - [settingsSection, providerSection, emailPasswordSection, otherSection, recaptchaSection, - customAuthDomainSection, appSection, oobSection] - + [settingsSection, providerSection, emailPasswordSection, otherSection, recaptchaSection, + customAuthDomainSection, appSection, oobSection] + static var authLinkSections: [Section] { let allItems = AuthMenuData.sections.flatMap { $0.items } let header = "Manage linking between providers" let footer = - "Select an unchecked row to link the currently signed in user to that auth provider. To unlink the user from a linked provider, select its corresponding row marked with a checkmark." + "Select an unchecked row to link the currently signed in user to that auth provider. To unlink the user from a linked provider, select its corresponding row marked with a checkmark." return [Section(headerDescription: header, footerDescription: footer, items: allItems)] } - + var sections: [Section] = AuthMenuData.sections } diff --git a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/Utility/DataSourceProvider/DataSourceProvider.swift b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/Utility/DataSourceProvider/DataSourceProvider.swift index d500f07d2c3..12b0b1e9084 100644 --- a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/Utility/DataSourceProvider/DataSourceProvider.swift +++ b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/Utility/DataSourceProvider/DataSourceProvider.swift @@ -1,29 +1,29 @@ - // Copyright 2020 Google LLC - // - // Licensed under the Apache License, Version 2.0 (the "License"); - // you may not use this file except in compliance with the License. - // You may obtain a copy of the License at - // - // http://www.apache.org/licenses/LICENSE-2.0 - // - // Unless required by applicable law or agreed to in writing, software - // distributed under the License is distributed on an "AS IS" BASIS, - // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - // See the License for the specific language governing permissions and - // limitations under the License. +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. import UIKit - /// Abstracts away view/view controller based tableview configuration by acting as a tableview's - /// datasource and delegate +/// Abstracts away view/view controller based tableview configuration by acting as a tableview's +/// datasource and delegate class DataSourceProvider: NSObject, UITableViewDataSource, - UITableViewDelegate { + UITableViewDelegate { weak var delegate: DataSourceProviderDelegate? - + private var emptyView: UIView? - + private var sections: [DataSource.Section]! - + convenience init(dataSource: [DataSource.Section]?, emptyStateView: UIView? = nil, tableView: UITableView? = nil) { self.init() @@ -32,90 +32,90 @@ class DataSourceProvider: NSObject, UITableVie tableView?.dataSource = self tableView?.delegate = self } - - // MARK: Public Section and Item Getters - + + // MARK: Public Section and Item Getters + public func section(at indexPath: IndexPath) -> DataSource.Section { return sections[indexPath.section] } - + public func item(at indexPath: IndexPath) -> DataSource.Section.Item { return sectionItem(at: indexPath) } - + public func updateItem(at indexPath: IndexPath, item: Item) -> DataSource.Section.Item { return editSectionItem(at: indexPath, item: item) } - - // MARK: - UITableViewDataSource - + + // MARK: - UITableViewDataSource + func numberOfSections(in tableView: UITableView) -> Int { updateBackgroundViewIfNeeded(for: tableView) - + return sections.count } - + func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return sections[section].items.count } - + func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat { return sections[section].headerDescription?.isEmpty ?? true ? 20 : 40 } - + func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? { var label = UILabel() let section = sections[section] config(&label, for: section) return label } - + func tableView(_ tableView: UITableView, titleForFooterInSection section: Int) -> String? { return sections[section].footerDescription } - + func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { var cell = tableView.dequeueReusableCell(withIdentifier: "cell") - ?? UITableViewCell(style: .subtitle, reuseIdentifier: "cell") + ?? UITableViewCell(style: .subtitle, reuseIdentifier: "cell") let item = sectionItem(at: indexPath) config(&cell, for: item) return cell } - - // MARK: - UITableViewDelegate - + + // MARK: - UITableViewDelegate + func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { tableView.deselectRow(at: indexPath, animated: true) delegate?.didSelectRowAt(indexPath, on: tableView) } - + func scrollViewDidScroll(_ scrollView: UIScrollView) { guard let tableView = scrollView as? UITableView else { return } delegate?.tableViewDidScroll(tableView) } - - // MARK: - Private Helpers - + + // MARK: - Private Helpers + private func updateBackgroundViewIfNeeded(for tableView: UITableView) { tableView.backgroundView = sections.isEmpty ? emptyView : nil tableView.isScrollEnabled = !sections.isEmpty } - + private func sectionItem(at indexPath: IndexPath) -> DataSource.Section.Item { return sections[indexPath.section].items[indexPath.row] } - + private func editSectionItem(at indexPath: IndexPath, item: Item) -> DataSource.Section.Item { sections[indexPath.section].items[indexPath.row] = item as! DataSource.Section.Item return sectionItem(at: indexPath) } - + private func config(_ label: inout UILabel, for section: DataSource.Section) { label.text = section.headerDescription label.textColor = .label label.font = UIFont.boldSystemFont(ofSize: 19.0) } - + private func config(_ cell: inout UITableViewCell, for item: DataSource.Section.Item) { cell.textLabel?.text = item.title cell.textLabel?.textColor = item.textColor @@ -126,7 +126,7 @@ class DataSourceProvider: NSObject, UITableVie cell.accessoryType = item.hasNestedContent ? .disclosureIndicator : .none cell.accessoryType = item.isChecked ? .checkmark : cell.accessoryType } - + private func editableImageView() -> UIImageView { let image = UIImage(systemName: "pencil")? .withTintColor(.systemOrange, renderingMode: .alwaysOriginal) From 22358a21b1f6107f5735f74f8a5cf2e293106645 Mon Sep 17 00:00:00 2001 From: Pragati Date: Tue, 9 Apr 2024 16:48:51 -0700 Subject: [PATCH 26/34] undo whitespace changes --- .../ViewControllers/AuthViewController.swift | 393 +++++++++--------- 1 file changed, 196 insertions(+), 197 deletions(-) diff --git a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/AuthViewController.swift b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/AuthViewController.swift index 9fa3139dac9..a0e762dc2c6 100644 --- a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/AuthViewController.swift +++ b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/AuthViewController.swift @@ -1,29 +1,29 @@ - // Copyright 2020 Google LLC - // - // Licensed under the Apache License, Version 2.0 (the "License"); - // you may not use this file except in compliance with the License. - // You may obtain a copy of the License at - // - // http://www.apache.org/licenses/LICENSE-2.0 - // - // Unless required by applicable law or agreed to in writing, software - // distributed under the License is distributed on an "AS IS" BASIS, - // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - // See the License for the specific language governing permissions and - // limitations under the License. +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. @testable import FirebaseAuth - - // For Sign in with Facebook +// For Sign in with Facebook import FBSDKLoginKit - // [START auth_import] +@testable import FirebaseAuth +// [START auth_import] import FirebaseCore import GameKit - // For Sign in with Google - // [START google_import] +// For Sign in with Google +// [START google_import] import GoogleSignIn import UIKit - // For Sign in with Apple +// For Sign in with Apple import AuthenticationServices import CryptoKit @@ -31,175 +31,174 @@ private let kFacebookAppID = "ENTER APP ID HERE" private let kContinueUrl = "Enter URL" class AuthViewController: UIViewController, DataSourceProviderDelegate { - // var tableView: UITableView { view as! UITableView } var dataSourceProvider: DataSourceProvider! var authStateDidChangeListeners: [AuthStateDidChangeListenerHandle] = [] var IDTokenDidChangeListeners: [IDTokenDidChangeListenerHandle] = [] var actionCodeContinueURL: URL? var actionCodeRequestType: ActionCodeRequestType = .inApp - + let spinner = UIActivityIndicatorView(style: .medium) var tableView: UITableView { view as! UITableView } - + override func loadView() { view = UITableView(frame: .zero, style: .insetGrouped) } - + override func viewDidLoad() { super.viewDidLoad() configureNavigationBar() configureDataSourceProvider() } - + private func showSpinner() { spinner.center = view.center spinner.startAnimating() view.addSubview(spinner) } - + private func hideSpinner() { spinner.stopAnimating() spinner.removeFromSuperview() } - + private func actionCodeSettings() -> ActionCodeSettings { let settings = ActionCodeSettings() settings.url = actionCodeContinueURL settings.handleCodeInApp = (actionCodeRequestType == .inApp) return settings } - - // MARK: - DataSourceProviderDelegate - + + // MARK: - DataSourceProviderDelegate + func didSelectRowAt(_ indexPath: IndexPath, on tableView: UITableView) { let item = dataSourceProvider.item(at: indexPath) - - let providerName = item.title! - + + let providerName = item.isEditable ? item.detailTitle! : item.title! + guard let provider = AuthMenu(rawValue: providerName) else { - // The row tapped has no affiliated action. + // The row tapped has no affiliated action. return } - + switch provider { case .settings: performSettings() - + case .google: performGoogleSignInFlow() - + case .apple: performAppleSignInFlow() - + case .facebook: performFacebookSignInFlow() - + case .twitter, .microsoft, .gitHub, .yahoo: performOAuthLoginFlow(for: provider) - + case .gameCenter: performGameCenterLoginFlow() - + case .emailPassword: performDemoEmailPasswordLoginFlow() - + case .passwordless: performPasswordlessLoginFlow() - + case .phoneNumber: performPhoneNumberLoginFlow() - + case .anonymous: performAnonymousLoginFlow() - + case .custom: performCustomAuthLoginFlow() - + case .initRecaptcha: performInitRecaptcha() - + case .customAuthDomain: performCustomAuthDomainFlow() - + case .getToken: getUserTokenResult(force: false) - + case .getTokenForceRefresh: getUserTokenResult(force: true) - + case .addAuthStateChangeListener: addAuthStateListener() - + case .removeLastAuthStateChangeListener: removeAuthStateListener() - + case .addIdTokenChangeListener: addIDTokenListener() - + case .removeLastIdTokenChangeListener: removeIDTokenListener() - + case .verifyClient: verifyClient() - + case .deleteApp: deleteApp() - + case .actionType: toggleActionCodeRequestType(at: indexPath) - + case .continueURL: changeActionCodeContinueURL(at: indexPath) - + case .requestVerifyEmail: requestVerifyEmail() - + case .requestPasswordReset: requestPasswordReset() - + case .resetPassword: resetPassword() - + case .checkActionCode: checkActionCode() - + case .applyActionCode: applyActionCode() - + case .verifyPasswordResetCode: verifyPasswordResetCode() } - - // MARK: - Firebase 🔥 - + + // MARK: - Firebase 🔥 + private func performSettings() { let settingsController = SettingsViewController() navigationController?.pushViewController(settingsController, animated: true) } - + private func performGoogleSignInFlow() { - // [START headless_google_auth] + // [START headless_google_auth] guard let clientID = FirebaseApp.app()?.options.clientID else { return } - - // Create Google Sign In configuration object. - // [START_EXCLUDE silent] - // TODO: Move configuration to Info.plist - // [END_EXCLUDE] + + // Create Google Sign In configuration object. + // [START_EXCLUDE silent] + // TODO: Move configuration to Info.plist + // [END_EXCLUDE] let config = GIDConfiguration(clientID: clientID) GIDSignIn.sharedInstance.configuration = config - - // Start the sign in flow! + + // Start the sign in flow! GIDSignIn.sharedInstance.signIn(withPresenting: self) { [unowned self] result, error in guard error == nil else { - // [START_EXCLUDE] + // [START_EXCLUDE] return displayError(error) - // [END_EXCLUDE] + // [END_EXCLUDE] } - + guard let user = result?.user, let idToken = user.idToken?.tokenString else { - // [START_EXCLUDE] + // [START_EXCLUDE] let error = NSError( domain: "GIDSignInError", code: -1, @@ -208,38 +207,38 @@ class AuthViewController: UIViewController, DataSourceProviderDelegate { ] ) return displayError(error) - // [END_EXCLUDE] + // [END_EXCLUDE] } - + let credential = GoogleAuthProvider.credential(withIDToken: idToken, accessToken: user.accessToken.tokenString) - - // [START_EXCLUDE] + + // [START_EXCLUDE] signIn(with: credential) - // [END_EXCLUDE] + // [END_EXCLUDE] } - // [END headless_google_auth] + // [END headless_google_auth] } - + func signIn(with credential: AuthCredential) { - // [START signin_google_credential] + // [START signin_google_credential] AppManager.shared.auth().signIn(with: credential) { result, error in - // [START_EXCLUDE silent] + // [START_EXCLUDE silent] guard error == nil else { return self.displayError(error) } - // [END_EXCLUDE] - - // At this point, our user is signed in - // [START_EXCLUDE silent] - // so we advance to the User View Controller + // [END_EXCLUDE] + + // At this point, our user is signed in + // [START_EXCLUDE silent] + // so we advance to the User View Controller self.transitionToUserViewController() - // [END_EXCLUDE] + // [END_EXCLUDE] } - // [END signin_google_credential] + // [END signin_google_credential] } - - // For Sign in with Apple + + // For Sign in with Apple var currentNonce: String? - + private func performAppleSignInFlow() { do { let nonce = try CryptoUtils.randomNonceString() @@ -248,23 +247,23 @@ class AuthViewController: UIViewController, DataSourceProviderDelegate { let request = appleIDProvider.createRequest() request.requestedScopes = [.fullName, .email] request.nonce = CryptoUtils.sha256(nonce) - + let authorizationController = ASAuthorizationController(authorizationRequests: [request]) authorizationController.delegate = self authorizationController.presentationContextProvider = self authorizationController.performRequests() } catch { - // In the unlikely case that nonce generation fails, show error view. + // In the unlikely case that nonce generation fails, show error view. displayError(error) } } - + private func performFacebookSignInFlow() { - // The following config can also be stored in the project's .plist + // The following config can also be stored in the project's .plist Settings.shared.appID = kFacebookAppID Settings.shared.displayName = "AuthenticationExample" - - // Create a Facebook `LoginManager` instance + + // Create a Facebook `LoginManager` instance let loginManager = LoginManager() loginManager.logIn(permissions: ["email"], from: self) { result, error in guard error == nil else { return self.displayError(error) } @@ -273,10 +272,10 @@ class AuthViewController: UIViewController, DataSourceProviderDelegate { self.signin(with: credential) } } - - // Maintain a strong reference to an OAuthProvider for login + + // Maintain a strong reference to an OAuthProvider for login private var oauthProvider: OAuthProvider! - + private func performOAuthLoginFlow(for provider: AuthMenu) { oauthProvider = OAuthProvider(providerID: provider.id) oauthProvider.getCredentialWith(nil) { credential, error in @@ -285,85 +284,85 @@ class AuthViewController: UIViewController, DataSourceProviderDelegate { self.signin(with: credential) } } - + private func performGameCenterLoginFlow() { - // Step 1: System Game Center Login + // Step 1: System Game Center Login GKLocalPlayer.local.authenticateHandler = { viewController, error in if let error = error { - // Handle Game Center login error + // Handle Game Center login error print("Error logging into Game Center: \(error.localizedDescription)") } else if let authViewController = viewController { - // Present Game Center login UI if needed + // Present Game Center login UI if needed self.present(authViewController, animated: true) } else { - // Game Center login successful, proceed to Firebase + // Game Center login successful, proceed to Firebase self.linkGameCenterToFirebase() } } } - - // Step 2: Link to Firebase + + // Step 2: Link to Firebase private func linkGameCenterToFirebase() { GameCenterAuthProvider.getCredential { credential, error in if let error = error { - // Handle Firebase credential retrieval error + // Handle Firebase credential retrieval error print("Error getting Game Center credential: \(error.localizedDescription)") } else if let credential = credential { Auth.auth().signIn(with: credential) { authResult, error in if let error = error { - // Handle Firebase sign-in error + // Handle Firebase sign-in error print("Error signing into Firebase with Game Center: \(error.localizedDescription)") } else { - // Firebase sign-in successful + // Firebase sign-in successful print("Successfully linked Game Center to Firebase") } } } } } - + private func performDemoEmailPasswordLoginFlow() { let loginController = LoginController() loginController.delegate = self navigationController?.pushViewController(loginController, animated: true) } - + private func performPasswordlessLoginFlow() { let passwordlessViewController = PasswordlessViewController() passwordlessViewController.delegate = self let navPasswordlessAuthController = - UINavigationController(rootViewController: passwordlessViewController) + UINavigationController(rootViewController: passwordlessViewController) navigationController?.present(navPasswordlessAuthController, animated: true) } - + private func performPhoneNumberLoginFlow() { let phoneAuthViewController = PhoneAuthViewController() phoneAuthViewController.delegate = self let navPhoneAuthController = UINavigationController(rootViewController: phoneAuthViewController) navigationController?.present(navPhoneAuthController, animated: true) } - + private func performAnonymousLoginFlow() { AppManager.shared.auth().signInAnonymously { result, error in guard error == nil else { return self.displayError(error) } self.transitionToUserViewController() } } - + private func performCustomAuthLoginFlow() { let customAuthController = CustomAuthViewController() customAuthController.delegate = self let navCustomAuthController = UINavigationController(rootViewController: customAuthController) navigationController?.present(navCustomAuthController, animated: true) } - + private func signin(with credential: AuthCredential) { AppManager.shared.auth().signIn(with: credential) { result, error in guard error == nil else { return self.displayError(error) } self.transitionToUserViewController() } } - + private func performInitRecaptcha() { Task { do { @@ -374,25 +373,25 @@ class AuthViewController: UIViewController, DataSourceProviderDelegate { } } } - + private func performCustomAuthDomainFlow() { showTextInputPrompt(with: "Enter Custom Auth Domain For Auth: ", completion: { newDomain in AppManager.shared.auth().customAuthDomain = newDomain }) } - + private func getUserTokenResult(force: Bool) { guard let currentUser = Auth.auth().currentUser else { print("Error: No user logged in") return } - + currentUser.getIDTokenResult(forcingRefresh: force, completion: { tokenResult, error in if error != nil { print("Error: Error refreshing token") return // Handle error case, returning early } - + if let tokenResult = tokenResult, let claims = tokenResult.claims as? [String: Any] { var message = "Token refresh succeeded\n\n" for (key, value) in claims { @@ -404,7 +403,7 @@ class AuthViewController: UIViewController, DataSourceProviderDelegate { } }) } - + private func addAuthStateListener() { weak var weakSelf = self let index = authStateDidChangeListeners.count @@ -415,7 +414,7 @@ class AuthViewController: UIViewController, DataSourceProviderDelegate { } authStateDidChangeListeners.append(handle) } - + private func removeAuthStateListener() { guard !authStateDidChangeListeners.isEmpty else { print("No remaining Auth State Did Change Listeners.") @@ -427,7 +426,7 @@ class AuthViewController: UIViewController, DataSourceProviderDelegate { authStateDidChangeListeners.removeLast() print("Auth State Did Change Listener #\(index) was removed.") } - + private func addIDTokenListener() { weak var weakSelf = self let index = IDTokenDidChangeListeners.count @@ -438,7 +437,7 @@ class AuthViewController: UIViewController, DataSourceProviderDelegate { } IDTokenDidChangeListeners.append(handle) } - + private func removeIDTokenListener() { guard !IDTokenDidChangeListeners.isEmpty else { print("No remaining ID Token Did Change Listeners.") @@ -450,7 +449,7 @@ class AuthViewController: UIViewController, DataSourceProviderDelegate { IDTokenDidChangeListeners.removeLast() print("ID Token Did Change Listener #\(index) was removed.") } - + private func verifyClient() { AppManager.shared.auth().tokenManager.getTokenInternal { token, error in if token == nil { @@ -462,17 +461,17 @@ class AuthViewController: UIViewController, DataSourceProviderDelegate { isSandbox: token?.type == .sandbox, requestConfiguration: AppManager.shared.auth().requestConfiguration ) - + Task { do { let verifyResponse = try await AuthBackend.call(with: request) - + guard let receipt = verifyResponse.receipt, let timeoutDate = verifyResponse.suggestedTimeOutDate else { print("Internal Auth Error: invalid VerifyClientResponse.") return } - + let timeout = timeoutDate.timeIntervalSinceNow do { let credential = await AppManager.shared.auth().appCredentialManager @@ -480,19 +479,19 @@ class AuthViewController: UIViewController, DataSourceProviderDelegate { withReceipt: receipt, timeout: timeout ) - + guard credential.secret != nil else { print("Failed to receive remote notification to verify App ID.") return } - + let testPhoneNumber = "+16509964692" let request = SendVerificationCodeRequest( phoneNumber: testPhoneNumber, codeIdentity: CodeIdentity.credential(credential), requestConfiguration: AppManager.shared.auth().requestConfiguration ) - + do { _ = try await AuthBackend.call(with: request) print("Verify iOS client succeeded") @@ -506,7 +505,7 @@ class AuthViewController: UIViewController, DataSourceProviderDelegate { } } } - + private func deleteApp() { AppManager.shared.app.delete { success in if success { @@ -516,7 +515,7 @@ class AuthViewController: UIViewController, DataSourceProviderDelegate { } } } - + private func toggleActionCodeRequestType(at indexPath: IndexPath) { switch actionCodeRequestType { case .inApp: @@ -532,7 +531,7 @@ class AuthViewController: UIViewController, DataSourceProviderDelegate { ) tableView.reloadData() } - + private func changeActionCodeContinueURL(at indexPath: IndexPath) { showTextInputPrompt(with: "Continue URL:", completion: { newContinueURL in self.actionCodeContinueURL = URL(string: newContinueURL) @@ -548,13 +547,13 @@ class AuthViewController: UIViewController, DataSourceProviderDelegate { self.tableView.reloadData() }) } - + private func requestVerifyEmail() { showSpinner() let completionHandler: (Error?) -> Void = { [weak self] error in guard let self = self else { return } self.hideSpinner() - + if let error = error { let errorMessage = "Error sending verification email: \(error.localizedDescription)" showAlert(for: errorMessage) @@ -578,7 +577,7 @@ class AuthViewController: UIViewController, DataSourceProviderDelegate { ) } } - + func requestPasswordReset() { showTextInputPrompt(with: "Email:", completion: { email in print("Sending password reset link to: \(email)") @@ -609,7 +608,7 @@ class AuthViewController: UIViewController, DataSourceProviderDelegate { } }) } - + private func resetPassword() { showSpinner() let completionHandler: (Error?) -> Void = { [weak self] error in @@ -635,7 +634,7 @@ class AuthViewController: UIViewController, DataSourceProviderDelegate { } } } - + private func nameForActionCodeOperation(_ operation: ActionCodeOperation) -> String { switch operation { case .verifyEmail: @@ -654,7 +653,7 @@ class AuthViewController: UIViewController, DataSourceProviderDelegate { return "Unknown action" } } - + private func checkActionCode() { showSpinner() let completionHandler: (ActionCodeInfo?, Error?) -> Void = { [weak self] info, error in @@ -678,7 +677,7 @@ class AuthViewController: UIViewController, DataSourceProviderDelegate { AppManager.shared.auth().checkActionCode(oobCode, completion: completionHandler) } } - + private func applyActionCode() { showSpinner() let completionHandler: (Error?) -> Void = { [weak self] error in @@ -697,7 +696,7 @@ class AuthViewController: UIViewController, DataSourceProviderDelegate { AppManager.shared.auth().applyActionCode(oobCode, completion: completionHandler) } } - + private func verifyPasswordResetCode() { showSpinner() let completionHandler: (String?, Error?) -> Void = { [weak self] email, error in @@ -716,9 +715,9 @@ class AuthViewController: UIViewController, DataSourceProviderDelegate { AppManager.shared.auth().verifyPasswordResetCode(oobCode, completion: completionHandler) } } - - // MARK: - Private Helpers - + + // MARK: - Private Helpers + private func showTextInputPrompt(with message: String, completion: ((String) -> Void)? = nil) { let editController = UIAlertController( title: message, @@ -726,48 +725,48 @@ class AuthViewController: UIViewController, DataSourceProviderDelegate { preferredStyle: .alert ) editController.addTextField() - + let saveHandler: (UIAlertAction) -> Void = { _ in let text = editController.textFields?.first?.text ?? "" completion?(text) // completion?() } - + let cancelHandler: (UIAlertAction) -> Void = { _ in completion?("") // completion?() } - + editController.addAction(UIAlertAction(title: "Save", style: .default, handler: saveHandler)) editController.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: cancelHandler)) - + // Assuming `self` is a view controller present(editController, animated: true, completion: nil) } - + private func showQRCodePromptWithTextInput(with message: String, url: String, completion: ((String) -> Void)? = nil) { // Create a UIAlertController let alertController = UIAlertController(title: "QR Code Prompt", message: message, preferredStyle: .alert) - + // Add a text field for input alertController.addTextField { (textField) in textField.placeholder = "Enter text" } - + // Create a UIImage from the URL guard let image = generateQRCode(from: url) else { print("Failed to generate QR code") return } - + // Create an image view to display the QR code let imageView = UIImageView(image: image) imageView.contentMode = .scaleAspectFit imageView.translatesAutoresizingMaskIntoConstraints = false - + // Add the image view to the alert controller alertController.view.addSubview(imageView) - + // Add constraints to position the image view NSLayoutConstraint.activate([ imageView.topAnchor.constraint(equalTo: alertController.view.topAnchor, constant: 20), @@ -775,7 +774,7 @@ class AuthViewController: UIViewController, DataSourceProviderDelegate { imageView.widthAnchor.constraint(equalToConstant: 200), imageView.heightAnchor.constraint(equalToConstant: 200) ]) - + // Add actions let cancelAction = UIAlertAction(title: "Cancel", style: .cancel, handler: nil) let submitAction = UIAlertAction(title: "Submit", style: .default) { (_) in @@ -783,30 +782,30 @@ class AuthViewController: UIViewController, DataSourceProviderDelegate { completion?(text) } } - + alertController.addAction(cancelAction) alertController.addAction(submitAction) - + // Present the alert controller UIApplication.shared.windows.first?.rootViewController?.present(alertController, animated: true, completion: nil) } - + // Function to generate QR code from a string private func generateQRCode(from string: String) -> UIImage? { let data = string.data(using: String.Encoding.ascii) - + if let filter = CIFilter(name: "CIQRCodeGenerator") { filter.setValue(data, forKey: "inputMessage") let transform = CGAffineTransform(scaleX: 10, y: 10) - + if let output = filter.outputImage?.transformed(by: transform) { return UIImage(ciImage: output) } } - + return nil } - + func showAlert(for message: String) { let alertController = UIAlertController( title: message, @@ -815,7 +814,7 @@ class AuthViewController: UIViewController, DataSourceProviderDelegate { ) alertController.addAction(UIAlertAction(title: "OK", style: UIAlertAction.Style.default)) } - + private func configureDataSourceProvider() { dataSourceProvider = DataSourceProvider( dataSource: AuthMenuData.sections, @@ -823,7 +822,7 @@ class AuthViewController: UIViewController, DataSourceProviderDelegate { ) dataSourceProvider.delegate = self } - + private func configureNavigationBar() { navigationItem.title = "Firebase Auth" guard let navigationBar = navigationController?.navigationBar else { return } @@ -831,9 +830,9 @@ class AuthViewController: UIViewController, DataSourceProviderDelegate { navigationBar.titleTextAttributes = [.foregroundColor: UIColor.systemOrange] navigationBar.largeTitleTextAttributes = [.foregroundColor: UIColor.systemOrange] } - + private func transitionToUserViewController() { - // UserViewController is at index 1 in the tabBarController.viewControllers array + // UserViewController is at index 1 in the tabBarController.viewControllers array tabBarController?.transitionToViewController(atIndex: 1) } } @@ -843,15 +842,15 @@ class AuthViewController: UIViewController, DataSourceProviderDelegate { extension AuthViewController: LoginDelegate { public func loginDidOccur() { transitionToUserViewController() - } + } } // MARK: - Implementing Sign in with Apple with Firebase extension AuthViewController: ASAuthorizationControllerDelegate, - ASAuthorizationControllerPresentationContextProviding { + ASAuthorizationControllerPresentationContextProviding { // MARK: ASAuthorizationControllerDelegate - + func authorizationController(controller: ASAuthorizationController, didCompleteWithAuthorization authorization: ASAuthorization) { guard let appleIDCredential = authorization.credential as? ASAuthorizationAppleIDCredential @@ -859,11 +858,11 @@ extension AuthViewController: ASAuthorizationControllerDelegate, print("Unable to retrieve AppleIDCredential") return } - + guard let nonce = currentNonce else { fatalError("Invalid state: A login callback was received, but no login request was sent.") } - + guard let appleIDToken = appleIDCredential.identityToken else { print("Unable to fetch identity token") return @@ -876,39 +875,39 @@ extension AuthViewController: ASAuthorizationControllerDelegate, print("Unable to serialize token string from data: \(appleIDToken.debugDescription)") return } - + guard let _ = String(data: appleAuthCode, encoding: .utf8) else { print("Unable to serialize auth code string from data: \(appleAuthCode.debugDescription)") return } - - // use this call to create the authentication credential and set the user's full name + + // use this call to create the authentication credential and set the user's full name let credential = OAuthProvider.appleCredential(withIDToken: idTokenString, rawNonce: nonce, fullName: appleIDCredential.fullName) - + AppManager.shared.auth().signIn(with: credential) { result, error in - // Error. If error.code == .MissingOrInvalidNonce, make sure - // you're sending the SHA256-hashed nonce as a hex string with - // your request to Apple. + // Error. If error.code == .MissingOrInvalidNonce, make sure + // you're sending the SHA256-hashed nonce as a hex string with + // your request to Apple. guard error == nil else { return self.displayError(error) } - - // At this point, our user is signed in - // so we advance to the User View Controller + + // At this point, our user is signed in + // so we advance to the User View Controller self.transitionToUserViewController() } } - + func authorizationController(controller: ASAuthorizationController, didCompleteWithError error: Error) { - // Ensure that you have: - // - enabled `Sign in with Apple` on the Firebase console - // - added the `Sign in with Apple` capability for this project + // Ensure that you have: + // - enabled `Sign in with Apple` on the Firebase console + // - added the `Sign in with Apple` capability for this project print("Sign in with Apple failed: \(error)") } - - // MARK: ASAuthorizationControllerPresentationContextProviding - + + // MARK: ASAuthorizationControllerPresentationContextProviding + func presentationAnchor(for controller: ASAuthorizationController) -> ASPresentationAnchor { return view.window! } From fb323ae25ec040ced3e91dd6de4e5ee97dad8fe8 Mon Sep 17 00:00:00 2001 From: Pragati Date: Tue, 9 Apr 2024 17:38:02 -0700 Subject: [PATCH 27/34] fix bracket --- .../ViewControllers/AuthViewController.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/AuthViewController.swift b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/AuthViewController.swift index a0e762dc2c6..e0f4acbad52 100644 --- a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/AuthViewController.swift +++ b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/AuthViewController.swift @@ -167,6 +167,7 @@ class AuthViewController: UIViewController, DataSourceProviderDelegate { case .verifyPasswordResetCode: verifyPasswordResetCode() + } } // MARK: - Firebase 🔥 From f5d8b4f78185ee63b51272efd2549232ad0bd662 Mon Sep 17 00:00:00 2001 From: Pragati Date: Tue, 9 Apr 2024 17:44:28 -0700 Subject: [PATCH 28/34] lint --- .../ViewControllers/AuthViewController.swift | 52 +++++++++++-------- 1 file changed, 30 insertions(+), 22 deletions(-) diff --git a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/AuthViewController.swift b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/AuthViewController.swift index e0f4acbad52..7eaac6f31f8 100644 --- a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/AuthViewController.swift +++ b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/AuthViewController.swift @@ -1,3 +1,5 @@ +// For Sign in with Facebook +import FBSDKLoginKit // Copyright 2020 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -12,9 +14,6 @@ // See the License for the specific language governing permissions and // limitations under the License. @testable import FirebaseAuth -// For Sign in with Facebook -import FBSDKLoginKit -@testable import FirebaseAuth // [START auth_import] import FirebaseCore import GameKit @@ -167,7 +166,7 @@ class AuthViewController: UIViewController, DataSourceProviderDelegate { case .verifyPasswordResetCode: verifyPasswordResetCode() - } + } } // MARK: - Firebase 🔥 @@ -730,55 +729,60 @@ class AuthViewController: UIViewController, DataSourceProviderDelegate { let saveHandler: (UIAlertAction) -> Void = { _ in let text = editController.textFields?.first?.text ?? "" completion?(text) - // completion?() + // completion?() } let cancelHandler: (UIAlertAction) -> Void = { _ in completion?("") - // completion?() + // completion?() } editController.addAction(UIAlertAction(title: "Save", style: .default, handler: saveHandler)) editController.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: cancelHandler)) - // Assuming `self` is a view controller + // Assuming `self` is a view controller present(editController, animated: true, completion: nil) } - private func showQRCodePromptWithTextInput(with message: String, url: String, completion: ((String) -> Void)? = nil) { - // Create a UIAlertController - let alertController = UIAlertController(title: "QR Code Prompt", message: message, preferredStyle: .alert) + private func showQRCodePromptWithTextInput(with message: String, url: String, + completion: ((String) -> Void)? = nil) { + // Create a UIAlertController + let alertController = UIAlertController( + title: "QR Code Prompt", + message: message, + preferredStyle: .alert + ) - // Add a text field for input - alertController.addTextField { (textField) in + // Add a text field for input + alertController.addTextField { textField in textField.placeholder = "Enter text" } - // Create a UIImage from the URL + // Create a UIImage from the URL guard let image = generateQRCode(from: url) else { print("Failed to generate QR code") return } - // Create an image view to display the QR code + // Create an image view to display the QR code let imageView = UIImageView(image: image) imageView.contentMode = .scaleAspectFit imageView.translatesAutoresizingMaskIntoConstraints = false - // Add the image view to the alert controller + // Add the image view to the alert controller alertController.view.addSubview(imageView) - // Add constraints to position the image view + // Add constraints to position the image view NSLayoutConstraint.activate([ imageView.topAnchor.constraint(equalTo: alertController.view.topAnchor, constant: 20), imageView.centerXAnchor.constraint(equalTo: alertController.view.centerXAnchor), imageView.widthAnchor.constraint(equalToConstant: 200), - imageView.heightAnchor.constraint(equalToConstant: 200) + imageView.heightAnchor.constraint(equalToConstant: 200), ]) - // Add actions + // Add actions let cancelAction = UIAlertAction(title: "Cancel", style: .cancel, handler: nil) - let submitAction = UIAlertAction(title: "Submit", style: .default) { (_) in + let submitAction = UIAlertAction(title: "Submit", style: .default) { _ in if let text = alertController.textFields?.first?.text { completion?(text) } @@ -787,11 +791,15 @@ class AuthViewController: UIViewController, DataSourceProviderDelegate { alertController.addAction(cancelAction) alertController.addAction(submitAction) - // Present the alert controller - UIApplication.shared.windows.first?.rootViewController?.present(alertController, animated: true, completion: nil) + // Present the alert controller + UIApplication.shared.windows.first?.rootViewController?.present( + alertController, + animated: true, + completion: nil + ) } - // Function to generate QR code from a string + // Function to generate QR code from a string private func generateQRCode(from string: String) -> UIImage? { let data = string.data(using: String.Encoding.ascii) From 53f4dde10f37ae90bcb28efb38306862672b8ccf Mon Sep 17 00:00:00 2001 From: Pragati Date: Mon, 6 May 2024 14:51:36 -0700 Subject: [PATCH 29/34] oob-section changes --- .../ViewControllers/AuthViewController.swift | 49 +++---------------- 1 file changed, 7 insertions(+), 42 deletions(-) diff --git a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/AuthViewController.swift b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/AuthViewController.swift index 428f3345858..470cffbd9fa 100644 --- a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/AuthViewController.swift +++ b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/AuthViewController.swift @@ -1,5 +1,3 @@ -// For Sign in with Facebook -import FBSDKLoginKit // Copyright 2020 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -13,10 +11,16 @@ import FBSDKLoginKit // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -@testable import FirebaseAuth // [START auth_import] import FirebaseCore +@testable import FirebaseAuth + +// For Sign in with Facebook +import FBSDKLoginKit + +// For Sign in with Game Center import GameKit + // For Sign in with Google // [START google_import] import GoogleSignIn @@ -98,9 +102,6 @@ class AuthViewController: UIViewController, DataSourceProviderDelegate { case .gameCenter: performGameCenterLoginFlow() - case .gameCenter: - performGameCenterLoginFlow() - case .emailPassword: performDemoEmailPasswordLoginFlow() @@ -324,42 +325,6 @@ class AuthViewController: UIViewController, DataSourceProviderDelegate { } } - private func performGameCenterLoginFlow() { - // Step 1: System Game Center Login - GKLocalPlayer.local.authenticateHandler = { viewController, error in - if let error = error { - // Handle Game Center login error - print("Error logging into Game Center: \(error.localizedDescription)") - } else if let authViewController = viewController { - // Present Game Center login UI if needed - self.present(authViewController, animated: true) - } else { - // Game Center login successful, proceed to Firebase - self.linkGameCenterToFirebase() - } - } - } - - // Step 2: Link to Firebase - private func linkGameCenterToFirebase() { - GameCenterAuthProvider.getCredential { credential, error in - if let error = error { - // Handle Firebase credential retrieval error - print("Error getting Game Center credential: \(error.localizedDescription)") - } else if let credential = credential { - Auth.auth().signIn(with: credential) { authResult, error in - if let error = error { - // Handle Firebase sign-in error - print("Error signing into Firebase with Game Center: \(error.localizedDescription)") - } else { - // Firebase sign-in successful - print("Successfully linked Game Center to Firebase") - } - } - } - } - } - private func performDemoEmailPasswordLoginFlow() { let loginController = LoginController() loginController.delegate = self From e70c435a34f212d901aa7616e62cb7f945c24c16 Mon Sep 17 00:00:00 2001 From: Pragati Date: Mon, 6 May 2024 14:59:28 -0700 Subject: [PATCH 30/34] lint --- .../ViewControllers/AuthViewController.swift | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/AuthViewController.swift b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/AuthViewController.swift index 470cffbd9fa..7a78bcb0559 100644 --- a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/AuthViewController.swift +++ b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/AuthViewController.swift @@ -1,3 +1,5 @@ +@testable import FirebaseAuth + // Copyright 2020 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -13,7 +15,6 @@ // limitations under the License. // [START auth_import] import FirebaseCore -@testable import FirebaseAuth // For Sign in with Facebook import FBSDKLoginKit @@ -924,4 +925,4 @@ extension AuthViewController: ASAuthorizationControllerDelegate, func presentationAnchor(for controller: ASAuthorizationController) -> ASPresentationAnchor { return view.window! } -} \ No newline at end of file +} From ae791c99045b4ae3ccedf7332e968464ac7acfe6 Mon Sep 17 00:00:00 2001 From: Pragati Date: Mon, 6 May 2024 15:04:54 -0700 Subject: [PATCH 31/34] lint --- .../ViewControllers/AuthViewController.swift | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/AuthViewController.swift b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/AuthViewController.swift index 7a78bcb0559..79121e9abf7 100644 --- a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/AuthViewController.swift +++ b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/AuthViewController.swift @@ -788,8 +788,9 @@ class AuthViewController: UIViewController, DataSourceProviderDelegate { // Add actions let cancelAction = UIAlertAction(title: "Cancel", style: .cancel, handler: nil) let submitAction = UIAlertAction(title: "Submit", style: .default) { _ in - if let text = alertController.textFields?.first?.text { - completion?(text) + if let completion, + let text = alertController.textFields?.first?.text { + completion(text) } } From 20c6668fb08f200c9eb13af3fdd3a416fab0f398 Mon Sep 17 00:00:00 2001 From: Pragati Date: Mon, 6 May 2024 15:10:13 -0700 Subject: [PATCH 32/34] apply suggestions from code review --- .../ViewControllers/AuthViewController.swift | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/AuthViewController.swift b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/AuthViewController.swift index 79121e9abf7..88b9578ced3 100644 --- a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/AuthViewController.swift +++ b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/AuthViewController.swift @@ -733,13 +733,15 @@ class AuthViewController: UIViewController, DataSourceProviderDelegate { let saveHandler: (UIAlertAction) -> Void = { _ in let text = editController.textFields?.first?.text ?? "" - completion?(text) - // completion?() + if let completion { + completion(text) + } } let cancelHandler: (UIAlertAction) -> Void = { _ in - completion?("") - // completion?() + if let completion { + completion("") + } } editController.addAction(UIAlertAction(title: "Save", style: .default, handler: saveHandler)) From 63e01b90ac4ada0c15cb0e6147f14a8327ab9de2 Mon Sep 17 00:00:00 2001 From: Pragati Date: Mon, 6 May 2024 15:30:02 -0700 Subject: [PATCH 33/34] debugged --- .../SettingsViewController.swift | 152 +++++++----------- 1 file changed, 58 insertions(+), 94 deletions(-) diff --git a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/SettingsViewController.swift b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/SettingsViewController.swift index 73430ce5ed1..80129cd051a 100644 --- a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/SettingsViewController.swift +++ b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/SettingsViewController.swift @@ -1,22 +1,22 @@ -// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. + // Copyright 2023 Google LLC + // + // Licensed under the Apache License, Version 2.0 (the "License"); + // you may not use this file except in compliance with the License. + // You may obtain a copy of the License at + // + // http://www.apache.org/licenses/LICENSE-2.0 + // + // Unless required by applicable law or agreed to in writing, software + // distributed under the License is distributed on an "AS IS" BASIS, + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + // See the License for the specific language governing permissions and + // limitations under the License. @testable import FirebaseAuth import FirebaseCore import UIKit -/// Namespace for performable actions on a Auth Settings view + /// Namespace for performable actions on a Auth Settings view enum SettingsAction: String { case toggleIdentityTokenAPI = "Identity Toolkit" case toggleSecureTokenAPI = "Secure Token" @@ -31,43 +31,43 @@ enum SettingsAction: String { class SettingsViewController: UIViewController, DataSourceProviderDelegate { var dataSourceProvider: DataSourceProvider! - + var tableView: UITableView { view as! UITableView } - + private var _settings: AuthSettings? var settings: AuthSettings? { get { AppManager.shared.auth().settings } set { _settings = newValue } } - - // MARK: - UIViewController Life Cycle - + + // MARK: - UIViewController Life Cycle + override func loadView() { view = UITableView(frame: .zero, style: .insetGrouped) } - + override func viewDidLoad() { super.viewDidLoad() configureNavigationBar() } - + override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) configureDataSourceProvider() } - - // MARK: - DataSourceProviderDelegate - + + // MARK: - DataSourceProviderDelegate + func didSelectRowAt(_ indexPath: IndexPath, on tableView: UITableView) { let item = dataSourceProvider.item(at: indexPath) - + guard let actionName = item.detailTitle, let action = SettingsAction(rawValue: actionName) else { - // The row tapped has no affiliated action. + // The row tapped has no affiliated action. return } let auth = AppManager.shared.auth() - + switch action { case .toggleSecureTokenAPI: toggleSecureTokenAPI() @@ -93,9 +93,9 @@ class SettingsViewController: UIViewController, DataSourceProviderDelegate { } updateUI() } - - // MARK: - Firebase 🔥 - + + // MARK: - Firebase 🔥 + private func toggleIdentityTokenAPI() { if IdentityToolkitRequest.host == "www.googleapis.com" { IdentityToolkitRequest.setHost("staging-www.sandbox.googleapis.com") @@ -103,7 +103,7 @@ class SettingsViewController: UIViewController, DataSourceProviderDelegate { IdentityToolkitRequest.setHost("www.googleapis.com") } } - + private func toggleSecureTokenAPI() { if SecureTokenRequest.host == "securetoken.googleapis.com" { SecureTokenRequest.setHost("staging-securetoken.sandbox.googleapis.com") @@ -111,7 +111,7 @@ class SettingsViewController: UIViewController, DataSourceProviderDelegate { SecureTokenRequest.setHost("securetoken.googleapis.com") } } - + private func toggleAccessGroup() { if AppManager.shared.auth().userAccessGroup == nil { guard let bundleDictionary = Bundle.main.infoDictionary, @@ -123,15 +123,15 @@ class SettingsViewController: UIViewController, DataSourceProviderDelegate { AppManager.shared.auth().userAccessGroup = nil } } - + func clearAPNSToken() { guard let token = AppManager.shared.auth().tokenManager.token else { return } - + let tokenType = token.type == .prod ? "Production" : "Sandbox" let message = "token: \(token.string)\ntype: \(tokenType)" - + let prompt = UIAlertController(title: nil, message: "Clear APNs Token?", preferredStyle: .alert) let okAction = UIAlertAction(title: "OK", style: .default) { action in @@ -141,7 +141,7 @@ class SettingsViewController: UIViewController, DataSourceProviderDelegate { prompt.addAction(okAction) present(prompt, animated: true) } - + func clearAppCredential() { if let credential = AppManager.shared.auth().appCredentialManager.credential { let prompt = UIAlertController(title: nil, message: "Clear APNs Token?", @@ -154,7 +154,7 @@ class SettingsViewController: UIViewController, DataSourceProviderDelegate { present(prompt, animated: true) } } - + private func setAuthLanguage() { let prompt = UIAlertController(title: nil, message: "Enter Language Code For Auth:", preferredStyle: .alert) @@ -164,12 +164,12 @@ class SettingsViewController: UIViewController, DataSourceProviderDelegate { self.updateUI() } prompt.addAction(okAction) - + present(prompt, animated: true) } - - // MARK: - Private Helpers - + + // MARK: - Private Helpers + private func configureNavigationBar() { navigationItem.title = "Settings" guard let navigationBar = navigationController?.navigationBar else { return } @@ -177,7 +177,7 @@ class SettingsViewController: UIViewController, DataSourceProviderDelegate { navigationBar.titleTextAttributes = [.foregroundColor: UIColor.systemOrange] navigationBar.largeTitleTextAttributes = [.foregroundColor: UIColor.systemOrange] } - + private func configureDataSourceProvider() { dataSourceProvider = DataSourceProvider( dataSource: settings?.sections, @@ -186,35 +186,17 @@ class SettingsViewController: UIViewController, DataSourceProviderDelegate { ) dataSourceProvider.delegate = self } - + private func updateUI() { configureDataSourceProvider() animateUpdates(for: tableView) } - + private func animateUpdates(for tableView: UITableView) { UIView.transition(with: tableView, duration: 0.2, options: .transitionCrossDissolve, animations: { tableView.reloadData() }) } - - func showPromptWithTitle(_ title: String, message: String, showCancelButton: Bool, - completion: @escaping (Bool, String?) -> Void) { - let alertController = UIAlertController(title: title, message: message, preferredStyle: .alert) - - alertController.addAction(UIAlertAction(title: "OK", style: .default, handler: { _ in - let userInput = alertController.textFields?.first?.text - completion(true, userInput) - })) - - if showCancelButton { - alertController.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: { _ in - completion(false, nil) - })) - } - - alertController.addTextField(configurationHandler: nil) - } } // MARK: - Extending a `AuthSettings` to conform to `DataSourceProvidable` @@ -224,72 +206,54 @@ extension AuthSettings: DataSourceProvidable { let items = [Item(title: FirebaseVersion(), detailTitle: "FirebaseAuth")] return Section(headerDescription: "Versions", items: items) } - + private var apiHostSection: Section { let items = [Item(title: IdentityToolkitRequest.host, detailTitle: "Identity Toolkit"), Item(title: SecureTokenRequest.host, detailTitle: "Secure Token")] return Section(headerDescription: "API Hosts", items: items) } - + private var appsSection: Section { let items = [Item(title: AppManager.shared.app.options.projectID, detailTitle: "Active App")] return Section(headerDescription: "Firebase Apps", items: items) } - + private var keychainSection: Section { let items = [Item(title: AppManager.shared.auth().userAccessGroup ?? "[none]", detailTitle: "Current Access Group")] return Section(headerDescription: "Keychain Access Groups", items: items) } - + func truncatedString(string: String, length: Int) -> String { guard string.count > length else { return string } - + let half = (length - 3) / 2 let startIndex = string.startIndex let midIndex = string.index(startIndex, offsetBy: half) // Ensure correct mid index let endIndex = string.index(startIndex, offsetBy: string.count - half) - + return "\(string[startIndex ..< midIndex])...\(string[endIndex...])" } - - // TODO: Add ability to click and clear both of these fields. + + // TODO: Add ability to click and clear both of these fields. private var phoneAuthSection: Section { let items = [Item(title: APNSTokenString(), detailTitle: "APNs Token"), Item(title: appCredentialString(), detailTitle: "App Credential")] return Section(headerDescription: "Phone Auth", items: items) } - + func APNSTokenString() -> String { guard let token = AppManager.shared.auth().tokenManager.token else { return "No APNs token" } - + let truncatedToken = truncatedString(string: token.string, length: 19) let tokenType = token.type == .prod ? "Production" : "Sandbox" return "\(truncatedToken)(\(tokenType))" } - + func appCredentialString() -> String { if let credential = AppManager.shared.auth().appCredentialManager.credential { - let message = "receipt: \(credential.receipt)\nsecret: \(credential.secret)" - - showPromptWithTitle("Clear App Credential?", message: message, - showCancelButton: true) { userPressedOK, _ in - if userPressedOK { - AppManager.shared.auth().appCredentialManager.clearCredential() - } - } - } - let message = "receipt: \(credential.receipt)\nsecret: \(credential.secret)" - - showPromptWithTitle("Clear App Credential?", message: message, - showCancelButton: true) { userPressedOK, _ in - if userPressedOK { - AppManager.shared.auth().appCredentialManager.clearCredential() - } - } - } let truncatedReceipt = truncatedString(string: credential.receipt, length: 13) let truncatedSecret = truncatedString(string: credential.secret ?? "", length: 13) return "\(truncatedReceipt)/\(truncatedSecret)" @@ -297,14 +261,14 @@ extension AuthSettings: DataSourceProvidable { return "No App Credential" } } - + private var languageSection: Section { let languageCode = AppManager.shared.auth().languageCode let items = [Item(title: languageCode ?? "[none]", detailTitle: "Auth Language"), Item(title: "Click to Use App Language", detailTitle: "Use App Language")] return Section(headerDescription: "Language", items: items) } - + private var disableSection: Section { guard let settings = AppManager.shared.auth().settings else { fatalError("Missing auth settings") @@ -313,7 +277,7 @@ extension AuthSettings: DataSourceProvidable { let items = [Item(title: disabling, detailTitle: "Disable App Verification (Phone)")] return Section(headerDescription: "Auth Settings", items: items) } - + var sections: [Section] { [ versionSection, From fcd905566c8c9cd50c78ab1e6fdc2ef68ed3dc7a Mon Sep 17 00:00:00 2001 From: Pragati Date: Mon, 6 May 2024 15:31:37 -0700 Subject: [PATCH 34/34] lint --- .../SettingsViewController.swift | 116 +++++++++--------- 1 file changed, 58 insertions(+), 58 deletions(-) diff --git a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/SettingsViewController.swift b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/SettingsViewController.swift index 80129cd051a..6c673022e29 100644 --- a/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/SettingsViewController.swift +++ b/FirebaseAuth/Tests/SampleSwift/AuthenticationExample/ViewControllers/SettingsViewController.swift @@ -1,22 +1,22 @@ - // Copyright 2023 Google LLC - // - // Licensed under the Apache License, Version 2.0 (the "License"); - // you may not use this file except in compliance with the License. - // You may obtain a copy of the License at - // - // http://www.apache.org/licenses/LICENSE-2.0 - // - // Unless required by applicable law or agreed to in writing, software - // distributed under the License is distributed on an "AS IS" BASIS, - // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - // See the License for the specific language governing permissions and - // limitations under the License. +// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. @testable import FirebaseAuth import FirebaseCore import UIKit - /// Namespace for performable actions on a Auth Settings view +/// Namespace for performable actions on a Auth Settings view enum SettingsAction: String { case toggleIdentityTokenAPI = "Identity Toolkit" case toggleSecureTokenAPI = "Secure Token" @@ -31,43 +31,43 @@ enum SettingsAction: String { class SettingsViewController: UIViewController, DataSourceProviderDelegate { var dataSourceProvider: DataSourceProvider! - + var tableView: UITableView { view as! UITableView } - + private var _settings: AuthSettings? var settings: AuthSettings? { get { AppManager.shared.auth().settings } set { _settings = newValue } } - - // MARK: - UIViewController Life Cycle - + + // MARK: - UIViewController Life Cycle + override func loadView() { view = UITableView(frame: .zero, style: .insetGrouped) } - + override func viewDidLoad() { super.viewDidLoad() configureNavigationBar() } - + override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) configureDataSourceProvider() } - - // MARK: - DataSourceProviderDelegate - + + // MARK: - DataSourceProviderDelegate + func didSelectRowAt(_ indexPath: IndexPath, on tableView: UITableView) { let item = dataSourceProvider.item(at: indexPath) - + guard let actionName = item.detailTitle, let action = SettingsAction(rawValue: actionName) else { - // The row tapped has no affiliated action. + // The row tapped has no affiliated action. return } let auth = AppManager.shared.auth() - + switch action { case .toggleSecureTokenAPI: toggleSecureTokenAPI() @@ -93,9 +93,9 @@ class SettingsViewController: UIViewController, DataSourceProviderDelegate { } updateUI() } - - // MARK: - Firebase 🔥 - + + // MARK: - Firebase 🔥 + private func toggleIdentityTokenAPI() { if IdentityToolkitRequest.host == "www.googleapis.com" { IdentityToolkitRequest.setHost("staging-www.sandbox.googleapis.com") @@ -103,7 +103,7 @@ class SettingsViewController: UIViewController, DataSourceProviderDelegate { IdentityToolkitRequest.setHost("www.googleapis.com") } } - + private func toggleSecureTokenAPI() { if SecureTokenRequest.host == "securetoken.googleapis.com" { SecureTokenRequest.setHost("staging-securetoken.sandbox.googleapis.com") @@ -111,7 +111,7 @@ class SettingsViewController: UIViewController, DataSourceProviderDelegate { SecureTokenRequest.setHost("securetoken.googleapis.com") } } - + private func toggleAccessGroup() { if AppManager.shared.auth().userAccessGroup == nil { guard let bundleDictionary = Bundle.main.infoDictionary, @@ -123,15 +123,15 @@ class SettingsViewController: UIViewController, DataSourceProviderDelegate { AppManager.shared.auth().userAccessGroup = nil } } - + func clearAPNSToken() { guard let token = AppManager.shared.auth().tokenManager.token else { return } - + let tokenType = token.type == .prod ? "Production" : "Sandbox" let message = "token: \(token.string)\ntype: \(tokenType)" - + let prompt = UIAlertController(title: nil, message: "Clear APNs Token?", preferredStyle: .alert) let okAction = UIAlertAction(title: "OK", style: .default) { action in @@ -141,7 +141,7 @@ class SettingsViewController: UIViewController, DataSourceProviderDelegate { prompt.addAction(okAction) present(prompt, animated: true) } - + func clearAppCredential() { if let credential = AppManager.shared.auth().appCredentialManager.credential { let prompt = UIAlertController(title: nil, message: "Clear APNs Token?", @@ -154,7 +154,7 @@ class SettingsViewController: UIViewController, DataSourceProviderDelegate { present(prompt, animated: true) } } - + private func setAuthLanguage() { let prompt = UIAlertController(title: nil, message: "Enter Language Code For Auth:", preferredStyle: .alert) @@ -164,12 +164,12 @@ class SettingsViewController: UIViewController, DataSourceProviderDelegate { self.updateUI() } prompt.addAction(okAction) - + present(prompt, animated: true) } - - // MARK: - Private Helpers - + + // MARK: - Private Helpers + private func configureNavigationBar() { navigationItem.title = "Settings" guard let navigationBar = navigationController?.navigationBar else { return } @@ -177,7 +177,7 @@ class SettingsViewController: UIViewController, DataSourceProviderDelegate { navigationBar.titleTextAttributes = [.foregroundColor: UIColor.systemOrange] navigationBar.largeTitleTextAttributes = [.foregroundColor: UIColor.systemOrange] } - + private func configureDataSourceProvider() { dataSourceProvider = DataSourceProvider( dataSource: settings?.sections, @@ -186,12 +186,12 @@ class SettingsViewController: UIViewController, DataSourceProviderDelegate { ) dataSourceProvider.delegate = self } - + private func updateUI() { configureDataSourceProvider() animateUpdates(for: tableView) } - + private func animateUpdates(for tableView: UITableView) { UIView.transition(with: tableView, duration: 0.2, options: .transitionCrossDissolve, @@ -206,52 +206,52 @@ extension AuthSettings: DataSourceProvidable { let items = [Item(title: FirebaseVersion(), detailTitle: "FirebaseAuth")] return Section(headerDescription: "Versions", items: items) } - + private var apiHostSection: Section { let items = [Item(title: IdentityToolkitRequest.host, detailTitle: "Identity Toolkit"), Item(title: SecureTokenRequest.host, detailTitle: "Secure Token")] return Section(headerDescription: "API Hosts", items: items) } - + private var appsSection: Section { let items = [Item(title: AppManager.shared.app.options.projectID, detailTitle: "Active App")] return Section(headerDescription: "Firebase Apps", items: items) } - + private var keychainSection: Section { let items = [Item(title: AppManager.shared.auth().userAccessGroup ?? "[none]", detailTitle: "Current Access Group")] return Section(headerDescription: "Keychain Access Groups", items: items) } - + func truncatedString(string: String, length: Int) -> String { guard string.count > length else { return string } - + let half = (length - 3) / 2 let startIndex = string.startIndex let midIndex = string.index(startIndex, offsetBy: half) // Ensure correct mid index let endIndex = string.index(startIndex, offsetBy: string.count - half) - + return "\(string[startIndex ..< midIndex])...\(string[endIndex...])" } - - // TODO: Add ability to click and clear both of these fields. + + // TODO: Add ability to click and clear both of these fields. private var phoneAuthSection: Section { let items = [Item(title: APNSTokenString(), detailTitle: "APNs Token"), Item(title: appCredentialString(), detailTitle: "App Credential")] return Section(headerDescription: "Phone Auth", items: items) } - + func APNSTokenString() -> String { guard let token = AppManager.shared.auth().tokenManager.token else { return "No APNs token" } - + let truncatedToken = truncatedString(string: token.string, length: 19) let tokenType = token.type == .prod ? "Production" : "Sandbox" return "\(truncatedToken)(\(tokenType))" } - + func appCredentialString() -> String { if let credential = AppManager.shared.auth().appCredentialManager.credential { let truncatedReceipt = truncatedString(string: credential.receipt, length: 13) @@ -261,14 +261,14 @@ extension AuthSettings: DataSourceProvidable { return "No App Credential" } } - + private var languageSection: Section { let languageCode = AppManager.shared.auth().languageCode let items = [Item(title: languageCode ?? "[none]", detailTitle: "Auth Language"), Item(title: "Click to Use App Language", detailTitle: "Use App Language")] return Section(headerDescription: "Language", items: items) } - + private var disableSection: Section { guard let settings = AppManager.shared.auth().settings else { fatalError("Missing auth settings") @@ -277,7 +277,7 @@ extension AuthSettings: DataSourceProvidable { let items = [Item(title: disabling, detailTitle: "Disable App Verification (Phone)")] return Section(headerDescription: "Auth Settings", items: items) } - + var sections: [Section] { [ versionSection,