"use strict";(()=>{var e={};e.id=4727,e.ids=[4727],e.modules={75600:e=>{e.exports=require("next/dist/compiled/next-server/pages-api.runtime.prod.js")},72583:e=>{e.exports=require("sanitize-html")},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")},27310:(e,r,t)=>{t.r(r),t.d(r,{config:()=>p,default:()=>d,routeModule:()=>f});var s={};t.r(s),t.d(s,{config:()=>u,default:()=>c});var a=t(89947),o=t(2706),n=t(96762),i=t(69842),l=t(33170);let u={api:{responseLimit:"1mb",bodyParser:{sizeLimit:"200mb"}}};async function c(e,r){if("POST"!==e.method)return r.json({msg:"Failed!"});let t=await (0,i.A)(e,r,!0);if(!t)return r.json({success:!1,msg:"Unauthorized"});let{paradigm:s,dbName:a,tableName:o,payload:n}=e.body;try{let e=await (0,l.A)({dbName:a,paradigm:s,payload:n,tableName:o,userId:t.id,payloadType:"base64"});if(!e)return r.json({success:!1,msg:"Operation Failed!"});r.json({success:!0,msg:"Success!",data:e?.tableData})}catch(e){r.json({success:!1,msg:e.message})}}let d=(0,n.M)(s,"default"),p=(0,n.M)(s,"config"),f=new a.PagesAPIRouteModule({definition:{kind:o.A.PAGES_API,page:"/api/exportTableData",pathname:"/api/exportTableData",bundlePath:"",filename:""},userland:s})},33170:(e,r,t)=>{t.d(r,{A:()=>n});var s=t(98e3),a=t(67619),o=t(48786);async function n({paradigm:e,userId:r,dbName:t,tableName:n,payload:i,payloadType:l}){let u={};try{let a=`${process.env.DSQL_USER_DB_PREFIX}${r}_${t.replace(/ /g,"")}`;switch(e){case"export":let c=await (0,o.A)(`SELECT * FROM \`${a}\`.\`${n}\``);u.tableData=c;break;case"import":let d="base64"==l?Buffer.from(i,"base64").toString():i,p="object"===l?i:JSON.parse(d);for(let e=0;e
{t.d(r,{A:()=>l});var s=t(48786),a=t(95969),o=t(29021),n=t.n(o),i=t(89159);async function l(e,r,t){try{let{keyCookieName:o,csrfCookieName:l}=(0,i.A)();if(!e.cookies?.[o]?.match(/./))throw Error("Request Cookies not Found!");let u=(0,a.A)({encryptedString:e.cookies[o]});if(!u)throw Error("Couldn't decrypt auth cookie!");let c=JSON.parse(u);if(!c.csrf_k)throw Error("No `csrf_k` present in user Object!");if(t&&!Object.keys(e.headers).find(e=>e.includes(c.csrf_k)))throw Error("Deep Auth Failed. `csrf` key not found in request headers!");let d=process.env.DSQL_USER_LOGIN_KEYS_PATH;if(!d)throw Error("DSQL_USER_LOGIN_KEYS_PATH env variable not found. Please set this variable.");if(t&&!n().existsSync(`${d}/${c.csrf_k}`))throw Error("Key not found in Auth Keys Folder!");if(0==c.verification_status&&!t){let e=await (0,s.A)(`SELECT verification_status FROM users WHERE id='${c.id}'`);e&&e[0]&&1==e[0].verification_status&&r.setHeader("Set-Cookie",["user_refresh=1"])}if(c?.date&&Date.now()-c.date>6048e5)throw Error("Key expired!");return c}catch(r){return console.log(`userAuth Error for ${e.url}: ${r.message}`),null}}},89159:(e,r,t)=>{t.d(r,{A:()=>s});function s(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",a=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+_/,""),n=r;e?.userId&&(n+=`user_${e.userId}_`),o&&(n+=`${o}_`),n+=t;let i=r;e?.userId&&(i+=`user_${e.userId}_`),o&&(i+=`${o}_`),i+=s;let l=r;return e?.userId&&(l+=`user_${e.userId}_`),o&&(l+=`${o}_`),{keyCookieName:n,csrfCookieName:i,oneTimeCodeName:l+=a}}},67619:(e,r,t)=>{t.d(r,{A:()=>o});var s=t(29021),a=t.n(s);async function o({user:e,message:r,component:t,noMail:s,req:o}){let n=new Date,i=(()=>{if(!o)return null;try{let e=o.headers["x-forwarded-for"],r=o.headers["x-real-ip"],t=o.headers["cf-connecting-ip"],s=Array.isArray(e)?e[0]:e?.split(",")[0],a=t||s||r||o.socket.remoteAddress;if(!a)return null;return String(a)}catch(e){return null}})();try{let s=`🚀 SERVER ERROR ===========================
Error Message: ${r}
Component: ${t}`;e?.id&&e?.first_name&&e?.last_name&&e?.email&&(s+=`
User Id: ${e?.id}
User Name: ${e?.first_name} ${e?.last_name}
User Email: ${e?.email}`),o?.url&&(s+=`
URL: ${o.url}`),o?.body&&(s+=`
Request Body: ${JSON.stringify(o.body,null,4)}`),i&&(s+=`
IP: ${i}`),s+=`
Date: ${n.toDateString()}
========================================`,a().existsSync("./.tmp/error.log")||a().writeFileSync("./.tmp/error.log","","utf-8");let l=a().readFileSync("./.tmp/error.log","utf-8");a().writeFileSync("./.tmp/error.log",s),a().appendFileSync("./.tmp/error.log",`
${l}`)}catch(e){console.log("Server Error Reporting Error:",e.message)}}},95969:(e,r,t)=>{t.d(r,{A:()=>o});var s=t(55511),a=t(79428);function o({encryptedString:e,encryptionKey:r,encryptionSalt:t}){if(!e?.match(/./))return console.log("Encrypted string is invalid"),e;let o=r||process.env.DSQL_ENCRYPTION_PASSWORD,n=t||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(!n?.match(/.{8,}/))return console.log("Decrption salt is invalid"),e;let l=(0,s.scryptSync)(o,n,i),u=a.Buffer.alloc(16,0),c=(0,s.createDecipheriv)("aes-192-cbc",l,u);try{let r=c.update(e,"hex","utf8");return r+=c.final("utf8")}catch(r){return console.log("Error in decrypting =>",r.message),e}}}};var r=require("../../webpack-api-runtime.js");r.C(e);var t=e=>r(r.s=e),s=r.X(0,[1251],()=>t(27310));module.exports=s})();