UNPKG

voluptasmollitia

Version:
1,402 lines (1,320 loc) 123 kB
/** * @license Copyright 2017 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @fileoverview Firebase Auth API. * @externs */ /** * 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 * // Get the Auth service for the default app * var defaultAuth = firebase.auth(); * * @example * // Get the Auth service for a given app * var otherAuth = firebase.auth(otherApp); * * @namespace * @param {!firebase.app.App=} app * * @return {!firebase.auth.Auth} */ firebase.auth = function (app) {}; /** * Interface that represents the credentials returned by an auth provider. * Implementations specify the details about each auth provider's credential * requirements. * * @interface */ firebase.auth.AuthCredential = function () {}; /** * The authentication provider ID for the credential. * For example, 'facebook.com', or 'google.com'. * * @type {string} */ firebase.auth.AuthCredential.prototype.providerId; /** * 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}. * * @type {string} */ firebase.auth.AuthCredential.prototype.signInMethod; /** * 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 {string|!Object} json The plain object representation of an * AuthCredential. * @return {?firebase.auth.AuthCredential} The auth credential. */ firebase.auth.AuthCredential.fromJSON = function (json) {}; /** * Returns a JSON-serializable representation of this object. * @return {!Object} The plain object representation of the `AuthCredential`. */ firebase.auth.AuthCredential.prototype.toJSON = function () {}; /** * 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 */ firebase.auth.OAuthCredentialOptions = function () {}; /** * The OAuth ID token used to initialize the OAuthCredential. * * @type {string|undefined} */ firebase.auth.OAuthCredentialOptions.prototype.idToken; /** * The OAuth access token used to initialize the OAuthCredential. * * @type {string|undefined} */ firebase.auth.OAuthCredentialOptions.prototype.accessToken; /** * 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. * * @type {string|undefined} */ firebase.auth.OAuthCredentialOptions.prototype.rawNonce; /** * Interface that represents the OAuth credentials returned by an OAuth * provider. Implementations specify the details about each auth provider's * credential requirements. * * @interface * @extends {firebase.auth.AuthCredential} */ firebase.auth.OAuthCredential = function () {}; /** * The OAuth ID token associated with the credential if it belongs to an * OIDC provider, such as `google.com`. * * @type {?string|undefined} */ firebase.auth.OAuthCredential.prototype.idToken; /** * The OAuth access token associated with the credential if it belongs to an * OAuth provider, such as `facebook.com`, `twitter.com`, etc. * * @type {?string|undefined} */ firebase.auth.OAuthCredential.prototype.accessToken; /** * The OAuth access token secret associated with the credential if it belongs * to an OAuth 1.0 provider, such as `twitter.com`. * * @type {?string|undefined} */ firebase.auth.OAuthCredential.prototype.secret; /** * Interface that represents the phone credentials returned by a phone provider. * * @interface * @extends {firebase.auth.AuthCredential} */ firebase.auth.PhoneAuthCredential = function () {}; /** * Gets the {@link firebase.auth.Auth `Auth`} service for the current app. * * @example * var auth = app.auth(); * // The above is shorthand for: * // var auth = firebase.auth(app); * * @return {!firebase.auth.Auth} */ firebase.app.App.prototype.auth = function () {}; /** * Interface representing a user's metadata. * * @interface */ firebase.auth.UserMetadata = function () {}; /** * The date the user last signed in, formatted as a UTC string. * For example, 'Fri, 22 Sep 2017 01:49:58 GMT'. * * @type {?string} */ firebase.auth.UserMetadata.prototype.lastSignInTime; /** * The date the user was created, formatted as a UTC string. * For example, 'Fri, 22 Sep 2017 01:49:58 GMT'. * * @type {?string} */ firebase.auth.UserMetadata.prototype.creationTime; /** * User profile information, visible only to the Firebase project's * apps. * * @interface */ firebase.UserInfo = function () {}; /** * The user's unique ID. * * @type {string} */ firebase.UserInfo.prototype.uid; /** * The authentication provider ID for the current user. * For example, 'facebook.com', or 'google.com'. * * @type {string} */ firebase.UserInfo.prototype.providerId; /** * The user's email address (if available). * @type {?string} */ firebase.UserInfo.prototype.email; /** * The user's display name (if available). * * @type {?string} */ firebase.UserInfo.prototype.displayName; /** * The URL of the user's profile picture (if available). * * @type {?string} */ firebase.UserInfo.prototype.photoURL; /** * The user's E.164 formatted phone number (if available). * * @type {?string} */ firebase.UserInfo.prototype.phoneNumber; /** * A user account. * * @interface * @extends {firebase.UserInfo} */ firebase.User = function () {}; /** * 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. * @type {?string} */ firebase.User.prototype.phoneNumber; /** @type {boolean} */ firebase.User.prototype.isAnonymous; /** * True if the user's email address has been verified. * @type {boolean} */ firebase.User.prototype.emailVerified; /** * Additional metadata about the user. * @type {!firebase.auth.UserMetadata} */ firebase.User.prototype.metadata; /** * Additional provider-specific information about the user. * @type {!Array<firebase.UserInfo>} */ firebase.User.prototype.providerData; /** * A refresh token for the user account. Use only for advanced scenarios that * require explicitly refreshing tokens. * @type {string} */ firebase.User.prototype.refreshToken; /** * The {@link firebase.User.MultiFactor} object corresponding to the current * user. This is used to access all multi-factor properties and operations * related to the current user. * @type {!firebase.User.MultiFactorUser} */ firebase.User.prototype.multiFactor; /** * 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. * }); * ``` * @type {?string} */ firebase.User.prototype.tenantId; /** * Returns a JWT token 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 {boolean=} forceRefresh Force refresh regardless of token * expiration. * @return {!firebase.Promise<string>} */ firebase.User.prototype.getIdToken = function (forceRefresh) {}; /** * Refreshes the current user, if signed in. * * @return {!firebase.Promise<void>} */ firebase.User.prototype.reload = function () {}; /** * 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 * 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 {?firebase.auth.ActionCodeSettings=} 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. * @return {!firebase.Promise<void>} */ firebase.User.prototype.sendEmailVerification = function ( actionCodeSettings ) {}; /** * 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 {!firebase.auth.AuthCredential} credential The auth credential. * @return {!firebase.Promise<!firebase.auth.UserCredential>} */ firebase.User.prototype.linkWithCredential = function (credential) {}; /** * Links the user account with the given credentials, and returns any available * additional user information, such as user name. * * This method is deprecated. Use * {@link firebase.User#linkWithCredential} instead. * * <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 {!firebase.auth.AuthCredential} credential The auth credential. * @return {!firebase.Promise<!firebase.auth.UserCredential>} */ firebase.User.prototype.linkAndRetrieveDataWithCredential = function ( credential ) {}; /** * 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 {string} phoneNumber The user's phone number in E.164 format (e.g. * +16505550101). * @param {!firebase.auth.ApplicationVerifier} applicationVerifier * @return {!firebase.Promise<!firebase.auth.ConfirmationResult>} */ firebase.User.prototype.linkWithPhoneNumber = function ( phoneNumber, applicationVerifier ) {}; /** * 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 {string} providerId * @return {!firebase.Promise<!firebase.User>} */ firebase.User.prototype.unlink = function (providerId) {}; /** * 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 {!firebase.auth.AuthCredential} credential * @return {!firebase.Promise<firebase.auth.UserCredential>} */ firebase.User.prototype.reauthenticateWithCredential = function (credential) {}; /** * 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. * * This method is deprecated. Use * {@link firebase.User#reauthenticateWithCredential} instead. * * <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 {!firebase.auth.AuthCredential} credential * @return {!firebase.Promise<!firebase.auth.UserCredential>} */ firebase.User.prototype.reauthenticateAndRetrieveDataWithCredential = function ( credential ) {}; /** * 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 {string} phoneNumber The user's phone number in E.164 format (e.g. * +16505550101). * @param {!firebase.auth.ApplicationVerifier} applicationVerifier * @return {!firebase.Promise<!firebase.auth.ConfirmationResult>} */ firebase.User.prototype.reauthenticateWithPhoneNumber = function ( phoneNumber, applicationVerifier ) {}; /** * 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 {string} newEmail The new email address. * @return {!firebase.Promise<void>} */ firebase.User.prototype.updateEmail = function (newEmail) {}; /** * 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 {string} newPassword * @return {!firebase.Promise<void>} */ firebase.User.prototype.updatePassword = function (newPassword) {}; /** * 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 {!firebase.auth.AuthCredential} phoneCredential * @return {!firebase.Promise<void>} */ firebase.User.prototype.updatePhoneNumber = function (phoneCredential) {}; /** * Updates a user's profile data. * * @example * // 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 {!{displayName: ?string, photoURL: ?string}} profile The profile's * displayName and photoURL to update. * @return {!firebase.Promise<void>} */ firebase.User.prototype.updateProfile = function (profile) {}; /** * 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 {string} newEmail The email address to be verified and updated to. * @param {?firebase.auth.ActionCodeSettings=} 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. * @return {!firebase.Promise<void>} */ firebase.User.prototype.verifyBeforeUpdateEmail = function ( newEmail, actionCodeSettings ) {}; /** * 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> * * @return {!firebase.Promise<void>} */ firebase.User.prototype.delete = function () {}; /** * Returns a JSON-serializable representation of this object. * * @return {!Object} A JSON-serializable representation of this object. */ firebase.User.prototype.toJSON = function () {}; /** * 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 */ firebase.auth.Auth = function () {}; /** * 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 {string} code A verification code sent to the user. * @return {!firebase.Promise<string>} */ firebase.auth.Auth.prototype.verifyPasswordResetCode = function (code) {}; /** * A response from {@link firebase.auth.Auth#checkActionCode}. * * @interface */ firebase.auth.ActionCodeInfo = function () {}; /** * 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.Auth.PhoneMultiFactorInfo} * object, which contains the phone number. * * @typedef {{ * email: (?string|undefined), * fromEmail: (?string|undefined), * multiFactorInfo: (?firebase.auth.MultiFactorInfo|undefined), previousEmail: (?string|undefined) * }} */ firebase.auth.ActionCodeInfo.prototype.data; /** * 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> * * @type {string} */ firebase.auth.ActionCodeInfo.prototype.operation; /** * @enum {string} * An enumeration of the possible email action types. */ firebase.auth.ActionCodeInfo.Operation = { /** * The email link sign in email action. */ EMAIL_SIGNIN: 'EMAIL_SIGNIN', /** * The reset password email action. */ PASSWORD_RESET: 'PASSWORD_RESET', /** * The email revocation action. */ RECOVER_EMAIL: 'RECOVER_EMAIL', /** * The revert second factor addition email action. */ REVERT_SECOND_FACTOR_ADDITION: 'REVERT_SECOND_FACTOR_ADDITION', /** * The verify and update email action. */ VERIFY_AND_CHANGE_EMAIL: 'VERIFY_AND_CHANGE_EMAIL', /** * The email verification action. */ VERIFY_EMAIL: 'VERIFY_EMAIL' }; /** * A utility class to parse email action URLs. * * @constructor */ firebase.auth.ActionCodeURL = function () {}; /** * The API key of the email action link. * * @type {string} */ firebase.auth.ActionCodeURL.prototype.apiKey; /** * The action code of the email action link. * * @type {string} */ firebase.auth.ActionCodeURL.prototype.code; /** * The continue URL of the email action link. Null if not provided. * * @type {?string} */ firebase.auth.ActionCodeURL.prototype.continueUrl; /** * The language code of the email action link. Null if not provided. * * @type {?string} */ firebase.auth.ActionCodeURL.prototype.languageCode; /** * The action performed by the email action link. It returns from one * of the types from {@link firebase.auth.ActionCodeInfo}. * * @type {!firebase.auth.ActionCodeInfo.Operation} */ firebase.auth.ActionCodeURL.prototype.operation; /** * The tenant ID of the email action link. Null if the email action * is from the parent project. * * @type {?string} */ firebase.auth.ActionCodeURL.prototype.tenantId; /** * Parses the email action link string and returns an ActionCodeURL object * if the link is valid, otherwise returns null. * * @param {string} link The email action link string. * @return {?firebase.auth.ActionCodeURL} The ActionCodeURL object, or null if * the link is invalid. */ firebase.auth.ActionCodeURL.parseLink = function (link) {}; /** * 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> * * @typedef {{ * url: string, * iOS: ({bundleId: string}|undefined), * android: ({packageName: string, installApp: (boolean|undefined), * minimumVersion: (string|undefined)}|undefined), * handleCodeInApp: (boolean|undefined) * }} */ firebase.auth.ActionCodeSettings; /** * 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 {string} code A verification code sent to the user. * @return {!firebase.Promise<!firebase.auth.ActionCodeInfo>} */ firebase.auth.Auth.prototype.checkActionCode = function (code) {}; /** * 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 {string} code A verification code sent to the user. * @return {!firebase.Promise<void>} */ firebase.auth.Auth.prototype.applyActionCode = function (code) {}; /** * The {@link firebase.app.App app} associated with the `Auth` service * instance. * * @example * var app = auth.app; * * @type {!firebase.app.App} */ firebase.auth.Auth.prototype.app; /** * The currently signed-in user (or null). * * @type {firebase.User|null} */ firebase.auth.Auth.prototype.currentUser; /** * The full emulator configuration as set on `auth().emulatorConfig`. * <ul> * <li>protocol: the protocol used by the emulator (http or https).</li> * <li>host: the host used to reach the emulator.</li> * <li>port: the port used to reach the emulator.</li> * <li>options: a list of options used to configure the SDK's interaction with * the emulator.</li> * </ul> * * @typedef {{ * protocol: string, * host: string, * port: (number|null), * options: { * disableWarnings: boolean, * } * }} */ firebase.auth.EmulatorConfig; /** * The current emulator configuration, or null if not set. * * @type {firebase.auth.EmulatorConfig|null} */ firebase.auth.Auth.prototype.emulatorConfig; /** * Configures the SDK to communicate with the Firebase Auth emulator. * * This must be called before any other Auth SDK actions are taken. * * Options can include `disableWarnings`. When set to true, the SDK will not * display a warning banner at the bottom of the page. * * @param {string} url The full emulator url including scheme and port. * @param {!Object=} options Options for configuring the SDK's emulator config. */ firebase.auth.Auth.prototype.useEmulator = function (url, options) {}; /** * 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. * }); * ``` * * @type {?string} */ firebase.auth.Auth.prototype.tenantId; /** * @enum {string} * An enumeration of the possible persistence mechanism types. */ firebase.auth.Auth.Persistence = { /** * Indicates that the state will be persisted even when the browser window is * closed or the activity is destroyed in react-native. */ LOCAL: 'local', /** * Indicates that the state will only be stored in memory and will be cleared * when the window or activity is refreshed. */ NONE: 'none', /** * 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: 'session' }; /** * 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 * 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. * }); * * @param {!firebase.auth.Auth.Persistence} persistence The auth state * persistence mechanism. * @return {!firebase.Promise<void>} */ firebase.auth.Auth.prototype.setPersistence = function (persistence) {}; /** * 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. * * @type {?string} */ firebase.auth.Auth.prototype.languageCode; /** * Sets the current language to the default device/browser preference. */ firebase.auth.Auth.prototype.useDeviceLanguage = function () {}; /** * The current Auth instance's settings. This is used to edit/read configuration * related options like app verification mode for phone authentication. * * @type {!firebase.auth.AuthSettings} */ firebase.auth.Auth.prototype.settings; /** * 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 p