UNPKG

firebase

Version:

Firebase JavaScript library for web and Node.js

1,260 lines (1,240 loc) • 294 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. */ /** * <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: string; /** * 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 current SDK version. */ var SDK_VERSION: string; /** * @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> * * @webonly * * @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 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> * * @webonly * * @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> * * @webonly * * @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>; /** * 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>; } /** * 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; } /** * 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/setup#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 * 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 * }); * ``` * * @example * ```javascript * * // Initialize another app * var otherApp = firebase.initializeApp({ * databaseURL: "https://<OTHER_DATABASE_NAME>.firebaseio.com", * storageBucket: "<OTHER_STORAGE_BUCKET>.appspot.com" * }, "otherApp"); * ``` * * @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. * * @webonly * * @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. * * @webonly * * @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; /** * @webonly */ 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. * * @webonly * * @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; } 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. * * @webonly * * @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. * * @webonly * * @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 (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. * * @webonly * * @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; /** * @webonly */ functions(region?: 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. * * @webonly * * @example * ```javascript * const perf = app.performance(); * // The above is shorthand for: * // const perf = firebase.performance(app); * ``` */ performance(): firebase.performance.Performance; } } /** * @webonly */ 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 { /** * 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 */ ge