Spaces:
Running
Running
Upload 38 files
Browse files- dist/auth/admin.js +156 -1
- dist/auth/audit.js +28 -1
- dist/auth/avatars.js +59 -1
- dist/auth/delete.js +138 -1
- dist/auth/forgot.js +92 -1
- dist/auth/leaderboard.js +52 -1
- dist/auth/login.js +35 -1
- dist/auth/plans.js +334 -1
- dist/auth/posts.js +227 -1
- dist/auth/register.js +95 -1
- dist/auth/social.js +214 -1
- dist/auth/userinfo.js +101 -1
- dist/auth/verify.js +59 -1
- dist/auth/xp.js +72 -1
- dist/index.js +180 -1
- dist/services/auditStore.js +70 -1
- dist/services/credStore.js +40 -1
- dist/services/drive.js +500 -1
- dist/services/mailer.js +145 -1
- dist/services/paymentsStore.js +79 -1
- dist/services/postsStore.js +138 -1
- dist/services/rateLimit.js +31 -1
- dist/services/secureStore.js +119 -1
- dist/services/xpService.js +113 -1
- dist/utils/CheckUserVerified.js +31 -1
- dist/utils/achievements.js +26 -1
- dist/utils/dedupe.js +49 -1
- dist/utils/owners.js +66 -1
- dist/utils/validate.js +84 -1
- dist/wsBridge.js +133 -1
- local-db/token.enc +0 -0
dist/auth/admin.js
CHANGED
|
@@ -1 +1,156 @@
|
|
| 1 |
-
const _0x2759db=_0x1269;(function(_0x11f652,_0x5259d7){const _0x230307=_0x1269,_0x507723=_0x11f652();while(!![]){try{const _0x3d9863=parseInt(_0x230307(0xac))/0x1+parseInt(_0x230307(0xb8))/0x2*(-parseInt(_0x230307(0xb6))/0x3)+parseInt(_0x230307(0xce))/0x4+parseInt(_0x230307(0xa1))/0x5+-parseInt(_0x230307(0xe5))/0x6+-parseInt(_0x230307(0xad))/0x7+parseInt(_0x230307(0xa6))/0x8*(parseInt(_0x230307(0xc4))/0x9);if(_0x3d9863===_0x5259d7)break;else _0x507723['push'](_0x507723['shift']());}catch(_0x68d427){_0x507723['push'](_0x507723['shift']());}}}(_0xebe0,0x86549));const _0x4cce59=(function(){let _0x3e11af=!![];return function(_0x34994b,_0x2b9768){const _0x5d5694=_0x3e11af?function(){const _0x4e35e1=_0x1269;if(_0x2b9768){const _0x350005=_0x2b9768[_0x4e35e1(0x8f)](_0x34994b,arguments);return _0x2b9768=null,_0x350005;}}:function(){};return _0x3e11af=![],_0x5d5694;};}()),_0x13a8e6=_0x4cce59(this,function(){const _0x192d7c=_0x1269,_0x6e2bc9={};_0x6e2bc9[_0x192d7c(0xa8)]='(((.+)+)+)+$';const _0x1ce7e9=_0x6e2bc9;return _0x13a8e6[_0x192d7c(0xb0)]()[_0x192d7c(0xcf)](_0x192d7c(0x80))[_0x192d7c(0xb0)]()[_0x192d7c(0xeb)](_0x13a8e6)[_0x192d7c(0xcf)](_0x1ce7e9[_0x192d7c(0xa8)]);});_0x13a8e6();function _0x1269(_0x16a34d,_0x43026d){_0x16a34d=_0x16a34d-0x80;const _0x4d8bd2=_0xebe0();let _0x13a8e6=_0x4d8bd2[_0x16a34d];if(_0x1269['TBjHYq']===undefined){var _0x4cce59=function(_0x484cde){const _0x251ffa='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0xc56953='',_0x52cab2='',_0x43c486=_0xc56953+_0x4cce59;for(let _0x27be25=0x0,_0x55e83a,_0x3a6e94,_0x359a8e=0x0;_0x3a6e94=_0x484cde['charAt'](_0x359a8e++);~_0x3a6e94&&(_0x55e83a=_0x27be25%0x4?_0x55e83a*0x40+_0x3a6e94:_0x3a6e94,_0x27be25++%0x4)?_0xc56953+=_0x43c486['charCodeAt'](_0x359a8e+0xa)-0xa!==0x0?String['fromCharCode'](0xff&_0x55e83a>>(-0x2*_0x27be25&0x6)):_0x27be25:0x0){_0x3a6e94=_0x251ffa['indexOf'](_0x3a6e94);}for(let _0x2b7d89=0x0,_0x434200=_0xc56953['length'];_0x2b7d89<_0x434200;_0x2b7d89++){_0x52cab2+='%'+('00'+_0xc56953['charCodeAt'](_0x2b7d89)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x52cab2);};_0x1269['AUqORy']=_0x4cce59,_0x1269['fELcUS']={},_0x1269['TBjHYq']=!![];}const _0xebe0e8=_0x4d8bd2[0x0],_0x126949=_0x16a34d+_0xebe0e8,_0x5b5b52=_0x1269['fELcUS'][_0x126949];if(!_0x5b5b52){const _0x521fe7=function(_0x11a931){this['oNGXZF']=_0x11a931,this['XXhgXp']=[0x1,0x0,0x0],this['BxIUtf']=function(){return'newState';},this['JMMyQp']='\x5cw+\x20*\x5c(\x5c)\x20*{\x5cw+\x20*',this['gnXCwk']='[\x27|\x22].+[\x27|\x22];?\x20*}';};_0x521fe7['prototype']['jLxIvT']=function(){const _0x56736b=new RegExp(this['JMMyQp']+this['gnXCwk']),_0x4e23c0=_0x56736b['test'](this['BxIUtf']['toString']())?--this['XXhgXp'][0x1]:--this['XXhgXp'][0x0];return this['ucNHnx'](_0x4e23c0);},_0x521fe7['prototype']['ucNHnx']=function(_0x582ec5){if(!Boolean(~_0x582ec5))return _0x582ec5;return this['jvEYQk'](this['oNGXZF']);},_0x521fe7['prototype']['jvEYQk']=function(_0x2f0553){for(let _0x6c6455=0x0,_0x24aa9b=this['XXhgXp']['length'];_0x6c6455<_0x24aa9b;_0x6c6455++){this['XXhgXp']['push'](Math['round'](Math['random']())),_0x24aa9b=this['XXhgXp']['length'];}return _0x2f0553(this['XXhgXp'][0x0]);},new _0x521fe7(_0x1269)['jLxIvT'](),_0x13a8e6=_0x1269['AUqORy'](_0x13a8e6),_0x1269['fELcUS'][_0x126949]=_0x13a8e6;}else _0x13a8e6=_0x5b5b52;return _0x13a8e6;}'use strict';function _0xebe0(){const _0x2a4128=['A3jpvNq','t2PdCeC','vxzozMm','EwfkB3m','CM9SzuzVCKvTywLS','kcGOlISPkYKRksSK','Dg9Rzw4VDgfYz2v0l3jVBguGCMvXDwLYzwq','B3DUzxi','Aw5ZDwzMAwnPzw50ihbYAxzPBgvNzxm','CvjcA2W','twLZC2LUzYb0B2TLBG','Dg9Rzw4VDgfYz2v0l2rHExmGCMvXDwLYzwq','D3jPDgvvC2vYrgi','yxbWzw5KqxvKAxq','Bwv0yq','yMfUoMXPzNq','sLvez2K','z2v0vxnLCKzVBgrLCG','BeLwswm','z2v0qwXSvxnLCNm','yxbWBhK','yMXtzg0','x19LC01VzhvSzq','DNH6DwK','CNfMEw0','Bxv0ztPHChbSEq','DxnLCG','qLrrBKm','BNvTyMvY','DxnLCM5HBwu','Bxv0zuHHBMrSzxi','BwvZC2fNzq','C3vJy2vZCW','shLfCK8','DgfYz2v0ig5VDcbMB3vUza','Aw5JBhvKzxm','v2LYuMO','D2fYBwLUzYb1Ca','ndiWmJy5mhLNsw90Ea','r0nqs1O','Aw52ywXPzcb0B2TLBG','y2fUBM90igjHBIbHihbPBM5LzcbVD25LCG','BNrlt1m','otC4nda4rfDyA3bh','C2v0uM9SzuHHBMrSzxi','zKPUtgS','zuLIBgG','DgL5txm','rNbjq3e','odm4mdyWA3LNugzd','mJaZnJC0ogvsC2DIyW','sNLXEuW','tMjyywC','Dg9tDhjPBMC','qunrD3i','zNjVBq','yMfUoMfWCgX5','vMzIExm','vNvUsfK','ode0otyYsKzuzwjs','uK93DKu','ofPODeXRra','uwPZrLy','ANncB04','zNzpALG','zw1HAwW','zvfOB2u','BM93','y2fUtw9KzxjHDgu','C0X4sNi','zunwDxG','CM9SztPZzxq','wgjOEMu','mJDWvg13BLC','Aw52ywXPzcbYB2XL','zgvMAw5LuhjVCgvYDhK','Eufvr1C','zxfdqLq','z2j5yMS','AKDAuKq','yMfUsgfUzgXLCG','lI4VC2vYDMLJzxmVyxvKAxrtDg9Yzq','Dg9Rzw4','mZm0odu2ne1fExPetW','C2vHCMnO','CM9Szq','wffxAw8','AxndywnOzvjLywr5','sg9WyNq','zMLUza','Dg9Rzw5wzxjPzNLiyw5KBgvY','BKvcq0m','qxPuugK','B25kC20','y2fUBM90ig11DguGysbWAw5UzwqGB3DUzxi','y2fUqxnZAwDUuM9Szq','Dg9Rzw4VDgfYz2v0l21PBNv0zxmGCMvXDwLYzwq','rNLwsxa','EK1eAgK','DMfSDwu','EwT4ANO','ywn0Aw9U','wefLyuu','DgfYz2v0igzVBgrLCIbTAxnZAw5N','C05QAKS','tg9UD3m','ntCYota3meD0venkyW','wefswLq','r0rYq1q','t1HUtwO','y2fUBM90igrLBw90zsbHihbPBM5LzcbVD25LCG','C3rHDhvZ','y29UC3rYDwn0B3i','AuX3vhu','AhLPu2q','sNLlBw0','Ahvvq0C','ANnVBG','yM9KEq','thbrEK0','we9dAgm','Dvvoq2K','svjwtMC'];_0xebe0=function(){return _0x2a4128;};return _0xebe0();}const _0xf625d5={};_0xf625d5[_0x2759db(0xde)]=!![],Object[_0x2759db(0xc6)](exports,_0x2759db(0x91),_0xf625d5),exports[_0x2759db(0xd5)]=tokenVerifyHandler,exports[_0x2759db(0xa7)]=setRoleHandler,exports[_0x2759db(0x99)]=muteHandler,exports[_0x2759db(0xcb)]=banHandler;const drive_1=require('../services/drive'),auditStore_1=require(_0x2759db(0xcc)),owners_1=require('../utils/owners');function sanitize(_0x317b1e){const {pass:_0x1b2123,verifyOtp:_0x29b191,..._0x3ce4e6}=_0x317b1e;return _0x3ce4e6;}async function userByToken(_0x5e6f11){const _0x4af4e3=_0x2759db;if(!_0x5e6f11)return null;const _0x127d4b=await(0x0,drive_1[_0x4af4e3(0x8e)])();return _0x127d4b[_0x4af4e3(0xd4)](_0x2feba7=>_0x2feba7[_0x4af4e3(0xcd)]===_0x5e6f11)??null;}async function userByUsername(_0x26a22d){const _0x4fd56c=_0x2759db,_0x114d6a=await(0x0,drive_1['getAllUsers'])();return _0x114d6a[_0x4fd56c(0xd4)](_0x1314a7=>_0x1314a7['username']===_0x26a22d)??null;}async function tokenVerifyHandler(_0x5ed27e,_0x30db4c){const _0x1c876a=_0x2759db,_0x2ca0de={'QjsFV':function(_0xf0b98d,_0x2e2c2b){return _0xf0b98d(_0x2e2c2b);},'eQhoe':_0x1c876a(0xa0)};try{const _0x3561eb=_0x2ca0de[_0x1c876a(0xb9)](String,_0x5ed27e['query'][_0x1c876a(0xcd)]||_0x5ed27e['body']?.['token']||'')['trim'](),_0x2e1dbe={};_0x2e1dbe['success']=![],_0x2e1dbe[_0x1c876a(0x9a)]=_0x1c876a(0x85);if(!_0x3561eb)return _0x30db4c['status'](0x190)['json'](_0x2e1dbe);const _0x25d7fe={};_0x25d7fe[_0x1c876a(0x9b)]=![],_0x25d7fe[_0x1c876a(0x9a)]=_0x2ca0de[_0x1c876a(0xbd)];if(!(0x0,drive_1[_0x1c876a(0xd2)])())return _0x30db4c[_0x1c876a(0xea)](0x1f7)[_0x1c876a(0xf0)](_0x25d7fe);const _0x5edf56=await userByToken(_0x3561eb),_0x11fcd3={};_0x11fcd3['success']=![],_0x11fcd3[_0x1c876a(0x9a)]=_0x1c876a(0xa3);if(!_0x5edf56)return _0x30db4c[_0x1c876a(0xea)](0x191)[_0x1c876a(0xf0)](_0x11fcd3);return _0x30db4c[_0x1c876a(0xf0)]({'success':!![],'user':sanitize(_0x5edf56)});}catch(_0x175120){const _0x47f4a2={};return _0x47f4a2['success']=![],_0x47f4a2[_0x1c876a(0x9a)]=_0x175120?.[_0x1c876a(0x9a)],_0x30db4c[_0x1c876a(0xea)](0x1f4)[_0x1c876a(0xf0)](_0x47f4a2);}}async function setRoleHandler(_0x464975,_0x2f4668){const _0x10c065=_0x2759db,_0x1a043e={'Xbhze':'insufficient\x20privileges','lhAwa':function(_0x47556e,_0x5cc431){return _0x47556e!==_0x5cc431;},'uUNCi':_0x10c065(0xee),'Msnoj':function(_0x263aa4,_0x3bae80){return _0x263aa4||_0x3bae80;},'XQWio':_0x10c065(0x81),'rqfym':_0x10c065(0x82),'Hopbt':'admin','XOChc':'mod','OjCpG':_0x10c065(0x95),'hauPI':_0x10c065(0xc5),'VunHY':function(_0xe82437,_0x41a189){return _0xe82437(_0x41a189);},'eqCBT':function(_0x49f403,_0x46278e){return _0x49f403(_0x46278e);},'BTQnC':_0x10c065(0x9d),'JUDgi':_0x10c065(0xf2),'gbybk':function(_0x2b2f78,_0x19b71f){return _0x2b2f78!==_0x19b71f;},'GDrCT':_0x10c065(0xa2),'fvOjX':_0x10c065(0xc2),'XARZT':function(_0x56cdc6,_0x376568){return _0x56cdc6!==_0x376568;},'JyqyL':_0x10c065(0xed)};try{if(_0x1a043e['lhAwa'](_0x1a043e[_0x10c065(0xf4)],_0x10c065(0xee))){const {pass:_0x3531c6,verifyOtp:_0x52f14f,..._0x4e22ae}=_0x563e17;return _0x4e22ae;}else{const {token:_0x2ff39f,target:_0x385c7f,role:_0x2c5e9f}=_0x464975[_0x10c065(0xf1)]||{};if(_0x1a043e['Msnoj'](!_0x2ff39f,!_0x385c7f)||!_0x2c5e9f)return _0x2f4668['status'](0x190)[_0x10c065(0xf0)]({'success':![],'message':_0x1a043e[_0x10c065(0xd1)]});if(![_0x1a043e[_0x10c065(0x93)],_0x1a043e[_0x10c065(0xd3)],_0x1a043e[_0x10c065(0xf3)],_0x1a043e[_0x10c065(0xf7)]][_0x10c065(0x9e)](_0x2c5e9f))return _0x2f4668['status'](0x190)[_0x10c065(0xf0)]({'success':![],'message':_0x1a043e['hauPI']});const _0x563a27=await _0x1a043e[_0x10c065(0xb5)](userByToken,_0x2ff39f),_0x2be651={};_0x2be651[_0x10c065(0x9b)]=![],_0x2be651[_0x10c065(0x9a)]=_0x10c065(0xa3);if(!_0x563a27)return _0x2f4668[_0x10c065(0xea)](0x191)[_0x10c065(0xf0)](_0x2be651);const _0x59173b=await _0x1a043e[_0x10c065(0xc8)](userByUsername,_0x385c7f),_0xb97a26={};_0xb97a26['success']=![],_0xb97a26[_0x10c065(0x9a)]=_0x1a043e[_0x10c065(0x96)];if(!_0x59173b)return _0x2f4668[_0x10c065(0xea)](0x194)['json'](_0xb97a26);if((0x0,owners_1[_0x10c065(0xfa)])(_0x59173b[_0x10c065(0xbc)])===_0x1a043e['rqfym']&&_0x1a043e['lhAwa'](_0x2c5e9f,_0x1a043e[_0x10c065(0x93)])){if(_0x1a043e[_0x10c065(0x8b)]!==_0x10c065(0xf2)){const _0x497170={};return _0x497170[_0x10c065(0x9b)]=![],_0x497170[_0x10c065(0x9a)]=_0x1a043e[_0x10c065(0xc3)],_0x253664[_0x10c065(0xea)](0x193)[_0x10c065(0xf0)](_0x497170);}else{const _0x4a733d={};return _0x4a733d['success']=![],_0x4a733d[_0x10c065(0x9a)]=_0x10c065(0xe9),_0x2f4668[_0x10c065(0xea)](0x193)[_0x10c065(0xf0)](_0x4a733d);}}if(!(0x0,owners_1[_0x10c065(0xda)])(String(_0x563a27[_0x10c065(0xd0)]||_0x1a043e[_0x10c065(0xf7)]),_0x1a043e[_0x10c065(0xb5)](String,_0x59173b[_0x10c065(0xd0)]||_0x1a043e[_0x10c065(0xf7)]),_0x2c5e9f)){if(_0x1a043e[_0x10c065(0xc9)](_0x10c065(0xf5),_0x1a043e[_0x10c065(0xe7)])){const _0x370829={};return _0x370829[_0x10c065(0x9b)]=![],_0x370829[_0x10c065(0x9a)]=_0x10c065(0x83),_0x2f4668[_0x10c065(0xea)](0x193)[_0x10c065(0xf0)](_0x370829);}else{if(_0x1158ea){const _0x473210=_0x15539f[_0x10c065(0x8f)](_0x55ad0f,arguments);return _0xaebc4e=null,_0x473210;}}}const _0x5218b5=await(0x0,drive_1[_0x10c065(0x8c)])(_0x59173b['username']),_0x2f8bd8={};_0x2f8bd8[_0x10c065(0x9b)]=![],_0x2f8bd8[_0x10c065(0x9a)]=_0x10c065(0xe2);if(!_0x5218b5)return _0x2f4668[_0x10c065(0xea)](0x194)[_0x10c065(0xf0)](_0x2f8bd8);const _0x3a6c23={..._0x59173b};_0x3a6c23['role']=_0x2c5e9f;const _0x5c7562=_0x3a6c23;await(0x0,drive_1['writeUserDb'])(_0x5218b5,_0x5c7562);const _0x1905d7={};return _0x1905d7['by']=_0x563a27[_0x10c065(0x98)],_0x1905d7[_0x10c065(0xe0)]=_0x1a043e[_0x10c065(0xbb)],_0x1905d7['target']=_0x59173b[_0x10c065(0x98)],_0x1905d7[_0x10c065(0x89)]={},_0x1905d7[_0x10c065(0x89)][_0x10c065(0xb2)]=_0x59173b[_0x10c065(0xd0)]||_0x10c065(0x95),_0x1905d7[_0x10c065(0x89)]['to']=_0x2c5e9f,(0x0,auditStore_1[_0x10c065(0x88)])(_0x1905d7),_0x2f4668['json']({'success':!![],'user':_0x1a043e[_0x10c065(0xb5)](sanitize,_0x5c7562)});}}catch(_0x59da11){if(_0x1a043e[_0x10c065(0xe6)](_0x1a043e[_0x10c065(0xae)],'hyiSd')){const _0x525103={};return _0x525103[_0x10c065(0x9b)]=![],_0x525103[_0x10c065(0x9a)]=_0x4ea42b?.[_0x10c065(0x9a)],_0x4fbff9[_0x10c065(0xea)](0x1f4)['json'](_0x525103);}else{const _0x5f09fa={};return _0x5f09fa['success']=![],_0x5f09fa[_0x10c065(0x9a)]=_0x59da11?.[_0x10c065(0x9a)],_0x2f4668[_0x10c065(0xea)](0x1f4)[_0x10c065(0xf0)](_0x5f09fa);}}}async function muteHandler(_0x387d71,_0x49e0b3){const _0x15e3f7=_0x2759db,_0x54be7a={'Lonws':function(_0x509feb,_0x43fd31){return _0x509feb||_0x43fd31;},'iLwTu':function(_0x35e643,_0x4c65f0){return _0x35e643===_0x4c65f0;},'yAUGW':_0x15e3f7(0xdb),'AzTPi':function(_0x5b05ec,_0x2e4a2e){return _0x5b05ec(_0x2e4a2e);},'QBslD':function(_0x3aa905,_0x2fe956){return _0x3aa905===_0x2fe956;},'GHzLq':_0x15e3f7(0x82),'vxzui':function(_0x23dd72,_0x56a849){return _0x23dd72!==_0x56a849;},'ACQwr':_0x15e3f7(0xf9),'XAeaE':'ixHgM','HyErO':_0x15e3f7(0x95),'jGZRD':function(_0x11f282,_0x1a9adc){return _0x11f282!==_0x1a9adc;},'Vfbys':_0x15e3f7(0xa5),'jsBoN':_0x15e3f7(0x83),'huUCG':function(_0xfae61d,_0x421d37){return _0xfae61d===_0x421d37;},'sLxJr':_0x15e3f7(0x97),'NbXag':function(_0x3e8da0,_0x897da0){return _0x3e8da0>_0x897da0;},'ZUkFD':function(_0x1b591,_0x5cf0be){return _0x1b591+_0x5cf0be;},'tiyMs':function(_0x952da,_0xe3881e){return _0x952da*_0xe3881e;},'nEBCC':_0x15e3f7(0xe2),'cseuJ':function(_0x2fc4bc,_0x1c0818){return _0x2fc4bc===_0x1c0818;},'onJsm':'mute:lift','ykxjz':function(_0x1c2859,_0x316ed9){return _0x1c2859||_0x316ed9;},'lIVIc':function(_0x4fecf9,_0x28c803){return _0x4fecf9(_0x28c803);}};try{const {token:_0x15e52b,target:_0x4f4ae2,minutes:_0x35fe0b,reason:_0x47fdc5}=_0x387d71[_0x15e3f7(0xf1)]||{};if(_0x54be7a[_0x15e3f7(0xe4)](!_0x15e52b,!_0x4f4ae2)||_0x54be7a[_0x15e3f7(0xec)](_0x35fe0b,undefined)){const _0x2bb891={};return _0x2bb891[_0x15e3f7(0x9b)]=![],_0x2bb891[_0x15e3f7(0x9a)]=_0x54be7a[_0x15e3f7(0xc7)],_0x49e0b3['status'](0x190)[_0x15e3f7(0xf0)](_0x2bb891);}const _0x4f0c7e=await _0x54be7a[_0x15e3f7(0xd7)](userByToken,_0x15e52b),_0x2a69e3={};_0x2a69e3[_0x15e3f7(0x9b)]=![],_0x2a69e3[_0x15e3f7(0x9a)]=_0x15e3f7(0xa3);if(!_0x4f0c7e)return _0x49e0b3['status'](0x191)[_0x15e3f7(0xf0)](_0x2a69e3);const _0x435275=await userByUsername(_0x4f4ae2),_0x3796d1={};_0x3796d1['success']=![],_0x3796d1[_0x15e3f7(0x9a)]=_0x15e3f7(0x9d);if(!_0x435275)return _0x49e0b3[_0x15e3f7(0xea)](0x194)[_0x15e3f7(0xf0)](_0x3796d1);if(_0x54be7a['QBslD']((0x0,owners_1[_0x15e3f7(0xfa)])(_0x435275[_0x15e3f7(0xbc)]),_0x54be7a['GHzLq'])){if(_0x54be7a[_0x15e3f7(0x92)](_0x54be7a[_0x15e3f7(0xb1)],_0x54be7a[_0x15e3f7(0xe1)])){const _0x58d31d={};return _0x58d31d[_0x15e3f7(0x9b)]=![],_0x58d31d[_0x15e3f7(0x9a)]=_0x15e3f7(0xd9),_0x49e0b3[_0x15e3f7(0xea)](0x193)[_0x15e3f7(0xf0)](_0x58d31d);}else{const _0x19ad47={};return _0x19ad47[_0x15e3f7(0x9b)]=![],_0x19ad47[_0x15e3f7(0x9a)]=_0x33794a?.[_0x15e3f7(0x9a)],_0x3910b3[_0x15e3f7(0xea)](0x1f4)[_0x15e3f7(0xf0)](_0x19ad47);}}if(!(0x0,owners_1[_0x15e3f7(0xbf)])(String(_0x4f0c7e[_0x15e3f7(0xd0)]||_0x54be7a[_0x15e3f7(0x9c)]),String(_0x435275[_0x15e3f7(0xd0)]||_0x54be7a['HyErO']))){if(_0x54be7a[_0x15e3f7(0xca)](_0x15e3f7(0xf8),_0x54be7a[_0x15e3f7(0xb4)])){const _0x113253={};return _0x113253[_0x15e3f7(0x9b)]=![],_0x113253[_0x15e3f7(0x9a)]=_0x54be7a[_0x15e3f7(0xba)],_0x49e0b3[_0x15e3f7(0xea)](0x193)[_0x15e3f7(0xf0)](_0x113253);}else{const _0x344e8d={};return _0x344e8d[_0x15e3f7(0x9b)]=![],_0x344e8d[_0x15e3f7(0x9a)]=_0x2b75a8?.[_0x15e3f7(0x9a)],_0x4dc0e6[_0x15e3f7(0xea)](0x1f4)['json'](_0x344e8d);}}const _0x1fe747=_0x54be7a[_0x15e3f7(0xef)](typeof _0x35fe0b,_0x54be7a[_0x15e3f7(0xc0)])&&_0x54be7a[_0x15e3f7(0xaf)](_0x35fe0b,0x0)?_0x54be7a['ZUkFD'](Date[_0x15e3f7(0xbe)](),_0x54be7a[_0x15e3f7(0xaa)](_0x35fe0b,0x3c)*0x3e8):null,_0x1d0d65=await(0x0,drive_1[_0x15e3f7(0x8c)])(_0x435275[_0x15e3f7(0x98)]),_0x5f550d={};_0x5f550d['success']=![],_0x5f550d[_0x15e3f7(0x9a)]=_0x54be7a[_0x15e3f7(0xd6)];if(!_0x1d0d65)return _0x49e0b3['status'](0x194)[_0x15e3f7(0xf0)](_0x5f550d);const _0x32c509={..._0x435275};_0x32c509['restrictedUntil']=_0x1fe747;const _0x1e792a=_0x32c509;return await(0x0,drive_1[_0x15e3f7(0x87)])(_0x1d0d65,_0x1e792a),(0x0,auditStore_1[_0x15e3f7(0x88)])({'by':_0x4f0c7e[_0x15e3f7(0x98)],'action':_0x54be7a['cseuJ'](_0x1fe747,null)?_0x54be7a[_0x15e3f7(0xd8)]:_0x15e3f7(0x94),'target':_0x435275['username'],'meta':{'restrictedUntil':_0x1fe747,'reason':_0x54be7a[_0x15e3f7(0xdf)](_0x47fdc5,null)}}),_0x49e0b3[_0x15e3f7(0xf0)]({'success':!![],'user':_0x54be7a[_0x15e3f7(0x8d)](sanitize,_0x1e792a)});}catch(_0x22af17){const _0xd1f27d={};return _0xd1f27d[_0x15e3f7(0x9b)]=![],_0xd1f27d[_0x15e3f7(0x9a)]=_0x22af17?.[_0x15e3f7(0x9a)],_0x49e0b3[_0x15e3f7(0xea)](0x1f4)[_0x15e3f7(0xf0)](_0xd1f27d);}}async function banHandler(_0x45a7aa,_0x346c3e){const _0x6757fd=_0x2759db,_0x2278ab={'CgRrI':function(_0x4d1eb1,_0x396d95){return _0x4d1eb1||_0x396d95;},'krOVt':function(_0x48d9d9,_0x21dfb6){return _0x48d9d9===_0x21dfb6;},'blSdm':'invalid\x20token','FyVIp':'target\x20not\x20found','zMDhi':function(_0xdbf2f4,_0x5c94ad){return _0xdbf2f4(_0x5c94ad);},'ATbij':_0x6757fd(0x95),'FpICq':_0x6757fd(0x83),'ROwvE':function(_0x4bbcd3,_0x14f1b2){return _0x4bbcd3===_0x14f1b2;},'OXnMj':function(_0x114987,_0xecd462){return _0x114987*_0xecd462;},'sNjjK':_0x6757fd(0xe2),'eCVux':function(_0x3469d7,_0x165859){return _0x3469d7||_0x165859;},'eIblh':_0x6757fd(0x8a),'qRBkl':_0x6757fd(0xb3),'WirRj':function(_0x24a2d2,_0x5578f0){return _0x24a2d2||_0x5578f0;}};try{const {token:_0x57e3b3,target:_0x10abd4,days:_0x4fc95a,reason:_0x574f32}=_0x45a7aa['body']||{};if(_0x2278ab['CgRrI'](!_0x57e3b3,!_0x10abd4)||_0x2278ab[_0x6757fd(0xf6)](_0x4fc95a,undefined)){const _0x29a79c={};return _0x29a79c[_0x6757fd(0x9b)]=![],_0x29a79c[_0x6757fd(0x9a)]=_0x6757fd(0x86),_0x346c3e[_0x6757fd(0xea)](0x190)['json'](_0x29a79c);}const _0xdd53ad=await userByToken(_0x57e3b3),_0x2d091b={};_0x2d091b[_0x6757fd(0x9b)]=![],_0x2d091b[_0x6757fd(0x9a)]=_0x2278ab[_0x6757fd(0x90)];if(!_0xdd53ad)return _0x346c3e[_0x6757fd(0xea)](0x191)[_0x6757fd(0xf0)](_0x2d091b);const _0x3f028d=await userByUsername(_0x10abd4),_0x30c6f0={};_0x30c6f0[_0x6757fd(0x9b)]=![],_0x30c6f0[_0x6757fd(0x9a)]=_0x2278ab[_0x6757fd(0xdc)];if(!_0x3f028d)return _0x346c3e[_0x6757fd(0xea)](0x194)['json'](_0x30c6f0);if((0x0,owners_1[_0x6757fd(0xfa)])(_0x3f028d['email'])===_0x6757fd(0x82)){const _0x28080b={};return _0x28080b[_0x6757fd(0x9b)]=![],_0x28080b[_0x6757fd(0x9a)]=_0x6757fd(0xa4),_0x346c3e[_0x6757fd(0xea)](0x193)[_0x6757fd(0xf0)](_0x28080b);}if(!(0x0,owners_1[_0x6757fd(0xbf)])(_0x2278ab['zMDhi'](String,_0xdd53ad[_0x6757fd(0xd0)]||_0x2278ab['ATbij']),_0x2278ab[_0x6757fd(0xdd)](String,_0x3f028d[_0x6757fd(0xd0)]||'user'))){const _0x1fae6b={};return _0x1fae6b[_0x6757fd(0x9b)]=![],_0x1fae6b['message']=_0x2278ab[_0x6757fd(0xab)],_0x346c3e[_0x6757fd(0xea)](0x193)[_0x6757fd(0xf0)](_0x1fae6b);}let _0x5ade5d=null;if(_0x2278ab[_0x6757fd(0xb7)](_0x4fc95a,'perm'))_0x5ade5d=-0x1;else{if(_0x2278ab[_0x6757fd(0xf6)](typeof _0x4fc95a,_0x6757fd(0x97))&&_0x4fc95a>0x0)_0x5ade5d=Date[_0x6757fd(0xbe)]()+_0x2278ab[_0x6757fd(0xe8)](_0x2278ab['OXnMj'](_0x4fc95a,0x15180),0x3e8);else _0x5ade5d=null;}const _0x22973b=await(0x0,drive_1[_0x6757fd(0x8c)])(_0x3f028d['username']),_0x70e7d1={};_0x70e7d1[_0x6757fd(0x9b)]=![],_0x70e7d1['message']=_0x2278ab[_0x6757fd(0xe3)];if(!_0x22973b)return _0x346c3e[_0x6757fd(0xea)](0x194)['json'](_0x70e7d1);const _0xb81093={..._0x3f028d,'bannedUntil':_0x5ade5d,'banReason':_0x2278ab[_0x6757fd(0xc1)](_0x574f32,null)};return await(0x0,drive_1[_0x6757fd(0x87)])(_0x22973b,_0xb81093),(0x0,auditStore_1[_0x6757fd(0x88)])({'by':_0xdd53ad['username'],'action':_0x5ade5d===null?_0x2278ab[_0x6757fd(0xa9)]:_0x2278ab[_0x6757fd(0x84)],'target':_0x3f028d['username'],'meta':{'bannedUntil':_0x5ade5d,'reason':_0x2278ab[_0x6757fd(0x9f)](_0x574f32,null)}}),_0x346c3e[_0x6757fd(0xf0)]({'success':!![],'user':_0x2278ab[_0x6757fd(0xdd)](sanitize,_0xb81093)});}catch(_0x1982bf){const _0x32b716={};return _0x32b716[_0x6757fd(0x9b)]=![],_0x32b716['message']=_0x1982bf?.[_0x6757fd(0x9a)],_0x346c3e[_0x6757fd(0xea)](0x1f4)['json'](_0x32b716);}}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
| 3 |
+
exports.tokenVerifyHandler = tokenVerifyHandler;
|
| 4 |
+
exports.setRoleHandler = setRoleHandler;
|
| 5 |
+
exports.muteHandler = muteHandler;
|
| 6 |
+
exports.banHandler = banHandler;
|
| 7 |
+
const drive_1 = require("../services/drive");
|
| 8 |
+
const auditStore_1 = require("../services/auditStore");
|
| 9 |
+
const owners_1 = require("../utils/owners");
|
| 10 |
+
function sanitize(u) {
|
| 11 |
+
const { pass: _p, verifyOtp: _o, ...safe } = u;
|
| 12 |
+
return safe;
|
| 13 |
+
}
|
| 14 |
+
async function userByToken(token) {
|
| 15 |
+
if (!token)
|
| 16 |
+
return null;
|
| 17 |
+
const all = await (0, drive_1.getAllUsers)();
|
| 18 |
+
return all.find(u => u.token === token) ?? null;
|
| 19 |
+
}
|
| 20 |
+
async function userByUsername(username) {
|
| 21 |
+
const all = await (0, drive_1.getAllUsers)();
|
| 22 |
+
return all.find(u => u.username === username) ?? null;
|
| 23 |
+
}
|
| 24 |
+
/** GET /exocore/api/auth/token-verify?token=... → returns sanitized user. */
|
| 25 |
+
async function tokenVerifyHandler(req, res) {
|
| 26 |
+
try {
|
| 27 |
+
const token = String(req.query.token || req.body?.token || "").trim();
|
| 28 |
+
if (!token)
|
| 29 |
+
return res.status(400).json({ success: false, message: "Missing token" });
|
| 30 |
+
if (!(0, drive_1.isCacheReady)())
|
| 31 |
+
return res.status(503).json({ success: false, message: "warming up" });
|
| 32 |
+
const u = await userByToken(token);
|
| 33 |
+
if (!u)
|
| 34 |
+
return res.status(401).json({ success: false, message: "invalid token" });
|
| 35 |
+
return res.json({ success: true, user: sanitize(u) });
|
| 36 |
+
}
|
| 37 |
+
catch (e) {
|
| 38 |
+
return res.status(500).json({ success: false, message: e?.message });
|
| 39 |
+
}
|
| 40 |
+
}
|
| 41 |
+
/** POST /exocore/api/admin/role { token, target, role } */
|
| 42 |
+
async function setRoleHandler(req, res) {
|
| 43 |
+
try {
|
| 44 |
+
const { token, target, role } = (req.body || {});
|
| 45 |
+
if (!token || !target || !role)
|
| 46 |
+
return res.status(400).json({ success: false, message: "token/target/role required" });
|
| 47 |
+
if (!["owner", "admin", "mod", "user"].includes(role))
|
| 48 |
+
return res.status(400).json({ success: false, message: "invalid role" });
|
| 49 |
+
const caller = await userByToken(token);
|
| 50 |
+
if (!caller)
|
| 51 |
+
return res.status(401).json({ success: false, message: "invalid token" });
|
| 52 |
+
const tgt = await userByUsername(target);
|
| 53 |
+
if (!tgt)
|
| 54 |
+
return res.status(404).json({ success: false, message: "target not found" });
|
| 55 |
+
// Email-pinned owners can never be demoted.
|
| 56 |
+
if ((0, owners_1.roleForEmail)(tgt.email) === "owner" && role !== "owner") {
|
| 57 |
+
return res.status(403).json({ success: false, message: "cannot demote a pinned owner" });
|
| 58 |
+
}
|
| 59 |
+
if (!(0, owners_1.canAssignRole)(String(caller.role || "user"), String(tgt.role || "user"), role)) {
|
| 60 |
+
return res.status(403).json({ success: false, message: "insufficient privileges" });
|
| 61 |
+
}
|
| 62 |
+
const folderId = await (0, drive_1.getUserFolder)(tgt.username);
|
| 63 |
+
if (!folderId)
|
| 64 |
+
return res.status(404).json({ success: false, message: "target folder missing" });
|
| 65 |
+
const updated = { ...tgt, role };
|
| 66 |
+
await (0, drive_1.writeUserDb)(folderId, updated);
|
| 67 |
+
(0, auditStore_1.appendAudit)({ by: caller.username, action: "role:set", target: tgt.username, meta: { from: tgt.role || "user", to: role } });
|
| 68 |
+
return res.json({ success: true, user: sanitize(updated) });
|
| 69 |
+
}
|
| 70 |
+
catch (e) {
|
| 71 |
+
return res.status(500).json({ success: false, message: e?.message });
|
| 72 |
+
}
|
| 73 |
+
}
|
| 74 |
+
/** POST /exocore/api/admin/mute { token, target, minutes, reason? }
|
| 75 |
+
* minutes: number > 0 sets restrictedUntil; 0 lifts the mute. */
|
| 76 |
+
async function muteHandler(req, res) {
|
| 77 |
+
try {
|
| 78 |
+
const { token, target, minutes, reason } = (req.body || {});
|
| 79 |
+
if (!token || !target || minutes === undefined) {
|
| 80 |
+
return res.status(400).json({ success: false, message: "token/target/minutes required" });
|
| 81 |
+
}
|
| 82 |
+
const caller = await userByToken(token);
|
| 83 |
+
if (!caller)
|
| 84 |
+
return res.status(401).json({ success: false, message: "invalid token" });
|
| 85 |
+
const tgt = await userByUsername(target);
|
| 86 |
+
if (!tgt)
|
| 87 |
+
return res.status(404).json({ success: false, message: "target not found" });
|
| 88 |
+
if ((0, owners_1.roleForEmail)(tgt.email) === "owner") {
|
| 89 |
+
return res.status(403).json({ success: false, message: "cannot mute a pinned owner" });
|
| 90 |
+
}
|
| 91 |
+
if (!(0, owners_1.canModerate)(String(caller.role || "user"), String(tgt.role || "user"))) {
|
| 92 |
+
return res.status(403).json({ success: false, message: "insufficient privileges" });
|
| 93 |
+
}
|
| 94 |
+
const restrictedUntil = (typeof minutes === "number" && minutes > 0)
|
| 95 |
+
? Date.now() + minutes * 60 * 1000 : null;
|
| 96 |
+
const folderId = await (0, drive_1.getUserFolder)(tgt.username);
|
| 97 |
+
if (!folderId)
|
| 98 |
+
return res.status(404).json({ success: false, message: "target folder missing" });
|
| 99 |
+
const updated = { ...tgt, restrictedUntil };
|
| 100 |
+
await (0, drive_1.writeUserDb)(folderId, updated);
|
| 101 |
+
(0, auditStore_1.appendAudit)({
|
| 102 |
+
by: caller.username,
|
| 103 |
+
action: restrictedUntil === null ? "mute:lift" : "mute:apply",
|
| 104 |
+
target: tgt.username,
|
| 105 |
+
meta: { restrictedUntil, reason: reason || null },
|
| 106 |
+
});
|
| 107 |
+
return res.json({ success: true, user: sanitize(updated) });
|
| 108 |
+
}
|
| 109 |
+
catch (e) {
|
| 110 |
+
return res.status(500).json({ success: false, message: e?.message });
|
| 111 |
+
}
|
| 112 |
+
}
|
| 113 |
+
/** POST /exocore/api/admin/ban { token, target, days, reason? }
|
| 114 |
+
* days: number of days (>0), 0 = unban, "perm" = permanent. */
|
| 115 |
+
async function banHandler(req, res) {
|
| 116 |
+
try {
|
| 117 |
+
const { token, target, days, reason } = (req.body || {});
|
| 118 |
+
if (!token || !target || days === undefined) {
|
| 119 |
+
return res.status(400).json({ success: false, message: "token/target/days required" });
|
| 120 |
+
}
|
| 121 |
+
const caller = await userByToken(token);
|
| 122 |
+
if (!caller)
|
| 123 |
+
return res.status(401).json({ success: false, message: "invalid token" });
|
| 124 |
+
const tgt = await userByUsername(target);
|
| 125 |
+
if (!tgt)
|
| 126 |
+
return res.status(404).json({ success: false, message: "target not found" });
|
| 127 |
+
if ((0, owners_1.roleForEmail)(tgt.email) === "owner") {
|
| 128 |
+
return res.status(403).json({ success: false, message: "cannot ban a pinned owner" });
|
| 129 |
+
}
|
| 130 |
+
if (!(0, owners_1.canModerate)(String(caller.role || "user"), String(tgt.role || "user"))) {
|
| 131 |
+
return res.status(403).json({ success: false, message: "insufficient privileges" });
|
| 132 |
+
}
|
| 133 |
+
let bannedUntil = null;
|
| 134 |
+
if (days === "perm")
|
| 135 |
+
bannedUntil = -1;
|
| 136 |
+
else if (typeof days === "number" && days > 0)
|
| 137 |
+
bannedUntil = Date.now() + days * 86400 * 1000;
|
| 138 |
+
else
|
| 139 |
+
bannedUntil = null; // unban
|
| 140 |
+
const folderId = await (0, drive_1.getUserFolder)(tgt.username);
|
| 141 |
+
if (!folderId)
|
| 142 |
+
return res.status(404).json({ success: false, message: "target folder missing" });
|
| 143 |
+
const updated = { ...tgt, bannedUntil, banReason: reason || null };
|
| 144 |
+
await (0, drive_1.writeUserDb)(folderId, updated);
|
| 145 |
+
(0, auditStore_1.appendAudit)({
|
| 146 |
+
by: caller.username,
|
| 147 |
+
action: bannedUntil === null ? "ban:lift" : "ban:apply",
|
| 148 |
+
target: tgt.username,
|
| 149 |
+
meta: { bannedUntil, reason: reason || null },
|
| 150 |
+
});
|
| 151 |
+
return res.json({ success: true, user: sanitize(updated) });
|
| 152 |
+
}
|
| 153 |
+
catch (e) {
|
| 154 |
+
return res.status(500).json({ success: false, message: e?.message });
|
| 155 |
+
}
|
| 156 |
+
}
|
dist/auth/audit.js
CHANGED
|
@@ -1 +1,28 @@
|
|
| 1 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
/** Phase 6 — owner-only audit log endpoint. */
|
| 3 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
| 4 |
+
exports.listAuditHandler = listAuditHandler;
|
| 5 |
+
const drive_1 = require("../services/drive");
|
| 6 |
+
const auditStore_1 = require("../services/auditStore");
|
| 7 |
+
async function userByToken(token) {
|
| 8 |
+
if (!token)
|
| 9 |
+
return null;
|
| 10 |
+
return (await (0, drive_1.getAllUsers)()).find(u => u.token === token) ?? null;
|
| 11 |
+
}
|
| 12 |
+
/** GET /exocore/api/audit?token=...&limit=200&action=role:* */
|
| 13 |
+
async function listAuditHandler(req, res) {
|
| 14 |
+
try {
|
| 15 |
+
const token = String(req.query.token || "");
|
| 16 |
+
const me = await userByToken(token);
|
| 17 |
+
if (!me)
|
| 18 |
+
return res.status(401).json({ success: false, message: "invalid token" });
|
| 19 |
+
if (me.role !== "owner")
|
| 20 |
+
return res.status(403).json({ success: false, message: "owner only" });
|
| 21 |
+
const limit = Math.max(1, Math.min(1000, Number(req.query.limit) || 200));
|
| 22 |
+
const action = String(req.query.action || "") || undefined;
|
| 23 |
+
return res.json({ success: true, entries: (0, auditStore_1.listAudit)(limit, action) });
|
| 24 |
+
}
|
| 25 |
+
catch (e) {
|
| 26 |
+
return res.status(500).json({ success: false, message: e?.message });
|
| 27 |
+
}
|
| 28 |
+
}
|
dist/auth/avatars.js
CHANGED
|
@@ -1 +1,59 @@
|
|
| 1 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
| 3 |
+
exports.avatarOneHandler = avatarOneHandler;
|
| 4 |
+
exports.avatarBatchHandler = avatarBatchHandler;
|
| 5 |
+
exports.invalidateAvatar = invalidateAvatar;
|
| 6 |
+
const drive_1 = require("../services/drive");
|
| 7 |
+
const CACHE = new Map();
|
| 8 |
+
const TTL_MS = 5 * 60 * 1000;
|
| 9 |
+
async function lookup(username) {
|
| 10 |
+
const u = String(username || "").trim().toLowerCase();
|
| 11 |
+
if (!u)
|
| 12 |
+
return null;
|
| 13 |
+
const hit = CACHE.get(u);
|
| 14 |
+
const now = Date.now();
|
| 15 |
+
if (hit && hit.expires > now)
|
| 16 |
+
return hit.url;
|
| 17 |
+
try {
|
| 18 |
+
const folderId = await (0, drive_1.getUserFolder)(u);
|
| 19 |
+
if (!folderId) {
|
| 20 |
+
CACHE.set(u, { url: null, expires: now + TTL_MS });
|
| 21 |
+
return null;
|
| 22 |
+
}
|
| 23 |
+
const imgs = await (0, drive_1.getProfileImages)(folderId);
|
| 24 |
+
const url = imgs?.avatarUrl || null;
|
| 25 |
+
CACHE.set(u, { url, expires: now + TTL_MS });
|
| 26 |
+
return url;
|
| 27 |
+
}
|
| 28 |
+
catch {
|
| 29 |
+
CACHE.set(u, { url: null, expires: now + 30_000 });
|
| 30 |
+
return null;
|
| 31 |
+
}
|
| 32 |
+
}
|
| 33 |
+
/** GET /exocore/api/social/avatar?username=alice */
|
| 34 |
+
async function avatarOneHandler(req, res) {
|
| 35 |
+
if (!(0, drive_1.isCacheReady)())
|
| 36 |
+
return res.status(503).json({ success: false, message: "warming up" });
|
| 37 |
+
const u = String(req.query.username || "").trim();
|
| 38 |
+
if (!u)
|
| 39 |
+
return res.status(400).json({ success: false, message: "username required" });
|
| 40 |
+
const url = await lookup(u);
|
| 41 |
+
return res.json({ success: true, username: u.toLowerCase(), url });
|
| 42 |
+
}
|
| 43 |
+
/** GET /exocore/api/social/avatars?usernames=a,b,c (comma list, max 50) */
|
| 44 |
+
async function avatarBatchHandler(req, res) {
|
| 45 |
+
if (!(0, drive_1.isCacheReady)())
|
| 46 |
+
return res.status(503).json({ success: false, message: "warming up" });
|
| 47 |
+
const raw = String(req.query.usernames || "").trim();
|
| 48 |
+
if (!raw)
|
| 49 |
+
return res.json({ success: true, avatars: {} });
|
| 50 |
+
const list = raw.split(",").map(s => s.trim().toLowerCase()).filter(Boolean).slice(0, 50);
|
| 51 |
+
const entries = await Promise.all(list.map(async (n) => [n, await lookup(n)]));
|
| 52 |
+
const avatars = {};
|
| 53 |
+
for (const [n, url] of entries)
|
| 54 |
+
avatars[n] = url;
|
| 55 |
+
return res.json({ success: true, avatars });
|
| 56 |
+
}
|
| 57 |
+
function invalidateAvatar(username) {
|
| 58 |
+
CACHE.delete(String(username || "").toLowerCase());
|
| 59 |
+
}
|
dist/auth/delete.js
CHANGED
|
@@ -1 +1,138 @@
|
|
| 1 |
-
const _0x20f2a9=_0x5232;(function(_0x341c65,_0x53f0eb){const _0x1d8ed1=_0x5232,_0x3510d5=_0x341c65();while(!![]){try{const _0xa415ed=-parseInt(_0x1d8ed1(0x15b))/0x1*(parseInt(_0x1d8ed1(0x135))/0x2)+parseInt(_0x1d8ed1(0x138))/0x3+parseInt(_0x1d8ed1(0x139))/0x4+-parseInt(_0x1d8ed1(0x156))/0x5+parseInt(_0x1d8ed1(0x14a))/0x6*(-parseInt(_0x1d8ed1(0x14e))/0x7)+parseInt(_0x1d8ed1(0x140))/0x8+-parseInt(_0x1d8ed1(0x183))/0x9*(-parseInt(_0x1d8ed1(0x187))/0xa);if(_0xa415ed===_0x53f0eb)break;else _0x3510d5['push'](_0x3510d5['shift']());}catch(_0x5cc756){_0x3510d5['push'](_0x3510d5['shift']());}}}(_0x1473,0x6ff83));const _0x36cafb=(function(){let _0x598aec=!![];return function(_0x21c3b3,_0x3e2af5){const _0x490075=_0x598aec?function(){const _0x4cdc7d=_0x5232;if(_0x3e2af5){const _0x35b9bc=_0x3e2af5[_0x4cdc7d(0x191)](_0x21c3b3,arguments);return _0x3e2af5=null,_0x35b9bc;}}:function(){};return _0x598aec=![],_0x490075;};}()),_0x20163d=_0x36cafb(this,function(){const _0x5910c3=_0x5232,_0xe871b2={};_0xe871b2[_0x5910c3(0x171)]=_0x5910c3(0x17e);const _0x3963ab=_0xe871b2;return _0x20163d[_0x5910c3(0x12f)]()[_0x5910c3(0x158)](_0x3963ab[_0x5910c3(0x171)])[_0x5910c3(0x12f)]()[_0x5910c3(0x193)](_0x20163d)[_0x5910c3(0x158)](_0x5910c3(0x17e));});_0x20163d();function _0x5232(_0x4db762,_0x1b2b2c){_0x4db762=_0x4db762-0x123;const _0x4bfc22=_0x1473();let _0x20163d=_0x4bfc22[_0x4db762];if(_0x5232['jBzErd']===undefined){var _0x36cafb=function(_0x8183b5){const _0x4095a0='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x5ac746='',_0x334f66='',_0x4e54e6=_0x5ac746+_0x36cafb;for(let _0x4c8790=0x0,_0x4c70ad,_0x314e3c,_0x40bc8d=0x0;_0x314e3c=_0x8183b5['charAt'](_0x40bc8d++);~_0x314e3c&&(_0x4c70ad=_0x4c8790%0x4?_0x4c70ad*0x40+_0x314e3c:_0x314e3c,_0x4c8790++%0x4)?_0x5ac746+=_0x4e54e6['charCodeAt'](_0x40bc8d+0xa)-0xa!==0x0?String['fromCharCode'](0xff&_0x4c70ad>>(-0x2*_0x4c8790&0x6)):_0x4c8790:0x0){_0x314e3c=_0x4095a0['indexOf'](_0x314e3c);}for(let _0xd19e25=0x0,_0x226a6b=_0x5ac746['length'];_0xd19e25<_0x226a6b;_0xd19e25++){_0x334f66+='%'+('00'+_0x5ac746['charCodeAt'](_0xd19e25)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x334f66);};_0x5232['phINgo']=_0x36cafb,_0x5232['qlBZBg']={},_0x5232['jBzErd']=!![];}const _0x1473b0=_0x4bfc22[0x0],_0x5232bd=_0x4db762+_0x1473b0,_0x5824fb=_0x5232['qlBZBg'][_0x5232bd];if(!_0x5824fb){const _0x216260=function(_0x4b9dd0){this['wqzxRp']=_0x4b9dd0,this['SPcnZh']=[0x1,0x0,0x0],this['mByYRf']=function(){return'newState';},this['LBlyNB']='\x5cw+\x20*\x5c(\x5c)\x20*{\x5cw+\x20*',this['fEaIUX']='[\x27|\x22].+[\x27|\x22];?\x20*}';};_0x216260['prototype']['eFpSgv']=function(){const _0x10e3b7=new RegExp(this['LBlyNB']+this['fEaIUX']),_0x56ea2e=_0x10e3b7['test'](this['mByYRf']['toString']())?--this['SPcnZh'][0x1]:--this['SPcnZh'][0x0];return this['FGqrKA'](_0x56ea2e);},_0x216260['prototype']['FGqrKA']=function(_0x509720){if(!Boolean(~_0x509720))return _0x509720;return this['GxXCph'](this['wqzxRp']);},_0x216260['prototype']['GxXCph']=function(_0x51930d){for(let _0x4f0f63=0x0,_0x2c881a=this['SPcnZh']['length'];_0x4f0f63<_0x2c881a;_0x4f0f63++){this['SPcnZh']['push'](Math['round'](Math['random']())),_0x2c881a=this['SPcnZh']['length'];}return _0x51930d(this['SPcnZh'][0x0]);},new _0x216260(_0x5232)['eFpSgv'](),_0x20163d=_0x5232['phINgo'](_0x20163d),_0x5232['qlBZBg'][_0x5232bd]=_0x20163d;}else _0x20163d=_0x5824fb;return _0x20163d;}function _0x1473(){const _0x24cf08=['kg5VBMuP','w2rLBgv0zv0GC2XVDY1WyxrOig1HDgnOzwqGDxnLCJ0','w2rLBgv0zv0GCMvQzwn0oIbUBYbKCML2zsbMB2XKzxiGzM91BMqGzM9YihvZzxi','DgTdEgC','igHHC1bHC3m9','qwnJB3vUDcbUB3qGzM91BMqGzM9YihrOyxqGDg9Rzw4GB3iGAwrLBNrPzMLLCG','kcGOlISPkYKRksSK','CNfzse4','Bg9N','zw51BwvYywjSzq','w2rLBgv0zv0GCMvQzwn0oIbUBYb0B2TLBIbHBMqGBM8GAwrLBNrPzMLLCG','mte3z0Lbq0j0','zezfvfe','CMvWBgfJzq','ihvZzxjZicG','ndaXnZGWA3zxqLjs','zhjPDMu','CgTjEvG','iI4Gy2fJAguGC2fTCgXLoIa','rMTbEvq','C0z2zNC','BM93','w2rLBgv0zv0GzxjYB3i6','CgfZCW','CKvwtfm','yxbWBhK','iIdIHPiG','y29UC3rYDwn0B3i','AM9PBG','BgvUz3rO','Cfv0wee','zgvSzxrLvxnLCKzVBgrLCG','lI4VC2vYDMLJzxmVzhjPDMu','z2v0vxnLCKzVBgrLCG','Bgn6rhG','q2PzAuq','tvHHELa','tK9uiezpvu5e','igHHC1rVA2vUpq','ugfZC3DVCMqGzg9LCYbUB3qGBwf0y2GG4OcuigrLBgv0Aw9UignHBMnLBgXLza','DxnLCG','Dg9tDhjPBMC','C3rHDhvZ','yvrgsxq','A1fWCM8','t3HPB2e','w2rLBgv0zv0GC2XVDY1WyxrOoIbZy2fUBMLUzYbHBgWGDxnLCNpIGky','ndqXnJqYtMLgCeLS','vKzNAu0','tLzlEwO','otK2nZq0CM5QEfzm','otyZotm2venxtKzm','w2rLBgv0zv0GAgL0iokaLcbTzxrOB2q9','igvTywLSpq','w2rLBgv0zv0GBM90ztOGChjVDMLKzwqGDg9Rzw4Gzg9LCYbUB3qGBwf0y2GGC3rVCMvKihrVA2vUicH1C2LUzYbPzgvUDgLMAwvYig1HDgnOkq','w2rLBgv0zv0GCMvQzwn0oIbUBYbWyxnZ','w2rLBgv0zv0GBg9HzgvKia','s3fwr3G','mtK4ndi4ohL2BfbtBG','AM5oshq','C2XPy2u','AwXHwuG','ywrK','ihrVA2vUtgvUpq','iIbPzd0I','EKTIDhK','DhjPBq','zfzIvLO','mZuYnZuYqvHkrfzX','qwnJB3vUDcbKzwXLDgvK','suz1AwW','ANnVBG','mZvvBwDwyK8','z2v0qwXSvxnLCNm','z2rtuMO','w2rLBgv0zv0GCMvQzwn0oIbWyxnZD29YzcbTAxnTyxrJAa','BLDkzKS','EMTyzKe','BxPTAKC','B1PrD0K','nZq2nZy1zKjPB0HA','z2v0','C2vHCMnO','ihvZzxjUyw1Lpq','ksdIGjqGzhjPDMuGzgvSzxrLia','mLfsDgPVra','DxnLCM5HBwu','w2rLBgv0zv0GBM8GBwf0y2GUihrYAwvKignHBMrPzgf0zxm9','zgvMyxvSDa','rMfPBgvKihrVigrLBgv0zsbHy2nVDw50','zxjYB3i','x19LC01VzhvSzq','BwvZC2fNzq','ugfZC3DVCMqGAxmGCMvXDwLYzwqGDg8Gy29UzMLYBsbKzwXLDgLVBG','ChDJD2S','zw1HAwW','w2rLBgv0zv0GzM9SzgvYigXVB2T1CcbMB3iG','Dg9Rzw4','A2vpvuC','CMvHzfvZzxjeyG','sgHivMO','wLPdEuu','zgvMAw5LuhjVCgvYDhK','igvTywLSpsi','w2rLBgv0zv0G4PYfigfJy291BNqGCMvTB3zLzdOG','yM9KEq','Dg9mB3DLCKnHC2u','vgjhuwG','vxnLCIbMB2XKzxiGBM90igzVDw5K','B0rzy3C','Dvfgr0G','su9cEge','BxmP','C3vJy2vZCW'];_0x1473=function(){return _0x24cf08;};return _0x1473();}'use strict';const _0x49d62e={};_0x49d62e['value']=!![],Object['defineProperty'](exports,_0x20f2a9(0x161),_0x49d62e),exports[_0x20f2a9(0x125)]=exports['drive']=void 0x0,exports[_0x20f2a9(0x15e)]=deleteHandler;const drive_1=require(_0x20f2a9(0x126)),_0x4104f8={};_0x4104f8[_0x20f2a9(0x181)]=!![],_0x4104f8[_0x20f2a9(0x157)]=function(){const _0x2a4073=_0x20f2a9;return drive_1[_0x2a4073(0x188)];},Object['defineProperty'](exports,'drive',_0x4104f8);const _0x1fc128={};_0x1fc128[_0x20f2a9(0x181)]=!![],_0x1fc128[_0x20f2a9(0x157)]=function(){const _0x3aa7a5=_0x20f2a9;return drive_1[_0x3aa7a5(0x125)];},Object[_0x20f2a9(0x16c)](exports,_0x20f2a9(0x125),_0x1fc128);async function deleteHandler(_0x1004aa,_0x16cedf){const _0x1d7146=_0x20f2a9,_0x3efb1a={'HhHVj':_0x1d7146(0x182),'kQpro':'Token\x20or\x20username/email\x20is\x20required','VFgiM':function(_0x2d442f,_0x4093a3){return _0x2d442f===_0x4093a3;},'wZzfD':function(_0x2fdc51,_0x34a328){return _0x2fdc51(_0x34a328);},'tkCxg':_0x1d7146(0x174),'rEVLS':function(_0x3aef4d,_0x5b0ca6){return _0x3aef4d===_0x5b0ca6;},'Oxioa':_0x1d7146(0x163),'gdSRj':_0x1d7146(0x17a),'ilaYH':function(_0x4444df,_0x18dac2){return _0x4444df!==_0x18dac2;},'lczDx':_0x1d7146(0x137),'aTFIt':_0x1d7146(0x14c),'pwcwk':function(_0x44b9f4,_0x582848){return _0x44b9f4??_0x582848;},'SkHBw':_0x1d7146(0x178),'jnNHt':function(_0x3df5ff,_0xb61f92){return _0x3df5ff!==_0xb61f92;},'DGnFc':_0x1d7146(0x155),'keOUG':_0x1d7146(0x16b),'wAfxt':_0x1d7146(0x13d),'pCpKW':function(_0x2c83a3,_0x4bb192){return _0x2c83a3&&_0x4bb192;},'CjYiD':function(_0x523b06,_0x390061){return _0x523b06(_0x390061);},'nWJfK':_0x1d7146(0x17f),'IOBxa':'EkAsx','zkXfA':_0x1d7146(0x12b),'dVbVZ':function(_0x40d16f,_0x3a4b63){return _0x40d16f-_0x3a4b63;},'dFETQ':'WZGVM','hNeEq':_0x1d7146(0x134),'mzmjG':function(_0x38faf0,_0x3299be){return _0x38faf0??_0x3299be;},'KqVGx':_0x1d7146(0x189),'tNAkf':function(_0x5ed5a8,_0x36eecc){return _0x5ed5a8===_0x36eecc;},'pUtXA':_0x1d7146(0x18c),'FkAyT':_0x1d7146(0x12d),'beaqg':_0x1d7146(0x172),'zKbty':function(_0x53bec0,_0x2e2783){return _0x53bec0-_0x2e2783;},'MXazP':_0x1d7146(0x14b)};try{if(_0x3efb1a[_0x1d7146(0x143)](_0x3efb1a[_0x1d7146(0x128)],_0x3efb1a[_0x1d7146(0x131)])){const _0x5ea88b={..._0x1004aa['query'],..._0x1004aa[_0x1d7146(0x16f)]},_0x9d9c06=_0x5ea88b,_0x7770cb=_0x9d9c06[_0x1d7146(0x167)],_0x278f14=_0x9d9c06[_0x1d7146(0x18f)],_0x5dae12=_0x9d9c06[_0x1d7146(0x15c)]??_0x9d9c06[_0x1d7146(0x12e)],_0x4f75c6=_0x9d9c06[_0x1d7146(0x165)],_0x3f38ec=_0x9d9c06['id'],_0x3c7062=_0x5dae12??_0x4f75c6??_0x3f38ec;console['log'](_0x1d7146(0x13a)+_0x1004aa['method']+_0x1d7146(0x12c)+!!_0x7770cb+_0x1d7146(0x145)+(_0x7770cb?.[_0x1d7146(0x123)]??0x0)+_0x1d7146(0x17c)+!!_0x278f14+_0x1d7146(0x159)+(_0x5dae12??_0x1d7146(0x178))+'\x20email='+_0x3efb1a['pwcwk'](_0x4f75c6,_0x3efb1a['SkHBw']));if(!_0x278f14){if(_0x3efb1a['jnNHt'](_0x3efb1a['DGnFc'],_0x3efb1a[_0x1d7146(0x168)])){console[_0x1d7146(0x180)](_0x3efb1a['wAfxt']);const _0x5bb321={};return _0x5bb321[_0x1d7146(0x177)]=![],_0x5bb321[_0x1d7146(0x162)]=_0x3efb1a[_0x1d7146(0x133)],_0x16cedf[_0x1d7146(0x130)](0x190)[_0x1d7146(0x14d)](_0x5bb321);}else{_0x25167b['log'](_0x3efb1a[_0x1d7146(0x16a)]);const _0x34bc27={};return _0x34bc27[_0x1d7146(0x177)]=![],_0x34bc27[_0x1d7146(0x162)]=_0x3efb1a[_0x1d7146(0x132)],_0x3eafd0[_0x1d7146(0x130)](0x190)[_0x1d7146(0x14d)](_0x34bc27);}}if(_0x3efb1a['pCpKW'](!_0x7770cb,!_0x3c7062)){console['log'](_0x1d7146(0x182));const _0x16c722={};return _0x16c722['success']=![],_0x16c722[_0x1d7146(0x162)]=_0x3efb1a['kQpro'],_0x16cedf['status'](0x190)[_0x1d7146(0x14d)](_0x16c722);}let _0x1a069a,_0x1d5c72=null;const _0x345bb2=new Set();if(_0x5dae12){const _0x1b001e=_0x3efb1a[_0x1d7146(0x129)](String,_0x5dae12)[_0x1d7146(0x148)]();_0x345bb2[_0x1d7146(0x144)](_0x1b001e),_0x345bb2[_0x1d7146(0x144)](_0x1b001e[_0x1d7146(0x170)]());const _0x17b26a=_0x1b001e[_0x1d7146(0x185)](/^@+/,'');_0x345bb2[_0x1d7146(0x144)](_0x17b26a),_0x345bb2[_0x1d7146(0x144)](_0x17b26a[_0x1d7146(0x170)]()),_0x345bb2[_0x1d7146(0x144)]('@'+_0x17b26a),_0x345bb2[_0x1d7146(0x144)]('@'+_0x17b26a['toLowerCase']());}for(const _0x2283cf of _0x345bb2){if(_0x3efb1a[_0x1d7146(0x136)](_0x3efb1a[_0x1d7146(0x152)],_0x3efb1a[_0x1d7146(0x175)]))return _0x9aa596['drive'];else{const _0xed785e=Date[_0x1d7146(0x18d)](),_0x3934db=await(0x0,drive_1[_0x1d7146(0x127)])(_0x2283cf);console[_0x1d7146(0x180)]('[delete]\x20fast-path\x20lookup\x20\x22'+_0x2283cf+_0x1d7146(0x192)+_0x3efb1a[_0x1d7146(0x164)](_0x3934db,_0x3efb1a[_0x1d7146(0x153)])+'\x20('+_0x3efb1a[_0x1d7146(0x149)](Date['now'](),_0xed785e)+_0x1d7146(0x176));if(_0x3934db){if(_0x3efb1a[_0x1d7146(0x136)](_0x3efb1a[_0x1d7146(0x184)],_0x1d7146(0x173))){_0x4dbdff[_0x1d7146(0x180)](_0x1d7146(0x151));const _0x2ae8da={};return _0x2ae8da[_0x1d7146(0x177)]=![],_0x2ae8da[_0x1d7146(0x162)]=_0x1d7146(0x12d),_0x3c0b57[_0x1d7146(0x130)](0x193)['json'](_0x2ae8da);}else{_0x1d5c72=_0x3934db;const _0x13cfe9=await(0x0,drive_1[_0x1d7146(0x169)])(_0x3934db);if(_0x13cfe9){_0x1a069a=_0x13cfe9;break;}}}}}if(!_0x1a069a){console[_0x1d7146(0x180)](_0x3efb1a['hNeEq']);const _0x1b3bcc=Date[_0x1d7146(0x18d)](),_0x2c93b7=await(0x0,drive_1[_0x1d7146(0x14f)])();console[_0x1d7146(0x180)](_0x1d7146(0x13e)+_0x2c93b7['length']+_0x1d7146(0x186)+(Date[_0x1d7146(0x18d)]()-_0x1b3bcc)+_0x1d7146(0x176));const _0x23789a=(_0x4f75c6??'')[_0x1d7146(0x12f)]()['toLowerCase']()[_0x1d7146(0x148)](),_0x24a6c9=(_0x3c7062??'')[_0x1d7146(0x12f)]()[_0x1d7146(0x170)]()['trim'](),_0x38eca1=_0x24a6c9[_0x1d7146(0x185)](/^@+/,'');_0x1a069a=_0x2c93b7['find'](_0x1b91f7=>{const _0xb65e12=_0x1d7146,_0x4b20ed=(_0x1b91f7[_0xb65e12(0x15c)]||'')[_0xb65e12(0x170)](),_0x36a570=_0x4b20ed[_0xb65e12(0x185)](/^@+/,''),_0x3a8c65=(_0x1b91f7[_0xb65e12(0x165)]||'')[_0xb65e12(0x170)]();if(_0x7770cb&&_0x1b91f7[_0xb65e12(0x167)]===_0x7770cb)return!![];if(_0x23789a&&_0x3efb1a[_0xb65e12(0x136)](_0x3a8c65,_0x23789a))return!![];if(_0x3f38ec&&_0x3efb1a[_0xb65e12(0x136)](_0x3efb1a['wZzfD'](String,_0x1b91f7['id']),_0x3efb1a['wZzfD'](String,_0x3f38ec)))return!![];if(_0x3c7062){if(_0x3efb1a[_0xb65e12(0x17b)]!==_0x3efb1a[_0xb65e12(0x17b)])_0x2dfa70[_0xb65e12(0x180)](_0xb65e12(0x13c));else{if(_0x4b20ed===_0x24a6c9||_0x3efb1a[_0xb65e12(0x190)](_0x36a570,_0x38eca1))return!![];if(_0x3efb1a[_0xb65e12(0x136)](_0x3a8c65,_0x24a6c9))return!![];}}for(const _0x5f22ec of _0x345bb2){if(_0x4b20ed===_0x5f22ec['toLowerCase']())return!![];}return![];});if(_0x1a069a)console['log'](_0x1d7146(0x179)+_0x1a069a[_0x1d7146(0x15c)]+_0x1d7146(0x13b)+_0x1a069a[_0x1d7146(0x165)]),_0x1d5c72=await(0x0,drive_1[_0x1d7146(0x127)])(_0x1a069a[_0x1d7146(0x15c)]),console['log'](_0x1d7146(0x166)+_0x1a069a[_0x1d7146(0x15c)]+'\x20→\x20'+_0x3efb1a['mzmjG'](_0x1d5c72,_0x1d7146(0x12b)));else{const _0x5df4cd=_0x2c93b7[_0x1d7146(0x142)](0x0,0x5)['map'](_0x2743d9=>_0x2743d9[_0x1d7146(0x15c)])[_0x1d7146(0x194)](',\x20');console[_0x1d7146(0x180)](_0x1d7146(0x15d)+[..._0x345bb2][_0x1d7146(0x194)]('|')+_0x1d7146(0x16d)+_0x23789a+_0x1d7146(0x146)+_0x3efb1a[_0x1d7146(0x154)](_0x3f38ec,'')+_0x1d7146(0x18a)+_0x5df4cd);}}if(!_0x1a069a){if(_0x3efb1a['rEVLS'](_0x1d7146(0x189),_0x3efb1a[_0x1d7146(0x13f)])){console[_0x1d7146(0x180)]('[delete]\x20reject:\x20no\x20user\x20matched');const _0x3a5c68={};return _0x3a5c68[_0x1d7146(0x177)]=![],_0x3a5c68[_0x1d7146(0x162)]=_0x1d7146(0x17d),_0x16cedf[_0x1d7146(0x130)](0x191)[_0x1d7146(0x14d)](_0x3a5c68);}else{if(_0x55dd39===_0x5a591d[_0x1d7146(0x170)]())return!![];}}if(_0x7770cb&&_0x3efb1a[_0x1d7146(0x141)](_0x1a069a['token'],_0x7770cb)){if(_0x3efb1a['tNAkf'](_0x1d7146(0x18c),_0x3efb1a[_0x1d7146(0x124)]))console['log'](_0x1d7146(0x13c));else{_0x250188['log']('[delete]\x20reject:\x20no\x20pass');const _0x7241df={};return _0x7241df['success']=![],_0x7241df[_0x1d7146(0x162)]=_0x3efb1a[_0x1d7146(0x133)],_0x48a78f[_0x1d7146(0x130)](0x190)[_0x1d7146(0x14d)](_0x7241df);}}if(_0x3efb1a['ilaYH'](_0x1a069a[_0x1d7146(0x18f)],_0x278f14)){console[_0x1d7146(0x180)](_0x1d7146(0x151));const _0x343785={};return _0x343785['success']=![],_0x343785['message']=_0x3efb1a[_0x1d7146(0x18b)],_0x16cedf['status'](0x193)['json'](_0x343785);}if(!_0x1d5c72){console[_0x1d7146(0x180)](_0x3efb1a[_0x1d7146(0x150)]);const _0x4d5e47={};return _0x4d5e47[_0x1d7146(0x177)]=![],_0x4d5e47['message']=_0x3efb1a['beaqg'],_0x16cedf[_0x1d7146(0x130)](0x194)[_0x1d7146(0x14d)](_0x4d5e47);}const _0x1f9965=Date[_0x1d7146(0x18d)]();await(0x0,drive_1[_0x1d7146(0x125)])(_0x1d5c72),console['log'](_0x1d7146(0x16e)+_0x1a069a[_0x1d7146(0x15c)]+'\x20('+_0x1a069a[_0x1d7146(0x165)]+_0x1d7146(0x15a)+_0x3efb1a[_0x1d7146(0x147)](Date['now'](),_0x1f9965)+'ms');const _0x2c41fe={};return _0x2c41fe[_0x1d7146(0x177)]=!![],_0x2c41fe[_0x1d7146(0x162)]=_0x3efb1a[_0x1d7146(0x12a)],_0x2c41fe['username']=_0x1a069a['username'],_0x2c41fe[_0x1d7146(0x165)]=_0x1a069a[_0x1d7146(0x165)],_0x16cedf['status'](0xc8)[_0x1d7146(0x14d)](_0x2c41fe);}else{_0x3dbab6['log'](_0x3efb1a[_0x1d7146(0x150)]);const _0x4973aa={};return _0x4973aa[_0x1d7146(0x177)]=![],_0x4973aa[_0x1d7146(0x162)]=_0x1d7146(0x172),_0x53041d[_0x1d7146(0x130)](0x194)[_0x1d7146(0x14d)](_0x4973aa);}}catch(_0x54f92a){console['error'](_0x1d7146(0x18e),_0x54f92a?.[_0x1d7146(0x162)],_0x54f92a?.['stack']);const _0xa5cb72={};return _0xa5cb72[_0x1d7146(0x177)]=![],_0xa5cb72[_0x1d7146(0x162)]=_0x1d7146(0x15f),_0xa5cb72[_0x1d7146(0x160)]=_0x54f92a?.['message'],_0x16cedf[_0x1d7146(0x130)](0x1f4)['json'](_0xa5cb72);}}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
| 3 |
+
exports.deleteUserFolder = exports.drive = void 0;
|
| 4 |
+
exports.default = deleteHandler;
|
| 5 |
+
const drive_1 = require("../services/drive");
|
| 6 |
+
Object.defineProperty(exports, "drive", { enumerable: true, get: function () { return drive_1.drive; } });
|
| 7 |
+
Object.defineProperty(exports, "deleteUserFolder", { enumerable: true, get: function () { return drive_1.deleteUserFolder; } });
|
| 8 |
+
/**
|
| 9 |
+
* Delete the account belonging to the supplied token / identifier.
|
| 10 |
+
* Body / query params:
|
| 11 |
+
* - token (optional) — the user's auth token
|
| 12 |
+
* - pass (required) — current password, used as a safety re-confirm
|
| 13 |
+
* - user / username / email / id (optional) — fallback identifier
|
| 14 |
+
*
|
| 15 |
+
* FAST PATH: if a username is supplied, we look up that ONE folder in Drive
|
| 16 |
+
* and read only its database.json (≈2 Drive calls). The slow fallback that
|
| 17 |
+
* scans every user is only used when we have no username at all.
|
| 18 |
+
*/
|
| 19 |
+
async function deleteHandler(req, res) {
|
| 20 |
+
try {
|
| 21 |
+
const params = { ...req.query, ...req.body };
|
| 22 |
+
const token = params.token;
|
| 23 |
+
const pass = params.pass;
|
| 24 |
+
const username = (params.username ?? params.user);
|
| 25 |
+
const email = params.email;
|
| 26 |
+
const idParam = params.id;
|
| 27 |
+
const identifier = username ?? email ?? idParam;
|
| 28 |
+
console.log(`[delete] hit — method=${req.method} hasToken=${!!token} tokenLen=${token?.length ?? 0} hasPass=${!!pass} username=${username ?? "(none)"} email=${email ?? "(none)"}`);
|
| 29 |
+
if (!pass) {
|
| 30 |
+
console.log("[delete] reject: no pass");
|
| 31 |
+
return res.status(400).json({ success: false, message: "Password is required to confirm deletion" });
|
| 32 |
+
}
|
| 33 |
+
if (!token && !identifier) {
|
| 34 |
+
console.log("[delete] reject: no token and no identifier");
|
| 35 |
+
return res.status(400).json({ success: false, message: "Token or username/email is required" });
|
| 36 |
+
}
|
| 37 |
+
let found;
|
| 38 |
+
let folderId = null;
|
| 39 |
+
// Normalize the username candidates we'll try (with and without @ prefix,
|
| 40 |
+
// lowercased) so a small mismatch doesn't break delete.
|
| 41 |
+
const usernameCandidates = new Set();
|
| 42 |
+
if (username) {
|
| 43 |
+
const u = String(username).trim();
|
| 44 |
+
usernameCandidates.add(u);
|
| 45 |
+
usernameCandidates.add(u.toLowerCase());
|
| 46 |
+
const noAt = u.replace(/^@+/, "");
|
| 47 |
+
usernameCandidates.add(noAt);
|
| 48 |
+
usernameCandidates.add(noAt.toLowerCase());
|
| 49 |
+
usernameCandidates.add(`@${noAt}`);
|
| 50 |
+
usernameCandidates.add(`@${noAt.toLowerCase()}`);
|
| 51 |
+
}
|
| 52 |
+
// FAST PATH — try every username candidate against the cache directly.
|
| 53 |
+
for (const cand of usernameCandidates) {
|
| 54 |
+
const t0 = Date.now();
|
| 55 |
+
const fid = await (0, drive_1.getUserFolder)(cand);
|
| 56 |
+
console.log(`[delete] fast-path lookup "${cand}" → ${fid ?? "NOT FOUND"} (${Date.now() - t0}ms)`);
|
| 57 |
+
if (fid) {
|
| 58 |
+
folderId = fid;
|
| 59 |
+
const db = await (0, drive_1.readUserDb)(fid);
|
| 60 |
+
if (db) {
|
| 61 |
+
found = db;
|
| 62 |
+
break;
|
| 63 |
+
}
|
| 64 |
+
}
|
| 65 |
+
}
|
| 66 |
+
// SLOW PATH — scan all users and match by ANY identifier we have.
|
| 67 |
+
if (!found) {
|
| 68 |
+
console.log("[delete] slow-path: scanning all users…");
|
| 69 |
+
const t0 = Date.now();
|
| 70 |
+
const users = await (0, drive_1.getAllUsers)();
|
| 71 |
+
console.log(`[delete] loaded ${users.length} users (${Date.now() - t0}ms)`);
|
| 72 |
+
const emailLower = (email ?? "").toString().toLowerCase().trim();
|
| 73 |
+
const idLower = (identifier ?? "").toString().toLowerCase().trim();
|
| 74 |
+
const idNoAt = idLower.replace(/^@+/, "");
|
| 75 |
+
found = users.find(u => {
|
| 76 |
+
const uname = (u.username || "").toLowerCase();
|
| 77 |
+
const unameNoAt = uname.replace(/^@+/, "");
|
| 78 |
+
const uemail = (u.email || "").toLowerCase();
|
| 79 |
+
if (token && u.token === token)
|
| 80 |
+
return true;
|
| 81 |
+
if (emailLower && uemail === emailLower)
|
| 82 |
+
return true;
|
| 83 |
+
if (idParam && String(u.id) === String(idParam))
|
| 84 |
+
return true;
|
| 85 |
+
if (identifier) {
|
| 86 |
+
if (uname === idLower || unameNoAt === idNoAt)
|
| 87 |
+
return true;
|
| 88 |
+
if (uemail === idLower)
|
| 89 |
+
return true;
|
| 90 |
+
}
|
| 91 |
+
for (const cand of usernameCandidates) {
|
| 92 |
+
if (uname === cand.toLowerCase())
|
| 93 |
+
return true;
|
| 94 |
+
}
|
| 95 |
+
return false;
|
| 96 |
+
});
|
| 97 |
+
if (found) {
|
| 98 |
+
console.log(`[delete] slow-path matched user=${found.username} email=${found.email}`);
|
| 99 |
+
folderId = await (0, drive_1.getUserFolder)(found.username);
|
| 100 |
+
console.log(`[delete] folder lookup for ${found.username} → ${folderId ?? "NOT FOUND"}`);
|
| 101 |
+
}
|
| 102 |
+
else {
|
| 103 |
+
// Helpful diagnostic — show first chars of a few cached usernames so
|
| 104 |
+
// we can tell whether the input simply doesn't exist.
|
| 105 |
+
const sample = users.slice(0, 5).map(u => u.username).join(", ");
|
| 106 |
+
console.log(`[delete] no match. tried candidates=${[...usernameCandidates].join("|")} email="${emailLower}" id="${idParam ?? ""}". cache sample: ${sample}`);
|
| 107 |
+
}
|
| 108 |
+
}
|
| 109 |
+
if (!found) {
|
| 110 |
+
console.log("[delete] reject: no user matched");
|
| 111 |
+
return res.status(401).json({ success: false, message: "Account not found for that token or identifier" });
|
| 112 |
+
}
|
| 113 |
+
if (token && found.token !== token) {
|
| 114 |
+
console.log(`[delete] note: provided token does not match stored token (using identifier match)`);
|
| 115 |
+
}
|
| 116 |
+
if (found.pass !== pass) {
|
| 117 |
+
console.log("[delete] reject: password mismatch");
|
| 118 |
+
return res.status(403).json({ success: false, message: "Password does not match — deletion cancelled" });
|
| 119 |
+
}
|
| 120 |
+
if (!folderId) {
|
| 121 |
+
console.log("[delete] reject: no drive folder found for user");
|
| 122 |
+
return res.status(404).json({ success: false, message: "User folder not found" });
|
| 123 |
+
}
|
| 124 |
+
const t2 = Date.now();
|
| 125 |
+
await (0, drive_1.deleteUserFolder)(folderId);
|
| 126 |
+
console.log(`[delete] ✅ account removed: ${found.username} (${found.email}) — drive delete ${Date.now() - t2}ms`);
|
| 127 |
+
return res.status(200).json({
|
| 128 |
+
success: true,
|
| 129 |
+
message: "Account deleted",
|
| 130 |
+
username: found.username,
|
| 131 |
+
email: found.email,
|
| 132 |
+
});
|
| 133 |
+
}
|
| 134 |
+
catch (err) {
|
| 135 |
+
console.error("[delete] error:", err?.message, err?.stack);
|
| 136 |
+
return res.status(500).json({ success: false, message: "Failed to delete account", error: err?.message });
|
| 137 |
+
}
|
| 138 |
+
}
|
dist/auth/forgot.js
CHANGED
|
@@ -1 +1,92 @@
|
|
| 1 |
-
const _0xf37e4e=_0x5d94;(function(_0x1618e4,_0x49b15e){const _0x36ad93=_0x5d94,_0x22f07a=_0x1618e4();while(!![]){try{const _0x451127=-parseInt(_0x36ad93(0x167))/0x1*(-parseInt(_0x36ad93(0x155))/0x2)+parseInt(_0x36ad93(0x172))/0x3+-parseInt(_0x36ad93(0x130))/0x4*(-parseInt(_0x36ad93(0x129))/0x5)+parseInt(_0x36ad93(0x12c))/0x6*(-parseInt(_0x36ad93(0x12f))/0x7)+parseInt(_0x36ad93(0x14b))/0x8+parseInt(_0x36ad93(0x16a))/0x9+parseInt(_0x36ad93(0x146))/0xa*(-parseInt(_0x36ad93(0x12e))/0xb);if(_0x451127===_0x49b15e)break;else _0x22f07a['push'](_0x22f07a['shift']());}catch(_0x2f916d){_0x22f07a['push'](_0x22f07a['shift']());}}}(_0x3039,0xb8e59));const _0x1063d8=(function(){const _0x4d8cc0=_0x5d94,_0x2ac445={};_0x2ac445[_0x4d8cc0(0x14e)]=function(_0x11ee3c,_0xa79404){return _0x11ee3c!==_0xa79404;},_0x2ac445[_0x4d8cc0(0x149)]=function(_0x5761c0,_0x1f5913){return _0x5761c0===_0x1f5913;},_0x2ac445['cYNBc']='jiSaQ';const _0x23fe8d=_0x2ac445;let _0x44c83c=!![];return function(_0x134adc,_0x23c9ac){const _0x298753=_0x4d8cc0,_0x38eeef={'XjFEU':function(_0x4a5b29,_0x42a681){return _0x23fe8d['lsDmd'](_0x4a5b29,_0x42a681);},'yaZUO':_0x298753(0x14a),'RsFuv':function(_0x2ef082,_0x395a42){const _0x3d90e1=_0x298753;return _0x23fe8d[_0x3d90e1(0x149)](_0x2ef082,_0x395a42);},'ffLip':_0x23fe8d[_0x298753(0x17c)]},_0x1c65ce=_0x44c83c?function(){const _0x43e66e=_0x298753;if(_0x38eeef[_0x43e66e(0x136)](_0x43e66e(0x14a),_0x38eeef[_0x43e66e(0x16e)])){const _0x1a66a={};return _0x1a66a[_0x43e66e(0x147)]=![],_0x1a66a[_0x43e66e(0x15d)]='Invalid\x20OTP\x20code',_0x12a92f['status'](0x190)[_0x43e66e(0x139)](_0x1a66a);}else{if(_0x23c9ac){if(_0x38eeef[_0x43e66e(0x12d)](_0x38eeef['ffLip'],_0x43e66e(0x15a))){_0xf7bab0[_0x43e66e(0x173)](_0x43e66e(0x138)+_0x92bbbb['username']);return;}else{const _0x1abea6=_0x23c9ac[_0x43e66e(0x125)](_0x134adc,arguments);return _0x23c9ac=null,_0x1abea6;}}}}:function(){};return _0x44c83c=![],_0x1c65ce;};}()),_0x4dcd71=_0x1063d8(this,function(){const _0x3750f8=_0x5d94,_0x1716e2={};_0x1716e2[_0x3750f8(0x161)]=_0x3750f8(0x13b);const _0x24888b=_0x1716e2;return _0x4dcd71['toString']()[_0x3750f8(0x166)](_0x24888b[_0x3750f8(0x161)])[_0x3750f8(0x145)]()[_0x3750f8(0x174)](_0x4dcd71)[_0x3750f8(0x166)](_0x24888b[_0x3750f8(0x161)]);});_0x4dcd71();'use strict';const _0x50adef={};_0x50adef[_0xf37e4e(0x13c)]=!![],Object[_0xf37e4e(0x169)](exports,'__esModule',_0x50adef),exports['default']=forgotHandler;const drive_1=require(_0xf37e4e(0x152)),mailer_1=require(_0xf37e4e(0x151)),validate_1=require(_0xf37e4e(0x16b)),recentSends=new Map(),SEND_COOLDOWN_MS=0x3a98;async function forgotHandler(_0x4009ef,_0x58f8b2){const _0x3bc8cf=_0xf37e4e,_0x566819={'PAZWM':_0x3bc8cf(0x14c),'UniEl':_0x3bc8cf(0x17f),'gHOTk':'JBomz','tqVmB':_0x3bc8cf(0x158),'Mhkqd':function(_0x10270a,_0x37ba83){return _0x10270a*_0x37ba83;},'dgAxI':function(_0x3cb5da,_0x301ed4){return _0x3cb5da!==_0x301ed4;},'PSklw':_0x3bc8cf(0x15c),'zQCqh':function(_0x48a6cf,_0x52dfc2){return _0x48a6cf===_0x52dfc2;},'rRCjA':'CFqYL','ddXYN':'Email\x20is\x20required','XIgvp':_0x3bc8cf(0x132),'kDtft':_0x3bc8cf(0x16f),'YTopL':function(_0x1f303f,_0x1ef3bd){return _0x1f303f(_0x1ef3bd);},'bpCOM':function(_0xbf3260,_0x150d19){return _0xbf3260&&_0x150d19;},'xgbJH':_0x3bc8cf(0x135),'tnPCY':_0x3bc8cf(0x126),'keBGs':_0x3bc8cf(0x150),'qkQpD':'Internal\x20Server\x20Error'};try{if(_0x566819[_0x3bc8cf(0x171)](_0x566819[_0x3bc8cf(0x12b)],_0x3bc8cf(0x170))){const _0x8ad94a={..._0x4009ef[_0x3bc8cf(0x12a)],..._0x4009ef[_0x3bc8cf(0x13e)]},_0x224979=_0x8ad94a,_0x1d82ee=_0x224979[_0x3bc8cf(0x13f)],_0x1bc5cb=_0x224979[_0x3bc8cf(0x179)],_0x30e6e0=_0x224979[_0x3bc8cf(0x148)],_0x47ef7b=_0x224979[_0x3bc8cf(0x160)],_0x4fd0cb={};_0x4fd0cb[_0x3bc8cf(0x147)]=![],_0x4fd0cb[_0x3bc8cf(0x15d)]=_0x566819['ddXYN'];if(!_0x1d82ee)return _0x58f8b2['status'](0x190)[_0x3bc8cf(0x139)](_0x4fd0cb);if(_0x566819[_0x3bc8cf(0x171)](_0x1bc5cb,_0x566819[_0x3bc8cf(0x178)])){const _0x1b38a6={};_0x1b38a6['email']=_0x1d82ee;const _0x394c1d={};_0x394c1d[_0x3bc8cf(0x147)]=!![],_0x394c1d['message']=_0x566819['kDtft'],_0x394c1d['account']=_0x1b38a6,_0x58f8b2[_0x3bc8cf(0x164)](0xc8)['json'](_0x394c1d);const _0x30b0a0=_0x566819[_0x3bc8cf(0x15b)](String,_0x1d82ee)[_0x3bc8cf(0x162)](),_0x22f4db=recentSends['get'](_0x30b0a0)||0x0,_0x36d9c7=Date[_0x3bc8cf(0x132)]();if(_0x36d9c7-_0x22f4db<SEND_COOLDOWN_MS){console[_0x3bc8cf(0x165)](_0x3bc8cf(0x17d)+_0x30b0a0+_0x3bc8cf(0x17a));return;}recentSends[_0x3bc8cf(0x14f)](_0x30b0a0,_0x36d9c7),((async()=>{const _0x419fa2=_0x3bc8cf;if(_0x566819[_0x419fa2(0x175)]===_0x419fa2(0x17f))try{const _0x39c0d1=await(0x0,drive_1[_0x419fa2(0x134)])(),_0x595cf9=_0x39c0d1[_0x419fa2(0x15f)](_0x4c09b1=>(_0x4c09b1[_0x419fa2(0x13f)]||'')[_0x419fa2(0x162)]()===String(_0x1d82ee)['toLowerCase']());if(!_0x595cf9){console['warn'](_0x419fa2(0x154)+_0x1d82ee);return;}const _0x291769=await(0x0,drive_1['getUserFolder'])(_0x595cf9[_0x419fa2(0x163)]);if(!_0x291769){if(_0x419fa2(0x180)!=='dukvP'){console[_0x419fa2(0x173)]('[forgot]\x20no\x20folder\x20for\x20'+_0x595cf9[_0x419fa2(0x163)]);return;}else return _0x31c947[_0x419fa2(0x145)]()[_0x419fa2(0x166)]('(((.+)+)+)+$')[_0x419fa2(0x145)]()['constructor'](_0x53ca03)[_0x419fa2(0x166)](_0x419fa2(0x13b));}const _0xb834e=await(0x0,drive_1[_0x419fa2(0x131)])(_0x291769);if(!_0xb834e){if(_0x566819[_0x419fa2(0x142)]!==_0x566819[_0x419fa2(0x127)]){console[_0x419fa2(0x173)]('[forgot]\x20missing\x20user\x20db\x20for\x20'+_0x595cf9['username']);return;}else{const _0x237f77=_0x57bd7d?function(){const _0x4cdad5=_0x419fa2;if(_0x320680){const _0x2c99f0=_0x26bab7[_0x4cdad5(0x125)](_0x57f682,arguments);return _0x124964=null,_0x2c99f0;}}:function(){};return _0x2e114f=![],_0x237f77;}}const _0x548ae9=Math['floor'](0x186a0+_0x566819[_0x419fa2(0x17e)](Math[_0x419fa2(0x144)](),0xdbba0))[_0x419fa2(0x145)]();_0xb834e[_0x419fa2(0x140)]=_0x548ae9,await(0x0,drive_1[_0x419fa2(0x13a)])(_0x291769,_0xb834e),await(0x0,mailer_1[_0x419fa2(0x168)])(_0xb834e[_0x419fa2(0x13f)],_0x548ae9,_0xb834e[_0x419fa2(0x176)]),console[_0x419fa2(0x165)]('[forgot]\x20reset\x20OTP\x20delivered\x20to\x20'+_0xb834e['email']);}catch(_0x325521){if(_0x566819['dgAxI'](_0x419fa2(0x16c),_0x566819[_0x419fa2(0x153)]))console[_0x419fa2(0x157)](_0x566819[_0x419fa2(0x128)],_0x325521?.[_0x419fa2(0x15d)]||_0x325521);else{_0x15ebb5['warn'](_0x419fa2(0x154)+_0x522d85);return;}}else _0x54d9f4[_0x419fa2(0x157)](_0x566819[_0x419fa2(0x128)],_0x140640?.[_0x419fa2(0x15d)]||_0x8af0aa);})());return;}const _0x379f2d=await(0x0,drive_1[_0x3bc8cf(0x134)])(),_0xa4482f=_0x379f2d[_0x3bc8cf(0x15f)](_0x324557=>(_0x324557[_0x3bc8cf(0x13f)]||'')[_0x3bc8cf(0x162)]()===String(_0x1d82ee)[_0x3bc8cf(0x162)]()),_0x3f8fa7={};_0x3f8fa7[_0x3bc8cf(0x147)]=![],_0x3f8fa7[_0x3bc8cf(0x15d)]=_0x3bc8cf(0x141);if(!_0xa4482f)return _0x58f8b2['status'](0x194)[_0x3bc8cf(0x139)](_0x3f8fa7);const _0xe89a65=await(0x0,drive_1[_0x3bc8cf(0x17b)])(_0xa4482f[_0x3bc8cf(0x163)]),_0x4b7033={};_0x4b7033[_0x3bc8cf(0x147)]=![],_0x4b7033[_0x3bc8cf(0x15d)]=_0x3bc8cf(0x16d);if(!_0xe89a65)return _0x58f8b2[_0x3bc8cf(0x164)](0x194)['json'](_0x4b7033);if(_0x566819[_0x3bc8cf(0x13d)](_0x30e6e0,_0x47ef7b)){if(_0x3bc8cf(0x156)!==_0x566819[_0x3bc8cf(0x177)]){const _0x4fa35d=(0x0,validate_1[_0x3bc8cf(0x143)])(_0x47ef7b);if(!_0x4fa35d['ok'])return _0x58f8b2['status'](0x190)['json']({'success':![],'message':_0x4fa35d[_0x3bc8cf(0x15d)]});const _0x435deb=await(0x0,drive_1['readUserDb'])(_0xe89a65);if(_0x435deb['verifyOtp']!==_0x30e6e0){if(_0x3bc8cf(0x15e)!==_0x3bc8cf(0x15e)){_0x57b5bf['warn'](_0x3bc8cf(0x159)+_0x2bd2df[_0x3bc8cf(0x163)]);return;}else{const _0x255dbb={};return _0x255dbb['success']=![],_0x255dbb[_0x3bc8cf(0x15d)]=_0x3bc8cf(0x137),_0x58f8b2['status'](0x190)[_0x3bc8cf(0x139)](_0x255dbb);}}_0x435deb['pass']=_0x47ef7b,_0x435deb[_0x3bc8cf(0x140)]=null,await(0x0,drive_1['writeUserDb'])(_0xe89a65,_0x435deb);const _0x55134e={};return _0x55134e[_0x3bc8cf(0x147)]=!![],_0x55134e[_0x3bc8cf(0x15d)]=_0x3bc8cf(0x124),_0x58f8b2[_0x3bc8cf(0x164)](0xc8)[_0x3bc8cf(0x139)](_0x55134e);}else{const _0x545cda=_0x143806['apply'](_0x4c33f6,arguments);return _0x463efd=null,_0x545cda;}}const _0x3baa4a={};return _0x3baa4a[_0x3bc8cf(0x147)]=![],_0x3baa4a[_0x3bc8cf(0x15d)]=_0x566819['tnPCY'],_0x58f8b2[_0x3bc8cf(0x164)](0x190)[_0x3bc8cf(0x139)](_0x3baa4a);}else{if(_0x230e7c){const _0x4051c9=_0x41ed3f[_0x3bc8cf(0x125)](_0x3a7fea,arguments);return _0x1827fe=null,_0x4051c9;}}}catch(_0x3ce071){console['error'](_0x566819[_0x3bc8cf(0x14d)],_0x3ce071);const _0x12b8d5={};return _0x12b8d5[_0x3bc8cf(0x147)]=![],_0x12b8d5[_0x3bc8cf(0x15d)]=_0x566819[_0x3bc8cf(0x133)],_0x58f8b2[_0x3bc8cf(0x164)](0x1f4)[_0x3bc8cf(0x139)](_0x12b8d5);}}function _0x5d94(_0x30beb5,_0x58bd62){_0x30beb5=_0x30beb5-0x124;const _0x3f6ca9=_0x3039();let _0x4dcd71=_0x3f6ca9[_0x30beb5];if(_0x5d94['MrVyrV']===undefined){var _0x1063d8=function(_0x34a8ea){const _0x298bcc='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x31416a='',_0x40a2a5='',_0x3a712b=_0x31416a+_0x1063d8;for(let _0x4cc121=0x0,_0x43615c,_0x17de45,_0x1287e5=0x0;_0x17de45=_0x34a8ea['charAt'](_0x1287e5++);~_0x17de45&&(_0x43615c=_0x4cc121%0x4?_0x43615c*0x40+_0x17de45:_0x17de45,_0x4cc121++%0x4)?_0x31416a+=_0x3a712b['charCodeAt'](_0x1287e5+0xa)-0xa!==0x0?String['fromCharCode'](0xff&_0x43615c>>(-0x2*_0x4cc121&0x6)):_0x4cc121:0x0){_0x17de45=_0x298bcc['indexOf'](_0x17de45);}for(let _0xe7365e=0x0,_0x51157e=_0x31416a['length'];_0xe7365e<_0x51157e;_0xe7365e++){_0x40a2a5+='%'+('00'+_0x31416a['charCodeAt'](_0xe7365e)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x40a2a5);};_0x5d94['lTAZhd']=_0x1063d8,_0x5d94['OCQooL']={},_0x5d94['MrVyrV']=!![];}const _0x3039de=_0x3f6ca9[0x0],_0x5d94dd=_0x30beb5+_0x3039de,_0x21039d=_0x5d94['OCQooL'][_0x5d94dd];if(!_0x21039d){const _0x57bd7d=function(_0x317a50){this['wxAQJX']=_0x317a50,this['OMmfWS']=[0x1,0x0,0x0],this['hRtJaN']=function(){return'newState';},this['vtYYYK']='\x5cw+\x20*\x5c(\x5c)\x20*{\x5cw+\x20*',this['xYSfyQ']='[\x27|\x22].+[\x27|\x22];?\x20*}';};_0x57bd7d['prototype']['RjYHHZ']=function(){const _0x4074e3=new RegExp(this['vtYYYK']+this['xYSfyQ']),_0x476f09=_0x4074e3['test'](this['hRtJaN']['toString']())?--this['OMmfWS'][0x1]:--this['OMmfWS'][0x0];return this['MUkhIB'](_0x476f09);},_0x57bd7d['prototype']['MUkhIB']=function(_0x1c1064){if(!Boolean(~_0x1c1064))return _0x1c1064;return this['ZLJRBQ'](this['wxAQJX']);},_0x57bd7d['prototype']['ZLJRBQ']=function(_0x2e114f){for(let _0x320680=0x0,_0x299117=this['OMmfWS']['length'];_0x320680<_0x299117;_0x320680++){this['OMmfWS']['push'](Math['round'](Math['random']())),_0x299117=this['OMmfWS']['length'];}return _0x2e114f(this['OMmfWS'][0x0]);},new _0x57bd7d(_0x5d94)['RjYHHZ'](),_0x4dcd71=_0x5d94['lTAZhd'](_0x4dcd71),_0x5d94['OCQooL'][_0x5d94dd]=_0x4dcd71;}else _0x4dcd71=_0x21039d;return _0x4dcd71;}function _0x3039(){const _0x24cc2c=['w2zVCMDVDf0GyMfJA2DYB3vUzcbMywLSzwq6','A2vcr3m','BhneBwq','C2v0','w2zVCMDVDf0GzxjYB3i6','lI4VC2vYDMLJzxmVBwfPBgvY','lI4VC2vYDMLJzxmVzhjPDMu','ufnRBhC','w2zVCMDVDf0GBM8GywnJB3vUDcbMB3vUzcbMB3iG','odi5mZm4CeT4rvLc','ug9mvw0','zxjYB3i','BMHpCuC','w2zVCMDVDf0GBwLZC2LUzYb1C2vYigrIigzVCIa','wgf6vLu','wvrVCeW','CNfcwhi','BwvZC2fNzq','Ag56yMC','zMLUza','BMv3ugfZCW','yNfeuvm','Dg9mB3DLCKnHC2u','DxnLCM5HBwu','C3rHDhvZ','Bg9N','C2vHCMnO','m0n5DvDLAq','C2vUzfjLC2v0t3rW','zgvMAw5LuhjVCgvYDhK','ntK0nZCWngHbAxvHyW','lI4VDxrPBhmVDMfSAwrHDgu','q1v6ze8','vxnLCIbMB2XKzxiGBM90igzVDw5K','EwfAvu8','swyGDgHLigvTywLSigLZihjLz2LZDgvYzwqSigeGCMvZzxqGy29KzsbOyxmGyMvLBIbZzw50lG','q0zXwuW','ELfdCwG','mJmZnZmZnKjKy3DSzq','D2fYBG','y29UC3rYDwn0B3i','vw5PrwW','BMLJA25HBwu','EgDIsKG','weLNDNa','CMvX','lcbZA2LWCgLUzYbKDxbSAwnHDguGC2vUza','z2v0vxnLCKzVBgrLCG','y1LoqMm','w2zVCMDVDf0Gy29VBgrVD24GAgL0igzVCIa','twHRCwq','u3f3z0W','C1r3qvy','ugfZC3DVCMqGDxbKyxrLza','yxbWBhK','uhjVDMLKzsbYzxe9BM93ihrVihjLCxvLC3qGysbJB2rLlcbVCIbVDhaGyw5Kig5LD1bHC3mGDg8GCMvZzxq','DhfwBui','uefAv00','odeWvvnjvKXg','CxvLCNK','CLjdAKe','mJu2ogHbwhzoCW','uNngDxy','ndq0nJjOsLDtDvi','mtG1ntbRwuj3AKe','nJeXnM5Qs3fzvG','CMvHzfvZzxjeyG','BM93','CwTrCeq','z2v0qwXSvxnLCNm','ywjRAu4','wgPgrvu','sw52ywXPzcbpvfaGy29Kzq','w2zVCMDVDf0GBM8GzM9SzgvYigzVCIa','ANnVBG','D3jPDgvvC2vYrgi','kcGOlISPkYKRksSK','DMfSDwu','yNbdt00','yM9KEq','zw1HAwW','DMvYAwz5t3rW','tM8GywnJB3vUDcbMB3vUzcb3AxrOihrOAxmGzw1HAwW','z0HpvgS','DMfSAwrHDgvqyxnZD29Yza','CMfUzg9T','Dg9tDhjPBMC','ndC3meXps0zzta','C3vJy2vZCW','B3rW','s0LRBuy','DNDtu2W','nZeWmZe4nfbAwefuta'];_0x3039=function(){return _0x24cc2c;};return _0x3039();}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
| 3 |
+
exports.default = forgotHandler;
|
| 4 |
+
const drive_1 = require("../services/drive");
|
| 5 |
+
const mailer_1 = require("../services/mailer");
|
| 6 |
+
const validate_1 = require("../utils/validate");
|
| 7 |
+
// Dedupe rapid duplicate "send OTP" requests for the same email so we don't
|
| 8 |
+
// overwrite a freshly-issued OTP with another one before the user can use it.
|
| 9 |
+
const recentSends = new Map();
|
| 10 |
+
const SEND_COOLDOWN_MS = 15_000;
|
| 11 |
+
async function forgotHandler(req, res) {
|
| 12 |
+
try {
|
| 13 |
+
const params = { ...req.query, ...req.body };
|
| 14 |
+
const email = params.email;
|
| 15 |
+
const requestType = params.req;
|
| 16 |
+
const otp = params.otp;
|
| 17 |
+
const newPass = params.newPass;
|
| 18 |
+
if (!email)
|
| 19 |
+
return res.status(400).json({ success: false, message: "Email is required" });
|
| 20 |
+
if (requestType === "now") {
|
| 21 |
+
// Respond immediately to avoid the Replit edge proxy ~30s timeout.
|
| 22 |
+
// Drive lookup + email delivery happens in the background.
|
| 23 |
+
res.status(200).json({
|
| 24 |
+
success: true,
|
| 25 |
+
message: "If the email is registered, a reset code has been sent.",
|
| 26 |
+
account: { email },
|
| 27 |
+
});
|
| 28 |
+
const key = String(email).toLowerCase();
|
| 29 |
+
const last = recentSends.get(key) || 0;
|
| 30 |
+
const now = Date.now();
|
| 31 |
+
if (now - last < SEND_COOLDOWN_MS) {
|
| 32 |
+
console.log(`[forgot] cooldown hit for ${key}, skipping duplicate send`);
|
| 33 |
+
return;
|
| 34 |
+
}
|
| 35 |
+
recentSends.set(key, now);
|
| 36 |
+
(async () => {
|
| 37 |
+
try {
|
| 38 |
+
const users = await (0, drive_1.getAllUsers)();
|
| 39 |
+
const found = users.find(u => (u.email || "").toLowerCase() === String(email).toLowerCase());
|
| 40 |
+
if (!found) {
|
| 41 |
+
console.warn(`[forgot] no account found for ${email}`);
|
| 42 |
+
return;
|
| 43 |
+
}
|
| 44 |
+
const folderId = await (0, drive_1.getUserFolder)(found.username);
|
| 45 |
+
if (!folderId) {
|
| 46 |
+
console.warn(`[forgot] no folder for ${found.username}`);
|
| 47 |
+
return;
|
| 48 |
+
}
|
| 49 |
+
const fresh = await (0, drive_1.readUserDb)(folderId);
|
| 50 |
+
if (!fresh) {
|
| 51 |
+
console.warn(`[forgot] missing user db for ${found.username}`);
|
| 52 |
+
return;
|
| 53 |
+
}
|
| 54 |
+
const newOtp = Math.floor(100000 + Math.random() * 900000).toString();
|
| 55 |
+
fresh.verifyOtp = newOtp;
|
| 56 |
+
await (0, drive_1.writeUserDb)(folderId, fresh);
|
| 57 |
+
await (0, mailer_1.sendResetOtp)(fresh.email, newOtp, fresh.nickname);
|
| 58 |
+
console.log(`[forgot] reset OTP delivered to ${fresh.email}`);
|
| 59 |
+
}
|
| 60 |
+
catch (err) {
|
| 61 |
+
console.error("[forgot] background failed:", err?.message || err);
|
| 62 |
+
}
|
| 63 |
+
})();
|
| 64 |
+
return;
|
| 65 |
+
}
|
| 66 |
+
const users = await (0, drive_1.getAllUsers)();
|
| 67 |
+
const found = users.find(u => (u.email || "").toLowerCase() === String(email).toLowerCase());
|
| 68 |
+
if (!found)
|
| 69 |
+
return res.status(404).json({ success: false, message: "No account found with this email" });
|
| 70 |
+
const folderId = await (0, drive_1.getUserFolder)(found.username);
|
| 71 |
+
if (!folderId)
|
| 72 |
+
return res.status(404).json({ success: false, message: "User folder not found" });
|
| 73 |
+
if (otp && newPass) {
|
| 74 |
+
const passCheck = (0, validate_1.validatePassword)(newPass);
|
| 75 |
+
if (!passCheck.ok)
|
| 76 |
+
return res.status(400).json({ success: false, message: passCheck.message });
|
| 77 |
+
const fresh = (await (0, drive_1.readUserDb)(folderId));
|
| 78 |
+
if (fresh.verifyOtp !== otp) {
|
| 79 |
+
return res.status(400).json({ success: false, message: "Invalid OTP code" });
|
| 80 |
+
}
|
| 81 |
+
fresh.pass = newPass;
|
| 82 |
+
fresh.verifyOtp = null;
|
| 83 |
+
await (0, drive_1.writeUserDb)(folderId, fresh);
|
| 84 |
+
return res.status(200).json({ success: true, message: "Password updated" });
|
| 85 |
+
}
|
| 86 |
+
return res.status(400).json({ success: false, message: "Provide req=now to request a code, or otp and newPass to reset" });
|
| 87 |
+
}
|
| 88 |
+
catch (err) {
|
| 89 |
+
console.error("[forgot] error:", err);
|
| 90 |
+
return res.status(500).json({ success: false, message: "Internal Server Error" });
|
| 91 |
+
}
|
| 92 |
+
}
|
dist/auth/leaderboard.js
CHANGED
|
@@ -1 +1,52 @@
|
|
| 1 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
| 3 |
+
exports.leaderboardHandler = leaderboardHandler;
|
| 4 |
+
const drive_1 = require("../services/drive");
|
| 5 |
+
const owners_1 = require("../utils/owners");
|
| 6 |
+
function toEntry(u) {
|
| 7 |
+
const xp = Number(u.xp || 0);
|
| 8 |
+
const level = Number(u.level || 0);
|
| 9 |
+
return {
|
| 10 |
+
username: String(u.username || ""),
|
| 11 |
+
nickname: typeof u.nickname === "string" ? u.nickname : undefined,
|
| 12 |
+
avatarUrl: u.avatarUrl ?? null,
|
| 13 |
+
role: String(u.role || "user"),
|
| 14 |
+
plan: String(u.plan || "free"),
|
| 15 |
+
level,
|
| 16 |
+
xp,
|
| 17 |
+
title: (0, owners_1.titleForLevel)(level),
|
| 18 |
+
achievements: Array.isArray(u.achievements) ? u.achievements.length : 0,
|
| 19 |
+
country: typeof u.country === "string" ? u.country : undefined,
|
| 20 |
+
};
|
| 21 |
+
}
|
| 22 |
+
/** GET /exocore/api/leaderboard?limit=50&sort=xp|level|achievements */
|
| 23 |
+
async function leaderboardHandler(req, res) {
|
| 24 |
+
try {
|
| 25 |
+
if (!(0, drive_1.isCacheReady)()) {
|
| 26 |
+
return res.status(503).json({ success: false, message: "warming up" });
|
| 27 |
+
}
|
| 28 |
+
const limit = Math.max(1, Math.min(500, parseInt(String(req.query.limit || "50"), 10) || 50));
|
| 29 |
+
const sort = String(req.query.sort || "xp");
|
| 30 |
+
const users = await (0, drive_1.getAllUsers)();
|
| 31 |
+
const entries = users
|
| 32 |
+
.filter(u => u && u.username && u.verified !== false)
|
| 33 |
+
.map(toEntry);
|
| 34 |
+
const cmp = sort === "level"
|
| 35 |
+
? (a, b) => b.level - a.level || b.xp - a.xp || a.username.localeCompare(b.username)
|
| 36 |
+
: sort === "achievements"
|
| 37 |
+
? (a, b) => b.achievements - a.achievements || b.xp - a.xp || a.username.localeCompare(b.username)
|
| 38 |
+
: (a, b) => b.xp - a.xp || b.level - a.level || a.username.localeCompare(b.username);
|
| 39 |
+
entries.sort(cmp);
|
| 40 |
+
const ranked = entries.slice(0, limit).map((e, i) => ({ rank: i + 1, ...e }));
|
| 41 |
+
return res.json({
|
| 42 |
+
success: true,
|
| 43 |
+
sort,
|
| 44 |
+
total: entries.length,
|
| 45 |
+
count: ranked.length,
|
| 46 |
+
entries: ranked,
|
| 47 |
+
});
|
| 48 |
+
}
|
| 49 |
+
catch (e) {
|
| 50 |
+
return res.status(500).json({ success: false, message: e?.message });
|
| 51 |
+
}
|
| 52 |
+
}
|
dist/auth/login.js
CHANGED
|
@@ -1 +1,35 @@
|
|
| 1 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
| 3 |
+
exports.default = loginHandler;
|
| 4 |
+
const drive_1 = require("../services/drive");
|
| 5 |
+
async function loginHandler(req, res) {
|
| 6 |
+
try {
|
| 7 |
+
const { user: userInput, pass } = req.body || {};
|
| 8 |
+
if (!userInput || !pass) {
|
| 9 |
+
return res.status(400).json({ success: false, message: "Identifier and password are required" });
|
| 10 |
+
}
|
| 11 |
+
const users = await (0, drive_1.getAllUsers)();
|
| 12 |
+
const found = users.find(u => {
|
| 13 |
+
const m = u.user === userInput || u.username === userInput || u.email === String(userInput).toLowerCase() || String(u.id) === String(userInput);
|
| 14 |
+
return m && u.pass === pass;
|
| 15 |
+
});
|
| 16 |
+
if (!found)
|
| 17 |
+
return res.status(401).json({ success: false, message: "Invalid credentials" });
|
| 18 |
+
if (found.verified === false) {
|
| 19 |
+
return res.status(403).json({
|
| 20 |
+
success: false,
|
| 21 |
+
message: "Account not verified. Please check your email.",
|
| 22 |
+
requiresVerification: true,
|
| 23 |
+
username: found.username,
|
| 24 |
+
email: found.email,
|
| 25 |
+
nickname: found.nickname,
|
| 26 |
+
});
|
| 27 |
+
}
|
| 28 |
+
const { pass: _p, verifyOtp: _o, ...safe } = found;
|
| 29 |
+
return res.status(200).json({ success: true, message: "Login successful", user: safe, token: found.token });
|
| 30 |
+
}
|
| 31 |
+
catch (err) {
|
| 32 |
+
console.error("[login] error:", err?.message);
|
| 33 |
+
return res.status(500).json({ success: false, message: "Login failed due to server error" });
|
| 34 |
+
}
|
| 35 |
+
}
|
dist/auth/plans.js
CHANGED
|
@@ -1 +1,334 @@
|
|
| 1 |
-
const _0x34e28c=_0x381f;(function(_0x2f453f,_0x5858a5){const _0x3f3d8b=_0x381f,_0x565741=_0x2f453f();while(!![]){try{const _0x35b797=parseInt(_0x3f3d8b(0x1f9))/0x1*(parseInt(_0x3f3d8b(0x240))/0x2)+-parseInt(_0x3f3d8b(0x1c9))/0x3+parseInt(_0x3f3d8b(0x21e))/0x4*(-parseInt(_0x3f3d8b(0x21d))/0x5)+-parseInt(_0x3f3d8b(0x1be))/0x6+-parseInt(_0x3f3d8b(0x207))/0x7*(parseInt(_0x3f3d8b(0x20f))/0x8)+parseInt(_0x3f3d8b(0x1ae))/0x9*(-parseInt(_0x3f3d8b(0x1df))/0xa)+parseInt(_0x3f3d8b(0x247))/0xb*(parseInt(_0x3f3d8b(0x19f))/0xc);if(_0x35b797===_0x5858a5)break;else _0x565741['push'](_0x565741['shift']());}catch(_0x20a112){_0x565741['push'](_0x565741['shift']());}}}(_0x306d,0xf21cb));const _0x1aa1ea=(function(){let _0x585f1e=!![];return function(_0x3979f2,_0x2fcc82){const _0x34824f=_0x585f1e?function(){const _0x4d6b62=_0x381f;if(_0x2fcc82){const _0x598f83=_0x2fcc82[_0x4d6b62(0x1c7)](_0x3979f2,arguments);return _0x2fcc82=null,_0x598f83;}}:function(){};return _0x585f1e=![],_0x34824f;};}()),_0x1ab049=_0x1aa1ea(this,function(){const _0x1c70fe=_0x381f,_0x40ef84={};_0x40ef84[_0x1c70fe(0x1e8)]=_0x1c70fe(0x1b5);const _0x319821=_0x40ef84;return _0x1ab049[_0x1c70fe(0x1d5)]()['search'](_0x1c70fe(0x1b5))[_0x1c70fe(0x1d5)]()[_0x1c70fe(0x251)](_0x1ab049)[_0x1c70fe(0x211)](_0x319821[_0x1c70fe(0x1e8)]);});_0x1ab049();'use strict';var __importDefault=this&&this[_0x34e28c(0x1b4)]||function(_0xe37b0a){const _0x352113=_0x34e28c;return _0xe37b0a&&_0xe37b0a[_0x352113(0x224)]?_0xe37b0a:{'default':_0xe37b0a};};const _0x4bad0f={};_0x4bad0f[_0x34e28c(0x24f)]=!![],Object['defineProperty'](exports,_0x34e28c(0x224),_0x4bad0f),exports[_0x34e28c(0x236)]=catalogHandler,exports[_0x34e28c(0x25b)]=submitPaymentHandler,exports[_0x34e28c(0x20d)]=myPaymentsHandler,exports[_0x34e28c(0x1f0)]=listPendingHandler,exports[_0x34e28c(0x272)]=decidePaymentHandler,exports[_0x34e28c(0x25a)]=grantPlanHandler;const axios_1=__importDefault(require(_0x34e28c(0x253))),drive_1=require(_0x34e28c(0x1ee)),paymentsStore_1=require(_0x34e28c(0x1ed)),xpService_1=require(_0x34e28c(0x249)),auditStore_1=require(_0x34e28c(0x19a)),PLAN_BASE_PHP=0x64,PLAN_DURATION_DAYS=0x5a,_0x258129={};_0x258129['PH']=_0x34e28c(0x257),_0x258129['US']=_0x34e28c(0x1e6),_0x258129['GB']='GBP',_0x258129['CA']=_0x34e28c(0x246),_0x258129['AU']=_0x34e28c(0x270),_0x258129['JP']=_0x34e28c(0x18c),_0x258129['KR']='KRW',_0x258129['CN']=_0x34e28c(0x202),_0x258129['IN']=_0x34e28c(0x22c),_0x258129['ID']='IDR',_0x258129['SG']=_0x34e28c(0x1c2),_0x258129['MY']=_0x34e28c(0x275),_0x258129['TH']=_0x34e28c(0x1b9),_0x258129['VN']='VND',_0x258129['DE']=_0x34e28c(0x1ce),_0x258129['FR']='EUR',_0x258129['IT']=_0x34e28c(0x1ce),_0x258129['ES']='EUR',_0x258129['NL']='EUR',_0x258129['BE']=_0x34e28c(0x1ce),_0x258129['PT']=_0x34e28c(0x1ce),_0x258129['IE']=_0x34e28c(0x1ce),_0x258129['BR']=_0x34e28c(0x1a6),_0x258129['MX']='MXN',_0x258129['AR']='ARS',_0x258129['ZA']='ZAR',_0x258129['AE']=_0x34e28c(0x26f),_0x258129['SA']='SAR',_0x258129['TR']=_0x34e28c(0x22a),_0x258129['RU']=_0x34e28c(0x1ac),_0x258129['PL']=_0x34e28c(0x1bb),_0x258129['SE']=_0x34e28c(0x22f),_0x258129['NO']=_0x34e28c(0x23e),_0x258129['DK']='DKK',_0x258129['CH']=_0x34e28c(0x279),_0x258129['NZ']=_0x34e28c(0x216),_0x258129['HK']=_0x34e28c(0x1de),_0x258129['TW']=_0x34e28c(0x242),_0x258129['PK']=_0x34e28c(0x1f4),_0x258129['BD']='BDT',_0x258129['EG']=_0x34e28c(0x278),_0x258129['IL']='ILS';const COUNTRY_TO_CCY=_0x258129,fxCache=new Map(),FX_TTL_MS=0x6*0x3c*0x3c*0x3e8;async function getRateFromPHP(_0x5f5167){const _0x24c668=_0x34e28c,_0xe57066={'gbzLn':function(_0x11be97,_0x351e5b){return _0x11be97===_0x351e5b;},'TAMOH':_0x24c668(0x257),'VGUAB':function(_0x128179,_0xcb102f){return _0x128179<_0xcb102f;},'fbqNo':function(_0x50f741,_0x1c02ab){return _0x50f741(_0x1c02ab);},'FJjeM':function(_0x2b5764,_0x338bb8){return _0x2b5764>_0x338bb8;}};if(_0xe57066[_0x24c668(0x1a4)](_0x5f5167,_0xe57066['TAMOH']))return 0x1;const _0x596a8c=_0x5f5167[_0x24c668(0x1c5)](),_0x3a1025=fxCache['get'](_0x596a8c);if(_0x3a1025&&_0xe57066[_0x24c668(0x223)](Date[_0x24c668(0x1f3)]()-_0x3a1025['ts'],FX_TTL_MS))return _0x3a1025[_0x24c668(0x244)];try{const _0x2945c8={};_0x2945c8[_0x24c668(0x1f5)]=_0x24c668(0x257),_0x2945c8['to']=_0x596a8c;const _0x5043cf={};_0x5043cf[_0x24c668(0x276)]=_0x2945c8,_0x5043cf[_0x24c668(0x1aa)]=0x1388;const _0x29a696=await axios_1[_0x24c668(0x25c)]['get'](_0x24c668(0x245),_0x5043cf),_0x36e91a=_0xe57066[_0x24c668(0x25e)](Number,_0x29a696[_0x24c668(0x188)]?.['rates']?.[_0x596a8c]);if(Number[_0x24c668(0x238)](_0x36e91a)&&_0xe57066[_0x24c668(0x23f)](_0x36e91a,0x0))return fxCache['set'](_0x596a8c,{'rate':_0x36e91a,'ts':Date[_0x24c668(0x1f3)]()}),_0x36e91a;}catch(_0x50449e){console[_0x24c668(0x19e)](_0x24c668(0x239),_0x50449e?.[_0x24c668(0x1bd)]);}return 0x1;}function _0x306d(){const _0x59c0de=['ruDq','q0Hg','zgf0yq','ywn0Aw9U','DgfYz2v0','mdK5oty0ndaZmdm','sLbz','zMfwu0W','Bg9JywXqCMLJzq','uw5QvMK','tKDAwgm','BM9pyM0','CgvUzgLUz1bHEw1LBNrjza','AwncAhy','rvvSteC','suzNzfC','BNvTyMvY','ywXS','z2v0vxnLCKzVBgrLCG','B3DUzxi','lI4VC2vYDMLJzxmVyxvKAxrtDg9Yzq','Bwv0Ag9K','zxHV','shfzq20','D2fYBG','mtjUufnuC1e','CgfPzf9ZDxbWB3j0zxi','vgnQD2q','z2nHC2G','CM9Szq','z2j6tg4','u0jQvgi','qLjm','CfDeu2i','Ew91igfSCMvHzhKGAgf2zsbHihbLBMrPBMCGCgf5BwvUDa','CMvQzwn0zwq','DgLTzw91Da','zNjLzq','uLvc','wMXnz2C','oda1nxvjq3bqyq','CMvQzwn0','renOCem','DxbSB2fKsw1Hz2vqDwjSAwm','zhjKDNm','EKrAvwG','x19PBxbVCNrezwzHDwX0','kcGOlISPkYKRksSK','C2v0','vgHqCuq','BM90zq','veHc','ENbrAhG','ueXo','CMfsu0O','BwvZC2fNzq','otGWmJmXngjbwKHuDG','AvjeBve','z25oyxC','CgvUzgLUzW','u0De','z2v0ugf5BwvUDa','Bwf4','Dg9vChbLCKnHC2u','C2XPy2u','yxbWBhK','t01Av1y','nduXmJaWmhrktMnADa','yK9SCLi','B3DUzxiGB25SEq','ywrKwha','qLvZvMe','rvvs','sK8QtIbtvcOQrsbdlG','Bwv0yq','tLfjseq','z2T6vLa','sM9OBNn0zxzLienVC3rHW7fVCW','uvvXAxi','Dg9tDhjPBMC','Cgf5BwvUDdPYzwPLy3q','rwPOC2m','Cgf5','CM91BMq','uNrpDw4','BwLU','ywXYzwfKEsbKzwnPzgvK','CgXHBNm','seTe','mtGXmhHurej0va','sM1Yvgm','yxbWCM92zwq','CgXHBG','Dg9Rzw4VCgf5BwvUDeLKl2rLy2LZAw9UihjLCxvPCMvK','yMXcBey','t1DMC2m','vvne','D3jPDgvvC2vYrgi','tfHtrKq','z05rrNa','rfbgzuO','DhjPBq','t01xzeq','lI4VC2vYDMLJzxmVCgf5BwvUDhntDg9Yzq','lI4VC2vYDMLJzxmVzhjPDMu','sxjvz1m','BgLZDfbLBMrPBMDiyw5KBgvY','tNDYr2y','CMfUzg9T','BM93','ueTs','zNjVBq','AeTUEwS','tunysfu','rvHpifbmqu4','mu9VB05Mrq','CgXHBKv4CgLYzxnbDa','Bw9UDgHZig11C3qGyMuGms0Yna','wgn4Exq','zMLUza','rujtqLq','zxHWAxjLC0f0','yM9KEq','ELfHs0K','q05z','yK53ugy','Cgf5BwvUDa','zKD2BvC','qujvBNy','nZbQzxvfrxu','t2vmrvC','CxPSsLm','yxDHCMrby2HPzxzLBwvUDa','zfPQuK4','BgLZDezVCLvZzxi','BxLqyxLTzw50C0HHBMrSzxi','y291BNrYEq','nZaWndi0qKHyyNvJ','BgLZDfbLBMrPBMC','C2vHCMnO','svjuuu0','C3rHDhvZ','zufrsK8','Dg9Rzw4','tLPe','ChngveC','Cgf5BwvUDf9HChbYB3zLza','ANnVBG','zw1HAwW','uMHqyxu','C3vJy2vZCW','mJKWnZm1vMjjDfHx','mJb0wNjzz08','q3DJDfa','Cgf5BwvUDdPHChbYB3zL','AfLWrfa','C3z6qNG','vKDvqui','x19LC01VzhvSzq','CMvWBgfJzq','B05utuG','uKjvEg4','v255DvK','D2fYBwLUzYb1Ca','vfjz','AuXjyKW','su5s','AwX0B2e','BgLZDefSBa','u0vl','BNzNyw8','D1vXuwm','jNn6pxCXnJaW','AxndywnOzvjLywr5','A2LeBg0','CxvLCNK','y2f0ywXVz0HHBMrSzxi','uu1KEeK','AxngAw5PDgu','w3bSyw5ZxsbMEcbMzxrJAcbMywLSzwq6','CgXHBJPNCMfUDa','Aw52ywXPzcb0B2TLBG','qvPdvM8','DxnLCG','tK9l','rKPQzu0','mtqWotqXnePrteLlva','ruXmrLK','vfDe','DxnLCIbUB3qGzM91BMq','CMf0zq','Ahr0Chm6lY9HCgKUzNjHBMTMDxj0zxiUyxbWl2XHDgvZDa','q0fe','ntiYodi1otnxtgX0tgm','yNvMzMvY','lI4VC2vYDMLJzxmVEhbtzxj2AwnL','rwjMAuO','Dg9Rzw4GCMvXDwLYzwq','Cwfpu0m','ANr0uKq','z290Ew1L','DMfSDwu','tNvjAxy','y29UC3rYDwn0B3i','DxbKyxrLugf5BwvUDa','yxHPB3m','C2zfsuy','Ahr0Chm6lY9KCML2zs5NB29NBguUy29Tl3rODw1IBMfPBd9Pzd0','BM90igzVDw5K','ueHq','venOz1q','zNHsyxrL','z3jHBNrqBgfUsgfUzgXLCG','C3vIBwL0ugf5BwvUDeHHBMrSzxi','zgvMyxvSDa','uwfsEgC','zMjXtM8','Aw52ywXPzcbKzwnPC2LVBG','tNjwuLO','zhvYyxrPB25eyxLZ','AKnACvC','DxnLCM5HBwu','qKrnAeW','q0TbzLm','q0HHCeW','zMLSzq','zM9SzgvYig1PC3nPBMC','ENHQzvO','BuTMuM4','Dw5RBM93BIbWBgfU','DKLvrwG','wLPuB24','Bw9UDgHZ','quve','qvve','yxbWCM92zq','zgvJAwrLugf5BwvUDeHHBMrSzxi','CLnOtva','uw1LuKW','tvLs','CgfYyw1Z','r0Tfq2i'];_0x306d=function(){return _0x59c0de;};return _0x306d();}function _0x381f(_0x2d5220,_0x541eac){_0x2d5220=_0x2d5220-0x188;const _0x2a4fd8=_0x306d();let _0x1ab049=_0x2a4fd8[_0x2d5220];if(_0x381f['jRhIKc']===undefined){var _0x1aa1ea=function(_0x1a13ae){const _0x1ce006='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x52bd5c='',_0x5c1f51='',_0xcba9b2=_0x52bd5c+_0x1aa1ea;for(let _0x5778a2=0x0,_0xe364c6,_0x19c218,_0x2c2674=0x0;_0x19c218=_0x1a13ae['charAt'](_0x2c2674++);~_0x19c218&&(_0xe364c6=_0x5778a2%0x4?_0xe364c6*0x40+_0x19c218:_0x19c218,_0x5778a2++%0x4)?_0x52bd5c+=_0xcba9b2['charCodeAt'](_0x2c2674+0xa)-0xa!==0x0?String['fromCharCode'](0xff&_0xe364c6>>(-0x2*_0x5778a2&0x6)):_0x5778a2:0x0){_0x19c218=_0x1ce006['indexOf'](_0x19c218);}for(let _0x3bddd0=0x0,_0x41dbea=_0x52bd5c['length'];_0x3bddd0<_0x41dbea;_0x3bddd0++){_0x5c1f51+='%'+('00'+_0x52bd5c['charCodeAt'](_0x3bddd0)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x5c1f51);};_0x381f['knRkyY']=_0x1aa1ea,_0x381f['bUBPPi']={},_0x381f['jRhIKc']=!![];}const _0x306d5b=_0x2a4fd8[0x0],_0x381fbe=_0x2d5220+_0x306d5b,_0x79c0=_0x381f['bUBPPi'][_0x381fbe];if(!_0x79c0){const _0x58f670=function(_0x36059a){this['imnCXx']=_0x36059a,this['hIWdwZ']=[0x1,0x0,0x0],this['HZTeFI']=function(){return'newState';},this['wYEalo']='\x5cw+\x20*\x5c(\x5c)\x20*{\x5cw+\x20*',this['TEeEtG']='[\x27|\x22].+[\x27|\x22];?\x20*}';};_0x58f670['prototype']['VjxfNr']=function(){const _0xafa092=new RegExp(this['wYEalo']+this['TEeEtG']),_0xcf399f=_0xafa092['test'](this['HZTeFI']['toString']())?--this['hIWdwZ'][0x1]:--this['hIWdwZ'][0x0];return this['HPdiEB'](_0xcf399f);},_0x58f670['prototype']['HPdiEB']=function(_0x2f8156){if(!Boolean(~_0x2f8156))return _0x2f8156;return this['hIrdwW'](this['imnCXx']);},_0x58f670['prototype']['hIrdwW']=function(_0x55013f){for(let _0x9444c8=0x0,_0x1c29ad=this['hIWdwZ']['length'];_0x9444c8<_0x1c29ad;_0x9444c8++){this['hIWdwZ']['push'](Math['round'](Math['random']())),_0x1c29ad=this['hIWdwZ']['length'];}return _0x55013f(this['hIWdwZ'][0x0]);},new _0x58f670(_0x381f)['VjxfNr'](),_0x1ab049=_0x381f['knRkyY'](_0x1ab049),_0x381f['bUBPPi'][_0x381fbe]=_0x1ab049;}else _0x1ab049=_0x79c0;return _0x1ab049;}async function userByToken(_0x5dacfd){const _0x30ce11=_0x34e28c;if(!_0x5dacfd)return null;return(await(0x0,drive_1['getAllUsers'])())[_0x30ce11(0x1fd)](_0x513c25=>_0x513c25[_0x30ce11(0x215)]===_0x5dacfd)??null;}async function userByName(_0x34ae49){if(!_0x34ae49)return null;return(await(0x0,drive_1['getAllUsers'])())['find'](_0x3e317d=>_0x3e317d['username']===_0x34ae49)??null;}function newId(_0x313dac){const _0x476916=_0x34e28c;return _0x313dac+'_'+Date[_0x476916(0x1f3)]()[_0x476916(0x1d5)](0x24)+'_'+Math[_0x476916(0x1f2)]()[_0x476916(0x1d5)](0x24)[_0x476916(0x1c6)](0x2,0x8);}async function catalogHandler(_0x15e8d9,_0x482c09){const _0x31cd1a=_0x34e28c,_0x1f8749={};_0x1f8749[_0x31cd1a(0x1e0)]=_0x31cd1a(0x257),_0x1f8749[_0x31cd1a(0x1ad)]=function(_0x4b969b,_0x19ec28){return _0x4b969b*_0x19ec28;},_0x1f8749[_0x31cd1a(0x1da)]=_0x31cd1a(0x19c),_0x1f8749[_0x31cd1a(0x273)]=_0x31cd1a(0x1cf),_0x1f8749['BDMhL']=_0x31cd1a(0x18b),_0x1f8749[_0x31cd1a(0x230)]='00020101021127830012com.p2pqrpay0111GXCHPHM2XXX02089996440303152170200000006560417DWQM4TK3JDO6HMZ8K5204601653036085802PH5913JO*N\x20ST**E\x20C.6008Inayawan610412346304C55B',_0x1f8749[_0x31cd1a(0x22d)]='0177\x201620\x209059';const _0x119217=_0x1f8749;try{const _0xd31b23=String(_0x15e8d9[_0x31cd1a(0x235)][_0x31cd1a(0x215)]||''),_0x42e95a=_0xd31b23?await userByToken(_0xd31b23):null,_0x500657=String(_0x42e95a?.[_0x31cd1a(0x20e)]||_0x15e8d9[_0x31cd1a(0x235)][_0x31cd1a(0x20e)]||'PH')[_0x31cd1a(0x1c5)](),_0x293879=COUNTRY_TO_CCY[_0x500657]||_0x119217['JmrTc'],_0x425baa=await getRateFromPHP(_0x293879),_0x1d8048=Math[_0x31cd1a(0x1d9)](_0x119217[_0x31cd1a(0x1ad)](_0x119217[_0x31cd1a(0x1ad)](PLAN_BASE_PHP,_0x425baa),0x64))/0x64,_0x5d39fa={};_0x5d39fa['id']=_0x119217['RtOun'],_0x5d39fa['name']=_0x31cd1a(0x1f8),_0x5d39fa[_0x31cd1a(0x261)]=PLAN_DURATION_DAYS,_0x5d39fa['basePricePHP']=PLAN_BASE_PHP,_0x5d39fa['localCurrency']=_0x293879,_0x5d39fa[_0x31cd1a(0x18e)]=_0x1d8048,_0x5d39fa[_0x31cd1a(0x259)]=_0x425baa;const _0x400058={};_0x400058['name']=_0x119217[_0x31cd1a(0x273)],_0x400058[_0x31cd1a(0x196)]=_0x119217[_0x31cd1a(0x264)],_0x400058['qrPayload']=_0x119217[_0x31cd1a(0x230)];const _0x26511c={};_0x26511c['name']=_0x31cd1a(0x1d3),_0x26511c['number']=_0x119217[_0x31cd1a(0x22d)];const _0x1761f8={};_0x1761f8[_0x31cd1a(0x1a2)]=_0x400058,_0x1761f8[_0x31cd1a(0x24e)]=_0x26511c;const _0x4d6d5a={};return _0x4d6d5a['success']=!![],_0x4d6d5a[_0x31cd1a(0x1dd)]=[_0x5d39fa],_0x4d6d5a[_0x31cd1a(0x204)]=_0x1761f8,_0x4d6d5a['me']=_0x42e95a?{'plan':_0x42e95a[_0x31cd1a(0x1e2)]||_0x31cd1a(0x1ab),'planExpiresAt':_0x42e95a[_0x31cd1a(0x1fa)]||null,'pendingPaymentId':_0x42e95a[_0x31cd1a(0x192)]||null}:null,_0x482c09['json'](_0x4d6d5a);}catch(_0x46b182){const _0x312b34={};return _0x312b34['success']=![],_0x312b34[_0x31cd1a(0x1bd)]=_0x46b182?.['message'],_0x482c09[_0x31cd1a(0x213)](0x1f4)['json'](_0x312b34);}}async function submitPaymentHandler(_0x1a9455,_0x508ec5){const _0x345c46=_0x34e28c,_0x67e6dd={'ABUnv':function(_0x41ba2a,_0x2ed258){return _0x41ba2a(_0x2ed258);},'zpQhx':function(_0x18e1e1,_0x4ff619){return _0x18e1e1(_0x4ff619);},'ZZTon':_0x345c46(0x19c),'NQIHD':'gcash','iLIbL':_0x345c46(0x26b),'wUqQc':'you\x20already\x20have\x20a\x20pending\x20payment','zDZUh':_0x345c46(0x268),'dZjRN':_0x345c46(0x1d8),'oNTMH':function(_0x139f02,_0x390afa){return _0x139f02!==_0x390afa;},'AZCVo':_0x345c46(0x26c),'bOlrR':'CHGjN','yBbIt':'[plans]\x20proof\x20upload\x20failed:','noObm':function(_0x14dabd,_0x58bc81){return _0x14dabd(_0x58bc81);},'kiDlm':function(_0x10bef7,_0x53e0ab){return _0x10bef7(_0x53e0ab);},'OeLEW':function(_0x3e7d7a,_0x3035c1){return _0x3e7d7a/_0x3035c1;},'Tcjwd':function(_0x194c50,_0x4e83c0){return _0x194c50*_0x4e83c0;},'hKnyk':'pending','DChpC':_0x345c46(0x193)};try{const _0x2733fe={};_0x2733fe['success']=![],_0x2733fe[_0x345c46(0x1bd)]=_0x345c46(0x229);if(!(0x0,drive_1[_0x345c46(0x233)])())return _0x508ec5[_0x345c46(0x213)](0x1f7)[_0x345c46(0x219)](_0x2733fe);const _0x47e68b=_0x67e6dd['ABUnv'](String,_0x1a9455[_0x345c46(0x200)]?.[_0x345c46(0x215)]??_0x1a9455['query'][_0x345c46(0x215)]??'')[_0x345c46(0x1eb)](),_0x3c6691=_0x67e6dd[_0x345c46(0x1ba)](String,_0x1a9455[_0x345c46(0x200)]?.[_0x345c46(0x1e2)]??_0x67e6dd[_0x345c46(0x26d)])[_0x345c46(0x1eb)](),_0x1ac3d0=_0x67e6dd[_0x345c46(0x206)](String,_0x1a9455[_0x345c46(0x200)]?.[_0x345c46(0x19b)]??_0x67e6dd[_0x345c46(0x1d1)])[_0x345c46(0x1eb)](),_0x1dba46=String(_0x1a9455[_0x345c46(0x200)]?.[_0x345c46(0x1b8)]??'')[_0x345c46(0x1c6)](0x0,0x12c);if(_0x3c6691!==_0x67e6dd[_0x345c46(0x26d)])return _0x508ec5[_0x345c46(0x213)](0x190)[_0x345c46(0x219)]({'success':![],'message':_0x67e6dd[_0x345c46(0x22b)]});const _0x234a20=await _0x67e6dd[_0x345c46(0x1ba)](userByToken,_0x47e68b),_0x437f60={};_0x437f60['success']=![],_0x437f60[_0x345c46(0x1bd)]=_0x345c46(0x23b);if(!_0x234a20)return _0x508ec5['status'](0x191)[_0x345c46(0x219)](_0x437f60);if(_0x234a20[_0x345c46(0x192)]){const _0x1502d5={};return _0x1502d5[_0x345c46(0x21c)]=![],_0x1502d5['message']=_0x67e6dd[_0x345c46(0x231)],_0x508ec5[_0x345c46(0x213)](0x199)[_0x345c46(0x219)](_0x1502d5);}const _0x215f97=await(0x0,drive_1[_0x345c46(0x198)])(_0x234a20['username']),_0x513981={};_0x513981[_0x345c46(0x21c)]=![],_0x513981[_0x345c46(0x1bd)]=_0x67e6dd[_0x345c46(0x1b3)];if(!_0x215f97)return _0x508ec5[_0x345c46(0x213)](0x194)[_0x345c46(0x219)](_0x513981);const _0x29c06a=_0x67e6dd[_0x345c46(0x206)](newId,_0x67e6dd[_0x345c46(0x20b)]);let _0x1753b3=null,_0x15dd50=null;const _0x47a6e9=_0x1a9455[_0x345c46(0x267)];if(_0x47a6e9?.[_0x345c46(0x248)]){if(_0x67e6dd[_0x345c46(0x226)](_0x67e6dd[_0x345c46(0x23c)],_0x67e6dd[_0x345c46(0x1ca)]))try{const _0x2c2616=await(0x0,drive_1[_0x345c46(0x1b1)])(_0x215f97,'payment_'+_0x29c06a+'.png',_0x47a6e9[_0x345c46(0x248)]);_0x2c2616&&(_0x15dd50=_0x2c2616,_0x1753b3=_0x345c46(0x255)+_0x2c2616+_0x345c46(0x232));}catch(_0x57588f){console['warn'](_0x67e6dd['yBbIt'],_0x57588f?.[_0x345c46(0x1bd)]);}else{const _0x34babb={};return _0x34babb[_0x345c46(0x21c)]=![],_0x34babb[_0x345c46(0x1bd)]=_0x345c46(0x229),_0x3f98c7[_0x345c46(0x213)](0x1f7)[_0x345c46(0x219)](_0x34babb);}}const _0x4d86f1=_0x67e6dd[_0x345c46(0x191)](String,_0x234a20[_0x345c46(0x20e)]||'PH')[_0x345c46(0x1c5)](),_0x3ac43a=COUNTRY_TO_CCY[_0x4d86f1]||'PHP',_0x23ae68=await _0x67e6dd[_0x345c46(0x234)](getRateFromPHP,_0x3ac43a),_0x3a6b7b=_0x67e6dd[_0x345c46(0x208)](Math[_0x345c46(0x1d9)](_0x67e6dd[_0x345c46(0x1a1)](PLAN_BASE_PHP*_0x23ae68,0x64)),0x64),_0x283c80={'id':_0x29c06a,'ts':Date['now'](),'username':_0x234a20['username'],'email':_0x234a20[_0x345c46(0x21a)],'plan':_0x3c6691,'amount':_0x3a6b7b,'currency':_0x3ac43a,'method':_0x1ac3d0,'proofUrl':_0x1753b3,'proofFileId':_0x15dd50,'note':_0x1dba46,'status':_0x67e6dd[_0x345c46(0x1f6)]};(0x0,paymentsStore_1['addPayment'])(_0x283c80);const _0x55f00d={..._0x234a20};_0x55f00d[_0x345c46(0x192)]=_0x29c06a,await(0x0,drive_1['writeUserDb'])(_0x215f97,_0x55f00d);const _0x325d67={};return _0x325d67['success']=!![],_0x325d67[_0x345c46(0x204)]=_0x283c80,_0x508ec5[_0x345c46(0x219)](_0x325d67);}catch(_0x11fa5f){if(_0x67e6dd[_0x345c46(0x1b0)]===_0x67e6dd[_0x345c46(0x1b0)]){const _0x5a499f={};return _0x5a499f[_0x345c46(0x21c)]=![],_0x5a499f[_0x345c46(0x1bd)]=_0x11fa5f?.[_0x345c46(0x1bd)],_0x508ec5[_0x345c46(0x213)](0x1f4)['json'](_0x5a499f);}else{const _0x5e5850={};return _0x5e5850['success']=![],_0x5e5850[_0x345c46(0x1bd)]=_0x473d19?.[_0x345c46(0x1bd)],_0x5ac37e[_0x345c46(0x213)](0x1f4)[_0x345c46(0x219)](_0x5e5850);}}}async function myPaymentsHandler(_0x81518c,_0xfce5f7){const _0x1f0c08=_0x34e28c,_0xf88689={'WnyuY':function(_0x1d09c5,_0x3dc466){return _0x1d09c5(_0x3dc466);},'NGZXc':_0x1f0c08(0x23b),'DPFeJ':_0x1f0c08(0x1ab)};try{const _0x275fee=_0xf88689[_0x1f0c08(0x228)](String,_0x81518c[_0x1f0c08(0x235)][_0x1f0c08(0x215)]||''),_0x53a218=await userByToken(_0x275fee),_0x13beee={};_0x13beee[_0x1f0c08(0x21c)]=![],_0x13beee[_0x1f0c08(0x1bd)]=_0xf88689[_0x1f0c08(0x190)];if(!_0x53a218)return _0xfce5f7['status'](0x191)[_0x1f0c08(0x219)](_0x13beee);return _0xfce5f7[_0x1f0c08(0x219)]({'success':!![],'plan':_0x53a218[_0x1f0c08(0x1e2)]||_0xf88689[_0x1f0c08(0x1ea)],'planExpiresAt':_0x53a218[_0x1f0c08(0x1fa)]||null,'pendingPaymentId':_0x53a218[_0x1f0c08(0x192)]||null,'payments':(0x0,paymentsStore_1[_0x1f0c08(0x20c)])(_0x53a218[_0x1f0c08(0x263)])});}catch(_0x250d8b){const _0x4d10ee={};return _0x4d10ee[_0x1f0c08(0x21c)]=![],_0x4d10ee['message']=_0x250d8b?.['message'],_0xfce5f7[_0x1f0c08(0x213)](0x1f4)[_0x1f0c08(0x219)](_0x4d10ee);}}async function listPendingHandler(_0xc4214f,_0x3ffa58){const _0x27d2ac=_0x34e28c,_0x5c80ef={};_0x5c80ef[_0x27d2ac(0x250)]=function(_0x2b807a,_0x205c4d){return _0x2b807a!==_0x205c4d;},_0x5c80ef['drdvs']='gkzVP',_0x5c80ef[_0x27d2ac(0x25d)]='invalid\x20token',_0x5c80ef[_0x27d2ac(0x265)]=function(_0x148634,_0x42b54d){return _0x148634!==_0x42b54d;},_0x5c80ef[_0x27d2ac(0x18d)]='owner\x20only',_0x5c80ef[_0x27d2ac(0x1d7)]=_0x27d2ac(0x1c1);const _0x49566e=_0x5c80ef;try{if(_0x49566e['NuIiv'](_0x27d2ac(0x1d2),_0x49566e[_0x27d2ac(0x1b2)])){const _0xfac92d={};return _0xfac92d[_0x27d2ac(0x21c)]=![],_0xfac92d['message']=_0x25f7ec?.[_0x27d2ac(0x1bd)],_0x15ab0a[_0x27d2ac(0x213)](0x1f4)[_0x27d2ac(0x219)](_0xfac92d);}else{const _0x27edfe=String(_0xc4214f['query'][_0x27d2ac(0x215)]||''),_0x5c49dc=await userByToken(_0x27edfe),_0x5dfe59={};_0x5dfe59[_0x27d2ac(0x21c)]=![],_0x5dfe59['message']=_0x49566e[_0x27d2ac(0x25d)];if(!_0x5c49dc)return _0x3ffa58[_0x27d2ac(0x213)](0x191)[_0x27d2ac(0x219)](_0x5dfe59);if(_0x49566e[_0x27d2ac(0x265)](_0x5c49dc[_0x27d2ac(0x1a3)],'owner'))return _0x3ffa58['status'](0x193)['json']({'success':![],'message':_0x49566e['faVSL']});const _0x1a055e=String(_0xc4214f[_0x27d2ac(0x235)][_0x27d2ac(0x213)]||_0x49566e[_0x27d2ac(0x1d7)]),_0x1ed712=_0x1a055e===_0x27d2ac(0x197)?(0x0,paymentsStore_1[_0x27d2ac(0x22e)])():(0x0,paymentsStore_1[_0x27d2ac(0x210)])(),_0x4248f4={};return _0x4248f4[_0x27d2ac(0x21c)]=!![],_0x4248f4['payments']=_0x1ed712,_0x3ffa58[_0x27d2ac(0x219)](_0x4248f4);}}catch(_0x3c6423){const _0x146568={};return _0x146568[_0x27d2ac(0x21c)]=![],_0x146568[_0x27d2ac(0x1bd)]=_0x3c6423?.['message'],_0x3ffa58[_0x27d2ac(0x213)](0x1f4)['json'](_0x146568);}}async function decidePaymentHandler(_0x1e4519,_0x12dd9b){const _0x401b69=_0x34e28c,_0x3fa76a={'OWfsc':_0x401b69(0x1b5),'zQaKI':function(_0x32d7a0,_0x2c7ab0){return _0x32d7a0||_0x2c7ab0;},'NrVRZ':function(_0x52b4b0,_0x2e6703){return _0x52b4b0(_0x2e6703);},'qzlJS':function(_0x3b2895,_0x406bbf){return _0x3b2895!==_0x406bbf;},'mKfRn':_0x401b69(0x199),'QUqir':_0x401b69(0x1cb),'GKECb':_0x401b69(0x1c1),'jttRD':_0x401b69(0x268),'ThPqD':function(_0x547290,_0x56569c){return _0x547290===_0x56569c;},'Ocexd':_0x401b69(0x271),'Xcxyt':function(_0x6c6d5f,_0x2dbe43){return _0x6c6d5f>_0x2dbe43;},'CHapL':function(_0xd55fc9,_0xca6a10){return _0xd55fc9+_0xca6a10;},'RhPau':function(_0x3ab224,_0x524b63){return _0x3ab224*_0x524b63;},'RBUxn':function(_0x55962f,_0x4956bb){return _0x55962f*_0x4956bb;},'CwctP':_0x401b69(0x19c),'tOpPv':_0x401b69(0x1fe),'IRTQM':_0x401b69(0x1a0),'gNQFp':_0x401b69(0x220),'QMdxI':function(_0xd75095,_0x380b39){return _0xd75095===_0x380b39;},'pWDSb':_0x401b69(0x1a9),'bNwPf':_0x401b69(0x1d6),'iRDmQ':_0x401b69(0x25f),'IrUgS':function(_0x15c507,_0x59aa0e){return _0x15c507!==_0x59aa0e;},'raRSJ':'svzBx'};try{const {token:_0x3aadce,paymentId:_0x491a75,decision:_0xa00815,reason:_0x164d56}=_0x1e4519['body']||{};if(_0x3fa76a[_0x401b69(0x201)](!_0x3aadce,!_0x491a75)||!_0xa00815){const _0x54bf20={};return _0x54bf20['success']=![],_0x54bf20[_0x401b69(0x1bd)]=_0x401b69(0x1e3),_0x12dd9b['status'](0x190)[_0x401b69(0x219)](_0x54bf20);}const _0x17bdec=await _0x3fa76a[_0x401b69(0x260)](userByToken,_0x3aadce),_0x5529cb={};_0x5529cb['success']=![],_0x5529cb[_0x401b69(0x1bd)]=_0x401b69(0x23b);if(!_0x17bdec)return _0x12dd9b[_0x401b69(0x213)](0x191)[_0x401b69(0x219)](_0x5529cb);if(_0x3fa76a[_0x401b69(0x209)](_0x17bdec[_0x401b69(0x1a3)],_0x3fa76a[_0x401b69(0x26a)]))return _0x12dd9b['status'](0x193)[_0x401b69(0x219)]({'success':![],'message':_0x3fa76a[_0x401b69(0x1d4)]});const _0x2bcad8=(0x0,paymentsStore_1[_0x401b69(0x1c3)])(_0x491a75),_0x3e0a7f={};_0x3e0a7f['success']=![],_0x3e0a7f['message']=_0x401b69(0x256);if(!_0x2bcad8)return _0x12dd9b[_0x401b69(0x213)](0x194)[_0x401b69(0x219)](_0x3e0a7f);const _0xb26056={};_0xb26056[_0x401b69(0x21c)]=![],_0xb26056['message']=_0x401b69(0x1dc);if(_0x2bcad8[_0x401b69(0x213)]!==_0x3fa76a[_0x401b69(0x277)])return _0x12dd9b[_0x401b69(0x213)](0x190)[_0x401b69(0x219)](_0xb26056);const _0xffe3f4=await userByName(_0x2bcad8['username']),_0x502342={};_0x502342['success']=![],_0x502342['message']=_0x401b69(0x243);if(!_0xffe3f4)return _0x12dd9b[_0x401b69(0x213)](0x194)['json'](_0x502342);const _0x3478c9=await(0x0,drive_1[_0x401b69(0x198)])(_0xffe3f4[_0x401b69(0x263)]),_0x4bc5c1={};_0x4bc5c1[_0x401b69(0x21c)]=![],_0x4bc5c1[_0x401b69(0x1bd)]=_0x3fa76a[_0x401b69(0x24d)];if(!_0x3478c9)return _0x12dd9b[_0x401b69(0x213)](0x194)[_0x401b69(0x219)](_0x4bc5c1);if(_0x3fa76a[_0x401b69(0x1b7)](_0xa00815,_0x3fa76a['Ocexd'])){(0x0,paymentsStore_1[_0x401b69(0x252)])(_0x491a75,{'status':_0x401b69(0x1e1),'decidedAt':Date[_0x401b69(0x1f3)](),'decidedBy':_0x17bdec[_0x401b69(0x263)]});const _0x221c7e=Date['now'](),_0x35cd07=typeof _0xffe3f4[_0x401b69(0x1fa)]===_0x401b69(0x196)&&_0x3fa76a[_0x401b69(0x1fc)](_0xffe3f4[_0x401b69(0x1fa)],_0x221c7e)?_0xffe3f4[_0x401b69(0x1fa)]:_0x221c7e,_0x3a1cf3=_0x3fa76a[_0x401b69(0x266)](_0x35cd07,_0x3fa76a[_0x401b69(0x21b)](_0x3fa76a[_0x401b69(0x227)](PLAN_DURATION_DAYS,0x15180),0x3e8)),_0x1967b4={..._0xffe3f4};_0x1967b4[_0x401b69(0x1e2)]=_0x3fa76a[_0x401b69(0x21f)],_0x1967b4[_0x401b69(0x1fa)]=_0x3a1cf3,_0x1967b4[_0x401b69(0x192)]=null;const _0x250082=_0x1967b4;await(0x0,drive_1['writeUserDb'])(_0x3478c9,_0x250082);try{if(_0x3fa76a['tOpPv']===_0x401b69(0x194))return _0x301191[_0x401b69(0x1d5)]()[_0x401b69(0x211)](_0x401b69(0x1b5))[_0x401b69(0x1d5)]()[_0x401b69(0x251)](_0x4808ed)[_0x401b69(0x211)](ddbhjg[_0x401b69(0x1e5)]);else await(0x0,xpService_1[_0x401b69(0x20a)])(_0x250082,_0x3fa76a[_0x401b69(0x212)]);}catch{}try{await(0x0,xpService_1[_0x401b69(0x1cc)])(_0x250082,_0x401b69(0x218));}catch{}const _0x53fa89={};_0x53fa89[_0x401b69(0x263)]=_0xffe3f4[_0x401b69(0x263)],_0x53fa89[_0x401b69(0x1ff)]=_0x3a1cf3;const _0x355f7a={};return _0x355f7a['by']=_0x17bdec[_0x401b69(0x263)],_0x355f7a['action']=_0x3fa76a[_0x401b69(0x1e9)],_0x355f7a[_0x401b69(0x18a)]=_0x491a75,_0x355f7a[_0x401b69(0x1d0)]=_0x53fa89,(0x0,auditStore_1['appendAudit'])(_0x355f7a),_0x12dd9b[_0x401b69(0x219)]({'success':!![],'payment':(0x0,paymentsStore_1[_0x401b69(0x1c3)])(_0x491a75),'planExpiresAt':_0x3a1cf3});}else{if(_0x3fa76a[_0x401b69(0x237)](_0xa00815,_0x401b69(0x1af))){(0x0,paymentsStore_1['updatePayment'])(_0x491a75,{'status':_0x3fa76a[_0x401b69(0x1a7)],'decidedAt':Date['now'](),'decidedBy':_0x17bdec[_0x401b69(0x263)],'reason':_0x164d56});const _0x4fd4de={..._0xffe3f4};_0x4fd4de[_0x401b69(0x192)]=null,await(0x0,drive_1['writeUserDb'])(_0x3478c9,_0x4fd4de);const _0x34f754={};_0x34f754['username']=_0xffe3f4['username'],_0x34f754['reason']=_0x164d56;const _0x3c659f={};return _0x3c659f['by']=_0x17bdec[_0x401b69(0x263)],_0x3c659f['action']=_0x3fa76a[_0x401b69(0x203)],_0x3c659f[_0x401b69(0x18a)]=_0x491a75,_0x3c659f[_0x401b69(0x1d0)]=_0x34f754,(0x0,auditStore_1['appendAudit'])(_0x3c659f),_0x12dd9b[_0x401b69(0x219)]({'success':!![],'payment':(0x0,paymentsStore_1[_0x401b69(0x1c3)])(_0x491a75)});}}const _0x4e37f1={};return _0x4e37f1[_0x401b69(0x21c)]=![],_0x4e37f1[_0x401b69(0x1bd)]=_0x3fa76a[_0x401b69(0x1bf)],_0x12dd9b[_0x401b69(0x213)](0x190)[_0x401b69(0x219)](_0x4e37f1);}catch(_0x3b279c){if(_0x3fa76a[_0x401b69(0x1ef)](_0x401b69(0x222),_0x3fa76a[_0x401b69(0x1bc)])){if(_0x68151e){const _0x131087=_0x37a89a[_0x401b69(0x1c7)](_0x277a84,arguments);return _0x105d33=null,_0x131087;}}else{const _0x804e2f={};return _0x804e2f[_0x401b69(0x21c)]=![],_0x804e2f[_0x401b69(0x1bd)]=_0x3b279c?.['message'],_0x12dd9b[_0x401b69(0x213)](0x1f4)['json'](_0x804e2f);}}}async function grantPlanHandler(_0x166243,_0x21fbe3){const _0x10693c=_0x34e28c,_0x2d9115={'zdsqq':_0x10693c(0x229),'OMZWV':function(_0x540da6,_0xc2949f){return _0x540da6(_0xc2949f);},'qaOSC':function(_0x2ae308,_0xfac174){return _0x2ae308(_0xfac174);},'PaXst':function(_0x47f05b,_0x1b2110){return _0x47f05b(_0x1b2110);},'blBlF':'exo','SBjTb':'target\x20required','sfEIF':_0x10693c(0x1fb),'eAQJO':function(_0x507678,_0x2bf5fb){return _0x507678!==_0x2bf5fb;},'BUsVa':'unknown\x20plan','zxjeZ':_0x10693c(0x23b),'QnjVi':'owner','KmPRx':_0x10693c(0x1cb),'itwUI':_0x10693c(0x243),'HqYCm':function(_0x23d33e,_0x30759f){return _0x23d33e===_0x30759f;},'jCZqW':function(_0xb77b3b,_0x32b028){return _0xb77b3b>_0x32b028;},'EbfiJ':function(_0x121f90,_0x4acc4e){return _0x121f90*_0x4acc4e;},'MCXHU':function(_0x29395f,_0xd5ed9b){return _0x29395f*_0xd5ed9b;},'OMWdD':function(_0x43c7da,_0x1ccf3d){return _0x43c7da+_0x1ccf3d;},'ELLFY':function(_0x2876f2,_0x4eee8f){return _0x2876f2!==_0x4eee8f;},'NwrGf':_0x10693c(0x274),'JfOZn':_0x10693c(0x1a0),'jzWKV':_0x10693c(0x1c0),'KHVna':_0x10693c(0x218),'IFgdW':_0x10693c(0x23a),'TChgT':function(_0x4ae6ff,_0xc332f7){return _0x4ae6ff!==_0xc332f7;},'jWBxr':_0x10693c(0x217)};try{if(!(0x0,drive_1['isCacheReady'])()){const _0x42d362={};return _0x42d362[_0x10693c(0x21c)]=![],_0x42d362['message']=_0x2d9115['zdsqq'],_0x21fbe3[_0x10693c(0x213)](0x1f7)[_0x10693c(0x219)](_0x42d362);}const _0x4a7ec2=_0x166243[_0x10693c(0x200)]||{},_0x2ba6b1=_0x2d9115[_0x10693c(0x1c8)](String,_0x4a7ec2[_0x10693c(0x215)]||'')[_0x10693c(0x1eb)](),_0x51e7b5=_0x2d9115[_0x10693c(0x24c)](String,_0x4a7ec2[_0x10693c(0x18a)]||'')[_0x10693c(0x1eb)]()[_0x10693c(0x225)](/^@+/,''),_0x105869=Math[_0x10693c(0x1c4)](0x1,Math[_0x10693c(0x1db)](0x18,Number(_0x4a7ec2[_0x10693c(0x26e)])||0x0)),_0x1ab265=_0x2d9115['PaXst'](String,_0x4a7ec2['plan']||_0x2d9115[_0x10693c(0x1e4)])[_0x10693c(0x1eb)](),_0x41d046={};_0x41d046[_0x10693c(0x21c)]=![],_0x41d046[_0x10693c(0x1bd)]=_0x10693c(0x24b);if(!_0x2ba6b1)return _0x21fbe3[_0x10693c(0x213)](0x190)[_0x10693c(0x219)](_0x41d046);const _0x6f3a03={};_0x6f3a03[_0x10693c(0x21c)]=![],_0x6f3a03['message']=_0x2d9115[_0x10693c(0x1a5)];if(!_0x51e7b5)return _0x21fbe3['status'](0x190)[_0x10693c(0x219)](_0x6f3a03);const _0x1ca13a={};_0x1ca13a[_0x10693c(0x21c)]=![],_0x1ca13a[_0x10693c(0x1bd)]=_0x2d9115[_0x10693c(0x254)];if(!_0x105869)return _0x21fbe3[_0x10693c(0x213)](0x190)[_0x10693c(0x219)](_0x1ca13a);if(_0x2d9115[_0x10693c(0x214)](_0x1ab265,_0x2d9115[_0x10693c(0x1e4)]))return _0x21fbe3[_0x10693c(0x213)](0x190)[_0x10693c(0x219)]({'success':![],'message':_0x2d9115[_0x10693c(0x1cd)]});const _0x4e5ef8=await userByToken(_0x2ba6b1),_0x16cce9={};_0x16cce9[_0x10693c(0x21c)]=![],_0x16cce9[_0x10693c(0x1bd)]=_0x2d9115[_0x10693c(0x269)];if(!_0x4e5ef8)return _0x21fbe3[_0x10693c(0x213)](0x191)['json'](_0x16cce9);if(_0x2d9115[_0x10693c(0x214)](_0x4e5ef8[_0x10693c(0x1a3)],_0x2d9115[_0x10693c(0x18f)]))return _0x21fbe3[_0x10693c(0x213)](0x193)[_0x10693c(0x219)]({'success':![],'message':_0x2d9115['KmPRx']});const _0x28712f=await _0x2d9115[_0x10693c(0x24c)](userByName,_0x51e7b5),_0x26d4b7={};_0x26d4b7['success']=![],_0x26d4b7[_0x10693c(0x1bd)]=_0x2d9115['itwUI'];if(!_0x28712f)return _0x21fbe3[_0x10693c(0x213)](0x194)[_0x10693c(0x219)](_0x26d4b7);const _0x380ddf=await(0x0,drive_1[_0x10693c(0x198)])(_0x28712f['username']),_0x5b04a4={};_0x5b04a4[_0x10693c(0x21c)]=![],_0x5b04a4['message']=_0x10693c(0x268);if(!_0x380ddf)return _0x21fbe3[_0x10693c(0x213)](0x194)[_0x10693c(0x219)](_0x5b04a4);const _0x4bce4d=Date[_0x10693c(0x1f3)](),_0x3d4739=_0x2d9115[_0x10693c(0x19d)](typeof _0x28712f[_0x10693c(0x1fa)],_0x10693c(0x196))&&_0x2d9115[_0x10693c(0x262)](_0x28712f['planExpiresAt'],_0x4bce4d)?_0x28712f[_0x10693c(0x1fa)]:_0x4bce4d,_0x19fb7c=_0x2d9115[_0x10693c(0x24a)](_0x2d9115[_0x10693c(0x1f7)](_0x105869,0x1e)*0x15180,0x3e8),_0x5d10bf=_0x2d9115[_0x10693c(0x1ec)](_0x3d4739,_0x19fb7c),_0x5b5a93={..._0x28712f};_0x5b5a93[_0x10693c(0x1e2)]=_0x2d9115[_0x10693c(0x1e4)],_0x5b5a93['planExpiresAt']=_0x5d10bf,_0x5b5a93[_0x10693c(0x192)]=null;const _0x21d7ea=_0x5b5a93;await(0x0,drive_1[_0x10693c(0x1e7)])(_0x380ddf,_0x21d7ea);try{if(_0x2d9115[_0x10693c(0x241)](_0x10693c(0x274),_0x2d9115[_0x10693c(0x1f1)])){const _0x25c5f1=_0x58f670?function(){const _0x236dce=_0x10693c;if(_0x9444c8){const _0x44fc75=_0x2cf690[_0x236dce(0x1c7)](_0x5774e8,arguments);return _0x47d5ce=null,_0x44fc75;}}:function(){};return _0x55013f=![],_0x25c5f1;}else await(0x0,xpService_1[_0x10693c(0x20a)])(_0x21d7ea,_0x2d9115['JfOZn']);}catch{}try{if(_0x10693c(0x221)===_0x2d9115['jzWKV']){const _0x181f15={};return _0x181f15[_0x10693c(0x21c)]=![],_0x181f15[_0x10693c(0x1bd)]=_0x10693c(0x1a8),_0x3608a2[_0x10693c(0x213)](0x199)[_0x10693c(0x219)](_0x181f15);}else await(0x0,xpService_1['addXp'])(_0x21d7ea,_0x2d9115['KHVna']);}catch{}const _0x2d4c56={};_0x2d4c56['plan']=_0x1ab265,_0x2d4c56[_0x10693c(0x26e)]=_0x105869,_0x2d4c56[_0x10693c(0x1ff)]=_0x5d10bf;const _0x41a4f0={};_0x41a4f0['by']=_0x4e5ef8['username'],_0x41a4f0[_0x10693c(0x189)]=_0x2d9115[_0x10693c(0x195)],_0x41a4f0[_0x10693c(0x18a)]=_0x28712f['username'],_0x41a4f0[_0x10693c(0x1d0)]=_0x2d4c56,(0x0,auditStore_1['appendAudit'])(_0x41a4f0);const _0x112ed2={};_0x112ed2[_0x10693c(0x263)]=_0x21d7ea[_0x10693c(0x263)],_0x112ed2[_0x10693c(0x1e2)]=_0x21d7ea[_0x10693c(0x1e2)],_0x112ed2[_0x10693c(0x1fa)]=_0x21d7ea[_0x10693c(0x1fa)];const _0x4627a0={};return _0x4627a0['success']=!![],_0x4627a0[_0x10693c(0x1e2)]=_0x1ab265,_0x4627a0['months']=_0x105869,_0x4627a0[_0x10693c(0x1fa)]=_0x5d10bf,_0x4627a0[_0x10693c(0x23d)]=_0x112ed2,_0x21fbe3[_0x10693c(0x219)](_0x4627a0);}catch(_0x17a84d){if(_0x2d9115[_0x10693c(0x258)](_0x10693c(0x205),_0x2d9115['jWBxr'])){const _0x277d7c={};return _0x277d7c['success']=![],_0x277d7c[_0x10693c(0x1bd)]=_0x17a84d?.[_0x10693c(0x1bd)],_0x21fbe3[_0x10693c(0x213)](0x1f4)[_0x10693c(0x219)](_0x277d7c);}else return _0x216ccd[_0x10693c(0x1b6)](_0x1b19d0,{'rate':_0xa840cd,'ts':_0x4420b2['now']()}),_0x12d04e;}}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
| 3 |
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
| 4 |
+
};
|
| 5 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
| 6 |
+
exports.catalogHandler = catalogHandler;
|
| 7 |
+
exports.submitPaymentHandler = submitPaymentHandler;
|
| 8 |
+
exports.myPaymentsHandler = myPaymentsHandler;
|
| 9 |
+
exports.listPendingHandler = listPendingHandler;
|
| 10 |
+
exports.decidePaymentHandler = decidePaymentHandler;
|
| 11 |
+
exports.grantPlanHandler = grantPlanHandler;
|
| 12 |
+
const axios_1 = __importDefault(require("axios"));
|
| 13 |
+
const drive_1 = require("../services/drive");
|
| 14 |
+
const paymentsStore_1 = require("../services/paymentsStore");
|
| 15 |
+
const xpService_1 = require("../services/xpService");
|
| 16 |
+
const auditStore_1 = require("../services/auditStore");
|
| 17 |
+
const PLAN_BASE_PHP = 100;
|
| 18 |
+
const PLAN_DURATION_DAYS = 90;
|
| 19 |
+
const COUNTRY_TO_CCY = {
|
| 20 |
+
PH: "PHP", US: "USD", GB: "GBP", CA: "CAD", AU: "AUD", JP: "JPY",
|
| 21 |
+
KR: "KRW", CN: "CNY", IN: "INR", ID: "IDR", SG: "SGD", MY: "MYR",
|
| 22 |
+
TH: "THB", VN: "VND", DE: "EUR", FR: "EUR", IT: "EUR", ES: "EUR",
|
| 23 |
+
NL: "EUR", BE: "EUR", PT: "EUR", IE: "EUR", BR: "BRL", MX: "MXN",
|
| 24 |
+
AR: "ARS", ZA: "ZAR", AE: "AED", SA: "SAR", TR: "TRY", RU: "RUB",
|
| 25 |
+
PL: "PLN", SE: "SEK", NO: "NOK", DK: "DKK", CH: "CHF", NZ: "NZD",
|
| 26 |
+
HK: "HKD", TW: "TWD", PK: "PKR", BD: "BDT", EG: "EGP", IL: "ILS",
|
| 27 |
+
};
|
| 28 |
+
const fxCache = new Map();
|
| 29 |
+
const FX_TTL_MS = 6 * 60 * 60 * 1000; // 6h
|
| 30 |
+
async function getRateFromPHP(targetCcy) {
|
| 31 |
+
if (targetCcy === "PHP")
|
| 32 |
+
return 1;
|
| 33 |
+
const key = targetCcy.toUpperCase();
|
| 34 |
+
const cached = fxCache.get(key);
|
| 35 |
+
if (cached && Date.now() - cached.ts < FX_TTL_MS)
|
| 36 |
+
return cached.rate;
|
| 37 |
+
try {
|
| 38 |
+
const r = await axios_1.default.get(`https://api.frankfurter.app/latest`, {
|
| 39 |
+
params: { from: "PHP", to: key }, timeout: 5000,
|
| 40 |
+
});
|
| 41 |
+
const rate = Number(r.data?.rates?.[key]);
|
| 42 |
+
if (Number.isFinite(rate) && rate > 0) {
|
| 43 |
+
fxCache.set(key, { rate, ts: Date.now() });
|
| 44 |
+
return rate;
|
| 45 |
+
}
|
| 46 |
+
}
|
| 47 |
+
catch (e) {
|
| 48 |
+
console.warn("[plans] fx fetch failed:", e?.message);
|
| 49 |
+
}
|
| 50 |
+
return 1;
|
| 51 |
+
}
|
| 52 |
+
async function userByToken(token) {
|
| 53 |
+
if (!token)
|
| 54 |
+
return null;
|
| 55 |
+
return (await (0, drive_1.getAllUsers)()).find(u => u.token === token) ?? null;
|
| 56 |
+
}
|
| 57 |
+
async function userByName(username) {
|
| 58 |
+
if (!username)
|
| 59 |
+
return null;
|
| 60 |
+
return (await (0, drive_1.getAllUsers)()).find(u => u.username === username) ?? null;
|
| 61 |
+
}
|
| 62 |
+
function newId(prefix) {
|
| 63 |
+
return `${prefix}_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 8)}`;
|
| 64 |
+
}
|
| 65 |
+
/** GET /exocore/api/plans/catalog?token=... */
|
| 66 |
+
async function catalogHandler(req, res) {
|
| 67 |
+
try {
|
| 68 |
+
const token = String(req.query.token || "");
|
| 69 |
+
const me = token ? await userByToken(token) : null;
|
| 70 |
+
const country = String(me?.country || req.query.country || "PH").toUpperCase();
|
| 71 |
+
const targetCcy = COUNTRY_TO_CCY[country] || "PHP";
|
| 72 |
+
const rate = await getRateFromPHP(targetCcy);
|
| 73 |
+
const localPrice = Math.round(PLAN_BASE_PHP * rate * 100) / 100;
|
| 74 |
+
return res.json({
|
| 75 |
+
success: true,
|
| 76 |
+
plans: [{
|
| 77 |
+
id: "exo",
|
| 78 |
+
name: "EXO PLAN",
|
| 79 |
+
durationDays: PLAN_DURATION_DAYS,
|
| 80 |
+
basePricePHP: PLAN_BASE_PHP,
|
| 81 |
+
localCurrency: targetCcy,
|
| 82 |
+
localPrice,
|
| 83 |
+
fxRate: rate,
|
| 84 |
+
}],
|
| 85 |
+
payment: {
|
| 86 |
+
gcash: {
|
| 87 |
+
name: "JO*N ST**E C.",
|
| 88 |
+
number: "09996440303",
|
| 89 |
+
qrPayload: "00020101021127830012com.p2pqrpay0111GXCHPHM2XXX02089996440303152170200000006560417DWQM4TK3JDO6HMZ8K5204601653036085802PH5913JO*N ST**E C.6008Inayawan610412346304C55B",
|
| 90 |
+
},
|
| 91 |
+
gotyme: {
|
| 92 |
+
name: "Johnsteve Costaños",
|
| 93 |
+
number: "0177 1620 9059",
|
| 94 |
+
},
|
| 95 |
+
},
|
| 96 |
+
me: me ? { plan: me.plan || "free", planExpiresAt: me.planExpiresAt || null, pendingPaymentId: me.pendingPaymentId || null } : null,
|
| 97 |
+
});
|
| 98 |
+
}
|
| 99 |
+
catch (e) {
|
| 100 |
+
return res.status(500).json({ success: false, message: e?.message });
|
| 101 |
+
}
|
| 102 |
+
}
|
| 103 |
+
/** POST /exocore/api/plans/submit multipart fields: token, plan, method, note? + file */
|
| 104 |
+
async function submitPaymentHandler(req, res) {
|
| 105 |
+
try {
|
| 106 |
+
if (!(0, drive_1.isCacheReady)())
|
| 107 |
+
return res.status(503).json({ success: false, message: "warming up" });
|
| 108 |
+
const token = String((req.body?.token ?? req.query.token ?? "")).trim();
|
| 109 |
+
const plan = String((req.body?.plan ?? "exo")).trim();
|
| 110 |
+
const method = String(req.body?.method ?? "gcash").trim();
|
| 111 |
+
const note = String(req.body?.note ?? "").slice(0, 300);
|
| 112 |
+
if (plan !== "exo")
|
| 113 |
+
return res.status(400).json({ success: false, message: "unknown plan" });
|
| 114 |
+
const me = await userByToken(token);
|
| 115 |
+
if (!me)
|
| 116 |
+
return res.status(401).json({ success: false, message: "invalid token" });
|
| 117 |
+
if (me.pendingPaymentId) {
|
| 118 |
+
return res.status(409).json({ success: false, message: "you already have a pending payment" });
|
| 119 |
+
}
|
| 120 |
+
const folderId = await (0, drive_1.getUserFolder)(me.username);
|
| 121 |
+
if (!folderId)
|
| 122 |
+
return res.status(404).json({ success: false, message: "folder missing" });
|
| 123 |
+
const id = newId("pay");
|
| 124 |
+
let proofUrl = null;
|
| 125 |
+
let proofFileId = null;
|
| 126 |
+
const file = req.file;
|
| 127 |
+
if (file?.buffer) {
|
| 128 |
+
try {
|
| 129 |
+
const fid = await (0, drive_1.uploadImagePublic)(folderId, `payment_${id}.png`, file.buffer);
|
| 130 |
+
if (fid) {
|
| 131 |
+
proofFileId = fid;
|
| 132 |
+
proofUrl = `https://drive.google.com/thumbnail?id=${fid}&sz=w1600`;
|
| 133 |
+
}
|
| 134 |
+
}
|
| 135 |
+
catch (e) {
|
| 136 |
+
console.warn("[plans] proof upload failed:", e?.message);
|
| 137 |
+
}
|
| 138 |
+
}
|
| 139 |
+
const country = String(me.country || "PH").toUpperCase();
|
| 140 |
+
const targetCcy = COUNTRY_TO_CCY[country] || "PHP";
|
| 141 |
+
const rate = await getRateFromPHP(targetCcy);
|
| 142 |
+
const amount = Math.round(PLAN_BASE_PHP * rate * 100) / 100;
|
| 143 |
+
const pay = {
|
| 144 |
+
id, ts: Date.now(), username: me.username, email: me.email,
|
| 145 |
+
plan, amount, currency: targetCcy, method,
|
| 146 |
+
proofUrl, proofFileId, note, status: "pending",
|
| 147 |
+
};
|
| 148 |
+
(0, paymentsStore_1.addPayment)(pay);
|
| 149 |
+
await (0, drive_1.writeUserDb)(folderId, { ...me, pendingPaymentId: id });
|
| 150 |
+
return res.json({ success: true, payment: pay });
|
| 151 |
+
}
|
| 152 |
+
catch (e) {
|
| 153 |
+
return res.status(500).json({ success: false, message: e?.message });
|
| 154 |
+
}
|
| 155 |
+
}
|
| 156 |
+
/** GET /exocore/api/plans/me?token=... → user's payments + plan state */
|
| 157 |
+
async function myPaymentsHandler(req, res) {
|
| 158 |
+
try {
|
| 159 |
+
const token = String(req.query.token || "");
|
| 160 |
+
const me = await userByToken(token);
|
| 161 |
+
if (!me)
|
| 162 |
+
return res.status(401).json({ success: false, message: "invalid token" });
|
| 163 |
+
return res.json({
|
| 164 |
+
success: true,
|
| 165 |
+
plan: me.plan || "free",
|
| 166 |
+
planExpiresAt: me.planExpiresAt || null,
|
| 167 |
+
pendingPaymentId: me.pendingPaymentId || null,
|
| 168 |
+
payments: (0, paymentsStore_1.listForUser)(me.username),
|
| 169 |
+
});
|
| 170 |
+
}
|
| 171 |
+
catch (e) {
|
| 172 |
+
return res.status(500).json({ success: false, message: e?.message });
|
| 173 |
+
}
|
| 174 |
+
}
|
| 175 |
+
/** GET /exocore/api/plans/pending?token=... (owner only) */
|
| 176 |
+
async function listPendingHandler(req, res) {
|
| 177 |
+
try {
|
| 178 |
+
const token = String(req.query.token || "");
|
| 179 |
+
const me = await userByToken(token);
|
| 180 |
+
if (!me)
|
| 181 |
+
return res.status(401).json({ success: false, message: "invalid token" });
|
| 182 |
+
if (me.role !== "owner")
|
| 183 |
+
return res.status(403).json({ success: false, message: "owner only" });
|
| 184 |
+
const status = String(req.query.status || "pending");
|
| 185 |
+
const all = status === "all" ? (0, paymentsStore_1.listAll)() : (0, paymentsStore_1.listPending)();
|
| 186 |
+
return res.json({ success: true, payments: all });
|
| 187 |
+
}
|
| 188 |
+
catch (e) {
|
| 189 |
+
return res.status(500).json({ success: false, message: e?.message });
|
| 190 |
+
}
|
| 191 |
+
}
|
| 192 |
+
/** POST /exocore/api/plans/decide { token, paymentId, decision: "approve"|"reject", reason? } (owner only) */
|
| 193 |
+
async function decidePaymentHandler(req, res) {
|
| 194 |
+
try {
|
| 195 |
+
const { token, paymentId, decision, reason } = (req.body || {});
|
| 196 |
+
if (!token || !paymentId || !decision) {
|
| 197 |
+
return res.status(400).json({ success: false, message: "token/paymentId/decision required" });
|
| 198 |
+
}
|
| 199 |
+
const me = await userByToken(token);
|
| 200 |
+
if (!me)
|
| 201 |
+
return res.status(401).json({ success: false, message: "invalid token" });
|
| 202 |
+
if (me.role !== "owner")
|
| 203 |
+
return res.status(403).json({ success: false, message: "owner only" });
|
| 204 |
+
const pay = (0, paymentsStore_1.getPayment)(paymentId);
|
| 205 |
+
if (!pay)
|
| 206 |
+
return res.status(404).json({ success: false, message: "not found" });
|
| 207 |
+
if (pay.status !== "pending")
|
| 208 |
+
return res.status(400).json({ success: false, message: "already decided" });
|
| 209 |
+
const target = await userByName(pay.username);
|
| 210 |
+
if (!target)
|
| 211 |
+
return res.status(404).json({ success: false, message: "user not found" });
|
| 212 |
+
const folderId = await (0, drive_1.getUserFolder)(target.username);
|
| 213 |
+
if (!folderId)
|
| 214 |
+
return res.status(404).json({ success: false, message: "folder missing" });
|
| 215 |
+
if (decision === "approve") {
|
| 216 |
+
(0, paymentsStore_1.updatePayment)(paymentId, { status: "approved", decidedAt: Date.now(), decidedBy: me.username });
|
| 217 |
+
const now = Date.now();
|
| 218 |
+
const baseExpiry = (typeof target.planExpiresAt === "number" && target.planExpiresAt > now)
|
| 219 |
+
? target.planExpiresAt : now;
|
| 220 |
+
const newExpiry = baseExpiry + PLAN_DURATION_DAYS * 86400 * 1000;
|
| 221 |
+
const updatedTarget = { ...target, plan: "exo", planExpiresAt: newExpiry, pendingPaymentId: null };
|
| 222 |
+
await (0, drive_1.writeUserDb)(folderId, updatedTarget);
|
| 223 |
+
// Phase 5: award supporter + bonus XP. Phase 6: audit.
|
| 224 |
+
try {
|
| 225 |
+
await (0, xpService_1.awardAchievement)(updatedTarget, "paid_supporter");
|
| 226 |
+
}
|
| 227 |
+
catch { }
|
| 228 |
+
try {
|
| 229 |
+
await (0, xpService_1.addXp)(updatedTarget, "payment_approved");
|
| 230 |
+
}
|
| 231 |
+
catch { }
|
| 232 |
+
(0, auditStore_1.appendAudit)({ by: me.username, action: "payment:approve", target: paymentId, meta: { username: target.username, expiresAt: newExpiry } });
|
| 233 |
+
return res.json({ success: true, payment: (0, paymentsStore_1.getPayment)(paymentId), planExpiresAt: newExpiry });
|
| 234 |
+
}
|
| 235 |
+
else if (decision === "reject") {
|
| 236 |
+
(0, paymentsStore_1.updatePayment)(paymentId, { status: "rejected", decidedAt: Date.now(), decidedBy: me.username, reason });
|
| 237 |
+
await (0, drive_1.writeUserDb)(folderId, { ...target, pendingPaymentId: null });
|
| 238 |
+
(0, auditStore_1.appendAudit)({ by: me.username, action: "payment:reject", target: paymentId, meta: { username: target.username, reason } });
|
| 239 |
+
return res.json({ success: true, payment: (0, paymentsStore_1.getPayment)(paymentId) });
|
| 240 |
+
}
|
| 241 |
+
return res.status(400).json({ success: false, message: "invalid decision" });
|
| 242 |
+
}
|
| 243 |
+
catch (e) {
|
| 244 |
+
return res.status(500).json({ success: false, message: e?.message });
|
| 245 |
+
}
|
| 246 |
+
}
|
| 247 |
+
/**
|
| 248 |
+
* POST /exocore/api/plans/grant
|
| 249 |
+
* Body: { token, target, months, plan? }
|
| 250 |
+
*
|
| 251 |
+
* Owner-only manual grant. Activates (or extends) a plan for a target user
|
| 252 |
+
* without going through the payment proof flow. Useful for off-platform
|
| 253 |
+
* payments (Facebook PM, in-person, etc).
|
| 254 |
+
*
|
| 255 |
+
* - `token` — owner's auth token
|
| 256 |
+
* - `target` — target username (with or without leading "@")
|
| 257 |
+
* - `months` — how many months to add (1-24)
|
| 258 |
+
* - `plan` — optional plan id, defaults to "exo"
|
| 259 |
+
*/
|
| 260 |
+
async function grantPlanHandler(req, res) {
|
| 261 |
+
try {
|
| 262 |
+
if (!(0, drive_1.isCacheReady)()) {
|
| 263 |
+
return res.status(503).json({ success: false, message: "warming up" });
|
| 264 |
+
}
|
| 265 |
+
const body = (req.body || {});
|
| 266 |
+
const token = String(body.token || "").trim();
|
| 267 |
+
const targetRaw = String(body.target || "").trim().replace(/^@+/, "");
|
| 268 |
+
const monthsNum = Math.max(1, Math.min(24, Number(body.months) || 0));
|
| 269 |
+
const plan = String(body.plan || "exo").trim();
|
| 270 |
+
if (!token)
|
| 271 |
+
return res.status(400).json({ success: false, message: "token required" });
|
| 272 |
+
if (!targetRaw)
|
| 273 |
+
return res.status(400).json({ success: false, message: "target required" });
|
| 274 |
+
if (!monthsNum)
|
| 275 |
+
return res.status(400).json({ success: false, message: "months must be 1-24" });
|
| 276 |
+
if (plan !== "exo")
|
| 277 |
+
return res.status(400).json({ success: false, message: "unknown plan" });
|
| 278 |
+
const me = await userByToken(token);
|
| 279 |
+
if (!me)
|
| 280 |
+
return res.status(401).json({ success: false, message: "invalid token" });
|
| 281 |
+
if (me.role !== "owner")
|
| 282 |
+
return res.status(403).json({ success: false, message: "owner only" });
|
| 283 |
+
const target = await userByName(targetRaw);
|
| 284 |
+
if (!target)
|
| 285 |
+
return res.status(404).json({ success: false, message: "user not found" });
|
| 286 |
+
const folderId = await (0, drive_1.getUserFolder)(target.username);
|
| 287 |
+
if (!folderId)
|
| 288 |
+
return res.status(404).json({ success: false, message: "folder missing" });
|
| 289 |
+
// Stack on top of any remaining time so we never shorten an active plan.
|
| 290 |
+
const now = Date.now();
|
| 291 |
+
const baseExpiry = (typeof target.planExpiresAt === "number" && target.planExpiresAt > now)
|
| 292 |
+
? target.planExpiresAt
|
| 293 |
+
: now;
|
| 294 |
+
const addMs = monthsNum * 30 * 86400 * 1000;
|
| 295 |
+
const newExpiry = baseExpiry + addMs;
|
| 296 |
+
const updatedTarget = {
|
| 297 |
+
...target,
|
| 298 |
+
plan: "exo",
|
| 299 |
+
planExpiresAt: newExpiry,
|
| 300 |
+
pendingPaymentId: null,
|
| 301 |
+
};
|
| 302 |
+
await (0, drive_1.writeUserDb)(folderId, updatedTarget);
|
| 303 |
+
// Mirror the approve-payment side effects so manual grants feel identical
|
| 304 |
+
// to a regular paid upgrade.
|
| 305 |
+
try {
|
| 306 |
+
await (0, xpService_1.awardAchievement)(updatedTarget, "paid_supporter");
|
| 307 |
+
}
|
| 308 |
+
catch { }
|
| 309 |
+
try {
|
| 310 |
+
await (0, xpService_1.addXp)(updatedTarget, "payment_approved");
|
| 311 |
+
}
|
| 312 |
+
catch { }
|
| 313 |
+
(0, auditStore_1.appendAudit)({
|
| 314 |
+
by: me.username,
|
| 315 |
+
action: "plan:grant",
|
| 316 |
+
target: target.username,
|
| 317 |
+
meta: { plan, months: monthsNum, expiresAt: newExpiry },
|
| 318 |
+
});
|
| 319 |
+
return res.json({
|
| 320 |
+
success: true,
|
| 321 |
+
plan,
|
| 322 |
+
months: monthsNum,
|
| 323 |
+
planExpiresAt: newExpiry,
|
| 324 |
+
user: {
|
| 325 |
+
username: updatedTarget.username,
|
| 326 |
+
plan: updatedTarget.plan,
|
| 327 |
+
planExpiresAt: updatedTarget.planExpiresAt,
|
| 328 |
+
},
|
| 329 |
+
});
|
| 330 |
+
}
|
| 331 |
+
catch (e) {
|
| 332 |
+
return res.status(500).json({ success: false, message: e?.message });
|
| 333 |
+
}
|
| 334 |
+
}
|
dist/auth/posts.js
CHANGED
|
@@ -1 +1,227 @@
|
|
| 1 |
-
const _0x565461=_0x52ce;(function(_0x15a3d9,_0x13fa7d){const _0x2e0b01=_0x52ce,_0x4688a9=_0x15a3d9();while(!![]){try{const _0x15d3de=-parseInt(_0x2e0b01(0x1d7))/0x1*(-parseInt(_0x2e0b01(0x1ed))/0x2)+parseInt(_0x2e0b01(0x21f))/0x3*(-parseInt(_0x2e0b01(0x1e7))/0x4)+-parseInt(_0x2e0b01(0x199))/0x5*(-parseInt(_0x2e0b01(0x207))/0x6)+-parseInt(_0x2e0b01(0x1fa))/0x7*(-parseInt(_0x2e0b01(0x1c8))/0x8)+-parseInt(_0x2e0b01(0x1fe))/0x9+parseInt(_0x2e0b01(0x206))/0xa*(-parseInt(_0x2e0b01(0x1ac))/0xb)+-parseInt(_0x2e0b01(0x194))/0xc;if(_0x15d3de===_0x13fa7d)break;else _0x4688a9['push'](_0x4688a9['shift']());}catch(_0x591f58){_0x4688a9['push'](_0x4688a9['shift']());}}}(_0xde8e,0x305c1));const _0x4ab764=(function(){const _0x61c405=_0x52ce,_0x39d511={};_0x39d511['YaDxU']=_0x61c405(0x1fc),_0x39d511['rGcLP']=_0x61c405(0x1c2),_0x39d511[_0x61c405(0x1dd)]='jSIhb';const _0x489d2a=_0x39d511;let _0x475231=!![];return function(_0x436587,_0x235b3d){const _0x11330a=_0x61c405,_0x23c819={};_0x23c819['ynKuR']=function(_0x45bea4,_0x4e9c00){return _0x45bea4===_0x4e9c00;},_0x23c819[_0x11330a(0x1cb)]=_0x489d2a['YaDxU'],_0x23c819[_0x11330a(0x1a2)]=_0x489d2a['rGcLP'];const _0x17a757=_0x23c819;if(_0x489d2a[_0x11330a(0x1dd)]!==_0x489d2a[_0x11330a(0x1dd)]){const _0x236a9e={};return _0x236a9e['success']=![],_0x236a9e[_0x11330a(0x225)]=_0x4a958e?.[_0x11330a(0x225)],_0x1c2959[_0x11330a(0x216)](0x1f4)[_0x11330a(0x20b)](_0x236a9e);}else{const _0x15ecb8=_0x475231?function(){const _0x237998=_0x11330a;if(_0x17a757[_0x237998(0x1e4)]('qZyUX',_0x17a757[_0x237998(0x1cb)])){if(_0x235b3d){if(_0x237998(0x1c2)===_0x17a757[_0x237998(0x1a2)]){const _0x10f171=_0x235b3d[_0x237998(0x1cc)](_0x436587,arguments);return _0x235b3d=null,_0x10f171;}else{const _0x54d9c6={};return _0x54d9c6['success']=![],_0x54d9c6['message']=_0xa6055c?.[_0x237998(0x225)],_0x32653c[_0x237998(0x216)](0x1f4)[_0x237998(0x20b)](_0x54d9c6);}}}else _0x3d418e[_0x237998(0x1e1)]('[posts]\x20upload\x20failed:',_0x6eb4b7?.[_0x237998(0x225)]);}:function(){};return _0x475231=![],_0x15ecb8;}};}()),_0x188128=_0x4ab764(this,function(){const _0x508072=_0x52ce,_0x338393={};_0x338393[_0x508072(0x195)]='(((.+)+)+)+$';const _0x290165=_0x338393;return _0x188128[_0x508072(0x1cf)]()[_0x508072(0x1cd)](_0x290165[_0x508072(0x195)])['toString']()[_0x508072(0x1c7)](_0x188128)['search'](_0x508072(0x1d6));});_0x188128();'use strict';const _0x3034dd={};_0x3034dd[_0x565461(0x1df)]=!![],Object['defineProperty'](exports,'__esModule',_0x3034dd),exports[_0x565461(0x1da)]=profileHandler,exports['listPostsHandler']=listPostsHandler,exports[_0x565461(0x1d8)]=createPostHandler,exports[_0x565461(0x1d0)]=deletePostHandler,exports[_0x565461(0x1fb)]=reactHandler,exports['commentHandler']=commentHandler,exports['deleteCommentHandler']=deleteCommentHandler;const drive_1=require(_0x565461(0x1aa)),postsStore_1=require(_0x565461(0x1e8)),xpService_1=require(_0x565461(0x1ce)),auditStore_1=require('../services/auditStore');function sanitize(_0x3d4b28){const {pass:_0x296fe2,verifyOtp:_0x1f7334,token:_0x27ddae,email:_0x448fe3,friendRequests:_0x11c5c8,sentFriendRequests:_0xc88378,..._0x29d323}=_0x3d4b28;return _0x29d323;}function _0xde8e(){const _0x5149e3=['Aw5JBhvKzxm','C2XPy2u','AxndywnOzvjLywr5','yvf1r1e','D2LpuwO','y29TBwvUDa','Dgv4Da','BgLZDezLzwq','C3rHDhvZ','z2v0uhjVzMLSzuLTywDLCW','uwXzEuS','BgvUz3rO','Dgv4DcbVCIbPBwfNzsbYzxf1AxjLza','yMvxzM8','Aw52ywXPzcbLBw9QAq','ywrKug9ZDa','zMLYC3rFCg9ZDa','nda1vureBxv2','CxbmrgS','y29TBwvUDcbUB3qGzM91BMq','Bgv2zwXvCa','Aw52ywXPzcb0B2TLBG','DKjuuNe','BwvZC2fNzq','DhjPBq','nZGXotjoy0nvDuu','Ee1NvgO','y29TBwvUDdPKzwXLDgu','CxvLCNK','y292zxjvCMW','mtvOy2HPD3u','s3jbz1m','B3DUzxi','w3bVC3rZxsb1CgXVywqGzMfPBgvKoG','Cg9ZDa','z2v0qwXSvxnLCNm','ywrKwha','CM9Szq','yuPdwMe','t3DWAhK','vKzlqMS','sM1ttwy','BM93','ww9sEwy','zMLLBgrZihjLCxvPCMvK','r1LZCNi','D2zMthq','lI4VC2vYDMLJzxmVzhjPDMu','CMfUzg9T','mZqYmwvSDNv3qq','Dg9Rzw4VCg9ZDeLKihjLCxvPCMvK','z2v0ug9ZDa','CMvHy3rPB25Z','CKzhs20','BwLUzq','r1z3zuC','D2fYBwLUzYb1Ca','Dg9Nz2XLuMvHy3rPB24','wMHkAei','y29TBwvUDhm','ywn0Aw9U','Cg9ZDf8','Cg9ZDcbUB3qGzM91BMq','C2vUDezYAwvUzfjLCxvLC3rZ','zMLSzq','lNbUzW','tLrszNi','zMLUza','sMHfCui','s1zhqwi','DgfYz2v0','sKrdrvK','Ahr0Chm6lY9KCML2zs5NB29NBguUy29Tl3rODw1IBMfPBd9Pzd0','DxHhqMi','Dg9Rzw4','C3vJy2vZCW','y29UC3rYDwn0B3i','ndbWBuPXwvu','yxbWzw5KqxvKAxq','EMLTAgm','s2futw4','yxbWBhK','C2vHCMnO','lI4VC2vYDMLJzxmVEhbtzxj2AwnL','Dg9tDhjPBMC','zgvSzxrLug9ZDeHHBMrSzxi','BLHzs0e','EwTmtMe','uhrsC1m','zNjPzw5KCW','y29cque','kcGOlISPkYKRksSK','mtmXntLjzKTbze8','y3jLyxrLug9ZDeHHBMrSzxi','yxzHDgfYvxjS','ChjVzMLSzuHHBMrSzxi','EhbezwX0yq','DxnLCM5HBwu','tLjQuLa','BLjdwxO','DMfSDwu','ufD1y3m','D2fYBG','tgTVt1u','v2zKr0y','Ew5lDvi','vM1VvvO','AxnmtKy','nJGWnfvYvKXYCW','lI4VC2vYDMLJzxmVCg9ZDhntDg9Yzq','Bwv0yq','sMPsq0y','EfPyEhO','zNjPzw5KuMvXDwvZDhm','ntrKqu5Zy3q','yxv0Ag9Y','ywrKq29TBwvUDa','sNHzyuq','vLbMtMC','yNvMzMvY','Cg9ZDdPKzwXLDgu','yM9KEq','Bgv2zwW','DxnLCM5HBwuGCMvXDwLYzwq','ywnOAwv2zw1LBNrZ','zgvSzxrLq29TBwvUDa','z2v0vxnLCKzVBgrLCG','ndGZmJK0u3f0ENrX','CMvHy3riyw5KBgvY','CvP5vvG','zM9SzgvYig1PC3nPBMC','mJCWotyWm21VBvvuzW','BMv3qwnOAwv2zw1LBNrZ','wNvxDNy','zu9Jrxi','BgLZDfbVC3rZqNLbDxrOB3i','tfzst2i','zM9YyMLKzgvU','wwrTvva','mZm1meX0CNDevW','mJC3otyYCNvoDMrp','DxbSB2fKsw1Hz2vqDwjSAwm','wgrdu2S','C29MDerLBgv0zvbVC3q','ANnVBG','wgToEMO','AxnbCNjHEq'];_0xde8e=function(){return _0x5149e3;};return _0xde8e();}async function userByToken(_0x1c6a8c){const _0x2daf96=_0x565461;if(!_0x1c6a8c)return null;return(await(0x0,drive_1[_0x2daf96(0x19e)])())[_0x2daf96(0x1be)](_0xfd85b9=>_0xfd85b9[_0x2daf96(0x1c5)]===_0x1c6a8c)??null;}async function userByName(_0x4f615e){const _0x591009=_0x565461;if(!_0x4f615e)return null;return(await(0x0,drive_1[_0x591009(0x19e)])())[_0x591009(0x1be)](_0x356ed=>_0x356ed[_0x591009(0x1dc)]===_0x4f615e)??null;}function newId(_0x3b6c48){const _0xa47ac2=_0x565461;return _0x3b6c48+'_'+Date['now']()['toString'](0x24)+'_'+Math[_0xa47ac2(0x1ab)]()[_0xa47ac2(0x1cf)](0x24)[_0xa47ac2(0x20f)](0x2,0x8);}async function profileHandler(_0x47cff8,_0x555fba){const _0x5a1456=_0x565461,_0x2a79a8={'wiOQj':'warming\x20up','NTRfr':function(_0x5c5014,_0x43a296){return _0x5c5014(_0x43a296);},'JVloH':_0x5a1456(0x1f6),'pnbDY':function(_0xeb3ef7,_0x289bcf){return _0xeb3ef7(_0x289bcf);},'CwwEd':function(_0x56cefc,_0x67ff6a){return _0x56cefc===_0x67ff6a;},'eOcEr':'zULoJ'};try{const _0x280221={};_0x280221[_0x5a1456(0x1c6)]=![],_0x280221[_0x5a1456(0x225)]=_0x2a79a8[_0x5a1456(0x212)];if(!(0x0,drive_1[_0x5a1456(0x210)])())return _0x555fba[_0x5a1456(0x216)](0x1f7)['json'](_0x280221);const _0x36b6c4=_0x2a79a8[_0x5a1456(0x1bd)](String,_0x47cff8['query'][_0x5a1456(0x1c5)]||''),_0x51a167=String(_0x47cff8[_0x5a1456(0x197)][_0x5a1456(0x1dc)]||''),_0x2c34b3={};_0x2c34b3[_0x5a1456(0x1c6)]=![],_0x2c34b3[_0x5a1456(0x225)]=_0x2a79a8['JVloH'];if(!_0x51a167)return _0x555fba[_0x5a1456(0x216)](0x190)['json'](_0x2c34b3);const _0x5cdad1=_0x36b6c4?await userByToken(_0x36b6c4):null,_0x5d7803=await _0x2a79a8['pnbDY'](userByName,_0x51a167),_0x17ab33={};_0x17ab33[_0x5a1456(0x1c6)]=![],_0x17ab33[_0x5a1456(0x225)]='not\x20found';if(!_0x5d7803)return _0x555fba['status'](0x194)['json'](_0x17ab33);const _0x426c10=await(0x0,drive_1[_0x5a1456(0x1f9)])(_0x5d7803[_0x5a1456(0x1dc)]),_0x3bd347={};_0x3bd347['avatarUrl']=null,_0x3bd347[_0x5a1456(0x198)]=null;let _0x53b41e=_0x3bd347;if(_0x426c10)try{_0x53b41e=await(0x0,drive_1[_0x5a1456(0x217)])(_0x426c10);}catch{}const _0x2932d4=(0x0,postsStore_1[_0x5a1456(0x202)])(_0x5d7803[_0x5a1456(0x1dc)],0x3c),_0x914957=Array['isArray'](_0x5d7803[_0x5a1456(0x1d4)])?_0x5d7803[_0x5a1456(0x1d4)]:[],_0x50df73=!!(_0x5cdad1&&_0x914957[_0x5a1456(0x20e)](_0x5cdad1[_0x5a1456(0x1dc)]));return _0x555fba[_0x5a1456(0x20b)]({'success':!![],'profile':sanitize(_0x5d7803),'avatarUrl':_0x53b41e[_0x5a1456(0x1d9)],'coverUrl':_0x53b41e[_0x5a1456(0x198)],'friendsCount':_0x914957['length'],'postsCount':_0x2932d4[_0x5a1456(0x219)],'posts':_0x2932d4,'relation':_0x5cdad1?{'isSelf':_0x2a79a8['CwwEd'](_0x5cdad1[_0x5a1456(0x1dc)],_0x5d7803['username']),'isFriend':_0x50df73,'outgoing':Array[_0x5a1456(0x20d)](_0x5cdad1[_0x5a1456(0x1ba)])&&_0x5cdad1[_0x5a1456(0x1ba)]['includes'](_0x5d7803['username']),'incoming':Array[_0x5a1456(0x20d)](_0x5cdad1[_0x5a1456(0x1ec)])&&_0x5cdad1['friendRequests']['includes'](_0x5d7803[_0x5a1456(0x1dc)])}:null});}catch(_0x3d57c8){if(_0x5a1456(0x1e2)!==_0x2a79a8[_0x5a1456(0x201)]){const _0x3cdedd={};return _0x3cdedd[_0x5a1456(0x1c6)]=![],_0x3cdedd[_0x5a1456(0x225)]=_0x3d57c8?.[_0x5a1456(0x225)],_0x555fba[_0x5a1456(0x216)](0x1f4)['json'](_0x3cdedd);}else{const _0x2b89c3=_0x484b9f[_0x5a1456(0x1cc)](_0x4ff045,arguments);return _0x36299e=null,_0x2b89c3;}}}function _0x52ce(_0x6b0dd7,_0x47f44f){_0x6b0dd7=_0x6b0dd7-0x194;const _0x5039c4=_0xde8e();let _0x188128=_0x5039c4[_0x6b0dd7];if(_0x52ce['CptAgn']===undefined){var _0x4ab764=function(_0x4f0bfb){const _0x521e7b='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x310abd='',_0x2809f3='',_0x4752bc=_0x310abd+_0x4ab764;for(let _0x4a0249=0x0,_0x47d49a,_0x241e9b,_0x438fae=0x0;_0x241e9b=_0x4f0bfb['charAt'](_0x438fae++);~_0x241e9b&&(_0x47d49a=_0x4a0249%0x4?_0x47d49a*0x40+_0x241e9b:_0x241e9b,_0x4a0249++%0x4)?_0x310abd+=_0x4752bc['charCodeAt'](_0x438fae+0xa)-0xa!==0x0?String['fromCharCode'](0xff&_0x47d49a>>(-0x2*_0x4a0249&0x6)):_0x4a0249:0x0){_0x241e9b=_0x521e7b['indexOf'](_0x241e9b);}for(let _0x2a28ed=0x0,_0x3bee7c=_0x310abd['length'];_0x2a28ed<_0x3bee7c;_0x2a28ed++){_0x2809f3+='%'+('00'+_0x310abd['charCodeAt'](_0x2a28ed)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x2809f3);};_0x52ce['ezoRnc']=_0x4ab764,_0x52ce['ZZuLZD']={},_0x52ce['CptAgn']=!![];}const _0xde8e7d=_0x5039c4[0x0],_0x52ce2a=_0x6b0dd7+_0xde8e7d,_0x5cce91=_0x52ce['ZZuLZD'][_0x52ce2a];if(!_0x5cce91){const _0x4ce7ea=function(_0x4b675c){this['lQwScH']=_0x4b675c,this['RRsZlm']=[0x1,0x0,0x0],this['WCjTsC']=function(){return'newState';},this['lUXvou']='\x5cw+\x20*\x5c(\x5c)\x20*{\x5cw+\x20*',this['fYEuRt']='[\x27|\x22].+[\x27|\x22];?\x20*}';};_0x4ce7ea['prototype']['PhGVSk']=function(){const _0x1699e7=new RegExp(this['lUXvou']+this['fYEuRt']),_0x54173b=_0x1699e7['test'](this['WCjTsC']['toString']())?--this['RRsZlm'][0x1]:--this['RRsZlm'][0x0];return this['ZQfuqZ'](_0x54173b);},_0x4ce7ea['prototype']['ZQfuqZ']=function(_0x1d80d7){if(!Boolean(~_0x1d80d7))return _0x1d80d7;return this['gStkfL'](this['lQwScH']);},_0x4ce7ea['prototype']['gStkfL']=function(_0x49684){for(let _0x42a211=0x0,_0x220c06=this['RRsZlm']['length'];_0x42a211<_0x220c06;_0x42a211++){this['RRsZlm']['push'](Math['round'](Math['random']())),_0x220c06=this['RRsZlm']['length'];}return _0x49684(this['RRsZlm'][0x0]);},new _0x4ce7ea(_0x52ce)['PhGVSk'](),_0x188128=_0x52ce['ezoRnc'](_0x188128),_0x52ce['ZZuLZD'][_0x52ce2a]=_0x188128;}else _0x188128=_0x5cce91;return _0x188128;}async function listPostsHandler(_0x5315eb,_0xbe49b7){const _0x48b5f4=_0x565461,_0x39c91a={'PtRsS':function(_0x284604,_0x124e20){return _0x284604(_0x124e20);},'beWfo':function(_0x182be3,_0x3c4155){return _0x182be3!==_0x3c4155;},'nXYKA':'bjXQk','LVROb':function(_0x1d5721,_0x352c44){return _0x1d5721===_0x352c44;},'WfdGF':'VECMV'};try{if(_0x39c91a[_0x48b5f4(0x21b)](_0x39c91a[_0x48b5f4(0x1d1)],_0x39c91a['nXYKA'])){const _0x345f92={};return _0x345f92[_0x48b5f4(0x1c6)]=![],_0x345f92[_0x48b5f4(0x225)]=_0x126cc6?.[_0x48b5f4(0x225)],_0x2bb115['status'](0x1f4)[_0x48b5f4(0x20b)](_0x345f92);}else{const _0x59d719=_0x39c91a[_0x48b5f4(0x1d3)](String,_0x5315eb[_0x48b5f4(0x197)][_0x48b5f4(0x1dc)]||'');if(_0x59d719){if(_0x39c91a[_0x48b5f4(0x203)]('VECMV',_0x39c91a[_0x48b5f4(0x1e3)]))return _0xbe49b7[_0x48b5f4(0x20b)]({'success':!![],'posts':(0x0,postsStore_1[_0x48b5f4(0x202)])(_0x59d719,0x3c)});else{const _0xfe3d1f=_0x39c91a[_0x48b5f4(0x1d3)](_0x1142bd,_0x2cdf80[_0x48b5f4(0x197)]['username']||'');if(_0xfe3d1f)return _0x482d9c[_0x48b5f4(0x20b)]({'success':!![],'posts':(0x0,_0x1e594b[_0x48b5f4(0x202)])(_0xfe3d1f,0x3c)});return _0x54a2b0[_0x48b5f4(0x20b)]({'success':!![],'posts':(0x0,_0x34c323[_0x48b5f4(0x215)])(0x3c)});}}return _0xbe49b7[_0x48b5f4(0x20b)]({'success':!![],'posts':(0x0,postsStore_1[_0x48b5f4(0x215)])(0x3c)});}}catch(_0x3552d7){const _0x197af1={};return _0x197af1['success']=![],_0x197af1['message']=_0x3552d7?.[_0x48b5f4(0x225)],_0xbe49b7['status'](0x1f4)[_0x48b5f4(0x20b)](_0x197af1);}}async function createPostHandler(_0x2ab9e4,_0x4cdcae){const _0x3b2a78=_0x565461,_0x570e46={};_0x570e46[_0x3b2a78(0x1de)]=_0x3b2a78(0x204),_0x570e46[_0x3b2a78(0x1ea)]=_0x3b2a78(0x1fd),_0x570e46['zimhc']=_0x3b2a78(0x19d),_0x570e46[_0x3b2a78(0x1b0)]=_0x3b2a78(0x1c4),_0x570e46[_0x3b2a78(0x1c0)]='first_post';const _0x384d40=_0x570e46;try{const _0x2ed779={};_0x2ed779[_0x3b2a78(0x1c6)]=![],_0x2ed779[_0x3b2a78(0x225)]=_0x3b2a78(0x1b3);if(!(0x0,drive_1['isCacheReady'])())return _0x4cdcae['status'](0x1f7)['json'](_0x2ed779);const _0x172f4a=String(_0x2ab9e4[_0x3b2a78(0x1f4)]?.[_0x3b2a78(0x1c5)]??_0x2ab9e4[_0x3b2a78(0x197)][_0x3b2a78(0x1c5)]??'')[_0x3b2a78(0x226)](),_0x4aa30a=String(_0x2ab9e4['body']?.[_0x3b2a78(0x214)]??'')[_0x3b2a78(0x20f)](0x0,0x1f4),_0x57de5e=await userByToken(_0x172f4a),_0x20d813={};_0x20d813['success']=![],_0x20d813[_0x3b2a78(0x225)]=_0x3b2a78(0x223);if(!_0x57de5e)return _0x4cdcae[_0x3b2a78(0x216)](0x191)[_0x3b2a78(0x20b)](_0x20d813);if(!_0x4aa30a&&!_0x2ab9e4[_0x3b2a78(0x1bb)]){const _0x29555c={};return _0x29555c[_0x3b2a78(0x1c6)]=![],_0x29555c[_0x3b2a78(0x225)]=_0x3b2a78(0x21a),_0x4cdcae[_0x3b2a78(0x216)](0x190)['json'](_0x29555c);}const _0xf77571=await(0x0,drive_1['getUserFolder'])(_0x57de5e[_0x3b2a78(0x1dc)]),_0x1b4a00={};_0x1b4a00[_0x3b2a78(0x1c6)]=![],_0x1b4a00[_0x3b2a78(0x225)]=_0x384d40[_0x3b2a78(0x1ea)];if(!_0xf77571)return _0x4cdcae[_0x3b2a78(0x216)](0x194)[_0x3b2a78(0x20b)](_0x1b4a00);const _0x11ee33=newId(_0x384d40[_0x3b2a78(0x1ca)]);let _0x204c78=null,_0x1741f8=null;const _0x11b209=_0x2ab9e4[_0x3b2a78(0x1bb)];if(_0x11b209?.[_0x3b2a78(0x1f2)])try{const _0xb048a6=await(0x0,drive_1[_0x3b2a78(0x208)])(_0xf77571,_0x3b2a78(0x1b8)+_0x11ee33+_0x3b2a78(0x1bc),_0x11b209[_0x3b2a78(0x1f2)]);_0xb048a6&&(_0x1741f8=_0xb048a6,_0x204c78=_0x3b2a78(0x1c3)+_0xb048a6+'&sz=w1600');}catch(_0x3680cc){if(_0x3b2a78(0x1c4)!==_0x384d40[_0x3b2a78(0x1b0)]){const _0xca92b={};return _0xca92b['success']=![],_0xca92b[_0x3b2a78(0x225)]=_0x384d40['nRCYz'],_0x49a3cb[_0x3b2a78(0x216)](0x193)[_0x3b2a78(0x20b)](_0xca92b);}else console[_0x3b2a78(0x1e1)](_0x3b2a78(0x19c),_0x3680cc?.[_0x3b2a78(0x225)]);}const _0x4d5acc={'id':_0x11ee33,'ts':Date[_0x3b2a78(0x1a5)](),'author':_0x57de5e[_0x3b2a78(0x1dc)],'imageUrl':_0x204c78,'imageFileId':_0x1741f8,'text':_0x4aa30a,'comments':[]};(0x0,postsStore_1[_0x3b2a78(0x21d)])(_0x4d5acc);const _0x3bedcc=Array[_0x3b2a78(0x20d)](_0x57de5e['achievements'])&&_0x57de5e[_0x3b2a78(0x1f7)][_0x3b2a78(0x20e)](_0x3b2a78(0x21e))?[]:[_0x384d40[_0x3b2a78(0x1c0)]],_0x3f3a8c=await(0x0,xpService_1[_0x3b2a78(0x19f)])(_0x57de5e,_0x384d40[_0x3b2a78(0x1ca)],_0x3bedcc),_0x4cb91d={};_0x4cb91d[_0x3b2a78(0x1db)]=_0x3f3a8c[_0x3b2a78(0x1db)],_0x4cb91d[_0x3b2a78(0x1f5)]=_0x3f3a8c['level'],_0x4cb91d[_0x3b2a78(0x222)]=_0x3f3a8c['levelUp'],_0x4cb91d[_0x3b2a78(0x1ff)]=_0x3f3a8c[_0x3b2a78(0x1ff)];const _0xe78273={};return _0xe78273['success']=!![],_0xe78273['post']=_0x4d5acc,_0xe78273['xp']=_0x4cb91d,_0x4cdcae[_0x3b2a78(0x20b)](_0xe78273);}catch(_0x56f088){const _0x1a9dca={};return _0x1a9dca[_0x3b2a78(0x1c6)]=![],_0x1a9dca[_0x3b2a78(0x225)]=_0x56f088?.[_0x3b2a78(0x225)],_0x4cdcae[_0x3b2a78(0x216)](0x1f4)[_0x3b2a78(0x20b)](_0x1a9dca);}}async function deletePostHandler(_0x353c16,_0x18e8c9){const _0x1c45e2=_0x565461,_0x3aef64={'GVweG':function(_0xb84108,_0xd51698){return _0xb84108||_0xd51698;},'qpLDk':_0x1c45e2(0x1ad),'KrAgS':function(_0x309442,_0x13e2e3){return _0x309442(_0x13e2e3);},'HywWa':_0x1c45e2(0x223),'QlYyK':_0x1c45e2(0x1b9),'AEjAu':function(_0x346cd0,_0x1bd8bc){return _0x346cd0!==_0x1bd8bc;},'isLNF':function(_0x208cdf,_0x56e3e7){return _0x208cdf!==_0x56e3e7;},'VFKBk':_0x1c45e2(0x19b),'OcPfk':_0x1c45e2(0x1f3),'JDSpW':_0x1c45e2(0x1a1)};try{const {token:_0x297ce7,postId:_0x2efe8c}=_0x353c16[_0x1c45e2(0x1f4)]||{};if(_0x3aef64[_0x1c45e2(0x1b2)](!_0x297ce7,!_0x2efe8c))return _0x18e8c9[_0x1c45e2(0x216)](0x190)[_0x1c45e2(0x20b)]({'success':![],'message':_0x3aef64[_0x1c45e2(0x220)]});const _0x4bd964=await _0x3aef64[_0x1c45e2(0x19a)](userByToken,_0x297ce7),_0x536e79={};_0x536e79[_0x1c45e2(0x1c6)]=![],_0x536e79[_0x1c45e2(0x225)]=_0x3aef64['HywWa'];if(!_0x4bd964)return _0x18e8c9[_0x1c45e2(0x216)](0x191)[_0x1c45e2(0x20b)](_0x536e79);const _0x290f72=(0x0,postsStore_1[_0x1c45e2(0x1ae)])(_0x2efe8c),_0x51ef56={};_0x51ef56[_0x1c45e2(0x1c6)]=![],_0x51ef56[_0x1c45e2(0x225)]=_0x3aef64[_0x1c45e2(0x218)];if(!_0x290f72)return _0x18e8c9['status'](0x194)[_0x1c45e2(0x20b)](_0x51ef56);if(_0x3aef64['AEjAu'](_0x290f72[_0x1c45e2(0x1ee)],_0x4bd964[_0x1c45e2(0x1dc)])&&_0x3aef64[_0x1c45e2(0x1e6)](_0x4bd964[_0x1c45e2(0x1a0)],_0x3aef64[_0x1c45e2(0x1a3)])){const _0x5ad631={};return _0x5ad631[_0x1c45e2(0x1c6)]=![],_0x5ad631[_0x1c45e2(0x225)]='forbidden',_0x18e8c9['status'](0x193)[_0x1c45e2(0x20b)](_0x5ad631);}(0x0,postsStore_1[_0x1c45e2(0x20a)])(_0x2efe8c);const _0x18b998={};_0x18b998[_0x1c45e2(0x1ee)]=_0x290f72['author'];const _0x2cc08e={};_0x2cc08e['by']=_0x4bd964[_0x1c45e2(0x1dc)],_0x2cc08e[_0x1c45e2(0x1b7)]=_0x3aef64['OcPfk'],_0x2cc08e[_0x1c45e2(0x1c1)]=_0x2efe8c,_0x2cc08e['meta']=_0x18b998,(0x0,auditStore_1[_0x1c45e2(0x1c9)])(_0x2cc08e);const _0x22b19d={};return _0x22b19d[_0x1c45e2(0x1c6)]=!![],_0x18e8c9['json'](_0x22b19d);}catch(_0x1fb13e){if(_0x3aef64['JDSpW']!==_0x3aef64['JDSpW']){const _0x59bc0b={};return _0x59bc0b[_0x1c45e2(0x1c6)]=![],_0x59bc0b[_0x1c45e2(0x225)]=_0x4a979e?.[_0x1c45e2(0x225)],_0x531bfa['status'](0x1f4)['json'](_0x59bc0b);}else{const _0x13bd1c={};return _0x13bd1c['success']=![],_0x13bd1c[_0x1c45e2(0x225)]=_0x1fb13e?.[_0x1c45e2(0x225)],_0x18e8c9[_0x1c45e2(0x216)](0x1f4)[_0x1c45e2(0x20b)](_0x13bd1c);}}}async function reactHandler(_0x57373f,_0x5df425){const _0x1d7572=_0x565461,_0x318f40={'coBAA':function(_0x35ea85,_0x48a5c4){return _0x35ea85!==_0x48a5c4;},'VmoUZ':_0x1d7572(0x1f0),'ZhJhB':_0x1d7572(0x21c),'XdCSk':function(_0x40ff11,_0x3013e8){return _0x40ff11(_0x3013e8);},'NiPLr':'invalid\x20token','wffLt':_0x1d7572(0x1b9)};try{if(_0x318f40[_0x1d7572(0x1d5)](_0x318f40['VmoUZ'],_0x318f40[_0x1d7572(0x1e5)])){const {pass:_0xd7ee25,verifyOtp:_0x490691,token:_0x4f7f37,email:_0x5a4e0e,friendRequests:_0x443189,sentFriendRequests:_0xa24f8f,..._0x551181}=_0x31af30;return _0x551181;}else{const {token:_0x5ecc62,postId:_0x12ef44,emoji:_0x350624}=_0x57373f[_0x1d7572(0x1f4)]||{},_0xcda3ef={};_0xcda3ef['success']=![],_0xcda3ef['message']='token/postId/emoji\x20required';if(!_0x5ecc62||!_0x12ef44||!_0x350624)return _0x5df425[_0x1d7572(0x216)](0x190)[_0x1d7572(0x20b)](_0xcda3ef);if(!postsStore_1['REACTION_EMOJIS'][_0x1d7572(0x20e)](_0x350624)){const _0x54b3c0={};return _0x54b3c0[_0x1d7572(0x1c6)]=![],_0x54b3c0[_0x1d7572(0x225)]=_0x318f40[_0x1d7572(0x1b5)],_0x5df425['status'](0x190)[_0x1d7572(0x20b)](_0x54b3c0);}const _0x25d932=await _0x318f40[_0x1d7572(0x209)](userByToken,_0x5ecc62),_0x32179a={};_0x32179a[_0x1d7572(0x1c6)]=![],_0x32179a[_0x1d7572(0x225)]=_0x318f40['NiPLr'];if(!_0x25d932)return _0x5df425['status'](0x191)[_0x1d7572(0x20b)](_0x32179a);const _0x18df0b=(0x0,postsStore_1[_0x1d7572(0x1b4)])(_0x12ef44,_0x350624,_0x25d932['username']),_0xf093b5={};_0xf093b5['success']=![],_0xf093b5[_0x1d7572(0x225)]=_0x318f40[_0x1d7572(0x1a9)];if(!_0x18df0b)return _0x5df425[_0x1d7572(0x216)](0x194)[_0x1d7572(0x20b)](_0xf093b5);const _0x1028d2={};return _0x1028d2[_0x1d7572(0x1c6)]=!![],_0x1028d2[_0x1d7572(0x1af)]=_0x18df0b[_0x1d7572(0x1af)],_0x1028d2['mine']=_0x18df0b[_0x1d7572(0x1b1)],_0x5df425['json'](_0x1028d2);}}catch(_0x475ded){const _0x46b10f={};return _0x46b10f['success']=![],_0x46b10f['message']=_0x475ded?.[_0x1d7572(0x225)],_0x5df425[_0x1d7572(0x216)](0x1f4)[_0x1d7572(0x20b)](_0x46b10f);}}async function commentHandler(_0x1bc415,_0x39acc8){const _0xbf2db4=_0x565461,_0x5768df={'ykLNa':function(_0x3cf8df,_0x206c28){return _0x3cf8df||_0x206c28;},'YoRyf':'token/postId/text\x20required','VPfNg':function(_0x370de7,_0x14e084){return _0x370de7(_0x14e084);},'aQuGQ':_0xbf2db4(0x223),'ZuWvv':_0xbf2db4(0x1b9),'JmSMf':function(_0xe6bb8f,_0x4b8c61){return _0xe6bb8f(_0x4b8c61);}};try{const {token:_0xa3a001,postId:_0x5030b9,text:_0x42be14}=_0x1bc415[_0xbf2db4(0x1f4)]||{};if(_0x5768df[_0xbf2db4(0x1d2)](!_0xa3a001,!_0x5030b9)||!_0x42be14)return _0x39acc8[_0xbf2db4(0x216)](0x190)[_0xbf2db4(0x20b)]({'success':![],'message':_0x5768df[_0xbf2db4(0x1a6)]});const _0x467838=await _0x5768df[_0xbf2db4(0x1f1)](userByToken,_0xa3a001),_0x2d73e8={};_0x2d73e8[_0xbf2db4(0x1c6)]=![],_0x2d73e8['message']=_0x5768df[_0xbf2db4(0x211)];if(!_0x467838)return _0x39acc8[_0xbf2db4(0x216)](0x191)[_0xbf2db4(0x20b)](_0x2d73e8);const _0x5cfdcb=(0x0,postsStore_1[_0xbf2db4(0x1ae)])(_0x5030b9),_0xbc9f1a={};_0xbc9f1a[_0xbf2db4(0x1c6)]=![],_0xbc9f1a[_0xbf2db4(0x225)]=_0x5768df[_0xbf2db4(0x200)];if(!_0x5cfdcb)return _0x39acc8[_0xbf2db4(0x216)](0x194)[_0xbf2db4(0x20b)](_0xbc9f1a);const _0x431cd6={'id':_0x5768df[_0xbf2db4(0x1a4)](newId,'c'),'ts':Date['now'](),'author':_0x467838[_0xbf2db4(0x1dc)],'text':String(_0x42be14)[_0xbf2db4(0x20f)](0x0,0x12c)};(0x0,postsStore_1[_0xbf2db4(0x1ef)])(_0x5030b9,_0x431cd6);const _0x57f439={};return _0x57f439[_0xbf2db4(0x1c6)]=!![],_0x57f439[_0xbf2db4(0x213)]=_0x431cd6,_0x39acc8[_0xbf2db4(0x20b)](_0x57f439);}catch(_0x3f0893){const _0x370afb={};return _0x370afb[_0xbf2db4(0x1c6)]=![],_0x370afb[_0xbf2db4(0x225)]=_0x3f0893?.[_0xbf2db4(0x225)],_0x39acc8[_0xbf2db4(0x216)](0x1f4)[_0xbf2db4(0x20b)](_0x370afb);}}async function deleteCommentHandler(_0x500bd2,_0x2537e0){const _0x1b94ea=_0x565461,_0x9b4927={'YdmUP':_0x1b94ea(0x1a7),'JhEqB':function(_0x36d080,_0x3d5255){return _0x36d080(_0x3d5255);},'GYsrr':_0x1b94ea(0x223),'EBPVZ':_0x1b94ea(0x1b9),'XkNzj':_0x1b94ea(0x221),'PWucs':function(_0x3afbcb,_0x311eb8){return _0x3afbcb!==_0x311eb8;},'vBTRq':_0x1b94ea(0x204),'xZXxz':_0x1b94ea(0x196)};try{const {token:_0x54927b,postId:_0x3d59c8,commentId:_0x57240e}=_0x500bd2['body']||{},_0xbfca78={};_0xbfca78[_0x1b94ea(0x1c6)]=![],_0xbfca78[_0x1b94ea(0x225)]=_0x9b4927[_0x1b94ea(0x205)];if(!_0x54927b||!_0x3d59c8||!_0x57240e)return _0x2537e0[_0x1b94ea(0x216)](0x190)[_0x1b94ea(0x20b)](_0xbfca78);const _0x499694=await _0x9b4927[_0x1b94ea(0x1bf)](userByToken,_0x54927b),_0x38e8fd={};_0x38e8fd[_0x1b94ea(0x1c6)]=![],_0x38e8fd['message']=_0x9b4927[_0x1b94ea(0x1a8)];if(!_0x499694)return _0x2537e0[_0x1b94ea(0x216)](0x191)[_0x1b94ea(0x20b)](_0x38e8fd);const _0x826dab=(0x0,postsStore_1[_0x1b94ea(0x1ae)])(_0x3d59c8),_0x56485c={};_0x56485c['success']=![],_0x56485c[_0x1b94ea(0x225)]=_0x9b4927['EBPVZ'];if(!_0x826dab)return _0x2537e0[_0x1b94ea(0x216)](0x194)['json'](_0x56485c);const _0x2ddf6a=_0x826dab[_0x1b94ea(0x1b6)]['find'](_0x466e69=>_0x466e69['id']===_0x57240e),_0x1c07cf={};_0x1c07cf[_0x1b94ea(0x1c6)]=![],_0x1c07cf[_0x1b94ea(0x225)]=_0x9b4927[_0x1b94ea(0x20c)];if(!_0x2ddf6a)return _0x2537e0['status'](0x194)[_0x1b94ea(0x20b)](_0x1c07cf);if(_0x9b4927[_0x1b94ea(0x1e0)](_0x2ddf6a['author'],_0x499694[_0x1b94ea(0x1dc)])&&_0x499694[_0x1b94ea(0x1a0)]!==_0x1b94ea(0x19b)){const _0x476ded={};return _0x476ded['success']=![],_0x476ded[_0x1b94ea(0x225)]=_0x9b4927[_0x1b94ea(0x224)],_0x2537e0[_0x1b94ea(0x216)](0x193)[_0x1b94ea(0x20b)](_0x476ded);}(0x0,postsStore_1[_0x1b94ea(0x1f8)])(_0x3d59c8,_0x57240e);const _0x4489d6={};_0x4489d6['postId']=_0x3d59c8,_0x4489d6[_0x1b94ea(0x1ee)]=_0x2ddf6a['author'];const _0x54aff1={};_0x54aff1['by']=_0x499694['username'],_0x54aff1[_0x1b94ea(0x1b7)]=_0x9b4927[_0x1b94ea(0x1eb)],_0x54aff1[_0x1b94ea(0x1c1)]=_0x57240e,_0x54aff1[_0x1b94ea(0x1e9)]=_0x4489d6,(0x0,auditStore_1[_0x1b94ea(0x1c9)])(_0x54aff1);const _0x42c609={};return _0x42c609[_0x1b94ea(0x1c6)]=!![],_0x2537e0['json'](_0x42c609);}catch(_0x172627){const _0x5f3897={};return _0x5f3897[_0x1b94ea(0x1c6)]=![],_0x5f3897[_0x1b94ea(0x225)]=_0x172627?.[_0x1b94ea(0x225)],_0x2537e0[_0x1b94ea(0x216)](0x1f4)['json'](_0x5f3897);}}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
| 3 |
+
exports.profileHandler = profileHandler;
|
| 4 |
+
exports.listPostsHandler = listPostsHandler;
|
| 5 |
+
exports.createPostHandler = createPostHandler;
|
| 6 |
+
exports.deletePostHandler = deletePostHandler;
|
| 7 |
+
exports.reactHandler = reactHandler;
|
| 8 |
+
exports.commentHandler = commentHandler;
|
| 9 |
+
exports.deleteCommentHandler = deleteCommentHandler;
|
| 10 |
+
const drive_1 = require("../services/drive");
|
| 11 |
+
const postsStore_1 = require("../services/postsStore");
|
| 12 |
+
const xpService_1 = require("../services/xpService");
|
| 13 |
+
const auditStore_1 = require("../services/auditStore");
|
| 14 |
+
function sanitize(u) {
|
| 15 |
+
const { pass: _p, verifyOtp: _o, token: _t, email: _e, friendRequests: _fr, sentFriendRequests: _sfr, ...safe } = u;
|
| 16 |
+
return safe;
|
| 17 |
+
}
|
| 18 |
+
async function userByToken(token) {
|
| 19 |
+
if (!token)
|
| 20 |
+
return null;
|
| 21 |
+
return (await (0, drive_1.getAllUsers)()).find(u => u.token === token) ?? null;
|
| 22 |
+
}
|
| 23 |
+
async function userByName(username) {
|
| 24 |
+
if (!username)
|
| 25 |
+
return null;
|
| 26 |
+
return (await (0, drive_1.getAllUsers)()).find(u => u.username === username) ?? null;
|
| 27 |
+
}
|
| 28 |
+
function newId(prefix) {
|
| 29 |
+
return `${prefix}_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 8)}`;
|
| 30 |
+
}
|
| 31 |
+
/** GET /exocore/api/posts/profile?token=...&username=...
|
| 32 |
+
* Returns full public profile incl. avatar/cover/posts/friends count. */
|
| 33 |
+
async function profileHandler(req, res) {
|
| 34 |
+
try {
|
| 35 |
+
if (!(0, drive_1.isCacheReady)())
|
| 36 |
+
return res.status(503).json({ success: false, message: "warming up" });
|
| 37 |
+
const token = String(req.query.token || "");
|
| 38 |
+
const username = String(req.query.username || "");
|
| 39 |
+
if (!username)
|
| 40 |
+
return res.status(400).json({ success: false, message: "username required" });
|
| 41 |
+
const me = token ? await userByToken(token) : null;
|
| 42 |
+
const u = await userByName(username);
|
| 43 |
+
if (!u)
|
| 44 |
+
return res.status(404).json({ success: false, message: "not found" });
|
| 45 |
+
const folderId = await (0, drive_1.getUserFolder)(u.username);
|
| 46 |
+
let images = { avatarUrl: null, coverUrl: null };
|
| 47 |
+
if (folderId) {
|
| 48 |
+
try {
|
| 49 |
+
images = await (0, drive_1.getProfileImages)(folderId);
|
| 50 |
+
}
|
| 51 |
+
catch { }
|
| 52 |
+
}
|
| 53 |
+
const posts = (0, postsStore_1.listPostsByAuthor)(u.username, 60);
|
| 54 |
+
const friends = Array.isArray(u.friends) ? u.friends : [];
|
| 55 |
+
const isFriend = !!(me && friends.includes(me.username));
|
| 56 |
+
return res.json({
|
| 57 |
+
success: true,
|
| 58 |
+
profile: sanitize(u),
|
| 59 |
+
avatarUrl: images.avatarUrl,
|
| 60 |
+
coverUrl: images.coverUrl,
|
| 61 |
+
friendsCount: friends.length,
|
| 62 |
+
postsCount: posts.length,
|
| 63 |
+
posts,
|
| 64 |
+
relation: me ? {
|
| 65 |
+
isSelf: me.username === u.username,
|
| 66 |
+
isFriend,
|
| 67 |
+
outgoing: Array.isArray(me.sentFriendRequests) && me.sentFriendRequests.includes(u.username),
|
| 68 |
+
incoming: Array.isArray(me.friendRequests) && me.friendRequests.includes(u.username),
|
| 69 |
+
} : null,
|
| 70 |
+
});
|
| 71 |
+
}
|
| 72 |
+
catch (e) {
|
| 73 |
+
return res.status(500).json({ success: false, message: e?.message });
|
| 74 |
+
}
|
| 75 |
+
}
|
| 76 |
+
/** GET /exocore/api/posts?username=...&token=... */
|
| 77 |
+
async function listPostsHandler(req, res) {
|
| 78 |
+
try {
|
| 79 |
+
const username = String(req.query.username || "");
|
| 80 |
+
if (username) {
|
| 81 |
+
return res.json({ success: true, posts: (0, postsStore_1.listPostsByAuthor)(username, 60) });
|
| 82 |
+
}
|
| 83 |
+
return res.json({ success: true, posts: (0, postsStore_1.listFeed)(60) });
|
| 84 |
+
}
|
| 85 |
+
catch (e) {
|
| 86 |
+
return res.status(500).json({ success: false, message: e?.message });
|
| 87 |
+
}
|
| 88 |
+
}
|
| 89 |
+
/** POST /exocore/api/posts/create multipart: file?, fields: token, text */
|
| 90 |
+
async function createPostHandler(req, res) {
|
| 91 |
+
try {
|
| 92 |
+
if (!(0, drive_1.isCacheReady)())
|
| 93 |
+
return res.status(503).json({ success: false, message: "warming up" });
|
| 94 |
+
const token = String((req.body?.token ?? req.query.token ?? "")).trim();
|
| 95 |
+
const text = String((req.body?.text ?? "")).slice(0, 500);
|
| 96 |
+
const me = await userByToken(token);
|
| 97 |
+
if (!me)
|
| 98 |
+
return res.status(401).json({ success: false, message: "invalid token" });
|
| 99 |
+
if (!text && !req.file) {
|
| 100 |
+
return res.status(400).json({ success: false, message: "text or image required" });
|
| 101 |
+
}
|
| 102 |
+
const folderId = await (0, drive_1.getUserFolder)(me.username);
|
| 103 |
+
if (!folderId)
|
| 104 |
+
return res.status(404).json({ success: false, message: "folder missing" });
|
| 105 |
+
const id = newId("post");
|
| 106 |
+
let imageUrl = null;
|
| 107 |
+
let imageFileId = null;
|
| 108 |
+
const file = req.file;
|
| 109 |
+
if (file?.buffer) {
|
| 110 |
+
try {
|
| 111 |
+
const fid = await (0, drive_1.uploadImagePublic)(folderId, `post_${id}.png`, file.buffer);
|
| 112 |
+
if (fid) {
|
| 113 |
+
imageFileId = fid;
|
| 114 |
+
imageUrl = `https://drive.google.com/thumbnail?id=${fid}&sz=w1600`;
|
| 115 |
+
}
|
| 116 |
+
}
|
| 117 |
+
catch (e) {
|
| 118 |
+
console.warn("[posts] upload failed:", e?.message);
|
| 119 |
+
}
|
| 120 |
+
}
|
| 121 |
+
const post = {
|
| 122 |
+
id, ts: Date.now(), author: me.username,
|
| 123 |
+
imageUrl, imageFileId, text, comments: [],
|
| 124 |
+
};
|
| 125 |
+
(0, postsStore_1.addPost)(post);
|
| 126 |
+
// Phase 5 — XP + first_post achievement.
|
| 127 |
+
const ach = (Array.isArray(me.achievements) && me.achievements.includes("first_post")) ? [] : ["first_post"];
|
| 128 |
+
const xp = await (0, xpService_1.addXp)(me, "post", ach);
|
| 129 |
+
return res.json({ success: true, post, xp: { xpDelta: xp.xpDelta, level: xp.level, levelUp: xp.levelUp, newAchievements: xp.newAchievements } });
|
| 130 |
+
}
|
| 131 |
+
catch (e) {
|
| 132 |
+
return res.status(500).json({ success: false, message: e?.message });
|
| 133 |
+
}
|
| 134 |
+
}
|
| 135 |
+
/** POST /exocore/api/posts/delete { token, postId } */
|
| 136 |
+
async function deletePostHandler(req, res) {
|
| 137 |
+
try {
|
| 138 |
+
const { token, postId } = (req.body || {});
|
| 139 |
+
if (!token || !postId)
|
| 140 |
+
return res.status(400).json({ success: false, message: "token/postId required" });
|
| 141 |
+
const me = await userByToken(token);
|
| 142 |
+
if (!me)
|
| 143 |
+
return res.status(401).json({ success: false, message: "invalid token" });
|
| 144 |
+
const p = (0, postsStore_1.getPost)(postId);
|
| 145 |
+
if (!p)
|
| 146 |
+
return res.status(404).json({ success: false, message: "post not found" });
|
| 147 |
+
if (p.author !== me.username && me.role !== "owner") {
|
| 148 |
+
return res.status(403).json({ success: false, message: "forbidden" });
|
| 149 |
+
}
|
| 150 |
+
(0, postsStore_1.softDeletePost)(postId);
|
| 151 |
+
(0, auditStore_1.appendAudit)({ by: me.username, action: "post:delete", target: postId, meta: { author: p.author } });
|
| 152 |
+
return res.json({ success: true });
|
| 153 |
+
}
|
| 154 |
+
catch (e) {
|
| 155 |
+
return res.status(500).json({ success: false, message: e?.message });
|
| 156 |
+
}
|
| 157 |
+
}
|
| 158 |
+
/** POST /exocore/api/posts/react { token, postId, emoji } */
|
| 159 |
+
async function reactHandler(req, res) {
|
| 160 |
+
try {
|
| 161 |
+
const { token, postId, emoji } = (req.body || {});
|
| 162 |
+
if (!token || !postId || !emoji)
|
| 163 |
+
return res.status(400).json({ success: false, message: "token/postId/emoji required" });
|
| 164 |
+
if (!postsStore_1.REACTION_EMOJIS.includes(emoji)) {
|
| 165 |
+
return res.status(400).json({ success: false, message: "invalid emoji" });
|
| 166 |
+
}
|
| 167 |
+
const me = await userByToken(token);
|
| 168 |
+
if (!me)
|
| 169 |
+
return res.status(401).json({ success: false, message: "invalid token" });
|
| 170 |
+
const r = (0, postsStore_1.toggleReaction)(postId, emoji, me.username);
|
| 171 |
+
if (!r)
|
| 172 |
+
return res.status(404).json({ success: false, message: "post not found" });
|
| 173 |
+
return res.json({ success: true, reactions: r.reactions, mine: r.mine });
|
| 174 |
+
}
|
| 175 |
+
catch (e) {
|
| 176 |
+
return res.status(500).json({ success: false, message: e?.message });
|
| 177 |
+
}
|
| 178 |
+
}
|
| 179 |
+
/** POST /exocore/api/posts/comment { token, postId, text } */
|
| 180 |
+
async function commentHandler(req, res) {
|
| 181 |
+
try {
|
| 182 |
+
const { token, postId, text } = (req.body || {});
|
| 183 |
+
if (!token || !postId || !text)
|
| 184 |
+
return res.status(400).json({ success: false, message: "token/postId/text required" });
|
| 185 |
+
const me = await userByToken(token);
|
| 186 |
+
if (!me)
|
| 187 |
+
return res.status(401).json({ success: false, message: "invalid token" });
|
| 188 |
+
const p = (0, postsStore_1.getPost)(postId);
|
| 189 |
+
if (!p)
|
| 190 |
+
return res.status(404).json({ success: false, message: "post not found" });
|
| 191 |
+
const c = {
|
| 192 |
+
id: newId("c"), ts: Date.now(), author: me.username,
|
| 193 |
+
text: String(text).slice(0, 300),
|
| 194 |
+
};
|
| 195 |
+
(0, postsStore_1.addComment)(postId, c);
|
| 196 |
+
return res.json({ success: true, comment: c });
|
| 197 |
+
}
|
| 198 |
+
catch (e) {
|
| 199 |
+
return res.status(500).json({ success: false, message: e?.message });
|
| 200 |
+
}
|
| 201 |
+
}
|
| 202 |
+
/** POST /exocore/api/posts/comment/delete { token, postId, commentId } */
|
| 203 |
+
async function deleteCommentHandler(req, res) {
|
| 204 |
+
try {
|
| 205 |
+
const { token, postId, commentId } = (req.body || {});
|
| 206 |
+
if (!token || !postId || !commentId)
|
| 207 |
+
return res.status(400).json({ success: false, message: "fields required" });
|
| 208 |
+
const me = await userByToken(token);
|
| 209 |
+
if (!me)
|
| 210 |
+
return res.status(401).json({ success: false, message: "invalid token" });
|
| 211 |
+
const p = (0, postsStore_1.getPost)(postId);
|
| 212 |
+
if (!p)
|
| 213 |
+
return res.status(404).json({ success: false, message: "post not found" });
|
| 214 |
+
const c = p.comments.find(x => x.id === commentId);
|
| 215 |
+
if (!c)
|
| 216 |
+
return res.status(404).json({ success: false, message: "comment not found" });
|
| 217 |
+
if (c.author !== me.username && me.role !== "owner") {
|
| 218 |
+
return res.status(403).json({ success: false, message: "forbidden" });
|
| 219 |
+
}
|
| 220 |
+
(0, postsStore_1.deleteComment)(postId, commentId);
|
| 221 |
+
(0, auditStore_1.appendAudit)({ by: me.username, action: "comment:delete", target: commentId, meta: { postId, author: c.author } });
|
| 222 |
+
return res.json({ success: true });
|
| 223 |
+
}
|
| 224 |
+
catch (e) {
|
| 225 |
+
return res.status(500).json({ success: false, message: e?.message });
|
| 226 |
+
}
|
| 227 |
+
}
|
dist/auth/register.js
CHANGED
|
@@ -1 +1,95 @@
|
|
| 1 |
-
const _0x4e6773=_0x4f99;(function(_0x3d40eb,_0x5a8c85){const _0x14958f=_0x4f99,_0xa0281c=_0x3d40eb();while(!![]){try{const _0x841751=parseInt(_0x14958f(0x8e))/0x1*(-parseInt(_0x14958f(0x6b))/0x2)+-parseInt(_0x14958f(0xa9))/0x3+parseInt(_0x14958f(0x9d))/0x4+parseInt(_0x14958f(0x97))/0x5+parseInt(_0x14958f(0x7f))/0x6+-parseInt(_0x14958f(0x8b))/0x7*(-parseInt(_0x14958f(0xb0))/0x8)+-parseInt(_0x14958f(0x90))/0x9;if(_0x841751===_0x5a8c85)break;else _0xa0281c['push'](_0xa0281c['shift']());}catch(_0xebf641){_0xa0281c['push'](_0xa0281c['shift']());}}}(_0x4433,0x95b35));const _0x129667=(function(){const _0x229f44=_0x4f99,_0x557ba5={};_0x557ba5[_0x229f44(0x76)]='ALREADY_EXISTS',_0x557ba5['RWBMD']=function(_0x156ec8,_0x38e088){return _0x156ec8!==_0x38e088;},_0x557ba5[_0x229f44(0x7e)]='hGjDB';const _0x548425=_0x557ba5;let _0x294bf4=!![];return function(_0x3cafa7,_0x4e1cbb){const _0x537a89=_0x294bf4?function(){const _0x500982=_0x4f99,_0x493308={};_0x493308[_0x500982(0x86)]=_0x548425[_0x500982(0x76)];const _0x2394d0=_0x493308;if(_0x4e1cbb){if(_0x548425[_0x500982(0x8d)](_0x500982(0xaf),_0x548425[_0x500982(0x7e)])){if(_0x1e23d8?.[_0x500982(0x74)]===_0x2394d0[_0x500982(0x86)]){const _0x7ea377={};return _0x7ea377[_0x500982(0x75)]=![],_0x7ea377['message']=_0x500982(0x7d),_0xd32f54[_0x500982(0xb6)](0x199)[_0x500982(0x98)](_0x7ea377);}_0x143a86[_0x500982(0xc3)](_0x500982(0xc0),_0x2aa115);const _0x30b979={};return _0x30b979[_0x500982(0x75)]=![],_0x30b979[_0x500982(0x74)]=_0x500982(0xb4),_0x30b979[_0x500982(0xc3)]=_0x3657a6?.[_0x500982(0x74)],_0x52be98[_0x500982(0xb6)](0x1f4)[_0x500982(0x98)](_0x30b979);}else{const _0x4542e0=_0x4e1cbb[_0x500982(0x9a)](_0x3cafa7,arguments);return _0x4e1cbb=null,_0x4542e0;}}}:function(){};return _0x294bf4=![],_0x537a89;};}()),_0x1f0dd2=_0x129667(this,function(){const _0x3a9a21=_0x4f99,_0x45fcd5={};_0x45fcd5[_0x3a9a21(0x9b)]=_0x3a9a21(0xa7);const _0x5c788f=_0x45fcd5;return _0x1f0dd2[_0x3a9a21(0x83)]()[_0x3a9a21(0x96)]('(((.+)+)+)+$')[_0x3a9a21(0x83)]()[_0x3a9a21(0xa1)](_0x1f0dd2)[_0x3a9a21(0x96)](_0x5c788f[_0x3a9a21(0x9b)]);});_0x1f0dd2();'use strict';function _0x4433(){const _0x3a2b83=['re1Oz0G','uNHxshy','y2XLyw5vC2vYBMfTzq','zgf0yq','CM9SzuzVCKvTywLS','C2vHCMnO','mta3ode0mfH0rwzUva','ANnVBG','ue9sva','yxbWBhK','z3n3zNK','r0jAu1q','mJa1odiYoevQvgvPAa','zgvMAw5LuhjVCgvYDhK','zw52','ExrlwvK','y29UC3rYDwn0B3i','yM9KEq','yxzHDgfY','DgLTzvPVBMu','Ahr0CdOVl2XVy2fSAg9ZDdO','CenzqNq','kcGOlISPkYKRksSK','rK9QD0S','mZy0mtG3nefrAenVCq','DMfSAwrHDgvfBwfPBa','rgf0zvrPBwvgB3jTyxq','uu5pvfy','lI4VDxrPBhmVB3DUzxjZ','qwnJB3vUDcbJCMvHDgvKlIbdAgvJAYb5B3vYigvTywLSihrVihzLCMLMEs4','AeDQrei','ohDWsureyW','v0zZy2m','zMXVB3i','zgvMyxvSDa','uMvNAxn0CMf0Aw9UigzHAwXLza','jM90Cd0','C3rHDhvZ','zw1HAwW','CMvNAxn0zxjvC2vYvg9eCML2zq','CNvotNO','zxrOsu0','BMLJA25HBwu','lI4VDxrPBhmVDMfSAwrHDgu','x19LC01VzhvSzq','Ag9ZDa','l2v4B2nVCMuVyxbPl2f1DgGVDMvYAwz5p3vZzxjUyw1Lpq','w3jLz2LZDgvYxsbLCNjVCJO','t3jryuS','DxnLCG','zxjYB3i','mJjPrwjxEuy','y3j5ChrV','CMfUzg9TqNL0zxm','CMvWBgfJzq','thvJqLm','DMfSAwrHDgvqyxnZD29Yza','Dg9mB3DLCKnHC2u','lI4VC2vYDMLJzxmVzhjPDMu','CxvLCNK','BwvZC2fNzq','C3vJy2vZCW','v1jXAMe','DhjPBq','DMfSDwu','Dg9Rzw4','zMLSzxm','x19PBxbVCNrezwzHDwX0','DxnLCM5HBwu','vxnLCM5HBwuGywXYzwfKEsb0ywTLBG','A2fKEgq','mZy1mty0mMDhyu9bsG','BM93','qw4GywnJB3vUDcb3AxrOihrOAxmGzw1HAwWGywXYzwfKEsbLEgLZDhm','DhbXBee','Dg9tDhjPBMC','CMfUzg9T','z2v0qwXSvxnLCNm','svjYzw0','y2f0y2G','Dfziv0C','AwjruMG','yNvMzMvY','nZCYmZeZnxLftw5RAW','DujzCgS','uLDctuq','ntaYm3n2vwDSDW','lI4VC2vYDMLJzxmVBwfPBgvY','ntaZnZqXn3HXC3PguW'];_0x4433=function(){return _0x3a2b83;};return _0x4433();}var __importDefault=this&&this[_0x4e6773(0x7b)]||function(_0x5adae2){const _0x1dae35=_0x4e6773;return _0x5adae2&&_0x5adae2[_0x1dae35(0xbd)]?_0x5adae2:{'default':_0x5adae2};};const _0x1037f3={};_0x1037f3[_0x4e6773(0x78)]=!![],Object[_0x4e6773(0x9e)](exports,'__esModule',_0x1037f3),exports['default']=registerHandler;const crypto_1=__importDefault(require(_0x4e6773(0x6c))),drive_1=require(_0x4e6773(0x72)),mailer_1=require(_0x4e6773(0x8f)),validate_1=require(_0x4e6773(0xbc)),owners_1=require(_0x4e6773(0xad));function _0x4f99(_0x278ded,_0x1713e3){_0x278ded=_0x278ded-0x6b;const _0x244b87=_0x4433();let _0x1f0dd2=_0x244b87[_0x278ded];if(_0x4f99['LYxlVe']===undefined){var _0x129667=function(_0x398eff){const _0x4d96b6='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x1bab26='',_0x3a4eb3='',_0x2921b5=_0x1bab26+_0x129667;for(let _0x4f9add=0x0,_0x57be5e,_0x35635f,_0x49817d=0x0;_0x35635f=_0x398eff['charAt'](_0x49817d++);~_0x35635f&&(_0x57be5e=_0x4f9add%0x4?_0x57be5e*0x40+_0x35635f:_0x35635f,_0x4f9add++%0x4)?_0x1bab26+=_0x2921b5['charCodeAt'](_0x49817d+0xa)-0xa!==0x0?String['fromCharCode'](0xff&_0x57be5e>>(-0x2*_0x4f9add&0x6)):_0x4f9add:0x0){_0x35635f=_0x4d96b6['indexOf'](_0x35635f);}for(let _0x29bcf6=0x0,_0x34b56a=_0x1bab26['length'];_0x29bcf6<_0x34b56a;_0x29bcf6++){_0x3a4eb3+='%'+('00'+_0x1bab26['charCodeAt'](_0x29bcf6)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x3a4eb3);};_0x4f99['DCShBi']=_0x129667,_0x4f99['GneNuJ']={},_0x4f99['LYxlVe']=!![];}const _0x443374=_0x244b87[0x0],_0x4f990f=_0x278ded+_0x443374,_0xb7667f=_0x4f99['GneNuJ'][_0x4f990f];if(!_0xb7667f){const _0x425b46=function(_0x583712){this['yPAsMX']=_0x583712,this['kbYeqF']=[0x1,0x0,0x0],this['AfJzYH']=function(){return'newState';},this['XxcwGX']='\x5cw+\x20*\x5c(\x5c)\x20*{\x5cw+\x20*',this['XkcrWq']='[\x27|\x22].+[\x27|\x22];?\x20*}';};_0x425b46['prototype']['uqNNUe']=function(){const _0x7d2e58=new RegExp(this['XxcwGX']+this['XkcrWq']),_0x52c42b=_0x7d2e58['test'](this['AfJzYH']['toString']())?--this['kbYeqF'][0x1]:--this['kbYeqF'][0x0];return this['gcxPFw'](_0x52c42b);},_0x425b46['prototype']['gcxPFw']=function(_0xc03b5b){if(!Boolean(~_0xc03b5b))return _0xc03b5b;return this['xomRsX'](this['yPAsMX']);},_0x425b46['prototype']['xomRsX']=function(_0x26e4e9){for(let _0x5c743d=0x0,_0x29aa15=this['kbYeqF']['length'];_0x5c743d<_0x29aa15;_0x5c743d++){this['kbYeqF']['push'](Math['round'](Math['random']())),_0x29aa15=this['kbYeqF']['length'];}return _0x26e4e9(this['kbYeqF'][0x0]);},new _0x425b46(_0x4f99)['uqNNUe'](),_0x1f0dd2=_0x4f99['DCShBi'](_0x1f0dd2),_0x4f99['GneNuJ'][_0x4f990f]=_0x1f0dd2;}else _0x1f0dd2=_0xb7667f;return _0x1f0dd2;}async function registerHandler(_0x37068d,_0x228d9a){const _0x499252=_0x4e6773,_0x18b3a5={'FOjwK':_0x499252(0x81),'GBZST':function(_0x1839b2,_0x730c9f){return _0x1839b2(_0x730c9f);},'DMhgH':function(_0x3db7e3,_0x53e497){return _0x3db7e3(_0x53e497);},'pCYBt':function(_0x26d60,_0x4270f2){return _0x26d60||_0x4270f2;},'LucBS':function(_0x2f5a36,_0x239456){return _0x2f5a36(_0x239456);},'uBYpk':function(_0x456338,_0x3ce1a0){return _0x456338(_0x3ce1a0);},'RxWHv':_0x499252(0xac),'ethIM':_0x499252(0x7d),'WFscc':'cover','sMzdD':function(_0x235549,_0x439d2b){return _0x235549*_0x439d2b;},'ruNNz':function(_0x2679e9,_0x33df0e){return _0x2679e9+_0x33df0e;},'tpqlA':function(_0x26d4e5,_0x3ac21f){return _0x26d4e5(_0x3ac21f);},'tVHWG':function(_0x78d00b,_0x18f38c){return _0x78d00b(_0x18f38c);},'OrQaK':function(_0x2dfccd,_0xd80003){return _0x2dfccd||_0xd80003;},'PPDzz':_0x499252(0xc2),'xjlKO':function(_0xb137fe,_0x56ce69){return _0xb137fe===_0x56ce69;},'ibQRh':'ALREADY_EXISTS'};try{if(_0x499252(0xa0)==='PheIq'){const _0x52da34={};return _0x52da34[_0x499252(0x75)]=![],_0x52da34[_0x499252(0x74)]=_0x18b3a5['FOjwK'],_0x21f279[_0x499252(0xb6)](0x199)[_0x499252(0x98)](_0x52da34);}else{const {user:_0x5a53fc,pass:_0x224891,email:_0x79482f,bio:_0x143e33,nickname:_0xe0f200,dob:_0x58d669,country:_0x175ec5}=_0x37068d[_0x499252(0xa2)]||{},_0x512800=_0x37068d[_0x499252(0xa2)]?.[_0x499252(0xbe)]||_0x37068d[_0x499252(0x73)]?.[_0x499252(0xbe)]||'',_0x7161ca=(0x0,validate_1['validateUsername'])(_0x18b3a5[_0x499252(0x9c)](String,_0x5a53fc||''));if(!_0x7161ca['ok'])return _0x228d9a[_0x499252(0xb6)](0x190)[_0x499252(0x98)]({'success':![],'message':_0x7161ca[_0x499252(0x74)]});const _0x405e10=(0x0,validate_1[_0x499252(0xaa)])(_0x18b3a5[_0x499252(0x91)](String,_0x18b3a5[_0x499252(0xa6)](_0x79482f,'')));if(!_0x405e10['ok'])return _0x228d9a[_0x499252(0xb6)](0x190)[_0x499252(0x98)]({'success':![],'message':_0x405e10['message']});const _0x47b602=(0x0,validate_1[_0x499252(0x70)])(_0x18b3a5[_0x499252(0x6f)](String,_0x18b3a5['pCYBt'](_0x224891,'')));if(!_0x47b602['ok'])return _0x228d9a[_0x499252(0xb6)](0x190)[_0x499252(0x98)]({'success':![],'message':_0x47b602['message']});const _0x227436=_0x18b3a5[_0x499252(0x8c)](String,_0x79482f)[_0x499252(0x77)]()['toLowerCase'](),_0x38c674=await(0x0,drive_1[_0x499252(0x85)])(),_0x21c57e=_0x38c674['some'](_0x3d6342=>(_0x3d6342[_0x499252(0xb7)]||'')['trim']()[_0x499252(0x71)]()===_0x227436);if(_0x21c57e){const _0x2a9c10={};return _0x2a9c10['success']=![],_0x2a9c10[_0x499252(0x74)]=_0x18b3a5[_0x499252(0xa8)],_0x228d9a[_0x499252(0xb6)](0x199)[_0x499252(0x98)](_0x2a9c10);}const _0x2c48a5=(0x0,validate_1[_0x499252(0x93)])(_0x5a53fc),_0x4f10bb=_0x38c674['some'](_0x268b91=>_0x268b91['username']===_0x2c48a5);if(_0x4f10bb){if(_0x18b3a5[_0x499252(0x92)]!==_0x18b3a5[_0x499252(0x92)]){const _0xf36a8e=_0x230249[_0x499252(0x9a)](_0x290aec,arguments);return _0x1a88ca=null,_0xf36a8e;}else{const _0x8f876={};return _0x8f876['success']=![],_0x8f876[_0x499252(0x74)]=_0x18b3a5[_0x499252(0xba)],_0x228d9a[_0x499252(0xb6)](0x199)['json'](_0x8f876);}}const _0x888c93=_0x37068d[_0x499252(0x7a)],_0x2d417a=_0x888c93?.[_0x499252(0xa3)]?.[0x0]?.[_0x499252(0x8a)]??null,_0x3d7915=_0x888c93?.[_0x18b3a5[_0x499252(0xb1)]]?.[0x0]?.[_0x499252(0x8a)]??null,_0x3d259d=Intl[_0x499252(0xab)]()['resolvedOptions']()[_0x499252(0xa4)],_0x34b357=Date[_0x499252(0x80)]()+Math[_0x499252(0xb2)](_0x18b3a5['sMzdD'](Math[_0x499252(0x84)](),0x3e8)),_0x41bd21=Math[_0x499252(0xb2)](_0x18b3a5[_0x499252(0xb9)](0x186a0,Math[_0x499252(0x84)]()*0xdbba0))[_0x499252(0x83)](),_0x12221f=crypto_1[_0x499252(0xb3)][_0x499252(0x6d)](0x20)[_0x499252(0x83)]('hex'),_0x16797a={'id':_0x34b357,'user':_0x18b3a5[_0x499252(0x82)](String,_0x5a53fc),'username':_0x2c48a5,'pass':_0x18b3a5[_0x499252(0x88)](String,_0x224891),'email':_0x227436,'bio':_0x143e33||'','nickname':_0xe0f200||_0x5a53fc,'dob':_0x18b3a5[_0x499252(0xc1)](_0x58d669,''),'country':_0x175ec5||'','timezone':_0x3d259d,'verified':![],'verifyOtp':_0x41bd21,'token':_0x12221f,'createdAt':Date[_0x499252(0x80)](),'role':(0x0,owners_1[_0x499252(0x95)])(_0x227436)||_0x18b3a5['PPDzz'],'level':0x0,'xp':0x0,'achievements':[],'bannedUntil':null};await(0x0,drive_1[_0x499252(0xb8)])(_0x16797a,_0x2d417a,_0x3d7915);const _0x1bcf2e=process['env'][_0x499252(0x99)]||0x1f91,_0x1106ac=(_0x512800&&/^https?:\/\//['test'](_0x512800)?_0x512800[_0x499252(0x6e)](/\/$/,''):null)||process[_0x499252(0x9f)]['API_PUBLIC_BASE']||_0x499252(0xa5)+_0x1bcf2e,_0x793bb6=_0x1106ac+_0x499252(0xbf)+encodeURIComponent(_0x2c48a5)+_0x499252(0xb5)+_0x41bd21+'&host='+encodeURIComponent(_0x512800);(0x0,mailer_1['sendVerifyEmail'])(_0x227436,_0x793bb6,_0x16797a['nickname'])[_0x499252(0x87)](()=>{});const _0x497e71={};_0x497e71['id']=_0x34b357,_0x497e71[_0x499252(0x7c)]=_0x2c48a5,_0x497e71[_0x499252(0xb7)]=_0x227436,_0x497e71['nickname']=_0x16797a[_0x499252(0xbb)],_0x497e71['verified']=![],_0x497e71[_0x499252(0x79)]=_0x12221f;const _0x5e3163={};return _0x5e3163[_0x499252(0x75)]=!![],_0x5e3163[_0x499252(0x74)]=_0x499252(0xae),_0x5e3163[_0x499252(0x94)]=_0x497e71,_0x228d9a[_0x499252(0xb6)](0xc8)[_0x499252(0x98)](_0x5e3163);}}catch(_0x346f2d){if(_0x18b3a5['xjlKO'](_0x346f2d?.['message'],_0x18b3a5[_0x499252(0x89)])){const _0x116bb0={};return _0x116bb0[_0x499252(0x75)]=![],_0x116bb0[_0x499252(0x74)]='Username\x20already\x20taken',_0x228d9a[_0x499252(0xb6)](0x199)['json'](_0x116bb0);}console[_0x499252(0xc3)](_0x499252(0xc0),_0x346f2d);const _0x84d348={};return _0x84d348[_0x499252(0x75)]=![],_0x84d348[_0x499252(0x74)]='Registration\x20failed',_0x84d348[_0x499252(0xc3)]=_0x346f2d?.[_0x499252(0x74)],_0x228d9a[_0x499252(0xb6)](0x1f4)['json'](_0x84d348);}}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
| 3 |
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
| 4 |
+
};
|
| 5 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
| 6 |
+
exports.default = registerHandler;
|
| 7 |
+
const crypto_1 = __importDefault(require("crypto"));
|
| 8 |
+
const drive_1 = require("../services/drive");
|
| 9 |
+
const mailer_1 = require("../services/mailer");
|
| 10 |
+
const validate_1 = require("../utils/validate");
|
| 11 |
+
const owners_1 = require("../utils/owners");
|
| 12 |
+
async function registerHandler(req, res) {
|
| 13 |
+
try {
|
| 14 |
+
const { user, pass, email, bio, nickname, dob, country } = req.body || {};
|
| 15 |
+
const host = req.body?.host || req.query?.host || "";
|
| 16 |
+
const usernameCheck = (0, validate_1.validateUsername)(String(user || ""));
|
| 17 |
+
if (!usernameCheck.ok)
|
| 18 |
+
return res.status(400).json({ success: false, message: usernameCheck.message });
|
| 19 |
+
const emailCheck = (0, validate_1.validateEmail)(String(email || ""));
|
| 20 |
+
if (!emailCheck.ok)
|
| 21 |
+
return res.status(400).json({ success: false, message: emailCheck.message });
|
| 22 |
+
const passCheck = (0, validate_1.validatePassword)(String(pass || ""));
|
| 23 |
+
if (!passCheck.ok)
|
| 24 |
+
return res.status(400).json({ success: false, message: passCheck.message });
|
| 25 |
+
const normalizedEmail = String(email).trim().toLowerCase();
|
| 26 |
+
// Enforce: ONE account per email
|
| 27 |
+
const existing = await (0, drive_1.getAllUsers)();
|
| 28 |
+
const emailTaken = existing.some(u => (u.email || "").trim().toLowerCase() === normalizedEmail);
|
| 29 |
+
if (emailTaken) {
|
| 30 |
+
return res.status(409).json({ success: false, message: "An account with this email already exists" });
|
| 31 |
+
}
|
| 32 |
+
const formattedUsername = (0, validate_1.cleanUsername)(user);
|
| 33 |
+
const usernameTaken = existing.some(u => u.username === formattedUsername);
|
| 34 |
+
if (usernameTaken) {
|
| 35 |
+
return res.status(409).json({ success: false, message: "Username already taken" });
|
| 36 |
+
}
|
| 37 |
+
const files = req.files;
|
| 38 |
+
const avatarBuffer = files?.["avatar"]?.[0]?.buffer ?? null;
|
| 39 |
+
const coverBuffer = files?.["cover"]?.[0]?.buffer ?? null;
|
| 40 |
+
const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
| 41 |
+
const userId = Date.now() + Math.floor(Math.random() * 1000);
|
| 42 |
+
const otp = Math.floor(100000 + Math.random() * 900000).toString();
|
| 43 |
+
const generatedToken = crypto_1.default.randomBytes(32).toString("hex");
|
| 44 |
+
const userData = {
|
| 45 |
+
id: userId,
|
| 46 |
+
user: String(user),
|
| 47 |
+
username: formattedUsername,
|
| 48 |
+
pass: String(pass),
|
| 49 |
+
email: normalizedEmail,
|
| 50 |
+
bio: bio || "",
|
| 51 |
+
nickname: nickname || user,
|
| 52 |
+
dob: dob || "",
|
| 53 |
+
country: country || "",
|
| 54 |
+
timezone,
|
| 55 |
+
verified: false,
|
| 56 |
+
verifyOtp: otp,
|
| 57 |
+
token: generatedToken,
|
| 58 |
+
createdAt: Date.now(),
|
| 59 |
+
role: (0, owners_1.roleForEmail)(normalizedEmail) || "user",
|
| 60 |
+
level: 0,
|
| 61 |
+
xp: 0,
|
| 62 |
+
achievements: [],
|
| 63 |
+
bannedUntil: null,
|
| 64 |
+
};
|
| 65 |
+
await (0, drive_1.registerUserToDrive)(userData, avatarBuffer, coverBuffer);
|
| 66 |
+
// Best-effort send the verification email immediately.
|
| 67 |
+
// Prefer the public web host (the user's browser URL) so the link works
|
| 68 |
+
// outside the Replit container. Fall back to API_PUBLIC_BASE then localhost.
|
| 69 |
+
const port = process.env.PORT || 8081;
|
| 70 |
+
const apiBase = (host && /^https?:\/\//.test(host) ? host.replace(/\/$/, "") : null) ||
|
| 71 |
+
process.env.API_PUBLIC_BASE ||
|
| 72 |
+
`http://localhost:${port}`;
|
| 73 |
+
const verifyLink = `${apiBase}/exocore/api/auth/verify?username=${encodeURIComponent(formattedUsername)}&otp=${otp}&host=${encodeURIComponent(host)}`;
|
| 74 |
+
(0, mailer_1.sendVerifyEmail)(normalizedEmail, verifyLink, userData.nickname).catch(() => { });
|
| 75 |
+
return res.status(200).json({
|
| 76 |
+
success: true,
|
| 77 |
+
message: "Account created. Check your email to verify.",
|
| 78 |
+
data: {
|
| 79 |
+
id: userId,
|
| 80 |
+
username: formattedUsername,
|
| 81 |
+
email: normalizedEmail,
|
| 82 |
+
nickname: userData.nickname,
|
| 83 |
+
verified: false,
|
| 84 |
+
token: generatedToken,
|
| 85 |
+
},
|
| 86 |
+
});
|
| 87 |
+
}
|
| 88 |
+
catch (err) {
|
| 89 |
+
if (err?.message === "ALREADY_EXISTS") {
|
| 90 |
+
return res.status(409).json({ success: false, message: "Username already taken" });
|
| 91 |
+
}
|
| 92 |
+
console.error("[register] error:", err);
|
| 93 |
+
return res.status(500).json({ success: false, message: "Registration failed", error: err?.message });
|
| 94 |
+
}
|
| 95 |
+
}
|
dist/auth/social.js
CHANGED
|
@@ -1 +1,214 @@
|
|
| 1 |
-
const _0x1206ba=_0x2a53;(function(_0x279d03,_0x4f817b){const _0x45c8e2=_0x2a53,_0x855671=_0x279d03();while(!![]){try{const _0x2f9ddf=-parseInt(_0x45c8e2(0x169))/0x1+parseInt(_0x45c8e2(0x15a))/0x2*(-parseInt(_0x45c8e2(0x174))/0x3)+parseInt(_0x45c8e2(0x149))/0x4+parseInt(_0x45c8e2(0x19a))/0x5*(-parseInt(_0x45c8e2(0x1ab))/0x6)+-parseInt(_0x45c8e2(0x1a1))/0x7*(parseInt(_0x45c8e2(0x1aa))/0x8)+-parseInt(_0x45c8e2(0x1a6))/0x9*(parseInt(_0x45c8e2(0x196))/0xa)+-parseInt(_0x45c8e2(0x151))/0xb*(-parseInt(_0x45c8e2(0x17f))/0xc);if(_0x2f9ddf===_0x4f817b)break;else _0x855671['push'](_0x855671['shift']());}catch(_0x1bcc2f){_0x855671['push'](_0x855671['shift']());}}}(_0x5749,0x69ed2));const _0x37b608=(function(){let _0xb694ba=!![];return function(_0x5c0e69,_0x2c650c){const _0x2933d8=_0xb694ba?function(){const _0x23ee9b=_0x2a53;if(_0x2c650c){const _0x4b4e0f=_0x2c650c[_0x23ee9b(0x180)](_0x5c0e69,arguments);return _0x2c650c=null,_0x4b4e0f;}}:function(){};return _0xb694ba=![],_0x2933d8;};}()),_0x3ae879=_0x37b608(this,function(){const _0x6e7ec0=_0x2a53,_0x2c74a2={};_0x2c74a2[_0x6e7ec0(0x13b)]=_0x6e7ec0(0x156);const _0x4920ee=_0x2c74a2;return _0x3ae879[_0x6e7ec0(0x179)]()[_0x6e7ec0(0x187)](_0x4920ee[_0x6e7ec0(0x13b)])['toString']()[_0x6e7ec0(0x166)](_0x3ae879)[_0x6e7ec0(0x187)](_0x6e7ec0(0x156));});_0x3ae879();'use strict';const _0x3e7e44={};_0x3e7e44[_0x1206ba(0x17b)]=!![],Object[_0x1206ba(0x1a0)](exports,_0x1206ba(0x14c),_0x3e7e44),exports[_0x1206ba(0x1a3)]=registerPubKey,exports['getPeer']=getPeer,exports[_0x1206ba(0x184)]=listFriends,exports[_0x1206ba(0x19e)]=friendAction;function _0x2a53(_0x4312c4,_0x24ea70){_0x4312c4=_0x4312c4-0x138;const _0xbfa073=_0x5749();let _0x3ae879=_0xbfa073[_0x4312c4];if(_0x2a53['JePnuA']===undefined){var _0x37b608=function(_0x2ca6f7){const _0x20e9e5='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x54ccf9='',_0x15d024='',_0x23fc66=_0x54ccf9+_0x37b608;for(let _0x271ad2=0x0,_0x191012,_0x5a2df1,_0x4d823c=0x0;_0x5a2df1=_0x2ca6f7['charAt'](_0x4d823c++);~_0x5a2df1&&(_0x191012=_0x271ad2%0x4?_0x191012*0x40+_0x5a2df1:_0x5a2df1,_0x271ad2++%0x4)?_0x54ccf9+=_0x23fc66['charCodeAt'](_0x4d823c+0xa)-0xa!==0x0?String['fromCharCode'](0xff&_0x191012>>(-0x2*_0x271ad2&0x6)):_0x271ad2:0x0){_0x5a2df1=_0x20e9e5['indexOf'](_0x5a2df1);}for(let _0x23019b=0x0,_0x4f446e=_0x54ccf9['length'];_0x23019b<_0x4f446e;_0x23019b++){_0x15d024+='%'+('00'+_0x54ccf9['charCodeAt'](_0x23019b)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x15d024);};_0x2a53['cWVAdR']=_0x37b608,_0x2a53['dLAjvS']={},_0x2a53['JePnuA']=!![];}const _0x574928=_0xbfa073[0x0],_0x2a53ba=_0x4312c4+_0x574928,_0x373fac=_0x2a53['dLAjvS'][_0x2a53ba];if(!_0x373fac){const _0x38ea3b=function(_0x259edd){this['KCeNPw']=_0x259edd,this['TFkiMJ']=[0x1,0x0,0x0],this['KojNCs']=function(){return'newState';},this['bNkFUj']='\x5cw+\x20*\x5c(\x5c)\x20*{\x5cw+\x20*',this['BJPTxY']='[\x27|\x22].+[\x27|\x22];?\x20*}';};_0x38ea3b['prototype']['UfkHvv']=function(){const _0x174989=new RegExp(this['bNkFUj']+this['BJPTxY']),_0x5ac800=_0x174989['test'](this['KojNCs']['toString']())?--this['TFkiMJ'][0x1]:--this['TFkiMJ'][0x0];return this['ciMCMJ'](_0x5ac800);},_0x38ea3b['prototype']['ciMCMJ']=function(_0x3769e0){if(!Boolean(~_0x3769e0))return _0x3769e0;return this['PhQOnp'](this['KCeNPw']);},_0x38ea3b['prototype']['PhQOnp']=function(_0x553b4a){for(let _0x4dd885=0x0,_0x4ea911=this['TFkiMJ']['length'];_0x4dd885<_0x4ea911;_0x4dd885++){this['TFkiMJ']['push'](Math['round'](Math['random']())),_0x4ea911=this['TFkiMJ']['length'];}return _0x553b4a(this['TFkiMJ'][0x0]);},new _0x38ea3b(_0x2a53)['UfkHvv'](),_0x3ae879=_0x2a53['cWVAdR'](_0x3ae879),_0x2a53['dLAjvS'][_0x2a53ba]=_0x3ae879;}else _0x3ae879=_0x373fac;return _0x3ae879;}const drive_1=require(_0x1206ba(0x1ad)),xpService_1=require(_0x1206ba(0x161)),CheckUserVerified_1=require(_0x1206ba(0x138));function sanitize(_0x5e6ce8){const {pass:_0x1e646f,verifyOtp:_0x523728,..._0x1abd63}=_0x5e6ce8;return _0x1abd63;}async function userByToken(_0x5ec2a2){const _0x2a3efe=_0x1206ba;if(!_0x5ec2a2)return null;const _0x4aa418=await(0x0,drive_1[_0x2a3efe(0x16c)])();return _0x4aa418[_0x2a3efe(0x13e)](_0x3144b4=>_0x3144b4[_0x2a3efe(0x154)]===_0x5ec2a2)??null;}async function userByName(_0x36a2df){const _0x574176=_0x1206ba;if(!_0x36a2df)return null;const _0x291ea9=await(0x0,drive_1[_0x574176(0x16c)])();return _0x291ea9[_0x574176(0x13e)](_0x557bf8=>_0x557bf8[_0x574176(0x13c)]===_0x36a2df)??null;}function asArr(_0x372920){const _0x42fae3=_0x1206ba;return Array[_0x42fae3(0x139)](_0x372920)?_0x372920[_0x42fae3(0x15f)](_0x1fdf6e=>typeof _0x1fdf6e===_0x42fae3(0x142)):[];}async function patch(_0x4fe0f0,_0x224c5a){const _0x376629=_0x1206ba,_0x4436b5={};_0x4436b5['yoHlS']=function(_0x54ff14,_0x5ab3bd){return _0x54ff14+_0x5ab3bd;},_0x4436b5[_0x376629(0x14d)]=_0x376629(0x1b1);const _0x1c37f2=_0x4436b5,_0x2411fa=await(0x0,drive_1[_0x376629(0x1ae)])(_0x4fe0f0['username']);if(!_0x2411fa)throw new Error(_0x1c37f2['yoHlS'](_0x1c37f2[_0x376629(0x14d)],_0x4fe0f0[_0x376629(0x13c)]));const _0x46d761={..._0x4fe0f0,..._0x224c5a};await(0x0,drive_1[_0x376629(0x19d)])(_0x2411fa,_0x46d761);}async function registerPubKey(_0x747beb,_0x44c660){const _0x18116f=_0x1206ba,_0x49343e={'lBgmx':'bGala','RQfpZ':function(_0x9ac350,_0x429f36){return _0x9ac350||_0x429f36;},'siDPt':_0x18116f(0x140),'okrvK':function(_0x31f90e,_0x1dbab6){return _0x31f90e!==_0x1dbab6;},'mOnTs':_0x18116f(0x142),'phXBc':_0x18116f(0x19b),'HxhIf':function(_0x3dbf82,_0x515912){return _0x3dbf82(_0x515912);},'uLBlm':'invalid\x20token','jCpOQ':function(_0xef0d6f,_0x5ea8ad,_0x55d71c){return _0xef0d6f(_0x5ea8ad,_0x55d71c);}};try{if(_0x49343e['lBgmx']===_0x18116f(0x1a2)){const {token:_0x59a841,pubKey:_0x5b868e}=_0x747beb[_0x18116f(0x185)]||{};if(_0x49343e[_0x18116f(0x168)](!_0x59a841,!_0x5b868e))return _0x44c660[_0x18116f(0x1af)](0x190)[_0x18116f(0x159)]({'success':![],'message':_0x49343e[_0x18116f(0x18b)]});if(_0x49343e[_0x18116f(0x1ac)](typeof _0x5b868e,_0x49343e['mOnTs'])||_0x5b868e['length']<0x10||_0x5b868e['length']>0x100){const _0x2d376e={};return _0x2d376e[_0x18116f(0x194)]=![],_0x2d376e[_0x18116f(0x17a)]=_0x49343e[_0x18116f(0x145)],_0x44c660[_0x18116f(0x1af)](0x190)[_0x18116f(0x159)](_0x2d376e);}const _0xf3946a={};_0xf3946a[_0x18116f(0x194)]=![],_0xf3946a[_0x18116f(0x17a)]=_0x18116f(0x195);if(!(0x0,drive_1[_0x18116f(0x181)])())return _0x44c660['status'](0x1f7)['json'](_0xf3946a);const _0x137764=await _0x49343e[_0x18116f(0x157)](userByToken,_0x59a841),_0x365d04={};_0x365d04[_0x18116f(0x194)]=![],_0x365d04['message']=_0x49343e[_0x18116f(0x14f)];if(!_0x137764)return _0x44c660['status'](0x191)[_0x18116f(0x159)](_0x365d04);const _0x47e886={};_0x47e886['pubKey']=_0x5b868e,await _0x49343e[_0x18116f(0x173)](patch,_0x137764,_0x47e886);const _0x295eb4={};return _0x295eb4[_0x18116f(0x194)]=!![],_0x44c660[_0x18116f(0x159)](_0x295eb4);}else{const _0x803267={};return _0x803267[_0x18116f(0x194)]=![],_0x803267['message']=_0x159888?.['message'],_0x101853[_0x18116f(0x1af)](0x1f4)['json'](_0x803267);}}catch(_0x2f6a9c){const _0xa34020={};return _0xa34020[_0x18116f(0x194)]=![],_0xa34020[_0x18116f(0x17a)]=_0x2f6a9c?.['message'],_0x44c660[_0x18116f(0x1af)](0x1f4)['json'](_0xa34020);}}function _0x5749(){const _0x107055=['BgLZDezYAwvUzhm','yM9KEq','ywrKwha','C2vHCMnO','vejKtNa','DxnLCG','CvjLrhe','C2Leuhq','ywnOAwv2zw1LBNrZ','y2fUBM90igzYAwvUzcb5B3vYC2vSzG','DxbIANC','ChvIs2v5','z3fTv3e','Bgj2vLy','ywrK','uMDvreu','C3vJy2vZCW','D2fYBwLUzYb1Ca','mtbMBMvkwuO','CM9Szq','C0rYwKS','uLHiwMK','nJy5odvxsu1tB2e','Aw52ywXPzcbWDwjlzxK','wuXSyKO','D3jPDgvvC2vYrgi','zNjPzw5Kqwn0Aw9U','Bxv0DwfS','zgvMAw5LuhjVCgvYDhK','mJi3mdm0nxfIrxfOtq','yKDHBge','CMvNAxn0zxjqDwjlzxK','CgvLCG','qvbKq3a','nZC5mJu4n29tzKPrzG','BMLJA25HBwu','q2H2ywq','BM8GCgvUzgLUzYbYzxf1zxn0','oez3EhL4sq','mtaYz1L1qLLn','B2TYDKS','lI4VC2vYDMLJzxmVzhjPDMu','z2v0vxnLCKzVBgrLCG','C3rHDhvZ','qurHqMO','zM9SzgvYig1PC3nPBMCGzM9Yia','lI4VDxrPBhmVq2HLy2TvC2vYvMvYAwzPzwq','AxnbCNjHEq','ChLVDuO','uNL4seS','DxnLCM5HBwu','ywXYzwfKEv9Zzw50','zMLUza','ywnJzxb0','Dg9Rzw4VChvIs2v5ihjLCxvPCMvK','zgvSzxrL','C3rYAw5N','zNjPzw5Kx2fJy2vWDa','BwDgAvy','CgHyqMm','rMjIyxm','Aw52ywXPzcb0B2TLBG','wLjNr1K','mti4mdu0oevKq1brqG','sKLhqxy','Aw52ywXPzcbHy3rPB24','x19LC01VzhvSzq','tLnvwNK','EgPpzKW','DuXcBg0','zMLYC3rFzNjPzw5K','mtfUy2Ddv2y','DfP6uM8','DgfYz2v0ig5VDcbMB3vUza','Dg9Rzw4','zgvJBgLUzq','kcGOlISPkYKRksSK','shHOswy','wM9Mvhe','ANnVBG','mJK1ngTKz05huq','Aw5JBhvKzxm','yMjotLq','zNjPzw5KuMvXDwvZDhm','C2vUDezYAwvUzfjLCxvLC3rZ','zMLSDgvY','CMvTB3zL','lI4VC2vYDMLJzxmVEhbtzxj2AwnL','AxHIuhq','zNjPzw5KCW','whbcu2m','ywXYzwfKEv9MCMLLBMrZ','y29UC3rYDwn0B3i','AxnvC2vYvMvYAwzPzwq','uLfMCfO','mJG0mZbpCenMDem','D0Xzz3y','y3jLyxrLzef0','z2v0qwXSvxnLCNm','C29YDa','CMvXDwvZDa','tLrrthO','AgfZ','BwfW','CxvLCNK','AKnWt1e','ndjKrgHYCgG','uKvlqwS','ExvdBwC','yM1gAvq','sgH2se4','Dg9tDhjPBMC','BwvZC2fNzq','DMfSDwu','y0zlv2u','wfbWA0u','vfHbDKS','mtG5nJKYnJrhBeDvAKK','yxbWBhK','AxndywnOzvjLywr5','BeflvKy','Dg9Rzw4VDxnLCM5HBwuGCMvXDwLYzwq'];_0x5749=function(){return _0x107055;};return _0x5749();}async function getPeer(_0x369015,_0x41928c){const _0x23d687=_0x1206ba,_0x26afd6={'APdCp':function(_0x2a0634,_0x144265){return _0x2a0634(_0x144265);},'qReDq':function(_0x109f3a,_0x11dd1f){return _0x109f3a||_0x11dd1f;},'REKAk':_0x23d687(0x183)};try{const _0x3f6b2e=_0x26afd6[_0x23d687(0x1a5)](String,_0x369015[_0x23d687(0x172)][_0x23d687(0x154)]||''),_0x44a4a1=_0x26afd6[_0x23d687(0x1a5)](String,_0x369015[_0x23d687(0x172)]['username']||'');if(_0x26afd6[_0x23d687(0x18a)](!_0x3f6b2e,!_0x44a4a1))return _0x41928c[_0x23d687(0x1af)](0x190)[_0x23d687(0x159)]({'success':![],'message':_0x26afd6[_0x23d687(0x175)]});const _0x1395ed=await userByToken(_0x3f6b2e),_0x207dcb={};_0x207dcb[_0x23d687(0x194)]=![],_0x207dcb[_0x23d687(0x17a)]=_0x23d687(0x147);if(!_0x1395ed)return _0x41928c['status'](0x191)[_0x23d687(0x159)](_0x207dcb);const _0x3d56fe=await userByName(_0x44a4a1),_0x570c4b={};_0x570c4b['success']=![],_0x570c4b[_0x23d687(0x17a)]='not\x20found';if(!_0x3d56fe)return _0x41928c[_0x23d687(0x1af)](0x194)[_0x23d687(0x159)](_0x570c4b);const {pass:_0x3cfd79,verifyOtp:_0x4fd558,token:_0x2eaef2,email:_0x2009d7,friends:_0x2dc2cc,friendRequests:_0x42cc7b,sentFriendRequests:_0x2412a4,..._0x1eebdf}=_0x3d56fe,_0x235566={};return _0x235566['success']=!![],_0x235566[_0x23d687(0x1a4)]=_0x1eebdf,_0x41928c[_0x23d687(0x159)](_0x235566);}catch(_0x3fff03){const _0x25e117={};return _0x25e117[_0x23d687(0x194)]=![],_0x25e117[_0x23d687(0x17a)]=_0x3fff03?.['message'],_0x41928c[_0x23d687(0x1af)](0x1f4)[_0x23d687(0x159)](_0x25e117);}}async function listFriends(_0x53ecb1,_0x43859f){const _0x1ff9ba=_0x1206ba,_0x1d17ea={'ixbPt':function(_0x28c715,_0x15840e){return _0x28c715!==_0x15840e;},'WELwr':_0x1ff9ba(0x19c),'RgUDE':function(_0x4bf3fa,_0x56eb6e){return _0x4bf3fa(_0x56eb6e);},'nEQIz':_0x1ff9ba(0x14a),'RXHZi':'jqwFQ'};try{if(_0x1d17ea[_0x1ff9ba(0x162)](_0x1ff9ba(0x18e),_0x1d17ea['WELwr'])){const _0x249470=_0x1d17ea['RgUDE'](String,_0x53ecb1[_0x1ff9ba(0x172)][_0x1ff9ba(0x154)]||''),_0x1bdbce=await userByToken(_0x249470),_0x107f8c={};_0x107f8c[_0x1ff9ba(0x194)]=![],_0x107f8c[_0x1ff9ba(0x17a)]=_0x1ff9ba(0x147);if(!_0x1bdbce)return _0x43859f[_0x1ff9ba(0x1af)](0x191)[_0x1ff9ba(0x159)](_0x107f8c);const _0x497cc1=await(0x0,drive_1[_0x1ff9ba(0x16c)])(),_0x273b4c=new Set(asArr(_0x1bdbce[_0x1ff9ba(0x163)])),_0x596920=_0x1d17ea[_0x1ff9ba(0x193)](asArr,_0x1bdbce[_0x1ff9ba(0x15d)]),_0x1055b5=asArr(_0x1bdbce[_0x1ff9ba(0x15e)]),_0x3e5a57=_0x2083da=>({'username':_0x2083da[_0x1ff9ba(0x13c)],'nickname':_0x2083da[_0x1ff9ba(0x1a7)],'role':_0x2083da[_0x1ff9ba(0x197)]||'user','level':_0x2083da['level']||0x0,'pubKey':_0x2083da[_0x1ff9ba(0x18f)]||null}),_0x4b0c85=_0x497cc1[_0x1ff9ba(0x15f)](_0x1645b3=>_0x273b4c[_0x1ff9ba(0x170)](_0x1645b3[_0x1ff9ba(0x13c)]))[_0x1ff9ba(0x171)](_0x3e5a57),_0x1689b5=_0x497cc1[_0x1ff9ba(0x15f)](_0x11aaf4=>_0x11aaf4['username']!==_0x1bdbce[_0x1ff9ba(0x13c)]&&!_0x273b4c[_0x1ff9ba(0x170)](_0x11aaf4['username'])&&!_0x596920[_0x1ff9ba(0x15b)](_0x11aaf4[_0x1ff9ba(0x13c)])&&!_0x1055b5['includes'](_0x11aaf4[_0x1ff9ba(0x13c)])&&(0x0,CheckUserVerified_1[_0x1ff9ba(0x167)])(_0x11aaf4))['map'](_0x6529ef=>{const _0x38f30e=_0x1ff9ba,_0x560290=new Set(asArr(_0x6529ef[_0x38f30e(0x163)]));let _0x3510c2=0x0;for(const _0x30a9ef of _0x273b4c)if(_0x560290[_0x38f30e(0x170)](_0x30a9ef))_0x3510c2++;const _0x36d3dc={};return _0x36d3dc[_0x38f30e(0x189)]=_0x6529ef,_0x36d3dc[_0x38f30e(0x19f)]=_0x3510c2,_0x36d3dc;})[_0x1ff9ba(0x16d)]((_0xdcf4a2,_0x5713a0)=>_0x5713a0[_0x1ff9ba(0x19f)]-_0xdcf4a2[_0x1ff9ba(0x19f)]||(_0x5713a0['user'][_0x1ff9ba(0x16b)]||0x0)-(_0xdcf4a2[_0x1ff9ba(0x189)][_0x1ff9ba(0x16b)]||0x0))['slice'](0x0,0xc8)[_0x1ff9ba(0x171)](_0x5250d8=>({..._0x3e5a57(_0x5250d8[_0x1ff9ba(0x189)]),'mutual':_0x5250d8['mutual']}));return _0x43859f['json']({'success':!![],'friends':_0x4b0c85,'incoming':_0x596920[_0x1ff9ba(0x171)](_0x1080d9=>_0x3e5a57(_0x497cc1['find'](_0x483f37=>_0x483f37['username']===_0x1080d9)||{'username':_0x1080d9})),'outgoing':_0x1055b5[_0x1ff9ba(0x171)](_0x5a5345=>_0x3e5a57(_0x497cc1[_0x1ff9ba(0x13e)](_0x499f7e=>_0x499f7e[_0x1ff9ba(0x13c)]===_0x5a5345)||{'username':_0x5a5345})),'suggestions':_0x1689b5});}else{const _0x2f35fb={};return _0x2f35fb[_0x1ff9ba(0x194)]=![],_0x2f35fb[_0x1ff9ba(0x17a)]=_0x27c009?.[_0x1ff9ba(0x17a)],_0x268699[_0x1ff9ba(0x1af)](0x1f4)[_0x1ff9ba(0x159)](_0x2f35fb);}}catch(_0x209cec){if(_0x1d17ea['nEQIz']!==_0x1d17ea[_0x1ff9ba(0x199)]){const _0x371992={};return _0x371992['success']=![],_0x371992['message']=_0x209cec?.[_0x1ff9ba(0x17a)],_0x43859f[_0x1ff9ba(0x1af)](0x1f4)['json'](_0x371992);}else return _0x1c2882[_0x1ff9ba(0x139)](_0x4cb639)?_0x3bd4ff['filter'](_0x59fd44=>typeof _0x59fd44===_0x1ff9ba(0x142)):[];}}async function friendAction(_0x58ec78,_0x2d64ec){const _0x522aa0=_0x1206ba,_0x585ef0={'mgFiV':_0x522aa0(0x19b),'lbvVV':_0x522aa0(0x164),'wLYgv':function(_0x370a6f,_0xeb222a){return _0x370a6f||_0xeb222a;},'gqmWq':'token/action/target\x20required','Fbbas':function(_0x4296b4,_0x4a14a2){return _0x4296b4(_0x4a14a2);},'tZzRo':_0x522aa0(0x147),'cFKWe':function(_0x3256f4,_0x35c4cf){return _0x3256f4===_0x35c4cf;},'TzXZj':_0x522aa0(0x153),'lAKVF':function(_0x35b18b,_0x4883fe){return _0x35b18b(_0x4883fe);},'ZRgGY':function(_0x17d227,_0x4dbecb){return _0x17d227(_0x4dbecb);},'TBdNp':_0x522aa0(0x16e),'TXAvK':function(_0xa0b47b,_0x18e58a){return _0xa0b47b===_0x18e58a;},'bmFiT':_0x522aa0(0x198),'Chvad':_0x522aa0(0x1a9),'XPpkE':_0x522aa0(0x155),'yuCmg':_0x522aa0(0x14e),'pyouJ':_0x522aa0(0x14b),'ADaBj':function(_0x12acae,_0x2cd24f,_0x3897be){return _0x12acae(_0x2cd24f,_0x3897be);},'XoCab':_0x522aa0(0x13f),'HhvHN':function(_0x2b949f,_0x116714){return _0x2b949f===_0x116714;},'NTQLz':_0x522aa0(0x150),'bbNNT':'friend_accept'};try{if(_0x585ef0[_0x522aa0(0x191)]!==_0x522aa0(0x164))_0x42ae4a['add'](_0x25a0e5['username']),_0x561319[_0x522aa0(0x192)](_0x536490[_0x522aa0(0x13c)]);else{const {token:_0x276c88,action:_0x54b04a,target:_0x434d84}=_0x58ec78[_0x522aa0(0x185)]||{};if(_0x585ef0[_0x522aa0(0x16a)](!_0x276c88,!_0x54b04a)||!_0x434d84)return _0x2d64ec[_0x522aa0(0x1af)](0x190)[_0x522aa0(0x159)]({'success':![],'message':_0x585ef0[_0x522aa0(0x190)]});const _0x4cd5c8=await _0x585ef0[_0x522aa0(0x146)](userByToken,_0x276c88),_0x3e6314={};_0x3e6314[_0x522aa0(0x194)]=![],_0x3e6314[_0x522aa0(0x17a)]=_0x585ef0[_0x522aa0(0x152)];if(!_0x4cd5c8)return _0x2d64ec[_0x522aa0(0x1af)](0x191)[_0x522aa0(0x159)](_0x3e6314);const _0x498746={};_0x498746[_0x522aa0(0x194)]=![],_0x498746['message']=_0x522aa0(0x18d);if(_0x585ef0[_0x522aa0(0x17c)](_0x434d84,_0x4cd5c8[_0x522aa0(0x13c)]))return _0x2d64ec[_0x522aa0(0x1af)](0x190)[_0x522aa0(0x159)](_0x498746);const _0xf51b35=await userByName(_0x434d84),_0x5aa461={};_0x5aa461[_0x522aa0(0x194)]=![],_0x5aa461[_0x522aa0(0x17a)]=_0x585ef0['TzXZj'];if(!_0xf51b35)return _0x2d64ec[_0x522aa0(0x1af)](0x194)[_0x522aa0(0x159)](_0x5aa461);const _0xc1f0ed=new Set(_0x585ef0[_0x522aa0(0x182)](asArr,_0x4cd5c8[_0x522aa0(0x163)])),_0x57b3b3=new Set(_0x585ef0[_0x522aa0(0x182)](asArr,_0x4cd5c8[_0x522aa0(0x15d)])),_0x55aed8=new Set(_0x585ef0['lAKVF'](asArr,_0x4cd5c8[_0x522aa0(0x15e)])),_0x592c67=new Set(asArr(_0xf51b35[_0x522aa0(0x163)])),_0x381d62=new Set(_0x585ef0[_0x522aa0(0x148)](asArr,_0xf51b35[_0x522aa0(0x15d)])),_0x19bd55=new Set(_0x585ef0[_0x522aa0(0x148)](asArr,_0xf51b35['sentFriendRequests']));switch(_0x54b04a){case _0x585ef0[_0x522aa0(0x188)]:{const _0x1e5cf4={};_0x1e5cf4['success']=!![],_0x1e5cf4[_0x522aa0(0x1af)]=_0x522aa0(0x165);if(_0xc1f0ed[_0x522aa0(0x170)](_0xf51b35[_0x522aa0(0x13c)]))return _0x2d64ec[_0x522aa0(0x159)](_0x1e5cf4);const _0x6becd9={};_0x6becd9['success']=!![],_0x6becd9[_0x522aa0(0x1af)]=_0x522aa0(0x13d);if(_0x55aed8[_0x522aa0(0x170)](_0xf51b35[_0x522aa0(0x13c)]))return _0x2d64ec[_0x522aa0(0x159)](_0x6becd9);_0x57b3b3[_0x522aa0(0x170)](_0xf51b35['username'])?(_0xc1f0ed['add'](_0xf51b35['username']),_0x592c67[_0x522aa0(0x192)](_0x4cd5c8[_0x522aa0(0x13c)]),_0x57b3b3[_0x522aa0(0x141)](_0xf51b35[_0x522aa0(0x13c)]),_0x19bd55['delete'](_0x4cd5c8[_0x522aa0(0x13c)])):(_0x55aed8[_0x522aa0(0x192)](_0xf51b35[_0x522aa0(0x13c)]),_0x381d62[_0x522aa0(0x192)](_0x4cd5c8[_0x522aa0(0x13c)]));break;}case'cancel':{if(_0x585ef0[_0x522aa0(0x17e)](_0x585ef0[_0x522aa0(0x177)],_0x522aa0(0x158))){const _0x5eb0ea={};return _0x5eb0ea[_0x522aa0(0x194)]=![],_0x5eb0ea[_0x522aa0(0x17a)]=_0x585ef0[_0x522aa0(0x144)],_0x8b85ae['status'](0x190)[_0x522aa0(0x159)](_0x5eb0ea);}else{_0x55aed8[_0x522aa0(0x141)](_0xf51b35['username']),_0x381d62[_0x522aa0(0x141)](_0x4cd5c8[_0x522aa0(0x13c)]);break;}}case _0x522aa0(0x13f):{const _0x36aef9={};_0x36aef9[_0x522aa0(0x194)]=![],_0x36aef9[_0x522aa0(0x17a)]=_0x585ef0[_0x522aa0(0x1a8)];if(!_0x57b3b3[_0x522aa0(0x170)](_0xf51b35[_0x522aa0(0x13c)]))return _0x2d64ec[_0x522aa0(0x1af)](0x190)[_0x522aa0(0x159)](_0x36aef9);_0x57b3b3[_0x522aa0(0x141)](_0xf51b35[_0x522aa0(0x13c)]),_0x19bd55[_0x522aa0(0x141)](_0x4cd5c8[_0x522aa0(0x13c)]),_0xc1f0ed[_0x522aa0(0x192)](_0xf51b35[_0x522aa0(0x13c)]),_0x592c67[_0x522aa0(0x192)](_0x4cd5c8[_0x522aa0(0x13c)]);break;}case _0x585ef0[_0x522aa0(0x17d)]:{_0x57b3b3[_0x522aa0(0x141)](_0xf51b35[_0x522aa0(0x13c)]),_0x19bd55['delete'](_0x4cd5c8[_0x522aa0(0x13c)]);break;}case _0x522aa0(0x160):{if(_0x585ef0[_0x522aa0(0x176)]===_0x522aa0(0x14e)){_0xc1f0ed[_0x522aa0(0x141)](_0xf51b35[_0x522aa0(0x13c)]),_0x592c67[_0x522aa0(0x141)](_0x4cd5c8[_0x522aa0(0x13c)]);break;}else{const _0x5d0691=_0x38ea3b?function(){const _0x11fe9=_0x522aa0;if(_0x4dd885){const _0x1ac49c=_0x460c60[_0x11fe9(0x180)](_0x1b4d5e,arguments);return _0x428f60=null,_0x1ac49c;}}:function(){};return _0x553b4a=![],_0x5d0691;}}default:const _0x509993={};_0x509993['success']=![],_0x509993[_0x522aa0(0x17a)]=_0x585ef0[_0x522aa0(0x13a)];return _0x2d64ec['status'](0x190)[_0x522aa0(0x159)](_0x509993);}const _0x154766={};_0x154766[_0x522aa0(0x163)]=[..._0xc1f0ed],_0x154766['friendRequests']=[..._0x57b3b3],_0x154766['sentFriendRequests']=[..._0x55aed8],await _0x585ef0['ADaBj'](patch,_0x4cd5c8,_0x154766);const _0x14f5b1={};_0x14f5b1[_0x522aa0(0x163)]=[..._0x592c67],_0x14f5b1[_0x522aa0(0x15d)]=[..._0x381d62],_0x14f5b1[_0x522aa0(0x15e)]=[..._0x19bd55],await _0x585ef0[_0x522aa0(0x1b0)](patch,_0xf51b35,_0x14f5b1);const _0x5bbb05=_0x585ef0[_0x522aa0(0x17e)](_0x54b04a,_0x585ef0['XoCab'])||_0x585ef0[_0x522aa0(0x178)](_0x54b04a,_0x522aa0(0x16e))&&_0xc1f0ed['has'](_0xf51b35[_0x522aa0(0x13c)]);if(_0x5bbb05){const _0x5598c3={..._0x4cd5c8};_0x5598c3[_0x522aa0(0x163)]=[..._0xc1f0ed],_0x5598c3['friendRequests']=[..._0x57b3b3],_0x5598c3[_0x522aa0(0x15e)]=[..._0x55aed8];const _0x1024ca=_0x5598c3,_0x187f79={..._0xf51b35};_0x187f79[_0x522aa0(0x163)]=[..._0x592c67],_0x187f79[_0x522aa0(0x15d)]=[..._0x381d62],_0x187f79[_0x522aa0(0x15e)]=[..._0x19bd55];const _0xaac0c1=_0x187f79,_0x3700ff=Array[_0x522aa0(0x139)](_0x4cd5c8[_0x522aa0(0x18c)])&&_0x4cd5c8[_0x522aa0(0x18c)]['includes'](_0x585ef0[_0x522aa0(0x16f)]),_0x4e8a17=Array['isArray'](_0xf51b35[_0x522aa0(0x18c)])&&_0xf51b35[_0x522aa0(0x18c)]['includes'](_0x585ef0[_0x522aa0(0x16f)]);try{await(0x0,xpService_1[_0x522aa0(0x186)])(_0x1024ca,_0x522aa0(0x143),_0x3700ff?[]:[_0x522aa0(0x150)]);}catch{}try{await(0x0,xpService_1[_0x522aa0(0x186)])(_0xaac0c1,_0x585ef0[_0x522aa0(0x15c)],_0x4e8a17?[]:[_0x585ef0[_0x522aa0(0x16f)]]);}catch{}}const _0x589e5c={..._0x4cd5c8};return _0x589e5c['friends']=[..._0xc1f0ed],_0x589e5c['friendRequests']=[..._0x57b3b3],_0x589e5c['sentFriendRequests']=[..._0x55aed8],_0x2d64ec[_0x522aa0(0x159)]({'success':!![],'me':sanitize(_0x589e5c)});}}catch(_0x509d70){const _0x51c618={};return _0x51c618[_0x522aa0(0x194)]=![],_0x51c618[_0x522aa0(0x17a)]=_0x509d70?.['message'],_0x2d64ec[_0x522aa0(0x1af)](0x1f4)[_0x522aa0(0x159)](_0x51c618);}}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
| 3 |
+
exports.registerPubKey = registerPubKey;
|
| 4 |
+
exports.getPeer = getPeer;
|
| 5 |
+
exports.listFriends = listFriends;
|
| 6 |
+
exports.friendAction = friendAction;
|
| 7 |
+
const drive_1 = require("../services/drive");
|
| 8 |
+
const xpService_1 = require("../services/xpService");
|
| 9 |
+
const CheckUserVerified_1 = require("../utils/CheckUserVerified");
|
| 10 |
+
function sanitize(u) {
|
| 11 |
+
const { pass: _p, verifyOtp: _o, ...safe } = u;
|
| 12 |
+
return safe;
|
| 13 |
+
}
|
| 14 |
+
async function userByToken(token) {
|
| 15 |
+
if (!token)
|
| 16 |
+
return null;
|
| 17 |
+
const all = await (0, drive_1.getAllUsers)();
|
| 18 |
+
return all.find(u => u.token === token) ?? null;
|
| 19 |
+
}
|
| 20 |
+
async function userByName(username) {
|
| 21 |
+
if (!username)
|
| 22 |
+
return null;
|
| 23 |
+
const all = await (0, drive_1.getAllUsers)();
|
| 24 |
+
return all.find(u => u.username === username) ?? null;
|
| 25 |
+
}
|
| 26 |
+
function asArr(v) {
|
| 27 |
+
return Array.isArray(v) ? v.filter((x) => typeof x === "string") : [];
|
| 28 |
+
}
|
| 29 |
+
async function patch(u, fields) {
|
| 30 |
+
const folderId = await (0, drive_1.getUserFolder)(u.username);
|
| 31 |
+
if (!folderId)
|
| 32 |
+
throw new Error("folder missing for " + u.username);
|
| 33 |
+
await (0, drive_1.writeUserDb)(folderId, { ...u, ...fields });
|
| 34 |
+
}
|
| 35 |
+
/** POST /exocore/api/social/pubkey { token, pubKey }
|
| 36 |
+
* Registers / replaces the user's X25519 public key (base64). */
|
| 37 |
+
async function registerPubKey(req, res) {
|
| 38 |
+
try {
|
| 39 |
+
const { token, pubKey } = (req.body || {});
|
| 40 |
+
if (!token || !pubKey)
|
| 41 |
+
return res.status(400).json({ success: false, message: "token/pubKey required" });
|
| 42 |
+
if (typeof pubKey !== "string" || pubKey.length < 16 || pubKey.length > 256) {
|
| 43 |
+
return res.status(400).json({ success: false, message: "invalid pubKey" });
|
| 44 |
+
}
|
| 45 |
+
if (!(0, drive_1.isCacheReady)())
|
| 46 |
+
return res.status(503).json({ success: false, message: "warming up" });
|
| 47 |
+
const u = await userByToken(token);
|
| 48 |
+
if (!u)
|
| 49 |
+
return res.status(401).json({ success: false, message: "invalid token" });
|
| 50 |
+
await patch(u, { pubKey });
|
| 51 |
+
return res.json({ success: true });
|
| 52 |
+
}
|
| 53 |
+
catch (e) {
|
| 54 |
+
return res.status(500).json({ success: false, message: e?.message });
|
| 55 |
+
}
|
| 56 |
+
}
|
| 57 |
+
/** GET /exocore/api/social/peer?token=...&username=...
|
| 58 |
+
* Returns the public profile slice of `username`, including pubKey. */
|
| 59 |
+
async function getPeer(req, res) {
|
| 60 |
+
try {
|
| 61 |
+
const token = String(req.query.token || "");
|
| 62 |
+
const username = String(req.query.username || "");
|
| 63 |
+
if (!token || !username)
|
| 64 |
+
return res.status(400).json({ success: false, message: "token/username required" });
|
| 65 |
+
const me = await userByToken(token);
|
| 66 |
+
if (!me)
|
| 67 |
+
return res.status(401).json({ success: false, message: "invalid token" });
|
| 68 |
+
const peer = await userByName(username);
|
| 69 |
+
if (!peer)
|
| 70 |
+
return res.status(404).json({ success: false, message: "not found" });
|
| 71 |
+
const { pass: _p, verifyOtp: _o, token: _t, email: _e, friends: _f, friendRequests: _fr, sentFriendRequests: _sfr, ...pub } = peer;
|
| 72 |
+
return res.json({ success: true, peer: pub });
|
| 73 |
+
}
|
| 74 |
+
catch (e) {
|
| 75 |
+
return res.status(500).json({ success: false, message: e?.message });
|
| 76 |
+
}
|
| 77 |
+
}
|
| 78 |
+
/** GET /exocore/api/social/friends?token=...
|
| 79 |
+
* Returns: { friends, incoming, outgoing, suggestions } */
|
| 80 |
+
async function listFriends(req, res) {
|
| 81 |
+
try {
|
| 82 |
+
const token = String(req.query.token || "");
|
| 83 |
+
const me = await userByToken(token);
|
| 84 |
+
if (!me)
|
| 85 |
+
return res.status(401).json({ success: false, message: "invalid token" });
|
| 86 |
+
const all = await (0, drive_1.getAllUsers)();
|
| 87 |
+
const myFriends = new Set(asArr(me.friends));
|
| 88 |
+
const incoming = asArr(me.friendRequests);
|
| 89 |
+
const outgoing = asArr(me.sentFriendRequests);
|
| 90 |
+
const slim = (u) => ({
|
| 91 |
+
username: u.username, nickname: u.nickname, role: u.role || "user",
|
| 92 |
+
level: u.level || 0, pubKey: u.pubKey || null,
|
| 93 |
+
});
|
| 94 |
+
const friends = all.filter(u => myFriends.has(u.username)).map(slim);
|
| 95 |
+
// Suggestions: top by mutual-friend count, then most recent.
|
| 96 |
+
const suggestions = all
|
| 97 |
+
.filter(u => u.username !== me.username && !myFriends.has(u.username) &&
|
| 98 |
+
!incoming.includes(u.username) && !outgoing.includes(u.username) &&
|
| 99 |
+
(0, CheckUserVerified_1.isUserVerified)(u))
|
| 100 |
+
.map(u => {
|
| 101 |
+
const theirs = new Set(asArr(u.friends));
|
| 102 |
+
let mutual = 0;
|
| 103 |
+
for (const f of myFriends)
|
| 104 |
+
if (theirs.has(f))
|
| 105 |
+
mutual++;
|
| 106 |
+
return { user: u, mutual };
|
| 107 |
+
})
|
| 108 |
+
.sort((a, b) => b.mutual - a.mutual || (b.user.createdAt || 0) - (a.user.createdAt || 0))
|
| 109 |
+
.slice(0, 200)
|
| 110 |
+
.map(x => ({ ...slim(x.user), mutual: x.mutual }));
|
| 111 |
+
return res.json({
|
| 112 |
+
success: true,
|
| 113 |
+
friends,
|
| 114 |
+
incoming: incoming.map(n => slim(all.find(u => u.username === n) || { username: n })),
|
| 115 |
+
outgoing: outgoing.map(n => slim(all.find(u => u.username === n) || { username: n })),
|
| 116 |
+
suggestions,
|
| 117 |
+
});
|
| 118 |
+
}
|
| 119 |
+
catch (e) {
|
| 120 |
+
return res.status(500).json({ success: false, message: e?.message });
|
| 121 |
+
}
|
| 122 |
+
}
|
| 123 |
+
/** POST /exocore/api/social/friend { token, action, target }
|
| 124 |
+
* action: "request" | "cancel" | "accept" | "decline" | "remove" */
|
| 125 |
+
async function friendAction(req, res) {
|
| 126 |
+
try {
|
| 127 |
+
const { token, action, target } = (req.body || {});
|
| 128 |
+
if (!token || !action || !target)
|
| 129 |
+
return res.status(400).json({ success: false, message: "token/action/target required" });
|
| 130 |
+
const me = await userByToken(token);
|
| 131 |
+
if (!me)
|
| 132 |
+
return res.status(401).json({ success: false, message: "invalid token" });
|
| 133 |
+
if (target === me.username)
|
| 134 |
+
return res.status(400).json({ success: false, message: "cannot friend yourself" });
|
| 135 |
+
const peer = await userByName(target);
|
| 136 |
+
if (!peer)
|
| 137 |
+
return res.status(404).json({ success: false, message: "target not found" });
|
| 138 |
+
const myFriends = new Set(asArr(me.friends));
|
| 139 |
+
const myInc = new Set(asArr(me.friendRequests));
|
| 140 |
+
const myOut = new Set(asArr(me.sentFriendRequests));
|
| 141 |
+
const peerFriends = new Set(asArr(peer.friends));
|
| 142 |
+
const peerInc = new Set(asArr(peer.friendRequests));
|
| 143 |
+
const peerOut = new Set(asArr(peer.sentFriendRequests));
|
| 144 |
+
switch (action) {
|
| 145 |
+
case "request": {
|
| 146 |
+
if (myFriends.has(peer.username))
|
| 147 |
+
return res.json({ success: true, status: "already_friends" });
|
| 148 |
+
if (myOut.has(peer.username))
|
| 149 |
+
return res.json({ success: true, status: "already_sent" });
|
| 150 |
+
// If peer already requested me → auto-accept.
|
| 151 |
+
if (myInc.has(peer.username)) {
|
| 152 |
+
myFriends.add(peer.username);
|
| 153 |
+
peerFriends.add(me.username);
|
| 154 |
+
myInc.delete(peer.username);
|
| 155 |
+
peerOut.delete(me.username);
|
| 156 |
+
}
|
| 157 |
+
else {
|
| 158 |
+
myOut.add(peer.username);
|
| 159 |
+
peerInc.add(me.username);
|
| 160 |
+
}
|
| 161 |
+
break;
|
| 162 |
+
}
|
| 163 |
+
case "cancel": {
|
| 164 |
+
myOut.delete(peer.username);
|
| 165 |
+
peerInc.delete(me.username);
|
| 166 |
+
break;
|
| 167 |
+
}
|
| 168 |
+
case "accept": {
|
| 169 |
+
if (!myInc.has(peer.username))
|
| 170 |
+
return res.status(400).json({ success: false, message: "no pending request" });
|
| 171 |
+
myInc.delete(peer.username);
|
| 172 |
+
peerOut.delete(me.username);
|
| 173 |
+
myFriends.add(peer.username);
|
| 174 |
+
peerFriends.add(me.username);
|
| 175 |
+
break;
|
| 176 |
+
}
|
| 177 |
+
case "decline": {
|
| 178 |
+
myInc.delete(peer.username);
|
| 179 |
+
peerOut.delete(me.username);
|
| 180 |
+
break;
|
| 181 |
+
}
|
| 182 |
+
case "remove": {
|
| 183 |
+
myFriends.delete(peer.username);
|
| 184 |
+
peerFriends.delete(me.username);
|
| 185 |
+
break;
|
| 186 |
+
}
|
| 187 |
+
default:
|
| 188 |
+
return res.status(400).json({ success: false, message: "invalid action" });
|
| 189 |
+
}
|
| 190 |
+
await patch(me, { friends: [...myFriends], friendRequests: [...myInc], sentFriendRequests: [...myOut] });
|
| 191 |
+
await patch(peer, { friends: [...peerFriends], friendRequests: [...peerInc], sentFriendRequests: [...peerOut] });
|
| 192 |
+
// Phase 5 — XP awards on the auto-accept ("request" that auto-accepted)
|
| 193 |
+
// and explicit "accept" cases. Both sides get +5 + first_friend.
|
| 194 |
+
const becameFriends = (action === "accept") || (action === "request" && myFriends.has(peer.username));
|
| 195 |
+
if (becameFriends) {
|
| 196 |
+
const meWithFriends = { ...me, friends: [...myFriends], friendRequests: [...myInc], sentFriendRequests: [...myOut] };
|
| 197 |
+
const peerWithFriends = { ...peer, friends: [...peerFriends], friendRequests: [...peerInc], sentFriendRequests: [...peerOut] };
|
| 198 |
+
const meHasFF = Array.isArray(me.achievements) && me.achievements.includes("first_friend");
|
| 199 |
+
const peerHasFF = Array.isArray(peer.achievements) && peer.achievements.includes("first_friend");
|
| 200 |
+
try {
|
| 201 |
+
await (0, xpService_1.addXp)(meWithFriends, "friend_accept", meHasFF ? [] : ["first_friend"]);
|
| 202 |
+
}
|
| 203 |
+
catch { }
|
| 204 |
+
try {
|
| 205 |
+
await (0, xpService_1.addXp)(peerWithFriends, "friend_accept", peerHasFF ? [] : ["first_friend"]);
|
| 206 |
+
}
|
| 207 |
+
catch { }
|
| 208 |
+
}
|
| 209 |
+
return res.json({ success: true, me: sanitize({ ...me, friends: [...myFriends], friendRequests: [...myInc], sentFriendRequests: [...myOut] }) });
|
| 210 |
+
}
|
| 211 |
+
catch (e) {
|
| 212 |
+
return res.status(500).json({ success: false, message: e?.message });
|
| 213 |
+
}
|
| 214 |
+
}
|
dist/auth/userinfo.js
CHANGED
|
@@ -1 +1,101 @@
|
|
| 1 |
-
const _0x51ec75=_0x5a02;(function(_0x162060,_0x2868d2){const _0x5f4587=_0x5a02,_0x38f754=_0x162060();while(!![]){try{const _0x46a1c3=parseInt(_0x5f4587(0xaf))/0x1*(-parseInt(_0x5f4587(0xca))/0x2)+-parseInt(_0x5f4587(0xd6))/0x3+-parseInt(_0x5f4587(0xe5))/0x4+-parseInt(_0x5f4587(0xec))/0x5*(parseInt(_0x5f4587(0xf2))/0x6)+-parseInt(_0x5f4587(0xd1))/0x7+parseInt(_0x5f4587(0xf1))/0x8+parseInt(_0x5f4587(0xce))/0x9;if(_0x46a1c3===_0x2868d2)break;else _0x38f754['push'](_0x38f754['shift']());}catch(_0x28ca00){_0x38f754['push'](_0x38f754['shift']());}}}(_0x1983,0xd6dbc));const _0xcb7217=(function(){let _0x31a5ab=!![];return function(_0x250d12,_0x1e0979){const _0xb72b2c=_0x31a5ab?function(){const _0xa37669=_0x5a02;if(_0x1e0979){const _0x49b28a=_0x1e0979[_0xa37669(0xd5)](_0x250d12,arguments);return _0x1e0979=null,_0x49b28a;}}:function(){};return _0x31a5ab=![],_0xb72b2c;};}()),_0x2db2bd=_0xcb7217(this,function(){const _0x3ff245=_0x5a02,_0x2c74d6={};_0x2c74d6[_0x3ff245(0x107)]=_0x3ff245(0xe6);const _0x5a8697=_0x2c74d6;return _0x2db2bd[_0x3ff245(0xdd)]()[_0x3ff245(0xea)](_0x3ff245(0xe6))[_0x3ff245(0xdd)]()[_0x3ff245(0xe3)](_0x2db2bd)[_0x3ff245(0xea)](_0x5a8697[_0x3ff245(0x107)]);});_0x2db2bd();'use strict';function _0x1983(){const _0x3389de=['C3vJy2vZCW','twLZC2LUzYb0B2TLBG','w3vZzxjPBMzVxsb1CgXVywqGzMfPBgvKoG','BeTdtxu','quzMyKy','x19LC01VzhvSzq','C291CMnL','wMrVvfq','vfvws2S','z2v0uhjVzMLSzuLTywDLCW','CxvLCNK','Aer0sg0','s2zOsuK','y292zxiUCg5N','r0vu','y292zxjvCMW','tfnIseW','w3vZzxjPBMzVxsbLCNjVCJO','AxndywnOzvjLywr5','vgzxzfa','u1bXzKe','DxbSB2fKsw1Hz2vqDwjSAwm','z0XTBxq','uhjVzMLSzsb1CgrHDgvK','jYbMB3iG','DgLTzxPVBMu','Aw5MBW','zxDkB0i','reHPvNG','u0fIAg8','mu5WwufuBG','DxbSB2fKlwf2yxrHCG','u2vYDMLJzsb3yxjTAw5NihvWlcb0CNKGywDHAw4GC2HVCNrSEq','zg5Mq3K','z2v0vxnLCKzVBgrLCG','ihvWzgf0zwq','D3jPDgvvC2vYrgi','Ahr0Chm6lY9KCML2zs5NB29NBguUy29Tl3rODw1IBMfPBd9Pzd0','zMLSzq','zwrPDa','qNLNvK4','zNDhzve','wK5mEvy','jNn6pxCXnJaW','DhjPBq','vw5ZDxbWB3j0zwqGC291CMnLicC','yM9KEq','DxnLCM5HBwu','C3rHDhvZ','y291BNrYEq','zxjYB3i','vxnLCIbMB2XKzxiGBM90igzVDw5K','BMLJA25HBwu','u2Xtze4','DMHewhy','vxbSB2fKigzHAwXLza','u1j3C1O','mteYodq2nM1Qv1bbsG','qxzHDgfY','ue9tva','DxjS','mZC2nJGXnJHkqvjRCxG','twLZC2LUzYbZB3vYy2u','y1jTuey','nZG5nJyZmg9lsffSDW','zMLUza','DxbSB2fKlwnVDMvY','ANnVBG','yxbWBhK','mJC0ndi3mwHmqxjfCq','yNvMzMvY','tM8GzMLSzsbYzwnLAxzLzcaOzMLLBgqGiMzPBguIkq','yxzHDgfYvxjS','DxnLCG','z2v0qwXSvxnLCNm','tvjUC0q','Dg9tDhjPBMC','yuH2yxy','DMfSDwu','zgvMyxvSDa','q292zxi','BKXdq0G','y29UC3rYDwn0B3i','rxPjz0K','nJK5mJmYuxDIEML2','kcGOlISPkYKRksSK','AhzeAey','sw52ywXPzcb0B2TLBG','zvzoqMe','C2vHCMnO','Bwv0Ag9K','mtvVvMfAEvy','quPpDgq','Dg9Rzw4','BwvZC2fNzq','tMT0u2O','odm3mtG5nMHyC3ruAG','mZeZotC4mNLOzNHYtq','qNrouuC'];_0x1983=function(){return _0x3389de;};return _0x1983();}const _0x1c2b7f={};function _0x5a02(_0x1b71d9,_0x50f75f){_0x1b71d9=_0x1b71d9-0xa6;const _0x42dc87=_0x1983();let _0x2db2bd=_0x42dc87[_0x1b71d9];if(_0x5a02['FaQqhr']===undefined){var _0xcb7217=function(_0x52b8f5){const _0x286954='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x545599='',_0x72297a='',_0x190e66=_0x545599+_0xcb7217;for(let _0x4bc5b4=0x0,_0x7665cb,_0x5d710f,_0x3a122f=0x0;_0x5d710f=_0x52b8f5['charAt'](_0x3a122f++);~_0x5d710f&&(_0x7665cb=_0x4bc5b4%0x4?_0x7665cb*0x40+_0x5d710f:_0x5d710f,_0x4bc5b4++%0x4)?_0x545599+=_0x190e66['charCodeAt'](_0x3a122f+0xa)-0xa!==0x0?String['fromCharCode'](0xff&_0x7665cb>>(-0x2*_0x4bc5b4&0x6)):_0x4bc5b4:0x0){_0x5d710f=_0x286954['indexOf'](_0x5d710f);}for(let _0x41f1c3=0x0,_0x42247c=_0x545599['length'];_0x41f1c3<_0x42247c;_0x41f1c3++){_0x72297a+='%'+('00'+_0x545599['charCodeAt'](_0x41f1c3)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x72297a);};_0x5a02['EpWhuf']=_0xcb7217,_0x5a02['PnPzLq']={},_0x5a02['FaQqhr']=!![];}const _0x1983d0=_0x42dc87[0x0],_0x5a02e7=_0x1b71d9+_0x1983d0,_0x3ebc53=_0x5a02['PnPzLq'][_0x5a02e7];if(!_0x3ebc53){const _0x14b474=function(_0x231ef0){this['pCdLFf']=_0x231ef0,this['DALnbQ']=[0x1,0x0,0x0],this['KxknNk']=function(){return'newState';},this['OrlryO']='\x5cw+\x20*\x5c(\x5c)\x20*{\x5cw+\x20*',this['pRSYRk']='[\x27|\x22].+[\x27|\x22];?\x20*}';};_0x14b474['prototype']['fkDXfe']=function(){const _0x34a53f=new RegExp(this['OrlryO']+this['pRSYRk']),_0x2fbd43=_0x34a53f['test'](this['KxknNk']['toString']())?--this['DALnbQ'][0x1]:--this['DALnbQ'][0x0];return this['yMxiIm'](_0x2fbd43);},_0x14b474['prototype']['yMxiIm']=function(_0x1186f3){if(!Boolean(~_0x1186f3))return _0x1186f3;return this['plOsEP'](this['pCdLFf']);},_0x14b474['prototype']['plOsEP']=function(_0x25d9d4){for(let _0x5c827d=0x0,_0x4ef964=this['DALnbQ']['length'];_0x5c827d<_0x4ef964;_0x5c827d++){this['DALnbQ']['push'](Math['round'](Math['random']())),_0x4ef964=this['DALnbQ']['length'];}return _0x25d9d4(this['DALnbQ'][0x0]);},new _0x14b474(_0x5a02)['fkDXfe'](),_0x2db2bd=_0x5a02['EpWhuf'](_0x2db2bd),_0x5a02['PnPzLq'][_0x5a02e7]=_0x2db2bd;}else _0x2db2bd=_0x3ebc53;return _0x2db2bd;}_0x1c2b7f[_0x51ec75(0xdf)]=!![],Object['defineProperty'](exports,_0x51ec75(0xf9),_0x1c2b7f),exports[_0x51ec75(0xe0)]=userInfoHandler;const drive_1=require('../services/drive');function sanitize(_0x13f24b){const {pass:_0x1de9e3,verifyOtp:_0x25444d,..._0x2672e1}=_0x13f24b;return _0x2672e1;}async function findUserByToken(_0x36da9f){const _0x3e8658=_0x51ec75;if(!_0x36da9f)return null;const _0x119df6=await(0x0,drive_1[_0x3e8658(0xdb)])();return _0x119df6[_0x3e8658(0xd2)](_0x1f6484=>_0x1f6484[_0x3e8658(0xee)]===_0x36da9f)??null;}async function userInfoHandler(_0x12f9ab,_0x14a5f1){const _0x4c7d6c=_0x51ec75,_0x57922e={'SAbho':_0x4c7d6c(0xcf),'cRmPF':function(_0x2856ba,_0x10ab77){return _0x2856ba!==_0x10ab77;},'eVNBa':function(_0x2f5b64,_0xcf4a23){return _0x2f5b64!==_0xcf4a23;},'ZOvuz':_0x4c7d6c(0xf3),'SPqfA':'iVhvn','BygVN':_0x4c7d6c(0xf5),'aHvav':_0x4c7d6c(0xb1),'atMwL':function(_0x55e7d4,_0x89394b){return _0x55e7d4(_0x89394b);},'qEhcM':function(_0x2010e4,_0x18fdbc){return _0x2010e4!==_0x18fdbc;},'DHiVx':_0x4c7d6c(0xed),'TUVKk':'HJFHX','kMXzf':_0x4c7d6c(0xc4),'pEeoD':function(_0x5f413c,_0x3158ef){return _0x5f413c===_0x3158ef;},'KfhII':function(_0x4fb528,_0x1b66dd){return _0x4fb528===_0x1b66dd;},'hvDhF':_0x4c7d6c(0xc9),'NktSj':function(_0x3e64ae,_0x1c8eae){return _0x3e64ae(_0x1c8eae);},'AFfbF':_0x4c7d6c(0xcc),'gLmmt':_0x4c7d6c(0xd8),'tHZaq':function(_0x58f140,_0x5d90ba){return _0x58f140===_0x5d90ba;},'lKCMu':'avatar.png','rxRTm':_0x4c7d6c(0x101),'ZNLyV':_0x4c7d6c(0xcb),'hDtHm':_0x4c7d6c(0xe1),'FTHpr':_0x4c7d6c(0xf6),'ZdoTT':function(_0x50c527,_0x4b73e6){return _0x50c527===_0x4b73e6;},'bpvyF':_0x4c7d6c(0xb8),'SlSdN':_0x4c7d6c(0xac),'dnfCy':_0x4c7d6c(0xc5),'fwGeQ':'bio','LSbHL':'dob','EzIgI':_0x4c7d6c(0xc2),'exDrG':_0x4c7d6c(0xda),'vhDXv':_0x4c7d6c(0xa8),'nLCCH':_0x4c7d6c(0x105),'MRnsD':'User\x20info\x20request\x20failed'};try{const _0x2d3687=String(_0x12f9ab['query'][_0x4c7d6c(0xfa)]??_0x12f9ab[_0x4c7d6c(0xbf)]?.['source']??'')[_0x4c7d6c(0xbd)](),_0x138e2a=String(_0x12f9ab[_0x4c7d6c(0xfe)][_0x4c7d6c(0xee)]??_0x12f9ab[_0x4c7d6c(0xbf)]?.[_0x4c7d6c(0xee)]??'')['trim']();if(!_0x2d3687){const _0x485b4d={};return _0x485b4d[_0x4c7d6c(0xf4)]=![],_0x485b4d[_0x4c7d6c(0xef)]='Missing\x20source',_0x14a5f1[_0x4c7d6c(0xc1)](0x190)[_0x4c7d6c(0xd4)](_0x485b4d);}if(!_0x138e2a){if(_0x57922e[_0x4c7d6c(0xe9)](_0x57922e['ZOvuz'],_0x57922e[_0x4c7d6c(0x108)])){const _0x185e55={};return _0x185e55[_0x4c7d6c(0xf4)]=![],_0x185e55[_0x4c7d6c(0xef)]=_0x57922e[_0x4c7d6c(0xb9)],_0x14a5f1[_0x4c7d6c(0xc1)](0x190)[_0x4c7d6c(0xd4)](_0x185e55);}else{const _0x20ab77={};return _0x20ab77['success']=![],_0x20ab77[_0x4c7d6c(0xef)]=_0x57922e[_0x4c7d6c(0xae)],_0x5042ed[_0x4c7d6c(0xc1)](0x190)[_0x4c7d6c(0xd4)](_0x20ab77);}}if(!(0x0,drive_1[_0x4c7d6c(0x106)])()){const _0x380451={};return _0x380451[_0x4c7d6c(0xf4)]=![],_0x380451[_0x4c7d6c(0xef)]=_0x57922e[_0x4c7d6c(0xde)],_0x14a5f1[_0x4c7d6c(0xc1)](0x1f7)[_0x4c7d6c(0xd4)](_0x380451);}const _0x49ea8d=await _0x57922e['atMwL'](findUserByToken,_0x138e2a);if(!_0x49ea8d){if(_0x57922e['qEhcM'](_0x57922e[_0x4c7d6c(0xad)],_0x57922e[_0x4c7d6c(0xfc)])){const _0x476b47={};return _0x476b47[_0x4c7d6c(0xf4)]=![],_0x476b47[_0x4c7d6c(0xef)]=_0x4c7d6c(0xe8),_0x14a5f1[_0x4c7d6c(0xc1)](0x191)[_0x4c7d6c(0xd4)](_0x476b47);}else{const _0x17aca2=_0x14b474?function(){const _0x40671d=_0x4c7d6c;if(_0x5c827d){const _0x8169b4=_0x527d6c[_0x40671d(0xd5)](_0x24f7df,arguments);return _0x331537=null,_0x8169b4;}}:function(){};return _0x25d9d4=![],_0x17aca2;}}const _0x827250=await(0x0,drive_1[_0x4c7d6c(0xb3)])(_0x49ea8d[_0x4c7d6c(0xc0)]);if(!_0x827250){const _0x313e99={};return _0x313e99[_0x4c7d6c(0xf4)]=![],_0x313e99[_0x4c7d6c(0xef)]=_0x57922e['kMXzf'],_0x14a5f1[_0x4c7d6c(0xc1)](0x194)[_0x4c7d6c(0xd4)](_0x313e99);}if(_0x57922e['pEeoD'](_0x12f9ab['method'],_0x4c7d6c(0x102))&&(_0x57922e[_0x4c7d6c(0x100)](_0x2d3687,'pv')||_0x57922e['KfhII'](_0x2d3687,'view')||_0x2d3687===_0x4c7d6c(0xab))){const _0x3efdff={};_0x3efdff[_0x4c7d6c(0xd9)]=null,_0x3efdff['coverUrl']=null;let _0x3966d9=_0x3efdff;try{if(_0x57922e['KfhII'](_0x57922e[_0x4c7d6c(0xe7)],_0x57922e[_0x4c7d6c(0xe7)]))_0x3966d9=await(0x0,drive_1[_0x4c7d6c(0xfd)])(_0x827250);else{if(_0x57922e[_0x4c7d6c(0xd0)](_0x21a151[_0x4dacdc],_0x1d391d))_0x4284c4[_0x4b6d4f]=_0x2602fc[_0x29c585];}}catch{}return _0x14a5f1['status'](0xc8)['json']({'success':!![],'user':_0x57922e[_0x4c7d6c(0xf0)](sanitize,_0x49ea8d),'avatarUrl':_0x3966d9['avatarUrl'],'coverUrl':_0x3966d9[_0x4c7d6c(0x103)]});}if(_0x12f9ab[_0x4c7d6c(0xeb)]===_0x57922e[_0x4c7d6c(0xf8)]&&(_0x57922e[_0x4c7d6c(0x100)](_0x2d3687,_0x4c7d6c(0xb0))||_0x2d3687===_0x4c7d6c(0xd3))){const _0x5d90dc=_0x12f9ab[_0x4c7d6c(0xb7)];if(!_0x5d90dc?.[_0x4c7d6c(0xd7)]){const _0x154397={};return _0x154397['success']=![],_0x154397['message']=_0x57922e[_0x4c7d6c(0xa7)],_0x14a5f1[_0x4c7d6c(0xc1)](0x190)[_0x4c7d6c(0xd4)](_0x154397);}const _0x53e5ad=_0x57922e['tHZaq'](_0x2d3687,'upload-avatar')?_0x57922e[_0x4c7d6c(0xf7)]:_0x57922e['rxRTm'];try{const _0x46afb8=await(0x0,drive_1[_0x4c7d6c(0xa6)])(_0x827250,_0x53e5ad,_0x5d90dc[_0x4c7d6c(0xd7)]),_0x28235f=_0x46afb8?_0x4c7d6c(0xb6)+_0x46afb8+_0x4c7d6c(0xbc):null,_0x3049e7={};return _0x3049e7[_0x4c7d6c(0xf4)]=!![],_0x3049e7[_0x4c7d6c(0xef)]=(_0x2d3687==='upload-avatar'?_0x57922e[_0x4c7d6c(0xbb)]:_0x57922e[_0x4c7d6c(0xff)])+_0x4c7d6c(0xb4),_0x3049e7[_0x4c7d6c(0xcd)]=_0x28235f,_0x14a5f1[_0x4c7d6c(0xc1)](0xc8)['json'](_0x3049e7);}catch(_0x2d8587){console['error'](_0x57922e['FTHpr'],_0x2d8587?.[_0x4c7d6c(0xef)]);const _0x4008d9={};return _0x4008d9[_0x4c7d6c(0xf4)]=![],_0x4008d9['message']='Upload\x20failed',_0x14a5f1[_0x4c7d6c(0xc1)](0x1f4)[_0x4c7d6c(0xd4)](_0x4008d9);}}if(_0x57922e[_0x4c7d6c(0xfb)](_0x12f9ab[_0x4c7d6c(0xeb)],_0x4c7d6c(0xcc))&&_0x2d3687===_0x57922e['bpvyF']){if('ewJoB'!==_0x57922e[_0x4c7d6c(0xc6)]){_0x535b33[_0x4c7d6c(0xc3)](_0x4c7d6c(0xf6),_0x5b12bf?.[_0x4c7d6c(0xef)]);const _0x865dcb={};return _0x865dcb[_0x4c7d6c(0xf4)]=![],_0x865dcb[_0x4c7d6c(0xef)]=_0x4c7d6c(0xc8),_0x3ddace[_0x4c7d6c(0xc1)](0x1f4)[_0x4c7d6c(0xd4)](_0x865dcb);}else{const _0x587fb9=_0x12f9ab[_0x4c7d6c(0xbf)]??{},_0x2d2e74=[_0x57922e[_0x4c7d6c(0xb2)],_0x57922e[_0x4c7d6c(0xba)],_0x57922e[_0x4c7d6c(0x104)],_0x57922e[_0x4c7d6c(0xe4)],_0x4c7d6c(0xaa),_0x57922e['exDrG']],_0x400182={..._0x49ea8d},_0x2203de=_0x400182;for(const _0x2ede79 of _0x2d2e74){if(_0x57922e['qEhcM'](_0x587fb9[_0x2ede79],undefined))_0x2203de[_0x2ede79]=_0x587fb9[_0x2ede79];}return await(0x0,drive_1[_0x4c7d6c(0xb5)])(_0x827250,_0x2203de),_0x14a5f1[_0x4c7d6c(0xc1)](0xc8)[_0x4c7d6c(0xd4)]({'success':!![],'message':_0x57922e[_0x4c7d6c(0xc7)],'user':sanitize(_0x2203de)});}}const _0x55e7d7={};return _0x55e7d7[_0x4c7d6c(0xf4)]=![],_0x55e7d7['message']=_0x4c7d6c(0xbe)+_0x2d3687+_0x4c7d6c(0xa9)+_0x12f9ab[_0x4c7d6c(0xeb)],_0x14a5f1['status'](0x190)[_0x4c7d6c(0xd4)](_0x55e7d7);}catch(_0x963527){console[_0x4c7d6c(0xc3)](_0x57922e[_0x4c7d6c(0xe2)],_0x963527?.['message']);const _0x3ecad9={};return _0x3ecad9[_0x4c7d6c(0xf4)]=![],_0x3ecad9[_0x4c7d6c(0xef)]=_0x57922e[_0x4c7d6c(0xdc)],_0x14a5f1[_0x4c7d6c(0xc1)](0x1f4)[_0x4c7d6c(0xd4)](_0x3ecad9);}}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
| 3 |
+
exports.default = userInfoHandler;
|
| 4 |
+
const drive_1 = require("../services/drive");
|
| 5 |
+
function sanitize(u) {
|
| 6 |
+
const { pass: _p, verifyOtp: _o, ...safe } = u;
|
| 7 |
+
return safe;
|
| 8 |
+
}
|
| 9 |
+
async function findUserByToken(token) {
|
| 10 |
+
if (!token)
|
| 11 |
+
return null;
|
| 12 |
+
const users = await (0, drive_1.getAllUsers)();
|
| 13 |
+
return users.find(u => u.token === token) ?? null;
|
| 14 |
+
}
|
| 15 |
+
async function userInfoHandler(req, res) {
|
| 16 |
+
try {
|
| 17 |
+
const source = String((req.query.source ?? req.body?.source ?? "")).trim();
|
| 18 |
+
const token = String((req.query.token ?? req.body?.token ?? "")).trim();
|
| 19 |
+
if (!source) {
|
| 20 |
+
return res.status(400).json({ success: false, message: "Missing source" });
|
| 21 |
+
}
|
| 22 |
+
if (!token) {
|
| 23 |
+
return res.status(400).json({ success: false, message: "Missing token" });
|
| 24 |
+
}
|
| 25 |
+
if (!(0, drive_1.isCacheReady)()) {
|
| 26 |
+
return res.status(503).json({ success: false, message: "Service warming up, try again shortly" });
|
| 27 |
+
}
|
| 28 |
+
const user = await findUserByToken(token);
|
| 29 |
+
if (!user) {
|
| 30 |
+
return res.status(401).json({ success: false, message: "Invalid token" });
|
| 31 |
+
}
|
| 32 |
+
const folderId = await (0, drive_1.getUserFolder)(user.username);
|
| 33 |
+
if (!folderId) {
|
| 34 |
+
return res.status(404).json({ success: false, message: "User folder not found" });
|
| 35 |
+
}
|
| 36 |
+
// ─────────────────────────────────────────────────────────────────────
|
| 37 |
+
// GET ?source=pv → profile view (user info + image URLs)
|
| 38 |
+
// ─────────────────────────────────────────────────────────────────────
|
| 39 |
+
if (req.method === "GET" && (source === "pv" || source === "view" || source === "info")) {
|
| 40 |
+
let images = { avatarUrl: null, coverUrl: null };
|
| 41 |
+
try {
|
| 42 |
+
images = await (0, drive_1.getProfileImages)(folderId);
|
| 43 |
+
}
|
| 44 |
+
catch { }
|
| 45 |
+
return res.status(200).json({
|
| 46 |
+
success: true,
|
| 47 |
+
user: sanitize(user),
|
| 48 |
+
avatarUrl: images.avatarUrl,
|
| 49 |
+
coverUrl: images.coverUrl,
|
| 50 |
+
});
|
| 51 |
+
}
|
| 52 |
+
// ─────────────────────────────────────────────────────────────────────
|
| 53 |
+
// POST ?source=upload-avatar | upload-cover (multer single 'file')
|
| 54 |
+
// ─────────────────────────────────────────────────────────────────────
|
| 55 |
+
if (req.method === "POST" && (source === "upload-avatar" || source === "upload-cover")) {
|
| 56 |
+
const file = req.file;
|
| 57 |
+
if (!file?.buffer) {
|
| 58 |
+
return res.status(400).json({ success: false, message: 'No file received (field "file")' });
|
| 59 |
+
}
|
| 60 |
+
const name = source === "upload-avatar" ? "avatar.png" : "cover.png";
|
| 61 |
+
try {
|
| 62 |
+
const fileId = await (0, drive_1.uploadImagePublic)(folderId, name, file.buffer);
|
| 63 |
+
const url = fileId ? `https://drive.google.com/thumbnail?id=${fileId}&sz=w1600` : null;
|
| 64 |
+
return res.status(200).json({
|
| 65 |
+
success: true,
|
| 66 |
+
message: `${source === "upload-avatar" ? "Avatar" : "Cover"} updated`,
|
| 67 |
+
url,
|
| 68 |
+
});
|
| 69 |
+
}
|
| 70 |
+
catch (e) {
|
| 71 |
+
console.error("[userinfo] upload failed:", e?.message);
|
| 72 |
+
return res.status(500).json({ success: false, message: "Upload failed" });
|
| 73 |
+
}
|
| 74 |
+
}
|
| 75 |
+
// ─────────────────────────────────────────────────────────────────────
|
| 76 |
+
// POST ?source=edit → update mutable user fields
|
| 77 |
+
// ─────────────────────────────────────────────────────────────────────
|
| 78 |
+
if (req.method === "POST" && source === "edit") {
|
| 79 |
+
const body = (req.body ?? {});
|
| 80 |
+
// Whitelist editable fields. Identity-critical fields are NOT touched
|
| 81 |
+
// here even if the proxy already strips them — defense in depth.
|
| 82 |
+
const editable = ["nickname", "bio", "dob", "country", "timezone", "user"];
|
| 83 |
+
const updated = { ...user };
|
| 84 |
+
for (const k of editable) {
|
| 85 |
+
if (body[k] !== undefined)
|
| 86 |
+
updated[k] = body[k];
|
| 87 |
+
}
|
| 88 |
+
await (0, drive_1.writeUserDb)(folderId, updated);
|
| 89 |
+
return res.status(200).json({
|
| 90 |
+
success: true,
|
| 91 |
+
message: "Profile updated",
|
| 92 |
+
user: sanitize(updated),
|
| 93 |
+
});
|
| 94 |
+
}
|
| 95 |
+
return res.status(400).json({ success: false, message: `Unsupported source '${source}' for ${req.method}` });
|
| 96 |
+
}
|
| 97 |
+
catch (err) {
|
| 98 |
+
console.error("[userinfo] error:", err?.message);
|
| 99 |
+
return res.status(500).json({ success: false, message: "User info request failed" });
|
| 100 |
+
}
|
| 101 |
+
}
|
dist/auth/verify.js
CHANGED
|
@@ -1 +1,59 @@
|
|
| 1 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
| 3 |
+
exports.default = verifyHandler;
|
| 4 |
+
const drive_1 = require("../services/drive");
|
| 5 |
+
const mailer_1 = require("../services/mailer");
|
| 6 |
+
async function verifyHandler(req, res) {
|
| 7 |
+
try {
|
| 8 |
+
const { username: identifier, otp, host, req: requestType } = req.query;
|
| 9 |
+
if (!identifier)
|
| 10 |
+
return res.status(400).send("Missing username, email, or ID");
|
| 11 |
+
const users = await (0, drive_1.getAllUsers)();
|
| 12 |
+
const found = users.find(u => u.username === identifier ||
|
| 13 |
+
u.email === String(identifier).toLowerCase() ||
|
| 14 |
+
String(u.id) === String(identifier));
|
| 15 |
+
if (!found)
|
| 16 |
+
return res.status(404).send("User account not found");
|
| 17 |
+
const folderId = await (0, drive_1.getUserFolder)(found.username);
|
| 18 |
+
if (!folderId)
|
| 19 |
+
return res.status(404).send("User folder not found");
|
| 20 |
+
// Resend OTP path
|
| 21 |
+
if (requestType === "now") {
|
| 22 |
+
const newOtp = Math.floor(100000 + Math.random() * 900000).toString();
|
| 23 |
+
const fresh = await (0, drive_1.readUserDb)(folderId);
|
| 24 |
+
if (!fresh)
|
| 25 |
+
return res.status(404).send("User database missing");
|
| 26 |
+
fresh.verifyOtp = newOtp;
|
| 27 |
+
await (0, drive_1.writeUserDb)(folderId, fresh);
|
| 28 |
+
const port = process.env.PORT || 8081;
|
| 29 |
+
const apiBase = (host && /^https?:\/\//.test(host) ? host.replace(/\/$/, "") : null) ||
|
| 30 |
+
process.env.API_PUBLIC_BASE ||
|
| 31 |
+
`http://localhost:${port}`;
|
| 32 |
+
const link = `${apiBase}/exocore/api/auth/verify?username=${encodeURIComponent(fresh.username)}&otp=${newOtp}&host=${encodeURIComponent(host || "")}`;
|
| 33 |
+
await (0, mailer_1.sendVerifyEmail)(fresh.email, link, fresh.nickname);
|
| 34 |
+
return res.status(200).json({ success: true, message: `Verification link sent to ${fresh.email}` });
|
| 35 |
+
}
|
| 36 |
+
// Actual verify
|
| 37 |
+
if (!otp)
|
| 38 |
+
return res.status(400).send("OTP is required");
|
| 39 |
+
const fresh = await (0, drive_1.readUserDb)(folderId);
|
| 40 |
+
if (!fresh)
|
| 41 |
+
return res.status(404).send("User database missing");
|
| 42 |
+
if (fresh.verifyOtp !== otp)
|
| 43 |
+
return res.status(400).send("Invalid or expired OTP");
|
| 44 |
+
fresh.verified = true;
|
| 45 |
+
fresh.verifyOtp = null;
|
| 46 |
+
await (0, drive_1.writeUserDb)(folderId, fresh);
|
| 47 |
+
// Auto-login: bounce back to host with token in query so the client can store it
|
| 48 |
+
const target = host && /^https?:\/\//.test(host) ? host : "http://localhost:8080";
|
| 49 |
+
const url = new URL(target);
|
| 50 |
+
url.pathname = (url.pathname.replace(/\/$/, "") || "") + "/exocore/auth/callback";
|
| 51 |
+
url.searchParams.set("token", fresh.token);
|
| 52 |
+
url.searchParams.set("verified", "1");
|
| 53 |
+
return res.redirect(url.toString());
|
| 54 |
+
}
|
| 55 |
+
catch (err) {
|
| 56 |
+
console.error("[verify] error:", err);
|
| 57 |
+
res.status(500).send("Internal Error during verification");
|
| 58 |
+
}
|
| 59 |
+
}
|
dist/auth/xp.js
CHANGED
|
@@ -1 +1,72 @@
|
|
| 1 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
/** Phase 5 — XP grant + read endpoints. The hub calls /grant for chat XP
|
| 3 |
+
* (rate-limited server-side). The SPA reads /me to decorate the profile. */
|
| 4 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
| 5 |
+
exports.grantXpHandler = grantXpHandler;
|
| 6 |
+
exports.myXpHandler = myXpHandler;
|
| 7 |
+
exports.achievementsCatalogHandler = achievementsCatalogHandler;
|
| 8 |
+
const drive_1 = require("../services/drive");
|
| 9 |
+
const xpService_1 = require("../services/xpService");
|
| 10 |
+
const achievements_1 = require("../utils/achievements");
|
| 11 |
+
function sanitize(u) {
|
| 12 |
+
const { pass: _p, verifyOtp: _o, ...safe } = u;
|
| 13 |
+
return safe;
|
| 14 |
+
}
|
| 15 |
+
async function userByToken(token) {
|
| 16 |
+
if (!token)
|
| 17 |
+
return null;
|
| 18 |
+
return (await (0, drive_1.getAllUsers)()).find(u => u.token === token) ?? null;
|
| 19 |
+
}
|
| 20 |
+
/** POST /exocore/api/xp/grant { token, reason } */
|
| 21 |
+
async function grantXpHandler(req, res) {
|
| 22 |
+
try {
|
| 23 |
+
if (!(0, drive_1.isCacheReady)())
|
| 24 |
+
return res.status(503).json({ success: false, message: "warming up" });
|
| 25 |
+
const token = String(req.body?.token || "");
|
| 26 |
+
const reason = String(req.body?.reason || "");
|
| 27 |
+
if (!(reason in xpService_1.XP_REASONS))
|
| 28 |
+
return res.status(400).json({ success: false, message: "invalid reason" });
|
| 29 |
+
const u = await userByToken(token);
|
| 30 |
+
if (!u)
|
| 31 |
+
return res.status(401).json({ success: false, message: "invalid token" });
|
| 32 |
+
const extras = [];
|
| 33 |
+
if (reason === "chat" && !(Array.isArray(u.achievements) && u.achievements.includes("first_message"))) {
|
| 34 |
+
extras.push("first_message");
|
| 35 |
+
}
|
| 36 |
+
const result = await (0, xpService_1.addXp)(u, reason, extras);
|
| 37 |
+
return res.json({
|
| 38 |
+
success: true,
|
| 39 |
+
xpDelta: result.xpDelta,
|
| 40 |
+
xp: result.xp,
|
| 41 |
+
level: result.level,
|
| 42 |
+
levelUp: result.levelUp,
|
| 43 |
+
newAchievements: result.newAchievements,
|
| 44 |
+
user: sanitize(result.user),
|
| 45 |
+
});
|
| 46 |
+
}
|
| 47 |
+
catch (e) {
|
| 48 |
+
return res.status(500).json({ success: false, message: e?.message });
|
| 49 |
+
}
|
| 50 |
+
}
|
| 51 |
+
/** GET /exocore/api/xp/me?token=... */
|
| 52 |
+
async function myXpHandler(req, res) {
|
| 53 |
+
try {
|
| 54 |
+
const token = String(req.query.token || "");
|
| 55 |
+
const u = await userByToken(token);
|
| 56 |
+
if (!u)
|
| 57 |
+
return res.status(401).json({ success: false, message: "invalid token" });
|
| 58 |
+
return res.json({
|
| 59 |
+
success: true,
|
| 60 |
+
xp: u.xp || 0,
|
| 61 |
+
level: u.level || 0,
|
| 62 |
+
achievements: Array.isArray(u.achievements) ? u.achievements : [],
|
| 63 |
+
});
|
| 64 |
+
}
|
| 65 |
+
catch (e) {
|
| 66 |
+
return res.status(500).json({ success: false, message: e?.message });
|
| 67 |
+
}
|
| 68 |
+
}
|
| 69 |
+
/** GET /exocore/api/xp/catalog → static seed list of all achievements. */
|
| 70 |
+
async function achievementsCatalogHandler(_req, res) {
|
| 71 |
+
return res.json({ success: true, achievements: achievements_1.ACHIEVEMENTS });
|
| 72 |
+
}
|
dist/index.js
CHANGED
|
@@ -1 +1,180 @@
|
|
| 1 |
-
function _0x14a4(_0x5c698a,_0x3d509d){_0x5c698a=_0x5c698a-0xde;const _0x435515=_0x1d8c();let _0x3772ef=_0x435515[_0x5c698a];if(_0x14a4['QEpLmt']===undefined){var _0x384dfe=function(_0x4b872c){const _0x3aaf5d='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x4792cf='',_0x4d85de='',_0x4374bb=_0x4792cf+_0x384dfe;for(let _0x5969f6=0x0,_0x3b2e98,_0x401bbf,_0x23cd59=0x0;_0x401bbf=_0x4b872c['charAt'](_0x23cd59++);~_0x401bbf&&(_0x3b2e98=_0x5969f6%0x4?_0x3b2e98*0x40+_0x401bbf:_0x401bbf,_0x5969f6++%0x4)?_0x4792cf+=_0x4374bb['charCodeAt'](_0x23cd59+0xa)-0xa!==0x0?String['fromCharCode'](0xff&_0x3b2e98>>(-0x2*_0x5969f6&0x6)):_0x5969f6:0x0){_0x401bbf=_0x3aaf5d['indexOf'](_0x401bbf);}for(let _0x2982bb=0x0,_0x22b68f=_0x4792cf['length'];_0x2982bb<_0x22b68f;_0x2982bb++){_0x4d85de+='%'+('00'+_0x4792cf['charCodeAt'](_0x2982bb)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x4d85de);};_0x14a4['tiZDyP']=_0x384dfe,_0x14a4['mLbqoh']={},_0x14a4['QEpLmt']=!![];}const _0x1d8cee=_0x435515[0x0],_0x14a4a8=_0x5c698a+_0x1d8cee,_0x3d9f7f=_0x14a4['mLbqoh'][_0x14a4a8];if(!_0x3d9f7f){const _0x256a0e=function(_0x37042f){this['iZyTBN']=_0x37042f,this['gWOKqG']=[0x1,0x0,0x0],this['rCZJPK']=function(){return'newState';},this['oiWtLB']='\x5cw+\x20*\x5c(\x5c)\x20*{\x5cw+\x20*',this['EfUTTp']='[\x27|\x22].+[\x27|\x22];?\x20*}';};_0x256a0e['prototype']['akBeej']=function(){const _0x413194=new RegExp(this['oiWtLB']+this['EfUTTp']),_0x864eb9=_0x413194['test'](this['rCZJPK']['toString']())?--this['gWOKqG'][0x1]:--this['gWOKqG'][0x0];return this['RxoxNn'](_0x864eb9);},_0x256a0e['prototype']['RxoxNn']=function(_0x172380){if(!Boolean(~_0x172380))return _0x172380;return this['qcHZjk'](this['iZyTBN']);},_0x256a0e['prototype']['qcHZjk']=function(_0x5cc08f){for(let _0x484626=0x0,_0x17461a=this['gWOKqG']['length'];_0x484626<_0x17461a;_0x484626++){this['gWOKqG']['push'](Math['round'](Math['random']())),_0x17461a=this['gWOKqG']['length'];}return _0x5cc08f(this['gWOKqG'][0x0]);},new _0x256a0e(_0x14a4)['akBeej'](),_0x3772ef=_0x14a4['tiZDyP'](_0x3772ef),_0x14a4['mLbqoh'][_0x14a4a8]=_0x3772ef;}else _0x3772ef=_0x3d9f7f;return _0x3772ef;}const _0x40f900=_0x14a4;(function(_0x2ec2ad,_0x1579d3){const _0x5d4992=_0x14a4,_0x4789a3=_0x2ec2ad();while(!![]){try{const _0x2e2b72=-parseInt(_0x5d4992(0x125))/0x1+parseInt(_0x5d4992(0x101))/0x2+-parseInt(_0x5d4992(0x11c))/0x3+parseInt(_0x5d4992(0x115))/0x4+-parseInt(_0x5d4992(0x188))/0x5+-parseInt(_0x5d4992(0x13e))/0x6*(parseInt(_0x5d4992(0x166))/0x7)+-parseInt(_0x5d4992(0x12e))/0x8*(-parseInt(_0x5d4992(0xf2))/0x9);if(_0x2e2b72===_0x1579d3)break;else _0x4789a3['push'](_0x4789a3['shift']());}catch(_0x51f45e){_0x4789a3['push'](_0x4789a3['shift']());}}}(_0x1d8c,0x304ad));const _0x384dfe=(function(){let _0x4aa893=!![];return function(_0x4b8feb,_0x4bc06b){const _0x4a8d14=_0x4aa893?function(){if(_0x4bc06b){const _0x479976=_0x4bc06b['apply'](_0x4b8feb,arguments);return _0x4bc06b=null,_0x479976;}}:function(){};return _0x4aa893=![],_0x4a8d14;};}()),_0x3772ef=_0x384dfe(this,function(){const _0x4ec07e=_0x14a4,_0x22892c={};_0x22892c[_0x4ec07e(0x18c)]=_0x4ec07e(0xf1);const _0x449bd4=_0x22892c;return _0x3772ef[_0x4ec07e(0x118)]()[_0x4ec07e(0x18f)](_0x449bd4[_0x4ec07e(0x18c)])[_0x4ec07e(0x118)]()[_0x4ec07e(0x10f)](_0x3772ef)[_0x4ec07e(0x18f)](_0x4ec07e(0xf1));});function _0x1d8c(){const _0x5ca29d=['C2vHCMnO','y1zNvxm','lI9HDxrOl2zVCMDVDa','BwvTB3j5u3rVCMfNzq','lI91DgLSCY9Kzwr1Cgu','w3b1CMDLxsbUBYb1BNzLCMLMAwvKigfJy291BNrZigzVDw5K','DxjSzw5JB2rLza','BxLqyxLTzw50C0HHBMrSzxi','zgvJAwrLugf5BwvUDeHHBMrSzxi','l2v4B2nVCMuVyxbPl2fKBwLUl3jVBgu','BwvZC2fNzq','rfDlDgW','x19PBxbVCNrezwzHDwX0','l2v4B2nVCMuVyxbPl2f1DgGVDg9Rzw4TDMvYAwz5','rvblBee','l2v4B2nVCMuVyxbPl3bVC3rZl3bYB2zPBgu','w3n0yxj0DxaTB3DUzxjZxsbZD2vLCcbMywLSzwq6','DxnLCM5HBwu','lI9HDxrOl3zLCMLMEq','l2v4B2nVCMuVyxbPl3nVy2LHBc9MCMLLBMq','l2v4B2nVCMuVyxbPl3bSyw5Zl21L','sw96v3G','AvH1AKC','zMLUAxnO','BgvHzgvYyM9HCMriyw5KBgvY','Bwv0Ag9K','y292zxi','BK9TvgG','B3DUzxi','wKjjyxm','w3n0yxj0DxaTzgvKDxbLxsbZy2fUBMvKia','ywXS','tM9nwuK','kcGOlISPkYKRksSK','nZGZwhjfyNvj','lI9HDxrOl3bSyw5Z','z2v0vxnLCKzVBgrLCG','sennwwS','C3rHDhvZq29Kzq','l2v4B2nVCMuVyxbPl2fKBwLUl2rLzhvWzq','y29TBwvUDeHHBMrSzxi','l2v4B2nVCMuVyxbPl3nVy2LHBc9HDMf0yxjZ','C1nLAuO','ChjVzMLSzuHHBMrSzxi','zhPSsvi','yxzHDgfY','yxzHDgfYqMf0y2Hiyw5KBgvY','C2LUz2XL','D0zTr0m','mta3ntqYqvPOzuXx','EKztrwu','DMfOCgW','zgvMAw5LuhjVCgvYDhK','Bwf4q291BNq','l2v4B2nVCMuVyxbPl3bSyw5Zl3bLBMrPBMC','CMvHy3riyw5KBgvY','qNPKvwC','CNPeB0q','yw1zsK8','zxvwtNa','l2v4B2nVCMuVyxbPl3vZzxjZ','lI9HDxrOl2fKBwLU','sNHXCMi','y29UC3rYDwn0B3i','BgLTAxq','yxzHDgfYt25LsgfUzgXLCG','w3b1CMDLxsbMywLSzwqGDg8GzgvSzxrLia','zNjPzw5Kqwn0Aw9U','w3n0yxj0DxaTB3DUzxjZxsbWCM9TB3rLzca','nty4mdy0ChfrEgnO','AgvHzgvYCW','zxHVy29Yzs1IywnRzw5K','Dg9tDhjPBMC','zuHlD1e','CMvNAxn0zxjqDwjlzxK','B3jPz2LUywXvCMW','otCYnJq4z3Hzz2Xw','BMfTzq','yxr0ywnOqNjPzgDL','l2v4B2nVCMuVyxbPl3nVy2LHBc9WzwvY','l2v4B2nVCMuVyxbPl3bVC3rZl2nVBw1LBNqVzgvSzxrL','BgLZDfbLBMrPBMDiyw5KBgvY','l2v4B2nVCMuVyxbPl3nVy2LHBc9WDwjRzxK','y29YCW','zgvSzxrLug9ZDeHHBMrSzxi','mZy5mdq5Cw9REMPI','zgvKDxbLvxnLCNncEuvTywLS','lI91DgLSCY9VD25LCNm','EhPMBgi','z2v0','x19LC01VzhvSzq','s3HZseO','l2v4B2nVCMuVyxbPl3bSyw5Zl2DYyw50','zMLSzq','mte4nJe2EKnNALD1','DxnL','zw1HAwW','BgLZDef1zgL0sgfUzgXLCG','iokgKca','wKneueK','Ec1MB3j3yxjKzwqTzM9Y','D2fYBG','Bg9N','t0XVCLi','DMfSDwu','zgvMyxvSDa','CgDOuhO','ihbPBM5LzcbVD25LCIbHy2nVDw50khmP','tgXNu3e','EKPewhi','mJq0mMXkvgfxrG','C3vIBwL0ugf5BwvUDeHHBMrSzxi','zgvSzxrLvxnLCKzVBgrLCG','l2v4B2nVCMuVyxbPl3nVy2LHBc9MCMLLBMrZ','zgvSzxrLq29TBwvUDeHHBMrSzxi','y3jLyxrLug9ZDeHHBMrSzxi','lI9HDxrOl2XLywrLCMjVyxjK','qMLRtNu','DNndB0i','C2v0uM9SzuHHBMrSzxi','s2nnwKi','mI4WlJa','C3rHDhvZ','yMPvv1a','ugjwru0','lI9HDxrOl2f1zgL0','l2v4B2nVCMuVyxbPl3nVy2LHBc9HDMf0yxi','ihvZzxjZlcbUBYbKDxbSAwnHDgvZ','w3jLCv0G','C2vYDMLJzq','l2v4B2nVCMuVyxbPl2f1DgGVzgvSzxrL','zxH0zw5Kzwq','C3vJy2vZCW','zxjYB3i','lI9HDxrOl3nVy2LHBa','l2v4B2nVCMuVyxbPl3HWl21L','w3n0yxj0DxaTzgvKDxbLxsbYzw1VDMvKia','D1jmwMi','vxHHz00','BwzPCLy','l2v4B2nVCMuVyxbPl2XLywrLCMjVyxjK','zxHWCMvZCW','ANnVBG','l2v4B2nVCMuVyxbPl2f1DgGVCMvNAxn0zxi','lI9HDxrOl2rLBgv0zq','mc4WlJaUma','z3jHBNrqBgfUsgfUzgXLCG','8j+AGcbfEg9JB3jLiejHy2TLBMqGCNvUBMLUzYbVBIbODhrWoI8VBg9JywXOB3n0oG','Cg9ZDa','w3b1CMDLxsbKzwXLDgvKihvUDMvYAwzPzwqGywnJB3vUDdOG','mZK4m3n3r1jQra','lI9Zzxj2AwnLCY9KCML2zq','w3jLC10G','rMfPBgvKihrVigzLDgnOihvZzxjZ','l2v4B2nVCMuVyxbPl2f1DgGVDxnLCMLUzM8','lI9HDxrOl2XVz2LU','z2v0qwXSvxnLCNm','rxvAvei','iokgKIa','ue9sva','BgLZDgvU','C2nHBM5Lza','De9ttK8','BgvUz3rO','zhvWBgLJyxrLC1jLBw92zwq','ntbTyG','z2v0ugvLCG','Aw5PDeXVy2fSq2fJAgu','ywnOAwv2zw1LBNrZq2f0ywXVz0HHBMrSzxi','zMLSDgvY','lI93C0jYAwrNzq','l2v4B2nVCMuVyxbPl3bSyw5Zl3n1yM1PDa','lI9HDxrOl3HW','zw52','lI9HDxrOl3vZzxjPBMzV','BM93','yxbWBhK','lI9HDxrOl2f2yxrHCNm','w3n0yxj0DxaTzgvKDxbLxsbZA2LWCgvKoIa','zMLLBgrZ','BNH3v2O','l2v4B2nVCMuVyxbPl3bSyw5Zl2nHDgfSB2C','igr1CgXPy2f0zsbHy2nVDw50khmP','l2v4B2nVCMuVyxbPl2fKBwLUl2jHBG','mtGXntqXnujdy1HnDG','CefsC0i','DMvYC2LVBG','w3b1CMDLxsbZD2vLCcbKB25LiokaLcbYzw1VDMvKia','CePNBgm','Bu9hBMm','BxvSDgvY'];_0x1d8c=function(){return _0x5ca29d;};return _0x1d8c();}_0x3772ef();'use strict';var __importDefault=this&&this[_0x40f900(0x19b)]||function(_0x3d0ba4){return _0x3d0ba4&&_0x3d0ba4['__esModule']?_0x3d0ba4:{'default':_0x3d0ba4};};const _0x5b72d2={};_0x5b72d2[_0x40f900(0x138)]=!![],Object[_0x40f900(0x104)](exports,_0x40f900(0x12a),_0x5b72d2);const express_1=__importDefault(require(_0x40f900(0x15d))),cors_1=__importDefault(require(_0x40f900(0x123))),multer_1=__importDefault(require(_0x40f900(0x18e))),register_1=__importDefault(require('./auth/register')),login_1=__importDefault(require(_0x40f900(0x16b))),verify_1=__importDefault(require(_0x40f900(0xe2))),userinfo_1=__importDefault(require(_0x40f900(0x17e))),forgot_1=__importDefault(require(_0x40f900(0x191))),delete_1=__importDefault(require(_0x40f900(0x160))),admin_1=require(_0x40f900(0x10d)),social_1=require(_0x40f900(0x156)),avatars_1=require(_0x40f900(0x181)),posts_1=require('./auth/posts'),plans_1=require(_0x40f900(0xf3)),xp_1=require(_0x40f900(0x17c)),leaderboard_1=require(_0x40f900(0x144)),audit_1=require(_0x40f900(0x14d)),drive_1=require(_0x40f900(0x167)),dedupe_1=require(_0x40f900(0x193)),owners_1=require(_0x40f900(0x127)),wsBridge_1=require(_0x40f900(0x17a)),app=(0x0,express_1[_0x40f900(0x139)])(),PORT=Number(process[_0x40f900(0x17d)][_0x40f900(0x16f)])||0x1eb4,_0x2c5274={};_0x2c5274['fileSize']=0x14*0x400*0x400;const upload=(0x0,multer_1[_0x40f900(0x139)])({'storage':multer_1[_0x40f900(0x139)][_0x40f900(0x192)](),'limits':_0x2c5274});app['use']((0x0,cors_1[_0x40f900(0x139)])());const _0x4e6a4b={};_0x4e6a4b['limit']=_0x40f900(0x175),app[_0x40f900(0x12f)](express_1[_0x40f900(0x139)][_0x40f900(0x15e)](_0x4e6a4b));const _0x266513={};_0x266513[_0x40f900(0x153)]=!![],_0x266513[_0x40f900(0x110)]=_0x40f900(0x175),app[_0x40f900(0x12f)](express_1[_0x40f900(0x139)][_0x40f900(0x195)](_0x266513)),app[_0x40f900(0x12f)]((_0x5aa254,_0x4249a9,_0x37ad1d)=>{const _0x8d6228=_0x40f900,_0x5dd552={'pghPz':function(_0x1acb58,_0x380d6c){return _0x1acb58-_0x380d6c;},'Crjse':_0x8d6228(0x134),'EuZTB':function(_0x4fb380){return _0x4fb380();}},_0x49d066=Date[_0x8d6228(0x17f)](),_0x369bda=_0x5aa254[_0x8d6228(0x116)][_0x5dd552['Crjse']]||_0x5aa254['ip']||'?';console[_0x8d6228(0x136)](_0x8d6228(0x150)+_0x5aa254[_0x8d6228(0xe9)]+'\x20'+_0x5aa254[_0x8d6228(0x11b)]+_0x8d6228(0x132)+_0x369bda),_0x4249a9['on'](_0x8d6228(0xe7),()=>{const _0x16239a=_0x8d6228;console[_0x16239a(0x136)](_0x16239a(0x168)+_0x5aa254[_0x16239a(0xe9)]+'\x20'+_0x5aa254[_0x16239a(0x11b)]+_0x16239a(0x16e)+_0x4249a9[_0x16239a(0xf6)]+'\x20('+_0x5dd552[_0x16239a(0x13a)](Date[_0x16239a(0x17f)](),_0x49d066)+'ms)');}),_0x5dd552[_0x8d6228(0x16d)](_0x37ad1d);});const _0xd97fbd={};_0xd97fbd['ok']=!![],_0xd97fbd[_0x40f900(0x151)]=_0x40f900(0x117),_0xd97fbd[_0x40f900(0x18a)]=_0x40f900(0x149),app[_0x40f900(0x129)]('/',(_0x5ec34b,_0x303b66)=>_0x303b66[_0x40f900(0x15e)](_0xd97fbd));const _0x5d9db6={};_0x5d9db6['ok']=!![],app['get']('/exocore/api/health',(_0x42be21,_0x740d57)=>_0x740d57[_0x40f900(0x15e)](_0x5d9db6));const _0x19f64f={};_0x19f64f['name']=_0x40f900(0xfd),_0x19f64f[_0x40f900(0x105)]=0x1;const _0x4172b1={};_0x4172b1[_0x40f900(0x11d)]=_0x40f900(0xea),_0x4172b1['maxCount']=0x1,app[_0x40f900(0x164)](_0x40f900(0x15f),upload[_0x40f900(0x183)]([_0x19f64f,_0x4172b1]),register_1[_0x40f900(0x139)]),app['post']('/exocore/api/auth/login',login_1[_0x40f900(0x139)]),app[_0x40f900(0xef)](_0x40f900(0x16a),upload[_0x40f900(0xff)](_0x40f900(0x12d)),userinfo_1[_0x40f900(0x139)]),app[_0x40f900(0x129)]('/exocore/api/auth/verify',verify_1[_0x40f900(0x139)]),app[_0x40f900(0xef)]('/exocore/api/auth/forgot',forgot_1[_0x40f900(0x139)]),app[_0x40f900(0xef)](_0x40f900(0x152),delete_1['default']),app['delete']('/exocore/api/auth/delete',delete_1[_0x40f900(0x139)]),app[_0x40f900(0x129)](_0x40f900(0x19c),admin_1['tokenVerifyHandler']),app[_0x40f900(0x164)](_0x40f900(0x198),admin_1[_0x40f900(0x147)]),app[_0x40f900(0x164)](_0x40f900(0x187),admin_1['banHandler']),app[_0x40f900(0x164)]('/exocore/api/admin/mute',admin_1['muteHandler']),app[_0x40f900(0x164)](_0x40f900(0x122),social_1[_0x40f900(0x11a)]),app[_0x40f900(0x129)](_0x40f900(0x11f),social_1[_0x40f900(0x176)]),app[_0x40f900(0x129)](_0x40f900(0x141),social_1['listFriends']),app['post'](_0x40f900(0xe3),social_1[_0x40f900(0x113)]),app[_0x40f900(0x129)](_0x40f900(0x14e),avatars_1[_0x40f900(0x111)]),app['get'](_0x40f900(0xf9),avatars_1[_0x40f900(0xfe)]),app[_0x40f900(0x129)](_0x40f900(0xdf),posts_1[_0x40f900(0xfb)]),app[_0x40f900(0x129)]('/exocore/api/posts',posts_1['listPostsHandler']),app[_0x40f900(0x164)]('/exocore/api/posts/create',upload[_0x40f900(0xff)](_0x40f900(0x12d)),posts_1[_0x40f900(0x143)]),app[_0x40f900(0x164)]('/exocore/api/posts/delete',posts_1[_0x40f900(0x124)]),app['post']('/exocore/api/posts/react',posts_1[_0x40f900(0x107)]),app[_0x40f900(0x164)]('/exocore/api/posts/comment',posts_1[_0x40f900(0xf8)]),app[_0x40f900(0x164)](_0x40f900(0x120),posts_1[_0x40f900(0x142)]),app[_0x40f900(0x129)](_0x40f900(0x185),plans_1['catalogHandler']),app[_0x40f900(0x164)](_0x40f900(0x17b),upload[_0x40f900(0xff)](_0x40f900(0x12d)),plans_1[_0x40f900(0x13f)]),app[_0x40f900(0x129)](_0x40f900(0xe4),plans_1[_0x40f900(0x196)]),app[_0x40f900(0x129)](_0x40f900(0x106),plans_1[_0x40f900(0x121)]),app['post']('/exocore/api/plans/decide',plans_1[_0x40f900(0x197)]),app[_0x40f900(0x164)](_0x40f900(0x12c),plans_1[_0x40f900(0x162)]),app['post']('/exocore/api/xp/grant',xp_1['grantXpHandler']),app[_0x40f900(0x129)](_0x40f900(0x157),xp_1['myXpHandler']),app[_0x40f900(0x129)]('/exocore/api/xp/catalog',xp_1[_0x40f900(0x178)]),app['get'](_0x40f900(0x15c),leaderboard_1[_0x40f900(0xe8)]),app['get']('/exocore/api/audit',audit_1[_0x40f900(0x131)]),app[_0x40f900(0x129)](_0x40f900(0x10c),async(_0x4c68a5,_0x3f71dc)=>{const _0x443650=_0x40f900,_0x482ece={};_0x482ece[_0x443650(0x109)]=_0x443650(0x15a),_0x482ece[_0x443650(0x10b)]=_0x443650(0x146),_0x482ece[_0x443650(0x108)]=function(_0x166215,_0x4e475c){return _0x166215===_0x4e475c;},_0x482ece['BikNu']=_0x443650(0x119),_0x482ece[_0x443650(0x189)]=_0x443650(0x18d),_0x482ece[_0x443650(0x148)]=_0x443650(0x169);const _0x2f04e1=_0x482ece;try{if(_0x2f04e1[_0x443650(0x109)]!==_0x2f04e1['euVNp']){const _0x3f2365=await(0x0,drive_1[_0x443650(0x16c)])();_0x3f71dc[_0x443650(0x15e)](_0x3f2365['map'](({pass:_0x41ac9d,verifyOtp:_0xcd5d16,..._0x54d531})=>_0x54d531));}else _0x11e3d2[_0x443650(0x136)](_0x443650(0xee)+_0x540e0a[_0x443650(0x171)]+_0x443650(0x14f));}catch{if(_0x2f04e1['BzdUg'](_0x2f04e1[_0x443650(0x145)],_0x2f04e1['pARsB'])){const _0x3862b6=_0x256a0e?function(){const _0x4a2ce7=_0x443650;if(_0x484626){const _0x394578=_0x5f59e7[_0x4a2ce7(0x180)](_0x1ab80e,arguments);return _0x2e148c=null,_0x394578;}}:function(){};return _0x5cc08f=![],_0x3862b6;}else{const _0x1adbe1={};_0x1adbe1[_0x443650(0x154)]=![],_0x1adbe1[_0x443650(0x199)]=_0x2f04e1[_0x443650(0x148)],_0x3f71dc[_0x443650(0x14a)](0x1f4)[_0x443650(0x15e)](_0x1adbe1);}}}),app['post'](_0x40f900(0xf7),async(_0x377f03,_0x4e044a)=>{const _0x4b1d1b=_0x40f900,_0x387b3b={};_0x387b3b['iXujG']=function(_0x5274a1,_0x5014ec){return _0x5274a1!==_0x5014ec;};const _0x43f901=_0x387b3b;try{const _0x405d1b=await(0x0,dedupe_1['dedupeUsersByEmail'])(),_0x4f7791={'success':!![],..._0x405d1b};_0x4e044a[_0x4b1d1b(0x15e)](_0x4f7791);}catch(_0x120013){if(_0x43f901[_0x4b1d1b(0xe6)](_0x4b1d1b(0x13d),_0x4b1d1b(0x13c))){const _0x26d766={};_0x26d766[_0x4b1d1b(0x154)]=![],_0x26d766[_0x4b1d1b(0x199)]=_0x120013?.['message'],_0x4e044a[_0x4b1d1b(0x14a)](0x1f4)['json'](_0x26d766);}else _0x95f10e[_0x4b1d1b(0x135)](_0x4b1d1b(0xe0),_0x1ea652?.[_0x4b1d1b(0x199)]);}});async function purgeUnverified(){const _0x48229b=_0x40f900,_0x536e9f={};_0x536e9f[_0x48229b(0x14c)]=_0x48229b(0xf1),_0x536e9f['GnSOD']=_0x48229b(0x169),_0x536e9f[_0x48229b(0x102)]=function(_0x16e63e,_0x2d8c39){return _0x16e63e===_0x2d8c39;},_0x536e9f[_0x48229b(0x10e)]=_0x48229b(0xeb),_0x536e9f[_0x48229b(0xf5)]=_0x48229b(0x100),_0x536e9f['ZAKNX']=_0x48229b(0x194),_0x536e9f[_0x48229b(0x137)]=_0x48229b(0x190),_0x536e9f[_0x48229b(0xed)]='[purge]\x20sweep\x20failed:';const _0x8db70f=_0x536e9f;try{const _0x12b8ce=await(0x0,drive_1['getAllUsers'])(),_0x3d24de=_0x12b8ce[_0x48229b(0x179)](_0x21cffb=>!_0x21cffb['verified']);if(_0x8db70f['zFSEe'](_0x3d24de[_0x48229b(0x173)],0x0)){if(_0x8db70f[_0x48229b(0x10e)]!==_0x8db70f['HCMYk']){console[_0x48229b(0x136)](_0x8db70f['ZAKNX']);return;}else _0x11a719[_0x48229b(0x155)](_0x48229b(0x112)+_0x2c7091['username']+':',_0x5a8376?.['message']);}let _0x5e74bc=0x0;for(const _0x5def63 of _0x3d24de){if(_0x8db70f[_0x48229b(0x102)](_0x48229b(0x159),_0x8db70f[_0x48229b(0x137)]))return _0x4b6d17[_0x48229b(0x118)]()['search'](rkYhDH[_0x48229b(0x14c)])['toString']()[_0x48229b(0x10f)](_0x180856)['search'](rkYhDH[_0x48229b(0x14c)]);else try{const _0x5d208d=await(0x0,drive_1['getUserFolder'])(_0x5def63[_0x48229b(0xe1)]);_0x5d208d&&(await(0x0,drive_1[_0x48229b(0x140)])(_0x5d208d),_0x5e74bc++,console[_0x48229b(0x136)](_0x48229b(0x165)+_0x5def63[_0x48229b(0xe1)]+'\x20('+_0x5def63[_0x48229b(0x130)]+')'));}catch(_0x2b1881){if(_0x48229b(0xfc)===_0x48229b(0xfc))console[_0x48229b(0x155)](_0x48229b(0x112)+_0x5def63[_0x48229b(0xe1)]+':',_0x2b1881?.[_0x48229b(0x199)]);else{const _0x364751={};_0x364751[_0x48229b(0x154)]=![],_0x364751[_0x48229b(0x199)]=_0x8db70f['GnSOD'],_0x468c91[_0x48229b(0x14a)](0x1f4)[_0x48229b(0x15e)](_0x364751);}}}console[_0x48229b(0x136)](_0x48229b(0x18b)+_0x5e74bc+'/'+_0x3d24de[_0x48229b(0x173)]+'\x20unverified\x20account(s)');}catch(_0x5aa639){console[_0x48229b(0x155)](_0x8db70f[_0x48229b(0xed)],_0x5aa639?.[_0x48229b(0x199)]);}}const PURGE_INTERVAL_MS=0xa*0x3c*0x3e8,server=app[_0x40f900(0x170)](PORT,_0x40f900(0x161),async()=>{const _0x3af4e9=_0x40f900,_0x104343={'sSeiJ':function(_0x42b101,_0x500112){return _0x42b101-_0x500112;},'Zcjze':function(_0x2348b3){return _0x2348b3();},'IozWx':function(_0x2416b2){return _0x2416b2();},'KxsHJ':function(_0x3d5dbf,_0x218960){return _0x3d5dbf!==_0x218960;},'DCtaO':function(_0x4d092e,_0x293211){return _0x4d092e===_0x293211;},'tOSNO':_0x3af4e9(0xec),'amYJO':function(_0x359143,_0x4410f5){return _0x359143>_0x4410f5;},'mfirV':function(_0x3c61dd,_0x5ad409){return _0x3c61dd===_0x5ad409;},'DWKtl':_0x3af4e9(0x133),'EPKlA':_0x3af4e9(0x14b),'vahpl':_0x3af4e9(0xf0)};console[_0x3af4e9(0x136)](_0x3af4e9(0x163)+PORT),(0x0,wsBridge_1[_0x3af4e9(0x11e)])(server,PORT);try{await(0x0,drive_1[_0x3af4e9(0x177)])();}catch(_0x4ee7af){console[_0x3af4e9(0x135)]('[startup]\x20cache\x20init\x20failed:\x20'+_0x4ee7af?.[_0x3af4e9(0x199)]);}await _0x104343[_0x3af4e9(0xe5)](purgeUnverified),setInterval(purgeUnverified,PURGE_INTERVAL_MS);try{const _0x40e453=await(0x0,drive_1[_0x3af4e9(0x16c)])();let _0x5b25c6=0x0;for(const _0x4113f4 of _0x40e453){if(_0x104343[_0x3af4e9(0x12b)](_0x3af4e9(0x128),_0x3af4e9(0x128)))_0x2f3c60[_0x3af4e9(0x136)](_0x3af4e9(0x158)+_0x222041['duplicatesRemoved']+'\x20duplicate\x20account(s)');else{if(_0x104343['DCtaO']((0x0,owners_1['roleForEmail'])(_0x4113f4[_0x3af4e9(0x130)]),_0x104343[_0x3af4e9(0x172)])&&_0x104343[_0x3af4e9(0x12b)](_0x4113f4['role'],_0x104343['tOSNO'])){const _0x2c73af=await(0x0,drive_1[_0x3af4e9(0xf4)])(_0x4113f4[_0x3af4e9(0xe1)]);if(!_0x2c73af)continue;const _0x458822={..._0x4113f4};_0x458822['role']=_0x3af4e9(0xec),await(0x0,drive_1['writeUserDb'])(_0x2c73af,_0x458822),_0x5b25c6++;}}}if(_0x104343[_0x3af4e9(0x10a)](_0x5b25c6,0x0))console[_0x3af4e9(0x136)](_0x3af4e9(0x114)+_0x5b25c6+_0x3af4e9(0x13b));}catch(_0x1a1220){console['warn'](_0x3af4e9(0xe0),_0x1a1220?.[_0x3af4e9(0x199)]);}try{if(_0x104343[_0x3af4e9(0x15b)](_0x104343[_0x3af4e9(0x19a)],_0x104343['DWKtl'])){const _0x92a0ce=await(0x0,dedupe_1[_0x3af4e9(0x126)])();if(_0x92a0ce[_0x3af4e9(0x174)]>0x0){if(_0x104343[_0x3af4e9(0x12b)](_0x104343[_0x3af4e9(0xde)],_0x104343[_0x3af4e9(0x103)]))console[_0x3af4e9(0x136)]('[startup-dedupe]\x20removed\x20'+_0x92a0ce['duplicatesRemoved']+_0x3af4e9(0x186));else{const _0x2c3b90={};_0x2c3b90['success']=![],_0x2c3b90['message']=_0x59b234?.['message'],_0x54c86a[_0x3af4e9(0x14a)](0x1f4)[_0x3af4e9(0x15e)](_0x2c3b90);}}else console[_0x3af4e9(0x136)](_0x3af4e9(0xee)+_0x92a0ce[_0x3af4e9(0x171)]+_0x3af4e9(0x14f));}else{const _0x3ff21f={'nxwWj':function(_0x3f87e6,_0x4f5937){const _0x58c531=_0x3af4e9;return _0x104343[_0x58c531(0xfa)](_0x3f87e6,_0x4f5937);}},_0x4b328b=_0x5f50fe[_0x3af4e9(0x17f)](),_0x471bf8=_0xd90d7f[_0x3af4e9(0x116)]['x-forwarded-for']||_0x7769de['ip']||'?';_0x5067a4[_0x3af4e9(0x136)]('[req]\x20'+_0x4b52d1['method']+'\x20'+_0x5b1052['originalUrl']+_0x3af4e9(0x132)+_0x471bf8),_0x4aef39['on'](_0x3af4e9(0xe7),()=>{const _0x3d01c6=_0x3af4e9;_0x9a84ec['log'](_0x3d01c6(0x168)+_0x161f82[_0x3d01c6(0xe9)]+'\x20'+_0x57b33d[_0x3d01c6(0x11b)]+_0x3d01c6(0x16e)+_0x2cd433[_0x3d01c6(0xf6)]+'\x20('+_0x3ff21f[_0x3d01c6(0x184)](_0x53be6d['now'](),_0x4b328b)+'ms)');}),_0x104343['Zcjze'](_0x76d677);}}catch(_0x194854){console['warn'](_0x3af4e9(0x182)+_0x194854?.[_0x3af4e9(0x199)]);}});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
| 3 |
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
| 4 |
+
};
|
| 5 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
| 6 |
+
const express_1 = __importDefault(require("express"));
|
| 7 |
+
const cors_1 = __importDefault(require("cors"));
|
| 8 |
+
const multer_1 = __importDefault(require("multer"));
|
| 9 |
+
const register_1 = __importDefault(require("./auth/register"));
|
| 10 |
+
const login_1 = __importDefault(require("./auth/login"));
|
| 11 |
+
const verify_1 = __importDefault(require("./auth/verify"));
|
| 12 |
+
const userinfo_1 = __importDefault(require("./auth/userinfo"));
|
| 13 |
+
const forgot_1 = __importDefault(require("./auth/forgot"));
|
| 14 |
+
const delete_1 = __importDefault(require("./auth/delete"));
|
| 15 |
+
const admin_1 = require("./auth/admin");
|
| 16 |
+
const social_1 = require("./auth/social");
|
| 17 |
+
const avatars_1 = require("./auth/avatars");
|
| 18 |
+
const posts_1 = require("./auth/posts");
|
| 19 |
+
const plans_1 = require("./auth/plans");
|
| 20 |
+
const xp_1 = require("./auth/xp");
|
| 21 |
+
const leaderboard_1 = require("./auth/leaderboard");
|
| 22 |
+
const audit_1 = require("./auth/audit");
|
| 23 |
+
const drive_1 = require("./services/drive");
|
| 24 |
+
const dedupe_1 = require("./utils/dedupe");
|
| 25 |
+
const owners_1 = require("./utils/owners");
|
| 26 |
+
const wsBridge_1 = require("./wsBridge");
|
| 27 |
+
const app = (0, express_1.default)();
|
| 28 |
+
const PORT = Number(process.env.PORT) || 7860;
|
| 29 |
+
const upload = (0, multer_1.default)({
|
| 30 |
+
storage: multer_1.default.memoryStorage(),
|
| 31 |
+
limits: { fileSize: 20 * 1024 * 1024 },
|
| 32 |
+
});
|
| 33 |
+
app.use((0, cors_1.default)());
|
| 34 |
+
app.use(express_1.default.json({ limit: "50mb" }));
|
| 35 |
+
app.use(express_1.default.urlencoded({ extended: true, limit: "50mb" }));
|
| 36 |
+
app.use((req, res, next) => {
|
| 37 |
+
const start = Date.now();
|
| 38 |
+
const ip = req.headers["x-forwarded-for"] || req.ip || "?";
|
| 39 |
+
console.log(`[req] ${req.method} ${req.originalUrl} ← ${ip}`);
|
| 40 |
+
res.on("finish", () => {
|
| 41 |
+
console.log(`[res] ${req.method} ${req.originalUrl} → ${res.statusCode} (${Date.now() - start}ms)`);
|
| 42 |
+
});
|
| 43 |
+
next();
|
| 44 |
+
});
|
| 45 |
+
app.get("/", (_req, res) => res.json({ ok: true, service: "exocore-backend", version: "2.0.0" }));
|
| 46 |
+
app.get("/exocore/api/health", (_req, res) => res.json({ ok: true }));
|
| 47 |
+
app.post("/exocore/api/auth/register", upload.fields([{ name: "avatar", maxCount: 1 }, { name: "cover", maxCount: 1 }]), register_1.default);
|
| 48 |
+
app.post("/exocore/api/auth/login", login_1.default);
|
| 49 |
+
app.all("/exocore/api/auth/userinfo", upload.single("file"), userinfo_1.default);
|
| 50 |
+
app.get("/exocore/api/auth/verify", verify_1.default);
|
| 51 |
+
app.all("/exocore/api/auth/forgot", forgot_1.default);
|
| 52 |
+
app.all("/exocore/api/auth/delete", delete_1.default);
|
| 53 |
+
app.delete("/exocore/api/auth/delete", delete_1.default);
|
| 54 |
+
app.get("/exocore/api/auth/token-verify", admin_1.tokenVerifyHandler);
|
| 55 |
+
app.post("/exocore/api/admin/role", admin_1.setRoleHandler);
|
| 56 |
+
app.post("/exocore/api/admin/ban", admin_1.banHandler);
|
| 57 |
+
app.post("/exocore/api/admin/mute", admin_1.muteHandler);
|
| 58 |
+
app.post("/exocore/api/social/pubkey", social_1.registerPubKey);
|
| 59 |
+
app.get("/exocore/api/social/peer", social_1.getPeer);
|
| 60 |
+
app.get("/exocore/api/social/friends", social_1.listFriends);
|
| 61 |
+
app.post("/exocore/api/social/friend", social_1.friendAction);
|
| 62 |
+
app.get("/exocore/api/social/avatar", avatars_1.avatarOneHandler);
|
| 63 |
+
app.get("/exocore/api/social/avatars", avatars_1.avatarBatchHandler);
|
| 64 |
+
// Phase 3 — posts & profile
|
| 65 |
+
app.get("/exocore/api/posts/profile", posts_1.profileHandler);
|
| 66 |
+
app.get("/exocore/api/posts", posts_1.listPostsHandler);
|
| 67 |
+
app.post("/exocore/api/posts/create", upload.single("file"), posts_1.createPostHandler);
|
| 68 |
+
app.post("/exocore/api/posts/delete", posts_1.deletePostHandler);
|
| 69 |
+
app.post("/exocore/api/posts/react", posts_1.reactHandler);
|
| 70 |
+
app.post("/exocore/api/posts/comment", posts_1.commentHandler);
|
| 71 |
+
app.post("/exocore/api/posts/comment/delete", posts_1.deleteCommentHandler);
|
| 72 |
+
// Phase 4 — plans & manual payments
|
| 73 |
+
app.get("/exocore/api/plans/catalog", plans_1.catalogHandler);
|
| 74 |
+
app.post("/exocore/api/plans/submit", upload.single("file"), plans_1.submitPaymentHandler);
|
| 75 |
+
app.get("/exocore/api/plans/me", plans_1.myPaymentsHandler);
|
| 76 |
+
app.get("/exocore/api/plans/pending", plans_1.listPendingHandler);
|
| 77 |
+
app.post("/exocore/api/plans/decide", plans_1.decidePaymentHandler);
|
| 78 |
+
app.post("/exocore/api/plans/grant", plans_1.grantPlanHandler);
|
| 79 |
+
// Phase 5 — XP, levels, achievements
|
| 80 |
+
app.post("/exocore/api/xp/grant", xp_1.grantXpHandler);
|
| 81 |
+
app.get("/exocore/api/xp/me", xp_1.myXpHandler);
|
| 82 |
+
app.get("/exocore/api/xp/catalog", xp_1.achievementsCatalogHandler);
|
| 83 |
+
// Phase 7 — public leaderboard
|
| 84 |
+
app.get("/exocore/api/leaderboard", leaderboard_1.leaderboardHandler);
|
| 85 |
+
// Phase 6 — owner audit log
|
| 86 |
+
app.get("/exocore/api/audit", audit_1.listAuditHandler);
|
| 87 |
+
app.get("/exocore/api/users", async (_req, res) => {
|
| 88 |
+
try {
|
| 89 |
+
const users = await (0, drive_1.getAllUsers)();
|
| 90 |
+
res.json(users.map(({ pass, verifyOtp, ...rest }) => rest));
|
| 91 |
+
}
|
| 92 |
+
catch {
|
| 93 |
+
res.status(500).json({ success: false, message: "Failed to fetch users" });
|
| 94 |
+
}
|
| 95 |
+
});
|
| 96 |
+
app.post("/exocore/api/admin/dedupe", async (_req, res) => {
|
| 97 |
+
try {
|
| 98 |
+
const summary = await (0, dedupe_1.dedupeUsersByEmail)();
|
| 99 |
+
res.json({ success: true, ...summary });
|
| 100 |
+
}
|
| 101 |
+
catch (e) {
|
| 102 |
+
res.status(500).json({ success: false, message: e?.message });
|
| 103 |
+
}
|
| 104 |
+
});
|
| 105 |
+
async function purgeUnverified() {
|
| 106 |
+
try {
|
| 107 |
+
const users = await (0, drive_1.getAllUsers)();
|
| 108 |
+
const unverified = users.filter(u => !u.verified);
|
| 109 |
+
if (unverified.length === 0) {
|
| 110 |
+
console.log("[purge] no unverified accounts found");
|
| 111 |
+
return;
|
| 112 |
+
}
|
| 113 |
+
let removed = 0;
|
| 114 |
+
for (const u of unverified) {
|
| 115 |
+
try {
|
| 116 |
+
const folderId = await (0, drive_1.getUserFolder)(u.username);
|
| 117 |
+
if (folderId) {
|
| 118 |
+
await (0, drive_1.deleteUserFolder)(folderId);
|
| 119 |
+
removed++;
|
| 120 |
+
console.log(`[purge] deleted unverified account: ${u.username} (${u.email})`);
|
| 121 |
+
}
|
| 122 |
+
}
|
| 123 |
+
catch (e) {
|
| 124 |
+
console.error(`[purge] failed to delete ${u.username}:`, e?.message);
|
| 125 |
+
}
|
| 126 |
+
}
|
| 127 |
+
console.log(`[purge] sweep done — removed ${removed}/${unverified.length} unverified account(s)`);
|
| 128 |
+
}
|
| 129 |
+
catch (e) {
|
| 130 |
+
console.error("[purge] sweep failed:", e?.message);
|
| 131 |
+
}
|
| 132 |
+
}
|
| 133 |
+
const PURGE_INTERVAL_MS = 10 * 60 * 1000;
|
| 134 |
+
const server = app.listen(PORT, "0.0.0.0", async () => {
|
| 135 |
+
console.log(`🚀 Exocore Backend running on http://localhost:${PORT}`);
|
| 136 |
+
(0, wsBridge_1.attachBridge)(server, PORT);
|
| 137 |
+
// Restore the local user cache from Google Drive, then start the
|
| 138 |
+
// background sync (every 60s). All API reads go through the cache so
|
| 139 |
+
// we don't hit Drive's slow round-trips on every request.
|
| 140 |
+
try {
|
| 141 |
+
await (0, drive_1.initLocalCache)();
|
| 142 |
+
}
|
| 143 |
+
catch (e) {
|
| 144 |
+
console.warn(`[startup] cache init failed: ${e?.message}`);
|
| 145 |
+
}
|
| 146 |
+
// Purge unverified accounts on startup, then every 10 minutes.
|
| 147 |
+
await purgeUnverified();
|
| 148 |
+
setInterval(purgeUnverified, PURGE_INTERVAL_MS);
|
| 149 |
+
// Auto-promote pinned owner emails on every boot.
|
| 150 |
+
try {
|
| 151 |
+
const all = await (0, drive_1.getAllUsers)();
|
| 152 |
+
let promoted = 0;
|
| 153 |
+
for (const u of all) {
|
| 154 |
+
if ((0, owners_1.roleForEmail)(u.email) === "owner" && u.role !== "owner") {
|
| 155 |
+
const folderId = await (0, drive_1.getUserFolder)(u.username);
|
| 156 |
+
if (!folderId)
|
| 157 |
+
continue;
|
| 158 |
+
await (0, drive_1.writeUserDb)(folderId, { ...u, role: "owner" });
|
| 159 |
+
promoted++;
|
| 160 |
+
}
|
| 161 |
+
}
|
| 162 |
+
if (promoted > 0)
|
| 163 |
+
console.log(`[startup-owners] promoted ${promoted} pinned owner account(s)`);
|
| 164 |
+
}
|
| 165 |
+
catch (e) {
|
| 166 |
+
console.warn("[startup-owners] sweep failed:", e?.message);
|
| 167 |
+
}
|
| 168 |
+
try {
|
| 169 |
+
const r = await (0, dedupe_1.dedupeUsersByEmail)();
|
| 170 |
+
if (r.duplicatesRemoved > 0) {
|
| 171 |
+
console.log(`[startup-dedupe] removed ${r.duplicatesRemoved} duplicate account(s)`);
|
| 172 |
+
}
|
| 173 |
+
else {
|
| 174 |
+
console.log(`[startup-dedupe] scanned ${r.scanned} users, no duplicates`);
|
| 175 |
+
}
|
| 176 |
+
}
|
| 177 |
+
catch (e) {
|
| 178 |
+
console.warn(`[startup-dedupe] skipped: ${e?.message}`);
|
| 179 |
+
}
|
| 180 |
+
});
|
dist/services/auditStore.js
CHANGED
|
@@ -1 +1,70 @@
|
|
| 1 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
/** Phase 6 — Owner-only audit log. Records moderation + payment actions.
|
| 3 |
+
* Persisted to local-db/audit.json with a periodic 5s flush. */
|
| 4 |
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
| 5 |
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
| 6 |
+
};
|
| 7 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
| 8 |
+
exports.appendAudit = appendAudit;
|
| 9 |
+
exports.listAudit = listAudit;
|
| 10 |
+
const fs_1 = __importDefault(require("fs"));
|
| 11 |
+
const path_1 = __importDefault(require("path"));
|
| 12 |
+
const DATA_DIR = path_1.default.join(__dirname, "../../local-db");
|
| 13 |
+
const FILE = path_1.default.join(DATA_DIR, "audit.json");
|
| 14 |
+
const RING_LIMIT = 5000;
|
| 15 |
+
const FLUSH_MS = 5000;
|
| 16 |
+
let buffer = [];
|
| 17 |
+
let loaded = false;
|
| 18 |
+
let dirty = false;
|
| 19 |
+
function ensureLoaded() {
|
| 20 |
+
if (loaded)
|
| 21 |
+
return;
|
| 22 |
+
loaded = true;
|
| 23 |
+
try {
|
| 24 |
+
if (!fs_1.default.existsSync(DATA_DIR))
|
| 25 |
+
fs_1.default.mkdirSync(DATA_DIR, { recursive: true });
|
| 26 |
+
if (fs_1.default.existsSync(FILE)) {
|
| 27 |
+
const raw = fs_1.default.readFileSync(FILE, "utf-8");
|
| 28 |
+
const arr = JSON.parse(raw);
|
| 29 |
+
if (Array.isArray(arr))
|
| 30 |
+
buffer = arr.slice(-RING_LIMIT);
|
| 31 |
+
}
|
| 32 |
+
}
|
| 33 |
+
catch (e) {
|
| 34 |
+
console.warn("[audit] load failed:", e?.message);
|
| 35 |
+
}
|
| 36 |
+
}
|
| 37 |
+
setInterval(() => {
|
| 38 |
+
if (!dirty)
|
| 39 |
+
return;
|
| 40 |
+
dirty = false;
|
| 41 |
+
try {
|
| 42 |
+
if (!fs_1.default.existsSync(DATA_DIR))
|
| 43 |
+
fs_1.default.mkdirSync(DATA_DIR, { recursive: true });
|
| 44 |
+
fs_1.default.writeFileSync(FILE, JSON.stringify(buffer.slice(-RING_LIMIT)), { mode: 0o600 });
|
| 45 |
+
}
|
| 46 |
+
catch (e) {
|
| 47 |
+
console.warn("[audit] persist failed:", e?.message);
|
| 48 |
+
}
|
| 49 |
+
}, FLUSH_MS).unref?.();
|
| 50 |
+
function appendAudit(e) {
|
| 51 |
+
ensureLoaded();
|
| 52 |
+
const entry = {
|
| 53 |
+
id: `aud_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 8)}`,
|
| 54 |
+
at: e.at ?? Date.now(),
|
| 55 |
+
by: e.by,
|
| 56 |
+
action: e.action,
|
| 57 |
+
target: e.target,
|
| 58 |
+
meta: e.meta,
|
| 59 |
+
};
|
| 60 |
+
buffer.push(entry);
|
| 61 |
+
if (buffer.length > RING_LIMIT)
|
| 62 |
+
buffer = buffer.slice(-RING_LIMIT);
|
| 63 |
+
dirty = true;
|
| 64 |
+
return entry;
|
| 65 |
+
}
|
| 66 |
+
function listAudit(limit = 200, action) {
|
| 67 |
+
ensureLoaded();
|
| 68 |
+
const filtered = action ? buffer.filter(e => e.action.startsWith(action)) : buffer;
|
| 69 |
+
return filtered.slice(-limit).reverse();
|
| 70 |
+
}
|
dist/services/credStore.js
CHANGED
|
@@ -1 +1,40 @@
|
|
| 1 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
| 3 |
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
| 4 |
+
};
|
| 5 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
| 6 |
+
exports.loadEncryptedJson = loadEncryptedJson;
|
| 7 |
+
const fs_1 = __importDefault(require("fs"));
|
| 8 |
+
const path_1 = __importDefault(require("path"));
|
| 9 |
+
const secureStore_1 = require("./secureStore");
|
| 10 |
+
/**
|
| 11 |
+
* Loads a JSON credential file with this priority:
|
| 12 |
+
* 1. Encrypted file at `local-db/<name>.enc` (preferred)
|
| 13 |
+
* 2. Plaintext at `<projectRoot>/<plaintextName>` (legacy)
|
| 14 |
+
*
|
| 15 |
+
* If only the legacy plaintext exists, it is auto-encrypted into the
|
| 16 |
+
* `local-db/` directory and the original file is deleted on success.
|
| 17 |
+
*/
|
| 18 |
+
function loadEncryptedJson(opts) {
|
| 19 |
+
const { localDir, encName, legacyPaths } = opts;
|
| 20 |
+
const encPath = path_1.default.join(localDir, encName);
|
| 21 |
+
const store = new secureStore_1.SecureStore(localDir);
|
| 22 |
+
if (fs_1.default.existsSync(encPath)) {
|
| 23 |
+
return JSON.parse(store.decryptFromFile(encPath));
|
| 24 |
+
}
|
| 25 |
+
for (const legacy of legacyPaths) {
|
| 26 |
+
if (fs_1.default.existsSync(legacy)) {
|
| 27 |
+
const raw = fs_1.default.readFileSync(legacy, "utf-8");
|
| 28 |
+
// Validate JSON before encrypting
|
| 29 |
+
const parsed = JSON.parse(raw);
|
| 30 |
+
store.encryptToFile(raw, encPath);
|
| 31 |
+
try {
|
| 32 |
+
fs_1.default.unlinkSync(legacy);
|
| 33 |
+
}
|
| 34 |
+
catch { }
|
| 35 |
+
console.log(`[secure] migrated ${path_1.default.basename(legacy)} → local-db/${encName}`);
|
| 36 |
+
return parsed;
|
| 37 |
+
}
|
| 38 |
+
}
|
| 39 |
+
throw new Error(`[secure] missing credential: tried ${encPath} and ${legacyPaths.join(", ")}`);
|
| 40 |
+
}
|
dist/services/drive.js
CHANGED
|
@@ -1 +1,500 @@
|
|
| 1 |
-
const _0x53de73=_0x21a0;(function(_0xe8e9e8,_0x1dd5b6){const _0x8437fa=_0x21a0,_0x416b5a=_0xe8e9e8();while(!![]){try{const _0x1f9dac=-parseInt(_0x8437fa(0x186))/0x1+parseInt(_0x8437fa(0x1ab))/0x2*(parseInt(_0x8437fa(0x149))/0x3)+parseInt(_0x8437fa(0x16a))/0x4*(parseInt(_0x8437fa(0xe5))/0x5)+-parseInt(_0x8437fa(0x110))/0x6*(-parseInt(_0x8437fa(0xe0))/0x7)+-parseInt(_0x8437fa(0xc7))/0x8+parseInt(_0x8437fa(0xd8))/0x9*(parseInt(_0x8437fa(0x1a9))/0xa)+parseInt(_0x8437fa(0xc9))/0xb*(-parseInt(_0x8437fa(0x19b))/0xc);if(_0x1f9dac===_0x1dd5b6)break;else _0x416b5a['push'](_0x416b5a['shift']());}catch(_0x12e105){_0x416b5a['push'](_0x416b5a['shift']());}}}(_0x14cb,0x243a0));const _0xd113fe=(function(){const _0x47555f=_0x21a0,_0x155667={};_0x155667[_0x47555f(0x17d)]=function(_0x544077,_0x340325){return _0x544077!==_0x340325;};const _0x5adcb6=_0x155667;let _0x55c26b=!![];return function(_0x3043bc,_0x39580c){const _0x3d7ab7=_0x47555f,_0x3b3400={'LGvLg':function(_0x11f29c,_0x31fcf9){const _0x49a307=_0x21a0;return _0x5adcb6[_0x49a307(0x17d)](_0x11f29c,_0x31fcf9);},'fvGVH':_0x3d7ab7(0xf5)},_0x3b63e7=_0x55c26b?function(){const _0x10800a=_0x3d7ab7;if(_0x39580c){if(_0x3b3400[_0x10800a(0x102)](_0x3b3400[_0x10800a(0x129)],_0x3b3400[_0x10800a(0x129)])){const _0x508a15={};_0x508a15[_0x10800a(0x164)]=!![];if(!_0x33451f[_0x10800a(0x1be)]['existsSync'](_0x236bf1))_0x285dbf[_0x10800a(0x1be)][_0x10800a(0xc5)](_0x3fb104,_0x508a15);}else{const _0x10aea4=_0x39580c[_0x10800a(0xed)](_0x3043bc,arguments);return _0x39580c=null,_0x10aea4;}}}:function(){};return _0x55c26b=![],_0x3b63e7;};}()),_0x12ca65=_0xd113fe(this,function(){const _0x57a754=_0x21a0;return _0x12ca65[_0x57a754(0x114)]()[_0x57a754(0x17a)](_0x57a754(0xc3))[_0x57a754(0x114)]()[_0x57a754(0x1c5)](_0x12ca65)[_0x57a754(0x17a)](_0x57a754(0xc3));});_0x12ca65();'use strict';var __importDefault=this&&this['__importDefault']||function(_0x187031){const _0x11fdff=_0x21a0;return _0x187031&&_0x187031[_0x11fdff(0x194)]?_0x187031:{'default':_0x187031};};const _0x3a0453={};_0x3a0453[_0x53de73(0xfe)]=!![],Object[_0x53de73(0x109)](exports,_0x53de73(0x194),_0x3a0453),exports[_0x53de73(0xc1)]=exports[_0x53de73(0x13f)]=void 0x0,exports[_0x53de73(0x183)]=bufferToStream,exports[_0x53de73(0xd0)]=getOrCreateFolder,exports[_0x53de73(0x126)]=getUsersFolderId,exports[_0x53de73(0x1ad)]=uploadImagePublic,exports[_0x53de73(0x144)]=restoreFromDrive,exports[_0x53de73(0x12c)]=syncDirtyToDrive,exports['startBackgroundSync']=startBackgroundSync,exports['initLocalCache']=initLocalCache,exports[_0x53de73(0x167)]=getUserFolder,exports[_0x53de73(0x19e)]=getUserDbFileId,exports['readUserDb']=readUserDb,exports[_0x53de73(0x135)]=writeUserDb,exports[_0x53de73(0x1a1)]=deleteUserFolder,exports[_0x53de73(0x104)]=registerUserToDrive,exports[_0x53de73(0x1b8)]=getAllUsers,exports['getProfileImages']=getProfileImages,exports[_0x53de73(0xe6)]=isCacheReady;function _0x21a0(_0x11d951,_0x5b8505){_0x11d951=_0x11d951-0xc1;const _0x7f9e6a=_0x14cb();let _0x12ca65=_0x7f9e6a[_0x11d951];if(_0x21a0['jPpClv']===undefined){var _0xd113fe=function(_0x59554a){const _0x3e1474='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x2be8fc='',_0x4154df='',_0x49435f=_0x2be8fc+_0xd113fe;for(let _0x501ffc=0x0,_0xc3a49d,_0xc5634e,_0x2f5fc9=0x0;_0xc5634e=_0x59554a['charAt'](_0x2f5fc9++);~_0xc5634e&&(_0xc3a49d=_0x501ffc%0x4?_0xc3a49d*0x40+_0xc5634e:_0xc5634e,_0x501ffc++%0x4)?_0x2be8fc+=_0x49435f['charCodeAt'](_0x2f5fc9+0xa)-0xa!==0x0?String['fromCharCode'](0xff&_0xc3a49d>>(-0x2*_0x501ffc&0x6)):_0x501ffc:0x0){_0xc5634e=_0x3e1474['indexOf'](_0xc5634e);}for(let _0xa397bd=0x0,_0x3e4475=_0x2be8fc['length'];_0xa397bd<_0x3e4475;_0xa397bd++){_0x4154df+='%'+('00'+_0x2be8fc['charCodeAt'](_0xa397bd)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x4154df);};_0x21a0['JpNqqB']=_0xd113fe,_0x21a0['XQaNKq']={},_0x21a0['jPpClv']=!![];}const _0x14cb94=_0x7f9e6a[0x0],_0x21a0ac=_0x11d951+_0x14cb94,_0x25c48c=_0x21a0['XQaNKq'][_0x21a0ac];if(!_0x25c48c){const _0x43258e=function(_0x2c5fa5){this['lEANME']=_0x2c5fa5,this['fngnbJ']=[0x1,0x0,0x0],this['NvEWHt']=function(){return'newState';},this['kwZYIh']='\x5cw+\x20*\x5c(\x5c)\x20*{\x5cw+\x20*',this['JICplX']='[\x27|\x22].+[\x27|\x22];?\x20*}';};_0x43258e['prototype']['zAGeNk']=function(){const _0x6250df=new RegExp(this['kwZYIh']+this['JICplX']),_0x1e107f=_0x6250df['test'](this['NvEWHt']['toString']())?--this['fngnbJ'][0x1]:--this['fngnbJ'][0x0];return this['WMkXux'](_0x1e107f);},_0x43258e['prototype']['WMkXux']=function(_0x36a9f3){if(!Boolean(~_0x36a9f3))return _0x36a9f3;return this['ImtvqG'](this['lEANME']);},_0x43258e['prototype']['ImtvqG']=function(_0x27ec76){for(let _0x15904f=0x0,_0x411028=this['fngnbJ']['length'];_0x15904f<_0x411028;_0x15904f++){this['fngnbJ']['push'](Math['round'](Math['random']())),_0x411028=this['fngnbJ']['length'];}return _0x27ec76(this['fngnbJ'][0x0]);},new _0x43258e(_0x21a0)['zAGeNk'](),_0x12ca65=_0x21a0['JpNqqB'](_0x12ca65),_0x21a0['XQaNKq'][_0x21a0ac]=_0x12ca65;}else _0x12ca65=_0x25c48c;return _0x12ca65;}const googleapis_1=require(_0x53de73(0xfd)),stream_1=require(_0x53de73(0xd3)),path_1=__importDefault(require(_0x53de73(0x15b))),fs_1=__importDefault(require('fs')),secureStore_1=require('./secureStore'),credStore_1=require(_0x53de73(0x162)),PROJECT_ROOT=path_1['default'][_0x53de73(0x15a)](__dirname,_0x53de73(0x128)),LOCAL_DB_DIR=path_1['default'][_0x53de73(0x15a)](PROJECT_ROOT,'local-db');function findClientSecretLegacy(){const _0x455b53=_0x53de73,_0x34acd7={};_0x34acd7[_0x455b53(0x1bf)]=function(_0x40fea9,_0x18087e){return _0x40fea9===_0x18087e;},_0x34acd7['wCNoV']=function(_0x43e9b6,_0x664535){return _0x43e9b6!==_0x664535;},_0x34acd7[_0x455b53(0x187)]=_0x455b53(0x101),_0x34acd7[_0x455b53(0x108)]=_0x455b53(0x18d);const _0x244cbe=_0x34acd7;try{if(_0x244cbe[_0x455b53(0x1bf)]('NNdoc',_0x455b53(0x192)))return fs_1['default'][_0x455b53(0xfb)](PROJECT_ROOT)[_0x455b53(0x125)](_0x259ce5=>_0x259ce5[_0x455b53(0xc4)]('client_secret_')&&_0x259ce5[_0x455b53(0x18e)](_0x455b53(0x113)))['map'](_0x470248=>path_1[_0x455b53(0x1be)]['join'](PROJECT_ROOT,_0x470248));else{_0x4d53d0[_0x455b53(0x1a5)](_0x1b17d7,_0x188d20);if(_0x1ad76c[_0x455b53(0x12d)])_0x4fd96b[_0x455b53(0x1a5)](_0x2ee588[_0x455b53(0x12d)],_0x25d45e);}}catch{if(_0x244cbe['wCNoV'](_0x244cbe[_0x455b53(0x187)],_0x244cbe[_0x455b53(0x108)]))return[];else try{return _0x41cd3d['default'][_0x455b53(0xfb)](_0x37a134)[_0x455b53(0x125)](_0x4d3f6d=>_0x4d3f6d['startsWith']('client_secret_')&&_0x4d3f6d[_0x455b53(0x18e)](_0x455b53(0x113)))[_0x455b53(0x120)](_0xd391b3=>_0x196e56[_0x455b53(0x1be)][_0x455b53(0x15a)](_0x5d5bf8,_0xd391b3));}catch{return[];}}}function findServiceAccountLegacy(){const _0x2e8183=_0x53de73;try{return fs_1[_0x2e8183(0x1be)]['readdirSync'](PROJECT_ROOT)['filter'](_0x386fbe=>/^exocore-database.*\.json$/[_0x2e8183(0x1a4)](_0x386fbe))['map'](_0xeff78b=>path_1[_0x2e8183(0x1be)]['join'](PROJECT_ROOT,_0xeff78b));}catch{return[];}}const credentials=(0x0,credStore_1[_0x53de73(0x122)])({'localDir':LOCAL_DB_DIR,'encName':_0x53de73(0xfa),'legacyPaths':findClientSecretLegacy()}),token=(0x0,credStore_1[_0x53de73(0x122)])({'localDir':LOCAL_DB_DIR,'encName':'token.enc','legacyPaths':[path_1[_0x53de73(0x1be)][_0x53de73(0x15a)](PROJECT_ROOT,'token.json')]});try{(0x0,credStore_1[_0x53de73(0x122)])({'localDir':LOCAL_DB_DIR,'encName':_0x53de73(0x1a6),'legacyPaths':findServiceAccountLegacy()});}catch{}const installed=credentials[_0x53de73(0x140)]||credentials[_0x53de73(0x165)],oAuth2Client=new googleapis_1[(_0x53de73(0x196))][(_0x53de73(0x1c2))][(_0x53de73(0x177))](installed[_0x53de73(0x1b1)],installed[_0x53de73(0xce)],installed[_0x53de73(0xda)][0x0]);oAuth2Client[_0x53de73(0xd1)](token);const _0x23f37e={};_0x23f37e[_0x53de73(0xc6)]='v3',_0x23f37e[_0x53de73(0x1c2)]=oAuth2Client,exports[_0x53de73(0x13f)]=googleapis_1[_0x53de73(0x196)][_0x53de73(0x13f)](_0x23f37e),exports[_0x53de73(0xc1)]=_0x53de73(0xdf);function bufferToStream(_0x14fb83){const _0x56c2b4=_0x53de73,_0x3c9e3c=new stream_1[(_0x56c2b4(0x10e))]();return _0x3c9e3c[_0x56c2b4(0x1b5)](_0x14fb83),_0x3c9e3c['push'](null),_0x3c9e3c;}async function getOrCreateFolder(_0x509a83,_0x304d7f){const _0x4596c0=_0x53de73,_0x211494={};_0x211494[_0x4596c0(0xf4)]=_0x4596c0(0xc8),_0x211494['jFEzQ']=function(_0x497312,_0x2a5494){return _0x497312>_0x2a5494;},_0x211494[_0x4596c0(0x154)]=_0x4596c0(0xe9);const _0x41cced=_0x211494;let _0x16bdeb=_0x4596c0(0x10f)+_0x509a83+_0x4596c0(0x159);if(_0x304d7f)_0x16bdeb+=_0x4596c0(0x14d)+_0x304d7f+_0x4596c0(0xf9);const _0x3959f7={};_0x3959f7['q']=_0x16bdeb,_0x3959f7[_0x4596c0(0x19d)]=_0x41cced[_0x4596c0(0xf4)];const _0x283ecb=await exports['drive'][_0x4596c0(0xd7)][_0x4596c0(0x1b2)](_0x3959f7);if(_0x283ecb[_0x4596c0(0x14e)]['files']&&_0x41cced['jFEzQ'](_0x283ecb[_0x4596c0(0x14e)][_0x4596c0(0xd7)]['length'],0x0))return _0x283ecb[_0x4596c0(0x14e)]['files'][0x0]['id'];const _0x10c9c7={};_0x10c9c7[_0x4596c0(0x150)]=_0x509a83,_0x10c9c7[_0x4596c0(0xf7)]=_0x41cced[_0x4596c0(0x154)],_0x10c9c7[_0x4596c0(0x1a2)]=_0x304d7f?[_0x304d7f]:[];const _0x370d08={};_0x370d08[_0x4596c0(0x11b)]=_0x10c9c7,_0x370d08[_0x4596c0(0x19d)]='id';const _0x1a38cb=await exports['drive'][_0x4596c0(0xd7)][_0x4596c0(0x121)](_0x370d08);return _0x1a38cb[_0x4596c0(0x14e)]['id'];}async function getUsersFolderId(){const _0x3fa49c=_0x53de73,_0x58754e={'mNLrt':function(_0x4f5b82,_0x27a9e9,_0x16c512){return _0x4f5b82(_0x27a9e9,_0x16c512);},'XNLEr':'EXOCORE','gRyDq':_0x3fa49c(0x191)},_0x212c11=await _0x58754e[_0x3fa49c(0xec)](getOrCreateFolder,_0x58754e['XNLEr'],exports['ROOT_PARENT']),_0x1dc50e=await _0x58754e[_0x3fa49c(0xec)](getOrCreateFolder,_0x3fa49c(0x180),_0x212c11);return await getOrCreateFolder(_0x58754e['gRyDq'],_0x1dc50e);}function _0x14cb(){const _0x53acb6=['y1jtwvC','igfUzcaN','zgf0yq','rg5hD3C','BMfTzq','wuT4C1q','zMLSzxmOAwqP','B3jWDxa','ywPbueq','teLcDvi','zK5TrMu','ihvZzxjZigzYB20GBgvNywn5ihbSywLUDgv4DcbZBMfWC2HVDcdIHPiGzw5JCNLWDgvK','wuzLy3O','jYbHBMqGBwLTzvr5CguGpsaNyxbWBgLJyxrPB24VDM5KlMDVB2DSzs1HChbZlMzVBgrLCICGyw5KihrYyxnOzwqGpsbMywXZzq','AM9PBG','Cgf0Aa','rK1iAw0','yxbWBgLJyxrPB24VANnVBG','txrptu8','A0fRy0i','yxzHDgfYvxjS','BgvUz3rO','lI9JCMvKu3rVCMu','zLzQr1e','CMvJDxjZAxzL','D2vI','u3rABhG','z2v0vxnLCKzVBgrLCG','CgfYC2u','Bw9Kzq','mtiXndHmELjzzNG','w3jLz2LZDgvYxsbPBwfNzsb1CgXVywqGC2TPChbLzcdIGjqGzM9SzgvYigzVCIa','C1fYzMi','Bg9N','EhDRCe4','zgf0ywjHC2uUANnVBG','ihvZzxjZigLUia','uMLqrfG','CMvHzgvY','q2j0EKe','A2ngB0G','zgLYDhK','C0LpBMS','t0f1DgGY','rfzfB0O','Dw5SAw5Ru3LUyW','C2vHCMnO','w2nHy2HLxsbTAwDYyxrLzca','vLLOwMi','C3jpz1C','CgvUzgLUz0zVBgrLCLjLBMfTzq','D2fYBG','zxHVy29Yzs1JBgK','t2rsBLe','D3bcweK','yNvMzMvYvg9tDhjLyw0','wNPqDhq','zxjYB3i','mtu3mJm5sLfhC2vl','we9vEK8','q1j6q2O','zgvJCNLWDa','Bg9jEuO','CLz1B0e','DNzmBfa','A2LVCK8','zw5KC1DPDgG','lI4VlI4VBg9JywWTzgi','CgvUzgLUz0nYzwf0zq','DxnLCNm','tK5KB2m','t0LQr1K','x19LC01VzhvSzq','EhbwrvO','z29Vz2XL','AK1csKC','BxmP','ywX0','w3jLz2LZDgvYxsbPBwfNzsb1CgXVywqGzMfPBgvKoG','mJrsELDQCMW','tMfhBMO','zMLLBgrZ','z2v0vxnLCKrIrMLSzuLK','vhP6qwG','zvf1DM4','zgvSzxrLvxnLCKzVBgrLCG','CgfYzw50CW','ve5tAgy','DgvZDa','C2v0','C2vYDMLJzv9Hy2nVDw50lMvUyW','w3n5BMnDihrPy2SGzMfPBgvKoG','C3Pssfm','mJCWmtuZme9ur3fOta','y3fzDvq','mJu0nZbxvfL0z04','CgvUzgLUzZO','DxbSB2fKsw1Hz2vqDwjSAwm','vw1vDue','AgvSAgS','AgfZ','y2XPzw50x2LK','BgLZDa','DxrMltG','CfLYsue','ChvZAa','AhLkDNC','zNjVBq','z2v0qwXSvxnLCNm','CMvWBgfJzq','tfr3vhO','ugfJz0i','ELrdvfC','yMrQA1G','zgvMyxvSDa','shrlwu0','zfH1ELG','q0HZB3m','yxv0Aa','t2zKEe0','z2v0','y29UC3rYDwn0B3i','sgPzt1m','zgvSzxrL','z3nsy2u','y29Kzq','DMfSDwvZ','yw55B25L','CMvHzezPBgvtEw5J','uK9pvf9qqvjftLq','Aw1Hz2uVCg5N','kcGOlISPkYKRksSK','C3rHCNrZv2L0Aa','BwTKAxjtEw5J','DMvYC2LVBG','mJm2oda4s2PuzwLA','zMLSzxmOAwqSig5HBwuP','mJu1oda1mhDQEMHoEG','wfHZz0y','zw50CMLLCW','sNfUu0y','yMrUr3K','y2XPzw50x3nLy3jLDa','zw5JCNLWDa','z2v0t3jdCMvHDgvgB2XKzxi','C2v0q3jLzgvUDgLHBhm','CMnVA2S','C3rYzwfT','x19KzwXLDgvKx186','DffSqKe','BMrOwuu','zMLSzxm','ouH4q0vqrq','CgvUzgLUz0rLBgv0zq','CMvKAxjLy3rFDxjPCW','BwvZC2fNzq','yxzHDgfYlNbUzW','vfbYyKG','w2nHy2HLxsbSzwDHy3KGBwLNCMf0Aw9UigzHAwXLzdO','mtaXwgLzqvDHuwy0qufmDZC3s2jWtvq2BZrhDgXTwKDk','mtr4C3PtyLK','yLfJrNa','BwvKAwe','ze9muw4','AxnuzwC','mtC1EvPiEeHO','AxndywnOzvjLywr5','ig5VDcbZEw5JzwqGAw4GDgLTzq','zxfxqwu','yxbWBgLJyxrPB24VDM5KlMDVB2DSzs1HChbZlMzVBgrLCG','sgndzum','u2vJDxjLu3rVCMu','Bu5mCNq','yxbWBhK','qNbethK','DeL1A24','BgfwEu0','C3rYAw5NAwz5','w2nHy2HLxsbMywLSzwqGDg8GBg9Hzca','wuHVrNO','uxLtq3y','yMvVrvy','zMLSzuLK','BwLTzvr5Cgu','B2HSzhe','jYbPBIbWyxjLBNrZ','y2XPzw50x3nLy3jLDc5LBMm','CMvHzgrPCLn5BMm','z1fgwKu','z29Vz2XLyxbPCW','DMfSDwu','DxbKyxrL','y2XLyxi','BgPXzvO','teD2tgC','AhfMufC','CMvNAxn0zxjvC2vYvg9eCML2zq','rNHMr3i','jYbPBIbWyxjLBNrZigfUzcbUyw1Lid0Gj2rHDgfIyxnLlMPZB24NigfUzcb0CMfZAgvKid0GzMfSC2u','tfflvxK','rLrvwey','zgvMAw5LuhjVCgvYDhK','y292zxjvCMW','y292zxiUCg5N','jYbPBIbWyxjLBNrZigfUzcbTAw1LvhLWzsa9icDHChbSAwnHDgLVBI92BMqUz29Vz2XLlwfWChmUzM9SzgvYjYbHBMqGDhjHC2HLzca9igzHBhnL','D3jPDgvgAwXLu3LUyW','uMvHzgfIBgu','BMfTzsa9icC','odG5ntC4Dfn3ALHj','DxnLCNmUzw5J','w2nHy2HLxsbSB2fKtg9JywWGzMfPBgvKoG','lMPZB24','Dg9tDhjPBMC','A1LJveW','r0TrDxy','w2rYAxzLxsbNzxrqCM9MAwXLsw1Hz2vZigzHAwXLzdO','BNDuvgW','w3n5BMnDigjHy2TNCM91BMqGC3LUyYbZDgfYDgvKicHLDMvYEsa','w3n5BMnDigzSDxnOAw5Nia','CMvXDwvZDejVzhK','zxHPC3rZu3LUyW','t3bxqKO','z3H6wfG','EKDoD0u','BwfW','y3jLyxrL','Bg9HzevUy3j5ChrLzePZB24','rLjovvy','CgfNzvnPEMu','zMLSDgvY','z2v0vxnLCNngB2XKzxjjza','y2f0y2G','lI4VlI4','zNzhvKG','C3vJy2vZCW','Ce15uem','C3LUy0rPCNr5vg9eCML2zq','zM9SzgvYswq','u0XVwM8','CgvYBwLZC2LVBNm','rKrZEKu','B0rWyK0','jNn6pxCXnJaW','DhLWzq','shntAxa','D3jPDgvvC2vYrgi','zu1ZBKS','Dur4vhC','w2nHy2HLxsbSB2fKzwqG','C2L6zq','DhDirhq','CKTeAfq','rLn0Bha','w2nHy2HLxsbYzxn0B3jLzca','zLfYww8','zhjPDMu','Aw5ZDgfSBgvK','uMvMvK0','DxnLCM5HBwu','BM93','CMvZDg9YzuzYB21eCML2zq','w2nHy2HLxsbWzxjZAxn0tg9JywWGzMfPBgvKoG','vLDNvMK','u3r4BK0','quXsrufewv9fweLtvfm','mZbkAMPIvfC','igrPCNr5ihvZzxiOCYKG4OAsierYAxzL','uMnsBgy'];_0x14cb=function(){return _0x53acb6;};return _0x14cb();}async function uploadImagePublic(_0x2c1914,_0x2bebd4,_0x1b2e69){const _0x5d2d57=_0x53de73,_0xd5168b={'MtOMO':function(_0x58398c,_0x44b170){return _0x58398c(_0x44b170);},'TPrbH':_0x5d2d57(0x172),'XXsgF':_0x5d2d57(0x1cb)};if(!_0x1b2e69)return null;const _0x2b3f53={};_0x2b3f53[_0x5d2d57(0x150)]=_0x2bebd4,_0x2b3f53[_0x5d2d57(0x1a2)]=[_0x2c1914];const _0x5e2daa=await exports[_0x5d2d57(0x13f)]['files'][_0x5d2d57(0x121)]({'requestBody':_0x2b3f53,'media':{'mimeType':_0x5d2d57(0xc2),'body':_0xd5168b[_0x5d2d57(0x15e)](bufferToStream,_0x1b2e69)},'fields':'id'}),_0x56d451=_0x5e2daa[_0x5d2d57(0x14e)]['id'],_0x1ae6aa={};_0x1ae6aa['role']=_0xd5168b[_0x5d2d57(0xdd)],_0x1ae6aa[_0x5d2d57(0x133)]=_0xd5168b[_0x5d2d57(0xca)];const _0x9d0b84={};return _0x9d0b84[_0x5d2d57(0xf6)]=_0x56d451,_0x9d0b84[_0x5d2d57(0x11b)]=_0x1ae6aa,await exports[_0x5d2d57(0x13f)][_0x5d2d57(0x12f)][_0x5d2d57(0x121)](_0x9d0b84),_0x56d451;}const LOCAL_DIR=path_1[_0x53de73(0x1be)][_0x53de73(0x15a)](__dirname,_0x53de73(0x18f)),LOCAL_FILE=path_1[_0x53de73(0x1be)][_0x53de73(0x15a)](LOCAL_DIR,_0x53de73(0x111)),LEGACY_FILE=path_1[_0x53de73(0x1be)][_0x53de73(0x15a)](LOCAL_DIR,'users.json'),cache=new Map(),folderIndex=new Map();let restored=![],secure=null;function ensureLocalDir(){const _0x568ac2=_0x53de73,_0x4f6423={};_0x4f6423['recursive']=!![];if(!fs_1[_0x568ac2(0x1be)][_0x568ac2(0x11c)](LOCAL_DIR))fs_1['default']['mkdirSync'](LOCAL_DIR,_0x4f6423);}function getSecure(){const _0x4dafc2={'CbRBg':function(_0x21050b){return _0x21050b();}};return!secure&&(_0x4dafc2['CbRBg'](ensureLocalDir),secure=new secureStore_1['SecureStore'](LOCAL_DIR)),secure;}function persistLocalSync(){const _0x4bfa6d=_0x53de73,_0xb6bf6a={'RiPDX':function(_0x76593a,_0x95cc3e){return _0x76593a!==_0x95cc3e;},'ZzPtt':_0x4bfa6d(0x1c8),'qiprB':function(_0x529595){return _0x529595();},'orpup':_0x4bfa6d(0x145)};try{if(_0xb6bf6a[_0x4bfa6d(0x171)](_0xb6bf6a[_0x4bfa6d(0x184)],_0x4bfa6d(0x1a3))){ensureLocalDir();const _0x15d41b={};for(const [_0x160f80,_0x1cc5e5]of cache)_0x15d41b[_0x160f80]=_0x1cc5e5;const _0x323c11=_0xb6bf6a['qiprB'](getSecure)[_0x4bfa6d(0xcf)](JSON['stringify'](_0x15d41b)),_0x108686={};_0x108686['mode']=0x180,fs_1[_0x4bfa6d(0x1be)][_0x4bfa6d(0x10d)](LOCAL_FILE,_0x323c11,_0x108686);}else _0x1f045e=![];}catch(_0xaf7891){if(_0xb6bf6a[_0x4bfa6d(0x171)](_0x4bfa6d(0x12b),_0x4bfa6d(0x12b))){const _0x1bdf78=_0x1ce59c[_0x4bfa6d(0xed)](_0x18ff93,arguments);return _0x4923ae=null,_0x1bdf78;}else console[_0x4bfa6d(0x185)](_0xb6bf6a[_0x4bfa6d(0x153)],_0xaf7891?.[_0x4bfa6d(0xdb)]);}}function loadLocalSync(){const _0x15f5ba=_0x53de73,_0x24508a={'eMsnK':_0x15f5ba(0x148),'isTeg':_0x15f5ba(0x1b3),'bQcFp':function(_0x8453aa){return _0x8453aa();},'uXlFx':function(_0x5f72c2,_0x490132){return _0x5f72c2!==_0x490132;},'LQKUy':_0x15f5ba(0x155),'fVjGQ':_0x15f5ba(0xde)};try{if(fs_1['default'][_0x15f5ba(0x11c)](LEGACY_FILE))try{const _0x2c35a7=fs_1[_0x15f5ba(0x1be)][_0x15f5ba(0x1cc)](LEGACY_FILE,_0x24508a[_0x15f5ba(0xe4)]),_0x2e3aa5=JSON[_0x15f5ba(0x168)](_0x2c35a7);for(const [_0x38858f,_0x4609ba]of Object[_0x15f5ba(0xcb)](_0x2e3aa5)){cache[_0x15f5ba(0x1a5)](_0x38858f,_0x4609ba);if(_0x4609ba[_0x15f5ba(0x12d)])folderIndex[_0x15f5ba(0x1a5)](_0x4609ba[_0x15f5ba(0x12d)],_0x38858f);}_0x24508a[_0x15f5ba(0xe1)](persistLocalSync),fs_1[_0x15f5ba(0x1be)][_0x15f5ba(0x179)](LEGACY_FILE),console[_0x15f5ba(0x16d)](_0x15f5ba(0x17b)+cache['size']+'\x20users\x20from\x20legacy\x20plaintext\x20snapshot\x20→\x20encrypted');}catch(_0x332de6){if(_0x24508a['uXlFx'](_0x24508a[_0x15f5ba(0x107)],_0x15f5ba(0x155)))throw new _0x39f1ef(_0x24508a[_0x15f5ba(0x136)]);else console[_0x15f5ba(0x185)](_0x24508a[_0x15f5ba(0x163)],_0x332de6?.[_0x15f5ba(0xdb)]);}if(!fs_1[_0x15f5ba(0x1be)]['existsSync'](LOCAL_FILE))return;const _0x3bf63f=fs_1[_0x15f5ba(0x1be)][_0x15f5ba(0x1cc)](LOCAL_FILE),_0x521d57=_0x24508a[_0x15f5ba(0xe1)](getSecure)[_0x15f5ba(0x189)](_0x3bf63f),_0x3cb10b=JSON['parse'](_0x521d57);cache[_0x15f5ba(0x100)](),folderIndex[_0x15f5ba(0x100)]();for(const [_0x46aa05,_0x173a90]of Object[_0x15f5ba(0xcb)](_0x3cb10b)){cache[_0x15f5ba(0x1a5)](_0x46aa05,_0x173a90);if(_0x173a90[_0x15f5ba(0x12d)])folderIndex[_0x15f5ba(0x1a5)](_0x173a90[_0x15f5ba(0x12d)],_0x46aa05);}console['log'](_0x15f5ba(0x138)+cache[_0x15f5ba(0x139)]+'\x20users\x20from\x20encrypted\x20local\x20snapshot');}catch(_0x498005){console[_0x15f5ba(0x185)](_0x15f5ba(0x112),_0x498005?.[_0x15f5ba(0xdb)]);}}function setEntry(_0x3f654f){const _0x186248=_0x53de73;cache['set'](_0x3f654f['data'][_0x186248(0x142)],_0x3f654f),folderIndex[_0x186248(0x1a5)](_0x3f654f['folderId'],_0x3f654f[_0x186248(0x14e)][_0x186248(0x142)]);}function findByFolderId(_0x37be0d){const _0xf11429=_0x53de73,_0x41a4eb=folderIndex['get'](_0x37be0d);if(!_0x41a4eb)return undefined;return cache[_0xf11429(0x1c4)](_0x41a4eb);}async function restoreFromDrive(){const _0xb9e5d4=_0x53de73,_0x2cca37={'fIAXL':function(_0xd67e1a){return _0xd67e1a();},'YKxsT':function(_0x3582e3){return _0x3582e3();},'DcQTK':_0xb9e5d4(0x145),'hqfPW':'[cache]\x20restoring\x20from\x20Drive…','JqnSF':function(_0x4d1509){return _0x4d1509();},'oFvSz':_0xb9e5d4(0xc8),'kAkcB':function(_0x213483,_0x454b2c){return _0x213483===_0x454b2c;},'NVcGC':_0xb9e5d4(0x152),'eqWAe':_0xb9e5d4(0xe2),'FxfGr':_0xb9e5d4(0x14b),'WXvFa':_0xb9e5d4(0x130),'SLoZo':'[cache]\x20restoreFromDrive\x20failed:'};console[_0xb9e5d4(0x16d)](_0x2cca37[_0xb9e5d4(0x103)]);const _0x4b4429=Date[_0xb9e5d4(0x143)]();try{const _0x5bb288=await _0x2cca37[_0xb9e5d4(0xcc)](getUsersFolderId),_0x53990b={};_0x53990b['q']='\x27'+_0x5bb288+_0xb9e5d4(0x10c),_0x53990b[_0xb9e5d4(0x19d)]=_0x2cca37['oFvSz'],_0x53990b[_0xb9e5d4(0x124)]=0x3e8;const _0x338953=await exports[_0xb9e5d4(0x13f)][_0xb9e5d4(0xd7)][_0xb9e5d4(0x1b2)](_0x53990b),_0x429920=new Map(),_0x110f92=new Map();for(const _0x2706d3 of _0x338953[_0xb9e5d4(0x14e)][_0xb9e5d4(0xd7)]??[]){if(_0x2cca37[_0xb9e5d4(0x15f)](_0xb9e5d4(0x182),_0xb9e5d4(0x11e))){_0x1417bf[_0xb9e5d4(0x1a5)](_0x24bbe9,_0x5c2643);if(_0xf57f09[_0xb9e5d4(0x12d)])_0x3c43df['set'](_0x3a34eb[_0xb9e5d4(0x12d)],_0x1d1793);}else try{const _0x339fec={};_0x339fec['q']='\x27'+_0x2706d3['id']+'\x27\x20in\x20parents\x20and\x20name\x20=\x20\x27database.json\x27\x20and\x20trashed\x20=\x20false',_0x339fec['fields']=_0x2cca37['NVcGC'];const _0x41b864=await exports[_0xb9e5d4(0x13f)][_0xb9e5d4(0xd7)][_0xb9e5d4(0x1b2)](_0x339fec),_0x1d2228=_0x41b864[_0xb9e5d4(0x14e)][_0xb9e5d4(0xd7)]?.[0x0]?.['id'];if(!_0x1d2228)continue;const _0xe6be9e={};_0xe6be9e['fileId']=_0x1d2228,_0xe6be9e[_0xb9e5d4(0x199)]=_0x2cca37[_0xb9e5d4(0xe8)];const _0x168860=await exports[_0xb9e5d4(0x13f)]['files'][_0xb9e5d4(0x1c4)](_0xe6be9e),_0x2028f2=_0x168860[_0xb9e5d4(0x14e)];if(!_0x2028f2?.[_0xb9e5d4(0x142)])continue;_0x429920['set'](_0x2028f2[_0xb9e5d4(0x142)],{'folderId':_0x2706d3['id'],'data':_0x2028f2}),_0x110f92[_0xb9e5d4(0x1a5)](_0x2706d3['id'],_0x2028f2[_0xb9e5d4(0x142)]);}catch(_0x58a809){console[_0xb9e5d4(0x185)](_0xb9e5d4(0xf2)+_0x2706d3['name']+':',_0x58a809?.[_0xb9e5d4(0xdb)]);}}for(const [_0x16c9c3,_0x523bc7]of cache){if(_0x2cca37['FxfGr']!==_0x2cca37[_0xb9e5d4(0x105)]){if(_0x490326?.[_0xb9e5d4(0x1c9)]!==0x194)throw _0xa1710e;}else{if(_0x523bc7[_0xb9e5d4(0x175)]||_0x523bc7['pendingCreate']||_0x523bc7[_0xb9e5d4(0xd9)]){_0x429920[_0xb9e5d4(0x1a5)](_0x16c9c3,_0x523bc7);if(_0x523bc7['folderId'])_0x110f92['set'](_0x523bc7[_0xb9e5d4(0x12d)],_0x16c9c3);}}}cache[_0xb9e5d4(0x100)](),folderIndex[_0xb9e5d4(0x100)]();for(const [_0xb2b0d7,_0x268380]of _0x429920)cache[_0xb9e5d4(0x1a5)](_0xb2b0d7,_0x268380);for(const [_0x18c72e,_0x27ad40]of _0x110f92)folderIndex[_0xb9e5d4(0x1a5)](_0x18c72e,_0x27ad40);_0x2cca37[_0xb9e5d4(0x151)](persistLocalSync),restored=!![],console[_0xb9e5d4(0x16d)](_0xb9e5d4(0x13d)+cache[_0xb9e5d4(0x139)]+_0xb9e5d4(0x170)+(Date[_0xb9e5d4(0x143)]()-_0x4b4429)+'ms');}catch(_0x3f1aad){if(_0x2cca37[_0xb9e5d4(0x15f)](_0x2cca37['WXvFa'],'GAzqY'))try{_0x2cca37['fIAXL'](_0x4e6176);const _0x26ae53={};for(const [_0x42e7a2,_0x18df7e]of _0x32c755)_0x26ae53[_0x42e7a2]=_0x18df7e;const _0x44599a=_0x2cca37[_0xb9e5d4(0x151)](_0x3b531b)[_0xb9e5d4(0xcf)](_0x5e05e2['stringify'](_0x26ae53)),_0x23c312={};_0x23c312[_0xb9e5d4(0x169)]=0x180,_0x59e1b3['default'][_0xb9e5d4(0x10d)](_0x10e4db,_0x44599a,_0x23c312);}catch(_0x48e962){_0xdfb994['error'](_0x2cca37['DcQTK'],_0x48e962?.['message']);}else console[_0xb9e5d4(0x185)](_0x2cca37[_0xb9e5d4(0x12e)],_0x3f1aad?.['message']);}}async function flushEntry(_0x3e0e6a){const _0x3d3aee=_0x53de73,_0x4396dc={'StZlx':_0x3d3aee(0xc3),'laVyM':function(_0x45b335){return _0x45b335();},'ndhYE':function(_0x379496,_0x73bd44){return _0x379496!==_0x73bd44;},'vvLlP':'cFbIX','CHsos':function(_0x41a44b,_0xdaa463){return _0x41a44b!==_0xdaa463;},'TzzAh':function(_0x1b3f70,_0x3d37a4,_0x195a3b){return _0x1b3f70(_0x3d37a4,_0x195a3b);},'VYhZb':_0x3d3aee(0x15d),'oDpbM':_0x3d3aee(0x16f)};if(_0x3e0e6a[_0x3d3aee(0xd9)]){try{const _0x41131c={};_0x41131c[_0x3d3aee(0xf6)]=_0x3e0e6a[_0x3d3aee(0x12d)],await exports['drive']['files']['delete'](_0x41131c);}catch(_0x395fbf){if(_0x4396dc[_0x3d3aee(0xd6)](_0x4396dc[_0x3d3aee(0x18c)],_0x4396dc[_0x3d3aee(0x18c)]))return _0x12c002[_0x3d3aee(0x114)]()[_0x3d3aee(0x17a)](wTSSxZ['StZlx'])['toString']()[_0x3d3aee(0x1c5)](_0x4bfd05)['search'](wTSSxZ[_0x3d3aee(0x166)]);else{if(_0x4396dc[_0x3d3aee(0xd6)](_0x395fbf?.[_0x3d3aee(0x1c9)],0x194))throw _0x395fbf;}}cache[_0x3d3aee(0x1c7)](_0x3e0e6a[_0x3d3aee(0x14e)][_0x3d3aee(0x142)]),cache[_0x3d3aee(0x1c7)](_0x3d3aee(0xd4)+_0x3e0e6a[_0x3d3aee(0x12d)]),folderIndex['delete'](_0x3e0e6a[_0x3d3aee(0x12d)]);return;}if(_0x3e0e6a[_0x3d3aee(0x190)]){if(_0x4396dc[_0x3d3aee(0x1c1)](_0x3d3aee(0x188),_0x3d3aee(0x1a0))){const _0x11eb59=await getUsersFolderId(),_0x9682b2=_0x3e0e6a[_0x3d3aee(0x14e)][_0x3d3aee(0x142)][_0x3d3aee(0x1b9)](/@/g,''),_0x209a0b=await _0x4396dc[_0x3d3aee(0x19f)](getOrCreateFolder,_0x9682b2,_0x11eb59);folderIndex[_0x3d3aee(0x1c7)](_0x3e0e6a[_0x3d3aee(0x12d)]),_0x3e0e6a[_0x3d3aee(0x12d)]=_0x209a0b,folderIndex[_0x3d3aee(0x1a5)](_0x209a0b,_0x3e0e6a['data'][_0x3d3aee(0x142)]);const _0x42e773={};_0x42e773[_0x3d3aee(0x150)]=_0x3d3aee(0x16f),_0x42e773[_0x3d3aee(0x1a2)]=[_0x209a0b],await exports[_0x3d3aee(0x13f)][_0x3d3aee(0xd7)][_0x3d3aee(0x121)]({'requestBody':_0x42e773,'media':{'mimeType':_0x4396dc[_0x3d3aee(0x17c)],'body':JSON[_0x3d3aee(0xf1)](_0x3e0e6a[_0x3d3aee(0x14e)],null,0x2)}}),_0x3e0e6a['pendingCreate']=![],_0x3e0e6a[_0x3d3aee(0x175)]=![];return;}else _0x4396dc[_0x3d3aee(0xf0)](_0x52af58);}if(_0x3e0e6a['pendingFolderRename']){const _0x542963=_0x3e0e6a[_0x3d3aee(0x17e)],_0x491020={};_0x491020[_0x3d3aee(0x150)]=_0x542963;const _0x5dd23d={};_0x5dd23d[_0x3d3aee(0xf6)]=_0x3e0e6a[_0x3d3aee(0x12d)],_0x5dd23d[_0x3d3aee(0x11b)]=_0x491020,await exports[_0x3d3aee(0x13f)][_0x3d3aee(0xd7)][_0x3d3aee(0xff)](_0x5dd23d),_0x3e0e6a[_0x3d3aee(0x17e)]=undefined;}const _0x99a8fd={};_0x99a8fd['q']='\x27'+_0x3e0e6a[_0x3d3aee(0x12d)]+'\x27\x20in\x20parents\x20and\x20name\x20=\x20\x27database.json\x27\x20and\x20trashed\x20=\x20false',_0x99a8fd['fields']=_0x3d3aee(0x152);const _0x1a2b59=await exports[_0x3d3aee(0x13f)]['files'][_0x3d3aee(0x1b2)](_0x99a8fd),_0x5cf1b7=_0x1a2b59[_0x3d3aee(0x14e)]['files']?.[0x0]?.['id'];if(!_0x5cf1b7){const _0x3a3b1f={};_0x3a3b1f[_0x3d3aee(0x150)]=_0x4396dc[_0x3d3aee(0x131)],_0x3a3b1f[_0x3d3aee(0x1a2)]=[_0x3e0e6a['folderId']],await exports[_0x3d3aee(0x13f)][_0x3d3aee(0xd7)]['create']({'requestBody':_0x3a3b1f,'media':{'mimeType':_0x4396dc[_0x3d3aee(0x17c)],'body':JSON[_0x3d3aee(0xf1)](_0x3e0e6a[_0x3d3aee(0x14e)],null,0x2)}});}else await exports['drive'][_0x3d3aee(0xd7)][_0x3d3aee(0xff)]({'fileId':_0x5cf1b7,'media':{'mimeType':_0x4396dc[_0x3d3aee(0x17c)],'body':JSON['stringify'](_0x3e0e6a[_0x3d3aee(0x14e)],null,0x2)}});_0x3e0e6a[_0x3d3aee(0x175)]=![];}let syncing=![];async function syncDirtyToDrive(){const _0x59087a=_0x53de73,_0x56a6a1={'kcFoH':_0x59087a(0xde),'YHoFz':function(_0x3ad962,_0x2971ca){return _0x3ad962===_0x2971ca;},'CbtzA':_0x59087a(0x197),'FStlp':function(_0x3dd68f,_0x682715){return _0x3dd68f(_0x682715);},'PacgB':_0x59087a(0x123)};if(syncing)return;syncing=!![];try{if(_0x59087a(0x1c0)!=='dXuzX')return[];else{const _0x1890e7=Array[_0x59087a(0x1b7)](cache['values']())[_0x59087a(0x125)](_0x597f9d=>_0x597f9d['dirty']||_0x597f9d[_0x59087a(0x190)]||_0x597f9d['pendingDelete']||_0x597f9d[_0x59087a(0x17e)]);if(_0x56a6a1[_0x59087a(0xf3)](_0x1890e7[_0x59087a(0x161)],0x0))return;console['log'](_0x59087a(0x11a)+_0x1890e7['length']+_0x59087a(0x14a));for(const _0x4b03a6 of _0x1890e7){if(_0x56a6a1[_0x59087a(0xf3)]('jMBJG',_0x56a6a1[_0x59087a(0x173)]))try{await _0x56a6a1[_0x59087a(0x13c)](flushEntry,_0x4b03a6);}catch(_0x4cff08){console[_0x59087a(0x185)]('[sync]\x20failed\x20for\x20'+_0x4b03a6[_0x59087a(0x14e)][_0x59087a(0x142)]+':',_0x4cff08?.['message']);}else{const _0x183723=_0x442e3b[_0x59087a(0x1be)][_0x59087a(0x1cc)](_0x39e64a,_0x59087a(0x1b3)),_0x30961a=_0x224e27['parse'](_0x183723);for(const [_0x2e3b7f,_0x3c7a4c]of _0x225faf[_0x59087a(0xcb)](_0x30961a)){_0x1a3b3b[_0x59087a(0x1a5)](_0x2e3b7f,_0x3c7a4c);if(_0x3c7a4c['folderId'])_0x141f2a[_0x59087a(0x1a5)](_0x3c7a4c[_0x59087a(0x12d)],_0x2e3b7f);}_0x30780d(),_0x4d7b80['default'][_0x59087a(0x179)](_0xf44b2f),_0x4389d9[_0x59087a(0x16d)](_0x59087a(0x17b)+_0x13f926[_0x59087a(0x139)]+_0x59087a(0x157));}}persistLocalSync();}}finally{_0x56a6a1['YHoFz'](_0x56a6a1['PacgB'],_0x56a6a1[_0x59087a(0x1bb)])?syncing=![]:_0x3dae5e[_0x59087a(0x185)](_0x56a6a1[_0x59087a(0x174)],_0x48c184?.['message']);}}let syncTimer=null;function startBackgroundSync(_0xe84e2c=0xea60){const _0x5de225=_0x53de73,_0x317340={'VWgVi':function(_0x46f443,_0xa6cef6,_0x2fd198){return _0x46f443(_0xa6cef6,_0x2fd198);}};if(syncTimer)return;syncTimer=_0x317340[_0x5de225(0x146)](setInterval,()=>{const _0x400c50=_0x5de225;syncDirtyToDrive()['catch'](_0x48386c=>console['error'](_0x400c50(0x1a7),_0x48386c?.[_0x400c50(0xdb)]));},_0xe84e2c),console[_0x5de225(0x16d)](_0x5de225(0x119)+_0xe84e2c+_0x5de225(0x198));}async function initLocalCache(){const _0x3af113=_0x53de73,_0x18a670={'OpWBJ':function(_0x5c4448){return _0x5c4448();},'RefVM':function(_0x41a2e1){return _0x41a2e1();},'HjYOS':function(_0x39ac43,_0x447bdd){return _0x39ac43(_0x447bdd);}};_0x18a670[_0x3af113(0x11d)](ensureLocalDir),_0x18a670[_0x3af113(0x141)](loadLocalSync),await _0x18a670[_0x3af113(0x141)](restoreFromDrive),_0x18a670[_0x3af113(0x1c6)](startBackgroundSync,0xea60);}async function getUserFolder(_0x4c4818){const _0x58bb36=_0x53de73,_0x27c40b=cache['get'](_0x4c4818);return _0x27c40b?_0x27c40b[_0x58bb36(0x12d)]:null;}async function getUserDbFileId(_0x528eb4){const _0x3520ab=_0x53de73,_0x38711b={};_0x38711b['q']='\x27'+_0x528eb4+_0x3520ab(0x106),_0x38711b[_0x3520ab(0x19d)]=_0x3520ab(0x152);const _0x947dd9=await exports[_0x3520ab(0x13f)]['files'][_0x3520ab(0x1b2)](_0x38711b);return _0x947dd9[_0x3520ab(0x14e)]['files']?.[0x0]?.['id']??null;}async function readUserDb(_0x2f4054){const _0x736bc6=_0x53de73,_0x1f2d52=findByFolderId(_0x2f4054);return _0x1f2d52?{..._0x1f2d52[_0x736bc6(0x14e)]}:null;}async function writeUserDb(_0xd2d93c,_0x4458b6){const _0x433a4a=_0x53de73,_0x164bb2={'rgQpZ':function(_0x824869){return _0x824869();},'uDxTw':function(_0x47dc7d){return _0x47dc7d();},'HcCeC':function(_0x476e09,_0x57ee8a){return _0x476e09(_0x57ee8a);},'ohldq':function(_0x352f05,_0x15f029){return _0x352f05!==_0x15f029;},'aKIRf':_0x433a4a(0x13a),'zGNwE':function(_0x8df729,_0x2ef55c){return _0x8df729!==_0x2ef55c;},'StxnM':_0x433a4a(0x1ae),'rKDhT':'svMqr','GKQuv':function(_0x56fbab,_0x1fe109){return _0x56fbab(_0x1fe109);},'iknix':function(_0x146dbf){return _0x146dbf();}};let _0x57ef98=_0x164bb2[_0x433a4a(0xea)](findByFolderId,_0xd2d93c);if(!_0x57ef98){if('Avdru'===_0x433a4a(0x14f))_0x2cefd2[_0x433a4a(0x1c7)](_0x350db7);else{const _0x29b31d={};_0x29b31d[_0x433a4a(0x12d)]=_0xd2d93c,_0x29b31d[_0x433a4a(0x14e)]=_0x4458b6,_0x29b31d[_0x433a4a(0x175)]=!![],_0x57ef98=_0x29b31d,setEntry(_0x57ef98);}}else{if(_0x164bb2[_0x433a4a(0xf8)](_0x164bb2['aKIRf'],'KGupZ')){const _0xde1ce3=_0x57ef98[_0x433a4a(0x14e)][_0x433a4a(0x142)];_0x57ef98[_0x433a4a(0x14e)]=_0x4458b6,_0x57ef98[_0x433a4a(0x175)]=!![];if(_0x164bb2[_0x433a4a(0x11f)](_0xde1ce3,_0x4458b6[_0x433a4a(0x142)])){if(_0x164bb2[_0x433a4a(0x147)]!==_0x164bb2[_0x433a4a(0x13b)])cache[_0x433a4a(0x1c7)](_0xde1ce3);else{_0x2589ca[_0x433a4a(0x1a5)](_0x513f2c,_0x19dd43);if(_0x528eb8[_0x433a4a(0x12d)])_0x2ed523[_0x433a4a(0x1a5)](_0x5b8ba8['folderId'],_0x33125e);}}_0x164bb2[_0x433a4a(0x116)](setEntry,_0x57ef98);}else{try{_0x164bb2['rgQpZ'](_0x3f7653);}catch{}_0x164bb2[_0x433a4a(0x137)](_0x26eb61)[_0x433a4a(0x127)](()=>{});}}_0x164bb2['iknix'](persistLocalSync);}async function deleteUserFolder(_0xcaad3){const _0x1056b1=_0x53de73,_0x4e9823={'FMHim':function(_0x41fb02,_0x1bf027){return _0x41fb02===_0x1bf027;},'NaGnj':_0x1056b1(0x18b),'BpDLy':'ALqwY','sQrfb':'EYbYt','LTwTz':function(_0x385a19,_0x737638){return _0x385a19(_0x737638);},'gQFZE':_0x1056b1(0x1bd),'qqFoR':function(_0x228180,_0x517264){return _0x228180!==_0x517264;}},_0x4b0996=_0x4e9823[_0x1056b1(0x1ba)](findByFolderId,_0xcaad3);if(_0x4b0996)_0x4b0996[_0x1056b1(0xd9)]=!![],cache[_0x1056b1(0x1c7)](_0x4b0996[_0x1056b1(0x14e)][_0x1056b1(0x142)]),folderIndex['delete'](_0x4b0996[_0x1056b1(0x12d)]),cache['set'](_0x1056b1(0xd4)+_0x4b0996['folderId'],_0x4b0996),setImmediate(()=>{const _0x2545fb=_0x1056b1;if(_0x4e9823[_0x2545fb(0x15c)](_0x4e9823[_0x2545fb(0x19c)],_0x4e9823[_0x2545fb(0x19c)])){try{_0x4e9823[_0x2545fb(0xee)]!==_0x4e9823[_0x2545fb(0x16c)]?persistLocalSync():_0xd51ce6[_0x2545fb(0x185)](_0x2545fb(0xf2)+_0x3c0bab[_0x2545fb(0x150)]+':',_0x12204b?.['message']);}catch{}syncDirtyToDrive()[_0x2545fb(0x127)](()=>{});}else{if(_0x2fa01f?.[_0x2545fb(0x1c9)]!==0x194)throw _0x5a4cd4;}});else try{const _0xcf42ba={};_0xcf42ba['fileId']=_0xcaad3,await exports[_0x1056b1(0x13f)][_0x1056b1(0xd7)][_0x1056b1(0x1c7)](_0xcf42ba);}catch(_0x2bab62){if(_0x4e9823[_0x1056b1(0xfc)]!==_0x4e9823[_0x1056b1(0xfc)])return[];else{if(_0x4e9823['qqFoR'](_0x2bab62?.[_0x1056b1(0x1c9)],0x194))throw _0x2bab62;}}}async function registerUserToDrive(_0xea2540,_0x33e678,_0x467519){const _0x5c9c82=_0x53de73,_0x3349d5={'cRSYW':function(_0x4f91eb,_0x36f6ce){return _0x4f91eb(_0x36f6ce);},'DVEoJ':function(_0x2392b5,_0x152017){return _0x2392b5!==_0x152017;},'fQrYo':function(_0x30c392){return _0x30c392();},'YFecz':function(_0x1fb877,_0x302359){return _0x1fb877===_0x302359;},'xpVEZ':_0x5c9c82(0x115),'zTCTW':function(_0x67e8d,_0x3318a4){return _0x67e8d<_0x3318a4;},'hyJvw':'pending:','oSnSa':function(_0x5898ff,_0x5d1c38){return _0x5898ff===_0x5d1c38;},'cqYuT':_0x5c9c82(0x16e),'rcokk':_0x5c9c82(0xe3),'loIyJ':_0x5c9c82(0xdc),'HsSip':'cover.png','pYrIA':_0x5c9c82(0x1a6),'bdnGy':function(_0x12b55f){return _0x12b55f();},'NfREf':_0x5c9c82(0x148),'tQlBA':function(_0x2b40ad,_0x213235){return _0x2b40ad||_0x213235;},'OIjGY':function(_0x2e6ce8,_0x47595f){return _0x2e6ce8===_0x47595f;},'XVVuA':_0x5c9c82(0x176),'csUON':function(_0x521b53){return _0x521b53();}};if(cache[_0x5c9c82(0x1b0)](_0xea2540[_0x5c9c82(0x142)]))throw new Error(_0x3349d5['NfREf']);const _0xa61b1d='pending:'+_0xea2540[_0x5c9c82(0x142)]+':'+Date['now'](),_0x43340f={};_0x43340f['folderId']=_0xa61b1d,_0x43340f[_0x5c9c82(0x14e)]=_0xea2540,_0x43340f['dirty']=!![],_0x43340f[_0x5c9c82(0x190)]=!![],setEntry(_0x43340f),_0x3349d5[_0x5c9c82(0xcd)](persistLocalSync);_0x3349d5[_0x5c9c82(0xd5)](_0x33e678,_0x467519)&&(_0x3349d5[_0x5c9c82(0x193)](_0x3349d5['XVVuA'],_0x3349d5['XVVuA'])?((async()=>{const _0x47c84d=_0x5c9c82;if(_0x3349d5[_0x47c84d(0x158)](_0x3349d5[_0x47c84d(0x195)],_0x47c84d(0x1af))){let _0x59b52b=_0x3349d5[_0x47c84d(0x14c)](_0x136007,_0x19e9cf);if(!_0x59b52b){const _0x3341ce={};_0x3341ce[_0x47c84d(0x12d)]=_0x19e9dc,_0x3341ce[_0x47c84d(0x14e)]=_0x4674b0,_0x3341ce[_0x47c84d(0x175)]=!![],_0x59b52b=_0x3341ce,_0x3349d5[_0x47c84d(0x14c)](_0x1ee0c3,_0x59b52b);}else{const _0x348fc5=_0x59b52b[_0x47c84d(0x14e)][_0x47c84d(0x142)];_0x59b52b[_0x47c84d(0x14e)]=_0x5d82f9,_0x59b52b[_0x47c84d(0x175)]=!![],_0x3349d5[_0x47c84d(0x178)](_0x348fc5,_0x3d500f[_0x47c84d(0x142)])&&_0x2e19eb[_0x47c84d(0x1c7)](_0x348fc5),_0x4d6ab0(_0x59b52b);}_0x3349d5[_0x47c84d(0x13e)](_0x2380e3);}else{for(let _0x329e5b=0x0;_0x3349d5[_0x47c84d(0x1bc)](_0x329e5b,0x1e);_0x329e5b++){const _0x216ffa=cache['get'](_0xea2540[_0x47c84d(0x142)]);if(_0x216ffa&&!_0x216ffa[_0x47c84d(0x190)]&&!_0x216ffa[_0x47c84d(0x12d)][_0x47c84d(0xc4)](_0x3349d5[_0x47c84d(0x1b6)])){try{if(_0x3349d5['oSnSa'](_0x3349d5[_0x47c84d(0x1aa)],_0x3349d5[_0x47c84d(0xd2)]))return _0x206ca5['default']['readdirSync'](_0x3b5e7b)['filter'](_0x523c4b=>/^exocore-database.*\.json$/['test'](_0x523c4b))[_0x47c84d(0x120)](_0x3bd6a5=>_0x13a69b[_0x47c84d(0x1be)]['join'](_0x3ec857,_0x3bd6a5));else{if(_0x33e678)await uploadImagePublic(_0x216ffa['folderId'],_0x3349d5[_0x47c84d(0x18a)],_0x33e678);if(_0x467519)await uploadImagePublic(_0x216ffa[_0x47c84d(0x12d)],_0x3349d5[_0x47c84d(0x134)],_0x467519);}}catch(_0x2b08f1){console['error'](_0x47c84d(0x19a),_0x2b08f1?.[_0x47c84d(0xdb)]);}return;}await new Promise(_0x46e5fa=>setTimeout(_0x46e5fa,0x7d0));}console[_0x47c84d(0x17f)](_0x47c84d(0x16b)+_0xea2540[_0x47c84d(0x142)]+_0x47c84d(0xe7));}})()):(0x0,_0x15d453[_0x5c9c82(0x122)])({'localDir':_0x3ccaef,'encName':_0x3349d5[_0x5c9c82(0x1b4)],'legacyPaths':_0x3349d5[_0x5c9c82(0xcd)](_0x59f78f)}));_0x3349d5['csUON'](syncDirtyToDrive)[_0x5c9c82(0x127)](()=>{});const _0xe147={};return _0xe147[_0x5c9c82(0x12a)]=!![],_0xe147;}async function getAllUsers(){const _0x1f0094=_0x53de73,_0x22623f={'nwTTl':function(_0x26a73a){return _0x26a73a();},'OfdxM':function(_0x1f1e97,_0x3c34c3){return _0x1f1e97!==_0x3c34c3;},'ZxTGz':_0x1f0094(0x156)},_0x57f814=[];for(const _0x1f14a1 of cache[_0x1f0094(0x1ca)]()){if(_0x22623f[_0x1f0094(0x1c3)](_0x22623f['ZxTGz'],_0x1f0094(0x156)))return!_0x4fc041&&(_0x22623f[_0x1f0094(0x118)](_0x9f36bf),_0x4f0c40=new _0x3ae61b[(_0x1f0094(0xeb))](_0x4fccef)),_0x6a0e9c;else{if(_0x1f14a1[_0x1f0094(0xd9)])continue;const _0x3a2238={..._0x1f14a1[_0x1f0094(0x14e)]};_0x57f814[_0x1f0094(0x1b5)](_0x3a2238);}}return _0x57f814;}async function getProfileImages(_0x13dfb0){const _0x33b825=_0x53de73,_0x16af17={};_0x16af17[_0x33b825(0xef)]='avatar.png',_0x16af17[_0x33b825(0x181)]=function(_0x21b109,_0x1a3063){return _0x21b109===_0x1a3063;},_0x16af17[_0x33b825(0x1a8)]=_0x33b825(0x10b);const _0x26cba1=_0x16af17;if(_0x13dfb0['startsWith'](_0x33b825(0x1ac))){const _0x35aba8={};return _0x35aba8[_0x33b825(0x160)]=null,_0x35aba8['coverUrl']=null,_0x35aba8;}try{const _0x2ef4c6={};_0x2ef4c6['q']='\x27'+_0x13dfb0+'\x27\x20in\x20parents\x20and\x20(name\x20=\x20\x27avatar.png\x27\x20or\x20name\x20=\x20\x27cover.png\x27)\x20and\x20trashed\x20=\x20false',_0x2ef4c6[_0x33b825(0x19d)]=_0x33b825(0xc8);const _0x42413b=await exports['drive']['files'][_0x33b825(0x1b2)](_0x2ef4c6),_0x3cd65d={};_0x3cd65d[_0x33b825(0x160)]=null,_0x3cd65d[_0x33b825(0x10a)]=null;const _0x2362e0=_0x3cd65d;for(const _0x40c48f of _0x42413b[_0x33b825(0x14e)][_0x33b825(0xd7)]??[]){const _0x50c7e7='https://drive.google.com/thumbnail?id='+_0x40c48f['id']+_0x33b825(0x132);if(_0x40c48f[_0x33b825(0x150)]===_0x26cba1['tIukn'])_0x2362e0[_0x33b825(0x160)]=_0x50c7e7;if(_0x26cba1[_0x33b825(0x181)](_0x40c48f[_0x33b825(0x150)],_0x26cba1[_0x33b825(0x1a8)]))_0x2362e0[_0x33b825(0x10a)]=_0x50c7e7;}return _0x2362e0;}catch(_0x5d964b){console['error'](_0x33b825(0x117),_0x5d964b?.['message']);const _0x1376ba={};return _0x1376ba[_0x33b825(0x160)]=null,_0x1376ba['coverUrl']=null,_0x1376ba;}}function isCacheReady(){return restored;}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
| 3 |
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
| 4 |
+
};
|
| 5 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
| 6 |
+
exports.ROOT_PARENT = exports.oAuth2Client = exports.drive = void 0;
|
| 7 |
+
exports.bufferToStream = bufferToStream;
|
| 8 |
+
exports.getOrCreateFolder = getOrCreateFolder;
|
| 9 |
+
exports.getUsersFolderId = getUsersFolderId;
|
| 10 |
+
exports.uploadImagePublic = uploadImagePublic;
|
| 11 |
+
exports.restoreFromDrive = restoreFromDrive;
|
| 12 |
+
exports.syncDirtyToDrive = syncDirtyToDrive;
|
| 13 |
+
exports.startBackgroundSync = startBackgroundSync;
|
| 14 |
+
exports.initLocalCache = initLocalCache;
|
| 15 |
+
exports.getUserFolder = getUserFolder;
|
| 16 |
+
exports.getUserDbFileId = getUserDbFileId;
|
| 17 |
+
exports.readUserDb = readUserDb;
|
| 18 |
+
exports.writeUserDb = writeUserDb;
|
| 19 |
+
exports.deleteUserFolder = deleteUserFolder;
|
| 20 |
+
exports.registerUserToDrive = registerUserToDrive;
|
| 21 |
+
exports.getAllUsers = getAllUsers;
|
| 22 |
+
exports.getProfileImages = getProfileImages;
|
| 23 |
+
exports.isCacheReady = isCacheReady;
|
| 24 |
+
const googleapis_1 = require("googleapis");
|
| 25 |
+
const stream_1 = require("stream");
|
| 26 |
+
const path_1 = __importDefault(require("path"));
|
| 27 |
+
const fs_1 = __importDefault(require("fs"));
|
| 28 |
+
const secureStore_1 = require("./secureStore");
|
| 29 |
+
const credStore_1 = require("./credStore");
|
| 30 |
+
const PROJECT_ROOT = path_1.default.join(__dirname, "../..");
|
| 31 |
+
const LOCAL_DB_DIR = path_1.default.join(PROJECT_ROOT, "local-db");
|
| 32 |
+
// Find any legacy `client_secret_*.json` if present (before migration).
|
| 33 |
+
function findClientSecretLegacy() {
|
| 34 |
+
try {
|
| 35 |
+
return fs_1.default.readdirSync(PROJECT_ROOT)
|
| 36 |
+
.filter(f => f.startsWith("client_secret_") && f.endsWith(".json"))
|
| 37 |
+
.map(f => path_1.default.join(PROJECT_ROOT, f));
|
| 38 |
+
}
|
| 39 |
+
catch {
|
| 40 |
+
return [];
|
| 41 |
+
}
|
| 42 |
+
}
|
| 43 |
+
function findServiceAccountLegacy() {
|
| 44 |
+
try {
|
| 45 |
+
return fs_1.default.readdirSync(PROJECT_ROOT)
|
| 46 |
+
.filter(f => /^exocore-database.*\.json$/.test(f))
|
| 47 |
+
.map(f => path_1.default.join(PROJECT_ROOT, f));
|
| 48 |
+
}
|
| 49 |
+
catch {
|
| 50 |
+
return [];
|
| 51 |
+
}
|
| 52 |
+
}
|
| 53 |
+
const credentials = (0, credStore_1.loadEncryptedJson)({
|
| 54 |
+
localDir: LOCAL_DB_DIR,
|
| 55 |
+
encName: "client_secret.enc",
|
| 56 |
+
legacyPaths: findClientSecretLegacy(),
|
| 57 |
+
});
|
| 58 |
+
const token = (0, credStore_1.loadEncryptedJson)({
|
| 59 |
+
localDir: LOCAL_DB_DIR,
|
| 60 |
+
encName: "token.enc",
|
| 61 |
+
legacyPaths: [path_1.default.join(PROJECT_ROOT, "token.json")],
|
| 62 |
+
});
|
| 63 |
+
// Optional service-account credential (not required by the OAuth flow but
|
| 64 |
+
// migrated/encrypted so it never sits as plaintext on disk).
|
| 65 |
+
try {
|
| 66 |
+
(0, credStore_1.loadEncryptedJson)({
|
| 67 |
+
localDir: LOCAL_DB_DIR,
|
| 68 |
+
encName: "service_account.enc",
|
| 69 |
+
legacyPaths: findServiceAccountLegacy(),
|
| 70 |
+
});
|
| 71 |
+
}
|
| 72 |
+
catch { /* optional */ }
|
| 73 |
+
const installed = credentials.installed || credentials.web;
|
| 74 |
+
const oAuth2Client = new googleapis_1.google.auth.OAuth2(installed.client_id, installed.client_secret, installed.redirect_uris[0]);
|
| 75 |
+
exports.oAuth2Client = oAuth2Client;
|
| 76 |
+
oAuth2Client.setCredentials(token);
|
| 77 |
+
exports.drive = googleapis_1.google.drive({ version: "v3", auth: oAuth2Client });
|
| 78 |
+
exports.ROOT_PARENT = "101XiYAWaQf4AALw77KbpMT6o4GtlmZGJ";
|
| 79 |
+
function bufferToStream(buffer) {
|
| 80 |
+
const s = new stream_1.Readable();
|
| 81 |
+
s.push(buffer);
|
| 82 |
+
s.push(null);
|
| 83 |
+
return s;
|
| 84 |
+
}
|
| 85 |
+
async function getOrCreateFolder(name, parentId) {
|
| 86 |
+
let q = `name = '${name}' and mimeType = 'application/vnd.google-apps.folder' and trashed = false`;
|
| 87 |
+
if (parentId)
|
| 88 |
+
q += ` and '${parentId}' in parents`;
|
| 89 |
+
const res = await exports.drive.files.list({ q, fields: "files(id, name)" });
|
| 90 |
+
if (res.data.files && res.data.files.length > 0)
|
| 91 |
+
return res.data.files[0].id;
|
| 92 |
+
const created = await exports.drive.files.create({
|
| 93 |
+
requestBody: {
|
| 94 |
+
name,
|
| 95 |
+
mimeType: "application/vnd.google-apps.folder",
|
| 96 |
+
parents: parentId ? [parentId] : [],
|
| 97 |
+
},
|
| 98 |
+
fields: "id",
|
| 99 |
+
});
|
| 100 |
+
return created.data.id;
|
| 101 |
+
}
|
| 102 |
+
async function getUsersFolderId() {
|
| 103 |
+
const root = await getOrCreateFolder("EXOCORE", exports.ROOT_PARENT);
|
| 104 |
+
const cli = await getOrCreateFolder("exocore-cli", root);
|
| 105 |
+
return await getOrCreateFolder("users", cli);
|
| 106 |
+
}
|
| 107 |
+
async function uploadImagePublic(folderId, name, buffer) {
|
| 108 |
+
if (!buffer)
|
| 109 |
+
return null;
|
| 110 |
+
const created = await exports.drive.files.create({
|
| 111 |
+
requestBody: { name, parents: [folderId] },
|
| 112 |
+
media: { mimeType: "image/png", body: bufferToStream(buffer) },
|
| 113 |
+
fields: "id",
|
| 114 |
+
});
|
| 115 |
+
const fileId = created.data.id;
|
| 116 |
+
await exports.drive.permissions.create({
|
| 117 |
+
fileId,
|
| 118 |
+
requestBody: { role: "reader", type: "anyone" },
|
| 119 |
+
});
|
| 120 |
+
return fileId;
|
| 121 |
+
}
|
| 122 |
+
const LOCAL_DIR = path_1.default.join(__dirname, "../../local-db");
|
| 123 |
+
// Encrypted at rest: AES-256-GCM ⊕ XChaCha20-Poly1305. Plain JSON is never
|
| 124 |
+
// written to disk. The legacy `users.json` file is migrated + deleted on boot.
|
| 125 |
+
const LOCAL_FILE = path_1.default.join(LOCAL_DIR, "users.enc");
|
| 126 |
+
const LEGACY_FILE = path_1.default.join(LOCAL_DIR, "users.json");
|
| 127 |
+
const cache = new Map(); // by username
|
| 128 |
+
const folderIndex = new Map(); // folderId -> username
|
| 129 |
+
let restored = false;
|
| 130 |
+
let secure = null;
|
| 131 |
+
function ensureLocalDir() {
|
| 132 |
+
if (!fs_1.default.existsSync(LOCAL_DIR))
|
| 133 |
+
fs_1.default.mkdirSync(LOCAL_DIR, { recursive: true });
|
| 134 |
+
}
|
| 135 |
+
function getSecure() {
|
| 136 |
+
if (!secure) {
|
| 137 |
+
ensureLocalDir();
|
| 138 |
+
secure = new secureStore_1.SecureStore(LOCAL_DIR);
|
| 139 |
+
}
|
| 140 |
+
return secure;
|
| 141 |
+
}
|
| 142 |
+
function persistLocalSync() {
|
| 143 |
+
try {
|
| 144 |
+
ensureLocalDir();
|
| 145 |
+
const obj = {};
|
| 146 |
+
for (const [k, v] of cache)
|
| 147 |
+
obj[k] = v;
|
| 148 |
+
const blob = getSecure().encrypt(JSON.stringify(obj));
|
| 149 |
+
fs_1.default.writeFileSync(LOCAL_FILE, blob, { mode: 0o600 });
|
| 150 |
+
}
|
| 151 |
+
catch (e) {
|
| 152 |
+
console.error("[cache] persistLocal failed:", e?.message);
|
| 153 |
+
}
|
| 154 |
+
}
|
| 155 |
+
function loadLocalSync() {
|
| 156 |
+
try {
|
| 157 |
+
// Migrate legacy plaintext snapshot if present, then remove it.
|
| 158 |
+
if (fs_1.default.existsSync(LEGACY_FILE)) {
|
| 159 |
+
try {
|
| 160 |
+
const raw = fs_1.default.readFileSync(LEGACY_FILE, "utf-8");
|
| 161 |
+
const obj = JSON.parse(raw);
|
| 162 |
+
for (const [k, v] of Object.entries(obj)) {
|
| 163 |
+
cache.set(k, v);
|
| 164 |
+
if (v.folderId)
|
| 165 |
+
folderIndex.set(v.folderId, k);
|
| 166 |
+
}
|
| 167 |
+
persistLocalSync();
|
| 168 |
+
fs_1.default.unlinkSync(LEGACY_FILE);
|
| 169 |
+
console.log(`[cache] migrated ${cache.size} users from legacy plaintext snapshot → encrypted`);
|
| 170 |
+
}
|
| 171 |
+
catch (e) {
|
| 172 |
+
console.error("[cache] legacy migration failed:", e?.message);
|
| 173 |
+
}
|
| 174 |
+
}
|
| 175 |
+
if (!fs_1.default.existsSync(LOCAL_FILE))
|
| 176 |
+
return;
|
| 177 |
+
const blob = fs_1.default.readFileSync(LOCAL_FILE);
|
| 178 |
+
const json = getSecure().decrypt(blob);
|
| 179 |
+
const obj = JSON.parse(json);
|
| 180 |
+
cache.clear();
|
| 181 |
+
folderIndex.clear();
|
| 182 |
+
for (const [k, v] of Object.entries(obj)) {
|
| 183 |
+
cache.set(k, v);
|
| 184 |
+
if (v.folderId)
|
| 185 |
+
folderIndex.set(v.folderId, k);
|
| 186 |
+
}
|
| 187 |
+
console.log(`[cache] loaded ${cache.size} users from encrypted local snapshot`);
|
| 188 |
+
}
|
| 189 |
+
catch (e) {
|
| 190 |
+
console.error("[cache] loadLocal failed:", e?.message);
|
| 191 |
+
}
|
| 192 |
+
}
|
| 193 |
+
function setEntry(entry) {
|
| 194 |
+
cache.set(entry.data.username, entry);
|
| 195 |
+
folderIndex.set(entry.folderId, entry.data.username);
|
| 196 |
+
}
|
| 197 |
+
function findByFolderId(folderId) {
|
| 198 |
+
const username = folderIndex.get(folderId);
|
| 199 |
+
if (!username)
|
| 200 |
+
return undefined;
|
| 201 |
+
return cache.get(username);
|
| 202 |
+
}
|
| 203 |
+
async function restoreFromDrive() {
|
| 204 |
+
console.log("[cache] restoring from Drive…");
|
| 205 |
+
const t0 = Date.now();
|
| 206 |
+
try {
|
| 207 |
+
const usersFolderId = await getUsersFolderId();
|
| 208 |
+
const folderRes = await exports.drive.files.list({
|
| 209 |
+
q: `'${usersFolderId}' in parents and mimeType = 'application/vnd.google-apps.folder' and trashed = false`,
|
| 210 |
+
fields: "files(id, name)",
|
| 211 |
+
pageSize: 1000,
|
| 212 |
+
});
|
| 213 |
+
const fresh = new Map();
|
| 214 |
+
const freshIndex = new Map();
|
| 215 |
+
for (const folder of folderRes.data.files ?? []) {
|
| 216 |
+
try {
|
| 217 |
+
const dbList = await exports.drive.files.list({
|
| 218 |
+
q: `'${folder.id}' in parents and name = 'database.json' and trashed = false`,
|
| 219 |
+
fields: "files(id)",
|
| 220 |
+
});
|
| 221 |
+
const fileId = dbList.data.files?.[0]?.id;
|
| 222 |
+
if (!fileId)
|
| 223 |
+
continue;
|
| 224 |
+
const r = await exports.drive.files.get({ fileId, alt: "media" });
|
| 225 |
+
const data = r.data;
|
| 226 |
+
if (!data?.username)
|
| 227 |
+
continue;
|
| 228 |
+
fresh.set(data.username, { folderId: folder.id, data });
|
| 229 |
+
freshIndex.set(folder.id, data.username);
|
| 230 |
+
}
|
| 231 |
+
catch (e) {
|
| 232 |
+
console.error(`[cache] failed to load ${folder.name}:`, e?.message);
|
| 233 |
+
}
|
| 234 |
+
}
|
| 235 |
+
// Preserve any locally-dirty entries that haven't synced yet.
|
| 236 |
+
for (const [username, entry] of cache) {
|
| 237 |
+
if (entry.dirty || entry.pendingCreate || entry.pendingDelete) {
|
| 238 |
+
fresh.set(username, entry);
|
| 239 |
+
if (entry.folderId)
|
| 240 |
+
freshIndex.set(entry.folderId, username);
|
| 241 |
+
}
|
| 242 |
+
}
|
| 243 |
+
cache.clear();
|
| 244 |
+
folderIndex.clear();
|
| 245 |
+
for (const [k, v] of fresh)
|
| 246 |
+
cache.set(k, v);
|
| 247 |
+
for (const [k, v] of freshIndex)
|
| 248 |
+
folderIndex.set(k, v);
|
| 249 |
+
persistLocalSync();
|
| 250 |
+
restored = true;
|
| 251 |
+
console.log(`[cache] restored ${cache.size} users in ${Date.now() - t0}ms`);
|
| 252 |
+
}
|
| 253 |
+
catch (e) {
|
| 254 |
+
console.error("[cache] restoreFromDrive failed:", e?.message);
|
| 255 |
+
}
|
| 256 |
+
}
|
| 257 |
+
async function flushEntry(entry) {
|
| 258 |
+
if (entry.pendingDelete) {
|
| 259 |
+
try {
|
| 260 |
+
await exports.drive.files.delete({ fileId: entry.folderId });
|
| 261 |
+
}
|
| 262 |
+
catch (e) {
|
| 263 |
+
// Folder may already be gone; ignore 404s.
|
| 264 |
+
if (e?.code !== 404)
|
| 265 |
+
throw e;
|
| 266 |
+
}
|
| 267 |
+
cache.delete(entry.data.username);
|
| 268 |
+
cache.delete(`__deleted__:${entry.folderId}`);
|
| 269 |
+
folderIndex.delete(entry.folderId);
|
| 270 |
+
return;
|
| 271 |
+
}
|
| 272 |
+
if (entry.pendingCreate) {
|
| 273 |
+
const usersFolderId = await getUsersFolderId();
|
| 274 |
+
const folderName = entry.data.username.replace(/@/g, "");
|
| 275 |
+
const folderId = await getOrCreateFolder(folderName, usersFolderId);
|
| 276 |
+
folderIndex.delete(entry.folderId);
|
| 277 |
+
entry.folderId = folderId;
|
| 278 |
+
folderIndex.set(folderId, entry.data.username);
|
| 279 |
+
await exports.drive.files.create({
|
| 280 |
+
requestBody: { name: "database.json", parents: [folderId] },
|
| 281 |
+
media: { mimeType: "application/json", body: JSON.stringify(entry.data, null, 2) },
|
| 282 |
+
});
|
| 283 |
+
entry.pendingCreate = false;
|
| 284 |
+
entry.dirty = false;
|
| 285 |
+
return;
|
| 286 |
+
}
|
| 287 |
+
if (entry.pendingFolderRename) {
|
| 288 |
+
const newName = entry.pendingFolderRename;
|
| 289 |
+
await exports.drive.files.update({ fileId: entry.folderId, requestBody: { name: newName } });
|
| 290 |
+
entry.pendingFolderRename = undefined;
|
| 291 |
+
}
|
| 292 |
+
// Update database.json
|
| 293 |
+
const list = await exports.drive.files.list({
|
| 294 |
+
q: `'${entry.folderId}' in parents and name = 'database.json' and trashed = false`,
|
| 295 |
+
fields: "files(id)",
|
| 296 |
+
});
|
| 297 |
+
const fileId = list.data.files?.[0]?.id;
|
| 298 |
+
if (!fileId) {
|
| 299 |
+
await exports.drive.files.create({
|
| 300 |
+
requestBody: { name: "database.json", parents: [entry.folderId] },
|
| 301 |
+
media: { mimeType: "application/json", body: JSON.stringify(entry.data, null, 2) },
|
| 302 |
+
});
|
| 303 |
+
}
|
| 304 |
+
else {
|
| 305 |
+
await exports.drive.files.update({
|
| 306 |
+
fileId,
|
| 307 |
+
media: { mimeType: "application/json", body: JSON.stringify(entry.data, null, 2) },
|
| 308 |
+
});
|
| 309 |
+
}
|
| 310 |
+
entry.dirty = false;
|
| 311 |
+
}
|
| 312 |
+
let syncing = false;
|
| 313 |
+
async function syncDirtyToDrive() {
|
| 314 |
+
if (syncing)
|
| 315 |
+
return;
|
| 316 |
+
syncing = true;
|
| 317 |
+
try {
|
| 318 |
+
const dirty = Array.from(cache.values()).filter(e => e.dirty || e.pendingCreate || e.pendingDelete || e.pendingFolderRename);
|
| 319 |
+
if (dirty.length === 0)
|
| 320 |
+
return;
|
| 321 |
+
console.log(`[sync] flushing ${dirty.length} dirty user(s) → Drive`);
|
| 322 |
+
for (const entry of dirty) {
|
| 323 |
+
try {
|
| 324 |
+
await flushEntry(entry);
|
| 325 |
+
}
|
| 326 |
+
catch (e) {
|
| 327 |
+
console.error(`[sync] failed for ${entry.data.username}:`, e?.message);
|
| 328 |
+
}
|
| 329 |
+
}
|
| 330 |
+
persistLocalSync();
|
| 331 |
+
}
|
| 332 |
+
finally {
|
| 333 |
+
syncing = false;
|
| 334 |
+
}
|
| 335 |
+
}
|
| 336 |
+
let syncTimer = null;
|
| 337 |
+
function startBackgroundSync(intervalMs = 60_000) {
|
| 338 |
+
if (syncTimer)
|
| 339 |
+
return;
|
| 340 |
+
syncTimer = setInterval(() => {
|
| 341 |
+
syncDirtyToDrive().catch(e => console.error("[sync] tick failed:", e?.message));
|
| 342 |
+
}, intervalMs);
|
| 343 |
+
console.log(`[sync] background sync started (every ${intervalMs}ms)`);
|
| 344 |
+
}
|
| 345 |
+
async function initLocalCache() {
|
| 346 |
+
ensureLocalDir();
|
| 347 |
+
loadLocalSync();
|
| 348 |
+
await restoreFromDrive();
|
| 349 |
+
startBackgroundSync(60_000);
|
| 350 |
+
}
|
| 351 |
+
// ============================================================================
|
| 352 |
+
// CACHE-BACKED PUBLIC API (drop-in replacements for the original Drive funcs)
|
| 353 |
+
// ============================================================================
|
| 354 |
+
async function getUserFolder(username) {
|
| 355 |
+
const entry = cache.get(username);
|
| 356 |
+
return entry ? entry.folderId : null;
|
| 357 |
+
}
|
| 358 |
+
async function getUserDbFileId(folderId) {
|
| 359 |
+
// Kept for backward-compat. Looks up the live Drive id (rare path).
|
| 360 |
+
const res = await exports.drive.files.list({
|
| 361 |
+
q: `'${folderId}' in parents and name = 'database.json' and trashed = false`,
|
| 362 |
+
fields: "files(id)",
|
| 363 |
+
});
|
| 364 |
+
return res.data.files?.[0]?.id ?? null;
|
| 365 |
+
}
|
| 366 |
+
async function readUserDb(folderId) {
|
| 367 |
+
const entry = findByFolderId(folderId);
|
| 368 |
+
return entry ? { ...entry.data } : null;
|
| 369 |
+
}
|
| 370 |
+
async function writeUserDb(folderId, data) {
|
| 371 |
+
let entry = findByFolderId(folderId);
|
| 372 |
+
if (!entry) {
|
| 373 |
+
entry = { folderId, data, dirty: true };
|
| 374 |
+
setEntry(entry);
|
| 375 |
+
}
|
| 376 |
+
else {
|
| 377 |
+
const oldUsername = entry.data.username;
|
| 378 |
+
entry.data = data;
|
| 379 |
+
entry.dirty = true;
|
| 380 |
+
if (oldUsername !== data.username) {
|
| 381 |
+
cache.delete(oldUsername);
|
| 382 |
+
}
|
| 383 |
+
setEntry(entry);
|
| 384 |
+
}
|
| 385 |
+
persistLocalSync();
|
| 386 |
+
}
|
| 387 |
+
async function deleteUserFolder(folderId) {
|
| 388 |
+
const entry = findByFolderId(folderId);
|
| 389 |
+
if (entry) {
|
| 390 |
+
// Mark for Drive deletion in the background sync, AND remove from the
|
| 391 |
+
// live in-memory index immediately so the user truly disappears from
|
| 392 |
+
// login/userinfo right away (don't wait for the next 60s tick).
|
| 393 |
+
entry.pendingDelete = true;
|
| 394 |
+
cache.delete(entry.data.username);
|
| 395 |
+
folderIndex.delete(entry.folderId);
|
| 396 |
+
// Re-insert under a hidden tombstone key so the sync loop can still find
|
| 397 |
+
// it and complete the Drive-side delete.
|
| 398 |
+
cache.set(`__deleted__:${entry.folderId}`, entry);
|
| 399 |
+
// Defer disk persist + Drive sync to the next tick so the HTTP response
|
| 400 |
+
// returns immediately (encryption + Drive call can be slow).
|
| 401 |
+
setImmediate(() => {
|
| 402 |
+
try {
|
| 403 |
+
persistLocalSync();
|
| 404 |
+
}
|
| 405 |
+
catch { }
|
| 406 |
+
syncDirtyToDrive().catch(() => { });
|
| 407 |
+
});
|
| 408 |
+
}
|
| 409 |
+
else {
|
| 410 |
+
// Not in cache; delete directly.
|
| 411 |
+
try {
|
| 412 |
+
await exports.drive.files.delete({ fileId: folderId });
|
| 413 |
+
}
|
| 414 |
+
catch (e) {
|
| 415 |
+
if (e?.code !== 404)
|
| 416 |
+
throw e;
|
| 417 |
+
}
|
| 418 |
+
}
|
| 419 |
+
}
|
| 420 |
+
async function registerUserToDrive(userData, avatarBuffer, coverBuffer) {
|
| 421 |
+
// Reject duplicates locally first.
|
| 422 |
+
if (cache.has(userData.username)) {
|
| 423 |
+
throw new Error("ALREADY_EXISTS");
|
| 424 |
+
}
|
| 425 |
+
// Stage in cache immediately so subsequent reads see the new user.
|
| 426 |
+
// We don't have a real folderId yet — use a placeholder that will be
|
| 427 |
+
// replaced once the background sync creates the Drive folder.
|
| 428 |
+
const placeholderFolderId = `pending:${userData.username}:${Date.now()}`;
|
| 429 |
+
setEntry({
|
| 430 |
+
folderId: placeholderFolderId,
|
| 431 |
+
data: userData,
|
| 432 |
+
dirty: true,
|
| 433 |
+
pendingCreate: true,
|
| 434 |
+
});
|
| 435 |
+
persistLocalSync();
|
| 436 |
+
// Best-effort: upload avatar / cover synchronously when provided. They are
|
| 437 |
+
// attached to the real Drive folder once the background sync creates it.
|
| 438 |
+
if (avatarBuffer || coverBuffer) {
|
| 439 |
+
(async () => {
|
| 440 |
+
// Wait briefly for the folder to be materialised on Drive.
|
| 441 |
+
for (let i = 0; i < 30; i++) {
|
| 442 |
+
const e = cache.get(userData.username);
|
| 443 |
+
if (e && !e.pendingCreate && !e.folderId.startsWith("pending:")) {
|
| 444 |
+
try {
|
| 445 |
+
if (avatarBuffer)
|
| 446 |
+
await uploadImagePublic(e.folderId, "avatar.png", avatarBuffer);
|
| 447 |
+
if (coverBuffer)
|
| 448 |
+
await uploadImagePublic(e.folderId, "cover.png", coverBuffer);
|
| 449 |
+
}
|
| 450 |
+
catch (err) {
|
| 451 |
+
console.error("[register] image upload failed:", err?.message);
|
| 452 |
+
}
|
| 453 |
+
return;
|
| 454 |
+
}
|
| 455 |
+
await new Promise(r => setTimeout(r, 2000));
|
| 456 |
+
}
|
| 457 |
+
console.warn(`[register] image upload skipped — folder for ${userData.username} not synced in time`);
|
| 458 |
+
})();
|
| 459 |
+
}
|
| 460 |
+
// Kick the sync immediately (don't await — caller stays fast).
|
| 461 |
+
syncDirtyToDrive().catch(() => { });
|
| 462 |
+
return { success: true };
|
| 463 |
+
}
|
| 464 |
+
async function getAllUsers() {
|
| 465 |
+
const out = [];
|
| 466 |
+
for (const entry of cache.values()) {
|
| 467 |
+
if (entry.pendingDelete)
|
| 468 |
+
continue;
|
| 469 |
+
out.push({ ...entry.data });
|
| 470 |
+
}
|
| 471 |
+
return out;
|
| 472 |
+
}
|
| 473 |
+
async function getProfileImages(folderId) {
|
| 474 |
+
// Image lookups still hit Drive directly (we don't cache binary assets).
|
| 475 |
+
if (folderId.startsWith("pending:")) {
|
| 476 |
+
return { avatarUrl: null, coverUrl: null };
|
| 477 |
+
}
|
| 478 |
+
try {
|
| 479 |
+
const res = await exports.drive.files.list({
|
| 480 |
+
q: `'${folderId}' in parents and (name = 'avatar.png' or name = 'cover.png') and trashed = false`,
|
| 481 |
+
fields: "files(id, name)",
|
| 482 |
+
});
|
| 483 |
+
const out = { avatarUrl: null, coverUrl: null };
|
| 484 |
+
for (const f of res.data.files ?? []) {
|
| 485 |
+
const url = `https://drive.google.com/thumbnail?id=${f.id}&sz=w1600`;
|
| 486 |
+
if (f.name === "avatar.png")
|
| 487 |
+
out.avatarUrl = url;
|
| 488 |
+
if (f.name === "cover.png")
|
| 489 |
+
out.coverUrl = url;
|
| 490 |
+
}
|
| 491 |
+
return out;
|
| 492 |
+
}
|
| 493 |
+
catch (e) {
|
| 494 |
+
console.error("[drive] getProfileImages failed:", e?.message);
|
| 495 |
+
return { avatarUrl: null, coverUrl: null };
|
| 496 |
+
}
|
| 497 |
+
}
|
| 498 |
+
function isCacheReady() {
|
| 499 |
+
return restored;
|
| 500 |
+
}
|
dist/services/mailer.js
CHANGED
|
@@ -1 +1,145 @@
|
|
| 1 |
-
const _0x321c4c=_0x33cc;(function(_0x16cb51,_0x6a6a86){const _0x2d9d70=_0x33cc,_0x6ca736=_0x16cb51();while(!![]){try{const _0x3c7e00=-parseInt(_0x2d9d70(0x150))/0x1+-parseInt(_0x2d9d70(0x146))/0x2+parseInt(_0x2d9d70(0x139))/0x3*(-parseInt(_0x2d9d70(0x161))/0x4)+-parseInt(_0x2d9d70(0x153))/0x5*(parseInt(_0x2d9d70(0x16b))/0x6)+-parseInt(_0x2d9d70(0x154))/0x7*(parseInt(_0x2d9d70(0x14d))/0x8)+parseInt(_0x2d9d70(0x165))/0x9+parseInt(_0x2d9d70(0x168))/0xa;if(_0x3c7e00===_0x6a6a86)break;else _0x6ca736['push'](_0x6ca736['shift']());}catch(_0xe5ee43){_0x6ca736['push'](_0x6ca736['shift']());}}}(_0x5a3c,0x2bc13));const _0x2b052f=(function(){const _0x60911=_0x33cc,_0x1d3ead={};_0x1d3ead[_0x60911(0x167)]=function(_0x404a7d,_0x503a7a){return _0x404a7d!==_0x503a7a;},_0x1d3ead['NkvBX']=_0x60911(0x16a);const _0xd1374a=_0x1d3ead;let _0x396fcd=!![];return function(_0x23110b,_0x4d9421){const _0x36e42d=_0x396fcd?function(){const _0x43ad74=_0x33cc;if(_0x4d9421){if(_0xd1374a[_0x43ad74(0x167)](_0xd1374a[_0x43ad74(0x136)],_0xd1374a['NkvBX'])){const _0x426ebf={};return _0x426ebf[_0x43ad74(0x13b)]=_0x5d5c02,_0x444b08&&_0x35ee26[_0x43ad74(0x13d)]?_0x5d9762:_0x426ebf;}else{const _0x1375d6=_0x4d9421[_0x43ad74(0x130)](_0x23110b,arguments);return _0x4d9421=null,_0x1375d6;}}}:function(){};return _0x396fcd=![],_0x36e42d;};}()),_0x17696a=_0x2b052f(this,function(){const _0x3fe813=_0x33cc,_0x4b83a9={};_0x4b83a9[_0x3fe813(0x13a)]=_0x3fe813(0x151);const _0x1e0192=_0x4b83a9;return _0x17696a[_0x3fe813(0x14b)]()[_0x3fe813(0x14a)](_0x3fe813(0x151))[_0x3fe813(0x14b)]()['constructor'](_0x17696a)[_0x3fe813(0x14a)](_0x1e0192[_0x3fe813(0x13a)]);});_0x17696a();function _0x5a3c(){const _0x462599=['DM1QCsbTDwnHigDREg4GzgrOBG','yxbWBhK','y29UBMvJDgLVBLrPBwvVDxq','zxHVy29YzwfPqgDTywLSlMnVBq','iKv4B2nVCMuIidW','C2vUze1HAwW','iIbZDhLSzt0IzgLZCgXHEtPPBMXPBMuTyMXVy2S7yMfJA2DYB3vUzdOJrKzfntaWo2nVBg9YoImWmda7CgfKzgLUzZOXnhb4idi4ChG7yM9YzgvYoJjWEcbZB2XPzcaJmdaWo2jVEc1ZAgfKB3C6nhb4idrWEcaWicmWmda7Dgv4Dc1KzwnVCMf0Aw9UoM5VBMu7zM9UDc13zwLNAhq6odaWo2XLDhrLCI1ZCgfJAw5NoI4WogvTo3rLEhqTDhjHBNnMB3jToNvWCgvYy2fZztTMB250lxnPEMu6mtnWEdSIpLzLCMLMEsbTEsbLBwfPBdWVyt4kicaGicaGica8l3a+cIaGicaGicaGphaGC3r5Bgu9iM1HCMDPBJOWo2nVBg9YoIm2nJy7zM9UDc1ZAxPLoJeYChG7BgLUzs1OzwLNAhq6ms42oYi+cIaGicaGicaGicbcDxr0B24GyNjVA2vUpYbdB3b5iczHBxa7ihbHC3rLihrOAxmGvvjmoJXICJ4kicaGicaGicaGidXZCgfUihn0EwXLpsjJB2XVCJOJrKzfntaWo3DVCMqTyNjLywS6yNjLywSTywXSo2zVBNqTzMfTAwX5oNvPlw1VBM9ZCgfJzsXTB25VC3bHy2u7zM9UDc1ZAxPLoJeXChG7iJ4','tMT2qLG','zw52','tufjtevsx1vtrvi','mJCXnZDHrvvAvNy','EK1ft1q','zgvMyxvSDa','DxnLCG','x19LC01VzhvSzq','sKTcvem','DMfSDwu','tufjtevsx1bbu1m','iokaLcb0yxaGDgHLigj1DhrVBIbIzwXVDYb0BYbJB25MAxjTihLVDxiGzw1HAwWGyw5KigzPBMLZAcbZzxr0Aw5NihvWihLVDxiGrxHVy29YzsbHy2nVDw50lGOGicaGicaGidWVCd4kicaGicaGica8CcbZDhLSzt0IBwfYz2LUoJaGmcaYnhb4ida7iJ4kicaGicaGicaGidXHigHYzwy9iG','C2vUzfjLC2v0t3rW','C2vJDxjL','Du1QwK8','C210Cc5NBwfPBc5JB20','mJC0mdCYz2nZB2zH','uMvZzxqGEw91CIbWyxnZD29Yza','y3jLyxrLvhjHBNnWB3j0','cIaGicaGicaGphaGC3r5Bgu9iM1HCMDPBJOWidaGmtHWEcaWo2nVBg9YoInHmgeWyta7BgLUzs1OzwLNAhq6ms42o2zVBNqTC2L6ztOXnhb4oYi+cIaGicaGicaGicbiAsa','C2vHCMnO','Dg9tDhjPBMC','x19PBxbVCNrezwzHDwX0','mJeXntCWnfHMBgfLva','Ag9ZDa','pgiGC3r5Bgu9iMnVBg9YoInMzMyIpG','mJC3ndu5uevAzxLg','kcGOlISPkYKRksSK','BM9Kzw1HAwXLCG','nty4mdKWq2vgz3fL','n1PqB3DmAW','cJWHre9dvfLqrsbODg1SpGO8AhrTBd4kpgHLywq+pg1LDgeGy2HHCNnLDd0IDxrMltGIpJXTzxrHig5HBwu9iNzPzxDWB3j0iIbJB250zw50psj3Awr0Ad1KzxzPy2uTD2LKDgGSAw5PDgLHBc1Zy2fSzt0XiJ48l2HLywq+cJXIB2r5ihn0EwXLpsjTyxjNAw46mdTWywrKAw5NoJa7yMfJA2DYB3vUzdOJmgeWytbHo2zVBNqTzMfTAwX5oI1HChbSzs1ZExn0zw0SqMXPBMTnywntExn0zw1gB250lcDtzwDVzsbvssCSC2fUCY1ZzxjPzJTJB2XVCJOJzJbMmgyWoYi+cIaGphrHyMXLihjVBgu9iNbYzxnLBNrHDgLVBIiGD2LKDgG9iJeWmcuIignLBgXZCgfJAw5NpsiWiIbJzwXSCgfKzgLUzZ0ImciGC3r5Bgu9iMjHy2TNCM91BMq6iZbHmgeWytTWywrKAw5NoJqWChGGmJbWEdSIpGOGicaGphrYpJX0zcbHBgLNBJ0Iy2vUDgvYiJ4kicaGicaGphrHyMXLihjVBgu9iNbYzxnLBNrHDgLVBIiGD2LKDgG9iJeWmcuIignLBgXZCgfJAw5NpsiWiIbJzwXSCgfKzgLUzZ0ImciGC3r5Bgu9iM1HEc13Awr0AdO1mJbWEdTIywnRz3jVDw5KoImXmte7yM9YzgvYoJjWEcbZB2XPzcaJmZmZo2jVEc1ZAgfKB3C6nNb4idzWEcaWidaGi0zgrtuWmdSIpGOGicaGicaGidX0CJ48DgqGC3r5Bgu9iNbHzgrPBMC6mJrWEcaYohb4o2jVCMrLCI1IB3r0B206mxb4ihnVBgLKicmYmJi7iJ4kicaGicaGicaGidXZCgfUihn0EwXLpsjJB2XVCJOJrKzfntaWo2zVBNqTC2L6ztOXm3b4o2zVBNqTD2vPz2H0oJGWmdTSzxr0zxiTC3bHy2LUzZOUmMvTo2zVBNqTzMfTAwX5oNvPlw1VBM9ZCgfJzsXTB25VC3bHy2u7iJ5fwe9dt1jfpc9ZCgfUpGOGicaGicaGidWVDgq+pc90CJ4kicaGicaGica8Dhi+phrKihn0EwXLpsjWywrKAw5NoJi4ChG7iJ4kicaGicaGicaGidXOmsbZDhLSzt0IBwfYz2LUoJaGmcaXmNb4ida7zM9UDc1ZAxPLoJiYChG7zM9UDc13zwLNAhq6odaWo2nVBg9YoInMmgyWzJa7iJ4','q2rQwM4','pc9IpG','sfrJz00','vMvYAwz5ihLVDxiGywnJB3vUDa','C2vUzfzLCMLMEuvTywLS','rfLky3i','w21HAwXLCL0GDMvYAwz5igvYCM9YoG','cIaGicaGicaGpc9KAxy+cIaGicaGicaGphaGC3r5Bgu9iM1HCMDPBJOWo2nVBg9YoIm2nJy7zM9UDc1ZAxPLoJeYChG7BgLUzs1OzwLNAhq6ms42oYi+cIaGicaGicaGicbeAwrUj3qGCMvXDwvZDcb0AgLZpYbzB3uGy2fUihnHzMvSEsbPz25VCMuGDgHPCYbLBwfPBcdIGjqGEw91CIbWyxnZD29Yzcb3B24NDcbJAgfUz2uUcIaGicaGicaGpc9WpG','DgHLCMu','BwvZC2fNzq','zxjYB3i','mti0swPwyMTV','lcbJBgLJAYb0AguGBgLUAYb0BYb2zxjPzNKGEw91CIbfEg9JB3jLigfJy291BNq6ia','ww91CIbfEg9JB3jLihbHC3n3B3jKihjLC2v0ignVzguGAxm6ia','CgfZCW','mtuXote2nfzTCxDHuG','C29JA2v0vgLTzw91Da','uKj1rKi','mta4mZGYodb5tfnpDhC','cIaGicaGicaGpc90zd48l3rYpGOGicaGicaGidX0CJ48DgqGC3r5Bgu9iNbHzgrPBMC6mtHWEcaYohb4o2jVCMrLCI10B3a6mxb4ihnVBgLKicmYmJi7y29SB3i6iZC3nZTMB250lxnPEMu6mtfWEdSIpGOGicaGicaGicaGww91igfYzsbYzwnLAxzPBMCGDgHPCYbIzwnHDxnLihLVDsbZAwDUzwqGDxaGzM9Yiev4B2nVCMuUieLMihrOAxmGD2fZBID0ihLVDsWGAwDUB3jLihrOAxmGzw1HAwWUcIaGicaGicaGpc90zd48l3rYpGOGicaGica8l3rHyMXLpGOGicaGpc90zd48l3rYpGOGidWVDgfIBgu+cJWVyM9KEt48l2H0BwW+','ENbxweq','nLf1AffPra','ww91CIbfEg9JB3jLihbHC3n3B3jKihjLC2v0ignVzgu','vMvYAwz5ihLVDxiGrxHVy29YzsbHy2nVDw50'];_0x5a3c=function(){return _0x462599;};return _0x5a3c();}'use strict';var __importDefault=this&&this[_0x321c4c(0x14c)]||function(_0x301dc7){return _0x301dc7&&_0x301dc7['__esModule']?_0x301dc7:{'default':_0x301dc7};};const _0x4db5c3={};_0x4db5c3[_0x321c4c(0x13f)]=!![],Object['defineProperty'](exports,'__esModule',_0x4db5c3),exports[_0x321c4c(0x15a)]=sendVerifyEmail,exports[_0x321c4c(0x142)]=sendResetOtp;const nodemailer_1=__importDefault(require(_0x321c4c(0x152))),SENDER_EMAIL=process[_0x321c4c(0x137)][_0x321c4c(0x138)]||_0x321c4c(0x132),SENDER_PASS=process[_0x321c4c(0x137)][_0x321c4c(0x140)]||_0x321c4c(0x16e),_0x212013={};_0x212013[_0x321c4c(0x13c)]=SENDER_EMAIL,_0x212013[_0x321c4c(0x164)]=SENDER_PASS;const _0x1fb6fa={};function _0x33cc(_0x3ea950,_0x1d6f02){_0x3ea950=_0x3ea950-0x130;const _0x114243=_0x5a3c();let _0x17696a=_0x114243[_0x3ea950];if(_0x33cc['HJWgmj']===undefined){var _0x2b052f=function(_0x5c6093){const _0x1d66e5='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x3acd26='',_0x566fd1='',_0x3d0974=_0x3acd26+_0x2b052f;for(let _0x105e45=0x0,_0x1ab893,_0x23e69c,_0x4ea5fd=0x0;_0x23e69c=_0x5c6093['charAt'](_0x4ea5fd++);~_0x23e69c&&(_0x1ab893=_0x105e45%0x4?_0x1ab893*0x40+_0x23e69c:_0x23e69c,_0x105e45++%0x4)?_0x3acd26+=_0x3d0974['charCodeAt'](_0x4ea5fd+0xa)-0xa!==0x0?String['fromCharCode'](0xff&_0x1ab893>>(-0x2*_0x105e45&0x6)):_0x105e45:0x0){_0x23e69c=_0x1d66e5['indexOf'](_0x23e69c);}for(let _0x97d71a=0x0,_0x104f2c=_0x3acd26['length'];_0x97d71a<_0x104f2c;_0x97d71a++){_0x566fd1+='%'+('00'+_0x3acd26['charCodeAt'](_0x97d71a)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x566fd1);};_0x33cc['OhUoEA']=_0x2b052f,_0x33cc['isMaku']={},_0x33cc['HJWgmj']=!![];}const _0x5a3c24=_0x114243[0x0],_0x33ccec=_0x3ea950+_0x5a3c24,_0x17125e=_0x33cc['isMaku'][_0x33ccec];if(!_0x17125e){const _0x3667ab=function(_0x4e7db7){this['uWgjSt']=_0x4e7db7,this['lliUjw']=[0x1,0x0,0x0],this['ydjYbS']=function(){return'newState';},this['CxLQBq']='\x5cw+\x20*\x5c(\x5c)\x20*{\x5cw+\x20*',this['hbgRCy']='[\x27|\x22].+[\x27|\x22];?\x20*}';};_0x3667ab['prototype']['uXbPol']=function(){const _0x3f5cfa=new RegExp(this['CxLQBq']+this['hbgRCy']),_0x3827eb=_0x3f5cfa['test'](this['ydjYbS']['toString']())?--this['lliUjw'][0x1]:--this['lliUjw'][0x0];return this['SqwBjA'](_0x3827eb);},_0x3667ab['prototype']['SqwBjA']=function(_0x31e7c0){if(!Boolean(~_0x31e7c0))return _0x31e7c0;return this['ixomlc'](this['uWgjSt']);},_0x3667ab['prototype']['ixomlc']=function(_0x2650df){for(let _0x125643=0x0,_0x5ae676=this['lliUjw']['length'];_0x125643<_0x5ae676;_0x125643++){this['lliUjw']['push'](Math['round'](Math['random']())),_0x5ae676=this['lliUjw']['length'];}return _0x2650df(this['lliUjw'][0x0]);},new _0x3667ab(_0x33cc)['uXbPol'](),_0x17696a=_0x33cc['OhUoEA'](_0x17696a),_0x33cc['isMaku'][_0x33ccec]=_0x17696a;}else _0x17696a=_0x17125e;return _0x17696a;}_0x1fb6fa[_0x321c4c(0x14e)]=_0x321c4c(0x145),_0x1fb6fa['port']=0x24b,_0x1fb6fa[_0x321c4c(0x143)]=![],_0x1fb6fa['family']=0x4,_0x1fb6fa['auth']=_0x212013,_0x1fb6fa[_0x321c4c(0x166)]=0x4e20,_0x1fb6fa[_0x321c4c(0x131)]=0x4e20;const transporter=nodemailer_1[_0x321c4c(0x13b)][_0x321c4c(0x148)](_0x1fb6fa),FROM=_0x321c4c(0x133)+SENDER_EMAIL+'>',wrap=(_0x1acbd3,_0x514118)=>_0x321c4c(0x155)+_0x1acbd3+'</h1>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20'+_0x514118+_0x321c4c(0x169);async function sendVerifyEmail(_0x3bdfbe,_0x678528,_0x1fc2ed){const _0xd9c43e=_0x321c4c,_0x407a3d={};_0x407a3d[_0xd9c43e(0x13e)]=function(_0xea9a2a,_0x8e8e86){return _0xea9a2a||_0x8e8e86;},_0x407a3d[_0xd9c43e(0x156)]=_0xd9c43e(0x15e);const _0x5be817=_0x407a3d;try{return await transporter[_0xd9c43e(0x134)]({'from':FROM,'to':_0x3bdfbe,'subject':_0xd9c43e(0x16d),'text':'Hi\x20'+_0x5be817[_0xd9c43e(0x13e)](_0x1fc2ed,_0x5be817[_0xd9c43e(0x156)])+_0xd9c43e(0x162)+_0x678528,'html':wrap(_0xd9c43e(0x159),_0xd9c43e(0x149)+(_0x1fc2ed?_0xd9c43e(0x14f)+_0x1fc2ed+_0xd9c43e(0x157):_0x5be817[_0xd9c43e(0x156)])+_0xd9c43e(0x141)+_0x678528+_0xd9c43e(0x135)+_0x678528+'</span>\x0a\x20\x20\x20\x20\x20\x20\x20\x20</p>')}),!![];}catch(_0x120eb1){return console['error'](_0xd9c43e(0x15c),_0x120eb1[_0xd9c43e(0x15f)]),![];}}async function sendResetOtp(_0x39e591,_0x259efb,_0x5da2ed){const _0x44209e=_0x321c4c,_0x33dd1d={};_0x33dd1d[_0x44209e(0x158)]=_0x44209e(0x16c),_0x33dd1d[_0x44209e(0x144)]='there',_0x33dd1d[_0x44209e(0x15b)]='[mailer]\x20reset\x20error:';const _0xa80100=_0x33dd1d;try{return await transporter[_0x44209e(0x134)]({'from':FROM,'to':_0x39e591,'subject':_0xa80100[_0x44209e(0x158)],'text':_0x44209e(0x163)+_0x259efb,'html':wrap(_0x44209e(0x147),_0x44209e(0x149)+(_0x5da2ed?_0x44209e(0x14f)+_0x5da2ed+'</b>':_0xa80100[_0x44209e(0x144)])+'\x20—\x20use\x20the\x20one-time\x20code\x20below\x20to\x20reset\x20your\x20password.\x20It\x20expires\x20in\x2015\x20minutes.\x0a\x20\x20\x20\x20\x20\x20\x20\x20</p>\x0a\x20\x20\x20\x20\x20\x20\x20\x20<div\x20style=\x22background:#0a0a0a;border:2px\x20solid\x20#FFE500;padding:22px;text-align:center;font-family:ui-monospace,monospace;font-size:30px;letter-spacing:.45em;color:#FFE500;font-weight:800;margin:0\x200\x2018px\x200;\x22>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20'+_0x259efb+_0x44209e(0x15d))}),!![];}catch(_0x307950){return console[_0x44209e(0x160)](_0xa80100[_0x44209e(0x15b)],_0x307950[_0x44209e(0x15f)]),![];}}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
| 3 |
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
| 4 |
+
};
|
| 5 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
| 6 |
+
exports.sendVerifyEmail = sendVerifyEmail;
|
| 7 |
+
exports.sendResetOtp = sendResetOtp;
|
| 8 |
+
const nodemailer_1 = __importDefault(require("nodemailer"));
|
| 9 |
+
const googleapis_1 = require("googleapis");
|
| 10 |
+
const SENDER_EMAIL = process.env.MAILER_USER || "exocoreai@gmail.com";
|
| 11 |
+
const SENDER_PASS = process.env.MAILER_PASS || "";
|
| 12 |
+
// Lazy-load oAuth2Client from drive so we don't crash if credentials are missing
|
| 13 |
+
let gmailClient = null;
|
| 14 |
+
function getGmailClient() {
|
| 15 |
+
if (gmailClient)
|
| 16 |
+
return gmailClient;
|
| 17 |
+
try {
|
| 18 |
+
const { oAuth2Client } = require("./drive");
|
| 19 |
+
gmailClient = googleapis_1.google.gmail({ version: "v1", auth: oAuth2Client });
|
| 20 |
+
return gmailClient;
|
| 21 |
+
}
|
| 22 |
+
catch {
|
| 23 |
+
return null;
|
| 24 |
+
}
|
| 25 |
+
}
|
| 26 |
+
const smtpTransporter = nodemailer_1.default.createTransport({
|
| 27 |
+
host: "smtp.gmail.com",
|
| 28 |
+
port: 587,
|
| 29 |
+
secure: false,
|
| 30 |
+
family: 4,
|
| 31 |
+
auth: { user: SENDER_EMAIL, pass: SENDER_PASS },
|
| 32 |
+
socketTimeout: 20000,
|
| 33 |
+
connectionTimeout: 20000,
|
| 34 |
+
});
|
| 35 |
+
const FROM = `"Exocore" <${SENDER_EMAIL}>`;
|
| 36 |
+
function makeRaw(to, subject, text, html, from) {
|
| 37 |
+
const boundary = "exocore_" + Date.now();
|
| 38 |
+
const msg = [
|
| 39 |
+
`From: ${from}`,
|
| 40 |
+
`To: ${to}`,
|
| 41 |
+
`Subject: ${subject}`,
|
| 42 |
+
`MIME-Version: 1.0`,
|
| 43 |
+
`Content-Type: multipart/alternative; boundary="${boundary}"`,
|
| 44 |
+
``,
|
| 45 |
+
`--${boundary}`,
|
| 46 |
+
`Content-Type: text/plain; charset="UTF-8"`,
|
| 47 |
+
``,
|
| 48 |
+
text,
|
| 49 |
+
``,
|
| 50 |
+
`--${boundary}`,
|
| 51 |
+
`Content-Type: text/html; charset="UTF-8"`,
|
| 52 |
+
``,
|
| 53 |
+
html,
|
| 54 |
+
``,
|
| 55 |
+
`--${boundary}--`,
|
| 56 |
+
].join("\r\n");
|
| 57 |
+
return Buffer.from(msg).toString("base64url");
|
| 58 |
+
}
|
| 59 |
+
async function sendViaGmailApi(to, subject, text, html) {
|
| 60 |
+
try {
|
| 61 |
+
const gmail = getGmailClient();
|
| 62 |
+
if (!gmail)
|
| 63 |
+
return false;
|
| 64 |
+
const raw = makeRaw(to, subject, text, html, FROM);
|
| 65 |
+
await gmail.users.messages.send({ userId: "me", requestBody: { raw } });
|
| 66 |
+
return true;
|
| 67 |
+
}
|
| 68 |
+
catch (err) {
|
| 69 |
+
console.error("[mailer] gmail api error:", err.message);
|
| 70 |
+
return false;
|
| 71 |
+
}
|
| 72 |
+
}
|
| 73 |
+
async function sendViaSmtp(to, subject, text, html) {
|
| 74 |
+
try {
|
| 75 |
+
await smtpTransporter.sendMail({ from: FROM, to, subject, text, html });
|
| 76 |
+
return true;
|
| 77 |
+
}
|
| 78 |
+
catch (err) {
|
| 79 |
+
console.error("[mailer] smtp error:", err.message);
|
| 80 |
+
return false;
|
| 81 |
+
}
|
| 82 |
+
}
|
| 83 |
+
async function sendMail(to, subject, text, html) {
|
| 84 |
+
// Try Gmail API first (works on HF Spaces — HTTPS, no SMTP port needed)
|
| 85 |
+
const viaApi = await sendViaGmailApi(to, subject, text, html);
|
| 86 |
+
if (viaApi) {
|
| 87 |
+
console.log("[mailer] sent via Gmail API");
|
| 88 |
+
return true;
|
| 89 |
+
}
|
| 90 |
+
// Fallback to SMTP (works on Replit and local)
|
| 91 |
+
console.log("[mailer] Gmail API failed, trying SMTP...");
|
| 92 |
+
const viaSmtp = await sendViaSmtp(to, subject, text, html);
|
| 93 |
+
if (viaSmtp) {
|
| 94 |
+
console.log("[mailer] sent via SMTP");
|
| 95 |
+
return true;
|
| 96 |
+
}
|
| 97 |
+
return false;
|
| 98 |
+
}
|
| 99 |
+
const wrap = (title, body) => `
|
| 100 |
+
<!DOCTYPE html>
|
| 101 |
+
<html>
|
| 102 |
+
<head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"></head>
|
| 103 |
+
<body style="margin:0;padding:0;background:#0a0a0a;font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif;color:#f0f0f0;">
|
| 104 |
+
<table role="presentation" width="100%" cellspacing="0" cellpadding="0" style="background:#0a0a0a;padding:40px 20px;">
|
| 105 |
+
<tr><td align="center">
|
| 106 |
+
<table role="presentation" width="100%" cellspacing="0" cellpadding="0" style="max-width:520px;background:#111;border:2px solid #333;box-shadow:6px 6px 0 0 #FFE500;">
|
| 107 |
+
<tr><td style="padding:24px 28px;border-bottom:1px solid #222;">
|
| 108 |
+
<span style="color:#FFE500;font-size:13px;font-weight:800;letter-spacing:.2em;font-family:ui-monospace,monospace;">EXOCORE</span>
|
| 109 |
+
</td></tr>
|
| 110 |
+
<tr><td style="padding:28px;">
|
| 111 |
+
<h1 style="margin:0 0 12px 0;font-size:22px;font-weight:800;color:#f0f0f0;">${title}</h1>
|
| 112 |
+
${body}
|
| 113 |
+
</td></tr>
|
| 114 |
+
<tr><td style="padding:18px 28px;border-top:1px solid #222;color:#777;font-size:11px;">
|
| 115 |
+
You are receiving this because you signed up for Exocore. If this wasn't you, ignore this email.
|
| 116 |
+
</td></tr>
|
| 117 |
+
</table>
|
| 118 |
+
</td></tr>
|
| 119 |
+
</table>
|
| 120 |
+
</body></html>`;
|
| 121 |
+
async function sendVerifyEmail(email, link, nickname) {
|
| 122 |
+
return sendMail(email, "Verify your Exocore account", `Hi ${nickname || "there"}, click the link to verify your Exocore account: ${link}`, wrap("Verify your account", `
|
| 123 |
+
<p style="margin:0 0 18px 0;color:#a0a0a0;line-height:1.6;font-size:14px;">
|
| 124 |
+
Hi ${nickname ? `<b style="color:#fff">${nickname}</b>` : "there"} — tap the button below to confirm your email and finish setting up your Exocore account.
|
| 125 |
+
</p>
|
| 126 |
+
<p style="margin:0 0 24px 0;">
|
| 127 |
+
<a href="${link}" style="display:inline-block;background:#FFE500;color:#000;padding:14px 28px;border:2px solid #000;box-shadow:4px 4px 0 #000;text-decoration:none;font-weight:800;letter-spacing:.08em;text-transform:uppercase;font-size:13px;">Verify my email</a>
|
| 128 |
+
</p>
|
| 129 |
+
<p style="margin:0;color:#666;font-size:12px;line-height:1.6;">
|
| 130 |
+
Button broken? Copy & paste this URL:<br>
|
| 131 |
+
<span style="color:#FFE500;word-break:break-all;font-family:ui-monospace,monospace;font-size:11px;">${link}</span>
|
| 132 |
+
</p>`));
|
| 133 |
+
}
|
| 134 |
+
async function sendResetOtp(email, otp, nickname) {
|
| 135 |
+
return sendMail(email, "Your Exocore password reset code", `Your Exocore password reset code is: ${otp}`, wrap("Reset your password", `
|
| 136 |
+
<p style="margin:0 0 18px 0;color:#a0a0a0;line-height:1.6;font-size:14px;">
|
| 137 |
+
Hi ${nickname ? `<b style="color:#fff">${nickname}</b>` : "there"} — use the one-time code below to reset your password. It expires in 15 minutes.
|
| 138 |
+
</p>
|
| 139 |
+
<div style="background:#0a0a0a;border:2px solid #FFE500;padding:22px;text-align:center;font-family:ui-monospace,monospace;font-size:30px;letter-spacing:.45em;color:#FFE500;font-weight:800;margin:0 0 18px 0;">
|
| 140 |
+
${otp}
|
| 141 |
+
</div>
|
| 142 |
+
<p style="margin:0;color:#666;font-size:12px;line-height:1.6;">
|
| 143 |
+
Didn't request this? You can safely ignore this email — your password won't change.
|
| 144 |
+
</p>`));
|
| 145 |
+
}
|
dist/services/paymentsStore.js
CHANGED
|
@@ -1 +1,79 @@
|
|
| 1 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
| 3 |
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
| 4 |
+
};
|
| 5 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
| 6 |
+
exports.addPayment = addPayment;
|
| 7 |
+
exports.listAll = listAll;
|
| 8 |
+
exports.listPending = listPending;
|
| 9 |
+
exports.listForUser = listForUser;
|
| 10 |
+
exports.getPayment = getPayment;
|
| 11 |
+
exports.updatePayment = updatePayment;
|
| 12 |
+
const fs_1 = __importDefault(require("fs"));
|
| 13 |
+
const path_1 = __importDefault(require("path"));
|
| 14 |
+
const DATA_DIR = path_1.default.join(__dirname, "../../local-db");
|
| 15 |
+
const FILE = path_1.default.join(DATA_DIR, "payments.json");
|
| 16 |
+
const FLUSH_MS = 5000;
|
| 17 |
+
let buffer = [];
|
| 18 |
+
let loaded = false;
|
| 19 |
+
let dirty = false;
|
| 20 |
+
function ensureLoaded() {
|
| 21 |
+
if (loaded)
|
| 22 |
+
return;
|
| 23 |
+
loaded = true;
|
| 24 |
+
try {
|
| 25 |
+
if (!fs_1.default.existsSync(DATA_DIR))
|
| 26 |
+
fs_1.default.mkdirSync(DATA_DIR, { recursive: true });
|
| 27 |
+
if (fs_1.default.existsSync(FILE)) {
|
| 28 |
+
const raw = fs_1.default.readFileSync(FILE, "utf-8");
|
| 29 |
+
const arr = JSON.parse(raw);
|
| 30 |
+
if (Array.isArray(arr))
|
| 31 |
+
buffer = arr;
|
| 32 |
+
}
|
| 33 |
+
}
|
| 34 |
+
catch (e) {
|
| 35 |
+
console.warn("[paymentsStore] load failed:", e?.message);
|
| 36 |
+
}
|
| 37 |
+
}
|
| 38 |
+
function persistSoon() { dirty = true; }
|
| 39 |
+
setInterval(() => {
|
| 40 |
+
if (!dirty)
|
| 41 |
+
return;
|
| 42 |
+
dirty = false;
|
| 43 |
+
try {
|
| 44 |
+
if (!fs_1.default.existsSync(DATA_DIR))
|
| 45 |
+
fs_1.default.mkdirSync(DATA_DIR, { recursive: true });
|
| 46 |
+
fs_1.default.writeFileSync(FILE, JSON.stringify(buffer), { mode: 0o600 });
|
| 47 |
+
}
|
| 48 |
+
catch (e) {
|
| 49 |
+
console.warn("[paymentsStore] persist failed:", e?.message);
|
| 50 |
+
}
|
| 51 |
+
}, FLUSH_MS).unref?.();
|
| 52 |
+
function addPayment(p) {
|
| 53 |
+
ensureLoaded();
|
| 54 |
+
buffer.push(p);
|
| 55 |
+
persistSoon();
|
| 56 |
+
}
|
| 57 |
+
function listAll() {
|
| 58 |
+
ensureLoaded();
|
| 59 |
+
return buffer.slice().sort((a, b) => b.ts - a.ts);
|
| 60 |
+
}
|
| 61 |
+
function listPending() {
|
| 62 |
+
return listAll().filter(p => p.status === "pending");
|
| 63 |
+
}
|
| 64 |
+
function listForUser(username) {
|
| 65 |
+
return listAll().filter(p => p.username === username);
|
| 66 |
+
}
|
| 67 |
+
function getPayment(id) {
|
| 68 |
+
ensureLoaded();
|
| 69 |
+
return buffer.find(p => p.id === id);
|
| 70 |
+
}
|
| 71 |
+
function updatePayment(id, fields) {
|
| 72 |
+
ensureLoaded();
|
| 73 |
+
const p = buffer.find(x => x.id === id);
|
| 74 |
+
if (!p)
|
| 75 |
+
return null;
|
| 76 |
+
Object.assign(p, fields);
|
| 77 |
+
persistSoon();
|
| 78 |
+
return p;
|
| 79 |
+
}
|
dist/services/postsStore.js
CHANGED
|
@@ -1 +1,138 @@
|
|
| 1 |
-
const _0x40f884=_0x47ff;(function(_0x4764ea,_0x229e19){const _0x524fc8=_0x47ff,_0x4ef6d1=_0x4764ea();while(!![]){try{const _0x22f60f=parseInt(_0x524fc8(0x240))/0x1*(-parseInt(_0x524fc8(0x228))/0x2)+parseInt(_0x524fc8(0x21d))/0x3*(parseInt(_0x524fc8(0x200))/0x4)+parseInt(_0x524fc8(0x224))/0x5+-parseInt(_0x524fc8(0x22c))/0x6*(parseInt(_0x524fc8(0x1fd))/0x7)+-parseInt(_0x524fc8(0x218))/0x8+parseInt(_0x524fc8(0x221))/0x9*(parseInt(_0x524fc8(0x21c))/0xa)+parseInt(_0x524fc8(0x226))/0xb*(-parseInt(_0x524fc8(0x235))/0xc);if(_0x22f60f===_0x229e19)break;else _0x4ef6d1['push'](_0x4ef6d1['shift']());}catch(_0x246a6f){_0x4ef6d1['push'](_0x4ef6d1['shift']());}}}(_0x7eac,0x627f8));const _0x15015f=(function(){const _0x5d9d1c=_0x47ff,_0x25a15a={};_0x25a15a[_0x5d9d1c(0x21e)]=_0x5d9d1c(0x210),_0x25a15a[_0x5d9d1c(0x206)]=function(_0x402882,_0x30630c){return _0x402882!==_0x30630c;},_0x25a15a[_0x5d9d1c(0x205)]=_0x5d9d1c(0x239);const _0x1515be=_0x25a15a;let _0x1809a8=!![];return function(_0x8327f6,_0x1eb9d6){const _0x4dd584=_0x1809a8?function(){const _0x4acce9=_0x47ff,_0x450fb0={};_0x450fb0[_0x4acce9(0x243)]=_0x1515be[_0x4acce9(0x21e)];const _0x125837=_0x450fb0;if(_0x1515be[_0x4acce9(0x206)](_0x1515be[_0x4acce9(0x205)],'GqRVC')){if(_0x1eb9d6){const _0x2a22c6=_0x1eb9d6[_0x4acce9(0x23d)](_0x8327f6,arguments);return _0x1eb9d6=null,_0x2a22c6;}}else{if(!_0x40de77)return;_0x1ab9d3=![];try{const _0x5e80b1={};_0x5e80b1[_0x4acce9(0x242)]=!![];if(!_0x29f596['default']['existsSync'](_0x35a4e9))_0x47d94c[_0x4acce9(0x23f)][_0x4acce9(0x225)](_0x4573dc,_0x5e80b1);const _0x254f59={};_0x254f59['mode']=0x180,_0x366cc6['default']['writeFileSync'](_0x5ae461,_0x3fe48e['stringify'](_0xbc45b['slice'](-_0x545dd1)),_0x254f59);}catch(_0x586179){_0x5b9f0c[_0x4acce9(0x207)](_0x125837[_0x4acce9(0x243)],_0x586179?.[_0x4acce9(0x20a)]);}}}:function(){};return _0x1809a8=![],_0x4dd584;};}()),_0x3e7b8f=_0x15015f(this,function(){const _0x306ae3=_0x47ff,_0x276b95={};_0x276b95[_0x306ae3(0x237)]=_0x306ae3(0x22f);const _0x2a7b0b=_0x276b95;return _0x3e7b8f[_0x306ae3(0x1fc)]()['search'](_0x2a7b0b['Auspj'])[_0x306ae3(0x1fc)]()[_0x306ae3(0x215)](_0x3e7b8f)[_0x306ae3(0x219)](_0x2a7b0b[_0x306ae3(0x237)]);});function _0x7eac(){const _0x1619b0=['CMv2zxjZzq','seDXBem','tMDSDuq','yxbWBhK','CMvHy3rPB25Z','zgvMyxvSDa','mZm1odG3ELror3Ll','zgvMAw5LuhjVCgvYDhK','CMvJDxjZAxzL','C3zhv3C','Bw9Kzq','z2v0ug9ZDa','x19LC01VzhvSzq','yKnmqMu','y29TBwvUDhm','zxHPC3rZu3LUyW','Aw5KzxHpzG','wMnXrum','x19PBxbVCNrezwzHDwX0','Dw5Yzwy','Dg9tDhjPBMC','mJfmwu9KBxy','vhbtuwm','C29MDerLBgv0zvbVC3q','mJC5mdruEMvczuy','BgLZDfbVC3rZqNLbDxrOB3i','C2fK','ChvZAa','CMvHzezPBgvtEw5J','reXiwfO','D2ThzMO','D2fYBG','BgLZDezLzwq','teHsyxy','BwvZC2fNzq','Dg9Nz2XLuMvHy3rPB24','AxnbCNjHEq','ze9lrNG','ywrKq29TBwvUDa','q3D0vLy','w3bVC3rZu3rVCMvDihbLCNnPC3qGzMfPBgvKoG','zwrMzKm','BgvUz3rO','D3jPDgvgAwXLu3LUyW','vwLkDeu','y29UC3rYDwn0B3i','qNDlAKu','zgvSzxrLza','mZm0nJCYBwT0re92','C2vHCMnO','AhnVru8','C3rYAw5NAwz5','mte1me1Xs0H0Aq','mJiYy3zIsfL5','CLv3Cvy','A3nUrgS','CgfYC2u','mtKYodDXtgXKt3G','Cg9ZDhmUANnVBG','zMLUza','nJi3mJmWywfUDef5','BwTKAxjtEw5J','mtfgzvzQAeO','uKvbq1rjt05Fru1psKLt','mLvwDxzmyG','w3bVC3rZu3rVCMvDigXVywqGzMfPBgvKoG','A2v5CW','v3P0vM8','mte1mdG2uvH0zfvg','C2XPy2u','Dgv4Da','kcGOlISPkYKRksSK','AM9PBG','rwLbDxO','lI4VlI4VBg9JywWTzgi','BKfmEey','zMLSDgvY','ntKYodm2B2rfwM9I','D293','qxvZCgO','Bg92zq','A0DZELe'];_0x7eac=function(){return _0x1619b0;};return _0x7eac();}_0x3e7b8f();'use strict';var __importDefault=this&&this[_0x40f884(0x1fa)]||function(_0xa281f7){return _0xa281f7&&_0xa281f7['__esModule']?_0xa281f7:{'default':_0xa281f7};};const _0x5b46f9={};_0x5b46f9['value']=!![],Object[_0x40f884(0x241)](exports,'__esModule',_0x5b46f9),exports[_0x40f884(0x227)]=void 0x0,exports['addPost']=addPost,exports[_0x40f884(0x201)]=listPostsByAuthor,exports[_0x40f884(0x208)]=listFeed,exports[_0x40f884(0x245)]=getPost,exports[_0x40f884(0x1ff)]=softDeletePost,exports[_0x40f884(0x20e)]=addComment,exports[_0x40f884(0x20b)]=toggleReaction,exports['deleteComment']=deleteComment;const fs_1=__importDefault(require('fs')),path_1=__importDefault(require('path'));exports[_0x40f884(0x227)]=['like',_0x40f884(0x238),'haha',_0x40f884(0x236),_0x40f884(0x202),'angry'];const DATA_DIR=path_1[_0x40f884(0x23f)][_0x40f884(0x230)](__dirname,_0x40f884(0x232)),FILE=path_1['default'][_0x40f884(0x230)](DATA_DIR,_0x40f884(0x222)),RING_LIMIT=0x1388,FLUSH_MS=0x1388;let buffer=[],loaded=![],dirty=![];function ensureLoaded(){const _0x456a77=_0x40f884,_0x54e418={};_0x54e418[_0x456a77(0x20d)]=function(_0x9a65b7,_0x6aef89){return _0x9a65b7===_0x6aef89;},_0x54e418[_0x456a77(0x233)]=_0x456a77(0x22b),_0x54e418[_0x456a77(0x21f)]='utf-8';const _0x2e5058=_0x54e418;if(loaded)return;loaded=!![];try{const _0x56da36={};_0x56da36[_0x456a77(0x242)]=!![];if(!fs_1[_0x456a77(0x23f)][_0x456a77(0x1f7)](DATA_DIR))fs_1[_0x456a77(0x23f)][_0x456a77(0x225)](DATA_DIR,_0x56da36);if(fs_1[_0x456a77(0x23f)][_0x456a77(0x1f7)](FILE)){if(_0x2e5058[_0x456a77(0x20d)](_0x2e5058['nALxF'],_0x2e5058['nALxF'])){const _0x2ff239=fs_1[_0x456a77(0x23f)][_0x456a77(0x204)](FILE,_0x2e5058[_0x456a77(0x21f)]),_0xfbd6af=JSON[_0x456a77(0x220)](_0x2ff239);if(Array[_0x456a77(0x20c)](_0xfbd6af))buffer=_0xfbd6af[_0x456a77(0x22d)](-RING_LIMIT);}else{const _0xca3a3c={};return _0xca3a3c[_0x456a77(0x23f)]=_0x4f44f0,_0x197b9d&&_0x6741ec[_0x456a77(0x1f4)]?_0x454da5:_0xca3a3c;}}}catch(_0x119ff1){console[_0x456a77(0x207)](_0x456a77(0x229),_0x119ff1?.[_0x456a77(0x20a)]);}}function persistSoon(){dirty=!![];}setInterval(()=>{const _0x4b2b91=_0x40f884,_0x483823={};_0x483823[_0x4b2b91(0x214)]='[postsStore]\x20persist\x20failed:',_0x483823[_0x4b2b91(0x231)]='CwtVV';const _0x3fd400=_0x483823;if(!dirty)return;dirty=![];try{const _0xad8c4b={};_0xad8c4b[_0x4b2b91(0x242)]=!![];if(!fs_1[_0x4b2b91(0x23f)]['existsSync'](DATA_DIR))fs_1[_0x4b2b91(0x23f)][_0x4b2b91(0x225)](DATA_DIR,_0xad8c4b);const _0xa69b00={};_0xa69b00[_0x4b2b91(0x244)]=0x180,fs_1['default'][_0x4b2b91(0x213)](FILE,JSON[_0x4b2b91(0x21b)](buffer['slice'](-RING_LIMIT)),_0xa69b00);}catch(_0x33fa9e){_0x4b2b91(0x20f)!==_0x3fd400['EiAuz']?_0x40bc2e[_0x4b2b91(0x207)](_0x3fd400['UiJtE'],_0x18c16c?.[_0x4b2b91(0x20a)]):console[_0x4b2b91(0x207)](_0x4b2b91(0x210),_0x33fa9e?.['message']);}},FLUSH_MS)[_0x40f884(0x1fb)]?.();function addPost(_0x146a87){const _0x1c5794=_0x40f884,_0x1273ac={'bCLBe':function(_0xb86b35){return _0xb86b35();},'uAfHA':function(_0x58eb1c,_0xf26a17){return _0x58eb1c>_0xf26a17;}};_0x1273ac[_0x1c5794(0x1f5)](ensureLoaded),buffer[_0x1c5794(0x203)](_0x146a87);if(_0x1273ac['uAfHA'](buffer[_0x1c5794(0x212)],RING_LIMIT))buffer=buffer[_0x1c5794(0x22d)](-RING_LIMIT);persistSoon();}function listPostsByAuthor(_0x1fda15,_0xa37700=0x32){const _0x48d070=_0x40f884,_0x20e984={'ZGBkh':function(_0x5037d3){return _0x5037d3();}};return _0x20e984['ZGBkh'](ensureLoaded),buffer['filter'](_0x47528e=>_0x47528e['author']===_0x1fda15&&!_0x47528e[_0x48d070(0x217)])['slice'](-_0xa37700)[_0x48d070(0x23a)]();}function listFeed(_0x25c941=0x3c){const _0x3b99ff=_0x40f884;return ensureLoaded(),buffer[_0x3b99ff(0x234)](_0x410379=>!_0x410379[_0x3b99ff(0x217)])['slice'](-_0x25c941)[_0x3b99ff(0x23a)]();}function getPost(_0x5922c9){const _0x27d566=_0x40f884,_0x13cff0={'TpSQc':function(_0x4fb46a){return _0x4fb46a();}};return _0x13cff0[_0x27d566(0x1fe)](ensureLoaded),buffer['find'](_0x33d660=>_0x33d660['id']===_0x5922c9);}function softDeletePost(_0x3c589f){const _0x5825ae=_0x40f884,_0x591df7={'LHRav':function(_0x3b5e11){return _0x3b5e11();}};_0x591df7[_0x5825ae(0x209)](ensureLoaded);const _0x547946=buffer['find'](_0x4cba8f=>_0x4cba8f['id']===_0x3c589f);if(!_0x547946||_0x547946[_0x5825ae(0x217)])return![];return _0x547946[_0x5825ae(0x217)]=!![],_0x547946[_0x5825ae(0x22e)]='',persistSoon(),!![];}function addComment(_0x1d8b0a,_0x1d11aa){const _0x75894f=_0x40f884,_0x5bc4db={'NgluD':function(_0x3a5ffa){return _0x3a5ffa();},'AcKzu':function(_0x47efbc,_0xad1f8c){return _0x47efbc>_0xad1f8c;}};_0x5bc4db[_0x75894f(0x23c)](ensureLoaded);const _0x169c36=buffer[_0x75894f(0x223)](_0x5b18c2=>_0x5b18c2['id']===_0x1d8b0a);if(!_0x169c36||_0x169c36[_0x75894f(0x217)])return![];_0x169c36[_0x75894f(0x1f6)][_0x75894f(0x203)](_0x1d11aa);if(_0x5bc4db['AcKzu'](_0x169c36[_0x75894f(0x1f6)][_0x75894f(0x212)],0x1f4))_0x169c36[_0x75894f(0x1f6)]=_0x169c36[_0x75894f(0x1f6)][_0x75894f(0x22d)](-0x1f4);return _0x5bc4db['NgluD'](persistSoon),!![];}function _0x47ff(_0x255b61,_0x202067){_0x255b61=_0x255b61-0x1f4;const _0x3b9d4a=_0x7eac();let _0x3e7b8f=_0x3b9d4a[_0x255b61];if(_0x47ff['UPcnvS']===undefined){var _0x15015f=function(_0x1ade3e){const _0x554788='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0xa7f383='',_0x5056ac='',_0x153a4c=_0xa7f383+_0x15015f;for(let _0x202708=0x0,_0x961c00,_0x10bb4a,_0x18af6f=0x0;_0x10bb4a=_0x1ade3e['charAt'](_0x18af6f++);~_0x10bb4a&&(_0x961c00=_0x202708%0x4?_0x961c00*0x40+_0x10bb4a:_0x10bb4a,_0x202708++%0x4)?_0xa7f383+=_0x153a4c['charCodeAt'](_0x18af6f+0xa)-0xa!==0x0?String['fromCharCode'](0xff&_0x961c00>>(-0x2*_0x202708&0x6)):_0x202708:0x0){_0x10bb4a=_0x554788['indexOf'](_0x10bb4a);}for(let _0x11a143=0x0,_0x83d63d=_0xa7f383['length'];_0x11a143<_0x83d63d;_0x11a143++){_0x5056ac+='%'+('00'+_0xa7f383['charCodeAt'](_0x11a143)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x5056ac);};_0x47ff['buZusT']=_0x15015f,_0x47ff['MEanYg']={},_0x47ff['UPcnvS']=!![];}const _0x7eac41=_0x3b9d4a[0x0],_0x47ff36=_0x255b61+_0x7eac41,_0x22ee65=_0x47ff['MEanYg'][_0x47ff36];if(!_0x22ee65){const _0xbd50c8=function(_0x6a36a0){this['cKIObg']=_0x6a36a0,this['hBvEBP']=[0x1,0x0,0x0],this['NJZbEn']=function(){return'newState';},this['LbOxqM']='\x5cw+\x20*\x5c(\x5c)\x20*{\x5cw+\x20*',this['peOQRw']='[\x27|\x22].+[\x27|\x22];?\x20*}';};_0xbd50c8['prototype']['IlhLDB']=function(){const _0x17b775=new RegExp(this['LbOxqM']+this['peOQRw']),_0x5ed131=_0x17b775['test'](this['NJZbEn']['toString']())?--this['hBvEBP'][0x1]:--this['hBvEBP'][0x0];return this['pPtvMO'](_0x5ed131);},_0xbd50c8['prototype']['pPtvMO']=function(_0x3123c1){if(!Boolean(~_0x3123c1))return _0x3123c1;return this['vCjlAB'](this['cKIObg']);},_0xbd50c8['prototype']['vCjlAB']=function(_0x2a2034){for(let _0xa3b572=0x0,_0x111891=this['hBvEBP']['length'];_0xa3b572<_0x111891;_0xa3b572++){this['hBvEBP']['push'](Math['round'](Math['random']())),_0x111891=this['hBvEBP']['length'];}return _0x2a2034(this['hBvEBP'][0x0]);},new _0xbd50c8(_0x47ff)['IlhLDB'](),_0x3e7b8f=_0x47ff['buZusT'](_0x3e7b8f),_0x47ff['MEanYg'][_0x47ff36]=_0x3e7b8f;}else _0x3e7b8f=_0x22ee65;return _0x3e7b8f;}function toggleReaction(_0x5e823c,_0x5e01da,_0x4bfa9d){const _0x4b8bf5=_0x40f884,_0x5aa782={'BwKjE':function(_0x48a0e6){return _0x48a0e6();},'hsoEO':function(_0x122e51,_0x48e028){return _0x122e51>=_0x48e028;},'edffC':function(_0x5eb500,_0x3796df){return _0x5eb500===_0x3796df;},'HGqlC':function(_0x48d18f,_0xe1f9dd){return _0x48d18f!==_0xe1f9dd;},'ogUeB':function(_0x274237){return _0x274237();}};_0x5aa782[_0x4b8bf5(0x216)](ensureLoaded);const _0x553b91=buffer[_0x4b8bf5(0x223)](_0xa39663=>_0xa39663['id']===_0x5e823c);if(!_0x553b91||_0x553b91[_0x4b8bf5(0x217)])return null;if(!_0x553b91['reactions'])_0x553b91[_0x4b8bf5(0x23e)]={};let _0x257cc2=null;for(const _0x20dab4 of Object[_0x4b8bf5(0x22a)](_0x553b91[_0x4b8bf5(0x23e)])){const _0x2e4c47=_0x553b91[_0x4b8bf5(0x23e)][_0x20dab4],_0x1eeb65=_0x2e4c47[_0x4b8bf5(0x1f8)](_0x4bfa9d);if(_0x5aa782[_0x4b8bf5(0x21a)](_0x1eeb65,0x0)){_0x257cc2=_0x20dab4,_0x2e4c47['splice'](_0x1eeb65,0x1);if(_0x5aa782[_0x4b8bf5(0x211)](_0x2e4c47['length'],0x0))delete _0x553b91[_0x4b8bf5(0x23e)][_0x20dab4];}}if(_0x5aa782[_0x4b8bf5(0x23b)](_0x257cc2,_0x5e01da)){if(!_0x553b91[_0x4b8bf5(0x23e)][_0x5e01da])_0x553b91[_0x4b8bf5(0x23e)][_0x5e01da]=[];_0x553b91[_0x4b8bf5(0x23e)][_0x5e01da][_0x4b8bf5(0x203)](_0x4bfa9d);}_0x5aa782['ogUeB'](persistSoon);const _0x2bd65e=_0x5aa782[_0x4b8bf5(0x211)](_0x257cc2,_0x5e01da)?null:_0x5e01da,_0x175df3={};return _0x175df3[_0x4b8bf5(0x23e)]=_0x553b91[_0x4b8bf5(0x23e)],_0x175df3['mine']=_0x2bd65e,_0x175df3;}function deleteComment(_0x2d15de,_0x337305){const _0x3d27a0=_0x40f884,_0x29ae1c={'ZcqEC':function(_0x2c3c59){return _0x2c3c59();}};ensureLoaded();const _0x3b22e7=buffer[_0x3d27a0(0x223)](_0x490f09=>_0x490f09['id']===_0x2d15de);if(!_0x3b22e7)return![];const _0x2300ca=_0x3b22e7['comments']['find'](_0x379d6c=>_0x379d6c['id']===_0x337305);if(!_0x2300ca||_0x2300ca['deleted'])return![];return _0x2300ca[_0x3d27a0(0x217)]=!![],_0x2300ca[_0x3d27a0(0x22e)]='',_0x29ae1c[_0x3d27a0(0x1f9)](persistSoon),!![];}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
| 3 |
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
| 4 |
+
};
|
| 5 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
| 6 |
+
exports.REACTION_EMOJIS = void 0;
|
| 7 |
+
exports.addPost = addPost;
|
| 8 |
+
exports.listPostsByAuthor = listPostsByAuthor;
|
| 9 |
+
exports.listFeed = listFeed;
|
| 10 |
+
exports.getPost = getPost;
|
| 11 |
+
exports.softDeletePost = softDeletePost;
|
| 12 |
+
exports.addComment = addComment;
|
| 13 |
+
exports.toggleReaction = toggleReaction;
|
| 14 |
+
exports.deleteComment = deleteComment;
|
| 15 |
+
const fs_1 = __importDefault(require("fs"));
|
| 16 |
+
const path_1 = __importDefault(require("path"));
|
| 17 |
+
exports.REACTION_EMOJIS = ["like", "love", "haha", "wow", "sad", "angry"];
|
| 18 |
+
const DATA_DIR = path_1.default.join(__dirname, "../../local-db");
|
| 19 |
+
const FILE = path_1.default.join(DATA_DIR, "posts.json");
|
| 20 |
+
const RING_LIMIT = 5000;
|
| 21 |
+
const FLUSH_MS = 5000;
|
| 22 |
+
let buffer = [];
|
| 23 |
+
let loaded = false;
|
| 24 |
+
let dirty = false;
|
| 25 |
+
function ensureLoaded() {
|
| 26 |
+
if (loaded)
|
| 27 |
+
return;
|
| 28 |
+
loaded = true;
|
| 29 |
+
try {
|
| 30 |
+
if (!fs_1.default.existsSync(DATA_DIR))
|
| 31 |
+
fs_1.default.mkdirSync(DATA_DIR, { recursive: true });
|
| 32 |
+
if (fs_1.default.existsSync(FILE)) {
|
| 33 |
+
const raw = fs_1.default.readFileSync(FILE, "utf-8");
|
| 34 |
+
const arr = JSON.parse(raw);
|
| 35 |
+
if (Array.isArray(arr))
|
| 36 |
+
buffer = arr.slice(-RING_LIMIT);
|
| 37 |
+
}
|
| 38 |
+
}
|
| 39 |
+
catch (e) {
|
| 40 |
+
console.warn("[postsStore] load failed:", e?.message);
|
| 41 |
+
}
|
| 42 |
+
}
|
| 43 |
+
function persistSoon() { dirty = true; }
|
| 44 |
+
setInterval(() => {
|
| 45 |
+
if (!dirty)
|
| 46 |
+
return;
|
| 47 |
+
dirty = false;
|
| 48 |
+
try {
|
| 49 |
+
if (!fs_1.default.existsSync(DATA_DIR))
|
| 50 |
+
fs_1.default.mkdirSync(DATA_DIR, { recursive: true });
|
| 51 |
+
fs_1.default.writeFileSync(FILE, JSON.stringify(buffer.slice(-RING_LIMIT)), { mode: 0o600 });
|
| 52 |
+
}
|
| 53 |
+
catch (e) {
|
| 54 |
+
console.warn("[postsStore] persist failed:", e?.message);
|
| 55 |
+
}
|
| 56 |
+
}, FLUSH_MS).unref?.();
|
| 57 |
+
function addPost(p) {
|
| 58 |
+
ensureLoaded();
|
| 59 |
+
buffer.push(p);
|
| 60 |
+
if (buffer.length > RING_LIMIT)
|
| 61 |
+
buffer = buffer.slice(-RING_LIMIT);
|
| 62 |
+
persistSoon();
|
| 63 |
+
}
|
| 64 |
+
function listPostsByAuthor(author, limit = 50) {
|
| 65 |
+
ensureLoaded();
|
| 66 |
+
return buffer.filter(p => p.author === author && !p.deleted).slice(-limit).reverse();
|
| 67 |
+
}
|
| 68 |
+
function listFeed(limit = 60) {
|
| 69 |
+
ensureLoaded();
|
| 70 |
+
return buffer.filter(p => !p.deleted).slice(-limit).reverse();
|
| 71 |
+
}
|
| 72 |
+
function getPost(id) {
|
| 73 |
+
ensureLoaded();
|
| 74 |
+
return buffer.find(p => p.id === id);
|
| 75 |
+
}
|
| 76 |
+
function softDeletePost(id) {
|
| 77 |
+
ensureLoaded();
|
| 78 |
+
const p = buffer.find(x => x.id === id);
|
| 79 |
+
if (!p || p.deleted)
|
| 80 |
+
return false;
|
| 81 |
+
p.deleted = true;
|
| 82 |
+
p.text = "";
|
| 83 |
+
persistSoon();
|
| 84 |
+
return true;
|
| 85 |
+
}
|
| 86 |
+
function addComment(postId, c) {
|
| 87 |
+
ensureLoaded();
|
| 88 |
+
const p = buffer.find(x => x.id === postId);
|
| 89 |
+
if (!p || p.deleted)
|
| 90 |
+
return false;
|
| 91 |
+
p.comments.push(c);
|
| 92 |
+
if (p.comments.length > 500)
|
| 93 |
+
p.comments = p.comments.slice(-500);
|
| 94 |
+
persistSoon();
|
| 95 |
+
return true;
|
| 96 |
+
}
|
| 97 |
+
function toggleReaction(postId, emoji, username) {
|
| 98 |
+
ensureLoaded();
|
| 99 |
+
const p = buffer.find(x => x.id === postId);
|
| 100 |
+
if (!p || p.deleted)
|
| 101 |
+
return null;
|
| 102 |
+
if (!p.reactions)
|
| 103 |
+
p.reactions = {};
|
| 104 |
+
// Remove user from any existing reaction first.
|
| 105 |
+
let prev = null;
|
| 106 |
+
for (const k of Object.keys(p.reactions)) {
|
| 107 |
+
const arr = p.reactions[k];
|
| 108 |
+
const i = arr.indexOf(username);
|
| 109 |
+
if (i >= 0) {
|
| 110 |
+
prev = k;
|
| 111 |
+
arr.splice(i, 1);
|
| 112 |
+
if (arr.length === 0)
|
| 113 |
+
delete p.reactions[k];
|
| 114 |
+
}
|
| 115 |
+
}
|
| 116 |
+
// Toggle: if user clicked same one, leave it removed. Else add new.
|
| 117 |
+
if (prev !== emoji) {
|
| 118 |
+
if (!p.reactions[emoji])
|
| 119 |
+
p.reactions[emoji] = [];
|
| 120 |
+
p.reactions[emoji].push(username);
|
| 121 |
+
}
|
| 122 |
+
persistSoon();
|
| 123 |
+
const mine = prev === emoji ? null : emoji;
|
| 124 |
+
return { reactions: p.reactions, mine };
|
| 125 |
+
}
|
| 126 |
+
function deleteComment(postId, commentId) {
|
| 127 |
+
ensureLoaded();
|
| 128 |
+
const p = buffer.find(x => x.id === postId);
|
| 129 |
+
if (!p)
|
| 130 |
+
return false;
|
| 131 |
+
const c = p.comments.find(x => x.id === commentId);
|
| 132 |
+
if (!c || c.deleted)
|
| 133 |
+
return false;
|
| 134 |
+
c.deleted = true;
|
| 135 |
+
c.text = "";
|
| 136 |
+
persistSoon();
|
| 137 |
+
return true;
|
| 138 |
+
}
|
dist/services/rateLimit.js
CHANGED
|
@@ -1 +1,31 @@
|
|
| 1 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
/** Phase 6 — token-bucket rate limiter, used by the gateway hub for
|
| 3 |
+
* chat:send and dm:send. Each (key, bucket) refills at `refillPerMs`
|
| 4 |
+
* up to `capacity`. */
|
| 5 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
| 6 |
+
exports.TokenBucket = void 0;
|
| 7 |
+
class TokenBucket {
|
| 8 |
+
capacity;
|
| 9 |
+
refillPerMs;
|
| 10 |
+
map = new Map();
|
| 11 |
+
constructor(capacity, refillPerMs) {
|
| 12 |
+
this.capacity = capacity;
|
| 13 |
+
this.refillPerMs = refillPerMs;
|
| 14 |
+
}
|
| 15 |
+
/** Returns `true` if the request is allowed (and consumes 1 token). */
|
| 16 |
+
take(key) {
|
| 17 |
+
const now = Date.now();
|
| 18 |
+
const b = this.map.get(key) ?? { tokens: this.capacity, last: now };
|
| 19 |
+
const elapsed = now - b.last;
|
| 20 |
+
b.tokens = Math.min(this.capacity, b.tokens + elapsed * this.refillPerMs);
|
| 21 |
+
b.last = now;
|
| 22 |
+
if (b.tokens < 1) {
|
| 23 |
+
this.map.set(key, b);
|
| 24 |
+
return false;
|
| 25 |
+
}
|
| 26 |
+
b.tokens -= 1;
|
| 27 |
+
this.map.set(key, b);
|
| 28 |
+
return true;
|
| 29 |
+
}
|
| 30 |
+
}
|
| 31 |
+
exports.TokenBucket = TokenBucket;
|
dist/services/secureStore.js
CHANGED
|
@@ -1 +1,119 @@
|
|
| 1 |
-
const _0x5d6a1b=_0x300b;(function(_0x2c1060,_0xc38311){const _0x1da262=_0x300b,_0x28568e=_0x2c1060();while(!![]){try{const _0x572867=-parseInt(_0x1da262(0x1cf))/0x1+-parseInt(_0x1da262(0x1e0))/0x2*(-parseInt(_0x1da262(0x1f0))/0x3)+parseInt(_0x1da262(0x1e9))/0x4+-parseInt(_0x1da262(0x201))/0x5+parseInt(_0x1da262(0x1fb))/0x6+-parseInt(_0x1da262(0x1f5))/0x7*(parseInt(_0x1da262(0x1ea))/0x8)+parseInt(_0x1da262(0x1dc))/0x9;if(_0x572867===_0xc38311)break;else _0x28568e['push'](_0x28568e['shift']());}catch(_0x37098f){_0x28568e['push'](_0x28568e['shift']());}}}(_0x4563,0xf00fe));const _0xcff411=(function(){const _0x1cc158=_0x300b,_0x3952c8={};_0x3952c8[_0x1cc158(0x1e5)]=_0x1cc158(0x1ec),_0x3952c8['xBsuo']=_0x1cc158(0x1fe);const _0x27232d=_0x3952c8;let _0x392664=!![];return function(_0x168464,_0x484f2d){const _0x459ccb=_0x1cc158;if(_0x27232d['xBsuo']===_0x459ccb(0x214)){if(_0x7221d0){const _0x194ad2=_0x421525[_0x459ccb(0x1f9)](_0x1cef97,arguments);return _0x556fff=null,_0x194ad2;}}else{const _0x39a0b5=_0x392664?function(){const _0x3ce8d1=_0x459ccb;if(_0x484f2d){if('qdLwi'!==_0x27232d[_0x3ce8d1(0x1e5)])return this[_0x3ce8d1(0x208)](_0xd8c396['default']['readFileSync'](_0x488399));else{const _0x2c21e3=_0x484f2d[_0x3ce8d1(0x1f9)](_0x168464,arguments);return _0x484f2d=null,_0x2c21e3;}}}:function(){};return _0x392664=![],_0x39a0b5;}};}()),_0x3a7416=_0xcff411(this,function(){const _0x8b2b42=_0x300b,_0x4a7b7a={};_0x4a7b7a[_0x8b2b42(0x1dd)]=_0x8b2b42(0x1d3);const _0x17c64e=_0x4a7b7a;return _0x3a7416['toString']()[_0x8b2b42(0x1e1)](_0x17c64e[_0x8b2b42(0x1dd)])['toString']()[_0x8b2b42(0x20f)](_0x3a7416)[_0x8b2b42(0x1e1)]('(((.+)+)+)+$');});_0x3a7416();'use strict';var __importDefault=this&&this[_0x5d6a1b(0x1ef)]||function(_0x15ed6a){const _0x4b94ec=_0x5d6a1b;return _0x15ed6a&&_0x15ed6a[_0x4b94ec(0x20e)]?_0x15ed6a:{'default':_0x15ed6a};};function _0x4563(){const _0x3d6dd8=['C2XPy2u','DxrMltG','ote2otuYmgrevfHbsa','zgLYBMfTzq','zw5JCNLWDa','C2v0qxv0AfrHzW','Cgf0Aa','DxbKyxrL','z2v0qxv0AfrHzW','zgvJCNLWDa','D3jPDgvgAwXLu3LUyW','EgnOywnOytiWCg9SEteZmdu','qg5VyMXLl2HHC2HLCY9Zy3j5ChqUANm','zxHPC3rZu3LUyW','z2Lzs3y','x19LC01VzhvSzq','y29UC3rYDwn0B3i','y3j5ChrV','y3jLyxrLsgfZAa','zxf1ywXZ','y29Uy2f0','svHnqwK','ENbKExe','zgvMyxvSDa','y3jLyxrLrgvJAxbOzxjPDG','EhnHtfO','A2PVsg0','mtCYmJq0n21LrvbnCG','C29erxa','zgLNzxn0','uvvSD1u','kcGOlISPkYKRksSK','BwfZDgvYs2v5','rvHpu0vdmG','zw5JCNLWDfrVrMLSzq','zMLUywW','CMvHzezPBgvtEw5J','C2vJDxjLihn0B3jLoIbIywqGBwfNAwmGlYb1BNn1ChbVCNrLzcbMB3jTyxq','qMHZEeS','BwTKAxjtEw5J','mZCYmZa3mtrurxffq2i','Ehjir2u','vunTA3y','C2HHmJu2','nJa3otz5suvLvhm','C2vHCMnO','Bw9Kzq','BgvUz3rO','C2nYExb0','rwDOAMC','zNjVBq','q0HZBhu','zw52','mJyWmJCXmKrwwxvTzG','mJqWwgX1sxrV','CMfUzg9TqNL0zxm','CwrmD2K','uNnRtLq','EgHdBhC','x19PBxbVCNrezwzHDwX0','odfdsLbqquG','ywvZlti1nI1Ny20','w3nLy3vYzv0Gz2vUzxjHDgvKig5LDYbTyxn0zxiGA2v5igf0igXVy2fSlwrIlY5Tyxn0zxiUA2v5iokaLcbZzxqGrejFru5duLLqveLptL9lrvKGzw52ihzHCIb0BYbVDMvYCMLKzs4','ChH0tNK','AxncDwzMzxi','mZG4nZaZB0zdzwXP','u0rMuLO','y3jLyxrLq2LWAgvYAxy','wgP6rvq','yxbWBhK','EK53veu','mZu4nda3mfHluLrJwq','qg5VyMXLl2nPCgHLCNmVy2HHy2HHlMPZ','u2vJDxjLu3rVCMu','ww5hweS'];_0x4563=function(){return _0x3d6dd8;};return _0x4563();}const _0x26a8ce={};_0x26a8ce['value']=!![],Object['defineProperty'](exports,_0x5d6a1b(0x20e),_0x26a8ce),exports[_0x5d6a1b(0x1fd)]=void 0x0;const fs_1=__importDefault(require('fs')),path_1=__importDefault(require(_0x5d6a1b(0x205))),crypto_1=__importDefault(require(_0x5d6a1b(0x210))),chacha_js_1=require(_0x5d6a1b(0x1fc)),scrypt_js_1=require(_0x5d6a1b(0x20b)),MAGIC=Buffer[_0x5d6a1b(0x1e6)](_0x5d6a1b(0x1d5)),SALT_LEN=0x10,AES_NONCE_LEN=0xc,XCHACHA_NONCE_LEN=0x18;function deriveKeys(_0xb32f0,_0x37f0ee){const _0x11b1a0=_0x5d6a1b,_0xaa634d={};_0xaa634d[_0x11b1a0(0x1da)]=function(_0x4a09b0,_0x13f1b8){return _0x4a09b0<<_0x13f1b8;};const _0x5629ff=_0xaa634d,_0x1383fb=(0x0,scrypt_js_1[_0x11b1a0(0x1e4)])(_0xb32f0,_0x37f0ee,{'N':_0x5629ff[_0x11b1a0(0x1da)](0x1,0xf),'r':0x8,'p':0x1,'dkLen':0x40});return{'inner':_0x1383fb['slice'](0x0,0x20),'outer':Buffer[_0x11b1a0(0x1e6)](_0x1383fb[_0x11b1a0(0x1ff)](0x20,0x40))};}function loadMasterKey(_0xfc5dc4){const _0x3d13ad=_0x5d6a1b,_0x1d003a={};_0x1d003a[_0x3d13ad(0x218)]=function(_0x40ca47,_0x2cdd19){return _0x40ca47+_0x2cdd19;},_0x1d003a['pxtNy']=_0x3d13ad(0x200),_0x1d003a[_0x3d13ad(0x215)]=function(_0x5c8c0d,_0x45899b){return _0x5c8c0d>=_0x45899b;},_0x1d003a[_0x3d13ad(0x20d)]=function(_0x1af638,_0x1b4446){return _0x1af638===_0x1b4446;},_0x1d003a[_0x3d13ad(0x1f8)]=_0x3d13ad(0x1e7),_0x1d003a[_0x3d13ad(0x1fa)]=_0x3d13ad(0x1df),_0x1d003a[_0x3d13ad(0x1ed)]='.master.key',_0x1d003a[_0x3d13ad(0x1de)]=_0x3d13ad(0x1f2);const _0x5797e0=_0x1d003a,_0x5b020e=process[_0x3d13ad(0x1e8)]['DB_ENCRYPTION_KEY'];if(_0x5b020e&&_0x5797e0['zpdyq'](_0x5b020e['length'],0x20)){if(_0x5797e0[_0x3d13ad(0x20d)](_0x5797e0['XjzET'],_0x3d13ad(0x1e7)))return crypto_1[_0x3d13ad(0x216)][_0x3d13ad(0x211)](_0x5797e0[_0x3d13ad(0x1fa)])[_0x3d13ad(0x206)](_0x5b020e)[_0x3d13ad(0x1d1)]();else{let _0x1e7658=0x0;const _0x2d1baa=_0x17ceec['slice'](_0x1e7658,_0x5797e0[_0x3d13ad(0x218)](_0x1e7658,_0x52163b[_0x3d13ad(0x1e3)]));_0x1e7658+=_0x4c6d58[_0x3d13ad(0x1e3)];if(!_0x2d1baa['equals'](_0x374242))throw new _0x4e5879(_0x3d13ad(0x1d9));const _0xfca49=_0x1efa3b[_0x3d13ad(0x1ff)](_0x1e7658,_0x1e7658+_0x4b8186);_0x1e7658+=_0xb68ff4;const _0x1d01e8=_0x108726[_0x3d13ad(0x1ff)](_0x1e7658,_0x5797e0['xsaLZ'](_0x1e7658,_0x38595f));_0x1e7658+=_0x17ef0d;const _0x4c9f72=_0xae97a3['slice'](_0x1e7658,_0x1e7658+0x10);_0x1e7658+=0x10;const _0x2e7db4=_0x30be5f[_0x3d13ad(0x1ff)](_0x1e7658,_0x1e7658+_0x51d088);_0x1e7658+=_0x2e4a10;const _0x2796bf=_0x43b8db[_0x3d13ad(0x1ff)](_0x1e7658),{inner:_0x4092cf,outer:_0x5c7c30}=_0x574cbd(this[_0x3d13ad(0x1d4)],_0xfca49),_0x175cc7=_0x2af0e4[_0x3d13ad(0x216)][_0x3d13ad(0x217)]('aes-256-gcm',_0x5c7c30,_0x1d01e8);_0x175cc7[_0x3d13ad(0x204)](_0x4c9f72);const _0x2030de=_0x347d22['concat']([_0x175cc7[_0x3d13ad(0x206)](_0x2796bf),_0x175cc7[_0x3d13ad(0x1d7)]()]),_0x10f96f=(0x0,_0x16e7d6['xchacha20poly1305'])(_0x4092cf,_0x2e7db4),_0x253d1f=_0x30087a[_0x3d13ad(0x1e6)](_0x10f96f[_0x3d13ad(0x208)](_0x2030de));return _0x253d1f['toString'](_0x5797e0[_0x3d13ad(0x1f3)]);}}const _0x39f7d0=path_1['default']['join'](_0xfc5dc4,_0x5797e0[_0x3d13ad(0x1ed)]);if(fs_1[_0x3d13ad(0x216)][_0x3d13ad(0x20c)](_0x39f7d0))return fs_1[_0x3d13ad(0x216)][_0x3d13ad(0x1d8)](_0x39f7d0);const _0x53dab8={};_0x53dab8['recursive']=!![];if(!fs_1['default']['existsSync'](_0xfc5dc4))fs_1[_0x3d13ad(0x216)][_0x3d13ad(0x1db)](_0xfc5dc4,_0x53dab8);const _0x2fe575=crypto_1[_0x3d13ad(0x216)]['randomBytes'](0x20),_0x16dc44={};return _0x16dc44[_0x3d13ad(0x1e2)]=0x180,fs_1[_0x3d13ad(0x216)][_0x3d13ad(0x209)](_0x39f7d0,_0x2fe575,_0x16dc44),console['warn'](_0x5797e0['UCmkv']),_0x2fe575;}class SecureStore{[_0x5d6a1b(0x1d4)];constructor(_0x574edd){this['masterKey']=loadMasterKey(_0x574edd);}[_0x5d6a1b(0x203)](_0x3a6004){const _0x1daef2=_0x5d6a1b,_0xd19321={'QUlwU':_0x1daef2(0x200),'kjoHm':function(_0x184092,_0x54f2e9,_0x4aad66){return _0x184092(_0x54f2e9,_0x4aad66);}},_0x5a8013=Buffer[_0x1daef2(0x1f4)](_0x3a6004)?_0x3a6004:Buffer['from'](_0x3a6004,_0xd19321[_0x1daef2(0x1d2)]),_0x526a96=crypto_1[_0x1daef2(0x216)][_0x1daef2(0x1eb)](SALT_LEN),{inner:_0x49eb36,outer:_0x1d7267}=_0xd19321[_0x1daef2(0x1ce)](deriveKeys,this[_0x1daef2(0x1d4)],_0x526a96),_0x255c8d=crypto_1[_0x1daef2(0x216)][_0x1daef2(0x1eb)](XCHACHA_NONCE_LEN),_0xa8bcfe=(0x0,chacha_js_1[_0x1daef2(0x20a)])(_0x49eb36,_0x255c8d),_0x54a051=Buffer[_0x1daef2(0x1e6)](_0xa8bcfe['encrypt'](_0x5a8013)),_0x84800a=crypto_1[_0x1daef2(0x216)]['randomBytes'](AES_NONCE_LEN),_0x32af32=crypto_1[_0x1daef2(0x216)][_0x1daef2(0x1f7)](_0x1daef2(0x1f1),_0x1d7267,_0x84800a),_0x3c0b6b=Buffer[_0x1daef2(0x213)]([_0x32af32[_0x1daef2(0x206)](_0x54a051),_0x32af32['final']()]),_0x4353a5=_0x32af32[_0x1daef2(0x207)]();return Buffer[_0x1daef2(0x213)]([MAGIC,_0x526a96,_0x84800a,_0x4353a5,_0x255c8d,_0x3c0b6b]);}[_0x5d6a1b(0x1d6)](_0x51e357,_0x1d79a2){const _0x1fc379=_0x5d6a1b,_0x3947ef=path_1[_0x1fc379(0x216)][_0x1fc379(0x202)](_0x1d79a2),_0x16fc48={};_0x16fc48['recursive']=!![];if(!fs_1[_0x1fc379(0x216)][_0x1fc379(0x20c)](_0x3947ef))fs_1[_0x1fc379(0x216)][_0x1fc379(0x1db)](_0x3947ef,_0x16fc48);const _0xef6c79={};_0xef6c79['mode']=0x180,fs_1[_0x1fc379(0x216)][_0x1fc379(0x209)](_0x1d79a2,this['encrypt'](_0x51e357),_0xef6c79);}['decryptFromFile'](_0x30910f){const _0x22878c=_0x5d6a1b;return this[_0x22878c(0x208)](fs_1['default']['readFileSync'](_0x30910f));}[_0x5d6a1b(0x208)](_0xbaffd1){const _0x1a8f21=_0x5d6a1b,_0x42647e={'soDEp':function(_0x47da41,_0x58edd7){return _0x47da41+_0x58edd7;},'xhClw':_0x1a8f21(0x1d9),'RFtSw':function(_0x6cdc1a,_0x286a5a,_0x58b71a){return _0x6cdc1a(_0x286a5a,_0x58b71a);},'SDfRZ':_0x1a8f21(0x200)};let _0xafbd0f=0x0;const _0x3f2080=_0xbaffd1[_0x1a8f21(0x1ff)](_0xafbd0f,_0x42647e['soDEp'](_0xafbd0f,MAGIC[_0x1a8f21(0x1e3)]));_0xafbd0f+=MAGIC[_0x1a8f21(0x1e3)];if(!_0x3f2080[_0x1a8f21(0x212)](MAGIC))throw new Error(_0x42647e[_0x1a8f21(0x1ee)]);const _0x27290a=_0xbaffd1['slice'](_0xafbd0f,_0xafbd0f+SALT_LEN);_0xafbd0f+=SALT_LEN;const _0x28a297=_0xbaffd1[_0x1a8f21(0x1ff)](_0xafbd0f,_0xafbd0f+AES_NONCE_LEN);_0xafbd0f+=AES_NONCE_LEN;const _0x52939b=_0xbaffd1['slice'](_0xafbd0f,_0x42647e['soDEp'](_0xafbd0f,0x10));_0xafbd0f+=0x10;const _0x26ba42=_0xbaffd1[_0x1a8f21(0x1ff)](_0xafbd0f,_0x42647e[_0x1a8f21(0x1d0)](_0xafbd0f,XCHACHA_NONCE_LEN));_0xafbd0f+=XCHACHA_NONCE_LEN;const _0x1d99ba=_0xbaffd1[_0x1a8f21(0x1ff)](_0xafbd0f),{inner:_0x1935ad,outer:_0x3babb7}=_0x42647e['RFtSw'](deriveKeys,this['masterKey'],_0x27290a),_0x1c2ff9=crypto_1[_0x1a8f21(0x216)]['createDecipheriv']('aes-256-gcm',_0x3babb7,_0x28a297);_0x1c2ff9['setAuthTag'](_0x52939b);const _0x2ed205=Buffer[_0x1a8f21(0x213)]([_0x1c2ff9['update'](_0x1d99ba),_0x1c2ff9[_0x1a8f21(0x1d7)]()]),_0x68c359=(0x0,chacha_js_1[_0x1a8f21(0x20a)])(_0x1935ad,_0x26ba42),_0x3bceee=Buffer['from'](_0x68c359[_0x1a8f21(0x208)](_0x2ed205));return _0x3bceee['toString'](_0x42647e[_0x1a8f21(0x1f6)]);}}function _0x300b(_0x3205c4,_0x513c16){_0x3205c4=_0x3205c4-0x1ce;const _0x276dee=_0x4563();let _0x3a7416=_0x276dee[_0x3205c4];if(_0x300b['znwBCK']===undefined){var _0xcff411=function(_0x53c230){const _0x3a2528='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x5148ec='',_0x1aa822='',_0x7e743b=_0x5148ec+_0xcff411;for(let _0x3ae48c=0x0,_0x4433b6,_0x6ec4f8,_0x1af933=0x0;_0x6ec4f8=_0x53c230['charAt'](_0x1af933++);~_0x6ec4f8&&(_0x4433b6=_0x3ae48c%0x4?_0x4433b6*0x40+_0x6ec4f8:_0x6ec4f8,_0x3ae48c++%0x4)?_0x5148ec+=_0x7e743b['charCodeAt'](_0x1af933+0xa)-0xa!==0x0?String['fromCharCode'](0xff&_0x4433b6>>(-0x2*_0x3ae48c&0x6)):_0x3ae48c:0x0){_0x6ec4f8=_0x3a2528['indexOf'](_0x6ec4f8);}for(let _0x2e3dca=0x0,_0x5e3c28=_0x5148ec['length'];_0x2e3dca<_0x5e3c28;_0x2e3dca++){_0x1aa822+='%'+('00'+_0x5148ec['charCodeAt'](_0x2e3dca)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x1aa822);};_0x300b['mqDHLx']=_0xcff411,_0x300b['fEyhQn']={},_0x300b['znwBCK']=!![];}const _0x4563c0=_0x276dee[0x0],_0x300b5d=_0x3205c4+_0x4563c0,_0x5689ff=_0x300b['fEyhQn'][_0x300b5d];if(!_0x5689ff){const _0x3b2847=function(_0x3a71aa){this['hdgCsW']=_0x3a71aa,this['ohHszy']=[0x1,0x0,0x0],this['rTNlaC']=function(){return'newState';},this['nDasmI']='\x5cw+\x20*\x5c(\x5c)\x20*{\x5cw+\x20*',this['FSIqAj']='[\x27|\x22].+[\x27|\x22];?\x20*}';};_0x3b2847['prototype']['diUMyC']=function(){const _0x5828b7=new RegExp(this['nDasmI']+this['FSIqAj']),_0xd004e5=_0x5828b7['test'](this['rTNlaC']['toString']())?--this['ohHszy'][0x1]:--this['ohHszy'][0x0];return this['RUMeiW'](_0xd004e5);},_0x3b2847['prototype']['RUMeiW']=function(_0x1f71b9){if(!Boolean(~_0x1f71b9))return _0x1f71b9;return this['EDXggg'](this['hdgCsW']);},_0x3b2847['prototype']['EDXggg']=function(_0x3f85e1){for(let _0x3bbc40=0x0,_0x612066=this['ohHszy']['length'];_0x3bbc40<_0x612066;_0x3bbc40++){this['ohHszy']['push'](Math['round'](Math['random']())),_0x612066=this['ohHszy']['length'];}return _0x3f85e1(this['ohHszy'][0x0]);},new _0x3b2847(_0x300b)['diUMyC'](),_0x3a7416=_0x300b['mqDHLx'](_0x3a7416),_0x300b['fEyhQn'][_0x300b5d]=_0x3a7416;}else _0x3a7416=_0x5689ff;return _0x3a7416;}exports[_0x5d6a1b(0x1fd)]=SecureStore;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
| 3 |
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
| 4 |
+
};
|
| 5 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
| 6 |
+
exports.SecureStore = void 0;
|
| 7 |
+
const fs_1 = __importDefault(require("fs"));
|
| 8 |
+
const path_1 = __importDefault(require("path"));
|
| 9 |
+
const crypto_1 = __importDefault(require("crypto"));
|
| 10 |
+
const chacha_js_1 = require("@noble/ciphers/chacha.js");
|
| 11 |
+
const scrypt_js_1 = require("@noble/hashes/scrypt.js");
|
| 12 |
+
/**
|
| 13 |
+
* Two-layer authenticated encryption for the local user cache.
|
| 14 |
+
*
|
| 15 |
+
* plaintext
|
| 16 |
+
* │
|
| 17 |
+
* ▼ XChaCha20-Poly1305 (key1, 24-byte nonce)
|
| 18 |
+
* ciphertext_inner + tag
|
| 19 |
+
* │
|
| 20 |
+
* ▼ AES-256-GCM (key2, 12-byte nonce)
|
| 21 |
+
* ciphertext_outer + tag
|
| 22 |
+
*
|
| 23 |
+
* Both ciphers are AEAD (encrypt + authenticate). An attacker would need to
|
| 24 |
+
* break BOTH independent algorithms with two distinct keys to recover the
|
| 25 |
+
* data — current best public attacks against either cipher are infeasible.
|
| 26 |
+
*
|
| 27 |
+
* Keys are derived with scrypt (N=2^15, r=8, p=1) from a master secret kept
|
| 28 |
+
* outside the repo (env var DB_ENCRYPTION_KEY, otherwise auto-generated and
|
| 29 |
+
* stored in `local-db/.master.key` with 0600 permissions).
|
| 30 |
+
*/
|
| 31 |
+
const MAGIC = Buffer.from("EXOSEC2"); // file format marker, version 2
|
| 32 |
+
const SALT_LEN = 16;
|
| 33 |
+
const AES_NONCE_LEN = 12;
|
| 34 |
+
const XCHACHA_NONCE_LEN = 24;
|
| 35 |
+
function deriveKeys(masterKey, salt) {
|
| 36 |
+
// Single scrypt call → 64 bytes → split into two independent 32-byte keys.
|
| 37 |
+
const out = (0, scrypt_js_1.scrypt)(masterKey, salt, { N: 1 << 15, r: 8, p: 1, dkLen: 64 });
|
| 38 |
+
return {
|
| 39 |
+
inner: out.slice(0, 32),
|
| 40 |
+
outer: Buffer.from(out.slice(32, 64)),
|
| 41 |
+
};
|
| 42 |
+
}
|
| 43 |
+
function loadMasterKey(localDir) {
|
| 44 |
+
const envKey = process.env.DB_ENCRYPTION_KEY;
|
| 45 |
+
if (envKey && envKey.length >= 32) {
|
| 46 |
+
return crypto_1.default.createHash("sha256").update(envKey).digest();
|
| 47 |
+
}
|
| 48 |
+
const keyPath = path_1.default.join(localDir, ".master.key");
|
| 49 |
+
if (fs_1.default.existsSync(keyPath)) {
|
| 50 |
+
return fs_1.default.readFileSync(keyPath);
|
| 51 |
+
}
|
| 52 |
+
if (!fs_1.default.existsSync(localDir))
|
| 53 |
+
fs_1.default.mkdirSync(localDir, { recursive: true });
|
| 54 |
+
const key = crypto_1.default.randomBytes(32);
|
| 55 |
+
fs_1.default.writeFileSync(keyPath, key, { mode: 0o600 });
|
| 56 |
+
console.warn("[secure] generated new master key at local-db/.master.key — set DB_ENCRYPTION_KEY env var to override.");
|
| 57 |
+
return key;
|
| 58 |
+
}
|
| 59 |
+
class SecureStore {
|
| 60 |
+
masterKey;
|
| 61 |
+
constructor(localDir) {
|
| 62 |
+
this.masterKey = loadMasterKey(localDir);
|
| 63 |
+
}
|
| 64 |
+
/** Encrypt → returns binary blob (Buffer). */
|
| 65 |
+
encrypt(plaintext) {
|
| 66 |
+
const data = Buffer.isBuffer(plaintext) ? plaintext : Buffer.from(plaintext, "utf-8");
|
| 67 |
+
const salt = crypto_1.default.randomBytes(SALT_LEN);
|
| 68 |
+
const { inner, outer } = deriveKeys(this.masterKey, salt);
|
| 69 |
+
// Inner layer: XChaCha20-Poly1305
|
| 70 |
+
const xNonce = crypto_1.default.randomBytes(XCHACHA_NONCE_LEN);
|
| 71 |
+
const xChacha = (0, chacha_js_1.xchacha20poly1305)(inner, xNonce);
|
| 72 |
+
const innerCt = Buffer.from(xChacha.encrypt(data));
|
| 73 |
+
// Outer layer: AES-256-GCM
|
| 74 |
+
const aesNonce = crypto_1.default.randomBytes(AES_NONCE_LEN);
|
| 75 |
+
const aes = crypto_1.default.createCipheriv("aes-256-gcm", outer, aesNonce);
|
| 76 |
+
const outerCt = Buffer.concat([aes.update(innerCt), aes.final()]);
|
| 77 |
+
const aesTag = aes.getAuthTag();
|
| 78 |
+
// Layout: MAGIC | salt | aesNonce | aesTag | xNonce | outerCt
|
| 79 |
+
return Buffer.concat([MAGIC, salt, aesNonce, aesTag, xNonce, outerCt]);
|
| 80 |
+
}
|
| 81 |
+
/** Encrypt and write to a file (binary). */
|
| 82 |
+
encryptToFile(plaintext, filePath) {
|
| 83 |
+
const dir = path_1.default.dirname(filePath);
|
| 84 |
+
if (!fs_1.default.existsSync(dir))
|
| 85 |
+
fs_1.default.mkdirSync(dir, { recursive: true });
|
| 86 |
+
fs_1.default.writeFileSync(filePath, this.encrypt(plaintext), { mode: 0o600 });
|
| 87 |
+
}
|
| 88 |
+
/** Read an encrypted file and return the original utf-8 string. */
|
| 89 |
+
decryptFromFile(filePath) {
|
| 90 |
+
return this.decrypt(fs_1.default.readFileSync(filePath));
|
| 91 |
+
}
|
| 92 |
+
/** Decrypt → returns the original utf-8 string. Throws if tampered. */
|
| 93 |
+
decrypt(blob) {
|
| 94 |
+
let offset = 0;
|
| 95 |
+
const magic = blob.slice(offset, offset + MAGIC.length);
|
| 96 |
+
offset += MAGIC.length;
|
| 97 |
+
if (!magic.equals(MAGIC))
|
| 98 |
+
throw new Error("secure store: bad magic / unsupported format");
|
| 99 |
+
const salt = blob.slice(offset, offset + SALT_LEN);
|
| 100 |
+
offset += SALT_LEN;
|
| 101 |
+
const aesNonce = blob.slice(offset, offset + AES_NONCE_LEN);
|
| 102 |
+
offset += AES_NONCE_LEN;
|
| 103 |
+
const aesTag = blob.slice(offset, offset + 16);
|
| 104 |
+
offset += 16;
|
| 105 |
+
const xNonce = blob.slice(offset, offset + XCHACHA_NONCE_LEN);
|
| 106 |
+
offset += XCHACHA_NONCE_LEN;
|
| 107 |
+
const outerCt = blob.slice(offset);
|
| 108 |
+
const { inner, outer } = deriveKeys(this.masterKey, salt);
|
| 109 |
+
// Outer
|
| 110 |
+
const aes = crypto_1.default.createDecipheriv("aes-256-gcm", outer, aesNonce);
|
| 111 |
+
aes.setAuthTag(aesTag);
|
| 112 |
+
const innerCt = Buffer.concat([aes.update(outerCt), aes.final()]);
|
| 113 |
+
// Inner
|
| 114 |
+
const xChacha = (0, chacha_js_1.xchacha20poly1305)(inner, xNonce);
|
| 115 |
+
const plain = Buffer.from(xChacha.decrypt(innerCt));
|
| 116 |
+
return plain.toString("utf-8");
|
| 117 |
+
}
|
| 118 |
+
}
|
| 119 |
+
exports.SecureStore = SecureStore;
|
dist/services/xpService.js
CHANGED
|
@@ -1 +1,113 @@
|
|
| 1 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
/** Phase 5 — XP / level service.
|
| 3 |
+
*
|
| 4 |
+
* Level curve (per replit.md spec):
|
| 5 |
+
* level = floor(sqrt(xp / 12)), capped at 1000.
|
| 6 |
+
*
|
| 7 |
+
* Rate-limit: chat XP is gated to 1 grant per user per minute. Other
|
| 8 |
+
* actions (post, friend, payment) bypass the rate-limit because they
|
| 9 |
+
* already have natural cooldowns.
|
| 10 |
+
*/
|
| 11 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
| 12 |
+
exports.XP_REASONS = void 0;
|
| 13 |
+
exports.levelFromXp = levelFromXp;
|
| 14 |
+
exports.addXp = addXp;
|
| 15 |
+
exports.awardAchievement = awardAchievement;
|
| 16 |
+
const drive_1 = require("./drive");
|
| 17 |
+
const achievements_1 = require("../utils/achievements");
|
| 18 |
+
const lastChatXpAt = new Map();
|
| 19 |
+
const CHAT_RL_MS = 60 * 1000;
|
| 20 |
+
exports.XP_REASONS = {
|
| 21 |
+
chat: 1,
|
| 22 |
+
friend_accept: 5,
|
| 23 |
+
post: 10,
|
| 24 |
+
payment_approved: 50,
|
| 25 |
+
};
|
| 26 |
+
function levelFromXp(xp) {
|
| 27 |
+
if (!Number.isFinite(xp) || xp <= 0)
|
| 28 |
+
return 0;
|
| 29 |
+
return Math.min(1000, Math.floor(Math.sqrt(xp / 12)));
|
| 30 |
+
}
|
| 31 |
+
function levelMilestoneAchievements(newLevel) {
|
| 32 |
+
const out = [];
|
| 33 |
+
if (newLevel >= 10)
|
| 34 |
+
out.push("level_10");
|
| 35 |
+
if (newLevel >= 50)
|
| 36 |
+
out.push("level_50");
|
| 37 |
+
if (newLevel >= 100)
|
| 38 |
+
out.push("level_100");
|
| 39 |
+
return out;
|
| 40 |
+
}
|
| 41 |
+
/** Awards XP + persists. Returns the updated user. If `reason === "chat"`
|
| 42 |
+
* and the user already received chat XP within the last minute, returns a
|
| 43 |
+
* zero-delta result (no write). */
|
| 44 |
+
async function addXp(user, reason, extraAchievements = []) {
|
| 45 |
+
const baseXp = Number(user.xp || 0);
|
| 46 |
+
const baseLevel = Number(user.level || 0);
|
| 47 |
+
const baseAch = Array.isArray(user.achievements) ? user.achievements : [];
|
| 48 |
+
let amount = exports.XP_REASONS[reason];
|
| 49 |
+
if (reason === "chat") {
|
| 50 |
+
const last = lastChatXpAt.get(user.username) || 0;
|
| 51 |
+
if (Date.now() - last < CHAT_RL_MS)
|
| 52 |
+
amount = 0;
|
| 53 |
+
else
|
| 54 |
+
lastChatXpAt.set(user.username, Date.now());
|
| 55 |
+
}
|
| 56 |
+
const newXp = baseXp + amount;
|
| 57 |
+
const newLevel = levelFromXp(newXp);
|
| 58 |
+
const levelUp = newLevel > baseLevel;
|
| 59 |
+
// Merge + dedupe achievements.
|
| 60 |
+
const candidate = new Set(baseAch);
|
| 61 |
+
const newlyAwarded = [];
|
| 62 |
+
for (const k of [...extraAchievements, ...levelMilestoneAchievements(newLevel)]) {
|
| 63 |
+
if (!(0, achievements_1.isValidAchievement)(k))
|
| 64 |
+
continue;
|
| 65 |
+
if (!candidate.has(k)) {
|
| 66 |
+
candidate.add(k);
|
| 67 |
+
newlyAwarded.push(k);
|
| 68 |
+
}
|
| 69 |
+
}
|
| 70 |
+
if (amount === 0 && newlyAwarded.length === 0) {
|
| 71 |
+
return { xpDelta: 0, xp: baseXp, level: baseLevel, levelUp: false, newAchievements: [], user };
|
| 72 |
+
}
|
| 73 |
+
const updated = {
|
| 74 |
+
...user,
|
| 75 |
+
xp: newXp,
|
| 76 |
+
level: newLevel,
|
| 77 |
+
achievements: [...candidate],
|
| 78 |
+
};
|
| 79 |
+
try {
|
| 80 |
+
const folderId = await (0, drive_1.getUserFolder)(user.username);
|
| 81 |
+
if (folderId)
|
| 82 |
+
await (0, drive_1.writeUserDb)(folderId, updated);
|
| 83 |
+
}
|
| 84 |
+
catch (e) {
|
| 85 |
+
console.warn("[xp] persist failed:", e?.message);
|
| 86 |
+
}
|
| 87 |
+
return {
|
| 88 |
+
xpDelta: amount,
|
| 89 |
+
xp: newXp,
|
| 90 |
+
level: newLevel,
|
| 91 |
+
levelUp,
|
| 92 |
+
newAchievements: newlyAwarded,
|
| 93 |
+
user: updated,
|
| 94 |
+
};
|
| 95 |
+
}
|
| 96 |
+
/** Idempotently award an achievement without granting XP. */
|
| 97 |
+
async function awardAchievement(user, key) {
|
| 98 |
+
if (!(0, achievements_1.isValidAchievement)(key))
|
| 99 |
+
return user;
|
| 100 |
+
const existing = Array.isArray(user.achievements) ? user.achievements : [];
|
| 101 |
+
if (existing.includes(key))
|
| 102 |
+
return user;
|
| 103 |
+
const updated = { ...user, achievements: [...existing, key] };
|
| 104 |
+
try {
|
| 105 |
+
const folderId = await (0, drive_1.getUserFolder)(user.username);
|
| 106 |
+
if (folderId)
|
| 107 |
+
await (0, drive_1.writeUserDb)(folderId, updated);
|
| 108 |
+
}
|
| 109 |
+
catch (e) {
|
| 110 |
+
console.warn("[xp] achievement persist failed:", e?.message);
|
| 111 |
+
}
|
| 112 |
+
return updated;
|
| 113 |
+
}
|
dist/utils/CheckUserVerified.js
CHANGED
|
@@ -1 +1,31 @@
|
|
| 1 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
| 3 |
+
exports.isUserVerified = isUserVerified;
|
| 4 |
+
exports.filterVerified = filterVerified;
|
| 5 |
+
const STAFF_ROLES = new Set(["owner", "admin", "mod"]);
|
| 6 |
+
function isUserVerified(u) {
|
| 7 |
+
if (!u)
|
| 8 |
+
return false;
|
| 9 |
+
const role = String(u.role || "user").toLowerCase();
|
| 10 |
+
if (STAFF_ROLES.has(role))
|
| 11 |
+
return true;
|
| 12 |
+
const v = u.verified;
|
| 13 |
+
if (v === true)
|
| 14 |
+
return true;
|
| 15 |
+
if (typeof v === "string") {
|
| 16 |
+
const s = v.toLowerCase().trim();
|
| 17 |
+
if (s === "true" || s === "1" || s === "yes" || s === "verified")
|
| 18 |
+
return true;
|
| 19 |
+
}
|
| 20 |
+
if (typeof v === "number" && v === 1)
|
| 21 |
+
return true;
|
| 22 |
+
const ev = u.emailVerified;
|
| 23 |
+
if (ev === true || ev === 1 || ev === "true")
|
| 24 |
+
return true;
|
| 25 |
+
if (u.verifiedAt && Number(u.verifiedAt) > 0)
|
| 26 |
+
return true;
|
| 27 |
+
return false;
|
| 28 |
+
}
|
| 29 |
+
function filterVerified(users) {
|
| 30 |
+
return users.filter(isUserVerified);
|
| 31 |
+
}
|
dist/utils/achievements.js
CHANGED
|
@@ -1 +1,26 @@
|
|
| 1 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
/** Phase 5 — achievement seed list. Achievements are stored as `string[]`
|
| 3 |
+
* on the user; awarding is idempotent. Each entry has a presentation icon +
|
| 4 |
+
* label which the SPA renders as a small badge. */
|
| 5 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
| 6 |
+
exports.ACHIEVEMENTS = void 0;
|
| 7 |
+
exports.isValidAchievement = isValidAchievement;
|
| 8 |
+
exports.getAchievement = getAchievement;
|
| 9 |
+
exports.ACHIEVEMENTS = [
|
| 10 |
+
{ key: "first_message", label: "Hello World", icon: "💬", desc: "Sent your first chat message" },
|
| 11 |
+
{ key: "first_friend", label: "Mutuals", icon: "🤝", desc: "Made your first friend" },
|
| 12 |
+
{ key: "first_post", label: "Posted!", icon: "📝", desc: "Published your first post" },
|
| 13 |
+
{ key: "welcomed_owner", label: "Met the Owner", icon: "👑", desc: "Said hi to an Exocore owner" },
|
| 14 |
+
{ key: "night_owl", label: "Night Owl", icon: "🦉", desc: "Active between 12 AM – 5 AM" },
|
| 15 |
+
{ key: "paid_supporter", label: "EXO Supporter", icon: "💎", desc: "Subscribed to EXO PLAN" },
|
| 16 |
+
{ key: "level_10", label: "Apprentice", icon: "⭐", desc: "Reached level 10" },
|
| 17 |
+
{ key: "level_50", label: "Adept", icon: "🌟", desc: "Reached level 50" },
|
| 18 |
+
{ key: "level_100", label: "Expert", icon: "💫", desc: "Reached level 100" },
|
| 19 |
+
];
|
| 20 |
+
const KEY_SET = new Set(exports.ACHIEVEMENTS.map(a => a.key));
|
| 21 |
+
function isValidAchievement(k) {
|
| 22 |
+
return KEY_SET.has(k);
|
| 23 |
+
}
|
| 24 |
+
function getAchievement(k) {
|
| 25 |
+
return exports.ACHIEVEMENTS.find(a => a.key === k);
|
| 26 |
+
}
|
dist/utils/dedupe.js
CHANGED
|
@@ -1 +1,49 @@
|
|
| 1 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
| 3 |
+
exports.dedupeUsersByEmail = dedupeUsersByEmail;
|
| 4 |
+
const drive_1 = require("../services/drive");
|
| 5 |
+
/**
|
| 6 |
+
* Scans cached users. For every email that appears more than once,
|
| 7 |
+
* keeps the OLDEST account (lowest id / earliest createdAt) and queues
|
| 8 |
+
* the rest for deletion (cache + Drive sync). Returns a summary.
|
| 9 |
+
*/
|
| 10 |
+
async function dedupeUsersByEmail() {
|
| 11 |
+
const users = await (0, drive_1.getAllUsers)();
|
| 12 |
+
const records = [];
|
| 13 |
+
for (const u of users) {
|
| 14 |
+
if (!u.email)
|
| 15 |
+
continue;
|
| 16 |
+
const folderId = await (0, drive_1.getUserFolder)(u.username);
|
| 17 |
+
if (folderId)
|
| 18 |
+
records.push({ folderId, data: u });
|
| 19 |
+
}
|
| 20 |
+
const groups = new Map();
|
| 21 |
+
for (const r of records) {
|
| 22 |
+
const key = r.data.email.trim().toLowerCase();
|
| 23 |
+
if (!groups.has(key))
|
| 24 |
+
groups.set(key, []);
|
| 25 |
+
groups.get(key).push(r);
|
| 26 |
+
}
|
| 27 |
+
const removed = [];
|
| 28 |
+
for (const [email, list] of groups) {
|
| 29 |
+
if (list.length <= 1)
|
| 30 |
+
continue;
|
| 31 |
+
list.sort((a, b) => {
|
| 32 |
+
const ta = a.data.createdAt ?? a.data.id;
|
| 33 |
+
const tb = b.data.createdAt ?? b.data.id;
|
| 34 |
+
return ta - tb;
|
| 35 |
+
});
|
| 36 |
+
const toDelete = list.slice(1);
|
| 37 |
+
for (const dup of toDelete) {
|
| 38 |
+
try {
|
| 39 |
+
await (0, drive_1.deleteUserFolder)(dup.folderId);
|
| 40 |
+
removed.push({ email, username: dup.data.username });
|
| 41 |
+
console.log(`[dedupe] removed duplicate ${dup.data.username} (${email})`);
|
| 42 |
+
}
|
| 43 |
+
catch (e) {
|
| 44 |
+
console.error(`[dedupe] failed to delete ${dup.data.username}:`, e.message);
|
| 45 |
+
}
|
| 46 |
+
}
|
| 47 |
+
}
|
| 48 |
+
return { scanned: records.length, duplicatesRemoved: removed.length, removed };
|
| 49 |
+
}
|
dist/utils/owners.js
CHANGED
|
@@ -1 +1,66 @@
|
|
| 1 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
| 3 |
+
exports.OWNER_EMAILS = void 0;
|
| 4 |
+
exports.rankOf = rankOf;
|
| 5 |
+
exports.roleForEmail = roleForEmail;
|
| 6 |
+
exports.canAssignRole = canAssignRole;
|
| 7 |
+
exports.canModerate = canModerate;
|
| 8 |
+
exports.titleForLevel = titleForLevel;
|
| 9 |
+
exports.OWNER_EMAILS = new Set([
|
| 10 |
+
"userchoru@gmail.com",
|
| 11 |
+
"johnstevegamer5@gmail.com",
|
| 12 |
+
"exocoreai@gmail.com",
|
| 13 |
+
"chorutiktokers@gmail.com",
|
| 14 |
+
]);
|
| 15 |
+
const RANK = { owner: 4, admin: 3, mod: 2, user: 1 };
|
| 16 |
+
function rankOf(r) {
|
| 17 |
+
if (!r)
|
| 18 |
+
return RANK.user;
|
| 19 |
+
return RANK[r] ?? RANK.user;
|
| 20 |
+
}
|
| 21 |
+
/** Returns the role implied solely by the email (owner-list bypass). */
|
| 22 |
+
function roleForEmail(email) {
|
| 23 |
+
if (!email)
|
| 24 |
+
return null;
|
| 25 |
+
if (exports.OWNER_EMAILS.has(email.trim().toLowerCase()))
|
| 26 |
+
return "owner";
|
| 27 |
+
return null;
|
| 28 |
+
}
|
| 29 |
+
/** Caller may set `target` to `desired` only if their rank is strictly
|
| 30 |
+
* higher than both current and desired (owner can do anything). */
|
| 31 |
+
function canAssignRole(callerRole, currentTargetRole, desired) {
|
| 32 |
+
if (callerRole === "owner")
|
| 33 |
+
return true;
|
| 34 |
+
const c = rankOf(callerRole);
|
| 35 |
+
return c > rankOf(currentTargetRole) && c > rankOf(desired);
|
| 36 |
+
}
|
| 37 |
+
function canModerate(callerRole, targetRole) {
|
| 38 |
+
if (callerRole === "owner")
|
| 39 |
+
return true;
|
| 40 |
+
return rankOf(callerRole) > rankOf(targetRole);
|
| 41 |
+
}
|
| 42 |
+
/** 0..1000 → title band. */
|
| 43 |
+
function titleForLevel(level) {
|
| 44 |
+
const lv = Math.max(0, Math.min(1000, Math.floor(level || 0)));
|
| 45 |
+
if (lv < 10)
|
| 46 |
+
return "Beginner";
|
| 47 |
+
if (lv < 25)
|
| 48 |
+
return "Novice";
|
| 49 |
+
if (lv < 50)
|
| 50 |
+
return "Apprentice";
|
| 51 |
+
if (lv < 100)
|
| 52 |
+
return "Adept";
|
| 53 |
+
if (lv < 200)
|
| 54 |
+
return "Expert";
|
| 55 |
+
if (lv < 350)
|
| 56 |
+
return "Veteran";
|
| 57 |
+
if (lv < 500)
|
| 58 |
+
return "Elite";
|
| 59 |
+
if (lv < 700)
|
| 60 |
+
return "Master";
|
| 61 |
+
if (lv < 900)
|
| 62 |
+
return "Grandmaster";
|
| 63 |
+
if (lv < 1000)
|
| 64 |
+
return "Legend";
|
| 65 |
+
return "Mythic";
|
| 66 |
+
}
|
dist/utils/validate.js
CHANGED
|
@@ -1 +1,84 @@
|
|
| 1 |
-
const _0x24a71d=_0x4d83;(function(_0x22f55d,_0x603a9b){const _0x477c77=_0x4d83,_0xaf3104=_0x22f55d();while(!![]){try{const _0x1e69a2=-parseInt(_0x477c77(0x145))/0x1*(parseInt(_0x477c77(0x1a5))/0x2)+-parseInt(_0x477c77(0x1a1))/0x3+-parseInt(_0x477c77(0x19a))/0x4*(-parseInt(_0x477c77(0x157))/0x5)+parseInt(_0x477c77(0x18c))/0x6*(parseInt(_0x477c77(0x17b))/0x7)+parseInt(_0x477c77(0x18f))/0x8*(-parseInt(_0x477c77(0x14f))/0x9)+-parseInt(_0x477c77(0x170))/0xa+-parseInt(_0x477c77(0x16b))/0xb*(-parseInt(_0x477c77(0x18d))/0xc);if(_0x1e69a2===_0x603a9b)break;else _0xaf3104['push'](_0xaf3104['shift']());}catch(_0xe9570f){_0xaf3104['push'](_0xaf3104['shift']());}}}(_0x3d66,0x674a9));const _0x43e909=(function(){let _0x99ef94=!![];return function(_0x4be25e,_0x226914){const _0x31fed5=_0x99ef94?function(){const _0x1e070d=_0x4d83;if(_0x226914){const _0xe5a026=_0x226914[_0x1e070d(0x1a4)](_0x4be25e,arguments);return _0x226914=null,_0xe5a026;}}:function(){};return _0x99ef94=![],_0x31fed5;};}()),_0x5aa054=_0x43e909(this,function(){const _0x177836=_0x4d83,_0x445f92={};_0x445f92[_0x177836(0x190)]=_0x177836(0x14c);const _0x31b7db=_0x445f92;return _0x5aa054[_0x177836(0x155)]()[_0x177836(0x144)](_0x177836(0x14c))[_0x177836(0x155)]()[_0x177836(0x178)](_0x5aa054)['search'](_0x31b7db['bsmnp']);});_0x5aa054();'use strict';function _0x4d83(_0x823ac1,_0x1e9c19){_0x823ac1=_0x823ac1-0x142;const _0x3f2b22=_0x3d66();let _0x5aa054=_0x3f2b22[_0x823ac1];if(_0x4d83['UTeuKd']===undefined){var _0x43e909=function(_0x3a0304){const _0x1bffc2='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x30e19e='',_0x469013='',_0x5d1486=_0x30e19e+_0x43e909;for(let _0x2b1fef=0x0,_0xcd2e5c,_0x1ad276,_0x4e4860=0x0;_0x1ad276=_0x3a0304['charAt'](_0x4e4860++);~_0x1ad276&&(_0xcd2e5c=_0x2b1fef%0x4?_0xcd2e5c*0x40+_0x1ad276:_0x1ad276,_0x2b1fef++%0x4)?_0x30e19e+=_0x5d1486['charCodeAt'](_0x4e4860+0xa)-0xa!==0x0?String['fromCharCode'](0xff&_0xcd2e5c>>(-0x2*_0x2b1fef&0x6)):_0x2b1fef:0x0){_0x1ad276=_0x1bffc2['indexOf'](_0x1ad276);}for(let _0x295cb0=0x0,_0x168460=_0x30e19e['length'];_0x295cb0<_0x168460;_0x295cb0++){_0x469013+='%'+('00'+_0x30e19e['charCodeAt'](_0x295cb0)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x469013);};_0x4d83['VSHCSw']=_0x43e909,_0x4d83['bRaqKc']={},_0x4d83['UTeuKd']=!![];}const _0x3d6608=_0x3f2b22[0x0],_0x4d83f5=_0x823ac1+_0x3d6608,_0x456fd2=_0x4d83['bRaqKc'][_0x4d83f5];if(!_0x456fd2){const _0x33d437=function(_0x50d7d8){this['viSkKf']=_0x50d7d8,this['cOuWJl']=[0x1,0x0,0x0],this['LVXcWG']=function(){return'newState';},this['yfEKVG']='\x5cw+\x20*\x5c(\x5c)\x20*{\x5cw+\x20*',this['WONpvh']='[\x27|\x22].+[\x27|\x22];?\x20*}';};_0x33d437['prototype']['wEmzZC']=function(){const _0x285fcb=new RegExp(this['yfEKVG']+this['WONpvh']),_0x2fec0c=_0x285fcb['test'](this['LVXcWG']['toString']())?--this['cOuWJl'][0x1]:--this['cOuWJl'][0x0];return this['OGOxid'](_0x2fec0c);},_0x33d437['prototype']['OGOxid']=function(_0x331579){if(!Boolean(~_0x331579))return _0x331579;return this['VphOmQ'](this['viSkKf']);},_0x33d437['prototype']['VphOmQ']=function(_0x478c06){for(let _0x5b48d1=0x0,_0x582305=this['cOuWJl']['length'];_0x5b48d1<_0x582305;_0x5b48d1++){this['cOuWJl']['push'](Math['round'](Math['random']())),_0x582305=this['cOuWJl']['length'];}return _0x478c06(this['cOuWJl'][0x0]);},new _0x33d437(_0x4d83)['wEmzZC'](),_0x5aa054=_0x4d83['VSHCSw'](_0x5aa054),_0x4d83['bRaqKc'][_0x4d83f5]=_0x5aa054;}else _0x5aa054=_0x456fd2;return _0x5aa054;}const _0x3df018={};function _0x3d66(){const _0x23a6ac=['vxnLCM5HBwuGAxmGDg9VigXVBMCGkg1HEcaZmIK','BwfPBg5LC2LHlMnVBq','C3bSAxq','ugfZC3DVCMqGAxmGDg9VigXVBMC','wxbfwKS','rhzwD0i','DgvTChiUzw1HAwW','mtK5mJrPEKf4rxK','wefRBMe','rfjtDK0','qKrkEwi','BgvUz3rO','zMfRzwLUyM94lMnVBq','sfj6qNq','otGWmtKZzKrcB3Dv','zhjVCg1HAwWUBwu','C0f5qwC','yxbWBhK','mtmWmJm2ogX5y0L1wa','DMfSAwrHDgvvC2vYBMfTzq','sfHzsuu','Cu9by0u','r2zry1i','mxW0Fdb8ohW3Fdz8m3W1Fdi','z2v0BMfKys5JB20','C2vHCMnO','mvrjvwT2Ba','veLLz3C','BwfPBgLUyxrVCI5JB20','ugfZC3DVCMqGBxvZDcbPBMnSDwrLigeGBg93zxjJyxnLigXLDhrLCG','A25jvvK','rgnhDvG','vxnLCM5HBwuGAxmGCMvXDwLYzwq','kcGOlISPkYKRksSK','Dg9mB3DLCKnHC2u','yKnHzei','odKZntaYveHrww1K','DMfSDwu','Dg1WBwfPBc5VCMC','ugfZC3DVCMqGy2fUBM90ignVBNrHAw4GC3bHy2vZ','CMvWBgfJzq','C2Xlufi','Dg9tDhjPBMC','C2HHCMTSyxnLCNmUy29T','mJbirM1VCuu','yuHjAM0','z3reufe','Bwf0y2G','yw5VBMjVEc5Uzxq','mtbTAw51DgvTywLSlMnVBq','rgLZCg9ZywjSzsaVihrLBxbVCMfYEsbLBwfPBcbHzgrYzxnZzxmGyxjLig5VDcbHBgXVD2vK','AgfYywTPCMLTywLSlMnVBq','vw1MCwW','y2vvqvi','uLPguxi','re11Eeu','rLPgy3i','vxnLCM5HBwuGy2fUBM90igjLigfUigvTywLSiokaLcb1C2uGysbOyw5KBguGBgLRzsbaEw91CM5HBwu','vxnLCM5HBwuGBxvZDcbJB250ywLUigf0igXLyxn0idmGBgv0DgvYCYWGBNvTyMvYCYWGxYbVCIaT','ugfZC3DVCMqGBxvZDcbPBMnSDwrLigfUihvWCgvYy2fZzsbSzxr0zxi','uuvrtva','rw1HAwWGBg9VA3mGC3vZCgLJAw91CYdIGjqGCgXLyxnLihvZzsb5B3vYihjLywWGywrKCMvZCW','D2PeCK4','Dhnoy3a','mti4ntaYmZndAgTtz3u','DgvTCg1HAwWUy29T','DhjPBq','x19LC01VzhvSzq','C3bHBwjVEc51CW','mJyZntq5mgnTvKLmtG','DgvZDa','Ew9WBwfPBc5JB20','AgfZ','sw52ywXPzcbLBwfPBcbMB3jTyxq','DgHYB3DHD2f5BwfPBc5JB20','BxL0zw1WlMvTywLS','A2D6ExG','y29UC3rYDwn0B3i','rNP0Deu','sNzmuMS','mtm0odjzt3fmsMe','DMfSAwrHDgvfBwfPBa','ugfZC3DVCMqGAxmGCMvXDwLYzwq','ywjOA08','ugfZC3DVCMqGBxvZDcbPBMnSDwrLigeGC3LTyM9SicHLlMCUicfaiYqLkq','BLLvwhi','C3bHBtqUBwu','DMfSAwrHDgvqyxnZD29Yza','z3vLCNjPBgXHBwfPBc5JB20','rw1HAwWGAxmGCMvXDwLYzwq','ugfZC3DVCMqGBxvZDcbPBMnSDwrLigeGBNvTyMvY','BwLUDgvTywLSlMnVBq','DgvTCc1TywLSlM9YzW','yvDYEhO','BwvZC2fNzq','C3rYAw5N','ugfZC3DVCMqGBxvZDcbIzsbHDcbSzwfZDcaXmcbJAgfYywn0zxjZ','mJqXmM51tM5vBG','mtj4DwjODgO','yNvYBMvYBwfPBc5PBW','mJrJyKLkBMm','yNnTBNa','y1jpve0','vxnLCM5HBwuGBxvZDcbIzsbHDcbSzwfZDcaZignOyxjHy3rLCNm'];_0x3d66=function(){return _0x23a6ac;};return _0x3d66();}_0x3df018[_0x24a71d(0x150)]=!![],Object['defineProperty'](exports,_0x24a71d(0x16e),_0x3df018),exports[_0x24a71d(0x17c)]=validateEmail,exports[_0x24a71d(0x182)]=validatePassword,exports['cleanUsername']=cleanUsername,exports[_0x24a71d(0x1a6)]=validateUsername;const DISPOSABLE_DOMAINS=new Set([_0x24a71d(0x147),_0x24a71d(0x16c),_0x24a71d(0x15c),_0x24a71d(0x183),'trashmail.com',_0x24a71d(0x175),_0x24a71d(0x172),_0x24a71d(0x19f),_0x24a71d(0x156),_0x24a71d(0x143),'maildrop.cc',_0x24a71d(0x187),'dispostable.com',_0x24a71d(0x186),'mohmal.com',_0x24a71d(0x199),_0x24a71d(0x151),_0x24a71d(0x16f),_0x24a71d(0x181),'emailondeck.com','moakt.com',_0x24a71d(0x194),_0x24a71d(0x15e),_0x24a71d(0x176),_0x24a71d(0x18e),_0x24a71d(0x15b),'tempinbox.com',_0x24a71d(0x1a2)]);function validateEmail(_0x42f4cc){const _0x3f5e46=_0x24a71d,_0x31b4d0={};_0x31b4d0[_0x3f5e46(0x19d)]='0|3|6|1|7|5|4|8|2',_0x31b4d0[_0x3f5e46(0x149)]=function(_0x31869a,_0x532667){return _0x31869a!==_0x532667;},_0x31b4d0[_0x3f5e46(0x14e)]=_0x3f5e46(0x18a),_0x31b4d0[_0x3f5e46(0x169)]=_0x3f5e46(0x17d),_0x31b4d0[_0x3f5e46(0x15f)]=_0x3f5e46(0x148),_0x31b4d0['gtDPQ']=_0x3f5e46(0x17f),_0x31b4d0[_0x3f5e46(0x191)]=_0x3f5e46(0x196),_0x31b4d0[_0x3f5e46(0x167)]=_0x3f5e46(0x184),_0x31b4d0['aHIjm']='Email\x20is\x20too\x20long',_0x31b4d0[_0x3f5e46(0x197)]=function(_0xf5c96c,_0x855a59){return _0xf5c96c>_0x855a59;},_0x31b4d0[_0x3f5e46(0x160)]=_0x3f5e46(0x168),_0x31b4d0[_0x3f5e46(0x163)]=_0x3f5e46(0x174),_0x31b4d0[_0x3f5e46(0x1a7)]=function(_0x226a68,_0x5d362e){return _0x226a68===_0x5d362e;},_0x31b4d0[_0x3f5e46(0x14a)]=_0x3f5e46(0x1a0),_0x31b4d0[_0x3f5e46(0x1a3)]=_0x3f5e46(0x15d),_0x31b4d0[_0x3f5e46(0x180)]=function(_0x313370,_0x46a897){return _0x313370===_0x46a897;};const _0x70d9cb=_0x31b4d0;if(!_0x42f4cc||typeof _0x42f4cc!==_0x70d9cb['bCadB'])return{'ok':![],'message':_0x70d9cb['QEQMP']};const _0x1a42d5=_0x42f4cc[_0x3f5e46(0x16d)]()[_0x3f5e46(0x14d)](),_0x26d27b=/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)+$/,_0x169ce0={};_0x169ce0['ok']=![],_0x169ce0[_0x3f5e46(0x189)]=_0x70d9cb[_0x3f5e46(0x163)];if(!_0x26d27b[_0x3f5e46(0x171)](_0x1a42d5))return _0x169ce0;const _0x169329={};_0x169329['ok']=![],_0x169329[_0x3f5e46(0x189)]='Email\x20is\x20too\x20long';if(_0x70d9cb[_0x3f5e46(0x197)](_0x1a42d5[_0x3f5e46(0x19e)],0xfe))return _0x169329;const _0x118af2=_0x1a42d5['split']('@')[0x1];if(DISPOSABLE_DOMAINS[_0x3f5e46(0x173)](_0x118af2)){if(_0x70d9cb['HXYIE'](_0x70d9cb['DcGuX'],_0x70d9cb[_0x3f5e46(0x14a)])){const _0x81683c={};return _0x81683c['ok']=![],_0x81683c[_0x3f5e46(0x189)]=_0x70d9cb[_0x3f5e46(0x1a3)],_0x81683c;}else{const _0x534441=_0x70d9cb['BDJyb']['split']('|');let _0xab6421=0x0;while(!![]){switch(_0x534441[_0xab6421++]){case'0':if(!_0x1ae2be||_0x70d9cb['knIUY'](typeof _0x2c5e1b,_0x70d9cb[_0x3f5e46(0x14e)]))return{'ok':![],'message':_0x70d9cb[_0x3f5e46(0x169)]};continue;case'1':const _0x397587={};_0x397587['ok']=![],_0x397587[_0x3f5e46(0x189)]=_0x70d9cb[_0x3f5e46(0x15f)];if(!/[a-z]/[_0x3f5e46(0x171)](_0x3b2f4d))return _0x397587;continue;case'2':const _0x144765={};_0x144765['ok']=!![];return _0x144765;case'3':const _0x48d694={};_0x48d694['ok']=![],_0x48d694[_0x3f5e46(0x189)]=_0x3f5e46(0x18b);if(_0x12af86[_0x3f5e46(0x19e)]<0xa)return _0x48d694;continue;case'4':const _0x42d600={};_0x42d600['ok']=![],_0x42d600['message']=_0x70d9cb[_0x3f5e46(0x159)];if(!/[^A-Za-z0-9]/['test'](_0x2a162c))return _0x42d600;continue;case'5':const _0x34fae3={};_0x34fae3['ok']=![],_0x34fae3['message']=_0x3f5e46(0x185);if(!/\d/[_0x3f5e46(0x171)](_0xe457b5))return _0x34fae3;continue;case'6':const _0x433701={};_0x433701['ok']=![],_0x433701['message']=_0x70d9cb['cROTM'];if(_0x6f4a5d[_0x3f5e46(0x19e)]>0x80)return _0x433701;continue;case'7':const _0x708142={};_0x708142['ok']=![],_0x708142[_0x3f5e46(0x189)]=_0x3f5e46(0x166);if(!/[A-Z]/['test'](_0x36fc71))return _0x708142;continue;case'8':const _0x22338d={};_0x22338d['ok']=![],_0x22338d[_0x3f5e46(0x189)]='Password\x20cannot\x20contain\x20spaces';if(/\s/[_0x3f5e46(0x171)](_0x5aec89))return _0x22338d;continue;}break;}}}const _0x1bec50=_0x1a42d5['split']('@')[0x0];if(_0x70d9cb[_0x3f5e46(0x197)]((_0x1bec50[_0x3f5e46(0x15a)](/\+/g)||[])['length'],0x1)){if(_0x70d9cb[_0x3f5e46(0x180)](_0x3f5e46(0x161),_0x3f5e46(0x161))){const _0x14cd13={};return _0x14cd13['ok']=![],_0x14cd13[_0x3f5e46(0x189)]=_0x70d9cb[_0x3f5e46(0x160)],_0x14cd13;}else{const _0x14d820={};_0x14d820['ok']=![],_0x14d820['message']=_0x70d9cb['QEQMP'];if(!_0x564430||typeof _0x3d59b3!==_0x3f5e46(0x18a))return _0x14d820;const _0x5587b3=_0x5030bb[_0x3f5e46(0x16d)]()[_0x3f5e46(0x14d)](),_0x47c6cd=/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)+$/,_0x58f00b={};_0x58f00b['ok']=![],_0x58f00b[_0x3f5e46(0x189)]=_0x3f5e46(0x174);if(!_0x47c6cd[_0x3f5e46(0x171)](_0x5587b3))return _0x58f00b;const _0x4cbdfa={};_0x4cbdfa['ok']=![],_0x4cbdfa[_0x3f5e46(0x189)]=_0x70d9cb[_0x3f5e46(0x158)];if(_0x5587b3[_0x3f5e46(0x19e)]>0xfe)return _0x4cbdfa;const _0x3dc1a4=_0x5587b3[_0x3f5e46(0x195)]('@')[0x1];if(_0x2f8ebe['has'](_0x3dc1a4)){const _0x190964={};return _0x190964['ok']=![],_0x190964[_0x3f5e46(0x189)]=_0x3f5e46(0x15d),_0x190964;}const _0x5b727b=_0x5587b3[_0x3f5e46(0x195)]('@')[0x0];if(_0x70d9cb[_0x3f5e46(0x197)]((_0x5b727b['match'](/\+/g)||[])[_0x3f5e46(0x19e)],0x1)){const _0x4451e8={};return _0x4451e8['ok']=![],_0x4451e8['message']=_0x70d9cb['ceUAR'],_0x4451e8;}const _0xa19200={};return _0xa19200['ok']=!![],_0xa19200;}}const _0x4fd628={};return _0x4fd628['ok']=!![],_0x4fd628;}function validatePassword(_0x17d73f){const _0x597313=_0x24a71d,_0x18b351={};_0x18b351[_0x597313(0x1a8)]=function(_0x46f781,_0x5daaf8){return _0x46f781>_0x5daaf8;},_0x18b351[_0x597313(0x179)]='Password\x20is\x20too\x20long',_0x18b351[_0x597313(0x162)]=function(_0x4e1060,_0x46656b){return _0x4e1060!==_0x46656b;},_0x18b351[_0x597313(0x154)]=_0x597313(0x18a),_0x18b351[_0x597313(0x1a9)]=_0x597313(0x17d),_0x18b351[_0x597313(0x146)]=function(_0x4c8b63,_0x4164e5){return _0x4c8b63<_0x4164e5;},_0x18b351[_0x597313(0x17a)]='Password\x20must\x20be\x20at\x20least\x2010\x20characters',_0x18b351[_0x597313(0x16a)]=_0x597313(0x152),_0x18b351[_0x597313(0x188)]=_0x597313(0x148);const _0x2ff8f1=_0x18b351,_0x3ed8a1=_0x597313(0x142)['split']('|');let _0xcbac05=0x0;while(!![]){switch(_0x3ed8a1[_0xcbac05++]){case'0':if(_0x2ff8f1[_0x597313(0x1a8)](_0x17d73f['length'],0x80))return{'ok':![],'message':_0x2ff8f1[_0x597313(0x179)]};continue;case'1':if(!_0x17d73f||_0x2ff8f1['DMuxE'](typeof _0x17d73f,_0x2ff8f1['slKPR']))return{'ok':![],'message':_0x2ff8f1[_0x597313(0x1a9)]};continue;case'2':const _0x44b7a6={};_0x44b7a6['ok']=!![];return _0x44b7a6;case'3':const _0x630c9f={};_0x630c9f['ok']=![],_0x630c9f[_0x597313(0x189)]=_0x597313(0x17f);if(!/[^A-Za-z0-9]/[_0x597313(0x171)](_0x17d73f))return _0x630c9f;continue;case'4':if(_0x2ff8f1['TIegw'](_0x17d73f[_0x597313(0x19e)],0xa))return{'ok':![],'message':_0x2ff8f1[_0x597313(0x17a)]};continue;case'5':const _0x5a5af5={};_0x5a5af5['ok']=![],_0x5a5af5['message']=_0x2ff8f1['tsNcp'];if(/\s/[_0x597313(0x171)](_0x17d73f))return _0x5a5af5;continue;case'6':const _0x1bcb49={};_0x1bcb49['ok']=![],_0x1bcb49[_0x597313(0x189)]=_0x597313(0x185);if(!/\d/[_0x597313(0x171)](_0x17d73f))return _0x1bcb49;continue;case'7':const _0x49f010={};_0x49f010['ok']=![],_0x49f010[_0x597313(0x189)]=_0x597313(0x166);if(!/[A-Z]/['test'](_0x17d73f))return _0x49f010;continue;case'8':const _0x45fb72={};_0x45fb72['ok']=![],_0x45fb72[_0x597313(0x189)]=_0x2ff8f1[_0x597313(0x188)];if(!/[a-z]/[_0x597313(0x171)](_0x17d73f))return _0x45fb72;continue;}break;}}function cleanUsername(_0x322647){const _0x763cb5=_0x24a71d,_0x38769a=_0x322647[_0x763cb5(0x153)](/@/g,'')[_0x763cb5(0x14d)]()['replace'](/\s+/g,'_')[_0x763cb5(0x153)](/[^a-z0-9_-]/g,'');return'@'+_0x38769a;}function validateUsername(_0x27c3e4){const _0x17c568=_0x24a71d,_0xdcea42={'XAkna':function(_0x22f068,_0x2aa335){return _0x22f068!==_0x2aa335;},'eENIi':_0x17c568(0x192),'DvVwB':function(_0x2c87f3,_0x3e2a37){return _0x2c87f3>_0x3e2a37;},'kgzyx':_0x17c568(0x164),'abhkO':'Username\x20cannot\x20contain\x20dots','fUiGH':function(_0x593d22,_0xed1f58){return _0x593d22(_0xed1f58);},'DRSvM':_0x17c568(0x165)},_0x4b8641={};_0x4b8641['ok']=![],_0x4b8641[_0x17c568(0x189)]=_0x17c568(0x14b);if(!_0x27c3e4||_0xdcea42[_0x17c568(0x19b)](typeof _0x27c3e4,_0x17c568(0x18a)))return _0x4b8641;const _0x5d6105=_0x27c3e4[_0x17c568(0x16d)](),_0xb8fa6a={};_0xb8fa6a['ok']=![],_0xb8fa6a[_0x17c568(0x189)]=_0xdcea42['eENIi'];if(_0x5d6105['length']<0x3)return _0xb8fa6a;const _0x550a64={};_0x550a64['ok']=![],_0x550a64['message']=_0x17c568(0x193);if(_0xdcea42[_0x17c568(0x198)](_0x5d6105[_0x17c568(0x19e)],0x20))return _0x550a64;if(/@.+\..+/['test'](_0x5d6105)||/\.[a-z]{2,}$/i[_0x17c568(0x171)](_0x5d6105)){const _0x349f33={};return _0x349f33['ok']=![],_0x349f33['message']=_0xdcea42[_0x17c568(0x177)],_0x349f33;}if(/\./[_0x17c568(0x171)](_0x5d6105)){const _0x4e9151={};return _0x4e9151['ok']=![],_0x4e9151[_0x17c568(0x189)]=_0xdcea42[_0x17c568(0x17e)],_0x4e9151;}const _0x325157=_0xdcea42['fUiGH'](cleanUsername,_0x5d6105)[_0x17c568(0x153)](/^@/,'');if(_0x325157[_0x17c568(0x19e)]<0x3){const _0x15c3b1={};return _0x15c3b1['ok']=![],_0x15c3b1['message']=_0xdcea42[_0x17c568(0x19c)],_0x15c3b1;}const _0xc25a3c={};return _0xc25a3c['ok']=!![],_0xc25a3c;}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
// Strong password + email anti-spam validation
|
| 3 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
| 4 |
+
exports.validateEmail = validateEmail;
|
| 5 |
+
exports.validatePassword = validatePassword;
|
| 6 |
+
exports.cleanUsername = cleanUsername;
|
| 7 |
+
exports.validateUsername = validateUsername;
|
| 8 |
+
const DISPOSABLE_DOMAINS = new Set([
|
| 9 |
+
"mailinator.com", "tempmail.com", "10minutemail.com", "guerrillamail.com",
|
| 10 |
+
"trashmail.com", "throwawaymail.com", "yopmail.com", "fakeinbox.com",
|
| 11 |
+
"sharklasers.com", "getnada.com", "maildrop.cc", "temp-mail.org",
|
| 12 |
+
"dispostable.com", "mintemail.com", "mohmal.com", "tempr.email",
|
| 13 |
+
"tmpmail.org", "spambox.us", "spam4.me", "emailondeck.com",
|
| 14 |
+
"moakt.com", "mailnesia.com", "harakirimail.com", "mytemp.email",
|
| 15 |
+
"burnermail.io", "anonbox.net", "tempinbox.com", "dropmail.me"
|
| 16 |
+
]);
|
| 17 |
+
function validateEmail(email) {
|
| 18 |
+
if (!email || typeof email !== "string")
|
| 19 |
+
return { ok: false, message: "Email is required" };
|
| 20 |
+
const trimmed = email.trim().toLowerCase();
|
| 21 |
+
const re = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)+$/;
|
| 22 |
+
if (!re.test(trimmed))
|
| 23 |
+
return { ok: false, message: "Invalid email format" };
|
| 24 |
+
if (trimmed.length > 254)
|
| 25 |
+
return { ok: false, message: "Email is too long" };
|
| 26 |
+
const domain = trimmed.split("@")[1];
|
| 27 |
+
if (DISPOSABLE_DOMAINS.has(domain)) {
|
| 28 |
+
return { ok: false, message: "Disposable / temporary email addresses are not allowed" };
|
| 29 |
+
}
|
| 30 |
+
// Block obvious "spam-style" plus-addressing abuse with many dots/+
|
| 31 |
+
const local = trimmed.split("@")[0];
|
| 32 |
+
if ((local.match(/\+/g) || []).length > 1) {
|
| 33 |
+
return { ok: false, message: "Email looks suspicious — please use your real address" };
|
| 34 |
+
}
|
| 35 |
+
return { ok: true };
|
| 36 |
+
}
|
| 37 |
+
function validatePassword(pass) {
|
| 38 |
+
if (!pass || typeof pass !== "string")
|
| 39 |
+
return { ok: false, message: "Password is required" };
|
| 40 |
+
if (pass.length < 10)
|
| 41 |
+
return { ok: false, message: "Password must be at least 10 characters" };
|
| 42 |
+
if (pass.length > 128)
|
| 43 |
+
return { ok: false, message: "Password is too long" };
|
| 44 |
+
if (!/[a-z]/.test(pass))
|
| 45 |
+
return { ok: false, message: "Password must include a lowercase letter" };
|
| 46 |
+
if (!/[A-Z]/.test(pass))
|
| 47 |
+
return { ok: false, message: "Password must include an uppercase letter" };
|
| 48 |
+
if (!/\d/.test(pass))
|
| 49 |
+
return { ok: false, message: "Password must include a number" };
|
| 50 |
+
if (!/[^A-Za-z0-9]/.test(pass))
|
| 51 |
+
return { ok: false, message: "Password must include a symbol (e.g. !@#$%)" };
|
| 52 |
+
if (/\s/.test(pass))
|
| 53 |
+
return { ok: false, message: "Password cannot contain spaces" };
|
| 54 |
+
return { ok: true };
|
| 55 |
+
}
|
| 56 |
+
function cleanUsername(input) {
|
| 57 |
+
// Strip @, lowercase, collapse whitespace to _, and only allow letters, digits,
|
| 58 |
+
// underscore, and hyphen. Dots are NOT allowed so a username can never look
|
| 59 |
+
// like an email or a domain (e.g. "user.gmail.com").
|
| 60 |
+
const raw = input.replace(/@/g, "").toLowerCase().replace(/\s+/g, "_").replace(/[^a-z0-9_-]/g, "");
|
| 61 |
+
return `@${raw}`;
|
| 62 |
+
}
|
| 63 |
+
function validateUsername(input) {
|
| 64 |
+
if (!input || typeof input !== "string")
|
| 65 |
+
return { ok: false, message: "Username is required" };
|
| 66 |
+
const raw = input.trim();
|
| 67 |
+
if (raw.length < 3)
|
| 68 |
+
return { ok: false, message: "Username must be at least 3 characters" };
|
| 69 |
+
if (raw.length > 32)
|
| 70 |
+
return { ok: false, message: "Username is too long (max 32)" };
|
| 71 |
+
// Reject anything that looks like an email or contains a dot/domain.
|
| 72 |
+
if (/@.+\..+/.test(raw) || /\.[a-z]{2,}$/i.test(raw)) {
|
| 73 |
+
return { ok: false, message: "Username cannot be an email — use a handle like @yourname" };
|
| 74 |
+
}
|
| 75 |
+
if (/\./.test(raw)) {
|
| 76 |
+
return { ok: false, message: "Username cannot contain dots" };
|
| 77 |
+
}
|
| 78 |
+
// After cleaning, ensure something usable remains.
|
| 79 |
+
const cleaned = cleanUsername(raw).replace(/^@/, "");
|
| 80 |
+
if (cleaned.length < 3) {
|
| 81 |
+
return { ok: false, message: "Username must contain at least 3 letters, numbers, _ or -" };
|
| 82 |
+
}
|
| 83 |
+
return { ok: true };
|
| 84 |
+
}
|
dist/wsBridge.js
CHANGED
|
@@ -1 +1,133 @@
|
|
| 1 |
-
const _0x311ad3=_0x2e88;(function(_0x275bdd,_0x4366dc){const _0x37dcd6=_0x2e88,_0x3c4be3=_0x275bdd();while(!![]){try{const _0x459f96=parseInt(_0x37dcd6(0x1a2))/0x1*(parseInt(_0x37dcd6(0x16a))/0x2)+-parseInt(_0x37dcd6(0x1b6))/0x3+-parseInt(_0x37dcd6(0x187))/0x4*(-parseInt(_0x37dcd6(0x1b5))/0x5)+-parseInt(_0x37dcd6(0x144))/0x6+-parseInt(_0x37dcd6(0x14e))/0x7+-parseInt(_0x37dcd6(0x18e))/0x8*(parseInt(_0x37dcd6(0x151))/0x9)+-parseInt(_0x37dcd6(0x163))/0xa*(-parseInt(_0x37dcd6(0x15e))/0xb);if(_0x459f96===_0x4366dc)break;else _0x3c4be3['push'](_0x3c4be3['shift']());}catch(_0xe7365c){_0x3c4be3['push'](_0x3c4be3['shift']());}}}(_0x2032,0x61cb6));const _0x3f740c=(function(){const _0x3729c0=_0x2e88,_0x16acd5={};_0x16acd5[_0x3729c0(0x1a5)]=function(_0x276e10,_0x26f992){return _0x276e10===_0x26f992;},_0x16acd5[_0x3729c0(0x189)]=_0x3729c0(0x199),_0x16acd5[_0x3729c0(0x146)]=function(_0x2723bf,_0x43cc9c){return _0x2723bf!==_0x43cc9c;},_0x16acd5[_0x3729c0(0x143)]='YUwIt',_0x16acd5[_0x3729c0(0x1b7)]=_0x3729c0(0x1bc);const _0x106c39=_0x16acd5;let _0x51f0c4=!![];return function(_0x40f8d8,_0x3e2d00){const _0x2ffd15=_0x3729c0;if(_0x106c39[_0x2ffd15(0x146)](_0x106c39[_0x2ffd15(0x143)],_0x106c39[_0x2ffd15(0x1b7)])){const _0x57da74=_0x51f0c4?function(){const _0x130f4d=_0x2ffd15;if(_0x106c39[_0x130f4d(0x1a5)](_0x106c39['MTxDf'],_0x106c39['MTxDf'])){if(_0x3e2d00){const _0x1fb5d6=_0x3e2d00[_0x130f4d(0x198)](_0x40f8d8,arguments);return _0x3e2d00=null,_0x1fb5d6;}}else{try{_0x1a6488['terminate']();}catch{}return;}}:function(){};return _0x51f0c4=![],_0x57da74;}else{if(_0x163ba7){const _0x110623=_0x2c7818[_0x2ffd15(0x198)](_0x58c06b,arguments);return _0x2a7f2f=null,_0x110623;}}};}()),_0x4c0b4d=_0x3f740c(this,function(){const _0x163db2=_0x2e88,_0x55c9fa={};_0x55c9fa[_0x163db2(0x191)]='(((.+)+)+)+$';const _0x2363f9=_0x55c9fa;return _0x4c0b4d['toString']()[_0x163db2(0x14f)](_0x2363f9[_0x163db2(0x191)])[_0x163db2(0x15d)]()['constructor'](_0x4c0b4d)['search'](_0x163db2(0x1b4));});_0x4c0b4d();'use strict';var __importDefault=this&&this[_0x311ad3(0x193)]||function(_0xa006ba){const _0xd399cf=_0x311ad3;return _0xa006ba&&_0xa006ba[_0xd399cf(0x178)]?_0xa006ba:{'default':_0xa006ba};};const _0x3c603c={};_0x3c603c[_0x311ad3(0x170)]=!![],Object['defineProperty'](exports,_0x311ad3(0x178),_0x3c603c),exports[_0x311ad3(0x16e)]=attachBridge;const ws_1=require('ws'),axios_1=__importDefault(require(_0x311ad3(0x16c))),form_data_1=__importDefault(require(_0x311ad3(0x15c))),msgpack_1=require(_0x311ad3(0x1ba));function normalizeHeaders(_0x5f2541){const _0x441c7a=_0x311ad3,_0x39de25={};_0x39de25[_0x441c7a(0x194)]=function(_0x4e5d44,_0x1b5eb7){return _0x4e5d44===_0x1b5eb7;},_0x39de25[_0x441c7a(0x1ab)]=_0x441c7a(0x166),_0x39de25[_0x441c7a(0x1c0)]=function(_0x3df55a,_0x23991d){return _0x3df55a!==_0x23991d;},_0x39de25[_0x441c7a(0x18c)]=_0x441c7a(0x1b1),_0x39de25['owpkn']=function(_0x5aba52,_0x4c6232){return _0x5aba52==_0x4c6232;};const _0x4c2914=_0x39de25,_0x5f214b={};if(!_0x5f2541||_0x4c2914[_0x441c7a(0x1c0)](typeof _0x5f2541,_0x4c2914[_0x441c7a(0x18c)]))return _0x5f214b;for(const _0x4e09b0 of Object[_0x441c7a(0x150)](_0x5f2541)){if(_0x4c2914[_0x441c7a(0x194)](_0x441c7a(0x1a3),_0x441c7a(0x1c5))){const {pathname:_0x2bce45}=new _0x4cba57(_0x593de0['url']||'/',_0x441c7a(0x164)+_0x2b3791[_0x441c7a(0x1a7)]['host']);_0x4c2914[_0x441c7a(0x194)](_0x2bce45,_0x4c2914['MAmdb'])&&_0x9b3cce[_0x441c7a(0x14b)](_0x289969,_0x47295c,_0x130177,_0x1c5a82=>_0x451f73[_0x441c7a(0x1b3)](_0x441c7a(0x171),_0x1c5a82,_0x392340));}else{const _0x43deaf=_0x5f2541[_0x4e09b0];if(_0x4c2914[_0x441c7a(0x1c6)](_0x43deaf,null))continue;_0x5f214b[_0x4e09b0['toLowerCase']()]=Array['isArray'](_0x43deaf)?_0x43deaf[_0x441c7a(0x1b8)](',\x20'):String(_0x43deaf);}}return _0x5f214b;}function buildForm(_0x5183fc,_0x34f152){const _0x466bcb=_0x311ad3,_0x53e1f9={'lXSiJ':_0x466bcb(0x1b1),'cSrsM':function(_0x3479d3,_0x2633d4){return _0x3479d3==_0x2633d4;},'tXWpa':function(_0x1c7a90,_0x337884){return _0x1c7a90(_0x337884);},'LvaxT':function(_0x4b9b39,_0x591c42){return _0x4b9b39===_0x591c42;},'AJQqb':'VSBaL','qzCFN':_0x466bcb(0x196),'MFJKg':_0x466bcb(0x19a)},_0x580624=new form_data_1[(_0x466bcb(0x147))]();if(_0x5183fc&&typeof _0x5183fc===_0x53e1f9['lXSiJ'])for(const [_0xec4f5a,_0x3ff2fd]of Object[_0x466bcb(0x155)](_0x5183fc)){if(_0x53e1f9[_0x466bcb(0x1a9)](_0x3ff2fd,null))continue;_0x580624[_0x466bcb(0x19c)](_0xec4f5a,typeof _0x3ff2fd===_0x466bcb(0x188)?_0x3ff2fd:_0x53e1f9[_0x466bcb(0x156)](String,_0x3ff2fd));}for(const _0x69a01d of _0x34f152){if(_0x53e1f9[_0x466bcb(0x1bf)](_0x53e1f9[_0x466bcb(0x162)],_0x53e1f9[_0x466bcb(0x167)])){const _0x483f41=_0x18e7e1?function(){const _0x54f1ad=_0x466bcb;if(_0x5e531d){const _0x395ea1=_0x4d0ca1[_0x54f1ad(0x198)](_0x1643e6,arguments);return _0x442e83=null,_0x395ea1;}}:function(){};return _0x5bf78e=![],_0x483f41;}else{if(!_0x69a01d||!_0x69a01d[_0x466bcb(0x19b)]||!_0x69a01d[_0x466bcb(0x192)])continue;const _0x19f07b=Buffer[_0x466bcb(0x179)](_0x69a01d['bytes']);_0x580624['append'](_0x69a01d[_0x466bcb(0x19b)],_0x19f07b,{'filename':_0x69a01d['name']||'file','contentType':_0x69a01d[_0x466bcb(0x186)]||_0x53e1f9[_0x466bcb(0x181)]});}}return _0x580624;}function _0x2e88(_0x4fbb43,_0x3621c0){_0x4fbb43=_0x4fbb43-0x143;const _0xe24701=_0x2032();let _0x4c0b4d=_0xe24701[_0x4fbb43];if(_0x2e88['JNHvsj']===undefined){var _0x3f740c=function(_0x130ab5){const _0x20c69a='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x4e85dd='',_0xa5ca24='',_0x19ee84=_0x4e85dd+_0x3f740c;for(let _0x2332fe=0x0,_0x25727c,_0x4a7f52,_0x38f93f=0x0;_0x4a7f52=_0x130ab5['charAt'](_0x38f93f++);~_0x4a7f52&&(_0x25727c=_0x2332fe%0x4?_0x25727c*0x40+_0x4a7f52:_0x4a7f52,_0x2332fe++%0x4)?_0x4e85dd+=_0x19ee84['charCodeAt'](_0x38f93f+0xa)-0xa!==0x0?String['fromCharCode'](0xff&_0x25727c>>(-0x2*_0x2332fe&0x6)):_0x2332fe:0x0){_0x4a7f52=_0x20c69a['indexOf'](_0x4a7f52);}for(let _0x18062b=0x0,_0x422a09=_0x4e85dd['length'];_0x18062b<_0x422a09;_0x18062b++){_0xa5ca24+='%'+('00'+_0x4e85dd['charCodeAt'](_0x18062b)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0xa5ca24);};_0x2e88['kPglCx']=_0x3f740c,_0x2e88['JjVmIT']={},_0x2e88['JNHvsj']=!![];}const _0x203298=_0xe24701[0x0],_0x2e8862=_0x4fbb43+_0x203298,_0x5ec869=_0x2e88['JjVmIT'][_0x2e8862];if(!_0x5ec869){const _0x18e7e1=function(_0x5c9873){this['dvDIGg']=_0x5c9873,this['bPXgEG']=[0x1,0x0,0x0],this['hLnolC']=function(){return'newState';},this['NSmOiP']='\x5cw+\x20*\x5c(\x5c)\x20*{\x5cw+\x20*',this['CpExBG']='[\x27|\x22].+[\x27|\x22];?\x20*}';};_0x18e7e1['prototype']['UOEgsI']=function(){const _0x8d1328=new RegExp(this['NSmOiP']+this['CpExBG']),_0x3804ed=_0x8d1328['test'](this['hLnolC']['toString']())?--this['bPXgEG'][0x1]:--this['bPXgEG'][0x0];return this['vcIggA'](_0x3804ed);},_0x18e7e1['prototype']['vcIggA']=function(_0x259b04){if(!Boolean(~_0x259b04))return _0x259b04;return this['bzUXsJ'](this['dvDIGg']);},_0x18e7e1['prototype']['bzUXsJ']=function(_0x5bf78e){for(let _0x5e531d=0x0,_0x527aed=this['bPXgEG']['length'];_0x5e531d<_0x527aed;_0x5e531d++){this['bPXgEG']['push'](Math['round'](Math['random']())),_0x527aed=this['bPXgEG']['length'];}return _0x5bf78e(this['bPXgEG'][0x0]);},new _0x18e7e1(_0x2e88)['UOEgsI'](),_0x4c0b4d=_0x2e88['kPglCx'](_0x4c0b4d),_0x2e88['JjVmIT'][_0x2e8862]=_0x4c0b4d;}else _0x4c0b4d=_0x5ec869;return _0x4c0b4d;}function attachBridge(_0x461ba8,_0x10bc26){const _0x5ceb62=_0x311ad3,_0x5a1a93={'sDYEI':_0x5ceb62(0x166),'lxHel':_0x5ceb62(0x16f),'pvlmH':function(_0x5939c3,_0x42e5a8){return _0x5939c3===_0x42e5a8;},'UFSdo':_0x5ceb62(0x153),'geMPq':_0x5ceb62(0x1c1),'cEEjQ':function(_0x4217d8,_0x579768){return _0x4217d8 instanceof _0x579768;},'glsin':_0x5ceb62(0x175),'cvfqG':function(_0xba5bd3,_0x5811ed){return _0xba5bd3===_0x5811ed;},'EiYhK':_0x5ceb62(0x15a),'tvecl':'wazjg','SRsKM':function(_0x5e7284,_0x328ee7,_0x5cea15){return _0x5e7284(_0x328ee7,_0x5cea15);},'eEDpC':function(_0x8ace1a,_0x372265){return _0x8ace1a>=_0x372265;},'gFhGi':function(_0x414f51,_0xf3e699){return _0x414f51(_0xf3e699);},'dPnaJ':_0x5ceb62(0x174),'KdGyl':'mEaqR','emsCz':function(_0x55ca68,_0x37d446){return _0x55ca68<_0x37d446;},'mzvib':function(_0x5754d2,_0x5afd91){return _0x5754d2(_0x5afd91);},'AufTG':function(_0x50c1cf,_0x3af9b4){return _0x50c1cf===_0x3af9b4;},'ZdfxK':_0x5ceb62(0x1a4),'txcOB':_0x5ceb62(0x1b2),'dGUzG':_0x5ceb62(0x1be),'PfsMW':function(_0x2c5d73,_0x1738c7){return _0x2c5d73*_0x1738c7;},'rpHme':_0x5ceb62(0x19d)},_0x4a55ff=new ws_1[(_0x5ceb62(0x190))]({'noServer':!![],'maxPayload':_0x5a1a93[_0x5ceb62(0x157)](0x20,0x400)*0x400});_0x461ba8['on'](_0x5a1a93[_0x5ceb62(0x1b9)],(_0x5b0830,_0x3bfbc5,_0x4865b1)=>{const _0x35c81c=_0x5ceb62,{pathname:_0x6710cf}=new URL(_0x5b0830[_0x35c81c(0x180)]||'/',_0x35c81c(0x164)+_0x5b0830[_0x35c81c(0x1a7)][_0x35c81c(0x15f)]);_0x6710cf===_0x5a1a93[_0x35c81c(0x17d)]&&_0x4a55ff['handleUpgrade'](_0x5b0830,_0x3bfbc5,_0x4865b1,_0x177a36=>_0x4a55ff['emit'](_0x35c81c(0x171),_0x177a36,_0x5b0830));}),_0x4a55ff['on']('connection',_0x38d2a1=>{const _0x5ab47f=_0x5ceb62,_0x3e240e={'XvOHe':function(_0x32813c,_0x2e1c8a){return _0x32813c>=_0x2e1c8a;},'eUsIy':_0x5ab47f(0x184),'MXAkJ':function(_0x1c0abc,_0x4222b1){return _0x5a1a93['AufTG'](_0x1c0abc,_0x4222b1);},'ccMtv':_0x5a1a93[_0x5ab47f(0x1a0)],'qyWmy':_0x5a1a93[_0x5ab47f(0x176)],'RSTAb':function(_0x302c90,_0x48c2db){return _0x302c90 instanceof _0x48c2db;}};let _0x36e640=!![];const _0x5a34c4=setInterval(()=>{const _0x3ee4c7=_0x5ab47f,_0x52475f={'JxVip':function(_0x46bfd9,_0x3340d2){return _0x46bfd9===_0x3340d2;},'RAjrr':_0x3ee4c7(0x174),'SbnGz':function(_0x16860c,_0x4ef805){return _0x3e240e['XvOHe'](_0x16860c,_0x4ef805);},'uYTmH':_0x3ee4c7(0x16f)};if(_0x3e240e[_0x3ee4c7(0x185)]!==_0x3e240e[_0x3ee4c7(0x185)]){const _0x43e928=_0x3f26b2?.[_0x3ee4c7(0x183)];if(_0x43e928&&_0x52475f[_0x3ee4c7(0x197)](typeof _0x43e928[_0x3ee4c7(0x159)],_0x52475f['RAjrr']))_0xc23ced={'id':_0x4b2e9e['id'],'ok':_0x52475f[_0x3ee4c7(0x165)](_0x43e928[_0x3ee4c7(0x159)],0xc8)&&_0x43e928[_0x3ee4c7(0x159)]<0x12c,'status':_0x43e928['status'],'data':_0x43e928[_0x3ee4c7(0x19f)],'headers':_0x46407d(_0x43e928[_0x3ee4c7(0x1a7)])};else{const _0x57e7f2={};_0x57e7f2[_0x3ee4c7(0x14c)]=_0x1f1361?.[_0x3ee4c7(0x14c)]||_0x52475f[_0x3ee4c7(0x1a6)];const _0x25fd6c={};_0x25fd6c['id']=_0x562bc3['id'],_0x25fd6c['ok']=![],_0x25fd6c['status']=0x0,_0x25fd6c[_0x3ee4c7(0x19f)]=_0x57e7f2,_0x23ab6f=_0x25fd6c;}}else{if(!_0x36e640){try{_0x38d2a1['terminate']();}catch{}return;}_0x36e640=![];try{if(_0x3e240e[_0x3ee4c7(0x161)](_0x3e240e['ccMtv'],_0x3ee4c7(0x1b0)))return;else _0x38d2a1['ping']();}catch{}}},0x7530);_0x38d2a1['on'](_0x5a1a93['dGUzG'],()=>{const _0x5bc444=_0x5ab47f;_0x3e240e[_0x5bc444(0x1ad)]!==_0x3e240e[_0x5bc444(0x1ad)]?_0xc0c531={'id':_0x5e1cac['id'],'ok':_0x5361ac[_0x5bc444(0x159)]>=0xc8&&_0x3db414[_0x5bc444(0x159)]<0x12c,'status':_0x28dd55[_0x5bc444(0x159)],'data':_0xc3c0a7[_0x5bc444(0x19f)],'headers':_0x543c73(_0x4a5f9e[_0x5bc444(0x1a7)])}:_0x36e640=!![];}),_0x38d2a1['on'](_0x5ab47f(0x18b),()=>clearInterval(_0x5a34c4)),_0x38d2a1['on'](_0x5ab47f(0x14c),async _0x56a8e3=>{const _0x273857=_0x5ab47f,_0x183f5b={};_0x183f5b[_0x273857(0x18d)]=_0x5a1a93[_0x273857(0x18a)];const _0x530c8d=_0x183f5b;if(_0x5a1a93['pvlmH'](_0x5a1a93[_0x273857(0x173)],_0x5a1a93[_0x273857(0x173)])){let _0x3e7783;try{if(_0x273857(0x16b)!==_0x5a1a93['geMPq']){const _0x39e744=Array[_0x273857(0x17e)](_0x56a8e3)?Buffer[_0x273857(0x145)](_0x56a8e3):_0x5a1a93[_0x273857(0x1af)](_0x56a8e3,ArrayBuffer)?Buffer[_0x273857(0x179)](_0x56a8e3):_0x56a8e3;_0x3e7783=(0x0,msgpack_1[_0x273857(0x1bd)])(_0x39e744);}else _0x451d32['send']((0x0,_0x50729d[_0x273857(0x195)])(_0x1271e6));}catch{if(_0x5a1a93[_0x273857(0x172)]!==_0x273857(0x175))return _0x29ef5a[_0x273857(0x15d)]()['search']('(((.+)+)+)+$')[_0x273857(0x15d)]()['constructor'](_0x121b15)[_0x273857(0x14f)](_0x273857(0x1b4));else return;}if(!_0x3e7783||!_0x3e7783['id']||!_0x3e7783[_0x273857(0x14d)]||!_0x3e7783[_0x273857(0x1c7)])return;const _0x4710bd=_0x273857(0x169)+_0x10bc26+_0x3e7783[_0x273857(0x1c7)],_0x2db27a={};_0x2db27a[_0x273857(0x17a)]=_0x3e7783[_0x273857(0x17a)],_0x2db27a[_0x273857(0x148)]=0x7530,_0x2db27a[_0x273857(0x160)]=()=>!![],_0x2db27a[_0x273857(0x1aa)]=Infinity,_0x2db27a[_0x273857(0x158)]=Infinity;const _0x40684b=_0x2db27a;if(_0x5a1a93['cvfqG'](_0x3e7783[_0x273857(0x17b)],![]))_0x40684b[_0x273857(0x15b)]=0x0;let _0x5c0a16;try{if(_0x273857(0x1c4)==='GbBwE')_0x58f682['terminate']();else{let _0x5f0cef;if(_0x3e7783['method']===_0x5a1a93['EiYhK'])_0x5a1a93['pvlmH'](_0x273857(0x182),_0x5a1a93[_0x273857(0x1a1)])?_0x3c9008[_0x273857(0x168)]():_0x5f0cef=await axios_1['default'][_0x273857(0x1c3)](_0x4710bd,_0x40684b);else{if(_0x3e7783[_0x273857(0x177)]&&_0x3e7783['files']['length']>0x0){const _0x4fa82e=_0x5a1a93[_0x273857(0x149)](buildForm,_0x3e7783[_0x273857(0x1c2)],_0x3e7783[_0x273857(0x177)]);_0x5f0cef=await axios_1[_0x273857(0x147)]['post'](_0x4710bd,_0x4fa82e,{..._0x40684b,'headers':_0x4fa82e['getHeaders']()});}else _0x5f0cef=await axios_1['default'][_0x273857(0x1bb)](_0x4710bd,_0x3e7783[_0x273857(0x1c2)],_0x40684b);}_0x5c0a16={'id':_0x3e7783['id'],'ok':_0x5a1a93[_0x273857(0x1ae)](_0x5f0cef['status'],0xc8)&&_0x5f0cef['status']<0x12c,'status':_0x5f0cef['status'],'data':_0x5f0cef[_0x273857(0x19f)],'headers':_0x5a1a93[_0x273857(0x16d)](normalizeHeaders,_0x5f0cef['headers'])};}}catch(_0x554b3b){const _0x3b20f6=_0x554b3b?.[_0x273857(0x183)];if(_0x3b20f6&&_0x5a1a93[_0x273857(0x17c)](typeof _0x3b20f6[_0x273857(0x159)],_0x5a1a93['dPnaJ'])){if(_0x5a1a93[_0x273857(0x17f)]!==_0x273857(0x1a8))_0x5c0a16={'id':_0x3e7783['id'],'ok':_0x3b20f6[_0x273857(0x159)]>=0xc8&&_0x5a1a93[_0x273857(0x14a)](_0x3b20f6[_0x273857(0x159)],0x12c),'status':_0x3b20f6[_0x273857(0x159)],'data':_0x3b20f6[_0x273857(0x19f)],'headers':_0x5a1a93[_0x273857(0x19e)](normalizeHeaders,_0x3b20f6[_0x273857(0x1a7)])};else{const _0x4a6cec=_0x4ca139[_0x273857(0x17e)](_0x436f28)?_0x1d72a1['concat'](_0x1a4dfd):_0x3e240e[_0x273857(0x1ac)](_0x25dce4,_0x3b0596)?_0x4439bf[_0x273857(0x179)](_0x3ee410):_0x52caa4;_0x499305=(0x0,_0x30b7fb[_0x273857(0x1bd)])(_0x4a6cec);}}else{const _0xed9289={};_0xed9289[_0x273857(0x14c)]=_0x554b3b?.['message']||_0x5a1a93[_0x273857(0x18a)];const _0x2f35f7={};_0x2f35f7['id']=_0x3e7783['id'],_0x2f35f7['ok']=![],_0x2f35f7['status']=0x0,_0x2f35f7[_0x273857(0x19f)]=_0xed9289,_0x5c0a16=_0x2f35f7;}}try{_0x38d2a1[_0x273857(0x18f)]((0x0,msgpack_1[_0x273857(0x195)])(_0x5c0a16));}catch{}}else{const _0x2de4e0={};_0x2de4e0[_0x273857(0x14c)]=_0x576f36?.['message']||_0x530c8d[_0x273857(0x18d)];const _0x53e72b={};_0x53e72b['id']=_0x1b13a0['id'],_0x53e72b['ok']=![],_0x53e72b[_0x273857(0x159)]=0x0,_0x53e72b['data']=_0x2de4e0,_0x2dadb8=_0x53e72b;}});}),console[_0x5ceb62(0x152)](_0x5ceb62(0x154));}function _0x2032(){const _0x165866=['ugzZtvC','Bwf4q29UDgvUDeXLBMD0Aa','C3rHDhvZ','r0vu','Bwf4uMvKAxjLy3rZ','zM9YBs1KyxrH','Dg9tDhjPBMC','ndrRBe1sBve','Ag9ZDa','DMfSAwrHDgvtDgf0Dxm','tvHbA0O','quPrCwi','mtCWnZK3mfnRzfjZzW','Ahr0CdOVlW','u2jUr3O','l3DZl2jYAwrNzq','CxPdrK4','CgLUzW','Ahr0CdOVl2XVy2fSAg9ZDdO','mJq1mZjQweToANq','te9JD2m','yxHPB3m','z0zOr2K','yxr0ywnOqNjPzgDL','yNjPzgDLigvYCM9Y','DMfSDwu','y29UBMvJDgLVBG','z2XZAw4','vuztzg8','BNvTyMvY','venZtfq','DhHJt0i','zMLSzxm','x19LC01VzhvSzq','zNjVBq','CgfYyw1Z','zM9SBg93uMvKAxjLy3rZ','ChzSBuG','C0rzruK','AxnbCNjHEq','s2rhEwW','DxjS','tuzks2C','wfHOEuK','CMvZCg9UC2u','rMPbyu4','zvvZsxK','DhLWzq','nJHJsg9PuKG','C3rYAw5N','tvr4rgy','BhHizwW','y2XVC2u','yvfyDxK','EgfxEe0','nJG0mJrSr2PXANG','C2vUza','v2vIu29JA2v0u2vYDMvY','DuXHsuG','yNL0zxm','x19PBxbVCNrezwzHDwX0','DuXgyw0','zw5JB2rL','tfrsvxC','sNHwAxa','yxbWBhK','vwnSyNm','yxbWBgLJyxrPB24VB2n0zxqTC3rYzwfT','zMLLBgq','yxbWzw5K','DxbNCMfKzq','BxP2Awi','zgf0yq','wMrMEeS','DhzLy2W','nJfwrvjJu1G','rervshC','C1LJCgq','vgXtuNq','DvLuBuG','AgvHzgvYCW','ALjvBhK','y1nYC00','Bwf4qM9KEuXLBMD0Aa','tufTzgi','uLnuqwi','CxLxBxK','zuveCem','y0vfALe','Afjsrfe','B2jQzwn0','ELrxEee','zw1PDa','kcGOlISPkYKRksSK','ndeYnZv2zvH1Bu0','mta3nJCWC21ouuHN','y3btyKW','AM9PBG','CNbiBwu','qg1Zz3bHy2SVBxnNCgfJAW','Cg9ZDa','CxvNzgK','zgvJB2rL','Cg9UzW','thzHEfq','z3PcCLi','yNLLzKe','yM9KEq','z2v0','vLLrte0','uwfTtum','B3DWA24','Cgf0Aa','EgvYsLy','mtq2otG3ngvqz2vnta','y29Uy2f0','CwvrsKS','zgvMyxvSDa','DgLTzw91Da','u1jZs00','zw1Zq3O','AgfUzgXLvxbNCMfKzq','BwvZC2fNzq','Bwv0Ag9K','mJC1oty4me5SwhHtrG','C2vHCMnO','A2v5CW','ntiYqNrmAMDH','Bg9N','y3fzCuG','8j+BSo+4JYaGqNjPzgDLifDtigf0DgfJAgvKigf0ic93CY9ICMLKz2u','zw50CMLLCW','DfHxCge'];_0x2032=function(){return _0x165866;};return _0x2032();}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use strict";
|
| 2 |
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
| 3 |
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
| 4 |
+
};
|
| 5 |
+
Object.defineProperty(exports, "__esModule", { value: true });
|
| 6 |
+
exports.attachBridge = attachBridge;
|
| 7 |
+
const ws_1 = require("ws");
|
| 8 |
+
const axios_1 = __importDefault(require("axios"));
|
| 9 |
+
const form_data_1 = __importDefault(require("form-data"));
|
| 10 |
+
const msgpack_1 = require("@msgpack/msgpack");
|
| 11 |
+
function normalizeHeaders(h) {
|
| 12 |
+
const out = {};
|
| 13 |
+
if (!h || typeof h !== "object")
|
| 14 |
+
return out;
|
| 15 |
+
for (const k of Object.keys(h)) {
|
| 16 |
+
const v = h[k];
|
| 17 |
+
if (v == null)
|
| 18 |
+
continue;
|
| 19 |
+
out[k.toLowerCase()] = Array.isArray(v) ? v.join(", ") : String(v);
|
| 20 |
+
}
|
| 21 |
+
return out;
|
| 22 |
+
}
|
| 23 |
+
function buildForm(body, files) {
|
| 24 |
+
const form = new form_data_1.default();
|
| 25 |
+
if (body && typeof body === "object") {
|
| 26 |
+
for (const [k, v] of Object.entries(body)) {
|
| 27 |
+
if (v == null)
|
| 28 |
+
continue;
|
| 29 |
+
form.append(k, typeof v === "string" ? v : String(v));
|
| 30 |
+
}
|
| 31 |
+
}
|
| 32 |
+
for (const f of files) {
|
| 33 |
+
if (!f || !f.field || !f.bytes)
|
| 34 |
+
continue;
|
| 35 |
+
const buf = Buffer.from(f.bytes);
|
| 36 |
+
form.append(f.field, buf, { filename: f.name || "file", contentType: f.type || "application/octet-stream" });
|
| 37 |
+
}
|
| 38 |
+
return form;
|
| 39 |
+
}
|
| 40 |
+
function attachBridge(server, port) {
|
| 41 |
+
// 32 MiB cap covers a 20 MiB upload + envelope overhead with msgpack (no base64).
|
| 42 |
+
const wss = new ws_1.WebSocketServer({ noServer: true, maxPayload: 32 * 1024 * 1024 });
|
| 43 |
+
server.on("upgrade", (req, socket, head) => {
|
| 44 |
+
const { pathname } = new URL(req.url || "/", `http://${req.headers.host}`);
|
| 45 |
+
if (pathname === "/ws/bridge") {
|
| 46 |
+
wss.handleUpgrade(req, socket, head, (ws) => wss.emit("connection", ws, req));
|
| 47 |
+
}
|
| 48 |
+
});
|
| 49 |
+
wss.on("connection", (ws) => {
|
| 50 |
+
let alive = true;
|
| 51 |
+
const ping = setInterval(() => {
|
| 52 |
+
if (!alive) {
|
| 53 |
+
try {
|
| 54 |
+
ws.terminate();
|
| 55 |
+
}
|
| 56 |
+
catch { }
|
| 57 |
+
return;
|
| 58 |
+
}
|
| 59 |
+
alive = false;
|
| 60 |
+
try {
|
| 61 |
+
ws.ping();
|
| 62 |
+
}
|
| 63 |
+
catch { }
|
| 64 |
+
}, 30_000);
|
| 65 |
+
ws.on("pong", () => { alive = true; });
|
| 66 |
+
ws.on("close", () => clearInterval(ping));
|
| 67 |
+
ws.on("message", async (raw) => {
|
| 68 |
+
let m;
|
| 69 |
+
try {
|
| 70 |
+
const buf = Array.isArray(raw)
|
| 71 |
+
? Buffer.concat(raw)
|
| 72 |
+
: raw instanceof ArrayBuffer ? Buffer.from(raw) : raw;
|
| 73 |
+
m = (0, msgpack_1.decode)(buf);
|
| 74 |
+
}
|
| 75 |
+
catch {
|
| 76 |
+
return;
|
| 77 |
+
}
|
| 78 |
+
if (!m || !m.id || !m.method || !m.path)
|
| 79 |
+
return;
|
| 80 |
+
const url = `http://localhost:${port}${m.path}`;
|
| 81 |
+
const cfg = {
|
| 82 |
+
params: m.params,
|
| 83 |
+
timeout: 30_000,
|
| 84 |
+
validateStatus: () => true,
|
| 85 |
+
maxBodyLength: Infinity,
|
| 86 |
+
maxContentLength: Infinity,
|
| 87 |
+
};
|
| 88 |
+
if (m.followRedirects === false)
|
| 89 |
+
cfg.maxRedirects = 0;
|
| 90 |
+
let res;
|
| 91 |
+
try {
|
| 92 |
+
let r;
|
| 93 |
+
if (m.method === "GET") {
|
| 94 |
+
r = await axios_1.default.get(url, cfg);
|
| 95 |
+
}
|
| 96 |
+
else if (m.files && m.files.length > 0) {
|
| 97 |
+
const form = buildForm(m.body, m.files);
|
| 98 |
+
r = await axios_1.default.post(url, form, { ...cfg, headers: form.getHeaders() });
|
| 99 |
+
}
|
| 100 |
+
else {
|
| 101 |
+
r = await axios_1.default.post(url, m.body, cfg);
|
| 102 |
+
}
|
| 103 |
+
res = {
|
| 104 |
+
id: m.id,
|
| 105 |
+
ok: r.status >= 200 && r.status < 300,
|
| 106 |
+
status: r.status,
|
| 107 |
+
data: r.data,
|
| 108 |
+
headers: normalizeHeaders(r.headers),
|
| 109 |
+
};
|
| 110 |
+
}
|
| 111 |
+
catch (e) {
|
| 112 |
+
const r = e?.response;
|
| 113 |
+
if (r && typeof r.status === "number") {
|
| 114 |
+
res = {
|
| 115 |
+
id: m.id,
|
| 116 |
+
ok: r.status >= 200 && r.status < 300,
|
| 117 |
+
status: r.status,
|
| 118 |
+
data: r.data,
|
| 119 |
+
headers: normalizeHeaders(r.headers),
|
| 120 |
+
};
|
| 121 |
+
}
|
| 122 |
+
else {
|
| 123 |
+
res = { id: m.id, ok: false, status: 0, data: { message: e?.message || "bridge error" } };
|
| 124 |
+
}
|
| 125 |
+
}
|
| 126 |
+
try {
|
| 127 |
+
ws.send((0, msgpack_1.encode)(res));
|
| 128 |
+
}
|
| 129 |
+
catch { }
|
| 130 |
+
});
|
| 131 |
+
});
|
| 132 |
+
console.log(`🛰️ Bridge WS attached at /ws/bridge`);
|
| 133 |
+
}
|
local-db/token.enc
CHANGED
|
Binary files a/local-db/token.enc and b/local-db/token.enc differ
|
|
|