dsql-admin/dsql-app/.local_dist/server/pages/api/admin/getUserData.js
Benjamin Toby 3ffd2d6777 Updates
2024-12-05 08:03:33 +01:00

1 line
3.5 KiB
JavaScript

"use strict";(()=>{var e={};e.id=9664,e.ids=[9664],e.modules={75600:e=>{e.exports=require("next/dist/compiled/next-server/pages-api.runtime.prod.js")},9973:e=>{e.exports=require("serverless-mysql")},79428:e=>{e.exports=require("buffer")},55511:e=>{e.exports=require("crypto")},29021:e=>{e.exports=require("fs")},81630:e=>{e.exports=require("http")},96762:(e,t)=>{Object.defineProperty(t,"M",{enumerable:!0,get:function(){return function e(t,r){return r in t?t[r]:"then"in t&&"function"==typeof t.then?t.then(t=>e(t,r)):"function"==typeof t&&"default"===r?t:void 0}}})},29249:(e,t,r)=>{r.r(t),r.d(t,{config:()=>S,default:()=>f,routeModule:()=>_});var s={};r.r(s),r.d(s,{default:()=>d});var n=r(89947),o=r(2706),a=r(96762),u=r(51348),i=r.n(u),l=r(19131),c=r.n(l);let p=r(29021);async function d(e,t){if("POST"!==e.method)return t.json({success:!1,msg:"Wrong Method"});let r=await c()(e);if(!r?.logged_in_status)return t.json({success:!1,log:"No Logs"});let s=e.body.user,n=s?.id.toString().replace(/[^0-9]/g,"").replace(/\//g,""),o=`${process.env.DSQL_USER_DB_SCHEMA_PATH}/user-${n}`,a=[];!function e({originArray:t,rootPath:r}){let s=p.readdirSync(r);for(let n=0;n<s.length;n++){let o=s[n];if(o?.match(/\..{2,5}$/))t.push({name:o,type:"file",root:r});else{let s={name:o,type:"folder",root:r,content:[]};e({originArray:s.content,rootPath:`${r}/${o}`}),t.push(s)}}}({originArray:a,rootPath:o});let u=await i()(`SHOW databases LIKE 'datasquirel_user_${s.id}_%'`);t.json({success:!0,data:a,databases:u.map(e=>Object.values(e)[0])})}let f=(0,a.M)(s,"default"),S=(0,a.M)(s,"config"),_=new n.PagesAPIRouteModule({definition:{kind:o.A.PAGES_API,page:"/api/admin/getUserData",pathname:"/api/admin/getUserData",bundlePath:"",filename:""},userland:s})},19131:(e,t,r)=>{let{IncomingMessage:s}=r(81630),n=r(72907);e.exports=async function(e){if(!e.cookies?.datasquirelSuAdminUserAuthKey)return console.log("No auth key cookie found"),null;let t=n(e.cookies.datasquirelSuAdminUserAuthKey);if(!t)return console.log("No user payload found"),null;let r=JSON.parse(t);return r.password!==process.env.DSQL_USER_KEY?(console.log("Invalid password"),null):r.authKey!==process.env.DSQL_SPECIAL_KEY?(console.log("Invalid auth key"),null):r}},72907:(e,t,r)=>{let{scryptSync:s,createDecipheriv:n}=r(55511),{Buffer:o}=r(79428);e.exports=e=>{let t=n("aes-192-cbc",s(process.env.DSQL_ENCRYPTION_PASSWORD||"",process.env.DSQL_ENCRYPTION_SALT||"",24),o.alloc(16,0));try{let r=t.update(e,"hex","utf8");return r+=t.final("utf8")}catch(e){return null}}},51348:(e,t,r)=>{let s=r(9973),n=r(21580),o=s({config:{host:process.env.DSQL_DB_HOST,user:process.env.DSQL_DB_USERNAME,password:process.env.DSQL_DB_PASSWORD,database:process.env.DSQL_DB_NAME,port:process.env.DSQL_DB_PORT?Number(process.env.DSQL_DB_PORT):void 0,charset:"utf8mb4",ssl:n()}});async function a(...e){try{let t=await o.query(...e);return await o.end(),JSON.parse(JSON.stringify(t))}catch(e){return console.log("DB Error =>",e),{success:!1,error:e.message}}}e.exports=a},21580:(e,t,r)=>{let s=r(29021);e.exports=function(){let e=process.env.DSQL_SSL_DIR;if(!e?.match(/./))return;let t=`${e}/ca-cert.pem`;if(!s.existsSync(t)){console.log(`${t} does not exist`);return}return{ca:s.readFileSync(`${e}/ca-cert.pem`)}}},2706:(e,t)=>{var r;Object.defineProperty(t,"A",{enumerable:!0,get:function(){return r}}),function(e){e.PAGES="PAGES",e.PAGES_API="PAGES_API",e.APP_PAGE="APP_PAGE",e.APP_ROUTE="APP_ROUTE",e.IMAGE="IMAGE"}(r||(r={}))},89947:(e,t,r)=>{e.exports=r(75600)}};var t=require("../../../webpack-api-runtime.js");t.C(e);var r=t(t.s=29249);module.exports=r})();