"use strict";(()=>{vare={};e.id=1658,e.ids=[1658],e.modules={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")},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}}})},43390:(e,r,t)=>{t.r(r),t.d(r,{config:()=>m,default:()=>D,routeModule:()=>y});vars={};t.r(s),t.d(s,{default:()=>g});varn=t(89947),o=t(2706),a=t(96762),i=t(64122),l=t.n(i),c=t(73677),u=t.n(c),d=t(39831),_=t.n(d),p=t(48225),S=t.n(p),E=t(6420),f=t.n(E);asyncfunctiong(e,r){if("POST"!==e.method)returnr.json({msg:"Failed!"});lett=awaitf()(e,r,!0);if(!t)returnr.json({success:!1,msg:"Unauthorized"});let{dbFullName:s,tableName:n,entryId:o,dbSlug:a,dbId:i,delegated:c}=e.body;try{letc=await_()({databaseSlug:a,request:e,user:t,query:e.query});if(!awaitu()({user:t,confirmedDelegetedUser:c,database:a,table:n,dbId:i,priviledgeRegex:/Delete Entries/i}))returnr.json({success:!1,msg:"Unauthorized"});awaitl()({dbContext:"Dsql User",paradigm:"Full Access",dbFullName:s,tableName:n,identifierColumnName:"id",identifierValue:o}),r.json({success:!0})}catch(e){S()({component:"/api/deleteTableEntry/main-catch-error",message:e.message,user:t}),r.json({success:!1,msg:"Deletion Failed!"})}}letD=(0,a.M)(s,"default"),m=(0,a.M)(s,"config"),y=newn.PagesAPIRouteModule({definition:{kind:o.A.PAGES_API,page:"/api/deleteTableEntry",pathname:"/api/deleteTableEntry",bundlePath:"",filename:""},userland:s})},73677:(e,r,t)=>{lets=t(51348),n=t(48225);e.exports=asyncfunction({user:e,confirmedDelegetedUser:r,database:t,table:o,priviledgeRegex:a,dbId:i}){letl,c;try{r?.delegated?(l=awaits("SELECT priviledge FROM delegated_user_tables WHERE root_user_id=? AND delegated_user_id=? AND `database`=? AND `table`=?",[r.rootUserId,e.id,t,o]),c=l[0]?.priviledge?.match(a)):(l=awaits("SELECT table_slug FROM user_database_tables WHERE user_id=? AND table_slug=? AND db_id=?",[e.id,o,i]),c=!0)}catch(r){n({component:"checkUserRights",message:r.message,user:e})}return!!l&&!!l[0]&&!!c}},39831:(e,r,t)=>{t(81630);lets=t(72835);e.exports=asyncfunction({request:e,databaseSlug:r,user:t,query:n}){try{leto=t.id,a=null;if(!n?.delegated)return{dbUserId:o};leti=n.dbUserId,l=`${process.env.DSQL_USER_DB_PREFIX}${i}_${r}`,c=`${process.env.DSQL_USER_DELEGATED_DB_COOKIE_PREFIX}${l}`;try{if(!e.cookies?.[c])throwError("Cookie not present");lett=s({encryptedString:e.cookies[c]});if(!t)throwError("Invalid Token");if((a=JSON.parse(t)).databaseSlug===r)return{dbUserId:o=a.rootUserId,rootUserId:a.rootUserId,rootUserName:a.rootUserName,rootUserEmail:a.rootUserEmail,rootUserImage:a.rootUserImage,databaseFullName:a.databaseFullName,databaseSlug:a.databaseSlug,allowedTables:a.allowedTables,priviledges:a.priviledges,database:a.databaseSlug,delegated:!0}}catch(e){}return{dbUserId:o}}catch(e){returnnull}}},6420:(e,r,t)=>{t(81630);lets=t(51348),n=t(72835),o=t(29021),a=t(31341);asyncfunctioni(e,r,t,i){let{keyCookieName:l,csrfCookieName:c}=a();if(!e.cookies?.[l]?.match(/./))returnnull;letu=n({encryptedString:e.cookies[l]});if(!u)returnnull;letd=JSON.parse(u);if(!d.csrf_k||t&&!e.headers["x-csrf-auth"]?.match(RegExp(`${d.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(t&&!o.existsSync(`${_}/${d.csrf_k}`))returnnull;if(0==d.verification_status&&!t){lete=awaits(`SELECT verification_status FROM users WHERE id='${d.id}'`);e&&e[0]&&1==e[0].verification_status&&r.setHeader("Set-Cookie",["user_refresh=1"])}returnd?.date&&Date.now()-d.date>6048e5?null:d}e.exports=i},31341:e=>{e.exports=function(){lete=process.env.DSQL_COOKIES_PREFIX||"dsql_";return{keyCookieName:e+