"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:()=>f,routeModule:()=>m});vart={};s.r(t),s.d(t,{default:()=>E});vari=s(89947),a=s(2706),l=s(96762),n=s(51348),u=s.n(n),o=s(6420),d=s.n(o),_=s(47670),c=s.n(_);s(29021),s(33873);let{execSync:p}=s(79646);asyncfunctionE(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,o=awaitu()("UPDATE user_users SET database_access = ? ,user_priviledge = ? WHERE user_id = ? AND email = ?",[i,a,s.id,t.email]),_=l.split("|");awaitu()(`DELETE FROM delegated_user_tables WHERE root_user_id='${s.id}' AND delegated_user_id='${n}'`);for(lete=0;e<_.length;e++){let[r,t]=_[e].split("-");awaitc()({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:!!o?.affectedRows})}letf=(0,l.M)(t,"default"),S=(0,l.M)(t,"config"),m=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:u,csrfCookieName:o}=l();if(!e.cookies?.[u]?.match(/./))returnnull;letd=i({encryptedString:e.cookies[u]});if(!d)returnnull;let_=JSON.parse(d);if(!_.csrf_k||s&&!e.headers["x-csrf-auth"]?.match(RegExp(`${_.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&&!a.existsSync(`${c}/${_.csrf_k}`))returnnull;if(0==_.verification_status&&!s){lete=awaitt(`SELECT verification_status FROM users WHERE id='${_.id}'`);e&&e[0]&&1==e[0].verification_status&&r.setHeader("Set-Cookie",["user_refresh=1"])}return_?.date&&Date.now()-_.date>6048e5?null:_}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=process.env.DSQL_COOKIES_ONE_TIME_CODE_NAME||"one-time-code",a=e?.database?.replace(/^datasquirel_user_\d+_/,"")||process.env.DSQL_DB_NAME?.replace(/^datasquirel_user_\d+_/,""),l=r;e?.userId&&(l+=`user_${e.userId}_`),a&&(l+=`${a}_`),l+=s;letn=r;e?.userId&&(n+=`user_${e.userId}_`),a&&(n+=`${a}_`),n+=t;letu=r;returne?.userId&&(u+=`user_${e.userId}_`),a&&(u+=`${a}_`),{keyCookieName:l,csrfCookieName:n,oneTimeCodeName:u+=i}}},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,u=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;leto=i("aes-192-cbc",t(l,n,u),a.alloc(16,0));try{letr=o.update(e,"hex","utf8");returnr+=o.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})();