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
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v13.9.0 */
1
+ /*! firebase-admin v14.0.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2020 Google LLC
@@ -20,6 +20,7 @@ exports.RemoteConfigFetchResponse = exports.RemoteConfig = void 0;
20
20
  const utils = require("../utils/index");
21
21
  const validator = require("../utils/validator");
22
22
  const remote_config_api_client_internal_1 = require("./remote-config-api-client-internal");
23
+ const error_1 = require("./error");
23
24
  const condition_evaluator_internal_1 = require("./condition-evaluator-internal");
24
25
  const value_impl_1 = require("./internal/value-impl");
25
26
  /**
@@ -136,14 +137,21 @@ class RemoteConfig {
136
137
  */
137
138
  createTemplateFromJSON(json) {
138
139
  if (!validator.isNonEmptyString(json)) {
139
- throw new remote_config_api_client_internal_1.FirebaseRemoteConfigError('invalid-argument', 'JSON string must be a valid non-empty string');
140
+ throw new error_1.FirebaseRemoteConfigError({
141
+ code: 'invalid-argument',
142
+ message: 'JSON string must be a valid non-empty string'
143
+ });
140
144
  }
141
145
  let template;
142
146
  try {
143
147
  template = JSON.parse(json);
144
148
  }
145
149
  catch (e) {
146
- throw new remote_config_api_client_internal_1.FirebaseRemoteConfigError('invalid-argument', `Failed to parse the JSON string: ${json}. ` + e);
150
+ throw new error_1.FirebaseRemoteConfigError({
151
+ code: 'invalid-argument',
152
+ message: `Failed to parse the JSON string: ${json}.`,
153
+ cause: e
154
+ });
147
155
  }
148
156
  return new RemoteConfigTemplateImpl(template);
149
157
  }
@@ -175,12 +183,18 @@ class RemoteConfigTemplateImpl {
175
183
  constructor(config) {
176
184
  if (!validator.isNonNullObject(config) ||
177
185
  !validator.isNonEmptyString(config.etag)) {
178
- throw new remote_config_api_client_internal_1.FirebaseRemoteConfigError('invalid-argument', `Invalid Remote Config template: ${JSON.stringify(config)}`);
186
+ throw new error_1.FirebaseRemoteConfigError({
187
+ code: 'invalid-argument',
188
+ message: `Invalid Remote Config template: ${JSON.stringify(config)}`
189
+ });
179
190
  }
180
191
  this.etagInternal = config.etag;
181
192
  if (typeof config.parameters !== 'undefined') {
182
193
  if (!validator.isNonNullObject(config.parameters)) {
183
- throw new remote_config_api_client_internal_1.FirebaseRemoteConfigError('invalid-argument', 'Remote Config parameters must be a non-null object');
194
+ throw new error_1.FirebaseRemoteConfigError({
195
+ code: 'invalid-argument',
196
+ message: 'Remote Config parameters must be a non-null object'
197
+ });
184
198
  }
185
199
  this.parameters = config.parameters;
186
200
  }
@@ -190,7 +204,10 @@ class RemoteConfigTemplateImpl {
190
204
  validateAllParameterExposures(this.parameters);
191
205
  if (typeof config.parameterGroups !== 'undefined') {
192
206
  if (!validator.isNonNullObject(config.parameterGroups)) {
193
- throw new remote_config_api_client_internal_1.FirebaseRemoteConfigError('invalid-argument', 'Remote Config parameter groups must be a non-null object');
207
+ throw new error_1.FirebaseRemoteConfigError({
208
+ code: 'invalid-argument',
209
+ message: 'Remote Config parameter groups must be a non-null object'
210
+ });
194
211
  }
195
212
  this.parameterGroups = config.parameterGroups;
196
213
  }
@@ -204,7 +221,10 @@ class RemoteConfigTemplateImpl {
204
221
  }
205
222
  if (typeof config.conditions !== 'undefined') {
206
223
  if (!validator.isArray(config.conditions)) {
207
- throw new remote_config_api_client_internal_1.FirebaseRemoteConfigError('invalid-argument', 'Remote Config conditions must be an array');
224
+ throw new error_1.FirebaseRemoteConfigError({
225
+ code: 'invalid-argument',
226
+ message: 'Remote Config conditions must be an array'
227
+ });
208
228
  }
209
229
  this.conditions = config.conditions;
210
230
  }
@@ -274,7 +294,11 @@ class ServerTemplateImpl {
274
294
  }
275
295
  catch (e) {
276
296
  // Transforms JSON parse errors to Firebase error.
277
- throw new remote_config_api_client_internal_1.FirebaseRemoteConfigError('invalid-argument', `Failed to parse the JSON string: ${template}. ` + e);
297
+ throw new error_1.FirebaseRemoteConfigError({
298
+ code: 'invalid-argument',
299
+ message: `Failed to parse the JSON string: ${template}.`,
300
+ cause: e
301
+ });
278
302
  }
279
303
  }
280
304
  else {
@@ -291,7 +315,10 @@ class ServerTemplateImpl {
291
315
  // This is the only place we should throw during evaluation, since it's under the
292
316
  // control of application logic. To preserve forward-compatibility, we should only
293
317
  // return false in cases where the SDK is unsure how to evaluate the fetched template.
294
- throw new remote_config_api_client_internal_1.FirebaseRemoteConfigError('failed-precondition', 'No Remote Config Server template in cache. Call load() before calling evaluate().');
318
+ throw new error_1.FirebaseRemoteConfigError({
319
+ code: 'failed-precondition',
320
+ message: 'No Remote Config Server template in cache. Call load() before calling evaluate().'
321
+ });
295
322
  }
296
323
  const evaluatedConditions = this.conditionEvaluator.evaluateConditions(this.cache.conditions, context);
297
324
  const configValues = {};
@@ -394,7 +421,10 @@ function validateExperimentExposurePercent(parameterValue, parameterName) {
394
421
  // Enforce public contract: numeric and within [0, 100].
395
422
  if (!validator.isNumber(exposurePercent) || !Number.isFinite(exposurePercent) ||
396
423
  exposurePercent < 0 || exposurePercent > 100) {
397
- throw new remote_config_api_client_internal_1.FirebaseRemoteConfigError('invalid-argument', `Experiment exposure percent must be between 0 and 100 (${parameterName})`);
424
+ throw new error_1.FirebaseRemoteConfigError({
425
+ code: 'invalid-argument',
426
+ message: `Experiment exposure percent must be between 0 and 100 (${parameterName})`
427
+ });
398
428
  }
399
429
  }
400
430
  /**
@@ -404,12 +434,18 @@ class ServerTemplateDataImpl {
404
434
  constructor(template) {
405
435
  if (!validator.isNonNullObject(template) ||
406
436
  !validator.isNonEmptyString(template.etag)) {
407
- throw new remote_config_api_client_internal_1.FirebaseRemoteConfigError('invalid-argument', `Invalid Remote Config template: ${JSON.stringify(template)}`);
437
+ throw new error_1.FirebaseRemoteConfigError({
438
+ code: 'invalid-argument',
439
+ message: `Invalid Remote Config template: ${JSON.stringify(template)}`
440
+ });
408
441
  }
409
442
  this.etag = template.etag;
410
443
  if (typeof template.parameters !== 'undefined') {
411
444
  if (!validator.isNonNullObject(template.parameters)) {
412
- throw new remote_config_api_client_internal_1.FirebaseRemoteConfigError('invalid-argument', 'Remote Config parameters must be a non-null object');
445
+ throw new error_1.FirebaseRemoteConfigError({
446
+ code: 'invalid-argument',
447
+ message: 'Remote Config parameters must be a non-null object'
448
+ });
413
449
  }
414
450
  this.parameters = template.parameters;
415
451
  }
@@ -418,7 +454,10 @@ class ServerTemplateDataImpl {
418
454
  }
419
455
  if (typeof template.conditions !== 'undefined') {
420
456
  if (!validator.isArray(template.conditions)) {
421
- throw new remote_config_api_client_internal_1.FirebaseRemoteConfigError('invalid-argument', 'Remote Config conditions must be an array');
457
+ throw new error_1.FirebaseRemoteConfigError({
458
+ code: 'invalid-argument',
459
+ message: 'Remote Config conditions must be an array'
460
+ });
422
461
  }
423
462
  this.conditions = template.conditions;
424
463
  }
@@ -436,51 +475,78 @@ class ServerTemplateDataImpl {
436
475
  class VersionImpl {
437
476
  constructor(version) {
438
477
  if (!validator.isNonNullObject(version)) {
439
- throw new remote_config_api_client_internal_1.FirebaseRemoteConfigError('invalid-argument', `Invalid Remote Config version instance: ${JSON.stringify(version)}`);
478
+ throw new error_1.FirebaseRemoteConfigError({
479
+ code: 'invalid-argument',
480
+ message: `Invalid Remote Config version instance: ${JSON.stringify(version)}`
481
+ });
440
482
  }
441
483
  if (typeof version.versionNumber !== 'undefined') {
442
484
  if (!validator.isNonEmptyString(version.versionNumber) &&
443
485
  !validator.isNumber(version.versionNumber)) {
444
- throw new remote_config_api_client_internal_1.FirebaseRemoteConfigError('invalid-argument', 'Version number must be a non-empty string in int64 format or a number');
486
+ throw new error_1.FirebaseRemoteConfigError({
487
+ code: 'invalid-argument',
488
+ message: 'Version number must be a non-empty string in int64 format or a number'
489
+ });
445
490
  }
446
491
  if (!Number.isInteger(Number(version.versionNumber))) {
447
- throw new remote_config_api_client_internal_1.FirebaseRemoteConfigError('invalid-argument', 'Version number must be an integer or a string in int64 format');
492
+ throw new error_1.FirebaseRemoteConfigError({
493
+ code: 'invalid-argument',
494
+ message: 'Version number must be an integer or a string in int64 format'
495
+ });
448
496
  }
449
497
  this.versionNumber = version.versionNumber;
450
498
  }
451
499
  if (typeof version.updateOrigin !== 'undefined') {
452
500
  if (!validator.isNonEmptyString(version.updateOrigin)) {
453
- throw new remote_config_api_client_internal_1.FirebaseRemoteConfigError('invalid-argument', 'Version update origin must be a non-empty string');
501
+ throw new error_1.FirebaseRemoteConfigError({
502
+ code: 'invalid-argument',
503
+ message: 'Version update origin must be a non-empty string'
504
+ });
454
505
  }
455
506
  this.updateOrigin = version.updateOrigin;
456
507
  }
457
508
  if (typeof version.updateType !== 'undefined') {
458
509
  if (!validator.isNonEmptyString(version.updateType)) {
459
- throw new remote_config_api_client_internal_1.FirebaseRemoteConfigError('invalid-argument', 'Version update type must be a non-empty string');
510
+ throw new error_1.FirebaseRemoteConfigError({
511
+ code: 'invalid-argument',
512
+ message: 'Version update type must be a non-empty string'
513
+ });
460
514
  }
461
515
  this.updateType = version.updateType;
462
516
  }
463
517
  if (typeof version.updateUser !== 'undefined') {
464
518
  if (!validator.isNonNullObject(version.updateUser)) {
465
- throw new remote_config_api_client_internal_1.FirebaseRemoteConfigError('invalid-argument', 'Version update user must be a non-null object');
519
+ throw new error_1.FirebaseRemoteConfigError({
520
+ code: 'invalid-argument',
521
+ message: 'Version update user must be a non-null object'
522
+ });
466
523
  }
467
524
  this.updateUser = version.updateUser;
468
525
  }
469
526
  if (typeof version.description !== 'undefined') {
470
527
  if (!validator.isNonEmptyString(version.description)) {
471
- throw new remote_config_api_client_internal_1.FirebaseRemoteConfigError('invalid-argument', 'Version description must be a non-empty string');
528
+ throw new error_1.FirebaseRemoteConfigError({
529
+ code: 'invalid-argument',
530
+ message: 'Version description must be a non-empty string'
531
+ });
472
532
  }
473
533
  this.description = version.description;
474
534
  }
475
535
  if (typeof version.rollbackSource !== 'undefined') {
476
536
  if (!validator.isNonEmptyString(version.rollbackSource)) {
477
- throw new remote_config_api_client_internal_1.FirebaseRemoteConfigError('invalid-argument', 'Version rollback source must be a non-empty string');
537
+ throw new error_1.FirebaseRemoteConfigError({
538
+ code: 'invalid-argument',
539
+ message: 'Version rollback source must be a non-empty string'
540
+ });
478
541
  }
479
542
  this.rollbackSource = version.rollbackSource;
480
543
  }
481
544
  if (typeof version.isLegacy !== 'undefined') {
482
545
  if (!validator.isBoolean(version.isLegacy)) {
483
- throw new remote_config_api_client_internal_1.FirebaseRemoteConfigError('invalid-argument', 'Version.isLegacy must be a boolean');
546
+ throw new error_1.FirebaseRemoteConfigError({
547
+ code: 'invalid-argument',
548
+ message: 'Version.isLegacy must be a boolean'
549
+ });
484
550
  }
485
551
  this.isLegacy = version.isLegacy;
486
552
  }
@@ -489,7 +555,10 @@ class VersionImpl {
489
555
  // we could still validate it below.
490
556
  if (typeof version.updateTime !== 'undefined') {
491
557
  if (!this.isValidTimestamp(version.updateTime)) {
492
- throw new remote_config_api_client_internal_1.FirebaseRemoteConfigError('invalid-argument', 'Version update time must be a valid date string');
558
+ throw new error_1.FirebaseRemoteConfigError({
559
+ code: 'invalid-argument',
560
+ message: 'Version update time must be a valid date string'
561
+ });
493
562
  }
494
563
  this.updateTime = new Date(version.updateTime).toUTCString();
495
564
  }
@@ -0,0 +1,45 @@
1
+ /*! firebase-admin v14.0.0 */
2
+ /*!
3
+ * Copyright 2019 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { FirebaseError, ErrorInfo } from '../utils/error';
18
+ /**
19
+ * The constant mapping for valid Security Rules client error codes.
20
+ */
21
+ export declare const SecurityRulesErrorCode: {
22
+ readonly ALREADY_EXISTS: "already-exists";
23
+ readonly AUTHENTICATION_ERROR: "authentication-error";
24
+ readonly INTERNAL_ERROR: "internal-error";
25
+ readonly INVALID_ARGUMENT: "invalid-argument";
26
+ readonly INVALID_SERVER_RESPONSE: "invalid-server-response";
27
+ readonly NOT_FOUND: "not-found";
28
+ readonly RESOURCE_EXHAUSTED: "resource-exhausted";
29
+ readonly SERVICE_UNAVAILABLE: "service-unavailable";
30
+ readonly UNKNOWN_ERROR: "unknown-error";
31
+ };
32
+ /**
33
+ * The type definition for valid Security Rules client error codes.
34
+ */
35
+ export type SecurityRulesErrorCode = typeof SecurityRulesErrorCode[keyof typeof SecurityRulesErrorCode];
36
+ /**
37
+ * Firebase Security Rules error code structure. This extends `FirebaseError`.
38
+ */
39
+ export declare class FirebaseSecurityRulesError extends FirebaseError {
40
+ /**
41
+ * @param info - The error code info.
42
+ * @param message - The error message. If provided, this will override the default message.
43
+ */
44
+ constructor(info: ErrorInfo, message?: string);
45
+ }
@@ -0,0 +1,54 @@
1
+ /*! firebase-admin v14.0.0 */
2
+ "use strict";
3
+ /*!
4
+ * Copyright 2019 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.FirebaseSecurityRulesError = exports.SecurityRulesErrorCode = void 0;
20
+ const error_1 = require("../utils/error");
21
+ /**
22
+ * The constant mapping for valid Security Rules client error codes.
23
+ */
24
+ exports.SecurityRulesErrorCode = {
25
+ ALREADY_EXISTS: 'already-exists',
26
+ AUTHENTICATION_ERROR: 'authentication-error',
27
+ INTERNAL_ERROR: 'internal-error',
28
+ INVALID_ARGUMENT: 'invalid-argument',
29
+ INVALID_SERVER_RESPONSE: 'invalid-server-response',
30
+ NOT_FOUND: 'not-found',
31
+ RESOURCE_EXHAUSTED: 'resource-exhausted',
32
+ SERVICE_UNAVAILABLE: 'service-unavailable',
33
+ UNKNOWN_ERROR: 'unknown-error',
34
+ };
35
+ /**
36
+ * Firebase Security Rules error code structure. This extends `FirebaseError`.
37
+ */
38
+ class FirebaseSecurityRulesError extends error_1.FirebaseError {
39
+ /**
40
+ * @param info - The error code info.
41
+ * @param message - The error message. If provided, this will override the default message.
42
+ */
43
+ constructor(info, message) {
44
+ super({
45
+ code: `security-rules/${info.code}`,
46
+ message: message || info.message,
47
+ httpResponse: info.httpResponse,
48
+ cause: info.cause,
49
+ });
50
+ /** @internal */
51
+ this.codePrefix = 'security-rules';
52
+ }
53
+ }
54
+ exports.FirebaseSecurityRulesError = FirebaseSecurityRulesError;
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v13.9.0 */
1
+ /*! firebase-admin v14.0.0 */
2
2
  /*!
3
3
  * Copyright 2020 Google LLC
4
4
  *
@@ -48,3 +48,4 @@ export { RulesFile, Ruleset, RulesetMetadata, RulesetMetadataList, SecurityRules
48
48
  * `SecurityRules` service associated with the provided app.
49
49
  */
50
50
  export declare function getSecurityRules(app?: App): SecurityRules;
51
+ export { FirebaseSecurityRulesError, SecurityRulesErrorCode } from './error';
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v13.9.0 */
1
+ /*! firebase-admin v14.0.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2020 Google LLC
@@ -16,7 +16,7 @@
16
16
  * limitations under the License.
17
17
  */
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
- exports.SecurityRules = exports.RulesetMetadataList = exports.Ruleset = void 0;
19
+ exports.SecurityRulesErrorCode = exports.FirebaseSecurityRulesError = exports.SecurityRules = exports.RulesetMetadataList = exports.Ruleset = void 0;
20
20
  exports.getSecurityRules = getSecurityRules;
21
21
  /**
22
22
  * Security Rules for Cloud Firestore and Cloud Storage.
@@ -61,3 +61,6 @@ function getSecurityRules(app) {
61
61
  const firebaseApp = app;
62
62
  return firebaseApp.getOrInitService('securityRules', (app) => new security_rules_1.SecurityRules(app));
63
63
  }
64
+ var error_1 = require("./error");
65
+ Object.defineProperty(exports, "FirebaseSecurityRulesError", { enumerable: true, get: function () { return error_1.FirebaseSecurityRulesError; } });
66
+ Object.defineProperty(exports, "SecurityRulesErrorCode", { enumerable: true, get: function () { return error_1.SecurityRulesErrorCode; } });
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v13.9.0 */
1
+ /*! firebase-admin v14.0.0 */
2
2
  /*!
3
3
  * Copyright 2019 Google LLC
4
4
  *
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v13.9.0 */
1
+ /*! firebase-admin v14.0.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2019 Google LLC
@@ -19,7 +19,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
19
19
  exports.SecurityRulesApiClient = void 0;
20
20
  const api_request_1 = require("../utils/api-request");
21
21
  const error_1 = require("../utils/error");
22
- const security_rules_internal_1 = require("./security-rules-internal");
22
+ const error_2 = require("./error");
23
23
  const utils = require("../utils/index");
24
24
  const validator = require("../utils/validator");
25
25
  const RULES_V1_API = 'https://firebaserules.googleapis.com/v1';
@@ -35,8 +35,11 @@ class SecurityRulesApiClient {
35
35
  constructor(app) {
36
36
  this.app = app;
37
37
  if (!validator.isNonNullObject(app) || !('options' in app)) {
38
- throw new security_rules_internal_1.FirebaseSecurityRulesError('invalid-argument', 'First argument passed to admin.securityRules() must be a valid Firebase app '
39
- + 'instance.');
38
+ throw new error_2.FirebaseSecurityRulesError({
39
+ code: 'invalid-argument',
40
+ message: 'First argument passed to admin.securityRules() must be a valid Firebase app ' +
41
+ 'instance.'
42
+ });
40
43
  }
41
44
  this.httpClient = new api_request_1.AuthorizedHttpClient(app);
42
45
  }
@@ -53,14 +56,20 @@ class SecurityRulesApiClient {
53
56
  if (!validator.isNonNullObject(ruleset) ||
54
57
  !validator.isNonNullObject(ruleset.source) ||
55
58
  !validator.isNonEmptyArray(ruleset.source.files)) {
56
- const err = new security_rules_internal_1.FirebaseSecurityRulesError('invalid-argument', 'Invalid rules content.');
59
+ const err = new error_2.FirebaseSecurityRulesError({
60
+ code: 'invalid-argument',
61
+ message: 'Invalid rules content.'
62
+ });
57
63
  return Promise.reject(err);
58
64
  }
59
65
  for (const rf of ruleset.source.files) {
60
66
  if (!validator.isNonNullObject(rf) ||
61
67
  !validator.isNonEmptyString(rf.name) ||
62
68
  !validator.isNonEmptyString(rf.content)) {
63
- const err = new security_rules_internal_1.FirebaseSecurityRulesError('invalid-argument', `Invalid rules file argument: ${JSON.stringify(rf)}`);
69
+ const err = new error_2.FirebaseSecurityRulesError({
70
+ code: 'invalid-argument',
71
+ message: `Invalid rules file argument: ${JSON.stringify(rf)}`
72
+ });
64
73
  return Promise.reject(err);
65
74
  }
66
75
  }
@@ -87,15 +96,24 @@ class SecurityRulesApiClient {
87
96
  }
88
97
  listRulesets(pageSize = 100, pageToken) {
89
98
  if (!validator.isNumber(pageSize)) {
90
- const err = new security_rules_internal_1.FirebaseSecurityRulesError('invalid-argument', 'Invalid page size.');
99
+ const err = new error_2.FirebaseSecurityRulesError({
100
+ code: 'invalid-argument',
101
+ message: 'Invalid page size.'
102
+ });
91
103
  return Promise.reject(err);
92
104
  }
93
105
  if (pageSize < 1 || pageSize > 100) {
94
- const err = new security_rules_internal_1.FirebaseSecurityRulesError('invalid-argument', 'Page size must be between 1 and 100.');
106
+ const err = new error_2.FirebaseSecurityRulesError({
107
+ code: 'invalid-argument',
108
+ message: 'Page size must be between 1 and 100.'
109
+ });
95
110
  return Promise.reject(err);
96
111
  }
97
112
  if (typeof pageToken !== 'undefined' && !validator.isNonEmptyString(pageToken)) {
98
- const err = new security_rules_internal_1.FirebaseSecurityRulesError('invalid-argument', 'Next page token must be a non-empty string.');
113
+ const err = new error_2.FirebaseSecurityRulesError({
114
+ code: 'invalid-argument',
115
+ message: 'Next page token must be a non-empty string.'
116
+ });
99
117
  return Promise.reject(err);
100
118
  }
101
119
  const data = {
@@ -168,9 +186,12 @@ class SecurityRulesApiClient {
168
186
  return utils.findProjectId(this.app)
169
187
  .then((projectId) => {
170
188
  if (!validator.isNonEmptyString(projectId)) {
171
- throw new security_rules_internal_1.FirebaseSecurityRulesError('invalid-argument', 'Failed to determine project ID. Initialize the SDK with service account credentials, or '
172
- + 'set project ID as an app option. Alternatively, set the GOOGLE_CLOUD_PROJECT '
173
- + 'environment variable.');
189
+ throw new error_2.FirebaseSecurityRulesError({
190
+ code: 'invalid-argument',
191
+ message: 'Failed to determine project ID. Initialize the SDK with service account credentials, or '
192
+ + 'set project ID as an app option. Alternatively, set the GOOGLE_CLOUD_PROJECT '
193
+ + 'environment variable.'
194
+ });
174
195
  }
175
196
  this.projectIdPrefix = `projects/${projectId}`;
176
197
  return this.projectIdPrefix;
@@ -204,10 +225,16 @@ class SecurityRulesApiClient {
204
225
  }
205
226
  getRulesetName(name) {
206
227
  if (!validator.isNonEmptyString(name)) {
207
- throw new security_rules_internal_1.FirebaseSecurityRulesError('invalid-argument', 'Ruleset name must be a non-empty string.');
228
+ throw new error_2.FirebaseSecurityRulesError({
229
+ code: 'invalid-argument',
230
+ message: 'Ruleset name must be a non-empty string.'
231
+ });
208
232
  }
209
233
  if (name.indexOf('/') !== -1) {
210
- throw new security_rules_internal_1.FirebaseSecurityRulesError('invalid-argument', 'Ruleset name must not contain any "/" characters.');
234
+ throw new error_2.FirebaseSecurityRulesError({
235
+ code: 'invalid-argument',
236
+ message: 'Ruleset name must not contain any "/" characters.'
237
+ });
211
238
  }
212
239
  return `rulesets/${name}`;
213
240
  }
@@ -222,20 +249,25 @@ class SecurityRulesApiClient {
222
249
  });
223
250
  }
224
251
  toFirebaseError(err) {
225
- if (err instanceof error_1.PrefixedFirebaseError) {
252
+ if (err instanceof error_1.FirebaseError) {
226
253
  return err;
227
254
  }
228
255
  const response = err.response;
229
256
  if (!response.isJson()) {
230
- return new security_rules_internal_1.FirebaseSecurityRulesError('unknown-error', `Unexpected response with status: ${response.status} and body: ${response.text}`);
257
+ return new error_2.FirebaseSecurityRulesError({
258
+ code: 'unknown-error',
259
+ message: `Unexpected response with status: ${response.status} and body: ${response.text}`,
260
+ httpResponse: (0, error_1.toHttpResponse)(response),
261
+ cause: err
262
+ });
231
263
  }
232
264
  const error = response.data.error || {};
233
265
  let code = 'unknown-error';
234
266
  if (error.status && error.status in ERROR_CODE_MAPPING) {
235
267
  code = ERROR_CODE_MAPPING[error.status];
236
268
  }
237
- const message = error.message || `Unknown server error: ${response.text}`;
238
- return new security_rules_internal_1.FirebaseSecurityRulesError(code, message);
269
+ const message = error.message || 'Unknown server error';
270
+ return new error_2.FirebaseSecurityRulesError({ code, message, httpResponse: (0, error_1.toHttpResponse)(response), cause: err });
239
271
  }
240
272
  }
241
273
  exports.SecurityRulesApiClient = SecurityRulesApiClient;
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v13.9.0 */
1
+ /*! firebase-admin v14.0.0 */
2
2
  /*!
3
3
  * Copyright 2019 Google LLC
4
4
  *
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v13.9.0 */
1
+ /*! firebase-admin v14.0.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2019 Google LLC
@@ -19,7 +19,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
19
19
  exports.SecurityRules = exports.Ruleset = exports.RulesetMetadataList = void 0;
20
20
  const validator = require("../utils/validator");
21
21
  const security_rules_api_client_internal_1 = require("./security-rules-api-client-internal");
22
- const security_rules_internal_1 = require("./security-rules-internal");
22
+ const error_1 = require("./error");
23
23
  /**
24
24
  * A page of ruleset metadata.
25
25
  */
@@ -29,7 +29,10 @@ class RulesetMetadataList {
29
29
  */
30
30
  constructor(response) {
31
31
  if (!validator.isNonNullObject(response) || !validator.isArray(response.rulesets)) {
32
- throw new security_rules_internal_1.FirebaseSecurityRulesError('invalid-argument', `Invalid ListRulesets response: ${JSON.stringify(response)}`);
32
+ throw new error_1.FirebaseSecurityRulesError({
33
+ code: 'invalid-argument',
34
+ message: `Invalid ListRulesets response: ${JSON.stringify(response)}`
35
+ });
33
36
  }
34
37
  this.rulesets = response.rulesets.map((rs) => {
35
38
  return {
@@ -55,7 +58,10 @@ class Ruleset {
55
58
  !validator.isNonEmptyString(ruleset.name) ||
56
59
  !validator.isNonEmptyString(ruleset.createTime) ||
57
60
  !validator.isNonNullObject(ruleset.source)) {
58
- throw new security_rules_internal_1.FirebaseSecurityRulesError('invalid-argument', `Invalid Ruleset response: ${JSON.stringify(ruleset)}`);
61
+ throw new error_1.FirebaseSecurityRulesError({
62
+ code: 'invalid-argument',
63
+ message: `Invalid Ruleset response: ${JSON.stringify(ruleset)}`
64
+ });
59
65
  }
60
66
  this.name = stripProjectIdPrefix(ruleset.name);
61
67
  this.createTime = new Date(ruleset.createTime).toUTCString();
@@ -217,7 +223,10 @@ class SecurityRules {
217
223
  */
218
224
  createRulesFileFromSource(name, source) {
219
225
  if (!validator.isNonEmptyString(name)) {
220
- throw new security_rules_internal_1.FirebaseSecurityRulesError('invalid-argument', 'Name must be a non-empty string.');
226
+ throw new error_1.FirebaseSecurityRulesError({
227
+ code: 'invalid-argument',
228
+ message: 'Name must be a non-empty string.'
229
+ });
221
230
  }
222
231
  let content;
223
232
  if (validator.isNonEmptyString(source)) {
@@ -227,7 +236,10 @@ class SecurityRules {
227
236
  content = source.toString('utf-8');
228
237
  }
229
238
  else {
230
- throw new security_rules_internal_1.FirebaseSecurityRulesError('invalid-argument', 'Source must be a non-empty string or a Buffer.');
239
+ throw new error_1.FirebaseSecurityRulesError({
240
+ code: 'invalid-argument',
241
+ message: 'Source must be a non-empty string or a Buffer.'
242
+ });
231
243
  }
232
244
  return {
233
245
  name,
@@ -284,7 +296,10 @@ class SecurityRules {
284
296
  .then((release) => {
285
297
  const rulesetName = release.rulesetName;
286
298
  if (!validator.isNonEmptyString(rulesetName)) {
287
- throw new security_rules_internal_1.FirebaseSecurityRulesError('not-found', `Ruleset name not found for ${releaseName}.`);
299
+ throw new error_1.FirebaseSecurityRulesError({
300
+ code: 'not-found',
301
+ message: `Ruleset name not found for ${releaseName}.`
302
+ });
288
303
  }
289
304
  return this.getRuleset(stripProjectIdPrefix(rulesetName));
290
305
  });
@@ -292,7 +307,10 @@ class SecurityRules {
292
307
  releaseRuleset(ruleset, releaseName) {
293
308
  if (!validator.isNonEmptyString(ruleset) &&
294
309
  (!validator.isNonNullObject(ruleset) || !validator.isNonEmptyString(ruleset.name))) {
295
- const err = new security_rules_internal_1.FirebaseSecurityRulesError('invalid-argument', 'ruleset must be a non-empty name or a RulesetMetadata object.');
310
+ const err = new error_1.FirebaseSecurityRulesError({
311
+ code: 'invalid-argument',
312
+ message: 'ruleset must be a non-empty name or a RulesetMetadata object.'
313
+ });
296
314
  return Promise.reject(err);
297
315
  }
298
316
  const rulesetName = validator.isString(ruleset) ? ruleset : ruleset.name;
@@ -304,9 +322,12 @@ class SecurityRules {
304
322
  getBucketName(bucket) {
305
323
  const bucketName = (typeof bucket !== 'undefined') ? bucket : this.app.options.storageBucket;
306
324
  if (!validator.isNonEmptyString(bucketName)) {
307
- throw new security_rules_internal_1.FirebaseSecurityRulesError('invalid-argument', 'Bucket name not specified or invalid. Specify a default bucket name via the ' +
308
- 'storageBucket option when initializing the app, or specify the bucket name ' +
309
- 'explicitly when calling the rules API.');
325
+ throw new error_1.FirebaseSecurityRulesError({
326
+ code: 'invalid-argument',
327
+ message: 'Bucket name not specified or invalid. Specify a default bucket name via the ' +
328
+ 'storageBucket option when initializing the app, or specify the bucket name ' +
329
+ 'explicitly when calling the rules API.'
330
+ });
310
331
  }
311
332
  return bucketName;
312
333
  }