Skip to content

Commit 5be78c3

Browse files
authored
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 08cee09 commit 5be78c3

1 file changed

Lines changed: 14 additions & 5 deletions

File tree

packages/auth/lib/index.d.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2096,19 +2096,28 @@ 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('joe.bloggs@example.com');
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.
2111-
*/
2119+
* @param email The user's email address.
2120+
*/
21122121
fetchSignInMethodsForEmail(email: string): Promise<string[]>;
21132122

21142123
/**

0 commit comments

Comments
 (0)