filestack / filestack-js

Official Javascript SDK for the Filestack API and content ingestion system.
https://www.filestack.com
MIT License
206 stars 76 forks source link

Update store.browser.ts to handle window.localStorage access error #527

Open BenMuschol-at opened 11 months ago

BenMuschol-at commented 11 months ago

🐛 Bug fix

window.localStorage crashes in an iframe with an Access Denied error. The code is already resilient to localStorage not existing, it's just not resilient to localStorage throwing an error. This PR includes a minor code structure change so that it handles this case.

Does not crash in iframes, properly falls back to other storage

heiglandreas commented 7 months ago

This is a vital change for our use-case as well.

Steps to reproduce:

In Firefox 119 set the browser privacy to "Custom" and set blocked "Cookies" to "All cross-site cookies".

grafik

Embed the filestack-code in a website that is then embedded in an iFrame on a different domain. Now accessing the localStorage will fail with error "Error: Failed to read the 'localStorage' property from 'Window': Access is denied for this document" or similar.