Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WEB WAM IMPLEMENTATION!!!!! #708

Merged
merged 3 commits into from
Apr 28, 2024
Merged

WEB WAM IMPLEMENTATION!!!!! #708

merged 3 commits into from
Apr 28, 2024

Conversation

PurpShell
Copy link
Collaborator

@PurpShell PurpShell commented Mar 30, 2024

Hey everyone, this was an enormous effort. Please support me to keep going!

Support my work on GitHub Sponsors

Overview

WAM is "WhatsApp Metrics". As we all know, WhatsApp sends a lot of analytics on all its platforms. WhatsApp has exploited this fact to send some information verifying official clients. We need this to prevent the "unofficial client, install the official whatsapp" warning.

Detailed talk

All the current WAM events (harvested from Web) are available in the ./src/WAM/constants.ts, and all the globals I saw being mentioned (there could be more). Due to the sheer amount, I'll just keep that file huge, it will get minified in TS compilation.

WhatsApp sends WAM events randomly. We know there is a schedule to them, something like monthly/weekly/daily. Though in reality, if you are active, you can see this vary a lot!

WhatsApp tracks a ginormous amount of data, in the dozens of thousands of events per client per day. For this reason, they have made their own byte-efficient protocol. This protocol (WAMv5) insures that events only take as much data as they have to. This is why we keep the constants. The WAM_EVENT's/WAM_GLOBAL ID and NAME properties are important as they serve a key-> value in the encoded protocol.

I'll be explaining more about the protocol itself in an upcoming video.

Let's talk on what this all means for your current setup.

Usage

I have made a small example in the Example.ts file, as you can see. The first event will contain specific globals, IN THAT ORDER (The globals come before the events themselves, IN ORDER, so they seem to be ordered by alphabetical order (by event ID)).

The boot_analytics_test.json in this case is used to just contain one of the events I CAPTURED A FEW WEEKS AGO! DO NOT SIMPLY RUN THIS! Only use it as a basis for understanding. Your timestamps and sequenceNumbers and everything should be matching and your events should match what you're doing in the app (more on this later`t).

AGAIN, DO NOT RUN THIS IMMEDIATELY. YOU NEED TO MAKE SURE YOUR ANALYTICS MATCH YOUR SETUP! YOU HAVE BEEN WARNED!

In this case, we require your help! On the Discord server, in the #wam channel in a thread, I would like you guys to harvest events (using a tool I'll release soon) and correlate those events for actions made in the app)!

Development

There is a lot of place for further development for this feature, and I expect we do more soon! For now, Baileys doesn't actually send any analytics on it's own (but we can work on that!).

I'll be setting up a toolkit repository in WhiskeySockets soon, to decode captured WAMs from Baileys and WA Web to inspect their payload and verify what they're doing. It'll also contain some scripts for live event and WAM buffer capture straight from Web.

I currently have a repository (PurpShell/wam-prototype) up which contains (more than this) a decoder and sample payloads for you to test with!

Credit

Thank you to Samuel! He helped me a lot in the background, and it's only because of his constant help were we able to release something so large in a small time-frame. Thank you to my sponsors, and to all the other maintainers in the space for collectively working on understanding 2.3000.x's new build system!

Thank you Edgard for your work on Baileys, your contribution will not be missed! Thank you for the help all of these years. Good luck with what you're working on next! It was a wild run!!!

@whiskeysockets-bot
Copy link
Contributor

Thanks for your contribution.

The next step is to wait for review and approval to merge it to main repository

The community can help reacting with a thumb up (:thumbsup:) for approval and rocket (:rocket:) for who has tested it.

To test this PR you can run the following command below:

# NPM
npm install @whiskeysockets/baileys@WhiskeySockets/Baileys#wam-development
# YARN v2
yarn add @whiskeysockets/baileys@WhiskeySockets/Baileys#wam-development

Example/example.ts Outdated Show resolved Hide resolved
Co-authored-by: Javier Cuevas <[email protected]>
src/WAM/BinaryInfo.ts Show resolved Hide resolved
@PurpShell
Copy link
Collaborator Author

@SheIITear / @Auties00

@PurpShell PurpShell merged commit 306e1c1 into master Apr 28, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants