"use strict";(()=>{vare={};e.id=294,e.ids=[294],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")},79646:e=>{e.exports=require("child_process")},55511:e=>{e.exports=require("crypto")},29021:e=>{e.exports=require("fs")},33873:e=>{e.exports=require("path")},7522:(e,r,s)=>{s.r(r),s.d(r,{config:()=>p,default:()=>_,routeModule:()=>f});vart={};s.r(t),s.d(t,{default:()=>c});vari=s(89947),a=s(2706),o=s(96762),n=s(48786),d=s(69842),u=s(98e3);s(29021),s(33873);let{execSync:l}=s(79646);asyncfunctionc(e,r){if("POST"!==e.method)returnr.json({msg:"Failed!"});lets=await(0,d.A)(e,r,!0);if(!s)returnr.json({success:!1,msg:"Unauthorized"});let{userObject:t,database_access:i,user_priviledge:a,db_tables:o,inv_user_id:l}=e.body,c=await(0,n.A)("UPDATE user_users SET database_access = ? ,user_priviledge = ? WHERE user_id = ? AND email = ?",[i,a,s.id,t.email]),_=o.split("|");await(0,n.A)(`DELETE FROM delegated_user_tables WHERE root_user_id='${s.id}' AND delegated_user_id='${l}'`);for(lete=0;e<_.length;e++){let[r,t]=_[e].split("-");await(0,u.A)({dbFullName:"datasquirel",tableName:"delegated_user_tables",data:{delegated_user_id:l,root_user_id:s.id,database:r,table:t,priviledge:a}})}r.json({success:!!c?.affectedRows})}let_=(0,o.M)(t,"default"),p=(0,o.M)(t,"config"),f=newi.PagesAPIRouteModule({definition:{kind:a.A.PAGES_API,page:"/api/updateAdminUserAccess",pathname:"/api/updateAdminUserAccess",bundlePath:"",filename:""},userland:t})},69842:(e,r,s)=>{s.d(r,{A:()=>d});vart=s(48786),i=s(95969),a=s(29021),o=s.n(a),n=s(89159);asyncfunctiond(e,r,s){try{let{keyCookieName:a,csrfCookieName:d}=(0,n.A)();if(!e.cookies?.[a]?.match(/./))throwError("Request Cookies not Found!");letu=(0,i.A)({encryptedString:e.cookies[a]});if(!u)throwError("Couldn't decrypt auth cookie!");letl=JSON.parse(u);if(!l.csrf_k)throwError("No `csrf_k` present in user Object!");if(s&&!Object.keys(e.headers).find(e=>e.includes(l.csrf_k)))throwError("Deep Auth Failed. `csrf` key not found in request headers!");letc=process.env.DSQL_USER_LOGIN_KEYS_PATH;if(!c)throwError("DSQL_USER_LOGIN_KEYS_PATH env variable not found. Please set this variable.");if(s&&!o().existsSync(`${c}/${l.csrf_k}`))throwError("Key not found in Auth Keys Folder!");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"])}if(l?.date&&Date.now()-l.date>6048e5)throwError("Key expired!");returnl}catch(e){returnconsole.log(`userAuth Error: ${e.message}`),null}}},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",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+_/,""),o=r;e?.userId&&(o+=`user_${e.userId}_`),a&&(o+=`${a}_`),o+=s;letn=r;e?.userId&&(n+=`user_${e.userId}_`),a&&(n+=`${a}_`),n+=t;letd=r;returne?.userId&&(d+=`user_${e.userId}_`),a&&(d+=`${a}_`),{keyCookieName:o,csrfCookieName:n,oneTimeCodeName:d+=i}}},95969:(e,r,s)=>{s.d(r,{A:()=>a});vart=s(55511),i=s(79428);functiona({encryptedString:e,encryptionKey:r,encryptionSalt:s}){if(!e?.match(/./))returnconsole.log("Encrypted string is invalid"),e;leta=r||process.env.DSQL_ENCRYPTION_PASSWORD,o=s||process.env.DSQL_ENCRYPTION_SALT,n=process.env.DSQL_ENCRYPTION_KEY_LENGTH?Number(process.env.DSQL_ENCRYPTION_KEY_LENGTH):24;if(!a?.match(/.{8,}/))returnconsole.log("Decrption key is invalid"),e;if(!o?.match(/.{8,}/))returnconsole.log("Decrption salt is invalid"),e;letd=(0,t.scryptSync)(a,o,n),u=i.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.messa