Created
February 17, 2020 17:04
-
-
Save Matt-Jensen/d7c52c51b2a2ac7af7e0f7f1c31ef31d to your computer and use it in GitHub Desktop.
Access your Firebase Auth Token by dumping your IndexedDB session
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(() => { | |
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
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.