internal.js 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', { value: true });
  3. var index = require('./index-5ca0aadd.js');
  4. var util = require('@firebase/util');
  5. require('@firebase/app');
  6. require('tslib');
  7. require('@firebase/logger');
  8. require('@firebase/component');
  9. /**
  10. * @license
  11. * Copyright 2021 Google LLC
  12. *
  13. * Licensed under the Apache License, Version 2.0 (the "License");
  14. * you may not use this file except in compliance with the License.
  15. * You may obtain a copy of the License at
  16. *
  17. * http://www.apache.org/licenses/LICENSE-2.0
  18. *
  19. * Unless required by applicable law or agreed to in writing, software
  20. * distributed under the License is distributed on an "AS IS" BASIS,
  21. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  22. * See the License for the specific language governing permissions and
  23. * limitations under the License.
  24. */
  25. function _cordovaWindow() {
  26. return window;
  27. }
  28. /**
  29. * @license
  30. * Copyright 2020 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. * How long to wait after the app comes back into focus before concluding that
  46. * the user closed the sign in tab.
  47. */
  48. const REDIRECT_TIMEOUT_MS = 2000;
  49. /**
  50. * Generates the URL for the OAuth handler.
  51. */
  52. async function _generateHandlerUrl(auth, event, provider) {
  53. var _a;
  54. // Get the cordova plugins
  55. const { BuildInfo } = _cordovaWindow();
  56. index.debugAssert(event.sessionId, 'AuthEvent did not contain a session ID');
  57. const sessionDigest = await computeSha256(event.sessionId);
  58. const additionalParams = {};
  59. if (index._isIOS()) {
  60. // iOS app identifier
  61. additionalParams['ibi'] = BuildInfo.packageName;
  62. }
  63. else if (index._isAndroid()) {
  64. // Android app identifier
  65. additionalParams['apn'] = BuildInfo.packageName;
  66. }
  67. else {
  68. index._fail(auth, "operation-not-supported-in-this-environment" /* AuthErrorCode.OPERATION_NOT_SUPPORTED */);
  69. }
  70. // Add the display name if available
  71. if (BuildInfo.displayName) {
  72. additionalParams['appDisplayName'] = BuildInfo.displayName;
  73. }
  74. // Attached the hashed session ID
  75. additionalParams['sessionId'] = sessionDigest;
  76. return index._getRedirectUrl(auth, provider, event.type, undefined, (_a = event.eventId) !== null && _a !== void 0 ? _a : undefined, additionalParams);
  77. }
  78. /**
  79. * Validates that this app is valid for this project configuration
  80. */
  81. async function _validateOrigin(auth) {
  82. const { BuildInfo } = _cordovaWindow();
  83. const request = {};
  84. if (index._isIOS()) {
  85. request.iosBundleId = BuildInfo.packageName;
  86. }
  87. else if (index._isAndroid()) {
  88. request.androidPackageName = BuildInfo.packageName;
  89. }
  90. else {
  91. index._fail(auth, "operation-not-supported-in-this-environment" /* AuthErrorCode.OPERATION_NOT_SUPPORTED */);
  92. }
  93. // Will fail automatically if package name is not authorized
  94. await index._getProjectConfig(auth, request);
  95. }
  96. function _performRedirect(handlerUrl) {
  97. // Get the cordova plugins
  98. const { cordova } = _cordovaWindow();
  99. return new Promise(resolve => {
  100. cordova.plugins.browsertab.isAvailable(browserTabIsAvailable => {
  101. let iabRef = null;
  102. if (browserTabIsAvailable) {
  103. cordova.plugins.browsertab.openUrl(handlerUrl);
  104. }
  105. else {
  106. // TODO: Return the inappbrowser ref that's returned from the open call
  107. iabRef = cordova.InAppBrowser.open(handlerUrl, index._isIOS7Or8() ? '_blank' : '_system', 'location=yes');
  108. }
  109. resolve(iabRef);
  110. });
  111. });
  112. }
  113. /**
  114. * This function waits for app activity to be seen before resolving. It does
  115. * this by attaching listeners to various dom events. Once the app is determined
  116. * to be visible, this promise resolves. AFTER that resolution, the listeners
  117. * are detached and any browser tabs left open will be closed.
  118. */
  119. async function _waitForAppResume(auth, eventListener, iabRef) {
  120. // Get the cordova plugins
  121. const { cordova } = _cordovaWindow();
  122. let cleanup = () => { };
  123. try {
  124. await new Promise((resolve, reject) => {
  125. let onCloseTimer = null;
  126. // DEFINE ALL THE CALLBACKS =====
  127. function authEventSeen() {
  128. var _a;
  129. // Auth event was detected. Resolve this promise and close the extra
  130. // window if it's still open.
  131. resolve();
  132. const closeBrowserTab = (_a = cordova.plugins.browsertab) === null || _a === void 0 ? void 0 : _a.close;
  133. if (typeof closeBrowserTab === 'function') {
  134. closeBrowserTab();
  135. }
  136. // Close inappbrowser emebedded webview in iOS7 and 8 case if still
  137. // open.
  138. if (typeof (iabRef === null || iabRef === void 0 ? void 0 : iabRef.close) === 'function') {
  139. iabRef.close();
  140. }
  141. }
  142. function resumed() {
  143. if (onCloseTimer) {
  144. // This code already ran; do not rerun.
  145. return;
  146. }
  147. onCloseTimer = window.setTimeout(() => {
  148. // Wait two seeconds after resume then reject.
  149. reject(index._createError(auth, "redirect-cancelled-by-user" /* AuthErrorCode.REDIRECT_CANCELLED_BY_USER */));
  150. }, REDIRECT_TIMEOUT_MS);
  151. }
  152. function visibilityChanged() {
  153. if ((document === null || document === void 0 ? void 0 : document.visibilityState) === 'visible') {
  154. resumed();
  155. }
  156. }
  157. // ATTACH ALL THE LISTENERS =====
  158. // Listen for the auth event
  159. eventListener.addPassiveListener(authEventSeen);
  160. // Listen for resume and visibility events
  161. document.addEventListener('resume', resumed, false);
  162. if (index._isAndroid()) {
  163. document.addEventListener('visibilitychange', visibilityChanged, false);
  164. }
  165. // SETUP THE CLEANUP FUNCTION =====
  166. cleanup = () => {
  167. eventListener.removePassiveListener(authEventSeen);
  168. document.removeEventListener('resume', resumed, false);
  169. document.removeEventListener('visibilitychange', visibilityChanged, false);
  170. if (onCloseTimer) {
  171. window.clearTimeout(onCloseTimer);
  172. }
  173. };
  174. });
  175. }
  176. finally {
  177. cleanup();
  178. }
  179. }
  180. /**
  181. * Checks the configuration of the Cordova environment. This has no side effect
  182. * if the configuration is correct; otherwise it throws an error with the
  183. * missing plugin.
  184. */
  185. function _checkCordovaConfiguration(auth) {
  186. var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
  187. const win = _cordovaWindow();
  188. // Check all dependencies installed.
  189. // https://github.com/nordnet/cordova-universal-links-plugin
  190. // Note that cordova-universal-links-plugin has been abandoned.
  191. // A fork with latest fixes is available at:
  192. // https://www.npmjs.com/package/cordova-universal-links-plugin-fix
  193. index._assert(typeof ((_a = win === null || win === void 0 ? void 0 : win.universalLinks) === null || _a === void 0 ? void 0 : _a.subscribe) === 'function', auth, "invalid-cordova-configuration" /* AuthErrorCode.INVALID_CORDOVA_CONFIGURATION */, {
  194. missingPlugin: 'cordova-universal-links-plugin-fix'
  195. });
  196. // https://www.npmjs.com/package/cordova-plugin-buildinfo
  197. index._assert(typeof ((_b = win === null || win === void 0 ? void 0 : win.BuildInfo) === null || _b === void 0 ? void 0 : _b.packageName) !== 'undefined', auth, "invalid-cordova-configuration" /* AuthErrorCode.INVALID_CORDOVA_CONFIGURATION */, {
  198. missingPlugin: 'cordova-plugin-buildInfo'
  199. });
  200. // https://github.com/google/cordova-plugin-browsertab
  201. index._assert(typeof ((_e = (_d = (_c = win === null || win === void 0 ? void 0 : win.cordova) === null || _c === void 0 ? void 0 : _c.plugins) === null || _d === void 0 ? void 0 : _d.browsertab) === null || _e === void 0 ? void 0 : _e.openUrl) === 'function', auth, "invalid-cordova-configuration" /* AuthErrorCode.INVALID_CORDOVA_CONFIGURATION */, {
  202. missingPlugin: 'cordova-plugin-browsertab'
  203. });
  204. index._assert(typeof ((_h = (_g = (_f = win === null || win === void 0 ? void 0 : win.cordova) === null || _f === void 0 ? void 0 : _f.plugins) === null || _g === void 0 ? void 0 : _g.browsertab) === null || _h === void 0 ? void 0 : _h.isAvailable) === 'function', auth, "invalid-cordova-configuration" /* AuthErrorCode.INVALID_CORDOVA_CONFIGURATION */, {
  205. missingPlugin: 'cordova-plugin-browsertab'
  206. });
  207. // https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-inappbrowser/
  208. index._assert(typeof ((_k = (_j = win === null || win === void 0 ? void 0 : win.cordova) === null || _j === void 0 ? void 0 : _j.InAppBrowser) === null || _k === void 0 ? void 0 : _k.open) === 'function', auth, "invalid-cordova-configuration" /* AuthErrorCode.INVALID_CORDOVA_CONFIGURATION */, {
  209. missingPlugin: 'cordova-plugin-inappbrowser'
  210. });
  211. }
  212. /**
  213. * Computes the SHA-256 of a session ID. The SubtleCrypto interface is only
  214. * available in "secure" contexts, which covers Cordova (which is served on a file
  215. * protocol).
  216. */
  217. async function computeSha256(sessionId) {
  218. const bytes = stringToArrayBuffer(sessionId);
  219. // TODO: For IE11 crypto has a different name and this operation comes back
  220. // as an object, not a promise. This is the old proposed standard that
  221. // is used by IE11:
  222. // https://www.w3.org/TR/2013/WD-WebCryptoAPI-20130108/#cryptooperation-interface
  223. const buf = await crypto.subtle.digest('SHA-256', bytes);
  224. const arr = Array.from(new Uint8Array(buf));
  225. return arr.map(num => num.toString(16).padStart(2, '0')).join('');
  226. }
  227. function stringToArrayBuffer(str) {
  228. // This function is only meant to deal with an ASCII charset and makes
  229. // certain simplifying assumptions.
  230. index.debugAssert(/[0-9a-zA-Z]+/.test(str), 'Can only convert alpha-numeric strings');
  231. if (typeof TextEncoder !== 'undefined') {
  232. return new TextEncoder().encode(str);
  233. }
  234. const buff = new ArrayBuffer(str.length);
  235. const view = new Uint8Array(buff);
  236. for (let i = 0; i < str.length; i++) {
  237. view[i] = str.charCodeAt(i);
  238. }
  239. return view;
  240. }
  241. /**
  242. * @license
  243. * Copyright 2020 Google LLC
  244. *
  245. * Licensed under the Apache License, Version 2.0 (the "License");
  246. * you may not use this file except in compliance with the License.
  247. * You may obtain a copy of the License at
  248. *
  249. * http://www.apache.org/licenses/LICENSE-2.0
  250. *
  251. * Unless required by applicable law or agreed to in writing, software
  252. * distributed under the License is distributed on an "AS IS" BASIS,
  253. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  254. * See the License for the specific language governing permissions and
  255. * limitations under the License.
  256. */
  257. const SESSION_ID_LENGTH = 20;
  258. /** Custom AuthEventManager that adds passive listeners to events */
  259. class CordovaAuthEventManager extends index.AuthEventManager {
  260. constructor() {
  261. super(...arguments);
  262. this.passiveListeners = new Set();
  263. this.initPromise = new Promise(resolve => {
  264. this.resolveInialized = resolve;
  265. });
  266. }
  267. addPassiveListener(cb) {
  268. this.passiveListeners.add(cb);
  269. }
  270. removePassiveListener(cb) {
  271. this.passiveListeners.delete(cb);
  272. }
  273. // In a Cordova environment, this manager can live through multiple redirect
  274. // operations
  275. resetRedirect() {
  276. this.queuedRedirectEvent = null;
  277. this.hasHandledPotentialRedirect = false;
  278. }
  279. /** Override the onEvent method */
  280. onEvent(event) {
  281. this.resolveInialized();
  282. this.passiveListeners.forEach(cb => cb(event));
  283. return super.onEvent(event);
  284. }
  285. async initialized() {
  286. await this.initPromise;
  287. }
  288. }
  289. /**
  290. * Generates a (partial) {@link AuthEvent}.
  291. */
  292. function _generateNewEvent(auth, type, eventId = null) {
  293. return {
  294. type,
  295. eventId,
  296. urlResponse: null,
  297. sessionId: generateSessionId(),
  298. postBody: null,
  299. tenantId: auth.tenantId,
  300. error: index._createError(auth, "no-auth-event" /* AuthErrorCode.NO_AUTH_EVENT */)
  301. };
  302. }
  303. function _savePartialEvent(auth, event) {
  304. return storage()._set(persistenceKey(auth), event);
  305. }
  306. async function _getAndRemoveEvent(auth) {
  307. const event = (await storage()._get(persistenceKey(auth)));
  308. if (event) {
  309. await storage()._remove(persistenceKey(auth));
  310. }
  311. return event;
  312. }
  313. function _eventFromPartialAndUrl(partialEvent, url) {
  314. var _a, _b;
  315. // Parse the deep link within the dynamic link URL.
  316. const callbackUrl = _getDeepLinkFromCallback(url);
  317. // Confirm it is actually a callback URL.
  318. // Currently the universal link will be of this format:
  319. // https://<AUTH_DOMAIN>/__/auth/callback<OAUTH_RESPONSE>
  320. // This is a fake URL but is not intended to take the user anywhere
  321. // and just redirect to the app.
  322. if (callbackUrl.includes('/__/auth/callback')) {
  323. // Check if there is an error in the URL.
  324. // This mechanism is also used to pass errors back to the app:
  325. // https://<AUTH_DOMAIN>/__/auth/callback?firebaseError=<STRINGIFIED_ERROR>
  326. const params = searchParamsOrEmpty(callbackUrl);
  327. // Get the error object corresponding to the stringified error if found.
  328. const errorObject = params['firebaseError']
  329. ? parseJsonOrNull(decodeURIComponent(params['firebaseError']))
  330. : null;
  331. const code = (_b = (_a = errorObject === null || errorObject === void 0 ? void 0 : errorObject['code']) === null || _a === void 0 ? void 0 : _a.split('auth/')) === null || _b === void 0 ? void 0 : _b[1];
  332. const error = code ? index._createError(code) : null;
  333. if (error) {
  334. return {
  335. type: partialEvent.type,
  336. eventId: partialEvent.eventId,
  337. tenantId: partialEvent.tenantId,
  338. error,
  339. urlResponse: null,
  340. sessionId: null,
  341. postBody: null
  342. };
  343. }
  344. else {
  345. return {
  346. type: partialEvent.type,
  347. eventId: partialEvent.eventId,
  348. tenantId: partialEvent.tenantId,
  349. sessionId: partialEvent.sessionId,
  350. urlResponse: callbackUrl,
  351. postBody: null
  352. };
  353. }
  354. }
  355. return null;
  356. }
  357. function generateSessionId() {
  358. const chars = [];
  359. const allowedChars = '1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
  360. for (let i = 0; i < SESSION_ID_LENGTH; i++) {
  361. const idx = Math.floor(Math.random() * allowedChars.length);
  362. chars.push(allowedChars.charAt(idx));
  363. }
  364. return chars.join('');
  365. }
  366. function storage() {
  367. return index._getInstance(index.browserLocalPersistence);
  368. }
  369. function persistenceKey(auth) {
  370. return index._persistenceKeyName("authEvent" /* KeyName.AUTH_EVENT */, auth.config.apiKey, auth.name);
  371. }
  372. function parseJsonOrNull(json) {
  373. try {
  374. return JSON.parse(json);
  375. }
  376. catch (e) {
  377. return null;
  378. }
  379. }
  380. // Exported for testing
  381. function _getDeepLinkFromCallback(url) {
  382. const params = searchParamsOrEmpty(url);
  383. const link = params['link'] ? decodeURIComponent(params['link']) : undefined;
  384. // Double link case (automatic redirect)
  385. const doubleDeepLink = searchParamsOrEmpty(link)['link'];
  386. // iOS custom scheme links.
  387. const iOSDeepLink = params['deep_link_id']
  388. ? decodeURIComponent(params['deep_link_id'])
  389. : undefined;
  390. const iOSDoubleDeepLink = searchParamsOrEmpty(iOSDeepLink)['link'];
  391. return iOSDoubleDeepLink || iOSDeepLink || doubleDeepLink || link || url;
  392. }
  393. /**
  394. * Optimistically tries to get search params from a string, or else returns an
  395. * empty search params object.
  396. */
  397. function searchParamsOrEmpty(url) {
  398. if (!(url === null || url === void 0 ? void 0 : url.includes('?'))) {
  399. return {};
  400. }
  401. const [_, ...rest] = url.split('?');
  402. return util.querystringDecode(rest.join('?'));
  403. }
  404. /**
  405. * @license
  406. * Copyright 2021 Google LLC
  407. *
  408. * Licensed under the Apache License, Version 2.0 (the "License");
  409. * you may not use this file except in compliance with the License.
  410. * You may obtain a copy of the License at
  411. *
  412. * http://www.apache.org/licenses/LICENSE-2.0
  413. *
  414. * Unless required by applicable law or agreed to in writing, software
  415. * distributed under the License is distributed on an "AS IS" BASIS,
  416. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  417. * See the License for the specific language governing permissions and
  418. * limitations under the License.
  419. */
  420. /**
  421. * How long to wait for the initial auth event before concluding no
  422. * redirect pending
  423. */
  424. const INITIAL_EVENT_TIMEOUT_MS = 500;
  425. class CordovaPopupRedirectResolver {
  426. constructor() {
  427. this._redirectPersistence = index.browserSessionPersistence;
  428. this._shouldInitProactively = true; // This is lightweight for Cordova
  429. this.eventManagers = new Map();
  430. this.originValidationPromises = {};
  431. this._completeRedirectFn = index._getRedirectResult;
  432. this._overrideRedirectResult = index._overrideRedirectResult;
  433. }
  434. async _initialize(auth) {
  435. const key = auth._key();
  436. let manager = this.eventManagers.get(key);
  437. if (!manager) {
  438. manager = new CordovaAuthEventManager(auth);
  439. this.eventManagers.set(key, manager);
  440. this.attachCallbackListeners(auth, manager);
  441. }
  442. return manager;
  443. }
  444. _openPopup(auth) {
  445. index._fail(auth, "operation-not-supported-in-this-environment" /* AuthErrorCode.OPERATION_NOT_SUPPORTED */);
  446. }
  447. async _openRedirect(auth, provider, authType, eventId) {
  448. _checkCordovaConfiguration(auth);
  449. const manager = await this._initialize(auth);
  450. await manager.initialized();
  451. // Reset the persisted redirect states. This does not matter on Web where
  452. // the redirect always blows away application state entirely. On Cordova,
  453. // the app maintains control flow through the redirect.
  454. manager.resetRedirect();
  455. index._clearRedirectOutcomes();
  456. await this._originValidation(auth);
  457. const event = _generateNewEvent(auth, authType, eventId);
  458. await _savePartialEvent(auth, event);
  459. const url = await _generateHandlerUrl(auth, event, provider);
  460. const iabRef = await _performRedirect(url);
  461. return _waitForAppResume(auth, manager, iabRef);
  462. }
  463. _isIframeWebStorageSupported(_auth, _cb) {
  464. throw new Error('Method not implemented.');
  465. }
  466. _originValidation(auth) {
  467. const key = auth._key();
  468. if (!this.originValidationPromises[key]) {
  469. this.originValidationPromises[key] = _validateOrigin(auth);
  470. }
  471. return this.originValidationPromises[key];
  472. }
  473. attachCallbackListeners(auth, manager) {
  474. // Get the global plugins
  475. const { universalLinks, handleOpenURL, BuildInfo } = _cordovaWindow();
  476. const noEventTimeout = setTimeout(async () => {
  477. // We didn't see that initial event. Clear any pending object and
  478. // dispatch no event
  479. await _getAndRemoveEvent(auth);
  480. manager.onEvent(generateNoEvent());
  481. }, INITIAL_EVENT_TIMEOUT_MS);
  482. const universalLinksCb = async (eventData) => {
  483. // We have an event so we can clear the no event timeout
  484. clearTimeout(noEventTimeout);
  485. const partialEvent = await _getAndRemoveEvent(auth);
  486. let finalEvent = null;
  487. if (partialEvent && (eventData === null || eventData === void 0 ? void 0 : eventData['url'])) {
  488. finalEvent = _eventFromPartialAndUrl(partialEvent, eventData['url']);
  489. }
  490. // If finalEvent is never filled, trigger with no event
  491. manager.onEvent(finalEvent || generateNoEvent());
  492. };
  493. // Universal links subscriber doesn't exist for iOS, so we need to check
  494. if (typeof universalLinks !== 'undefined' &&
  495. typeof universalLinks.subscribe === 'function') {
  496. universalLinks.subscribe(null, universalLinksCb);
  497. }
  498. // iOS 7 or 8 custom URL schemes.
  499. // This is also the current default behavior for iOS 9+.
  500. // For this to work, cordova-plugin-customurlscheme needs to be installed.
  501. // https://github.com/EddyVerbruggen/Custom-URL-scheme
  502. // Do not overwrite the existing developer's URL handler.
  503. const existingHandleOpenURL = handleOpenURL;
  504. const packagePrefix = `${BuildInfo.packageName.toLowerCase()}://`;
  505. _cordovaWindow().handleOpenURL = async (url) => {
  506. if (url.toLowerCase().startsWith(packagePrefix)) {
  507. // We want this intentionally to float
  508. // eslint-disable-next-line @typescript-eslint/no-floating-promises
  509. universalLinksCb({ url });
  510. }
  511. // Call the developer's handler if it is present.
  512. if (typeof existingHandleOpenURL === 'function') {
  513. try {
  514. existingHandleOpenURL(url);
  515. }
  516. catch (e) {
  517. // This is a developer error. Don't stop the flow of the SDK.
  518. console.error(e);
  519. }
  520. }
  521. };
  522. }
  523. }
  524. /**
  525. * An implementation of {@link PopupRedirectResolver} suitable for Cordova
  526. * based applications.
  527. *
  528. * @public
  529. */
  530. const cordovaPopupRedirectResolver = CordovaPopupRedirectResolver;
  531. function generateNoEvent() {
  532. return {
  533. type: "unknown" /* AuthEventType.UNKNOWN */,
  534. eventId: null,
  535. sessionId: null,
  536. urlResponse: null,
  537. postBody: null,
  538. tenantId: null,
  539. error: index._createError("no-auth-event" /* AuthErrorCode.NO_AUTH_EVENT */)
  540. };
  541. }
  542. /**
  543. * @license
  544. * Copyright 2017 Google LLC
  545. *
  546. * Licensed under the Apache License, Version 2.0 (the "License");
  547. * you may not use this file except in compliance with the License.
  548. * You may obtain a copy of the License at
  549. *
  550. * http://www.apache.org/licenses/LICENSE-2.0
  551. *
  552. * Unless required by applicable law or agreed to in writing, software
  553. * distributed under the License is distributed on an "AS IS" BASIS,
  554. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  555. * See the License for the specific language governing permissions and
  556. * limitations under the License.
  557. */
  558. // This function should only be called by frameworks (e.g. FirebaseUI-web) to log their usage.
  559. // It is not intended for direct use by developer apps. NO jsdoc here to intentionally leave it out
  560. // of autogenerated documentation pages to reduce accidental misuse.
  561. function addFrameworkForLogging(auth, framework) {
  562. index._castAuth(auth)._logFramework(framework);
  563. }
  564. exports.ActionCodeOperation = index.ActionCodeOperation;
  565. exports.ActionCodeURL = index.ActionCodeURL;
  566. exports.AuthCredential = index.AuthCredential;
  567. exports.AuthErrorCodes = index.AUTH_ERROR_CODES_MAP_DO_NOT_USE_INTERNALLY;
  568. exports.AuthImpl = index.AuthImpl;
  569. exports.AuthPopup = index.AuthPopup;
  570. exports.EmailAuthCredential = index.EmailAuthCredential;
  571. exports.EmailAuthProvider = index.EmailAuthProvider;
  572. exports.FacebookAuthProvider = index.FacebookAuthProvider;
  573. exports.FactorId = index.FactorId;
  574. exports.FetchProvider = index.FetchProvider;
  575. exports.GithubAuthProvider = index.GithubAuthProvider;
  576. exports.GoogleAuthProvider = index.GoogleAuthProvider;
  577. exports.OAuthCredential = index.OAuthCredential;
  578. exports.OAuthProvider = index.OAuthProvider;
  579. exports.OperationType = index.OperationType;
  580. exports.PhoneAuthCredential = index.PhoneAuthCredential;
  581. exports.PhoneAuthProvider = index.PhoneAuthProvider;
  582. exports.PhoneMultiFactorGenerator = index.PhoneMultiFactorGenerator;
  583. exports.ProviderId = index.ProviderId;
  584. exports.RecaptchaVerifier = index.RecaptchaVerifier;
  585. exports.SAMLAuthCredential = index.SAMLAuthCredential;
  586. exports.SAMLAuthProvider = index.SAMLAuthProvider;
  587. exports.SignInMethod = index.SignInMethod;
  588. exports.TotpMultiFactorGenerator = index.TotpMultiFactorGenerator;
  589. exports.TotpSecret = index.TotpSecret;
  590. exports.TwitterAuthProvider = index.TwitterAuthProvider;
  591. exports.UserImpl = index.UserImpl;
  592. exports._assert = index._assert;
  593. exports._castAuth = index._castAuth;
  594. exports._fail = index._fail;
  595. exports._generateEventId = index._generateEventId;
  596. exports._getClientVersion = index._getClientVersion;
  597. exports._getInstance = index._getInstance;
  598. exports._getRedirectResult = index._getRedirectResult;
  599. exports._overrideRedirectResult = index._overrideRedirectResult;
  600. exports._persistenceKeyName = index._persistenceKeyName;
  601. exports.applyActionCode = index.applyActionCode;
  602. exports.beforeAuthStateChanged = index.beforeAuthStateChanged;
  603. exports.browserLocalPersistence = index.browserLocalPersistence;
  604. exports.browserPopupRedirectResolver = index.browserPopupRedirectResolver;
  605. exports.browserSessionPersistence = index.browserSessionPersistence;
  606. exports.checkActionCode = index.checkActionCode;
  607. exports.confirmPasswordReset = index.confirmPasswordReset;
  608. exports.connectAuthEmulator = index.connectAuthEmulator;
  609. exports.createUserWithEmailAndPassword = index.createUserWithEmailAndPassword;
  610. exports.debugErrorMap = index.debugErrorMap;
  611. exports.deleteUser = index.deleteUser;
  612. exports.fetchSignInMethodsForEmail = index.fetchSignInMethodsForEmail;
  613. exports.getAdditionalUserInfo = index.getAdditionalUserInfo;
  614. exports.getAuth = index.getAuth;
  615. exports.getIdToken = index.getIdToken;
  616. exports.getIdTokenResult = index.getIdTokenResult;
  617. exports.getMultiFactorResolver = index.getMultiFactorResolver;
  618. exports.getRedirectResult = index.getRedirectResult;
  619. exports.inMemoryPersistence = index.inMemoryPersistence;
  620. exports.indexedDBLocalPersistence = index.indexedDBLocalPersistence;
  621. exports.initializeAuth = index.initializeAuth;
  622. exports.initializeRecaptchaConfig = index.initializeRecaptchaConfig;
  623. exports.isSignInWithEmailLink = index.isSignInWithEmailLink;
  624. exports.linkWithCredential = index.linkWithCredential;
  625. exports.linkWithPhoneNumber = index.linkWithPhoneNumber;
  626. exports.linkWithPopup = index.linkWithPopup;
  627. exports.linkWithRedirect = index.linkWithRedirect;
  628. exports.multiFactor = index.multiFactor;
  629. exports.onAuthStateChanged = index.onAuthStateChanged;
  630. exports.onIdTokenChanged = index.onIdTokenChanged;
  631. exports.parseActionCodeURL = index.parseActionCodeURL;
  632. exports.prodErrorMap = index.prodErrorMap;
  633. exports.reauthenticateWithCredential = index.reauthenticateWithCredential;
  634. exports.reauthenticateWithPhoneNumber = index.reauthenticateWithPhoneNumber;
  635. exports.reauthenticateWithPopup = index.reauthenticateWithPopup;
  636. exports.reauthenticateWithRedirect = index.reauthenticateWithRedirect;
  637. exports.reload = index.reload;
  638. exports.sendEmailVerification = index.sendEmailVerification;
  639. exports.sendPasswordResetEmail = index.sendPasswordResetEmail;
  640. exports.sendSignInLinkToEmail = index.sendSignInLinkToEmail;
  641. exports.setPersistence = index.setPersistence;
  642. exports.signInAnonymously = index.signInAnonymously;
  643. exports.signInWithCredential = index.signInWithCredential;
  644. exports.signInWithCustomToken = index.signInWithCustomToken;
  645. exports.signInWithEmailAndPassword = index.signInWithEmailAndPassword;
  646. exports.signInWithEmailLink = index.signInWithEmailLink;
  647. exports.signInWithPhoneNumber = index.signInWithPhoneNumber;
  648. exports.signInWithPopup = index.signInWithPopup;
  649. exports.signInWithRedirect = index.signInWithRedirect;
  650. exports.signOut = index.signOut;
  651. exports.unlink = index.unlink;
  652. exports.updateCurrentUser = index.updateCurrentUser;
  653. exports.updateEmail = index.updateEmail;
  654. exports.updatePassword = index.updatePassword;
  655. exports.updatePhoneNumber = index.updatePhoneNumber;
  656. exports.updateProfile = index.updateProfile;
  657. exports.useDeviceLanguage = index.useDeviceLanguage;
  658. exports.verifyBeforeUpdateEmail = index.verifyBeforeUpdateEmail;
  659. exports.verifyPasswordResetCode = index.verifyPasswordResetCode;
  660. exports.addFrameworkForLogging = addFrameworkForLogging;
  661. exports.cordovaPopupRedirectResolver = cordovaPopupRedirectResolver;
  662. //# sourceMappingURL=internal.js.map