refactor(global): cleanup redundant availability checks and update sample apps audit (#16143)

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
This commit is contained in:
Nick Cookeandgemini-code-assist[bot] authored and GitHub committed 2026-04-30 18:48:30 -04:00
1 parent ee41ce8dbc
commit dc18b7f5b9
182 files changed
+28 -303

No files matched your search

@@ -17,7 +17,6 @@
import SwiftUI
/// Custom view modifier to allow for easily logging screen view events.
@available(iOS 13.0, macOS 10.15, macCatalyst 13.0, tvOS 13.0, *)
@available(watchOS, unavailable)
struct LoggedAnalyticsModifier: ViewModifier {
/// The name of the view to log in the `AnalyticsParameterScreenName` parameter.
@@ -42,7 +41,6 @@
}
}
@available(iOS 13.0, macOS 10.15, macCatalyst 13.0, tvOS 13.0, *)
@available(watchOS, unavailable)
public extension View {
/// Logs `screen_view` events in Google Analytics for Firebase when this view appears on screen.
@@ -74,7 +74,6 @@ import FirebaseCoreExtension
}
#endif
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
extension Auth: AuthInterop {
/// Retrieves the Firebase authentication token, possibly refreshing it if it has expired.
///
@@ -144,7 +143,6 @@ extension Auth: AuthInterop {
/// Manages authentication for Firebase apps.
///
/// This class is thread-safe.
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
@preconcurrency
@objc(FIRAuth) open class Auth: NSObject {
/// Gets the auth object for the default Firebase app.
@@ -261,7 +259,6 @@ extension Auth: AuthInterop {
/// Sets the `currentUser` on the receiver to the provided user object.
/// - Parameter user: The user object to be set as the current user of the calling Auth instance.
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
open func updateCurrentUser(_ user: User) async throws {
return try await withCheckedThrowingContinuation { continuation in
self.updateCurrentUser(user) { error in
@@ -427,7 +424,6 @@ extension Auth: AuthInterop {
/// - Parameter email: The user's email address.
/// - Parameter password: The user's password.
/// - Returns: The `AuthDataResult` after a successful signin.
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
@discardableResult
open func signIn(withEmail email: String, password: String) async throws -> AuthDataResult {
return try await withCheckedThrowingContinuation { continuation in
@@ -485,7 +481,6 @@ extension Auth: AuthInterop {
/// - Parameter email: The user's email address.
/// - Parameter link: The email sign-in link.
/// - Returns: The `AuthDataResult` after a successful signin.
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
open func signIn(withEmail email: String, link: String) async throws -> AuthDataResult {
return try await withCheckedThrowingContinuation { continuation in
self.signIn(withEmail: email, link: link) { result, error in
@@ -584,7 +579,6 @@ extension Auth: AuthInterop {
/// protocol, this is used for presenting the web context. If nil, a default AuthUIDelegate
/// will be used.
/// - Returns: The `AuthDataResult` after the successful signin.
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
@available(tvOS, unavailable)
@available(macOS, unavailable)
@available(watchOS, unavailable)
@@ -683,7 +677,6 @@ extension Auth: AuthInterop {
/// * `AuthErrorCodeSessionExpired` - Indicates that the SMS code has expired.
/// - Parameter credential: The credential supplied by the IdP.
/// - Returns: The `AuthDataResult` after the successful signin.
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
@discardableResult
open func signIn(with credential: AuthCredential) async throws -> AuthDataResult {
return try await withCheckedThrowingContinuation { continuation in
@@ -749,7 +742,6 @@ extension Auth: AuthInterop {
/// * `AuthErrorCodeOperationNotAllowed` - Indicates that anonymous accounts are
/// not enabled. Enable them in the Auth section of the Firebase console.
/// - Returns: The `AuthDataResult` after the successful signin.
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
@discardableResult
@objc open func signInAnonymously() async throws -> AuthDataResult {
return try await withCheckedThrowingContinuation { continuation in
@@ -812,7 +804,6 @@ extension Auth: AuthInterop {
/// belong to different projects.
/// - Parameter token: A self-signed custom auth token.
/// - Returns: The `AuthDataResult` after the successful signin.
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
@discardableResult
open func signIn(withCustomToken token: String) async throws -> AuthDataResult {
return try await withCheckedThrowingContinuation { continuation in
@@ -941,7 +932,6 @@ extension Auth: AuthInterop {
/// - Parameter email: The user's email address.
/// - Parameter password: The user's desired password.
/// - Returns: The `AuthDataResult` after the successful signin.
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
@discardableResult
open func createUser(withEmail email: String, password: String) async throws -> AuthDataResult {
return try await withCheckedThrowingContinuation { continuation in
@@ -991,7 +981,6 @@ extension Auth: AuthInterop {
/// * `AuthErrorCodeInvalidActionCode` - Indicates the OOB code is invalid.
/// - Parameter code: The reset code.
/// - Parameter newPassword: The new password.
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
open func confirmPasswordReset(withCode code: String, newPassword: String) async throws {
return try await withCheckedThrowingContinuation { continuation in
self.confirmPasswordReset(withCode: code, newPassword: newPassword) { error in
@@ -1037,7 +1026,6 @@ extension Auth: AuthInterop {
/// Checks the validity of an out of band code.
/// - Parameter code: The out of band code to check validity.
/// - Returns: An `ActionCodeInfo`.
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
open func checkActionCode(_ code: String) async throws -> ActionCodeInfo {
return try await withCheckedThrowingContinuation { continuation in
self.checkActionCode(code) { info, error in
@@ -1068,7 +1056,6 @@ extension Auth: AuthInterop {
/// Checks the validity of a verify password reset code.
/// - Parameter code: The password reset code to be verified.
/// - Returns: An email.
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
open func verifyPasswordResetCode(_ code: String) async throws -> String {
return try await withCheckedThrowingContinuation { continuation in
self.verifyPasswordResetCode(code) { code, error in
@@ -1101,7 +1088,6 @@ extension Auth: AuthInterop {
/// This method will not work for out of band codes which require an additional parameter,
/// such as password reset code.
/// - Parameter code: The out of band code to be applied.
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
open func applyActionCode(_ code: String) async throws {
return try await withCheckedThrowingContinuation { continuation in
self.applyActionCode(code) { error in
@@ -1216,7 +1202,6 @@ extension Auth: AuthInterop {
/// - Parameter email: The email address of the user.
/// - Parameter actionCodeSettings: An `ActionCodeSettings` object containing settings related to
/// handling action codes.
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
open func sendPasswordReset(withEmail email: String,
actionCodeSettings: ActionCodeSettings? = nil) async throws {
return try await withCheckedThrowingContinuation { continuation in
@@ -1271,7 +1256,6 @@ extension Auth: AuthInterop {
/// - Parameter email: The email address of the user.
/// - Parameter actionCodeSettings: An `ActionCodeSettings` object containing settings related to
/// handling action codes.
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
open func sendSignInLink(toEmail email: String,
actionCodeSettings: ActionCodeSettings) async throws {
return try await withCheckedThrowingContinuation { continuation in
@@ -1480,7 +1464,6 @@ extension Auth: AuthInterop {
/// Revoke the users token with authorization code.
/// - Parameter authorizationCode: The authorization code used to perform the revocation.
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
open func revokeToken(withAuthorizationCode authorizationCode: String) async throws {
return try await withCheckedThrowingContinuation { continuation in
self.revokeToken(withAuthorizationCode: authorizationCode) { error in
@@ -19,7 +19,6 @@ import FirebaseAuthInterop
import FirebaseCore
import FirebaseCoreExtension
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
@objc(FIRAuthComponent)
class AuthComponent: NSObject, Library, ComponentLifecycleMaintainer {
// MARK: - Private Variables
@@ -14,14 +14,12 @@
import Foundation
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
extension AuthDataResult: NSSecureCoding {}
/// Helper object that contains the result of a successful sign-in, link and reauthenticate
/// action.
///
/// It contains references to a `User` instance and an `AdditionalUserInfo` instance.
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
@objc(FIRAuthDataResult) open class AuthDataResult: NSObject {
/// The signed in user.
@objc public let user: User
@@ -14,12 +14,10 @@
import Foundation
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
extension AuthTokenResult: NSSecureCoding {}
/// A data class containing the ID token JWT string and other properties associated with the
/// token including the decoded payload claims.
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
@objc(FIRAuthTokenResult) open class AuthTokenResult: NSObject {
/// Stores the JWT string of the ID token.
@objc open var token: String
@@ -15,7 +15,6 @@
import Foundation
/// Public representation of a credential.
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
@objc(FIRAuthCredential) open class AuthCredential: NSObject, @unchecked Sendable {
/// The name of the identity provider for the credential.
@objc public let provider: String
@@ -15,7 +15,6 @@
import Foundation
/// A concrete implementation of `AuthProvider` for Email & Password Sign In.
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
@objc(FIREmailAuthProvider) open class EmailAuthProvider: NSObject {
/// A string constant identifying the email & password identity provider.
@objc public static let id = "password"
@@ -37,7 +36,6 @@ import Foundation
}
}
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
@objc(FIREmailPasswordAuthCredential) class EmailAuthCredential: AuthCredential, NSSecureCoding,
@unchecked Sendable {
let email: String
@@ -15,7 +15,6 @@
import Foundation
/// Utility class for constructing Facebook Sign In credentials.
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
@objc(FIRFacebookAuthProvider) open class FacebookAuthProvider: NSObject {
/// A string constant identifying the Facebook identity provider.
@objc public static let id = "facebook.com"
@@ -33,7 +32,6 @@ import Foundation
}
}
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
@objc(FIRFacebookAuthCredential) class FacebookAuthCredential: AuthCredential, NSSecureCoding,
@unchecked Sendable {
let accessToken: String?
@@ -15,7 +15,6 @@
import Foundation
/// Utility type for constructing federated auth provider credentials.
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
@objc(FIRFederatedAuthProvider) public protocol FederatedAuthProvider: NSObjectProtocol {
#if os(iOS)
@@ -19,17 +19,14 @@
// TODO: Delete this when minimum iOS version passes 13.5.
/// WarningWorkaround is needed because playerID is deprecated in iOS 13.0 but still needed until
/// 13.5 when the fetchItems API was introduced.
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
private protocol WarningWorkaround {
static func pre135Credential(localPlayer: GKLocalPlayer,
completion: @escaping (AuthCredential?, Error?) -> Void)
}
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
extension GameCenterAuthProvider: WarningWorkaround {}
/// A concrete implementation of `AuthProvider` for Game Center Sign In. Not available on watchOS.
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
@objc(FIRGameCenterAuthProvider) open class GameCenterAuthProvider: NSObject {
/// A string constant identifying the Game Center identity provider.
@objc public static let id = "gc.apple.com"
@@ -127,7 +124,6 @@
}
}
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
@objc(FIRGameCenterAuthCredential)
class GameCenterAuthCredential: AuthCredential, NSSecureCoding, @unchecked Sendable {
let playerID: String?
@@ -15,7 +15,6 @@
import Foundation
/// Utility class for constructing GitHub Sign In credentials.
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
@objc(FIRGitHubAuthProvider) open class GitHubAuthProvider: NSObject {
/// A string constant identifying the GitHub identity provider.
@objc public static let id = "github.com"
@@ -33,7 +32,6 @@ import Foundation
}
}
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
@objc(FIRGitHubAuthCredential) class GitHubAuthCredential: AuthCredential, NSSecureCoding,
@unchecked Sendable {
let token: String?
@@ -15,7 +15,6 @@
import Foundation
/// Utility class for constructing Google Sign In credentials.
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
@objc(FIRGoogleAuthProvider) open class GoogleAuthProvider: NSObject {
/// A string constant identifying the Google identity provider.
@objc public static let id = "google.com"
@@ -35,7 +34,6 @@ import Foundation
}
}
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
@objc(FIRGoogleAuthCredential) class GoogleAuthCredential: AuthCredential, NSSecureCoding,
@unchecked Sendable {
let idToken: String?
@@ -15,7 +15,6 @@
import Foundation
/// Internal implementation of `AuthCredential` for generic credentials.
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
@objc(FIROAuthCredential) open class OAuthCredential: AuthCredential, NSSecureCoding,
@unchecked Sendable {
/// The ID Token associated with this credential.
@@ -16,7 +16,6 @@ import CommonCrypto
import Foundation
/// Utility class for constructing OAuth Sign In credentials.
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
@objc(FIROAuthProvider) open class OAuthProvider: NSObject, FederatedAuthProvider {
@objc public static let id = "OAuth"
@@ -17,7 +17,6 @@ import Foundation
/// Implementation of AuthCredential for Phone Auth credentials.
///
/// This class is available on iOS only.
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
@objc(FIRPhoneAuthCredential) open class PhoneAuthCredential: AuthCredential, NSSecureCoding,
@unchecked Sendable {
enum CredentialKind {
@@ -20,7 +20,6 @@ import Foundation
/// A concrete implementation of `AuthProvider` for phone auth providers.
///
/// This class is available on iOS only.
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
@objc(FIRPhoneAuthProvider) open class PhoneAuthProvider: NSObject, @unchecked Sendable {
/// A string constant identifying the phone identity provider.
@objc public static let id = "phone"
@@ -15,7 +15,6 @@
import Foundation
/// Utility class for constructing Twitter Sign In credentials.
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
@objc(FIRTwitterAuthProvider) open class TwitterAuthProvider: NSObject {
/// A string constant identifying the Twitter identity provider.
@objc public static let id = "twitter.com"
@@ -34,7 +33,6 @@ import Foundation
}
}
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
@objc(FIRTwitterAuthCredential) class TwitterAuthCredential: AuthCredential, NSSecureCoding,
@unchecked Sendable {
let token: String?
@@ -21,12 +21,10 @@ import Foundation
import GTMSessionFetcherCore
#endif
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
protocol AuthBackendProtocol: Sendable {
func call<T: AuthRPCRequest>(with request: T) async throws -> T.Response
}
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
final class AuthBackend: AuthBackendProtocol {
static func authUserAgent() -> String {
return "FirebaseAuth.iOS/\(FirebaseVersion()) \(GTMFetcherStandardUserAgentString(nil))"
@@ -21,7 +21,6 @@ import Foundation
@preconcurrency import GTMSessionFetcherCore
#endif
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
protocol AuthBackendRPCIssuerProtocol: Sendable {
/// Asynchronously send a HTTP request.
/// - Parameter request: The request to be made.
@@ -34,7 +33,6 @@ protocol AuthBackendRPCIssuerProtocol: Sendable {
contentType: String) async -> (Data?, Error?)
}
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
final class AuthBackendRPCIssuer: AuthBackendRPCIssuerProtocol {
let fetcherService: GTMSessionFetcherService
@@ -15,7 +15,6 @@
import Foundation
/// The generic interface for an RPC request needed by AuthBackend.
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
protocol AuthRPCRequest {
associatedtype Response: AuthRPCResponse
@@ -36,7 +35,6 @@ protocol AuthRPCRequest {
// Default implementation of AuthRPCRequests. This produces similar behaviour to an optional method
// in Obj-C.
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
extension AuthRPCRequest {
func injectRecaptchaFields(recaptchaResponse: String?, recaptchaVersion: String) {
fatalError("Internal FirebaseAuth Error: unimplemented injectRecaptchaFields")
@@ -18,7 +18,6 @@ import FirebaseAppCheckInterop
import FirebaseCoreExtension
/// Defines configurations to be added to a request to Firebase Auth's backend.
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
final class AuthRequestConfiguration {
/// The Firebase Auth API key used in the request.
let apiKey: String
@@ -31,7 +31,6 @@ private let kIdentityPlatformStagingAPIHost =
"staging-identitytoolkit.sandbox.googleapis.com"
/// Represents a request to an identity toolkit endpoint.
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
class IdentityToolkitRequest {
/// Gets the RPC's endpoint.
let endpoint: String
@@ -43,7 +43,6 @@ private let kTenantIDKey = "tenantId"
/// Represents the parameters for the createAuthUri endpoint.
/// See https://developers.google.com/identity/toolkit/web/reference/relyingparty/createAuthUri
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
class CreateAuthURIRequest: IdentityToolkitRequest, AuthRPCRequest {
typealias Response = CreateAuthURIResponse
@@ -25,7 +25,6 @@ private let kIDTokenKey = "idToken"
/// The key for the "localID" value in the request.
private let kLocalIDKey = "localId"
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
class DeleteAccountRequest: IdentityToolkitRequest, AuthRPCRequest {
typealias Response = DeleteAccountResponse
@@ -32,7 +32,6 @@ private let kPostBodyKey = "postBody"
/// The key for the tenant id value in the request.
private let kTenantIDKey = "tenantId"
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
class EmailLinkSignInRequest: IdentityToolkitRequest, AuthRPCRequest {
typealias Response = EmailLinkSignInResponse
@@ -23,7 +23,6 @@ private let kIDTokenKey = "idToken"
/// Represents the parameters for the getAccountInfo endpoint.
/// See https://developers.google.com/identity/toolkit/web/reference/relyingparty/getAccountInfo
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
class GetAccountInfoRequest: IdentityToolkitRequest, AuthRPCRequest {
typealias Response = GetAccountInfoResponse
@@ -14,9 +14,8 @@
import Foundation
/// Represents the response from the setAccountInfo endpoint.
/// Represents the response from the getAccountInfo endpoint.
/// See https://developers.google.com/identity/toolkit/web/reference/relyingparty/getAccountInfo
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
struct GetAccountInfoResponse: AuthRPCResponse {
/// Represents the provider user info part of the response from the getAccountInfo endpoint.
/// See https://developers.google.com/identity/toolkit/web/reference/relyingparty/getAccountInfo
@@ -102,7 +102,6 @@ private let kClientType = "clientType"
/// The key for the "recaptchaVersion" value in the request.
private let kRecaptchaVersion = "recaptchaVersion"
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
class GetOOBConfirmationCodeRequest: IdentityToolkitRequest, AuthRPCRequest {
typealias Response = GetOOBConfirmationCodeResponse
@@ -17,7 +17,6 @@ import Foundation
/// The "getProjectConfig" endpoint.
private let kGetProjectConfigEndPoint = "getProjectConfig"
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
class GetProjectConfigRequest: IdentityToolkitRequest, AuthRPCRequest {
typealias Response = GetProjectConfigResponse
@@ -43,7 +43,6 @@ private let kVersionKey = "version"
/// The key for the tenant id value in the request.
private let kTenantIDKey = "tenantId"
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
class GetRecaptchaConfigRequest: IdentityToolkitRequest, AuthRPCRequest {
typealias Response = GetRecaptchaConfigResponse
@@ -19,7 +19,6 @@ private let kFinalizeMFAEnrollmentEndPoint = "accounts/mfaEnrollment:finalize"
/// The key for the tenant id value in the request.
private let kTenantIDKey = "tenantId"
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
class FinalizeMFAEnrollmentRequest: IdentityToolkitRequest, AuthRPCRequest {
typealias Response = FinalizeMFAEnrollmentResponse
@@ -14,7 +14,6 @@
import Foundation
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
struct FinalizeMFAEnrollmentResponse: AuthRPCResponse {
private(set) var idToken: String?
private(set) var refreshToken: String?
@@ -31,7 +31,6 @@ private let kRecaptchaVersion = "recaptchaVersion"
/// The key for the tenant id value in the request.
private let kTenantIDKey = "tenantId"
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
class StartMFAEnrollmentRequest: IdentityToolkitRequest, AuthRPCRequest {
typealias Response = StartMFAEnrollmentResponse
@@ -14,7 +14,6 @@
import Foundation
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
struct StartMFAEnrollmentResponse: AuthRPCResponse {
private(set) var phoneSessionInfo: AuthProtoStartMFAPhoneResponseInfo?
private(set) var totpSessionInfo: AuthProtoStartMFATOTPEnrollmentResponseInfo?
@@ -19,7 +19,6 @@ private let kFinalizeMFASignInEndPoint = "accounts/mfaSignIn:finalize"
/// The key for the tenant id value in the request.
private let kTenantIDKey = "tenantId"
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
class FinalizeMFASignInRequest: IdentityToolkitRequest, AuthRPCRequest {
typealias Response = FinalizeMFAEnrollmentResponse
@@ -14,7 +14,6 @@
import Foundation
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
struct FinalizeMFASignInResponse: AuthRPCResponse {
var IDToken: String?
var refreshToken: String?
@@ -20,7 +20,6 @@ private let kStartMFASignInEndPoint = "accounts/mfaSignIn:start"
private let kTenantIDKey = "tenantId"
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
class StartMFASignInRequest: IdentityToolkitRequest, AuthRPCRequest {
typealias Response = StartMFASignInResponse
@@ -14,7 +14,6 @@
import Foundation
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
struct StartMFASignInResponse: AuthRPCResponse {
let responseInfo: AuthProtoStartMFAPhoneResponseInfo
@@ -19,7 +19,6 @@ private let kWithdrawMFAEndPoint = "accounts/mfaEnrollment:withdraw"
/// The key for the tenant id value in the request.
private let kTenantIDKey = "tenantId"
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
class WithdrawMFARequest: IdentityToolkitRequest, AuthRPCRequest {
typealias Response = WithdrawMFAResponse
@@ -26,7 +26,6 @@ private let kCurrentPasswordKey = "newPassword"
/// The key for the tenant id value in the request.
private let kTenantIDKey = "tenantId"
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
class ResetPasswordRequest: IdentityToolkitRequest, AuthRPCRequest {
typealias Response = ResetPasswordResponse
@@ -29,10 +29,9 @@ private let kTokenKey = "token"
/// The key for the ID Token associated with this credential.
private let kIDTokenKey = "idToken"
/// Represents the parameters for the verifyPassword endpoint.
/// Represents the parameters for the revokeToken endpoint.
///
/// See https: // developers.google.com/identity/toolkit/web/reference/relyingparty/verifyPassword
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
/// See https://developers.google.com/identity/toolkit/web/reference/relyingparty/revokeToken
class RevokeTokenRequest: IdentityToolkitRequest, AuthRPCRequest {
typealias Response = RevokeTokenResponse
@@ -59,7 +59,6 @@ private let kCodeKey = "code"
private nonisolated(unsafe) var gAPIHost = "securetoken.googleapis.com"
/// Represents the parameters for the token endpoint.
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
class SecureTokenRequest: AuthRPCRequest {
typealias Response = SecureTokenResponse
@@ -28,7 +28,6 @@ private let kAccessTokenKey = "access_token"
private let kIDTokenKey = "id_token"
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
struct SecureTokenResponse: AuthRPCResponse {
var approximateExpirationDate: Date?
var refreshToken: String?
@@ -48,7 +48,6 @@ enum CodeIdentity: Equatable {
case empty
}
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
class SendVerificationCodeRequest: IdentityToolkitRequest, AuthRPCRequest {
typealias Response = SendVerificationCodeResponse
@@ -78,7 +78,6 @@ private let kTenantIDKey = "tenantId"
/// Represents the parameters for the setAccountInfo endpoint.
/// See https://developers.google.com/identity/toolkit/web/reference/relyingparty/setAccountInfo
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
class SetAccountInfoRequest: IdentityToolkitRequest, AuthRPCRequest {
typealias Response = SetAccountInfoResponse
@@ -17,7 +17,6 @@ import Foundation
private let kSignInWithGameCenterEndPoint = "signInWithGameCenter"
/// The request to sign in with Game Center account
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
class SignInWithGameCenterRequest: IdentityToolkitRequest, AuthRPCRequest {
typealias Response = SignInWithGameCenterResponse
@@ -44,7 +44,6 @@ private let kReturnSecureTokenKey = "returnSecureToken"
/// The key for the tenant id value in the request.
private let kTenantIDKey = "tenantId"
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
class SignUpNewUserRequest: IdentityToolkitRequest, AuthRPCRequest {
typealias Response = SignUpNewUserResponse
@@ -79,7 +79,6 @@ private let kLastNameKey = "lastName"
/// Represents the parameters for the verifyAssertion endpoint.
/// See https://developers.google.com/identity/toolkit/web/reference/relyingparty/verifyAssertion
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
class VerifyAssertionRequest: IdentityToolkitRequest, AuthRPCRequest {
typealias Response = VerifyAssertionResponse
@@ -26,7 +26,6 @@ private let kReturnSecureTokenKey = "returnSecureToken"
/// The key for the tenant id value in the request.
private let kTenantIDKey = "tenantId"
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
class VerifyCustomTokenRequest: IdentityToolkitRequest, AuthRPCRequest {
typealias Response = VerifyCustomTokenResponse
@@ -46,7 +46,6 @@ private let kTenantIDKey = "tenantId"
/// Represents the parameters for the verifyPassword endpoint.
/// See https: // developers.google.com/identity/toolkit/web/reference/relyingparty/verifyPassword
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
class VerifyPasswordRequest: IdentityToolkitRequest, AuthRPCRequest {
typealias Response = VerifyPasswordResponse
@@ -56,7 +56,6 @@ extension AuthOperationType {
}
}
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
class VerifyPhoneNumberRequest: IdentityToolkitRequest, AuthRPCRequest {
typealias Response = VerifyPhoneNumberResponse
@@ -14,7 +14,6 @@
import Foundation
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
class VerifyClientRequest: IdentityToolkitRequest, AuthRPCRequest {
typealias Response = VerifyClientResponse
@@ -16,14 +16,12 @@ import Foundation
#if os(iOS) || os(macOS)
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
extension MultiFactor: NSSecureCoding {}
/// The interface defining the multi factor related properties and operations pertaining to a
/// user.
///
/// This class is available on iOS and macOS.
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
@objc(FIRMultiFactor) open class MultiFactor: NSObject {
@objc open var enrolledFactors: [MultiFactorInfo]
@@ -43,7 +41,6 @@ import Foundation
/// Get a session for a second factor enrollment operation.
///
/// This is used to identify the current user trying to enroll a second factor.
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
open func session() async throws -> MultiFactorSession {
return try await withCheckedThrowingContinuation { continuation in
self.getSessionWithCompletion { session, error in
@@ -166,7 +163,6 @@ import Foundation
/// - Parameter assertion: The `MultiFactorAssertion`.
/// - Parameter displayName: An optional display name associated with the multi factor to
/// enroll.
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
open func enroll(with assertion: MultiFactorAssertion, displayName: String?) async throws {
return try await withCheckedThrowingContinuation { continuation in
self.enroll(with: assertion, displayName: displayName) { error in
@@ -190,7 +186,6 @@ import Foundation
}
/// Unenroll the given multi factor.
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
open func unenroll(with factorInfo: MultiFactorInfo) async throws {
try await unenroll(withFactorUID: factorInfo.uid)
}
@@ -240,7 +235,6 @@ import Foundation
}
/// Unenroll the given multi factor.
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
open func unenroll(withFactorUID factorUID: String) async throws {
return try await withCheckedThrowingContinuation { continuation in
self.unenroll(withFactorUID: factorUID) { error in
@@ -20,7 +20,6 @@ import Foundation
/// second factor.
///
/// This class is available on iOS and macOS.
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
@objc(FIRMultiFactorResolver)
open class MultiFactorResolver: NSObject {
/// The opaque session identifier for the current sign-in flow.
@@ -92,7 +91,6 @@ import Foundation
/// A helper function to help users complete sign in with a second factor using a
/// - Parameter assertion: The assertion confirming the user successfully
/// completed the second factor challenge.
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
open func resolveSignIn(with assertion: MultiFactorAssertion) async throws -> AuthDataResult {
return try await withCheckedThrowingContinuation { continuation in
self.resolveSignIn(with: assertion) { result, error in
@@ -24,7 +24,6 @@ import Foundation
/// existing user, notably the confirmation that the user passed the first factor challenge.
///
/// This class is available on iOS and macOS.
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
@objc(FIRMultiFactorSession) open class MultiFactorSession: NSObject {
/// The ID token for an enroll flow. This has to be retrieved after recent authentication.
let idToken: String?
@@ -20,7 +20,6 @@ import Foundation
/// second factor.
///
/// This class is available on iOS and macOS.
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
@objc(FIRPhoneMultiFactorAssertion) open class PhoneMultiFactorAssertion: MultiFactorAssertion {
var authCredential: PhoneAuthCredential?
@@ -22,7 +22,6 @@ import Foundation
/// Depending on the type of second factor, this will help generate the assertion.
///
/// This class is available on iOS and macOS.
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
@objc(FIRPhoneMultiFactorGenerator)
open class PhoneMultiFactorGenerator: NSObject {
/// Initializes the MFA assertion to confirm ownership of the phone second factor.
@@ -21,7 +21,6 @@ import Foundation
/// the assertion.
///
/// This class is available on iOS and macOS.
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
@objc(FIRTOTPMultiFactorGenerator) open class TOTPMultiFactorGenerator: NSObject {
/// Creates a TOTP secret as part of enrolling a TOTP second factor. Used for generating a
/// QR code URL or inputting into a TOTP app. This method uses the auth instance corresponding
@@ -69,10 +68,9 @@ import Foundation
/// Creates a TOTP secret as part of enrolling a TOTP second factor.
///
/// Used for generating a QR code URL or inputting into a TOTP app. This
/// method uses the auth instance correspondingto the user in the multiFactorSession.
/// method uses the auth instance corresponding to the user in the multiFactorSession.
/// - Parameter session: The multiFactorSession instance.
/// - Returns: The TOTP secret.
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
open class func generateSecret(with session: MultiFactorSession) async throws -> TOTPSecret {
return try await withCheckedThrowingContinuation { continuation in
self.generateSecret(with: session) { secret, error in
@@ -22,7 +22,6 @@ import Foundation
private let kAccountPrefix = "firebase_auth_1_"
/// The utility class to manipulate data in iOS Keychain.
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
final class AuthKeychainServices: Sendable {
/// The name of the keychain service.
private let service: String
@@ -16,7 +16,6 @@ import Foundation
/// Protocol to manage keychain updates. Tests can do a fake implementation.
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
protocol AuthKeychainStorage: Sendable {
func get(query: [String: Any], result: inout AnyObject?) -> OSStatus
func add(query: [String: Any]) -> OSStatus
@@ -15,7 +15,6 @@
import Foundation
/// The utility class to update the real keychain
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
final class AuthKeychainStorageReal: AuthKeychainStorage {
static let shared: AuthKeychainStorageReal = .init()
@@ -30,7 +30,6 @@
extension UIApplication: AuthAPNSTokenApplication {}
/// A class to manage APNs token in memory.
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
class AuthAPNSTokenManager: @unchecked Sendable /* TODO: sendable */ {
/// The timeout for registering for remote notification.
///
@@ -16,7 +16,6 @@
import Foundation
/// A class to manage app credentials backed by iOS Keychain.
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
class AuthAppCredentialManager {
let kKeychainDataKey = "app_credentials"
let kFullCredentialKey = "full_credential"
@@ -17,7 +17,6 @@
import UIKit
/// A class represents a credential that proves the identity of the app.
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
@preconcurrency
class AuthNotificationManager {
/// The key to locate payload data in the remote notification.
@@ -14,7 +14,6 @@
import Foundation
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
class AuthStoredUserManager {
/// Key of user access group stored in user defaults. Used for retrieve the
/// user access group at launch.
@@ -17,7 +17,6 @@ import Foundation
private let kFiveMinutes = 5 * 60.0
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
actor SecureTokenServiceInternal {
/// Coalescer to deduplicate concurrent token refresh requests.
/// When multiple requests arrive at the same time, only one network call is made.
@@ -130,7 +129,6 @@ actor SecureTokenServiceInternal {
}
/// A class represents a credential that proves the identity of the app.
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
@objc(FIRSecureTokenService) // objc Needed for decoding old versions
final class SecureTokenService: NSObject, NSSecureCoding, Sendable {
/// Internal actor to enforce serialization
@@ -33,7 +33,6 @@ import Foundation
///
/// // Only ONE network call is made. All three tasks receive the same refreshed token.
/// ```
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
actor TokenRefreshCoalescer {
/// The in-flight token refresh task, if any.
/// When this is set, all concurrent calls wait for this task instead of starting their own.
@@ -14,7 +14,6 @@
import Foundation
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
extension User: NSSecureCoding {}
/// Represents a user.
@@ -26,7 +25,6 @@ extension User: NSSecureCoding {}
/// ID token is automatically refreshed.
///
/// This class is thread-safe.
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
@objc(FIRUser) open class User: NSObject, UserInfo {
/// Indicates the user represents an anonymous user.
@objc public internal(set) var isAnonymous: Bool {
@@ -166,7 +164,6 @@ extension User: NSSecureCoding {}
message: "`updateEmail` is deprecated and will be removed in a future release. Use sendEmailVerification(beforeUpdatingEmail:) instead."
)
#endif // !FIREBASE_CI
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
open func updateEmail(to email: String) async throws {
return try await withCheckedThrowingContinuation { continuation in
self.updateEmail(to: email) { error in
@@ -226,7 +223,6 @@ extension User: NSSecureCoding {}
/// considered too weak. The `NSLocalizedFailureReasonErrorKey` field in the `userInfo`
/// dictionary object will contain more detailed explanation that can be shown to the user.
/// - Parameter password: The new password for the user.
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
open func updatePassword(to password: String) async throws {
return try await withCheckedThrowingContinuation { continuation in
self.updatePassword(to: password) { error in
@@ -281,7 +277,6 @@ extension User: NSSecureCoding {}
/// - Parameter credential: The new phone number credential corresponding to the
/// phone number to be added to the Firebase account, if a phone number is already linked to the
/// account this new phone number will replace it.
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
open func updatePhoneNumber(_ credential: PhoneAuthCredential) async throws {
return try await withCheckedThrowingContinuation { continuation in
self.updatePhoneNumber(credential) { error in
@@ -340,7 +335,6 @@ extension User: NSSecureCoding {}
/// May fail with an `AuthErrorCodeRequiresRecentLogin` error code. In this case
/// you should call `reauthenticate(with:)` before re-invoking
/// `updateEmail(to:)`.
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
open func reload() async throws {
return try await withCheckedThrowingContinuation { continuation in
self.reload { error in
@@ -459,7 +453,6 @@ extension User: NSSecureCoding {}
/// This can be a successful third-party identity provider sign-in, or an email address and
/// password.
/// - Returns: The `AuthDataResult` after the reauthentication.
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
@discardableResult
open func reauthenticate(with credential: AuthCredential) async throws -> AuthDataResult {
return try await withCheckedThrowingContinuation { continuation in
@@ -511,7 +504,6 @@ extension User: NSSecureCoding {}
/// protocol, used for presenting the web context. If nil, a default `AuthUIDelegate`
/// will be used.
/// - Returns: The `AuthDataResult` after the reauthentication.
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
@discardableResult
open func reauthenticate(with provider: FederatedAuthProvider,
uiDelegate: AuthUIDelegate?) async throws -> AuthDataResult {
@@ -564,7 +556,6 @@ extension User: NSSecureCoding {}
/// - Parameter forceRefresh: Forces a token refresh. Useful if the token becomes invalid for some
/// reason other than an expiration.
/// - Returns: The Firebase authentication token.
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
open func getIDToken(forcingRefresh forceRefresh: Bool = false) async throws -> String {
return try await withCheckedThrowingContinuation { continuation in
self.getIDTokenForcingRefresh(forceRefresh) { tokenResult, error in
@@ -649,7 +640,6 @@ extension User: NSSecureCoding {}
/// - Parameter forceRefresh: Forces a token refresh. Useful if the token becomes invalid for some
/// reason other than an expiration.
/// - Returns: The Firebase authentication token.
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
open func getIDTokenResult(forcingRefresh forceRefresh: Bool = false) async throws
-> AuthTokenResult {
return try await withCheckedThrowingContinuation { continuation in
@@ -747,7 +737,6 @@ extension User: NSSecureCoding {}
/// `updatePassword(to:)` on `User`.
/// - Parameter credential: The credential for the identity provider.
/// - Returns: An `AuthDataResult`.
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
@discardableResult
open func link(with credential: AuthCredential) async throws -> AuthDataResult {
return try await withCheckedThrowingContinuation { continuation in
@@ -797,7 +786,6 @@ extension User: NSSecureCoding {}
/// protocol used for presenting the web context. If nil, a default `AuthUIDelegate`
/// will be used.
/// - Returns: An AuthDataResult.
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
@discardableResult
open func link(with provider: FederatedAuthProvider,
uiDelegate: AuthUIDelegate?) async throws -> AuthDataResult {
@@ -856,7 +844,6 @@ extension User: NSSecureCoding {}
/// `reauthenticate(with:)`.
/// - Parameter provider: The provider ID of the provider to unlink.
/// - Returns: The user.
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
open func unlink(fromProvider provider: String) async throws -> User {
return try await userProfileUpdate.unlink(user: self, fromProvider: provider)
}
@@ -937,7 +924,6 @@ extension User: NSSecureCoding {}
/// * `AuthErrorCodeUserNotFound` - Indicates the user account was not found.
/// - Parameter actionCodeSettings: An `ActionCodeSettings` object containing settings related to
/// handling action codes. The default value is `nil`.
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
open func sendEmailVerification(with actionCodeSettings: ActionCodeSettings? = nil) async throws {
return try await withCheckedThrowingContinuation { continuation in
self.sendEmailVerification(with: actionCodeSettings) { error in
@@ -994,7 +980,6 @@ extension User: NSSecureCoding {}
/// operation that requires a recent login from the user. This error indicates the user
/// has not signed in recently enough. To resolve, reauthenticate the user by calling
/// `reauthenticate(with:)`.
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
open func delete() async throws {
return try await withCheckedThrowingContinuation { continuation in
self.delete { error in
@@ -1059,7 +1044,6 @@ extension User: NSSecureCoding {}
/// - Parameter newEmail: The email to be updated to.
/// - Parameter actionCodeSettings: An `ActionCodeSettings` object containing settings related to
/// handling action codes.
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
open func sendEmailVerification(beforeUpdatingEmail newEmail: String,
actionCodeSettings: ActionCodeSettings? = nil) async throws {
return try await withCheckedThrowingContinuation { continuation in
@@ -14,10 +14,8 @@
import Foundation
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
extension UserInfoImpl: NSSecureCoding {}
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
@objc(FIRUserInfoImpl) // objc Needed for decoding old versions
class UserInfoImpl: NSObject, UserInfo {
/// A convenience factory method for constructing a `UserInfo` instance from data
@@ -14,11 +14,9 @@
import Foundation
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
extension UserMetadata: NSSecureCoding {}
/// A data class representing the metadata corresponding to a Firebase user.
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
@objc(FIRUserMetadata) open class UserMetadata: NSObject {
/// Stores the last sign in date for the corresponding Firebase user.
@objc public let lastSignInDate: Date?
@@ -18,7 +18,6 @@ import Foundation
///
/// Properties are marked as being part of a profile update when they are set. Setting a
/// property value to nil is not the same as leaving the property unassigned.
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
@objc(FIRUserProfileChangeRequest) open class UserProfileChangeRequest: NSObject {
/// The name of the user.
@objc open var displayName: String? {
@@ -104,7 +103,6 @@ import Foundation
/// Commits any pending changes.
///
/// This method should only be called once. Once called, property values should not be changed.
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
open func commitChanges() async throws {
return try await withCheckedThrowingContinuation { continuation in
self.commitChanges { error in
@@ -15,7 +15,6 @@
import Foundation
/// Actor to serialize the update profile calls.
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
actor UserProfileUpdate {
func link(user: User, with credential: AuthCredential) async throws -> AuthDataResult {
let accessToken = try await user.internalGetTokenAsync(backend: user.backend)
@@ -15,7 +15,6 @@
import Foundation
/// Utility struct to make the execution of one task dependent upon a signal from another task.
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
struct AuthCondition {
private let waiter: () async -> Void
private let stream: AsyncStream<Void>.Continuation
@@ -30,7 +30,6 @@ private let kURLResponseErrorCodeInternalError = "auth/internal-error"
private let kFIRAuthErrorMessageMalformedJWT =
"Failed to parse JWT. Check the userInfo dictionary for the full token."
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
class AuthErrorUtils {
static let internalErrorDomain = "FIRAuthInternalErrorDomain"
static let userInfoDeserializedResponseKey = "FIRAuthErrorUserInfoDeserializedResponseKey"
@@ -21,7 +21,6 @@
#endif
import RecaptchaInterop
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
class AuthRecaptchaConfig {
var siteKey: String?
let enablementStatus: [AuthRecaptchaProvider: AuthRecaptchaEnablementStatus]
@@ -33,7 +32,6 @@
}
}
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
enum AuthRecaptchaEnablementStatus: String, CaseIterable {
case enforce = "ENFORCE"
case audit = "AUDIT"
@@ -43,7 +41,6 @@
var stringValue: String { rawValue }
}
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
enum AuthRecaptchaProvider: String, CaseIterable {
case password = "EMAIL_PASSWORD_PROVIDER"
case phone = "PHONE_PROVIDER"
@@ -52,7 +49,6 @@
var stringValue: String { rawValue }
}
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
enum AuthRecaptchaAction: String {
case defaultAction
case signInWithPassword
@@ -66,7 +62,6 @@
var stringValue: String { rawValue }
}
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
class AuthRecaptchaVerifier {
private(set) weak var auth: Auth?
private(set) var agentConfig: AuthRecaptchaConfig?
@@ -20,7 +20,6 @@
import WebKit
/// A Class responsible for presenting URL via SFSafariViewController or WKWebView.
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
class AuthURLPresenter: NSObject,
SFSafariViewControllerDelegate, AuthWebViewControllerDelegate {
/// Presents an URL to interact with user.
@@ -14,7 +14,6 @@
import Foundation
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
class AuthWebUtils {
static func randomString(withLength length: Int) -> String {
var randomString = ""
@@ -18,7 +18,6 @@
import WebKit
/// A class responsible for creating a WKWebView for use within Firebase Auth.
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
class AuthWebView: UIView {
lazy var webView: WKWebView = createWebView()
lazy var spinner: UIActivityIndicatorView = createSpinner()
@@ -19,7 +19,6 @@
import WebKit
/// Defines a delegate for AuthWebViewController
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
protocol AuthWebViewControllerDelegate: AnyObject {
/// Notifies the delegate that the web view controller is being cancelled by the user.
/// - Parameter webViewController: The web view controller in question.
@@ -47,7 +46,6 @@
completion: @escaping (URL?, Error?) -> Void)
}
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
class AuthWebViewController: UIViewController,
WKNavigationDelegate {
// MARK: - Properties
@@ -44,7 +44,6 @@ import XCTest
// deleteFacebookTestingAccountbyID(facebookAccountID)
// }
//
// @available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
// func testSignInWithFacebookAsync() async throws {
// let auth = Auth.auth()
// let userInfoDict = try await createFacebookTestingAccountAsync()
@@ -88,7 +87,6 @@ import XCTest
// deleteFacebookTestingAccountbyID(facebookAccountID)
// }
//
// @available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
// func testLinkAnonymousAccountToFacebookAccountAsync() async throws {
// let auth = Auth.auth()
// try await signInAnonymouslyAsync()
@@ -147,7 +145,6 @@ import XCTest
// return returnValue
// }
//
// @available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
// /// Creates a Facebook testing account using Facebook Graph API and return a dictionary that
// /// constains "id", "access_token", "login_url", "email" and "password" of the created
// /// account.
@@ -189,7 +186,6 @@ import XCTest
// waitForExpectations(timeout: TestsBase.kExpectationsTimeout)
// }
//
// @available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
// // ** Delete a Facebook testing account by account Id using Facebook Graph API. */
// func deleteFacebookTestingAccountbyIDAsync(_ accountID: String) async throws {
// let urltoDeleteTestUser = "https://graph.facebook.com/\(accountID)"
@@ -37,7 +37,6 @@ class GoogleTests: TestsBase {
waitForExpectations(timeout: TestsBase.kExpectationsTimeout)
}
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
func testSignInWithGoogleAsync() async throws {
let auth = Auth.auth()
let userInfoDict = try await getGoogleAccessTokenAsync()
@@ -89,7 +88,6 @@ class GoogleTests: TestsBase {
/// Returns a dictionary that constains "access_token", "token_type", "expires_in" and sometimes
/// the "id_token". (The id_token is not guaranteed to be returned during a refresh exchange;
/// see https://openid.net/specs/openid-connect-core-1_0.html#RefreshTokenResponse)
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
func getGoogleAccessTokenAsync() async throws -> [String: Any] {
let googleOauth2TokenServerUrl = "https://www.googleapis.com/oauth2/v4/token"
let bodyString = "client_id=\(Credentials.kGoogleClientID)&grant_type=refresh_token" +
@@ -16,7 +16,6 @@
import FirebaseCore
import XCTest
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
class UserThreadSafetyTests: XCTestCase {
// A basic user setup for testing purposes.
private func createTestUser() throws -> User {
@@ -17,7 +17,6 @@ import XCTest
@testable import FirebaseAuth
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
class AdditionalUserInfoTests: XCTestCase {
let kFakeProfile = ["email": "user@mail.com", "given_name": "User", "family_name": "Doe"]
let kUserName = "User Doe"
@@ -19,7 +19,6 @@
@testable import FirebaseAuth
import FirebaseCoreInternal
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
class AuthAPNSTokenManagerTests: XCTestCase {
private var fakeApplication: FakeApplication?
var manager: AuthAPNSTokenManager?
@@ -18,7 +18,6 @@
@testable import FirebaseAuth
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
class AuthAPNSTokenTests: XCTestCase {
/** @fn testProperties
@brief Tests the properties of the class.
@@ -18,7 +18,6 @@
@testable import FirebaseAuth
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
class AuthAppCredentialManagerTests: XCTestCase {
let kReceipt = "FAKE_RECEIPT"
let kVerificationTimeout = 1.0
@@ -17,7 +17,6 @@ import XCTest
@testable import FirebaseAuth
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
class AuthAppCredentialTests: XCTestCase {
private let kReceipt = "RECEIPT"
private let kSecret = "SECRET"
@@ -26,7 +26,6 @@ import FirebaseCoreExtension
private let kFakeAPIKey = "kTestAPIKey"
private let kFakeAppID = "kTestFirebaseAppID"
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
class AuthBackendTests: RPCBaseTests {
let kFakeErrorDomain = "fakeDomain"
let kFakeErrorCode = -1
@@ -17,7 +17,6 @@ import XCTest
@testable import FirebaseAuth
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
class AuthDispatcherTests: XCTestCase {
let kTestDelay = 0.1
let kMaxDifferenceBetweenTimeIntervals = 0.4
@@ -19,7 +19,6 @@ import XCTest
@testable import FirebaseAuth
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
class AuthKeychainServicesTests: XCTestCase {
static let accountPrefix = "firebase_auth_1_"
static let key = "ACCOUNT"
@@ -18,7 +18,6 @@ import XCTest
@testable import FirebaseAuth
import FirebaseCore
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
class AuthLifecycleTests: XCTestCase {
private let kFakeAPIKey = "FAKE_API_KEY"
private let options = FirebaseOptions(googleAppID: "0:0000000000000:ios:0000000000000000",
@@ -18,7 +18,6 @@
@testable import FirebaseAuth
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
class AuthNotificationManagerTests: XCTestCase {
/** @var kReceipt
@brief A fake receipt used for testing.
@@ -16,7 +16,6 @@ import FirebaseAuth
import Foundation
import XCTest
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
final class AuthProviderIDTests: XCTestCase {
// Verify that AuthProviderID enum values match the class values published for Objective-C
// compatibility.
-1
View File
@@ -20,7 +20,6 @@ import FirebaseAuthInterop
import FirebaseCore
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
class AuthTests: RPCBaseTests {
static let kAccessToken = "TEST_ACCESS_TOKEN"
static let kNewAccessToken = "NEW_ACCESS_TOKEN"
@@ -21,7 +21,6 @@
import FirebaseCore
import SafariServices
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
class AuthURLPresenterTests: XCTestCase {
/** @fn testFIRAuthURLPresenterNonNilUIDelegate
@brief Tests @c FIRAuthURLPresenter class showing UI with a non-nil UIDelegate.
@@ -18,7 +18,6 @@ import XCTest
@testable import FirebaseAuth
import FirebaseCore
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
class UseUserAccessGroupTests: RPCBaseTests {
static var auth: Auth?
@@ -18,7 +18,6 @@ import XCTest
@testable import FirebaseAuth
import FirebaseCore
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
class AuthUserDefaultsTests: XCTestCase {
let kKey = "ACCOUNT"
let kData = "DATA"
@@ -17,7 +17,6 @@ import XCTest
@testable import FirebaseAuth
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
class AuthWebUtilsTests: XCTestCase {
/** @fn testExtractDomainWithHTTP
@brief Test case for extracting the domain from a URL with "http://" scheme.
@@ -17,7 +17,6 @@ import XCTest
@testable import FirebaseAuth
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
class CreateAuthURITests: RPCBaseTests {
/** @var kContinueURITestKey
@brief The key for the "continueUri" value in the request.
@@ -17,7 +17,6 @@ import XCTest
@testable import FirebaseAuth
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
class DeleteAccountTests: RPCBaseTests {
/** @var kLocalIDKey
@brief The name of the "localID" property in the request.
Loaded 100 of 182 files, more files were not shown because too many files have changed in this diff. Show more