"use strict";(()=>{vare={};e.id=1385,e.ids=[1385],e.modules={47795:e=>{e.exports=require("generate-password")},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")},79646:e=>{e.exports=require("child_process")},55511:e=>{e.exports=require("crypto")},29021:e=>{e.exports=require("fs")},81630:e=>{e.exports=require("http")},33873:e=>{e.exports=require("path")},87256:(e,r,t)=>{t.r(r),t.d(r,{config:()=>x,default:()=>h,routeModule:()=>A});vars={};t.r(s),t.d(s,{default:()=>g});vara=t(89947),i=t(2706),n=t(96762),o=t(82703),l=t.n(o),u=t(77538),c=t.n(u),d=t(6420),p=t.n(d),f=t(47670),m=t.n(f);lety=t(29021);t(33873);let{execSync:S}=t(79646),_=t(47795);asyncfunctiong(e,r){if("POST"!==e.method)returnr.json({msg:"Failed!"});lett=awaitp()(e,r,!0);if(!t)returnr.json({success:!1,msg:"Unauthorized"});let{api_key_name:s,api_key_slug:a,api_key_scope:i,target_database:n,target_table:o}=e.body;if(!s?.match(/./)||!a?.match(/./)||!i?.match(/./))returnr.json({success:!1,msg:"Wrong Input"});try{lete=process.env.DSQL_API_KEYS_PATH;if(!e)throwError("process.env.DSQL_API_KEYS_PATH variable not found");y.existsSync(e)||y.mkdirSync(e,{recursive:!0});letu=_.generate({length:24,numbers:!0,uppercase:!0,lowercase:!0,symbols:"-"})+"-"+Date.now(),c={user_id:t.id,date_code:Date.now(),sign:u,target_database:n,target_table:o};"fullAccess"==i&&(c={...c,full_access:!0});letd=l()(JSON.stringify(c));if(!d)returnr.json({success:!1,msg:"Couldn't encrypt API key"});letp=l()(d),f={dbFullName:"datasquirel",tableName:"api_keys",data:{user_id:t.id,name:s,slug:a,key:p,scope:i}};if(u&&(f.data.csrf=u),!(awaitm()(f)).insertId)throwError("Api Key Couldn't be added");y.writeFileSync(`${e}/${u}`,JSON.stringify(c),"utf-8"),r.json({success:!0})}catch(e){c()({component:"/api/addApiKey/catch-error",message:e.message,user:t}),r.json({success:!1,msg:"Database Files could not be written!"})}}leth=(0,n.M)(s,"default"),x=(0,n.M)(s,"config"),A=newa.PagesAPIRouteModule({definition:{kind:i.A.PAGES_API,page:"/api/addApiKey",pathname:"/api/addApiKey",bundlePath:"",filename:""},userland:s})},77538:(e,r,t)=>{lets=t(29021),{IncomingMessage:a}=t(81630);e.exports=asyncfunction({user:e,message:r,component:t,noMail:a,req:i}){letn=newDate,o=(()=>{if(!i)returnnull;try{lete=i.headers["x-forwarded-for"],r=i.headers["x-real-ip"],t=i.headers["cf-connecting-ip"],s=Array.isArray(e)?e[0]:e?.split(",")[0],a=t||s||r||i.socket.remoteAddress;if(!a)returnnull;returnString(a)}catch(e){returnnull}})();try{leta=`🚀 SERVER ERROR ===========================