"use strict";(()=>{vare={};e.id=7889,e.ids=[7889],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")},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")},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}}})},66650:(e,r,t)=>{t.r(r),t.d(r,{config:()=>R,default:()=>y,routeModule:()=>A});vars={};t.r(s),t.d(s,{default:()=>g});varn=t(89947),a=t(2706),o=t(96762),i=t(6420),l=t.n(i),c=t(77538),u=t.n(c);t(27825);varp=t(33873),d=t.n(p),f=t(79646),m=t(51348),S=t.n(m),h=t(82703),E=t.n(h);t(29021);let_=t(47795);asyncfunctiong(e,r){if("POST"!==e.method)returnr.json({user:null,msg:"Registration Failed!"});lett=awaitl()(e,r,!0);if(!t)returnr.json({success:!1,msg:"Unauthorized"});let{data:s,edit:n,grants:a}=e.body;try{lete=process.env.DSQL_DB_HOST||"127.0.0.1",n=`dsql_user_${t.id}`,{host:o,password:i}=s;if(!o.match(/./))throwError("Invalid host");if(o.match(/^%$/))throwError("Cannot set a catch-all host for this user.");letl=String(o).replace(/[^a-zA-Z0-9-\.\:\/\%]/g,""),c=i?.match(/./)?i:_.generate({length:16,numbers:!0,symbols:!0,uppercase:!0,exclude:"*#.'`\""}),u=awaitS()("SELECT * FROM mysql.user WHERE User = ? AND (Host = ? OR Host = ?)",[n,l,e]);if(u?.[0]?.User)throwError("SQL User already exists. Remember if you have the '%' host on your primary user, it catches all other hosts.");if(l.match(/^%$/))throwError("Can't create a catch-all host for this username. Catch-all host is only allowed on the primary user.");letp=awaitS()("SELECT COUNT(*) FROM mariadb_users WHERE user_id = ?",[t.id]);if(p?.[0]?.["COUNT(*)"]>=10)throwError("User limit reached");letm=E()(c),h=awaitS()("INSERT INTO mariadb_users (user_id, username, host, password, grants) VALUES (?, ?, ?, ?, ?)",[t.id,n,l,m,JSON.stringify(a)]);if(!h?.insertId)throwError("Error in adding SQL user");letg=d().resolve(process.cwd(),"./shell/mariadb-users");(0,f.execSync)(`node refreshUsersAndGrants.js --userId ${t.id} --username ${n} --host ${l}`,{cwd:g}),r.json({success:!0})}catch(e){console.log("Create MariaDB user ERROR:",e.message),u()({component:"/api/acceptUserInvitation/catch-error",message:e.message,user:t}),r.json({success:!1,msg:"Error in adding SQL user =>"+e.message,err:e.message})}}lety=(0,o.M)(s,"default"),R=(0,o.M)(s,"config"),A=newn.PagesAPIRouteModule({definition:{kind:a.A.PAGES_API,page:"/api/sql-users/create",pathname:"/api/sql-users/create",bundlePath:"",filename:""},userland:s})},77538:(e,r,t)=>{lets=t(29021),{IncomingMessage:n}=t(81630);e.exports=asyncfunction({user:e,message:r,component:t,noMail:n,req:a}){leto=newDate,i=(()=>{if(!a)returnnull;try{lete=a.headers["x-forwarded-for"],r=a.headers["x-real-ip"],t=a.headers["cf-connecting-ip"],s=Array.isArray(e)?e[0]:e?.split(",")[0],n=t||s||r||a.socket.remoteAddress;if(!n)returnnull;returnString(n)}catch(e){returnnull}})();try{letn=`🚀 SERVER ERROR ===========================