"use strict";exports.id=3496,exports.ids=[3496],exports.modules={96762:(e,r)=>{Object.defineProperty(r,"M",{enumerable:!0,get:function(){returnfunctione(r,t){returntinr?r[t]:"then"inr&&"function"==typeofr.then?r.then(r=>e(r,t)):"function"==typeofr&&"default"===t?r:void0}}})},69842:(e,r,t)=>{t.d(r,{A:()=>l});vars=t(48786),n=t(95969),a=t(29021),o=t.n(a),i=t(89159);asyncfunctionl(e,r,t){try{let{keyCookieName:a,csrfCookieName:l}=(0,i.A)();if(!e.cookies?.[a]?.match(/./))throwError("Request Cookies not Found!");letc=(0,n.A)({encryptedString:e.cookies[a]});if(!c)throwError("Couldn't decrypt auth cookie!");letu=JSON.parse(c);if(!u.csrf_k)throwError("No `csrf_k` present in user Object!");if(t&&!Object.keys(e.headers).find(e=>e.includes(u.csrf_k)))throwError("Deep Auth Failed. `csrf` key not found in request headers!");letE=process.env.DSQL_USER_LOGIN_KEYS_PATH;if(!E)throwError("DSQL_USER_LOGIN_KEYS_PATH env variable not found. Please set this variable.");if(t&&!o().existsSync(`${E}/${u.csrf_k}`))throwError("Key not found in Auth Keys Folder!");if(0==u.verification_status&&!t){lete=await(0,s.A)(`SELECT verification_status FROM users WHERE id='${u.id}'`);e&&e[0]&&1==e[0].verification_status&&r.setHeader("Set-Cookie",["user_refresh=1"])}if(u?.date&&Date.now()-u.date>6048e5)throwError("Key expired!");returnu}catch(e){returnconsole.log(`userAuth Error: ${e.message}`),null}}},89159:(e,r,t)=>{t.d(r,{A:()=>s});functions(e){letr=process.env.DSQL_COOKIES_PREFIX||"dsql_",t=process.env.DSQL_COOKIES_KEY_NAME||"key",s=process.env.DSQL_COOKIES_CSRF_NAME||"csrf",n=process.env.DSQL_COOKIES_ONE_TIME_CODE_NAME||"one-time-code",a=e?.database?.replace(/^datasquirel_user_\d+_/,"")||process.env.DSQL_DB_NAME?.replace(/^datasquirel_user_\d+_/,""),o=r;e?.userId&&(o+=`user_${e.userId}_`),a&&(o+=`${a}_`),o+=t;leti=r;e?.userId&&(i+=`user_${e.userId}_`),a&&(i+=`${a}_`),i+=s;letl=r;returne?.userId&&(l+=`user_${e.userId}_`),a&&(l+=`${a}_`),{keyCookieName:o,csrfCookieName:i,oneTimeCodeName:l+=n}}},67619:(e,r,t)=>{t.r(r),t.d(r,{default:()=>a});vars=t(29021),n=t.n(s);asyncfunctiona({user:e,message:r,component:t,noMail:s,req:a}){leto=newDate,i=(()=>{if(!a)returnnull;try{lete=a.headers["x-forwarded-for"],r=a.headers["x-real-ip"],t=a.headers["cf-connecting-ip"],s=Array.isArray(e)?e[0]:e?.split(",")[0],n=t||s||r||a.socket.remoteAddress;if(!n)returnnull;returnString(n)}catch(e){returnnull}})();try{lets=`🚀 SERVER ERROR ===========================
${l}`)}catch(e){console.log("Server Error Reporting Error:",e.message)}}},95969:(e,r,t)=>{t.d(r,{A:()=>a});var s=t(55511),n=t(79428);function a({encryptedString:e,encryptionKey:r,encryptionSalt:t}){if(!e?.match(/./))return console.log("Encrypted string is invalid"),e;let a=r||process.env.DSQL_ENCRYPTION_PASSWORD,o=t||process.env.DSQL_ENCRYPTION_SALT,i=process.env.DSQL_ENCRYPTION_KEY_LENGTH?Number(process.env.DSQL_ENCRYPTION_KEY_LENGTH):24;if(!a?.match(/.{8,}/))return console.log("Decrption key is invalid"),e;if(!o?.match(/.{8,}/))return console.log("Decrption salt is invalid"),e;let l=(0,s.scryptSync)(a,o,i),c=n.Buffer.alloc(16,0),u=(0,s.createDecipheriv)("aes-192-cbc",l,c);try{let r=u.update(e,"hex","utf8");return r+=u.final("utf8")}catch(r){return console.log("Error in decrypting =>",r.message),e}}},68829:(e,r,t)=>{t.r(r),t.d(r,{default:()=>a});var s=t(55511),n=t(79428);function a({data:e,encryptionKey:r,encryptionSalt:t}){if(!e?.match(/./))return console.log("Encryption string is invalid"),e;let a=r||process.env.DSQL_ENCRYPTION_PASSWORD,o=t||process.env.DSQL_ENCRYPTION_SALT,i=process.env.DSQL_ENCRYPTION_KEY_LENGTH?Number(process.env.DSQL_ENCRYPTION_KEY_LENGTH):24;if(!a?.match(/.{8,}/))return console.log("Encryption key is invalid"),e;if(!o?.match(/.{8,}/))return console.log("Encryption salt is invalid"),e;let l=(0,s.scryptSync)(a,o,i),c=n.Buffer.alloc(16,0),u=(0,s.createCipheriv)("aes-192-cbc",l,c);try{let r=u.update(e,"utf8","hex");return r+=u.final("hex")}catch(r){return console.log("Error in encrypting =>",r.message),e}}},5437:(e,r,t)=>{t.d(r,{A:()=>_});var s=t(33873),n=t.n(s),a=t(47795),o=t.n(a),i=t(66866),l=t(41864);async function c({username:e,host:r,grants:t,userId:s}){let n=!1;if(console.log("Handling Grants for User =>",e,r),!e)return console.log("No username provided."),n;if(!r)return console.log(`NoHostprovided.\x1b[35m\`--host\`\x1b[0m flag is required`),n;if(!t)returnconsole.log("No grants Array provided."),n;try{leta=await(0,i.A)(`SELECT * FROM mysql.user WHERE User = '${e}' AND Host = '${r}'`);if(a?.[0]?.User){letn=await(0,i.A)(`SHOW GRANTS FOR '${e}'@'${r}'`);for(lete=0;e<n.length;e++){letr=n[e],t=r?.[Object.keys(r)[0]];if(t?.match(/GRANT .* PRIVILEGES ON .* TO/)){lete=t.replace(/GRANT/,"REVOKE").replace(/ TO /," FROM ");await(0,i.A)(e)}}for(letn=0;n<t.length;n++){let{database:a,table:o,privileges:l}=t[n],c="*"==o?"*":`\`${o}\``,u="*"==a?`\`${process.env.DSQL_USER_DB_PREFIX}${s}_%\``:`\`${a}\``,E=l.includes("ALL")?"ALL PRIVILEGES":l.join(", "),d=`GRANT ${E} ON ${u}.${c} TO '${e}'@'${r}'`;await(0,i.A)(d)}}n=!0}catch(e){console.log("Error in adding SQL user =>",e.message)}returnn}varu=t(68829),E=t(95969);t(60818).config({path:n().resolve(__dirname,"../../../.env")});letd=process.env.DSQL_DB_HOST||"127.0.0.1";asyncfunction_({userId:e,mariadbUserHost:r,mariadbUsername:t,sqlUserID:s}){letn=await(0,l.A)({query:"SELECT * FROM mariadb_users"});if(!n?.[0])return;leta=!!e&&e==Number(process.env.DSQL_SU_USER_ID);for(let_=0;_<n.length;_++){letS=n[_];if(S&&(!e||S.user_id==e))try{let{mariadb_user:n,mariadb_host:_,mariadb_pass:f,user_id:p}=S,y=await(0,i.A)(`SELECT * FROM mysql.user WHERE User = '${n}' AND Host = '${_}'`),A=e&&s?await(0,l.A)({query:"SELECT * FROM mariadb_users WHERE id = ? AND user_id = ?",values:[s,e]}):null,g=Array.isArray(A)?A?.[0]:void0,N=!!g&&!!String(g.primary)?.match(/1/),m=!!y?.[0]?.User,R=a?t:`dsql_user_${p}`,O=g?.password?g.password:m?f:o().generate({length:16,numbers:!0,symbols:!0,uppercase:!0,exclude:"*#.'`\""}),D=g?.password?g.password:m?f:(0,u.default)({data:O,encryptionKey:process.env.DSQL_ENCRYPTION_PASSWORD,encryptionSalt:process.env.DSQL_ENCRYPTION_SALT});if(m||s||N||r||t)!m&&r&&await(0,i.A)(`CREATE USER IF NOT EXISTS '${R}'@'${r}' IDENTIFIED BY '${O}'`);else{lete=await(0,i.A)(`CREATE USER IF NOT EXISTS '${R}'@'${d}' IDENTIFIED BY '${O}'`);console.log("createNewUser",e),console.log(`User ${S.id}: ${S.first_name}${S.last_name} SQL credentials successfully updated.`),await(0,l.A)({query:"UPDATEusersSETmariadb_user=?,mariadb_host=?,mariadb_pass