"use strict";(()=>{vare={};e.id=7015,e.ids=[7015],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}}})},5261:(e,r,t)=>{t.r(r),t.d(r,{config:()=>y,default:()=>m,routeModule:()=>A});vars={};t.r(s),t.d(s,{default:()=>D});varn=t(89947),o=t(2706),a=t(96762),i=t(72835),l=t.n(i),c=t(48225),u=t.n(c),_=t(6420),p=t.n(_),S=t(64122),d=t.n(S),f=t(77619),g=t.n(f);letE=t(29021);asyncfunctionD(e,r){if("POST"!==e.method)returnr.json({msg:"Failed!"});lett=awaitp()(e,r,!0);if(!t)returnr.json({success:!1,msg:"Unauthorized"});let{id:s,key:n,user_id:o}=e.body;try{lete=process.env.DSQL_API_KEYS_PATH;if(!e)throwError("process.env.DSQL_API_KEYS_PATH variable not found");leto=g()({key:String(l()({encryptedString:n})),user_id:t.id});if(!o?.sign)throwawaitd()({dbFullName:"datasquirel",tableName:"api_keys",identifierColumnName:"id",identifierValue:s}),Error("API KEY is Invalid");try{letr=`${e}/${o?.sign}`;E.unlinkSync(r)}catch(e){console.log("Error Deleting API key",e.message)}awaitd()({dbFullName:"datasquirel",tableName:"api_keys",identifierColumnName:"id",identifierValue:s}),r.json({success:!0})}catch(e){console.log(`ERROR Deleting API Key => ${e.message}`),u()({component:"/api/deleteApiKey/main-catch-error",message:e.message,user:t}),r.json({success:!1,msg:"Deletion Failed!"})}}letm=(0,a.M)(s,"default"),y=(0,a.M)(s,"config"),A=newn.PagesAPIRouteModule({definition:{kind:o.A.PAGES_API,page:"/api/deleteApiKey",pathname:"/api/deleteApiKey",bundlePath:"",filename:""},userland:s})},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;let_=JSON.parse(u);if(!_.csrf_k||t&&!e.headers["x-csrf-auth"]?.match(RegExp(`${_.csrf_k}`)))returnnull;letp=process.env.DSQL_USER_LOGIN_KEYS_PATH;if(!p)returnconsole.log("DSQL_USER_LOGIN_KEYS_PATH env variable not found. Please set this variable."),null;if(t&&!o.existsSync(`${p}/${_.csrf_k}`))returnnull;if(0==_.verification_status&&!t){lete=awaits(`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=i},77619:(e,r,t)=>{lets=t(29021),n=t(72835);e.exports=({key:e,database:r,table:t,user_id:o})=>{if(!e||!o)returnnull;try{leta=process.env.DSQL_API_KEYS_PATH;if(!a)throwError("process.env.DSQL_API_KEYS_PATH variable not found");leti=n({encryptedString:e}),l=JSON.parse(i||""),c=s.existsSync(`${a}/${l.sign}`);if(String(l.user_id)!==String(o)||!c)returnnull;if(!l.target_database)returnl;if(!r&&l.target_database)returnnull;letu=l.target_database?.split(",").includes(String(r));if(u&&!l.target_table)returnl;if(u&&!t&&l.target_table)returnnull;if(l.target_table?.split(",").includes(String(t)))returnl;returnnull}catch(e){returnconsole.log(`api-cred ERROR: ${e.message}`),null}}},31341:e=>{e.exports=function(e){letr=process.env.DSQL_COOKIES_PREFIX||"dsql_",t=process.env.DSQL_COOKIES_KEY_NAME||"key",s=process.env.DSQL_COOKIES_CSRF_NAME||"csrf",n=e?.database||process.env.DSQL_DB_NAME?.replace(/^datasquirel_user_\d+_/,""),o=r;e?.userId&&(o+=`user_${e.userId}_`),n&&(o+=`${n}_`),o+=t;leta=r;returne?.userId&&(a+=`user_${e.userId}_`),n&&(a+=`${n}_`),{keyCookieName:o,csrfCookieName:a+=s}}},64122:(e,r,t)=>{lets=t(51348),n=t(21339),o=t(44900);asyncfunctiona({dbContext:e,paradigm:r,dbFullName:t,tableName:a,identifierColumnName:i,identifierValue:l,useLocal:c}){try{letu=!!c||!e?.matc