"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(_),d=t(64122),S=t.n(d),f=t(77619),E=t.n(f);letg=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=E()({key:String(l()({encryptedString:n})),user_id:t.id});if(!o?.sign)throwawaitS()({dbFullName:"datasquirel",tableName:"api_keys",identifierColumnName:"id",identifierValue:s}),Error("API KEY is Invalid");try{letr=`${e}/${o?.sign}`;g.unlinkSync(r)}catch(e){console.log("Error Deleting API key",e.message)}awaitS()({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,media:a})=>{if(!e||!o)returnnull;try{leti=process.env.DSQL_API_KEYS_PATH;if(!i)throwError("process.env.DSQL_API_KEYS_PATH variable not found");letl=n({encryptedString:e}),c=JSON.parse(l||""),u=s.existsSync(`${i}/${c.sign}`);if(String(c.user_id)!==String(o)||!u)returnnull;if(!c.target_database||a)returnc;if(!r&&c.target_database)returnnull;let_=c.target_database?.split(",").includes(String(r));if(_&&!c.target_table)returnc;if(_&&!t&&c.target_table)returnnull;if(c.target_table?.split(",").includes(String(t)))returnc;returnnull}catch(e){returnconsole.log(`api-cred ERROR: ${e.message}`),{error:`api-cred ERROR: ${e.message}`}}}},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=process.env.DSQL_COOKIES_ONE_TIME_CODE_NAME||"one-time-code",o=e?.database?.replace(/^datasquirel_user_\d+_/,"")||process.env.DSQL_DB_NAME?.replace(/^datasquirel_user_\d+_/,""),a=r;e?.userId&&(a+=`user_${e.userId}_`),o&&(a+=`${o}_`),a+=t;leti=r;e?.userId&&(i+=`user_${e.userId}_`),o&&(i+=`${o}_`),i+=s;letl=r;returne?.userId&&(l+=`user_${e.userId}_`),o&&(l+=`${o}_`),{keyCookieName:a,csrfCook