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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
5604
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
5670
5671
5672
5673
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
5688
5689
5690
5691
5692
5693
5694
5695
5696
5697
5698
5699
5700
5701
5702
5703
5704
5705
5706
5707
5708
5709
5710
5711
5712
5713
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723
5724
5725
5726
5727
5728
5729
5730
5731
5732
5733
5734
5735
5736
5737
5738
5739
5740
5741
5742
5743
5744
5745
5746
5747
5748
5749
5750
5751
5752
5753
5754
5755
5756
5757
5758
5759
5760
5761
5762
5763
5764
5765
5766
5767
5768
5769
5770
5771
5772
5773
5774
5775
5776
5777
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
5796
5797
5798
5799
5800
5801
5802
5803
5804
5805
5806
5807
5808
5809
5810
5811
5812
5813
5814
5815
5816
5817
5818
5819
5820
5821
5822
5823
5824
5825
5826
5827
5828
5829
5830
5831
5832
5833
5834
5835
5836
5837
5838
5839
5840
5841
5842
5843
5844
5845
5846
5847
5848
5849
5850
5851
5852
5853
5854
5855
5856
5857
5858
5859
5860
5861
5862
5863
5864
5865
5866
5867
5868
5869
5870
5871
5872
5873
5874
5875
5876
5877
5878
5879
5880
5881
5882
5883
5884
5885
5886
5887
5888
5889
5890
5891
5892
5893
5894
5895
5896
5897
5898
5899
5900
5901
5902
5903
5904
5905
5906
5907
5908
5909
5910
5911
5912
5913
5914
5915
5916
5917
5918
5919
5920
5921
5922
5923
5924
5925
5926
5927
5928
5929
5930
5931
5932
5933
5934
5935
5936
5937
5938
5939
5940
5941
5942
5943
5944
5945
5946
5947
5948
5949
5950
5951
5952
5953
5954
5955
5956
5957
5958
5959
5960
5961
5962
5963
5964
5965
5966
5967
5968
5969
5970
5971
5972
5973
5974
5975
5976
5977
5978
5979
5980
5981
5982
5983
5984
5985
5986
5987
5988
5989
5990
5991
5992
5993
5994
5995
5996
5997
5998
5999
6000
6001
6002
6003
6004
6005
6006
6007
6008
6009
6010
6011
6012
6013
6014
6015
6016
6017
6018
6019
6020
6021
6022
6023
6024
6025
6026
6027
6028
6029
6030
6031
6032
6033
6034
6035
6036
6037
6038
6039
6040
6041
6042
6043
6044
6045
6046
6047
6048
6049
6050
6051
6052
6053
6054
6055
6056
6057
6058
6059
6060
6061
6062
6063
6064
6065
6066
6067
6068
6069
6070
6071
6072
6073
6074
6075
6076
6077
6078
6079
6080
6081
6082
6083
6084
6085
6086
6087
6088
6089
6090
6091
6092
6093
6094
6095
6096
6097
6098
6099
6100
6101
6102
6103
6104
6105
6106
6107
6108
6109
6110
6111
6112
6113
6114
6115
6116
6117
6118
6119
6120
6121
6122
6123
6124
6125
6126
6127
6128
6129
6130
6131
6132
6133
6134
6135
6136
6137
6138
6139
6140
6141
6142
6143
6144
6145
6146
6147
6148
6149
6150
6151
6152
6153
6154
6155
6156
6157
6158
6159
6160
6161
6162
6163
6164
6165
6166
6167
6168
6169
6170
6171
6172
6173
6174
6175
6176
6177
6178
6179
6180
6181
6182
6183
6184
6185
6186
6187
6188
6189
6190
6191
6192
6193
6194
6195
6196
6197
6198
6199
6200
6201
6202
6203
6204
6205
6206
6207
6208
6209
6210
6211
6212
6213
6214
6215
6216
6217
6218
6219
6220
6221
6222
6223
6224
6225
6226
6227
6228
6229
6230
6231
6232
6233
6234
6235
6236
6237
6238
6239
6240
6241
6242
6243
6244
6245
6246
6247
6248
6249
6250
6251
6252
6253
6254
6255
6256
6257
6258
6259
6260
6261
6262
6263
6264
6265
6266
6267
6268
6269
6270
6271
6272
6273
6274
6275
6276
6277
6278
6279
6280
6281
6282
6283
6284
6285
6286
6287
6288
6289
6290
6291
6292
6293
6294
6295
6296
6297
6298
6299
6300
6301
6302
6303
6304
6305
6306
6307
6308
6309
6310
6311
6312
6313
6314
6315
6316
6317
6318
6319
6320
6321
6322
6323
6324
6325
6326
6327
6328
6329
6330
6331
6332
6333
6334
6335
6336
6337
6338
6339
6340
6341
6342
6343
6344
6345
6346
6347
6348
6349
6350
6351
6352
6353
6354
6355
6356
6357
6358
6359
6360
6361
6362
6363
6364
6365
6366
6367
6368
6369
6370
6371
6372
6373
6374
6375
6376
6377
6378
6379
6380
6381
6382
6383
6384
6385
6386
6387
6388
6389
6390
6391
6392
6393
6394
6395
6396
6397
6398
6399
6400
6401
6402
6403
6404
6405
6406
6407
6408
6409
6410
6411
6412
6413
6414
6415
6416
6417
6418
6419
6420
6421
6422
6423
6424
6425
6426
6427
6428
6429
6430
6431
6432
6433
6434
6435
6436
6437
6438
6439
6440
6441
6442
6443
6444
6445
6446
6447
6448
6449
6450
6451
6452
6453
6454
6455
6456
6457
6458
6459
6460
6461
6462
6463
6464
6465
6466
6467
6468
6469
6470
6471
6472
6473
6474
6475
6476
6477
6478
6479
6480
6481
6482
6483
6484
6485
6486
6487
6488
6489
6490
6491
6492
6493
6494
6495
6496
6497
6498
6499
6500
6501
6502
6503
6504
6505
6506
6507
6508
6509
6510
6511
6512
6513
6514
6515
6516
6517
6518
6519
6520
6521
6522
6523
6524
6525
6526
6527
6528
6529
6530
6531
6532
6533
6534
6535
6536
6537
6538
6539
6540
6541
6542
6543
6544
6545
6546
6547
6548
6549
6550
6551
6552
6553
6554
6555
6556
6557
6558
6559
6560
6561
6562
6563
6564
6565
6566
6567
6568
6569
6570
6571
6572
6573
6574
6575
6576
6577
6578
6579
6580
6581
6582
6583
6584
6585
6586
6587
6588
6589
6590
6591
6592
6593
6594
6595
6596
6597
6598
6599
6600
6601
6602
6603
6604
6605
6606
6607
6608
6609
6610
6611
6612
6613
6614
6615
6616
6617
6618
6619
6620
6621
6622
6623
6624
6625
6626
6627
6628
6629
6630
6631
6632
6633
6634
6635
6636
6637
6638
6639
6640
6641
6642
6643
6644
6645
6646
6647
6648
6649
6650
6651
6652
6653
6654
6655
6656
6657
6658
6659
6660
6661
6662
6663
6664
6665
6666
6667
6668
6669
6670
6671
6672
6673
6674
6675
6676
6677
6678
6679
6680
6681
6682
6683
6684
6685
6686
6687
6688
6689
6690
6691
6692
6693
6694
6695
6696
6697
6698
6699
6700
6701
6702
6703
6704
6705
6706
6707
6708
6709
6710
6711
6712
6713
6714
6715
6716
6717
6718
6719
6720
6721
6722
6723
6724
6725
6726
6727
6728
6729
6730
6731
6732
6733
6734
6735
6736
6737
6738
6739
6740
6741
6742
6743
6744
6745
6746
6747
6748
6749
6750
6751
6752
6753
6754
6755
6756
6757
6758
6759
6760
6761
6762
6763
6764
6765
6766
6767
6768
6769
6770
6771
6772
6773
6774
6775
6776
6777
6778
6779
6780
6781
6782
6783
6784
6785
6786
6787
6788
6789
6790
6791
6792
6793
6794
6795
6796
6797
6798
6799
6800
6801
6802
6803
6804
6805
6806
6807
6808
6809
6810
6811
6812
6813
6814
6815
6816
6817
6818
6819
6820
6821
6822
6823
6824
6825
6826
6827
6828
6829
6830
6831
6832
6833
6834
6835
6836
6837
6838
6839
6840
6841
6842
6843
6844
6845
6846
6847
6848
6849
6850
6851
6852
6853
6854
6855
6856
6857
6858
6859
6860
6861
6862
6863
6864
6865
6866
6867
6868
6869
6870
6871
6872
6873
6874
6875
6876
6877
6878
6879
6880
6881
6882
6883
6884
6885
6886
6887
6888
6889
6890
6891
6892
6893
6894
6895
6896
6897
6898
6899
6900
6901
6902
6903
6904
6905
6906
6907
6908
6909
6910
6911
6912
6913
6914
6915
6916
6917
6918
6919
6920
6921
6922
6923
6924
6925
6926
6927
6928
6929
6930
6931
6932
6933
6934
6935
6936
6937
6938
6939
6940
6941
6942
6943
6944
6945
6946
6947
6948
6949
6950
6951
6952
6953
6954
6955
6956
6957
6958
6959
6960
6961
6962
6963
6964
6965
6966
6967
6968
6969
6970
6971
6972
6973
6974
6975
6976
6977
6978
6979
6980
6981
6982
6983
6984
6985
6986
6987
6988
6989
6990
6991
6992
6993
6994
6995
6996
6997
6998
6999
7000
7001
7002
7003
7004
7005
7006
7007
7008
7009
7010
7011
7012
7013
7014
7015
7016
7017
7018
7019
7020
7021
7022
7023
7024
7025
7026
7027
7028
7029
7030
7031
7032
7033
7034
7035
7036
7037
7038
7039
7040
7041
7042
7043
7044
7045
7046
7047
7048
7049
7050
7051
7052
7053
7054
7055
7056
7057
7058
7059
7060
7061
7062
7063
7064
7065
7066
7067
7068
7069
7070
7071
7072
7073
7074
7075
7076
7077
7078
7079
7080
7081
7082
7083
7084
7085
7086
7087
7088
7089
7090
7091
7092
7093
7094
7095
7096
7097
7098
7099
7100
7101
7102
7103
7104
7105
7106
7107
7108
7109
7110
7111
7112
7113
7114
7115
7116
7117
7118
7119
7120
7121
7122
7123
7124
7125
7126
7127
7128
7129
7130
7131
7132
7133
7134
7135
7136
7137
7138
7139
7140
7141
7142
7143
7144
7145
7146
7147
7148
7149
7150
7151
7152
7153
7154
7155
7156
7157
7158
7159
7160
7161
7162
7163
7164
7165
7166
7167
7168
7169
7170
7171
7172
7173
7174
7175
7176
7177
7178
7179
7180
7181
7182
7183
7184
7185
7186
7187
7188
7189
7190
7191
7192
7193
7194
7195
7196
7197
7198
7199
7200
7201
7202
7203
7204
7205
7206
7207
7208
7209
7210
7211
7212
7213
7214
7215
7216
7217
7218
7219
7220
7221
7222
7223
7224
7225
7226
7227
7228
7229
7230
7231
7232
7233
7234
7235
7236
7237
7238
7239
7240
7241
7242
7243
7244
7245
7246
7247
7248
7249
7250
7251
7252
7253
7254
7255
7256
7257
7258
7259
7260
7261
7262
7263
7264
7265
7266
7267
7268
7269
7270
7271
7272
7273
7274
7275
7276
7277
7278
7279
7280
7281
7282
7283
7284
7285
7286
7287
7288
7289
7290
7291
7292
7293
7294
7295
7296
7297
7298
7299
7300
7301
7302
7303
7304
7305
7306
7307
7308
7309
7310
7311
7312
7313
7314
7315
7316
7317
7318
7319
7320
7321
7322
7323
7324
7325
7326
7327
7328
7329
7330
7331
7332
7333
7334
7335
7336
7337
7338
7339
7340
7341
7342
7343
7344
7345
7346
7347
7348
7349
7350
7351
7352
7353
7354
7355
7356
7357
7358
7359
7360
7361
7362
7363
7364
7365
7366
7367
7368
7369
7370
7371
7372
7373
7374
7375
7376
7377
7378
7379
7380
7381
7382
7383
7384
7385
7386
7387
7388
7389
7390
7391
7392
7393
7394
7395
7396
7397
7398
7399
7400
7401
7402
7403
7404
7405
7406
7407
7408
7409
7410
7411
7412
7413
7414
7415
7416
7417
7418
7419
7420
7421
7422
7423
7424
7425
7426
7427
7428
7429
7430
7431
7432
7433
7434
7435
7436
7437
7438
7439
7440
7441
7442
7443
7444
7445
7446
7447
7448
7449
7450
7451
7452
7453
7454
7455
7456
7457
7458
7459
7460
7461
7462
7463
7464
7465
7466
7467
7468
7469
7470
7471
7472
7473
7474
7475
7476
7477
7478
7479
7480
7481
7482
7483
7484
7485
7486
7487
7488
7489
7490
7491
7492
7493
7494
7495
7496
7497
7498
7499
7500
7501
7502
7503
7504
7505
7506
7507
7508
7509
7510
7511
7512
7513
7514
7515
7516
7517
7518
7519
7520
7521
7522
7523
7524
7525
7526
7527
7528
7529
7530
7531
7532
7533
7534
7535
7536
7537
7538
7539
7540
7541
7542
7543
7544
7545
7546
7547
7548
7549
7550
7551
7552
7553
7554
7555
7556
7557
7558
7559
7560
7561
7562
7563
7564
7565
7566
7567
7568
7569
7570
7571
7572
7573
7574
7575
7576
7577
7578
7579
7580
7581
7582
7583
7584
7585
7586
7587
7588
7589
7590
7591
7592
7593
7594
7595
7596
7597
7598
7599
7600
7601
7602
7603
7604
7605
7606
7607
7608
7609
7610
7611
7612
7613
7614
7615
7616
7617
7618
7619
7620
7621
7622
7623
7624
7625
7626
7627
7628
7629
7630
7631
7632
7633
7634
7635
7636
7637
7638
7639
7640
7641
7642
7643
7644
7645
7646
7647
7648
7649
7650
7651
7652
7653
7654
7655
7656
7657
7658
7659
7660
7661
7662
7663
7664
7665
7666
7667
7668
7669
7670
7671
7672
7673
7674
7675
7676
7677
7678
7679
7680
7681
7682
7683
7684
7685
7686
7687
7688
7689
7690
7691
7692
7693
7694
7695
7696
7697
7698
7699
7700
7701
7702
7703
7704
7705
7706
7707
7708
7709
7710
7711
7712
7713
7714
7715
7716
7717
7718
7719
7720
7721
7722
7723
7724
7725
7726
7727
7728
7729
7730
7731
7732
7733
7734
7735
7736
7737
7738
7739
7740
7741
7742
7743
7744
7745
7746
7747
7748
7749
7750
7751
7752
7753
7754
7755
7756
7757
7758
7759
7760
7761
7762
7763
7764
7765
7766
7767
7768
7769
7770
7771
7772
7773
7774
7775
7776
7777
7778
7779
7780
7781
7782
7783
7784
7785
7786
7787
7788
7789
7790
7791
7792
7793
7794
7795
7796
7797
7798
7799
7800
7801
7802
7803
7804
7805
7806
7807
7808
7809
7810
7811
7812
7813
7814
7815
7816
7817
7818
7819
7820
7821
7822
7823
7824
7825
7826
7827
7828
7829
7830
7831
7832
7833
7834
7835
7836
7837
7838
7839
7840
7841
7842
7843
7844
7845
7846
7847
7848
7849
7850
7851
7852
7853
7854
7855
7856
7857
7858
7859
7860
7861
7862
7863
7864
7865
7866
7867
7868
7869
7870
7871
7872
7873
7874
7875
7876
7877
7878
7879
7880
7881
7882
7883
7884
7885
7886
7887
7888
7889
7890
7891
7892
7893
7894
7895
7896
7897
7898
7899
7900
7901
7902
7903
7904
7905
7906
7907
7908
7909
7910
7911
7912
7913
7914
7915
7916
7917
7918
7919
7920
7921
7922
7923
7924
7925
7926
7927
7928
7929
7930
7931
7932
7933
7934
7935
7936
7937
7938
7939
7940
7941
7942
7943
7944
7945
7946
7947
7948
7949
7950
7951
7952
7953
7954
7955
7956
7957
7958
7959
7960
7961
7962
7963
7964
7965
7966
7967
7968
7969
7970
7971
7972
7973
7974
7975
7976
7977
7978
7979
7980
7981
7982
7983
7984
7985
7986
7987
7988
7989
7990
7991
7992
7993
7994
7995
7996
7997
7998
7999
8000
8001
8002
8003
8004
8005
8006
8007
8008
8009
8010
8011
8012
8013
8014
8015
8016
8017
8018
8019
8020
8021
8022
8023
8024
8025
8026
8027
8028
8029
8030
8031
8032
8033
8034
8035
8036
8037
8038
8039
8040
8041
8042
8043
8044
8045
8046
8047
8048
8049
8050
8051
8052
8053
8054
8055
8056
8057
8058
8059
8060
8061
8062
8063
8064
8065
8066
8067
8068
8069
8070
8071
8072
8073
8074
8075
8076
8077
8078
8079
8080
8081
8082
8083
8084
8085
8086
8087
8088
8089
8090
8091
8092
8093
8094
8095
8096
8097
8098
8099
8100
8101
8102
8103
8104
8105
8106
8107
8108
8109
8110
8111
8112
8113
8114
8115
8116
8117
8118
8119
8120
8121
8122
8123
8124
8125
8126
8127
8128
8129
8130
8131
8132
8133
8134
8135
8136
8137
8138
8139
8140
8141
8142
8143
8144
8145
8146
8147
8148
8149
8150
8151
8152
8153
8154
8155
8156
8157
8158
8159
8160
8161
8162
8163
8164
8165
8166
8167
8168
8169
8170
8171
8172
8173
8174
8175
8176
8177
8178
8179
8180
8181
8182
8183
8184
8185
8186
8187
8188
8189
8190
8191
8192
8193
8194
8195
8196
8197
8198
8199
8200
8201
8202
8203
8204
8205
8206
8207
8208
8209
8210
8211
8212
8213
8214
8215
8216
8217
8218
8219
8220
8221
8222
8223
8224
8225
8226
8227
8228
8229
8230
8231
8232
8233
8234
8235
8236
8237
8238
8239
8240
8241
8242
8243
8244
8245
8246
8247
8248
8249
8250
8251
8252
8253
8254
8255
8256
8257
8258
8259
8260
8261
8262
8263
8264
8265
8266
8267
8268
8269
8270
8271
8272
8273
8274
8275
8276
8277
8278
8279
8280
8281
8282
8283
8284
8285
8286
8287
8288
8289
8290
8291
8292
8293
8294
8295
8296
8297
8298
8299
8300
8301
8302
8303
8304
8305
8306
8307
8308
8309
8310
8311
8312
8313
8314
8315
8316
8317
8318
8319
8320
8321
8322
8323
8324
8325
8326
8327
8328
8329
8330
8331
8332
8333
8334
8335
8336
8337
8338
8339
8340
8341
8342
8343
8344
8345
8346
8347
8348
8349
8350
8351
8352
8353
8354
8355
8356
8357
8358
8359
8360
8361
8362
8363
8364
8365
8366
8367
8368
8369
8370
8371
8372
8373
8374
8375
8376
8377
8378
8379
8380
8381
8382
8383
8384
8385
8386
8387
8388
8389
8390
8391
8392
8393
8394
8395
8396
8397
8398
8399
8400
8401
8402
8403
8404
8405
8406
8407
8408
8409
8410
8411
8412
8413
8414
8415
8416
8417
8418
8419
8420
8421
8422
8423
8424
8425
8426
8427
8428
8429
8430
8431
8432
8433
8434
8435
8436
8437
8438
8439
8440
8441
8442
8443
8444
8445
8446
8447
8448
8449
8450
8451
8452
8453
8454
8455
8456
8457
8458
8459
8460
8461
8462
8463
8464
8465
8466
8467
8468
8469
8470
8471
8472
8473
8474
8475
8476
8477
8478
8479
8480
8481
8482
8483
8484
8485
8486
8487
8488
8489
8490
8491
8492
8493
8494
8495
8496
8497
8498
8499
8500
8501
8502
8503
8504
8505
8506
8507
8508
8509
8510
8511
8512
8513
8514
8515
8516
8517
8518
8519
8520
8521
8522
8523
8524
8525
8526
8527
8528
8529
8530
8531
8532
8533
8534
8535
8536
8537
8538
8539
8540
8541
8542
8543
8544
8545
8546
8547
8548
8549
8550
8551
8552
8553
8554
8555
8556
8557
8558
8559
8560
8561
8562
8563
8564
8565
8566
8567
8568
8569
8570
8571
8572
8573
8574
8575
8576
8577
8578
8579
8580
8581
8582
8583
8584
8585
8586
8587
8588
8589
8590
8591
8592
8593
8594
8595
8596
8597
8598
8599
8600
8601
8602
8603
8604
8605
8606
8607
8608
8609
8610
8611
8612
8613
8614
8615
8616
8617
8618
8619
8620
8621
8622
8623
8624
8625
8626
8627
8628
8629
8630
8631
8632
8633
8634
8635
8636
8637
8638
8639
8640
8641
8642
8643
8644
8645
8646
8647
8648
8649
8650
8651
8652
8653
8654
8655
8656
8657
8658
8659
8660
8661
8662
8663
8664
8665
8666
8667
8668
8669
8670
8671
8672
8673
8674
8675
8676
8677
8678
8679
8680
8681
8682
8683
8684
8685
8686
8687
8688
8689
8690
8691
8692
8693
8694
8695
8696
8697
8698
8699
8700
8701
8702
8703
8704
8705
8706
8707
8708
8709
8710
8711
8712
8713
8714
8715
8716
8717
8718
8719
8720
8721
8722
8723
8724
8725
8726
8727
8728
8729
8730
8731
8732
8733
8734
8735
8736
8737
8738
8739
8740
8741
8742
8743
8744
8745
8746
8747
8748
8749
8750
8751
8752
8753
8754
8755
8756
8757
8758
8759
8760
8761
8762
8763
8764
8765
8766
8767
8768
8769
8770
8771
8772
8773
8774
8775
8776
8777
8778
8779
8780
8781
8782
8783
8784
8785
8786
8787
8788
8789
8790
8791
8792
8793
8794
8795
8796
8797
8798
8799
8800
8801
8802
8803
8804
8805
8806
8807
8808
8809
8810
8811
8812
8813
8814
8815
8816
8817
8818
8819
8820
8821
8822
8823
8824
8825
8826
8827
8828
8829
8830
8831
8832
8833
8834
8835
8836
8837
8838
8839
8840
8841
8842
8843
8844
8845
8846
8847
8848
8849
8850
8851
8852
8853
8854
8855
8856
8857
8858
8859
8860
8861
8862
8863
8864
8865
8866
8867
8868
8869
8870
8871
8872
8873
8874
8875
8876
8877
8878
8879
8880
8881
8882
8883
8884
8885
8886
8887
8888
8889
8890
8891
8892
8893
8894
8895
8896
8897
8898
8899
8900
8901
8902
8903
8904
8905
8906
8907
8908
8909
8910
8911
8912
8913
8914
8915
8916
8917
8918
8919
8920
8921
8922
8923
8924
8925
8926
8927
8928
8929
8930
8931
8932
8933
8934
8935
8936
8937
8938
8939
8940
8941
8942
8943
8944
8945
8946
8947
8948
8949
8950
8951
8952
8953
8954
8955
8956
8957
8958
8959
8960
8961
8962
8963
8964
8965
8966
8967
8968
8969
8970
8971
8972
8973
8974
8975
8976
8977
8978
8979
8980
8981
8982
8983
8984
8985
8986
8987
8988
8989
8990
8991
8992
8993
8994
8995
8996
8997
8998
8999
9000
9001
9002
9003
9004
9005
9006
9007
9008
9009
9010
9011
9012
9013
9014
9015
9016
9017
9018
9019
9020
9021
9022
9023
9024
9025
9026
9027
9028
9029
9030
9031
9032
9033
9034
9035
9036
9037
9038
9039
9040
9041
9042
9043
9044
9045
9046
9047
9048
9049
9050
9051
9052
9053
9054
9055
9056
9057
9058
9059
9060
9061
9062
9063
9064
9065
9066
9067
9068
9069
9070
9071
9072
9073
9074
9075
9076
9077
9078
9079
9080
9081
9082
9083
9084
9085
9086
9087
9088
9089
9090
9091
9092
9093
9094
9095
9096
9097
9098
9099
9100
9101
9102
9103
9104
9105
9106
9107
9108
9109
9110
9111
9112
9113
9114
9115
9116
9117
9118
9119
9120
9121
9122
9123
9124
9125
9126
9127
9128
9129
9130
9131
9132
9133
9134
9135
9136
9137
9138
9139
9140
9141
9142
9143
9144
9145
9146
9147
9148
9149
9150
9151
9152
9153
9154
9155
9156
9157
9158
9159
9160
9161
9162
9163
9164
9165
9166
9167
9168
9169
9170
9171
9172
9173
9174
9175
9176
9177
9178
9179
9180
9181
9182
9183
9184
9185
9186
9187
9188
9189
9190
9191
9192
9193
9194
9195
9196
9197
9198
9199
9200
9201
9202
9203
9204
9205
9206
9207
9208
9209
9210
9211
9212
9213
9214
9215
9216
9217
9218
9219
9220
9221
9222
9223
9224
9225
9226
9227
9228
9229
9230
9231
9232
9233
9234
9235
9236
9237
9238
9239
9240
9241
9242
9243
9244
9245
9246
9247
9248
9249
9250
9251
9252
9253
9254
9255
9256
9257
9258
9259
9260
9261
9262
9263
9264
9265
9266
9267
9268
9269
9270
9271
9272
9273
9274
9275
9276
9277
9278
9279
9280
9281
9282
9283
9284
9285
9286
9287
9288
9289
9290
9291
9292
9293
9294
9295
9296
9297
9298
9299
9300
9301
9302
9303
9304
9305
9306
9307
9308
9309
9310
9311
9312
9313
9314
9315
9316
9317
9318
9319
9320
9321
9322
9323
9324
9325
9326
9327
9328
9329
9330
9331
9332
9333
9334
9335
9336
9337
9338
9339
9340
9341
9342
9343
9344
9345
9346
9347
9348
9349
9350
9351
9352
9353
9354
9355
9356
9357
9358
9359
9360
9361
9362
9363
9364
9365
9366
9367
9368
9369
9370
9371
9372
9373
9374
9375
9376
9377
9378
9379
9380
9381
9382
9383
9384
9385
9386
9387
9388
9389
9390
9391
9392
9393
9394
9395
9396
9397
9398
9399
9400
9401
9402
9403
9404
9405
9406
9407
9408
9409
9410
9411
9412
9413
9414
9415
9416
9417
9418
9419
9420
9421
9422
9423
9424
9425
9426
9427
9428
9429
9430
9431
9432
9433
9434
9435
9436
9437
9438
9439
9440
9441
9442
9443
9444
9445
9446
9447
9448
9449
9450
9451
9452
9453
9454
9455
9456
9457
9458
9459
9460
9461
9462
9463
9464
9465
9466
9467
9468
9469
9470
9471
9472
9473
9474
9475
9476
9477
9478
9479
9480
9481
9482
9483
9484
9485
9486
9487
9488
9489
9490
9491
9492
9493
9494
9495
9496
9497
9498
9499
9500
9501
9502
9503
9504
9505
9506
9507
9508
9509
9510
9511
9512
9513
9514
9515
9516
9517
9518
9519
9520
9521
9522
9523
9524
9525
9526
9527
9528
9529
9530
9531
9532
9533
9534
9535
9536
9537
9538
9539
9540
9541
9542
9543
9544
9545
9546
9547
9548
9549
9550
9551
9552
9553
9554
9555
9556
9557
9558
9559
9560
9561
9562
9563
9564
9565
9566
9567
9568
9569
9570
9571
9572
9573
9574
9575
9576
9577
9578
9579
9580
9581
9582
9583
9584
9585
9586
9587
9588
9589
9590
9591
9592
9593
9594
9595
9596
9597
9598
9599
9600
9601
9602
9603
9604
9605
9606
9607
9608
9609
9610
9611
9612
9613
9614
9615
9616
9617
9618
9619
9620
9621
9622
9623
9624
9625
9626
9627
9628
9629
9630
9631
9632
9633
9634
9635
9636
9637
9638
9639
9640
9641
9642
9643
9644
9645
9646
9647
9648
9649
9650
9651
9652
9653
9654
9655
9656
9657
9658
9659
9660
9661
9662
9663
9664
9665
9666
9667
9668
9669
9670
9671
9672
9673
9674
9675
9676
9677
9678
9679
9680
9681
9682
9683
9684
9685
9686
9687
9688
9689
9690
9691
9692
9693
9694
9695
9696
9697
9698
9699
9700
9701
9702
9703
9704
9705
9706
9707
9708
9709
9710
9711
9712
9713
9714
9715
9716
9717
9718
9719
9720
9721
9722
9723
9724
9725
9726
9727
9728
9729
9730
9731
9732
9733
9734
9735
9736
9737
9738
9739
9740
9741
9742
9743
9744
9745
9746
9747
9748
9749
9750
9751
9752
9753
9754
9755
9756
9757
9758
9759
9760
9761
9762
9763
9764
9765
9766
9767
9768
9769
9770
9771
9772
9773
9774
9775
9776
9777
9778
9779
9780
9781
9782
9783
9784
9785
9786
9787
9788
9789
9790
9791
9792
9793
9794
9795
9796
9797
9798
9799
9800
9801
9802
9803
9804
9805
9806
9807
9808
9809
9810
9811
9812
9813
9814
9815
9816
9817
9818
9819
9820
9821
9822
9823
9824
9825
9826
9827
9828
9829
9830
9831
9832
9833
9834
9835
9836
9837
9838
9839
9840
9841
9842
9843
9844
9845
9846
9847
9848
9849
9850
9851
9852
9853
9854
9855
9856
9857
9858
9859
9860
9861
9862
9863
9864
9865
9866
9867
9868
9869
9870
9871
9872
9873
9874
9875
9876
9877
9878
9879
9880
9881
9882
9883
9884
9885
9886
9887
9888
9889
9890
9891
9892
9893
9894
9895
9896
9897
9898
9899
9900
9901
9902
9903
9904
9905
9906
9907
9908
9909
9910
9911
9912
9913
9914
9915
9916
9917
9918
9919
9920
9921
9922
9923
9924
9925
9926
9927
9928
9929
9930
9931
9932
9933
9934
9935
9936
9937
9938
9939
9940
9941
9942
9943
9944
9945
9946
9947
9948
9949
9950
9951
9952
9953
9954
9955
9956
9957
9958
9959
9960
9961
9962
9963
9964
9965
9966
9967
9968
9969
9970
9971
9972
9973
9974
9975
9976
9977
9978
9979
9980
9981
9982
9983
9984
9985
9986
9987
9988
9989
9990
9991
9992
9993
9994
9995
9996
9997
9998
9999
10000
10001
10002
10003
10004
10005
10006
10007
10008
10009
10010
10011
10012
10013
10014
10015
10016
10017
10018
10019
10020
10021
10022
10023
10024
10025
10026
10027
10028
10029
10030
10031
10032
10033
10034
10035
10036
10037
10038
10039
10040
10041
10042
10043
10044
10045
10046
10047
10048
10049
10050
10051
10052
10053
10054
10055
10056
10057
10058
10059
10060
10061
10062
10063
10064
10065
10066
10067
10068
10069
10070
10071
10072
10073
10074
10075
10076
10077
10078
10079
10080
10081
10082
10083
10084
10085
10086
10087
10088
10089
10090
10091
10092
10093
10094
10095
10096
10097
10098
10099
10100
10101
10102
10103
10104
10105
10106
10107
10108
10109
10110
10111
10112
10113
10114
10115
10116
10117
10118
10119
10120
10121
10122
10123
10124
10125
10126
10127
10128
10129
10130
10131
10132
10133
10134
10135
10136
10137
10138
10139
10140
10141
10142
10143
10144
10145
10146
10147
10148
10149
10150
10151
10152
10153
10154
10155
10156
10157
10158
10159
10160
10161
10162
10163
10164
10165
10166
10167
10168
10169
10170
10171
10172
10173
10174
10175
10176
10177
10178
10179
10180
10181
10182
10183
10184
10185
10186
10187
10188
10189
10190
10191
10192
10193
10194
10195
10196
10197
10198
10199
10200
10201
10202
10203
10204
10205
10206
10207
10208
10209
10210
10211
10212
10213
10214
10215
10216
10217
10218
10219
10220
10221
10222
10223
10224
10225
10226
10227
10228
10229
10230
10231
10232
10233
10234
10235
10236
10237
10238
10239
10240
10241
10242
10243
10244
10245
10246
10247
10248
10249
10250
10251
10252
10253
10254
10255
10256
10257
10258
10259
10260
10261
10262
10263
10264
10265
10266
10267
10268
10269
10270
10271
10272
10273
10274
10275
10276
10277
10278
10279
10280
10281
10282
10283
10284
10285
10286
10287
10288
10289
10290
10291
10292
10293
10294
10295
10296
10297
10298
10299
10300
10301
10302
10303
10304
10305
10306
10307
10308
10309
10310
10311
10312
10313
10314
10315
10316
|
/**
* @license
* Copyright 2021 Google LLC
*
* 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: 'FirebaseError';
/**
* 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 JS SDK supports 5 log levels and also allows a user the ability to
* silence the logs altogether.
*
* The order is as follows:
* silent < debug < verbose < info < warn < error
*/
type LogLevel = 'debug' | 'verbose' | 'info' | 'warn' | 'error' | 'silent';
/**
* The current SDK version.
*/
var SDK_VERSION: string;
/**
* Registers a library's name and version for platform logging purposes.
* @param library Name of 1p or 3p library (e.g. firestore, angularfire)
* @param version Current version of that library.
* @param variant Bundle variant, e.g., node, rn, etc.
*/
function registerVersion(
library: string,
version: string,
variant?: string
): void;
/**
* Sets log level for all Firebase packages.
*
* All of the log types above the current log level are captured (i.e. if
* you set the log level to `info`, errors are logged, but `debug` and
* `verbose` logs are not).
*/
function setLogLevel(logLevel: LogLevel): void;
/**
* Sets log handler for all Firebase packages.
* @param logCallback An optional custom log handler that executes user code whenever
* the Firebase SDK makes a logging call.
*/
function onLog(
logCallback: (callbackParams: {
/**
* Level of event logged.
*/
level: LogLevel;
/**
* Any text from logged arguments joined into one string.
*/
message: string;
/**
* The raw arguments passed to the log call.
*/
args: any[];
/**
* A string indicating the name of the package that made the log call,
* such as `@firebase/firestore`.
*/
type: string;
}) => void,
options?: {
/**
* Threshhold log level. Only logs at or above this level trigger the `logCallback`
* passed to `onLog`.
*/
level: LogLevel;
}
): void;
/**
* @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>
*
* This method does not work in a Node.js environment.
*
* @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 {@link firebase.User.MultiFactorUser} object corresponding to the current user.
* This is used to access all multi-factor properties and operations related to the
* current user.
*/
multiFactor: firebase.User.MultiFactorUser;
/**
* 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>
*
* This method does not work in a Node.js environment.
*
* @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>
*
* This method does not work in a Node.js environment.
*
* @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/cart?email=user@example.com&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>;
/**
* The current user's tenant ID. This is a read-only property, which indicates
* the tenant ID used to sign in the current user. This is null if the user is
* signed in from the parent project.
*
* @example
* ```javascript
* // Set the tenant ID on Auth instance.
* firebase.auth().tenantId = ‘TENANT_PROJECT_ID’;
*
* // All future sign-in request now include tenant ID.
* firebase.auth().signInWithEmailAndPassword(email, password)
* .then(function(result) {
* // result.user.tenantId should be ‘TENANT_PROJECT_ID’.
* }).catch(function(error) {
* // Handle error.
* });
* ```
*/
tenantId: string | null;
/**
* 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>;
/**
* Sends a verification email to a new email address. The user's email will be
* updated to the new one after being verified.
*
* If you have a custom email action handler, you can complete the verification
* process 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/cart?email=user@example.com&cartId=123',
* iOS: {
* bundleId: 'com.example.ios'
* },
* android: {
* packageName: 'com.example.android',
* installApp: true,
* minimumVersion: '12'
* },
* handleCodeInApp: true
* };
* firebase.auth().currentUser.verifyBeforeUpdateEmail(
* 'user@example.com', actionCodeSettings)
* .then(function() {
* // Verification email sent.
* })
* .catch(function(error) {
* // Error occurred. Inspect error.code.
* });
* ```
*
* @param newEmail The email address to be verified and updated to.
* @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.
*/
verifyBeforeUpdateEmail(
newEmail: string,
actionCodeSettings?: firebase.auth.ActionCodeSettings | 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;
}
type FirebaseSignInProvider =
| 'custom'
| 'email'
| 'password'
| 'phone'
| 'anonymous'
| 'google.com'
| 'facebook.com'
| 'github.com'
| 'twitter.com'
| 'microsoft.com'
| 'apple.com';
interface FirebaseIdToken {
/** Always set to https://securetoken.google.com/PROJECT_ID */
iss: string;
/** Always set to PROJECT_ID */
aud: string;
/** The user's unique ID */
sub: string;
/** The token issue time, in seconds since epoch */
iat: number;
/** The token expiry time, normally 'iat' + 3600 */
exp: number;
/** The user's unique ID. Must be equal to 'sub' */
user_id: string;
/** The time the user authenticated, normally 'iat' */
auth_time: number;
/** The sign in provider, only set when the provider is 'anonymous' */
provider_id?: 'anonymous';
/** The user's primary email */
email?: string;
/** The user's email verification status */
email_verified?: boolean;
/** The user's primary phone number */
phone_number?: string;
/** The user's display name */
name?: string;
/** The user's profile photo URL */
picture?: string;
/** Information on all identities linked to this user */
firebase: {
/** The primary sign-in provider */
sign_in_provider: FirebaseSignInProvider;
/** A map of providers to the user's list of unique identifiers from each provider */
identities?: { [provider in FirebaseSignInProvider]?: string[] };
};
/** Custom claims set by the developer */
[claim: string]: unknown;
// NO LONGER SUPPORTED. Use "sub" instead. (Not a jsdoc comment to avoid generating docs.)
uid?: never;
}
export type EmulatorMockTokenOptions = (
| { user_id: string }
| { sub: string }
) &
Partial<FirebaseIdToken>;
/**
* 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/learn-more#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
* appId: "1:27992087142:web:ce....", // General Use
* projectId: "my-firebase-project", // 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
* measurementId: "G-12345" // Analytics
* });
* ```
*
* @example
* ```javascript
*
* // Initialize another app
* var otherApp = firebase.initializeApp({
* apiKey: "AIza....",
* appId: "1:27992087142:web:ce....",
* projectId: "my-firebase-project",
* databaseURL: "https://<OTHER_DATABASE_NAME>.firebaseio.com",
* storageBucket: "<OTHER_STORAGE_BUCKET>.appspot.com"
* }, "nameOfOtherApp");
* ```
*
* @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.
*
* The Messaging SDK does not work in a Node.js environment.
*
* @example
* ```javascript
* // Get the Messaging service for the default app
* var defaultMessaging = firebase.messaging();
* ```
*
* @example
* ```javascript
* // Get the Messaging service for a given app
* var otherMessaging = firebase.messaging(otherApp);
* ```
*
* @namespace
* @param app The app to create a Messaging service for.
* If not passed, uses the default app.
*/
function messaging(app?: firebase.app.App): firebase.messaging.Messaging;
/**
* Gets the {@link firebase.storage.Storage `Storage`} service for the default
* app or a given app.
*
* `firebase.storage()` can be called with no arguments to access the default
* app's {@link firebase.storage.Storage `Storage`} service or as
* `firebase.storage(app)` to access the
* {@link firebase.storage.Storage `Storage`} service associated with a
* specific app.
*
* @example
* ```javascript
* // Get the Storage service for the default app
* var defaultStorage = firebase.storage();
* ```
*
* @example
* ```javascript
* // Get the Storage service for a given app
* var otherStorage = firebase.storage(otherApp);
* ```
*
* @param app The app to create a storage service for.
* If not passed, uses the default app.
*/
function storage(app?: firebase.app.App): firebase.storage.Storage;
function firestore(app?: firebase.app.App): firebase.firestore.Firestore;
function functions(app?: firebase.app.App): firebase.functions.Functions;
/**
* Gets the {@link firebase.performance.Performance `Performance`} service.
*
* `firebase.performance()` can be called with no arguments to access the default
* app's {@link firebase.performance.Performance `Performance`} service.
* The {@link firebase.performance.Performance `Performance`} service does not work with
* any other app.
*
* The Performance SDK does not work in a Node.js environment.
*
* @example
* ```javascript
* // Get the Performance service for the default app
* const defaultPerformance = firebase.performance();
* ```
*
* @param app The app to create a performance service for. Performance Monitoring only works with
* the default app.
* If not passed, uses the default app.
*/
function performance(
app?: firebase.app.App
): firebase.performance.Performance;
/**
* Gets the {@link firebase.remoteConfig.RemoteConfig `RemoteConfig`} instance.
*
* The Remote Config SDK does not work in a Node.js environment.
*
* @example
* ```javascript
* // Get the RemoteConfig instance for the default app
* const defaultRemoteConfig = firebase.remoteConfig();
* ```
*
* @param app The app to create a Remote Config service for. If not passed, uses the default app.
*/
function remoteConfig(
app?: firebase.app.App
): firebase.remoteConfig.RemoteConfig;
/**
* Gets the {@link firebase.analytics.Analytics `Analytics`} service.
*
* `firebase.analytics()` can be called with no arguments to access the default
* app's {@link firebase.analytics.Analytics `Analytics`} service.
*
* The Analytics SDK does not work in a Node.js environment.
*
* @example
* ```javascript
* // Get the Analytics service for the default app
* const defaultAnalytics = firebase.analytics();
* ```
*
* @param app The app to create an analytics service for.
* If not passed, uses the default app.
*/
function analytics(app?: firebase.app.App): firebase.analytics.Analytics;
function appCheck(app?: firebase.app.App): firebase.appCheck.AppCheck;
}
declare namespace firebase.app {
/**
* A Firebase App holds the initialization information for a collection of
* services.
*
* Do not call this constructor directly. Instead, use
* {@link firebase.initializeApp|`firebase.initializeApp()`} to create an app.
*
*/
interface App {
/**
* Gets the {@link firebase.auth.Auth `Auth`} service for the current app.
*
* @example
* ```javascript
* var auth = app.auth();
* // The above is shorthand for:
* // var auth = firebase.auth(app);
* ```
*/
auth(): firebase.auth.Auth;
/**
* Gets the {@link firebase.database.Database `Database`} service for the
* current app.
*
* @example
* ```javascript
* var database = app.database();
* // The above is shorthand for:
* // var database = firebase.database(app);
* ```
*/
database(url?: string): firebase.database.Database;
/**
* Renders this app unusable and frees the resources of all associated
* services.
*
* @example
* ```javascript
* app.delete()
* .then(function() {
* console.log("App deleted successfully");
* })
* .catch(function(error) {
* console.log("Error deleting app:", error);
* });
* ```
*/
delete(): Promise<any>;
/**
* Gets the {@link firebase.installations.Installations `Installations`} service for the
* current app.
*
* The Installations SDK does not work in a Node.js environment.
*
* @example
* ```javascript
* const installations = app.installations();
* // The above is shorthand for:
* // const installations = firebase.installations(app);
* ```
*/
installations(): firebase.installations.Installations;
/**
* Gets the {@link firebase.messaging.Messaging `Messaging`} service for the
* current app.
*
* The Messaging SDK does not work in a Node.js environment.
*
* @example
* ```javascript
* var messaging = app.messaging();
* // The above is shorthand for:
* // var messaging = firebase.messaging(app);
* ```
*/
messaging(): firebase.messaging.Messaging;
/**
* The (read-only) name for this app.
*
* The default app's name is `"[DEFAULT]"`.
*
* @example
* ```javascript
* // The default app's name is "[DEFAULT]"
* firebase.initializeApp(defaultAppConfig);
* console.log(firebase.app().name); // "[DEFAULT]"
* ```
*
* @example
* ```javascript
* // A named app's name is what you provide to initializeApp()
* var otherApp = firebase.initializeApp(otherAppConfig, "other");
* console.log(otherApp.name); // "other"
* ```
*/
name: string;
/**
* The settable config flag for GDPR opt-in/opt-out
*/
automaticDataCollectionEnabled: boolean;
/**
* The (read-only) configuration options for this app. These are the original
* parameters given in
* {@link firebase.initializeApp `firebase.initializeApp()`}.
*
* @example
* ```javascript
* var app = firebase.initializeApp(config);
* console.log(app.options.databaseURL === config.databaseURL); // true
* ```
*/
options: Object;
/**
* Gets the {@link firebase.storage.Storage `Storage`} service for the current
* app, optionally initialized with a custom storage bucket.
*
* @example
* ```javascript
* var storage = app.storage();
* // The above is shorthand for:
* // var storage = firebase.storage(app);
* ```
*
* @example
* ```javascript
* var storage = app.storage("gs://your-app.appspot.com");
* ```
*
* @param url The gs:// url to your Firebase Storage Bucket.
* If not passed, uses the app's default Storage Bucket.
*/
storage(url?: string): firebase.storage.Storage;
firestore(): firebase.firestore.Firestore;
functions(regionOrCustomDomain?: string): firebase.functions.Functions;
/**
* Gets the {@link firebase.performance.Performance `Performance`} service for the
* current app. If the current app is not the default one, throws an error.
*
* The Performance SDK does not work in a Node.js environment.
*
* @example
* ```javascript
* const perf = app.performance();
* // The above is shorthand for:
* // const perf = firebase.performance(app);
* ```
*/
performance(): firebase.performance.Performance;
/**
* Gets the {@link firebase.remoteConfig.RemoteConfig `RemoteConfig`} instance.
*
* The Remote Config SDK does not work in a Node.js environment.
*
* @example
* ```javascript
* const rc = app.remoteConfig();
* // The above is shorthand for:
* // const rc = firebase.remoteConfig(app);
* ```
*/
remoteConfig(): firebase.remoteConfig.RemoteConfig;
/**
* Gets the {@link firebase.analytics.Analytics `Analytics`} service for the
* current app. If the current app is not the default one, throws an error.
*
* The Analytics SDK does not work in a Node.js environment.
*
* @example
* ```javascript
* const analytics = app.analytics();
* // The above is shorthand for:
* // const analytics = firebase.analytics(app);
* ```
*/
analytics(): firebase.analytics.Analytics;
appCheck(): firebase.appCheck.AppCheck;
}
}
/**
* Firebase App Check does not work in a Node.js environment using `ReCaptchaV3Provider` or
* `ReCaptchaEnterpriseProvider`, but can be used in Node.js if you use
* `CustomProvider` and write your own attestation method.
*/
declare namespace firebase.appCheck {
/**
* Result returned by
* {@link firebase.appCheck.AppCheck.getToken `firebase.appCheck().getToken()`}.
*/
interface AppCheckTokenResult {
token: string;
}
/*
* reCAPTCHA v3 token provider.
*/
class ReCaptchaV3Provider {
/**
* @param siteKey - reCAPTCHA v3 site key (public key).
*/
constructor(siteKey: string);
}
/*
* reCAPTCHA Enterprise token provider.
*/
class ReCaptchaEnterpriseProvider {
/**
* @param keyId - reCAPTCHA Enterprise key ID.
*/
constructor(keyId: string);
}
/*
* Custom token provider.
*/
class CustomProvider {
/**
* @param options - Options for creating the custom provider.
*/
constructor(options: CustomProviderOptions);
}
/**
* Options when creating a CustomProvider.
*/
interface CustomProviderOptions {
/**
* Function to get an App Check token through a custom provider
* service.
*/
getToken: () => Promise<AppCheckToken>;
}
/**
* The Firebase AppCheck service interface.
*
* Do not call this constructor directly. Instead, use
* {@link firebase.appCheck `firebase.appCheck()`}.
*/
export interface AppCheck {
/**
* Activate AppCheck
* @param provider This can be a `ReCaptchaV3Provider` instance,
* a `ReCaptchaEnterpriseProvider` instance, a `CustomProvider` instance,
* an object with a custom `getToken()` method, or a reCAPTCHA site key.
* @param isTokenAutoRefreshEnabled If true, the SDK automatically
* refreshes App Check tokens as needed. If undefined, defaults to the
* value of `app.automaticDataCollectionEnabled`, which defaults to
* false and can be set in the app config.
*/
activate(
provider:
| ReCaptchaV3Provider
| ReCaptchaEnterpriseProvider
| CustomProvider
| AppCheckProvider
| { getToken: () => AppCheckToken }
| string,
isTokenAutoRefreshEnabled?: boolean
): void;
/**
*
* @param isTokenAutoRefreshEnabled If true, the SDK automatically
* refreshes App Check tokens as needed. This overrides any value set
* during `activate()`.
*/
setTokenAutoRefreshEnabled(isTokenAutoRefreshEnabled: boolean): void;
/**
* Get the current App Check token. Attaches to the most recent
* in-flight request if one is present. Returns null if no token
* is present and no token requests are in-flight.
*
* @param forceRefresh - If true, will always try to fetch a fresh token.
* If false, will use a cached token if found in storage.
*/
getToken(
forceRefresh?: boolean
): Promise<firebase.appCheck.AppCheckTokenResult>;
/**
* Registers a listener to changes in the token state. There can be more
* than one listener registered at the same time for one or more
* App Check instances. The listeners call back on the UI thread whenever
* the current token associated with this App Check instance changes.
*
* @param observer An object with `next`, `error`, and `complete`
* properties. `next` is called with an
* {@link firebase.appCheck.AppCheckTokenResult `AppCheckTokenResult`}
* whenever the token changes. `error` is optional and is called if an
* error is thrown by the listener (the `next` function). `complete`
* is unused, as the token stream is unending.
*
* @returns A function that unsubscribes this listener.
*/
onTokenChanged(observer: {
next: (tokenResult: firebase.appCheck.AppCheckTokenResult) => void;
error?: (error: Error) => void;
complete?: () => void;
}): Unsubscribe;
/**
* Registers a listener to changes in the token state. There can be more
* than one listener registered at the same time for one or more
* App Check instances. The listeners call back on the UI thread whenever
* the current token associated with this App Check instance changes.
*
* @param onNext When the token changes, this function is called with aa
* {@link firebase.appCheck.AppCheckTokenResult `AppCheckTokenResult`}.
* @param onError Optional. Called if there is an error thrown by the
* listener (the `onNext` function).
* @param onCompletion Currently unused, as the token stream is unending.
* @returns A function that unsubscribes this listener.
*/
onTokenChanged(
onNext: (tokenResult: firebase.appCheck.AppCheckTokenResult) => void,
onError?: (error: Error) => void,
onCompletion?: () => void
): Unsubscribe;
}
/**
* An App Check provider. This can be either the built-in reCAPTCHA
* provider or a custom provider. For more on custom providers, see
* https://firebase.google.com/docs/app-check/web-custom-provider
*/
interface AppCheckProvider {
/**
* Returns an AppCheck token.
*/
getToken(): Promise<AppCheckToken>;
}
/**
* The token returned from an {@link firebase.appCheck.AppCheckProvider `AppCheckProvider`}.
*/
interface AppCheckToken {
/**
* The token string in JWT format.
*/
readonly token: string;
/**
* The local timestamp after which the token will expire.
*/
readonly expireTimeMillis: number;
}
}
/**
* The Installations SDK does not work in a Node.js environment.
*/
declare namespace firebase.installations {
/**
* The Firebase Installations service interface.
*
* Do not call this constructor directly. Instead, use
* {@link firebase.installations `firebase.installations()`}.
*/
export interface Installations {
/**
* The {@link firebase.app.App app} associated with the `Installations` service
* instance.
*
* @example
* ```javascript
* var app = analytics.app;
* ```
*/
app: firebase.app.App;
/**
* Creates a Firebase Installation if there isn't one for the app and
* returns the Installation ID.
*
* @return Firebase Installation ID
*/
getId(): Promise<string>;
/**
* Returns an Authentication Token for the current Firebase Installation.
*
* @return Firebase Installation Authentication Token
*/
getToken(forceRefresh?: boolean): Promise<string>;
/**
* Deletes the Firebase Installation and all associated data.
*/
delete(): Promise<void>;
/**
* Sets a new callback that will get called when Installation ID changes.
* Returns an unsubscribe function that will remove the callback when called.
*/
onIdChange(callback: (installationId: string) => void): () => void;
}
}
/**
* The Performance SDK does not work in a Node.js environment.
*/
declare namespace firebase.performance {
/**
* The Firebase Performance Monitoring service interface.
*
* Do not call this constructor directly. Instead, use
* {@link firebase.performance `firebase.performance()`}.
*/
export interface Performance {
/**
* The {@link firebase.app.App app} associated with the `Performance` service
* instance.
*
* @example
* ```javascript
* var app = analytics.app;
* ```
*/
app: firebase.app.App;
/**
* Creates an uninitialized instance of {@link firebase.performance.Trace `trace`} and returns
* it.
*
* @param traceName The name of the trace instance.
* @return The Trace instance.
*/
trace(traceName: string): Trace;
/**
* Controls the logging of automatic traces and HTTP/S network monitoring.
*/
instrumentationEnabled: boolean;
/**
* Controls the logging of custom traces.
*/
dataCollectionEnabled: boolean;
}
export interface Trace {
/**
* Starts the timing for the {@link firebase.performance.Trace `trace`} instance.
*/
start(): void;
/**
* Stops the timing of the {@link firebase.performance.Trace `trace`} instance and logs the
* data of the instance.
*/
stop(): void;
/**
* Records a {@link firebase.performance.Trace `trace`} from given parameters. This provides a
* direct way to use {@link firebase.performance.Trace `trace`} without a need to start/stop.
* This is useful for use cases in which the {@link firebase.performance.Trace `trace`} cannot
* directly be used (e.g. if the duration was captured before the Performance SDK was loaded).
*
* @param startTime Trace start time since epoch in millisec.
* @param duration The duration of the trace in millisec.
* @param options An object which can optionally hold maps of custom metrics and
* custom attributes.
*/
record(
startTime: number,
duration: number,
options?: {
metrics?: { [key: string]: number };
attributes?: { [key: string]: string };
}
): void;
/**
* Adds to the value of a custom metric. If a custom metric with the provided name does not
* exist, it creates one with that name and the value equal to the given number.
*
* @param metricName The name of the custom metric.
* @param num The number to be added to the value of the custom metric. If not provided, it
* uses a default value of one.
*/
incrementMetric(metricName: string, num?: number): void;
/**
* Sets the value of the specified custom metric to the given number regardless of whether
* a metric with that name already exists on the {@link firebase.performance.Trace `trace`}
* instance or not.
*
* @param metricName Name of the custom metric.
* @param num Value to of the custom metric.
*/
putMetric(metricName: string, num: number): void;
/**
* Returns the value of the custom metric by that name. If a custom metric with that name does
* not exist returns zero.
*
* @param metricName Name of the custom metric.
*/
getMetric(metricName: string): number;
/**
* Set a custom attribute of a {@link firebase.performance.Trace `trace`} to a certain value.
*
* @param attr Name of the custom attribute.
* @param value Value of the custom attribute.
*/
putAttribute(attr: string, value: string): void;
/**
* Retrieves the value that the custom attribute is set to.
*
* @param attr Name of the custom attribute.
*/
getAttribute(attr: string): string | undefined;
/**
* Removes the specified custom attribute from a {@link firebase.performance.Trace `trace`}
* instance.
*
* @param attr Name of the custom attribute.
*/
removeAttribute(attr: string): void;
/**
* Returns a map of all custom attributes of a {@link firebase.performance.Trace `trace`}
* instance.
*/
getAttributes(): { [key: string]: string };
}
}
/**
* The Remote Config SDK does not work in a Node.js environment.
*/
declare namespace firebase.remoteConfig {
/**
* The Firebase Remote Config service interface.
*
* Do not call this constructor directly. Instead, use
* {@link firebase.remoteConfig `firebase.remoteConfig()`}.
*/
export interface RemoteConfig {
/**
* The {@link firebase.app.App app} associated with the `Performance` service
* instance.
*
* @example
* ```javascript
* var app = analytics.app;
* ```
*/
app: firebase.app.App;
/**
* Defines configuration for the Remote Config SDK.
*/
settings: Settings;
/**
* Object containing default values for configs.
*/
defaultConfig: { [key: string]: string | number | boolean };
/**
* The Unix timestamp in milliseconds of the last <i>successful</i> fetch, or negative one if
* the {@link RemoteConfig} instance either hasn't fetched or initialization
* is incomplete.
*/
fetchTimeMillis: number;
/**
* The status of the last fetch <i>attempt</i>.
*/
lastFetchStatus: FetchStatus;
/**
* Makes the last fetched config available to the getters.
* Returns a promise which resolves to true if the current call activated the fetched configs.
* If the fetched configs were already activated, the promise will resolve to false.
*/
activate(): Promise<boolean>;
/**
* Ensures the last activated config are available to the getters.
*/
ensureInitialized(): Promise<void>;
/**
* Fetches and caches configuration from the Remote Config service.
*/
fetch(): Promise<void>;
/**
* Performs fetch and activate operations, as a convenience.
* Returns a promise which resolves to true if the current call activated the fetched configs.
* If the fetched configs were already activated, the promise will resolve to false.
*/
fetchAndActivate(): Promise<boolean>;
/**
* Gets all config.
*/
getAll(): { [key: string]: Value };
/**
* Gets the value for the given key as a boolean.
*
* Convenience method for calling <code>remoteConfig.getValue(key).asBoolean()</code>.
*/
getBoolean(key: string): boolean;
/**
* Gets the value for the given key as a number.
*
* Convenience method for calling <code>remoteConfig.getValue(key).asNumber()</code>.
*/
getNumber(key: string): number;
/**
* Gets the value for the given key as a String.
*
* Convenience method for calling <code>remoteConfig.getValue(key).asString()</code>.
*/
getString(key: string): string;
/**
* Gets the {@link Value} for the given key.
*/
getValue(key: string): Value;
/**
* Defines the log level to use.
*/
setLogLevel(logLevel: LogLevel): void;
}
/**
* Indicates the source of a value.
*
* <ul>
* <li>"static" indicates the value was defined by a static constant.</li>
* <li>"default" indicates the value was defined by default config.</li>
* <li>"remote" indicates the value was defined by fetched config.</li>
* </ul>
*/
export type ValueSource = 'static' | 'default' | 'remote';
/**
* Wraps a value with metadata and type-safe getters.
*/
export interface Value {
/**
* Gets the value as a boolean.
*
* The following values (case-insensitive) are interpreted as true:
* "1", "true", "t", "yes", "y", "on". Other values are interpreted as false.
*/
asBoolean(): boolean;
/**
* Gets the value as a number. Comparable to calling <code>Number(value) || 0</code>.
*/
asNumber(): number;
/**
* Gets the value as a string.
*/
asString(): string;
/**
* Gets the {@link ValueSource} for the given key.
*/
getSource(): ValueSource;
}
/**
* Defines configuration options for the Remote Config SDK.
*/
export interface Settings {
/**
* Defines the maximum age in milliseconds of an entry in the config cache before
* it is considered stale. Defaults to 43200000 (Twelve hours).
*/
minimumFetchIntervalMillis: number;
/**
* Defines the maximum amount of milliseconds to wait for a response when fetching
* configuration from the Remote Config server. Defaults to 60000 (One minute).
*/
fetchTimeoutMillis: number;
}
/**
* Summarizes the outcome of the last attempt to fetch config from the Firebase Remote Config server.
*
* <ul>
* <li>"no-fetch-yet" indicates the {@link RemoteConfig} instance has not yet attempted
* to fetch config, or that SDK initialization is incomplete.</li>
* <li>"success" indicates the last attempt succeeded.</li>
* <li>"failure" indicates the last attempt failed.</li>
* <li>"throttle" indicates the last attempt was rate-limited.</li>
* </ul>
*/
export type FetchStatus = 'no-fetch-yet' | 'success' | 'failure' | 'throttle';
/**
* Defines levels of Remote Config logging.
*/
export type LogLevel = 'debug' | 'error' | 'silent';
/**
* This method provides two different checks:
*
* 1. Check if IndexedDB exists in the browser environment.
* 2. Check if the current browser context allows IndexedDB `open()` calls.
*
* It returns a `Promise` which resolves to true if a {@link RemoteConfig} instance
* can be initialized in this environment, or false if it cannot.
*/
export function isSupported(): Promise<boolean>;
}
declare namespace firebase.functions {
/**
* An HttpsCallableResult wraps a single result from a function call.
*/
export interface HttpsCallableResult {
readonly data: any;
}
/**
* An HttpsCallable is a reference to a "callable" http trigger in
* Google Cloud Functions.
*/
export interface HttpsCallable {
(data?: any): Promise<HttpsCallableResult>;
}
export interface HttpsCallableOptions {
timeout?: number;
}
/**
* The Cloud Functions for Firebase service interface.
*
* Do not call this constructor directly. Instead, use
* {@link firebase.functions `firebase.functions()`}.
*/
export class Functions {
private constructor();
/**
* Modify this instance to communicate with the Cloud Functions emulator.
*
* Note: this must be called before this instance has been used to do any operations.
*
* @param host The emulator host (ex: localhost)
* @param port The emulator port (ex: 5001)
*/
useEmulator(host: string, port: number): void;
/**
* Changes this instance to point to a Cloud Functions emulator running
* locally. See https://firebase.google.com/docs/functions/local-emulator
*
* @deprecated Prefer the useEmulator(host, port) method.
* @param origin The origin of the local emulator, such as
* "http://localhost:5005".
*/
useFunctionsEmulator(url: string): void;
/**
* Gets an `HttpsCallable` instance that refers to the function with the given
* name.
*
* @param name The name of the https callable function.
* @param options The options for this HttpsCallable instance.
* @return The `HttpsCallable` instance.
*/
httpsCallable(name: string, options?: HttpsCallableOptions): HttpsCallable;
}
/**
* The set of Firebase Functions status codes. The codes are the same at the
* ones exposed by gRPC here:
* https://github.com/grpc/grpc/blob/master/doc/statuscodes.md
*
* Possible values:
* - 'cancelled': The operation was cancelled (typically by the caller).
* - 'unknown': Unknown error or an error from a different error domain.
* - 'invalid-argument': Client specified an invalid argument. Note that this
* differs from 'failed-precondition'. 'invalid-argument' indicates
* arguments that are problematic regardless of the state of the system
* (e.g. an invalid field name).
* - 'deadline-exceeded': Deadline expired before operation could complete.
* For operations that change the state of the system, this error may be
* returned even if the operation has completed successfully. For example,
* a successful response from a server could have been delayed long enough
* for the deadline to expire.
* - 'not-found': Some requested document was not found.
* - 'already-exists': Some document that we attempted to create already
* exists.
* - 'permission-denied': The caller does not have permission to execute the
* specified operation.
* - 'resource-exhausted': Some resource has been exhausted, perhaps a
* per-user quota, or perhaps the entire file system is out of space.
* - 'failed-precondition': Operation was rejected because the system is not
* in a state required for the operation's execution.
* - 'aborted': The operation was aborted, typically due to a concurrency
* issue like transaction aborts, etc.
* - 'out-of-range': Operation was attempted past the valid range.
* - 'unimplemented': Operation is not implemented or not supported/enabled.
* - 'internal': Internal errors. Means some invariants expected by
* underlying system has been broken. If you see one of these errors,
* something is very broken.
* - 'unavailable': The service is currently unavailable. This is most likely
* a transient condition and may be corrected by retrying with a backoff.
* - 'data-loss': Unrecoverable data loss or corruption.
* - 'unauthenticated': The request does not have valid authentication
* credentials for the operation.
*/
export type FunctionsErrorCode =
| 'ok'
| 'cancelled'
| 'unknown'
| 'invalid-argument'
| 'deadline-exceeded'
| 'not-found'
| 'already-exists'
| 'permission-denied'
| 'resource-exhausted'
| 'failed-precondition'
| 'aborted'
| 'out-of-range'
| 'unimplemented'
| 'internal'
| 'unavailable'
| 'data-loss'
| 'unauthenticated';
export interface HttpsError extends Error {
/**
* A standard error code that will be returned to the client. This also
* determines the HTTP status code of the response, as defined in code.proto.
*/
readonly code: FunctionsErrorCode;
/**
* Extra data to be converted to JSON and included in the error response.
*/
readonly details?: any;
}
}
declare namespace firebase.auth {
/**
* A utility class to parse email action URLs.
*/
class ActionCodeURL {
private constructor();
/**
* The API key of the email action link.
*/
apiKey: string;
/**
* The action code of the email action link.
*/
code: string;
/**
* The continue URL of the email action link. Null if not provided.
*/
continueUrl: string | null;
/**
* The language code of the email action link. Null if not provided.
*/
languageCode: string | null;
/**
* The action performed by the email action link. It returns from one
* of the types from {@link firebase.auth.ActionCodeInfo}.
*/
operation: firebase.auth.ActionCodeInfo.Operation;
/**
* Parses the email action link string and returns an ActionCodeURL object
* if the link is valid, otherwise returns null.
*
* @param link The email action link string.
* @return The ActionCodeURL object, or null if the link is invalid.
*/
static parseLink(link: string): firebase.auth.ActionCodeURL | null;
/**
* The tenant ID of the email action link. Null if the email action
* is from the parent project.
*/
tenantId: string | null;
}
/**
* A response from {@link firebase.auth.Auth.checkActionCode}.
*/
interface ActionCodeInfo {
/**
* The data associated with the action code.
*
* For the `PASSWORD_RESET`, `VERIFY_EMAIL`, and `RECOVER_EMAIL` actions, this object
* contains an `email` field with the address the email was sent to.
*
* For the RECOVER_EMAIL action, which allows a user to undo an email address
* change, this object also contains a `previousEmail` field with the user account's
* current email address. After the action completes, the user's email address will
* revert to the value in the `email` field from the value in `previousEmail` field.
*
* For the VERIFY_AND_CHANGE_EMAIL action, which allows a user to verify the email
* before updating it, this object contains a `previousEmail` field with the user
* account's email address before updating. After the action completes, the user's
* email address will be updated to the value in the `email` field from the value
* in `previousEmail` field.
*
* For the REVERT_SECOND_FACTOR_ADDITION action, which allows a user to unenroll
* a newly added second factor, this object contains a `multiFactorInfo` field with
* the information about the second factor. For phone second factor, the
* `multiFactorInfo` is a {@link firebase.auth.PhoneMultiFactorInfo} object,
* which contains the phone number.
*/
data: {
email?: string | null;
/**
* @deprecated
* This field is deprecated in favor of previousEmail.
*/
fromEmail?: string | null;
multiFactorInfo?: firebase.auth.MultiFactorInfo | null;
previousEmail?: string | null;
};
/**
* The type of operation that generated the action code. This could be:
* <ul>
* <li>`EMAIL_SIGNIN`: email sign in code generated via
* {@link firebase.auth.Auth.sendSignInLinkToEmail}.</li>
* <li>`PASSWORD_RESET`: password reset code generated via
* {@link firebase.auth.Auth.sendPasswordResetEmail}.</li>
* <li>`RECOVER_EMAIL`: email change revocation code generated via
* {@link firebase.User.updateEmail}.</li>
* <li>`REVERT_SECOND_FACTOR_ADDITION`: revert second factor addition
* code generated via
* {@link firebase.User.MultiFactorUser.enroll}.</li>
* <li>`VERIFY_AND_CHANGE_EMAIL`: verify and change email code generated
* via {@link firebase.User.verifyBeforeUpdateEmail}.</li>
* <li>`VERIFY_EMAIL`: email verification code generated via
* {@link firebase.User.sendEmailVerification}.</li>
* </ul>
*/
operation: string;
}
/**
* This is the interface that defines the required continue/state URL with
* optional Android and iOS bundle identifiers.
* The action code setting fields are:
* <ul>
* <li><p>url: Sets the link continue/state URL, which has different meanings
* in different contexts:</p>
* <ul>
* <li>When the link is handled in the web action widgets, this is the deep
* link in the continueUrl query parameter.</li>
* <li>When the link is handled in the app directly, this is the continueUrl
* query parameter in the deep link of the Dynamic Link.</li>
* </ul>
* </li>
* <li>iOS: Sets the iOS bundle ID. This will try to open the link in an iOS app
* if it is installed.</li>
* <li>android: Sets the Android package name. This will try to open the link in
* an android app if it is installed. If installApp is passed, it specifies
* whether to install the Android app if the device supports it and the app
* is not already installed. If this field is provided without a
* packageName, an error is thrown explaining that the packageName must be
* provided in conjunction with this field.
* If minimumVersion is specified, and an older version of the app is
* installed, the user is taken to the Play Store to upgrade the app.</li>
* <li>handleCodeInApp: The default is false. When set to true, the action code
* link will be be sent as a Universal Link or Android App Link and will be
* opened by the app if installed. In the false case, the code will be sent
* to the web widget first and then on continue will redirect to the app if
* installed.</li>
* </ul>
*/
type ActionCodeSettings = {
android?: {
installApp?: boolean;
minimumVersion?: string;
packageName: string;
};
handleCodeInApp?: boolean;
iOS?: { bundleId: string };
url: string;
dynamicLinkDomain?: string;
};
/**
* A structure containing additional user information from a federated identity
* provider.
*/
type AdditionalUserInfo = {
isNewUser: boolean;
profile: Object | null;
providerId: string;
username?: string | null;
};
/**
* A verifier for domain verification and abuse prevention. Currently, the
* only implementation is {@link firebase.auth.RecaptchaVerifier}.
*/
interface ApplicationVerifier {
/**
* Identifies the type of application verifier (e.g. "recaptcha").
*/
type: string;
/**
* Executes the verification process.
* @return A Promise for a token that can be used to
* assert the validity of a request.
*/
verify(): Promise<string>;
}
/**
* Interface representing an Auth instance's settings, currently used for
* enabling/disabling app verification for phone Auth testing.
*/
interface AuthSettings {
/**
* When set, this property disables app verification for the purpose of testing
* phone authentication. For this property to take effect, it needs to be set
* before rendering a reCAPTCHA app verifier. When this is disabled, a
* mock reCAPTCHA is rendered instead. This is useful for manual testing during
* development or for automated integration tests.
*
* In order to use this feature, you will need to
* {@link https://firebase.google.com/docs/auth/web/phone-auth#test-with-whitelisted-phone-numbers
* whitelist your phone number} via the
* Firebase Console.
*
* The default value is false (app verification is enabled).
*/
appVerificationDisabledForTesting: boolean;
}
/**
* Interface representing the Auth config.
*
* @public
*/
export interface Config {
/**
* The API Key used to communicate with the Firebase Auth backend.
*/
apiKey: string;
/**
* The host at which the Firebase Auth backend is running.
*/
apiHost: string;
/**
* The scheme used to communicate with the Firebase Auth backend.
*/
apiScheme: string;
/**
* The host at which the Secure Token API is running.
*/
tokenApiHost: string;
/**
* The SDK Client Version.
*/
sdkClientVersion: string;
/**
* The domain at which the web widgets are hosted (provided via Firebase Config).
*/
authDomain?: string;
}
/**
* Configuration of Firebase Authentication Emulator.
*/
export interface EmulatorConfig {
/**
* The protocol used to communicate with the emulator ("http"/"https").
*/
readonly protocol: string;
/**
* The hostname of the emulator, which may be a domain ("localhost"), IPv4 address ("127.0.0.1")
* or quoted IPv6 address ("[::1]").
*/
readonly host: string;
/**
* The port of the emulator, or null if port isn't specified (i.e. protocol default).
*/
readonly port: number | null;
/**
* The emulator-specific options.
*/
readonly options: {
/**
* Whether the warning banner attached to the DOM was disabled.
*/
readonly disableWarnings: boolean;
};
}
/**
* The Firebase Auth service interface.
*
* Do not call this constructor directly. Instead, use
* {@link firebase.auth `firebase.auth()`}.
*
* See
* {@link https://firebase.google.com/docs/auth/ Firebase Authentication}
* for a full guide on how to use the Firebase Auth service.
*
*/
interface Auth {
/** The name of the app associated with the Auth service instance. */
readonly name: string;
/** The config used to initialize this instance. */
readonly config: Config;
/** The current emulator configuration (or null). */
readonly emulatorConfig: EmulatorConfig | null;
/**
* The {@link firebase.app.App app} associated with the `Auth` service
* instance.
*
* @example
* ```javascript
* var app = auth.app;
* ```
*/
app: firebase.app.App;
/**
* Applies a verification code sent to the user by email or other out-of-band
* mechanism.
*
* <h4>Error Codes</h4>
* <dl>
* <dt>auth/expired-action-code</dt>
* <dd>Thrown if the action code has expired.</dd>
* <dt>auth/invalid-action-code</dt>
* <dd>Thrown if the action code is invalid. This can happen if the code is
* malformed or has already been used.</dd>
* <dt>auth/user-disabled</dt>
* <dd>Thrown if the user corresponding to the given action code has been
* disabled.</dd>
* <dt>auth/user-not-found</dt>
* <dd>Thrown if there is no user corresponding to the action code. This may
* have happened if the user was deleted between when the action code was
* issued and when this method was called.</dd>
* </dl>
*
* @param code A verification code sent to the user.
*/
applyActionCode(code: string): Promise<void>;
/**
* Checks a verification code sent to the user by email or other out-of-band
* mechanism.
*
* Returns metadata about the code.
*
* <h4>Error Codes</h4>
* <dl>
* <dt>auth/expired-action-code</dt>
* <dd>Thrown if the action code has expired.</dd>
* <dt>auth/invalid-action-code</dt>
* <dd>Thrown if the action code is invalid. This can happen if the code is
* malformed or has already been used.</dd>
* <dt>auth/user-disabled</dt>
* <dd>Thrown if the user corresponding to the given action code has been
* disabled.</dd>
* <dt>auth/user-not-found</dt>
* <dd>Thrown if there is no user corresponding to the action code. This may
* have happened if the user was deleted between when the action code was
* issued and when this method was called.</dd>
* </dl>
*
* @param code A verification code sent to the user.
*/
checkActionCode(code: string): Promise<firebase.auth.ActionCodeInfo>;
/**
* Completes the password reset process, given a confirmation code and new
* password.
*
* <h4>Error Codes</h4>
* <dl>
* <dt>auth/expired-action-code</dt>
* <dd>Thrown if the password reset code has expired.</dd>
* <dt>auth/invalid-action-code</dt>
* <dd>Thrown if the password reset code is invalid. This can happen if the
* code is malformed or has already been used.</dd>
* <dt>auth/user-disabled</dt>
* <dd>Thrown if the user corresponding to the given password reset code has
* been disabled.</dd>
* <dt>auth/user-not-found</dt>
* <dd>Thrown if there is no user corresponding to the password reset code. This
* may have happened if the user was deleted between when the code was
* issued and when this method was called.</dd>
* <dt>auth/weak-password</dt>
* <dd>Thrown if the new password is not strong enough.</dd>
* </dl>
*
* @param code The confirmation code send via email to the user.
* @param newPassword The new password.
*/
confirmPasswordReset(code: string, newPassword: string): Promise<void>;
/**
* Creates a new user account associated with the specified email address and
* password.
*
* On successful creation of the user account, this user will also be
* signed in to your application.
*
* User account creation can fail if the account already exists or the password
* is invalid.
*
* Note: The email address acts as a unique identifier for the user and
* enables an email-based password reset. This function will create
* a new user account and set the initial user password.
*
* <h4>Error Codes</h4>
* <dl>
* <dt>auth/email-already-in-use</dt>
* <dd>Thrown if there already exists an account with the given email
* address.</dd>
* <dt>auth/invalid-email</dt>
* <dd>Thrown if the email address is not valid.</dd>
* <dt>auth/operation-not-allowed</dt>
* <dd>Thrown if email/password accounts are not enabled. Enable email/password
* accounts in the Firebase Console, under the Auth tab.</dd>
* <dt>auth/weak-password</dt>
* <dd>Thrown if the password is not strong enough.</dd>
* </dl>
*
* @example
* ```javascript
* firebase.auth().createUserWithEmailAndPassword(email, password)
* .catch(function(error) {
* // Handle Errors here.
* var errorCode = error.code;
* var errorMessage = error.message;
* if (errorCode == 'auth/weak-password') {
* alert('The password is too weak.');
* } else {
* alert(errorMessage);
* }
* console.log(error);
* });
* ```
* @param email The user's email address.
* @param password The user's chosen password.
*/
createUserWithEmailAndPassword(
email: string,
password: string
): Promise<firebase.auth.UserCredential>;
/**
* The currently signed-in user (or null).
*/
currentUser: firebase.User | null;
/**
* Gets the list of possible sign in methods for the given email address. This
* is useful to differentiate methods of sign-in for the same provider,
* eg. `EmailAuthProvider` which has 2 methods of sign-in, email/password and
* email/link.
*
* <h4>Error Codes</h4>
* <dl>
* <dt>auth/invalid-email</dt>
* <dd>Thrown if the email address is not valid.</dd>
* </dl>
*/
fetchSignInMethodsForEmail(email: string): Promise<Array<string>>;
/**
* Checks if an incoming link is a sign-in with email link.
*/
isSignInWithEmailLink(emailLink: string): boolean;
/**
* Returns a UserCredential from the redirect-based sign-in flow.
*
* If sign-in succeeded, returns the signed in user. If sign-in was
* unsuccessful, fails with an error. If no redirect operation was called, returns `null`.
*
* <h4>Error Codes</h4>
* <dl>
* <dt>auth/account-exists-with-different-credential</dt>
* <dd>Thrown if there already exists an account with the email address
* asserted by the credential. Resolve this by calling
* {@link firebase.auth.Auth.fetchSignInMethodsForEmail} with the error.email
* and then asking the user to sign in using one of the returned providers.
* Once the user is signed in, the original credential retrieved from the
* error.credential can be linked to the user with
* {@link firebase.User.linkWithCredential} to prevent the user from signing
* in again to the original provider via popup or redirect. If you are using
* redirects for sign in, save the credential in session storage and then
* retrieve on redirect and repopulate the credential using for example
* {@link firebase.auth.GoogleAuthProvider.credential} depending on the
* credential provider id and complete the link.</dd>
* <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/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 the type of account corresponding to the credential
* is not enabled. Enable the account type in the Firebase Console, under
* the Auth tab.</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/timeout</dt>
* <dd>Thrown typically 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>
*
* This method does not work in a Node.js environment.
*
* @example
* ```javascript
* // First, we perform the signInWithRedirect.
* // 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');
* // Sign in with redirect:
* auth.signInWithRedirect(provider)
* ////////////////////////////////////////////////////////////
* // The user is redirected to the provider's sign in flow...
* ////////////////////////////////////////////////////////////
* // Then redirected back to the app, where we check the redirect result:
* auth.getRedirectResult().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;
* // As this API can be used for sign-in, linking and reauthentication,
* // check the operationType to determine what triggered this redirect
* // operation.
* var operationType = result.operationType;
* }, function(error) {
* // The provider's account email, can be used in case of
* // auth/account-exists-with-different-credential to fetch the providers
* // linked to the email:
* var email = error.email;
* // The provider's credential:
* var credential = error.credential;
* // In case of auth/account-exists-with-different-credential error,
* // you can fetch the providers using this:
* if (error.code === 'auth/account-exists-with-different-credential') {
* auth.fetchSignInMethodsForEmail(email).then(function(providers) {
* // The returned 'providers' is a list of the available providers
* // linked to the email address. Please refer to the guide for a more
* // complete explanation on how to recover from this error.
* });
* }
* });
* ```
*/
getRedirectResult(): Promise<firebase.auth.UserCredential>;
/**
* The current Auth instance's language code. This is a readable/writable
* property. When set to null, the default Firebase Console language setting
* is applied. The language code will propagate to email action templates
* (password reset, email verification and email change revocation), SMS
* templates for phone authentication, reCAPTCHA verifier and OAuth
* popup/redirect operations provided the specified providers support
* localization with the language code specified.
*/
languageCode: string | null;
/**
* The current Auth instance's settings. This is used to edit/read configuration
* related options like app verification mode for phone authentication.
*/
settings: firebase.auth.AuthSettings;
/**
* Adds an observer for changes to the user's sign-in state.
*
* Prior to 4.0.0, this triggered the observer when users were signed in,
* signed out, or when the user's ID token changed in situations such as token
* expiry or password change. After 4.0.0, the observer is only triggered
* on sign-in or sign-out.
*
* To keep the old behavior, see {@link firebase.auth.Auth.onIdTokenChanged}.
*
* @example
* ```javascript
* firebase.auth().onAuthStateChanged(function(user) {
* if (user) {
* // User is signed in.
* }
* });
* ```
*/
onAuthStateChanged(
nextOrObserver:
| firebase.Observer<any>
| ((a: firebase.User | null) => any),
error?: (a: firebase.auth.Error) => any,
completed?: firebase.Unsubscribe
): firebase.Unsubscribe;
/**
* Adds an observer for changes to the signed-in user's ID token, which includes
* sign-in, sign-out, and token refresh events. This method has the same
* behavior as {@link firebase.auth.Auth.onAuthStateChanged} had prior to 4.0.0.
*
* @example
* ```javascript
* firebase.auth().onIdTokenChanged(function(user) {
* if (user) {
* // User is signed in or token was refreshed.
* }
* });
* ```
* @param
* nextOrObserver An observer object or a function triggered on change.
* @param error Optional A function
* triggered on auth error.
* @param completed Optional A function triggered when the
* observer is removed.
*/
onIdTokenChanged(
nextOrObserver:
| firebase.Observer<any>
| ((a: firebase.User | null) => any),
error?: (a: firebase.auth.Error) => any,
completed?: firebase.Unsubscribe
): firebase.Unsubscribe;
/**
* Sends a sign-in email link to the user with the specified email.
*
* The sign-in operation has to always be completed in the app unlike other out
* of band email actions (password reset and email verifications). This is
* because, at the end of the flow, the user is expected to be signed in and
* their Auth state persisted within the app.
*
* To complete sign in with the email link, call
* {@link firebase.auth.Auth.signInWithEmailLink} with the email address and
* the email link supplied in the email sent to the user.
*
* <h4>Error Codes</h4>
* <dl>
* <dt>auth/argument-error</dt>
* <dd>Thrown if handleCodeInApp is false.</dd>
* <dt>auth/invalid-email</dt>
* <dd>Thrown if the email address is not valid.</dd>
* <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 = {
* // The URL to redirect to for sign-in completion. This is also the deep
* // link for mobile redirects. The domain (www.example.com) for this URL
* // must be whitelisted in the Firebase Console.
* url: 'https://www.example.com/finishSignUp?cartId=1234',
* iOS: {
* bundleId: 'com.example.ios'
* },
* android: {
* packageName: 'com.example.android',
* installApp: true,
* minimumVersion: '12'
* },
* // This must be true.
* handleCodeInApp: true
* };
* firebase.auth().sendSignInLinkToEmail('user@example.com', actionCodeSettings)
* .then(function() {
* // The link was successfully sent. Inform the user. Save the email
* // locally so you don't need to ask the user for it again if they open
* // the link on the same device.
* })
* .catch(function(error) {
* // Some error occurred, you can inspect the code: error.code
* });
* ```
* @param email The email account to sign in with.
* @param actionCodeSettings The action
* code settings. The action code settings which provides Firebase with
* instructions on how to construct the email link. This includes the
* sign in completion URL or the deep link for mobile redirects, the mobile
* apps to use when the sign-in link is opened on an Android or iOS device.
* 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.
*/
sendSignInLinkToEmail(
email: string,
actionCodeSettings: firebase.auth.ActionCodeSettings
): Promise<void>;
/**
* Sends a password reset email to the given email address.
*
* To complete the password reset, call
* {@link firebase.auth.Auth.confirmPasswordReset} with the code supplied in the
* email sent to the user, along with the new password specified by the user.
*
* <h4>Error Codes</h4>
* <dl>
* <dt>auth/invalid-email</dt>
* <dd>Thrown if the email address is not valid.</dd>
* <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>
* <dt>auth/user-not-found</dt>
* <dd>Thrown if there is no user corresponding to the email address.</dd>
* </dl>
*
* @example
* ```javascript
* var actionCodeSettings = {
* url: 'https://www.example.com/?email=user@example.com',
* iOS: {
* bundleId: 'com.example.ios'
* },
* android: {
* packageName: 'com.example.android',
* installApp: true,
* minimumVersion: '12'
* },
* handleCodeInApp: true
* };
* firebase.auth().sendPasswordResetEmail(
* 'user@example.com', actionCodeSettings)
* .then(function() {
* // Password reset email sent.
* })
* .catch(function(error) {
* // Error occurred. Inspect error.code.
* });
* ```
*
* @param email The email address with the password to be reset.
* @param actionCodeSettings The action
* code settings. If specified, the state/continue URL will be set as the
* "continueUrl" parameter in the password reset link. The default password
* reset 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.
*/
sendPasswordResetEmail(
email: string,
actionCodeSettings?: firebase.auth.ActionCodeSettings | null
): Promise<void>;
/**
* Changes the current type of persistence on the current Auth instance for the
* currently saved Auth session and applies this type of persistence for
* future sign-in requests, including sign-in with redirect requests. This will
* return a promise that will resolve once the state finishes copying from one
* type of storage to the other.
* Calling a sign-in method after changing persistence will wait for that
* persistence change to complete before applying it on the new Auth state.
*
* This makes it easy for a user signing in to specify whether their session
* should be remembered or not. It also makes it easier to never persist the
* Auth state for applications that are shared by other users or have sensitive
* data.
*
* The default for web browser apps and React Native apps is 'local' (provided
* the browser supports this mechanism) whereas it is 'none' for Node.js backend
* apps.
*
* <h4>Error Codes (thrown synchronously)</h4>
* <dl>
* <dt>auth/invalid-persistence-type</dt>
* <dd>Thrown if the specified persistence type is invalid.</dd>
* <dt>auth/unsupported-persistence-type</dt>
* <dd>Thrown if the current environment does not support the specified
* persistence type.</dd>
* </dl>
*
* @example
* ```javascript
* firebase.auth().setPersistence(firebase.auth.Auth.Persistence.SESSION)
* .then(function() {
* // Existing and future Auth states are now persisted in the current
* // session only. Closing the window would clear any existing state even if
* // a user forgets to sign out.
* });
* ```
*/
setPersistence(persistence: firebase.auth.Auth.Persistence): Promise<void>;
/**
* Asynchronously signs in with the given credentials, and returns any available
* additional user information, such as user name.
*
* <h4>Error Codes</h4>
* <dl>
* <dt>auth/account-exists-with-different-credential</dt>
* <dd>Thrown if there already exists an account with the email address
* asserted by the credential. Resolve this by calling
* {@link firebase.auth.Auth.fetchSignInMethodsForEmail} and then asking the
* user to sign in using one of the returned providers. Once the user is
* signed in, the original credential can be linked to the user with
* {@link firebase.User.linkWithCredential}.</dd>
* <dt>auth/invalid-credential</dt>
* <dd>Thrown if the credential is malformed or has expired.</dd>
* <dt>auth/operation-not-allowed</dt>
* <dd>Thrown if the type of account corresponding to the credential
* is not enabled. Enable the account type in the Firebase Console, under
* the Auth tab.</dd>
* <dt>auth/user-disabled</dt>
* <dd>Thrown if the user corresponding to the given credential has been
* disabled.</dd>
* <dt>auth/user-not-found</dt>
* <dd>Thrown if signing in with a credential from
* {@link firebase.auth.EmailAuthProvider.credential} and there is no user
* corresponding to the given email. </dd>
* <dt>auth/wrong-password</dt>
* <dd>Thrown if signing in with a credential from
* {@link firebase.auth.EmailAuthProvider.credential} and the password is
* invalid for the given email, or if the account corresponding to the email
* does not have a password set.</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.auth.Auth.signInWithCredential} instead.
*
* @example
* ```javascript
* firebase.auth().signInAndRetrieveDataWithCredential(credential)
* .then(function(userCredential) {
* console.log(userCredential.additionalUserInfo.username);
* });
* ```
* @param credential The auth credential.
*/
signInAndRetrieveDataWithCredential(
credential: firebase.auth.AuthCredential
): Promise<firebase.auth.UserCredential>;
/**
* Asynchronously signs in as an anonymous user.
*
*
* If there is already an anonymous user signed in, that user will be returned;
* otherwise, a new anonymous user identity will be created and returned.
*
* <h4>Error Codes</h4>
* <dl>
* <dt>auth/operation-not-allowed</dt>
* <dd>Thrown if anonymous accounts are not enabled. Enable anonymous accounts
* in the Firebase Console, under the Auth tab.</dd>
* </dl>
*
* @example
* ```javascript
* firebase.auth().signInAnonymously().catch(function(error) {
* // Handle Errors here.
* var errorCode = error.code;
* var errorMessage = error.message;
*
* if (errorCode === 'auth/operation-not-allowed') {
* alert('You must enable Anonymous auth in the Firebase Console.');
* } else {
* console.error(error);
* }
* });
* ```
*/
signInAnonymously(): Promise<firebase.auth.UserCredential>;
/**
* Asynchronously signs in with the given credentials.
*
* <h4>Error Codes</h4>
* <dl>
* <dt>auth/account-exists-with-different-credential</dt>
* <dd>Thrown if there already exists an account with the email address
* asserted by the credential. Resolve this by calling
* {@link firebase.auth.Auth.fetchSignInMethodsForEmail} and then asking the
* user to sign in using one of the returned providers. Once the user is
* signed in, the original credential can be linked to the user with
* {@link firebase.User.linkWithCredential}.</dd>
* <dt>auth/invalid-credential</dt>
* <dd>Thrown if the credential is malformed or has expired.</dd>
* <dt>auth/operation-not-allowed</dt>
* <dd>Thrown if the type of account corresponding to the credential
* is not enabled. Enable the account type in the Firebase Console, under
* the Auth tab.</dd>
* <dt>auth/user-disabled</dt>
* <dd>Thrown if the user corresponding to the given credential has been
* disabled.</dd>
* <dt>auth/user-not-found</dt>
* <dd>Thrown if signing in with a credential from
* {@link firebase.auth.EmailAuthProvider.credential} and there is no user
* corresponding to the given email. </dd>
* <dt>auth/wrong-password</dt>
* <dd>Thrown if signing in with a credential from
* {@link firebase.auth.EmailAuthProvider.credential} and the password is
* invalid for the given email, or if the account corresponding to the email
* does not have a password set.</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>
*
* @example
* ```javascript
* firebase.auth().signInWithCredential(credential).catch(function(error) {
* // Handle Errors here.
* var errorCode = error.code;
* var errorMessage = error.message;
* // The email of the user's account used.
* var email = error.email;
* // The firebase.auth.AuthCredential type that was used.
* var credential = error.credential;
* if (errorCode === 'auth/account-exists-with-different-credential') {
* alert('Email already associated with another account.');
* // Handle account linking here, if using.
* } else {
* console.error(error);
* }
* });
* ```
*
* @param credential The auth credential.
*/
signInWithCredential(
credential: firebase.auth.AuthCredential
): Promise<firebase.auth.UserCredential>;
/**
* Asynchronously signs in using a custom token.
*
* Custom tokens are used to integrate Firebase Auth with existing auth systems,
* and must be generated by the auth backend.
*
* Fails with an error if the token is invalid, expired, or not accepted by the
* Firebase Auth service.
*
* <h4>Error Codes</h4>
* <dl>
* <dt>auth/custom-token-mismatch</dt>
* <dd>Thrown if the custom token is for a different Firebase App.</dd>
* <dt>auth/invalid-custom-token</dt>
* <dd>Thrown if the custom token format is incorrect.</dd>
* </dl>
*
* @example
* ```javascript
* firebase.auth().signInWithCustomToken(token).catch(function(error) {
* // Handle Errors here.
* var errorCode = error.code;
* var errorMessage = error.message;
* if (errorCode === 'auth/invalid-custom-token') {
* alert('The token you provided is not valid.');
* } else {
* console.error(error);
* }
* });
* ```
*
* @param token The custom token to sign in with.
*/
signInWithCustomToken(token: string): Promise<firebase.auth.UserCredential>;
/**
* Asynchronously signs in using an email and password.
*
* Fails with an error if the email address and password do not match.
*
* Note: The user's password is NOT the password used to access the user's email
* account. The email address serves as a unique identifier for the user, and
* the password is used to access the user's account in your Firebase project.
*
* See also: {@link firebase.auth.Auth.createUserWithEmailAndPassword}.
*
* <h4>Error Codes</h4>
* <dl>
* <dt>auth/invalid-email</dt>
* <dd>Thrown if the email address is not valid.</dd>
* <dt>auth/user-disabled</dt>
* <dd>Thrown if the user corresponding to the given email has been
* disabled.</dd>
* <dt>auth/user-not-found</dt>
* <dd>Thrown if there is no user corresponding to the given email.</dd>
* <dt>auth/wrong-password</dt>
* <dd>Thrown if the password is invalid for the given email, or the account
* corresponding to the email does not have a password set.</dd>
* </dl>
*
* @example
* ```javascript
* firebase.auth().signInWithEmailAndPassword(email, password)
* .catch(function(error) {
* // Handle Errors here.
* var errorCode = error.code;
* var errorMessage = error.message;
* if (errorCode === 'auth/wrong-password') {
* alert('Wrong password.');
* } else {
* alert(errorMessage);
* }
* console.log(error);
* });
* ```
*
* @param email The users email address.
* @param password The users password.
*/
signInWithEmailAndPassword(
email: string,
password: string
): Promise<firebase.auth.UserCredential>;
/**
* Asynchronously signs in using a phone number. This method sends a code via
* SMS to the given phone number, and returns a
* {@link firebase.auth.ConfirmationResult}. After the user provides the code
* sent to their phone, call {@link firebase.auth.ConfirmationResult.confirm}
* with the code to sign the user in.
*
* For abuse prevention, this method also requires a
* {@link firebase.auth.ApplicationVerifier}. The Firebase Auth SDK includes
* a reCAPTCHA-based implementation, {@link firebase.auth.RecaptchaVerifier}.
*
* <h4>Error Codes</h4>
* <dl>
* <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/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>
* </dl>
*
* @example
* ```javascript
* // 'recaptcha-container' is the ID of an element in the DOM.
* var applicationVerifier = new firebase.auth.RecaptchaVerifier(
* 'recaptcha-container');
* firebase.auth().signInWithPhoneNumber(phoneNumber, applicationVerifier)
* .then(function(confirmationResult) {
* var verificationCode = window.prompt('Please enter the verification ' +
* 'code that was sent to your mobile device.');
* return confirmationResult.confirm(verificationCode);
* })
* .catch(function(error) {
* // Handle Errors here.
* });
* ```
*
* @param phoneNumber The user's phone number in E.164 format (e.g.
* +16505550101).
* @param applicationVerifier
*/
signInWithPhoneNumber(
phoneNumber: string,
applicationVerifier: firebase.auth.ApplicationVerifier
): Promise<firebase.auth.ConfirmationResult>;
/**
* Asynchronously signs in using an email and sign-in email link. If no link
* is passed, the link is inferred from the current URL.
*
* Fails with an error if the email address is invalid or OTP in email link
* expires.
*
* Note: Confirm the link is a sign-in email link before calling this method
* {@link firebase.auth.Auth.isSignInWithEmailLink}.
*
* <h4>Error Codes</h4>
* <dl>
* <dt>auth/expired-action-code</dt>
* <dd>Thrown if OTP in email link expires.</dd>
* <dt>auth/invalid-email</dt>
* <dd>Thrown if the email address is not valid.</dd>
* <dt>auth/user-disabled</dt>
* <dd>Thrown if the user corresponding to the given email has been
* disabled.</dd>
* </dl>
*
* @example
* ```javascript
* firebase.auth().signInWithEmailLink(email, emailLink)
* .catch(function(error) {
* // Some error occurred, you can inspect the code: error.code
* // Common errors could be invalid email and invalid or expired OTPs.
* });
* ```
*
* @param email The email account to sign in with.
* @param emailLink The optional link which contains the OTP needed
* to complete the sign in with email link. If not specified, the current
* URL is used instead.
*/
signInWithEmailLink(
email: string,
emailLink?: string
): Promise<firebase.auth.UserCredential>;
/**
* Authenticates a Firebase client using a popup-based OAuth authentication
* flow.
*
* If succeeds, returns the signed in user along with the provider's credential.
* If sign in was unsuccessful, returns an error object containing additional
* information about the error.
*
* <h4>Error Codes</h4>
* <dl>
* <dt>auth/account-exists-with-different-credential</dt>
* <dd>Thrown if there already exists an account with the email address
* asserted by the credential. Resolve this by calling
* {@link firebase.auth.Auth.fetchSignInMethodsForEmail} with the error.email
* and then asking the user to sign in using one of the returned providers.
* Once the user is signed in, the original credential retrieved from the
* error.credential can be linked to the user with
* {@link firebase.User.linkWithCredential} to prevent the user from signing
* in again to the original provider via popup or redirect. If you are using
* redirects for sign in, save the credential in session storage and then
* retrieve on redirect and repopulate the credential using for example
* {@link firebase.auth.GoogleAuthProvider.credential} depending on the
* credential provider id and complete the link.</dd>
* <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. All the popups would fail with this error
* except for the last one.</dd>
* <dt>auth/operation-not-allowed</dt>
* <dd>Thrown if the type of account corresponding to the credential
* is not enabled. Enable the account type in the Firebase Console, under
* the Auth tab.</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-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/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>
*
* This method does not work in a Node.js environment.
*
* @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');
* // Sign in with popup:
* auth.signInWithPopup(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) {
* // The provider's account email, can be used in case of
* // auth/account-exists-with-different-credential to fetch the providers
* // linked to the email:
* var email = error.email;
* // The provider's credential:
* var credential = error.credential;
* // In case of auth/account-exists-with-different-credential error,
* // you can fetch the providers using this:
* if (error.code === 'auth/account-exists-with-different-credential') {
* auth.fetchSignInMethodsForEmail(email).then(function(providers) {
* // The returned 'providers' is a list of the available providers
* // linked to the email address. Please refer to the guide for a more
* // complete explanation on how to recover from this error.
* });
* }
* });
* ```
*
* @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.
*/
signInWithPopup(
provider: firebase.auth.AuthProvider
): Promise<firebase.auth.UserCredential>;
/**
* Authenticates a Firebase client using a full-page redirect flow. To handle
* the results and errors for this operation, refer to {@link
* firebase.auth.Auth.getRedirectResult}.
*
* <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/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>
*
* This method does not work in a Node.js environment.
*
* @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.
*/
signInWithRedirect(provider: firebase.auth.AuthProvider): Promise<void>;
/**
* Signs out the current user.
*/
signOut(): Promise<void>;
/**
* The current Auth instance's tenant ID. This is a readable/writable
* property. When you set the tenant ID of an Auth instance, all future
* sign-in/sign-up operations will pass this tenant ID and sign in or
* sign up users to the specified tenant project.
* When set to null, users are signed in to the parent project. By default,
* this is set to null.
*
* @example
* ```javascript
* // Set the tenant ID on Auth instance.
* firebase.auth().tenantId = ‘TENANT_PROJECT_ID’;
*
* // All future sign-in request now include tenant ID.
* firebase.auth().signInWithEmailAndPassword(email, password)
* .then(function(result) {
* // result.user.tenantId should be ‘TENANT_PROJECT_ID’.
* }).catch(function(error) {
* // Handle error.
* });
* ```
*/
tenantId: string | null;
/**
* Asynchronously sets the provided user as `currentUser` on the current Auth
* instance. A new instance copy of the user provided will be made and set as
* `currentUser`.
*
* This will trigger {@link firebase.auth.Auth.onAuthStateChanged} and
* {@link firebase.auth.Auth.onIdTokenChanged} listeners like other sign in
* methods.
*
* The operation fails with an error if the user to be updated belongs to a
* different Firebase project.
*
* <h4>Error Codes</h4>
* <dl>
* <dt>auth/invalid-user-token</dt>
* <dd>Thrown if the user to be updated belongs to a different Firebase
* project.</dd>
* <dt>auth/user-token-expired</dt>
* <dd>Thrown if the token of the user to be updated is expired.</dd>
* <dt>auth/null-user</dt>
* <dd>Thrown if the user to be updated is null.</dd>
* <dt>auth/tenant-id-mismatch</dt>
* <dd>Thrown if the provided user's tenant ID does not match the
* underlying Auth instance's configured tenant ID</dd>
* </dl>
*/
updateCurrentUser(user: firebase.User | null): Promise<void>;
/**
* Sets the current language to the default device/browser preference.
*/
useDeviceLanguage(): void;
/**
* Modify this Auth instance to communicate with the Firebase Auth emulator. This must be
* called synchronously immediately following the first call to `firebase.auth()`. Do not use
* with production credentials as emulator traffic is not encrypted.
*
* @param url The URL at which the emulator is running (eg, 'http://localhost:9099')
*/
useEmulator(url: string): void;
/**
* Checks a password reset code sent to the user by email or other out-of-band
* mechanism.
*
* Returns the user's email address if valid.
*
* <h4>Error Codes</h4>
* <dl>
* <dt>auth/expired-action-code</dt>
* <dd>Thrown if the password reset code has expired.</dd>
* <dt>auth/invalid-action-code</dt>
* <dd>Thrown if the password reset code is invalid. This can happen if the code
* is malformed or has already been used.</dd>
* <dt>auth/user-disabled</dt>
* <dd>Thrown if the user corresponding to the given password reset code has
* been disabled.</dd>
* <dt>auth/user-not-found</dt>
* <dd>Thrown if there is no user corresponding to the password reset code. This
* may have happened if the user was deleted between when the code was
* issued and when this method was called.</dd>
* </dl>
*
* @param code A verification code sent to the user.
*/
verifyPasswordResetCode(code: string): Promise<string>;
}
/**
* Interface that represents the credentials returned by an auth provider.
* Implementations specify the details about each auth provider's credential
* requirements.
*
*/
abstract class AuthCredential {
/**
* The authentication provider ID for the credential.
* For example, 'facebook.com', or 'google.com'.
*/
providerId: string;
/**
* The authentication sign in method for the credential.
* For example, 'password', or 'emailLink. This corresponds to the sign-in
* method identifier as returned in
* {@link firebase.auth.Auth.fetchSignInMethodsForEmail}.
*/
signInMethod: string;
/**
* Returns a JSON-serializable representation of this object.
*/
toJSON(): Object;
/**
* Static method to deserialize a JSON representation of an object into an
* {@link firebase.auth.AuthCredential}. Input can be either Object or the
* stringified representation of the object. When string is provided,
* JSON.parse would be called first. If the JSON input does not represent
* an`AuthCredential`, null is returned.
* @param json The plain object representation of an
* AuthCredential.
*/
static fromJSON(json: Object | string): AuthCredential | null;
}
/**
* Interface that represents the OAuth credentials returned by an OAuth
* provider. Implementations specify the details about each auth provider's
* credential requirements.
*
*/
class OAuthCredential extends AuthCredential {
private constructor();
/**
* The OAuth ID token associated with the credential if it belongs to an
* OIDC provider, such as `google.com`.
*/
idToken?: string;
/**
* The OAuth access token associated with the credential if it belongs to
* an OAuth provider, such as `facebook.com`, `twitter.com`, etc.
*/
accessToken?: string;
/**
* The OAuth access token secret associated with the credential if it
* belongs to an OAuth 1.0 provider, such as `twitter.com`.
*/
secret?: string;
}
/**
* Interface that represents an auth provider.
*/
interface AuthProvider {
providerId: string;
}
/**
* A result from a phone number sign-in, link, or reauthenticate call.
*/
interface ConfirmationResult {
/**
* Finishes a phone number sign-in, link, or reauthentication, given the code
* that was sent to the user's mobile device.
*
* <h4>Error Codes</h4>
* <dl>
* <dt>auth/invalid-verification-code</dt>
* <dd>Thrown if the verification code is not valid.</dd>
* <dt>auth/missing-verification-code</dt>
* <dd>Thrown if the verification code is missing.</dd>
* </dl>
*/
confirm(verificationCode: string): Promise<firebase.auth.UserCredential>;
/**
* The phone number authentication operation's verification ID. This can be used
* along with the verification code to initialize a phone auth credential.
*/
verificationId: string;
}
/**
* Email and password auth provider implementation.
*
* To authenticate: {@link firebase.auth.Auth.createUserWithEmailAndPassword}
* and {@link firebase.auth.Auth.signInWithEmailAndPassword}.
*/
class EmailAuthProvider extends EmailAuthProvider_Instance {
static PROVIDER_ID: string;
/**
* This corresponds to the sign-in method identifier as returned in
* {@link firebase.auth.Auth.fetchSignInMethodsForEmail}.
*/
static EMAIL_PASSWORD_SIGN_IN_METHOD: string;
/**
* This corresponds to the sign-in method identifier as returned in
* {@link firebase.auth.Auth.fetchSignInMethodsForEmail}.
*/
static EMAIL_LINK_SIGN_IN_METHOD: string;
/**
* @example
* ```javascript
* var cred = firebase.auth.EmailAuthProvider.credential(
* email,
* password
* );
* ```
*
* @param email Email address.
* @param password User account password.
* @return The auth provider credential.
*/
static credential(
email: string,
password: string
): firebase.auth.AuthCredential;
/**
* Initialize an `EmailAuthProvider` credential using an email and an email link
* after a sign in with email link operation.
*
* @example
* ```javascript
* var cred = firebase.auth.EmailAuthProvider.credentialWithLink(
* email,
* emailLink
* );
* ```
*
* @param email Email address.
* @param emailLink Sign-in email link.
* @return The auth provider credential.
*/
static credentialWithLink(
email: string,
emailLink: string
): firebase.auth.AuthCredential;
}
/**
* @hidden
*/
class EmailAuthProvider_Instance implements firebase.auth.AuthProvider {
providerId: string;
}
/**
* An authentication error.
* For method-specific error codes, refer to the specific methods in the
* documentation. For common error codes, check the reference below. Use{@link
* firebase.auth.Error.code} to get the specific error code. For a detailed
* message, use {@link firebase.auth.Error.message}.
* Errors with the code <strong>auth/account-exists-with-different-credential
* </strong> will have the additional fields <strong>email</strong> and <strong>
* credential</strong> which are needed to provide a way to resolve these
* specific errors. Refer to {@link firebase.auth.Auth.signInWithPopup} for more
* information.
*
* <h4>Common Error Codes</h4>
* <dl>
* <dt>auth/app-deleted</dt>
* <dd>Thrown if the instance of FirebaseApp has been deleted.</dd>
* <dt>auth/app-not-authorized</dt>
* <dd>Thrown if the app identified by the domain where it's hosted, is not
* authorized to use Firebase Authentication with the provided API key.
* Review your key configuration in the Google API console.</dd>
* <dt>auth/argument-error</dt>
* <dd>Thrown if a method is called with incorrect arguments.</dd>
* <dt>auth/invalid-api-key</dt>
* <dd>Thrown if the provided API key is invalid. Please check that you have
* copied it correctly from the Firebase Console.</dd>
* <dt>auth/invalid-user-token</dt>
* <dd>Thrown if the user's credential is no longer valid. The user must sign in
* again.</dd>
* <dt>auth/invalid-tenant-id</dt>
* <dd>Thrown if the tenant ID provided is invalid.</dd>
* <dt>auth/network-request-failed</dt>
* <dd>Thrown if a network error (such as timeout, interrupted connection or
* unreachable host) has occurred.</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/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>
* <dt>auth/too-many-requests</dt>
* <dd>Thrown if requests are blocked from a device due to unusual activity.
* Trying again after some delay would unblock.</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>
* <dt>auth/user-disabled</dt>
* <dd>Thrown if the user account has been disabled by an administrator.
* Accounts can be enabled or disabled in the Firebase Console, the Auth
* section and Users subsection.</dd>
* <dt>auth/user-token-expired</dt>
* <dd>Thrown if the user's credential has expired. This could also be thrown if
* a user has been deleted. Prompting the user to sign in again should
* resolve this for either case.</dd>
* <dt>auth/web-storage-unsupported</dt>
* <dd>Thrown if the browser does not support web storage or if the user
* disables them.</dd>
* </dl>
*/
interface Error {
name: string;
/**
* Unique error code.
*/
code: string;
/**
* Complete error message.
*/
message: string;
}
/**
* The account conflict error.
* Refer to {@link firebase.auth.Auth.signInWithPopup} for more information.
*
* <h4>Common Error Codes</h4>
* <dl>
* <dt>auth/account-exists-with-different-credential</dt>
* <dd>Thrown if there already exists an account with the email address
* asserted by the credential. Resolve this by calling
* {@link firebase.auth.Auth.fetchSignInMethodsForEmail} with the error.email
* and then asking the user to sign in using one of the returned providers.
* Once the user is signed in, the original credential retrieved from the
* error.credential can be linked to the user with
* {@link firebase.User.linkWithCredential} to prevent the user from signing
* in again to the original provider via popup or redirect. If you are using
* redirects for sign in, save the credential in session storage and then
* retrieve on redirect and repopulate the credential using for example
* {@link firebase.auth.GoogleAuthProvider.credential} depending on the
* credential provider id and complete the link.</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>
* </dl>
*/
interface AuthError extends firebase.auth.Error {
/**
* The {@link firebase.auth.AuthCredential} that can be used to resolve the
* error.
*/
credential?: firebase.auth.AuthCredential;
/**
* The email of the user's account used for sign-in/linking.
*/
email?: string;
/**
* The phone number of the user's account used for sign-in/linking.
*/
phoneNumber?: string;
/**
* The tenant ID being used for sign-in/linking. If you use
* {@link firebase.auth.Auth.signInWithRedirect} to sign in, you have to
* set the tenant ID on Auth instance again as the tenant ID is not
* persisted after redirection.
*/
tenantId?: string;
}
/**
* The error thrown when the user needs to provide a second factor to sign in
* successfully.
* The error code for this error is <code>auth/multi-factor-auth-required</code>.
* This error provides a {@link firebase.auth.MultiFactorResolver} object,
* which you can use to get the second sign-in factor from the user.
*
* @example
* ```javascript
* firebase.auth().signInWithEmailAndPassword()
* .then(function(result) {
* // User signed in. No 2nd factor challenge is needed.
* })
* .catch(function(error) {
* if (error.code == 'auth/multi-factor-auth-required') {
* var resolver = error.resolver;
* var multiFactorHints = resolver.hints;
* } else {
* // Handle other errors.
* }
* });
*
* resolver.resolveSignIn(multiFactorAssertion)
* .then(function(userCredential) {
* // User signed in.
* });
* ```
*/
interface MultiFactorError extends firebase.auth.AuthError {
/**
* The multi-factor resolver to complete second factor sign-in.
*/
resolver: firebase.auth.MultiFactorResolver;
}
/**
* Facebook auth provider.
*
* @example
* ```javascript
* // Sign in using a redirect.
* firebase.auth().getRedirectResult().then(function(result) {
* if (result.credential) {
* // This gives you a Google Access Token.
* var token = result.credential.accessToken;
* }
* var user = result.user;
* })
* // Start a sign in process for an unauthenticated user.
* var provider = new firebase.auth.FacebookAuthProvider();
* provider.addScope('user_birthday');
* firebase.auth().signInWithRedirect(provider);
* ```
*
* @example
* ```javascript
* // Sign in using a popup.
* var provider = new firebase.auth.FacebookAuthProvider();
* provider.addScope('user_birthday');
* firebase.auth().signInWithPopup(provider).then(function(result) {
* // This gives you a Facebook Access Token.
* var token = result.credential.accessToken;
* // The signed-in user info.
* var user = result.user;
* });
* ```
*
* @see {@link firebase.auth.Auth.onAuthStateChanged} to receive sign in state
* changes.
*/
class FacebookAuthProvider extends FacebookAuthProvider_Instance {
static PROVIDER_ID: string;
/**
* This corresponds to the sign-in method identifier as returned in
* {@link firebase.auth.Auth.fetchSignInMethodsForEmail}.
*/
static FACEBOOK_SIGN_IN_METHOD: string;
/**
* @example
* ```javascript
* var cred = firebase.auth.FacebookAuthProvider.credential(
* // `event` from the Facebook auth.authResponseChange callback.
* event.authResponse.accessToken
* );
* ```
*
* @param token Facebook access token.
*/
static credential(token: string): firebase.auth.OAuthCredential;
}
/**
* @hidden
*/
class FacebookAuthProvider_Instance implements firebase.auth.AuthProvider {
/**
* @param scope Facebook OAuth scope.
* @return The provider instance itself.
*/
addScope(scope: string): firebase.auth.AuthProvider;
providerId: string;
/**
* Sets the OAuth custom parameters to pass in a Facebook OAuth request for
* popup and redirect sign-in operations.
* Valid parameters include 'auth_type', 'display' and 'locale'.
* For a detailed list, check the
* {@link https://goo.gl/pve4fo Facebook}
* documentation.
* Reserved required OAuth 2.0 parameters such as 'client_id', 'redirect_uri',
* 'scope', 'response_type' and 'state' are not allowed and will be ignored.
* @param customOAuthParameters The custom OAuth parameters to pass
* in the OAuth request.
* @return The provider instance itself.
*/
setCustomParameters(
customOAuthParameters: Object
): firebase.auth.AuthProvider;
}
/**
* GitHub auth provider.
*
* GitHub requires an OAuth 2.0 redirect, so you can either handle the redirect
* directly, or use the signInWithPopup handler:
*
* @example
* ```javascript
* // Using a redirect.
* firebase.auth().getRedirectResult().then(function(result) {
* if (result.credential) {
* // This gives you a GitHub Access Token.
* var token = result.credential.accessToken;
* }
* var user = result.user;
* }).catch(function(error) {
* // Handle Errors here.
* var errorCode = error.code;
* var errorMessage = error.message;
* // The email of the user's account used.
* var email = error.email;
* // The firebase.auth.AuthCredential type that was used.
* var credential = error.credential;
* if (errorCode === 'auth/account-exists-with-different-credential') {
* alert('You have signed up with a different provider for that email.');
* // Handle linking here if your app allows it.
* } else {
* console.error(error);
* }
* });
*
* // Start a sign in process for an unauthenticated user.
* var provider = new firebase.auth.GithubAuthProvider();
* provider.addScope('repo');
* firebase.auth().signInWithRedirect(provider);
* ```
*
* @example
* ```javascript
* // With popup.
* var provider = new firebase.auth.GithubAuthProvider();
* provider.addScope('repo');
* firebase.auth().signInWithPopup(provider).then(function(result) {
* // This gives you a GitHub Access Token.
* var token = result.credential.accessToken;
* // The signed-in user info.
* var user = result.user;
* }).catch(function(error) {
* // Handle Errors here.
* var errorCode = error.code;
* var errorMessage = error.message;
* // The email of the user's account used.
* var email = error.email;
* // The firebase.auth.AuthCredential type that was used.
* var credential = error.credential;
* if (errorCode === 'auth/account-exists-with-different-credential') {
* alert('You have signed up with a different provider for that email.');
* // Handle linking here if your app allows it.
* } else {
* console.error(error);
* }
* });
* ```
*
* @see {@link firebase.auth.Auth.onAuthStateChanged} to receive sign in state
* changes.
*/
class GithubAuthProvider extends GithubAuthProvider_Instance {
static PROVIDER_ID: string;
/**
* This corresponds to the sign-in method identifier as returned in
* {@link firebase.auth.Auth.fetchSignInMethodsForEmail}.
*/
static GITHUB_SIGN_IN_METHOD: string;
/**
* @example
* ```javascript
* var cred = firebase.auth.GithubAuthProvider.credential(
* // `event` from the GitHub auth.authResponseChange callback.
* event.authResponse.accessToken
* );
* ```
*
* @param token GitHub access token.
* @return {!firebase.auth.OAuthCredential} The auth provider credential.
*/
static credential(token: string): firebase.auth.OAuthCredential;
}
/**
* @hidden
*/
class GithubAuthProvider_Instance implements firebase.auth.AuthProvider {
/**
* @param scope GitHub OAuth scope.
* @return The provider instance itself.
*/
addScope(scope: string): firebase.auth.AuthProvider;
providerId: string;
/**
* Sets the OAuth custom parameters to pass in a GitHub OAuth request for popup
* and redirect sign-in operations.
* Valid parameters include 'allow_signup'.
* For a detailed list, check the
* {@link https://developer.github.com/v3/oauth/ GitHub} documentation.
* Reserved required OAuth 2.0 parameters such as 'client_id', 'redirect_uri',
* 'scope', 'response_type' and 'state' are not allowed and will be ignored.
* @param customOAuthParameters The custom OAuth parameters to pass
* in the OAuth request.
* @return The provider instance itself.
*/
setCustomParameters(
customOAuthParameters: Object
): firebase.auth.AuthProvider;
}
/**
* Google auth provider.
*
* @example
* ```javascript
* // Using a redirect.
* firebase.auth().getRedirectResult().then(function(result) {
* if (result.credential) {
* // This gives you a Google Access Token.
* var token = result.credential.accessToken;
* }
* var user = result.user;
* });
*
* // Start a sign in process for an unauthenticated user.
* var provider = new firebase.auth.GoogleAuthProvider();
* provider.addScope('profile');
* provider.addScope('email');
* firebase.auth().signInWithRedirect(provider);
* ```
*
* @example
* ```javascript
* // Using a popup.
* var provider = new firebase.auth.GoogleAuthProvider();
* provider.addScope('profile');
* provider.addScope('email');
* firebase.auth().signInWithPopup(provider).then(function(result) {
* // This gives you a Google Access Token.
* var token = result.credential.accessToken;
* // The signed-in user info.
* var user = result.user;
* });
* ```
*
* @see {@link firebase.auth.Auth.onAuthStateChanged} to receive sign in state
* changes.
*/
class GoogleAuthProvider extends GoogleAuthProvider_Instance {
static PROVIDER_ID: string;
/**
* This corresponds to the sign-in method identifier as returned in
* {@link firebase.auth.Auth.fetchSignInMethodsForEmail}.
*/
static GOOGLE_SIGN_IN_METHOD: string;
/**
* Creates a credential for Google. At least one of ID token and access token
* is required.
*
* @example
* ```javascript
* // \`googleUser\` from the onsuccess Google Sign In callback.
* var credential = firebase.auth.GoogleAuthProvider.credential(
googleUser.getAuthResponse().id_token);
* firebase.auth().signInWithCredential(credential)
* ```
* @param idToken Google ID token.
* @param accessToken Google access token.
* @return The auth provider credential.
*/
static credential(
idToken?: string | null,
accessToken?: string | null
): firebase.auth.OAuthCredential;
}
/**
* @hidden
*/
class GoogleAuthProvider_Instance implements firebase.auth.AuthProvider {
/**
* @param scope Google OAuth scope.
* @return The provider instance itself.
*/
addScope(scope: string): firebase.auth.AuthProvider;
providerId: string;
/**
* Sets the OAuth custom parameters to pass in a Google OAuth request for popup
* and redirect sign-in operations.
* Valid parameters include 'hd', 'hl', 'include_granted_scopes', 'login_hint'
* and 'prompt'.
* For a detailed list, check the
* {@link https://goo.gl/Xo01Jm Google}
* documentation.
* Reserved required OAuth 2.0 parameters such as 'client_id', 'redirect_uri',
* 'scope', 'response_type' and 'state' are not allowed and will be ignored.
* @param customOAuthParameters The custom OAuth parameters to pass
* in the OAuth request.
* @return The provider instance itself.
*/
setCustomParameters(
customOAuthParameters: Object
): firebase.auth.AuthProvider;
}
/**
* Generic OAuth provider.
*
* @example
* ```javascript
* // Using a redirect.
* firebase.auth().getRedirectResult().then(function(result) {
* if (result.credential) {
* // This gives you the OAuth Access Token for that provider.
* var token = result.credential.accessToken;
* }
* var user = result.user;
* });
*
* // Start a sign in process for an unauthenticated user.
* var provider = new firebase.auth.OAuthProvider('google.com');
* provider.addScope('profile');
* provider.addScope('email');
* firebase.auth().signInWithRedirect(provider);
* ```
* @example
* ```javascript
* // Using a popup.
* var provider = new firebase.auth.OAuthProvider('google.com');
* provider.addScope('profile');
* provider.addScope('email');
* firebase.auth().signInWithPopup(provider).then(function(result) {
* // This gives you the OAuth Access Token for that provider.
* var token = result.credential.accessToken;
* // The signed-in user info.
* var user = result.user;
* });
* ```
*
* @see {@link firebase.auth.Auth.onAuthStateChanged} to receive sign in state
* changes.
* @param providerId The associated provider ID, such as `github.com`.
*/
class OAuthProvider implements firebase.auth.AuthProvider {
constructor(providerId: string);
providerId: string;
/**
* @param scope Provider OAuth scope to add.
*/
addScope(scope: string): firebase.auth.AuthProvider;
/**
* Creates a Firebase credential from a generic OAuth provider's access token or
* ID token. The raw nonce is required when an ID token with a nonce field is
* provided. The SHA-256 hash of the raw nonce must match the nonce field in
* the ID token.
*
* @example
* ```javascript
* // `googleUser` from the onsuccess Google Sign In callback.
* // Initialize a generate OAuth provider with a `google.com` providerId.
* var provider = new firebase.auth.OAuthProvider('google.com');
* var credential = provider.credential({
* idToken: googleUser.getAuthResponse().id_token,
* });
* firebase.auth().signInWithCredential(credential)
* ```
*
* @param optionsOrIdToken Either the options object containing
* the ID token, access token and raw nonce or the ID token string.
* @param accessToken The OAuth access token.
*/
credential(
optionsOrIdToken: firebase.auth.OAuthCredentialOptions | string | null,
accessToken?: string
): firebase.auth.OAuthCredential;
/**
* Sets the OAuth custom parameters to pass in an OAuth request for popup
* and redirect sign-in operations.
* For a detailed list, check the
* reserved required OAuth 2.0 parameters such as `client_id`, `redirect_uri`,
* `scope`, `response_type` and `state` are not allowed and will be ignored.
* @param customOAuthParameters The custom OAuth parameters to pass
* in the OAuth request.
*/
setCustomParameters(
customOAuthParameters: Object
): firebase.auth.AuthProvider;
}
class SAMLAuthProvider implements firebase.auth.AuthProvider {
constructor(providerId: string);
providerId: string;
}
/**
* Interface representing ID token result obtained from
* {@link firebase.User.getIdTokenResult}. It contains the ID token JWT string
* and other helper properties for getting different data associated with the
* token as well as all the decoded payload claims.
*
* Note that these claims are not to be trusted as they are parsed client side.
* Only server side verification can guarantee the integrity of the token
* claims.
*/
interface IdTokenResult {
/**
* The Firebase Auth ID token JWT string.
*/
token: string;
/**
* The ID token expiration time formatted as a UTC string.
*/
expirationTime: string;
/**
* The authentication time formatted as a UTC string. This is the time the
* user authenticated (signed in) and not the time the token was refreshed.
*/
authTime: string;
/**
* The ID token issued at time formatted as a UTC string.
*/
issuedAtTime: string;
/**
* The sign-in provider through which the ID token was obtained (anonymous,
* custom, phone, password, etc). Note, this does not map to provider IDs.
*/
signInProvider: string | null;
/**
* The type of second factor associated with this session, provided the user
* was multi-factor authenticated (eg. phone, etc).
*/
signInSecondFactor: string | null;
/**
* The entire payload claims of the ID token including the standard reserved
* claims as well as the custom claims.
*/
claims: {
[key: string]: any;
};
}
/**
* Defines the options for initializing an
* {@link firebase.auth.OAuthCredential}. For ID tokens with nonce claim,
* the raw nonce has to also be provided.
*/
interface OAuthCredentialOptions {
/**
* The OAuth ID token used to initialize the OAuthCredential.
*/
idToken?: string;
/**
* The OAuth access token used to initialize the OAuthCredential.
*/
accessToken?: string;
/**
* The raw nonce associated with the ID token. It is required when an ID token
* with a nonce field is provided. The SHA-256 hash of the raw nonce must match
* the nonce field in the ID token.
*/
rawNonce?: string;
}
/**
* The base class for asserting ownership of a second factor. This is used to
* facilitate enrollment of a second factor on an existing user
* or sign-in of a user who already verified the first factor.
*
*/
abstract class MultiFactorAssertion {
/**
* The identifier of the second factor.
*/
factorId: string;
}
/**
* The class for asserting ownership of a phone second factor.
*/
class PhoneMultiFactorAssertion extends firebase.auth.MultiFactorAssertion {
private constructor();
}
/**
* The class used to initialize {@link firebase.auth.PhoneMultiFactorAssertion}.
*/
class PhoneMultiFactorGenerator {
private constructor();
/**
* The identifier of the phone second factor: `phone`.
*/
static FACTOR_ID: string;
/**
* Initializes the {@link firebase.auth.PhoneMultiFactorAssertion} to confirm ownership
* of the phone second factor.
*/
static assertion(
phoneAuthCredential: firebase.auth.PhoneAuthCredential
): firebase.auth.PhoneMultiFactorAssertion;
}
/**
* A structure containing the information of a second factor entity.
*/
interface MultiFactorInfo {
/**
* The multi-factor enrollment ID.
*/
uid: string;
/**
* The user friendly name of the current second factor.
*/
displayName?: string | null;
/**
* The enrollment date of the second factor formatted as a UTC string.
*/
enrollmentTime: string;
/**
* The identifier of the second factor.
*/
factorId: string;
}
/**
* The subclass of the MultiFactorInfo interface for phone number second factors.
* The factorId of this second factor is
* {@link firebase.auth.PhoneMultiFactorGenerator.FACTOR_ID}.
*/
interface PhoneMultiFactorInfo extends firebase.auth.MultiFactorInfo {
/**
* The phone number associated with the current second factor.
*/
phoneNumber: string;
}
/**
* The information required to verify the ownership of a phone number. The
* information that's required depends on whether you are doing single-factor
* sign-in, multi-factor enrollment or multi-factor sign-in.
*/
type PhoneInfoOptions =
| firebase.auth.PhoneSingleFactorInfoOptions
| firebase.auth.PhoneMultiFactorEnrollInfoOptions
| firebase.auth.PhoneMultiFactorSignInInfoOptions;
/**
* The phone info options for single-factor sign-in. Only phone number is
* required.
*/
interface PhoneSingleFactorInfoOptions {
phoneNumber: string;
}
/**
* The phone info options for multi-factor enrollment. Phone number and
* multi-factor session are required.
*/
interface PhoneMultiFactorEnrollInfoOptions {
phoneNumber: string;
session: firebase.auth.MultiFactorSession;
}
/**
* The phone info options for multi-factor sign-in. Either multi-factor hint or
* multi-factor UID and multi-factor session are required.
*/
interface PhoneMultiFactorSignInInfoOptions {
multiFactorHint?: firebase.auth.MultiFactorInfo;
multiFactorUid?: string;
session: firebase.auth.MultiFactorSession;
}
/**
* The class used to facilitate recovery from
* {@link firebase.auth.MultiFactorError} when a user needs to provide a second
* factor to sign in.
*
* @example
* ```javascript
* firebase.auth().signInWithEmailAndPassword()
* .then(function(result) {
* // User signed in. No 2nd factor challenge is needed.
* })
* .catch(function(error) {
* if (error.code == 'auth/multi-factor-auth-required') {
* var resolver = error.resolver;
* // Show UI to let user select second factor.
* var multiFactorHints = resolver.hints;
* } else {
* // Handle other errors.
* }
* });
*
* // The enrolled second factors that can be used to complete
* // sign-in are returned in the `MultiFactorResolver.hints` list.
* // UI needs to be presented to allow the user to select a second factor
* // from that list.
*
* var selectedHint = // ; selected from multiFactorHints
* var phoneAuthProvider = new firebase.auth.PhoneAuthProvider();
* var phoneInfoOptions = {
* multiFactorHint: selectedHint,
* session: resolver.session
* };
* phoneAuthProvider.verifyPhoneNumber(
* phoneInfoOptions,
* appVerifier
* ).then(function(verificationId) {
* // store verificationID and show UI to let user enter verification code.
* });
*
* // UI to enter verification code and continue.
* // Continue button click handler
* var phoneAuthCredential =
* firebase.auth.PhoneAuthProvider.credential(verificationId, verificationCode);
* var multiFactorAssertion =
* firebase.auth.PhoneMultiFactorGenerator.assertion(phoneAuthCredential);
* resolver.resolveSignIn(multiFactorAssertion)
* .then(function(userCredential) {
* // User signed in.
* });
* ```
*/
class MultiFactorResolver {
private constructor();
/**
* The Auth instance used to sign in with the first factor.
*/
auth: firebase.auth.Auth;
/**
* The session identifier for the current sign-in flow, which can be used
* to complete the second factor sign-in.
*/
session: firebase.auth.MultiFactorSession;
/**
* The list of hints for the second factors needed to complete the sign-in
* for the current session.
*/
hints: firebase.auth.MultiFactorInfo[];
/**
* A helper function to help users complete sign in with a second factor
* using an {@link firebase.auth.MultiFactorAssertion} confirming the user
* successfully completed the second factor challenge.
*
* <h4>Error Codes</h4>
* <dl>
* <dt>auth/invalid-verification-code</dt>
* <dd>Thrown if the verification code is not valid.</dd>
* <dt>auth/missing-verification-code</dt>
* <dd>Thrown if the verification code is missing.</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>
* <dt>auth/missing-verification-id</dt>
* <dd>Thrown if the verification ID is missing.</dd>
* <dt>auth/code-expired</dt>
* <dd>Thrown if the verification code has expired.</dd>
* <dt>auth/invalid-multi-factor-session</dt>
* <dd>Thrown if the request does not contain a valid proof of first factor
* successful sign-in.</dd>
* <dt>auth/missing-multi-factor-session</dt>
* <dd>Thrown if The request is missing proof of first factor successful
* sign-in.</dd>
* </dl>
*
* @param assertion The multi-factor assertion to resolve sign-in with.
* @return The promise that resolves with the user credential object.
*/
resolveSignIn(
assertion: firebase.auth.MultiFactorAssertion
): Promise<firebase.auth.UserCredential>;
}
/**
* The multi-factor session object used for enrolling a second factor on a
* user or helping sign in an enrolled user with a second factor.
*/
class MultiFactorSession {
private constructor();
}
/**
* Classes that represents the Phone Auth credentials returned by a
* {@link firebase.auth.PhoneAuthProvider}.
*
*/
class PhoneAuthCredential extends AuthCredential {
private constructor();
}
/**
* Phone number auth provider.
*
* @example
* ```javascript
* // 'recaptcha-container' is the ID of an element in the DOM.
* var applicationVerifier = new firebase.auth.RecaptchaVerifier(
* 'recaptcha-container');
* var provider = new firebase.auth.PhoneAuthProvider();
* provider.verifyPhoneNumber('+16505550101', applicationVerifier)
* .then(function(verificationId) {
* var verificationCode = window.prompt('Please enter the verification ' +
* 'code that was sent to your mobile device.');
* return firebase.auth.PhoneAuthProvider.credential(verificationId,
* verificationCode);
* })
* .then(function(phoneCredential) {
* return firebase.auth().signInWithCredential(phoneCredential);
* });
* ```
* @param auth The Firebase Auth instance in which
* sign-ins should occur. Uses the default Auth instance if unspecified.
*/
class PhoneAuthProvider extends PhoneAuthProvider_Instance {
static PROVIDER_ID: string;
/**
* This corresponds to the sign-in method identifier as returned in
* {@link firebase.auth.Auth.fetchSignInMethodsForEmail}.
*/
static PHONE_SIGN_IN_METHOD: string;
/**
* Creates a phone auth credential, given the verification ID from
* {@link firebase.auth.PhoneAuthProvider.verifyPhoneNumber} and the code
* that was sent to the user's mobile device.
*
* <h4>Error Codes</h4>
* <dl>
* <dt>auth/missing-verification-code</dt>
* <dd>Thrown if the verification code is missing.</dd>
* <dt>auth/missing-verification-id</dt>
* <dd>Thrown if the verification ID is missing.</dd>
* </dl>
*
* @param verificationId The verification ID returned from
* {@link firebase.auth.PhoneAuthProvider.verifyPhoneNumber}.
* @param verificationCode The verification code sent to the user's
* mobile device.
* @return The auth provider credential.
*/
static credential(
verificationId: string,
verificationCode: string
): firebase.auth.AuthCredential;
}
/**
* @hidden
*/
class PhoneAuthProvider_Instance implements firebase.auth.AuthProvider {
constructor(auth?: firebase.auth.Auth | null);
providerId: string;
/**
* Starts a phone number authentication flow by sending a verification code to
* the given phone number. Returns an ID that can be passed to
* {@link firebase.auth.PhoneAuthProvider.credential} to identify this flow.
*
* For abuse prevention, this method also requires a
* {@link firebase.auth.ApplicationVerifier}. The Firebase Auth SDK includes
* a reCAPTCHA-based implementation, {@link firebase.auth.RecaptchaVerifier}.
*
* <h4>Error Codes</h4>
* <dl>
* <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/maximum-second-factor-count-exceeded</dt>
* <dd>Thrown if The maximum allowed number of second factors on a user
* has been exceeded.</dd>
* <dt>auth/second-factor-already-in-use</dt>
* <dd>Thrown if the second factor is already enrolled on this account.</dd>
* <dt>auth/unsupported-first-factor</dt>
* <dd>Thrown if the first factor being used to sign in is not supported.</dd>
* <dt>auth/unverified-email</dt>
* <dd>Thrown if the email of the account is not verified.</dd>
* </dl>
*
* @param phoneInfoOptions The user's {@link firebase.auth.PhoneInfoOptions}.
* The phone number should be in E.164 format (e.g. +16505550101).
* @param applicationVerifier
* @return A Promise for the verification ID.
*/
verifyPhoneNumber(
phoneInfoOptions: firebase.auth.PhoneInfoOptions | string,
applicationVerifier: firebase.auth.ApplicationVerifier
): Promise<string>;
}
/**
* An {@link https://www.google.com/recaptcha/ reCAPTCHA}-based application
* verifier.
*
* This class does not work in a Node.js environment.
*
* @param container The reCAPTCHA container parameter. This
* has different meaning depending on whether the reCAPTCHA is hidden or
* visible. For a visible reCAPTCHA the container must be empty. If a string
* is used, it has to correspond to an element ID. The corresponding element
* must also must be in the DOM at the time of initialization.
* @param parameters The optional reCAPTCHA parameters. Check the
* reCAPTCHA docs for a comprehensive list. All parameters are accepted
* except for the sitekey. Firebase Auth backend provisions a reCAPTCHA for
* each project and will configure this upon rendering. For an invisible
* reCAPTCHA, a size key must have the value 'invisible'.
* @param app The corresponding Firebase app. If none is
* provided, the default Firebase App instance is used. A Firebase App
* instance must be initialized with an API key, otherwise an error will be
* thrown.
*/
class RecaptchaVerifier extends RecaptchaVerifier_Instance {}
/**
* @hidden
*/
class RecaptchaVerifier_Instance
implements firebase.auth.ApplicationVerifier
{
constructor(
container: any | string,
parameters?: Object | null,
app?: firebase.app.App | null
);
/**
* Clears the reCAPTCHA widget from the page and destroys the current instance.
*/
clear(): void;
/**
* Renders the reCAPTCHA widget on the page.
* @return A Promise that resolves with the
* reCAPTCHA widget ID.
*/
render(): Promise<number>;
/**
* The application verifier type. For a reCAPTCHA verifier, this is 'recaptcha'.
*/
type: string;
/**
* Waits for the user to solve the reCAPTCHA and resolves with the reCAPTCHA
* token.
* @return A Promise for the reCAPTCHA token.
*/
verify(): Promise<string>;
}
/**
* Twitter auth provider.
*
* @example
* ```javascript
* // Using a redirect.
* firebase.auth().getRedirectResult().then(function(result) {
* if (result.credential) {
* // For accessing the Twitter API.
* var token = result.credential.accessToken;
* var secret = result.credential.secret;
* }
* var user = result.user;
* });
*
* // Start a sign in process for an unauthenticated user.
* var provider = new firebase.auth.TwitterAuthProvider();
* firebase.auth().signInWithRedirect(provider);
* ```
* @example
* ```javascript
* // Using a popup.
* var provider = new firebase.auth.TwitterAuthProvider();
* firebase.auth().signInWithPopup(provider).then(function(result) {
* // For accessing the Twitter API.
* var token = result.credential.accessToken;
* var secret = result.credential.secret;
* // The signed-in user info.
* var user = result.user;
* });
* ```
*
* @see {@link firebase.auth.Auth.onAuthStateChanged} to receive sign in state
* changes.
*/
class TwitterAuthProvider extends TwitterAuthProvider_Instance {
static PROVIDER_ID: string;
/**
* This corresponds to the sign-in method identifier as returned in
* {@link firebase.auth.Auth.fetchSignInMethodsForEmail}.
*
*/
static TWITTER_SIGN_IN_METHOD: string;
/**
* @param token Twitter access token.
* @param secret Twitter secret.
* @return The auth provider credential.
*/
static credential(
token: string,
secret: string
): firebase.auth.OAuthCredential;
}
/**
* @hidden
*/
class TwitterAuthProvider_Instance implements firebase.auth.AuthProvider {
providerId: string;
/**
* Sets the OAuth custom parameters to pass in a Twitter OAuth request for popup
* and redirect sign-in operations.
* Valid parameters include 'lang'.
* Reserved required OAuth 1.0 parameters such as 'oauth_consumer_key',
* 'oauth_token', 'oauth_signature', etc are not allowed and will be ignored.
* @param customOAuthParameters The custom OAuth parameters to pass
* in the OAuth request.
* @return The provider instance itself.
*/
setCustomParameters(
customOAuthParameters: Object
): firebase.auth.AuthProvider;
}
/**
* A structure containing a User, an AuthCredential, the operationType, and
* any additional user information that was returned from the identity provider.
* operationType could be 'signIn' for a sign-in operation, 'link' for a linking
* operation and 'reauthenticate' for a reauthentication operation.
*/
type UserCredential = {
additionalUserInfo?: firebase.auth.AdditionalUserInfo | null;
credential: firebase.auth.AuthCredential | null;
operationType?: string | null;
user: firebase.User | null;
};
/**
* Interface representing a user's metadata.
*/
interface UserMetadata {
creationTime?: string;
lastSignInTime?: string;
}
}
/**
* The Analytics SDK does not work in a Node.js environment.
*/
declare namespace firebase.analytics {
/**
* The Firebase Analytics service interface.
*
* Do not call this constructor directly. Instead, use
* {@link firebase.analytics `firebase.analytics()`}.
*/
export interface Analytics {
/**
* The {@link firebase.app.App app} associated with the `Analytics` service
* instance.
*
* @example
* ```javascript
* var app = analytics.app;
* ```
*/
app: firebase.app.App;
/**
* Sends analytics event with given `eventParams`. This method
* automatically associates this logged event with this Firebase web
* app instance on this device.
* List of recommended event parameters can be found in
* {@link https://developers.google.com/gtagjs/reference/ga4-events
* | the GA4 reference documentation}.
*/
logEvent(
eventName: 'add_payment_info',
eventParams?: {
coupon?: EventParams['coupon'];
currency?: EventParams['currency'];
items?: EventParams['items'];
payment_type?: EventParams['payment_type'];
value?: EventParams['value'];
[key: string]: any;
},
options?: firebase.analytics.AnalyticsCallOptions
): void;
/**
* Sends analytics event with given `eventParams`. This method
* automatically associates this logged event with this Firebase web
* app instance on this device.
* List of recommended event parameters can be found in
* {@link https://developers.google.com/gtagjs/reference/ga4-events
* | the GA4 reference documentation}.
*/
logEvent(
eventName: 'add_shipping_info',
eventParams?: {
coupon?: EventParams['coupon'];
currency?: EventParams['currency'];
items?: EventParams['items'];
shipping_tier?: EventParams['shipping_tier'];
value?: EventParams['value'];
[key: string]: any;
},
options?: firebase.analytics.AnalyticsCallOptions
): void;
/**
* Sends analytics event with given `eventParams`. This method
* automatically associates this logged event with this Firebase web
* app instance on this device.
* List of recommended event parameters can be found in
* {@link https://developers.google.com/gtagjs/reference/ga4-events
* | the GA4 reference documentation}.
*/
logEvent(
eventName: 'add_to_cart' | 'add_to_wishlist' | 'remove_from_cart',
eventParams?: {
currency?: EventParams['currency'];
value?: EventParams['value'];
items?: EventParams['items'];
[key: string]: any;
},
options?: firebase.analytics.AnalyticsCallOptions
): void;
/**
* Sends analytics event with given `eventParams`. This method
* automatically associates this logged event with this Firebase web
* app instance on this device.
* List of recommended event parameters can be found in
* {@link https://developers.google.com/gtagjs/reference/ga4-events
* | the GA4 reference documentation}.
*/
logEvent(
eventName: 'begin_checkout',
eventParams?: {
currency?: EventParams['currency'];
coupon?: EventParams['coupon'];
value?: EventParams['value'];
items?: EventParams['items'];
[key: string]: any;
},
options?: firebase.analytics.AnalyticsCallOptions
): void;
/**
* Sends analytics event with given `eventParams`. This method
* automatically associates this logged event with this Firebase web
* app instance on this device.
* List of recommended event parameters can be found in
* {@link https://developers.google.com/gtagjs/reference/ga4-events
* | the GA4 reference documentation}.
*/
logEvent(
eventName: 'checkout_progress',
eventParams?: {
currency?: EventParams['currency'];
coupon?: EventParams['coupon'];
value?: EventParams['value'];
items?: EventParams['items'];
checkout_step?: EventParams['checkout_step'];
checkout_option?: EventParams['checkout_option'];
[key: string]: any;
},
options?: firebase.analytics.AnalyticsCallOptions
): void;
/**
* Sends analytics event with given `eventParams`. This method
* automatically associates this logged event with this Firebase web
* app instance on this device.
* See
* {@link https://developers.google.com/analytics/devguides/collection/ga4/exceptions
* | Measure exceptions}.
*/
logEvent(
eventName: 'exception',
eventParams?: {
description?: EventParams['description'];
fatal?: EventParams['fatal'];
[key: string]: any;
},
options?: firebase.analytics.AnalyticsCallOptions
): void;
/**
* Sends analytics event with given `eventParams`. This method
* automatically associates this logged event with this Firebase web
* app instance on this device.
* List of recommended event parameters can be found in
* {@link https://developers.google.com/gtagjs/reference/ga4-events
* | the GA4 reference documentation}.
*/
logEvent(
eventName: 'generate_lead',
eventParams?: {
value?: EventParams['value'];
currency?: EventParams['currency'];
[key: string]: any;
},
options?: firebase.analytics.AnalyticsCallOptions
): void;
/**
* Sends analytics event with given `eventParams`. This method
* automatically associates this logged event with this Firebase web
* app instance on this device.
* List of recommended event parameters can be found in
* {@link https://developers.google.com/gtagjs/reference/ga4-events
* | the GA4 reference documentation}.
*/
logEvent(
eventName: 'login',
eventParams?: {
method?: EventParams['method'];
[key: string]: any;
},
options?: firebase.analytics.AnalyticsCallOptions
): void;
/**
* Sends analytics event with given `eventParams`. This method
* automatically associates this logged event with this Firebase web
* app instance on this device.
* See
* {@link https://developers.google.com/analytics/devguides/collection/ga4/views
* | Page views}.
*/
logEvent(
eventName: 'page_view',
eventParams?: {
page_title?: string;
page_location?: string;
page_path?: string;
[key: string]: any;
},
options?: firebase.analytics.AnalyticsCallOptions
): void;
/**
* Sends analytics event with given `eventParams`. This method
* automatically associates this logged event with this Firebase web
* app instance on this device.
* List of recommended event parameters can be found in
* {@link https://developers.google.com/gtagjs/reference/ga4-events
* | the GA4 reference documentation}.
*/
logEvent(
eventName: 'purchase' | 'refund',
eventParams?: {
value?: EventParams['value'];
currency?: EventParams['currency'];
transaction_id: EventParams['transaction_id'];
tax?: EventParams['tax'];
shipping?: EventParams['shipping'];
items?: EventParams['items'];
coupon?: EventParams['coupon'];
affiliation?: EventParams['affiliation'];
[key: string]: any;
},
options?: firebase.analytics.AnalyticsCallOptions
): void;
/**
* Sends analytics event with given `eventParams`. This method
* automatically associates this logged event with this Firebase web
* app instance on this device.
* See {@link https://firebase.google.com/docs/analytics/screenviews
* | Track Screenviews}.
*/
logEvent(
eventName: 'screen_view',
eventParams?: {
firebase_screen: EventParams['firebase_screen'];
firebase_screen_class: EventParams['firebase_screen_class'];
[key: string]: any;
},
options?: firebase.analytics.AnalyticsCallOptions
): void;
/**
* Sends analytics event with given `eventParams`. This method
* automatically associates this logged event with this Firebase web
* app instance on this device.
* List of recommended event parameters can be found in
* {@link https://developers.google.com/gtagjs/reference/ga4-events
* | the GA4 reference documentation}.
*/
logEvent(
eventName: 'search' | 'view_search_results',
eventParams?: {
search_term?: EventParams['search_term'];
[key: string]: any;
},
options?: firebase.analytics.AnalyticsCallOptions
): void;
/**
* Sends analytics event with given `eventParams`. This method
* automatically associates this logged event with this Firebase web
* app instance on this device.
* List of recommended event parameters can be found in
* {@link https://developers.google.com/gtagjs/reference/ga4-events
* | the GA4 reference documentation}.
*/
logEvent(
eventName: 'select_content',
eventParams?: {
content_type?: EventParams['content_type'];
item_id?: EventParams['item_id'];
[key: string]: any;
},
options?: firebase.analytics.AnalyticsCallOptions
): void;
/**
* Sends analytics event with given `eventParams`. This method
* automatically associates this logged event with this Firebase web
* app instance on this device.
* List of recommended event parameters can be found in
* {@link https://developers.google.com/gtagjs/reference/ga4-events
* | the GA4 reference documentation}.
*/
logEvent(
eventName: 'select_item',
eventParams?: {
items?: EventParams['items'];
item_list_name?: EventParams['item_list_name'];
item_list_id?: EventParams['item_list_id'];
[key: string]: any;
},
options?: firebase.analytics.AnalyticsCallOptions
): void;
/**
* Sends analytics event with given `eventParams`. This method
* automatically associates this logged event with this Firebase web
* app instance on this device.
* List of recommended event parameters can be found in
* {@link https://developers.google.com/gtagjs/reference/ga4-events
* | the GA4 reference documentation}.
*/
logEvent(
eventName: 'select_promotion' | 'view_promotion',
eventParams?: {
items?: EventParams['items'];
promotion_id?: EventParams['promotion_id'];
promotion_name?: EventParams['promotion_name'];
[key: string]: any;
},
options?: firebase.analytics.AnalyticsCallOptions
): void;
/**
* Sends analytics event with given `eventParams`. This method
* automatically associates this logged event with this Firebase web
* app instance on this device.
* List of recommended event parameters can be found in
* {@link https://developers.google.com/gtagjs/reference/ga4-events
* | the GA4 reference documentation}.
*/
logEvent(
eventName: 'set_checkout_option',
eventParams?: {
checkout_step?: EventParams['checkout_step'];
checkout_option?: EventParams['checkout_option'];
[key: string]: any;
},
options?: firebase.analytics.AnalyticsCallOptions
): void;
/**
* Sends analytics event with given `eventParams`. This method
* automatically associates this logged event with this Firebase web
* app instance on this device.
* List of recommended event parameters can be found in
* {@link https://developers.google.com/gtagjs/reference/ga4-events
* | the GA4 reference documentation}.
*/
logEvent(
eventName: 'share',
eventParams?: {
method?: EventParams['method'];
content_type?: EventParams['content_type'];
item_id?: EventParams['item_id'];
[key: string]: any;
},
options?: firebase.analytics.AnalyticsCallOptions
): void;
/**
* Sends analytics event with given `eventParams`. This method
* automatically associates this logged event with this Firebase web
* app instance on this device.
* List of recommended event parameters can be found in
* {@link https://developers.google.com/gtagjs/reference/ga4-events
* | the GA4 reference documentation}.
*/
logEvent(
eventName: 'sign_up',
eventParams?: {
method?: EventParams['method'];
[key: string]: any;
},
options?: firebase.analytics.AnalyticsCallOptions
): void;
/**
* Sends analytics event with given `eventParams`. This method
* automatically associates this logged event with this Firebase web
* app instance on this device.
* List of recommended event parameters can be found in
* {@link https://developers.google.com/gtagjs/reference/ga4-events
* | the GA4 reference documentation}.
*/
logEvent(
eventName: 'timing_complete',
eventParams?: {
name: string;
value: number;
event_category?: string;
event_label?: string;
[key: string]: any;
},
options?: firebase.analytics.AnalyticsCallOptions
): void;
/**
* Sends analytics event with given `eventParams`. This method
* automatically associates this logged event with this Firebase web
* app instance on this device.
* List of recommended event parameters can be found in
* {@link https://developers.google.com/gtagjs/reference/ga4-events
* | the GA4 reference documentation}.
*/
logEvent(
eventName: 'view_cart' | 'view_item',
eventParams?: {
currency?: EventParams['currency'];
items?: EventParams['items'];
value?: EventParams['value'];
[key: string]: any;
},
options?: firebase.analytics.AnalyticsCallOptions
): void;
/**
* Sends analytics event with given `eventParams`. This method
* automatically associates this logged event with this Firebase web
* app instance on this device.
* List of recommended event parameters can be found in
* {@link https://developers.google.com/gtagjs/reference/ga4-events
* | the GA4 reference documentation}.
*/
logEvent(
eventName: 'view_item_list',
eventParams?: {
items?: EventParams['items'];
item_list_name?: EventParams['item_list_name'];
item_list_id?: EventParams['item_list_id'];
[key: string]: any;
},
options?: firebase.analytics.AnalyticsCallOptions
): void;
/**
* Sends analytics event with given `eventParams`. This method
* automatically associates this logged event with this Firebase web
* app instance on this device.
* List of recommended event parameters can be found in
* {@link https://developers.google.com/gtagjs/reference/ga4-events
* | the GA4 reference documentation}.
*/
logEvent<T extends string>(
eventName: CustomEventName<T>,
eventParams?: { [key: string]: any },
options?: firebase.analytics.AnalyticsCallOptions
): void;
/**
* Use gtag 'config' command to set 'screen_name'.
*
* @deprecated Use {@link logEvent} with `eventName` as 'screen_view' and add relevant `eventParams`.
* See {@link https://firebase.google.com/docs/analytics/screenviews | Track Screenviews}.
*/
setCurrentScreen(
screenName: string,
options?: firebase.analytics.AnalyticsCallOptions
): void;
/**
* Use gtag 'config' command to set 'user_id'.
*/
setUserId(
id: string,
options?: firebase.analytics.AnalyticsCallOptions
): void;
/**
* Use gtag 'config' command to set all params specified.
*/
setUserProperties(
properties: firebase.analytics.CustomParams,
options?: firebase.analytics.AnalyticsCallOptions
): void;
/**
* Sets whether analytics collection is enabled for this app on this device.
* window['ga-disable-analyticsId'] = true;
*/
setAnalyticsCollectionEnabled(enabled: boolean): void;
}
export type CustomEventName<T> = T extends EventNameString ? never : T;
/**
* Additional options that can be passed to Firebase Analytics method
* calls such as `logEvent`, `setCurrentScreen`, etc.
*/
export interface AnalyticsCallOptions {
/**
* If true, this config or event call applies globally to all
* analytics properties on the page.
*/
global: boolean;
}
/**
* Specifies custom options for your Firebase Analytics instance.
* You must set these before initializing `firebase.analytics()`.
*/
export interface SettingsOptions {
/** Sets custom name for `gtag` function. */
gtagName?: string;
/** Sets custom name for `dataLayer` array used by gtag. */
dataLayerName?: string;
}
/**
* Configures Firebase Analytics to use custom `gtag` or `dataLayer` names.
* Intended to be used if `gtag.js` script has been installed on
* this page independently of Firebase Analytics, and is using non-default
* names for either the `gtag` function or for `dataLayer`.
* Must be called before calling `firebase.analytics()` or it won't
* have any effect.
*/
export function settings(settings: firebase.analytics.SettingsOptions): void;
/**
* Standard gtag.js control parameters.
* For more information, see
* {@link https://developers.google.com/gtagjs/reference/parameter
* the gtag.js documentation on parameters}.
*/
export interface ControlParams {
groups?: string | string[];
send_to?: string | string[];
event_callback?: () => void;
event_timeout?: number;
}
/**
* Standard gtag.js event parameters.
* For more information, see
* {@link https://developers.google.com/gtagjs/reference/parameter
* the gtag.js documentation on parameters}.
*/
export interface EventParams {
checkout_option?: string;
checkout_step?: number;
item_id?: string;
content_type?: string;
coupon?: string;
currency?: string;
description?: string;
fatal?: boolean;
items?: Item[];
method?: string;
number?: string;
promotions?: Promotion[];
screen_name?: string;
/**
* Firebase-specific. Use to log a `screen_name` to Firebase Analytics.
*/
firebase_screen?: string;
/**
* Firebase-specific. Use to log a `screen_class` to Firebase Analytics.
*/
firebase_screen_class?: string;
search_term?: string;
shipping?: Currency;
tax?: Currency;
transaction_id?: string;
value?: number;
event_label?: string;
event_category: string;
shipping_tier?: string;
item_list_id?: string;
item_list_name?: string;
promotion_id?: string;
promotion_name?: string;
payment_type?: string;
affiliation?: string;
}
/**
* Any custom params the user may pass to gtag.js.
*/
export interface CustomParams {
[key: string]: any;
}
/**
* Type for standard gtag.js event names. `logEvent` also accepts any
* custom string and interprets it as a custom event name.
*/
export type EventNameString =
| 'add_payment_info'
| 'add_shipping_info'
| 'add_to_cart'
| 'add_to_wishlist'
| 'begin_checkout'
| 'checkout_progress'
| 'exception'
| 'generate_lead'
| 'login'
| 'page_view'
| 'purchase'
| 'refund'
| 'remove_from_cart'
| 'screen_view'
| 'search'
| 'select_content'
| 'select_item'
| 'select_promotion'
| 'set_checkout_option'
| 'share'
| 'sign_up'
| 'timing_complete'
| 'view_cart'
| 'view_item'
| 'view_item_list'
| 'view_promotion'
| 'view_search_results';
/**
* Enum of standard gtag.js event names provided for convenient
* developer usage. `logEvent` will also accept any custom string
* and interpret it as a custom event name.
*/
export enum EventName {
ADD_PAYMENT_INFO = 'add_payment_info',
ADD_SHIPPING_INFO = 'add_shipping_info',
ADD_TO_CART = 'add_to_cart',
ADD_TO_WISHLIST = 'add_to_wishlist',
BEGIN_CHECKOUT = 'begin_checkout',
/** @deprecated */
CHECKOUT_PROGRESS = 'checkout_progress',
EXCEPTION = 'exception',
GENERATE_LEAD = 'generate_lead',
LOGIN = 'login',
PAGE_VIEW = 'page_view',
PURCHASE = 'purchase',
REFUND = 'refund',
REMOVE_FROM_CART = 'remove_from_cart',
SCREEN_VIEW = 'screen_view',
SEARCH = 'search',
SELECT_CONTENT = 'select_content',
SELECT_ITEM = 'select_item',
SELECT_PROMOTION = 'select_promotion',
/** @deprecated */
SET_CHECKOUT_OPTION = 'set_checkout_option',
SHARE = 'share',
SIGN_UP = 'sign_up',
TIMING_COMPLETE = 'timing_complete',
VIEW_CART = 'view_cart',
VIEW_ITEM = 'view_item',
VIEW_ITEM_LIST = 'view_item_list',
VIEW_PROMOTION = 'view_promotion',
VIEW_SEARCH_RESULTS = 'view_search_results'
}
export type Currency = string | number;
export interface Item {
item_id?: string;
item_name?: string;
item_brand?: string;
item_category?: string;
item_category2?: string;
item_category3?: string;
item_category4?: string;
item_category5?: string;
item_variant?: string;
price?: Currency;
quantity?: number;
index?: number;
coupon?: string;
item_list_name?: string;
item_list_id?: string;
discount?: Currency;
affiliation?: string;
creative_name?: string;
creative_slot?: string;
promotion_id?: string;
promotion_name?: string;
location_id?: string;
/** @deprecated Use item_brand instead. */
brand?: string;
/** @deprecated Use item_category instead. */
category?: string;
/** @deprecated Use item_id instead. */
id?: string;
/** @deprecated Use item_name instead. */
name?: string;
}
/** @deprecated Use Item instead. */
export interface Promotion {
creative_name?: string;
creative_slot?: string;
id?: string;
name?: string;
}
/**
* An async function that returns true if current browser context supports initialization of analytics module
* (`firebase.analytics()`).
*
* Returns false otherwise.
*
*
*/
function isSupported(): Promise<boolean>;
}
declare namespace firebase.auth.Auth {
type Persistence = string;
/**
* An enumeration of the possible persistence mechanism types.
*/
var Persistence: {
/**
* Indicates that the state will be persisted even when the browser window is
* closed or the activity is destroyed in react-native.
*/
LOCAL: Persistence;
/**
* Indicates that the state will only be stored in memory and will be cleared
* when the window or activity is refreshed.
*/
NONE: Persistence;
/**
* Indicates that the state will only persist in current session/tab, relevant
* to web only, and will be cleared when the tab is closed.
*/
SESSION: Persistence;
};
}
declare namespace firebase.User {
/**
* This is the interface that defines the multi-factor related properties and
* operations pertaining to a {@link firebase.User}.
*/
interface MultiFactorUser {
/**
* Returns a list of the user's enrolled second factors.
*/
enrolledFactors: firebase.auth.MultiFactorInfo[];
/**
* Enrolls a second factor as identified by the
* {@link firebase.auth.MultiFactorAssertion} for the current user.
* On resolution, the user tokens are updated to reflect the change in the
* JWT payload.
* Accepts an additional display name parameter used to identify the second
* factor to the end user.
* Recent re-authentication is required for this operation to succeed.
* On successful enrollment, existing Firebase sessions (refresh tokens) are
* revoked. When a new factor is enrolled, an email notification is sent
* to the user’s email.
*
* <h4>Error Codes</h4>
* <dl>
* <dt>auth/invalid-verification-code</dt>
* <dd>Thrown if the verification code is not valid.</dd>
* <dt>auth/missing-verification-code</dt>
* <dd>Thrown if the verification code is missing.</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>
* <dt>auth/missing-verification-id</dt>
* <dd>Thrown if the verification ID is missing.</dd>
* <dt>auth/code-expired</dt>
* <dd>Thrown if the verification code has expired.</dd>
* <dt>auth/maximum-second-factor-count-exceeded</dt>
* <dd>Thrown if The maximum allowed number of second factors on a user
* has been exceeded.</dd>
* <dt>auth/second-factor-already-in-use</dt>
* <dd>Thrown if the second factor is already enrolled on this account.</dd>
* <dt>auth/unsupported-first-factor</dt>
* <dd>Thrown if the first factor being used to sign in is not supported.</dd>
* <dt>auth/unverified-email</dt>
* <dd>Thrown if the email of the account is not verified.</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.</dd>
* </dl>
*
* @example
* ```javascript
* firebase.auth().currentUser.multiFactor.getSession()
* .then(function(multiFactorSession) {
* // Send verification code
* var phoneAuthProvider = new firebase.auth.PhoneAuthProvider();
* var phoneInfoOptions = {
* phoneNumber: phoneNumber,
* session: multiFactorSession
* };
* return phoneAuthProvider.verifyPhoneNumber(
* phoneInfoOptions, appVerifier);
* }).then(function(verificationId) {
* // Store verificationID and show UI to let user enter verification code.
* });
*
* var phoneAuthCredential =
* firebase.auth.PhoneAuthProvider.credential(verificationId, verificationCode);
* var multiFactorAssertion =
* firebase.auth.PhoneMultiFactorGenerator.assertion(phoneAuthCredential);
* firebase.auth().currentUser.multiFactor.enroll(multiFactorAssertion)
* .then(function() {
* // Second factor enrolled.
* });
* ```
*
* @param assertion The multi-factor assertion to enroll with.
* @param displayName The display name of the second factor.
*/
enroll(
assertion: firebase.auth.MultiFactorAssertion,
displayName?: string | null
): Promise<void>;
/**
* Returns the session identifier for a second factor enrollment operation.
* This is used to identify the current user trying to enroll a second factor.
* @return The promise that resolves with the
* {@link firebase.auth.MultiFactorSession}.
*
* <h4>Error Codes</h4>
* <dl>
* <dt>auth/user-token-expired</dt>
* <dd>Thrown if the token of the user is expired.</dd>
* </dl>
*/
getSession(): Promise<firebase.auth.MultiFactorSession>;
/**
* Unenrolls the specified second factor. To specify the factor to remove, pass
* a {@link firebase.auth.MultiFactorInfo} object
* (retrieved from <code>enrolledFactors()</code>)
* or the factor's UID string.
* Sessions are not revoked when the account is downgraded. An email
* notification is likely to be sent to the user notifying them of the change.
* Recent re-authentication is required for this operation to succeed.
* When an existing factor is unenrolled, an email notification is sent to the
* user’s email.
*
* <h4>Error Codes</h4>
* <dl>
* <dt>auth/multi-factor-info-not-found</dt>
* <dd>Thrown if the user does not have a second factor matching the
* identifier provided.</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.</dd>
* </dl>
*
* @example
* ```javascript
* var options = firebase.auth().currentUser.multiFactor.enrolledFactors;
* // Present user the option to unenroll.
* return firebase.auth().currentUser.multiFactor.unenroll(options[i])
* .then(function() {
* // User successfully unenrolled selected factor.
* }).catch(function(error) {
* // Handler error.
* });
* ```
*
* @param option The multi-factor option to unenroll.
*/
unenroll(option: firebase.auth.MultiFactorInfo | string): Promise<void>;
}
}
declare namespace firebase.auth.ActionCodeInfo {
type Operation = string;
/**
* An enumeration of the possible email action types.
*/
var Operation: {
/**
* The email link sign-in action.
*/
EMAIL_SIGNIN: Operation;
/**
* The password reset action.
*/
PASSWORD_RESET: Operation;
/**
* The email revocation action.
*/
RECOVER_EMAIL: Operation;
/**
* The revert second factor addition email action.
*/
REVERT_SECOND_FACTOR_ADDITION: Operation;
/**
* The verify and update email action.
*/
VERIFY_AND_CHANGE_EMAIL: Operation;
/**
* The email verification action.
*/
VERIFY_EMAIL: Operation;
};
}
declare namespace firebase.database {
/**
* A `DataSnapshot` contains data from a Database location.
*
* Any time you read data from the Database, you receive the data as a
* `DataSnapshot`. A `DataSnapshot` is passed to the event callbacks you attach
* with `on()` or `once()`. You can extract the contents of the snapshot as a
* JavaScript object by calling the `val()` method. Alternatively, you can
* traverse into the snapshot by calling `child()` to return child snapshots
* (which you could then call `val()` on).
*
* A `DataSnapshot` is an efficiently generated, immutable copy of the data at
* a Database location. It cannot be modified and will never change (to modify
* data, you always call the `set()` method on a `Reference` directly).
*
*/
interface DataSnapshot {
/**
* Gets another `DataSnapshot` for the location at the specified relative path.
*
* Passing a relative path to the `child()` method of a DataSnapshot returns
* another `DataSnapshot` for the location at the specified relative path. The
* relative path can either be a simple child name (for example, "ada") or a
* deeper, slash-separated path (for example, "ada/name/first"). If the child
* location has no data, an empty `DataSnapshot` (that is, a `DataSnapshot`
* whose value is `null`) is returned.
*
* @example
* ```javascript
* // Assume we have the following data in the Database:
* {
* "name": {
* "first": "Ada",
* "last": "Lovelace"
* }
* }
*
* // Test for the existence of certain keys within a DataSnapshot
* var ref = firebase.database().ref("users/ada");
* ref.once("value")
* .then(function(snapshot) {
* var name = snapshot.child("name").val(); // {first:"Ada",last:"Lovelace"}
* var firstName = snapshot.child("name/first").val(); // "Ada"
* var lastName = snapshot.child("name").child("last").val(); // "Lovelace"
* var age = snapshot.child("age").val(); // null
* });
* ```
*
* @param path A relative path to the location of child data.
*/
child(path: string): firebase.database.DataSnapshot;
/**
* Returns true if this `DataSnapshot` contains any data. It is slightly more
* efficient than using `snapshot.val() !== null`.
*
* @example
* ```javascript
* // Assume we have the following data in the Database:
* {
* "name": {
* "first": "Ada",
* "last": "Lovelace"
* }
* }
*
* // Test for the existence of certain keys within a DataSnapshot
* var ref = firebase.database().ref("users/ada");
* ref.once("value")
* .then(function(snapshot) {
* var a = snapshot.exists(); // true
* var b = snapshot.child("name").exists(); // true
* var c = snapshot.child("name/first").exists(); // true
* var d = snapshot.child("name/middle").exists(); // false
* });
* ```
*/
exists(): boolean;
/**
* Exports the entire contents of the DataSnapshot as a JavaScript object.
*
* The `exportVal()` method is similar to `val()`, except priority information
* is included (if available), making it suitable for backing up your data.
*
* @return The DataSnapshot's contents as a JavaScript value (Object,
* Array, string, number, boolean, or `null`).
*/
exportVal(): any;
/**
* Enumerates the top-level children in the `DataSnapshot`.
*
* Because of the way JavaScript objects work, the ordering of data in the
* JavaScript object returned by `val()` is not guaranteed to match the ordering
* on the server nor the ordering of `child_added` events. That is where
* `forEach()` comes in handy. It guarantees the children of a `DataSnapshot`
* will be iterated in their query order.
*
* If no explicit `orderBy*()` method is used, results are returned
* ordered by key (unless priorities are used, in which case, results are
* returned by priority).
*
* @example
* ```javascript
* // Assume we have the following data in the Database:
* {
* "users": {
* "ada": {
* "first": "Ada",
* "last": "Lovelace"
* },
* "alan": {
* "first": "Alan",
* "last": "Turing"
* }
* }
* }
*
* // Loop through users in order with the forEach() method. The callback
* // provided to forEach() will be called synchronously with a DataSnapshot
* // for each child:
* var query = firebase.database().ref("users").orderByKey();
* query.once("value")
* .then(function(snapshot) {
* snapshot.forEach(function(childSnapshot) {
* // key will be "ada" the first time and "alan" the second time
* var key = childSnapshot.key;
* // childData will be the actual contents of the child
* var childData = childSnapshot.val();
* });
* });
* ```
*
* @example
* ```javascript
* // You can cancel the enumeration at any point by having your callback
* // function return true. For example, the following code sample will only
* // fire the callback function one time:
* var query = firebase.database().ref("users").orderByKey();
* query.once("value")
* .then(function(snapshot) {
* snapshot.forEach(function(childSnapshot) {
* var key = childSnapshot.key; // "ada"
*
* // Cancel enumeration
* return true;
* });
* });
* ```
*
* @param action A function
* that will be called for each child DataSnapshot. The callback can return
* true to cancel further enumeration.
* @return true if enumeration was canceled due to your callback
* returning true.
*/
forEach(
action: (a: firebase.database.IteratedDataSnapshot) => boolean | void
): boolean;
/**
* Gets the priority value of the data in this `DataSnapshot`.
*
* Applications need not use priority but can order collections by
* ordinary properties (see
* {@link
* https://firebase.google.com/docs/database/web/lists-of-data#sorting_and_filtering_data
* Sorting and filtering data}).
*/
getPriority(): string | number | null;
/**
* Returns true if the specified child path has (non-null) data.
*
* @example
* ```javascript
* // Assume we have the following data in the Database:
* {
* "name": {
* "first": "Ada",
* "last": "Lovelace"
* }
* }
*
* // Determine which child keys in DataSnapshot have data.
* var ref = firebase.database().ref("users/ada");
* ref.once("value")
* .then(function(snapshot) {
* var hasName = snapshot.hasChild("name"); // true
* var hasAge = snapshot.hasChild("age"); // false
* });
* ```
*
* @param path A relative path to the location of a potential child.
* @return `true` if data exists at the specified child path; else
* `false`.
*/
hasChild(path: string): boolean;
/**
* Returns whether or not the `DataSnapshot` has any non-`null` child
* properties.
*
* You can use `hasChildren()` to determine if a `DataSnapshot` has any
* children. If it does, you can enumerate them using `forEach()`. If it
* doesn't, then either this snapshot contains a primitive value (which can be
* retrieved with `val()`) or it is empty (in which case, `val()` will return
* `null`).
*
* @example
* ```javascript
* // Assume we have the following data in the Database:
* {
* "name": {
* "first": "Ada",
* "last": "Lovelace"
* }
* }
*
* var ref = firebase.database().ref("users/ada");
* ref.once("value")
* .then(function(snapshot) {
* var a = snapshot.hasChildren(); // true
* var b = snapshot.child("name").hasChildren(); // true
* var c = snapshot.child("name/first").hasChildren(); // false
* });
* ```
*
* @return true if this snapshot has any children; else false.
*/
hasChildren(): boolean;
/**
* The key (last part of the path) of the location of this `DataSnapshot`.
*
* The last token in a Database location is considered its key. For example,
* "ada" is the key for the /users/ada/ node. Accessing the key on any
* `DataSnapshot` will return the key for the location that generated it.
* However, accessing the key on the root URL of a Database will return `null`.
*
* @example
* ```javascript
* // Assume we have the following data in the Database:
* {
* "name": {
* "first": "Ada",
* "last": "Lovelace"
* }
* }
*
* var ref = firebase.database().ref("users/ada");
* ref.once("value")
* .then(function(snapshot) {
* var key = snapshot.key; // "ada"
* var childKey = snapshot.child("name/last").key; // "last"
* });
* ```
*
* @example
* ```javascript
* var rootRef = firebase.database().ref();
* rootRef.once("value")
* .then(function(snapshot) {
* var key = snapshot.key; // null
* var childKey = snapshot.child("users/ada").key; // "ada"
* });
* ```
*/
key: string | null;
/**
* Returns the number of child properties of this `DataSnapshot`.
*
* @example
* ```javascript
* // Assume we have the following data in the Database:
* {
* "name": {
* "first": "Ada",
* "last": "Lovelace"
* }
* }
*
* var ref = firebase.database().ref("users/ada");
* ref.once("value")
* .then(function(snapshot) {
* var a = snapshot.numChildren(); // 1 ("name")
* var b = snapshot.child("name").numChildren(); // 2 ("first", "last")
* var c = snapshot.child("name/first").numChildren(); // 0
* });
* ```
*/
numChildren(): number;
/**
* Extracts a JavaScript value from a `DataSnapshot`.
*
* Depending on the data in a `DataSnapshot`, the `val()` method may return a
* scalar type (string, number, or boolean), an array, or an object. It may also
* return null, indicating that the `DataSnapshot` is empty (contains no data).
*
* @example
* ```javascript
* // Write and then read back a string from the Database.
* ref.set("hello")
* .then(function() {
* return ref.once("value");
* })
* .then(function(snapshot) {
* var data = snapshot.val(); // data === "hello"
* });
* ```
*
* @example
* ```javascript
* // Write and then read back a JavaScript object from the Database.
* ref.set({ name: "Ada", age: 36 })
* .then(function() {
* return ref.once("value");
* })
* .then(function(snapshot) {
* var data = snapshot.val();
* // data is { "name": "Ada", "age": 36 }
* // data.name === "Ada"
* // data.age === 36
* });
* ```
*
* @return The DataSnapshot's contents as a JavaScript value (Object,
* Array, string, number, boolean, or `null`).
*/
val(): any;
/**
* The `Reference` for the location that generated this `DataSnapshot`.
*/
ref: firebase.database.Reference;
/**
* Returns a JSON-serializable representation of this object.
*/
toJSON(): Object | null;
}
interface IteratedDataSnapshot extends DataSnapshot {
key: string; // key of the location of this snapshot.
}
/**
* The Firebase Database service interface.
*
* Do not call this constructor directly. Instead, use
* {@link firebase.database `firebase.database()`}.
*
* See
* {@link
* https://firebase.google.com/docs/database/web/start/
* Installation & Setup in JavaScript}
* for a full guide on how to use the Firebase Database service.
*/
interface Database {
/**
* The {@link firebase.app.App app} associated with the `Database` service
* instance.
*
* @example
* ```javascript
* var app = database.app;
* ```
*/
app: firebase.app.App;
/**
* Additional methods for debugging and special cases.
*
*/
INTERNAL: {
/**
* Force the use of WebSockets instead of long polling.
*/
forceWebSockets: () => void;
/**
* Force the use of long polling instead of WebSockets. This will be ignored if the WebSocket protocol is used in `databaseURL`.
*/
forceLongPolling: () => void;
};
/**
* Modify this instance to communicate with the Realtime Database emulator.
*
* <p>Note: This method must be called before performing any other operation.
*
* @param host the emulator host (ex: localhost)
* @param port the emulator port (ex: 8080)
* @param options.mockUserToken the mock auth token to use for unit testing Security Rules
*/
useEmulator(
host: string,
port: number,
options?: {
mockUserToken?: EmulatorMockTokenOptions | string;
}
): void;
/**
* Disconnects from the server (all Database operations will be completed
* offline).
*
* The client automatically maintains a persistent connection to the Database
* server, which will remain active indefinitely and reconnect when
* disconnected. However, the `goOffline()` and `goOnline()` methods may be used
* to control the client connection in cases where a persistent connection is
* undesirable.
*
* While offline, the client will no longer receive data updates from the
* Database. However, all Database operations performed locally will continue to
* immediately fire events, allowing your application to continue behaving
* normally. Additionally, each operation performed locally will automatically
* be queued and retried upon reconnection to the Database server.
*
* To reconnect to the Database and begin receiving remote events, see
* `goOnline()`.
*
* @example
* ```javascript
* firebase.database().goOffline();
* ```
*/
goOffline(): any;
/**
* Reconnects to the server and synchronizes the offline Database state
* with the server state.
*
* This method should be used after disabling the active connection with
* `goOffline()`. Once reconnected, the client will transmit the proper data
* and fire the appropriate events so that your client "catches up"
* automatically.
*
* @example
* ```javascript
* firebase.database().goOnline();
* ```
*/
goOnline(): any;
/**
* Returns a `Reference` representing the location in the Database
* corresponding to the provided path. If no path is provided, the `Reference`
* will point to the root of the Database.
*
* @example
* ```javascript
* // Get a reference to the root of the Database
* var rootRef = firebase.database().ref();
* ```
*
* @example
* ```javascript
* // Get a reference to the /users/ada node
* var adaRef = firebase.database().ref("users/ada");
* // The above is shorthand for the following operations:
* //var rootRef = firebase.database().ref();
* //var adaRef = rootRef.child("users/ada");
* ```
*
* @param path Optional path representing the location the returned
* `Reference` will point. If not provided, the returned `Reference` will
* point to the root of the Database.
* @return If a path is provided, a `Reference`
* pointing to the provided path. Otherwise, a `Reference` pointing to the
* root of the Database.
*/
ref(path?: string): firebase.database.Reference;
/**
* Returns a `Reference` representing the location in the Database
* corresponding to the provided Firebase URL.
*
* An exception is thrown if the URL is not a valid Firebase Database URL or it
* has a different domain than the current `Database` instance.
*
* Note that all query parameters (`orderBy`, `limitToLast`, etc.) are ignored
* and are not applied to the returned `Reference`.
*
* @example
* ```javascript
* // Get a reference to the root of the Database
* var rootRef = firebase.database().ref("https://<DATABASE_NAME>.firebaseio.com");
* ```
*
* @example
* ```javascript
* // Get a reference to the /users/ada node
* var adaRef = firebase.database().ref("https://<DATABASE_NAME>.firebaseio.com/users/ada");
* ```
*
* @param url The Firebase URL at which the returned `Reference` will
* point.
* @return A `Reference` pointing to the provided
* Firebase URL.
*/
refFromURL(url: string): firebase.database.Reference;
}
/**
* The `onDisconnect` class allows you to write or clear data when your client
* disconnects from the Database server. These updates occur whether your
* client disconnects cleanly or not, so you can rely on them to clean up data
* even if a connection is dropped or a client crashes.
*
* The `onDisconnect` class is most commonly used to manage presence in
* applications where it is useful to detect how many clients are connected and
* when other clients disconnect. See
* {@link
* https://firebase.google.com/docs/database/web/offline-capabilities
* Enabling Offline Capabilities in JavaScript} for more information.
*
* To avoid problems when a connection is dropped before the requests can be
* transferred to the Database server, these functions should be called before
* writing any data.
*
* Note that `onDisconnect` operations are only triggered once. If you want an
* operation to occur each time a disconnect occurs, you'll need to re-establish
* the `onDisconnect` operations each time you reconnect.
*/
interface OnDisconnect {
/**
* Cancels all previously queued `onDisconnect()` set or update events for this
* location and all children.
*
* If a write has been queued for this location via a `set()` or `update()` at a
* parent location, the write at this location will be canceled, though writes
* to sibling locations will still occur.
*
* @example
* ```javascript
* var ref = firebase.database().ref("onlineState");
* ref.onDisconnect().set(false);
* // ... sometime later
* ref.onDisconnect().cancel();
* ```
*
* @param onComplete An optional callback function that will
* be called when synchronization to the server has completed. The callback
* will be passed a single parameter: null for success, or an Error object
* indicating a failure.
* @return Resolves when synchronization to the server
* is complete.
*/
cancel(onComplete?: (a: Error | null) => any): Promise<any>;
/**
* Ensures the data at this location is deleted when the client is disconnected
* (due to closing the browser, navigating to a new page, or network issues).
*
* @param onComplete An optional callback function that will
* be called when synchronization to the server has completed. The callback
* will be passed a single parameter: null for success, or an Error object
* indicating a failure.
* @return Resolves when synchronization to the server
* is complete.
*/
remove(onComplete?: (a: Error | null) => any): Promise<any>;
/**
* Ensures the data at this location is set to the specified value when the
* client is disconnected (due to closing the browser, navigating to a new page,
* or network issues).
*
* `set()` is especially useful for implementing "presence" systems, where a
* value should be changed or cleared when a user disconnects so that they
* appear "offline" to other users. See
* {@link
* https://firebase.google.com/docs/database/web/offline-capabilities
* Enabling Offline Capabilities in JavaScript} for more information.
*
* Note that `onDisconnect` operations are only triggered once. If you want an
* operation to occur each time a disconnect occurs, you'll need to re-establish
* the `onDisconnect` operations each time.
*
* @example
* ```javascript
* var ref = firebase.database().ref("users/ada/status");
* ref.onDisconnect().set("I disconnected!");
* ```
*
* @param value The value to be written to this location on
* disconnect (can be an object, array, string, number, boolean, or null).
* @param onComplete An optional callback function that
* will be called when synchronization to the Database server has completed.
* The callback will be passed a single parameter: null for success, or an
* `Error` object indicating a failure.
* @return Resolves when synchronization to the
* Database is complete.
*/
set(value: any, onComplete?: (a: Error | null) => any): Promise<any>;
/**
* Ensures the data at this location is set to the specified value and priority
* when the client is disconnected (due to closing the browser, navigating to a
* new page, or network issues).
*/
setWithPriority(
value: any,
priority: number | string | null,
onComplete?: (a: Error | null) => any
): Promise<any>;
/**
* Writes multiple values at this location when the client is disconnected (due
* to closing the browser, navigating to a new page, or network issues).
*
* The `values` argument contains multiple property-value pairs that will be
* written to the Database together. Each child property can either be a simple
* property (for example, "name") or a relative path (for example, "name/first")
* from the current location to the data to update.
*
* As opposed to the `set()` method, `update()` can be use to selectively update
* only the referenced properties at the current location (instead of replacing
* all the child properties at the current location).
*
* See more examples using the connected version of
* {@link firebase.database.Reference.update `update()`}.
*
* @example
* ```javascript
* var ref = firebase.database().ref("users/ada");
* ref.update({
* onlineState: true,
* status: "I'm online."
* });
* ref.onDisconnect().update({
* onlineState: false,
* status: "I'm offline."
* });
* ```
*
* @param values Object containing multiple values.
* @param onComplete An optional callback function that will
* be called when synchronization to the server has completed. The
* callback will be passed a single parameter: null for success, or an Error
* object indicating a failure.
* @return Resolves when synchronization to the
* Database is complete.
*/
update(values: Object, onComplete?: (a: Error | null) => any): Promise<any>;
}
type EventType =
| 'value'
| 'child_added'
| 'child_changed'
| 'child_moved'
| 'child_removed';
/**
* A `Query` sorts and filters the data at a Database location so only a subset
* of the child data is included. This can be used to order a collection of
* data by some attribute (for example, height of dinosaurs) as well as to
* restrict a large list of items (for example, chat messages) down to a number
* suitable for synchronizing to the client. Queries are created by chaining
* together one or more of the filter methods defined here.
*
* Just as with a `Reference`, you can receive data from a `Query` by using the
* `on()` method. You will only receive events and `DataSnapshot`s for the
* subset of the data that matches your query.
*
* Read our documentation on
* {@link
* https://firebase.google.com/docs/database/web/lists-of-data#sorting_and_filtering_data
* Sorting and filtering data} for more information.
*/
interface Query {
/**
* Creates a `Query` with the specified ending point.
*
* Using `startAt()`, `startAfter()`, `endBefore()`, `endAt()` and `equalTo()`
* allows you to choose arbitrary starting and ending points for your queries.
*
* The ending point is inclusive, so children with exactly the specified value
* will be included in the query. The optional key argument can be used to
* further limit the range of the query. If it is specified, then children that
* have exactly the specified value must also have a key name less than or equal
* to the specified key.
*
* You can read more about `endAt()` in
* {@link
* https://firebase.google.com/docs/database/web/lists-of-data#filtering_data
* Filtering data}.
*
* @example
* ```javascript
* // Find all dinosaurs whose names come before Pterodactyl lexicographically.
* // Include Pterodactyl in the result.
* var ref = firebase.database().ref("dinosaurs");
* ref.orderByKey().endAt("pterodactyl").on("child_added", function(snapshot) {
* console.log(snapshot.key);
* });
* ```
*
* @param value The value to end at. The argument
* type depends on which `orderBy*()` function was used in this query.
* Specify a value that matches the `orderBy*()` type. When used in
* combination with `orderByKey()`, the value must be a string.
* @param key The child key to end at, among the children with the
* previously specified priority. This argument is only allowed if ordering by
* child, value, or priority.
*/
endAt(
value: number | string | boolean | null,
key?: string
): firebase.database.Query;
/**
* Creates a `Query` with the specified ending point (exclusive).
*
* Using `startAt()`, `startAfter()`, `endBefore()`, `endAt()` and `equalTo()`
* allows you to choose arbitrary starting and ending points for your queries.
*
* The ending point is exclusive. If only a value is provided, children
* with a value less than the specified value will be included in the query.
* If a key is specified, then children must have a value less than or equal
* to the specified value and a a key name less than the specified key.
*
* @example
* ```javascript
* // Find all dinosaurs whose names come before Pterodactyl lexicographically.
* // Do not include Pterodactyl in the result.
* var ref = firebase.database().ref("dinosaurs");
* ref.orderByKey().endBefore("pterodactyl").on("child_added", function(snapshot) {
* console.log(snapshot.key);
* });
*
* @param value The value to end before. The argument
* type depends on which `orderBy*()` function was used in this query.
* Specify a value that matches the `orderBy*()` type. When used in
* combination with `orderByKey()`, the value must be a string.
* @param key The child key to end before, among the children with the
* previously specified priority. This argument is only allowed if ordering by
* child, value, or priority.
*/
endBefore(
value: number | string | boolean | null,
key?: string
): firebase.database.Query;
/**
* Creates a `Query` that includes children that match the specified value.
*
* Using `startAt()`, `startAfter()`, `endBefore()`, `endAt()` and `equalTo()`
* allows you to choose arbitrary starting and ending points for your queries.
*
* The optional key argument can be used to further limit the range of the
* query. If it is specified, then children that have exactly the specified
* value must also have exactly the specified key as their key name. This can be
* used to filter result sets with many matches for the same value.
*
* You can read more about `equalTo()` in
* {@link
* https://firebase.google.com/docs/database/web/lists-of-data#filtering_data
* Filtering data}.
*
* @example
* ```javascript
* // Find all dinosaurs whose height is exactly 25 meters.
* var ref = firebase.database().ref("dinosaurs");
* ref.orderByChild("height").equalTo(25).on("child_added", function(snapshot) {
* console.log(snapshot.key);
* });
* ```
*
* @param value The value to match for. The
* argument type depends on which `orderBy*()` function was used in this
* query. Specify a value that matches the `orderBy*()` type. When used in
* combination with `orderByKey()`, the value must be a string.
* @param key The child key to start at, among the children with the
* previously specified priority. This argument is only allowed if ordering by
* child, value, or priority.
*/
equalTo(
value: number | string | boolean | null,
key?: string
): firebase.database.Query;
/**
* Returns whether or not the current and provided queries represent the same
* location, have the same query parameters, and are from the same instance of
* `firebase.app.App`.
*
* Two `Reference` objects are equivalent if they represent the same location
* and are from the same instance of `firebase.app.App`.
*
* Two `Query` objects are equivalent if they represent the same location, have
* the same query parameters, and are from the same instance of
* `firebase.app.App`. Equivalent queries share the same sort order, limits, and
* starting and ending points.
*
* @example
* ```javascript
* var rootRef = firebase.database.ref();
* var usersRef = rootRef.child("users");
*
* usersRef.isEqual(rootRef); // false
* usersRef.isEqual(rootRef.child("users")); // true
* usersRef.parent.isEqual(rootRef); // true
* ```
*
* @example
* ```javascript
* var rootRef = firebase.database.ref();
* var usersRef = rootRef.child("users");
* var usersQuery = usersRef.limitToLast(10);
*
* usersQuery.isEqual(usersRef); // false
* usersQuery.isEqual(usersRef.limitToLast(10)); // true
* usersQuery.isEqual(rootRef.limitToLast(10)); // false
* usersQuery.isEqual(usersRef.orderByKey().limitToLast(10)); // false
* ```
*
* @param other The query to compare against.
* @return Whether or not the current and provided queries are
* equivalent.
*/
isEqual(other: firebase.database.Query | null): boolean;
/**
* Generates a new `Query` limited to the first specific number of children.
*
* The `limitToFirst()` method is used to set a maximum number of children to be
* synced for a given callback. If we set a limit of 100, we will initially only
* receive up to 100 `child_added` events. If we have fewer than 100 messages
* stored in our Database, a `child_added` event will fire for each message.
* However, if we have over 100 messages, we will only receive a `child_added`
* event for the first 100 ordered messages. As items change, we will receive
* `child_removed` events for each item that drops out of the active list so
* that the total number stays at 100.
*
* You can read more about `limitToFirst()` in
* {@link
* https://firebase.google.com/docs/database/web/lists-of-data#filtering_data
* Filtering data}.
*
* @example
* ```javascript
* // Find the two shortest dinosaurs.
* var ref = firebase.database().ref("dinosaurs");
* ref.orderByChild("height").limitToFirst(2).on("child_added", function(snapshot) {
* // This will be called exactly two times (unless there are less than two
* // dinosaurs in the Database).
*
* // It will also get fired again if one of the first two dinosaurs is
* // removed from the data set, as a new dinosaur will now be the second
* // shortest.
* console.log(snapshot.key);
* });
* ```
*
* @param limit The maximum number of nodes to include in this query.
*/
limitToFirst(limit: number): firebase.database.Query;
/**
* Generates a new `Query` object limited to the last specific number of
* children.
*
* The `limitToLast()` method is used to set a maximum number of children to be
* synced for a given callback. If we set a limit of 100, we will initially only
* receive up to 100 `child_added` events. If we have fewer than 100 messages
* stored in our Database, a `child_added` event will fire for each message.
* However, if we have over 100 messages, we will only receive a `child_added`
* event for the last 100 ordered messages. As items change, we will receive
* `child_removed` events for each item that drops out of the active list so
* that the total number stays at 100.
*
* You can read more about `limitToLast()` in
* {@link
* https://firebase.google.com/docs/database/web/lists-of-data#filtering_data
* Filtering data}.
*
* @example
* ```javascript
* // Find the two heaviest dinosaurs.
* var ref = firebase.database().ref("dinosaurs");
* ref.orderByChild("weight").limitToLast(2).on("child_added", function(snapshot) {
* // This callback will be triggered exactly two times, unless there are
* // fewer than two dinosaurs stored in the Database. It will also get fired
* // for every new, heavier dinosaur that gets added to the data set.
* console.log(snapshot.key);
* });
* ```
*
* @param limit The maximum number of nodes to include in this query.
*/
limitToLast(limit: number): firebase.database.Query;
/**
* Detaches a callback previously attached with `on()`.
*
* Detach a callback previously attached with `on()`. Note that if `on()` was
* called multiple times with the same eventType and callback, the callback
* will be called multiple times for each event, and `off()` must be called
* multiple times to remove the callback. Calling `off()` on a parent listener
* will not automatically remove listeners registered on child nodes, `off()`
* must also be called on any child listeners to remove the callback.
*
* If a callback is not specified, all callbacks for the specified eventType
* will be removed. Similarly, if no eventType is specified, all callbacks
* for the `Reference` will be removed.
*
* @example
* ```javascript
* var onValueChange = function(dataSnapshot) { ... };
* ref.on('value', onValueChange);
* ref.child('meta-data').on('child_added', onChildAdded);
* // Sometime later...
* ref.off('value', onValueChange);
*
* // You must also call off() for any child listeners on ref
* // to cancel those callbacks
* ref.child('meta-data').off('child_added', onValueAdded);
* ```
*
* @example
* ```javascript
* // Or you can save a line of code by using an inline function
* // and on()'s return value.
* var onValueChange = ref.on('value', function(dataSnapshot) { ... });
* // Sometime later...
* ref.off('value', onValueChange);
* ```
*
* @param eventType One of the following strings: "value",
* "child_added", "child_changed", "child_removed", or "child_moved." If
* omitted, all callbacks for the `Reference` will be removed.
* @param callback The callback function that was passed to `on()` or
* `undefined` to remove all callbacks.
* @param context The context that was passed to `on()`.
*/
off(
eventType?: EventType,
callback?: (a: firebase.database.DataSnapshot, b?: string | null) => any,
context?: Object | null
): void;
/**
* Gets the most up-to-date result for this query.
*
* @return A promise which resolves to the resulting DataSnapshot if
* a value is available, or rejects if the client is unable to return
* a value (e.g., if the server is unreachable and there is nothing
* cached).
*/
get(): Promise<DataSnapshot>;
/**
* Listens for data changes at a particular location.
*
* This is the primary way to read data from a Database. Your callback
* will be triggered for the initial data and again whenever the data changes.
* Use `off( )` to stop receiving updates. See
* {@link https://firebase.google.com/docs/database/web/retrieve-data
* Retrieve Data on the Web}
* for more details.
*
* <h4>value event</h4>
*
* This event will trigger once with the initial data stored at this location,
* and then trigger again each time the data changes. The `DataSnapshot` passed
* to the callback will be for the location at which `on()` was called. It
* won't trigger until the entire contents has been synchronized. If the
* location has no data, it will be triggered with an empty `DataSnapshot`
* (`val()` will return `null`).
*
* <h4>child_added event</h4>
*
* This event will be triggered once for each initial child at this location,
* and it will be triggered again every time a new child is added. The
* `DataSnapshot` passed into the callback will reflect the data for the
* relevant child. For ordering purposes, it is passed a second argument which
* is a string containing the key of the previous sibling child by sort order,
* or `null` if it is the first child.
*
* <h4>child_removed event</h4>
*
* This event will be triggered once every time a child is removed. The
* `DataSnapshot` passed into the callback will be the old data for the child
* that was removed. A child will get removed when either:
*
* - a client explicitly calls `remove()` on that child or one of its ancestors
* - a client calls `set(null)` on that child or one of its ancestors
* - that child has all of its children removed
* - there is a query in effect which now filters out the child (because it's
* sort order changed or the max limit was hit)
*
* <h4>child_changed event</h4>
*
* This event will be triggered when the data stored in a child (or any of its
* descendants) changes. Note that a single `child_changed` event may represent
* multiple changes to the child. The `DataSnapshot` passed to the callback will
* contain the new child contents. For ordering purposes, the callback is also
* passed a second argument which is a string containing the key of the previous
* sibling child by sort order, or `null` if it is the first child.
*
* <h4>child_moved event</h4>
*
* This event will be triggered when a child's sort order changes such that its
* position relative to its siblings changes. The `DataSnapshot` passed to the
* callback will be for the data of the child that has moved. It is also passed
* a second argument which is a string containing the key of the previous
* sibling child by sort order, or `null` if it is the first child.
*
* @example **Handle a new value:**
* ```javascript
* ref.on('value', function(dataSnapshot) {
* ...
* });
* ```
*
* @example **Handle a new child:**
* ```javascript
* ref.on('child_added', function(childSnapshot, prevChildKey) {
* ...
* });
* ```
*
* @example **Handle child removal:**
* ```javascript
* ref.on('child_removed', function(oldChildSnapshot) {
* ...
* });
* ```
*
* @example **Handle child data changes:**
* ```javascript
* ref.on('child_changed', function(childSnapshot, prevChildKey) {
* ...
* });
* ```
*
* @example **Handle child ordering changes:**
* ```javascript
* ref.on('child_moved', function(childSnapshot, prevChildKey) {
* ...
* });
* ```
*
* @param eventType One of the following strings: "value",
* "child_added", "child_changed", "child_removed", or "child_moved."
* @param callback A
* callback that fires when the specified event occurs. The callback will be
* passed a DataSnapshot. For ordering purposes, "child_added",
* "child_changed", and "child_moved" will also be passed a string containing
* the key of the previous child, by sort order, or `null` if it is the
* first child.
* @param cancelCallbackOrContext An optional
* callback that will be notified if your event subscription is ever canceled
* because your client does not have permission to read this data (or it had
* permission but has now lost it). This callback will be passed an `Error`
* object indicating why the failure occurred.
* @param context If provided, this object will be used as `this`
* when calling your callback(s).
* @return The provided
* callback function is returned unmodified. This is just for convenience if
* you want to pass an inline function to `on()` but store the callback
* function for later passing to `off()`.
*/
on(
eventType: EventType,
callback: (a: firebase.database.DataSnapshot, b?: string | null) => any,
cancelCallbackOrContext?: ((a: Error) => any) | Object | null,
context?: Object | null
): (a: firebase.database.DataSnapshot | null, b?: string | null) => any;
/**
* Listens for exactly one event of the specified event type, and then stops
* listening.
*
* This is equivalent to calling {@link firebase.database.Query.on `on()`}, and
* then calling {@link firebase.database.Query.off `off()`} inside the callback
* function. See {@link firebase.database.Query.on `on()`} for details on the
* event types.
*
* @example
* ```javascript
* // Basic usage of .once() to read the data located at ref.
* ref.once('value')
* .then(function(dataSnapshot) {
* // handle read data.
* });
* ```
*
* @param eventType One of the following strings: "value",
* "child_added", "child_changed", "child_removed", or "child_moved."
* @param successCallback A
* callback that fires when the specified event occurs. The callback will be
* passed a DataSnapshot. For ordering purposes, "child_added",
* "child_changed", and "child_moved" will also be passed a string containing
* the key of the previous child by sort order, or `null` if it is the
* first child.
* @param failureCallbackOrContext An optional
* callback that will be notified if your client does not have permission to
* read the data. This callback will be passed an `Error` object indicating
* why the failure occurred.
* @param context If provided, this object will be used as `this`
* when calling your callback(s).
*/
once(
eventType: EventType,
successCallback?: (
a: firebase.database.DataSnapshot,
b?: string | null
) => any,
failureCallbackOrContext?: ((a: Error) => void) | Object | null,
context?: Object | null
): Promise<firebase.database.DataSnapshot>;
/**
* Generates a new `Query` object ordered by the specified child key.
*
* Queries can only order by one key at a time. Calling `orderByChild()`
* multiple times on the same query is an error.
*
* Firebase queries allow you to order your data by any child key on the fly.
* However, if you know in advance what your indexes will be, you can define
* them via the .indexOn rule in your Security Rules for better performance. See
* the {@link https://firebase.google.com/docs/database/security/indexing-data
* .indexOn} rule for more information.
*
* You can read more about `orderByChild()` in
* {@link
* https://firebase.google.com/docs/database/web/lists-of-data#sort_data
* Sort data}.
*
* @example
* ```javascript
* var ref = firebase.database().ref("dinosaurs");
* ref.orderByChild("height").on("child_added", function(snapshot) {
* console.log(snapshot.key + " was " + snapshot.val().height + " m tall");
* });
* ```
*/
orderByChild(path: string): firebase.database.Query;
/**
* Generates a new `Query` object ordered by key.
*
* Sorts the results of a query by their (ascending) key values.
*
* You can read more about `orderByKey()` in
* {@link
* https://firebase.google.com/docs/database/web/lists-of-data#sort_data
* Sort data}.
*
* @example
* ```javascript
* var ref = firebase.database().ref("dinosaurs");
* ref.orderByKey().on("child_added", function(snapshot) {
* console.log(snapshot.key);
* });
* ```
*/
orderByKey(): firebase.database.Query;
/**
* Generates a new `Query` object ordered by priority.
*
* Applications need not use priority but can order collections by
* ordinary properties (see
* {@link
* https://firebase.google.com/docs/database/web/lists-of-data#sort_data
* Sort data} for alternatives to priority.
*/
orderByPriority(): firebase.database.Query;
/**
* Generates a new `Query` object ordered by value.
*
* If the children of a query are all scalar values (string, number, or
* boolean), you can order the results by their (ascending) values.
*
* You can read more about `orderByValue()` in
* {@link
* https://firebase.google.com/docs/database/web/lists-of-data#sort_data
* Sort data}.
*
* @example
* ```javascript
* var scoresRef = firebase.database().ref("scores");
* scoresRef.orderByValue().limitToLast(3).on("value", function(snapshot) {
* snapshot.forEach(function(data) {
* console.log("The " + data.key + " score is " + data.val());
* });
* });
* ```
*/
orderByValue(): firebase.database.Query;
/**
* Returns a `Reference` to the `Query`'s location.
*/
ref: firebase.database.Reference;
/**
* Creates a `Query` with the specified starting point.
*
* Using `startAt()`, `startAfter()`, `endBefore()`, `endAt()` and `equalTo()`
* allows you to choose arbitrary starting and ending points for your queries.
*
* The starting point is inclusive, so children with exactly the specified value
* will be included in the query. The optional key argument can be used to
* further limit the range of the query. If it is specified, then children that
* have exactly the specified value must also have a key name greater than or
* equal to the specified key.
*
* You can read more about `startAt()` in
* {@link
* https://firebase.google.com/docs/database/web/lists-of-data#filtering_data
* Filtering data}.
*
* @example
* ```javascript
* // Find all dinosaurs that are at least three meters tall.
* var ref = firebase.database().ref("dinosaurs");
* ref.orderByChild("height").startAt(3).on("child_added", function(snapshot) {
* console.log(snapshot.key)
* });
* ```
*
* @param value The value to start at. The argument
* type depends on which `orderBy*()` function was used in this query.
* Specify a value that matches the `orderBy*()` type. When used in
* combination with `orderByKey()`, the value must be a string.
* @param key The child key to start at. This argument is only allowed
* if ordering by child, value, or priority.
*/
startAt(
value: number | string | boolean | null,
key?: string
): firebase.database.Query;
/**
* Creates a `Query` with the specified starting point (exclusive).
*
* Using `startAt()`, `startAfter()`, `endBefore()`, `endAt()` and `equalTo()`
* allows you to choose arbitrary starting and ending points for your queries.
*
* The starting point is exclusive. If only a value is provided, children
* with a value greater than the specified value will be included in the query.
* If a key is specified, then children must have a value greater than or equal
* to the specified value and a a key name greater than the specified key.
*
* @example
* ```javascript
* // Find all dinosaurs that are more than three meters tall.
* var ref = firebase.database().ref("dinosaurs");
* ref.orderByChild("height").startAfter(3).on("child_added", function(snapshot) {
* console.log(snapshot.key)
* });
* ```
*
* @param value The value to start after. The argument
* type depends on which `orderBy*()` function was used in this query.
* Specify a value that matches the `orderBy*()` type. When used in
* combination with `orderByKey()`, the value must be a string.
* @param key The child key to start after. This argument is only allowed
* if ordering by child, value, or priority.
*/
startAfter(
value: number | string | boolean | null,
key?: string
): firebase.database.Query;
/**
* Returns a JSON-serializable representation of this object.
*
* @return A JSON-serializable representation of this object.
*/
toJSON(): Object;
/**
* Gets the absolute URL for this location.
*
* The `toString()` method returns a URL that is ready to be put into a browser,
* curl command, or a `firebase.database().refFromURL()` call. Since all of
* those expect the URL to be url-encoded, `toString()` returns an encoded URL.
*
* Append '.json' to the returned URL when typed into a browser to download
* JSON-formatted data. If the location is secured (that is, not publicly
* readable), you will get a permission-denied error.
*
* @example
* ```javascript
* // Calling toString() on a root Firebase reference returns the URL where its
* // data is stored within the Database:
* var rootRef = firebase.database().ref();
* var rootUrl = rootRef.toString();
* // rootUrl === "https://sample-app.firebaseio.com/".
*
* // Calling toString() at a deeper Firebase reference returns the URL of that
* // deep path within the Database:
* var adaRef = rootRef.child('users/ada');
* var adaURL = adaRef.toString();
* // adaURL === "https://sample-app.firebaseio.com/users/ada".
* ```
*
* @return The absolute URL for this location.
*/
toString(): string;
}
/**
* A `Reference` represents a specific location in your Database and can be used
* for reading or writing data to that Database location.
*
* You can reference the root or child location in your Database by calling
* `firebase.database().ref()` or `firebase.database().ref("child/path")`.
*
* Writing is done with the `set()` method and reading can be done with the
* `on()` method. See
* {@link
* https://firebase.google.com/docs/database/web/read-and-write
* Read and Write Data on the Web}
*/
interface Reference extends firebase.database.Query {
/**
* Gets a `Reference` for the location at the specified relative path.
*
* The relative path can either be a simple child name (for example, "ada") or
* a deeper slash-separated path (for example, "ada/name/first").
*
* @example
* ```javascript
* var usersRef = firebase.database().ref('users');
* var adaRef = usersRef.child('ada');
* var adaFirstNameRef = adaRef.child('name/first');
* var path = adaFirstNameRef.toString();
* // path is now 'https://sample-app.firebaseio.com/users/ada/name/first'
* ```
*
* @param path A relative path from this location to the desired child
* location.
* @return The specified child location.
*/
child(path: string): firebase.database.Reference;
/**
* The last part of the `Reference`'s path.
*
* For example, `"ada"` is the key for
* `https://<DATABASE_NAME>.firebaseio.com/users/ada`.
*
* The key of a root `Reference` is `null`.
*
* @example
* ```javascript
* // The key of a root reference is null
* var rootRef = firebase.database().ref();
* var key = rootRef.key; // key === null
* ```
*
* @example
* ```javascript
* // The key of any non-root reference is the last token in the path
* var adaRef = firebase.database().ref("users/ada");
* var key = adaRef.key; // key === "ada"
* key = adaRef.child("name/last").key; // key === "last"
* ```
*/
key: string | null;
/**
* Returns an `OnDisconnect` object - see
* {@link
* https://firebase.google.com/docs/database/web/offline-capabilities
* Enabling Offline Capabilities in JavaScript} for more information on how
* to use it.
*/
onDisconnect(): firebase.database.OnDisconnect;
/**
* The parent location of a `Reference`.
*
* The parent of a root `Reference` is `null`.
*
* @example
* ```javascript
* // The parent of a root reference is null
* var rootRef = firebase.database().ref();
* parent = rootRef.parent; // parent === null
* ```
*
* @example
* ```javascript
* // The parent of any non-root reference is the parent location
* var usersRef = firebase.database().ref("users");
* var adaRef = firebase.database().ref("users/ada");
* // usersRef and adaRef.parent represent the same location
* ```
*/
parent: firebase.database.Reference | null;
/**
* Generates a new child location using a unique key and returns its
* `Reference`.
*
* This is the most common pattern for adding data to a collection of items.
*
* If you provide a value to `push()`, the value is written to the
* generated location. If you don't pass a value, nothing is written to the
* database and the child remains empty (but you can use the `Reference`
* elsewhere).
*
* The unique keys generated by `push()` are ordered by the current time, so the
* resulting list of items is chronologically sorted. The keys are also
* designed to be unguessable (they contain 72 random bits of entropy).
*
*
* See
* {@link
* https://firebase.google.com/docs/database/web/lists-of-data#append_to_a_list_of_data
* Append to a list of data}
* </br>See
* {@link
* https://firebase.googleblog.com/2015/02/the-2120-ways-to-ensure-unique_68.html
* The 2^120 Ways to Ensure Unique Identifiers}
*
* @example
* ```javascript
* var messageListRef = firebase.database().ref('message_list');
* var newMessageRef = messageListRef.push();
* newMessageRef.set({
* 'user_id': 'ada',
* 'text': 'The Analytical Engine weaves algebraical patterns just as the Jacquard loom weaves flowers and leaves.'
* });
* // We've appended a new message to the message_list location.
* var path = newMessageRef.toString();
* // path will be something like
* // 'https://sample-app.firebaseio.com/message_list/-IKo28nwJLH0Nc5XeFmj'
* ```
*
* @param value Optional value to be written at the generated location.
* @param onComplete Callback called when write to server is
* complete.
* @return Combined `Promise` and `Reference`; resolves when write is complete, but can be
* used immediately as the `Reference` to the child location.
*/
push(
value?: any,
onComplete?: (a: Error | null) => any
): firebase.database.ThenableReference;
/**
* Removes the data at this Database location.
*
* Any data at child locations will also be deleted.
*
* The effect of the remove will be visible immediately and the corresponding
* event 'value' will be triggered. Synchronization of the remove to the
* Firebase servers will also be started, and the returned Promise will resolve
* when complete. If provided, the onComplete callback will be called
* asynchronously after synchronization has finished.
*
* @example
* ```javascript
* var adaRef = firebase.database().ref('users/ada');
* adaRef.remove()
* .then(function() {
* console.log("Remove succeeded.")
* })
* .catch(function(error) {
* console.log("Remove failed: " + error.message)
* });
* ```
*
* @param onComplete Callback called when write to server is
* complete.
* @return Resolves when remove on server is complete.
*/
remove(onComplete?: (a: Error | null) => void): Promise<void>;
/**
* The root `Reference` of the Database.
*
* @example
* ```javascript
* // The root of a root reference is itself
* var rootRef = firebase.database().ref();
* // rootRef and rootRef.root represent the same location
* ```
*
* @example
* ```javascript
* // The root of any non-root reference is the root location
* var adaRef = firebase.database().ref("users/ada");
* // rootRef and adaRef.root represent the same location
* ```
*/
root: firebase.database.Reference;
/**
* Writes data to this Database location.
*
* This will overwrite any data at this location and all child locations.
*
* The effect of the write will be visible immediately, and the corresponding
* events ("value", "child_added", etc.) will be triggered. Synchronization of
* the data to the Firebase servers will also be started, and the returned
* Promise will resolve when complete. If provided, the `onComplete` callback
* will be called asynchronously after synchronization has finished.
*
* Passing `null` for the new value is equivalent to calling `remove()`; namely,
* all data at this location and all child locations will be deleted.
*
* `set()` will remove any priority stored at this location, so if priority is
* meant to be preserved, you need to use `setWithPriority()` instead.
*
* Note that modifying data with `set()` will cancel any pending transactions
* at that location, so extreme care should be taken if mixing `set()` and
* `transaction()` to modify the same data.
*
* A single `set()` will generate a single "value" event at the location where
* the `set()` was performed.
*
* @example
* ```javascript
* var adaNameRef = firebase.database().ref('users/ada/name');
* adaNameRef.child('first').set('Ada');
* adaNameRef.child('last').set('Lovelace');
* // We've written 'Ada' to the Database location storing Ada's first name,
* // and 'Lovelace' to the location storing her last name.
* ```
*
* @example
* ```javascript
* adaNameRef.set({ first: 'Ada', last: 'Lovelace' });
* // Exact same effect as the previous example, except we've written
* // Ada's first and last name simultaneously.
* ```
*
* @example
* ```javascript
* adaNameRef.set({ first: 'Ada', last: 'Lovelace' })
* .then(function() {
* console.log('Synchronization succeeded');
* })
* .catch(function(error) {
* console.log('Synchronization failed');
* });
* // Same as the previous example, except we will also log a message
* // when the data has finished synchronizing.
* ```
*
* @param value The value to be written (string, number, boolean, object,
* array, or null).
* @param onComplete Callback called when write to server is
* complete.
* @return Resolves when write to server is complete.
*/
set(value: any, onComplete?: (a: Error | null) => void): Promise<void>;
/**
* Sets a priority for the data at this Database location.
*
* Applications need not use priority but can order collections by
* ordinary properties (see
* {@link
* https://firebase.google.com/docs/database/web/lists-of-data#sorting_and_filtering_data
* Sorting and filtering data}).
*/
setPriority(
priority: string | number | null,
onComplete: (a: Error | null) => void
): Promise<void>;
/**
* Writes data the Database location. Like `set()` but also specifies the
* priority for that data.
*
* Applications need not use priority but can order collections by
* ordinary properties (see
* {@link
* https://firebase.google.com/docs/database/web/lists-of-data#sorting_and_filtering_data
* Sorting and filtering data}).
*/
setWithPriority(
newVal: any,
newPriority: string | number | null,
onComplete?: (a: Error | null) => void
): Promise<void>;
/**
* Atomically modifies the data at this location.
*
* Atomically modify the data at this location. Unlike a normal `set()`, which
* just overwrites the data regardless of its previous value, `transaction()` is
* used to modify the existing value to a new value, ensuring there are no
* conflicts with other clients writing to the same location at the same time.
*
* To accomplish this, you pass `transaction()` an update function which is used
* to transform the current value into a new value. If another client writes to
* the location before your new value is successfully written, your update
* function will be called again with the new current value, and the write will
* be retried. This will happen repeatedly until your write succeeds without
* conflict or you abort the transaction by not returning a value from your
* update function.
*
* Note: Modifying data with `set()` will cancel any pending transactions at
* that location, so extreme care should be taken if mixing `set()` and
* `transaction()` to update the same data.
*
* Note: When using transactions with Security and Firebase Rules in place, be
* aware that a client needs `.read` access in addition to `.write` access in
* order to perform a transaction. This is because the client-side nature of
* transactions requires the client to read the data in order to transactionally
* update it.
*
* @example
* ```javascript
* // Increment Ada's rank by 1.
* var adaRankRef = firebase.database().ref('users/ada/rank');
* adaRankRef.transaction(function(currentRank) {
* // If users/ada/rank has never been set, currentRank will be `null`.
* return currentRank + 1;
* });
* ```
*
* @example
* ```javascript
* // Try to create a user for ada, but only if the user id 'ada' isn't
* // already taken
* var adaRef = firebase.database().ref('users/ada');
* adaRef.transaction(function(currentData) {
* if (currentData === null) {
* return { name: { first: 'Ada', last: 'Lovelace' } };
* } else {
* console.log('User ada already exists.');
* return; // Abort the transaction.
* }
* }, function(error, committed, snapshot) {
* if (error) {
* console.log('Transaction failed abnormally!', error);
* } else if (!committed) {
* console.log('We aborted the transaction (because ada already exists).');
* } else {
* console.log('User ada added!');
* }
* console.log("Ada's data: ", snapshot.val());
* });
* ```
*
* @param transactionUpdate A developer-supplied function which
* will be passed the current data stored at this location (as a JavaScript
* object). The function should return the new value it would like written (as
* a JavaScript object). If `undefined` is returned (i.e. you return with no
* arguments) the transaction will be aborted and the data at this location
* will not be modified.
* @param onComplete A callback
* function that will be called when the transaction completes. The callback
* is passed three arguments: a possibly-null `Error`, a `boolean` indicating
* whether the transaction was committed, and a `DataSnapshot` indicating the
* final result. If the transaction failed abnormally, the first argument will
* be an `Error` object indicating the failure cause. If the transaction
* finished normally, but no data was committed because no data was returned
* from `transactionUpdate`, then second argument will be false. If the
* transaction completed and committed data to Firebase, the second argument
* will be true. Regardless, the third argument will be a `DataSnapshot`
* containing the resulting data in this location.
* @param applyLocally By default, events are raised each time the
* transaction update function runs. So if it is run multiple times, you may
* see intermediate states. You can set this to false to suppress these
* intermediate states and instead wait until the transaction has completed
* before events are raised.
* @return Returns a Promise that can optionally be used instead of the onComplete
* callback to handle success and failure.
*/
transaction(
transactionUpdate: (a: any) => any,
onComplete?: (
a: Error | null,
b: boolean,
c: firebase.database.DataSnapshot | null
) => void,
applyLocally?: boolean
): Promise<TransactionResult>;
/**
* Writes multiple values to the Database at once.
*
* The `values` argument contains multiple property-value pairs that will be
* written to the Database together. Each child property can either be a simple
* property (for example, "name") or a relative path (for example,
* "name/first") from the current location to the data to update.
*
* As opposed to the `set()` method, `update()` can be use to selectively update
* only the referenced properties at the current location (instead of replacing
* all the child properties at the current location).
*
* The effect of the write will be visible immediately, and the corresponding
* events ('value', 'child_added', etc.) will be triggered. Synchronization of
* the data to the Firebase servers will also be started, and the returned
* Promise will resolve when complete. If provided, the `onComplete` callback
* will be called asynchronously after synchronization has finished.
*
* A single `update()` will generate a single "value" event at the location
* where the `update()` was performed, regardless of how many children were
* modified.
*
* Note that modifying data with `update()` will cancel any pending
* transactions at that location, so extreme care should be taken if mixing
* `update()` and `transaction()` to modify the same data.
*
* Passing `null` to `update()` will remove the data at this location.
*
* See
* {@link
* https://firebase.googleblog.com/2015/09/introducing-multi-location-updates-and_86.html
* Introducing multi-location updates and more}.
*
* @example
* ```javascript
* var adaNameRef = firebase.database().ref('users/ada/name');
* // Modify the 'first' and 'last' properties, but leave other data at
* // adaNameRef unchanged.
* adaNameRef.update({ first: 'Ada', last: 'Lovelace' });
* ```
*
* @param values Object containing multiple values.
* @param onComplete Callback called when write to server is
* complete.
* @return Resolves when update on server is complete.
*/
update(
values: Object,
onComplete?: (a: Error | null) => void
): Promise<void>;
}
interface TransactionResult {
/**
* Whether the transaction was successfully committed.
*/
committed: boolean;
/**
* The resulting data snapshot.
*/
snapshot: DataSnapshot;
}
interface ThenableReference
extends firebase.database.Reference,
Pick<Promise<Reference>, 'then' | 'catch'> {
key: string;
parent: Reference;
}
/**
* Logs debugging information to the console.
*
* @example
* ```javascript
* // Enable logging
* firebase.database.enableLogging(true);
* ```
*
* @example
* ```javascript
* // Disable logging
* firebase.database.enableLogging(false);
* ```
*
* @example
* ```javascript
* // Enable logging across page refreshes
* firebase.database.enableLogging(true, true);
* ```
*
* @example
* ```javascript
* // Provide custom logger which prefixes log statements with "[FIREBASE]"
* firebase.database.enableLogging(function(message) {
* console.log("[FIREBASE]", message);
* });
* ```
*
* @param logger Enables logging if `true`;
* disables logging if `false`. You can also provide a custom logger function
* to control how things get logged.
* @param persistent Remembers the logging state between page
* refreshes if `true`.
*/
function enableLogging(
logger?: boolean | ((a: string) => any),
persistent?: boolean
): any;
export type EmulatorMockTokenOptions = firebase.EmulatorMockTokenOptions;
}
declare namespace firebase.database.ServerValue {
/**
* A placeholder value for auto-populating the current timestamp (time
* since the Unix epoch, in milliseconds) as determined by the Firebase
* servers.
*
* @example
* ```javascript
* var sessionsRef = firebase.database().ref("sessions");
* sessionsRef.push({
* startedAt: firebase.database.ServerValue.TIMESTAMP
* });
* ```
*/
var TIMESTAMP: Object;
/**
* Returns a placeholder value that can be used to atomically increment the
* current database value by the provided delta.
*
* @param delta the amount to modify the current value atomically.
* @return a placeholder value for modifying data atomically server-side.
*/
function increment(delta: number): Object;
}
/**
* The Messaging SDK does not work in a Node.js environment.
*/
declare namespace firebase.messaging {
/**
* The Firebase Messaging service interface.
*
* Do not call this constructor directly. Instead, use
* {@link firebase.messaging `firebase.messaging()`}.
*
* See {@link https://firebase.google.com/docs/cloud-messaging/js/client
* Set Up a JavaScript Firebase Cloud Messaging Client App} for a full guide on how to use the
* Firebase Messaging service.
*
*/
interface Messaging {
/**
* Deletes the registration token associated with this messaging instance and unsubscribes the
* messaging instance from the push subscription.
*
* @return The promise resolves when the token has been successfully deleted.
*/
deleteToken(): Promise<boolean>;
/**
* Subscribes the messaging instance to push notifications. Returns an FCM registration token
* that can be used to send push messages to that messaging instance.
*
* If a notification permission isn't already granted, this method asks the user for permission.
* The returned promise rejects if the user does not allow the app to show notifications.
*
* @param options.vapidKey The public server key provided to push services. It is used to
* authenticate the push subscribers to receive push messages only from sending servers that
* hold the corresponding private key. If it is not provided, a default VAPID key is used. Note
* that some push services (Chrome Push Service) require a non-default VAPID key. Therefore, it
* is recommended to generate and import a VAPID key for your project with
* {@link https://firebase.google.com/docs/cloud-messaging/js/client#configure_web_credentials_with_fcm Configure Web Credentials with FCM}.
* See
* {@link https://developers.google.com/web/fundamentals/push-notifications/web-push-protocol The Web Push Protocol}
* for details on web push services.}
*
* @param options.serviceWorkerRegistration The service worker registration for receiving push
* messaging. If the registration is not provided explicitly, you need to have a
* `firebase-messaging-sw.js` at your root location. See
* {@link https://firebase.google.com/docs/cloud-messaging/js/client#access_the_registration_token | Access the registration token}
* for more details.
*
* @return The promise resolves with an FCM registration token.
*
*/
getToken(options?: {
vapidKey?: string;
serviceWorkerRegistration?: ServiceWorkerRegistration;
}): Promise<string>;
/**
* When a push message is received and the user is currently on a page for your origin, the
* message is passed to the page and an `onMessage()` event is dispatched with the payload of
* the push message.
*
* @param
* nextOrObserver This function, or observer object with `next` defined,
* is called when a message is received and the user is currently viewing your page.
* @return To stop listening for messages execute this returned function.
*/
onMessage(
nextOrObserver: firebase.NextFn<any> | firebase.Observer<any>
): firebase.Unsubscribe;
/**
* Called when a message is received while the app is in the background. An app is considered to
* be in the background if no active window is displayed.
*
* @param
* nextOrObserver This function, or observer object with `next` defined,
* is called when a message is received and the app is currently in the background.
*
* @return To stop listening for messages execute this returned function
*/
onBackgroundMessage(
nextOrObserver:
| firebase.NextFn<MessagePayload>
| firebase.Observer<MessagePayload>
): firebase.Unsubscribe;
}
/**
* Message payload that contains the notification payload that is represented with
* {@link firebase.messaging.NotificationPayload} and the data payload that contains an arbitrary
* number of key-value pairs sent by developers through the
* {@link https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages#notification Send API}
*/
export interface MessagePayload {
/**
* See {@link firebase.messaging.NotificationPayload}.
*/
notification?: NotificationPayload;
/**
* Arbitrary key/value pairs.
*/
data?: { [key: string]: string };
/**
* See {@link firebase.messaging.FcmOptions}.
*/
fcmOptions?: FcmOptions;
/**
* The sender of this message.
*/
from: string;
/**
* The collapse key of this message. See
* {@link https://firebase.google.com/docs/cloud-messaging/concept-options#collapsible_and_non-collapsible_messages
* Collapsible and non-collapsible messages}.
*/
collapseKey: string;
}
/**
* Options for features provided by the FCM SDK for Web. See
* {@link https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages#webpushfcmoptions
* WebpushFcmOptions}.
*/
export interface FcmOptions {
/**
* The link to open when the user clicks on the notification. For all URL values, HTTPS is
* required. For example, by setting this value to your app's URL, a notification click event
* will put your app in focus for the user.
*/
link?: string;
/**
* Label associated with the message's analytics data. See
* {@link https://firebase.google.com/docs/cloud-messaging/understand-delivery#adding-analytics-labels-to-messages
* Adding analytics labels}.
*/
analyticsLabel?: string;
}
/**
* Parameters that define how a push notification is displayed to users.
*/
export interface NotificationPayload {
/**
* The title of a notification.
*/
title?: string;
/**
* The body of a notification.
*/
body?: string;
/**
* The URL of the image that is shown with the notification. See
* {@link https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages#notification
* `notification.image`} for supported image format.
*/
image?: string;
}
function isSupported(): boolean;
}
declare namespace firebase.storage {
/**
* The full set of object metadata, including read-only properties.
*/
interface FullMetadata extends firebase.storage.UploadMetadata {
/**
* The bucket this object is contained in.
*/
bucket: string;
/**
* The full path of this object.
*/
fullPath: string;
/**
* The object's generation.
* @see {@link https://cloud.google.com/storage/docs/generations-preconditions}
*/
generation: string;
/**
* The object's metageneration.
* @see {@link https://cloud.google.com/storage/docs/generations-preconditions}
*/
metageneration: string;
/**
* The short name of this object, which is the last component of the full path.
* For example, if fullPath is 'full/path/image.png', name is 'image.png'.
*/
name: string;
/**
* The size of this object, in bytes.
*/
size: number;
/**
* A date string representing when this object was created.
*/
timeCreated: string;
/**
* A date string representing when this object was last updated.
*/
updated: string;
}
/**
* Represents a reference to a Google Cloud Storage object. Developers can
* upload, download, and delete objects, as well as get/set object metadata.
*/
interface Reference {
/**
* The name of the bucket containing this reference's object.
*/
bucket: string;
/**
* Returns a reference to a relative path from this reference.
* @param path The relative path from this reference.
* Leading, trailing, and consecutive slashes are removed.
* @return The reference to the given path.
*/
child(path: string): firebase.storage.Reference;
/**
* Deletes the object at this reference's location.
* @return A Promise that resolves if the deletion
* succeeded and rejects if it failed, including if the object didn't exist.
*/
delete(): Promise<void>;
/**
* The full path of this object.
*/
fullPath: string;
/**
* Fetches a long lived download URL for this object.
* @return A Promise that resolves with the download
* URL or rejects if the fetch failed, including if the object did not
* exist.
*/
getDownloadURL(): Promise<string>;
/**
* Fetches metadata for the object at this location, if one exists.
* @return A Promise that
* resolves with the metadata, or rejects if the fetch failed, including if
* the object did not exist.
*/
getMetadata(): Promise<FullMetadata>;
/**
* The short name of this object, which is the last component of the full path.
* For example, if fullPath is 'full/path/image.png', name is 'image.png'.
*/
name: string;
/**
* A reference pointing to the parent location of this reference, or null if
* this reference is the root.
*/
parent: firebase.storage.Reference | null;
/**
* Uploads data to this reference's location.
* @param data The data to upload.
* @param metadata Metadata for the newly
* uploaded object.
* @return An object that can be used to monitor
* and manage the upload.
*/
put(
data: Blob | Uint8Array | ArrayBuffer,
metadata?: firebase.storage.UploadMetadata
): firebase.storage.UploadTask;
/**
* Uploads string data to this reference's location.
* @param data The string to upload.
* @param format The format of the string to
* upload.
* @param metadata Metadata for the newly
* uploaded object.
* @throws If the format is not an allowed format, or if the given string
* doesn't conform to the specified format.
*/
putString(
data: string,
format?: firebase.storage.StringFormat,
metadata?: firebase.storage.UploadMetadata
): firebase.storage.UploadTask;
/**
* A reference to the root of this reference's bucket.
*/
root: firebase.storage.Reference;
/**
* The storage service associated with this reference.
*/
storage: firebase.storage.Storage;
/**
* Returns a gs:// URL for this object in the form
* `gs://<bucket>/<path>/<to>/<object>`
* @return The gs:// URL.
*/
toString(): string;
/**
* Updates the metadata for the object at this location, if one exists.
* @param metadata The new metadata.
* Setting a property to 'null' removes it on the server, while leaving
* a property as 'undefined' has no effect.
* @return A Promise that
* resolves with the full updated metadata or rejects if the updated failed,
* including if the object did not exist.
*/
updateMetadata(
metadata: firebase.storage.SettableMetadata
): Promise<FullMetadata>;
/**
* List all items (files) and prefixes (folders) under this storage reference.
*
* This is a helper method for calling `list()` repeatedly until there are
* no more results. The default pagination size is 1000.
*
* Note: The results may not be consistent if objects are changed while this
* operation is running.
*
* Warning: `listAll` may potentially consume too many resources if there are
* too many results.
*
* @return A Promise that resolves with all the items and prefixes under
* the current storage reference. `prefixes` contains references to
* sub-directories and `items` contains references to objects in this
* folder. `nextPageToken` is never returned.
*/
listAll(): Promise<ListResult>;
/**
* List items (files) and prefixes (folders) under this storage reference.
*
* List API is only available for Firebase Rules Version 2.
*
* GCS is a key-blob store. Firebase Storage imposes the semantic of '/'
* delimited folder structure.
* Refer to GCS's List API if you want to learn more.
*
* To adhere to Firebase Rules's Semantics, Firebase Storage does not
* support objects whose paths end with "/" or contain two consecutive
* "/"s. Firebase Storage List API will filter these unsupported objects.
* `list()` may fail if there are too many unsupported objects in the bucket.
*
* @param options See `ListOptions` for details.
* @return A Promise that resolves with the items and prefixes.
* `prefixes` contains references to sub-folders and `items`
* contains references to objects in this folder. `nextPageToken`
* can be used to get the rest of the results.
*/
list(options?: ListOptions): Promise<ListResult>;
}
/**
* Result returned by list().
*/
interface ListResult {
/**
* References to prefixes (sub-folders). You can call list() on them to
* get its contents.
*
* Folders are implicit based on '/' in the object paths.
* For example, if a bucket has two objects '/a/b/1' and '/a/b/2', list('/a')
* will return '/a/b' as a prefix.
*/
prefixes: Reference[];
/**
* Objects in this directory.
* You can call getMetadata() and getDownloadUrl() on them.
*/
items: Reference[];
/**
* If set, there might be more results for this list. Use this token to resume the list.
*/
nextPageToken: string | null;
}
/**
* The options `list()` accepts.
*/
interface ListOptions {
/**
* If set, limits the total number of `prefixes` and `items` to return.
* The default and maximum maxResults is 1000.
*/
maxResults?: number | null;
/**
* The `nextPageToken` from a previous call to `list()`. If provided,
* listing is resumed from the previous position.
*/
pageToken?: string | null;
}
/**
* Object metadata that can be set at any time.
*/
interface SettableMetadata {
/**
* Served as the 'Cache-Control' header on object download.
*/
cacheControl?: string | null;
contentDisposition?: string | null;
/**
* Served as the 'Content-Encoding' header on object download.
*/
contentEncoding?: string | null;
/**
* Served as the 'Content-Language' header on object download.
*/
contentLanguage?: string | null;
/**
* Served as the 'Content-Type' header on object download.
*/
contentType?: string | null;
/**
* Additional user-defined custom metadata.
*/
customMetadata?: {
[/* warning: coerced from ? */ key: string]: string;
} | null;
}
/**
* The Firebase Storage service interface.
*
* Do not call this constructor directly. Instead, use
* {@link firebase.storage `firebase.storage()`}.
*
* See
* {@link
* https://firebase.google.com/docs/storage/web/start/
* Get Started on Web}
* for a full guide on how to use the Firebase Storage service.
*/
interface Storage {
/**
* The {@link firebase.app.App app} associated with the `Storage` service
* instance.
*
* @example
* ```javascript
* var app = storage.app;
* ```
*/
app: firebase.app.App;
/**
* The maximum time to retry operations other than uploads or downloads in
* milliseconds.
*/
maxOperationRetryTime: number;
/**
* The maximum time to retry uploads in milliseconds.
*/
maxUploadRetryTime: number;
/**
* Returns a reference for the given path in the default bucket.
* @param path A relative path to initialize the reference with,
* for example `path/to/image.jpg`. If not passed, the returned reference
* points to the bucket root.
* @return A reference for the given path.
*/
ref(path?: string): firebase.storage.Reference;
/**
* Returns a reference for the given absolute URL.
* @param url A URL in the form: <br />
* 1) a gs:// URL, for example `gs://bucket/files/image.png` <br />
* 2) a download URL taken from object metadata. <br />
* @return A reference for the given URL.
*/
refFromURL(url: string): firebase.storage.Reference;
/**
* @param time The new maximum operation retry time in milliseconds.
* @see {@link firebase.storage.Storage.maxOperationRetryTime}
*/
setMaxOperationRetryTime(time: number): any;
/**
* @param time The new maximum upload retry time in milliseconds.
* @see {@link firebase.storage.Storage.maxUploadRetryTime}
*/
setMaxUploadRetryTime(time: number): any;
/**
* Modify this `Storage` instance to communicate with the Cloud Storage emulator.
*
* @param host - The emulator host (ex: localhost)
* @param port - The emulator port (ex: 5001)
* @param options.mockUserToken the mock auth token to use for unit testing Security Rules
*/
useEmulator(
host: string,
port: number,
options?: {
mockUserToken?: EmulatorMockTokenOptions | string;
}
): void;
}
/**
* @enum {string}
* An enumeration of the possible string formats for upload.
*/
type StringFormat = string;
var StringFormat: {
/**
* Indicates the string should be interpreted as base64-encoded data.
* Padding characters (trailing '='s) are optional.
* Example: The string 'rWmO++E6t7/rlw==' becomes the byte sequence
* ad 69 8e fb e1 3a b7 bf eb 97
*/
BASE64: StringFormat;
/**
* Indicates the string should be interpreted as base64url-encoded data.
* Padding characters (trailing '='s) are optional.
* Example: The string 'rWmO--E6t7_rlw==' becomes the byte sequence
* ad 69 8e fb e1 3a b7 bf eb 97
*/
BASE64URL: StringFormat;
/**
* Indicates the string is a data URL, such as one obtained from
* canvas.toDataURL().
* Example: the string 'data:application/octet-stream;base64,aaaa'
* becomes the byte sequence
* 69 a6 9a
* (the content-type "application/octet-stream" is also applied, but can
* be overridden in the metadata object).
*/
DATA_URL: StringFormat;
/**
* Indicates the string should be interpreted "raw", that is, as normal text.
* The string will be interpreted as UTF-16, then uploaded as a UTF-8 byte
* sequence.
* Example: The string 'Hello! \ud83d\ude0a' becomes the byte sequence
* 48 65 6c 6c 6f 21 20 f0 9f 98 8a
*/
RAW: StringFormat;
};
/**
* An event that is triggered on a task.
* @enum {string}
* @see {@link firebase.storage.UploadTask.on}
*/
type TaskEvent = string;
var TaskEvent: {
/**
* For this event,
* <ul>
* <li>The `next` function is triggered on progress updates and when the
* task is paused/resumed with a
* {@link firebase.storage.UploadTaskSnapshot} as the first
* argument.</li>
* <li>The `error` function is triggered if the upload is canceled or fails
* for another reason.</li>
* <li>The `complete` function is triggered if the upload completes
* successfully.</li>
* </ul>
*/
STATE_CHANGED: TaskEvent;
};
/**
* Represents the current state of a running upload.
* @enum {string}
*/
type TaskState = string;
var TaskState: {
CANCELED: TaskState;
ERROR: TaskState;
PAUSED: TaskState;
RUNNING: TaskState;
SUCCESS: TaskState;
};
/**
* Object metadata that can be set at upload.
*/
interface UploadMetadata extends firebase.storage.SettableMetadata {
/**
* A Base64-encoded MD5 hash of the object being uploaded.
*/
md5Hash?: string | null;
}
/**
* Error codes that can be attached to `StorageError` objects.
*/
export enum StorageErrorCode {
UNKNOWN = 'unknown',
OBJECT_NOT_FOUND = 'object-not-found',
BUCKET_NOT_FOUND = 'bucket-not-found',
PROJECT_NOT_FOUND = 'project-not-found',
QUOTA_EXCEEDED = 'quota-exceeded',
UNAUTHENTICATED = 'unauthenticated',
UNAUTHORIZED = 'unauthorized',
UNAUTHORIZED_APP = 'unauthorized-app',
RETRY_LIMIT_EXCEEDED = 'retry-limit-exceeded',
INVALID_CHECKSUM = 'invalid-checksum',
CANCELED = 'canceled',
INVALID_EVENT_NAME = 'invalid-event-name',
INVALID_URL = 'invalid-url',
INVALID_DEFAULT_BUCKET = 'invalid-default-bucket',
NO_DEFAULT_BUCKET = 'no-default-bucket',
CANNOT_SLICE_BLOB = 'cannot-slice-blob',
SERVER_FILE_WRONG_SIZE = 'server-file-wrong-size',
NO_DOWNLOAD_URL = 'no-download-url',
INVALID_ARGUMENT = 'invalid-argument',
INVALID_ARGUMENT_COUNT = 'invalid-argument-count',
APP_DELETED = 'app-deleted',
INVALID_ROOT_OPERATION = 'invalid-root-operation',
INVALID_FORMAT = 'invalid-format',
INTERNAL_ERROR = 'internal-error',
UNSUPPORTED_ENVIRONMENT = 'unsupported-environment'
}
interface StorageObserver<T> {
next?: NextFn<T> | null;
error?: (error: FirebaseStorageError) => void | null;
complete?: CompleteFn | null;
}
/**
* Represents the process of uploading an object. Allows you to monitor and
* manage the upload.
*/
interface UploadTask {
/**
* Cancels a running task. Has no effect on a complete or failed task.
* @return True if the cancel had an effect.
*/
cancel(): boolean;
/**
* Equivalent to calling `then(null, onRejected)`.
*/
catch(onRejected: (error: FirebaseStorageError) => any): Promise<any>;
/**
* Listens for events on this task.
*
* Events have three callback functions (referred to as `next`, `error`, and
* `complete`).
*
* If only the event is passed, a function that can be used to register the
* callbacks is returned. Otherwise, the callbacks are passed after the event.
*
* Callbacks can be passed either as three separate arguments <em>or</em> as the
* `next`, `error`, and `complete` properties of an object. Any of the three
* callbacks is optional, as long as at least one is specified. In addition,
* when you add your callbacks, you get a function back. You can call this
* function to unregister the associated callbacks.
*
* @example **Pass callbacks separately or in an object.**
* ```javascript
* var next = function(snapshot) {};
* var error = function(error) {};
* var complete = function() {};
*
* // The first example.
* uploadTask.on(
* firebase.storage.TaskEvent.STATE_CHANGED,
* next,
* error,
* complete);
*
* // This is equivalent to the first example.
* uploadTask.on(firebase.storage.TaskEvent.STATE_CHANGED, {
* 'next': next,
* 'error': error,
* 'complete': complete
* });
*
* // This is equivalent to the first example.
* var subscribe = uploadTask.on(firebase.storage.TaskEvent.STATE_CHANGED);
* subscribe(next, error, complete);
*
* // This is equivalent to the first example.
* var subscribe = uploadTask.on(firebase.storage.TaskEvent.STATE_CHANGED);
* subscribe({
* 'next': next,
* 'error': error,
* 'complete': complete
* });
* ```
*
* @example **Any callback is optional.**
* ```javascript
* // Just listening for completion, this is legal.
* uploadTask.on(
* firebase.storage.TaskEvent.STATE_CHANGED,
* null,
* null,
* function() {
* console.log('upload complete!');
* });
*
* // Just listening for progress/state changes, this is legal.
* uploadTask.on(firebase.storage.TaskEvent.STATE_CHANGED, function(snapshot) {
* var percent = snapshot.bytesTransferred / snapshot.totalBytes * 100;
* console.log(percent + "% done");
* });
*
* // This is also legal.
* uploadTask.on(firebase.storage.TaskEvent.STATE_CHANGED, {
* 'complete': function() {
* console.log('upload complete!');
* }
* });
* ```
*
* @example **Use the returned function to remove callbacks.**
* ```javascript
* var unsubscribe = uploadTask.on(
* firebase.storage.TaskEvent.STATE_CHANGED,
* function(snapshot) {
* var percent = snapshot.bytesTransferred / snapshot.totalBytes * 100;
* console.log(percent + "% done");
* // Stop after receiving one update.
* unsubscribe();
* });
*
* // This code is equivalent to the above.
* var handle = uploadTask.on(firebase.storage.TaskEvent.STATE_CHANGED);
* unsubscribe = handle(function(snapshot) {
* var percent = snapshot.bytesTransferred / snapshot.totalBytes * 100;
* console.log(percent + "% done");
* // Stop after receiving one update.
* unsubscribe();
* });
* ```
*
* @param event The event to listen for.
* @param nextOrObserver
* The `next` function, which gets called for each item in
* the event stream, or an observer object with some or all of these three
* properties (`next`, `error`, `complete`).
* @param error A function that gets called with a `FirebaseStorageError`
* if the event stream ends due to an error.
* @param complete A function that gets called if the
* event stream ends normally.
* @return
* If only the event argument is passed, returns a function you can use to
* add callbacks (see the examples above). If more than just the event
* argument is passed, returns a function you can call to unregister the
* callbacks.
*/
on(
event: firebase.storage.TaskEvent,
nextOrObserver?:
| StorageObserver<UploadTaskSnapshot>
| null
| ((snapshot: UploadTaskSnapshot) => any),
error?: ((error: FirebaseStorageError) => any) | null,
complete?: firebase.Unsubscribe | null
): Function;
/**
* Pauses a running task. Has no effect on a paused or failed task.
* @return True if the pause had an effect.
*/
pause(): boolean;
/**
* Resumes a paused task. Has no effect on a running or failed task.
* @return True if the resume had an effect.
*/
resume(): boolean;
/**
* A snapshot of the current task state.
*/
snapshot: firebase.storage.UploadTaskSnapshot;
/**
* This object behaves like a Promise, and resolves with its snapshot data when
* the upload completes.
* @param onFulfilled
* The fulfillment callback. Promise chaining works as normal.
* @param onRejected The rejection callback.
*/
then(
onFulfilled?:
| ((snapshot: firebase.storage.UploadTaskSnapshot) => any)
| null,
onRejected?: ((error: FirebaseStorageError) => any) | null
): Promise<any>;
}
/**
* Holds data about the current state of the upload task.
*/
interface UploadTaskSnapshot {
/**
* The number of bytes that have been successfully uploaded so far.
*/
bytesTransferred: number;
/**
* Before the upload completes, contains the metadata sent to the server.
* After the upload completes, contains the metadata sent back from the server.
*/
metadata: firebase.storage.FullMetadata;
/**
* The reference that spawned this snapshot's upload task.
*/
ref: firebase.storage.Reference;
/**
* The current state of the task.
*/
state: firebase.storage.TaskState;
/**
* The task of which this is a snapshot.
*/
task: firebase.storage.UploadTask;
/**
* The total number of bytes to be uploaded.
*/
totalBytes: number;
}
/**
* An error returned by the Firebase Storage SDK.
*/
export interface FirebaseStorageError extends FirebaseError {
/**
* Stores custom error data unique to the `StorageError`.
*/
customData: {
serverResponse: string | null;
};
get status(): number;
set status(status: number);
/**
* Compares a `StorageErrorCode` against this error's code, filtering out the prefix.
*/
_codeEquals(code: StorageErrorCode): boolean;
/**
* Optional response message that was added by the server.
*/
get serverResponse(): null | string;
set serverResponse(serverResponse: string | null);
}
}
declare namespace firebase.firestore {
/**
* Document data (for use with `DocumentReference.set()`) consists of fields
* mapped to values.
*/
export type DocumentData = { [field: string]: any };
/**
* Update data (for use with `DocumentReference.update()`) consists of field
* paths (e.g. 'foo' or 'foo.baz') mapped to values. Fields that contain dots
* reference nested fields within the document.
*/
export type UpdateData = { [fieldPath: string]: any };
/**
* Constant used to indicate the LRU garbage collection should be disabled.
* Set this value as the `cacheSizeBytes` on the settings passed to the
* `Firestore` instance.
*/
export const CACHE_SIZE_UNLIMITED: number;
/**
* Specifies custom configurations for your Cloud Firestore instance.
* You must set these before invoking any other methods.
*/
export interface Settings {
/** The hostname to connect to. */
host?: string;
/** Whether to use SSL when connecting. */
ssl?: boolean;
/**
* An approximate cache size threshold for the on-disk data. If the cache grows beyond this
* size, Firestore will start removing data that hasn't been recently used. The size is not a
* guarantee that the cache will stay below that size, only that if the cache exceeds the given
* size, cleanup will be attempted.
*
* The default value is 40 MB. The threshold must be set to at least 1 MB, and can be set to
* CACHE_SIZE_UNLIMITED to disable garbage collection.
*/
cacheSizeBytes?: number;
/**
* Forces the SDK’s underlying network transport (WebChannel) to use
* long-polling. Each response from the backend will be closed immediately
* after the backend sends data (by default responses are kept open in
* case the backend has more data to send). This avoids incompatibility
* issues with certain proxies, antivirus software, etc. that incorrectly
* buffer traffic indefinitely. Use of this option will cause some
* performance degradation though.
*
* This setting cannot be used with `experimentalAutoDetectLongPolling` and
* may be removed in a future release. If you find yourself using it to
* work around a specific network reliability issue, please tell us about
* it in https://github.com/firebase/firebase-js-sdk/issues/1674.
*
* This setting does not work in a Node.js environment.
*/
experimentalForceLongPolling?: boolean;
/**
* Configures the SDK's underlying transport (WebChannel) to automatically detect if
* long-polling should be used. This is very similar to `experimentalForceLongPolling`,
* but only uses long-polling if required.
*
* This setting will likely be enabled by default in future releases and cannot be
* combined with `experimentalForceLongPolling`.
*
* This setting does not work in a Node.js environment.
*/
experimentalAutoDetectLongPolling?: boolean;
/**
* Whether to skip nested properties that are set to `undefined` during
* object serialization. If set to `true`, these properties are skipped
* and not written to Firestore. If set to `false` or omitted, the SDK
* throws an exception when it encounters properties of type `undefined`.
*/
ignoreUndefinedProperties?: boolean;
/**
* Whether to merge the provided settings with the existing settings. If
* set to `true`, the settings are merged with existing settings. If
* set to `false` or left unset, the settings replace the existing
* settings.
*/
merge?: boolean;
}
/**
* Settings that can be passed to Firestore.enablePersistence() to configure
* Firestore persistence.
*/
export interface PersistenceSettings {
/**
* Whether to synchronize the in-memory state of multiple tabs. Setting this
* to `true` in all open tabs enables shared access to local persistence,
* shared execution of queries and latency-compensated local document updates
* across all connected instances.
*
* To enable this mode, `synchronizeTabs:true` needs to be set globally in all
* active tabs. If omitted or set to 'false', `enablePersistence()` will fail
* in all but the first tab.
*/
synchronizeTabs?: boolean;
/**
* Whether to force enable persistence for the client. This cannot be used
* with `synchronizeTabs:true` and is primarily intended for use with Web
* Workers. Setting this to `true` will enable persistence, but cause other
* tabs using persistence to fail.
*
* This setting may be removed in a future release. If you find yourself
* using it for a specific use case or run into any issues, please tell us
* about it in
* https://github.com/firebase/firebase-js-sdk/issues/983.
*/
experimentalForceOwningTab?: boolean;
}
export type LogLevel = 'debug' | 'error' | 'silent';
/**
* Sets the verbosity of Cloud Firestore logs (debug, error, or silent).
*
* @param logLevel
* The verbosity you set for activity and error logging. Can be any of
* the following values:
*
* <ul>
* <li><code>debug</code> for the most verbose logging level, primarily for
* debugging.</li>
* <li><code>error</code> to log errors only.</li>
* <li><code>silent</code> to turn off logging.</li>
* </ul>
*/
export function setLogLevel(logLevel: LogLevel): void;
/**
* Converter used by `withConverter()` to transform user objects of type T
* into Firestore data.
*
* Using the converter allows you to specify generic type arguments when
* storing and retrieving objects from Firestore.
*
* @example
* ```typescript
* class Post {
* constructor(readonly title: string, readonly author: string) {}
*
* toString(): string {
* return this.title + ', by ' + this.author;
* }
* }
*
* const postConverter = {
* toFirestore(post: Post): firebase.firestore.DocumentData {
* return {title: post.title, author: post.author};
* },
* fromFirestore(
* snapshot: firebase.firestore.QueryDocumentSnapshot,
* options: firebase.firestore.SnapshotOptions
* ): Post {
* const data = snapshot.data(options)!;
* return new Post(data.title, data.author);
* }
* };
*
* const postSnap = await firebase.firestore()
* .collection('posts')
* .withConverter(postConverter)
* .doc().get();
* const post = postSnap.data();
* if (post !== undefined) {
* post.title; // string
* post.toString(); // Should be defined
* post.someNonExistentProperty; // TS error
* }
* ```
*/
export interface FirestoreDataConverter<T> {
/**
* Called by the Firestore SDK to convert a custom model object of type T
* into a plain JavaScript object (suitable for writing directly to the
* Firestore database). To use `set()` with `merge` and `mergeFields`,
* `toFirestore()` must be defined with `Partial<T>`.
*/
toFirestore(modelObject: T): DocumentData;
toFirestore(modelObject: Partial<T>, options: SetOptions): DocumentData;
/**
* Called by the Firestore SDK to convert Firestore data into an object of
* type T. You can access your data by calling: `snapshot.data(options)`.
*
* @param snapshot A QueryDocumentSnapshot containing your data and metadata.
* @param options The SnapshotOptions from the initial call to `data()`.
*/
fromFirestore(snapshot: QueryDocumentSnapshot, options: SnapshotOptions): T;
}
/**
* The Cloud Firestore service interface.
*
* Do not call this constructor directly. Instead, use
* {@link firebase.firestore `firebase.firestore()`}.
*/
export class Firestore {
private constructor();
/**
* Specifies custom settings to be used to configure the `Firestore`
* instance. Must be set before invoking any other methods.
*
* @param settings The settings to use.
*/
settings(settings: Settings): void;
/**
* Modify this instance to communicate with the Cloud Firestore emulator.
*
* <p>Note: this must be called before this instance has been used to do any operations.
*
* @param host the emulator host (ex: localhost).
* @param port the emulator port (ex: 9000).
* @param options.mockUserToken - the mock auth token to use for unit
* testing Security Rules.
*/
useEmulator(
host: string,
port: number,
options?: {
mockUserToken?: EmulatorMockTokenOptions | string;
}
): void;
/**
* Attempts to enable persistent storage, if possible.
*
* Must be called before any other methods (other than settings() and
* clearPersistence()).
*
* If this fails, enablePersistence() will reject the promise it returns.
* Note that even after this failure, the firestore instance will remain
* usable, however offline persistence will be disabled.
*
* There are several reasons why this can fail, which can be identified by
* the `code` on the error.
*
* * failed-precondition: The app is already open in another browser tab.
* * unimplemented: The browser is incompatible with the offline
* persistence implementation.
*
* @param settings Optional settings object to configure persistence.
* @return A promise that represents successfully enabling persistent
* storage.
*/
enablePersistence(settings?: PersistenceSettings): Promise<void>;
/**
* Gets a `CollectionReference` instance that refers to the collection at
* the specified path.
*
* @param collectionPath A slash-separated path to a collection.
* @return The `CollectionReference` instance.
*/
collection(collectionPath: string): CollectionReference<DocumentData>;
/**
* Gets a `DocumentReference` instance that refers to the document at the
* specified path.
*
* @param documentPath A slash-separated path to a document.
* @return The `DocumentReference` instance.
*/
doc(documentPath: string): DocumentReference<DocumentData>;
/**
* Creates and returns a new Query that includes all documents in the
* database that are contained in a collection or subcollection with the
* given collectionId.
*
* @param collectionId Identifies the collections to query over. Every
* collection or subcollection with this ID as the last segment of its path
* will be included. Cannot contain a slash.
* @return The created Query.
*/
collectionGroup(collectionId: string): Query<DocumentData>;
/**
* Executes the given `updateFunction` and then attempts to commit the changes
* applied within the transaction. If any document read within the transaction
* has changed, Cloud Firestore retries the `updateFunction`. If it fails to
* commit after 5 attempts, the transaction fails.
*
* The maximum number of writes allowed in a single transaction is 500, but
* note that each usage of `FieldValue.serverTimestamp()`,
* `FieldValue.arrayUnion()`, `FieldValue.arrayRemove()`, or
* `FieldValue.increment()` inside a transaction counts as an additional write.
*
* @param updateFunction
* The function to execute within the transaction context.
*
* @return
* If the transaction completed successfully or was explicitly aborted
* (the `updateFunction` returned a failed promise),
* the promise returned by the updateFunction is returned here. Else, if the
* transaction failed, a rejected promise with the corresponding failure
* error will be returned.
*/
runTransaction<T>(
updateFunction: (transaction: Transaction) => Promise<T>
): Promise<T>;
/**
* Creates a write batch, used for performing multiple writes as a single
* atomic operation. The maximum number of writes allowed in a single WriteBatch
* is 500, but note that each usage of `FieldValue.serverTimestamp()`,
* `FieldValue.arrayUnion()`, `FieldValue.arrayRemove()`, or
* `FieldValue.increment()` inside a WriteBatch counts as an additional write.
*
* @return
* A `WriteBatch` that can be used to atomically execute multiple writes.
*/
batch(): WriteBatch;
/**
* The {@link firebase.app.App app} associated with this `Firestore` service
* instance.
*/
app: firebase.app.App;
/**
* Clears the persistent storage. This includes pending writes and cached
* documents.
*
* Must be called while the firestore instance is not started (after the app
* is shutdown or when the app is first initialized). On startup, this
* method must be called before other methods (other than settings()). If
* the firestore instance is still running, the promise will be rejected
* with the error code of `failed-precondition`.
*
* Note: clearPersistence() is primarily intended to help write reliable
* tests that use Cloud Firestore. It uses an efficient mechanism for
* dropping existing data but does not attempt to securely overwrite or
* otherwise make cached data unrecoverable. For applications that are
* sensitive to the disclosure of cached data in between user sessions, we
* strongly recommend not enabling persistence at all.
*
* @return A promise that is resolved when the persistent storage is
* cleared. Otherwise, the promise is rejected with an error.
*/
clearPersistence(): Promise<void>;
/**
* Re-enables use of the network for this Firestore instance after a prior
* call to {@link firebase.firestore.Firestore.disableNetwork
* `disableNetwork()`}.
*
* @return A promise that is resolved once the network has been
* enabled.
*/
enableNetwork(): Promise<void>;
/**
* Disables network usage for this instance. It can be re-enabled via
* {@link firebase.firestore.Firestore.enableNetwork `enableNetwork()`}. While
* the network is disabled, any snapshot listeners or get() calls will return
* results from cache, and any write operations will be queued until the network
* is restored.
*
* @return A promise that is resolved once the network has been
* disabled.
*/
disableNetwork(): Promise<void>;
/**
* Waits until all currently pending writes for the active user have been acknowledged by the
* backend.
*
* The returned Promise resolves immediately if there are no outstanding writes. Otherwise, the
* Promise waits for all previously issued writes (including those written in a previous app
* session), but it does not wait for writes that were added after the method is called. If you
* want to wait for additional writes, call `waitForPendingWrites()` again.
*
* Any outstanding `waitForPendingWrites()` Promises are rejected during user changes.
*
* @return A Promise which resolves when all currently pending writes have been
* acknowledged by the backend.
*/
waitForPendingWrites(): Promise<void>;
/**
* Attaches a listener for a snapshots-in-sync event. The snapshots-in-sync
* event indicates that all listeners affected by a given change have fired,
* even if a single server-generated change affects multiple listeners.
*
* NOTE: The snapshots-in-sync event only indicates that listeners are in sync
* with each other, but does not relate to whether those snapshots are in sync
* with the server. Use SnapshotMetadata in the individual listeners to
* determine if a snapshot is from the cache or the server.
*
* @param observer A single object containing `next` and `error` callbacks.
* @return An unsubscribe function that can be called to cancel the snapshot
* listener.
*/
onSnapshotsInSync(observer: {
next?: (value: void) => void;
error?: (error: FirestoreError) => void;
complete?: () => void;
}): () => void;
/**
* Attaches a listener for a snapshots-in-sync event. The snapshots-in-sync
* event indicates that all listeners affected by a given change have fired,
* even if a single server-generated change affects multiple listeners.
*
* NOTE: The snapshots-in-sync event only indicates that listeners are in sync
* with each other, but does not relate to whether those snapshots are in sync
* with the server. Use SnapshotMetadata in the individual listeners to
* determine if a snapshot is from the cache or the server.
*
* @param onSync A callback to be called every time all snapshot listeners are
* in sync with each other.
* @return An unsubscribe function that can be called to cancel the snapshot
* listener.
*/
onSnapshotsInSync(onSync: () => void): () => void;
/**
* Terminates this Firestore instance.
*
* After calling `terminate()` only the `clearPersistence()` method may be used. Any other method
* will throw a `FirestoreError`.
*
* To restart after termination, create a new instance of FirebaseFirestore with
* `firebase.firestore()`.
*
* Termination does not cancel any pending writes, and any promises that are awaiting a response
* from the server will not be resolved. If you have persistence enabled, the next time you
* start this instance, it will resume sending these writes to the server.
*
* Note: Under normal circumstances, calling `terminate()` is not required. This
* method is useful only when you want to force this instance to release all of its resources or
* in combination with `clearPersistence()` to ensure that all local state is destroyed
* between test runs.
*
* @return A promise that is resolved when the instance has been successfully terminated.
*/
terminate(): Promise<void>;
/**
* Loads a Firestore bundle into the local cache.
*
* @param bundleData
* An object representing the bundle to be loaded. Valid objects are `ArrayBuffer`,
* `ReadableStream<Uint8Array>` or `string`.
*
* @return
* A `LoadBundleTask` object, which notifies callers with progress updates, and completion
* or error events. It can be used as a `Promise<LoadBundleTaskProgress>`.
*/
loadBundle(
bundleData: ArrayBuffer | ReadableStream<Uint8Array> | string
): LoadBundleTask;
/**
* Reads a Firestore `Query` from local cache, identified by the given name.
*
* The named queries are packaged into bundles on the server side (along
* with resulting documents), and loaded to local cache using `loadBundle`. Once in local
* cache, use this method to extract a `Query` by name.
*/
namedQuery(name: string): Promise<Query<DocumentData> | null>;
/**
* @hidden
*/
INTERNAL: { delete: () => Promise<void> };
}
/**
* Represents the task of loading a Firestore bundle. It provides progress of bundle
* loading, as well as task completion and error events.
*
* The API is compatible with `Promise<LoadBundleTaskProgress>`.
*/
export interface LoadBundleTask extends PromiseLike<LoadBundleTaskProgress> {
/**
* Registers functions to listen to bundle loading progress events.
* @param next
* Called when there is a progress update from bundle loading. Typically `next` calls occur
* each time a Firestore document is loaded from the bundle.
* @param error
* Called when an error occurs during bundle loading. The task aborts after reporting the
* error, and there should be no more updates after this.
* @param complete
* Called when the loading task is complete.
*/
onProgress(
next?: (progress: LoadBundleTaskProgress) => any,
error?: (error: Error) => any,
complete?: () => void
): void;
/**
* Implements the `Promise<LoadBundleTaskProgress>.then` interface.
*
* @param onFulfilled
* Called on the completion of the loading task with a final `LoadBundleTaskProgress` update.
* The update will always have its `taskState` set to `"Success"`.
* @param onRejected
* Called when an error occurs during bundle loading.
*/
then<T, R>(
onFulfilled?: (a: LoadBundleTaskProgress) => T | PromiseLike<T>,
onRejected?: (a: Error) => R | PromiseLike<R>
): Promise<T | R>;
/**
* Implements the `Promise<LoadBundleTaskProgress>.catch` interface.
*
* @param onRejected
* Called when an error occurs during bundle loading.
*/
catch<R>(
onRejected: (a: Error) => R | PromiseLike<R>
): Promise<R | LoadBundleTaskProgress>;
}
/**
* Represents a progress update or a final state from loading bundles.
*/
export interface LoadBundleTaskProgress {
/** How many documents have been loaded. */
documentsLoaded: number;
/** How many documents are in the bundle being loaded. */
totalDocuments: number;
/** How many bytes have been loaded. */
bytesLoaded: number;
/** How many bytes are in the bundle being loaded. */
totalBytes: number;
/** Current task state. */
taskState: TaskState;
}
/**
* Represents the state of bundle loading tasks.
*
* Both 'Error' and 'Success' are sinking state: task will abort or complete and there will
* be no more updates after they are reported.
*/
export type TaskState = 'Error' | 'Running' | 'Success';
/**
* An immutable object representing a geo point in Firestore. The geo point
* is represented as latitude/longitude pair.
*
* Latitude values are in the range of [-90, 90].
* Longitude values are in the range of [-180, 180].
*/
export class GeoPoint {
/**
* Creates a new immutable GeoPoint object with the provided latitude and
* longitude values.
* @param latitude The latitude as number between -90 and 90.
* @param longitude The longitude as number between -180 and 180.
*/
constructor(latitude: number, longitude: number);
/**
* The latitude of this GeoPoint instance.
*/
readonly latitude: number;
/**
* The longitude of this GeoPoint instance.
*/
readonly longitude: number;
/**
* Returns true if this `GeoPoint` is equal to the provided one.
*
* @param other The `GeoPoint` to compare against.
* @return true if this `GeoPoint` is equal to the provided one.
*/
isEqual(other: GeoPoint): boolean;
}
/**
* A Timestamp represents a point in time independent of any time zone or
* calendar, represented as seconds and fractions of seconds at nanosecond
* resolution in UTC Epoch time.
*
* It is encoded using the Proleptic Gregorian
* Calendar which extends the Gregorian calendar backwards to year one. It is
* encoded assuming all minutes are 60 seconds long, i.e. leap seconds are
* "smeared" so that no leap second table is needed for interpretation. Range is
* from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z.
*
* @see https://github.com/google/protobuf/blob/master/src/google/protobuf/timestamp.proto
*/
export class Timestamp {
/**
* Creates a new timestamp.
*
* @param seconds The number of seconds of UTC time since Unix epoch
* 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to
* 9999-12-31T23:59:59Z inclusive.
* @param nanoseconds The non-negative fractions of a second at nanosecond
* resolution. Negative second values with fractions must still have
* non-negative nanoseconds values that count forward in time. Must be
* from 0 to 999,999,999 inclusive.
*/
constructor(seconds: number, nanoseconds: number);
/**
* Creates a new timestamp with the current date, with millisecond precision.
*
* @return a new timestamp representing the current date.
*/
static now(): Timestamp;
/**
* Creates a new timestamp from the given date.
*
* @param date The date to initialize the `Timestamp` from.
* @return A new `Timestamp` representing the same point in time as the given
* date.
*/
static fromDate(date: Date): Timestamp;
/**
* Creates a new timestamp from the given number of milliseconds.
*
* @param milliseconds Number of milliseconds since Unix epoch
* 1970-01-01T00:00:00Z.
* @return A new `Timestamp` representing the same point in time as the given
* number of milliseconds.
*/
static fromMillis(milliseconds: number): Timestamp;
readonly seconds: number;
readonly nanoseconds: number;
/**
* Convert a Timestamp to a JavaScript `Date` object. This conversion causes
* a loss of precision since `Date` objects only support millisecond precision.
*
* @return JavaScript `Date` object representing the same point in time as
* this `Timestamp`, with millisecond precision.
*/
toDate(): Date;
/**
* Convert a timestamp to a numeric timestamp (in milliseconds since epoch).
* This operation causes a loss of precision.
*
* @return The point in time corresponding to this timestamp, represented as
* the number of milliseconds since Unix epoch 1970-01-01T00:00:00Z.
*/
toMillis(): number;
/**
* Returns true if this `Timestamp` is equal to the provided one.
*
* @param other The `Timestamp` to compare against.
* @return true if this `Timestamp` is equal to the provided one.
*/
isEqual(other: Timestamp): boolean;
/**
* Converts this object to a primitive string, which allows Timestamp objects to be compared
* using the `>`, `<=`, `>=` and `>` operators.
*/
valueOf(): string;
}
/**
* An immutable object representing an array of bytes.
*/
export class Blob {
private constructor();
/**
* Creates a new Blob from the given Base64 string, converting it to
* bytes.
*
* @param base64
* The Base64 string used to create the Blob object.
*/
static fromBase64String(base64: string): Blob;
/**
* Creates a new Blob from the given Uint8Array.
*
* @param array
* The Uint8Array used to create the Blob object.
*/
static fromUint8Array(array: Uint8Array): Blob;
/**
* Returns the bytes of a Blob as a Base64-encoded string.
*
* @return
* The Base64-encoded string created from the Blob object.
*/
public toBase64(): string;
/**
* Returns the bytes of a Blob in a new Uint8Array.
*
* @return
* The Uint8Array created from the Blob object.
*/
public toUint8Array(): Uint8Array;
/**
* Returns true if this `Blob` is equal to the provided one.
*
* @param other The `Blob` to compare against.
* @return true if this `Blob` is equal to the provided one.
*/
isEqual(other: Blob): boolean;
}
/**
* A reference to a transaction.
* The `Transaction` object passed to a transaction's updateFunction provides
* the methods to read and write data within the transaction context. See
* `Firestore.runTransaction()`.
*/
export class Transaction {
private constructor();
/**
* Reads the document referenced by the provided `DocumentReference.`
*
* @param documentRef A reference to the document to be read.
* @return A DocumentSnapshot for the read data.
*/
get<T>(documentRef: DocumentReference<T>): Promise<DocumentSnapshot<T>>;
/**
* Writes to the document referred to by the provided `DocumentReference`.
* If the document does not exist yet, it will be created. If you pass
* `SetOptions`, the provided data can be merged into the existing document.
*
* @param documentRef A reference to the document to be set.
* @param data An object of the fields and values for the document.
* @param options An object to configure the set behavior.
* @return This `Transaction` instance. Used for chaining method calls.
*/
set<T>(
documentRef: DocumentReference<T>,
data: Partial<T>,
options: SetOptions
): Transaction;
/**
* Writes to the document referred to by the provided `DocumentReference`.
* If the document does not exist yet, it will be created. If you pass
* `SetOptions`, the provided data can be merged into the existing document.
*
* @param documentRef A reference to the document to be set.
* @param data An object of the fields and values for the document.
* @return This `Transaction` instance. Used for chaining method calls.
*/
set<T>(documentRef: DocumentReference<T>, data: T): Transaction;
/**
* Updates fields in the document referred to by the provided
* `DocumentReference`. The update will fail if applied to a document that
* does not exist.
*
* @param documentRef A reference to the document to be updated.
* @param data An object containing the fields and values with which to
* update the document. Fields can contain dots to reference nested fields
* within the document.
* @return This `Transaction` instance. Used for chaining method calls.
*/
update(documentRef: DocumentReference<any>, data: UpdateData): Transaction;
/**
* Updates fields in the document referred to by the provided
* `DocumentReference`. The update will fail if applied to a document that
* does not exist.
*
* Nested fields can be updated by providing dot-separated field path
* strings or by providing FieldPath objects.
*
* @param documentRef A reference to the document to be updated.
* @param field The first field to update.
* @param value The first value.
* @param moreFieldsAndValues Additional key/value pairs.
* @return A Promise resolved once the data has been successfully written
* to the backend (Note that it won't resolve while you're offline).
*/
update(
documentRef: DocumentReference<any>,
field: string | FieldPath,
value: any,
...moreFieldsAndValues: any[]
): Transaction;
/**
* Deletes the document referred to by the provided `DocumentReference`.
*
* @param documentRef A reference to the document to be deleted.
* @return This `Transaction` instance. Used for chaining method calls.
*/
delete(documentRef: DocumentReference<any>): Transaction;
}
/**
* A write batch, used to perform multiple writes as a single atomic unit.
*
* A `WriteBatch` object can be acquired by calling `Firestore.batch()`. It
* provides methods for adding writes to the write batch. None of the
* writes will be committed (or visible locally) until `WriteBatch.commit()`
* is called.
*
* Unlike transactions, write batches are persisted offline and therefore are
* preferable when you don't need to condition your writes on read data.
*/
export class WriteBatch {
private constructor();
/**
* Writes to the document referred to by the provided `DocumentReference`.
* If the document does not exist yet, it will be created. If you pass
* `SetOptions`, the provided data can be merged into the existing document.
*
* @param documentRef A reference to the document to be set.
* @param data An object of the fields and values for the document.
* @param options An object to configure the set behavior.
* @return This `WriteBatch` instance. Used for chaining method calls.
*/
set<T>(
documentRef: DocumentReference<T>,
data: Partial<T>,
options: SetOptions
): WriteBatch;
/**
* Writes to the document referred to by the provided `DocumentReference`.
* If the document does not exist yet, it will be created. If you pass
* `SetOptions`, the provided data can be merged into the existing document.
*
* @param documentRef A reference to the document to be set.
* @param data An object of the fields and values for the document.
* @return This `WriteBatch` instance. Used for chaining method calls.
*/
set<T>(documentRef: DocumentReference<T>, data: T): WriteBatch;
/**
* Updates fields in the document referred to by the provided
* `DocumentReference`. The update will fail if applied to a document that
* does not exist.
*
* @param documentRef A reference to the document to be updated.
* @param data An object containing the fields and values with which to
* update the document. Fields can contain dots to reference nested fields
* within the document.
* @return This `WriteBatch` instance. Used for chaining method calls.
*/
update(documentRef: DocumentReference<any>, data: UpdateData): WriteBatch;
/**
* Updates fields in the document referred to by this `DocumentReference`.
* The update will fail if applied to a document that does not exist.
*
* Nested fields can be update by providing dot-separated field path strings
* or by providing FieldPath objects.
*
* @param documentRef A reference to the document to be updated.
* @param field The first field to update.
* @param value The first value.
* @param moreFieldsAndValues Additional key value pairs.
* @return A Promise resolved once the data has been successfully written
* to the backend (Note that it won't resolve while you're offline).
*/
update(
documentRef: DocumentReference<any>,
field: string | FieldPath,
value: any,
...moreFieldsAndValues: any[]
): WriteBatch;
/**
* Deletes the document referred to by the provided `DocumentReference`.
*
* @param documentRef A reference to the document to be deleted.
* @return This `WriteBatch` instance. Used for chaining method calls.
*/
delete(documentRef: DocumentReference<any>): WriteBatch;
/**
* Commits all of the writes in this write batch as a single atomic unit.
*
* @return A Promise resolved once all of the writes in the batch have been
* successfully written to the backend as an atomic unit. Note that it won't
* resolve while you're offline.
*/
commit(): Promise<void>;
}
/**
* An options object that can be passed to `DocumentReference.onSnapshot()`,
* `Query.onSnapshot()` and `QuerySnapshot.docChanges()` to control which
* types of changes to include in the result set.
*/
export interface SnapshotListenOptions {
/**
* Include a change even if only the metadata of the query or of a document
* changed. Default is false.
*/
readonly includeMetadataChanges?: boolean;
}
/**
* An options object that configures the behavior of `set()` calls in
* {@link firebase.firestore.DocumentReference.set DocumentReference}, {@link
* firebase.firestore.WriteBatch.set WriteBatch} and {@link
* firebase.firestore.Transaction.set Transaction}. These calls can be
* configured to perform granular merges instead of overwriting the target
* documents in their entirety by providing a `SetOptions` with `merge: true`.
*/
export interface SetOptions {
/**
* Changes the behavior of a set() call to only replace the values specified
* in its data argument. Fields omitted from the set() call remain
* untouched.
*/
readonly merge?: boolean;
/**
* Changes the behavior of set() calls to only replace the specified field
* paths. Any field path that is not specified is ignored and remains
* untouched.
*/
readonly mergeFields?: (string | FieldPath)[];
}
/**
* An options object that configures the behavior of `get()` calls on
* `DocumentReference` and `Query`. By providing a `GetOptions` object, these
* methods can be configured to fetch results only from the server, only from
* the local cache or attempt to fetch results from the server and fall back to
* the cache (which is the default).
*/
export interface GetOptions {
/**
* Describes whether we should get from server or cache.
*
* Setting to `default` (or not setting at all), causes Firestore to try to
* retrieve an up-to-date (server-retrieved) snapshot, but fall back to
* returning cached data if the server can't be reached.
*
* Setting to `server` causes Firestore to avoid the cache, generating an
* error if the server cannot be reached. Note that the cache will still be
* updated if the server request succeeds. Also note that latency-compensation
* still takes effect, so any pending write operations will be visible in the
* returned data (merged into the server-provided data).
*
* Setting to `cache` causes Firestore to immediately return a value from the
* cache, ignoring the server completely (implying that the returned value
* may be stale with respect to the value on the server.) If there is no data
* in the cache to satisfy the `get()` call, `DocumentReference.get()` will
* return an error and `QuerySnapshot.get()` will return an empty
* `QuerySnapshot` with no documents.
*/
readonly source?: 'default' | 'server' | 'cache';
}
/**
* A `DocumentReference` refers to a document location in a Firestore database
* and can be used to write, read, or listen to the location. The document at
* the referenced location may or may not exist. A `DocumentReference` can
* also be used to create a `CollectionReference` to a subcollection.
*/
export class DocumentReference<T = DocumentData> {
private constructor();
/**
* The document's identifier within its collection.
*/
readonly id: string;
/**
* The {@link firebase.firestore.Firestore} the document is in.
* This is useful for performing transactions, for example.
*/
readonly firestore: Firestore;
/**
* The Collection this `DocumentReference` belongs to.
*/
readonly parent: CollectionReference<T>;
/**
* A string representing the path of the referenced document (relative
* to the root of the database).
*/
readonly path: string;
/**
* Gets a `CollectionReference` instance that refers to the collection at
* the specified path.
*
* @param collectionPath A slash-separated path to a collection.
* @return The `CollectionReference` instance.
*/
collection(collectionPath: string): CollectionReference<DocumentData>;
/**
* Returns true if this `DocumentReference` is equal to the provided one.
*
* @param other The `DocumentReference` to compare against.
* @return true if this `DocumentReference` is equal to the provided one.
*/
isEqual(other: DocumentReference<T>): boolean;
/**
* Writes to the document referred to by this `DocumentReference`. If the
* document does not yet exist, it will be created. If you pass
* `SetOptions`, the provided data can be merged into an existing document.
*
* @param data A map of the fields and values for the document.
* @param options An object to configure the set behavior.
* @return A Promise resolved once the data has been successfully written
* to the backend (Note that it won't resolve while you're offline).
*/
set(data: Partial<T>, options: SetOptions): Promise<void>;
/**
* Writes to the document referred to by this `DocumentReference`. If the
* document does not yet exist, it will be created. If you pass
* `SetOptions`, the provided data can be merged into an existing document.
*
* @param data A map of the fields and values for the document.
* @return A Promise resolved once the data has been successfully written
* to the backend (Note that it won't resolve while you're offline).
*/
set(data: T): Promise<void>;
/**
* Updates fields in the document referred to by this `DocumentReference`.
* The update will fail if applied to a document that does not exist.
*
* @param data An object containing the fields and values with which to
* update the document. Fields can contain dots to reference nested fields
* within the document.
* @return A Promise resolved once the data has been successfully written
* to the backend (Note that it won't resolve while you're offline).
*/
update(data: UpdateData): Promise<void>;
/**
* Updates fields in the document referred to by this `DocumentReference`.
* The update will fail if applied to a document that does not exist.
*
* Nested fields can be updated by providing dot-separated field path
* strings or by providing FieldPath objects.
*
* @param field The first field to update.
* @param value The first value.
* @param moreFieldsAndValues Additional key value pairs.
* @return A Promise resolved once the data has been successfully written
* to the backend (Note that it won't resolve while you're offline).
*/
update(
field: string | FieldPath,
value: any,
...moreFieldsAndValues: any[]
): Promise<void>;
/**
* Deletes the document referred to by this `DocumentReference`.
*
* @return A Promise resolved once the document has been successfully
* deleted from the backend (Note that it won't resolve while you're
* offline).
*/
delete(): Promise<void>;
/**
* Reads the document referred to by this `DocumentReference`.
*
* Note: By default, get() attempts to provide up-to-date data when possible
* by waiting for data from the server, but it may return cached data or fail
* if you are offline and the server cannot be reached. This behavior can be
* altered via the `GetOptions` parameter.
*
* @param options An object to configure the get behavior.
* @return A Promise resolved with a DocumentSnapshot containing the
* current document contents.
*/
get(options?: GetOptions): Promise<DocumentSnapshot<T>>;
/**
* Attaches a listener for DocumentSnapshot events. You may either pass
* individual `onNext` and `onError` callbacks or pass a single observer
* object with `next` and `error` callbacks.
*
* NOTE: Although an `onCompletion` callback can be provided, it will
* never be called because the snapshot stream is never-ending.
*
* @param observer A single object containing `next` and `error` callbacks.
* @return An unsubscribe function that can be called to cancel
* the snapshot listener.
*/
onSnapshot(observer: {
next?: (snapshot: DocumentSnapshot<T>) => void;
error?: (error: FirestoreError) => void;
complete?: () => void;
}): () => void;
/**
* Attaches a listener for DocumentSnapshot events. You may either pass
* individual `onNext` and `onError` callbacks or pass a single observer
* object with `next` and `error` callbacks.
*
* NOTE: Although an `onCompletion` callback can be provided, it will
* never be called because the snapshot stream is never-ending.
*
* @param options Options controlling the listen behavior.
* @param observer A single object containing `next` and `error` callbacks.
* @return An unsubscribe function that can be called to cancel
* the snapshot listener.
*/
onSnapshot(
options: SnapshotListenOptions,
observer: {
next?: (snapshot: DocumentSnapshot<T>) => void;
error?: (error: FirestoreError) => void;
complete?: () => void;
}
): () => void;
/**
* Attaches a listener for DocumentSnapshot events. You may either pass
* individual `onNext` and `onError` callbacks or pass a single observer
* object with `next` and `error` callbacks.
*
* NOTE: Although an `onCompletion` callback can be provided, it will
* never be called because the snapshot stream is never-ending.
*
* @param onNext A callback to be called every time a new `DocumentSnapshot`
* is available.
* @param onError A callback to be called if the listen fails or is
* cancelled. No further callbacks will occur.
* @return An unsubscribe function that can be called to cancel
* the snapshot listener.
*/
onSnapshot(
onNext: (snapshot: DocumentSnapshot<T>) => void,
onError?: (error: FirestoreError) => void,
onCompletion?: () => void
): () => void;
/**
* Attaches a listener for DocumentSnapshot events. You may either pass
* individual `onNext` and `onError` callbacks or pass a single observer
* object with `next` and `error` callbacks.
*
* NOTE: Although an `onCompletion` callback can be provided, it will
* never be called because the snapshot stream is never-ending.
*
* @param options Options controlling the listen behavior.
* @param onNext A callback to be called every time a new `DocumentSnapshot`
* is available.
* @param onError A callback to be called if the listen fails or is
* cancelled. No further callbacks will occur.
* @return An unsubscribe function that can be called to cancel
* the snapshot listener.
*/
onSnapshot(
options: SnapshotListenOptions,
onNext: (snapshot: DocumentSnapshot<T>) => void,
onError?: (error: FirestoreError) => void,
onCompletion?: () => void
): () => void;
/**
* Applies a custom data converter to this DocumentReference, allowing you
* to use your own custom model objects with Firestore. When you call
* set(), get(), etc. on the returned DocumentReference instance, the
* provided converter will convert between Firestore data and your custom
* type U.
*
* Passing in `null` as the converter parameter removes the current
* converter.
*
* @param converter Converts objects to and from Firestore. Passing in
* `null` removes the current converter.
* @return A DocumentReference<U> that uses the provided converter.
*/
withConverter(converter: null): DocumentReference<DocumentData>;
/**
* Applies a custom data converter to this DocumentReference, allowing you
* to use your own custom model objects with Firestore. When you call
* set(), get(), etc. on the returned DocumentReference instance, the
* provided converter will convert between Firestore data and your custom
* type U.
*
* Passing in `null` as the converter parameter removes the current
* converter.
*
* @param converter Converts objects to and from Firestore. Passing in
* `null` removes the current converter.
* @return A DocumentReference<U> that uses the provided converter.
*/
withConverter<U>(
converter: FirestoreDataConverter<U>
): DocumentReference<U>;
}
/**
* Options that configure how data is retrieved from a `DocumentSnapshot`
* (e.g. the desired behavior for server timestamps that have not yet been set
* to their final value).
*/
export interface SnapshotOptions {
/**
* If set, controls the return value for server timestamps that have not yet
* been set to their final value.
*
* By specifying 'estimate', pending server timestamps return an estimate
* based on the local clock. This estimate will differ from the final value
* and cause these values to change once the server result becomes available.
*
* By specifying 'previous', pending timestamps will be ignored and return
* their previous value instead.
*
* If omitted or set to 'none', `null` will be returned by default until the
* server value becomes available.
*/
readonly serverTimestamps?: 'estimate' | 'previous' | 'none';
}
/**
* Metadata about a snapshot, describing the state of the snapshot.
*/
export interface SnapshotMetadata {
/**
* True if the snapshot contains the result of local writes (e.g. set() or
* update() calls) that have not yet been committed to the backend.
* If your listener has opted into metadata updates (via
* `SnapshotListenOptions`) you will receive another
* snapshot with `hasPendingWrites` equal to false once the writes have been
* committed to the backend.
*/
readonly hasPendingWrites: boolean;
/**
* True if the snapshot was created from cached data rather than guaranteed
* up-to-date server data. If your listener has opted into metadata updates
* (via `SnapshotListenOptions`)
* you will receive another snapshot with `fromCache` set to false once
* the client has received up-to-date data from the backend.
*/
readonly fromCache: boolean;
/**
* Returns true if this `SnapshotMetadata` is equal to the provided one.
*
* @param other The `SnapshotMetadata` to compare against.
* @return true if this `SnapshotMetadata` is equal to the provided one.
*/
isEqual(other: SnapshotMetadata): boolean;
}
/**
* A `DocumentSnapshot` contains data read from a document in your Firestore
* database. The data can be extracted with `.data()` or `.get(<field>)` to
* get a specific field.
*
* For a `DocumentSnapshot` that points to a non-existing document, any data
* access will return 'undefined'. You can use the `exists` property to
* explicitly verify a document's existence.
*/
export class DocumentSnapshot<T = DocumentData> {
protected constructor();
/**
* Property of the `DocumentSnapshot` that signals whether or not the data
* exists. True if the document exists.
*/
readonly exists: boolean;
/**
* The `DocumentReference` for the document included in the `DocumentSnapshot`.
*/
readonly ref: DocumentReference<T>;
/**
* Property of the `DocumentSnapshot` that provides the document's ID.
*/
readonly id: string;
/**
* Metadata about the `DocumentSnapshot`, including information about its
* source and local modifications.
*/
readonly metadata: SnapshotMetadata;
/**
* Retrieves all fields in the document as an Object. Returns 'undefined' if
* the document doesn't exist.
*
* By default, `FieldValue.serverTimestamp()` values that have not yet been
* set to their final value will be returned as `null`. You can override
* this by passing an options object.
*
* @param options An options object to configure how data is retrieved from
* the snapshot (e.g. the desired behavior for server timestamps that have
* not yet been set to their final value).
* @return An Object containing all fields in the document or 'undefined' if
* the document doesn't exist.
*/
data(options?: SnapshotOptions): T | undefined;
/**
* Retrieves the field specified by `fieldPath`. Returns `undefined` if the
* document or field doesn't exist.
*
* By default, a `FieldValue.serverTimestamp()` that has not yet been set to
* its final value will be returned as `null`. You can override this by
* passing an options object.
*
* @param fieldPath The path (e.g. 'foo' or 'foo.bar') to a specific field.
* @param options An options object to configure how the field is retrieved
* from the snapshot (e.g. the desired behavior for server timestamps that have
* not yet been set to their final value).
* @return The data at the specified field location or undefined if no such
* field exists in the document.
*/
get(fieldPath: string | FieldPath, options?: SnapshotOptions): any;
/**
* Returns true if this `DocumentSnapshot` is equal to the provided one.
*
* @param other The `DocumentSnapshot` to compare against.
* @return true if this `DocumentSnapshot` is equal to the provided one.
*/
isEqual(other: DocumentSnapshot<T>): boolean;
}
/**
* A `QueryDocumentSnapshot` contains data read from a document in your
* Firestore database as part of a query. The document is guaranteed to exist
* and its data can be extracted with `.data()` or `.get(<field>)` to get a
* specific field.
*
* A `QueryDocumentSnapshot` offers the same API surface as a
* `DocumentSnapshot`. Since query results contain only existing documents, the
* `exists` property will always be true and `data()` will never return
* 'undefined'.
*/
export class QueryDocumentSnapshot<
T = DocumentData
> extends DocumentSnapshot<T> {
private constructor();
/**
* Retrieves all fields in the document as an Object.
*
* By default, `FieldValue.serverTimestamp()` values that have not yet been
* set to their final value will be returned as `null`. You can override
* this by passing an options object.
*
* @override
* @param options An options object to configure how data is retrieved from
* the snapshot (e.g. the desired behavior for server timestamps that have
* not yet been set to their final value).
* @return An Object containing all fields in the document.
*/
data(options?: SnapshotOptions): T;
}
/**
* The direction of a `Query.orderBy()` clause is specified as 'desc' or 'asc'
* (descending or ascending).
*/
export type OrderByDirection = 'desc' | 'asc';
/**
* Filter conditions in a `Query.where()` clause are specified using the
* strings '<', '<=', '==', '!=', '>=', '>', 'array-contains', 'in',
* 'array-contains-any', and 'not-in'.
*/
export type WhereFilterOp =
| '<'
| '<='
| '=='
| '!='
| '>='
| '>'
| 'array-contains'
| 'in'
| 'array-contains-any'
| 'not-in';
/**
* A `Query` refers to a Query which you can read or listen to. You can also
* construct refined `Query` objects by adding filters and ordering.
*/
export class Query<T = DocumentData> {
protected constructor();
/**
* The `Firestore` for the Firestore database (useful for performing
* transactions, etc.).
*/
readonly firestore: Firestore;
/**
* Creates and returns a new Query with the additional filter that documents
* must contain the specified field and the value should satisfy the
* relation constraint provided.
*
* @param fieldPath The path to compare
* @param opStr The operation string (e.g "<", "<=", "==", ">", ">=").
* @param value The value for comparison
* @return The created Query.
*/
where(
fieldPath: string | FieldPath,
opStr: WhereFilterOp,
value: any
): Query<T>;
/**
* Creates and returns a new Query that's additionally sorted by the
* specified field, optionally in descending order instead of ascending.
*
* @param fieldPath The field to sort by.
* @param directionStr Optional direction to sort by (`asc` or `desc`). If
* not specified, order will be ascending.
* @return The created Query.
*/
orderBy(
fieldPath: string | FieldPath,
directionStr?: OrderByDirection
): Query<T>;
/**
* Creates and returns a new Query that only returns the first matching
* documents.
*
* @param limit The maximum number of items to return.
* @return The created Query.
*/
limit(limit: number): Query<T>;
/**
* Creates and returns a new Query that only returns the last matching
* documents.
*
* You must specify at least one `orderBy` clause for `limitToLast` queries,
* otherwise an exception will be thrown during execution.
*
* @param limit The maximum number of items to return.
* @return The created Query.
*/
limitToLast(limit: number): Query<T>;
/**
* Creates and returns a new Query that starts at the provided document
* (inclusive). The starting position is relative to the order of the query.
* The document must contain all of the fields provided in the `orderBy` of
* this query.
*
* @param snapshot The snapshot of the document to start at.
* @return The created Query.
*/
startAt(snapshot: DocumentSnapshot<any>): Query<T>;
/**
* Creates and returns a new Query that starts at the provided fields
* relative to the order of the query. The order of the field values
* must match the order of the order by clauses of the query.
*
* @param fieldValues The field values to start this query at, in order
* of the query's order by.
* @return The created Query.
*/
startAt(...fieldValues: any[]): Query<T>;
/**
* Creates and returns a new Query that starts after the provided document
* (exclusive). The starting position is relative to the order of the query.
* The document must contain all of the fields provided in the orderBy of
* this query.
*
* @param snapshot The snapshot of the document to start after.
* @return The created Query.
*/
startAfter(snapshot: DocumentSnapshot<any>): Query<T>;
/**
* Creates and returns a new Query that starts after the provided fields
* relative to the order of the query. The order of the field values
* must match the order of the order by clauses of the query.
*
* @param fieldValues The field values to start this query after, in order
* of the query's order by.
* @return The created Query.
*/
startAfter(...fieldValues: any[]): Query<T>;
/**
* Creates and returns a new Query that ends before the provided document
* (exclusive). The end position is relative to the order of the query. The
* document must contain all of the fields provided in the orderBy of this
* query.
*
* @param snapshot The snapshot of the document to end before.
* @return The created Query.
*/
endBefore(snapshot: DocumentSnapshot<any>): Query<T>;
/**
* Creates and returns a new Query that ends before the provided fields
* relative to the order of the query. The order of the field values
* must match the order of the order by clauses of the query.
*
* @param fieldValues The field values to end this query before, in order
* of the query's order by.
* @return The created Query.
*/
endBefore(...fieldValues: any[]): Query<T>;
/**
* Creates and returns a new Query that ends at the provided document
* (inclusive). The end position is relative to the order of the query. The
* document must contain all of the fields provided in the orderBy of this
* query.
*
* @param snapshot The snapshot of the document to end at.
* @return The created Query.
*/
endAt(snapshot: DocumentSnapshot<any>): Query<T>;
/**
* Creates and returns a new Query that ends at the provided fields
* relative to the order of the query. The order of the field values
* must match the order of the order by clauses of the query.
*
* @param fieldValues The field values to end this query at, in order
* of the query's order by.
* @return The created Query.
*/
endAt(...fieldValues: any[]): Query<T>;
/**
* Returns true if this `Query` is equal to the provided one.
*
* @param other The `Query` to compare against.
* @return true if this `Query` is equal to the provided one.
*/
isEqual(other: Query<T>): boolean;
/**
* Executes the query and returns the results as a `QuerySnapshot`.
*
* Note: By default, get() attempts to provide up-to-date data when possible
* by waiting for data from the server, but it may return cached data or fail
* if you are offline and the server cannot be reached. This behavior can be
* altered via the `GetOptions` parameter.
*
* @param options An object to configure the get behavior.
* @return A Promise that will be resolved with the results of the Query.
*/
get(options?: GetOptions): Promise<QuerySnapshot<T>>;
/**
* Attaches a listener for QuerySnapshot events. You may either pass
* individual `onNext` and `onError` callbacks or pass a single observer
* object with `next` and `error` callbacks. The listener can be cancelled by
* calling the function that is returned when `onSnapshot` is called.
*
* NOTE: Although an `onCompletion` callback can be provided, it will
* never be called because the snapshot stream is never-ending.
*
* @param observer A single object containing `next` and `error` callbacks.
* @return An unsubscribe function that can be called to cancel
* the snapshot listener.
*/
onSnapshot(observer: {
next?: (snapshot: QuerySnapshot<T>) => void;
error?: (error: FirestoreError) => void;
complete?: () => void;
}): () => void;
/**
* Attaches a listener for QuerySnapshot events. You may either pass
* individual `onNext` and `onError` callbacks or pass a single observer
* object with `next` and `error` callbacks. The listener can be cancelled by
* calling the function that is returned when `onSnapshot` is called.
*
* NOTE: Although an `onCompletion` callback can be provided, it will
* never be called because the snapshot stream is never-ending.
*
* @param options Options controlling the listen behavior.
* @param observer A single object containing `next` and `error` callbacks.
* @return An unsubscribe function that can be called to cancel
* the snapshot listener.
*/
onSnapshot(
options: SnapshotListenOptions,
observer: {
next?: (snapshot: QuerySnapshot<T>) => void;
error?: (error: FirestoreError) => void;
complete?: () => void;
}
): () => void;
/**
* Attaches a listener for QuerySnapshot events. You may either pass
* individual `onNext` and `onError` callbacks or pass a single observer
* object with `next` and `error` callbacks. The listener can be cancelled by
* calling the function that is returned when `onSnapshot` is called.
*
* NOTE: Although an `onCompletion` callback can be provided, it will
* never be called because the snapshot stream is never-ending.
*
* @param onNext A callback to be called every time a new `QuerySnapshot`
* is available.
* @param onError A callback to be called if the listen fails or is
* cancelled. No further callbacks will occur.
* @return An unsubscribe function that can be called to cancel
* the snapshot listener.
*/
onSnapshot(
onNext: (snapshot: QuerySnapshot<T>) => void,
onError?: (error: FirestoreError) => void,
onCompletion?: () => void
): () => void;
/**
* Attaches a listener for QuerySnapshot events. You may either pass
* individual `onNext` and `onError` callbacks or pass a single observer
* object with `next` and `error` callbacks. The listener can be cancelled by
* calling the function that is returned when `onSnapshot` is called.
*
* NOTE: Although an `onCompletion` callback can be provided, it will
* never be called because the snapshot stream is never-ending.
*
* @param options Options controlling the listen behavior.
* @param onNext A callback to be called every time a new `QuerySnapshot`
* is available.
* @param onError A callback to be called if the listen fails or is
* cancelled. No further callbacks will occur.
* @return An unsubscribe function that can be called to cancel
* the snapshot listener.
*/
onSnapshot(
options: SnapshotListenOptions,
onNext: (snapshot: QuerySnapshot<T>) => void,
onError?: (error: FirestoreError) => void,
onCompletion?: () => void
): () => void;
/**
* Applies a custom data converter to this Query, allowing you to use your
* own custom model objects with Firestore. When you call get() on the
* returned Query, the provided converter will convert between Firestore
* data and your custom type U.
*
* Passing in `null` as the converter parameter removes the current
* converter.
*
* @param converter Converts objects to and from Firestore. Passing in
* `null` removes the current converter.
* @return A Query<U> that uses the provided converter.
*/
withConverter(converter: null): Query<DocumentData>;
/**
* Applies a custom data converter to this Query, allowing you to use your
* own custom model objects with Firestore. When you call get() on the
* returned Query, the provided converter will convert between Firestore
* data and your custom type U.
*
* Passing in `null` as the converter parameter removes the current
* converter.
*
* @param converter Converts objects to and from Firestore. Passing in
* `null` removes the current converter.
* @return A Query<U> that uses the provided converter.
*/
withConverter<U>(converter: FirestoreDataConverter<U>): Query<U>;
}
/**
* A `QuerySnapshot` contains zero or more `DocumentSnapshot` objects
* representing the results of a query. The documents can be accessed as an
* array via the `docs` property or enumerated using the `forEach` method. The
* number of documents can be determined via the `empty` and `size`
* properties.
*/
export class QuerySnapshot<T = DocumentData> {
private constructor();
/**
* The query on which you called `get` or `onSnapshot` in order to get this
* `QuerySnapshot`.
*/
readonly query: Query<T>;
/**
* Metadata about this snapshot, concerning its source and if it has local
* modifications.
*/
readonly metadata: SnapshotMetadata;
/** An array of all the documents in the `QuerySnapshot`. */
readonly docs: Array<QueryDocumentSnapshot<T>>;
/** The number of documents in the `QuerySnapshot`. */
readonly size: number;
/** True if there are no documents in the `QuerySnapshot`. */
readonly empty: boolean;
/**
* Returns an array of the documents changes since the last snapshot. If this
* is the first snapshot, all documents will be in the list as added changes.
*
* @param options `SnapshotListenOptions` that control whether metadata-only
* changes (i.e. only `DocumentSnapshot.metadata` changed) should trigger
* snapshot events.
*/
docChanges(options?: SnapshotListenOptions): Array<DocumentChange<T>>;
/**
* Enumerates all of the documents in the `QuerySnapshot`.
*
* @param callback A callback to be called with a `QueryDocumentSnapshot` for
* each document in the snapshot.
* @param thisArg The `this` binding for the callback.
*/
forEach(
callback: (result: QueryDocumentSnapshot<T>) => void,
thisArg?: any
): void;
/**
* Returns true if this `QuerySnapshot` is equal to the provided one.
*
* @param other The `QuerySnapshot` to compare against.
* @return true if this `QuerySnapshot` is equal to the provided one.
*/
isEqual(other: QuerySnapshot<T>): boolean;
}
/**
* The type of a `DocumentChange` may be 'added', 'removed', or 'modified'.
*/
export type DocumentChangeType = 'added' | 'removed' | 'modified';
/**
* A `DocumentChange` represents a change to the documents matching a query.
* It contains the document affected and the type of change that occurred.
*/
export interface DocumentChange<T = DocumentData> {
/** The type of change ('added', 'modified', or 'removed'). */
readonly type: DocumentChangeType;
/** The document affected by this change. */
readonly doc: QueryDocumentSnapshot<T>;
/**
* The index of the changed document in the result set immediately prior to
* this `DocumentChange` (i.e. supposing that all prior `DocumentChange` objects
* have been applied). Is -1 for 'added' events.
*/
readonly oldIndex: number;
/**
* The index of the changed document in the result set immediately after
* this `DocumentChange` (i.e. supposing that all prior `DocumentChange`
* objects and the current `DocumentChange` object have been applied).
* Is -1 for 'removed' events.
*/
readonly newIndex: number;
}
/**
* A `CollectionReference` object can be used for adding documents, getting
* document references, and querying for documents (using the methods
* inherited from `Query`).
*/
export class CollectionReference<T = DocumentData> extends Query<T> {
private constructor();
/** The collection's identifier. */
readonly id: string;
/**
* A reference to the containing `DocumentReference` if this is a subcollection.
* If this isn't a subcollection, the reference is null.
*/
readonly parent: DocumentReference<DocumentData> | null;
/**
* A string representing the path of the referenced collection (relative
* to the root of the database).
*/
readonly path: string;
/**
* Get a `DocumentReference` for the document within the collection at the
* specified path. If no path is specified, an automatically-generated
* unique ID will be used for the returned DocumentReference.
*
* @param documentPath A slash-separated path to a document.
* @return The `DocumentReference` instance.
*/
doc(documentPath?: string): DocumentReference<T>;
/**
* Add a new document to this collection with the specified data, assigning
* it a document ID automatically.
*
* @param data An Object containing the data for the new document.
* @return A Promise resolved with a `DocumentReference` pointing to the
* newly created document after it has been written to the backend.
*/
add(data: T): Promise<DocumentReference<T>>;
/**
* Returns true if this `CollectionReference` is equal to the provided one.
*
* @param other The `CollectionReference` to compare against.
* @return true if this `CollectionReference` is equal to the provided one.
*/
isEqual(other: CollectionReference<T>): boolean;
/**
* Applies a custom data converter to this CollectionReference, allowing you
* to use your own custom model objects with Firestore. When you call add()
* on the returned CollectionReference instance, the provided converter will
* convert between Firestore data and your custom type U.
*
* Passing in `null` as the converter parameter removes the current
* converter.
*
* @param converter Converts objects to and from Firestore. Passing in
* `null` removes the current converter.
* @return A CollectionReference<U> that uses the provided converter.
*/
withConverter(converter: null): CollectionReference<DocumentData>;
/**
* Applies a custom data converter to this CollectionReference, allowing you
* to use your own custom model objects with Firestore. When you call add()
* on the returned CollectionReference instance, the provided converter will
* convert between Firestore data and your custom type U.
*
* Passing in `null` as the converter parameter removes the current
* converter.
*
* @param converter Converts objects to and from Firestore. Passing in
* `null` removes the current converter.
* @return A CollectionReference<U> that uses the provided converter.
*/
withConverter<U>(
converter: FirestoreDataConverter<U>
): CollectionReference<U>;
}
/**
* Sentinel values that can be used when writing document fields with `set()`
* or `update()`.
*/
export class FieldValue {
private constructor();
/**
* Returns a sentinel used with `set()` or `update()` to include a
* server-generated timestamp in the written data.
*/
static serverTimestamp(): FieldValue;
/**
* Returns a sentinel for use with `update()` to mark a field for deletion.
*/
static delete(): FieldValue;
/**
* Returns a special value that can be used with `set()` or `update()` that tells
* the server to union the given elements with any array value that already
* exists on the server. Each specified element that doesn't already exist in
* the array will be added to the end. If the field being modified is not
* already an array it will be overwritten with an array containing exactly
* the specified elements.
*
* @param elements The elements to union into the array.
* @return The FieldValue sentinel for use in a call to `set()` or `update()`.
*/
static arrayUnion(...elements: any[]): FieldValue;
/**
* Returns a special value that can be used with `set()` or `update()` that tells
* the server to remove the given elements from any array value that already
* exists on the server. All instances of each element specified will be
* removed from the array. If the field being modified is not already an
* array it will be overwritten with an empty array.
*
* @param elements The elements to remove from the array.
* @return The FieldValue sentinel for use in a call to `set()` or `update()`.
*/
static arrayRemove(...elements: any[]): FieldValue;
/**
* Returns a special value that can be used with `set()` or `update()` that tells
* the server to increment the field's current value by the given value.
*
* If either the operand or the current field value uses floating point precision,
* all arithmetic follows IEEE 754 semantics. If both values are integers,
* values outside of JavaScript's safe number range (`Number.MIN_SAFE_INTEGER` to
* `Number.MAX_SAFE_INTEGER`) are also subject to precision loss. Furthermore,
* once processed by the Firestore backend, all integer operations are capped
* between -2^63 and 2^63-1.
*
* If the current field value is not of type `number`, or if the field does not
* yet exist, the transformation sets the field to the given value.
*
* @param n The value to increment by.
* @return The FieldValue sentinel for use in a call to `set()` or `update()`.
*/
static increment(n: number): FieldValue;
/**
* Returns true if this `FieldValue` is equal to the provided one.
*
* @param other The `FieldValue` to compare against.
* @return true if this `FieldValue` is equal to the provided one.
*/
isEqual(other: FieldValue): boolean;
}
/**
* A FieldPath refers to a field in a document. The path may consist of a
* single field name (referring to a top-level field in the document), or a
* list of field names (referring to a nested field in the document).
*
* Create a FieldPath by providing field names. If more than one field
* name is provided, the path will point to a nested field in a document.
*
*/
export class FieldPath {
/**
* Creates a FieldPath from the provided field names. If more than one field
* name is provided, the path will point to a nested field in a document.
*
* @param fieldNames A list of field names.
*/
constructor(...fieldNames: string[]);
/**
* Returns a special sentinel `FieldPath` to refer to the ID of a document.
* It can be used in queries to sort or filter by the document ID.
*/
static documentId(): FieldPath;
/**
* Returns true if this `FieldPath` is equal to the provided one.
*
* @param other The `FieldPath` to compare against.
* @return true if this `FieldPath` is equal to the provided one.
*/
isEqual(other: FieldPath): boolean;
}
/**
* The set of Firestore status codes. The codes are the same at the ones
* exposed by gRPC here:
* https://github.com/grpc/grpc/blob/master/doc/statuscodes.md
*
* Possible values:
* - 'cancelled': The operation was cancelled (typically by the caller).
* - 'unknown': Unknown error or an error from a different error domain.
* - 'invalid-argument': Client specified an invalid argument. Note that this
* differs from 'failed-precondition'. 'invalid-argument' indicates
* arguments that are problematic regardless of the state of the system
* (e.g. an invalid field name).
* - 'deadline-exceeded': Deadline expired before operation could complete.
* For operations that change the state of the system, this error may be
* returned even if the operation has completed successfully. For example,
* a successful response from a server could have been delayed long enough
* for the deadline to expire.
* - 'not-found': Some requested document was not found.
* - 'already-exists': Some document that we attempted to create already
* exists.
* - 'permission-denied': The caller does not have permission to execute the
* specified operation.
* - 'resource-exhausted': Some resource has been exhausted, perhaps a
* per-user quota, or perhaps the entire file system is out of space.
* - 'failed-precondition': Operation was rejected because the system is not
* in a state required for the operation's execution.
* - 'aborted': The operation was aborted, typically due to a concurrency
* issue like transaction aborts, etc.
* - 'out-of-range': Operation was attempted past the valid range.
* - 'unimplemented': Operation is not implemented or not supported/enabled.
* - 'internal': Internal errors. Means some invariants expected by
* underlying system has been broken. If you see one of these errors,
* something is very broken.
* - 'unavailable': The service is currently unavailable. This is most likely
* a transient condition and may be corrected by retrying with a backoff.
* - 'data-loss': Unrecoverable data loss or corruption.
* - 'unauthenticated': The request does not have valid authentication
* credentials for the operation.
*/
export type FirestoreErrorCode =
| 'cancelled'
| 'unknown'
| 'invalid-argument'
| 'deadline-exceeded'
| 'not-found'
| 'already-exists'
| 'permission-denied'
| 'resource-exhausted'
| 'failed-precondition'
| 'aborted'
| 'out-of-range'
| 'unimplemented'
| 'internal'
| 'unavailable'
| 'data-loss'
| 'unauthenticated';
/** An error returned by a Firestore operation. */
// TODO(b/63008957): FirestoreError should extend firebase.FirebaseError
export interface FirestoreError {
code: FirestoreErrorCode;
message: string;
name: string;
stack?: string;
}
export type EmulatorMockTokenOptions = firebase.EmulatorMockTokenOptions;
}
export default firebase;
export as namespace firebase;
|