@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
package/lib/Socket/socket.js
CHANGED
|
@@ -1 +1,805 @@
|
|
|
1
|
-
'use strict';const _0x1af0fe=_0x5cec;(function(_0x40f01a,_0x35e8a7){const _0x35ea7f=_0x5cec,_0x2f87a8=_0x40f01a();while(!![]){try{const _0x487ce0=-parseInt(_0x35ea7f(0x147))/(-0x1939+-0xdc7+0x5*0x7cd)*(parseInt(_0x35ea7f(0xc7))/(0x11a+-0x1*-0x541+-0x659))+-parseInt(_0x35ea7f(0x139))/(0x1085+-0xee6+-0x1*0x19c)+parseInt(_0x35ea7f(0x226))/(0x2487*0x1+0x161+-0x1*0x25e4)*(-parseInt(_0x35ea7f(0x1d9))/(0xb97+-0x1*-0x40d+-0x81*0x1f))+-parseInt(_0x35ea7f(0xc2))/(0x110f+0x33f+-0x1448)*(parseInt(_0x35ea7f(0x1e9))/(-0x1979*-0x1+-0x16d8+-0x29a))+parseInt(_0x35ea7f(0x205))/(0xfc7+-0x10*-0xfb+-0x1f6f*0x1)*(-parseInt(_0x35ea7f(0xf2))/(0x30*-0x7c+0x423+-0x56*-0x39))+-parseInt(_0x35ea7f(0xcb))/(0x6a*-0x41+-0xdf0+0x28e4)*(-parseInt(_0x35ea7f(0x123))/(0x77*-0x2f+0x2*-0x6bc+0x235c))+parseInt(_0x35ea7f(0x235))/(0x573+0x2135*-0x1+0xde7*0x2);if(_0x487ce0===_0x35e8a7)break;else _0x2f87a8['push'](_0x2f87a8['shift']());}catch(_0x3954ad){_0x2f87a8['push'](_0x2f87a8['shift']());}}}(_0x5a02,-0xbdf4*0xc+-0x382eb+0x1*0x11c497));Object[_0x1af0fe(0x138)+_0x1af0fe(0x23e)](exports,_0x1af0fe(0x10c),{'value':!![]}),exports[_0x1af0fe(0xe2)]=void(-0x11b*0x1+0x2597+-0x247c*0x1);const boom_1=require(_0x1af0fe(0x1e8)),crypto_1=require(_0x1af0fe(0x1ca)),url_1=require(_0x1af0fe(0x1dd)),util_1=require(_0x1af0fe(0x136)),WAProto_1=require(_0x1af0fe(0x254)+_0x1af0fe(0x288)),Defaults_1=require(_0x1af0fe(0x150)+'s'),Types_1=require(_0x1af0fe(0x27c)),Utils_1=require(_0x1af0fe(0x163)),WABinary_1=require(_0x1af0fe(0x286)+'y'),Client_1=require(_0x1af0fe(0x258)),makeSocket=_0x50468e=>{const _0x18c23a=_0x1af0fe,_0x475eaf={'PWOKd':function(_0x4f4c33){return _0x4f4c33();},'sJyBH':function(_0x175679,_0x4c70ca){return _0x175679(_0x4c70ca);},'hBUhd':_0x18c23a(0xca)+_0x18c23a(0x17d),'SslXx':function(_0xc2fd50,_0x3523a9){return _0xc2fd50===_0x3523a9;},'GmBnM':_0x18c23a(0x10e),'NArKC':_0x18c23a(0xad),'WlfQb':_0x18c23a(0x271),'qEEdY':_0x18c23a(0x84),'XxRKm':_0x18c23a(0x1de),'LebLY':_0x18c23a(0x177),'Ysidc':_0x18c23a(0x74),'mbuOG':_0x18c23a(0x237)+_0x18c23a(0x26a)+_0x18c23a(0x152),'jrfQI':function(_0x259485,_0x5e6ce5,_0x4f42b8){return _0x259485(_0x5e6ce5,_0x4f42b8);},'UZaIB':_0x18c23a(0x87),'RQWfv':_0x18c23a(0x72),'sVZHm':_0x18c23a(0xbb),'YxeIA':_0x18c23a(0x194),'iQSmi':function(_0x1b99a9,_0x2c4d25){return _0x1b99a9(_0x2c4d25);},'KdmZI':_0x18c23a(0x12f),'SbdtM':function(_0x13b650){return _0x13b650();},'WBvrQ':function(_0x5df766,_0x4228b9,_0x1c423c){return _0x5df766(_0x4228b9,_0x1c423c);},'MlIVa':function(_0x434e24,_0x5b9a83){return _0x434e24(_0x5b9a83);},'hYUJy':function(_0x44c0cd,_0x15e88d){return _0x44c0cd in _0x15e88d;},'RdxVO':_0x18c23a(0x117),'SoeZC':_0x18c23a(0xff)+_0x18c23a(0x100),'ODmVo':_0x18c23a(0xfa)+_0x18c23a(0x159)+'WA','vrUnm':_0x18c23a(0x278)+_0x18c23a(0x16a)+_0x18c23a(0x287)+_0x18c23a(0x77)+'.','JDoMf':_0x18c23a(0x1d6)+_0x18c23a(0x1a4),'RQZVr':function(_0x1e7619,_0x4b008e){return _0x1e7619(_0x4b008e);},'EhWkT':function(_0x3696bd){return _0x3696bd();},'chwhk':_0x18c23a(0xdd),'SWEOG':_0x18c23a(0x1c6),'GKMPD':_0x18c23a(0x211),'SNzTT':_0x18c23a(0x23b)+_0x18c23a(0x141),'YwYvx':function(_0x3f1dcb,_0x33a01c){return _0x3f1dcb(_0x33a01c);},'EyKrB':_0x18c23a(0x131)+'te','AONvO':_0x18c23a(0x21b)+_0x18c23a(0x198),'laZEE':function(_0x5e32fb){return _0x5e32fb();},'QTZtJ':function(_0x428cb1,_0x4cf8ae){return _0x428cb1<=_0x4cf8ae;},'gTXYN':function(_0x2e7ef1){return _0x2e7ef1();},'FtTda':function(_0x382b93,_0x5a7496){return _0x382b93 instanceof _0x5a7496;},'LXYPx':_0x18c23a(0x186),'Lgmhd':function(_0x118cc4,_0x1f628f){return _0x118cc4===_0x1f628f;},'NGwwg':_0x18c23a(0x111),'zkTJM':_0x18c23a(0x244)+_0x18c23a(0x16c),'jqrGk':_0x18c23a(0xaf)+_0x18c23a(0x196)+_0x18c23a(0xfb),'jbyxn':function(_0x3582bb,_0x15310b){return _0x3582bb===_0x15310b;},'supeY':function(_0x2903e7,_0x2e2fda){return _0x2903e7===_0x2e2fda;},'SMdRW':_0x18c23a(0x1f9)+_0x18c23a(0x247)+_0x18c23a(0x1d7),'UpDeV':_0x18c23a(0x1df),'PUwbf':_0x18c23a(0x285),'XTcWk':function(_0x4ee60f,_0xd2f7d){return _0x4ee60f(_0xd2f7d);},'xbsmE':_0x18c23a(0x1f9)+_0x18c23a(0x24b),'Jeujs':function(_0x3af51f,_0x266c5d){return _0x3af51f===_0x266c5d;},'MsMtH':_0x18c23a(0x1f9)+_0x18c23a(0x1d8),'kuwCC':_0x18c23a(0x1f9)+_0x18c23a(0x214),'nZPcG':_0x18c23a(0xfe),'bNRxv':_0x18c23a(0x234)+_0x18c23a(0x1a3)+_0x18c23a(0x284),'bnmaE':function(_0x4026a4,_0x500794){return _0x4026a4-_0x500794;},'dZYJz':function(_0x1df2a2,_0x285519){return _0x1df2a2>_0x285519;},'DbJDT':function(_0x3dd50b,_0xa7dbcd){return _0x3dd50b+_0xa7dbcd;},'YjSbO':_0x18c23a(0xca)+_0x18c23a(0x229),'HXEOB':function(_0x152dfa,_0x1d0e2c){return _0x152dfa(_0x1d0e2c);},'zcPUr':_0x18c23a(0x267),'lMilH':_0x18c23a(0xf4),'sAwvh':_0x18c23a(0x227)+_0x18c23a(0xe8)+_0x18c23a(0x1d5)+_0x18c23a(0x285),'PuUkv':function(_0x424d56,_0x3994a9){return _0x424d56===_0x3994a9;},'QUzAA':_0x18c23a(0x264),'anBGO':_0x18c23a(0x21f)+_0x18c23a(0xf8)+_0x18c23a(0x113),'qbcXx':_0x18c23a(0x262)+_0x18c23a(0x243),'Pvurz':function(_0x434f40,_0x48906d){return _0x434f40||_0x48906d;},'Alolq':_0x18c23a(0x14f)+_0x18c23a(0x251),'INcap':_0x18c23a(0x275),'DmyXl':_0x18c23a(0x15a)+_0x18c23a(0x255),'hdPtw':function(_0x527d95,_0x462dd8){return _0x527d95(_0x462dd8);},'rHANW':function(_0x327409){return _0x327409();},'CuDGi':_0x18c23a(0x15b)+_0x18c23a(0x1c7)+_0x18c23a(0x97),'jQFon':_0x18c23a(0x1c7)+_0x18c23a(0x125),'thsFu':_0x18c23a(0x14e),'aTCNv':_0x18c23a(0x15b)+_0x18c23a(0x8f)+_0x18c23a(0x1bb)+_0x18c23a(0x23f)+_0x18c23a(0x137),'xpYxi':function(_0x4cf38a){return _0x4cf38a();},'KihMZ':_0x18c23a(0x1c7)+_0x18c23a(0x276)+_0x18c23a(0xa4),'qUtBb':_0x18c23a(0x1c7)+_0x18c23a(0x219)+'d','QlBVA':_0x18c23a(0x1c7)+_0x18c23a(0x143)+_0x18c23a(0x26f),'tiAAI':_0x18c23a(0x15b)+_0x18c23a(0x1fd)+_0x18c23a(0x15f),'eNtED':function(_0x5998ae){return _0x5998ae();},'ZILxv':_0x18c23a(0x242),'QFCRm':_0x18c23a(0x261),'FOwUc':_0x18c23a(0x134)+_0x18c23a(0x75)+_0x18c23a(0x1f9),'diBVF':function(_0x2029a2,_0x5db702){return _0x2029a2(_0x5db702);},'ELZFg':_0x18c23a(0x187)+_0x18c23a(0x135)+'ed','MWUqD':_0x18c23a(0x12c),'ECyTC':function(_0x106bb4,_0x240f5a,_0x1ed612){return _0x106bb4(_0x240f5a,_0x1ed612);},'YmUzs':_0x18c23a(0x28a),'CBaPN':function(_0xa60df1,_0x19cc30){return _0xa60df1(_0x19cc30);},'GIlwc':_0x18c23a(0x250)+'e','GNaVT':_0x18c23a(0x1cc),'rrBRV':_0x18c23a(0x1e3),'cLPNv':function(_0x2e5a91){return _0x2e5a91();},'bGTLq':_0x18c23a(0x231)+_0x18c23a(0x154),'AQXPI':_0x18c23a(0x86)+_0x18c23a(0x129)+_0x18c23a(0x1d2)+_0x18c23a(0x225)+_0x18c23a(0x122)+_0x18c23a(0xac)+_0x18c23a(0x28c),'sddpg':function(_0x274c70,_0x502933){return _0x274c70(_0x502933);},'hwyBi':_0x18c23a(0x1c8)+_0x18c23a(0x166),'xVSdD':_0x18c23a(0xb8)+'2','FhaFl':function(_0x37c561){return _0x37c561();},'jwqfP':_0x18c23a(0x24f)+_0x18c23a(0x270)+_0x18c23a(0xa5),'XZjwG':function(_0x3514d0,_0xf99674){return _0x3514d0(_0xf99674);},'ojgfq':_0x18c23a(0x120),'ZIFpQ':_0x18c23a(0x1ed)+_0x18c23a(0x73)+_0x18c23a(0x18c),'BvLnr':_0x18c23a(0x7d)+_0x18c23a(0x1fe),'AZZbd':_0x18c23a(0xca)+_0x18c23a(0x94),'NKhgS':function(_0x216cea,_0x51cdee){return _0x216cea(_0x51cdee);},'rSodh':_0x18c23a(0x21a)+_0x18c23a(0x248)+_0x18c23a(0x16d),'QmIwQ':_0x18c23a(0x103)+_0x18c23a(0xb3)+_0x18c23a(0x92),'yXDnC':_0x18c23a(0x6d)+_0x18c23a(0xb0),'ZTnAF':_0x18c23a(0x167),'Dbwpv':_0x18c23a(0x109)+'ng','oXfOC':_0x18c23a(0x27d)+'fo','XbmfL':function(_0xb499f6,_0x5726d9){return _0xb499f6===_0x5726d9;},'poXnU':function(_0x5ed17f,_0x30b766){return _0x5ed17f===_0x30b766;},'lgbWx':function(_0x2a1e0c,_0x1d345e){return _0x2a1e0c===_0x1d345e;},'pCRRY':function(_0x4a2486,_0xb3f5d7){return _0x4a2486===_0xb3f5d7;},'Dooel':_0x18c23a(0x192),'ienqp':_0x18c23a(0x1e4),'ouxYx':function(_0x128c71,_0x3d38e0){return _0x128c71===_0x3d38e0;},'WrZsk':_0x18c23a(0x69)+_0x18c23a(0x1c5)+_0x18c23a(0x18e)+_0x18c23a(0x1c0),'pCetA':_0x18c23a(0x234)+_0x18c23a(0x140)+_0x18c23a(0x230)+_0x18c23a(0x161)+_0x18c23a(0xf9),'whyXs':function(_0x5a4034,_0x36a3d6){return _0x5a4034!==_0x36a3d6;},'yqsAT':function(_0x3124ed,_0xbfc439){return _0x3124ed===_0xbfc439;},'BONmU':function(_0x1a81dd,_0x1f0854){return _0x1a81dd===_0x1f0854;},'XZlJZ':_0x18c23a(0xf7)+_0x18c23a(0xb1),'pPdFQ':_0x18c23a(0xde),'jTWSc':function(_0x2662b0,_0x330b7d){return _0x2662b0===_0x330b7d;},'RFkaG':_0x18c23a(0x108),'ociFP':function(_0x512e9d,_0xbb3a99){return _0x512e9d===_0xbb3a99;},'chveB':_0x18c23a(0x22b),'IHqyG':_0x18c23a(0x18f)+_0x18c23a(0x9b)+_0x18c23a(0x197)+_0x18c23a(0xae),'eLejt':_0x18c23a(0x148),'PxMXn':function(_0x31ccf7,_0x438641){return _0x31ccf7===_0x438641;},'Ciptr':function(_0x511f8a,_0x8b5062){return _0x511f8a===_0x8b5062;},'IrRdx':_0x18c23a(0x157),'Rpcpa':function(_0x5ac1a8,_0x2392f4){return _0x5ac1a8===_0x2392f4;},'MrBBp':function(_0x194db4,_0x3a9f26){return _0x194db4===_0x3a9f26;},'QPUhn':function(_0x4a2f62,_0x3243fd){return _0x4a2f62===_0x3243fd;},'rCQXa':_0x18c23a(0x1a5)+_0x18c23a(0xc3),'RfCJL':_0x18c23a(0x16b)+_0x18c23a(0x204)+_0x18c23a(0xbf),'seCDp':_0x18c23a(0x8c)+_0x18c23a(0xa9),'hcgeg':_0x18c23a(0x184),'BBrrz':_0x18c23a(0x239)+_0x18c23a(0x194),'CgSfQ':_0x18c23a(0x145),'TkFFz':_0x18c23a(0x144)+_0x18c23a(0xb9)+_0x18c23a(0x83),'tBMiL':_0x18c23a(0xec)+_0x18c23a(0xb4)+'ew','leevW':_0x18c23a(0x228)+_0x18c23a(0x7b),'bPcLV':_0x18c23a(0xec)+_0x18c23a(0x1f0)};var _0x5282e0,_0x48e5c5;const {waWebSocketUrl:_0x5e05ec,connectTimeoutMs:_0x321d29,logger:_0x1c6fb7,keepAliveIntervalMs:_0x2249b3,browser:_0x16e26f,auth:_0x53452b,printQRInTerminal:_0x2f560d,defaultQueryTimeoutMs:_0x2c4095,transactionOpts:_0x337f54,qrTimeout:_0x45ebbb,makeSignalRepository:_0x16a353}=_0x50468e,_0x16d5ce=_0x475eaf[_0x18c23a(0x1b5)](typeof _0x5e05ec,_0x475eaf[_0x18c23a(0x1cf)])?new url_1[(_0x18c23a(0xee))](_0x5e05ec):_0x5e05ec;if(_0x50468e[_0x18c23a(0x105)]||_0x475eaf[_0x18c23a(0x168)](_0x16d5ce[_0x18c23a(0x96)],_0x475eaf[_0x18c23a(0xa8)]))throw new boom_1[(_0x18c23a(0x1bf))](_0x475eaf[_0x18c23a(0x7e)],{'statusCode':Types_1[_0x18c23a(0x7f)+_0x18c23a(0x171)][_0x18c23a(0x265)]});_0x475eaf[_0x18c23a(0x246)](_0x16d5ce[_0x18c23a(0x96)],_0x475eaf[_0x18c23a(0x1e7)])&&(_0x475eaf[_0x18c23a(0x6b)](_0x5282e0=_0x475eaf[_0x18c23a(0x257)](_0x53452b,null)||_0x475eaf[_0x18c23a(0x18b)](_0x53452b,void(0x16*0xf9+0x20fb+-0x3661))?void(-0x2*-0xbe7+-0xb62+-0xc*0x109):_0x53452b[_0x18c23a(0x1bc)],null)||_0x475eaf[_0x18c23a(0x10f)](_0x5282e0,void(0xf8f*-0x1+0x95*-0x4+0x11e3))?void(-0x3f9*-0x3+-0x1*-0x347+-0xf32):_0x5282e0[_0x18c23a(0x1e6)+'o'])&&_0x16d5ce[_0x18c23a(0xed)+'ms'][_0x18c23a(0x115)]('ED',_0x53452b[_0x18c23a(0x1bc)][_0x18c23a(0x1e6)+'o'][_0x18c23a(0x10b)](_0x475eaf[_0x18c23a(0x14b)]));const _0x5c03a7=new Client_1[(_0x18c23a(0xd9))+(_0x18c23a(0x13a))](_0x16d5ce,_0x50468e);_0x5c03a7[_0x18c23a(0x9a)]();const _0x2b8b21=(-0x1f4a+-0x1*0x1c96+0x3be0,Utils_1[_0x18c23a(0x27a)+_0x18c23a(0x1ad)])(_0x1c6fb7),_0x48be2c=Utils_1[_0x18c23a(0x6e)][_0x18c23a(0x193)+_0x18c23a(0x1f2)](),_0x5a7508=(-0x1*-0xdb1+-0x1183+-0x3d2*-0x1,Utils_1[_0x18c23a(0xa1)+_0x18c23a(0x112)])({'keyPair':_0x48be2c,'NOISE_HEADER':Defaults_1[_0x18c23a(0x238)+_0x18c23a(0x18d)],'logger':_0x1c6fb7,'routingInfo':_0x475eaf[_0x18c23a(0x80)](_0x48e5c5=_0x475eaf[_0x18c23a(0xd5)](_0x53452b,null)||_0x475eaf[_0x18c23a(0x27b)](_0x53452b,void(-0xa2c+-0x270c+-0x5a*-0x8c))?void(-0x1c0d*-0x1+-0x1a15+0x4*-0x7e):_0x53452b[_0x18c23a(0x1bc)],null)||_0x475eaf[_0x18c23a(0x1f4)](_0x48e5c5,void(0x8db*-0x1+0x14c6+-0xbeb))?void(-0x1ad2*-0x1+-0x2689+0xbb7*0x1):_0x48e5c5[_0x18c23a(0x1e6)+'o']}),{creds:_0xdbedb9}=_0x53452b,_0x1c6cc3=(-0x3d*-0x78+0x8aa+-0x2542,Utils_1[_0x18c23a(0x1d3)+_0x18c23a(0x1ee)+_0x18c23a(0x1e2)])(_0x53452b[_0x18c23a(0xd4)],_0x1c6fb7,_0x337f54),_0x381dc4=_0x475eaf[_0x18c23a(0x1da)](_0x16a353,{'creds':_0xdbedb9,'keys':_0x1c6cc3});let _0x4e2d50,_0xe46e67=-0xa0c+-0x95d+-0x47*-0x46,_0xdf496,_0x4d8da8,_0xa861e9=![];const _0x34663d=(-0x5*0x523+0x2*0x6a3+0xc69*0x1,Utils_1[_0x18c23a(0x24e)+_0x18c23a(0x9f)])(),_0x200b2d=()=>''+_0x34663d+_0xe46e67++,_0x4d6a71=(0x38c*0x9+0x2559+-0x4545,util_1[_0x18c23a(0x25f)])(_0x5c03a7[_0x18c23a(0x162)]),_0x52ff72=async _0x3f25ec=>{const _0x4b6b49=_0x18c23a;if(!_0x5c03a7[_0x4b6b49(0x1ea)])throw new boom_1[(_0x4b6b49(0x1bf))](_0x475eaf[_0x4b6b49(0xfd)],{'statusCode':Types_1[_0x4b6b49(0x7f)+_0x4b6b49(0x171)][_0x4b6b49(0x1f9)+_0x4b6b49(0xe5)]});const _0x1ee025=_0x5a7508[_0x4b6b49(0x260)+'e'](_0x3f25ec);await(0x763*-0x4+-0x1c52*-0x1+-0x1*-0x13a,Utils_1[_0x4b6b49(0x175)+_0x4b6b49(0x236)])(_0x321d29,async(_0x168807,_0x6e60e6)=>{const _0x50d18f=_0x4b6b49;try{await _0x4d6a71[_0x50d18f(0x6a)](_0x5c03a7,_0x1ee025),_0x475eaf[_0x50d18f(0x91)](_0x168807);}catch(_0x15dcf5){_0x475eaf[_0x50d18f(0x17c)](_0x6e60e6,_0x15dcf5);}});},_0x2c57ff=_0x27b37a=>{const _0x1f8a18=_0x18c23a;_0x475eaf[_0x1f8a18(0x246)](_0x1c6fb7[_0x1f8a18(0x1ce)],_0x475eaf[_0x1f8a18(0x1a2)])&&_0x1c6fb7[_0x1f8a18(0x10e)]({'xml':(0x1a38+-0x1*0x65d+0x17*-0xdd,WABinary_1[_0x1f8a18(0x209)+_0x1f8a18(0x1c4)])(_0x27b37a),'msg':_0x475eaf[_0x1f8a18(0x222)]});const _0x217273=(-0x2024+-0x21bd+0xd2d*0x5,WABinary_1[_0x1f8a18(0x76)+_0x1f8a18(0xdf)])(_0x27b37a);return _0x475eaf[_0x1f8a18(0x17c)](_0x52ff72,_0x217273);},_0x5a0ae4=(_0x59a830,_0x29db0a)=>{const _0x1e22b8=_0x18c23a;_0x1c6fb7[_0x1e22b8(0x194)]({'err':_0x59a830},_0x1e22b8(0x252)+_0x1e22b8(0x8a)+'\x27'+_0x29db0a+'\x27');const _0x4d1945=(_0x59a830&&(_0x59a830[_0x1e22b8(0xf0)]||_0x59a830[_0x1e22b8(0x1df)]||_0x475eaf[_0x1e22b8(0x17c)](String,_0x59a830)))[_0x1e22b8(0xbe)+'e']();if(_0x4d1945[_0x1e22b8(0x1cd)](_0x475eaf[_0x1e22b8(0x24c)])||_0x4d1945[_0x1e22b8(0x1cd)](_0x475eaf[_0x1e22b8(0x174)])&&_0x4d1945[_0x1e22b8(0x1cd)](_0x475eaf[_0x1e22b8(0x218)]))try{_0x475eaf[_0x1e22b8(0x17c)](_0x251981,!![])[_0x1e22b8(0x151)](_0x1ca9fb=>_0x1c6fb7[_0x1e22b8(0x1d4)]({'e':_0x1ca9fb},_0x1e22b8(0x1aa)+_0x1e22b8(0xd7)+_0x1e22b8(0x1a6)+_0x1e22b8(0xdb)+'c'));}catch(_0x4e1432){}if(_0x4d1945[_0x1e22b8(0x1cd)](_0x475eaf[_0x1e22b8(0x216)])||_0x4d1945[_0x1e22b8(0x1cd)](_0x475eaf[_0x1e22b8(0x26b)])){const _0x53fab8=Math[_0x1e22b8(0x13e)](0x38d9+0x14f3*-0x1+-0x2*-0x28a5,_0x50468e[_0x1e22b8(0x26e)+_0x1e22b8(0x12d)]||0xb0*-0x1c+-0x9f*0x13+0x3295);_0x1c6fb7[_0x1e22b8(0x200)]({'wait':_0x53fab8},_0x475eaf[_0x1e22b8(0x233)]),_0x475eaf[_0x1e22b8(0x8d)](setTimeout,()=>{},_0x53fab8);}},_0x505b8c=async _0x2ca998=>{const _0x51de96=_0x18c23a,_0x18924a={'Yjhht':_0x475eaf[_0x51de96(0x164)],'fFhBV':function(_0x184dce,_0x4d16a5){const _0x1c2a70=_0x51de96;return _0x475eaf[_0x1c2a70(0x17c)](_0x184dce,_0x4d16a5);},'zqhja':_0x475eaf[_0x51de96(0x1b7)],'hZWTY':_0x475eaf[_0x51de96(0x190)],'uvmbr':_0x475eaf[_0x51de96(0xea)]};if(!_0x5c03a7[_0x51de96(0x1ea)])throw new boom_1[(_0x51de96(0x1bf))](_0x475eaf[_0x51de96(0xfd)],{'statusCode':Types_1[_0x51de96(0x7f)+_0x51de96(0x171)][_0x51de96(0x1f9)+_0x51de96(0xe5)]});let _0x294e1f,_0x5f1ab3;const _0x1f1572=(-0xf9c+-0x4*-0x7e1+0x1fd*-0x8,Utils_1[_0x51de96(0x175)+_0x51de96(0x236)])(_0x321d29,(_0x5b5db4,_0x4b3262)=>{const _0x6fcc27=_0x51de96,_0x4ff49b=_0x18924a[_0x6fcc27(0x11e)][_0x6fcc27(0x11b)]('|');let _0x24b71b=-0x207a+-0xa3d+0x4bf*0x9;while(!![]){switch(_0x4ff49b[_0x24b71b++]){case'0':_0x5f1ab3=_0x18924a[_0x6fcc27(0x19d)](mapWebSocketError,_0x4b3262);continue;case'1':_0x294e1f=_0x5b5db4;continue;case'2':_0x5c03a7['on'](_0x18924a[_0x6fcc27(0x268)],_0x294e1f);continue;case'3':_0x5c03a7['on'](_0x18924a[_0x6fcc27(0x23d)],_0x5f1ab3);continue;case'4':_0x5c03a7['on'](_0x18924a[_0x6fcc27(0x21e)],_0x5f1ab3);continue;}break;}})[_0x51de96(0x241)](()=>{const _0x41857d=_0x51de96;_0x5c03a7[_0x41857d(0x1a1)](_0x18924a[_0x41857d(0x268)],_0x294e1f),_0x5c03a7[_0x41857d(0x1a1)](_0x18924a[_0x41857d(0x23d)],_0x5f1ab3),_0x5c03a7[_0x41857d(0x1a1)](_0x18924a[_0x41857d(0x21e)],_0x5f1ab3);});return _0x2ca998&&_0x475eaf[_0x51de96(0xc0)](_0x52ff72,_0x2ca998)[_0x51de96(0x151)](_0x5f1ab3),_0x1f1572;},_0x2b1fe4=async(_0x4f20e3,_0x29e4c3=_0x2c4095)=>{const _0x128abb=_0x18c23a,_0x368c2e={'ZRDwy':function(_0x108537,_0x3828de){const _0x31251c=_0x5cec;return _0x475eaf[_0x31251c(0x17c)](_0x108537,_0x3828de);},'MkeJn':_0x475eaf[_0x128abb(0xfd)]};let _0x1a57ae,_0x3f85ec;try{const _0x41af0c=await(0xe*0x4e+0x19*-0x14+-0x250,Utils_1[_0x128abb(0x175)+_0x128abb(0x236)])(_0x29e4c3,(_0x39951a,_0x502b7f)=>{const _0x5ad495=_0x128abb,_0x234163=_0x475eaf[_0x5ad495(0xf3)][_0x5ad495(0x11b)]('|');let _0x197f8c=0x1c65*0x1+0x1*-0x26e1+0xb*0xf4;while(!![]){switch(_0x234163[_0x197f8c++]){case'0':_0x1a57ae=_0x39951a;continue;case'1':_0x5c03a7['on'](_0x475eaf[_0x5ad495(0x190)],_0x3f85ec);continue;case'2':_0x5c03a7['on'](_0x5ad495(0x195)+_0x4f20e3,_0x1a57ae);continue;case'3':_0x3f85ec=_0x15ed26=>{const _0x105763=_0x5ad495;_0x368c2e[_0x105763(0x289)](_0x502b7f,_0x15ed26||new boom_1[(_0x105763(0x1bf))](_0x368c2e[_0x105763(0x199)],{'statusCode':Types_1[_0x105763(0x7f)+_0x105763(0x171)][_0x105763(0x1f9)+_0x105763(0xe5)]}));};continue;case'4':_0x5c03a7[_0x5ad495(0x1a1)](_0x475eaf[_0x5ad495(0xea)],_0x3f85ec);continue;}break;}});return _0x41af0c;}finally{_0x5c03a7[_0x128abb(0x1a1)](_0x128abb(0x195)+_0x4f20e3,_0x1a57ae),_0x5c03a7[_0x128abb(0x1a1)](_0x475eaf[_0x128abb(0x190)],_0x3f85ec),_0x5c03a7[_0x128abb(0x1a1)](_0x475eaf[_0x128abb(0xea)],_0x3f85ec);}},_0x52ae12=async(_0x116bd7,_0x705ea4)=>{const _0x547433=_0x18c23a;!_0x116bd7[_0x547433(0x20b)]['id']&&(_0x116bd7[_0x547433(0x20b)]['id']=_0x475eaf[_0x547433(0x1dc)](_0x200b2d));const _0x1d08a2=_0x116bd7[_0x547433(0x20b)]['id'],[_0x4b8fd0]=await Promise[_0x547433(0x22e)]([_0x475eaf[_0x547433(0x149)](_0x2b1fe4,_0x1d08a2,_0x705ea4),_0x475eaf[_0x547433(0x119)](_0x2c57ff,_0x116bd7)]);return _0x475eaf[_0x547433(0x124)](_0x475eaf[_0x547433(0xe3)],_0x4b8fd0)&&(-0x2*-0xd97+-0x1*0xc69+-0xec5,WABinary_1[_0x547433(0x1e5)+_0x547433(0x11f)])(_0x4b8fd0),_0x4b8fd0;},_0x3d3eb0=async()=>{const _0x964773=_0x18c23a;let _0x24dfac={'clientHello':{'ephemeral':_0x48be2c[_0x964773(0x277)]}};_0x24dfac=WAProto_1[_0x964773(0xda)][_0x964773(0x98)+_0x964773(0xdc)][_0x964773(0x1b0)](_0x24dfac),_0x1c6fb7[_0x964773(0x200)]({'browser':_0x16e26f,'helloMsg':_0x24dfac},_0x475eaf[_0x964773(0x210)]);const _0x2ee61d=WAProto_1[_0x964773(0xda)][_0x964773(0x98)+_0x964773(0xdc)][_0x964773(0x245)](_0x24dfac)[_0x964773(0x17f)](),_0x8c1ba7=await _0x475eaf[_0x964773(0x119)](_0x505b8c,_0x2ee61d),_0x36ead8=WAProto_1[_0x964773(0xda)][_0x964773(0x98)+_0x964773(0xdc)][_0x964773(0xd1)](_0x8c1ba7);_0x1c6fb7[_0x964773(0x10e)]({'handshake':_0x36ead8},_0x475eaf[_0x964773(0x1b3)]);const _0x4bc325=await _0x5a7508[_0x964773(0x116)+_0x964773(0x269)](_0x36ead8,_0xdbedb9[_0x964773(0xd8)]);let _0x100d45;!_0xdbedb9['me']?(_0x100d45=(-0x25f2+0x1c0e+0x9e4,Utils_1[_0x964773(0x15c)+_0x964773(0xf6)+_0x964773(0x1f6)])(_0xdbedb9,_0x50468e),_0x1c6fb7[_0x964773(0x200)]({'node':_0x100d45},_0x475eaf[_0x964773(0x1fa)])):(_0x100d45=(-0xd64+-0x26d6*0x1+-0xa72*-0x5,Utils_1[_0x964773(0x12e)+_0x964773(0x1d1)])(_0xdbedb9['me']['id'],_0x50468e),_0x1c6fb7[_0x964773(0x200)]({'node':_0x100d45},_0x475eaf[_0x964773(0x224)]));const _0x212d02=_0x5a7508[_0x964773(0xdd)](WAProto_1[_0x964773(0xda)][_0x964773(0x1e1)+_0x964773(0x191)][_0x964773(0x245)](_0x100d45)[_0x964773(0x17f)]());await _0x475eaf[_0x964773(0x1f3)](_0x52ff72,WAProto_1[_0x964773(0xda)][_0x964773(0x98)+_0x964773(0xdc)][_0x964773(0x245)]({'clientFinish':{'static':_0x4bc325,'payload':_0x212d02}})[_0x964773(0x17f)]()),_0x5a7508[_0x964773(0x1eb)](),_0x475eaf[_0x964773(0x91)](_0x1bbfb1);},_0x3280a3=async()=>{const _0x204c22=_0x18c23a,_0x1b1877=await _0x475eaf[_0x204c22(0x17c)](_0x52ae12,{'tag':'iq','attrs':{'id':_0x475eaf[_0x204c22(0x21d)](_0x200b2d),'xmlns':_0x475eaf[_0x204c22(0x1b9)],'type':_0x475eaf[_0x204c22(0x79)],'to':WABinary_1[_0x204c22(0x208)+_0x204c22(0xbc)]},'content':[{'tag':_0x475eaf[_0x204c22(0xc8)],'attrs':{}}]}),_0x8478d8=(0x10f*-0x5+-0x25fc+0x4cf*0x9,WABinary_1[_0x204c22(0x26c)+_0x204c22(0x280)])(_0x1b1877,_0x475eaf[_0x204c22(0xc8)]);return+_0x8478d8[_0x204c22(0x20b)][_0x204c22(0x23a)];},_0x4be4cb=async(_0x151689=Defaults_1[_0x18c23a(0x1ec)+_0x18c23a(0x81)])=>{const _0x46bb60=_0x18c23a,_0x8beb42={'JzoJQ':_0x475eaf[_0x46bb60(0xf5)],'QFedP':function(_0x343cdb,_0x112b5f){const _0x2e4adc=_0x46bb60;return _0x475eaf[_0x2e4adc(0x13f)](_0x343cdb,_0x112b5f);},'JmKJT':_0x475eaf[_0x46bb60(0x133)],'rkerw':_0x475eaf[_0x46bb60(0xba)]};await _0x1c6cc3[_0x46bb60(0x1b8)+'n'](async()=>{const _0x188827=_0x46bb60;_0x1c6fb7[_0x188827(0x200)]({'count':_0x151689},_0x8beb42[_0x188827(0x160)]);const {update:_0x56a76f,node:_0x59918a}=await(-0x4*-0x116+0x2bc*-0x1+-0x19c,Utils_1[_0x188827(0x11c)+_0x188827(0x82)])({'creds':_0xdbedb9,'keys':_0x1c6cc3},_0x151689);await _0x8beb42[_0x188827(0x279)](_0x52ae12,_0x59918a),_0x2b8b21[_0x188827(0x17e)](_0x8beb42[_0x188827(0x282)],_0x56a76f),_0x1c6fb7[_0x188827(0x200)]({'count':_0x151689},_0x8beb42[_0x188827(0x70)]);});},_0x251981=async()=>{const _0x210eaa=_0x18c23a,_0x5afbf2=await _0x475eaf[_0x210eaa(0x169)](_0x3280a3);_0x1c6fb7[_0x210eaa(0x200)](_0x5afbf2+(_0x210eaa(0x85)+_0x210eaa(0x1f7)+_0x210eaa(0x1ba))),_0x475eaf[_0x210eaa(0x7c)](_0x5afbf2,Defaults_1[_0x210eaa(0x146)+_0x210eaa(0x207)])&&await _0x475eaf[_0x210eaa(0x1db)](_0x4be4cb);},_0x155490=_0x3e5264=>{const _0xa2b3ba=_0x18c23a;_0x5a7508[_0xa2b3ba(0xaa)+'e'](_0x3e5264,_0x5a63be=>{const _0x41d681=_0xa2b3ba;var _0x504e34;_0x4e2d50=new Date();let _0x339627=![];_0x339627=_0x5c03a7[_0x41d681(0x17e)](_0x475eaf[_0x41d681(0x1b7)],_0x5a63be);if(!_0x475eaf[_0x41d681(0x14c)](_0x5a63be,Uint8Array)){const _0x3d3faf=_0x5a63be[_0x41d681(0x20b)]['id'];_0x475eaf[_0x41d681(0x246)](_0x1c6fb7[_0x41d681(0x1ce)],_0x475eaf[_0x41d681(0x1a2)])&&_0x1c6fb7[_0x41d681(0x10e)]({'xml':(0x2196+0x1ff6+-0x5*0xd1c,WABinary_1[_0x41d681(0x209)+_0x41d681(0x1c4)])(_0x5a63be),'msg':_0x475eaf[_0x41d681(0x249)]});_0x339627=_0x5c03a7[_0x41d681(0x17e)](''+Defaults_1[_0x41d681(0x16f)+_0x41d681(0x1a0)]+_0x3d3faf,_0x5a63be)||_0x339627;const _0xb795de=_0x5a63be[_0x41d681(0x117)],_0x1c27e4=_0x5a63be[_0x41d681(0x20b)]||{},_0x2d4264=Array[_0x41d681(0x26d)](_0x5a63be[_0x41d681(0x25a)])?_0x475eaf[_0x41d681(0x246)](_0x504e34=_0x5a63be[_0x41d681(0x25a)][0x245f*0x1+-0x1fdc+-0x483],null)||_0x475eaf[_0x41d681(0x246)](_0x504e34,void(-0x11dc+0xf1+-0x3d*-0x47))?void(-0xa76+0x11*0x16b+0x1*-0xda5):_0x504e34[_0x41d681(0x117)]:'';for(const _0x31243b of Object[_0x41d681(0xd4)](_0x1c27e4)){_0x339627=_0x5c03a7[_0x41d681(0x17e)](''+Defaults_1[_0x41d681(0x7a)+_0x41d681(0x256)]+_0xb795de+','+_0x31243b+':'+_0x1c27e4[_0x31243b]+','+_0x2d4264,_0x5a63be)||_0x339627,_0x339627=_0x5c03a7[_0x41d681(0x17e)](''+Defaults_1[_0x41d681(0x7a)+_0x41d681(0x256)]+_0xb795de+','+_0x31243b+':'+_0x1c27e4[_0x31243b],_0x5a63be)||_0x339627,_0x339627=_0x5c03a7[_0x41d681(0x17e)](''+Defaults_1[_0x41d681(0x7a)+_0x41d681(0x256)]+_0xb795de+','+_0x31243b,_0x5a63be)||_0x339627;}_0x339627=_0x5c03a7[_0x41d681(0x17e)](''+Defaults_1[_0x41d681(0x7a)+_0x41d681(0x256)]+_0xb795de+',,'+_0x2d4264,_0x5a63be)||_0x339627,_0x339627=_0x5c03a7[_0x41d681(0x17e)](''+Defaults_1[_0x41d681(0x7a)+_0x41d681(0x256)]+_0xb795de,_0x5a63be)||_0x339627,!_0x339627&&_0x475eaf[_0x41d681(0x223)](_0x1c6fb7[_0x41d681(0x1ce)],_0x475eaf[_0x41d681(0xc6)])&&_0x1c6fb7[_0x41d681(0x111)]({'unhandled':!![],'msgId':_0x3d3faf,'fromMe':![],'frame':_0x5a63be},_0x475eaf[_0x41d681(0x23c)]);}});},_0x3a4655=_0x31a58b=>{const _0x411126=_0x18c23a,_0x385bf5=_0x475eaf[_0x411126(0x156)][_0x411126(0x11b)]('|');let _0x29ab3a=-0x10b8+0xb03*-0x2+0x26be;while(!![]){switch(_0x385bf5[_0x29ab3a++]){case'0':_0xa861e9=!![];continue;case'1':if(_0xa861e9){_0x1c6fb7[_0x411126(0x10e)]({'trace':_0x475eaf[_0x411126(0x27e)](_0x31a58b,null)||_0x475eaf[_0x411126(0x27b)](_0x31a58b,void(0x1587+0x3d3+0x16*-0x127))?void(0xba7*-0x2+-0x1fe5+-0x3733*-0x1):_0x31a58b[_0x411126(0xf0)]},_0x475eaf[_0x411126(0x104)]);return;}continue;case'2':_0x5c03a7[_0x411126(0x22d)+_0x411126(0x181)](_0x475eaf[_0x411126(0x190)]);continue;case'3':_0x5c03a7[_0x411126(0x22d)+_0x411126(0x181)](_0x475eaf[_0x411126(0x16e)]);continue;case'4':_0x5c03a7[_0x411126(0x22d)+_0x411126(0x181)](_0x475eaf[_0x411126(0x1c3)]);continue;case'5':if(!_0x5c03a7[_0x411126(0xbd)]&&!_0x5c03a7[_0x411126(0xcd)])try{_0x5c03a7[_0x411126(0xbb)]();}catch(_0x39b1d9){}continue;case'6':_0x475eaf[_0x411126(0x1ac)](clearTimeout,_0x4d8da8);continue;case'7':_0x2b8b21[_0x411126(0x17e)](_0x475eaf[_0x411126(0x10d)],{'connection':_0x475eaf[_0x411126(0x190)],'lastDisconnect':{'error':_0x31a58b,'date':new Date()}});continue;case'8':_0x1c6fb7[_0x411126(0x200)]({'trace':_0x475eaf[_0x411126(0x223)](_0x31a58b,null)||_0x475eaf[_0x411126(0xa2)](_0x31a58b,void(-0x1*0x1da5+-0xc*0x212+-0x1d*-0x1e1))?void(-0x121+0x5*-0x679+-0x595*-0x6):_0x31a58b[_0x411126(0xf0)]},_0x31a58b?_0x475eaf[_0x411126(0x155)]:_0x475eaf[_0x411126(0x189)]);continue;case'9':_0x475eaf[_0x411126(0x119)](clearInterval,_0xdf496);continue;case'10':_0x2b8b21[_0x411126(0x22d)+_0x411126(0x181)](_0x475eaf[_0x411126(0x10d)]);continue;case'11':_0x5c03a7[_0x411126(0x22d)+_0x411126(0x181)](_0x475eaf[_0x411126(0xea)]);continue;}break;}},_0x1adc6b=async()=>{const _0x23fb40=_0x18c23a,_0x50c32f={'OnsZw':_0x475eaf[_0x23fb40(0x142)],'DfgyM':function(_0xf6d0f6,_0x330847){const _0x3e9728=_0x23fb40;return _0x475eaf[_0x3e9728(0x119)](_0xf6d0f6,_0x330847);},'kjkrX':_0x475eaf[_0x23fb40(0x190)],'VROIC':_0x475eaf[_0x23fb40(0xea)],'kykXV':_0x475eaf[_0x23fb40(0x1c3)]};if(_0x5c03a7[_0x23fb40(0x1ea)])return;if(_0x5c03a7[_0x23fb40(0xbd)]||_0x5c03a7[_0x23fb40(0xcd)])throw new boom_1[(_0x23fb40(0x1bf))](_0x475eaf[_0x23fb40(0xfd)],{'statusCode':Types_1[_0x23fb40(0x7f)+_0x23fb40(0x171)][_0x23fb40(0x1f9)+_0x23fb40(0xe5)]});let _0x32afba,_0x12ac58;await new Promise((_0x22f7c3,_0x5c45ec)=>{const _0x11bb72=_0x23fb40,_0x34a758=_0x50c32f[_0x11bb72(0x78)][_0x11bb72(0x11b)]('|');let _0x3387fd=-0x1be4+-0x1e9d*0x1+0x3a81*0x1;while(!![]){switch(_0x34a758[_0x3387fd++]){case'0':_0x12ac58=_0x50c32f[_0x11bb72(0x9d)](mapWebSocketError,_0x5c45ec);continue;case'1':_0x5c03a7['on'](_0x50c32f[_0x11bb72(0x19a)],_0x12ac58);continue;case'2':_0x32afba=()=>_0x22f7c3(undefined);continue;case'3':_0x5c03a7['on'](_0x50c32f[_0x11bb72(0x182)],_0x12ac58);continue;case'4':_0x5c03a7['on'](_0x50c32f[_0x11bb72(0x128)],_0x32afba);continue;}break;}})[_0x23fb40(0x241)](()=>{const _0x29c995=_0x23fb40;_0x5c03a7[_0x29c995(0x1a1)](_0x50c32f[_0x29c995(0x128)],_0x32afba),_0x5c03a7[_0x29c995(0x1a1)](_0x50c32f[_0x29c995(0x19a)],_0x12ac58),_0x5c03a7[_0x29c995(0x1a1)](_0x50c32f[_0x29c995(0x182)],_0x12ac58);});},_0x1bbfb1=()=>_0xdf496=setInterval(()=>{const _0x20d2bd=_0x18c23a,_0x5b0028={'LghJu':_0x475eaf[_0x20d2bd(0x13d)]};!_0x4e2d50&&(_0x4e2d50=new Date());const _0x46d1f6=_0x475eaf[_0x20d2bd(0xab)](Date[_0x20d2bd(0x1b1)](),_0x4e2d50[_0x20d2bd(0xc1)]());if(_0x475eaf[_0x20d2bd(0x232)](_0x46d1f6,_0x475eaf[_0x20d2bd(0x1cb)](_0x2249b3,-0x61*0x49+0x5f4+-0x9*-0x495)))_0x475eaf[_0x20d2bd(0x1f3)](_0x3a4655,new boom_1[(_0x20d2bd(0x1bf))](_0x475eaf[_0x20d2bd(0x183)],{'statusCode':Types_1[_0x20d2bd(0x7f)+_0x20d2bd(0x171)][_0x20d2bd(0x1f9)+_0x20d2bd(0x273)]}));else _0x5c03a7[_0x20d2bd(0x1ea)]?_0x475eaf[_0x20d2bd(0x1da)](_0x52ae12,{'tag':'iq','attrs':{'id':_0x475eaf[_0x20d2bd(0x91)](_0x200b2d),'to':WABinary_1[_0x20d2bd(0x208)+_0x20d2bd(0xbc)],'type':_0x475eaf[_0x20d2bd(0x79)],'xmlns':_0x475eaf[_0x20d2bd(0x188)]},'content':[{'tag':_0x475eaf[_0x20d2bd(0x25d)],'attrs':{}}]})[_0x20d2bd(0x151)](_0x2de444=>{const _0x5a1079=_0x20d2bd;_0x1c6fb7[_0x5a1079(0x194)]({'trace':_0x2de444[_0x5a1079(0xf0)]},_0x5b0028[_0x5a1079(0xd3)]);}):_0x1c6fb7[_0x20d2bd(0x1d4)](_0x475eaf[_0x20d2bd(0x20a)]);},_0x2249b3),_0x5f1479=_0x2ad679=>_0x52ae12({'tag':'iq','attrs':{'to':WABinary_1[_0x18c23a(0x208)+_0x18c23a(0xbc)],'xmlns':_0x18c23a(0x1c2),'type':_0x18c23a(0x264)},'content':[{'tag':_0x2ad679,'attrs':{}}]}),_0x46ee80=async _0x160dac=>{const _0x4173d6=_0x18c23a;var _0x254436;const _0x2debe1=_0x475eaf[_0x4173d6(0x27e)](_0x254436=_0x53452b[_0x4173d6(0x1bc)]['me'],null)||_0x475eaf[_0x4173d6(0x1f8)](_0x254436,void(0x116*0x16+0x1d19*0x1+-0x34fd))?void(-0x2c*0x9+0x14c7+-0x133b):_0x254436['id'];_0x2debe1&&await _0x475eaf[_0x4173d6(0x1f3)](_0x2c57ff,{'tag':'iq','attrs':{'to':WABinary_1[_0x4173d6(0x208)+_0x4173d6(0xbc)],'type':_0x475eaf[_0x4173d6(0x1c1)],'id':_0x475eaf[_0x4173d6(0x91)](_0x200b2d),'xmlns':'md'},'content':[{'tag':_0x475eaf[_0x4173d6(0x13c)],'attrs':{'jid':_0x2debe1,'reason':_0x475eaf[_0x4173d6(0x1f5)]}}]}),_0x475eaf[_0x4173d6(0x119)](_0x3a4655,new boom_1[(_0x4173d6(0x1bf))](_0x475eaf[_0x4173d6(0xc9)](_0x160dac,_0x475eaf[_0x4173d6(0x201)]),{'statusCode':Types_1[_0x4173d6(0x7f)+_0x4173d6(0x171)][_0x4173d6(0x265)]}));},_0x2e914a=async(_0x21af49,_0x20ec4=_0x18c23a(0x12b))=>{const _0x10c1f1=_0x18c23a,_0xc86153=_0x475eaf[_0x10c1f1(0x28b)][_0x10c1f1(0x11b)]('|');let _0xd5d1b1=-0xd39+-0x1f32+-0x53*-0x89;while(!![]){switch(_0xc86153[_0xd5d1b1++]){case'0':_0x20ec4?_0x53452b[_0x10c1f1(0x1bc)][_0x10c1f1(0xe0)+'e']=_0x20ec4[_0x10c1f1(0x89)+'e']():_0x53452b[_0x10c1f1(0x1bc)][_0x10c1f1(0xe0)+'e']=(-0x2ab*0xa+-0x1*-0x5a1+0x11*0x13d,Utils_1[_0x10c1f1(0x102)+_0x10c1f1(0x121)])((0x1a80+-0x3*0xbdf+0x91d,crypto_1[_0x10c1f1(0x253)+'s'])(0x1*0x166+0x2136+0x4f1*-0x7));continue;case'1':_0x53452b[_0x10c1f1(0x1bc)]['me']={'id':(0x3b*-0x89+-0xe9b*-0x1+0x16a*0xc,WABinary_1[_0x10c1f1(0x179)])(_0x21af49,_0x475eaf[_0x10c1f1(0x240)]),'name':'~'};continue;case'2':return _0x53452b[_0x10c1f1(0x1bc)][_0x10c1f1(0xe0)+'e'];case'3':await _0x475eaf[_0x10c1f1(0x153)](_0x2c57ff,{'tag':'iq','attrs':{'to':WABinary_1[_0x10c1f1(0x208)+_0x10c1f1(0xbc)],'type':_0x475eaf[_0x10c1f1(0x1c1)],'id':_0x475eaf[_0x10c1f1(0x217)](_0x200b2d),'xmlns':'md'},'content':[{'tag':_0x475eaf[_0x10c1f1(0x90)],'attrs':{'jid':_0x53452b[_0x10c1f1(0x1bc)]['me']['id'],'stage':_0x475eaf[_0x10c1f1(0x281)],'should_show_push_notification':_0x475eaf[_0x10c1f1(0x1ae)]},'content':[{'tag':_0x475eaf[_0x10c1f1(0xe9)],'attrs':{},'content':await _0x475eaf[_0x10c1f1(0x215)](_0x19ed82)},{'tag':_0x475eaf[_0x10c1f1(0x1b6)],'attrs':{},'content':_0x53452b[_0x10c1f1(0x1bc)][_0x10c1f1(0xd8)][_0x10c1f1(0x277)]},{'tag':_0x475eaf[_0x10c1f1(0x25c)],'attrs':{},'content':(-0x422+0x1cdb+0x1*-0x18b9,Utils_1[_0x10c1f1(0x172)+_0x10c1f1(0xc4)])(_0x16e26f[-0x341+0x7e*-0x3b+0x204c])},{'tag':_0x475eaf[_0x10c1f1(0x126)],'attrs':{},'content':_0x16e26f[0x1c67+0x1647+-0x1*0x32ad]+'\x20('+_0x16e26f[-0x18c1+0x4f*0x9+0x3a*0x61]+')'},{'tag':_0x475eaf[_0x10c1f1(0xcc)],'attrs':{},'content':'0'}]}]});continue;case'4':_0x2b8b21[_0x10c1f1(0x17e)](_0x475eaf[_0x10c1f1(0x133)],_0x53452b[_0x10c1f1(0x1bc)]);continue;}break;}};async function _0x19ed82(){const _0x17ec94=_0x18c23a,_0x141447=(-0x2153+-0x198+0x22eb*0x1,crypto_1[_0x17ec94(0x253)+'s'])(0x19fd+0x1*-0x1bd9+-0x2*-0xfe),_0x561096=(-0x3*-0xc53+0x83*-0x27+0x2*-0x882,crypto_1[_0x17ec94(0x253)+'s'])(0x100+-0x711+0x3*0x20b),_0x416e92=await(0x7*0x49c+-0x2ce*0x1+-0x3*0x9d2,Utils_1[_0x17ec94(0x9e)+_0x17ec94(0x71)])(_0x53452b[_0x17ec94(0x1bc)][_0x17ec94(0xe0)+'e'],_0x141447),_0x5475d4=(0x5f3+0x20e1+-0x7c4*0x5,Utils_1[_0x17ec94(0x25e)+_0x17ec94(0x6c)])(_0x53452b[_0x17ec94(0x1bc)][_0x17ec94(0x14a)+_0x17ec94(0x18a)+_0x17ec94(0x165)][_0x17ec94(0x277)],_0x416e92,_0x561096);return Buffer[_0x17ec94(0x202)]([_0x141447,_0x561096,_0x5475d4]);}const _0x2deaec=_0x4e6c14=>{const _0x6ca922=_0x18c23a;return _0x475eaf[_0x6ca922(0x1ac)](_0x52ae12,{'tag':'iq','attrs':{'to':WABinary_1[_0x6ca922(0x208)+_0x6ca922(0xbc)],'id':_0x475eaf[_0x6ca922(0x283)](_0x200b2d),'xmlns':_0x475eaf[_0x6ca922(0xc5)]},'content':[{'tag':_0x475eaf[_0x6ca922(0x1a7)],'attrs':{},'content':_0x4e6c14}]});};_0x5c03a7['on'](_0x475eaf[_0x18c23a(0x16e)],_0x155490),_0x5c03a7['on'](_0x475eaf[_0x18c23a(0x1c3)],async()=>{const _0x4ebb7b=_0x18c23a;try{await _0x475eaf[_0x4ebb7b(0x1dc)](_0x3d3eb0);}catch(_0x2bc18d){_0x1c6fb7[_0x4ebb7b(0x194)]({'err':_0x2bc18d},_0x475eaf[_0x4ebb7b(0x24d)]),_0x475eaf[_0x4ebb7b(0x1da)](_0x3a4655,_0x2bc18d);}}),_0x5c03a7['on'](_0x475eaf[_0x18c23a(0xea)],_0x475eaf[_0x18c23a(0x17c)](mapWebSocketError,_0x3a4655)),_0x5c03a7['on'](_0x475eaf[_0x18c23a(0x190)],()=>_0x3a4655(new boom_1[(_0x18c23a(0x1bf))](_0x18c23a(0xca)+_0x18c23a(0xb6)+'d',{'statusCode':Types_1[_0x18c23a(0x7f)+_0x18c23a(0x171)][_0x18c23a(0x1f9)+_0x18c23a(0xe5)]}))),_0x5c03a7['on'](_0x475eaf[_0x18c23a(0x22f)],()=>_0x3a4655(new boom_1[(_0x18c23a(0x1bf))](_0x18c23a(0xca)+_0x18c23a(0xb6)+_0x18c23a(0x19e)+'r',{'statusCode':Types_1[_0x18c23a(0x7f)+_0x18c23a(0x171)][_0x18c23a(0x1f9)+_0x18c23a(0xe5)]}))),_0x5c03a7['on'](_0x475eaf[_0x18c23a(0x8b)],async _0x4f13b3=>{const _0x2849c7=_0x18c23a,_0xa91d06={'tag':'iq','attrs':{'to':WABinary_1[_0x2849c7(0x208)+_0x2849c7(0xbc)],'type':_0x475eaf[_0x2849c7(0xd2)],'id':_0x4f13b3[_0x2849c7(0x20b)]['id']}};await _0x475eaf[_0x2849c7(0xe4)](_0x2c57ff,_0xa91d06);const _0x373580=(0x164d+-0x26b*0x1+-0x13e2,WABinary_1[_0x2849c7(0x26c)+_0x2849c7(0x280)])(_0x4f13b3,_0x475eaf[_0x2849c7(0x13b)]),_0x32a533=(0x111a+-0x805+0x1d1*-0x5,WABinary_1[_0x2849c7(0x26c)+_0x2849c7(0x110)+'n'])(_0x373580,_0x475eaf[_0x2849c7(0x1fc)]),_0x3fbadf=Buffer[_0x2849c7(0x20d)](_0xdbedb9[_0x2849c7(0xd8)][_0x2849c7(0x277)])[_0x2849c7(0x10b)](_0x475eaf[_0x2849c7(0x20f)]),_0x754ba0=Buffer[_0x2849c7(0x20d)](_0xdbedb9[_0x2849c7(0x274)+_0x2849c7(0x106)][_0x2849c7(0x277)])[_0x2849c7(0x10b)](_0x475eaf[_0x2849c7(0x20f)]),_0x15120e=_0xdbedb9[_0x2849c7(0x99)+'ey'];let _0x3d030d=_0x475eaf[_0x2849c7(0xc9)](_0x45ebbb,-0x1*0xf28f+-0xf4e9+0x2d1d8);const _0x4b6f7c=()=>{const _0x3f4966=_0x2849c7;if(!_0x5c03a7[_0x3f4966(0x1ea)])return;const _0x5b58bc=_0x32a533[_0x3f4966(0x1af)]();if(!_0x5b58bc){_0x475eaf[_0x3f4966(0x114)](_0x3a4655,new boom_1[(_0x3f4966(0x1bf))](_0x475eaf[_0x3f4966(0xa7)],{'statusCode':Types_1[_0x3f4966(0x7f)+_0x3f4966(0x171)][_0x3f4966(0x6f)]}));return;}const _0x477854=_0x5b58bc[_0x3f4966(0x25a)][_0x3f4966(0x10b)](_0x475eaf[_0x3f4966(0x20c)]),_0x35f637=[_0x477854,_0x3fbadf,_0x754ba0,_0x15120e][_0x3f4966(0x220)](',');_0x2b8b21[_0x3f4966(0x17e)](_0x475eaf[_0x3f4966(0x10d)],{'qr':_0x35f637}),_0x4d8da8=_0x475eaf[_0x3f4966(0x107)](setTimeout,_0x4b6f7c,_0x3d030d),_0x3d030d=_0x475eaf[_0x3f4966(0xc9)](_0x45ebbb,-0x3d*-0x1fb+0x5f22+-0x89d1);};_0x475eaf[_0x2849c7(0x8e)](_0x4b6f7c);}),_0x5c03a7['on'](_0x475eaf[_0x18c23a(0x1b2)],async _0x7b507d=>{const _0x33da9b=_0x18c23a;_0x1c6fb7[_0x33da9b(0x111)](_0x475eaf[_0x33da9b(0x25b)]);try{const {reply:_0x28c671,creds:_0x5c1cff}=(0x5*-0x2cf+-0x1d22+0x1*0x2b2d,Utils_1[_0x33da9b(0x22a)+_0x33da9b(0x176)+_0x33da9b(0x166)])(_0x7b507d,_0xdbedb9);_0x1c6fb7[_0x33da9b(0x200)]({'me':_0x5c1cff['me'],'platform':_0x5c1cff[_0x33da9b(0x101)]},_0x475eaf[_0x33da9b(0x15e)]),_0x2b8b21[_0x33da9b(0x17e)](_0x475eaf[_0x33da9b(0x133)],_0x5c1cff),_0x2b8b21[_0x33da9b(0x17e)](_0x475eaf[_0x33da9b(0x10d)],{'isNewLogin':!![],'qr':undefined}),await _0x475eaf[_0x33da9b(0x22c)](_0x2c57ff,_0x28c671);}catch(_0x20408d){_0x1c6fb7[_0x33da9b(0x200)]({'trace':_0x20408d[_0x33da9b(0xf0)]},_0x475eaf[_0x33da9b(0x17a)]),_0x475eaf[_0x33da9b(0x1f3)](_0x3a4655,_0x20408d);}}),_0x5c03a7['on'](_0x475eaf[_0x18c23a(0x14d)],async _0x3519b0=>{const _0x2fcdd2=_0x18c23a;try{const _0x2fe8bd=_0x475eaf[_0x2fcdd2(0xa0)][_0x2fcdd2(0x11b)]('|');let _0x20b7b0=-0xb4a*-0x2+-0x9*-0x1b3+-0x25df;while(!![]){switch(_0x2fe8bd[_0x20b7b0++]){case'0':await _0x475eaf[_0x2fcdd2(0x93)](_0x251981);continue;case'1':_0x2b8b21[_0x2fcdd2(0x17e)](_0x475eaf[_0x2fcdd2(0x133)],{'me':{..._0x53452b[_0x2fcdd2(0x1bc)]['me'],'lid':_0x3519b0[_0x2fcdd2(0x20b)][_0x2fcdd2(0x130)]}});continue;case'2':_0x2b8b21[_0x2fcdd2(0x17e)](_0x475eaf[_0x2fcdd2(0x10d)],{'connection':_0x475eaf[_0x2fcdd2(0x1c3)]});continue;case'3':_0x1c6fb7[_0x2fcdd2(0x200)](_0x475eaf[_0x2fcdd2(0x1f1)]);continue;case'4':_0x475eaf[_0x2fcdd2(0x88)](clearTimeout,_0x4d8da8);continue;case'5':await _0x475eaf[_0x2fcdd2(0x22c)](_0x5f1479,_0x475eaf[_0x2fcdd2(0x1b4)]);continue;}break;}}catch(_0x16b439){_0x1c6fb7[_0x2fcdd2(0x194)]({'err':_0x16b439},_0x475eaf[_0x2fcdd2(0xcf)]),_0x475eaf[_0x2fcdd2(0x114)](_0x3a4655,_0x16b439);}}),_0x5c03a7['on'](_0x475eaf[_0x18c23a(0xeb)],_0x130b01=>{const _0x5a5516=_0x18c23a;_0x1c6fb7[_0x5a5516(0x194)]({'node':_0x130b01},_0x475eaf[_0x5a5516(0xb7)]);const {reason:_0x100daa,statusCode:_0x240738}=(-0x1be1+0x2635+-0x1*0xa54,Utils_1[_0x5a5516(0xe7)+_0x5a5516(0x17b)+_0x5a5516(0xd6)])(_0x130b01);_0x475eaf[_0x5a5516(0x114)](_0x3a4655,new boom_1[(_0x5a5516(0x1bf))](_0x5a5516(0x24a)+_0x5a5516(0x9c)+_0x100daa+')',{'statusCode':_0x240738,'data':_0x130b01}));}),_0x5c03a7['on'](_0x475eaf[_0x18c23a(0x272)],_0x236001=>{const _0x3a93e7=_0x18c23a,_0x55d373=+(_0x236001[_0x3a93e7(0x20b)][_0x3a93e7(0x11a)]||-0x14ce+0x414+-0x6*-0x31d);_0x475eaf[_0x3a93e7(0x153)](_0x3a4655,new boom_1[(_0x3a93e7(0x1bf))](_0x475eaf[_0x3a93e7(0x266)],{'statusCode':_0x55d373,'data':_0x236001[_0x3a93e7(0x20b)]}));}),_0x5c03a7['on'](_0x475eaf[_0x18c23a(0x1ab)],()=>{const _0x1252f8=_0x18c23a;_0x475eaf[_0x1252f8(0xe1)](_0x3a4655,new boom_1[(_0x1252f8(0x1bf))](_0x475eaf[_0x1252f8(0x1a8)],{'statusCode':Types_1[_0x1252f8(0x7f)+_0x1252f8(0x171)][_0x1252f8(0x20e)+_0x1252f8(0xfc)]}));}),_0x5c03a7['on'](_0x475eaf[_0x18c23a(0x15d)],_0x1c0db5=>{const _0x2e7d4f=_0x18c23a;_0x1c6fb7[_0x2e7d4f(0x200)](_0x475eaf[_0x2e7d4f(0x19c)],JSON[_0x2e7d4f(0xb2)](_0x1c0db5)),_0x475eaf[_0x2e7d4f(0x153)](_0x2c57ff,{'tag':'ib','attrs':{},'content':[{'tag':_0x475eaf[_0x2e7d4f(0xa3)],'attrs':{'count':_0x475eaf[_0x2e7d4f(0x1bd)]}}]});}),_0x5c03a7['on'](_0x475eaf[_0x18c23a(0xb5)],_0xd6fee6=>{const _0x3e4324=_0x18c23a,_0x3f2c70=(-0x17*0x3f+0xed1+-0x4*0x24a,WABinary_1[_0x3e4324(0x26c)+_0x3e4324(0x280)])(_0xd6fee6,_0x475eaf[_0x3e4324(0x21c)]),_0x5de7a4=(-0x1*0x1273+0x14bb*-0x1+-0x127*-0x22,WABinary_1[_0x3e4324(0x26c)+_0x3e4324(0x280)])(_0x3f2c70,_0x475eaf[_0x3e4324(0x259)]);(_0x475eaf[_0x3e4324(0x27b)](_0x5de7a4,null)||_0x475eaf[_0x3e4324(0x223)](_0x5de7a4,void(0x2f9*-0x3+-0xeec*-0x1+-0x601))?void(0x107*-0x5+0x1a59+-0x1536):_0x5de7a4[_0x3e4324(0x25a)])&&(_0x53452b[_0x3e4324(0x1bc)][_0x3e4324(0x1e6)+'o']=Buffer[_0x3e4324(0x20d)](_0x475eaf[_0x3e4324(0x180)](_0x5de7a4,null)||_0x475eaf[_0x3e4324(0x127)](_0x5de7a4,void(-0x2*-0x487+-0x2fb+-0x613))?void(0x171*-0x11+-0x2169*-0x1+-0x8e8):_0x5de7a4[_0x3e4324(0x25a)]),_0x2b8b21[_0x3e4324(0x17e)](_0x475eaf[_0x3e4324(0x133)],_0x53452b[_0x3e4324(0x1bc)]));});let _0x5ce20c=![];return process[_0x18c23a(0x1fb)](()=>{const _0x348459=_0x18c23a;var _0x3c5c83;(_0x475eaf[_0x348459(0x10a)](_0x3c5c83=_0xdbedb9['me'],null)||_0x475eaf[_0x348459(0x18b)](_0x3c5c83,void(-0x15b3+0x1*-0x1c63+-0x190b*-0x2))?void(-0x392+0x3*0x33b+0x61f*-0x1):_0x3c5c83['id'])&&(_0x2b8b21[_0x348459(0x1e0)](),_0x5ce20c=!![]),_0x2b8b21[_0x348459(0x17e)](_0x475eaf[_0x348459(0x10d)],{'connection':_0x475eaf[_0x348459(0x185)],'receivedPendingNotifications':![],'qr':undefined});}),_0x5c03a7['on'](_0x475eaf[_0x18c23a(0xa6)],_0x49cd04=>{const _0x4c25e5=_0x18c23a,_0x300b58=(0x170c+0x1bcc*-0x1+0x260*0x2,WABinary_1[_0x4c25e5(0x26c)+_0x4c25e5(0x280)])(_0x49cd04,_0x475eaf[_0x4c25e5(0xe6)]),_0x5eb5e2=+((_0x475eaf[_0x4c25e5(0x1be)](_0x300b58,null)||_0x475eaf[_0x4c25e5(0x246)](_0x300b58,void(-0x1122+-0x461+-0x1583*-0x1))?void(-0x1920+0xa5a+0xec6):_0x300b58[_0x4c25e5(0x20b)][_0x4c25e5(0x211)])||-0x2462+0x686+-0x4e*-0x62);_0x1c6fb7[_0x4c25e5(0x200)](_0x4c25e5(0x118)+_0x5eb5e2+(_0x4c25e5(0x12a)+_0x4c25e5(0xef)+_0x4c25e5(0xce)+'s')),_0x5ce20c&&(_0x2b8b21[_0x4c25e5(0x1ef)](),_0x1c6fb7[_0x4c25e5(0x10e)](_0x475eaf[_0x4c25e5(0x19f)])),_0x2b8b21[_0x4c25e5(0x17e)](_0x475eaf[_0x4c25e5(0x10d)],{'receivedPendingNotifications':!![]});}),_0x2b8b21['on'](_0x475eaf[_0x18c23a(0x133)],_0x392bf4=>{const _0x2a1da5=_0x18c23a,_0x5959ba={'lVHtF':_0x475eaf[_0x2a1da5(0x1ff)]};var _0x430151,_0x596719;const _0x452ce5=_0x475eaf[_0x2a1da5(0x223)](_0x430151=_0x392bf4['me'],null)||_0x475eaf[_0x2a1da5(0x127)](_0x430151,void(-0x20f+0x9f6+0x7e7*-0x1))?void(0x3*0x887+0x298+0x1c2d*-0x1):_0x430151[_0x2a1da5(0xf1)];_0x475eaf[_0x2a1da5(0x221)](_0x475eaf[_0x2a1da5(0x173)](_0x596719=_0xdbedb9['me'],null)||_0x475eaf[_0x2a1da5(0x257)](_0x596719,void(-0x1*-0x106b+-0x1*-0x9a4+0x1a0f*-0x1))?void(-0x28d*0x8+0x1*-0x368+0x8*0x2fa):_0x596719[_0x2a1da5(0xf1)],_0x452ce5)&&(_0x1c6fb7[_0x2a1da5(0x111)]({'name':_0x452ce5},_0x475eaf[_0x2a1da5(0x213)]),_0x475eaf[_0x2a1da5(0x1ac)](_0x2c57ff,{'tag':_0x475eaf[_0x2a1da5(0x158)],'attrs':{'name':_0x452ce5}})[_0x2a1da5(0x151)](_0x38c12f=>{const _0x475fdf=_0x2a1da5;_0x1c6fb7[_0x475fdf(0x1d4)]({'trace':_0x38c12f[_0x475fdf(0xf0)]},_0x5959ba[_0x475fdf(0x95)]);})),Object[_0x2a1da5(0x19b)](_0xdbedb9,_0x392bf4);}),_0x2f560d&&(0x42*-0x22+0x2400+-0x1b3c,Utils_1[_0x18c23a(0x1d0)+_0x18c23a(0x1c9)+_0x18c23a(0x27f)])(_0x2b8b21,_0x1c6fb7),{'type':'md','ws':_0x5c03a7,'ev':_0x2b8b21,'authState':{'creds':_0xdbedb9,'keys':_0x1c6cc3},'signalRepository':_0x381dc4,get 'user'(){const _0xa6ce5d=_0x18c23a;return _0x53452b[_0xa6ce5d(0x1bc)]['me'];},'generateMessageTag':_0x200b2d,'query':_0x52ae12,'waitForMessage':_0x2b1fe4,'waitForSocketOpen':_0x1adc6b,'sendRawMessage':_0x52ff72,'sendNode':_0x2c57ff,'logout':_0x46ee80,'end':_0x3a4655,'onUnexpectedError':_0x5a0ae4,'uploadPreKeys':_0x4be4cb,'uploadPreKeysToServerIfRequired':_0x251981,'requestPairingCode':_0x2e914a,'waitForConnectionUpdate':(0xad*-0x23+0x200a+-0x863,Utils_1[_0x18c23a(0x170)+_0x18c23a(0xd0)+_0x18c23a(0x206)])(_0x2b8b21),'sendWAMBuffer':_0x2deaec};};function _0x5cec(_0x25091d,_0x50f5be){const _0xa8fb72=_0x5a02();return _0x5cec=function(_0x10b21d,_0x2616cf){_0x10b21d=_0x10b21d-(0x2528*0x1+-0x25ee+0x12f*0x1);let _0x505ff0=_0xa8fb72[_0x10b21d];return _0x505ff0;},_0x5cec(_0x25091d,_0x50f5be);}exports[_0x1af0fe(0xe2)]=makeSocket;function mapWebSocketError(_0x22f763){const _0x5575b9={'YmGfU':function(_0x23ee6d,_0x48bfb6){return _0x23ee6d(_0x48bfb6);},'YbAuu':function(_0x3cd865,_0x4b69b9){return _0x3cd865===_0x4b69b9;},'iQGjY':function(_0x53249b,_0x2405cb){return _0x53249b===_0x2405cb;}};return _0x36f551=>{const _0x1970a7=_0x5cec;_0x5575b9[_0x1970a7(0x11d)](_0x22f763,new boom_1[(_0x1970a7(0x1bf))](_0x1970a7(0x212)+_0x1970a7(0x263)+(_0x5575b9[_0x1970a7(0x178)](_0x36f551,null)||_0x5575b9[_0x1970a7(0x203)](_0x36f551,void(0x1*-0x2395+0x23ff+-0x35*0x2))?void(-0x1bf6+0x15cd+0x629):_0x36f551[_0x1970a7(0x1df)])+')',{'statusCode':(0x26bb+0x1a2e+-0x40e9,Utils_1[_0x1970a7(0x1a9)+_0x1970a7(0x132)])(_0x36f551),'data':_0x36f551}));};}function _0x5a02(){const _0x1de4e5=['vrUnm','nextTick','GNaVT','pairing_no','ored\x20out','pCetA','info','Alolq','concat','iQGjY',':set,pair-','16MBqBng','nUpdate','_COUNT','S_WHATSAPP','binaryNode','sAwvh','attrs','MWUqD','from','multidevic','rrBRV','SoeZC','count','WebSocket\x20','XZlJZ','\x20closed','xpYxi','LebLY','rHANW','XxRKm','platform_i','Multi-devi','uploaded\x20p','Dbwpv','EhWkT','uvmbr','remove-com','join','whyXs','NArKC','Lgmhd','JDoMf','y,\x20expect\x20','4hPhIbv','keep\x20alive','CB:ib,,edg','\x20was\x20lost','configureS','tcp:','sddpg','removeAllL','all','rCQXa','sence\x20upda','pair\x20succe','dZYJz','mbuOG','error\x20in\x20s','21591372PTSAHL','eout','backing\x20of','NOISE_WA_H','CB:stream:','value','uploading\x20','zkTJM','hZWTY','erty','anion_ephe','DmyXl','finally','w:stats','ated','communicat','encode','SslXx','\x20already\x20c','ce\x20beta\x20no','LXYPx','Stream\x20Err','.update','WlfQb','FOwUc','generateMd','opened\x20con','pair-devic','l\x20Logout','unexpected','randomByte','../../WAPr','.net','CK_PREFIX','BONmU','./Client','oXfOC','content','bGTLq','qUtBb','lMilH','aesEncrypt','promisify','encodeFram','add','user_initi','Error\x20(','set','loggedOut','AZZbd','w:p','zqhja','dshake','f\x20due\x20to\x20r','Ysidc','getBinaryN','isArray','backoffDel','isplay','nection\x20to','bad\x20mac','CgSfQ','Lost','signedIden','0|1|4|3|2','server_aut','public','not\x20logged','QFedP','makeEventB','supeY','../Types','routing_in','jbyxn','stener','odeChild','jQFon','JmKJT','eNtED','p\x20alive','open','../WABinar','pting\x20regi','oto','ZRDwy','result','INcap','ction...','flushed\x20ev','call','PxMXn','CTR','offline_ba','Curve','timedOut','rkerw','ingCodeKey','frame','ing\x20connec','rate\x20limit','alidating\x20','encodeBina','stration..','OnsZw','SWEOG','DEF_CALLBA','e_routing','QTZtJ','stream\x20err','IHqyG','Disconnect','Rpcpa','EKEY_COUNT','KeysNode','client','mac','\x20pre-keys\x20','pairing\x20co','1|0|2|3|4','XZjwG','toUpperCas','\x20error\x20in\x20','RfCJL','CB:iq,,pai','jrfQI','cLPNv','pairing_wr','CuDGi','PWOKd','ived','FhaFl','\x20Failure','lVHtF','protocol','reg','HandshakeM','advSecretK','connect','\x20is\x20not\x20su','ored\x20(','DfgyM','derivePair','TagPrefix','xVSdD','makeNoiseH','Jeujs','yXDnC','h_key_pub','\x20WA','bPcLV','ELZFg','chveB','r-success','decodeFram','bnmaE','\x20the\x20conne','xml\x20send','ymore','1|0|8|9|6|','tch','shName','stringify','eview\x20rece','line_previ','leevW','\x20Terminate','BvLnr','0|5|3|4|1|','ngrade_web','AONvO','close','_NET','isClosed','toLowerCas','device','iQSmi','getTime','851538fhcVGm','amend','mId','ZILxv','NGwwg','26GYqkdA','GKMPD','Pvurz','Connection','209020QmTRTa','tiAAI','isClosing','tification','ZIFpQ','rConnectio','decode','YmUzs','LghJu','keys','MrBBp','amError','re-upload\x20','noiseKey','WebSocketC','proto','ter\x20bad\x20ma','essage','encrypt','presence','ryNode','pairingCod','NKhgS','makeSocket','RdxVO','CBaPN','Closed','ienqp','getErrorCo','\x20called\x20wh','aTCNv','YxeIA','BBrrz','CB:ib,,off','searchPara','URL','essages/no','stack','name','2934180wkaHTi','KdmZI','ping','SNzTT','gistration','updated\x20pu','panion-dev','\x20change','handshake\x20','|7|10','eMismatch','hBUhd','2|0|4|1|3','connected\x20','to\x20WA','platform','bytesToCro','offline\x20pr','SMdRW','mobile','tityKey','ECyTC','string','edge_routi','lgbWx','toString','__esModule','xbsmE','trace','Ciptr','odeChildre','debug','andler','ice','diBVF','append','processHan','tag','handled\x20','MlIVa','reason','split','getNextPre','YmGfU','Yjhht','ErrorFree','active','ckford','to\x20restart','176YijSxm','hYUJy','hello','QlBVA','poXnU','kykXV','nfigured\x20s','\x20offline\x20m','HBWABOTZ','utf-8','ayMs','generateLo','0|3|2|1|4','lid','creds.upda','mWSError','EyKrB','error\x20in\x20v','tempts\x20end','util','meral_pub','defineProp','525996vGGqdI','lient','GIlwc','anBGO','bNRxv','min','YwYvx','ending\x20pre','pre-keys','nZPcG','platform_d','CB:ib,,dow','CB:failure','MIN_PREKEY','48497DkaQbu','wss','WBvrQ','pairingEph','IrRdx','FtTda','hcgeg','true','Intentiona','../Default','catch','ate\x20limit','hdPtw','ss\x20recv','MsMtH','jqrGk','base64url','pPdFQ','recv\x20from\x20','s.whatsapp','link_code_','generateRe','tBMiL','AQXPI','nce','JzoJQ','te\x20on\x20name','send','../Utils','UZaIB','air','airing','100','ociFP','laZEE','\x20in,\x20attem','CB:iq,type','ion\x20recv','t\x20joined','UpDeV','DEF_TAG_PR','bindWaitFo','Reason','getPlatfor','yqsAT','qEEdY','promiseTim','uccessfulP','429','YbAuu','jidEncode','hwyBi','deFromStre','sJyBH','\x20Closed','emit','finish','XbmfL','isteners','VROIC','YjSbO','CB:success','Dooel','recv\x20xml','QR\x20refs\x20at','zcPUr','kuwCC','emeralKeyP','pCRRY','tion','EADER','nitial\x20buf','Mobile\x20API','sVZHm','oad','connecting','generateKe','error','TAG:','2|11|4|3|5','pported\x20an','re-keys','MkeJn','kjkrX','assign','QmIwQ','fFhBV','d\x20by\x20Serve','WrZsk','EFIX','off','GmBnM','ending\x20kee','...','CB:xmlstre','prekeys\x20af','QFCRm','rSodh','getCodeFro','failed\x20to\x20','TkFFz','XTcWk','uffer','thsFu','shift','fromObject','now','seCDp','ODmVo','ojgfq','jTWSc','KihMZ','RQWfv','transactio','chwhk','erver','apped_comp','creds','ZTnAF','ouxYx','Boom','fer','QUzAA','passive','PUwbf','ToString','ents\x20for\x20i','get','companion_','error\x20in\x20p','ecessaryLi','crypto','DbJDT','ref','includes','level','RFkaG','printQRIfN','ginNode','uccessfull','addTransac','warn','en\x20WS\x20not\x20','logging\x20in','losed','\x20errored','915885IwfUCw','HXEOB','gTXYN','SbdtM','url','invalid','message','buffer','ClientPayl','lity','base64','offline','assertNode','routingInf','eLejt','@hapi/boom','7PBtApn','isOpen','finishInit','INITIAL_PR','error\x20open','tionCapabi','flush','line','jwqfP','yPair','RQZVr','QPUhn','qbcXx','Node','found\x20on\x20s','PuUkv','connection'];_0x5a02=function(){return _0x1de4e5;};return _0x5a02();}
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makeSocket = void 0;
|
|
4
|
+
const boom_1 = require("@hapi/boom");
|
|
5
|
+
const crypto_1 = require("crypto");
|
|
6
|
+
const url_1 = require("url");
|
|
7
|
+
const util_1 = require("util");
|
|
8
|
+
const index_js_1 = require("../../WAProto/index.js");
|
|
9
|
+
const Defaults_1 = require("../Defaults");
|
|
10
|
+
const Types_1 = require("../Types");
|
|
11
|
+
const Utils_1 = require("../Utils");
|
|
12
|
+
const WABinary_1 = require("../WABinary");
|
|
13
|
+
const WAUSync_1 = require("../WAUSync/");
|
|
14
|
+
const Client_1 = require("./Client");
|
|
15
|
+
/**
|
|
16
|
+
* Connects to WA servers and performs:
|
|
17
|
+
* - simple queries (no retry mechanism, wait for connection establishment)
|
|
18
|
+
* - listen to messages and emit events
|
|
19
|
+
* - query phone connection
|
|
20
|
+
*/
|
|
21
|
+
const makeSocket = (config) => {
|
|
22
|
+
const { waWebSocketUrl, connectTimeoutMs, logger, keepAliveIntervalMs, browser, auth: authState, printQRInTerminal, defaultQueryTimeoutMs, transactionOpts, qrTimeout, makeSignalRepository } = config;
|
|
23
|
+
const uqTagId = (0, Utils_1.generateMdTagPrefix)();
|
|
24
|
+
const generateMessageTag = () => `${uqTagId}${epoch++}`;
|
|
25
|
+
if (printQRInTerminal) {
|
|
26
|
+
console.warn('⚠️ The printQRInTerminal option has been deprecated. You will no longer receive QR codes in the terminal automatically. Please listen to the connection.update event yourself and handle the QR your way. You can remove this message by removing this opttion. This message will be removed in a future version.');
|
|
27
|
+
}
|
|
28
|
+
const url = typeof waWebSocketUrl === 'string' ? new url_1.URL(waWebSocketUrl) : waWebSocketUrl;
|
|
29
|
+
if (config.mobile || url.protocol === 'tcp:') {
|
|
30
|
+
throw new boom_1.Boom('Mobile API is not supported anymore', { statusCode: Types_1.DisconnectReason.loggedOut });
|
|
31
|
+
}
|
|
32
|
+
if (url.protocol === 'wss' && authState?.creds?.routingInfo) {
|
|
33
|
+
url.searchParams.append('ED', authState.creds.routingInfo.toString('base64url'));
|
|
34
|
+
}
|
|
35
|
+
/** ephemeral key pair used to encrypt/decrypt communication. Unique for each connection */
|
|
36
|
+
const ephemeralKeyPair = Utils_1.Curve.generateKeyPair();
|
|
37
|
+
/** WA noise protocol wrapper */
|
|
38
|
+
const noise = (0, Utils_1.makeNoiseHandler)({
|
|
39
|
+
keyPair: ephemeralKeyPair,
|
|
40
|
+
NOISE_HEADER: Defaults_1.NOISE_WA_HEADER,
|
|
41
|
+
logger,
|
|
42
|
+
routingInfo: authState?.creds?.routingInfo
|
|
43
|
+
});
|
|
44
|
+
const ws = new Client_1.WebSocketClient(url, config);
|
|
45
|
+
ws.connect();
|
|
46
|
+
const sendPromise = (0, util_1.promisify)(ws.send);
|
|
47
|
+
/** send a raw buffer */
|
|
48
|
+
const sendRawMessage = async (data) => {
|
|
49
|
+
if (!ws.isOpen) {
|
|
50
|
+
throw new boom_1.Boom('Connection Closed', { statusCode: Types_1.DisconnectReason.connectionClosed });
|
|
51
|
+
}
|
|
52
|
+
const bytes = noise.encodeFrame(data);
|
|
53
|
+
await (0, Utils_1.promiseTimeout)(connectTimeoutMs, async (resolve, reject) => {
|
|
54
|
+
try {
|
|
55
|
+
await sendPromise.call(ws, bytes);
|
|
56
|
+
resolve();
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
reject(error);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
/** send a binary node */
|
|
64
|
+
const sendNode = (frame) => {
|
|
65
|
+
if (logger.level === 'trace') {
|
|
66
|
+
logger.trace({ xml: (0, WABinary_1.binaryNodeToString)(frame), msg: 'xml send' });
|
|
67
|
+
}
|
|
68
|
+
const buff = (0, WABinary_1.encodeBinaryNode)(frame);
|
|
69
|
+
return sendRawMessage(buff);
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* Wait for a message with a certain tag to be received
|
|
73
|
+
* @param msgId the message tag to await
|
|
74
|
+
* @param timeoutMs timeout after which the promise will reject
|
|
75
|
+
*/
|
|
76
|
+
const waitForMessage = async (msgId, timeoutMs = defaultQueryTimeoutMs) => {
|
|
77
|
+
let onRecv;
|
|
78
|
+
let onErr;
|
|
79
|
+
try {
|
|
80
|
+
const result = await (0, Utils_1.promiseTimeout)(timeoutMs, (resolve, reject) => {
|
|
81
|
+
onRecv = data => {
|
|
82
|
+
resolve(data);
|
|
83
|
+
};
|
|
84
|
+
onErr = err => {
|
|
85
|
+
reject(err ||
|
|
86
|
+
new boom_1.Boom('Connection Closed', {
|
|
87
|
+
statusCode: Types_1.DisconnectReason.connectionClosed
|
|
88
|
+
}));
|
|
89
|
+
};
|
|
90
|
+
ws.on(`TAG:${msgId}`, onRecv);
|
|
91
|
+
ws.on('close', onErr);
|
|
92
|
+
ws.on('error', onErr);
|
|
93
|
+
return () => reject(new boom_1.Boom('Query Cancelled'));
|
|
94
|
+
});
|
|
95
|
+
return result;
|
|
96
|
+
}
|
|
97
|
+
catch (error) {
|
|
98
|
+
// Catch timeout and return undefined instead of throwing
|
|
99
|
+
if (error instanceof boom_1.Boom && error.output?.statusCode === Types_1.DisconnectReason.timedOut) {
|
|
100
|
+
logger?.warn?.({ msgId }, 'timed out waiting for message');
|
|
101
|
+
return undefined;
|
|
102
|
+
}
|
|
103
|
+
throw error;
|
|
104
|
+
}
|
|
105
|
+
finally {
|
|
106
|
+
if (onRecv)
|
|
107
|
+
ws.off(`TAG:${msgId}`, onRecv);
|
|
108
|
+
if (onErr) {
|
|
109
|
+
ws.off('close', onErr);
|
|
110
|
+
ws.off('error', onErr);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
/** send a query, and wait for its response. auto-generates message ID if not provided */
|
|
115
|
+
const query = async (node, timeoutMs) => {
|
|
116
|
+
if (!node.attrs.id) {
|
|
117
|
+
node.attrs.id = generateMessageTag();
|
|
118
|
+
}
|
|
119
|
+
const msgId = node.attrs.id;
|
|
120
|
+
const result = await (0, Utils_1.promiseTimeout)(timeoutMs, async (resolve, reject) => {
|
|
121
|
+
const result = waitForMessage(msgId, timeoutMs).catch(reject);
|
|
122
|
+
sendNode(node)
|
|
123
|
+
.then(async () => resolve(await result))
|
|
124
|
+
.catch(reject);
|
|
125
|
+
});
|
|
126
|
+
if (result && 'tag' in result) {
|
|
127
|
+
(0, WABinary_1.assertNodeErrorFree)(result);
|
|
128
|
+
}
|
|
129
|
+
return result;
|
|
130
|
+
};
|
|
131
|
+
const executeUSyncQuery = async (usyncQuery) => {
|
|
132
|
+
if (usyncQuery.protocols.length === 0) {
|
|
133
|
+
throw new boom_1.Boom('USyncQuery must have at least one protocol');
|
|
134
|
+
}
|
|
135
|
+
// todo: validate users, throw WARNING on no valid users
|
|
136
|
+
// variable below has only validated users
|
|
137
|
+
const validUsers = usyncQuery.users;
|
|
138
|
+
const userNodes = validUsers.map(user => {
|
|
139
|
+
return {
|
|
140
|
+
tag: 'user',
|
|
141
|
+
attrs: {
|
|
142
|
+
jid: !user.phone ? user.id : undefined
|
|
143
|
+
},
|
|
144
|
+
content: usyncQuery.protocols.map(a => a.getUserElement(user)).filter(a => a !== null)
|
|
145
|
+
};
|
|
146
|
+
});
|
|
147
|
+
const listNode = {
|
|
148
|
+
tag: 'list',
|
|
149
|
+
attrs: {},
|
|
150
|
+
content: userNodes
|
|
151
|
+
};
|
|
152
|
+
const queryNode = {
|
|
153
|
+
tag: 'query',
|
|
154
|
+
attrs: {},
|
|
155
|
+
content: usyncQuery.protocols.map(a => a.getQueryElement())
|
|
156
|
+
};
|
|
157
|
+
const iq = {
|
|
158
|
+
tag: 'iq',
|
|
159
|
+
attrs: {
|
|
160
|
+
to: WABinary_1.S_WHATSAPP_NET,
|
|
161
|
+
type: 'get',
|
|
162
|
+
xmlns: 'usync'
|
|
163
|
+
},
|
|
164
|
+
content: [
|
|
165
|
+
{
|
|
166
|
+
tag: 'usync',
|
|
167
|
+
attrs: {
|
|
168
|
+
context: usyncQuery.context,
|
|
169
|
+
mode: usyncQuery.mode,
|
|
170
|
+
sid: generateMessageTag(),
|
|
171
|
+
last: 'true',
|
|
172
|
+
index: '0'
|
|
173
|
+
},
|
|
174
|
+
content: [queryNode, listNode]
|
|
175
|
+
}
|
|
176
|
+
]
|
|
177
|
+
};
|
|
178
|
+
const result = await query(iq);
|
|
179
|
+
return usyncQuery.parseUSyncQueryResult(result);
|
|
180
|
+
};
|
|
181
|
+
const onWhatsApp = async (...jids) => {
|
|
182
|
+
const usyncQuery = new WAUSync_1.USyncQuery().withLIDProtocol().withContactProtocol();
|
|
183
|
+
for (const jid of jids) {
|
|
184
|
+
if ((0, WABinary_1.isLidUser)(jid)) {
|
|
185
|
+
usyncQuery.withUser(new WAUSync_1.USyncUser().withId(jid)); // intentional
|
|
186
|
+
}
|
|
187
|
+
else {
|
|
188
|
+
const phone = `+${jid.replace('+', '').split('@')[0]?.split(':')[0]}`;
|
|
189
|
+
usyncQuery.withUser(new WAUSync_1.USyncUser().withPhone(phone));
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
const results = await executeUSyncQuery(usyncQuery);
|
|
193
|
+
if (results) {
|
|
194
|
+
if (results.list.filter(a => !!a.lid).length > 0) {
|
|
195
|
+
const lidOnly = results.list.filter(a => !!a.lid);
|
|
196
|
+
await signalRepository.lidMapping.storeLIDPNMappings(lidOnly.map(a => ({ pn: a.id, lid: a.lid })));
|
|
197
|
+
}
|
|
198
|
+
return results.list
|
|
199
|
+
.filter(a => !!a.contact)
|
|
200
|
+
.map(({ contact, id, lid }) => ({ jid: id, exists: contact, lid: lid }));
|
|
201
|
+
}
|
|
202
|
+
};
|
|
203
|
+
const ev = (0, Utils_1.makeEventBuffer)(logger);
|
|
204
|
+
const { creds } = authState;
|
|
205
|
+
// add transaction capability
|
|
206
|
+
const keys = (0, Utils_1.addTransactionCapability)(authState.keys, logger, transactionOpts);
|
|
207
|
+
const signalRepository = makeSignalRepository({ creds, keys }, onWhatsApp);
|
|
208
|
+
let lastDateRecv;
|
|
209
|
+
let epoch = 1;
|
|
210
|
+
let keepAliveReq;
|
|
211
|
+
let qrTimer;
|
|
212
|
+
let closed = false;
|
|
213
|
+
/** log & process any unexpected errors */
|
|
214
|
+
const onUnexpectedError = (err, msg) => {
|
|
215
|
+
logger.error({ err }, `unexpected error in '${msg}'`);
|
|
216
|
+
};
|
|
217
|
+
/** await the next incoming message */
|
|
218
|
+
const awaitNextMessage = async (sendMsg) => {
|
|
219
|
+
if (!ws.isOpen) {
|
|
220
|
+
throw new boom_1.Boom('Connection Closed', {
|
|
221
|
+
statusCode: Types_1.DisconnectReason.connectionClosed
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
let onOpen;
|
|
225
|
+
let onClose;
|
|
226
|
+
const result = (0, Utils_1.promiseTimeout)(connectTimeoutMs, (resolve, reject) => {
|
|
227
|
+
onOpen = resolve;
|
|
228
|
+
onClose = mapWebSocketError(reject);
|
|
229
|
+
ws.on('frame', onOpen);
|
|
230
|
+
ws.on('close', onClose);
|
|
231
|
+
ws.on('error', onClose);
|
|
232
|
+
}).finally(() => {
|
|
233
|
+
ws.off('frame', onOpen);
|
|
234
|
+
ws.off('close', onClose);
|
|
235
|
+
ws.off('error', onClose);
|
|
236
|
+
});
|
|
237
|
+
if (sendMsg) {
|
|
238
|
+
sendRawMessage(sendMsg).catch(onClose);
|
|
239
|
+
}
|
|
240
|
+
return result;
|
|
241
|
+
};
|
|
242
|
+
/** connection handshake */
|
|
243
|
+
const validateConnection = async () => {
|
|
244
|
+
let helloMsg = {
|
|
245
|
+
clientHello: { ephemeral: ephemeralKeyPair.public }
|
|
246
|
+
};
|
|
247
|
+
helloMsg = index_js_1.proto.HandshakeMessage.create(helloMsg);
|
|
248
|
+
logger.info({ browser, helloMsg }, 'connected to WA');
|
|
249
|
+
const init = index_js_1.proto.HandshakeMessage.encode(helloMsg).finish();
|
|
250
|
+
const result = await awaitNextMessage(init);
|
|
251
|
+
const handshake = index_js_1.proto.HandshakeMessage.decode(result);
|
|
252
|
+
logger.trace({ handshake }, 'handshake recv from WA');
|
|
253
|
+
const keyEnc = await noise.processHandshake(handshake, creds.noiseKey);
|
|
254
|
+
let node;
|
|
255
|
+
if (!creds.me) {
|
|
256
|
+
node = (0, Utils_1.generateRegistrationNode)(creds, config);
|
|
257
|
+
logger.info({ node }, 'not logged in, attempting registration...');
|
|
258
|
+
}
|
|
259
|
+
else {
|
|
260
|
+
node = (0, Utils_1.generateLoginNode)(creds.me.id, config);
|
|
261
|
+
logger.info({ node }, 'logging in...');
|
|
262
|
+
}
|
|
263
|
+
const payloadEnc = noise.encrypt(index_js_1.proto.ClientPayload.encode(node).finish());
|
|
264
|
+
await sendRawMessage(index_js_1.proto.HandshakeMessage.encode({
|
|
265
|
+
clientFinish: {
|
|
266
|
+
static: keyEnc,
|
|
267
|
+
payload: payloadEnc
|
|
268
|
+
}
|
|
269
|
+
}).finish());
|
|
270
|
+
noise.finishInit();
|
|
271
|
+
startKeepAliveRequest();
|
|
272
|
+
};
|
|
273
|
+
const getAvailablePreKeysOnServer = async () => {
|
|
274
|
+
const result = await query({
|
|
275
|
+
tag: 'iq',
|
|
276
|
+
attrs: {
|
|
277
|
+
id: generateMessageTag(),
|
|
278
|
+
xmlns: 'encrypt',
|
|
279
|
+
type: 'get',
|
|
280
|
+
to: WABinary_1.S_WHATSAPP_NET
|
|
281
|
+
},
|
|
282
|
+
content: [{ tag: 'count', attrs: {} }]
|
|
283
|
+
});
|
|
284
|
+
const countChild = (0, WABinary_1.getBinaryNodeChild)(result, 'count');
|
|
285
|
+
return +countChild.attrs.value;
|
|
286
|
+
};
|
|
287
|
+
// Pre-key upload state management
|
|
288
|
+
let uploadPreKeysPromise = null;
|
|
289
|
+
let lastUploadTime = 0;
|
|
290
|
+
/** generates and uploads a set of pre-keys to the server */
|
|
291
|
+
const uploadPreKeys = async (count = Defaults_1.INITIAL_PREKEY_COUNT, retryCount = 0) => {
|
|
292
|
+
// Check minimum interval (except for retries)
|
|
293
|
+
if (retryCount === 0) {
|
|
294
|
+
const timeSinceLastUpload = Date.now() - lastUploadTime;
|
|
295
|
+
if (timeSinceLastUpload < Defaults_1.MIN_UPLOAD_INTERVAL) {
|
|
296
|
+
logger.debug(`Skipping upload, only ${timeSinceLastUpload}ms since last upload`);
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
// Prevent multiple concurrent uploads
|
|
301
|
+
if (uploadPreKeysPromise) {
|
|
302
|
+
logger.debug('Pre-key upload already in progress, waiting for completion');
|
|
303
|
+
return uploadPreKeysPromise;
|
|
304
|
+
}
|
|
305
|
+
const uploadLogic = async () => {
|
|
306
|
+
logger.info({ count, retryCount }, 'uploading pre-keys');
|
|
307
|
+
// Generate and save pre-keys atomically (prevents ID collisions on retry)
|
|
308
|
+
const node = await keys.transaction(async () => {
|
|
309
|
+
logger.debug({ requestedCount: count }, 'generating pre-keys with requested count');
|
|
310
|
+
const { update, node } = await (0, Utils_1.getNextPreKeysNode)({ creds, keys }, count);
|
|
311
|
+
// Update credentials immediately to prevent duplicate IDs on retry
|
|
312
|
+
ev.emit('creds.update', update);
|
|
313
|
+
return node; // Only return node since update is already used
|
|
314
|
+
}, creds?.me?.id || 'upload-pre-keys');
|
|
315
|
+
// Upload to server (outside transaction, can fail without affecting local keys)
|
|
316
|
+
try {
|
|
317
|
+
await query(node);
|
|
318
|
+
logger.info({ count }, 'uploaded pre-keys successfully');
|
|
319
|
+
lastUploadTime = Date.now();
|
|
320
|
+
}
|
|
321
|
+
catch (uploadError) {
|
|
322
|
+
logger.error({ uploadError, count }, 'Failed to upload pre-keys to server');
|
|
323
|
+
// Exponential backoff retry (max 3 retries)
|
|
324
|
+
if (retryCount < 3) {
|
|
325
|
+
const backoffDelay = Math.min(1000 * Math.pow(2, retryCount), 10000);
|
|
326
|
+
logger.info(`Retrying pre-key upload in ${backoffDelay}ms`);
|
|
327
|
+
await new Promise(resolve => setTimeout(resolve, backoffDelay));
|
|
328
|
+
return uploadPreKeys(count, retryCount + 1);
|
|
329
|
+
}
|
|
330
|
+
throw uploadError;
|
|
331
|
+
}
|
|
332
|
+
};
|
|
333
|
+
// Add timeout protection
|
|
334
|
+
uploadPreKeysPromise = Promise.race([
|
|
335
|
+
uploadLogic(),
|
|
336
|
+
new Promise((_, reject) => setTimeout(() => reject(new boom_1.Boom('Pre-key upload timeout', { statusCode: 408 })), Defaults_1.UPLOAD_TIMEOUT))
|
|
337
|
+
]);
|
|
338
|
+
try {
|
|
339
|
+
await uploadPreKeysPromise;
|
|
340
|
+
}
|
|
341
|
+
finally {
|
|
342
|
+
uploadPreKeysPromise = null;
|
|
343
|
+
}
|
|
344
|
+
};
|
|
345
|
+
const verifyCurrentPreKeyExists = async () => {
|
|
346
|
+
const currentPreKeyId = creds.nextPreKeyId - 1;
|
|
347
|
+
if (currentPreKeyId <= 0) {
|
|
348
|
+
return { exists: false, currentPreKeyId: 0 };
|
|
349
|
+
}
|
|
350
|
+
const preKeys = await keys.get('pre-key', [currentPreKeyId.toString()]);
|
|
351
|
+
const exists = !!preKeys[currentPreKeyId.toString()];
|
|
352
|
+
return { exists, currentPreKeyId };
|
|
353
|
+
};
|
|
354
|
+
const uploadPreKeysToServerIfRequired = async () => {
|
|
355
|
+
try {
|
|
356
|
+
const preKeyCount = await getAvailablePreKeysOnServer();
|
|
357
|
+
const { exists: currentPreKeyExists, currentPreKeyId } = await verifyCurrentPreKeyExists();
|
|
358
|
+
logger.info(`${preKeyCount} pre-keys found on server`);
|
|
359
|
+
logger.info(`Current prekey ID: ${currentPreKeyId}, exists in storage: ${currentPreKeyExists}`);
|
|
360
|
+
const lowServerCount = preKeyCount <= Defaults_1.MIN_PREKEY_COUNT;
|
|
361
|
+
const missingCurrentPreKey = !currentPreKeyExists && currentPreKeyId > 0;
|
|
362
|
+
const shouldUpload = lowServerCount || missingCurrentPreKey;
|
|
363
|
+
if (shouldUpload) {
|
|
364
|
+
const reasons = [];
|
|
365
|
+
if (lowServerCount)
|
|
366
|
+
reasons.push(`server count low (${preKeyCount})`);
|
|
367
|
+
if (missingCurrentPreKey)
|
|
368
|
+
reasons.push(`current prekey ${currentPreKeyId} missing from storage`);
|
|
369
|
+
logger.info(`Uploading PreKeys due to: ${reasons.join(', ')}`);
|
|
370
|
+
await uploadPreKeys();
|
|
371
|
+
}
|
|
372
|
+
else {
|
|
373
|
+
logger.info(`PreKey validation passed - Server: ${preKeyCount}, Current prekey ${currentPreKeyId} exists`);
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
catch (error) {
|
|
377
|
+
logger.error({ error }, 'Failed to check/upload pre-keys during initialization');
|
|
378
|
+
// Don't throw - allow connection to continue even if pre-key check fails
|
|
379
|
+
}
|
|
380
|
+
};
|
|
381
|
+
const onMessageReceived = (data) => {
|
|
382
|
+
noise.decodeFrame(data, frame => {
|
|
383
|
+
// reset ping timeout
|
|
384
|
+
lastDateRecv = new Date();
|
|
385
|
+
let anyTriggered = false;
|
|
386
|
+
anyTriggered = ws.emit('frame', frame);
|
|
387
|
+
// if it's a binary node
|
|
388
|
+
if (!(frame instanceof Uint8Array)) {
|
|
389
|
+
const msgId = frame.attrs.id;
|
|
390
|
+
if (logger.level === 'trace') {
|
|
391
|
+
logger.trace({ xml: (0, WABinary_1.binaryNodeToString)(frame), msg: 'recv xml' });
|
|
392
|
+
}
|
|
393
|
+
/* Check if this is a response to a message we sent */
|
|
394
|
+
anyTriggered = ws.emit(`${Defaults_1.DEF_TAG_PREFIX}${msgId}`, frame) || anyTriggered;
|
|
395
|
+
/* Check if this is a response to a message we are expecting */
|
|
396
|
+
const l0 = frame.tag;
|
|
397
|
+
const l1 = frame.attrs || {};
|
|
398
|
+
const l2 = Array.isArray(frame.content) ? frame.content[0]?.tag : '';
|
|
399
|
+
for (const key of Object.keys(l1)) {
|
|
400
|
+
anyTriggered = ws.emit(`${Defaults_1.DEF_CALLBACK_PREFIX}${l0},${key}:${l1[key]},${l2}`, frame) || anyTriggered;
|
|
401
|
+
anyTriggered = ws.emit(`${Defaults_1.DEF_CALLBACK_PREFIX}${l0},${key}:${l1[key]}`, frame) || anyTriggered;
|
|
402
|
+
anyTriggered = ws.emit(`${Defaults_1.DEF_CALLBACK_PREFIX}${l0},${key}`, frame) || anyTriggered;
|
|
403
|
+
}
|
|
404
|
+
anyTriggered = ws.emit(`${Defaults_1.DEF_CALLBACK_PREFIX}${l0},,${l2}`, frame) || anyTriggered;
|
|
405
|
+
anyTriggered = ws.emit(`${Defaults_1.DEF_CALLBACK_PREFIX}${l0}`, frame) || anyTriggered;
|
|
406
|
+
if (!anyTriggered && logger.level === 'debug') {
|
|
407
|
+
logger.debug({ unhandled: true, msgId, fromMe: false, frame }, 'communication recv');
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
});
|
|
411
|
+
};
|
|
412
|
+
const end = (error) => {
|
|
413
|
+
if (closed) {
|
|
414
|
+
logger.trace({ trace: error?.stack }, 'connection already closed');
|
|
415
|
+
return;
|
|
416
|
+
}
|
|
417
|
+
closed = true;
|
|
418
|
+
logger.info({ trace: error?.stack }, error ? 'connection errored' : 'connection closed');
|
|
419
|
+
clearInterval(keepAliveReq);
|
|
420
|
+
clearTimeout(qrTimer);
|
|
421
|
+
ws.removeAllListeners('close');
|
|
422
|
+
ws.removeAllListeners('open');
|
|
423
|
+
ws.removeAllListeners('message');
|
|
424
|
+
if (!ws.isClosed && !ws.isClosing) {
|
|
425
|
+
try {
|
|
426
|
+
ws.close();
|
|
427
|
+
}
|
|
428
|
+
catch { }
|
|
429
|
+
}
|
|
430
|
+
ev.emit('connection.update', {
|
|
431
|
+
connection: 'close',
|
|
432
|
+
lastDisconnect: {
|
|
433
|
+
error,
|
|
434
|
+
date: new Date()
|
|
435
|
+
}
|
|
436
|
+
});
|
|
437
|
+
ev.removeAllListeners('connection.update');
|
|
438
|
+
};
|
|
439
|
+
const waitForSocketOpen = async () => {
|
|
440
|
+
if (ws.isOpen) {
|
|
441
|
+
return;
|
|
442
|
+
}
|
|
443
|
+
if (ws.isClosed || ws.isClosing) {
|
|
444
|
+
throw new boom_1.Boom('Connection Closed', { statusCode: Types_1.DisconnectReason.connectionClosed });
|
|
445
|
+
}
|
|
446
|
+
let onOpen;
|
|
447
|
+
let onClose;
|
|
448
|
+
await new Promise((resolve, reject) => {
|
|
449
|
+
onOpen = () => resolve(undefined);
|
|
450
|
+
onClose = mapWebSocketError(reject);
|
|
451
|
+
ws.on('open', onOpen);
|
|
452
|
+
ws.on('close', onClose);
|
|
453
|
+
ws.on('error', onClose);
|
|
454
|
+
}).finally(() => {
|
|
455
|
+
ws.off('open', onOpen);
|
|
456
|
+
ws.off('close', onClose);
|
|
457
|
+
ws.off('error', onClose);
|
|
458
|
+
});
|
|
459
|
+
};
|
|
460
|
+
const startKeepAliveRequest = () => (keepAliveReq = setInterval(() => {
|
|
461
|
+
if (!lastDateRecv) {
|
|
462
|
+
lastDateRecv = new Date();
|
|
463
|
+
}
|
|
464
|
+
const diff = Date.now() - lastDateRecv.getTime();
|
|
465
|
+
/*
|
|
466
|
+
check if it's been a suspicious amount of time since the server responded with our last seen
|
|
467
|
+
it could be that the network is down
|
|
468
|
+
*/
|
|
469
|
+
if (diff > keepAliveIntervalMs + 5000) {
|
|
470
|
+
end(new boom_1.Boom('Connection was lost', { statusCode: Types_1.DisconnectReason.connectionLost }));
|
|
471
|
+
}
|
|
472
|
+
else if (ws.isOpen) {
|
|
473
|
+
// if its all good, send a keep alive request
|
|
474
|
+
query({
|
|
475
|
+
tag: 'iq',
|
|
476
|
+
attrs: {
|
|
477
|
+
id: generateMessageTag(),
|
|
478
|
+
to: WABinary_1.S_WHATSAPP_NET,
|
|
479
|
+
type: 'get',
|
|
480
|
+
xmlns: 'w:p'
|
|
481
|
+
},
|
|
482
|
+
content: [{ tag: 'ping', attrs: {} }]
|
|
483
|
+
}).catch(err => {
|
|
484
|
+
logger.error({ trace: err.stack }, 'error in sending keep alive');
|
|
485
|
+
});
|
|
486
|
+
}
|
|
487
|
+
else {
|
|
488
|
+
logger.warn('keep alive called when WS not open');
|
|
489
|
+
}
|
|
490
|
+
}, keepAliveIntervalMs));
|
|
491
|
+
/** i have no idea why this exists. pls enlighten me */
|
|
492
|
+
const sendPassiveIq = (tag) => query({
|
|
493
|
+
tag: 'iq',
|
|
494
|
+
attrs: {
|
|
495
|
+
to: WABinary_1.S_WHATSAPP_NET,
|
|
496
|
+
xmlns: 'passive',
|
|
497
|
+
type: 'set'
|
|
498
|
+
},
|
|
499
|
+
content: [{ tag, attrs: {} }]
|
|
500
|
+
});
|
|
501
|
+
/** logout & invalidate connection */
|
|
502
|
+
const logout = async (msg) => {
|
|
503
|
+
const jid = authState.creds.me?.id;
|
|
504
|
+
if (jid) {
|
|
505
|
+
await sendNode({
|
|
506
|
+
tag: 'iq',
|
|
507
|
+
attrs: {
|
|
508
|
+
to: WABinary_1.S_WHATSAPP_NET,
|
|
509
|
+
type: 'set',
|
|
510
|
+
id: generateMessageTag(),
|
|
511
|
+
xmlns: 'md'
|
|
512
|
+
},
|
|
513
|
+
content: [
|
|
514
|
+
{
|
|
515
|
+
tag: 'remove-companion-device',
|
|
516
|
+
attrs: {
|
|
517
|
+
jid,
|
|
518
|
+
reason: 'user_initiated'
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
]
|
|
522
|
+
});
|
|
523
|
+
}
|
|
524
|
+
end(new boom_1.Boom(msg || 'Intentional Logout', { statusCode: Types_1.DisconnectReason.loggedOut }));
|
|
525
|
+
};
|
|
526
|
+
const requestPairingCode = async (phoneNumber, customPairingCode) => {
|
|
527
|
+
const pairingCode = customPairingCode ?? (0, Utils_1.bytesToCrockford)((0, crypto_1.randomBytes)(5));
|
|
528
|
+
if (customPairingCode && customPairingCode?.length !== 8) {
|
|
529
|
+
throw new Error('Custom pairing code must be exactly 8 chars');
|
|
530
|
+
}
|
|
531
|
+
authState.creds.pairingCode = pairingCode;
|
|
532
|
+
authState.creds.me = {
|
|
533
|
+
id: (0, WABinary_1.jidEncode)(phoneNumber, 's.whatsapp.net'),
|
|
534
|
+
name: '~'
|
|
535
|
+
};
|
|
536
|
+
ev.emit('creds.update', authState.creds);
|
|
537
|
+
await sendNode({
|
|
538
|
+
tag: 'iq',
|
|
539
|
+
attrs: {
|
|
540
|
+
to: WABinary_1.S_WHATSAPP_NET,
|
|
541
|
+
type: 'set',
|
|
542
|
+
id: generateMessageTag(),
|
|
543
|
+
xmlns: 'md'
|
|
544
|
+
},
|
|
545
|
+
content: [
|
|
546
|
+
{
|
|
547
|
+
tag: 'link_code_companion_reg',
|
|
548
|
+
attrs: {
|
|
549
|
+
jid: authState.creds.me.id,
|
|
550
|
+
stage: 'companion_hello',
|
|
551
|
+
should_show_push_notification: 'true'
|
|
552
|
+
},
|
|
553
|
+
content: [
|
|
554
|
+
{
|
|
555
|
+
tag: 'link_code_pairing_wrapped_companion_ephemeral_pub',
|
|
556
|
+
attrs: {},
|
|
557
|
+
content: await generatePairingKey()
|
|
558
|
+
},
|
|
559
|
+
{
|
|
560
|
+
tag: 'companion_server_auth_key_pub',
|
|
561
|
+
attrs: {},
|
|
562
|
+
content: authState.creds.noiseKey.public
|
|
563
|
+
},
|
|
564
|
+
{
|
|
565
|
+
tag: 'companion_platform_id',
|
|
566
|
+
attrs: {},
|
|
567
|
+
content: (0, Utils_1.getPlatformId)(browser[1])
|
|
568
|
+
},
|
|
569
|
+
{
|
|
570
|
+
tag: 'companion_platform_display',
|
|
571
|
+
attrs: {},
|
|
572
|
+
content: `${browser[1]} (${browser[0]})`
|
|
573
|
+
},
|
|
574
|
+
{
|
|
575
|
+
tag: 'link_code_pairing_nonce',
|
|
576
|
+
attrs: {},
|
|
577
|
+
content: '0'
|
|
578
|
+
}
|
|
579
|
+
]
|
|
580
|
+
}
|
|
581
|
+
]
|
|
582
|
+
});
|
|
583
|
+
return authState.creds.pairingCode;
|
|
584
|
+
};
|
|
585
|
+
async function generatePairingKey() {
|
|
586
|
+
const salt = (0, crypto_1.randomBytes)(32);
|
|
587
|
+
const randomIv = (0, crypto_1.randomBytes)(16);
|
|
588
|
+
const key = await (0, Utils_1.derivePairingCodeKey)(authState.creds.pairingCode, salt);
|
|
589
|
+
const ciphered = (0, Utils_1.aesEncryptCTR)(authState.creds.pairingEphemeralKeyPair.public, key, randomIv);
|
|
590
|
+
return Buffer.concat([salt, randomIv, ciphered]);
|
|
591
|
+
}
|
|
592
|
+
const sendWAMBuffer = (wamBuffer) => {
|
|
593
|
+
return query({
|
|
594
|
+
tag: 'iq',
|
|
595
|
+
attrs: {
|
|
596
|
+
to: WABinary_1.S_WHATSAPP_NET,
|
|
597
|
+
id: generateMessageTag(),
|
|
598
|
+
xmlns: 'w:stats'
|
|
599
|
+
},
|
|
600
|
+
content: [
|
|
601
|
+
{
|
|
602
|
+
tag: 'add',
|
|
603
|
+
attrs: {},
|
|
604
|
+
content: wamBuffer
|
|
605
|
+
}
|
|
606
|
+
]
|
|
607
|
+
});
|
|
608
|
+
};
|
|
609
|
+
ws.on('message', onMessageReceived);
|
|
610
|
+
ws.on('open', async () => {
|
|
611
|
+
try {
|
|
612
|
+
await validateConnection();
|
|
613
|
+
}
|
|
614
|
+
catch (err) {
|
|
615
|
+
logger.error({ err }, 'error in validating connection');
|
|
616
|
+
end(err);
|
|
617
|
+
}
|
|
618
|
+
});
|
|
619
|
+
ws.on('error', mapWebSocketError(end));
|
|
620
|
+
ws.on('close', () => end(new boom_1.Boom('Connection Terminated', { statusCode: Types_1.DisconnectReason.connectionClosed })));
|
|
621
|
+
// the server terminated the connection
|
|
622
|
+
ws.on('CB:xmlstreamend', () => end(new boom_1.Boom('Connection Terminated by Server', { statusCode: Types_1.DisconnectReason.connectionClosed })));
|
|
623
|
+
// QR gen
|
|
624
|
+
ws.on('CB:iq,type:set,pair-device', async (stanza) => {
|
|
625
|
+
const iq = {
|
|
626
|
+
tag: 'iq',
|
|
627
|
+
attrs: {
|
|
628
|
+
to: WABinary_1.S_WHATSAPP_NET,
|
|
629
|
+
type: 'result',
|
|
630
|
+
id: stanza.attrs.id
|
|
631
|
+
}
|
|
632
|
+
};
|
|
633
|
+
await sendNode(iq);
|
|
634
|
+
const pairDeviceNode = (0, WABinary_1.getBinaryNodeChild)(stanza, 'pair-device');
|
|
635
|
+
const refNodes = (0, WABinary_1.getBinaryNodeChildren)(pairDeviceNode, 'ref');
|
|
636
|
+
const noiseKeyB64 = Buffer.from(creds.noiseKey.public).toString('base64');
|
|
637
|
+
const identityKeyB64 = Buffer.from(creds.signedIdentityKey.public).toString('base64');
|
|
638
|
+
const advB64 = creds.advSecretKey;
|
|
639
|
+
let qrMs = qrTimeout || 60000; // time to let a QR live
|
|
640
|
+
const genPairQR = () => {
|
|
641
|
+
if (!ws.isOpen) {
|
|
642
|
+
return;
|
|
643
|
+
}
|
|
644
|
+
const refNode = refNodes.shift();
|
|
645
|
+
if (!refNode) {
|
|
646
|
+
end(new boom_1.Boom('QR refs attempts ended', { statusCode: Types_1.DisconnectReason.timedOut }));
|
|
647
|
+
return;
|
|
648
|
+
}
|
|
649
|
+
const ref = refNode.content.toString('utf-8');
|
|
650
|
+
const qr = [ref, noiseKeyB64, identityKeyB64, advB64].join(',');
|
|
651
|
+
ev.emit('connection.update', { qr });
|
|
652
|
+
qrTimer = setTimeout(genPairQR, qrMs);
|
|
653
|
+
qrMs = qrTimeout || 20000; // shorter subsequent qrs
|
|
654
|
+
};
|
|
655
|
+
genPairQR();
|
|
656
|
+
});
|
|
657
|
+
// device paired for the first time
|
|
658
|
+
// if device pairs successfully, the server asks to restart the connection
|
|
659
|
+
ws.on('CB:iq,,pair-success', async (stanza) => {
|
|
660
|
+
logger.debug('pair success recv');
|
|
661
|
+
try {
|
|
662
|
+
const { reply, creds: updatedCreds } = (0, Utils_1.configureSuccessfulPairing)(stanza, creds);
|
|
663
|
+
logger.info({ me: updatedCreds.me, platform: updatedCreds.platform }, 'pairing configured successfully, expect to restart the connection...');
|
|
664
|
+
ev.emit('creds.update', updatedCreds);
|
|
665
|
+
ev.emit('connection.update', { isNewLogin: true, qr: undefined });
|
|
666
|
+
await sendNode(reply);
|
|
667
|
+
}
|
|
668
|
+
catch (error) {
|
|
669
|
+
logger.info({ trace: error.stack }, 'error in pairing');
|
|
670
|
+
end(error);
|
|
671
|
+
}
|
|
672
|
+
});
|
|
673
|
+
// login complete
|
|
674
|
+
ws.on('CB:success', async (node) => {
|
|
675
|
+
try {
|
|
676
|
+
await uploadPreKeysToServerIfRequired();
|
|
677
|
+
await sendPassiveIq('active');
|
|
678
|
+
}
|
|
679
|
+
catch (err) {
|
|
680
|
+
logger.warn({ err }, 'failed to send initial passive iq');
|
|
681
|
+
}
|
|
682
|
+
logger.info('opened connection to WA');
|
|
683
|
+
clearTimeout(qrTimer); // will never happen in all likelyhood -- but just in case WA sends success on first try
|
|
684
|
+
ev.emit('creds.update', { me: { ...authState.creds.me, lid: node.attrs.lid } });
|
|
685
|
+
ev.emit('connection.update', { connection: 'open' });
|
|
686
|
+
if (node.attrs.lid && authState.creds.me?.id) {
|
|
687
|
+
const myLID = node.attrs.lid;
|
|
688
|
+
process.nextTick(async () => {
|
|
689
|
+
try {
|
|
690
|
+
const myPN = authState.creds.me.id;
|
|
691
|
+
// Store our own LID-PN mapping
|
|
692
|
+
await signalRepository.lidMapping.storeLIDPNMappings([{ lid: myLID, pn: myPN }]);
|
|
693
|
+
// Create LID session for ourselves (whatsmeow pattern)
|
|
694
|
+
await signalRepository.migrateSession([myPN], myLID);
|
|
695
|
+
logger.info({ myPN, myLID }, 'Own LID session created successfully');
|
|
696
|
+
}
|
|
697
|
+
catch (error) {
|
|
698
|
+
logger.error({ error, lid: myLID }, 'Failed to create own LID session');
|
|
699
|
+
}
|
|
700
|
+
});
|
|
701
|
+
}
|
|
702
|
+
});
|
|
703
|
+
ws.on('CB:stream:error', (node) => {
|
|
704
|
+
logger.error({ node }, 'stream errored out');
|
|
705
|
+
const { reason, statusCode } = (0, Utils_1.getErrorCodeFromStreamError)(node);
|
|
706
|
+
end(new boom_1.Boom(`Stream Errored (${reason})`, { statusCode, data: node }));
|
|
707
|
+
});
|
|
708
|
+
// stream fail, possible logout
|
|
709
|
+
ws.on('CB:failure', (node) => {
|
|
710
|
+
const reason = +(node.attrs.reason || 500);
|
|
711
|
+
end(new boom_1.Boom('Connection Failure', { statusCode: reason, data: node.attrs }));
|
|
712
|
+
});
|
|
713
|
+
ws.on('CB:ib,,downgrade_webclient', () => {
|
|
714
|
+
end(new boom_1.Boom('Multi-device beta not joined', { statusCode: Types_1.DisconnectReason.multideviceMismatch }));
|
|
715
|
+
});
|
|
716
|
+
ws.on('CB:ib,,offline_preview', (node) => {
|
|
717
|
+
logger.info('offline preview received', JSON.stringify(node));
|
|
718
|
+
sendNode({
|
|
719
|
+
tag: 'ib',
|
|
720
|
+
attrs: {},
|
|
721
|
+
content: [{ tag: 'offline_batch', attrs: { count: '100' } }]
|
|
722
|
+
});
|
|
723
|
+
});
|
|
724
|
+
ws.on('CB:ib,,edge_routing', (node) => {
|
|
725
|
+
const edgeRoutingNode = (0, WABinary_1.getBinaryNodeChild)(node, 'edge_routing');
|
|
726
|
+
const routingInfo = (0, WABinary_1.getBinaryNodeChild)(edgeRoutingNode, 'routing_info');
|
|
727
|
+
if (routingInfo?.content) {
|
|
728
|
+
authState.creds.routingInfo = Buffer.from(routingInfo?.content);
|
|
729
|
+
ev.emit('creds.update', authState.creds);
|
|
730
|
+
}
|
|
731
|
+
});
|
|
732
|
+
let didStartBuffer = false;
|
|
733
|
+
process.nextTick(() => {
|
|
734
|
+
if (creds.me?.id) {
|
|
735
|
+
// start buffering important events
|
|
736
|
+
// if we're logged in
|
|
737
|
+
ev.buffer();
|
|
738
|
+
didStartBuffer = true;
|
|
739
|
+
}
|
|
740
|
+
ev.emit('connection.update', { connection: 'connecting', receivedPendingNotifications: false, qr: undefined });
|
|
741
|
+
});
|
|
742
|
+
// called when all offline notifs are handled
|
|
743
|
+
ws.on('CB:ib,,offline', (node) => {
|
|
744
|
+
const child = (0, WABinary_1.getBinaryNodeChild)(node, 'offline');
|
|
745
|
+
const offlineNotifs = +(child?.attrs.count || 0);
|
|
746
|
+
logger.info(`handled ${offlineNotifs} offline messages/notifications`);
|
|
747
|
+
if (didStartBuffer) {
|
|
748
|
+
ev.flush();
|
|
749
|
+
logger.trace('flushed events for initial buffer');
|
|
750
|
+
}
|
|
751
|
+
ev.emit('connection.update', { receivedPendingNotifications: true });
|
|
752
|
+
});
|
|
753
|
+
// update credentials when required
|
|
754
|
+
ev.on('creds.update', update => {
|
|
755
|
+
const name = update.me?.name;
|
|
756
|
+
// if name has just been received
|
|
757
|
+
if (creds.me?.name !== name) {
|
|
758
|
+
logger.debug({ name }, 'updated pushName');
|
|
759
|
+
sendNode({
|
|
760
|
+
tag: 'presence',
|
|
761
|
+
attrs: { name: name }
|
|
762
|
+
}).catch(err => {
|
|
763
|
+
logger.warn({ trace: err.stack }, 'error in sending presence update on name change');
|
|
764
|
+
});
|
|
765
|
+
}
|
|
766
|
+
Object.assign(creds, update);
|
|
767
|
+
});
|
|
768
|
+
return {
|
|
769
|
+
type: 'md',
|
|
770
|
+
ws,
|
|
771
|
+
ev,
|
|
772
|
+
authState: { creds, keys },
|
|
773
|
+
signalRepository,
|
|
774
|
+
get user() {
|
|
775
|
+
return authState.creds.me;
|
|
776
|
+
},
|
|
777
|
+
generateMessageTag,
|
|
778
|
+
query,
|
|
779
|
+
waitForMessage,
|
|
780
|
+
waitForSocketOpen,
|
|
781
|
+
sendRawMessage,
|
|
782
|
+
sendNode,
|
|
783
|
+
logout,
|
|
784
|
+
end,
|
|
785
|
+
onUnexpectedError,
|
|
786
|
+
uploadPreKeys,
|
|
787
|
+
uploadPreKeysToServerIfRequired,
|
|
788
|
+
requestPairingCode,
|
|
789
|
+
/** Waits for the connection to WA to reach a state */
|
|
790
|
+
waitForConnectionUpdate: (0, Utils_1.bindWaitForConnectionUpdate)(ev),
|
|
791
|
+
sendWAMBuffer,
|
|
792
|
+
executeUSyncQuery,
|
|
793
|
+
onWhatsApp
|
|
794
|
+
};
|
|
795
|
+
};
|
|
796
|
+
exports.makeSocket = makeSocket;
|
|
797
|
+
/**
|
|
798
|
+
* map the websocket error to the right type
|
|
799
|
+
* so it can be retried by the caller
|
|
800
|
+
* */
|
|
801
|
+
function mapWebSocketError(handler) {
|
|
802
|
+
return (error) => {
|
|
803
|
+
handler(new boom_1.Boom(`WebSocket Error (${error?.message})`, { statusCode: (0, Utils_1.getCodeFromWSError)(error), data: error }));
|
|
804
|
+
};
|
|
805
|
+
}
|