"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),a=t(2706),o=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:a,dbSlug:o,dbId:i,delegated:c}=e.body;try{letc=await_()({databaseSlug:o,request:e,user:t,query:e.query});if(!awaitu()({user:t,confirmedDelegetedUser:c,database:o,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:a}),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,o.M)(s,"default"),m=(0,o.M)(s,"config"),y=newn.PagesAPIRouteModule({definition:{kind:a.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:a,priviledgeRegex:o,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,a]),c=l[0]?.priviledge?.match(o)):(l=awaits("SELECT table_slug FROM user_database_tables WHERE user_id=? AND table_slug=? AND db_id=?",[e.id,a,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{leta=t.id,o=null;if(!n?.delegated)return{dbUserId:a};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((o=JSON.parse(t)).databaseSlug===r)return{dbUserId:a=o.rootUserId,rootUserId:o.rootUserId,rootUserName:o.rootUserName,rootUserEmail:o.rootUserEmail,rootUserImage:o.rootUserImage,databaseFullName:o.databaseFullName,databaseSlug:o.databaseSlug,allowedTables:o.allowedTables,priviledges:o.priviledges,database:o.databaseSlug,delegated:!0}}catch(e){}return{dbUserId:a}}catch(e){returnnull}}},6420:(e,r,t)=>{t(81630);lets=t(51348),n=t(72835),a=t(29021),o=t(31341);asyncfunctioni(e,r,t,i){let{keyCookieName:l,csrfCookieName:c}=o();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&&!a.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(e){letr=process.env.DSQL_COOKIES_PREFIX||"dsql_",t=process.env.DSQL_COO