error.js 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050
  1. /*! firebase-admin v12.1.1 */
  2. "use strict";
  3. /*!
  4. * @license
  5. * Copyright 2017 Google Inc.
  6. *
  7. * Licensed under the Apache License, Version 2.0 (the "License");
  8. * you may not use this file except in compliance with the License.
  9. * You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS,
  15. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. * See the License for the specific language governing permissions and
  17. * limitations under the License.
  18. */
  19. Object.defineProperty(exports, "__esModule", { value: true });
  20. exports.InstanceIdClientErrorCode = exports.InstallationsClientErrorCode = exports.MessagingClientErrorCode = exports.AuthClientErrorCode = exports.AppErrorCodes = exports.FirebaseProjectManagementError = exports.FirebaseMessagingError = exports.FirebaseInstallationsError = exports.FirebaseInstanceIdError = exports.FirebaseFirestoreError = exports.FirebaseDatabaseError = exports.FirebaseAuthError = exports.FirebaseAppError = exports.PrefixedFirebaseError = exports.FirebaseError = void 0;
  21. const deep_copy_1 = require("../utils/deep-copy");
  22. /**
  23. * Firebase error code structure. This extends Error.
  24. */
  25. class FirebaseError extends Error {
  26. /**
  27. * @param errorInfo - The error information (code and message).
  28. * @constructor
  29. * @internal
  30. */
  31. constructor(errorInfo) {
  32. super(errorInfo.message);
  33. this.errorInfo = errorInfo;
  34. /* tslint:disable:max-line-length */
  35. // Set the prototype explicitly. See the following link for more details:
  36. // https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes#extending-built-ins-like-error-array-and-map-may-no-longer-work
  37. /* tslint:enable:max-line-length */
  38. this.__proto__ = FirebaseError.prototype;
  39. }
  40. /** @returns The error code. */
  41. get code() {
  42. return this.errorInfo.code;
  43. }
  44. /** @returns The error message. */
  45. get message() {
  46. return this.errorInfo.message;
  47. }
  48. /** @returns The object representation of the error. */
  49. toJSON() {
  50. return {
  51. code: this.code,
  52. message: this.message,
  53. };
  54. }
  55. }
  56. exports.FirebaseError = FirebaseError;
  57. /**
  58. * A FirebaseError with a prefix in front of the error code.
  59. */
  60. class PrefixedFirebaseError extends FirebaseError {
  61. /**
  62. * @param codePrefix - The prefix to apply to the error code.
  63. * @param code - The error code.
  64. * @param message - The error message.
  65. * @constructor
  66. * @internal
  67. */
  68. constructor(codePrefix, code, message) {
  69. super({
  70. code: `${codePrefix}/${code}`,
  71. message,
  72. });
  73. this.codePrefix = codePrefix;
  74. /* tslint:disable:max-line-length */
  75. // Set the prototype explicitly. See the following link for more details:
  76. // https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes#extending-built-ins-like-error-array-and-map-may-no-longer-work
  77. /* tslint:enable:max-line-length */
  78. this.__proto__ = PrefixedFirebaseError.prototype;
  79. }
  80. /**
  81. * Allows the error type to be checked without needing to know implementation details
  82. * of the code prefixing.
  83. *
  84. * @param code - The non-prefixed error code to test against.
  85. * @returns True if the code matches, false otherwise.
  86. */
  87. hasCode(code) {
  88. return `${this.codePrefix}/${code}` === this.code;
  89. }
  90. }
  91. exports.PrefixedFirebaseError = PrefixedFirebaseError;
  92. /**
  93. * Firebase App error code structure. This extends PrefixedFirebaseError.
  94. */
  95. class FirebaseAppError extends PrefixedFirebaseError {
  96. /**
  97. * @param code - The error code.
  98. * @param message - The error message.
  99. * @constructor
  100. * @internal
  101. */
  102. constructor(code, message) {
  103. super('app', code, message);
  104. /* tslint:disable:max-line-length */
  105. // Set the prototype explicitly. See the following link for more details:
  106. // https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes#extending-built-ins-like-error-array-and-map-may-no-longer-work
  107. /* tslint:enable:max-line-length */
  108. this.__proto__ = FirebaseAppError.prototype;
  109. }
  110. }
  111. exports.FirebaseAppError = FirebaseAppError;
  112. /**
  113. * Firebase Auth error code structure. This extends PrefixedFirebaseError.
  114. */
  115. class FirebaseAuthError extends PrefixedFirebaseError {
  116. /**
  117. * Creates the developer-facing error corresponding to the backend error code.
  118. *
  119. * @param serverErrorCode - The server error code.
  120. * @param [message] The error message. The default message is used
  121. * if not provided.
  122. * @param [rawServerResponse] The error's raw server response.
  123. * @returns The corresponding developer-facing error.
  124. * @internal
  125. */
  126. static fromServerError(serverErrorCode, message, rawServerResponse) {
  127. // serverErrorCode could contain additional details:
  128. // ERROR_CODE : Detailed message which can also contain colons
  129. const colonSeparator = (serverErrorCode || '').indexOf(':');
  130. let customMessage = null;
  131. if (colonSeparator !== -1) {
  132. customMessage = serverErrorCode.substring(colonSeparator + 1).trim();
  133. serverErrorCode = serverErrorCode.substring(0, colonSeparator).trim();
  134. }
  135. // If not found, default to internal error.
  136. const clientCodeKey = AUTH_SERVER_TO_CLIENT_CODE[serverErrorCode] || 'INTERNAL_ERROR';
  137. const error = (0, deep_copy_1.deepCopy)(AuthClientErrorCode[clientCodeKey]);
  138. // Server detailed message should have highest priority.
  139. error.message = customMessage || message || error.message;
  140. if (clientCodeKey === 'INTERNAL_ERROR' && typeof rawServerResponse !== 'undefined') {
  141. try {
  142. error.message += ` Raw server response: "${JSON.stringify(rawServerResponse)}"`;
  143. }
  144. catch (e) {
  145. // Ignore JSON parsing error.
  146. }
  147. }
  148. return new FirebaseAuthError(error);
  149. }
  150. /**
  151. * @param info - The error code info.
  152. * @param message - The error message. This will override the default message if provided.
  153. * @constructor
  154. * @internal
  155. */
  156. constructor(info, message) {
  157. // Override default message if custom message provided.
  158. super('auth', info.code, message || info.message);
  159. /* tslint:disable:max-line-length */
  160. // Set the prototype explicitly. See the following link for more details:
  161. // https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes#extending-built-ins-like-error-array-and-map-may-no-longer-work
  162. /* tslint:enable:max-line-length */
  163. this.__proto__ = FirebaseAuthError.prototype;
  164. }
  165. }
  166. exports.FirebaseAuthError = FirebaseAuthError;
  167. /**
  168. * Firebase Database error code structure. This extends FirebaseError.
  169. */
  170. class FirebaseDatabaseError extends FirebaseError {
  171. /**
  172. * @param info - The error code info.
  173. * @param message - The error message. This will override the default
  174. * message if provided.
  175. * @constructor
  176. * @internal
  177. */
  178. constructor(info, message) {
  179. // Override default message if custom message provided.
  180. super({ code: 'database/' + info.code, message: message || info.message });
  181. }
  182. }
  183. exports.FirebaseDatabaseError = FirebaseDatabaseError;
  184. /**
  185. * Firebase Firestore error code structure. This extends FirebaseError.
  186. */
  187. class FirebaseFirestoreError extends FirebaseError {
  188. /**
  189. * @param info - The error code info.
  190. * @param message - The error message. This will override the default
  191. * message if provided.
  192. * @constructor
  193. * @internal
  194. */
  195. constructor(info, message) {
  196. // Override default message if custom message provided.
  197. super({ code: 'firestore/' + info.code, message: message || info.message });
  198. }
  199. }
  200. exports.FirebaseFirestoreError = FirebaseFirestoreError;
  201. /**
  202. * Firebase instance ID error code structure. This extends FirebaseError.
  203. */
  204. class FirebaseInstanceIdError extends FirebaseError {
  205. /**
  206. *
  207. * @param info - The error code info.
  208. * @param message - The error message. This will override the default
  209. * message if provided.
  210. * @constructor
  211. * @internal
  212. */
  213. constructor(info, message) {
  214. // Override default message if custom message provided.
  215. super({ code: 'instance-id/' + info.code, message: message || info.message });
  216. this.__proto__ = FirebaseInstanceIdError.prototype;
  217. }
  218. }
  219. exports.FirebaseInstanceIdError = FirebaseInstanceIdError;
  220. /**
  221. * Firebase Installations service error code structure. This extends `FirebaseError`.
  222. */
  223. class FirebaseInstallationsError extends FirebaseError {
  224. /**
  225. *
  226. * @param info - The error code info.
  227. * @param message - The error message. This will override the default
  228. * message if provided.
  229. * @constructor
  230. * @internal
  231. */
  232. constructor(info, message) {
  233. // Override default message if custom message provided.
  234. super({ code: 'installations/' + info.code, message: message || info.message });
  235. this.__proto__ = FirebaseInstallationsError.prototype;
  236. }
  237. }
  238. exports.FirebaseInstallationsError = FirebaseInstallationsError;
  239. /**
  240. * Firebase Messaging error code structure. This extends PrefixedFirebaseError.
  241. */
  242. class FirebaseMessagingError extends PrefixedFirebaseError {
  243. /**
  244. * Creates the developer-facing error corresponding to the backend error code.
  245. *
  246. * @param serverErrorCode - The server error code.
  247. * @param [message] The error message. The default message is used
  248. * if not provided.
  249. * @param [rawServerResponse] The error's raw server response.
  250. * @returns The corresponding developer-facing error.
  251. * @internal
  252. */
  253. static fromServerError(serverErrorCode, message, rawServerResponse) {
  254. // If not found, default to unknown error.
  255. let clientCodeKey = 'UNKNOWN_ERROR';
  256. if (serverErrorCode && serverErrorCode in MESSAGING_SERVER_TO_CLIENT_CODE) {
  257. clientCodeKey = MESSAGING_SERVER_TO_CLIENT_CODE[serverErrorCode];
  258. }
  259. const error = (0, deep_copy_1.deepCopy)(MessagingClientErrorCode[clientCodeKey]);
  260. error.message = message || error.message;
  261. if (clientCodeKey === 'UNKNOWN_ERROR' && typeof rawServerResponse !== 'undefined') {
  262. try {
  263. error.message += ` Raw server response: "${JSON.stringify(rawServerResponse)}"`;
  264. }
  265. catch (e) {
  266. // Ignore JSON parsing error.
  267. }
  268. }
  269. return new FirebaseMessagingError(error);
  270. }
  271. /**
  272. * @internal
  273. */
  274. static fromTopicManagementServerError(serverErrorCode, message, rawServerResponse) {
  275. // If not found, default to unknown error.
  276. const clientCodeKey = TOPIC_MGT_SERVER_TO_CLIENT_CODE[serverErrorCode] || 'UNKNOWN_ERROR';
  277. const error = (0, deep_copy_1.deepCopy)(MessagingClientErrorCode[clientCodeKey]);
  278. error.message = message || error.message;
  279. if (clientCodeKey === 'UNKNOWN_ERROR' && typeof rawServerResponse !== 'undefined') {
  280. try {
  281. error.message += ` Raw server response: "${JSON.stringify(rawServerResponse)}"`;
  282. }
  283. catch (e) {
  284. // Ignore JSON parsing error.
  285. }
  286. }
  287. return new FirebaseMessagingError(error);
  288. }
  289. /**
  290. *
  291. * @param info - The error code info.
  292. * @param message - The error message. This will override the default message if provided.
  293. * @constructor
  294. * @internal
  295. */
  296. constructor(info, message) {
  297. // Override default message if custom message provided.
  298. super('messaging', info.code, message || info.message);
  299. /* tslint:disable:max-line-length */
  300. // Set the prototype explicitly. See the following link for more details:
  301. // https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes#extending-built-ins-like-error-array-and-map-may-no-longer-work
  302. /* tslint:enable:max-line-length */
  303. this.__proto__ = FirebaseMessagingError.prototype;
  304. }
  305. }
  306. exports.FirebaseMessagingError = FirebaseMessagingError;
  307. /**
  308. * Firebase project management error code structure. This extends PrefixedFirebaseError.
  309. */
  310. class FirebaseProjectManagementError extends PrefixedFirebaseError {
  311. /**
  312. * @param code - The error code.
  313. * @param message - The error message.
  314. * @constructor
  315. * @internal
  316. */
  317. constructor(code, message) {
  318. super('project-management', code, message);
  319. /* tslint:disable:max-line-length */
  320. // Set the prototype explicitly. See the following link for more details:
  321. // https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes#extending-built-ins-like-error-array-and-map-may-no-longer-work
  322. /* tslint:enable:max-line-length */
  323. this.__proto__ = FirebaseProjectManagementError.prototype;
  324. }
  325. }
  326. exports.FirebaseProjectManagementError = FirebaseProjectManagementError;
  327. /**
  328. * App client error codes and their default messages.
  329. */
  330. class AppErrorCodes {
  331. }
  332. exports.AppErrorCodes = AppErrorCodes;
  333. AppErrorCodes.APP_DELETED = 'app-deleted';
  334. AppErrorCodes.DUPLICATE_APP = 'duplicate-app';
  335. AppErrorCodes.INVALID_ARGUMENT = 'invalid-argument';
  336. AppErrorCodes.INTERNAL_ERROR = 'internal-error';
  337. AppErrorCodes.INVALID_APP_NAME = 'invalid-app-name';
  338. AppErrorCodes.INVALID_APP_OPTIONS = 'invalid-app-options';
  339. AppErrorCodes.INVALID_CREDENTIAL = 'invalid-credential';
  340. AppErrorCodes.NETWORK_ERROR = 'network-error';
  341. AppErrorCodes.NETWORK_TIMEOUT = 'network-timeout';
  342. AppErrorCodes.NO_APP = 'no-app';
  343. AppErrorCodes.UNABLE_TO_PARSE_RESPONSE = 'unable-to-parse-response';
  344. /**
  345. * Auth client error codes and their default messages.
  346. */
  347. class AuthClientErrorCode {
  348. }
  349. exports.AuthClientErrorCode = AuthClientErrorCode;
  350. AuthClientErrorCode.AUTH_BLOCKING_TOKEN_EXPIRED = {
  351. code: 'auth-blocking-token-expired',
  352. message: 'The provided Firebase Auth Blocking token is expired.',
  353. };
  354. AuthClientErrorCode.BILLING_NOT_ENABLED = {
  355. code: 'billing-not-enabled',
  356. message: 'Feature requires billing to be enabled.',
  357. };
  358. AuthClientErrorCode.CLAIMS_TOO_LARGE = {
  359. code: 'claims-too-large',
  360. message: 'Developer claims maximum payload size exceeded.',
  361. };
  362. AuthClientErrorCode.CONFIGURATION_EXISTS = {
  363. code: 'configuration-exists',
  364. message: 'A configuration already exists with the provided identifier.',
  365. };
  366. AuthClientErrorCode.CONFIGURATION_NOT_FOUND = {
  367. code: 'configuration-not-found',
  368. message: 'There is no configuration corresponding to the provided identifier.',
  369. };
  370. AuthClientErrorCode.ID_TOKEN_EXPIRED = {
  371. code: 'id-token-expired',
  372. message: 'The provided Firebase ID token is expired.',
  373. };
  374. AuthClientErrorCode.INVALID_ARGUMENT = {
  375. code: 'argument-error',
  376. message: 'Invalid argument provided.',
  377. };
  378. AuthClientErrorCode.INVALID_CONFIG = {
  379. code: 'invalid-config',
  380. message: 'The provided configuration is invalid.',
  381. };
  382. AuthClientErrorCode.EMAIL_ALREADY_EXISTS = {
  383. code: 'email-already-exists',
  384. message: 'The email address is already in use by another account.',
  385. };
  386. AuthClientErrorCode.EMAIL_NOT_FOUND = {
  387. code: 'email-not-found',
  388. message: 'There is no user record corresponding to the provided email.',
  389. };
  390. AuthClientErrorCode.FORBIDDEN_CLAIM = {
  391. code: 'reserved-claim',
  392. message: 'The specified developer claim is reserved and cannot be specified.',
  393. };
  394. AuthClientErrorCode.INVALID_ID_TOKEN = {
  395. code: 'invalid-id-token',
  396. message: 'The provided ID token is not a valid Firebase ID token.',
  397. };
  398. AuthClientErrorCode.ID_TOKEN_REVOKED = {
  399. code: 'id-token-revoked',
  400. message: 'The Firebase ID token has been revoked.',
  401. };
  402. AuthClientErrorCode.INTERNAL_ERROR = {
  403. code: 'internal-error',
  404. message: 'An internal error has occurred.',
  405. };
  406. AuthClientErrorCode.INVALID_CLAIMS = {
  407. code: 'invalid-claims',
  408. message: 'The provided custom claim attributes are invalid.',
  409. };
  410. AuthClientErrorCode.INVALID_CONTINUE_URI = {
  411. code: 'invalid-continue-uri',
  412. message: 'The continue URL must be a valid URL string.',
  413. };
  414. AuthClientErrorCode.INVALID_CREATION_TIME = {
  415. code: 'invalid-creation-time',
  416. message: 'The creation time must be a valid UTC date string.',
  417. };
  418. AuthClientErrorCode.INVALID_CREDENTIAL = {
  419. code: 'invalid-credential',
  420. message: 'Invalid credential object provided.',
  421. };
  422. AuthClientErrorCode.INVALID_DISABLED_FIELD = {
  423. code: 'invalid-disabled-field',
  424. message: 'The disabled field must be a boolean.',
  425. };
  426. AuthClientErrorCode.INVALID_DISPLAY_NAME = {
  427. code: 'invalid-display-name',
  428. message: 'The displayName field must be a valid string.',
  429. };
  430. AuthClientErrorCode.INVALID_DYNAMIC_LINK_DOMAIN = {
  431. code: 'invalid-dynamic-link-domain',
  432. message: 'The provided dynamic link domain is not configured or authorized ' +
  433. 'for the current project.',
  434. };
  435. AuthClientErrorCode.INVALID_EMAIL_VERIFIED = {
  436. code: 'invalid-email-verified',
  437. message: 'The emailVerified field must be a boolean.',
  438. };
  439. AuthClientErrorCode.INVALID_EMAIL = {
  440. code: 'invalid-email',
  441. message: 'The email address is improperly formatted.',
  442. };
  443. AuthClientErrorCode.INVALID_NEW_EMAIL = {
  444. code: 'invalid-new-email',
  445. message: 'The new email address is improperly formatted.',
  446. };
  447. AuthClientErrorCode.INVALID_ENROLLED_FACTORS = {
  448. code: 'invalid-enrolled-factors',
  449. message: 'The enrolled factors must be a valid array of MultiFactorInfo objects.',
  450. };
  451. AuthClientErrorCode.INVALID_ENROLLMENT_TIME = {
  452. code: 'invalid-enrollment-time',
  453. message: 'The second factor enrollment time must be a valid UTC date string.',
  454. };
  455. AuthClientErrorCode.INVALID_HASH_ALGORITHM = {
  456. code: 'invalid-hash-algorithm',
  457. message: 'The hash algorithm must match one of the strings in the list of ' +
  458. 'supported algorithms.',
  459. };
  460. AuthClientErrorCode.INVALID_HASH_BLOCK_SIZE = {
  461. code: 'invalid-hash-block-size',
  462. message: 'The hash block size must be a valid number.',
  463. };
  464. AuthClientErrorCode.INVALID_HASH_DERIVED_KEY_LENGTH = {
  465. code: 'invalid-hash-derived-key-length',
  466. message: 'The hash derived key length must be a valid number.',
  467. };
  468. AuthClientErrorCode.INVALID_HASH_KEY = {
  469. code: 'invalid-hash-key',
  470. message: 'The hash key must a valid byte buffer.',
  471. };
  472. AuthClientErrorCode.INVALID_HASH_MEMORY_COST = {
  473. code: 'invalid-hash-memory-cost',
  474. message: 'The hash memory cost must be a valid number.',
  475. };
  476. AuthClientErrorCode.INVALID_HASH_PARALLELIZATION = {
  477. code: 'invalid-hash-parallelization',
  478. message: 'The hash parallelization must be a valid number.',
  479. };
  480. AuthClientErrorCode.INVALID_HASH_ROUNDS = {
  481. code: 'invalid-hash-rounds',
  482. message: 'The hash rounds must be a valid number.',
  483. };
  484. AuthClientErrorCode.INVALID_HASH_SALT_SEPARATOR = {
  485. code: 'invalid-hash-salt-separator',
  486. message: 'The hashing algorithm salt separator field must be a valid byte buffer.',
  487. };
  488. AuthClientErrorCode.INVALID_LAST_SIGN_IN_TIME = {
  489. code: 'invalid-last-sign-in-time',
  490. message: 'The last sign-in time must be a valid UTC date string.',
  491. };
  492. AuthClientErrorCode.INVALID_NAME = {
  493. code: 'invalid-name',
  494. message: 'The resource name provided is invalid.',
  495. };
  496. AuthClientErrorCode.INVALID_OAUTH_CLIENT_ID = {
  497. code: 'invalid-oauth-client-id',
  498. message: 'The provided OAuth client ID is invalid.',
  499. };
  500. AuthClientErrorCode.INVALID_PAGE_TOKEN = {
  501. code: 'invalid-page-token',
  502. message: 'The page token must be a valid non-empty string.',
  503. };
  504. AuthClientErrorCode.INVALID_PASSWORD = {
  505. code: 'invalid-password',
  506. message: 'The password must be a string with at least 6 characters.',
  507. };
  508. AuthClientErrorCode.INVALID_PASSWORD_HASH = {
  509. code: 'invalid-password-hash',
  510. message: 'The password hash must be a valid byte buffer.',
  511. };
  512. AuthClientErrorCode.INVALID_PASSWORD_SALT = {
  513. code: 'invalid-password-salt',
  514. message: 'The password salt must be a valid byte buffer.',
  515. };
  516. AuthClientErrorCode.INVALID_PHONE_NUMBER = {
  517. code: 'invalid-phone-number',
  518. message: 'The phone number must be a non-empty E.164 standard compliant identifier ' +
  519. 'string.',
  520. };
  521. AuthClientErrorCode.INVALID_PHOTO_URL = {
  522. code: 'invalid-photo-url',
  523. message: 'The photoURL field must be a valid URL.',
  524. };
  525. AuthClientErrorCode.INVALID_PROJECT_ID = {
  526. code: 'invalid-project-id',
  527. message: 'Invalid parent project. Either parent project doesn\'t exist or didn\'t enable multi-tenancy.',
  528. };
  529. AuthClientErrorCode.INVALID_PROVIDER_DATA = {
  530. code: 'invalid-provider-data',
  531. message: 'The providerData must be a valid array of UserInfo objects.',
  532. };
  533. AuthClientErrorCode.INVALID_PROVIDER_ID = {
  534. code: 'invalid-provider-id',
  535. message: 'The providerId must be a valid supported provider identifier string.',
  536. };
  537. AuthClientErrorCode.INVALID_PROVIDER_UID = {
  538. code: 'invalid-provider-uid',
  539. message: 'The providerUid must be a valid provider uid string.',
  540. };
  541. AuthClientErrorCode.INVALID_OAUTH_RESPONSETYPE = {
  542. code: 'invalid-oauth-responsetype',
  543. message: 'Only exactly one OAuth responseType should be set to true.',
  544. };
  545. AuthClientErrorCode.INVALID_SESSION_COOKIE_DURATION = {
  546. code: 'invalid-session-cookie-duration',
  547. message: 'The session cookie duration must be a valid number in milliseconds ' +
  548. 'between 5 minutes and 2 weeks.',
  549. };
  550. AuthClientErrorCode.INVALID_TENANT_ID = {
  551. code: 'invalid-tenant-id',
  552. message: 'The tenant ID must be a valid non-empty string.',
  553. };
  554. AuthClientErrorCode.INVALID_TENANT_TYPE = {
  555. code: 'invalid-tenant-type',
  556. message: 'Tenant type must be either "full_service" or "lightweight".',
  557. };
  558. AuthClientErrorCode.INVALID_TESTING_PHONE_NUMBER = {
  559. code: 'invalid-testing-phone-number',
  560. message: 'Invalid testing phone number or invalid test code provided.',
  561. };
  562. AuthClientErrorCode.INVALID_UID = {
  563. code: 'invalid-uid',
  564. message: 'The uid must be a non-empty string with at most 128 characters.',
  565. };
  566. AuthClientErrorCode.INVALID_USER_IMPORT = {
  567. code: 'invalid-user-import',
  568. message: 'The user record to import is invalid.',
  569. };
  570. AuthClientErrorCode.INVALID_TOKENS_VALID_AFTER_TIME = {
  571. code: 'invalid-tokens-valid-after-time',
  572. message: 'The tokensValidAfterTime must be a valid UTC number in seconds.',
  573. };
  574. AuthClientErrorCode.MISMATCHING_TENANT_ID = {
  575. code: 'mismatching-tenant-id',
  576. message: 'User tenant ID does not match with the current TenantAwareAuth tenant ID.',
  577. };
  578. AuthClientErrorCode.MISSING_ANDROID_PACKAGE_NAME = {
  579. code: 'missing-android-pkg-name',
  580. message: 'An Android Package Name must be provided if the Android App is ' +
  581. 'required to be installed.',
  582. };
  583. AuthClientErrorCode.MISSING_CONFIG = {
  584. code: 'missing-config',
  585. message: 'The provided configuration is missing required attributes.',
  586. };
  587. AuthClientErrorCode.MISSING_CONTINUE_URI = {
  588. code: 'missing-continue-uri',
  589. message: 'A valid continue URL must be provided in the request.',
  590. };
  591. AuthClientErrorCode.MISSING_DISPLAY_NAME = {
  592. code: 'missing-display-name',
  593. message: 'The resource being created or edited is missing a valid display name.',
  594. };
  595. AuthClientErrorCode.MISSING_EMAIL = {
  596. code: 'missing-email',
  597. message: 'The email is required for the specified action. For example, a multi-factor user ' +
  598. 'requires a verified email.',
  599. };
  600. AuthClientErrorCode.MISSING_IOS_BUNDLE_ID = {
  601. code: 'missing-ios-bundle-id',
  602. message: 'The request is missing an iOS Bundle ID.',
  603. };
  604. AuthClientErrorCode.MISSING_ISSUER = {
  605. code: 'missing-issuer',
  606. message: 'The OAuth/OIDC configuration issuer must not be empty.',
  607. };
  608. AuthClientErrorCode.MISSING_HASH_ALGORITHM = {
  609. code: 'missing-hash-algorithm',
  610. message: 'Importing users with password hashes requires that the hashing ' +
  611. 'algorithm and its parameters be provided.',
  612. };
  613. AuthClientErrorCode.MISSING_OAUTH_CLIENT_ID = {
  614. code: 'missing-oauth-client-id',
  615. message: 'The OAuth/OIDC configuration client ID must not be empty.',
  616. };
  617. AuthClientErrorCode.MISSING_OAUTH_CLIENT_SECRET = {
  618. code: 'missing-oauth-client-secret',
  619. message: 'The OAuth configuration client secret is required to enable OIDC code flow.',
  620. };
  621. AuthClientErrorCode.MISSING_PROVIDER_ID = {
  622. code: 'missing-provider-id',
  623. message: 'A valid provider ID must be provided in the request.',
  624. };
  625. AuthClientErrorCode.MISSING_SAML_RELYING_PARTY_CONFIG = {
  626. code: 'missing-saml-relying-party-config',
  627. message: 'The SAML configuration provided is missing a relying party configuration.',
  628. };
  629. AuthClientErrorCode.MAXIMUM_TEST_PHONE_NUMBER_EXCEEDED = {
  630. code: 'test-phone-number-limit-exceeded',
  631. message: 'The maximum allowed number of test phone number / code pairs has been exceeded.',
  632. };
  633. AuthClientErrorCode.MAXIMUM_USER_COUNT_EXCEEDED = {
  634. code: 'maximum-user-count-exceeded',
  635. message: 'The maximum allowed number of users to import has been exceeded.',
  636. };
  637. AuthClientErrorCode.MISSING_UID = {
  638. code: 'missing-uid',
  639. message: 'A uid identifier is required for the current operation.',
  640. };
  641. AuthClientErrorCode.OPERATION_NOT_ALLOWED = {
  642. code: 'operation-not-allowed',
  643. message: 'The given sign-in provider is disabled for this Firebase project. ' +
  644. 'Enable it in the Firebase console, under the sign-in method tab of the ' +
  645. 'Auth section.',
  646. };
  647. AuthClientErrorCode.PHONE_NUMBER_ALREADY_EXISTS = {
  648. code: 'phone-number-already-exists',
  649. message: 'The user with the provided phone number already exists.',
  650. };
  651. AuthClientErrorCode.PROJECT_NOT_FOUND = {
  652. code: 'project-not-found',
  653. message: 'No Firebase project was found for the provided credential.',
  654. };
  655. AuthClientErrorCode.INSUFFICIENT_PERMISSION = {
  656. code: 'insufficient-permission',
  657. message: 'Credential implementation provided to initializeApp() via the "credential" property ' +
  658. 'has insufficient permission to access the requested resource. See ' +
  659. 'https://firebase.google.com/docs/admin/setup for details on how to authenticate this SDK ' +
  660. 'with appropriate permissions.',
  661. };
  662. AuthClientErrorCode.QUOTA_EXCEEDED = {
  663. code: 'quota-exceeded',
  664. message: 'The project quota for the specified operation has been exceeded.',
  665. };
  666. AuthClientErrorCode.SECOND_FACTOR_LIMIT_EXCEEDED = {
  667. code: 'second-factor-limit-exceeded',
  668. message: 'The maximum number of allowed second factors on a user has been exceeded.',
  669. };
  670. AuthClientErrorCode.SECOND_FACTOR_UID_ALREADY_EXISTS = {
  671. code: 'second-factor-uid-already-exists',
  672. message: 'The specified second factor "uid" already exists.',
  673. };
  674. AuthClientErrorCode.SESSION_COOKIE_EXPIRED = {
  675. code: 'session-cookie-expired',
  676. message: 'The Firebase session cookie is expired.',
  677. };
  678. AuthClientErrorCode.SESSION_COOKIE_REVOKED = {
  679. code: 'session-cookie-revoked',
  680. message: 'The Firebase session cookie has been revoked.',
  681. };
  682. AuthClientErrorCode.TENANT_NOT_FOUND = {
  683. code: 'tenant-not-found',
  684. message: 'There is no tenant corresponding to the provided identifier.',
  685. };
  686. AuthClientErrorCode.UID_ALREADY_EXISTS = {
  687. code: 'uid-already-exists',
  688. message: 'The user with the provided uid already exists.',
  689. };
  690. AuthClientErrorCode.UNAUTHORIZED_DOMAIN = {
  691. code: 'unauthorized-continue-uri',
  692. message: 'The domain of the continue URL is not whitelisted. Whitelist the domain in the ' +
  693. 'Firebase console.',
  694. };
  695. AuthClientErrorCode.UNSUPPORTED_FIRST_FACTOR = {
  696. code: 'unsupported-first-factor',
  697. message: 'A multi-factor user requires a supported first factor.',
  698. };
  699. AuthClientErrorCode.UNSUPPORTED_SECOND_FACTOR = {
  700. code: 'unsupported-second-factor',
  701. message: 'The request specified an unsupported type of second factor.',
  702. };
  703. AuthClientErrorCode.UNSUPPORTED_TENANT_OPERATION = {
  704. code: 'unsupported-tenant-operation',
  705. message: 'This operation is not supported in a multi-tenant context.',
  706. };
  707. AuthClientErrorCode.UNVERIFIED_EMAIL = {
  708. code: 'unverified-email',
  709. message: 'A verified email is required for the specified action. For example, a multi-factor user ' +
  710. 'requires a verified email.',
  711. };
  712. AuthClientErrorCode.USER_NOT_FOUND = {
  713. code: 'user-not-found',
  714. message: 'There is no user record corresponding to the provided identifier.',
  715. };
  716. AuthClientErrorCode.NOT_FOUND = {
  717. code: 'not-found',
  718. message: 'The requested resource was not found.',
  719. };
  720. AuthClientErrorCode.USER_DISABLED = {
  721. code: 'user-disabled',
  722. message: 'The user record is disabled.',
  723. };
  724. AuthClientErrorCode.USER_NOT_DISABLED = {
  725. code: 'user-not-disabled',
  726. message: 'The user must be disabled in order to bulk delete it (or you must pass force=true).',
  727. };
  728. AuthClientErrorCode.INVALID_RECAPTCHA_ACTION = {
  729. code: 'invalid-recaptcha-action',
  730. message: 'reCAPTCHA action must be "BLOCK".'
  731. };
  732. AuthClientErrorCode.INVALID_RECAPTCHA_ENFORCEMENT_STATE = {
  733. code: 'invalid-recaptcha-enforcement-state',
  734. message: 'reCAPTCHA enforcement state must be either "OFF", "AUDIT" or "ENFORCE".'
  735. };
  736. AuthClientErrorCode.RECAPTCHA_NOT_ENABLED = {
  737. code: 'racaptcha-not-enabled',
  738. message: 'reCAPTCHA enterprise is not enabled.'
  739. };
  740. /**
  741. * Messaging client error codes and their default messages.
  742. */
  743. class MessagingClientErrorCode {
  744. }
  745. exports.MessagingClientErrorCode = MessagingClientErrorCode;
  746. MessagingClientErrorCode.INVALID_ARGUMENT = {
  747. code: 'invalid-argument',
  748. message: 'Invalid argument provided.',
  749. };
  750. MessagingClientErrorCode.INVALID_RECIPIENT = {
  751. code: 'invalid-recipient',
  752. message: 'Invalid message recipient provided.',
  753. };
  754. MessagingClientErrorCode.INVALID_PAYLOAD = {
  755. code: 'invalid-payload',
  756. message: 'Invalid message payload provided.',
  757. };
  758. MessagingClientErrorCode.INVALID_DATA_PAYLOAD_KEY = {
  759. code: 'invalid-data-payload-key',
  760. message: 'The data message payload contains an invalid key. See the reference documentation ' +
  761. 'for the DataMessagePayload type for restricted keys.',
  762. };
  763. MessagingClientErrorCode.PAYLOAD_SIZE_LIMIT_EXCEEDED = {
  764. code: 'payload-size-limit-exceeded',
  765. message: 'The provided message payload exceeds the FCM size limits. See the error documentation ' +
  766. 'for more details.',
  767. };
  768. MessagingClientErrorCode.INVALID_OPTIONS = {
  769. code: 'invalid-options',
  770. message: 'Invalid message options provided.',
  771. };
  772. MessagingClientErrorCode.INVALID_REGISTRATION_TOKEN = {
  773. code: 'invalid-registration-token',
  774. message: 'Invalid registration token provided. Make sure it matches the registration token ' +
  775. 'the client app receives from registering with FCM.',
  776. };
  777. MessagingClientErrorCode.REGISTRATION_TOKEN_NOT_REGISTERED = {
  778. code: 'registration-token-not-registered',
  779. message: 'The provided registration token is not registered. A previously valid registration ' +
  780. 'token can be unregistered for a variety of reasons. See the error documentation for more ' +
  781. 'details. Remove this registration token and stop using it to send messages.',
  782. };
  783. MessagingClientErrorCode.MISMATCHED_CREDENTIAL = {
  784. code: 'mismatched-credential',
  785. message: 'The credential used to authenticate this SDK does not have permission to send ' +
  786. 'messages to the device corresponding to the provided registration token. Make sure the ' +
  787. 'credential and registration token both belong to the same Firebase project.',
  788. };
  789. MessagingClientErrorCode.INVALID_PACKAGE_NAME = {
  790. code: 'invalid-package-name',
  791. message: 'The message was addressed to a registration token whose package name does not match ' +
  792. 'the provided "restrictedPackageName" option.',
  793. };
  794. MessagingClientErrorCode.DEVICE_MESSAGE_RATE_EXCEEDED = {
  795. code: 'device-message-rate-exceeded',
  796. message: 'The rate of messages to a particular device is too high. Reduce the number of ' +
  797. 'messages sent to this device and do not immediately retry sending to this device.',
  798. };
  799. MessagingClientErrorCode.TOPICS_MESSAGE_RATE_EXCEEDED = {
  800. code: 'topics-message-rate-exceeded',
  801. message: 'The rate of messages to subscribers to a particular topic is too high. Reduce the ' +
  802. 'number of messages sent for this topic, and do not immediately retry sending to this topic.',
  803. };
  804. MessagingClientErrorCode.MESSAGE_RATE_EXCEEDED = {
  805. code: 'message-rate-exceeded',
  806. message: 'Sending limit exceeded for the message target.',
  807. };
  808. MessagingClientErrorCode.THIRD_PARTY_AUTH_ERROR = {
  809. code: 'third-party-auth-error',
  810. message: 'A message targeted to an iOS device could not be sent because the required APNs ' +
  811. 'SSL certificate was not uploaded or has expired. Check the validity of your development ' +
  812. 'and production certificates.',
  813. };
  814. MessagingClientErrorCode.TOO_MANY_TOPICS = {
  815. code: 'too-many-topics',
  816. message: 'The maximum number of topics the provided registration token can be subscribed to ' +
  817. 'has been exceeded.',
  818. };
  819. MessagingClientErrorCode.AUTHENTICATION_ERROR = {
  820. code: 'authentication-error',
  821. message: 'An error occurred when trying to authenticate to the FCM servers. Make sure the ' +
  822. 'credential used to authenticate this SDK has the proper permissions. See ' +
  823. 'https://firebase.google.com/docs/admin/setup for setup instructions.',
  824. };
  825. MessagingClientErrorCode.SERVER_UNAVAILABLE = {
  826. code: 'server-unavailable',
  827. message: 'The FCM server could not process the request in time. See the error documentation ' +
  828. 'for more details.',
  829. };
  830. MessagingClientErrorCode.INTERNAL_ERROR = {
  831. code: 'internal-error',
  832. message: 'An internal error has occurred. Please retry the request.',
  833. };
  834. MessagingClientErrorCode.UNKNOWN_ERROR = {
  835. code: 'unknown-error',
  836. message: 'An unknown server error was returned.',
  837. };
  838. class InstallationsClientErrorCode {
  839. }
  840. exports.InstallationsClientErrorCode = InstallationsClientErrorCode;
  841. InstallationsClientErrorCode.INVALID_ARGUMENT = {
  842. code: 'invalid-argument',
  843. message: 'Invalid argument provided.',
  844. };
  845. InstallationsClientErrorCode.INVALID_PROJECT_ID = {
  846. code: 'invalid-project-id',
  847. message: 'Invalid project ID provided.',
  848. };
  849. InstallationsClientErrorCode.INVALID_INSTALLATION_ID = {
  850. code: 'invalid-installation-id',
  851. message: 'Invalid installation ID provided.',
  852. };
  853. InstallationsClientErrorCode.API_ERROR = {
  854. code: 'api-error',
  855. message: 'Installation ID API call failed.',
  856. };
  857. class InstanceIdClientErrorCode extends InstallationsClientErrorCode {
  858. }
  859. exports.InstanceIdClientErrorCode = InstanceIdClientErrorCode;
  860. InstanceIdClientErrorCode.INVALID_INSTANCE_ID = {
  861. code: 'invalid-instance-id',
  862. message: 'Invalid instance ID provided.',
  863. };
  864. /** @const {ServerToClientCode} Auth server to client enum error codes. */
  865. const AUTH_SERVER_TO_CLIENT_CODE = {
  866. // Feature being configured or used requires a billing account.
  867. BILLING_NOT_ENABLED: 'BILLING_NOT_ENABLED',
  868. // Claims payload is too large.
  869. CLAIMS_TOO_LARGE: 'CLAIMS_TOO_LARGE',
  870. // Configuration being added already exists.
  871. CONFIGURATION_EXISTS: 'CONFIGURATION_EXISTS',
  872. // Configuration not found.
  873. CONFIGURATION_NOT_FOUND: 'CONFIGURATION_NOT_FOUND',
  874. // Provided credential has insufficient permissions.
  875. INSUFFICIENT_PERMISSION: 'INSUFFICIENT_PERMISSION',
  876. // Provided configuration has invalid fields.
  877. INVALID_CONFIG: 'INVALID_CONFIG',
  878. // Provided configuration identifier is invalid.
  879. INVALID_CONFIG_ID: 'INVALID_PROVIDER_ID',
  880. // ActionCodeSettings missing continue URL.
  881. INVALID_CONTINUE_URI: 'INVALID_CONTINUE_URI',
  882. // Dynamic link domain in provided ActionCodeSettings is not authorized.
  883. INVALID_DYNAMIC_LINK_DOMAIN: 'INVALID_DYNAMIC_LINK_DOMAIN',
  884. // uploadAccount provides an email that already exists.
  885. DUPLICATE_EMAIL: 'EMAIL_ALREADY_EXISTS',
  886. // uploadAccount provides a localId that already exists.
  887. DUPLICATE_LOCAL_ID: 'UID_ALREADY_EXISTS',
  888. // Request specified a multi-factor enrollment ID that already exists.
  889. DUPLICATE_MFA_ENROLLMENT_ID: 'SECOND_FACTOR_UID_ALREADY_EXISTS',
  890. // setAccountInfo email already exists.
  891. EMAIL_EXISTS: 'EMAIL_ALREADY_EXISTS',
  892. // /accounts:sendOobCode for password reset when user is not found.
  893. EMAIL_NOT_FOUND: 'EMAIL_NOT_FOUND',
  894. // Reserved claim name.
  895. FORBIDDEN_CLAIM: 'FORBIDDEN_CLAIM',
  896. // Invalid claims provided.
  897. INVALID_CLAIMS: 'INVALID_CLAIMS',
  898. // Invalid session cookie duration.
  899. INVALID_DURATION: 'INVALID_SESSION_COOKIE_DURATION',
  900. // Invalid email provided.
  901. INVALID_EMAIL: 'INVALID_EMAIL',
  902. // Invalid new email provided.
  903. INVALID_NEW_EMAIL: 'INVALID_NEW_EMAIL',
  904. // Invalid tenant display name. This can be thrown on CreateTenant and UpdateTenant.
  905. INVALID_DISPLAY_NAME: 'INVALID_DISPLAY_NAME',
  906. // Invalid ID token provided.
  907. INVALID_ID_TOKEN: 'INVALID_ID_TOKEN',
  908. // Invalid tenant/parent resource name.
  909. INVALID_NAME: 'INVALID_NAME',
  910. // OIDC configuration has an invalid OAuth client ID.
  911. INVALID_OAUTH_CLIENT_ID: 'INVALID_OAUTH_CLIENT_ID',
  912. // Invalid page token.
  913. INVALID_PAGE_SELECTION: 'INVALID_PAGE_TOKEN',
  914. // Invalid phone number.
  915. INVALID_PHONE_NUMBER: 'INVALID_PHONE_NUMBER',
  916. // Invalid agent project. Either agent project doesn't exist or didn't enable multi-tenancy.
  917. INVALID_PROJECT_ID: 'INVALID_PROJECT_ID',
  918. // Invalid provider ID.
  919. INVALID_PROVIDER_ID: 'INVALID_PROVIDER_ID',
  920. // Invalid service account.
  921. INVALID_SERVICE_ACCOUNT: 'INVALID_SERVICE_ACCOUNT',
  922. // Invalid testing phone number.
  923. INVALID_TESTING_PHONE_NUMBER: 'INVALID_TESTING_PHONE_NUMBER',
  924. // Invalid tenant type.
  925. INVALID_TENANT_TYPE: 'INVALID_TENANT_TYPE',
  926. // Missing Android package name.
  927. MISSING_ANDROID_PACKAGE_NAME: 'MISSING_ANDROID_PACKAGE_NAME',
  928. // Missing configuration.
  929. MISSING_CONFIG: 'MISSING_CONFIG',
  930. // Missing configuration identifier.
  931. MISSING_CONFIG_ID: 'MISSING_PROVIDER_ID',
  932. // Missing tenant display name: This can be thrown on CreateTenant and UpdateTenant.
  933. MISSING_DISPLAY_NAME: 'MISSING_DISPLAY_NAME',
  934. // Email is required for the specified action. For example a multi-factor user requires
  935. // a verified email.
  936. MISSING_EMAIL: 'MISSING_EMAIL',
  937. // Missing iOS bundle ID.
  938. MISSING_IOS_BUNDLE_ID: 'MISSING_IOS_BUNDLE_ID',
  939. // Missing OIDC issuer.
  940. MISSING_ISSUER: 'MISSING_ISSUER',
  941. // No localId provided (deleteAccount missing localId).
  942. MISSING_LOCAL_ID: 'MISSING_UID',
  943. // OIDC configuration is missing an OAuth client ID.
  944. MISSING_OAUTH_CLIENT_ID: 'MISSING_OAUTH_CLIENT_ID',
  945. // Missing provider ID.
  946. MISSING_PROVIDER_ID: 'MISSING_PROVIDER_ID',
  947. // Missing SAML RP config.
  948. MISSING_SAML_RELYING_PARTY_CONFIG: 'MISSING_SAML_RELYING_PARTY_CONFIG',
  949. // Empty user list in uploadAccount.
  950. MISSING_USER_ACCOUNT: 'MISSING_UID',
  951. // Password auth disabled in console.
  952. OPERATION_NOT_ALLOWED: 'OPERATION_NOT_ALLOWED',
  953. // Provided credential has insufficient permissions.
  954. PERMISSION_DENIED: 'INSUFFICIENT_PERMISSION',
  955. // Phone number already exists.
  956. PHONE_NUMBER_EXISTS: 'PHONE_NUMBER_ALREADY_EXISTS',
  957. // Project not found.
  958. PROJECT_NOT_FOUND: 'PROJECT_NOT_FOUND',
  959. // In multi-tenancy context: project creation quota exceeded.
  960. QUOTA_EXCEEDED: 'QUOTA_EXCEEDED',
  961. // Currently only 5 second factors can be set on the same user.
  962. SECOND_FACTOR_LIMIT_EXCEEDED: 'SECOND_FACTOR_LIMIT_EXCEEDED',
  963. // Tenant not found.
  964. TENANT_NOT_FOUND: 'TENANT_NOT_FOUND',
  965. // Tenant ID mismatch.
  966. TENANT_ID_MISMATCH: 'MISMATCHING_TENANT_ID',
  967. // Token expired error.
  968. TOKEN_EXPIRED: 'ID_TOKEN_EXPIRED',
  969. // Continue URL provided in ActionCodeSettings has a domain that is not whitelisted.
  970. UNAUTHORIZED_DOMAIN: 'UNAUTHORIZED_DOMAIN',
  971. // A multi-factor user requires a supported first factor.
  972. UNSUPPORTED_FIRST_FACTOR: 'UNSUPPORTED_FIRST_FACTOR',
  973. // The request specified an unsupported type of second factor.
  974. UNSUPPORTED_SECOND_FACTOR: 'UNSUPPORTED_SECOND_FACTOR',
  975. // Operation is not supported in a multi-tenant context.
  976. UNSUPPORTED_TENANT_OPERATION: 'UNSUPPORTED_TENANT_OPERATION',
  977. // A verified email is required for the specified action. For example a multi-factor user
  978. // requires a verified email.
  979. UNVERIFIED_EMAIL: 'UNVERIFIED_EMAIL',
  980. // User on which action is to be performed is not found.
  981. USER_NOT_FOUND: 'USER_NOT_FOUND',
  982. // User record is disabled.
  983. USER_DISABLED: 'USER_DISABLED',
  984. // Password provided is too weak.
  985. WEAK_PASSWORD: 'INVALID_PASSWORD',
  986. // Unrecognized reCAPTCHA action.
  987. INVALID_RECAPTCHA_ACTION: 'INVALID_RECAPTCHA_ACTION',
  988. // Unrecognized reCAPTCHA enforcement state.
  989. INVALID_RECAPTCHA_ENFORCEMENT_STATE: 'INVALID_RECAPTCHA_ENFORCEMENT_STATE',
  990. // reCAPTCHA is not enabled for account defender.
  991. RECAPTCHA_NOT_ENABLED: 'RECAPTCHA_NOT_ENABLED'
  992. };
  993. /** @const {ServerToClientCode} Messaging server to client enum error codes. */
  994. const MESSAGING_SERVER_TO_CLIENT_CODE = {
  995. /* GENERIC ERRORS */
  996. // Generic invalid message parameter provided.
  997. InvalidParameters: 'INVALID_ARGUMENT',
  998. // Mismatched sender ID.
  999. MismatchSenderId: 'MISMATCHED_CREDENTIAL',
  1000. // FCM server unavailable.
  1001. Unavailable: 'SERVER_UNAVAILABLE',
  1002. // FCM server internal error.
  1003. InternalServerError: 'INTERNAL_ERROR',
  1004. /* SEND ERRORS */
  1005. // Invalid registration token format.
  1006. InvalidRegistration: 'INVALID_REGISTRATION_TOKEN',
  1007. // Registration token is not registered.
  1008. NotRegistered: 'REGISTRATION_TOKEN_NOT_REGISTERED',
  1009. // Registration token does not match restricted package name.
  1010. InvalidPackageName: 'INVALID_PACKAGE_NAME',
  1011. // Message payload size limit exceeded.
  1012. MessageTooBig: 'PAYLOAD_SIZE_LIMIT_EXCEEDED',
  1013. // Invalid key in the data message payload.
  1014. InvalidDataKey: 'INVALID_DATA_PAYLOAD_KEY',
  1015. // Invalid time to live option.
  1016. InvalidTtl: 'INVALID_OPTIONS',
  1017. // Device message rate exceeded.
  1018. DeviceMessageRateExceeded: 'DEVICE_MESSAGE_RATE_EXCEEDED',
  1019. // Topics message rate exceeded.
  1020. TopicsMessageRateExceeded: 'TOPICS_MESSAGE_RATE_EXCEEDED',
  1021. // Invalid APNs credentials.
  1022. InvalidApnsCredential: 'THIRD_PARTY_AUTH_ERROR',
  1023. /* FCM v1 canonical error codes */
  1024. NOT_FOUND: 'REGISTRATION_TOKEN_NOT_REGISTERED',
  1025. PERMISSION_DENIED: 'MISMATCHED_CREDENTIAL',
  1026. RESOURCE_EXHAUSTED: 'MESSAGE_RATE_EXCEEDED',
  1027. UNAUTHENTICATED: 'THIRD_PARTY_AUTH_ERROR',
  1028. /* FCM v1 new error codes */
  1029. APNS_AUTH_ERROR: 'THIRD_PARTY_AUTH_ERROR',
  1030. INTERNAL: 'INTERNAL_ERROR',
  1031. INVALID_ARGUMENT: 'INVALID_ARGUMENT',
  1032. QUOTA_EXCEEDED: 'MESSAGE_RATE_EXCEEDED',
  1033. SENDER_ID_MISMATCH: 'MISMATCHED_CREDENTIAL',
  1034. THIRD_PARTY_AUTH_ERROR: 'THIRD_PARTY_AUTH_ERROR',
  1035. UNAVAILABLE: 'SERVER_UNAVAILABLE',
  1036. UNREGISTERED: 'REGISTRATION_TOKEN_NOT_REGISTERED',
  1037. UNSPECIFIED_ERROR: 'UNKNOWN_ERROR',
  1038. };
  1039. /** @const {ServerToClientCode} Topic management (IID) server to client enum error codes. */
  1040. const TOPIC_MGT_SERVER_TO_CLIENT_CODE = {
  1041. /* TOPIC SUBSCRIPTION MANAGEMENT ERRORS */
  1042. NOT_FOUND: 'REGISTRATION_TOKEN_NOT_REGISTERED',
  1043. INVALID_ARGUMENT: 'INVALID_REGISTRATION_TOKEN',
  1044. TOO_MANY_TOPICS: 'TOO_MANY_TOPICS',
  1045. RESOURCE_EXHAUSTED: 'TOO_MANY_TOPICS',
  1046. PERMISSION_DENIED: 'AUTHENTICATION_ERROR',
  1047. DEADLINE_EXCEEDED: 'SERVER_UNAVAILABLE',
  1048. INTERNAL: 'INTERNAL_ERROR',
  1049. UNKNOWN: 'UNKNOWN_ERROR',
  1050. };