firebase-admin 12.7.0 → 13.0.1
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/README.md +1 -2
- package/lib/app/core.d.ts +1 -2
- package/lib/app/core.js +1 -1
- package/lib/app/credential-factory.d.ts +1 -2
- package/lib/app/credential-factory.js +5 -6
- package/lib/app/credential-internal.d.ts +37 -35
- package/lib/app/credential-internal.js +197 -294
- 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 +6 -6
- 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 +3 -3
- package/lib/app-check/token-generator.d.ts +1 -1
- package/lib/app-check/token-generator.js +3 -3
- 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 +3 -4
- package/lib/auth/auth-config.d.ts +1 -1
- package/lib/auth/auth-config.js +3 -3
- 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 +3 -3
- package/lib/auth/identifier.d.ts +1 -1
- package/lib/auth/identifier.js +5 -6
- package/lib/auth/index.d.ts +1 -1
- package/lib/auth/index.js +3 -3
- 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 -2
- package/lib/auth/token-generator.js +3 -3
- package/lib/auth/token-verifier.d.ts +1 -1
- package/lib/auth/token-verifier.js +5 -5
- package/lib/auth/user-import-builder.d.ts +1 -2
- package/lib/auth/user-import-builder.js +3 -3
- 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/data-connect/data-connect-api-client-internal.d.ts +1 -1
- package/lib/data-connect/data-connect-api-client-internal.js +1 -1
- package/lib/data-connect/data-connect-api.d.ts +1 -1
- package/lib/data-connect/data-connect-api.js +1 -1
- package/lib/data-connect/data-connect.d.ts +1 -1
- package/lib/data-connect/data-connect.js +1 -1
- package/lib/data-connect/index.d.ts +1 -1
- package/lib/data-connect/index.js +3 -3
- package/lib/database/database-namespace.d.ts +1 -1
- package/lib/database/database-namespace.js +1 -1
- package/lib/database/database.d.ts +1 -2
- package/lib/database/database.js +1 -1
- package/lib/database/index.d.ts +1 -1
- package/lib/database/index.js +4 -4
- 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 +3 -3
- 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 +3 -3
- 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 +3 -3
- 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 +3 -3
- 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 +4 -4
- package/lib/functions/functions-api-client-internal.d.ts +1 -1
- package/lib/functions/functions-api-client-internal.js +3 -2
- 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 +3 -3
- 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 +3 -3
- 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 +1 -1
- 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 +3 -3
- 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 +3 -3
- package/lib/machine-learning/machine-learning-api-client.d.ts +1 -1
- package/lib/machine-learning/machine-learning-api-client.js +3 -3
- 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/index.d.ts +2 -2
- package/lib/messaging/index.js +3 -3
- package/lib/messaging/messaging-api-request-internal.d.ts +2 -12
- package/lib/messaging/messaging-api-request-internal.js +4 -40
- package/lib/messaging/messaging-api.d.ts +8 -94
- package/lib/messaging/messaging-api.js +1 -1
- package/lib/messaging/messaging-errors-internal.d.ts +1 -1
- package/lib/messaging/messaging-errors-internal.js +3 -4
- package/lib/messaging/messaging-internal.d.ts +1 -1
- package/lib/messaging/messaging-internal.js +4 -3
- package/lib/messaging/messaging-namespace.d.ts +2 -22
- package/lib/messaging/messaging-namespace.js +1 -1
- package/lib/messaging/messaging.d.ts +3 -149
- package/lib/messaging/messaging.js +2 -539
- 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 +3 -3
- 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 +6 -14
- package/lib/remote-config/index.d.ts +1 -1
- package/lib/remote-config/index.js +3 -3
- 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 +3 -3
- 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 -2
- package/lib/security-rules/security-rules.js +1 -1
- package/lib/storage/index.d.ts +1 -1
- package/lib/storage/index.js +4 -4
- 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 +2 -3
- package/lib/utils/api-request.d.ts +1 -5
- package/lib/utils/api-request.js +23 -8
- package/lib/utils/crypto-signer.d.ts +1 -2
- package/lib/utils/crypto-signer.js +3 -3
- package/lib/utils/deep-copy.d.ts +1 -1
- package/lib/utils/deep-copy.js +3 -4
- package/lib/utils/error.d.ts +1 -1
- package/lib/utils/error.js +1 -1
- package/lib/utils/index.d.ts +2 -2
- package/lib/utils/index.js +19 -16
- package/lib/utils/jwt.d.ts +1 -2
- package/lib/utils/jwt.js +5 -5
- package/lib/utils/validator.d.ts +1 -2
- package/lib/utils/validator.js +20 -21
- package/package.json +14 -13
- package/CHANGELOG.md +0 -4
- package/lib/messaging/batch-request-internal.d.ts +0 -55
- package/lib/messaging/batch-request-internal.js +0 -127
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! firebase-admin
|
|
1
|
+
/*! firebase-admin v13.0.1 */
|
|
2
2
|
"use strict";
|
|
3
3
|
/*!
|
|
4
4
|
* @license
|
|
@@ -27,92 +27,11 @@ const messaging_api_request_internal_1 = require("./messaging-api-request-intern
|
|
|
27
27
|
const api_request_1 = require("../utils/api-request");
|
|
28
28
|
// FCM endpoints
|
|
29
29
|
const FCM_SEND_HOST = 'fcm.googleapis.com';
|
|
30
|
-
const FCM_SEND_PATH = '/fcm/send';
|
|
31
30
|
const FCM_TOPIC_MANAGEMENT_HOST = 'iid.googleapis.com';
|
|
32
31
|
const FCM_TOPIC_MANAGEMENT_ADD_PATH = '/iid/v1:batchAdd';
|
|
33
32
|
const FCM_TOPIC_MANAGEMENT_REMOVE_PATH = '/iid/v1:batchRemove';
|
|
34
33
|
// Maximum messages that can be included in a batch request.
|
|
35
34
|
const FCM_MAX_BATCH_SIZE = 500;
|
|
36
|
-
// Key renames for the messaging notification payload object.
|
|
37
|
-
const CAMELCASED_NOTIFICATION_PAYLOAD_KEYS_MAP = {
|
|
38
|
-
bodyLocArgs: 'body_loc_args',
|
|
39
|
-
bodyLocKey: 'body_loc_key',
|
|
40
|
-
clickAction: 'click_action',
|
|
41
|
-
titleLocArgs: 'title_loc_args',
|
|
42
|
-
titleLocKey: 'title_loc_key',
|
|
43
|
-
};
|
|
44
|
-
// Key renames for the messaging options object.
|
|
45
|
-
const CAMELCASE_OPTIONS_KEYS_MAP = {
|
|
46
|
-
dryRun: 'dry_run',
|
|
47
|
-
timeToLive: 'time_to_live',
|
|
48
|
-
collapseKey: 'collapse_key',
|
|
49
|
-
mutableContent: 'mutable_content',
|
|
50
|
-
contentAvailable: 'content_available',
|
|
51
|
-
restrictedPackageName: 'restricted_package_name',
|
|
52
|
-
};
|
|
53
|
-
// Key renames for the MessagingDeviceResult object.
|
|
54
|
-
const MESSAGING_DEVICE_RESULT_KEYS_MAP = {
|
|
55
|
-
message_id: 'messageId',
|
|
56
|
-
registration_id: 'canonicalRegistrationToken',
|
|
57
|
-
};
|
|
58
|
-
// Key renames for the MessagingDevicesResponse object.
|
|
59
|
-
const MESSAGING_DEVICES_RESPONSE_KEYS_MAP = {
|
|
60
|
-
canonical_ids: 'canonicalRegistrationTokenCount',
|
|
61
|
-
failure: 'failureCount',
|
|
62
|
-
success: 'successCount',
|
|
63
|
-
multicast_id: 'multicastId',
|
|
64
|
-
};
|
|
65
|
-
// Key renames for the MessagingDeviceGroupResponse object.
|
|
66
|
-
const MESSAGING_DEVICE_GROUP_RESPONSE_KEYS_MAP = {
|
|
67
|
-
success: 'successCount',
|
|
68
|
-
failure: 'failureCount',
|
|
69
|
-
failed_registration_ids: 'failedRegistrationTokens',
|
|
70
|
-
};
|
|
71
|
-
// Key renames for the MessagingTopicResponse object.
|
|
72
|
-
const MESSAGING_TOPIC_RESPONSE_KEYS_MAP = {
|
|
73
|
-
message_id: 'messageId',
|
|
74
|
-
};
|
|
75
|
-
// Key renames for the MessagingConditionResponse object.
|
|
76
|
-
const MESSAGING_CONDITION_RESPONSE_KEYS_MAP = {
|
|
77
|
-
message_id: 'messageId',
|
|
78
|
-
};
|
|
79
|
-
/**
|
|
80
|
-
* Maps a raw FCM server response to a `MessagingDevicesResponse` object.
|
|
81
|
-
*
|
|
82
|
-
* @param response - The raw FCM server response to map.
|
|
83
|
-
*
|
|
84
|
-
* @returns The mapped `MessagingDevicesResponse` object.
|
|
85
|
-
*/
|
|
86
|
-
function mapRawResponseToDevicesResponse(response) {
|
|
87
|
-
// Rename properties on the server response
|
|
88
|
-
utils.renameProperties(response, MESSAGING_DEVICES_RESPONSE_KEYS_MAP);
|
|
89
|
-
if ('results' in response) {
|
|
90
|
-
response.results.forEach((messagingDeviceResult) => {
|
|
91
|
-
utils.renameProperties(messagingDeviceResult, MESSAGING_DEVICE_RESULT_KEYS_MAP);
|
|
92
|
-
// Map the FCM server's error strings to actual error objects.
|
|
93
|
-
if ('error' in messagingDeviceResult) {
|
|
94
|
-
const newError = error_1.FirebaseMessagingError.fromServerError(messagingDeviceResult.error, /* message */ undefined, messagingDeviceResult.error);
|
|
95
|
-
messagingDeviceResult.error = newError;
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
return response;
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Maps a raw FCM server response to a `MessagingDeviceGroupResponse` object.
|
|
103
|
-
*
|
|
104
|
-
* @param response - The raw FCM server response to map.
|
|
105
|
-
*
|
|
106
|
-
* @returns The mapped `MessagingDeviceGroupResponse` object.
|
|
107
|
-
*/
|
|
108
|
-
function mapRawResponseToDeviceGroupResponse(response) {
|
|
109
|
-
// Rename properties on the server response
|
|
110
|
-
utils.renameProperties(response, MESSAGING_DEVICE_GROUP_RESPONSE_KEYS_MAP);
|
|
111
|
-
// Add the 'failedRegistrationTokens' property if it does not exist on the response, which
|
|
112
|
-
// it won't when the 'failureCount' property has a value of 0)
|
|
113
|
-
response.failedRegistrationTokens = response.failedRegistrationTokens || [];
|
|
114
|
-
return response;
|
|
115
|
-
}
|
|
116
35
|
/**
|
|
117
36
|
* Maps a raw FCM server response to a `MessagingTopicManagementResponse` object.
|
|
118
37
|
*
|
|
@@ -219,7 +138,7 @@ class Messaging {
|
|
|
219
138
|
/**
|
|
220
139
|
* Sends each message in the given array via Firebase Cloud Messaging.
|
|
221
140
|
*
|
|
222
|
-
*
|
|
141
|
+
* This method makes a single RPC call for each message
|
|
223
142
|
* in the given array.
|
|
224
143
|
*
|
|
225
144
|
* The responses list obtained from the return value corresponds to the order of `messages`.
|
|
@@ -332,325 +251,6 @@ class Messaging {
|
|
|
332
251
|
});
|
|
333
252
|
return this.sendEach(messages, dryRun);
|
|
334
253
|
}
|
|
335
|
-
/**
|
|
336
|
-
* Sends all the messages in the given array via Firebase Cloud Messaging.
|
|
337
|
-
* Employs batching to send the entire list as a single RPC call. Compared
|
|
338
|
-
* to the `send()` method, this method is a significantly more efficient way
|
|
339
|
-
* to send multiple messages.
|
|
340
|
-
*
|
|
341
|
-
* The responses list obtained from the return value
|
|
342
|
-
* corresponds to the order of tokens in the `MulticastMessage`. An error
|
|
343
|
-
* from this method indicates a total failure, meaning that none of the messages
|
|
344
|
-
* in the list could be sent. Partial failures are indicated by a `BatchResponse`
|
|
345
|
-
* return value.
|
|
346
|
-
*
|
|
347
|
-
* @param messages - A non-empty array
|
|
348
|
-
* containing up to 500 messages.
|
|
349
|
-
* @param dryRun - Whether to send the messages in the dry-run
|
|
350
|
-
* (validation only) mode.
|
|
351
|
-
* @returns A Promise fulfilled with an object representing the result of the
|
|
352
|
-
* send operation.
|
|
353
|
-
*
|
|
354
|
-
* @deprecated Use {@link Messaging.sendEach} instead.
|
|
355
|
-
*/
|
|
356
|
-
sendAll(messages, dryRun) {
|
|
357
|
-
if (validator.isArray(messages) && messages.constructor !== Array) {
|
|
358
|
-
// In more recent JS specs, an array-like object might have a constructor that is not of
|
|
359
|
-
// Array type. Our deepCopy() method doesn't handle them properly. Convert such objects to
|
|
360
|
-
// a regular array here before calling deepCopy(). See issue #566 for details.
|
|
361
|
-
messages = Array.from(messages);
|
|
362
|
-
}
|
|
363
|
-
const copy = (0, deep_copy_1.deepCopy)(messages);
|
|
364
|
-
if (!validator.isNonEmptyArray(copy)) {
|
|
365
|
-
throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_ARGUMENT, 'messages must be a non-empty array');
|
|
366
|
-
}
|
|
367
|
-
if (copy.length > FCM_MAX_BATCH_SIZE) {
|
|
368
|
-
throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_ARGUMENT, `messages list must not contain more than ${FCM_MAX_BATCH_SIZE} items`);
|
|
369
|
-
}
|
|
370
|
-
if (typeof dryRun !== 'undefined' && !validator.isBoolean(dryRun)) {
|
|
371
|
-
throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_ARGUMENT, 'dryRun must be a boolean');
|
|
372
|
-
}
|
|
373
|
-
return this.getUrlPath()
|
|
374
|
-
.then((urlPath) => {
|
|
375
|
-
const requests = copy.map((message) => {
|
|
376
|
-
(0, messaging_internal_1.validateMessage)(message);
|
|
377
|
-
const request = { message };
|
|
378
|
-
if (dryRun) {
|
|
379
|
-
request.validate_only = true;
|
|
380
|
-
}
|
|
381
|
-
return {
|
|
382
|
-
url: `https://${FCM_SEND_HOST}${urlPath}`,
|
|
383
|
-
body: request,
|
|
384
|
-
};
|
|
385
|
-
});
|
|
386
|
-
return this.messagingRequestHandler.sendBatchRequest(requests);
|
|
387
|
-
});
|
|
388
|
-
}
|
|
389
|
-
/**
|
|
390
|
-
* Sends the given multicast message to all the FCM registration tokens
|
|
391
|
-
* specified in it.
|
|
392
|
-
*
|
|
393
|
-
* This method uses the `sendAll()` API under the hood to send the given
|
|
394
|
-
* message to all the target recipients. The responses list obtained from the
|
|
395
|
-
* return value corresponds to the order of tokens in the `MulticastMessage`.
|
|
396
|
-
* An error from this method indicates a total failure, meaning that the message
|
|
397
|
-
* was not sent to any of the tokens in the list. Partial failures are indicated
|
|
398
|
-
* by a `BatchResponse` return value.
|
|
399
|
-
*
|
|
400
|
-
* @param message - A multicast message
|
|
401
|
-
* containing up to 500 tokens.
|
|
402
|
-
* @param dryRun - Whether to send the message in the dry-run
|
|
403
|
-
* (validation only) mode.
|
|
404
|
-
* @returns A Promise fulfilled with an object representing the result of the
|
|
405
|
-
* send operation.
|
|
406
|
-
*
|
|
407
|
-
* @deprecated Use {@link Messaging.sendEachForMulticast} instead.
|
|
408
|
-
*/
|
|
409
|
-
sendMulticast(message, dryRun) {
|
|
410
|
-
const copy = (0, deep_copy_1.deepCopy)(message);
|
|
411
|
-
if (!validator.isNonNullObject(copy)) {
|
|
412
|
-
throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_ARGUMENT, 'MulticastMessage must be a non-null object');
|
|
413
|
-
}
|
|
414
|
-
if (!validator.isNonEmptyArray(copy.tokens)) {
|
|
415
|
-
throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_ARGUMENT, 'tokens must be a non-empty array');
|
|
416
|
-
}
|
|
417
|
-
if (copy.tokens.length > FCM_MAX_BATCH_SIZE) {
|
|
418
|
-
throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_ARGUMENT, `tokens list must not contain more than ${FCM_MAX_BATCH_SIZE} items`);
|
|
419
|
-
}
|
|
420
|
-
const messages = copy.tokens.map((token) => {
|
|
421
|
-
return {
|
|
422
|
-
token,
|
|
423
|
-
android: copy.android,
|
|
424
|
-
apns: copy.apns,
|
|
425
|
-
data: copy.data,
|
|
426
|
-
notification: copy.notification,
|
|
427
|
-
webpush: copy.webpush,
|
|
428
|
-
fcmOptions: copy.fcmOptions,
|
|
429
|
-
};
|
|
430
|
-
});
|
|
431
|
-
return this.sendAll(messages, dryRun);
|
|
432
|
-
}
|
|
433
|
-
/**
|
|
434
|
-
* Sends an FCM message to a single device corresponding to the provided
|
|
435
|
-
* registration token.
|
|
436
|
-
*
|
|
437
|
-
* See {@link https://firebase.google.com/docs/cloud-messaging/admin/legacy-fcm#send_to_individual_devices |
|
|
438
|
-
* Send to individual devices}
|
|
439
|
-
* for code samples and detailed documentation. Takes either a
|
|
440
|
-
* `registrationToken` to send to a single device or a
|
|
441
|
-
* `registrationTokens` parameter containing an array of tokens to send
|
|
442
|
-
* to multiple devices.
|
|
443
|
-
*
|
|
444
|
-
* @param registrationToken - A device registration token or an array of
|
|
445
|
-
* device registration tokens to which the message should be sent.
|
|
446
|
-
* @param payload - The message payload.
|
|
447
|
-
* @param options - Optional options to
|
|
448
|
-
* alter the message.
|
|
449
|
-
*
|
|
450
|
-
* @returns A promise fulfilled with the server's response after the message
|
|
451
|
-
* has been sent.
|
|
452
|
-
*
|
|
453
|
-
* @deprecated Use {@link Messaging.send} instead.
|
|
454
|
-
*/
|
|
455
|
-
sendToDevice(registrationTokenOrTokens, payload, options = {}) {
|
|
456
|
-
// Validate the input argument types. Since these are common developer errors when getting
|
|
457
|
-
// started, throw an error instead of returning a rejected promise.
|
|
458
|
-
this.validateRegistrationTokensType(registrationTokenOrTokens, 'sendToDevice', error_1.MessagingClientErrorCode.INVALID_RECIPIENT);
|
|
459
|
-
this.validateMessagingPayloadAndOptionsTypes(payload, options);
|
|
460
|
-
return Promise.resolve()
|
|
461
|
-
.then(() => {
|
|
462
|
-
// Validate the contents of the input arguments. Because we are now in a promise, any thrown
|
|
463
|
-
// error will cause this method to return a rejected promise.
|
|
464
|
-
this.validateRegistrationTokens(registrationTokenOrTokens, 'sendToDevice', error_1.MessagingClientErrorCode.INVALID_RECIPIENT);
|
|
465
|
-
const payloadCopy = this.validateMessagingPayload(payload);
|
|
466
|
-
const optionsCopy = this.validateMessagingOptions(options);
|
|
467
|
-
const request = (0, deep_copy_1.deepCopy)(payloadCopy);
|
|
468
|
-
(0, deep_copy_1.deepExtend)(request, optionsCopy);
|
|
469
|
-
if (validator.isString(registrationTokenOrTokens)) {
|
|
470
|
-
request.to = registrationTokenOrTokens;
|
|
471
|
-
}
|
|
472
|
-
else {
|
|
473
|
-
request.registration_ids = registrationTokenOrTokens;
|
|
474
|
-
}
|
|
475
|
-
return this.messagingRequestHandler.invokeRequestHandler(FCM_SEND_HOST, FCM_SEND_PATH, request);
|
|
476
|
-
})
|
|
477
|
-
.then((response) => {
|
|
478
|
-
// The sendToDevice() and sendToDeviceGroup() methods both set the `to` query parameter in
|
|
479
|
-
// the underlying FCM request. If the provided registration token argument is actually a
|
|
480
|
-
// valid notification key, the response from the FCM server will be a device group response.
|
|
481
|
-
// If that is the case, we map the response to a MessagingDeviceGroupResponse.
|
|
482
|
-
// See b/35394951 for more context.
|
|
483
|
-
if ('multicast_id' in response) {
|
|
484
|
-
return mapRawResponseToDevicesResponse(response);
|
|
485
|
-
}
|
|
486
|
-
else {
|
|
487
|
-
const groupResponse = mapRawResponseToDeviceGroupResponse(response);
|
|
488
|
-
return {
|
|
489
|
-
...groupResponse,
|
|
490
|
-
canonicalRegistrationTokenCount: -1,
|
|
491
|
-
multicastId: -1,
|
|
492
|
-
results: [],
|
|
493
|
-
};
|
|
494
|
-
}
|
|
495
|
-
});
|
|
496
|
-
}
|
|
497
|
-
/**
|
|
498
|
-
* Sends an FCM message to a device group corresponding to the provided
|
|
499
|
-
* notification key.
|
|
500
|
-
*
|
|
501
|
-
* See {@link https://firebase.google.com/docs/cloud-messaging/admin/legacy-fcm#send_to_a_device_group |
|
|
502
|
-
* Send to a device group} for code samples and detailed documentation.
|
|
503
|
-
*
|
|
504
|
-
* @param notificationKey - The notification key for the device group to
|
|
505
|
-
* which to send the message.
|
|
506
|
-
* @param payload - The message payload.
|
|
507
|
-
* @param options - Optional options to
|
|
508
|
-
* alter the message.
|
|
509
|
-
*
|
|
510
|
-
* @returns A promise fulfilled with the server's response after the message
|
|
511
|
-
* has been sent.
|
|
512
|
-
*
|
|
513
|
-
* @deprecated Use {@link Messaging.send} instead.
|
|
514
|
-
*/
|
|
515
|
-
sendToDeviceGroup(notificationKey, payload, options = {}) {
|
|
516
|
-
if (!validator.isNonEmptyString(notificationKey)) {
|
|
517
|
-
throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_RECIPIENT, 'Notification key provided to sendToDeviceGroup() must be a non-empty string.');
|
|
518
|
-
}
|
|
519
|
-
else if (notificationKey.indexOf(':') !== -1) {
|
|
520
|
-
// It is possible the developer provides a registration token instead of a notification key
|
|
521
|
-
// to this method. We can detect some of those cases by checking to see if the string contains
|
|
522
|
-
// a colon. Not all registration tokens will contain a colon (only newer ones will), but no
|
|
523
|
-
// notification keys will contain a colon, so we can use it as a rough heuristic.
|
|
524
|
-
// See b/35394951 for more context.
|
|
525
|
-
return Promise.reject(new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_RECIPIENT, 'Notification key provided to sendToDeviceGroup() has the format of a registration token. ' +
|
|
526
|
-
'You should use sendToDevice() instead.'));
|
|
527
|
-
}
|
|
528
|
-
// Validate the types of the payload and options arguments. Since these are common developer
|
|
529
|
-
// errors, throw an error instead of returning a rejected promise.
|
|
530
|
-
this.validateMessagingPayloadAndOptionsTypes(payload, options);
|
|
531
|
-
return Promise.resolve()
|
|
532
|
-
.then(() => {
|
|
533
|
-
// Validate the contents of the payload and options objects. Because we are now in a
|
|
534
|
-
// promise, any thrown error will cause this method to return a rejected promise.
|
|
535
|
-
const payloadCopy = this.validateMessagingPayload(payload);
|
|
536
|
-
const optionsCopy = this.validateMessagingOptions(options);
|
|
537
|
-
const request = (0, deep_copy_1.deepCopy)(payloadCopy);
|
|
538
|
-
(0, deep_copy_1.deepExtend)(request, optionsCopy);
|
|
539
|
-
request.to = notificationKey;
|
|
540
|
-
return this.messagingRequestHandler.invokeRequestHandler(FCM_SEND_HOST, FCM_SEND_PATH, request);
|
|
541
|
-
})
|
|
542
|
-
.then((response) => {
|
|
543
|
-
// The sendToDevice() and sendToDeviceGroup() methods both set the `to` query parameter in
|
|
544
|
-
// the underlying FCM request. If the provided notification key argument has an invalid
|
|
545
|
-
// format (that is, it is either a registration token or some random string), the response
|
|
546
|
-
// from the FCM server will default to a devices response (which we detect by looking for
|
|
547
|
-
// the `multicast_id` property). If that is the case, we either throw an error saying the
|
|
548
|
-
// provided notification key is invalid (if the message failed to send) or map the response
|
|
549
|
-
// to a MessagingDevicesResponse (if the message succeeded).
|
|
550
|
-
// See b/35394951 for more context.
|
|
551
|
-
if ('multicast_id' in response) {
|
|
552
|
-
if (response.success === 0) {
|
|
553
|
-
throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_RECIPIENT, 'Notification key provided to sendToDeviceGroup() is invalid.');
|
|
554
|
-
}
|
|
555
|
-
else {
|
|
556
|
-
const devicesResponse = mapRawResponseToDevicesResponse(response);
|
|
557
|
-
return {
|
|
558
|
-
...devicesResponse,
|
|
559
|
-
failedRegistrationTokens: [],
|
|
560
|
-
};
|
|
561
|
-
}
|
|
562
|
-
}
|
|
563
|
-
return mapRawResponseToDeviceGroupResponse(response);
|
|
564
|
-
});
|
|
565
|
-
}
|
|
566
|
-
/**
|
|
567
|
-
* Sends an FCM message to a topic.
|
|
568
|
-
*
|
|
569
|
-
* See {@link https://firebase.google.com/docs/cloud-messaging/admin/legacy-fcm#send_to_a_topic |
|
|
570
|
-
* Send to a topic} for code samples and detailed documentation.
|
|
571
|
-
*
|
|
572
|
-
* @param topic - The topic to which to send the message.
|
|
573
|
-
* @param payload - The message payload.
|
|
574
|
-
* @param options - Optional options to
|
|
575
|
-
* alter the message.
|
|
576
|
-
*
|
|
577
|
-
* @returns A promise fulfilled with the server's response after the message
|
|
578
|
-
* has been sent.
|
|
579
|
-
*
|
|
580
|
-
* @deprecated Use {@link Messaging.send} instead.
|
|
581
|
-
*/
|
|
582
|
-
sendToTopic(topic, payload, options = {}) {
|
|
583
|
-
// Validate the input argument types. Since these are common developer errors when getting
|
|
584
|
-
// started, throw an error instead of returning a rejected promise.
|
|
585
|
-
this.validateTopicType(topic, 'sendToTopic', error_1.MessagingClientErrorCode.INVALID_RECIPIENT);
|
|
586
|
-
this.validateMessagingPayloadAndOptionsTypes(payload, options);
|
|
587
|
-
// Prepend the topic with /topics/ if necessary.
|
|
588
|
-
topic = this.normalizeTopic(topic);
|
|
589
|
-
return Promise.resolve()
|
|
590
|
-
.then(() => {
|
|
591
|
-
// Validate the contents of the payload and options objects. Because we are now in a
|
|
592
|
-
// promise, any thrown error will cause this method to return a rejected promise.
|
|
593
|
-
const payloadCopy = this.validateMessagingPayload(payload);
|
|
594
|
-
const optionsCopy = this.validateMessagingOptions(options);
|
|
595
|
-
this.validateTopic(topic, 'sendToTopic', error_1.MessagingClientErrorCode.INVALID_RECIPIENT);
|
|
596
|
-
const request = (0, deep_copy_1.deepCopy)(payloadCopy);
|
|
597
|
-
(0, deep_copy_1.deepExtend)(request, optionsCopy);
|
|
598
|
-
request.to = topic;
|
|
599
|
-
return this.messagingRequestHandler.invokeRequestHandler(FCM_SEND_HOST, FCM_SEND_PATH, request);
|
|
600
|
-
})
|
|
601
|
-
.then((response) => {
|
|
602
|
-
// Rename properties on the server response
|
|
603
|
-
utils.renameProperties(response, MESSAGING_TOPIC_RESPONSE_KEYS_MAP);
|
|
604
|
-
return response;
|
|
605
|
-
});
|
|
606
|
-
}
|
|
607
|
-
/**
|
|
608
|
-
* Sends an FCM message to a condition.
|
|
609
|
-
*
|
|
610
|
-
* See {@link https://firebase.google.com/docs/cloud-messaging/admin/legacy-fcm#send_to_a_condition |
|
|
611
|
-
* Send to a condition}
|
|
612
|
-
* for code samples and detailed documentation.
|
|
613
|
-
*
|
|
614
|
-
* @param condition - The condition determining to which topics to send
|
|
615
|
-
* the message.
|
|
616
|
-
* @param payload - The message payload.
|
|
617
|
-
* @param options - Optional options to
|
|
618
|
-
* alter the message.
|
|
619
|
-
*
|
|
620
|
-
* @returns A promise fulfilled with the server's response after the message
|
|
621
|
-
* has been sent.
|
|
622
|
-
*
|
|
623
|
-
* @deprecated Use {@link Messaging.send} instead.
|
|
624
|
-
*/
|
|
625
|
-
sendToCondition(condition, payload, options = {}) {
|
|
626
|
-
if (!validator.isNonEmptyString(condition)) {
|
|
627
|
-
throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_RECIPIENT, 'Condition provided to sendToCondition() must be a non-empty string.');
|
|
628
|
-
}
|
|
629
|
-
// Validate the types of the payload and options arguments. Since these are common developer
|
|
630
|
-
// errors, throw an error instead of returning a rejected promise.
|
|
631
|
-
this.validateMessagingPayloadAndOptionsTypes(payload, options);
|
|
632
|
-
// The FCM server rejects conditions which are surrounded in single quotes. When the condition
|
|
633
|
-
// is stringified over the wire, double quotes in it get converted to \" which the FCM server
|
|
634
|
-
// does not properly handle. We can get around this by replacing internal double quotes with
|
|
635
|
-
// single quotes.
|
|
636
|
-
condition = condition.replace(/"/g, '\'');
|
|
637
|
-
return Promise.resolve()
|
|
638
|
-
.then(() => {
|
|
639
|
-
// Validate the contents of the payload and options objects. Because we are now in a
|
|
640
|
-
// promise, any thrown error will cause this method to return a rejected promise.
|
|
641
|
-
const payloadCopy = this.validateMessagingPayload(payload);
|
|
642
|
-
const optionsCopy = this.validateMessagingOptions(options);
|
|
643
|
-
const request = (0, deep_copy_1.deepCopy)(payloadCopy);
|
|
644
|
-
(0, deep_copy_1.deepExtend)(request, optionsCopy);
|
|
645
|
-
request.condition = condition;
|
|
646
|
-
return this.messagingRequestHandler.invokeRequestHandler(FCM_SEND_HOST, FCM_SEND_PATH, request);
|
|
647
|
-
})
|
|
648
|
-
.then((response) => {
|
|
649
|
-
// Rename properties on the server response
|
|
650
|
-
utils.renameProperties(response, MESSAGING_CONDITION_RESPONSE_KEYS_MAP);
|
|
651
|
-
return response;
|
|
652
|
-
});
|
|
653
|
-
}
|
|
654
254
|
/**
|
|
655
255
|
* Subscribes a device to an FCM topic.
|
|
656
256
|
*
|
|
@@ -741,143 +341,6 @@ class Messaging {
|
|
|
741
341
|
return mapRawResponseToTopicManagementResponse(response);
|
|
742
342
|
});
|
|
743
343
|
}
|
|
744
|
-
/**
|
|
745
|
-
* Validates the types of the messaging payload and options. If invalid, an error will be thrown.
|
|
746
|
-
*
|
|
747
|
-
* @param payload - The messaging payload to validate.
|
|
748
|
-
* @param options - The messaging options to validate.
|
|
749
|
-
*/
|
|
750
|
-
validateMessagingPayloadAndOptionsTypes(payload, options) {
|
|
751
|
-
// Validate the payload is an object
|
|
752
|
-
if (!validator.isNonNullObject(payload)) {
|
|
753
|
-
throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'Messaging payload must be an object with at least one of the "data" or "notification" properties.');
|
|
754
|
-
}
|
|
755
|
-
// Validate the options argument is an object
|
|
756
|
-
if (!validator.isNonNullObject(options)) {
|
|
757
|
-
throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_OPTIONS, 'Messaging options must be an object.');
|
|
758
|
-
}
|
|
759
|
-
}
|
|
760
|
-
/**
|
|
761
|
-
* Validates the messaging payload. If invalid, an error will be thrown.
|
|
762
|
-
*
|
|
763
|
-
* @param payload - The messaging payload to validate.
|
|
764
|
-
*
|
|
765
|
-
* @returns A copy of the provided payload with whitelisted properties switched
|
|
766
|
-
* from camelCase to underscore_case.
|
|
767
|
-
*/
|
|
768
|
-
validateMessagingPayload(payload) {
|
|
769
|
-
const payloadCopy = (0, deep_copy_1.deepCopy)(payload);
|
|
770
|
-
const payloadKeys = Object.keys(payloadCopy);
|
|
771
|
-
const validPayloadKeys = ['data', 'notification'];
|
|
772
|
-
let containsDataOrNotificationKey = false;
|
|
773
|
-
payloadKeys.forEach((payloadKey) => {
|
|
774
|
-
// Validate the payload does not contain any invalid keys
|
|
775
|
-
if (validPayloadKeys.indexOf(payloadKey) === -1) {
|
|
776
|
-
throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, `Messaging payload contains an invalid "${payloadKey}" property. Valid properties are ` +
|
|
777
|
-
'"data" and "notification".');
|
|
778
|
-
}
|
|
779
|
-
else {
|
|
780
|
-
containsDataOrNotificationKey = true;
|
|
781
|
-
}
|
|
782
|
-
});
|
|
783
|
-
// Validate the payload contains at least one of the "data" and "notification" keys
|
|
784
|
-
if (!containsDataOrNotificationKey) {
|
|
785
|
-
throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'Messaging payload must contain at least one of the "data" or "notification" properties.');
|
|
786
|
-
}
|
|
787
|
-
const validatePayload = (payloadKey, value) => {
|
|
788
|
-
// Validate each top-level key in the payload is an object
|
|
789
|
-
if (!validator.isNonNullObject(value)) {
|
|
790
|
-
throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, `Messaging payload contains an invalid value for the "${payloadKey}" property. ` +
|
|
791
|
-
'Value must be an object.');
|
|
792
|
-
}
|
|
793
|
-
Object.keys(value).forEach((subKey) => {
|
|
794
|
-
if (!validator.isString(value[subKey])) {
|
|
795
|
-
// Validate all sub-keys have a string value
|
|
796
|
-
throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, `Messaging payload contains an invalid value for the "${payloadKey}.${subKey}" ` +
|
|
797
|
-
'property. Values must be strings.');
|
|
798
|
-
}
|
|
799
|
-
else if (payloadKey === 'data' && /^google\./.test(subKey)) {
|
|
800
|
-
// Validate the data payload does not contain keys which start with 'google.'.
|
|
801
|
-
throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, `Messaging payload contains the blacklisted "data.${subKey}" property.`);
|
|
802
|
-
}
|
|
803
|
-
});
|
|
804
|
-
};
|
|
805
|
-
if (payloadCopy.data !== undefined) {
|
|
806
|
-
validatePayload('data', payloadCopy.data);
|
|
807
|
-
}
|
|
808
|
-
if (payloadCopy.notification !== undefined) {
|
|
809
|
-
validatePayload('notification', payloadCopy.notification);
|
|
810
|
-
}
|
|
811
|
-
// Validate the data payload object does not contain blacklisted properties
|
|
812
|
-
if ('data' in payloadCopy) {
|
|
813
|
-
messaging_internal_1.BLACKLISTED_DATA_PAYLOAD_KEYS.forEach((blacklistedKey) => {
|
|
814
|
-
if (blacklistedKey in payloadCopy.data) {
|
|
815
|
-
throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, `Messaging payload contains the blacklisted "data.${blacklistedKey}" property.`);
|
|
816
|
-
}
|
|
817
|
-
});
|
|
818
|
-
}
|
|
819
|
-
// Convert whitelisted camelCase keys to underscore_case
|
|
820
|
-
if (payloadCopy.notification) {
|
|
821
|
-
utils.renameProperties(payloadCopy.notification, CAMELCASED_NOTIFICATION_PAYLOAD_KEYS_MAP);
|
|
822
|
-
}
|
|
823
|
-
return payloadCopy;
|
|
824
|
-
}
|
|
825
|
-
/**
|
|
826
|
-
* Validates the messaging options. If invalid, an error will be thrown.
|
|
827
|
-
*
|
|
828
|
-
* @param options - The messaging options to validate.
|
|
829
|
-
*
|
|
830
|
-
* @returns A copy of the provided options with whitelisted properties switched
|
|
831
|
-
* from camelCase to underscore_case.
|
|
832
|
-
*/
|
|
833
|
-
validateMessagingOptions(options) {
|
|
834
|
-
const optionsCopy = (0, deep_copy_1.deepCopy)(options);
|
|
835
|
-
// Validate the options object does not contain blacklisted properties
|
|
836
|
-
messaging_internal_1.BLACKLISTED_OPTIONS_KEYS.forEach((blacklistedKey) => {
|
|
837
|
-
if (blacklistedKey in optionsCopy) {
|
|
838
|
-
throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_OPTIONS, `Messaging options contains the blacklisted "${blacklistedKey}" property.`);
|
|
839
|
-
}
|
|
840
|
-
});
|
|
841
|
-
// Convert whitelisted camelCase keys to underscore_case
|
|
842
|
-
utils.renameProperties(optionsCopy, CAMELCASE_OPTIONS_KEYS_MAP);
|
|
843
|
-
// Validate the options object contains valid values for whitelisted properties
|
|
844
|
-
if ('collapse_key' in optionsCopy && !validator.isNonEmptyString(optionsCopy.collapse_key)) {
|
|
845
|
-
const keyName = ('collapseKey' in options) ? 'collapseKey' : 'collapse_key';
|
|
846
|
-
throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_OPTIONS, `Messaging options contains an invalid value for the "${keyName}" property. Value must ` +
|
|
847
|
-
'be a non-empty string.');
|
|
848
|
-
}
|
|
849
|
-
else if ('dry_run' in optionsCopy && !validator.isBoolean(optionsCopy.dry_run)) {
|
|
850
|
-
const keyName = ('dryRun' in options) ? 'dryRun' : 'dry_run';
|
|
851
|
-
throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_OPTIONS, `Messaging options contains an invalid value for the "${keyName}" property. Value must ` +
|
|
852
|
-
'be a boolean.');
|
|
853
|
-
}
|
|
854
|
-
else if ('priority' in optionsCopy && !validator.isNonEmptyString(optionsCopy.priority)) {
|
|
855
|
-
throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_OPTIONS, 'Messaging options contains an invalid value for the "priority" property. Value must ' +
|
|
856
|
-
'be a non-empty string.');
|
|
857
|
-
}
|
|
858
|
-
else if ('restricted_package_name' in optionsCopy &&
|
|
859
|
-
!validator.isNonEmptyString(optionsCopy.restricted_package_name)) {
|
|
860
|
-
const keyName = ('restrictedPackageName' in options) ? 'restrictedPackageName' : 'restricted_package_name';
|
|
861
|
-
throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_OPTIONS, `Messaging options contains an invalid value for the "${keyName}" property. Value must ` +
|
|
862
|
-
'be a non-empty string.');
|
|
863
|
-
}
|
|
864
|
-
else if ('time_to_live' in optionsCopy && !validator.isNumber(optionsCopy.time_to_live)) {
|
|
865
|
-
const keyName = ('timeToLive' in options) ? 'timeToLive' : 'time_to_live';
|
|
866
|
-
throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_OPTIONS, `Messaging options contains an invalid value for the "${keyName}" property. Value must ` +
|
|
867
|
-
'be a number.');
|
|
868
|
-
}
|
|
869
|
-
else if ('content_available' in optionsCopy && !validator.isBoolean(optionsCopy.content_available)) {
|
|
870
|
-
const keyName = ('contentAvailable' in options) ? 'contentAvailable' : 'content_available';
|
|
871
|
-
throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_OPTIONS, `Messaging options contains an invalid value for the "${keyName}" property. Value must ` +
|
|
872
|
-
'be a boolean.');
|
|
873
|
-
}
|
|
874
|
-
else if ('mutable_content' in optionsCopy && !validator.isBoolean(optionsCopy.mutable_content)) {
|
|
875
|
-
const keyName = ('mutableContent' in options) ? 'mutableContent' : 'mutable_content';
|
|
876
|
-
throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_OPTIONS, `Messaging options contains an invalid value for the "${keyName}" property. Value must ` +
|
|
877
|
-
'be a boolean.');
|
|
878
|
-
}
|
|
879
|
-
return optionsCopy;
|
|
880
|
-
}
|
|
881
344
|
/**
|
|
882
345
|
* Validates the type of the provided registration token(s). If invalid, an error will be thrown.
|
|
883
346
|
*
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! firebase-admin
|
|
1
|
+
/*! firebase-admin v13.0.1 */
|
|
2
2
|
"use strict";
|
|
3
3
|
/*!
|
|
4
4
|
* Copyright 2020 Google Inc.
|
|
@@ -16,7 +16,8 @@
|
|
|
16
16
|
* limitations under the License.
|
|
17
17
|
*/
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
-
exports.FirebaseProjectManagementError = exports.
|
|
19
|
+
exports.FirebaseProjectManagementError = exports.IosApp = exports.ShaCertificate = exports.AndroidApp = exports.ProjectManagement = exports.AppPlatform = void 0;
|
|
20
|
+
exports.getProjectManagement = getProjectManagement;
|
|
20
21
|
/**
|
|
21
22
|
* Firebase project management.
|
|
22
23
|
*
|
|
@@ -65,6 +66,5 @@ function getProjectManagement(app) {
|
|
|
65
66
|
const firebaseApp = app;
|
|
66
67
|
return firebaseApp.getOrInitService('projectManagement', (app) => new project_management_1.ProjectManagement(app));
|
|
67
68
|
}
|
|
68
|
-
exports.getProjectManagement = getProjectManagement;
|
|
69
69
|
var error_1 = require("../utils/error");
|
|
70
70
|
Object.defineProperty(exports, "FirebaseProjectManagementError", { enumerable: true, get: function () { return error_1.FirebaseProjectManagementError; } });
|