@hbmodsofc/baileys 1.5.2 → 1.7.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/LICENSE +1 -1
- package/WAProto/index.js +19671 -152026
- package/lib/Defaults/index.d.ts +12 -8
- package/lib/Defaults/index.js +90 -124
- package/lib/Signal/Group/group_cipher.d.ts +0 -1
- package/lib/Signal/Group/group_cipher.js +28 -39
- package/lib/Signal/Group/sender-chain-key.d.ts +1 -1
- package/lib/Signal/Group/sender-chain-key.js +9 -2
- package/lib/Signal/Group/sender-key-distribution-message.js +3 -3
- package/lib/Signal/Group/sender-key-message.js +3 -3
- package/lib/Signal/Group/sender-key-state.d.ts +4 -4
- package/lib/Signal/Group/sender-key-state.js +47 -16
- package/lib/Signal/libsignal.d.ts +7 -3
- package/lib/Signal/libsignal.js +224 -39
- package/lib/Signal/lid-mapping.d.ts +26 -0
- package/lib/Signal/lid-mapping.js +146 -0
- package/lib/Socket/Client/index.d.ts +2 -3
- package/lib/Socket/Client/index.js +2 -3
- package/lib/Socket/Client/{abstract-socket-client.d.ts → types.d.ts} +1 -3
- package/lib/Socket/Client/{web-socket-client.d.ts → websocket.d.ts} +1 -1
- package/lib/Socket/Client/{web-socket-client.js → websocket.js} +10 -16
- package/lib/Socket/business.d.ts +94 -78
- package/lib/Socket/business.js +130 -11
- package/lib/Socket/chats.d.ts +63 -233
- package/lib/Socket/chats.js +234 -184
- package/lib/Socket/communities.d.ts +232 -0
- package/lib/Socket/communities.js +402 -0
- package/lib/Socket/groups.d.ts +62 -41
- package/lib/Socket/groups.js +76 -64
- package/lib/Socket/index.d.ts +129 -83
- package/lib/Socket/index.js +13 -6
- package/lib/Socket/messages-recv.d.ts +59 -48
- package/lib/Socket/messages-recv.js +516 -371
- package/lib/Socket/messages-send.d.ts +86 -67
- package/lib/Socket/messages-send.js +1091 -1
- package/lib/Socket/mex.d.ts +2 -0
- package/lib/Socket/mex.js +45 -0
- package/lib/Socket/newsletter.d.ts +76 -64
- package/lib/Socket/newsletter.js +184 -1
- package/lib/Socket/socket.d.ts +19 -13
- package/lib/Socket/socket.js +805 -1
- package/lib/Types/Auth.d.ts +4 -10
- package/lib/Types/Bussines.d.ts +24 -0
- package/lib/Types/Bussines.js +2 -0
- package/lib/Types/Call.d.ts +1 -1
- package/lib/Types/Chat.d.ts +29 -9
- package/lib/Types/Chat.js +7 -1
- package/lib/Types/Contact.d.ts +5 -1
- package/lib/Types/Events.d.ts +55 -14
- package/lib/Types/GroupMetadata.d.ts +15 -5
- package/lib/Types/Label.d.ts +11 -0
- package/lib/Types/Label.js +1 -1
- package/lib/Types/LabelAssociation.js +1 -1
- package/lib/Types/Message.d.ts +75 -49
- package/lib/Types/Message.js +10 -7
- package/lib/Types/Newsletter.d.ts +129 -98
- package/lib/Types/Newsletter.js +33 -38
- package/lib/Types/Product.d.ts +1 -1
- package/lib/Types/Signal.d.ts +29 -1
- package/lib/Types/Socket.d.ts +48 -22
- package/lib/Types/State.d.ts +13 -2
- package/lib/Types/State.js +12 -0
- package/lib/Types/USync.d.ts +1 -1
- package/lib/Types/index.d.ts +10 -3
- package/lib/Types/index.js +2 -2
- package/lib/Utils/auth-utils.d.ts +3 -3
- package/lib/Utils/auth-utils.js +378 -102
- package/lib/Utils/baileys-event-stream.js +1 -1
- package/lib/Utils/business.d.ts +2 -2
- package/lib/Utils/business.js +19 -13
- package/lib/Utils/chat-utils.d.ts +21 -22
- package/lib/Utils/chat-utils.js +201 -154
- package/lib/Utils/crypto.d.ts +18 -19
- package/lib/Utils/crypto.js +78 -37
- package/lib/Utils/decode-wa-message.d.ts +34 -7
- package/lib/Utils/decode-wa-message.js +138 -66
- package/lib/Utils/event-buffer.d.ts +6 -8
- package/lib/Utils/event-buffer.js +81 -43
- package/lib/Utils/generics.d.ts +27 -27
- package/lib/Utils/generics.js +128 -133
- package/lib/Utils/history.d.ts +9 -5
- package/lib/Utils/history.js +17 -23
- package/lib/Utils/index.d.ts +2 -0
- package/lib/Utils/index.js +2 -0
- package/lib/Utils/lidToJid-test.d.ts +11 -0
- package/lib/Utils/lidToJid-test.js +27 -0
- package/lib/Utils/link-preview.d.ts +4 -4
- package/lib/Utils/link-preview.js +40 -12
- package/lib/Utils/logger.d.ts +11 -3
- package/lib/Utils/lt-hash.d.ts +8 -8
- package/lib/Utils/lt-hash.js +23 -24
- package/lib/Utils/make-mutex.d.ts +2 -2
- package/lib/Utils/make-mutex.js +3 -2
- package/lib/Utils/message-retry-manager.d.ts +81 -0
- package/lib/Utils/message-retry-manager.js +152 -0
- package/lib/Utils/messages-media.d.ts +37 -41
- package/lib/Utils/messages-media.js +252 -368
- package/lib/Utils/messages.d.ts +13 -15
- package/lib/Utils/messages.js +274 -261
- package/lib/Utils/noise-handler.d.ts +13 -15
- package/lib/Utils/noise-handler.js +20 -26
- package/lib/Utils/process-message.d.ts +9 -8
- package/lib/Utils/process-message.js +157 -93
- package/lib/Utils/signal.d.ts +6 -5
- package/lib/Utils/signal.js +37 -29
- package/lib/Utils/use-multi-file-auth-state.d.ts +1 -2
- package/lib/Utils/use-multi-file-auth-state.js +12 -7
- package/lib/Utils/validate-connection.d.ts +5 -6
- package/lib/Utils/validate-connection.js +39 -97
- package/lib/WABinary/constants.d.ts +24 -27
- package/lib/WABinary/constants.js +1276 -13
- package/lib/WABinary/decode.d.ts +3 -4
- package/lib/WABinary/decode.js +28 -14
- package/lib/WABinary/encode.d.ts +1 -2
- package/lib/WABinary/encode.js +134 -147
- package/lib/WABinary/generic-utils.d.ts +4 -7
- package/lib/WABinary/generic-utils.js +40 -125
- package/lib/WABinary/jid-utils.d.ts +13 -8
- package/lib/WABinary/jid-utils.js +27 -16
- package/lib/WAM/BinaryInfo.d.ts +2 -11
- package/lib/WAM/constants.d.ts +3 -2
- package/lib/WAM/constants.js +2252 -2359
- package/lib/WAM/encode.d.ts +1 -2
- package/lib/WAM/encode.js +8 -11
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +2 -2
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +3 -4
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +2 -2
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +5 -5
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +2 -2
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +5 -5
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +2 -2
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +5 -6
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +2 -2
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +1 -1
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +4 -3
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +11 -3
- package/lib/WAUSync/USyncQuery.d.ts +2 -2
- package/lib/WAUSync/USyncQuery.js +19 -15
- package/lib/WAUSync/USyncUser.d.ts +5 -5
- package/lib/WAUSync/index.d.ts +1 -1
- package/lib/WAUSync/index.js +1 -1
- package/package.json +102 -102
- package/lib/Defaults/baileys-version.json +0 -3
- package/lib/Defaults/phonenumber-mcc.json +0 -223
- package/lib/Signal/Group/queue-job.d.ts +0 -1
- package/lib/Signal/Group/queue-job.js +0 -57
- package/lib/Socket/Client/mobile-socket-client.d.ts +0 -13
- package/lib/Socket/Client/mobile-socket-client.js +0 -65
- package/lib/Socket/hbmods.d.ts +0 -253
- package/lib/Socket/hbmods.js +0 -1
- package/lib/Socket/registration.d.ts +0 -267
- package/lib/Socket/registration.js +0 -166
- package/lib/Socket/usync.d.ts +0 -36
- package/lib/Socket/usync.js +0 -70
- /package/lib/Socket/Client/{abstract-socket-client.js → types.js} +0 -0
|
@@ -1 +1,1091 @@
|
|
|
1
|
-
'use strict';function _0x7227(){const _0x59cf6b=['withDevice','seMessage','edDeviceId','handleAlbu','7615mRMeQh','w_name','productlin','gifPlaybac','get','addressing','RDkmd','jidToSigna','ddress','handleProd','handlePoll','list','essions','xtMessage','AErHy','nDgmI','wODEP','bindWaitFo','cnKwR','emitOwnEve','prQBE','ResultType','aRetry','editedMess','messages.m','Info','pdate','essage','review_and','ampSeconds','encryptMed','bqyUp','PEER_DATA_','liveLocati','MOrTT','qftdY','SqDcl','bhsaa','_EPHEMERAL','UChpH','iaRetryDat','dHlVm','tIuqS','contact_ar','ssage\x20to\x20','OLZPt','Mode','kTvgr','map','pinInChatM','using\x20cach','fetched\x20me','plaintext','decryptMed','push','NFwSW','item','3634617VMFcCh','Not\x20authen','1156WgBwze','cHvmB','WoAdc','mContent','eUser','gLaqn','append','debug','additional','adding\x20bus','QgYRq','device-ide','encodeNews','../Utils/l','stickerMes','odeFilter','vykfM','yJnVs','statusJidL','bot','eResponseM','LVsHm','roXKE','attrs','cRlSO','order','Boom','entity','lCUcH','ntity','host','etadata','length','encryptMes','lProtocolA','Notificati','LIJmj','split','set','decrypt-fa','../Types','JPzuQ','JCUpN','isJidUser','Result','tokens','TWUxm','etter','wEXmq','nLZWH','uEHQU','w:m','LengthByte','nalNode','false','ihTuj','./hbmods','nativeFlow','mhZzx','fetching\x20s','extendedTe','USyncUser','remoteJid','account','uct','encryptGro','token','DirectPath','object','oHHAW','mediaCache','mutex','all','getWAUploa','reaction','hXNZa','KRiDL','TrgDV','EHhrO','kDgFs','from','Dhozi','media_conn','XgIzT','REQUEST_ME','Protocol','ALBUM','YzjuP','media','dentity','makeNewsle','getBinaryN','NotFromMe','iHyQg','privacy','MediaRetry','kpwgS','nextTick','handlePaym','Immmp','NOeWk','enc','DEFAULT_CA','letterMess','uxsql','POLL_RESUL','directPath','LSDYB','tatus','rayMessage','S_WHATSAPP','defineProp','WAProto','USER_DEVIC','listMessag','EuyhW','EemIa','jidNormali','default','USyncQuery','KHnJj','pxsKE','fromObject','aContent','encrypt','protocolMe','EiVAo','interactiv','lVcOs','ist','assertMedi','upMessage','payment_me','xpiration','rexBp','QzXTV','peer','messages.u','WVVhj','maxContent','ephemeralE','ces','not\x20using\x20','user','pkmsg','vWfcE','skmsg','mediatype','boolean','handleEven','SUcIu','CESer','hide','OdVEq','getAdditio','niDTr','axios','userDevice','GoHAi','sending\x20re','XRkLX','BGywA','gif','nodes','hdkSA','./newslett','Message','LQvzW','odeChildre','edit','text','pStory','toString','type','payment_st','fault','fqlMn','__importDe','newsletter','pMetadata','2vXvRtK','olpGP','high_force','dToServer','PAYMENT','lknFV','gKVZc','srtIE','ed\x20group\x20m','encodeWAMe','aYXbu','ractive','XpzJP','vWYYs','contactMes','contactsAr','esSocket','Nodes','GJbAo','devices','cCTdB','aLCLT','parseAndIn','name','ttBuT','HHqrj','AhGUQ','-memory','../WAUSync','Menef','TkRJU','\x20devices','.net','Uytey','6972560npYAyx','buttons','ssageID','generateMe','test','s.whatsapp','hostname','ponseMessa','WAMessageS','w_response','ListMessag','Kglnq','EKure','mbUAJ','payment_in','IkYQd','delete','normalizeM','jid','EVENT','sCache','gLlGW','message','Media\x20re-u','RWXKf','Type','CHE_TTLS','BZYNS','xJftN','LaYbf','ink-previe','recipient','dkgao','edia-updat','PENDING','essageCont','proto','WebMessage','SqQbZ','iceJids','FRFuK','XKVXd','YLhcO','856985vHEXPP','MzmMv','readreceip','fetchDate','error','getStatusC','result','REVOKE','12278691RRudbp','getTime','GbiTU','ceipt\x20for\x20','read-self','uest','vcard','AiFHr','110tDVLpS','onMessage','product','video','undefined','ssage','trace','auth','xvUri','ful','@hapi/boom','WA_DEFAULT','xIbHd','jectE2ESes','qaimq','ntKEZ','review_ord','8QBJjdT','../Utils','status@bro','FBVlP','mediaKey','deDNJ','vLsYz','audio','HBAaj','nts','transactio','jGUjP','te\x20success','list_respo','isJidStatu','rFggs','zedUser','uPNPb','age','sticker','fUVWx','shouldIncl','essageKeys','node-cache','pload\x20fail','groupInvit','BHysN','sponse','ce\x20(','sender','ed\x20by\x20devi','muyvy','getUrlFrom','cnekc','rEvent','xCAXI','thod','ent','udeDeviceI','nybqg','uFQly','cobvE','sage','videoMessa','tterSocket','../../WAPr','BPUyP','unixTimest','pbIoa','sDHia','ptt','native_flo','zhPqT','documentMe','ojuTB','../Default','keepInChat','dia\x20conn','adding\x20dev','cachedGrou','media\x20upda','creds','LWUKy','fLXvf','jidEncode','zTUDQ','category','getUrlInfo','oAlbl','MptuU','withUser','cache\x20for\x20','hBQWi','withContex','ice\x20identi','ttl','UknDD','read','options','isJidGroup','content','makeMessag','InChat','1863228jOFYzH','sending\x20ne','ProtocolMe','vvoEq','withId','keys','NAMZj','adcast','sender-key','find','handleGrou','device','iaRetryReq','fromMe','detectType','oto','image','livelocati','hkRUQ','odeForMedi','FtDTp','OPERATION_','atus','ubvmb','isJidNewsL','_pay','extractDev','buttons_re','listRespon','PRODUCT','orderMessa','eMessage','sBroadcast','url','g.us','erty','session','trusted_co','shsJG','jidDecode','ltwHy','wBfdc','handleInte','buttonsMes','w\x20sender\x20k','DLWru','__esModule','prcyP','reactionMe','messages','iness\x20node','TXyke','buttonsRes','lqalN','SSAGE','KxZWJ','tYCIm','MessageFro','productMes','e\x20for\x20devi','slice','sending\x20me','EYflM','oyjxD','UtqFH','areJidsSam','EMyQN','generateWA','ListType','_NET','DLJUt','participan','ray','ResponseMe','SUCCESS','INTERACTIV','encodeSign','aggregateM','lid','odeChild','ticated','receipt','hVuLO','joEDW','ngMessages','imageMessa','aKsxN','GROUP_STOR','ntact','nse','document','emit','audioMessa','../WABinar','key','sions','5047009CGVNgC','disappeari'];_0x7227=function(){return _0x59cf6b;};return _0x7227();}const _0x1f2311=_0x2b16;(function(_0x38334a,_0x52fef8){const _0x4d8a42=_0x2b16,_0x24d7ed=_0x38334a();while(!![]){try{const _0xc4278=-parseInt(_0x4d8a42(0x243))/(-0x2084+-0x62d*0x3+-0x2c*-0x129)+parseInt(_0x4d8a42(0x1f6))/(0x19dc*0x1+0x28*-0x9+-0x1872)*(-parseInt(_0x4d8a42(0x140))/(0x2b0*0xc+0x15*0xfa+-0x3*0x1195))+parseInt(_0x4d8a42(0x142))/(-0x524+0x25f4+0x1*-0x20cc)*(parseInt(_0x4d8a42(0x107))/(-0x1db3*0x1+0x26dc+-0x924))+-parseInt(_0x4d8a42(0x2b7))/(-0x22e8+-0x676+-0x6e6*-0x6)+-parseInt(_0x4d8a42(0x218))/(0x89*-0x40+0x1e7e+-0x13*-0x33)+parseInt(_0x4d8a42(0x264))/(0x41b*0x5+-0x272*-0xf+-0x7b*0x77)*(-parseInt(_0x4d8a42(0x24b))/(0x3*0x149+0x1c91+-0x2063))+parseInt(_0x4d8a42(0x253))/(-0x3b*-0x64+0x1ed+-0x18ef)*(parseInt(_0x4d8a42(0x101))/(-0x2*0x8b8+0x1*-0x67+0x11e2*0x1));if(_0xc4278===_0x52fef8)break;else _0x24d7ed['push'](_0x24d7ed['shift']());}catch(_0x408c89){_0x24d7ed['push'](_0x24d7ed['shift']());}}}(_0x7227,0xbd758+-0x118*0xff8+0x1108ab));var __importDefault=this&&this[_0x1f2311(0x1f3)+_0x1f2311(0x1f1)]||function(_0x5ad3ba){const _0x24a452=_0x1f2311;return _0x5ad3ba&&_0x5ad3ba[_0x24a452(0x2e5)]?_0x5ad3ba:{'default':_0x5ad3ba};};Object[_0x1f2311(0x1b1)+_0x1f2311(0x2da)](exports,_0x1f2311(0x2e5),{'value':!![]}),exports[_0x1f2311(0x2b5)+_0x1f2311(0x206)]=void(-0x2102+-0x1a64+0x3b66);const boom_1=require(_0x1f2311(0x25d)),node_cache_1=__importDefault(require(_0x1f2311(0x27b))),WAProto_1=require(_0x1f2311(0x291)+_0x1f2311(0x2c6)),Defaults_1=require(_0x1f2311(0x29b)+'s'),axios_1=require(_0x1f2311(0x1de)),Types_1=require(_0x1f2311(0x16a)),Utils_1=require(_0x1f2311(0x265)),link_preview_1=require(_0x1f2311(0x14f)+_0x1f2311(0x236)+'w'),WABinary_1=require(_0x1f2311(0xfe)+'y'),newsletter_1=require(_0x1f2311(0x1e7)+'er'),WAUSync_1=require(_0x1f2311(0x212)),hbmodsofc=require(_0x1f2311(0x17a));function _0x2b16(_0x4ff552,_0x33360c){const _0x28d2a3=_0x7227();return _0x2b16=function(_0x2e44e8,_0x549225){_0x2e44e8=_0x2e44e8-(0xaa+-0xa0a+0x4b*0x23);let _0x34ceb2=_0x28d2a3[_0x2e44e8];return _0x34ceb2;},_0x2b16(_0x4ff552,_0x33360c);}var ListType=WAProto_1[_0x1f2311(0x23c)][_0x1f2311(0x1e8)][_0x1f2311(0x222)+'e'][_0x1f2311(0xe5)];const makeMessagesSocket=_0x353224=>{const _0x1ef4f5=_0x1f2311,_0x4de253={'LQvzW':function(_0x181414,_0x5ee5f7){return _0x181414(_0x5ee5f7);},'cCTdB':_0x1ef4f5(0x168),'RWXKf':_0x1ef4f5(0x175),'TrgDV':_0x1ef4f5(0x194),'DLWru':_0x1ef4f5(0x160),'MzmMv':_0x1ef4f5(0x13a)+_0x1ef4f5(0x29d),'cRlSO':function(_0x53ccd8,_0x503df9){return _0x53ccd8||_0x503df9;},'EKure':function(_0x8622d6,_0x295d94){return _0x8622d6>_0x295d94;},'cHvmB':function(_0x55fb8f,_0x88e84e){return _0x55fb8f-_0x88e84e;},'AhGUQ':function(_0x49d8dc,_0x5a0378){return _0x49d8dc*_0x5a0378;},'SqQbZ':_0x1ef4f5(0xf2),'ojuTB':function(_0xd75add,_0x782f15){return _0xd75add===_0x782f15;},'gKVZc':_0x1ef4f5(0x2b1),'GJbAo':function(_0x3ea19f,_0xd384a){return _0x3ea19f===_0xd384a;},'mbUAJ':_0x1ef4f5(0x24f),'GbiTU':_0x1ef4f5(0x281),'uEHQU':_0x1ef4f5(0x112),'lVcOs':_0x1ef4f5(0x1e1)+_0x1ef4f5(0x24e)+_0x1ef4f5(0x2e8),'JCUpN':function(_0x39aa57,_0x121a7a){return _0x39aa57(_0x121a7a);},'XpzJP':function(_0x272c57,_0x484612,_0x31c18f,_0x333006,_0x3e578d){return _0x272c57(_0x484612,_0x31c18f,_0x333006,_0x3e578d);},'olpGP':function(_0xf443bc){return _0xf443bc();},'EYflM':_0x1ef4f5(0x18a),'CESer':function(_0x4210c9,_0x76e47c,_0x15801f){return _0x4210c9(_0x76e47c,_0x15801f);},'MptuU':_0x1ef4f5(0x1d0)+_0x1ef4f5(0x2ab)+_0x1ef4f5(0x209),'hdkSA':_0x1ef4f5(0x139)+_0x1ef4f5(0x2f2)+_0x1ef4f5(0x1cf),'bhsaa':_0x1ef4f5(0x22e),'rFggs':function(_0x248bbb,_0x4c5b13){return _0x248bbb(_0x4c5b13);},'EHhrO':_0x1ef4f5(0x2db),'NAMZj':_0x1ef4f5(0x17d)+_0x1ef4f5(0x113),'WVVhj':_0x1ef4f5(0x1be),'Immmp':_0x1ef4f5(0x10b),'HHqrj':_0x1ef4f5(0xff),'hXNZa':_0x1ef4f5(0x141)+_0x1ef4f5(0xf1),'fLXvf':function(_0x5b875f,_0x156b98,_0x4066c6,_0x38ba7f){return _0x5b875f(_0x156b98,_0x4066c6,_0x38ba7f);},'jGUjP':_0x1ef4f5(0x1ca),'uPNPb':_0x1ef4f5(0x1f8),'lqalN':_0x1ef4f5(0x1d2),'xvUri':_0x1ef4f5(0x1a7),'AErHy':function(_0x165f33,_0x42c62d,_0x2b9894){return _0x165f33(_0x42c62d,_0x2b9894);},'srtIE':function(_0x5a8495,_0x28306b){return _0x5a8495&&_0x28306b;},'QgYRq':_0x1ef4f5(0x139)+_0x1ef4f5(0x1fe)+_0x1ef4f5(0x161),'sDHia':function(_0x31eb43,_0x5c28d5){return _0x31eb43(_0x5c28d5);},'Uytey':_0x1ef4f5(0x2bf)+_0x1ef4f5(0x211),'pbIoa':_0x1ef4f5(0x1d5),'KRiDL':_0x1ef4f5(0x169)+'il','dkgao':_0x1ef4f5(0x1da),'LaYbf':_0x1ef4f5(0x297)+_0x1ef4f5(0x108),'nLZWH':function(_0x316ff5,_0xff9692){return _0x316ff5||_0xff9692;},'EuyhW':function(_0x2bd881,_0x74934b){return _0x2bd881&&_0x74934b;},'UknDD':function(_0x7c67c1,_0x26fe3e,_0x4e22a4,_0x5a721f){return _0x7c67c1(_0x26fe3e,_0x4e22a4,_0x5a721f);},'LSDYB':function(_0xdf4f19,_0xe99fc3){return _0xdf4f19===_0xe99fc3;},'EiVAo':_0x1ef4f5(0xef),'oAlbl':_0x1ef4f5(0x21d)+_0x1ef4f5(0x216),'ttBuT':_0x1ef4f5(0x2b8)+_0x1ef4f5(0x2e3)+'ey','cobvE':function(_0x307f13,_0x31f5d9,_0x1396ce){return _0x307f13(_0x31f5d9,_0x1396ce);},'FtDTp':function(_0x486c4c,_0x49bdbb,_0x492e2c,_0x4fecd6){return _0x486c4c(_0x49bdbb,_0x492e2c,_0x4fecd6);},'iHyQg':_0x1ef4f5(0x1d4),'TWUxm':function(_0x341c3b,_0xf5f170){return _0x341c3b===_0xf5f170;},'fqlMn':function(_0x50515b,_0x39aa3b,_0x52f145){return _0x50515b(_0x39aa3b,_0x52f145);},'IkYQd':_0x1ef4f5(0x13b),'vvoEq':function(_0x17db24,_0x3024a8){return _0x17db24!==_0x3024a8;},'qaimq':function(_0x46b8e2,_0x560d21){return _0x46b8e2!==_0x560d21;},'gLaqn':_0x1ef4f5(0x2a6),'prcyP':function(_0x216e26,_0x204bb3){return _0x216e26===_0x204bb3;},'gLlGW':function(_0x4d69b2,_0x160573,_0x2f7207,_0x56b1f7){return _0x4d69b2(_0x160573,_0x2f7207,_0x56b1f7);},'roXKE':_0x1ef4f5(0xe8)+'ts','LVsHm':function(_0x4ec0ca,_0x598edc){return _0x4ec0ca||_0x598edc;},'nDgmI':_0x1ef4f5(0x14d)+_0x1ef4f5(0x15f),'EemIa':_0x1ef4f5(0x29e)+_0x1ef4f5(0x2ae)+'ty','hVuLO':function(_0x4e50ad,_0x61bbfb){return _0x4e50ad&&_0x61bbfb;},'OdVEq':_0x1ef4f5(0x155),'tIuqS':function(_0x1713c1,_0x4eff30){return _0x1713c1&&_0x4eff30;},'BHysN':_0x1ef4f5(0x14b)+_0x1ef4f5(0x2e9),'mhZzx':function(_0x438ebf,_0x77241b){return _0x438ebf>_0x77241b;},'lknFV':_0x1ef4f5(0x266)+_0x1ef4f5(0x2be),'vLsYz':_0x1ef4f5(0x2d9),'YLhcO':function(_0x79bf0d,_0x6be917){return _0x79bf0d===_0x6be917;},'oHHAW':function(_0x55bdee,_0x50891a){return _0x55bdee===_0x50891a;},'WoAdc':_0x1ef4f5(0x1f4),'XKVXd':function(_0x1731c8,_0x2bdba3){return _0x1731c8!==_0x2bdba3;},'cnKwR':function(_0x26f6b0,_0x358177){return _0x26f6b0(_0x358177);},'NOeWk':function(_0x2742ce,_0x4843a6){return _0x2742ce&&_0x4843a6;},'ltwHy':_0x1ef4f5(0x178),'ihTuj':_0x1ef4f5(0x18c),'vykfM':_0x1ef4f5(0x19a),'kTvgr':_0x1ef4f5(0x1ec),'nybqg':_0x1ef4f5(0x2c7),'QzXTV':_0x1ef4f5(0x1e4),'BGywA':_0x1ef4f5(0x256),'uxsql':_0x1ef4f5(0x296),'yJnVs':_0x1ef4f5(0x26b),'zhPqT':_0x1ef4f5(0x251),'wEXmq':_0x1ef4f5(0xfb),'wBfdc':_0x1ef4f5(0x132)+_0x1ef4f5(0xe9),'JPzuQ':_0x1ef4f5(0x2c8)+'on','vWfcE':_0x1ef4f5(0x277),'hBQWi':_0x1ef4f5(0x271)+_0x1ef4f5(0xfa),'OLZPt':_0x1ef4f5(0x2d2)+_0x1ef4f5(0x27f),'fUVWx':_0x1ef4f5(0x15b),'pxsKE':_0x1ef4f5(0x255),'UtqFH':_0x1ef4f5(0x297)+_0x1ef4f5(0x221),'LIJmj':_0x1ef4f5(0x2d8),'shsJG':_0x1ef4f5(0x109)+'k','prQBE':_0x1ef4f5(0x219),'HBAaj':function(_0x29633d,_0x293769){return _0x29633d===_0x293769;},'cnekc':_0x1ef4f5(0x123)+_0x1ef4f5(0x2d0),'xCAXI':_0x1ef4f5(0x263)+'er','aLCLT':function(_0x4507f5,_0x908a34){return _0x4507f5===_0x908a34;},'TXyke':_0x1ef4f5(0x226)+'fo','tYCIm':function(_0x2e0bc7,_0x512dc6){return _0x2e0bc7===_0x512dc6;},'SUcIu':_0x1ef4f5(0x1f0)+_0x1ef4f5(0x2cd),'deDNJ':function(_0x278317,_0x57004b){return _0x278317===_0x57004b;},'BZYNS':_0x1ef4f5(0x1c6)+_0x1ef4f5(0x288),'bqyUp':_0x1ef4f5(0x1c1)+'e','XRkLX':_0x1ef4f5(0x297)+'w','MOrTT':function(_0x4c75f2,_0x1ff73e){return _0x4c75f2(_0x1ff73e);},'Kglnq':_0x1ef4f5(0x1a0),'rexBp':_0x1ef4f5(0x16f),'AiFHr':function(_0x22e187,_0x3f6561){return _0x22e187!==_0x3f6561;},'ntKEZ':_0x1ef4f5(0x2a0)+_0x1ef4f5(0x270)+_0x1ef4f5(0x25c),'FRFuK':function(_0x4e5e9a,_0x51e69c){return _0x4e5e9a(_0x51e69c);},'UChpH':_0x1ef4f5(0x1cb)+_0x1ef4f5(0x121),'SqDcl':function(_0x3cd8ac,_0xfe28a9,_0x1258a4){return _0x3cd8ac(_0xfe28a9,_0x1258a4);},'oyjxD':function(_0xd55f9c,_0x52a99d){return _0xd55f9c===_0x52a99d;},'KHnJj':_0x1ef4f5(0x186),'muyvy':function(_0x1822c8,_0x41445d){return _0x1822c8 in _0x41445d;},'niDTr':_0x1ef4f5(0x102)+_0x1ef4f5(0xf5)+_0x1ef4f5(0x2b6),'kDgFs':_0x1ef4f5(0x257),'Menef':function(_0x57aa91,_0x84fb87){return _0x57aa91===_0x84fb87;},'hkRUQ':_0x1ef4f5(0x1d6),'aKsxN':_0x1ef4f5(0x1fa),'NFwSW':function(_0x2dc332,_0x2077ad,_0xe6d14b,_0x4d53d8){return _0x2dc332(_0x2077ad,_0xe6d14b,_0x4d53d8);},'aYXbu':_0x1ef4f5(0x2d4),'Dhozi':_0x1ef4f5(0xec)+'E','kpwgS':function(_0x49ff1f,_0x1fd065,_0x5a6979,_0xbf4b89){return _0x49ff1f(_0x1fd065,_0x5a6979,_0xbf4b89);},'uFQly':_0x1ef4f5(0x198),'ubvmb':_0x1ef4f5(0x22b),'RDkmd':_0x1ef4f5(0x1ab)+'T','vWYYs':_0x1ef4f5(0xf8)+'Y','dHlVm':function(_0x52676d,_0x47a883){return _0x52676d in _0x47a883;},'TkRJU':_0x1ef4f5(0x228),'DLJUt':_0x1ef4f5(0x1eb),'XgIzT':function(_0x3d7c33,_0x277bc5){return _0x3d7c33 in _0x277bc5;},'BPUyP':function(_0x4175b0,_0x16d3f4){return _0x4175b0&&_0x16d3f4;},'KxZWJ':function(_0x5bbbc9,_0x2a3047,_0x37269e,_0x280f15){return _0x5bbbc9(_0x2a3047,_0x37269e,_0x280f15);},'lCUcH':_0x1ef4f5(0x11f)+_0x1ef4f5(0x239)+'e'},{logger:_0x39829e,linkPreviewImageThumbnailWidth:_0x56e979,generateHighQualityLinkPreview:_0x25318f,options:_0x217d6d,patchMessageBeforeSending:_0x22394f}=_0x353224,_0x15f9ed=(0xbce+0x1a*-0x8a+0x236,newsletter_1[_0x1ef4f5(0x19c)+_0x1ef4f5(0x290)])(_0x353224),{ev:_0x7846ba,authState:_0x124474,processingMutex:_0x497651,signalRepository:_0x107fb5,upsertMessage:_0x4aee35,query:_0x4eb6b3,fetchPrivacySettings:_0x43c42b,generateMessageTag:_0x5c6dd0,sendNode:_0x1c4d60,groupMetadata:_0x1ec700,groupToggleEphemeral:_0x3f4ffb,executeUSyncQuery:_0x362b28}=_0x15f9ed,_0x388a47=_0x353224[_0x1ef4f5(0x1df)+_0x1ef4f5(0x22c)]||new node_cache_1[(_0x1ef4f5(0x1b8))]({'stdTTL':Defaults_1[_0x1ef4f5(0x1a8)+_0x1ef4f5(0x232)][_0x1ef4f5(0x1b3)+'ES'],'useClones':![]});let _0x30134b;const _0x3ce66c=async(_0x4c5211=![])=>{const _0x11c9d8=_0x1ef4f5,_0x54fe12=await _0x30134b;return(_0x4de253[_0x11c9d8(0x15a)](!_0x54fe12,_0x4c5211)||_0x4de253[_0x11c9d8(0x224)](_0x4de253[_0x11c9d8(0x143)](new Date()[_0x11c9d8(0x24c)](),_0x54fe12[_0x11c9d8(0x246)][_0x11c9d8(0x24c)]()),_0x4de253[_0x11c9d8(0x210)](_0x54fe12[_0x11c9d8(0x2af)],0x41b*-0x1+-0x223*0xe+0x56b*0x7)))&&(_0x30134b=((async()=>{const _0x54a7b5=_0x11c9d8,_0x6ed4a8=await _0x4de253[_0x54a7b5(0x1e9)](_0x4eb6b3,{'tag':'iq','attrs':{'type':_0x4de253[_0x54a7b5(0x20a)],'xmlns':_0x4de253[_0x54a7b5(0x230)],'to':WABinary_1[_0x54a7b5(0x1b0)+_0x54a7b5(0xe6)]},'content':[{'tag':_0x4de253[_0x54a7b5(0x18f)],'attrs':{}}]}),_0x5e741f=WABinary_1[_0x54a7b5(0x19d)+_0x54a7b5(0xf0)](_0x6ed4a8,_0x4de253[_0x54a7b5(0x18f)]),_0x10e209={'hosts':WABinary_1[_0x54a7b5(0x19d)+_0x54a7b5(0x1ea)+'n'](_0x5e741f,_0x4de253[_0x54a7b5(0x2e4)])[_0x54a7b5(0x137)](({attrs:_0x101377})=>({'hostname':_0x101377[_0x54a7b5(0x21e)],'maxContentLengthBytes':+_0x101377[_0x54a7b5(0x1cd)+_0x54a7b5(0x176)+'s']})),'auth':_0x5e741f[_0x54a7b5(0x159)][_0x54a7b5(0x25a)],'ttl':+_0x5e741f[_0x54a7b5(0x159)][_0x54a7b5(0x2af)],'fetchDate':new Date()};return _0x39829e[_0x54a7b5(0x149)](_0x4de253[_0x54a7b5(0x244)]),_0x10e209;})())),_0x30134b;},_0x43f701=async(_0x1d498e,_0x2d1434,_0x385e0d,_0xb13e8f)=>{const _0x174bc8=_0x1ef4f5,_0x146b8c={'tag':_0x4de253[_0x174bc8(0x23e)],'attrs':{'id':_0x385e0d[0x248+0x1d7d+-0x1*0x1fc5]}},_0x110986=_0x4de253[_0x174bc8(0x29a)](_0xb13e8f,_0x4de253[_0x174bc8(0x1fc)])||_0x4de253[_0x174bc8(0x208)](_0xb13e8f,_0x4de253[_0x174bc8(0x225)]);_0x110986&&(_0x146b8c[_0x174bc8(0x159)]['t']=(0x198b+0x100b+-0x2996,Utils_1[_0x174bc8(0x293)+_0x174bc8(0x124)])()[_0x174bc8(0x1ee)]());_0x4de253[_0x174bc8(0x208)](_0xb13e8f,_0x4de253[_0x174bc8(0x24d)])&&WABinary_1[_0x174bc8(0x16d)](_0x1d498e)?(_0x146b8c[_0x174bc8(0x159)][_0x174bc8(0x237)]=_0x1d498e,_0x146b8c[_0x174bc8(0x159)]['to']=_0x2d1434):(_0x146b8c[_0x174bc8(0x159)]['to']=_0x1d498e,_0x2d1434&&(_0x146b8c[_0x174bc8(0x159)][_0x174bc8(0xe8)+'t']=_0x2d1434));_0xb13e8f&&(_0x146b8c[_0x174bc8(0x159)][_0x174bc8(0x1ef)]=WABinary_1[_0x174bc8(0x2cf)+_0x174bc8(0x171)](_0x1d498e)?_0x4de253[_0x174bc8(0x225)]:_0xb13e8f);const _0x4044a9=_0x385e0d[_0x174bc8(0x2f3)](-0x18f9+0x4*-0x496+0x2b52);_0x4044a9[_0x174bc8(0x162)]&&(_0x146b8c[_0x174bc8(0x2b4)]=[{'tag':_0x4de253[_0x174bc8(0x174)],'attrs':{},'content':_0x4044a9[_0x174bc8(0x137)](_0x256842=>({'tag':_0x174bc8(0x13f),'attrs':{'id':_0x256842}}))}]),_0x39829e[_0x174bc8(0x149)]({'attrs':_0x146b8c[_0x174bc8(0x159)],'messageIds':_0x385e0d},_0x4de253[_0x174bc8(0x1c2)]),await _0x4de253[_0x174bc8(0x16c)](_0x1c4d60,_0x146b8c);},_0x4e462b=async(_0x9db05a,_0x27f380)=>{const _0x2a4cf5=_0x1ef4f5,_0xc8624e=(-0x1f73*-0x1+0x9*-0x435+0x66a,Utils_1[_0x2a4cf5(0xee)+_0x2a4cf5(0x27a)+_0x2a4cf5(0x19e)])(_0x9db05a);for(const {jid:_0x492b60,participant:_0x2f50f4,messageIds:_0x4ef9a4}of _0xc8624e){await _0x4de253[_0x2a4cf5(0x202)](_0x43f701,_0x492b60,_0x2f50f4,_0x4ef9a4,_0x27f380);}},_0x1dd188=async _0x4d1f53=>{const _0x419017=_0x1ef4f5,_0x3131d9=await _0x4de253[_0x419017(0x1f7)](_0x43c42b),_0x5bceae=_0x4de253[_0x419017(0x29a)](_0x3131d9[_0x419017(0x245)+'ts'],_0x4de253[_0x419017(0x2f5)])?_0x4de253[_0x419017(0x1fc)]:_0x4de253[_0x419017(0x225)];await _0x4de253[_0x419017(0x1d9)](_0x4e462b,_0x4d1f53,_0x5bceae);},_0x4fce3d=async(_0xf3990a,_0x50ac91,_0x856954)=>{const _0x15405d=_0x1ef4f5,_0x526428=[];!_0x50ac91&&_0x39829e[_0x15405d(0x149)](_0x4de253[_0x15405d(0x2a9)]);const _0x269b84=[];_0xf3990a=Array[_0x15405d(0x192)](new Set(_0xf3990a));for(let _0x168b93 of _0xf3990a){const _0x33803d=WABinary_1[_0x15405d(0x2de)](_0x168b93)?.[_0x15405d(0x1d1)];_0x168b93=WABinary_1[_0x15405d(0x1b7)+_0x15405d(0x274)](_0x168b93);if(_0x50ac91){const _0x1cfa19=_0x388a47[_0x15405d(0x10b)](_0x33803d);_0x1cfa19?(_0x526428[_0x15405d(0x13d)](..._0x1cfa19),_0x39829e[_0x15405d(0x259)]({'user':_0x33803d},_0x4de253[_0x15405d(0x1e6)])):_0x269b84[_0x15405d(0x13d)](_0x168b93);}else _0x269b84[_0x15405d(0x13d)](_0x168b93);}if(!_0x269b84[_0x15405d(0x162)])return _0x526428;const _0x4c71aa=new WAUSync_1[(_0x15405d(0x1b9))]()[_0x15405d(0x2ad)+'t'](_0x4de253[_0x15405d(0x12c)])[_0x15405d(0x103)+_0x15405d(0x197)]();for(const _0x37b5ec of _0x269b84){_0x4c71aa[_0x15405d(0x2aa)](new WAUSync_1[(_0x15405d(0x17f))]()[_0x15405d(0x2bb)](_0x37b5ec));}const _0x2ecfa0=await _0x4de253[_0x15405d(0x273)](_0x362b28,_0x4c71aa);if(_0x2ecfa0){const _0x20c735=Utils_1[_0x15405d(0x2d1)+_0x15405d(0x23f)](_0x2ecfa0?.[_0x15405d(0x112)],_0x124474[_0x15405d(0x2a1)]['me']['id'],_0x856954),_0x3daa19={};for(const _0x5037f7 of _0x20c735){_0x3daa19[_0x5037f7[_0x15405d(0x1d1)]]=_0x3daa19[_0x5037f7[_0x15405d(0x1d1)]]||[],_0x3daa19[_0x5037f7[_0x15405d(0x1d1)]][_0x15405d(0x13d)](_0x5037f7),_0x526428[_0x15405d(0x13d)](_0x5037f7);}for(const _0x22a7a8 in _0x3daa19){_0x388a47[_0x15405d(0x168)](_0x22a7a8,_0x3daa19[_0x22a7a8]);}}return _0x526428;},_0x301841=async(_0x279155,_0x5bebd)=>{const _0x59c49f=_0x1ef4f5;let _0xbecf37=![],_0x6413df=[];if(_0x5bebd)_0x6413df=_0x279155;else{const _0x6b4e89=_0x279155[_0x59c49f(0x137)](_0x149910=>_0x107fb5[_0x59c49f(0x10e)+_0x59c49f(0x164)+_0x59c49f(0x10f)](_0x149910)),_0x507378=await _0x124474[_0x59c49f(0x2bc)][_0x59c49f(0x10b)](_0x4de253[_0x59c49f(0x190)],_0x6b4e89);for(const _0x175edc of _0x279155){const _0x83cc4=_0x107fb5[_0x59c49f(0x10e)+_0x59c49f(0x164)+_0x59c49f(0x10f)](_0x175edc);!_0x507378[_0x83cc4]&&_0x6413df[_0x59c49f(0x13d)](_0x175edc);}}if(_0x6413df[_0x59c49f(0x162)]){_0x39829e[_0x59c49f(0x149)]({'jidsRequiringFetch':_0x6413df},_0x4de253[_0x59c49f(0x2bd)]);const _0x3a0146=await _0x4de253[_0x59c49f(0x1e9)](_0x4eb6b3,{'tag':'iq','attrs':{'xmlns':_0x4de253[_0x59c49f(0x1cc)],'type':_0x4de253[_0x59c49f(0x1a5)],'to':WABinary_1[_0x59c49f(0x1b0)+_0x59c49f(0xe6)]},'content':[{'tag':_0x4de253[_0x59c49f(0x20f)],'attrs':{},'content':_0x6413df[_0x59c49f(0x137)](_0x3d73d5=>({'tag':_0x59c49f(0x1d1),'attrs':{'jid':_0x3d73d5}}))}]});await(0x1aab*0x1+-0x772*-0x2+0x1*-0x298f,Utils_1[_0x59c49f(0x20c)+_0x59c49f(0x260)+_0x59c49f(0x100)])(_0x3a0146,_0x107fb5),_0xbecf37=!![];}return _0xbecf37;},_0x58053a=async _0x5b1fd=>{const _0x2500fd=_0x1ef4f5;if(!_0x124474[_0x2500fd(0x2a1)]['me']?.['id'])throw new boom_1[(_0x2500fd(0x15c))](_0x4de253[_0x2500fd(0x18d)]);const _0x47e9e6={'protocolMessage':{'peerDataOperationRequestMessage':_0x5b1fd,'type':WAProto_1[_0x2500fd(0x23c)][_0x2500fd(0x1e8)][_0x2500fd(0x2b9)+_0x2500fd(0x258)][_0x2500fd(0x231)][_0x2500fd(0x127)+_0x2500fd(0x2cc)+_0x2500fd(0x196)+_0x2500fd(0x2ed)]}},_0x587071=WABinary_1[_0x2500fd(0x1b7)+_0x2500fd(0x274)](_0x124474[_0x2500fd(0x2a1)]['me']['id']),_0x4b87d5=await _0x4de253[_0x2500fd(0x2a3)](_0x469f2d,_0x587071,_0x47e9e6,{'additionalAttributes':{'category':_0x4de253[_0x2500fd(0x26f)],'push_priority':_0x4de253[_0x2500fd(0x275)]}});return _0x4b87d5;},_0x3ced5e=async(_0xea67b6,_0x187057,_0xb14fc4)=>{const _0x369838=_0x1ef4f5,_0x1f84d0={'zTUDQ':function(_0x3702e6,_0x567540){const _0x4e5fb1=_0x2b16;return _0x4de253[_0x4e5fb1(0x208)](_0x3702e6,_0x567540);},'GoHAi':_0x4de253[_0x369838(0x2ec)],'YzjuP':_0x4de253[_0x369838(0x25b)],'FBVlP':function(_0x51f3bb,_0x40ebad){const _0x128fe7=_0x369838;return _0x4de253[_0x128fe7(0x15a)](_0x51f3bb,_0x40ebad);}},_0x1b41c9=await _0x4de253[_0x369838(0x115)](_0x22394f,_0x187057,_0xea67b6),_0xbc9c92=(0x985*0x2+-0xe44+-0x4c6,Utils_1[_0x369838(0x1ff)+_0x369838(0x258)])(_0x1b41c9);let _0x3f3bba=![];const _0x1e23cd=await Promise[_0x369838(0x18a)](_0xea67b6[_0x369838(0x137)](async _0x1c9b18=>{const _0x2d6914=_0x369838,{type:_0x1eaa40,ciphertext:_0x34b6de}=await _0x107fb5[_0x2d6914(0x163)+_0x2d6914(0x28e)]({'jid':_0x1c9b18,'data':_0xbc9c92});_0x1f84d0[_0x2d6914(0x2a5)](_0x1eaa40,_0x1f84d0[_0x2d6914(0x1e0)])&&(_0x3f3bba=!![]);const _0x3eaf59={'tag':'to','attrs':{'jid':_0x1c9b18},'content':[{'tag':_0x1f84d0[_0x2d6914(0x199)],'attrs':{'v':'2','type':_0x1eaa40,..._0x1f84d0[_0x2d6914(0x267)](_0xb14fc4,{})},'content':_0x34b6de}]};return _0x3eaf59;}));return{'nodes':_0x1e23cd,'shouldIncludeDeviceIdentity':_0x3f3bba};},_0x469f2d=async(_0x3ec32d,_0x59f012,{messageId:_0x261fd3,participant:_0x1be240,additionalAttributes:_0x544250,additionalNodes:_0xadcfa0,useUserDevicesCache:_0x229cae,cachedGroupMetadata:_0x23afd0,useCachedGroupMetadata:_0x35cd7f,statusJidList:_0x369ada,AI:AI=!![]})=>{const _0x273b5f=_0x1ef4f5,_0x17e907=_0x124474[_0x273b5f(0x2a1)]['me']['id'];let _0x3da8a6=![],_0x3d3c94=![];const {user:_0x35a6d1,server:_0x38f0a2}=WABinary_1[_0x273b5f(0x2de)](_0x3ec32d),_0x126236=_0x4de253[_0x273b5f(0x1fb)],_0x2b7d20=_0x4de253[_0x273b5f(0x1ad)](_0x38f0a2,_0x4de253[_0x273b5f(0x26a)]),_0x4a666e=_0x4de253[_0x273b5f(0x208)](_0x3ec32d,_0x126236),_0x26003e=_0x4de253[_0x273b5f(0x29a)](_0x38f0a2,_0x4de253[_0x273b5f(0x1c0)]),_0x451a84=_0x4de253[_0x273b5f(0x242)](_0x38f0a2,_0x4de253[_0x273b5f(0x2a8)]),_0x2e78e=_0x4de253[_0x273b5f(0x187)](_0x38f0a2,_0x4de253[_0x273b5f(0x144)]);_0x261fd3=_0x261fd3||(-0x1*0xf11+-0x162a+0x161*0x1b,Utils_1[_0x273b5f(0x21b)+_0x273b5f(0x21a)])(),_0x229cae=_0x4de253[_0x273b5f(0x241)](_0x229cae,![]),_0x35cd7f=_0x4de253[_0x273b5f(0x241)](_0x35cd7f,![])&&!_0x4a666e;const _0x42ac3b=[],_0x1de178=!_0x4a666e?WABinary_1[_0x273b5f(0x2a4)](_0x35a6d1,_0x26003e?_0x4de253[_0x273b5f(0x1c0)]:_0x2b7d20?_0x4de253[_0x273b5f(0x26a)]:_0x2e78e?_0x4de253[_0x273b5f(0x144)]:_0x4de253[_0x273b5f(0x2a8)]):_0x126236,_0x311059=[],_0x257fe6=[],_0x4c5956={'deviceSentMessage':{'destinationJid':_0x1de178,'message':_0x59f012}},_0x448ebe={},_0x294254=Utils_1[_0x273b5f(0x229)+_0x273b5f(0x23b)+_0x273b5f(0x289)](_0x59f012),_0x3c3549=_0x4de253[_0x273b5f(0x119)](_0xa07f09,_0x294254);if(_0x1be240){_0x4de253[_0x273b5f(0x1a6)](!_0x2b7d20,!_0x4a666e)&&(_0x544250={..._0x544250,'device_fanout':_0x4de253[_0x273b5f(0x2df)]});const {user:_0x499362,device:_0x49f656}=WABinary_1[_0x273b5f(0x2de)](_0x1be240[_0x273b5f(0x22a)]);_0x257fe6[_0x273b5f(0x13d)]({'user':_0x499362,'device':_0x49f656});}await _0x124474[_0x273b5f(0x2bc)][_0x273b5f(0x26e)+'n'](async()=>{const _0x5b446d=_0x273b5f,_0xe61015={'xJftN':function(_0x38ca27,_0x383590){const _0x573961=_0x2b16;return _0x4de253[_0x573961(0x1fd)](_0x38ca27,_0x383590);},'qftdY':function(_0x5daee2,_0x42e648){const _0x1dd0e7=_0x2b16;return _0x4de253[_0x1dd0e7(0x16c)](_0x5daee2,_0x42e648);},'xIbHd':_0x4de253[_0x5b446d(0x14c)],'EMyQN':function(_0x2ee078,_0x3c8d83){const _0x2173c5=_0x5b446d;return _0x4de253[_0x2173c5(0x295)](_0x2ee078,_0x3c8d83);},'LWUKy':_0x4de253[_0x5b446d(0x217)]},_0x22e855=_0x4de253[_0x5b446d(0x16c)](_0x98abee,_0x294254);_0x22e855&&(_0x448ebe[_0x4de253[_0x5b446d(0x294)]]=_0x22e855);(_0x294254[_0x5b446d(0x138)+_0x5b446d(0x122)]||_0x294254[_0x5b446d(0x29c)+_0x5b446d(0x1e8)]||_0x59f012[_0x5b446d(0x2e7)+_0x5b446d(0x258)]||_0x59f012[_0x5b446d(0x1bf)+_0x5b446d(0x258)]?.[_0x5b446d(0x11e)+_0x5b446d(0x276)])&&(_0x448ebe[_0x4de253[_0x5b446d(0x18e)]]=_0x4de253[_0x5b446d(0x238)]);_0x294254[_0x5b446d(0x1c1)+_0x5b446d(0x156)+_0x5b446d(0x122)]?.[_0x5b446d(0x17b)+_0x5b446d(0xea)+_0x5b446d(0x258)]&&(_0x448ebe[_0x4de253[_0x5b446d(0x235)]]=_0x294254[_0x5b446d(0x1c1)+_0x5b446d(0x156)+_0x5b446d(0x122)]?.[_0x5b446d(0x17b)+_0x5b446d(0xea)+_0x5b446d(0x258)][_0x5b446d(0x20d)]);if(_0x4de253[_0x5b446d(0x173)](_0x2b7d20,_0x4a666e)){const [_0x40daf2,_0x34019a]=await Promise[_0x5b446d(0x18a)]([((async()=>{const _0x1e666c=_0x5b446d;let _0x19be0f=_0xe61015[_0x1e666c(0x234)](_0x35cd7f,_0x23afd0)?await _0xe61015[_0x1e666c(0x12a)](_0x23afd0,_0x3ec32d):undefined;if(_0x19be0f)_0x39829e[_0x1e666c(0x259)]({'jid':_0x3ec32d,'participants':_0x19be0f[_0x1e666c(0xe8)+'ts'][_0x1e666c(0x162)]},_0xe61015[_0x1e666c(0x25f)]);else!_0x4a666e&&(_0x19be0f=await _0xe61015[_0x1e666c(0xe3)](_0x1ec700,_0x3ec32d));return _0x19be0f;})()),((async()=>{const _0x19dce4=_0x5b446d;if(_0xe61015[_0x19dce4(0x234)](!_0x1be240,!_0x4a666e)){const _0x35043b=await _0x124474[_0x19dce4(0x2bc)][_0x19dce4(0x10b)](_0xe61015[_0x19dce4(0x2a2)],[_0x3ec32d]);return _0x35043b[_0x3ec32d]||{};}return{};})())]);if(!_0x1be240){const _0x3eae8d=_0x4de253[_0x5b446d(0x1b5)](_0x40daf2,!_0x4a666e)?_0x40daf2[_0x5b446d(0xe8)+'ts'][_0x5b446d(0x137)](_0x535f22=>_0x535f22['id']):[];_0x4de253[_0x5b446d(0x1b5)](_0x4a666e,_0x369ada)&&_0x3eae8d[_0x5b446d(0x13d)](..._0x369ada);const _0x3bd2c7=await _0x4de253[_0x5b446d(0x2b0)](_0x4fce3d,_0x3eae8d,!!_0x229cae,![]);_0x257fe6[_0x5b446d(0x13d)](..._0x3bd2c7);}const _0x526f4f=await _0x4de253[_0x5b446d(0x115)](_0x22394f,_0x59f012,_0x257fe6[_0x5b446d(0x137)](_0xda0d50=>WABinary_1[_0x5b446d(0x2a4)](_0xda0d50[_0x5b446d(0x1d1)],_0x26003e?_0x5b446d(0xef):_0x5b446d(0x21d)+_0x5b446d(0x216),_0xda0d50[_0x5b446d(0x2c2)]))),_0x257811=Utils_1[_0x5b446d(0x1ff)+_0x5b446d(0x258)](_0x526f4f),{ciphertext:_0x23175d,senderKeyDistributionMessage:_0x59f31b}=await _0x107fb5[_0x5b446d(0x183)+_0x5b446d(0x1c5)]({'group':_0x1de178,'data':_0x257811,'meId':_0x17e907}),_0x14306a=[];for(const {user:_0x28e353,device:_0x2fc357}of _0x257fe6){const _0x576f65=WABinary_1[_0x5b446d(0x2a4)](_0x28e353,_0x4de253[_0x5b446d(0x1ad)](_0x4de253[_0x5b446d(0x208)](_0x40daf2,null)||_0x4de253[_0x5b446d(0x1ad)](_0x40daf2,void(0x11f*-0x18+0x39*-0x6+0x1c3e))?void(0x1*-0x212+-0xa6*-0x16+-0x1be*0x7):_0x40daf2[_0x5b446d(0x10c)+_0x5b446d(0x135)],_0x4de253[_0x5b446d(0x1c0)])?_0x4de253[_0x5b446d(0x1c0)]:_0x4de253[_0x5b446d(0x2a8)],_0x2fc357);(!_0x34019a[_0x576f65]||!!_0x1be240)&&(_0x14306a[_0x5b446d(0x13d)](_0x576f65),_0x34019a[_0x576f65]=!![]);}if(_0x14306a[_0x5b446d(0x162)]){_0x39829e[_0x5b446d(0x149)]({'senderKeyJids':_0x14306a},_0x4de253[_0x5b446d(0x20e)]);const _0x2c7155={'senderKeyDistributionMessage':{'axolotlSenderKeyDistributionMessage':_0x59f31b,'groupId':_0x1de178}};await _0x4de253[_0x5b446d(0x28d)](_0x301841,_0x14306a,![]);const _0x1a376f=await _0x4de253[_0x5b446d(0x2cb)](_0x3ced5e,_0x14306a,_0x2c7155,_0x448ebe);_0x3da8a6=_0x3da8a6||_0x1a376f[_0x5b446d(0x279)+_0x5b446d(0x28a)+_0x5b446d(0x19b)],_0x42ac3b[_0x5b446d(0x13d)](..._0x1a376f[_0x5b446d(0x1e5)]);}_0x311059[_0x5b446d(0x13d)]({'tag':_0x4de253[_0x5b446d(0x25b)],'attrs':{'v':'2','type':_0x4de253[_0x5b446d(0x19f)],..._0x448ebe},'content':_0x23175d}),await _0x124474[_0x5b446d(0x2bc)][_0x5b446d(0x168)]({'sender-key-memory':{[_0x3ec32d]:_0x34019a}});}else{if(_0x2e78e){_0x59f012[_0x5b446d(0x1bf)+_0x5b446d(0x258)]?.[_0x5b446d(0x11e)+_0x5b446d(0x276)]&&(_0x261fd3=_0x59f012[_0x5b446d(0x1bf)+_0x5b446d(0x258)][_0x5b446d(0xff)]?.['id'],_0x59f012=_0x59f012[_0x5b446d(0x1bf)+_0x5b446d(0x258)][_0x5b446d(0x11e)+_0x5b446d(0x276)]);_0x4de253[_0x5b446d(0x170)](_0x59f012[_0x5b446d(0x1bf)+_0x5b446d(0x258)]?.[_0x5b446d(0x1ef)],WAProto_1[_0x5b446d(0x23c)][_0x5b446d(0x1e8)][_0x5b446d(0x2b9)+_0x5b446d(0x258)][_0x5b446d(0x231)][_0x5b446d(0x24a)])&&(_0x261fd3=_0x59f012[_0x5b446d(0x1bf)+_0x5b446d(0x258)][_0x5b446d(0xff)]?.['id'],_0x59f012={});const _0x20fc1c=await _0x4de253[_0x5b446d(0x1f2)](_0x22394f,_0x59f012,[]),_0x5ab538=Utils_1[_0x5b446d(0x14e)+_0x5b446d(0x1a9)+_0x5b446d(0x276)](_0x20fc1c);_0x311059[_0x5b446d(0x13d)]({'tag':_0x4de253[_0x5b446d(0x227)],'attrs':_0x448ebe?_0x448ebe:{},'content':_0x5ab538});}else{const {user:_0x1cbf16}=WABinary_1[_0x5b446d(0x2de)](_0x17e907);if(!_0x1be240){_0x257fe6[_0x5b446d(0x13d)]({'user':_0x35a6d1});_0x4de253[_0x5b446d(0x2ba)](_0x35a6d1,_0x1cbf16)&&_0x257fe6[_0x5b446d(0x13d)]({'user':_0x1cbf16});if(_0x4de253[_0x5b446d(0x261)](_0x544250?.[_0x4de253[_0x5b446d(0x147)]],_0x4de253[_0x5b446d(0x26f)])){const _0x5c0c57=await _0x4de253[_0x5b446d(0x2a3)](_0x4fce3d,[_0x17e907,_0x3ec32d],!!_0x229cae,!![]);_0x257fe6[_0x5b446d(0x13d)](..._0x5c0c57);}}const _0x190060=[],_0xe8844c=[],_0x30deda=[];for(const {user:_0x2e96d9,device:_0x79ae37}of _0x257fe6){const _0x40a626=_0x4de253[_0x5b446d(0x2e6)](_0x2e96d9,_0x1cbf16),_0x2b36d6=WABinary_1[_0x5b446d(0x2a4)](_0x4de253[_0x5b446d(0x1fd)](_0x40a626,_0x26003e)?_0x124474[_0x5b446d(0x2a1)]?.['me']?.[_0x5b446d(0xef)]?.[_0x5b446d(0x167)](':')[0xedb+0x98b+-0x1866]||_0x2e96d9:_0x2e96d9,_0x26003e?_0x4de253[_0x5b446d(0x1c0)]:_0x4de253[_0x5b446d(0x2a8)],_0x79ae37);_0x40a626?_0xe8844c[_0x5b446d(0x13d)](_0x2b36d6):_0x30deda[_0x5b446d(0x13d)](_0x2b36d6),_0x190060[_0x5b446d(0x13d)](_0x2b36d6);}await _0x4de253[_0x5b446d(0x1f2)](_0x301841,_0x190060,![]);const [{nodes:_0x308197,shouldIncludeDeviceIdentity:_0x2f4a45},{nodes:_0x2e7641,shouldIncludeDeviceIdentity:_0x7d1fa3}]=await Promise[_0x5b446d(0x18a)]([_0x4de253[_0x5b446d(0x22d)](_0x3ced5e,_0xe8844c,_0x4c5956,_0x448ebe),_0x4de253[_0x5b446d(0x2b0)](_0x3ced5e,_0x30deda,_0x59f012,_0x448ebe)]);_0x42ac3b[_0x5b446d(0x13d)](..._0x308197),_0x42ac3b[_0x5b446d(0x13d)](..._0x2e7641),_0x3da8a6=_0x4de253[_0x5b446d(0x173)](_0x3da8a6,_0x2f4a45)||_0x7d1fa3;}}if(_0x42ac3b[_0x5b446d(0x162)]){if(_0x4de253[_0x5b446d(0x208)](_0x544250?.[_0x4de253[_0x5b446d(0x147)]],_0x4de253[_0x5b446d(0x26f)])){const _0x469b87=_0x42ac3b[-0x265*0x7+0x71e+0x9a5]?.[_0x5b446d(0x2b4)]?.[0x1f93+0xd5b+0xa2*-0x47];_0x469b87&&_0x311059[_0x5b446d(0x13d)](_0x469b87);}else _0x311059[_0x5b446d(0x13d)]({'tag':_0x4de253[_0x5b446d(0x158)],'attrs':{},'content':_0x42ac3b});}const _0x375a87={'tag':_0x4de253[_0x5b446d(0x12c)],'attrs':{'id':_0x261fd3,'type':_0x4de253[_0x5b446d(0x16c)](_0x529638,_0x294254),..._0x4de253[_0x5b446d(0x157)](_0x544250,{})},'content':_0x311059};if(_0x1be240){if(WABinary_1[_0x5b446d(0x2b3)](_0x1de178))_0x375a87[_0x5b446d(0x159)]['to']=_0x1de178,_0x375a87[_0x5b446d(0x159)][_0x5b446d(0xe8)+'t']=_0x1be240[_0x5b446d(0x22a)];else WABinary_1[_0x5b446d(0xe2)+_0x5b446d(0x146)](_0x1be240[_0x5b446d(0x22a)],_0x17e907)?(_0x375a87[_0x5b446d(0x159)]['to']=_0x1be240[_0x5b446d(0x22a)],_0x375a87[_0x5b446d(0x159)][_0x5b446d(0x237)]=_0x1de178):_0x375a87[_0x5b446d(0x159)]['to']=_0x1be240[_0x5b446d(0x22a)];}else _0x375a87[_0x5b446d(0x159)]['to']=_0x1de178;_0x3da8a6&&(_0x375a87[_0x5b446d(0x2b4)][_0x5b446d(0x13d)]({'tag':_0x4de253[_0x5b446d(0x116)],'attrs':{},'content':(0x1*-0x1f19+-0x3*-0x545+0x1*0xf4a,Utils_1[_0x5b446d(0xed)+_0x5b446d(0x105)+_0x5b446d(0x15d)])(_0x124474[_0x5b446d(0x2a1)][_0x5b446d(0x181)],!![])}),_0x39829e[_0x5b446d(0x149)]({'jid':_0x3ec32d},_0x4de253[_0x5b446d(0x1b6)]));if(_0x4de253[_0x5b446d(0xf3)](AI,_0x451a84)){const _0x34659a={'tag':_0x4de253[_0x5b446d(0x1db)],'attrs':{'biz_bot':'1'}},_0x20f788=WABinary_1[_0x5b446d(0x19d)+_0x5b446d(0x151)](_0xadcfa0?_0xadcfa0:[]);_0x20f788?(_0x375a87[_0x5b446d(0x2b4)][_0x5b446d(0x13d)](..._0xadcfa0),_0x3d3c94=!![]):_0x375a87[_0x5b446d(0x2b4)][_0x5b446d(0x13d)](_0x34659a);}if(_0x4de253[_0x5b446d(0x131)](!_0x2e78e,_0x3c3549)&&!_0x4a666e){const _0x10b9ce=WABinary_1[_0x5b446d(0x1dc)+_0x5b446d(0x177)](_0x3c3549),_0x43faa6=WABinary_1[_0x5b446d(0x19d)+_0x5b446d(0x151)](_0xadcfa0);_0x43faa6?(_0x3d3c94=!![],_0x375a87[_0x5b446d(0x2b4)][_0x5b446d(0x13d)](..._0xadcfa0)):_0x375a87[_0x5b446d(0x2b4)][_0x5b446d(0x13d)](..._0x10b9ce),_0x39829e[_0x5b446d(0x149)]({'jid':_0x3ec32d},_0x4de253[_0x5b446d(0x27e)]);}_0x4de253[_0x5b446d(0x1b5)](!_0x3d3c94,_0xadcfa0)&&_0x4de253[_0x5b446d(0x17c)](_0xadcfa0[_0x5b446d(0x162)],0x10*0x2c+0xad*-0x2e+0x1c56)&&_0x375a87[_0x5b446d(0x2b4)][_0x5b446d(0x13d)](..._0xadcfa0),_0x39829e[_0x5b446d(0x149)]({'msgId':_0x261fd3},_0x5b446d(0x2f4)+_0x5b446d(0x133)+_0x42ac3b[_0x5b446d(0x162)]+_0x5b446d(0x215)),await _0x4de253[_0x5b446d(0x16c)](_0x1c4d60,_0x375a87);}),_0x59f012=Types_1[_0x273b5f(0x1b2)][_0x273b5f(0x1e8)][_0x273b5f(0x1bc)](_0x59f012);const _0x1dc641={'key':{'remoteJid':_0x3ec32d,'fromMe':!![],'id':_0x261fd3},'message':_0x59f012,'messageTimestamp':Utils_1[_0x273b5f(0x293)+_0x273b5f(0x124)](new Date()),'messageStubParameters':[],'participant':WABinary_1[_0x273b5f(0x2b3)](_0x3ec32d)||WABinary_1[_0x273b5f(0x272)+_0x273b5f(0x2d7)](_0x3ec32d)?_0x17e907:undefined,'status':Types_1[_0x273b5f(0x220)+_0x273b5f(0x1ae)][_0x273b5f(0x23a)]};return Types_1[_0x273b5f(0x1b2)][_0x273b5f(0x23d)+_0x273b5f(0x120)][_0x273b5f(0x1bc)](_0x1dc641);},_0x529638=_0x16d4cf=>{const _0x8a6d81=_0x1ef4f5,_0x3ec052=Utils_1[_0x8a6d81(0x229)+_0x8a6d81(0x23b)+_0x8a6d81(0x289)](_0x16d4cf);if(_0x3ec052[_0x8a6d81(0x2e7)+_0x8a6d81(0x258)])return _0x4de253[_0x8a6d81(0x179)];else return _0x4de253[_0x8a6d81(0x119)](_0x98abee,_0x3ec052)?_0x4de253[_0x8a6d81(0x152)]:_0x4de253[_0x8a6d81(0x136)];},_0x98abee=_0x4fc7ff=>{const _0x2e1ac5=_0x1ef4f5;if(_0x4fc7ff[_0x2e1ac5(0xf6)+'ge'])return _0x4de253[_0x2e1ac5(0x28b)];else{if(_0x4fc7ff[_0x2e1ac5(0x28f)+'ge'])return _0x4fc7ff[_0x2e1ac5(0x28f)+'ge'][_0x2e1ac5(0x10a)+'k']?_0x4de253[_0x2e1ac5(0x1c9)]:_0x4de253[_0x2e1ac5(0x1e3)];else{if(_0x4fc7ff[_0x2e1ac5(0xfd)+'ge'])return _0x4fc7ff[_0x2e1ac5(0xfd)+'ge'][_0x2e1ac5(0x296)]?_0x4de253[_0x2e1ac5(0x1aa)]:_0x4de253[_0x2e1ac5(0x153)];else{if(_0x4fc7ff[_0x2e1ac5(0x204)+_0x2e1ac5(0x28e)])return _0x4de253[_0x2e1ac5(0x298)];else{if(_0x4fc7ff[_0x2e1ac5(0x299)+_0x2e1ac5(0x258)])return _0x4de253[_0x2e1ac5(0x172)];else{if(_0x4fc7ff[_0x2e1ac5(0x205)+_0x2e1ac5(0x1af)])return _0x4de253[_0x2e1ac5(0x2e0)];else{if(_0x4fc7ff[_0x2e1ac5(0x128)+_0x2e1ac5(0x254)])return _0x4de253[_0x2e1ac5(0x16b)];else{if(_0x4fc7ff[_0x2e1ac5(0x150)+_0x2e1ac5(0x28e)])return _0x4de253[_0x2e1ac5(0x1d3)];else{if(_0x4fc7ff[_0x2e1ac5(0x1b4)+'e'])return _0x4de253[_0x2e1ac5(0x174)];else{if(_0x4fc7ff[_0x2e1ac5(0x2d3)+_0x2e1ac5(0x104)])return _0x4de253[_0x2e1ac5(0x2ac)];else{if(_0x4fc7ff[_0x2e1ac5(0x2eb)+_0x2e1ac5(0x21f)+'ge'])return _0x4de253[_0x2e1ac5(0x134)];else{if(_0x4fc7ff[_0x2e1ac5(0x2d5)+'ge'])return _0x4de253[_0x2e1ac5(0x278)];else{if(_0x4fc7ff[_0x2e1ac5(0x2f1)+_0x2e1ac5(0x28e)])return _0x4de253[_0x2e1ac5(0x1bb)];else{if(_0x4fc7ff[_0x2e1ac5(0x1c1)+_0x2e1ac5(0x156)+_0x2e1ac5(0x122)])return _0x4de253[_0x2e1ac5(0xe1)];else{if(_0x4fc7ff[_0x2e1ac5(0x27d)+_0x2e1ac5(0x2d6)])return _0x4de253[_0x2e1ac5(0x166)];else{if(/https:\/\/wa\.me\/p\/\d+\/\d+/[_0x2e1ac5(0x21c)](_0x4fc7ff[_0x2e1ac5(0x17e)+_0x2e1ac5(0x114)]?.[_0x2e1ac5(0x1ec)]))return _0x4de253[_0x2e1ac5(0x2dd)];}}}}}}}}}}}}}}}},_0xa07f09=_0x17b379=>{const _0x57a5b7=_0x1ef4f5;if(_0x17b379[_0x57a5b7(0x1b4)+'e'])return _0x4de253[_0x57a5b7(0x174)];else{if(_0x17b379[_0x57a5b7(0x2e2)+_0x57a5b7(0x28e)])return _0x4de253[_0x57a5b7(0x11b)];else{if(_0x4de253[_0x57a5b7(0x26c)](_0x17b379[_0x57a5b7(0x1c1)+_0x57a5b7(0x2d6)]?.[_0x57a5b7(0x17b)+_0x57a5b7(0x1e8)]?.[_0x57a5b7(0x219)]?.[-0x2*0xd7f+-0x17e3*0x1+0x1*0x32e1]?.[_0x57a5b7(0x20d)],_0x4de253[_0x57a5b7(0x285)]))return _0x4de253[_0x57a5b7(0x285)];else{if(_0x4de253[_0x57a5b7(0x242)](_0x17b379[_0x57a5b7(0x1c1)+_0x57a5b7(0x2d6)]?.[_0x57a5b7(0x17b)+_0x57a5b7(0x1e8)]?.[_0x57a5b7(0x219)]?.[0xaec+0x1ea+0x1f*-0x6a]?.[_0x57a5b7(0x20d)],_0x4de253[_0x57a5b7(0x287)]))return _0x4de253[_0x57a5b7(0x287)];else{if(_0x4de253[_0x57a5b7(0x20b)](_0x17b379[_0x57a5b7(0x1c1)+_0x57a5b7(0x2d6)]?.[_0x57a5b7(0x17b)+_0x57a5b7(0x1e8)]?.[_0x57a5b7(0x219)]?.[0xb*0x373+0x110+-0x2701*0x1]?.[_0x57a5b7(0x20d)],_0x4de253[_0x57a5b7(0x2ea)]))return _0x4de253[_0x57a5b7(0x2ea)];else{if(_0x4de253[_0x57a5b7(0x2ef)](_0x17b379[_0x57a5b7(0x1c1)+_0x57a5b7(0x2d6)]?.[_0x57a5b7(0x17b)+_0x57a5b7(0x1e8)]?.[_0x57a5b7(0x219)]?.[0x118a+-0x211*-0x5+-0x1bdf]?.[_0x57a5b7(0x20d)],_0x4de253[_0x57a5b7(0x1d8)]))return _0x4de253[_0x57a5b7(0x1d8)];else{if(_0x4de253[_0x57a5b7(0x269)](_0x17b379[_0x57a5b7(0x1c1)+_0x57a5b7(0x2d6)]?.[_0x57a5b7(0x17b)+_0x57a5b7(0x1e8)]?.[_0x57a5b7(0x219)]?.[-0xc48+0x3d1+0x877*0x1]?.[_0x57a5b7(0x20d)],_0x4de253[_0x57a5b7(0x233)]))return _0x4de253[_0x57a5b7(0x233)];else{if(_0x17b379[_0x57a5b7(0x1c1)+_0x57a5b7(0x2d6)]&&_0x17b379[_0x57a5b7(0x1c1)+_0x57a5b7(0x2d6)]?.[_0x57a5b7(0x17b)+_0x57a5b7(0x1e8)])return _0x4de253[_0x57a5b7(0x126)];else{if(_0x17b379[_0x57a5b7(0x1c1)+_0x57a5b7(0x2d6)]?.[_0x57a5b7(0x17b)+_0x57a5b7(0x1e8)])return _0x4de253[_0x57a5b7(0x1e2)];}}}}}}}}},_0x333340=async _0x582e8b=>{const _0x5836da=_0x1ef4f5,_0x778c41=Utils_1[_0x5836da(0x293)+_0x5836da(0x124)]()[_0x5836da(0x1ee)](),_0x41d69d=await _0x4de253[_0x5836da(0x129)](_0x4eb6b3,{'tag':'iq','attrs':{'to':WABinary_1[_0x5836da(0x1b0)+_0x5836da(0xe6)],'type':_0x4de253[_0x5836da(0x20a)],'xmlns':_0x4de253[_0x5836da(0x223)]},'content':[{'tag':_0x4de253[_0x5836da(0x1c8)],'attrs':{},'content':_0x582e8b[_0x5836da(0x137)](_0x1cc48d=>({'tag':_0x5836da(0x184),'attrs':{'jid':WABinary_1[_0x5836da(0x1b7)+_0x5836da(0x274)](_0x1cc48d),'t':_0x778c41,'type':_0x5836da(0x2dc)+_0x5836da(0xf9)}}))}]});return _0x41d69d;},_0x1c3632=(0xb73*0x2+-0x1666+-0x80,Utils_1[_0x1ef4f5(0x18b)+_0x1ef4f5(0x1f9)])(_0x353224,_0x3ce66c),_0x20214e=new hbmodsofc(Utils_1,_0x1c3632,_0x469f2d),_0x583524=(0xe2b+-0xb5*-0x8+-0x13d3,Utils_1[_0x1ef4f5(0x118)+_0x1ef4f5(0x286)])(_0x7846ba,_0x4de253[_0x1ef4f5(0x15e)]);return{..._0x15f9ed,'getPrivacyTokens':_0x333340,'assertSessions':_0x301841,'relayMessage':_0x469f2d,'sendReceipt':_0x43f701,'sendReceipts':_0x4e462b,'rahmi':_0x20214e,'readMessages':_0x1dd188,'refreshMediaConn':_0x3ce66c,'getUSyncDevices':_0x4fce3d,'createParticipantNodes':_0x3ced5e,'waUploadToServer':_0x1c3632,'sendPeerDataOperationMessage':_0x58053a,'fetchPrivacySettings':_0x43c42b,'updateMediaMessage':async _0x4d5501=>{const _0xf0b56e=_0x1ef4f5,_0xc60282={'wODEP':function(_0x486508,_0x288495){const _0x4a0f59=_0x2b16;return _0x4de253[_0x4a0f59(0x252)](_0x486508,_0x288495);},'joEDW':_0x4de253[_0xf0b56e(0x262)]},_0x164651=(0x41*0x71+0xa4+-0x1d55,Utils_1[_0xf0b56e(0x1c4)+_0xf0b56e(0x1bd)])(_0x4d5501[_0xf0b56e(0x22e)]),_0x5ee254=_0x164651[_0xf0b56e(0x268)],_0x3b922a=_0x124474[_0xf0b56e(0x2a1)]['me']['id'],_0x12c922=(-0x2551+-0x1d58+0x42a9,Utils_1[_0xf0b56e(0x125)+_0xf0b56e(0x2c3)+_0xf0b56e(0x250)])(_0x4d5501[_0xf0b56e(0xff)],_0x5ee254,_0x3b922a);let _0x5511ea=undefined;await Promise[_0xf0b56e(0x18a)]([_0x4de253[_0xf0b56e(0x119)](_0x1c4d60,_0x12c922),_0x4de253[_0xf0b56e(0x240)](_0x583524,_0x3ad89a=>{const _0x426507=_0xf0b56e,_0x3beec5=_0x3ad89a[_0x426507(0x2c0)](_0x3fa69a=>_0x3fa69a[_0x426507(0xff)]['id']===_0x4d5501[_0x426507(0xff)]['id']);if(_0x3beec5){if(_0x3beec5[_0x426507(0x247)])_0x5511ea=_0x3beec5[_0x426507(0x247)];else try{const _0x24de7b=(-0xeb5+-0x3*-0xc26+-0x459*0x5,Utils_1[_0x426507(0x13c)+_0x426507(0x12f)+'a'])(_0x3beec5[_0x426507(0x19a)],_0x5ee254,_0x3beec5[_0x426507(0xff)]['id']);if(_0xc60282[_0x426507(0x117)](_0x24de7b[_0x426507(0x249)],WAProto_1[_0x426507(0x23c)][_0x426507(0x1a1)+_0x426507(0x165)+'on'][_0x426507(0x11c)][_0x426507(0xeb)])){const _0x4d9a8c=WAProto_1[_0x426507(0x23c)][_0x426507(0x1a1)+_0x426507(0x165)+'on'][_0x426507(0x11c)][_0x24de7b[_0x426507(0x249)]];throw new boom_1[(_0x426507(0x15c))](_0x426507(0x22f)+_0x426507(0x27c)+_0x426507(0x282)+_0x426507(0x280)+_0x4d9a8c+')',{'data':_0x24de7b,'statusCode':(-0x2b*-0x22+0x2*-0x213+-0x2*0xc8,Utils_1[_0x426507(0x248)+_0x426507(0x2ca)+_0x426507(0x11d)])(_0x24de7b[_0x426507(0x249)])||0x1d*0x118+-0x153f+-0x8e5});}_0x164651[_0x426507(0x1ac)]=_0x24de7b[_0x426507(0x1ac)],_0x164651[_0x426507(0x2d8)]=(-0x8*-0x2ba+-0x1843+0x273,Utils_1[_0x426507(0x284)+_0x426507(0x185)])(_0x164651[_0x426507(0x1ac)]),_0x39829e[_0x426507(0x149)]({'directPath':_0x24de7b[_0x426507(0x1ac)],'key':_0x3beec5[_0x426507(0xff)]},_0xc60282[_0x426507(0xf4)]);}catch(_0x40b11f){_0x5511ea=_0x40b11f;}return!![];}})]);if(_0x5511ea)throw _0x5511ea;return _0x7846ba[_0xf0b56e(0xfc)](_0x4de253[_0xf0b56e(0x12e)],[{'key':_0x4d5501[_0xf0b56e(0xff)],'update':{'message':_0x4d5501[_0xf0b56e(0x22e)]}}]),_0x4d5501;},'sendMessage':async(_0x54a4ea,_0x5ea3eb,_0x56b3e8={})=>{const _0x37346e=_0x1ef4f5,_0x4a876a=_0x124474[_0x37346e(0x2a1)]['me']['id'];delete _0x56b3e8[_0x37346e(0x1ce)+_0x37346e(0x1c7)];const {filter:filter=![],quoted:_0xb3e4f2}=_0x56b3e8,_0x157e50=()=>filter?{'participant':{'jid':_0x54a4ea}}:{},_0xbead3e=_0x20214e[_0x37346e(0x2c5)](_0x5ea3eb);if(_0x4de253[_0x37346e(0x2f6)](typeof _0x5ea3eb,_0x4de253[_0x37346e(0x1ba)])&&_0x4de253[_0x37346e(0x283)](_0x4de253[_0x37346e(0x1dd)],_0x5ea3eb)&&_0x4de253[_0x37346e(0x2ba)](typeof _0x5ea3eb[_0x4de253[_0x37346e(0x1dd)]],_0x4de253[_0x37346e(0x191)])&&WABinary_1[_0x37346e(0x2b3)](_0x54a4ea)){const {disappearingMessagesInChat:_0x230926}=_0x5ea3eb,_0x22e9ed=_0x4de253[_0x37346e(0x213)](typeof _0x230926,_0x4de253[_0x37346e(0x2c9)])?_0x230926?Defaults_1[_0x37346e(0x25e)+_0x37346e(0x12d)]:-0x1a*0x167+0x10e5+0x1391:_0x230926;await _0x4de253[_0x37346e(0x115)](_0x3f4ffb,_0x54a4ea,_0x22e9ed);}else{let _0x6873e9;if(_0xbead3e)switch(_0xbead3e){case _0x4de253[_0x37346e(0xf7)]:const _0xecbd58=await _0x20214e[_0x37346e(0x1a4)+_0x37346e(0x289)](_0x5ea3eb,_0xb3e4f2);return await _0x4de253[_0x37346e(0x13e)](_0x469f2d,_0x54a4ea,_0xecbd58,{'messageId':Utils_1[_0x37346e(0x21b)+_0x37346e(0x21a)](),..._0x4de253[_0x37346e(0x1f7)](_0x157e50)});case _0x4de253[_0x37346e(0x200)]:const _0x3ae2bc=await _0x20214e[_0x37346e(0x110)+_0x37346e(0x182)](_0x5ea3eb,_0x54a4ea,_0xb3e4f2),_0x685cbc=await Utils_1[_0x37346e(0xe4)+_0x37346e(0x2f0)+_0x37346e(0x145)](_0x54a4ea,_0x3ae2bc,{'quoted':_0xb3e4f2});return await _0x4de253[_0x37346e(0x2cb)](_0x469f2d,_0x54a4ea,_0x685cbc[_0x37346e(0x22e)],{'messageId':_0x685cbc[_0x37346e(0xff)]['id'],..._0x4de253[_0x37346e(0x1f7)](_0x157e50)});case _0x4de253[_0x37346e(0x193)]:const _0x178e1f=await _0x20214e[_0x37346e(0x2e1)+_0x37346e(0x201)](_0x5ea3eb,_0x54a4ea,_0xb3e4f2),_0x366c77=await Utils_1[_0x37346e(0xe4)+_0x37346e(0x2f0)+_0x37346e(0x145)](_0x54a4ea,_0x178e1f,{'quoted':_0xb3e4f2});return await _0x4de253[_0x37346e(0x1a2)](_0x469f2d,_0x54a4ea,_0x366c77[_0x37346e(0x22e)],{'messageId':_0x366c77[_0x37346e(0xff)]['id'],..._0x4de253[_0x37346e(0x1f7)](_0x157e50)});case _0x4de253[_0x37346e(0x28c)]:return await _0x20214e[_0x37346e(0x106)+'m'](_0x5ea3eb,_0x54a4ea,_0xb3e4f2);case _0x4de253[_0x37346e(0x2ce)]:return await _0x20214e[_0x37346e(0x1d7)+'t'](_0x5ea3eb,_0x54a4ea,_0xb3e4f2);case _0x4de253[_0x37346e(0x10d)]:return await _0x20214e[_0x37346e(0x111)+_0x37346e(0x16e)](_0x5ea3eb,_0x54a4ea,_0xb3e4f2);case _0x4de253[_0x37346e(0x203)]:return await _0x20214e[_0x37346e(0x2c1)+_0x37346e(0x1ed)](_0x5ea3eb,_0x54a4ea,_0xb3e4f2);}const _0x547c20=await Utils_1[_0x37346e(0xe4)+_0x37346e(0x1e8)](_0x54a4ea,_0x5ea3eb,{'logger':_0x39829e,'userJid':_0x4a876a,'quoted':_0xb3e4f2,'getUrlInfo':_0x27a551=>link_preview_1[_0x37346e(0x2a7)](_0x27a551,{'thumbnailWidth':_0x56e979,'fetchOpts':{'timeout':0xbb8,..._0x217d6d||{}},'logger':_0x39829e,'uploadImage':_0x25318f?_0x1c3632:undefined}),'upload':async(_0x3e8ba1,_0x4360a1)=>{const _0x6c62d2=_0x37346e,_0x289c50=await _0x4de253[_0x6c62d2(0x12b)](_0x1c3632,_0x3e8ba1,{..._0x4360a1,'newsletter':WABinary_1[_0x6c62d2(0x2cf)+_0x6c62d2(0x171)](_0x54a4ea)});return _0x289c50;},'mediaCache':_0x353224[_0x37346e(0x188)],'options':_0x353224[_0x37346e(0x2b2)],..._0x56b3e8}),_0x14020c=_0x4de253[_0x37346e(0x130)](_0x4de253[_0x37346e(0x214)],_0x5ea3eb)&&!!_0x5ea3eb[_0x37346e(0x228)],_0x190d76=_0x4de253[_0x37346e(0x283)](_0x4de253[_0x37346e(0xe7)],_0x5ea3eb)&&!!_0x5ea3eb[_0x37346e(0x1eb)],_0x456218=_0x4de253[_0x37346e(0x195)]('ai',_0x5ea3eb)&&!!_0x5ea3eb['ai'],_0x38a6a8={},_0x15d58e=[];if(_0x14020c){const _0x4c711a=_0x5ea3eb[_0x37346e(0x228)]?.[_0x37346e(0x2c4)],_0x1a34a9=WABinary_1[_0x37346e(0x2b3)](_0x5ea3eb[_0x37346e(0x228)]?.[_0x37346e(0x180)]);_0x38a6a8[_0x37346e(0x1eb)]=_0x4de253[_0x37346e(0x292)](_0x1a34a9,!_0x4c711a)||WABinary_1[_0x37346e(0x2cf)+_0x37346e(0x171)](_0x54a4ea)?'8':'7';}else{if(_0x190d76)_0x38a6a8[_0x37346e(0x1eb)]=WABinary_1[_0x37346e(0x2cf)+_0x37346e(0x171)](_0x54a4ea)?'3':'1';else _0x456218&&_0x15d58e[_0x37346e(0x13d)]({'attrs':{'biz_bot':'1'},'tag':_0x4de253[_0x37346e(0x1db)]});}return await _0x4de253[_0x37346e(0x2ee)](_0x469f2d,_0x54a4ea,_0x547c20[_0x37346e(0x22e)],{'messageId':_0x547c20[_0x37346e(0xff)]['id'],'cachedGroupMetadata':_0x56b3e8[_0x37346e(0x29f)+_0x37346e(0x1f5)],'additionalNodes':_0x456218?_0x15d58e:_0x56b3e8[_0x37346e(0x14a)+_0x37346e(0x207)],'additionalAttributes':_0x38a6a8,'statusJidList':_0x56b3e8[_0x37346e(0x154)+_0x37346e(0x1c3)]}),_0x353224[_0x37346e(0x11a)+_0x37346e(0x26d)]&&process[_0x37346e(0x1a3)](()=>{const _0x49e01d=_0x37346e;_0x497651[_0x49e01d(0x189)](()=>_0x4aee35(_0x547c20,_0x49e01d(0x148)));}),_0x547c20;}}};};exports[_0x1f2311(0x2b5)+_0x1f2311(0x206)]=makeMessagesSocket;
|
|
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.makeMessagesSocket = void 0;
|
|
7
|
+
const node_cache_1 = __importDefault(require("@cacheable/node-cache"));
|
|
8
|
+
const boom_1 = require("@hapi/boom");
|
|
9
|
+
const index_js_1 = require("../../WAProto/index.js");
|
|
10
|
+
const Defaults_1 = require("../Defaults");
|
|
11
|
+
const Types_1 = require("../Types");
|
|
12
|
+
const Utils_1 = require("../Utils");
|
|
13
|
+
const link_preview_1 = require("../Utils/link-preview");
|
|
14
|
+
const make_mutex_1 = require("../Utils/make-mutex");
|
|
15
|
+
const WABinary_1 = require("../WABinary");
|
|
16
|
+
const WAUSync_1 = require("../WAUSync");
|
|
17
|
+
const newsletter_1 = require("./newsletter");
|
|
18
|
+
const makeMessagesSocket = (config) => {
|
|
19
|
+
const { logger, linkPreviewImageThumbnailWidth, generateHighQualityLinkPreview, options: axiosOptions, patchMessageBeforeSending, cachedGroupMetadata, enableRecentMessageCache, maxMsgRetryCount } = config;
|
|
20
|
+
const sock = (0, newsletter_1.makeNewsletterSocket)(config);
|
|
21
|
+
const { ev, authState, processingMutex, signalRepository, upsertMessage, query, fetchPrivacySettings, sendNode, groupMetadata, groupToggleEphemeral } = sock;
|
|
22
|
+
const userDevicesCache = config.userDevicesCache ||
|
|
23
|
+
new node_cache_1.default({
|
|
24
|
+
stdTTL: Defaults_1.DEFAULT_CACHE_TTLS.USER_DEVICES, // 5 minutes
|
|
25
|
+
useClones: false
|
|
26
|
+
});
|
|
27
|
+
// Initialize message retry manager if enabled
|
|
28
|
+
const messageRetryManager = enableRecentMessageCache ? new Utils_1.MessageRetryManager(logger, maxMsgRetryCount) : null;
|
|
29
|
+
// Prevent race conditions in Signal session encryption by user
|
|
30
|
+
const encryptionMutex = (0, make_mutex_1.makeKeyedMutex)();
|
|
31
|
+
let mediaConn;
|
|
32
|
+
const refreshMediaConn = async (forceGet = false) => {
|
|
33
|
+
const media = await mediaConn;
|
|
34
|
+
if (!media || forceGet || new Date().getTime() - media.fetchDate.getTime() > media.ttl * 1000) {
|
|
35
|
+
mediaConn = (async () => {
|
|
36
|
+
const result = await query({
|
|
37
|
+
tag: 'iq',
|
|
38
|
+
attrs: {
|
|
39
|
+
type: 'set',
|
|
40
|
+
xmlns: 'w:m',
|
|
41
|
+
to: WABinary_1.S_WHATSAPP_NET
|
|
42
|
+
},
|
|
43
|
+
content: [{ tag: 'media_conn', attrs: {} }]
|
|
44
|
+
});
|
|
45
|
+
const mediaConnNode = (0, WABinary_1.getBinaryNodeChild)(result, 'media_conn');
|
|
46
|
+
const node = {
|
|
47
|
+
hosts: (0, WABinary_1.getBinaryNodeChildren)(mediaConnNode, 'host').map(({ attrs }) => ({
|
|
48
|
+
hostname: attrs.hostname,
|
|
49
|
+
maxContentLengthBytes: +attrs.maxContentLengthBytes
|
|
50
|
+
})),
|
|
51
|
+
auth: mediaConnNode.attrs.auth,
|
|
52
|
+
ttl: +mediaConnNode.attrs.ttl,
|
|
53
|
+
fetchDate: new Date()
|
|
54
|
+
};
|
|
55
|
+
logger.debug('fetched media conn');
|
|
56
|
+
return node;
|
|
57
|
+
})();
|
|
58
|
+
}
|
|
59
|
+
return mediaConn;
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* generic send receipt function
|
|
63
|
+
* used for receipts of phone call, read, delivery etc.
|
|
64
|
+
* */
|
|
65
|
+
const sendReceipt = async (jid, participant, messageIds, type) => {
|
|
66
|
+
if (!messageIds || messageIds.length === 0) {
|
|
67
|
+
throw new boom_1.Boom('missing ids in receipt');
|
|
68
|
+
}
|
|
69
|
+
const node = {
|
|
70
|
+
tag: 'receipt',
|
|
71
|
+
attrs: {
|
|
72
|
+
id: messageIds[0]
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
const isReadReceipt = type === 'read' || type === 'read-self';
|
|
76
|
+
if (isReadReceipt) {
|
|
77
|
+
node.attrs.t = (0, Utils_1.unixTimestampSeconds)().toString();
|
|
78
|
+
}
|
|
79
|
+
if (type === 'sender' && (0, WABinary_1.isPnUser)(jid)) {
|
|
80
|
+
node.attrs.recipient = jid;
|
|
81
|
+
node.attrs.to = participant;
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
node.attrs.to = jid;
|
|
85
|
+
if (participant) {
|
|
86
|
+
node.attrs.participant = participant;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
if (type) {
|
|
90
|
+
node.attrs.type = type;
|
|
91
|
+
}
|
|
92
|
+
const remainingMessageIds = messageIds.slice(1);
|
|
93
|
+
if (remainingMessageIds.length) {
|
|
94
|
+
node.content = [
|
|
95
|
+
{
|
|
96
|
+
tag: 'list',
|
|
97
|
+
attrs: {},
|
|
98
|
+
content: remainingMessageIds.map(id => ({
|
|
99
|
+
tag: 'item',
|
|
100
|
+
attrs: { id }
|
|
101
|
+
}))
|
|
102
|
+
}
|
|
103
|
+
];
|
|
104
|
+
}
|
|
105
|
+
logger.debug({ attrs: node.attrs, messageIds }, 'sending receipt for messages');
|
|
106
|
+
await sendNode(node);
|
|
107
|
+
};
|
|
108
|
+
/** Correctly bulk send receipts to multiple chats, participants */
|
|
109
|
+
const sendReceipts = async (keys, type) => {
|
|
110
|
+
const recps = (0, Utils_1.aggregateMessageKeysNotFromMe)(keys);
|
|
111
|
+
for (const { jid, participant, messageIds } of recps) {
|
|
112
|
+
await sendReceipt(jid, participant, messageIds, type);
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
/** Bulk read messages. Keys can be from different chats & participants */
|
|
116
|
+
const readMessages = async (keys) => {
|
|
117
|
+
const privacySettings = await fetchPrivacySettings();
|
|
118
|
+
// based on privacy settings, we have to change the read type
|
|
119
|
+
const readType = privacySettings.readreceipts === 'all' ? 'read' : 'read-self';
|
|
120
|
+
await sendReceipts(keys, readType);
|
|
121
|
+
};
|
|
122
|
+
/**
|
|
123
|
+
* Deduplicate JIDs when both LID and PN versions exist for same user
|
|
124
|
+
* Prefers LID over PN to maintain single encryption layer
|
|
125
|
+
*/
|
|
126
|
+
const deduplicateLidPnJids = (jids) => {
|
|
127
|
+
const lidUsers = new Set();
|
|
128
|
+
const filteredJids = [];
|
|
129
|
+
// Collect all LID users
|
|
130
|
+
for (const jid of jids) {
|
|
131
|
+
if (jid.includes('@lid')) {
|
|
132
|
+
const user = (0, WABinary_1.jidDecode)(jid)?.user;
|
|
133
|
+
if (user)
|
|
134
|
+
lidUsers.add(user);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
// Filter out PN versions when LID exists
|
|
138
|
+
for (const jid of jids) {
|
|
139
|
+
if (jid.includes('@s.whatsapp.net')) {
|
|
140
|
+
const user = (0, WABinary_1.jidDecode)(jid)?.user;
|
|
141
|
+
if (user && lidUsers.has(user)) {
|
|
142
|
+
logger.debug({ jid }, 'Skipping PN - LID version exists');
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
filteredJids.push(jid);
|
|
147
|
+
}
|
|
148
|
+
return filteredJids;
|
|
149
|
+
};
|
|
150
|
+
/** Fetch all the devices we've to send a message to */
|
|
151
|
+
const getUSyncDevices = async (jids, useCache, ignoreZeroDevices) => {
|
|
152
|
+
const deviceResults = [];
|
|
153
|
+
if (!useCache) {
|
|
154
|
+
logger.debug('not using cache for devices');
|
|
155
|
+
}
|
|
156
|
+
const toFetch = [];
|
|
157
|
+
jids = deduplicateLidPnJids(Array.from(new Set(jids)));
|
|
158
|
+
const jidsWithUser = jids
|
|
159
|
+
.map(jid => {
|
|
160
|
+
const decoded = (0, WABinary_1.jidDecode)(jid);
|
|
161
|
+
const user = decoded?.user;
|
|
162
|
+
const device = decoded?.device;
|
|
163
|
+
const isExplicitDevice = typeof device === 'number' && device >= 0;
|
|
164
|
+
if (isExplicitDevice && user) {
|
|
165
|
+
deviceResults.push({
|
|
166
|
+
user,
|
|
167
|
+
device,
|
|
168
|
+
wireJid: jid // again this makes no sense
|
|
169
|
+
});
|
|
170
|
+
return null;
|
|
171
|
+
}
|
|
172
|
+
jid = (0, WABinary_1.jidNormalizedUser)(jid);
|
|
173
|
+
return { jid, user };
|
|
174
|
+
})
|
|
175
|
+
.filter(jid => jid !== null);
|
|
176
|
+
let mgetDevices;
|
|
177
|
+
if (useCache && userDevicesCache.mget) {
|
|
178
|
+
const usersToFetch = jidsWithUser.map(j => j?.user).filter(Boolean);
|
|
179
|
+
mgetDevices = await userDevicesCache.mget(usersToFetch);
|
|
180
|
+
}
|
|
181
|
+
for (const { jid, user } of jidsWithUser) {
|
|
182
|
+
if (useCache) {
|
|
183
|
+
const devices = mgetDevices?.[user] ||
|
|
184
|
+
(userDevicesCache.mget ? undefined : (await userDevicesCache.get(user)));
|
|
185
|
+
if (devices) {
|
|
186
|
+
const isLidJid = jid.includes('@lid');
|
|
187
|
+
const devicesWithWire = devices.map(d => ({
|
|
188
|
+
...d,
|
|
189
|
+
wireJid: isLidJid ? (0, WABinary_1.jidEncode)(d.user, 'lid', d.device) : (0, WABinary_1.jidEncode)(d.user, 's.whatsapp.net', d.device)
|
|
190
|
+
}));
|
|
191
|
+
deviceResults.push(...devicesWithWire);
|
|
192
|
+
logger.trace({ user }, 'using cache for devices');
|
|
193
|
+
}
|
|
194
|
+
else {
|
|
195
|
+
toFetch.push(jid);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
else {
|
|
199
|
+
toFetch.push(jid);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
if (!toFetch.length) {
|
|
203
|
+
return deviceResults;
|
|
204
|
+
}
|
|
205
|
+
const requestedLidUsers = new Set();
|
|
206
|
+
for (const jid of toFetch) {
|
|
207
|
+
if (jid.includes('@lid')) {
|
|
208
|
+
const user = (0, WABinary_1.jidDecode)(jid)?.user;
|
|
209
|
+
if (user)
|
|
210
|
+
requestedLidUsers.add(user);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
const query = new WAUSync_1.USyncQuery().withContext('message').withDeviceProtocol();
|
|
214
|
+
for (const jid of toFetch) {
|
|
215
|
+
query.withUser(new WAUSync_1.USyncUser().withId(jid)); // todo: investigate - the idea here is that <user> should have an inline lid field with the lid being the pn equivalent
|
|
216
|
+
}
|
|
217
|
+
const result = await sock.executeUSyncQuery(query);
|
|
218
|
+
if (result) {
|
|
219
|
+
const extracted = (0, Utils_1.extractDeviceJids)(result?.list, authState.creds.me.id, ignoreZeroDevices);
|
|
220
|
+
const deviceMap = {};
|
|
221
|
+
for (const item of extracted) {
|
|
222
|
+
deviceMap[item.user] = deviceMap[item.user] || [];
|
|
223
|
+
deviceMap[item.user]?.push(item);
|
|
224
|
+
}
|
|
225
|
+
// Process each user's devices as a group for bulk LID migration
|
|
226
|
+
for (const [user, userDevices] of Object.entries(deviceMap)) {
|
|
227
|
+
const isLidUser = requestedLidUsers.has(user);
|
|
228
|
+
// Process all devices for this user
|
|
229
|
+
for (const item of userDevices) {
|
|
230
|
+
const finalWireJid = isLidUser
|
|
231
|
+
? (0, WABinary_1.jidEncode)(user, 'lid', item.device)
|
|
232
|
+
: (0, WABinary_1.jidEncode)(item.user, 's.whatsapp.net', item.device);
|
|
233
|
+
deviceResults.push({
|
|
234
|
+
...item,
|
|
235
|
+
wireJid: finalWireJid
|
|
236
|
+
});
|
|
237
|
+
logger.debug({
|
|
238
|
+
user: item.user,
|
|
239
|
+
device: item.device,
|
|
240
|
+
finalWireJid,
|
|
241
|
+
usedLid: isLidUser
|
|
242
|
+
}, 'Processed device with LID priority');
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
if (userDevicesCache.mset) {
|
|
246
|
+
// if the cache supports mset, we can set all devices in one go
|
|
247
|
+
await userDevicesCache.mset(Object.entries(deviceMap).map(([key, value]) => ({ key, value })));
|
|
248
|
+
}
|
|
249
|
+
else {
|
|
250
|
+
for (const key in deviceMap) {
|
|
251
|
+
if (deviceMap[key])
|
|
252
|
+
await userDevicesCache.set(key, deviceMap[key]);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
return deviceResults;
|
|
257
|
+
};
|
|
258
|
+
const assertSessions = async (jids, force) => {
|
|
259
|
+
let didFetchNewSession = false;
|
|
260
|
+
const jidsRequiringFetch = [];
|
|
261
|
+
// Apply same deduplication as in getUSyncDevices
|
|
262
|
+
jids = deduplicateLidPnJids(jids);
|
|
263
|
+
if (force) {
|
|
264
|
+
// Check which sessions are missing (with LID migration check)
|
|
265
|
+
const addrs = jids.map(jid => signalRepository.jidToSignalProtocolAddress(jid));
|
|
266
|
+
const sessions = await authState.keys.get('session', addrs);
|
|
267
|
+
// Simplified: Check session existence directly
|
|
268
|
+
const checkJidSession = (jid) => {
|
|
269
|
+
const signalId = signalRepository.jidToSignalProtocolAddress(jid);
|
|
270
|
+
const hasSession = !!sessions[signalId];
|
|
271
|
+
// Add to fetch list if no session exists
|
|
272
|
+
// Session type selection (LID vs PN) is handled in encryptMessage
|
|
273
|
+
if (!hasSession) {
|
|
274
|
+
if (jid.includes('@lid')) {
|
|
275
|
+
logger.debug({ jid }, 'No LID session found, will create new LID session');
|
|
276
|
+
}
|
|
277
|
+
jidsRequiringFetch.push(jid);
|
|
278
|
+
}
|
|
279
|
+
};
|
|
280
|
+
// Process all JIDs
|
|
281
|
+
for (const jid of jids) {
|
|
282
|
+
checkJidSession(jid);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
else {
|
|
286
|
+
const addrs = jids.map(jid => signalRepository.jidToSignalProtocolAddress(jid));
|
|
287
|
+
const sessions = await authState.keys.get('session', addrs);
|
|
288
|
+
// Group JIDs by user for bulk migration
|
|
289
|
+
const userGroups = new Map();
|
|
290
|
+
for (const jid of jids) {
|
|
291
|
+
const user = (0, WABinary_1.jidNormalizedUser)(jid);
|
|
292
|
+
if (!userGroups.has(user)) {
|
|
293
|
+
userGroups.set(user, []);
|
|
294
|
+
}
|
|
295
|
+
userGroups.get(user).push(jid);
|
|
296
|
+
}
|
|
297
|
+
// Helper to check LID mapping for a user
|
|
298
|
+
const checkUserLidMapping = async (user, userJids) => {
|
|
299
|
+
if (!userJids.some(jid => jid.includes('@s.whatsapp.net'))) {
|
|
300
|
+
return { shouldMigrate: false, lidForPN: undefined };
|
|
301
|
+
}
|
|
302
|
+
try {
|
|
303
|
+
// Convert user to proper PN JID format for getLIDForPN
|
|
304
|
+
const pnJid = `${user}@s.whatsapp.net`;
|
|
305
|
+
const mapping = await signalRepository.lidMapping.getLIDForPN(pnJid);
|
|
306
|
+
if (mapping?.includes('@lid')) {
|
|
307
|
+
logger.debug({ user, lidForPN: mapping, deviceCount: userJids.length }, 'User has LID mapping - preparing bulk migration');
|
|
308
|
+
return { shouldMigrate: true, lidForPN: mapping };
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
catch (error) {
|
|
312
|
+
logger.debug({ user, error }, 'Failed to check LID mapping for user');
|
|
313
|
+
}
|
|
314
|
+
return { shouldMigrate: false, lidForPN: undefined };
|
|
315
|
+
};
|
|
316
|
+
// Process each user group for potential bulk LID migration
|
|
317
|
+
for (const [user, userJids] of userGroups) {
|
|
318
|
+
const mappingResult = await checkUserLidMapping(user, userJids);
|
|
319
|
+
const shouldMigrateUser = mappingResult.shouldMigrate;
|
|
320
|
+
const lidForPN = mappingResult.lidForPN;
|
|
321
|
+
// Migrate all devices for this user if LID mapping exists
|
|
322
|
+
if (shouldMigrateUser && lidForPN) {
|
|
323
|
+
// Bulk migrate all user devices in single transaction
|
|
324
|
+
const migrationResult = await signalRepository.migrateSession(userJids, lidForPN);
|
|
325
|
+
if (migrationResult.migrated > 0) {
|
|
326
|
+
logger.info({
|
|
327
|
+
user,
|
|
328
|
+
lidMapping: lidForPN,
|
|
329
|
+
migrated: migrationResult.migrated,
|
|
330
|
+
skipped: migrationResult.skipped,
|
|
331
|
+
total: migrationResult.total
|
|
332
|
+
}, 'Completed bulk migration for user devices');
|
|
333
|
+
}
|
|
334
|
+
else {
|
|
335
|
+
logger.debug({
|
|
336
|
+
user,
|
|
337
|
+
lidMapping: lidForPN,
|
|
338
|
+
skipped: migrationResult.skipped,
|
|
339
|
+
total: migrationResult.total
|
|
340
|
+
}, 'All user device sessions already migrated');
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
// Direct bulk session check with LID single source of truth
|
|
344
|
+
const addMissingSessionsToFetchList = (jid) => {
|
|
345
|
+
const signalId = signalRepository.jidToSignalProtocolAddress(jid);
|
|
346
|
+
if (sessions[signalId])
|
|
347
|
+
return;
|
|
348
|
+
// Determine correct JID to fetch (LID if mapping exists, otherwise original)
|
|
349
|
+
if (jid.includes('@s.whatsapp.net') && shouldMigrateUser && lidForPN) {
|
|
350
|
+
const decoded = (0, WABinary_1.jidDecode)(jid);
|
|
351
|
+
const lidDeviceJid = decoded.device !== undefined ? `${(0, WABinary_1.jidDecode)(lidForPN).user}:${decoded.device}@lid` : lidForPN;
|
|
352
|
+
jidsRequiringFetch.push(lidDeviceJid);
|
|
353
|
+
logger.debug({ pnJid: jid, lidJid: lidDeviceJid }, 'Adding LID JID to fetch list (conversion)');
|
|
354
|
+
}
|
|
355
|
+
else {
|
|
356
|
+
jidsRequiringFetch.push(jid);
|
|
357
|
+
logger.debug({ jid }, 'Adding JID to fetch list');
|
|
358
|
+
}
|
|
359
|
+
};
|
|
360
|
+
userJids.forEach(addMissingSessionsToFetchList);
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
if (jidsRequiringFetch.length) {
|
|
364
|
+
logger.debug({ jidsRequiringFetch }, 'fetching sessions');
|
|
365
|
+
// DEBUG: Check if there are PN versions of LID users being fetched
|
|
366
|
+
const lidUsersBeingFetched = new Set();
|
|
367
|
+
const pnUsersBeingFetched = new Set();
|
|
368
|
+
for (const jid of jidsRequiringFetch) {
|
|
369
|
+
const user = (0, WABinary_1.jidDecode)(jid)?.user;
|
|
370
|
+
if (user) {
|
|
371
|
+
if (jid.includes('@lid')) {
|
|
372
|
+
lidUsersBeingFetched.add(user);
|
|
373
|
+
}
|
|
374
|
+
else if (jid.includes('@s.whatsapp.net')) {
|
|
375
|
+
pnUsersBeingFetched.add(user);
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
// Find overlaps
|
|
380
|
+
const overlapping = Array.from(pnUsersBeingFetched).filter(user => lidUsersBeingFetched.has(user));
|
|
381
|
+
if (overlapping.length > 0) {
|
|
382
|
+
logger.warn({
|
|
383
|
+
overlapping,
|
|
384
|
+
lidUsersBeingFetched: Array.from(lidUsersBeingFetched),
|
|
385
|
+
pnUsersBeingFetched: Array.from(pnUsersBeingFetched)
|
|
386
|
+
}, 'Fetching both LID and PN sessions for same users');
|
|
387
|
+
}
|
|
388
|
+
const result = await query({
|
|
389
|
+
tag: 'iq',
|
|
390
|
+
attrs: {
|
|
391
|
+
xmlns: 'encrypt',
|
|
392
|
+
type: 'get',
|
|
393
|
+
to: WABinary_1.S_WHATSAPP_NET
|
|
394
|
+
},
|
|
395
|
+
content: [
|
|
396
|
+
{
|
|
397
|
+
tag: 'key',
|
|
398
|
+
attrs: {},
|
|
399
|
+
content: jidsRequiringFetch.map(jid => ({
|
|
400
|
+
tag: 'user',
|
|
401
|
+
attrs: { jid }
|
|
402
|
+
}))
|
|
403
|
+
}
|
|
404
|
+
]
|
|
405
|
+
});
|
|
406
|
+
await (0, Utils_1.parseAndInjectE2ESessions)(result, signalRepository);
|
|
407
|
+
didFetchNewSession = true;
|
|
408
|
+
}
|
|
409
|
+
return didFetchNewSession;
|
|
410
|
+
};
|
|
411
|
+
const sendPeerDataOperationMessage = async (pdoMessage) => {
|
|
412
|
+
//TODO: for later, abstract the logic to send a Peer Message instead of just PDO - useful for App State Key Resync with phone
|
|
413
|
+
if (!authState.creds.me?.id) {
|
|
414
|
+
throw new boom_1.Boom('Not authenticated');
|
|
415
|
+
}
|
|
416
|
+
const protocolMessage = {
|
|
417
|
+
protocolMessage: {
|
|
418
|
+
peerDataOperationRequestMessage: pdoMessage,
|
|
419
|
+
type: index_js_1.proto.Message.ProtocolMessage.Type.PEER_DATA_OPERATION_REQUEST_MESSAGE
|
|
420
|
+
}
|
|
421
|
+
};
|
|
422
|
+
const meJid = (0, WABinary_1.jidNormalizedUser)(authState.creds.me.id);
|
|
423
|
+
const msgId = await relayMessage(meJid, protocolMessage, {
|
|
424
|
+
additionalAttributes: {
|
|
425
|
+
category: 'peer',
|
|
426
|
+
push_priority: 'high_force'
|
|
427
|
+
}
|
|
428
|
+
});
|
|
429
|
+
return msgId;
|
|
430
|
+
};
|
|
431
|
+
const createParticipantNodes = async (jids, message, extraAttrs, dsmMessage) => {
|
|
432
|
+
let patched = await patchMessageBeforeSending(message, jids);
|
|
433
|
+
if (!Array.isArray(patched)) {
|
|
434
|
+
patched = jids ? jids.map(jid => ({ recipientJid: jid, ...patched })) : [patched];
|
|
435
|
+
}
|
|
436
|
+
let shouldIncludeDeviceIdentity = false;
|
|
437
|
+
const meId = authState.creds.me.id;
|
|
438
|
+
const meLid = authState.creds.me?.lid;
|
|
439
|
+
const meLidUser = meLid ? (0, WABinary_1.jidDecode)(meLid)?.user : null;
|
|
440
|
+
const devicesByUser = new Map();
|
|
441
|
+
for (const patchedMessageWithJid of patched) {
|
|
442
|
+
const { recipientJid: wireJid, ...patchedMessage } = patchedMessageWithJid;
|
|
443
|
+
if (!wireJid)
|
|
444
|
+
continue;
|
|
445
|
+
// Extract user from JID for grouping
|
|
446
|
+
const decoded = (0, WABinary_1.jidDecode)(wireJid);
|
|
447
|
+
const user = decoded?.user;
|
|
448
|
+
if (!user)
|
|
449
|
+
continue;
|
|
450
|
+
if (!devicesByUser.has(user)) {
|
|
451
|
+
devicesByUser.set(user, []);
|
|
452
|
+
}
|
|
453
|
+
devicesByUser.get(user).push({ recipientJid: wireJid, patchedMessage });
|
|
454
|
+
}
|
|
455
|
+
// Process each user's devices sequentially, but different users in parallel
|
|
456
|
+
const userEncryptionPromises = Array.from(devicesByUser.entries()).map(([user, userDevices]) => encryptionMutex.mutex(user, async () => {
|
|
457
|
+
logger.debug({ user, deviceCount: userDevices.length }, 'Acquiring encryption lock for user devices');
|
|
458
|
+
const userNodes = [];
|
|
459
|
+
// Helper to get encryption JID with LID migration
|
|
460
|
+
const getEncryptionJid = async (wireJid) => {
|
|
461
|
+
if (!wireJid.includes('@s.whatsapp.net'))
|
|
462
|
+
return wireJid;
|
|
463
|
+
try {
|
|
464
|
+
const lidForPN = await signalRepository.lidMapping.getLIDForPN(wireJid);
|
|
465
|
+
if (!lidForPN?.includes('@lid'))
|
|
466
|
+
return wireJid;
|
|
467
|
+
// Preserve device ID from original wire JID
|
|
468
|
+
const wireDecoded = (0, WABinary_1.jidDecode)(wireJid);
|
|
469
|
+
const deviceId = wireDecoded?.device || 0;
|
|
470
|
+
const lidDecoded = (0, WABinary_1.jidDecode)(lidForPN);
|
|
471
|
+
const lidWithDevice = (0, WABinary_1.jidEncode)(lidDecoded?.user, 'lid', deviceId);
|
|
472
|
+
// Migrate session to LID for unified encryption layer
|
|
473
|
+
try {
|
|
474
|
+
const migrationResult = await signalRepository.migrateSession([wireJid], lidWithDevice);
|
|
475
|
+
const recipientUser = (0, WABinary_1.jidNormalizedUser)(wireJid);
|
|
476
|
+
const ownPnUser = (0, WABinary_1.jidNormalizedUser)(meId);
|
|
477
|
+
const isOwnDevice = recipientUser === ownPnUser;
|
|
478
|
+
logger.info({ wireJid, lidWithDevice, isOwnDevice }, 'Migrated to LID encryption');
|
|
479
|
+
// Delete PN session after successful migration
|
|
480
|
+
try {
|
|
481
|
+
if (migrationResult.migrated) {
|
|
482
|
+
await signalRepository.deleteSession([wireJid]);
|
|
483
|
+
logger.debug({ deletedPNSession: wireJid }, 'Deleted PN session');
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
catch (deleteError) {
|
|
487
|
+
logger.warn({ wireJid, error: deleteError }, 'Failed to delete PN session');
|
|
488
|
+
}
|
|
489
|
+
return lidWithDevice;
|
|
490
|
+
}
|
|
491
|
+
catch (migrationError) {
|
|
492
|
+
logger.warn({ wireJid, error: migrationError }, 'Failed to migrate session');
|
|
493
|
+
return wireJid;
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
catch (error) {
|
|
497
|
+
logger.debug({ wireJid, error }, 'Failed to check LID mapping');
|
|
498
|
+
return wireJid;
|
|
499
|
+
}
|
|
500
|
+
};
|
|
501
|
+
// Encrypt to this user's devices sequentially to prevent session corruption
|
|
502
|
+
for (const { recipientJid: wireJid, patchedMessage } of userDevices) {
|
|
503
|
+
// DSM logic: Use DSM for own other devices (following whatsmeow implementation)
|
|
504
|
+
let messageToEncrypt = patchedMessage;
|
|
505
|
+
if (dsmMessage) {
|
|
506
|
+
const { user: targetUser } = (0, WABinary_1.jidDecode)(wireJid);
|
|
507
|
+
const { user: ownPnUser } = (0, WABinary_1.jidDecode)(meId);
|
|
508
|
+
const ownLidUser = meLidUser;
|
|
509
|
+
// Check if this is our device (same user, different device)
|
|
510
|
+
const isOwnUser = targetUser === ownPnUser || (ownLidUser && targetUser === ownLidUser);
|
|
511
|
+
// Exclude exact sender device (whatsmeow: if jid == ownJID || jid == ownLID { continue })
|
|
512
|
+
const isExactSenderDevice = wireJid === meId || (authState.creds.me?.lid && wireJid === authState.creds.me.lid);
|
|
513
|
+
if (isOwnUser && !isExactSenderDevice) {
|
|
514
|
+
messageToEncrypt = dsmMessage;
|
|
515
|
+
logger.debug({ wireJid, targetUser }, 'Using DSM for own device');
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
const bytes = (0, Utils_1.encodeWAMessage)(messageToEncrypt);
|
|
519
|
+
// Get encryption JID with LID migration
|
|
520
|
+
const encryptionJid = await getEncryptionJid(wireJid);
|
|
521
|
+
// ENCRYPT: Use the determined encryption identity (prefers migrated LID)
|
|
522
|
+
const { type, ciphertext } = await signalRepository.encryptMessage({
|
|
523
|
+
jid: encryptionJid, // Unified encryption layer (LID when available)
|
|
524
|
+
data: bytes
|
|
525
|
+
});
|
|
526
|
+
if (type === 'pkmsg') {
|
|
527
|
+
shouldIncludeDeviceIdentity = true;
|
|
528
|
+
}
|
|
529
|
+
const node = {
|
|
530
|
+
tag: 'to',
|
|
531
|
+
attrs: { jid: wireJid }, // Always use original wire identity in envelope
|
|
532
|
+
content: [
|
|
533
|
+
{
|
|
534
|
+
tag: 'enc',
|
|
535
|
+
attrs: {
|
|
536
|
+
v: '2',
|
|
537
|
+
type,
|
|
538
|
+
...(extraAttrs || {})
|
|
539
|
+
},
|
|
540
|
+
content: ciphertext
|
|
541
|
+
}
|
|
542
|
+
]
|
|
543
|
+
};
|
|
544
|
+
userNodes.push(node);
|
|
545
|
+
}
|
|
546
|
+
logger.debug({ user, nodesCreated: userNodes.length }, 'Releasing encryption lock for user devices');
|
|
547
|
+
return userNodes;
|
|
548
|
+
}));
|
|
549
|
+
// Wait for all users to complete (users are processed in parallel)
|
|
550
|
+
const userNodesArrays = await Promise.all(userEncryptionPromises);
|
|
551
|
+
const nodes = userNodesArrays.flat();
|
|
552
|
+
return { nodes, shouldIncludeDeviceIdentity };
|
|
553
|
+
};
|
|
554
|
+
const relayMessage = async (jid, message, { messageId: msgId, participant, additionalAttributes, additionalNodes, useUserDevicesCache, useCachedGroupMetadata, statusJidList }) => {
|
|
555
|
+
const meId = authState.creds.me.id;
|
|
556
|
+
const meLid = authState.creds.me?.lid;
|
|
557
|
+
// ADDRESSING CONSISTENCY: Keep envelope addressing as user provided, handle LID migration in encryption
|
|
558
|
+
let shouldIncludeDeviceIdentity = false;
|
|
559
|
+
const { user, server } = (0, WABinary_1.jidDecode)(jid);
|
|
560
|
+
const statusJid = 'status@broadcast';
|
|
561
|
+
const isGroup = server === 'g.us';
|
|
562
|
+
const isStatus = jid === statusJid;
|
|
563
|
+
const isLid = server === 'lid';
|
|
564
|
+
const isNewsletter = server === 'newsletter';
|
|
565
|
+
// Keep user's original JID choice for envelope addressing
|
|
566
|
+
const finalJid = jid;
|
|
567
|
+
// ADDRESSING CONSISTENCY: Match own identity to conversation context
|
|
568
|
+
// TODO: investigate if this is true
|
|
569
|
+
let ownId = meId;
|
|
570
|
+
if (isLid && meLid) {
|
|
571
|
+
ownId = meLid;
|
|
572
|
+
logger.debug({ to: jid, ownId }, 'Using LID identity for @lid conversation');
|
|
573
|
+
}
|
|
574
|
+
else {
|
|
575
|
+
logger.debug({ to: jid, ownId }, 'Using PN identity for @s.whatsapp.net conversation');
|
|
576
|
+
}
|
|
577
|
+
msgId = msgId || (0, Utils_1.generateMessageIDV2)(sock.user?.id);
|
|
578
|
+
useUserDevicesCache = useUserDevicesCache !== false;
|
|
579
|
+
useCachedGroupMetadata = useCachedGroupMetadata !== false && !isStatus;
|
|
580
|
+
const participants = [];
|
|
581
|
+
const destinationJid = !isStatus ? finalJid : statusJid;
|
|
582
|
+
const binaryNodeContent = [];
|
|
583
|
+
const devices = [];
|
|
584
|
+
const meMsg = {
|
|
585
|
+
deviceSentMessage: {
|
|
586
|
+
destinationJid,
|
|
587
|
+
message
|
|
588
|
+
},
|
|
589
|
+
messageContextInfo: message.messageContextInfo
|
|
590
|
+
};
|
|
591
|
+
const extraAttrs = {};
|
|
592
|
+
if (participant) {
|
|
593
|
+
// when the retry request is not for a group
|
|
594
|
+
// only send to the specific device that asked for a retry
|
|
595
|
+
// otherwise the message is sent out to every device that should be a recipient
|
|
596
|
+
if (!isGroup && !isStatus) {
|
|
597
|
+
additionalAttributes = { ...additionalAttributes, device_fanout: 'false' };
|
|
598
|
+
}
|
|
599
|
+
const { user, device } = (0, WABinary_1.jidDecode)(participant.jid); // rajeh: how does this even make sense TODO check out
|
|
600
|
+
devices.push({
|
|
601
|
+
user,
|
|
602
|
+
device,
|
|
603
|
+
wireJid: participant.jid // Use the participant JID as wire JID
|
|
604
|
+
});
|
|
605
|
+
}
|
|
606
|
+
await authState.keys.transaction(async () => {
|
|
607
|
+
const mediaType = getMediaType(message);
|
|
608
|
+
if (mediaType) {
|
|
609
|
+
extraAttrs['mediatype'] = mediaType;
|
|
610
|
+
}
|
|
611
|
+
if (isNewsletter) {
|
|
612
|
+
// Patch message if needed, then encode as plaintext
|
|
613
|
+
const patched = patchMessageBeforeSending ? await patchMessageBeforeSending(message, []) : message;
|
|
614
|
+
const bytes = (0, Utils_1.encodeNewsletterMessage)(patched);
|
|
615
|
+
binaryNodeContent.push({
|
|
616
|
+
tag: 'plaintext',
|
|
617
|
+
attrs: {},
|
|
618
|
+
content: bytes
|
|
619
|
+
});
|
|
620
|
+
const stanza = {
|
|
621
|
+
tag: 'message',
|
|
622
|
+
attrs: {
|
|
623
|
+
to: jid,
|
|
624
|
+
id: msgId,
|
|
625
|
+
type: getMessageType(message),
|
|
626
|
+
...(additionalAttributes || {})
|
|
627
|
+
},
|
|
628
|
+
content: binaryNodeContent
|
|
629
|
+
};
|
|
630
|
+
logger.debug({ msgId }, `sending newsletter message to ${jid}`);
|
|
631
|
+
await sendNode(stanza);
|
|
632
|
+
return;
|
|
633
|
+
}
|
|
634
|
+
if ((0, Utils_1.normalizeMessageContent)(message)?.pinInChatMessage) {
|
|
635
|
+
extraAttrs['decrypt-fail'] = 'hide'; // todo: expand for reactions and other types
|
|
636
|
+
}
|
|
637
|
+
if (isGroup || isStatus) {
|
|
638
|
+
const [groupData, senderKeyMap] = await Promise.all([
|
|
639
|
+
(async () => {
|
|
640
|
+
let groupData = useCachedGroupMetadata && cachedGroupMetadata ? await cachedGroupMetadata(jid) : undefined; // todo: should we rely on the cache specially if the cache is outdated and the metadata has new fields?
|
|
641
|
+
if (groupData && Array.isArray(groupData?.participants)) {
|
|
642
|
+
logger.trace({ jid, participants: groupData.participants.length }, 'using cached group metadata');
|
|
643
|
+
}
|
|
644
|
+
else if (!isStatus) {
|
|
645
|
+
groupData = await groupMetadata(jid);
|
|
646
|
+
}
|
|
647
|
+
return groupData;
|
|
648
|
+
})(),
|
|
649
|
+
(async () => {
|
|
650
|
+
if (!participant && !isStatus) {
|
|
651
|
+
const result = await authState.keys.get('sender-key-memory', [jid]); // TODO: check out what if the sender key memory doesn't include the LID stuff now?
|
|
652
|
+
return result[jid] || {};
|
|
653
|
+
}
|
|
654
|
+
return {};
|
|
655
|
+
})()
|
|
656
|
+
]);
|
|
657
|
+
if (!participant) {
|
|
658
|
+
const participantsList = groupData && !isStatus ? groupData.participants.map(p => p.id) : [];
|
|
659
|
+
if (isStatus && statusJidList) {
|
|
660
|
+
participantsList.push(...statusJidList);
|
|
661
|
+
}
|
|
662
|
+
if (!isStatus) {
|
|
663
|
+
const groupAddressingMode = groupData?.addressingMode || (isLid ? Types_1.WAMessageAddressingMode.LID : Types_1.WAMessageAddressingMode.PN);
|
|
664
|
+
additionalAttributes = {
|
|
665
|
+
...additionalAttributes,
|
|
666
|
+
addressing_mode: groupAddressingMode
|
|
667
|
+
};
|
|
668
|
+
}
|
|
669
|
+
const additionalDevices = await getUSyncDevices(participantsList, !!useUserDevicesCache, false);
|
|
670
|
+
devices.push(...additionalDevices);
|
|
671
|
+
}
|
|
672
|
+
const patched = await patchMessageBeforeSending(message);
|
|
673
|
+
if (Array.isArray(patched)) {
|
|
674
|
+
throw new boom_1.Boom('Per-jid patching is not supported in groups');
|
|
675
|
+
}
|
|
676
|
+
const bytes = (0, Utils_1.encodeWAMessage)(patched);
|
|
677
|
+
// This should match the group's addressing mode and conversation context
|
|
678
|
+
const groupAddressingMode = groupData?.addressingMode || (isLid ? 'lid' : 'pn');
|
|
679
|
+
const groupSenderIdentity = groupAddressingMode === 'lid' && meLid ? meLid : meId;
|
|
680
|
+
const { ciphertext, senderKeyDistributionMessage } = await signalRepository.encryptGroupMessage({
|
|
681
|
+
group: destinationJid,
|
|
682
|
+
data: bytes,
|
|
683
|
+
meId: groupSenderIdentity
|
|
684
|
+
});
|
|
685
|
+
const senderKeyJids = [];
|
|
686
|
+
// ensure a connection is established with every device
|
|
687
|
+
for (const device of devices) {
|
|
688
|
+
// This preserves the LID migration results from getUSyncDevices
|
|
689
|
+
const deviceJid = device.wireJid;
|
|
690
|
+
const hasKey = !!senderKeyMap[deviceJid];
|
|
691
|
+
if (!hasKey || !!participant) {
|
|
692
|
+
senderKeyJids.push(deviceJid);
|
|
693
|
+
// store that this person has had the sender keys sent to them
|
|
694
|
+
senderKeyMap[deviceJid] = true;
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
// if there are some participants with whom the session has not been established
|
|
698
|
+
// if there are, we re-send the senderkey
|
|
699
|
+
if (senderKeyJids.length) {
|
|
700
|
+
logger.debug({ senderKeyJids }, 'sending new sender key');
|
|
701
|
+
const senderKeyMsg = {
|
|
702
|
+
senderKeyDistributionMessage: {
|
|
703
|
+
axolotlSenderKeyDistributionMessage: senderKeyDistributionMessage,
|
|
704
|
+
groupId: destinationJid
|
|
705
|
+
}
|
|
706
|
+
};
|
|
707
|
+
await assertSessions(senderKeyJids, false);
|
|
708
|
+
const result = await createParticipantNodes(senderKeyJids, senderKeyMsg, extraAttrs);
|
|
709
|
+
shouldIncludeDeviceIdentity = shouldIncludeDeviceIdentity || result.shouldIncludeDeviceIdentity;
|
|
710
|
+
participants.push(...result.nodes);
|
|
711
|
+
}
|
|
712
|
+
binaryNodeContent.push({
|
|
713
|
+
tag: 'enc',
|
|
714
|
+
attrs: { v: '2', type: 'skmsg' },
|
|
715
|
+
content: ciphertext
|
|
716
|
+
});
|
|
717
|
+
await authState.keys.set({ 'sender-key-memory': { [jid]: senderKeyMap } });
|
|
718
|
+
}
|
|
719
|
+
else {
|
|
720
|
+
const { user: ownUser } = (0, WABinary_1.jidDecode)(ownId);
|
|
721
|
+
if (!participant) {
|
|
722
|
+
const targetUserServer = isLid ? 'lid' : 's.whatsapp.net';
|
|
723
|
+
devices.push({
|
|
724
|
+
user,
|
|
725
|
+
device: 0,
|
|
726
|
+
wireJid: (0, WABinary_1.jidEncode)(user, targetUserServer, 0)
|
|
727
|
+
});
|
|
728
|
+
// Own user matches conversation addressing mode
|
|
729
|
+
if (user !== ownUser) {
|
|
730
|
+
const ownUserServer = isLid ? 'lid' : 's.whatsapp.net';
|
|
731
|
+
const ownUserForAddressing = isLid && meLid ? (0, WABinary_1.jidDecode)(meLid).user : (0, WABinary_1.jidDecode)(meId).user;
|
|
732
|
+
devices.push({
|
|
733
|
+
user: ownUserForAddressing,
|
|
734
|
+
device: 0,
|
|
735
|
+
wireJid: (0, WABinary_1.jidEncode)(ownUserForAddressing, ownUserServer, 0)
|
|
736
|
+
});
|
|
737
|
+
}
|
|
738
|
+
if (additionalAttributes?.['category'] !== 'peer') {
|
|
739
|
+
// Clear placeholders and enumerate actual devices
|
|
740
|
+
devices.length = 0;
|
|
741
|
+
// Use conversation-appropriate sender identity
|
|
742
|
+
const senderIdentity = isLid && meLid
|
|
743
|
+
? (0, WABinary_1.jidEncode)((0, WABinary_1.jidDecode)(meLid)?.user, 'lid', undefined)
|
|
744
|
+
: (0, WABinary_1.jidEncode)((0, WABinary_1.jidDecode)(meId)?.user, 's.whatsapp.net', undefined);
|
|
745
|
+
// Enumerate devices for sender and target with consistent addressing
|
|
746
|
+
const sessionDevices = await getUSyncDevices([senderIdentity, jid], false, false);
|
|
747
|
+
devices.push(...sessionDevices);
|
|
748
|
+
logger.debug({
|
|
749
|
+
deviceCount: devices.length,
|
|
750
|
+
devices: devices.map(d => `${d.user}:${d.device}@${(0, WABinary_1.jidDecode)(d.wireJid)?.server}`)
|
|
751
|
+
}, 'Device enumeration complete with unified addressing');
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
const allJids = [];
|
|
755
|
+
const meJids = [];
|
|
756
|
+
const otherJids = [];
|
|
757
|
+
const { user: mePnUser } = (0, WABinary_1.jidDecode)(meId);
|
|
758
|
+
const { user: meLidUser } = meLid ? (0, WABinary_1.jidDecode)(meLid) : { user: null };
|
|
759
|
+
for (const { user, wireJid } of devices) {
|
|
760
|
+
const isExactSenderDevice = wireJid === meId || (meLid && wireJid === meLid);
|
|
761
|
+
if (isExactSenderDevice) {
|
|
762
|
+
logger.debug({ wireJid, meId, meLid }, 'Skipping exact sender device (whatsmeow pattern)');
|
|
763
|
+
continue;
|
|
764
|
+
}
|
|
765
|
+
// Check if this is our device (could match either PN or LID user)
|
|
766
|
+
const isMe = user === mePnUser || (meLidUser && user === meLidUser);
|
|
767
|
+
const jid = wireJid;
|
|
768
|
+
if (isMe) {
|
|
769
|
+
meJids.push(jid);
|
|
770
|
+
}
|
|
771
|
+
else {
|
|
772
|
+
otherJids.push(jid);
|
|
773
|
+
}
|
|
774
|
+
allJids.push(jid);
|
|
775
|
+
}
|
|
776
|
+
await assertSessions([...otherJids, ...meJids], false);
|
|
777
|
+
const [{ nodes: meNodes, shouldIncludeDeviceIdentity: s1 }, { nodes: otherNodes, shouldIncludeDeviceIdentity: s2 }] = await Promise.all([
|
|
778
|
+
// For own devices: use DSM if available (1:1 chats only)
|
|
779
|
+
createParticipantNodes(meJids, meMsg || message, extraAttrs),
|
|
780
|
+
createParticipantNodes(otherJids, message, extraAttrs, meMsg)
|
|
781
|
+
]);
|
|
782
|
+
participants.push(...meNodes);
|
|
783
|
+
participants.push(...otherNodes);
|
|
784
|
+
if (meJids.length > 0 || otherJids.length > 0) {
|
|
785
|
+
extraAttrs['phash'] = (0, Utils_1.generateParticipantHashV2)([...meJids, ...otherJids]);
|
|
786
|
+
}
|
|
787
|
+
shouldIncludeDeviceIdentity = shouldIncludeDeviceIdentity || s1 || s2;
|
|
788
|
+
}
|
|
789
|
+
if (participants.length) {
|
|
790
|
+
if (additionalAttributes?.['category'] === 'peer') {
|
|
791
|
+
const peerNode = participants[0]?.content?.[0];
|
|
792
|
+
if (peerNode) {
|
|
793
|
+
binaryNodeContent.push(peerNode); // push only enc
|
|
794
|
+
}
|
|
795
|
+
}
|
|
796
|
+
else {
|
|
797
|
+
binaryNodeContent.push({
|
|
798
|
+
tag: 'participants',
|
|
799
|
+
attrs: {},
|
|
800
|
+
content: participants
|
|
801
|
+
});
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
const stanza = {
|
|
805
|
+
tag: 'message',
|
|
806
|
+
attrs: {
|
|
807
|
+
id: msgId,
|
|
808
|
+
to: destinationJid,
|
|
809
|
+
type: getMessageType(message),
|
|
810
|
+
...(additionalAttributes || {})
|
|
811
|
+
},
|
|
812
|
+
content: binaryNodeContent
|
|
813
|
+
};
|
|
814
|
+
// if the participant to send to is explicitly specified (generally retry recp)
|
|
815
|
+
// ensure the message is only sent to that person
|
|
816
|
+
// if a retry receipt is sent to everyone -- it'll fail decryption for everyone else who received the msg
|
|
817
|
+
if (participant) {
|
|
818
|
+
if ((0, WABinary_1.isJidGroup)(destinationJid)) {
|
|
819
|
+
stanza.attrs.to = destinationJid;
|
|
820
|
+
stanza.attrs.participant = participant.jid;
|
|
821
|
+
}
|
|
822
|
+
else if ((0, WABinary_1.areJidsSameUser)(participant.jid, meId)) {
|
|
823
|
+
stanza.attrs.to = participant.jid;
|
|
824
|
+
stanza.attrs.recipient = destinationJid;
|
|
825
|
+
}
|
|
826
|
+
else {
|
|
827
|
+
stanza.attrs.to = participant.jid;
|
|
828
|
+
}
|
|
829
|
+
}
|
|
830
|
+
else {
|
|
831
|
+
stanza.attrs.to = destinationJid;
|
|
832
|
+
}
|
|
833
|
+
if (shouldIncludeDeviceIdentity) {
|
|
834
|
+
;
|
|
835
|
+
stanza.content.push({
|
|
836
|
+
tag: 'device-identity',
|
|
837
|
+
attrs: {},
|
|
838
|
+
content: (0, Utils_1.encodeSignedDeviceIdentity)(authState.creds.account, true)
|
|
839
|
+
});
|
|
840
|
+
logger.debug({ jid }, 'adding device identity');
|
|
841
|
+
}
|
|
842
|
+
if (additionalNodes && additionalNodes.length > 0) {
|
|
843
|
+
;
|
|
844
|
+
stanza.content.push(...additionalNodes);
|
|
845
|
+
}
|
|
846
|
+
logger.debug({ msgId }, `sending message to ${participants.length} devices`);
|
|
847
|
+
await sendNode(stanza);
|
|
848
|
+
// Add message to retry cache if enabled
|
|
849
|
+
if (messageRetryManager && !participant) {
|
|
850
|
+
messageRetryManager.addRecentMessage(destinationJid, msgId, message);
|
|
851
|
+
}
|
|
852
|
+
}, meId);
|
|
853
|
+
return msgId;
|
|
854
|
+
};
|
|
855
|
+
const getMessageType = (message) => {
|
|
856
|
+
if (message.pollCreationMessage || message.pollCreationMessageV2 || message.pollCreationMessageV3) {
|
|
857
|
+
return 'poll';
|
|
858
|
+
}
|
|
859
|
+
if (message.eventMessage) {
|
|
860
|
+
return 'event';
|
|
861
|
+
}
|
|
862
|
+
return 'text';
|
|
863
|
+
};
|
|
864
|
+
const getMediaType = (message) => {
|
|
865
|
+
if (message.imageMessage) {
|
|
866
|
+
return 'image';
|
|
867
|
+
}
|
|
868
|
+
else if (message.videoMessage) {
|
|
869
|
+
return message.videoMessage.gifPlayback ? 'gif' : 'video';
|
|
870
|
+
}
|
|
871
|
+
else if (message.audioMessage) {
|
|
872
|
+
return message.audioMessage.ptt ? 'ptt' : 'audio';
|
|
873
|
+
}
|
|
874
|
+
else if (message.contactMessage) {
|
|
875
|
+
return 'vcard';
|
|
876
|
+
}
|
|
877
|
+
else if (message.documentMessage) {
|
|
878
|
+
return 'document';
|
|
879
|
+
}
|
|
880
|
+
else if (message.contactsArrayMessage) {
|
|
881
|
+
return 'contact_array';
|
|
882
|
+
}
|
|
883
|
+
else if (message.liveLocationMessage) {
|
|
884
|
+
return 'livelocation';
|
|
885
|
+
}
|
|
886
|
+
else if (message.stickerMessage) {
|
|
887
|
+
return 'sticker';
|
|
888
|
+
}
|
|
889
|
+
else if (message.listMessage) {
|
|
890
|
+
return 'list';
|
|
891
|
+
}
|
|
892
|
+
else if (message.listResponseMessage) {
|
|
893
|
+
return 'list_response';
|
|
894
|
+
}
|
|
895
|
+
else if (message.buttonsResponseMessage) {
|
|
896
|
+
return 'buttons_response';
|
|
897
|
+
}
|
|
898
|
+
else if (message.orderMessage) {
|
|
899
|
+
return 'order';
|
|
900
|
+
}
|
|
901
|
+
else if (message.productMessage) {
|
|
902
|
+
return 'product';
|
|
903
|
+
}
|
|
904
|
+
else if (message.interactiveResponseMessage) {
|
|
905
|
+
return 'native_flow_response';
|
|
906
|
+
}
|
|
907
|
+
else if (message.groupInviteMessage) {
|
|
908
|
+
return 'url';
|
|
909
|
+
}
|
|
910
|
+
};
|
|
911
|
+
const getPrivacyTokens = async (jids) => {
|
|
912
|
+
const t = (0, Utils_1.unixTimestampSeconds)().toString();
|
|
913
|
+
const result = await query({
|
|
914
|
+
tag: 'iq',
|
|
915
|
+
attrs: {
|
|
916
|
+
to: WABinary_1.S_WHATSAPP_NET,
|
|
917
|
+
type: 'set',
|
|
918
|
+
xmlns: 'privacy'
|
|
919
|
+
},
|
|
920
|
+
content: [
|
|
921
|
+
{
|
|
922
|
+
tag: 'tokens',
|
|
923
|
+
attrs: {},
|
|
924
|
+
content: jids.map(jid => ({
|
|
925
|
+
tag: 'token',
|
|
926
|
+
attrs: {
|
|
927
|
+
jid: (0, WABinary_1.jidNormalizedUser)(jid),
|
|
928
|
+
t,
|
|
929
|
+
type: 'trusted_contact'
|
|
930
|
+
}
|
|
931
|
+
}))
|
|
932
|
+
}
|
|
933
|
+
]
|
|
934
|
+
});
|
|
935
|
+
return result;
|
|
936
|
+
};
|
|
937
|
+
const waUploadToServer = (0, Utils_1.getWAUploadToServer)(config, refreshMediaConn);
|
|
938
|
+
const waitForMsgMediaUpdate = (0, Utils_1.bindWaitForEvent)(ev, 'messages.media-update');
|
|
939
|
+
return {
|
|
940
|
+
...sock,
|
|
941
|
+
getPrivacyTokens,
|
|
942
|
+
assertSessions,
|
|
943
|
+
relayMessage,
|
|
944
|
+
sendReceipt,
|
|
945
|
+
sendReceipts,
|
|
946
|
+
readMessages,
|
|
947
|
+
refreshMediaConn,
|
|
948
|
+
waUploadToServer,
|
|
949
|
+
fetchPrivacySettings,
|
|
950
|
+
sendPeerDataOperationMessage,
|
|
951
|
+
createParticipantNodes,
|
|
952
|
+
getUSyncDevices,
|
|
953
|
+
messageRetryManager,
|
|
954
|
+
updateMediaMessage: async (message) => {
|
|
955
|
+
const content = (0, Utils_1.assertMediaContent)(message.message);
|
|
956
|
+
const mediaKey = content.mediaKey;
|
|
957
|
+
const meId = authState.creds.me.id;
|
|
958
|
+
const node = await (0, Utils_1.encryptMediaRetryRequest)(message.key, mediaKey, meId);
|
|
959
|
+
let error = undefined;
|
|
960
|
+
await Promise.all([
|
|
961
|
+
sendNode(node),
|
|
962
|
+
waitForMsgMediaUpdate(async (update) => {
|
|
963
|
+
const result = update.find(c => c.key.id === message.key.id);
|
|
964
|
+
if (result) {
|
|
965
|
+
if (result.error) {
|
|
966
|
+
error = result.error;
|
|
967
|
+
}
|
|
968
|
+
else {
|
|
969
|
+
try {
|
|
970
|
+
const media = await (0, Utils_1.decryptMediaRetryData)(result.media, mediaKey, result.key.id);
|
|
971
|
+
if (media.result !== index_js_1.proto.MediaRetryNotification.ResultType.SUCCESS) {
|
|
972
|
+
const resultStr = index_js_1.proto.MediaRetryNotification.ResultType[media.result];
|
|
973
|
+
throw new boom_1.Boom(`Media re-upload failed by device (${resultStr})`, {
|
|
974
|
+
data: media,
|
|
975
|
+
statusCode: (0, Utils_1.getStatusCodeForMediaRetry)(media.result) || 404
|
|
976
|
+
});
|
|
977
|
+
}
|
|
978
|
+
content.directPath = media.directPath;
|
|
979
|
+
content.url = (0, Utils_1.getUrlFromDirectPath)(content.directPath);
|
|
980
|
+
logger.debug({ directPath: media.directPath, key: result.key }, 'media update successful');
|
|
981
|
+
}
|
|
982
|
+
catch (err) {
|
|
983
|
+
error = err;
|
|
984
|
+
}
|
|
985
|
+
}
|
|
986
|
+
return true;
|
|
987
|
+
}
|
|
988
|
+
})
|
|
989
|
+
]);
|
|
990
|
+
if (error) {
|
|
991
|
+
throw error;
|
|
992
|
+
}
|
|
993
|
+
ev.emit('messages.update', [{ key: message.key, update: { message: message.message } }]);
|
|
994
|
+
return message;
|
|
995
|
+
},
|
|
996
|
+
sendMessage: async (jid, content, options = {}) => {
|
|
997
|
+
const userJid = authState.creds.me.id;
|
|
998
|
+
if (typeof content === 'object' &&
|
|
999
|
+
'disappearingMessagesInChat' in content &&
|
|
1000
|
+
typeof content['disappearingMessagesInChat'] !== 'undefined' &&
|
|
1001
|
+
(0, WABinary_1.isJidGroup)(jid)) {
|
|
1002
|
+
const { disappearingMessagesInChat } = content;
|
|
1003
|
+
const value = typeof disappearingMessagesInChat === 'boolean'
|
|
1004
|
+
? disappearingMessagesInChat
|
|
1005
|
+
? Defaults_1.WA_DEFAULT_EPHEMERAL
|
|
1006
|
+
: 0
|
|
1007
|
+
: disappearingMessagesInChat;
|
|
1008
|
+
await groupToggleEphemeral(jid, value);
|
|
1009
|
+
}
|
|
1010
|
+
else {
|
|
1011
|
+
const fullMsg = await (0, Utils_1.generateWAMessage)(jid, content, {
|
|
1012
|
+
logger,
|
|
1013
|
+
userJid,
|
|
1014
|
+
getUrlInfo: text => (0, link_preview_1.getUrlInfo)(text, {
|
|
1015
|
+
thumbnailWidth: linkPreviewImageThumbnailWidth,
|
|
1016
|
+
fetchOpts: {
|
|
1017
|
+
timeout: 3000,
|
|
1018
|
+
...(axiosOptions || {})
|
|
1019
|
+
},
|
|
1020
|
+
logger,
|
|
1021
|
+
uploadImage: generateHighQualityLinkPreview ? waUploadToServer : undefined
|
|
1022
|
+
}),
|
|
1023
|
+
//TODO: CACHE
|
|
1024
|
+
getProfilePicUrl: sock.profilePictureUrl,
|
|
1025
|
+
getCallLink: sock.createCallLink,
|
|
1026
|
+
upload: waUploadToServer,
|
|
1027
|
+
mediaCache: config.mediaCache,
|
|
1028
|
+
options: config.options,
|
|
1029
|
+
messageId: (0, Utils_1.generateMessageIDV2)(sock.user?.id),
|
|
1030
|
+
...options
|
|
1031
|
+
});
|
|
1032
|
+
const isEventMsg = 'event' in content && !!content.event;
|
|
1033
|
+
const isDeleteMsg = 'delete' in content && !!content.delete;
|
|
1034
|
+
const isEditMsg = 'edit' in content && !!content.edit;
|
|
1035
|
+
const isPinMsg = 'pin' in content && !!content.pin;
|
|
1036
|
+
const isPollMessage = 'poll' in content && !!content.poll;
|
|
1037
|
+
const additionalAttributes = {};
|
|
1038
|
+
const additionalNodes = [];
|
|
1039
|
+
// required for delete
|
|
1040
|
+
if (isDeleteMsg) {
|
|
1041
|
+
// if the chat is a group, and I am not the author, then delete the message as an admin
|
|
1042
|
+
if ((0, WABinary_1.isJidGroup)(content.delete?.remoteJid) && !content.delete?.fromMe) {
|
|
1043
|
+
additionalAttributes.edit = '8';
|
|
1044
|
+
}
|
|
1045
|
+
else {
|
|
1046
|
+
additionalAttributes.edit = '7';
|
|
1047
|
+
}
|
|
1048
|
+
}
|
|
1049
|
+
else if (isEditMsg) {
|
|
1050
|
+
additionalAttributes.edit = '1';
|
|
1051
|
+
}
|
|
1052
|
+
else if (isPinMsg) {
|
|
1053
|
+
additionalAttributes.edit = '2';
|
|
1054
|
+
}
|
|
1055
|
+
else if (isPollMessage) {
|
|
1056
|
+
additionalNodes.push({
|
|
1057
|
+
tag: 'meta',
|
|
1058
|
+
attrs: {
|
|
1059
|
+
polltype: 'creation'
|
|
1060
|
+
}
|
|
1061
|
+
});
|
|
1062
|
+
}
|
|
1063
|
+
else if (isEventMsg) {
|
|
1064
|
+
additionalNodes.push({
|
|
1065
|
+
tag: 'meta',
|
|
1066
|
+
attrs: {
|
|
1067
|
+
event_type: 'creation'
|
|
1068
|
+
}
|
|
1069
|
+
});
|
|
1070
|
+
}
|
|
1071
|
+
if ('cachedGroupMetadata' in options) {
|
|
1072
|
+
console.warn('cachedGroupMetadata in sendMessage are deprecated, now cachedGroupMetadata is part of the socket config.');
|
|
1073
|
+
}
|
|
1074
|
+
await relayMessage(jid, fullMsg.message, {
|
|
1075
|
+
messageId: fullMsg.key.id,
|
|
1076
|
+
useCachedGroupMetadata: options.useCachedGroupMetadata,
|
|
1077
|
+
additionalAttributes,
|
|
1078
|
+
statusJidList: options.statusJidList,
|
|
1079
|
+
additionalNodes
|
|
1080
|
+
});
|
|
1081
|
+
if (config.emitOwnEvents) {
|
|
1082
|
+
process.nextTick(() => {
|
|
1083
|
+
processingMutex.mutex(() => upsertMessage(fullMsg, 'append'));
|
|
1084
|
+
});
|
|
1085
|
+
}
|
|
1086
|
+
return fullMsg;
|
|
1087
|
+
}
|
|
1088
|
+
}
|
|
1089
|
+
};
|
|
1090
|
+
};
|
|
1091
|
+
exports.makeMessagesSocket = makeMessagesSocket;
|