diff --git a/docs-devsite/auth.auth.md b/docs-devsite/auth.auth.md
index b089a9b09bd..cbbc7a9ceb0 100644
--- a/docs-devsite/auth.auth.md
+++ b/docs-devsite/auth.auth.md
@@ -265,6 +265,8 @@ auth.setPersistence(browserSessionPersistence);
Signs out the current user. This does not automatically revoke the user's ID token.
+This method is not supported by [Auth](./auth.auth.md#auth_interface) instances created with a [FirebaseServerApp](./app.firebaseserverapp.md#firebaseserverapp_interface).
+
Signature:
```typescript
diff --git a/docs-devsite/auth.md b/docs-devsite/auth.md
index 4449c8dc1a4..10f153f53fe 100644
--- a/docs-devsite/auth.md
+++ b/docs-devsite/auth.md
@@ -381,6 +381,8 @@ On successful creation of the user account, this user will also be signed in to
User account creation can fail if the account already exists or the password is invalid.
+This method is not supported on [Auth](./auth.auth.md#auth_interface) instances created with a [FirebaseServerApp](./app.firebaseserverapp.md#firebaseserverapp_interface).
+
Note: The email address acts as a unique identifier for the user and enables an email-based password reset. This function will create a new user account and set the initial user password.
Signature:
@@ -451,7 +453,7 @@ Returns a [UserCredential](./auth.usercredential.md#usercredential_interface) fr
If sign-in succeeded, returns the signed in user. If sign-in was unsuccessful, fails with an error. If no redirect operation was called, returns `null`.
-This method does not work in a Node.js environment.
+This method does not work in a Node.js environment or with [Auth](./auth.auth.md#auth_interface) instances created with a [FirebaseServerApp](./app.firebaseserverapp.md#firebaseserverapp_interface).
Signature:
@@ -728,7 +730,7 @@ Changes the type of persistence on the [Auth](./auth.auth.md#auth_interface) ins
This makes it easy for a user signing in to specify whether their session should be remembered or not. It also makes it easier to never persist the `Auth` state for applications that are shared by other users or have sensitive data.
-This method does not work in a Node.js environment.
+This method does not work in a Node.js environment or with [Auth](./auth.auth.md#auth_interface) instances created with a [FirebaseServerApp](./app.firebaseserverapp.md#firebaseserverapp_interface).
Signature:
@@ -763,6 +765,8 @@ Asynchronously signs in as an anonymous user.
If there is already an anonymous user signed in, that user will be returned; otherwise, a new anonymous user identity will be created and returned.
+This method is not supported by [Auth](./auth.auth.md#auth_interface) instances created with a [FirebaseServerApp](./app.firebaseserverapp.md#firebaseserverapp_interface).
+
Signature:
```typescript
@@ -785,6 +789,8 @@ Asynchronously signs in with the given credentials.
An [AuthProvider](./auth.authprovider.md#authprovider_interface) can be used to generate the credential.
+This method is not supported by [Auth](./auth.auth.md#auth_interface) instances created with a [FirebaseServerApp](./app.firebaseserverapp.md#firebaseserverapp_interface).
+
Signature:
```typescript
@@ -810,6 +816,8 @@ Custom tokens are used to integrate Firebase Auth with existing auth systems, an
Fails with an error if the token is invalid, expired, or not accepted by the Firebase Auth service.
+This method is not supported by [Auth](./auth.auth.md#auth_interface) instances created with a [FirebaseServerApp](./app.firebaseserverapp.md#firebaseserverapp_interface).
+
Signature:
```typescript
@@ -833,6 +841,8 @@ Asynchronously signs in using an email and password.
Fails with an error if the email address and password do not match. When \[Email Enumeration Protection\](https://cloud.google.com/identity-platform/docs/admin/email-enumeration-protection) is enabled, this method fails with "auth/invalid-credential" in case of an invalid email/password.
+This method is not supported on [Auth](./auth.auth.md#auth_interface) instances created with a [FirebaseServerApp](./app.firebaseserverapp.md#firebaseserverapp_interface).
+
Note: The user's password is NOT the password used to access the user's email account. The email address serves as a unique identifier for the user, and the password is used to access the user's account in your Firebase project. See also: [createUserWithEmailAndPassword()](./auth.md#createuserwithemailandpassword_21ad33b).
Signature:
@@ -861,6 +871,8 @@ If no link is passed, the link is inferred from the current URL.
Fails with an error if the email address is invalid or OTP in email link expires.
+This method is not supported by [Auth](./auth.auth.md#auth_interface) instances created with a [FirebaseServerApp](./app.firebaseserverapp.md#firebaseserverapp_interface).
+
Note: Confirm the link is a sign-in email link before calling this method firebase.auth.Auth.isSignInWithEmailLink.
Signature:
@@ -913,7 +925,7 @@ This method sends a code via SMS to the given phone number, and returns a [Confi
For abuse prevention, this method also requires a [ApplicationVerifier](./auth.applicationverifier.md#applicationverifier_interface). This SDK includes a reCAPTCHA-based implementation, [RecaptchaVerifier](./auth.recaptchaverifier.md#recaptchaverifier_class). This function can work on other platforms that do not support the [RecaptchaVerifier](./auth.recaptchaverifier.md#recaptchaverifier_class) (like React Native), but you need to use a third-party [ApplicationVerifier](./auth.applicationverifier.md#applicationverifier_interface) implementation.
-This method does not work in a Node.js environment.
+This method does not work in a Node.js environment or with [Auth](./auth.auth.md#auth_interface) instances created with a [FirebaseServerApp](./app.firebaseserverapp.md#firebaseserverapp_interface).
Signature:
@@ -951,7 +963,7 @@ Authenticates a Firebase client using a popup-based OAuth authentication flow.
If succeeds, returns the signed in user along with the provider's credential. If sign in was unsuccessful, returns an error object containing additional information about the error.
-This method does not work in a Node.js environment.
+This method does not work in a Node.js environment or with [Auth](./auth.auth.md#auth_interface) instances created with a [FirebaseServerApp](./app.firebaseserverapp.md#firebaseserverapp_interface).
Signature:
@@ -993,7 +1005,7 @@ Authenticates a Firebase client using a full-page redirect flow.
To handle the results and errors for this operation, refer to [getRedirectResult()](./auth.md#getredirectresult_c35dc1f). Follow the [best practices](https://firebase.google.com/docs/auth/web/redirect-best-practices) when using [signInWithRedirect()](./auth.md#signinwithredirect_770f816).
-This method does not work in a Node.js environment.
+This method does not work in a Node.js environment or with [Auth](./auth.auth.md#auth_interface) instances created with a [FirebaseServerApp](./app.firebaseserverapp.md#firebaseserverapp_interface).
Signature:
@@ -1045,6 +1057,8 @@ const operationType = result.operationType;
Signs out the current user.
+This method is not supported by [Auth](./auth.auth.md#auth_interface) instances created with a [FirebaseServerApp](./app.firebaseserverapp.md#firebaseserverapp_interface).
+
Signature:
```typescript
@@ -1071,6 +1085,8 @@ This will trigger [onAuthStateChanged()](./auth.md#onauthstatechanged_b0d07ab) a
The operation fails with an error if the user to be updated belongs to a different Firebase project.
+This method is not supported by [Auth](./auth.auth.md#auth_interface) instances created with a [FirebaseServerApp](./app.firebaseserverapp.md#firebaseserverapp_interface).
+
Signature:
```typescript
@@ -1347,7 +1363,7 @@ Links the [OAuthProvider](./auth.oauthprovider.md#oauthprovider_class) to the us
To handle the results and errors for this operation, refer to [getRedirectResult()](./auth.md#getredirectresult_c35dc1f). Follow the [best practices](https://firebase.google.com/docs/auth/web/redirect-best-practices) when using [linkWithRedirect()](./auth.md#linkwithredirect_41c0b31).
-This method does not work in a Node.js environment.
+This method does not work in a Node.js environment or with [Auth](./auth.auth.md#auth_interface) instances created with a [FirebaseServerApp](./app.firebaseserverapp.md#firebaseserverapp_interface).
Signature:
@@ -1411,6 +1427,8 @@ Re-authenticates a user using a fresh credential.
Use before operations such as [updatePassword()](./auth.md#updatepassword_6df673e) that require tokens from recent sign-in attempts. This method can be used to recover from a `CREDENTIAL_TOO_OLD_LOGIN_AGAIN` error or a `TOKEN_EXPIRED` error.
+This method is not supported on any [User](./auth.user.md#user_interface) signed in by [Auth](./auth.auth.md#auth_interface) instances created with a [FirebaseServerApp](./app.firebaseserverapp.md#firebaseserverapp_interface).
+
Signature:
```typescript
@@ -1434,7 +1452,7 @@ Re-authenticates a user using a fresh phone credential.
Use before operations such as [updatePassword()](./auth.md#updatepassword_6df673e) that require tokens from recent sign-in attempts.
-This method does not work in a Node.js environment.
+This method does not work in a Node.js environment or on any [User](./auth.user.md#user_interface) signed in by [Auth](./auth.auth.md#auth_interface) instances created with a [FirebaseServerApp](./app.firebaseserverapp.md#firebaseserverapp_interface).
Signature:
@@ -1460,7 +1478,7 @@ Reauthenticates the current user with the specified [OAuthProvider](./auth.oauth
If the reauthentication is successful, the returned result will contain the user and the provider's credential.
-This method does not work in a Node.js environment.
+This method does not work in a Node.js environment or on any [User](./auth.user.md#user_interface) signed in by [Auth](./auth.auth.md#auth_interface) instances created with a [FirebaseServerApp](./app.firebaseserverapp.md#firebaseserverapp_interface).
Signature:
@@ -1498,7 +1516,7 @@ Reauthenticates the current user with the specified [OAuthProvider](./auth.oauth
To handle the results and errors for this operation, refer to [getRedirectResult()](./auth.md#getredirectresult_c35dc1f). Follow the [best practices](https://firebase.google.com/docs/auth/web/redirect-best-practices) when using [reauthenticateWithRedirect()](./auth.md#reauthenticatewithredirect_41c0b31).
-This method does not work in a Node.js environment.
+This method does not work in a Node.js environment or with [Auth](./auth.auth.md#auth_interface) instances created with a [FirebaseServerApp](./app.firebaseserverapp.md#firebaseserverapp_interface).
Signature:
@@ -1630,6 +1648,8 @@ Updates the user's email address.
An email will be sent to the original email address (if it was set) that allows to revoke the email address change, in order to protect them from account hijacking.
+This method is not supported on any [User](./auth.user.md#user_interface) signed in by [Auth](./auth.auth.md#auth_interface) instances created with a [FirebaseServerApp](./app.firebaseserverapp.md#firebaseserverapp_interface).
+
Important: this is a security sensitive operation that requires the user to have recently signed in. If this requirement isn't met, ask the user to authenticate again and then call [reauthenticateWithCredential()](./auth.md#reauthenticatewithcredential_60f8043).
Signature:
@@ -1676,7 +1696,7 @@ Promise<void>
Updates the user's phone number.
-This method does not work in a Node.js environment.
+This method does not work in a Node.js environment or on any [User](./auth.user.md#user_interface) signed in by [Auth](./auth.auth.md#auth_interface) instances created with a [FirebaseServerApp](./app.firebaseserverapp.md#firebaseserverapp_interface).
Signature:
diff --git a/docs-devsite/auth.user.md b/docs-devsite/auth.user.md
index a774c914f34..f28c7eeb3bc 100644
--- a/docs-devsite/auth.user.md
+++ b/docs-devsite/auth.user.md
@@ -121,6 +121,8 @@ Deletes and signs out the user.
Important: this is a security-sensitive operation that requires the user to have recently signed in. If this requirement isn't met, ask the user to authenticate again and then call one of the reauthentication methods like [reauthenticateWithCredential()](./auth.md#reauthenticatewithcredential_60f8043).
+This method is not supported on any [User](./auth.user.md#user_interface) signed in by [Auth](./auth.auth.md#auth_interface) instances created with a [FirebaseServerApp](./app.firebaseserverapp.md#firebaseserverapp_interface).
+
Signature:
```typescript
diff --git a/packages/auth/src/core/auth/auth_impl.ts b/packages/auth/src/core/auth/auth_impl.ts
index 55f474eda9e..893854852d8 100644
--- a/packages/auth/src/core/auth/auth_impl.ts
+++ b/packages/auth/src/core/auth/auth_impl.ts
@@ -62,7 +62,7 @@ import {
PersistenceUserManager
} from '../persistence/persistence_user_manager';
import { _reloadWithoutSaving } from '../user/reload';
-import { _assert } from '../util/assert';
+import { _assert, _createError } from '../util/assert';
import { _getInstance } from '../util/instantiator';
import { _getUserLanguage } from '../util/navigator';
import { _getClientVersion } from '../util/version';
@@ -354,6 +354,11 @@ export class AuthImpl implements AuthInternal, _FirebaseService {
}
async updateCurrentUser(userExtern: User | null): Promise {
+ if (_isFirebaseServerApp(this.app)) {
+ return Promise.reject(
+ _createError(this, AuthErrorCode.OPERATION_NOT_SUPPORTED)
+ );
+ }
// The public updateCurrentUser method needs to make a copy of the user,
// and also check that the project matches
const user = userExtern
@@ -395,6 +400,11 @@ export class AuthImpl implements AuthInternal, _FirebaseService {
}
async signOut(): Promise {
+ if (_isFirebaseServerApp(this.app)) {
+ return Promise.reject(
+ _createError(this, AuthErrorCode.OPERATION_NOT_SUPPORTED)
+ );
+ }
// Run first, to block _setRedirectUser() if any callbacks fail.
await this.beforeStateQueue.runMiddleware(null);
// Clear the redirect user when signOut is called
@@ -408,6 +418,11 @@ export class AuthImpl implements AuthInternal, _FirebaseService {
}
setPersistence(persistence: Persistence): Promise {
+ if (_isFirebaseServerApp(this.app)) {
+ return Promise.reject(
+ _createError(this, AuthErrorCode.OPERATION_NOT_SUPPORTED)
+ );
+ }
return this.queue(async () => {
await this.assertedPersistence.setPersistence(_getInstance(persistence));
});
diff --git a/packages/auth/src/core/index.ts b/packages/auth/src/core/index.ts
index 506d7623f25..43b1adb4bb9 100644
--- a/packages/auth/src/core/index.ts
+++ b/packages/auth/src/core/index.ts
@@ -46,7 +46,8 @@ export {
* remembered or not. It also makes it easier to never persist the `Auth` state for applications
* that are shared by other users or have sensitive data.
*
- * This method does not work in a Node.js environment.
+ * This method does not work in a Node.js environment or with {@link Auth} instances created with a
+ * {@link @firebase/app#FirebaseServerApp}.
*
* @example
* ```javascript
@@ -223,6 +224,9 @@ export function useDeviceLanguage(auth: Auth): void {
* The operation fails with an error if the user to be updated belongs to a different Firebase
* project.
*
+ * This method is not supported by {@link Auth} instances created with a
+ * {@link @firebase/app#FirebaseServerApp}.
+ *
* @param auth - The {@link Auth} instance.
* @param user - The new {@link User}.
*
@@ -237,6 +241,10 @@ export function updateCurrentUser(
/**
* Signs out the current user.
*
+ * @remarks
+ * This method is not supported by {@link Auth} instances created with a
+ * {@link @firebase/app#FirebaseServerApp}.
+ *
* @param auth - The {@link Auth} instance.
*
* @public
diff --git a/packages/auth/src/core/strategies/anonymous.ts b/packages/auth/src/core/strategies/anonymous.ts
index cd2a40f8240..e15b738d4d6 100644
--- a/packages/auth/src/core/strategies/anonymous.ts
+++ b/packages/auth/src/core/strategies/anonymous.ts
@@ -21,6 +21,9 @@ import { UserInternal } from '../../model/user';
import { UserCredentialImpl } from '../user/user_credential_impl';
import { _castAuth } from '../auth/auth_impl';
import { OperationType } from '../../model/enums';
+import { _isFirebaseServerApp } from '@firebase/app';
+import { _createError } from '../../core/util/assert';
+import { AuthErrorCode } from '../../core/errors';
/**
* Asynchronously signs in as an anonymous user.
@@ -29,11 +32,19 @@ import { OperationType } from '../../model/enums';
* If there is already an anonymous user signed in, that user will be returned; otherwise, a
* new anonymous user identity will be created and returned.
*
+ * This method is not supported by {@link Auth} instances created with a
+ * {@link @firebase/app#FirebaseServerApp}.
+ *
* @param auth - The {@link Auth} instance.
*
* @public
*/
export async function signInAnonymously(auth: Auth): Promise {
+ if (_isFirebaseServerApp(auth.app)) {
+ return Promise.reject(
+ _createError(auth, AuthErrorCode.OPERATION_NOT_SUPPORTED)
+ );
+ }
const authInternal = _castAuth(auth);
await authInternal._initializationPromise;
if (authInternal.currentUser?.isAnonymous) {
diff --git a/packages/auth/src/core/strategies/credential.ts b/packages/auth/src/core/strategies/credential.ts
index 00aa919f047..d429d3eb11b 100644
--- a/packages/auth/src/core/strategies/credential.ts
+++ b/packages/auth/src/core/strategies/credential.ts
@@ -27,12 +27,20 @@ import { UserCredentialImpl } from '../user/user_credential_impl';
import { _castAuth } from '../auth/auth_impl';
import { getModularInstance } from '@firebase/util';
import { OperationType } from '../../model/enums';
+import { _isFirebaseServerApp } from '@firebase/app';
+import { _createError } from '../../core/util/assert';
+import { AuthErrorCode } from '../../core/errors';
export async function _signInWithCredential(
auth: AuthInternal,
credential: AuthCredential,
bypassAuthState = false
): Promise {
+ if (_isFirebaseServerApp(auth.app)) {
+ return Promise.reject(
+ _createError(auth, AuthErrorCode.OPERATION_NOT_SUPPORTED)
+ );
+ }
const operationType = OperationType.SIGN_IN;
const response = await _processCredentialSavingMfaContextIfNecessary(
auth,
@@ -57,6 +65,9 @@ export async function _signInWithCredential(
* @remarks
* An {@link AuthProvider} can be used to generate the credential.
*
+ * This method is not supported by {@link Auth} instances created with a
+ * {@link @firebase/app#FirebaseServerApp}.
+ *
* @param auth - The {@link Auth} instance.
* @param credential - The auth credential.
*
@@ -99,6 +110,9 @@ export async function linkWithCredential(
* attempts. This method can be used to recover from a `CREDENTIAL_TOO_OLD_LOGIN_AGAIN` error
* or a `TOKEN_EXPIRED` error.
*
+ * This method is not supported on any {@link User} signed in by {@link Auth} instances
+ * created with a {@link @firebase/app#FirebaseServerApp}.
+ *
* @param user - The user.
* @param credential - The auth credential.
*
diff --git a/packages/auth/src/core/strategies/custom_token.ts b/packages/auth/src/core/strategies/custom_token.ts
index 6d1e1b36fe0..56dc6741453 100644
--- a/packages/auth/src/core/strategies/custom_token.ts
+++ b/packages/auth/src/core/strategies/custom_token.ts
@@ -22,7 +22,9 @@ import { IdTokenResponse } from '../../model/id_token';
import { UserCredentialImpl } from '../user/user_credential_impl';
import { _castAuth } from '../auth/auth_impl';
import { OperationType } from '../../model/enums';
-
+import { _isFirebaseServerApp } from '@firebase/app';
+import { _createError } from '../../core/util/assert';
+import { AuthErrorCode } from '../../core/errors';
/**
* Asynchronously signs in using a custom token.
*
@@ -34,6 +36,9 @@ import { OperationType } from '../../model/enums';
*
* Fails with an error if the token is invalid, expired, or not accepted by the Firebase Auth service.
*
+ * This method is not supported by {@link Auth} instances created with a
+ * {@link @firebase/app#FirebaseServerApp}.
+ *
* @param auth - The {@link Auth} instance.
* @param customToken - The custom token to sign in with.
*
@@ -43,6 +48,11 @@ export async function signInWithCustomToken(
auth: Auth,
customToken: string
): Promise {
+ if (_isFirebaseServerApp(auth.app)) {
+ return Promise.reject(
+ _createError(auth, AuthErrorCode.OPERATION_NOT_SUPPORTED)
+ );
+ }
const authInternal = _castAuth(auth);
const response: IdTokenResponse = await getIdTokenResponse(authInternal, {
token: customToken,
diff --git a/packages/auth/src/core/strategies/email_and_password.ts b/packages/auth/src/core/strategies/email_and_password.ts
index 86855dfa8b2..4e3d1304507 100644
--- a/packages/auth/src/core/strategies/email_and_password.ts
+++ b/packages/auth/src/core/strategies/email_and_password.ts
@@ -29,7 +29,7 @@ import { signUp, SignUpRequest } from '../../api/authentication/sign_up';
import { MultiFactorInfoImpl } from '../../mfa/mfa_info';
import { EmailAuthProvider } from '../providers/email';
import { UserCredentialImpl } from '../user/user_credential_impl';
-import { _assert } from '../util/assert';
+import { _assert, _createError } from '../util/assert';
import { _setActionCodeSettingsOnRequest } from './action_code_settings';
import { signInWithCredential } from './credential';
import { _castAuth } from '../auth/auth_impl';
@@ -39,6 +39,7 @@ import { OperationType } from '../../model/enums';
import { handleRecaptchaFlow } from '../../platform_browser/recaptcha/recaptcha_enterprise_verifier';
import { IdTokenResponse } from '../../model/id_token';
import { RecaptchaActionName, RecaptchaClientType } from '../../api';
+import { _isFirebaseServerApp } from '@firebase/app';
/**
* Updates the password policy cached in the {@link Auth} instance if a policy is already
@@ -253,6 +254,9 @@ export async function verifyPasswordResetCode(
*
* User account creation can fail if the account already exists or the password is invalid.
*
+ * This method is not supported on {@link Auth} instances created with a
+ * {@link @firebase/app#FirebaseServerApp}.
+ *
* Note: The email address acts as a unique identifier for the user and enables an email-based
* password reset. This function will create a new user account and set the initial user password.
*
@@ -267,6 +271,11 @@ export async function createUserWithEmailAndPassword(
email: string,
password: string
): Promise {
+ if (_isFirebaseServerApp(auth.app)) {
+ return Promise.reject(
+ _createError(auth, AuthErrorCode.OPERATION_NOT_SUPPORTED)
+ );
+ }
const authInternal = _castAuth(auth);
const request: SignUpRequest = {
returnSecureToken: true,
@@ -308,10 +317,14 @@ export async function createUserWithEmailAndPassword(
* When [Email Enumeration Protection](https://cloud.google.com/identity-platform/docs/admin/email-enumeration-protection) is enabled,
* this method fails with "auth/invalid-credential" in case of an invalid email/password.
*
+ * This method is not supported on {@link Auth} instances created with a
+ * {@link @firebase/app#FirebaseServerApp}.
+ *
* Note: The user's password is NOT the password used to access the user's email account. The
* email address serves as a unique identifier for the user, and the password is used to access
* the user's account in your Firebase project. See also: {@link createUserWithEmailAndPassword}.
*
+ *
* @param auth - The {@link Auth} instance.
* @param email - The users email address.
* @param password - The users password.
@@ -323,6 +336,11 @@ export function signInWithEmailAndPassword(
email: string,
password: string
): Promise {
+ if (_isFirebaseServerApp(auth.app)) {
+ return Promise.reject(
+ _createError(auth, AuthErrorCode.OPERATION_NOT_SUPPORTED)
+ );
+ }
return signInWithCredential(
getModularInstance(auth),
EmailAuthProvider.credential(email, password)
diff --git a/packages/auth/src/core/strategies/email_link.ts b/packages/auth/src/core/strategies/email_link.ts
index 55f95226656..f9dd75bbe26 100644
--- a/packages/auth/src/core/strategies/email_link.ts
+++ b/packages/auth/src/core/strategies/email_link.ts
@@ -34,6 +34,8 @@ import { getModularInstance } from '@firebase/util';
import { _castAuth } from '../auth/auth_impl';
import { handleRecaptchaFlow } from '../../platform_browser/recaptcha/recaptcha_enterprise_verifier';
import { RecaptchaActionName, RecaptchaClientType } from '../../api';
+import { _isFirebaseServerApp } from '@firebase/app';
+import { _createError } from '../../core/util/assert';
/**
* Sends a sign-in email link to the user with the specified email.
@@ -131,6 +133,9 @@ export function isSignInWithEmailLink(auth: Auth, emailLink: string): boolean {
*
* Fails with an error if the email address is invalid or OTP in email link expires.
*
+ * This method is not supported by {@link Auth} instances created with a
+ * {@link @firebase/app#FirebaseServerApp}.
+ *
* Note: Confirm the link is a sign-in email link before calling this method firebase.auth.Auth.isSignInWithEmailLink.
*
* @example
@@ -154,6 +159,7 @@ export function isSignInWithEmailLink(auth: Auth, emailLink: string): boolean {
* }
* ```
*
+ *
* @param auth - The {@link Auth} instance.
* @param email - The user's email address.
* @param emailLink - The link sent to the user's email address.
@@ -165,6 +171,11 @@ export async function signInWithEmailLink(
email: string,
emailLink?: string
): Promise {
+ if (_isFirebaseServerApp(auth.app)) {
+ return Promise.reject(
+ _createError(auth, AuthErrorCode.OPERATION_NOT_SUPPORTED)
+ );
+ }
const authModular = getModularInstance(auth);
const credential = EmailAuthProvider.credentialWithLink(
email,
diff --git a/packages/auth/src/core/user/account_info.ts b/packages/auth/src/core/user/account_info.ts
index 3f061630435..d59669f153c 100644
--- a/packages/auth/src/core/user/account_info.ts
+++ b/packages/auth/src/core/user/account_info.ts
@@ -26,6 +26,9 @@ import { UserInternal } from '../../model/user';
import { _logoutIfInvalidated } from './invalidation';
import { getModularInstance } from '@firebase/util';
import { ProviderId } from '../../model/enums';
+import { _isFirebaseServerApp } from '@firebase/app';
+import { _createError } from '../../core/util/assert';
+import { AuthErrorCode } from '../../core/errors';
/**
* Updates a user's profile data.
@@ -81,6 +84,9 @@ export async function updateProfile(
* An email will be sent to the original email address (if it was set) that allows to revoke the
* email address change, in order to protect them from account hijacking.
*
+ * This method is not supported on any {@link User} signed in by {@link Auth} instances
+ * created with a {@link @firebase/app#FirebaseServerApp}.
+ *
* Important: this is a security sensitive operation that requires the user to have recently signed
* in. If this requirement isn't met, ask the user to authenticate again and then call
* {@link reauthenticateWithCredential}.
@@ -94,11 +100,13 @@ export async function updateProfile(
* @public
*/
export function updateEmail(user: User, newEmail: string): Promise {
- return updateEmailOrPassword(
- getModularInstance(user) as UserInternal,
- newEmail,
- null
- );
+ const userInternal = getModularInstance(user) as UserInternal;
+ if (_isFirebaseServerApp(userInternal.auth.app)) {
+ return Promise.reject(
+ _createError(userInternal.auth, AuthErrorCode.OPERATION_NOT_SUPPORTED)
+ );
+ }
+ return updateEmailOrPassword(userInternal, newEmail, null);
}
/**
diff --git a/packages/auth/src/core/user/reauthenticate.ts b/packages/auth/src/core/user/reauthenticate.ts
index a88b9479b51..eb2a6c5b57d 100644
--- a/packages/auth/src/core/user/reauthenticate.ts
+++ b/packages/auth/src/core/user/reauthenticate.ts
@@ -25,6 +25,8 @@ import { _assert, _fail } from '../util/assert';
import { _parseToken } from './id_token_result';
import { _logoutIfInvalidated } from './invalidation';
import { UserCredentialImpl } from './user_credential_impl';
+import { _isFirebaseServerApp } from '@firebase/app';
+import { _createError } from '../../core/util/assert';
export async function _reauthenticate(
user: UserInternal,
@@ -32,6 +34,11 @@ export async function _reauthenticate(
bypassAuthState = false
): Promise {
const { auth } = user;
+ if (_isFirebaseServerApp(auth.app)) {
+ return Promise.reject(
+ _createError(auth, AuthErrorCode.OPERATION_NOT_SUPPORTED)
+ );
+ }
const operationType = OperationType.REAUTHENTICATE;
try {
diff --git a/packages/auth/src/core/user/user_impl.ts b/packages/auth/src/core/user/user_impl.ts
index 0aa91861cb9..468bdc163ce 100644
--- a/packages/auth/src/core/user/user_impl.ts
+++ b/packages/auth/src/core/user/user_impl.ts
@@ -32,7 +32,7 @@ import {
} from '../../model/user';
import { AuthErrorCode } from '../errors';
import { PersistedBlob } from '../persistence';
-import { _assert } from '../util/assert';
+import { _assert, _createError } from '../util/assert';
import { getIdTokenResult } from './id_token_result';
import { _logoutIfInvalidated } from './invalidation';
import { ProactiveRefresh } from './proactive_refresh';
@@ -40,6 +40,7 @@ import { extractProviderData, _reloadWithoutSaving, reload } from './reload';
import { StsTokenManager } from './token_manager';
import { UserMetadata } from './user_metadata';
import { ProviderId } from '../../model/enums';
+import { _isFirebaseServerApp } from '@firebase/app';
function assertStringOrUndefined(
assertion: unknown,
@@ -200,6 +201,11 @@ export class UserImpl implements UserInternal {
}
async delete(): Promise {
+ if (_isFirebaseServerApp(this.auth.app)) {
+ return Promise.reject(
+ _createError(this.auth, AuthErrorCode.OPERATION_NOT_SUPPORTED)
+ );
+ }
const idToken = await this.getIdToken();
await _logoutIfInvalidated(this, deleteAccount(this.auth, { idToken }));
this.stsTokenManager.clearRefreshToken();
diff --git a/packages/auth/src/model/public_types.ts b/packages/auth/src/model/public_types.ts
index 0390ba5e30d..ea9b9e0c213 100644
--- a/packages/auth/src/model/public_types.ts
+++ b/packages/auth/src/model/public_types.ts
@@ -322,6 +322,10 @@ export interface Auth {
useDeviceLanguage(): void;
/**
* Signs out the current user. This does not automatically revoke the user's ID token.
+ *
+ * @remarks
+ * This method is not supported by {@link Auth} instances created with a
+ * {@link @firebase/app#FirebaseServerApp}.
*/
signOut(): Promise;
}
@@ -1004,6 +1008,9 @@ export interface User extends UserInfo {
* Important: this is a security-sensitive operation that requires the user to have recently
* signed in. If this requirement isn't met, ask the user to authenticate again and then call
* one of the reauthentication methods like {@link reauthenticateWithCredential}.
+ *
+ * This method is not supported on any {@link User} signed in by {@link Auth} instances
+ * created with a {@link @firebase/app#FirebaseServerApp}.
*/
delete(): Promise;
/**
diff --git a/packages/auth/src/platform_browser/strategies/phone.ts b/packages/auth/src/platform_browser/strategies/phone.ts
index 745385c2db9..5e027284275 100644
--- a/packages/auth/src/platform_browser/strategies/phone.ts
+++ b/packages/auth/src/platform_browser/strategies/phone.ts
@@ -31,7 +31,7 @@ import { ApplicationVerifierInternal } from '../../model/application_verifier';
import { PhoneAuthCredential } from '../../core/credentials/phone';
import { AuthErrorCode } from '../../core/errors';
import { _assertLinkedStatus, _link } from '../../core/user/link_unlink';
-import { _assert } from '../../core/util/assert';
+import { _assert, _createError } from '../../core/util/assert';
import { AuthInternal } from '../../model/auth';
import {
linkWithCredential,
@@ -47,6 +47,7 @@ import { RECAPTCHA_VERIFIER_TYPE } from '../recaptcha/recaptcha_verifier';
import { _castAuth } from '../../core/auth/auth_impl';
import { getModularInstance } from '@firebase/util';
import { ProviderId } from '../../model/enums';
+import { _isFirebaseServerApp } from '@firebase/app';
interface OnConfirmationCallback {
(credential: PhoneAuthCredential): Promise;
@@ -82,7 +83,8 @@ class ConfirmationResultImpl implements ConfirmationResult {
* {@link RecaptchaVerifier} (like React Native), but you need to use a
* third-party {@link ApplicationVerifier} implementation.
*
- * This method does not work in a Node.js environment.
+ * This method does not work in a Node.js environment or with {@link Auth} instances created with a
+ * {@link @firebase/app#FirebaseServerApp}.
*
* @example
* ```javascript
@@ -104,6 +106,11 @@ export async function signInWithPhoneNumber(
phoneNumber: string,
appVerifier: ApplicationVerifier
): Promise {
+ if (_isFirebaseServerApp(auth.app)) {
+ return Promise.reject(
+ _createError(auth, AuthErrorCode.OPERATION_NOT_SUPPORTED)
+ );
+ }
const authInternal = _castAuth(auth);
const verificationId = await _verifyPhoneNumber(
authInternal,
@@ -150,7 +157,8 @@ export async function linkWithPhoneNumber(
* @remarks
* Use before operations such as {@link updatePassword} that require tokens from recent sign-in attempts.
*
- * This method does not work in a Node.js environment.
+ * This method does not work in a Node.js environment or on any {@link User} signed in by
+ * {@link Auth} instances created with a {@link @firebase/app#FirebaseServerApp}.
*
* @param user - The user.
* @param phoneNumber - The user's phone number in E.164 format (e.g. +16505550101).
@@ -164,6 +172,11 @@ export async function reauthenticateWithPhoneNumber(
appVerifier: ApplicationVerifier
): Promise {
const userInternal = getModularInstance(user) as UserInternal;
+ if (_isFirebaseServerApp(userInternal.auth.app)) {
+ return Promise.reject(
+ _createError(userInternal.auth, AuthErrorCode.OPERATION_NOT_SUPPORTED)
+ );
+ }
const verificationId = await _verifyPhoneNumber(
userInternal.auth,
phoneNumber,
@@ -259,7 +272,8 @@ export async function _verifyPhoneNumber(
* Updates the user's phone number.
*
* @remarks
- * This method does not work in a Node.js environment.
+ * This method does not work in a Node.js environment or on any {@link User} signed in by
+ * {@link Auth} instances created with a {@link @firebase/app#FirebaseServerApp}.
*
* @example
* ```
@@ -281,5 +295,11 @@ export async function updatePhoneNumber(
user: User,
credential: PhoneAuthCredential
): Promise {
- await _link(getModularInstance(user) as UserInternal, credential);
+ const userInternal = getModularInstance(user) as UserInternal;
+ if (_isFirebaseServerApp(userInternal.auth.app)) {
+ return Promise.reject(
+ _createError(userInternal.auth, AuthErrorCode.OPERATION_NOT_SUPPORTED)
+ );
+ }
+ await _link(userInternal, credential);
}
diff --git a/packages/auth/src/platform_browser/strategies/popup.ts b/packages/auth/src/platform_browser/strategies/popup.ts
index e47e03cd3f7..12ba128aca9 100644
--- a/packages/auth/src/platform_browser/strategies/popup.ts
+++ b/packages/auth/src/platform_browser/strategies/popup.ts
@@ -44,6 +44,7 @@ import { AuthPopup } from '../util/popup';
import { AbstractPopupRedirectOperation } from '../../core/strategies/abstract_popup_redirect_operation';
import { FederatedAuthProvider } from '../../core/providers/federated';
import { getModularInstance } from '@firebase/util';
+import { _isFirebaseServerApp } from '@firebase/app';
/*
* The event timeout is the same on mobile and desktop, no need for Delay. Set this to 8s since
@@ -63,7 +64,8 @@ export const _POLL_WINDOW_CLOSE_TIMEOUT = new Delay(2000, 10000);
* If succeeds, returns the signed in user along with the provider's credential. If sign in was
* unsuccessful, returns an error object containing additional information about the error.
*
- * This method does not work in a Node.js environment.
+ * This method does not work in a Node.js environment or with {@link Auth} instances created with a
+ * {@link @firebase/app#FirebaseServerApp}.
*
* @example
* ```javascript
@@ -91,6 +93,11 @@ export async function signInWithPopup(
provider: AuthProvider,
resolver?: PopupRedirectResolver
): Promise {
+ if (_isFirebaseServerApp(auth.app)) {
+ return Promise.reject(
+ _createError(auth, AuthErrorCode.OPERATION_NOT_SUPPORTED)
+ );
+ }
const authInternal = _castAuth(auth);
_assertInstanceOf(auth, provider, FederatedAuthProvider);
const resolverInternal = _withDefaultResolver(authInternal, resolver);
@@ -111,7 +118,8 @@ export async function signInWithPopup(
* If the reauthentication is successful, the returned result will contain the user and the
* provider's credential.
*
- * This method does not work in a Node.js environment.
+ * This method does not work in a Node.js environment or on any {@link User} signed in by
+ * {@link Auth} instances created with a {@link @firebase/app#FirebaseServerApp}.
*
* @example
* ```javascript
@@ -136,6 +144,11 @@ export async function reauthenticateWithPopup(
resolver?: PopupRedirectResolver
): Promise {
const userInternal = getModularInstance(user) as UserInternal;
+ if (_isFirebaseServerApp(userInternal.auth.app)) {
+ return Promise.reject(
+ _createError(userInternal.auth, AuthErrorCode.OPERATION_NOT_SUPPORTED)
+ );
+ }
_assertInstanceOf(userInternal.auth, provider, FederatedAuthProvider);
const resolverInternal = _withDefaultResolver(userInternal.auth, resolver);
const action = new PopupOperation(
diff --git a/packages/auth/src/platform_browser/strategies/redirect.ts b/packages/auth/src/platform_browser/strategies/redirect.ts
index 8586ea589d2..0c4abaf82f8 100644
--- a/packages/auth/src/platform_browser/strategies/redirect.ts
+++ b/packages/auth/src/platform_browser/strategies/redirect.ts
@@ -25,7 +25,7 @@ import {
import { _castAuth } from '../../core/auth/auth_impl';
import { _assertLinkedStatus } from '../../core/user/link_unlink';
-import { _assertInstanceOf } from '../../core/util/assert';
+import { _assertInstanceOf, _createError } from '../../core/util/assert';
import { _generateEventId } from '../../core/util/event_id';
import { AuthEventType } from '../../model/popup_redirect';
import { UserInternal } from '../../model/user';
@@ -36,6 +36,8 @@ import {
} from '../../core/strategies/redirect';
import { FederatedAuthProvider } from '../../core/providers/federated';
import { getModularInstance } from '@firebase/util';
+import { _isFirebaseServerApp } from '@firebase/app';
+import { AuthErrorCode } from '../../core/errors';
/**
* Authenticates a Firebase client using a full-page redirect flow.
@@ -45,7 +47,8 @@ import { getModularInstance } from '@firebase/util';
* Follow the {@link https://firebase.google.com/docs/auth/web/redirect-best-practices
* | best practices} when using {@link signInWithRedirect}.
*
- * This method does not work in a Node.js environment.
+ * This method does not work in a Node.js environment or with {@link Auth} instances created with a
+ * {@link @firebase/app#FirebaseServerApp}.
*
* @example
* ```javascript
@@ -93,6 +96,11 @@ export async function _signInWithRedirect(
provider: AuthProvider,
resolver?: PopupRedirectResolver
): Promise {
+ if (_isFirebaseServerApp(auth.app)) {
+ return Promise.reject(
+ _createError(auth, AuthErrorCode.OPERATION_NOT_SUPPORTED)
+ );
+ }
const authInternal = _castAuth(auth);
_assertInstanceOf(auth, provider, FederatedAuthProvider);
// Wait for auth initialization to complete, this will process pending redirects and clear the
@@ -116,7 +124,8 @@ export async function _signInWithRedirect(
* Follow the {@link https://firebase.google.com/docs/auth/web/redirect-best-practices
* | best practices} when using {@link reauthenticateWithRedirect}.
*
- * This method does not work in a Node.js environment.
+ * This method does not work in a Node.js environment or with {@link Auth} instances
+ * created with a {@link @firebase/app#FirebaseServerApp}.
*
* @example
* ```javascript
@@ -161,6 +170,11 @@ export async function _reauthenticateWithRedirect(
): Promise {
const userInternal = getModularInstance(user) as UserInternal;
_assertInstanceOf(userInternal.auth, provider, FederatedAuthProvider);
+ if (_isFirebaseServerApp(userInternal.auth.app)) {
+ return Promise.reject(
+ _createError(userInternal.auth, AuthErrorCode.OPERATION_NOT_SUPPORTED)
+ );
+ }
// Wait for auth initialization to complete, this will process pending redirects and clear the
// PENDING_REDIRECT_KEY in persistence. This should be completed before starting a new
// redirect and creating a PENDING_REDIRECT_KEY entry.
@@ -185,7 +199,8 @@ export async function _reauthenticateWithRedirect(
* Follow the {@link https://firebase.google.com/docs/auth/web/redirect-best-practices
* | best practices} when using {@link linkWithRedirect}.
*
- * This method does not work in a Node.js environment.
+ * This method does not work in a Node.js environment or with {@link Auth} instances
+ * created with a {@link @firebase/app#FirebaseServerApp}.
*
* @example
* ```javascript
@@ -247,7 +262,8 @@ export async function _linkWithRedirect(
* If sign-in succeeded, returns the signed in user. If sign-in was unsuccessful, fails with an
* error. If no redirect operation was called, returns `null`.
*
- * This method does not work in a Node.js environment.
+ * This method does not work in a Node.js environment or with {@link Auth} instances created with a
+ * {@link @firebase/app#FirebaseServerApp}.
*
* @example
* ```javascript
@@ -293,6 +309,11 @@ export async function _getRedirectResult(
resolverExtern?: PopupRedirectResolver,
bypassAuthState = false
): Promise {
+ if (_isFirebaseServerApp(auth.app)) {
+ return Promise.reject(
+ _createError(auth, AuthErrorCode.OPERATION_NOT_SUPPORTED)
+ );
+ }
const authInternal = _castAuth(auth);
const resolver = _withDefaultResolver(authInternal, resolverExtern);
const action = new RedirectAction(authInternal, resolver, bypassAuthState);
diff --git a/packages/auth/test/integration/flows/firebaseserverapp.test.ts b/packages/auth/test/integration/flows/firebaseserverapp.test.ts
index 42b14eb2edc..917430089c4 100644
--- a/packages/auth/test/integration/flows/firebaseserverapp.test.ts
+++ b/packages/auth/test/integration/flows/firebaseserverapp.test.ts
@@ -21,16 +21,27 @@ import chaiAsPromised from 'chai-as-promised';
// eslint-disable-next-line import/no-extraneous-dependencies
import {
Auth,
- OperationType,
createUserWithEmailAndPassword,
+ EmailAuthProvider,
getAdditionalUserInfo,
+ getRedirectResult,
+ GoogleAuthProvider,
onAuthStateChanged,
+ OperationType,
+ reauthenticateWithCredential,
signInAnonymously,
+ signInWithCredential,
+ signInWithCustomToken,
+ signInWithEmailAndPassword,
+ signInWithEmailLink,
+ signInWithRedirect,
signOut,
+ updateCurrentUser,
+ updateEmail,
updateProfile
} from '@firebase/auth';
-import { isBrowser } from '@firebase/util';
-import { initializeServerApp } from '@firebase/app';
+import { isBrowser, FirebaseError } from '@firebase/util';
+import { initializeServerApp, deleteApp } from '@firebase/app';
import {
cleanUpTestInstance,
@@ -47,17 +58,12 @@ const signInWaitDuration = 200;
describe('Integration test: Auth FirebaseServerApp tests', () => {
let auth: Auth;
- let serverAppAuth: Auth | null;
beforeEach(() => {
auth = getTestInstance();
});
afterEach(async () => {
- if (serverAppAuth) {
- await signOut(serverAppAuth);
- serverAppAuth = null;
- }
await cleanUpTestInstance(auth);
});
@@ -79,7 +85,7 @@ describe('Integration test: Auth FirebaseServerApp tests', () => {
const firebaseServerAppSettings = { authIdToken };
const serverApp = initializeServerApp(auth.app, firebaseServerAppSettings);
- serverAppAuth = getTestInstanceForServerApp(serverApp);
+ const serverAppAuth = getTestInstanceForServerApp(serverApp);
console.log('auth.emulatorConfig ', auth.emulatorConfig);
console.log('serverAuth.emulatorConfig ', serverAppAuth.emulatorConfig);
@@ -105,6 +111,8 @@ describe('Integration test: Auth FirebaseServerApp tests', () => {
});
expect(numberServerLogins).to.equal(1);
+
+ await deleteApp(serverApp);
});
it('getToken operations fullfilled or rejected', async () => {
@@ -126,7 +134,7 @@ describe('Integration test: Auth FirebaseServerApp tests', () => {
getAppConfig(),
firebaseServerAppSettings
);
- serverAppAuth = getTestInstanceForServerApp(serverApp);
+ const serverAppAuth = getTestInstanceForServerApp(serverApp);
let numberServerLogins = 0;
onAuthStateChanged(serverAppAuth, serverAuthUser => {
if (serverAuthUser) {
@@ -154,6 +162,8 @@ describe('Integration test: Auth FirebaseServerApp tests', () => {
await expect(serverAppAuth.currentUser.getIdToken(/*forceRefresh=*/ true))
.to.be.rejected;
}
+
+ await deleteApp(serverApp);
});
it('invalid token does not sign in user', async () => {
@@ -167,7 +177,7 @@ describe('Integration test: Auth FirebaseServerApp tests', () => {
getAppConfig(),
firebaseServerAppSettings
);
- serverAppAuth = getTestInstanceForServerApp(serverApp);
+ const serverAppAuth = getTestInstanceForServerApp(serverApp);
expect(serverAppAuth.currentUser).to.be.null;
let numberServerLogins = 0;
@@ -183,6 +193,8 @@ describe('Integration test: Auth FirebaseServerApp tests', () => {
expect(numberServerLogins).to.equal(0);
expect(serverAppAuth.currentUser).to.be.null;
+
+ await deleteApp(serverApp);
});
it('signs in with email crednetial user', async () => {
@@ -213,7 +225,7 @@ describe('Integration test: Auth FirebaseServerApp tests', () => {
getAppConfig(),
firebaseServerAppSettings
);
- serverAppAuth = getTestInstanceForServerApp(serverApp);
+ const serverAppAuth = getTestInstanceForServerApp(serverApp);
let numberServerLogins = 0;
onAuthStateChanged(serverAppAuth, serverAuthUser => {
if (serverAuthUser) {
@@ -238,6 +250,8 @@ describe('Integration test: Auth FirebaseServerApp tests', () => {
});
expect(numberServerLogins).to.equal(1);
+
+ await deleteApp(serverApp);
});
it('can reload user', async () => {
@@ -258,7 +272,7 @@ describe('Integration test: Auth FirebaseServerApp tests', () => {
getAppConfig(),
firebaseServerAppSettings
);
- serverAppAuth = getTestInstanceForServerApp(serverApp);
+ const serverAppAuth = getTestInstanceForServerApp(serverApp);
let numberServerLogins = 0;
onAuthStateChanged(serverAppAuth, serverAuthUser => {
if (serverAuthUser) {
@@ -280,6 +294,8 @@ describe('Integration test: Auth FirebaseServerApp tests', () => {
await serverAppAuth.currentUser.reload();
}
expect(numberServerLogins).to.equal(1);
+
+ await deleteApp(serverApp);
});
it('can update server based user profile', async () => {
@@ -301,7 +317,7 @@ describe('Integration test: Auth FirebaseServerApp tests', () => {
getAppConfig(),
firebaseServerAppSettings
);
- serverAppAuth = getTestInstanceForServerApp(serverApp);
+ const serverAppAuth = getTestInstanceForServerApp(serverApp);
let numberServerLogins = 0;
const newDisplayName = 'newName';
onAuthStateChanged(serverAppAuth, serverAuthUser => {
@@ -336,6 +352,8 @@ describe('Integration test: Auth FirebaseServerApp tests', () => {
expect(serverAppAuth.currentUser?.displayName).to.not.be.null;
expect(serverAppAuth.currentUser?.displayName).to.equal(newDisplayName);
}
+
+ await deleteApp(serverApp);
});
it('can sign out of main auth and still use server auth', async () => {
@@ -357,7 +375,7 @@ describe('Integration test: Auth FirebaseServerApp tests', () => {
getAppConfig(),
firebaseServerAppSettings
);
- serverAppAuth = getTestInstanceForServerApp(serverApp);
+ const serverAppAuth = getTestInstanceForServerApp(serverApp);
let numberServerLogins = 0;
onAuthStateChanged(serverAppAuth, serverAuthUser => {
if (serverAuthUser) {
@@ -387,5 +405,124 @@ describe('Integration test: Auth FirebaseServerApp tests', () => {
if (serverAppAuth) {
expect(serverAppAuth.currentUser).to.not.be.null;
}
+
+ await deleteApp(serverApp);
+ });
+
+ it('auth operations fail correctly on FirebaseServerApp instances', async () => {
+ if (isBrowser()) {
+ return;
+ }
+ const userCred = await signInAnonymously(auth);
+ expect(auth.currentUser).to.eq(userCred.user);
+
+ const user = userCred.user;
+ expect(user).to.equal(auth.currentUser);
+ expect(user.uid).to.be.a('string');
+
+ const authIdToken = await user.getIdToken();
+ const firebaseServerAppSettings = { authIdToken };
+
+ const serverApp = initializeServerApp(
+ getAppConfig(),
+ firebaseServerAppSettings
+ );
+
+ const serverAppAuth = getTestInstanceForServerApp(serverApp);
+ await new Promise(resolve => {
+ setTimeout(resolve, signInWaitDuration);
+ });
+
+ expect(serverAppAuth.currentUser).to.not.be.null;
+ const email = randomEmail();
+ const password = 'password';
+
+ // Auth tests:
+ await expect(
+ createUserWithEmailAndPassword(serverAppAuth, email, password)
+ ).to.be.rejectedWith(
+ FirebaseError,
+ 'operation-not-supported-in-this-environment'
+ );
+ await expect(
+ signInWithRedirect(serverAppAuth, new GoogleAuthProvider())
+ ).to.be.rejectedWith(
+ FirebaseError,
+ 'operation-not-supported-in-this-environment'
+ );
+ await expect(getRedirectResult(serverAppAuth)).to.be.rejectedWith(
+ FirebaseError,
+ 'operation-not-supported-in-this-environment'
+ );
+ await expect(signInAnonymously(serverAppAuth)).to.be.rejectedWith(
+ FirebaseError,
+ 'operation-not-supported-in-this-environment'
+ );
+
+ const credential = EmailAuthProvider.credential(email, password);
+ await expect(
+ signInWithCredential(serverAppAuth, credential)
+ ).to.be.rejectedWith(
+ FirebaseError,
+ 'operation-not-supported-in-this-environment'
+ );
+
+ await expect(
+ signInWithCustomToken(serverAppAuth, 'custom token')
+ ).to.be.rejectedWith(
+ FirebaseError,
+ 'operation-not-supported-in-this-environment'
+ );
+ await expect(
+ signInWithEmailAndPassword(serverAppAuth, email, password)
+ ).to.be.rejectedWith(
+ FirebaseError,
+ 'operation-not-supported-in-this-environment'
+ );
+ await expect(
+ signInWithEmailLink(serverAppAuth, email, 'email link')
+ ).to.be.rejectedWith(
+ FirebaseError,
+ 'operation-not-supported-in-this-environment'
+ );
+ await expect(
+ updateCurrentUser(serverAppAuth, serverAppAuth.currentUser)
+ ).to.be.rejectedWith(
+ FirebaseError,
+ 'operation-not-supported-in-this-environment'
+ );
+ await expect(
+ updateCurrentUser(serverAppAuth, serverAppAuth.currentUser)
+ ).to.be.rejectedWith(
+ FirebaseError,
+ 'operation-not-supported-in-this-environment'
+ );
+ await expect(signOut(serverAppAuth)).to.be.rejectedWith(
+ FirebaseError,
+ 'operation-not-supported-in-this-environment'
+ );
+
+ if (serverAppAuth.currentUser !== null) {
+ await expect(
+ reauthenticateWithCredential(serverAppAuth.currentUser, credential)
+ ).to.be.rejectedWith(
+ FirebaseError,
+ 'operation-not-supported-in-this-environment'
+ );
+
+ await expect(serverAppAuth.currentUser.delete()).to.be.rejectedWith(
+ FirebaseError,
+ 'operation-not-supported-in-this-environment'
+ );
+
+ await expect(
+ updateEmail(serverAppAuth.currentUser, email)
+ ).to.be.rejectedWith(
+ FirebaseError,
+ 'operation-not-supported-in-this-environment'
+ );
+ }
+
+ await deleteApp(serverApp);
});
});