firebase-admin 12.2.0 → 12.3.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 (209) hide show
  1. package/lib/app/core.d.ts +1 -1
  2. package/lib/app/core.js +1 -1
  3. package/lib/app/credential-factory.d.ts +1 -1
  4. package/lib/app/credential-factory.js +1 -1
  5. package/lib/app/credential-internal.d.ts +1 -1
  6. package/lib/app/credential-internal.js +4 -4
  7. package/lib/app/credential.d.ts +1 -1
  8. package/lib/app/credential.js +1 -1
  9. package/lib/app/firebase-app.d.ts +1 -1
  10. package/lib/app/firebase-app.js +1 -1
  11. package/lib/app/firebase-namespace.d.ts +1 -1
  12. package/lib/app/firebase-namespace.js +1 -1
  13. package/lib/app/index.d.ts +1 -1
  14. package/lib/app/index.js +1 -1
  15. package/lib/app/lifecycle.d.ts +1 -1
  16. package/lib/app/lifecycle.js +1 -1
  17. package/lib/app-check/app-check-api-client-internal.d.ts +1 -1
  18. package/lib/app-check/app-check-api-client-internal.js +1 -1
  19. package/lib/app-check/app-check-api.d.ts +1 -1
  20. package/lib/app-check/app-check-api.js +1 -1
  21. package/lib/app-check/app-check-namespace.d.ts +1 -1
  22. package/lib/app-check/app-check-namespace.js +1 -1
  23. package/lib/app-check/app-check.d.ts +1 -1
  24. package/lib/app-check/app-check.js +1 -1
  25. package/lib/app-check/index.d.ts +1 -1
  26. package/lib/app-check/index.js +1 -1
  27. package/lib/app-check/token-generator.d.ts +1 -1
  28. package/lib/app-check/token-generator.js +1 -1
  29. package/lib/app-check/token-verifier.d.ts +1 -1
  30. package/lib/app-check/token-verifier.js +1 -1
  31. package/lib/auth/action-code-settings-builder.d.ts +1 -1
  32. package/lib/auth/action-code-settings-builder.js +1 -1
  33. package/lib/auth/auth-api-request.d.ts +1 -1
  34. package/lib/auth/auth-api-request.js +2 -2
  35. package/lib/auth/auth-config.d.ts +1 -1
  36. package/lib/auth/auth-config.js +1 -1
  37. package/lib/auth/auth-namespace.d.ts +1 -1
  38. package/lib/auth/auth-namespace.js +1 -1
  39. package/lib/auth/auth.d.ts +1 -1
  40. package/lib/auth/auth.js +1 -1
  41. package/lib/auth/base-auth.d.ts +1 -1
  42. package/lib/auth/base-auth.js +1 -1
  43. package/lib/auth/identifier.d.ts +1 -1
  44. package/lib/auth/identifier.js +1 -1
  45. package/lib/auth/index.d.ts +1 -1
  46. package/lib/auth/index.js +1 -1
  47. package/lib/auth/project-config-manager.d.ts +1 -1
  48. package/lib/auth/project-config-manager.js +1 -1
  49. package/lib/auth/project-config.d.ts +1 -1
  50. package/lib/auth/project-config.js +1 -1
  51. package/lib/auth/tenant-manager.d.ts +1 -1
  52. package/lib/auth/tenant-manager.js +1 -1
  53. package/lib/auth/tenant.d.ts +1 -1
  54. package/lib/auth/tenant.js +1 -1
  55. package/lib/auth/token-generator.d.ts +1 -1
  56. package/lib/auth/token-generator.js +1 -1
  57. package/lib/auth/token-verifier.d.ts +1 -1
  58. package/lib/auth/token-verifier.js +1 -1
  59. package/lib/auth/user-import-builder.d.ts +1 -1
  60. package/lib/auth/user-import-builder.js +1 -1
  61. package/lib/auth/user-record.d.ts +1 -1
  62. package/lib/auth/user-record.js +1 -1
  63. package/lib/credential/index.d.ts +1 -1
  64. package/lib/credential/index.js +1 -1
  65. package/lib/database/database-namespace.d.ts +1 -1
  66. package/lib/database/database-namespace.js +1 -1
  67. package/lib/database/database.d.ts +1 -1
  68. package/lib/database/database.js +2 -2
  69. package/lib/database/index.d.ts +1 -1
  70. package/lib/database/index.js +1 -1
  71. package/lib/default-namespace.d.ts +1 -1
  72. package/lib/default-namespace.js +1 -1
  73. package/lib/eventarc/cloudevent.d.ts +1 -1
  74. package/lib/eventarc/cloudevent.js +1 -1
  75. package/lib/eventarc/eventarc-client-internal.d.ts +1 -1
  76. package/lib/eventarc/eventarc-client-internal.js +1 -1
  77. package/lib/eventarc/eventarc-utils.d.ts +1 -1
  78. package/lib/eventarc/eventarc-utils.js +1 -1
  79. package/lib/eventarc/eventarc.d.ts +1 -1
  80. package/lib/eventarc/eventarc.js +1 -1
  81. package/lib/eventarc/index.d.ts +1 -1
  82. package/lib/eventarc/index.js +1 -1
  83. package/lib/extensions/extensions-api-client-internal.d.ts +1 -1
  84. package/lib/extensions/extensions-api-client-internal.js +1 -1
  85. package/lib/extensions/extensions-api.d.ts +1 -1
  86. package/lib/extensions/extensions-api.js +1 -1
  87. package/lib/extensions/extensions.d.ts +1 -1
  88. package/lib/extensions/extensions.js +1 -1
  89. package/lib/extensions/index.d.ts +1 -1
  90. package/lib/extensions/index.js +1 -1
  91. package/lib/firebase-namespace-api.d.ts +1 -1
  92. package/lib/firebase-namespace-api.js +1 -1
  93. package/lib/firestore/firestore-internal.d.ts +1 -1
  94. package/lib/firestore/firestore-internal.js +1 -1
  95. package/lib/firestore/firestore-namespace.d.ts +1 -1
  96. package/lib/firestore/firestore-namespace.js +1 -1
  97. package/lib/firestore/index.d.ts +1 -1
  98. package/lib/firestore/index.js +1 -1
  99. package/lib/functions/functions-api-client-internal.d.ts +1 -1
  100. package/lib/functions/functions-api-client-internal.js +3 -3
  101. package/lib/functions/functions-api.d.ts +1 -1
  102. package/lib/functions/functions-api.js +1 -1
  103. package/lib/functions/functions.d.ts +1 -1
  104. package/lib/functions/functions.js +1 -1
  105. package/lib/functions/index.d.ts +1 -1
  106. package/lib/functions/index.js +1 -1
  107. package/lib/index.d.ts +1 -1
  108. package/lib/index.js +1 -1
  109. package/lib/installations/index.d.ts +1 -1
  110. package/lib/installations/index.js +1 -1
  111. package/lib/installations/installations-namespace.d.ts +1 -1
  112. package/lib/installations/installations-namespace.js +1 -1
  113. package/lib/installations/installations-request-handler.d.ts +1 -1
  114. package/lib/installations/installations-request-handler.js +2 -2
  115. package/lib/installations/installations.d.ts +1 -1
  116. package/lib/installations/installations.js +1 -1
  117. package/lib/instance-id/index.d.ts +1 -1
  118. package/lib/instance-id/index.js +1 -1
  119. package/lib/instance-id/instance-id-namespace.d.ts +1 -1
  120. package/lib/instance-id/instance-id-namespace.js +1 -1
  121. package/lib/instance-id/instance-id.d.ts +1 -1
  122. package/lib/instance-id/instance-id.js +1 -1
  123. package/lib/machine-learning/index.d.ts +1 -1
  124. package/lib/machine-learning/index.js +1 -1
  125. package/lib/machine-learning/machine-learning-api-client.d.ts +1 -1
  126. package/lib/machine-learning/machine-learning-api-client.js +1 -1
  127. package/lib/machine-learning/machine-learning-namespace.d.ts +1 -1
  128. package/lib/machine-learning/machine-learning-namespace.js +1 -1
  129. package/lib/machine-learning/machine-learning-utils.d.ts +1 -1
  130. package/lib/machine-learning/machine-learning-utils.js +1 -1
  131. package/lib/machine-learning/machine-learning.d.ts +1 -1
  132. package/lib/machine-learning/machine-learning.js +1 -1
  133. package/lib/messaging/batch-request-internal.d.ts +4 -4
  134. package/lib/messaging/batch-request-internal.js +2 -2
  135. package/lib/messaging/index.d.ts +1 -1
  136. package/lib/messaging/index.js +1 -1
  137. package/lib/messaging/messaging-api-request-internal.d.ts +15 -4
  138. package/lib/messaging/messaging-api-request-internal.js +39 -10
  139. package/lib/messaging/messaging-api.d.ts +1 -1
  140. package/lib/messaging/messaging-api.js +1 -1
  141. package/lib/messaging/messaging-errors-internal.d.ts +6 -6
  142. package/lib/messaging/messaging-errors-internal.js +4 -4
  143. package/lib/messaging/messaging-internal.d.ts +1 -1
  144. package/lib/messaging/messaging-internal.js +1 -1
  145. package/lib/messaging/messaging-namespace.d.ts +1 -1
  146. package/lib/messaging/messaging-namespace.js +1 -1
  147. package/lib/messaging/messaging.d.ts +16 -1
  148. package/lib/messaging/messaging.js +37 -9
  149. package/lib/project-management/android-app.d.ts +1 -1
  150. package/lib/project-management/android-app.js +1 -1
  151. package/lib/project-management/app-metadata.d.ts +1 -1
  152. package/lib/project-management/app-metadata.js +1 -1
  153. package/lib/project-management/index.d.ts +1 -1
  154. package/lib/project-management/index.js +1 -1
  155. package/lib/project-management/ios-app.d.ts +1 -1
  156. package/lib/project-management/ios-app.js +1 -1
  157. package/lib/project-management/project-management-api-request-internal.d.ts +1 -1
  158. package/lib/project-management/project-management-api-request-internal.js +3 -3
  159. package/lib/project-management/project-management-namespace.d.ts +1 -1
  160. package/lib/project-management/project-management-namespace.js +1 -1
  161. package/lib/project-management/project-management.d.ts +1 -1
  162. package/lib/project-management/project-management.js +1 -1
  163. package/lib/remote-config/condition-evaluator-internal.d.ts +1 -1
  164. package/lib/remote-config/condition-evaluator-internal.js +20 -14
  165. package/lib/remote-config/index.d.ts +1 -1
  166. package/lib/remote-config/index.js +1 -1
  167. package/lib/remote-config/internal/value-impl.d.ts +1 -1
  168. package/lib/remote-config/internal/value-impl.js +1 -1
  169. package/lib/remote-config/remote-config-api-client-internal.d.ts +1 -1
  170. package/lib/remote-config/remote-config-api-client-internal.js +1 -1
  171. package/lib/remote-config/remote-config-api.d.ts +1 -1
  172. package/lib/remote-config/remote-config-api.js +1 -1
  173. package/lib/remote-config/remote-config-namespace.d.ts +1 -1
  174. package/lib/remote-config/remote-config-namespace.js +1 -1
  175. package/lib/remote-config/remote-config.d.ts +1 -1
  176. package/lib/remote-config/remote-config.js +1 -1
  177. package/lib/security-rules/index.d.ts +1 -1
  178. package/lib/security-rules/index.js +1 -1
  179. package/lib/security-rules/security-rules-api-client-internal.d.ts +1 -1
  180. package/lib/security-rules/security-rules-api-client-internal.js +1 -1
  181. package/lib/security-rules/security-rules-internal.d.ts +1 -1
  182. package/lib/security-rules/security-rules-internal.js +1 -1
  183. package/lib/security-rules/security-rules-namespace.d.ts +1 -1
  184. package/lib/security-rules/security-rules-namespace.js +1 -1
  185. package/lib/security-rules/security-rules.d.ts +1 -1
  186. package/lib/security-rules/security-rules.js +1 -1
  187. package/lib/storage/index.d.ts +1 -1
  188. package/lib/storage/index.js +1 -1
  189. package/lib/storage/storage-namespace.d.ts +1 -1
  190. package/lib/storage/storage-namespace.js +1 -1
  191. package/lib/storage/storage.d.ts +1 -1
  192. package/lib/storage/storage.js +1 -1
  193. package/lib/storage/utils.d.ts +1 -1
  194. package/lib/storage/utils.js +1 -1
  195. package/lib/utils/api-request.d.ts +134 -42
  196. package/lib/utils/api-request.js +430 -186
  197. package/lib/utils/crypto-signer.d.ts +1 -1
  198. package/lib/utils/crypto-signer.js +2 -2
  199. package/lib/utils/deep-copy.d.ts +1 -1
  200. package/lib/utils/deep-copy.js +1 -1
  201. package/lib/utils/error.d.ts +1 -1
  202. package/lib/utils/error.js +1 -1
  203. package/lib/utils/index.d.ts +1 -1
  204. package/lib/utils/index.js +1 -1
  205. package/lib/utils/jwt.d.ts +1 -1
  206. package/lib/utils/jwt.js +3 -3
  207. package/lib/utils/validator.d.ts +1 -1
  208. package/lib/utils/validator.js +1 -1
  209. package/package.json +4 -5
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v12.2.0 */
1
+ /*! firebase-admin v12.3.0 */
2
2
  /*!
3
3
  * Copyright 2019 Google Inc.
4
4
  *
@@ -14,16 +14,16 @@
14
14
  * See the License for the specific language governing permissions and
15
15
  * limitations under the License.
16
16
  */
17
- import { HttpError } from '../utils/api-request';
17
+ import { RequestResponseError } from '../utils/api-request';
18
18
  import { FirebaseMessagingError } from '../utils/error';
19
19
  /**
20
- * Creates a new FirebaseMessagingError by extracting the error code, message and other relevant
21
- * details from an HTTP error response.
20
+ * Creates a new `FirebaseMessagingError` by extracting the error code, message and other relevant
21
+ * details from a `RequestResponseError` response.
22
22
  *
23
- * @param err - The HttpError to convert into a Firebase error
23
+ * @param err - The `RequestResponseError` to convert into a Firebase error
24
24
  * @returns A Firebase error that can be returned to the user.
25
25
  */
26
- export declare function createFirebaseError(err: HttpError): FirebaseMessagingError;
26
+ export declare function createFirebaseError(err: RequestResponseError): FirebaseMessagingError;
27
27
  /**
28
28
  * @param response - The response to check for errors.
29
29
  * @returns The error code if present; null otherwise.
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v12.2.0 */
1
+ /*! firebase-admin v12.3.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2019 Google Inc.
@@ -20,10 +20,10 @@ exports.getErrorCode = exports.createFirebaseError = void 0;
20
20
  const error_1 = require("../utils/error");
21
21
  const validator = require("../utils/validator");
22
22
  /**
23
- * Creates a new FirebaseMessagingError by extracting the error code, message and other relevant
24
- * details from an HTTP error response.
23
+ * Creates a new `FirebaseMessagingError` by extracting the error code, message and other relevant
24
+ * details from a `RequestResponseError` response.
25
25
  *
26
- * @param err - The HttpError to convert into a Firebase error
26
+ * @param err - The `RequestResponseError` to convert into a Firebase error
27
27
  * @returns A Firebase error that can be returned to the user.
28
28
  */
29
29
  function createFirebaseError(err) {
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v12.2.0 */
1
+ /*! firebase-admin v12.3.0 */
2
2
  /*!
3
3
  * Copyright 2020 Google Inc.
4
4
  *
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v12.2.0 */
1
+ /*! firebase-admin v12.3.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2020 Google Inc.
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v12.2.0 */
1
+ /*! firebase-admin v12.3.0 */
2
2
  /*!
3
3
  * Copyright 2021 Google Inc.
4
4
  *
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v12.2.0 */
1
+ /*! firebase-admin v12.3.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2021 Google Inc.
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v12.2.0 */
1
+ /*! firebase-admin v12.3.0 */
2
2
  /*!
3
3
  * @license
4
4
  * Copyright 2017 Google Inc.
@@ -24,6 +24,7 @@ export declare class Messaging {
24
24
  private urlPath;
25
25
  private readonly appInternal;
26
26
  private readonly messagingRequestHandler;
27
+ private useLegacyTransport;
27
28
  /**
28
29
  * The {@link firebase-admin.app#App} associated with the current `Messaging` service
29
30
  * instance.
@@ -34,6 +35,20 @@ export declare class Messaging {
34
35
  * ```
35
36
  */
36
37
  get app(): App;
38
+ /**
39
+ * Enables the use of legacy HTTP/1.1 transport for `sendEach()` and `sendEachForMulticast()`.
40
+ *
41
+ * @example
42
+ * ```javascript
43
+ * const messaging = getMessaging(app);
44
+ * messaging.enableLegacyTransport();
45
+ * messaging.sendEach(messages);
46
+ * ```
47
+ *
48
+ * @deprecated This will be removed when the HTTP/2 transport implementation reaches the same
49
+ * stability as the legacy HTTP/1.1 implementation.
50
+ */
51
+ enableLegacyHttpTransport(): void;
37
52
  /**
38
53
  * Sends the given message via FCM.
39
54
  *
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v12.2.0 */
1
+ /*! firebase-admin v12.3.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * @license
@@ -24,6 +24,7 @@ const utils = require("../utils");
24
24
  const validator = require("../utils/validator");
25
25
  const messaging_internal_1 = require("./messaging-internal");
26
26
  const messaging_api_request_internal_1 = require("./messaging-api-request-internal");
27
+ const api_request_1 = require("../utils/api-request");
27
28
  // FCM endpoints
28
29
  const FCM_SEND_HOST = 'fcm.googleapis.com';
29
30
  const FCM_SEND_PATH = '/fcm/send';
@@ -76,11 +77,11 @@ const MESSAGING_CONDITION_RESPONSE_KEYS_MAP = {
76
77
  message_id: 'messageId',
77
78
  };
78
79
  /**
79
- * Maps a raw FCM server response to a MessagingDevicesResponse object.
80
+ * Maps a raw FCM server response to a `MessagingDevicesResponse` object.
80
81
  *
81
82
  * @param response - The raw FCM server response to map.
82
83
  *
83
- * @returns The mapped MessagingDevicesResponse object.
84
+ * @returns The mapped `MessagingDevicesResponse` object.
84
85
  */
85
86
  function mapRawResponseToDevicesResponse(response) {
86
87
  // Rename properties on the server response
@@ -98,11 +99,11 @@ function mapRawResponseToDevicesResponse(response) {
98
99
  return response;
99
100
  }
100
101
  /**
101
- * Maps a raw FCM server response to a MessagingDeviceGroupResponse object.
102
+ * Maps a raw FCM server response to a `MessagingDeviceGroupResponse` object.
102
103
  *
103
104
  * @param response - The raw FCM server response to map.
104
105
  *
105
- * @returns The mapped MessagingDeviceGroupResponse object.
106
+ * @returns The mapped `MessagingDeviceGroupResponse` object.
106
107
  */
107
108
  function mapRawResponseToDeviceGroupResponse(response) {
108
109
  // Rename properties on the server response
@@ -113,11 +114,11 @@ function mapRawResponseToDeviceGroupResponse(response) {
113
114
  return response;
114
115
  }
115
116
  /**
116
- * Maps a raw FCM server response to a MessagingTopicManagementResponse object.
117
+ * Maps a raw FCM server response to a `MessagingTopicManagementResponse` object.
117
118
  *
118
119
  * @param {object} response The raw FCM server response to map.
119
120
  *
120
- * @returns {MessagingTopicManagementResponse} The mapped MessagingTopicManagementResponse object.
121
+ * @returns {MessagingTopicManagementResponse} The mapped `MessagingTopicManagementResponse` object.
121
122
  */
122
123
  function mapRawResponseToTopicManagementResponse(response) {
123
124
  // Add the success and failure counts.
@@ -152,6 +153,7 @@ class Messaging {
152
153
  * @internal
153
154
  */
154
155
  constructor(app) {
156
+ this.useLegacyTransport = false;
155
157
  if (!validator.isNonNullObject(app) || !('options' in app)) {
156
158
  throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_ARGUMENT, 'First argument passed to admin.messaging() must be a valid Firebase app instance.');
157
159
  }
@@ -170,6 +172,22 @@ class Messaging {
170
172
  get app() {
171
173
  return this.appInternal;
172
174
  }
175
+ /**
176
+ * Enables the use of legacy HTTP/1.1 transport for `sendEach()` and `sendEachForMulticast()`.
177
+ *
178
+ * @example
179
+ * ```javascript
180
+ * const messaging = getMessaging(app);
181
+ * messaging.enableLegacyTransport();
182
+ * messaging.sendEach(messages);
183
+ * ```
184
+ *
185
+ * @deprecated This will be removed when the HTTP/2 transport implementation reaches the same
186
+ * stability as the legacy HTTP/1.1 implementation.
187
+ */
188
+ enableLegacyHttpTransport() {
189
+ this.useLegacyTransport = true;
190
+ }
173
191
  /**
174
192
  * Sends the given message via FCM.
175
193
  *
@@ -233,6 +251,7 @@ class Messaging {
233
251
  if (typeof dryRun !== 'undefined' && !validator.isBoolean(dryRun)) {
234
252
  throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_ARGUMENT, 'dryRun must be a boolean');
235
253
  }
254
+ const http2SessionHandler = this.useLegacyTransport ? undefined : new api_request_1.Http2SessionHandler(`https://${FCM_SEND_HOST}`);
236
255
  return this.getUrlPath()
237
256
  .then((urlPath) => {
238
257
  const requests = copy.map(async (message) => {
@@ -241,10 +260,14 @@ class Messaging {
241
260
  if (dryRun) {
242
261
  request.validate_only = true;
243
262
  }
244
- return this.messagingRequestHandler.invokeRequestHandlerForSendResponse(FCM_SEND_HOST, urlPath, request);
263
+ if (http2SessionHandler) {
264
+ return this.messagingRequestHandler.invokeHttp2RequestHandlerForSendResponse(FCM_SEND_HOST, urlPath, request, http2SessionHandler);
265
+ }
266
+ return this.messagingRequestHandler.invokeHttpRequestHandlerForSendResponse(FCM_SEND_HOST, urlPath, request);
245
267
  });
246
268
  return Promise.allSettled(requests);
247
- }).then((results) => {
269
+ })
270
+ .then((results) => {
248
271
  const responses = [];
249
272
  results.forEach(result => {
250
273
  if (result.status === 'fulfilled') {
@@ -260,6 +283,11 @@ class Messaging {
260
283
  successCount,
261
284
  failureCount: responses.length - successCount,
262
285
  };
286
+ })
287
+ .finally(() => {
288
+ if (http2SessionHandler) {
289
+ http2SessionHandler.close();
290
+ }
263
291
  });
264
292
  }
265
293
  /**
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v12.2.0 */
1
+ /*! firebase-admin v12.3.0 */
2
2
  /*!
3
3
  * Copyright 2018 Google Inc.
4
4
  *
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v12.2.0 */
1
+ /*! firebase-admin v12.3.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2018 Google Inc.
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v12.2.0 */
1
+ /*! firebase-admin v12.3.0 */
2
2
  /*!
3
3
  * Copyright 2021 Google Inc.
4
4
  *
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v12.2.0 */
1
+ /*! firebase-admin v12.3.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2021 Google Inc.
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v12.2.0 */
1
+ /*! firebase-admin v12.3.0 */
2
2
  /*!
3
3
  * Copyright 2020 Google Inc.
4
4
  *
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v12.2.0 */
1
+ /*! firebase-admin v12.3.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2020 Google Inc.
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v12.2.0 */
1
+ /*! firebase-admin v12.3.0 */
2
2
  /*!
3
3
  * Copyright 2018 Google Inc.
4
4
  *
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v12.2.0 */
1
+ /*! firebase-admin v12.3.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2018 Google Inc.
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v12.2.0 */
1
+ /*! firebase-admin v12.3.0 */
2
2
  /*!
3
3
  * Copyright 2018 Google Inc.
4
4
  *
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v12.2.0 */
1
+ /*! firebase-admin v12.3.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2018 Google Inc.
@@ -253,12 +253,12 @@ class ProjectManagementRequestHandler {
253
253
  .then((response) => {
254
254
  // Send non-JSON responses to the catch() below, where they will be treated as errors.
255
255
  if (!response.isJson()) {
256
- throw new api_request_1.HttpError(response);
256
+ throw new api_request_1.RequestResponseError(response);
257
257
  }
258
258
  return response.data;
259
259
  })
260
260
  .catch((err) => {
261
- if (err instanceof api_request_1.HttpError) {
261
+ if (err instanceof api_request_1.RequestResponseError) {
262
262
  ProjectManagementRequestHandler.wrapAndRethrowHttpError(err.response.status, err.response.text);
263
263
  }
264
264
  throw err;
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v12.2.0 */
1
+ /*! firebase-admin v12.3.0 */
2
2
  /*!
3
3
  * Copyright 2021 Google Inc.
4
4
  *
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v12.2.0 */
1
+ /*! firebase-admin v12.3.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2021 Google Inc.
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v12.2.0 */
1
+ /*! firebase-admin v12.3.0 */
2
2
  /*!
3
3
  * Copyright 2018 Google Inc.
4
4
  *
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v12.2.0 */
1
+ /*! firebase-admin v12.3.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2018 Google Inc.
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v12.2.0 */
1
+ /*! firebase-admin v12.3.0 */
2
2
  /*!
3
3
  * Copyright 2024 Google Inc.
4
4
  *
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v12.2.0 */
1
+ /*! firebase-admin v12.3.0 */
2
2
  /*!
3
3
  * Copyright 2024 Google Inc.
4
4
  *
@@ -19,7 +19,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
19
19
  exports.ConditionEvaluator = void 0;
20
20
  const remote_config_api_1 = require("./remote-config-api");
21
21
  const farmhash = require("farmhash-modern");
22
- const long = require("long");
23
22
  /**
24
23
  * Encapsulates condition evaluation logic to simplify organization and
25
24
  * facilitate testing.
@@ -102,22 +101,16 @@ class ConditionEvaluator {
102
101
  const normalizedMicroPercentLowerBound = microPercentRange?.microPercentLowerBound || 0;
103
102
  const seedPrefix = seed && seed.length > 0 ? `${seed}.` : '';
104
103
  const stringToHash = `${seedPrefix}${context.randomizationId}`;
105
- // Using a 64-bit long for consistency with the Remote Config fetch endpoint.
106
- let hash64 = long.fromString(farmhash.fingerprint64(stringToHash).toString());
107
- // Negate the hash if its value is less than 0. We handle this manually because the
108
- // Long library doesn't provided an absolute value method.
109
- if (hash64.lt(0)) {
110
- hash64 = hash64.negate();
111
- }
112
- const instanceMicroPercentile = hash64.mod(100 * 1000000);
104
+ const hash64 = ConditionEvaluator.hashSeededRandomizationId(stringToHash);
105
+ const instanceMicroPercentile = hash64 % BigInt(100 * 1000000);
113
106
  switch (percentOperator) {
114
107
  case remote_config_api_1.PercentConditionOperator.LESS_OR_EQUAL:
115
- return instanceMicroPercentile.lte(normalizedMicroPercent);
108
+ return instanceMicroPercentile <= normalizedMicroPercent;
116
109
  case remote_config_api_1.PercentConditionOperator.GREATER_THAN:
117
- return instanceMicroPercentile.gt(normalizedMicroPercent);
110
+ return instanceMicroPercentile > normalizedMicroPercent;
118
111
  case remote_config_api_1.PercentConditionOperator.BETWEEN:
119
- return instanceMicroPercentile.gt(normalizedMicroPercentLowerBound)
120
- && instanceMicroPercentile.lte(normalizedMicroPercentUpperBound);
112
+ return instanceMicroPercentile > normalizedMicroPercentLowerBound
113
+ && instanceMicroPercentile <= normalizedMicroPercentUpperBound;
121
114
  case remote_config_api_1.PercentConditionOperator.UNKNOWN:
122
115
  default:
123
116
  break;
@@ -125,6 +118,19 @@ class ConditionEvaluator {
125
118
  // TODO: add logging once we have a wrapped logger.
126
119
  return false;
127
120
  }
121
+ // Visible for testing
122
+ static hashSeededRandomizationId(seededRandomizationId) {
123
+ // For consistency with the Remote Config fetch endpoint's percent condition behavior
124
+ // we use Farmhash's fingerprint64 algorithm and interpret the resulting unsigned value
125
+ // as a signed value.
126
+ let hash64 = BigInt.asIntN(64, farmhash.fingerprint64(seededRandomizationId));
127
+ // Manually negate the hash if its value is less than 0, since Math.abs doesn't
128
+ // support BigInt.
129
+ if (hash64 < 0) {
130
+ hash64 = -hash64;
131
+ }
132
+ return hash64;
133
+ }
128
134
  }
129
135
  exports.ConditionEvaluator = ConditionEvaluator;
130
136
  ConditionEvaluator.MAX_CONDITION_RECURSION_DEPTH = 10;
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v12.2.0 */
1
+ /*! firebase-admin v12.3.0 */
2
2
  /*!
3
3
  * Copyright 2020 Google Inc.
4
4
  *
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v12.2.0 */
1
+ /*! firebase-admin v12.3.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2020 Google Inc.
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v12.2.0 */
1
+ /*! firebase-admin v12.3.0 */
2
2
  /*!
3
3
  * Copyright 2024 Google Inc.
4
4
  *
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v12.2.0 */
1
+ /*! firebase-admin v12.3.0 */
2
2
  /*!
3
3
  * Copyright 2024 Google Inc.
4
4
  *
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v12.2.0 */
1
+ /*! firebase-admin v12.3.0 */
2
2
  /*!
3
3
  * Copyright 2020 Google Inc.
4
4
  *
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v12.2.0 */
1
+ /*! firebase-admin v12.3.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2020 Google Inc.
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v12.2.0 */
1
+ /*! firebase-admin v12.3.0 */
2
2
  /*!
3
3
  * Copyright 2021 Google Inc.
4
4
  *
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v12.2.0 */
1
+ /*! firebase-admin v12.3.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2021 Google Inc.
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v12.2.0 */
1
+ /*! firebase-admin v12.3.0 */
2
2
  /*!
3
3
  * Copyright 2021 Google Inc.
4
4
  *
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v12.2.0 */
1
+ /*! firebase-admin v12.3.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2021 Google Inc.
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v12.2.0 */
1
+ /*! firebase-admin v12.3.0 */
2
2
  /*!
3
3
  * Copyright 2020 Google Inc.
4
4
  *
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v12.2.0 */
1
+ /*! firebase-admin v12.3.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2020 Google Inc.
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v12.2.0 */
1
+ /*! firebase-admin v12.3.0 */
2
2
  /*!
3
3
  * Copyright 2020 Google Inc.
4
4
  *
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v12.2.0 */
1
+ /*! firebase-admin v12.3.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2020 Google Inc.
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v12.2.0 */
1
+ /*! firebase-admin v12.3.0 */
2
2
  /*!
3
3
  * Copyright 2019 Google Inc.
4
4
  *
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v12.2.0 */
1
+ /*! firebase-admin v12.3.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2019 Google Inc.
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v12.2.0 */
1
+ /*! firebase-admin v12.3.0 */
2
2
  /*!
3
3
  * Copyright 2019 Google Inc.
4
4
  *
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v12.2.0 */
1
+ /*! firebase-admin v12.3.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2019 Google Inc.
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v12.2.0 */
1
+ /*! firebase-admin v12.3.0 */
2
2
  /*!
3
3
  * Copyright 2021 Google Inc.
4
4
  *
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v12.2.0 */
1
+ /*! firebase-admin v12.3.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2021 Google Inc.
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v12.2.0 */
1
+ /*! firebase-admin v12.3.0 */
2
2
  /*!
3
3
  * Copyright 2019 Google Inc.
4
4
  *
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v12.2.0 */
1
+ /*! firebase-admin v12.3.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2019 Google Inc.
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v12.2.0 */
1
+ /*! firebase-admin v12.3.0 */
2
2
  /*!
3
3
  * Copyright 2020 Google Inc.
4
4
  *
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v12.2.0 */
1
+ /*! firebase-admin v12.3.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2020 Google Inc.
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v12.2.0 */
1
+ /*! firebase-admin v12.3.0 */
2
2
  /*!
3
3
  * Copyright 2021 Google Inc.
4
4
  *
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v12.2.0 */
1
+ /*! firebase-admin v12.3.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * Copyright 2021 Google Inc.
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v12.2.0 */
1
+ /*! firebase-admin v12.3.0 */
2
2
  /*!
3
3
  * @license
4
4
  * Copyright 2017 Google Inc.
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v12.2.0 */
1
+ /*! firebase-admin v12.3.0 */
2
2
  "use strict";
3
3
  /*!
4
4
  * @license
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v12.2.0 */
1
+ /*! firebase-admin v12.3.0 */
2
2
  import { File } from '@google-cloud/storage';
3
3
  export interface FirebaseMetadata {
4
4
  name: string;
@@ -1,4 +1,4 @@
1
- /*! firebase-admin v12.2.0 */
1
+ /*! firebase-admin v12.3.0 */
2
2
  "use strict";
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.getFirebaseMetadata = void 0;