Built motion from commit f7863d46.|2.5.41
[motion2.git] / server / services / email / lib / imap.js
index aa4ca98..e7fef23 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x08cc=['handleMessageAttributes','handleSimpleParser','handleMessageEnd','stringify','textCode','hasOwnProperty','upperFirst','exports','util','imap','lodash','mailparser','iconv','events','EventEmitter','./utils','../../../config/logger','email','mailbox','INBOX','account','getAccount','ready','handleReady','bind','once','end','handleEnd','error','handleError','prototype','connTimeout','authTimeout','isNil','service','authentication','user','password','host','port','tls','autotls','getHost','openBox','handleOpenBox','emit','box','readUnseen','handleCloseBox','search','UNSEEN','handleReadUnseen','length','message','handleFetchMessage','handleFetchError','closeBox','handleMessageBody','attributes'];(function(_0x2238be,_0x2a33a9){var _0x245b96=function(_0x51e3ec){while(--_0x51e3ec){_0x2238be['push'](_0x2238be['shift']());}};_0x245b96(++_0x2a33a9);}(_0x08cc,0xb9));var _0xc08c=function(_0x152826,_0x5d01db){_0x152826=_0x152826-0x0;var _0x51cc1c=_0x08cc[_0x152826];return _0x51cc1c;};'use strict';var fs=require('fs');var path=require('path');var util=require(_0xc08c('0x0'));var Imap=require(_0xc08c('0x1'));var _=require(_0xc08c('0x2'));var rs=require('randomstring');var simpleParser=require(_0xc08c('0x3'))['simpleParser'];var Iconv=require(_0xc08c('0x4'))['Iconv'];var EventEmitter=require(_0xc08c('0x5'))[_0xc08c('0x6')];var utils=require(_0xc08c('0x7'));var logger=require(_0xc08c('0x8'))(_0xc08c('0x9'));function EmailImap(_0x4fba18,_0x593c91){this[_0xc08c('0xa')]=_0xc08c('0xb');this[_0xc08c('0xc')]=this[_0xc08c('0xd')](_0x4fba18,_0x593c91);this[_0xc08c('0x1')]=new Imap(this['account']);this[_0xc08c('0x1')]['once'](_0xc08c('0xe'),this[_0xc08c('0xf')][_0xc08c('0x10')](this));this[_0xc08c('0x1')][_0xc08c('0x11')](_0xc08c('0x12'),this[_0xc08c('0x13')]['bind'](this));this[_0xc08c('0x1')]['on'](_0xc08c('0x14'),this[_0xc08c('0x15')][_0xc08c('0x10')](this));this[_0xc08c('0x1')]['connect']();}util['inherits'](EmailImap,EventEmitter);EmailImap[_0xc08c('0x16')]['getAccount']=function(_0x47cc21,_0x4dd521){var _0x54c5d5={'connTimeout':_0x47cc21[_0xc08c('0x17')]?_0x47cc21[_0xc08c('0x17')]*0x3e8:0x2710,'authTimeout':_0x47cc21['authTimeout']?_0x47cc21[_0xc08c('0x18')]*0x3e8:0x1388};if(_[_0xc08c('0x19')](_0x47cc21[_0xc08c('0x1a')])){if(_0x47cc21[_0xc08c('0x1b')]){_0x54c5d5['user']=_0x47cc21[_0xc08c('0x1c')];_0x54c5d5[_0xc08c('0x1d')]=_0x47cc21[_0xc08c('0x1d')];}_0x54c5d5[_0xc08c('0x1e')]=_0x47cc21[_0xc08c('0x1e')];_0x54c5d5[_0xc08c('0x1f')]=_0x47cc21[_0xc08c('0x1f')]||0x3e1;if(_0x47cc21[_0xc08c('0x20')]){_0x54c5d5[_0xc08c('0x20')]=!![];}else{_0x54c5d5[_0xc08c('0x20')]=![];_0x54c5d5[_0xc08c('0x21')]='required';}}else{_0x54c5d5[_0xc08c('0x1c')]=_0x47cc21[_0xc08c('0x1c')];_0x54c5d5[_0xc08c('0x1d')]=_0x47cc21[_0xc08c('0x1d')];_0x54c5d5[_0xc08c('0x1e')]=utils[_0xc08c('0x22')](_0x47cc21[_0xc08c('0x1a')]);_0x54c5d5[_0xc08c('0x1f')]=0x3e1;_0x54c5d5[_0xc08c('0x20')]=!![];}_0x54c5d5[_0xc08c('0x9')]=_0x4dd521||_0x47cc21['user']||'anonymous@xcally.com';return _0x54c5d5;};EmailImap[_0xc08c('0x16')][_0xc08c('0xf')]=function(){this['imap'][_0xc08c('0x23')](this[_0xc08c('0xa')],![],this[_0xc08c('0x24')]['bind'](this));};EmailImap[_0xc08c('0x16')][_0xc08c('0x24')]=function(_0x1052c9,_0x1568eb){if(_0x1052c9){this[_0xc08c('0x15')](_0x1052c9,!![]);}else{this[_0xc08c('0x25')](_0xc08c('0x26'),_0x1568eb);this[_0xc08c('0x27')]();}};EmailImap[_0xc08c('0x16')][_0xc08c('0x28')]=function(_0x3e42d8){if(_0x3e42d8){this['handleError'](_0x3e42d8,!![]);}else{this['imap'][_0xc08c('0x12')]();}};EmailImap[_0xc08c('0x16')][_0xc08c('0x27')]=function(){this[_0xc08c('0x1')][_0xc08c('0x29')]([_0xc08c('0x2a')],this[_0xc08c('0x2b')][_0xc08c('0x10')](this));};EmailImap[_0xc08c('0x16')][_0xc08c('0x2b')]=function(_0x18ba64,_0x554cd6){if(_0x18ba64){this[_0xc08c('0x15')](_0x18ba64,!![]);}else{if(_0x554cd6[_0xc08c('0x2c')]){try{var _0x3e28b9=this[_0xc08c('0x1')]['fetch'](_0x554cd6,{'bodies':'','markSeen':!![]});_0x3e28b9['on'](_0xc08c('0x2d'),this[_0xc08c('0x2e')][_0xc08c('0x10')](this));_0x3e28b9[_0xc08c('0x11')](_0xc08c('0x14'),this[_0xc08c('0x2f')]['bind'](this));_0x3e28b9[_0xc08c('0x11')](_0xc08c('0x12'),this['handleFetchEnd'][_0xc08c('0x10')](this));}catch(_0x5a48f0){logger[_0xc08c('0x14')](_0x5a48f0);}}else{this['imap'][_0xc08c('0x30')](!![],this['handleCloseBox'][_0xc08c('0x10')](this));}}};EmailImap[_0xc08c('0x16')][_0xc08c('0x2e')]=function(_0x4e46a2,_0x4fc422){_0x4e46a2['on']('body',this[_0xc08c('0x31')][_0xc08c('0x10')](this));_0x4e46a2[_0xc08c('0x11')](_0xc08c('0x32'),this[_0xc08c('0x33')][_0xc08c('0x10')](this));_0x4e46a2[_0xc08c('0x11')](_0xc08c('0x12'),this['handleMessageEnd'][_0xc08c('0x10')](this));};EmailImap[_0xc08c('0x16')]['handleMessageBody']=function(_0x57b932,_0x4812e0){simpleParser(_0x57b932,{'Iconv':Iconv},this[_0xc08c('0x34')][_0xc08c('0x10')](this));};EmailImap[_0xc08c('0x16')]['handleMessageAttributes']=function(_0xd5a605){};EmailImap[_0xc08c('0x16')][_0xc08c('0x35')]=function(){};EmailImap[_0xc08c('0x16')][_0xc08c('0x34')]=function(_0x32b3a5,_0x4d4235){if(_0x32b3a5){logger['error'](_0x32b3a5);}else{var _0x386959=this;utils['parser'](this[_0xc08c('0xc')],_0x4d4235,function(_0x31db4b){_0x386959[_0xc08c('0x25')](_0xc08c('0x9'),_0x31db4b);});}};EmailImap['prototype']['handleFetchEnd']=function(){this[_0xc08c('0x1')][_0xc08c('0x30')](!![],this[_0xc08c('0x28')]['bind'](this));};EmailImap[_0xc08c('0x16')]['handleFetchError']=function(_0xc5ce29){this[_0xc08c('0x15')](_0xc5ce29);this[_0xc08c('0x1')][_0xc08c('0x30')](!![],this['handleCloseBox'][_0xc08c('0x10')](this));};EmailImap['prototype'][_0xc08c('0x13')]=function(){this[_0xc08c('0x25')]('end');};EmailImap['prototype'][_0xc08c('0x15')]=function(_0x3d7288,_0x54962a){logger[_0xc08c('0x14')](_0xc08c('0x15'),this[_0xc08c('0xc')][_0xc08c('0x9')],JSON[_0xc08c('0x36')](_0x3d7288));var _0x5dbbcf='';if(_0x3d7288){if(_0x3d7288[_0xc08c('0x37')]){_0x5dbbcf=_0x3d7288[_0xc08c('0x37')];}else{for(var _0x4f3668 in _0x3d7288){if(_0x3d7288[_0xc08c('0x38')](_0x4f3668)){_0x5dbbcf+=_[_0xc08c('0x39')](_0x4f3668)+':\x20'+_0x3d7288[_0x4f3668]+'\x0a';}}}}if(_0x54962a){this['imap'][_0xc08c('0x12')]();}else{this['emit']('error',_0x5dbbcf);this[_0xc08c('0x25')](_0xc08c('0x12'));}};module[_0xc08c('0x3a')]=EmailImap;
\ No newline at end of file
+var _0xeda8=['fetch','handleFetchError','end','handleFetchEnd','closeBox','handleFetchMessage','body','attributes','handleMessageAttributes','handleMessageEnd','handleMessageBody','parser','stringify','textCode','hasOwnProperty','exports','lodash','util','mailparser','simpleParser','iconv','Iconv','events','EventEmitter','./utils','../../../config/logger','email','mailbox','account','getAccount','imap','bind','once','handleEnd','error','handleError','connect','inherits','prototype','connTimeout','authTimeout','service','user','password','host','tls','autotls','required','modernAuthentication','xoauth2','generateXOAuth2Token','CloudProvider','data5','anonymous@xcally.com','openBox','handleOpenBox','emit','readUnseen','handleCloseBox','search','handleReadUnseen'];(function(_0x119280,_0x439c3e){var _0x481797=function(_0x4265cb){while(--_0x4265cb){_0x119280['push'](_0x119280['shift']());}};_0x481797(++_0x439c3e);}(_0xeda8,0x104));var _0x8eda=function(_0x508bf5,_0x4d9ffc){_0x508bf5=_0x508bf5-0x0;var _0x2f931e=_0xeda8[_0x508bf5];return _0x2f931e;};'use strict';var _=require(_0x8eda('0x0'));var util=require(_0x8eda('0x1'));var Imap=require('imap');var simpleParser=require(_0x8eda('0x2'))[_0x8eda('0x3')];var Iconv=require(_0x8eda('0x4'))[_0x8eda('0x5')];var EventEmitter=require(_0x8eda('0x6'))[_0x8eda('0x7')];var utils=require(_0x8eda('0x8'));var logger=require(_0x8eda('0x9'))(_0x8eda('0xa'));function EmailImap(_0x1f3556,_0x349361){this[_0x8eda('0xb')]='INBOX';this[_0x8eda('0xc')]=this[_0x8eda('0xd')](_0x1f3556,_0x349361);this[_0x8eda('0xe')]=new Imap(this[_0x8eda('0xc')]);this['imap']['once']('ready',this['handleReady'][_0x8eda('0xf')](this));this[_0x8eda('0xe')][_0x8eda('0x10')]('end',this[_0x8eda('0x11')]['bind'](this));this[_0x8eda('0xe')]['on'](_0x8eda('0x12'),this[_0x8eda('0x13')][_0x8eda('0xf')](this));this[_0x8eda('0xe')][_0x8eda('0x14')]();}util[_0x8eda('0x15')](EmailImap,EventEmitter);EmailImap[_0x8eda('0x16')]['getAccount']=function(_0x500bd4,_0xe04d90){var _0x223dcf={'connTimeout':_0x500bd4['connTimeout']?_0x500bd4[_0x8eda('0x17')]*0x3e8:0x2710,'authTimeout':_0x500bd4[_0x8eda('0x18')]?_0x500bd4[_0x8eda('0x18')]*0x3e8:0x1388};if(_['isNil'](_0x500bd4[_0x8eda('0x19')])){if(_0x500bd4['authentication']){_0x223dcf[_0x8eda('0x1a')]=_0x500bd4['user'];_0x223dcf[_0x8eda('0x1b')]=_0x500bd4['password'];}_0x223dcf[_0x8eda('0x1c')]=_0x500bd4[_0x8eda('0x1c')];_0x223dcf['port']=_0x500bd4['port']||0x3e1;if(_0x500bd4[_0x8eda('0x1d')]){_0x223dcf[_0x8eda('0x1d')]=!![];}else{_0x223dcf[_0x8eda('0x1d')]=![];_0x223dcf[_0x8eda('0x1e')]=_0x8eda('0x1f');}}else{if(_0x500bd4[_0x8eda('0x20')]){_0x223dcf[_0x8eda('0x21')]=utils[_0x8eda('0x22')](_0x500bd4[_0x8eda('0x23')][_0x8eda('0x24')],_0x500bd4[_0x8eda('0x1a')]);_0x223dcf['user']=_0x500bd4[_0x8eda('0x1a')];}else{_0x223dcf['user']=_0x500bd4[_0x8eda('0x1a')];_0x223dcf['password']=_0x500bd4[_0x8eda('0x1b')];}_0x223dcf[_0x8eda('0x1c')]=utils['getHost'](_0x500bd4['service']);_0x223dcf['port']=0x3e1;_0x223dcf[_0x8eda('0x1d')]=!![];}_0x223dcf[_0x8eda('0xa')]=_0xe04d90||_0x500bd4['user']||_0x8eda('0x25');return _0x223dcf;};EmailImap[_0x8eda('0x16')]['handleReady']=function(){this[_0x8eda('0xe')][_0x8eda('0x26')](this[_0x8eda('0xb')],![],this[_0x8eda('0x27')][_0x8eda('0xf')](this));};EmailImap['prototype'][_0x8eda('0x27')]=function(_0x5a8bed,_0x35310c){if(_0x5a8bed){this[_0x8eda('0x13')](_0x5a8bed,!![]);}else{this[_0x8eda('0x28')]('box',_0x35310c);this[_0x8eda('0x29')]();}};EmailImap[_0x8eda('0x16')][_0x8eda('0x2a')]=function(_0x4cdd2e){if(_0x4cdd2e){this[_0x8eda('0x13')](_0x4cdd2e,!![]);}else{this[_0x8eda('0xe')]['end']();}};EmailImap[_0x8eda('0x16')][_0x8eda('0x29')]=function(){this[_0x8eda('0xe')][_0x8eda('0x2b')](['UNSEEN'],this['handleReadUnseen']['bind'](this));};EmailImap[_0x8eda('0x16')][_0x8eda('0x2c')]=function(_0x1ed3d3,_0x540690){if(_0x1ed3d3){this['handleError'](_0x1ed3d3,!![]);}else{if(_0x540690['length']){try{var _0x244da0=this[_0x8eda('0xe')][_0x8eda('0x2d')](_0x540690,{'bodies':'','markSeen':!![]});_0x244da0['on']('message',this['handleFetchMessage']['bind'](this));_0x244da0[_0x8eda('0x10')](_0x8eda('0x12'),this[_0x8eda('0x2e')][_0x8eda('0xf')](this));_0x244da0[_0x8eda('0x10')](_0x8eda('0x2f'),this[_0x8eda('0x30')][_0x8eda('0xf')](this));}catch(_0x2db577){logger[_0x8eda('0x12')](_0x2db577);}}else{this[_0x8eda('0xe')][_0x8eda('0x31')](!![],this[_0x8eda('0x2a')][_0x8eda('0xf')](this));}}};EmailImap['prototype'][_0x8eda('0x32')]=function(_0x2ed279){_0x2ed279['on'](_0x8eda('0x33'),this['handleMessageBody']['bind'](this));_0x2ed279[_0x8eda('0x10')](_0x8eda('0x34'),this[_0x8eda('0x35')][_0x8eda('0xf')](this));_0x2ed279['once'](_0x8eda('0x2f'),this[_0x8eda('0x36')][_0x8eda('0xf')](this));};EmailImap[_0x8eda('0x16')][_0x8eda('0x37')]=function(_0x29a706){simpleParser(_0x29a706,{'Iconv':Iconv},this['handleSimpleParser'][_0x8eda('0xf')](this));};EmailImap[_0x8eda('0x16')][_0x8eda('0x35')]=function(){};EmailImap[_0x8eda('0x16')][_0x8eda('0x36')]=function(){};EmailImap[_0x8eda('0x16')]['handleSimpleParser']=function(_0x1067eb,_0x2007c3){if(_0x1067eb){logger[_0x8eda('0x12')](_0x1067eb);}else{var _0x3b8527=this;utils[_0x8eda('0x38')](this['account'],_0x2007c3,function(_0x17ee80){_0x3b8527[_0x8eda('0x28')](_0x8eda('0xa'),_0x17ee80);});}};EmailImap['prototype'][_0x8eda('0x30')]=function(){this['imap'][_0x8eda('0x31')](!![],this[_0x8eda('0x2a')][_0x8eda('0xf')](this));};EmailImap[_0x8eda('0x16')][_0x8eda('0x2e')]=function(_0x5cdc89){this['handleError'](_0x5cdc89);this[_0x8eda('0xe')][_0x8eda('0x31')](!![],this[_0x8eda('0x2a')][_0x8eda('0xf')](this));};EmailImap[_0x8eda('0x16')][_0x8eda('0x11')]=function(){this[_0x8eda('0x28')](_0x8eda('0x2f'));};EmailImap[_0x8eda('0x16')][_0x8eda('0x13')]=function(_0x3f0552,_0x400548){logger[_0x8eda('0x12')](_0x8eda('0x13'),this[_0x8eda('0xc')][_0x8eda('0xa')],JSON[_0x8eda('0x39')](_0x3f0552));var _0x106232='';if(_0x3f0552){if(_0x3f0552[_0x8eda('0x3a')]){_0x106232=_0x3f0552['textCode'];}else{for(var _0x3711f8 in _0x3f0552){if(_0x3f0552[_0x8eda('0x3b')](_0x3711f8)){_0x106232+=_['upperFirst'](_0x3711f8)+':\x20'+_0x3f0552[_0x3711f8]+'\x0a';}}}}if(_0x400548){this[_0x8eda('0xe')][_0x8eda('0x2f')]();}else{this['emit'](_0x8eda('0x12'),_0x106232);this[_0x8eda('0x28')]('end');}};module[_0x8eda('0x3c')]=EmailImap;
\ No newline at end of file