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 22.5 kB
'use strict';function a51_0x4335(){const _0x63574e=['doDecryptWhisperMessage','./types','chains','ChainType','hasOpenSession','deserialize','getOwnPropertyDescriptor','345846BxGkio','hasOwnProperty','oldRatchetList','16udHvWu','storage','get','ratchet\x20missing\x20ephemeralKeyPair','updateSessionState','unable\x20to\x20find\x20session\x20for\x20base\x20key\x20','Our\x20identity\x20key\x20is\x20missing.\x20Cannot\x20decrypt.','name','indexInfo','SignalProtocolAddress','WhisperMessageKeys','decryptPreKeyWhisperMessage','197264axrIYJ','binaryStringToArrayBuffer','getIdentityKeyPair','Direction','49xuHHGQ','registrationId','counter','key','6680unOAIV','uint8ArrayToArrayBuffer','encryptJob','saveIdentity','ephemeralKeyPair','serialize','chainKey','cannot\x20encrypt\x20without\x20identity\x20key','default','finish','SessionRecord','create','message','currentRatchet','toString','reject','SessionLock','call','getSessions','Tried\x20to\x20encrypt\x20on\x20a\x20receiving\x20chain','./session-builder','resolve','Got\x20invalid\x20request\x20to\x20extend\x20chain\x20after\x20it\x20was\x20already\x20closed','string','__createBinding','./session-lock','remoteIdentityKey','messageKeys','privKey','getRecord','pubKey','decryptWithSessionList','SENDING','fromByteArray','6019tHkNIm','RECEIVING','session','closed','encrypt','105393wMGlWY','queueJobForNumber','./signal-protocol-address','length','Message\x20key\x20not\x20found.\x20The\x20counter\x20was\x20repeated\x20or\x20the\x20key\x20was\x20not\x20filled.','73212stAUGf','removePreKey','getName','binary','signedKeyId','storeSession','isTrustedIdentity','./helpers','decryptWhisperMessage','./session-types','base64-js','fillMessageKeys','__setModuleDefault','384958HAeRDj','configurable','./session-record','No\x20record\x20for\x20','crypto','1665KmEOns','preKeyId','unsupported\x20encoding:\x20','calculateRatchet','SessionCipher','PreKeyWhisperMessage','uint8ArrayToString','HKDF','WhisperRatchet','buffer','12026oDkWeR','archiveCurrentState','5eIeTtj','lastRemoteEphemeralKey','baseKey','./internal','__esModule','No\x20session\x20to\x20encrypt\x20message\x20for\x20','slice','haveOpenSession','ciphertext','previousCounter','defineProperty','209qzFnxD','push','decode','signedPreKeyId','Expected\x20buffer\x20to\x20be\x20an\x20ArrayBuffer','ephemeralKey','sign','1iUIaaL','set','fromCharCode','now','loadKeysAndRecord','@privacyresearch/libsignal-protocol-protobuf-ts','MessageCounterError','prepareChain','maybeStepRatchet','closeOpenSessionForDevice','getOpenSession','SessionBuilder','WhisperMessage','remoteAddress','__importStar','pendingPreKey','currentRatchet\x20has\x20no\x20ephemeral\x20key.\x20Cannot\x20calculateRatchet.','chainType','chain\x20key\x20is\x20missing','encode','byteLength','getSessionByBaseKey','fromJSON','loadSession','getLocalRegistrationId','writable','rootKey','No\x20registrationId','Incompatible\x20version\x20number\x20on\x20WhisperMessage\x20','Identity\x20key\x20changed'];a51_0x4335=function(){return _0x63574e;};return a51_0x4335();}const a51_0x10fc0f=a51_0x440a;(function(_0x5856f1,_0x1ceae1){const _0x324000=a51_0x440a,_0x544e1f=_0x5856f1();while(!![]){try{const _0x11ffeb=-parseInt(_0x324000(0x26c))/0x1*(parseInt(_0x324000(0x249))/0x2)+-parseInt(_0x324000(0x237))/0x3*(-parseInt(_0x324000(0x1fc))/0x4)+-parseInt(_0x324000(0x25a))/0x5*(parseInt(_0x324000(0x1f9))/0x6)+-parseInt(_0x324000(0x20c))/0x7*(parseInt(_0x324000(0x208))/0x8)+-parseInt(_0x324000(0x24e))/0x9*(-parseInt(_0x324000(0x210))/0xa)+parseInt(_0x324000(0x265))/0xb*(-parseInt(_0x324000(0x23c))/0xc)+-parseInt(_0x324000(0x232))/0xd*(-parseInt(_0x324000(0x258))/0xe);if(_0x11ffeb===_0x1ceae1)break;else _0x544e1f['push'](_0x544e1f['shift']());}catch(_0x38c54d){_0x544e1f['push'](_0x544e1f['shift']());}}}(a51_0x4335,0x1e128));function a51_0x440a(_0xb4ebe2,_0x495d0e){const _0x43355d=a51_0x4335();return a51_0x440a=function(_0x440a9a,_0x33f0fe){_0x440a9a=_0x440a9a-0x1dd;let _0x3075fb=_0x43355d[_0x440a9a];return _0x3075fb;},a51_0x440a(_0xb4ebe2,_0x495d0e);}var __createBinding=this&&this[a51_0x10fc0f(0x228)]||(Object[a51_0x10fc0f(0x21b)]?function(_0x2dbb14,_0x3f4943,_0x202537,_0x2c61fc){const _0x47ede9=a51_0x10fc0f;if(_0x2c61fc===undefined)_0x2c61fc=_0x202537;var _0x3d3651=Object[_0x47ede9(0x1f8)](_0x3f4943,_0x202537);(!_0x3d3651||(_0x47ede9(0x1fe)in _0x3d3651?!_0x3f4943[_0x47ede9(0x25e)]:_0x3d3651[_0x47ede9(0x1ed)]||_0x3d3651[_0x47ede9(0x24a)]))&&(_0x3d3651={'enumerable':!![],'get':function(){return _0x3f4943[_0x202537];}}),Object[_0x47ede9(0x264)](_0x2dbb14,_0x2c61fc,_0x3d3651);}:function(_0x589c37,_0xc9f47d,_0x589257,_0x49b207){if(_0x49b207===undefined)_0x49b207=_0x589257;_0x589c37[_0x49b207]=_0xc9f47d[_0x589257];}),__setModuleDefault=this&&this[a51_0x10fc0f(0x248)]||(Object['create']?function(_0x176f1d,_0x1629a9){const _0x3a7560=a51_0x10fc0f;Object[_0x3a7560(0x264)](_0x176f1d,'default',{'enumerable':!![],'value':_0x1629a9});}:function(_0x383aff,_0x2eaee8){const _0x4857e4=a51_0x10fc0f;_0x383aff[_0x4857e4(0x218)]=_0x2eaee8;}),__importStar=this&&this[a51_0x10fc0f(0x1e2)]||function(_0x5bcc64){const _0x567f5f=a51_0x10fc0f;if(_0x5bcc64&&_0x5bcc64[_0x567f5f(0x25e)])return _0x5bcc64;var _0x5acfa0={};if(_0x5bcc64!=null){for(var _0x45e44c in _0x5bcc64)if(_0x45e44c!==_0x567f5f(0x218)&&Object['prototype'][_0x567f5f(0x1fa)][_0x567f5f(0x221)](_0x5bcc64,_0x45e44c))__createBinding(_0x5acfa0,_0x5bcc64,_0x45e44c);}return __setModuleDefault(_0x5acfa0,_0x5bcc64),_0x5acfa0;};Object[a51_0x10fc0f(0x264)](exports,a51_0x10fc0f(0x25e),{'value':!![]}),exports[a51_0x10fc0f(0x252)]=void 0x0;const types_1=require(a51_0x10fc0f(0x1f3)),session_types_1=require(a51_0x10fc0f(0x245)),signal_protocol_address_1=require(a51_0x10fc0f(0x239)),libsignal_protocol_protobuf_ts_1=require(a51_0x10fc0f(0x271)),base64=__importStar(require(a51_0x10fc0f(0x246))),util=__importStar(require(a51_0x10fc0f(0x243))),Internal=__importStar(require(a51_0x10fc0f(0x25d))),session_record_1=require(a51_0x10fc0f(0x24b)),session_lock_1=require(a51_0x10fc0f(0x229)),session_builder_1=require(a51_0x10fc0f(0x224)),helpers_1=require(a51_0x10fc0f(0x243));class SessionCipher{constructor(_0x3cd1d2,_0x4f16d2){const _0x16cdc3=a51_0x10fc0f;this[_0x16cdc3(0x212)]=async _0x2192e7=>{const _0x3c65dd=_0x16cdc3;if(!(_0x2192e7 instanceof ArrayBuffer))throw new Error(_0x3c65dd(0x269));const _0x19358a=this['remoteAddress'][_0x3c65dd(0x21e)](),_0x253a63=libsignal_protocol_protobuf_ts_1['WhisperMessage'][_0x3c65dd(0x1ea)]({}),[_0x601c88,_0x2fd573,_0x59ef94]=await this['loadKeysAndRecord'](_0x19358a);if(!_0x59ef94)throw new Error(_0x3c65dd(0x24c)+_0x19358a);if(!_0x601c88)throw new Error(_0x3c65dd(0x217));const {session:_0x248ed6,chain:_0x3afedd}=await this[_0x3c65dd(0x273)](_0x19358a,_0x59ef94,_0x253a63),_0xffb519=await Internal[_0x3c65dd(0x255)](_0x3afedd[_0x3c65dd(0x22b)][_0x3afedd[_0x3c65dd(0x216)][_0x3c65dd(0x20e)]],new ArrayBuffer(0x20),_0x3c65dd(0x206));delete _0x3afedd[_0x3c65dd(0x22b)][_0x3afedd[_0x3c65dd(0x216)][_0x3c65dd(0x20e)]],_0x253a63['counter']=_0x3afedd[_0x3c65dd(0x216)][_0x3c65dd(0x20e)],_0x253a63[_0x3c65dd(0x263)]=_0x248ed6['currentRatchet']['previousCounter'];const _0x198c29=await Internal[_0x3c65dd(0x24d)][_0x3c65dd(0x236)](_0xffb519[0x0],_0x2192e7,_0xffb519[0x2][_0x3c65dd(0x260)](0x0,0x10));_0x253a63[_0x3c65dd(0x262)]=new Uint8Array(_0x198c29);const _0x4007db=libsignal_protocol_protobuf_ts_1[_0x3c65dd(0x1e0)][_0x3c65dd(0x1e7)](_0x253a63)[_0x3c65dd(0x219)](),_0x65bc1b=new Uint8Array(_0x4007db[_0x3c65dd(0x1e8)]+0x21*0x2+0x1);_0x65bc1b[_0x3c65dd(0x26d)](new Uint8Array(_0x601c88['pubKey'])),_0x65bc1b['set'](new Uint8Array(_0x248ed6['indexInfo']['remoteIdentityKey']),0x21),_0x65bc1b[0x21*0x2]=0x3<<0x4|0x3,_0x65bc1b[_0x3c65dd(0x26d)](new Uint8Array(_0x4007db),0x21*0x2+0x1);const _0x2ee9d3=await Internal[_0x3c65dd(0x24d)]['sign'](_0xffb519[0x1],_0x65bc1b[_0x3c65dd(0x257)]),_0x6aaf98=new Uint8Array(_0x4007db[_0x3c65dd(0x1e8)]+0x9);_0x6aaf98[0x0]=0x3<<0x4|0x3,_0x6aaf98[_0x3c65dd(0x26d)](new Uint8Array(_0x4007db),0x1),_0x6aaf98[_0x3c65dd(0x26d)](new Uint8Array(_0x2ee9d3,0x0,0x8),_0x4007db[_0x3c65dd(0x1e8)]+0x1);const _0x269bf0=await this[_0x3c65dd(0x1fd)][_0x3c65dd(0x242)](this['remoteAddress'][_0x3c65dd(0x23e)](),_0x248ed6['indexInfo'][_0x3c65dd(0x22a)],types_1[_0x3c65dd(0x20b)][_0x3c65dd(0x230)]);if(!_0x269bf0)throw new Error(_0x3c65dd(0x1f1));this['storage'][_0x3c65dd(0x213)](this[_0x3c65dd(0x1e1)][_0x3c65dd(0x21e)](),_0x248ed6[_0x3c65dd(0x204)][_0x3c65dd(0x22a)]),_0x59ef94['updateSessionState'](_0x248ed6),await this['storage'][_0x3c65dd(0x241)](_0x19358a,_0x59ef94[_0x3c65dd(0x215)]());if(_0x248ed6[_0x3c65dd(0x1e3)]!==undefined){const _0x4d9d32=libsignal_protocol_protobuf_ts_1['PreKeyWhisperMessage']['fromJSON']({});_0x4d9d32['identityKey']=new Uint8Array(_0x601c88[_0x3c65dd(0x22e)]),_0x4d9d32[_0x3c65dd(0x20d)]=_0x2fd573,_0x4d9d32['baseKey']=new Uint8Array(_0x248ed6['pendingPreKey'][_0x3c65dd(0x25c)]);_0x248ed6[_0x3c65dd(0x1e3)][_0x3c65dd(0x24f)]&&(_0x4d9d32[_0x3c65dd(0x24f)]=_0x248ed6[_0x3c65dd(0x1e3)]['preKeyId']);_0x4d9d32[_0x3c65dd(0x268)]=_0x248ed6['pendingPreKey'][_0x3c65dd(0x240)],_0x4d9d32[_0x3c65dd(0x21c)]=_0x6aaf98;const _0x22cc52=libsignal_protocol_protobuf_ts_1[_0x3c65dd(0x253)][_0x3c65dd(0x1e7)](_0x4d9d32)[_0x3c65dd(0x219)](),_0x213a12=String[_0x3c65dd(0x26e)](0x3<<0x4|0x3)+util['uint8ArrayToString'](_0x22cc52);return{'type':0x3,'body':_0x213a12,'registrationId':_0x248ed6[_0x3c65dd(0x20d)]};}else return{'type':0x1,'body':util[_0x3c65dd(0x254)](_0x6aaf98),'registrationId':_0x248ed6[_0x3c65dd(0x20d)]};},this[_0x16cdc3(0x270)]=_0x50b2a0=>{const _0x44ea6d=_0x16cdc3;return Promise['all']([this[_0x44ea6d(0x1fd)]['getIdentityKeyPair'](),this[_0x44ea6d(0x1fd)][_0x44ea6d(0x1ec)](),this[_0x44ea6d(0x22d)](_0x50b2a0)]);},this[_0x16cdc3(0x273)]=async(_0x38bce9,_0x2f302d,_0xe73a96)=>{const _0x4e6be0=_0x16cdc3,_0x4bbcd7=_0x2f302d[_0x4e6be0(0x1de)]();if(!_0x4bbcd7)throw new Error(_0x4e6be0(0x25f)+_0x38bce9);if(!_0x4bbcd7['currentRatchet'][_0x4e6be0(0x214)])throw new Error(_0x4e6be0(0x1ff));_0xe73a96['ephemeralKey']=new Uint8Array(_0x4bbcd7[_0x4e6be0(0x21d)][_0x4e6be0(0x214)][_0x4e6be0(0x22e)]);const _0x1536b4=base64[_0x4e6be0(0x231)](_0xe73a96[_0x4e6be0(0x26a)]),_0xfd8618=_0x4bbcd7[_0x4e6be0(0x1f4)][_0x1536b4];if((_0xfd8618===null||_0xfd8618===void 0x0?void 0x0:_0xfd8618[_0x4e6be0(0x1e5)])===session_types_1['ChainType'][_0x4e6be0(0x233)])throw new Error(_0x4e6be0(0x223));return await this[_0x4e6be0(0x247)](_0xfd8618,_0xfd8618['chainKey'][_0x4e6be0(0x20e)]+0x1),{'session':_0x4bbcd7,'chain':_0xfd8618};},this[_0x16cdc3(0x247)]=async(_0x27ff83,_0x376da7)=>{const _0x2f2651=_0x16cdc3;if(_0x27ff83[_0x2f2651(0x216)]['counter']>=_0x376da7)return Promise[_0x2f2651(0x225)]();if(_0x376da7-_0x27ff83[_0x2f2651(0x216)][_0x2f2651(0x20e)]>0x7d0)throw new Error('Over\x202000\x20messages\x20into\x20the\x20future!');if(_0x27ff83[_0x2f2651(0x216)][_0x2f2651(0x20f)]===undefined)throw new Error(_0x2f2651(0x226));const _0x8828d2=_0x27ff83[_0x2f2651(0x216)]['key'];if(!_0x8828d2)throw new Error(_0x2f2651(0x1e6));const _0x5b44db=new Uint8Array(0x1);_0x5b44db[0x0]=0x1;const _0x55e2a6=await Internal[_0x2f2651(0x24d)]['sign'](_0x8828d2,_0x5b44db['buffer']);_0x5b44db[0x0]=0x2;const _0x4bd147=await Internal['crypto'][_0x2f2651(0x26b)](_0x8828d2,_0x5b44db[_0x2f2651(0x257)]);_0x27ff83[_0x2f2651(0x22b)][_0x27ff83[_0x2f2651(0x216)][_0x2f2651(0x20e)]+0x1]=_0x55e2a6,_0x27ff83[_0x2f2651(0x216)][_0x2f2651(0x20f)]=_0x4bd147,_0x27ff83[_0x2f2651(0x216)][_0x2f2651(0x20e)]+=0x1,await this[_0x2f2651(0x247)](_0x27ff83,_0x376da7);},this[_0x16cdc3(0x1fd)]=_0x3cd1d2,this[_0x16cdc3(0x1e1)]=typeof _0x4f16d2==='string'?signal_protocol_address_1[_0x16cdc3(0x205)]['fromString'](_0x4f16d2):_0x4f16d2;}async[a51_0x10fc0f(0x22d)](_0x5c8055){const _0x141351=a51_0x10fc0f,_0x3529e9=await this['storage'][_0x141351(0x1eb)](_0x5c8055);if(_0x3529e9===undefined)return undefined;return session_record_1[_0x141351(0x21a)][_0x141351(0x1f7)](_0x3529e9);}[a51_0x10fc0f(0x236)](_0x2300ed){const _0x1d4ab2=a51_0x10fc0f;return session_lock_1[_0x1d4ab2(0x220)][_0x1d4ab2(0x238)](this[_0x1d4ab2(0x1e1)]['toString'](),()=>this[_0x1d4ab2(0x212)](_0x2300ed));}async[a51_0x10fc0f(0x251)](_0xa98d40,_0x3b3d13,_0x376432){const _0x22800d=a51_0x10fc0f,_0x25444e=_0xa98d40[_0x22800d(0x21d)];if(!_0x25444e[_0x22800d(0x214)])throw new Error(_0x22800d(0x1e4));const _0x40d836=await Internal['crypto']['ECDHE'](_0x3b3d13,_0x25444e['ephemeralKeyPair'][_0x22800d(0x22c)]),_0xd3d2f0=await Internal[_0x22800d(0x255)](_0x40d836,_0x25444e[_0x22800d(0x1ee)],_0x22800d(0x256));let _0x22fa5e;_0x376432?_0x22fa5e=_0x25444e['ephemeralKeyPair']['pubKey']:_0x22fa5e=_0x3b3d13,_0xa98d40[_0x22800d(0x1f4)][base64['fromByteArray'](new Uint8Array(_0x22fa5e))]={'messageKeys':{},'chainKey':{'counter':-0x1,'key':_0xd3d2f0[0x1]},'chainType':_0x376432?session_types_1[_0x22800d(0x1f5)][_0x22800d(0x230)]:session_types_1[_0x22800d(0x1f5)][_0x22800d(0x233)]},_0x25444e[_0x22800d(0x1ee)]=_0xd3d2f0[0x0];}async[a51_0x10fc0f(0x207)](_0xbc7d20,_0x26e90d){const _0x362c78=a51_0x10fc0f;_0x26e90d=_0x26e90d||_0x362c78(0x23f);if(_0x26e90d!=='binary')throw new Error(_0x362c78(0x250)+_0x26e90d);const _0x41fae7=typeof _0xbc7d20===_0x362c78(0x227)?util['binaryStringToArrayBuffer'](_0xbc7d20):_0xbc7d20,_0x36110a=new Uint8Array(_0x41fae7),_0x15d808=_0x36110a[0x0],_0x3a1c15=_0x36110a[_0x362c78(0x260)](0x1);if((_0x15d808&0xf)>0x3||_0x15d808>>0x4<0x3)throw new Error('Incompatible\x20version\x20number\x20on\x20PreKeyWhisperMessage');const _0x488dc7=this[_0x362c78(0x1e1)][_0x362c78(0x21e)](),_0x3ae4ca=async()=>{const _0x2c22b0=_0x362c78;let _0x165e91=await this['getRecord'](_0x488dc7);const _0x584e1d=libsignal_protocol_protobuf_ts_1[_0x2c22b0(0x253)][_0x2c22b0(0x267)](_0x3a1c15);if(!_0x165e91){if(_0x584e1d[_0x2c22b0(0x20d)]===undefined)throw new Error(_0x2c22b0(0x1ef));_0x165e91=new session_record_1['SessionRecord']();}const _0x48c3c2=new session_builder_1[(_0x2c22b0(0x1df))](this['storage'],this['remoteAddress']),_0x4908a7=await _0x48c3c2['processV3'](_0x165e91,_0x584e1d),_0x53be8a=_0x165e91[_0x2c22b0(0x1e9)]((0x0,helpers_1[_0x2c22b0(0x211)])(_0x584e1d[_0x2c22b0(0x25c)]));if(!_0x53be8a)throw new Error(_0x2c22b0(0x201)+base64['fromByteArray'](_0x584e1d['baseKey'])+',\x20'+_0x584e1d[_0x2c22b0(0x25c)][_0x2c22b0(0x1e8)]);const _0x177a46=await this['doDecryptWhisperMessage'](_0x584e1d['message'],_0x53be8a);return _0x165e91[_0x2c22b0(0x200)](_0x53be8a),await this[_0x2c22b0(0x1fd)]['storeSession'](_0x488dc7,_0x165e91[_0x2c22b0(0x215)]()),_0x4908a7!==undefined&&_0x4908a7!==null&&await this['storage'][_0x2c22b0(0x23d)](_0x4908a7),_0x177a46;};return session_lock_1['SessionLock'][_0x362c78(0x238)](_0x488dc7,_0x3ae4ca);}async[a51_0x10fc0f(0x22f)](_0x4d5fe3,_0x2b7599,_0x230146){const _0x20a463=a51_0x10fc0f;if(_0x2b7599[_0x20a463(0x23a)]===0x0)return Promise[_0x20a463(0x21f)](_0x230146[0x0]);const _0x1eb814=_0x2b7599['pop']();if(!_0x1eb814)return Promise[_0x20a463(0x21f)](_0x230146[0x0]);try{const _0x3cd15e=await this[_0x20a463(0x1f2)](_0x4d5fe3,_0x1eb814);return{'plaintext':_0x3cd15e,'session':_0x1eb814};}catch(_0x2391ff){if(_0x2391ff[_0x20a463(0x203)]==='MessageCounterError')return Promise[_0x20a463(0x21f)](_0x2391ff);return _0x230146[_0x20a463(0x266)](_0x2391ff),this['decryptWithSessionList'](_0x4d5fe3,_0x2b7599,_0x230146);}}[a51_0x10fc0f(0x244)](_0x2e76b6,_0x359fc1){const _0xd78103=a51_0x10fc0f;_0x359fc1=_0x359fc1||'binary';if(_0x359fc1!=='binary')throw new Error('unsupported\x20encoding:\x20'+_0x359fc1);const _0x3b3c52=typeof _0x2e76b6===_0xd78103(0x227)?util[_0xd78103(0x209)](_0x2e76b6):_0x2e76b6,_0x5ba45d=this[_0xd78103(0x1e1)][_0xd78103(0x21e)](),_0x1633f9=async()=>{const _0xc0cfbd=_0xd78103;var _0x3ad860;const _0x5a8aa=await this['getRecord'](_0x5ba45d);if(!_0x5a8aa)throw new Error('No\x20record\x20for\x20device\x20'+_0x5ba45d);const _0x29afc7=[],_0x590f88=await this[_0xc0cfbd(0x22f)](_0x3b3c52,_0x5a8aa[_0xc0cfbd(0x222)](),_0x29afc7);_0x590f88['session'][_0xc0cfbd(0x204)][_0xc0cfbd(0x25c)]!==((_0x3ad860=_0x5a8aa[_0xc0cfbd(0x1de)]())===null||_0x3ad860===void 0x0?void 0x0:_0x3ad860['indexInfo'][_0xc0cfbd(0x25c)])&&(_0x5a8aa[_0xc0cfbd(0x259)](),_0x5a8aa['promoteState'](_0x590f88['session']));const _0x1e2d21=await this['storage'][_0xc0cfbd(0x242)](this[_0xc0cfbd(0x1e1)][_0xc0cfbd(0x23e)](),_0x590f88[_0xc0cfbd(0x234)]['indexInfo']['remoteIdentityKey'],types_1[_0xc0cfbd(0x20b)][_0xc0cfbd(0x233)]);if(!_0x1e2d21)throw new Error(_0xc0cfbd(0x1f1));return await this[_0xc0cfbd(0x1fd)][_0xc0cfbd(0x213)](_0x5ba45d,_0x590f88[_0xc0cfbd(0x234)][_0xc0cfbd(0x204)][_0xc0cfbd(0x22a)]),_0x5a8aa[_0xc0cfbd(0x200)](_0x590f88['session']),await this[_0xc0cfbd(0x1fd)]['storeSession'](_0x5ba45d,_0x5a8aa[_0xc0cfbd(0x215)]()),_0x590f88['plaintext'];};return session_lock_1[_0xd78103(0x220)][_0xd78103(0x238)](_0x5ba45d,_0x1633f9);}async[a51_0x10fc0f(0x1f2)](_0x1b5096,_0x507329){const _0x55dd2d=a51_0x10fc0f,_0x33e603=new Uint8Array(_0x1b5096)[0x0];if((_0x33e603&0xf)>0x3||_0x33e603>>0x4<0x3)throw new Error(_0x55dd2d(0x1f0)+_0x33e603);const _0x4284aa=_0x1b5096['slice'](0x1,_0x1b5096[_0x55dd2d(0x1e8)]-0x8),_0x461334=_0x1b5096[_0x55dd2d(0x260)](_0x1b5096['byteLength']-0x8,_0x1b5096[_0x55dd2d(0x1e8)]),_0x54d883=libsignal_protocol_protobuf_ts_1[_0x55dd2d(0x1e0)]['decode'](new Uint8Array(_0x4284aa)),_0x633e5f=(0x0,helpers_1[_0x55dd2d(0x211)])(_0x54d883[_0x55dd2d(0x26a)]);if(_0x507329===undefined)return Promise['reject'](new Error('No\x20session\x20found\x20to\x20decrypt\x20message\x20from\x20'+this[_0x55dd2d(0x1e1)]['toString']()));if(_0x507329[_0x55dd2d(0x204)][_0x55dd2d(0x235)]!=-0x1){}await this[_0x55dd2d(0x274)](_0x507329,_0x633e5f,_0x54d883[_0x55dd2d(0x263)]);const _0x1f349c=_0x507329[_0x55dd2d(0x1f4)][base64[_0x55dd2d(0x231)](_0x54d883[_0x55dd2d(0x26a)])];!_0x1f349c&&console['warn']('no\x20chain\x20found\x20for\x20key',{'key':base64[_0x55dd2d(0x231)](_0x54d883['ephemeralKey']),'session':_0x507329});if((_0x1f349c===null||_0x1f349c===void 0x0?void 0x0:_0x1f349c[_0x55dd2d(0x1e5)])===session_types_1[_0x55dd2d(0x1f5)][_0x55dd2d(0x230)])throw new Error('Tried\x20to\x20decrypt\x20on\x20a\x20sending\x20chain');await this[_0x55dd2d(0x247)](_0x1f349c,_0x54d883[_0x55dd2d(0x20e)]);const _0x3da934=_0x1f349c[_0x55dd2d(0x22b)][_0x54d883[_0x55dd2d(0x20e)]];if(_0x3da934===undefined){const _0x4467b5=new Error(_0x55dd2d(0x23b));_0x4467b5[_0x55dd2d(0x203)]=_0x55dd2d(0x272);throw _0x4467b5;}delete _0x1f349c[_0x55dd2d(0x22b)][_0x54d883[_0x55dd2d(0x20e)]];const _0x53dc3f=await Internal['HKDF'](_0x3da934,new ArrayBuffer(0x20),'WhisperMessageKeys'),_0x5d1fcd=await this[_0x55dd2d(0x1fd)][_0x55dd2d(0x20a)]();if(!_0x5d1fcd)throw new Error(_0x55dd2d(0x202));const _0x3bf7db=new Uint8Array(_0x4284aa[_0x55dd2d(0x1e8)]+0x21*0x2+0x1);_0x3bf7db[_0x55dd2d(0x26d)](new Uint8Array(_0x507329[_0x55dd2d(0x204)][_0x55dd2d(0x22a)])),_0x3bf7db[_0x55dd2d(0x26d)](new Uint8Array(_0x5d1fcd[_0x55dd2d(0x22e)]),0x21),_0x3bf7db[0x21*0x2]=0x3<<0x4|0x3,_0x3bf7db[_0x55dd2d(0x26d)](new Uint8Array(_0x4284aa),0x21*0x2+0x1),await Internal['verifyMAC'](_0x3bf7db[_0x55dd2d(0x257)],_0x53dc3f[0x1],_0x461334,0x8);const _0x395da9=await Internal[_0x55dd2d(0x24d)]['decrypt'](_0x53dc3f[0x0],(0x0,helpers_1[_0x55dd2d(0x211)])(_0x54d883[_0x55dd2d(0x262)]),_0x53dc3f[0x2][_0x55dd2d(0x260)](0x0,0x10));return delete _0x507329['pendingPreKey'],_0x395da9;}async[a51_0x10fc0f(0x274)](_0x4fe697,_0x449d4b,_0x19d92b){const _0x394d04=a51_0x10fc0f,_0x587f74=base64[_0x394d04(0x231)](new Uint8Array(_0x449d4b));if(_0x4fe697[_0x394d04(0x1f4)][_0x587f74]!==undefined)return Promise[_0x394d04(0x225)]();const _0x2b1a15=_0x4fe697['currentRatchet'];if(!_0x2b1a15['ephemeralKeyPair'])throw new Error('attempting\x20to\x20step\x20reatchet\x20without\x20ephemeral\x20key');const _0x5d75df=_0x4fe697[_0x394d04(0x1f4)][base64[_0x394d04(0x231)](new Uint8Array(_0x2b1a15[_0x394d04(0x25b)]))];_0x5d75df!==undefined&&await this['fillMessageKeys'](_0x5d75df,_0x19d92b)['then'](function(){const _0x4625c0=_0x394d04;delete _0x5d75df[_0x4625c0(0x216)][_0x4625c0(0x20f)],_0x4fe697[_0x4625c0(0x1fb)][_0x4fe697['oldRatchetList'][_0x4625c0(0x23a)]]={'added':Date[_0x4625c0(0x26f)](),'ephemeralKey':_0x2b1a15[_0x4625c0(0x25b)]};});await this[_0x394d04(0x251)](_0x4fe697,_0x449d4b,![]);const _0x11e8b8=base64[_0x394d04(0x231)](new Uint8Array(_0x2b1a15[_0x394d04(0x214)][_0x394d04(0x22e)]));_0x4fe697[_0x394d04(0x1f4)][_0x11e8b8]!==undefined&&(_0x2b1a15[_0x394d04(0x263)]=_0x4fe697['chains'][_0x11e8b8]['chainKey'][_0x394d04(0x20e)],delete _0x4fe697[_0x394d04(0x1f4)][_0x11e8b8]);const _0x4f0a25=await Internal[_0x394d04(0x24d)]['createKeyPair']();_0x2b1a15[_0x394d04(0x214)]=_0x4f0a25,await this[_0x394d04(0x251)](_0x4fe697,_0x449d4b,!![]),_0x2b1a15['lastRemoteEphemeralKey']=_0x449d4b;}['getRemoteRegistrationId'](){const _0xf37eb9=a51_0x10fc0f;return session_lock_1[_0xf37eb9(0x220)]['queueJobForNumber'](this[_0xf37eb9(0x1e1)]['toString'](),async()=>{const _0x1b6cb2=_0xf37eb9,_0x5d5f9a=await this[_0x1b6cb2(0x22d)](this[_0x1b6cb2(0x1e1)][_0x1b6cb2(0x21e)]());if(_0x5d5f9a===undefined)return undefined;const _0x1fe529=_0x5d5f9a[_0x1b6cb2(0x1de)]();if(_0x1fe529===undefined)return undefined;return _0x1fe529[_0x1b6cb2(0x20d)];});}[a51_0x10fc0f(0x1f6)](){const _0x48e2a2=a51_0x10fc0f,_0x37af83=async()=>{const _0x541da0=a51_0x440a,_0x59d1ab=await this['getRecord'](this[_0x541da0(0x1e1)][_0x541da0(0x21e)]());if(_0x59d1ab===undefined)return![];return _0x59d1ab[_0x541da0(0x261)]();};return session_lock_1['SessionLock']['queueJobForNumber'](this[_0x48e2a2(0x1e1)][_0x48e2a2(0x21e)](),_0x37af83);}[a51_0x10fc0f(0x1dd)](){const _0x172644=a51_0x10fc0f,_0x881d37=this[_0x172644(0x1e1)][_0x172644(0x21e)](),_0x40e827=async()=>{const _0x217a98=_0x172644,_0x2892b8=await this[_0x217a98(0x22d)](this[_0x217a98(0x1e1)][_0x217a98(0x21e)]());if(_0x2892b8===undefined||_0x2892b8[_0x217a98(0x1de)]()===undefined)return;return _0x2892b8[_0x217a98(0x259)](),this[_0x217a98(0x1fd)][_0x217a98(0x241)](_0x881d37,_0x2892b8[_0x217a98(0x215)]());};return session_lock_1[_0x172644(0x220)][_0x172644(0x238)](_0x881d37,_0x40e827);}['deleteAllSessionsForDevice'](){const _0x4a6f58=a51_0x10fc0f,_0x228126=this[_0x4a6f58(0x1e1)][_0x4a6f58(0x21e)](),_0x2f0f92=async()=>{const _0x4ab4b0=_0x4a6f58,_0x52a957=await this[_0x4ab4b0(0x22d)](this[_0x4ab4b0(0x1e1)][_0x4ab4b0(0x21e)]());if(_0x52a957===undefined)return;return _0x52a957['deleteAllSessions'](),this[_0x4ab4b0(0x1fd)]['storeSession'](_0x228126,_0x52a957['serialize']());};return session_lock_1[_0x4a6f58(0x220)]['queueJobForNumber'](_0x228126,_0x2f0f92);}}exports['SessionCipher']=SessionCipher;