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.
- package/lib/app/core.d.ts +1 -1
- package/lib/app/core.js +1 -1
- package/lib/app/credential-factory.d.ts +1 -1
- package/lib/app/credential-factory.js +1 -1
- package/lib/app/credential-internal.d.ts +1 -1
- package/lib/app/credential-internal.js +4 -4
- package/lib/app/credential.d.ts +1 -1
- package/lib/app/credential.js +1 -1
- package/lib/app/firebase-app.d.ts +1 -1
- package/lib/app/firebase-app.js +1 -1
- package/lib/app/firebase-namespace.d.ts +1 -1
- package/lib/app/firebase-namespace.js +1 -1
- package/lib/app/index.d.ts +1 -1
- package/lib/app/index.js +1 -1
- package/lib/app/lifecycle.d.ts +1 -1
- package/lib/app/lifecycle.js +1 -1
- package/lib/app-check/app-check-api-client-internal.d.ts +1 -1
- package/lib/app-check/app-check-api-client-internal.js +1 -1
- package/lib/app-check/app-check-api.d.ts +1 -1
- package/lib/app-check/app-check-api.js +1 -1
- package/lib/app-check/app-check-namespace.d.ts +1 -1
- package/lib/app-check/app-check-namespace.js +1 -1
- package/lib/app-check/app-check.d.ts +1 -1
- package/lib/app-check/app-check.js +1 -1
- package/lib/app-check/index.d.ts +1 -1
- package/lib/app-check/index.js +1 -1
- package/lib/app-check/token-generator.d.ts +1 -1
- package/lib/app-check/token-generator.js +1 -1
- package/lib/app-check/token-verifier.d.ts +1 -1
- package/lib/app-check/token-verifier.js +1 -1
- package/lib/auth/action-code-settings-builder.d.ts +1 -1
- package/lib/auth/action-code-settings-builder.js +1 -1
- package/lib/auth/auth-api-request.d.ts +1 -1
- package/lib/auth/auth-api-request.js +2 -2
- package/lib/auth/auth-config.d.ts +1 -1
- package/lib/auth/auth-config.js +1 -1
- package/lib/auth/auth-namespace.d.ts +1 -1
- package/lib/auth/auth-namespace.js +1 -1
- package/lib/auth/auth.d.ts +1 -1
- package/lib/auth/auth.js +1 -1
- package/lib/auth/base-auth.d.ts +1 -1
- package/lib/auth/base-auth.js +1 -1
- package/lib/auth/identifier.d.ts +1 -1
- package/lib/auth/identifier.js +1 -1
- package/lib/auth/index.d.ts +1 -1
- package/lib/auth/index.js +1 -1
- package/lib/auth/project-config-manager.d.ts +1 -1
- package/lib/auth/project-config-manager.js +1 -1
- package/lib/auth/project-config.d.ts +1 -1
- package/lib/auth/project-config.js +1 -1
- package/lib/auth/tenant-manager.d.ts +1 -1
- package/lib/auth/tenant-manager.js +1 -1
- package/lib/auth/tenant.d.ts +1 -1
- package/lib/auth/tenant.js +1 -1
- package/lib/auth/token-generator.d.ts +1 -1
- package/lib/auth/token-generator.js +1 -1
- package/lib/auth/token-verifier.d.ts +1 -1
- package/lib/auth/token-verifier.js +1 -1
- package/lib/auth/user-import-builder.d.ts +1 -1
- package/lib/auth/user-import-builder.js +1 -1
- package/lib/auth/user-record.d.ts +1 -1
- package/lib/auth/user-record.js +1 -1
- package/lib/credential/index.d.ts +1 -1
- package/lib/credential/index.js +1 -1
- package/lib/database/database-namespace.d.ts +1 -1
- package/lib/database/database-namespace.js +1 -1
- package/lib/database/database.d.ts +1 -1
- package/lib/database/database.js +2 -2
- package/lib/database/index.d.ts +1 -1
- package/lib/database/index.js +1 -1
- package/lib/default-namespace.d.ts +1 -1
- package/lib/default-namespace.js +1 -1
- package/lib/eventarc/cloudevent.d.ts +1 -1
- package/lib/eventarc/cloudevent.js +1 -1
- package/lib/eventarc/eventarc-client-internal.d.ts +1 -1
- package/lib/eventarc/eventarc-client-internal.js +1 -1
- package/lib/eventarc/eventarc-utils.d.ts +1 -1
- package/lib/eventarc/eventarc-utils.js +1 -1
- package/lib/eventarc/eventarc.d.ts +1 -1
- package/lib/eventarc/eventarc.js +1 -1
- package/lib/eventarc/index.d.ts +1 -1
- package/lib/eventarc/index.js +1 -1
- package/lib/extensions/extensions-api-client-internal.d.ts +1 -1
- package/lib/extensions/extensions-api-client-internal.js +1 -1
- package/lib/extensions/extensions-api.d.ts +1 -1
- package/lib/extensions/extensions-api.js +1 -1
- package/lib/extensions/extensions.d.ts +1 -1
- package/lib/extensions/extensions.js +1 -1
- package/lib/extensions/index.d.ts +1 -1
- package/lib/extensions/index.js +1 -1
- package/lib/firebase-namespace-api.d.ts +1 -1
- package/lib/firebase-namespace-api.js +1 -1
- package/lib/firestore/firestore-internal.d.ts +1 -1
- package/lib/firestore/firestore-internal.js +1 -1
- package/lib/firestore/firestore-namespace.d.ts +1 -1
- package/lib/firestore/firestore-namespace.js +1 -1
- package/lib/firestore/index.d.ts +1 -1
- package/lib/firestore/index.js +1 -1
- package/lib/functions/functions-api-client-internal.d.ts +1 -1
- package/lib/functions/functions-api-client-internal.js +3 -3
- package/lib/functions/functions-api.d.ts +1 -1
- package/lib/functions/functions-api.js +1 -1
- package/lib/functions/functions.d.ts +1 -1
- package/lib/functions/functions.js +1 -1
- package/lib/functions/index.d.ts +1 -1
- package/lib/functions/index.js +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/installations/index.d.ts +1 -1
- package/lib/installations/index.js +1 -1
- package/lib/installations/installations-namespace.d.ts +1 -1
- package/lib/installations/installations-namespace.js +1 -1
- package/lib/installations/installations-request-handler.d.ts +1 -1
- package/lib/installations/installations-request-handler.js +2 -2
- package/lib/installations/installations.d.ts +1 -1
- package/lib/installations/installations.js +1 -1
- package/lib/instance-id/index.d.ts +1 -1
- package/lib/instance-id/index.js +1 -1
- package/lib/instance-id/instance-id-namespace.d.ts +1 -1
- package/lib/instance-id/instance-id-namespace.js +1 -1
- package/lib/instance-id/instance-id.d.ts +1 -1
- package/lib/instance-id/instance-id.js +1 -1
- package/lib/machine-learning/index.d.ts +1 -1
- package/lib/machine-learning/index.js +1 -1
- package/lib/machine-learning/machine-learning-api-client.d.ts +1 -1
- package/lib/machine-learning/machine-learning-api-client.js +1 -1
- package/lib/machine-learning/machine-learning-namespace.d.ts +1 -1
- package/lib/machine-learning/machine-learning-namespace.js +1 -1
- package/lib/machine-learning/machine-learning-utils.d.ts +1 -1
- package/lib/machine-learning/machine-learning-utils.js +1 -1
- package/lib/machine-learning/machine-learning.d.ts +1 -1
- package/lib/machine-learning/machine-learning.js +1 -1
- package/lib/messaging/batch-request-internal.d.ts +4 -4
- package/lib/messaging/batch-request-internal.js +2 -2
- package/lib/messaging/index.d.ts +1 -1
- package/lib/messaging/index.js +1 -1
- package/lib/messaging/messaging-api-request-internal.d.ts +15 -4
- package/lib/messaging/messaging-api-request-internal.js +39 -10
- package/lib/messaging/messaging-api.d.ts +1 -1
- package/lib/messaging/messaging-api.js +1 -1
- package/lib/messaging/messaging-errors-internal.d.ts +6 -6
- package/lib/messaging/messaging-errors-internal.js +4 -4
- package/lib/messaging/messaging-internal.d.ts +1 -1
- package/lib/messaging/messaging-internal.js +1 -1
- package/lib/messaging/messaging-namespace.d.ts +1 -1
- package/lib/messaging/messaging-namespace.js +1 -1
- package/lib/messaging/messaging.d.ts +16 -1
- package/lib/messaging/messaging.js +37 -9
- package/lib/project-management/android-app.d.ts +1 -1
- package/lib/project-management/android-app.js +1 -1
- package/lib/project-management/app-metadata.d.ts +1 -1
- package/lib/project-management/app-metadata.js +1 -1
- package/lib/project-management/index.d.ts +1 -1
- package/lib/project-management/index.js +1 -1
- package/lib/project-management/ios-app.d.ts +1 -1
- package/lib/project-management/ios-app.js +1 -1
- package/lib/project-management/project-management-api-request-internal.d.ts +1 -1
- package/lib/project-management/project-management-api-request-internal.js +3 -3
- package/lib/project-management/project-management-namespace.d.ts +1 -1
- package/lib/project-management/project-management-namespace.js +1 -1
- package/lib/project-management/project-management.d.ts +1 -1
- package/lib/project-management/project-management.js +1 -1
- package/lib/remote-config/condition-evaluator-internal.d.ts +1 -1
- package/lib/remote-config/condition-evaluator-internal.js +20 -14
- package/lib/remote-config/index.d.ts +1 -1
- package/lib/remote-config/index.js +1 -1
- package/lib/remote-config/internal/value-impl.d.ts +1 -1
- package/lib/remote-config/internal/value-impl.js +1 -1
- package/lib/remote-config/remote-config-api-client-internal.d.ts +1 -1
- package/lib/remote-config/remote-config-api-client-internal.js +1 -1
- package/lib/remote-config/remote-config-api.d.ts +1 -1
- package/lib/remote-config/remote-config-api.js +1 -1
- package/lib/remote-config/remote-config-namespace.d.ts +1 -1
- package/lib/remote-config/remote-config-namespace.js +1 -1
- package/lib/remote-config/remote-config.d.ts +1 -1
- package/lib/remote-config/remote-config.js +1 -1
- package/lib/security-rules/index.d.ts +1 -1
- package/lib/security-rules/index.js +1 -1
- package/lib/security-rules/security-rules-api-client-internal.d.ts +1 -1
- package/lib/security-rules/security-rules-api-client-internal.js +1 -1
- package/lib/security-rules/security-rules-internal.d.ts +1 -1
- package/lib/security-rules/security-rules-internal.js +1 -1
- package/lib/security-rules/security-rules-namespace.d.ts +1 -1
- package/lib/security-rules/security-rules-namespace.js +1 -1
- package/lib/security-rules/security-rules.d.ts +1 -1
- package/lib/security-rules/security-rules.js +1 -1
- package/lib/storage/index.d.ts +1 -1
- package/lib/storage/index.js +1 -1
- package/lib/storage/storage-namespace.d.ts +1 -1
- package/lib/storage/storage-namespace.js +1 -1
- package/lib/storage/storage.d.ts +1 -1
- package/lib/storage/storage.js +1 -1
- package/lib/storage/utils.d.ts +1 -1
- package/lib/storage/utils.js +1 -1
- package/lib/utils/api-request.d.ts +134 -42
- package/lib/utils/api-request.js +430 -186
- package/lib/utils/crypto-signer.d.ts +1 -1
- package/lib/utils/crypto-signer.js +2 -2
- package/lib/utils/deep-copy.d.ts +1 -1
- package/lib/utils/deep-copy.js +1 -1
- package/lib/utils/error.d.ts +1 -1
- package/lib/utils/error.js +1 -1
- package/lib/utils/index.d.ts +1 -1
- package/lib/utils/index.js +1 -1
- package/lib/utils/jwt.d.ts +1 -1
- package/lib/utils/jwt.js +3 -3
- package/lib/utils/validator.d.ts +1 -1
- package/lib/utils/validator.js +1 -1
- package/package.json +4 -5
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! firebase-admin v12.
|
|
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 {
|
|
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
|
|
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
|
|
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:
|
|
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.
|
|
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
|
|
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
|
|
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.
|
|
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.
|
|
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
|
-
|
|
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
|
-
})
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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
|
-
|
|
106
|
-
|
|
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
|
|
108
|
+
return instanceMicroPercentile <= normalizedMicroPercent;
|
|
116
109
|
case remote_config_api_1.PercentConditionOperator.GREATER_THAN:
|
|
117
|
-
return instanceMicroPercentile
|
|
110
|
+
return instanceMicroPercentile > normalizedMicroPercent;
|
|
118
111
|
case remote_config_api_1.PercentConditionOperator.BETWEEN:
|
|
119
|
-
return instanceMicroPercentile
|
|
120
|
-
&& instanceMicroPercentile
|
|
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;
|
package/lib/storage/index.d.ts
CHANGED
package/lib/storage/index.js
CHANGED
package/lib/storage/storage.d.ts
CHANGED
package/lib/storage/storage.js
CHANGED
package/lib/storage/utils.d.ts
CHANGED
package/lib/storage/utils.js
CHANGED