Skip to content

Commit 0729030

Browse files
authored
docs(auth): clarify fetchSignInMethodsForEmail behavior with email enumeration protection (#8518)
* docs(auth): clarify fetchSignInMethodsForEmail behavior with email enumeration protection This update enhances the JSDoc comment for fetchSignInMethodsForEmail by explaining its behavior when "Email Enumeration Protection" is enabled in Firebase Authentication settings (which is the default). It notes that the method may return an empty array even for existing accounts when called from an unauthenticated context. This clarification aims to prevent confusion and potential misuse that could lead to security vulnerabilities.
1 parent 0cbca93 commit 0729030

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

packages/auth/lib/index.d.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2096,18 +2096,27 @@ export namespace FirebaseAuthTypes {
20962096
/**
20972097
* Returns a list of authentication methods that can be used to sign in a given user (identified by its main email address).
20982098
*
2099+
* ⚠️ Note:
2100+
* If "Email Enumeration Protection" is enabled in your Firebase Authentication settings (which is the default),
2101+
* this method may return an empty array even if the email is registered, especially when called from an unauthenticated context.
2102+
*
2103+
* This is a security measure to prevent leaking account existence via email enumeration attacks.
2104+
* Do not use the result of this method to directly inform the user whether an email is registered.
2105+
*
20992106
* #### Example
21002107
*
21012108
* ```js
21022109
* const methods = await firebase.auth().fetchSignInMethodsForEmail('[email protected]');
21032110
*
2104-
* methods.forEach((method) => {
2105-
* console.log(method);
2106-
* });
2111+
* if (methods.length > 0) {
2112+
* // Likely a registered user — offer sign-in
2113+
* } else {
2114+
* // Could be unregistered OR email enumeration protection is active — offer registration
2115+
* }
21072116
* ```
21082117
*
21092118
* @error auth/invalid-email Thrown if the email address is not valid.
2110-
* @param email The users email address.
2119+
* @param email The user's email address.
21112120
*/
21122121
fetchSignInMethodsForEmail(email: string): Promise<string[]>;
21132122

0 commit comments

Comments
 (0)