@react-native-firebase/auth 20.1.0 → 20.2.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 +6 -0
- package/android/src/main/java/io/invertase/firebase/auth/ReactNativeFirebaseAuthModule.java +2 -1
- package/lib/index.js +5 -1
- package/lib/version.js +1 -1
- package/lib/web/RNFBAuthModule.android.js +2 -0
- package/lib/web/RNFBAuthModule.ios.js +2 -0
- package/lib/web/RNFBAuthModule.js +1027 -0
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
@@ -3,6 +3,12 @@
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
5
5
|
|
6
|
+
## [20.2.0](https://github.com/invertase/react-native-firebase/compare/v20.1.0...v20.2.0) (2024-07-15)
|
7
|
+
|
8
|
+
### Features
|
9
|
+
|
10
|
+
- **other:** Add Auth support ([#7878](https://github.com/invertase/react-native-firebase/issues/7878)) ([54befe7](https://github.com/invertase/react-native-firebase/commit/54befe776353f07eeab9b044d6261eeb76f1f238))
|
11
|
+
|
6
12
|
## [20.1.0](https://github.com/invertase/react-native-firebase/compare/v20.0.0...v20.1.0) (2024-06-04)
|
7
13
|
|
8
14
|
**Note:** Version bump only for package @react-native-firebase/auth
|
@@ -1188,7 +1188,8 @@ class ReactNativeFirebaseAuthModule extends ReactNativeFirebaseModule {
|
|
1188
1188
|
final Promise promise) {
|
1189
1189
|
final MultiFactorSession multiFactorSession = mMultiFactorSessions.get(sessionKey);
|
1190
1190
|
if (multiFactorSession == null) {
|
1191
|
-
rejectPromiseWithCodeAndMessage(
|
1191
|
+
rejectPromiseWithCodeAndMessage(
|
1192
|
+
promise, "invalid-multi-factor-session", "can't find session for provided key");
|
1192
1193
|
return;
|
1193
1194
|
}
|
1194
1195
|
FirebaseApp firebaseApp = FirebaseApp.getInstance(appName);
|
package/lib/index.js
CHANGED
@@ -22,6 +22,7 @@ import {
|
|
22
22
|
isString,
|
23
23
|
isValidUrl,
|
24
24
|
} from '@react-native-firebase/app/lib/common';
|
25
|
+
import { setReactNativeModule } from '@react-native-firebase/app/lib/internal/nativeModule';
|
25
26
|
import {
|
26
27
|
FirebaseModule,
|
27
28
|
createModuleNamespace,
|
@@ -44,6 +45,7 @@ import OIDCAuthProvider from './providers/OIDCAuthProvider';
|
|
44
45
|
import PhoneAuthProvider from './providers/PhoneAuthProvider';
|
45
46
|
import TwitterAuthProvider from './providers/TwitterAuthProvider';
|
46
47
|
import version from './version';
|
48
|
+
import fallBackModule from './web/RNFBAuthModule';
|
47
49
|
|
48
50
|
export {
|
49
51
|
applyActionCode,
|
@@ -137,7 +139,6 @@ const statics = {
|
|
137
139
|
};
|
138
140
|
|
139
141
|
const namespace = 'auth';
|
140
|
-
|
141
142
|
const nativeModuleName = 'RNFBAuthModule';
|
142
143
|
|
143
144
|
class FirebaseAuthModule extends FirebaseModule {
|
@@ -533,3 +534,6 @@ export default createModuleNamespace({
|
|
533
534
|
// auth().X(...);
|
534
535
|
// firebase.auth().X(...);
|
535
536
|
export const firebase = getFirebaseRoot();
|
537
|
+
|
538
|
+
// Register the interop module for non-native platforms.
|
539
|
+
setReactNativeModule(nativeModuleName, fallBackModule);
|
package/lib/version.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
// Generated by genversion.
|
2
|
-
module.exports = '20.
|
2
|
+
module.exports = '20.2.0';
|
@@ -0,0 +1,1027 @@
|
|
1
|
+
import {
|
2
|
+
getApps,
|
3
|
+
getApp,
|
4
|
+
getAuth,
|
5
|
+
onAuthStateChanged,
|
6
|
+
onIdTokenChanged,
|
7
|
+
signInAnonymously,
|
8
|
+
sendSignInLinkToEmail,
|
9
|
+
getAdditionalUserInfo,
|
10
|
+
multiFactor,
|
11
|
+
createUserWithEmailAndPassword,
|
12
|
+
signInWithEmailAndPassword,
|
13
|
+
signInWithEmailLink,
|
14
|
+
signInWithCustomToken,
|
15
|
+
sendPasswordResetEmail,
|
16
|
+
useDeviceLanguage,
|
17
|
+
verifyPasswordResetCode,
|
18
|
+
connectAuthEmulator,
|
19
|
+
fetchSignInMethodsForEmail,
|
20
|
+
sendEmailVerification,
|
21
|
+
verifyBeforeUpdateEmail,
|
22
|
+
confirmPasswordReset,
|
23
|
+
updateEmail,
|
24
|
+
updatePassword,
|
25
|
+
updateProfile,
|
26
|
+
updatePhoneNumber,
|
27
|
+
signInWithCredential,
|
28
|
+
unlink,
|
29
|
+
linkWithCredential,
|
30
|
+
reauthenticateWithCredential,
|
31
|
+
getIdToken,
|
32
|
+
getIdTokenResult,
|
33
|
+
applyActionCode,
|
34
|
+
checkActionCode,
|
35
|
+
EmailAuthProvider,
|
36
|
+
FacebookAuthProvider,
|
37
|
+
GoogleAuthProvider,
|
38
|
+
TwitterAuthProvider,
|
39
|
+
GithubAuthProvider,
|
40
|
+
PhoneAuthProvider,
|
41
|
+
OAuthProvider,
|
42
|
+
} from '@react-native-firebase/app/lib/internal/web/firebaseAuth';
|
43
|
+
import { guard, getWebError, emitEvent } from '@react-native-firebase/app/lib/internal/web/utils';
|
44
|
+
|
45
|
+
/**
|
46
|
+
* Resolves or rejects an auth method promise without a user (user was missing).
|
47
|
+
* @param {boolean} isError whether to reject the promise.
|
48
|
+
* @returns {Promise<void>} - Void promise.
|
49
|
+
*/
|
50
|
+
function promiseNoUser(isError = false) {
|
51
|
+
if (isError) {
|
52
|
+
return rejectPromiseWithCodeAndMessage('no-current-user', 'No user currently signed in.');
|
53
|
+
}
|
54
|
+
|
55
|
+
// TODO(ehesp): Should this be null, or undefined?
|
56
|
+
return Promise.resolve(null);
|
57
|
+
}
|
58
|
+
|
59
|
+
/**
|
60
|
+
* Returns a structured error object.
|
61
|
+
* @param {string} code - The error code.
|
62
|
+
* @param {string} message - The error message.
|
63
|
+
*/
|
64
|
+
function rejectPromiseWithCodeAndMessage(code, message) {
|
65
|
+
return rejectPromise(getWebError({ code: `auth/${code}`, message }));
|
66
|
+
}
|
67
|
+
|
68
|
+
/**
|
69
|
+
* Returns a structured error object.
|
70
|
+
* @param {error} error The error object.
|
71
|
+
* @returns {never}
|
72
|
+
*/
|
73
|
+
function rejectPromise(error) {
|
74
|
+
const { code, message, details } = error;
|
75
|
+
const nativeError = {
|
76
|
+
code,
|
77
|
+
message,
|
78
|
+
userInfo: {
|
79
|
+
code: code ? code.replace('auth/', '') : 'unknown',
|
80
|
+
message,
|
81
|
+
details,
|
82
|
+
},
|
83
|
+
};
|
84
|
+
return Promise.reject(nativeError);
|
85
|
+
}
|
86
|
+
|
87
|
+
/**
|
88
|
+
* Converts a user object to a plain object.
|
89
|
+
* @param {User} user - The User object to convert.
|
90
|
+
* @returns {object}
|
91
|
+
*/
|
92
|
+
function userToObject(user) {
|
93
|
+
return {
|
94
|
+
...userInfoToObject(user),
|
95
|
+
emailVerified: user.emailVerified,
|
96
|
+
isAnonymous: user.isAnonymous,
|
97
|
+
tenantId: user.tenantId !== null && user.tenantId !== '' ? user.tenantId : null,
|
98
|
+
providerData: user.providerData.map(userInfoToObject),
|
99
|
+
metadata: userMetadataToObject(user.metadata),
|
100
|
+
multiFactor: multiFactor(user).enrolledFactors.map(multiFactorInfoToObject),
|
101
|
+
};
|
102
|
+
}
|
103
|
+
|
104
|
+
/**
|
105
|
+
* Returns an AuthCredential object for the given provider.
|
106
|
+
* @param {Auth} auth - The Auth instance to use.
|
107
|
+
* @param {string} provider - The provider to get the credential for.
|
108
|
+
* @param {string} token - The token to use for the credential.
|
109
|
+
* @param {string|null} secret - The secret to use for the credential.
|
110
|
+
* @returns {AuthCredential|null} - The AuthCredential object.
|
111
|
+
*/
|
112
|
+
function getAuthCredential(auth, provider, token, secret) {
|
113
|
+
if (provider.startsWith('oidc.')) {
|
114
|
+
return new OAuthProvider(provider).credential({
|
115
|
+
idToken: token,
|
116
|
+
});
|
117
|
+
}
|
118
|
+
|
119
|
+
switch (provider) {
|
120
|
+
case 'facebook.com':
|
121
|
+
return FacebookAuthProvider().credential(token);
|
122
|
+
case 'google.com':
|
123
|
+
return GoogleAuthProvider().credential(token, secret);
|
124
|
+
case 'twitter.com':
|
125
|
+
return TwitterAuthProvider().credential(token, secret);
|
126
|
+
case 'github.com':
|
127
|
+
return GithubAuthProvider().credential(token);
|
128
|
+
case 'apple.com':
|
129
|
+
return new OAuthProvider(provider).credential({
|
130
|
+
idToken: token,
|
131
|
+
rawNonce: secret,
|
132
|
+
});
|
133
|
+
case 'oauth':
|
134
|
+
return OAuthProvider(provider).credential({
|
135
|
+
idToken: token,
|
136
|
+
accessToken: secret,
|
137
|
+
});
|
138
|
+
case 'phone':
|
139
|
+
return PhoneAuthProvider.credential(token, secret);
|
140
|
+
case 'password':
|
141
|
+
return EmailAuthProvider.credential(token, secret);
|
142
|
+
case 'emailLink':
|
143
|
+
return EmailAuthProvider.credentialWithLink(token, secret);
|
144
|
+
default:
|
145
|
+
return null;
|
146
|
+
}
|
147
|
+
}
|
148
|
+
|
149
|
+
/**
|
150
|
+
* Converts a user info object to a plain object.
|
151
|
+
* @param {UserInfo} userInfo - The UserInfo object to convert.
|
152
|
+
*/
|
153
|
+
function userInfoToObject(userInfo) {
|
154
|
+
return {
|
155
|
+
providerId: userInfo.providerId,
|
156
|
+
uid: userInfo.uid,
|
157
|
+
displayName:
|
158
|
+
userInfo.displayName !== null && userInfo.displayName !== '' ? userInfo.displayName : null,
|
159
|
+
email: userInfo.email !== null && userInfo.email !== '' ? userInfo.email : null,
|
160
|
+
photoURL: userInfo.photoURL !== null && userInfo.photoURL !== '' ? userInfo.photoURL : null,
|
161
|
+
phoneNumber:
|
162
|
+
userInfo.phoneNumber !== null && userInfo.phoneNumber !== '' ? userInfo.phoneNumber : null,
|
163
|
+
};
|
164
|
+
}
|
165
|
+
|
166
|
+
/**
|
167
|
+
* Converts a user metadata object to a plain object.
|
168
|
+
* @param {UserMetadata} metadata - The UserMetadata object to convert.
|
169
|
+
*/
|
170
|
+
function userMetadataToObject(metadata) {
|
171
|
+
return {
|
172
|
+
creationTime: metadata.creationTime ? new Date(metadata.creationTime).toISOString() : null,
|
173
|
+
lastSignInTime: metadata.lastSignInTime
|
174
|
+
? new Date(metadata.lastSignInTime).toISOString()
|
175
|
+
: null,
|
176
|
+
};
|
177
|
+
}
|
178
|
+
|
179
|
+
/**
|
180
|
+
* Converts a MultiFactorInfo object to a plain object.
|
181
|
+
* @param {MultiFactorInfo} multiFactorInfo - The MultiFactorInfo object to convert.
|
182
|
+
*/
|
183
|
+
function multiFactorInfoToObject(multiFactorInfo) {
|
184
|
+
const obj = {
|
185
|
+
displayName: multiFactorInfo.displayName,
|
186
|
+
enrollmentTime: multiFactorInfo.enrollmentTime,
|
187
|
+
factorId: multiFactorInfo.factorId,
|
188
|
+
uid: multiFactorInfo.uid,
|
189
|
+
};
|
190
|
+
|
191
|
+
// If https://firebase.google.com/docs/reference/js/auth.phonemultifactorinfo
|
192
|
+
if ('phoneNumber' in multiFactorInfo) {
|
193
|
+
obj.phoneNumber = multiFactorInfo.phoneNumber;
|
194
|
+
}
|
195
|
+
|
196
|
+
return obj;
|
197
|
+
}
|
198
|
+
|
199
|
+
/**
|
200
|
+
* Converts a user credential object to a plain object.
|
201
|
+
* @param {UserCredential} userCredential - The user credential object to convert.
|
202
|
+
*/
|
203
|
+
function authResultToObject(userCredential) {
|
204
|
+
const additional = getAdditionalUserInfo(userCredential);
|
205
|
+
return {
|
206
|
+
user: userToObject(userCredential.user),
|
207
|
+
additionalUserInfo: {
|
208
|
+
isNewUser: additional.isNewUser,
|
209
|
+
profile: additional.profile,
|
210
|
+
providerId: additional.providerId,
|
211
|
+
username: additional.username,
|
212
|
+
},
|
213
|
+
};
|
214
|
+
}
|
215
|
+
|
216
|
+
const instances = {};
|
217
|
+
const authStateListeners = {};
|
218
|
+
const idTokenListeners = {};
|
219
|
+
const sessionMap = new Map();
|
220
|
+
let sessionId = 0;
|
221
|
+
|
222
|
+
// Returns a cached Firestore instance.
|
223
|
+
function getCachedAuthInstance(appName) {
|
224
|
+
return (instances[appName] ??= getAuth(getApp(appName)));
|
225
|
+
}
|
226
|
+
|
227
|
+
// getConstants
|
228
|
+
const CONSTANTS = {
|
229
|
+
APP_LANGUAGE: {},
|
230
|
+
APP_USER: {},
|
231
|
+
};
|
232
|
+
|
233
|
+
for (const appName of getApps()) {
|
234
|
+
const instance = getAuth(getApp(appName));
|
235
|
+
CONSTANTS.APP_LANGUAGE[appName] = instance.languageCode;
|
236
|
+
if (instance.currentUser) {
|
237
|
+
CONSTANTS.APP_USER[appName] = userToObject(instance.currentUser);
|
238
|
+
}
|
239
|
+
}
|
240
|
+
|
241
|
+
/**
|
242
|
+
* This is a 'NativeModule' for the web platform.
|
243
|
+
* Methods here are identical to the ones found in
|
244
|
+
* the native android/ios modules e.g. `@ReactMethod` annotated
|
245
|
+
* java methods on Android.
|
246
|
+
*/
|
247
|
+
export default {
|
248
|
+
// Expose all the constants.
|
249
|
+
...CONSTANTS,
|
250
|
+
|
251
|
+
async useUserAccessGroup() {
|
252
|
+
// noop
|
253
|
+
},
|
254
|
+
|
255
|
+
configureAuthDomain() {
|
256
|
+
return rejectPromiseWithCodeAndMessage(
|
257
|
+
'unsupported',
|
258
|
+
'This operation is not supported in this environment.',
|
259
|
+
);
|
260
|
+
},
|
261
|
+
|
262
|
+
async getCustomAuthDomain() {
|
263
|
+
return rejectPromiseWithCodeAndMessage(
|
264
|
+
'unsupported',
|
265
|
+
'This operation is not supported in this environment.',
|
266
|
+
);
|
267
|
+
},
|
268
|
+
|
269
|
+
/**
|
270
|
+
* Create a new auth state listener instance for a given app.
|
271
|
+
* @param {string} appName - The name of the app to get the auth instance for.
|
272
|
+
* @returns {Promise<void>} - Void promise.
|
273
|
+
*/
|
274
|
+
addAuthStateListener(appName) {
|
275
|
+
if (authStateListeners[appName]) {
|
276
|
+
return;
|
277
|
+
}
|
278
|
+
|
279
|
+
return guard(async () => {
|
280
|
+
const auth = getCachedAuthInstance(appName);
|
281
|
+
|
282
|
+
authStateListeners[appName] = onAuthStateChanged(auth, user => {
|
283
|
+
emitEvent('auth_state_changed', {
|
284
|
+
appName,
|
285
|
+
user: user ? userToObject(user) : null,
|
286
|
+
});
|
287
|
+
});
|
288
|
+
});
|
289
|
+
},
|
290
|
+
|
291
|
+
/**
|
292
|
+
* Remove an auth state listener instance for a given app.
|
293
|
+
* @param {string} appName - The name of the app to get the auth instance for.
|
294
|
+
* @returns {Promise<void>} - Void promise.
|
295
|
+
*/
|
296
|
+
removeAuthStateListener(appName) {
|
297
|
+
if (authStateListeners[appName]) {
|
298
|
+
authStateListeners[appName]();
|
299
|
+
delete authStateListeners[appName];
|
300
|
+
}
|
301
|
+
},
|
302
|
+
|
303
|
+
/**
|
304
|
+
* Create a new ID token listener instance for a given app.
|
305
|
+
* @param {string} appName - The name of the app to get the auth instance for.
|
306
|
+
* @returns {Promise<void>} - Void promise.
|
307
|
+
*/
|
308
|
+
addIdTokenListener(appName) {
|
309
|
+
if (idTokenListeners[appName]) {
|
310
|
+
return;
|
311
|
+
}
|
312
|
+
|
313
|
+
return guard(async () => {
|
314
|
+
const auth = getCachedAuthInstance(appName);
|
315
|
+
|
316
|
+
idTokenListeners[appName] = onIdTokenChanged(auth, user => {
|
317
|
+
emitEvent('auth_id_token_changed', {
|
318
|
+
authenticated: !!user,
|
319
|
+
appName,
|
320
|
+
user: user ? userToObject(user) : null,
|
321
|
+
});
|
322
|
+
});
|
323
|
+
});
|
324
|
+
},
|
325
|
+
|
326
|
+
/**
|
327
|
+
* Remove an ID token listener instance for a given app.
|
328
|
+
* @param {string} appName - The name of the app to get the auth instance for.
|
329
|
+
* @returns {Promise<void>} - Void promise.
|
330
|
+
*/
|
331
|
+
removeIdTokenListener(appName) {
|
332
|
+
if (idTokenListeners[appName]) {
|
333
|
+
idTokenListeners[appName]();
|
334
|
+
delete idTokenListeners[appName];
|
335
|
+
}
|
336
|
+
},
|
337
|
+
|
338
|
+
async forceRecaptchaFlowForTesting() {
|
339
|
+
return rejectPromiseWithCodeAndMessage(
|
340
|
+
'unsupported',
|
341
|
+
'This operation is not supported in this environment.',
|
342
|
+
);
|
343
|
+
},
|
344
|
+
|
345
|
+
async setAutoRetrievedSmsCodeForPhoneNumber() {
|
346
|
+
return rejectPromiseWithCodeAndMessage(
|
347
|
+
'unsupported',
|
348
|
+
'This operation is not supported in this environment.',
|
349
|
+
);
|
350
|
+
},
|
351
|
+
|
352
|
+
async setAppVerificationDisabledForTesting() {
|
353
|
+
return rejectPromiseWithCodeAndMessage(
|
354
|
+
'unsupported',
|
355
|
+
'This operation is not supported in this environment.',
|
356
|
+
);
|
357
|
+
},
|
358
|
+
|
359
|
+
/**
|
360
|
+
* Sign out the current user.
|
361
|
+
* @param {string} appName - The name of the app to get the auth instance for.
|
362
|
+
* @returns {Promise<void>} - Void promise.
|
363
|
+
*/
|
364
|
+
signOut(appName) {
|
365
|
+
return guard(async () => {
|
366
|
+
const auth = getCachedAuthInstance(appName);
|
367
|
+
|
368
|
+
if (auth.currentUser === null) {
|
369
|
+
return promiseNoUser(true);
|
370
|
+
}
|
371
|
+
|
372
|
+
await auth.signOut();
|
373
|
+
return promiseNoUser();
|
374
|
+
});
|
375
|
+
},
|
376
|
+
|
377
|
+
/**
|
378
|
+
* Sign in anonymously.
|
379
|
+
* @param {*} appName - The name of the app to get the auth instance for.
|
380
|
+
* @returns
|
381
|
+
*/
|
382
|
+
signInAnonymously(appName) {
|
383
|
+
return guard(async () => {
|
384
|
+
const auth = getCachedAuthInstance(appName);
|
385
|
+
const credential = await signInAnonymously(auth);
|
386
|
+
return authResultToObject(credential);
|
387
|
+
});
|
388
|
+
},
|
389
|
+
|
390
|
+
/**
|
391
|
+
* Sign in with email and password.
|
392
|
+
* @param {string} appName - The name of the app to get the auth instance for.
|
393
|
+
* @param {string} email - The email to sign in with.
|
394
|
+
* @param {string} password - The password to sign in with.
|
395
|
+
* @returns {Promise<object>} - The result of the sign in.
|
396
|
+
*/
|
397
|
+
async createUserWithEmailAndPassword(appName, email, password) {
|
398
|
+
return guard(async () => {
|
399
|
+
const auth = getCachedAuthInstance(appName);
|
400
|
+
const credential = await createUserWithEmailAndPassword(auth, email, password);
|
401
|
+
return authResultToObject(credential);
|
402
|
+
});
|
403
|
+
},
|
404
|
+
|
405
|
+
/**
|
406
|
+
* Sign in with email and password.
|
407
|
+
* @param {string} appName - The name of the app to get the auth instance for.
|
408
|
+
* @param {string} email - The email to sign in with.
|
409
|
+
* @param {string} password - The password to sign in with.
|
410
|
+
* @returns {Promise<object>} - The result of the sign in.
|
411
|
+
*/
|
412
|
+
async signInWithEmailAndPassword(appName, email, password) {
|
413
|
+
return guard(async () => {
|
414
|
+
const auth = getCachedAuthInstance(appName);
|
415
|
+
const credential = await signInWithEmailAndPassword(auth, email, password);
|
416
|
+
return authResultToObject(credential);
|
417
|
+
});
|
418
|
+
},
|
419
|
+
|
420
|
+
/**
|
421
|
+
* Sign in with email link.
|
422
|
+
* @param {string} appName - The name of the app to get the auth instance for.
|
423
|
+
* @param {string} email - The email to sign in with.
|
424
|
+
* @param {string} emailLink - The email link to sign in with.
|
425
|
+
* @returns {Promise<object>} - The result of the sign in.
|
426
|
+
*/
|
427
|
+
async signInWithEmailLink(appName, email, emailLink) {
|
428
|
+
return guard(async () => {
|
429
|
+
const auth = getCachedAuthInstance(appName);
|
430
|
+
const credential = await signInWithEmailLink(auth, email, emailLink);
|
431
|
+
return authResultToObject(credential);
|
432
|
+
});
|
433
|
+
},
|
434
|
+
|
435
|
+
/**
|
436
|
+
* Sign in with a custom token.
|
437
|
+
* @param {string} appName - The name of the app to get the auth instance for.
|
438
|
+
* @param {string} token - The token to sign in with.
|
439
|
+
* @returns {Promise<object>} - The result of the sign in.
|
440
|
+
*/
|
441
|
+
async signInWithCustomToken(appName, token) {
|
442
|
+
return guard(async () => {
|
443
|
+
const auth = getCachedAuthInstance(appName);
|
444
|
+
const credential = await signInWithCustomToken(auth, token);
|
445
|
+
return authResultToObject(credential);
|
446
|
+
});
|
447
|
+
},
|
448
|
+
|
449
|
+
/**
|
450
|
+
* Not implemented on web.
|
451
|
+
*/
|
452
|
+
async revokeToken() {
|
453
|
+
return promiseNoUser();
|
454
|
+
},
|
455
|
+
|
456
|
+
/**
|
457
|
+
* Send a password reset email.
|
458
|
+
* @param {string} appName - The name of the app to get the auth instance for.
|
459
|
+
* @param {string} email - The email to send the password reset email to.
|
460
|
+
* @param {ActionCodeSettings} settings - The settings to use for the password reset email.
|
461
|
+
* @returns {Promise<null>}
|
462
|
+
*/
|
463
|
+
async sendPasswordResetEmail(appName, email, settings) {
|
464
|
+
return guard(async () => {
|
465
|
+
const auth = getCachedAuthInstance(appName);
|
466
|
+
await sendPasswordResetEmail(auth, email, settings);
|
467
|
+
return promiseNoUser();
|
468
|
+
});
|
469
|
+
},
|
470
|
+
|
471
|
+
/**
|
472
|
+
* Send a sign in link to an email.
|
473
|
+
* @param {string} appName - The name of the app to get the auth instance for.
|
474
|
+
* @param {string} email - The email to send the password reset email to.
|
475
|
+
* @param {ActionCodeSettings} settings - The settings to use for the password reset email.
|
476
|
+
* @returns {Promise<null>}
|
477
|
+
*/
|
478
|
+
async sendSignInLinkToEmail(appName, email, settings) {
|
479
|
+
return guard(async () => {
|
480
|
+
const auth = getCachedAuthInstance(appName);
|
481
|
+
await sendSignInLinkToEmail(auth, email, settings);
|
482
|
+
return promiseNoUser();
|
483
|
+
});
|
484
|
+
},
|
485
|
+
|
486
|
+
/* ----------------------
|
487
|
+
* .currentUser methods
|
488
|
+
* ---------------------- */
|
489
|
+
|
490
|
+
/**
|
491
|
+
* Delete the current user.
|
492
|
+
* @param {string} appName - The name of the app to get the auth instance for.
|
493
|
+
* @returns {Promise<null>}
|
494
|
+
*/
|
495
|
+
async delete(appName) {
|
496
|
+
return guard(async () => {
|
497
|
+
const auth = getCachedAuthInstance(appName);
|
498
|
+
|
499
|
+
if (auth.currentUser === null) {
|
500
|
+
return promiseNoUser(true);
|
501
|
+
}
|
502
|
+
|
503
|
+
await auth.currentUser.delete();
|
504
|
+
return promiseNoUser();
|
505
|
+
});
|
506
|
+
},
|
507
|
+
|
508
|
+
/**
|
509
|
+
* Reload the current user.
|
510
|
+
* @param {string} appName - The name of the app to get the auth instance for.
|
511
|
+
* @returns {Promise<object>} - The current user object.
|
512
|
+
*/
|
513
|
+
async reload(appName) {
|
514
|
+
return guard(async () => {
|
515
|
+
const auth = getCachedAuthInstance(appName);
|
516
|
+
|
517
|
+
if (auth.currentUser === null) {
|
518
|
+
return promiseNoUser(true);
|
519
|
+
}
|
520
|
+
|
521
|
+
await auth.currentUser.reload();
|
522
|
+
return userToObject(auth.currentUser);
|
523
|
+
});
|
524
|
+
},
|
525
|
+
|
526
|
+
/**
|
527
|
+
* Send a verification email to the current user.
|
528
|
+
* @param {string} appName - The name of the app to get the auth instance for.
|
529
|
+
* @param {ActionCodeSettings} actionCodeSettings - The settings to use for the email verification.
|
530
|
+
* @returns {Promise<object>} - The current user object.
|
531
|
+
*/
|
532
|
+
async sendEmailVerification(appName, actionCodeSettings) {
|
533
|
+
return guard(async () => {
|
534
|
+
const auth = getCachedAuthInstance(appName);
|
535
|
+
|
536
|
+
if (auth.currentUser === null) {
|
537
|
+
return promiseNoUser(true);
|
538
|
+
}
|
539
|
+
|
540
|
+
await sendEmailVerification(auth.currentUser, actionCodeSettings);
|
541
|
+
return userToObject(auth.currentUser);
|
542
|
+
});
|
543
|
+
},
|
544
|
+
|
545
|
+
/**
|
546
|
+
* Verify the email before updating it.
|
547
|
+
* @param {string} appName - The name of the app to get the auth instance for.
|
548
|
+
* @param {string} email - The email to verify.
|
549
|
+
* @param {ActionCodeSettings} actionCodeSettings - The settings to use for the email verification.
|
550
|
+
* @returns {Promise<object>} - The current user object.
|
551
|
+
*/
|
552
|
+
async verifyBeforeUpdateEmail(appName, email, actionCodeSettings) {
|
553
|
+
return guard(async () => {
|
554
|
+
const auth = getCachedAuthInstance(appName);
|
555
|
+
|
556
|
+
if (auth.currentUser === null) {
|
557
|
+
return promiseNoUser(true);
|
558
|
+
}
|
559
|
+
|
560
|
+
await verifyBeforeUpdateEmail(auth.currentUser, email, actionCodeSettings);
|
561
|
+
return userToObject(auth.currentUser);
|
562
|
+
});
|
563
|
+
},
|
564
|
+
|
565
|
+
/**
|
566
|
+
* Update the current user's email.
|
567
|
+
* @param {string} appName - The name of the app to get the auth instance for.
|
568
|
+
* @param {string} email - The email to update.
|
569
|
+
* @returns {Promise<object>} - The current user object.
|
570
|
+
*/
|
571
|
+
async updateEmail(appName, email) {
|
572
|
+
return guard(async () => {
|
573
|
+
const auth = getCachedAuthInstance(appName);
|
574
|
+
|
575
|
+
if (auth.currentUser === null) {
|
576
|
+
return promiseNoUser(true);
|
577
|
+
}
|
578
|
+
|
579
|
+
await updateEmail(auth.currentUser, email);
|
580
|
+
return userToObject(auth.currentUser);
|
581
|
+
});
|
582
|
+
},
|
583
|
+
|
584
|
+
/**
|
585
|
+
* Update the current user's password.
|
586
|
+
* @param {string} appName - The name of the app to get the auth instance for.
|
587
|
+
* @param {string} password - The password to update.
|
588
|
+
* @returns {Promise<object>} - The current user object.
|
589
|
+
*/
|
590
|
+
async updatePassword(appName, password) {
|
591
|
+
return guard(async () => {
|
592
|
+
const auth = getCachedAuthInstance(appName);
|
593
|
+
|
594
|
+
if (auth.currentUser === null) {
|
595
|
+
return promiseNoUser(true);
|
596
|
+
}
|
597
|
+
|
598
|
+
await updatePassword(auth.currentUser, password);
|
599
|
+
return userToObject(auth.currentUser);
|
600
|
+
});
|
601
|
+
},
|
602
|
+
|
603
|
+
/**
|
604
|
+
* Update the current user's phone number.
|
605
|
+
* @param {string} appName - The name of the app to get the auth instance for.
|
606
|
+
* @param {string} provider - The provider to update the phone number with.
|
607
|
+
* @param {string} authToken - The auth token to update the phone number with.
|
608
|
+
* @param {string} authSecret - The auth secret to update the phone number with.
|
609
|
+
* @returns {Promise<object>} - The current user object.
|
610
|
+
*/
|
611
|
+
async updatePhoneNumber(appName, provider, authToken, authSecret) {
|
612
|
+
return guard(async () => {
|
613
|
+
const auth = getCachedAuthInstance(appName);
|
614
|
+
|
615
|
+
if (auth.currentUser === null) {
|
616
|
+
return promiseNoUser(true);
|
617
|
+
}
|
618
|
+
|
619
|
+
if (provider !== 'phone') {
|
620
|
+
return rejectPromiseWithCodeAndMessage(
|
621
|
+
'invalid-credential',
|
622
|
+
'The supplied auth credential does not have a phone provider.',
|
623
|
+
);
|
624
|
+
}
|
625
|
+
|
626
|
+
const credential = getAuthCredential(auth, provider, authToken, authSecret);
|
627
|
+
|
628
|
+
if (!credential) {
|
629
|
+
return rejectPromiseWithCodeAndMessage(
|
630
|
+
'invalid-credential',
|
631
|
+
'The supplied auth credential is malformed, has expired or is not currently supported.',
|
632
|
+
);
|
633
|
+
}
|
634
|
+
|
635
|
+
await updatePhoneNumber(auth.currentUser, credential);
|
636
|
+
|
637
|
+
return userToObject(auth.currentUser);
|
638
|
+
});
|
639
|
+
},
|
640
|
+
|
641
|
+
/**
|
642
|
+
* Update the current user's profile.
|
643
|
+
* @param {string} appName - The name of the app to get the auth instance for.
|
644
|
+
* @param {object} props - The properties to update.
|
645
|
+
* @returns {Promise<object>} - The current user object.
|
646
|
+
*/
|
647
|
+
async updateProfile(appName, props) {
|
648
|
+
return guard(async () => {
|
649
|
+
const auth = getCachedAuthInstance(appName);
|
650
|
+
|
651
|
+
if (auth.currentUser === null) {
|
652
|
+
return promiseNoUser(true);
|
653
|
+
}
|
654
|
+
|
655
|
+
await updateProfile(auth.currentUser, {
|
656
|
+
displayName: props.displayName,
|
657
|
+
photoURL: props.photoURL,
|
658
|
+
});
|
659
|
+
|
660
|
+
return userToObject(auth.currentUser);
|
661
|
+
});
|
662
|
+
},
|
663
|
+
|
664
|
+
/**
|
665
|
+
* Sign in with a credential.
|
666
|
+
* @param {string} appName - The name of the app to get the auth instance for.
|
667
|
+
* @param {string} provider - The provider to sign in with.
|
668
|
+
* @param {string} authToken - The auth token to sign in with.
|
669
|
+
* @param {string} authSecret - The auth secret to sign in with.
|
670
|
+
* @returns {Promise<object>} - The result of the sign in.
|
671
|
+
*/
|
672
|
+
async signInWithCredential(appName, provider, authToken, authSecret) {
|
673
|
+
return guard(async () => {
|
674
|
+
const auth = getCachedAuthInstance(appName);
|
675
|
+
const credential = getAuthCredential(auth, provider, authToken, authSecret);
|
676
|
+
|
677
|
+
if (credential === null) {
|
678
|
+
return rejectPromiseWithCodeAndMessage(
|
679
|
+
'invalid-credential',
|
680
|
+
'The supplied auth credential is malformed, has expired or is not currently supported.',
|
681
|
+
);
|
682
|
+
}
|
683
|
+
|
684
|
+
const credentialResult = await signInWithCredential(auth, credential);
|
685
|
+
return authResultToObject(credentialResult);
|
686
|
+
});
|
687
|
+
},
|
688
|
+
|
689
|
+
async signInWithProvider() {
|
690
|
+
return rejectPromiseWithCodeAndMessage(
|
691
|
+
'unsupported',
|
692
|
+
'This operation is not supported in this environment.',
|
693
|
+
);
|
694
|
+
},
|
695
|
+
|
696
|
+
// TODO...
|
697
|
+
async signInWithPhoneNumber() {},
|
698
|
+
|
699
|
+
/**
|
700
|
+
* Get a multi-factor session.
|
701
|
+
* @param {string} appName - The name of the app to get the auth instance for.
|
702
|
+
* @returns {Promise<string>} - The session ID.
|
703
|
+
*/
|
704
|
+
async getSession(appName) {
|
705
|
+
return guard(async () => {
|
706
|
+
const auth = getCachedAuthInstance(appName);
|
707
|
+
|
708
|
+
if (auth.currentUser === null) {
|
709
|
+
return promiseNoUser(true);
|
710
|
+
}
|
711
|
+
|
712
|
+
const session = await multiFactor(auth.currentUser).getSession();
|
713
|
+
|
714
|
+
// Increment the session ID.
|
715
|
+
sessionId++;
|
716
|
+
|
717
|
+
const key = `${sessionId}`;
|
718
|
+
sessionMap.set(key, session);
|
719
|
+
return key;
|
720
|
+
});
|
721
|
+
},
|
722
|
+
|
723
|
+
verifyPhoneNumberForMultiFactor() {
|
724
|
+
return rejectPromiseWithCodeAndMessage(
|
725
|
+
'unsupported',
|
726
|
+
'This operation is not supported in this environment.',
|
727
|
+
);
|
728
|
+
},
|
729
|
+
|
730
|
+
finalizeMultiFactorEnrollment() {
|
731
|
+
return rejectPromiseWithCodeAndMessage(
|
732
|
+
'unsupported',
|
733
|
+
'This operation is not supported in this environment.',
|
734
|
+
);
|
735
|
+
},
|
736
|
+
|
737
|
+
resolveMultiFactorSignIn() {
|
738
|
+
return rejectPromiseWithCodeAndMessage(
|
739
|
+
'unsupported',
|
740
|
+
'This operation is not supported in this environment.',
|
741
|
+
);
|
742
|
+
},
|
743
|
+
|
744
|
+
confirmationResultConfirm() {
|
745
|
+
return rejectPromiseWithCodeAndMessage(
|
746
|
+
'unsupported',
|
747
|
+
'This operation is not supported in this environment.',
|
748
|
+
);
|
749
|
+
},
|
750
|
+
|
751
|
+
verifyPhoneNumber() {
|
752
|
+
return rejectPromiseWithCodeAndMessage(
|
753
|
+
'unsupported',
|
754
|
+
'This operation is not supported in this environment.',
|
755
|
+
);
|
756
|
+
},
|
757
|
+
|
758
|
+
/**
|
759
|
+
* Confirm the password reset code.
|
760
|
+
* @param {string} appName - The name of the app to get the auth instance for.
|
761
|
+
* @param {string} code - The code to confirm.
|
762
|
+
* @param {string} newPassword - The new password to set.
|
763
|
+
* @returns {Promise<null>}
|
764
|
+
*/
|
765
|
+
async confirmPasswordReset(appName, code, newPassword) {
|
766
|
+
return guard(async () => {
|
767
|
+
const auth = getCachedAuthInstance(appName);
|
768
|
+
await confirmPasswordReset(auth, code, newPassword);
|
769
|
+
return promiseNoUser();
|
770
|
+
});
|
771
|
+
},
|
772
|
+
|
773
|
+
/**
|
774
|
+
* Apply an action code.
|
775
|
+
* @param {string} appName - The name of the app to get the auth instance for.
|
776
|
+
* @param {string} code - The code to apply.
|
777
|
+
* @returns {Promise<void>} - Void promise.
|
778
|
+
*/
|
779
|
+
async applyActionCode(appName, code) {
|
780
|
+
return guard(async () => {
|
781
|
+
const auth = getCachedAuthInstance(appName);
|
782
|
+
await applyActionCode(auth, code);
|
783
|
+
});
|
784
|
+
},
|
785
|
+
|
786
|
+
/**
|
787
|
+
* Check an action code.
|
788
|
+
* @param {string} appName - The name of the app to get the auth instance for.
|
789
|
+
* @param {string} code - The code to check.
|
790
|
+
* @returns {Promise<object>} - The result of the check.
|
791
|
+
*/
|
792
|
+
async checkActionCode(appName, code) {
|
793
|
+
return guard(async () => {
|
794
|
+
const auth = getCachedAuthInstance(appName);
|
795
|
+
const result = await checkActionCode(auth, code);
|
796
|
+
|
797
|
+
return {
|
798
|
+
operation: result.operation,
|
799
|
+
data: {
|
800
|
+
email: result.data.email,
|
801
|
+
fromEmail: result.data.previousEmail,
|
802
|
+
// multiFactorInfo - not implemented
|
803
|
+
},
|
804
|
+
};
|
805
|
+
});
|
806
|
+
},
|
807
|
+
|
808
|
+
/**
|
809
|
+
* Link a credential to the current user.
|
810
|
+
* @param {string} appName - The name of the app to get the auth instance for.
|
811
|
+
* @param {string} provider - The provider to link.
|
812
|
+
* @param {string} authToken - The auth token to link.
|
813
|
+
* @param {string} authSecret - The auth secret to link.
|
814
|
+
* @returns {Promise<object>} - The current user object.
|
815
|
+
*/
|
816
|
+
async linkWithCredential(appName, provider, authToken, authSecret) {
|
817
|
+
return guard(async () => {
|
818
|
+
const auth = getCachedAuthInstance(appName);
|
819
|
+
const credential = getAuthCredential(auth, provider, authToken, authSecret);
|
820
|
+
|
821
|
+
if (credential === null) {
|
822
|
+
return rejectPromiseWithCodeAndMessage(
|
823
|
+
'invalid-credential',
|
824
|
+
'The supplied auth credential is malformed, has expired or is not currently supported.',
|
825
|
+
);
|
826
|
+
}
|
827
|
+
|
828
|
+
if (auth.currentUser === null) {
|
829
|
+
return promiseNoUser(true);
|
830
|
+
}
|
831
|
+
|
832
|
+
return authResultToObject(await linkWithCredential(auth.currentUser, credential));
|
833
|
+
});
|
834
|
+
},
|
835
|
+
|
836
|
+
async linkWithProvider() {
|
837
|
+
// TODO: We could check if window is available here, but for now it's not supported.
|
838
|
+
return rejectPromiseWithCodeAndMessage(
|
839
|
+
'unsupported',
|
840
|
+
'This operation is not supported in this environment.',
|
841
|
+
);
|
842
|
+
},
|
843
|
+
|
844
|
+
/**
|
845
|
+
* Unlink a provider from the current user.
|
846
|
+
* @param {string} appName - The name of the app to get the auth instance for.
|
847
|
+
* @param {string} providerId - The provider ID to unlink.
|
848
|
+
* @returns {Promise<object>} - The current user object.
|
849
|
+
*/
|
850
|
+
async unlink(appName, providerId) {
|
851
|
+
return guard(async () => {
|
852
|
+
const auth = getCachedAuthInstance(appName);
|
853
|
+
|
854
|
+
if (auth.currentUser === null) {
|
855
|
+
return promiseNoUser(true);
|
856
|
+
}
|
857
|
+
|
858
|
+
const user = await unlink(auth.currentUser, providerId);
|
859
|
+
return userToObject(user);
|
860
|
+
});
|
861
|
+
},
|
862
|
+
|
863
|
+
/**
|
864
|
+
* Reauthenticate with a credential.
|
865
|
+
* @param {string} appName - The name of the app to get the auth instance for.
|
866
|
+
* @param {string} provider - The provider to reauthenticate with.
|
867
|
+
* @param {string} authToken - The auth token to reauthenticate with.
|
868
|
+
* @param {string} authSecret - The auth secret to reauthenticate with.
|
869
|
+
* @returns {Promise<object>} - The current user object.
|
870
|
+
*/
|
871
|
+
async reauthenticateWithCredential(appName, provider, authToken, authSecret) {
|
872
|
+
return guard(async () => {
|
873
|
+
const auth = getCachedAuthInstance(appName);
|
874
|
+
const credential = getAuthCredential(auth, provider, authToken, authSecret);
|
875
|
+
|
876
|
+
if (credential === null) {
|
877
|
+
return rejectPromiseWithCodeAndMessage(
|
878
|
+
'invalid-credential',
|
879
|
+
'The supplied auth credential is malformed, has expired or is not currently supported.',
|
880
|
+
);
|
881
|
+
}
|
882
|
+
|
883
|
+
if (auth.currentUser === null) {
|
884
|
+
return promiseNoUser(true);
|
885
|
+
}
|
886
|
+
|
887
|
+
return authResultToObject(await reauthenticateWithCredential(auth.currentUser, credential));
|
888
|
+
});
|
889
|
+
},
|
890
|
+
|
891
|
+
async reauthenticateWithProvider() {
|
892
|
+
// TODO: We could check if window is available here, but for now it's not supported.
|
893
|
+
return rejectPromiseWithCodeAndMessage(
|
894
|
+
'unsupported',
|
895
|
+
'This operation is not supported in this environment.',
|
896
|
+
);
|
897
|
+
},
|
898
|
+
|
899
|
+
/**
|
900
|
+
* Get the ID token for the current user.
|
901
|
+
* @param {string} appName - The name of the app to get the auth instance for.
|
902
|
+
* @param {boolean} forceRefresh - Whether to force a token refresh.
|
903
|
+
* @returns {Promise<string>} - The ID token.
|
904
|
+
*/
|
905
|
+
async getIdToken(appName, forceRefresh) {
|
906
|
+
return guard(async () => {
|
907
|
+
const auth = getCachedAuthInstance(appName);
|
908
|
+
|
909
|
+
if (auth.currentUser === null) {
|
910
|
+
return promiseNoUser(true);
|
911
|
+
}
|
912
|
+
|
913
|
+
const token = await getIdToken(auth.currentUser, forceRefresh);
|
914
|
+
return token;
|
915
|
+
});
|
916
|
+
},
|
917
|
+
|
918
|
+
/**
|
919
|
+
* Get the ID token result for the current user.
|
920
|
+
* @param {string} appName - The name of the app to get the auth instance for.
|
921
|
+
* @param {boolean} forceRefresh - Whether to force a token refresh.
|
922
|
+
* @returns {Promise<object>} - The ID token result.
|
923
|
+
*/
|
924
|
+
async getIdTokenResult(appName, forceRefresh) {
|
925
|
+
return guard(async () => {
|
926
|
+
const auth = getCachedAuthInstance(appName);
|
927
|
+
|
928
|
+
if (auth.currentUser === null) {
|
929
|
+
return promiseNoUser(true);
|
930
|
+
}
|
931
|
+
|
932
|
+
const result = await getIdTokenResult(auth.currentUser, forceRefresh);
|
933
|
+
|
934
|
+
// TODO(ehesp): Result looks expected, might be safer to keep fixed object?
|
935
|
+
return {
|
936
|
+
authTime: result.authTime,
|
937
|
+
expirationTime: result.expirationTime,
|
938
|
+
issuedAtTime: result.issuedAtTime,
|
939
|
+
claims: result.claims,
|
940
|
+
signInProvider: result.signInProvider,
|
941
|
+
token: result.token,
|
942
|
+
};
|
943
|
+
});
|
944
|
+
},
|
945
|
+
|
946
|
+
/* ----------------------
|
947
|
+
* other methods
|
948
|
+
* ---------------------- */
|
949
|
+
|
950
|
+
/**
|
951
|
+
* Fetch the sign in methods for an email.
|
952
|
+
* @param {string} appName - The name of the app to get the auth instance for.
|
953
|
+
* @param {string} email - The email to fetch the sign in methods for.
|
954
|
+
* @returns {Promise<string[]>} - The sign in methods for the email.
|
955
|
+
*/
|
956
|
+
async fetchSignInMethodsForEmail(appName, email) {
|
957
|
+
return guard(async () => {
|
958
|
+
const auth = getCachedAuthInstance(appName);
|
959
|
+
const methods = await fetchSignInMethodsForEmail(auth, email);
|
960
|
+
return methods;
|
961
|
+
});
|
962
|
+
},
|
963
|
+
|
964
|
+
/**
|
965
|
+
* Set the language code.
|
966
|
+
* @param {string} appName - The name of the app to get the auth instance for.
|
967
|
+
* @param {string} code - The language code to set.
|
968
|
+
* @returns {void}
|
969
|
+
*/
|
970
|
+
setLanguageCode(appName, code) {
|
971
|
+
return guard(async () => {
|
972
|
+
const auth = getCachedAuthInstance(appName);
|
973
|
+
auth.languageCode = code;
|
974
|
+
});
|
975
|
+
},
|
976
|
+
|
977
|
+
/**
|
978
|
+
* Set the tenant ID.
|
979
|
+
* @param {string} appName - The name of the app to get the auth instance for.
|
980
|
+
* @param {string} tenantId - The tenant ID to set.
|
981
|
+
* @returns {void}
|
982
|
+
*/
|
983
|
+
setTenantId(appName, tenantId) {
|
984
|
+
return guard(async () => {
|
985
|
+
const auth = getCachedAuthInstance(appName);
|
986
|
+
auth.tenantId = tenantId;
|
987
|
+
});
|
988
|
+
},
|
989
|
+
|
990
|
+
/**
|
991
|
+
* Use the device language.
|
992
|
+
* @param {string} appName - The name of the app to get the auth instance for.
|
993
|
+
* @returns void
|
994
|
+
*/
|
995
|
+
useDeviceLanguage(appName) {
|
996
|
+
return guard(async () => {
|
997
|
+
const auth = getCachedAuthInstance(appName);
|
998
|
+
useDeviceLanguage(auth);
|
999
|
+
});
|
1000
|
+
},
|
1001
|
+
|
1002
|
+
/**
|
1003
|
+
* Verify the provided password reset code.
|
1004
|
+
* @returns {string} - The users email address if valid.
|
1005
|
+
*/
|
1006
|
+
verifyPasswordResetCode(appName, code) {
|
1007
|
+
return guard(async () => {
|
1008
|
+
const auth = getCachedAuthInstance(appName);
|
1009
|
+
const email = await verifyPasswordResetCode(auth, code);
|
1010
|
+
return email;
|
1011
|
+
});
|
1012
|
+
},
|
1013
|
+
|
1014
|
+
/**
|
1015
|
+
* Connect to the auth emulator.
|
1016
|
+
* @param {string} appName - The name of the app to get the auth instance for.
|
1017
|
+
* @param {string} host - The host to use for the auth emulator.
|
1018
|
+
* @param {number} port - The port to use for the auth emulator.
|
1019
|
+
* @returns {void}
|
1020
|
+
*/
|
1021
|
+
useEmulator(appName, host, port) {
|
1022
|
+
return guard(async () => {
|
1023
|
+
const auth = getCachedAuthInstance(appName);
|
1024
|
+
connectAuthEmulator(auth, `http://${host}:${port}`);
|
1025
|
+
});
|
1026
|
+
},
|
1027
|
+
};
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@react-native-firebase/auth",
|
3
|
-
"version": "20.
|
3
|
+
"version": "20.2.0",
|
4
4
|
"author": "Invertase <oss@invertase.io> (http://invertase.io)",
|
5
5
|
"description": "React Native Firebase - The authentication module provides an easy-to-use API to integrate an authentication workflow into new and existing applications. React Native Firebase provides access to all Firebase authentication methods and identity providers.",
|
6
6
|
"main": "lib/index.js",
|
@@ -27,12 +27,12 @@
|
|
27
27
|
"plist": "^3.1.0"
|
28
28
|
},
|
29
29
|
"peerDependencies": {
|
30
|
-
"@react-native-firebase/app": "20.
|
30
|
+
"@react-native-firebase/app": "20.2.0",
|
31
31
|
"expo": ">=47.0.0"
|
32
32
|
},
|
33
33
|
"devDependencies": {
|
34
34
|
"@types/plist": "^3.0.5",
|
35
|
-
"expo": "^50.0.
|
35
|
+
"expo": "^50.0.19"
|
36
36
|
},
|
37
37
|
"peerDependenciesMeta": {
|
38
38
|
"expo": {
|
@@ -42,5 +42,5 @@
|
|
42
42
|
"publishConfig": {
|
43
43
|
"access": "public"
|
44
44
|
},
|
45
|
-
"gitHead": "
|
45
|
+
"gitHead": "82c50138d07e673213cd8dee5ce9a2f9b5656649"
|
46
46
|
}
|