forked from firebase/firebase-js-sdk
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.d.ts
7556 lines (7342 loc) · 287 KB
/
index.d.ts
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
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/**
* @license
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* <code>firebase</code> is a global namespace from which all Firebase
* services are accessed.
*/
declare namespace firebase {
/**
* @hidden
*/
type NextFn<T> = (value: T) => void;
/**
* @hidden
*/
type ErrorFn<E = Error> = (error: E) => void;
/**
* @hidden
*/
type CompleteFn = () => void;
/**
* `FirebaseError` is a subclass of the standard JavaScript `Error` object. In
* addition to a message string and stack trace, it contains a string code.
*/
interface FirebaseError {
/**
* Error codes are strings using the following format: `"service/string-code"`.
* Some examples include `"app/no-app"` and `"auth/user-not-found"`.
*
* While the message for a given error can change, the code will remain the same
* between backward-compatible versions of the Firebase SDK.
*/
code: string;
/**
* An explanatory message for the error that just occurred.
*
* This message is designed to be helpful to you, the developer. Because
* it generally does not convey meaningful information to end users,
* this message should not be displayed in your application.
*/
message: string;
/**
* The name of the class of errors, which is `"FirebaseError"`.
*/
name: string;
/**
* A string value containing the execution backtrace when the error originally
* occurred. This may not always be available.
*
* When it is available, this information can be sent to
* {@link https://firebase.google.com/support/ Firebase Support} to help
* explain the cause of an error.
*/
stack?: string;
}
/**
* @hidden
*/
interface Observer<T, E = Error> {
next: NextFn<T>;
error: ErrorFn<E>;
complete: CompleteFn;
}
/**
* The current SDK version.
*/
var SDK_VERSION: string;
/**
* @hidden
*/
type Unsubscribe = () => void;
/**
* A user account.
*/
interface User extends firebase.UserInfo {
/**
* Deletes and signs out the user.
*
* <b>Important:</b> this is a security-sensitive operation that requires the
* user to have recently signed in. If this requirement isn't met, ask the user
* to authenticate again and then call
* {@link firebase.User.reauthenticateWithCredential}.
*
* <h4>Error Codes</h4>
* <dl>
* <dt>auth/requires-recent-login</dt>
* <dd>Thrown if the user's last sign-in time does not meet the security
* threshold. Use {@link firebase.User.reauthenticateWithCredential} to
* resolve. This does not apply if the user is anonymous.</dd>
* </dl>
*/
delete(): Promise<void>;
emailVerified: boolean;
getIdTokenResult(
forceRefresh?: boolean
): Promise<firebase.auth.IdTokenResult>;
/**
* Returns a JSON Web Token (JWT) used to identify the user to a Firebase
* service.
*
* Returns the current token if it has not expired. Otherwise, this will
* refresh the token and return a new one.
*
* @param forceRefresh Force refresh regardless of token
* expiration.
*/
getIdToken(forceRefresh?: boolean): Promise<string>;
isAnonymous: boolean;
/**
* Links the user account with the given credentials and returns any available
* additional user information, such as user name.
*
* <h4>Error Codes</h4>
* <dl>
* <dt>auth/provider-already-linked</dt>
* <dd>Thrown if the provider has already been linked to the user. This error is
* thrown even if this is not the same provider's account that is currently
* linked to the user.</dd>
* <dt>auth/invalid-credential</dt>
* <dd>Thrown if the provider's credential is not valid. This can happen if it
* has already expired when calling link, or if it used invalid token(s).
* See the Firebase documentation for your provider, and make sure you pass
* in the correct parameters to the credential method.</dd>
* <dt>auth/credential-already-in-use</dt>
* <dd>Thrown if the account corresponding to the credential already exists
* among your users, or is already linked to a Firebase User.
* For example, this error could be thrown if you are upgrading an anonymous
* user to a Google user by linking a Google credential to it and the Google
* credential used is already associated with an existing Firebase Google
* user.
* The fields <code>error.email</code>, <code>error.phoneNumber</code>, and
* <code>error.credential</code> ({@link firebase.auth.AuthCredential})
* may be provided, depending on the type of credential. You can recover
* from this error by signing in with <code>error.credential</code> directly
* via {@link firebase.auth.Auth.signInWithCredential}.</dd>
* <dt>auth/email-already-in-use</dt>
* <dd>Thrown if the email corresponding to the credential already exists
* among your users. When thrown while linking a credential to an existing
* user, an <code>error.email</code> and <code>error.credential</code>
* ({@link firebase.auth.AuthCredential}) fields are also provided.
* You have to link the credential to the existing user with that email if
* you wish to continue signing in with that credential. To do so, call
* {@link firebase.auth.Auth.fetchSignInMethodsForEmail}, sign in to
* <code>error.email</code> via one of the providers returned and then
* {@link firebase.User.linkWithCredential} the original credential to that
* newly signed in user.</dd>
* <dt>auth/operation-not-allowed</dt>
* <dd>Thrown if you have not enabled the provider in the Firebase Console. Go
* to the Firebase Console for your project, in the Auth section and the
* <strong>Sign in Method</strong> tab and configure the provider.</dd>
* <dt>auth/invalid-email</dt>
* <dd>Thrown if the email used in a
* {@link firebase.auth.EmailAuthProvider.credential} is invalid.</dd>
* <dt>auth/wrong-password</dt>
* <dd>Thrown if the password used in a
* {@link firebase.auth.EmailAuthProvider.credential} is not correct or
* when the user associated with the email does not have a password.</dd>
* <dt>auth/invalid-verification-code</dt>
* <dd>Thrown if the credential is a
* {@link firebase.auth.PhoneAuthProvider.credential} and the verification
* code of the credential is not valid.</dd>
* <dt>auth/invalid-verification-id</dt>
* <dd>Thrown if the credential is a
* {@link firebase.auth.PhoneAuthProvider.credential} and the verification
* ID of the credential is not valid.</dd>
* </dl>
*
* @deprecated This method is deprecated. Use
* {@link firebase.User.linkWithCredential} instead.
*
* @param credential The auth credential.
*/
linkAndRetrieveDataWithCredential(
credential: firebase.auth.AuthCredential
): Promise<firebase.auth.UserCredential>;
/**
* Links the user account with the given credentials.
*
* <h4>Error Codes</h4>
* <dl>
* <dt>auth/provider-already-linked</dt>
* <dd>Thrown if the provider has already been linked to the user. This error is
* thrown even if this is not the same provider's account that is currently
* linked to the user.</dd>
* <dt>auth/invalid-credential</dt>
* <dd>Thrown if the provider's credential is not valid. This can happen if it
* has already expired when calling link, or if it used invalid token(s).
* See the Firebase documentation for your provider, and make sure you pass
* in the correct parameters to the credential method.</dd>
* <dt>auth/credential-already-in-use</dt>
* <dd>Thrown if the account corresponding to the credential already exists
* among your users, or is already linked to a Firebase User.
* For example, this error could be thrown if you are upgrading an anonymous
* user to a Google user by linking a Google credential to it and the Google
* credential used is already associated with an existing Firebase Google
* user.
* The fields <code>error.email</code>, <code>error.phoneNumber</code>, and
* <code>error.credential</code> ({@link firebase.auth.AuthCredential})
* may be provided, depending on the type of credential. You can recover
* from this error by signing in with <code>error.credential</code> directly
* via {@link firebase.auth.Auth.signInWithCredential}.</dd>
* <dt>auth/email-already-in-use</dt>
* <dd>Thrown if the email corresponding to the credential already exists
* among your users. When thrown while linking a credential to an existing
* user, an <code>error.email</code> and <code>error.credential</code>
* ({@link firebase.auth.AuthCredential}) fields are also provided.
* You have to link the credential to the existing user with that email if
* you wish to continue signing in with that credential. To do so, call
* {@link firebase.auth.Auth.fetchSignInMethodsForEmail}, sign in to
* <code>error.email</code> via one of the providers returned and then
* {@link firebase.User.linkWithCredential} the original credential to that
* newly signed in user.</dd>
* <dt>auth/operation-not-allowed</dt>
* <dd>Thrown if you have not enabled the provider in the Firebase Console. Go
* to the Firebase Console for your project, in the Auth section and the
* <strong>Sign in Method</strong> tab and configure the provider.</dd>
* <dt>auth/invalid-email</dt>
* <dd>Thrown if the email used in a
* {@link firebase.auth.EmailAuthProvider.credential} is invalid.</dd>
* <dt>auth/wrong-password</dt>
* <dd>Thrown if the password used in a
* {@link firebase.auth.EmailAuthProvider.credential} is not correct or
* when the user associated with the email does not have a password.</dd>
* <dt>auth/invalid-verification-code</dt>
* <dd>Thrown if the credential is a
* {@link firebase.auth.PhoneAuthProvider.credential} and the verification
* code of the credential is not valid.</dd>
* <dt>auth/invalid-verification-id</dt>
* <dd>Thrown if the credential is a
* {@link firebase.auth.PhoneAuthProvider.credential} and the verification
* ID of the credential is not valid.</dd>
* </dl>
*
* @param credential The auth credential.
*/
linkWithCredential(
credential: firebase.auth.AuthCredential
): Promise<firebase.auth.UserCredential>;
/**
* Links the user account with the given phone number.
*
* <h4>Error Codes</h4>
* <dl>
* <dt>auth/provider-already-linked</dt>
* <dd>Thrown if the provider has already been linked to the user. This error is
* thrown even if this is not the same provider's account that is currently
* linked to the user.</dd>
* <dt>auth/captcha-check-failed</dt>
* <dd>Thrown if the reCAPTCHA response token was invalid, expired, or if
* this method was called from a non-whitelisted domain.</dd>
* <dt>auth/invalid-phone-number</dt>
* <dd>Thrown if the phone number has an invalid format.</dd>
* <dt>auth/missing-phone-number</dt>
* <dd>Thrown if the phone number is missing.</dd>
* <dt>auth/quota-exceeded</dt>
* <dd>Thrown if the SMS quota for the Firebase project has been exceeded.</dd>
* <dt>auth/user-disabled</dt>
* <dd>Thrown if the user corresponding to the given phone number has been
* disabled.</dd>
* <dt>auth/credential-already-in-use</dt>
* <dd>Thrown if the account corresponding to the phone number already exists
* among your users, or is already linked to a Firebase User.
* The fields <code>error.phoneNumber</code> and
* <code>error.credential</code> ({@link firebase.auth.AuthCredential})
* are provided in this case. You can recover from this error by signing in
* with that credential directly via
* {@link firebase.auth.Auth.signInWithCredential}.</dd>
* <dt>auth/operation-not-allowed</dt>
* <dd>Thrown if you have not enabled the phone authentication provider in the
* Firebase Console. Go to the Firebase Console for your project, in the
* Auth section and the <strong>Sign in Method</strong> tab and configure
* the provider.</dd>
* </dl>
*
* @param phoneNumber The user's phone number in E.164 format (e.g.
* +16505550101).
* @param applicationVerifier
*/
linkWithPhoneNumber(
phoneNumber: string,
applicationVerifier: firebase.auth.ApplicationVerifier
): Promise<firebase.auth.ConfirmationResult>;
/**
* Links the authenticated provider to the user account using a pop-up based
* OAuth flow.
*
* If the linking is successful, the returned result will contain the user
* and the provider's credential.
*
* <h4>Error Codes</h4>
* <dl>
* <dt>auth/auth-domain-config-required</dt>
* <dd>Thrown if authDomain configuration is not provided when calling
* firebase.initializeApp(). Check Firebase Console for instructions on
* determining and passing that field.</dd>
* <dt>auth/cancelled-popup-request</dt>
* <dd>Thrown if successive popup operations are triggered. Only one popup
* request is allowed at one time on a user or an auth instance. All the
* popups would fail with this error except for the last one.</dd>
* <dt>auth/credential-already-in-use</dt>
* <dd>Thrown if the account corresponding to the credential already exists
* among your users, or is already linked to a Firebase User.
* For example, this error could be thrown if you are upgrading an anonymous
* user to a Google user by linking a Google credential to it and the Google
* credential used is already associated with an existing Firebase Google
* user.
* An <code>error.email</code> and <code>error.credential</code>
* ({@link firebase.auth.AuthCredential}) fields are also provided. You can
* recover from this error by signing in with that credential directly via
* {@link firebase.auth.Auth.signInWithCredential}.</dd>
* <dt>auth/email-already-in-use</dt>
* <dd>Thrown if the email corresponding to the credential already exists
* among your users. When thrown while linking a credential to an existing
* user, an <code>error.email</code> and <code>error.credential</code>
* ({@link firebase.auth.AuthCredential}) fields are also provided.
* You have to link the credential to the existing user with that email if
* you wish to continue signing in with that credential. To do so, call
* {@link firebase.auth.Auth.fetchSignInMethodsForEmail}, sign in to
* <code>error.email</code> via one of the providers returned and then
* {@link firebase.User.linkWithCredential} the original credential to that
* newly signed in user.</dd>
* <dt>auth/operation-not-allowed</dt>
* <dd>Thrown if you have not enabled the provider in the Firebase Console. Go
* to the Firebase Console for your project, in the Auth section and the
* <strong>Sign in Method</strong> tab and configure the provider.</dd>
* <dt>auth/popup-blocked</dt>
* <dt>auth/operation-not-supported-in-this-environment</dt>
* <dd>Thrown if this operation is not supported in the environment your
* application is running on. "location.protocol" must be http or https.
* </dd>
* <dd>Thrown if the popup was blocked by the browser, typically when this
* operation is triggered outside of a click handler.</dd>
* <dt>auth/popup-closed-by-user</dt>
* <dd>Thrown if the popup window is closed by the user without completing the
* sign in to the provider.</dd>
* <dt>auth/provider-already-linked</dt>
* <dd>Thrown if the provider has already been linked to the user. This error is
* thrown even if this is not the same provider's account that is currently
* linked to the user.</dd>
* <dt>auth/unauthorized-domain</dt>
* <dd>Thrown if the app domain is not authorized for OAuth operations for your
* Firebase project. Edit the list of authorized domains from the Firebase
* console.</dd>
* </dl>
*
* @webonly
*
* @example
* ```javascript
* // Creates the provider object.
* var provider = new firebase.auth.FacebookAuthProvider();
* // You can add additional scopes to the provider:
* provider.addScope('email');
* provider.addScope('user_friends');
* // Link with popup:
* user.linkWithPopup(provider).then(function(result) {
* // The firebase.User instance:
* var user = result.user;
* // The Facebook firebase.auth.AuthCredential containing the Facebook
* // access token:
* var credential = result.credential;
* }, function(error) {
* // An error happened.
* });
* ```
*
* @param provider The provider to authenticate.
* The provider has to be an OAuth provider. Non-OAuth providers like {@link
* firebase.auth.EmailAuthProvider} will throw an error.
*/
linkWithPopup(
provider: firebase.auth.AuthProvider
): Promise<firebase.auth.UserCredential>;
/**
* Links the authenticated provider to the user account using a full-page
* redirect flow.
*
* <h4>Error Codes</h4>
* <dl>
* <dt>auth/auth-domain-config-required</dt>
* <dd>Thrown if authDomain configuration is not provided when calling
* firebase.initializeApp(). Check Firebase Console for instructions on
* determining and passing that field.</dd>
* <dt>auth/operation-not-supported-in-this-environment</dt>
* <dd>Thrown if this operation is not supported in the environment your
* application is running on. "location.protocol" must be http or https.
* </dd>
* <dt>auth/provider-already-linked</dt>
* <dd>Thrown if the provider has already been linked to the user. This error is
* thrown even if this is not the same provider's account that is currently
* linked to the user.</dd>
* <dt>auth/unauthorized-domain</dt>
* <dd>Thrown if the app domain is not authorized for OAuth operations for your
* Firebase project. Edit the list of authorized domains from the Firebase
* console.</dd>
* </dl>
*
* @param provider The provider to authenticate.
* The provider has to be an OAuth provider. Non-OAuth providers like {@link
* firebase.auth.EmailAuthProvider} will throw an error.
*/
linkWithRedirect(provider: firebase.auth.AuthProvider): Promise<void>;
metadata: firebase.auth.UserMetadata;
/**
* The phone number normalized based on the E.164 standard (e.g. +16505550101)
* for the current user. This is null if the user has no phone credential linked
* to the account.
*/
phoneNumber: string | null;
providerData: (firebase.UserInfo | null)[];
/**
* Re-authenticates a user using a fresh credential, and returns any available
* additional user information, such as user name. Use before operations
* such as {@link firebase.User.updatePassword} that require tokens from recent
* sign-in attempts.
*
* <h4>Error Codes</h4>
* <dl>
* <dt>auth/user-mismatch</dt>
* <dd>Thrown if the credential given does not correspond to the user.</dd>
* <dt>auth/user-not-found</dt>
* <dd>Thrown if the credential given does not correspond to any existing user.
* </dd>
* <dt>auth/invalid-credential</dt>
* <dd>Thrown if the provider's credential is not valid. This can happen if it
* has already expired when calling link, or if it used invalid token(s).
* See the Firebase documentation for your provider, and make sure you pass
* in the correct parameters to the credential method.</dd>
* <dt>auth/invalid-email</dt>
* <dd>Thrown if the email used in a
* {@link firebase.auth.EmailAuthProvider.credential} is invalid.</dd>
* <dt>auth/wrong-password</dt>
* <dd>Thrown if the password used in a
* {@link firebase.auth.EmailAuthProvider.credential} is not correct or when
* the user associated with the email does not have a password.</dd>
* <dt>auth/invalid-verification-code</dt>
* <dd>Thrown if the credential is a
* {@link firebase.auth.PhoneAuthProvider.credential} and the verification
* code of the credential is not valid.</dd>
* <dt>auth/invalid-verification-id</dt>
* <dd>Thrown if the credential is a
* {@link firebase.auth.PhoneAuthProvider.credential} and the verification
* ID of the credential is not valid.</dd>
* </dl>
*
* @deprecated
* This method is deprecated. Use
* {@link firebase.User.reauthenticateWithCredential} instead.
*
* @param credential
*/
reauthenticateAndRetrieveDataWithCredential(
credential: firebase.auth.AuthCredential
): Promise<firebase.auth.UserCredential>;
/**
* Re-authenticates a user using a fresh credential. Use before operations
* such as {@link firebase.User.updatePassword} that require tokens from recent
* sign-in attempts.
*
* <h4>Error Codes</h4>
* <dl>
* <dt>auth/user-mismatch</dt>
* <dd>Thrown if the credential given does not correspond to the user.</dd>
* <dt>auth/user-not-found</dt>
* <dd>Thrown if the credential given does not correspond to any existing user.
* </dd>
* <dt>auth/invalid-credential</dt>
* <dd>Thrown if the provider's credential is not valid. This can happen if it
* has already expired when calling link, or if it used invalid token(s).
* See the Firebase documentation for your provider, and make sure you pass
* in the correct parameters to the credential method.</dd>
* <dt>auth/invalid-email</dt>
* <dd>Thrown if the email used in a
* {@link firebase.auth.EmailAuthProvider.credential} is invalid.</dd>
* <dt>auth/wrong-password</dt>
* <dd>Thrown if the password used in a
* {@link firebase.auth.EmailAuthProvider.credential} is not correct or when
* the user associated with the email does not have a password.</dd>
* <dt>auth/invalid-verification-code</dt>
* <dd>Thrown if the credential is a
* {@link firebase.auth.PhoneAuthProvider.credential} and the verification
* code of the credential is not valid.</dd>
* <dt>auth/invalid-verification-id</dt>
* <dd>Thrown if the credential is a
* {@link firebase.auth.PhoneAuthProvider.credential} and the verification
* ID of the credential is not valid.</dd>
* </dl>
*
* @param credential
*/
reauthenticateWithCredential(
credential: firebase.auth.AuthCredential
): Promise<firebase.auth.UserCredential>;
/**
* Re-authenticates a user using a fresh credential. Use before operations
* such as {@link firebase.User.updatePassword} that require tokens from recent
* sign-in attempts.
*
* <h4>Error Codes</h4>
* <dl>
* <dt>auth/user-mismatch</dt>
* <dd>Thrown if the credential given does not correspond to the user.</dd>
* <dt>auth/user-not-found</dt>
* <dd>Thrown if the credential given does not correspond to any existing user.
* </dd>
* <dt>auth/captcha-check-failed</dt>
* <dd>Thrown if the reCAPTCHA response token was invalid, expired, or if
* this method was called from a non-whitelisted domain.</dd>
* <dt>auth/invalid-phone-number</dt>
* <dd>Thrown if the phone number has an invalid format.</dd>
* <dt>auth/missing-phone-number</dt>
* <dd>Thrown if the phone number is missing.</dd>
* <dt>auth/quota-exceeded</dt>
* <dd>Thrown if the SMS quota for the Firebase project has been exceeded.</dd>
* </dl>
*
* @param phoneNumber The user's phone number in E.164 format (e.g.
* +16505550101).
* @param applicationVerifier
*/
reauthenticateWithPhoneNumber(
phoneNumber: string,
applicationVerifier: firebase.auth.ApplicationVerifier
): Promise<firebase.auth.ConfirmationResult>;
/**
* Reauthenticates the current user with the specified provider using a pop-up
* based OAuth flow.
*
* If the reauthentication is successful, the returned result will contain the
* user and the provider's credential.
*
* <h4>Error Codes</h4>
* <dl>
* <dt>auth/auth-domain-config-required</dt>
* <dd>Thrown if authDomain configuration is not provided when calling
* firebase.initializeApp(). Check Firebase Console for instructions on
* determining and passing that field.</dd>
* <dt>auth/cancelled-popup-request</dt>
* <dd>Thrown if successive popup operations are triggered. Only one popup
* request is allowed at one time on a user or an auth instance. All the
* popups would fail with this error except for the last one.</dd>
* <dt>auth/user-mismatch</dt>
* <dd>Thrown if the credential given does not correspond to the user.</dd>
* <dt>auth/operation-not-allowed</dt>
* <dd>Thrown if you have not enabled the provider in the Firebase Console. Go
* to the Firebase Console for your project, in the Auth section and the
* <strong>Sign in Method</strong> tab and configure the provider.</dd>
* <dt>auth/popup-blocked</dt>
* <dd>Thrown if the popup was blocked by the browser, typically when this
* operation is triggered outside of a click handler.</dd>
* <dt>auth/operation-not-supported-in-this-environment</dt>
* <dd>Thrown if this operation is not supported in the environment your
* application is running on. "location.protocol" must be http or https.
* </dd>
* <dt>auth/popup-closed-by-user</dt>
* <dd>Thrown if the popup window is closed by the user without completing the
* sign in to the provider.</dd>
* <dt>auth/unauthorized-domain</dt>
* <dd>Thrown if the app domain is not authorized for OAuth operations for your
* Firebase project. Edit the list of authorized domains from the Firebase
* console.</dd>
* </dl>
*
* @webonly
*
* @example
* ```javascript
* // Creates the provider object.
* var provider = new firebase.auth.FacebookAuthProvider();
* // You can add additional scopes to the provider:
* provider.addScope('email');
* provider.addScope('user_friends');
* // Reauthenticate with popup:
* user.reauthenticateWithPopup(provider).then(function(result) {
* // The firebase.User instance:
* var user = result.user;
* // The Facebook firebase.auth.AuthCredential containing the Facebook
* // access token:
* var credential = result.credential;
* }, function(error) {
* // An error happened.
* });
* ```
*
* @param provider The provider to authenticate.
* The provider has to be an OAuth provider. Non-OAuth providers like {@link
* firebase.auth.EmailAuthProvider} will throw an error.
*/
reauthenticateWithPopup(
provider: firebase.auth.AuthProvider
): Promise<firebase.auth.UserCredential>;
/**
* Reauthenticates the current user with the specified OAuth provider using a
* full-page redirect flow.
*
* <h4>Error Codes</h4>
* <dl>
* <dt>auth/auth-domain-config-required</dt>
* <dd>Thrown if authDomain configuration is not provided when calling
* firebase.initializeApp(). Check Firebase Console for instructions on
* determining and passing that field.</dd>
* <dt>auth/operation-not-supported-in-this-environment</dt>
* <dd>Thrown if this operation is not supported in the environment your
* application is running on. "location.protocol" must be http or https.
* </dd>
* <dt>auth/user-mismatch</dt>
* <dd>Thrown if the credential given does not correspond to the user.</dd>
* <dt>auth/unauthorized-domain</dt>
* <dd>Thrown if the app domain is not authorized for OAuth operations for your
* Firebase project. Edit the list of authorized domains from the Firebase
* console.</dd>
* </dl>
*
* @webonly
*
* @param provider The provider to authenticate.
* The provider has to be an OAuth provider. Non-OAuth providers like {@link
* firebase.auth.EmailAuthProvider} will throw an error.
*/
reauthenticateWithRedirect(
provider: firebase.auth.AuthProvider
): Promise<void>;
refreshToken: string;
/**
* Refreshes the current user, if signed in.
*
*/
reload(): Promise<void>;
/**
* Sends a verification email to a user.
*
* The verification process is completed by calling
* {@link firebase.auth.Auth.applyActionCode}
*
* <h4>Error Codes</h4>
* <dl>
* <dt>auth/missing-android-pkg-name</dt>
* <dd>An Android package name must be provided if the Android app is required
* to be installed.</dd>
* <dt>auth/missing-continue-uri</dt>
* <dd>A continue URL must be provided in the request.</dd>
* <dt>auth/missing-ios-bundle-id</dt>
* <dd>An iOS bundle ID must be provided if an App Store ID is provided.</dd>
* <dt>auth/invalid-continue-uri</dt>
* <dd>The continue URL provided in the request is invalid.</dd>
* <dt>auth/unauthorized-continue-uri</dt>
* <dd>The domain of the continue URL is not whitelisted. Whitelist
* the domain in the Firebase console.</dd>
* </dl>
*
* @example
* ```javascript
* var actionCodeSettings = {
* url: 'https://www.example.com/[email protected]&cartId=123',
* iOS: {
* bundleId: 'com.example.ios'
* },
* android: {
* packageName: 'com.example.android',
* installApp: true,
* minimumVersion: '12'
* },
* handleCodeInApp: true
* };
* firebase.auth().currentUser.sendEmailVerification(actionCodeSettings)
* .then(function() {
* // Verification email sent.
* })
* .catch(function(error) {
* // Error occurred. Inspect error.code.
* });
* ```
*
* @param actionCodeSettings The action
* code settings. If specified, the state/continue URL will be set as the
* "continueUrl" parameter in the email verification link. The default email
* verification landing page will use this to display a link to go back to
* the app if it is installed.
* If the actionCodeSettings is not specified, no URL is appended to the
* action URL.
* The state URL provided must belong to a domain that is whitelisted by the
* developer in the console. Otherwise an error will be thrown.
* Mobile app redirects will only be applicable if the developer configures
* and accepts the Firebase Dynamic Links terms of condition.
* The Android package name and iOS bundle ID will be respected only if they
* are configured in the same Firebase Auth project used.
*/
sendEmailVerification(
actionCodeSettings?: firebase.auth.ActionCodeSettings | null
): Promise<void>;
/**
* Returns a JSON-serializable representation of this object.
*
* @return A JSON-serializable representation of this object.
*/
toJSON(): Object;
/**
* Unlinks a provider from a user account.
*
* <h4>Error Codes</h4>
* <dl>
* <dt>auth/no-such-provider</dt>
* <dd>Thrown if the user does not have this provider linked or when the
* provider ID given does not exist.</dd>
* </dt>
*
* @param providerId
*/
unlink(providerId: string): Promise<firebase.User>;
/**
* Updates the user's email address.
*
* An email will be sent to the original email address (if it was set) that
* allows to revoke the email address change, in order to protect them from
* account hijacking.
*
* <b>Important:</b> this is a security sensitive operation that requires the
* user to have recently signed in. If this requirement isn't met, ask the user
* to authenticate again and then call
* {@link firebase.User.reauthenticateWithCredential}.
*
* <h4>Error Codes</h4>
* <dl>
* <dt>auth/invalid-email</dt>
* <dd>Thrown if the email used is invalid.</dd>
* <dt>auth/email-already-in-use</dt>
* <dd>Thrown if the email is already used by another user.</dd>
* <dt>auth/requires-recent-login</dt>
* <dd>Thrown if the user's last sign-in time does not meet the security
* threshold. Use {@link firebase.User.reauthenticateWithCredential} to
* resolve. This does not apply if the user is anonymous.</dd>
* </dl>
*
* @param newEmail The new email address.
*/
updateEmail(newEmail: string): Promise<void>;
/**
* Updates the user's password.
*
* <b>Important:</b> this is a security sensitive operation that requires the
* user to have recently signed in. If this requirement isn't met, ask the user
* to authenticate again and then call
* {@link firebase.User.reauthenticateWithCredential}.
*
* <h4>Error Codes</h4>
* <dl>
* <dt>auth/weak-password</dt>
* <dd>Thrown if the password is not strong enough.</dd>
* <dt>auth/requires-recent-login</dt>
* <dd>Thrown if the user's last sign-in time does not meet the security
* threshold. Use {@link firebase.User.reauthenticateWithCredential} to
* resolve. This does not apply if the user is anonymous.</dd>
* </dl>
*
* @param newPassword
*/
updatePassword(newPassword: string): Promise<void>;
/**
* Updates the user's phone number.
*
* <h4>Error Codes</h4>
* <dl>
* <dt>auth/invalid-verification-code</dt>
* <dd>Thrown if the verification code of the credential is not valid.</dd>
* <dt>auth/invalid-verification-id</dt>
* <dd>Thrown if the verification ID of the credential is not valid.</dd>
* </dl>
*
* @param phoneCredential
*/
updatePhoneNumber(
phoneCredential: firebase.auth.AuthCredential
): Promise<void>;
/**
* Updates a user's profile data.
*
* @example
* ```javascript
* // Updates the user attributes:
* user.updateProfile({
* displayName: "Jane Q. User",
* photoURL: "https://example.com/jane-q-user/profile.jpg"
* }).then(function() {
* // Profile updated successfully!
* // "Jane Q. User"
* var displayName = user.displayName;
* // "https://example.com/jane-q-user/profile.jpg"
* var photoURL = user.photoURL;
* }, function(error) {
* // An error happened.
* });
*
* // Passing a null value will delete the current attribute's value, but not
* // passing a property won't change the current attribute's value:
* // Let's say we're using the same user than before, after the update.
* user.updateProfile({photoURL: null}).then(function() {
* // Profile updated successfully!
* // "Jane Q. User", hasn't changed.
* var displayName = user.displayName;
* // Now, this is null.
* var photoURL = user.photoURL;
* }, function(error) {
* // An error happened.
* });
* ```
*
* @param profile The profile's
* displayName and photoURL to update.
*/
updateProfile(profile: {
displayName?: string | null;
photoURL?: string | null;
}): Promise<void>;
}
/**
* User profile information, visible only to the Firebase project's
* apps.
*
*/
interface UserInfo {
displayName: string | null;
email: string | null;
phoneNumber: string | null;
photoURL: string | null;
providerId: string;
/**
* The user's unique ID.
*/
uid: string;
}
/**
* Retrieves a Firebase {@link firebase.app.App app} instance.
*
* When called with no arguments, the default app is returned. When an app name
* is provided, the app corresponding to that name is returned.
*
* An exception is thrown if the app being retrieved has not yet been
* initialized.
*
* @example
* ```javascript
* // Return the default app
* var app = firebase.app();
* ```
*
* @example
* ```javascript
* // Return a named app
* var otherApp = firebase.app("otherApp");
* ```
*
* @param name Optional name of the app to return. If no name is
* provided, the default is `"[DEFAULT]"`.
*
* @return The app corresponding to the provided app name.
* If no app name is provided, the default app is returned.
*/
function app(name?: string): firebase.app.App;
/**
* A (read-only) array of all initialized apps.
*/
var apps: firebase.app.App[];
/**
* Gets the {@link firebase.auth.Auth `Auth`} service for the default app or a
* given app.
*
* `firebase.auth()` can be called with no arguments to access the default app's
* {@link firebase.auth.Auth `Auth`} service or as `firebase.auth(app)` to
* access the {@link firebase.auth.Auth `Auth`} service associated with a
* specific app.
*
* @example
* ```javascript
*
* // Get the Auth service for the default app
* var defaultAuth = firebase.auth();
* ```
* @example
* ```javascript
*
* // Get the Auth service for a given app
* var otherAuth = firebase.auth(otherApp);
* ```
* @param app
*/
function auth(app?: firebase.app.App): firebase.auth.Auth;
/**
* Gets the {@link firebase.database.Database `Database`} service for the
* default app or a given app.
*
* `firebase.database()` can be called with no arguments to access the default
* app's {@link firebase.database.Database `Database`} service or as
* `firebase.database(app)` to access the
* {@link firebase.database.Database `Database`} service associated with a
* specific app.
*
* `firebase.database` is also a namespace that can be used to access global
* constants and methods associated with the `Database` service.
*
* @example
* ```javascript
* // Get the Database service for the default app
* var defaultDatabase = firebase.database();
* ```
*
* @example
* ```javascript
* // Get the Database service for a specific app
* var otherDatabase = firebase.database(app);
* ```
*
* @namespace
* @param app Optional app whose Database service to
* return. If not provided, the default Database service will be returned.
* @return The default Database service if no app
* is provided or the Database service associated with the provided app.
*/
function database(app?: firebase.app.App): firebase.database.Database;
/**
* Creates and initializes a Firebase {@link firebase.app.App app} instance.
*
* See
* {@link
* https://firebase.google.com/docs/web/setup#add_firebase_to_your_app
* Add Firebase to your app} and
* {@link
* https://firebase.google.com/docs/web/setup#multiple-projects
* Initialize multiple projects} for detailed documentation.
*
* @example
* ```javascript
*
* // Initialize default app
* // Retrieve your own options values by adding a web app on
* // https://console.firebase.google.com
* firebase.initializeApp({
* apiKey: "AIza....", // Auth / General Use
* authDomain: "YOUR_APP.firebaseapp.com", // Auth with popup/redirect
* databaseURL: "https://YOUR_APP.firebaseio.com", // Realtime Database
* storageBucket: "YOUR_APP.appspot.com", // Storage
* messagingSenderId: "123456789" // Cloud Messaging
* });
* ```
*
* @example
* ```javascript
*
* // Initialize another app
* var otherApp = firebase.initializeApp({
* databaseURL: "https://<OTHER_DATABASE_NAME>.firebaseio.com",
* storageBucket: "<OTHER_STORAGE_BUCKET>.appspot.com"
* }, "otherApp");
* ```
*
* @param options Options to configure the app's services.
* @param name Optional name of the app to initialize. If no name
* is provided, the default is `"[DEFAULT]"`.
*
* @return {!firebase.app.App} The initialized app.
*/
function initializeApp(options: Object, name?: string): firebase.app.App;
/**
* Gets the {@link firebase.messaging.Messaging `Messaging`} service for the
* default app or a given app.
*
* `firebase.messaging()` can be called with no arguments to access the default
* app's {@link firebase.messaging.Messaging `Messaging`} service or as
* `firebase.messaging(app)` to access the
* {@link firebase.messaging.Messaging `Messaging`} service associated with a
* specific app.
*
* Calling `firebase.messaging()` in a service worker results in Firebase
* generating notifications if the push message payload has a `notification`
* parameter.