@react-native-firebase/auth 24.1.0 → 25.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 +14 -0
- package/android/src/main/java/io/invertase/firebase/auth/ReactNativeFirebaseAuthModule.java +16 -4
- package/dist/module/ActionCodeURL.js +140 -0
- package/dist/module/ActionCodeURL.js.map +1 -0
- package/{lib → dist/module}/ConfirmationResult.js +4 -5
- package/dist/module/ConfirmationResult.js.map +1 -0
- package/{lib → dist/module}/MultiFactorResolver.js +14 -5
- package/dist/module/MultiFactorResolver.js.map +1 -0
- package/{lib → dist/module}/PhoneAuthListener.js +52 -75
- package/dist/module/PhoneAuthListener.js.map +1 -0
- package/dist/module/PhoneAuthState.js +25 -0
- package/dist/module/PhoneAuthState.js.map +1 -0
- package/dist/module/PhoneMultiFactorGenerator.js +39 -0
- package/dist/module/PhoneMultiFactorGenerator.js.map +1 -0
- package/{lib → dist/module}/Settings.js +3 -7
- package/dist/module/Settings.js.map +1 -0
- package/{lib → dist/module}/TotpMultiFactorGenerator.js +20 -15
- package/dist/module/TotpMultiFactorGenerator.js.map +1 -0
- package/{lib → dist/module}/TotpSecret.js +7 -5
- package/dist/module/TotpSecret.js.map +1 -0
- package/dist/module/User.js +245 -0
- package/dist/module/User.js.map +1 -0
- package/dist/module/constants.js +54 -0
- package/dist/module/constants.js.map +1 -0
- package/dist/module/credentials/AuthCredential.js +51 -0
- package/dist/module/credentials/AuthCredential.js.map +1 -0
- package/dist/module/credentials/EmailAuthCredential.js +51 -0
- package/dist/module/credentials/EmailAuthCredential.js.map +1 -0
- package/dist/module/credentials/OAuthCredential.js +84 -0
- package/dist/module/credentials/OAuthCredential.js.map +1 -0
- package/dist/module/credentials/PhoneAuthCredential.js +50 -0
- package/dist/module/credentials/PhoneAuthCredential.js.map +1 -0
- package/{lib/providers/GoogleAuthProvider.js → dist/module/credentials/index.js} +7 -19
- package/dist/module/credentials/index.js.map +1 -0
- package/{lib → dist/module}/getMultiFactorResolver.js +5 -8
- package/dist/module/getMultiFactorResolver.js.map +1 -0
- package/{lib/providers/FacebookAuthProvider.js → dist/module/index.js} +11 -18
- package/dist/module/index.js.map +1 -0
- package/dist/module/modular.js +779 -0
- package/dist/module/modular.js.map +1 -0
- package/{lib → dist/module}/multiFactor.js +16 -14
- package/dist/module/multiFactor.js.map +1 -0
- package/dist/module/namespaced.js +522 -0
- package/dist/module/namespaced.js.map +1 -0
- package/dist/module/package.json +1 -0
- package/dist/module/password-policy/PasswordPolicyImpl.js +103 -0
- package/dist/module/password-policy/PasswordPolicyImpl.js.map +1 -0
- package/{lib → dist/module}/password-policy/PasswordPolicyMixin.js +14 -16
- package/dist/module/password-policy/PasswordPolicyMixin.js.map +1 -0
- package/{lib → dist/module}/password-policy/passwordPolicyApi.js +18 -12
- package/dist/module/password-policy/passwordPolicyApi.js.map +1 -0
- package/{lib → dist/module}/providers/AppleAuthProvider.js +14 -7
- package/dist/module/providers/AppleAuthProvider.js.map +1 -0
- package/{lib → dist/module}/providers/EmailAuthProvider.js +10 -25
- package/dist/module/providers/EmailAuthProvider.js.map +1 -0
- package/dist/module/providers/FacebookAuthProvider.js +56 -0
- package/dist/module/providers/FacebookAuthProvider.js.map +1 -0
- package/dist/module/providers/GithubAuthProvider.js +49 -0
- package/dist/module/providers/GithubAuthProvider.js.map +1 -0
- package/dist/module/providers/GoogleAuthProvider.js +57 -0
- package/dist/module/providers/GoogleAuthProvider.js.map +1 -0
- package/dist/module/providers/OAuthProvider.js +116 -0
- package/dist/module/providers/OAuthProvider.js.map +1 -0
- package/{lib → dist/module}/providers/OIDCAuthProvider.js +15 -7
- package/dist/module/providers/OIDCAuthProvider.js.map +1 -0
- package/dist/module/providers/PhoneAuthProvider.js +87 -0
- package/dist/module/providers/PhoneAuthProvider.js.map +1 -0
- package/dist/module/providers/TwitterAuthProvider.js +50 -0
- package/dist/module/providers/TwitterAuthProvider.js.map +1 -0
- package/dist/module/types/auth.js +43 -0
- package/dist/module/types/auth.js.map +1 -0
- package/dist/module/types/internal.js +4 -0
- package/dist/module/types/internal.js.map +1 -0
- package/dist/module/types/namespaced.js +62 -0
- package/dist/module/types/namespaced.js.map +1 -0
- package/dist/module/version.js +5 -0
- package/dist/module/version.js.map +1 -0
- package/dist/module/web/RNFBAuthModule.android.js +5 -0
- package/dist/module/web/RNFBAuthModule.android.js.map +1 -0
- package/dist/module/web/RNFBAuthModule.ios.js +5 -0
- package/dist/module/web/RNFBAuthModule.ios.js.map +1 -0
- package/{lib → dist/module}/web/RNFBAuthModule.js +104 -321
- package/dist/module/web/RNFBAuthModule.js.map +1 -0
- package/dist/typescript/lib/ActionCodeURL.d.ts +41 -0
- package/dist/typescript/lib/ActionCodeURL.d.ts.map +1 -0
- package/dist/typescript/lib/ConfirmationResult.d.ts +10 -0
- package/dist/typescript/lib/ConfirmationResult.d.ts.map +1 -0
- package/dist/typescript/lib/MultiFactorResolver.d.ts +24 -0
- package/dist/typescript/lib/MultiFactorResolver.d.ts.map +1 -0
- package/dist/typescript/lib/PhoneAuthListener.d.ts +34 -0
- package/dist/typescript/lib/PhoneAuthListener.d.ts.map +1 -0
- package/dist/typescript/lib/PhoneAuthState.d.ts +7 -0
- package/dist/typescript/lib/PhoneAuthState.d.ts.map +1 -0
- package/dist/typescript/lib/PhoneMultiFactorGenerator.d.ts +7 -0
- package/dist/typescript/lib/PhoneMultiFactorGenerator.d.ts.map +1 -0
- package/dist/typescript/lib/Settings.d.ts +13 -0
- package/dist/typescript/lib/Settings.d.ts.map +1 -0
- package/dist/typescript/lib/TotpMultiFactorGenerator.d.ts +11 -0
- package/dist/typescript/lib/TotpMultiFactorGenerator.d.ts.map +1 -0
- package/dist/typescript/lib/TotpSecret.d.ts +33 -0
- package/dist/typescript/lib/TotpSecret.d.ts.map +1 -0
- package/dist/typescript/lib/User.d.ts +51 -0
- package/dist/typescript/lib/User.d.ts.map +1 -0
- package/dist/typescript/lib/constants.d.ts +35 -0
- package/dist/typescript/lib/constants.d.ts.map +1 -0
- package/dist/typescript/lib/credentials/AuthCredential.d.ts +12 -0
- package/dist/typescript/lib/credentials/AuthCredential.d.ts.map +1 -0
- package/dist/typescript/lib/credentials/EmailAuthCredential.d.ts +8 -0
- package/dist/typescript/lib/credentials/EmailAuthCredential.d.ts.map +1 -0
- package/dist/typescript/lib/credentials/OAuthCredential.d.ts +22 -0
- package/dist/typescript/lib/credentials/OAuthCredential.d.ts.map +1 -0
- package/dist/typescript/lib/credentials/PhoneAuthCredential.d.ts +8 -0
- package/dist/typescript/lib/credentials/PhoneAuthCredential.d.ts.map +1 -0
- package/dist/typescript/lib/credentials/index.d.ts +5 -0
- package/dist/typescript/lib/credentials/index.d.ts.map +1 -0
- package/dist/typescript/lib/getMultiFactorResolver.d.ts +19 -0
- package/dist/typescript/lib/getMultiFactorResolver.d.ts.map +1 -0
- package/dist/typescript/lib/index.d.ts +8 -0
- package/dist/typescript/lib/index.d.ts.map +1 -0
- package/dist/typescript/lib/modular.d.ts +360 -0
- package/dist/typescript/lib/modular.d.ts.map +1 -0
- package/dist/typescript/lib/multiFactor.d.ts +26 -0
- package/dist/typescript/lib/multiFactor.d.ts.map +1 -0
- package/dist/typescript/lib/namespaced.d.ts +12 -0
- package/dist/typescript/lib/namespaced.d.ts.map +1 -0
- package/dist/typescript/lib/password-policy/PasswordPolicyImpl.d.ts +19 -0
- package/dist/typescript/lib/password-policy/PasswordPolicyImpl.d.ts.map +1 -0
- package/dist/typescript/lib/password-policy/PasswordPolicyMixin.d.ts +11 -0
- package/dist/typescript/lib/password-policy/PasswordPolicyMixin.d.ts.map +1 -0
- package/dist/typescript/lib/password-policy/passwordPolicyApi.d.ts +10 -0
- package/dist/typescript/lib/password-policy/passwordPolicyApi.d.ts.map +1 -0
- package/dist/typescript/lib/providers/AppleAuthProvider.d.ts +16 -0
- package/dist/typescript/lib/providers/AppleAuthProvider.d.ts.map +1 -0
- package/dist/typescript/lib/providers/EmailAuthProvider.d.ts +11 -0
- package/dist/typescript/lib/providers/EmailAuthProvider.d.ts.map +1 -0
- package/dist/typescript/lib/providers/FacebookAuthProvider.d.ts +19 -0
- package/dist/typescript/lib/providers/FacebookAuthProvider.d.ts.map +1 -0
- package/dist/typescript/lib/providers/GithubAuthProvider.d.ts +15 -0
- package/dist/typescript/lib/providers/GithubAuthProvider.d.ts.map +1 -0
- package/dist/typescript/lib/providers/GoogleAuthProvider.d.ts +21 -0
- package/dist/typescript/lib/providers/GoogleAuthProvider.d.ts.map +1 -0
- package/dist/typescript/lib/providers/OAuthProvider.d.ts +33 -0
- package/dist/typescript/lib/providers/OAuthProvider.d.ts.map +1 -0
- package/dist/typescript/lib/providers/OIDCAuthProvider.d.ts +16 -0
- package/dist/typescript/lib/providers/OIDCAuthProvider.d.ts.map +1 -0
- package/dist/typescript/lib/providers/PhoneAuthProvider.d.ts +16 -0
- package/dist/typescript/lib/providers/PhoneAuthProvider.d.ts.map +1 -0
- package/dist/typescript/lib/providers/TwitterAuthProvider.d.ts +15 -0
- package/dist/typescript/lib/providers/TwitterAuthProvider.d.ts.map +1 -0
- package/dist/typescript/lib/types/auth.d.ts +305 -0
- package/dist/typescript/lib/types/auth.d.ts.map +1 -0
- package/dist/typescript/lib/types/internal.d.ts +292 -0
- package/dist/typescript/lib/types/internal.d.ts.map +1 -0
- package/dist/typescript/lib/types/namespaced.d.ts +2185 -0
- package/dist/typescript/lib/types/namespaced.d.ts.map +1 -0
- package/dist/typescript/lib/version.d.ts +2 -0
- package/dist/typescript/lib/version.d.ts.map +1 -0
- package/dist/typescript/lib/web/RNFBAuthModule.android.d.ts +3 -0
- package/dist/typescript/lib/web/RNFBAuthModule.android.d.ts.map +1 -0
- package/dist/typescript/lib/web/RNFBAuthModule.d.ts +406 -0
- package/dist/typescript/lib/web/RNFBAuthModule.d.ts.map +1 -0
- package/dist/typescript/lib/web/RNFBAuthModule.ios.d.ts +3 -0
- package/dist/typescript/lib/web/RNFBAuthModule.ios.d.ts.map +1 -0
- package/dist/typescript/package.json +1 -0
- package/ios/RNFBAuth/RNFBAuthModule.m +4 -2
- package/lib/ActionCodeURL.ts +174 -0
- package/lib/ConfirmationResult.ts +42 -0
- package/lib/MultiFactorResolver.ts +51 -0
- package/lib/PhoneAuthListener.ts +312 -0
- package/lib/PhoneAuthState.ts +22 -0
- package/lib/{PhoneMultiFactorGenerator.js → PhoneMultiFactorGenerator.ts} +8 -2
- package/lib/Settings.ts +59 -0
- package/lib/TotpMultiFactorGenerator.ts +78 -0
- package/lib/TotpSecret.ts +71 -0
- package/lib/{User.js → User.ts} +127 -83
- package/lib/constants.ts +55 -0
- package/lib/credentials/AuthCredential.ts +55 -0
- package/lib/credentials/EmailAuthCredential.ts +70 -0
- package/lib/credentials/OAuthCredential.ts +113 -0
- package/lib/credentials/PhoneAuthCredential.ts +66 -0
- package/lib/{providers/GithubAuthProvider.js → credentials/index.ts} +4 -19
- package/lib/getMultiFactorResolver.ts +40 -0
- package/lib/{providers/TwitterAuthProvider.js → index.ts} +14 -19
- package/lib/modular.ts +1158 -0
- package/lib/multiFactor.ts +83 -0
- package/lib/namespaced.ts +846 -0
- package/lib/password-policy/{PasswordPolicyImpl.js → PasswordPolicyImpl.ts} +37 -19
- package/lib/password-policy/PasswordPolicyMixin.ts +83 -0
- package/lib/password-policy/passwordPolicyApi.ts +60 -0
- package/lib/providers/AppleAuthProvider.ts +44 -0
- package/lib/providers/EmailAuthProvider.ts +42 -0
- package/lib/providers/FacebookAuthProvider.ts +58 -0
- package/lib/providers/GithubAuthProvider.ts +51 -0
- package/lib/providers/GoogleAuthProvider.ts +60 -0
- package/lib/providers/OAuthProvider.ts +150 -0
- package/lib/providers/OIDCAuthProvider.ts +49 -0
- package/lib/providers/PhoneAuthProvider.ts +161 -0
- package/lib/providers/TwitterAuthProvider.ts +52 -0
- package/lib/types/auth.ts +393 -0
- package/lib/types/internal.ts +474 -0
- package/lib/{index.d.ts → types/namespaced.ts} +52 -41
- package/lib/version.ts +2 -0
- package/lib/web/RNFBAuthModule.ts +1359 -0
- package/package.json +41 -9
- package/plugin/tsconfig.tsbuildinfo +1 -1
- package/tsconfig.json +26 -0
- package/tsdoc.json +22 -0
- package/typedoc.json +9 -2
- package/lib/index.js +0 -572
- package/lib/modular/index.d.ts +0 -801
- package/lib/modular/index.js +0 -651
- package/lib/providers/OAuthProvider.js +0 -70
- package/lib/providers/PhoneAuthProvider.js +0 -52
- package/lib/version.js +0 -2
- /package/lib/web/{RNFBAuthModule.android.js → RNFBAuthModule.android.ts} +0 -0
- /package/lib/web/{RNFBAuthModule.ios.js → RNFBAuthModule.ios.ts} +0 -0
package/lib/{User.js → User.ts}
RENAMED
|
@@ -21,30 +21,42 @@ import {
|
|
|
21
21
|
isUndefined,
|
|
22
22
|
isBoolean,
|
|
23
23
|
} from '@react-native-firebase/app/dist/module/common';
|
|
24
|
+
import type { IdTokenResult, UserInfo, UserMetadata } from './types/auth';
|
|
25
|
+
import type { FirebaseAuthTypes } from './types/namespaced';
|
|
26
|
+
import type { AuthInternal, NativeUserInternal } from './types/internal';
|
|
27
|
+
|
|
28
|
+
type AuthProviderWithObject = FirebaseAuthTypes.AuthProvider & {
|
|
29
|
+
toObject(): Record<string, unknown>;
|
|
30
|
+
};
|
|
24
31
|
|
|
25
32
|
export default class User {
|
|
26
|
-
|
|
33
|
+
/** @internal */
|
|
34
|
+
readonly _auth: AuthInternal;
|
|
35
|
+
/** @internal */
|
|
36
|
+
readonly _user: NativeUserInternal;
|
|
37
|
+
|
|
38
|
+
constructor(auth: AuthInternal, user: NativeUserInternal) {
|
|
27
39
|
this._auth = auth;
|
|
28
40
|
this._user = user;
|
|
29
41
|
}
|
|
30
42
|
|
|
31
|
-
get displayName() {
|
|
43
|
+
get displayName(): string | null {
|
|
32
44
|
return this._user.displayName || null;
|
|
33
45
|
}
|
|
34
46
|
|
|
35
|
-
get email() {
|
|
47
|
+
get email(): string | null {
|
|
36
48
|
return this._user.email || null;
|
|
37
49
|
}
|
|
38
50
|
|
|
39
|
-
get emailVerified() {
|
|
51
|
+
get emailVerified(): boolean {
|
|
40
52
|
return this._user.emailVerified || false;
|
|
41
53
|
}
|
|
42
54
|
|
|
43
|
-
get isAnonymous() {
|
|
55
|
+
get isAnonymous(): boolean {
|
|
44
56
|
return this._user.isAnonymous || false;
|
|
45
57
|
}
|
|
46
58
|
|
|
47
|
-
get metadata() {
|
|
59
|
+
get metadata(): UserMetadata {
|
|
48
60
|
const { metadata } = this._user;
|
|
49
61
|
|
|
50
62
|
return {
|
|
@@ -53,148 +65,173 @@ export default class User {
|
|
|
53
65
|
};
|
|
54
66
|
}
|
|
55
67
|
|
|
56
|
-
get multiFactor() {
|
|
68
|
+
get multiFactor(): FirebaseAuthTypes.MultiFactor | null {
|
|
57
69
|
return this._user.multiFactor || null;
|
|
58
70
|
}
|
|
59
71
|
|
|
60
|
-
get phoneNumber() {
|
|
72
|
+
get phoneNumber(): string | null {
|
|
61
73
|
return this._user.phoneNumber || null;
|
|
62
74
|
}
|
|
63
75
|
|
|
64
|
-
get tenantId() {
|
|
76
|
+
get tenantId(): string | null {
|
|
65
77
|
return this._user.tenantId || null;
|
|
66
78
|
}
|
|
67
79
|
|
|
68
|
-
get photoURL() {
|
|
80
|
+
get photoURL(): string | null {
|
|
69
81
|
return this._user.photoURL || null;
|
|
70
82
|
}
|
|
71
83
|
|
|
72
|
-
get providerData() {
|
|
73
|
-
return this._user.providerData
|
|
84
|
+
get providerData(): UserInfo[] {
|
|
85
|
+
return this._user.providerData.map(provider => ({
|
|
86
|
+
displayName: provider.displayName ?? null,
|
|
87
|
+
email: provider.email ?? null,
|
|
88
|
+
phoneNumber: provider.phoneNumber ?? null,
|
|
89
|
+
photoURL: provider.photoURL ?? null,
|
|
90
|
+
providerId: provider.providerId,
|
|
91
|
+
uid: provider.uid,
|
|
92
|
+
}));
|
|
74
93
|
}
|
|
75
94
|
|
|
76
|
-
get providerId() {
|
|
95
|
+
get providerId(): string {
|
|
77
96
|
return this._user.providerId;
|
|
78
97
|
}
|
|
79
98
|
|
|
80
|
-
get uid() {
|
|
99
|
+
get uid(): string {
|
|
81
100
|
return this._user.uid;
|
|
82
101
|
}
|
|
83
102
|
|
|
84
|
-
delete() {
|
|
103
|
+
delete(): Promise<void> {
|
|
85
104
|
return this._auth.native.delete().then(() => {
|
|
86
|
-
this._auth._setUser();
|
|
105
|
+
this._auth._setUser(null);
|
|
87
106
|
});
|
|
88
107
|
}
|
|
89
108
|
|
|
90
|
-
getIdToken(forceRefresh = false) {
|
|
109
|
+
getIdToken(forceRefresh = false): Promise<string> {
|
|
91
110
|
return this._auth.native.getIdToken(forceRefresh);
|
|
92
111
|
}
|
|
93
112
|
|
|
94
|
-
getIdTokenResult(forceRefresh = false) {
|
|
95
|
-
return this._auth.native.getIdTokenResult(forceRefresh)
|
|
113
|
+
getIdTokenResult(forceRefresh = false): Promise<IdTokenResult> {
|
|
114
|
+
return this._auth.native.getIdTokenResult(forceRefresh) as Promise<IdTokenResult>;
|
|
96
115
|
}
|
|
97
116
|
|
|
98
|
-
linkWithCredential(
|
|
117
|
+
linkWithCredential(
|
|
118
|
+
credential: FirebaseAuthTypes.AuthCredential,
|
|
119
|
+
): Promise<FirebaseAuthTypes.UserCredential> {
|
|
99
120
|
return this._auth.native
|
|
100
121
|
.linkWithCredential(credential.providerId, credential.token, credential.secret)
|
|
101
|
-
.then(
|
|
122
|
+
.then(
|
|
123
|
+
userCredential =>
|
|
124
|
+
this._auth._setUserCredential(userCredential) as FirebaseAuthTypes.UserCredential,
|
|
125
|
+
);
|
|
102
126
|
}
|
|
103
127
|
|
|
104
|
-
linkWithPopup(provider) {
|
|
128
|
+
linkWithPopup(provider: AuthProviderWithObject): Promise<FirebaseAuthTypes.UserCredential> {
|
|
105
129
|
// call through to linkWithRedirect for shared implementation
|
|
106
130
|
return this.linkWithRedirect(provider);
|
|
107
131
|
}
|
|
108
132
|
|
|
109
|
-
linkWithRedirect(provider) {
|
|
133
|
+
linkWithRedirect(provider: AuthProviderWithObject): Promise<FirebaseAuthTypes.UserCredential> {
|
|
110
134
|
return this._auth.native
|
|
111
135
|
.linkWithProvider(provider.toObject())
|
|
112
|
-
.then(
|
|
136
|
+
.then(
|
|
137
|
+
userCredential =>
|
|
138
|
+
this._auth._setUserCredential(userCredential) as FirebaseAuthTypes.UserCredential,
|
|
139
|
+
);
|
|
113
140
|
}
|
|
114
141
|
|
|
115
|
-
reauthenticateWithCredential(
|
|
142
|
+
reauthenticateWithCredential(
|
|
143
|
+
credential: FirebaseAuthTypes.AuthCredential,
|
|
144
|
+
): Promise<FirebaseAuthTypes.UserCredential> {
|
|
116
145
|
return this._auth.native
|
|
117
146
|
.reauthenticateWithCredential(credential.providerId, credential.token, credential.secret)
|
|
118
|
-
.then(
|
|
147
|
+
.then(
|
|
148
|
+
userCredential =>
|
|
149
|
+
this._auth._setUserCredential(userCredential) as FirebaseAuthTypes.UserCredential,
|
|
150
|
+
);
|
|
119
151
|
}
|
|
120
152
|
|
|
121
|
-
reauthenticateWithPopup(
|
|
153
|
+
reauthenticateWithPopup(
|
|
154
|
+
provider: AuthProviderWithObject,
|
|
155
|
+
): Promise<FirebaseAuthTypes.UserCredential> {
|
|
122
156
|
// call through to reauthenticateWithRedirect for shared implementation
|
|
123
|
-
return this.
|
|
157
|
+
return this._auth.native
|
|
158
|
+
.reauthenticateWithProvider(provider.toObject())
|
|
159
|
+
.then(
|
|
160
|
+
userCredential =>
|
|
161
|
+
this._auth._setUserCredential(userCredential) as FirebaseAuthTypes.UserCredential,
|
|
162
|
+
);
|
|
124
163
|
}
|
|
125
164
|
|
|
126
|
-
reauthenticateWithRedirect(provider) {
|
|
165
|
+
reauthenticateWithRedirect(provider: AuthProviderWithObject): Promise<void> {
|
|
127
166
|
return this._auth.native
|
|
128
167
|
.reauthenticateWithProvider(provider.toObject())
|
|
129
|
-
.then(userCredential =>
|
|
168
|
+
.then(userCredential => {
|
|
169
|
+
this._auth._setUserCredential(userCredential);
|
|
170
|
+
});
|
|
130
171
|
}
|
|
131
172
|
|
|
132
|
-
reload() {
|
|
173
|
+
reload(): Promise<void> {
|
|
133
174
|
return this._auth.native.reload().then(user => {
|
|
134
175
|
this._auth._setUser(user);
|
|
135
176
|
});
|
|
136
177
|
}
|
|
137
178
|
|
|
138
|
-
sendEmailVerification(actionCodeSettings) {
|
|
179
|
+
sendEmailVerification(actionCodeSettings?: FirebaseAuthTypes.ActionCodeSettings): Promise<void> {
|
|
139
180
|
if (isObject(actionCodeSettings)) {
|
|
140
|
-
|
|
181
|
+
const settings = actionCodeSettings as FirebaseAuthTypes.ActionCodeSettings;
|
|
182
|
+
|
|
183
|
+
if (!isString(settings.url)) {
|
|
141
184
|
throw new Error(
|
|
142
185
|
"firebase.auth.User.sendEmailVerification(*) 'actionCodeSettings.url' expected a string value.",
|
|
143
186
|
);
|
|
144
187
|
}
|
|
145
188
|
|
|
146
|
-
if (!isUndefined(
|
|
189
|
+
if (!isUndefined(settings.linkDomain) && !isString(settings.linkDomain)) {
|
|
147
190
|
throw new Error(
|
|
148
191
|
"firebase.auth.User.sendEmailVerification(*) 'actionCodeSettings.linkDomain' expected a string value.",
|
|
149
192
|
);
|
|
150
193
|
}
|
|
151
194
|
|
|
152
|
-
if (
|
|
153
|
-
!isUndefined(actionCodeSettings.handleCodeInApp) &&
|
|
154
|
-
!isBoolean(actionCodeSettings.handleCodeInApp)
|
|
155
|
-
) {
|
|
195
|
+
if (!isUndefined(settings.handleCodeInApp) && !isBoolean(settings.handleCodeInApp)) {
|
|
156
196
|
throw new Error(
|
|
157
197
|
"firebase.auth.User.sendEmailVerification(*) 'actionCodeSettings.handleCodeInApp' expected a boolean value.",
|
|
158
198
|
);
|
|
159
199
|
}
|
|
160
200
|
|
|
161
|
-
if (!isUndefined(
|
|
162
|
-
if (!isObject(
|
|
201
|
+
if (!isUndefined(settings.iOS)) {
|
|
202
|
+
if (!isObject(settings.iOS)) {
|
|
163
203
|
throw new Error(
|
|
164
204
|
"firebase.auth.User.sendEmailVerification(*) 'actionCodeSettings.iOS' expected an object value.",
|
|
165
205
|
);
|
|
166
206
|
}
|
|
167
|
-
if (!isString(
|
|
207
|
+
if (!isString(settings.iOS.bundleId)) {
|
|
168
208
|
throw new Error(
|
|
169
209
|
"firebase.auth.User.sendEmailVerification(*) 'actionCodeSettings.iOS.bundleId' expected a string value.",
|
|
170
210
|
);
|
|
171
211
|
}
|
|
172
212
|
}
|
|
173
213
|
|
|
174
|
-
if (!isUndefined(
|
|
175
|
-
if (!isObject(
|
|
214
|
+
if (!isUndefined(settings.android)) {
|
|
215
|
+
if (!isObject(settings.android)) {
|
|
176
216
|
throw new Error(
|
|
177
217
|
"firebase.auth.User.sendEmailVerification(*) 'actionCodeSettings.android' expected an object value.",
|
|
178
218
|
);
|
|
179
219
|
}
|
|
180
|
-
if (!isString(
|
|
220
|
+
if (!isString(settings.android.packageName)) {
|
|
181
221
|
throw new Error(
|
|
182
222
|
"firebase.auth.User.sendEmailVerification(*) 'actionCodeSettings.android.packageName' expected a string value.",
|
|
183
223
|
);
|
|
184
224
|
}
|
|
185
225
|
|
|
186
|
-
if (
|
|
187
|
-
!isUndefined(actionCodeSettings.android.installApp) &&
|
|
188
|
-
!isBoolean(actionCodeSettings.android.installApp)
|
|
189
|
-
) {
|
|
226
|
+
if (!isUndefined(settings.android.installApp) && !isBoolean(settings.android.installApp)) {
|
|
190
227
|
throw new Error(
|
|
191
228
|
"firebase.auth.User.sendEmailVerification(*) 'actionCodeSettings.android.installApp' expected a boolean value.",
|
|
192
229
|
);
|
|
193
230
|
}
|
|
194
231
|
|
|
195
232
|
if (
|
|
196
|
-
!isUndefined(
|
|
197
|
-
!isString(
|
|
233
|
+
!isUndefined(settings.android.minimumVersion) &&
|
|
234
|
+
!isString(settings.android.minimumVersion)
|
|
198
235
|
) {
|
|
199
236
|
throw new Error(
|
|
200
237
|
"firebase.auth.User.sendEmailVerification(*) 'actionCodeSettings.android.minimumVersion' expected a string value.",
|
|
@@ -204,31 +241,39 @@ export default class User {
|
|
|
204
241
|
}
|
|
205
242
|
|
|
206
243
|
return this._auth.native.sendEmailVerification(actionCodeSettings).then(user => {
|
|
207
|
-
|
|
208
|
-
|
|
244
|
+
this._auth._setUser(user);
|
|
245
|
+
});
|
|
209
246
|
}
|
|
210
247
|
|
|
211
|
-
toJSON() {
|
|
248
|
+
toJSON(): object {
|
|
212
249
|
return Object.assign({}, this._user);
|
|
213
250
|
}
|
|
214
251
|
|
|
215
|
-
unlink(providerId) {
|
|
216
|
-
return this._auth.native
|
|
252
|
+
unlink(providerId: string): Promise<FirebaseAuthTypes.User> {
|
|
253
|
+
return this._auth.native
|
|
254
|
+
.unlink(providerId)
|
|
255
|
+
.then(user => {
|
|
256
|
+
const updatedUser = this._auth._setUser(user);
|
|
257
|
+
if (!updatedUser) {
|
|
258
|
+
throw new Error('firebase.auth.User.unlink() returned no user after unlinking provider.');
|
|
259
|
+
}
|
|
260
|
+
return updatedUser;
|
|
261
|
+
});
|
|
217
262
|
}
|
|
218
263
|
|
|
219
|
-
updateEmail(email) {
|
|
264
|
+
updateEmail(email: string): Promise<void> {
|
|
220
265
|
return this._auth.native.updateEmail(email).then(user => {
|
|
221
266
|
this._auth._setUser(user);
|
|
222
267
|
});
|
|
223
268
|
}
|
|
224
269
|
|
|
225
|
-
updatePassword(password) {
|
|
270
|
+
updatePassword(password: string): Promise<void> {
|
|
226
271
|
return this._auth.native.updatePassword(password).then(user => {
|
|
227
272
|
this._auth._setUser(user);
|
|
228
273
|
});
|
|
229
274
|
}
|
|
230
275
|
|
|
231
|
-
updatePhoneNumber(credential) {
|
|
276
|
+
updatePhoneNumber(credential: FirebaseAuthTypes.AuthCredential): Promise<void> {
|
|
232
277
|
return this._auth.native
|
|
233
278
|
.updatePhoneNumber(credential.providerId, credential.token, credential.secret)
|
|
234
279
|
.then(user => {
|
|
@@ -236,13 +281,16 @@ export default class User {
|
|
|
236
281
|
});
|
|
237
282
|
}
|
|
238
283
|
|
|
239
|
-
updateProfile(updates) {
|
|
284
|
+
updateProfile(updates: FirebaseAuthTypes.UpdateProfile): Promise<void> {
|
|
240
285
|
return this._auth.native.updateProfile(updates).then(user => {
|
|
241
286
|
this._auth._setUser(user);
|
|
242
287
|
});
|
|
243
288
|
}
|
|
244
289
|
|
|
245
|
-
verifyBeforeUpdateEmail(
|
|
290
|
+
verifyBeforeUpdateEmail(
|
|
291
|
+
newEmail: string,
|
|
292
|
+
actionCodeSettings?: FirebaseAuthTypes.ActionCodeSettings,
|
|
293
|
+
): Promise<void> {
|
|
246
294
|
if (!isString(newEmail)) {
|
|
247
295
|
throw new Error(
|
|
248
296
|
"firebase.auth.User.verifyBeforeUpdateEmail(*) 'newEmail' expected a string value.",
|
|
@@ -250,64 +298,60 @@ export default class User {
|
|
|
250
298
|
}
|
|
251
299
|
|
|
252
300
|
if (isObject(actionCodeSettings)) {
|
|
253
|
-
|
|
301
|
+
const settings = actionCodeSettings as FirebaseAuthTypes.ActionCodeSettings;
|
|
302
|
+
|
|
303
|
+
if (!isString(settings.url)) {
|
|
254
304
|
throw new Error(
|
|
255
305
|
"firebase.auth.User.verifyBeforeUpdateEmail(_, *) 'actionCodeSettings.url' expected a string value.",
|
|
256
306
|
);
|
|
257
307
|
}
|
|
258
308
|
|
|
259
|
-
if (!isUndefined(
|
|
309
|
+
if (!isUndefined(settings.linkDomain) && !isString(settings.linkDomain)) {
|
|
260
310
|
throw new Error(
|
|
261
311
|
"firebase.auth.User.verifyBeforeUpdateEmail(_, *) 'actionCodeSettings.linkDomain' expected a string value.",
|
|
262
312
|
);
|
|
263
313
|
}
|
|
264
314
|
|
|
265
|
-
if (
|
|
266
|
-
!isUndefined(actionCodeSettings.handleCodeInApp) &&
|
|
267
|
-
!isBoolean(actionCodeSettings.handleCodeInApp)
|
|
268
|
-
) {
|
|
315
|
+
if (!isUndefined(settings.handleCodeInApp) && !isBoolean(settings.handleCodeInApp)) {
|
|
269
316
|
throw new Error(
|
|
270
317
|
"firebase.auth.User.verifyBeforeUpdateEmail(_, *) 'actionCodeSettings.handleCodeInApp' expected a boolean value.",
|
|
271
318
|
);
|
|
272
319
|
}
|
|
273
320
|
|
|
274
|
-
if (!isUndefined(
|
|
275
|
-
if (!isObject(
|
|
321
|
+
if (!isUndefined(settings.iOS)) {
|
|
322
|
+
if (!isObject(settings.iOS)) {
|
|
276
323
|
throw new Error(
|
|
277
324
|
"firebase.auth.User.verifyBeforeUpdateEmail(_, *) 'actionCodeSettings.iOS' expected an object value.",
|
|
278
325
|
);
|
|
279
326
|
}
|
|
280
|
-
if (!isString(
|
|
327
|
+
if (!isString(settings.iOS.bundleId)) {
|
|
281
328
|
throw new Error(
|
|
282
329
|
"firebase.auth.User.verifyBeforeUpdateEmail(_, *) 'actionCodeSettings.iOS.bundleId' expected a string value.",
|
|
283
330
|
);
|
|
284
331
|
}
|
|
285
332
|
}
|
|
286
333
|
|
|
287
|
-
if (!isUndefined(
|
|
288
|
-
if (!isObject(
|
|
334
|
+
if (!isUndefined(settings.android)) {
|
|
335
|
+
if (!isObject(settings.android)) {
|
|
289
336
|
throw new Error(
|
|
290
337
|
"firebase.auth.User.verifyBeforeUpdateEmail(_, *) 'actionCodeSettings.android' expected an object value.",
|
|
291
338
|
);
|
|
292
339
|
}
|
|
293
|
-
if (!isString(
|
|
340
|
+
if (!isString(settings.android.packageName)) {
|
|
294
341
|
throw new Error(
|
|
295
342
|
"firebase.auth.User.verifyBeforeUpdateEmail(_, *) 'actionCodeSettings.android.packageName' expected a string value.",
|
|
296
343
|
);
|
|
297
344
|
}
|
|
298
345
|
|
|
299
|
-
if (
|
|
300
|
-
!isUndefined(actionCodeSettings.android.installApp) &&
|
|
301
|
-
!isBoolean(actionCodeSettings.android.installApp)
|
|
302
|
-
) {
|
|
346
|
+
if (!isUndefined(settings.android.installApp) && !isBoolean(settings.android.installApp)) {
|
|
303
347
|
throw new Error(
|
|
304
348
|
"firebase.auth.User.verifyBeforeUpdateEmail(_, *) 'actionCodeSettings.android.installApp' expected a boolean value.",
|
|
305
349
|
);
|
|
306
350
|
}
|
|
307
351
|
|
|
308
352
|
if (
|
|
309
|
-
!isUndefined(
|
|
310
|
-
!isString(
|
|
353
|
+
!isUndefined(settings.android.minimumVersion) &&
|
|
354
|
+
!isString(settings.android.minimumVersion)
|
|
311
355
|
) {
|
|
312
356
|
throw new Error(
|
|
313
357
|
"firebase.auth.User.verifyBeforeUpdateEmail(_, *) 'actionCodeSettings.android.minimumVersion' expected a string value.",
|
|
@@ -317,27 +361,27 @@ export default class User {
|
|
|
317
361
|
}
|
|
318
362
|
|
|
319
363
|
return this._auth.native.verifyBeforeUpdateEmail(newEmail, actionCodeSettings).then(user => {
|
|
320
|
-
|
|
321
|
-
|
|
364
|
+
this._auth._setUser(user);
|
|
365
|
+
});
|
|
322
366
|
}
|
|
323
367
|
|
|
324
368
|
/**
|
|
325
369
|
* KNOWN UNSUPPORTED METHODS
|
|
326
370
|
*/
|
|
327
371
|
|
|
328
|
-
linkWithPhoneNumber() {
|
|
372
|
+
linkWithPhoneNumber(): never {
|
|
329
373
|
throw new Error(
|
|
330
374
|
'firebase.auth.User.linkWithPhoneNumber() is unsupported by the native Firebase SDKs.',
|
|
331
375
|
);
|
|
332
376
|
}
|
|
333
377
|
|
|
334
|
-
reauthenticateWithPhoneNumber() {
|
|
378
|
+
reauthenticateWithPhoneNumber(): never {
|
|
335
379
|
throw new Error(
|
|
336
380
|
'firebase.auth.User.reauthenticateWithPhoneNumber() is unsupported by the native Firebase SDKs.',
|
|
337
381
|
);
|
|
338
382
|
}
|
|
339
383
|
|
|
340
|
-
get refreshToken() {
|
|
384
|
+
get refreshToken(): never {
|
|
341
385
|
throw new Error('firebase.auth.User.refreshToken is unsupported by the native Firebase SDKs.');
|
|
342
386
|
}
|
|
343
387
|
}
|
package/lib/constants.ts
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
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
|
+
|
|
18
|
+
export const ActionCodeOperation = {
|
|
19
|
+
EMAIL_SIGNIN: 'EMAIL_SIGNIN',
|
|
20
|
+
PASSWORD_RESET: 'PASSWORD_RESET',
|
|
21
|
+
RECOVER_EMAIL: 'RECOVER_EMAIL',
|
|
22
|
+
REVERT_SECOND_FACTOR_ADDITION: 'REVERT_SECOND_FACTOR_ADDITION',
|
|
23
|
+
VERIFY_AND_CHANGE_EMAIL: 'VERIFY_AND_CHANGE_EMAIL',
|
|
24
|
+
VERIFY_EMAIL: 'VERIFY_EMAIL',
|
|
25
|
+
} as const;
|
|
26
|
+
|
|
27
|
+
export const FactorId = {
|
|
28
|
+
PHONE: 'phone',
|
|
29
|
+
TOTP: 'totp',
|
|
30
|
+
} as const;
|
|
31
|
+
|
|
32
|
+
export const OperationType = {
|
|
33
|
+
LINK: 'link',
|
|
34
|
+
REAUTHENTICATE: 'reauthenticate',
|
|
35
|
+
SIGN_IN: 'signIn',
|
|
36
|
+
} as const;
|
|
37
|
+
|
|
38
|
+
export const ProviderId = {
|
|
39
|
+
FACEBOOK: 'facebook.com',
|
|
40
|
+
GITHUB: 'github.com',
|
|
41
|
+
GOOGLE: 'google.com',
|
|
42
|
+
PASSWORD: 'password',
|
|
43
|
+
PHONE: 'phone',
|
|
44
|
+
TWITTER: 'twitter.com',
|
|
45
|
+
} as const;
|
|
46
|
+
|
|
47
|
+
export const SignInMethod = {
|
|
48
|
+
EMAIL_LINK: 'emailLink',
|
|
49
|
+
EMAIL_PASSWORD: 'password',
|
|
50
|
+
FACEBOOK: 'facebook.com',
|
|
51
|
+
GITHUB: 'github.com',
|
|
52
|
+
GOOGLE: 'google.com',
|
|
53
|
+
PHONE: 'phone',
|
|
54
|
+
TWITTER: 'twitter.com',
|
|
55
|
+
} as const;
|
|
@@ -0,0 +1,55 @@
|
|
|
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
|
+
|
|
18
|
+
export function parseCredentialJSON(json: object | string): object | null {
|
|
19
|
+
if (typeof json === 'string') {
|
|
20
|
+
try {
|
|
21
|
+
return JSON.parse(json) as object;
|
|
22
|
+
} catch {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (json === null || Array.isArray(json)) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return json;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export class AuthCredential {
|
|
35
|
+
readonly providerId: string;
|
|
36
|
+
readonly signInMethod: string;
|
|
37
|
+
/** @internal RNFB native bridge token slot. */
|
|
38
|
+
readonly token: string;
|
|
39
|
+
/** @internal RNFB native bridge secret slot. */
|
|
40
|
+
readonly secret: string;
|
|
41
|
+
|
|
42
|
+
constructor(providerId: string, signInMethod: string, token: string, secret: string) {
|
|
43
|
+
this.providerId = providerId;
|
|
44
|
+
this.signInMethod = signInMethod;
|
|
45
|
+
this.token = token;
|
|
46
|
+
this.secret = secret;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
toJSON(): object {
|
|
50
|
+
return {
|
|
51
|
+
providerId: this.providerId,
|
|
52
|
+
signInMethod: this.signInMethod,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
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
|
+
|
|
18
|
+
import { AuthCredential, parseCredentialJSON } from './AuthCredential';
|
|
19
|
+
|
|
20
|
+
type EmailCredentialJSON = {
|
|
21
|
+
email?: string;
|
|
22
|
+
password?: string;
|
|
23
|
+
signInMethod?: string;
|
|
24
|
+
tenantId?: string | null;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export class EmailAuthCredential extends AuthCredential {
|
|
28
|
+
constructor(
|
|
29
|
+
signInMethod: 'password' | 'emailLink',
|
|
30
|
+
email: string,
|
|
31
|
+
password: string,
|
|
32
|
+
) {
|
|
33
|
+
super(signInMethod, signInMethod, email, password);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
toJSON(): object {
|
|
37
|
+
return {
|
|
38
|
+
email: this.token,
|
|
39
|
+
password: this.secret,
|
|
40
|
+
signInMethod: this.signInMethod,
|
|
41
|
+
tenantId: null,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
static fromJSON(json: object | string): EmailAuthCredential | null {
|
|
46
|
+
const parsed = parseCredentialJSON(json) as EmailCredentialJSON | null;
|
|
47
|
+
if (!parsed) {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const signInMethod = parsed.signInMethod;
|
|
52
|
+
if (signInMethod !== 'password' && signInMethod !== 'emailLink') {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (typeof parsed.email !== 'string' || typeof parsed.password !== 'string') {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return new EmailAuthCredential(signInMethod, parsed.email, parsed.password);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export function createEmailAuthCredential(
|
|
65
|
+
email: string,
|
|
66
|
+
password: string,
|
|
67
|
+
signInMethod: 'password' | 'emailLink',
|
|
68
|
+
): EmailAuthCredential {
|
|
69
|
+
return new EmailAuthCredential(signInMethod, email, password);
|
|
70
|
+
}
|