UNPKG

140 kBTypeScriptView Raw
1/**
2 * Firebase Authentication
3 *
4 * @packageDocumentation
5 */
6
7import { CompleteFn } from '@firebase/util';
8import { ErrorFactory } from '@firebase/util';
9import { ErrorFn } from '@firebase/util';
10import { FirebaseApp } from '@firebase/app';
11import { FirebaseError } from '@firebase/util';
12import { NextFn } from '@firebase/util';
13import { Observer } from '@firebase/util';
14import { Unsubscribe } from '@firebase/util';
15
16/**
17 * A response from {@link checkActionCode}.
18 *
19 * @public
20 */
21export declare interface ActionCodeInfo {
22 /**
23 * The data associated with the action code.
24 *
25 * @remarks
26 * For the {@link ActionCodeOperation}.PASSWORD_RESET, {@link ActionCodeOperation}.VERIFY_EMAIL, and
27 * {@link ActionCodeOperation}.RECOVER_EMAIL actions, this object contains an email field with the address
28 * the email was sent to.
29 *
30 * For the {@link ActionCodeOperation}.RECOVER_EMAIL action, which allows a user to undo an email address
31 * change, this object also contains a `previousEmail` field with the user account's current
32 * email address. After the action completes, the user's email address will revert to the value
33 * in the `email` field from the value in `previousEmail` field.
34 *
35 * For the {@link ActionCodeOperation}.VERIFY_AND_CHANGE_EMAIL action, which allows a user to verify the
36 * email before updating it, this object contains a `previousEmail` field with the user account's
37 * email address before updating. After the action completes, the user's email address will be
38 * updated to the value in the `email` field from the value in `previousEmail` field.
39 *
40 * For the {@link ActionCodeOperation}.REVERT_SECOND_FACTOR_ADDITION action, which allows a user to
41 * unenroll a newly added second factor, this object contains a `multiFactorInfo` field with
42 * the information about the second factor. For phone second factor, the `multiFactorInfo`
43 * is a {@link MultiFactorInfo} object, which contains the phone number.
44 */
45 data: {
46 email?: string | null;
47 multiFactorInfo?: MultiFactorInfo | null;
48 previousEmail?: string | null;
49 };
50 /**
51 * The type of operation that generated the action code.
52 */
53 operation: typeof ActionCodeOperation[keyof typeof ActionCodeOperation];
54}
55
56/**
57 * An enumeration of the possible email action types.
58 *
59 * @public
60 */
61export declare const ActionCodeOperation: {
62 /** The email link sign-in action. */
63 readonly EMAIL_SIGNIN: "EMAIL_SIGNIN";
64 /** The password reset action. */
65 readonly PASSWORD_RESET: "PASSWORD_RESET";
66 /** The email revocation action. */
67 readonly RECOVER_EMAIL: "RECOVER_EMAIL";
68 /** The revert second factor addition email action. */
69 readonly REVERT_SECOND_FACTOR_ADDITION: "REVERT_SECOND_FACTOR_ADDITION";
70 /** The revert second factor addition email action. */
71 readonly VERIFY_AND_CHANGE_EMAIL: "VERIFY_AND_CHANGE_EMAIL";
72 /** The email verification action. */
73 readonly VERIFY_EMAIL: "VERIFY_EMAIL";
74};
75
76/**
77 * An interface that defines the required continue/state URL with optional Android and iOS
78 * bundle identifiers.
79 *
80 * @public
81 */
82export declare interface ActionCodeSettings {
83 /**
84 * Sets the Android package name.
85 *
86 * @remarks
87 * This will try to open the link in an android app if it is
88 * installed. If `installApp` is passed, it specifies whether to install the Android app if the
89 * device supports it and the app is not already installed. If this field is provided without
90 * a `packageName`, an error is thrown explaining that the `packageName` must be provided in
91 * conjunction with this field. If `minimumVersion` is specified, and an older version of the
92 * app is installed, the user is taken to the Play Store to upgrade the app.
93 */
94 android?: {
95 installApp?: boolean;
96 minimumVersion?: string;
97 packageName: string;
98 };
99 /**
100 * When set to true, the action code link will be be sent as a Universal Link or Android App
101 * Link and will be opened by the app if installed.
102 *
103 * @remarks
104 * In the false case, the code will be sent to the web widget first and then on continue will
105 * redirect to the app if installed.
106 *
107 * @defaultValue false
108 */
109 handleCodeInApp?: boolean;
110 /**
111 * Sets the iOS bundle ID.
112 *
113 * @remarks
114 * This will try to open the link in an iOS app if it is installed.
115 *
116 * App installation is not supported for iOS.
117 */
118 iOS?: {
119 bundleId: string;
120 };
121 /**
122 * Sets the link continue/state URL.
123 *
124 * @remarks
125 * This has different meanings in different contexts:
126 * - When the link is handled in the web action widgets, this is the deep link in the
127 * `continueUrl` query parameter.
128 * - When the link is handled in the app directly, this is the `continueUrl` query parameter in
129 * the deep link of the Dynamic Link.
130 */
131 url: string;
132 /**
133 * When multiple custom dynamic link domains are defined for a project, specify which one to use
134 * when the link is to be opened via a specified mobile app (for example, `example.page.link`).
135 *
136 *
137 * @defaultValue The first domain is automatically selected.
138 */
139 dynamicLinkDomain?: string;
140}
141
142/**
143 * @license
144 * Copyright 2020 Google LLC
145 *
146 * Licensed under the Apache License, Version 2.0 (the "License");
147 * you may not use this file except in compliance with the License.
148 * You may obtain a copy of the License at
149 *
150 * http://www.apache.org/licenses/LICENSE-2.0
151 *
152 * Unless required by applicable law or agreed to in writing, software
153 * distributed under the License is distributed on an "AS IS" BASIS,
154 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
155 * See the License for the specific language governing permissions and
156 * limitations under the License.
157 */
158/**
159 * A utility class to parse email action URLs such as password reset, email verification,
160 * email link sign in, etc.
161 *
162 * @public
163 */
164export declare class ActionCodeURL {
165 /**
166 * The API key of the email action link.
167 */
168 readonly apiKey: string;
169 /**
170 * The action code of the email action link.
171 */
172 readonly code: string;
173 /**
174 * The continue URL of the email action link. Null if not provided.
175 */
176 readonly continueUrl: string | null;
177 /**
178 * The language code of the email action link. Null if not provided.
179 */
180 readonly languageCode: string | null;
181 /**
182 * The action performed by the email action link. It returns from one of the types from
183 * {@link ActionCodeInfo}
184 */
185 readonly operation: string;
186 /**
187 * The tenant ID of the email action link. Null if the email action is from the parent project.
188 */
189 readonly tenantId: string | null;
190 /**
191 * @param actionLink - The link from which to extract the URL.
192 * @returns The {@link ActionCodeURL} object, or null if the link is invalid.
193 *
194 * @internal
195 */
196 constructor(actionLink: string);
197 /**
198 * Parses the email action link string and returns an {@link ActionCodeURL} if the link is valid,
199 * otherwise returns null.
200 *
201 * @param link - The email action link string.
202 * @returns The {@link ActionCodeURL} object, or null if the link is invalid.
203 *
204 * @public
205 */
206 static parseLink(link: string): ActionCodeURL | null;
207}
208
209/**
210 * A structure containing additional user information from a federated identity provider.
211 *
212 * @public
213 */
214export declare interface AdditionalUserInfo {
215 /**
216 * Whether the user is new (created via sign-up) or existing (authenticated using sign-in).
217 */
218 readonly isNewUser: boolean;
219 /**
220 * Map containing IDP-specific user data.
221 */
222 readonly profile: Record<string, unknown> | null;
223 /**
224 * Identifier for the provider used to authenticate this user.
225 */
226 readonly providerId: string | null;
227 /**
228 * The username if the provider is GitHub or Twitter.
229 */
230 readonly username?: string | null;
231}
232
233declare interface APIUserInfo {
234 localId?: string;
235 displayName?: string;
236 photoUrl?: string;
237 email?: string;
238 emailVerified?: boolean;
239 phoneNumber?: string;
240 lastLoginAt?: number;
241 createdAt?: number;
242 tenantId?: string;
243 passwordHash?: string;
244 providerUserInfo?: ProviderUserInfo[];
245 mfaInfo?: MfaEnrollment[];
246}
247
248/**
249 * A verifier for domain verification and abuse prevention.
250 *
251 * @remarks
252 * Currently, the only implementation is {@link RecaptchaVerifier}.
253 *
254 * @public
255 */
256export declare interface ApplicationVerifier {
257 /**
258 * Identifies the type of application verifier (e.g. "recaptcha").
259 */
260 readonly type: string;
261 /**
262 * Executes the verification process.
263 *
264 * @returns A Promise for a token that can be used to assert the validity of a request.
265 */
266 verify(): Promise<string>;
267}
268
269declare interface ApplicationVerifierInternal extends ApplicationVerifier {
270 /**
271 * @internal
272 */
273 _reset(): void;
274}
275
276/**
277 * Applies a verification code sent to the user by email or other out-of-band mechanism.
278 *
279 * @param auth - The {@link Auth} instance.
280 * @param oobCode - A verification code sent to the user.
281 *
282 * @public
283 */
284export declare function applyActionCode(auth: Auth, oobCode: string): Promise<void>;
285
286declare type AppName = string;
287
288/**
289 * Interface representing Firebase Auth service.
290 *
291 * @remarks
292 * See {@link https://firebase.google.com/docs/auth/ | Firebase Authentication} for a full guide
293 * on how to use the Firebase Auth service.
294 *
295 * @public
296 */
297export declare interface Auth {
298 /** The {@link @firebase/app#FirebaseApp} associated with the `Auth` service instance. */
299 readonly app: FirebaseApp;
300 /** The name of the app associated with the `Auth` service instance. */
301 readonly name: string;
302 /** The {@link Config} used to initialize this instance. */
303 readonly config: Config;
304 /**
305 * Changes the type of persistence on the `Auth` instance.
306 *
307 * @remarks
308 * This will affect the currently saved Auth session and applies this type of persistence for
309 * future sign-in requests, including sign-in with redirect requests.
310 *
311 * This makes it easy for a user signing in to specify whether their session should be
312 * remembered or not. It also makes it easier to never persist the Auth state for applications
313 * that are shared by other users or have sensitive data.
314 *
315 * @example
316 * ```javascript
317 * auth.setPersistence(browserSessionPersistence);
318 * ```
319 *
320 * @param persistence - The {@link Persistence} to use.
321 */
322 setPersistence(persistence: Persistence): Promise<void>;
323 /**
324 * The {@link Auth} instance's language code.
325 *
326 * @remarks
327 * This is a readable/writable property. When set to null, the default Firebase Console language
328 * setting is applied. The language code will propagate to email action templates (password
329 * reset, email verification and email change revocation), SMS templates for phone authentication,
330 * reCAPTCHA verifier and OAuth popup/redirect operations provided the specified providers support
331 * localization with the language code specified.
332 */
333 languageCode: string | null;
334 /**
335 * The {@link Auth} instance's tenant ID.
336 *
337 * @remarks
338 * This is a readable/writable property. When you set the tenant ID of an {@link Auth} instance, all
339 * future sign-in/sign-up operations will pass this tenant ID and sign in or sign up users to
340 * the specified tenant project. When set to null, users are signed in to the parent project.
341 *
342 * @example
343 * ```javascript
344 * // Set the tenant ID on Auth instance.
345 * auth.tenantId = 'TENANT_PROJECT_ID';
346 *
347 * // All future sign-in request now include tenant ID.
348 * const result = await signInWithEmailAndPassword(auth, email, password);
349 * // result.user.tenantId should be 'TENANT_PROJECT_ID'.
350 * ```
351 *
352 * @defaultValue null
353 */
354 tenantId: string | null;
355 /**
356 * The {@link Auth} instance's settings.
357 *
358 * @remarks
359 * This is used to edit/read configuration related options such as app verification mode for
360 * phone authentication.
361 */
362 readonly settings: AuthSettings;
363 /**
364 * Adds an observer for changes to the user's sign-in state.
365 *
366 * @remarks
367 * To keep the old behavior, see {@link Auth.onIdTokenChanged}.
368 *
369 * @param nextOrObserver - callback triggered on change.
370 * @param error - Deprecated. This callback is never triggered. Errors
371 * on signing in/out can be caught in promises returned from
372 * sign-in/sign-out functions.
373 * @param completed - Deprecated. This callback is never triggered.
374 */
375 onAuthStateChanged(nextOrObserver: NextOrObserver<User | null>, error?: ErrorFn, completed?: CompleteFn): Unsubscribe;
376 /**
377 * Adds a blocking callback that runs before an auth state change
378 * sets a new user.
379 *
380 * @param callback - callback triggered before new user value is set.
381 * If this throws, it blocks the user from being set.
382 * @param onAbort - callback triggered if a later `beforeAuthStateChanged()`
383 * callback throws, allowing you to undo any side effects.
384 */
385 beforeAuthStateChanged(callback: (user: User | null) => void | Promise<void>, onAbort?: () => void): Unsubscribe;
386 /**
387 * Adds an observer for changes to the signed-in user's ID token.
388 *
389 * @remarks
390 * This includes sign-in, sign-out, and token refresh events.
391 *
392 * @param nextOrObserver - callback triggered on change.
393 * @param error - Deprecated. This callback is never triggered. Errors
394 * on signing in/out can be caught in promises returned from
395 * sign-in/sign-out functions.
396 * @param completed - Deprecated. This callback is never triggered.
397 */
398 onIdTokenChanged(nextOrObserver: NextOrObserver<User | null>, error?: ErrorFn, completed?: CompleteFn): Unsubscribe;
399 /** The currently signed-in user (or null). */
400 readonly currentUser: User | null;
401 /** The current emulator configuration (or null). */
402 readonly emulatorConfig: EmulatorConfig | null;
403 /**
404 * Asynchronously sets the provided user as {@link Auth.currentUser} on the {@link Auth} instance.
405 *
406 * @remarks
407 * A new instance copy of the user provided will be made and set as currentUser.
408 *
409 * This will trigger {@link Auth.onAuthStateChanged} and {@link Auth.onIdTokenChanged} listeners
410 * like other sign in methods.
411 *
412 * The operation fails with an error if the user to be updated belongs to a different Firebase
413 * project.
414 *
415 * @param user - The new {@link User}.
416 */
417 updateCurrentUser(user: User | null): Promise<void>;
418 /**
419 * Sets the current language to the default device/browser preference.
420 */
421 useDeviceLanguage(): void;
422 /**
423 * Signs out the current user.
424 */
425 signOut(): Promise<void>;
426}
427
428/**
429 * Interface that represents the credentials returned by an {@link AuthProvider}.
430 *
431 * @remarks
432 * Implementations specify the details about each auth provider's credential requirements.
433 *
434 * @public
435 */
436export declare class AuthCredential {
437 /**
438 * The authentication provider ID for the credential.
439 *
440 * @remarks
441 * For example, 'facebook.com', or 'google.com'.
442 */
443 readonly providerId: string;
444 /**
445 * The authentication sign in method for the credential.
446 *
447 * @remarks
448 * For example, {@link SignInMethod}.EMAIL_PASSWORD, or
449 * {@link SignInMethod}.EMAIL_LINK. This corresponds to the sign-in method
450 * identifier as returned in {@link fetchSignInMethodsForEmail}.
451 */
452 readonly signInMethod: string;
453 /** @internal */
454 protected constructor(
455 /**
456 * The authentication provider ID for the credential.
457 *
458 * @remarks
459 * For example, 'facebook.com', or 'google.com'.
460 */
461 providerId: string,
462 /**
463 * The authentication sign in method for the credential.
464 *
465 * @remarks
466 * For example, {@link SignInMethod}.EMAIL_PASSWORD, or
467 * {@link SignInMethod}.EMAIL_LINK. This corresponds to the sign-in method
468 * identifier as returned in {@link fetchSignInMethodsForEmail}.
469 */
470 signInMethod: string);
471 /**
472 * Returns a JSON-serializable representation of this object.
473 *
474 * @returns a JSON-serializable representation of this object.
475 */
476 toJSON(): object;
477 /** @internal */
478 _getIdTokenResponse(_auth: AuthInternal): Promise<PhoneOrOauthTokenResponse>;
479 /** @internal */
480 _linkToIdToken(_auth: AuthInternal, _idToken: string): Promise<IdTokenResponse>;
481 /** @internal */
482 _getReauthenticationResolver(_auth: AuthInternal): Promise<IdTokenResponse>;
483}
484
485/**
486 * Interface for an `Auth` error.
487 *
488 * @public
489 */
490export declare interface AuthError extends FirebaseError {
491 /** Details about the Firebase Auth error. */
492 readonly customData: {
493 /** The name of the Firebase App which triggered this error. */
494 readonly appName: string;
495 /** The email address of the user's account, used for sign-in and linking. */
496 readonly email?: string;
497 /** The phone number of the user's account, used for sign-in and linking. */
498 readonly phoneNumber?: string;
499 /**
500 * The tenant ID being used for sign-in and linking.
501 *
502 * @remarks
503 * If you use {@link signInWithRedirect} to sign in,
504 * you have to set the tenant ID on the {@link Auth} instance again as the tenant ID is not persisted
505 * after redirection.
506 */
507 readonly tenantId?: string;
508 };
509}
510
511/**
512 * Enumeration of Firebase Auth error codes.
513 *
514 * @internal
515 */
516declare const enum AuthErrorCode {
517 ADMIN_ONLY_OPERATION = "admin-restricted-operation",
518 ARGUMENT_ERROR = "argument-error",
519 APP_NOT_AUTHORIZED = "app-not-authorized",
520 APP_NOT_INSTALLED = "app-not-installed",
521 CAPTCHA_CHECK_FAILED = "captcha-check-failed",
522 CODE_EXPIRED = "code-expired",
523 CORDOVA_NOT_READY = "cordova-not-ready",
524 CORS_UNSUPPORTED = "cors-unsupported",
525 CREDENTIAL_ALREADY_IN_USE = "credential-already-in-use",
526 CREDENTIAL_MISMATCH = "custom-token-mismatch",
527 CREDENTIAL_TOO_OLD_LOGIN_AGAIN = "requires-recent-login",
528 DEPENDENT_SDK_INIT_BEFORE_AUTH = "dependent-sdk-initialized-before-auth",
529 DYNAMIC_LINK_NOT_ACTIVATED = "dynamic-link-not-activated",
530 EMAIL_CHANGE_NEEDS_VERIFICATION = "email-change-needs-verification",
531 EMAIL_EXISTS = "email-already-in-use",
532 EMULATOR_CONFIG_FAILED = "emulator-config-failed",
533 EXPIRED_OOB_CODE = "expired-action-code",
534 EXPIRED_POPUP_REQUEST = "cancelled-popup-request",
535 INTERNAL_ERROR = "internal-error",
536 INVALID_API_KEY = "invalid-api-key",
537 INVALID_APP_CREDENTIAL = "invalid-app-credential",
538 INVALID_APP_ID = "invalid-app-id",
539 INVALID_AUTH = "invalid-user-token",
540 INVALID_AUTH_EVENT = "invalid-auth-event",
541 INVALID_CERT_HASH = "invalid-cert-hash",
542 INVALID_CODE = "invalid-verification-code",
543 INVALID_CONTINUE_URI = "invalid-continue-uri",
544 INVALID_CORDOVA_CONFIGURATION = "invalid-cordova-configuration",
545 INVALID_CUSTOM_TOKEN = "invalid-custom-token",
546 INVALID_DYNAMIC_LINK_DOMAIN = "invalid-dynamic-link-domain",
547 INVALID_EMAIL = "invalid-email",
548 INVALID_EMULATOR_SCHEME = "invalid-emulator-scheme",
549 INVALID_IDP_RESPONSE = "invalid-credential",
550 INVALID_MESSAGE_PAYLOAD = "invalid-message-payload",
551 INVALID_MFA_SESSION = "invalid-multi-factor-session",
552 INVALID_OAUTH_CLIENT_ID = "invalid-oauth-client-id",
553 INVALID_OAUTH_PROVIDER = "invalid-oauth-provider",
554 INVALID_OOB_CODE = "invalid-action-code",
555 INVALID_ORIGIN = "unauthorized-domain",
556 INVALID_PASSWORD = "wrong-password",
557 INVALID_PERSISTENCE = "invalid-persistence-type",
558 INVALID_PHONE_NUMBER = "invalid-phone-number",
559 INVALID_PROVIDER_ID = "invalid-provider-id",
560 INVALID_RECIPIENT_EMAIL = "invalid-recipient-email",
561 INVALID_SENDER = "invalid-sender",
562 INVALID_SESSION_INFO = "invalid-verification-id",
563 INVALID_TENANT_ID = "invalid-tenant-id",
564 LOGIN_BLOCKED = "login-blocked",
565 MFA_INFO_NOT_FOUND = "multi-factor-info-not-found",
566 MFA_REQUIRED = "multi-factor-auth-required",
567 MISSING_ANDROID_PACKAGE_NAME = "missing-android-pkg-name",
568 MISSING_APP_CREDENTIAL = "missing-app-credential",
569 MISSING_AUTH_DOMAIN = "auth-domain-config-required",
570 MISSING_CODE = "missing-verification-code",
571 MISSING_CONTINUE_URI = "missing-continue-uri",
572 MISSING_IFRAME_START = "missing-iframe-start",
573 MISSING_IOS_BUNDLE_ID = "missing-ios-bundle-id",
574 MISSING_OR_INVALID_NONCE = "missing-or-invalid-nonce",
575 MISSING_MFA_INFO = "missing-multi-factor-info",
576 MISSING_MFA_SESSION = "missing-multi-factor-session",
577 MISSING_PHONE_NUMBER = "missing-phone-number",
578 MISSING_SESSION_INFO = "missing-verification-id",
579 MODULE_DESTROYED = "app-deleted",
580 NEED_CONFIRMATION = "account-exists-with-different-credential",
581 NETWORK_REQUEST_FAILED = "network-request-failed",
582 NULL_USER = "null-user",
583 NO_AUTH_EVENT = "no-auth-event",
584 NO_SUCH_PROVIDER = "no-such-provider",
585 OPERATION_NOT_ALLOWED = "operation-not-allowed",
586 OPERATION_NOT_SUPPORTED = "operation-not-supported-in-this-environment",
587 POPUP_BLOCKED = "popup-blocked",
588 POPUP_CLOSED_BY_USER = "popup-closed-by-user",
589 PROVIDER_ALREADY_LINKED = "provider-already-linked",
590 QUOTA_EXCEEDED = "quota-exceeded",
591 REDIRECT_CANCELLED_BY_USER = "redirect-cancelled-by-user",
592 REDIRECT_OPERATION_PENDING = "redirect-operation-pending",
593 REJECTED_CREDENTIAL = "rejected-credential",
594 SECOND_FACTOR_ALREADY_ENROLLED = "second-factor-already-in-use",
595 SECOND_FACTOR_LIMIT_EXCEEDED = "maximum-second-factor-count-exceeded",
596 TENANT_ID_MISMATCH = "tenant-id-mismatch",
597 TIMEOUT = "timeout",
598 TOKEN_EXPIRED = "user-token-expired",
599 TOO_MANY_ATTEMPTS_TRY_LATER = "too-many-requests",
600 UNAUTHORIZED_DOMAIN = "unauthorized-continue-uri",
601 UNSUPPORTED_FIRST_FACTOR = "unsupported-first-factor",
602 UNSUPPORTED_PERSISTENCE = "unsupported-persistence-type",
603 UNSUPPORTED_TENANT_OPERATION = "unsupported-tenant-operation",
604 UNVERIFIED_EMAIL = "unverified-email",
605 USER_CANCELLED = "user-cancelled",
606 USER_DELETED = "user-not-found",
607 USER_DISABLED = "user-disabled",
608 USER_MISMATCH = "user-mismatch",
609 USER_SIGNED_OUT = "user-signed-out",
610 WEAK_PASSWORD = "weak-password",
611 WEB_STORAGE_UNSUPPORTED = "web-storage-unsupported",
612 ALREADY_INITIALIZED = "already-initialized"
613}
614
615/**
616 * A map of potential `Auth` error codes, for easier comparison with errors
617 * thrown by the SDK.
618 *
619 * @remarks
620 * Note that you can't tree-shake individual keys
621 * in the map, so by using the map you might substantially increase your
622 * bundle size.
623 *
624 * @public
625 */
626export declare const AuthErrorCodes: {
627 readonly ADMIN_ONLY_OPERATION: "auth/admin-restricted-operation";
628 readonly ARGUMENT_ERROR: "auth/argument-error";
629 readonly APP_NOT_AUTHORIZED: "auth/app-not-authorized";
630 readonly APP_NOT_INSTALLED: "auth/app-not-installed";
631 readonly CAPTCHA_CHECK_FAILED: "auth/captcha-check-failed";
632 readonly CODE_EXPIRED: "auth/code-expired";
633 readonly CORDOVA_NOT_READY: "auth/cordova-not-ready";
634 readonly CORS_UNSUPPORTED: "auth/cors-unsupported";
635 readonly CREDENTIAL_ALREADY_IN_USE: "auth/credential-already-in-use";
636 readonly CREDENTIAL_MISMATCH: "auth/custom-token-mismatch";
637 readonly CREDENTIAL_TOO_OLD_LOGIN_AGAIN: "auth/requires-recent-login";
638 readonly DEPENDENT_SDK_INIT_BEFORE_AUTH: "auth/dependent-sdk-initialized-before-auth";
639 readonly DYNAMIC_LINK_NOT_ACTIVATED: "auth/dynamic-link-not-activated";
640 readonly EMAIL_CHANGE_NEEDS_VERIFICATION: "auth/email-change-needs-verification";
641 readonly EMAIL_EXISTS: "auth/email-already-in-use";
642 readonly EMULATOR_CONFIG_FAILED: "auth/emulator-config-failed";
643 readonly EXPIRED_OOB_CODE: "auth/expired-action-code";
644 readonly EXPIRED_POPUP_REQUEST: "auth/cancelled-popup-request";
645 readonly INTERNAL_ERROR: "auth/internal-error";
646 readonly INVALID_API_KEY: "auth/invalid-api-key";
647 readonly INVALID_APP_CREDENTIAL: "auth/invalid-app-credential";
648 readonly INVALID_APP_ID: "auth/invalid-app-id";
649 readonly INVALID_AUTH: "auth/invalid-user-token";
650 readonly INVALID_AUTH_EVENT: "auth/invalid-auth-event";
651 readonly INVALID_CERT_HASH: "auth/invalid-cert-hash";
652 readonly INVALID_CODE: "auth/invalid-verification-code";
653 readonly INVALID_CONTINUE_URI: "auth/invalid-continue-uri";
654 readonly INVALID_CORDOVA_CONFIGURATION: "auth/invalid-cordova-configuration";
655 readonly INVALID_CUSTOM_TOKEN: "auth/invalid-custom-token";
656 readonly INVALID_DYNAMIC_LINK_DOMAIN: "auth/invalid-dynamic-link-domain";
657 readonly INVALID_EMAIL: "auth/invalid-email";
658 readonly INVALID_EMULATOR_SCHEME: "auth/invalid-emulator-scheme";
659 readonly INVALID_IDP_RESPONSE: "auth/invalid-credential";
660 readonly INVALID_MESSAGE_PAYLOAD: "auth/invalid-message-payload";
661 readonly INVALID_MFA_SESSION: "auth/invalid-multi-factor-session";
662 readonly INVALID_OAUTH_CLIENT_ID: "auth/invalid-oauth-client-id";
663 readonly INVALID_OAUTH_PROVIDER: "auth/invalid-oauth-provider";
664 readonly INVALID_OOB_CODE: "auth/invalid-action-code";
665 readonly INVALID_ORIGIN: "auth/unauthorized-domain";
666 readonly INVALID_PASSWORD: "auth/wrong-password";
667 readonly INVALID_PERSISTENCE: "auth/invalid-persistence-type";
668 readonly INVALID_PHONE_NUMBER: "auth/invalid-phone-number";
669 readonly INVALID_PROVIDER_ID: "auth/invalid-provider-id";
670 readonly INVALID_RECIPIENT_EMAIL: "auth/invalid-recipient-email";
671 readonly INVALID_SENDER: "auth/invalid-sender";
672 readonly INVALID_SESSION_INFO: "auth/invalid-verification-id";
673 readonly INVALID_TENANT_ID: "auth/invalid-tenant-id";
674 readonly MFA_INFO_NOT_FOUND: "auth/multi-factor-info-not-found";
675 readonly MFA_REQUIRED: "auth/multi-factor-auth-required";
676 readonly MISSING_ANDROID_PACKAGE_NAME: "auth/missing-android-pkg-name";
677 readonly MISSING_APP_CREDENTIAL: "auth/missing-app-credential";
678 readonly MISSING_AUTH_DOMAIN: "auth/auth-domain-config-required";
679 readonly MISSING_CODE: "auth/missing-verification-code";
680 readonly MISSING_CONTINUE_URI: "auth/missing-continue-uri";
681 readonly MISSING_IFRAME_START: "auth/missing-iframe-start";
682 readonly MISSING_IOS_BUNDLE_ID: "auth/missing-ios-bundle-id";
683 readonly MISSING_OR_INVALID_NONCE: "auth/missing-or-invalid-nonce";
684 readonly MISSING_MFA_INFO: "auth/missing-multi-factor-info";
685 readonly MISSING_MFA_SESSION: "auth/missing-multi-factor-session";
686 readonly MISSING_PHONE_NUMBER: "auth/missing-phone-number";
687 readonly MISSING_SESSION_INFO: "auth/missing-verification-id";
688 readonly MODULE_DESTROYED: "auth/app-deleted";
689 readonly NEED_CONFIRMATION: "auth/account-exists-with-different-credential";
690 readonly NETWORK_REQUEST_FAILED: "auth/network-request-failed";
691 readonly NULL_USER: "auth/null-user";
692 readonly NO_AUTH_EVENT: "auth/no-auth-event";
693 readonly NO_SUCH_PROVIDER: "auth/no-such-provider";
694 readonly OPERATION_NOT_ALLOWED: "auth/operation-not-allowed";
695 readonly OPERATION_NOT_SUPPORTED: "auth/operation-not-supported-in-this-environment";
696 readonly POPUP_BLOCKED: "auth/popup-blocked";
697 readonly POPUP_CLOSED_BY_USER: "auth/popup-closed-by-user";
698 readonly PROVIDER_ALREADY_LINKED: "auth/provider-already-linked";
699 readonly QUOTA_EXCEEDED: "auth/quota-exceeded";
700 readonly REDIRECT_CANCELLED_BY_USER: "auth/redirect-cancelled-by-user";
701 readonly REDIRECT_OPERATION_PENDING: "auth/redirect-operation-pending";
702 readonly REJECTED_CREDENTIAL: "auth/rejected-credential";
703 readonly SECOND_FACTOR_ALREADY_ENROLLED: "auth/second-factor-already-in-use";
704 readonly SECOND_FACTOR_LIMIT_EXCEEDED: "auth/maximum-second-factor-count-exceeded";
705 readonly TENANT_ID_MISMATCH: "auth/tenant-id-mismatch";
706 readonly TIMEOUT: "auth/timeout";
707 readonly TOKEN_EXPIRED: "auth/user-token-expired";
708 readonly TOO_MANY_ATTEMPTS_TRY_LATER: "auth/too-many-requests";
709 readonly UNAUTHORIZED_DOMAIN: "auth/unauthorized-continue-uri";
710 readonly UNSUPPORTED_FIRST_FACTOR: "auth/unsupported-first-factor";
711 readonly UNSUPPORTED_PERSISTENCE: "auth/unsupported-persistence-type";
712 readonly UNSUPPORTED_TENANT_OPERATION: "auth/unsupported-tenant-operation";
713 readonly UNVERIFIED_EMAIL: "auth/unverified-email";
714 readonly USER_CANCELLED: "auth/user-cancelled";
715 readonly USER_DELETED: "auth/user-not-found";
716 readonly USER_DISABLED: "auth/user-disabled";
717 readonly USER_MISMATCH: "auth/user-mismatch";
718 readonly USER_SIGNED_OUT: "auth/user-signed-out";
719 readonly WEAK_PASSWORD: "auth/weak-password";
720 readonly WEB_STORAGE_UNSUPPORTED: "auth/web-storage-unsupported";
721 readonly ALREADY_INITIALIZED: "auth/already-initialized";
722};
723
724/**
725 * A mapping of error codes to error messages.
726 *
727 * @remarks
728 *
729 * While error messages are useful for debugging (providing verbose textual
730 * context around what went wrong), these strings take up a lot of space in the
731 * compiled code. When deploying code in production, using {@link prodErrorMap}
732 * will save you roughly 10k compressed/gzipped over {@link debugErrorMap}. You
733 * can select the error map during initialization:
734 *
735 * ```javascript
736 * initializeAuth(app, {errorMap: debugErrorMap})
737 * ```
738 *
739 * When initializing Auth, {@link prodErrorMap} is default.
740 *
741 * @public
742 */
743export declare interface AuthErrorMap {
744}
745
746/**
747 * @internal
748 */
749declare interface AuthErrorParams extends GenericAuthErrorParams {
750 [AuthErrorCode.ARGUMENT_ERROR]: {
751 appName?: AppName;
752 };
753 [AuthErrorCode.DEPENDENT_SDK_INIT_BEFORE_AUTH]: {
754 appName?: AppName;
755 };
756 [AuthErrorCode.INTERNAL_ERROR]: {
757 appName?: AppName;
758 };
759 [AuthErrorCode.LOGIN_BLOCKED]: {
760 appName?: AppName;
761 originalMessage?: string;
762 };
763 [AuthErrorCode.OPERATION_NOT_SUPPORTED]: {
764 appName?: AppName;
765 };
766 [AuthErrorCode.NO_AUTH_EVENT]: {
767 appName?: AppName;
768 };
769 [AuthErrorCode.MFA_REQUIRED]: {
770 appName: AppName;
771 _serverResponse: IdTokenMfaResponse;
772 };
773 [AuthErrorCode.INVALID_CORDOVA_CONFIGURATION]: {
774 appName: AppName;
775 missingPlugin?: string;
776 };
777}
778
779/**
780 * @internal
781 */
782declare interface AuthEvent {
783 type: AuthEventType;
784 eventId: string | null;
785 urlResponse: string | null;
786 sessionId: string | null;
787 postBody: string | null;
788 tenantId: string | null;
789 error?: AuthEventError;
790}
791
792/**
793 * @internal
794 */
795declare interface AuthEventConsumer {
796 readonly filter: AuthEventType[];
797 eventId: string | null;
798 onAuthEvent(event: AuthEvent): unknown;
799 onError(error: FirebaseError): unknown;
800}
801
802declare interface AuthEventError extends Error {
803 code: string;
804 message: string;
805}
806
807/**
808 * @internal
809 */
810declare const enum AuthEventType {
811 LINK_VIA_POPUP = "linkViaPopup",
812 LINK_VIA_REDIRECT = "linkViaRedirect",
813 REAUTH_VIA_POPUP = "reauthViaPopup",
814 REAUTH_VIA_REDIRECT = "reauthViaRedirect",
815 SIGN_IN_VIA_POPUP = "signInViaPopup",
816 SIGN_IN_VIA_REDIRECT = "signInViaRedirect",
817 UNKNOWN = "unknown",
818 VERIFY_APP = "verifyApp"
819}
820
821/**
822 * UserInternal and AuthInternal reference each other, so both of them are included in the public typings.
823 * In order to exclude them, we mark them as internal explicitly.
824 *
825 * @internal
826 */
827declare interface AuthInternal extends Auth {
828 currentUser: User | null;
829 emulatorConfig: EmulatorConfig | null;
830 _canInitEmulator: boolean;
831 _isInitialized: boolean;
832 _initializationPromise: Promise<void> | null;
833 _updateCurrentUser(user: UserInternal | null): Promise<void>;
834 _onStorageEvent(): void;
835 _notifyListenersIfCurrent(user: UserInternal): void;
836 _persistUserIfCurrent(user: UserInternal): Promise<void>;
837 _setRedirectUser(user: UserInternal | null, popupRedirectResolver?: PopupRedirectResolver): Promise<void>;
838 _redirectUserForId(id: string): Promise<UserInternal | null>;
839 _popupRedirectResolver: PopupRedirectResolverInternal | null;
840 _key(): string;
841 _startProactiveRefresh(): void;
842 _stopProactiveRefresh(): void;
843 _getPersistence(): string;
844 _logFramework(framework: string): void;
845 _getFrameworks(): readonly string[];
846 _getAdditionalHeaders(): Promise<Record<string, string>>;
847 readonly name: AppName;
848 readonly config: ConfigInternal;
849 languageCode: string | null;
850 tenantId: string | null;
851 readonly settings: AuthSettings;
852 _errorFactory: ErrorFactory<AuthErrorCode, AuthErrorParams>;
853 useDeviceLanguage(): void;
854 signOut(): Promise<void>;
855}
856
857declare class AuthPopup {
858 readonly window: Window | null;
859 associatedEvent: string | null;
860 constructor(window: Window | null);
861 close(): void;
862}
863
864/**
865 * Interface that represents an auth provider, used to facilitate creating {@link AuthCredential}.
866 *
867 * @public
868 */
869export declare interface AuthProvider {
870 /**
871 * Provider for which credentials can be constructed.
872 */
873 readonly providerId: string;
874}
875
876/**
877 * Interface representing an {@link Auth} instance's settings.
878 *
879 * @remarks Currently used for enabling/disabling app verification for phone Auth testing.
880 *
881 * @public
882 */
883export declare interface AuthSettings {
884 /**
885 * When set, this property disables app verification for the purpose of testing phone
886 * authentication. For this property to take effect, it needs to be set before rendering a
887 * reCAPTCHA app verifier. When this is disabled, a mock reCAPTCHA is rendered instead. This is
888 * useful for manual testing during development or for automated integration tests.
889 *
890 * In order to use this feature, you will need to
891 * {@link https://firebase.google.com/docs/auth/web/phone-auth#test-with-whitelisted-phone-numbers | whitelist your phone number}
892 * via the Firebase Console.
893 *
894 * The default value is false (app verification is enabled).
895 */
896 appVerificationDisabledForTesting: boolean;
897}
898
899/**
900 * MFA Info as returned by the API
901 */
902declare interface BaseMfaEnrollment {
903 mfaEnrollmentId: string;
904 enrolledAt: number;
905 displayName?: string;
906}
907
908/**
909 * Common code to all OAuth providers. This is separate from the
910 * {@link OAuthProvider} so that child providers (like
911 * {@link GoogleAuthProvider}) don't inherit the `credential` instance method.
912 * Instead, they rely on a static `credential` method.
913 */
914declare abstract class BaseOAuthProvider extends FederatedAuthProvider implements AuthProvider {
915 /** @internal */
916 private scopes;
917 /**
918 * Add an OAuth scope to the credential.
919 *
920 * @param scope - Provider OAuth scope to add.
921 */
922 addScope(scope: string): AuthProvider;
923 /**
924 * Retrieve the current list of OAuth scopes.
925 */
926 getScopes(): string[];
927}
928
929/**
930 * Adds a blocking callback that runs before an auth state change
931 * sets a new user.
932 *
933 * @param auth - The {@link Auth} instance.
934 * @param callback - callback triggered before new user value is set.
935 * If this throws, it blocks the user from being set.
936 * @param onAbort - callback triggered if a later `beforeAuthStateChanged()`
937 * callback throws, allowing you to undo any side effects.
938 */
939export declare function beforeAuthStateChanged(auth: Auth, callback: (user: User | null) => void | Promise<void>, onAbort?: () => void): Unsubscribe;
940
941/**
942 * An implementation of {@link Persistence} of type `LOCAL` using `localStorage`
943 * for the underlying storage.
944 *
945 * @public
946 */
947export declare const browserLocalPersistence: Persistence;
948
949/**
950 * An implementation of {@link PopupRedirectResolver} suitable for browser
951 * based applications.
952 *
953 * @public
954 */
955export declare const browserPopupRedirectResolver: PopupRedirectResolver;
956
957/**
958 * An implementation of {@link Persistence} of `SESSION` using `sessionStorage`
959 * for the underlying storage.
960 *
961 * @public
962 */
963export declare const browserSessionPersistence: Persistence;
964
965/**
966 * Checks a verification code sent to the user by email or other out-of-band mechanism.
967 *
968 * @returns metadata about the code.
969 *
970 * @param auth - The {@link Auth} instance.
971 * @param oobCode - A verification code sent to the user.
972 *
973 * @public
974 */
975export declare function checkActionCode(auth: Auth, oobCode: string): Promise<ActionCodeInfo>;
976
977/**
978 * @internal
979 */
980declare const enum ClientPlatform {
981 BROWSER = "Browser",
982 NODE = "Node",
983 REACT_NATIVE = "ReactNative",
984 CORDOVA = "Cordova",
985 WORKER = "Worker"
986}
987export { CompleteFn }
988
989/**
990 * Interface representing the `Auth` config.
991 *
992 * @public
993 */
994export declare interface Config {
995 /**
996 * The API Key used to communicate with the Firebase Auth backend.
997 */
998 apiKey: string;
999 /**
1000 * The host at which the Firebase Auth backend is running.
1001 */
1002 apiHost: string;
1003 /**
1004 * The scheme used to communicate with the Firebase Auth backend.
1005 */
1006 apiScheme: string;
1007 /**
1008 * The host at which the Secure Token API is running.
1009 */
1010 tokenApiHost: string;
1011 /**
1012 * The SDK Client Version.
1013 */
1014 sdkClientVersion: string;
1015 /**
1016 * The domain at which the web widgets are hosted (provided via Firebase Config).
1017 */
1018 authDomain?: string;
1019}
1020
1021/**
1022 * @internal
1023 */
1024declare interface ConfigInternal extends Config {
1025 /**
1026 * @readonly
1027 */
1028 emulator?: {
1029 url: string;
1030 };
1031 /**
1032 * @readonly
1033 */
1034 clientPlatform: ClientPlatform;
1035}
1036
1037/**
1038 * A result from a phone number sign-in, link, or reauthenticate call.
1039 *
1040 * @public
1041 */
1042export declare interface ConfirmationResult {
1043 /**
1044 * The phone number authentication operation's verification ID.
1045 *
1046 * @remarks
1047 * This can be used along with the verification code to initialize a
1048 * {@link PhoneAuthCredential}.
1049 */
1050 readonly verificationId: string;
1051 /**
1052 * Finishes a phone number sign-in, link, or reauthentication.
1053 *
1054 * @example
1055 * ```javascript
1056 * const confirmationResult = await signInWithPhoneNumber(auth, phoneNumber, applicationVerifier);
1057 * // Obtain verificationCode from the user.
1058 * const userCredential = await confirmationResult.confirm(verificationCode);
1059 * ```
1060 *
1061 * @param verificationCode - The code that was sent to the user's mobile device.
1062 */
1063 confirm(verificationCode: string): Promise<UserCredential>;
1064}
1065
1066/**
1067 * Completes the password reset process, given a confirmation code and new password.
1068 *
1069 * @param auth - The {@link Auth} instance.
1070 * @param oobCode - A confirmation code sent to the user.
1071 * @param newPassword - The new password.
1072 *
1073 * @public
1074 */
1075export declare function confirmPasswordReset(auth: Auth, oobCode: string, newPassword: string): Promise<void>;
1076
1077/**
1078 * Changes the {@link Auth} instance to communicate with the Firebase Auth Emulator, instead of production
1079 * Firebase Auth services.
1080 *
1081 * @remarks
1082 * This must be called synchronously immediately following the first call to
1083 * {@link initializeAuth}. Do not use with production credentials as emulator
1084 * traffic is not encrypted.
1085 *
1086 *
1087 * @example
1088 * ```javascript
1089 * connectAuthEmulator(auth, 'http://127.0.0.1:9099', { disableWarnings: true });
1090 * ```
1091 *
1092 * @param auth - The {@link Auth} instance.
1093 * @param url - The URL at which the emulator is running (eg, 'http://localhost:9099').
1094 * @param options - Optional. `options.disableWarnings` defaults to `false`. Set it to
1095 * `true` to disable the warning banner attached to the DOM.
1096 *
1097 * @public
1098 */
1099export declare function connectAuthEmulator(auth: Auth, url: string, options?: {
1100 disableWarnings: boolean;
1101}): void;
1102
1103/**
1104 * Creates a new user account associated with the specified email address and password.
1105 *
1106 * @remarks
1107 * On successful creation of the user account, this user will also be signed in to your application.
1108 *
1109 * User account creation can fail if the account already exists or the password is invalid.
1110 *
1111 * Note: The email address acts as a unique identifier for the user and enables an email-based
1112 * password reset. This function will create a new user account and set the initial user password.
1113 *
1114 * @param auth - The {@link Auth} instance.
1115 * @param email - The user's email address.
1116 * @param password - The user's chosen password.
1117 *
1118 * @public
1119 */
1120export declare function createUserWithEmailAndPassword(auth: Auth, email: string, password: string): Promise<UserCredential>;
1121
1122/**
1123 * Map of OAuth Custom Parameters.
1124 *
1125 * @public
1126 */
1127export declare type CustomParameters = Record<string, string>;
1128
1129/**
1130 * A verbose error map with detailed descriptions for most error codes.
1131 *
1132 * See discussion at {@link AuthErrorMap}
1133 *
1134 * @public
1135 */
1136export declare const debugErrorMap: AuthErrorMap;
1137
1138/**
1139 * Deletes and signs out the user.
1140 *
1141 * @remarks
1142 * Important: this is a security-sensitive operation that requires the user to have recently
1143 * signed in. If this requirement isn't met, ask the user to authenticate again and then call
1144 * {@link reauthenticateWithCredential}.
1145 *
1146 * @param user - The user.
1147 *
1148 * @public
1149 */
1150export declare function deleteUser(user: User): Promise<void>;
1151
1152/**
1153 * The dependencies that can be used to initialize an {@link Auth} instance.
1154 *
1155 * @remarks
1156 *
1157 * The modular SDK enables tree shaking by allowing explicit declarations of
1158 * dependencies. For example, a web app does not need to include code that
1159 * enables Cordova redirect sign in. That functionality is therefore split into
1160 * {@link browserPopupRedirectResolver} and
1161 * {@link cordovaPopupRedirectResolver}. The dependencies object is how Auth is
1162 * configured to reduce bundle sizes.
1163 *
1164 * There are two ways to initialize an {@link Auth} instance: {@link getAuth} and
1165 * {@link initializeAuth}. `getAuth` initializes everything using
1166 * platform-specific configurations, while `initializeAuth` takes a
1167 * `Dependencies` object directly, giving you more control over what is used.
1168 *
1169 * @public
1170 */
1171export declare interface Dependencies {
1172 /**
1173 * Which {@link Persistence} to use. If this is an array, the first
1174 * `Persistence` that the device supports is used. The SDK searches for an
1175 * existing account in order and, if one is found in a secondary
1176 * `Persistence`, the account is moved to the primary `Persistence`.
1177 *
1178 * If no persistence is provided, the SDK falls back on
1179 * {@link inMemoryPersistence}.
1180 */
1181 persistence?: Persistence | Persistence[];
1182 /**
1183 * The {@link PopupRedirectResolver} to use. This value depends on the
1184 * platform. Options are {@link browserPopupRedirectResolver} and
1185 * {@link cordovaPopupRedirectResolver}. This field is optional if neither
1186 * {@link signInWithPopup} or {@link signInWithRedirect} are being used.
1187 */
1188 popupRedirectResolver?: PopupRedirectResolver;
1189 /**
1190 * Which {@link AuthErrorMap} to use.
1191 */
1192 errorMap?: AuthErrorMap;
1193}
1194
1195/**
1196 * Interface that represents the credentials returned by {@link EmailAuthProvider} for
1197 * {@link ProviderId}.PASSWORD
1198 *
1199 * @remarks
1200 * Covers both {@link SignInMethod}.EMAIL_PASSWORD and
1201 * {@link SignInMethod}.EMAIL_LINK.
1202 *
1203 * @public
1204 */
1205export declare class EmailAuthCredential extends AuthCredential {
1206 /** @internal */
1207 readonly _email: string;
1208 /** @internal */
1209 readonly _password: string;
1210 /** @internal */
1211 readonly _tenantId: string | null;
1212 /** @internal */
1213 private constructor();
1214 /** @internal */
1215 static _fromEmailAndPassword(email: string, password: string): EmailAuthCredential;
1216 /** @internal */
1217 static _fromEmailAndCode(email: string, oobCode: string, tenantId?: string | null): EmailAuthCredential;
1218 /** {@inheritdoc AuthCredential.toJSON} */
1219 toJSON(): object;
1220 /**
1221 * Static method to deserialize a JSON representation of an object into an {@link AuthCredential}.
1222 *
1223 * @param json - Either `object` or the stringified representation of the object. When string is
1224 * provided, `JSON.parse` would be called first.
1225 *
1226 * @returns If the JSON input does not represent an {@link AuthCredential}, null is returned.
1227 */
1228 static fromJSON(json: object | string): EmailAuthCredential | null;
1229 /** @internal */
1230 _getIdTokenResponse(auth: AuthInternal): Promise<IdTokenResponse>;
1231 /** @internal */
1232 _linkToIdToken(auth: AuthInternal, idToken: string): Promise<IdTokenResponse>;
1233 /** @internal */
1234 _getReauthenticationResolver(auth: AuthInternal): Promise<IdTokenResponse>;
1235}
1236
1237/**
1238 * Provider for generating {@link EmailAuthCredential}.
1239 *
1240 * @public
1241 */
1242export declare class EmailAuthProvider implements AuthProvider {
1243 /**
1244 * Always set to {@link ProviderId}.PASSWORD, even for email link.
1245 */
1246 static readonly PROVIDER_ID: 'password';
1247 /**
1248 * Always set to {@link SignInMethod}.EMAIL_PASSWORD.
1249 */
1250 static readonly EMAIL_PASSWORD_SIGN_IN_METHOD: 'password';
1251 /**
1252 * Always set to {@link SignInMethod}.EMAIL_LINK.
1253 */
1254 static readonly EMAIL_LINK_SIGN_IN_METHOD: 'emailLink';
1255 /**
1256 * Always set to {@link ProviderId}.PASSWORD, even for email link.
1257 */
1258 readonly providerId: "password";
1259 /**
1260 * Initialize an {@link AuthCredential} using an email and password.
1261 *
1262 * @example
1263 * ```javascript
1264 * const authCredential = EmailAuthProvider.credential(email, password);
1265 * const userCredential = await signInWithCredential(auth, authCredential);
1266 * ```
1267 *
1268 * @example
1269 * ```javascript
1270 * const userCredential = await signInWithEmailAndPassword(auth, email, password);
1271 * ```
1272 *
1273 * @param email - Email address.
1274 * @param password - User account password.
1275 * @returns The auth provider credential.
1276 */
1277 static credential(email: string, password: string): EmailAuthCredential;
1278 /**
1279 * Initialize an {@link AuthCredential} using an email and an email link after a sign in with
1280 * email link operation.
1281 *
1282 * @example
1283 * ```javascript
1284 * const authCredential = EmailAuthProvider.credentialWithLink(auth, email, emailLink);
1285 * const userCredential = await signInWithCredential(auth, authCredential);
1286 * ```
1287 *
1288 * @example
1289 * ```javascript
1290 * await sendSignInLinkToEmail(auth, email);
1291 * // Obtain emailLink from user.
1292 * const userCredential = await signInWithEmailLink(auth, email, emailLink);
1293 * ```
1294 *
1295 * @param auth - The {@link Auth} instance used to verify the link.
1296 * @param email - Email address.
1297 * @param emailLink - Sign-in email link.
1298 * @returns - The auth provider credential.
1299 */
1300 static credentialWithLink(email: string, emailLink: string): EmailAuthCredential;
1301}
1302
1303/**
1304 * Configuration of Firebase Authentication Emulator.
1305 * @public
1306 */
1307export declare interface EmulatorConfig {
1308 /**
1309 * The protocol used to communicate with the emulator ("http"/"https").
1310 */
1311 readonly protocol: string;
1312 /**
1313 * The hostname of the emulator, which may be a domain ("localhost"), IPv4 address ("127.0.0.1")
1314 * or quoted IPv6 address ("[::1]").
1315 */
1316 readonly host: string;
1317 /**
1318 * The port of the emulator, or null if port isn't specified (i.e. protocol default).
1319 */
1320 readonly port: number | null;
1321 /**
1322 * The emulator-specific options.
1323 */
1324 readonly options: {
1325 /**
1326 * Whether the warning banner attached to the DOM was disabled.
1327 */
1328 readonly disableWarnings: boolean;
1329 };
1330}
1331export { ErrorFn }
1332
1333/**
1334 * @internal
1335 */
1336declare interface EventManager {
1337 registerConsumer(authEventConsumer: AuthEventConsumer): void;
1338 unregisterConsumer(authEventConsumer: AuthEventConsumer): void;
1339}
1340
1341/**
1342 * Provider for generating an {@link OAuthCredential} for {@link ProviderId}.FACEBOOK.
1343 *
1344 * @example
1345 * ```javascript
1346 * // Sign in using a redirect.
1347 * const provider = new FacebookAuthProvider();
1348 * // Start a sign in process for an unauthenticated user.
1349 * provider.addScope('user_birthday');
1350 * await signInWithRedirect(auth, provider);
1351 * // This will trigger a full page redirect away from your app
1352 *
1353 * // After returning from the redirect when your app initializes you can obtain the result
1354 * const result = await getRedirectResult(auth);
1355 * if (result) {
1356 * // This is the signed-in user
1357 * const user = result.user;
1358 * // This gives you a Facebook Access Token.
1359 * const credential = FacebookAuthProvider.credentialFromResult(result);
1360 * const token = credential.accessToken;
1361 * }
1362 * ```
1363 *
1364 * @example
1365 * ```javascript
1366 * // Sign in using a popup.
1367 * const provider = new FacebookAuthProvider();
1368 * provider.addScope('user_birthday');
1369 * const result = await signInWithPopup(auth, provider);
1370 *
1371 * // The signed-in user info.
1372 * const user = result.user;
1373 * // This gives you a Facebook Access Token.
1374 * const credential = FacebookAuthProvider.credentialFromResult(result);
1375 * const token = credential.accessToken;
1376 * ```
1377 *
1378 * @public
1379 */
1380export declare class FacebookAuthProvider extends BaseOAuthProvider {
1381 /** Always set to {@link SignInMethod}.FACEBOOK. */
1382 static readonly FACEBOOK_SIGN_IN_METHOD: 'facebook.com';
1383 /** Always set to {@link ProviderId}.FACEBOOK. */
1384 static readonly PROVIDER_ID: 'facebook.com';
1385 constructor();
1386 /**
1387 * Creates a credential for Facebook.
1388 *
1389 * @example
1390 * ```javascript
1391 * // `event` from the Facebook auth.authResponseChange callback.
1392 * const credential = FacebookAuthProvider.credential(event.authResponse.accessToken);
1393 * const result = await signInWithCredential(credential);
1394 * ```
1395 *
1396 * @param accessToken - Facebook access token.
1397 */
1398 static credential(accessToken: string): OAuthCredential;
1399 /**
1400 * Used to extract the underlying {@link OAuthCredential} from a {@link UserCredential}.
1401 *
1402 * @param userCredential - The user credential.
1403 */
1404 static credentialFromResult(userCredential: UserCredential): OAuthCredential | null;
1405 /**
1406 * Used to extract the underlying {@link OAuthCredential} from a {@link AuthError} which was
1407 * thrown during a sign-in, link, or reauthenticate operation.
1408 *
1409 * @param userCredential - The user credential.
1410 */
1411 static credentialFromError(error: FirebaseError): OAuthCredential | null;
1412 private static credentialFromTaggedObject;
1413}
1414
1415/**
1416 * An enum of factors that may be used for multifactor authentication.
1417 *
1418 * @public
1419 */
1420export declare const FactorId: {
1421 /** Phone as second factor */
1422 readonly PHONE: "phone";
1423};
1424
1425/**
1426 * The base class for all Federated providers (OAuth (including OIDC), SAML).
1427 *
1428 * This class is not meant to be instantiated directly.
1429 *
1430 * @public
1431 */
1432declare abstract class FederatedAuthProvider implements AuthProvider {
1433 readonly providerId: string;
1434 /** @internal */
1435 defaultLanguageCode: string | null;
1436 /** @internal */
1437 private customParameters;
1438 /**
1439 * Constructor for generic OAuth providers.
1440 *
1441 * @param providerId - Provider for which credentials should be generated.
1442 */
1443 constructor(providerId: string);
1444 /**
1445 * Set the language gode.
1446 *
1447 * @param languageCode - language code
1448 */
1449 setDefaultLanguage(languageCode: string | null): void;
1450 /**
1451 * Sets the OAuth custom parameters to pass in an OAuth request for popup and redirect sign-in
1452 * operations.
1453 *
1454 * @remarks
1455 * For a detailed list, check the reserved required OAuth 2.0 parameters such as `client_id`,
1456 * `redirect_uri`, `scope`, `response_type`, and `state` are not allowed and will be ignored.
1457 *
1458 * @param customOAuthParameters - The custom OAuth parameters to pass in the OAuth request.
1459 */
1460 setCustomParameters(customOAuthParameters: CustomParameters): AuthProvider;
1461 /**
1462 * Retrieve the current list of {@link CustomParameters}.
1463 */
1464 getCustomParameters(): CustomParameters;
1465}
1466
1467/**
1468 * Gets the list of possible sign in methods for the given email address.
1469 *
1470 * @remarks
1471 * This is useful to differentiate methods of sign-in for the same provider, eg.
1472 * {@link EmailAuthProvider} which has 2 methods of sign-in,
1473 * {@link SignInMethod}.EMAIL_PASSWORD and
1474 * {@link SignInMethod}.EMAIL_LINK.
1475 *
1476 * @param auth - The {@link Auth} instance.
1477 * @param email - The user's email address.
1478 *
1479 * @public
1480 */
1481export declare function fetchSignInMethodsForEmail(auth: Auth, email: string): Promise<string[]>;
1482
1483declare interface FinalizeMfaResponse {
1484 idToken: string;
1485 refreshToken: string;
1486}
1487
1488/**
1489 * @internal
1490 */
1491declare type GenericAuthErrorParams = {
1492 [key in Exclude<AuthErrorCode, AuthErrorCode.ARGUMENT_ERROR | AuthErrorCode.DEPENDENT_SDK_INIT_BEFORE_AUTH | AuthErrorCode.INTERNAL_ERROR | AuthErrorCode.MFA_REQUIRED | AuthErrorCode.NO_AUTH_EVENT | AuthErrorCode.OPERATION_NOT_SUPPORTED>]: {
1493 appName?: AppName;
1494 email?: string;
1495 phoneNumber?: string;
1496 message?: string;
1497 };
1498};
1499
1500/**
1501 * Extracts provider specific {@link AdditionalUserInfo} for the given credential.
1502 *
1503 * @param userCredential - The user credential.
1504 *
1505 * @public
1506 */
1507export declare function getAdditionalUserInfo(userCredential: UserCredential): AdditionalUserInfo | null;
1508
1509/**
1510 * Returns the Auth instance associated with the provided {@link @firebase/app#FirebaseApp}.
1511 * If no instance exists, initializes an Auth instance with platform-specific default dependencies.
1512 *
1513 * @param app - The Firebase App.
1514 *
1515 * @public
1516 */
1517export declare function getAuth(app?: FirebaseApp): Auth;
1518
1519/**
1520 * Returns a JSON Web Token (JWT) used to identify the user to a Firebase service.
1521 *
1522 * @remarks
1523 * Returns the current token if it has not expired or if it will not expire in the next five
1524 * minutes. Otherwise, this will refresh the token and return a new one.
1525 *
1526 * @param user - The user.
1527 * @param forceRefresh - Force refresh regardless of token expiration.
1528 *
1529 * @public
1530 */
1531export declare function getIdToken(user: User, forceRefresh?: boolean): Promise<string>;
1532
1533/**
1534 * Returns a deserialized JSON Web Token (JWT) used to identitfy the user to a Firebase service.
1535 *
1536 * @remarks
1537 * Returns the current token if it has not expired or if it will not expire in the next five
1538 * minutes. Otherwise, this will refresh the token and return a new one.
1539 *
1540 * @param user - The user.
1541 * @param forceRefresh - Force refresh regardless of token expiration.
1542 *
1543 * @public
1544 */
1545export declare function getIdTokenResult(user: User, forceRefresh?: boolean): Promise<IdTokenResult>;
1546
1547/**
1548 * Provides a {@link MultiFactorResolver} suitable for completion of a
1549 * multi-factor flow.
1550 *
1551 * @param auth - The {@link Auth} instance.
1552 * @param error - The {@link MultiFactorError} raised during a sign-in, or
1553 * reauthentication operation.
1554 *
1555 * @public
1556 */
1557export declare function getMultiFactorResolver(auth: Auth, error: MultiFactorError): MultiFactorResolver;
1558
1559/**
1560 * Returns a {@link UserCredential} from the redirect-based sign-in flow.
1561 *
1562 * @remarks
1563 * If sign-in succeeded, returns the signed in user. If sign-in was unsuccessful, fails with an
1564 * error. If no redirect operation was called, returns a {@link UserCredential}
1565 * with a null `user`.
1566 *
1567 * @example
1568 * ```javascript
1569 * // Sign in using a redirect.
1570 * const provider = new FacebookAuthProvider();
1571 * // You can add additional scopes to the provider:
1572 * provider.addScope('user_birthday');
1573 * // Start a sign in process for an unauthenticated user.
1574 * await signInWithRedirect(auth, provider);
1575 * // This will trigger a full page redirect away from your app
1576 *
1577 * // After returning from the redirect when your app initializes you can obtain the result
1578 * const result = await getRedirectResult(auth);
1579 * if (result) {
1580 * // This is the signed-in user
1581 * const user = result.user;
1582 * // This gives you a Facebook Access Token.
1583 * const credential = provider.credentialFromResult(auth, result);
1584 * const token = credential.accessToken;
1585 * }
1586 * // As this API can be used for sign-in, linking and reauthentication,
1587 * // check the operationType to determine what triggered this redirect
1588 * // operation.
1589 * const operationType = result.operationType;
1590 * ```
1591 *
1592 * @param auth - The {@link Auth} instance.
1593 * @param resolver - An instance of {@link PopupRedirectResolver}, optional
1594 * if already supplied to {@link initializeAuth} or provided by {@link getAuth}.
1595 *
1596 * @public
1597 */
1598export declare function getRedirectResult(auth: Auth, resolver?: PopupRedirectResolver): Promise<UserCredential | null>;
1599
1600/**
1601 * Provider for generating an {@link OAuthCredential} for {@link ProviderId}.GITHUB.
1602 *
1603 * @remarks
1604 * GitHub requires an OAuth 2.0 redirect, so you can either handle the redirect directly, or use
1605 * the {@link signInWithPopup} handler:
1606 *
1607 * @example
1608 * ```javascript
1609 * // Sign in using a redirect.
1610 * const provider = new GithubAuthProvider();
1611 * // Start a sign in process for an unauthenticated user.
1612 * provider.addScope('repo');
1613 * await signInWithRedirect(auth, provider);
1614 * // This will trigger a full page redirect away from your app
1615 *
1616 * // After returning from the redirect when your app initializes you can obtain the result
1617 * const result = await getRedirectResult(auth);
1618 * if (result) {
1619 * // This is the signed-in user
1620 * const user = result.user;
1621 * // This gives you a Github Access Token.
1622 * const credential = GithubAuthProvider.credentialFromResult(result);
1623 * const token = credential.accessToken;
1624 * }
1625 * ```
1626 *
1627 * @example
1628 * ```javascript
1629 * // Sign in using a popup.
1630 * const provider = new GithubAuthProvider();
1631 * provider.addScope('repo');
1632 * const result = await signInWithPopup(auth, provider);
1633 *
1634 * // The signed-in user info.
1635 * const user = result.user;
1636 * // This gives you a Github Access Token.
1637 * const credential = GithubAuthProvider.credentialFromResult(result);
1638 * const token = credential.accessToken;
1639 * ```
1640 * @public
1641 */
1642export declare class GithubAuthProvider extends BaseOAuthProvider {
1643 /** Always set to {@link SignInMethod}.GITHUB. */
1644 static readonly GITHUB_SIGN_IN_METHOD: 'github.com';
1645 /** Always set to {@link ProviderId}.GITHUB. */
1646 static readonly PROVIDER_ID: 'github.com';
1647 constructor();
1648 /**
1649 * Creates a credential for Github.
1650 *
1651 * @param accessToken - Github access token.
1652 */
1653 static credential(accessToken: string): OAuthCredential;
1654 /**
1655 * Used to extract the underlying {@link OAuthCredential} from a {@link UserCredential}.
1656 *
1657 * @param userCredential - The user credential.
1658 */
1659 static credentialFromResult(userCredential: UserCredential): OAuthCredential | null;
1660 /**
1661 * Used to extract the underlying {@link OAuthCredential} from a {@link AuthError} which was
1662 * thrown during a sign-in, link, or reauthenticate operation.
1663 *
1664 * @param userCredential - The user credential.
1665 */
1666 static credentialFromError(error: FirebaseError): OAuthCredential | null;
1667 private static credentialFromTaggedObject;
1668}
1669
1670/**
1671 * Provider for generating an an {@link OAuthCredential} for {@link ProviderId}.GOOGLE.
1672 *
1673 * @example
1674 * ```javascript
1675 * // Sign in using a redirect.
1676 * const provider = new GoogleAuthProvider();
1677 * // Start a sign in process for an unauthenticated user.
1678 * provider.addScope('profile');
1679 * provider.addScope('email');
1680 * await signInWithRedirect(auth, provider);
1681 * // This will trigger a full page redirect away from your app
1682 *
1683 * // After returning from the redirect when your app initializes you can obtain the result
1684 * const result = await getRedirectResult(auth);
1685 * if (result) {
1686 * // This is the signed-in user
1687 * const user = result.user;
1688 * // This gives you a Google Access Token.
1689 * const credential = GoogleAuthProvider.credentialFromResult(result);
1690 * const token = credential.accessToken;
1691 * }
1692 * ```
1693 *
1694 * @example
1695 * ```javascript
1696 * // Sign in using a popup.
1697 * const provider = new GoogleAuthProvider();
1698 * provider.addScope('profile');
1699 * provider.addScope('email');
1700 * const result = await signInWithPopup(auth, provider);
1701 *
1702 * // The signed-in user info.
1703 * const user = result.user;
1704 * // This gives you a Google Access Token.
1705 * const credential = GoogleAuthProvider.credentialFromResult(result);
1706 * const token = credential.accessToken;
1707 * ```
1708 *
1709 * @public
1710 */
1711export declare class GoogleAuthProvider extends BaseOAuthProvider {
1712 /** Always set to {@link SignInMethod}.GOOGLE. */
1713 static readonly GOOGLE_SIGN_IN_METHOD: 'google.com';
1714 /** Always set to {@link ProviderId}.GOOGLE. */
1715 static readonly PROVIDER_ID: 'google.com';
1716 constructor();
1717 /**
1718 * Creates a credential for Google. At least one of ID token and access token is required.
1719 *
1720 * @example
1721 * ```javascript
1722 * // \`googleUser\` from the onsuccess Google Sign In callback.
1723 * const credential = GoogleAuthProvider.credential(googleUser.getAuthResponse().id_token);
1724 * const result = await signInWithCredential(credential);
1725 * ```
1726 *
1727 * @param idToken - Google ID token.
1728 * @param accessToken - Google access token.
1729 */
1730 static credential(idToken?: string | null, accessToken?: string | null): OAuthCredential;
1731 /**
1732 * Used to extract the underlying {@link OAuthCredential} from a {@link UserCredential}.
1733 *
1734 * @param userCredential - The user credential.
1735 */
1736 static credentialFromResult(userCredential: UserCredential): OAuthCredential | null;
1737 /**
1738 * Used to extract the underlying {@link OAuthCredential} from a {@link AuthError} which was
1739 * thrown during a sign-in, link, or reauthenticate operation.
1740 *
1741 * @param userCredential - The user credential.
1742 */
1743 static credentialFromError(error: FirebaseError): OAuthCredential | null;
1744 private static credentialFromTaggedObject;
1745}
1746
1747/**
1748 * Raw encoded JWT
1749 *
1750 */
1751declare type IdToken = string;
1752
1753/**
1754 * @internal
1755 */
1756declare interface IdTokenMfaResponse extends IdTokenResponse {
1757 mfaPendingCredential?: string;
1758 mfaInfo?: MfaEnrollment[];
1759}
1760
1761/**
1762 * IdToken as returned by the API
1763 *
1764 * @internal
1765 */
1766declare interface IdTokenResponse {
1767 localId: string;
1768 idToken?: IdToken;
1769 refreshToken?: string;
1770 expiresIn?: string;
1771 providerId?: string;
1772 displayName?: string | null;
1773 isNewUser?: boolean;
1774 kind?: IdTokenResponseKind;
1775 photoUrl?: string | null;
1776 rawUserInfo?: string;
1777 screenName?: string | null;
1778}
1779
1780/**
1781 * The possible types of the `IdTokenResponse`
1782 *
1783 * @internal
1784 */
1785declare const enum IdTokenResponseKind {
1786 CreateAuthUri = "identitytoolkit#CreateAuthUriResponse",
1787 DeleteAccount = "identitytoolkit#DeleteAccountResponse",
1788 DownloadAccount = "identitytoolkit#DownloadAccountResponse",
1789 EmailLinkSignin = "identitytoolkit#EmailLinkSigninResponse",
1790 GetAccountInfo = "identitytoolkit#GetAccountInfoResponse",
1791 GetOobConfirmationCode = "identitytoolkit#GetOobConfirmationCodeResponse",
1792 GetRecaptchaParam = "identitytoolkit#GetRecaptchaParamResponse",
1793 ResetPassword = "identitytoolkit#ResetPasswordResponse",
1794 SetAccountInfo = "identitytoolkit#SetAccountInfoResponse",
1795 SignupNewUser = "identitytoolkit#SignupNewUserResponse",
1796 UploadAccount = "identitytoolkit#UploadAccountResponse",
1797 VerifyAssertion = "identitytoolkit#VerifyAssertionResponse",
1798 VerifyCustomToken = "identitytoolkit#VerifyCustomTokenResponse",
1799 VerifyPassword = "identitytoolkit#VerifyPasswordResponse"
1800}
1801
1802/**
1803 * Interface representing ID token result obtained from {@link User.getIdTokenResult}.
1804 *
1805 * @remarks
1806 * `IdTokenResult` contains the ID token JWT string and other helper properties for getting different data
1807 * associated with the token as well as all the decoded payload claims.
1808 *
1809 * Note that these claims are not to be trusted as they are parsed client side. Only server side
1810 * verification can guarantee the integrity of the token claims.
1811 *
1812 * @public
1813 */
1814export declare interface IdTokenResult {
1815 /**
1816 * The authentication time formatted as a UTC string.
1817 *
1818 * @remarks
1819 * This is the time the user authenticated (signed in) and not the time the token was refreshed.
1820 */
1821 authTime: string;
1822 /** The ID token expiration time formatted as a UTC string. */
1823 expirationTime: string;
1824 /** The ID token issuance time formatted as a UTC string. */
1825 issuedAtTime: string;
1826 /**
1827 * The sign-in provider through which the ID token was obtained (anonymous, custom, phone,
1828 * password, etc).
1829 *
1830 * @remarks
1831 * Note, this does not map to provider IDs.
1832 */
1833 signInProvider: string | null;
1834 /**
1835 * The type of second factor associated with this session, provided the user was multi-factor
1836 * authenticated (eg. phone, etc).
1837 */
1838 signInSecondFactor: string | null;
1839 /** The Firebase Auth ID token JWT string. */
1840 token: string;
1841 /**
1842 * The entire payload claims of the ID token including the standard reserved claims as well as
1843 * the custom claims.
1844 */
1845 claims: ParsedToken;
1846}
1847
1848/**
1849 * An implementation of {@link Persistence} of type `LOCAL` using `indexedDB`
1850 * for the underlying storage.
1851 *
1852 * @public
1853 */
1854export declare const indexedDBLocalPersistence: Persistence;
1855
1856/**
1857 * Initializes an {@link Auth} instance with fine-grained control over
1858 * {@link Dependencies}.
1859 *
1860 * @remarks
1861 *
1862 * This function allows more control over the {@link Auth} instance than
1863 * {@link getAuth}. `getAuth` uses platform-specific defaults to supply
1864 * the {@link Dependencies}. In general, `getAuth` is the easiest way to
1865 * initialize Auth and works for most use cases. Use `initializeAuth` if you
1866 * need control over which persistence layer is used, or to minimize bundle
1867 * size if you're not using either `signInWithPopup` or `signInWithRedirect`.
1868 *
1869 * For example, if your app only uses anonymous accounts and you only want
1870 * accounts saved for the current session, initialize `Auth` with:
1871 *
1872 * ```js
1873 * const auth = initializeAuth(app, {
1874 * persistence: browserSessionPersistence,
1875 * popupRedirectResolver: undefined,
1876 * });
1877 * ```
1878 *
1879 * @public
1880 */
1881export declare function initializeAuth(app: FirebaseApp, deps?: Dependencies): Auth;
1882
1883/**
1884 * An implementation of {@link Persistence} of type 'NONE'.
1885 *
1886 * @public
1887 */
1888export declare const inMemoryPersistence: Persistence;
1889
1890/**
1891 * Checks if an incoming link is a sign-in with email link suitable for {@link signInWithEmailLink}.
1892 *
1893 * @param auth - The {@link Auth} instance.
1894 * @param emailLink - The link sent to the user's email address.
1895 *
1896 * @public
1897 */
1898export declare function isSignInWithEmailLink(auth: Auth, emailLink: string): boolean;
1899
1900/**
1901 * Links the user account with the given credentials.
1902 *
1903 * @remarks
1904 * An {@link AuthProvider} can be used to generate the credential.
1905 *
1906 * @param user - The user.
1907 * @param credential - The auth credential.
1908 *
1909 * @public
1910 */
1911export declare function linkWithCredential(user: User, credential: AuthCredential): Promise<UserCredential>;
1912
1913/**
1914 * Links the user account with the given phone number.
1915 *
1916 * @param user - The user.
1917 * @param phoneNumber - The user's phone number in E.164 format (e.g. +16505550101).
1918 * @param appVerifier - The {@link ApplicationVerifier}.
1919 *
1920 * @public
1921 */
1922export declare function linkWithPhoneNumber(user: User, phoneNumber: string, appVerifier: ApplicationVerifier): Promise<ConfirmationResult>;
1923
1924/**
1925 * Links the authenticated provider to the user account using a pop-up based OAuth flow.
1926 *
1927 * @remarks
1928 * If the linking is successful, the returned result will contain the user and the provider's credential.
1929 *
1930 *
1931 * @example
1932 * ```javascript
1933 * // Sign in using some other provider.
1934 * const result = await signInWithEmailAndPassword(auth, email, password);
1935 * // Link using a popup.
1936 * const provider = new FacebookAuthProvider();
1937 * await linkWithPopup(result.user, provider);
1938 * ```
1939 *
1940 * @param user - The user.
1941 * @param provider - The provider to authenticate. The provider has to be an {@link OAuthProvider}.
1942 * Non-OAuth providers like {@link EmailAuthProvider} will throw an error.
1943 * @param resolver - An instance of {@link PopupRedirectResolver}, optional
1944 * if already supplied to {@link initializeAuth} or provided by {@link getAuth}.
1945 *
1946 * @public
1947 */
1948export declare function linkWithPopup(user: User, provider: AuthProvider, resolver?: PopupRedirectResolver): Promise<UserCredential>;
1949
1950/**
1951 * Links the {@link OAuthProvider} to the user account using a full-page redirect flow.
1952 *
1953 * @example
1954 * ```javascript
1955 * // Sign in using some other provider.
1956 * const result = await signInWithEmailAndPassword(auth, email, password);
1957 * // Link using a redirect.
1958 * const provider = new FacebookAuthProvider();
1959 * await linkWithRedirect(result.user, provider);
1960 * // This will trigger a full page redirect away from your app
1961 *
1962 * // After returning from the redirect when your app initializes you can obtain the result
1963 * const result = await getRedirectResult(auth);
1964 * ```
1965 *
1966 * @param user - The user.
1967 * @param provider - The provider to authenticate. The provider has to be an {@link OAuthProvider}.
1968 * Non-OAuth providers like {@link EmailAuthProvider} will throw an error.
1969 * @param resolver - An instance of {@link PopupRedirectResolver}, optional
1970 * if already supplied to {@link initializeAuth} or provided by {@link getAuth}.
1971 *
1972 *
1973 * @public
1974 */
1975export declare function linkWithRedirect(user: User, provider: AuthProvider, resolver?: PopupRedirectResolver): Promise<never>;
1976
1977/**
1978 * MfaEnrollment can be any subtype of BaseMfaEnrollment, currently only PhoneMfaEnrollment is supported
1979 */
1980declare type MfaEnrollment = PhoneMfaEnrollment;
1981
1982/**
1983 * The {@link MultiFactorUser} corresponding to the user.
1984 *
1985 * @remarks
1986 * This is used to access all multi-factor properties and operations related to the user.
1987 *
1988 * @param user - The user.
1989 *
1990 * @public
1991 */
1992export declare function multiFactor(user: User): MultiFactorUser;
1993
1994/**
1995 * The base class for asserting ownership of a second factor.
1996 *
1997 * @remarks
1998 * This is used to facilitate enrollment of a second factor on an existing user or sign-in of a
1999 * user who already verified the first factor.
2000 *
2001 * @public
2002 */
2003export declare interface MultiFactorAssertion {
2004 /** The identifier of the second factor. */
2005 readonly factorId: typeof FactorId[keyof typeof FactorId];
2006}
2007
2008/**
2009 * The error thrown when the user needs to provide a second factor to sign in successfully.
2010 *
2011 * @remarks
2012 * The error code for this error is `auth/multi-factor-auth-required`.
2013 *
2014 * @example
2015 * ```javascript
2016 * let resolver;
2017 * let multiFactorHints;
2018 *
2019 * signInWithEmailAndPassword(auth, email, password)
2020 * .then((result) => {
2021 * // User signed in. No 2nd factor challenge is needed.
2022 * })
2023 * .catch((error) => {
2024 * if (error.code == 'auth/multi-factor-auth-required') {
2025 * resolver = getMultiFactorResolver(auth, error);
2026 * multiFactorHints = resolver.hints;
2027 * } else {
2028 * // Handle other errors.
2029 * }
2030 * });
2031 *
2032 * // Obtain a multiFactorAssertion by verifying the second factor.
2033 *
2034 * const userCredential = await resolver.resolveSignIn(multiFactorAssertion);
2035 * ```
2036 *
2037 * @public
2038 */
2039export declare interface MultiFactorError extends AuthError {
2040 /** Details about the MultiFactorError. */
2041 readonly customData: AuthError['customData'] & {
2042 /**
2043 * The type of operation (sign-in, linking, or re-authentication) that raised the error.
2044 */
2045 readonly operationType: typeof OperationType[keyof typeof OperationType];
2046 };
2047}
2048
2049/**
2050 * A structure containing the information of a second factor entity.
2051 *
2052 * @public
2053 */
2054export declare interface MultiFactorInfo {
2055 /** The multi-factor enrollment ID. */
2056 readonly uid: string;
2057 /** The user friendly name of the current second factor. */
2058 readonly displayName?: string | null;
2059 /** The enrollment date of the second factor formatted as a UTC string. */
2060 readonly enrollmentTime: string;
2061 /** The identifier of the second factor. */
2062 readonly factorId: typeof FactorId[keyof typeof FactorId];
2063}
2064
2065/**
2066 * The class used to facilitate recovery from {@link MultiFactorError} when a user needs to
2067 * provide a second factor to sign in.
2068 *
2069 * @example
2070 * ```javascript
2071 * let resolver;
2072 * let multiFactorHints;
2073 *
2074 * signInWithEmailAndPassword(auth, email, password)
2075 * .then((result) => {
2076 * // User signed in. No 2nd factor challenge is needed.
2077 * })
2078 * .catch((error) => {
2079 * if (error.code == 'auth/multi-factor-auth-required') {
2080 * resolver = getMultiFactorResolver(auth, error);
2081 * // Show UI to let user select second factor.
2082 * multiFactorHints = resolver.hints;
2083 * } else {
2084 * // Handle other errors.
2085 * }
2086 * });
2087 *
2088 * // The enrolled second factors that can be used to complete
2089 * // sign-in are returned in the `MultiFactorResolver.hints` list.
2090 * // UI needs to be presented to allow the user to select a second factor
2091 * // from that list.
2092 *
2093 * const selectedHint = // ; selected from multiFactorHints
2094 * const phoneAuthProvider = new PhoneAuthProvider(auth);
2095 * const phoneInfoOptions = {
2096 * multiFactorHint: selectedHint,
2097 * session: resolver.session
2098 * };
2099 * const verificationId = phoneAuthProvider.verifyPhoneNumber(phoneInfoOptions, appVerifier);
2100 * // Store `verificationId` and show UI to let user enter verification code.
2101 *
2102 * // UI to enter verification code and continue.
2103 * // Continue button click handler
2104 * const phoneAuthCredential = PhoneAuthProvider.credential(verificationId, verificationCode);
2105 * const multiFactorAssertion = PhoneMultiFactorGenerator.assertion(phoneAuthCredential);
2106 * const userCredential = await resolver.resolveSignIn(multiFactorAssertion);
2107 * ```
2108 *
2109 * @public
2110 */
2111export declare interface MultiFactorResolver {
2112 /**
2113 * The list of hints for the second factors needed to complete the sign-in for the current
2114 * session.
2115 */
2116 readonly hints: MultiFactorInfo[];
2117 /**
2118 * The session identifier for the current sign-in flow, which can be used to complete the second
2119 * factor sign-in.
2120 */
2121 readonly session: MultiFactorSession;
2122 /**
2123 * A helper function to help users complete sign in with a second factor using an
2124 * {@link MultiFactorAssertion} confirming the user successfully completed the second factor
2125 * challenge.
2126 *
2127 * @example
2128 * ```javascript
2129 * const phoneAuthCredential = PhoneAuthProvider.credential(verificationId, verificationCode);
2130 * const multiFactorAssertion = PhoneMultiFactorGenerator.assertion(phoneAuthCredential);
2131 * const userCredential = await resolver.resolveSignIn(multiFactorAssertion);
2132 * ```
2133 *
2134 * @param assertion - The multi-factor assertion to resolve sign-in with.
2135 * @returns The promise that resolves with the user credential object.
2136 */
2137 resolveSignIn(assertion: MultiFactorAssertion): Promise<UserCredential>;
2138}
2139
2140/**
2141 * An interface defining the multi-factor session object used for enrolling a second factor on a
2142 * user or helping sign in an enrolled user with a second factor.
2143 *
2144 * @public
2145 */
2146export declare interface MultiFactorSession {
2147}
2148
2149/**
2150 * An interface that defines the multi-factor related properties and operations pertaining
2151 * to a {@link User}.
2152 *
2153 * @public
2154 */
2155export declare interface MultiFactorUser {
2156 /** Returns a list of the user's enrolled second factors. */
2157 readonly enrolledFactors: MultiFactorInfo[];
2158 /**
2159 * Returns the session identifier for a second factor enrollment operation. This is used to
2160 * identify the user trying to enroll a second factor.
2161 *
2162 * @example
2163 * ```javascript
2164 * const multiFactorUser = multiFactor(auth.currentUser);
2165 * const multiFactorSession = await multiFactorUser.getSession();
2166 *
2167 * // Send verification code.
2168 * const phoneAuthProvider = new PhoneAuthProvider(auth);
2169 * const phoneInfoOptions = {
2170 * phoneNumber: phoneNumber,
2171 * session: multiFactorSession
2172 * };
2173 * const verificationId = await phoneAuthProvider.verifyPhoneNumber(phoneInfoOptions, appVerifier);
2174 *
2175 * // Obtain verification code from user.
2176 * const phoneAuthCredential = PhoneAuthProvider.credential(verificationId, verificationCode);
2177 * const multiFactorAssertion = PhoneMultiFactorGenerator.assertion(phoneAuthCredential);
2178 * await multiFactorUser.enroll(multiFactorAssertion);
2179 * ```
2180 *
2181 * @returns The promise that resolves with the {@link MultiFactorSession}.
2182 */
2183 getSession(): Promise<MultiFactorSession>;
2184 /**
2185 *
2186 * Enrolls a second factor as identified by the {@link MultiFactorAssertion} for the
2187 * user.
2188 *
2189 * @remarks
2190 * On resolution, the user tokens are updated to reflect the change in the JWT payload.
2191 * Accepts an additional display name parameter used to identify the second factor to the end
2192 * user. Recent re-authentication is required for this operation to succeed. On successful
2193 * enrollment, existing Firebase sessions (refresh tokens) are revoked. When a new factor is
2194 * enrolled, an email notification is sent to the user’s email.
2195 *
2196 * @example
2197 * ```javascript
2198 * const multiFactorUser = multiFactor(auth.currentUser);
2199 * const multiFactorSession = await multiFactorUser.getSession();
2200 *
2201 * // Send verification code.
2202 * const phoneAuthProvider = new PhoneAuthProvider(auth);
2203 * const phoneInfoOptions = {
2204 * phoneNumber: phoneNumber,
2205 * session: multiFactorSession
2206 * };
2207 * const verificationId = await phoneAuthProvider.verifyPhoneNumber(phoneInfoOptions, appVerifier);
2208 *
2209 * // Obtain verification code from user.
2210 * const phoneAuthCredential = PhoneAuthProvider.credential(verificationId, verificationCode);
2211 * const multiFactorAssertion = PhoneMultiFactorGenerator.assertion(phoneAuthCredential);
2212 * await multiFactorUser.enroll(multiFactorAssertion);
2213 * // Second factor enrolled.
2214 * ```
2215 *
2216 * @param assertion - The multi-factor assertion to enroll with.
2217 * @param displayName - The display name of the second factor.
2218 */
2219 enroll(assertion: MultiFactorAssertion, displayName?: string | null): Promise<void>;
2220 /**
2221 * Unenrolls the specified second factor.
2222 *
2223 * @remarks
2224 * To specify the factor to remove, pass a {@link MultiFactorInfo} object (retrieved from
2225 * {@link MultiFactorUser.enrolledFactors}) or the
2226 * factor's UID string. Sessions are not revoked when the account is unenrolled. An email
2227 * notification is likely to be sent to the user notifying them of the change. Recent
2228 * re-authentication is required for this operation to succeed. When an existing factor is
2229 * unenrolled, an email notification is sent to the user’s email.
2230 *
2231 * @example
2232 * ```javascript
2233 * const multiFactorUser = multiFactor(auth.currentUser);
2234 * // Present user the option to choose which factor to unenroll.
2235 * await multiFactorUser.unenroll(multiFactorUser.enrolledFactors[i])
2236 * ```
2237 *
2238 * @param option - The multi-factor option to unenroll.
2239 * @returns - A `Promise` which resolves when the unenroll operation is complete.
2240 */
2241 unenroll(option: MultiFactorInfo | string): Promise<void>;
2242}
2243
2244declare type MutableUserInfo = {
2245 -readonly [K in keyof UserInfo]: UserInfo[K];
2246};
2247export { NextFn }
2248
2249/**
2250 * Type definition for an event callback.
2251 *
2252 * @privateRemarks TODO(avolkovi): should we consolidate with Subscribe<T> since we're changing the API anyway?
2253 *
2254 * @public
2255 */
2256export declare type NextOrObserver<T> = NextFn<T | null> | Observer<T | null>;
2257
2258/**
2259 * Represents the OAuth credentials returned by an {@link OAuthProvider}.
2260 *
2261 * @remarks
2262 * Implementations specify the details about each auth provider's credential requirements.
2263 *
2264 * @public
2265 */
2266export declare class OAuthCredential extends AuthCredential {
2267 /**
2268 * The OAuth ID token associated with the credential if it belongs to an OIDC provider,
2269 * such as `google.com`.
2270 * @readonly
2271 */
2272 idToken?: string;
2273 /**
2274 * The OAuth access token associated with the credential if it belongs to an
2275 * {@link OAuthProvider}, such as `facebook.com`, `twitter.com`, etc.
2276 * @readonly
2277 */
2278 accessToken?: string;
2279 /**
2280 * The OAuth access token secret associated with the credential if it belongs to an OAuth 1.0
2281 * provider, such as `twitter.com`.
2282 * @readonly
2283 */
2284 secret?: string;
2285 private nonce?;
2286 private pendingToken;
2287 /** @internal */
2288 static _fromParams(params: OAuthCredentialParams): OAuthCredential;
2289 /** {@inheritdoc AuthCredential.toJSON} */
2290 toJSON(): object;
2291 /**
2292 * Static method to deserialize a JSON representation of an object into an
2293 * {@link AuthCredential}.
2294 *
2295 * @param json - Input can be either Object or the stringified representation of the object.
2296 * When string is provided, JSON.parse would be called first.
2297 *
2298 * @returns If the JSON input does not represent an {@link AuthCredential}, null is returned.
2299 */
2300 static fromJSON(json: string | object): OAuthCredential | null;
2301 /** @internal */
2302 _getIdTokenResponse(auth: AuthInternal): Promise<IdTokenResponse>;
2303 /** @internal */
2304 _linkToIdToken(auth: AuthInternal, idToken: string): Promise<IdTokenResponse>;
2305 /** @internal */
2306 _getReauthenticationResolver(auth: AuthInternal): Promise<IdTokenResponse>;
2307 private buildRequest;
2308}
2309
2310/**
2311 * Defines the options for initializing an {@link OAuthCredential}.
2312 *
2313 * @remarks
2314 * For ID tokens with nonce claim, the raw nonce has to also be provided.
2315 *
2316 * @public
2317 */
2318export declare interface OAuthCredentialOptions {
2319 /**
2320 * The OAuth ID token used to initialize the {@link OAuthCredential}.
2321 */
2322 idToken?: string;
2323 /**
2324 * The OAuth access token used to initialize the {@link OAuthCredential}.
2325 */
2326 accessToken?: string;
2327 /**
2328 * The raw nonce associated with the ID token.
2329 *
2330 * @remarks
2331 * It is required when an ID token with a nonce field is provided. The SHA-256 hash of the
2332 * raw nonce must match the nonce field in the ID token.
2333 */
2334 rawNonce?: string;
2335}
2336
2337declare interface OAuthCredentialParams {
2338 idToken?: string | null;
2339 accessToken?: string | null;
2340 oauthToken?: string;
2341 secret?: string;
2342 oauthTokenSecret?: string;
2343 nonce?: string;
2344 pendingToken?: string;
2345 providerId: string;
2346 signInMethod: string;
2347}
2348
2349/**
2350 * Provider for generating generic {@link OAuthCredential}.
2351 *
2352 * @example
2353 * ```javascript
2354 * // Sign in using a redirect.
2355 * const provider = new OAuthProvider('google.com');
2356 * // Start a sign in process for an unauthenticated user.
2357 * provider.addScope('profile');
2358 * provider.addScope('email');
2359 * await signInWithRedirect(auth, provider);
2360 * // This will trigger a full page redirect away from your app
2361 *
2362 * // After returning from the redirect when your app initializes you can obtain the result
2363 * const result = await getRedirectResult(auth);
2364 * if (result) {
2365 * // This is the signed-in user
2366 * const user = result.user;
2367 * // This gives you a OAuth Access Token for the provider.
2368 * const credential = provider.credentialFromResult(auth, result);
2369 * const token = credential.accessToken;
2370 * }
2371 * ```
2372 *
2373 * @example
2374 * ```javascript
2375 * // Sign in using a popup.
2376 * const provider = new OAuthProvider('google.com');
2377 * provider.addScope('profile');
2378 * provider.addScope('email');
2379 * const result = await signInWithPopup(auth, provider);
2380 *
2381 * // The signed-in user info.
2382 * const user = result.user;
2383 * // This gives you a OAuth Access Token for the provider.
2384 * const credential = provider.credentialFromResult(auth, result);
2385 * const token = credential.accessToken;
2386 * ```
2387 * @public
2388 */
2389export declare class OAuthProvider extends BaseOAuthProvider {
2390 /**
2391 * Creates an {@link OAuthCredential} from a JSON string or a plain object.
2392 * @param json - A plain object or a JSON string
2393 */
2394 static credentialFromJSON(json: object | string): OAuthCredential;
2395 /**
2396 * Creates a {@link OAuthCredential} from a generic OAuth provider's access token or ID token.
2397 *
2398 * @remarks
2399 * The raw nonce is required when an ID token with a nonce field is provided. The SHA-256 hash of
2400 * the raw nonce must match the nonce field in the ID token.
2401 *
2402 * @example
2403 * ```javascript
2404 * // `googleUser` from the onsuccess Google Sign In callback.
2405 * // Initialize a generate OAuth provider with a `google.com` providerId.
2406 * const provider = new OAuthProvider('google.com');
2407 * const credential = provider.credential({
2408 * idToken: googleUser.getAuthResponse().id_token,
2409 * });
2410 * const result = await signInWithCredential(credential);
2411 * ```
2412 *
2413 * @param params - Either the options object containing the ID token, access token and raw nonce
2414 * or the ID token string.
2415 */
2416 credential(params: OAuthCredentialOptions): OAuthCredential;
2417 /** An internal credential method that accepts more permissive options */
2418 private _credential;
2419 /**
2420 * Used to extract the underlying {@link OAuthCredential} from a {@link UserCredential}.
2421 *
2422 * @param userCredential - The user credential.
2423 */
2424 static credentialFromResult(userCredential: UserCredential): OAuthCredential | null;
2425 /**
2426 * Used to extract the underlying {@link OAuthCredential} from a {@link AuthError} which was
2427 * thrown during a sign-in, link, or reauthenticate operation.
2428 *
2429 * @param userCredential - The user credential.
2430 */
2431 static credentialFromError(error: FirebaseError): OAuthCredential | null;
2432 private static oauthCredentialFromTaggedObject;
2433}
2434
2435/**
2436 * Adds an observer for changes to the user's sign-in state.
2437 *
2438 * @remarks
2439 * To keep the old behavior, see {@link onIdTokenChanged}.
2440 *
2441 * @param auth - The {@link Auth} instance.
2442 * @param nextOrObserver - callback triggered on change.
2443 * @param error - Deprecated. This callback is never triggered. Errors
2444 * on signing in/out can be caught in promises returned from
2445 * sign-in/sign-out functions.
2446 * @param completed - Deprecated. This callback is never triggered.
2447 *
2448 * @public
2449 */
2450export declare function onAuthStateChanged(auth: Auth, nextOrObserver: NextOrObserver<User>, error?: ErrorFn, completed?: CompleteFn): Unsubscribe;
2451
2452/**
2453 * Adds an observer for changes to the signed-in user's ID token.
2454 *
2455 * @remarks
2456 * This includes sign-in, sign-out, and token refresh events.
2457 *
2458 * @param auth - The {@link Auth} instance.
2459 * @param nextOrObserver - callback triggered on change.
2460 * @param error - Deprecated. This callback is never triggered. Errors
2461 * on signing in/out can be caught in promises returned from
2462 * sign-in/sign-out functions.
2463 * @param completed - Deprecated. This callback is never triggered.
2464 *
2465 * @public
2466 */
2467export declare function onIdTokenChanged(auth: Auth, nextOrObserver: NextOrObserver<User>, error?: ErrorFn, completed?: CompleteFn): Unsubscribe;
2468
2469/**
2470 * Enumeration of supported operation types.
2471 *
2472 * @public
2473 */
2474export declare const OperationType: {
2475 /** Operation involving linking an additional provider to an already signed-in user. */
2476 readonly LINK: "link";
2477 /** Operation involving using a provider to reauthenticate an already signed-in user. */
2478 readonly REAUTHENTICATE: "reauthenticate";
2479 /** Operation involving signing in a user. */
2480 readonly SIGN_IN: "signIn";
2481};
2482
2483/**
2484 * Parses the email action link string and returns an {@link ActionCodeURL} if
2485 * the link is valid, otherwise returns null.
2486 *
2487 * @public
2488 */
2489export declare function parseActionCodeURL(link: string): ActionCodeURL | null;
2490
2491/**
2492 * Interface representing a parsed ID token.
2493 *
2494 * @privateRemarks TODO(avolkovi): consolidate with parsed_token in implementation.
2495 *
2496 * @public
2497 */
2498export declare interface ParsedToken {
2499 /** Expiration time of the token. */
2500 'exp'?: string;
2501 /** UID of the user. */
2502 'sub'?: string;
2503 /** Time at which authentication was performed. */
2504 'auth_time'?: string;
2505 /** Issuance time of the token. */
2506 'iat'?: string;
2507 /** Firebase specific claims, containing the provider(s) used to authenticate the user. */
2508 'firebase'?: {
2509 'sign_in_provider'?: string;
2510 'sign_in_second_factor'?: string;
2511 'identities'?: Record<string, string>;
2512 };
2513 /** Map of any additional custom claims. */
2514 [key: string]: string | object | undefined;
2515}
2516
2517declare type PersistedBlob = Record<string, unknown>;
2518
2519/**
2520 * An interface covering the possible persistence mechanism types.
2521 *
2522 * @public
2523 */
2524export declare interface Persistence {
2525 /**
2526 * Type of Persistence.
2527 * - 'SESSION' is used for temporary persistence such as `sessionStorage`.
2528 * - 'LOCAL' is used for long term persistence such as `localStorage` or `IndexedDB`.
2529 * - 'NONE' is used for in-memory, or no persistence.
2530 */
2531 readonly type: 'SESSION' | 'LOCAL' | 'NONE';
2532}
2533
2534/**
2535 * Represents the credentials returned by {@link PhoneAuthProvider}.
2536 *
2537 * @public
2538 */
2539export declare class PhoneAuthCredential extends AuthCredential {
2540 private readonly params;
2541 private constructor();
2542 /** @internal */
2543 static _fromVerification(verificationId: string, verificationCode: string): PhoneAuthCredential;
2544 /** @internal */
2545 static _fromTokenResponse(phoneNumber: string, temporaryProof: string): PhoneAuthCredential;
2546 /** @internal */
2547 _getIdTokenResponse(auth: AuthInternal): Promise<PhoneOrOauthTokenResponse>;
2548 /** @internal */
2549 _linkToIdToken(auth: AuthInternal, idToken: string): Promise<IdTokenResponse>;
2550 /** @internal */
2551 _getReauthenticationResolver(auth: AuthInternal): Promise<IdTokenResponse>;
2552 /** @internal */
2553 _makeVerificationRequest(): SignInWithPhoneNumberRequest;
2554 /** {@inheritdoc AuthCredential.toJSON} */
2555 toJSON(): object;
2556 /** Generates a phone credential based on a plain object or a JSON string. */
2557 static fromJSON(json: object | string): PhoneAuthCredential | null;
2558}
2559
2560/**
2561 * Provider for generating an {@link PhoneAuthCredential}.
2562 *
2563 * @example
2564 * ```javascript
2565 * // 'recaptcha-container' is the ID of an element in the DOM.
2566 * const applicationVerifier = new RecaptchaVerifier('recaptcha-container');
2567 * const provider = new PhoneAuthProvider(auth);
2568 * const verificationId = await provider.verifyPhoneNumber('+16505550101', applicationVerifier);
2569 * // Obtain the verificationCode from the user.
2570 * const phoneCredential = PhoneAuthProvider.credential(verificationId, verificationCode);
2571 * const userCredential = await signInWithCredential(auth, phoneCredential);
2572 * ```
2573 *
2574 * @public
2575 */
2576export declare class PhoneAuthProvider {
2577 /** Always set to {@link ProviderId}.PHONE. */
2578 static readonly PROVIDER_ID: 'phone';
2579 /** Always set to {@link SignInMethod}.PHONE. */
2580 static readonly PHONE_SIGN_IN_METHOD: 'phone';
2581 /** Always set to {@link ProviderId}.PHONE. */
2582 readonly providerId: "phone";
2583 private readonly auth;
2584 /**
2585 * @param auth - The Firebase {@link Auth} instance in which sign-ins should occur.
2586 *
2587 */
2588 constructor(auth: Auth);
2589 /**
2590 *
2591 * Starts a phone number authentication flow by sending a verification code to the given phone
2592 * number.
2593 *
2594 * @example
2595 * ```javascript
2596 * const provider = new PhoneAuthProvider(auth);
2597 * const verificationId = await provider.verifyPhoneNumber(phoneNumber, applicationVerifier);
2598 * // Obtain verificationCode from the user.
2599 * const authCredential = PhoneAuthProvider.credential(verificationId, verificationCode);
2600 * const userCredential = await signInWithCredential(auth, authCredential);
2601 * ```
2602 *
2603 * @example
2604 * An alternative flow is provided using the `signInWithPhoneNumber` method.
2605 * ```javascript
2606 * const confirmationResult = signInWithPhoneNumber(auth, phoneNumber, applicationVerifier);
2607 * // Obtain verificationCode from the user.
2608 * const userCredential = confirmationResult.confirm(verificationCode);
2609 * ```
2610 *
2611 * @param phoneInfoOptions - The user's {@link PhoneInfoOptions}. The phone number should be in
2612 * E.164 format (e.g. +16505550101).
2613 * @param applicationVerifier - For abuse prevention, this method also requires a
2614 * {@link ApplicationVerifier}. This SDK includes a reCAPTCHA-based implementation,
2615 * {@link RecaptchaVerifier}.
2616 *
2617 * @returns A Promise for a verification ID that can be passed to
2618 * {@link PhoneAuthProvider.credential} to identify this flow..
2619 */
2620 verifyPhoneNumber(phoneOptions: PhoneInfoOptions | string, applicationVerifier: ApplicationVerifier): Promise<string>;
2621 /**
2622 * Creates a phone auth credential, given the verification ID from
2623 * {@link PhoneAuthProvider.verifyPhoneNumber} and the code that was sent to the user's
2624 * mobile device.
2625 *
2626 * @example
2627 * ```javascript
2628 * const provider = new PhoneAuthProvider(auth);
2629 * const verificationId = provider.verifyPhoneNumber(phoneNumber, applicationVerifier);
2630 * // Obtain verificationCode from the user.
2631 * const authCredential = PhoneAuthProvider.credential(verificationId, verificationCode);
2632 * const userCredential = signInWithCredential(auth, authCredential);
2633 * ```
2634 *
2635 * @example
2636 * An alternative flow is provided using the `signInWithPhoneNumber` method.
2637 * ```javascript
2638 * const confirmationResult = await signInWithPhoneNumber(auth, phoneNumber, applicationVerifier);
2639 * // Obtain verificationCode from the user.
2640 * const userCredential = await confirmationResult.confirm(verificationCode);
2641 * ```
2642 *
2643 * @param verificationId - The verification ID returned from {@link PhoneAuthProvider.verifyPhoneNumber}.
2644 * @param verificationCode - The verification code sent to the user's mobile device.
2645 *
2646 * @returns The auth provider credential.
2647 */
2648 static credential(verificationId: string, verificationCode: string): PhoneAuthCredential;
2649 /**
2650 * Generates an {@link AuthCredential} from a {@link UserCredential}.
2651 * @param userCredential - The user credential.
2652 */
2653 static credentialFromResult(userCredential: UserCredential): AuthCredential | null;
2654 /**
2655 * Returns an {@link AuthCredential} when passed an error.
2656 *
2657 * @remarks
2658 *
2659 * This method works for errors like
2660 * `auth/account-exists-with-different-credentials`. This is useful for
2661 * recovering when attempting to set a user's phone number but the number
2662 * in question is already tied to another account. For example, the following
2663 * code tries to update the current user's phone number, and if that
2664 * fails, links the user with the account associated with that number:
2665 *
2666 * ```js
2667 * const provider = new PhoneAuthProvider(auth);
2668 * const verificationId = await provider.verifyPhoneNumber(number, verifier);
2669 * try {
2670 * const code = ''; // Prompt the user for the verification code
2671 * await updatePhoneNumber(
2672 * auth.currentUser,
2673 * PhoneAuthProvider.credential(verificationId, code));
2674 * } catch (e) {
2675 * if ((e as FirebaseError)?.code === 'auth/account-exists-with-different-credential') {
2676 * const cred = PhoneAuthProvider.credentialFromError(e);
2677 * await linkWithCredential(auth.currentUser, cred);
2678 * }
2679 * }
2680 *
2681 * // At this point, auth.currentUser.phoneNumber === number.
2682 * ```
2683 *
2684 * @param error - The error to generate a credential from.
2685 */
2686 static credentialFromError(error: FirebaseError): AuthCredential | null;
2687 private static credentialFromTaggedObject;
2688}
2689
2690/**
2691 * The information required to verify the ownership of a phone number.
2692 *
2693 * @remarks
2694 * The information that's required depends on whether you are doing single-factor sign-in,
2695 * multi-factor enrollment or multi-factor sign-in.
2696 *
2697 * @public
2698 */
2699export declare type PhoneInfoOptions = PhoneSingleFactorInfoOptions | PhoneMultiFactorEnrollInfoOptions | PhoneMultiFactorSignInInfoOptions;
2700
2701/**
2702 * An MFA provided by SMS verification
2703 */
2704declare interface PhoneMfaEnrollment extends BaseMfaEnrollment {
2705 phoneInfo: string;
2706}
2707
2708/**
2709 * The class for asserting ownership of a phone second factor. Provided by
2710 * {@link PhoneMultiFactorGenerator.assertion}.
2711 *
2712 * @public
2713 */
2714export declare interface PhoneMultiFactorAssertion extends MultiFactorAssertion {
2715}
2716
2717/**
2718 * Options used for enrolling a second factor.
2719 *
2720 * @public
2721 */
2722export declare interface PhoneMultiFactorEnrollInfoOptions {
2723 /** Phone number to send a verification code to. */
2724 phoneNumber: string;
2725 /** The {@link MultiFactorSession} obtained via {@link MultiFactorUser.getSession}. */
2726 session: MultiFactorSession;
2727}
2728
2729/**
2730 * Provider for generating a {@link PhoneMultiFactorAssertion}.
2731 *
2732 * @public
2733 */
2734export declare class PhoneMultiFactorGenerator {
2735 private constructor();
2736 /**
2737 * Provides a {@link PhoneMultiFactorAssertion} to confirm ownership of the phone second factor.
2738 *
2739 * @param phoneAuthCredential - A credential provided by {@link PhoneAuthProvider.credential}.
2740 * @returns A {@link PhoneMultiFactorAssertion} which can be used with
2741 * {@link MultiFactorResolver.resolveSignIn}
2742 */
2743 static assertion(credential: PhoneAuthCredential): PhoneMultiFactorAssertion;
2744 /**
2745 * The identifier of the phone second factor: `phone`.
2746 */
2747 static FACTOR_ID: string;
2748}
2749
2750/**
2751 * The subclass of the {@link MultiFactorInfo} interface for phone number
2752 * second factors. The `factorId` of this second factor is {@link FactorId}.PHONE.
2753 * @public
2754 */
2755export declare interface PhoneMultiFactorInfo extends MultiFactorInfo {
2756 /** The phone number associated with the current second factor. */
2757 readonly phoneNumber: string;
2758}
2759
2760/**
2761 * Options used for signing in with a second factor.
2762 *
2763 * @public
2764 */
2765export declare interface PhoneMultiFactorSignInInfoOptions {
2766 /**
2767 * The {@link MultiFactorInfo} obtained via {@link MultiFactorResolver.hints}.
2768 *
2769 * One of `multiFactorHint` or `multiFactorUid` is required.
2770 */
2771 multiFactorHint?: MultiFactorInfo;
2772 /**
2773 * The uid of the second factor.
2774 *
2775 * One of `multiFactorHint` or `multiFactorUid` is required.
2776 */
2777 multiFactorUid?: string;
2778 /** The {@link MultiFactorSession} obtained via {@link MultiFactorResolver.session}. */
2779 session: MultiFactorSession;
2780}
2781
2782/**
2783 * @internal
2784 */
2785declare type PhoneOrOauthTokenResponse = SignInWithPhoneNumberResponse | SignInWithIdpResponse | IdTokenResponse;
2786
2787/**
2788 * Options used for single-factor sign-in.
2789 *
2790 * @public
2791 */
2792export declare interface PhoneSingleFactorInfoOptions {
2793 /** Phone number to send a verification code to. */
2794 phoneNumber: string;
2795}
2796
2797/**
2798 * A resolver used for handling DOM specific operations like {@link signInWithPopup}
2799 * or {@link signInWithRedirect}.
2800 *
2801 * @public
2802 */
2803export declare interface PopupRedirectResolver {
2804}
2805
2806/**
2807 * We need to mark this interface as internal explicitly to exclude it in the public typings, because
2808 * it references AuthInternal which has a circular dependency with UserInternal.
2809 *
2810 * @internal
2811 */
2812declare interface PopupRedirectResolverInternal extends PopupRedirectResolver {
2813 _shouldInitProactively: boolean;
2814 _initialize(auth: AuthInternal): Promise<EventManager>;
2815 _openPopup(auth: AuthInternal, provider: AuthProvider, authType: AuthEventType, eventId?: string): Promise<AuthPopup>;
2816 _openRedirect(auth: AuthInternal, provider: AuthProvider, authType: AuthEventType, eventId?: string): Promise<void | never>;
2817 _isIframeWebStorageSupported(auth: AuthInternal, cb: (support: boolean) => unknown): void;
2818 _redirectPersistence: Persistence;
2819 _originValidation(auth: Auth): Promise<void>;
2820 _completeRedirectFn: (auth: Auth, resolver: PopupRedirectResolver, bypassAuthState: boolean) => Promise<UserCredential | null>;
2821 _overrideRedirectResult: (auth: AuthInternal, resultGetter: () => Promise<UserCredentialInternal | null>) => void;
2822}
2823
2824/**
2825 * A minimal error map with all verbose error messages stripped.
2826 *
2827 * See discussion at {@link AuthErrorMap}
2828 *
2829 * @public
2830 */
2831export declare const prodErrorMap: AuthErrorMap;
2832
2833/**
2834 * Enumeration of supported providers.
2835 *
2836 * @public
2837 */
2838export declare const ProviderId: {
2839 /** Facebook provider ID */
2840 readonly FACEBOOK: "facebook.com";
2841 /** GitHub provider ID */
2842 readonly GITHUB: "github.com";
2843 /** Google provider ID */
2844 readonly GOOGLE: "google.com";
2845 /** Password provider */
2846 readonly PASSWORD: "password";
2847 /** Phone provider */
2848 readonly PHONE: "phone";
2849 /** Twitter provider ID */
2850 readonly TWITTER: "twitter.com";
2851};
2852
2853/**
2854 * @license
2855 * Copyright 2021 Google LLC
2856 *
2857 * Licensed under the Apache License, Version 2.0 (the "License");
2858 * you may not use this file except in compliance with the License.
2859 * You may obtain a copy of the License at
2860 *
2861 * http://www.apache.org/licenses/LICENSE-2.0
2862 *
2863 * Unless required by applicable law or agreed to in writing, software
2864 * distributed under the License is distributed on an "AS IS" BASIS,
2865 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2866 * See the License for the specific language governing permissions and
2867 * limitations under the License.
2868 */
2869/**
2870 * Enumeration of supported providers.
2871 * @internal
2872 */
2873declare const enum ProviderId_2 {
2874 /** @internal */
2875 ANONYMOUS = "anonymous",
2876 /** @internal */
2877 CUSTOM = "custom",
2878 /** Facebook provider ID */
2879 FACEBOOK = "facebook.com",
2880 /** @internal */
2881 FIREBASE = "firebase",
2882 /** GitHub provider ID */
2883 GITHUB = "github.com",
2884 /** Google provider ID */
2885 GOOGLE = "google.com",
2886 /** Password provider */
2887 PASSWORD = "password",
2888 /** Phone provider */
2889 PHONE = "phone",
2890 /** Twitter provider ID */
2891 TWITTER = "twitter.com"
2892}
2893
2894declare interface ProviderUserInfo {
2895 providerId: string;
2896 rawId?: string;
2897 email?: string;
2898 displayName?: string;
2899 photoUrl?: string;
2900 phoneNumber?: string;
2901}
2902
2903/**
2904 * Interface for a supplied `AsyncStorage`.
2905 *
2906 * @public
2907 */
2908export declare interface ReactNativeAsyncStorage {
2909 /**
2910 * Persist an item in storage.
2911 *
2912 * @param key - storage key.
2913 * @param value - storage value.
2914 */
2915 setItem(key: string, value: string): Promise<void>;
2916 /**
2917 * Retrieve an item from storage.
2918 *
2919 * @param key - storage key.
2920 */
2921 getItem(key: string): Promise<string | null>;
2922 /**
2923 * Remove an item from storage.
2924 *
2925 * @param key - storage key.
2926 */
2927 removeItem(key: string): Promise<void>;
2928}
2929
2930/**
2931 * Re-authenticates a user using a fresh credential.
2932 *
2933 * @remarks
2934 * Use before operations such as {@link updatePassword} that require tokens from recent sign-in
2935 * attempts. This method can be used to recover from a `CREDENTIAL_TOO_OLD_LOGIN_AGAIN` error.
2936 *
2937 * @param user - The user.
2938 * @param credential - The auth credential.
2939 *
2940 * @public
2941 */
2942export declare function reauthenticateWithCredential(user: User, credential: AuthCredential): Promise<UserCredential>;
2943
2944/**
2945 * Re-authenticates a user using a fresh phone credential.
2946 *
2947 * @remarks Use before operations such as {@link updatePassword} that require tokens from recent sign-in attempts.
2948 *
2949 * @param user - The user.
2950 * @param phoneNumber - The user's phone number in E.164 format (e.g. +16505550101).
2951 * @param appVerifier - The {@link ApplicationVerifier}.
2952 *
2953 * @public
2954 */
2955export declare function reauthenticateWithPhoneNumber(user: User, phoneNumber: string, appVerifier: ApplicationVerifier): Promise<ConfirmationResult>;
2956
2957/**
2958 * Reauthenticates the current user with the specified {@link OAuthProvider} using a pop-up based
2959 * OAuth flow.
2960 *
2961 * @remarks
2962 * If the reauthentication is successful, the returned result will contain the user and the
2963 * provider's credential.
2964 *
2965 * @example
2966 * ```javascript
2967 * // Sign in using a popup.
2968 * const provider = new FacebookAuthProvider();
2969 * const result = await signInWithPopup(auth, provider);
2970 * // Reauthenticate using a popup.
2971 * await reauthenticateWithPopup(result.user, provider);
2972 * ```
2973 *
2974 * @param user - The user.
2975 * @param provider - The provider to authenticate. The provider has to be an {@link OAuthProvider}.
2976 * Non-OAuth providers like {@link EmailAuthProvider} will throw an error.
2977 * @param resolver - An instance of {@link PopupRedirectResolver}, optional
2978 * if already supplied to {@link initializeAuth} or provided by {@link getAuth}.
2979 *
2980 * @public
2981 */
2982export declare function reauthenticateWithPopup(user: User, provider: AuthProvider, resolver?: PopupRedirectResolver): Promise<UserCredential>;
2983
2984/**
2985 * Reauthenticates the current user with the specified {@link OAuthProvider} using a full-page redirect flow.
2986 *
2987 * @example
2988 * ```javascript
2989 * // Sign in using a redirect.
2990 * const provider = new FacebookAuthProvider();
2991 * const result = await signInWithRedirect(auth, provider);
2992 * // This will trigger a full page redirect away from your app
2993 *
2994 * // After returning from the redirect when your app initializes you can obtain the result
2995 * const result = await getRedirectResult(auth);
2996 * // Link using a redirect.
2997 * await linkWithRedirect(result.user, provider);
2998 * // This will again trigger a full page redirect away from your app
2999 *
3000 * // After returning from the redirect when your app initializes you can obtain the result
3001 * const result = await getRedirectResult(auth);
3002 * ```
3003 *
3004 * @param user - The user.
3005 * @param provider - The provider to authenticate. The provider has to be an {@link OAuthProvider}.
3006 * Non-OAuth providers like {@link EmailAuthProvider} will throw an error.
3007 * @param resolver - An instance of {@link PopupRedirectResolver}, optional
3008 * if already supplied to {@link initializeAuth} or provided by {@link getAuth}.
3009 *
3010 * @public
3011 */
3012export declare function reauthenticateWithRedirect(user: User, provider: AuthProvider, resolver?: PopupRedirectResolver): Promise<never>;
3013
3014declare interface Recaptcha {
3015 render: (container: HTMLElement, parameters: RecaptchaParameters) => number;
3016 getResponse: (id: number) => string;
3017 execute: (id: number) => unknown;
3018 reset: (id: number) => unknown;
3019}
3020
3021/**
3022 * We need to mark this interface as internal explicitly to exclude it in the public typings, because
3023 * it references AuthInternal which has a circular dependency with UserInternal.
3024 *
3025 * @internal
3026 */
3027declare interface ReCaptchaLoader {
3028 load(auth: AuthInternal, hl?: string): Promise<Recaptcha>;
3029 clearedOneInstance(): void;
3030}
3031
3032/**
3033 * Interface representing reCAPTCHA parameters.
3034 *
3035 * See the [reCAPTCHA docs](https://developers.google.com/recaptcha/docs/display#render_param)
3036 * for the list of accepted parameters. All parameters are accepted except for `sitekey`: Firebase Auth
3037 * provisions a reCAPTCHA for each project and will configure the site key upon rendering.
3038 *
3039 * For an invisible reCAPTCHA, set the `size` key to `invisible`.
3040 *
3041 * @public
3042 */
3043export declare interface RecaptchaParameters {
3044 [key: string]: any;
3045}
3046
3047/**
3048 * An {@link https://www.google.com/recaptcha/ | reCAPTCHA}-based application verifier.
3049 *
3050 * @public
3051 */
3052export declare class RecaptchaVerifier implements ApplicationVerifierInternal {
3053 private readonly parameters;
3054 /**
3055 * The application verifier type.
3056 *
3057 * @remarks
3058 * For a reCAPTCHA verifier, this is 'recaptcha'.
3059 */
3060 readonly type = "recaptcha";
3061 private destroyed;
3062 private widgetId;
3063 private readonly container;
3064 private readonly isInvisible;
3065 private readonly tokenChangeListeners;
3066 private renderPromise;
3067 private readonly auth;
3068 /** @internal */
3069 readonly _recaptchaLoader: ReCaptchaLoader;
3070 private recaptcha;
3071 /**
3072 *
3073 * @param containerOrId - The reCAPTCHA container parameter.
3074 *
3075 * @remarks
3076 * This has different meaning depending on whether the reCAPTCHA is hidden or visible. For a
3077 * visible reCAPTCHA the container must be empty. If a string is used, it has to correspond to
3078 * an element ID. The corresponding element must also must be in the DOM at the time of
3079 * initialization.
3080 *
3081 * @param parameters - The optional reCAPTCHA parameters.
3082 *
3083 * @remarks
3084 * Check the reCAPTCHA docs for a comprehensive list. All parameters are accepted except for
3085 * the sitekey. Firebase Auth backend provisions a reCAPTCHA for each project and will
3086 * configure this upon rendering. For an invisible reCAPTCHA, a size key must have the value
3087 * 'invisible'.
3088 *
3089 * @param authExtern - The corresponding Firebase {@link Auth} instance.
3090 *
3091 * @remarks
3092 * If none is provided, the default Firebase {@link Auth} instance is used. A Firebase {@link Auth} instance
3093 * must be initialized with an API key, otherwise an error will be thrown.
3094 */
3095 constructor(containerOrId: HTMLElement | string, parameters: RecaptchaParameters, authExtern: Auth);
3096 /**
3097 * Waits for the user to solve the reCAPTCHA and resolves with the reCAPTCHA token.
3098 *
3099 * @returns A Promise for the reCAPTCHA token.
3100 */
3101 verify(): Promise<string>;
3102 /**
3103 * Renders the reCAPTCHA widget on the page.
3104 *
3105 * @returns A Promise that resolves with the reCAPTCHA widget ID.
3106 */
3107 render(): Promise<number>;
3108 /** @internal */
3109 _reset(): void;
3110 /**
3111 * Clears the reCAPTCHA widget from the page and destroys the instance.
3112 */
3113 clear(): void;
3114 private validateStartingState;
3115 private makeTokenCallback;
3116 private assertNotDestroyed;
3117 private makeRenderPromise;
3118 private init;
3119 private getAssertedRecaptcha;
3120}
3121
3122/**
3123 * Reloads user account data, if signed in.
3124 *
3125 * @param user - The user.
3126 *
3127 * @public
3128 */
3129export declare function reload(user: User): Promise<void>;
3130
3131/**
3132 * An {@link AuthProvider} for SAML.
3133 *
3134 * @public
3135 */
3136export declare class SAMLAuthProvider extends FederatedAuthProvider {
3137 /**
3138 * Constructor. The providerId must start with "saml."
3139 * @param providerId - SAML provider ID.
3140 */
3141 constructor(providerId: string);
3142 /**
3143 * Generates an {@link AuthCredential} from a {@link UserCredential} after a
3144 * successful SAML flow completes.
3145 *
3146 * @remarks
3147 *
3148 * For example, to get an {@link AuthCredential}, you could write the
3149 * following code:
3150 *
3151 * ```js
3152 * const userCredential = await signInWithPopup(auth, samlProvider);
3153 * const credential = SAMLAuthProvider.credentialFromResult(userCredential);
3154 * ```
3155 *
3156 * @param userCredential - The user credential.
3157 */
3158 static credentialFromResult(userCredential: UserCredential): AuthCredential | null;
3159 /**
3160 * Used to extract the underlying {@link OAuthCredential} from a {@link AuthError} which was
3161 * thrown during a sign-in, link, or reauthenticate operation.
3162 *
3163 * @param userCredential - The user credential.
3164 */
3165 static credentialFromError(error: FirebaseError): AuthCredential | null;
3166 /**
3167 * Creates an {@link AuthCredential} from a JSON string or a plain object.
3168 * @param json - A plain object or a JSON string
3169 */
3170 static credentialFromJSON(json: string | object): AuthCredential;
3171 private static samlCredentialFromTaggedObject;
3172}
3173
3174/**
3175 * Sends a verification email to a user.
3176 *
3177 * @remarks
3178 * The verification process is completed by calling {@link applyActionCode}.
3179 *
3180 * @example
3181 * ```javascript
3182 * const actionCodeSettings = {
3183 * url: 'https://www.example.com/?email=user@example.com',
3184 * iOS: {
3185 * bundleId: 'com.example.ios'
3186 * },
3187 * android: {
3188 * packageName: 'com.example.android',
3189 * installApp: true,
3190 * minimumVersion: '12'
3191 * },
3192 * handleCodeInApp: true
3193 * };
3194 * await sendEmailVerification(user, actionCodeSettings);
3195 * // Obtain code from the user.
3196 * await applyActionCode(auth, code);
3197 * ```
3198 *
3199 * @param user - The user.
3200 * @param actionCodeSettings - The {@link ActionCodeSettings}.
3201 *
3202 * @public
3203 */
3204export declare function sendEmailVerification(user: User, actionCodeSettings?: ActionCodeSettings | null): Promise<void>;
3205
3206/**
3207 * Sends a password reset email to the given email address.
3208 *
3209 * @remarks
3210 * To complete the password reset, call {@link confirmPasswordReset} with the code supplied in
3211 * the email sent to the user, along with the new password specified by the user.
3212 *
3213 * @example
3214 * ```javascript
3215 * const actionCodeSettings = {
3216 * url: 'https://www.example.com/?email=user@example.com',
3217 * iOS: {
3218 * bundleId: 'com.example.ios'
3219 * },
3220 * android: {
3221 * packageName: 'com.example.android',
3222 * installApp: true,
3223 * minimumVersion: '12'
3224 * },
3225 * handleCodeInApp: true
3226 * };
3227 * await sendPasswordResetEmail(auth, 'user@example.com', actionCodeSettings);
3228 * // Obtain code from user.
3229 * await confirmPasswordReset('user@example.com', code);
3230 * ```
3231 *
3232 * @param auth - The {@link Auth} instance.
3233 * @param email - The user's email address.
3234 * @param actionCodeSettings - The {@link ActionCodeSettings}.
3235 *
3236 * @public
3237 */
3238export declare function sendPasswordResetEmail(auth: Auth, email: string, actionCodeSettings?: ActionCodeSettings): Promise<void>;
3239
3240/**
3241 * Sends a sign-in email link to the user with the specified email.
3242 *
3243 * @remarks
3244 * The sign-in operation has to always be completed in the app unlike other out of band email
3245 * actions (password reset and email verifications). This is because, at the end of the flow,
3246 * the user is expected to be signed in and their Auth state persisted within the app.
3247 *
3248 * To complete sign in with the email link, call {@link signInWithEmailLink} with the email
3249 * address and the email link supplied in the email sent to the user.
3250 *
3251 * @example
3252 * ```javascript
3253 * const actionCodeSettings = {
3254 * url: 'https://www.example.com/?email=user@example.com',
3255 * iOS: {
3256 * bundleId: 'com.example.ios'
3257 * },
3258 * android: {
3259 * packageName: 'com.example.android',
3260 * installApp: true,
3261 * minimumVersion: '12'
3262 * },
3263 * handleCodeInApp: true
3264 * };
3265 * await sendSignInLinkToEmail(auth, 'user@example.com', actionCodeSettings);
3266 * // Obtain emailLink from the user.
3267 * if(isSignInWithEmailLink(auth, emailLink)) {
3268 * await signInWithEmailLink(auth, 'user@example.com', emailLink);
3269 * }
3270 * ```
3271 *
3272 * @param authInternal - The {@link Auth} instance.
3273 * @param email - The user's email address.
3274 * @param actionCodeSettings - The {@link ActionCodeSettings}.
3275 *
3276 * @public
3277 */
3278export declare function sendSignInLinkToEmail(auth: Auth, email: string, actionCodeSettings: ActionCodeSettings): Promise<void>;
3279
3280/**
3281 * Changes the type of persistence on the {@link Auth} instance for the currently saved
3282 * `Auth` session and applies this type of persistence for future sign-in requests, including
3283 * sign-in with redirect requests.
3284 *
3285 * @remarks
3286 * This makes it easy for a user signing in to specify whether their session should be
3287 * remembered or not. It also makes it easier to never persist the `Auth` state for applications
3288 * that are shared by other users or have sensitive data.
3289 *
3290 * @example
3291 * ```javascript
3292 * setPersistence(auth, browserSessionPersistence);
3293 * ```
3294 *
3295 * @param auth - The {@link Auth} instance.
3296 * @param persistence - The {@link Persistence} to use.
3297 * @returns A `Promise` that resolves once the persistence change has completed
3298 *
3299 * @public
3300 */
3301export declare function setPersistence(auth: Auth, persistence: Persistence): Promise<void>;
3302
3303/**
3304 * Asynchronously signs in as an anonymous user.
3305 *
3306 * @remarks
3307 * If there is already an anonymous user signed in, that user will be returned; otherwise, a
3308 * new anonymous user identity will be created and returned.
3309 *
3310 * @param auth - The {@link Auth} instance.
3311 *
3312 * @public
3313 */
3314export declare function signInAnonymously(auth: Auth): Promise<UserCredential>;
3315
3316/**
3317 * Enumeration of supported sign-in methods.
3318 *
3319 * @public
3320 */
3321export declare const SignInMethod: {
3322 /** Email link sign in method */
3323 readonly EMAIL_LINK: "emailLink";
3324 /** Email/password sign in method */
3325 readonly EMAIL_PASSWORD: "password";
3326 /** Facebook sign in method */
3327 readonly FACEBOOK: "facebook.com";
3328 /** GitHub sign in method */
3329 readonly GITHUB: "github.com";
3330 /** Google sign in method */
3331 readonly GOOGLE: "google.com";
3332 /** Phone sign in method */
3333 readonly PHONE: "phone";
3334 /** Twitter sign in method */
3335 readonly TWITTER: "twitter.com";
3336};
3337
3338/**
3339 * Asynchronously signs in with the given credentials.
3340 *
3341 * @remarks
3342 * An {@link AuthProvider} can be used to generate the credential.
3343 *
3344 * @param auth - The {@link Auth} instance.
3345 * @param credential - The auth credential.
3346 *
3347 * @public
3348 */
3349export declare function signInWithCredential(auth: Auth, credential: AuthCredential): Promise<UserCredential>;
3350
3351/**
3352 * Asynchronously signs in using a custom token.
3353 *
3354 * @remarks
3355 * Custom tokens are used to integrate Firebase Auth with existing auth systems, and must
3356 * be generated by an auth backend using the
3357 * {@link https://firebase.google.com/docs/reference/admin/node/admin.auth.Auth#createcustomtoken | createCustomToken}
3358 * method in the {@link https://firebase.google.com/docs/auth/admin | Admin SDK} .
3359 *
3360 * Fails with an error if the token is invalid, expired, or not accepted by the Firebase Auth service.
3361 *
3362 * @param auth - The {@link Auth} instance.
3363 * @param customToken - The custom token to sign in with.
3364 *
3365 * @public
3366 */
3367export declare function signInWithCustomToken(auth: Auth, customToken: string): Promise<UserCredential>;
3368
3369/**
3370 * Asynchronously signs in using an email and password.
3371 *
3372 * @remarks
3373 * Fails with an error if the email address and password do not match.
3374 *
3375 * Note: The user's password is NOT the password used to access the user's email account. The
3376 * email address serves as a unique identifier for the user, and the password is used to access
3377 * the user's account in your Firebase project. See also: {@link createUserWithEmailAndPassword}.
3378 *
3379 * @param auth - The {@link Auth} instance.
3380 * @param email - The users email address.
3381 * @param password - The users password.
3382 *
3383 * @public
3384 */
3385export declare function signInWithEmailAndPassword(auth: Auth, email: string, password: string): Promise<UserCredential>;
3386
3387/**
3388 * Asynchronously signs in using an email and sign-in email link.
3389 *
3390 * @remarks
3391 * If no link is passed, the link is inferred from the current URL.
3392 *
3393 * Fails with an error if the email address is invalid or OTP in email link expires.
3394 *
3395 * Note: Confirm the link is a sign-in email link before calling this method firebase.auth.Auth.isSignInWithEmailLink.
3396 *
3397 * @example
3398 * ```javascript
3399 * const actionCodeSettings = {
3400 * url: 'https://www.example.com/?email=user@example.com',
3401 * iOS: {
3402 * bundleId: 'com.example.ios'
3403 * },
3404 * android: {
3405 * packageName: 'com.example.android',
3406 * installApp: true,
3407 * minimumVersion: '12'
3408 * },
3409 * handleCodeInApp: true
3410 * };
3411 * await sendSignInLinkToEmail(auth, 'user@example.com', actionCodeSettings);
3412 * // Obtain emailLink from the user.
3413 * if(isSignInWithEmailLink(auth, emailLink)) {
3414 * await signInWithEmailLink(auth, 'user@example.com', emailLink);
3415 * }
3416 * ```
3417 *
3418 * @param auth - The {@link Auth} instance.
3419 * @param email - The user's email address.
3420 * @param emailLink - The link sent to the user's email address.
3421 *
3422 * @public
3423 */
3424export declare function signInWithEmailLink(auth: Auth, email: string, emailLink?: string): Promise<UserCredential>;
3425
3426/**
3427 * @internal
3428 */
3429declare interface SignInWithIdpResponse extends IdTokenResponse {
3430 oauthAccessToken?: string;
3431 oauthTokenSecret?: string;
3432 nonce?: string;
3433 oauthIdToken?: string;
3434 pendingToken?: string;
3435}
3436
3437/**
3438 * Asynchronously signs in using a phone number.
3439 *
3440 * @remarks
3441 * This method sends a code via SMS to the given
3442 * phone number, and returns a {@link ConfirmationResult}. After the user
3443 * provides the code sent to their phone, call {@link ConfirmationResult.confirm}
3444 * with the code to sign the user in.
3445 *
3446 * For abuse prevention, this method also requires a {@link ApplicationVerifier}.
3447 * This SDK includes a reCAPTCHA-based implementation, {@link RecaptchaVerifier}.
3448 * This function can work on other platforms that do not support the
3449 * {@link RecaptchaVerifier} (like React Native), but you need to use a
3450 * third-party {@link ApplicationVerifier} implementation.
3451 *
3452 * @example
3453 * ```javascript
3454 * // 'recaptcha-container' is the ID of an element in the DOM.
3455 * const applicationVerifier = new firebase.auth.RecaptchaVerifier('recaptcha-container');
3456 * const confirmationResult = await signInWithPhoneNumber(auth, phoneNumber, applicationVerifier);
3457 * // Obtain a verificationCode from the user.
3458 * const credential = await confirmationResult.confirm(verificationCode);
3459 * ```
3460 *
3461 * @param auth - The {@link Auth} instance.
3462 * @param phoneNumber - The user's phone number in E.164 format (e.g. +16505550101).
3463 * @param appVerifier - The {@link ApplicationVerifier}.
3464 *
3465 * @public
3466 */
3467export declare function signInWithPhoneNumber(auth: Auth, phoneNumber: string, appVerifier: ApplicationVerifier): Promise<ConfirmationResult>;
3468
3469/**
3470 * @internal
3471 */
3472declare interface SignInWithPhoneNumberRequest {
3473 temporaryProof?: string;
3474 phoneNumber?: string;
3475 sessionInfo?: string;
3476 code?: string;
3477 tenantId?: string;
3478}
3479
3480/**
3481 * @internal
3482 */
3483declare interface SignInWithPhoneNumberResponse extends IdTokenResponse {
3484 temporaryProof?: string;
3485 phoneNumber?: string;
3486}
3487
3488/**
3489 * Authenticates a Firebase client using a popup-based OAuth authentication flow.
3490 *
3491 * @remarks
3492 * If succeeds, returns the signed in user along with the provider's credential. If sign in was
3493 * unsuccessful, returns an error object containing additional information about the error.
3494 *
3495 * @example
3496 * ```javascript
3497 * // Sign in using a popup.
3498 * const provider = new FacebookAuthProvider();
3499 * const result = await signInWithPopup(auth, provider);
3500 *
3501 * // The signed-in user info.
3502 * const user = result.user;
3503 * // This gives you a Facebook Access Token.
3504 * const credential = provider.credentialFromResult(auth, result);
3505 * const token = credential.accessToken;
3506 * ```
3507 *
3508 * @param auth - The {@link Auth} instance.
3509 * @param provider - The provider to authenticate. The provider has to be an {@link OAuthProvider}.
3510 * Non-OAuth providers like {@link EmailAuthProvider} will throw an error.
3511 * @param resolver - An instance of {@link PopupRedirectResolver}, optional
3512 * if already supplied to {@link initializeAuth} or provided by {@link getAuth}.
3513 *
3514 *
3515 * @public
3516 */
3517export declare function signInWithPopup(auth: Auth, provider: AuthProvider, resolver?: PopupRedirectResolver): Promise<UserCredential>;
3518
3519/**
3520 * Authenticates a Firebase client using a full-page redirect flow.
3521 *
3522 * @remarks
3523 * To handle the results and errors for this operation, refer to {@link getRedirectResult}.
3524 *
3525 * @example
3526 * ```javascript
3527 * // Sign in using a redirect.
3528 * const provider = new FacebookAuthProvider();
3529 * // You can add additional scopes to the provider:
3530 * provider.addScope('user_birthday');
3531 * // Start a sign in process for an unauthenticated user.
3532 * await signInWithRedirect(auth, provider);
3533 * // This will trigger a full page redirect away from your app
3534 *
3535 * // After returning from the redirect when your app initializes you can obtain the result
3536 * const result = await getRedirectResult(auth);
3537 * if (result) {
3538 * // This is the signed-in user
3539 * const user = result.user;
3540 * // This gives you a Facebook Access Token.
3541 * const credential = provider.credentialFromResult(auth, result);
3542 * const token = credential.accessToken;
3543 * }
3544 * // As this API can be used for sign-in, linking and reauthentication,
3545 * // check the operationType to determine what triggered this redirect
3546 * // operation.
3547 * const operationType = result.operationType;
3548 * ```
3549 *
3550 * @param auth - The {@link Auth} instance.
3551 * @param provider - The provider to authenticate. The provider has to be an {@link OAuthProvider}.
3552 * Non-OAuth providers like {@link EmailAuthProvider} will throw an error.
3553 * @param resolver - An instance of {@link PopupRedirectResolver}, optional
3554 * if already supplied to {@link initializeAuth} or provided by {@link getAuth}.
3555 *
3556 * @public
3557 */
3558export declare function signInWithRedirect(auth: Auth, provider: AuthProvider, resolver?: PopupRedirectResolver): Promise<never>;
3559
3560/**
3561 * Signs out the current user.
3562 *
3563 * @param auth - The {@link Auth} instance.
3564 *
3565 * @public
3566 */
3567export declare function signOut(auth: Auth): Promise<void>;
3568
3569/**
3570 * We need to mark this class as internal explicitly to exclude it in the public typings, because
3571 * it references AuthInternal which has a circular dependency with UserInternal.
3572 *
3573 * @internal
3574 */
3575declare class StsTokenManager {
3576 refreshToken: string | null;
3577 accessToken: string | null;
3578 expirationTime: number | null;
3579 get isExpired(): boolean;
3580 updateFromServerResponse(response: IdTokenResponse | FinalizeMfaResponse): void;
3581 getToken(auth: AuthInternal, forceRefresh?: boolean): Promise<string | null>;
3582 clearRefreshToken(): void;
3583 private refresh;
3584 private updateTokensAndExpiration;
3585 static fromJSON(appName: string, object: PersistedBlob): StsTokenManager;
3586 toJSON(): object;
3587 _assign(stsTokenManager: StsTokenManager): void;
3588 _clone(): StsTokenManager;
3589 _performRefresh(): never;
3590}
3591
3592/**
3593 * @internal
3594 */
3595declare interface TaggedWithTokenResponse {
3596 _tokenResponse?: PhoneOrOauthTokenResponse;
3597}
3598
3599/**
3600 * Provider for generating an {@link OAuthCredential} for {@link ProviderId}.TWITTER.
3601 *
3602 * @example
3603 * ```javascript
3604 * // Sign in using a redirect.
3605 * const provider = new TwitterAuthProvider();
3606 * // Start a sign in process for an unauthenticated user.
3607 * await signInWithRedirect(auth, provider);
3608 * // This will trigger a full page redirect away from your app
3609 *
3610 * // After returning from the redirect when your app initializes you can obtain the result
3611 * const result = await getRedirectResult(auth);
3612 * if (result) {
3613 * // This is the signed-in user
3614 * const user = result.user;
3615 * // This gives you a Twitter Access Token and Secret.
3616 * const credential = TwitterAuthProvider.credentialFromResult(result);
3617 * const token = credential.accessToken;
3618 * const secret = credential.secret;
3619 * }
3620 * ```
3621 *
3622 * @example
3623 * ```javascript
3624 * // Sign in using a popup.
3625 * const provider = new TwitterAuthProvider();
3626 * const result = await signInWithPopup(auth, provider);
3627 *
3628 * // The signed-in user info.
3629 * const user = result.user;
3630 * // This gives you a Twitter Access Token and Secret.
3631 * const credential = TwitterAuthProvider.credentialFromResult(result);
3632 * const token = credential.accessToken;
3633 * const secret = credential.secret;
3634 * ```
3635 *
3636 * @public
3637 */
3638export declare class TwitterAuthProvider extends BaseOAuthProvider {
3639 /** Always set to {@link SignInMethod}.TWITTER. */
3640 static readonly TWITTER_SIGN_IN_METHOD: 'twitter.com';
3641 /** Always set to {@link ProviderId}.TWITTER. */
3642 static readonly PROVIDER_ID: 'twitter.com';
3643 constructor();
3644 /**
3645 * Creates a credential for Twitter.
3646 *
3647 * @param token - Twitter access token.
3648 * @param secret - Twitter secret.
3649 */
3650 static credential(token: string, secret: string): OAuthCredential;
3651 /**
3652 * Used to extract the underlying {@link OAuthCredential} from a {@link UserCredential}.
3653 *
3654 * @param userCredential - The user credential.
3655 */
3656 static credentialFromResult(userCredential: UserCredential): OAuthCredential | null;
3657 /**
3658 * Used to extract the underlying {@link OAuthCredential} from a {@link AuthError} which was
3659 * thrown during a sign-in, link, or reauthenticate operation.
3660 *
3661 * @param userCredential - The user credential.
3662 */
3663 static credentialFromError(error: FirebaseError): OAuthCredential | null;
3664 private static credentialFromTaggedObject;
3665}
3666
3667/**
3668 * Unlinks a provider from a user account.
3669 *
3670 * @param user - The user.
3671 * @param providerId - The provider to unlink.
3672 *
3673 * @public
3674 */
3675export declare function unlink(user: User, providerId: string): Promise<User>;
3676export { Unsubscribe }
3677
3678/**
3679 * Asynchronously sets the provided user as {@link Auth.currentUser} on the
3680 * {@link Auth} instance.
3681 *
3682 * @remarks
3683 * A new instance copy of the user provided will be made and set as currentUser.
3684 *
3685 * This will trigger {@link onAuthStateChanged} and {@link onIdTokenChanged} listeners
3686 * like other sign in methods.
3687 *
3688 * The operation fails with an error if the user to be updated belongs to a different Firebase
3689 * project.
3690 *
3691 * @param auth - The {@link Auth} instance.
3692 * @param user - The new {@link User}.
3693 *
3694 * @public
3695 */
3696export declare function updateCurrentUser(auth: Auth, user: User | null): Promise<void>;
3697
3698/**
3699 * Updates the user's email address.
3700 *
3701 * @remarks
3702 * An email will be sent to the original email address (if it was set) that allows to revoke the
3703 * email address change, in order to protect them from account hijacking.
3704 *
3705 * Important: this is a security sensitive operation that requires the user to have recently signed
3706 * in. If this requirement isn't met, ask the user to authenticate again and then call
3707 * {@link reauthenticateWithCredential}.
3708 *
3709 * @param user - The user.
3710 * @param newEmail - The new email address.
3711 *
3712 * @public
3713 */
3714export declare function updateEmail(user: User, newEmail: string): Promise<void>;
3715
3716/**
3717 * Updates the user's password.
3718 *
3719 * @remarks
3720 * Important: this is a security sensitive operation that requires the user to have recently signed
3721 * in. If this requirement isn't met, ask the user to authenticate again and then call
3722 * {@link reauthenticateWithCredential}.
3723 *
3724 * @param user - The user.
3725 * @param newPassword - The new password.
3726 *
3727 * @public
3728 */
3729export declare function updatePassword(user: User, newPassword: string): Promise<void>;
3730
3731/**
3732 * Updates the user's phone number.
3733 *
3734 * @example
3735 * ```
3736 * // 'recaptcha-container' is the ID of an element in the DOM.
3737 * const applicationVerifier = new RecaptchaVerifier('recaptcha-container');
3738 * const provider = new PhoneAuthProvider(auth);
3739 * const verificationId = await provider.verifyPhoneNumber('+16505550101', applicationVerifier);
3740 * // Obtain the verificationCode from the user.
3741 * const phoneCredential = PhoneAuthProvider.credential(verificationId, verificationCode);
3742 * await updatePhoneNumber(user, phoneCredential);
3743 * ```
3744 *
3745 * @param user - The user.
3746 * @param credential - A credential authenticating the new phone number.
3747 *
3748 * @public
3749 */
3750export declare function updatePhoneNumber(user: User, credential: PhoneAuthCredential): Promise<void>;
3751
3752/**
3753 * Updates a user's profile data.
3754 *
3755 * @param user - The user.
3756 * @param profile - The profile's `displayName` and `photoURL` to update.
3757 *
3758 * @public
3759 */
3760export declare function updateProfile(user: User, { displayName, photoURL: photoUrl }: {
3761 displayName?: string | null;
3762 photoURL?: string | null;
3763}): Promise<void>;
3764
3765/**
3766 * Sets the current language to the default device/browser preference.
3767 *
3768 * @param auth - The {@link Auth} instance.
3769 *
3770 * @public
3771 */
3772export declare function useDeviceLanguage(auth: Auth): void;
3773
3774/**
3775 * A user account.
3776 *
3777 * @public
3778 */
3779export declare interface User extends UserInfo {
3780 /**
3781 * Whether the email has been verified with {@link sendEmailVerification} and
3782 * {@link applyActionCode}.
3783 */
3784 readonly emailVerified: boolean;
3785 /**
3786 * Whether the user is authenticated using the {@link ProviderId}.ANONYMOUS provider.
3787 */
3788 readonly isAnonymous: boolean;
3789 /**
3790 * Additional metadata around user creation and sign-in times.
3791 */
3792 readonly metadata: UserMetadata;
3793 /**
3794 * Additional per provider such as displayName and profile information.
3795 */
3796 readonly providerData: UserInfo[];
3797 /**
3798 * Refresh token used to reauthenticate the user. Avoid using this directly and prefer
3799 * {@link User.getIdToken} to refresh the ID token instead.
3800 */
3801 readonly refreshToken: string;
3802 /**
3803 * The user's tenant ID.
3804 *
3805 * @remarks
3806 * This is a read-only property, which indicates the tenant ID
3807 * used to sign in the user. This is null if the user is signed in from the parent
3808 * project.
3809 *
3810 * @example
3811 * ```javascript
3812 * // Set the tenant ID on Auth instance.
3813 * auth.tenantId = 'TENANT_PROJECT_ID';
3814 *
3815 * // All future sign-in request now include tenant ID.
3816 * const result = await signInWithEmailAndPassword(auth, email, password);
3817 * // result.user.tenantId should be 'TENANT_PROJECT_ID'.
3818 * ```
3819 */
3820 readonly tenantId: string | null;
3821 /**
3822 * Deletes and signs out the user.
3823 *
3824 * @remarks
3825 * Important: this is a security-sensitive operation that requires the user to have recently
3826 * signed in. If this requirement isn't met, ask the user to authenticate again and then call
3827 * one of the reauthentication methods like {@link reauthenticateWithCredential}.
3828 */
3829 delete(): Promise<void>;
3830 /**
3831 * Returns a JSON Web Token (JWT) used to identify the user to a Firebase service.
3832 *
3833 * @remarks
3834 * Returns the current token if it has not expired or if it will not expire in the next five
3835 * minutes. Otherwise, this will refresh the token and return a new one.
3836 *
3837 * @param forceRefresh - Force refresh regardless of token expiration.
3838 */
3839 getIdToken(forceRefresh?: boolean): Promise<string>;
3840 /**
3841 * Returns a deserialized JSON Web Token (JWT) used to identitfy the user to a Firebase service.
3842 *
3843 * @remarks
3844 * Returns the current token if it has not expired or if it will not expire in the next five
3845 * minutes. Otherwise, this will refresh the token and return a new one.
3846 *
3847 * @param forceRefresh - Force refresh regardless of token expiration.
3848 */
3849 getIdTokenResult(forceRefresh?: boolean): Promise<IdTokenResult>;
3850 /**
3851 * Refreshes the user, if signed in.
3852 */
3853 reload(): Promise<void>;
3854 /**
3855 * Returns a JSON-serializable representation of this object.
3856 *
3857 * @returns A JSON-serializable representation of this object.
3858 */
3859 toJSON(): object;
3860}
3861
3862/**
3863 * A structure containing a {@link User}, the {@link OperationType}, and the provider ID.
3864 *
3865 * @remarks
3866 * `operationType` could be {@link OperationType}.SIGN_IN for a sign-in operation,
3867 * {@link OperationType}.LINK for a linking operation and {@link OperationType}.REAUTHENTICATE for
3868 * a reauthentication operation.
3869 *
3870 * @public
3871 */
3872export declare interface UserCredential {
3873 /**
3874 * The user authenticated by this credential.
3875 */
3876 user: User;
3877 /**
3878 * The provider which was used to authenticate the user.
3879 */
3880 providerId: string | null;
3881 /**
3882 * The type of operation which was used to authenticate the user (such as sign-in or link).
3883 */
3884 operationType: typeof OperationType[keyof typeof OperationType];
3885}
3886
3887/**
3888 * @internal
3889 */
3890declare interface UserCredentialInternal extends UserCredential, TaggedWithTokenResponse {
3891 user: UserInternal;
3892}
3893
3894/**
3895 * User profile information, visible only to the Firebase project's apps.
3896 *
3897 * @public
3898 */
3899export declare interface UserInfo {
3900 /**
3901 * The display name of the user.
3902 */
3903 readonly displayName: string | null;
3904 /**
3905 * The email of the user.
3906 */
3907 readonly email: string | null;
3908 /**
3909 * The phone number normalized based on the E.164 standard (e.g. +16505550101) for the
3910 * user.
3911 *
3912 * @remarks
3913 * This is null if the user has no phone credential linked to the account.
3914 */
3915 readonly phoneNumber: string | null;
3916 /**
3917 * The profile photo URL of the user.
3918 */
3919 readonly photoURL: string | null;
3920 /**
3921 * The provider used to authenticate the user.
3922 */
3923 readonly providerId: string;
3924 /**
3925 * The user's unique ID, scoped to the project.
3926 */
3927 readonly uid: string;
3928}
3929
3930/**
3931 * UserInternal and AuthInternal reference each other, so both of them are included in the public typings.
3932 * In order to exclude them, we mark them as internal explicitly.
3933 *
3934 * @internal
3935 */
3936declare interface UserInternal extends User {
3937 displayName: string | null;
3938 email: string | null;
3939 phoneNumber: string | null;
3940 photoURL: string | null;
3941 auth: AuthInternal;
3942 providerId: ProviderId_2.FIREBASE;
3943 refreshToken: string;
3944 emailVerified: boolean;
3945 tenantId: string | null;
3946 providerData: MutableUserInfo[];
3947 metadata: UserMetadata_2;
3948 stsTokenManager: StsTokenManager;
3949 _redirectEventId?: string;
3950 _updateTokensIfNecessary(response: IdTokenResponse | FinalizeMfaResponse, reload?: boolean): Promise<void>;
3951 _assign(user: UserInternal): void;
3952 _clone(auth: AuthInternal): UserInternal;
3953 _onReload: (cb: NextFn<APIUserInfo>) => void;
3954 _notifyReloadListener: NextFn<APIUserInfo>;
3955 _startProactiveRefresh: () => void;
3956 _stopProactiveRefresh: () => void;
3957 getIdToken(forceRefresh?: boolean): Promise<string>;
3958 getIdTokenResult(forceRefresh?: boolean): Promise<IdTokenResult>;
3959 reload(): Promise<void>;
3960 delete(): Promise<void>;
3961 toJSON(): PersistedBlob;
3962}
3963
3964/**
3965 * Interface representing a user's metadata.
3966 *
3967 * @public
3968 */
3969export declare interface UserMetadata {
3970 /** Time the user was created. */
3971 readonly creationTime?: string;
3972 /** Time the user last signed in. */
3973 readonly lastSignInTime?: string;
3974}
3975
3976declare class UserMetadata_2 implements UserMetadata {
3977 private createdAt?;
3978 private lastLoginAt?;
3979 creationTime?: string;
3980 lastSignInTime?: string;
3981 constructor(createdAt?: string | number | undefined, lastLoginAt?: string | number | undefined);
3982 private _initializeTime;
3983 _copy(metadata: UserMetadata_2): void;
3984 toJSON(): object;
3985}
3986
3987/**
3988 * User profile used in {@link AdditionalUserInfo}.
3989 *
3990 * @public
3991 */
3992export declare type UserProfile = Record<string, unknown>;
3993
3994/**
3995 * Sends a verification email to a new email address.
3996 *
3997 * @remarks
3998 * The user's email will be updated to the new one after being verified.
3999 *
4000 * If you have a custom email action handler, you can complete the verification process by calling
4001 * {@link applyActionCode}.
4002 *
4003 * @example
4004 * ```javascript
4005 * const actionCodeSettings = {
4006 * url: 'https://www.example.com/?email=user@example.com',
4007 * iOS: {
4008 * bundleId: 'com.example.ios'
4009 * },
4010 * android: {
4011 * packageName: 'com.example.android',
4012 * installApp: true,
4013 * minimumVersion: '12'
4014 * },
4015 * handleCodeInApp: true
4016 * };
4017 * await verifyBeforeUpdateEmail(user, 'newemail@example.com', actionCodeSettings);
4018 * // Obtain code from the user.
4019 * await applyActionCode(auth, code);
4020 * ```
4021 *
4022 * @param user - The user.
4023 * @param newEmail - The new email address to be verified before update.
4024 * @param actionCodeSettings - The {@link ActionCodeSettings}.
4025 *
4026 * @public
4027 */
4028export declare function verifyBeforeUpdateEmail(user: User, newEmail: string, actionCodeSettings?: ActionCodeSettings | null): Promise<void>;
4029
4030/**
4031 * Checks a password reset code sent to the user by email or other out-of-band mechanism.
4032 *
4033 * @returns the user's email address if valid.
4034 *
4035 * @param auth - The {@link Auth} instance.
4036 * @param code - A verification code sent to the user.
4037 *
4038 * @public
4039 */
4040export declare function verifyPasswordResetCode(auth: Auth, code: string): Promise<string>;
4041
4042export { }