"use strict";(()=>{vare={};e.id=7963,e.ids=[7963],e.modules={43499:e=>{e.exports=require("@moduletrace/datasquirel/functions/hashPassword")},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")},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}}})},6523:(e,r,t)=>{t.r(r),t.d(r,{config:()=>_,default:()=>S,routeModule:()=>P});vars={};t.r(s),t.d(s,{default:()=>p});varn=t(89947),a=t(2706),o=t(96762),i=t(51348),u=t.n(i),c=t(6420),l=t.n(c),d=t(43499),f=t.n(d);asyncfunctionp(e,r){if("POST"!==e.method)returnr.json({msg:"Failed!"});if(!awaitl()(e,r,!0))returnr.json({success:!1,msg:"Unauthorized"});let{userId:t,password:s,dbId:n}=e.body;try{lete=!!String(n).match(/^\d+$/),a=!!String(t).match(/^\d+$/),o=!!String(s).match(/ /);if(!e||!a)throwError("Invalud Parameters!");if(o)throwError("Invalid Password!");leti=awaitu()("SELECT * FROM user_databases WHERE id = ?",[n]),c=i?.[0]?.db_full_name,l=f()({encryptionKey:process.env.DSQL_ENCRYPTION_PASSWORD||"",password:s});awaitu()(`UPDATE \`${c}\`.\`users\` SET password = ? WHERE id = ?`,[l,t]),r.json({success:!0,msg:"DB user Password Changed!"})}catch(e){r.json({success:!1,msg:e.message})}}letS=(0,o.M)(s,"default"),_=(0,o.M)(s,"config"),P=newn.PagesAPIRouteModule({definition:{kind:a.A.PAGES_API,page:"/api/changeDbUserPassword",pathname:"/api/changeDbUserPassword",bundlePath:"",filename:""},userland:s})},6420:(e,r,t)=>{t(81630);lets=t(51348),n=t(72907),a=t(29021);asyncfunctiono(e,r,t,o){if(!e.cookies?.datasquirelAuthKey?.match(/./))returnnull;leti=n(e.cookies.datasquirelAuthKey);if(!i)returnnull;letu=JSON.parse(i);if(!u.csrf_k||t&&!e.headers["x-csrf-auth"]?.match(RegExp(`${u.csrf_k}`)))returnnull;letc=process.env.DSQL_USER_LOGIN_KEYS_PATH;if(!c)returnconsole.log("DSQL_USER_LOGIN_KEYS_PATH env variable not found. Please set this variable."),null;if(t&&!a.existsSync(`${c}/${u.csrf_k}`))returnnull;if(0==u.verification_status&&!t){lete=awaits(`SELECT verification_status FROM users WHERE id='${u.id}'`);e&&e[0]&&1==e[0].verification_status&&r.setHeader("Set-Cookie",["user_refresh=1"])}returnu?.date&&Date.now()-u.date>6048e5?null:u}e.exports=o},72907:(e,r,t)=>{let{scryptSync:s,createDecipheriv:n}=t(55511),{Buffer:a}=t(79428);e.exports=e=>{letr=n("aes-192-cbc",s(process.env.DSQL_ENCRYPTION_PASSWORD||"",process.env.DSQL_ENCRYPTION_SALT||"",24),a.alloc(16,0));try{lett=r.update(e,"hex","utf8");returnt+=r.final("utf8")}catch(e){returnnull}}},51348:(e,r,t)=>{lets=t(9973),n=t(21580),a=s({config:{host:process.env.DSQL_DB_HOST,user:process.env.DSQL_DB_USERNAME,password:process.env.DSQL_DB_PASSWORD,database:process.env.DSQL_DB_NAME,port:process.env.DSQL_DB_PORT?Number(process.env.DSQL_DB_PORT):void0,charset:"utf8mb4",ssl:n()}});asyncfunctiono(...e){try{letr=awaita.query(...e);returnawaita.end(),JSON.parse(JSON.stringify(r))}catch(e){returnconsole.log("DB Error =>",e),{success:!1,error:e.message}}}e.exports=o},21580:(e,r,t)=>{lets=t(29021);e.exports=function(){lete=process.env.DSQL_SSL_DIR;if(!e?.match(/./))return;letr=`${e}/ca-cert.pem`;if(!s.existsSync(r)){console.log(`${r} does not exist`);return}return{ca:s.readFileSync(`${e}/ca-cert.pem`)}}},2706:(e,r)=>{vart;Object.defineProperty(r,"A",{enumerable:!0,get:function(){returnt}}),function(e){e.PAGES="PAGES",e.PAGES_API="PAGES_API",e.APP_PAGE="APP_PAGE",e.APP_ROUTE="APP_ROUTE",e.IMAGE="IMAGE"}(t||(t={}))},89947:(e,r,t)=>{e.exports=t(75600)}};varr=require("../../webpack-api-runtime.js");r.C(e);vart=r(r.s=6523);module.exports=t})();