awslabs / aws-mobile-appsync-sdk-js

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

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

Open bpcrao opened 2 years ago

bpcrao commented 2 years ago

Note: If your issue/feature-request/question is regarding the AWS AppSync service, please log it in the official AWS AppSync forum

Do you want to request a feature or report a bug? bug

What is the current behavior?

  1. In incognito window mode of chrome browser "disable cookies" button
  2. try loading the script, it fails to access localStorage since the localStorage property exists but access is restricted
  3. the handling in the current code(paho-mqtt) is checking if a property exists instead

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

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem.

  1. In incognito window mode of chrome browser "disable cookies" button
  2. try loading the script, it fails to access localStorage since the localStorage property exists but access is restricted
  3. the handling in the current code(paho-mqtt) is checking if a property exists instead it should gracefully handle it by catching the exception and polyfill it.

What is the expected behavior? it should gracefully handle it by catching the exception and polyfill it.

Which versions and which environment (browser, react-native, nodejs) / OS are affected by this issue? Did this work in previous versions?

nodejs : 14.X browser: chrome

bpcrao commented 2 years ago

the expected handling is done in https://github.com/aws/aws-sdk-js/blob/307e82673b48577fce4389e4ce03f95064e8fe0d/lib/credentials/cognito_identity_credentials.js#L362