Skip to content

Commit 73f40f5

Browse files
Merge master into release
2 parents 1eb302f + c8a2568 commit 73f40f5

File tree

105 files changed

+4574
-2111
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

105 files changed

+4574
-2111
lines changed

.changeset/afraid-fishes-repair.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
'@firebase/auth': minor
3+
'@firebase/app': minor
4+
'firebase': minor
5+
---
6+
7+
Added the new `FirebaseServerApp` interface to bridge state
8+
data between client and server runtime environments. This interface extends `FirebaseApp`.

.changeset/green-mugs-protect.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@firebase/auth': patch
3+
---
4+
5+
Additional protection against misuse of the authTokenSyncURL experiment

.changeset/smart-turkeys-run.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@firebase/auth': patch
3+
---
4+
5+
Updated transitive dependencies based on generated dependabot security reports. For more information see [PR #8088](https://github.com/firebase/firebase-js-sdk/pull/8088/files).

.changeset/thick-eagles-collect.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
---
2+
'@firebase/analytics-interop-types': patch
3+
'@firebase/app-check-interop-types': patch
4+
'@firebase/messaging-interop-types': patch
5+
'@firebase/installations-compat': patch
6+
'@firebase/remote-config-compat': patch
7+
'@firebase/installations-types': patch
8+
'@firebase/remote-config-types': patch
9+
'@firebase/auth-interop-types': patch
10+
'@firebase/performance-compat': patch
11+
'@firebase/rules-unit-testing': patch
12+
'@firebase/webchannel-wrapper': patch
13+
'@firebase/performance-types': patch
14+
'@firebase/analytics-compat': patch
15+
'@firebase/app-check-compat': patch
16+
'@firebase/firestore-compat': patch
17+
'@firebase/functions-compat': patch
18+
'@firebase/messaging-compat': patch
19+
'@firebase/analytics-types': patch
20+
'@firebase/app-check-types': patch
21+
'@firebase/database-compat': patch
22+
'@firebase/firestore-types': patch
23+
'@firebase/functions-types': patch
24+
'@firebase/database-types': patch
25+
'@firebase/storage-compat': patch
26+
'@firebase/template-types': patch
27+
'@firebase/installations': patch
28+
'@firebase/remote-config': patch
29+
'@firebase/storage-types': patch
30+
'@firebase/auth-compat': patch
31+
'@firebase/performance': patch
32+
'@firebase/app-compat': patch
33+
'@firebase/auth-types': patch
34+
'@firebase/analytics': patch
35+
'@firebase/app-check': patch
36+
'@firebase/app-types': patch
37+
'@firebase/component': patch
38+
'@firebase/firestore': patch
39+
'@firebase/functions': patch
40+
'@firebase/messaging': patch
41+
'@firebase/database': patch
42+
'firebase': patch
43+
'@firebase/template': patch
44+
'@firebase/storage': patch
45+
'@firebase/logger': patch
46+
'@firebase/auth': patch
47+
'@firebase/util': patch
48+
'@firebase/app': patch
49+
---
50+
51+
Update `repository.url` field in all `package.json` files to NPM's preferred format.

.github/workflows/test-all.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,6 @@ jobs:
161161
name: (Firestore) Node.js and Browser (Chrome) Tests
162162
needs: build
163163
runs-on: ubuntu-latest
164-
if: false
165-
# Disable test for now since it's failing 100% of the time since
166-
# https://github.com/firebase/firebase-js-sdk/pull/7453 and it needs to be investigated.
167164
steps:
168165
# install Chrome so the correct version of webdriver can be installed by chromedriver when setting up the repo
169166
- name: install Chrome stable

common/api-review/app.api.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,19 @@ export interface FirebaseOptions {
7171
storageBucket?: string;
7272
}
7373

74+
// @public
75+
export interface FirebaseServerApp extends FirebaseApp {
76+
name: string;
77+
readonly settings: FirebaseServerAppSettings;
78+
}
79+
80+
// @public
81+
export interface FirebaseServerAppSettings extends FirebaseAppSettings {
82+
authIdToken?: string;
83+
name?: undefined;
84+
releaseOnDeref?: object;
85+
}
86+
7487
// @internal (undocumented)
7588
export interface _FirebaseService {
7689
// (undocumented)
@@ -96,6 +109,15 @@ export function initializeApp(options: FirebaseOptions, config?: FirebaseAppSett
96109
// @public
97110
export function initializeApp(): FirebaseApp;
98111

112+
// @public
113+
export function initializeServerApp(options: FirebaseOptions | FirebaseApp, config: FirebaseServerAppSettings): FirebaseServerApp;
114+
115+
// @internal (undocumented)
116+
export function _isFirebaseApp(obj: FirebaseApp | FirebaseOptions): obj is FirebaseApp;
117+
118+
// @internal (undocumented)
119+
export function _isFirebaseServerApp(obj: FirebaseApp | FirebaseServerApp): obj is FirebaseServerApp;
120+
99121
// @public
100122
export function onLog(logCallback: LogCallback | null, options?: LogOptions): void;
101123

@@ -111,6 +133,9 @@ export function _removeServiceInstance<T extends Name>(app: FirebaseApp, name: T
111133
// @public
112134
export const SDK_VERSION: string;
113135

136+
// @internal (undocumented)
137+
export const _serverApps: Map<string, FirebaseServerApp>;
138+
114139
// @public
115140
export function setLogLevel(logLevel: LogLevelString): void;
116141

config/tsconfig.base.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"es2015.core",
1616
"es2017.object",
1717
"es2017.string",
18+
"ESNext.WeakRef",
1819
],
1920
"module": "ES2015",
2021
"moduleResolution": "node",

docs-devsite/app.firebaseserverapp.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
Project: /docs/reference/js/_project.yaml
2+
Book: /docs/reference/_book.yaml
3+
page_type: reference
4+
5+
{% comment %}
6+
DO NOT EDIT THIS FILE!
7+
This is generated by the JS SDK team, and any local changes will be
8+
overwritten. Changes should be made in the source code at
9+
https://github.com/firebase/firebase-js-sdk
10+
{% endcomment %}
11+
12+
# FirebaseServerApp interface
13+
A [FirebaseServerApp](./app.firebaseserverapp.md#firebaseserverapp_interface) holds the initialization information for a collection of services running in server environments.
14+
15+
Do not call this constructor directly. Instead, use [initializeServerApp()](./app.md#initializeserverapp_30ab697) to create an app.
16+
17+
<b>Signature:</b>
18+
19+
```typescript
20+
export interface FirebaseServerApp extends FirebaseApp
21+
```
22+
<b>Extends:</b> [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface)
23+
24+
## Properties
25+
26+
| Property | Type | Description |
27+
| --- | --- | --- |
28+
| [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. |
29+
| [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)<!-- -->. |
30+
31+
## FirebaseServerApp.name
32+
33+
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.
34+
35+
<b>Signature:</b>
36+
37+
```typescript
38+
name: string;
39+
```
40+
41+
## FirebaseServerApp.settings
42+
43+
The (read-only) configuration settings for this server app. These are the original parameters given in [initializeServerApp()](./app.md#initializeserverapp_30ab697)<!-- -->.
44+
45+
<b>Signature:</b>
46+
47+
```typescript
48+
readonly settings: FirebaseServerAppSettings;
49+
```
50+
51+
### Example
52+
53+
54+
```javascript
55+
const app = initializeServerApp(settings);
56+
console.log(app.settings.authIdToken === options.authIdToken); // true
57+
58+
```
59+
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
Project: /docs/reference/js/_project.yaml
2+
Book: /docs/reference/_book.yaml
3+
page_type: reference
4+
5+
{% comment %}
6+
DO NOT EDIT THIS FILE!
7+
This is generated by the JS SDK team, and any local changes will be
8+
overwritten. Changes should be made in the source code at
9+
https://github.com/firebase/firebase-js-sdk
10+
{% endcomment %}
11+
12+
# FirebaseServerAppSettings interface
13+
Configuration options given to [initializeServerApp()](./app.md#initializeserverapp_30ab697)
14+
15+
<b>Signature:</b>
16+
17+
```typescript
18+
export interface FirebaseServerAppSettings extends FirebaseAppSettings
19+
```
20+
<b>Extends:</b> [FirebaseAppSettings](./app.firebaseappsettings.md#firebaseappsettings_interface)
21+
22+
## Properties
23+
24+
| Property | Type | Description |
25+
| --- | --- | --- |
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. |
27+
| [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. |
28+
| [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. |
29+
30+
## FirebaseServerAppSettings.authIdToken
31+
32+
An optional Auth ID token used to resume a signed in user session from a client runtime environment.
33+
34+
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.
35+
36+
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.
37+
38+
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.
39+
40+
<b>Signature:</b>
41+
42+
```typescript
43+
authIdToken?: string;
44+
```
45+
46+
## FirebaseServerAppSettings.name
47+
48+
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.
49+
50+
<b>Signature:</b>
51+
52+
```typescript
53+
name?: undefined;
54+
```
55+
56+
## FirebaseServerAppSettings.releaseOnDeref
57+
58+
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.
59+
60+
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.)
61+
62+
If an object is not provided then the application must clean up the `FirebaseServerApp` instance by invoking `deleteApp`<!-- -->.
63+
64+
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.
65+
66+
<b>Signature:</b>
67+
68+
```typescript
69+
releaseOnDeref?: object;
70+
```

docs-devsite/app.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ This package coordinates the communication between the different Firebase compon
3434
| <b>function(options, ...)</b> |
3535
| [initializeApp(options, name)](./app.md#initializeapp_cb2f5e1) | Creates and initializes a [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) instance.<!-- -->See [Add Firebase to your app](https://firebase.google.com/docs/web/setup#add_firebase_to_your_app) and [Initialize multiple projects](https://firebase.google.com/docs/web/setup#multiple-projects) for detailed documentation. |
3636
| [initializeApp(options, config)](./app.md#initializeapp_079e917) | Creates and initializes a FirebaseApp instance. |
37+
| [initializeServerApp(options, config)](./app.md#initializeserverapp_30ab697) | Creates and initializes a [FirebaseServerApp](./app.firebaseserverapp.md#firebaseserverapp_interface) instance.<!-- -->The <code>FirebaseServerApp</code> is similar to <code>FirebaseApp</code>, but is intended for execution in server side rendering environments only. Initialization will fail if invoked from a browser environment.<!-- -->See [Add Firebase to your app](https://firebase.google.com/docs/web/setup#add_firebase_to_your_app) and [Initialize multiple projects](https://firebase.google.com/docs/web/setup#multiple-projects) for detailed documentation. |
3738

3839
## Interfaces
3940

@@ -42,6 +43,8 @@ This package coordinates the communication between the different Firebase compon
4243
| [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) | A [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) holds the initialization information for a collection of services.<!-- -->Do not call this constructor directly. Instead, use [initializeApp()](./app.md#initializeapp_cb2f5e1) to create an app. |
4344
| [FirebaseAppSettings](./app.firebaseappsettings.md#firebaseappsettings_interface) | Configuration options given to [initializeApp()](./app.md#initializeapp_cb2f5e1) |
4445
| [FirebaseOptions](./app.firebaseoptions.md#firebaseoptions_interface) | Firebase configuration object. Contains a set of parameters required by services in order to successfully communicate with Firebase server APIs and to associate client data with your Firebase project and Firebase application. Typically this object is populated by the Firebase console at project setup. See also: [Learn about the Firebase config object](https://firebase.google.com/docs/web/setup#config-object)<!-- -->. |
46+
| [FirebaseServerApp](./app.firebaseserverapp.md#firebaseserverapp_interface) | A [FirebaseServerApp](./app.firebaseserverapp.md#firebaseserverapp_interface) holds the initialization information for a collection of services running in server environments.<!-- -->Do not call this constructor directly. Instead, use [initializeServerApp()](./app.md#initializeserverapp_30ab697) to create an app. |
47+
| [FirebaseServerAppSettings](./app.firebaseserverappsettings.md#firebaseserverappsettings_interface) | Configuration options given to [initializeServerApp()](./app.md#initializeserverapp_30ab697) |
4548

4649
## Variables
4750

@@ -309,6 +312,54 @@ export declare function initializeApp(options: FirebaseOptions, config?: Firebas
309312

310313
[FirebaseApp](./app.firebaseapp.md#firebaseapp_interface)
311314

315+
### initializeServerApp(options, config) {:#initializeserverapp_30ab697}
316+
317+
Creates and initializes a [FirebaseServerApp](./app.firebaseserverapp.md#firebaseserverapp_interface) instance.
318+
319+
The `FirebaseServerApp` is similar to `FirebaseApp`<!-- -->, but is intended for execution in server side rendering environments only. Initialization will fail if invoked from a browser environment.
320+
321+
See [Add Firebase to your app](https://firebase.google.com/docs/web/setup#add_firebase_to_your_app) and [Initialize multiple projects](https://firebase.google.com/docs/web/setup#multiple-projects) for detailed documentation.
322+
323+
<b>Signature:</b>
324+
325+
```typescript
326+
export declare function initializeServerApp(options: FirebaseOptions | FirebaseApp, config: FirebaseServerAppSettings): FirebaseServerApp;
327+
```
328+
329+
#### Parameters
330+
331+
| Parameter | Type | Description |
332+
| --- | --- | --- |
333+
| options | [FirebaseOptions](./app.firebaseoptions.md#firebaseoptions_interface) \| [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) | <code>Firebase.AppOptions</code> to configure the app's services, or a a <code>FirebaseApp</code> instance which contains the <code>AppOptions</code> within. |
334+
| config | [FirebaseServerAppSettings](./app.firebaseserverappsettings.md#firebaseserverappsettings_interface) | <code>FirebaseServerApp</code> configuration. |
335+
336+
<b>Returns:</b>
337+
338+
[FirebaseServerApp](./app.firebaseserverapp.md#firebaseserverapp_interface)
339+
340+
The initialized `FirebaseServerApp`<!-- -->.
341+
342+
### Example
343+
344+
345+
```javascript
346+
347+
// Initialize an instance of `FirebaseServerApp`.
348+
// Retrieve your own options values by adding a web app on
349+
// https://console.firebase.google.com
350+
initializeServerApp({
351+
apiKey: "AIza....", // Auth / General Use
352+
authDomain: "YOUR_APP.firebaseapp.com", // Auth with popup/redirect
353+
databaseURL: "https://YOUR_APP.firebaseio.com", // Realtime Database
354+
storageBucket: "YOUR_APP.appspot.com", // Storage
355+
messagingSenderId: "123456789" // Cloud Messaging
356+
},
357+
{
358+
authIdToken: "Your Auth ID Token"
359+
});
360+
361+
```
362+
312363
## SDK\_VERSION
313364

314365
The current SDK version.

docs-devsite/auth.auth.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,8 @@ auth.setPersistence(browserSessionPersistence);
265265

266266
Signs out the current user. This does not automatically revoke the user's ID token.
267267

268+
This method is not supported by [Auth](./auth.auth.md#auth_interface) instances created with a [FirebaseServerApp](./app.firebaseserverapp.md#firebaseserverapp_interface)<!-- -->.
269+
268270
<b>Signature:</b>
269271

270272
```typescript

0 commit comments

Comments
 (0)