Skip to content

Commit 9f74ac9

Browse files
authored
Remove authIDTokenVerified (#8089)
We're rethinking how authIDTokenVerified should be used. It might reside in its own function. Remove the method for now.
1 parent e3e3339 commit 9f74ac9

File tree

7 files changed

+4
-48
lines changed

7 files changed

+4
-48
lines changed

common/api-review/app.api.md

-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ export interface FirebaseOptions {
7373

7474
// @public
7575
export interface FirebaseServerApp extends FirebaseApp {
76-
authIdTokenVerified: () => Promise<void>;
7776
name: string;
7877
readonly settings: FirebaseServerAppSettings;
7978
}

docs-devsite/app.firebaseserverapp.md

-15
Original file line numberDiff line numberDiff line change
@@ -25,24 +25,9 @@ export interface FirebaseServerApp extends FirebaseApp
2525
2626
| Property | Type | Description |
2727
| --- | --- | --- |
28-
| [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. |
2928
| [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. |
3029
| [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)<!-- -->. |
3130
32-
## FirebaseServerApp.authIdTokenVerified
33-
34-
Checks to see if the local verification of the `authIdToken` provided to [initializeServerApp()](./app.md#initializeserverapp_30ab697) has completed.
35-
36-
It is recommend that your application awaits this `Promise` before invoking `getAuth` if an `authIdToken` was provided in the `FirebaseServerAppSettings`<!-- -->.
37-
38-
The returned `Promise` is completed immediately if the optional `authIdToken` parameter was omitted from `FirebaseServerApp` initialization.
39-
40-
<b>Signature:</b>
41-
42-
```typescript
43-
authIdTokenVerified: () => Promise<void>;
44-
```
45-
4631
## FirebaseServerApp.name
4732
4833
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.

docs-devsite/app.firebaseserverappsettings.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,14 @@ export interface FirebaseServerAppSettings extends FirebaseAppSettings
2323
2424
| Property | Type | Description |
2525
| --- | --- | --- |
26-
| [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. |
26+
| [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. |
2727
| [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. |
2828
| [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. |
2929
3030
## FirebaseServerAppSettings.authIdToken
3131
3232
An optional Auth ID token used to resume a signed in user session from a client runtime environment.
3333
34-
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.
35-
3634
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.
3735
3836
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.

packages/app/src/firebaseServerApp.test.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,9 @@ describe('FirebaseServerApp', () => {
130130
new ComponentContainer('test')
131131
);
132132

133-
expect(() => app.authIdTokenVerified).to.not.throw();
133+
expect(() => app.settings).to.not.throw();
134134
(app as unknown as FirebaseServerAppImpl).isDeleted = true;
135135

136-
expect(() => app.authIdTokenVerified()).throws(
137-
'Firebase Server App has been deleted'
138-
);
136+
expect(() => app.settings).throws('Firebase Server App has been deleted');
139137
});
140138
});

packages/app/src/firebaseServerApp.ts

-6
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,6 @@ export class FirebaseServerAppImpl
115115
return this._serverConfig;
116116
}
117117

118-
authIdTokenVerified(): Promise<void> {
119-
this.checkDestroyed();
120-
// TODO
121-
return Promise.resolve();
122-
}
123-
124118
/**
125119
* This function will throw an Error if the App has already been deleted -
126120
* use before performing API actions on the App.

packages/app/src/internal.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ export function _isFirebaseApp(
170170
export function _isFirebaseServerApp(
171171
obj: FirebaseApp | FirebaseServerApp
172172
): obj is FirebaseServerApp {
173-
return (obj as FirebaseServerApp).authIdTokenVerified !== undefined;
173+
return (obj as FirebaseServerApp).settings !== undefined;
174174
}
175175

176176
/**

packages/app/src/public-types.ts

-18
Original file line numberDiff line numberDiff line change
@@ -82,18 +82,6 @@ export interface FirebaseApp {
8282
* @public
8383
*/
8484
export interface FirebaseServerApp extends FirebaseApp {
85-
/**
86-
* Checks to see if the local verification of the `authIdToken` provided to
87-
* {@link (initializeServerApp:1) | initializeServerApp()} has completed.
88-
*
89-
* It is recommend that your application awaits this `Promise` before invoking `getAuth` if an
90-
* `authIdToken` was provided in the `FirebaseServerAppSettings`.
91-
*
92-
* The returned `Promise` is completed immediately if the optional `authIdToken` parameter
93-
* was omitted from `FirebaseServerApp` initialization.
94-
*/
95-
authIdTokenVerified: () => Promise<void>;
96-
9785
/**
9886
* There is no `getApp()` operation for `FirebaseServerApp`, so the name is not relevant for
9987
* applications. However, it may be used internally, and is declared here so that
@@ -192,12 +180,6 @@ export interface FirebaseServerAppSettings extends FirebaseAppSettings {
192180
* An optional Auth ID token used to resume a signed in user session from a client
193181
* runtime environment.
194182
*
195-
* If provided, the `FirebaseServerApp` works to validate the token even before
196-
* `Auth` is initialized. The result of the validation can be queried via
197-
* {@link (FirebaseServerApp.authIdTokenVerified()}. Awaiting the `Promise` returned by
198-
* {@link (FirebaseServerApp.authIdTokenVerified()} is highly recommended if an `authIdToken`
199-
* token is provided.
200-
*
201183
* Invoking `getAuth` with a `FirebaseServerApp` configured with a validated `authIdToken`
202184
* causes an automatic attempt to sign in the user that the `authIdToken` represents. The token
203185
* needs to have been recently minted for this operation to succeed.

0 commit comments

Comments
 (0)