diff --git a/.changeset/mighty-shirts-pump.md b/.changeset/mighty-shirts-pump.md new file mode 100644 index 00000000000..ca513c438c7 --- /dev/null +++ b/.changeset/mighty-shirts-pump.md @@ -0,0 +1,5 @@ +--- +'@firebase/auth': patch +--- + +Remove localStorage synchronization on storage events in Safari iframes. See [GitHub PR #8408](https://github.com/firebase/firebase-js-sdk/pull/8408). diff --git a/packages/auth/src/platform_browser/persistence/local_storage.ts b/packages/auth/src/platform_browser/persistence/local_storage.ts index b4126120828..94b8322d0a9 100644 --- a/packages/auth/src/platform_browser/persistence/local_storage.ts +++ b/packages/auth/src/platform_browser/persistence/local_storage.ts @@ -17,14 +17,7 @@ import { Persistence } from '../../model/public_types'; -import { getUA } from '@firebase/util'; -import { - _isSafari, - _isIOS, - _isIframe, - _isMobileBrowser, - _isIE10 -} from '../../core/util/browser'; +import { _isMobileBrowser, _isIE10 } from '../../core/util/browser'; import { PersistenceInternal as InternalPersistence, PersistenceType, @@ -33,11 +26,6 @@ import { } from '../../core/persistence'; import { BrowserPersistenceClass } from './browser'; -function _iframeCannotSyncWebStorage(): boolean { - const ua = getUA(); - return _isSafari(ua) || _isIOS(ua); -} - // The polling period in case events are not supported export const _POLLING_INTERVAL_MS = 1000; @@ -64,9 +52,6 @@ class BrowserLocalPersistence // eslint-disable-next-line @typescript-eslint/no-explicit-any private pollTimer: any | null = null; - // Safari or iOS browser and embedded in an iframe. - private readonly safariLocalStorageNotSynced = - _iframeCannotSyncWebStorage() && _isIframe(); // Whether to use polling instead of depending on window events private readonly fallbackToPolling = _isMobileBrowser(); readonly _shouldAllowMigration = true; @@ -112,26 +97,6 @@ class BrowserLocalPersistence this.stopPolling(); } - // Safari embedded iframe. Storage event will trigger with the delta - // changes but no changes will be applied to the iframe localStorage. - if (this.safariLocalStorageNotSynced) { - // Get current iframe page value. - const storedValue = this.storage.getItem(key); - // Value not synchronized, synchronize manually. - if (event.newValue !== storedValue) { - if (event.newValue !== null) { - // Value changed from current value. - this.storage.setItem(key, event.newValue); - } else { - // Current value deleted. - this.storage.removeItem(key); - } - } else if (this.localCache[key] === event.newValue && !poll) { - // Already detected and processed, do not trigger listeners again. - return; - } - } - const triggerListeners = (): void => { // Keep local map up to date in case storage event is triggered before // poll.