Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Auth] First pass marking closures as Sendable #14109

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 21 additions & 16 deletions FirebaseAuth/Sources/Swift/Auth/Auth.swift
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,8 @@ extension Auth: AuthInterop {
/// - user: The user object to be set as the current user of the calling Auth instance.
/// - completion: Optionally; a block invoked after the user of the calling Auth instance has
/// been updated or an error was encountered.
@objc open func updateCurrentUser(_ user: User?, completion: ((Error?) -> Void)? = nil) {
@objc open func updateCurrentUser(_ user: User?,
completion: (@Sendable (Error?) -> Void)? = nil) {
kAuthGlobalWorkQueue.async {
guard let user else {
let error = AuthErrorUtils.nullUserError(message: nil)
Expand Down Expand Up @@ -286,7 +287,7 @@ extension Auth: AuthInterop {
)
#endif // !FIREBASE_CI
@objc open func fetchSignInMethods(forEmail email: String,
completion: (([String]?, Error?) -> Void)? = nil) {
completion: (@Sendable ([String]?, Error?) -> Void)? = nil) {
kAuthGlobalWorkQueue.async {
let request = CreateAuthURIRequest(identifier: email,
continueURI: "http://www.google.com/",
Expand Down Expand Up @@ -350,7 +351,7 @@ extension Auth: AuthInterop {
/// or is canceled. Invoked asynchronously on the main thread in the future.
@objc open func signIn(withEmail email: String,
password: String,
completion: ((AuthDataResult?, Error?) -> Void)? = nil) {
completion: (@Sendable (AuthDataResult?, Error?) -> Void)? = nil) {
kAuthGlobalWorkQueue.async {
let decoratedCallback = self.signInFlowAuthDataResultCallback(byDecorating: completion)
Task {
Expand Down Expand Up @@ -449,7 +450,7 @@ extension Auth: AuthInterop {
/// or is canceled. Invoked asynchronously on the main thread in the future.
@objc open func signIn(withEmail email: String,
link: String,
completion: ((AuthDataResult?, Error?) -> Void)? = nil) {
completion: (@Sendable (AuthDataResult?, Error?) -> Void)? = nil) {
kAuthGlobalWorkQueue.async {
let decoratedCallback = self.signInFlowAuthDataResultCallback(byDecorating: completion)
let credential = EmailAuthCredential(withEmail: email, link: link)
Expand Down Expand Up @@ -528,7 +529,7 @@ extension Auth: AuthInterop {
@objc(signInWithProvider:UIDelegate:completion:)
open func signIn(with provider: FederatedAuthProvider,
uiDelegate: AuthUIDelegate?,
completion: ((AuthDataResult?, Error?) -> Void)?) {
completion: (@Sendable (AuthDataResult?, Error?) -> Void)?) {
kAuthGlobalWorkQueue.async {
Task {
let decoratedCallback = self.signInFlowAuthDataResultCallback(byDecorating: completion)
Expand Down Expand Up @@ -629,7 +630,7 @@ extension Auth: AuthInterop {
/// or is canceled. Invoked asynchronously on the main thread in the future.
@objc(signInWithCredential:completion:)
open func signIn(with credential: AuthCredential,
completion: ((AuthDataResult?, Error?) -> Void)? = nil) {
completion: (@Sendable (AuthDataResult?, Error?) -> Void)? = nil) {
kAuthGlobalWorkQueue.async {
let decoratedCallback = self.signInFlowAuthDataResultCallback(byDecorating: completion)
Task {
Expand Down Expand Up @@ -699,7 +700,8 @@ extension Auth: AuthInterop {
/// not enabled. Enable them in the Auth section of the Firebase console.
/// - Parameter completion: Optionally; a block which is invoked when the sign in finishes, or is
/// canceled. Invoked asynchronously on the main thread in the future.
@objc open func signInAnonymously(completion: ((AuthDataResult?, Error?) -> Void)? = nil) {
@objc open func signInAnonymously(completion: (@Sendable (AuthDataResult?, Error?) -> Void)? =
nil) {
kAuthGlobalWorkQueue.async {
let decoratedCallback = self.signInFlowAuthDataResultCallback(byDecorating: completion)
if let currentUser = self.currentUser, currentUser.isAnonymous {
Expand Down Expand Up @@ -765,7 +767,7 @@ extension Auth: AuthInterop {
/// - Parameter completion: Optionally; a block which is invoked when the sign in finishes, or is
/// canceled. Invoked asynchronously on the main thread in the future.
@objc open func signIn(withCustomToken token: String,
completion: ((AuthDataResult?, Error?) -> Void)? = nil) {
completion: (@Sendable (AuthDataResult?, Error?) -> Void)? = nil) {
kAuthGlobalWorkQueue.async {
let decoratedCallback = self.signInFlowAuthDataResultCallback(byDecorating: completion)
let request = VerifyCustomTokenRequest(token: token,
Expand Down Expand Up @@ -834,7 +836,7 @@ extension Auth: AuthInterop {
/// or is canceled. Invoked asynchronously on the main thread in the future.
@objc open func createUser(withEmail email: String,
password: String,
completion: ((AuthDataResult?, Error?) -> Void)? = nil) {
completion: (@Sendable (AuthDataResult?, Error?) -> Void)? = nil) {
guard password.count > 0 else {
if let completion {
completion(nil, AuthErrorUtils.weakPasswordError(serverResponseReason: "Missing password"))
Expand Down Expand Up @@ -947,7 +949,7 @@ extension Auth: AuthInterop {
/// - Parameter completion: Optionally; a block which is invoked when the request finishes.
/// Invoked asynchronously on the main thread in the future.
@objc open func confirmPasswordReset(withCode code: String, newPassword: String,
completion: @escaping (Error?) -> Void) {
completion: @Sendable @escaping (Error?) -> Void) {
kAuthGlobalWorkQueue.async {
let request = ResetPasswordRequest(oobCode: code,
newPassword: newPassword,
Expand Down Expand Up @@ -987,7 +989,8 @@ extension Auth: AuthInterop {
/// Invoked
/// asynchronously on the main thread in the future.
@objc open func checkActionCode(_ code: String,
completion: @escaping (ActionCodeInfo?, Error?) -> Void) {
completion: @Sendable @escaping (ActionCodeInfo?, Error?)
-> Void) {
kAuthGlobalWorkQueue.async {
let request = ResetPasswordRequest(oobCode: code,
newPassword: nil,
Expand Down Expand Up @@ -1032,7 +1035,8 @@ extension Auth: AuthInterop {
/// - Parameter completion: Optionally; a block which is invoked when the request finishes.
/// Invoked asynchronously on the main thread in the future.
@objc open func verifyPasswordResetCode(_ code: String,
completion: @escaping (String?, Error?) -> Void) {
completion: @Sendable @escaping (String?, Error?)
-> Void) {
checkActionCode(code) { info, error in
if let error {
completion(nil, error)
Expand Down Expand Up @@ -1065,7 +1069,8 @@ extension Auth: AuthInterop {
/// - Parameter code: The out of band code to be applied.
/// - Parameter completion: Optionally; a block which is invoked when the request finishes.
/// Invoked asynchronously on the main thread in the future.
@objc open func applyActionCode(_ code: String, completion: @escaping (Error?) -> Void) {
@objc open func applyActionCode(_ code: String,
completion: @Sendable @escaping (Error?) -> Void) {
kAuthGlobalWorkQueue.async {
let request = SetAccountInfoRequest(requestConfiguration: self.requestConfiguration)
request.oobCode = code
Expand Down Expand Up @@ -1110,7 +1115,7 @@ extension Auth: AuthInterop {
/// Invoked
/// asynchronously on the main thread in the future.
@objc open func sendPasswordReset(withEmail email: String,
completion: ((Error?) -> Void)? = nil) {
completion: (@Sendable (Error?) -> Void)? = nil) {
sendPasswordReset(withEmail: email, actionCodeSettings: nil, completion: completion)
}

Expand Down Expand Up @@ -1143,7 +1148,7 @@ extension Auth: AuthInterop {
/// Invoked asynchronously on the main thread in the future.
@objc open func sendPasswordReset(withEmail email: String,
actionCodeSettings: ActionCodeSettings?,
completion: ((Error?) -> Void)? = nil) {
completion: (@Sendable (Error?) -> Void)? = nil) {
kAuthGlobalWorkQueue.async {
let request = GetOOBConfirmationCodeRequest.passwordResetRequest(
email: email,
Expand Down Expand Up @@ -1212,7 +1217,7 @@ extension Auth: AuthInterop {
/// Invoked asynchronously on the main thread in the future.
@objc open func sendSignInLink(toEmail email: String,
actionCodeSettings: ActionCodeSettings,
completion: ((Error?) -> Void)? = nil) {
completion: (@Sendable (Error?) -> Void)? = nil) {
if !actionCodeSettings.handleCodeInApp {
fatalError("The handleCodeInApp flag in ActionCodeSettings must be true for Email-link " +
"Authentication.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ import Foundation
/// - Parameter completion: Optionally; a block which is invoked asynchronously on the main
/// thread when the mobile web flow is completed.
open func getCredentialWith(_ uiDelegate: AuthUIDelegate?,
completion: ((AuthCredential?, Error?) -> Void)? = nil) {
completion: (@Sendable (AuthCredential?, Error?) -> Void)? = nil) {
guard let urlTypes = auth.mainBundleUrlTypes,
AuthWebUtils.isCallbackSchemeRegistered(forCustomURLScheme: callbackScheme,
urlTypes: urlTypes) else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ import Foundation
@objc(verifyPhoneNumber:UIDelegate:completion:)
open func verifyPhoneNumber(_ phoneNumber: String,
uiDelegate: AuthUIDelegate? = nil,
completion: ((_: String?, _: Error?) -> Void)?) {
completion: (@Sendable (_: String?, _: Error?) -> Void)?) {
verifyPhoneNumber(phoneNumber,
uiDelegate: uiDelegate,
multiFactorSession: nil,
Expand All @@ -71,7 +71,7 @@ import Foundation
open func verifyPhoneNumber(_ phoneNumber: String,
uiDelegate: AuthUIDelegate? = nil,
multiFactorSession: MultiFactorSession? = nil,
completion: ((_: String?, _: Error?) -> Void)?) {
completion: (@Sendable (_: String?, _: Error?) -> Void)?) {
guard AuthWebUtils.isCallbackSchemeRegistered(forCustomURLScheme: callbackScheme,
urlTypes: auth.mainBundleUrlTypes) else {
fatalError(
Expand Down Expand Up @@ -132,7 +132,7 @@ import Foundation
open func verifyPhoneNumber(with multiFactorInfo: PhoneMultiFactorInfo,
uiDelegate: AuthUIDelegate? = nil,
multiFactorSession: MultiFactorSession?,
completion: ((_: String?, _: Error?) -> Void)?) {
completion: (@Sendable (_: String?, _: Error?) -> Void)?) {
multiFactorSession?.multiFactorInfo = multiFactorInfo
verifyPhoneNumber(multiFactorInfo.phoneNumber,
uiDelegate: uiDelegate,
Expand Down
Loading
Loading