Skip to content

Commit 514ce75

Browse files
committed
Merge remote-tracking branch 'origin/main' into ThreadSafeMemoizerMemoryLeakFix
2 parents 903df59 + e5a7384 commit 514ce75

File tree

4 files changed

+38
-4
lines changed

4 files changed

+38
-4
lines changed

FirebaseAuth/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
for decoding `nil` values. (#14212)
55
- [fixed] Address Xcode 16.2 concurrency compile time issues. (#14279)
66
- [fixed] Fix handling of cloud blocking function errors. (#14052)
7+
- [fixed] Fix phone auth flow to skip RCE verification if appVerificationDisabledForTesting is set. (#14242)
78

89
# 11.6.0
910
- [added] Added reCAPTCHA Enterprise support for app verification during phone

FirebaseAuth/Sources/Swift/Auth/Auth.swift

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2382,7 +2382,16 @@ extension Auth: AuthInterop {
23822382
private let keychainServices: AuthKeychainServices
23832383

23842384
/// The user access (ID) token used last time for posting auth state changed notification.
2385-
private var lastNotifiedUserToken: String?
2385+
///
2386+
/// - Note: The atomic wrapper can be removed when the SDK is fully
2387+
/// synchronized with structured concurrency.
2388+
private var lastNotifiedUserToken: String? {
2389+
get { lastNotifiedUserTokenLock.withLock { _lastNotifiedUserToken } }
2390+
set { lastNotifiedUserTokenLock.withLock { _lastNotifiedUserToken = newValue } }
2391+
}
2392+
2393+
private var _lastNotifiedUserToken: String?
2394+
private var lastNotifiedUserTokenLock = NSLock()
23862395

23872396
/// This flag denotes whether or not tokens should be automatically refreshed.
23882397
/// Will only be set to `true` if the another Firebase service is included (additionally to

FirebaseAuth/Sources/Swift/AuthProvider/PhoneAuthProvider.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,21 @@ import Foundation
203203
}
204204

205205
let recaptchaVerifier = AuthRecaptchaVerifier.shared(auth: auth)
206+
207+
if let settings = auth.settings,
208+
settings.isAppVerificationDisabledForTesting {
209+
// If app verification is disabled for testing
210+
// do not fetch recaptcha config, as this is not implemented in emulator
211+
// Treat this same as RCE enable status off
212+
213+
return try await verifyClAndSendVerificationCode(
214+
toPhoneNumber: phoneNumber,
215+
retryOnInvalidAppCredential: true,
216+
multiFactorSession: multiFactorSession,
217+
uiDelegate: uiDelegate
218+
)
219+
}
220+
206221
try await recaptchaVerifier.retrieveRecaptchaConfig(forceRefresh: true)
207222

208223
switch recaptchaVerifier.enablementStatus(forProvider: .phone) {

FirebaseAuth/Sources/Swift/SystemService/SecureTokenService.swift

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,17 @@ class SecureTokenService: NSObject, NSSecureCoding {
125125
///
126126
/// This method is specifically for providing the access token to internal clients during
127127
/// deserialization and sign-in events, and should not be used to retrieve the access token by
128-
/// anyone else.
129-
var accessToken: String
128+
/// anyone else.
129+
///
130+
/// - Note: The atomic wrapper can be removed when the SDK is fully
131+
/// synchronized with structured concurrency.
132+
var accessToken: String {
133+
get { accessTokenLock.withLock { _accessToken } }
134+
set { accessTokenLock.withLock { _accessToken = newValue } }
135+
}
136+
137+
private var _accessToken: String
138+
private let accessTokenLock = NSLock()
130139

131140
/// The refresh token for the user, or `nil` if the user has yet completed sign-in flow.
132141
///
@@ -147,7 +156,7 @@ class SecureTokenService: NSObject, NSSecureCoding {
147156
refreshToken: String) {
148157
internalService = SecureTokenServiceInternal()
149158
self.requestConfiguration = requestConfiguration
150-
self.accessToken = accessToken
159+
_accessToken = accessToken
151160
self.accessTokenExpirationDate = accessTokenExpirationDate
152161
self.refreshToken = refreshToken
153162
}

0 commit comments

Comments
 (0)