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 2019 Google LLC
@@ -18,7 +18,8 @@
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
19
  exports.createFirebaseError = createFirebaseError;
20
20
  exports.getErrorCode = getErrorCode;
21
- const error_1 = require("../utils/error");
21
+ const error_1 = require("./error");
22
+ const error_2 = require("../utils/error");
22
23
  const validator = require("../utils/validator");
23
24
  /**
24
25
  * Creates a new `FirebaseMessagingError` by extracting the error code, message and other relevant
@@ -33,32 +34,34 @@ function createFirebaseError(err) {
33
34
  const json = err.response.data;
34
35
  const errorCode = getErrorCode(json);
35
36
  const errorMessage = getErrorMessage(json);
36
- return error_1.FirebaseMessagingError.fromServerError(errorCode, errorMessage, json);
37
+ return error_1.FirebaseMessagingError.fromServerError(errorCode, errorMessage, err);
37
38
  }
38
39
  // Non-JSON response
39
40
  let error;
40
41
  switch (err.response.status) {
41
42
  case 400:
42
- error = error_1.MessagingClientErrorCode.INVALID_ARGUMENT;
43
+ error = error_1.messagingClientErrorCode.INVALID_ARGUMENT;
43
44
  break;
44
45
  case 401:
45
46
  case 403:
46
- error = error_1.MessagingClientErrorCode.AUTHENTICATION_ERROR;
47
+ error = error_1.messagingClientErrorCode.AUTHENTICATION_ERROR;
47
48
  break;
48
49
  case 500:
49
- error = error_1.MessagingClientErrorCode.INTERNAL_ERROR;
50
+ error = error_1.messagingClientErrorCode.INTERNAL_ERROR;
50
51
  break;
51
52
  case 503:
52
- error = error_1.MessagingClientErrorCode.SERVER_UNAVAILABLE;
53
+ error = error_1.messagingClientErrorCode.SERVER_UNAVAILABLE;
53
54
  break;
54
55
  default:
55
56
  // Treat non-JSON responses with unexpected status codes as unknown errors.
56
- error = error_1.MessagingClientErrorCode.UNKNOWN_ERROR;
57
+ error = error_1.messagingClientErrorCode.UNKNOWN_ERROR;
57
58
  }
58
59
  return new error_1.FirebaseMessagingError({
59
60
  code: error.code,
60
61
  message: `${error.message} Raw server response: "${err.response.text}". Status code: ` +
61
62
  `${err.response.status}.`,
63
+ httpResponse: (0, error_2.toHttpResponse)(err.response),
64
+ cause: err,
62
65
  });
63
66
  }
64
67
  /**
@@ -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
  *
@@ -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
@@ -19,7 +19,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
19
19
  exports.BLACKLISTED_OPTIONS_KEYS = exports.BLACKLISTED_DATA_PAYLOAD_KEYS = void 0;
20
20
  exports.validateMessage = validateMessage;
21
21
  const index_1 = require("../utils/index");
22
- const error_1 = require("../utils/error");
22
+ const error_1 = require("./error");
23
23
  const validator = require("../utils/validator");
24
24
  // Keys which are not allowed in the messaging data payload object.
25
25
  exports.BLACKLISTED_DATA_PAYLOAD_KEYS = ['from'];
@@ -36,7 +36,7 @@ exports.BLACKLISTED_OPTIONS_KEYS = [
36
36
  */
37
37
  function validateMessage(message) {
38
38
  if (!validator.isNonNullObject(message)) {
39
- throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'Message must be a non-null object');
39
+ throw new error_1.FirebaseMessagingError(error_1.messagingClientErrorCode.INVALID_PAYLOAD, 'Message must be a non-null object');
40
40
  }
41
41
  const anyMessage = message;
42
42
  if (anyMessage.topic) {
@@ -46,12 +46,12 @@ function validateMessage(message) {
46
46
  }
47
47
  // Checks for illegal characters and empty string.
48
48
  if (!/^[a-zA-Z0-9-_.~%]+$/.test(anyMessage.topic)) {
49
- throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'Malformed topic name');
49
+ throw new error_1.FirebaseMessagingError(error_1.messagingClientErrorCode.INVALID_PAYLOAD, 'Malformed topic name');
50
50
  }
51
51
  }
52
52
  const targets = [anyMessage.token, anyMessage.topic, anyMessage.condition];
53
53
  if (targets.filter((v) => validator.isNonEmptyString(v)).length !== 1) {
54
- throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'Exactly one of topic, token or condition is required');
54
+ throw new error_1.FirebaseMessagingError(error_1.messagingClientErrorCode.INVALID_PAYLOAD, 'Exactly one of topic, token or condition is required');
55
55
  }
56
56
  validateStringMap(message.data, 'data');
57
57
  validateAndroidConfig(message.android);
@@ -71,11 +71,11 @@ function validateStringMap(map, label) {
71
71
  return;
72
72
  }
73
73
  else if (!validator.isNonNullObject(map)) {
74
- throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, `${label} must be a non-null object`);
74
+ throw new error_1.FirebaseMessagingError(error_1.messagingClientErrorCode.INVALID_PAYLOAD, `${label} must be a non-null object`);
75
75
  }
76
76
  Object.keys(map).forEach((key) => {
77
77
  if (!validator.isString(map[key])) {
78
- throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, `${label} must only contain string values`);
78
+ throw new error_1.FirebaseMessagingError(error_1.messagingClientErrorCode.INVALID_PAYLOAD, `${label} must only contain string values`);
79
79
  }
80
80
  });
81
81
  }
@@ -89,7 +89,7 @@ function validateWebpushConfig(config) {
89
89
  return;
90
90
  }
91
91
  else if (!validator.isNonNullObject(config)) {
92
- throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'webpush must be a non-null object');
92
+ throw new error_1.FirebaseMessagingError(error_1.messagingClientErrorCode.INVALID_PAYLOAD, 'webpush must be a non-null object');
93
93
  }
94
94
  validateStringMap(config.headers, 'webpush.headers');
95
95
  validateStringMap(config.data, 'webpush.data');
@@ -105,7 +105,7 @@ function validateApnsConfig(config) {
105
105
  return;
106
106
  }
107
107
  else if (!validator.isNonNullObject(config)) {
108
- throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'apns must be a non-null object');
108
+ throw new error_1.FirebaseMessagingError(error_1.messagingClientErrorCode.INVALID_PAYLOAD, 'apns must be a non-null object');
109
109
  }
110
110
  validateApnsLiveActivityToken(config.liveActivityToken);
111
111
  validateStringMap(config.headers, 'apns.headers');
@@ -121,10 +121,10 @@ function validateApnsLiveActivityToken(liveActivityToken) {
121
121
  return;
122
122
  }
123
123
  else if (!validator.isString(liveActivityToken)) {
124
- throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'apns.liveActivityToken must be a string value');
124
+ throw new error_1.FirebaseMessagingError(error_1.messagingClientErrorCode.INVALID_PAYLOAD, 'apns.liveActivityToken must be a string value');
125
125
  }
126
126
  else if (!validator.isNonEmptyString(liveActivityToken)) {
127
- throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'apns.liveActivityToken must be a non-empty string');
127
+ throw new error_1.FirebaseMessagingError(error_1.messagingClientErrorCode.INVALID_PAYLOAD, 'apns.liveActivityToken must be a non-empty string');
128
128
  }
129
129
  }
130
130
  /**
@@ -137,21 +137,21 @@ function validateApnsFcmOptions(fcmOptions) {
137
137
  return;
138
138
  }
139
139
  else if (!validator.isNonNullObject(fcmOptions)) {
140
- throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'fcmOptions must be a non-null object');
140
+ throw new error_1.FirebaseMessagingError(error_1.messagingClientErrorCode.INVALID_PAYLOAD, 'fcmOptions must be a non-null object');
141
141
  }
142
142
  if (typeof fcmOptions.imageUrl !== 'undefined' &&
143
143
  !validator.isURL(fcmOptions.imageUrl)) {
144
- throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'imageUrl must be a valid URL string');
144
+ throw new error_1.FirebaseMessagingError(error_1.messagingClientErrorCode.INVALID_PAYLOAD, 'imageUrl must be a valid URL string');
145
145
  }
146
146
  if (typeof fcmOptions.analyticsLabel !== 'undefined' && !validator.isString(fcmOptions.analyticsLabel)) {
147
- throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'analyticsLabel must be a string value');
147
+ throw new error_1.FirebaseMessagingError(error_1.messagingClientErrorCode.INVALID_PAYLOAD, 'analyticsLabel must be a string value');
148
148
  }
149
149
  const propertyMappings = {
150
150
  imageUrl: 'image',
151
151
  };
152
152
  Object.keys(propertyMappings).forEach((key) => {
153
153
  if (key in fcmOptions && propertyMappings[key] in fcmOptions) {
154
- throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, `Multiple specifications for ${key} in ApnsFcmOptions`);
154
+ throw new error_1.FirebaseMessagingError(error_1.messagingClientErrorCode.INVALID_PAYLOAD, `Multiple specifications for ${key} in ApnsFcmOptions`);
155
155
  }
156
156
  });
157
157
  (0, index_1.renameProperties)(fcmOptions, propertyMappings);
@@ -166,10 +166,10 @@ function validateFcmOptions(fcmOptions) {
166
166
  return;
167
167
  }
168
168
  else if (!validator.isNonNullObject(fcmOptions)) {
169
- throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'fcmOptions must be a non-null object');
169
+ throw new error_1.FirebaseMessagingError(error_1.messagingClientErrorCode.INVALID_PAYLOAD, 'fcmOptions must be a non-null object');
170
170
  }
171
171
  if (typeof fcmOptions.analyticsLabel !== 'undefined' && !validator.isString(fcmOptions.analyticsLabel)) {
172
- throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'analyticsLabel must be a string value');
172
+ throw new error_1.FirebaseMessagingError(error_1.messagingClientErrorCode.INVALID_PAYLOAD, 'analyticsLabel must be a string value');
173
173
  }
174
174
  }
175
175
  /**
@@ -182,17 +182,17 @@ function validateNotification(notification) {
182
182
  return;
183
183
  }
184
184
  else if (!validator.isNonNullObject(notification)) {
185
- throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'notification must be a non-null object');
185
+ throw new error_1.FirebaseMessagingError(error_1.messagingClientErrorCode.INVALID_PAYLOAD, 'notification must be a non-null object');
186
186
  }
187
187
  if (typeof notification.imageUrl !== 'undefined' && !validator.isURL(notification.imageUrl)) {
188
- throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'notification.imageUrl must be a valid URL string');
188
+ throw new error_1.FirebaseMessagingError(error_1.messagingClientErrorCode.INVALID_PAYLOAD, 'notification.imageUrl must be a valid URL string');
189
189
  }
190
190
  const propertyMappings = {
191
191
  imageUrl: 'image',
192
192
  };
193
193
  Object.keys(propertyMappings).forEach((key) => {
194
194
  if (key in notification && propertyMappings[key] in notification) {
195
- throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, `Multiple specifications for ${key} in Notification`);
195
+ throw new error_1.FirebaseMessagingError(error_1.messagingClientErrorCode.INVALID_PAYLOAD, `Multiple specifications for ${key} in Notification`);
196
196
  }
197
197
  });
198
198
  (0, index_1.renameProperties)(notification, propertyMappings);
@@ -207,7 +207,7 @@ function validateApnsPayload(payload) {
207
207
  return;
208
208
  }
209
209
  else if (!validator.isNonNullObject(payload)) {
210
- throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'apns.payload must be a non-null object');
210
+ throw new error_1.FirebaseMessagingError(error_1.messagingClientErrorCode.INVALID_PAYLOAD, 'apns.payload must be a non-null object');
211
211
  }
212
212
  validateAps(payload.aps);
213
213
  }
@@ -222,7 +222,7 @@ function validateAps(aps) {
222
222
  return;
223
223
  }
224
224
  else if (!validator.isNonNullObject(aps)) {
225
- throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'apns.payload.aps must be a non-null object');
225
+ throw new error_1.FirebaseMessagingError(error_1.messagingClientErrorCode.INVALID_PAYLOAD, 'apns.payload.aps must be a non-null object');
226
226
  }
227
227
  validateApsAlert(aps.alert);
228
228
  validateApsSound(aps.sound);
@@ -233,7 +233,7 @@ function validateAps(aps) {
233
233
  };
234
234
  Object.keys(propertyMappings).forEach((key) => {
235
235
  if (key in aps && propertyMappings[key] in aps) {
236
- throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, `Multiple specifications for ${key} in Aps`);
236
+ throw new error_1.FirebaseMessagingError(error_1.messagingClientErrorCode.INVALID_PAYLOAD, `Multiple specifications for ${key} in Aps`);
237
237
  }
238
238
  });
239
239
  (0, index_1.renameProperties)(aps, propertyMappings);
@@ -261,18 +261,18 @@ function validateApsSound(sound) {
261
261
  return;
262
262
  }
263
263
  else if (!validator.isNonNullObject(sound)) {
264
- throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'apns.payload.aps.sound must be a non-empty string or a non-null object');
264
+ throw new error_1.FirebaseMessagingError(error_1.messagingClientErrorCode.INVALID_PAYLOAD, 'apns.payload.aps.sound must be a non-empty string or a non-null object');
265
265
  }
266
266
  if (!validator.isNonEmptyString(sound.name)) {
267
- throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'apns.payload.aps.sound.name must be a non-empty string');
267
+ throw new error_1.FirebaseMessagingError(error_1.messagingClientErrorCode.INVALID_PAYLOAD, 'apns.payload.aps.sound.name must be a non-empty string');
268
268
  }
269
269
  const volume = sound.volume;
270
270
  if (typeof volume !== 'undefined') {
271
271
  if (!validator.isNumber(volume)) {
272
- throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'apns.payload.aps.sound.volume must be a number');
272
+ throw new error_1.FirebaseMessagingError(error_1.messagingClientErrorCode.INVALID_PAYLOAD, 'apns.payload.aps.sound.volume must be a number');
273
273
  }
274
274
  if (volume < 0 || volume > 1) {
275
- throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'apns.payload.aps.sound.volume must be in the interval [0, 1]');
275
+ throw new error_1.FirebaseMessagingError(error_1.messagingClientErrorCode.INVALID_PAYLOAD, 'apns.payload.aps.sound.volume must be in the interval [0, 1]');
276
276
  }
277
277
  }
278
278
  const soundObject = sound;
@@ -299,20 +299,20 @@ function validateApsAlert(alert) {
299
299
  return;
300
300
  }
301
301
  else if (!validator.isNonNullObject(alert)) {
302
- throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'apns.payload.aps.alert must be a string or a non-null object');
302
+ throw new error_1.FirebaseMessagingError(error_1.messagingClientErrorCode.INVALID_PAYLOAD, 'apns.payload.aps.alert must be a string or a non-null object');
303
303
  }
304
304
  const apsAlert = alert;
305
305
  if (validator.isNonEmptyArray(apsAlert.locArgs) &&
306
306
  !validator.isNonEmptyString(apsAlert.locKey)) {
307
- throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'apns.payload.aps.alert.locKey is required when specifying locArgs');
307
+ throw new error_1.FirebaseMessagingError(error_1.messagingClientErrorCode.INVALID_PAYLOAD, 'apns.payload.aps.alert.locKey is required when specifying locArgs');
308
308
  }
309
309
  if (validator.isNonEmptyArray(apsAlert.titleLocArgs) &&
310
310
  !validator.isNonEmptyString(apsAlert.titleLocKey)) {
311
- throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'apns.payload.aps.alert.titleLocKey is required when specifying titleLocArgs');
311
+ throw new error_1.FirebaseMessagingError(error_1.messagingClientErrorCode.INVALID_PAYLOAD, 'apns.payload.aps.alert.titleLocKey is required when specifying titleLocArgs');
312
312
  }
313
313
  if (validator.isNonEmptyArray(apsAlert.subtitleLocArgs) &&
314
314
  !validator.isNonEmptyString(apsAlert.subtitleLocKey)) {
315
- throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'apns.payload.aps.alert.subtitleLocKey is required when specifying subtitleLocArgs');
315
+ throw new error_1.FirebaseMessagingError(error_1.messagingClientErrorCode.INVALID_PAYLOAD, 'apns.payload.aps.alert.subtitleLocKey is required when specifying subtitleLocArgs');
316
316
  }
317
317
  const propertyMappings = {
318
318
  locKey: 'loc-key',
@@ -338,11 +338,11 @@ function validateAndroidConfig(config) {
338
338
  return;
339
339
  }
340
340
  else if (!validator.isNonNullObject(config)) {
341
- throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'android must be a non-null object');
341
+ throw new error_1.FirebaseMessagingError(error_1.messagingClientErrorCode.INVALID_PAYLOAD, 'android must be a non-null object');
342
342
  }
343
343
  if (typeof config.ttl !== 'undefined') {
344
344
  if (!validator.isNumber(config.ttl) || config.ttl < 0) {
345
- throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'TTL must be a non-negative duration in milliseconds');
345
+ throw new error_1.FirebaseMessagingError(error_1.messagingClientErrorCode.INVALID_PAYLOAD, 'TTL must be a non-negative duration in milliseconds');
346
346
  }
347
347
  const duration = (0, index_1.transformMillisecondsToSecondsString)(config.ttl);
348
348
  config.ttl = duration;
@@ -371,26 +371,26 @@ function validateAndroidNotification(notification) {
371
371
  return;
372
372
  }
373
373
  else if (!validator.isNonNullObject(notification)) {
374
- throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'android.notification must be a non-null object');
374
+ throw new error_1.FirebaseMessagingError(error_1.messagingClientErrorCode.INVALID_PAYLOAD, 'android.notification must be a non-null object');
375
375
  }
376
376
  if (typeof notification.color !== 'undefined' && !/^#[0-9a-fA-F]{6}$/.test(notification.color)) {
377
- throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'android.notification.color must be in the form #RRGGBB');
377
+ throw new error_1.FirebaseMessagingError(error_1.messagingClientErrorCode.INVALID_PAYLOAD, 'android.notification.color must be in the form #RRGGBB');
378
378
  }
379
379
  if (validator.isNonEmptyArray(notification.bodyLocArgs) &&
380
380
  !validator.isNonEmptyString(notification.bodyLocKey)) {
381
- throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'android.notification.bodyLocKey is required when specifying bodyLocArgs');
381
+ throw new error_1.FirebaseMessagingError(error_1.messagingClientErrorCode.INVALID_PAYLOAD, 'android.notification.bodyLocKey is required when specifying bodyLocArgs');
382
382
  }
383
383
  if (validator.isNonEmptyArray(notification.titleLocArgs) &&
384
384
  !validator.isNonEmptyString(notification.titleLocKey)) {
385
- throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'android.notification.titleLocKey is required when specifying titleLocArgs');
385
+ throw new error_1.FirebaseMessagingError(error_1.messagingClientErrorCode.INVALID_PAYLOAD, 'android.notification.titleLocKey is required when specifying titleLocArgs');
386
386
  }
387
387
  if (typeof notification.imageUrl !== 'undefined' &&
388
388
  !validator.isURL(notification.imageUrl)) {
389
- throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'android.notification.imageUrl must be a valid URL string');
389
+ throw new error_1.FirebaseMessagingError(error_1.messagingClientErrorCode.INVALID_PAYLOAD, 'android.notification.imageUrl must be a valid URL string');
390
390
  }
391
391
  if (typeof notification.eventTimestamp !== 'undefined') {
392
392
  if (!(notification.eventTimestamp instanceof Date)) {
393
- throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'android.notification.eventTimestamp must be a valid `Date` object');
393
+ throw new error_1.FirebaseMessagingError(error_1.messagingClientErrorCode.INVALID_PAYLOAD, 'android.notification.eventTimestamp must be a valid `Date` object');
394
394
  }
395
395
  // Convert timestamp to RFC3339 UTC "Zulu" format, example "2014-10-02T15:01:23.045123456Z"
396
396
  const zuluTimestamp = notification.eventTimestamp.toISOString();
@@ -398,12 +398,12 @@ function validateAndroidNotification(notification) {
398
398
  }
399
399
  if (typeof notification.vibrateTimingsMillis !== 'undefined') {
400
400
  if (!validator.isNonEmptyArray(notification.vibrateTimingsMillis)) {
401
- throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'android.notification.vibrateTimingsMillis must be a non-empty array of numbers');
401
+ throw new error_1.FirebaseMessagingError(error_1.messagingClientErrorCode.INVALID_PAYLOAD, 'android.notification.vibrateTimingsMillis must be a non-empty array of numbers');
402
402
  }
403
403
  const vibrateTimings = [];
404
404
  notification.vibrateTimingsMillis.forEach((value) => {
405
405
  if (!validator.isNumber(value) || value < 0) {
406
- throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'android.notification.vibrateTimingsMillis must be non-negative durations in milliseconds');
406
+ throw new error_1.FirebaseMessagingError(error_1.messagingClientErrorCode.INVALID_PAYLOAD, 'android.notification.vibrateTimingsMillis must be non-negative durations in milliseconds');
407
407
  }
408
408
  const duration = (0, index_1.transformMillisecondsToSecondsString)(value);
409
409
  vibrateTimings.push(duration);
@@ -455,26 +455,26 @@ function validateLightSettings(lightSettings) {
455
455
  return;
456
456
  }
457
457
  else if (!validator.isNonNullObject(lightSettings)) {
458
- throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'android.notification.lightSettings must be a non-null object');
458
+ throw new error_1.FirebaseMessagingError(error_1.messagingClientErrorCode.INVALID_PAYLOAD, 'android.notification.lightSettings must be a non-null object');
459
459
  }
460
460
  if (!validator.isNumber(lightSettings.lightOnDurationMillis) || lightSettings.lightOnDurationMillis < 0) {
461
- throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'android.notification.lightSettings.lightOnDurationMillis must be a non-negative duration in milliseconds');
461
+ throw new error_1.FirebaseMessagingError(error_1.messagingClientErrorCode.INVALID_PAYLOAD, 'android.notification.lightSettings.lightOnDurationMillis must be a non-negative duration in milliseconds');
462
462
  }
463
463
  const durationOn = (0, index_1.transformMillisecondsToSecondsString)(lightSettings.lightOnDurationMillis);
464
464
  lightSettings.lightOnDurationMillis = durationOn;
465
465
  if (!validator.isNumber(lightSettings.lightOffDurationMillis) || lightSettings.lightOffDurationMillis < 0) {
466
- throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'android.notification.lightSettings.lightOffDurationMillis must be a non-negative duration in milliseconds');
466
+ throw new error_1.FirebaseMessagingError(error_1.messagingClientErrorCode.INVALID_PAYLOAD, 'android.notification.lightSettings.lightOffDurationMillis must be a non-negative duration in milliseconds');
467
467
  }
468
468
  const durationOff = (0, index_1.transformMillisecondsToSecondsString)(lightSettings.lightOffDurationMillis);
469
469
  lightSettings.lightOffDurationMillis = durationOff;
470
470
  if (!validator.isString(lightSettings.color) ||
471
471
  (!/^#[0-9a-fA-F]{6}$/.test(lightSettings.color) && !/^#[0-9a-fA-F]{8}$/.test(lightSettings.color))) {
472
- throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'android.notification.lightSettings.color must be in the form #RRGGBB or #RRGGBBAA format');
472
+ throw new error_1.FirebaseMessagingError(error_1.messagingClientErrorCode.INVALID_PAYLOAD, 'android.notification.lightSettings.color must be in the form #RRGGBB or #RRGGBBAA format');
473
473
  }
474
474
  const colorString = lightSettings.color.length === 7 ? lightSettings.color + 'FF' : lightSettings.color;
475
475
  const rgb = /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/i.exec(colorString);
476
476
  if (!rgb || rgb.length < 4) {
477
- throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INTERNAL_ERROR, 'regex to extract rgba values from ' + colorString + ' failed.');
477
+ throw new error_1.FirebaseMessagingError(error_1.messagingClientErrorCode.INTERNAL_ERROR, 'regex to extract rgba values from ' + colorString + ' failed.');
478
478
  }
479
479
  const color = {
480
480
  red: parseInt(rgb[1], 16) / 255.0,
@@ -499,9 +499,9 @@ function validateAndroidFcmOptions(fcmOptions) {
499
499
  return;
500
500
  }
501
501
  else if (!validator.isNonNullObject(fcmOptions)) {
502
- throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'fcmOptions must be a non-null object');
502
+ throw new error_1.FirebaseMessagingError(error_1.messagingClientErrorCode.INVALID_PAYLOAD, 'fcmOptions must be a non-null object');
503
503
  }
504
504
  if (typeof fcmOptions.analyticsLabel !== 'undefined' && !validator.isString(fcmOptions.analyticsLabel)) {
505
- throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'analyticsLabel must be a string value');
505
+ throw new error_1.FirebaseMessagingError(error_1.messagingClientErrorCode.INVALID_PAYLOAD, 'analyticsLabel must be a string value');
506
506
  }
507
507
  }
@@ -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
@@ -19,7 +19,7 @@
19
19
  Object.defineProperty(exports, "__esModule", { value: true });
20
20
  exports.Messaging = void 0;
21
21
  const deep_copy_1 = require("../utils/deep-copy");
22
- const error_1 = require("../utils/error");
22
+ const error_1 = require("./error");
23
23
  const utils = require("../utils");
24
24
  const validator = require("../utils/validator");
25
25
  const messaging_internal_1 = require("./messaging-internal");
@@ -74,7 +74,7 @@ class Messaging {
74
74
  constructor(app) {
75
75
  this.useLegacyTransport = false;
76
76
  if (!validator.isNonNullObject(app) || !('options' in app)) {
77
- throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_ARGUMENT, 'First argument passed to admin.messaging() must be a valid Firebase app instance.');
77
+ throw new error_1.FirebaseMessagingError(error_1.messagingClientErrorCode.INVALID_ARGUMENT, 'First argument passed to admin.messaging() must be a valid Firebase app instance.');
78
78
  }
79
79
  this.appInternal = app;
80
80
  this.messagingRequestHandler = new messaging_api_request_internal_1.FirebaseMessagingRequestHandler(app);
@@ -121,7 +121,7 @@ class Messaging {
121
121
  const copy = (0, deep_copy_1.deepCopy)(message);
122
122
  (0, messaging_internal_1.validateMessage)(copy);
123
123
  if (typeof dryRun !== 'undefined' && !validator.isBoolean(dryRun)) {
124
- throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_ARGUMENT, 'dryRun must be a boolean');
124
+ throw new error_1.FirebaseMessagingError(error_1.messagingClientErrorCode.INVALID_ARGUMENT, 'dryRun must be a boolean');
125
125
  }
126
126
  return this.getUrlPath()
127
127
  .then((urlPath) => {
@@ -162,64 +162,61 @@ class Messaging {
162
162
  }
163
163
  const copy = (0, deep_copy_1.deepCopy)(messages);
164
164
  if (!validator.isNonEmptyArray(copy)) {
165
- throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_ARGUMENT, 'messages must be a non-empty array');
165
+ throw new error_1.FirebaseMessagingError(error_1.messagingClientErrorCode.INVALID_ARGUMENT, 'messages must be a non-empty array');
166
166
  }
167
167
  if (copy.length > FCM_MAX_BATCH_SIZE) {
168
- throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_ARGUMENT, `messages list must not contain more than ${FCM_MAX_BATCH_SIZE} items`);
168
+ throw new error_1.FirebaseMessagingError(error_1.messagingClientErrorCode.INVALID_ARGUMENT, `messages list must not contain more than ${FCM_MAX_BATCH_SIZE} items`);
169
169
  }
170
170
  if (typeof dryRun !== 'undefined' && !validator.isBoolean(dryRun)) {
171
- throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_ARGUMENT, 'dryRun must be a boolean');
171
+ throw new error_1.FirebaseMessagingError(error_1.messagingClientErrorCode.INVALID_ARGUMENT, 'dryRun must be a boolean');
172
172
  }
173
173
  const http2SessionHandler = this.useLegacyTransport ? undefined : new api_request_1.Http2SessionHandler(`https://${FCM_SEND_HOST}`);
174
174
  return this.getUrlPath()
175
175
  .then((urlPath) => {
176
- if (http2SessionHandler) {
177
- let sendResponsePromise;
178
- return new Promise((resolve, reject) => {
179
- // Start session listeners
180
- http2SessionHandler.invoke().catch((error) => {
181
- const pendingBatchResponse = sendResponsePromise ? sendResponsePromise.then(this.parseSendResponses) : undefined;
182
- reject(new error_1.FirebaseMessagingSessionError(error, undefined, pendingBatchResponse));
183
- });
184
- // Start making requests
185
- const requests = copy.map(async (message) => {
186
- (0, messaging_internal_1.validateMessage)(message);
187
- const request = { message };
188
- if (dryRun) {
189
- request.validate_only = true;
190
- }
191
- return this.messagingRequestHandler.invokeHttp2RequestHandlerForSendResponse(FCM_SEND_HOST, urlPath, request, http2SessionHandler);
192
- });
193
- // Resolve once all requests have completed
194
- sendResponsePromise = Promise.allSettled(requests);
195
- sendResponsePromise.then(resolve);
196
- });
197
- }
198
- else {
199
- const requests = copy.map(async (message) => {
200
- (0, messaging_internal_1.validateMessage)(message);
201
- const request = { message };
202
- if (dryRun) {
203
- request.validate_only = true;
204
- }
176
+ const requests = copy.map(async (message) => {
177
+ (0, messaging_internal_1.validateMessage)(message);
178
+ const request = { message };
179
+ if (dryRun) {
180
+ request.validate_only = true;
181
+ }
182
+ if (http2SessionHandler) {
183
+ return this.messagingRequestHandler.invokeHttp2RequestHandlerForSendResponse(FCM_SEND_HOST, urlPath, request, http2SessionHandler);
184
+ }
185
+ else {
205
186
  return this.messagingRequestHandler.invokeHttpRequestHandlerForSendResponse(FCM_SEND_HOST, urlPath, request);
206
- });
207
- return Promise.allSettled(requests);
208
- }
187
+ }
188
+ });
189
+ return Promise.allSettled(requests);
190
+ })
191
+ .then((results) => {
192
+ const sessionErrors = http2SessionHandler ? http2SessionHandler.getErrors() : [];
193
+ return this.parseSendResponses(results, sessionErrors);
209
194
  })
210
- .then(this.parseSendResponses)
211
195
  .finally(() => {
212
196
  http2SessionHandler?.close();
213
197
  });
214
198
  }
215
- parseSendResponses(results) {
199
+ parseSendResponses(results, sessionErrors = []) {
216
200
  const responses = [];
217
201
  results.forEach(result => {
218
202
  if (result.status === 'fulfilled') {
219
203
  responses.push(result.value);
220
204
  }
221
205
  else { // rejected
222
- responses.push({ success: false, error: result.reason });
206
+ let error = result.reason;
207
+ if (sessionErrors.length > 0) {
208
+ // Combine the original stream error and all session errors
209
+ const allErrors = [result.reason, ...sessionErrors];
210
+ const cause = new AggregateError(allErrors, 'Stream failure and session failures occurred');
211
+ const streamMessage = result.reason?.message || 'Unknown stream error';
212
+ const sessionMessage = `. Session failures: ${sessionErrors.map(e => e.message).join(', ')}`;
213
+ error = new error_1.FirebaseMessagingError({
214
+ code: error_1.messagingClientErrorCode.UNKNOWN_ERROR.code,
215
+ message: `${streamMessage}${sessionMessage}`,
216
+ cause: cause
217
+ });
218
+ }
219
+ responses.push({ success: false, error });
223
220
  }
224
221
  });
225
222
  const successCount = responses.filter((resp) => resp.success).length;
@@ -250,13 +247,13 @@ class Messaging {
250
247
  sendEachForMulticast(message, dryRun) {
251
248
  const copy = (0, deep_copy_1.deepCopy)(message);
252
249
  if (!validator.isNonNullObject(copy)) {
253
- throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_ARGUMENT, 'MulticastMessage must be a non-null object');
250
+ throw new error_1.FirebaseMessagingError(error_1.messagingClientErrorCode.INVALID_ARGUMENT, 'MulticastMessage must be a non-null object');
254
251
  }
255
252
  if (!validator.isNonEmptyArray(copy.tokens)) {
256
- throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_ARGUMENT, 'tokens must be a non-empty array');
253
+ throw new error_1.FirebaseMessagingError(error_1.messagingClientErrorCode.INVALID_ARGUMENT, 'tokens must be a non-empty array');
257
254
  }
258
255
  if (copy.tokens.length > FCM_MAX_BATCH_SIZE) {
259
- throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_ARGUMENT, `tokens list must not contain more than ${FCM_MAX_BATCH_SIZE} items`);
256
+ throw new error_1.FirebaseMessagingError(error_1.messagingClientErrorCode.INVALID_ARGUMENT, `tokens list must not contain more than ${FCM_MAX_BATCH_SIZE} items`);
260
257
  }
261
258
  const messages = copy.tokens.map((token) => {
262
259
  return {
@@ -315,7 +312,7 @@ class Messaging {
315
312
  .then((projectId) => {
316
313
  if (!validator.isNonEmptyString(projectId)) {
317
314
  // Assert for an explicit project ID (either via AppOptions or the cert itself).
318
- throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_ARGUMENT, 'Failed to determine project ID for Messaging. Initialize the '
315
+ throw new error_1.FirebaseMessagingError(error_1.messagingClientErrorCode.INVALID_ARGUMENT, 'Failed to determine project ID for Messaging. Initialize the '
319
316
  + 'SDK with service account credentials or set project ID as an app option. '
320
317
  + 'Alternatively set the GOOGLE_CLOUD_PROJECT environment variable.');
321
318
  }
@@ -368,7 +365,7 @@ class Messaging {
368
365
  * @param method - The method name to use in error messages.
369
366
  * @param errorInfo - The error info to use if the registration tokens are invalid.
370
367
  */
371
- validateRegistrationTokensType(registrationTokenOrTokens, methodName, errorInfo = error_1.MessagingClientErrorCode.INVALID_ARGUMENT) {
368
+ validateRegistrationTokensType(registrationTokenOrTokens, methodName, errorInfo = error_1.messagingClientErrorCode.INVALID_ARGUMENT) {
372
369
  if (!validator.isNonEmptyArray(registrationTokenOrTokens) &&
373
370
  !validator.isNonEmptyString(registrationTokenOrTokens)) {
374
371
  throw new error_1.FirebaseMessagingError(errorInfo, `Registration token(s) provided to ${methodName}() must be a non-empty string or a ` +
@@ -383,7 +380,7 @@ class Messaging {
383
380
  * @param method - The method name to use in error messages.
384
381
  * @param errorInfo - The error info to use if the registration tokens are invalid.
385
382
  */
386
- validateRegistrationTokens(registrationTokenOrTokens, methodName, errorInfo = error_1.MessagingClientErrorCode.INVALID_ARGUMENT) {
383
+ validateRegistrationTokens(registrationTokenOrTokens, methodName, errorInfo = error_1.messagingClientErrorCode.INVALID_ARGUMENT) {
387
384
  if (validator.isArray(registrationTokenOrTokens)) {
388
385
  // Validate the array contains no more than 1,000 registration tokens.
389
386
  if (registrationTokenOrTokens.length > 1000) {
@@ -406,7 +403,7 @@ class Messaging {
406
403
  * @param method - The method name to use in error messages.
407
404
  * @param errorInfo - The error info to use if the topic is invalid.
408
405
  */
409
- validateTopicType(topic, methodName, errorInfo = error_1.MessagingClientErrorCode.INVALID_ARGUMENT) {
406
+ validateTopicType(topic, methodName, errorInfo = error_1.messagingClientErrorCode.INVALID_ARGUMENT) {
410
407
  if (!validator.isNonEmptyString(topic)) {
411
408
  throw new error_1.FirebaseMessagingError(errorInfo, `Topic provided to ${methodName}() must be a string which matches the format ` +
412
409
  '"/topics/[a-zA-Z0-9-_.~%]+".');
@@ -419,7 +416,7 @@ class Messaging {
419
416
  * @param method - The method name to use in error messages.
420
417
  * @param errorInfo - The error info to use if the topic is invalid.
421
418
  */
422
- validateTopic(topic, methodName, errorInfo = error_1.MessagingClientErrorCode.INVALID_ARGUMENT) {
419
+ validateTopic(topic, methodName, errorInfo = error_1.messagingClientErrorCode.INVALID_ARGUMENT) {
423
420
  if (!validator.isTopic(topic)) {
424
421
  throw new error_1.FirebaseMessagingError(errorInfo, `Topic provided to ${methodName}() must be a string which matches the format ` +
425
422
  '"/topics/[a-zA-Z0-9-_.~%]+".');
@@ -0,0 +1,43 @@
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 { FirebaseError, ErrorInfo } from '../utils/error';
18
+ /**
19
+ * The constant mapping for valid Phone Number Verification client error codes.
20
+ */
21
+ export declare const PhoneNumberVerificationErrorCode: {
22
+ readonly INVALID_ARGUMENT: "invalid-argument";
23
+ readonly INVALID_TOKEN: "invalid-token";
24
+ readonly EXPIRED_TOKEN: "expired-token";
25
+ };
26
+ /**
27
+ * The type definition for valid Phone Number Verification client error codes.
28
+ */
29
+ export type PhoneNumberVerificationErrorCode = typeof PhoneNumberVerificationErrorCode[keyof typeof PhoneNumberVerificationErrorCode];
30
+ export declare const FPNV_ERROR_CODE_MAPPING: {
31
+ readonly INVALID_ARGUMENT: "invalid-argument";
32
+ readonly INVALID_TOKEN: "invalid-token";
33
+ readonly EXPIRED_TOKEN: "expired-token";
34
+ };
35
+ /**
36
+ * Firebase Phone Number Verification error code structure. This extends `FirebaseError`.
37
+ *
38
+ * @param info - The error code info.
39
+ * @param message - The error message. If provided, this will override the default message.
40
+ */
41
+ export declare class FirebasePhoneNumberVerificationError extends FirebaseError {
42
+ constructor(info: ErrorInfo, message?: string);
43
+ }