@react-native-firebase/auth 20.2.1 → 20.4.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/lib/version.js CHANGED
@@ -1,2 +1,2 @@
1
1
  // Generated by genversion.
2
- module.exports = '20.2.1';
2
+ module.exports = '20.4.0';
@@ -1,7 +1,7 @@
1
1
  import {
2
- getApps,
3
2
  getApp,
4
- getAuth,
3
+ initializeAuth,
4
+ getReactNativePersistence,
5
5
  onAuthStateChanged,
6
6
  onIdTokenChanged,
7
7
  signInAnonymously,
@@ -41,6 +41,10 @@ import {
41
41
  OAuthProvider,
42
42
  } from '@react-native-firebase/app/lib/internal/web/firebaseAuth';
43
43
  import { guard, getWebError, emitEvent } from '@react-native-firebase/app/lib/internal/web/utils';
44
+ import {
45
+ getReactNativeAsyncStorageInternal,
46
+ isMemoryStorage,
47
+ } from '@react-native-firebase/app/lib/internal/asyncStorage';
44
48
 
45
49
  /**
46
50
  * Resolves or rejects an auth method promise without a user (user was missing).
@@ -221,7 +225,32 @@ let sessionId = 0;
221
225
 
222
226
  // Returns a cached Firestore instance.
223
227
  function getCachedAuthInstance(appName) {
224
- return (instances[appName] ??= getAuth(getApp(appName)));
228
+ if (!instances[appName]) {
229
+ if (!isMemoryStorage()) {
230
+ // Warn auth persistence is is disabled unless Async Storage implementation is provided.
231
+ // eslint-disable-next-line no-console
232
+ console.warn(
233
+ ```
234
+ Firebase Auth persistence is disabled. To enable persistence, provide an Async Storage implementation.
235
+
236
+ For example, to use React Native Async Storage:
237
+
238
+ import AsyncStorage from '@react-native-async-storage/async-storage';
239
+
240
+ // Before initializing Firebase set the Async Storage implementation
241
+ // that will be used to persist user sessions.
242
+ firebase.setReactNativeAsyncStorage(AsyncStorage);
243
+
244
+ // Then initialize Firebase as normal.
245
+ await firebase.initializeApp({ ... });
246
+ ```,
247
+ );
248
+ }
249
+ instances[appName] = initializeAuth(getApp(appName), {
250
+ persistence: getReactNativePersistence(getReactNativeAsyncStorageInternal()),
251
+ });
252
+ }
253
+ return instances[appName];
225
254
  }
226
255
 
227
256
  // getConstants
@@ -230,13 +259,16 @@ const CONSTANTS = {
230
259
  APP_USER: {},
231
260
  };
232
261
 
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
- }
262
+ // Not required for web, since it's dynamic initialization
263
+ // and we are not making instances of auth based on apps that already exist
264
+ // since there are none that exist before we initialize them in our code below.
265
+ // for (const appName of getApps()) {
266
+ // const instance = getAuth(getApp(appName));
267
+ // CONSTANTS.APP_LANGUAGE[appName] = instance.languageCode;
268
+ // if (instance.currentUser) {
269
+ // CONSTANTS.APP_USER[appName] = userToObject(instance.currentUser);
270
+ // }
271
+ // }
240
272
 
241
273
  /**
242
274
  * This is a 'NativeModule' for the web platform.
@@ -693,8 +725,12 @@ export default {
693
725
  );
694
726
  },
695
727
 
696
- // TODO...
697
- async signInWithPhoneNumber() {},
728
+ async signInWithPhoneNumber() {
729
+ return rejectPromiseWithCodeAndMessage(
730
+ 'unsupported',
731
+ 'This operation is not supported in this environment.',
732
+ );
733
+ },
698
734
 
699
735
  /**
700
736
  * Get a multi-factor session.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-native-firebase/auth",
3
- "version": "20.2.1",
3
+ "version": "20.4.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,7 +27,7 @@
27
27
  "plist": "^3.1.0"
28
28
  },
29
29
  "peerDependencies": {
30
- "@react-native-firebase/app": "20.2.1",
30
+ "@react-native-firebase/app": "20.4.0",
31
31
  "expo": ">=47.0.0"
32
32
  },
33
33
  "devDependencies": {
@@ -42,5 +42,5 @@
42
42
  "publishConfig": {
43
43
  "access": "public"
44
44
  },
45
- "gitHead": "2c787c2dbefbefcc637018e1e5d74a73b39600ab"
45
+ "gitHead": "3ac3e9623674a8db52c111b4aa0a85a883260116"
46
46
  }