firebase-admin 10.3.0 → 11.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 (192) hide show
  1. package/README.md +1 -2
  2. package/lib/app/core.d.ts +1 -1
  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 +8 -8
  6. package/lib/app/credential-internal.d.ts +1 -1
  7. package/lib/app/credential-internal.js +97 -106
  8. package/lib/app/credential.d.ts +1 -1
  9. package/lib/app/credential.js +1 -1
  10. package/lib/app/firebase-app.d.ts +1 -1
  11. package/lib/app/firebase-app.js +76 -91
  12. package/lib/app/firebase-namespace.d.ts +1 -1
  13. package/lib/app/firebase-namespace.js +209 -279
  14. package/lib/app/index.d.ts +1 -1
  15. package/lib/app/index.js +4 -4
  16. package/lib/app/lifecycle.d.ts +1 -1
  17. package/lib/app/lifecycle.js +37 -43
  18. package/lib/app-check/app-check-api-client-internal.d.ts +1 -1
  19. package/lib/app-check/app-check-api-client-internal.js +54 -73
  20. package/lib/app-check/app-check-api.d.ts +1 -1
  21. package/lib/app-check/app-check-api.js +1 -1
  22. package/lib/app-check/app-check-namespace.d.ts +1 -1
  23. package/lib/app-check/app-check-namespace.js +1 -1
  24. package/lib/app-check/app-check.d.ts +1 -1
  25. package/lib/app-check/app-check.js +17 -19
  26. package/lib/app-check/index.d.ts +1 -1
  27. package/lib/app-check/index.js +7 -7
  28. package/lib/app-check/token-generator.d.ts +1 -1
  29. package/lib/app-check/token-generator.js +47 -52
  30. package/lib/app-check/token-verifier.d.ts +1 -1
  31. package/lib/app-check/token-verifier.js +46 -50
  32. package/lib/auth/action-code-settings-builder.d.ts +1 -1
  33. package/lib/auth/action-code-settings-builder.js +10 -11
  34. package/lib/auth/auth-api-request.d.ts +1 -1
  35. package/lib/auth/auth-api-request.js +346 -393
  36. package/lib/auth/auth-config.d.ts +1 -1
  37. package/lib/auth/auth-config.js +95 -106
  38. package/lib/auth/auth-namespace.d.ts +1 -1
  39. package/lib/auth/auth-namespace.js +1 -1
  40. package/lib/auth/auth.d.ts +1 -1
  41. package/lib/auth/auth.js +20 -40
  42. package/lib/auth/base-auth.d.ts +1 -1
  43. package/lib/auth/base-auth.js +137 -144
  44. package/lib/auth/identifier.d.ts +1 -1
  45. package/lib/auth/identifier.js +2 -2
  46. package/lib/auth/index.d.ts +1 -1
  47. package/lib/auth/index.js +7 -7
  48. package/lib/auth/tenant-manager.d.ts +1 -1
  49. package/lib/auth/tenant-manager.js +49 -71
  50. package/lib/auth/tenant.d.ts +1 -1
  51. package/lib/auth/tenant.js +44 -55
  52. package/lib/auth/token-generator.d.ts +1 -1
  53. package/lib/auth/token-generator.js +49 -53
  54. package/lib/auth/token-verifier.d.ts +1 -1
  55. package/lib/auth/token-verifier.js +83 -91
  56. package/lib/auth/user-import-builder.d.ts +1 -1
  57. package/lib/auth/user-import-builder.js +70 -73
  58. package/lib/auth/user-record.d.ts +1 -1
  59. package/lib/auth/user-record.js +61 -84
  60. package/lib/credential/index.d.ts +1 -1
  61. package/lib/credential/index.js +2 -2
  62. package/lib/database/database-namespace.d.ts +1 -1
  63. package/lib/database/database-namespace.js +1 -1
  64. package/lib/database/database.d.ts +1 -1
  65. package/lib/database/database.js +92 -108
  66. package/lib/database/index.d.ts +1 -1
  67. package/lib/database/index.js +10 -10
  68. package/lib/default-namespace.d.ts +1 -1
  69. package/lib/default-namespace.js +2 -2
  70. package/lib/eventarc/cloudevent.d.ts +1 -1
  71. package/lib/eventarc/cloudevent.js +1 -1
  72. package/lib/eventarc/eventarc-client-internal.d.ts +1 -1
  73. package/lib/eventarc/eventarc-client-internal.js +63 -129
  74. package/lib/eventarc/eventarc-utils.d.ts +1 -1
  75. package/lib/eventarc/eventarc-utils.js +16 -32
  76. package/lib/eventarc/eventarc.d.ts +1 -1
  77. package/lib/eventarc/eventarc.js +51 -65
  78. package/lib/eventarc/index.d.ts +1 -1
  79. package/lib/eventarc/index.js +7 -7
  80. package/lib/firebase-namespace-api.d.ts +1 -1
  81. package/lib/firebase-namespace-api.js +8 -3
  82. package/lib/firestore/firestore-internal.d.ts +1 -1
  83. package/lib/firestore/firestore-internal.js +28 -37
  84. package/lib/firestore/firestore-namespace.d.ts +9 -1
  85. package/lib/firestore/firestore-namespace.js +2 -2
  86. package/lib/firestore/index.d.ts +2 -2
  87. package/lib/firestore/index.js +7 -7
  88. package/lib/functions/functions-api-client-internal.d.ts +1 -1
  89. package/lib/functions/functions-api-client-internal.js +71 -93
  90. package/lib/functions/functions-api.d.ts +1 -1
  91. package/lib/functions/functions-api.js +1 -1
  92. package/lib/functions/functions.d.ts +1 -1
  93. package/lib/functions/functions.js +13 -15
  94. package/lib/functions/index.d.ts +1 -1
  95. package/lib/functions/index.js +7 -7
  96. package/lib/index.d.ts +1 -1
  97. package/lib/index.js +14 -4
  98. package/lib/installations/index.d.ts +1 -1
  99. package/lib/installations/index.js +6 -6
  100. package/lib/installations/installations-namespace.d.ts +1 -1
  101. package/lib/installations/installations-namespace.js +1 -1
  102. package/lib/installations/installations-request-handler.d.ts +1 -1
  103. package/lib/installations/installations-request-handler.js +33 -36
  104. package/lib/installations/installations.d.ts +1 -1
  105. package/lib/installations/installations.js +17 -22
  106. package/lib/instance-id/index.d.ts +1 -1
  107. package/lib/instance-id/index.js +6 -6
  108. package/lib/instance-id/instance-id-namespace.d.ts +1 -1
  109. package/lib/instance-id/instance-id-namespace.js +1 -1
  110. package/lib/instance-id/instance-id.d.ts +1 -1
  111. package/lib/instance-id/instance-id.js +21 -26
  112. package/lib/machine-learning/index.d.ts +1 -1
  113. package/lib/machine-learning/index.js +7 -7
  114. package/lib/machine-learning/machine-learning-api-client.d.ts +1 -1
  115. package/lib/machine-learning/machine-learning-api-client.js +110 -124
  116. package/lib/machine-learning/machine-learning-namespace.d.ts +1 -1
  117. package/lib/machine-learning/machine-learning-namespace.js +1 -1
  118. package/lib/machine-learning/machine-learning-utils.d.ts +1 -1
  119. package/lib/machine-learning/machine-learning-utils.js +9 -24
  120. package/lib/machine-learning/machine-learning.d.ts +1 -1
  121. package/lib/machine-learning/machine-learning.js +146 -207
  122. package/lib/messaging/batch-request-internal.d.ts +1 -1
  123. package/lib/messaging/batch-request-internal.js +33 -35
  124. package/lib/messaging/index.d.ts +1 -1
  125. package/lib/messaging/index.js +7 -7
  126. package/lib/messaging/messaging-api-request-internal.d.ts +1 -1
  127. package/lib/messaging/messaging-api-request-internal.js +38 -40
  128. package/lib/messaging/messaging-api.d.ts +1 -1
  129. package/lib/messaging/messaging-api.js +1 -1
  130. package/lib/messaging/messaging-errors-internal.d.ts +1 -1
  131. package/lib/messaging/messaging-errors-internal.js +12 -13
  132. package/lib/messaging/messaging-internal.d.ts +1 -1
  133. package/lib/messaging/messaging-internal.js +51 -51
  134. package/lib/messaging/messaging-namespace.d.ts +1 -1
  135. package/lib/messaging/messaging-namespace.js +1 -1
  136. package/lib/messaging/messaging.d.ts +1 -1
  137. package/lib/messaging/messaging.js +184 -208
  138. package/lib/project-management/android-app.d.ts +1 -1
  139. package/lib/project-management/android-app.js +41 -43
  140. package/lib/project-management/app-metadata.d.ts +1 -1
  141. package/lib/project-management/app-metadata.js +1 -1
  142. package/lib/project-management/index.d.ts +1 -1
  143. package/lib/project-management/index.js +7 -7
  144. package/lib/project-management/ios-app.d.ts +1 -1
  145. package/lib/project-management/ios-app.js +25 -26
  146. package/lib/project-management/project-management-api-request-internal.d.ts +1 -1
  147. package/lib/project-management/project-management-api-request-internal.js +84 -89
  148. package/lib/project-management/project-management-namespace.d.ts +1 -1
  149. package/lib/project-management/project-management-namespace.js +1 -1
  150. package/lib/project-management/project-management.d.ts +1 -1
  151. package/lib/project-management/project-management.js +80 -87
  152. package/lib/remote-config/index.d.ts +1 -1
  153. package/lib/remote-config/index.js +7 -7
  154. package/lib/remote-config/remote-config-api-client-internal.d.ts +1 -1
  155. package/lib/remote-config/remote-config-api-client-internal.js +116 -154
  156. package/lib/remote-config/remote-config-api.d.ts +1 -1
  157. package/lib/remote-config/remote-config-api.js +1 -1
  158. package/lib/remote-config/remote-config-namespace.d.ts +1 -1
  159. package/lib/remote-config/remote-config-namespace.js +1 -1
  160. package/lib/remote-config/remote-config.d.ts +1 -1
  161. package/lib/remote-config/remote-config.js +51 -59
  162. package/lib/security-rules/index.d.ts +1 -1
  163. package/lib/security-rules/index.js +7 -7
  164. package/lib/security-rules/security-rules-api-client-internal.d.ts +1 -1
  165. package/lib/security-rules/security-rules-api-client-internal.js +95 -107
  166. package/lib/security-rules/security-rules-internal.d.ts +1 -1
  167. package/lib/security-rules/security-rules-internal.js +6 -21
  168. package/lib/security-rules/security-rules-namespace.d.ts +1 -1
  169. package/lib/security-rules/security-rules-namespace.js +1 -1
  170. package/lib/security-rules/security-rules.d.ts +1 -1
  171. package/lib/security-rules/security-rules.js +82 -91
  172. package/lib/storage/index.d.ts +1 -1
  173. package/lib/storage/index.js +7 -7
  174. package/lib/storage/storage-namespace.d.ts +1 -1
  175. package/lib/storage/storage-namespace.js +1 -1
  176. package/lib/storage/storage.d.ts +1 -1
  177. package/lib/storage/storage.js +25 -30
  178. package/lib/utils/api-request.d.ts +3 -1
  179. package/lib/utils/api-request.js +278 -356
  180. package/lib/utils/crypto-signer.d.ts +1 -1
  181. package/lib/utils/crypto-signer.js +58 -93
  182. package/lib/utils/deep-copy.d.ts +1 -1
  183. package/lib/utils/deep-copy.js +3 -3
  184. package/lib/utils/error.d.ts +1 -1
  185. package/lib/utils/error.js +611 -681
  186. package/lib/utils/index.d.ts +1 -1
  187. package/lib/utils/index.js +38 -43
  188. package/lib/utils/jwt.d.ts +1 -1
  189. package/lib/utils/jwt.js +97 -123
  190. package/lib/utils/validator.d.ts +1 -1
  191. package/lib/utils/validator.js +13 -13
  192. package/package.json +5 -5
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v10.3.0 */
1
+ /*! firebase-admin v11.0.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2020 Google Inc.
@@ -16,14 +16,14 @@
16
16
  * limitations under the License.
17
17
  */
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
- exports.getMessaging = void 0;
19
+ exports.getMessaging = exports.Messaging = void 0;
20
20
  /**
21
21
  * Firebase Cloud Messaging (FCM).
22
22
  *
23
23
  * @packageDocumentation
24
24
  */
25
- var app_1 = require("../app");
26
- var messaging_1 = require("./messaging");
25
+ const app_1 = require("../app");
26
+ const messaging_1 = require("./messaging");
27
27
  var messaging_2 = require("./messaging");
28
28
  Object.defineProperty(exports, "Messaging", { enumerable: true, get: function () { return messaging_2.Messaging; } });
29
29
  /**
@@ -54,9 +54,9 @@ Object.defineProperty(exports, "Messaging", { enumerable: true, get: function ()
54
54
  */
55
55
  function getMessaging(app) {
56
56
  if (typeof app === 'undefined') {
57
- app = app_1.getApp();
57
+ app = (0, app_1.getApp)();
58
58
  }
59
- var firebaseApp = app;
60
- return firebaseApp.getOrInitService('messaging', function (app) { return new messaging_1.Messaging(app); });
59
+ const firebaseApp = app;
60
+ return firebaseApp.getOrInitService('messaging', (app) => new messaging_1.Messaging(app));
61
61
  }
62
62
  exports.getMessaging = getMessaging;
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v10.3.0 */
1
+ /*! firebase-admin v11.0.0 */
2
2
  /*!
3
3
  * @license
4
4
  * Copyright 2017 Google Inc.
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v10.3.0 */
1
+ /*! firebase-admin v11.0.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * @license
@@ -18,30 +18,30 @@
18
18
  */
19
19
  Object.defineProperty(exports, "__esModule", { value: true });
20
20
  exports.FirebaseMessagingRequestHandler = void 0;
21
- var api_request_1 = require("../utils/api-request");
22
- var messaging_errors_internal_1 = require("./messaging-errors-internal");
23
- var batch_request_internal_1 = require("./batch-request-internal");
24
- var index_1 = require("../utils/index");
21
+ const api_request_1 = require("../utils/api-request");
22
+ const messaging_errors_internal_1 = require("./messaging-errors-internal");
23
+ const batch_request_internal_1 = require("./batch-request-internal");
24
+ const index_1 = require("../utils/index");
25
25
  // FCM backend constants
26
- var FIREBASE_MESSAGING_TIMEOUT = 10000;
27
- var FIREBASE_MESSAGING_BATCH_URL = 'https://fcm.googleapis.com/batch';
28
- var FIREBASE_MESSAGING_HTTP_METHOD = 'POST';
29
- var FIREBASE_MESSAGING_HEADERS = {
30
- 'X-Firebase-Client': "fire-admin-node/" + index_1.getSdkVersion(),
26
+ const FIREBASE_MESSAGING_TIMEOUT = 10000;
27
+ const FIREBASE_MESSAGING_BATCH_URL = 'https://fcm.googleapis.com/batch';
28
+ const FIREBASE_MESSAGING_HTTP_METHOD = 'POST';
29
+ const FIREBASE_MESSAGING_HEADERS = {
30
+ 'X-Firebase-Client': `fire-admin-node/${(0, index_1.getSdkVersion)()}`,
31
31
  };
32
- var LEGACY_FIREBASE_MESSAGING_HEADERS = {
33
- 'X-Firebase-Client': "fire-admin-node/" + index_1.getSdkVersion(),
32
+ const LEGACY_FIREBASE_MESSAGING_HEADERS = {
33
+ 'X-Firebase-Client': `fire-admin-node/${(0, index_1.getSdkVersion)()}`,
34
34
  'access_token_auth': 'true',
35
35
  };
36
36
  /**
37
37
  * Class that provides a mechanism to send requests to the Firebase Cloud Messaging backend.
38
38
  */
39
- var FirebaseMessagingRequestHandler = /** @class */ (function () {
39
+ class FirebaseMessagingRequestHandler {
40
40
  /**
41
41
  * @param app - The app used to fetch access tokens to sign API requests.
42
42
  * @constructor
43
43
  */
44
- function FirebaseMessagingRequestHandler(app) {
44
+ constructor(app) {
45
45
  this.httpClient = new api_request_1.AuthorizedHttpClient(app);
46
46
  this.batchClient = new batch_request_internal_1.BatchRequestClient(this.httpClient, FIREBASE_MESSAGING_BATCH_URL, FIREBASE_MESSAGING_HEADERS);
47
47
  }
@@ -53,35 +53,35 @@ var FirebaseMessagingRequestHandler = /** @class */ (function () {
53
53
  * @param requestData - The request data.
54
54
  * @returns A promise that resolves with the response.
55
55
  */
56
- FirebaseMessagingRequestHandler.prototype.invokeRequestHandler = function (host, path, requestData) {
57
- var request = {
56
+ invokeRequestHandler(host, path, requestData) {
57
+ const request = {
58
58
  method: FIREBASE_MESSAGING_HTTP_METHOD,
59
- url: "https://" + host + path,
59
+ url: `https://${host}${path}`,
60
60
  data: requestData,
61
61
  headers: LEGACY_FIREBASE_MESSAGING_HEADERS,
62
62
  timeout: FIREBASE_MESSAGING_TIMEOUT,
63
63
  };
64
- return this.httpClient.send(request).then(function (response) {
64
+ return this.httpClient.send(request).then((response) => {
65
65
  // Send non-JSON responses to the catch() below where they will be treated as errors.
66
66
  if (!response.isJson()) {
67
67
  throw new api_request_1.HttpError(response);
68
68
  }
69
69
  // Check for backend errors in the response.
70
- var errorCode = messaging_errors_internal_1.getErrorCode(response.data);
70
+ const errorCode = (0, messaging_errors_internal_1.getErrorCode)(response.data);
71
71
  if (errorCode) {
72
72
  throw new api_request_1.HttpError(response);
73
73
  }
74
74
  // Return entire response.
75
75
  return response.data;
76
76
  })
77
- .catch(function (err) {
77
+ .catch((err) => {
78
78
  if (err instanceof api_request_1.HttpError) {
79
- throw messaging_errors_internal_1.createFirebaseError(err);
79
+ throw (0, messaging_errors_internal_1.createFirebaseError)(err);
80
80
  }
81
81
  // Re-throw the error if it already has the proper format.
82
82
  throw err;
83
83
  });
84
- };
84
+ }
85
85
  /**
86
86
  * Sends the given array of sub requests as a single batch to FCM, and parses the result into
87
87
  * a BatchResponse object.
@@ -89,40 +89,38 @@ var FirebaseMessagingRequestHandler = /** @class */ (function () {
89
89
  * @param requests - An array of sub requests to send.
90
90
  * @returns A promise that resolves when the send operation is complete.
91
91
  */
92
- FirebaseMessagingRequestHandler.prototype.sendBatchRequest = function (requests) {
93
- var _this = this;
92
+ sendBatchRequest(requests) {
94
93
  return this.batchClient.send(requests)
95
- .then(function (responses) {
96
- return responses.map(function (part) {
97
- return _this.buildSendResponse(part);
94
+ .then((responses) => {
95
+ return responses.map((part) => {
96
+ return this.buildSendResponse(part);
98
97
  });
99
- }).then(function (responses) {
100
- var successCount = responses.filter(function (resp) { return resp.success; }).length;
98
+ }).then((responses) => {
99
+ const successCount = responses.filter((resp) => resp.success).length;
101
100
  return {
102
- responses: responses,
103
- successCount: successCount,
101
+ responses,
102
+ successCount,
104
103
  failureCount: responses.length - successCount,
105
104
  };
106
- }).catch(function (err) {
105
+ }).catch((err) => {
107
106
  if (err instanceof api_request_1.HttpError) {
108
- throw messaging_errors_internal_1.createFirebaseError(err);
107
+ throw (0, messaging_errors_internal_1.createFirebaseError)(err);
109
108
  }
110
109
  // Re-throw the error if it already has the proper format.
111
110
  throw err;
112
111
  });
113
- };
114
- FirebaseMessagingRequestHandler.prototype.buildSendResponse = function (response) {
115
- var result = {
112
+ }
113
+ buildSendResponse(response) {
114
+ const result = {
116
115
  success: response.status === 200,
117
116
  };
118
117
  if (result.success) {
119
118
  result.messageId = response.data.name;
120
119
  }
121
120
  else {
122
- result.error = messaging_errors_internal_1.createFirebaseError(new api_request_1.HttpError(response));
121
+ result.error = (0, messaging_errors_internal_1.createFirebaseError)(new api_request_1.HttpError(response));
123
122
  }
124
123
  return result;
125
- };
126
- return FirebaseMessagingRequestHandler;
127
- }());
124
+ }
125
+ }
128
126
  exports.FirebaseMessagingRequestHandler = FirebaseMessagingRequestHandler;
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v10.3.0 */
1
+ /*! firebase-admin v11.0.0 */
2
2
  /*!
3
3
  * @license
4
4
  * Copyright 2021 Google Inc.
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v10.3.0 */
1
+ /*! firebase-admin v11.0.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * @license
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v10.3.0 */
1
+ /*! firebase-admin v11.0.0 */
2
2
  /*!
3
3
  * Copyright 2019 Google Inc.
4
4
  *
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v10.3.0 */
1
+ /*! firebase-admin v11.0.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2019 Google Inc.
@@ -17,8 +17,8 @@
17
17
  */
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
19
  exports.getErrorCode = exports.createFirebaseError = void 0;
20
- var error_1 = require("../utils/error");
21
- var validator = require("../utils/validator");
20
+ const error_1 = require("../utils/error");
21
+ const validator = require("../utils/validator");
22
22
  /**
23
23
  * Creates a new FirebaseMessagingError by extracting the error code, message and other relevant
24
24
  * details from an HTTP error response.
@@ -29,13 +29,13 @@ var validator = require("../utils/validator");
29
29
  function createFirebaseError(err) {
30
30
  if (err.response.isJson()) {
31
31
  // For JSON responses, map the server response to a client-side error.
32
- var json = err.response.data;
33
- var errorCode = getErrorCode(json);
34
- var errorMessage = getErrorMessage(json);
32
+ const json = err.response.data;
33
+ const errorCode = getErrorCode(json);
34
+ const errorMessage = getErrorMessage(json);
35
35
  return error_1.FirebaseMessagingError.fromServerError(errorCode, errorMessage, json);
36
36
  }
37
37
  // Non-JSON response
38
- var error;
38
+ let error;
39
39
  switch (err.response.status) {
40
40
  case 400:
41
41
  error = error_1.MessagingClientErrorCode.INVALID_ARGUMENT;
@@ -56,8 +56,8 @@ function createFirebaseError(err) {
56
56
  }
57
57
  return new error_1.FirebaseMessagingError({
58
58
  code: error.code,
59
- message: error.message + " Raw server response: \"" + err.response.text + "\". Status code: " +
60
- (err.response.status + "."),
59
+ message: `${error.message} Raw server response: "${err.response.text}". Status code: ` +
60
+ `${err.response.status}.`,
61
61
  });
62
62
  }
63
63
  exports.createFirebaseError = createFirebaseError;
@@ -67,14 +67,13 @@ exports.createFirebaseError = createFirebaseError;
67
67
  */
68
68
  function getErrorCode(response) {
69
69
  if (validator.isNonNullObject(response) && 'error' in response) {
70
- var error = response.error;
70
+ const error = response.error;
71
71
  if (validator.isString(error)) {
72
72
  return error;
73
73
  }
74
74
  if (validator.isArray(error.details)) {
75
- var fcmErrorType = 'type.googleapis.com/google.firebase.fcm.v1.FcmError';
76
- for (var _i = 0, _a = error.details; _i < _a.length; _i++) {
77
- var element = _a[_i];
75
+ const fcmErrorType = 'type.googleapis.com/google.firebase.fcm.v1.FcmError';
76
+ for (const element of error.details) {
78
77
  if (element['@type'] === fcmErrorType) {
79
78
  return element.errorCode;
80
79
  }
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v10.3.0 */
1
+ /*! firebase-admin v11.0.0 */
2
2
  /*!
3
3
  * Copyright 2020 Google Inc.
4
4
  *
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v10.3.0 */
1
+ /*! firebase-admin v11.0.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2020 Google Inc.
@@ -17,9 +17,9 @@
17
17
  */
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
19
  exports.validateMessage = exports.BLACKLISTED_OPTIONS_KEYS = exports.BLACKLISTED_DATA_PAYLOAD_KEYS = void 0;
20
- var index_1 = require("../utils/index");
21
- var error_1 = require("../utils/error");
22
- var validator = require("../utils/validator");
20
+ const index_1 = require("../utils/index");
21
+ const error_1 = require("../utils/error");
22
+ const validator = require("../utils/validator");
23
23
  // Keys which are not allowed in the messaging data payload object.
24
24
  exports.BLACKLISTED_DATA_PAYLOAD_KEYS = ['from'];
25
25
  // Keys which are not allowed in the messaging options object.
@@ -37,7 +37,7 @@ function validateMessage(message) {
37
37
  if (!validator.isNonNullObject(message)) {
38
38
  throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'Message must be a non-null object');
39
39
  }
40
- var anyMessage = message;
40
+ const anyMessage = message;
41
41
  if (anyMessage.topic) {
42
42
  // If the topic name is prefixed, remove it.
43
43
  if (anyMessage.topic.startsWith('/topics/')) {
@@ -48,8 +48,8 @@ function validateMessage(message) {
48
48
  throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'Malformed topic name');
49
49
  }
50
50
  }
51
- var targets = [anyMessage.token, anyMessage.topic, anyMessage.condition];
52
- if (targets.filter(function (v) { return validator.isNonEmptyString(v); }).length !== 1) {
51
+ const targets = [anyMessage.token, anyMessage.topic, anyMessage.condition];
52
+ if (targets.filter((v) => validator.isNonEmptyString(v)).length !== 1) {
53
53
  throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'Exactly one of topic, token or condition is required');
54
54
  }
55
55
  validateStringMap(message.data, 'data');
@@ -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
- Object.keys(map).forEach(function (key) {
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
  }
@@ -130,15 +130,15 @@ function validateApnsFcmOptions(fcmOptions) {
130
130
  if (typeof fcmOptions.analyticsLabel !== 'undefined' && !validator.isString(fcmOptions.analyticsLabel)) {
131
131
  throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'analyticsLabel must be a string value');
132
132
  }
133
- var propertyMappings = {
133
+ const propertyMappings = {
134
134
  imageUrl: 'image',
135
135
  };
136
- Object.keys(propertyMappings).forEach(function (key) {
136
+ Object.keys(propertyMappings).forEach((key) => {
137
137
  if (key in fcmOptions && propertyMappings[key] in fcmOptions) {
138
- throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, "Multiple specifications for " + key + " in ApnsFcmOptions");
138
+ throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, `Multiple specifications for ${key} in ApnsFcmOptions`);
139
139
  }
140
140
  });
141
- index_1.renameProperties(fcmOptions, propertyMappings);
141
+ (0, index_1.renameProperties)(fcmOptions, propertyMappings);
142
142
  }
143
143
  /**
144
144
  * Checks if the given FcmOptions object is valid.
@@ -171,15 +171,15 @@ function validateNotification(notification) {
171
171
  if (typeof notification.imageUrl !== 'undefined' && !validator.isURL(notification.imageUrl)) {
172
172
  throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'notification.imageUrl must be a valid URL string');
173
173
  }
174
- var propertyMappings = {
174
+ const propertyMappings = {
175
175
  imageUrl: 'image',
176
176
  };
177
- Object.keys(propertyMappings).forEach(function (key) {
177
+ Object.keys(propertyMappings).forEach((key) => {
178
178
  if (key in notification && propertyMappings[key] in notification) {
179
- throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, "Multiple specifications for " + key + " in Notification");
179
+ throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, `Multiple specifications for ${key} in Notification`);
180
180
  }
181
181
  });
182
- index_1.renameProperties(notification, propertyMappings);
182
+ (0, index_1.renameProperties)(notification, propertyMappings);
183
183
  }
184
184
  /**
185
185
  * Checks if the given ApnsPayload object is valid. The object must have a valid aps value.
@@ -210,18 +210,18 @@ function validateAps(aps) {
210
210
  }
211
211
  validateApsAlert(aps.alert);
212
212
  validateApsSound(aps.sound);
213
- var propertyMappings = {
213
+ const propertyMappings = {
214
214
  contentAvailable: 'content-available',
215
215
  mutableContent: 'mutable-content',
216
216
  threadId: 'thread-id',
217
217
  };
218
- Object.keys(propertyMappings).forEach(function (key) {
218
+ Object.keys(propertyMappings).forEach((key) => {
219
219
  if (key in aps && propertyMappings[key] in aps) {
220
- throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, "Multiple specifications for " + key + " in Aps");
220
+ throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, `Multiple specifications for ${key} in Aps`);
221
221
  }
222
222
  });
223
- index_1.renameProperties(aps, propertyMappings);
224
- var contentAvailable = aps['content-available'];
223
+ (0, index_1.renameProperties)(aps, propertyMappings);
224
+ const contentAvailable = aps['content-available'];
225
225
  if (typeof contentAvailable !== 'undefined' && contentAvailable !== 1) {
226
226
  if (contentAvailable === true) {
227
227
  aps['content-available'] = 1;
@@ -230,7 +230,7 @@ function validateAps(aps) {
230
230
  delete aps['content-available'];
231
231
  }
232
232
  }
233
- var mutableContent = aps['mutable-content'];
233
+ const mutableContent = aps['mutable-content'];
234
234
  if (typeof mutableContent !== 'undefined' && mutableContent !== 1) {
235
235
  if (mutableContent === true) {
236
236
  aps['mutable-content'] = 1;
@@ -250,7 +250,7 @@ function validateApsSound(sound) {
250
250
  if (!validator.isNonEmptyString(sound.name)) {
251
251
  throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'apns.payload.aps.sound.name must be a non-empty string');
252
252
  }
253
- var volume = sound.volume;
253
+ const volume = sound.volume;
254
254
  if (typeof volume !== 'undefined') {
255
255
  if (!validator.isNumber(volume)) {
256
256
  throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'apns.payload.aps.sound.volume must be a number');
@@ -259,9 +259,9 @@ function validateApsSound(sound) {
259
259
  throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'apns.payload.aps.sound.volume must be in the interval [0, 1]');
260
260
  }
261
261
  }
262
- var soundObject = sound;
263
- var key = 'critical';
264
- var critical = soundObject[key];
262
+ const soundObject = sound;
263
+ const key = 'critical';
264
+ const critical = soundObject[key];
265
265
  if (typeof critical !== 'undefined' && critical !== 1) {
266
266
  if (critical === true) {
267
267
  soundObject[key] = 1;
@@ -285,7 +285,7 @@ function validateApsAlert(alert) {
285
285
  else if (!validator.isNonNullObject(alert)) {
286
286
  throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'apns.payload.aps.alert must be a string or a non-null object');
287
287
  }
288
- var apsAlert = alert;
288
+ const apsAlert = alert;
289
289
  if (validator.isNonEmptyArray(apsAlert.locArgs) &&
290
290
  !validator.isNonEmptyString(apsAlert.locKey)) {
291
291
  throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'apns.payload.aps.alert.locKey is required when specifying locArgs');
@@ -298,7 +298,7 @@ function validateApsAlert(alert) {
298
298
  !validator.isNonEmptyString(apsAlert.subtitleLocKey)) {
299
299
  throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'apns.payload.aps.alert.subtitleLocKey is required when specifying subtitleLocArgs');
300
300
  }
301
- var propertyMappings = {
301
+ const propertyMappings = {
302
302
  locKey: 'loc-key',
303
303
  locArgs: 'loc-args',
304
304
  titleLocKey: 'title-loc-key',
@@ -308,7 +308,7 @@ function validateApsAlert(alert) {
308
308
  actionLocKey: 'action-loc-key',
309
309
  launchImage: 'launch-image',
310
310
  };
311
- index_1.renameProperties(apsAlert, propertyMappings);
311
+ (0, index_1.renameProperties)(apsAlert, propertyMappings);
312
312
  }
313
313
  /**
314
314
  * Checks if the given AndroidConfig object is valid. The object must have valid ttl, data,
@@ -328,17 +328,17 @@ function validateAndroidConfig(config) {
328
328
  if (!validator.isNumber(config.ttl) || config.ttl < 0) {
329
329
  throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'TTL must be a non-negative duration in milliseconds');
330
330
  }
331
- var duration = index_1.transformMillisecondsToSecondsString(config.ttl);
331
+ const duration = (0, index_1.transformMillisecondsToSecondsString)(config.ttl);
332
332
  config.ttl = duration;
333
333
  }
334
334
  validateStringMap(config.data, 'android.data');
335
335
  validateAndroidNotification(config.notification);
336
336
  validateAndroidFcmOptions(config.fcmOptions);
337
- var propertyMappings = {
337
+ const propertyMappings = {
338
338
  collapseKey: 'collapse_key',
339
339
  restrictedPackageName: 'restricted_package_name',
340
340
  };
341
- index_1.renameProperties(config, propertyMappings);
341
+ (0, index_1.renameProperties)(config, propertyMappings);
342
342
  }
343
343
  /**
344
344
  * Checks if the given AndroidNotification object is valid. The object must have valid color and
@@ -374,33 +374,33 @@ function validateAndroidNotification(notification) {
374
374
  throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'android.notification.eventTimestamp must be a valid `Date` object');
375
375
  }
376
376
  // Convert timestamp to RFC3339 UTC "Zulu" format, example "2014-10-02T15:01:23.045123456Z"
377
- var zuluTimestamp = notification.eventTimestamp.toISOString();
377
+ const zuluTimestamp = notification.eventTimestamp.toISOString();
378
378
  notification.eventTimestamp = zuluTimestamp;
379
379
  }
380
380
  if (typeof notification.vibrateTimingsMillis !== 'undefined') {
381
381
  if (!validator.isNonEmptyArray(notification.vibrateTimingsMillis)) {
382
382
  throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'android.notification.vibrateTimingsMillis must be a non-empty array of numbers');
383
383
  }
384
- var vibrateTimings_1 = [];
385
- notification.vibrateTimingsMillis.forEach(function (value) {
384
+ const vibrateTimings = [];
385
+ notification.vibrateTimingsMillis.forEach((value) => {
386
386
  if (!validator.isNumber(value) || value < 0) {
387
387
  throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'android.notification.vibrateTimingsMillis must be non-negative durations in milliseconds');
388
388
  }
389
- var duration = index_1.transformMillisecondsToSecondsString(value);
390
- vibrateTimings_1.push(duration);
389
+ const duration = (0, index_1.transformMillisecondsToSecondsString)(value);
390
+ vibrateTimings.push(duration);
391
391
  });
392
- notification.vibrateTimingsMillis = vibrateTimings_1;
392
+ notification.vibrateTimingsMillis = vibrateTimings;
393
393
  }
394
394
  if (typeof notification.priority !== 'undefined') {
395
- var priority = 'PRIORITY_' + notification.priority.toUpperCase();
395
+ const priority = 'PRIORITY_' + notification.priority.toUpperCase();
396
396
  notification.priority = priority;
397
397
  }
398
398
  if (typeof notification.visibility !== 'undefined') {
399
- var visibility = notification.visibility.toUpperCase();
399
+ const visibility = notification.visibility.toUpperCase();
400
400
  notification.visibility = visibility;
401
401
  }
402
402
  validateLightSettings(notification.lightSettings);
403
- var propertyMappings = {
403
+ const propertyMappings = {
404
404
  clickAction: 'click_action',
405
405
  bodyLocKey: 'body_loc_key',
406
406
  bodyLocArgs: 'body_loc_args',
@@ -418,7 +418,7 @@ function validateAndroidNotification(notification) {
418
418
  defaultLightSettings: 'default_light_settings',
419
419
  notificationCount: 'notification_count',
420
420
  };
421
- index_1.renameProperties(notification, propertyMappings);
421
+ (0, index_1.renameProperties)(notification, propertyMappings);
422
422
  }
423
423
  /**
424
424
  * Checks if the given LightSettings object is valid. The object must have valid color and
@@ -437,34 +437,34 @@ function validateLightSettings(lightSettings) {
437
437
  if (!validator.isNumber(lightSettings.lightOnDurationMillis) || lightSettings.lightOnDurationMillis < 0) {
438
438
  throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'android.notification.lightSettings.lightOnDurationMillis must be a non-negative duration in milliseconds');
439
439
  }
440
- var durationOn = index_1.transformMillisecondsToSecondsString(lightSettings.lightOnDurationMillis);
440
+ const durationOn = (0, index_1.transformMillisecondsToSecondsString)(lightSettings.lightOnDurationMillis);
441
441
  lightSettings.lightOnDurationMillis = durationOn;
442
442
  if (!validator.isNumber(lightSettings.lightOffDurationMillis) || lightSettings.lightOffDurationMillis < 0) {
443
443
  throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'android.notification.lightSettings.lightOffDurationMillis must be a non-negative duration in milliseconds');
444
444
  }
445
- var durationOff = index_1.transformMillisecondsToSecondsString(lightSettings.lightOffDurationMillis);
445
+ const durationOff = (0, index_1.transformMillisecondsToSecondsString)(lightSettings.lightOffDurationMillis);
446
446
  lightSettings.lightOffDurationMillis = durationOff;
447
447
  if (!validator.isString(lightSettings.color) ||
448
448
  (!/^#[0-9a-fA-F]{6}$/.test(lightSettings.color) && !/^#[0-9a-fA-F]{8}$/.test(lightSettings.color))) {
449
449
  throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'android.notification.lightSettings.color must be in the form #RRGGBB or #RRGGBBAA format');
450
450
  }
451
- var colorString = lightSettings.color.length === 7 ? lightSettings.color + 'FF' : lightSettings.color;
452
- var rgb = /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/i.exec(colorString);
451
+ const colorString = lightSettings.color.length === 7 ? lightSettings.color + 'FF' : lightSettings.color;
452
+ 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);
453
453
  if (!rgb || rgb.length < 4) {
454
454
  throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INTERNAL_ERROR, 'regex to extract rgba values from ' + colorString + ' failed.');
455
455
  }
456
- var color = {
456
+ const color = {
457
457
  red: parseInt(rgb[1], 16) / 255.0,
458
458
  green: parseInt(rgb[2], 16) / 255.0,
459
459
  blue: parseInt(rgb[3], 16) / 255.0,
460
460
  alpha: parseInt(rgb[4], 16) / 255.0,
461
461
  };
462
462
  lightSettings.color = color;
463
- var propertyMappings = {
463
+ const propertyMappings = {
464
464
  lightOnDurationMillis: 'light_on_duration',
465
465
  lightOffDurationMillis: 'light_off_duration',
466
466
  };
467
- index_1.renameProperties(lightSettings, propertyMappings);
467
+ (0, index_1.renameProperties)(lightSettings, propertyMappings);
468
468
  }
469
469
  /**
470
470
  * Checks if the given AndroidFcmOptions object is valid.
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v10.3.0 */
1
+ /*! firebase-admin v11.0.0 */
2
2
  /*!
3
3
  * Copyright 2021 Google Inc.
4
4
  *
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v10.3.0 */
1
+ /*! firebase-admin v11.0.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2021 Google Inc.
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v10.3.0 */
1
+ /*! firebase-admin v11.0.0 */
2
2
  /*!
3
3
  * @license
4
4
  * Copyright 2017 Google Inc.