@queenanya/baileys 7.3.5 → 7.3.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.anya-md/.replit +2 -0
- package/.anya-md/.temp/.temp +1 -0
- package/.anya-md/Dockerfile +16 -0
- package/.anya-md/LICENCE +674 -0
- package/.anya-md/README.md +301 -0
- package/.anya-md/app.json +81 -0
- package/.anya-md/config.js +74 -0
- package/.anya-md/heroku.yml +5 -0
- package/.anya-md/index.js +47 -0
- package/.anya-md/koyeb.yaml +14 -0
- package/.anya-md/lib/.dev.js +47 -0
- package/.anya-md/lib/Assets/aliveMedia.mp4 +0 -0
- package/.anya-md/lib/Assets/goodbyeBG.jpg +0 -0
- package/.anya-md/lib/Assets/image_1.jpg +0 -0
- package/.anya-md/lib/Assets/image_2.jpg +0 -0
- package/.anya-md/lib/Assets/menuMedia.mp4 +0 -0
- package/.anya-md/lib/Assets/ownerMentionMp3.mp3 +0 -0
- package/.anya-md/lib/Assets/port.html +36 -0
- package/.anya-md/lib/Assets/reaction/angry/angry108202410.jpeg +0 -0
- package/.anya-md/lib/Assets/reaction/angry/angry108202412.jpeg +0 -0
- package/.anya-md/lib/Assets/reaction/angry/angry108202413.jpeg +0 -0
- package/.anya-md/lib/Assets/reaction/angry/angry108202414.jpeg +0 -0
- package/.anya-md/lib/Assets/reaction/angry/angry108202415.jpeg +0 -0
- package/.anya-md/lib/Assets/reaction/angry/angry108202416.jpeg +0 -0
- package/.anya-md/lib/Assets/reaction/angry/angry108202417.jpeg +0 -0
- package/.anya-md/lib/Assets/reaction/angry/angry108202418.jpeg +0 -0
- package/.anya-md/lib/Assets/reaction/angry/angry108202419.jpeg +0 -0
- package/.anya-md/lib/Assets/reaction/angry/angry108202420.jpeg +0 -0
- package/.anya-md/lib/Assets/reaction/angry/angry108202421.jpeg +0 -0
- package/.anya-md/lib/Assets/reaction/angry/angry108202423.jpeg +0 -0
- package/.anya-md/lib/Assets/reaction/angry/angry108202425.jpeg +0 -0
- package/.anya-md/lib/Assets/reaction/angry/angry108202426.jpeg +0 -0
- package/.anya-md/lib/Assets/reaction/angry/angry108202427.jpeg +0 -0
- package/.anya-md/lib/Assets/reaction/angry/angry108202428.jpeg +0 -0
- package/.anya-md/lib/Assets/reaction/angry/angry108202429.jpeg +0 -0
- package/.anya-md/lib/Assets/reaction/angry/angry108202430.jpeg +0 -0
- package/.anya-md/lib/Assets/reaction/angry/angry108202431.jpeg +0 -0
- package/.anya-md/lib/Assets/reaction/angry/angry108202469.jpeg +0 -0
- package/.anya-md/lib/Assets/reaction/angry/angry10820249.jpeg +0 -0
- package/.anya-md/lib/Assets/reaction/angry/angry11.mp4 +0 -0
- package/.anya-md/lib/Assets/reaction/angry/angry12.mp4 +0 -0
- package/.anya-md/lib/Assets/reaction/angry/angry14.jpg +0 -0
- package/.anya-md/lib/Assets/reaction/angry/angry2.mp4 +0 -0
- package/.anya-md/lib/Assets/reaction/angry/angry3.mp4 +0 -0
- package/.anya-md/lib/Assets/reaction/angry/angry5.jpg +0 -0
- package/.anya-md/lib/Assets/reaction/angry/angry6.png +0 -0
- package/.anya-md/lib/Assets/reaction/angry/angry8.png +0 -0
- package/.anya-md/lib/Assets/reaction/angry/angry9.jpg +0 -0
- package/.anya-md/lib/Assets/reaction/confused/confused1.png +0 -0
- package/.anya-md/lib/Assets/reaction/confused/confused2.jpg +0 -0
- package/.anya-md/lib/Assets/reaction/confused/confused3.jpg +0 -0
- package/.anya-md/lib/Assets/reaction/confused/confused4.mp4 +0 -0
- package/.anya-md/lib/Assets/reaction/confused/confused5.jpg +0 -0
- package/.anya-md/lib/Assets/reaction/confused/confused6.webp +0 -0
- package/.anya-md/lib/Assets/reaction/confused/confused7.png +0 -0
- package/.anya-md/lib/Assets/reaction/confused/confused8.jpg +0 -0
- package/.anya-md/lib/Assets/reaction/cry/cry1.jpeg +0 -0
- package/.anya-md/lib/Assets/reaction/cry/cry12.jpeg +0 -0
- package/.anya-md/lib/Assets/reaction/cry/cry13.jpeg +0 -0
- package/.anya-md/lib/Assets/reaction/cry/cry14.jpeg +0 -0
- package/.anya-md/lib/Assets/reaction/cry/cry15.jpeg +0 -0
- package/.anya-md/lib/Assets/reaction/cry/cry16.jpeg +0 -0
- package/.anya-md/lib/Assets/reaction/cry/cry17.jpeg +0 -0
- package/.anya-md/lib/Assets/reaction/cry/cry18.jpeg +0 -0
- package/.anya-md/lib/Assets/reaction/cry/cry19.jpeg +0 -0
- package/.anya-md/lib/Assets/reaction/cry/cry22.jpeg +0 -0
- package/.anya-md/lib/Assets/reaction/cry/cry23.jpeg +0 -0
- package/.anya-md/lib/Assets/reaction/cry/cry5.jpeg +0 -0
- package/.anya-md/lib/Assets/reaction/cry/cry9.jpeg +0 -0
- package/.anya-md/lib/Assets/reaction/happy/happyrect1.jpeg +0 -0
- package/.anya-md/lib/Assets/reaction/no/_pika +1 -0
- package/.anya-md/lib/Assets/reaction/no/no1.jpg +0 -0
- package/.anya-md/lib/Assets/reaction/no/no2.png +0 -0
- package/.anya-md/lib/Assets/reaction/no/no3.jpg +0 -0
- package/.anya-md/lib/Assets/reaction/no/no4.png +0 -0
- package/.anya-md/lib/Assets/reaction/no/no5.png +0 -0
- package/.anya-md/lib/Assets/reaction/no/no6.jpg +0 -0
- package/.anya-md/lib/Assets/reaction/no/no7.jpg +0 -0
- package/.anya-md/lib/Assets/reaction/no/no8.jpg +0 -0
- package/.anya-md/lib/Assets/reaction/no/no9.mp4 +0 -0
- package/.anya-md/lib/Assets/reaction/smug/059e1bdc-e62a-4943-b85e-ea372709f6a7.jpeg +0 -0
- package/.anya-md/lib/Assets/reaction/smug/8fda90b3-bc98-4d24-ac10-4402c4e7be93.jpeg +0 -0
- package/.anya-md/lib/Assets/reaction/smug/Aqua.jpeg +0 -0
- package/.anya-md/lib/Assets/reaction/smug/Karasuma Chitose.jpeg +0 -0
- package/.anya-md/lib/Assets/reaction/smug/Smug Face - Fibel Sistine.jpeg +0 -0
- package/.anya-md/lib/Assets/reaction/smug/bf8d78ec-4fcc-4ff7-b3c3-91a0c5f22567.jpeg +0 -0
- package/.anya-md/lib/Assets/reaction/smug//330/247/330/255/331/204/330/247/331/213 /330/247/330/250/330/252/330/263/330/247/331/205/331/207 /330/264/330/261/331/212/330/261/331/207/360/237/230/255/360/237/230/255/360/237/230/255.jpeg +0 -0
- package/.anya-md/lib/Assets/verifyIMG.jpg +0 -0
- package/.anya-md/lib/Assets/welcomeGIF.mp4 +0 -0
- package/.anya-md/lib/database/categories.json +77 -0
- package/.anya-md/lib/database/cooldown.json +1 -0
- package/.anya-md/lib/database/disk/main.js +43 -0
- package/.anya-md/lib/database/emoji.js +23 -0
- package/.anya-md/lib/database/games/quiz/Questions.js +44 -0
- package/.anya-md/lib/database/games/quiz/Quiz.js +169 -0
- package/.anya-md/lib/database/games/quiz/database.json +1 -0
- package/.anya-md/lib/database/games/quiz/index.js +7 -0
- package/.anya-md/lib/database/json/.pika.js +3 -0
- package/.anya-md/lib/database/json/animeQuotes.json +51062 -0
- package/.anya-md/lib/database/json/bioQuotes.json +5744 -0
- package/.anya-md/lib/database/json/cogan.json +102 -0
- package/.anya-md/lib/database/json/countries.json +21210 -0
- package/.anya-md/lib/database/json/countries2.json +1 -0
- package/.anya-md/lib/database/json/couplepp.json +725 -0
- package/.anya-md/lib/database/json/flaming.json +7 -0
- package/.anya-md/lib/database/json/ganpati.json +102 -0
- package/.anya-md/lib/database/json/husbu.json +1967 -0
- package/.anya-md/lib/database/json/islamicWall.json +501 -0
- package/.anya-md/lib/database/json/pickupLines.json +118 -0
- package/.anya-md/lib/database/json/shreeram.json +49 -0
- package/.anya-md/lib/database/json/truthDare.json +643 -0
- package/.anya-md/lib/database/mongodb/README.md +142 -0
- package/.anya-md/lib/database/mongodb/bot.js +12 -0
- package/.anya-md/lib/database/mongodb/cmd.js +17 -0
- package/.anya-md/lib/database/mongodb/group.js +22 -0
- package/.anya-md/lib/database/mongodb/index.js +24 -0
- package/.anya-md/lib/database/mongodb/plugins.js +124 -0
- package/.anya-md/lib/database/mongodb/system.js +34 -0
- package/.anya-md/lib/database/mongodb/ui.js +15 -0
- package/.anya-md/lib/database/mongodb/user.js +17 -0
- package/.anya-md/lib/database/mongodb/warn.js +136 -0
- package/.anya-md/lib/database/sessions/.pika.js +3 -0
- package/.anya-md/lib/frameworks/index.js +5 -0
- package/.anya-md/lib/frameworks/reactionMedia.js +91 -0
- package/.anya-md/lib/lib/README.md +29 -0
- package/.anya-md/lib/lib/ai/README.md +35 -0
- package/.anya-md/lib/lib/ai/aiArt.js +47 -0
- package/.anya-md/lib/lib/ai/index.js +7 -0
- package/.anya-md/lib/lib/buttons.js +530 -0
- package/.anya-md/lib/lib/connectionMsg.js +72 -0
- package/.anya-md/lib/lib/converter.js +355 -0
- package/.anya-md/lib/lib/cooldown.js +46 -0
- package/.anya-md/lib/lib/events.js +47 -0
- package/.anya-md/lib/lib/functions.js +47 -0
- package/.anya-md/lib/lib/greeting.js +115 -0
- package/.anya-md/lib/lib/index.js +381 -0
- package/.anya-md/lib/lib/logger.js +7 -0
- package/.anya-md/lib/lib/maker/remini.js +35 -0
- package/.anya-md/lib/lib/mongoUrlFix.js +46 -0
- package/.anya-md/lib/lib/myfunc.js +47 -0
- package/.anya-md/lib/lib/plugins.js +20 -0
- package/.anya-md/lib/lib/prefix.js +47 -0
- package/.anya-md/lib/lib/scraper/README.md +35 -0
- package/.anya-md/lib/lib/scraper/SoundCloud.js +47 -0
- package/.anya-md/lib/lib/scraper/WebToons.js +47 -0
- package/.anya-md/lib/lib/scraper/android1.js +47 -0
- package/.anya-md/lib/lib/scraper/happymodSearch.js +47 -0
- package/.anya-md/lib/lib/scraper/index.js +27 -0
- package/.anya-md/lib/lib/scraper/konaChanSearch.js +47 -0
- package/.anya-md/lib/lib/scraper/pinterest.js +47 -0
- package/.anya-md/lib/lib/scraper/playstore.js +47 -0
- package/.anya-md/lib/lib/scraper/ringtone.js +47 -0
- package/.anya-md/lib/lib/scraper/steam.js +47 -0
- package/.anya-md/lib/lib/scraper/trendingTwitter.js +51 -0
- package/.anya-md/lib/lib/scraper/wattpad.js +61 -0
- package/.anya-md/lib/lib/scraper/wikipediaSearch.js +42 -0
- package/.anya-md/lib/lib/scraper.js +47 -0
- package/.anya-md/lib/lib/session.js +47 -0
- package/.anya-md/lib/lib/session2.js +47 -0
- package/.anya-md/lib/lib/similar.js +47 -0
- package/.anya-md/lib/lib/stylish-font.js +2302 -0
- package/.anya-md/lib/lib/unicode.js +877 -0
- package/.anya-md/lib/lib/upload/index.js +3 -0
- package/.anya-md/lib/lib/upload/webp2mp4File.js +56 -0
- package/.anya-md/lib/lib/ytdl-core.js +47 -0
- package/.anya-md/lib/plugins/README.md +83 -0
- package/.anya-md/lib/plugins/_menu.js +810 -0
- package/.anya-md/lib/plugins/_plugins.js +239 -0
- package/.anya-md/lib/plugins/admins.js +689 -0
- package/.anya-md/lib/plugins/ai.js +160 -0
- package/.anya-md/lib/plugins/autoreply.js +101 -0
- package/.anya-md/lib/plugins/broadcast.js +204 -0
- package/.anya-md/lib/plugins/convert.js +293 -0
- package/.anya-md/lib/plugins/core.js +941 -0
- package/.anya-md/lib/plugins/download.js +373 -0
- package/.anya-md/lib/plugins/fun.js +75 -0
- package/.anya-md/lib/plugins/games.js +33 -0
- package/.anya-md/lib/plugins/gcswitches.js +204 -0
- package/.anya-md/lib/plugins/general.js +456 -0
- package/.anya-md/lib/plugins/maker.js +41 -0
- package/.anya-md/lib/plugins/owner.js +1049 -0
- package/.anya-md/lib/plugins/religious.js +81 -0
- package/.anya-md/lib/plugins/search.js +902 -0
- package/.anya-md/lib/plugins/stalker.js +187 -0
- package/.anya-md/lib/plugins/sticker.js +125 -0
- package/.anya-md/lib/plugins/tools.js +193 -0
- package/.anya-md/lib/plugins/youtube.js +204 -0
- package/.anya-md/package.json +75 -0
- package/.anya-md/railway.json +12 -0
- package/.anya-md/render.yaml +48 -0
- package/.anya-md/replit.nix +18 -0
- package/.bash_history +500 -0
- package/.config/gh/config.yml +19 -0
- package/.config/gh/hosts.yml +11 -0
- package/.config/ngrok/ngrok.yml +3 -0
- package/.config/yarn/global/package.json +5 -0
- package/.gitconfig +772 -0
- package/.node_repl_history +0 -0
- package/.npm/_cacache/content-v2/sha512/02/b3/d1abf5af06222f7de440ab1b057deb21f9dfb0ce0a8f5064b2ba00595933bbcbbaa040b4616f951d9f8ba48d67491df1198a4831fbd8ee26eb27dde36511 +0 -0
- package/.npm/_cacache/content-v2/sha512/49/7b/0cdbb4861f7c9358a7367ca478498371b269efb8143d75de901ed1169a267f56a68e60f008952f3ebcc727dbb60bb401011af3514a1dd33cdbed8d981fa8 +0 -0
- package/.npm/_cacache/content-v2/sha512/54/3a/647bceb49b7632e6e700cb9f1b66f0f528d4ca71f4f73e76a1e7c8c50b563a2d0bb7734c18f93e6c03b7ea93167db35db0e1999ab13b08ed6b250eed2d2a +1 -0
- package/.npm/_cacache/content-v2/sha512/56/7c/4d5820233a7278225351642f7355d9889af42e7efbbfe27d6b201727efad972a59fa32063c7e1159d01dbf27ba014095ca1349ec0d0767746c39441178fa +1 -0
- package/.npm/_cacache/content-v2/sha512/89/88/d295c7e4f4d0f4621676d4c499bea2a1c72b0c31a84ff78a8bb8f83042da2bcf596e664c021d21025b296cdd4aecb57a036ea366e39466df5a129fa471df +0 -0
- package/.npm/_cacache/content-v2/sha512/8b/46/42882ebb46a975b0ce6b9cdea357190c41b51bb59a21df41c575418850b28115921e130709846d8ff9cabeae72544ec37a48ee7ccb074fe94da925250e55 +1 -0
- package/.npm/_cacache/content-v2/sha512/dd/0d/f856b793da0619d18260556498dfff13391593abb6d6a582bf052f03ba35a03a1444bf5c2d40b7515d268ec2cb3e67a17a42f09f5e668c3bb9b743e3b8a7 +1 -0
- package/.npm/_cacache/content-v2/sha512/dd/15/702501c36ce653a003d2b101034a0cb9c0fd262fa77797f1a286a161a0b2dce51ef13199e9a3fa58008bdbbf4646a33b6f1a24a2807691093cb89beefb00 +1 -0
- package/.npm/_cacache/index-v5/35/f9/e8cc076ef93c1bc40804d3fe05171053366095c922f515b1fab2b580116f +4 -0
- package/.npm/_cacache/index-v5/6a/a2/780c77f928115d4dad58a9dc4fa241de8d914abfff994e44602cc93a697c +2 -0
- package/.npm/_cacache/index-v5/71/ba/d0bb16fddeb617bbbb3713f46750d1bf5b57742abb6feb6dee4d16c68da4 +4 -0
- package/.npm/_cacache/index-v5/72/ae/c69532318093b3bd13618450ca5c26adc018a4afc0e020786207068593cf +2 -0
- package/.npm/_cacache/index-v5/7e/5e/9683ad4854f4201d7e53bf9beb2aefafa7b1efbb2c6ac7b36b78d0b218c8 +2 -0
- package/.npm/_cacache/index-v5/eb/a0/19e529094c594367a9e1aa68096a313d3dc5509d410761bf50122826a6d2 +4 -0
- package/.npm/_cacache/index-v5/f1/fa/2d2f12de549683d1275ec0f2ff15610b408fd89d1b7a755ddb7b77c00371 +2 -0
- package/.npm/_logs/2024-10-03T05_52_01_853Z-debug-0.log +52 -0
- package/.npm/_logs/2024-10-03T05_52_08_135Z-debug-0.log +52 -0
- package/.npm/_logs/2024-10-03T05_52_14_087Z-debug-0.log +52 -0
- package/.npm/_logs/2024-10-03T05_52_22_730Z-debug-0.log +52 -0
- package/.npm/_logs/2024-10-03T05_52_29_410Z-debug-0.log +52 -0
- package/.npm/_logs/2024-10-03T05_52_35_375Z-debug-0.log +52 -0
- package/.npm/_logs/2024-10-03T15_32_57_465Z-debug-0.log +20 -0
- package/.npm/_logs/2024-10-10T05_40_23_847Z-debug-0.log +254 -0
- package/.npm/_logs/2024-10-10T05_40_50_397Z-debug-0.log +73 -0
- package/.npm/_logs/2024-10-10T05_40_59_931Z-debug-0.log +52 -0
- package/.npm/_logs/2024-10-10T05_42_07_969Z-debug-0.log +52 -0
- package/.pm2/logs/anya-error.log +0 -0
- package/.pm2/logs/anya-out.log +59 -0
- package/.pm2/logs/anya-v2-error.log +2184 -0
- package/.pm2/logs/anya-v2-out.log +362 -0
- package/.pm2/module_conf.json +1 -0
- package/.pm2/pm2.log +919 -0
- package/.pm2/pm2.pid +1 -0
- package/.pm2/touch +1 -0
- package/.ssh/authorized_keys +0 -0
- package/.termux/termux.properties +180 -0
- package/.wget-hsts +5 -0
- package/package.json +2 -102
- package/LICENSE +0 -21
- package/README.md +0 -941
- package/WAProto/GenerateStatics.sh +0 -4
- package/WAProto/WAProto.proto +0 -3344
- package/WAProto/index.d.ts +0 -37016
- package/WAProto/index.js +0 -101044
- package/WASignalGroup/GroupProtocol.js +0 -1697
- package/WASignalGroup/ciphertext_message.js +0 -16
- package/WASignalGroup/group_cipher.js +0 -120
- package/WASignalGroup/group_session_builder.js +0 -46
- package/WASignalGroup/index.js +0 -5
- package/WASignalGroup/keyhelper.js +0 -21
- package/WASignalGroup/protobufs.js +0 -3
- package/WASignalGroup/queue_job.js +0 -69
- package/WASignalGroup/sender_chain_key.js +0 -50
- package/WASignalGroup/sender_key_distribution_message.js +0 -78
- package/WASignalGroup/sender_key_message.js +0 -92
- package/WASignalGroup/sender_key_name.js +0 -70
- package/WASignalGroup/sender_key_record.js +0 -56
- package/WASignalGroup/sender_key_state.js +0 -129
- package/WASignalGroup/sender_message_key.js +0 -39
- package/lib/Defaults/baileys-version.json +0 -3
- package/lib/Defaults/index.d.ts +0 -284
- package/lib/Defaults/index.js +0 -122
- package/lib/Defaults/phonenumber-mcc.json +0 -223
- package/lib/Signal/libsignal.d.ts +0 -3
- package/lib/Signal/libsignal.js +0 -152
- package/lib/Socket/Client/abstract-socket-client.d.ts +0 -17
- package/lib/Socket/Client/abstract-socket-client.js +0 -13
- package/lib/Socket/Client/index.d.ts +0 -3
- package/lib/Socket/Client/index.js +0 -19
- package/lib/Socket/Client/mobile-socket-client.d.ts +0 -13
- package/lib/Socket/Client/mobile-socket-client.js +0 -65
- package/lib/Socket/Client/web-socket-client.d.ts +0 -12
- package/lib/Socket/Client/web-socket-client.js +0 -62
- package/lib/Socket/business.d.ts +0 -177
- package/lib/Socket/business.js +0 -260
- package/lib/Socket/chats.d.ts +0 -91
- package/lib/Socket/chats.js +0 -948
- package/lib/Socket/groups.d.ts +0 -137
- package/lib/Socket/groups.js +0 -314
- package/lib/Socket/index.d.ts +0 -179
- package/lib/Socket/index.js +0 -10
- package/lib/Socket/messages-recv.d.ts +0 -164
- package/lib/Socket/messages-recv.js +0 -921
- package/lib/Socket/messages-send.d.ts +0 -157
- package/lib/Socket/messages-send.js +0 -779
- package/lib/Socket/newsletter.d.ts +0 -143
- package/lib/Socket/newsletter.js +0 -249
- package/lib/Socket/registration.d.ts +0 -271
- package/lib/Socket/registration.js +0 -166
- package/lib/Socket/socket.d.ts +0 -44
- package/lib/Socket/socket.js +0 -620
- package/lib/Store/index.d.ts +0 -3
- package/lib/Store/index.js +0 -10
- package/lib/Store/make-cache-manager-store.d.ts +0 -14
- package/lib/Store/make-cache-manager-store.js +0 -83
- package/lib/Store/make-in-memory-store.d.ts +0 -118
- package/lib/Store/make-in-memory-store.js +0 -422
- package/lib/Store/make-ordered-dictionary.d.ts +0 -13
- package/lib/Store/make-ordered-dictionary.js +0 -81
- package/lib/Store/object-repository.d.ts +0 -10
- package/lib/Store/object-repository.js +0 -27
- package/lib/Types/Auth.d.ts +0 -111
- package/lib/Types/Auth.js +0 -2
- package/lib/Types/Call.d.ts +0 -13
- package/lib/Types/Call.js +0 -2
- package/lib/Types/Chat.d.ts +0 -107
- package/lib/Types/Chat.js +0 -4
- package/lib/Types/Contact.d.ts +0 -19
- package/lib/Types/Contact.js +0 -2
- package/lib/Types/Events.d.ts +0 -199
- package/lib/Types/Events.js +0 -2
- package/lib/Types/GroupMetadata.d.ts +0 -56
- package/lib/Types/GroupMetadata.js +0 -2
- package/lib/Types/Label.d.ts +0 -46
- package/lib/Types/Label.js +0 -27
- package/lib/Types/LabelAssociation.d.ts +0 -29
- package/lib/Types/LabelAssociation.js +0 -9
- package/lib/Types/Message.d.ts +0 -278
- package/lib/Types/Message.js +0 -9
- package/lib/Types/Newsletter.d.ts +0 -79
- package/lib/Types/Newsletter.js +0 -18
- package/lib/Types/Product.d.ts +0 -78
- package/lib/Types/Product.js +0 -2
- package/lib/Types/Signal.d.ts +0 -57
- package/lib/Types/Signal.js +0 -2
- package/lib/Types/Socket.d.ts +0 -118
- package/lib/Types/Socket.js +0 -2
- package/lib/Types/State.d.ts +0 -27
- package/lib/Types/State.js +0 -2
- package/lib/Types/index.d.ts +0 -65
- package/lib/Types/index.js +0 -42
- package/lib/Utils/auth-utils.d.ts +0 -18
- package/lib/Utils/auth-utils.js +0 -206
- package/lib/Utils/baileys-event-stream.d.ts +0 -16
- package/lib/Utils/baileys-event-stream.js +0 -63
- package/lib/Utils/business.d.ts +0 -22
- package/lib/Utils/business.js +0 -234
- package/lib/Utils/chat-utils.d.ts +0 -72
- package/lib/Utils/chat-utils.js +0 -740
- package/lib/Utils/crypto.d.ts +0 -42
- package/lib/Utils/crypto.js +0 -153
- package/lib/Utils/decode-wa-message.d.ts +0 -20
- package/lib/Utils/decode-wa-message.js +0 -207
- package/lib/Utils/event-buffer.d.ts +0 -35
- package/lib/Utils/event-buffer.js +0 -520
- package/lib/Utils/generics.d.ts +0 -115
- package/lib/Utils/generics.js +0 -440
- package/lib/Utils/history.d.ts +0 -19
- package/lib/Utils/history.js +0 -94
- package/lib/Utils/index.d.ts +0 -17
- package/lib/Utils/index.js +0 -33
- package/lib/Utils/link-preview.d.ts +0 -21
- package/lib/Utils/link-preview.js +0 -93
- package/lib/Utils/logger.d.ts +0 -2
- package/lib/Utils/logger.js +0 -7
- package/lib/Utils/lt-hash.d.ts +0 -12
- package/lib/Utils/lt-hash.js +0 -51
- package/lib/Utils/make-mutex.d.ts +0 -7
- package/lib/Utils/make-mutex.js +0 -43
- package/lib/Utils/messages-media.d.ts +0 -131
- package/lib/Utils/messages-media.js +0 -793
- package/lib/Utils/messages.d.ts +0 -78
- package/lib/Utils/messages.js +0 -771
- package/lib/Utils/noise-handler.d.ts +0 -22
- package/lib/Utils/noise-handler.js +0 -155
- package/lib/Utils/process-message.d.ts +0 -42
- package/lib/Utils/process-message.js +0 -354
- package/lib/Utils/signal.d.ts +0 -32
- package/lib/Utils/signal.js +0 -156
- package/lib/Utils/use-multi-file-auth-state.d.ts +0 -12
- package/lib/Utils/use-multi-file-auth-state.js +0 -93
- package/lib/Utils/validate-connection.d.ts +0 -11
- package/lib/Utils/validate-connection.js +0 -205
- package/lib/WABinary/constants.d.ts +0 -27
- package/lib/WABinary/constants.js +0 -40
- package/lib/WABinary/decode.d.ts +0 -8
- package/lib/WABinary/decode.js +0 -254
- package/lib/WABinary/encode.d.ts +0 -2
- package/lib/WABinary/encode.js +0 -228
- package/lib/WABinary/generic-utils.d.ts +0 -16
- package/lib/WABinary/generic-utils.js +0 -110
- package/lib/WABinary/index.d.ts +0 -5
- package/lib/WABinary/index.js +0 -21
- package/lib/WABinary/jid-utils.d.ts +0 -31
- package/lib/WABinary/jid-utils.js +0 -62
- package/lib/WABinary/types.d.ts +0 -18
- package/lib/WABinary/types.js +0 -2
- package/lib/WAM/BinaryInfo.d.ts +0 -18
- package/lib/WAM/BinaryInfo.js +0 -13
- package/lib/WAM/constants.d.ts +0 -38
- package/lib/WAM/constants.js +0 -15350
- package/lib/WAM/encode.d.ts +0 -4
- package/lib/WAM/encode.js +0 -155
- package/lib/WAM/index.d.ts +0 -3
- package/lib/WAM/index.js +0 -19
- package/lib/index.d.ts +0 -11
- package/lib/index.js +0 -30
|
@@ -1,921 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.makeMessagesRecvSocket = void 0;
|
|
7
|
-
const boom_1 = require("@hapi/boom");
|
|
8
|
-
const crypto_1 = require("crypto");
|
|
9
|
-
const node_cache_1 = __importDefault(require("node-cache"));
|
|
10
|
-
const WAProto_1 = require("../../WAProto");
|
|
11
|
-
const Defaults_1 = require("../Defaults");
|
|
12
|
-
const Types_1 = require("../Types");
|
|
13
|
-
const Utils_1 = require("../Utils");
|
|
14
|
-
const Utils_2 = require("../Utils");
|
|
15
|
-
const make_mutex_1 = require("../Utils/make-mutex");
|
|
16
|
-
const WABinary_1 = require("../WABinary");
|
|
17
|
-
const groups_1 = require("./groups");
|
|
18
|
-
const messages_send_1 = require("./messages-send");
|
|
19
|
-
const makeMessagesRecvSocket = (config) => {
|
|
20
|
-
const { logger, retryRequestDelayMs, maxMsgRetryCount, ignoreMsgLoading, getMessage, shouldIgnoreJid } = config;
|
|
21
|
-
const sock = (0, messages_send_1.makeMessagesSocket)(config);
|
|
22
|
-
const { ev, authState, ws, processingMutex, signalRepository, query, upsertMessage, resyncAppState, onUnexpectedError, assertSessions, sendNode, relayMessage, sendReceipt, uploadPreKeys, sendPeerDataOperationMessage, } = sock;
|
|
23
|
-
/** this mutex ensures that each retryRequest will wait for the previous one to finish */
|
|
24
|
-
const retryMutex = (0, make_mutex_1.makeMutex)();
|
|
25
|
-
const msgRetryCache = config.msgRetryCounterCache || new node_cache_1.default({
|
|
26
|
-
stdTTL: Defaults_1.DEFAULT_CACHE_TTLS.MSG_RETRY,
|
|
27
|
-
useClones: false
|
|
28
|
-
});
|
|
29
|
-
const callOfferCache = config.callOfferCache || new node_cache_1.default({
|
|
30
|
-
stdTTL: Defaults_1.DEFAULT_CACHE_TTLS.CALL_OFFER,
|
|
31
|
-
useClones: false
|
|
32
|
-
});
|
|
33
|
-
const placeholderResendCache = config.placeholderResendCache || new node_cache_1.default({
|
|
34
|
-
stdTTL: Defaults_1.DEFAULT_CACHE_TTLS.MSG_RETRY,
|
|
35
|
-
useClones: false
|
|
36
|
-
});
|
|
37
|
-
let sendActiveReceipts = false;
|
|
38
|
-
const sendMessageAck = async ({ tag, attrs, content }) => {
|
|
39
|
-
const stanza = {
|
|
40
|
-
tag: 'ack',
|
|
41
|
-
attrs: {
|
|
42
|
-
id: attrs.id,
|
|
43
|
-
to: attrs.from,
|
|
44
|
-
class: tag,
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
if (!!attrs.participant) {
|
|
48
|
-
stanza.attrs.participant = attrs.participant;
|
|
49
|
-
}
|
|
50
|
-
if (!!attrs.recipient) {
|
|
51
|
-
stanza.attrs.recipient = attrs.recipient;
|
|
52
|
-
}
|
|
53
|
-
if (!!attrs.type && (tag !== 'message' || (0, WABinary_1.getBinaryNodeChild)({ tag, attrs, content }, 'unavailable'))) {
|
|
54
|
-
stanza.attrs.type = attrs.type;
|
|
55
|
-
}
|
|
56
|
-
if (tag === 'message' && (0, WABinary_1.getBinaryNodeChild)({ tag, attrs, content }, 'unavailable')) {
|
|
57
|
-
stanza.attrs.from = authState.creds.me.id;
|
|
58
|
-
}
|
|
59
|
-
logger.debug({ recv: { tag, attrs }, sent: stanza.attrs }, 'sent ack');
|
|
60
|
-
await sendNode(stanza);
|
|
61
|
-
};
|
|
62
|
-
const rejectCall = async (callId, callFrom) => {
|
|
63
|
-
const stanza = ({
|
|
64
|
-
tag: 'call',
|
|
65
|
-
attrs: {
|
|
66
|
-
from: authState.creds.me.id,
|
|
67
|
-
to: callFrom,
|
|
68
|
-
},
|
|
69
|
-
content: [{
|
|
70
|
-
tag: 'reject',
|
|
71
|
-
attrs: {
|
|
72
|
-
'call-id': callId,
|
|
73
|
-
'call-creator': callFrom,
|
|
74
|
-
count: '0',
|
|
75
|
-
},
|
|
76
|
-
content: undefined,
|
|
77
|
-
}],
|
|
78
|
-
});
|
|
79
|
-
await query(stanza);
|
|
80
|
-
};
|
|
81
|
-
const sendRetryRequest = async (node, forceIncludeKeys = false) => {
|
|
82
|
-
const { fullMessage } = (0, Utils_1.decodeMessageNode)(node, authState.creds.me.id, authState.creds.me.lid || '');
|
|
83
|
-
const { key: msgKey } = fullMessage;
|
|
84
|
-
const msgId = msgKey.id;
|
|
85
|
-
const key = `${msgId}:${msgKey === null || msgKey === void 0 ? void 0 : msgKey.participant}`;
|
|
86
|
-
let retryCount = msgRetryCache.get(key) || 0;
|
|
87
|
-
if (retryCount >= maxMsgRetryCount) {
|
|
88
|
-
logger.debug({ retryCount, msgId }, 'reached retry limit, clearing');
|
|
89
|
-
msgRetryCache.del(key);
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
retryCount += 1;
|
|
93
|
-
msgRetryCache.set(key, retryCount);
|
|
94
|
-
const { account, signedPreKey, signedIdentityKey: identityKey } = authState.creds;
|
|
95
|
-
if (retryCount === 1) {
|
|
96
|
-
//request a resend via phone
|
|
97
|
-
const msgId = await requestPlaceholderResend(msgKey);
|
|
98
|
-
logger.debug(`sendRetryRequest: requested placeholder resend for message ${msgId}`);
|
|
99
|
-
}
|
|
100
|
-
const deviceIdentity = (0, Utils_1.encodeSignedDeviceIdentity)(account, true);
|
|
101
|
-
await authState.keys.transaction(async () => {
|
|
102
|
-
const receipt = {
|
|
103
|
-
tag: 'receipt',
|
|
104
|
-
attrs: {
|
|
105
|
-
id: msgId,
|
|
106
|
-
type: 'retry',
|
|
107
|
-
to: node.attrs.from
|
|
108
|
-
},
|
|
109
|
-
content: [
|
|
110
|
-
{
|
|
111
|
-
tag: 'retry',
|
|
112
|
-
attrs: {
|
|
113
|
-
count: retryCount.toString(),
|
|
114
|
-
id: node.attrs.id,
|
|
115
|
-
t: node.attrs.t,
|
|
116
|
-
v: '1'
|
|
117
|
-
}
|
|
118
|
-
},
|
|
119
|
-
{
|
|
120
|
-
tag: 'registration',
|
|
121
|
-
attrs: {},
|
|
122
|
-
content: (0, Utils_1.encodeBigEndian)(authState.creds.registrationId)
|
|
123
|
-
}
|
|
124
|
-
]
|
|
125
|
-
};
|
|
126
|
-
if (node.attrs.recipient) {
|
|
127
|
-
receipt.attrs.recipient = node.attrs.recipient;
|
|
128
|
-
}
|
|
129
|
-
if (node.attrs.participant) {
|
|
130
|
-
receipt.attrs.participant = node.attrs.participant;
|
|
131
|
-
}
|
|
132
|
-
if (retryCount > 1 || forceIncludeKeys) {
|
|
133
|
-
const { update, preKeys } = await (0, Utils_1.getNextPreKeys)(authState, 1);
|
|
134
|
-
const [keyId] = Object.keys(preKeys);
|
|
135
|
-
const key = preKeys[+keyId];
|
|
136
|
-
const content = receipt.content;
|
|
137
|
-
content.push({
|
|
138
|
-
tag: 'keys',
|
|
139
|
-
attrs: {},
|
|
140
|
-
content: [
|
|
141
|
-
{ tag: 'type', attrs: {}, content: Buffer.from(Defaults_1.KEY_BUNDLE_TYPE) },
|
|
142
|
-
{ tag: 'identity', attrs: {}, content: identityKey.public },
|
|
143
|
-
(0, Utils_1.xmppPreKey)(key, +keyId),
|
|
144
|
-
(0, Utils_1.xmppSignedPreKey)(signedPreKey),
|
|
145
|
-
{ tag: 'device-identity', attrs: {}, content: deviceIdentity }
|
|
146
|
-
]
|
|
147
|
-
});
|
|
148
|
-
ev.emit('creds.update', update);
|
|
149
|
-
}
|
|
150
|
-
await sendNode(receipt);
|
|
151
|
-
logger.info({ msgAttrs: node.attrs, retryCount }, 'sent retry receipt');
|
|
152
|
-
});
|
|
153
|
-
};
|
|
154
|
-
const handleEncryptNotification = async (node) => {
|
|
155
|
-
const from = node.attrs.from;
|
|
156
|
-
if (from === WABinary_1.S_WHATSAPP_NET) {
|
|
157
|
-
const countChild = (0, WABinary_1.getBinaryNodeChild)(node, 'count');
|
|
158
|
-
const count = +countChild.attrs.value;
|
|
159
|
-
const shouldUploadMorePreKeys = count < Defaults_1.MIN_PREKEY_COUNT;
|
|
160
|
-
logger.debug({ count, shouldUploadMorePreKeys }, 'recv pre-key count');
|
|
161
|
-
if (shouldUploadMorePreKeys) {
|
|
162
|
-
await uploadPreKeys();
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
else {
|
|
166
|
-
const identityNode = (0, WABinary_1.getBinaryNodeChild)(node, 'identity');
|
|
167
|
-
if (identityNode) {
|
|
168
|
-
logger.info({ jid: from }, 'identity changed');
|
|
169
|
-
// not handling right now
|
|
170
|
-
// signal will override new identity anyway
|
|
171
|
-
}
|
|
172
|
-
else {
|
|
173
|
-
logger.info({ node }, 'unknown encrypt notification');
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
};
|
|
177
|
-
const handleGroupNotification = (participant, child, msg) => {
|
|
178
|
-
var _a, _b, _c, _d;
|
|
179
|
-
const participantJid = ((_b = (_a = (0, WABinary_1.getBinaryNodeChild)(child, 'participant')) === null || _a === void 0 ? void 0 : _a.attrs) === null || _b === void 0 ? void 0 : _b.jid) || participant;
|
|
180
|
-
switch (child === null || child === void 0 ? void 0 : child.tag) {
|
|
181
|
-
case 'create':
|
|
182
|
-
const metadata = (0, groups_1.extractGroupMetadata)(child);
|
|
183
|
-
msg.messageStubType = Types_1.WAMessageStubType.GROUP_CREATE;
|
|
184
|
-
msg.messageStubParameters = [metadata.subject];
|
|
185
|
-
msg.key = { participant: metadata.owner };
|
|
186
|
-
ev.emit('chats.upsert', [{
|
|
187
|
-
id: metadata.id,
|
|
188
|
-
name: metadata.subject,
|
|
189
|
-
conversationTimestamp: metadata.creation,
|
|
190
|
-
}]);
|
|
191
|
-
ev.emit('groups.upsert', [{
|
|
192
|
-
...metadata,
|
|
193
|
-
author: participant
|
|
194
|
-
}]);
|
|
195
|
-
break;
|
|
196
|
-
case 'ephemeral':
|
|
197
|
-
case 'not_ephemeral':
|
|
198
|
-
msg.message = {
|
|
199
|
-
protocolMessage: {
|
|
200
|
-
type: WAProto_1.proto.Message.ProtocolMessage.Type.EPHEMERAL_SETTING,
|
|
201
|
-
ephemeralExpiration: +(child.attrs.expiration || 0)
|
|
202
|
-
}
|
|
203
|
-
};
|
|
204
|
-
break;
|
|
205
|
-
case 'modify':
|
|
206
|
-
const oldNumber = (0, WABinary_1.getBinaryNodeChildren)(child, 'participant').map(p => p.attrs.jid);
|
|
207
|
-
msg.messageStubParameters = oldNumber || [];
|
|
208
|
-
msg.messageStubType = Types_1.WAMessageStubType.GROUP_PARTICIPANT_CHANGE_NUMBER;
|
|
209
|
-
break;
|
|
210
|
-
case 'promote':
|
|
211
|
-
case 'demote':
|
|
212
|
-
case 'remove':
|
|
213
|
-
case 'add':
|
|
214
|
-
case 'leave':
|
|
215
|
-
const stubType = `GROUP_PARTICIPANT_${child.tag.toUpperCase()}`;
|
|
216
|
-
msg.messageStubType = Types_1.WAMessageStubType[stubType];
|
|
217
|
-
const participants = (0, WABinary_1.getBinaryNodeChildren)(child, 'participant').map(p => p.attrs.jid);
|
|
218
|
-
if (participants.length === 1 &&
|
|
219
|
-
// if recv. "remove" message and sender removed themselves
|
|
220
|
-
// mark as left
|
|
221
|
-
(0, WABinary_1.areJidsSameUser)(participants[0], participant) &&
|
|
222
|
-
child.tag === 'remove') {
|
|
223
|
-
msg.messageStubType = Types_1.WAMessageStubType.GROUP_PARTICIPANT_LEAVE;
|
|
224
|
-
}
|
|
225
|
-
msg.messageStubParameters = participants;
|
|
226
|
-
break;
|
|
227
|
-
case 'subject':
|
|
228
|
-
msg.messageStubType = Types_1.WAMessageStubType.GROUP_CHANGE_SUBJECT;
|
|
229
|
-
msg.messageStubParameters = [child.attrs.subject];
|
|
230
|
-
break;
|
|
231
|
-
case 'description':
|
|
232
|
-
const description = (_d = (_c = (0, WABinary_1.getBinaryNodeChild)(child, 'body')) === null || _c === void 0 ? void 0 : _c.content) === null || _d === void 0 ? void 0 : _d.toString();
|
|
233
|
-
msg.messageStubType = Types_1.WAMessageStubType.GROUP_CHANGE_DESCRIPTION;
|
|
234
|
-
msg.messageStubParameters = description ? [description] : undefined;
|
|
235
|
-
break;
|
|
236
|
-
case 'announcement':
|
|
237
|
-
case 'not_announcement':
|
|
238
|
-
msg.messageStubType = Types_1.WAMessageStubType.GROUP_CHANGE_ANNOUNCE;
|
|
239
|
-
msg.messageStubParameters = [(child.tag === 'announcement') ? 'on' : 'off'];
|
|
240
|
-
break;
|
|
241
|
-
case 'locked':
|
|
242
|
-
case 'unlocked':
|
|
243
|
-
msg.messageStubType = Types_1.WAMessageStubType.GROUP_CHANGE_RESTRICT;
|
|
244
|
-
msg.messageStubParameters = [(child.tag === 'locked') ? 'on' : 'off'];
|
|
245
|
-
break;
|
|
246
|
-
case 'invite':
|
|
247
|
-
msg.messageStubType = Types_1.WAMessageStubType.GROUP_CHANGE_INVITE_LINK;
|
|
248
|
-
msg.messageStubParameters = [child.attrs.code];
|
|
249
|
-
break;
|
|
250
|
-
case 'member_add_mode':
|
|
251
|
-
const addMode = child.content;
|
|
252
|
-
if (addMode) {
|
|
253
|
-
msg.messageStubType = Types_1.WAMessageStubType.GROUP_MEMBER_ADD_MODE;
|
|
254
|
-
msg.messageStubParameters = [addMode.toString()];
|
|
255
|
-
}
|
|
256
|
-
break;
|
|
257
|
-
case 'membership_approval_mode':
|
|
258
|
-
const approvalMode = (0, WABinary_1.getBinaryNodeChild)(child, 'group_join');
|
|
259
|
-
if (approvalMode) {
|
|
260
|
-
msg.messageStubType = Types_1.WAMessageStubType.GROUP_MEMBERSHIP_JOIN_APPROVAL_MODE;
|
|
261
|
-
msg.messageStubParameters = [approvalMode.attrs.state];
|
|
262
|
-
}
|
|
263
|
-
break;
|
|
264
|
-
case 'created_membership_requests':
|
|
265
|
-
msg.messageStubType = Types_1.WAMessageStubType.GROUP_MEMBERSHIP_JOIN_APPROVAL_REQUEST_NON_ADMIN_ADD;
|
|
266
|
-
msg.messageStubParameters = [participantJid, 'created', child.attrs.request_method];
|
|
267
|
-
break;
|
|
268
|
-
case 'revoked_membership_requests':
|
|
269
|
-
const isDenied = (0, WABinary_1.areJidsSameUser)(participantJid, participant);
|
|
270
|
-
msg.messageStubType = Types_1.WAMessageStubType.GROUP_MEMBERSHIP_JOIN_APPROVAL_REQUEST_NON_ADMIN_ADD;
|
|
271
|
-
msg.messageStubParameters = [participantJid, isDenied ? 'revoked' : 'rejected'];
|
|
272
|
-
break;
|
|
273
|
-
}
|
|
274
|
-
};
|
|
275
|
-
const handleNewsletterNotification = (id, node) => {
|
|
276
|
-
const messages = (0, WABinary_1.getBinaryNodeChild)(node, 'messages');
|
|
277
|
-
const message = (0, WABinary_1.getBinaryNodeChild)(messages, 'message');
|
|
278
|
-
const server_id = message.attrs.server_id;
|
|
279
|
-
const reactionsList = (0, WABinary_1.getBinaryNodeChild)(message, 'reactions');
|
|
280
|
-
const viewsList = (0, WABinary_1.getBinaryNodeChildren)(message, 'views_count');
|
|
281
|
-
if (reactionsList) {
|
|
282
|
-
const reactions = (0, WABinary_1.getBinaryNodeChildren)(reactionsList, 'reaction');
|
|
283
|
-
if (reactions.length === 0) {
|
|
284
|
-
ev.emit('newsletter.reaction', { id, server_id, reaction: { removed: true } });
|
|
285
|
-
}
|
|
286
|
-
reactions.forEach(item => {
|
|
287
|
-
var _a, _b;
|
|
288
|
-
ev.emit('newsletter.reaction', { id, server_id, reaction: { code: (_a = item.attrs) === null || _a === void 0 ? void 0 : _a.code, count: +((_b = item.attrs) === null || _b === void 0 ? void 0 : _b.count) } });
|
|
289
|
-
});
|
|
290
|
-
}
|
|
291
|
-
if (viewsList.length) {
|
|
292
|
-
viewsList.forEach(item => {
|
|
293
|
-
ev.emit('newsletter.view', { id, server_id, count: +item.attrs.count });
|
|
294
|
-
});
|
|
295
|
-
}
|
|
296
|
-
};
|
|
297
|
-
const handleMexNewsletterNotification = (id, node) => {
|
|
298
|
-
var _a;
|
|
299
|
-
const operation = node === null || node === void 0 ? void 0 : node.attrs.op_name;
|
|
300
|
-
const content = JSON.parse((_a = node === null || node === void 0 ? void 0 : node.content) === null || _a === void 0 ? void 0 : _a.toString());
|
|
301
|
-
let contentPath;
|
|
302
|
-
if (operation === Types_1.MexOperations.PROMOTE || operation === Types_1.MexOperations.DEMOTE) {
|
|
303
|
-
let action;
|
|
304
|
-
if (operation === Types_1.MexOperations.PROMOTE) {
|
|
305
|
-
action = 'promote';
|
|
306
|
-
contentPath = content.data[Types_1.XWAPaths.PROMOTE];
|
|
307
|
-
}
|
|
308
|
-
if (operation === Types_1.MexOperations.DEMOTE) {
|
|
309
|
-
action = 'demote';
|
|
310
|
-
contentPath = content.data[Types_1.XWAPaths.DEMOTE];
|
|
311
|
-
}
|
|
312
|
-
ev.emit('newsletter-participants.update', { id, author: contentPath.actor.pn, user: contentPath.user.pn, new_role: contentPath.user_new_role, action });
|
|
313
|
-
}
|
|
314
|
-
if (operation === Types_1.MexOperations.UPDATE) {
|
|
315
|
-
contentPath = content.data[Types_1.XWAPaths.METADATA_UPDATE];
|
|
316
|
-
ev.emit('newsletter-settings.update', { id, update: contentPath.thread_metadata.settings });
|
|
317
|
-
}
|
|
318
|
-
};
|
|
319
|
-
const processNotification = async (node) => {
|
|
320
|
-
var _a, _b, _c;
|
|
321
|
-
const result = {};
|
|
322
|
-
const [child] = (0, WABinary_1.getAllBinaryNodeChildren)(node);
|
|
323
|
-
const nodeType = node.attrs.type;
|
|
324
|
-
const from = (0, WABinary_1.jidNormalizedUser)(node.attrs.from);
|
|
325
|
-
switch (nodeType) {
|
|
326
|
-
case 'privacy_token':
|
|
327
|
-
const tokenList = (0, WABinary_1.getBinaryNodeChildren)(child, 'token');
|
|
328
|
-
for (const { attrs, content } of tokenList) {
|
|
329
|
-
const jid = attrs.jid;
|
|
330
|
-
ev.emit('chats.update', [
|
|
331
|
-
{
|
|
332
|
-
id: jid,
|
|
333
|
-
tcToken: content
|
|
334
|
-
}
|
|
335
|
-
]);
|
|
336
|
-
logger.debug({ jid }, 'got privacy token update');
|
|
337
|
-
}
|
|
338
|
-
break;
|
|
339
|
-
case 'newsletter':
|
|
340
|
-
handleNewsletterNotification(node.attrs.from, child);
|
|
341
|
-
break;
|
|
342
|
-
case 'mex':
|
|
343
|
-
handleMexNewsletterNotification(node.attrs.from, child);
|
|
344
|
-
break;
|
|
345
|
-
case 'w:gp2':
|
|
346
|
-
handleGroupNotification(node.attrs.participant, child, result);
|
|
347
|
-
break;
|
|
348
|
-
case 'mediaretry':
|
|
349
|
-
const event = (0, Utils_1.decodeMediaRetryNode)(node);
|
|
350
|
-
ev.emit('messages.media-update', [event]);
|
|
351
|
-
break;
|
|
352
|
-
case 'encrypt':
|
|
353
|
-
await handleEncryptNotification(node);
|
|
354
|
-
break;
|
|
355
|
-
case 'newsletter':
|
|
356
|
-
// TO DO
|
|
357
|
-
break;
|
|
358
|
-
case 'devices':
|
|
359
|
-
const devices = (0, WABinary_1.getBinaryNodeChildren)(child, 'device');
|
|
360
|
-
if ((0, WABinary_1.areJidsSameUser)(child.attrs.jid, authState.creds.me.id)) {
|
|
361
|
-
const deviceJids = devices.map(d => d.attrs.jid);
|
|
362
|
-
logger.info({ deviceJids }, 'got my own devices');
|
|
363
|
-
}
|
|
364
|
-
break;
|
|
365
|
-
case 'server_sync':
|
|
366
|
-
const update = (0, WABinary_1.getBinaryNodeChild)(node, 'collection');
|
|
367
|
-
if (update) {
|
|
368
|
-
const name = update.attrs.name;
|
|
369
|
-
await resyncAppState([name], false);
|
|
370
|
-
}
|
|
371
|
-
break;
|
|
372
|
-
case 'picture':
|
|
373
|
-
const setPicture = (0, WABinary_1.getBinaryNodeChild)(node, 'set');
|
|
374
|
-
const delPicture = (0, WABinary_1.getBinaryNodeChild)(node, 'delete');
|
|
375
|
-
ev.emit('contacts.update', [{
|
|
376
|
-
id: (0, WABinary_1.jidNormalizedUser)((_a = node === null || node === void 0 ? void 0 : node.attrs) === null || _a === void 0 ? void 0 : _a.from) || ((_c = (_b = (setPicture || delPicture)) === null || _b === void 0 ? void 0 : _b.attrs) === null || _c === void 0 ? void 0 : _c.hash) || '',
|
|
377
|
-
imgUrl: setPicture ? 'changed' : 'removed'
|
|
378
|
-
}]);
|
|
379
|
-
if ((0, WABinary_1.isJidGroup)(from)) {
|
|
380
|
-
const node = setPicture || delPicture;
|
|
381
|
-
result.messageStubType = Types_1.WAMessageStubType.GROUP_CHANGE_ICON;
|
|
382
|
-
if (setPicture) {
|
|
383
|
-
result.messageStubParameters = [setPicture.attrs.id];
|
|
384
|
-
}
|
|
385
|
-
result.participant = node === null || node === void 0 ? void 0 : node.attrs.author;
|
|
386
|
-
result.key = {
|
|
387
|
-
...result.key || {},
|
|
388
|
-
participant: setPicture === null || setPicture === void 0 ? void 0 : setPicture.attrs.author
|
|
389
|
-
};
|
|
390
|
-
}
|
|
391
|
-
break;
|
|
392
|
-
case 'account_sync':
|
|
393
|
-
if (child.tag === 'disappearing_mode') {
|
|
394
|
-
const newDuration = +child.attrs.duration;
|
|
395
|
-
const timestamp = +child.attrs.t;
|
|
396
|
-
logger.info({ newDuration }, 'updated account disappearing mode');
|
|
397
|
-
ev.emit('creds.update', {
|
|
398
|
-
accountSettings: {
|
|
399
|
-
...authState.creds.accountSettings,
|
|
400
|
-
defaultDisappearingMode: {
|
|
401
|
-
ephemeralExpiration: newDuration,
|
|
402
|
-
ephemeralSettingTimestamp: timestamp,
|
|
403
|
-
},
|
|
404
|
-
}
|
|
405
|
-
});
|
|
406
|
-
}
|
|
407
|
-
else if (child.tag === 'blocklist') {
|
|
408
|
-
const blocklists = (0, WABinary_1.getBinaryNodeChildren)(child, 'item');
|
|
409
|
-
for (const { attrs } of blocklists) {
|
|
410
|
-
const blocklist = [attrs.jid];
|
|
411
|
-
const type = (attrs.action === 'block') ? 'add' : 'remove';
|
|
412
|
-
ev.emit('blocklist.update', { blocklist, type });
|
|
413
|
-
}
|
|
414
|
-
}
|
|
415
|
-
break;
|
|
416
|
-
case 'link_code_companion_reg':
|
|
417
|
-
const linkCodeCompanionReg = (0, WABinary_1.getBinaryNodeChild)(node, 'link_code_companion_reg');
|
|
418
|
-
const ref = toRequiredBuffer((0, WABinary_1.getBinaryNodeChildBuffer)(linkCodeCompanionReg, 'link_code_pairing_ref'));
|
|
419
|
-
const primaryIdentityPublicKey = toRequiredBuffer((0, WABinary_1.getBinaryNodeChildBuffer)(linkCodeCompanionReg, 'primary_identity_pub'));
|
|
420
|
-
const primaryEphemeralPublicKeyWrapped = toRequiredBuffer((0, WABinary_1.getBinaryNodeChildBuffer)(linkCodeCompanionReg, 'link_code_pairing_wrapped_primary_ephemeral_pub'));
|
|
421
|
-
const codePairingPublicKey = await decipherLinkPublicKey(primaryEphemeralPublicKeyWrapped);
|
|
422
|
-
const companionSharedKey = Utils_1.Curve.sharedKey(authState.creds.pairingEphemeralKeyPair.private, codePairingPublicKey);
|
|
423
|
-
const random = (0, crypto_1.randomBytes)(32);
|
|
424
|
-
const linkCodeSalt = (0, crypto_1.randomBytes)(32);
|
|
425
|
-
const linkCodePairingExpanded = (0, Utils_1.hkdf)(companionSharedKey, 32, {
|
|
426
|
-
salt: linkCodeSalt,
|
|
427
|
-
info: 'link_code_pairing_key_bundle_encryption_key'
|
|
428
|
-
});
|
|
429
|
-
const encryptPayload = Buffer.concat([Buffer.from(authState.creds.signedIdentityKey.public), primaryIdentityPublicKey, random]);
|
|
430
|
-
const encryptIv = (0, crypto_1.randomBytes)(12);
|
|
431
|
-
const encrypted = (0, Utils_1.aesEncryptGCM)(encryptPayload, linkCodePairingExpanded, encryptIv, Buffer.alloc(0));
|
|
432
|
-
const encryptedPayload = Buffer.concat([linkCodeSalt, encryptIv, encrypted]);
|
|
433
|
-
const identitySharedKey = Utils_1.Curve.sharedKey(authState.creds.signedIdentityKey.private, primaryIdentityPublicKey);
|
|
434
|
-
const identityPayload = Buffer.concat([companionSharedKey, identitySharedKey, random]);
|
|
435
|
-
authState.creds.advSecretKey = (0, Utils_1.hkdf)(identityPayload, 32, { info: 'adv_secret' }).toString('base64');
|
|
436
|
-
await query({
|
|
437
|
-
tag: 'iq',
|
|
438
|
-
attrs: {
|
|
439
|
-
to: WABinary_1.S_WHATSAPP_NET,
|
|
440
|
-
type: 'set',
|
|
441
|
-
id: sock.generateMessageTag(),
|
|
442
|
-
xmlns: 'md'
|
|
443
|
-
},
|
|
444
|
-
content: [
|
|
445
|
-
{
|
|
446
|
-
tag: 'link_code_companion_reg',
|
|
447
|
-
attrs: {
|
|
448
|
-
jid: authState.creds.me.id,
|
|
449
|
-
stage: 'companion_finish',
|
|
450
|
-
},
|
|
451
|
-
content: [
|
|
452
|
-
{
|
|
453
|
-
tag: 'link_code_pairing_wrapped_key_bundle',
|
|
454
|
-
attrs: {},
|
|
455
|
-
content: encryptedPayload
|
|
456
|
-
},
|
|
457
|
-
{
|
|
458
|
-
tag: 'companion_identity_public',
|
|
459
|
-
attrs: {},
|
|
460
|
-
content: authState.creds.signedIdentityKey.public
|
|
461
|
-
},
|
|
462
|
-
{
|
|
463
|
-
tag: 'link_code_pairing_ref',
|
|
464
|
-
attrs: {},
|
|
465
|
-
content: ref
|
|
466
|
-
}
|
|
467
|
-
]
|
|
468
|
-
}
|
|
469
|
-
]
|
|
470
|
-
});
|
|
471
|
-
authState.creds.registered = true;
|
|
472
|
-
ev.emit('creds.update', authState.creds);
|
|
473
|
-
}
|
|
474
|
-
if (Object.keys(result).length) {
|
|
475
|
-
return result;
|
|
476
|
-
}
|
|
477
|
-
};
|
|
478
|
-
async function decipherLinkPublicKey(data) {
|
|
479
|
-
const buffer = toRequiredBuffer(data);
|
|
480
|
-
const salt = buffer.slice(0, 32);
|
|
481
|
-
const secretKey = await (0, Utils_1.derivePairingCodeKey)(authState.creds.pairingCode, salt);
|
|
482
|
-
const iv = buffer.slice(32, 48);
|
|
483
|
-
const payload = buffer.slice(48, 80);
|
|
484
|
-
return (0, Utils_1.aesDecryptCTR)(payload, secretKey, iv);
|
|
485
|
-
}
|
|
486
|
-
function toRequiredBuffer(data) {
|
|
487
|
-
if (data === undefined) {
|
|
488
|
-
throw new boom_1.Boom('Invalid buffer', { statusCode: 400 });
|
|
489
|
-
}
|
|
490
|
-
return data instanceof Buffer ? data : Buffer.from(data);
|
|
491
|
-
}
|
|
492
|
-
const willSendMessageAgain = (id, participant) => {
|
|
493
|
-
const key = `${id}:${participant}`;
|
|
494
|
-
const retryCount = msgRetryCache.get(key) || 0;
|
|
495
|
-
return retryCount < maxMsgRetryCount;
|
|
496
|
-
};
|
|
497
|
-
const updateSendMessageAgainCount = (id, participant) => {
|
|
498
|
-
const key = `${id}:${participant}`;
|
|
499
|
-
const newValue = (msgRetryCache.get(key) || 0) + 1;
|
|
500
|
-
msgRetryCache.set(key, newValue);
|
|
501
|
-
};
|
|
502
|
-
const sendMessagesAgain = async (key, ids, retryNode) => {
|
|
503
|
-
var _a;
|
|
504
|
-
const msgs = await Promise.all(ids.map(id => getMessage({ ...key, id })));
|
|
505
|
-
const remoteJid = key.remoteJid;
|
|
506
|
-
const participant = key.participant || remoteJid;
|
|
507
|
-
// if it's the primary jid sending the request
|
|
508
|
-
// just re-send the message to everyone
|
|
509
|
-
// prevents the first message decryption failure
|
|
510
|
-
const sendToAll = !((_a = (0, WABinary_1.jidDecode)(participant)) === null || _a === void 0 ? void 0 : _a.device);
|
|
511
|
-
await assertSessions([participant], true);
|
|
512
|
-
if ((0, WABinary_1.isJidGroup)(remoteJid)) {
|
|
513
|
-
await authState.keys.set({ 'sender-key-memory': { [remoteJid]: null } });
|
|
514
|
-
}
|
|
515
|
-
logger.debug({ participant, sendToAll }, 'forced new session for retry recp');
|
|
516
|
-
for (let i = 0; i < msgs.length; i++) {
|
|
517
|
-
const msg = msgs[i];
|
|
518
|
-
if (msg) {
|
|
519
|
-
updateSendMessageAgainCount(ids[i], participant);
|
|
520
|
-
const msgRelayOpts = { messageId: ids[i] };
|
|
521
|
-
if (sendToAll) {
|
|
522
|
-
msgRelayOpts.useUserDevicesCache = false;
|
|
523
|
-
}
|
|
524
|
-
else {
|
|
525
|
-
msgRelayOpts.participant = {
|
|
526
|
-
jid: participant,
|
|
527
|
-
count: +retryNode.attrs.count
|
|
528
|
-
};
|
|
529
|
-
}
|
|
530
|
-
await relayMessage(key.remoteJid, msg, msgRelayOpts);
|
|
531
|
-
}
|
|
532
|
-
else {
|
|
533
|
-
logger.debug({ jid: key.remoteJid, id: ids[i] }, 'recv retry request, but message not available');
|
|
534
|
-
}
|
|
535
|
-
}
|
|
536
|
-
};
|
|
537
|
-
const handleReceipt = async (node) => {
|
|
538
|
-
var _a, _b;
|
|
539
|
-
const { attrs, content } = node;
|
|
540
|
-
const isLid = attrs.from.includes('lid');
|
|
541
|
-
const isNodeFromMe = (0, WABinary_1.areJidsSameUser)(attrs.participant || attrs.from, isLid ? (_a = authState.creds.me) === null || _a === void 0 ? void 0 : _a.lid : (_b = authState.creds.me) === null || _b === void 0 ? void 0 : _b.id);
|
|
542
|
-
const remoteJid = !isNodeFromMe || (0, WABinary_1.isJidGroup)(attrs.from) ? attrs.from : attrs.recipient;
|
|
543
|
-
const fromMe = !attrs.recipient || (attrs.type === 'retry' && isNodeFromMe);
|
|
544
|
-
const key = {
|
|
545
|
-
remoteJid,
|
|
546
|
-
id: '',
|
|
547
|
-
fromMe,
|
|
548
|
-
participant: attrs.participant
|
|
549
|
-
};
|
|
550
|
-
if (shouldIgnoreJid(remoteJid) && remoteJid !== '@s.whatsapp.net') {
|
|
551
|
-
logger.debug({ remoteJid }, 'ignoring receipt from jid');
|
|
552
|
-
await sendMessageAck(node);
|
|
553
|
-
return;
|
|
554
|
-
}
|
|
555
|
-
const ids = [attrs.id];
|
|
556
|
-
if (Array.isArray(content)) {
|
|
557
|
-
const items = (0, WABinary_1.getBinaryNodeChildren)(content[0], 'item');
|
|
558
|
-
ids.push(...items.map(i => i.attrs.id));
|
|
559
|
-
}
|
|
560
|
-
try {
|
|
561
|
-
await Promise.all([
|
|
562
|
-
processingMutex.mutex(async () => {
|
|
563
|
-
const status = (0, Utils_1.getStatusFromReceiptType)(attrs.type);
|
|
564
|
-
if (typeof status !== 'undefined' &&
|
|
565
|
-
(
|
|
566
|
-
// basically, we only want to know when a message from us has been delivered to/read by the other person
|
|
567
|
-
// or another device of ours has read some messages
|
|
568
|
-
status > WAProto_1.proto.WebMessageInfo.Status.DELIVERY_ACK ||
|
|
569
|
-
!isNodeFromMe)) {
|
|
570
|
-
if ((0, WABinary_1.isJidGroup)(remoteJid) || (0, WABinary_1.isJidStatusBroadcast)(remoteJid)) {
|
|
571
|
-
if (attrs.participant) {
|
|
572
|
-
const updateKey = status === WAProto_1.proto.WebMessageInfo.Status.DELIVERY_ACK ? 'receiptTimestamp' : 'readTimestamp';
|
|
573
|
-
ev.emit('message-receipt.update', ids.map(id => ({
|
|
574
|
-
key: { ...key, id },
|
|
575
|
-
receipt: {
|
|
576
|
-
userJid: (0, WABinary_1.jidNormalizedUser)(attrs.participant),
|
|
577
|
-
[updateKey]: +attrs.t
|
|
578
|
-
}
|
|
579
|
-
})));
|
|
580
|
-
}
|
|
581
|
-
}
|
|
582
|
-
else {
|
|
583
|
-
ev.emit('messages.update', ids.map(id => ({
|
|
584
|
-
key: { ...key, id },
|
|
585
|
-
update: { status }
|
|
586
|
-
})));
|
|
587
|
-
}
|
|
588
|
-
}
|
|
589
|
-
if (attrs.type === 'retry') {
|
|
590
|
-
// correctly set who is asking for the retry
|
|
591
|
-
key.participant = key.participant || attrs.from;
|
|
592
|
-
const retryNode = (0, WABinary_1.getBinaryNodeChild)(node, 'retry');
|
|
593
|
-
if (willSendMessageAgain(ids[0], key.participant)) {
|
|
594
|
-
if (key.fromMe) {
|
|
595
|
-
try {
|
|
596
|
-
logger.debug({ attrs, key }, 'recv retry request');
|
|
597
|
-
await sendMessagesAgain(key, ids, retryNode);
|
|
598
|
-
}
|
|
599
|
-
catch (error) {
|
|
600
|
-
logger.error({ key, ids, trace: error.stack }, 'error in sending message again');
|
|
601
|
-
}
|
|
602
|
-
}
|
|
603
|
-
else {
|
|
604
|
-
logger.info({ attrs, key }, 'recv retry for not fromMe message');
|
|
605
|
-
}
|
|
606
|
-
}
|
|
607
|
-
else {
|
|
608
|
-
logger.info({ attrs, key }, 'will not send message again, as sent too many times');
|
|
609
|
-
}
|
|
610
|
-
}
|
|
611
|
-
})
|
|
612
|
-
]);
|
|
613
|
-
}
|
|
614
|
-
finally {
|
|
615
|
-
await sendMessageAck(node);
|
|
616
|
-
}
|
|
617
|
-
};
|
|
618
|
-
const handleNotification = async (node) => {
|
|
619
|
-
const remoteJid = node.attrs.from;
|
|
620
|
-
if (shouldIgnoreJid(remoteJid) && remoteJid !== '@s.whatsapp.net') {
|
|
621
|
-
logger.debug({ remoteJid, id: node.attrs.id }, 'ignored notification');
|
|
622
|
-
await sendMessageAck(node);
|
|
623
|
-
return;
|
|
624
|
-
}
|
|
625
|
-
try {
|
|
626
|
-
await Promise.all([
|
|
627
|
-
processingMutex.mutex(async () => {
|
|
628
|
-
var _a;
|
|
629
|
-
const msg = await processNotification(node);
|
|
630
|
-
if (msg) {
|
|
631
|
-
const fromMe = (0, WABinary_1.areJidsSameUser)(node.attrs.participant || remoteJid, authState.creds.me.id);
|
|
632
|
-
msg.key = {
|
|
633
|
-
remoteJid,
|
|
634
|
-
fromMe,
|
|
635
|
-
participant: node.attrs.participant,
|
|
636
|
-
id: node.attrs.id,
|
|
637
|
-
...(msg.key || {})
|
|
638
|
-
};
|
|
639
|
-
(_a = msg.participant) !== null && _a !== void 0 ? _a : (msg.participant = node.attrs.participant);
|
|
640
|
-
msg.messageTimestamp = +node.attrs.t;
|
|
641
|
-
const fullMsg = WAProto_1.proto.WebMessageInfo.fromObject(msg);
|
|
642
|
-
await upsertMessage(fullMsg, 'append');
|
|
643
|
-
}
|
|
644
|
-
})
|
|
645
|
-
]);
|
|
646
|
-
}
|
|
647
|
-
finally {
|
|
648
|
-
await sendMessageAck(node);
|
|
649
|
-
}
|
|
650
|
-
};
|
|
651
|
-
const handleMessage = async (node) => {
|
|
652
|
-
var _a, _b, _c;
|
|
653
|
-
if (shouldIgnoreJid(node.attrs.from) && node.attrs.from !== '@s.whatsapp.net') {
|
|
654
|
-
logger.debug({ key: node.attrs.key }, 'ignored message');
|
|
655
|
-
await sendMessageAck(node);
|
|
656
|
-
return;
|
|
657
|
-
}
|
|
658
|
-
let response;
|
|
659
|
-
if ((0, WABinary_1.getBinaryNodeChild)(node, 'unavailable') && !(0, WABinary_1.getBinaryNodeChild)(node, 'enc')) {
|
|
660
|
-
await sendMessageAck(node);
|
|
661
|
-
const { key } = (0, Utils_1.decodeMessageNode)(node, authState.creds.me.id, authState.creds.me.lid || '').fullMessage;
|
|
662
|
-
response = await requestPlaceholderResend(key);
|
|
663
|
-
if (response === 'RESOLVED') {
|
|
664
|
-
return;
|
|
665
|
-
}
|
|
666
|
-
logger.debug('received unavailable message, acked and requested resend from phone');
|
|
667
|
-
}
|
|
668
|
-
else {
|
|
669
|
-
if (placeholderResendCache.get(node.attrs.id)) {
|
|
670
|
-
placeholderResendCache.del(node.attrs.id);
|
|
671
|
-
}
|
|
672
|
-
}
|
|
673
|
-
const { fullMessage: msg, category, author, decrypt } = (0, Utils_1.decryptMessageNode)(node, authState.creds.me.id, authState.creds.me.lid || '', signalRepository, logger);
|
|
674
|
-
if (response && ((_a = msg === null || msg === void 0 ? void 0 : msg.messageStubParameters) === null || _a === void 0 ? void 0 : _a[0]) === Utils_1.NO_MESSAGE_FOUND_ERROR_TEXT) {
|
|
675
|
-
msg.messageStubParameters = [Utils_1.NO_MESSAGE_FOUND_ERROR_TEXT, response];
|
|
676
|
-
}
|
|
677
|
-
if (((_c = (_b = msg.message) === null || _b === void 0 ? void 0 : _b.protocolMessage) === null || _c === void 0 ? void 0 : _c.type) === WAProto_1.proto.Message.ProtocolMessage.Type.SHARE_PHONE_NUMBER) {
|
|
678
|
-
if (node.attrs.sender_pn) {
|
|
679
|
-
ev.emit('chats.phoneNumberShare', { lid: node.attrs.from, jid: node.attrs.sender_pn });
|
|
680
|
-
}
|
|
681
|
-
}
|
|
682
|
-
try {
|
|
683
|
-
await Promise.all([
|
|
684
|
-
processingMutex.mutex(async () => {
|
|
685
|
-
await decrypt();
|
|
686
|
-
// message failed to decrypt
|
|
687
|
-
if (msg.messageStubType === WAProto_1.proto.WebMessageInfo.StubType.CIPHERTEXT) {
|
|
688
|
-
retryMutex.mutex(async () => {
|
|
689
|
-
if (ws.isOpen) {
|
|
690
|
-
if ((0, WABinary_1.getBinaryNodeChild)(node, 'unavailable')) {
|
|
691
|
-
return;
|
|
692
|
-
}
|
|
693
|
-
const encNode = (0, WABinary_1.getBinaryNodeChild)(node, 'enc');
|
|
694
|
-
await sendRetryRequest(node, !encNode);
|
|
695
|
-
if (retryRequestDelayMs) {
|
|
696
|
-
await (0, Utils_1.delay)(retryRequestDelayMs);
|
|
697
|
-
}
|
|
698
|
-
}
|
|
699
|
-
else {
|
|
700
|
-
logger.debug({ node }, 'connection closed, ignoring retry req');
|
|
701
|
-
}
|
|
702
|
-
});
|
|
703
|
-
}
|
|
704
|
-
else {
|
|
705
|
-
// no type in the receipt => message delivered
|
|
706
|
-
let type = undefined;
|
|
707
|
-
let participant = msg.key.participant;
|
|
708
|
-
if (category === 'peer') { // special peer message
|
|
709
|
-
type = 'peer_msg';
|
|
710
|
-
}
|
|
711
|
-
else if (msg.key.fromMe) { // message was sent by us from a different device
|
|
712
|
-
type = 'sender';
|
|
713
|
-
// need to specially handle this case
|
|
714
|
-
if ((0, WABinary_1.isJidUser)(msg.key.remoteJid)) {
|
|
715
|
-
participant = author;
|
|
716
|
-
}
|
|
717
|
-
}
|
|
718
|
-
else if (!sendActiveReceipts) {
|
|
719
|
-
type = 'inactive';
|
|
720
|
-
}
|
|
721
|
-
await sendReceipt(msg.key.remoteJid, participant, [msg.key.id], type);
|
|
722
|
-
// send ack for history message
|
|
723
|
-
const isAnyHistoryMsg = (0, Utils_1.getHistoryMsg)(msg.message);
|
|
724
|
-
if (isAnyHistoryMsg) {
|
|
725
|
-
const jid = (0, WABinary_1.jidNormalizedUser)(msg.key.remoteJid);
|
|
726
|
-
await sendReceipt(jid, undefined, [msg.key.id], 'hist_sync');
|
|
727
|
-
}
|
|
728
|
-
}
|
|
729
|
-
(0, Utils_2.cleanMessage)(msg, authState.creds.me.id);
|
|
730
|
-
await upsertMessage(msg, node.attrs.offline ? 'append' : 'notify');
|
|
731
|
-
})
|
|
732
|
-
]);
|
|
733
|
-
}
|
|
734
|
-
finally {
|
|
735
|
-
await sendMessageAck(node);
|
|
736
|
-
}
|
|
737
|
-
};
|
|
738
|
-
const fetchMessageHistory = async (count, oldestMsgKey, oldestMsgTimestamp) => {
|
|
739
|
-
var _a;
|
|
740
|
-
if (!((_a = authState.creds.me) === null || _a === void 0 ? void 0 : _a.id)) {
|
|
741
|
-
throw new boom_1.Boom('Not authenticated');
|
|
742
|
-
}
|
|
743
|
-
const pdoMessage = {
|
|
744
|
-
historySyncOnDemandRequest: {
|
|
745
|
-
chatJid: oldestMsgKey.remoteJid,
|
|
746
|
-
oldestMsgFromMe: oldestMsgKey.fromMe,
|
|
747
|
-
oldestMsgId: oldestMsgKey.id,
|
|
748
|
-
oldestMsgTimestampMs: oldestMsgTimestamp,
|
|
749
|
-
onDemandMsgCount: count
|
|
750
|
-
},
|
|
751
|
-
peerDataOperationRequestType: WAProto_1.proto.Message.PeerDataOperationRequestType.HISTORY_SYNC_ON_DEMAND
|
|
752
|
-
};
|
|
753
|
-
return sendPeerDataOperationMessage(pdoMessage);
|
|
754
|
-
};
|
|
755
|
-
const requestPlaceholderResend = async (messageKey) => {
|
|
756
|
-
var _a;
|
|
757
|
-
if (!((_a = authState.creds.me) === null || _a === void 0 ? void 0 : _a.id)) {
|
|
758
|
-
throw new boom_1.Boom('Not authenticated');
|
|
759
|
-
}
|
|
760
|
-
if (placeholderResendCache.get(messageKey === null || messageKey === void 0 ? void 0 : messageKey.id)) {
|
|
761
|
-
logger.debug('already requested resend', { messageKey });
|
|
762
|
-
return;
|
|
763
|
-
}
|
|
764
|
-
else {
|
|
765
|
-
placeholderResendCache.set(messageKey === null || messageKey === void 0 ? void 0 : messageKey.id, true);
|
|
766
|
-
}
|
|
767
|
-
await (0, Utils_1.delay)(5000);
|
|
768
|
-
if (!placeholderResendCache.get(messageKey === null || messageKey === void 0 ? void 0 : messageKey.id)) {
|
|
769
|
-
logger.debug('message received while resend requested', { messageKey });
|
|
770
|
-
return 'RESOLVED';
|
|
771
|
-
}
|
|
772
|
-
const pdoMessage = {
|
|
773
|
-
placeholderMessageResendRequest: [{
|
|
774
|
-
messageKey
|
|
775
|
-
}],
|
|
776
|
-
peerDataOperationRequestType: WAProto_1.proto.Message.PeerDataOperationRequestType.PLACEHOLDER_MESSAGE_RESEND
|
|
777
|
-
};
|
|
778
|
-
setTimeout(() => {
|
|
779
|
-
if (placeholderResendCache.get(messageKey === null || messageKey === void 0 ? void 0 : messageKey.id)) {
|
|
780
|
-
logger.debug('PDO message without response after 15 seconds. Phone possibly offline', { messageKey });
|
|
781
|
-
placeholderResendCache.del(messageKey === null || messageKey === void 0 ? void 0 : messageKey.id);
|
|
782
|
-
}
|
|
783
|
-
}, 15000);
|
|
784
|
-
return sendPeerDataOperationMessage(pdoMessage);
|
|
785
|
-
};
|
|
786
|
-
const handleCall = async (node) => {
|
|
787
|
-
const { attrs } = node;
|
|
788
|
-
const [infoChild] = (0, WABinary_1.getAllBinaryNodeChildren)(node);
|
|
789
|
-
const callId = infoChild.attrs['call-id'];
|
|
790
|
-
const from = infoChild.attrs.from || infoChild.attrs['call-creator'];
|
|
791
|
-
const status = (0, Utils_1.getCallStatusFromNode)(infoChild);
|
|
792
|
-
const call = {
|
|
793
|
-
chatId: attrs.from,
|
|
794
|
-
from,
|
|
795
|
-
id: callId,
|
|
796
|
-
date: new Date(+attrs.t * 1000),
|
|
797
|
-
offline: !!attrs.offline,
|
|
798
|
-
status,
|
|
799
|
-
};
|
|
800
|
-
if (status === 'offer') {
|
|
801
|
-
call.isVideo = !!(0, WABinary_1.getBinaryNodeChild)(infoChild, 'video');
|
|
802
|
-
call.isGroup = infoChild.attrs.type === 'group' || !!infoChild.attrs['group-jid'];
|
|
803
|
-
call.groupJid = infoChild.attrs['group-jid'];
|
|
804
|
-
callOfferCache.set(call.id, call);
|
|
805
|
-
}
|
|
806
|
-
const existingCall = callOfferCache.get(call.id);
|
|
807
|
-
// use existing call info to populate this event
|
|
808
|
-
if (existingCall) {
|
|
809
|
-
call.isVideo = existingCall.isVideo;
|
|
810
|
-
call.isGroup = existingCall.isGroup;
|
|
811
|
-
}
|
|
812
|
-
// delete data once call has ended
|
|
813
|
-
if (status === 'reject' || status === 'accept' || status === 'timeout' || status === 'terminate') {
|
|
814
|
-
callOfferCache.del(call.id);
|
|
815
|
-
}
|
|
816
|
-
ev.emit('call', [call]);
|
|
817
|
-
await sendMessageAck(node);
|
|
818
|
-
};
|
|
819
|
-
const handleBadAck = async ({ attrs }) => {
|
|
820
|
-
// const key: WAMessageKey = { remoteJid: attrs.from, fromMe: true, id: attrs.id }
|
|
821
|
-
const key = { remoteJid: attrs.from, fromMe: true, id: attrs.id, server_id: attrs === null || attrs === void 0 ? void 0 : attrs.server_id };
|
|
822
|
-
// current hypothesis is that if pash is sent in the ack
|
|
823
|
-
// it means -- the message hasn't reached all devices yet
|
|
824
|
-
// we'll retry sending the message here
|
|
825
|
-
if (attrs.phash) {
|
|
826
|
-
logger.info({ attrs }, 'received phash in ack, resending message...');
|
|
827
|
-
const msg = await getMessage(key);
|
|
828
|
-
if (msg) {
|
|
829
|
-
await relayMessage(key.remoteJid, msg, { messageId: key.id, useUserDevicesCache: false });
|
|
830
|
-
}
|
|
831
|
-
else {
|
|
832
|
-
logger.warn({ attrs }, 'could not send message again, as it was not found');
|
|
833
|
-
}
|
|
834
|
-
}
|
|
835
|
-
// error in acknowledgement,
|
|
836
|
-
// device could not display the message
|
|
837
|
-
if (attrs.error) {
|
|
838
|
-
logger.warn({ attrs }, 'received error in ack');
|
|
839
|
-
ev.emit('messages.update', [
|
|
840
|
-
{
|
|
841
|
-
key,
|
|
842
|
-
update: {
|
|
843
|
-
status: Types_1.WAMessageStatus.ERROR,
|
|
844
|
-
messageStubParameters: [
|
|
845
|
-
attrs.error
|
|
846
|
-
]
|
|
847
|
-
}
|
|
848
|
-
}
|
|
849
|
-
]);
|
|
850
|
-
}
|
|
851
|
-
};
|
|
852
|
-
/// processes a node with the given function
|
|
853
|
-
/// and adds the task to the existing buffer if we're buffering events
|
|
854
|
-
const processNodeWithBuffer = async (node, identifier, exec) => {
|
|
855
|
-
ev.buffer();
|
|
856
|
-
await execTask();
|
|
857
|
-
ev.flush();
|
|
858
|
-
function execTask() {
|
|
859
|
-
return exec(node)
|
|
860
|
-
.catch(err => onUnexpectedError(err, identifier));
|
|
861
|
-
}
|
|
862
|
-
};
|
|
863
|
-
// recv a message
|
|
864
|
-
ws.on('CB:message', (node) => {
|
|
865
|
-
processNodeWithBuffer(node, 'processing message', handleMessage);
|
|
866
|
-
});
|
|
867
|
-
ws.on('CB:call', async (node) => {
|
|
868
|
-
processNodeWithBuffer(node, 'handling call', handleCall);
|
|
869
|
-
});
|
|
870
|
-
ws.on('CB:receipt', node => {
|
|
871
|
-
processNodeWithBuffer(node, 'handling receipt', handleReceipt);
|
|
872
|
-
});
|
|
873
|
-
ws.on('CB:notification', async (node) => {
|
|
874
|
-
processNodeWithBuffer(node, 'handling notification', handleNotification);
|
|
875
|
-
});
|
|
876
|
-
ws.on('CB:ack,class:message', (node) => {
|
|
877
|
-
handleBadAck(node)
|
|
878
|
-
.catch(error => onUnexpectedError(error, 'handling bad ack'));
|
|
879
|
-
});
|
|
880
|
-
ev.on('call', ([call]) => {
|
|
881
|
-
// missed call + group call notification message generation
|
|
882
|
-
if (call.status === 'timeout' || (call.status === 'offer' && call.isGroup)) {
|
|
883
|
-
const msg = {
|
|
884
|
-
key: {
|
|
885
|
-
remoteJid: call.chatId,
|
|
886
|
-
id: call.id,
|
|
887
|
-
fromMe: false
|
|
888
|
-
},
|
|
889
|
-
messageTimestamp: (0, Utils_1.unixTimestampSeconds)(call.date),
|
|
890
|
-
};
|
|
891
|
-
if (call.status === 'timeout') {
|
|
892
|
-
if (call.isGroup) {
|
|
893
|
-
msg.messageStubType = call.isVideo ? Types_1.WAMessageStubType.CALL_MISSED_GROUP_VIDEO : Types_1.WAMessageStubType.CALL_MISSED_GROUP_VOICE;
|
|
894
|
-
}
|
|
895
|
-
else {
|
|
896
|
-
msg.messageStubType = call.isVideo ? Types_1.WAMessageStubType.CALL_MISSED_VIDEO : Types_1.WAMessageStubType.CALL_MISSED_VOICE;
|
|
897
|
-
}
|
|
898
|
-
}
|
|
899
|
-
else {
|
|
900
|
-
msg.message = { call: { callKey: Buffer.from(call.id) } };
|
|
901
|
-
}
|
|
902
|
-
const protoMsg = WAProto_1.proto.WebMessageInfo.fromObject(msg);
|
|
903
|
-
upsertMessage(protoMsg, call.offline ? 'append' : 'notify');
|
|
904
|
-
}
|
|
905
|
-
});
|
|
906
|
-
ev.on('connection.update', ({ isOnline }) => {
|
|
907
|
-
if (typeof isOnline !== 'undefined') {
|
|
908
|
-
sendActiveReceipts = isOnline;
|
|
909
|
-
logger.trace(`sendActiveReceipts set to "${sendActiveReceipts}"`);
|
|
910
|
-
}
|
|
911
|
-
});
|
|
912
|
-
return {
|
|
913
|
-
...sock,
|
|
914
|
-
sendMessageAck,
|
|
915
|
-
sendRetryRequest,
|
|
916
|
-
rejectCall,
|
|
917
|
-
fetchMessageHistory,
|
|
918
|
-
requestPlaceholderResend,
|
|
919
|
-
};
|
|
920
|
-
};
|
|
921
|
-
exports.makeMessagesRecvSocket = makeMessagesRecvSocket;
|