"use strict";(()=>{vare={};e.id=7402,e.ids=[7402],e.modules={75600:e=>{e.exports=require("next/dist/compiled/next-server/pages-api.runtime.prod.js")},79428:e=>{e.exports=require("buffer")},79646:e=>{e.exports=require("child_process")},55511:e=>{e.exports=require("crypto")},29021:e=>{e.exports=require("fs")},21820:e=>{e.exports=require("os")},96762:(e,r)=>{Object.defineProperty(r,"M",{enumerable:!0,get:function(){returnfunctione(r,t){returntinr?r[t]:"then"inr&&"function"==typeofr.then?r.then(r=>e(r,t)):"function"==typeofr&&"default"===t?r:void0}}})},87476:(e,r,t)=>{t.r(r),t.d(r,{config:()=>m,default:()=>S,routeModule:()=>y});vars={};t.r(s),t.d(s,{default:()=>E});varn=t(89947),o=t(2706),i=t(96762),a=t(29021),c=t.n(a),l=t(21820),u=t.n(l),d=t(79646),p=t(67619);asyncfunction_({dbName:e,user:r,res:t}){lets=u().platform().match(/win/i)?"'C:\\Program Files\\MySQL\\MySQL Server 8.0\\bin\\mysqldump.exe'":"mysqldump";try{letn={cwd:process.cwd()},o=`${process.env.DSQL_USER_DB_SCHEMA_PATH}/user-${r.id}/export.sql`;u().platform().match(/win/i)&&(n.shell="bash.exe");leti=`${s} -u ${process.env.DSQL_DB_USERNAME} -h ${process.env.DSQL_DB_HOST} -p${process.env.DSQL_DB_PASSWORD}${e} > ${o}`;console.log(`exportDb.ts exe => ${i}`),(0,d.execSync)(i,n),t.setHeader("Content-Type","application/zip"),t.setHeader("Content-Disposition","attachment; filename=export.sql"),c().createReadStream(o).pipe(t)}catch(e){(0,p.A)({component:"/functions/backend/exportDb/lines-30-46",message:e.message,user:r})}}varf=t(69842);asyncfunctionE(e,r){if("GET"!==e.method)returnr.json({msg:"Failed!"});lett=await(0,f.A)(e,r,!0);if(!t)returnr.json({success:!1,msg:"Unauthorized"});let{dbName:s}=e.query;await_({dbName:s?.toString()||"",res:r,user:t})}letS=(0,i.M)(s,"default"),m=(0,i.M)(s,"config"),y=newn.PagesAPIRouteModule({definition:{kind:o.A.PAGES_API,page:"/api/exportDatabase",pathname:"/api/exportDatabase",bundlePath:"",filename:""},userland:s})},69842:(e,r,t)=>{t.d(r,{A:()=>c});vars=t(48786),n=t(95969),o=t(29021),i=t.n(o),a=t(89159);asyncfunctionc(e,r,t){try{let{keyCookieName:o,csrfCookieName:c}=(0,a.A)();if(!e.cookies?.[o]?.match(/./))throwError("Request Cookies not Found!");letl=(0,n.A)({encryptedString:e.cookies[o]});if(!l)throwError("Couldn't decrypt auth cookie!");letu=JSON.parse(l);if(!u.csrf_k)throwError("No `csrf_k` present in user Object!");if(t&&!Object.keys(e.headers).find(e=>e.includes(u.csrf_k)))throwconsole.log("req.headers",e.headers),console.log("userObject",u),Error("Deep Auth Failed. `csrf` key not found in request headers!");letd=process.env.DSQL_USER_LOGIN_KEYS_PATH;if(!d)throwError("DSQL_USER_LOGIN_KEYS_PATH env variable not found. Please set this variable.");if(t&&!i().existsSync(`${d}/${u.csrf_k}`))throwError("Key not found in Auth Keys Folder!");if(0==u.verification_status&&!t){lete=await(0,s.A)(`SELECT verification_status FROM users WHERE id='${u.id}'`);e&&e[0]&&1==e[0].verification_status&&r.setHeader("Set-Cookie",["user_refresh=1"])}if(u?.date&&Date.now()-u.date>6048e5)throwError("Key expired!");returnu}catch(e){returnconsole.log(`userAuth Error: ${e.message}`),null}}},89159:(e,r,t)=>{t.d(r,{A:()=>s});functions(e){letr=process.env.DSQL_COOKIES_PREFIX||"dsql_",t=process.env.DSQL_COOKIES_KEY_NAME||"key",s=process.env.DSQL_COOKIES_CSRF_NAME||"csrf",n=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+_/,""),i=r;e?.userId&&(i+=`user_${e.userId}_`),o&&(i+=`${o}_`),i+=t;leta=r;e?.userId&&(a+=`user_${e.userId}_`),o&&(a+=`${o}_`),a+=s;letc=r;returne?.userId&&(c+=`user_${e.userId}_`),o&&(c+=`${o}_`),{keyCookieName:i,csrfCookieName:a,oneTimeCodeName:c+=n}}},67619:(e,r,t)=>{t.d(r,{A:()=>o});vars=t(29021),n=t.n(s);asyncfunctiono({user:e,message:r,component:t,noMail:s,req:o}){leti=newDate,a=(()=>{if(!o)returnnull;try{lete=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],n=t||s||r||o.socket.remoteAddress