Skip to content

Commit cf7b8fc

Browse files
committed
Add comments and public annotations, fix promise
1 parent 4bc0bcf commit cf7b8fc

File tree

3 files changed

+43
-16
lines changed

3 files changed

+43
-16
lines changed

common/api-review/util.api.md

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -195,21 +195,16 @@ export class FirebaseError extends Error {
195195
// @public
196196
export type FirebaseSignInProvider = 'custom' | 'email' | 'password' | 'phone' | 'anonymous' | 'google.com' | 'facebook.com' | 'github.com' | 'twitter.com' | 'microsoft.com' | 'apple.com';
197197

198-
// Warning: (ae-missing-release-tag) "getDefaultAppConfig" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
199-
//
200-
// @public (undocumented)
198+
// @public
201199
export const getDefaultAppConfig: () => Record<string, string> | undefined;
202200

203-
// Warning: (ae-missing-release-tag) "getDefaultEmulatorHost" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
204-
//
205-
// @public (undocumented)
206-
export const getDefaultEmulatorHost: (name: string) => string | undefined;
201+
// @public
202+
export const getDefaultEmulatorHost: (productName: string) => string | undefined;
207203

208204
// Warning: (ae-forgotten-export) The symbol "ExperimentalKey" needs to be exported by the entry point index.d.ts
209205
// Warning: (ae-forgotten-export) The symbol "FirebaseDefaults" needs to be exported by the entry point index.d.ts
210-
// Warning: (ae-missing-release-tag) "getExperimentalSetting" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
211206
//
212-
// @public (undocumented)
207+
// @public
213208
export const getExperimentalSetting: <T extends ExperimentalKey>(name: T) => FirebaseDefaults[`_${T}`];
214209

215210
// Warning: (ae-missing-release-tag) "getGlobal" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)

packages/auth/src/platform_browser/index.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,7 @@ export function getAuth(app: FirebaseApp = getApp()): Auth {
8989
const authTokenSyncUrl = getExperimentalSetting('authTokenSyncURL');
9090
if (authTokenSyncUrl) {
9191
const mintCookie = mintCookieFactory(authTokenSyncUrl);
92-
beforeAuthStateChanged(auth, mintCookie, () => {
93-
void mintCookie(auth.currentUser);
94-
});
92+
beforeAuthStateChanged(auth, mintCookie, () => mintCookie(auth.currentUser));
9593
onIdTokenChanged(auth, user => mintCookie(user));
9694
}
9795

packages/util/src/defaults.ts

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,23 @@
1818
import { base64Decode } from './crypt';
1919
import { getGlobal } from './environment';
2020

21-
type ExperimentalKey = 'authTokenSyncURL' | 'authIdTokenMaxAge';
21+
/**
22+
* Keys for experimental properties on the `FirebaseDefaults` object.
23+
* @public
24+
*/
25+
export type ExperimentalKey = 'authTokenSyncURL' | 'authIdTokenMaxAge';
2226

23-
interface FirebaseDefaults {
27+
/**
28+
* An object that can be injected into the environment as __FIREBASE_DEFAULTS__,
29+
* either as a property of globalThis, a shell environment variable, or a
30+
* cookie.
31+
*
32+
* This object can be used to automatically configure and initialize
33+
* a Firebase app as well as any emulators.
34+
*
35+
* @public
36+
*/
37+
export interface FirebaseDefaults {
2438
config?: Record<string, string>;
2539
emulatorHosts?: Record<string, string>;
2640
_authTokenSyncURL?: string;
@@ -81,17 +95,37 @@ const getDefaultsFromCookie = (): FirebaseDefaults | undefined => {
8195
return decoded && JSON.parse(decoded);
8296
};
8397

98+
/**
99+
* Get the __FIREBASE_DEFAULTS__ object. It checks in order:
100+
* (1) if such an object exists as a property of `globalThis`
101+
* (2) if such an object was provided on a shell environment variable
102+
* (3) if such an object exists in a cookie
103+
*/
84104
const getDefaults = (): FirebaseDefaults | undefined =>
85105
getDefaultsFromGlobal() ||
86106
getDefaultsFromEnvVariable() ||
87107
getDefaultsFromCookie();
88108

89-
export const getDefaultEmulatorHost = (name: string): string | undefined =>
90-
getDefaults()?.emulatorHosts?.[name];
109+
/**
110+
* Returns emulator host stored in the __FIREBASE_DEFAULTS__ object
111+
* for the given product.
112+
* @public
113+
*/
114+
export const getDefaultEmulatorHost = (productName: string): string | undefined =>
115+
getDefaults()?.emulatorHosts?.[productName];
91116

117+
/**
118+
* Returns Firebase app config stored in the __FIREBASE_DEFAULTS__ object.
119+
* @public
120+
*/
92121
export const getDefaultAppConfig = (): Record<string, string> | undefined =>
93122
getDefaults()?.config;
94123

124+
/**
125+
* Returns an experimental setting on the __FIREBASE_DEFAULTS__ object (properties
126+
* prefixed by "_")
127+
* @public
128+
*/
95129
export const getExperimentalSetting = <T extends ExperimentalKey>(
96130
name: T
97131
): FirebaseDefaults[`_${T}`] =>

0 commit comments

Comments
 (0)