firebase-admin 13.10.0 → 14.0.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/README.md +1 -2
- package/lib/app/core.d.ts +2 -38
- 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 +45 -14
- package/lib/app/credential.d.ts +1 -1
- package/lib/app/credential.js +1 -1
- package/lib/app/error.d.ts +47 -0
- package/lib/app/error.js +57 -0
- package/lib/app/firebase-app.d.ts +1 -1
- package/lib/app/firebase-app.js +28 -12
- package/lib/app/index.d.ts +4 -3
- package/lib/app/index.js +6 -4
- package/lib/app/lifecycle.d.ts +2 -2
- package/lib/app/lifecycle.js +46 -21
- package/lib/app-check/app-check-api-client-internal.d.ts +2 -16
- package/lib/app-check/app-check-api-client-internal.js +57 -48
- 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.d.ts +1 -1
- package/lib/app-check/app-check.js +6 -2
- package/lib/app-check/error.d.ts +47 -0
- package/lib/app-check/error.js +65 -0
- package/lib/app-check/index.d.ts +2 -1
- package/lib/app-check/index.js +5 -2
- package/lib/app-check/token-generator.d.ts +1 -1
- package/lib/app-check/token-generator.js +43 -13
- package/lib/app-check/token-verifier.d.ts +1 -1
- package/lib/app-check/token-verifier.js +39 -11
- package/lib/auth/action-code-settings-builder.d.ts +1 -1
- package/lib/auth/action-code-settings-builder.js +16 -16
- package/lib/auth/auth-api-request.d.ts +6 -4
- package/lib/auth/auth-api-request.js +277 -166
- package/lib/auth/auth-config.d.ts +31 -2
- package/lib/auth/auth-config.js +103 -103
- package/lib/auth/auth.d.ts +1 -1
- package/lib/auth/auth.js +1 -1
- package/lib/auth/base-auth.d.ts +2 -1
- package/lib/auth/base-auth.js +29 -27
- package/lib/auth/error.d.ts +137 -0
- package/lib/auth/error.js +690 -0
- package/lib/auth/identifier.d.ts +1 -1
- package/lib/auth/identifier.js +1 -1
- package/lib/auth/index.d.ts +2 -2
- package/lib/auth/index.js +4 -4
- 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 +4 -4
- package/lib/auth/tenant-manager.d.ts +2 -1
- package/lib/auth/tenant-manager.js +13 -10
- package/lib/auth/tenant.d.ts +1 -1
- package/lib/auth/tenant.js +7 -7
- package/lib/auth/token-generator.d.ts +1 -1
- package/lib/auth/token-generator.js +13 -13
- package/lib/auth/token-verifier.d.ts +1 -1
- package/lib/auth/token-verifier.js +22 -22
- package/lib/auth/user-import-builder.d.ts +1 -1
- package/lib/auth/user-import-builder.js +22 -22
- package/lib/auth/user-record.d.ts +1 -1
- package/lib/auth/user-record.js +6 -6
- 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 -16
- package/lib/data-connect/data-connect-api-client-internal.js +122 -65
- 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 +1 -1
- package/lib/data-connect/data-connect.js +1 -1
- package/lib/data-connect/error.d.ts +47 -0
- package/lib/data-connect/error.js +66 -0
- package/lib/data-connect/index.d.ts +2 -1
- package/lib/data-connect/index.js +5 -2
- package/lib/data-connect/validate-admin-args.d.ts +1 -1
- package/lib/data-connect/validate-admin-args.js +6 -3
- package/lib/database/database.d.ts +1 -1
- package/lib/database/database.js +11 -6
- package/lib/database/error.d.ts +39 -0
- package/lib/database/error.js +49 -0
- package/lib/database/index.d.ts +2 -2
- package/lib/database/index.js +4 -3
- package/lib/esm/app/index.js +2 -1
- package/lib/esm/app-check/index.js +2 -0
- package/lib/esm/auth/index.js +1 -1
- package/lib/esm/data-connect/index.js +2 -0
- package/lib/esm/database/index.js +1 -0
- package/lib/esm/eventarc/index.js +2 -0
- package/lib/esm/extensions/index.js +2 -0
- package/lib/esm/firebase-admin/index.js +13 -0
- package/lib/esm/firestore/index.js +1 -0
- package/lib/esm/functions/index.js +2 -0
- package/lib/esm/installations/index.js +1 -1
- package/lib/esm/machine-learning/index.js +2 -0
- package/lib/esm/messaging/index.js +1 -1
- package/lib/esm/phone-number-verification/index.js +2 -0
- package/lib/esm/project-management/index.js +1 -0
- package/lib/esm/remote-config/index.js +2 -0
- package/lib/esm/security-rules/index.js +2 -0
- package/lib/esm/storage/index.js +2 -0
- package/lib/eventarc/cloudevent.d.ts +1 -1
- package/lib/eventarc/cloudevent.js +1 -1
- package/lib/eventarc/error.d.ts +38 -0
- package/lib/eventarc/error.js +47 -0
- package/lib/eventarc/eventarc-client-internal.d.ts +1 -1
- package/lib/eventarc/eventarc-client-internal.js +24 -9
- package/lib/eventarc/eventarc-utils.d.ts +1 -13
- package/lib/eventarc/eventarc-utils.js +34 -24
- package/lib/eventarc/eventarc.d.ts +1 -1
- package/lib/eventarc/eventarc.js +18 -6
- package/lib/eventarc/index.d.ts +2 -1
- package/lib/eventarc/index.js +5 -2
- package/lib/extensions/error.d.ts +41 -0
- package/lib/extensions/error.js +50 -0
- package/lib/extensions/extensions-api-client-internal.d.ts +1 -13
- package/lib/extensions/extensions-api-client-internal.js +40 -28
- 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 +18 -5
- package/lib/extensions/index.d.ts +2 -1
- package/lib/extensions/index.js +5 -2
- package/lib/firestore/error.d.ts +41 -0
- package/lib/firestore/error.js +51 -0
- package/lib/firestore/firestore-internal.d.ts +2 -1
- package/lib/firestore/firestore-internal.js +6 -6
- package/lib/firestore/index.d.ts +2 -2
- package/lib/firestore/index.js +7 -7
- package/lib/functions/error.d.ts +48 -0
- package/lib/functions/error.js +67 -0
- package/lib/functions/functions-api-client-internal.d.ts +1 -16
- package/lib/functions/functions-api-client-internal.js +111 -71
- 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 +14 -4
- package/lib/functions/index.d.ts +2 -1
- package/lib/functions/index.js +5 -2
- package/lib/index.d.ts +13 -8
- package/lib/index.js +19 -3
- package/lib/installations/error.d.ts +48 -0
- package/lib/installations/error.js +73 -0
- package/lib/installations/index.d.ts +2 -2
- package/lib/installations/index.js +4 -4
- package/lib/installations/installations-request-handler.d.ts +1 -1
- package/lib/installations/installations-request-handler.js +11 -5
- package/lib/installations/installations.d.ts +1 -1
- package/lib/installations/installations.js +3 -3
- package/lib/machine-learning/error.d.ts +53 -0
- package/lib/machine-learning/error.js +84 -0
- package/lib/machine-learning/index.d.ts +2 -1
- package/lib/machine-learning/index.js +5 -2
- package/lib/machine-learning/machine-learning-api-client.d.ts +1 -1
- package/lib/machine-learning/machine-learning-api-client.js +61 -24
- package/lib/machine-learning/machine-learning.d.ts +1 -1
- package/lib/machine-learning/machine-learning.js +21 -9
- package/lib/messaging/error.d.ts +63 -0
- package/lib/messaging/error.js +286 -0
- package/lib/messaging/index.d.ts +3 -3
- package/lib/messaging/index.js +4 -4
- 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 +1 -280
- package/lib/messaging/messaging-api.js +1 -1
- package/lib/messaging/messaging-errors-internal.d.ts +2 -2
- package/lib/messaging/messaging-errors-internal.js +11 -8
- package/lib/messaging/messaging-internal.d.ts +1 -1
- package/lib/messaging/messaging-internal.js +48 -48
- package/lib/messaging/messaging.d.ts +1 -1
- package/lib/messaging/messaging.js +47 -50
- package/lib/phone-number-verification/error.d.ts +43 -0
- package/lib/phone-number-verification/error.js +48 -0
- package/lib/phone-number-verification/index.d.ts +2 -1
- package/lib/phone-number-verification/index.js +5 -2
- package/lib/phone-number-verification/phone-number-verification-api-client-internal.d.ts +1 -18
- package/lib/phone-number-verification/phone-number-verification-api-client-internal.js +2 -26
- package/lib/phone-number-verification/phone-number-verification-api.d.ts +2 -2
- package/lib/phone-number-verification/phone-number-verification-api.js +5 -4
- package/lib/phone-number-verification/phone-number-verification.d.ts +1 -1
- package/lib/phone-number-verification/phone-number-verification.js +1 -1
- package/lib/phone-number-verification/token-verifier.d.ts +1 -1
- package/lib/phone-number-verification/token-verifier.js +68 -20
- package/lib/project-management/android-app.d.ts +1 -1
- package/lib/project-management/android-app.js +15 -6
- package/lib/project-management/app-metadata.d.ts +1 -1
- package/lib/project-management/app-metadata.js +1 -1
- package/lib/project-management/error.d.ts +45 -0
- package/lib/project-management/error.js +55 -0
- package/lib/project-management/index.d.ts +2 -2
- package/lib/project-management/index.js +4 -3
- package/lib/project-management/ios-app.d.ts +1 -1
- package/lib/project-management/ios-app.js +6 -3
- package/lib/project-management/project-management-api-request-internal.d.ts +1 -1
- package/lib/project-management/project-management-api-request-internal.js +18 -6
- package/lib/project-management/project-management.d.ts +1 -1
- package/lib/project-management/project-management.js +13 -7
- package/lib/remote-config/condition-evaluator-internal.d.ts +1 -1
- package/lib/remote-config/condition-evaluator-internal.js +2 -2
- package/lib/remote-config/error.d.ts +49 -0
- package/lib/remote-config/error.js +70 -0
- package/lib/remote-config/index.d.ts +2 -1
- package/lib/remote-config/index.js +5 -2
- 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 +2 -13
- package/lib/remote-config/remote-config-api-client-internal.js +80 -52
- 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.d.ts +1 -1
- package/lib/remote-config/remote-config.js +92 -23
- package/lib/security-rules/error.d.ts +45 -0
- package/lib/security-rules/error.js +54 -0
- package/lib/security-rules/index.d.ts +2 -1
- package/lib/security-rules/index.js +5 -2
- package/lib/security-rules/security-rules-api-client-internal.d.ts +1 -1
- package/lib/security-rules/security-rules-api-client-internal.js +50 -18
- package/lib/security-rules/security-rules.d.ts +1 -1
- package/lib/security-rules/security-rules.js +32 -11
- package/lib/storage/error.d.ts +41 -0
- package/lib/storage/error.js +50 -0
- package/lib/storage/index.d.ts +2 -1
- package/lib/storage/index.js +8 -5
- package/lib/storage/storage.d.ts +1 -1
- package/lib/storage/storage.js +12 -12
- package/lib/storage/utils.d.ts +1 -1
- package/lib/storage/utils.js +1 -1
- package/lib/utils/api-request.d.ts +12 -12
- package/lib/utils/api-request.js +97 -55
- package/lib/utils/crypto-signer.d.ts +1 -1
- package/lib/utils/crypto-signer.js +2 -7
- package/lib/utils/deep-copy.d.ts +1 -1
- package/lib/utils/deep-copy.js +1 -1
- package/lib/utils/error.d.ts +75 -570
- package/lib/utils/error.js +53 -1047
- package/lib/utils/index.d.ts +1 -1
- package/lib/utils/index.js +2 -2
- package/lib/utils/jwt.d.ts +1 -1
- package/lib/utils/jwt.js +1 -2
- package/lib/utils/validator.d.ts +1 -1
- package/lib/utils/validator.js +1 -1
- package/package.json +24 -29
- package/lib/app/firebase-namespace.d.ts +0 -163
- package/lib/app/firebase-namespace.js +0 -335
- package/lib/app-check/app-check-namespace.d.ts +0 -72
- package/lib/app-check/app-check-namespace.js +0 -18
- package/lib/auth/auth-namespace.d.ts +0 -257
- package/lib/auth/auth-namespace.js +0 -18
- package/lib/database/database-namespace.d.ts +0 -95
- package/lib/database/database-namespace.js +0 -23
- package/lib/default-namespace.d.ts +0 -24
- package/lib/default-namespace.js +0 -30
- package/lib/esm/instance-id/index.js +0 -6
- package/lib/firebase-namespace-api.d.ts +0 -91
- package/lib/firebase-namespace-api.js +0 -58
- package/lib/firestore/firestore-namespace.d.ts +0 -71
- package/lib/firestore/firestore-namespace.js +0 -52
- package/lib/installations/installations-namespace.d.ts +0 -55
- package/lib/installations/installations-namespace.js +0 -18
- package/lib/instance-id/index.d.ts +0 -62
- package/lib/instance-id/index.js +0 -74
- package/lib/instance-id/instance-id-namespace.d.ts +0 -38
- package/lib/instance-id/instance-id-namespace.js +0 -3
- package/lib/instance-id/instance-id.d.ts +0 -47
- package/lib/instance-id/instance-id.js +0 -77
- package/lib/machine-learning/machine-learning-namespace.d.ts +0 -81
- package/lib/machine-learning/machine-learning-namespace.js +0 -18
- package/lib/machine-learning/machine-learning-utils.d.ts +0 -22
- package/lib/machine-learning/machine-learning-utils.js +0 -47
- package/lib/messaging/messaging-namespace.d.ts +0 -161
- package/lib/messaging/messaging-namespace.js +0 -18
- package/lib/project-management/project-management-namespace.d.ts +0 -82
- package/lib/project-management/project-management-namespace.js +0 -18
- package/lib/remote-config/remote-config-namespace.d.ts +0 -141
- package/lib/remote-config/remote-config-namespace.js +0 -18
- package/lib/security-rules/security-rules-internal.d.ts +0 -21
- package/lib/security-rules/security-rules-internal.js +0 -26
- package/lib/security-rules/security-rules-namespace.d.ts +0 -69
- package/lib/security-rules/security-rules-namespace.js +0 -18
- package/lib/storage/storage-namespace.d.ts +0 -45
- package/lib/storage/storage-namespace.js +0 -18
package/README.md
CHANGED
|
@@ -59,8 +59,7 @@ requests, code review feedback, and also pull requests.
|
|
|
59
59
|
|
|
60
60
|
## Supported Environments
|
|
61
61
|
|
|
62
|
-
We currently support Node.js
|
|
63
|
-
you to use Node.js 22 or higher as we will drop support for Node.js 18 and Node.js 20 in the next major version.
|
|
62
|
+
We currently support Node.js 22 and higher.
|
|
64
63
|
|
|
65
64
|
Please also note that the Admin SDK should only
|
|
66
65
|
be used in server-side/back-end environments controlled by the app developer.
|
package/lib/app/core.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! firebase-admin
|
|
1
|
+
/*! firebase-admin v14.0.0 */
|
|
2
2
|
/*!
|
|
3
3
|
* @license
|
|
4
4
|
* Copyright 2021 Google LLC
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
*/
|
|
18
18
|
import { Agent } from 'http';
|
|
19
19
|
import { Credential } from './credential';
|
|
20
|
+
import { FirebaseError } from '../utils/error';
|
|
20
21
|
/**
|
|
21
22
|
* Available options to pass to {@link firebase-admin.app#initializeApp}.
|
|
22
23
|
*/
|
|
@@ -113,43 +114,6 @@ export interface App {
|
|
|
113
114
|
*/
|
|
114
115
|
options: AppOptions;
|
|
115
116
|
}
|
|
116
|
-
/**
|
|
117
|
-
* `FirebaseError` is a subclass of the standard JavaScript `Error` object. In
|
|
118
|
-
* addition to a message string and stack trace, it contains a string code.
|
|
119
|
-
*/
|
|
120
|
-
export interface FirebaseError {
|
|
121
|
-
/**
|
|
122
|
-
* Error codes are strings using the following format: `"service/string-code"`.
|
|
123
|
-
* Some examples include `"auth/invalid-uid"` and
|
|
124
|
-
* `"messaging/invalid-recipient"`.
|
|
125
|
-
*
|
|
126
|
-
* While the message for a given error can change, the code will remain the same
|
|
127
|
-
* between backward-compatible versions of the Firebase SDK.
|
|
128
|
-
*/
|
|
129
|
-
code: string;
|
|
130
|
-
/**
|
|
131
|
-
* An explanatory message for the error that just occurred.
|
|
132
|
-
*
|
|
133
|
-
* This message is designed to be helpful to you, the developer. Because
|
|
134
|
-
* it generally does not convey meaningful information to end users,
|
|
135
|
-
* this message should not be displayed in your application.
|
|
136
|
-
*/
|
|
137
|
-
message: string;
|
|
138
|
-
/**
|
|
139
|
-
* A string value containing the execution backtrace when the error originally
|
|
140
|
-
* occurred.
|
|
141
|
-
*
|
|
142
|
-
* This information can be useful for troubleshooting the cause of the error with
|
|
143
|
-
* {@link https://firebase.google.com/support | Firebase Support}.
|
|
144
|
-
*/
|
|
145
|
-
stack?: string;
|
|
146
|
-
/**
|
|
147
|
-
* Returns a JSON-serializable object representation of this error.
|
|
148
|
-
*
|
|
149
|
-
* @returns A JSON-serializable representation of this object.
|
|
150
|
-
*/
|
|
151
|
-
toJSON(): object;
|
|
152
|
-
}
|
|
153
117
|
/**
|
|
154
118
|
* Composite type which includes both a `FirebaseError` object and an index
|
|
155
119
|
* which can be used to get the errored item.
|
package/lib/app/core.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! firebase-admin
|
|
1
|
+
/*! firebase-admin v14.0.0 */
|
|
2
2
|
"use strict";
|
|
3
3
|
/*!
|
|
4
4
|
* @license
|
|
@@ -23,7 +23,7 @@ exports.getApplicationDefault = getApplicationDefault;
|
|
|
23
23
|
const fs = require("fs");
|
|
24
24
|
const node_crypto_1 = require("node:crypto");
|
|
25
25
|
const google_auth_library_1 = require("google-auth-library");
|
|
26
|
-
const error_1 = require("
|
|
26
|
+
const error_1 = require("./error");
|
|
27
27
|
const util = require("../utils/validator");
|
|
28
28
|
const SCOPES = [
|
|
29
29
|
'https://www.googleapis.com/auth/cloud-platform',
|
|
@@ -83,7 +83,10 @@ class ApplicationDefaultCredential {
|
|
|
83
83
|
return this.authClient.fetchIdToken(audience);
|
|
84
84
|
}
|
|
85
85
|
else {
|
|
86
|
-
throw new error_1.FirebaseAppError(
|
|
86
|
+
throw new error_1.FirebaseAppError({
|
|
87
|
+
code: error_1.AppErrorCode.INVALID_CREDENTIAL,
|
|
88
|
+
message: 'Credentials type should be Compute Engine Credentials.'
|
|
89
|
+
});
|
|
87
90
|
}
|
|
88
91
|
}
|
|
89
92
|
async getServiceAccountEmail() {
|
|
@@ -151,12 +154,19 @@ class ServiceAccount {
|
|
|
151
154
|
}
|
|
152
155
|
catch (error) {
|
|
153
156
|
// Throw a nicely formed error message if the file contents cannot be parsed
|
|
154
|
-
throw new error_1.FirebaseAppError(
|
|
157
|
+
throw new error_1.FirebaseAppError({
|
|
158
|
+
code: error_1.AppErrorCode.INVALID_CREDENTIAL,
|
|
159
|
+
message: `Failed to parse service account json file: ${error.message}`,
|
|
160
|
+
cause: error,
|
|
161
|
+
});
|
|
155
162
|
}
|
|
156
163
|
}
|
|
157
164
|
constructor(json) {
|
|
158
165
|
if (!util.isNonNullObject(json)) {
|
|
159
|
-
throw new error_1.FirebaseAppError(
|
|
166
|
+
throw new error_1.FirebaseAppError({
|
|
167
|
+
code: error_1.AppErrorCode.INVALID_CREDENTIAL,
|
|
168
|
+
message: 'Service account must be an object.'
|
|
169
|
+
});
|
|
160
170
|
}
|
|
161
171
|
copyAttr(this, json, 'projectId', 'project_id');
|
|
162
172
|
copyAttr(this, json, 'privateKey', 'private_key');
|
|
@@ -172,14 +182,18 @@ class ServiceAccount {
|
|
|
172
182
|
errorMessage = 'Service account object must contain a string "client_email" property.';
|
|
173
183
|
}
|
|
174
184
|
if (typeof errorMessage !== 'undefined') {
|
|
175
|
-
throw new error_1.FirebaseAppError(error_1.
|
|
185
|
+
throw new error_1.FirebaseAppError({ code: error_1.AppErrorCode.INVALID_CREDENTIAL, message: errorMessage });
|
|
176
186
|
}
|
|
177
187
|
// Validate private key format using native crypto module
|
|
178
188
|
try {
|
|
179
189
|
(0, node_crypto_1.createPrivateKey)(this.privateKey);
|
|
180
190
|
}
|
|
181
191
|
catch (error) {
|
|
182
|
-
throw new error_1.FirebaseAppError(
|
|
192
|
+
throw new error_1.FirebaseAppError({
|
|
193
|
+
code: error_1.AppErrorCode.INVALID_CREDENTIAL,
|
|
194
|
+
message: 'Failed to parse private key.',
|
|
195
|
+
cause: error,
|
|
196
|
+
});
|
|
183
197
|
}
|
|
184
198
|
}
|
|
185
199
|
}
|
|
@@ -237,7 +251,11 @@ class RefreshToken {
|
|
|
237
251
|
}
|
|
238
252
|
catch (error) {
|
|
239
253
|
// Throw a nicely formed error message if the file contents cannot be parsed
|
|
240
|
-
throw new error_1.FirebaseAppError(
|
|
254
|
+
throw new error_1.FirebaseAppError({
|
|
255
|
+
code: error_1.AppErrorCode.INVALID_CREDENTIAL,
|
|
256
|
+
message: 'Failed to parse refresh token file.',
|
|
257
|
+
cause: error,
|
|
258
|
+
});
|
|
241
259
|
}
|
|
242
260
|
}
|
|
243
261
|
static validateFromJSON(json) {
|
|
@@ -260,7 +278,7 @@ class RefreshToken {
|
|
|
260
278
|
errorMessage = 'Refresh token must contain a "type" property.';
|
|
261
279
|
}
|
|
262
280
|
if (typeof errorMessage !== 'undefined') {
|
|
263
|
-
throw new error_1.FirebaseAppError(error_1.
|
|
281
|
+
throw new error_1.FirebaseAppError({ code: error_1.AppErrorCode.INVALID_CREDENTIAL, message: errorMessage });
|
|
264
282
|
}
|
|
265
283
|
}
|
|
266
284
|
}
|
|
@@ -321,7 +339,11 @@ class ImpersonatedServiceAccount {
|
|
|
321
339
|
}
|
|
322
340
|
catch (error) {
|
|
323
341
|
// Throw a nicely formed error message if the file contents cannot be parsed
|
|
324
|
-
throw new error_1.FirebaseAppError(
|
|
342
|
+
throw new error_1.FirebaseAppError({
|
|
343
|
+
code: error_1.AppErrorCode.INVALID_CREDENTIAL,
|
|
344
|
+
message: 'Failed to parse impersonated service account file.',
|
|
345
|
+
cause: error,
|
|
346
|
+
});
|
|
325
347
|
}
|
|
326
348
|
}
|
|
327
349
|
static validateFromJSON(json) {
|
|
@@ -340,7 +362,7 @@ class ImpersonatedServiceAccount {
|
|
|
340
362
|
errorMessage = 'Impersonated Service Account must contain a "source_credentials.type" property.';
|
|
341
363
|
}
|
|
342
364
|
if (typeof errorMessage !== 'undefined') {
|
|
343
|
-
throw new error_1.FirebaseAppError(error_1.
|
|
365
|
+
throw new error_1.FirebaseAppError({ code: error_1.AppErrorCode.INVALID_CREDENTIAL, message: errorMessage });
|
|
344
366
|
}
|
|
345
367
|
}
|
|
346
368
|
}
|
|
@@ -389,7 +411,10 @@ function populateGoogleAuth(keyFile, httpAgent) {
|
|
|
389
411
|
});
|
|
390
412
|
if (typeof keyFile === 'object') {
|
|
391
413
|
if (!util.isNonNullObject(keyFile)) {
|
|
392
|
-
throw new error_1.FirebaseAppError(
|
|
414
|
+
throw new error_1.FirebaseAppError({
|
|
415
|
+
code: error_1.AppErrorCode.INVALID_CREDENTIAL,
|
|
416
|
+
message: 'Service account must be an object.'
|
|
417
|
+
});
|
|
393
418
|
}
|
|
394
419
|
copyAttr(keyFile, keyFile, 'project_id', 'projectId');
|
|
395
420
|
copyAttr(keyFile, keyFile, 'private_key', 'privateKey');
|
|
@@ -405,9 +430,15 @@ function populateCredential(credentials) {
|
|
|
405
430
|
const accessToken = credentials?.access_token;
|
|
406
431
|
const expiryDate = credentials?.expiry_date;
|
|
407
432
|
if (typeof accessToken !== 'string')
|
|
408
|
-
throw new error_1.FirebaseAppError(
|
|
433
|
+
throw new error_1.FirebaseAppError({
|
|
434
|
+
code: error_1.AppErrorCode.INVALID_CREDENTIAL,
|
|
435
|
+
message: 'Failed to parse Google auth credential: access_token must be a non empty string.'
|
|
436
|
+
});
|
|
409
437
|
if (typeof expiryDate !== 'number')
|
|
410
|
-
throw new error_1.FirebaseAppError(
|
|
438
|
+
throw new error_1.FirebaseAppError({
|
|
439
|
+
code: error_1.AppErrorCode.INVALID_CREDENTIAL,
|
|
440
|
+
message: 'Failed to parse Google auth credential: Invalid expiry_date.'
|
|
441
|
+
});
|
|
411
442
|
return {
|
|
412
443
|
...credentials,
|
|
413
444
|
access_token: accessToken,
|
package/lib/app/credential.d.ts
CHANGED
package/lib/app/credential.js
CHANGED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/*! firebase-admin v14.0.0 */
|
|
2
|
+
/*!
|
|
3
|
+
* Copyright 2026 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
|
+
import { ErrorInfo, FirebaseError } from '../utils/error';
|
|
18
|
+
/**
|
|
19
|
+
* Firebase App error code structure. This extends `FirebaseError`.
|
|
20
|
+
*/
|
|
21
|
+
export declare class FirebaseAppError extends FirebaseError {
|
|
22
|
+
/**
|
|
23
|
+
* @param info - The error code info.
|
|
24
|
+
* @param message - The error message. This will override the default message if provided.
|
|
25
|
+
*/
|
|
26
|
+
constructor(info: ErrorInfo, message?: string);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* The constant mapping for valid App client error codes.
|
|
30
|
+
*/
|
|
31
|
+
export declare const AppErrorCode: {
|
|
32
|
+
readonly APP_DELETED: "app-deleted";
|
|
33
|
+
readonly DUPLICATE_APP: "duplicate-app";
|
|
34
|
+
readonly INVALID_ARGUMENT: "invalid-argument";
|
|
35
|
+
readonly INTERNAL_ERROR: "internal-error";
|
|
36
|
+
readonly INVALID_APP_NAME: "invalid-app-name";
|
|
37
|
+
readonly INVALID_APP_OPTIONS: "invalid-app-options";
|
|
38
|
+
readonly INVALID_CREDENTIAL: "invalid-credential";
|
|
39
|
+
readonly NETWORK_ERROR: "network-error";
|
|
40
|
+
readonly NETWORK_TIMEOUT: "network-timeout";
|
|
41
|
+
readonly NO_APP: "no-app";
|
|
42
|
+
readonly UNABLE_TO_PARSE_RESPONSE: "unable-to-parse-response";
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* The type definition for valid App client error codes.
|
|
46
|
+
*/
|
|
47
|
+
export type AppErrorCode = typeof AppErrorCode[keyof typeof AppErrorCode];
|
package/lib/app/error.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/*! firebase-admin v14.0.0 */
|
|
2
|
+
"use strict";
|
|
3
|
+
/*!
|
|
4
|
+
* Copyright 2026 Google LLC
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.AppErrorCode = exports.FirebaseAppError = void 0;
|
|
20
|
+
const error_1 = require("../utils/error");
|
|
21
|
+
/**
|
|
22
|
+
* Firebase App error code structure. This extends `FirebaseError`.
|
|
23
|
+
*/
|
|
24
|
+
class FirebaseAppError extends error_1.FirebaseError {
|
|
25
|
+
/**
|
|
26
|
+
* @param info - The error code info.
|
|
27
|
+
* @param message - The error message. This will override the default message if provided.
|
|
28
|
+
*/
|
|
29
|
+
constructor(info, message) {
|
|
30
|
+
// Override default message if custom message provided.
|
|
31
|
+
super({
|
|
32
|
+
code: `app/${info.code}`,
|
|
33
|
+
message: message || info.message,
|
|
34
|
+
httpResponse: info.httpResponse,
|
|
35
|
+
cause: info.cause,
|
|
36
|
+
});
|
|
37
|
+
/** @internal */
|
|
38
|
+
this.codePrefix = 'app';
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.FirebaseAppError = FirebaseAppError;
|
|
42
|
+
/**
|
|
43
|
+
* The constant mapping for valid App client error codes.
|
|
44
|
+
*/
|
|
45
|
+
exports.AppErrorCode = {
|
|
46
|
+
APP_DELETED: 'app-deleted',
|
|
47
|
+
DUPLICATE_APP: 'duplicate-app',
|
|
48
|
+
INVALID_ARGUMENT: 'invalid-argument',
|
|
49
|
+
INTERNAL_ERROR: 'internal-error',
|
|
50
|
+
INVALID_APP_NAME: 'invalid-app-name',
|
|
51
|
+
INVALID_APP_OPTIONS: 'invalid-app-options',
|
|
52
|
+
INVALID_CREDENTIAL: 'invalid-credential',
|
|
53
|
+
NETWORK_ERROR: 'network-error',
|
|
54
|
+
NETWORK_TIMEOUT: 'network-timeout',
|
|
55
|
+
NO_APP: 'no-app',
|
|
56
|
+
UNABLE_TO_PARSE_RESPONSE: 'unable-to-parse-response',
|
|
57
|
+
};
|
package/lib/app/firebase-app.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! firebase-admin
|
|
1
|
+
/*! firebase-admin v14.0.0 */
|
|
2
2
|
"use strict";
|
|
3
3
|
/*!
|
|
4
4
|
* @license
|
|
@@ -21,7 +21,7 @@ exports.FirebaseApp = exports.FirebaseAppInternals = void 0;
|
|
|
21
21
|
const credential_internal_1 = require("./credential-internal");
|
|
22
22
|
const validator = require("../utils/validator");
|
|
23
23
|
const deep_copy_1 = require("../utils/deep-copy");
|
|
24
|
-
const error_1 = require("
|
|
24
|
+
const error_1 = require("./error");
|
|
25
25
|
const TOKEN_EXPIRY_THRESHOLD_MILLIS = 5 * 60 * 1000;
|
|
26
26
|
/**
|
|
27
27
|
* Internals of a FirebaseApp instance.
|
|
@@ -51,9 +51,12 @@ class FirebaseAppInternals {
|
|
|
51
51
|
if (!validator.isNonNullObject(result) ||
|
|
52
52
|
typeof result.expires_in !== 'number' ||
|
|
53
53
|
typeof result.access_token !== 'string') {
|
|
54
|
-
throw new error_1.FirebaseAppError(
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
throw new error_1.FirebaseAppError({
|
|
55
|
+
code: error_1.AppErrorCode.INVALID_CREDENTIAL,
|
|
56
|
+
message: `Invalid access token generated: "${JSON.stringify(result)}". Valid access ` +
|
|
57
|
+
'tokens must be an object with the "expires_in" (number) and "access_token" ' +
|
|
58
|
+
'(string) properties.',
|
|
59
|
+
});
|
|
57
60
|
}
|
|
58
61
|
const token = {
|
|
59
62
|
accessToken: result.access_token,
|
|
@@ -84,7 +87,11 @@ class FirebaseAppInternals {
|
|
|
84
87
|
'not, generate a new key file at ' +
|
|
85
88
|
'https://console.firebase.google.com/project/_/settings/serviceaccounts/adminsdk.';
|
|
86
89
|
}
|
|
87
|
-
throw new error_1.FirebaseAppError(
|
|
90
|
+
throw new error_1.FirebaseAppError({
|
|
91
|
+
code: error_1.AppErrorCode.INVALID_CREDENTIAL,
|
|
92
|
+
message: errorMessage,
|
|
93
|
+
cause: error
|
|
94
|
+
});
|
|
88
95
|
})
|
|
89
96
|
.finally(() => {
|
|
90
97
|
this.isRefreshing = false;
|
|
@@ -131,8 +138,11 @@ class FirebaseApp {
|
|
|
131
138
|
this.options_ = (0, deep_copy_1.deepCopy)(options);
|
|
132
139
|
this.autoInit_ = autoInit;
|
|
133
140
|
if (!validator.isNonNullObject(this.options_)) {
|
|
134
|
-
throw new error_1.FirebaseAppError(
|
|
135
|
-
|
|
141
|
+
throw new error_1.FirebaseAppError({
|
|
142
|
+
code: error_1.AppErrorCode.INVALID_APP_OPTIONS,
|
|
143
|
+
message: 'Invalid Firebase app options passed as the first argument to initializeApp() for the ' +
|
|
144
|
+
`app named "${this.name_}". Options must be a non-null object.`
|
|
145
|
+
});
|
|
136
146
|
}
|
|
137
147
|
const hasCredential = ('credential' in this.options_);
|
|
138
148
|
if (!hasCredential) {
|
|
@@ -141,9 +151,12 @@ class FirebaseApp {
|
|
|
141
151
|
}
|
|
142
152
|
const credential = this.options_.credential;
|
|
143
153
|
if (typeof credential !== 'object' || credential === null || typeof credential.getAccessToken !== 'function') {
|
|
144
|
-
throw new error_1.FirebaseAppError(
|
|
145
|
-
|
|
146
|
-
'the
|
|
154
|
+
throw new error_1.FirebaseAppError({
|
|
155
|
+
code: error_1.AppErrorCode.INVALID_APP_OPTIONS,
|
|
156
|
+
message: 'Invalid Firebase app options passed as the first argument to initializeApp() for the ' +
|
|
157
|
+
`app named "${this.name_}". The "credential" property must be an object which implements ` +
|
|
158
|
+
'the Credential interface.'
|
|
159
|
+
});
|
|
147
160
|
}
|
|
148
161
|
this.INTERNAL = new FirebaseAppInternals(credential);
|
|
149
162
|
}
|
|
@@ -224,7 +237,10 @@ class FirebaseApp {
|
|
|
224
237
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
225
238
|
checkDestroyed_() {
|
|
226
239
|
if (this.isDeleted_) {
|
|
227
|
-
throw new error_1.FirebaseAppError(
|
|
240
|
+
throw new error_1.FirebaseAppError({
|
|
241
|
+
code: error_1.AppErrorCode.APP_DELETED,
|
|
242
|
+
message: `Firebase app named "${this.name_}" has already been deleted.`
|
|
243
|
+
});
|
|
228
244
|
}
|
|
229
245
|
}
|
|
230
246
|
}
|
package/lib/app/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! firebase-admin
|
|
1
|
+
/*! firebase-admin v14.0.0 */
|
|
2
2
|
/*!
|
|
3
3
|
* @license
|
|
4
4
|
* Copyright 2021 Google LLC
|
|
@@ -20,9 +20,10 @@
|
|
|
20
20
|
*
|
|
21
21
|
* @packageDocumentation
|
|
22
22
|
*/
|
|
23
|
-
export { App, AppOptions, FirebaseArrayIndexError
|
|
23
|
+
export { App, AppOptions, FirebaseArrayIndexError } from './core';
|
|
24
24
|
export { initializeApp, getApp, getApps, deleteApp } from './lifecycle';
|
|
25
25
|
export { Credential, ServiceAccount, GoogleOAuthAccessToken } from './credential';
|
|
26
26
|
export { applicationDefault, cert, refreshToken } from './credential-factory';
|
|
27
|
-
export {
|
|
27
|
+
export { FirebaseError, ErrorInfo, HttpResponse } from '../utils/error';
|
|
28
|
+
export { FirebaseAppError, AppErrorCode } from './error';
|
|
28
29
|
export declare const SDK_VERSION: string;
|
package/lib/app/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! firebase-admin
|
|
1
|
+
/*! firebase-admin v14.0.0 */
|
|
2
2
|
"use strict";
|
|
3
3
|
/*!
|
|
4
4
|
* @license
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
* limitations under the License.
|
|
18
18
|
*/
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.SDK_VERSION = exports.
|
|
20
|
+
exports.SDK_VERSION = exports.AppErrorCode = exports.FirebaseAppError = exports.FirebaseError = exports.refreshToken = exports.cert = exports.applicationDefault = exports.deleteApp = exports.getApps = exports.getApp = exports.initializeApp = void 0;
|
|
21
21
|
const utils_1 = require("../utils");
|
|
22
22
|
var lifecycle_1 = require("./lifecycle");
|
|
23
23
|
Object.defineProperty(exports, "initializeApp", { enumerable: true, get: function () { return lifecycle_1.initializeApp; } });
|
|
@@ -29,6 +29,8 @@ Object.defineProperty(exports, "applicationDefault", { enumerable: true, get: fu
|
|
|
29
29
|
Object.defineProperty(exports, "cert", { enumerable: true, get: function () { return credential_factory_1.cert; } });
|
|
30
30
|
Object.defineProperty(exports, "refreshToken", { enumerable: true, get: function () { return credential_factory_1.refreshToken; } });
|
|
31
31
|
var error_1 = require("../utils/error");
|
|
32
|
-
Object.defineProperty(exports, "
|
|
33
|
-
|
|
32
|
+
Object.defineProperty(exports, "FirebaseError", { enumerable: true, get: function () { return error_1.FirebaseError; } });
|
|
33
|
+
var error_2 = require("./error");
|
|
34
|
+
Object.defineProperty(exports, "FirebaseAppError", { enumerable: true, get: function () { return error_2.FirebaseAppError; } });
|
|
35
|
+
Object.defineProperty(exports, "AppErrorCode", { enumerable: true, get: function () { return error_2.AppErrorCode; } });
|
|
34
36
|
exports.SDK_VERSION = (0, utils_1.getSdkVersion)();
|
package/lib/app/lifecycle.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! firebase-admin
|
|
1
|
+
/*! firebase-admin v14.0.0 */
|
|
2
2
|
/*!
|
|
3
3
|
* @license
|
|
4
4
|
* Copyright 2021 Google LLC
|
|
@@ -74,7 +74,7 @@ export declare const defaultAppStore: AppStore;
|
|
|
74
74
|
export declare function initializeApp(options?: AppOptions, appName?: string): App;
|
|
75
75
|
/**
|
|
76
76
|
* Returns an existing {@link App} instance for the provided name. If no name
|
|
77
|
-
* is provided the
|
|
77
|
+
* is provided the default app name is used.
|
|
78
78
|
*
|
|
79
79
|
* @param appName - Optional name of the `App` instance.
|
|
80
80
|
*
|
package/lib/app/lifecycle.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! firebase-admin
|
|
1
|
+
/*! firebase-admin v14.0.0 */
|
|
2
2
|
"use strict";
|
|
3
3
|
/*!
|
|
4
4
|
* @license
|
|
@@ -24,7 +24,7 @@ exports.getApps = getApps;
|
|
|
24
24
|
exports.deleteApp = deleteApp;
|
|
25
25
|
const fs = require("fs");
|
|
26
26
|
const validator = require("../utils/validator");
|
|
27
|
-
const error_1 = require("
|
|
27
|
+
const error_1 = require("./error");
|
|
28
28
|
const credential_internal_1 = require("./credential-internal");
|
|
29
29
|
const firebase_app_1 = require("./firebase-app");
|
|
30
30
|
const fastDeepEqual = require('fast-deep-equal');
|
|
@@ -51,7 +51,10 @@ class AppStore {
|
|
|
51
51
|
const currentApp = this.appStore.get(appName);
|
|
52
52
|
// Ensure the `autoInit` state matches the existing app's. If not, throw.
|
|
53
53
|
if (currentApp.autoInit() !== autoInit) {
|
|
54
|
-
throw new error_1.FirebaseAppError(
|
|
54
|
+
throw new error_1.FirebaseAppError({
|
|
55
|
+
code: error_1.AppErrorCode.INVALID_APP_OPTIONS,
|
|
56
|
+
message: `A Firebase app named "${appName}" already exists with a different configuration.`
|
|
57
|
+
});
|
|
55
58
|
}
|
|
56
59
|
if (autoInit) {
|
|
57
60
|
// Auto-initialization is triggered when no options were passed to
|
|
@@ -66,7 +69,10 @@ class AppStore {
|
|
|
66
69
|
const currentAppOptions = { ...currentApp.options };
|
|
67
70
|
delete currentAppOptions.credential;
|
|
68
71
|
if (!fastDeepEqual(options, currentAppOptions)) {
|
|
69
|
-
throw new error_1.FirebaseAppError(
|
|
72
|
+
throw new error_1.FirebaseAppError({
|
|
73
|
+
code: error_1.AppErrorCode.DUPLICATE_APP,
|
|
74
|
+
message: `A Firebase app named "${appName}" already exists with a different configuration.`
|
|
75
|
+
});
|
|
70
76
|
}
|
|
71
77
|
return currentApp;
|
|
72
78
|
}
|
|
@@ -76,7 +82,7 @@ class AppStore {
|
|
|
76
82
|
let errorMessage = (appName === DEFAULT_APP_NAME)
|
|
77
83
|
? 'The default Firebase app does not exist. ' : `Firebase app named "${appName}" does not exist. `;
|
|
78
84
|
errorMessage += 'Make sure you call initializeApp() before using any of the Firebase services.';
|
|
79
|
-
throw new error_1.FirebaseAppError(error_1.
|
|
85
|
+
throw new error_1.FirebaseAppError({ code: error_1.AppErrorCode.NO_APP, message: errorMessage });
|
|
80
86
|
}
|
|
81
87
|
return this.appStore.get(appName);
|
|
82
88
|
}
|
|
@@ -86,7 +92,7 @@ class AppStore {
|
|
|
86
92
|
}
|
|
87
93
|
deleteApp(app) {
|
|
88
94
|
if (typeof app !== 'object' || app === null || !('options' in app)) {
|
|
89
|
-
throw new error_1.FirebaseAppError(error_1.
|
|
95
|
+
throw new error_1.FirebaseAppError({ code: error_1.AppErrorCode.INVALID_ARGUMENT, message: 'Invalid app argument.' });
|
|
90
96
|
}
|
|
91
97
|
// Make sure the given app already exists.
|
|
92
98
|
const existingApp = getApp(app.name);
|
|
@@ -127,25 +133,37 @@ exports.AppStore = AppStore;
|
|
|
127
133
|
function validateAppOptionsSupportDeepEquals(requestedOptions, existingApp) {
|
|
128
134
|
// http.Agent checks.
|
|
129
135
|
if (typeof requestedOptions.httpAgent !== 'undefined') {
|
|
130
|
-
throw new error_1.FirebaseAppError(
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
136
|
+
throw new error_1.FirebaseAppError({
|
|
137
|
+
code: error_1.AppErrorCode.INVALID_APP_OPTIONS,
|
|
138
|
+
message: `Firebase app named "${existingApp.name}" already exists and initializeApp was` +
|
|
139
|
+
' invoked with an optional http.Agent. The SDK cannot confirm the equality' +
|
|
140
|
+
' of http.Agent objects with the existing app. Please use getApp or getApps to reuse' +
|
|
141
|
+
' the existing app instead.'
|
|
142
|
+
});
|
|
134
143
|
}
|
|
135
144
|
else if (typeof existingApp.options.httpAgent !== 'undefined') {
|
|
136
|
-
throw new error_1.FirebaseAppError(
|
|
137
|
-
|
|
145
|
+
throw new error_1.FirebaseAppError({
|
|
146
|
+
code: error_1.AppErrorCode.INVALID_APP_OPTIONS,
|
|
147
|
+
message: `An existing app named "${existingApp.name}" already exists with a different` +
|
|
148
|
+
' options configuration: httpAgent.'
|
|
149
|
+
});
|
|
138
150
|
}
|
|
139
151
|
// Credential checks.
|
|
140
152
|
if (typeof requestedOptions.credential !== 'undefined') {
|
|
141
|
-
throw new error_1.FirebaseAppError(
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
153
|
+
throw new error_1.FirebaseAppError({
|
|
154
|
+
code: error_1.AppErrorCode.INVALID_APP_OPTIONS,
|
|
155
|
+
message: `Firebase app named "${existingApp.name}" already exists and initializeApp was` +
|
|
156
|
+
' invoked with an optional Credential. The SDK cannot confirm the equality' +
|
|
157
|
+
' of Credential objects with the existing app. Please use getApp or getApps' +
|
|
158
|
+
' to reuse the existing app instead.'
|
|
159
|
+
});
|
|
145
160
|
}
|
|
146
161
|
if (existingApp.customCredential()) {
|
|
147
|
-
throw new error_1.FirebaseAppError(
|
|
148
|
-
|
|
162
|
+
throw new error_1.FirebaseAppError({
|
|
163
|
+
code: error_1.AppErrorCode.INVALID_APP_OPTIONS,
|
|
164
|
+
message: `An existing app named "${existingApp.name}" already exists with a different` +
|
|
165
|
+
' options configuration: Credential.'
|
|
166
|
+
});
|
|
149
167
|
}
|
|
150
168
|
}
|
|
151
169
|
/**
|
|
@@ -160,7 +178,10 @@ function validateAppOptionsSupportDeepEquals(requestedOptions, existingApp) {
|
|
|
160
178
|
*/
|
|
161
179
|
function validateAppNameFormat(appName) {
|
|
162
180
|
if (!validator.isNonEmptyString(appName)) {
|
|
163
|
-
throw new error_1.FirebaseAppError(
|
|
181
|
+
throw new error_1.FirebaseAppError({
|
|
182
|
+
code: error_1.AppErrorCode.INVALID_APP_NAME,
|
|
183
|
+
message: `Invalid Firebase app name "${appName}" provided. App name must be a non-empty string.`
|
|
184
|
+
});
|
|
164
185
|
}
|
|
165
186
|
}
|
|
166
187
|
exports.defaultAppStore = new AppStore();
|
|
@@ -209,7 +230,7 @@ function initializeApp(options, appName = DEFAULT_APP_NAME) {
|
|
|
209
230
|
}
|
|
210
231
|
/**
|
|
211
232
|
* Returns an existing {@link App} instance for the provided name. If no name
|
|
212
|
-
* is provided the
|
|
233
|
+
* is provided the default app name is used.
|
|
213
234
|
*
|
|
214
235
|
* @param appName - Optional name of the `App` instance.
|
|
215
236
|
*
|
|
@@ -272,6 +293,10 @@ function loadOptionsFromEnvVar() {
|
|
|
272
293
|
}
|
|
273
294
|
catch (error) {
|
|
274
295
|
// Throw a nicely formed error message if the file contents cannot be parsed
|
|
275
|
-
throw new error_1.FirebaseAppError(
|
|
296
|
+
throw new error_1.FirebaseAppError({
|
|
297
|
+
code: error_1.AppErrorCode.INVALID_APP_OPTIONS,
|
|
298
|
+
message: `Failed to parse app options file: ${error.message}`,
|
|
299
|
+
cause: error
|
|
300
|
+
});
|
|
276
301
|
}
|
|
277
302
|
}
|