Skip to content

Commit

Permalink
Only fetch reCAPTCHA v2 token when FAKE_TOKEN
Browse files Browse the repository at this point in the history
  • Loading branch information
NhienLam committed Sep 10, 2024
1 parent 41a5f9f commit a315256
Showing 1 changed file with 6 additions and 18 deletions.
24 changes: 6 additions & 18 deletions packages/auth/src/platform_browser/strategies/phone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,12 +267,8 @@ export async function _verifyPhoneNumber(
authInstance: AuthInternal,
request: StartPhoneMfaEnrollmentRequest
) => {
// If reCAPTCHA Enterprise token is empty or "NO_RECAPTCHA", fetch reCAPTCHA v2 token and inject into request.
if (
!request.phoneEnrollmentInfo.captchaResponse ||
request.phoneEnrollmentInfo.captchaResponse.length === 0 ||
request.phoneEnrollmentInfo.captchaResponse === FAKE_TOKEN
) {
// If reCAPTCHA Enterprise token is FAKE_TOKEN, fetch reCAPTCHA v2 token and inject into request.
if (request.phoneEnrollmentInfo.captchaResponse === FAKE_TOKEN) {
_assert(
verifier?.type === RECAPTCHA_VERIFIER_TYPE,
authInstance,
Expand Down Expand Up @@ -329,12 +325,8 @@ export async function _verifyPhoneNumber(
authInstance: AuthInternal,
request: StartPhoneMfaSignInRequest
) => {
// If reCAPTCHA Enterprise token is empty or "NO_RECAPTCHA", fetch reCAPTCHA v2 token and inject into request.
if (
!request.phoneSignInInfo.captchaResponse ||
request.phoneSignInInfo.captchaResponse.length === 0 ||
request.phoneSignInInfo.captchaResponse === FAKE_TOKEN
) {
// If reCAPTCHA Enterprise token is FAKE_TOKEN, fetch reCAPTCHA v2 token and inject into request.
if (request.phoneSignInInfo.captchaResponse === FAKE_TOKEN) {
_assert(
verifier?.type === RECAPTCHA_VERIFIER_TYPE,
authInstance,
Expand Down Expand Up @@ -380,12 +372,8 @@ export async function _verifyPhoneNumber(
authInstance: AuthInternal,
request: SendPhoneVerificationCodeRequest
) => {
// If reCAPTCHA Enterprise token is empty or "NO_RECAPTCHA", fetch reCAPTCHA v2 token and inject into request.
if (
!request.captchaResponse ||
request.captchaResponse.length === 0 ||
request.captchaResponse === FAKE_TOKEN
) {
// If reCAPTCHA Enterprise token is FAKE_TOKEN, fetch reCAPTCHA v2 token and inject into request.
if (request.captchaResponse === FAKE_TOKEN) {
_assert(
verifier?.type === RECAPTCHA_VERIFIER_TYPE,
authInstance,
Expand Down

0 comments on commit a315256

Please sign in to comment.