firebase-admin 13.3.0 → 13.5.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.
- package/lib/app/core.d.ts +1 -1
- package/lib/app/core.js +1 -1
- package/lib/app/credential-factory.d.ts +1 -1
- package/lib/app/credential-factory.js +1 -1
- package/lib/app/credential-internal.d.ts +1 -1
- package/lib/app/credential-internal.js +1 -1
- package/lib/app/credential.d.ts +1 -1
- package/lib/app/credential.js +1 -1
- package/lib/app/firebase-app.d.ts +1 -1
- package/lib/app/firebase-app.js +23 -2
- package/lib/app/firebase-namespace.d.ts +1 -1
- package/lib/app/firebase-namespace.js +1 -1
- package/lib/app/index.d.ts +1 -1
- package/lib/app/index.js +1 -1
- package/lib/app/lifecycle.d.ts +57 -1
- package/lib/app/lifecycle.js +141 -23
- package/lib/app-check/app-check-api-client-internal.d.ts +1 -1
- package/lib/app-check/app-check-api-client-internal.js +1 -1
- package/lib/app-check/app-check-api.d.ts +1 -1
- package/lib/app-check/app-check-api.js +1 -1
- package/lib/app-check/app-check-namespace.d.ts +1 -1
- package/lib/app-check/app-check-namespace.js +1 -1
- package/lib/app-check/app-check.d.ts +1 -1
- package/lib/app-check/app-check.js +1 -1
- package/lib/app-check/index.d.ts +1 -1
- package/lib/app-check/index.js +1 -1
- package/lib/app-check/token-generator.d.ts +1 -1
- package/lib/app-check/token-generator.js +1 -1
- package/lib/app-check/token-verifier.d.ts +1 -1
- package/lib/app-check/token-verifier.js +1 -1
- package/lib/auth/action-code-settings-builder.d.ts +1 -1
- package/lib/auth/action-code-settings-builder.js +1 -1
- package/lib/auth/auth-api-request.d.ts +1 -1
- package/lib/auth/auth-api-request.js +1 -1
- package/lib/auth/auth-config.d.ts +1 -1
- package/lib/auth/auth-config.js +1 -1
- package/lib/auth/auth-namespace.d.ts +1 -1
- package/lib/auth/auth-namespace.js +1 -1
- package/lib/auth/auth.d.ts +1 -1
- package/lib/auth/auth.js +1 -1
- package/lib/auth/base-auth.d.ts +1 -1
- package/lib/auth/base-auth.js +1 -1
- package/lib/auth/identifier.d.ts +1 -1
- package/lib/auth/identifier.js +1 -1
- package/lib/auth/index.d.ts +1 -1
- package/lib/auth/index.js +1 -1
- package/lib/auth/project-config-manager.d.ts +1 -1
- package/lib/auth/project-config-manager.js +1 -1
- package/lib/auth/project-config.d.ts +1 -1
- package/lib/auth/project-config.js +1 -1
- package/lib/auth/tenant-manager.d.ts +1 -1
- package/lib/auth/tenant-manager.js +1 -1
- package/lib/auth/tenant.d.ts +1 -1
- package/lib/auth/tenant.js +1 -1
- package/lib/auth/token-generator.d.ts +1 -1
- package/lib/auth/token-generator.js +1 -1
- package/lib/auth/token-verifier.d.ts +1 -1
- package/lib/auth/token-verifier.js +1 -1
- package/lib/auth/user-import-builder.d.ts +1 -1
- package/lib/auth/user-import-builder.js +1 -1
- package/lib/auth/user-record.d.ts +1 -1
- package/lib/auth/user-record.js +1 -1
- package/lib/credential/index.d.ts +1 -1
- package/lib/credential/index.js +1 -1
- package/lib/data-connect/data-connect-api-client-internal.d.ts +1 -1
- package/lib/data-connect/data-connect-api-client-internal.js +147 -1
- package/lib/data-connect/data-connect-api.d.ts +1 -1
- package/lib/data-connect/data-connect-api.js +1 -1
- package/lib/data-connect/data-connect.d.ts +44 -14
- package/lib/data-connect/data-connect.js +57 -19
- package/lib/data-connect/index.d.ts +1 -1
- package/lib/data-connect/index.js +1 -1
- package/lib/database/database-namespace.d.ts +1 -1
- package/lib/database/database-namespace.js +1 -1
- package/lib/database/database.d.ts +1 -1
- package/lib/database/database.js +1 -1
- package/lib/database/index.d.ts +1 -1
- package/lib/database/index.js +1 -1
- package/lib/default-namespace.d.ts +1 -1
- package/lib/default-namespace.js +1 -1
- package/lib/eventarc/cloudevent.d.ts +1 -1
- package/lib/eventarc/cloudevent.js +1 -1
- package/lib/eventarc/eventarc-client-internal.d.ts +1 -1
- package/lib/eventarc/eventarc-client-internal.js +1 -1
- package/lib/eventarc/eventarc-utils.d.ts +1 -1
- package/lib/eventarc/eventarc-utils.js +1 -1
- package/lib/eventarc/eventarc.d.ts +1 -1
- package/lib/eventarc/eventarc.js +1 -1
- package/lib/eventarc/index.d.ts +1 -1
- package/lib/eventarc/index.js +1 -1
- package/lib/extensions/extensions-api-client-internal.d.ts +1 -1
- package/lib/extensions/extensions-api-client-internal.js +1 -1
- package/lib/extensions/extensions-api.d.ts +1 -1
- package/lib/extensions/extensions-api.js +1 -1
- package/lib/extensions/extensions.d.ts +1 -1
- package/lib/extensions/extensions.js +1 -1
- package/lib/extensions/index.d.ts +1 -1
- package/lib/extensions/index.js +1 -1
- package/lib/firebase-namespace-api.d.ts +1 -1
- package/lib/firebase-namespace-api.js +1 -1
- package/lib/firestore/firestore-internal.d.ts +1 -1
- package/lib/firestore/firestore-internal.js +1 -1
- package/lib/firestore/firestore-namespace.d.ts +1 -1
- package/lib/firestore/firestore-namespace.js +1 -1
- package/lib/firestore/index.d.ts +1 -1
- package/lib/firestore/index.js +1 -1
- package/lib/functions/functions-api-client-internal.d.ts +1 -1
- package/lib/functions/functions-api-client-internal.js +1 -1
- package/lib/functions/functions-api.d.ts +1 -1
- package/lib/functions/functions-api.js +1 -1
- package/lib/functions/functions.d.ts +1 -1
- package/lib/functions/functions.js +1 -1
- package/lib/functions/index.d.ts +1 -1
- package/lib/functions/index.js +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/installations/index.d.ts +1 -1
- package/lib/installations/index.js +1 -1
- package/lib/installations/installations-namespace.d.ts +1 -1
- package/lib/installations/installations-namespace.js +1 -1
- package/lib/installations/installations-request-handler.d.ts +1 -1
- package/lib/installations/installations-request-handler.js +1 -1
- package/lib/installations/installations.d.ts +1 -1
- package/lib/installations/installations.js +1 -1
- package/lib/instance-id/index.d.ts +1 -1
- package/lib/instance-id/index.js +1 -1
- package/lib/instance-id/instance-id-namespace.d.ts +1 -1
- package/lib/instance-id/instance-id-namespace.js +1 -1
- package/lib/instance-id/instance-id.d.ts +1 -1
- package/lib/instance-id/instance-id.js +1 -1
- package/lib/machine-learning/index.d.ts +1 -1
- package/lib/machine-learning/index.js +1 -1
- package/lib/machine-learning/machine-learning-api-client.d.ts +1 -1
- package/lib/machine-learning/machine-learning-api-client.js +1 -1
- package/lib/machine-learning/machine-learning-namespace.d.ts +1 -1
- package/lib/machine-learning/machine-learning-namespace.js +1 -1
- package/lib/machine-learning/machine-learning-utils.d.ts +1 -1
- package/lib/machine-learning/machine-learning-utils.js +1 -1
- package/lib/machine-learning/machine-learning.d.ts +1 -1
- package/lib/machine-learning/machine-learning.js +1 -1
- package/lib/messaging/index.d.ts +1 -1
- package/lib/messaging/index.js +1 -1
- package/lib/messaging/messaging-api-request-internal.d.ts +1 -1
- package/lib/messaging/messaging-api-request-internal.js +1 -1
- package/lib/messaging/messaging-api.d.ts +5 -1
- package/lib/messaging/messaging-api.js +1 -1
- package/lib/messaging/messaging-errors-internal.d.ts +1 -1
- package/lib/messaging/messaging-errors-internal.js +1 -1
- package/lib/messaging/messaging-internal.d.ts +1 -1
- package/lib/messaging/messaging-internal.js +17 -1
- package/lib/messaging/messaging-namespace.d.ts +1 -1
- package/lib/messaging/messaging-namespace.js +1 -1
- package/lib/messaging/messaging.d.ts +1 -1
- package/lib/messaging/messaging.js +1 -1
- package/lib/project-management/android-app.d.ts +1 -1
- package/lib/project-management/android-app.js +1 -1
- package/lib/project-management/app-metadata.d.ts +1 -1
- package/lib/project-management/app-metadata.js +1 -1
- package/lib/project-management/index.d.ts +1 -1
- package/lib/project-management/index.js +1 -1
- package/lib/project-management/ios-app.d.ts +1 -1
- package/lib/project-management/ios-app.js +1 -1
- package/lib/project-management/project-management-api-request-internal.d.ts +1 -1
- package/lib/project-management/project-management-api-request-internal.js +1 -1
- package/lib/project-management/project-management-namespace.d.ts +1 -1
- package/lib/project-management/project-management-namespace.js +1 -1
- package/lib/project-management/project-management.d.ts +1 -1
- package/lib/project-management/project-management.js +1 -1
- package/lib/remote-config/condition-evaluator-internal.d.ts +1 -1
- package/lib/remote-config/condition-evaluator-internal.js +1 -1
- package/lib/remote-config/index.d.ts +1 -1
- package/lib/remote-config/index.js +1 -1
- package/lib/remote-config/internal/value-impl.d.ts +1 -1
- package/lib/remote-config/internal/value-impl.js +1 -1
- package/lib/remote-config/remote-config-api-client-internal.d.ts +1 -1
- package/lib/remote-config/remote-config-api-client-internal.js +1 -1
- package/lib/remote-config/remote-config-api.d.ts +1 -1
- package/lib/remote-config/remote-config-api.js +1 -1
- package/lib/remote-config/remote-config-namespace.d.ts +1 -1
- package/lib/remote-config/remote-config-namespace.js +1 -1
- package/lib/remote-config/remote-config.d.ts +1 -1
- package/lib/remote-config/remote-config.js +1 -1
- package/lib/security-rules/index.d.ts +1 -1
- package/lib/security-rules/index.js +1 -1
- package/lib/security-rules/security-rules-api-client-internal.d.ts +1 -1
- package/lib/security-rules/security-rules-api-client-internal.js +1 -1
- package/lib/security-rules/security-rules-internal.d.ts +1 -1
- package/lib/security-rules/security-rules-internal.js +1 -1
- package/lib/security-rules/security-rules-namespace.d.ts +1 -1
- package/lib/security-rules/security-rules-namespace.js +1 -1
- package/lib/security-rules/security-rules.d.ts +1 -1
- package/lib/security-rules/security-rules.js +1 -1
- package/lib/storage/index.d.ts +1 -1
- package/lib/storage/index.js +1 -1
- package/lib/storage/storage-namespace.d.ts +1 -1
- package/lib/storage/storage-namespace.js +1 -1
- package/lib/storage/storage.d.ts +1 -1
- package/lib/storage/storage.js +1 -1
- package/lib/storage/utils.d.ts +1 -1
- package/lib/storage/utils.js +1 -1
- package/lib/utils/api-request.d.ts +1 -1
- package/lib/utils/api-request.js +1 -1
- package/lib/utils/crypto-signer.d.ts +1 -1
- package/lib/utils/crypto-signer.js +1 -1
- package/lib/utils/deep-copy.d.ts +1 -1
- package/lib/utils/deep-copy.js +1 -1
- package/lib/utils/error.d.ts +1 -1
- package/lib/utils/error.js +1 -1
- package/lib/utils/index.d.ts +1 -1
- package/lib/utils/index.js +1 -1
- package/lib/utils/jwt.d.ts +1 -1
- package/lib/utils/jwt.js +1 -1
- package/lib/utils/validator.d.ts +1 -1
- package/lib/utils/validator.js +1 -1
- package/package.json +5 -4
package/lib/app/core.d.ts
CHANGED
package/lib/app/core.js
CHANGED
package/lib/app/credential.d.ts
CHANGED
package/lib/app/credential.js
CHANGED
package/lib/app/firebase-app.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! firebase-admin v13.
|
|
1
|
+
/*! firebase-admin v13.5.0 */
|
|
2
2
|
"use strict";
|
|
3
3
|
/*!
|
|
4
4
|
* @license
|
|
@@ -121,18 +121,22 @@ exports.FirebaseAppInternals = FirebaseAppInternals;
|
|
|
121
121
|
* @internal
|
|
122
122
|
*/
|
|
123
123
|
class FirebaseApp {
|
|
124
|
-
constructor(options, name, appStore) {
|
|
124
|
+
constructor(options, name, autoInit = false, appStore) {
|
|
125
125
|
this.appStore = appStore;
|
|
126
126
|
this.services_ = {};
|
|
127
127
|
this.isDeleted_ = false;
|
|
128
|
+
this.autoInit_ = false;
|
|
129
|
+
this.customCredential_ = true;
|
|
128
130
|
this.name_ = name;
|
|
129
131
|
this.options_ = (0, deep_copy_1.deepCopy)(options);
|
|
132
|
+
this.autoInit_ = autoInit;
|
|
130
133
|
if (!validator.isNonNullObject(this.options_)) {
|
|
131
134
|
throw new error_1.FirebaseAppError(error_1.AppErrorCodes.INVALID_APP_OPTIONS, 'Invalid Firebase app options passed as the first argument to initializeApp() for the ' +
|
|
132
135
|
`app named "${this.name_}". Options must be a non-null object.`);
|
|
133
136
|
}
|
|
134
137
|
const hasCredential = ('credential' in this.options_);
|
|
135
138
|
if (!hasCredential) {
|
|
139
|
+
this.customCredential_ = false;
|
|
136
140
|
this.options_.credential = (0, credential_internal_1.getApplicationDefault)(this.options_.httpAgent);
|
|
137
141
|
}
|
|
138
142
|
const credential = this.options_.credential;
|
|
@@ -167,6 +171,23 @@ class FirebaseApp {
|
|
|
167
171
|
getOrInitService(name, init) {
|
|
168
172
|
return this.ensureService_(name, () => init(this));
|
|
169
173
|
}
|
|
174
|
+
/**
|
|
175
|
+
* Returns `true` if this app was initialized with auto-initialization.
|
|
176
|
+
*
|
|
177
|
+
* @internal
|
|
178
|
+
*/
|
|
179
|
+
autoInit() {
|
|
180
|
+
return this.autoInit_;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Returns `true` if the `FirebaseApp` instance was initialized with a custom
|
|
184
|
+
* `Credential`.
|
|
185
|
+
*
|
|
186
|
+
* @internal
|
|
187
|
+
*/
|
|
188
|
+
customCredential() {
|
|
189
|
+
return this.customCredential_;
|
|
190
|
+
}
|
|
170
191
|
/**
|
|
171
192
|
* Deletes the FirebaseApp instance.
|
|
172
193
|
*
|
package/lib/app/index.d.ts
CHANGED
package/lib/app/index.js
CHANGED
package/lib/app/lifecycle.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! firebase-admin v13.
|
|
1
|
+
/*! firebase-admin v13.5.0 */
|
|
2
2
|
/*!
|
|
3
3
|
* @license
|
|
4
4
|
* Copyright 2021 Google Inc.
|
|
@@ -31,8 +31,64 @@ export declare class AppStore {
|
|
|
31
31
|
removeApp(appName: string): void;
|
|
32
32
|
}
|
|
33
33
|
export declare const defaultAppStore: AppStore;
|
|
34
|
+
/**
|
|
35
|
+
* Initializes the `App` instance.
|
|
36
|
+
*
|
|
37
|
+
* Creates a new instance of {@link App} if one doesn't exist, or returns an existing
|
|
38
|
+
* `App` instance if one exists with the same `appName` and `options`.
|
|
39
|
+
*
|
|
40
|
+
* Note, due to the inablity to compare `http.Agent` objects and `Credential` objects,
|
|
41
|
+
* this function cannot support idempotency if either of `options.httpAgent` or
|
|
42
|
+
* `options.credential` are defined. When either is defined, subsequent invocations will
|
|
43
|
+
* throw a `FirebaseAppError` instead of returning an `App` object.
|
|
44
|
+
*
|
|
45
|
+
* For example, to safely initialize an app that may already exist:
|
|
46
|
+
*
|
|
47
|
+
* ```javascript
|
|
48
|
+
* let app;
|
|
49
|
+
* try {
|
|
50
|
+
* app = getApp("myApp");
|
|
51
|
+
* } catch (error) {
|
|
52
|
+
* app = initializeApp({ credential: myCredential }, "myApp");
|
|
53
|
+
* }
|
|
54
|
+
* ```
|
|
55
|
+
*
|
|
56
|
+
* @param options - Optional A set of {@link AppOptions} for the `App` instance.
|
|
57
|
+
* If not present, `initializeApp` will try to initialize with the options from the
|
|
58
|
+
* `FIREBASE_CONFIG` environment variable. If the environment variable contains a
|
|
59
|
+
* string that starts with `{` it will be parsed as JSON, otherwise it will be
|
|
60
|
+
* assumed to be pointing to a file.
|
|
61
|
+
* @param appName - Optional name of the `App` instance.
|
|
62
|
+
*
|
|
63
|
+
* @returns A new App instance, or the existing App if the instance already exists with
|
|
64
|
+
* the provided configuration.
|
|
65
|
+
*
|
|
66
|
+
* @throws FirebaseAppError if an `App` with the same name has already been
|
|
67
|
+
* initialized with a different set of `AppOptions`.
|
|
68
|
+
* @throws FirebaseAppError if an existing `App` exists and `options.httpAgent`
|
|
69
|
+
* or `options.credential` are defined. This is due to the function's inability to
|
|
70
|
+
* determine if the existing `App`'s `options` equate to the `options` parameter
|
|
71
|
+
* of this function. It's recommended to use {@link getApp} or {@link getApps} if your
|
|
72
|
+
* implementation uses either of these two fields in `AppOptions`.
|
|
73
|
+
*/
|
|
34
74
|
export declare function initializeApp(options?: AppOptions, appName?: string): App;
|
|
75
|
+
/**
|
|
76
|
+
* Returns an existing {@link App} instance for the provided name. If no name
|
|
77
|
+
* is provided the the default app name is used.
|
|
78
|
+
*
|
|
79
|
+
* @param appName - Optional name of the `App` instance.
|
|
80
|
+
*
|
|
81
|
+
* @returns An existing `App` instance that matches the name provided.
|
|
82
|
+
*
|
|
83
|
+
* @throws FirebaseAppError if no `App` exists for the given name.
|
|
84
|
+
* @throws FirebaseAppError if the `appName` is malformed.
|
|
85
|
+
*/
|
|
35
86
|
export declare function getApp(appName?: string): App;
|
|
87
|
+
/**
|
|
88
|
+
* A (read-only) array of all initialized apps.
|
|
89
|
+
*
|
|
90
|
+
* @returns An array containing all initialized apps.
|
|
91
|
+
*/
|
|
36
92
|
export declare function getApps(): App[];
|
|
37
93
|
/**
|
|
38
94
|
* Renders this given `App` unusable and frees the resources of
|
package/lib/app/lifecycle.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! firebase-admin v13.
|
|
1
|
+
/*! firebase-admin v13.5.0 */
|
|
2
2
|
"use strict";
|
|
3
3
|
/*!
|
|
4
4
|
* @license
|
|
@@ -27,42 +27,52 @@ const validator = require("../utils/validator");
|
|
|
27
27
|
const error_1 = require("../utils/error");
|
|
28
28
|
const credential_internal_1 = require("./credential-internal");
|
|
29
29
|
const firebase_app_1 = require("./firebase-app");
|
|
30
|
+
const fastDeepEqual = require('fast-deep-equal');
|
|
30
31
|
const DEFAULT_APP_NAME = '[DEFAULT]';
|
|
31
32
|
class AppStore {
|
|
32
33
|
constructor() {
|
|
33
34
|
this.appStore = new Map();
|
|
34
35
|
}
|
|
35
36
|
initializeApp(options, appName = DEFAULT_APP_NAME) {
|
|
37
|
+
validateAppNameFormat(appName);
|
|
38
|
+
let autoInit = false;
|
|
36
39
|
if (typeof options === 'undefined') {
|
|
40
|
+
autoInit = true;
|
|
37
41
|
options = loadOptionsFromEnvVar();
|
|
38
42
|
options.credential = (0, credential_internal_1.getApplicationDefault)();
|
|
39
43
|
}
|
|
40
|
-
if
|
|
41
|
-
|
|
44
|
+
// Check if an app already exists and, if so, ensure its `AppOptions` match
|
|
45
|
+
// those of this `initializeApp` request.
|
|
46
|
+
if (!this.appStore.has(appName)) {
|
|
47
|
+
const app = new firebase_app_1.FirebaseApp(options, appName, autoInit, this);
|
|
48
|
+
this.appStore.set(app.name, app);
|
|
49
|
+
return app;
|
|
42
50
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
'you only need to call initializeApp() once. But if you do want to initialize ' +
|
|
48
|
-
'multiple apps, pass a second argument to initializeApp() to give each app a unique ' +
|
|
49
|
-
'name.');
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
throw new error_1.FirebaseAppError(error_1.AppErrorCodes.DUPLICATE_APP, `Firebase app named "${appName}" already exists. This means you called initializeApp() ` +
|
|
53
|
-
'more than once with the same app name as the second argument. Make sure you provide a ' +
|
|
54
|
-
'unique name every time you call initializeApp().');
|
|
55
|
-
}
|
|
51
|
+
const currentApp = this.appStore.get(appName);
|
|
52
|
+
// Ensure the `autoInit` state matches the existing app's. If not, throw.
|
|
53
|
+
if (currentApp.autoInit() !== autoInit) {
|
|
54
|
+
throw new error_1.FirebaseAppError(error_1.AppErrorCodes.INVALID_APP_OPTIONS, `A Firebase app named "${appName}" already exists with a different configuration.`);
|
|
56
55
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
56
|
+
if (autoInit) {
|
|
57
|
+
// Auto-initialization is triggered when no options were passed to
|
|
58
|
+
// `initializeApp`. With no options to compare, simply return the App.
|
|
59
|
+
return currentApp;
|
|
60
|
+
}
|
|
61
|
+
// Ensure the options objects don't break deep equal comparisons.
|
|
62
|
+
validateAppOptionsSupportDeepEquals(options, currentApp);
|
|
63
|
+
// `FirebaseApp()` adds a synthesized `Credential` to `app.options` upon
|
|
64
|
+
// app construction. Run a comparison w/o `Credential` to see if the base
|
|
65
|
+
// configurations match. Return the existing app if so.
|
|
66
|
+
const currentAppOptions = { ...currentApp.options };
|
|
67
|
+
delete currentAppOptions.credential;
|
|
68
|
+
if (!fastDeepEqual(options, currentAppOptions)) {
|
|
69
|
+
throw new error_1.FirebaseAppError(error_1.AppErrorCodes.DUPLICATE_APP, `A Firebase app named "${appName}" already exists with a different configuration.`);
|
|
70
|
+
}
|
|
71
|
+
return currentApp;
|
|
60
72
|
}
|
|
61
73
|
getApp(appName = DEFAULT_APP_NAME) {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
else if (!this.appStore.has(appName)) {
|
|
74
|
+
validateAppNameFormat(appName);
|
|
75
|
+
if (!this.appStore.has(appName)) {
|
|
66
76
|
let errorMessage = (appName === DEFAULT_APP_NAME)
|
|
67
77
|
? 'The default Firebase app does not exist. ' : `Firebase app named "${appName}" does not exist. `;
|
|
68
78
|
errorMessage += 'Make sure you call initializeApp() before using any of the Firebase services.';
|
|
@@ -101,13 +111,121 @@ class AppStore {
|
|
|
101
111
|
}
|
|
102
112
|
}
|
|
103
113
|
exports.AppStore = AppStore;
|
|
114
|
+
/**
|
|
115
|
+
* Validates that the `requestedOptions` and the `existingApp` options objects
|
|
116
|
+
* do not have fields that would break deep equals comparisons.
|
|
117
|
+
*
|
|
118
|
+
* @param requestedOptions The incoming `AppOptions` of a new `initailizeApp`
|
|
119
|
+
* request.
|
|
120
|
+
* @param existingApp An existing `FirebaseApp` with internal `options` to
|
|
121
|
+
* compare against.
|
|
122
|
+
*
|
|
123
|
+
* @throws FirebaseAppError if the objects cannot be deeply compared.
|
|
124
|
+
*
|
|
125
|
+
* @internal
|
|
126
|
+
*/
|
|
127
|
+
function validateAppOptionsSupportDeepEquals(requestedOptions, existingApp) {
|
|
128
|
+
// http.Agent checks.
|
|
129
|
+
if (typeof requestedOptions.httpAgent !== 'undefined') {
|
|
130
|
+
throw new error_1.FirebaseAppError(error_1.AppErrorCodes.INVALID_APP_OPTIONS, `Firebase app named "${existingApp.name}" already exists and initializeApp was` +
|
|
131
|
+
' invoked with an optional http.Agent. The SDK cannot confirm the equality' +
|
|
132
|
+
' of http.Agent objects with the existing app. Please use getApp or getApps to reuse' +
|
|
133
|
+
' the existing app instead.');
|
|
134
|
+
}
|
|
135
|
+
else if (typeof existingApp.options.httpAgent !== 'undefined') {
|
|
136
|
+
throw new error_1.FirebaseAppError(error_1.AppErrorCodes.INVALID_APP_OPTIONS, `An existing app named "${existingApp.name}" already exists with a different` +
|
|
137
|
+
' options configuration: httpAgent.');
|
|
138
|
+
}
|
|
139
|
+
// Credential checks.
|
|
140
|
+
if (typeof requestedOptions.credential !== 'undefined') {
|
|
141
|
+
throw new error_1.FirebaseAppError(error_1.AppErrorCodes.INVALID_APP_OPTIONS, `Firebase app named "${existingApp.name}" already exists and initializeApp was` +
|
|
142
|
+
' invoked with an optional Credential. The SDK cannot confirm the equality' +
|
|
143
|
+
' of Credential objects with the existing app. Please use getApp or getApps' +
|
|
144
|
+
' to reuse the existing app instead.');
|
|
145
|
+
}
|
|
146
|
+
if (existingApp.customCredential()) {
|
|
147
|
+
throw new error_1.FirebaseAppError(error_1.AppErrorCodes.INVALID_APP_OPTIONS, `An existing app named "${existingApp.name}" already exists with a different` +
|
|
148
|
+
' options configuration: Credential.');
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Checks to see if the provided appName is a non-empty string and throws if it
|
|
153
|
+
* is not.
|
|
154
|
+
*
|
|
155
|
+
* @param appName A string representation of an App name.
|
|
156
|
+
*
|
|
157
|
+
* @throws FirebaseAppError if appName is not of type string or is empty.
|
|
158
|
+
*
|
|
159
|
+
* @internal
|
|
160
|
+
*/
|
|
161
|
+
function validateAppNameFormat(appName) {
|
|
162
|
+
if (!validator.isNonEmptyString(appName)) {
|
|
163
|
+
throw new error_1.FirebaseAppError(error_1.AppErrorCodes.INVALID_APP_NAME, `Invalid Firebase app name "${appName}" provided. App name must be a non-empty string.`);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
104
166
|
exports.defaultAppStore = new AppStore();
|
|
167
|
+
/**
|
|
168
|
+
* Initializes the `App` instance.
|
|
169
|
+
*
|
|
170
|
+
* Creates a new instance of {@link App} if one doesn't exist, or returns an existing
|
|
171
|
+
* `App` instance if one exists with the same `appName` and `options`.
|
|
172
|
+
*
|
|
173
|
+
* Note, due to the inablity to compare `http.Agent` objects and `Credential` objects,
|
|
174
|
+
* this function cannot support idempotency if either of `options.httpAgent` or
|
|
175
|
+
* `options.credential` are defined. When either is defined, subsequent invocations will
|
|
176
|
+
* throw a `FirebaseAppError` instead of returning an `App` object.
|
|
177
|
+
*
|
|
178
|
+
* For example, to safely initialize an app that may already exist:
|
|
179
|
+
*
|
|
180
|
+
* ```javascript
|
|
181
|
+
* let app;
|
|
182
|
+
* try {
|
|
183
|
+
* app = getApp("myApp");
|
|
184
|
+
* } catch (error) {
|
|
185
|
+
* app = initializeApp({ credential: myCredential }, "myApp");
|
|
186
|
+
* }
|
|
187
|
+
* ```
|
|
188
|
+
*
|
|
189
|
+
* @param options - Optional A set of {@link AppOptions} for the `App` instance.
|
|
190
|
+
* If not present, `initializeApp` will try to initialize with the options from the
|
|
191
|
+
* `FIREBASE_CONFIG` environment variable. If the environment variable contains a
|
|
192
|
+
* string that starts with `{` it will be parsed as JSON, otherwise it will be
|
|
193
|
+
* assumed to be pointing to a file.
|
|
194
|
+
* @param appName - Optional name of the `App` instance.
|
|
195
|
+
*
|
|
196
|
+
* @returns A new App instance, or the existing App if the instance already exists with
|
|
197
|
+
* the provided configuration.
|
|
198
|
+
*
|
|
199
|
+
* @throws FirebaseAppError if an `App` with the same name has already been
|
|
200
|
+
* initialized with a different set of `AppOptions`.
|
|
201
|
+
* @throws FirebaseAppError if an existing `App` exists and `options.httpAgent`
|
|
202
|
+
* or `options.credential` are defined. This is due to the function's inability to
|
|
203
|
+
* determine if the existing `App`'s `options` equate to the `options` parameter
|
|
204
|
+
* of this function. It's recommended to use {@link getApp} or {@link getApps} if your
|
|
205
|
+
* implementation uses either of these two fields in `AppOptions`.
|
|
206
|
+
*/
|
|
105
207
|
function initializeApp(options, appName = DEFAULT_APP_NAME) {
|
|
106
208
|
return exports.defaultAppStore.initializeApp(options, appName);
|
|
107
209
|
}
|
|
210
|
+
/**
|
|
211
|
+
* Returns an existing {@link App} instance for the provided name. If no name
|
|
212
|
+
* is provided the the default app name is used.
|
|
213
|
+
*
|
|
214
|
+
* @param appName - Optional name of the `App` instance.
|
|
215
|
+
*
|
|
216
|
+
* @returns An existing `App` instance that matches the name provided.
|
|
217
|
+
*
|
|
218
|
+
* @throws FirebaseAppError if no `App` exists for the given name.
|
|
219
|
+
* @throws FirebaseAppError if the `appName` is malformed.
|
|
220
|
+
*/
|
|
108
221
|
function getApp(appName = DEFAULT_APP_NAME) {
|
|
109
222
|
return exports.defaultAppStore.getApp(appName);
|
|
110
223
|
}
|
|
224
|
+
/**
|
|
225
|
+
* A (read-only) array of all initialized apps.
|
|
226
|
+
*
|
|
227
|
+
* @returns An array containing all initialized apps.
|
|
228
|
+
*/
|
|
111
229
|
function getApps() {
|
|
112
230
|
return exports.defaultAppStore.getApps();
|
|
113
231
|
}
|
package/lib/app-check/index.d.ts
CHANGED
package/lib/app-check/index.js
CHANGED
package/lib/auth/auth-config.js
CHANGED
package/lib/auth/auth.d.ts
CHANGED
package/lib/auth/auth.js
CHANGED
package/lib/auth/base-auth.d.ts
CHANGED
package/lib/auth/base-auth.js
CHANGED
package/lib/auth/identifier.d.ts
CHANGED
package/lib/auth/identifier.js
CHANGED
package/lib/auth/index.d.ts
CHANGED
package/lib/auth/index.js
CHANGED