diff --git a/.changeset/shy-bats-wave.md b/.changeset/shy-bats-wave.md
new file mode 100644
index 00000000000..d234f2925c2
--- /dev/null
+++ b/.changeset/shy-bats-wave.md
@@ -0,0 +1,5 @@
+---
+'@firebase/app': patch
+---
+
+FirebaseServerApp should not be JSON serializable
diff --git a/docs-devsite/app.firebaseserverappsettings.md b/docs-devsite/app.firebaseserverappsettings.md
index 20c335b04a6..59aba9bca78 100644
--- a/docs-devsite/app.firebaseserverappsettings.md
+++ b/docs-devsite/app.firebaseserverappsettings.md
@@ -23,7 +23,7 @@ export interface FirebaseServerAppSettings extends FirebaseAppSettings
| Property | Type | Description |
| --- | --- | --- |
-| [authIdToken](./app.firebaseserverappsettings.md#firebaseserverappsettingsauthidtoken) | string | An optional Auth ID token used to resume a signed in user session from a client runtime environment.Invoking getAuth
with a FirebaseServerApp
configured with a validated authIdToken
causes an automatic attempt to sign in the user that the authIdToken
represents. The token needs to have been recently minted for this operation to succeed.If the token fails local verification, or if the Auth service has failed to validate it when the Auth SDK is initialized, then a warning is logged to the console and the Auth SDK will not sign in a user on initalization.If a user is successfully signed in, then the Auth instance's onAuthStateChanged
callback is invoked with the User
object as per standard Auth flows. However, User
objects created via an authIdToken
do not have a refresh token. Attempted refreshToken
operations fail. |
+| [authIdToken](./app.firebaseserverappsettings.md#firebaseserverappsettingsauthidtoken) | string | An optional Auth ID token used to resume a signed in user session from a client runtime environment.Invoking getAuth
with a FirebaseServerApp
configured with a validated authIdToken
causes an automatic attempt to sign in the user that the authIdToken
represents. The token needs to have been recently minted for this operation to succeed.If the token fails local verification, or if the Auth service has failed to validate it when the Auth SDK is initialized, then a warning is logged to the console and the Auth SDK will not sign in a user on initialization.If a user is successfully signed in, then the Auth instance's onAuthStateChanged
callback is invoked with the User
object as per standard Auth flows. However, User
objects created via an authIdToken
do not have a refresh token. Attempted refreshToken
operations fail. |
| [name](./app.firebaseserverappsettings.md#firebaseserverappsettingsname) | undefined | There is no getApp()
operation for FirebaseServerApp
, so the name is not relevant for applications. However, it may be used internally, and is declared here so that FirebaseServerApp
conforms to the FirebaseApp
interface. |
| [releaseOnDeref](./app.firebaseserverappsettings.md#firebaseserverappsettingsreleaseonderef) | object | An optional object. If provided, the Firebase SDK uses a FinalizationRegistry
object to monitor the garbage collection status of the provided object. The Firebase SDK releases its reference on the FirebaseServerApp
instance when the provided releaseOnDeref
object is garbage collected.You can use this field to reduce memory management overhead for your application. If provided, an app running in a SSR pass does not need to perform FirebaseServerApp
cleanup, so long as the reference object is deleted (by falling out of SSR scope, for instance.)If an object is not provided then the application must clean up the FirebaseServerApp
instance by invoking deleteApp
.If the application provides an object in this parameter, but the application is executed in a JavaScript engine that predates the support of FinalizationRegistry
(introduced in node v14.6.0, for instance), then an error is thrown at FirebaseServerApp
initialization. |
@@ -33,7 +33,7 @@ An optional Auth ID token used to resume a signed in user session from a client
Invoking `getAuth` with a `FirebaseServerApp` configured with a validated `authIdToken` causes an automatic attempt to sign in the user that the `authIdToken` represents. The token needs to have been recently minted for this operation to succeed.
-If the token fails local verification, or if the Auth service has failed to validate it when the Auth SDK is initialized, then a warning is logged to the console and the Auth SDK will not sign in a user on initalization.
+If the token fails local verification, or if the Auth service has failed to validate it when the Auth SDK is initialized, then a warning is logged to the console and the Auth SDK will not sign in a user on initialization.
If a user is successfully signed in, then the Auth instance's `onAuthStateChanged` callback is invoked with the `User` object as per standard Auth flows. However, `User` objects created via an `authIdToken` do not have a refresh token. Attempted `refreshToken` operations fail.
diff --git a/packages/app/src/firebaseServerApp.test.ts b/packages/app/src/firebaseServerApp.test.ts
index 408b5f09922..bf2da5c06d5 100644
--- a/packages/app/src/firebaseServerApp.test.ts
+++ b/packages/app/src/firebaseServerApp.test.ts
@@ -135,4 +135,24 @@ describe('FirebaseServerApp', () => {
expect(() => app.settings).throws('Firebase Server App has been deleted');
});
+
+ it('should not be JSON serializable', () => {
+ const options = {
+ apiKey: 'APIKEY'
+ };
+
+ const serverAppSettings: FirebaseServerAppSettings = {
+ automaticDataCollectionEnabled: false,
+ releaseOnDeref: options
+ };
+
+ const app = new FirebaseServerAppImpl(
+ options,
+ serverAppSettings,
+ 'testName',
+ new ComponentContainer('test')
+ );
+
+ expect(JSON.stringify(app)).to.eql(undefined);
+ });
});
diff --git a/packages/app/src/firebaseServerApp.ts b/packages/app/src/firebaseServerApp.ts
index b40471c903f..6b6c33d316b 100644
--- a/packages/app/src/firebaseServerApp.ts
+++ b/packages/app/src/firebaseServerApp.ts
@@ -82,6 +82,10 @@ export class FirebaseServerAppImpl
registerVersion(packageName, version, 'serverapp');
}
+ toJSON(): undefined {
+ return undefined;
+ }
+
get refCount(): number {
return this._refCount;
}
diff --git a/packages/app/src/public-types.ts b/packages/app/src/public-types.ts
index ad2b441933a..eb963a54adf 100644
--- a/packages/app/src/public-types.ts
+++ b/packages/app/src/public-types.ts
@@ -186,7 +186,7 @@ export interface FirebaseServerAppSettings extends FirebaseAppSettings {
*
* If the token fails local verification, or if the Auth service has failed to validate it when
* the Auth SDK is initialized, then a warning is logged to the console and the Auth SDK will not
- * sign in a user on initalization.
+ * sign in a user on initialization.
*
* If a user is successfully signed in, then the Auth instance's `onAuthStateChanged` callback
* is invoked with the `User` object as per standard Auth flows. However, `User` objects