pedroslopez / whatsapp-web.js

A WhatsApp client library for NodeJS that connects through the WhatsApp Web browser app
https://wwebjs.dev
Apache License 2.0
15.39k stars 3.67k forks source link

Regarding the Multi-device BETA. (CLICK HERE) #758

Closed PurpShell closed 2 years ago

PurpShell commented 3 years ago

I opened this issue to discuss the multi-device beta that just got announced and available to everyone at the latest version of the WhatsApp and WhatsApp Business beta.

We are in the final stages of supporting this beta update, and we need your help. Visit #889 to help test.

ps: pinned because of so many issues

PurpShell commented 3 years ago

localStorage

{
  "history-sync-earliest-date": "1618517463",
  "md-opted-in": "true",
  "WARoutingInfo": "{\"domain\":\"fb\",\"edgeRouting\":\"CA0IBQ==\"}",
  "f86SIKHSKlIRpTDW+hsAiQ==": "{\"id\":\"global_mute\",\"expiration\":0}",
  "4P/5geRSELQs6BOP78jHJA==": "{\"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}",
  "DmSuwvU7JZflIEQn2wbPRg==": "\"{\\\"9618xxxx95-1624479435@g.us\\\":\\\"1:QENIbvzu\\\",\\\"x96xxxxxxx8-162xxxxxx6@g.us\\\":\\\"1:yeFyj1P5\\\"}\"",
  "Ha6V0naB+Asaj7QK9E9Yhw==": "false",
  "jytAU/x5IFaodumGFgGCqQ==": "false",
  "remember-me": "true",
  "WaInitialHistorySynced": "\"true\"",
  "Q9l1pa9U6RusJLJ/OGoVmw==": "{\"readReceipts\":\"all\",\"groupAdd\":\"all\",\"profilePicture\":\"all\",\"about\":\"all\",\"lastSeen\":\"all\"}",
  "dX8DofUHWjwPKlwiKhrvbg==": "false",
  "MdUpgradeWamFlag": "false",
  "WebEncKeySalt": "\"akzrRxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxUkv9Q=\"",
  "last-wid-md": "\"xxxxxxxx2x8:2@c.us\"",
  "WALogPreemptiveCleanUp": "false",
  "DcsZisUDFOGXo22KiEczVw==": "true",
  "WAHistorySyncStatus": "{\"initialCompleted\":true,\"recentCompleted\":true}",
  "MdHistoryLastChunkProcessed": "\"3_1\"",
  "syncd_disabled_due_to_fatal": "false",
  "WANoiseInfoIv": "[\"exxfxxxxxxxYDxxxxQ==\",\"mxxTx7Kxxxxxx3x5xxxA==\",\"exxxxxx/+36Fxxxxxg==\"]",
  "critical_data_synced": "true",
  "nSsarI/MAjXIC+UZpEdYEQ==": "[0,17]",
  "7qZ3zUZ0x8WTp6gYa0npDg==": "\"{}\"",
  "WANoiseInfo": "{\"recoveryToken\":\"B82GoA6DzVxxxxxxRJtzYk5gM=\",\"pubKey\":\"6umXxxxxxxxxxxxxxxINxDxxRkxxxxxxxxTvsxb\",\"privKey\":\"ZLxxxxxxLxxFZynAxxxxxxxxxxPvEpqExxxxxmK\"}",
  "pBzk5ZV/gj4KEC8gIJo2WA==": "\"SJKJLDKSJLD\"",
  "lFi24bP/zxekbO3AVtNXXA==": "[]",
  "abprops": "{\"hash\":\"1Xv5L1\",\"lastSyncTime\":1626293473539}",
  "debugCursor": "1196",
  "WALangPref": "\"en\"",
  "dpKjR53BUeu6nmFjKBsnaQ==": "{\"FavC7xOxxxxxxQ==\":1}",
  "contact-sync-refresh-seconds": "527917",
  "WAShouldCheckContactSyncStatus": "true",
  "mobile-platform": "\"android\"",
  "whatsapp-mutex": "\"x813505889:init_1626295122038\"",
  "WABrowserId": "\"RYc8V8xxxxxxxxx7WwuEg==\""
}
PurpShell commented 3 years ago

Seems the main hurdle is the selector we wait for:

Before: image

After: image

PurpShell commented 3 years ago

WANoiseInfo, WANoiseInfoIv, WABrowserId, WebEncKeySalt seem to our new session details? I'll test saving them and then loading.

PurpShell commented 3 years ago

SUCCESS!

PurpShell commented 3 years ago

image

PurpShell commented 3 years ago

hmm, this was about Store and mR

the only hurdle i can see is the session

PurpShell commented 3 years ago

using session is proving pretty hard, seems they are using the IndexedDB;

before: image

after: image

PurpShell commented 3 years ago

image able to import the database, now trying to set it.

PurpShell commented 3 years ago

Hey! I would like to know how you guys would like me to handle this. I am going to open a Pull request to just get the bare minimum out there, regarding sessions, i have a few puzzling questions to ask, hopefully you guys can answer!

PurpShell commented 3 years ago

761 has been opened. I'll add my experimental systems there.

Darker935 commented 3 years ago

Hey! I would like to know how you guys would like me to handle this. I am going to open a Pull request to just get the bare minimum out there, regarding sessions, i have a few puzzling questions to ask, hopefully you guys can answer!

  • Would it be better if the library had control over where it places it's session and database files? As an example: you specify: something like infoPath: "./wweb-info/"in the ClientOptions and the library would go: ./wweb-info/ID/indexedDB/signal-storage.json. (YES/no), provide your way of solving this if you find it an issue!
  • How do you guys close your node app? (CTRL+C, restart via nodemon etc.) and would you rather have a (timed interval between saves (ClientOption; saveIntervalMs: 20), save on detect of closing the app, or both just in case)

Have a default path, controlled by lib, but we can change the path

I close with CTRL + C, or pm2 delete process_pid

PurpShell commented 3 years ago

Hey! I would like to know how you guys would like me to handle this. I am going to open a Pull request to just get the bare minimum out there, regarding sessions, i have a few puzzling questions to ask, hopefully you guys can answer!

  • Would it be better if the library had control over where it places it's session and database files? As an example: you specify: something like infoPath: "./wweb-info/"in the ClientOptions and the library would go: ./wweb-info/ID/indexedDB/signal-storage.json. (YES/no), provide your way of solving this if you find it an issue!
  • How do you guys close your node app? (CTRL+C, restart via nodemon etc.) and would you rather have a (timed interval between saves (ClientOption; saveIntervalMs: 20), save on detect of closing the app, or both just in case)

Have a default path, controlled by lib, but we can change the path

I close with CTRL + C, or pm2 delete process_pid

the path is based on operating system? I think that path should be placed by the user

PurpShell commented 3 years ago

Hey! I would like to know how you guys would like me to handle this. I am going to open a Pull request to just get the bare minimum out there, regarding sessions, i have a few puzzling questions to ask, hopefully you guys can answer!

  • Would it be better if the library had control over where it places it's session and database files? As an example: you specify: something like infoPath: "./wweb-info/"in the ClientOptions and the library would go: ./wweb-info/ID/indexedDB/signal-storage.json. (YES/no), provide your way of solving this if you find it an issue!
  • How do you guys close your node app? (CTRL+C, restart via nodemon etc.) and would you rather have a (timed interval between saves (ClientOption; saveIntervalMs: 20000), save on detect of closing the app, or both just in case)

@pedroslopez I would like your thoughts!

PurpShell commented 3 years ago

I know for a fact some people store data in databases, so I don't know how i'll support it for them.. Maybe a "exportAll.json" where the structure would be like this:

{
  localStorage: {},
  indexedDB: {}
} 
pedroslopez commented 3 years ago

Super interesting! Thanks for looking into this.

From what I'm understanding, WhatsApp Web when in multi-device mode no longer stores any information in localStorage and instead stores everything (including session information) in IndexedDB, so our current solution of injecting the session into localStorage before loading WhatsApp Web no longer works, is that correct?

Puppeteer has a built-in way of persisting these things by specifying a userDataDir path, which includes persisting IndexedDB as well as localStorage. However, I'd like to avoid requiring the use of the local filesystem since people might be running things in a container, which doesn't have a persistent filesystem at least by default. To this point, the session.json that we're writing today as part of examples is just one way of doing it, and people are free to load the session keys from a database or wherever else they need. I would like to keep this functionality if possible.

I think a potential path forward is to see what are the minimal values we need to persist to be able to start up a whatsapp session. This probably contains no past message data, but only things required for authentication. Then, we could do something similar to what we do for localStorage and have a pre-step that writes these things to IndexedDB instead as needed.

PurpShell commented 3 years ago

Super interesting! Thanks for looking into this.

From what I'm understanding, WhatsApp Web when in multi-device mode no longer stores any information in localStorage and instead stores everything (including session information) in IndexedDB, so our current solution of injecting the session into localStorage before loading WhatsApp Web no longer works, is that correct?

Puppeteer has a built-in way of persisting these things by specifying a userDataDir path, which includes persisting IndexedDB as well as localStorage. However, I'd like to avoid requiring the use of the local filesystem since people might be running things in a container, which doesn't have a persistent filesystem at least by default. To this point, the session.json that we're writing today as part of examples is just one way of doing it, and people are free to load the session keys from a database or wherever else they need. I would like to keep this functionality if possible.

I think a potential path forward is to see what are the minimal values we need to persist to be able to start up a whatsapp session. This probably contains no past message data, but only things required for authentication. Then, we could do something similar to what we do for localStorage and have a pre-step that writes these things to IndexedDB instead as needed.

  1. yes, it results in a no internet error, and some metadata in localStorage is required like keys, etc..

  2. i searched yesterday, and I found userDataDir. Though it seemed it'll contain too much junk, and it is unprepared for multiple instances, and as you said, people with containers and restarting servers that reset the file-system to it's original state.

  3. I found the minimal values of localStorage, i'll see what happens if i remove the database of chats, contacts, messages

olirock commented 3 years ago

any update? :/

PurpShell commented 3 years ago

Super interesting! Thanks for looking into this. From what I'm understanding, WhatsApp Web when in multi-device mode no longer stores any information in localStorage and instead stores everything (including session information) in IndexedDB, so our current solution of injecting the session into localStorage before loading WhatsApp Web no longer works, is that correct? Puppeteer has a built-in way of persisting these things by specifying a userDataDir path, which includes persisting IndexedDB as well as localStorage. However, I'd like to avoid requiring the use of the local filesystem since people might be running things in a container, which doesn't have a persistent filesystem at least by default. To this point, the session.json that we're writing today as part of examples is just one way of doing it, and people are free to load the session keys from a database or wherever else they need. I would like to keep this functionality if possible. I think a potential path forward is to see what are the minimal values we need to persist to be able to start up a whatsapp session. This probably contains no past message data, but only things required for authentication. Then, we could do something similar to what we do for localStorage and have a pre-step that writes these things to IndexedDB instead as needed.

  1. yes, it results in a no internet error, and some metadata in localStorage is required like keys, etc..
  2. i searched yesterday, and I found userDataDir. Though it seemed it'll contain too much junk, and it is unprepared for multiple instances, and as you said, people with containers and restarting servers that reset the file-system to it's original state.
  3. I found the minimal values of localStorage, i'll see what happens if i remove the database of chats, contacts, messages

I'm implementing a file management system, debating on userDataDir since it also saves data of other open tabs in the browser aswell. I am going for an Observer with a custom system to save the indexedDB now.

I'm also going to push that to #761, so stay tuned for later today as i'll talk about it on the WWebJS discord.

thewh1teagle commented 3 years ago

@PurpShell Hi to store credentials all you need to do is to backup & restore signal-storage, wawc, wawc_db_enc databases inside indexeddb + localStorage (that's not a lot of data) now, the challenge after you restore the session is to re-trigger re-sync of chats, messages, etc... has happen once when you log in. otherwise when you restore the session you will not get your chat history.

PurpShell commented 3 years ago

@PurpShell Hi to store credentials all you need to do is to backup & restore signal-storage, wawc, wawc_db_enc databases inside indexeddb + localStorage (that's not a lot of data) now, the challenge after you restore the session is to re-trigger re-sync of chats, messages, etc... has happen once when you log in. otherwise when you restore the session you will not get your chat history.

Hey! I've already documented what you said above. I am working on & testing a file management system solution. I have worked out some stuff that can potentially trigger a re-sync, looks promising.

PurpShell commented 3 years ago

After a bunch of days of inactivity, whatsapp re-syncs with the phone. This is shown in a "Downloading Messages X%" message on the splash screen. So far, I've found webpack methods that can re-trigger synchronization.

PurpShell commented 3 years ago

Pinning this issue since people have opened too many issues and this has fallen off the 1st page causing people to open more issues

PurpShell commented 3 years ago

After a bunch of days of inactivity, whatsapp re-syncs with the phone. This is shown in a "Downloading Messages X%" message on the splash screen. So far, I've found webpack methods that can re-trigger synchronization.

The issue with this is that the data is practically impossible to get (we give them an array of our messages, and they respond)

yuan8 commented 3 years ago

const KEEP_PHONE_CONNECTED_IMG_SELECTOR = '[data-asset-intro-image-light="true"], [data-asset-intro-image-dark="true"],#pane-side'; im try to add "#pane-side" to detect authentificated

PurpShell commented 3 years ago

const KEEP_PHONE_CONNECTED_IMG_SELECTOR = '[data-asset-intro-image-light="true"], [data-asset-intro-image-dark="true"],#pane-side'; im try to add "#pane-side" to detect authentificated

the image will do just good

ev4ndropc commented 3 years ago

I used this code for testing, however, it creates a directory called WWebJS with various files and folders inside, but it doesn't show the QR code on the terminal. Any solution?



const client = new Client();

client.on('qr', (qr) => {
    // Generate and scan this code with your phone
    console.log('QR RECEIVED', qr);
});

client.on('ready', () => {
    console.log('Client is ready!');
});

client.on('message', msg => {
    if (msg.body == '!ping') {
        msg.reply('pong');
    }
});

client.initialize();
smatosjr commented 3 years ago

I can't use getNumberId and isRegisteredUser methods in this version.

can anybody help me?

albalooshi commented 3 years ago

Any timeline or estimation for this feature? @pedroslopez @PurpShell

ahmedkh19 commented 3 years ago

(node:123448) UnhandledPromiseRejectionWarning: TimeoutError: waiting for selector canvas failed: timeout 45000ms exceeded at new WaitTask (/var/www/Whatsapp/Multi-device/node_modules/puppeteer/lib/cjs/puppeteer/common/DOMWorld.js:509:34) at DOMWorld.waitForSelectorInPage (/var/www/Whatsapp/Multi-device/node_modules/puppeteer/lib/cjs/puppeteer/common/DOMWorld.js:420:26) at Object.internalHandler.waitFor (/var/www/Whatsapp/Multi-device/node_modules/puppeteer/lib/cjs/puppeteer/common/QueryHandler.js:31:77) at DOMWorld.waitForSelector (/var/www/Whatsapp/Multi-device/node_modules/puppeteer/lib/cjs/puppeteer/common/DOMWorld.js:313:29) at Frame.waitForSelector (/var/www/Whatsapp/Multi-device/node_modules/puppeteer/lib/cjs/puppeteer/common/FrameManager.js:841:51) at Page.waitForSelector (/var/www/Whatsapp/Multi-device/node_modules/puppeteer/lib/cjs/puppeteer/common/Page.js:2252:33) at Timeout.getQrCode [as _onTimeout] (/var/www/Whatsapp/Multi-device/src/Client.js:140:28) at processTicksAndRejections (internal/process/task_queues.js:95:5) (Use node --trace-warnings ... to show where the warning was created) (node:123448) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1) (node:123448) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

janke184 commented 3 years ago

(node:123448) UnhandledPromiseRejectionWarning: TimeoutError: waiting for selector canvas failed: timeout 45000ms exceeded at new WaitTask (/var/www/Whatsapp/Multi-device/node_modules/puppeteer/lib/cjs/puppeteer/common/DOMWorld.js:509:34) at DOMWorld.waitForSelectorInPage (/var/www/Whatsapp/Multi-device/node_modules/puppeteer/lib/cjs/puppeteer/common/DOMWorld.js:420:26) at Object.internalHandler.waitFor (/var/www/Whatsapp/Multi-device/node_modules/puppeteer/lib/cjs/puppeteer/common/QueryHandler.js:31:77) at DOMWorld.waitForSelector (/var/www/Whatsapp/Multi-device/node_modules/puppeteer/lib/cjs/puppeteer/common/DOMWorld.js:313:29) at Frame.waitForSelector (/var/www/Whatsapp/Multi-device/node_modules/puppeteer/lib/cjs/puppeteer/common/FrameManager.js:841:51) at Page.waitForSelector (/var/www/Whatsapp/Multi-device/node_modules/puppeteer/lib/cjs/puppeteer/common/Page.js:2252:33) at Timeout.getQrCode [as _onTimeout] (/var/www/Whatsapp/Multi-device/src/Client.js:140:28) at processTicksAndRejections (internal/process/task_queues.js:95:5) (Use node --trace-warnings ... to show where the warning was created) (node:123448) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1) (node:123448) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

I have the same problem using headless=true

hz279785752 commented 3 years ago

const KEEP_PHONE_CONNECTED_IMG_SELECTOR = '[data-asset-intro-image-light="true"], [data-asset-intro-image-dark="true"], [data-icon="intro-md-beta-logo-light"], [data-icon="intro-md-beta-logo-dark"]'; I'm try to add "[data-icon="intro-md-beta-logo-light"], [data-icon="intro-md-beta-logo-dark"]" to detect authentificated,it was successful; but the wid field in clientInfo is null in WhatsApp BETA,How can this problem be solved

issue
albalooshi commented 3 years ago

Is there a way I can sponsor one of the repo developers to achieve this task?

PurpShell commented 3 years ago

Is there a way I can sponsor one of the repo developers to achieve this task?

You can sponsor me via Paypal.me, as for pedro, you can look at https://github.com/pedroslopez/whatsapp-web.js#funding

diogenespetry commented 3 years ago

Uma sugestão de mudança para que o QR code seja mostrado no console. assim facilita o uso do docker na versão, adicionei uma negação no if que verifica se a sessão existe no arquivo Client.js

javargasm commented 3 years ago

messages sent to groups are never read, even though members have already viewed them.

SebestikCZ commented 3 years ago

(node:123448) UnhandledPromiseRejectionWarning: TimeoutError: waiting for selector canvas failed: timeout 45000ms exceeded at new WaitTask (/var/www/Whatsapp/Multi-device/node_modules/puppeteer/lib/cjs/puppeteer/common/DOMWorld.js:509:34) at DOMWorld.waitForSelectorInPage (/var/www/Whatsapp/Multi-device/node_modules/puppeteer/lib/cjs/puppeteer/common/DOMWorld.js:420:26) at Object.internalHandler.waitFor (/var/www/Whatsapp/Multi-device/node_modules/puppeteer/lib/cjs/puppeteer/common/QueryHandler.js:31:77) at DOMWorld.waitForSelector (/var/www/Whatsapp/Multi-device/node_modules/puppeteer/lib/cjs/puppeteer/common/DOMWorld.js:313:29) at Frame.waitForSelector (/var/www/Whatsapp/Multi-device/node_modules/puppeteer/lib/cjs/puppeteer/common/FrameManager.js:841:51) at Page.waitForSelector (/var/www/Whatsapp/Multi-device/node_modules/puppeteer/lib/cjs/puppeteer/common/Page.js:2252:33) at Timeout.getQrCode [as _onTimeout] (/var/www/Whatsapp/Multi-device/src/Client.js:140:28) at processTicksAndRejections (internal/process/task_queues.js:95:5) (Use node --trace-warnings ... to show where the warning was created) (node:123448) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1) (node:123448) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Same problem Sorry, everything works! Just write this in the terminal npm i github:pedroslopez/whatsapp-web.js#multidevice

PurpShell commented 3 years ago

Uma sugestão de mudança para que o QR code seja mostrado no console. assim facilita o uso do docker na versão, adicionei uma negação no if que verifica se a sessão existe no arquivo Client.js

Please use english here, thanks.

Spooder9 commented 3 years ago

(node:123448) UnhandledPromiseRejectionWarning: TimeoutError: waiting for selector canvas failed: timeout 45000ms exceeded at new WaitTask (/var/www/Whatsapp/Multi-device/node_modules/puppeteer/lib/cjs/puppeteer/common/DOMWorld.js:509:34) at DOMWorld.waitForSelectorInPage (/var/www/Whatsapp/Multi-device/node_modules/puppeteer/lib/cjs/puppeteer/common/DOMWorld.js:420:26) at Object.internalHandler.waitFor (/var/www/Whatsapp/Multi-device/node_modules/puppeteer/lib/cjs/puppeteer/common/QueryHandler.js:31:77) at DOMWorld.waitForSelector (/var/www/Whatsapp/Multi-device/node_modules/puppeteer/lib/cjs/puppeteer/common/DOMWorld.js:313:29) at Frame.waitForSelector (/var/www/Whatsapp/Multi-device/node_modules/puppeteer/lib/cjs/puppeteer/common/FrameManager.js:841:51) at Page.waitForSelector (/var/www/Whatsapp/Multi-device/node_modules/puppeteer/lib/cjs/puppeteer/common/Page.js:2252:33) at Timeout.getQrCode [as _onTimeout] (/var/www/Whatsapp/Multi-device/src/Client.js:140:28) at processTicksAndRejections (internal/process/task_queues.js:95:5) (Use node --trace-warnings ... to show where the warning was created) (node:123448) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1) (node:123448) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

~Same problem~ Sorry, everything works! Just write this in the terminal npm i github:pedroslopez/whatsapp-web.js#multidevice

that happens to me too

SebestikCZ commented 3 years ago

~~I have got new problem when I tried to start my "self bot" the code doesn't did anything. But I found, that the qr code is also shown in one of the divs where qr canvas is: o3lVuP3q~~ Problem partially solved I disconnect "self bot" and delete WWebJS folder to delete session data then I need to log in. It's quite annoying when I just debugging features. I also find out that when I turn computer to sleep and wake it up again, it doesn't reload the client until program restart.

SebestikCZ commented 3 years ago

~I have got new problem when I tried to start my "self bot" the code doesn't did anything. But I found, that the qr code is also shown in one of the divs where qr canvas is: o3lVuP3q~ Problem partially solved I disconnect "self bot" and delete WWebJS folder to delete session data then I need to log in. It's quite annoying when I just debugging features. I also find out that when I turn computer to sleep and wake it up again, it doesn't reload the client until program restart.

@PurpShell please check this

PurpShell commented 3 years ago

~I have got new problem when I tried to start my "self bot" the code doesn't did anything. But I found, that the qr code is also shown in one of the divs where qr canvas is: o3lVuP3q~ Problem partially solved I disconnect "self bot" and delete WWebJS folder to delete session data then I need to log in. It's quite annoying when I just debugging features. I also find out that when I turn computer to sleep and wake it up again, it doesn't reload the client until program restart.

umm I updated the branch to fix, talk on #889

SebestikCZ commented 3 years ago

~I have got new problem when I tried to start my "self bot" the code doesn't did anything. But I found, that the qr code is also shown in one of the divs where qr canvas is: o3lVuP3q~ Problem partially solved I disconnect "self bot" and delete WWebJS folder to delete session data then I need to log in. It's quite annoying when I just debugging features. I also find out that when I turn computer to sleep and wake it up again, it doesn't reload the client until program restart.

umm I updated the branch to fix, talk on #889

okay

diogenespetry commented 3 years ago

how to check if the number has or not whatsapp account in the beta version?

DukazzCruz commented 3 years ago

how to check if the number has or not whatsapp account in the beta version?

const checkRegisteredNumber = async function(number) {

try {
    var isRegistered = await client.isRegisteredUser(number)
}catch(err) {

    isRegistered = false
    console.log(err,isRegistered)
}
console.log('isRegistered: ',isRegistered)
return isRegistered;

};

This works for me. Only Beta Whatsapp Login, Dont work for Stable Version.

diogenespetry commented 3 years ago

how to check if the number has or not whatsapp account in the beta version?

const checkRegisteredNumber = async function(number) {

try {
  var isRegistered = await client.isRegisteredUser(number)
}catch(err) {

  isRegistered = false
  console.log(err,isRegistered)
}
console.log('isRegistered: ',isRegistered)
return isRegistered;

};

This works for me. Only Beta Whatsapp Login, Dont work for Stable Version.

I did the test with this code, but it is only true if the number is saved in the contacts. ( Beta Version)

RahulKasireddy commented 3 years ago

To Re-Produce this error: Send url in text example: https://example.com

and also note: I am unable to retrieve the session again. It say's: "Are the session details valid?"

Evaluation failed: Error: Unexpected null or undefined: bundle.encKey at t.default (https://web.whatsapp.com/:2:286) at Function.encrypt (https://web.whatsapp.com/bootstrap_main.bbe15d776ba206ec4ed3.js:5:6923) at t.default. (https://web.whatsapp.com/bootstrap_main.bbe15d776ba206ec4ed3.js:2:53596) at t.default.write (https://web.whatsapp.com/bootstrap_qr.ff0d334fa3c74b000fab.js:2:390139) at Object. (https://web.whatsapp.com/bootstrap_main.bbe15d776ba206ec4ed3.js:2:38783) at Generator.next () at t (https://web.whatsapp.com/vendor1~bootstrap_qr.d4ef2d214939fc06cd93.js:2:63784) at s (https://web.whatsapp.com/vendor1~bootstrap_qr.d4ef2d214939fc06cd93.js:2:63995) at https://web.whatsapp.com/vendor1~bootstrap_qr.d4ef2d214939fc06cd93.js:2:64054 at j (https://web.whatsapp.com/bootstrap_qr.ff0d334fa3c74b000fab.js:2:385573) at ExecutionContext._evaluateInternal (/var/www/html/node_modules/whatsapp-web.js/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:221:19) at processTicksAndRejections (internal/process/task_queues.js:93:5) at async ExecutionContext.evaluate (/var/www/html/node_modules/whatsapp-web.js/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:110:16) at async Client.sendMessage (/var/www/html/node_modules/whatsapp-web.js/src/Client.js:502:28)

RahulKasireddy commented 3 years ago

how to check if the number has or not whatsapp account in the beta version?

const checkRegisteredNumber = async function(number) {

try {
    var isRegistered = await client.isRegisteredUser(number)
}catch(err) {

    isRegistered = false
    console.log(err,isRegistered)
}
console.log('isRegistered: ',isRegistered)
return isRegistered;

}; This works for me. Only Beta Whatsapp Login, Dont work for Stable Version.

I did the test with this code, but it is only true if the number is saved in the contacts. ( Beta Version)

Solution: Replace:

async isRegisteredUser(id) {
        if(!id.endsWith('@c.us')) {
            id += '@c.us';
        }
        if(!id.startsWith('+')) {
            id = '+' + id;
        }
        return await this.pupPage.evaluate(async (id) => {
            let result = await window.Store.QueryExist(id);
            return result.wid !== undefined;
        }, id);
    }

With:

async isRegisteredUser(id) {
        if (!id.endsWith('@c.us')) {
           id += '@c.us';
        }
        if (!id.startsWith('+')) {
            id = '+' + id;
        }
        return await this.pupPage.evaluate(async (id) => {
            try {
                let result = await window.Store.QueryExist(id);
                return result.wid !== undefined;
            } catch (err) {
                console.log(err)
                let result = await window.Store.Wap.queryExist(id);
                return result.jid !== undefined;
            }
        }, id);
    }
PurpShell commented 3 years ago

how to check if the number has or not whatsapp account in the beta version?

const checkRegisteredNumber = async function(number) {

try {
  var isRegistered = await client.isRegisteredUser(number)
}catch(err) {

  isRegistered = false
  console.log(err,isRegistered)
}
console.log('isRegistered: ',isRegistered)
return isRegistered;

}; This works for me. Only Beta Whatsapp Login, Dont work for Stable Version.

I did the test with this code, but it is only true if the number is saved in the contacts. ( Beta Version)

Solution: Replace:

async isRegisteredUser(id) {
        if(!id.endsWith('@c.us')) {
            id += '@c.us';
        }
        if(!id.startsWith('+')) {
            id = '+' + id;
        }
        return await this.pupPage.evaluate(async (id) => {
            let result = await window.Store.QueryExist(id);
            return result.wid !== undefined;
        }, id);
    }

With:

async isRegisteredUser(id) {
        if (!id.endsWith('@c.us')) {
           id += '@c.us';
        }
        if (!id.startsWith('+')) {
            id = '+' + id;
        }
        return await this.pupPage.evaluate(async (id) => {
            try {
                let result = await window.Store.QueryExist(id);
                return result.wid !== undefined;
            } catch (err) {
                console.log(err)
                let result = await window.Store.Wap.queryExist(id);
                return result.jid !== undefined;
            }
        }, id);
    }

Will do

diogenespetry commented 3 years ago

how to check if the number has or not whatsapp account in the beta version?

const checkRegisteredNumber = async function(number) {

try {
    var isRegistered = await client.isRegisteredUser(number)
}catch(err) {

    isRegistered = false
    console.log(err,isRegistered)
}
console.log('isRegistered: ',isRegistered)
return isRegistered;

}; This works for me. Only Beta Whatsapp Login, Dont work for Stable Version.

I did the test with this code, but it is only true if the number is saved in the contacts. ( Beta Version)

Solution: Replace:

async isRegisteredUser(id) {
        if(!id.endsWith('@c.us')) {
            id += '@c.us';
        }
        if(!id.startsWith('+')) {
            id = '+' + id;
        }
        return await this.pupPage.evaluate(async (id) => {
            let result = await window.Store.QueryExist(id);
            return result.wid !== undefined;
        }, id);
    }

With:

async isRegisteredUser(id) {
        if (!id.endsWith('@c.us')) {
           id += '@c.us';
        }
        if (!id.startsWith('+')) {
            id = '+' + id;
        }
        return await this.pupPage.evaluate(async (id) => {
            try {
                let result = await window.Store.QueryExist(id);
                return result.wid !== undefined;
            } catch (err) {
                console.log(err)
                let result = await window.Store.Wap.queryExist(id);
                return result.jid !== undefined;
            }
        }, id);
    }

Will do

That didn't work either

enhessam commented 3 years ago

hello every one i want to know you are supporting whatsapp beta or not and where is the code for it ? thanks a lot