@depup/firebase__app 0.14.9-depup.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/README.md +32 -0
  2. package/changes.json +14 -0
  3. package/dist/app/src/api.d.ts +235 -0
  4. package/dist/app/src/constants.d.ts +26 -0
  5. package/dist/app/src/errors.d.ts +67 -0
  6. package/dist/app/src/firebaseApp.d.ts +46 -0
  7. package/dist/app/src/firebaseServerApp.d.ts +36 -0
  8. package/dist/app/src/global_index.d.ts +939 -0
  9. package/dist/app/src/heartbeatService.d.ts +89 -0
  10. package/dist/app/src/index.d.ts +9 -0
  11. package/dist/app/src/indexeddb.d.ts +20 -0
  12. package/dist/app/src/internal.d.ts +108 -0
  13. package/dist/app/src/logger.d.ts +18 -0
  14. package/dist/app/src/platformLoggerService.d.ts +23 -0
  15. package/dist/app/src/public-types.d.ts +241 -0
  16. package/dist/app/src/registerCoreComponents.d.ts +17 -0
  17. package/dist/app/src/tsdoc-metadata.json +11 -0
  18. package/dist/app/src/types.d.ts +55 -0
  19. package/dist/app/test/setup.d.ts +17 -0
  20. package/dist/app/test/util.d.ts +26 -0
  21. package/dist/app-public.d.ts +477 -0
  22. package/dist/app.d.ts +572 -0
  23. package/dist/esm/app/src/api.d.ts +235 -0
  24. package/dist/esm/app/src/constants.d.ts +26 -0
  25. package/dist/esm/app/src/errors.d.ts +67 -0
  26. package/dist/esm/app/src/firebaseApp.d.ts +46 -0
  27. package/dist/esm/app/src/firebaseServerApp.d.ts +36 -0
  28. package/dist/esm/app/src/heartbeatService.d.ts +89 -0
  29. package/dist/esm/app/src/index.d.ts +9 -0
  30. package/dist/esm/app/src/indexeddb.d.ts +20 -0
  31. package/dist/esm/app/src/internal.d.ts +108 -0
  32. package/dist/esm/app/src/logger.d.ts +18 -0
  33. package/dist/esm/app/src/platformLoggerService.d.ts +23 -0
  34. package/dist/esm/app/src/public-types.d.ts +241 -0
  35. package/dist/esm/app/src/registerCoreComponents.d.ts +17 -0
  36. package/dist/esm/app/src/types.d.ts +55 -0
  37. package/dist/esm/app/test/setup.d.ts +17 -0
  38. package/dist/esm/app/test/util.d.ts +26 -0
  39. package/dist/esm/index.esm.js +1237 -0
  40. package/dist/esm/index.esm.js.map +1 -0
  41. package/dist/esm/package.json +1 -0
  42. package/dist/index.cjs.js +1265 -0
  43. package/dist/index.cjs.js.map +1 -0
  44. package/package.json +100 -0
@@ -0,0 +1,939 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2019 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+
18
+ /**
19
+ * Provider for instance for service name T, e.g. 'auth', 'auth-internal'
20
+ * NameServiceMapping[T] is an alias for the type of the instance
21
+ */
22
+ declare class Provider<T extends Name> {
23
+ private readonly name;
24
+ private readonly container;
25
+ private component;
26
+ private readonly instances;
27
+ private readonly instancesDeferred;
28
+ private readonly instancesOptions;
29
+ private onInitCallbacks;
30
+ constructor(name: T, container: ComponentContainer);
31
+ /**
32
+ * @param identifier A provider can provide multiple instances of a service
33
+ * if this.component.multipleInstances is true.
34
+ */
35
+ get(identifier?: string): Promise<NameServiceMapping[T]>;
36
+ /**
37
+ *
38
+ * @param options.identifier A provider can provide multiple instances of a service
39
+ * if this.component.multipleInstances is true.
40
+ * @param options.optional If optional is false or not provided, the method throws an error when
41
+ * the service is not immediately available.
42
+ * If optional is true, the method returns null if the service is not immediately available.
43
+ */
44
+ getImmediate(options: {
45
+ identifier?: string;
46
+ optional: true;
47
+ }): NameServiceMapping[T] | null;
48
+ getImmediate(options?: {
49
+ identifier?: string;
50
+ optional?: false;
51
+ }): NameServiceMapping[T];
52
+ getComponent(): Component<T> | null;
53
+ setComponent(component: Component<T>): void;
54
+ clearInstance(identifier?: string): void;
55
+ delete(): Promise<void>;
56
+ isComponentSet(): boolean;
57
+ isInitialized(identifier?: string): boolean;
58
+ getOptions(identifier?: string): Record<string, unknown>;
59
+ initialize(opts?: InitializeOptions): NameServiceMapping[T];
60
+ /**
61
+ *
62
+ * @param callback - a function that will be invoked after the provider has been initialized by calling provider.initialize().
63
+ * The function is invoked SYNCHRONOUSLY, so it should not execute any longrunning tasks in order to not block the program.
64
+ *
65
+ * @param identifier An optional instance identifier
66
+ * @returns a function to unregister the callback
67
+ */
68
+ onInit(callback: OnInitCallBack<T>, identifier?: string): () => void;
69
+ /**
70
+ * Invoke onInit callbacks synchronously
71
+ * @param instance the service instance`
72
+ */
73
+ private invokeOnInitCallbacks;
74
+ private getOrInitializeService;
75
+ private normalizeInstanceIdentifier;
76
+ private shouldAutoInitialize;
77
+ }
78
+
79
+ /**
80
+ * @license
81
+ * Copyright 2019 Google LLC
82
+ *
83
+ * Licensed under the Apache License, Version 2.0 (the "License");
84
+ * you may not use this file except in compliance with the License.
85
+ * You may obtain a copy of the License at
86
+ *
87
+ * http://www.apache.org/licenses/LICENSE-2.0
88
+ *
89
+ * Unless required by applicable law or agreed to in writing, software
90
+ * distributed under the License is distributed on an "AS IS" BASIS,
91
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
92
+ * See the License for the specific language governing permissions and
93
+ * limitations under the License.
94
+ */
95
+
96
+ /**
97
+ * ComponentContainer that provides Providers for service name T, e.g. `auth`, `auth-internal`
98
+ */
99
+ declare class ComponentContainer {
100
+ private readonly name;
101
+ private readonly providers;
102
+ constructor(name: string);
103
+ /**
104
+ *
105
+ * @param component Component being added
106
+ * @param overwrite When a component with the same name has already been registered,
107
+ * if overwrite is true: overwrite the existing component with the new component and create a new
108
+ * provider with the new component. It can be useful in tests where you want to use different mocks
109
+ * for different tests.
110
+ * if overwrite is false: throw an exception
111
+ */
112
+ addComponent<T extends Name>(component: Component<T>): void;
113
+ addOrOverwriteComponent<T extends Name>(component: Component<T>): void;
114
+ /**
115
+ * getProvider provides a type safe interface where it can only be called with a field name
116
+ * present in NameServiceMapping interface.
117
+ *
118
+ * Firebase SDKs providing services should extend NameServiceMapping interface to register
119
+ * themselves.
120
+ */
121
+ getProvider<T extends Name>(name: T): Provider<T>;
122
+ getProviders(): Array<Provider<Name>>;
123
+ }
124
+
125
+ /**
126
+ * @license
127
+ * Copyright 2019 Google LLC
128
+ *
129
+ * Licensed under the Apache License, Version 2.0 (the "License");
130
+ * you may not use this file except in compliance with the License.
131
+ * You may obtain a copy of the License at
132
+ *
133
+ * http://www.apache.org/licenses/LICENSE-2.0
134
+ *
135
+ * Unless required by applicable law or agreed to in writing, software
136
+ * distributed under the License is distributed on an "AS IS" BASIS,
137
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
138
+ * See the License for the specific language governing permissions and
139
+ * limitations under the License.
140
+ */
141
+
142
+ declare const enum InstantiationMode {
143
+ LAZY = "LAZY",// Currently most components are LAZY in JS SDK
144
+ EAGER = "EAGER",// EAGER components are initialized immediately upon registration
145
+ EXPLICIT = "EXPLICIT"
146
+ }
147
+ /**
148
+ * PUBLIC: A public component provides a set of public APIs to customers. A service namespace will be patched
149
+ * onto `firebase` namespace. Assume the component name is `test`, customers will be able
150
+ * to get the service by calling `firebase.test()` or `app.test()` where `app` is a `FirebaseApp` instance.
151
+ *
152
+ * PRIVATE: A private component provides a set of private APIs that are used internally by other
153
+ * Firebase SDKs. No service namespace is created in `firebase` namespace and customers have no way to get them.
154
+ */
155
+ declare const enum ComponentType {
156
+ PUBLIC = "PUBLIC",
157
+ PRIVATE = "PRIVATE",
158
+ VERSION = "VERSION"
159
+ }
160
+ interface InstanceFactoryOptions {
161
+ instanceIdentifier?: string;
162
+ options?: {};
163
+ }
164
+ type InitializeOptions = InstanceFactoryOptions;
165
+ /**
166
+ * Factory to create an instance of type T, given a ComponentContainer.
167
+ * ComponentContainer is the IOC container that provides {@link Provider}
168
+ * for dependencies.
169
+ *
170
+ * NOTE: The container only provides {@link Provider} rather than the actual instances of dependencies.
171
+ * It is useful for lazily loaded dependencies and optional dependencies.
172
+ */
173
+ type InstanceFactory<T extends Name> = (container: ComponentContainer, options: InstanceFactoryOptions) => NameServiceMapping[T];
174
+ type onInstanceCreatedCallback<T extends Name> = (container: ComponentContainer, instanceIdentifier: string, instance: NameServiceMapping[T]) => void;
175
+ interface Dictionary {
176
+ [key: string]: unknown;
177
+ }
178
+ /**
179
+ * This interface will be extended by Firebase SDKs to provide service name and service type mapping.
180
+ * It is used as a generic constraint to ensure type safety.
181
+ */
182
+ interface NameServiceMapping {
183
+ }
184
+ type Name = keyof NameServiceMapping;
185
+ type OnInitCallBack<T extends Name> = (instance: NameServiceMapping[T], identifier: string) => void;
186
+
187
+ /**
188
+ * @license
189
+ * Copyright 2019 Google LLC
190
+ *
191
+ * Licensed under the Apache License, Version 2.0 (the "License");
192
+ * you may not use this file except in compliance with the License.
193
+ * You may obtain a copy of the License at
194
+ *
195
+ * http://www.apache.org/licenses/LICENSE-2.0
196
+ *
197
+ * Unless required by applicable law or agreed to in writing, software
198
+ * distributed under the License is distributed on an "AS IS" BASIS,
199
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ * See the License for the specific language governing permissions and
201
+ * limitations under the License.
202
+ */
203
+
204
+ /**
205
+ * Component for service name T, e.g. `auth`, `auth-internal`
206
+ */
207
+ declare class Component<T extends Name = Name> {
208
+ readonly name: T;
209
+ readonly instanceFactory: InstanceFactory<T>;
210
+ readonly type: ComponentType;
211
+ multipleInstances: boolean;
212
+ /**
213
+ * Properties to be added to the service namespace
214
+ */
215
+ serviceProps: Dictionary;
216
+ instantiationMode: InstantiationMode;
217
+ onInstanceCreated: onInstanceCreatedCallback<T> | null;
218
+ /**
219
+ *
220
+ * @param name The public service name, e.g. app, auth, firestore, database
221
+ * @param instanceFactory Service factory responsible for creating the public interface
222
+ * @param type whether the service provided by the component is public or private
223
+ */
224
+ constructor(name: T, instanceFactory: InstanceFactory<T>, type: ComponentType);
225
+ setInstantiationMode(mode: InstantiationMode): this;
226
+ setMultipleInstances(multipleInstances: boolean): this;
227
+ setServiceProps(props: Dictionary): this;
228
+ setInstanceCreatedCallback(callback: onInstanceCreatedCallback<T>): this;
229
+ }
230
+
231
+ /**
232
+ * @license
233
+ * Copyright 2020 Google LLC
234
+ *
235
+ * Licensed under the Apache License, Version 2.0 (the "License");
236
+ * you may not use this file except in compliance with the License.
237
+ * You may obtain a copy of the License at
238
+ *
239
+ * http://www.apache.org/licenses/LICENSE-2.0
240
+ *
241
+ * Unless required by applicable law or agreed to in writing, software
242
+ * distributed under the License is distributed on an "AS IS" BASIS,
243
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
244
+ * See the License for the specific language governing permissions and
245
+ * limitations under the License.
246
+ */
247
+ interface VersionService {
248
+ library: string;
249
+ version: string;
250
+ }
251
+ interface PlatformLoggerService {
252
+ getPlatformInfoString(): string;
253
+ }
254
+ interface HeartbeatService {
255
+ /**
256
+ * Called to report a heartbeat. The function will generate
257
+ * a HeartbeatsByUserAgent object, update heartbeatsCache, and persist it
258
+ * to IndexedDB.
259
+ * Note that we only store one heartbeat per day. So if a heartbeat for today is
260
+ * already logged, subsequent calls to this function in the same day will be ignored.
261
+ */
262
+ triggerHeartbeat(): Promise<void>;
263
+ /**
264
+ * Returns a base64 encoded string which can be attached to the heartbeat-specific header directly.
265
+ * It also clears all heartbeats from memory as well as in IndexedDB.
266
+ */
267
+ getHeartbeatsHeader(): Promise<string>;
268
+ }
269
+
270
+ /**
271
+ * @license
272
+ * Copyright 2020 Google LLC
273
+ *
274
+ * Licensed under the Apache License, Version 2.0 (the "License");
275
+ * you may not use this file except in compliance with the License.
276
+ * You may obtain a copy of the License at
277
+ *
278
+ * http://www.apache.org/licenses/LICENSE-2.0
279
+ *
280
+ * Unless required by applicable law or agreed to in writing, software
281
+ * distributed under the License is distributed on an "AS IS" BASIS,
282
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
283
+ * See the License for the specific language governing permissions and
284
+ * limitations under the License.
285
+ */
286
+
287
+ /**
288
+ * A {@link @firebase/app#FirebaseApp} holds the initialization information for a collection of
289
+ * services.
290
+ *
291
+ * Do not call this constructor directly. Instead, use
292
+ * {@link (initializeApp:1) | initializeApp()} to create an app.
293
+ *
294
+ * @public
295
+ */
296
+ interface FirebaseApp {
297
+ /**
298
+ * The (read-only) name for this app.
299
+ *
300
+ * The default app's name is `"[DEFAULT]"`.
301
+ *
302
+ * @example
303
+ * ```javascript
304
+ * // The default app's name is "[DEFAULT]"
305
+ * const app = initializeApp(defaultAppConfig);
306
+ * console.log(app.name); // "[DEFAULT]"
307
+ * ```
308
+ *
309
+ * @example
310
+ * ```javascript
311
+ * // A named app's name is what you provide to initializeApp()
312
+ * const otherApp = initializeApp(otherAppConfig, "other");
313
+ * console.log(otherApp.name); // "other"
314
+ * ```
315
+ */
316
+ readonly name: string;
317
+ /**
318
+ * The (read-only) configuration options for this app. These are the original
319
+ * parameters given in {@link (initializeApp:1) | initializeApp()}.
320
+ *
321
+ * @example
322
+ * ```javascript
323
+ * const app = initializeApp(config);
324
+ * console.log(app.options.databaseURL === config.databaseURL); // true
325
+ * ```
326
+ */
327
+ readonly options: FirebaseOptions;
328
+ /**
329
+ * The settable config flag for GDPR opt-in/opt-out
330
+ */
331
+ automaticDataCollectionEnabled: boolean;
332
+ }
333
+ /**
334
+ * A {@link @firebase/app#FirebaseServerApp} holds the initialization information
335
+ * for a collection of services running in server environments.
336
+ *
337
+ * Do not call this constructor directly. Instead, use
338
+ * {@link (initializeServerApp:1) | initializeServerApp()} to create
339
+ * an app.
340
+ *
341
+ * @public
342
+ */
343
+ interface FirebaseServerApp extends FirebaseApp {
344
+ /**
345
+ * There is no `getApp()` operation for `FirebaseServerApp`, so the name is not relevant for
346
+ * applications. However, it may be used internally, and is declared here so that
347
+ * `FirebaseServerApp` conforms to the `FirebaseApp` interface.
348
+ */
349
+ name: string;
350
+ /**
351
+ * The (read-only) configuration settings for this server app. These are the original
352
+ * parameters given in {@link (initializeServerApp:1) | initializeServerApp()}.
353
+ *
354
+ * @example
355
+ * ```javascript
356
+ * const app = initializeServerApp(settings);
357
+ * console.log(app.settings.authIdToken === options.authIdToken); // true
358
+ * ```
359
+ */
360
+ readonly settings: FirebaseServerAppSettings;
361
+ }
362
+ /**
363
+ * @public
364
+ *
365
+ * Firebase configuration object. Contains a set of parameters required by
366
+ * services in order to successfully communicate with Firebase server APIs
367
+ * and to associate client data with your Firebase project and
368
+ * Firebase application. Typically this object is populated by the Firebase
369
+ * console at project setup. See also:
370
+ * {@link https://firebase.google.com/docs/web/setup#config-object | Learn about the Firebase config object}.
371
+ */
372
+ interface FirebaseOptions {
373
+ /**
374
+ * An encrypted string used when calling certain APIs that don't need to
375
+ * access private user data
376
+ * (example value: `AIzaSyDOCAbC123dEf456GhI789jKl012-MnO`).
377
+ */
378
+ apiKey?: string;
379
+ /**
380
+ * Auth domain for the project ID.
381
+ */
382
+ authDomain?: string;
383
+ /**
384
+ * Default Realtime Database URL.
385
+ */
386
+ databaseURL?: string;
387
+ /**
388
+ * The unique identifier for the project across all of Firebase and
389
+ * Google Cloud.
390
+ */
391
+ projectId?: string;
392
+ /**
393
+ * The default Cloud Storage bucket name.
394
+ */
395
+ storageBucket?: string;
396
+ /**
397
+ * Unique numerical value used to identify each sender that can send
398
+ * Firebase Cloud Messaging messages to client apps.
399
+ */
400
+ messagingSenderId?: string;
401
+ /**
402
+ * Unique identifier for the app.
403
+ */
404
+ appId?: string;
405
+ /**
406
+ * An ID automatically created when you enable Analytics in your
407
+ * Firebase project and register a web app. In versions 7.20.0
408
+ * and higher, this parameter is optional.
409
+ */
410
+ measurementId?: string;
411
+ }
412
+ /**
413
+ * @public
414
+ *
415
+ * Configuration options given to {@link (initializeApp:1) | initializeApp()}
416
+ */
417
+ interface FirebaseAppSettings {
418
+ /**
419
+ * custom name for the Firebase App.
420
+ * The default value is `"[DEFAULT]"`.
421
+ */
422
+ name?: string;
423
+ /**
424
+ * The settable config flag for GDPR opt-in/opt-out. Defaults to true.
425
+ */
426
+ automaticDataCollectionEnabled?: boolean;
427
+ }
428
+ /**
429
+ * @public
430
+ *
431
+ * Configuration options given to {@link (initializeServerApp:1) | initializeServerApp()}
432
+ */
433
+ interface FirebaseServerAppSettings extends Omit<FirebaseAppSettings, 'name'> {
434
+ /**
435
+ * An optional Auth ID token used to resume a signed in user session from a client
436
+ * runtime environment.
437
+ *
438
+ * Invoking `getAuth` with a `FirebaseServerApp` configured with a validated `authIdToken`
439
+ * causes an automatic attempt to sign in the user that the `authIdToken` represents. The token
440
+ * needs to have been recently minted for this operation to succeed.
441
+ *
442
+ * If the token fails local verification due to expiration or parsing errors, then a console error
443
+ * is logged at the time of initialization of the `FirebaseServerApp` instance.
444
+ *
445
+ * If the Auth service has failed to validate the token when the Auth SDK is initialized, then an
446
+ * warning is logged to the console and the Auth SDK will not sign in a user on initialization.
447
+ *
448
+ * If a user is successfully signed in, then the Auth instance's `onAuthStateChanged` callback
449
+ * is invoked with the `User` object as per standard Auth flows. However, `User` objects
450
+ * created via an `authIdToken` do not have a refresh token. Attempted `refreshToken`
451
+ * operations fail.
452
+ */
453
+ authIdToken?: string;
454
+ /**
455
+ * An optional App Check token. If provided, the Firebase SDKs that use App Check will utilize
456
+ * this App Check token in place of requiring an instance of App Check to be initialized.
457
+ *
458
+ * If the token fails local verification due to expiration or parsing errors, then a console error
459
+ * is logged at the time of initialization of the `FirebaseServerApp` instance.
460
+ */
461
+ appCheckToken?: string;
462
+ /**
463
+ * An optional object. If provided, the Firebase SDK uses a `FinalizationRegistry`
464
+ * object to monitor the garbage collection status of the provided object. The
465
+ * Firebase SDK releases its reference on the `FirebaseServerApp` instance when the
466
+ * provided `releaseOnDeref` object is garbage collected.
467
+ *
468
+ * You can use this field to reduce memory management overhead for your application.
469
+ * If provided, an app running in a SSR pass does not need to perform
470
+ * `FirebaseServerApp` cleanup, so long as the reference object is deleted (by falling out of
471
+ * SSR scope, for instance.)
472
+ *
473
+ * If an object is not provided then the application must clean up the `FirebaseServerApp`
474
+ * instance by invoking `deleteApp`.
475
+ *
476
+ * If the application provides an object in this parameter, but the application is
477
+ * executed in a JavaScript engine that predates the support of `FinalizationRegistry`
478
+ * (introduced in node v14.6.0, for instance), then an error is thrown at `FirebaseServerApp`
479
+ * initialization.
480
+ */
481
+ releaseOnDeref?: object;
482
+ }
483
+ /**
484
+ * @internal
485
+ */
486
+ interface _FirebaseService {
487
+ app: FirebaseApp;
488
+ /**
489
+ * Delete the service and free it's resources - called from
490
+ * {@link @firebase/app#deleteApp | deleteApp()}
491
+ */
492
+ _delete(): Promise<void>;
493
+ }
494
+ /**
495
+ * @internal
496
+ */
497
+ interface _FirebaseAppInternal extends FirebaseApp {
498
+ container: ComponentContainer;
499
+ isDeleted: boolean;
500
+ checkDestroyed(): void;
501
+ }
502
+ declare module '@firebase/component' {
503
+ interface NameServiceMapping {
504
+ 'app': FirebaseApp;
505
+ 'app-version': VersionService;
506
+ 'heartbeat': HeartbeatService;
507
+ 'platform-logger': PlatformLoggerService;
508
+ }
509
+ }
510
+
511
+ /**
512
+ * @license
513
+ * Copyright 2017 Google LLC
514
+ *
515
+ * Licensed under the Apache License, Version 2.0 (the "License");
516
+ * you may not use this file except in compliance with the License.
517
+ * You may obtain a copy of the License at
518
+ *
519
+ * http://www.apache.org/licenses/LICENSE-2.0
520
+ *
521
+ * Unless required by applicable law or agreed to in writing, software
522
+ * distributed under the License is distributed on an "AS IS" BASIS,
523
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
524
+ * See the License for the specific language governing permissions and
525
+ * limitations under the License.
526
+ */
527
+ type LogLevelString = 'debug' | 'verbose' | 'info' | 'warn' | 'error' | 'silent';
528
+ interface LogOptions {
529
+ level: LogLevelString;
530
+ }
531
+ type LogCallback = (callbackParams: LogCallbackParams) => void;
532
+ interface LogCallbackParams {
533
+ level: LogLevelString;
534
+ message: string;
535
+ args: unknown[];
536
+ type: string;
537
+ }
538
+
539
+ /**
540
+ * An object that can be injected into the environment as __FIREBASE_DEFAULTS__,
541
+ * either as a property of globalThis, a shell environment variable, or a
542
+ * cookie.
543
+ *
544
+ * This object can be used to automatically configure and initialize
545
+ * a Firebase app as well as any emulators.
546
+ *
547
+ * @public
548
+ */
549
+ interface FirebaseDefaults {
550
+ config?: Record<string, string>;
551
+ emulatorHosts?: Record<string, string>;
552
+ _authTokenSyncURL?: string;
553
+ _authIdTokenMaxAge?: number;
554
+ /**
555
+ * Override Firebase's runtime environment detection and
556
+ * force the SDK to act as if it were in the specified environment.
557
+ */
558
+ forceEnvironment?: 'browser' | 'node';
559
+ [key: string]: unknown;
560
+ }
561
+ declare global {
562
+ var __FIREBASE_DEFAULTS__: FirebaseDefaults | undefined;
563
+ }
564
+
565
+ declare class FirebaseError extends Error {
566
+ /** The error code for this error. */
567
+ readonly code: string;
568
+ /** Custom data for this error. */
569
+ customData?: Record<string, unknown> | undefined;
570
+ /** The custom name for all FirebaseErrors. */
571
+ readonly name: string;
572
+ constructor(
573
+ /** The error code for this error. */
574
+ code: string, message: string,
575
+ /** Custom data for this error. */
576
+ customData?: Record<string, unknown> | undefined);
577
+ }
578
+
579
+ /**
580
+ * @license
581
+ * Copyright 2019 Google LLC
582
+ *
583
+ * Licensed under the Apache License, Version 2.0 (the "License");
584
+ * you may not use this file except in compliance with the License.
585
+ * You may obtain a copy of the License at
586
+ *
587
+ * http://www.apache.org/licenses/LICENSE-2.0
588
+ *
589
+ * Unless required by applicable law or agreed to in writing, software
590
+ * distributed under the License is distributed on an "AS IS" BASIS,
591
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
592
+ * See the License for the specific language governing permissions and
593
+ * limitations under the License.
594
+ */
595
+
596
+ /**
597
+ * The current SDK version.
598
+ *
599
+ * @public
600
+ */
601
+ declare const SDK_VERSION: string;
602
+ /**
603
+ * Creates and initializes a {@link @firebase/app#FirebaseApp} instance.
604
+ *
605
+ * See
606
+ * {@link
607
+ * https://firebase.google.com/docs/web/setup#add_firebase_to_your_app
608
+ * | Add Firebase to your app} and
609
+ * {@link
610
+ * https://firebase.google.com/docs/web/setup#multiple-projects
611
+ * | Initialize multiple projects} for detailed documentation.
612
+ *
613
+ * @example
614
+ * ```javascript
615
+ *
616
+ * // Initialize default app
617
+ * // Retrieve your own options values by adding a web app on
618
+ * // https://console.firebase.google.com
619
+ * initializeApp({
620
+ * apiKey: "AIza....", // Auth / General Use
621
+ * authDomain: "YOUR_APP.firebaseapp.com", // Auth with popup/redirect
622
+ * databaseURL: "https://YOUR_APP.firebaseio.com", // Realtime Database
623
+ * storageBucket: "YOUR_APP.appspot.com", // Storage
624
+ * messagingSenderId: "123456789" // Cloud Messaging
625
+ * });
626
+ * ```
627
+ *
628
+ * @example
629
+ * ```javascript
630
+ *
631
+ * // Initialize another app
632
+ * const otherApp = initializeApp({
633
+ * databaseURL: "https://<OTHER_DATABASE_NAME>.firebaseio.com",
634
+ * storageBucket: "<OTHER_STORAGE_BUCKET>.appspot.com"
635
+ * }, "otherApp");
636
+ * ```
637
+ *
638
+ * @param options - Options to configure the app's services.
639
+ * @param name - Optional name of the app to initialize. If no name
640
+ * is provided, the default is `"[DEFAULT]"`.
641
+ *
642
+ * @returns The initialized app.
643
+ *
644
+ * @throws If the optional `name` parameter is malformed or empty.
645
+ *
646
+ * @throws If a `FirebaseApp` already exists with the same name but with a different configuration.
647
+ *
648
+ * @public
649
+ */
650
+ declare function initializeApp(options: FirebaseOptions, name?: string): FirebaseApp;
651
+ /**
652
+ * Creates and initializes a FirebaseApp instance.
653
+ *
654
+ * @param options - Options to configure the app's services.
655
+ * @param config - FirebaseApp Configuration
656
+ *
657
+ * @throws If {@link FirebaseAppSettings.name} is defined but the value is malformed or empty.
658
+ *
659
+ * @throws If a `FirebaseApp` already exists with the same name but with a different configuration.
660
+ * @public
661
+ */
662
+ declare function initializeApp(options: FirebaseOptions, config?: FirebaseAppSettings): FirebaseApp;
663
+ /**
664
+ * Creates and initializes a FirebaseApp instance.
665
+ *
666
+ * @public
667
+ */
668
+ declare function initializeApp(): FirebaseApp;
669
+ /**
670
+ * Creates and initializes a {@link @firebase/app#FirebaseServerApp} instance.
671
+ *
672
+ * The `FirebaseServerApp` is similar to `FirebaseApp`, but is intended for execution in
673
+ * server side rendering environments only. Initialization will fail if invoked from a
674
+ * browser environment.
675
+ *
676
+ * See
677
+ * {@link
678
+ * https://firebase.google.com/docs/web/setup#add_firebase_to_your_app
679
+ * | Add Firebase to your app} and
680
+ * {@link
681
+ * https://firebase.google.com/docs/web/setup#multiple-projects
682
+ * | Initialize multiple projects} for detailed documentation.
683
+ *
684
+ * @example
685
+ * ```javascript
686
+ *
687
+ * // Initialize an instance of `FirebaseServerApp`.
688
+ * // Retrieve your own options values by adding a web app on
689
+ * // https://console.firebase.google.com
690
+ * initializeServerApp({
691
+ * apiKey: "AIza....", // Auth / General Use
692
+ * authDomain: "YOUR_APP.firebaseapp.com", // Auth with popup/redirect
693
+ * databaseURL: "https://YOUR_APP.firebaseio.com", // Realtime Database
694
+ * storageBucket: "YOUR_APP.appspot.com", // Storage
695
+ * messagingSenderId: "123456789" // Cloud Messaging
696
+ * },
697
+ * {
698
+ * authIdToken: "Your Auth ID Token"
699
+ * });
700
+ * ```
701
+ *
702
+ * @param options - `Firebase.AppOptions` to configure the app's services, or a
703
+ * a `FirebaseApp` instance which contains the `AppOptions` within.
704
+ * @param config - Optional `FirebaseServerApp` settings.
705
+ *
706
+ * @returns The initialized `FirebaseServerApp`.
707
+ *
708
+ * @throws If invoked in an unsupported non-server environment such as a browser.
709
+ *
710
+ * @throws If {@link FirebaseServerAppSettings.releaseOnDeref} is defined but the runtime doesn't
711
+ * provide Finalization Registry support.
712
+ *
713
+ * @public
714
+ */
715
+ declare function initializeServerApp(options: FirebaseOptions | FirebaseApp, config?: FirebaseServerAppSettings): FirebaseServerApp;
716
+ /**
717
+ * Creates and initializes a {@link @firebase/app#FirebaseServerApp} instance.
718
+ *
719
+ * @param config - Optional `FirebaseServerApp` settings.
720
+ *
721
+ * @returns The initialized `FirebaseServerApp`.
722
+ *
723
+ * @throws If invoked in an unsupported non-server environment such as a browser.
724
+ * @throws If {@link FirebaseServerAppSettings.releaseOnDeref} is defined but the runtime doesn't
725
+ * provide Finalization Registry support.
726
+ * @throws If the `FIREBASE_OPTIONS` environment variable does not contain a valid project
727
+ * configuration required for auto-initialization.
728
+ *
729
+ * @public
730
+ */
731
+ declare function initializeServerApp(config?: FirebaseServerAppSettings): FirebaseServerApp;
732
+ /**
733
+ * Retrieves a {@link @firebase/app#FirebaseApp} instance.
734
+ *
735
+ * When called with no arguments, the default app is returned. When an app name
736
+ * is provided, the app corresponding to that name is returned.
737
+ *
738
+ * An exception is thrown if the app being retrieved has not yet been
739
+ * initialized.
740
+ *
741
+ * @example
742
+ * ```javascript
743
+ * // Return the default app
744
+ * const app = getApp();
745
+ * ```
746
+ *
747
+ * @example
748
+ * ```javascript
749
+ * // Return a named app
750
+ * const otherApp = getApp("otherApp");
751
+ * ```
752
+ *
753
+ * @param name - Optional name of the app to return. If no name is
754
+ * provided, the default is `"[DEFAULT]"`.
755
+ *
756
+ * @returns The app corresponding to the provided app name.
757
+ * If no app name is provided, the default app is returned.
758
+ *
759
+ * @public
760
+ */
761
+ declare function getApp(name?: string): FirebaseApp;
762
+ /**
763
+ * A (read-only) array of all initialized apps.
764
+ * @public
765
+ */
766
+ declare function getApps(): FirebaseApp[];
767
+ /**
768
+ * Renders this app unusable and frees the resources of all associated
769
+ * services.
770
+ *
771
+ * @example
772
+ * ```javascript
773
+ * deleteApp(app)
774
+ * .then(function() {
775
+ * console.log("App deleted successfully");
776
+ * })
777
+ * .catch(function(error) {
778
+ * console.log("Error deleting app:", error);
779
+ * });
780
+ * ```
781
+ *
782
+ * @public
783
+ */
784
+ declare function deleteApp(app: FirebaseApp): Promise<void>;
785
+ /**
786
+ * Registers a library's name and version for platform logging purposes.
787
+ * @param library - Name of 1p or 3p library (e.g. firestore, angularfire)
788
+ * @param version - Current version of that library.
789
+ * @param variant - Bundle variant, e.g., node, rn, etc.
790
+ *
791
+ * @public
792
+ */
793
+ declare function registerVersion(libraryKeyOrName: string, version: string, variant?: string): void;
794
+ /**
795
+ * Sets log handler for all Firebase SDKs.
796
+ * @param logCallback - An optional custom log handler that executes user code whenever
797
+ * the Firebase SDK makes a logging call.
798
+ *
799
+ * @public
800
+ */
801
+ declare function onLog(logCallback: LogCallback | null, options?: LogOptions): void;
802
+ /**
803
+ * Sets log level for all Firebase SDKs.
804
+ *
805
+ * All of the log types above the current log level are captured (i.e. if
806
+ * you set the log level to `info`, errors are logged, but `debug` and
807
+ * `verbose` logs are not).
808
+ *
809
+ * @public
810
+ */
811
+ declare function setLogLevel(logLevel: LogLevelString): void;
812
+
813
+ /**
814
+ * @license
815
+ * Copyright 2019 Google LLC
816
+ *
817
+ * Licensed under the Apache License, Version 2.0 (the "License");
818
+ * you may not use this file except in compliance with the License.
819
+ * You may obtain a copy of the License at
820
+ *
821
+ * http://www.apache.org/licenses/LICENSE-2.0
822
+ *
823
+ * Unless required by applicable law or agreed to in writing, software
824
+ * distributed under the License is distributed on an "AS IS" BASIS,
825
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
826
+ * See the License for the specific language governing permissions and
827
+ * limitations under the License.
828
+ */
829
+ /**
830
+ * The default app name
831
+ *
832
+ * @internal
833
+ */
834
+ declare const DEFAULT_ENTRY_NAME = "[DEFAULT]";
835
+
836
+ /**
837
+ * @license
838
+ * Copyright 2019 Google LLC
839
+ *
840
+ * Licensed under the Apache License, Version 2.0 (the "License");
841
+ * you may not use this file except in compliance with the License.
842
+ * You may obtain a copy of the License at
843
+ *
844
+ * http://www.apache.org/licenses/LICENSE-2.0
845
+ *
846
+ * Unless required by applicable law or agreed to in writing, software
847
+ * distributed under the License is distributed on an "AS IS" BASIS,
848
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
849
+ * See the License for the specific language governing permissions and
850
+ * limitations under the License.
851
+ */
852
+
853
+ /**
854
+ * @internal
855
+ */
856
+ declare const _apps: Map<string, FirebaseApp>;
857
+ /**
858
+ * @internal
859
+ */
860
+ declare const _serverApps: Map<string, FirebaseServerApp>;
861
+ /**
862
+ * Registered components.
863
+ *
864
+ * @internal
865
+ */
866
+ declare const _components: Map<string, Component<any>>;
867
+ /**
868
+ * @param component - the component being added to this app's container
869
+ *
870
+ * @internal
871
+ */
872
+ declare function _addComponent<T extends Name>(app: FirebaseApp, component: Component<T>): void;
873
+ /**
874
+ *
875
+ * @internal
876
+ */
877
+ declare function _addOrOverwriteComponent(app: FirebaseApp, component: Component): void;
878
+ /**
879
+ *
880
+ * @param component - the component to register
881
+ * @returns whether or not the component is registered successfully
882
+ *
883
+ * @internal
884
+ */
885
+ declare function _registerComponent<T extends Name>(component: Component<T>): boolean;
886
+ /**
887
+ *
888
+ * @param app - FirebaseApp instance
889
+ * @param name - service name
890
+ *
891
+ * @returns the provider for the service with the matching name
892
+ *
893
+ * @internal
894
+ */
895
+ declare function _getProvider<T extends Name>(app: FirebaseApp, name: T): Provider<T>;
896
+ /**
897
+ *
898
+ * @param app - FirebaseApp instance
899
+ * @param name - service name
900
+ * @param instanceIdentifier - service instance identifier in case the service supports multiple instances
901
+ *
902
+ * @internal
903
+ */
904
+ declare function _removeServiceInstance<T extends Name>(app: FirebaseApp, name: T, instanceIdentifier?: string): void;
905
+ /**
906
+ *
907
+ * @param obj - an object of type FirebaseApp, FirebaseOptions or FirebaseAppSettings.
908
+ *
909
+ * @returns true if the provide object is of type FirebaseApp.
910
+ *
911
+ * @internal
912
+ */
913
+ declare function _isFirebaseApp(obj: FirebaseApp | FirebaseOptions | FirebaseAppSettings): obj is FirebaseApp;
914
+ /**
915
+ *
916
+ * @param obj - an object of type FirebaseApp, FirebaseOptions or FirebaseAppSettings.
917
+ *
918
+ * @returns true if the provided object is of type FirebaseServerAppImpl.
919
+ *
920
+ * @internal
921
+ */
922
+ declare function _isFirebaseServerAppSettings(obj: FirebaseApp | FirebaseOptions | FirebaseAppSettings): obj is FirebaseServerAppSettings;
923
+ /**
924
+ *
925
+ * @param obj - an object of type FirebaseApp.
926
+ *
927
+ * @returns true if the provided object is of type FirebaseServerAppImpl.
928
+ *
929
+ * @internal
930
+ */
931
+ declare function _isFirebaseServerApp(obj: FirebaseApp | FirebaseServerApp | null | undefined): obj is FirebaseServerApp;
932
+ /**
933
+ * Test only
934
+ *
935
+ * @internal
936
+ */
937
+ declare function _clearComponents(): void;
938
+
939
+ export { FirebaseApp, FirebaseAppSettings, FirebaseError, FirebaseOptions, FirebaseServerApp, FirebaseServerAppSettings, SDK_VERSION, DEFAULT_ENTRY_NAME as _DEFAULT_ENTRY_NAME, _FirebaseAppInternal, _FirebaseService, _addComponent, _addOrOverwriteComponent, _apps, _clearComponents, _components, _getProvider, _isFirebaseApp, _isFirebaseServerApp, _isFirebaseServerAppSettings, _registerComponent, _removeServiceInstance, _serverApps, deleteApp, getApp, getApps, initializeApp, initializeServerApp, onLog, registerVersion, setLogLevel };