UNPKG

superchats

Version:

SuperChats is a premium library with unique features that control Whatsapp functions. With Superchats you can build service bots, multiservice chats or any system that uses whatsapp

1 lines 12.2 kB
'use strict';const a50_0xeee96b=a50_0x21d7;(function(_0x1685e9,_0x2c97c9){const _0x821ee5=a50_0x21d7,_0x213983=_0x1685e9();while(!![]){try{const _0x5281b0=-parseInt(_0x821ee5(0x1a1))/0x1+parseInt(_0x821ee5(0x1a0))/0x2*(-parseInt(_0x821ee5(0x1bc))/0x3)+parseInt(_0x821ee5(0x1d7))/0x4*(-parseInt(_0x821ee5(0x1b5))/0x5)+parseInt(_0x821ee5(0x1e8))/0x6*(parseInt(_0x821ee5(0x1eb))/0x7)+parseInt(_0x821ee5(0x1a9))/0x8+parseInt(_0x821ee5(0x1a8))/0x9+parseInt(_0x821ee5(0x1e6))/0xa*(parseInt(_0x821ee5(0x1df))/0xb);if(_0x5281b0===_0x2c97c9)break;else _0x213983['push'](_0x213983['shift']());}catch(_0x34c962){_0x213983['push'](_0x213983['shift']());}}}(a50_0x2b27,0xcc31c));var __createBinding=this&&this['__createBinding']||(Object[a50_0xeee96b(0x1f1)]?function(_0x3ea5d2,_0x202974,_0x27b4ba,_0x54eb9a){const _0x4965fd=a50_0xeee96b;if(_0x54eb9a===undefined)_0x54eb9a=_0x27b4ba;var _0x3fc9f3=Object[_0x4965fd(0x1de)](_0x202974,_0x27b4ba);(!_0x3fc9f3||(_0x4965fd(0x1ee)in _0x3fc9f3?!_0x202974[_0x4965fd(0x1a6)]:_0x3fc9f3['writable']||_0x3fc9f3[_0x4965fd(0x1c1)]))&&(_0x3fc9f3={'enumerable':!![],'get':function(){return _0x202974[_0x27b4ba];}}),Object[_0x4965fd(0x1a2)](_0x3ea5d2,_0x54eb9a,_0x3fc9f3);}:function(_0x3a3bee,_0x28f151,_0x17f766,_0x32e23b){if(_0x32e23b===undefined)_0x32e23b=_0x17f766;_0x3a3bee[_0x32e23b]=_0x28f151[_0x17f766];}),__setModuleDefault=this&&this[a50_0xeee96b(0x1ce)]||(Object['create']?function(_0x2bc3bc,_0x4cdf03){const _0x2fc47c=a50_0xeee96b;Object[_0x2fc47c(0x1a2)](_0x2bc3bc,_0x2fc47c(0x1ea),{'enumerable':!![],'value':_0x4cdf03});}:function(_0x39cdde,_0x3420a9){_0x39cdde['default']=_0x3420a9;}),__importStar=this&&this[a50_0xeee96b(0x1fa)]||function(_0x1e34dc){const _0x394a5e=a50_0xeee96b;if(_0x1e34dc&&_0x1e34dc[_0x394a5e(0x1a6)])return _0x1e34dc;var _0x16ec4a={};if(_0x1e34dc!=null){for(var _0x52cb9a in _0x1e34dc)if(_0x52cb9a!==_0x394a5e(0x1ea)&&Object[_0x394a5e(0x1ca)][_0x394a5e(0x1aa)][_0x394a5e(0x1f4)](_0x1e34dc,_0x52cb9a))__createBinding(_0x16ec4a,_0x1e34dc,_0x52cb9a);}return __setModuleDefault(_0x16ec4a,_0x1e34dc),_0x16ec4a;};Object[a50_0xeee96b(0x1a2)](exports,a50_0xeee96b(0x1a6),{'value':!![]}),exports[a50_0xeee96b(0x1e4)]=void 0x0;const types_1=require(a50_0xeee96b(0x1c3)),session_types_1=require(a50_0xeee96b(0x19f)),Internal=__importStar(require('./internal')),base64=__importStar(require(a50_0xeee96b(0x1c6))),session_record_1=require(a50_0xeee96b(0x1be)),session_lock_1=require('./session-lock'),helpers_1=require(a50_0xeee96b(0x1c8));function a50_0x21d7(_0x28c0f7,_0x353fea){const _0x2b2762=a50_0x2b27();return a50_0x21d7=function(_0x21d7a5,_0x3314ac){_0x21d7a5=_0x21d7a5-0x19f;let _0x3aa89d=_0x2b2762[_0x21d7a5];return _0x3aa89d;},a50_0x21d7(_0x28c0f7,_0x353fea);}class SessionBuilder{constructor(_0x5ab64a,_0x55837d){const _0x5140d4=a50_0xeee96b;this['processPreKeyJob']=async _0x41e39a=>{const _0x3153c4=a50_0x21d7;var _0xcf97aa;const _0x4ef8a0=await this[_0x3153c4(0x1c5)][_0x3153c4(0x1d0)](this[_0x3153c4(0x1ae)][_0x3153c4(0x1d1)],_0x41e39a[_0x3153c4(0x1cc)],types_1[_0x3153c4(0x1f9)][_0x3153c4(0x1c2)]);if(!_0x4ef8a0)throw new Error('Identity\x20key\x20changed');await Internal[_0x3153c4(0x1bd)][_0x3153c4(0x1b6)](_0x41e39a[_0x3153c4(0x1cc)],_0x41e39a[_0x3153c4(0x1b2)][_0x3153c4(0x1f7)],_0x41e39a[_0x3153c4(0x1b2)]['signature']);const _0x44be59=await Internal[_0x3153c4(0x1bd)][_0x3153c4(0x1e7)](),_0x79f59c=(_0xcf97aa=_0x41e39a['preKey'])===null||_0xcf97aa===void 0x0?void 0x0:_0xcf97aa['publicKey'],_0x2fdfa4=await this[_0x3153c4(0x1e5)](_0x44be59,_0x41e39a['identityKey'],_0x41e39a[_0x3153c4(0x1b2)][_0x3153c4(0x1f7)],_0x79f59c,_0x41e39a[_0x3153c4(0x1b9)]);_0x2fdfa4[_0x3153c4(0x1fb)]={'signedKeyId':_0x41e39a[_0x3153c4(0x1b2)][_0x3153c4(0x1ed)],'baseKey':_0x44be59[_0x3153c4(0x1a7)]};_0x41e39a[_0x3153c4(0x1b8)]&&(_0x2fdfa4['pendingPreKey'][_0x3153c4(0x1a4)]=_0x41e39a[_0x3153c4(0x1b8)][_0x3153c4(0x1ed)]);const _0x37dd79=this[_0x3153c4(0x1ae)][_0x3153c4(0x1ba)](),_0x3d9b15=await this[_0x3153c4(0x1c5)][_0x3153c4(0x1bf)](_0x37dd79);let _0x242efd;return _0x3d9b15!==undefined?_0x242efd=session_record_1[_0x3153c4(0x1c0)][_0x3153c4(0x1f6)](_0x3d9b15):_0x242efd=new session_record_1['SessionRecord'](),_0x242efd[_0x3153c4(0x1b1)](),_0x242efd[_0x3153c4(0x1e1)](_0x2fdfa4),await Promise['all']([this[_0x3153c4(0x1c5)][_0x3153c4(0x1b0)](_0x37dd79,_0x242efd[_0x3153c4(0x1cf)]()),this[_0x3153c4(0x1c5)]['saveIdentity'](this[_0x3153c4(0x1ae)][_0x3153c4(0x1ba)](),_0x2fdfa4[_0x3153c4(0x1d8)][_0x3153c4(0x1b4)])]),_0x2fdfa4;},this['startSessionAsInitiator']=async(_0x36ab88,_0x42c835,_0x3e5968,_0xf96367,_0x20dd0b)=>{const _0x5dba2e=a50_0x21d7,_0x41a26d=await this[_0x5dba2e(0x1c5)][_0x5dba2e(0x1d3)]();if(!_0x41a26d)throw new Error(_0x5dba2e(0x1dc));let _0x58a052;_0xf96367===undefined?_0x58a052=new Uint8Array(0x20*0x4):_0x58a052=new Uint8Array(0x20*0x5);for(let _0x339a29=0x0;_0x339a29<0x20;_0x339a29++){_0x58a052[_0x339a29]=0xff;}if(!_0x3e5968)throw new Error(_0x5dba2e(0x1c4));const _0x5d6603=await Promise[_0x5dba2e(0x1c9)]([Internal[_0x5dba2e(0x1bd)][_0x5dba2e(0x1af)](_0x3e5968,_0x41a26d[_0x5dba2e(0x1e2)]),Internal[_0x5dba2e(0x1bd)][_0x5dba2e(0x1af)](_0x42c835,_0x36ab88[_0x5dba2e(0x1e2)]),Internal[_0x5dba2e(0x1bd)][_0x5dba2e(0x1af)](_0x3e5968,_0x36ab88[_0x5dba2e(0x1e2)])]);_0x58a052[_0x5dba2e(0x1ec)](new Uint8Array(_0x5d6603[0x0]),0x20),_0x58a052[_0x5dba2e(0x1ec)](new Uint8Array(_0x5d6603[0x1]),0x20*0x2),_0x58a052[_0x5dba2e(0x1ec)](new Uint8Array(_0x5d6603[0x2]),0x20*0x3);if(_0xf96367!==undefined){const _0x108ec9=await Internal['crypto'][_0x5dba2e(0x1af)](_0xf96367,_0x36ab88[_0x5dba2e(0x1e2)]);_0x58a052[_0x5dba2e(0x1ec)](new Uint8Array(_0x108ec9),0x20*0x4);}const _0x1fb878=await Internal['HKDF']((0x0,helpers_1['uint8ArrayToArrayBuffer'])(_0x58a052),new ArrayBuffer(0x20),_0x5dba2e(0x1e3)),_0x1e310c={'registrationId':_0x20dd0b,'currentRatchet':{'rootKey':_0x1fb878[0x0],'lastRemoteEphemeralKey':_0x3e5968,'previousCounter':0x0},'indexInfo':{'remoteIdentityKey':_0x42c835,'closed':-0x1},'oldRatchetList':[],'chains':{}};_0x1e310c['indexInfo'][_0x5dba2e(0x1c7)]=_0x36ab88[_0x5dba2e(0x1a7)],_0x1e310c[_0x5dba2e(0x1d8)]['baseKeyType']=session_types_1[_0x5dba2e(0x1b3)]['OURS'];const _0x3caaea=await Internal['crypto'][_0x5dba2e(0x1e7)]();return _0x1e310c[_0x5dba2e(0x1f3)][_0x5dba2e(0x1dd)]=_0x3caaea,await this[_0x5dba2e(0x1ab)](_0x1e310c,_0x3e5968),_0x1e310c;},this[_0x5140d4(0x1db)]=async(_0x4bdc3b,_0xd1f4e0,_0x20fb3b)=>{const _0x57cc7f=_0x5140d4,_0x5d5dab=await this[_0x57cc7f(0x1c5)][_0x57cc7f(0x1d3)](),_0x349fff=_0x20fb3b['identityKey'],_0x30eb0d=_0x20fb3b[_0x57cc7f(0x1c7)];if(!_0x5d5dab)throw new Error(_0x57cc7f(0x1dc));let _0x2d581e;!_0x4bdc3b?_0x2d581e=new Uint8Array(0x20*0x4):_0x2d581e=new Uint8Array(0x20*0x5);for(let _0x38f668=0x0;_0x38f668<0x20;_0x38f668++){_0x2d581e[_0x38f668]=0xff;}const _0x665c09=await Promise[_0x57cc7f(0x1c9)]([Internal[_0x57cc7f(0x1bd)][_0x57cc7f(0x1af)](_0x349fff,_0xd1f4e0[_0x57cc7f(0x1e2)]),Internal[_0x57cc7f(0x1bd)][_0x57cc7f(0x1af)](_0x30eb0d,_0x5d5dab['privKey']),Internal[_0x57cc7f(0x1bd)][_0x57cc7f(0x1af)](_0x30eb0d,_0xd1f4e0[_0x57cc7f(0x1e2)])]);_0x2d581e['set'](new Uint8Array(_0x665c09[0x0]),0x20),_0x2d581e[_0x57cc7f(0x1ec)](new Uint8Array(_0x665c09[0x1]),0x20*0x2),_0x2d581e[_0x57cc7f(0x1ec)](new Uint8Array(_0x665c09[0x2]),0x20*0x3);if(_0x4bdc3b){const _0x3e5178=await Internal[_0x57cc7f(0x1bd)][_0x57cc7f(0x1af)](_0x30eb0d,_0x4bdc3b[_0x57cc7f(0x1e2)]);_0x2d581e[_0x57cc7f(0x1ec)](new Uint8Array(_0x3e5178),0x20*0x4);}const _0x332456=await Internal[_0x57cc7f(0x1f0)]((0x0,helpers_1['uint8ArrayToArrayBuffer'])(_0x2d581e),new ArrayBuffer(0x20),_0x57cc7f(0x1e3)),_0x156572={'registrationId':_0x20fb3b[_0x57cc7f(0x1b9)],'currentRatchet':{'rootKey':_0x332456[0x0],'lastRemoteEphemeralKey':_0x30eb0d,'previousCounter':0x0},'indexInfo':{'remoteIdentityKey':_0x349fff,'closed':-0x1},'oldRatchetList':[],'chains':{}};return _0x156572[_0x57cc7f(0x1d8)]['baseKey']=_0x30eb0d,_0x156572['indexInfo'][_0x57cc7f(0x1ad)]=session_types_1[_0x57cc7f(0x1b3)][_0x57cc7f(0x1da)],_0x156572[_0x57cc7f(0x1f3)][_0x57cc7f(0x1dd)]=_0xd1f4e0,_0x156572;},this[_0x5140d4(0x1ae)]=_0x55837d,this[_0x5140d4(0x1c5)]=_0x5ab64a;}async['calculateSendingRatchet'](_0x39ad4b,_0x450a5e){const _0x4a30d2=a50_0xeee96b,_0x163146=_0x39ad4b[_0x4a30d2(0x1f3)];if(!_0x163146[_0x4a30d2(0x1dd)])throw new Error(_0x4a30d2(0x1d5));const _0x230cfb=_0x163146[_0x4a30d2(0x1dd)][_0x4a30d2(0x1e2)],_0x3f5b13=_0x163146[_0x4a30d2(0x1d4)],_0x1f34ad=base64[_0x4a30d2(0x1d2)](new Uint8Array(_0x163146[_0x4a30d2(0x1dd)]['pubKey']));if(!(_0x230cfb&&_0x1f34ad&&_0x3f5b13))throw new Error(_0x4a30d2(0x1f2));const _0x1c0886=await Internal[_0x4a30d2(0x1bd)][_0x4a30d2(0x1af)](_0x450a5e,_0x230cfb),_0x2d5681=await Internal[_0x4a30d2(0x1f0)](_0x1c0886,_0x3f5b13,_0x4a30d2(0x1b7));_0x39ad4b['chains'][_0x1f34ad]={'messageKeys':{},'chainKey':{'counter':-0x1,'key':_0x2d5681[0x1]},'chainType':session_types_1[_0x4a30d2(0x1d9)][_0x4a30d2(0x1c2)]},_0x163146['rootKey']=_0x2d5681[0x0];}async[a50_0xeee96b(0x1f5)](_0x3fde7d){const _0x2e35cb=a50_0xeee96b,_0x12a764=async()=>{const _0xbdf4a7=a50_0x21d7,_0x271192=await this[_0xbdf4a7(0x1a3)](_0x3fde7d);return _0x271192;};return session_lock_1[_0x2e35cb(0x1bb)][_0x2e35cb(0x1cd)](this[_0x2e35cb(0x1ae)][_0x2e35cb(0x1ba)](),_0x12a764);}async[a50_0xeee96b(0x1cb)](_0x300e82,_0x122e22){const _0x55d80d=a50_0xeee96b,_0x56c82c=this['storage'][_0x55d80d(0x1d0)](this['remoteAddress']['name'],(0x0,helpers_1[_0x55d80d(0x1e9)])(_0x122e22[_0x55d80d(0x1cc)]),types_1[_0x55d80d(0x1f9)]['RECEIVING']);if(!_0x56c82c)throw new Error(_0x55d80d(0x1e0)+(0x0,helpers_1[_0x55d80d(0x1e9)])(_0x122e22[_0x55d80d(0x1cc)]));const [_0x42acc0,_0x4cee0f]=await Promise[_0x55d80d(0x1c9)]([this['storage']['loadPreKey'](_0x122e22[_0x55d80d(0x1a4)]),this[_0x55d80d(0x1c5)][_0x55d80d(0x1d6)](_0x122e22['signedPreKeyId'])]);if(_0x300e82[_0x55d80d(0x1ac)](_0x122e22['baseKey']))return;const _0x21c7e5=_0x300e82[_0x55d80d(0x1a5)]();if(_0x4cee0f===undefined){if(_0x21c7e5!==undefined&&_0x21c7e5[_0x55d80d(0x1f3)]!==undefined)return;else throw new Error(_0x55d80d(0x1f8));}_0x21c7e5!==undefined&&_0x300e82[_0x55d80d(0x1b1)]();if(_0x122e22[_0x55d80d(0x1a4)]&&!_0x42acc0){}const _0x3c2e39=await this[_0x55d80d(0x1db)](_0x42acc0,_0x4cee0f,_0x122e22);return _0x300e82[_0x55d80d(0x1e1)](_0x3c2e39),await this['storage'][_0x55d80d(0x1ef)](this['remoteAddress'][_0x55d80d(0x1ba)](),(0x0,helpers_1[_0x55d80d(0x1e9)])(_0x122e22[_0x55d80d(0x1cc)])),_0x122e22['preKeyId'];}}function a50_0x2b27(){const _0x27c2bc=['1048883edsxnV','defineProperty','processPreKeyJob','preKeyId','getOpenSession','__esModule','pubKey','2753694WmjVIb','3090848ntlTqA','hasOwnProperty','calculateSendingRatchet','getSessionByBaseKey','baseKeyType','remoteAddress','ECDHE','storeSession','archiveCurrentState','signedPreKey','BaseKeyType','remoteIdentityKey','3994205JYpypr','Ed25519Verify','WhisperRatchet','preKey','registrationId','toString','SessionLock','3LBaLfa','crypto','./session-record','loadSession','SessionRecord','configurable','SENDING','./types','theirSignedPubKey\x20is\x20undefined.\x20Cannot\x20proceed\x20with\x20ECDHE','storage','base64-js','baseKey','./helpers','all','prototype','processV3','identityKey','queueJobForNumber','__setModuleDefault','serialize','isTrustedIdentity','name','fromByteArray','getIdentityKeyPair','rootKey','Invalid\x20ratchet\x20-\x20ephemeral\x20key\x20pair\x20is\x20missing','loadSignedPreKey','4IgAOYm','indexInfo','ChainType','THEIRS','startSessionWthPreKeyMessage','No\x20identity\x20key.\x20Cannot\x20initiate\x20session.','ephemeralKeyPair','getOwnPropertyDescriptor','11YmCPpa','Unknown\x20identity\x20key:\x20','updateSessionState','privKey','WhisperText','SessionBuilder','startSessionAsInitiator','19898320odUgUh','createKeyPair','6ajDgtx','uint8ArrayToArrayBuffer','default','6638093jkZwbT','set','keyId','get','saveIdentity','HKDF','create','Missing\x20key,\x20cannot\x20calculate\x20sending\x20ratchet','currentRatchet','call','processPreKey','deserialize','publicKey','Missing\x20Signed\x20PreKey\x20for\x20PreKeyWhisperMessage','Direction','__importStar','pendingPreKey','./session-types','1892698Tvvyre'];a50_0x2b27=function(){return _0x27c2bc;};return a50_0x2b27();}exports[a50_0xeee96b(0x1e4)]=SessionBuilder;