UNPKG

3.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 { ActionCodeSettings, Auth, UserCredential } from '../../model/public_types';
18/**
19 * Sends a sign-in email link to the user with the specified email.
20 *
21 * @remarks
22 * The sign-in operation has to always be completed in the app unlike other out of band email
23 * actions (password reset and email verifications). This is because, at the end of the flow,
24 * the user is expected to be signed in and their Auth state persisted within the app.
25 *
26 * To complete sign in with the email link, call {@link signInWithEmailLink} with the email
27 * address and the email link supplied in the email sent to the user.
28 *
29 * @example
30 * ```javascript
31 * const actionCodeSettings = {
32 * url: 'https://www.example.com/?email=user@example.com',
33 * iOS: {
34 * bundleId: 'com.example.ios'
35 * },
36 * android: {
37 * packageName: 'com.example.android',
38 * installApp: true,
39 * minimumVersion: '12'
40 * },
41 * handleCodeInApp: true
42 * };
43 * await sendSignInLinkToEmail(auth, 'user@example.com', actionCodeSettings);
44 * // Obtain emailLink from the user.
45 * if(isSignInWithEmailLink(auth, emailLink)) {
46 * await signInWithEmailLink(auth, 'user@example.com', emailLink);
47 * }
48 * ```
49 *
50 * @param authInternal - The {@link Auth} instance.
51 * @param email - The user's email address.
52 * @param actionCodeSettings - The {@link ActionCodeSettings}.
53 *
54 * @public
55 */
56export declare function sendSignInLinkToEmail(auth: Auth, email: string, actionCodeSettings: ActionCodeSettings): Promise<void>;
57/**
58 * Checks if an incoming link is a sign-in with email link suitable for {@link signInWithEmailLink}.
59 *
60 * @param auth - The {@link Auth} instance.
61 * @param emailLink - The link sent to the user's email address.
62 *
63 * @public
64 */
65export declare function isSignInWithEmailLink(auth: Auth, emailLink: string): boolean;
66/**
67 * Asynchronously signs in using an email and sign-in email link.
68 *
69 * @remarks
70 * If no link is passed, the link is inferred from the current URL.
71 *
72 * Fails with an error if the email address is invalid or OTP in email link expires.
73 *
74 * Note: Confirm the link is a sign-in email link before calling this method firebase.auth.Auth.isSignInWithEmailLink.
75 *
76 * @example
77 * ```javascript
78 * const actionCodeSettings = {
79 * url: 'https://www.example.com/?email=user@example.com',
80 * iOS: {
81 * bundleId: 'com.example.ios'
82 * },
83 * android: {
84 * packageName: 'com.example.android',
85 * installApp: true,
86 * minimumVersion: '12'
87 * },
88 * handleCodeInApp: true
89 * };
90 * await sendSignInLinkToEmail(auth, 'user@example.com', actionCodeSettings);
91 * // Obtain emailLink from the user.
92 * if(isSignInWithEmailLink(auth, emailLink)) {
93 * await signInWithEmailLink(auth, 'user@example.com', emailLink);
94 * }
95 * ```
96 *
97 * @param auth - The {@link Auth} instance.
98 * @param email - The user's email address.
99 * @param emailLink - The link sent to the user's email address.
100 *
101 * @public
102 */
103export declare function signInWithEmailLink(auth: Auth, email: string, emailLink?: string): Promise<UserCredential>;