Skip to content

Instantly share code, notes, and snippets.

@Matt-Jensen
Created February 17, 2020 17:04
Show Gist options
  • Star 14 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save Matt-Jensen/d7c52c51b2a2ac7af7e0f7f1c31ef31d to your computer and use it in GitHub Desktop.
Save Matt-Jensen/d7c52c51b2a2ac7af7e0f7f1c31ef31d to your computer and use it in GitHub Desktop.
Access your Firebase Auth Token by dumping your IndexedDB session
(() => {
const asyncForEach = (array, callback, done) => {
const runAndWait = i => {
if (i === array.length) return done();
return callback(array[i], () => runAndWait(i + 1));
};
return runAndWait(0);
};
const dump = {};
const dbRequest = window.indexedDB.open("firebaseLocalStorageDb");
dbRequest.onsuccess = () => {
const db = dbRequest.result;
const stores = ['firebaseLocalStorage'];
const tx = db.transaction(stores);
asyncForEach(
stores,
(store, next) => {
const req = tx.objectStore(store).getAll();
req.onsuccess = () => {
dump[store] = req.result;
next();
};
},
() => {
console.log(JSON.stringify(dump));
}
);
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment