dsql-admin/dsql-app/.local_dist/server/pages/api/admin/grabFile.js

1 line
3.4 KiB
JavaScript
Raw Normal View History

2025-01-13 08:00:21 +00:00
"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")},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}}})},53865:(e,r,n)=>{n.r(r),n.d(r,{config:()=>d,default:()=>l,routeModule:()=>_});var s={};n.r(s),n.d(s,{default:()=>c});var t=n(89947),o=n(2706),u=n(96762),i=n(87369);let a=n(29021);async function c(e,r){if("POST"!==e.method)return r.json({success:!1,msg:"Wrong Method"});let n=await (0,i.A)(e);if(!n?.logged_in_status)return r.json({success:!1,log:"No Logs"});let{type:s,path:t}=e.body;if(e.body.user,!t?.match(/^\.\/jsonData\/dbSchemas\/users/))return r.json({success:!1,msg:"Invalid Path"});let o=t.replace(/\//g,"\\\\"),u=a.readFileSync(o,"utf-8");r.json({success:!0,data:u})}let l=(0,u.M)(s,"default"),d=(0,u.M)(s,"config"),_=new t.PagesAPIRouteModule({definition:{kind:o.A.PAGES_API,page:"/api/admin/grabFile",pathname:"/api/admin/grabFile",bundlePath:"",filename:""},userland:s})},87369:(e,r,n)=>{n.d(r,{A:()=>o});var s=n(95969),t=n(89159);async function o(e){let{keyCookieName:r,csrfCookieName:n}=(0,t.A)(),o=`${r}_su`;if(!e.cookies?.[o])return console.log("No auth key cookie found"),null;let u=(0,s.A)({encryptedString:e.cookies[o]});if(!u)return console.log("No user payload found"),null;let i=JSON.parse(u);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,n)=>{n.d(r,{A:()=>s});function s(e){let r=process.env.DSQL_COOKIES_PREFIX||"dsql_",n=process.env.DSQL_COOKIES_KEY_NAME||"key",s=process.env.DSQL_COOKIES_CSRF_NAME||"csrf",t=process.env.DSQL_COOKIES_ONE_TIME_CODE_NAME||"one-time-code",o=e?.database?.replace(/^datasquirel_user_\d+_/,"")||process.env.DSQL_DB_NAME?.replace(/^datasquirel_user_\d+_/,""),u=r;e?.userId&&(u+=`user_${e.userId}_`),o&&(u+=`${o}_`),u+=n;let i=r;e?.userId&&(i+=`user_${e.userId}_`),o&&(i+=`${o}_`),i+=s;let a=r;return e?.userId&&(a+=`user_${e.userId}_`),o&&(a+=`${o}_`),{keyCookieName:u,csrfCookieName:i,oneTimeCodeName:a+=t}}},95969:(e,r,n)=>{n.d(r,{A:()=>o});var s=n(55511),t=n(79428);function o({encryptedString:e,encryptionKey:r,encryptionSalt:n}){if(!e?.match(/./))return console.log("Encrypted string is invalid"),e;let o=r||process.env.DSQL_ENCRYPTION_PASSWORD,u=n||process.env.DSQL_ENCRYPTION_SALT,i=process.env.DSQL_ENCRYPTION_KEY_LENGTH?Number(process.env.DSQL_ENCRYPTION_KEY_LENGTH):24;if(!o?.match(/.{8,}/))return console.log("Decrption key is invalid"),e;if(!u?.match(/.{8,}/))return console.log("Decrption salt is invalid"),e;let a=(0,s.scryptSync)(o,u,i),c=t.Buffer.alloc(16,0),l=(0,s.createDecipheriv)("aes-192-cbc",a,c);try{let r=l.update(e,"hex","utf8");return r+=l.final("utf8")}catch(r){return console.log("Error in decrypting =>",r.message),e}}},2706:(e,r)=>{Object.defineProperty(r,"A",{enumerable:!0,get:function(){return n}});var n=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,n)=>{e.exports=n(75600)}};var r=require("../../../webpack-api-runtime.js");r.C(e);var n=r(r.s=53865);module.exports=n})();