"use strict";(()=>{vare={};e.id=294,e.ids=[294],e.modules={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")},98397:(e,r,s)=>{s.r(r),s.d(r,{config:()=>S,default:()=>E,routeModule:()=>v});vart={};s.r(t),s.d(t,{default:()=>f});vari=s(89947),a=s(2706),l=s(96762),n=s(51348),o=s.n(n),u=s(6420),d=s.n(u),c=s(47670),_=s.n(c);s(29021),s(33873);let{execSync:p}=s(79646);asyncfunctionf(e,r){if("POST"!==e.method)returnr.json({msg:"Failed!"});lets=awaitd()(e,r,!0);if(!s)returnr.json({success:!1,msg:"Unauthorized"});let{userObject:t,database_access:i,user_priviledge:a,db_tables:l,inv_user_id:n}=e.body,u=awaito()("UPDATE user_users SET database_access = ? ,user_priviledge = ? WHERE user_id = ? AND email = ?",[i,a,s.id,t.email]),c=l.split("|");awaito()(`DELETE FROM delegated_user_tables WHERE root_user_id='${s.id}' AND delegated_user_id='${n}'`);for(lete=0;e<c.length;e++){let[r,t]=c[e].split("-");await_()({dbFullName:"datasquirel",tableName:"delegated_user_tables",data:{delegated_user_id:n,root_user_id:s.id,database:r,table:t,priviledge:a}})}r.json({success:!!u?.affectedRows})}letE=(0,l.M)(t,"default"),S=(0,l.M)(t,"config"),v=newi.PagesAPIRouteModule({definition:{kind:a.A.PAGES_API,page:"/api/updateAdminUserAccess",pathname:"/api/updateAdminUserAccess",bundlePath:"",filename:""},userland:t})},6420:(e,r,s)=>{s(81630);lett=s(51348),i=s(72835),a=s(29021),l=s(31341);asyncfunctionn(e,r,s,n){let{keyCookieName:o,csrfCookieName:u}=l();if(!e.cookies?.[o]?.match(/./))returnnull;letd=i({encryptedString:e.cookies[o]});if(!d)returnnull;letc=JSON.parse(d);if(!c.csrf_k||s&&!e.headers["x-csrf-auth"]?.match(RegExp(`${c.csrf_k}`)))returnnull;let_=process.env.DSQL_USER_LOGIN_KEYS_PATH;if(!_)returnconsole.log("DSQL_USER_LOGIN_KEYS_PATH env variable not found. Please set this variable."),null;if(s&&!a.existsSync(`${_}/${c.csrf_k}`))returnnull;if(0==c.verification_status&&!s){lete=awaitt(`SELECT verification_status FROM users WHERE id='${c.id}'`);e&&e[0]&&1==e[0].verification_status&&r.setHeader("Set-Cookie",["user_refresh=1"])}returnc?.date&&Date.now()-c.date>6048e5?null:c}e.exports=n},31341:e=>{e.exports=function(e){letr=process.env.DSQL_COOKIES_PREFIX||"dsql_",s=process.env.DSQL_COOKIES_KEY_NAME||"key",t=process.env.DSQL_COOKIES_CSRF_NAME||"csrf",i=e?.database||process.env.DSQL_DB_NAME?.replace(/^datasquirel_user_\d+_/,""),a=r;e?.userId&&(a+=`user_${e.userId}_`),i&&(a+=`${i}_`),a+=s;letl=r;returne?.userId&&(l+=`user_${e.userId}_`),i&&(l+=`${i}_`),{keyCookieName:a,csrfCookieName:l+=t}}},72835:(e,r,s)=>{let{scryptSync:t,createDecipheriv:i}=s(55511),{Buffer:a}=s(79428);e.exports=({encryptedString:e,encryptionKey:r,encryptionSalt:s})=>{if(!e?.match(/./))returnconsole.log("Encrypted string is invalid"),e;letl=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(!l?.match(/.{8,}/))returnconsole.log("Decrption key is invalid"),e;if(!n?.match(/.{8,}/))returnconsole.log("Decrption salt is invalid"),e;letu=i("aes-192-cbc",t(l,n,o),a.alloc(16,0));try{letr=u.update(e,"hex","utf8");returnr+=u.final("utf8")}catch(r){returnconsole.log("Error in decrypting =>",r.message),e}}}};varr=require("../../webpack-api-runtime.js");r.C(e);vars=e=>r(r.s=e),t=r.X(0,[4050],()=>s(98397));module.exports=t})();