Skip to content

Commit 7a40e87

Browse files
committed
make auth build (with warnings and todos)
1 parent 319fbee commit 7a40e87

File tree

54 files changed

+256
-238
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+256
-238
lines changed

FirebaseAuth/Interop/Public/FirebaseAuthInterop/FIRAuthInterop.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ NS_SWIFT_NAME(AuthInterop)
3434
/// Retrieves the Firebase authentication token, possibly refreshing it if it has expired.
3535
- (void)getTokenForcingRefresh:(BOOL)forceRefresh
3636
withCallback:
37-
(void (^)(NSString *_Nullable_result token, NSError *_Nullable error))callback
38-
NS_SWIFT_NAME(getToken(forcingRefresh:completion:));
37+
(void (^NS_SWIFT_UI_ACTOR)(NSString *_Nullable_result token, NSError *_Nullable error))callback NS_SWIFT_NAME(getToken(forcingRefresh:completion:));
3938

4039
/// Get the current Auth user's UID. Returns nil if there is no user signed in.
4140
- (nullable NSString *)getUserID;

FirebaseAuth/Sources/Swift/ActionCode/ActionCodeInfo.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import Foundation
1616

1717
/// Manages information regarding action codes.
18-
@objc(FIRActionCodeInfo) open class ActionCodeInfo: NSObject {
18+
@objc(FIRActionCodeInfo) final public class ActionCodeInfo: NSObject, Sendable {
1919
/// The operation being performed.
2020
@objc public let operation: ActionCodeOperation
2121

FirebaseAuth/Sources/Swift/ActionCode/ActionCodeSettings.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import Foundation
1616

1717
/// Used to set and retrieve settings related to handling action codes.
18-
@objc(FIRActionCodeSettings) open class ActionCodeSettings: NSObject {
18+
@objc(FIRActionCodeSettings) open class ActionCodeSettings: NSObject, @unchecked Sendable /* TODO: sendable */ {
1919
/// This URL represents the state/Continue URL in the form of a universal link.
2020
///
2121
/// This URL can should be constructed as a universal link that would either directly open

FirebaseAuth/Sources/Swift/Auth/Auth.swift

Lines changed: 70 additions & 58 deletions
Large diffs are not rendered by default.

FirebaseAuth/Sources/Swift/Auth/AuthDataResult.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ extension AuthDataResult: NSSecureCoding {}
2222
///
2323
/// It contains references to a `User` instance and an `AdditionalUserInfo` instance.
2424
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
25-
@objc(FIRAuthDataResult) open class AuthDataResult: NSObject {
25+
@objc(FIRAuthDataResult) open class AuthDataResult: NSObject, @unchecked Sendable /* TODO: sendable */ {
2626
/// The signed in user.
2727
@objc public let user: User
2828

FirebaseAuth/Sources/Swift/Auth/AuthTokenResult.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ extension AuthTokenResult: NSSecureCoding {}
2020
/// A data class containing the ID token JWT string and other properties associated with the
2121
/// token including the decoded payload claims.
2222
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
23-
@objc(FIRAuthTokenResult) open class AuthTokenResult: NSObject {
23+
@objc(FIRAuthTokenResult) open class AuthTokenResult: NSObject, @unchecked Sendable /* TODO: sendable */ {
2424
/// Stores the JWT string of the ID token.
2525
@objc open var token: String
2626

FirebaseAuth/Sources/Swift/AuthProvider/FederatedAuthProvider.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import Foundation
1616

1717
/// Utility type for constructing federated auth provider credentials.
1818
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
19-
@objc(FIRFederatedAuthProvider) public protocol FederatedAuthProvider: NSObjectProtocol {
19+
@objc(FIRFederatedAuthProvider) public protocol FederatedAuthProvider: NSObjectProtocol, Sendable {
2020
#if os(iOS)
2121

2222
/// Used to obtain an auth credential via a mobile web flow.

FirebaseAuth/Sources/Swift/AuthProvider/OAuthProvider.swift

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import Foundation
1717

1818
/// Utility class for constructing OAuth Sign In credentials.
1919
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
20-
@objc(FIROAuthProvider) open class OAuthProvider: NSObject, FederatedAuthProvider {
20+
@objc(FIROAuthProvider) open class OAuthProvider: NSObject, FederatedAuthProvider, @unchecked Sendable /* TODO: sendable */ {
2121
@objc public static let id = "OAuth"
2222

2323
/// Array used to configure the OAuth scopes.
@@ -268,7 +268,7 @@ import Foundation
268268
/// - Parameter completion: Optionally; a block which is invoked asynchronously on the main
269269
/// thread when the mobile web flow is completed.
270270
open func getCredentialWith(_ uiDelegate: AuthUIDelegate?,
271-
completion: ((AuthCredential?, Error?) -> Void)? = nil) {
271+
completion: (@MainActor (AuthCredential?, Error?) -> Void)? = nil) {
272272
guard let urlTypes = auth.mainBundleUrlTypes,
273273
AuthWebUtils.isCallbackSchemeRegistered(forCustomURLScheme: callbackScheme,
274274
urlTypes: urlTypes) else {
@@ -281,11 +281,9 @@ import Foundation
281281
let eventID = AuthWebUtils.randomString(withLength: 10)
282282
let sessionID = AuthWebUtils.randomString(withLength: 10)
283283

284-
let callbackOnMainThread: ((AuthCredential?, Error?) -> Void) = { credential, error in
284+
let callbackOnMainThread: (@MainActor (AuthCredential?, Error?) -> Void) = { credential, error in
285285
if let completion {
286-
DispatchQueue.main.async {
287-
completion(credential, error)
288-
}
286+
completion(credential, error)
289287
}
290288
}
291289
Task {
@@ -296,13 +294,13 @@ import Foundation
296294
"FirebaseAuth Internal Error: Both error and headfulLiteURL return are nil"
297295
)
298296
}
299-
let callbackMatcher: (URL?) -> Bool = { callbackURL in
297+
let callbackMatcher: @Sendable (URL?) -> Bool = { callbackURL in
300298
AuthWebUtils.isExpectedCallbackURL(callbackURL,
301299
eventID: eventID,
302300
authType: "signInWithRedirect",
303301
callbackScheme: self.callbackScheme)
304302
}
305-
self.auth.authURLPresenter.present(headfulLiteURL,
303+
await self.auth.authURLPresenter.present(headfulLiteURL,
306304
uiDelegate: uiDelegate,
307305
callbackMatcher: callbackMatcher) { callbackURL, error in
308306
if let error {
@@ -328,7 +326,7 @@ import Foundation
328326
callbackOnMainThread(credential, nil)
329327
}
330328
} catch {
331-
callbackOnMainThread(nil, error)
329+
await callbackOnMainThread(nil, error)
332330
}
333331
}
334332
}

FirebaseAuth/Sources/Swift/AuthProvider/PhoneAuthProvider.swift

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import Foundation
1919
///
2020
/// This class is available on iOS only.
2121
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
22-
@objc(FIRPhoneAuthProvider) open class PhoneAuthProvider: NSObject {
22+
@objc(FIRPhoneAuthProvider) open class PhoneAuthProvider: NSObject, @unchecked Sendable /* TODO: sendable */ {
2323
/// A string constant identifying the phone identity provider.
2424
@objc public static let id = "phone"
2525
private static let recaptchaVersion = "RECAPTCHA_ENTERPRISE"
@@ -56,7 +56,7 @@ import Foundation
5656
@objc(verifyPhoneNumber:UIDelegate:completion:)
5757
open func verifyPhoneNumber(_ phoneNumber: String,
5858
uiDelegate: AuthUIDelegate? = nil,
59-
completion: ((_: String?, _: Error?) -> Void)?) {
59+
completion: (@Sendable (_: String?, _: Error?) -> Void)?) {
6060
verifyPhoneNumber(phoneNumber,
6161
uiDelegate: uiDelegate,
6262
multiFactorSession: nil,
@@ -75,7 +75,7 @@ import Foundation
7575
open func verifyPhoneNumber(_ phoneNumber: String,
7676
uiDelegate: AuthUIDelegate? = nil,
7777
multiFactorSession: MultiFactorSession? = nil,
78-
completion: ((_: String?, _: Error?) -> Void)?) {
78+
completion: (@Sendable (String?, Error?) -> Void)?) {
7979
Task {
8080
do {
8181
let verificationID = try await verifyPhoneNumber(
@@ -135,7 +135,7 @@ import Foundation
135135
open func verifyPhoneNumber(with multiFactorInfo: PhoneMultiFactorInfo,
136136
uiDelegate: AuthUIDelegate? = nil,
137137
multiFactorSession: MultiFactorSession?,
138-
completion: ((_: String?, _: Error?) -> Void)?) {
138+
completion: (@Sendable (String?, Error?) -> Void)?) {
139139
Task {
140140
do {
141141
let verificationID = try await verifyPhoneNumber(
@@ -531,7 +531,7 @@ import Foundation
531531
"Internal error: reCAPTCHAURL returned neither a value nor an error. Report issue"
532532
)
533533
}
534-
let callbackMatcher: (URL?) -> Bool = { callbackURL in
534+
let callbackMatcher: @Sendable (URL?) -> Bool = { callbackURL in
535535
AuthWebUtils.isExpectedCallbackURL(
536536
callbackURL,
537537
eventID: eventID,
@@ -540,17 +540,19 @@ import Foundation
540540
)
541541
}
542542

543-
return try await withUnsafeThrowingContinuation { continuation in
544-
self.auth.authURLPresenter.present(url,
545-
uiDelegate: uiDelegate,
546-
callbackMatcher: callbackMatcher) { callbackURL, error in
547-
if let error {
548-
continuation.resume(throwing: error)
549-
} else {
550-
do {
551-
try continuation.resume(returning: self.reCAPTCHAToken(forURL: callbackURL))
552-
} catch {
543+
return try await withCheckedThrowingContinuation { continuation in
544+
DispatchQueue.main.async {
545+
self.auth.authURLPresenter.present(url,
546+
uiDelegate: uiDelegate,
547+
callbackMatcher: callbackMatcher) { callbackURL, error in
548+
if let error {
553549
continuation.resume(throwing: error)
550+
} else {
551+
do {
552+
try continuation.resume(returning: self.reCAPTCHAToken(forURL: callbackURL))
553+
} catch {
554+
continuation.resume(throwing: error)
555+
}
554556
}
555557
}
556558
}

FirebaseAuth/Sources/Swift/Backend/AuthBackend.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import Foundation
2323

2424
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
2525
protocol AuthBackendProtocol: Sendable {
26-
func call<T: AuthRPCRequest>(with request: T) async throws -> T.Response
26+
func call<T: AuthRPCRequest>(with request: sending T) async throws -> T.Response
2727
}
2828

2929
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
@@ -48,7 +48,7 @@ final class AuthBackend: AuthBackendProtocol {
4848
/// * See FIRAuthInternalErrorCodeRPCResponseDecodingError
4949
/// - Parameter request: The request.
5050
/// - Returns: The response.
51-
func call<T: AuthRPCRequest>(with request: T) async throws -> T.Response {
51+
func call<T: AuthRPCRequest>(with request: sending T) async throws -> T.Response {
5252
let response = try await callInternal(with: request)
5353
if let auth = request.requestConfiguration().auth,
5454
let mfaError = Self.generateMFAError(response: response, auth: auth) {

0 commit comments

Comments
 (0)