awslabs / aws-mobile-appsync-sdk-js

JavaScript library files for Offline, Sync, Sigv4. includes support for React Native
Apache License 2.0
920 stars 266 forks source link

Remove `global.localStorage` call in paho-mqtt file for incognito mode #582

Open ekarious opened 4 years ago

ekarious commented 4 years ago

What was the problem ?

paho-mqtt.js was using the code global.localStorage.

In Private navigation (aka incognito mode), cookies are by default blocked for third party. The fallback was to use localStorage but this file is attaching localStorage to global and access to the global window is forbidden which resulted in an error.

DOMException: Failed to read the 'localStorage' property from 'Window': Access is denied for this document

Why this modification:

Remove this little piece of code will allow aws-appsync to be correctly used even in private navigation.