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