1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 | 1 1 1 4 4 4 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | /*! firebase-admin v4.2.1 https://firebase.google.com/terms/ */ "use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); var deep_copy_1 = require("../utils/deep-copy"); /** * Firebase error code structure. This extends Error. * * @param {ErrorInfo} errorInfo The error information (code and message). * @constructor */ var FirebaseError = (function (_super) { __extends(FirebaseError, _super); function FirebaseError(errorInfo) { var _this = _super.call(this, errorInfo.message) || this; _this.errorInfo = errorInfo; /* tslint:disable:max-line-length */ // Set the prototype explicitly. See the following link for more details: // https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes#extending-built-ins-like-error-array-and-map-may-no-longer-work /* tslint:enable:max-line-length */ _this.__proto__ = FirebaseError.prototype; return _this; } Object.defineProperty(FirebaseError.prototype, "code", { /** @return {string} The error code. */ get: function () { return this.errorInfo.code; }, enumerable: true, configurable: true }); Object.defineProperty(FirebaseError.prototype, "message", { /** @return {string} The error message. */ get: function () { return this.errorInfo.message; }, enumerable: true, configurable: true }); /** @return {Object} The object representation of the error. */ FirebaseError.prototype.toJSON = function () { return { code: this.code, message: this.message, }; }; return FirebaseError; }(Error)); exports.FirebaseError = FirebaseError; /** * Firebase App error code structure. This extends FirebaseError. * * @param {string} code The error code. * @param {string} message The error message. * @constructor */ var FirebaseAppError = (function (_super) { __extends(FirebaseAppError, _super); function FirebaseAppError(code, message) { return _super.call(this, { code: 'app/' + code, message: message, }) || this; } return FirebaseAppError; }(FirebaseError)); exports.FirebaseAppError = FirebaseAppError; /** * Firebase Auth error code structure. This extends FirebaseError. * * @param {ErrorInfo} info The error code info. * @param {string} [message] The error message. This will override the default * message if provided. * @constructor */ var FirebaseAuthError = (function (_super) { __extends(FirebaseAuthError, _super); function FirebaseAuthError(info, message) { // Override default message if custom message provided. return _super.call(this, { code: 'auth/' + info.code, message: message || info.message }) || this; } /** * Creates the developer-facing error corresponding to the backend error code. * * @param {string} serverErrorCode The server error code. * @param {string} [message] The error message. The default message is used * if not provided. * @param {Object} [rawServerResponse] The error's raw server response. * @return {FirebaseAuthError} The corresponding developer-facing error. */ FirebaseAuthError.fromServerError = function (serverErrorCode, message, rawServerResponse) { // If not found, default to internal error. var clientCodeKey = AUTH_SERVER_TO_CLIENT_CODE[serverErrorCode] || 'INTERNAL_ERROR'; var error = deep_copy_1.deepCopy(AuthClientErrorCode[clientCodeKey]); error.message = message || error.message; if (clientCodeKey === 'INTERNAL_ERROR' && typeof rawServerResponse !== 'undefined') { try { error.message += " Raw server response: \"" + JSON.stringify(rawServerResponse) + "\""; } catch (e) { // Ignore JSON parsing error. } } return new FirebaseAuthError(error); }; return FirebaseAuthError; }(FirebaseError)); exports.FirebaseAuthError = FirebaseAuthError; /** * Firebase Messaging error code structure. This extends FirebaseError. * * @param {ErrorInfo} info The error code info. * @param {string} [message] The error message. This will override the default message if provided. * @constructor */ var FirebaseMessagingError = (function (_super) { __extends(FirebaseMessagingError, _super); function FirebaseMessagingError(info, message) { // Override default message if custom message provided. return _super.call(this, { code: 'messaging/' + info.code, message: message || info.message }) || this; } /** * Creates the developer-facing error corresponding to the backend error code. * * @param {string} serverErrorCode The server error code. * @param {string} [message] The error message. The default message is used * if not provided. * @param {Object} [rawServerResponse] The error's raw server response. * @return {FirebaseMessagingError} The corresponding developer-facing error. */ FirebaseMessagingError.fromServerError = function (serverErrorCode, message, rawServerResponse) { // If not found, default to unknown error. var clientCodeKey = MESSAGING_SERVER_TO_CLIENT_CODE[serverErrorCode] || 'UNKNOWN_ERROR'; var error = deep_copy_1.deepCopy(MessagingClientErrorCode[clientCodeKey]); error.message = message || error.message; if (clientCodeKey === 'UNKNOWN_ERROR' && typeof rawServerResponse !== 'undefined') { try { error.message += " Raw server response: \"" + JSON.stringify(rawServerResponse) + "\""; } catch (e) { // Ignore JSON parsing error. } } return new FirebaseMessagingError(error); }; return FirebaseMessagingError; }(FirebaseError)); exports.FirebaseMessagingError = FirebaseMessagingError; /** * App client error codes and their default messages. */ var AppErrorCodes = (function () { function AppErrorCodes() { } return AppErrorCodes; }()); AppErrorCodes.APP_DELETED = 'app-deleted'; AppErrorCodes.DUPLICATE_APP = 'duplicate-app'; AppErrorCodes.INTERNAL_ERROR = 'internal-error'; AppErrorCodes.INVALID_APP_NAME = 'invalid-app-name'; AppErrorCodes.INVALID_APP_OPTIONS = 'invalid-app-options'; AppErrorCodes.INVALID_CREDENTIAL = 'invalid-credential'; AppErrorCodes.NETWORK_ERROR = 'network-error'; AppErrorCodes.NETWORK_TIMEOUT = 'network-timeout'; AppErrorCodes.NO_APP = 'no-app'; AppErrorCodes.UNABLE_TO_PARSE_RESPONSE = 'unable-to-parse-response'; exports.AppErrorCodes = AppErrorCodes; ; /** * Auth client error codes and their default messages. */ var AuthClientErrorCode = (function () { function AuthClientErrorCode() { } return AuthClientErrorCode; }()); AuthClientErrorCode.INVALID_ARGUMENT = { code: 'argument-error', message: 'Invalid argument provided.', }; AuthClientErrorCode.EMAIL_ALREADY_EXISTS = { code: 'email-already-exists', message: 'The email address is already in use by another account.', }; AuthClientErrorCode.INTERNAL_ERROR = { code: 'internal-error', message: 'An internal error has occurred.', }; AuthClientErrorCode.INVALID_CREDENTIAL = { code: 'invalid-credential', message: 'Invalid credential object provided.', }; AuthClientErrorCode.INVALID_DISABLED_FIELD = { code: 'invalid-disabled-field', message: 'The disabled field must be a boolean.', }; AuthClientErrorCode.INVALID_DISPLAY_NAME = { code: 'invalid-display-name', message: 'The displayName field must be a valid string.', }; AuthClientErrorCode.INVALID_EMAIL_VERIFIED = { code: 'invalid-email-verified', message: 'The emailVerified field must be a boolean.', }; AuthClientErrorCode.INVALID_EMAIL = { code: 'invalid-email', message: 'The email address is improperly formatted.', }; AuthClientErrorCode.INVALID_PASSWORD = { code: 'invalid-password', message: 'The password must be a string with at least 6 characters.', }; AuthClientErrorCode.INVALID_PHOTO_URL = { code: 'invalid-photo-url', message: 'The photoURL field must be a valid URL.', }; AuthClientErrorCode.INVALID_UID = { code: 'invalid-uid', message: 'The uid must be a non-empty string with at most 128 characters.', }; AuthClientErrorCode.MISSING_UID = { code: 'missing-uid', message: 'A uid identifier is required for the current operation.', }; AuthClientErrorCode.OPERATION_NOT_ALLOWED = { code: 'operation-not-allowed', message: 'The given sign-in provider is disabled for this Firebase project. ' + 'Enable it in the Firebase console, under the sign-in method tab of the ' + 'Auth section.', }; AuthClientErrorCode.PROJECT_NOT_FOUND = { code: 'project-not-found', message: 'No Firebase project was found for the provided credential.', }; AuthClientErrorCode.INSUFFICIENT_PERMISSION = { code: 'insufficient-permission', message: 'Credential implementation provided to initializeApp() via the "credential" property ' + 'has insufficient permission to access the requested resource. See ' + 'https://firebase.google.com/docs/admin/setup for details on how to authenticate this SDK ' + 'with appropriate permissions.', }; AuthClientErrorCode.UID_ALREADY_EXISTS = { code: 'uid-already-exists', message: 'The user with the provided uid already exists.', }; AuthClientErrorCode.USER_NOT_FOUND = { code: 'user-not-found', message: 'There is no user record corresponding to the provided identifier.', }; exports.AuthClientErrorCode = AuthClientErrorCode; ; /** * Messaging client error codes and their default messages. */ var MessagingClientErrorCode = (function () { function MessagingClientErrorCode() { } return MessagingClientErrorCode; }()); MessagingClientErrorCode.INVALID_ARGUMENT = { code: 'invalid-argument', message: 'Invalid argument provided.', }; MessagingClientErrorCode.INVALID_RECIPIENT = { code: 'invalid-recipient', message: 'Invalid message recipient provided.', }; MessagingClientErrorCode.INVALID_PAYLOAD = { code: 'invalid-payload', message: 'Invalid message payload provided.', }; MessagingClientErrorCode.INVALID_DATA_PAYLOAD_KEY = { code: 'invalid-data-payload-key', message: 'The data message payload contains an invalid key. See the reference documentation ' + 'for the DataMessagePayload type for restricted keys.', }; MessagingClientErrorCode.PAYLOAD_SIZE_LIMIT_EXCEEDED = { code: 'payload-size-limit-exceeded', message: 'The provided message payload exceeds the FCM size limits. See the error documentation ' + 'for more details.', }; MessagingClientErrorCode.INVALID_OPTIONS = { code: 'invalid-options', message: 'Invalid message options provided.', }; MessagingClientErrorCode.INVALID_REGISTRATION_TOKEN = { code: 'invalid-registration-token', message: 'Invalid registration token provided. Make sure it matches the registration token ' + 'the client app receives from registering with FCM.', }; MessagingClientErrorCode.REGISTRATION_TOKEN_NOT_REGISTERED = { code: 'registration-token-not-registered', message: 'The provided registration token is not registered. A previously valid registration ' + 'token can be unregistered for a variety of reasons. See the error documentation for more ' + 'details. Remove this registration token and stop using it to send messages.', }; MessagingClientErrorCode.MISMATCHED_CREDENTIAL = { code: 'mismatched-credential', message: 'The credential used to authenticate this SDK does not have permission to send ' + 'messages to the device corresponding to the provided registration token. Make sure the ' + 'credential and registration token both belong to the same Firebase project.', }; MessagingClientErrorCode.INVALID_PACKAGE_NAME = { code: 'invalid-package-name', message: 'The message was addressed to a registration token whose package name does not match ' + 'the provided "restrictedPackageName" option.', }; MessagingClientErrorCode.DEVICE_MESSAGE_RATE_EXCEEDED = { code: 'device-message-rate-exceeded', message: 'The rate of messages to a particular device is too high. Reduce the number of ' + 'messages sent to this device and do not immediately retry sending to this device.', }; MessagingClientErrorCode.TOPICS_MESSAGE_RATE_EXCEEDED = { code: 'topics-message-rate-exceeded', message: 'The rate of messages to subscribers to a particular topic is too high. Reduce the ' + 'number of messages sent for this topic, and do not immediately retry sending to this topic.', }; MessagingClientErrorCode.INVALID_APNS_CREDENTIALS = { code: 'invalid-apns-credentials', message: 'A message targeted to an iOS device could not be sent because the required APNs ' + 'SSL certificate was not uploaded or has expired. Check the validity of your development ' + 'and production certificates.', }; 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 = { code: 'authentication-error', message: 'An error occurred when trying to authenticate to the FCM servers. Make sure the ' + 'credential used to authenticate this SDK has the proper permissions. See ' + 'https://firebase.google.com/docs/admin/setup for setup instructions.', }; MessagingClientErrorCode.SERVER_UNAVAILABLE = { code: 'server-unavailable', message: 'The FCM server could not process the request in time. See the error documentation ' + 'for more details.', }; MessagingClientErrorCode.INTERNAL_ERROR = { code: 'internal-error', message: 'An internal error has occurred. Please retry the request.', }; MessagingClientErrorCode.UNKNOWN_ERROR = { code: 'unknown-error', message: 'An unknown server error was returned.', }; exports.MessagingClientErrorCode = MessagingClientErrorCode; ; /** @const {ServerToClientCode} Auth server to client enum error codes. */ var AUTH_SERVER_TO_CLIENT_CODE = { // Project not found. CONFIGURATION_NOT_FOUND: 'PROJECT_NOT_FOUND', // Provided credential has insufficient permissions. INSUFFICIENT_PERMISSION: 'INSUFFICIENT_PERMISSION', // uploadAccount provides an email that already exists. DUPLICATE_EMAIL: 'EMAIL_EXISTS', // uploadAccount provides a localId that already exists. DUPLICATE_LOCAL_ID: 'UID_ALREADY_EXISTS', // setAccountInfo email already exists. EMAIL_EXISTS: 'EMAIL_ALREADY_EXISTS', // Invalid email provided. INVALID_EMAIL: 'INVALID_EMAIL', // Invalid service account. INVALID_SERVICE_ACCOUNT: 'INVALID_SERVICE_ACCOUNT', // No localId provided (deleteAccount missing localId). MISSING_LOCAL_ID: 'MISSING_UID', // Empty user list in uploadAccount. MISSING_USER_ACCOUNT: 'MISSING_UID', // Password auth disabled in console. OPERATION_NOT_ALLOWED: 'OPERATION_NOT_ALLOWED', // Project not found. PROJECT_NOT_FOUND: 'PROJECT_NOT_FOUND', // User on which action is to be performed is not found. USER_NOT_FOUND: 'USER_NOT_FOUND', // Password provided is too weak. WEAK_PASSWORD: 'INVALID_PASSWORD', }; /** @const {ServerToClientCode} Messaging server to client enum error codes. */ 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. InvalidRegistration: 'INVALID_REGISTRATION_TOKEN', // Registration token is not registered. NotRegistered: 'REGISTRATION_TOKEN_NOT_REGISTERED', // Registration token does not match restricted package name. InvalidPackageName: 'INVALID_PACKAGE_NAME', // Message payload size limit exceeded. MessageTooBig: 'PAYLOAD_SIZE_LIMIT_EXCEEDED', // Invalid key in the data message payload. InvalidDataKey: 'INVALID_DATA_PAYLOAD_KEY', // Invalid time to live option. InvalidTtl: 'INVALID_OPTIONS', // Device message rate exceeded. DeviceMessageRateExceeded: 'DEVICE_MESSAGE_RATE_EXCEEDED', // Topics message rate exceeded. TopicsMessageRateExceeded: 'TOPICS_MESSAGE_RATE_EXCEEDED', // Invalid APNs credentials. InvalidApnsCredential: 'INVALID_APNS_CREDENTIALS', /* 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', }; |