Skip to content

Commit

Permalink
[Auth] Compile-out recaptchaToken(...) for 1P (#14477)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewheard authored Feb 21, 2025
1 parent d03362a commit b888e1e
Showing 1 changed file with 26 additions and 24 deletions.
50 changes: 26 additions & 24 deletions FirebaseAuth/Sources/Swift/Utilities/AuthRecaptchaVerifier.swift
Original file line number Diff line number Diff line change
Expand Up @@ -156,36 +156,38 @@

private static var recaptchaClient: (any RCARecaptchaClientProtocol)?

private func recaptchaToken(siteKey: String,
actionString: String,
fakeToken: String) async -> (token: String, error: Error?,
linked: Bool, actionCreated: Bool) {
if let recaptchaClient {
return await retrieveToken(
actionString: actionString,
fakeToken: fakeToken,
recaptchaClient: recaptchaClient
)
}

if let recaptcha =
NSClassFromString("RecaptchaEnterprise.RCARecaptcha") as? RCARecaptchaProtocol.Type {
do {
let client = try await recaptcha.fetchClient(withSiteKey: siteKey)
recaptchaClient = client
#if COCOAPODS || SWIFT_PACKAGE // No recaptcha on internal build system.
private func recaptchaToken(siteKey: String,
actionString: String,
fakeToken: String) async -> (token: String, error: Error?,
linked: Bool, actionCreated: Bool) {
if let recaptchaClient {
return await retrieveToken(
actionString: actionString,
fakeToken: fakeToken,
recaptchaClient: client
recaptchaClient: recaptchaClient
)
} catch {
return ("", error, true, true)
}
} else {
// RecaptchaEnterprise not linked.
return ("", nil, false, false)

if let recaptcha =
NSClassFromString("RecaptchaEnterprise.RCARecaptcha") as? RCARecaptchaProtocol.Type {
do {
let client = try await recaptcha.fetchClient(withSiteKey: siteKey)
recaptchaClient = client
return await retrieveToken(
actionString: actionString,
fakeToken: fakeToken,
recaptchaClient: client
)
} catch {
return ("", error, true, true)
}
} else {
// RecaptchaEnterprise not linked.
return ("", nil, false, false)
}
}
}
#endif // (COCOAPODS || SWIFT_PACKAGE)

private func retrieveToken(actionString: String,
fakeToken: String,
Expand Down

0 comments on commit b888e1e

Please sign in to comment.