Skip to content

Instantly share code, notes, and snippets.

@Matt-Jensen
Created February 17, 2020 17:04
Show Gist options
  • 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));
}
);
};
})();
@jslegers
Copy link

You saved me quite some time today with this handy snippet.

Thanks a lot for sharing this code!

I used it to help me with https://github.com/microsoft/playwright-python/issues/2532.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment