firebase-admin 13.9.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.
Files changed (281) hide show
  1. package/README.md +1 -2
  2. package/lib/app/core.d.ts +2 -38
  3. package/lib/app/core.js +1 -1
  4. package/lib/app/credential-factory.d.ts +1 -1
  5. package/lib/app/credential-factory.js +1 -1
  6. package/lib/app/credential-internal.d.ts +1 -1
  7. package/lib/app/credential-internal.js +48 -17
  8. package/lib/app/credential.d.ts +1 -1
  9. package/lib/app/credential.js +1 -1
  10. package/lib/app/error.d.ts +47 -0
  11. package/lib/app/error.js +57 -0
  12. package/lib/app/firebase-app.d.ts +1 -1
  13. package/lib/app/firebase-app.js +28 -12
  14. package/lib/app/index.d.ts +4 -3
  15. package/lib/app/index.js +6 -4
  16. package/lib/app/lifecycle.d.ts +2 -2
  17. package/lib/app/lifecycle.js +46 -21
  18. package/lib/app-check/app-check-api-client-internal.d.ts +2 -16
  19. package/lib/app-check/app-check-api-client-internal.js +71 -47
  20. package/lib/app-check/app-check-api.d.ts +19 -1
  21. package/lib/app-check/app-check-api.js +1 -1
  22. package/lib/app-check/app-check.d.ts +1 -1
  23. package/lib/app-check/app-check.js +7 -3
  24. package/lib/app-check/error.d.ts +47 -0
  25. package/lib/app-check/error.js +65 -0
  26. package/lib/app-check/index.d.ts +2 -1
  27. package/lib/app-check/index.js +5 -2
  28. package/lib/app-check/token-generator.d.ts +1 -1
  29. package/lib/app-check/token-generator.js +43 -13
  30. package/lib/app-check/token-verifier.d.ts +1 -1
  31. package/lib/app-check/token-verifier.js +39 -11
  32. package/lib/auth/action-code-settings-builder.d.ts +1 -1
  33. package/lib/auth/action-code-settings-builder.js +16 -16
  34. package/lib/auth/auth-api-request.d.ts +6 -4
  35. package/lib/auth/auth-api-request.js +277 -166
  36. package/lib/auth/auth-config.d.ts +31 -2
  37. package/lib/auth/auth-config.js +103 -103
  38. package/lib/auth/auth.d.ts +1 -1
  39. package/lib/auth/auth.js +1 -1
  40. package/lib/auth/base-auth.d.ts +2 -1
  41. package/lib/auth/base-auth.js +29 -27
  42. package/lib/auth/error.d.ts +137 -0
  43. package/lib/auth/error.js +690 -0
  44. package/lib/auth/identifier.d.ts +1 -1
  45. package/lib/auth/identifier.js +1 -1
  46. package/lib/auth/index.d.ts +2 -2
  47. package/lib/auth/index.js +4 -4
  48. package/lib/auth/project-config-manager.d.ts +1 -1
  49. package/lib/auth/project-config-manager.js +1 -1
  50. package/lib/auth/project-config.d.ts +1 -1
  51. package/lib/auth/project-config.js +4 -4
  52. package/lib/auth/tenant-manager.d.ts +2 -1
  53. package/lib/auth/tenant-manager.js +13 -10
  54. package/lib/auth/tenant.d.ts +1 -1
  55. package/lib/auth/tenant.js +7 -7
  56. package/lib/auth/token-generator.d.ts +1 -1
  57. package/lib/auth/token-generator.js +13 -13
  58. package/lib/auth/token-verifier.d.ts +1 -1
  59. package/lib/auth/token-verifier.js +22 -22
  60. package/lib/auth/user-import-builder.d.ts +1 -1
  61. package/lib/auth/user-import-builder.js +22 -22
  62. package/lib/auth/user-record.d.ts +1 -1
  63. package/lib/auth/user-record.js +6 -6
  64. package/lib/credential/index.d.ts +1 -1
  65. package/lib/credential/index.js +1 -1
  66. package/lib/data-connect/data-connect-api-client-internal.d.ts +1 -16
  67. package/lib/data-connect/data-connect-api-client-internal.js +122 -65
  68. package/lib/data-connect/data-connect-api.d.ts +1 -1
  69. package/lib/data-connect/data-connect-api.js +1 -1
  70. package/lib/data-connect/data-connect.d.ts +1 -1
  71. package/lib/data-connect/data-connect.js +1 -1
  72. package/lib/data-connect/error.d.ts +47 -0
  73. package/lib/data-connect/error.js +66 -0
  74. package/lib/data-connect/index.d.ts +2 -1
  75. package/lib/data-connect/index.js +5 -2
  76. package/lib/data-connect/validate-admin-args.d.ts +1 -1
  77. package/lib/data-connect/validate-admin-args.js +6 -3
  78. package/lib/database/database.d.ts +1 -1
  79. package/lib/database/database.js +11 -6
  80. package/lib/database/error.d.ts +39 -0
  81. package/lib/database/error.js +49 -0
  82. package/lib/database/index.d.ts +2 -2
  83. package/lib/database/index.js +4 -3
  84. package/lib/esm/app/index.js +2 -1
  85. package/lib/esm/app-check/index.js +2 -0
  86. package/lib/esm/auth/index.js +1 -1
  87. package/lib/esm/data-connect/index.js +2 -0
  88. package/lib/esm/database/index.js +1 -0
  89. package/lib/esm/eventarc/index.js +2 -0
  90. package/lib/esm/extensions/index.js +2 -0
  91. package/lib/esm/firebase-admin/index.js +13 -0
  92. package/lib/esm/firestore/index.js +1 -0
  93. package/lib/esm/functions/index.js +2 -0
  94. package/lib/esm/installations/index.js +1 -1
  95. package/lib/esm/machine-learning/index.js +2 -0
  96. package/lib/esm/messaging/index.js +1 -1
  97. package/lib/esm/phone-number-verification/index.js +2 -0
  98. package/lib/esm/project-management/index.js +1 -0
  99. package/lib/esm/remote-config/index.js +2 -0
  100. package/lib/esm/security-rules/index.js +2 -0
  101. package/lib/esm/storage/index.js +2 -0
  102. package/lib/eventarc/cloudevent.d.ts +1 -1
  103. package/lib/eventarc/cloudevent.js +1 -1
  104. package/lib/eventarc/error.d.ts +38 -0
  105. package/lib/eventarc/error.js +47 -0
  106. package/lib/eventarc/eventarc-client-internal.d.ts +1 -1
  107. package/lib/eventarc/eventarc-client-internal.js +24 -9
  108. package/lib/eventarc/eventarc-utils.d.ts +1 -13
  109. package/lib/eventarc/eventarc-utils.js +36 -26
  110. package/lib/eventarc/eventarc.d.ts +1 -1
  111. package/lib/eventarc/eventarc.js +18 -6
  112. package/lib/eventarc/index.d.ts +2 -1
  113. package/lib/eventarc/index.js +5 -2
  114. package/lib/extensions/error.d.ts +41 -0
  115. package/lib/extensions/error.js +50 -0
  116. package/lib/extensions/extensions-api-client-internal.d.ts +1 -13
  117. package/lib/extensions/extensions-api-client-internal.js +40 -28
  118. package/lib/extensions/extensions-api.d.ts +1 -1
  119. package/lib/extensions/extensions-api.js +1 -1
  120. package/lib/extensions/extensions.d.ts +1 -1
  121. package/lib/extensions/extensions.js +18 -5
  122. package/lib/extensions/index.d.ts +2 -1
  123. package/lib/extensions/index.js +5 -2
  124. package/lib/firestore/error.d.ts +41 -0
  125. package/lib/firestore/error.js +51 -0
  126. package/lib/firestore/firestore-internal.d.ts +2 -1
  127. package/lib/firestore/firestore-internal.js +6 -6
  128. package/lib/firestore/index.d.ts +2 -2
  129. package/lib/firestore/index.js +7 -7
  130. package/lib/functions/error.d.ts +48 -0
  131. package/lib/functions/error.js +67 -0
  132. package/lib/functions/functions-api-client-internal.d.ts +1 -16
  133. package/lib/functions/functions-api-client-internal.js +111 -71
  134. package/lib/functions/functions-api.d.ts +1 -1
  135. package/lib/functions/functions-api.js +1 -1
  136. package/lib/functions/functions.d.ts +1 -1
  137. package/lib/functions/functions.js +14 -4
  138. package/lib/functions/index.d.ts +2 -1
  139. package/lib/functions/index.js +5 -2
  140. package/lib/index.d.ts +13 -8
  141. package/lib/index.js +19 -3
  142. package/lib/installations/error.d.ts +48 -0
  143. package/lib/installations/error.js +73 -0
  144. package/lib/installations/index.d.ts +2 -2
  145. package/lib/installations/index.js +4 -4
  146. package/lib/installations/installations-request-handler.d.ts +1 -1
  147. package/lib/installations/installations-request-handler.js +11 -5
  148. package/lib/installations/installations.d.ts +1 -1
  149. package/lib/installations/installations.js +3 -3
  150. package/lib/machine-learning/error.d.ts +53 -0
  151. package/lib/machine-learning/error.js +84 -0
  152. package/lib/machine-learning/index.d.ts +2 -1
  153. package/lib/machine-learning/index.js +5 -2
  154. package/lib/machine-learning/machine-learning-api-client.d.ts +1 -1
  155. package/lib/machine-learning/machine-learning-api-client.js +61 -24
  156. package/lib/machine-learning/machine-learning.d.ts +1 -1
  157. package/lib/machine-learning/machine-learning.js +21 -9
  158. package/lib/messaging/error.d.ts +63 -0
  159. package/lib/messaging/error.js +286 -0
  160. package/lib/messaging/index.d.ts +3 -3
  161. package/lib/messaging/index.js +4 -4
  162. package/lib/messaging/messaging-api-request-internal.d.ts +1 -1
  163. package/lib/messaging/messaging-api-request-internal.js +1 -1
  164. package/lib/messaging/messaging-api.d.ts +1 -280
  165. package/lib/messaging/messaging-api.js +1 -1
  166. package/lib/messaging/messaging-errors-internal.d.ts +2 -2
  167. package/lib/messaging/messaging-errors-internal.js +11 -8
  168. package/lib/messaging/messaging-internal.d.ts +1 -1
  169. package/lib/messaging/messaging-internal.js +48 -48
  170. package/lib/messaging/messaging.d.ts +1 -1
  171. package/lib/messaging/messaging.js +47 -50
  172. package/lib/phone-number-verification/error.d.ts +43 -0
  173. package/lib/phone-number-verification/error.js +48 -0
  174. package/lib/phone-number-verification/index.d.ts +2 -1
  175. package/lib/phone-number-verification/index.js +5 -2
  176. package/lib/phone-number-verification/phone-number-verification-api-client-internal.d.ts +1 -18
  177. package/lib/phone-number-verification/phone-number-verification-api-client-internal.js +2 -26
  178. package/lib/phone-number-verification/phone-number-verification-api.d.ts +2 -2
  179. package/lib/phone-number-verification/phone-number-verification-api.js +5 -4
  180. package/lib/phone-number-verification/phone-number-verification.d.ts +1 -1
  181. package/lib/phone-number-verification/phone-number-verification.js +1 -1
  182. package/lib/phone-number-verification/token-verifier.d.ts +1 -1
  183. package/lib/phone-number-verification/token-verifier.js +68 -20
  184. package/lib/project-management/android-app.d.ts +1 -1
  185. package/lib/project-management/android-app.js +15 -6
  186. package/lib/project-management/app-metadata.d.ts +1 -1
  187. package/lib/project-management/app-metadata.js +1 -1
  188. package/lib/project-management/error.d.ts +45 -0
  189. package/lib/project-management/error.js +55 -0
  190. package/lib/project-management/index.d.ts +2 -2
  191. package/lib/project-management/index.js +4 -3
  192. package/lib/project-management/ios-app.d.ts +1 -1
  193. package/lib/project-management/ios-app.js +6 -3
  194. package/lib/project-management/project-management-api-request-internal.d.ts +1 -1
  195. package/lib/project-management/project-management-api-request-internal.js +18 -6
  196. package/lib/project-management/project-management.d.ts +1 -1
  197. package/lib/project-management/project-management.js +13 -7
  198. package/lib/remote-config/condition-evaluator-internal.d.ts +1 -1
  199. package/lib/remote-config/condition-evaluator-internal.js +4 -4
  200. package/lib/remote-config/error.d.ts +49 -0
  201. package/lib/remote-config/error.js +70 -0
  202. package/lib/remote-config/index.d.ts +2 -1
  203. package/lib/remote-config/index.js +5 -2
  204. package/lib/remote-config/internal/value-impl.d.ts +1 -1
  205. package/lib/remote-config/internal/value-impl.js +1 -1
  206. package/lib/remote-config/remote-config-api-client-internal.d.ts +2 -13
  207. package/lib/remote-config/remote-config-api-client-internal.js +80 -52
  208. package/lib/remote-config/remote-config-api.d.ts +1 -1
  209. package/lib/remote-config/remote-config-api.js +1 -1
  210. package/lib/remote-config/remote-config.d.ts +1 -1
  211. package/lib/remote-config/remote-config.js +92 -23
  212. package/lib/security-rules/error.d.ts +45 -0
  213. package/lib/security-rules/error.js +54 -0
  214. package/lib/security-rules/index.d.ts +2 -1
  215. package/lib/security-rules/index.js +5 -2
  216. package/lib/security-rules/security-rules-api-client-internal.d.ts +1 -1
  217. package/lib/security-rules/security-rules-api-client-internal.js +50 -18
  218. package/lib/security-rules/security-rules.d.ts +1 -1
  219. package/lib/security-rules/security-rules.js +32 -11
  220. package/lib/storage/error.d.ts +41 -0
  221. package/lib/storage/error.js +50 -0
  222. package/lib/storage/index.d.ts +2 -1
  223. package/lib/storage/index.js +8 -5
  224. package/lib/storage/storage.d.ts +1 -1
  225. package/lib/storage/storage.js +12 -12
  226. package/lib/storage/utils.d.ts +1 -1
  227. package/lib/storage/utils.js +1 -1
  228. package/lib/utils/api-request.d.ts +12 -12
  229. package/lib/utils/api-request.js +97 -55
  230. package/lib/utils/crypto-signer.d.ts +1 -1
  231. package/lib/utils/crypto-signer.js +2 -7
  232. package/lib/utils/deep-copy.d.ts +1 -1
  233. package/lib/utils/deep-copy.js +1 -1
  234. package/lib/utils/error.d.ts +75 -570
  235. package/lib/utils/error.js +53 -1047
  236. package/lib/utils/index.d.ts +1 -1
  237. package/lib/utils/index.js +2 -2
  238. package/lib/utils/jwt.d.ts +1 -1
  239. package/lib/utils/jwt.js +1 -2
  240. package/lib/utils/validator.d.ts +1 -1
  241. package/lib/utils/validator.js +1 -1
  242. package/package.json +25 -33
  243. package/lib/app/firebase-namespace.d.ts +0 -163
  244. package/lib/app/firebase-namespace.js +0 -335
  245. package/lib/app-check/app-check-namespace.d.ts +0 -72
  246. package/lib/app-check/app-check-namespace.js +0 -18
  247. package/lib/auth/auth-namespace.d.ts +0 -257
  248. package/lib/auth/auth-namespace.js +0 -18
  249. package/lib/database/database-namespace.d.ts +0 -95
  250. package/lib/database/database-namespace.js +0 -23
  251. package/lib/default-namespace.d.ts +0 -24
  252. package/lib/default-namespace.js +0 -30
  253. package/lib/esm/instance-id/index.js +0 -6
  254. package/lib/firebase-namespace-api.d.ts +0 -91
  255. package/lib/firebase-namespace-api.js +0 -58
  256. package/lib/firestore/firestore-namespace.d.ts +0 -71
  257. package/lib/firestore/firestore-namespace.js +0 -52
  258. package/lib/installations/installations-namespace.d.ts +0 -55
  259. package/lib/installations/installations-namespace.js +0 -18
  260. package/lib/instance-id/index.d.ts +0 -62
  261. package/lib/instance-id/index.js +0 -74
  262. package/lib/instance-id/instance-id-namespace.d.ts +0 -38
  263. package/lib/instance-id/instance-id-namespace.js +0 -3
  264. package/lib/instance-id/instance-id.d.ts +0 -47
  265. package/lib/instance-id/instance-id.js +0 -77
  266. package/lib/machine-learning/machine-learning-namespace.d.ts +0 -81
  267. package/lib/machine-learning/machine-learning-namespace.js +0 -18
  268. package/lib/machine-learning/machine-learning-utils.d.ts +0 -22
  269. package/lib/machine-learning/machine-learning-utils.js +0 -47
  270. package/lib/messaging/messaging-namespace.d.ts +0 -161
  271. package/lib/messaging/messaging-namespace.js +0 -18
  272. package/lib/project-management/project-management-namespace.d.ts +0 -82
  273. package/lib/project-management/project-management-namespace.js +0 -18
  274. package/lib/remote-config/remote-config-namespace.d.ts +0 -141
  275. package/lib/remote-config/remote-config-namespace.js +0 -18
  276. package/lib/security-rules/security-rules-internal.d.ts +0 -21
  277. package/lib/security-rules/security-rules-internal.js +0 -26
  278. package/lib/security-rules/security-rules-namespace.d.ts +0 -69
  279. package/lib/security-rules/security-rules-namespace.js +0 -18
  280. package/lib/storage/storage-namespace.d.ts +0 -45
  281. 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 18 and higher, but support for Node.js 18 and Node.js 20 is deprecated. We strongly encourage
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 v13.9.0 */
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 v13.9.0 */
1
+ /*! firebase-admin v14.0.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * @license
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v13.9.0 */
1
+ /*! firebase-admin v14.0.0 */
2
2
  /*!
3
3
  * @license
4
4
  * Copyright 2021 Google LLC
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v13.9.0 */
1
+ /*! firebase-admin v14.0.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * @license
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v13.9.0 */
1
+ /*! firebase-admin v14.0.0 */
2
2
  /*!
3
3
  * @license
4
4
  * Copyright 2020 Google LLC
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v13.9.0 */
1
+ /*! firebase-admin v14.0.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * @license
@@ -21,8 +21,9 @@ exports.ImpersonatedServiceAccountCredential = exports.RefreshTokenCredential =
21
21
  exports.isApplicationDefault = isApplicationDefault;
22
22
  exports.getApplicationDefault = getApplicationDefault;
23
23
  const fs = require("fs");
24
+ const node_crypto_1 = require("node:crypto");
24
25
  const google_auth_library_1 = require("google-auth-library");
25
- const error_1 = require("../utils/error");
26
+ const error_1 = require("./error");
26
27
  const util = require("../utils/validator");
27
28
  const SCOPES = [
28
29
  'https://www.googleapis.com/auth/cloud-platform',
@@ -82,7 +83,10 @@ class ApplicationDefaultCredential {
82
83
  return this.authClient.fetchIdToken(audience);
83
84
  }
84
85
  else {
85
- throw new error_1.FirebaseAppError(error_1.AppErrorCodes.INVALID_CREDENTIAL, 'Credentials type should be Compute Engine Credentials.');
86
+ throw new error_1.FirebaseAppError({
87
+ code: error_1.AppErrorCode.INVALID_CREDENTIAL,
88
+ message: 'Credentials type should be Compute Engine Credentials.'
89
+ });
86
90
  }
87
91
  }
88
92
  async getServiceAccountEmail() {
@@ -150,12 +154,19 @@ class ServiceAccount {
150
154
  }
151
155
  catch (error) {
152
156
  // Throw a nicely formed error message if the file contents cannot be parsed
153
- throw new error_1.FirebaseAppError(error_1.AppErrorCodes.INVALID_CREDENTIAL, 'Failed to parse service account json file: ' + error);
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
+ });
154
162
  }
155
163
  }
156
164
  constructor(json) {
157
165
  if (!util.isNonNullObject(json)) {
158
- throw new error_1.FirebaseAppError(error_1.AppErrorCodes.INVALID_CREDENTIAL, 'Service account must be an object.');
166
+ throw new error_1.FirebaseAppError({
167
+ code: error_1.AppErrorCode.INVALID_CREDENTIAL,
168
+ message: 'Service account must be an object.'
169
+ });
159
170
  }
160
171
  copyAttr(this, json, 'projectId', 'project_id');
161
172
  copyAttr(this, json, 'privateKey', 'private_key');
@@ -171,15 +182,18 @@ class ServiceAccount {
171
182
  errorMessage = 'Service account object must contain a string "client_email" property.';
172
183
  }
173
184
  if (typeof errorMessage !== 'undefined') {
174
- throw new error_1.FirebaseAppError(error_1.AppErrorCodes.INVALID_CREDENTIAL, errorMessage);
185
+ throw new error_1.FirebaseAppError({ code: error_1.AppErrorCode.INVALID_CREDENTIAL, message: errorMessage });
175
186
  }
176
- // eslint-disable-next-line @typescript-eslint/no-var-requires
177
- const forge = require('node-forge');
187
+ // Validate private key format using native crypto module
178
188
  try {
179
- forge.pki.privateKeyFromPem(this.privateKey);
189
+ (0, node_crypto_1.createPrivateKey)(this.privateKey);
180
190
  }
181
191
  catch (error) {
182
- throw new error_1.FirebaseAppError(error_1.AppErrorCodes.INVALID_CREDENTIAL, 'Failed to parse private key: ' + error);
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(error_1.AppErrorCodes.INVALID_CREDENTIAL, 'Failed to parse refresh token file: ' + error);
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.AppErrorCodes.INVALID_CREDENTIAL, errorMessage);
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(error_1.AppErrorCodes.INVALID_CREDENTIAL, 'Failed to parse impersonated service account file: ' + error);
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.AppErrorCodes.INVALID_CREDENTIAL, errorMessage);
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(error_1.AppErrorCodes.INVALID_CREDENTIAL, 'Service account must be an object.');
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(error_1.AppErrorCodes.INVALID_CREDENTIAL, 'Failed to parse Google auth credential: access_token must be a non empty string.');
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(error_1.AppErrorCodes.INVALID_CREDENTIAL, 'Failed to parse Google auth credential: Invalid expiry_date.');
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,
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v13.9.0 */
1
+ /*! firebase-admin v14.0.0 */
2
2
  /*!
3
3
  * @license
4
4
  * Copyright 2021 Google LLC
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v13.9.0 */
1
+ /*! firebase-admin v14.0.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * @license
@@ -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];
@@ -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
+ };
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v13.9.0 */
1
+ /*! firebase-admin v14.0.0 */
2
2
  /*!
3
3
  * @license
4
4
  * Copyright 2017 Google LLC
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v13.9.0 */
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("../utils/error");
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(error_1.AppErrorCodes.INVALID_CREDENTIAL, `Invalid access token generated: "${JSON.stringify(result)}". Valid access ` +
55
- 'tokens must be an object with the "expires_in" (number) and "access_token" ' +
56
- '(string) properties.');
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(error_1.AppErrorCodes.INVALID_CREDENTIAL, errorMessage);
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(error_1.AppErrorCodes.INVALID_APP_OPTIONS, 'Invalid Firebase app options passed as the first argument to initializeApp() for the ' +
135
- `app named "${this.name_}". Options must be a non-null object.`);
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(error_1.AppErrorCodes.INVALID_APP_OPTIONS, 'Invalid Firebase app options passed as the first argument to initializeApp() for the ' +
145
- `app named "${this.name_}". The "credential" property must be an object which implements ` +
146
- 'the Credential interface.');
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(error_1.AppErrorCodes.APP_DELETED, `Firebase app named "${this.name_}" has already been deleted.`);
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
  }
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v13.9.0 */
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, FirebaseError } from './core';
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 { FirebaseAppError, AppErrorCodes } from '../utils/error';
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 v13.9.0 */
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.AppErrorCodes = exports.FirebaseAppError = exports.refreshToken = exports.cert = exports.applicationDefault = exports.deleteApp = exports.getApps = exports.getApp = exports.initializeApp = void 0;
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, "FirebaseAppError", { enumerable: true, get: function () { return error_1.FirebaseAppError; } });
33
- Object.defineProperty(exports, "AppErrorCodes", { enumerable: true, get: function () { return error_1.AppErrorCodes; } });
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)();
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v13.9.0 */
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 the default app name is used.
77
+ * is provided the default app name is used.
78
78
  *
79
79
  * @param appName - Optional name of the `App` instance.
80
80
  *
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v13.9.0 */
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("../utils/error");
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(error_1.AppErrorCodes.INVALID_APP_OPTIONS, `A Firebase app named "${appName}" already exists with a different configuration.`);
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(error_1.AppErrorCodes.DUPLICATE_APP, `A Firebase app named "${appName}" already exists with a different configuration.`);
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.AppErrorCodes.NO_APP, errorMessage);
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.AppErrorCodes.INVALID_ARGUMENT, 'Invalid app argument.');
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(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.');
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(error_1.AppErrorCodes.INVALID_APP_OPTIONS, `An existing app named "${existingApp.name}" already exists with a different` +
137
- ' options configuration: httpAgent.');
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(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.');
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(error_1.AppErrorCodes.INVALID_APP_OPTIONS, `An existing app named "${existingApp.name}" already exists with a different` +
148
- ' options configuration: Credential.');
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(error_1.AppErrorCodes.INVALID_APP_NAME, `Invalid Firebase app name "${appName}" provided. App name must be a non-empty string.`);
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 the default app name is used.
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(error_1.AppErrorCodes.INVALID_APP_OPTIONS, 'Failed to parse app options file: ' + error);
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
  }