-
Notifications
You must be signed in to change notification settings - Fork 897
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
.getItem from a local/session storage throws when 3rd party cookies/storage is disabled - chrome mobile & other similar behaving browsers #280
Comments
Can you provide exact steps how to recreate this? Right now, I am not sure what you are experiencing. |
Dont have unminified version since it still wasnt open sourced per say - dist was just a minified version, used |
Tried testing it with the Chrome emulator but can't reproduce it as you report it. |
I do this in 2 cases: Initializing redux store: export const firebaseApp = firebase.initializeApp(firebaseConfig);
const auth = firebaseApp.auth();
// make sure we only persist session and nothing else
auth.setPersistence(firebase.auth.Auth.Persistence.NONE);
...
// enable listener for id token and update http auth header accordingly
auth.onIdTokenChanged((user) => {
if (!user) return setHttpAuth();
return user
.getIdToken(false)
.catch((e) => {
window.Raven.captureException(e);
store.dispatch(showModal());
return null;
})
.then(setHttpAuth);
}); Second case: export const mintToken = createAction('@@auth0/firebase-mint', () => (dispatch, getState, getFirebase) => {
if (getState().auth.isFirebaseLoaded === false) return null;
dispatch(firebaseStartedLoading());
const token = getState().auth.id_token_payload[FIREBASE_TOKEN_KEY];
const fb = getFirebase();
return fb.auth()
.signInWithCustomToken(token)
.catch((e) => {
// Try again.
if (e.code === 'auth/network-request-failed') {
return fb.auth().signInWithCustomToken(token);
}
throw e;
})
.then(currentUser => currentUser.getIdToken())
.catch((e) => {
window.Raven.captureException(e, {
extra: {
context: 'auth/firebase-mint',
code: e.code,
},
});
throw e;
});
}); Likely its somewhere during 1st case, because the second one would've been reported as an error inside the reducer, and it did not |
This is similar, but when SecurityError is thrown, ie some1 accesses window.localStorage (simple as that) and I think I know where it is: https://github.com/firebase/firebase-js-sdk/blob/master/packages/auth/src/storage/localstorage.js#L57-L59 - access to localstorage object, I assume https://github.com/firebase/firebase-js-sdk/blob/master/packages/auth/src/storage/localstorage.js#L76 - likely throws |
I am still unable to recreate this. I am also not familiar with the debugger you are using. |
I'm using sentry.io / raven for capturing errors that do propagate up to the window and not get caught. Stacktrack is on the minified source code because there was no original code to map this to (ie you've just opensourced it a few days ago?) |
Yeah, we just open sourced yesterday. |
seems to have fixed it! |
Sorry, I forgot to update the bug. Thanks for confirming. |
Describe your environment
Describe the problem
Accessing window.localStorage && localStorage.getItem may throw security error based on settings of chrome, code is minified so cant really point to where it happens, but search via .getItem in the auth dist and it will be there
The text was updated successfully, but these errors were encountered: