UNPKG

17.2 kBTypeScriptView Raw
1/*! firebase-admin v10.0.0 */
2/*!
3 * @license
4 * Copyright 2017 Google Inc.
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18import { FirebaseError as FirebaseErrorInterface } from '../app';
19/**
20 * Defines error info type. This includes a code and message string.
21 */
22export interface ErrorInfo {
23 code: string;
24 message: string;
25}
26/**
27 * Firebase error code structure. This extends Error.
28 *
29 * @param errorInfo - The error information (code and message).
30 * @constructor
31 */
32export declare class FirebaseError extends Error implements FirebaseErrorInterface {
33 private errorInfo;
34 constructor(errorInfo: ErrorInfo);
35 /** @returns The error code. */
36 get code(): string;
37 /** @returns The error message. */
38 get message(): string;
39 /** @returns The object representation of the error. */
40 toJSON(): object;
41}
42/**
43 * A FirebaseError with a prefix in front of the error code.
44 *
45 * @param codePrefix - The prefix to apply to the error code.
46 * @param code - The error code.
47 * @param message - The error message.
48 * @constructor
49 */
50export declare class PrefixedFirebaseError extends FirebaseError {
51 private codePrefix;
52 constructor(codePrefix: string, code: string, message: string);
53 /**
54 * Allows the error type to be checked without needing to know implementation details
55 * of the code prefixing.
56 *
57 * @param code - The non-prefixed error code to test against.
58 * @returns True if the code matches, false otherwise.
59 */
60 hasCode(code: string): boolean;
61}
62/**
63 * Firebase App error code structure. This extends PrefixedFirebaseError.
64 *
65 * @param code - The error code.
66 * @param message - The error message.
67 * @constructor
68 */
69export declare class FirebaseAppError extends PrefixedFirebaseError {
70 constructor(code: string, message: string);
71}
72/**
73 * Firebase Auth error code structure. This extends PrefixedFirebaseError.
74 *
75 * @param info - The error code info.
76 * @param [message] The error message. This will override the default
77 * message if provided.
78 * @constructor
79 */
80export declare class FirebaseAuthError extends PrefixedFirebaseError {
81 /**
82 * Creates the developer-facing error corresponding to the backend error code.
83 *
84 * @param serverErrorCode - The server error code.
85 * @param [message] The error message. The default message is used
86 * if not provided.
87 * @param [rawServerResponse] The error's raw server response.
88 * @returns The corresponding developer-facing error.
89 */
90 static fromServerError(serverErrorCode: string, message?: string, rawServerResponse?: object): FirebaseAuthError;
91 constructor(info: ErrorInfo, message?: string);
92}
93/**
94 * Firebase Database error code structure. This extends FirebaseError.
95 *
96 * @param info - The error code info.
97 * @param [message] The error message. This will override the default
98 * message if provided.
99 * @constructor
100 */
101export declare class FirebaseDatabaseError extends FirebaseError {
102 constructor(info: ErrorInfo, message?: string);
103}
104/**
105 * Firebase Firestore error code structure. This extends FirebaseError.
106 *
107 * @param info - The error code info.
108 * @param [message] The error message. This will override the default
109 * message if provided.
110 * @constructor
111 */
112export declare class FirebaseFirestoreError extends FirebaseError {
113 constructor(info: ErrorInfo, message?: string);
114}
115/**
116 * Firebase instance ID error code structure. This extends FirebaseError.
117 *
118 * @param info - The error code info.
119 * @param [message] The error message. This will override the default
120 * message if provided.
121 * @constructor
122 */
123export declare class FirebaseInstanceIdError extends FirebaseError {
124 constructor(info: ErrorInfo, message?: string);
125}
126/**
127 * Firebase Installations service error code structure. This extends `FirebaseError`.
128 *
129 * @param info - The error code info.
130 * @param message - The error message. This will override the default
131 * message if provided.
132 * @constructor
133 */
134export declare class FirebaseInstallationsError extends FirebaseError {
135 constructor(info: ErrorInfo, message?: string);
136}
137/**
138 * Firebase Messaging error code structure. This extends PrefixedFirebaseError.
139 *
140 * @param info - The error code info.
141 * @param [message] The error message. This will override the default message if provided.
142 * @constructor
143 */
144export declare class FirebaseMessagingError extends PrefixedFirebaseError {
145 /**
146 * Creates the developer-facing error corresponding to the backend error code.
147 *
148 * @param serverErrorCode - The server error code.
149 * @param [message] The error message. The default message is used
150 * if not provided.
151 * @param [rawServerResponse] The error's raw server response.
152 * @returns The corresponding developer-facing error.
153 */
154 static fromServerError(serverErrorCode: string | null, message?: string | null, rawServerResponse?: object): FirebaseMessagingError;
155 static fromTopicManagementServerError(serverErrorCode: string, message?: string, rawServerResponse?: object): FirebaseMessagingError;
156 constructor(info: ErrorInfo, message?: string);
157}
158/**
159 * Firebase project management error code structure. This extends PrefixedFirebaseError.
160 *
161 * @param code - The error code.
162 * @param message - The error message.
163 * @constructor
164 */
165export declare class FirebaseProjectManagementError extends PrefixedFirebaseError {
166 constructor(code: ProjectManagementErrorCode, message: string);
167}
168/**
169 * App client error codes and their default messages.
170 */
171export declare class AppErrorCodes {
172 static APP_DELETED: string;
173 static DUPLICATE_APP: string;
174 static INVALID_ARGUMENT: string;
175 static INTERNAL_ERROR: string;
176 static INVALID_APP_NAME: string;
177 static INVALID_APP_OPTIONS: string;
178 static INVALID_CREDENTIAL: string;
179 static NETWORK_ERROR: string;
180 static NETWORK_TIMEOUT: string;
181 static NO_APP: string;
182 static UNABLE_TO_PARSE_RESPONSE: string;
183}
184/**
185 * Auth client error codes and their default messages.
186 */
187export declare class AuthClientErrorCode {
188 static BILLING_NOT_ENABLED: {
189 code: string;
190 message: string;
191 };
192 static CLAIMS_TOO_LARGE: {
193 code: string;
194 message: string;
195 };
196 static CONFIGURATION_EXISTS: {
197 code: string;
198 message: string;
199 };
200 static CONFIGURATION_NOT_FOUND: {
201 code: string;
202 message: string;
203 };
204 static ID_TOKEN_EXPIRED: {
205 code: string;
206 message: string;
207 };
208 static INVALID_ARGUMENT: {
209 code: string;
210 message: string;
211 };
212 static INVALID_CONFIG: {
213 code: string;
214 message: string;
215 };
216 static EMAIL_ALREADY_EXISTS: {
217 code: string;
218 message: string;
219 };
220 static EMAIL_NOT_FOUND: {
221 code: string;
222 message: string;
223 };
224 static FORBIDDEN_CLAIM: {
225 code: string;
226 message: string;
227 };
228 static INVALID_ID_TOKEN: {
229 code: string;
230 message: string;
231 };
232 static ID_TOKEN_REVOKED: {
233 code: string;
234 message: string;
235 };
236 static INTERNAL_ERROR: {
237 code: string;
238 message: string;
239 };
240 static INVALID_CLAIMS: {
241 code: string;
242 message: string;
243 };
244 static INVALID_CONTINUE_URI: {
245 code: string;
246 message: string;
247 };
248 static INVALID_CREATION_TIME: {
249 code: string;
250 message: string;
251 };
252 static INVALID_CREDENTIAL: {
253 code: string;
254 message: string;
255 };
256 static INVALID_DISABLED_FIELD: {
257 code: string;
258 message: string;
259 };
260 static INVALID_DISPLAY_NAME: {
261 code: string;
262 message: string;
263 };
264 static INVALID_DYNAMIC_LINK_DOMAIN: {
265 code: string;
266 message: string;
267 };
268 static INVALID_EMAIL_VERIFIED: {
269 code: string;
270 message: string;
271 };
272 static INVALID_EMAIL: {
273 code: string;
274 message: string;
275 };
276 static INVALID_ENROLLED_FACTORS: {
277 code: string;
278 message: string;
279 };
280 static INVALID_ENROLLMENT_TIME: {
281 code: string;
282 message: string;
283 };
284 static INVALID_HASH_ALGORITHM: {
285 code: string;
286 message: string;
287 };
288 static INVALID_HASH_BLOCK_SIZE: {
289 code: string;
290 message: string;
291 };
292 static INVALID_HASH_DERIVED_KEY_LENGTH: {
293 code: string;
294 message: string;
295 };
296 static INVALID_HASH_KEY: {
297 code: string;
298 message: string;
299 };
300 static INVALID_HASH_MEMORY_COST: {
301 code: string;
302 message: string;
303 };
304 static INVALID_HASH_PARALLELIZATION: {
305 code: string;
306 message: string;
307 };
308 static INVALID_HASH_ROUNDS: {
309 code: string;
310 message: string;
311 };
312 static INVALID_HASH_SALT_SEPARATOR: {
313 code: string;
314 message: string;
315 };
316 static INVALID_LAST_SIGN_IN_TIME: {
317 code: string;
318 message: string;
319 };
320 static INVALID_NAME: {
321 code: string;
322 message: string;
323 };
324 static INVALID_OAUTH_CLIENT_ID: {
325 code: string;
326 message: string;
327 };
328 static INVALID_PAGE_TOKEN: {
329 code: string;
330 message: string;
331 };
332 static INVALID_PASSWORD: {
333 code: string;
334 message: string;
335 };
336 static INVALID_PASSWORD_HASH: {
337 code: string;
338 message: string;
339 };
340 static INVALID_PASSWORD_SALT: {
341 code: string;
342 message: string;
343 };
344 static INVALID_PHONE_NUMBER: {
345 code: string;
346 message: string;
347 };
348 static INVALID_PHOTO_URL: {
349 code: string;
350 message: string;
351 };
352 static INVALID_PROJECT_ID: {
353 code: string;
354 message: string;
355 };
356 static INVALID_PROVIDER_DATA: {
357 code: string;
358 message: string;
359 };
360 static INVALID_PROVIDER_ID: {
361 code: string;
362 message: string;
363 };
364 static INVALID_PROVIDER_UID: {
365 code: string;
366 message: string;
367 };
368 static INVALID_OAUTH_RESPONSETYPE: {
369 code: string;
370 message: string;
371 };
372 static INVALID_SESSION_COOKIE_DURATION: {
373 code: string;
374 message: string;
375 };
376 static INVALID_TENANT_ID: {
377 code: string;
378 message: string;
379 };
380 static INVALID_TENANT_TYPE: {
381 code: string;
382 message: string;
383 };
384 static INVALID_TESTING_PHONE_NUMBER: {
385 code: string;
386 message: string;
387 };
388 static INVALID_UID: {
389 code: string;
390 message: string;
391 };
392 static INVALID_USER_IMPORT: {
393 code: string;
394 message: string;
395 };
396 static INVALID_TOKENS_VALID_AFTER_TIME: {
397 code: string;
398 message: string;
399 };
400 static MISMATCHING_TENANT_ID: {
401 code: string;
402 message: string;
403 };
404 static MISSING_ANDROID_PACKAGE_NAME: {
405 code: string;
406 message: string;
407 };
408 static MISSING_CONFIG: {
409 code: string;
410 message: string;
411 };
412 static MISSING_CONTINUE_URI: {
413 code: string;
414 message: string;
415 };
416 static MISSING_DISPLAY_NAME: {
417 code: string;
418 message: string;
419 };
420 static MISSING_EMAIL: {
421 code: string;
422 message: string;
423 };
424 static MISSING_IOS_BUNDLE_ID: {
425 code: string;
426 message: string;
427 };
428 static MISSING_ISSUER: {
429 code: string;
430 message: string;
431 };
432 static MISSING_HASH_ALGORITHM: {
433 code: string;
434 message: string;
435 };
436 static MISSING_OAUTH_CLIENT_ID: {
437 code: string;
438 message: string;
439 };
440 static MISSING_OAUTH_CLIENT_SECRET: {
441 code: string;
442 message: string;
443 };
444 static MISSING_PROVIDER_ID: {
445 code: string;
446 message: string;
447 };
448 static MISSING_SAML_RELYING_PARTY_CONFIG: {
449 code: string;
450 message: string;
451 };
452 static MAXIMUM_TEST_PHONE_NUMBER_EXCEEDED: {
453 code: string;
454 message: string;
455 };
456 static MAXIMUM_USER_COUNT_EXCEEDED: {
457 code: string;
458 message: string;
459 };
460 static MISSING_UID: {
461 code: string;
462 message: string;
463 };
464 static OPERATION_NOT_ALLOWED: {
465 code: string;
466 message: string;
467 };
468 static PHONE_NUMBER_ALREADY_EXISTS: {
469 code: string;
470 message: string;
471 };
472 static PROJECT_NOT_FOUND: {
473 code: string;
474 message: string;
475 };
476 static INSUFFICIENT_PERMISSION: {
477 code: string;
478 message: string;
479 };
480 static QUOTA_EXCEEDED: {
481 code: string;
482 message: string;
483 };
484 static SECOND_FACTOR_LIMIT_EXCEEDED: {
485 code: string;
486 message: string;
487 };
488 static SECOND_FACTOR_UID_ALREADY_EXISTS: {
489 code: string;
490 message: string;
491 };
492 static SESSION_COOKIE_EXPIRED: {
493 code: string;
494 message: string;
495 };
496 static SESSION_COOKIE_REVOKED: {
497 code: string;
498 message: string;
499 };
500 static TENANT_NOT_FOUND: {
501 code: string;
502 message: string;
503 };
504 static UID_ALREADY_EXISTS: {
505 code: string;
506 message: string;
507 };
508 static UNAUTHORIZED_DOMAIN: {
509 code: string;
510 message: string;
511 };
512 static UNSUPPORTED_FIRST_FACTOR: {
513 code: string;
514 message: string;
515 };
516 static UNSUPPORTED_SECOND_FACTOR: {
517 code: string;
518 message: string;
519 };
520 static UNSUPPORTED_TENANT_OPERATION: {
521 code: string;
522 message: string;
523 };
524 static UNVERIFIED_EMAIL: {
525 code: string;
526 message: string;
527 };
528 static USER_NOT_FOUND: {
529 code: string;
530 message: string;
531 };
532 static NOT_FOUND: {
533 code: string;
534 message: string;
535 };
536 static USER_DISABLED: {
537 code: string;
538 message: string;
539 };
540 static USER_NOT_DISABLED: {
541 code: string;
542 message: string;
543 };
544}
545/**
546 * Messaging client error codes and their default messages.
547 */
548export declare class MessagingClientErrorCode {
549 static INVALID_ARGUMENT: {
550 code: string;
551 message: string;
552 };
553 static INVALID_RECIPIENT: {
554 code: string;
555 message: string;
556 };
557 static INVALID_PAYLOAD: {
558 code: string;
559 message: string;
560 };
561 static INVALID_DATA_PAYLOAD_KEY: {
562 code: string;
563 message: string;
564 };
565 static PAYLOAD_SIZE_LIMIT_EXCEEDED: {
566 code: string;
567 message: string;
568 };
569 static INVALID_OPTIONS: {
570 code: string;
571 message: string;
572 };
573 static INVALID_REGISTRATION_TOKEN: {
574 code: string;
575 message: string;
576 };
577 static REGISTRATION_TOKEN_NOT_REGISTERED: {
578 code: string;
579 message: string;
580 };
581 static MISMATCHED_CREDENTIAL: {
582 code: string;
583 message: string;
584 };
585 static INVALID_PACKAGE_NAME: {
586 code: string;
587 message: string;
588 };
589 static DEVICE_MESSAGE_RATE_EXCEEDED: {
590 code: string;
591 message: string;
592 };
593 static TOPICS_MESSAGE_RATE_EXCEEDED: {
594 code: string;
595 message: string;
596 };
597 static MESSAGE_RATE_EXCEEDED: {
598 code: string;
599 message: string;
600 };
601 static THIRD_PARTY_AUTH_ERROR: {
602 code: string;
603 message: string;
604 };
605 static TOO_MANY_TOPICS: {
606 code: string;
607 message: string;
608 };
609 static AUTHENTICATION_ERROR: {
610 code: string;
611 message: string;
612 };
613 static SERVER_UNAVAILABLE: {
614 code: string;
615 message: string;
616 };
617 static INTERNAL_ERROR: {
618 code: string;
619 message: string;
620 };
621 static UNKNOWN_ERROR: {
622 code: string;
623 message: string;
624 };
625}
626export declare class InstallationsClientErrorCode {
627 static INVALID_ARGUMENT: {
628 code: string;
629 message: string;
630 };
631 static INVALID_PROJECT_ID: {
632 code: string;
633 message: string;
634 };
635 static INVALID_INSTALLATION_ID: {
636 code: string;
637 message: string;
638 };
639 static API_ERROR: {
640 code: string;
641 message: string;
642 };
643}
644export declare class InstanceIdClientErrorCode extends InstallationsClientErrorCode {
645 static INVALID_INSTANCE_ID: {
646 code: string;
647 message: string;
648 };
649}
650export declare type ProjectManagementErrorCode = 'already-exists' | 'authentication-error' | 'internal-error' | 'invalid-argument' | 'invalid-project-id' | 'invalid-server-response' | 'not-found' | 'service-unavailable' | 'unknown-error';