16 lines
4.4 KiB
JavaScript
16 lines
4.4 KiB
JavaScript
"use strict";(()=>{var e={};e.id=4727,e.ids=[4727],e.modules={27825:e=>{e.exports=require("lodash")},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")},81630:e=>{e.exports=require("http")},33873:e=>{e.exports=require("path")},724:(e,r,t)=>{t.r(r),t.d(r,{config:()=>f,default:()=>p,routeModule:()=>m});var a={};t.r(a),t.d(a,{config:()=>c,default:()=>d});var s=t(89947),i=t(2706),l=t(96762),n=t(6420),o=t.n(n),u=t(27444);let c={api:{responseLimit:"1mb",bodyParser:{sizeLimit:"200mb"}}};async function d(e,r){if("POST"!==e.method)return r.json({msg:"Failed!"});let t=await o()(e,r,!0);if(!t)return r.json({success:!1,msg:"Unauthorized"});let{paradigm:a,dbName:s,tableName:i,payload:l}=e.body;try{let e=await (0,u.A)({dbName:s,paradigm:a,payload:l,tableName:i,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 p=(0,l.M)(a,"default"),f=(0,l.M)(a,"config"),m=new s.PagesAPIRouteModule({definition:{kind:i.A.PAGES_API,page:"/api/exportTableData",pathname:"/api/exportTableData",bundlePath:"",filename:""},userland:a})},27444:(e,r,t)=>{t.d(r,{A:()=>n});var a=t(47670),s=t.n(a);let i=t(77538),l=t(51348);async function n({paradigm:e,userId:r,dbName:t,tableName:a,payload:n,payloadType:o}){let u={};try{let i=`${process.env.DSQL_USER_DB_PREFIX}${r}_${t.replace(/ /g,"")}`;switch(e){case"export":let c=await l(`SELECT * FROM \`${i}\`.\`${a}\``);u.tableData=c;break;case"import":let d="base64"==o?Buffer.from(n,"base64").toString():n,p="object"===o?n:JSON.parse(d);for(let e=0;e<p.length;e++){let r=p[e],t=await s()({data:r,dbFullName:i,tableName:a,dbContext:"Dsql User",paradigm:"Full Access",duplicateColumnName:"id",duplicateColumnValue:r?.id,update:!0});if(t.error)throw Error(t.error)}break;default:return null}return u}catch(e){return i({component:"/functions/backend/importExportTableDataFn",message:e.message}),null}}},77538:(e,r,t)=>{let a=t(29021),{IncomingMessage:s}=t(81630);e.exports=async function({user:e,message:r,component:t,noMail:s,req:i}){let l=new Date,n=(()=>{if(!i)return null;try{let e=i.headers["x-forwarded-for"],r=i.headers["x-real-ip"],t=i.headers["cf-connecting-ip"],a=Array.isArray(e)?e[0]:e?.split(",")[0],s=t||a||r||i.socket.remoteAddress;if(!s)return null;return String(s)}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}`),i?.url&&(s+=`
|
|
URL: ${i.url}`),i?.body&&(s+=`
|
|
Request Body: ${JSON.stringify(i.body,null,4)}`),n&&(s+=`
|
|
IP: ${n}`),s+=`
|
|
Date: ${l.toDateString()}
|
|
========================================`,a.existsSync("./.tmp/error.log")||a.writeFileSync("./.tmp/error.log","","utf-8");let o=a.readFileSync("./.tmp/error.log","utf-8");a.writeFileSync("./.tmp/error.log",s),a.appendFileSync("./.tmp/error.log",`
|
|
|
|
|
|
|
|
|
|
${o}`)}catch(e){console.log("Server Error Reporting Error:",e.message)}}},6420:(e,r,t)=>{t(81630);let a=t(51348),s=t(72907),i=t(29021);async function l(e,r,t,l){if(!e.cookies?.datasquirelAuthKey?.match(/./))return null;let n=s(e.cookies.datasquirelAuthKey);if(!n)return null;let o=JSON.parse(n);if(!o.csrf_k||t&&!e.headers["x-csrf-auth"]?.match(RegExp(`${o.csrf_k}`)))return null;let u=process.env.DSQL_USER_LOGIN_KEYS_PATH;if(!u)return console.log("DSQL_USER_LOGIN_KEYS_PATH env variable not found. Please set this variable."),null;if(t&&!i.existsSync(`${u}/${o.csrf_k}`))return null;if(0==o.verification_status&&!t){let e=await a(`SELECT verification_status FROM users WHERE id='${o.id}'`);e&&e[0]&&1==e[0].verification_status&&r.setHeader("Set-Cookie",["user_refresh=1"])}return o?.date&&Date.now()-o.date>6048e5?null:o}e.exports=l},72907:(e,r,t)=>{let{scryptSync:a,createDecipheriv:s}=t(55511),{Buffer:i}=t(79428);e.exports=e=>{let r=s("aes-192-cbc",a(process.env.DSQL_ENCRYPTION_PASSWORD||"",process.env.DSQL_ENCRYPTION_SALT||"",24),i.alloc(16,0));try{let t=r.update(e,"hex","utf8");return t+=r.final("utf8")}catch(e){return null}}}};var r=require("../../webpack-api-runtime.js");r.C(e);var t=e=>r(r.s=e),a=r.X(0,[4050],()=>t(724));module.exports=a})(); |