Skip to content

Commit b160e44

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 584596d commit b160e44

File tree

9 files changed

+17
-18
lines changed

9 files changed

+17
-18
lines changed
File renamed without changes.

docs-devsite/auth.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ export declare function fetchSignInMethodsForEmail(auth: Auth, email: string): P
416416
| Parameter | Type | Description |
417417
| --- | --- | --- |
418418
| auth | [Auth](./auth.auth.md#auth_interface) | The [Auth](./auth.auth.md#auth_interface) instance. |
419-
| email | string | The user's email address. |
419+
| email | string | The user's email address.<!-- -->Deprecated Migrating off of this method is recommended as a security best-practice. |
420420

421421
<b>Returns:</b>
422422

@@ -1855,7 +1855,7 @@ AUTH_ERROR_CODES_MAP_DO_NOT_USE_INTERNALLY: {
18551855
readonly INVALID_EMAIL: "auth/invalid-email";
18561856
readonly INVALID_EMULATOR_SCHEME: "auth/invalid-emulator-scheme";
18571857
readonly INVALID_IDP_RESPONSE: "auth/invalid-credential";
1858-
readonly INVALID_LOGIN_CREDENTIALS: "auth/invalid-login-credentials";
1858+
readonly INVALID_LOGIN_CREDENTIALS: "auth/invalid-credential";
18591859
readonly INVALID_MESSAGE_PAYLOAD: "auth/invalid-message-payload";
18601860
readonly INVALID_MFA_SESSION: "auth/invalid-multi-factor-session";
18611861
readonly INVALID_OAUTH_CLIENT_ID: "auth/invalid-oauth-client-id";

packages/auth/demo/src/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,9 @@ function onAuthError(error) {
318318
alertError('Token expired, please reauthenticate.');
319319
}
320320
if (error.code === 'auth/invalid-credential') {
321-
alertError('login credentials invalid. It is possible that the email/password combination does not exist.');
321+
alertError(
322+
'login credentials invalid. It is possible that the email/password combination does not exist.'
323+
);
322324
}
323325
}
324326
}

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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ describe('api/authentication/revokeToken', () => {
199199

200200
await expect(revokeToken(auth, request)).to.be.rejectedWith(
201201
FirebaseError,
202-
'Firebase: The supplied auth credential is malformed or has expired. (auth/invalid-credential).'
202+
'Firebase: The supplied auth credential is incorrect, malformed or has expired. (auth/invalid-credential).'
203203
);
204204
expect(mock.calls[0].request).to.eql(request);
205205
});

packages/auth/src/api/errors.ts

Lines changed: 4 additions & 5 deletions
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

Lines changed: 4 additions & 7 deletions
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

Lines changed: 1 addition & 0 deletions
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)