"use strict";(()=>{vare={};e.id=9187,e.ids=[9187],e.modules={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")},3931:(e,r,s)=>{s.r(r),s.d(r,{config:()=>_,default:()=>c,routeModule:()=>p});vart={};s.r(t),s.d(t,{default:()=>l});vara=s(89947),i=s(2706),n=s(96762),o=s(83919),d=s(69842),u=s(98e3);asyncfunctionl(e,r){if("POST"!==e.method)returnr.json({msg:"Failed!"});if(!await(0,d.A)(e,r,!0))returnr.json({success:!1,msg:"Unauthorized"});let{payload:s,dbFullName:t,dbId:a}=e.body,i=await(0,u.A)({dbContext:"Dsql User",paradigm:"Full Access",dbFullName:t,tableName:"users",data:(()=>{lete=Object.keys(s),r={};returne.forEach(e=>{e?.match(/paradigm|priviledge|database_access|databases|confirm/)||(r[e]=s[e])}),r.password=(0,o.A)({encryptionKey:process.env.DSQL_ENCRYPTION_PASSWORD||"",password:s.password}),r.email=s.email_address,r.image="/images/user-preset.png",r.image_thumbnail="/images/user-preset-thumbnail.png",deleter.email_address,r})()});r.json({success:!!i?.insertId,msg:"New User User Added",newUserId:i.insertId})}letc=(0,n.M)(t,"default"),_=(0,n.M)(t,"config"),p=newa.PagesAPIRouteModule({definition:{kind:i.A.PAGES_API,page:"/api/addDbUser",pathname:"/api/addDbUser",bundlePath:"",filename:""},userland:t})},69842:(e,r,s)=>{s.d(r,{A:()=>d});vart=s(48786),a=s(95969),i=s(29021),n=s.n(i),o=s(89159);asyncfunctiond(e,r,s){let{keyCookieName:i,csrfCookieName:d}=(0,o.A)();if(!e.cookies?.[i]?.match(/./))returnnull;letu=(0,a.A)({encryptedString:e.cookies[i]});if(!u)returnnull;letl=JSON.parse(u);if(!l.csrf_k||s&&!Object.keys(e.headers).find(e=>e.includes(l.csrf_k)))returnnull;letc=process.env.DSQL_USER_LOGIN_KEYS_PATH;if(!c)returnconsole.log("DSQL_USER_LOGIN_KEYS_PATH env variable not found. Please set this variable."),null;if(s&&!n().existsSync(`${c}/${l.csrf_k}`))returnnull;if(0==l.verification_status&&!s){lete=await(0,t.A)(`SELECT verification_status FROM users WHERE id='${l.id}'`);e&&e[0]&&1==e[0].verification_status&&r.setHeader("Set-Cookie",["user_refresh=1"])}returnl?.date&&Date.now()-l.date>6048e5?null:l}},89159:(e,r,s)=>{s.d(r,{A:()=>t});functiont(e){letr=process.env.DSQL_COOKIES_PREFIX||"dsql_",s=process.env.DSQL_COOKIES_KEY_NAME||"key",t=process.env.DSQL_COOKIES_CSRF_NAME||"csrf",a=process.env.DSQL_COOKIES_ONE_TIME_CODE_NAME||"one-time-code",i=e?.database?.replace(/^datasquirel_user_\d+_/,"")||process.env.DSQL_DB_NAME?.replace(/^datasquirel_user_\d+_/,""),n=r;e?.userId&&(n+=`user_${e.userId}_`),i&&(n+=`${i}_`),n+=s;leto=r;e?.userId&&(o+=`user_${e.userId}_`),i&&(o+=`${i}_`),o+=t;letd=r;returne?.userId&&(d+=`user_${e.userId}_`),i&&(d+=`${i}_`),{keyCookieName:n,csrfCookieName:o,oneTimeCodeName:d+=a}}},95969:(e,r,s)=>{s.d(r,{A:()=>i});vart=s(55511),a=s(79428);functioni({encryptedString:e,encryptionKey:r,encryptionSalt:s}){if(!e?.match(/./))returnconsole.log("Encrypted string is invalid"),e;leti=r||process.env.DSQL_ENCRYPTION_PASSWORD,n=s||process.env.DSQL_ENCRYPTION_SALT,o=process.env.DSQL_ENCRYPTION_KEY_LENGTH?Number(process.env.DSQL_ENCRYPTION_KEY_LENGTH):24;if(!i?.match(/.{8,}/))returnconsole.log("Decrption key is invalid"),e;if(!n?.match(/.{8,}/))returnconsole.log("Decrption salt is invalid"),e;letd=(0,t.scryptSync)(i,n,o),u=a.Buffer.alloc(16,0),l=(0,t.createDecipheriv)("aes-192-cbc",d,u);try{letr=l.update(e,"hex","utf8");returnr+=l.final("utf8")}catch(r){returnconsole.log("Error in decrypting =>",r.message),e}}},83919:(e,r,s)=>{s.d(r,{A:()=>a});vart=s(55511);functiona({password:e,encryptionKey:r}){lets=r||process.env.DSQL_ENCRYPTION_PASSWORD;if(!s?.match(/.{8,}/))throwError("Encryption key is invalid");leta=(0,t.createHmac)("sha512",s);returna.update(e),a.digest("base64")}}};varr=require("../../webpack-api-runtime.js");r.C(e);vars=e=>r(r.s=e),t=r.X(0,[1251],()=>s(3931));module.exports=t})();