firebase-admin
Advanced tools
Comparing version 4.1.4 to 4.2.0
@@ -1,2 +0,2 @@ | ||
/*! firebase-admin v4.1.4 | ||
/*! firebase-admin v4.2.0 | ||
https://firebase.google.com/terms/ */ | ||
@@ -19,3 +19,3 @@ "use strict"; | ||
'Content-Type': 'application/json', | ||
'X-Client-Version': 'Node/Admin/4.1.4', | ||
'X-Client-Version': 'Node/Admin/4.2.0', | ||
}; | ||
@@ -22,0 +22,0 @@ /** Firebase Auth request timeout duration in milliseconds. */ |
@@ -1,2 +0,2 @@ | ||
/*! firebase-admin v4.1.4 | ||
/*! firebase-admin v4.2.0 | ||
https://firebase.google.com/terms/ */ | ||
@@ -3,0 +3,0 @@ "use strict"; |
@@ -1,2 +0,2 @@ | ||
/*! firebase-admin v4.1.4 | ||
/*! firebase-admin v4.2.0 | ||
https://firebase.google.com/terms/ */ | ||
@@ -3,0 +3,0 @@ "use strict"; |
@@ -1,2 +0,2 @@ | ||
/*! firebase-admin v4.1.4 | ||
/*! firebase-admin v4.2.0 | ||
https://firebase.google.com/terms/ */ | ||
@@ -3,0 +3,0 @@ "use strict"; |
@@ -1,2 +0,2 @@ | ||
/*! firebase-admin v4.1.4 | ||
/*! firebase-admin v4.2.0 | ||
https://firebase.google.com/terms/ */ | ||
@@ -3,0 +3,0 @@ "use strict"; |
@@ -1,2 +0,2 @@ | ||
/*! firebase-admin v4.1.4 | ||
/*! firebase-admin v4.2.0 | ||
https://firebase.google.com/terms/ */ | ||
@@ -3,0 +3,0 @@ "use strict"; |
@@ -1,2 +0,2 @@ | ||
/*! firebase-admin v4.1.4 | ||
/*! firebase-admin v4.2.0 | ||
https://firebase.google.com/terms/ */ | ||
@@ -3,0 +3,0 @@ "use strict"; |
@@ -1,2 +0,2 @@ | ||
/*! firebase-admin v4.1.4 | ||
/*! firebase-admin v4.2.0 | ||
https://firebase.google.com/terms/ */ | ||
@@ -3,0 +3,0 @@ "use strict"; |
@@ -1,2 +0,2 @@ | ||
/*! firebase-admin v4.1.4 | ||
/*! firebase-admin v4.2.0 | ||
https://firebase.google.com/terms/ */ | ||
@@ -204,3 +204,3 @@ "use strict"; | ||
this.credential = firebaseCredential; | ||
this.SDK_VERSION = '4.1.4'; | ||
this.SDK_VERSION = '4.2.0'; | ||
/* tslint:disable */ | ||
@@ -207,0 +207,0 @@ // TODO(jwenger): Database is the only consumer of firebase.Promise. We should update it to use |
@@ -1,4 +0,4 @@ | ||
/*! firebase-admin v4.1.4 | ||
/*! firebase-admin v4.2.0 | ||
https://firebase.google.com/terms/ */ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -1,2 +0,2 @@ | ||
/*! firebase-admin v4.1.4 | ||
/*! firebase-admin v4.2.0 | ||
https://firebase.google.com/terms/ */ | ||
@@ -12,2 +12,7 @@ declare namespace admin { | ||
type FirebaseArrayIndexError = { | ||
index: number; | ||
error: FirebaseError; | ||
} | ||
interface ServiceAccount { | ||
@@ -302,2 +307,8 @@ projectId?: string; | ||
type MessagingTopicManagementResponse = { | ||
failureCount: number; | ||
successCount: number; | ||
errors: admin.FirebaseArrayIndexError[]; | ||
}; | ||
interface Messaging { | ||
@@ -331,2 +342,18 @@ app: admin.app.App; | ||
): Promise<admin.messaging.MessagingConditionResponse>; | ||
subscribeToTopic( | ||
registrationToken: string, | ||
topic: string | ||
): Promise<admin.messaging.MessagingTopicManagementResponse>; | ||
subscribeToTopic( | ||
registrationTokens: string[], | ||
topic: string | ||
): Promise<admin.messaging.MessagingTopicManagementResponse>; | ||
unsubscribeFromTopic( | ||
registrationToken: string, | ||
topic: string | ||
): Promise<admin.messaging.MessagingTopicManagementResponse>; | ||
unsubscribeFromTopic( | ||
registrationTokens: string[], | ||
topic: string | ||
): Promise<admin.messaging.MessagingTopicManagementResponse>; | ||
} | ||
@@ -333,0 +360,0 @@ } |
@@ -1,2 +0,2 @@ | ||
/*! firebase-admin v4.1.4 | ||
/*! firebase-admin v4.2.0 | ||
https://firebase.google.com/terms/ */ | ||
@@ -3,0 +3,0 @@ "use strict"; |
@@ -1,2 +0,2 @@ | ||
/*! firebase-admin v4.1.4 | ||
/*! firebase-admin v4.2.0 | ||
https://firebase.google.com/terms/ */ | ||
@@ -10,5 +10,3 @@ "use strict"; | ||
// FCM backend constants | ||
var FIREBASE_MESSAGING_HOST = 'fcm.googleapis.com'; | ||
var FIREBASE_MESSAGING_PORT = 443; | ||
var FIREBASE_MESSAGING_PATH = '/fcm/send'; | ||
var FIREBASE_MESSAGING_TIMEOUT = 10000; | ||
@@ -18,3 +16,3 @@ var FIREBASE_MESSAGING_HTTP_METHOD = 'POST'; | ||
'Content-Type': 'application/json', | ||
'Sdk-Version': 'Node/Admin/4.1.4', | ||
'Sdk-Version': 'Node/Admin/4.2.0', | ||
access_token_auth: 'true', | ||
@@ -51,7 +49,9 @@ }; | ||
* | ||
* @param {string} host The host to which to send the request. | ||
* @param {string} path The path to which to send the request. | ||
* @param {Object} requestData The request data. | ||
* @return {Promise<Object>} A promise that resolves with the response. | ||
*/ | ||
FirebaseMessagingRequestHandler.prototype.invokeRequestHandler = function (requestData) { | ||
return this.signedApiRequestHandler.sendRequest(FIREBASE_MESSAGING_HOST, FIREBASE_MESSAGING_PORT, FIREBASE_MESSAGING_PATH, FIREBASE_MESSAGING_HTTP_METHOD, requestData, FIREBASE_MESSAGING_HEADERS, FIREBASE_MESSAGING_TIMEOUT).then(function (response) { | ||
FirebaseMessagingRequestHandler.prototype.invokeRequestHandler = function (host, path, requestData) { | ||
return this.signedApiRequestHandler.sendRequest(host, FIREBASE_MESSAGING_PORT, path, FIREBASE_MESSAGING_HTTP_METHOD, requestData, FIREBASE_MESSAGING_HEADERS, FIREBASE_MESSAGING_TIMEOUT).then(function (response) { | ||
// Send non-JSON responses to the catch() below where they will be treated as errors. | ||
@@ -58,0 +58,0 @@ if (typeof response === 'string') { |
@@ -1,2 +0,2 @@ | ||
/*! firebase-admin v4.1.4 | ||
/*! firebase-admin v4.2.0 | ||
https://firebase.google.com/terms/ */ | ||
@@ -10,2 +10,8 @@ "use strict"; | ||
var validator = require("../utils/validator"); | ||
// FCM endpoints | ||
var FCM_SEND_HOST = 'fcm.googleapis.com'; | ||
var FCM_SEND_PATH = '/fcm/send'; | ||
var FCM_TOPIC_MANAGEMENT_HOST = 'iid.googleapis.com'; | ||
var FCM_TOPIC_MANAGEMENT_ADD_PATH = '/iid/v1:batchAdd'; | ||
var FCM_TOPIC_MANAGEMENT_REMOVE_PATH = '/iid/v1:batchRemove'; | ||
// Key renames for the messaging notification payload object. | ||
@@ -98,2 +104,34 @@ var CAMELCASED_NOTIFICATION_PAYLOAD_KEYS_MAP = { | ||
/** | ||
* Maps a raw FCM server response to a MessagingTopicManagementResponse object. | ||
* | ||
* @param {Object} response The raw FCM server response to map. | ||
* | ||
* @return {MessagingTopicManagementResponse} The mapped MessagingTopicManagementResponse object. | ||
*/ | ||
function mapRawResponseToTopicManagementResponse(response) { | ||
// Add the success and failure counts. | ||
response.successCount = 0; | ||
response.failureCount = 0; | ||
var errors = []; | ||
if ('results' in response) { | ||
response.results.forEach(function (tokenManagementResult, index) { | ||
// Map the FCM server's error strings to actual error objects. | ||
if ('error' in tokenManagementResult) { | ||
response.failureCount += 1; | ||
var newError = error_1.FirebaseMessagingError.fromServerError(tokenManagementResult.error, /* message */ undefined, tokenManagementResult.error); | ||
errors.push({ | ||
index: index, | ||
error: newError, | ||
}); | ||
} | ||
else { | ||
response.successCount += 1; | ||
} | ||
}); | ||
} | ||
delete response.results; | ||
response.errors = errors; | ||
return response; | ||
} | ||
/** | ||
* Internals of a Messaging instance. | ||
@@ -159,30 +197,11 @@ */ | ||
if (options === void 0) { options = {}; } | ||
if (registrationTokenOrTokens instanceof Array && registrationTokenOrTokens.length !== 0) { | ||
// Validate the array contains no more than 1,000 registration tokens. | ||
if (registrationTokenOrTokens.length > 1000) { | ||
return Promise.reject(new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_RECIPIENT, 'Too many registration tokens provided in a single request. Batch your requests to ' + | ||
'contain no more than 1,000 registration tokens per request.')); | ||
} | ||
// Validate the array contains registration tokens which are non-empty strings. | ||
try { | ||
registrationTokenOrTokens.forEach(function (registrationToken, index) { | ||
if (!validator.isNonEmptyString(registrationToken)) { | ||
throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_RECIPIENT, "Registration token provided to sendToDevice() at index " + index + " must be a non-empty string."); | ||
} | ||
}); | ||
} | ||
catch (error) { | ||
return Promise.reject(error); | ||
} | ||
} | ||
else if (!validator.isNonEmptyString(registrationTokenOrTokens)) { | ||
throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_RECIPIENT, 'Registration token provided to sendToDevice() must be a non-empty string or a non-empty array.'); | ||
} | ||
// Validate the types of the payload and options arguments. Since these are common developer | ||
// errors, throw an error instead of returning a rejected promise. | ||
// Validate the input argument types. Since these are common developer errors when getting | ||
// started, throw an error instead of returning a rejected promise. | ||
this.validateRegistrationTokensType(registrationTokenOrTokens, 'sendToDevice', error_1.MessagingClientErrorCode.INVALID_RECIPIENT); | ||
this.validateMessagingPayloadAndOptionsTypes(payload, options); | ||
return Promise.resolve() | ||
.then(function () { | ||
// Validate the contents of the payload and options objects. Because we are now in a | ||
// promise, any thrown error will cause this method to return a rejected promise. | ||
// Validate the contents of the input arguments. Because we are now in a promise, any thrown | ||
// error will cause this method to return a rejected promise. | ||
_this.validateRegistrationTokens(registrationTokenOrTokens, 'sendToDevice', error_1.MessagingClientErrorCode.INVALID_RECIPIENT); | ||
var payloadCopy = _this.validateMessagingPayload(payload); | ||
@@ -198,3 +217,3 @@ var optionsCopy = _this.validateMessagingOptions(options); | ||
} | ||
return _this.messagingRequestHandler.invokeRequestHandler(request); | ||
return _this.messagingRequestHandler.invokeRequestHandler(FCM_SEND_HOST, FCM_SEND_PATH, request); | ||
}) | ||
@@ -253,3 +272,3 @@ .then(function (response) { | ||
request.to = notificationKey; | ||
return _this.messagingRequestHandler.invokeRequestHandler(request); | ||
return _this.messagingRequestHandler.invokeRequestHandler(FCM_SEND_HOST, FCM_SEND_PATH, request); | ||
}) | ||
@@ -289,15 +308,8 @@ .then(function (response) { | ||
if (options === void 0) { options = {}; } | ||
if (!validator.isNonEmptyString(topic)) { | ||
throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_RECIPIENT, 'Topic provided to sendToTopic() must be a string which matches the format "/topics/[a-zA-Z0-9-_.~%]+".'); | ||
} | ||
else if (!validator.isTopic(topic)) { | ||
return Promise.reject(new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_RECIPIENT, 'Topic provided to sendToTopic() must be a string which matches the format "/topics/[a-zA-Z0-9-_.~%]+".')); | ||
} | ||
// Prepend the topic with /topics/ if necessary | ||
if (!/^\/topics\//.test(topic)) { | ||
topic = "/topics/" + topic; | ||
} | ||
// Validate the types of the payload and options arguments. Since these are common developer | ||
// errors, throw an error instead of returning a rejected promise. | ||
// Validate the input argument types. Since these are common developer errors when getting | ||
// started, throw an error instead of returning a rejected promise. | ||
this.validateTopicType(topic, 'sendToTopic', error_1.MessagingClientErrorCode.INVALID_RECIPIENT); | ||
this.validateMessagingPayloadAndOptionsTypes(payload, options); | ||
// Prepend the topic with /topics/ if necessary. | ||
topic = this.normalizeTopic(topic); | ||
return Promise.resolve() | ||
@@ -309,6 +321,7 @@ .then(function () { | ||
var optionsCopy = _this.validateMessagingOptions(options); | ||
_this.validateTopic(topic, 'sendToTopic', error_1.MessagingClientErrorCode.INVALID_RECIPIENT); | ||
var request = deep_copy_1.deepCopy(payloadCopy); | ||
deep_copy_1.deepExtend(request, optionsCopy); | ||
request.to = topic; | ||
return _this.messagingRequestHandler.invokeRequestHandler(request); | ||
return _this.messagingRequestHandler.invokeRequestHandler(FCM_SEND_HOST, FCM_SEND_PATH, request); | ||
}) | ||
@@ -354,3 +367,3 @@ .then(function (response) { | ||
request.condition = condition; | ||
return _this.messagingRequestHandler.invokeRequestHandler(request); | ||
return _this.messagingRequestHandler.invokeRequestHandler(FCM_SEND_HOST, FCM_SEND_PATH, request); | ||
}) | ||
@@ -364,2 +377,67 @@ .then(function (response) { | ||
/** | ||
* Subscribes a single device or an array of devices to a topic. | ||
* | ||
* @param {string|string[]} registrationTokenOrTokens The registration token or an array of | ||
* registration tokens to subscribe to the topic. | ||
* @param {string} topic The topic to which to subscribe. | ||
* | ||
* @return {Promise<MessagingTopicManagementResponse>} A Promise fulfilled with the parsed FCM | ||
* server response. | ||
*/ | ||
Messaging.prototype.subscribeToTopic = function (registrationTokenOrTokens, topic) { | ||
return this.sendTopicManagementRequest(registrationTokenOrTokens, topic, 'subscribeToTopic', FCM_TOPIC_MANAGEMENT_ADD_PATH); | ||
}; | ||
/** | ||
* Unsubscribes a single device or an array of devices from a topic. | ||
* | ||
* @param {string|string[]} registrationTokenOrTokens The registration token or an array of | ||
* registration tokens to unsubscribe from the topic. | ||
* @param {string} topic The topic to which to subscribe. | ||
* | ||
* @return {Promise<MessagingTopicManagementResponse>} A Promise fulfilled with the parsed FCM | ||
* server response. | ||
*/ | ||
Messaging.prototype.unsubscribeFromTopic = function (registrationTokenOrTokens, topic) { | ||
return this.sendTopicManagementRequest(registrationTokenOrTokens, topic, 'unsubscribeFromTopic', FCM_TOPIC_MANAGEMENT_REMOVE_PATH); | ||
}; | ||
/** | ||
* Helper method which sends and handles topic subscription management requests. | ||
* | ||
* @param {string|string[]} registrationTokenOrTokens The registration token or an array of | ||
* registration tokens to unsubscribe from the topic. | ||
* @param {string} topic The topic to which to subscribe. | ||
* @param {string} methodName The name of the original method called. | ||
* @param {string} path The endpoint path to use for the request. | ||
* | ||
* @return {Promise<MessagingTopicManagementResponse>} A Promise fulfilled with the parsed server | ||
* response. | ||
*/ | ||
Messaging.prototype.sendTopicManagementRequest = function (registrationTokenOrTokens, topic, methodName, path) { | ||
var _this = this; | ||
this.validateRegistrationTokensType(registrationTokenOrTokens, methodName); | ||
this.validateTopicType(topic, methodName); | ||
// Prepend the topic with /topics/ if necessary. | ||
topic = this.normalizeTopic(topic); | ||
return Promise.resolve() | ||
.then(function () { | ||
// Validate the contents of the input arguments. Because we are now in a promise, any thrown | ||
// error will cause this method to return a rejected promise. | ||
_this.validateRegistrationTokens(registrationTokenOrTokens, methodName); | ||
_this.validateTopic(topic, methodName); | ||
// Ensure the registration token(s) input argument is an array. | ||
var registrationTokensArray = registrationTokenOrTokens; | ||
if (validator.isString(registrationTokenOrTokens)) { | ||
registrationTokensArray = [registrationTokenOrTokens]; | ||
} | ||
var request = { | ||
to: topic, | ||
registration_tokens: registrationTokensArray, | ||
}; | ||
return _this.messagingRequestHandler.invokeRequestHandler(FCM_TOPIC_MANAGEMENT_HOST, path, request); | ||
}) | ||
.then(function (response) { | ||
return mapRawResponseToTopicManagementResponse(response); | ||
}); | ||
}; | ||
/** | ||
* Validates the types of the messaging payload and options. If invalid, an error will be thrown. | ||
@@ -496,2 +574,83 @@ * | ||
}; | ||
/** | ||
* Validates the type of the provided registration token(s). If invalid, an error will be thrown. | ||
* | ||
* @param {string|string[]} registrationTokenOrTokens The registration token(s) to validate. | ||
* @param {string} method The method name to use in error messages. | ||
* @param {ErrorInfo?} [errorInfo] The error info to use if the registration tokens are invalid. | ||
*/ | ||
Messaging.prototype.validateRegistrationTokensType = function (registrationTokenOrTokens, methodName, errorInfo) { | ||
if (errorInfo === void 0) { errorInfo = error_1.MessagingClientErrorCode.INVALID_ARGUMENT; } | ||
if (!validator.isNonEmptyArray(registrationTokenOrTokens) && | ||
!validator.isNonEmptyString(registrationTokenOrTokens)) { | ||
throw new error_1.FirebaseMessagingError(errorInfo, "Registration token(s) provided to " + methodName + "() must be a non-empty string or a " + | ||
'non-empty array.'); | ||
} | ||
}; | ||
/** | ||
* Validates the provided registration tokens. If invalid, an error will be thrown. | ||
* | ||
* @param {string|string[]} registrationTokenOrTokens The registration token or an array of | ||
* registration tokens to validate. | ||
* @param {string} method The method name to use in error messages. | ||
* @param {errorInfo?} [ErrorInfo] The error info to use if the registration tokens are invalid. | ||
*/ | ||
Messaging.prototype.validateRegistrationTokens = function (registrationTokenOrTokens, methodName, errorInfo) { | ||
if (errorInfo === void 0) { errorInfo = error_1.MessagingClientErrorCode.INVALID_ARGUMENT; } | ||
if (validator.isArray(registrationTokenOrTokens)) { | ||
// Validate the array contains no more than 1,000 registration tokens. | ||
if (registrationTokenOrTokens.length > 1000) { | ||
throw new error_1.FirebaseMessagingError(errorInfo, "Too many registration tokens provided in a single request to " + methodName + "(). Batch " + | ||
'your requests to contain no more than 1,000 registration tokens per request.'); | ||
} | ||
// Validate the array contains registration tokens which are non-empty strings. | ||
registrationTokenOrTokens.forEach(function (registrationToken, index) { | ||
if (!validator.isNonEmptyString(registrationToken)) { | ||
throw new error_1.FirebaseMessagingError(errorInfo, "Registration token provided to " + methodName + "() at index " + index + " must be a " + | ||
'non-empty string.'); | ||
} | ||
}); | ||
} | ||
}; | ||
/** | ||
* Validates the type of the provided topic. If invalid, an error will be thrown. | ||
* | ||
* @param {string} topic The topic to validate. | ||
* @param {string} method The method name to use in error messages. | ||
* @param {ErrorInfo?} [errorInfo] The error info to use if the topic is invalid. | ||
*/ | ||
Messaging.prototype.validateTopicType = function (topic, methodName, errorInfo) { | ||
if (errorInfo === void 0) { errorInfo = error_1.MessagingClientErrorCode.INVALID_ARGUMENT; } | ||
if (!validator.isNonEmptyString(topic)) { | ||
throw new error_1.FirebaseMessagingError(errorInfo, "Topic provided to " + methodName + "() must be a string which matches the format " + | ||
'"/topics/[a-zA-Z0-9-_.~%]+".'); | ||
} | ||
}; | ||
/** | ||
* Validates the provided topic. If invalid, an error will be thrown. | ||
* | ||
* @param {string} topic The topic to validate. | ||
* @param {string} method The method name to use in error messages. | ||
* @param {ErrorInfo?} [errorInfo] The error info to use if the topic is invalid. | ||
*/ | ||
Messaging.prototype.validateTopic = function (topic, methodName, errorInfo) { | ||
if (errorInfo === void 0) { errorInfo = error_1.MessagingClientErrorCode.INVALID_ARGUMENT; } | ||
if (!validator.isTopic(topic)) { | ||
throw new error_1.FirebaseMessagingError(errorInfo, "Topic provided to " + methodName + "() must be a string which matches the format " + | ||
'"/topics/[a-zA-Z0-9-_.~%]+".'); | ||
} | ||
}; | ||
/** | ||
* Normalizes the provided topic name by prepending it with '/topics/', if necessary. | ||
* | ||
* @param {string} topic The topic name to normalize. | ||
* | ||
* @return {string} The normalized topic name. | ||
*/ | ||
Messaging.prototype.normalizeTopic = function (topic) { | ||
if (!/^\/topics\//.test(topic)) { | ||
topic = "/topics/" + topic; | ||
} | ||
return topic; | ||
}; | ||
return Messaging; | ||
@@ -498,0 +657,0 @@ }()); |
@@ -1,2 +0,2 @@ | ||
/*! firebase-admin v4.1.4 | ||
/*! firebase-admin v4.2.0 | ||
https://firebase.google.com/terms/ */ | ||
@@ -3,0 +3,0 @@ "use strict"; |
@@ -1,2 +0,2 @@ | ||
/*! firebase-admin v4.1.4 | ||
/*! firebase-admin v4.2.0 | ||
https://firebase.google.com/terms/ */ | ||
@@ -3,0 +3,0 @@ "use strict"; |
@@ -1,2 +0,2 @@ | ||
/*! firebase-admin v4.1.4 | ||
/*! firebase-admin v4.2.0 | ||
https://firebase.google.com/terms/ */ | ||
@@ -3,0 +3,0 @@ "use strict"; |
@@ -1,2 +0,2 @@ | ||
/*! firebase-admin v4.1.4 | ||
/*! firebase-admin v4.2.0 | ||
https://firebase.google.com/terms/ */ | ||
@@ -334,2 +334,7 @@ "use strict"; | ||
}; | ||
MessagingClientErrorCode.TOO_MANY_TOPICS = { | ||
code: 'too-many-topics', | ||
message: 'The maximum number of topics the provided registration token can be subscribed to ' + | ||
'has been exceeded.', | ||
}; | ||
MessagingClientErrorCode.AUTHENTICATION_ERROR = { | ||
@@ -348,3 +353,3 @@ code: 'authentication-error', | ||
code: 'internal-error', | ||
message: 'An internal error has occurred.', | ||
message: 'An internal error has occurred. Please retry the request.', | ||
}; | ||
@@ -388,4 +393,12 @@ MessagingClientErrorCode.UNKNOWN_ERROR = { | ||
var MESSAGING_SERVER_TO_CLIENT_CODE = { | ||
/* GENERIC ERRORS */ | ||
// Generic invalid message parameter provided. | ||
InvalidParameters: 'INVALID_ARGUMENT', | ||
// Mismatched sender ID. | ||
MismatchSenderId: 'MISMATCHED_CREDENTIAL', | ||
// FCM server unavailable. | ||
Unavailable: 'SERVER_UNAVAILABLE', | ||
// FCM server internal error. | ||
InternalServerError: 'INTERNAL_ERROR', | ||
/* SEND ERRORS */ | ||
// Invalid registration token format. | ||
@@ -395,4 +408,2 @@ InvalidRegistration: 'INVALID_REGISTRATION_TOKEN', | ||
NotRegistered: 'REGISTRATION_TOKEN_NOT_REGISTERED', | ||
// Mismatched sender ID. | ||
MismatchSenderId: 'MISMATCHED_CREDENTIAL', | ||
// Registration token does not match restricted package name. | ||
@@ -412,6 +423,11 @@ InvalidPackageName: 'INVALID_PACKAGE_NAME', | ||
InvalidApnsCredential: 'INVALID_APNS_CREDENTIALS', | ||
// FCM server unavailable. | ||
Unavailable: 'SERVER_UNAVAILABLE', | ||
// FCM server internal error. | ||
InternalServerError: 'INTERNAL_ERROR', | ||
/* TOPIC SUBSCRIPTION MANAGEMENT ERRORS */ | ||
NOT_FOUND: 'REGISTRATION_TOKEN_NOT_REGISTERED', | ||
INVALID_ARGUMENT: 'INVALID_REGISTRATION_TOKEN', | ||
TOO_MANY_TOPICS: 'TOO_MANY_TOPICS', | ||
RESOURCE_EXHAUSTED: 'TOO_MANY_TOPICS', | ||
PERMISSION_DENIED: 'AUTHENTICATION_ERROR', | ||
DEADLINE_EXCEEDED: 'SERVER_UNAVAILABLE', | ||
INTERNAL: 'INTERNAL_ERROR', | ||
UNKNOWN: 'UNKNOWN_ERROR', | ||
}; |
@@ -1,2 +0,2 @@ | ||
/*! firebase-admin v4.1.4 | ||
/*! firebase-admin v4.2.0 | ||
https://firebase.google.com/terms/ */ | ||
@@ -3,0 +3,0 @@ "use strict"; |
@@ -1,2 +0,2 @@ | ||
/*! firebase-admin v4.1.4 | ||
/*! firebase-admin v4.2.0 | ||
https://firebase.google.com/terms/ */ | ||
@@ -7,2 +7,22 @@ "use strict"; | ||
/** | ||
* Validates that a value is an array. | ||
* | ||
* @param {any} value The value to validate. | ||
* @return {boolean} Whether the value is an array or not. | ||
*/ | ||
function isArray(value) { | ||
return value instanceof Array; | ||
} | ||
exports.isArray = isArray; | ||
/** | ||
* Validates that a value is a non-empty array. | ||
* | ||
* @param {any} value The value to validate. | ||
* @return {boolean} Whether the value is a non-empty array or not. | ||
*/ | ||
function isNonEmptyArray(value) { | ||
return isArray(value) && value.length !== 0; | ||
} | ||
exports.isNonEmptyArray = isNonEmptyArray; | ||
/** | ||
* Validates that a value is a boolean. | ||
@@ -44,3 +64,3 @@ * | ||
function isNonEmptyString(value) { | ||
return typeof value === 'string' && value !== ''; | ||
return isString(value) && value !== ''; | ||
} | ||
@@ -47,0 +67,0 @@ exports.isNonEmptyString = isNonEmptyString; |
{ | ||
"name": "firebase-admin", | ||
"version": "4.1.4", | ||
"version": "4.2.0", | ||
"dependencies": { | ||
@@ -5,0 +5,0 @@ "@types/jsonwebtoken": { |
{ | ||
"name": "firebase-admin", | ||
"version": "4.1.4", | ||
"version": "4.2.0", | ||
"description": "Firebase admin SDK for Node.js", | ||
@@ -5,0 +5,0 @@ "author": "Firebase (https://firebase.google.com/)", |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
298574
4528