"use strict";(()=>{vare={};e.id=2735,e.ids=[2735],e.modules={75600:e=>{e.exports=require("next/dist/compiled/next-server/pages-api.runtime.prod.js")},79428:e=>{e.exports=require("buffer")},55511:e=>{e.exports=require("crypto")},29021:e=>{e.exports=require("fs")},33873:e=>{e.exports=require("path")},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}}})},12057:(e,r,t)=>{t.r(r),t.d(r,{config:()=>p,default:()=>S,routeModule:()=>A});vars={};t.r(s),t.d(s,{default:()=>f});vari=t(89947),n=t(2706),a=t(96762),o=t(29021),u=t.n(o),d=t(33873),c=t.n(d),l=t(48786),E=t(67619),_=t(69842);asyncfunctionf(e,r){if("POST"!==e.method)returnr.json({msg:"Failed!"});lett=await(0,_.A)(e,r,!0);if(!t)returnr.json({success:!1,msg:"Unauthorized"});"production".match(/prod/i);try{await(0,l.A)(`DELETE FROM users WHERE id='${t.id}'`),await(0,l.A)(`DELETE FROM user_users WHERE invited_user_id='${t.id}' OR user_id='${t.id}'`),await(0,l.A)(`DELETE FROM delegated_user_tables WHERE delegated_user_id='${t.id}' OR root_user_id='${t.id}'`),await(0,l.A)(`DELETE FROM user_databases WHERE user_id='${t.id}'`),await(0,l.A)(`DELETE FROM user_database_tables WHERE user_id='${t.id}'`),await(0,l.A)(`DELETE FROM user_media WHERE user_id='${t.id}'`),await(0,l.A)(`DELETE FROM delegated_users WHERE user_id='${t.id}' OR delegated_user_id='${t.id}'`),await(0,l.A)(`DELETE FROM unsubscribes WHERE user_id='${t.id}'`),await(0,l.A)(`DELETE FROM notifications WHERE user_id='${t.id}'`),await(0,l.A)(`DELETE FROM api_keys WHERE user_id='${t.id}'`),await(0,l.A)(`DELETE FROM invitations WHERE inviting_user_id='${t.id}' OR invited_user_email='${t.email}'`);lete=await(0,l.A)("SELECT * FROM mariadb_users WHERE user_id = ?",[t.id]);for(letr=0;r<e.length;r++){let{username:t,host:s}=e[r];await(0,l.A)(`DROP USER IF EXISTS '${t}'@'${s}'`)}lets=await(0,l.A)(`SHOW databases LIKE 'datasquirel_user_${t.id}_%'`);for(lete=0;e<s.length;e++){letr=s[e],t=Object.values(r);await(0,l.A)(`DROP database IF EXISTS ${t}`)}leti=`${process.env.DSQL_USER_DB_SCHEMA_PATH}/user-${t.id}/main.json`;u().existsSync(i)&&u().unlinkSync(i);letn=process.env.DSQL_STATIC_SERVER_DIR;if(!n)throwconsole.log("Static File ENV not Found!"),Error("No Static Path!");leta=c().join(n,`images/user-images/user-${t.id}`);u().existsSync(a)&&function({rootFolderPath:e}){try{(functione(r){try{lett=u().readdirSync(r);for(lets=0;s<t.length;s++){leti=t[s];i?.match(/\..{2,5}$/)?u().unlinkSync(`${r}/${i}`):e(`${r}/${i}`)}u().rmdirSync(`${r}`)}catch(e){try{u().unlinkSync(r)}catch(e){}}})(e),u().rmSync(`${e}`,{recursive:!0,force:!0})}catch(e){returnconsole.log("ERROR in deleteFolderRecursively.ts function =>",e.message),!1}}({rootFolderPath:a}),r.json({success:!0})}catch(e){(0,E.A)({component:"/api/addApiKey/catch-error",message:e.message,user:t}),r.json({success:!1,msg:"User could not be deleted!"})}}letS=(0,a.M)(s,"default"),p=(0,a.M)(s,"config"),A=newi.PagesAPIRouteModule({definition:{kind:n.A.PAGES_API,page:"/api/deleteUser",pathname:"/api/deleteUser",bundlePath:"",filename:""},userland:s})},69842:(e,r,t)=>{t.d(r,{A:()=>u});vars=t(48786),i=t(95969),n=t(29021),a=t.n(n),o=t(89159);asyncfunctionu(e,r,t){try{let{keyCookieName:n,csrfCookieName:u}=(0,o.A)();if(!e.cookies?.[n]?.match(/./))throwError("Request Cookies not Found!");letd=(0,i.A)({encryptedString:e.cookies[n]});if(!d)throwError("Couldn't decrypt auth cookie!");letc=JSON.parse(d);if(!c.csrf_k)throwError("No `csrf_k` present in user Object!");if(t&&!Object.keys(e.headers).find(e=>e.includes(c.csrf_k)))throwconsole.log("req.headers",e.headers),console.log("userObject",c),Error("Deep Auth Failed. `csrf` key not found in request headers!");letl=process.env.DSQL_USER_LOGIN_KEYS_PATH;if(!l)throwError("DSQL_USER_LOGIN_KEYS_PATH env variable not found. Please set this variable.");if(t&&!a().existsSync(`${l}/${c.csrf_k}`))throwError("Key not found in Auth Keys Folder!");if(0==c.verifica