[WhatsApp Web Beta] Stuck on getIdbObjects #15
Comments
Oh that's a wierd issue, I don't know how this is happening yet, but I'll figure it out soon. That's the second issue related to WhatsApp Web Beta now, so they may have made some changes that trigger some funky behavior within my script. Can anyone participate in this or is there some special requirement for WhatsApp Web Beta? |
I tried to use it with chrome and the option to save the session to local file. |
That sounds great! But I would prefer not to compare these databases publicly since they contain keys for authentication to WhatsApp. |
Okay, let's do that a bit differently. Log in to WhatsApp Web Beta and look through LocalStorage and IndexedDB. Look for a key that says something like I don't need the exact values of these keys. I just need to know where they are. Could you tell me where these keys are stored in the beta version for IndexedDB? |
I can't see any key like Some useful infoMy local storage keys
> Object.keys(localStorage)
[
'whatsapp-mutex',
'remember-me',
'MdUpgradeWamFlag',
'WARoutingInfo',
'theme',
'syncd_disabled_due_to_fatal',
'system-theme-mode',
'WANoiseInfoIv',
'XXXXXXXXXXXXXXXX==',
'debugCursor',
'XXXXXXXXXXXXXXXXXXXXX==',
'contact-sync-refresh-seconds',
'last-wid-md',
'WaInitialHistorySynced',
'MdHistoryLastChunkProcessed',
'WALangPref',
'XXXXXXXXXXXXXXXXXXX==',
'XXXXXXXXXXXXXXXXXXX==',
'preserved_user_keys',
'md-opted-in',
'mobile-platform',
'XXXXXXXXXXXXXXXXXXXXX==',
'XXXXXXXXXXXXXXXXXXXXX==',
'WANoiseInfo',
'WAHistorySyncStatus',
'XXXXXXXXXXXXXXXXXXXXX==',
'XXXXXXXXXXXXXXXXXXXXX==',
'XXXXXXXXXXXXXXXXXXXXX==',
'XXXXXXXXXXXXXXXXX==',
'WAShouldCheckContactSyncStatus',
'abprops',
'XXXXXXXXXXXXXX==',
'WebEncKeySalt',
'old-logout-cred',
'XXXXXXXXXXXXXXXXXXXXXX==',
'XXXXXXXXXXXXXXXXXXXXXX==',
'XXXXXXXXXXXXXXXXXXXXXX==',
'history-sync-earliest-date',
'XXXXXXXXXXXXXXXXXXXXXX==',
'critical_data_synced'
] user objectStore inside wawc database in indexedDB
[
{
"key": "XXXXXXXXXXXXXXXXXXXXXX==",
"value": "false"
},
{
"key": XXXXXXXXXXXXXXXXXXX==",
"value": "{\"XXXXXXXXXXXXXXXXXX==\":1,\"XXXXXXXXXXXXXXXXXXXX==\":2}"
},
{
"key": "XXXXXXXXXXXXXXXXXXX==",
"value": "{\"DELETE_MSG_CLEAR_MEDIA\":true,\"MD_PAYMENT\":true,\"ARCHIVE_BROADCAST\":true,\"RECENT_EMOJI_SYNC\":true,\"VOIP_VOICE_CALL\":true,\"DESKTOP_VOIP_VOICE_CALL\":true,\"DESKTOP_VOIP_VIDEO_CALL\":true,\"MD_BACKEND\":true,\"MD_ADV\":true,\"MD_VOIP_GROUP\":false,\"VOIP_INDIVIDUAL_OUTGOING\":true,\"GROUPS_V_3\":true,\"GROUPS_V_3_CREATE\":false,\"CHANGE_NUMBER_V_2\":true,\"QUERY_STATUS_V_3_THUMBNAIL\":false,\"LIVE_LOCATIONS\":true,\"QUERY_VNAME\":true,\"VOIP_INDIVIDUAL_INCOMING\":true,\"PAYMENTS\":true,\"STICKER_PACK_QUERY\":true,\"LIVE_LOCATIONS_FINAL\":true,\"MEDIA_UPLOAD\":true,\"VNAME_V_2\":true,\"VIDEO_PLAYBACK_URL\":true,\"STATUS_RANKING\":true,\"VOIP_INDIVIDUAL_VIDEO\":false,\"THIRD_PARTY_STICKERS\":true,\"FREQUENTLY_FORWARDED_SETTING\":true,\"GROUPS_V_4_JOIN_PERMISSION\":true,\"RECENT_STICKERS\":false,\"CATALOG\":true,\"STARRED_STICKERS\":false,\"TEMPLATE_MESSAGE\":true,\"TEMPLATE_MESSAGE_INTERACTIVITY\":false,\"EPHEMERAL_MESSAGES\":true,\"RECENT_STICKERS_V_2\":true,\"USER_NOTICE\":true,\"SUPPORT\":true,\"GROUP_UII_CLEANUP\":true}"
},
{
"key": "XXXXXXXXXXXXXXXXXXXXXXXXX==",
"value": "[]"
},
{
"key": "XXXXXXXXXXXXXXXXXX==",
"value": "false"
},
{
"key": "WALangPref",
"value": "\"en\""
},
{
"key": "WALogPreemptiveCleanUp",
"value": "false"
},
{
"key": "WARoutingInfo",
"value": "{\"domain\":\"fb\",\"edgeRouting\":\"XXXXXX==\"}"
},
{
"key": "WAShouldCheckContactSyncStatus",
"value": "true"
},
{
"key": "XXXXXXXXXXXXXXXXXXXX==",
"value": "[0,17]"
},
{
"key": "debugCursor",
"value": "1222"
},
{
"key": "XXXXXXXXXXXXX==",
"value": "{\"XXXXXXXXXXXXXX==\":1}"
},
{
"key": "mobile-platform",
"value": "\"android\""
},
{
"key": "XXXXXXXXXXXXXXXXXXXX==",
"value": "{\"id\":\"global_mute\",\"expiration\":0}"
},
{
"key": "whatsapp-mutex",
"value": "\"xXXXXXXXXX:init_XXXXXXXXXXXXX\""
},
{
"key": "XXXXXXXXXXXXXXXXX==",
"value": "false"
}
] |
Thank you for providing so much information! I will update my script to allow WhatsApp Web Beta to work with it and tell you when you can test the new version. |
I already tried to manually restore the whole localStorage and user objectStore inside wawc database but whatsapp didn't connect. |
Could you describe your process to me? |
Yes. that's what I tried to do. |
Hmm, since I don't have access to the beta, it'll be a lot harder to test. I would say, let's try that with my implementation again and if that doesn't work I'll ask you to send me the other databases like you did with the |
I pushed my changes (8d13394), which means you could try to run my script again and see if it works (we would need a lot of luck though). |
I tried your latest update by unfortunately it doesn't worked Can we continue talk in telegram? |
Finally I got it to work poc here/** Promisified IndexedDB Request */
const preq = req =>
new Promise((resolve, reject) => {
req.addEventListener("error", reject);
req.addEventListener("success", e => resolve(e.target.result));
});
/** Promisified IndexedDB upgrade Request */
// const preupgrade = req =>
// new Promise((resolve, reject) => {
// req.addEventListener("error", reject)
// req.addEventListener("upgradeneeded", e => resolve(e.target.result))
// })
async function dumpIndexedDB() {
const result = {};
const dbs = await window.indexedDB.databases();
for (const { name, version } of dbs) {
const info = result[name] = {
ver: version,
tables: {},
};
const db = await preq(indexedDB.open(name));
const tables = Array.from(db.objectStoreNames);
console.log(tables)
const trans = db.transaction(tables, "readonly");
for (const tableName of tables) {
const table = trans.objectStore(tableName);
// add indexes
var indexes = {}
for (const indexName of table.indexNames) {
var index = table.index(indexName)
indexes[index.name] = {keyPath: index.keyPath, multiEntry: index.multiEntry, unique: index.unique}
}
info.tables[tableName] = {
keyPath: table.keyPath,
autoIncrement: table.autoIncrement,
indexes: indexes,
data: await preq(table.getAll()),
};
}
}
return result
}
async function restoreIndexedDB(dump) {
for (let dbName in dump) {
// delete old db
console.log(`deleting db ${dbName}`)
indexedDB.deleteDatabase(dbName)
// var db = await preupgrade(indexedDB.open(dbName, 1))
await new Promise((resolve, reject) => {
console.log(`opening new db ${dbName} version ${dump[dbName]['ver']}`)
var request = indexedDB.open(dbName, dump[dbName]['ver'])
request.onerror = e => reject(request)
request.onupgradeneeded = e => {
var db = e.target.result
for (const tableName in dump[dbName]['tables']) {
// debugger
var tableInfo = dump[dbName]['tables'][tableName]
// create table
console.log(`creating table ${tableName} in db ${dbName}`)
if (!tableInfo.keyPath) tableInfo.keyPath = "key"
var table = db.createObjectStore(tableName, { keyPath: tableInfo['keyPath'], autoIncrement: tableInfo['autoIncrement'] } )
// restore table indexes
for (const indexName in tableInfo['indexes']) {
console.log(`restoring index ${indexName} in table ${tableName} in db ${dbName}`)
const indexInfo = tableInfo['indexes'][indexName]
table.createIndex(indexName, indexInfo.keyPath, indexInfo)
}
// restore table data
console.log(`restoring data for table ${tableName}`)
for (const row of tableInfo['data']) {
table.add(row)
}
}
db.close()
resolve("ok")
}
})
}
return "ok"
}
async function deleteData() {
// localStorage.clear()
for (let db of await indexedDB.databases()) {
console.log(`deleting db ${db.name}`)
indexedDB.deleteDatabase(db.name)
}
}
async function test() {
var data = await dumpIndexedDB()
await restoreIndexedDB(data)
console.log("done")
} |
Thank you again for your work! |
Looking at the db names from your reply before (#15 (comment)) I would narrow down the list of necessary dbs like that:
Then we have a list of DBs that have to be included and can start poking at ObjectStores. I can't do a lot without having the ObjectStores and their keys, so it would be great if you could post the keys for the other DBs and OSs here as well. That way I could at least give you some kind of script that would figure out what we would need to save and help you with that! |
Tried, It worked when I restore now another thing - |
Nice! Have you tried doing it without localStorage? In the normal version WhatsApp Web would only check if one of them is there and because they used to switch between those two places I just restore the information to both localStorage and IDB. Ahh I think I might have read something about that before... Take a look at page 10 of this preview security whitepaper. I didn't read all of it yet, but they might hint at what they are using to resync message history and stuff. (I found that whitepaper on this page if you are curious: https://www.whatsapp.com/security/ ) As a first shot, there is this |
When I keep only indexeddb without localStorage it's not working, whatsapp throws me out. |
Update: |
I finally got the option to join the Multi Device Beta! So I will try to get it working with my script and while I am at it, I want to implement some general changes to the script to make it more reliable. Hopefully I will be able to solve this issue soon! |
Awesome news @jeliebig , I can't wait for your updates with Multi Device to be available. Hope you can get it working as soon as possible. |
@jeliebig Have you found a solution for the Multi Device? Look forward to your reply. |
Currently not at home, but was planning on finishing it today! Hopefully I can do it and don't have to let you guys wait any longer. |
@jeliebig Thanks for your great effort! |
Unfortunately I was not able to finish it this weekend. Since Firefox doesn't support Sorry to keep you guys waiting, I will comment here again, once everything is fixed and tested. But for now I need to get some sleep. |
@jeliebig |
That's what I kind of did. I am still rewriting a lot of this project and want to implement everything specific to WhatsApp in it's own subclass. Currently the rewrite works for dumping the session, but I still have some bugs in the restore process. @thewh1teagle I used your PoC from above as a reference for my new |
Thanks for asking, Yes you can and I would like to : - ) |
Hi, I also had this problem |
This issue will be solved soon. There is one annoying issue remaining that I need to fix, before I can merge everything into master. I am sorry that it takes me such a long time, but I currently need to study a lot for my exams and don't have as much time for my projects as I usually have. |
Nevermind, this will take longer than I expected. After fixing the remaining issue, I tested the script again and saw that my session wasn't restored correctly and WhatsApp would not let me login. This led to some more testing and I figured out which IDB databases are required to restore a working session from WhatsApp Web. One of these is To get this working, I need to figure out when the key gets imported and how the site receives it. |
thank you for your effort In which branch is the modified project now? (I know it is not finished yet) |
Everything is currently in this branch: |
@jeliebig Hi, Whatsapp is going to phase out the current web version and upgrade to the multi-device version in 7 days. See if there is a working version / workaround that we can use. Thanks a lot for your great effort. |
If that's true, I don't think there is anything that I could do to get the script to work again. The problem I'm facing is that I can't export the necessary This project was mostly a learning experience for me and I wanted to learn how open source works (even though I only got a tiny glimpse here, it was very valuable to me). I'm going to leave this issue open in case I or anyone else wants to work on it, but for now I don't think there is anything I can do. Thanks for helping me with this project and thank you so much for using it! |
WhatsApp started rolling out their new multi-device version this week and thus my script will stop working as soon as people update. I updated the README accordingly and will stop working on this project. Thank you guys for helping me (especially with this issue) and for using my script until it stopped working! |
I tried to use your script with chromium to store the session on file but after I logged in using the qr code the scripts hangs on.
As you can see in the picture, I use the beta version of whatsapp.
The text was updated successfully, but these errors were encountered: