No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.js 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', { value: true });
  3. var ReactNative = require('react-native');
  4. var app = require('@firebase/app');
  5. var phone = require('./phone-ec5655af.js');
  6. var tslib = require('tslib');
  7. require('@firebase/util');
  8. require('@firebase/component');
  9. require('@firebase/logger');
  10. function _interopNamespace(e) {
  11. if (e && e.__esModule) return e;
  12. var n = Object.create(null);
  13. if (e) {
  14. Object.keys(e).forEach(function (k) {
  15. if (k !== 'default') {
  16. var d = Object.getOwnPropertyDescriptor(e, k);
  17. Object.defineProperty(n, k, d.get ? d : {
  18. enumerable: true,
  19. get: function () { return e[k]; }
  20. });
  21. }
  22. });
  23. }
  24. n["default"] = e;
  25. return Object.freeze(n);
  26. }
  27. var ReactNative__namespace = /*#__PURE__*/_interopNamespace(ReactNative);
  28. /**
  29. * @license
  30. * Copyright 2019 Google LLC
  31. *
  32. * Licensed under the Apache License, Version 2.0 (the "License");
  33. * you may not use this file except in compliance with the License.
  34. * You may obtain a copy of the License at
  35. *
  36. * http://www.apache.org/licenses/LICENSE-2.0
  37. *
  38. * Unless required by applicable law or agreed to in writing, software
  39. * distributed under the License is distributed on an "AS IS" BASIS,
  40. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  41. * See the License for the specific language governing permissions and
  42. * limitations under the License.
  43. */
  44. /**
  45. * Returns a persistence object that wraps `AsyncStorage` imported from
  46. * `react-native` or `@react-native-community/async-storage`, and can
  47. * be used in the persistence dependency field in {@link initializeAuth}.
  48. *
  49. * @public
  50. */
  51. function getReactNativePersistence(storage) {
  52. var _a;
  53. // In the _getInstance() implementation (see src/core/persistence/index.ts),
  54. // we expect each "externs.Persistence" object passed to us by the user to
  55. // be able to be instantiated (as a class) using "new". That function also
  56. // expects the constructor to be empty. Since ReactNativeStorage requires the
  57. // underlying storage layer, we need to be able to create subclasses
  58. // (closures, esentially) that have the storage layer but empty constructor.
  59. return _a = /** @class */ (function () {
  60. function class_1() {
  61. this.type = "LOCAL" /* PersistenceType.LOCAL */;
  62. }
  63. class_1.prototype._isAvailable = function () {
  64. return tslib.__awaiter(this, void 0, void 0, function () {
  65. return tslib.__generator(this, function (_b) {
  66. switch (_b.label) {
  67. case 0:
  68. _b.trys.push([0, 3, , 4]);
  69. if (!storage) {
  70. return [2 /*return*/, false];
  71. }
  72. return [4 /*yield*/, storage.setItem(phone.STORAGE_AVAILABLE_KEY, '1')];
  73. case 1:
  74. _b.sent();
  75. return [4 /*yield*/, storage.removeItem(phone.STORAGE_AVAILABLE_KEY)];
  76. case 2:
  77. _b.sent();
  78. return [2 /*return*/, true];
  79. case 3:
  80. _b.sent();
  81. return [2 /*return*/, false];
  82. case 4: return [2 /*return*/];
  83. }
  84. });
  85. });
  86. };
  87. class_1.prototype._set = function (key, value) {
  88. return storage.setItem(key, JSON.stringify(value));
  89. };
  90. class_1.prototype._get = function (key) {
  91. return tslib.__awaiter(this, void 0, void 0, function () {
  92. var json;
  93. return tslib.__generator(this, function (_a) {
  94. switch (_a.label) {
  95. case 0: return [4 /*yield*/, storage.getItem(key)];
  96. case 1:
  97. json = _a.sent();
  98. return [2 /*return*/, json ? JSON.parse(json) : null];
  99. }
  100. });
  101. });
  102. };
  103. class_1.prototype._remove = function (key) {
  104. return storage.removeItem(key);
  105. };
  106. class_1.prototype._addListener = function (_key, _listener) {
  107. // Listeners are not supported for React Native storage.
  108. return;
  109. };
  110. class_1.prototype._removeListener = function (_key, _listener) {
  111. // Listeners are not supported for React Native storage.
  112. return;
  113. };
  114. return class_1;
  115. }()),
  116. _a.type = 'LOCAL',
  117. _a;
  118. }
  119. /**
  120. * @license
  121. * Copyright 2017 Google LLC
  122. *
  123. * Licensed under the Apache License, Version 2.0 (the "License");
  124. * you may not use this file except in compliance with the License.
  125. * You may obtain a copy of the License at
  126. *
  127. * http://www.apache.org/licenses/LICENSE-2.0
  128. *
  129. * Unless required by applicable law or agreed to in writing, software
  130. * distributed under the License is distributed on an "AS IS" BASIS,
  131. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  132. * See the License for the specific language governing permissions and
  133. * limitations under the License.
  134. */
  135. /**
  136. * An implementation of {@link Persistence} of type 'LOCAL' for use in React
  137. * Native environments.
  138. *
  139. * @public
  140. */
  141. var reactNativeLocalPersistence = getReactNativePersistence({
  142. getItem: function () {
  143. var _a;
  144. var args = [];
  145. for (var _i = 0; _i < arguments.length; _i++) {
  146. args[_i] = arguments[_i];
  147. }
  148. // Called inline to avoid deprecation warnings on startup.
  149. return (_a = ReactNative__namespace.AsyncStorage).getItem.apply(_a, args);
  150. },
  151. setItem: function () {
  152. var _a;
  153. var args = [];
  154. for (var _i = 0; _i < arguments.length; _i++) {
  155. args[_i] = arguments[_i];
  156. }
  157. // Called inline to avoid deprecation warnings on startup.
  158. return (_a = ReactNative__namespace.AsyncStorage).setItem.apply(_a, args);
  159. },
  160. removeItem: function () {
  161. var _a;
  162. var args = [];
  163. for (var _i = 0; _i < arguments.length; _i++) {
  164. args[_i] = arguments[_i];
  165. }
  166. // Called inline to avoid deprecation warnings on startup.
  167. return (_a = ReactNative__namespace.AsyncStorage).removeItem.apply(_a, args);
  168. }
  169. });
  170. function getAuth(app$1) {
  171. if (app$1 === void 0) { app$1 = app.getApp(); }
  172. var provider = app._getProvider(app$1, 'auth');
  173. if (provider.isInitialized()) {
  174. return provider.getImmediate();
  175. }
  176. return phone.initializeAuth(app$1, {
  177. persistence: reactNativeLocalPersistence
  178. });
  179. }
  180. phone.registerAuth("ReactNative" /* ClientPlatform.REACT_NATIVE */);
  181. exports.ActionCodeOperation = phone.ActionCodeOperation;
  182. exports.ActionCodeURL = phone.ActionCodeURL;
  183. exports.AuthCredential = phone.AuthCredential;
  184. exports.AuthErrorCodes = phone.AUTH_ERROR_CODES_MAP_DO_NOT_USE_INTERNALLY;
  185. exports.EmailAuthCredential = phone.EmailAuthCredential;
  186. exports.EmailAuthProvider = phone.EmailAuthProvider;
  187. exports.FacebookAuthProvider = phone.FacebookAuthProvider;
  188. exports.FactorId = phone.FactorId;
  189. exports.GithubAuthProvider = phone.GithubAuthProvider;
  190. exports.GoogleAuthProvider = phone.GoogleAuthProvider;
  191. exports.OAuthCredential = phone.OAuthCredential;
  192. exports.OAuthProvider = phone.OAuthProvider;
  193. exports.OperationType = phone.OperationType;
  194. exports.PhoneAuthCredential = phone.PhoneAuthCredential;
  195. exports.PhoneAuthProvider = phone.PhoneAuthProvider;
  196. exports.PhoneMultiFactorGenerator = phone.PhoneMultiFactorGenerator;
  197. exports.ProviderId = phone.ProviderId;
  198. exports.SAMLAuthProvider = phone.SAMLAuthProvider;
  199. exports.SignInMethod = phone.SignInMethod;
  200. exports.TwitterAuthProvider = phone.TwitterAuthProvider;
  201. exports.applyActionCode = phone.applyActionCode;
  202. exports.beforeAuthStateChanged = phone.beforeAuthStateChanged;
  203. exports.checkActionCode = phone.checkActionCode;
  204. exports.confirmPasswordReset = phone.confirmPasswordReset;
  205. exports.connectAuthEmulator = phone.connectAuthEmulator;
  206. exports.createUserWithEmailAndPassword = phone.createUserWithEmailAndPassword;
  207. exports.debugErrorMap = phone.debugErrorMap;
  208. exports.deleteUser = phone.deleteUser;
  209. exports.fetchSignInMethodsForEmail = phone.fetchSignInMethodsForEmail;
  210. exports.getAdditionalUserInfo = phone.getAdditionalUserInfo;
  211. exports.getIdToken = phone.getIdToken;
  212. exports.getIdTokenResult = phone.getIdTokenResult;
  213. exports.getMultiFactorResolver = phone.getMultiFactorResolver;
  214. exports.inMemoryPersistence = phone.inMemoryPersistence;
  215. exports.initializeAuth = phone.initializeAuth;
  216. exports.isSignInWithEmailLink = phone.isSignInWithEmailLink;
  217. exports.linkWithCredential = phone.linkWithCredential;
  218. exports.linkWithPhoneNumber = phone.linkWithPhoneNumber;
  219. exports.multiFactor = phone.multiFactor;
  220. exports.onAuthStateChanged = phone.onAuthStateChanged;
  221. exports.onIdTokenChanged = phone.onIdTokenChanged;
  222. exports.parseActionCodeURL = phone.parseActionCodeURL;
  223. exports.prodErrorMap = phone.prodErrorMap;
  224. exports.reauthenticateWithCredential = phone.reauthenticateWithCredential;
  225. exports.reauthenticateWithPhoneNumber = phone.reauthenticateWithPhoneNumber;
  226. exports.reload = phone.reload;
  227. exports.sendEmailVerification = phone.sendEmailVerification;
  228. exports.sendPasswordResetEmail = phone.sendPasswordResetEmail;
  229. exports.sendSignInLinkToEmail = phone.sendSignInLinkToEmail;
  230. exports.setPersistence = phone.setPersistence;
  231. exports.signInAnonymously = phone.signInAnonymously;
  232. exports.signInWithCredential = phone.signInWithCredential;
  233. exports.signInWithCustomToken = phone.signInWithCustomToken;
  234. exports.signInWithEmailAndPassword = phone.signInWithEmailAndPassword;
  235. exports.signInWithEmailLink = phone.signInWithEmailLink;
  236. exports.signInWithPhoneNumber = phone.signInWithPhoneNumber;
  237. exports.signOut = phone.signOut;
  238. exports.unlink = phone.unlink;
  239. exports.updateCurrentUser = phone.updateCurrentUser;
  240. exports.updateEmail = phone.updateEmail;
  241. exports.updatePassword = phone.updatePassword;
  242. exports.updatePhoneNumber = phone.updatePhoneNumber;
  243. exports.updateProfile = phone.updateProfile;
  244. exports.useDeviceLanguage = phone.useDeviceLanguage;
  245. exports.verifyBeforeUpdateEmail = phone.verifyBeforeUpdateEmail;
  246. exports.verifyPasswordResetCode = phone.verifyPasswordResetCode;
  247. exports.getAuth = getAuth;
  248. exports.getReactNativePersistence = getReactNativePersistence;
  249. exports.reactNativeLocalPersistence = reactNativeLocalPersistence;
  250. //# sourceMappingURL=index.js.map