@react-native-firebase/auth 25.1.0 → 26.1.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.
- package/CHANGELOG.md +35 -0
- package/RNFBAuth.podspec +16 -7
- package/android/build.gradle +23 -0
- package/android/src/main/java/io/invertase/firebase/auth/{ReactNativeFirebaseAuthModule.java → NativeRNFBTurboAuth.java} +131 -103
- package/android/src/main/java/io/invertase/firebase/auth/ReactNativeFirebaseAuthPackage.java +1 -1
- package/android/src/main/java/io/invertase/firebase/auth/ReactNativeFirebaseAuthSyncException.java +35 -0
- package/android/src/main/java/io/invertase/firebase/auth/generated/java/com/facebook/fbreact/specs/NativeRNFBTurboAuthSpec.java +308 -0
- package/android/src/main/java/io/invertase/firebase/auth/generated/jni/CMakeLists.txt +36 -0
- package/android/src/main/java/io/invertase/firebase/auth/generated/jni/RNFBAuthTurboModules-generated.cpp +392 -0
- package/android/src/main/java/io/invertase/firebase/auth/generated/jni/RNFBAuthTurboModules.h +31 -0
- package/android/src/main/java/io/invertase/firebase/auth/generated/jni/react/renderer/components/RNFBAuthTurboModules/RNFBAuthTurboModulesJSI-generated.cpp +539 -0
- package/android/src/main/java/io/invertase/firebase/auth/generated/jni/react/renderer/components/RNFBAuthTurboModules/RNFBAuthTurboModulesJSI.h +611 -0
- package/app.plugin.js +1 -1
- package/dist/module/ConfirmationResult.js.map +1 -1
- package/dist/module/MultiFactorResolver.js.map +1 -1
- package/dist/module/PhoneAuthListener.js +3 -4
- package/dist/module/PhoneAuthListener.js.map +1 -1
- package/dist/module/TotpMultiFactorGenerator.js +1 -1
- package/dist/module/TotpMultiFactorGenerator.js.map +1 -1
- package/dist/module/TotpSecret.js +15 -9
- package/dist/module/TotpSecret.js.map +1 -1
- package/dist/module/User.js +1 -1
- package/dist/module/User.js.map +1 -1
- package/dist/module/credentials/OAuthCredential.js +22 -1
- package/dist/module/credentials/OAuthCredential.js.map +1 -1
- package/dist/module/getMultiFactorResolver.js +2 -2
- package/dist/module/getMultiFactorResolver.js.map +1 -1
- package/dist/module/index.js +1226 -6
- package/dist/module/index.js.map +1 -1
- package/dist/module/internal/syncNativeError.js +75 -0
- package/dist/module/internal/syncNativeError.js.map +1 -0
- package/dist/module/multiFactor.js +5 -3
- package/dist/module/multiFactor.js.map +1 -1
- package/dist/module/providers/AppleAuthProvider.js +17 -4
- package/dist/module/providers/AppleAuthProvider.js.map +1 -1
- package/dist/module/providers/OAuthProvider.js +4 -2
- package/dist/module/providers/OAuthProvider.js.map +1 -1
- package/dist/module/providers/PhoneAuthProvider.js +4 -4
- package/dist/module/providers/PhoneAuthProvider.js.map +1 -1
- package/dist/module/types/auth.js +8 -0
- package/dist/module/types/auth.js.map +1 -1
- package/dist/module/version.js +1 -1
- package/dist/module/web/RNFBAuthModule.js +26 -18
- package/dist/module/web/RNFBAuthModule.js.map +1 -1
- package/dist/typescript/lib/ConfirmationResult.d.ts +2 -2
- package/dist/typescript/lib/ConfirmationResult.d.ts.map +1 -1
- package/dist/typescript/lib/MultiFactorResolver.d.ts +6 -6
- package/dist/typescript/lib/MultiFactorResolver.d.ts.map +1 -1
- package/dist/typescript/lib/PhoneAuthListener.d.ts +1 -4
- package/dist/typescript/lib/PhoneAuthListener.d.ts.map +1 -1
- package/dist/typescript/lib/TotpSecret.d.ts +2 -4
- package/dist/typescript/lib/TotpSecret.d.ts.map +1 -1
- package/dist/typescript/lib/User.d.ts +13 -13
- package/dist/typescript/lib/User.d.ts.map +1 -1
- package/dist/typescript/lib/credentials/OAuthCredential.d.ts +6 -0
- package/dist/typescript/lib/credentials/OAuthCredential.d.ts.map +1 -1
- package/dist/typescript/lib/getMultiFactorResolver.d.ts +5 -5
- package/dist/typescript/lib/getMultiFactorResolver.d.ts.map +1 -1
- package/dist/typescript/lib/index.d.ts +377 -4
- package/dist/typescript/lib/index.d.ts.map +1 -1
- package/dist/typescript/lib/internal/syncNativeError.d.ts +6 -0
- package/dist/typescript/lib/internal/syncNativeError.d.ts.map +1 -0
- package/dist/typescript/lib/multiFactor.d.ts +9 -9
- package/dist/typescript/lib/multiFactor.d.ts.map +1 -1
- package/dist/typescript/lib/providers/AppleAuthProvider.d.ts +10 -3
- package/dist/typescript/lib/providers/AppleAuthProvider.d.ts.map +1 -1
- package/dist/typescript/lib/providers/OAuthProvider.d.ts.map +1 -1
- package/dist/typescript/lib/providers/PhoneAuthProvider.d.ts.map +1 -1
- package/dist/typescript/lib/types/auth.d.ts +39 -0
- package/dist/typescript/lib/types/auth.d.ts.map +1 -1
- package/dist/typescript/lib/types/internal.d.ts +45 -48
- package/dist/typescript/lib/types/internal.d.ts.map +1 -1
- package/dist/typescript/lib/version.d.ts +1 -1
- package/dist/typescript/lib/web/RNFBAuthModule.d.ts +7 -5
- package/dist/typescript/lib/web/RNFBAuthModule.d.ts.map +1 -1
- package/ios/RNFBAuth/RNFBAuthHelper.h +338 -0
- package/ios/RNFBAuth/{RNFBAuthModule.m → RNFBAuthHelper.m} +605 -323
- package/ios/RNFBAuth/RNFBAuthModule.h +9 -66
- package/ios/RNFBAuth/RNFBAuthModule.mm +592 -0
- package/ios/RNFBAuth.xcodeproj/project.pbxproj +8 -8
- package/ios/generated/RCTAppDependencyProvider.h +25 -0
- package/ios/generated/RCTAppDependencyProvider.mm +55 -0
- package/ios/generated/RCTModulesConformingToProtocolsProvider.h +18 -0
- package/ios/generated/RCTModulesConformingToProtocolsProvider.mm +33 -0
- package/ios/generated/RCTThirdPartyComponentsProvider.h +16 -0
- package/ios/generated/RCTThirdPartyComponentsProvider.mm +23 -0
- package/ios/generated/RNFBAuthTurboModules/RNFBAuthTurboModules-generated.mm +459 -0
- package/ios/generated/RNFBAuthTurboModules/RNFBAuthTurboModules.h +342 -0
- package/ios/generated/RNFBAuthTurboModulesJSI-generated.cpp +539 -0
- package/ios/generated/RNFBAuthTurboModulesJSI.h +611 -0
- package/ios/generated/ReactAppDependencyProvider.podspec +34 -0
- package/lib/ConfirmationResult.ts +3 -6
- package/lib/MultiFactorResolver.ts +8 -8
- package/lib/PhoneAuthListener.ts +6 -10
- package/lib/TotpMultiFactorGenerator.ts +1 -1
- package/lib/TotpSecret.ts +22 -9
- package/lib/User.ts +27 -38
- package/lib/credentials/OAuthCredential.ts +44 -0
- package/lib/getMultiFactorResolver.ts +9 -11
- package/lib/index.ts +1848 -6
- package/lib/internal/syncNativeError.ts +89 -0
- package/lib/multiFactor.ts +25 -16
- package/lib/providers/AppleAuthProvider.ts +21 -5
- package/lib/providers/OAuthProvider.ts +2 -0
- package/lib/providers/PhoneAuthProvider.ts +9 -22
- package/lib/types/auth.ts +42 -0
- package/lib/types/internal.ts +56 -63
- package/lib/version.ts +1 -1
- package/lib/web/RNFBAuthModule.ts +47 -33
- package/package.json +30 -5
- package/plugin/build/app.plugin.d.ts +2 -0
- package/plugin/build/app.plugin.js +6 -0
- package/plugin/src/app.plugin.ts +3 -0
- package/plugin/tsconfig.tsbuildinfo +1 -1
- package/react-native.config.js +9 -0
- package/specs/NativeRNFBTurboAuth.ts +145 -0
- package/typedoc.json +0 -1
- package/dist/module/modular.js +0 -793
- package/dist/module/modular.js.map +0 -1
- package/dist/module/namespaced.js +0 -522
- package/dist/module/namespaced.js.map +0 -1
- package/dist/module/types/namespaced.js +0 -62
- package/dist/module/types/namespaced.js.map +0 -1
- package/dist/typescript/lib/modular.d.ts +0 -370
- package/dist/typescript/lib/modular.d.ts.map +0 -1
- package/dist/typescript/lib/namespaced.d.ts +0 -12
- package/dist/typescript/lib/namespaced.d.ts.map +0 -1
- package/dist/typescript/lib/types/namespaced.d.ts +0 -2185
- package/dist/typescript/lib/types/namespaced.d.ts.map +0 -1
- package/lib/modular.ts +0 -1166
- package/lib/namespaced.ts +0 -849
- 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
|
+
}
|
package/lib/multiFactor.ts
CHANGED
|
@@ -1,27 +1,35 @@
|
|
|
1
|
-
import { reload } from './modular';
|
|
2
1
|
import type { MultiFactorAssertion as ModularMultiFactorAssertion, User } from './types/auth';
|
|
3
|
-
import type {
|
|
4
|
-
|
|
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:
|
|
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):
|
|
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:
|
|
26
|
+
readonly enrolledFactors: MultiFactorInfo[];
|
|
19
27
|
private readonly _auth: MultiFactorAuthHost;
|
|
20
28
|
|
|
21
|
-
constructor(auth: MultiFactorAuthHost, user?:
|
|
29
|
+
constructor(auth: MultiFactorAuthHost, user?: User) {
|
|
22
30
|
this._auth = auth;
|
|
23
31
|
if (user === undefined) {
|
|
24
|
-
user = auth.currentUser as
|
|
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<
|
|
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:
|
|
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
|
-
|
|
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:
|
|
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
|
|
86
|
+
await (this._auth.currentUser as UserInternal).reload();
|
|
78
87
|
}
|
|
79
88
|
}
|
|
80
89
|
}
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
*
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
import {
|
|
19
|
-
import type {
|
|
18
|
+
import { OAuthCredential } from '../credentials';
|
|
19
|
+
import type { AppleFullPersonName } from '../types/auth';
|
|
20
20
|
|
|
21
21
|
const providerId = 'apple.com' as const;
|
|
22
22
|
|
|
@@ -26,7 +26,7 @@ const providerId = 'apple.com' as const;
|
|
|
26
26
|
* @example
|
|
27
27
|
* ```js
|
|
28
28
|
* const provider = new OAuthProvider('apple.com');
|
|
29
|
-
* const credential = provider.credential({ idToken, rawNonce });
|
|
29
|
+
* const credential = provider.credential({ idToken, rawNonce, fullName });
|
|
30
30
|
* ```
|
|
31
31
|
*/
|
|
32
32
|
export default class AppleAuthProvider {
|
|
@@ -38,7 +38,23 @@ export default class AppleAuthProvider {
|
|
|
38
38
|
return providerId;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
/**
|
|
42
|
+
* @param token The Apple identity token.
|
|
43
|
+
* @param secret The raw nonce used to obtain the identity token.
|
|
44
|
+
* @param fullName The user's full name, as shared by Sign in with Apple on the user's first
|
|
45
|
+
* authorization. See {@link OAuthCredentialOptions.fullName} for platform support.
|
|
46
|
+
*/
|
|
47
|
+
static credential(
|
|
48
|
+
token: string,
|
|
49
|
+
secret?: string,
|
|
50
|
+
fullName?: AppleFullPersonName,
|
|
51
|
+
): OAuthCredential {
|
|
52
|
+
return new OAuthCredential(providerId, {
|
|
53
|
+
idToken: token,
|
|
54
|
+
rawNonce: secret,
|
|
55
|
+
fullName,
|
|
56
|
+
bridgeToken: token,
|
|
57
|
+
bridgeSecret: secret ?? '',
|
|
58
|
+
});
|
|
43
59
|
}
|
|
44
60
|
}
|
|
@@ -94,6 +94,7 @@ export default class OAuthProvider {
|
|
|
94
94
|
idToken: credential.idToken,
|
|
95
95
|
accessToken: credential.accessToken,
|
|
96
96
|
rawNonce: credential.rawNonce ?? credential.nonce,
|
|
97
|
+
fullName: credential.fullName,
|
|
97
98
|
});
|
|
98
99
|
}
|
|
99
100
|
|
|
@@ -112,6 +113,7 @@ export default class OAuthProvider {
|
|
|
112
113
|
idToken: params.idToken,
|
|
113
114
|
accessToken: params.accessToken,
|
|
114
115
|
rawNonce: params.rawNonce,
|
|
116
|
+
fullName: params.fullName,
|
|
115
117
|
});
|
|
116
118
|
}
|
|
117
119
|
|
|
@@ -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.
|
|
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.
|
|
143
|
-
|
|
144
|
-
|
|
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.
|
|
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
|
@@ -169,10 +169,37 @@ export interface ApplicationVerifier {
|
|
|
169
169
|
|
|
170
170
|
export type CustomParameters = Record<string, string>;
|
|
171
171
|
|
|
172
|
+
/**
|
|
173
|
+
* The user's full name, as shared by Sign in with Apple.
|
|
174
|
+
*
|
|
175
|
+
* Apple only shares this data on the user's first authorization for a given app; it is
|
|
176
|
+
* omitted from the `ASAuthorizationAppleIDCredential` on subsequent sign-ins, so it should be
|
|
177
|
+
* captured and forwarded on the first sign-in.
|
|
178
|
+
*/
|
|
179
|
+
export interface AppleFullPersonName {
|
|
180
|
+
namePrefix?: string | null;
|
|
181
|
+
givenName?: string | null;
|
|
182
|
+
middleName?: string | null;
|
|
183
|
+
familyName?: string | null;
|
|
184
|
+
nameSuffix?: string | null;
|
|
185
|
+
nickname?: string | null;
|
|
186
|
+
}
|
|
187
|
+
|
|
172
188
|
export interface OAuthCredentialOptions {
|
|
173
189
|
idToken?: string;
|
|
174
190
|
accessToken?: string;
|
|
175
191
|
rawNonce?: string;
|
|
192
|
+
/**
|
|
193
|
+
* The user's full name, as shared by Sign in with Apple on the user's first authorization.
|
|
194
|
+
*
|
|
195
|
+
* @remarks Only retained for `apple.com` credentials with at least one non-empty name field,
|
|
196
|
+
* and only forwarded to the native SDK on iOS, where it is passed to
|
|
197
|
+
* `FIROAuthProvider.appleCredentialWithIDToken:rawNonce:fullName:` so Firebase can store it as
|
|
198
|
+
* {@link User.displayName} while creating the account. The Firebase Android SDK has no
|
|
199
|
+
* equivalent credential-level API; on Android (and Web) this field is ignored and the display
|
|
200
|
+
* name must be set with {@link updateProfile} after sign-in.
|
|
201
|
+
*/
|
|
202
|
+
fullName?: AppleFullPersonName;
|
|
176
203
|
}
|
|
177
204
|
|
|
178
205
|
export interface AuthProvider {
|
|
@@ -284,6 +311,8 @@ export interface User extends UserInfo {
|
|
|
284
311
|
readonly providerData: UserInfo[];
|
|
285
312
|
readonly refreshToken: string;
|
|
286
313
|
readonly tenantId: string | null;
|
|
314
|
+
/** Present on native user instances returned from auth state listeners. */
|
|
315
|
+
readonly multiFactor?: MultiFactor | null;
|
|
287
316
|
delete(): Promise<void>;
|
|
288
317
|
getIdToken(forceRefresh?: boolean): Promise<string>;
|
|
289
318
|
getIdTokenResult(forceRefresh?: boolean): Promise<IdTokenResult>;
|
|
@@ -391,3 +420,16 @@ export type PhoneInfoOptions =
|
|
|
391
420
|
export interface TotpMultiFactorAssertion extends MultiFactorAssertion {}
|
|
392
421
|
|
|
393
422
|
export interface TotpMultiFactorInfo extends MultiFactorInfo {}
|
|
423
|
+
|
|
424
|
+
export type AuthListenerCallback = (user: User | null) => void;
|
|
425
|
+
|
|
426
|
+
export type CallbackOrObserver<T extends (...args: any[]) => any> = T | { next: T };
|
|
427
|
+
|
|
428
|
+
export interface UpdateProfile {
|
|
429
|
+
displayName?: string | null;
|
|
430
|
+
photoURL?: string | null;
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
export interface MultiFactor {
|
|
434
|
+
enrolledFactors: MultiFactorInfo[];
|
|
435
|
+
}
|
package/lib/types/internal.ts
CHANGED
|
@@ -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
|
|
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:
|
|
57
|
-
additionalUserInfo?:
|
|
53
|
+
user: User;
|
|
54
|
+
additionalUserInfo?: AdditionalUserInfo;
|
|
58
55
|
};
|
|
59
56
|
|
|
60
|
-
export type UserCredentialResultInternal =
|
|
57
|
+
export type UserCredentialResultInternal = UserCredential &
|
|
61
58
|
Partial<Pick<UserCredential, 'operationType' | 'providerId'>>;
|
|
62
59
|
|
|
63
|
-
export type ActionCodeInfoResultInternal =
|
|
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:
|
|
72
|
-
session:
|
|
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 =
|
|
73
|
+
export type MultiFactorUserSourceInternal = User;
|
|
79
74
|
|
|
80
75
|
export type MultiFactorUserResultInternal = {
|
|
81
|
-
enrolledFactors:
|
|
82
|
-
getSession(): Promise<
|
|
83
|
-
enroll(
|
|
84
|
-
|
|
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?:
|
|
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?:
|
|
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:
|
|
245
|
+
session: MultiFactorSession,
|
|
257
246
|
): Promise<string>;
|
|
258
247
|
resolveMultiFactorSignIn(
|
|
259
|
-
session:
|
|
248
|
+
session: MultiFactorSession,
|
|
260
249
|
verificationId: string,
|
|
261
250
|
verificationCode: string,
|
|
262
251
|
): Promise<NativeUserCredentialInternal>;
|
|
263
252
|
resolveTotpSignIn(
|
|
264
|
-
session:
|
|
253
|
+
session: MultiFactorSession,
|
|
265
254
|
uid: string,
|
|
266
255
|
totpSecret: string,
|
|
267
256
|
): Promise<NativeUserCredentialInternal>;
|
|
@@ -278,21 +267,20 @@ export interface RNFBAuthModule {
|
|
|
278
267
|
providerId: string,
|
|
279
268
|
token: string,
|
|
280
269
|
secret?: string | null,
|
|
270
|
+
// Sign in with Apple full name (iOS only; see AppleFullPersonName in ./auth.ts).
|
|
271
|
+
fullName?: Record<string, unknown> | null,
|
|
281
272
|
): Promise<NativeUserCredentialInternal>;
|
|
282
273
|
revokeToken(authorizationCode: string): Promise<void>;
|
|
283
274
|
sendPasswordResetEmail(
|
|
284
275
|
email: string,
|
|
285
|
-
actionCodeSettings?:
|
|
286
|
-
): Promise<void>;
|
|
287
|
-
sendSignInLinkToEmail(
|
|
288
|
-
email: string,
|
|
289
|
-
actionCodeSettings?: FirebaseAuthTypes.ActionCodeSettings,
|
|
276
|
+
actionCodeSettings?: ActionCodeSettings | null,
|
|
290
277
|
): Promise<void>;
|
|
291
|
-
|
|
278
|
+
sendSignInLinkToEmail(email: string, actionCodeSettings?: ActionCodeSettings): Promise<void>;
|
|
279
|
+
isSignInWithEmailLink(emailLink: string): boolean;
|
|
292
280
|
signInWithEmailLink(email: string, emailLink?: string): Promise<NativeUserCredentialInternal>;
|
|
293
281
|
confirmPasswordReset(code: string, newPassword: string): Promise<void>;
|
|
294
282
|
applyActionCode(code: string): Promise<NativeUserInternal | null | undefined>;
|
|
295
|
-
checkActionCode(code: string): Promise<
|
|
283
|
+
checkActionCode(code: string): Promise<ActionCodeInfo>;
|
|
296
284
|
fetchSignInMethodsForEmail(email: string): Promise<string[]>;
|
|
297
285
|
verifyPasswordResetCode(code: string): Promise<string>;
|
|
298
286
|
useUserAccessGroup(userAccessGroup: string): Promise<null | void>;
|
|
@@ -300,7 +288,7 @@ export interface RNFBAuthModule {
|
|
|
300
288
|
useEmulator(host: string, port?: number): void;
|
|
301
289
|
getCustomAuthDomain(): Promise<string>;
|
|
302
290
|
confirmationResultConfirm(verificationCode: string): Promise<NativeUserCredentialInternal>;
|
|
303
|
-
|
|
291
|
+
deleteUser(): Promise<void>;
|
|
304
292
|
getIdToken(forceRefresh: boolean): Promise<string>;
|
|
305
293
|
getIdTokenResult(forceRefresh: boolean): Promise<IdTokenResult>;
|
|
306
294
|
linkWithCredential(
|
|
@@ -318,9 +306,7 @@ export interface RNFBAuthModule {
|
|
|
318
306
|
provider: Record<string, unknown>,
|
|
319
307
|
): Promise<NativeUserCredentialInternal>;
|
|
320
308
|
reload(): Promise<NativeUserInternal>;
|
|
321
|
-
sendEmailVerification(
|
|
322
|
-
actionCodeSettings?: FirebaseAuthTypes.ActionCodeSettings,
|
|
323
|
-
): Promise<NativeUserInternal>;
|
|
309
|
+
sendEmailVerification(actionCodeSettings?: ActionCodeSettings): Promise<NativeUserInternal>;
|
|
324
310
|
unlink(providerId: string): Promise<NativeUserInternal>;
|
|
325
311
|
updateEmail(email: string): Promise<NativeUserInternal>;
|
|
326
312
|
updatePassword(password: string): Promise<NativeUserInternal>;
|
|
@@ -335,22 +321,22 @@ export interface RNFBAuthModule {
|
|
|
335
321
|
}): Promise<NativeUserInternal>;
|
|
336
322
|
verifyBeforeUpdateEmail(
|
|
337
323
|
newEmail: string,
|
|
338
|
-
actionCodeSettings?:
|
|
324
|
+
actionCodeSettings?: ActionCodeSettings,
|
|
339
325
|
): Promise<NativeUserInternal>;
|
|
340
326
|
forceRecaptchaFlowForTesting(forceRecaptchaFlow: boolean): void | Promise<void>;
|
|
341
327
|
setAppVerificationDisabledForTesting(disabled: boolean): void | Promise<void>;
|
|
342
328
|
setAutoRetrievedSmsCodeForPhoneNumber(phoneNumber: string, smsCode: string): Promise<null>;
|
|
343
|
-
getSession(): Promise<
|
|
329
|
+
getSession(): Promise<MultiFactorSession>;
|
|
344
330
|
finalizeMultiFactorEnrollment(token: string, secret: string, displayName?: string): Promise<void>;
|
|
345
331
|
finalizeTotpEnrollment(
|
|
346
332
|
totpSecret: string,
|
|
347
333
|
verificationCode: string,
|
|
348
334
|
displayName?: string,
|
|
349
335
|
): Promise<void>;
|
|
350
|
-
unenrollMultiFactor(enrollmentId: string |
|
|
336
|
+
unenrollMultiFactor(enrollmentId: string | MultiFactorInfo): Promise<void>;
|
|
351
337
|
getMultiFactorResolver(error: unknown): MultiFactorResolverResultInternal | null;
|
|
352
|
-
generateTotpSecret(session:
|
|
353
|
-
generateQrCodeUrl(secretKey: string, accountName: string, issuer: string):
|
|
338
|
+
generateTotpSecret(session: MultiFactorSession): Promise<{ secretKey: string }>;
|
|
339
|
+
generateQrCodeUrl(secretKey: string, accountName: string, issuer: string): string;
|
|
354
340
|
openInOtpApp(secretKey: string, qrCodeUrl: string): string | void;
|
|
355
341
|
assertionForSignIn(
|
|
356
342
|
uid: string,
|
|
@@ -360,7 +346,7 @@ export interface RNFBAuthModule {
|
|
|
360
346
|
|
|
361
347
|
export type AuthInternal = Auth & {
|
|
362
348
|
app: ReactNativeFirebase.FirebaseApp;
|
|
363
|
-
currentUser:
|
|
349
|
+
currentUser: User | null;
|
|
364
350
|
applyActionCode(code: string): Promise<void>;
|
|
365
351
|
checkActionCode(code: string): Promise<ActionCodeInfoResultInternal>;
|
|
366
352
|
confirmPasswordReset(code: string, newPassword: string): Promise<void>;
|
|
@@ -371,12 +357,12 @@ export type AuthInternal = Auth & {
|
|
|
371
357
|
fetchSignInMethodsForEmail(email: string): Promise<string[]>;
|
|
372
358
|
getCustomAuthDomain(): Promise<string>;
|
|
373
359
|
getMultiFactorResolver(error: unknown): MultiFactorResolverResultInternal | null;
|
|
374
|
-
isSignInWithEmailLink(emailLink: string):
|
|
360
|
+
isSignInWithEmailLink(emailLink: string): boolean;
|
|
375
361
|
onAuthStateChanged(
|
|
376
|
-
listenerOrObserver: CallbackOrObserver<AuthListenerCallbackInternal>,
|
|
362
|
+
listenerOrObserver: import('./auth').CallbackOrObserver<AuthListenerCallbackInternal>,
|
|
377
363
|
): () => void;
|
|
378
364
|
onIdTokenChanged(
|
|
379
|
-
listenerOrObserver: CallbackOrObserver<AuthListenerCallbackInternal>,
|
|
365
|
+
listenerOrObserver: import('./auth').CallbackOrObserver<AuthListenerCallbackInternal>,
|
|
380
366
|
): () => void;
|
|
381
367
|
sendPasswordResetEmail(
|
|
382
368
|
email: string,
|
|
@@ -415,6 +401,13 @@ export type AuthInternal = Auth & {
|
|
|
415
401
|
autoVerifyTimeoutOrForceResend?: number | boolean,
|
|
416
402
|
forceResend?: boolean,
|
|
417
403
|
): PhoneAuthListener;
|
|
404
|
+
verifyPhoneNumberWithMultiFactorInfo(
|
|
405
|
+
multiFactorHint: MultiFactorInfo,
|
|
406
|
+
session: MultiFactorSession,
|
|
407
|
+
): Promise<string>;
|
|
408
|
+
verifyPhoneNumberForMultiFactor(
|
|
409
|
+
phoneInfoOptions: import('./auth').PhoneMultiFactorEnrollInfoOptions,
|
|
410
|
+
): Promise<string>;
|
|
418
411
|
verifyPasswordResetCode(code: string): Promise<string>;
|
|
419
412
|
revokeToken(authorizationCode: string): Promise<void>;
|
|
420
413
|
native: RNFBAuthModule;
|
|
@@ -424,23 +417,23 @@ export type AuthInternal = Auth & {
|
|
|
424
417
|
_tenantId: string | null;
|
|
425
418
|
_projectPasswordPolicy: PasswordPolicyInternal | null;
|
|
426
419
|
_tenantPasswordPolicies: Record<string, PasswordPolicyInternal | null>;
|
|
427
|
-
_setUser(user?: NativeUserInternal | null):
|
|
420
|
+
_setUser(user?: NativeUserInternal | null): User | null;
|
|
428
421
|
_setUserCredential(
|
|
429
422
|
userCredential: NativeUserCredentialInternal,
|
|
430
423
|
): UserCredentialWithAdditionalUserInfoInternal;
|
|
431
424
|
resolveMultiFactorSignIn(
|
|
432
|
-
session:
|
|
425
|
+
session: MultiFactorSession,
|
|
433
426
|
verificationId: string,
|
|
434
427
|
verificationCode: string,
|
|
435
428
|
): Promise<UserCredentialWithAdditionalUserInfoInternal>;
|
|
436
429
|
resolveTotpSignIn(
|
|
437
|
-
session:
|
|
430
|
+
session: MultiFactorSession,
|
|
438
431
|
uid: string,
|
|
439
432
|
totpSecret: string,
|
|
440
433
|
): Promise<UserCredentialWithAdditionalUserInfoInternal>;
|
|
441
434
|
} & PasswordPolicyMixinInternal;
|
|
442
435
|
|
|
443
|
-
export type UserInternal =
|
|
436
|
+
export type UserInternal = User & {
|
|
444
437
|
_auth?: AuthInternal;
|
|
445
438
|
_user?: NativeUserInternal;
|
|
446
439
|
getIdTokenResult(forceRefresh?: boolean): Promise<IdTokenResult>;
|
|
@@ -469,11 +462,11 @@ export type UserInternal = FirebaseAuthTypes.User & {
|
|
|
469
462
|
verifyBeforeUpdateEmail(newEmail: string, actionCodeSettings?: ActionCodeSettings): Promise<void>;
|
|
470
463
|
};
|
|
471
464
|
|
|
472
|
-
export type ConfirmationResultInternal =
|
|
473
|
-
export type MultiFactorResolverInternal =
|
|
465
|
+
export type ConfirmationResultInternal = ConfirmationResult;
|
|
466
|
+
export type MultiFactorResolverInternal = MultiFactorResolver;
|
|
474
467
|
|
|
475
468
|
declare module '@react-native-firebase/app/dist/module/internal/NativeModules' {
|
|
476
469
|
interface ReactNativeFirebaseNativeModules {
|
|
477
|
-
|
|
470
|
+
NativeRNFBTurboAuth: RNFBAuthModule;
|
|
478
471
|
}
|
|
479
472
|
}
|
package/lib/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Generated by genversion.
|
|
2
|
-
export const version = '
|
|
2
|
+
export const version = '26.1.0';
|