@firebase/auth 1.7.2 → 1.7.3-canary.0af23e02e

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