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