@react-native-firebase/auth 20.3.0 → 20.5.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 +8 -0
- package/__tests__/auth.test.ts +275 -1
- package/lib/index.d.ts +17 -1
- package/lib/index.js +28 -57
- package/lib/modular/index.d.ts +662 -0
- package/lib/modular/index.js +296 -176
- package/lib/version.js +1 -1
- package/package.json +3 -3
package/lib/modular/index.js
CHANGED
@@ -13,462 +13,582 @@
|
|
13
13
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
14
|
* See the License for the specific language governing permissions and
|
15
15
|
* limitations under the License.
|
16
|
-
*
|
17
16
|
*/
|
18
17
|
|
19
|
-
import { isString } from '@react-native-firebase/app/lib/common';
|
20
18
|
import { firebase } from '..';
|
21
19
|
|
22
|
-
|
20
|
+
/**
|
21
|
+
* @typedef {import('@firebase/app-types').FirebaseApp} FirebaseApp
|
22
|
+
* @typedef {import('..').FirebaseAuthTypes} FirebaseAuthTypes
|
23
|
+
* @typedef {import('..').FirebaseAuthTypes.Module} Auth
|
24
|
+
* @typedef {import('..').FirebaseAuthTypes.CallbackOrObserver} CallbackOrObserver
|
25
|
+
* @typedef {import('..').FirebaseAuthTypes.AuthListenerCallback} AuthListenerCallback
|
26
|
+
* @typedef {import('..').FirebaseAuthTypes.ActionCodeInfo} ActionCodeInfo
|
27
|
+
* @typedef {import('..').FirebaseAuthTypes.UserCredential} UserCredential
|
28
|
+
* @typedef {import('..').FirebaseAuthTypes.MultiFactorError} MultiFactorError
|
29
|
+
* @typedef {import('..').FirebaseAuthTypes.MultiFactorUser} MultiFactorUser
|
30
|
+
* @typedef {import('..').FirebaseAuthTypes.MultiFactorResolver} MultiFactorResolver
|
31
|
+
* @typedef {import('..').FirebaseAuthTypes.ConfirmationResult} ConfirmationResult
|
32
|
+
* @typedef {import('..').FirebaseAuthTypes.AuthCredential} AuthCredential
|
33
|
+
* @typedef {import('..').FirebaseAuthTypes.AuthProvider} AuthProvider
|
34
|
+
* @typedef {import('..').FirebaseAuthTypes.PhoneAuthListener} PhoneAuthListener
|
35
|
+
* @typedef {import('..').FirebaseAuthTypes.ActionCodeSettings} ActionCodeSettings
|
36
|
+
* @typedef {import('..').FirebaseAuthTypes.User} User
|
37
|
+
* @typedef {import('..').FirebaseAuthTypes.IdTokenResult} IdTokenResult
|
38
|
+
* @typedef {import('..').FirebaseAuthTypes.AdditionalUserInfo} AdditionalUserInfo
|
39
|
+
* @typedef {import('..').FirebaseAuthTypes.ActionCodeURL} ActionCodeURL
|
40
|
+
* @typedef {import('..').FirebaseAuthTypes.ApplicationVerifier} ApplicationVerifier
|
41
|
+
*/
|
42
|
+
|
43
|
+
/**
|
23
44
|
* Returns the Auth instance associated with the provided FirebaseApp.
|
24
|
-
|
25
|
-
|
26
|
-
constructor(app) {
|
27
|
-
this.app = app ? firebase.app(app.name) : firebase.app();
|
28
|
-
this._languageCode = this.app.auth().languageCode;
|
29
|
-
}
|
30
|
-
|
31
|
-
get config() {
|
32
|
-
return this.app.auth().config;
|
33
|
-
}
|
34
|
-
|
35
|
-
get currentUser() {
|
36
|
-
return this.app.auth().currentUser;
|
37
|
-
}
|
38
|
-
|
39
|
-
get languageCode() {
|
40
|
-
return this._languageCode;
|
41
|
-
}
|
42
|
-
|
43
|
-
set languageCode(code) {
|
44
|
-
if (code === null || isString(code)) {
|
45
|
-
this._languageCode = code;
|
46
|
-
this.app.auth().languageCode = code;
|
47
|
-
return;
|
48
|
-
}
|
49
|
-
throw new Error("expected 'languageCode' to be a string or null value");
|
50
|
-
}
|
51
|
-
|
52
|
-
get settings() {
|
53
|
-
return this.app.auth().settings;
|
54
|
-
}
|
55
|
-
|
56
|
-
get tenantId() {
|
57
|
-
return this.app.auth().tenantId;
|
58
|
-
}
|
59
|
-
}
|
60
|
-
|
61
|
-
/*
|
62
|
-
* Returns the Auth instance associated with the provided FirebaseApp.
|
63
|
-
*
|
64
|
-
* If no instance exists, initializes an Auth instance with platform-specific default dependencies.
|
45
|
+
* @param {FirebaseApp} [app] - The Firebase app instance.
|
46
|
+
* @returns {Auth}
|
65
47
|
*/
|
66
48
|
export function getAuth(app) {
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
return auth.app.auth();
|
49
|
+
if (app) {
|
50
|
+
return firebase.app(app.name).auth();
|
51
|
+
}
|
52
|
+
return firebase.app().auth();
|
72
53
|
}
|
73
54
|
|
74
|
-
|
55
|
+
/**
|
75
56
|
* This function allows more control over the Auth instance than getAuth().
|
76
|
-
*
|
77
|
-
*
|
78
|
-
*
|
79
|
-
* Use initializeAuth if you need control over which persistence layer is used, or to minimize bundle size
|
80
|
-
* if you're not using either signInWithPopup or signInWithRedirect.
|
57
|
+
* @param {FirebaseApp} app - The Firebase app instance.
|
58
|
+
* @param {any} [deps] - Optional. Dependencies for the Auth instance.
|
59
|
+
* @returns {Auth}
|
81
60
|
*/
|
82
61
|
export function initializeAuth(app, deps) {
|
83
|
-
|
62
|
+
if (app) {
|
63
|
+
return firebase.app(app.name).auth();
|
64
|
+
}
|
65
|
+
return firebase.app().auth();
|
84
66
|
}
|
85
67
|
|
86
|
-
|
68
|
+
/**
|
87
69
|
* Applies a verification code sent to the user by email or other out-of-band mechanism.
|
88
|
-
*
|
89
|
-
*
|
70
|
+
* @param {Auth} auth - The Auth instance.
|
71
|
+
* @param {string} oobCode - The out-of-band code sent to the user.
|
72
|
+
* @returns {Promise<void>}
|
90
73
|
*/
|
91
74
|
export async function applyActionCode(auth, oobCode) {
|
92
|
-
|
93
|
-
return _auth.applyActionCode(oobCode);
|
75
|
+
return auth.applyActionCode(oobCode);
|
94
76
|
}
|
95
77
|
|
96
|
-
|
78
|
+
/**
|
97
79
|
* Adds a blocking callback that runs before an auth state change sets a new user.
|
80
|
+
* @param {Auth} auth - The Auth instance.
|
81
|
+
* @param {(user: User | null) => void} callback - A callback function to run before the auth state changes.
|
82
|
+
* @param {() => void} [onAbort] - Optional. A callback function to run if the operation is aborted.
|
98
83
|
*/
|
99
84
|
export function beforeAuthStateChanged(auth, callback, onAbort) {
|
100
85
|
throw new Error('beforeAuthStateChanged is unsupported by the native Firebase SDKs');
|
101
86
|
}
|
102
87
|
|
103
|
-
|
88
|
+
/**
|
104
89
|
* Checks a verification code sent to the user by email or other out-of-band mechanism.
|
90
|
+
* @param {Auth} auth - The Auth instance.
|
91
|
+
* @param {string} oobCode - The out-of-band code sent to the user.
|
92
|
+
* @returns {Promise<ActionCodeInfo>}
|
105
93
|
*/
|
106
94
|
export async function checkActionCode(auth, oobCode) {
|
107
|
-
|
108
|
-
return _auth.checkActionCode(oobCode);
|
95
|
+
return auth.checkActionCode(oobCode);
|
109
96
|
}
|
110
97
|
|
111
|
-
|
98
|
+
/**
|
112
99
|
* Completes the password reset process, given a confirmation code and new password.
|
100
|
+
* @param {Auth} auth - The Auth instance.
|
101
|
+
* @param {string} oobCode - The out-of-band code sent to the user.
|
102
|
+
* @param {string} newPassword - The new password.
|
103
|
+
* @returns {Promise<void>}
|
113
104
|
*/
|
114
105
|
export async function confirmPasswordReset(auth, oobCode, newPassword) {
|
115
|
-
|
116
|
-
return _auth.confirmPasswordReset(oobCode, newPassword);
|
106
|
+
return auth.confirmPasswordReset(oobCode, newPassword);
|
117
107
|
}
|
118
108
|
|
119
|
-
|
109
|
+
/**
|
120
110
|
* Changes the Auth instance to communicate with the Firebase Auth Emulator, instead of production Firebase Auth services.
|
121
|
-
*
|
122
|
-
*
|
111
|
+
* @param {Auth} auth - The Auth instance.
|
112
|
+
* @param {string} url - The URL of the Firebase Auth Emulator.
|
113
|
+
* @param {{ disableWarnings: boolean }} [options] - Optional. Options for the emulator connection.
|
123
114
|
*/
|
124
115
|
export function connectAuthEmulator(auth, url, options) {
|
125
|
-
|
126
|
-
_auth.useEmulator(url, options);
|
116
|
+
auth.useEmulator(url, options);
|
127
117
|
}
|
128
118
|
|
129
|
-
|
119
|
+
/**
|
130
120
|
* Creates a new user account associated with the specified email address and password.
|
121
|
+
* @param {Auth} auth - The Auth instance.
|
122
|
+
* @param {string} email - The user's email address.
|
123
|
+
* @param {string} password - The user's password.
|
124
|
+
* @returns {Promise<UserCredential>}
|
131
125
|
*/
|
132
126
|
export async function createUserWithEmailAndPassword(auth, email, password) {
|
133
|
-
|
134
|
-
return _auth.createUserWithEmailAndPassword(email, password);
|
127
|
+
return auth.createUserWithEmailAndPassword(email, password);
|
135
128
|
}
|
136
129
|
|
137
|
-
|
130
|
+
/**
|
138
131
|
* Gets the list of possible sign in methods for the given email address.
|
132
|
+
* @param {Auth} auth - The Auth instance.
|
133
|
+
* @param {string} email - The user's email address.
|
134
|
+
* @returns {Promise<string[]>}
|
139
135
|
*/
|
140
136
|
export async function fetchSignInMethodsForEmail(auth, email) {
|
141
|
-
|
142
|
-
return _auth.fetchSignInMethodsForEmail(email);
|
137
|
+
return auth.fetchSignInMethodsForEmail(email);
|
143
138
|
}
|
144
139
|
|
145
|
-
|
140
|
+
/**
|
146
141
|
* Provides a MultiFactorResolver suitable for completion of a multi-factor flow.
|
142
|
+
* @param {Auth} auth - The Auth instance.
|
143
|
+
* @param {MultiFactorError} error - The multi-factor error.
|
144
|
+
* @returns {MultiFactorResolver}
|
147
145
|
*/
|
148
146
|
export function getMultiFactorResolver(auth, error) {
|
149
|
-
|
150
|
-
return _auth.getMultiFactorResolver(error);
|
147
|
+
return auth.getMultiFactorResolver(error);
|
151
148
|
}
|
152
149
|
|
153
|
-
|
150
|
+
/**
|
154
151
|
* Returns a UserCredential from the redirect-based sign-in flow.
|
152
|
+
* @param {Auth} auth - The Auth instance.
|
153
|
+
* @param {PopupRedirectResolver} [resolver] - Optional. The popup redirect resolver.
|
154
|
+
* @returns {Promise<UserCredential | null>}
|
155
155
|
*/
|
156
156
|
export async function getRedirectResult(auth, resolver) {
|
157
157
|
throw new Error('getRedirectResult is unsupported by the native Firebase SDKs');
|
158
158
|
}
|
159
159
|
|
160
|
-
|
160
|
+
/**
|
161
161
|
* Checks if an incoming link is a sign-in with email link suitable for signInWithEmailLink().
|
162
|
+
* @param {Auth} auth - The Auth instance.
|
163
|
+
* @param {string} emailLink - The email link to check.
|
164
|
+
* @returns {boolean}
|
162
165
|
*/
|
163
166
|
export function isSignInWithEmailLink(auth, emailLink) {
|
164
|
-
|
165
|
-
return _auth.isSignInWithEmailLink(emailLink);
|
167
|
+
return auth.isSignInWithEmailLink(emailLink);
|
166
168
|
}
|
167
169
|
|
168
|
-
|
170
|
+
/**
|
169
171
|
* Adds an observer for changes to the user's sign-in state.
|
172
|
+
* @param {Auth} auth - The Auth instance.
|
173
|
+
* @param {CallbackOrObserver<AuthListenerCallback>} nextOrObserver - A callback function or observer for auth state changes.
|
174
|
+
* @returns {() => void}
|
170
175
|
*/
|
171
176
|
export function onAuthStateChanged(auth, nextOrObserver) {
|
172
|
-
|
173
|
-
return _auth.onAuthStateChanged(nextOrObserver);
|
177
|
+
return auth.onAuthStateChanged(nextOrObserver);
|
174
178
|
}
|
175
179
|
|
176
|
-
|
180
|
+
/**
|
177
181
|
* Adds an observer for changes to the signed-in user's ID token.
|
182
|
+
* @param {Auth} auth - The Auth instance.
|
183
|
+
* @param {CallbackOrObserver<AuthListenerCallback>} nextOrObserver - A callback function or observer for ID token changes.
|
184
|
+
* @returns {() => void}
|
178
185
|
*/
|
179
186
|
export function onIdTokenChanged(auth, nextOrObserver) {
|
180
|
-
|
181
|
-
return _auth.onIdTokenChanged(nextOrObserver);
|
187
|
+
return auth.onIdTokenChanged(nextOrObserver);
|
182
188
|
}
|
183
189
|
|
184
|
-
|
190
|
+
/**
|
185
191
|
* Sends a password reset email to the given email address.
|
192
|
+
* @param {Auth} auth - The Auth instance.
|
193
|
+
* @param {string} email - The user's email address.
|
194
|
+
* @param {ActionCodeSettings} [actionCodeSettings] - Optional. Action code settings.
|
195
|
+
* @returns {Promise<void>}
|
186
196
|
*/
|
187
197
|
export async function sendPasswordResetEmail(auth, email, actionCodeSettings) {
|
188
|
-
|
189
|
-
return _auth.sendPasswordResetEmail(email, actionCodeSettings);
|
198
|
+
return auth.sendPasswordResetEmail(email, actionCodeSettings);
|
190
199
|
}
|
191
200
|
|
192
|
-
|
201
|
+
/**
|
193
202
|
* Sends a sign-in email link to the user with the specified email.
|
203
|
+
* @param {Auth} auth - The Auth instance.
|
204
|
+
* @param {string} email - The user's email address.
|
205
|
+
* @param {ActionCodeSettings} [actionCodeSettings] - Optional. Action code settings.
|
206
|
+
* @returns {Promise<void>}
|
194
207
|
*/
|
195
208
|
export async function sendSignInLinkToEmail(auth, email, actionCodeSettings) {
|
196
|
-
|
197
|
-
return _auth.sendSignInLinkToEmail(email, actionCodeSettings);
|
209
|
+
return auth.sendSignInLinkToEmail(email, actionCodeSettings);
|
198
210
|
}
|
199
211
|
|
200
|
-
|
212
|
+
/**
|
201
213
|
* Changes the type of persistence on the Auth instance for the currently saved Auth session and applies this type of persistence for future sign-in requests, including sign-in with redirect requests.
|
214
|
+
* @param {Auth} auth - The Auth instance.
|
215
|
+
* @param {Persistence} persistence - The persistence type.
|
216
|
+
* @returns {Promise<void>}
|
202
217
|
*/
|
203
218
|
export async function setPersistence(auth, persistence) {
|
204
219
|
throw new Error('setPersistence is unsupported by the native Firebase SDKs');
|
205
220
|
}
|
206
221
|
|
207
|
-
|
222
|
+
/**
|
208
223
|
* Asynchronously signs in as an anonymous user.
|
224
|
+
* @param {Auth} auth - The Auth instance.
|
225
|
+
* @returns {Promise<UserCredential>}
|
209
226
|
*/
|
210
227
|
export async function signInAnonymously(auth) {
|
211
|
-
|
212
|
-
return _auth.signInAnonymously();
|
228
|
+
return auth.signInAnonymously();
|
213
229
|
}
|
214
230
|
|
215
|
-
|
231
|
+
/**
|
216
232
|
* Asynchronously signs in with the given credentials.
|
233
|
+
* @param {Auth} auth - The Auth instance.
|
234
|
+
* @param {AuthCredential} credential - The auth credentials.
|
235
|
+
* @returns {Promise<UserCredential>}
|
217
236
|
*/
|
218
237
|
export async function signInWithCredential(auth, credential) {
|
219
|
-
|
220
|
-
return _auth.signInWithCredential(credential);
|
238
|
+
return auth.signInWithCredential(credential);
|
221
239
|
}
|
222
240
|
|
223
|
-
|
241
|
+
/**
|
224
242
|
* Asynchronously signs in using a custom token.
|
243
|
+
* @param {Auth} auth - The Auth instance.
|
244
|
+
* @param {string} customToken - The custom token.
|
245
|
+
* @returns {Promise<UserCredential>}
|
225
246
|
*/
|
226
247
|
export async function signInWithCustomToken(auth, customToken) {
|
227
|
-
|
228
|
-
return _auth.signInWithCustomToken(customToken);
|
248
|
+
return auth.signInWithCustomToken(customToken);
|
229
249
|
}
|
230
250
|
|
231
|
-
|
251
|
+
/**
|
232
252
|
* Asynchronously signs in using an email and password.
|
253
|
+
* @param {Auth} auth - The Auth instance.
|
254
|
+
* @param {string} email - The user's email address.
|
255
|
+
* @param {string} password - The user's password.
|
256
|
+
* @returns {Promise<UserCredential>}
|
233
257
|
*/
|
234
258
|
export async function signInWithEmailAndPassword(auth, email, password) {
|
235
|
-
|
236
|
-
return _auth.signInWithEmailAndPassword(email, password);
|
259
|
+
return auth.signInWithEmailAndPassword(email, password);
|
237
260
|
}
|
238
261
|
|
239
|
-
|
262
|
+
/**
|
240
263
|
* Asynchronously signs in using an email and sign-in email link.
|
264
|
+
* @param {Auth} auth - The Auth instance.
|
265
|
+
* @param {string} email - The user's email address.
|
266
|
+
* @param {string} emailLink - The email link.
|
267
|
+
* @returns {Promise<UserCredential>}
|
241
268
|
*/
|
242
269
|
export async function signInWithEmailLink(auth, email, emailLink) {
|
243
|
-
|
244
|
-
return _auth.signInWithEmailLink(email, emailLink);
|
270
|
+
return auth.signInWithEmailLink(email, emailLink);
|
245
271
|
}
|
246
272
|
|
247
|
-
|
273
|
+
/**
|
248
274
|
* Asynchronously signs in using a phone number.
|
275
|
+
* @param {Auth} auth - The Auth instance.
|
276
|
+
* @param {string} phoneNumber - The user's phone number.
|
277
|
+
* @param {ApplicationVerifier} appVerifier - The application verifier.
|
278
|
+
* @returns {Promise<ConfirmationResult>}
|
249
279
|
*/
|
250
280
|
export async function signInWithPhoneNumber(auth, phoneNumber, appVerifier) {
|
251
|
-
|
252
|
-
return _auth.signInWithPhoneNumber(phoneNumber);
|
281
|
+
return auth.signInWithPhoneNumber(phoneNumber, appVerifier);
|
253
282
|
}
|
254
283
|
|
255
|
-
|
256
|
-
* Asynchronously
|
284
|
+
/**
|
285
|
+
* Asynchronously verifies a phone number.
|
286
|
+
* @param {Auth} auth - The Auth instance.
|
287
|
+
* @param {string} phoneNumber - The user's phone number.
|
288
|
+
* @param {number | boolean} autoVerifyTimeoutOrForceResend - The auto verify timeout or force resend flag.
|
289
|
+
* @param {boolean} [forceResend] - Optional. Whether to force resend.
|
290
|
+
* @returns {PhoneAuthListener}
|
257
291
|
*/
|
258
292
|
export function verifyPhoneNumber(auth, phoneNumber, autoVerifyTimeoutOrForceResend, forceResend) {
|
259
|
-
|
260
|
-
return _auth.verifyPhoneNumber(phoneNumber, autoVerifyTimeoutOrForceResend, forceResend);
|
293
|
+
return auth.verifyPhoneNumber(phoneNumber, autoVerifyTimeoutOrForceResend, forceResend);
|
261
294
|
}
|
262
295
|
|
263
|
-
|
264
|
-
Authenticates a Firebase client using a popup-based OAuth authentication flow.
|
265
|
-
|
296
|
+
/**
|
297
|
+
* Authenticates a Firebase client using a popup-based OAuth authentication flow.
|
298
|
+
* @param {Auth} auth - The Auth instance.
|
299
|
+
* @param {AuthProvider} provider - The auth provider.
|
300
|
+
* @param {PopupRedirectResolver} [resolver] - Optional. The popup redirect resolver.
|
301
|
+
* @returns {Promise<UserCredential>}
|
302
|
+
*/
|
266
303
|
export async function signInWithPopup(auth, provider, resolver) {
|
267
|
-
|
268
|
-
return _auth.signInWithPopup(provider, resolver);
|
304
|
+
return auth.signInWithPopup(provider, resolver);
|
269
305
|
}
|
270
306
|
|
271
|
-
|
272
|
-
Authenticates a Firebase client using a full-page redirect flow.
|
273
|
-
|
307
|
+
/**
|
308
|
+
* Authenticates a Firebase client using a full-page redirect flow.
|
309
|
+
* @param {Auth} auth - The Auth instance.
|
310
|
+
* @param {AuthProvider} provider - The auth provider.
|
311
|
+
* @param {PopupRedirectResolver} [resolver] - Optional. The popup redirect resolver.
|
312
|
+
* @returns {Promise<void>}
|
313
|
+
*/
|
274
314
|
export async function signInWithRedirect(auth, provider, resolver) {
|
275
|
-
|
276
|
-
return _auth.signInWithRedirect(provider, resolver);
|
315
|
+
return auth.signInWithRedirect(provider, resolver);
|
277
316
|
}
|
278
317
|
|
279
|
-
|
280
|
-
Signs out the current user.
|
281
|
-
|
318
|
+
/**
|
319
|
+
* Signs out the current user.
|
320
|
+
* @param {Auth} auth - The Auth instance.
|
321
|
+
* @returns {Promise<void>}
|
322
|
+
*/
|
282
323
|
export async function signOut(auth) {
|
283
|
-
|
284
|
-
return _auth.signOut();
|
324
|
+
return auth.signOut();
|
285
325
|
}
|
286
326
|
|
287
|
-
|
288
|
-
Asynchronously sets the provided user as Auth.currentUser on the Auth instance.
|
289
|
-
|
327
|
+
/**
|
328
|
+
* Asynchronously sets the provided user as Auth.currentUser on the Auth instance.
|
329
|
+
* @param {Auth} auth - The Auth instance.
|
330
|
+
* @param {User} user - The user to set as the current user.
|
331
|
+
* @returns {Promise<void>}
|
332
|
+
*/
|
290
333
|
export async function updateCurrentUser(auth, user) {
|
291
334
|
throw new Error('updateCurrentUser is unsupported by the native Firebase SDKs');
|
292
335
|
}
|
293
336
|
|
294
|
-
|
295
|
-
Sets the current language to the default device/browser preference.
|
296
|
-
|
337
|
+
/**
|
338
|
+
* Sets the current language to the default device/browser preference.
|
339
|
+
* @param {Auth} auth - The Auth instance.
|
340
|
+
*/
|
297
341
|
export function useDeviceLanguage(auth) {
|
298
342
|
throw new Error('useDeviceLanguage is unsupported by the native Firebase SDKs');
|
299
343
|
}
|
300
344
|
|
301
|
-
|
302
|
-
Sets the current language to the default device/browser preference.
|
303
|
-
|
345
|
+
/**
|
346
|
+
* Sets the current language to the default device/browser preference.
|
347
|
+
* @param {Auth} auth - The Auth instance.
|
348
|
+
* @param {string} userAccessGroup - The user access group.
|
349
|
+
* @returns {Promise<void>}
|
350
|
+
*/
|
304
351
|
export function useUserAccessGroup(auth, userAccessGroup) {
|
305
|
-
|
306
|
-
return _auth.useUserAccessGroup(userAccessGroup);
|
352
|
+
return auth.useUserAccessGroup(userAccessGroup);
|
307
353
|
}
|
308
354
|
|
309
|
-
|
310
|
-
Verifies the password reset code sent to the user by email or other out-of-band mechanism.
|
311
|
-
|
355
|
+
/**
|
356
|
+
* Verifies the password reset code sent to the user by email or other out-of-band mechanism.
|
357
|
+
* @param {Auth} auth - The Auth instance.
|
358
|
+
* @param {string} code - The password reset code.
|
359
|
+
* @returns {Promise<string>}
|
360
|
+
*/
|
312
361
|
export async function verifyPasswordResetCode(auth, code) {
|
313
|
-
|
314
|
-
return _auth.verifyPasswordResetCode(code);
|
362
|
+
return auth.verifyPasswordResetCode(code);
|
315
363
|
}
|
316
364
|
|
317
|
-
|
365
|
+
/**
|
318
366
|
* Parses the email action link string and returns an ActionCodeURL if the link is valid, otherwise returns null.
|
367
|
+
* @param {string} link - The email action link string.
|
368
|
+
* @returns {ActionCodeURL | null}
|
319
369
|
*/
|
320
370
|
export function parseActionCodeURL(link) {
|
321
371
|
throw new Error('parseActionCodeURL is unsupported by the native Firebase SDKs');
|
322
372
|
}
|
323
373
|
|
324
|
-
|
374
|
+
/**
|
325
375
|
* Deletes and signs out the user.
|
376
|
+
* @param {User} user - The user to delete.
|
377
|
+
* @returns {Promise<void>}
|
326
378
|
*/
|
327
379
|
export async function deleteUser(user) {
|
328
380
|
return user.delete();
|
329
381
|
}
|
330
382
|
|
331
|
-
|
383
|
+
/**
|
332
384
|
* Returns a JSON Web Token (JWT) used to identify the user to a Firebase service.
|
385
|
+
* @param {User} user - The user to get the token for.
|
386
|
+
* @param {boolean} [forceRefresh] - Optional. Whether to force refresh the token.
|
387
|
+
* @returns {Promise<string>}
|
333
388
|
*/
|
334
389
|
export async function getIdToken(user, forceRefresh) {
|
335
390
|
return user.getIdToken(forceRefresh);
|
336
391
|
}
|
337
392
|
|
338
|
-
|
393
|
+
/**
|
339
394
|
* Returns a deserialized JSON Web Token (JWT) used to identify the user to a Firebase service.
|
395
|
+
* @param {User} user - The user to get the token result for.
|
396
|
+
* @param {boolean} [forceRefresh] - Optional. Whether to force refresh the token.
|
397
|
+
* @returns {Promise<IdTokenResult>}
|
340
398
|
*/
|
341
399
|
export async function getIdTokenResult(user, forceRefresh) {
|
342
400
|
return user.getIdTokenResult(forceRefresh);
|
343
401
|
}
|
344
402
|
|
345
|
-
|
403
|
+
/**
|
346
404
|
* Links the user account with the given credentials.
|
405
|
+
* @param {User} user - The user to link the credentials with.
|
406
|
+
* @param {AuthCredential} credential - The auth credentials.
|
407
|
+
* @returns {Promise<UserCredential>}
|
347
408
|
*/
|
348
409
|
export async function linkWithCredential(user, credential) {
|
349
410
|
return user.linkWithCredential(credential);
|
350
411
|
}
|
351
412
|
|
352
|
-
|
413
|
+
/**
|
353
414
|
* Links the user account with the given phone number.
|
415
|
+
* @param {User} user - The user to link the phone number with.
|
416
|
+
* @param {string} phoneNumber - The phone number.
|
417
|
+
* @param {ApplicationVerifier} appVerifier - The application verifier.
|
418
|
+
* @returns {Promise<ConfirmationResult>}
|
354
419
|
*/
|
355
420
|
export async function linkWithPhoneNumber(user, phoneNumber, appVerifier) {
|
356
421
|
throw new Error('linkWithPhoneNumber is unsupported by the native Firebase SDKs');
|
357
422
|
}
|
358
423
|
|
359
|
-
|
424
|
+
/**
|
360
425
|
* Links the authenticated provider to the user account using a pop-up based OAuth flow.
|
426
|
+
* @param {User} user - The user to link the provider with.
|
427
|
+
* @param {AuthProvider} provider - The auth provider.
|
428
|
+
* @param {PopupRedirectResolver} [resolver] - Optional. The popup redirect resolver.
|
429
|
+
* @returns {Promise<UserCredential>}
|
361
430
|
*/
|
362
431
|
export async function linkWithPopup(user, provider, resolver) {
|
363
432
|
return user.linkWithPopup(provider, resolver);
|
364
433
|
}
|
365
434
|
|
366
|
-
|
435
|
+
/**
|
367
436
|
* Links the OAuthProvider to the user account using a full-page redirect flow.
|
437
|
+
* @param {User} user - The user to link the provider with.
|
438
|
+
* @param {AuthProvider} provider - The auth provider.
|
439
|
+
* @param {PopupRedirectResolver} [resolver] - Optional. The popup redirect resolver.
|
440
|
+
* @returns {Promise<void>}
|
368
441
|
*/
|
369
442
|
export async function linkWithRedirect(user, provider, resolver) {
|
370
443
|
return user.linkWithRedirect(provider, resolver);
|
371
444
|
}
|
372
445
|
|
373
|
-
|
446
|
+
/**
|
374
447
|
* The MultiFactorUser corresponding to the user.
|
448
|
+
* @param {User} user - The user to get the multi-factor user for.
|
449
|
+
* @returns {MultiFactorUser}
|
375
450
|
*/
|
376
451
|
export function multiFactor(user) {
|
377
452
|
return user._auth.multiFactor(user);
|
378
453
|
}
|
379
454
|
|
380
|
-
|
455
|
+
/**
|
381
456
|
* Re-authenticates a user using a fresh credential.
|
457
|
+
* @param {User} user - The user to re-authenticate.
|
458
|
+
* @param {AuthCredential} credential - The auth credentials.
|
459
|
+
* @returns {Promise<UserCredential>}
|
382
460
|
*/
|
383
461
|
export async function reauthenticateWithCredential(user, credential) {
|
384
462
|
return user.reauthenticateWithCredential(credential);
|
385
463
|
}
|
386
464
|
|
387
|
-
|
465
|
+
/**
|
388
466
|
* Re-authenticates a user using a fresh phone credential.
|
467
|
+
* @param {User} user - The user to re-authenticate.
|
468
|
+
* @param {string} phoneNumber - The phone number.
|
469
|
+
* @param {ApplicationVerifier} appVerifier - The application verifier.
|
470
|
+
* @returns {Promise<ConfirmationResult>}
|
389
471
|
*/
|
390
472
|
export async function reauthenticateWithPhoneNumber(user, phoneNumber, appVerifier) {
|
391
473
|
throw new Error('reauthenticateWithPhoneNumber is unsupported by the native Firebase SDKs');
|
392
474
|
}
|
393
475
|
|
394
|
-
|
476
|
+
/**
|
395
477
|
* Reauthenticates the current user with the specified OAuthProvider using a pop-up based OAuth flow.
|
478
|
+
* @param {User} user - The user to re-authenticate.
|
479
|
+
* @param {AuthProvider} provider - The auth provider.
|
480
|
+
* @param {PopupRedirectResolver} [resolver] - Optional. The popup redirect resolver.
|
481
|
+
* @returns {Promise<UserCredential>}
|
396
482
|
*/
|
397
483
|
export async function reauthenticateWithPopup(user, provider, resolver) {
|
398
484
|
return user.reauthenticateWithPopup(provider, resolver);
|
399
485
|
}
|
400
486
|
|
401
|
-
|
487
|
+
/**
|
402
488
|
* Reauthenticates the current user with the specified OAuthProvider using a full-page redirect flow.
|
489
|
+
* @param {User} user - The user to re-authenticate.
|
490
|
+
* @param {AuthProvider} provider - The auth provider.
|
491
|
+
* @param {PopupRedirectResolver} [resolver] - Optional. The popup redirect resolver.
|
492
|
+
* @returns {Promise<void>}
|
403
493
|
*/
|
404
494
|
export async function reauthenticateWithRedirect(user, provider, resolver) {
|
405
495
|
return user.reauthenticateWithRedirect(provider, resolver);
|
406
496
|
}
|
407
497
|
|
408
|
-
|
498
|
+
/**
|
409
499
|
* Reloads user account data, if signed in.
|
500
|
+
* @param {User} user - The user to reload data for.
|
501
|
+
* @returns {Promise<void>}
|
410
502
|
*/
|
411
503
|
export async function reload(user) {
|
412
504
|
return user.reload();
|
413
505
|
}
|
414
506
|
|
415
|
-
|
507
|
+
/**
|
416
508
|
* Sends a verification email to a user.
|
509
|
+
* @param {User} user - The user to send the email to.
|
510
|
+
* @param {ActionCodeSettings} [actionCodeSettings] - Optional. Action code settings.
|
511
|
+
* @returns {Promise<void>}
|
417
512
|
*/
|
418
513
|
export async function sendEmailVerification(user, actionCodeSettings) {
|
419
514
|
return user.sendEmailVerification(actionCodeSettings);
|
420
515
|
}
|
421
516
|
|
422
|
-
|
517
|
+
/**
|
423
518
|
* Unlinks a provider from a user account.
|
519
|
+
* @param {User} user - The user to unlink the provider from.
|
520
|
+
* @param {string} providerId - The provider ID.
|
521
|
+
* @returns {Promise<User>}
|
424
522
|
*/
|
425
523
|
export async function unlink(user, providerId) {
|
426
524
|
return user.unlink(providerId);
|
427
525
|
}
|
428
526
|
|
429
|
-
|
527
|
+
/**
|
430
528
|
* Updates the user's email address.
|
529
|
+
* @param {User} user - The user to update the email for.
|
530
|
+
* @param {string} newEmail - The new email address.
|
531
|
+
* @returns {Promise<void>}
|
431
532
|
*/
|
432
533
|
export async function updateEmail(user, newEmail) {
|
433
534
|
return user.updateEmail(newEmail);
|
434
535
|
}
|
435
536
|
|
436
|
-
|
537
|
+
/**
|
437
538
|
* Updates the user's password.
|
539
|
+
* @param {User} user - The user to update the password for.
|
540
|
+
* @param {string} newPassword - The new password.
|
541
|
+
* @returns {Promise<void>}
|
438
542
|
*/
|
439
543
|
export async function updatePassword(user, newPassword) {
|
440
544
|
return user.updatePassword(newPassword);
|
441
545
|
}
|
442
546
|
|
443
|
-
|
547
|
+
/**
|
444
548
|
* Updates the user's phone number.
|
549
|
+
* @param {User} user - The user to update the phone number for.
|
550
|
+
* @param {AuthCredential} credential - The auth credentials.
|
551
|
+
* @returns {Promise<void>}
|
445
552
|
*/
|
446
553
|
export async function updatePhoneNumber(user, credential) {
|
447
554
|
return user.updatePhoneNumber(credential);
|
448
555
|
}
|
449
556
|
|
450
|
-
|
557
|
+
/**
|
451
558
|
* Updates a user's profile data.
|
559
|
+
* @param {User} user - The user to update the profile for.
|
560
|
+
* @param {{ displayName?: string | null, photoURL?: string | null }} profile - An object containing the profile data to update.
|
561
|
+
* @returns {Promise<void>}
|
452
562
|
*/
|
453
563
|
export async function updateProfile(user, { displayName, photoURL: photoUrl }) {
|
454
564
|
return user.updateProfile({ displayName, photoURL: photoUrl });
|
455
565
|
}
|
456
566
|
|
457
|
-
|
567
|
+
/**
|
458
568
|
* Sends a verification email to a new email address.
|
569
|
+
* @param {User} user - The user to send the email to.
|
570
|
+
* @param {string} newEmail - The new email address.
|
571
|
+
* @param {ActionCodeSettings} [actionCodeSettings] - Optional. Action code settings.
|
572
|
+
* @returns {Promise<void>}
|
459
573
|
*/
|
460
574
|
export async function verifyBeforeUpdateEmail(user, newEmail, actionCodeSettings) {
|
461
575
|
return user.verifyBeforeUpdateEmail(newEmail, actionCodeSettings);
|
462
576
|
}
|
463
577
|
|
464
|
-
|
578
|
+
/**
|
465
579
|
* Extracts provider specific AdditionalUserInfo for the given credential.
|
580
|
+
* @param {UserCredential} userCredential - The user credential.
|
581
|
+
* @returns {AdditionalUserInfo | null}
|
466
582
|
*/
|
467
583
|
export function getAdditionalUserInfo(userCredential) {
|
468
584
|
return userCredential.additionalUserInfo;
|
469
585
|
}
|
470
586
|
|
587
|
+
/**
|
588
|
+
* Returns the custom auth domain for the auth instance.
|
589
|
+
* @param {Auth} auth - The Auth instance.
|
590
|
+
* @returns {Promise<string>}
|
591
|
+
*/
|
471
592
|
export function getCustomAuthDomain(auth) {
|
472
|
-
|
473
|
-
return _auth.getCustomAuthDomain();
|
593
|
+
return auth.getCustomAuthDomain();
|
474
594
|
}
|