@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.
- package/CHANGELOG.md +30 -0
- package/RNFBAuth.podspec +14 -6
- package/android/build.gradle +23 -0
- package/android/src/main/java/io/invertase/firebase/auth/{ReactNativeFirebaseAuthModule.java → NativeRNFBTurboAuth.java} +122 -102
- 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 +538 -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/ActionCodeURL.js.map +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/EmailAuthCredential.js.map +1 -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 +1221 -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/OIDCAuthProvider.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.map +1 -1
- package/dist/module/version.js +1 -1
- package/dist/module/web/RNFBAuthModule.js +13 -7
- package/dist/module/web/RNFBAuthModule.js.map +1 -1
- package/dist/typescript/lib/ActionCodeURL.d.ts.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/EmailAuthCredential.d.ts.map +1 -1
- 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/OIDCAuthProvider.d.ts.map +1 -1
- package/dist/typescript/lib/providers/PhoneAuthProvider.d.ts.map +1 -1
- package/dist/typescript/lib/types/auth.d.ts +13 -0
- package/dist/typescript/lib/types/auth.d.ts.map +1 -1
- package/dist/typescript/lib/types/internal.d.ts +44 -47
- 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 +4 -4
- package/dist/typescript/lib/web/RNFBAuthModule.d.ts.map +1 -1
- package/ios/RNFBAuth/RNFBAuthModule.h +2 -2
- package/ios/RNFBAuth/{RNFBAuthModule.m → RNFBAuthModule.mm} +408 -297
- 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 +341 -0
- package/ios/generated/RNFBAuthTurboModulesJSI-generated.cpp +538 -0
- package/ios/generated/RNFBAuthTurboModulesJSI.h +611 -0
- package/ios/generated/ReactAppDependencyProvider.podspec +34 -0
- package/lib/ActionCodeURL.ts +3 -9
- 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 +38 -51
- package/lib/credentials/EmailAuthCredential.ts +1 -5
- package/lib/credentials/OAuthCredential.ts +4 -1
- package/lib/getMultiFactorResolver.ts +9 -9
- package/lib/index.ts +1836 -6
- package/lib/internal/syncNativeError.ts +89 -0
- package/lib/multiFactor.ts +24 -18
- package/lib/providers/OIDCAuthProvider.ts +1 -5
- package/lib/providers/PhoneAuthProvider.ts +9 -22
- package/lib/types/auth.ts +15 -0
- package/lib/types/internal.ts +68 -73
- package/lib/version.ts +1 -1
- package/lib/web/RNFBAuthModule.ts +13 -10
- package/package.json +30 -4
- 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 +143 -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 -1172
- package/lib/namespaced.ts +0 -846
- 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,30 +1,35 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { MultiFactorAssertion as ModularMultiFactorAssertion, User } from './types/auth';
|
|
2
2
|
import type {
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
MultiFactorInfo,
|
|
4
|
+
MultiFactorSession,
|
|
5
|
+
MultiFactorUser as MultiFactorUserType,
|
|
6
|
+
MultiFactorAssertion,
|
|
5
7
|
} from './types/auth';
|
|
6
|
-
import type {
|
|
7
|
-
|
|
8
|
+
import type {
|
|
9
|
+
AuthInternal,
|
|
10
|
+
MultiFactorEnrollmentAssertionInternal,
|
|
11
|
+
UserInternal,
|
|
12
|
+
} from './types/internal';
|
|
8
13
|
|
|
9
14
|
type MultiFactorAuthHost = {
|
|
10
|
-
currentUser:
|
|
15
|
+
currentUser: User | null;
|
|
11
16
|
native: AuthInternal['native'];
|
|
12
17
|
};
|
|
13
18
|
/**
|
|
14
19
|
* Return a MultiFactorUser instance the gateway to multi-factor operations.
|
|
15
20
|
*/
|
|
16
|
-
export function multiFactor(auth: MultiFactorAuthHost):
|
|
21
|
+
export function multiFactor(auth: MultiFactorAuthHost): MultiFactorUserType {
|
|
17
22
|
return new MultiFactorUser(auth);
|
|
18
23
|
}
|
|
19
24
|
|
|
20
25
|
export class MultiFactorUser {
|
|
21
|
-
readonly enrolledFactors:
|
|
26
|
+
readonly enrolledFactors: MultiFactorInfo[];
|
|
22
27
|
private readonly _auth: MultiFactorAuthHost;
|
|
23
28
|
|
|
24
|
-
constructor(auth: MultiFactorAuthHost, user?:
|
|
29
|
+
constructor(auth: MultiFactorAuthHost, user?: User) {
|
|
25
30
|
this._auth = auth;
|
|
26
31
|
if (user === undefined) {
|
|
27
|
-
user = auth.currentUser as
|
|
32
|
+
user = auth.currentUser as User;
|
|
28
33
|
}
|
|
29
34
|
|
|
30
35
|
if (!user) {
|
|
@@ -34,7 +39,7 @@ export class MultiFactorUser {
|
|
|
34
39
|
this.enrolledFactors = user.multiFactor?.enrolledFactors ?? [];
|
|
35
40
|
}
|
|
36
41
|
|
|
37
|
-
getSession(): Promise<
|
|
42
|
+
getSession(): Promise<MultiFactorSession> {
|
|
38
43
|
return this._auth.native.getSession();
|
|
39
44
|
}
|
|
40
45
|
|
|
@@ -44,7 +49,7 @@ export class MultiFactorUser {
|
|
|
44
49
|
* profile, which is necessary to see the multi-factor changes.
|
|
45
50
|
*/
|
|
46
51
|
async enroll(
|
|
47
|
-
multiFactorAssertion:
|
|
52
|
+
multiFactorAssertion: MultiFactorAssertion | ModularMultiFactorAssertion,
|
|
48
53
|
displayName?: string | null,
|
|
49
54
|
): Promise<void> {
|
|
50
55
|
const assertion = multiFactorAssertion as MultiFactorEnrollmentAssertionInternal;
|
|
@@ -68,16 +73,17 @@ export class MultiFactorUser {
|
|
|
68
73
|
|
|
69
74
|
// We need to reload the user otherwise the changes are not visible
|
|
70
75
|
// TODO reload not working on Other platform
|
|
71
|
-
|
|
76
|
+
const currentUser = this._auth.currentUser as UserInternal | null;
|
|
77
|
+
if (currentUser) {
|
|
78
|
+
await currentUser.reload();
|
|
79
|
+
}
|
|
72
80
|
}
|
|
73
81
|
|
|
74
|
-
async unenroll(enrollmentId:
|
|
75
|
-
await this._auth.native.unenrollMultiFactor(
|
|
76
|
-
enrollmentId as string | FirebaseAuthTypes.MultiFactorInfo,
|
|
77
|
-
);
|
|
82
|
+
async unenroll(enrollmentId: MultiFactorInfo | string): Promise<void> {
|
|
83
|
+
await this._auth.native.unenrollMultiFactor(enrollmentId as string | MultiFactorInfo);
|
|
78
84
|
|
|
79
85
|
if (this._auth.currentUser) {
|
|
80
|
-
await
|
|
86
|
+
await (this._auth.currentUser as UserInternal).reload();
|
|
81
87
|
}
|
|
82
88
|
}
|
|
83
89
|
}
|
|
@@ -38,11 +38,7 @@ export default class OIDCAuthProvider {
|
|
|
38
38
|
return providerId;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
static credential(
|
|
42
|
-
oidcSuffix: string,
|
|
43
|
-
idToken: string,
|
|
44
|
-
accessToken?: string,
|
|
45
|
-
): AuthCredentialType {
|
|
41
|
+
static credential(oidcSuffix: string, idToken: string, accessToken?: string): AuthCredentialType {
|
|
46
42
|
const resolvedProviderId = providerId + oidcSuffix;
|
|
47
43
|
return new AuthCredential(resolvedProviderId, resolvedProviderId, idToken, accessToken ?? '');
|
|
48
44
|
}
|
|
@@ -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
|
@@ -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
|
+
}
|
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>;
|
|
@@ -282,17 +271,14 @@ export interface RNFBAuthModule {
|
|
|
282
271
|
revokeToken(authorizationCode: string): Promise<void>;
|
|
283
272
|
sendPasswordResetEmail(
|
|
284
273
|
email: string,
|
|
285
|
-
actionCodeSettings?:
|
|
286
|
-
): Promise<void>;
|
|
287
|
-
sendSignInLinkToEmail(
|
|
288
|
-
email: string,
|
|
289
|
-
actionCodeSettings?: FirebaseAuthTypes.ActionCodeSettings,
|
|
274
|
+
actionCodeSettings?: ActionCodeSettings | null,
|
|
290
275
|
): Promise<void>;
|
|
291
|
-
|
|
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<
|
|
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
|
-
|
|
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>;
|
|
@@ -329,27 +313,28 @@ export interface RNFBAuthModule {
|
|
|
329
313
|
token: string,
|
|
330
314
|
secret?: string | null,
|
|
331
315
|
): Promise<NativeUserInternal>;
|
|
332
|
-
updateProfile(
|
|
333
|
-
|
|
334
|
-
|
|
316
|
+
updateProfile(updates: {
|
|
317
|
+
displayName?: string | null;
|
|
318
|
+
photoURL?: string | null;
|
|
319
|
+
}): Promise<NativeUserInternal>;
|
|
335
320
|
verifyBeforeUpdateEmail(
|
|
336
321
|
newEmail: string,
|
|
337
|
-
actionCodeSettings?:
|
|
322
|
+
actionCodeSettings?: ActionCodeSettings,
|
|
338
323
|
): Promise<NativeUserInternal>;
|
|
339
324
|
forceRecaptchaFlowForTesting(forceRecaptchaFlow: boolean): void | Promise<void>;
|
|
340
325
|
setAppVerificationDisabledForTesting(disabled: boolean): void | Promise<void>;
|
|
341
326
|
setAutoRetrievedSmsCodeForPhoneNumber(phoneNumber: string, smsCode: string): Promise<null>;
|
|
342
|
-
getSession(): Promise<
|
|
327
|
+
getSession(): Promise<MultiFactorSession>;
|
|
343
328
|
finalizeMultiFactorEnrollment(token: string, secret: string, displayName?: string): Promise<void>;
|
|
344
329
|
finalizeTotpEnrollment(
|
|
345
330
|
totpSecret: string,
|
|
346
331
|
verificationCode: string,
|
|
347
332
|
displayName?: string,
|
|
348
333
|
): Promise<void>;
|
|
349
|
-
unenrollMultiFactor(enrollmentId: string |
|
|
334
|
+
unenrollMultiFactor(enrollmentId: string | MultiFactorInfo): Promise<void>;
|
|
350
335
|
getMultiFactorResolver(error: unknown): MultiFactorResolverResultInternal | null;
|
|
351
|
-
generateTotpSecret(session:
|
|
352
|
-
generateQrCodeUrl(secretKey: string, accountName: string, issuer: string):
|
|
336
|
+
generateTotpSecret(session: MultiFactorSession): Promise<{ secretKey: string }>;
|
|
337
|
+
generateQrCodeUrl(secretKey: string, accountName: string, issuer: string): string;
|
|
353
338
|
openInOtpApp(secretKey: string, qrCodeUrl: string): string | void;
|
|
354
339
|
assertionForSignIn(
|
|
355
340
|
uid: string,
|
|
@@ -359,7 +344,7 @@ export interface RNFBAuthModule {
|
|
|
359
344
|
|
|
360
345
|
export type AuthInternal = Auth & {
|
|
361
346
|
app: ReactNativeFirebase.FirebaseApp;
|
|
362
|
-
currentUser:
|
|
347
|
+
currentUser: User | null;
|
|
363
348
|
applyActionCode(code: string): Promise<void>;
|
|
364
349
|
checkActionCode(code: string): Promise<ActionCodeInfoResultInternal>;
|
|
365
350
|
confirmPasswordReset(code: string, newPassword: string): Promise<void>;
|
|
@@ -370,24 +355,23 @@ export type AuthInternal = Auth & {
|
|
|
370
355
|
fetchSignInMethodsForEmail(email: string): Promise<string[]>;
|
|
371
356
|
getCustomAuthDomain(): Promise<string>;
|
|
372
357
|
getMultiFactorResolver(error: unknown): MultiFactorResolverResultInternal | null;
|
|
373
|
-
isSignInWithEmailLink(emailLink: string):
|
|
358
|
+
isSignInWithEmailLink(emailLink: string): boolean;
|
|
374
359
|
onAuthStateChanged(
|
|
375
|
-
listenerOrObserver: CallbackOrObserver<AuthListenerCallbackInternal>,
|
|
360
|
+
listenerOrObserver: import('./auth').CallbackOrObserver<AuthListenerCallbackInternal>,
|
|
376
361
|
): () => void;
|
|
377
362
|
onIdTokenChanged(
|
|
378
|
-
listenerOrObserver: CallbackOrObserver<AuthListenerCallbackInternal>,
|
|
363
|
+
listenerOrObserver: import('./auth').CallbackOrObserver<AuthListenerCallbackInternal>,
|
|
379
364
|
): () => void;
|
|
380
365
|
sendPasswordResetEmail(
|
|
381
366
|
email: string,
|
|
382
367
|
actionCodeSettings?: ActionCodeSettings | null,
|
|
383
368
|
): Promise<void>;
|
|
384
|
-
sendSignInLinkToEmail(
|
|
385
|
-
email: string,
|
|
386
|
-
actionCodeSettings?: ActionCodeSettings,
|
|
387
|
-
): Promise<void>;
|
|
369
|
+
sendSignInLinkToEmail(email: string, actionCodeSettings?: ActionCodeSettings): Promise<void>;
|
|
388
370
|
setLanguageCode(code: string | null): Promise<void>;
|
|
389
371
|
signInAnonymously(): Promise<UserCredentialWithAdditionalUserInfoInternal>;
|
|
390
|
-
signInWithCredential(
|
|
372
|
+
signInWithCredential(
|
|
373
|
+
credential: AuthCredential,
|
|
374
|
+
): Promise<UserCredentialWithAdditionalUserInfoInternal>;
|
|
391
375
|
signInWithCustomToken(customToken: string): Promise<UserCredentialWithAdditionalUserInfoInternal>;
|
|
392
376
|
signInWithEmailAndPassword(
|
|
393
377
|
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,28 +415,32 @@ 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):
|
|
418
|
+
_setUser(user?: NativeUserInternal | null): User | null;
|
|
428
419
|
_setUserCredential(
|
|
429
420
|
userCredential: NativeUserCredentialInternal,
|
|
430
421
|
): UserCredentialWithAdditionalUserInfoInternal;
|
|
431
422
|
resolveMultiFactorSignIn(
|
|
432
|
-
session:
|
|
423
|
+
session: MultiFactorSession,
|
|
433
424
|
verificationId: string,
|
|
434
425
|
verificationCode: string,
|
|
435
426
|
): Promise<UserCredentialWithAdditionalUserInfoInternal>;
|
|
436
427
|
resolveTotpSignIn(
|
|
437
|
-
session:
|
|
428
|
+
session: MultiFactorSession,
|
|
438
429
|
uid: string,
|
|
439
430
|
totpSecret: string,
|
|
440
431
|
): Promise<UserCredentialWithAdditionalUserInfoInternal>;
|
|
441
432
|
} & PasswordPolicyMixinInternal;
|
|
442
433
|
|
|
443
|
-
export type UserInternal =
|
|
434
|
+
export type UserInternal = User & {
|
|
444
435
|
_auth?: AuthInternal;
|
|
445
436
|
_user?: NativeUserInternal;
|
|
446
437
|
getIdTokenResult(forceRefresh?: boolean): Promise<IdTokenResult>;
|
|
447
|
-
linkWithCredential(
|
|
448
|
-
|
|
438
|
+
linkWithCredential(
|
|
439
|
+
credential: AuthCredential,
|
|
440
|
+
): Promise<UserCredentialWithAdditionalUserInfoInternal>;
|
|
441
|
+
linkWithPopup(
|
|
442
|
+
provider: AuthProviderWithObjectInternal,
|
|
443
|
+
): Promise<UserCredentialWithAdditionalUserInfoInternal>;
|
|
449
444
|
linkWithRedirect(
|
|
450
445
|
provider: AuthProviderWithObjectInternal,
|
|
451
446
|
): Promise<UserCredentialWithAdditionalUserInfoInternal>;
|
|
@@ -465,11 +460,11 @@ export type UserInternal = FirebaseAuthTypes.User & {
|
|
|
465
460
|
verifyBeforeUpdateEmail(newEmail: string, actionCodeSettings?: ActionCodeSettings): Promise<void>;
|
|
466
461
|
};
|
|
467
462
|
|
|
468
|
-
export type ConfirmationResultInternal =
|
|
469
|
-
export type MultiFactorResolverInternal =
|
|
463
|
+
export type ConfirmationResultInternal = ConfirmationResult;
|
|
464
|
+
export type MultiFactorResolverInternal = MultiFactorResolver;
|
|
470
465
|
|
|
471
466
|
declare module '@react-native-firebase/app/dist/module/internal/NativeModules' {
|
|
472
467
|
interface ReactNativeFirebaseNativeModules {
|
|
473
|
-
|
|
468
|
+
NativeRNFBTurboAuth: RNFBAuthModule;
|
|
474
469
|
}
|
|
475
470
|
}
|
package/lib/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Generated by genversion.
|
|
2
|
-
export const version = '
|
|
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 {
|
|
586
|
+
* @returns {boolean} - Whether the link is a valid sign in with email link.
|
|
587
587
|
*/
|
|
588
|
-
|
|
589
|
-
|
|
588
|
+
isSignInWithEmailLink(appName: string, emailLink: string) {
|
|
589
|
+
try {
|
|
590
590
|
const auth = getCachedAuthInstance(appName);
|
|
591
|
-
return
|
|
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
|
|
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
|
-
|
|
1258
|
-
'
|
|
1259
|
-
|
|
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
|
},
|