1 | /**
|
2 | * Firebase App
|
3 | *
|
4 | * @remarks This package coordinates the communication between the different Firebase components
|
5 | * @packageDocumentation
|
6 | */
|
7 |
|
8 | import { Component } from '@firebase/component';
|
9 | import { ComponentContainer } from '@firebase/component';
|
10 | import { FirebaseError } from '@firebase/util';
|
11 | import { LogCallback } from '@firebase/logger';
|
12 | import { LogLevelString } from '@firebase/logger';
|
13 | import { LogOptions } from '@firebase/logger';
|
14 | import { Name } from '@firebase/component';
|
15 | import { Provider } from '@firebase/component';
|
16 |
|
17 | /* Excluded from this release type: _addComponent */
|
18 |
|
19 | /* Excluded from this release type: _addOrOverwriteComponent */
|
20 |
|
21 | /* Excluded from this release type: _apps */
|
22 |
|
23 | /* Excluded from this release type: _clearComponents */
|
24 |
|
25 | /* Excluded from this release type: _components */
|
26 |
|
27 | /* Excluded from this release type: _DEFAULT_ENTRY_NAME */
|
28 |
|
29 | /**
|
30 | * Renders this app unusable and frees the resources of all associated
|
31 | * services.
|
32 | *
|
33 | * @example
|
34 | * ```javascript
|
35 | * deleteApp(app)
|
36 | * .then(function() {
|
37 | * console.log("App deleted successfully");
|
38 | * })
|
39 | * .catch(function(error) {
|
40 | * console.log("Error deleting app:", error);
|
41 | * });
|
42 | * ```
|
43 | *
|
44 | * @public
|
45 | */
|
46 | export declare function deleteApp(app: FirebaseApp): Promise<void>;
|
47 |
|
48 | /**
|
49 | * A {@link @firebase/app#FirebaseApp} holds the initialization information for a collection of
|
50 | * services.
|
51 | *
|
52 | * Do not call this constructor directly. Instead, use
|
53 | * {@link (initializeApp:1) | initializeApp()} to create an app.
|
54 | *
|
55 | * @public
|
56 | */
|
57 | export declare interface FirebaseApp {
|
58 | /**
|
59 | * The (read-only) name for this app.
|
60 | *
|
61 | * The default app's name is `"[DEFAULT]"`.
|
62 | *
|
63 | * @example
|
64 | * ```javascript
|
65 | * // The default app's name is "[DEFAULT]"
|
66 | * const app = initializeApp(defaultAppConfig);
|
67 | * console.log(app.name); // "[DEFAULT]"
|
68 | * ```
|
69 | *
|
70 | * @example
|
71 | * ```javascript
|
72 | * // A named app's name is what you provide to initializeApp()
|
73 | * const otherApp = initializeApp(otherAppConfig, "other");
|
74 | * console.log(otherApp.name); // "other"
|
75 | * ```
|
76 | */
|
77 | readonly name: string;
|
78 | /**
|
79 | * The (read-only) configuration options for this app. These are the original
|
80 | * parameters given in {@link (initializeApp:1) | initializeApp()}.
|
81 | *
|
82 | * @example
|
83 | * ```javascript
|
84 | * const app = initializeApp(config);
|
85 | * console.log(app.options.databaseURL === config.databaseURL); // true
|
86 | * ```
|
87 | */
|
88 | readonly options: FirebaseOptions;
|
89 | /**
|
90 | * The settable config flag for GDPR opt-in/opt-out
|
91 | */
|
92 | automaticDataCollectionEnabled: boolean;
|
93 | }
|
94 |
|
95 | /* Excluded from this release type: _FirebaseAppInternal */
|
96 |
|
97 | /**
|
98 | * @public
|
99 | *
|
100 | * Configuration options given to {@link (initializeApp:1) | initializeApp()}
|
101 | */
|
102 | export declare interface FirebaseAppSettings {
|
103 | /**
|
104 | * custom name for the Firebase App.
|
105 | * The default value is `"[DEFAULT]"`.
|
106 | */
|
107 | name?: string;
|
108 | /**
|
109 | * The settable config flag for GDPR opt-in/opt-out
|
110 | */
|
111 | automaticDataCollectionEnabled?: boolean;
|
112 | }
|
113 | export { FirebaseError }
|
114 |
|
115 | /**
|
116 | * @public
|
117 | *
|
118 | * Firebase configuration object. Contains a set of parameters required by
|
119 | * services in order to successfully communicate with Firebase server APIs
|
120 | * and to associate client data with your Firebase project and
|
121 | * Firebase application. Typically this object is populated by the Firebase
|
122 | * console at project setup. See also:
|
123 | * {@link https://firebase.google.com/docs/web/setup#config-object | Learn about the Firebase config object}.
|
124 | */
|
125 | export declare interface FirebaseOptions {
|
126 | /**
|
127 | * An encrypted string used when calling certain APIs that don't need to
|
128 | * access private user data
|
129 | * (example value: `AIzaSyDOCAbC123dEf456GhI789jKl012-MnO`).
|
130 | */
|
131 | apiKey?: string;
|
132 | /**
|
133 | * Auth domain for the project ID.
|
134 | */
|
135 | authDomain?: string;
|
136 | /**
|
137 | * Default Realtime Database URL.
|
138 | */
|
139 | databaseURL?: string;
|
140 | /**
|
141 | * The unique identifier for the project across all of Firebase and
|
142 | * Google Cloud.
|
143 | */
|
144 | projectId?: string;
|
145 | /**
|
146 | * The default Cloud Storage bucket name.
|
147 | */
|
148 | storageBucket?: string;
|
149 | /**
|
150 | * Unique numerical value used to identify each sender that can send
|
151 | * Firebase Cloud Messaging messages to client apps.
|
152 | */
|
153 | messagingSenderId?: string;
|
154 | /**
|
155 | * Unique identifier for the app.
|
156 | */
|
157 | appId?: string;
|
158 | /**
|
159 | * An ID automatically created when you enable Analytics in your
|
160 | * Firebase project and register a web app. In versions 7.20.0
|
161 | * and higher, this parameter is optional.
|
162 | */
|
163 | measurementId?: string;
|
164 | }
|
165 |
|
166 | /**
|
167 | * A {@link @firebase/app#FirebaseServerApp} holds the initialization information
|
168 | * for a collection of services running in server environments.
|
169 | *
|
170 | * Do not call this constructor directly. Instead, use
|
171 | * {@link (initializeServerApp:1) | initializeServerApp()} to create
|
172 | * an app.
|
173 | *
|
174 | * @public
|
175 | */
|
176 | export declare interface FirebaseServerApp extends FirebaseApp {
|
177 | /**
|
178 | * There is no `getApp()` operation for `FirebaseServerApp`, so the name is not relevant for
|
179 | * applications. However, it may be used internally, and is declared here so that
|
180 | * `FirebaseServerApp` conforms to the `FirebaseApp` interface.
|
181 | */
|
182 | name: string;
|
183 | /**
|
184 | * The (read-only) configuration settings for this server app. These are the original
|
185 | * parameters given in {@link (initializeServerApp:1) | initializeServerApp()}.
|
186 | *
|
187 | * @example
|
188 | * ```javascript
|
189 | * const app = initializeServerApp(settings);
|
190 | * console.log(app.settings.authIdToken === options.authIdToken); // true
|
191 | * ```
|
192 | */
|
193 | readonly settings: FirebaseServerAppSettings;
|
194 | }
|
195 |
|
196 | /**
|
197 | * @public
|
198 | *
|
199 | * Configuration options given to {@link (initializeServerApp:1) | initializeServerApp()}
|
200 | */
|
201 | export declare interface FirebaseServerAppSettings extends Omit<FirebaseAppSettings, 'name'> {
|
202 | /**
|
203 | * An optional Auth ID token used to resume a signed in user session from a client
|
204 | * runtime environment.
|
205 | *
|
206 | * Invoking `getAuth` with a `FirebaseServerApp` configured with a validated `authIdToken`
|
207 | * causes an automatic attempt to sign in the user that the `authIdToken` represents. The token
|
208 | * needs to have been recently minted for this operation to succeed.
|
209 | *
|
210 | * If the token fails local verification, or if the Auth service has failed to validate it when
|
211 | * the Auth SDK is initialized, then a warning is logged to the console and the Auth SDK will not
|
212 | * sign in a user on initialization.
|
213 | *
|
214 | * If a user is successfully signed in, then the Auth instance's `onAuthStateChanged` callback
|
215 | * is invoked with the `User` object as per standard Auth flows. However, `User` objects
|
216 | * created via an `authIdToken` do not have a refresh token. Attempted `refreshToken`
|
217 | * operations fail.
|
218 | */
|
219 | authIdToken?: string;
|
220 | /**
|
221 | * An optional object. If provided, the Firebase SDK uses a `FinalizationRegistry`
|
222 | * object to monitor the garbage collection status of the provided object. The
|
223 | * Firebase SDK releases its reference on the `FirebaseServerApp` instance when the
|
224 | * provided `releaseOnDeref` object is garbage collected.
|
225 | *
|
226 | * You can use this field to reduce memory management overhead for your application.
|
227 | * If provided, an app running in a SSR pass does not need to perform
|
228 | * `FirebaseServerApp` cleanup, so long as the reference object is deleted (by falling out of
|
229 | * SSR scope, for instance.)
|
230 | *
|
231 | * If an object is not provided then the application must clean up the `FirebaseServerApp`
|
232 | * instance by invoking `deleteApp`.
|
233 | *
|
234 | * If the application provides an object in this parameter, but the application is
|
235 | * executed in a JavaScript engine that predates the support of `FinalizationRegistry`
|
236 | * (introduced in node v14.6.0, for instance), then an error is thrown at `FirebaseServerApp`
|
237 | * initialization.
|
238 | */
|
239 | releaseOnDeref?: object;
|
240 | }
|
241 |
|
242 | /* Excluded from this release type: _FirebaseService */
|
243 |
|
244 | /**
|
245 | * Retrieves a {@link @firebase/app#FirebaseApp} instance.
|
246 | *
|
247 | * When called with no arguments, the default app is returned. When an app name
|
248 | * is provided, the app corresponding to that name is returned.
|
249 | *
|
250 | * An exception is thrown if the app being retrieved has not yet been
|
251 | * initialized.
|
252 | *
|
253 | * @example
|
254 | * ```javascript
|
255 | * // Return the default app
|
256 | * const app = getApp();
|
257 | * ```
|
258 | *
|
259 | * @example
|
260 | * ```javascript
|
261 | * // Return a named app
|
262 | * const otherApp = getApp("otherApp");
|
263 | * ```
|
264 | *
|
265 | * @param name - Optional name of the app to return. If no name is
|
266 | * provided, the default is `"[DEFAULT]"`.
|
267 | *
|
268 | * @returns The app corresponding to the provided app name.
|
269 | * If no app name is provided, the default app is returned.
|
270 | *
|
271 | * @public
|
272 | */
|
273 | export declare function getApp(name?: string): FirebaseApp;
|
274 |
|
275 | /**
|
276 | * A (read-only) array of all initialized apps.
|
277 | * @public
|
278 | */
|
279 | export declare function getApps(): FirebaseApp[];
|
280 |
|
281 | /* Excluded from this release type: _getProvider */
|
282 |
|
283 | /**
|
284 | * Creates and initializes a {@link @firebase/app#FirebaseApp} instance.
|
285 | *
|
286 | * See
|
287 | * {@link
|
288 | * https://firebase.google.com/docs/web/setup#add_firebase_to_your_app
|
289 | * | Add Firebase to your app} and
|
290 | * {@link
|
291 | * https://firebase.google.com/docs/web/setup#multiple-projects
|
292 | * | Initialize multiple projects} for detailed documentation.
|
293 | *
|
294 | * @example
|
295 | * ```javascript
|
296 | *
|
297 | * // Initialize default app
|
298 | * // Retrieve your own options values by adding a web app on
|
299 | * // https://console.firebase.google.com
|
300 | * initializeApp({
|
301 | * apiKey: "AIza....", // Auth / General Use
|
302 | * authDomain: "YOUR_APP.firebaseapp.com", // Auth with popup/redirect
|
303 | * databaseURL: "https://YOUR_APP.firebaseio.com", // Realtime Database
|
304 | * storageBucket: "YOUR_APP.appspot.com", // Storage
|
305 | * messagingSenderId: "123456789" // Cloud Messaging
|
306 | * });
|
307 | * ```
|
308 | *
|
309 | * @example
|
310 | * ```javascript
|
311 | *
|
312 | * // Initialize another app
|
313 | * const otherApp = initializeApp({
|
314 | * databaseURL: "https://<OTHER_DATABASE_NAME>.firebaseio.com",
|
315 | * storageBucket: "<OTHER_STORAGE_BUCKET>.appspot.com"
|
316 | * }, "otherApp");
|
317 | * ```
|
318 | *
|
319 | * @param options - Options to configure the app's services.
|
320 | * @param name - Optional name of the app to initialize. If no name
|
321 | * is provided, the default is `"[DEFAULT]"`.
|
322 | *
|
323 | * @returns The initialized app.
|
324 | *
|
325 | * @public
|
326 | */
|
327 | export declare function initializeApp(options: FirebaseOptions, name?: string): FirebaseApp;
|
328 |
|
329 | /**
|
330 | * Creates and initializes a FirebaseApp instance.
|
331 | *
|
332 | * @param options - Options to configure the app's services.
|
333 | * @param config - FirebaseApp Configuration
|
334 | *
|
335 | * @public
|
336 | */
|
337 | export declare function initializeApp(options: FirebaseOptions, config?: FirebaseAppSettings): FirebaseApp;
|
338 |
|
339 | /**
|
340 | * Creates and initializes a FirebaseApp instance.
|
341 | *
|
342 | * @public
|
343 | */
|
344 | export declare function initializeApp(): FirebaseApp;
|
345 |
|
346 | /**
|
347 | * Creates and initializes a {@link @firebase/app#FirebaseServerApp} instance.
|
348 | *
|
349 | * The `FirebaseServerApp` is similar to `FirebaseApp`, but is intended for execution in
|
350 | * server side rendering environments only. Initialization will fail if invoked from a
|
351 | * browser environment.
|
352 | *
|
353 | * See
|
354 | * {@link
|
355 | * https://firebase.google.com/docs/web/setup#add_firebase_to_your_app
|
356 | * | Add Firebase to your app} and
|
357 | * {@link
|
358 | * https://firebase.google.com/docs/web/setup#multiple-projects
|
359 | * | Initialize multiple projects} for detailed documentation.
|
360 | *
|
361 | * @example
|
362 | * ```javascript
|
363 | *
|
364 | * // Initialize an instance of `FirebaseServerApp`.
|
365 | * // Retrieve your own options values by adding a web app on
|
366 | * // https://console.firebase.google.com
|
367 | * initializeServerApp({
|
368 | * apiKey: "AIza....", // Auth / General Use
|
369 | * authDomain: "YOUR_APP.firebaseapp.com", // Auth with popup/redirect
|
370 | * databaseURL: "https://YOUR_APP.firebaseio.com", // Realtime Database
|
371 | * storageBucket: "YOUR_APP.appspot.com", // Storage
|
372 | * messagingSenderId: "123456789" // Cloud Messaging
|
373 | * },
|
374 | * {
|
375 | * authIdToken: "Your Auth ID Token"
|
376 | * });
|
377 | * ```
|
378 | *
|
379 | * @param options - `Firebase.AppOptions` to configure the app's services, or a
|
380 | * a `FirebaseApp` instance which contains the `AppOptions` within.
|
381 | * @param config - `FirebaseServerApp` configuration.
|
382 | *
|
383 | * @returns The initialized `FirebaseServerApp`.
|
384 | *
|
385 | * @public
|
386 | */
|
387 | export declare function initializeServerApp(options: FirebaseOptions | FirebaseApp, config: FirebaseServerAppSettings): FirebaseServerApp;
|
388 |
|
389 | /* Excluded from this release type: _isFirebaseApp */
|
390 |
|
391 | /* Excluded from this release type: _isFirebaseServerApp */
|
392 |
|
393 | /**
|
394 | * Sets log handler for all Firebase SDKs.
|
395 | * @param logCallback - An optional custom log handler that executes user code whenever
|
396 | * the Firebase SDK makes a logging call.
|
397 | *
|
398 | * @public
|
399 | */
|
400 | export declare function onLog(logCallback: LogCallback | null, options?: LogOptions): void;
|
401 |
|
402 | /* Excluded from this release type: _registerComponent */
|
403 |
|
404 | /**
|
405 | * Registers a library's name and version for platform logging purposes.
|
406 | * @param library - Name of 1p or 3p library (e.g. firestore, angularfire)
|
407 | * @param version - Current version of that library.
|
408 | * @param variant - Bundle variant, e.g., node, rn, etc.
|
409 | *
|
410 | * @public
|
411 | */
|
412 | export declare function registerVersion(libraryKeyOrName: string, version: string, variant?: string): void;
|
413 |
|
414 | /* Excluded from this release type: _removeServiceInstance */
|
415 |
|
416 | /**
|
417 | * The current SDK version.
|
418 | *
|
419 | * @public
|
420 | */
|
421 | export declare const SDK_VERSION: string;
|
422 |
|
423 | /* Excluded from this release type: _serverApps */
|
424 |
|
425 | /**
|
426 | * Sets log level for all Firebase SDKs.
|
427 | *
|
428 | * All of the log types above the current log level are captured (i.e. if
|
429 | * you set the log level to `info`, errors are logged, but `debug` and
|
430 | * `verbose` logs are not).
|
431 | *
|
432 | * @public
|
433 | */
|
434 | export declare function setLogLevel(logLevel: LogLevelString): void;
|
435 |
|
436 | export { }
|