dsql-admin/dsql-app/.local_dist/server/pages/api/admin/grabFile.js
Benjamin Toby 8b7ea057d0 Updates
2024-12-06 14:24:26 +01:00

1 line
3.0 KiB
JavaScript

"use strict";(()=>{var e={};e.id=7375,e.ids=[7375],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")},81630:e=>{e.exports=require("http")},96762:(e,r)=>{Object.defineProperty(r,"M",{enumerable:!0,get:function(){return function e(r,n){return n in r?r[n]:"then"in r&&"function"==typeof r.then?r.then(r=>e(r,n)):"function"==typeof r&&"default"===n?r:void 0}}})},15570:(e,r,n)=>{n.r(r),n.d(r,{config:()=>p,default:()=>d,routeModule:()=>f});var t={};n.r(t),n.d(t,{default:()=>c});var o=n(89947),s=n(2706),i=n(96762),u=n(19131),l=n.n(u);let a=n(29021);async function c(e,r){if("POST"!==e.method)return r.json({success:!1,msg:"Wrong Method"});let n=await l()(e);if(!n?.logged_in_status)return r.json({success:!1,log:"No Logs"});let{type:t,path:o}=e.body;if(e.body.user,!o?.match(/^\.\/jsonData\/dbSchemas\/users/))return r.json({success:!1,msg:"Invalid Path"});let s=o.replace(/\//g,"\\\\"),i=a.readFileSync(s,"utf-8");r.json({success:!0,data:i})}let d=(0,i.M)(t,"default"),p=(0,i.M)(t,"config"),f=new o.PagesAPIRouteModule({definition:{kind:s.A.PAGES_API,page:"/api/admin/grabFile",pathname:"/api/admin/grabFile",bundlePath:"",filename:""},userland:t})},19131:(e,r,n)=>{let{IncomingMessage:t}=n(81630),o=n(72835),s=n(31341);e.exports=async function(e){let{keyCookieName:r,csrfCookieName:n}=s(),t=`${r}_su`;if(!e.cookies?.[t])return console.log("No auth key cookie found"),null;let i=o({encryptedString:e.cookies[t]});if(!i)return console.log("No user payload found"),null;let u=JSON.parse(i);return u.password!==process.env.DSQL_USER_KEY?(console.log("Invalid password"),null):u.authKey!==process.env.DSQL_SPECIAL_KEY?(console.log("Invalid auth key"),null):u}},31341:e=>{e.exports=function(){let e=process.env.DSQL_COOKIES_PREFIX||"dsql_";return{keyCookieName:e+(process.env.DSQL_COOKIES_KEY_NAME||"key"),csrfCookieName:e+(process.env.DSQL_COOKIES_CSRF_NAME||"csrf")}}},72835:(e,r,n)=>{let{scryptSync:t,createDecipheriv:o}=n(55511),{Buffer:s}=n(79428);e.exports=({encryptedString:e,encryptionKey:r,encryptionSalt:n})=>{if(!e?.match(/./))return console.log("Encrypted string is invalid"),e;let i=r||process.env.DSQL_ENCRYPTION_PASSWORD,u=n||process.env.DSQL_ENCRYPTION_SALT,l=process.env.DSQL_ENCRYPTION_KEY_LENGTH?Number(process.env.DSQL_ENCRYPTION_KEY_LENGTH):24;if(!i?.match(/.{8,}/))return console.log("Decrption key is invalid"),e;if(!u?.match(/.{8,}/))return console.log("Decrption salt is invalid"),e;let a=o("aes-192-cbc",t(i,u,l),s.alloc(16,0));try{let r=a.update(e,"hex","utf8");return r+=a.final("utf8")}catch(r){return console.log("Error in decrypting =>",r.message),e}}},2706:(e,r)=>{var n;Object.defineProperty(r,"A",{enumerable:!0,get:function(){return n}}),function(e){e.PAGES="PAGES",e.PAGES_API="PAGES_API",e.APP_PAGE="APP_PAGE",e.APP_ROUTE="APP_ROUTE",e.IMAGE="IMAGE"}(n||(n={}))},89947:(e,r,n)=>{e.exports=n(75600)}};var r=require("../../../webpack-api-runtime.js");r.C(e);var n=r(r.s=15570);module.exports=n})();