@react-native-firebase/auth 25.1.0 → 26.0.0

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 (115) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/RNFBAuth.podspec +14 -6
  3. package/android/build.gradle +23 -0
  4. package/android/src/main/java/io/invertase/firebase/auth/{ReactNativeFirebaseAuthModule.java → NativeRNFBTurboAuth.java} +122 -102
  5. package/android/src/main/java/io/invertase/firebase/auth/ReactNativeFirebaseAuthPackage.java +1 -1
  6. package/android/src/main/java/io/invertase/firebase/auth/ReactNativeFirebaseAuthSyncException.java +35 -0
  7. package/android/src/main/java/io/invertase/firebase/auth/generated/java/com/facebook/fbreact/specs/NativeRNFBTurboAuthSpec.java +308 -0
  8. package/android/src/main/java/io/invertase/firebase/auth/generated/jni/CMakeLists.txt +36 -0
  9. package/android/src/main/java/io/invertase/firebase/auth/generated/jni/RNFBAuthTurboModules-generated.cpp +392 -0
  10. package/android/src/main/java/io/invertase/firebase/auth/generated/jni/RNFBAuthTurboModules.h +31 -0
  11. package/android/src/main/java/io/invertase/firebase/auth/generated/jni/react/renderer/components/RNFBAuthTurboModules/RNFBAuthTurboModulesJSI-generated.cpp +538 -0
  12. package/android/src/main/java/io/invertase/firebase/auth/generated/jni/react/renderer/components/RNFBAuthTurboModules/RNFBAuthTurboModulesJSI.h +611 -0
  13. package/app.plugin.js +1 -1
  14. package/dist/module/ConfirmationResult.js.map +1 -1
  15. package/dist/module/MultiFactorResolver.js.map +1 -1
  16. package/dist/module/PhoneAuthListener.js +3 -4
  17. package/dist/module/PhoneAuthListener.js.map +1 -1
  18. package/dist/module/TotpMultiFactorGenerator.js +1 -1
  19. package/dist/module/TotpMultiFactorGenerator.js.map +1 -1
  20. package/dist/module/TotpSecret.js +15 -9
  21. package/dist/module/TotpSecret.js.map +1 -1
  22. package/dist/module/User.js +1 -1
  23. package/dist/module/User.js.map +1 -1
  24. package/dist/module/getMultiFactorResolver.js +2 -2
  25. package/dist/module/getMultiFactorResolver.js.map +1 -1
  26. package/dist/module/index.js +1221 -6
  27. package/dist/module/index.js.map +1 -1
  28. package/dist/module/internal/syncNativeError.js +75 -0
  29. package/dist/module/internal/syncNativeError.js.map +1 -0
  30. package/dist/module/multiFactor.js +5 -3
  31. package/dist/module/multiFactor.js.map +1 -1
  32. package/dist/module/providers/PhoneAuthProvider.js +4 -4
  33. package/dist/module/providers/PhoneAuthProvider.js.map +1 -1
  34. package/dist/module/types/auth.js.map +1 -1
  35. package/dist/module/version.js +1 -1
  36. package/dist/module/web/RNFBAuthModule.js +13 -7
  37. package/dist/module/web/RNFBAuthModule.js.map +1 -1
  38. package/dist/typescript/lib/ConfirmationResult.d.ts +2 -2
  39. package/dist/typescript/lib/ConfirmationResult.d.ts.map +1 -1
  40. package/dist/typescript/lib/MultiFactorResolver.d.ts +6 -6
  41. package/dist/typescript/lib/MultiFactorResolver.d.ts.map +1 -1
  42. package/dist/typescript/lib/PhoneAuthListener.d.ts +1 -4
  43. package/dist/typescript/lib/PhoneAuthListener.d.ts.map +1 -1
  44. package/dist/typescript/lib/TotpSecret.d.ts +2 -4
  45. package/dist/typescript/lib/TotpSecret.d.ts.map +1 -1
  46. package/dist/typescript/lib/User.d.ts +13 -13
  47. package/dist/typescript/lib/User.d.ts.map +1 -1
  48. package/dist/typescript/lib/getMultiFactorResolver.d.ts +5 -5
  49. package/dist/typescript/lib/getMultiFactorResolver.d.ts.map +1 -1
  50. package/dist/typescript/lib/index.d.ts +377 -4
  51. package/dist/typescript/lib/index.d.ts.map +1 -1
  52. package/dist/typescript/lib/internal/syncNativeError.d.ts +6 -0
  53. package/dist/typescript/lib/internal/syncNativeError.d.ts.map +1 -0
  54. package/dist/typescript/lib/multiFactor.d.ts +9 -9
  55. package/dist/typescript/lib/multiFactor.d.ts.map +1 -1
  56. package/dist/typescript/lib/providers/PhoneAuthProvider.d.ts.map +1 -1
  57. package/dist/typescript/lib/types/auth.d.ts +13 -0
  58. package/dist/typescript/lib/types/auth.d.ts.map +1 -1
  59. package/dist/typescript/lib/types/internal.d.ts +44 -47
  60. package/dist/typescript/lib/types/internal.d.ts.map +1 -1
  61. package/dist/typescript/lib/version.d.ts +1 -1
  62. package/dist/typescript/lib/web/RNFBAuthModule.d.ts +4 -4
  63. package/dist/typescript/lib/web/RNFBAuthModule.d.ts.map +1 -1
  64. package/ios/RNFBAuth/RNFBAuthModule.h +2 -2
  65. package/ios/RNFBAuth/{RNFBAuthModule.m → RNFBAuthModule.mm} +408 -297
  66. package/ios/RNFBAuth.xcodeproj/project.pbxproj +8 -8
  67. package/ios/generated/RCTAppDependencyProvider.h +25 -0
  68. package/ios/generated/RCTAppDependencyProvider.mm +55 -0
  69. package/ios/generated/RCTModulesConformingToProtocolsProvider.h +18 -0
  70. package/ios/generated/RCTModulesConformingToProtocolsProvider.mm +33 -0
  71. package/ios/generated/RCTThirdPartyComponentsProvider.h +16 -0
  72. package/ios/generated/RCTThirdPartyComponentsProvider.mm +23 -0
  73. package/ios/generated/RNFBAuthTurboModules/RNFBAuthTurboModules-generated.mm +459 -0
  74. package/ios/generated/RNFBAuthTurboModules/RNFBAuthTurboModules.h +341 -0
  75. package/ios/generated/RNFBAuthTurboModulesJSI-generated.cpp +538 -0
  76. package/ios/generated/RNFBAuthTurboModulesJSI.h +611 -0
  77. package/ios/generated/ReactAppDependencyProvider.podspec +34 -0
  78. package/lib/ConfirmationResult.ts +3 -6
  79. package/lib/MultiFactorResolver.ts +8 -8
  80. package/lib/PhoneAuthListener.ts +6 -10
  81. package/lib/TotpMultiFactorGenerator.ts +1 -1
  82. package/lib/TotpSecret.ts +22 -9
  83. package/lib/User.ts +27 -38
  84. package/lib/getMultiFactorResolver.ts +9 -11
  85. package/lib/index.ts +1836 -6
  86. package/lib/internal/syncNativeError.ts +89 -0
  87. package/lib/multiFactor.ts +25 -16
  88. package/lib/providers/PhoneAuthProvider.ts +9 -22
  89. package/lib/types/auth.ts +15 -0
  90. package/lib/types/internal.ts +54 -63
  91. package/lib/version.ts +1 -1
  92. package/lib/web/RNFBAuthModule.ts +13 -10
  93. package/package.json +30 -5
  94. package/plugin/build/app.plugin.d.ts +2 -0
  95. package/plugin/build/app.plugin.js +6 -0
  96. package/plugin/src/app.plugin.ts +3 -0
  97. package/plugin/tsconfig.tsbuildinfo +1 -1
  98. package/react-native.config.js +9 -0
  99. package/specs/NativeRNFBTurboAuth.ts +143 -0
  100. package/typedoc.json +0 -1
  101. package/dist/module/modular.js +0 -793
  102. package/dist/module/modular.js.map +0 -1
  103. package/dist/module/namespaced.js +0 -522
  104. package/dist/module/namespaced.js.map +0 -1
  105. package/dist/module/types/namespaced.js +0 -62
  106. package/dist/module/types/namespaced.js.map +0 -1
  107. package/dist/typescript/lib/modular.d.ts +0 -370
  108. package/dist/typescript/lib/modular.d.ts.map +0 -1
  109. package/dist/typescript/lib/namespaced.d.ts +0 -12
  110. package/dist/typescript/lib/namespaced.d.ts.map +0 -1
  111. package/dist/typescript/lib/types/namespaced.d.ts +0 -2185
  112. package/dist/typescript/lib/types/namespaced.d.ts.map +0 -1
  113. package/lib/modular.ts +0 -1166
  114. package/lib/namespaced.ts +0 -849
  115. package/lib/types/namespaced.ts +0 -2350
@@ -1,2350 +0,0 @@
1
- /*
2
- * Copyright (c) 2016-present Invertase Limited & Contributors
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this library except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- *
16
- */
17
-
18
- import { ReactNativeFirebase } from '@react-native-firebase/app';
19
- import type { ActionCodeURL as ActionCodeURLClass } from '../ActionCodeURL';
20
-
21
- /**
22
- * Firebase Authentication package for React Native.
23
- *
24
- * #### Example: Access the firebase export from the `auth` package:
25
- *
26
- * ```js
27
- * import { firebase } from '@react-native-firebase/auth';
28
- *
29
- * // firebase.auth().X
30
- * ```
31
- *
32
- * #### Example: Using the default export from the `auth` package:
33
- *
34
- * ```js
35
- * import auth from '@react-native-firebase/auth';
36
- *
37
- * // auth().X
38
- * ```
39
- *
40
- * #### Example: Using the default export from the `app` package:
41
- *
42
- * ```js
43
- * import firebase from '@react-native-firebase/app';
44
- * import '@react-native-firebase/auth';
45
- *
46
- * // firebase.auth().X
47
- * ```
48
- * TODO @salakar @ehesp missing auth providers (PhoneAuthProvider, Facebook etc)
49
- *
50
- * @firebase auth
51
- */
52
- /**
53
- * @deprecated Use the exported auth types directly instead.
54
- * FirebaseAuthTypes namespace is kept for backwards compatibility.
55
- */
56
- /* eslint-disable @typescript-eslint/no-namespace */
57
- export declare namespace FirebaseAuthTypes {
58
- import FirebaseModule = ReactNativeFirebase.FirebaseModule;
59
- import NativeFirebaseError = ReactNativeFirebase.NativeFirebaseError;
60
-
61
- export interface AuthError extends NativeFirebaseError {
62
- customData?: Record<string, any>;
63
- }
64
-
65
- export const OperationType: {
66
- LINK: 'link';
67
- REAUTHENTICATE: 'reauthenticate';
68
- SIGN_IN: 'signIn';
69
- };
70
-
71
- export type ActionCodeURL = ActionCodeURLClass;
72
-
73
- export interface ApplicationVerifier {
74
- readonly type: string;
75
- verify(): Promise<string>;
76
- }
77
-
78
- export interface PasswordPolicy {
79
- readonly enforcementState?: string;
80
- readonly forceUpgradeOnSignin?: boolean;
81
- readonly schemaVersion: number;
82
- }
83
-
84
- export interface NativeFirebaseAuthError extends NativeFirebaseError {
85
- userInfo: {
86
- /**
87
- * When trying to sign in or link with an AuthCredential which was already associated with an account,
88
- * you might receive an updated credential (depending of provider) which you can use to recover from the error.
89
- */
90
- authCredential: AuthCredential | null;
91
- /**
92
- * When trying to sign in the user might be prompted for a second factor confirmation. Can
93
- * can use this object to initialize the second factor flow and recover from the error.
94
- */
95
- resolver: MultiFactorResolver | null;
96
- };
97
- }
98
-
99
- /**
100
- * Interface that represents the credentials returned by an auth provider. Implementations specify the details
101
- * about each auth provider's credential requirements.
102
- *
103
- * TODO Missing; signInMethod, toJSON, fromJSON
104
- *
105
- * #### Example
106
- *
107
- * ```js
108
- * const provider = firebase.auth.EmailAuthProvider;
109
- * const authCredential = provider.credential('foo@bar.com', '123456');
110
- *
111
- * await firebase.auth().signInWithCredential(authCredential);
112
- * ```
113
- */
114
- export interface AuthCredential {
115
- /**
116
- * The authentication provider ID for the credential. For example, 'facebook.com', or 'google.com'.
117
- */
118
- providerId: string;
119
- token: string;
120
- secret: string;
121
- }
122
-
123
- /**
124
- * Interface that represents an auth provider. Implemented by other providers.
125
- */
126
- export interface AuthProvider {
127
- /**
128
- * The provider ID of the provider.
129
- */
130
- PROVIDER_ID: string;
131
- /**
132
- * Creates a new `AuthCredential`.
133
- *
134
- * @returns {@link AuthCredential}.
135
- * @param token A provider token.
136
- * @param secret A provider secret.
137
- */
138
- credential: (token: string | null, secret?: string) => AuthCredential;
139
- }
140
-
141
- /**
142
- * Interface that represents an OAuth provider. Implemented by other providers.
143
- */
144
- export interface OAuthProvider extends AuthProvider {
145
- /**
146
- * The provider ID of the provider.
147
- * @param providerId
148
- */
149
- // eslint-disable-next-line @typescript-eslint/no-misused-new
150
- new (providerId: string): OAuthProvider;
151
- /**
152
- * Creates a new `AuthCredential`.
153
- *
154
- * @returns {@link AuthCredential}.
155
- * @param token A provider token.
156
- * @param secret A provider secret.
157
- */
158
- credential: (token: string | null, secret?: string) => AuthCredential;
159
- /**
160
- * Sets the OAuth custom parameters to pass in an OAuth request for sign-in
161
- * operations.
162
- *
163
- * @remarks
164
- * For a detailed list, check the reserved required OAuth 2.0 parameters such as `client_id`,
165
- * `redirect_uri`, `scope`, `response_type`, and `state` are not allowed and will be ignored.
166
- *
167
- * @param customOAuthParameters - The custom OAuth parameters to pass in the OAuth request.
168
- */
169
- setCustomParameters: (customOAuthParameters: Record<string, string>) => AuthProvider;
170
- /**
171
- * Retrieve the current list of custom parameters.
172
- * @returns The current map of OAuth custom parameters.
173
- */
174
- getCustomParameters: () => Record<string, string>;
175
- /**
176
- * Add an OAuth scope to the credential.
177
- *
178
- * @param scope - Provider OAuth scope to add.
179
- */
180
- addScope: (scope: string) => AuthProvider;
181
- /**
182
- * Retrieve the current list of OAuth scopes.
183
- */
184
- getScopes: () => string[];
185
- }
186
-
187
- /**
188
- * Interface that represents an Open ID Connect auth provider. Implemented by other providers.
189
- */
190
- export interface OIDCProvider {
191
- /**
192
- * The provider ID of the provider.
193
- */
194
- PROVIDER_ID: string;
195
- /**
196
- * Creates a new `OIDCProvider`.
197
- *
198
- * @returns {@link AuthCredential}.
199
- * @param oidcSuffix this is the "Provider ID" value from the firebase console fx `azure_test`.
200
- * @param idToken A provider ID token.
201
- */
202
- credential: (oidcSuffix: string, idToken: string) => AuthCredential;
203
- }
204
-
205
- /**
206
- * Email and password auth provider implementation.
207
- */
208
- export interface EmailAuthProvider {
209
- /**
210
- * The provider ID. Always returns `password`.
211
- */
212
- PROVIDER_ID: string;
213
- /**
214
- * This corresponds to the sign-in method identifier as returned in {@link fetchSignInMethodsForEmail}.
215
- *
216
- * #### Example
217
- *
218
- * ```js
219
- * const signInMethods = await firebase.auth().fetchSignInMethodsForEmail('...');
220
- * if (signInMethods.indexOf(firebase.auth.EmailAuthProvider.EMAIL_LINK_SIGN_IN_METHOD) != -1) {
221
- * // User can sign in with email/link
222
- * }
223
- * ```
224
- */
225
- EMAIL_LINK_SIGN_IN_METHOD: string;
226
- /**
227
- * This corresponds to the sign-in method identifier as returned in {@link fetchSignInMethodsForEmail}.
228
- *
229
- * #### Example
230
- *
231
- * ```js
232
- * const signInMethods = await firebase.auth().fetchSignInMethodsForEmail('...');
233
- * if (signInMethods.indexOf(firebase.auth.EmailAuthProvider.EMAIL_PASSWORD_SIGN_IN_METHOD) != -1) {
234
- * // User can sign in with email/password
235
- * }
236
- * ```
237
- */
238
- EMAIL_PASSWORD_SIGN_IN_METHOD: string;
239
- /**
240
- * Returns the auth provider credential.
241
- *
242
- * #### Example
243
- *
244
- * ```js
245
- * const authCredential = firebase.auth.EmailAuthProvider.credential('joe.bloggs@example.com', '123456');
246
- * ```
247
- *
248
- * @returns {@link AuthCredential}
249
- * @param email Users email address.
250
- * @param password User account password.
251
- */
252
- credential: (email: string, password: string) => AuthCredential;
253
- /**
254
- * Initialize an `EmailAuthProvider` credential using an email and an email link after a sign in with email link operation.
255
- *
256
- * #### Example
257
- *
258
- * ```js
259
- * const authCredential = firebase.auth.EmailAuthProvider.credentialWithLink('joe.bloggs@example.com', 'https://myexample.com/invite');
260
- * ```
261
- *
262
- * @param email Users email address.
263
- * @param emailLink Sign-in email link.
264
- */
265
- credentialWithLink: (email: string, emailLink: string) => AuthCredential;
266
- }
267
-
268
- /**
269
- *
270
- */
271
- export interface PhoneAuthState {
272
- /**
273
- * SMS message with verification code sent to phone number.
274
- */
275
- CODE_SENT: 'sent';
276
- /**
277
- * The timeout specified in {@link verifyPhoneNumber} has expired.
278
- */
279
- AUTO_VERIFY_TIMEOUT: 'timeout';
280
- /**
281
- * Phone number auto-verification succeeded.
282
- */
283
- AUTO_VERIFIED: 'verified';
284
- /**
285
- * Phone number verification failed with an error.
286
- */
287
- ERROR: 'error';
288
- }
289
-
290
- export interface MultiFactorSession {
291
- // this is has no documented contents, it is simply returned from some APIs and passed to others
292
- }
293
-
294
- export interface PhoneMultiFactorGenerator {
295
- /**
296
- * Identifies second factors of type phone.
297
- */
298
- FACTOR_ID: FactorId.PHONE;
299
-
300
- /**
301
- * Build a MultiFactorAssertion to resolve the multi-factor sign in process.
302
- */
303
- assertion(credential: AuthCredential): MultiFactorAssertion;
304
- }
305
-
306
- /**
307
- * Represents a TOTP secret that is used for enrolling a TOTP second factor.
308
- * Contains the shared secret key and other parameters to generate time-based
309
- * one-time passwords. Implements methods to retrieve the shared secret key,
310
- * generate a QR code URL, and open the QR code URL in an OTP authenticator app.
311
- *
312
- * Differs from standard firebase JS implementation in three ways:
313
- * 1- there is no visibility into ony properties other than the secretKey
314
- * 2- there is an added `openInOtpApp` method supported by native SDKs
315
- * 3- the return value of generateQrCodeUrl is a Promise because react-native bridge is async
316
- * @public
317
- */
318
- export class TotpSecret {
319
- /** used internally to support non-default auth instances */
320
- private readonly auth;
321
- /**
322
- * Shared secret key/seed used for enrolling in TOTP MFA and generating OTPs.
323
- */
324
- readonly secretKey: string;
325
-
326
- private constructor();
327
-
328
- /**
329
- * Returns a QR code URL as described in
330
- * https://github.com/google/google-authenticator/wiki/Key-Uri-Format
331
- * This can be displayed to the user as a QR code to be scanned into a TOTP app like Google Authenticator.
332
- * If the optional parameters are unspecified, an accountName of userEmail and issuer of firebaseAppName are used.
333
- *
334
- * @param accountName the name of the account/app along with a user identifier.
335
- * @param issuer issuer of the TOTP (likely the app name).
336
- * @returns A Promise that resolves to a QR code URL string.
337
- */
338
- generateQrCodeUrl(accountName?: string, issuer?: string): Promise<string>;
339
-
340
- /**
341
- * Opens the specified QR Code URL in an OTP authenticator app on the device.
342
- * The shared secret key and account name will be populated in the OTP authenticator app.
343
- * The URL uses the otpauth:// scheme and will be opened on an app that handles this scheme,
344
- * if it exists on the device, possibly opening the ecocystem-specific app store with a generic
345
- * query for compatible apps if no app exists on the device.
346
- *
347
- * @param qrCodeUrl the URL to open in the app, from generateQrCodeUrl
348
- */
349
- openInOtpApp(qrCodeUrl: string): string;
350
- }
351
-
352
- export interface TotpMultiFactorGenerator {
353
- FACTOR_ID: FactorId.TOTP;
354
-
355
- assertionForSignIn(uid: string, totpSecret: string): MultiFactorAssertion;
356
-
357
- assertionForEnrollment(secret: TotpSecret, code: string): MultiFactorAssertion;
358
-
359
- /**
360
- * @param auth - The Auth instance. Only used for native platforms, should be ignored on web.
361
- */
362
- generateSecret(
363
- session: FirebaseAuthTypes.MultiFactorSession,
364
- auth?: FirebaseAuthTypes.Module,
365
- ): Promise<TotpSecret>;
366
- }
367
-
368
- export interface MultiFactorError extends AuthError {
369
- /** Details about the MultiFactorError. */
370
- readonly customData: AuthError['customData'] & {
371
- /**
372
- * The type of operation (sign-in, linking, or re-authentication) that raised the error.
373
- */
374
- readonly operationType: (typeof OperationType)[keyof typeof OperationType];
375
- };
376
- }
377
-
378
- /**
379
- * firebase.auth.X
380
- */
381
- /**
382
- * @deprecated Use the package default export or modular APIs instead.
383
- */
384
- export interface Statics {
385
- /**
386
- * Return the #{@link MultiFactorUser} instance for the current user.
387
- */
388
- multiFactor: multiFactor;
389
- /**
390
- * Try and obtain a #{@link MultiFactorResolver} instance based on an error.
391
- * Returns null if no resolver object could be found.
392
- *
393
- */
394
- getMultiFactorResolver: getMultiFactorResolver;
395
- /**
396
- * Email and password auth provider implementation.
397
- *
398
- * #### Example
399
- *
400
- * ```js
401
- * firebase.auth.EmailAuthProvider;
402
- * ```
403
- */
404
- EmailAuthProvider: EmailAuthProvider;
405
- /**
406
- * Phone auth provider implementation.
407
- *
408
- * #### Example
409
- *
410
- * ```js
411
- * firebase.auth.PhoneAuthProvider;
412
- * ```
413
- */
414
- PhoneAuthProvider: AuthProvider;
415
- /**
416
- * Google auth provider implementation.
417
- *
418
- * #### Example
419
- *
420
- * ```js
421
- * firebase.auth.GoogleAuthProvider;
422
- * ```
423
- */
424
- GoogleAuthProvider: AuthProvider;
425
- /**
426
- * Apple auth provider implementation. Currently this is iOS only.
427
- *
428
- * For Apple Authentication please see our [`@invertase/react-native-apple-authentication`](https://github.com/invertase/react-native-apple-authentication) library which integrates well with Firebase and provides Firebase + Apple Auth examples.
429
- *
430
- * #### Example
431
- *
432
- * ```js
433
- * firebase.auth.AppleAuthProvider;
434
- * ```
435
- */
436
- AppleAuthProvider: AuthProvider;
437
- /**
438
- * Github auth provider implementation.
439
- *
440
- * #### Example
441
- *
442
- * ```js
443
- * firebase.auth.GithubAuthProvider;
444
- * ```
445
- */
446
- GithubAuthProvider: AuthProvider;
447
- /**
448
- * Twitter auth provider implementation.
449
- *
450
- * #### Example
451
- *
452
- * ```js
453
- * firebase.auth.TwitterAuthProvider;
454
- * ```
455
- */
456
- TwitterAuthProvider: AuthProvider;
457
- /**
458
- * Facebook auth provider implementation.
459
- *
460
- * #### Example
461
- *
462
- * ```js
463
- * firebase.auth.FacebookAuthProvider;
464
- * ```
465
- */
466
- FacebookAuthProvider: AuthProvider;
467
- /**
468
- * Custom OAuth auth provider implementation.
469
- *
470
- * #### Example
471
- *
472
- * ```js
473
- * firebase.auth.OAuthProvider;
474
- * ```
475
- */
476
- OAuthProvider: OAuthProvider;
477
- /**
478
- * Custom Open ID connect auth provider implementation.
479
- *
480
- * #### Example
481
- *
482
- * ```js
483
- * firebase.auth.OIDCAuthProvider;
484
- * ```
485
- */
486
- OIDCAuthProvider: OIDCProvider;
487
- /**
488
- * A PhoneAuthState interface.
489
- *
490
- * #### Example
491
- *
492
- * ```js
493
- * firebase.auth.PhoneAuthState;
494
- * ```
495
- */
496
- PhoneAuthState: PhoneAuthState;
497
-
498
- /**
499
- * A PhoneMultiFactorGenerator interface.
500
- */
501
- PhoneMultiFactorGenerator: PhoneMultiFactorGenerator;
502
- SDK_VERSION: string;
503
- }
504
-
505
- /**
506
- * A structure containing additional user information from a federated identity provider via {@link UserCredential}.
507
- *
508
- * #### Example
509
- *
510
- * ```js
511
- * const userCredential = await firebase.auth().signInAnonymously();
512
- * console.log('Additional user info: ', userCredential.additionalUserInfo);
513
- * ```
514
- *
515
- * @error auth/operation-not-allowed Thrown if anonymous accounts are not enabled. Enable anonymous accounts in the Firebase Console, under the Auth tab.
516
- */
517
- export interface AdditionalUserInfo {
518
- /**
519
- * Returns whether the user is new or existing.
520
- */
521
- isNewUser: boolean;
522
- /**
523
- * Returns an Object containing IDP-specific user data if the provider is one of Facebook,
524
- * GitHub, Google, Twitter, Microsoft, or Yahoo.
525
- */
526
- profile?: Record<string, any>;
527
- /**
528
- * Returns the provider ID for specifying which provider the information in `profile` is for.
529
- */
530
- providerId: string;
531
- /**
532
- * Returns the username if the provider is GitHub or Twitter.
533
- */
534
- username?: string;
535
- }
536
-
537
- /**
538
- * A structure containing a User, an AuthCredential, the operationType, and any additional user
539
- * information that was returned from the identity provider. operationType could be 'signIn' for
540
- * a sign-in operation, 'link' for a linking operation and 'reauthenticate' for a re-authentication operation.
541
- *
542
- * TODO @salakar; missing credential, operationType
543
- */
544
- export interface UserCredential {
545
- /**
546
- * Any additional user information assigned to the user.
547
- */
548
- additionalUserInfo?: AdditionalUserInfo;
549
- /**
550
- * Returns the {@link User} interface of this credential.
551
- */
552
- user: User;
553
- }
554
-
555
- /**
556
- * Holds the user metadata for the current {@link User}.
557
- *
558
- * #### Example
559
- *
560
- * ```js
561
- * const user = firebase.auth().currentUser;
562
- * console.log('User metadata: ', user.metadata);
563
- * ```
564
- */
565
- export interface UserMetadata {
566
- /**
567
- * Returns the timestamp at which this account was created as dictated by the server clock
568
- * as an ISO Date string.
569
- */
570
- creationTime?: string;
571
- /**
572
- * Returns the last signin timestamp as dictated by the server clock as an ISO Date string.
573
- * This is only accurate up to a granularity of 2 minutes for consecutive sign-in attempts.
574
- */
575
- lastSignInTime?: string;
576
- }
577
-
578
- /**
579
- * Identifies the type of a second factor.
580
- */
581
- export enum FactorId {
582
- PHONE = 'phone',
583
- TOTP = 'totp',
584
- }
585
-
586
- /**
587
- * Contains information about a second factor.
588
- */
589
- export type MultiFactorInfo = PhoneMultiFactorInfo | TotpMultiFactorInfo;
590
-
591
- export interface PhoneMultiFactorInfo extends MultiFactorInfoCommon {
592
- factorId: 'phone';
593
- /**
594
- * The phone number used for this factor.
595
- */
596
- phoneNumber: string;
597
- }
598
-
599
- export interface TotpMultiFactorInfo extends MultiFactorInfoCommon {
600
- factorId: 'totp';
601
- }
602
-
603
- export interface MultiFactorInfoCommon {
604
- /**
605
- * User friendly name for this factor.
606
- */
607
- displayName?: string;
608
- /**
609
- * Time the second factor was enrolled, in UTC.
610
- */
611
- enrollmentTime: string;
612
- /**
613
- * Unique id for this factor.
614
- */
615
- uid: string;
616
- }
617
-
618
- export interface MultiFactorAssertion {
619
- token: string;
620
- secret: string;
621
- }
622
-
623
- export interface PhoneMultiFactorEnrollInfoOptions {
624
- phoneNumber: string;
625
- session: MultiFactorSession;
626
- }
627
-
628
- export interface PhoneMultiFactorSignInInfoOptions {
629
- multiFactorHint?: MultiFactorInfo;
630
-
631
- /**
632
- * Unused in react-native-firebase ipmlementation
633
- */
634
- multiFactorUid?: string;
635
-
636
- session: MultiFactorSession;
637
- }
638
-
639
- /**
640
- * Facilitates the recovery when a user needs to provide a second factor to sign-in.
641
- */
642
- export interface MultiFactorResolver {
643
- /**
644
- * A list of enrolled factors that can be used to complete the multi-factor challenge.
645
- */
646
- hints: MultiFactorInfo[];
647
- /**
648
- * Serialized session this resolver belongs to.
649
- */
650
- session: MultiFactorSession;
651
-
652
- /**
653
- * For testing purposes only
654
- */
655
- _auth?: FirebaseAuthTypes.Module;
656
-
657
- /**
658
- * Resolve the multi factor flow.
659
- */
660
- resolveSignIn(assertion: MultiFactorAssertion): Promise<UserCredential>;
661
- }
662
-
663
- /**
664
- * Try and obtain a #{@link MultiFactorResolver} instance based on an error.
665
- * Returns null if no resolver object could be found.
666
- *
667
- * #### Example
668
- *
669
- * ```js
670
- * const auth = firebase.auth();
671
- * auth.signInWithEmailAndPassword(email, password).then((user) => {
672
- * // signed in
673
- * }).catch((error) => {
674
- * if (error.code === 'auth/multi-factor-auth-required') {
675
- * const resolver = getMultiFactorResolver(auth, error);
676
- * }
677
- * });
678
- * ```
679
- */
680
- export type getMultiFactorResolver = (
681
- auth: FirebaseAuthTypes.Module,
682
- error: unknown,
683
- ) => MultiFactorResolver | null;
684
-
685
- /**
686
- * The entry point for most multi-factor operations.
687
- */
688
- export interface MultiFactorUser {
689
- /**
690
- * Returns the user's enrolled factors.
691
- */
692
- enrolledFactors: MultiFactorInfo[];
693
-
694
- /**
695
- * Return the session for this user.
696
- */
697
- getSession(): Promise<MultiFactorSession>;
698
-
699
- /**
700
- * Enroll an additional factor. Provide an optional display name that can be shown to the user.
701
- * The method will ensure the user state is reloaded after successfully enrolling a factor.
702
- */
703
- enroll(assertion: MultiFactorAssertion, displayName?: string): Promise<void>;
704
-
705
- /**
706
- * Unenroll a previously enrolled multi-factor authentication factor.
707
- * @param option The multi-factor option to unenroll.
708
- */
709
- unenroll(option: MultiFactorInfo | string): Promise<void>;
710
- }
711
-
712
- /**
713
- * Return the #{@link MultiFactorUser} instance for the current user.
714
- */
715
- export type multiFactor = (auth: FirebaseAuthTypes.Module) => Promise<MultiFactorUser>;
716
-
717
- /**
718
- * Holds information about the user's enrolled factors.
719
- *
720
- * #### Example
721
- *
722
- * ```js
723
- * const user = firebase.auth().currentUser;
724
- * console.log('User multi factors: ', user.multiFactor);
725
- * ```
726
- */
727
- export interface MultiFactor {
728
- /**
729
- * Returns the enrolled factors
730
- */
731
- enrolledFactors: MultiFactorInfo[];
732
- }
733
-
734
- /**
735
- * Represents a collection of standard profile information for a user. Can be used to expose
736
- * profile information returned by an identity provider, such as Google Sign-In or Facebook Login.
737
- *
738
- * TODO @salakar: isEmailVerified
739
- *
740
- * #### Example
741
- *
742
- * ```js
743
- * const user = firebase.auth().currentUser;
744
- *
745
- * user.providerData.forEach((userInfo) => {
746
- * console.log('User info for provider: ', userInfo);
747
- * });
748
- * ```
749
- */
750
- export interface UserInfo {
751
- /**
752
- * Returns the user's display name, if available.
753
- */
754
- displayName?: string | null;
755
- /**
756
- * Returns the email address corresponding to the user's account in the specified provider, if available.
757
- */
758
- email?: string | null;
759
- /**
760
- * The phone number normalized based on the E.164 standard (e.g. +16505550101) for the current user. This is null if the user has no phone credential linked to the account.
761
- */
762
- phoneNumber?: string | null;
763
- /**
764
- * Returns a url to the user's profile picture, if available.
765
- */
766
- photoURL?: string | null;
767
- /**
768
- * Returns the unique identifier of the provider type that this instance corresponds to.
769
- */
770
- providerId: string;
771
- /**
772
- * Returns a string representing the multi-tenant tenant id. This is null if the user is not associated with a tenant.
773
- */
774
- tenantId?: string;
775
- /**
776
- * Returns a user identifier as specified by the authentication provider.
777
- */
778
- uid: string;
779
- }
780
-
781
- /**
782
- * Interface representing ID token result obtained from {@link User#getIdTokenResult}.
783
- * It contains the ID token JWT string and other helper properties for getting different data
784
- * associated with the token as well as all the decoded payload claims.
785
- *
786
- * TODO @salakar validate timestamp types
787
- *
788
- * #### Example
789
- *
790
- * ```js
791
- * const idTokenResult = await firebase.auth().currentUser.getIdTokenResult();
792
- * console.log('User JWT: ', idTokenResult.token);
793
- * ```
794
- */
795
- export interface IdTokenResult {
796
- /**
797
- * The Firebase Auth ID token JWT string.
798
- */
799
- token: string;
800
- /**
801
- * The authentication time formatted as a UTC string. This is the time the user authenticated
802
- * (signed in) and not the time the token was refreshed.
803
- */
804
- authTime: string;
805
- /**
806
- * The ID token issued at time formatted as a UTC string.
807
- */
808
- issuedAtTime: string;
809
- /**
810
- * The ID token expiration time formatted as a UTC string.
811
- */
812
- expirationTime: string;
813
- /**
814
- * The sign-in provider through which the ID token was obtained (anonymous, custom,
815
- * phone, password, etc). Note, this does not map to provider IDs.
816
- */
817
- signInProvider: null | string;
818
- /**
819
- * The entire payload claims of the ID token including the standard reserved claims as well as
820
- * the custom claims.
821
- */
822
- claims: {
823
- [key: string]: any;
824
- };
825
- }
826
-
827
- /**
828
- * Request used to update user profile information.
829
- *
830
- * #### Example
831
- *
832
- * ```js
833
- * const update = {
834
- * displayName: 'Alias',
835
- * photoURL: 'https://my-cdn.com/assets/user/123.png',
836
- * };
837
- *
838
- * await firebase.auth().currentUser.updateProfile(update);
839
- * ```
840
- */
841
- export interface UpdateProfile {
842
- /**
843
- * An optional display name for the user. Explicitly pass null to clear the displayName.
844
- */
845
- displayName?: string | null;
846
- /**
847
- * An optional photo URL for the user. Explicitly pass null to clear the photoURL.
848
- */
849
- photoURL?: string | null;
850
- }
851
-
852
- /**
853
- * A result from a {@link signInWithPhoneNumber} call.
854
- *
855
- * #### Example
856
- *
857
- * ```js
858
- * // Force a new message to be sent
859
- * const result = await firebase.auth().signInWithPhoneNumber('#4423456789');
860
- * const user = await result.confirm('12345');
861
- * ```
862
- */
863
- export interface ConfirmationResult {
864
- /**
865
- * The phone number authentication operation's verification ID. This can be used along with
866
- * the verification code to initialize a phone auth credential.
867
- */
868
- verificationId: string | null;
869
- /**
870
- * Finishes the sign in flow. Validates a code that was sent to the users device.
871
- *
872
- * @param verificationCode The code sent to the users device from Firebase.
873
- */
874
- confirm(verificationCode: string): Promise<UserCredential | null>;
875
- }
876
-
877
- /**
878
- * Android specific options which can be attached to the {@link ActionCodeSettings} object
879
- * to be sent with requests such as {@link User#sendEmailVerification}.
880
- *
881
- * #### Example
882
- *
883
- * ```js
884
- * await firebase.auth().currentUser.sendEmailVerification({
885
- * android: {
886
- * installApp: true,
887
- * packageName: 'com.awesome.app',
888
- * },
889
- * });
890
- * ```
891
- */
892
- export interface ActionCodeSettingsAndroid {
893
- /**
894
- * Sets the Android package name. This will try to open the link in an android app if it is installed.
895
- */
896
- packageName: string;
897
- /**
898
- * If installApp is passed, it specifies whether to install the Android app if the device supports it and the app is not already installed. If this field is provided without a packageName, an error is thrown explaining that the packageName must be provided in conjunction with this field.
899
- */
900
- installApp?: boolean;
901
- /**
902
- * If minimumVersion is specified, and an older version of the app is installed, the user is taken to the Play Store to upgrade the app. The Android app needs to be registered in the Console.
903
- */
904
- minimumVersion?: string;
905
- }
906
-
907
- /**
908
- * Additional data returned from a {@link checkActionCode} call.
909
- * For the PASSWORD_RESET, VERIFY_EMAIL, and RECOVER_EMAIL actions, this object contains an email field with the address the email was sent to.
910
- * For the RECOVER_EMAIL action, which allows a user to undo an email address change, this object also contains a fromEmail field with the user account's new email address. After the action completes, the user's email address will revert to the value in the email field from the value in fromEmail field.
911
- *
912
- * #### Example
913
- *
914
- * ```js
915
- * const actionCodeInfo = await firebase.auth().checkActionCode('ABCD');
916
- *Data
917
- * console.log('Action code email: ', actionCodeInfo.data.email);
918
- * console.log('Action code from email: ', actionCodeInfo.data.fromEmail);
919
- * ```
920
- */
921
- export interface ActionCodeInfoData {
922
- /**
923
- * This signifies the email before the call was made.
924
- */
925
- email?: string;
926
- /**
927
- * This signifies the current email associated with the account, which may have changed as a result of the {@link checkActionCode} call performed.
928
- */
929
- fromEmail?: string;
930
- }
931
-
932
- /**
933
- * The interface returned from a {@link checkActionCode} call.
934
- *
935
- * #### Example
936
- *
937
- * ```js
938
- * const actionCodeInfo = await firebase.auth().checkActionCode('ABCD');
939
- * console.log('Action code operation: ', actionCodeInfo.operation);
940
- * ```
941
- */
942
- export interface ActionCodeInfo {
943
- /**
944
- * The data associated with the action code.
945
- */
946
- data: ActionCodeInfoData;
947
- /**
948
- * The operation from where the action originated.
949
- */
950
- operation: 'PASSWORD_RESET' | 'VERIFY_EMAIL' | 'RECOVER_EMAIL' | 'EMAIL_SIGNIN' | 'ERROR';
951
- }
952
-
953
- /**
954
- * iOS specific options which can be attached to the {@link ActionCodeSettings} object
955
- * to be sent with requests such as {@link User#sendEmailVerification}.
956
- *
957
- * #### Example
958
- *
959
- * ```js
960
- * await firebase.auth().currentUser.sendEmailVerification({
961
- * iOS: {
962
- * bundleId: '123456',
963
- * },
964
- * });
965
- * ```
966
- */
967
- export interface ActionCodeSettingsIos {
968
- /**
969
- * Sets the iOS bundle ID. This will try to open the link in an iOS app if it is installed. The iOS app needs to be registered in the Console.
970
- */
971
- bundleId?: string;
972
- }
973
-
974
- /**
975
- * Options to be sent with requests such as {@link User#sendEmailVerification}.
976
- *
977
- * #### Example
978
- *
979
- * ```js
980
- * await firebase.auth().currentUser.sendEmailVerification({
981
- * handleCodeInApp: true,
982
- * url: 'app/email-verification',
983
- * });
984
- * ```
985
- */
986
- export interface ActionCodeSettings {
987
- /**
988
- * Android specific settings.
989
- */
990
- android?: ActionCodeSettingsAndroid;
991
-
992
- /**
993
- * Whether the email action link will be opened in a mobile app or a web link first. The default is false. When set to true, the action code link will be be sent as a Universal Link or Android App Link and will be opened by the app if installed. In the false case, the code will be sent to the web widget first and then on continue will redirect to the app if installed.
994
- */
995
- handleCodeInApp?: boolean;
996
-
997
- /**
998
- * iOS specific settings.
999
- */
1000
- iOS?: ActionCodeSettingsIos;
1001
-
1002
- /**
1003
- * Sets the dynamic link domain (or subdomain) to use for the current link if it is to be opened using Firebase Dynamic Links. As multiple dynamic link domains can be configured per project, this field provides the ability to explicitly choose one. If none is provided, the first domain is used by default.
1004
- * Deprecated - use {@link ActionCodeSettings.linkDomain} instead.
1005
- */
1006
- dynamicLinkDomain?: string;
1007
-
1008
- /**
1009
- * This URL represents the state/Continue URL in the form of a universal link. This URL can should be constructed as a universal link that would either directly open the app where the action code would be handled or continue to the app after the action code is handled by Firebase.
1010
- */
1011
- url: string;
1012
- /**
1013
- * Firebase Dynamic Links is deprecated and will be shut down as early as August * 2025.
1014
- * Instead, use ActionCodeSettings.linkDomain to set a a custom domain. Learn more at: https://firebase.google.com/support/dynamic-links-faq
1015
- */
1016
- linkDomain?: string;
1017
- }
1018
-
1019
- /**
1020
- * An auth listener callback function for {@link onAuthStateChanged}.
1021
- *
1022
- * #### Example
1023
- *
1024
- * ```js
1025
- * function listener(user) {
1026
- * if (user) {
1027
- * // Signed in
1028
- * } else {
1029
- * // Signed out
1030
- * }
1031
- * }
1032
- *
1033
- * firebase.auth().onAuthStateChanged(listener);
1034
- * ```
1035
- */
1036
- export type AuthListenerCallback = (user: User | null) => void;
1037
-
1038
- /**
1039
- * A snapshot interface of the current phone auth state.
1040
- *
1041
- * #### Example
1042
- *
1043
- * ```js
1044
- * firebase.auth().verifyPhoneNumber('+4423456789')
1045
- * .on('state_changed', (phoneAuthSnapshot) => {
1046
- * console.log('Snapshot state: ', phoneAuthSnapshot.state);
1047
- * });
1048
- * ```
1049
- */
1050
- export interface PhoneAuthSnapshot {
1051
- /**
1052
- * The current phone auth verification state.
1053
- *
1054
- * - `sent`: On iOS, this is the final event received. Once sent, show a visible input box asking the user to enter the verification code.
1055
- * - `timeout`: Auto verification has timed out. Show a visible input box asking the user to enter the verification code.
1056
- * - `verified`: The verification code has automatically been verified by the Android device. The snapshot contains the verification ID & code to create a credential.
1057
- * - `error`: An error occurred. Handle or allow the promise to reject.
1058
- */
1059
- state: 'sent' | 'timeout' | 'verified' | 'error';
1060
- /**
1061
- * The verification ID to build a `PhoneAuthProvider` credential.
1062
- */
1063
- verificationId: string;
1064
- /**
1065
- * The verification code. Will only be available if auto verification has taken place.
1066
- */
1067
- code: string | null;
1068
- /**
1069
- * A native JavaScript error if an error occurs.
1070
- */
1071
- error: NativeFirebaseError | null;
1072
- }
1073
-
1074
- /**
1075
- * A custom error in the event verifying a phone number failed.
1076
- *
1077
- * #### Example
1078
- *
1079
- * ```js
1080
- * firebase.auth().verifyPhoneNumber('+4423456789')
1081
- * .on('state_changed', (phoneAuthSnapshot) => {
1082
- * console.log('Snapshot state: ', phoneAuthSnapshot.state);
1083
- * }, (phoneAuthError) => {
1084
- * console.error('Error: ', phoneAuthError.message);
1085
- * });
1086
- * ```
1087
- */
1088
- export interface PhoneAuthError {
1089
- /**
1090
- * The code the verification failed with.
1091
- */
1092
- code: string | null;
1093
- /**
1094
- * The verification ID which failed.
1095
- */
1096
- verificationId: string;
1097
- /**
1098
- * JavaScript error message.
1099
- */
1100
- message: string | null;
1101
- /**
1102
- * JavaScript error stack trace.
1103
- */
1104
- stack: string | null;
1105
- }
1106
-
1107
- /**
1108
- * The listener function returned from a {@link verifyPhoneNumber} call.
1109
- */
1110
- export interface PhoneAuthListener {
1111
- /**
1112
- * The phone auth state listener. See {@link PhoneAuthState} for different event state types.
1113
- *
1114
- * #### Example
1115
- *
1116
- * ```js
1117
- * firebase.auth().verifyPhoneNumber('+4423456789')
1118
- * .on('state_changed', (phoneAuthSnapshot) => {
1119
- * console.log('State: ', phoneAuthSnapshot.state);
1120
- * }, (error) => {
1121
- * console.error(error);
1122
- * }, (phoneAuthSnapshot) => {
1123
- * console.log('Success');
1124
- * });
1125
- * ```
1126
- *
1127
- * @param event The event to subscribe to. Currently only `state_changed` is available.
1128
- * @param observer The required observer function. Returns a new phone auth snapshot on each event.
1129
- * @param errorCb An optional error handler function. This is not required if the `error` snapshot state is being handled in the `observer`.
1130
- * @param successCb An optional success handler function. This is not required if the `sent` or `verified` snapshot state is being handled in the `observer`.
1131
- */
1132
- on(
1133
- event: string,
1134
- observer: (snapshot: PhoneAuthSnapshot) => void,
1135
- errorCb?: (error: PhoneAuthError) => void,
1136
- successCb?: (snapshot: PhoneAuthSnapshot) => void,
1137
- ): PhoneAuthListener;
1138
-
1139
- /**
1140
- * A promise handler called once the `on` listener flow has succeeded or rejected.
1141
- *
1142
- * #### Example
1143
- *
1144
- * ```js
1145
- * firebase.auth().verifyPhoneNumber('+4423456789')
1146
- * .on('state_changed', (phoneAuthSnapshot) => {
1147
- * if (phoneAuthSnapshot.state === firebase.auth.PhoneAuthState.CODE_SENT) {
1148
- * return Promise.resolve();
1149
- * } else {
1150
- * return Promise.reject(
1151
- * new Error('Code not sent!')
1152
- * );
1153
- * }
1154
- * })
1155
- * .then((phoneAuthSnapshot) => {
1156
- * console.log(phoneAuthSnapshot.state);
1157
- * }, (error) => {
1158
- * console.error(error.message);
1159
- * });
1160
- * ```
1161
- *
1162
- * @param onFulfilled Resolved promise handler.
1163
- * @param onRejected Rejected promise handler.
1164
- */
1165
- then(
1166
- onFulfilled?: ((a: PhoneAuthSnapshot) => any) | null,
1167
- onRejected?: ((a: NativeFirebaseError) => any) | null,
1168
- ): Promise<any>;
1169
-
1170
- /**
1171
- * A promise handler called once the `on` listener flow has rejected.
1172
- *
1173
- * #### Example
1174
- *
1175
- * ```js
1176
- * firebase.auth().verifyPhoneNumber('+4423456789')
1177
- * .on('state_changed', (phoneAuthSnapshot) => {
1178
- * return Promise.reject(
1179
- * new Error('Code not sent!')
1180
- * );
1181
- * })
1182
- * .catch((error) => {
1183
- * console.error(error.message);
1184
- * });
1185
- * ```
1186
- *
1187
- * > Used when no `onRejected` handler is passed to {@link PhoneAuthListener#then}.
1188
- *
1189
- * @param onRejected Rejected promise handler.
1190
- */
1191
- catch(onRejected: (a: NativeFirebaseError) => any): Promise<any>;
1192
- }
1193
-
1194
- /**
1195
- * Interface for module auth settings.
1196
- *
1197
- * #### Example
1198
- *
1199
- * ```js
1200
- * const settings = firebase.auth().settings;
1201
- * console.log(settings.appVerificationDisabledForTesting);
1202
- * ```
1203
- */
1204
- export interface AuthSettings {
1205
- /**
1206
- * Forces application verification to use the web reCAPTCHA flow for Phone Authentication.
1207
- *
1208
- * Once this has been called, every call to PhoneAuthProvider#verifyPhoneNumber() will skip the Play Integrity API verification flow and use the reCAPTCHA flow instead.
1209
- *
1210
- * > Calling this method a second time will overwrite the previously passed parameter.
1211
- *
1212
- * @android
1213
- * @param appName
1214
- * @param forceRecaptchaFlow
1215
- * @param promise
1216
- */
1217
- forceRecaptchaFlowForTesting: boolean;
1218
-
1219
- /**
1220
- * Flag to disable app verification for the purpose of testing phone authentication. For this property to take effect, it needs to be set before rendering a reCAPTCHA app verifier. When this is disabled, a mock reCAPTCHA is rendered instead. This is useful for manual testing during development or for automated integration tests.
1221
- *
1222
- * > In order to use this feature, you will need to [whitelist your phone number](https://firebase.google.com/docs/auth/web/phone-auth#test-with-whitelisted-phone-numbers) via the Firebase Console.
1223
- *
1224
- * @param disabled Boolean value representing whether app verification should be disabled for testing.
1225
- */
1226
- appVerificationDisabledForTesting: boolean;
1227
-
1228
- /**
1229
- * Calling this method a second time will overwrite the previously passed parameters.
1230
- * Only one number can be configured at a given time.
1231
- *
1232
- * > The phone number and SMS code here must have been configured in the Firebase Console (Authentication > Sign In Method > Phone).
1233
- *
1234
- * #### Example
1235
- *
1236
- * ```js
1237
- * await firebase.auth().settings.setAutoRetrievedSmsCodeForPhoneNumber('+4423456789', 'ABCDE');
1238
- * ```
1239
- *
1240
- * @android
1241
- * @param phoneNumber The users phone number.
1242
- * @param smsCode The pre-set SMS code.
1243
- */
1244
- setAutoRetrievedSmsCodeForPhoneNumber(phoneNumber: string, smsCode: string): Promise<null>;
1245
- }
1246
-
1247
- /**
1248
- * Represents a user's profile information in your Firebase project's user database. It also
1249
- * contains helper methods to change or retrieve profile information, as well as to manage that user's authentication state.
1250
- *
1251
- * #### Example 1
1252
- *
1253
- * Subscribing to the users authentication state.
1254
- *
1255
- * ```js
1256
- * firebase.auth().onAuthStateChanged((user) => {
1257
- * if (user) {
1258
- * console.log('User email: ', user.email);
1259
- * }
1260
- * });
1261
- * ```
1262
- *
1263
- * #### Example 2
1264
- *
1265
- * ```js
1266
- * const user = firebase.auth().currentUser;
1267
- *
1268
- * if (user) {
1269
- * console.log('User email: ', user.email);
1270
- * }
1271
- * ```
1272
- */
1273
- export interface User {
1274
- /**
1275
- * The user's display name (if available).
1276
- */
1277
- displayName: string | null;
1278
- /**
1279
- * - The user's email address (if available).
1280
- */
1281
- email: string | null;
1282
- /**
1283
- * - True if the user's email address has been verified.
1284
- */
1285
- emailVerified: boolean;
1286
- /**
1287
- * Returns true if the user is anonymous; that is, the user account was created with
1288
- * {@link signInAnonymously} and has not been linked to another account
1289
- * with {@link linkWithCredential}.
1290
- */
1291
- isAnonymous: boolean;
1292
-
1293
- /**
1294
- * Returns the {@link UserMetadata} associated with this user.
1295
- */
1296
- metadata: UserMetadata;
1297
-
1298
- /**
1299
- * Returns the {@link MultiFactor} associated with this user.
1300
- */
1301
- multiFactor: MultiFactor | null;
1302
-
1303
- /**
1304
- * Returns the phone number of the user, as stored in the Firebase project's user database,
1305
- * or null if none exists. This can be updated at any time by calling {@link User#updatePhoneNumber}.
1306
- */
1307
- phoneNumber: string | null;
1308
-
1309
- /**
1310
- * The URL of the user's profile picture (if available).
1311
- */
1312
- photoURL: string | null;
1313
-
1314
- /**
1315
- * Additional provider-specific information about the user.
1316
- */
1317
- providerData: UserInfo[];
1318
-
1319
- /**
1320
- * The authentication provider ID for the current user.
1321
- * For example, 'facebook.com', or 'google.com'.
1322
- */
1323
- providerId: string;
1324
-
1325
- /**
1326
- * - The user's unique ID.
1327
- */
1328
- uid: string;
1329
-
1330
- /**
1331
- * Delete the current user.
1332
- *
1333
- * #### Example
1334
- *
1335
- * ```js
1336
- * await firebase.auth().currentUser.delete();
1337
- * ```
1338
- *
1339
- * @error auth/requires-recent-login Thrown if the user's last sign-in time does not meet the security threshold. Use `auth.User#reauthenticateWithCredential` to resolve. This does not apply if the user is anonymous.
1340
- */
1341
- delete(): Promise<void>;
1342
-
1343
- /**
1344
- * Returns the users authentication token.
1345
- *
1346
- * #### Example
1347
- *
1348
- * ```js
1349
- * // Force a token refresh
1350
- * const idToken = await firebase.auth().currentUser.getIdToken(true);
1351
- * ```
1352
- *
1353
- * @param forceRefresh A boolean value which forces Firebase to refresh the token.
1354
- */
1355
- getIdToken(forceRefresh?: boolean): Promise<string>;
1356
-
1357
- /**
1358
- * Returns a firebase.auth.IdTokenResult object which contains the ID token JWT string and
1359
- * other helper properties for getting different data associated with the token as well as
1360
- * all the decoded payload claims.
1361
- *
1362
- * #### Example
1363
- *
1364
- * ```js
1365
- * // Force a token refresh
1366
- * const idTokenResult = await firebase.auth().currentUser.getIdTokenResult(true);
1367
- * ```
1368
- *
1369
- * @param forceRefresh boolean Force refresh regardless of token expiration.
1370
- */
1371
- getIdTokenResult(forceRefresh?: boolean): Promise<IdTokenResult>;
1372
-
1373
- /**
1374
- * Link the user with a 3rd party credential provider.
1375
- *
1376
- * #### Example
1377
- *
1378
- * ```js
1379
- * const facebookCredential = firebase.auth.FacebookAuthProvider.credential('access token from Facebook');
1380
- * const userCredential = await firebase.auth().currentUser.linkWithCredential(facebookCredential);
1381
- * ```
1382
- *
1383
- * @error auth/provider-already-linked Thrown if the provider has already been linked to the user. This error is thrown even if this is not the same provider's account that is currently linked to the user.
1384
- * @error auth/invalid-credential Thrown if the provider's credential is not valid. This can happen if it has already expired when calling link, or if it used invalid token(s). See the Firebase documentation for your provider, and make sure you pass in the correct parameters to the credential method.
1385
- * @error auth/credential-already-in-use Thrown if the account corresponding to the credential already exists among your users, or is already linked to a Firebase User.
1386
- * @error auth/email-already-in-use Thrown if the email corresponding to the credential already exists among your users.
1387
- * @error auth/operation-not-allowed Thrown if you have not enabled the provider in the Firebase Console. Go to the Firebase Console for your project, in the Auth section and the Sign in Method tab and configure the provider.
1388
- * @error auth/invalid-email Thrown if the email used in a auth.EmailAuthProvider.credential is invalid.
1389
- * @error auth/wrong-password Thrown if the password used in a auth.EmailAuthProvider.credential is not correct or when the user associated with the email does not have a password.
1390
- * @error auth/invalid-verification-code Thrown if the credential is a auth.PhoneAuthProvider.credential and the verification code of the credential is not valid.
1391
- * @error auth/invalid-verification-id Thrown if the credential is a auth.PhoneAuthProvider.credential and the verification ID of the credential is not valid.
1392
- * @throws on iOS {@link NativeFirebaseAuthError}, on Android {@link NativeFirebaseError}
1393
- * @param credential A created {@link AuthCredential}.
1394
- */
1395
- linkWithCredential(credential: AuthCredential): Promise<UserCredential>;
1396
-
1397
- /**
1398
- * Link the user with a federated 3rd party credential provider (Microsoft, Yahoo).
1399
- * The APIs here are the web-compatible linkWithPopup and linkWithRedirect but both
1400
- * share the same underlying native SDK behavior and may be used interchangably.
1401
- *
1402
- * #### Example
1403
- *
1404
- * ```js
1405
- * const provider = new firebase.auth.OAuthProvider('microsoft.com');
1406
- * const userCredential = await firebase.auth().currentUser.linkWithPopup(provider);
1407
- * ```
1408
- *
1409
- * @error auth/provider-already-linked Thrown if the provider has already been linked to the user. This error is thrown even if this is not the same provider's account that is currently linked to the user.
1410
- * @error auth/invalid-credential Thrown if the provider's credential is not valid. This can happen if it has already expired when calling link, or if it used invalid token(s). See the Firebase documentation for your provider, and make sure you pass in the correct parameters to the credential method.
1411
- * @error auth/credential-already-in-use Thrown if the account corresponding to the credential already exists among your users, or is already linked to a Firebase User.
1412
- * @error auth/email-already-in-use Thrown if the email corresponding to the credential already exists among your users.
1413
- * @error auth/operation-not-allowed Thrown if you have not enabled the provider in the Firebase Console. Go to the Firebase Console for your project, in the Auth section and the Sign in Method tab and configure the provider.
1414
- * @error auth/invalid-email Thrown if the email used in a auth.EmailAuthProvider.credential is invalid.
1415
- * @error auth/wrong-password Thrown if the password used in a auth.EmailAuthProvider.credential is not correct or when the user associated with the email does not have a password.
1416
- * @error auth/invalid-verification-code Thrown if the credential is a auth.PhoneAuthProvider.credential and the verification code of the credential is not valid.
1417
- * @error auth/invalid-verification-id Thrown if the credential is a auth.PhoneAuthProvider.credential and the verification ID of the credential is not valid.
1418
- * @throws on iOS {@link NativeFirebaseAuthError}, on Android {@link NativeFirebaseError}
1419
- * @param provider A created {@link AuthProvider}.
1420
- */
1421
- linkWithPopup(provider: AuthProvider): Promise<UserCredential>;
1422
-
1423
- /**
1424
- * Link the user with a federated 3rd party credential provider (Microsoft, Yahoo).
1425
- * The APIs here are the web-compatible linkWithPopup and linkWithRedirect but both
1426
- * share the same underlying native SDK behavior and may be used interchangably.
1427
- *
1428
- * #### Example
1429
- *
1430
- * ```js
1431
- * const provider = new firebase.auth.OAuthProvider('microsoft.com');
1432
- * const userCredential = await firebase.auth().currentUser.linkWithRedirect(provider);
1433
- * ```
1434
- *
1435
- * @error auth/provider-already-linked Thrown if the provider has already been linked to the user. This error is thrown even if this is not the same provider's account that is currently linked to the user.
1436
- * @error auth/invalid-credential Thrown if the provider's credential is not valid. This can happen if it has already expired when calling link, or if it used invalid token(s). See the Firebase documentation for your provider, and make sure you pass in the correct parameters to the credential method.
1437
- * @error auth/credential-already-in-use Thrown if the account corresponding to the credential already exists among your users, or is already linked to a Firebase User.
1438
- * @error auth/email-already-in-use Thrown if the email corresponding to the credential already exists among your users.
1439
- * @error auth/operation-not-allowed Thrown if you have not enabled the provider in the Firebase Console. Go to the Firebase Console for your project, in the Auth section and the Sign in Method tab and configure the provider.
1440
- * @error auth/invalid-email Thrown if the email used in a auth.EmailAuthProvider.credential is invalid.
1441
- * @error auth/wrong-password Thrown if the password used in a auth.EmailAuthProvider.credential is not correct or when the user associated with the email does not have a password.
1442
- * @error auth/invalid-verification-code Thrown if the credential is a auth.PhoneAuthProvider.credential and the verification code of the credential is not valid.
1443
- * @error auth/invalid-verification-id Thrown if the credential is a auth.PhoneAuthProvider.credential and the verification ID of the credential is not valid.
1444
- * @throws on iOS {@link NativeFirebaseAuthError}, on Android {@link NativeFirebaseError}
1445
- * @param provider A created {@link AuthProvider}.
1446
- */
1447
- linkWithRedirect(provider: AuthProvider): Promise<UserCredential>;
1448
-
1449
- /**
1450
- * Re-authenticate a user with a third-party authentication provider.
1451
- *
1452
- * #### Example
1453
- *
1454
- * ```js
1455
- * const facebookCredential = firebase.auth.FacebookAuthProvider.credential('access token from Facebook');
1456
- * const userCredential = await firebase.auth().currentUser.reauthenticateWithCredential(facebookCredential);
1457
- * ```
1458
- *
1459
- * @error auth/user-mismatch Thrown if the credential given does not correspond to the user.
1460
- * @error auth/user-not-found Thrown if the credential given does not correspond to any existing user.
1461
- * @error auth/invalid-credential Thrown if the provider's credential is not valid. This can happen if it has already expired when calling link, or if it used invalid token(s). See the Firebase documentation for your provider, and make sure you pass in the correct parameters to the credential method.
1462
- * @error auth/invalid-email Thrown if the email used in a auth.EmailAuthProvider.credential is invalid.
1463
- * @error auth/wrong-password Thrown if the password used in a auth.EmailAuthProvider.credential is not correct or when the user associated with the email does not have a password.
1464
- * @error auth/invalid-verification-code Thrown if the credential is a auth.PhoneAuthProvider.credential and the verification code of the credential is not valid.
1465
- * @error auth/invalid-verification-id Thrown if the credential is a auth.PhoneAuthProvider.credential and the verification ID of the credential is not valid.
1466
- * @param credential A created {@link AuthCredential}.
1467
- */
1468
- reauthenticateWithCredential(credential: AuthCredential): Promise<UserCredential>;
1469
-
1470
- /**
1471
- * Re-authenticate a user with a federated authentication provider (Microsoft, Yahoo). For native platforms, this will open a browser window.
1472
- * #### Example
1473
- *
1474
- * ```js
1475
- * const provider = new firebase.auth.OAuthProvider('microsoft.com');
1476
- * const userCredential = await firebase.auth().currentUser.reauthenticateWithProvider(provider);
1477
- * ```
1478
- *
1479
- * @error auth/user-mismatch Thrown if the credential given does not correspond to the user.
1480
- * @error auth/user-not-found Thrown if the credential given does not correspond to any existing user.
1481
- * @error auth/invalid-credential Thrown if the provider's credential is not valid. This can happen if it has already expired when calling link, or if it used invalid token(s). See the Firebase documentation for your provider, and make sure you pass in the correct parameters to the credential method.
1482
- * @error auth/invalid-email Thrown if the email used in a auth.EmailAuthProvider.credential is invalid.
1483
- * @error auth/wrong-password Thrown if the password used in a auth.EmailAuthProvider.credential is not correct or when the user associated with the email does not have a password.
1484
- * @error auth/invalid-verification-code Thrown if the credential is a auth.PhoneAuthProvider.credential and the verification code of the credential is not valid.
1485
- * @error auth/invalid-verification-id Thrown if the credential is a auth.PhoneAuthProvider.credential and the verification ID of the credential is not valid.
1486
- * @param provider A created {@link AuthProvider}.
1487
- * @returns A promise that resolves with no value.
1488
- */
1489
- reauthenticateWithRedirect(provider: AuthProvider): Promise<void>;
1490
- /**
1491
- * Re-authenticate a user with a federated authentication provider (Microsoft, Yahoo). For native platforms, this will open a browser window.
1492
- * pop-up equivalent on native platforms.
1493
- *
1494
- * @param provider - The auth provider.
1495
- * @returns A promise that resolves with the user credentials.
1496
- */
1497
- reauthenticateWithPopup(provider: AuthProvider): Promise<UserCredential>;
1498
- /**
1499
- * Refreshes the current user.
1500
- *
1501
- * #### Example
1502
- *
1503
- * ```js
1504
- * await firebase.auth().currentUser.reload();
1505
- * ```
1506
- */
1507
- reload(): Promise<void>;
1508
-
1509
- /**
1510
- * Sends a verification email to a user.
1511
- *
1512
- * #### Example
1513
- *
1514
- * ```js
1515
- * await firebase.auth().currentUser.sendEmailVerification({
1516
- * handleCodeInApp: true,
1517
- * });
1518
- * ```
1519
- *
1520
- * > This will Promise reject if the user is anonymous.
1521
- *
1522
- * @error auth/missing-android-pkg-name An Android package name must be provided if the Android app is required to be installed.
1523
- * @error auth/missing-continue-uri A continue URL must be provided in the request.
1524
- * @error auth/missing-ios-bundle-id An iOS bundle ID must be provided if an App Store ID is provided.
1525
- * @error auth/invalid-continue-uri The continue URL provided in the request is invalid.
1526
- * @error auth/unauthorized-continue-uri The domain of the continue URL is not whitelisted. Whitelist the domain in the Firebase console.
1527
- * @param actionCodeSettings Any optional additional settings to be set before sending the verification email.
1528
- */
1529
- sendEmailVerification(actionCodeSettings?: ActionCodeSettings): Promise<void>;
1530
- /**
1531
- * Sends a link to the user's email address, when clicked, the user's Authentication email address will be updated to whatever
1532
- * was passed as the first argument.
1533
- *
1534
- * #### Example
1535
- *
1536
- * ```js
1537
- * await firebase.auth().currentUser.verifyBeforeUpdateEmail(
1538
- * 'foo@emailaddress.com',
1539
- * {
1540
- * handleCodeInApp: true,
1541
- * });
1542
- * ```
1543
- *
1544
- * > This will Promise reject if the user is anonymous.
1545
- *
1546
- * @error auth/missing-android-pkg-name An Android package name must be provided if the Android app is required to be installed.
1547
- * @error auth/missing-continue-uri A continue URL must be provided in the request.
1548
- * @error auth/missing-ios-bundle-id An iOS bundle ID must be provided if an App Store ID is provided.
1549
- * @error auth/invalid-continue-uri The continue URL provided in the request is invalid.
1550
- * @error auth/unauthorized-continue-uri The domain of the continue URL is not whitelisted. Whitelist the domain in the Firebase console.
1551
- * @param actionCodeSettings Any optional additional settings to be set before sending the verification email.
1552
- */
1553
- verifyBeforeUpdateEmail(email: string, actionCodeSettings?: ActionCodeSettings): Promise<void>;
1554
-
1555
- /**
1556
- * Returns a JSON-serializable representation of this object.
1557
- *
1558
- * #### Example
1559
- *
1560
- * ```js
1561
- * const user = firebase.auth().currentUser.toJSON();
1562
- * ```
1563
- */
1564
- toJSON(): object;
1565
-
1566
- /**
1567
- * Unlinks a provider from a user account.
1568
- *
1569
- * #### Example
1570
- *
1571
- * ```js
1572
- * const user = await firebase.auth().currentUser.unlink('facebook.com');
1573
- * ```
1574
- *
1575
- * @error auth/no-such-provider Thrown if the user does not have this provider linked or when the provider ID given does not exist.
1576
- * @param providerId
1577
- */
1578
- unlink(providerId: string): Promise<User>;
1579
-
1580
- /**
1581
- * Updates the user's email address.
1582
- *
1583
- * See Firebase docs for more information on security & email validation.
1584
- *
1585
- * #### Example
1586
- *
1587
- * ```js
1588
- * await firebase.auth().currentUser.updateEmail('joe.bloggs@new-email.com');
1589
- * ```
1590
- *
1591
- * > This will Promise reject if the user is anonymous.
1592
- *
1593
- * @error auth/invalid-email Thrown if the email used is invalid.
1594
- * @error auth/email-already-in-use Thrown if the email is already used by another user.
1595
- * @error auth/requires-recent-login Thrown if the user's last sign-in time does not meet the security threshold.
1596
- * @param email The users new email address.
1597
- */
1598
- updateEmail(email: string): Promise<void>;
1599
-
1600
- /**
1601
- * Updates the users password.
1602
- *
1603
- * Important: this is a security sensitive operation that requires the user to have recently signed in.
1604
- * If this requirement isn't met, ask the user to authenticate again and then call firebase.User#reauthenticate.
1605
- *
1606
- * #### Example
1607
- *
1608
- * ```js
1609
- * await firebase.auth().currentUser.updatePassword('654321');
1610
- * ```
1611
- *
1612
- * > This will Promise reject is the user is anonymous.
1613
- *
1614
- * @error auth/weak-password Thrown if the password is not strong enough.
1615
- * @error auth/requires-recent-login Thrown if the user's last sign-in time does not meet the security threshold.
1616
- * @param password The users new password.
1617
- */
1618
- updatePassword(password: string): Promise<void>;
1619
-
1620
- /**
1621
- * Updates the user's phone number.
1622
- *
1623
- * See Firebase docs for more information on security & email validation.
1624
- *
1625
- * #### Example
1626
- *
1627
- * ```js
1628
- * const snapshot = await firebase.auth().verifyPhoneNumber('+4423456789')
1629
- * .on(...); // See PhoneAuthListener - wait for successful verification
1630
- *
1631
- * const credential = firebase.auth.PhoneAuthProvider.credential(snapshot.verificationId, snapshot.code);
1632
- *
1633
- * // Update user with new verified phone number
1634
- * await firebase.auth().currentUser.updatePhoneNumber(credential);
1635
- * ```
1636
- *
1637
- * > This will Promise reject is the user is anonymous.
1638
- *
1639
- * @error auth/invalid-verification-code Thrown if the verification code of the credential is not valid.
1640
- * @error auth/invalid-verification-id Thrown if the verification ID of the credential is not valid.
1641
- * @param credential A created `PhoneAuthCredential`.
1642
- */
1643
- updatePhoneNumber(credential: AuthCredential): Promise<void>;
1644
-
1645
- /**
1646
- * Updates a user's profile data.
1647
- *
1648
- * #### Example
1649
- *
1650
- * ```js
1651
- * await firebase.auth().currentUser.updateProfile({
1652
- * displayName: 'Alias',
1653
- * });
1654
- * ```
1655
- */
1656
- updateProfile(updates: UpdateProfile): Promise<void>;
1657
- }
1658
-
1659
- /**
1660
- * The Firebase Authentication service is available for the default app or a given app.
1661
- *
1662
- * #### Example 1
1663
- *
1664
- * Get the auth instance for the **default app**:
1665
- *
1666
- * ```js
1667
- * const authForDefaultApp = firebase.auth();
1668
- * ```
1669
- *
1670
- * #### Example 2
1671
- *
1672
- * Get the auth instance for a **secondary app**:
1673
- *
1674
- * ```js
1675
- * const otherApp = firebase.app('otherApp');
1676
- * const authForOtherApp = firebase.auth(otherApp);
1677
- * ```
1678
- *
1679
- * TODO @salakar missing updateCurrentUser
1680
- */
1681
- /**
1682
- * @deprecated Use the package default export or modular APIs instead.
1683
- */
1684
- export class Module extends FirebaseModule {
1685
- /**
1686
- * The current `FirebaseApp` instance for this Firebase service.
1687
- */
1688
- app: ReactNativeFirebase.FirebaseApp;
1689
-
1690
- /**
1691
- * Returns the current tenant Id or null if it has never been set
1692
- *
1693
- * #### Example
1694
- *
1695
- * ```js
1696
- * const tenantId = firebase.auth().tenantId;
1697
- * ```
1698
- */
1699
- tenantId: string | null;
1700
- /**
1701
- * Returns the current language code.
1702
- *
1703
- * #### Example
1704
- *
1705
- * ```js
1706
- * const language = firebase.auth().languageCode;
1707
- * ```
1708
- */
1709
- get languageCode(): string;
1710
- /**
1711
- * Returns the current `AuthSettings`.
1712
- */
1713
- settings: AuthSettings;
1714
-
1715
- /**
1716
- * Returns the currently signed-in user (or null if no user signed in). See the User interface documentation for detailed usage.
1717
- *
1718
- * #### Example
1719
- *
1720
- * ```js
1721
- * const user = firebase.auth().currentUser;
1722
- * ```
1723
- *
1724
- * > It is recommended to use {@link onAuthStateChanged} to track whether the user is currently signed in.
1725
- */
1726
- currentUser: User | null;
1727
- /**
1728
- * Sets the tenant id.
1729
- *
1730
- * #### Example
1731
- *
1732
- * ```js
1733
- * await firebase.auth().setTenantId('tenant-123');
1734
- * ```
1735
- *
1736
- * @error auth/invalid-tenant-id if the tenant id is invalid for some reason
1737
- * @param tenantId the tenantID current app bind to. Pass `null` to revert to project-level IdPs (firebase-js-sdk parity). On Android, clearing tenant ID may reject because the native Firebase Auth SDK does not support null tenant IDs ([firebase-android-sdk#3398](https://github.com/firebase/firebase-android-sdk/issues/3398)).
1738
- */
1739
- setTenantId(tenantId: string | null): Promise<void>;
1740
- /**
1741
- * Sets the language code.
1742
- *
1743
- * #### Example
1744
- *
1745
- * ```js
1746
- * // Set language to French
1747
- * await firebase.auth().setLanguageCode('fr');
1748
- * ```
1749
- *
1750
- * @param languageCode An ISO language code.
1751
- * 'null' value will set the language code to the app's current language.
1752
- */
1753
- setLanguageCode(languageCode: string | null): Promise<void>;
1754
- /**
1755
- * Listen for changes in the users auth state (logging in and out).
1756
- * This method returns a unsubscribe function to stop listening to events.
1757
- * Always ensure you unsubscribe from the listener when no longer needed to prevent updates to components no longer in use.
1758
- *
1759
- * #### Example
1760
- *
1761
- * ```js
1762
- * const unsubscribe = firebase.auth().onAuthStateChanged((user) => {
1763
- * if (user) {
1764
- * // Signed in
1765
- * } else {
1766
- * // Signed out
1767
- * }
1768
- * });
1769
- *
1770
- * // Unsubscribe from further state changes
1771
- * unsubscribe();
1772
- * ```
1773
- *
1774
- * @param listener A listener function which triggers when auth state changed (for example signing out).
1775
- */
1776
- onAuthStateChanged(listener: CallbackOrObserver<AuthListenerCallback>): () => void;
1777
-
1778
- /**
1779
- * Listen for changes in ID token.
1780
- * ID token can be verified (if desired) using the [admin SDK or a 3rd party JWT library](https://firebase.google.com/docs/auth/admin/verify-id-tokens)
1781
- * This method returns a unsubscribe function to stop listening to events.
1782
- * Always ensure you unsubscribe from the listener when no longer needed to prevent updates to components no longer in use.
1783
- *
1784
- * #### Example
1785
- *
1786
- * ```js
1787
- * const unsubscribe = firebase.auth().onIdTokenChanged((user) => {
1788
- * if (user) {
1789
- * // User is signed in or token was refreshed.
1790
- * }
1791
- * });
1792
- *
1793
- * // Unsubscribe from further state changes
1794
- * unsubscribe();
1795
- * ```
1796
- *
1797
- * @param listener A listener function which triggers when the users ID token changes.
1798
- */
1799
- onIdTokenChanged(listener: CallbackOrObserver<AuthListenerCallback>): () => void;
1800
-
1801
- /**
1802
- * Adds a listener to observe changes to the User object. This is a superset of everything from
1803
- * {@link onAuthStateChanged}, {@link onIdTokenChanged} and user changes. The goal of this
1804
- * method is to provide easier listening to all user changes, such as when credentials are
1805
- * linked and unlinked, without manually having to call {@link User#reload}.
1806
- *
1807
- * #### Example
1808
- *
1809
- * ```js
1810
- * const unsubscribe = firebase.auth().onUserChanged((user) => {
1811
- * if (user) {
1812
- * // User is signed in or token was refreshed.
1813
- * }
1814
- * });
1815
- *
1816
- * // Unsubscribe from further state changes
1817
- * unsubscribe();
1818
- * ```
1819
- *
1820
- * > This is an experimental feature and is only part of React Native Firebase.
1821
- *
1822
- * @param listener A listener function which triggers when the users data changes.
1823
- */
1824
- onUserChanged(listener: CallbackOrObserver<AuthListenerCallback>): () => void;
1825
-
1826
- /**
1827
- * Signs the user out.
1828
- *
1829
- * Triggers the {@link onAuthStateChanged} listener.
1830
- *
1831
- * #### Example
1832
- *
1833
- * ```js
1834
- * await firebase.auth().signOut();
1835
- * ```
1836
- *
1837
- */
1838
- signOut(): Promise<void>;
1839
-
1840
- /**
1841
- * Sign in a user anonymously. If the user has already signed in, that user will be returned.
1842
- *
1843
- * #### Example
1844
- *
1845
- * ```js
1846
- * const userCredential = await firebase.auth().signInAnonymously();
1847
- * ```
1848
- *
1849
- * @error auth/operation-not-allowed Thrown if anonymous accounts are not enabled. Enable anonymous accounts in the Firebase Console, under the Auth tab.
1850
- */
1851
- signInAnonymously(): Promise<UserCredential>;
1852
-
1853
- /**
1854
- * Signs in the user using their phone number.
1855
- *
1856
- * #### Example
1857
- *
1858
- * ```js
1859
- * // Force a new message to be sent
1860
- * const result = await firebase.auth().signInWithPhoneNumber('#4423456789', true);
1861
- * ```
1862
- *
1863
- * @error auth/invalid-phone-number Thrown if the phone number has an invalid format.
1864
- * @error auth/missing-phone-number Thrown if the phone number is missing.
1865
- * @error auth/quota-exceeded Thrown if the SMS quota for the Firebase project has been exceeded.
1866
- * @error auth/user-disabled Thrown if the user corresponding to the given phone number has been disabled.
1867
- * @error auth/operation-not-allowed Thrown if you have not enabled the provider in the Firebase Console. Go to the Firebase Console for your project, in the Auth section and the Sign in Method tab and configure the provider.
1868
- * @param phoneNumber The devices phone number.
1869
- * @param forceResend Forces a new message to be sent if it was already recently sent.
1870
- */
1871
- signInWithPhoneNumber(phoneNumber: string, forceResend?: boolean): Promise<ConfirmationResult>;
1872
-
1873
- /**
1874
- * Returns a PhoneAuthListener to listen to phone verification events,
1875
- * on the final completion event a PhoneAuthCredential can be generated for
1876
- * authentication purposes.
1877
- *
1878
- * #### Example
1879
- *
1880
- * ```js
1881
- * firebase.auth().verifyPhoneNumber('+4423456789', )
1882
- * .on('state_changed', (phoneAuthSnapshot) => {
1883
- * console.log('Snapshot state: ', phoneAuthSnapshot.state);
1884
- * });
1885
- * ```
1886
- *
1887
- * @param phoneNumber The phone number identifier supplied by the user. Its format is normalized on the server, so it can be in any format here. (e.g. +16505550101).
1888
- * @param autoVerifyTimeoutOrForceResend If a number, sets in seconds how to to wait until auto verification times out. If boolean, sets the `forceResend` parameter.
1889
- * @param forceResend If true, resend the verification message even if it was recently sent.
1890
- */
1891
- verifyPhoneNumber(
1892
- phoneNumber: string,
1893
- autoVerifyTimeoutOrForceResend?: number | boolean,
1894
- forceResend?: boolean,
1895
- ): PhoneAuthListener;
1896
-
1897
- /**
1898
- * Obtain a verification id to complete the multi-factor sign-in flow.
1899
- */
1900
- verifyPhoneNumberWithMultiFactorInfo(
1901
- hint: MultiFactorInfo,
1902
- session: MultiFactorSession,
1903
- ): Promise<string>;
1904
-
1905
- /**
1906
- * Send an SMS to the user for verification of second factor
1907
- * @param phoneInfoOptions the phone number and session to use during enrollment
1908
- */
1909
- verifyPhoneNumberForMultiFactor(
1910
- phoneInfoOptions: PhoneMultiFactorEnrollInfoOptions,
1911
- ): Promise<string>;
1912
-
1913
- /**
1914
- * Creates a new user with an email and password.
1915
- *
1916
- * This method also signs the user in once the account has been created.
1917
- *
1918
- * #### Example
1919
- *
1920
- * ```js
1921
- * const userCredential = await firebase.auth().createUserWithEmailAndPassword('joe.bloggs@example.com', '123456');
1922
- * ```
1923
- *
1924
- * @error auth/email-already-in-use Thrown if there already exists an account with the given email address.
1925
- * @error auth/invalid-email Thrown if the email address is not valid.
1926
- * @error auth/operation-not-allowed Thrown if email/password accounts are not enabled. Enable email/password accounts in the Firebase Console, under the Auth tab.
1927
- * @error auth/weak-password Thrown if the password is not strong enough.
1928
- * @param email The users email address.
1929
- * @param password The users password.
1930
- */
1931
- createUserWithEmailAndPassword(email: string, password: string): Promise<UserCredential>;
1932
-
1933
- /**
1934
- * Signs a user in with an email and password.
1935
- *
1936
- * ⚠️ Note:
1937
- * If "Email Enumeration Protection" is enabled in your Firebase Authentication settings (enabled by default),
1938
- * Firebase may return a generic `auth/invalid-login-credentials` error instead of more specific ones like
1939
- * `auth/user-not-found` or `auth/wrong-password`. This behavior is intended to prevent leaking information
1940
- * about whether an account with the given email exists.
1941
- *
1942
- * To receive detailed error codes, you must disable "Email Enumeration Protection", which may increase
1943
- * security risks if not properly handled on the frontend.
1944
- *
1945
- * #### Example
1946
- *
1947
- * ```js
1948
- * const userCredential = await firebase.auth().signInWithEmailAndPassword('joe.bloggs@example.com', '123456');
1949
- * ```
1950
- *
1951
- * @error auth/invalid-email Thrown if the email address is not valid.
1952
- * @error auth/user-disabled Thrown if the user corresponding to the given email has been disabled.
1953
- * @error auth/user-not-found Thrown if there is no user corresponding to the given email. (May be suppressed if email enumeration protection is enabled.)
1954
- * @error auth/wrong-password Thrown if the password is invalid or missing. (May be suppressed if email enumeration protection is enabled.)
1955
- * @param email The user's email address.
1956
- * @param password The user's password.
1957
- */
1958
- signInWithEmailAndPassword(email: string, password: string): Promise<UserCredential>;
1959
-
1960
- /**
1961
- * Signs a user in with a custom token.
1962
- *
1963
- * #### Example
1964
- *
1965
- * ```js
1966
- * // Create a custom token via the Firebase Admin SDK.
1967
- * const token = await firebase.auth().createCustomToken(uid, customClaims);
1968
- * ...
1969
- * // Use the token on the device to sign in.
1970
- * const userCredential = await firebase.auth().signInWithCustomToken(token);
1971
- * ```
1972
- *
1973
- * @error auth/custom-token-mismatch Thrown if the custom token is for a different Firebase App.
1974
- * @error auth/invalid-custom-token Thrown if the custom token format is incorrect.
1975
- * @param customToken A custom token generated from the Firebase Admin SDK.
1976
- */
1977
- signInWithCustomToken(customToken: string): Promise<UserCredential>;
1978
-
1979
- /**
1980
- * Signs the user in with a generated credential.
1981
- *
1982
- * #### Example
1983
- *
1984
- * ```js
1985
- * // Generate a Firebase credential
1986
- * const credential = firebase.auth.FacebookAuthProvider.credential('access token from Facebook');
1987
- * // Sign the user in with the credential
1988
- * const userCredential = await firebase.auth().signInWithCredential(credential);
1989
- * ```
1990
- *
1991
- * @error auth/account-exists-with-different-credential Thrown if there already exists an account with the email address asserted by the credential.
1992
- * @error auth/invalid-credential Thrown if the credential is malformed or has expired.
1993
- * @error auth/operation-not-allowed Thrown if the type of account corresponding to the credential is not enabled. Enable the account type in the Firebase Console, under the Auth tab.
1994
- * @error auth/user-disabled Thrown if the user corresponding to the given credential has been disabled.
1995
- * @error auth/user-not-found Thrown if signing in with a credential from firebase.auth.EmailAuthProvider.credential and there is no user corresponding to the given email.
1996
- * @error auth/wrong-password Thrown if signing in with a credential from firebase.auth.EmailAuthProvider.credential and the password is invalid for the given email, or if the account corresponding to the email does not have a password set.
1997
- * @error auth/invalid-verification-code Thrown if the credential is a firebase.auth.PhoneAuthProvider.credential and the verification code of the credential is not valid.
1998
- * @error auth/invalid-verification-id Thrown if the credential is a firebase.auth.PhoneAuthProvider.credential and the verification ID of the credential is not valid.
1999
- * @param credential A generated `AuthCredential`, for example from social auth.
2000
- */
2001
- signInWithCredential(credential: AuthCredential): Promise<UserCredential>;
2002
-
2003
- /**
2004
- * Signs the user in with a specified provider. This is a web-compatible API along with signInWithRedirect.
2005
- * They both share the same call to the underlying native SDK signInWithProvider method.
2006
- *
2007
- * #### Example
2008
- *
2009
- * ```js
2010
- * // create a new OAuthProvider
2011
- * const provider = firebase.auth.OAuthProvider('microsoft.com');
2012
- * // Sign the user in with the provider
2013
- * const userCredential = await firebase.auth().signInWithPopup(provider);
2014
- * ```
2015
- *
2016
- * @error auth/account-exists-with-different-credential Thrown if there already exists an account with the email address asserted by the credential.
2017
- * @error auth/invalid-credential Thrown if the credential is malformed or has expired.
2018
- * @error auth/operation-not-allowed Thrown if the type of account corresponding to the credential is not enabled. Enable the account type in the Firebase Console, under the Auth tab.
2019
- * @error auth/user-disabled Thrown if the user corresponding to the given credential has been disabled.
2020
- * @error auth/user-not-found Thrown if signing in with a credential from firebase.auth.EmailAuthProvider.credential and there is no user corresponding to the given email.
2021
- * @error auth/wrong-password Thrown if signing in with a credential from firebase.auth.EmailAuthProvider.credential and the password is invalid for the given email, or if the account corresponding to the email does not have a password set.
2022
- * @error auth/invalid-verification-code Thrown if the credential is a firebase.auth.PhoneAuthProvider.credential and the verification code of the credential is not valid.
2023
- * @error auth/invalid-verification-id Thrown if the credential is a firebase.auth.PhoneAuthProvider.credential and the verification ID of the credential is not valid.
2024
- * @param provider An `AuthProvider` configured for your desired provider, e.g. "microsoft.com"
2025
- */
2026
- signInWithPopup(provider: AuthProvider): Promise<UserCredential>;
2027
-
2028
- /**
2029
- * Signs the user in with a specified provider. This is a web-compatible API along with signInWithPopup.
2030
- * They both share the same call to the underlying native SDK signInWithProvider method.
2031
- *
2032
- * #### Example
2033
- *
2034
- * ```js
2035
- * // create a new OAuthProvider
2036
- * const provider = firebase.auth.OAuthProvider('microsoft.com');
2037
- * // Sign the user in with the provider
2038
- * const userCredential = await firebase.auth().signInWithRedirect(provider);
2039
- * ```
2040
- *
2041
- * @error auth/account-exists-with-different-credential Thrown if there already exists an account with the email address asserted by the credential.
2042
- * @error auth/invalid-credential Thrown if the credential is malformed or has expired.
2043
- * @error auth/operation-not-allowed Thrown if the type of account corresponding to the credential is not enabled. Enable the account type in the Firebase Console, under the Auth tab.
2044
- * @error auth/user-disabled Thrown if the user corresponding to the given credential has been disabled.
2045
- * @error auth/user-not-found Thrown if signing in with a credential from firebase.auth.EmailAuthProvider.credential and there is no user corresponding to the given email.
2046
- * @error auth/wrong-password Thrown if signing in with a credential from firebase.auth.EmailAuthProvider.credential and the password is invalid for the given email, or if the account corresponding to the email does not have a password set.
2047
- * @error auth/invalid-verification-code Thrown if the credential is a firebase.auth.PhoneAuthProvider.credential and the verification code of the credential is not valid.
2048
- * @error auth/invalid-verification-id Thrown if the credential is a firebase.auth.PhoneAuthProvider.credential and the verification ID of the credential is not valid.
2049
- * @param provider An `AuthProvider` configured for your desired provider, e.g. "microsoft.com"
2050
- */
2051
- signInWithRedirect(provider: AuthProvider): Promise<UserCredential>;
2052
-
2053
- /**
2054
- * Revokes a user's Sign in with Apple token.
2055
- *
2056
- * #### Example
2057
- *
2058
- * ```js
2059
- * // Generate an Apple ID authorizationCode for the currently logged in user (ie, with @invertase/react-native-apple-authentication)
2060
- * const { authorizationCode } = await appleAuth.performRequest({ requestedOperation: appleAuth.Operation.REFRESH });
2061
- * // Revoke the token
2062
- * await firebase.auth().revokeToken(authorizationCode);
2063
- * ```
2064
- *
2065
- * @param authorizationCode A generated authorization code from Sign in with Apple.
2066
- */
2067
- revokeToken(authorizationCode: string): Promise<void>;
2068
-
2069
- /**
2070
- * Signs the user in with a federated OAuth provider supported by Firebase (Microsoft, Yahoo).
2071
- *
2072
- * From Firebase Docs:
2073
- * Unlike other OAuth providers supported by Firebase such as Google, Facebook, and Twitter, where
2074
- * sign-in can directly be achieved with OAuth access token based credentials, Firebase Auth does not
2075
- * support the same capability for providers such as Microsoft due to the inability of the Firebase Auth
2076
- * server to verify the audience of Microsoft OAuth access tokens.
2077
- *
2078
- * #### Example
2079
- * ```js
2080
- * // Generate an OAuth instance
2081
- * const provider = new firebase.auth.OAuthProvider('microsoft.com');
2082
- * // Optionally add scopes to the OAuth instance
2083
- * provider.addScope('mail.read');
2084
- * // Optionally add custom parameters to the OAuth instance
2085
- * provider.setCustomParameters({
2086
- * prompt: 'consent',
2087
- * });
2088
- * // Sign in using the OAuth provider
2089
- * const userCredential = await firebase.auth().signInWithProvider(provider);
2090
- * ```
2091
- *
2092
- * @error auth/account-exists-with-different-credential Thrown if there already exists an account with the email address asserted by the credential.
2093
- * @error auth/invalid-credential Thrown if the credential is malformed or has expired.
2094
- * @error auth/operation-not-allowed Thrown if the type of account corresponding to the credential is not enabled. Enable the account type in the Firebase Console, under the Auth tab.
2095
- * @error auth/user-disabled Thrown if the user corresponding to the given credential has been disabled.
2096
- * @error auth/user-not-found Thrown if signing in with a credential from firebase.auth.EmailAuthProvider.credential and there is no user corresponding to the given email.
2097
- * @error auth/wrong-password Thrown if signing in with a credential from firebase.auth.EmailAuthProvider.credential and the password is invalid for the given email, or if the account corresponding to the email does not have a password set.
2098
- * @error auth/invalid-verification-code Thrown if the credential is a firebase.auth.PhoneAuthProvider.credential and the verification code of the credential is not valid.
2099
- * @error auth/invalid-verification-id Thrown if the credential is a firebase.auth.PhoneAuthProvider.credential and the verification ID of the credential is not valid.
2100
- * @param provider A generated `AuthProvider`, for example from social auth.
2101
- */
2102
- signInWithProvider(provider: AuthProvider): Promise<UserCredential>;
2103
-
2104
- /**
2105
- * Sends a password reset email to the given email address.
2106
- * Unlike the web SDK, the email will contain a password reset link rather than a code.
2107
- *
2108
- * #### Example
2109
- *
2110
- * ```js
2111
- * await firebase.auth().sendPasswordResetEmail('joe.bloggs@example.com');
2112
- * ```
2113
- *
2114
- * @error auth/invalid-email Thrown if the email address is not valid.
2115
- * @error auth/missing-android-pkg-name An Android package name must be provided if the Android app is required to be installed.
2116
- * @error auth/missing-continue-uri A continue URL must be provided in the request.
2117
- * @error auth/missing-ios-bundle-id An iOS Bundle ID must be provided if an App Store ID is provided.
2118
- * @error auth/invalid-continue-uri The continue URL provided in the request is invalid.
2119
- * @error auth/unauthorized-continue-uri The domain of the continue URL is not whitelisted. Whitelist the domain in the Firebase console.
2120
- * @error auth/user-not-found Thrown if there is no user corresponding to the email address.
2121
- * @param email The users email address.
2122
- * @param actionCodeSettings Additional settings to be set before sending the reset email.
2123
- */
2124
- sendPasswordResetEmail(email: string, actionCodeSettings?: ActionCodeSettings): Promise<void>;
2125
-
2126
- /**
2127
- * Sends a sign in link to the user.
2128
- *
2129
- * #### Example
2130
- *
2131
- * ```js
2132
- * await firebase.auth().sendSignInLinkToEmail('joe.bloggs@example.com');
2133
- * ```
2134
- *
2135
- * @error auth/argument-error Thrown if handleCodeInApp is false.
2136
- * @error auth/invalid-email Thrown if the email address is not valid.
2137
- * @error auth/missing-android-pkg-name An Android package name must be provided if the Android app is required to be installed.
2138
- * @error auth/missing-continue-uri A continue URL must be provided in the request.
2139
- * @error auth/missing-ios-bundle-id An iOS Bundle ID must be provided if an App Store ID is provided.
2140
- * @error auth/invalid-continue-uri The continue URL provided in the request is invalid.
2141
- * @error auth/unauthorized-continue-uri The domain of the continue URL is not whitelisted. Whitelist the domain in the Firebase console.
2142
- * @param email The users email address.
2143
- * @param actionCodeSettings The action code settings. The action code settings which provides Firebase with instructions on how to construct the email link. This includes the sign in completion URL or the deep link for mobile redirects, the mobile apps to use when the sign-in link is opened on an Android or iOS device. Mobile app redirects will only be applicable if the developer configures and accepts the Firebase Dynamic Links terms of condition. The Android package name and iOS bundle ID will be respected only if they are configured in the same Firebase Auth project used.
2144
- */
2145
- sendSignInLinkToEmail(email: string, actionCodeSettings?: ActionCodeSettings): Promise<void>;
2146
-
2147
- /**
2148
- * Checks if an incoming link is a sign-in with email link suitable for signInWithEmailLink.
2149
- * Note that android and other platforms require `apiKey` link parameter for signInWithEmailLink
2150
- *
2151
- * #### Example
2152
- *
2153
- * ```js
2154
- * const valid = await firebase.auth().isSignInWithEmailLink(link);
2155
- * ```
2156
- *
2157
- * @param emailLink The email link to verify prior to using signInWithEmailLink
2158
- */
2159
- isSignInWithEmailLink(emailLink: string): Promise<boolean>;
2160
-
2161
- /**
2162
- * Signs the user in with an email link.
2163
- *
2164
- * #### Example
2165
- *
2166
- * ```js
2167
- * const userCredential = await firebase.auth().signInWithEmailLink('joe.bloggs@example.com', link);
2168
- * ```
2169
- *
2170
- * @error auth/expired-action-code Thrown if OTP in email link expires.
2171
- * @error auth/invalid-email Thrown if the email address is not valid.
2172
- * @error auth/user-disabled Thrown if the user corresponding to the given email has been disabled.
2173
- * @param email The users email to sign in with.
2174
- * @param emailLink An email link.
2175
- */
2176
- signInWithEmailLink(email: string, emailLink: string): Promise<UserCredential>;
2177
-
2178
- /**
2179
- * Completes the password reset process with the confirmation code and new password, via
2180
- * {@link sendPasswordResetEmail}.
2181
- *
2182
- * #### Example
2183
- *
2184
- * ```js
2185
- * await firebase.auth().confirmPasswordReset('ABCD', '1234567');
2186
- * ```
2187
- *
2188
- * @error auth/expired-action-code Thrown if the password reset code has expired.
2189
- * @error auth/invalid-action-code Thrown if the password reset code is invalid. This can happen if the code is malformed or has already been used.
2190
- * @error auth/user-disabled Thrown if the user corresponding to the given password reset code has been disabled.
2191
- * @error auth/user-not-found Thrown if there is no user corresponding to the password reset code. This may have happened if the user was deleted between when the code was issued and when this method was called.
2192
- * @error auth/weak-password Thrown if the new password is not strong enough.
2193
- * @param code The code from the password reset email.
2194
- * @param newPassword The new password.
2195
- */
2196
- confirmPasswordReset(code: string, newPassword: string): Promise<void>;
2197
-
2198
- /**
2199
- * Applies a verification code sent to the user by email or other out-of-band mechanism.
2200
- *
2201
- * #### Example
2202
- *
2203
- * ```js
2204
- * await firebase.auth().applyActionCode('ABCD');
2205
- * ```
2206
- *
2207
- * @error auth/expired-action-code Thrown if the action code has expired.
2208
- * @error auth/invalid-action-code Thrown if the action code is invalid. This can happen if the code is malformed or has already been used.
2209
- * @error auth/user-disabled Thrown if the user corresponding to the given action code has been disabled.
2210
- * @error auth/user-not-found Thrown if there is no user corresponding to the action code. This may have happened if the user was deleted between when the action code was issued and when this method was called.
2211
- * @param code A verification code sent to the user.
2212
- */
2213
- applyActionCode(code: string): Promise<void>;
2214
-
2215
- /**
2216
- * Checks a verification code sent to the user by email or other out-of-band mechanism.
2217
- *
2218
- * #### Example
2219
- *
2220
- * ```js
2221
- * const actionCodeInfo = await firebase.auth().checkActionCode('ABCD');
2222
- * console.log('Action code operation: ', actionCodeInfo.operation);
2223
- * ```
2224
- *
2225
- * @error auth/expired-action-code Thrown if the action code has expired.
2226
- * @error auth/invalid-action-code Thrown if the action code is invalid. This can happen if the code is malformed or has already been used.
2227
- * @error auth/user-disabled Thrown if the user corresponding to the given action code has been disabled.
2228
- * @error auth/user-not-found Thrown if there is no user corresponding to the action code. This may have happened if the user was deleted between when the action code was issued and when this method was called.
2229
- * @param code A verification code sent to the user.
2230
- */
2231
- checkActionCode(code: string): Promise<ActionCodeInfo>;
2232
-
2233
- /**
2234
- * Returns a list of authentication methods that can be used to sign in a given user (identified by its main email address).
2235
- *
2236
- * ⚠️ Note:
2237
- * If "Email Enumeration Protection" is enabled in your Firebase Authentication settings (which is the default),
2238
- * this method may return an empty array even if the email is registered, especially when called from an unauthenticated context.
2239
- *
2240
- * This is a security measure to prevent leaking account existence via email enumeration attacks.
2241
- * Do not use the result of this method to directly inform the user whether an email is registered.
2242
- *
2243
- * #### Example
2244
- *
2245
- * ```js
2246
- * const methods = await firebase.auth().fetchSignInMethodsForEmail('joe.bloggs@example.com');
2247
- *
2248
- * if (methods.length > 0) {
2249
- * // Likely a registered user — offer sign-in
2250
- * } else {
2251
- * // Could be unregistered OR email enumeration protection is active — offer registration
2252
- * }
2253
- * ```
2254
- *
2255
- * @error auth/invalid-email Thrown if the email address is not valid.
2256
- * @param email The user's email address.
2257
- */
2258
- fetchSignInMethodsForEmail(email: string): Promise<string[]>;
2259
-
2260
- /**
2261
- * Checks a password reset code sent to the user by email or other out-of-band mechanism.
2262
- * TODO salakar: confirm return behavior (Returns the user's email address if valid.)
2263
- *
2264
- * #### Example
2265
- *
2266
- * ```js
2267
- * const verifiedEmail = await firebase.auth().verifyPasswordResetCode('ABCD');
2268
- * ```
2269
- *
2270
- * @error auth/expired-action-code Thrown if the password reset code has expired.
2271
- * @error auth/invalid-action-code Thrown if the password reset code is invalid. This can happen if the code is malformed or has already been used.
2272
- * @error auth/user-disabled Thrown if the user corresponding to the given password reset code has been disabled.
2273
- * @error auth/user-not-found Thrown if there is no user corresponding to the password reset code. This may have happened if the user was deleted between when the code was issued and when this method was called.
2274
- * @param code A password reset code.
2275
- * @returns {string} The user's email address if valid
2276
- */
2277
- verifyPasswordResetCode(code: string): Promise<string>;
2278
- /**
2279
- * Switch userAccessGroup and current user to the given accessGroup and the user stored in it.
2280
- * Sign in a user with any sign in method, and the same current user is available in all
2281
- * apps in the access group.
2282
- *
2283
- * Set the `useAccessGroup` argument to `null` to stop sharing the auth state (default behaviour), the user state will no longer be
2284
- * available to any other apps.
2285
- *
2286
- * @platform ios
2287
- *
2288
- * @error auth/keychain-error Thrown if you attempt to access an inaccessible keychain
2289
- * @param userAccessGroup A string of the keychain id i.e. "TEAMID.com.example.group1"
2290
- */
2291
- useUserAccessGroup(userAccessGroup: string): Promise<null>;
2292
- /**
2293
- * Modify this Auth instance to communicate with the Firebase Auth emulator.
2294
- * This must be called synchronously immediately following the first call to firebase.auth().
2295
- * Do not use with production credentials as emulator traffic is not encrypted.
2296
- *
2297
- * Note: on android, hosts 'localhost' and '127.0.0.1' are automatically remapped to '10.0.2.2' (the
2298
- * "host" computer IP address for android emulators) to make the standard development experience easy.
2299
- * If you want to use the emulator on a real android device, you will need to specify the actual host
2300
- * computer IP address.
2301
- *
2302
- * @param url emulator URL, must have host and port (eg, 'http://localhost:9099')
2303
- */
2304
- useEmulator(url: string): void;
2305
- /**
2306
- * Provides a MultiFactorResolver suitable for completion of a multi-factor flow.
2307
- *
2308
- * @param error The MultiFactorError raised during a sign-in, or reauthentication operation.
2309
- */
2310
- getMultiFactorResolver(error: MultiFactorError): MultiFactorResolver;
2311
- /**
2312
- * The MultiFactorUser corresponding to the user.
2313
- *
2314
- * This is used to access all multi-factor properties and operations related to the user.
2315
- * @param user The user.
2316
- */
2317
- multiFactor(user: User): MultiFactorUser;
2318
- /**
2319
- * Returns the custom auth domain for the auth instance.
2320
- */
2321
- getCustomAuthDomain(): Promise<string>;
2322
- /**
2323
- * Sets the language code on the auth instance. This is to match Firebase JS SDK behavior.
2324
- * Please use the `setLanguageCode` method for setting the language code.
2325
- */
2326
- set languageCode(code: string | null);
2327
- /**
2328
- * Gets the config used to initialize this auth instance. This is to match Firebase JS SDK behavior.
2329
- * It returns an empty map as the config is not available in the native SDK.
2330
- */
2331
- get config(): Record<string, never>;
2332
- }
2333
- }
2334
-
2335
- export type CallbackOrObserver<T extends (...args: any[]) => any> = T | { next: T };
2336
-
2337
- /**
2338
- * Attach namespace to `firebase.` and `FirebaseApp.`.
2339
- */
2340
- declare module '@react-native-firebase/app' {
2341
- namespace ReactNativeFirebase {
2342
- import FirebaseModuleWithStaticsAndApp = ReactNativeFirebase.FirebaseModuleWithStaticsAndApp;
2343
- interface Module {
2344
- auth: FirebaseModuleWithStaticsAndApp<FirebaseAuthTypes.Module, FirebaseAuthTypes.Statics>;
2345
- }
2346
- interface FirebaseApp {
2347
- auth(): FirebaseAuthTypes.Module;
2348
- }
2349
- }
2350
- }