WEB WAM IMPLEMENTATION!!!!! (#708)

* feat(WAM): initial commit

* fix(wam-development): I made a whoopsie

* Update Example/example.ts

Co-authored-by: Javier Cuevas <javiercr@gmail.com>

---------

Co-authored-by: Javier Cuevas <javiercr@gmail.com>
This commit is contained in:
Rajeh Taher
2024-04-28 14:03:24 +03:00
committed by GitHub
parent e52570bbd7
commit 306e1c1355
8 changed files with 16546 additions and 1 deletions

View File

@@ -547,6 +547,24 @@ export const makeSocket = (config: SocketConfig) => {
return Buffer.concat([salt, randomIv, ciphered])
}
const sendWAMBuffer = (wamBuffer: Buffer) => {
return query({
tag: 'iq',
attrs: {
to: S_WHATSAPP_NET,
id: generateMessageTag(),
xmlns: 'w:stats'
},
content: [
{
tag: 'add',
attrs: {},
content: wamBuffer
}
]
})
}
ws.on('message', onMessageRecieved)
ws.on('open', async() => {
try {
@@ -723,6 +741,7 @@ export const makeSocket = (config: SocketConfig) => {
requestPairingCode,
/** Waits for the connection to WA to reach a state */
waitForConnectionUpdate: bindWaitForConnectionUpdate(ev),
sendWAMBuffer,
}
}