"use strict";(()=>{vare={};e.id=1385,e.ids=[1385],e.modules={39908:e=>{e.exports=require("@moduletrace/datasquirel/dist/users/user-auth")},47795:e=>{e.exports=require("generate-password")},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")},15420:(e,r,t)=>{t.r(r),t.d(r,{config:()=>A,default:()=>g,routeModule:()=>S});vars={};t.r(s),t.d(s,{default:()=>y});vara=t(89947),n=t(2706),i=t(96762),o=t(29021),l=t.n(o),d=t(47795),u=t.n(d),c=t(68829),p=t(67619),m=t(69842),f=t(98e3);asyncfunctiony(e,r){if("POST"!==e.method)returnr.json({msg:"Failed!"});lett=await(0,m.A)(e,r,!0);if(!t)returnr.json({success:!1,msg:"Unauthorized"});let{api_key_name:s,api_key_slug:a,api_key_scope:n,target_database:i,target_table:o}=e.body;if(!s?.match(/./)||!a?.match(/./)||!n?.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");l().existsSync(e)||l().mkdirSync(e,{recursive:!0});letd=u().generate({length:24,numbers:!0,uppercase:!0,lowercase:!0,symbols:"-"})+"-"+Date.now(),p={user_id:t.id,date_code:Date.now(),sign:d,target_database:i,target_table:o};"fullAccess"==n&&(p={...p,full_access:!0});letm=(0,c.A)({data:JSON.stringify(p)});if(!m)returnr.json({success:!1,msg:"Couldn't encrypt API key"});lety=(0,c.A)({data:m}),g={dbFullName:"datasquirel",tableName:"api_keys",data:{user_id:t.id,name:s,slug:a,key:y,scope:n}};d&&(g.data.csrf=d);letA=await(0,f.A)(g);if(!A.insertId)throwError(A?.error||"Api Key Couldn't be added");l().writeFileSync(`${e}/${d}`,JSON.stringify(p),"utf-8"),r.json({success:!0})}catch(e){(0,p.A)({component:"/api/addApiKey/catch-error",message:e.message,user:t}),r.json({success:!1,msg:"Database Files could not be written!"})}}letg=(0,i.M)(s,"default"),A=(0,i.M)(s,"config"),S=newa.PagesAPIRouteModule({definition:{kind:n.A.PAGES_API,page:"/api/addApiKey",pathname:"/api/addApiKey",bundlePath:"",filename:""},userland:s})},69842:(e,r,t)=>{t.d(r,{A:()=>n});vars=t(39908),a=t.n(s);asyncfunctionn(e,r,t){lets=a()({req:e,level:t?"deep":void0});returnconsole.log(s),s.payload}},67619:(e,r,t)=>{t.d(r,{A:()=>n});vars=t(29021),a=t.n(s);asyncfunctionn({user:e,message:r,component:t,noMail:s,req:n}){leti=newDate,o=(()=>{if(!n)returnnull;try{lete=n.headers["x-forwarded-for"],r=n.headers["x-real-ip"],t=n.headers["cf-connecting-ip"],s=Array.isArray(e)?e[0]:e?.split(",")[0],a=t||s||r||n.socket.remoteAddress;if(!a)returnnull;returnString(a)}catch(e){returnnull}})();try{lets=`🚀 SERVER ERROR ===========================