UNPKG

14.4 kBTypeScriptView Raw
1/**
2 * Firebase App
3 *
4 * @remarks This package coordinates the communication between the different Firebase components
5 * @packageDocumentation
6 */
7
8import { Component } from '@firebase/component';
9import { ComponentContainer } from '@firebase/component';
10import { FirebaseError } from '@firebase/util';
11import { LogCallback } from '@firebase/logger';
12import { LogLevelString } from '@firebase/logger';
13import { LogOptions } from '@firebase/logger';
14import { Name } from '@firebase/component';
15import { 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 */
46export 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 */
57export 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 */
102export 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}
113export { 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 */
125export 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 */
176export 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 */
201export declare interface FirebaseServerAppSettings extends FirebaseAppSettings {
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 * There is no `getApp()` operation for `FirebaseServerApp`, so the name is not relevant for
242 * applications. However, it may be used internally, and is declared here so that
243 * `FirebaseServerApp` conforms to the `FirebaseApp` interface.
244 */
245 name?: undefined;
246}
247
248/* Excluded from this release type: _FirebaseService */
249
250/**
251 * Retrieves a {@link @firebase/app#FirebaseApp} instance.
252 *
253 * When called with no arguments, the default app is returned. When an app name
254 * is provided, the app corresponding to that name is returned.
255 *
256 * An exception is thrown if the app being retrieved has not yet been
257 * initialized.
258 *
259 * @example
260 * ```javascript
261 * // Return the default app
262 * const app = getApp();
263 * ```
264 *
265 * @example
266 * ```javascript
267 * // Return a named app
268 * const otherApp = getApp("otherApp");
269 * ```
270 *
271 * @param name - Optional name of the app to return. If no name is
272 * provided, the default is `"[DEFAULT]"`.
273 *
274 * @returns The app corresponding to the provided app name.
275 * If no app name is provided, the default app is returned.
276 *
277 * @public
278 */
279export declare function getApp(name?: string): FirebaseApp;
280
281/**
282 * A (read-only) array of all initialized apps.
283 * @public
284 */
285export declare function getApps(): FirebaseApp[];
286
287/* Excluded from this release type: _getProvider */
288
289/**
290 * Creates and initializes a {@link @firebase/app#FirebaseApp} instance.
291 *
292 * See
293 * {@link
294 * https://firebase.google.com/docs/web/setup#add_firebase_to_your_app
295 * | Add Firebase to your app} and
296 * {@link
297 * https://firebase.google.com/docs/web/setup#multiple-projects
298 * | Initialize multiple projects} for detailed documentation.
299 *
300 * @example
301 * ```javascript
302 *
303 * // Initialize default app
304 * // Retrieve your own options values by adding a web app on
305 * // https://console.firebase.google.com
306 * initializeApp({
307 * apiKey: "AIza....", // Auth / General Use
308 * authDomain: "YOUR_APP.firebaseapp.com", // Auth with popup/redirect
309 * databaseURL: "https://YOUR_APP.firebaseio.com", // Realtime Database
310 * storageBucket: "YOUR_APP.appspot.com", // Storage
311 * messagingSenderId: "123456789" // Cloud Messaging
312 * });
313 * ```
314 *
315 * @example
316 * ```javascript
317 *
318 * // Initialize another app
319 * const otherApp = initializeApp({
320 * databaseURL: "https://<OTHER_DATABASE_NAME>.firebaseio.com",
321 * storageBucket: "<OTHER_STORAGE_BUCKET>.appspot.com"
322 * }, "otherApp");
323 * ```
324 *
325 * @param options - Options to configure the app's services.
326 * @param name - Optional name of the app to initialize. If no name
327 * is provided, the default is `"[DEFAULT]"`.
328 *
329 * @returns The initialized app.
330 *
331 * @public
332 */
333export declare function initializeApp(options: FirebaseOptions, name?: string): FirebaseApp;
334
335/**
336 * Creates and initializes a FirebaseApp instance.
337 *
338 * @param options - Options to configure the app's services.
339 * @param config - FirebaseApp Configuration
340 *
341 * @public
342 */
343export declare function initializeApp(options: FirebaseOptions, config?: FirebaseAppSettings): FirebaseApp;
344
345/**
346 * Creates and initializes a FirebaseApp instance.
347 *
348 * @public
349 */
350export declare function initializeApp(): FirebaseApp;
351
352/**
353 * Creates and initializes a {@link @firebase/app#FirebaseServerApp} instance.
354 *
355 * The `FirebaseServerApp` is similar to `FirebaseApp`, but is intended for execution in
356 * server side rendering environments only. Initialization will fail if invoked from a
357 * browser environment.
358 *
359 * See
360 * {@link
361 * https://firebase.google.com/docs/web/setup#add_firebase_to_your_app
362 * | Add Firebase to your app} and
363 * {@link
364 * https://firebase.google.com/docs/web/setup#multiple-projects
365 * | Initialize multiple projects} for detailed documentation.
366 *
367 * @example
368 * ```javascript
369 *
370 * // Initialize an instance of `FirebaseServerApp`.
371 * // Retrieve your own options values by adding a web app on
372 * // https://console.firebase.google.com
373 * initializeServerApp({
374 * apiKey: "AIza....", // Auth / General Use
375 * authDomain: "YOUR_APP.firebaseapp.com", // Auth with popup/redirect
376 * databaseURL: "https://YOUR_APP.firebaseio.com", // Realtime Database
377 * storageBucket: "YOUR_APP.appspot.com", // Storage
378 * messagingSenderId: "123456789" // Cloud Messaging
379 * },
380 * {
381 * authIdToken: "Your Auth ID Token"
382 * });
383 * ```
384 *
385 * @param options - `Firebase.AppOptions` to configure the app's services, or a
386 * a `FirebaseApp` instance which contains the `AppOptions` within.
387 * @param config - `FirebaseServerApp` configuration.
388 *
389 * @returns The initialized `FirebaseServerApp`.
390 *
391 * @public
392 */
393export declare function initializeServerApp(options: FirebaseOptions | FirebaseApp, config: FirebaseServerAppSettings): FirebaseServerApp;
394
395/* Excluded from this release type: _isFirebaseApp */
396
397/* Excluded from this release type: _isFirebaseServerApp */
398
399/**
400 * Sets log handler for all Firebase SDKs.
401 * @param logCallback - An optional custom log handler that executes user code whenever
402 * the Firebase SDK makes a logging call.
403 *
404 * @public
405 */
406export declare function onLog(logCallback: LogCallback | null, options?: LogOptions): void;
407
408/* Excluded from this release type: _registerComponent */
409
410/**
411 * Registers a library's name and version for platform logging purposes.
412 * @param library - Name of 1p or 3p library (e.g. firestore, angularfire)
413 * @param version - Current version of that library.
414 * @param variant - Bundle variant, e.g., node, rn, etc.
415 *
416 * @public
417 */
418export declare function registerVersion(libraryKeyOrName: string, version: string, variant?: string): void;
419
420/* Excluded from this release type: _removeServiceInstance */
421
422/**
423 * The current SDK version.
424 *
425 * @public
426 */
427export declare const SDK_VERSION: string;
428
429/* Excluded from this release type: _serverApps */
430
431/**
432 * Sets log level for all Firebase SDKs.
433 *
434 * All of the log types above the current log level are captured (i.e. if
435 * you set the log level to `info`, errors are logged, but `debug` and
436 * `verbose` logs are not).
437 *
438 * @public
439 */
440export declare function setLogLevel(logLevel: LogLevelString): void;
441
442export { }