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

isHostLanguageValid() in auth's recaptcha loader incorrectly determines long language codes to be invalid #8357

Open
sxxov opened this issue Jul 8, 2024 · 1 comment

Comments

@sxxov
Copy link

sxxov commented Jul 8, 2024

Operating System

Windows 11

Browser Version

Chrome/126.0.6478.127

Firebase SDK Version

10.12.3

Firebase SDK Product:

Auth

Describe your project's tooling

NextJS 15 RC
React Compiler

Describe the problem

My browser's language is en-GB-oxendict (got by doing navigator.languages[0]).

When trying to use auth.useDeviceLanguage(), which sets the above value to auth.languageCode, the recaptcha loader will fail an assertion as described here, & as implemented here, throwing a FirebaseError: Firebase: Error (auth/argument-error).

A bit perculiar that language codes are expected to be below 6 characters. Either that, or auth.useDeviceLanguage() should handle it.

Steps and code to reproduce issue

import { getAuth } from 'firebase/auth';
import { app } from './app';

export const auth = getAuth(app);
// either, on a environment with a long language string:
// auth.useDeviceLanguage();
// or, set it directly here:
auth.languageCode = 'en-GB-oxendict';

const el = document.createElement('div');
document.body.appendChild(el);

const verifier = new RecaptchaVerifier(auth, el, {
	size: 'invisible',
});
void verifier.render().then(console.log);
// uncaught promise rejection:
// FirebaseError: Firebase: Error (auth/argument-error).
//    at createErrorInternal (index-54738136.js:455:37)
//    at _assert (index-54738136.js:461:11)
//    at ReCaptchaLoaderImpl.load (index-54738136.js:8134:5)
//    at RecaptchaVerifier.init (index-54738136.js:8382:50)
//    at async RecaptchaVerifier.makeRenderPromise (index-54738136.js:8367:5)
@sxxov sxxov added new A new issue that hasn't be categoirzed as question, bug or feature request question labels Jul 8, 2024
@dlarocque
Copy link
Contributor

Thanks for reporting this issue, and for providing a great description!

@dlarocque dlarocque added bug api: auth and removed question new A new issue that hasn't be categoirzed as question, bug or feature request labels Jul 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants