dsql-admin/dsql-app/.local_dist/server/pages/api/admin/getUserData.js
Benjamin Toby bc037e839f Updates
2024-12-15 12:27:16 +01:00

1 line
4.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,r)=>{Object.defineProperty(r,"M",{enumerable:!0,get:function(){return function e(r,t){return t in r?r[t]:"then"in r&&"function"==typeof r.then?r.then(r=>e(r,t)):"function"==typeof r&&"default"===t?r:void 0}}})},29249:(e,r,t)=>{t.r(r),t.d(r,{config:()=>S,default:()=>d,routeModule:()=>f});var s={};t.r(s),t.d(s,{default:()=>p});var o=t(89947),n=t(2706),a=t(96762),i=t(51348),u=t.n(i),c=t(19131),l=t.n(c);let _=t(29021);async function p(e,r){if("POST"!==e.method)return r.json({success:!1,msg:"Wrong Method"});let t=await l()(e);if(!t?.logged_in_status)return r.json({success:!1,log:"No Logs"});let s=e.body.user,o=s?.id.toString().replace(/[^0-9]/g,"").replace(/\//g,""),n=`${process.env.DSQL_USER_DB_SCHEMA_PATH}/user-${o}`,a=[];!function e({originArray:r,rootPath:t}){let s=_.readdirSync(t);for(let o=0;o<s.length;o++){let n=s[o];if(n?.match(/\..{2,5}$/))r.push({name:n,type:"file",root:t});else{let s={name:n,type:"folder",root:t,content:[]};e({originArray:s.content,rootPath:`${t}/${n}`}),r.push(s)}}}({originArray:a,rootPath:n});let i=await u()(`SHOW databases LIKE 'datasquirel_user_${s.id}_%'`);r.json({success:!0,data:a,databases:i.map(e=>Object.values(e)[0])})}let d=(0,a.M)(s,"default"),S=(0,a.M)(s,"config"),f=new o.PagesAPIRouteModule({definition:{kind:n.A.PAGES_API,page:"/api/admin/getUserData",pathname:"/api/admin/getUserData",bundlePath:"",filename:""},userland:s})},19131:(e,r,t)=>{let{IncomingMessage:s}=t(81630),o=t(72835),n=t(31341);e.exports=async function(e){let{keyCookieName:r,csrfCookieName:t}=n(),s=`${r}_su`;if(!e.cookies?.[s])return console.log("No auth key cookie found"),null;let a=o({encryptedString:e.cookies[s]});if(!a)return console.log("No user payload found"),null;let i=JSON.parse(a);return i.password!==process.env.DSQL_USER_KEY?(console.log("Invalid password"),null):i.authKey!==process.env.DSQL_SPECIAL_KEY?(console.log("Invalid auth key"),null):i}},31341:e=>{e.exports=function(e){let r=process.env.DSQL_COOKIES_PREFIX||"dsql_",t=process.env.DSQL_COOKIES_KEY_NAME||"key",s=process.env.DSQL_COOKIES_CSRF_NAME||"csrf",o=process.env.DSQL_COOKIES_ONE_TIME_CODE_NAME||"one-time-code",n=e?.database?.replace(/^datasquirel_user_\d+_/,"")||process.env.DSQL_DB_NAME?.replace(/^datasquirel_user_\d+_/,""),a=r;e?.userId&&(a+=`user_${e.userId}_`),n&&(a+=`${n}_`),a+=t;let i=r;e?.userId&&(i+=`user_${e.userId}_`),n&&(i+=`${n}_`),i+=s;let u=r;return e?.userId&&(u+=`user_${e.userId}_`),n&&(u+=`${n}_`),{keyCookieName:a,csrfCookieName:i,oneTimeCodeName:u+=o}}},72835:(e,r,t)=>{let{scryptSync:s,createDecipheriv:o}=t(55511),{Buffer:n}=t(79428);e.exports=({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,i=t||process.env.DSQL_ENCRYPTION_SALT,u=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(!i?.match(/.{8,}/))return console.log("Decrption salt is invalid"),e;let c=o("aes-192-cbc",s(a,i,u),n.alloc(16,0));try{let r=c.update(e,"hex","utf8");return r+=c.final("utf8")}catch(r){return console.log("Error in decrypting =>",r.message),e}}},51348:(e,r,t)=>{let s=t(9973),o=t(21580),n=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:o()}});async function a(...e){try{let r=await n.query(...e);return await n.end(),JSON.parse(JSON.stringify(r))}catch(e){return console.log("DB Error =>",e),{success:!1,error:e.message}}}e.exports=a},21580:(e,r,t)=>{let s=t(29021);e.exports=function(){let e=process.env.DSQL_SSL_DIR;if(!e?.match(/./))return;let r=`${e}/ca-cert.pem`;if(!s.existsSync(r)){console.log(`${r} does not exist`);return}return{ca:s.readFileSync(`${e}/ca-cert.pem`)}}},2706:(e,r)=>{var t;Object.defineProperty(r,"A",{enumerable:!0,get:function(){return t}}),function(e){e.PAGES="PAGES",e.PAGES_API="PAGES_API",e.APP_PAGE="APP_PAGE",e.APP_ROUTE="APP_ROUTE",e.IMAGE="IMAGE"}(t||(t={}))},89947:(e,r,t)=>{e.exports=t(75600)}};var r=require("../../../webpack-api-runtime.js");r.C(e);var t=r(r.s=29249);module.exports=t})();