@react-native-firebase/auth 25.0.1 → 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 (127) hide show
  1. package/CHANGELOG.md +30 -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/ActionCodeURL.js.map +1 -1
  15. package/dist/module/ConfirmationResult.js.map +1 -1
  16. package/dist/module/MultiFactorResolver.js.map +1 -1
  17. package/dist/module/PhoneAuthListener.js +3 -4
  18. package/dist/module/PhoneAuthListener.js.map +1 -1
  19. package/dist/module/TotpMultiFactorGenerator.js +1 -1
  20. package/dist/module/TotpMultiFactorGenerator.js.map +1 -1
  21. package/dist/module/TotpSecret.js +15 -9
  22. package/dist/module/TotpSecret.js.map +1 -1
  23. package/dist/module/User.js +1 -1
  24. package/dist/module/User.js.map +1 -1
  25. package/dist/module/credentials/EmailAuthCredential.js.map +1 -1
  26. package/dist/module/credentials/OAuthCredential.js.map +1 -1
  27. package/dist/module/getMultiFactorResolver.js +2 -2
  28. package/dist/module/getMultiFactorResolver.js.map +1 -1
  29. package/dist/module/index.js +1221 -6
  30. package/dist/module/index.js.map +1 -1
  31. package/dist/module/internal/syncNativeError.js +75 -0
  32. package/dist/module/internal/syncNativeError.js.map +1 -0
  33. package/dist/module/multiFactor.js +5 -3
  34. package/dist/module/multiFactor.js.map +1 -1
  35. package/dist/module/providers/OIDCAuthProvider.js.map +1 -1
  36. package/dist/module/providers/PhoneAuthProvider.js +4 -4
  37. package/dist/module/providers/PhoneAuthProvider.js.map +1 -1
  38. package/dist/module/types/auth.js.map +1 -1
  39. package/dist/module/version.js +1 -1
  40. package/dist/module/web/RNFBAuthModule.js +13 -7
  41. package/dist/module/web/RNFBAuthModule.js.map +1 -1
  42. package/dist/typescript/lib/ActionCodeURL.d.ts.map +1 -1
  43. package/dist/typescript/lib/ConfirmationResult.d.ts +2 -2
  44. package/dist/typescript/lib/ConfirmationResult.d.ts.map +1 -1
  45. package/dist/typescript/lib/MultiFactorResolver.d.ts +6 -6
  46. package/dist/typescript/lib/MultiFactorResolver.d.ts.map +1 -1
  47. package/dist/typescript/lib/PhoneAuthListener.d.ts +1 -4
  48. package/dist/typescript/lib/PhoneAuthListener.d.ts.map +1 -1
  49. package/dist/typescript/lib/TotpSecret.d.ts +2 -4
  50. package/dist/typescript/lib/TotpSecret.d.ts.map +1 -1
  51. package/dist/typescript/lib/User.d.ts +13 -13
  52. package/dist/typescript/lib/User.d.ts.map +1 -1
  53. package/dist/typescript/lib/credentials/EmailAuthCredential.d.ts.map +1 -1
  54. package/dist/typescript/lib/credentials/OAuthCredential.d.ts.map +1 -1
  55. package/dist/typescript/lib/getMultiFactorResolver.d.ts +5 -5
  56. package/dist/typescript/lib/getMultiFactorResolver.d.ts.map +1 -1
  57. package/dist/typescript/lib/index.d.ts +377 -4
  58. package/dist/typescript/lib/index.d.ts.map +1 -1
  59. package/dist/typescript/lib/internal/syncNativeError.d.ts +6 -0
  60. package/dist/typescript/lib/internal/syncNativeError.d.ts.map +1 -0
  61. package/dist/typescript/lib/multiFactor.d.ts +9 -9
  62. package/dist/typescript/lib/multiFactor.d.ts.map +1 -1
  63. package/dist/typescript/lib/providers/OIDCAuthProvider.d.ts.map +1 -1
  64. package/dist/typescript/lib/providers/PhoneAuthProvider.d.ts.map +1 -1
  65. package/dist/typescript/lib/types/auth.d.ts +13 -0
  66. package/dist/typescript/lib/types/auth.d.ts.map +1 -1
  67. package/dist/typescript/lib/types/internal.d.ts +44 -47
  68. package/dist/typescript/lib/types/internal.d.ts.map +1 -1
  69. package/dist/typescript/lib/version.d.ts +1 -1
  70. package/dist/typescript/lib/web/RNFBAuthModule.d.ts +4 -4
  71. package/dist/typescript/lib/web/RNFBAuthModule.d.ts.map +1 -1
  72. package/ios/RNFBAuth/RNFBAuthModule.h +2 -2
  73. package/ios/RNFBAuth/{RNFBAuthModule.m → RNFBAuthModule.mm} +408 -297
  74. package/ios/RNFBAuth.xcodeproj/project.pbxproj +8 -8
  75. package/ios/generated/RCTAppDependencyProvider.h +25 -0
  76. package/ios/generated/RCTAppDependencyProvider.mm +55 -0
  77. package/ios/generated/RCTModulesConformingToProtocolsProvider.h +18 -0
  78. package/ios/generated/RCTModulesConformingToProtocolsProvider.mm +33 -0
  79. package/ios/generated/RCTThirdPartyComponentsProvider.h +16 -0
  80. package/ios/generated/RCTThirdPartyComponentsProvider.mm +23 -0
  81. package/ios/generated/RNFBAuthTurboModules/RNFBAuthTurboModules-generated.mm +459 -0
  82. package/ios/generated/RNFBAuthTurboModules/RNFBAuthTurboModules.h +341 -0
  83. package/ios/generated/RNFBAuthTurboModulesJSI-generated.cpp +538 -0
  84. package/ios/generated/RNFBAuthTurboModulesJSI.h +611 -0
  85. package/ios/generated/ReactAppDependencyProvider.podspec +34 -0
  86. package/lib/ActionCodeURL.ts +3 -9
  87. package/lib/ConfirmationResult.ts +3 -6
  88. package/lib/MultiFactorResolver.ts +8 -8
  89. package/lib/PhoneAuthListener.ts +6 -10
  90. package/lib/TotpMultiFactorGenerator.ts +1 -1
  91. package/lib/TotpSecret.ts +22 -9
  92. package/lib/User.ts +38 -51
  93. package/lib/credentials/EmailAuthCredential.ts +1 -5
  94. package/lib/credentials/OAuthCredential.ts +4 -1
  95. package/lib/getMultiFactorResolver.ts +9 -9
  96. package/lib/index.ts +1836 -6
  97. package/lib/internal/syncNativeError.ts +89 -0
  98. package/lib/multiFactor.ts +24 -18
  99. package/lib/providers/OIDCAuthProvider.ts +1 -5
  100. package/lib/providers/PhoneAuthProvider.ts +9 -22
  101. package/lib/types/auth.ts +15 -0
  102. package/lib/types/internal.ts +68 -73
  103. package/lib/version.ts +1 -1
  104. package/lib/web/RNFBAuthModule.ts +13 -10
  105. package/package.json +30 -4
  106. package/plugin/build/app.plugin.d.ts +2 -0
  107. package/plugin/build/app.plugin.js +6 -0
  108. package/plugin/src/app.plugin.ts +3 -0
  109. package/plugin/tsconfig.tsbuildinfo +1 -1
  110. package/react-native.config.js +9 -0
  111. package/specs/NativeRNFBTurboAuth.ts +143 -0
  112. package/typedoc.json +0 -1
  113. package/dist/module/modular.js +0 -793
  114. package/dist/module/modular.js.map +0 -1
  115. package/dist/module/namespaced.js +0 -522
  116. package/dist/module/namespaced.js.map +0 -1
  117. package/dist/module/types/namespaced.js +0 -62
  118. package/dist/module/types/namespaced.js.map +0 -1
  119. package/dist/typescript/lib/modular.d.ts +0 -370
  120. package/dist/typescript/lib/modular.d.ts.map +0 -1
  121. package/dist/typescript/lib/namespaced.d.ts +0 -12
  122. package/dist/typescript/lib/namespaced.d.ts.map +0 -1
  123. package/dist/typescript/lib/types/namespaced.d.ts +0 -2185
  124. package/dist/typescript/lib/types/namespaced.d.ts.map +0 -1
  125. package/lib/modular.ts +0 -1172
  126. package/lib/namespaced.ts +0 -846
  127. package/lib/types/namespaced.ts +0 -2350
@@ -42,12 +42,8 @@ function querystringDecode(query: string): Record<string, string> {
42
42
  }
43
43
 
44
44
  const separatorIndex = part.indexOf('=');
45
- const key = decodeURIComponent(
46
- separatorIndex >= 0 ? part.slice(0, separatorIndex) : part,
47
- );
48
- const value = decodeURIComponent(
49
- separatorIndex >= 0 ? part.slice(separatorIndex + 1) : '',
50
- );
45
+ const key = decodeURIComponent(separatorIndex >= 0 ? part.slice(0, separatorIndex) : part);
46
+ const value = decodeURIComponent(separatorIndex >= 0 ? part.slice(separatorIndex + 1) : '');
51
47
 
52
48
  decoded[key] = value;
53
49
  }
@@ -81,9 +77,7 @@ function parseMode(mode: string | null): string | null {
81
77
  */
82
78
  function parseDeepLink(url: string): string {
83
79
  const link = querystringDecode(extractQuerystring(url)).link;
84
- const doubleDeepLink = link
85
- ? querystringDecode(extractQuerystring(link)).deep_link_id
86
- : null;
80
+ const doubleDeepLink = link ? querystringDecode(extractQuerystring(link)).deep_link_id : null;
87
81
  const iOSDeepLink = querystringDecode(extractQuerystring(url)).deep_link_id;
88
82
  const iOSDoubleDeepLink = iOSDeepLink
89
83
  ? querystringDecode(extractQuerystring(iOSDeepLink)).link
@@ -15,7 +15,7 @@
15
15
  *
16
16
  */
17
17
 
18
- import type { FirebaseAuthTypes } from './types/namespaced';
18
+ import type { UserCredential } from './types/auth';
19
19
  import type { AuthInternal } from './types/internal';
20
20
 
21
21
  export default class ConfirmationResult {
@@ -27,13 +27,10 @@ export default class ConfirmationResult {
27
27
  this._verificationId = verificationId;
28
28
  }
29
29
 
30
- confirm(verificationCode: string): Promise<FirebaseAuthTypes.UserCredential | null> {
30
+ confirm(verificationCode: string): Promise<UserCredential | null> {
31
31
  return this._auth.native
32
32
  .confirmationResultConfirm(verificationCode)
33
- .then(
34
- userCredential =>
35
- this._auth._setUserCredential(userCredential) as FirebaseAuthTypes.UserCredential,
36
- );
33
+ .then(userCredential => this._auth._setUserCredential(userCredential) as UserCredential);
37
34
  }
38
35
 
39
36
  get verificationId(): string {
@@ -1,12 +1,12 @@
1
1
  /**
2
2
  * Base class to facilitate multi-factor authentication.
3
3
  */
4
- import type { FirebaseAuthTypes } from './types/namespaced';
4
+ import type { MultiFactorInfo, MultiFactorSession, UserCredential } from './types/auth';
5
5
  import type { AuthInternal } from './types/internal';
6
6
 
7
7
  type ResolverLike = {
8
- hints: FirebaseAuthTypes.MultiFactorInfo[];
9
- session: FirebaseAuthTypes.MultiFactorSession;
8
+ hints: MultiFactorInfo[];
9
+ session: MultiFactorSession;
10
10
  };
11
11
 
12
12
  type PhoneMultiFactorAssertion = {
@@ -17,8 +17,8 @@ type PhoneMultiFactorAssertion = {
17
17
  };
18
18
 
19
19
  export default class MultiFactorResolver {
20
- readonly hints: FirebaseAuthTypes.MultiFactorInfo[];
21
- readonly session: FirebaseAuthTypes.MultiFactorSession;
20
+ readonly hints: MultiFactorInfo[];
21
+ readonly session: MultiFactorSession;
22
22
  private readonly _auth: AuthInternal;
23
23
 
24
24
  constructor(auth: AuthInternal, resolver: ResolverLike) {
@@ -27,7 +27,7 @@ export default class MultiFactorResolver {
27
27
  this.session = resolver.session;
28
28
  }
29
29
 
30
- resolveSignIn(assertion: PhoneMultiFactorAssertion): Promise<FirebaseAuthTypes.UserCredential> {
30
+ resolveSignIn(assertion: PhoneMultiFactorAssertion): Promise<UserCredential> {
31
31
  const { token, secret, uid, verificationCode } = assertion;
32
32
 
33
33
  if (token && secret) {
@@ -35,7 +35,7 @@ export default class MultiFactorResolver {
35
35
  this.session,
36
36
  token,
37
37
  secret,
38
- ) as Promise<FirebaseAuthTypes.UserCredential>;
38
+ ) as Promise<UserCredential>;
39
39
  }
40
40
 
41
41
  if (uid && verificationCode) {
@@ -43,7 +43,7 @@ export default class MultiFactorResolver {
43
43
  this.session,
44
44
  uid,
45
45
  verificationCode,
46
- ) as Promise<FirebaseAuthTypes.UserCredential>;
46
+ ) as Promise<UserCredential>;
47
47
  }
48
48
 
49
49
  throw new Error('Invalid multi-factor assertion provided for sign-in resolution.');
@@ -23,7 +23,7 @@ import {
23
23
  } from '@react-native-firebase/app/dist/module/common';
24
24
  import type { ReactNativeFirebase } from '@react-native-firebase/app';
25
25
  import NativeFirebaseError from '@react-native-firebase/app/dist/module/internal/NativeFirebaseError';
26
- import type { FirebaseAuthTypes } from './types/namespaced';
26
+ import type { PhoneAuthSnapshot, PhoneAuthError } from './types/auth';
27
27
  import type {
28
28
  AuthInternal,
29
29
  NativePhoneAuthCredentialInternal,
@@ -38,8 +38,6 @@ type PhoneAuthInternalEventType =
38
38
 
39
39
  type InternalEvents = Record<PhoneAuthInternalEventType, string>;
40
40
  type PublicEvents = Record<'error' | 'event' | 'success', string>;
41
- type PhoneAuthSnapshot = FirebaseAuthTypes.PhoneAuthSnapshot;
42
- type PhoneAuthError = FirebaseAuthTypes.PhoneAuthError;
43
41
 
44
42
  let REQUEST_ID = 0;
45
43
 
@@ -235,16 +233,14 @@ export default class PhoneAuthListener {
235
233
  const snapshot: PhoneAuthSnapshot = {
236
234
  verificationId: state.verificationId,
237
235
  code: null,
238
- error: null,
236
+ error: new NativeFirebaseError(
237
+ { userInfo: state.error },
238
+ this._jsStack,
239
+ 'auth',
240
+ ) as ReactNativeFirebase.NativeFirebaseError,
239
241
  state: 'error',
240
242
  };
241
243
 
242
- snapshot.error = new NativeFirebaseError(
243
- { userInfo: state.error },
244
- this._jsStack,
245
- 'auth',
246
- ) as ReactNativeFirebase.NativeFirebaseError;
247
-
248
244
  this._emitToObservers(snapshot);
249
245
  this._emitToErrorCb(snapshot);
250
246
  this._removeAllListeners();
@@ -17,7 +17,7 @@
17
17
 
18
18
  import { isOther } from '@react-native-firebase/app/dist/module/common';
19
19
  import { TotpSecret } from './TotpSecret';
20
- import { getAuth } from './modular';
20
+ import { getAuth } from './index';
21
21
  import type { Auth, MultiFactorSession, TotpMultiFactorAssertion } from './types/auth';
22
22
  import type { AuthInternal } from './types/internal';
23
23
 
package/lib/TotpSecret.ts CHANGED
@@ -15,6 +15,7 @@
15
15
  */
16
16
 
17
17
  import { isString } from '@react-native-firebase/app/dist/module/common';
18
+ import { rethrowAuthSyncNativeError } from './internal/syncNativeError';
18
19
  import type { AuthInternal } from './types/internal';
19
20
 
20
21
  export class TotpSecret {
@@ -41,17 +42,29 @@ export class TotpSecret {
41
42
  *
42
43
  * @param accountName the name of the account/app along with a user identifier.
43
44
  * @param issuer issuer of the TOTP (likely the app name).
44
- * @returns A Promise that resolves to a QR code URL string. Unlike the firebase-js-sdk synchronous
45
- * return type, this method is async because QR code generation is performed through the React Native
46
- * native auth bridge.
45
+ * @returns A QR code URL string.
47
46
  */
48
- async generateQrCodeUrl(accountName?: string, issuer?: string): Promise<string> {
49
- // accountName and issure are nullable in the API specification but are
50
- // required by tha native SDK. The JS SDK returns '' if they are missing/empty.
51
- if (!isString(accountName) || !isString(issuer) || accountName === '' || issuer === '') {
52
- return '';
47
+ generateQrCodeUrl(accountName?: string, issuer?: string): string {
48
+ let resolvedAccountName = accountName;
49
+ let resolvedIssuer = issuer;
50
+
51
+ if (!isString(resolvedAccountName) || resolvedAccountName === '') {
52
+ resolvedAccountName = this.auth.currentUser?.email ?? 'unknownuser';
53
+ }
54
+
55
+ if (!isString(resolvedIssuer) || resolvedIssuer === '') {
56
+ resolvedIssuer = this.auth.app.name;
57
+ }
58
+
59
+ try {
60
+ return this.auth.native.generateQrCodeUrl(
61
+ this.secretKey,
62
+ resolvedAccountName,
63
+ resolvedIssuer,
64
+ );
65
+ } catch (error) {
66
+ rethrowAuthSyncNativeError(error);
53
67
  }
54
- return this.auth.native.generateQrCodeUrl(this.secretKey, accountName, issuer);
55
68
  }
56
69
 
57
70
  /**
package/lib/User.ts CHANGED
@@ -22,10 +22,17 @@ import {
22
22
  isBoolean,
23
23
  } from '@react-native-firebase/app/dist/module/common';
24
24
  import type { IdTokenResult, UserInfo, UserMetadata } from './types/auth';
25
- import type { FirebaseAuthTypes } from './types/namespaced';
25
+ import type {
26
+ AuthProvider,
27
+ AuthCredential,
28
+ ActionCodeSettings,
29
+ MultiFactor,
30
+ UpdateProfile,
31
+ UserCredential,
32
+ } from './types/auth';
26
33
  import type { AuthInternal, NativeUserInternal } from './types/internal';
27
34
 
28
- type AuthProviderWithObject = FirebaseAuthTypes.AuthProvider & {
35
+ type AuthProviderWithObject = AuthProvider & {
29
36
  toObject(): Record<string, unknown>;
30
37
  };
31
38
 
@@ -65,7 +72,7 @@ export default class User {
65
72
  };
66
73
  }
67
74
 
68
- get multiFactor(): FirebaseAuthTypes.MultiFactor | null {
75
+ get multiFactor(): MultiFactor | null {
69
76
  return this._user.multiFactor || null;
70
77
  }
71
78
 
@@ -101,7 +108,7 @@ export default class User {
101
108
  }
102
109
 
103
110
  delete(): Promise<void> {
104
- return this._auth.native.delete().then(() => {
111
+ return this._auth.native.deleteUser().then(() => {
105
112
  this._auth._setUser(null);
106
113
  });
107
114
  }
@@ -114,52 +121,34 @@ export default class User {
114
121
  return this._auth.native.getIdTokenResult(forceRefresh) as Promise<IdTokenResult>;
115
122
  }
116
123
 
117
- linkWithCredential(
118
- credential: FirebaseAuthTypes.AuthCredential,
119
- ): Promise<FirebaseAuthTypes.UserCredential> {
124
+ linkWithCredential(credential: AuthCredential): Promise<UserCredential> {
120
125
  return this._auth.native
121
126
  .linkWithCredential(credential.providerId, credential.token, credential.secret)
122
- .then(
123
- userCredential =>
124
- this._auth._setUserCredential(userCredential) as FirebaseAuthTypes.UserCredential,
125
- );
127
+ .then(userCredential => this._auth._setUserCredential(userCredential) as UserCredential);
126
128
  }
127
129
 
128
- linkWithPopup(provider: AuthProviderWithObject): Promise<FirebaseAuthTypes.UserCredential> {
130
+ linkWithPopup(provider: AuthProviderWithObject): Promise<UserCredential> {
129
131
  // call through to linkWithRedirect for shared implementation
130
132
  return this.linkWithRedirect(provider);
131
133
  }
132
134
 
133
- linkWithRedirect(provider: AuthProviderWithObject): Promise<FirebaseAuthTypes.UserCredential> {
135
+ linkWithRedirect(provider: AuthProviderWithObject): Promise<UserCredential> {
134
136
  return this._auth.native
135
137
  .linkWithProvider(provider.toObject())
136
- .then(
137
- userCredential =>
138
- this._auth._setUserCredential(userCredential) as FirebaseAuthTypes.UserCredential,
139
- );
138
+ .then(userCredential => this._auth._setUserCredential(userCredential) as UserCredential);
140
139
  }
141
140
 
142
- reauthenticateWithCredential(
143
- credential: FirebaseAuthTypes.AuthCredential,
144
- ): Promise<FirebaseAuthTypes.UserCredential> {
141
+ reauthenticateWithCredential(credential: AuthCredential): Promise<UserCredential> {
145
142
  return this._auth.native
146
143
  .reauthenticateWithCredential(credential.providerId, credential.token, credential.secret)
147
- .then(
148
- userCredential =>
149
- this._auth._setUserCredential(userCredential) as FirebaseAuthTypes.UserCredential,
150
- );
144
+ .then(userCredential => this._auth._setUserCredential(userCredential) as UserCredential);
151
145
  }
152
146
 
153
- reauthenticateWithPopup(
154
- provider: AuthProviderWithObject,
155
- ): Promise<FirebaseAuthTypes.UserCredential> {
147
+ reauthenticateWithPopup(provider: AuthProviderWithObject): Promise<UserCredential> {
156
148
  // call through to reauthenticateWithRedirect for shared implementation
157
149
  return this._auth.native
158
150
  .reauthenticateWithProvider(provider.toObject())
159
- .then(
160
- userCredential =>
161
- this._auth._setUserCredential(userCredential) as FirebaseAuthTypes.UserCredential,
162
- );
151
+ .then(userCredential => this._auth._setUserCredential(userCredential) as UserCredential);
163
152
  }
164
153
 
165
154
  reauthenticateWithRedirect(provider: AuthProviderWithObject): Promise<void> {
@@ -176,9 +165,9 @@ export default class User {
176
165
  });
177
166
  }
178
167
 
179
- sendEmailVerification(actionCodeSettings?: FirebaseAuthTypes.ActionCodeSettings): Promise<void> {
168
+ sendEmailVerification(actionCodeSettings?: ActionCodeSettings): Promise<void> {
180
169
  if (isObject(actionCodeSettings)) {
181
- const settings = actionCodeSettings as FirebaseAuthTypes.ActionCodeSettings;
170
+ const settings = actionCodeSettings as ActionCodeSettings;
182
171
 
183
172
  if (!isString(settings.url)) {
184
173
  throw new Error(
@@ -241,24 +230,22 @@ export default class User {
241
230
  }
242
231
 
243
232
  return this._auth.native.sendEmailVerification(actionCodeSettings).then(user => {
244
- this._auth._setUser(user);
245
- });
233
+ this._auth._setUser(user);
234
+ });
246
235
  }
247
236
 
248
237
  toJSON(): object {
249
238
  return Object.assign({}, this._user);
250
239
  }
251
240
 
252
- unlink(providerId: string): Promise<FirebaseAuthTypes.User> {
253
- return this._auth.native
254
- .unlink(providerId)
255
- .then(user => {
256
- const updatedUser = this._auth._setUser(user);
257
- if (!updatedUser) {
258
- throw new Error('firebase.auth.User.unlink() returned no user after unlinking provider.');
259
- }
260
- return updatedUser;
261
- });
241
+ unlink(providerId: string): Promise<import('./types/auth').User> {
242
+ return this._auth.native.unlink(providerId).then(user => {
243
+ const updatedUser = this._auth._setUser(user);
244
+ if (!updatedUser) {
245
+ throw new Error('firebase.auth.User.unlink() returned no user after unlinking provider.');
246
+ }
247
+ return updatedUser;
248
+ });
262
249
  }
263
250
 
264
251
  updateEmail(email: string): Promise<void> {
@@ -273,7 +260,7 @@ export default class User {
273
260
  });
274
261
  }
275
262
 
276
- updatePhoneNumber(credential: FirebaseAuthTypes.AuthCredential): Promise<void> {
263
+ updatePhoneNumber(credential: AuthCredential): Promise<void> {
277
264
  return this._auth.native
278
265
  .updatePhoneNumber(credential.providerId, credential.token, credential.secret)
279
266
  .then(user => {
@@ -281,7 +268,7 @@ export default class User {
281
268
  });
282
269
  }
283
270
 
284
- updateProfile(updates: FirebaseAuthTypes.UpdateProfile): Promise<void> {
271
+ updateProfile(updates: UpdateProfile): Promise<void> {
285
272
  return this._auth.native.updateProfile(updates).then(user => {
286
273
  this._auth._setUser(user);
287
274
  });
@@ -289,7 +276,7 @@ export default class User {
289
276
 
290
277
  verifyBeforeUpdateEmail(
291
278
  newEmail: string,
292
- actionCodeSettings?: FirebaseAuthTypes.ActionCodeSettings,
279
+ actionCodeSettings?: ActionCodeSettings,
293
280
  ): Promise<void> {
294
281
  if (!isString(newEmail)) {
295
282
  throw new Error(
@@ -298,7 +285,7 @@ export default class User {
298
285
  }
299
286
 
300
287
  if (isObject(actionCodeSettings)) {
301
- const settings = actionCodeSettings as FirebaseAuthTypes.ActionCodeSettings;
288
+ const settings = actionCodeSettings as ActionCodeSettings;
302
289
 
303
290
  if (!isString(settings.url)) {
304
291
  throw new Error(
@@ -361,8 +348,8 @@ export default class User {
361
348
  }
362
349
 
363
350
  return this._auth.native.verifyBeforeUpdateEmail(newEmail, actionCodeSettings).then(user => {
364
- this._auth._setUser(user);
365
- });
351
+ this._auth._setUser(user);
352
+ });
366
353
  }
367
354
 
368
355
  /**
@@ -25,11 +25,7 @@ type EmailCredentialJSON = {
25
25
  };
26
26
 
27
27
  export class EmailAuthCredential extends AuthCredential {
28
- constructor(
29
- signInMethod: 'password' | 'emailLink',
30
- email: string,
31
- password: string,
32
- ) {
28
+ constructor(signInMethod: 'password' | 'emailLink', email: string, password: string) {
33
29
  super(signInMethod, signInMethod, email, password);
34
30
  }
35
31
 
@@ -38,7 +38,10 @@ type OAuthCredentialParams = {
38
38
  bridgeSecret?: string;
39
39
  };
40
40
 
41
- function resolveOAuthBridgeFields(params: OAuthCredentialParams): { token: string; secret: string } {
41
+ function resolveOAuthBridgeFields(params: OAuthCredentialParams): {
42
+ token: string;
43
+ secret: string;
44
+ } {
42
45
  if (params.bridgeToken !== undefined || params.bridgeSecret !== undefined) {
43
46
  return {
44
47
  token: params.bridgeToken ?? '',
@@ -1,13 +1,13 @@
1
1
  import { isOther } from '@react-native-firebase/app/dist/module/common';
2
- import MultiFactorResolver from './MultiFactorResolver';
3
- import type { FirebaseAuthTypes } from './types/namespaced';
2
+ import MultiFactorResolverClass from './MultiFactorResolver';
3
+ import type { MultiFactorError, MultiFactorResolver } from './types/auth';
4
4
  import type { AuthInternal } from './types/internal';
5
5
 
6
- type ErrorWithResolver = FirebaseAuthTypes.MultiFactorError & {
6
+ type ErrorWithResolver = MultiFactorError & {
7
7
  userInfo?: {
8
8
  resolver?: {
9
- hints: FirebaseAuthTypes.MultiFactorResolver['hints'];
10
- session: FirebaseAuthTypes.MultiFactorResolver['session'];
9
+ hints: MultiFactorResolver['hints'];
10
+ session: MultiFactorResolver['session'];
11
11
  };
12
12
  };
13
13
  };
@@ -21,19 +21,19 @@ type ErrorWithResolver = FirebaseAuthTypes.MultiFactorError & {
21
21
  export function getMultiFactorResolver(
22
22
  auth: AuthInternal,
23
23
  error: ErrorWithResolver,
24
- ): FirebaseAuthTypes.MultiFactorResolver | null {
24
+ ): MultiFactorResolver | null {
25
25
  if (isOther) {
26
- return auth.native.getMultiFactorResolver(error) as FirebaseAuthTypes.MultiFactorResolver | null;
26
+ return auth.native.getMultiFactorResolver(error) as MultiFactorResolver | null;
27
27
  }
28
28
  if (
29
29
  error.hasOwnProperty('userInfo') &&
30
30
  error.userInfo?.hasOwnProperty('resolver') &&
31
31
  error.userInfo.resolver
32
32
  ) {
33
- return new MultiFactorResolver(
33
+ return new MultiFactorResolverClass(
34
34
  auth,
35
35
  error.userInfo.resolver,
36
- ) as unknown as FirebaseAuthTypes.MultiFactorResolver;
36
+ ) as unknown as MultiFactorResolver;
37
37
  }
38
38
 
39
39
  return null;