Skip to content

[FirebaseServerApp] Remove authIDTokenVerified method #8089

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion common/api-review/app.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ export interface FirebaseOptions {

// @public
export interface FirebaseServerApp extends FirebaseApp {
authIdTokenVerified: () => Promise<void>;
name: string;
readonly settings: FirebaseServerAppSettings;
}
Expand Down
15 changes: 0 additions & 15 deletions docs-devsite/app.firebaseserverapp.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,9 @@ export interface FirebaseServerApp extends FirebaseApp

| Property | Type | Description |
| --- | --- | --- |
| [authIdTokenVerified](./app.firebaseserverapp.md#firebaseserverappauthidtokenverified) | () =&gt; Promise&lt;void&gt; | Checks to see if the local verification of the <code>authIdToken</code> provided to [initializeServerApp()](./app.md#initializeserverapp_30ab697) has completed.<!-- -->It is recommend that your application awaits this <code>Promise</code> before invoking <code>getAuth</code> if an <code>authIdToken</code> was provided in the <code>FirebaseServerAppSettings</code>.<!-- -->The returned <code>Promise</code> is completed immediately if the optional <code>authIdToken</code> parameter was omitted from <code>FirebaseServerApp</code> initialization. |
| [name](./app.firebaseserverapp.md#firebaseserverappname) | string | There is no <code>getApp()</code> operation for <code>FirebaseServerApp</code>, so the name is not relevant for applications. However, it may be used internally, and is declared here so that <code>FirebaseServerApp</code> conforms to the <code>FirebaseApp</code> interface. |
| [settings](./app.firebaseserverapp.md#firebaseserverappsettings) | [FirebaseServerAppSettings](./app.firebaseserverappsettings.md#firebaseserverappsettings_interface) | The (read-only) configuration settings for this server app. These are the original parameters given in [initializeServerApp()](./app.md#initializeserverapp_30ab697)<!-- -->. |

## FirebaseServerApp.authIdTokenVerified

Checks to see if the local verification of the `authIdToken` provided to [initializeServerApp()](./app.md#initializeserverapp_30ab697) has completed.

It is recommend that your application awaits this `Promise` before invoking `getAuth` if an `authIdToken` was provided in the `FirebaseServerAppSettings`<!-- -->.

The returned `Promise` is completed immediately if the optional `authIdToken` parameter was omitted from `FirebaseServerApp` initialization.

<b>Signature:</b>

```typescript
authIdTokenVerified: () => Promise<void>;
```

## FirebaseServerApp.name

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.
Expand Down
4 changes: 1 addition & 3 deletions docs-devsite/app.firebaseserverappsettings.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,14 @@ 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.<!-- -->If provided, the <code>FirebaseServerApp</code> works to validate the token even before <code>Auth</code> is initialized. The result of the validation can be queried via . Awaiting the <code>Promise</code> returned by is highly recommended if an <code>authIdToken</code> token is provided.<!-- -->Invoking <code>getAuth</code> with a <code>FirebaseServerApp</code> configured with a validated <code>authIdToken</code> causes an automatic attempt to sign in the user that the <code>authIdToken</code> 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 <code>onAuthStateChanged</code> callback is invoked with the <code>User</code> object as per standard Auth flows. However, <code>User</code> objects created via an <code>authIdToken</code> do not have a refresh token. Attempted <code>refreshToken</code> 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 <code>getAuth</code> with a <code>FirebaseServerApp</code> configured with a validated <code>authIdToken</code> causes an automatic attempt to sign in the user that the <code>authIdToken</code> 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 <code>onAuthStateChanged</code> callback is invoked with the <code>User</code> object as per standard Auth flows. However, <code>User</code> objects created via an <code>authIdToken</code> do not have a refresh token. Attempted <code>refreshToken</code> operations fail. |
| [name](./app.firebaseserverappsettings.md#firebaseserverappsettingsname) | undefined | There is no <code>getApp()</code> operation for <code>FirebaseServerApp</code>, so the name is not relevant for applications. However, it may be used internally, and is declared here so that <code>FirebaseServerApp</code> conforms to the <code>FirebaseApp</code> interface. |
| [releaseOnDeref](./app.firebaseserverappsettings.md#firebaseserverappsettingsreleaseonderef) | object | An optional object. If provided, the Firebase SDK uses a <code>FinalizationRegistry</code> object to monitor the garbage collection status of the provided object. The Firebase SDK releases its reference on the <code>FirebaseServerApp</code> instance when the provided <code>releaseOnDeref</code> 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 <code>FirebaseServerApp</code> 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 <code>FirebaseServerApp</code> instance by invoking <code>deleteApp</code>.<!-- -->If the application provides an object in this parameter, but the application is executed in a JavaScript engine that predates the support of <code>FinalizationRegistry</code> (introduced in node v14.6.0, for instance), then an error is thrown at <code>FirebaseServerApp</code> initialization. |

## FirebaseServerAppSettings.authIdToken

An optional Auth ID token used to resume a signed in user session from a client runtime environment.

If provided, the `FirebaseServerApp` works to validate the token even before `Auth` is initialized. The result of the validation can be queried via . Awaiting the `Promise` returned by is highly recommended if an `authIdToken` token is provided.

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.
Expand Down
6 changes: 2 additions & 4 deletions packages/app/src/firebaseServerApp.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,9 @@ describe('FirebaseServerApp', () => {
new ComponentContainer('test')
);

expect(() => app.authIdTokenVerified).to.not.throw();
expect(() => app.settings).to.not.throw();
(app as unknown as FirebaseServerAppImpl).isDeleted = true;

expect(() => app.authIdTokenVerified()).throws(
'Firebase Server App has been deleted'
);
expect(() => app.settings).throws('Firebase Server App has been deleted');
});
});
6 changes: 0 additions & 6 deletions packages/app/src/firebaseServerApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,6 @@ export class FirebaseServerAppImpl
return this._serverConfig;
}

authIdTokenVerified(): Promise<void> {
this.checkDestroyed();
// TODO
return Promise.resolve();
}

/**
* This function will throw an Error if the App has already been deleted -
* use before performing API actions on the App.
Expand Down
2 changes: 1 addition & 1 deletion packages/app/src/internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ export function _isFirebaseApp(
export function _isFirebaseServerApp(
obj: FirebaseApp | FirebaseServerApp
): obj is FirebaseServerApp {
return (obj as FirebaseServerApp).authIdTokenVerified !== undefined;
return (obj as FirebaseServerApp).settings !== undefined;
}

/**
Expand Down
18 changes: 0 additions & 18 deletions packages/app/src/public-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,18 +82,6 @@ export interface FirebaseApp {
* @public
*/
export interface FirebaseServerApp extends FirebaseApp {
/**
* Checks to see if the local verification of the `authIdToken` provided to
* {@link (initializeServerApp:1) | initializeServerApp()} has completed.
*
* It is recommend that your application awaits this `Promise` before invoking `getAuth` if an
* `authIdToken` was provided in the `FirebaseServerAppSettings`.
*
* The returned `Promise` is completed immediately if the optional `authIdToken` parameter
* was omitted from `FirebaseServerApp` initialization.
*/
authIdTokenVerified: () => Promise<void>;

/**
* 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
Expand Down Expand Up @@ -192,12 +180,6 @@ export interface FirebaseServerAppSettings extends FirebaseAppSettings {
* An optional Auth ID token used to resume a signed in user session from a client
* runtime environment.
*
* If provided, the `FirebaseServerApp` works to validate the token even before
* `Auth` is initialized. The result of the validation can be queried via
* {@link (FirebaseServerApp.authIdTokenVerified()}. Awaiting the `Promise` returned by
* {@link (FirebaseServerApp.authIdTokenVerified()} is highly recommended if an `authIdToken`
* token is provided.
*
* 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.
Expand Down