Skip to content

Commit c045b6a

Browse files
committed
Reuse invalid-credential error code for INVALID_LOGIN_CREDENTIALS.
Update SDK method docs and the demo app Mark 2 SDK methods as deprecated. Fix error message for the error code and update tests.
1 parent 2b8ae87 commit c045b6a

File tree

9 files changed

+17
-18
lines changed

9 files changed

+17
-18
lines changed
File renamed without changes.

docs-devsite/auth.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ export declare function fetchSignInMethodsForEmail(auth: Auth, email: string): P
411411
| Parameter | Type | Description |
412412
| --- | --- | --- |
413413
| auth | [Auth](./auth.auth.md#auth_interface) | The [Auth](./auth.auth.md#auth_interface) instance. |
414-
| email | string | The user's email address. |
414+
| email | string | The user's email address.<!-- -->Deprecated Migrating off of this method is recommended as a security best-practice. |
415415

416416
<b>Returns:</b>
417417

@@ -1829,7 +1829,7 @@ AUTH_ERROR_CODES_MAP_DO_NOT_USE_INTERNALLY: {
18291829
readonly INVALID_EMAIL: "auth/invalid-email";
18301830
readonly INVALID_EMULATOR_SCHEME: "auth/invalid-emulator-scheme";
18311831
readonly INVALID_IDP_RESPONSE: "auth/invalid-credential";
1832-
readonly INVALID_LOGIN_CREDENTIALS: "auth/invalid-login-credentials";
1832+
readonly INVALID_LOGIN_CREDENTIALS: "auth/invalid-credential";
18331833
readonly INVALID_MESSAGE_PAYLOAD: "auth/invalid-message-payload";
18341834
readonly INVALID_MFA_SESSION: "auth/invalid-multi-factor-session";
18351835
readonly INVALID_OAUTH_CLIENT_ID: "auth/invalid-oauth-client-id";

packages/auth/demo/src/index.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,9 @@ function onAuthError(error) {
317317
alertError('Token expired, please reauthenticate.');
318318
}
319319
if (error.code === 'auth/invalid-credential') {
320-
alertError('login credentials invalid. It is possible that the email/password combination does not exist.');
320+
alertError(
321+
'login credentials invalid. It is possible that the email/password combination does not exist.'
322+
);
321323
}
322324
}
323325
}

packages/auth/src/api/authentication/idp.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ describe('api/authentication/signInWithIdp', () => {
8383

8484
await expect(signInWithIdp(auth, request)).to.be.rejectedWith(
8585
FirebaseError,
86-
'Firebase: The supplied auth credential is malformed or has expired. (auth/invalid-credential).'
86+
'Firebase: The supplied auth credential is incorrect, malformed or has expired. (auth/invalid-credential).'
8787
);
8888
expect(mock.calls[0].request).to.eql(request);
8989
});

packages/auth/src/api/authentication/mfa.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ describe('api/authentication/startSignInPhoneMfa', () => {
8585

8686
await expect(startSignInPhoneMfa(auth, request)).to.be.rejectedWith(
8787
FirebaseError,
88-
'Firebase: The supplied auth credential is malformed or has expired. (auth/invalid-credential).'
88+
'Firebase: The supplied auth credential is incorrect, malformed or has expired. (auth/invalid-credential).'
8989
);
9090
expect(mock.calls[0].request).to.eql(request);
9191
});

packages/auth/src/api/authentication/token.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -142,4 +142,4 @@ describe('requestStsToken', () => {
142142
'refresh_token': 'old-token'
143143
});
144144
});
145-
});
145+
});

packages/auth/src/api/errors.ts

+4-5
Original file line numberDiff line numberDiff line change
@@ -147,16 +147,15 @@ export const SERVER_ERROR_MAP: Partial<ServerErrorMap<ServerError>> = {
147147
[ServerError.MISSING_PASSWORD]: AuthErrorCode.MISSING_PASSWORD,
148148
// Thrown if Email Enumeration Protection is enabled in the project and the email or password is
149149
// invalid.
150-
[ServerError.INVALID_LOGIN_CREDENTIALS]:
151-
AuthErrorCode.INVALID_LOGIN_CREDENTIALS,
150+
[ServerError.INVALID_LOGIN_CREDENTIALS]: AuthErrorCode.INVALID_CREDENTIAL,
152151

153152
// Sign up with email and password errors.
154153
[ServerError.EMAIL_EXISTS]: AuthErrorCode.EMAIL_EXISTS,
155154
[ServerError.PASSWORD_LOGIN_DISABLED]: AuthErrorCode.OPERATION_NOT_ALLOWED,
156155

157156
// Verify assertion for sign in with credential errors:
158-
[ServerError.INVALID_IDP_RESPONSE]: AuthErrorCode.INVALID_IDP_RESPONSE,
159-
[ServerError.INVALID_PENDING_TOKEN]: AuthErrorCode.INVALID_IDP_RESPONSE,
157+
[ServerError.INVALID_IDP_RESPONSE]: AuthErrorCode.INVALID_CREDENTIAL,
158+
[ServerError.INVALID_PENDING_TOKEN]: AuthErrorCode.INVALID_CREDENTIAL,
160159
[ServerError.FEDERATED_USER_ID_ALREADY_LINKED]:
161160
AuthErrorCode.CREDENTIAL_ALREADY_IN_USE,
162161

@@ -189,7 +188,7 @@ export const SERVER_ERROR_MAP: Partial<ServerErrorMap<ServerError>> = {
189188
// Phone Auth related errors.
190189
[ServerError.INVALID_CODE]: AuthErrorCode.INVALID_CODE,
191190
[ServerError.INVALID_SESSION_INFO]: AuthErrorCode.INVALID_SESSION_INFO,
192-
[ServerError.INVALID_TEMPORARY_PROOF]: AuthErrorCode.INVALID_IDP_RESPONSE,
191+
[ServerError.INVALID_TEMPORARY_PROOF]: AuthErrorCode.INVALID_CREDENTIAL,
193192
[ServerError.MISSING_SESSION_INFO]: AuthErrorCode.MISSING_SESSION_INFO,
194193
[ServerError.SESSION_EXPIRED]: AuthErrorCode.CODE_EXPIRED,
195194

packages/auth/src/core/errors.ts

+4-7
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,7 @@ export const enum AuthErrorCode {
6060
INVALID_DYNAMIC_LINK_DOMAIN = 'invalid-dynamic-link-domain',
6161
INVALID_EMAIL = 'invalid-email',
6262
INVALID_EMULATOR_SCHEME = 'invalid-emulator-scheme',
63-
INVALID_IDP_RESPONSE = 'invalid-credential',
64-
INVALID_LOGIN_CREDENTIALS = 'invalid-login-credentials',
63+
INVALID_CREDENTIAL = 'invalid-credential',
6564
INVALID_MESSAGE_PAYLOAD = 'invalid-message-payload',
6665
INVALID_MFA_SESSION = 'invalid-multi-factor-session',
6766
INVALID_OAUTH_CLIENT_ID = 'invalid-oauth-client-id',
@@ -218,10 +217,8 @@ function _debugErrorMap(): ErrorMap<AuthErrorCode> {
218217
'Your API key is invalid, please check you have copied it correctly.',
219218
[AuthErrorCode.INVALID_CERT_HASH]:
220219
'The SHA-1 certificate hash provided is invalid.',
221-
[AuthErrorCode.INVALID_IDP_RESPONSE]:
222-
'The supplied auth credential is malformed or has expired.',
223-
[AuthErrorCode.INVALID_LOGIN_CREDENTIALS]:
224-
'The supplied login credentials are invalid.',
220+
[AuthErrorCode.INVALID_CREDENTIAL]:
221+
'The supplied auth credential is incorrect, malformed or has expired.',
225222
[AuthErrorCode.INVALID_MESSAGE_PAYLOAD]:
226223
'The email template corresponding to this action contains invalid characters in its message. ' +
227224
'Please fix by going to the Auth email templates section in the Firebase Console.',
@@ -531,7 +528,7 @@ export const AUTH_ERROR_CODES_MAP_DO_NOT_USE_INTERNALLY = {
531528
INVALID_EMAIL: 'auth/invalid-email',
532529
INVALID_EMULATOR_SCHEME: 'auth/invalid-emulator-scheme',
533530
INVALID_IDP_RESPONSE: 'auth/invalid-credential',
534-
INVALID_LOGIN_CREDENTIALS: 'auth/invalid-login-credentials',
531+
INVALID_LOGIN_CREDENTIALS: 'auth/invalid-credential',
535532
INVALID_MESSAGE_PAYLOAD: 'auth/invalid-message-payload',
536533
INVALID_MFA_SESSION: 'auth/invalid-multi-factor-session',
537534
INVALID_OAUTH_CLIENT_ID: 'auth/invalid-oauth-client-id',

packages/auth/src/core/strategies/email.ts

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ import { getModularInstance } from '@firebase/util';
4646
* @param auth - The {@link Auth} instance.
4747
* @param email - The user's email address.
4848
*
49+
* Deprecated Migrating off of this method is recommended as a security best-practice.
4950
* @public
5051
*/
5152
export async function fetchSignInMethodsForEmail(

0 commit comments

Comments
 (0)