dsql-admin/dsql-app/.local_dist/server/pages/api/admin/getUserData.js
Benjamin Toby 885c11f674 Updates
2025-01-14 07:42:13 +01:00

1 line
4.1 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")},79428:e=>{e.exports=require("buffer")},55511:e=>{e.exports=require("crypto")},29021:e=>{e.exports=require("fs")},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}}})},75461:(e,r,t)=>{t.r(r),t.d(r,{config:()=>p,default:()=>_,routeModule:()=>f});var n={};t.r(n),t.d(n,{default:()=>d});var o=t(89947),s=t(2706),a=t(96762),i=t(48786),u=t(87369),l=t(29021),c=t.n(l);async function d(e,r){if("POST"!==e.method)return r.json({success:!1,msg:"Wrong Method"});let t=await (0,u.A)(e);if(!t?.logged_in_status)return r.json({success:!1,log:"No Logs"});let n=e.body.user,o=n?.id.toString().replace(/[^0-9]/g,"").replace(/\//g,""),s=`${process.env.DSQL_USER_DB_SCHEMA_PATH}/user-${o}`,a=[];!function e({originArray:r,rootPath:t}){let n=c().readdirSync(t);for(let o=0;o<n.length;o++){let s=n[o];if(s?.match(/\..{2,5}$/))r.push({name:s,type:"file",root:t});else{let n={name:s,type:"folder",root:t,content:[]};e({originArray:n.content,rootPath:`${t}/${s}`}),r.push(n)}}}({originArray:a,rootPath:s});let l=await (0,i.A)(`SHOW databases LIKE 'datasquirel_user_${n.id}_%'`);r.json({success:!0,data:a,databases:l.map(e=>Object.values(e)[0])})}let _=(0,a.M)(n,"default"),p=(0,a.M)(n,"config"),f=new o.PagesAPIRouteModule({definition:{kind:s.A.PAGES_API,page:"/api/admin/getUserData",pathname:"/api/admin/getUserData",bundlePath:"",filename:""},userland:n})},87369:(e,r,t)=>{t.d(r,{A:()=>s});var n=t(95969),o=t(89159);async function s(e){let{keyCookieName:r,csrfCookieName:t}=(0,o.A)(),s=`${r}_su`;if(!e.cookies?.[s])return console.log("No auth key cookie found"),null;let a=(0,n.A)({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}},89159:(e,r,t)=>{t.d(r,{A:()=>n});function n(e){let r=process.env.DSQL_COOKIES_PREFIX||"dsql_",t=process.env.DSQL_COOKIES_KEY_NAME||"key",n=process.env.DSQL_COOKIES_CSRF_NAME||"csrf",o=process.env.DSQL_COOKIES_ONE_TIME_CODE_NAME||"one-time-code",s=e?.database?.replace(/^datasquirel_user_\d+_/,"")||process.env.DSQL_DB_NAME?.replace(/^datasquirel_user_\d+_/,""),a=r;e?.userId&&(a+=`user_${e.userId}_`),s&&(a+=`${s}_`),a+=t;let i=r;e?.userId&&(i+=`user_${e.userId}_`),s&&(i+=`${s}_`),i+=n;let u=r;return e?.userId&&(u+=`user_${e.userId}_`),s&&(u+=`${s}_`),{keyCookieName:a,csrfCookieName:i,oneTimeCodeName:u+=o}}},95969:(e,r,t)=>{t.d(r,{A:()=>s});var n=t(55511),o=t(79428);function s({encryptedString:e,encryptionKey:r,encryptionSalt:t}){if(!e?.match(/./))return console.log("Encrypted string is invalid"),e;let s=r||process.env.DSQL_ENCRYPTION_PASSWORD,a=t||process.env.DSQL_ENCRYPTION_SALT,i=process.env.DSQL_ENCRYPTION_KEY_LENGTH?Number(process.env.DSQL_ENCRYPTION_KEY_LENGTH):24;if(!s?.match(/.{8,}/))return console.log("Decrption key is invalid"),e;if(!a?.match(/.{8,}/))return console.log("Decrption salt is invalid"),e;let u=(0,n.scryptSync)(s,a,i),l=o.Buffer.alloc(16,0),c=(0,n.createDecipheriv)("aes-192-cbc",u,l);try{let r=c.update(e,"hex","utf8");return r+=c.final("utf8")}catch(r){return console.log("Error in decrypting =>",r.message),e}}},48786:(e,r,t)=>{t.d(r,{A:()=>n});async function n(...e){let r=global.DSQL_DB_CONN;try{if(!r)throw Error("No Connection provided to DB_HANDLER function!");let t=await r.query(...e);return JSON.parse(JSON.stringify(t))}catch(e){return console.log("DB Error =>",e),{success:!1,error:e.message}}finally{await r?.end()}}},2706:(e,r)=>{Object.defineProperty(r,"A",{enumerable:!0,get:function(){return t}});var t=function(e){return e.PAGES="PAGES",e.PAGES_API="PAGES_API",e.APP_PAGE="APP_PAGE",e.APP_ROUTE="APP_ROUTE",e.IMAGE="IMAGE",e}({})},89947:(e,r,t)=>{e.exports=t(75600)}};var r=require("../../../webpack-api-runtime.js");r.C(e);var t=r(r.s=75461);module.exports=t})();