UNPKG

4.76 kBTypeScriptView Raw
1/**
2 * @license
3 * Copyright 2020 Google LLC
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17import { ActionCodeInfo, ActionCodeSettings, Auth, UserCredential } from '../../model/public_types';
18/**
19 * Sends a password reset email to the given email address.
20 *
21 * @remarks
22 * To complete the password reset, call {@link confirmPasswordReset} with the code supplied in
23 * the email sent to the user, along with the new password specified by the user.
24 *
25 * @example
26 * ```javascript
27 * const actionCodeSettings = {
28 * url: 'https://www.example.com/?email=user@example.com',
29 * iOS: {
30 * bundleId: 'com.example.ios'
31 * },
32 * android: {
33 * packageName: 'com.example.android',
34 * installApp: true,
35 * minimumVersion: '12'
36 * },
37 * handleCodeInApp: true
38 * };
39 * await sendPasswordResetEmail(auth, 'user@example.com', actionCodeSettings);
40 * // Obtain code from user.
41 * await confirmPasswordReset('user@example.com', code);
42 * ```
43 *
44 * @param auth - The {@link Auth} instance.
45 * @param email - The user's email address.
46 * @param actionCodeSettings - The {@link ActionCodeSettings}.
47 *
48 * @public
49 */
50export declare function sendPasswordResetEmail(auth: Auth, email: string, actionCodeSettings?: ActionCodeSettings): Promise<void>;
51/**
52 * Completes the password reset process, given a confirmation code and new password.
53 *
54 * @param auth - The {@link Auth} instance.
55 * @param oobCode - A confirmation code sent to the user.
56 * @param newPassword - The new password.
57 *
58 * @public
59 */
60export declare function confirmPasswordReset(auth: Auth, oobCode: string, newPassword: string): Promise<void>;
61/**
62 * Applies a verification code sent to the user by email or other out-of-band mechanism.
63 *
64 * @param auth - The {@link Auth} instance.
65 * @param oobCode - A verification code sent to the user.
66 *
67 * @public
68 */
69export declare function applyActionCode(auth: Auth, oobCode: string): Promise<void>;
70/**
71 * Checks a verification code sent to the user by email or other out-of-band mechanism.
72 *
73 * @returns metadata about the code.
74 *
75 * @param auth - The {@link Auth} instance.
76 * @param oobCode - A verification code sent to the user.
77 *
78 * @public
79 */
80export declare function checkActionCode(auth: Auth, oobCode: string): Promise<ActionCodeInfo>;
81/**
82 * Checks a password reset code sent to the user by email or other out-of-band mechanism.
83 *
84 * @returns the user's email address if valid.
85 *
86 * @param auth - The {@link Auth} instance.
87 * @param code - A verification code sent to the user.
88 *
89 * @public
90 */
91export declare function verifyPasswordResetCode(auth: Auth, code: string): Promise<string>;
92/**
93 * Creates a new user account associated with the specified email address and password.
94 *
95 * @remarks
96 * On successful creation of the user account, this user will also be signed in to your application.
97 *
98 * User account creation can fail if the account already exists or the password is invalid.
99 *
100 * Note: The email address acts as a unique identifier for the user and enables an email-based
101 * password reset. This function will create a new user account and set the initial user password.
102 *
103 * @param auth - The {@link Auth} instance.
104 * @param email - The user's email address.
105 * @param password - The user's chosen password.
106 *
107 * @public
108 */
109export declare function createUserWithEmailAndPassword(auth: Auth, email: string, password: string): Promise<UserCredential>;
110/**
111 * Asynchronously signs in using an email and password.
112 *
113 * @remarks
114 * Fails with an error if the email address and password do not match.
115 *
116 * Note: The user's password is NOT the password used to access the user's email account. The
117 * email address serves as a unique identifier for the user, and the password is used to access
118 * the user's account in your Firebase project. See also: {@link createUserWithEmailAndPassword}.
119 *
120 * @param auth - The {@link Auth} instance.
121 * @param email - The users email address.
122 * @param password - The users password.
123 *
124 * @public
125 */
126export declare function signInWithEmailAndPassword(auth: Auth, email: string, password: string): Promise<UserCredential>;