@firebase/auth 1.2.0 → 1.3.0-canary.0ae010ef2

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.
Files changed (39) hide show
  1. package/dist/browser-cjs/{index-5590c19e.js → index-77c7acd1.js} +2 -2
  2. package/dist/browser-cjs/{index-5590c19e.js.map → index-77c7acd1.js.map} +1 -1
  3. package/dist/browser-cjs/index.js +1 -1
  4. package/dist/browser-cjs/index.rn.d.ts +11 -3
  5. package/dist/browser-cjs/internal.js +1 -1
  6. package/dist/cordova/index.js +2 -2
  7. package/dist/cordova/index.rn.d.ts +11 -3
  8. package/dist/cordova/internal.js +2 -2
  9. package/dist/cordova/{popup_redirect-bbfe516d.js → popup_redirect-378dee5d.js} +2 -2
  10. package/dist/cordova/{popup_redirect-bbfe516d.js.map → popup_redirect-378dee5d.js.map} +1 -1
  11. package/dist/esm2017/{index-81415345.js → index-8ae48e33.js} +2 -2
  12. package/dist/esm2017/{index-81415345.js.map → index-8ae48e33.js.map} +1 -1
  13. package/dist/esm2017/index.js +1 -1
  14. package/dist/esm2017/index.rn.d.ts +11 -3
  15. package/dist/esm2017/internal.js +2 -2
  16. package/dist/esm5/{index-2e0f742b.js → index-24e45e55.js} +2 -2
  17. package/dist/esm5/{index-2e0f742b.js.map → index-24e45e55.js.map} +1 -1
  18. package/dist/esm5/index.js +1 -1
  19. package/dist/esm5/index.rn.d.ts +11 -3
  20. package/dist/esm5/internal.js +2 -2
  21. package/dist/index.rn.d.ts +11 -3
  22. package/dist/index.webworker.esm5.js +1 -1
  23. package/dist/node/index.js +1 -1
  24. package/dist/node/index.rn.d.ts +11 -3
  25. package/dist/node/internal.js +1 -1
  26. package/dist/node/{totp-d1683767.js → totp-55649440.js} +2 -2
  27. package/dist/node/{totp-d1683767.js.map → totp-55649440.js.map} +1 -1
  28. package/dist/node-esm/index.js +1 -1
  29. package/dist/node-esm/index.rn.d.ts +11 -3
  30. package/dist/node-esm/internal.js +2 -2
  31. package/dist/node-esm/{totp-fafe3607.js → totp-4aedda59.js} +2 -2
  32. package/dist/node-esm/{totp-fafe3607.js.map → totp-4aedda59.js.map} +1 -1
  33. package/dist/rn/{phone-13539df0.js → index-dad0301e.js} +5 -4
  34. package/dist/rn/{phone-13539df0.js.map → index-dad0301e.js.map} +1 -1
  35. package/dist/rn/index.js +90 -80
  36. package/dist/rn/index.js.map +1 -1
  37. package/dist/rn/index.rn.d.ts +11 -3
  38. package/dist/rn/internal.js +198 -198
  39. package/package.json +18 -13
package/dist/rn/index.js CHANGED
@@ -3,17 +3,12 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var app = require('@firebase/app');
6
- var phone = require('./phone-13539df0.js');
6
+ var index = require('./index-dad0301e.js');
7
7
  var tslib = require('tslib');
8
- var ReactNativeAsyncStorage = require('@react-native-async-storage/async-storage');
9
8
  require('@firebase/util');
10
9
  require('@firebase/component');
11
10
  require('@firebase/logger');
12
11
 
13
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
14
-
15
- var ReactNativeAsyncStorage__default = /*#__PURE__*/_interopDefaultLegacy(ReactNativeAsyncStorage);
16
-
17
12
  /**
18
13
  * @license
19
14
  * Copyright 2019 Google LLC
@@ -58,10 +53,10 @@ function getReactNativePersistence(storage) {
58
53
  if (!storage) {
59
54
  return [2 /*return*/, false];
60
55
  }
61
- return [4 /*yield*/, storage.setItem(phone.STORAGE_AVAILABLE_KEY, '1')];
56
+ return [4 /*yield*/, storage.setItem(index.STORAGE_AVAILABLE_KEY, '1')];
62
57
  case 1:
63
58
  _b.sent();
64
- return [4 /*yield*/, storage.removeItem(phone.STORAGE_AVAILABLE_KEY)];
59
+ return [4 /*yield*/, storage.removeItem(index.STORAGE_AVAILABLE_KEY)];
65
60
  case 2:
66
61
  _b.sent();
67
62
  return [2 /*return*/, true];
@@ -122,86 +117,101 @@ function getReactNativePersistence(storage) {
122
117
  * See the License for the specific language governing permissions and
123
118
  * limitations under the License.
124
119
  */
120
+ var NO_PERSISTENCE_WARNING = "\nYou are initializing Firebase Auth for React Native without providing\nAsyncStorage. Auth state will default to memory persistence and will not\npersist between sessions. In order to persist auth state, install the package\n\"@react-native-async-storage/async-storage\" and provide it to\ninitializeAuth:\n\nimport { initializeAuth, getReactNativePersistence } from 'firebase/auth';\nimport ReactNativeAsyncStorage from '@react-native-async-storage/async-storage';\nconst auth = initializeAuth(app, {\n persistence: getReactNativePersistence(ReactNativeAsyncStorage)\n});\n";
125
121
  function getAuth(app$1) {
126
122
  if (app$1 === void 0) { app$1 = app.getApp(); }
127
123
  var provider = app._getProvider(app$1, 'auth');
128
124
  if (provider.isInitialized()) {
129
125
  return provider.getImmediate();
130
126
  }
131
- return phone.initializeAuth(app$1, {
132
- persistence: getReactNativePersistence(ReactNativeAsyncStorage__default["default"])
133
- });
127
+ // Only warn if getAuth() is called before initializeAuth()
128
+ index._logWarn(NO_PERSISTENCE_WARNING);
129
+ return index.initializeAuth(app$1);
130
+ }
131
+ /**
132
+ * Wrapper around base `initializeAuth()` for RN users only, which
133
+ * shows the warning message if no persistence is provided.
134
+ * Double-checked potential collision with `export * from './index.shared'`
135
+ * as `./index.shared` also exports `initializeAuth()`, and the final
136
+ * bundle does correctly export only this `initializeAuth()` function
137
+ * and not the one from index.shared.
138
+ */
139
+ function initializeAuth(app, deps) {
140
+ if (!(deps === null || deps === void 0 ? void 0 : deps.persistence)) {
141
+ index._logWarn(NO_PERSISTENCE_WARNING);
142
+ }
143
+ return index.initializeAuth(app, deps);
134
144
  }
135
- phone.registerAuth("ReactNative" /* ClientPlatform.REACT_NATIVE */);
145
+ index.registerAuth("ReactNative" /* ClientPlatform.REACT_NATIVE */);
136
146
 
137
- exports.ActionCodeOperation = phone.ActionCodeOperation;
138
- exports.ActionCodeURL = phone.ActionCodeURL;
139
- exports.AuthCredential = phone.AuthCredential;
140
- exports.AuthErrorCodes = phone.AUTH_ERROR_CODES_MAP_DO_NOT_USE_INTERNALLY;
141
- exports.EmailAuthCredential = phone.EmailAuthCredential;
142
- exports.EmailAuthProvider = phone.EmailAuthProvider;
143
- exports.FacebookAuthProvider = phone.FacebookAuthProvider;
144
- exports.FactorId = phone.FactorId;
145
- exports.GithubAuthProvider = phone.GithubAuthProvider;
146
- exports.GoogleAuthProvider = phone.GoogleAuthProvider;
147
- exports.OAuthCredential = phone.OAuthCredential;
148
- exports.OAuthProvider = phone.OAuthProvider;
149
- exports.OperationType = phone.OperationType;
150
- exports.PhoneAuthCredential = phone.PhoneAuthCredential;
151
- exports.PhoneAuthProvider = phone.PhoneAuthProvider;
152
- exports.PhoneMultiFactorGenerator = phone.PhoneMultiFactorGenerator;
153
- exports.ProviderId = phone.ProviderId;
154
- exports.SAMLAuthProvider = phone.SAMLAuthProvider;
155
- exports.SignInMethod = phone.SignInMethod;
156
- exports.TwitterAuthProvider = phone.TwitterAuthProvider;
157
- exports.applyActionCode = phone.applyActionCode;
158
- exports.beforeAuthStateChanged = phone.beforeAuthStateChanged;
159
- exports.checkActionCode = phone.checkActionCode;
160
- exports.confirmPasswordReset = phone.confirmPasswordReset;
161
- exports.connectAuthEmulator = phone.connectAuthEmulator;
162
- exports.createUserWithEmailAndPassword = phone.createUserWithEmailAndPassword;
163
- exports.debugErrorMap = phone.debugErrorMap;
164
- exports.deleteUser = phone.deleteUser;
165
- exports.fetchSignInMethodsForEmail = phone.fetchSignInMethodsForEmail;
166
- exports.getAdditionalUserInfo = phone.getAdditionalUserInfo;
167
- exports.getIdToken = phone.getIdToken;
168
- exports.getIdTokenResult = phone.getIdTokenResult;
169
- exports.getMultiFactorResolver = phone.getMultiFactorResolver;
170
- exports.inMemoryPersistence = phone.inMemoryPersistence;
171
- exports.initializeAuth = phone.initializeAuth;
172
- exports.initializeRecaptchaConfig = phone.initializeRecaptchaConfig;
173
- exports.isSignInWithEmailLink = phone.isSignInWithEmailLink;
174
- exports.linkWithCredential = phone.linkWithCredential;
175
- exports.linkWithPhoneNumber = phone.linkWithPhoneNumber;
176
- exports.multiFactor = phone.multiFactor;
177
- exports.onAuthStateChanged = phone.onAuthStateChanged;
178
- exports.onIdTokenChanged = phone.onIdTokenChanged;
179
- exports.parseActionCodeURL = phone.parseActionCodeURL;
180
- exports.prodErrorMap = phone.prodErrorMap;
181
- exports.reauthenticateWithCredential = phone.reauthenticateWithCredential;
182
- exports.reauthenticateWithPhoneNumber = phone.reauthenticateWithPhoneNumber;
183
- exports.reload = phone.reload;
184
- exports.sendEmailVerification = phone.sendEmailVerification;
185
- exports.sendPasswordResetEmail = phone.sendPasswordResetEmail;
186
- exports.sendSignInLinkToEmail = phone.sendSignInLinkToEmail;
187
- exports.setPersistence = phone.setPersistence;
188
- exports.signInAnonymously = phone.signInAnonymously;
189
- exports.signInWithCredential = phone.signInWithCredential;
190
- exports.signInWithCustomToken = phone.signInWithCustomToken;
191
- exports.signInWithEmailAndPassword = phone.signInWithEmailAndPassword;
192
- exports.signInWithEmailLink = phone.signInWithEmailLink;
193
- exports.signInWithPhoneNumber = phone.signInWithPhoneNumber;
194
- exports.signOut = phone.signOut;
195
- exports.unlink = phone.unlink;
196
- exports.updateCurrentUser = phone.updateCurrentUser;
197
- exports.updateEmail = phone.updateEmail;
198
- exports.updatePassword = phone.updatePassword;
199
- exports.updatePhoneNumber = phone.updatePhoneNumber;
200
- exports.updateProfile = phone.updateProfile;
201
- exports.useDeviceLanguage = phone.useDeviceLanguage;
202
- exports.validatePassword = phone.validatePassword;
203
- exports.verifyBeforeUpdateEmail = phone.verifyBeforeUpdateEmail;
204
- exports.verifyPasswordResetCode = phone.verifyPasswordResetCode;
147
+ exports.ActionCodeOperation = index.ActionCodeOperation;
148
+ exports.ActionCodeURL = index.ActionCodeURL;
149
+ exports.AuthCredential = index.AuthCredential;
150
+ exports.AuthErrorCodes = index.AUTH_ERROR_CODES_MAP_DO_NOT_USE_INTERNALLY;
151
+ exports.EmailAuthCredential = index.EmailAuthCredential;
152
+ exports.EmailAuthProvider = index.EmailAuthProvider;
153
+ exports.FacebookAuthProvider = index.FacebookAuthProvider;
154
+ exports.FactorId = index.FactorId;
155
+ exports.GithubAuthProvider = index.GithubAuthProvider;
156
+ exports.GoogleAuthProvider = index.GoogleAuthProvider;
157
+ exports.OAuthCredential = index.OAuthCredential;
158
+ exports.OAuthProvider = index.OAuthProvider;
159
+ exports.OperationType = index.OperationType;
160
+ exports.PhoneAuthCredential = index.PhoneAuthCredential;
161
+ exports.PhoneAuthProvider = index.PhoneAuthProvider;
162
+ exports.PhoneMultiFactorGenerator = index.PhoneMultiFactorGenerator;
163
+ exports.ProviderId = index.ProviderId;
164
+ exports.SAMLAuthProvider = index.SAMLAuthProvider;
165
+ exports.SignInMethod = index.SignInMethod;
166
+ exports.TwitterAuthProvider = index.TwitterAuthProvider;
167
+ exports.applyActionCode = index.applyActionCode;
168
+ exports.beforeAuthStateChanged = index.beforeAuthStateChanged;
169
+ exports.checkActionCode = index.checkActionCode;
170
+ exports.confirmPasswordReset = index.confirmPasswordReset;
171
+ exports.connectAuthEmulator = index.connectAuthEmulator;
172
+ exports.createUserWithEmailAndPassword = index.createUserWithEmailAndPassword;
173
+ exports.debugErrorMap = index.debugErrorMap;
174
+ exports.deleteUser = index.deleteUser;
175
+ exports.fetchSignInMethodsForEmail = index.fetchSignInMethodsForEmail;
176
+ exports.getAdditionalUserInfo = index.getAdditionalUserInfo;
177
+ exports.getIdToken = index.getIdToken;
178
+ exports.getIdTokenResult = index.getIdTokenResult;
179
+ exports.getMultiFactorResolver = index.getMultiFactorResolver;
180
+ exports.inMemoryPersistence = index.inMemoryPersistence;
181
+ exports.initializeRecaptchaConfig = index.initializeRecaptchaConfig;
182
+ exports.isSignInWithEmailLink = index.isSignInWithEmailLink;
183
+ exports.linkWithCredential = index.linkWithCredential;
184
+ exports.linkWithPhoneNumber = index.linkWithPhoneNumber;
185
+ exports.multiFactor = index.multiFactor;
186
+ exports.onAuthStateChanged = index.onAuthStateChanged;
187
+ exports.onIdTokenChanged = index.onIdTokenChanged;
188
+ exports.parseActionCodeURL = index.parseActionCodeURL;
189
+ exports.prodErrorMap = index.prodErrorMap;
190
+ exports.reauthenticateWithCredential = index.reauthenticateWithCredential;
191
+ exports.reauthenticateWithPhoneNumber = index.reauthenticateWithPhoneNumber;
192
+ exports.reload = index.reload;
193
+ exports.sendEmailVerification = index.sendEmailVerification;
194
+ exports.sendPasswordResetEmail = index.sendPasswordResetEmail;
195
+ exports.sendSignInLinkToEmail = index.sendSignInLinkToEmail;
196
+ exports.setPersistence = index.setPersistence;
197
+ exports.signInAnonymously = index.signInAnonymously;
198
+ exports.signInWithCredential = index.signInWithCredential;
199
+ exports.signInWithCustomToken = index.signInWithCustomToken;
200
+ exports.signInWithEmailAndPassword = index.signInWithEmailAndPassword;
201
+ exports.signInWithEmailLink = index.signInWithEmailLink;
202
+ exports.signInWithPhoneNumber = index.signInWithPhoneNumber;
203
+ exports.signOut = index.signOut;
204
+ exports.unlink = index.unlink;
205
+ exports.updateCurrentUser = index.updateCurrentUser;
206
+ exports.updateEmail = index.updateEmail;
207
+ exports.updatePassword = index.updatePassword;
208
+ exports.updatePhoneNumber = index.updatePhoneNumber;
209
+ exports.updateProfile = index.updateProfile;
210
+ exports.useDeviceLanguage = index.useDeviceLanguage;
211
+ exports.validatePassword = index.validatePassword;
212
+ exports.verifyBeforeUpdateEmail = index.verifyBeforeUpdateEmail;
213
+ exports.verifyPasswordResetCode = index.verifyPasswordResetCode;
205
214
  exports.getAuth = getAuth;
206
215
  exports.getReactNativePersistence = getReactNativePersistence;
216
+ exports.initializeAuth = initializeAuth;
207
217
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/platform_react_native/persistence/react_native.ts","../../index.rn.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2019 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Persistence, ReactNativeAsyncStorage } from '../../model/public_types';\n\nimport {\n PersistenceInternal,\n PersistenceType,\n PersistenceValue,\n STORAGE_AVAILABLE_KEY,\n StorageEventListener\n} from '../../core/persistence';\n\n/**\n * Returns a persistence object that wraps `AsyncStorage` imported from\n * `react-native` or `@react-native-community/async-storage`, and can\n * be used in the persistence dependency field in {@link initializeAuth}.\n *\n * @public\n */\nexport function getReactNativePersistence(\n storage: ReactNativeAsyncStorage\n): Persistence {\n // In the _getInstance() implementation (see src/core/persistence/index.ts),\n // we expect each \"externs.Persistence\" object passed to us by the user to\n // be able to be instantiated (as a class) using \"new\". That function also\n // expects the constructor to be empty. Since ReactNativeStorage requires the\n // underlying storage layer, we need to be able to create subclasses\n // (closures, esentially) that have the storage layer but empty constructor.\n return class implements PersistenceInternal {\n static type: 'LOCAL' = 'LOCAL';\n readonly type: PersistenceType = PersistenceType.LOCAL;\n\n async _isAvailable(): Promise<boolean> {\n try {\n if (!storage) {\n return false;\n }\n await storage.setItem(STORAGE_AVAILABLE_KEY, '1');\n await storage.removeItem(STORAGE_AVAILABLE_KEY);\n return true;\n } catch {\n return false;\n }\n }\n\n _set(key: string, value: PersistenceValue): Promise<void> {\n return storage.setItem(key, JSON.stringify(value));\n }\n\n async _get<T extends PersistenceValue>(key: string): Promise<T | null> {\n const json = await storage.getItem(key);\n return json ? JSON.parse(json) : null;\n }\n\n _remove(key: string): Promise<void> {\n return storage.removeItem(key);\n }\n\n _addListener(_key: string, _listener: StorageEventListener): void {\n // Listeners are not supported for React Native storage.\n return;\n }\n\n _removeListener(_key: string, _listener: StorageEventListener): void {\n // Listeners are not supported for React Native storage.\n return;\n }\n };\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * This is the file that people using React Native will actually import. You\n * should only include this file if you have something specific about your\n * implementation that mandates having a separate entrypoint. Otherwise you can\n * just use index.ts\n */\n\nimport { FirebaseApp, getApp, _getProvider } from '@firebase/app';\nimport { Auth } from './src/model/public_types';\n\nimport { initializeAuth } from './src';\nimport { registerAuth } from './src/core/auth/register';\nimport { ClientPlatform } from './src/core/util/version';\nimport { getReactNativePersistence } from './src/platform_react_native/persistence/react_native';\nimport ReactNativeAsyncStorage from '@react-native-async-storage/async-storage';\n\n// Core functionality shared by all clients\nexport * from './index.shared';\n\n// Export some Phone symbols\n// providers\nexport { PhoneAuthProvider } from './src/platform_browser/providers/phone';\n\n// strategies\nexport {\n signInWithPhoneNumber,\n linkWithPhoneNumber,\n reauthenticateWithPhoneNumber,\n updatePhoneNumber\n} from './src/platform_browser/strategies/phone';\n\n// MFA\nexport { PhoneMultiFactorGenerator } from './src/platform_browser/mfa/assertions/phone';\n\nexport { getReactNativePersistence };\n\nexport function getAuth(app: FirebaseApp = getApp()): Auth {\n const provider = _getProvider(app, 'auth');\n\n if (provider.isInitialized()) {\n return provider.getImmediate();\n }\n\n return initializeAuth(app, {\n persistence: getReactNativePersistence(ReactNativeAsyncStorage)\n });\n}\n\nregisterAuth(ClientPlatform.REACT_NATIVE);\n"],"names":["STORAGE_AVAILABLE_KEY","app","getApp","_getProvider","initializeAuth","ReactNativeAsyncStorage","registerAuth"],"mappings":";;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;AAeG;AAYH;;;;;;AAMG;AACG,SAAU,yBAAyB,CACvC,OAAgC,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IAAI,CAAC,CAAA;;;;AACvC,aAAA,CAAA;YAED,OAAO,CAAA,SAAA,CAAA,OAAA,GAAP,UAAQ,GAAW,EAAA;AACjB,gBAAA,OAAO,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;aAChC,CAAA;AAED,YAAA,OAAA,CAAA,SAAA,CAAA,YAAY,GAAZ,UAAa,IAAY,EAAE,SAA+B,EAAA;;gBAExD,OAAO;aACR,CAAA;AAED,YAAA,OAAA,CAAA,SAAA,CAAA,eAAe,GAAf,UAAgB,IAAY,EAAE,SAA+B,EAAA;;gBAE3D,OAAO;aACR,CAAA;YACH,OAAC,OAAA,CAAA;AAAD,SAAC,EAvCM,CAAA;AACE,QAAA,EAAA,CAAA,IAAI,GAAY,OAAQ;AAsC/B,QAAA,EAAA,CAAA;AACJ;;ACnFA;;;;;;;;;;;;;;;AAeG;AAsCG,SAAU,OAAO,CAACC,KAA2B,EAAA;IAA3B,IAAAA,KAAA,KAAA,KAAA,CAAA,EAAA,EAAAA,KAAmB,GAAAC,UAAM,EAAE,CAAA,EAAA;IACjD,IAAM,QAAQ,GAAGC,gBAAY,CAACF,KAAG,EAAE,MAAM,CAAC,CAAC;AAE3C,IAAA,IAAI,QAAQ,CAAC,aAAa,EAAE,EAAE;AAC5B,QAAA,OAAO,QAAQ,CAAC,YAAY,EAAE,CAAC;AAChC,KAAA;IAED,OAAOG,oBAAc,CAACH,KAAG,EAAE;AACzB,QAAA,WAAW,EAAE,yBAAyB,CAACI,2CAAuB,CAAC;AAChE,KAAA,CAAC,CAAC;AACL,CAAC;AAEDC,kBAAY,iDAA6B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/platform_react_native/persistence/react_native.ts","../../index.rn.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2019 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Persistence, ReactNativeAsyncStorage } from '../../model/public_types';\n\nimport {\n PersistenceInternal,\n PersistenceType,\n PersistenceValue,\n STORAGE_AVAILABLE_KEY,\n StorageEventListener\n} from '../../core/persistence';\n\n/**\n * Returns a persistence object that wraps `AsyncStorage` imported from\n * `react-native` or `@react-native-community/async-storage`, and can\n * be used in the persistence dependency field in {@link initializeAuth}.\n *\n * @public\n */\nexport function getReactNativePersistence(\n storage: ReactNativeAsyncStorage\n): Persistence {\n // In the _getInstance() implementation (see src/core/persistence/index.ts),\n // we expect each \"externs.Persistence\" object passed to us by the user to\n // be able to be instantiated (as a class) using \"new\". That function also\n // expects the constructor to be empty. Since ReactNativeStorage requires the\n // underlying storage layer, we need to be able to create subclasses\n // (closures, esentially) that have the storage layer but empty constructor.\n return class implements PersistenceInternal {\n static type: 'LOCAL' = 'LOCAL';\n readonly type: PersistenceType = PersistenceType.LOCAL;\n\n async _isAvailable(): Promise<boolean> {\n try {\n if (!storage) {\n return false;\n }\n await storage.setItem(STORAGE_AVAILABLE_KEY, '1');\n await storage.removeItem(STORAGE_AVAILABLE_KEY);\n return true;\n } catch {\n return false;\n }\n }\n\n _set(key: string, value: PersistenceValue): Promise<void> {\n return storage.setItem(key, JSON.stringify(value));\n }\n\n async _get<T extends PersistenceValue>(key: string): Promise<T | null> {\n const json = await storage.getItem(key);\n return json ? JSON.parse(json) : null;\n }\n\n _remove(key: string): Promise<void> {\n return storage.removeItem(key);\n }\n\n _addListener(_key: string, _listener: StorageEventListener): void {\n // Listeners are not supported for React Native storage.\n return;\n }\n\n _removeListener(_key: string, _listener: StorageEventListener): void {\n // Listeners are not supported for React Native storage.\n return;\n }\n };\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * This is the file that people using React Native will actually import. You\n * should only include this file if you have something specific about your\n * implementation that mandates having a separate entrypoint. Otherwise you can\n * just use index.ts\n */\n\nimport { FirebaseApp, getApp, _getProvider } from '@firebase/app';\nimport { Auth, Dependencies } from './src/model/public_types';\n\nimport { initializeAuth as initializeAuthOriginal } from './src';\nimport { registerAuth } from './src/core/auth/register';\nimport { ClientPlatform } from './src/core/util/version';\nimport { _logWarn } from './src/core/util/log';\n\n// Core functionality shared by all clients\nexport * from './index.shared';\n\n// Export some Phone symbols\n// providers\nexport { PhoneAuthProvider } from './src/platform_browser/providers/phone';\n\n// strategies\nexport {\n signInWithPhoneNumber,\n linkWithPhoneNumber,\n reauthenticateWithPhoneNumber,\n updatePhoneNumber\n} from './src/platform_browser/strategies/phone';\n\n// MFA\nexport { PhoneMultiFactorGenerator } from './src/platform_browser/mfa/assertions/phone';\n\nexport { getReactNativePersistence } from './src/platform_react_native/persistence/react_native';\n\nconst NO_PERSISTENCE_WARNING = `\nYou are initializing Firebase Auth for React Native without providing\nAsyncStorage. Auth state will default to memory persistence and will not\npersist between sessions. In order to persist auth state, install the package\n\"@react-native-async-storage/async-storage\" and provide it to\ninitializeAuth:\n\nimport { initializeAuth, getReactNativePersistence } from 'firebase/auth';\nimport ReactNativeAsyncStorage from '@react-native-async-storage/async-storage';\nconst auth = initializeAuth(app, {\n persistence: getReactNativePersistence(ReactNativeAsyncStorage)\n});\n`;\n\nexport function getAuth(app: FirebaseApp = getApp()): Auth {\n const provider = _getProvider(app, 'auth');\n\n if (provider.isInitialized()) {\n return provider.getImmediate();\n }\n\n // Only warn if getAuth() is called before initializeAuth()\n _logWarn(NO_PERSISTENCE_WARNING);\n\n return initializeAuthOriginal(app);\n}\n\n/**\n * Wrapper around base `initializeAuth()` for RN users only, which\n * shows the warning message if no persistence is provided.\n * Double-checked potential collision with `export * from './index.shared'`\n * as `./index.shared` also exports `initializeAuth()`, and the final\n * bundle does correctly export only this `initializeAuth()` function\n * and not the one from index.shared.\n */\nexport function initializeAuth(app: FirebaseApp, deps?: Dependencies): Auth {\n if (!deps?.persistence) {\n _logWarn(NO_PERSISTENCE_WARNING);\n }\n return initializeAuthOriginal(app, deps);\n}\n\nregisterAuth(ClientPlatform.REACT_NATIVE);\n"],"names":["STORAGE_AVAILABLE_KEY","app","getApp","_getProvider","_logWarn","initializeAuthOriginal","registerAuth"],"mappings":";;;;;;;;;;;AAAA;;;;;;;;;;;;;;;AAeG;AAYH;;;;;;AAMG;AACG,SAAU,yBAAyB,CACvC,OAAgC,EAAA;;;;;;;;AAQhC,IAAA,OAAA,EAAA,kBAAA,YAAA;AAAO,YAAA,SAAA,OAAA,GAAA;AAEI,gBAAA,IAAA,CAAA,IAAI,GAA0C,OAAA,6BAAA;aAqCxD;AAnCO,YAAA,OAAA,CAAA,SAAA,CAAA,YAAY,GAAlB,YAAA;;;;;;gCAEI,IAAI,CAAC,OAAO,EAAE;AACZ,oCAAA,OAAA,CAAA,CAAA,aAAO,KAAK,CAAC,CAAA;AACd,iCAAA;gCACD,OAAM,CAAA,CAAA,YAAA,OAAO,CAAC,OAAO,CAACA,2BAAqB,EAAE,GAAG,CAAC,CAAA,CAAA;;AAAjD,gCAAA,EAAA,CAAA,IAAA,EAAiD,CAAC;AAClD,gCAAA,OAAA,CAAA,CAAA,YAAM,OAAO,CAAC,UAAU,CAACA,2BAAqB,CAAC,CAAA,CAAA;;AAA/C,gCAAA,EAAA,CAAA,IAAA,EAA+C,CAAC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AC;AAEI,SAAU,OAAO,CAACC,KAA2B,EAAA;IAA3B,IAAAA,KAAA,KAAA,KAAA,CAAA,EAAA,EAAAA,KAAmB,GAAAC,UAAM,EAAE,CAAA,EAAA;IACjD,IAAM,QAAQ,GAAGC,gBAAY,CAACF,KAAG,EAAE,MAAM,CAAC,CAAC;AAE3C,IAAA,IAAI,QAAQ,CAAC,aAAa,EAAE,EAAE;AAC5B,QAAA,OAAO,QAAQ,CAAC,YAAY,EAAE,CAAC;AAChC,KAAA;;IAGDG,cAAQ,CAAC,sBAAsB,CAAC,CAAC;AAEjC,IAAA,OAAOC,oBAAsB,CAACJ,KAAG,CAAC,CAAC;AACrC,CAAC;AAED;;;;;;;AAOG;AACa,SAAA,cAAc,CAAC,GAAgB,EAAE,IAAmB,EAAA;IAClE,IAAI,EAAC,IAAI,KAAJ,IAAA,IAAA,IAAI,uBAAJ,IAAI,CAAE,WAAW,CAAA,EAAE;QACtBG,cAAQ,CAAC,sBAAsB,CAAC,CAAC;AAClC,KAAA;AACD,IAAA,OAAOC,oBAAsB,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;AAC3C,CAAC;AAEDC,kBAAY,iDAA6B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -21,11 +21,19 @@
21
21
  * just use index.ts
22
22
  */
23
23
  import { FirebaseApp } from '@firebase/app';
24
- import { Auth } from './src/model/public_types';
25
- import { getReactNativePersistence } from './src/platform_react_native/persistence/react_native';
24
+ import { Auth, Dependencies } from './src/model/public_types';
26
25
  export * from './index.shared';
27
26
  export { PhoneAuthProvider } from './src/platform_browser/providers/phone';
28
27
  export { signInWithPhoneNumber, linkWithPhoneNumber, reauthenticateWithPhoneNumber, updatePhoneNumber } from './src/platform_browser/strategies/phone';
29
28
  export { PhoneMultiFactorGenerator } from './src/platform_browser/mfa/assertions/phone';
30
- export { getReactNativePersistence };
29
+ export { getReactNativePersistence } from './src/platform_react_native/persistence/react_native';
31
30
  export declare function getAuth(app?: FirebaseApp): Auth;
31
+ /**
32
+ * Wrapper around base `initializeAuth()` for RN users only, which
33
+ * shows the warning message if no persistence is provided.
34
+ * Double-checked potential collision with `export * from './index.shared'`
35
+ * as `./index.shared` also exports `initializeAuth()`, and the final
36
+ * bundle does correctly export only this `initializeAuth()` function
37
+ * and not the one from index.shared.
38
+ */
39
+ export declare function initializeAuth(app: FirebaseApp, deps?: Dependencies): Auth;