@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
@@ -0,0 +1,89 @@
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
+ import { isObject } from '@react-native-firebase/app/dist/module/common';
18
+ import NativeFirebaseError from '@react-native-firebase/app/dist/module/internal/NativeFirebaseError';
19
+ import type { NativeError } from '@react-native-firebase/app/dist/module/types/internal';
20
+
21
+ const INVALID_TOTP_SECRET_CODE = 'invalid-multi-factor-secret';
22
+ const INVALID_TOTP_SECRET_MESSAGE = "can't find secret for provided key";
23
+
24
+ function hasAuthFirebaseErrorCode(error: unknown): error is { code: string } {
25
+ return (
26
+ isObject(error) &&
27
+ 'code' in error &&
28
+ typeof (error as { code?: unknown }).code === 'string' &&
29
+ ((error as { code: string }).code.startsWith('auth/') ||
30
+ (error as { code: string }).code === INVALID_TOTP_SECRET_CODE)
31
+ );
32
+ }
33
+
34
+ function getNativeErrorUserInfo(error: unknown): NativeError['userInfo'] | null {
35
+ if (!isObject(error)) {
36
+ return null;
37
+ }
38
+
39
+ if ('userInfo' in error && isObject((error as NativeError).userInfo)) {
40
+ return (error as NativeError).userInfo;
41
+ }
42
+
43
+ if ('code' in error && 'message' in error) {
44
+ const code = (error as { code?: unknown }).code;
45
+ const message = (error as { message?: unknown }).message;
46
+ if (typeof code === 'string' && typeof message === 'string') {
47
+ return { code, message };
48
+ }
49
+ }
50
+
51
+ return null;
52
+ }
53
+
54
+ /**
55
+ * Converts sync native TurboModule throws into {@link NativeFirebaseError} using the same
56
+ * {@code code}/{@code message} shape as promise rejects.
57
+ */
58
+ export function rethrowAuthSyncNativeError(error: unknown): never {
59
+ if (error instanceof NativeFirebaseError) {
60
+ throw error;
61
+ }
62
+
63
+ if (hasAuthFirebaseErrorCode(error)) {
64
+ throw error;
65
+ }
66
+
67
+ const userInfo = getNativeErrorUserInfo(error);
68
+ if (userInfo?.code && userInfo.message) {
69
+ throw new NativeFirebaseError({ userInfo }, new Error().stack!, 'auth');
70
+ }
71
+
72
+ const message = error instanceof Error ? error.message : String(error);
73
+ const name = error instanceof Error ? error.name : undefined;
74
+
75
+ if (message === INVALID_TOTP_SECRET_MESSAGE || name === INVALID_TOTP_SECRET_CODE) {
76
+ throw new NativeFirebaseError(
77
+ {
78
+ userInfo: {
79
+ code: INVALID_TOTP_SECRET_CODE,
80
+ message: INVALID_TOTP_SECRET_MESSAGE,
81
+ },
82
+ },
83
+ new Error().stack!,
84
+ 'auth',
85
+ );
86
+ }
87
+
88
+ throw error;
89
+ }
@@ -1,27 +1,35 @@
1
- import { reload } from './modular';
2
1
  import type { MultiFactorAssertion as ModularMultiFactorAssertion, User } from './types/auth';
3
- import type { FirebaseAuthTypes } from './types/namespaced';
4
- import type { AuthInternal, MultiFactorEnrollmentAssertionInternal } from './types/internal';
2
+ import type {
3
+ MultiFactorInfo,
4
+ MultiFactorSession,
5
+ MultiFactorUser as MultiFactorUserType,
6
+ MultiFactorAssertion,
7
+ } from './types/auth';
8
+ import type {
9
+ AuthInternal,
10
+ MultiFactorEnrollmentAssertionInternal,
11
+ UserInternal,
12
+ } from './types/internal';
5
13
 
6
14
  type MultiFactorAuthHost = {
7
- currentUser: FirebaseAuthTypes.User | null;
15
+ currentUser: User | null;
8
16
  native: AuthInternal['native'];
9
17
  };
10
18
  /**
11
19
  * Return a MultiFactorUser instance the gateway to multi-factor operations.
12
20
  */
13
- export function multiFactor(auth: MultiFactorAuthHost): FirebaseAuthTypes.MultiFactorUser {
21
+ export function multiFactor(auth: MultiFactorAuthHost): MultiFactorUserType {
14
22
  return new MultiFactorUser(auth);
15
23
  }
16
24
 
17
25
  export class MultiFactorUser {
18
- readonly enrolledFactors: FirebaseAuthTypes.MultiFactorInfo[];
26
+ readonly enrolledFactors: MultiFactorInfo[];
19
27
  private readonly _auth: MultiFactorAuthHost;
20
28
 
21
- constructor(auth: MultiFactorAuthHost, user?: FirebaseAuthTypes.User) {
29
+ constructor(auth: MultiFactorAuthHost, user?: User) {
22
30
  this._auth = auth;
23
31
  if (user === undefined) {
24
- user = auth.currentUser as FirebaseAuthTypes.User;
32
+ user = auth.currentUser as User;
25
33
  }
26
34
 
27
35
  if (!user) {
@@ -31,7 +39,7 @@ export class MultiFactorUser {
31
39
  this.enrolledFactors = user.multiFactor?.enrolledFactors ?? [];
32
40
  }
33
41
 
34
- getSession(): Promise<FirebaseAuthTypes.MultiFactorSession> {
42
+ getSession(): Promise<MultiFactorSession> {
35
43
  return this._auth.native.getSession();
36
44
  }
37
45
 
@@ -41,7 +49,7 @@ export class MultiFactorUser {
41
49
  * profile, which is necessary to see the multi-factor changes.
42
50
  */
43
51
  async enroll(
44
- multiFactorAssertion: FirebaseAuthTypes.MultiFactorAssertion | ModularMultiFactorAssertion,
52
+ multiFactorAssertion: MultiFactorAssertion | ModularMultiFactorAssertion,
45
53
  displayName?: string | null,
46
54
  ): Promise<void> {
47
55
  const assertion = multiFactorAssertion as MultiFactorEnrollmentAssertionInternal;
@@ -65,16 +73,17 @@ export class MultiFactorUser {
65
73
 
66
74
  // We need to reload the user otherwise the changes are not visible
67
75
  // TODO reload not working on Other platform
68
- await reload(this._auth.currentUser as unknown as User);
76
+ const currentUser = this._auth.currentUser as UserInternal | null;
77
+ if (currentUser) {
78
+ await currentUser.reload();
79
+ }
69
80
  }
70
81
 
71
- async unenroll(enrollmentId: FirebaseAuthTypes.MultiFactorInfo | string): Promise<void> {
72
- await this._auth.native.unenrollMultiFactor(
73
- enrollmentId as string | FirebaseAuthTypes.MultiFactorInfo,
74
- );
82
+ async unenroll(enrollmentId: MultiFactorInfo | string): Promise<void> {
83
+ await this._auth.native.unenrollMultiFactor(enrollmentId as string | MultiFactorInfo);
75
84
 
76
85
  if (this._auth.currentUser) {
77
- await reload(this._auth.currentUser as unknown as User);
86
+ await (this._auth.currentUser as UserInternal).reload();
78
87
  }
79
88
  }
80
89
  }
@@ -16,6 +16,7 @@
16
16
  */
17
17
 
18
18
  import { createPhoneAuthCredential } from '../credentials';
19
+ import type { AuthInternal } from '../types/internal';
19
20
  import type {
20
21
  ApplicationVerifier,
21
22
  Auth,
@@ -35,20 +36,7 @@ type FirebaseError = AuthError;
35
36
 
36
37
  const providerId = 'phone' as const;
37
38
 
38
- type PhoneAuthProviderAuth = {
39
- app: {
40
- auth(): {
41
- verifyPhoneNumber(phoneNumber: string): PhoneAuthListener;
42
- verifyPhoneNumberWithMultiFactorInfo(
43
- hint: Pick<MultiFactorInfo, 'uid'>,
44
- session: PhoneMultiFactorSignInInfoOptions['session'],
45
- ): Promise<string>;
46
- verifyPhoneNumberForMultiFactor(
47
- phoneInfoOptions: PhoneMultiFactorEnrollInfoOptions,
48
- ): Promise<string>;
49
- };
50
- };
51
- };
39
+ type PhoneAuthProviderAuth = AuthInternal;
52
40
 
53
41
  function isPhoneMultiFactorSignInOptions(
54
42
  phoneInfoOptions: PhoneInfoOptions,
@@ -131,7 +119,7 @@ export default class PhoneAuthProvider {
131
119
  _appVerifier?: ApplicationVerifier,
132
120
  ): Promise<string> {
133
121
  if (typeof phoneInfoOptions === 'string') {
134
- return verificationIdFromListener(this._auth.app.auth().verifyPhoneNumber(phoneInfoOptions));
122
+ return verificationIdFromListener(this._auth.verifyPhoneNumber(phoneInfoOptions));
135
123
  }
136
124
 
137
125
  if (isPhoneMultiFactorSignInOptions(phoneInfoOptions)) {
@@ -139,19 +127,18 @@ export default class PhoneAuthProvider {
139
127
  uid: phoneInfoOptions.multiFactorUid!,
140
128
  };
141
129
 
142
- return this._auth.app
143
- .auth()
144
- .verifyPhoneNumberWithMultiFactorInfo(multiFactorHint, phoneInfoOptions.session);
130
+ return this._auth.verifyPhoneNumberWithMultiFactorInfo(
131
+ multiFactorHint as MultiFactorInfo,
132
+ phoneInfoOptions.session,
133
+ );
145
134
  }
146
135
 
147
136
  if (isPhoneMultiFactorEnrollOptions(phoneInfoOptions)) {
148
- return this._auth.app.auth().verifyPhoneNumberForMultiFactor(phoneInfoOptions);
137
+ return this._auth.verifyPhoneNumberForMultiFactor(phoneInfoOptions);
149
138
  }
150
139
 
151
140
  if (isPhoneSingleFactorOptions(phoneInfoOptions)) {
152
- return verificationIdFromListener(
153
- this._auth.app.auth().verifyPhoneNumber(phoneInfoOptions.phoneNumber),
154
- );
141
+ return verificationIdFromListener(this._auth.verifyPhoneNumber(phoneInfoOptions.phoneNumber));
155
142
  }
156
143
 
157
144
  throw new Error(
package/lib/types/auth.ts CHANGED
@@ -284,6 +284,8 @@ export interface User extends UserInfo {
284
284
  readonly providerData: UserInfo[];
285
285
  readonly refreshToken: string;
286
286
  readonly tenantId: string | null;
287
+ /** Present on native user instances returned from auth state listeners. */
288
+ readonly multiFactor?: MultiFactor | null;
287
289
  delete(): Promise<void>;
288
290
  getIdToken(forceRefresh?: boolean): Promise<string>;
289
291
  getIdTokenResult(forceRefresh?: boolean): Promise<IdTokenResult>;
@@ -391,3 +393,16 @@ export type PhoneInfoOptions =
391
393
  export interface TotpMultiFactorAssertion extends MultiFactorAssertion {}
392
394
 
393
395
  export interface TotpMultiFactorInfo extends MultiFactorInfo {}
396
+
397
+ export type AuthListenerCallback = (user: User | null) => void;
398
+
399
+ export type CallbackOrObserver<T extends (...args: any[]) => any> = T | { next: T };
400
+
401
+ export interface UpdateProfile {
402
+ displayName?: string | null;
403
+ photoURL?: string | null;
404
+ }
405
+
406
+ export interface MultiFactor {
407
+ enrolledFactors: MultiFactorInfo[];
408
+ }
@@ -25,26 +25,23 @@ import type EventEmitter from 'react-native/Libraries/vendor/emitter/EventEmitte
25
25
  import type {
26
26
  ActionCodeInfo,
27
27
  ActionCodeSettings,
28
+ AdditionalUserInfo,
28
29
  Auth,
29
30
  AuthCredential,
30
31
  AuthProvider,
32
+ ConfirmationResult,
31
33
  IdTokenResult,
34
+ MultiFactor,
32
35
  MultiFactorAssertion,
36
+ MultiFactorInfo,
37
+ MultiFactorResolver,
38
+ MultiFactorSession,
33
39
  PhoneAuthListener,
34
40
  User,
35
41
  UserCredential,
36
42
  } from './auth';
37
- import type { CallbackOrObserver, FirebaseAuthTypes } from './namespaced';
38
43
 
39
- export type AuthModularDeprecationArg = string;
40
-
41
- export type WithAuthDeprecationArg<F> = F extends (...args: infer P) => infer R
42
- ? (...args: [...P, AuthModularDeprecationArg]) => R
43
- : never;
44
-
45
- export interface AppWithAuthInternal {
46
- auth(deprecationArg?: AuthModularDeprecationArg): Auth;
47
- }
44
+ export type { CallbackOrObserver } from './auth';
48
45
 
49
46
  export type AuthListenerCallbackInternal = (user: User | null) => void;
50
47
 
@@ -53,14 +50,14 @@ export type AuthProviderWithObjectInternal = AuthProvider & {
53
50
  };
54
51
 
55
52
  export type UserCredentialWithAdditionalUserInfoInternal = UserCredential & {
56
- user: FirebaseAuthTypes.User;
57
- additionalUserInfo?: FirebaseAuthTypes.AdditionalUserInfo;
53
+ user: User;
54
+ additionalUserInfo?: AdditionalUserInfo;
58
55
  };
59
56
 
60
- export type UserCredentialResultInternal = FirebaseAuthTypes.UserCredential &
57
+ export type UserCredentialResultInternal = UserCredential &
61
58
  Partial<Pick<UserCredential, 'operationType' | 'providerId'>>;
62
59
 
63
- export type ActionCodeInfoResultInternal = FirebaseAuthTypes.ActionCodeInfo | ActionCodeInfo;
60
+ export type ActionCodeInfoResultInternal = ActionCodeInfo;
64
61
 
65
62
  export type ConfirmationResultResultInternal = {
66
63
  verificationId: string | null;
@@ -68,23 +65,18 @@ export type ConfirmationResultResultInternal = {
68
65
  };
69
66
 
70
67
  export type MultiFactorResolverResultInternal = {
71
- hints: FirebaseAuthTypes.MultiFactorInfo[];
72
- session: FirebaseAuthTypes.MultiFactorSession;
73
- resolveSignIn(
74
- assertion: FirebaseAuthTypes.MultiFactorAssertion | MultiFactorAssertion,
75
- ): Promise<UserCredentialResultInternal>;
68
+ hints: MultiFactorInfo[];
69
+ session: MultiFactorSession;
70
+ resolveSignIn(assertion: MultiFactorAssertion): Promise<UserCredentialResultInternal>;
76
71
  };
77
72
 
78
- export type MultiFactorUserSourceInternal = FirebaseAuthTypes.User;
73
+ export type MultiFactorUserSourceInternal = User;
79
74
 
80
75
  export type MultiFactorUserResultInternal = {
81
- enrolledFactors: FirebaseAuthTypes.MultiFactorInfo[];
82
- getSession(): Promise<FirebaseAuthTypes.MultiFactorSession>;
83
- enroll(
84
- assertion: FirebaseAuthTypes.MultiFactorAssertion | MultiFactorAssertion,
85
- displayName?: string | null,
86
- ): Promise<void>;
87
- unenroll(option: FirebaseAuthTypes.MultiFactorInfo | string): Promise<void>;
76
+ enrolledFactors: MultiFactorInfo[];
77
+ getSession(): Promise<MultiFactorSession>;
78
+ enroll(assertion: MultiFactorAssertion, displayName?: string | null): Promise<void>;
79
+ unenroll(option: MultiFactorInfo | string): Promise<void>;
88
80
  };
89
81
 
90
82
  export type MultiFactorEnrollmentAssertionInternal =
@@ -123,14 +115,14 @@ export interface NativeUserInternal {
123
115
  emailVerified?: boolean;
124
116
  isAnonymous?: boolean;
125
117
  metadata: NativeUserMetadataInternal;
126
- multiFactor?: FirebaseAuthTypes.MultiFactor | null;
118
+ multiFactor?: MultiFactor | null;
127
119
  phoneNumber?: string | null;
128
120
  photoURL?: string | null;
129
121
  tenantId?: string | null;
130
122
  }
131
123
 
132
124
  export interface NativeUserCredentialInternal {
133
- additionalUserInfo?: FirebaseAuthTypes.AdditionalUserInfo;
125
+ additionalUserInfo?: AdditionalUserInfo;
134
126
  user: NativeUserInternal;
135
127
  }
136
128
 
@@ -247,21 +239,18 @@ export interface RNFBAuthModule {
247
239
  timeout?: number,
248
240
  forceResend?: boolean,
249
241
  ): void | Promise<void>;
250
- verifyPhoneNumberWithMultiFactorInfo(
251
- uid: string,
252
- session: FirebaseAuthTypes.MultiFactorSession,
253
- ): Promise<string>;
242
+ verifyPhoneNumberWithMultiFactorInfo(uid: string, session: MultiFactorSession): Promise<string>;
254
243
  verifyPhoneNumberForMultiFactor(
255
244
  phoneNumber: string,
256
- session: FirebaseAuthTypes.MultiFactorSession,
245
+ session: MultiFactorSession,
257
246
  ): Promise<string>;
258
247
  resolveMultiFactorSignIn(
259
- session: FirebaseAuthTypes.MultiFactorSession,
248
+ session: MultiFactorSession,
260
249
  verificationId: string,
261
250
  verificationCode: string,
262
251
  ): Promise<NativeUserCredentialInternal>;
263
252
  resolveTotpSignIn(
264
- session: FirebaseAuthTypes.MultiFactorSession,
253
+ session: MultiFactorSession,
265
254
  uid: string,
266
255
  totpSecret: string,
267
256
  ): Promise<NativeUserCredentialInternal>;
@@ -282,17 +271,14 @@ export interface RNFBAuthModule {
282
271
  revokeToken(authorizationCode: string): Promise<void>;
283
272
  sendPasswordResetEmail(
284
273
  email: string,
285
- actionCodeSettings?: FirebaseAuthTypes.ActionCodeSettings | null,
286
- ): Promise<void>;
287
- sendSignInLinkToEmail(
288
- email: string,
289
- actionCodeSettings?: FirebaseAuthTypes.ActionCodeSettings,
274
+ actionCodeSettings?: ActionCodeSettings | null,
290
275
  ): Promise<void>;
291
- isSignInWithEmailLink(emailLink: string): Promise<boolean>;
276
+ sendSignInLinkToEmail(email: string, actionCodeSettings?: ActionCodeSettings): Promise<void>;
277
+ isSignInWithEmailLink(emailLink: string): boolean;
292
278
  signInWithEmailLink(email: string, emailLink?: string): Promise<NativeUserCredentialInternal>;
293
279
  confirmPasswordReset(code: string, newPassword: string): Promise<void>;
294
280
  applyActionCode(code: string): Promise<NativeUserInternal | null | undefined>;
295
- checkActionCode(code: string): Promise<FirebaseAuthTypes.ActionCodeInfo>;
281
+ checkActionCode(code: string): Promise<ActionCodeInfo>;
296
282
  fetchSignInMethodsForEmail(email: string): Promise<string[]>;
297
283
  verifyPasswordResetCode(code: string): Promise<string>;
298
284
  useUserAccessGroup(userAccessGroup: string): Promise<null | void>;
@@ -300,7 +286,7 @@ export interface RNFBAuthModule {
300
286
  useEmulator(host: string, port?: number): void;
301
287
  getCustomAuthDomain(): Promise<string>;
302
288
  confirmationResultConfirm(verificationCode: string): Promise<NativeUserCredentialInternal>;
303
- delete(): Promise<void>;
289
+ deleteUser(): Promise<void>;
304
290
  getIdToken(forceRefresh: boolean): Promise<string>;
305
291
  getIdTokenResult(forceRefresh: boolean): Promise<IdTokenResult>;
306
292
  linkWithCredential(
@@ -318,9 +304,7 @@ export interface RNFBAuthModule {
318
304
  provider: Record<string, unknown>,
319
305
  ): Promise<NativeUserCredentialInternal>;
320
306
  reload(): Promise<NativeUserInternal>;
321
- sendEmailVerification(
322
- actionCodeSettings?: FirebaseAuthTypes.ActionCodeSettings,
323
- ): Promise<NativeUserInternal>;
307
+ sendEmailVerification(actionCodeSettings?: ActionCodeSettings): Promise<NativeUserInternal>;
324
308
  unlink(providerId: string): Promise<NativeUserInternal>;
325
309
  updateEmail(email: string): Promise<NativeUserInternal>;
326
310
  updatePassword(password: string): Promise<NativeUserInternal>;
@@ -335,22 +319,22 @@ export interface RNFBAuthModule {
335
319
  }): Promise<NativeUserInternal>;
336
320
  verifyBeforeUpdateEmail(
337
321
  newEmail: string,
338
- actionCodeSettings?: FirebaseAuthTypes.ActionCodeSettings,
322
+ actionCodeSettings?: ActionCodeSettings,
339
323
  ): Promise<NativeUserInternal>;
340
324
  forceRecaptchaFlowForTesting(forceRecaptchaFlow: boolean): void | Promise<void>;
341
325
  setAppVerificationDisabledForTesting(disabled: boolean): void | Promise<void>;
342
326
  setAutoRetrievedSmsCodeForPhoneNumber(phoneNumber: string, smsCode: string): Promise<null>;
343
- getSession(): Promise<FirebaseAuthTypes.MultiFactorSession>;
327
+ getSession(): Promise<MultiFactorSession>;
344
328
  finalizeMultiFactorEnrollment(token: string, secret: string, displayName?: string): Promise<void>;
345
329
  finalizeTotpEnrollment(
346
330
  totpSecret: string,
347
331
  verificationCode: string,
348
332
  displayName?: string,
349
333
  ): Promise<void>;
350
- unenrollMultiFactor(enrollmentId: string | FirebaseAuthTypes.MultiFactorInfo): Promise<void>;
334
+ unenrollMultiFactor(enrollmentId: string | MultiFactorInfo): Promise<void>;
351
335
  getMultiFactorResolver(error: unknown): MultiFactorResolverResultInternal | null;
352
- generateTotpSecret(session: FirebaseAuthTypes.MultiFactorSession): Promise<{ secretKey: string }>;
353
- generateQrCodeUrl(secretKey: string, accountName: string, issuer: string): Promise<string>;
336
+ generateTotpSecret(session: MultiFactorSession): Promise<{ secretKey: string }>;
337
+ generateQrCodeUrl(secretKey: string, accountName: string, issuer: string): string;
354
338
  openInOtpApp(secretKey: string, qrCodeUrl: string): string | void;
355
339
  assertionForSignIn(
356
340
  uid: string,
@@ -360,7 +344,7 @@ export interface RNFBAuthModule {
360
344
 
361
345
  export type AuthInternal = Auth & {
362
346
  app: ReactNativeFirebase.FirebaseApp;
363
- currentUser: FirebaseAuthTypes.User | null;
347
+ currentUser: User | null;
364
348
  applyActionCode(code: string): Promise<void>;
365
349
  checkActionCode(code: string): Promise<ActionCodeInfoResultInternal>;
366
350
  confirmPasswordReset(code: string, newPassword: string): Promise<void>;
@@ -371,12 +355,12 @@ export type AuthInternal = Auth & {
371
355
  fetchSignInMethodsForEmail(email: string): Promise<string[]>;
372
356
  getCustomAuthDomain(): Promise<string>;
373
357
  getMultiFactorResolver(error: unknown): MultiFactorResolverResultInternal | null;
374
- isSignInWithEmailLink(emailLink: string): Promise<boolean>;
358
+ isSignInWithEmailLink(emailLink: string): boolean;
375
359
  onAuthStateChanged(
376
- listenerOrObserver: CallbackOrObserver<AuthListenerCallbackInternal>,
360
+ listenerOrObserver: import('./auth').CallbackOrObserver<AuthListenerCallbackInternal>,
377
361
  ): () => void;
378
362
  onIdTokenChanged(
379
- listenerOrObserver: CallbackOrObserver<AuthListenerCallbackInternal>,
363
+ listenerOrObserver: import('./auth').CallbackOrObserver<AuthListenerCallbackInternal>,
380
364
  ): () => void;
381
365
  sendPasswordResetEmail(
382
366
  email: string,
@@ -415,6 +399,13 @@ export type AuthInternal = Auth & {
415
399
  autoVerifyTimeoutOrForceResend?: number | boolean,
416
400
  forceResend?: boolean,
417
401
  ): PhoneAuthListener;
402
+ verifyPhoneNumberWithMultiFactorInfo(
403
+ multiFactorHint: MultiFactorInfo,
404
+ session: MultiFactorSession,
405
+ ): Promise<string>;
406
+ verifyPhoneNumberForMultiFactor(
407
+ phoneInfoOptions: import('./auth').PhoneMultiFactorEnrollInfoOptions,
408
+ ): Promise<string>;
418
409
  verifyPasswordResetCode(code: string): Promise<string>;
419
410
  revokeToken(authorizationCode: string): Promise<void>;
420
411
  native: RNFBAuthModule;
@@ -424,23 +415,23 @@ export type AuthInternal = Auth & {
424
415
  _tenantId: string | null;
425
416
  _projectPasswordPolicy: PasswordPolicyInternal | null;
426
417
  _tenantPasswordPolicies: Record<string, PasswordPolicyInternal | null>;
427
- _setUser(user?: NativeUserInternal | null): FirebaseAuthTypes.User | null;
418
+ _setUser(user?: NativeUserInternal | null): User | null;
428
419
  _setUserCredential(
429
420
  userCredential: NativeUserCredentialInternal,
430
421
  ): UserCredentialWithAdditionalUserInfoInternal;
431
422
  resolveMultiFactorSignIn(
432
- session: FirebaseAuthTypes.MultiFactorSession,
423
+ session: MultiFactorSession,
433
424
  verificationId: string,
434
425
  verificationCode: string,
435
426
  ): Promise<UserCredentialWithAdditionalUserInfoInternal>;
436
427
  resolveTotpSignIn(
437
- session: FirebaseAuthTypes.MultiFactorSession,
428
+ session: MultiFactorSession,
438
429
  uid: string,
439
430
  totpSecret: string,
440
431
  ): Promise<UserCredentialWithAdditionalUserInfoInternal>;
441
432
  } & PasswordPolicyMixinInternal;
442
433
 
443
- export type UserInternal = FirebaseAuthTypes.User & {
434
+ export type UserInternal = User & {
444
435
  _auth?: AuthInternal;
445
436
  _user?: NativeUserInternal;
446
437
  getIdTokenResult(forceRefresh?: boolean): Promise<IdTokenResult>;
@@ -469,11 +460,11 @@ export type UserInternal = FirebaseAuthTypes.User & {
469
460
  verifyBeforeUpdateEmail(newEmail: string, actionCodeSettings?: ActionCodeSettings): Promise<void>;
470
461
  };
471
462
 
472
- export type ConfirmationResultInternal = FirebaseAuthTypes.ConfirmationResult;
473
- export type MultiFactorResolverInternal = FirebaseAuthTypes.MultiFactorResolver;
463
+ export type ConfirmationResultInternal = ConfirmationResult;
464
+ export type MultiFactorResolverInternal = MultiFactorResolver;
474
465
 
475
466
  declare module '@react-native-firebase/app/dist/module/internal/NativeModules' {
476
467
  interface ReactNativeFirebaseNativeModules {
477
- RNFBAuthModule: RNFBAuthModule;
468
+ NativeRNFBTurboAuth: RNFBAuthModule;
478
469
  }
479
470
  }
package/lib/version.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  // Generated by genversion.
2
- export const version = '25.1.0';
2
+ export const version = '26.0.0';
@@ -583,13 +583,15 @@ export default {
583
583
  * Check if a sign in with email link is valid
584
584
  * @param {string} appName - The name of the app to get the auth instance for.
585
585
  * @param {string} emailLink - The email link to sign in with.
586
- * @returns {Promise<boolean>} - Whether the link is a valid sign in with email link.
586
+ * @returns {boolean} - Whether the link is a valid sign in with email link.
587
587
  */
588
- async isSignInWithEmailLink(appName: string, emailLink: string) {
589
- return guard(async () => {
588
+ isSignInWithEmailLink(appName: string, emailLink: string) {
589
+ try {
590
590
  const auth = getCachedAuthInstance(appName);
591
- return await isSignInWithEmailLink(auth, emailLink);
592
- });
591
+ return isSignInWithEmailLink(auth, emailLink);
592
+ } catch (e) {
593
+ throw getWebError(e as Error & { code?: string });
594
+ }
593
595
  },
594
596
 
595
597
  /**
@@ -667,7 +669,7 @@ export default {
667
669
  * @param {string} appName - The name of the app to get the auth instance for.
668
670
  * @returns {Promise<null>}
669
671
  */
670
- async delete(appName: string) {
672
+ async deleteUser(appName: string) {
671
673
  return guard(async () => {
672
674
  const auth = getCachedAuthInstance(appName);
673
675
 
@@ -1254,10 +1256,11 @@ export default {
1254
1256
  generateQrCodeUrl(_appName: string, secretKey: string, accountName?: string, issuer?: string) {
1255
1257
  const totpSecret = totpSecretMap.get(secretKey);
1256
1258
  if (!totpSecret) {
1257
- return rejectPromiseWithCodeAndMessage(
1258
- 'invalid-multi-factor-secret',
1259
- "can't find secret for provided key",
1260
- );
1259
+ throw getWebError({
1260
+ name: 'FirebaseError',
1261
+ code: 'auth/invalid-multi-factor-secret',
1262
+ message: "can't find secret for provided key",
1263
+ });
1261
1264
  }
1262
1265
  return totpSecret.generateQrCodeUrl(accountName, issuer);
1263
1266
  },
package/package.json CHANGED
@@ -1,17 +1,34 @@
1
1
  {
2
2
  "name": "@react-native-firebase/auth",
3
- "version": "25.1.0",
3
+ "version": "26.0.0",
4
4
  "author": "Invertase <oss@invertase.io> (http://invertase.io)",
5
5
  "description": "React Native Firebase - The authentication module provides an easy-to-use API to integrate an authentication workflow into new and existing applications. React Native Firebase provides access to all Firebase authentication methods and identity providers.",
6
6
  "main": "./dist/module/index.js",
7
7
  "types": "./dist/typescript/lib/index.d.ts",
8
+ "codegenConfig": {
9
+ "name": "RNFBAuthTurboModules",
10
+ "type": "modules",
11
+ "jsSrcsDir": "specs",
12
+ "includesGeneratedCode": true,
13
+ "android": {
14
+ "javaPackageName": "io.invertase.firebase.auth"
15
+ },
16
+ "ios": {
17
+ "modulesProvider": {
18
+ "NativeRNFBTurboAuth": "RNFBAuthModule"
19
+ }
20
+ }
21
+ },
8
22
  "scripts": {
9
23
  "build": "genversion --esm --semi lib/version.ts",
10
24
  "build:clean": "rimraf android/build && rimraf ios/build",
11
25
  "build:plugin": "rimraf plugin/build && tsc --build plugin",
12
26
  "compile": "bob build",
13
27
  "lint:plugin": "eslint plugin/src/*",
14
- "prepare": "yarn run build && yarn compile && yarn run build:plugin"
28
+ "prepare": "yarn run build && yarn compile && yarn run build:plugin",
29
+ "codegen": "yarn android:codegen && yarn ios:codegen",
30
+ "android:codegen": "npx @react-native-community/cli codegen --platform android --outputPath=./android/src/main/java/io/invertase/firebase/auth/generated",
31
+ "ios:codegen": "npx @react-native-community/cli codegen --platform ios --outputPath=./ios/generated"
15
32
  },
16
33
  "repository": {
17
34
  "type": "git",
@@ -28,10 +45,11 @@
28
45
  "plist": "^3.1.1"
29
46
  },
30
47
  "peerDependencies": {
31
- "@react-native-firebase/app": "25.1.0",
48
+ "@react-native-firebase/app": "26.0.0",
32
49
  "expo": ">=47.0.0"
33
50
  },
34
51
  "devDependencies": {
52
+ "@react-native-firebase/app": "26.0.0",
35
53
  "@types/plist": "^3.0.5",
36
54
  "expo": "^55.0.18",
37
55
  "react-native-builder-bob": "^0.40.13"
@@ -51,7 +69,14 @@
51
69
  "types": "./dist/typescript/lib/index.d.ts",
52
70
  "default": "./dist/module/index.js"
53
71
  },
54
- "./app.plugin.js": "./app.plugin.js",
72
+ "./app.plugin": {
73
+ "types": "./plugin/build/app.plugin.d.ts",
74
+ "default": "./app.plugin.js"
75
+ },
76
+ "./app.plugin.js": {
77
+ "types": "./plugin/build/app.plugin.d.ts",
78
+ "default": "./app.plugin.js"
79
+ },
55
80
  "./package.json": "./package.json"
56
81
  },
57
82
  "react-native-builder-bob": {
@@ -76,5 +101,5 @@
76
101
  "node_modules/",
77
102
  "dist/"
78
103
  ],
79
- "gitHead": "e0a565d8a73a9b103d140ffacfb8876b30d8bdc5"
104
+ "gitHead": "2a360acb2aebdd39dd40e31be386b30697270626"
80
105
  }
@@ -0,0 +1,2 @@
1
+ import plugin from './index';
2
+ export = plugin;
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ const index_1 = __importDefault(require("./index"));
6
+ module.exports = index_1.default;