UNPKG

@firebase/auth

Version:

The Firebase Authenticaton component of the Firebase JS SDK.

104 lines (103 loc) 3.76 kB
/** * @license * Copyright 2020 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. */ import { ActionCodeSettings, Auth, UserCredential } from '../../model/public_types'; /** * Sends a sign-in email link to the user with the specified email. * * @remarks * 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 signInWithEmailLink} with the email * address and the email link supplied in the email sent to the user. * * @example * ```javascript * const 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 * }; * await sendSignInLinkToEmail(auth, 'user@example.com', actionCodeSettings); * // Obtain emailLink from the user. * if(isSignInWithEmailLink(auth, emailLink)) { * await signInWithEmailLink(auth, 'user@example.com', emailLink); * } * ``` * * @param authInternal - The {@link Auth} instance. * @param email - The user's email address. * @param actionCodeSettings - The {@link ActionCodeSettings}. * * @public */ export declare function sendSignInLinkToEmail(auth: Auth, email: string, actionCodeSettings: ActionCodeSettings): Promise<void>; /** * Checks if an incoming link is a sign-in with email link suitable for {@link signInWithEmailLink}. * * @param auth - The {@link Auth} instance. * @param emailLink - The link sent to the user's email address. * * @public */ export declare function isSignInWithEmailLink(auth: Auth, emailLink: string): boolean; /** * Asynchronously signs in using an email and sign-in email link. * * @remarks * 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 firebase.auth.Auth.isSignInWithEmailLink. * * @example * ```javascript * const 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 * }; * await sendSignInLinkToEmail(auth, 'user@example.com', actionCodeSettings); * // Obtain emailLink from the user. * if(isSignInWithEmailLink(auth, emailLink)) { * await signInWithEmailLink(auth, 'user@example.com', emailLink); * } * ``` * * @param auth - The {@link Auth} instance. * @param email - The user's email address. * @param emailLink - The link sent to the user's email address. * * @public */ export declare function signInWithEmailLink(auth: Auth, email: string, emailLink?: string): Promise<UserCredential>;