"use strict";(()=>{var e={};e.id=2500,e.ids=[2500],e.modules={75600:e=>{e.exports=require("next/dist/compiled/next-server/pages-api.runtime.prod.js")},72583:e=>{e.exports=require("sanitize-html")},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(){return function e(r,t){return t in r?r[t]:"then"in r&&"function"==typeof r.then?r.then(r=>e(r,t)):"function"==typeof r&&"default"===t?r:void 0}}})},66162:(e,r,t)=>{t.r(r),t.d(r,{config:()=>d,default:()=>p,routeModule:()=>S});var s={};t.r(s),t.d(s,{default:()=>_});var n=t(89947),o=t(2706),a=t(96762),c=t(33364),i=t.n(c),l=t(6420),u=t.n(l);async function _(e,r){if("POST"!==e.method)return r.json({msg:"Failed!"});if(!await u()(e,r,!0))return r.json({success:!1,msg:"Unauthorized"});let{user_type:t}=e.body,s=(()=>{let r=Object.keys(e.body),s={};return r.forEach(r=>{!(t?.match(/database/)&&r?.match(/user_type|priviledge|database_access|databases?|confirm/))&&(r?.match(/databases|confirm/)||(s[r]=e.body[r]))}),s})(),n=await i()({dbFullName:"datasquirel",tableName:"user_users",identifierColumnName:"id",identifierValue:e.body.id,data:{...s}});r.json({success:!!n?.affectedRows,msg:n?.affectedRows?"User Updated":n})}let p=(0,a.M)(s,"default"),d=(0,a.M)(s,"config"),S=new n.PagesAPIRouteModule({definition:{kind:o.A.PAGES_API,page:"/api/updateUserUser",pathname:"/api/updateUserUser",bundlePath:"",filename:""},userland:s})},6420:(e,r,t)=>{t(81630);let s=t(51348),n=t(72835),o=t(29021),a=t(31341);async function c(e,r,t,c){let{keyCookieName:i,csrfCookieName:l}=a();if(!e.cookies?.[i]?.match(/./))return null;let u=n({encryptedString:e.cookies[i]});if(!u)return null;let _=JSON.parse(u);if(!_.csrf_k||t&&!e.headers["x-csrf-auth"]?.match(RegExp(`${_.csrf_k}`)))return null;let p=process.env.DSQL_USER_LOGIN_KEYS_PATH;if(!p)return console.log("DSQL_USER_LOGIN_KEYS_PATH env variable not found. Please set this variable."),null;if(t&&!o.existsSync(`${p}/${_.csrf_k}`))return null;if(0==_.verification_status&&!t){let e=await s(`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=c},31341:e=>{e.exports=function(e){let r=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;let c=r;e?.userId&&(c+=`user_${e.userId}_`),o&&(c+=`${o}_`),c+=s;let i=r;return e?.userId&&(i+=`user_${e.userId}_`),o&&(i+=`${o}_`),{keyCookieName:a,csrfCookieName:c,oneTimeCodeName:i+=n}}},33364:(e,r,t)=>{let s=t(72583),n=t(16570),o=t(51348),a=t(21339),c=t(20503),i=t(44900);async function l({dbContext:e,paradigm:r,dbFullName:t,tableName:l,data:u,tableSchema:_,identifierColumnName:p,identifierValue:d,encryptionKey:S,encryptionSalt:f,useLocal:E}){if(!u||!Object.keys(u).length)return null;let D=!!E||!e?.match(/dsql.user/i)&&(!t||!!t.match(/^datasquirel$/)),g=E?i:D?o:a,h=Object.keys(u),m=[],y=[];for(let e=0;ee.fieldName===r):null,a=o&&o[0]?o[0]:null;if(null==t||void 0==t)continue;let i=/<[^>]+>/g;(a?.richText||String(t).match(i))&&(t=s(t,n)),a?.encrypted&&(t=c({data:t,encryptionKey:S,encryptionSalt:f})),"object"==typeof t&&(t=JSON.stringify(t)),a?.pattern&&!new RegExp(a.pattern,a.patternFlags||"").test(t)&&(console.log("DSQL: Pattern not matched =>",t),t=""),"string"==typeof t&&t.match(/^null$/i)&&(t={toSqlString:function(){return"NULL"}}),"string"!=typeof t||t.match(/./i)||(t={toSqlString:function(){return"NULL"}}),m.push(`\`${r}\`=?`),"number"==typeof t?y.push(String(t)):y.push(t)}catch(e){console.log("DSQL: Error in parsing data keys in update function =>",e.message);continue}m.push(`date_updated='${Date()}'`),m.push(`date_updated_code='${Date.now()}'`);let v=`UPDATE ${l} SET ${m.join(",")} WHERE \`${p}\`=?`;return y.push(d),D?await g(v,y):await g({paradigm:r,database:t,queryString:v,queryValues:y})}e.exports=l},16570:e=>{e.exports={allowedTags:["b","i","em","strong","a","p","span","ul","ol","li","h1","h2","h3","h4","h5","h6","img","div","button","pre","code","br"],allowedAttributes:{a:["href"],img:["src","alt","width","height","class","style"],"*":["style","class"]}}},72835:(e,r,t)=>{let{scryptSync:s,createDecipheriv:n}=t(55511),{Buffer:o}=t(79428);e.exports=({encryptedString:e,encryptionKey:r,encryptionSalt:t})=>{if(!e?.match(/./))return console.log("Encrypted string is invalid"),e;let a=r||process.env.DSQL_ENCRYPTION_PASSWORD,c=t||process.env.DSQL_ENCRYPTION_SALT,i=process.env.DSQL_ENCRYPTION_KEY_LENGTH?Number(process.env.DSQL_ENCRYPTION_KEY_LENGTH):24;if(!a?.match(/.{8,}/))return console.log("Decrption key is invalid"),e;if(!c?.match(/.{8,}/))return console.log("Decrption salt is invalid"),e;let l=n("aes-192-cbc",s(a,c,i),o.alloc(16,0));try{let r=l.update(e,"hex","utf8");return r+=l.final("utf8")}catch(r){return console.log("Error in decrypting =>",r.message),e}}},20503:(e,r,t)=>{let{scryptSync:s,createCipheriv:n}=t(55511),{Buffer:o}=t(79428);e.exports=({data:e,encryptionKey:r,encryptionSalt:t})=>{if(!e?.match(/./))return console.log("Encryption string is invalid"),e;let a=r||process.env.DSQL_ENCRYPTION_PASSWORD,c=t||process.env.DSQL_ENCRYPTION_SALT,i=process.env.DSQL_ENCRYPTION_KEY_LENGTH?Number(process.env.DSQL_ENCRYPTION_KEY_LENGTH):24;if(!a?.match(/.{8,}/))return console.log("Encryption key is invalid"),e;if(!c?.match(/.{8,}/))return console.log("Encryption salt is invalid"),e;let l=n("aes-192-cbc",s(a,c,i),o.alloc(16,0));try{let r=l.update(e,"utf8","hex");return r+=l.final("hex")}catch(r){return console.log("Error in encrypting =>",r.message),e}}},51348:(e,r,t)=>{let s=t(9973),n=t(21580),o=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):void 0,charset:"utf8mb4",ssl:n()}});async function a(...e){try{let r=await o.query(...e);return await o.end(),JSON.parse(JSON.stringify(r))}catch(e){return console.log("DB Error =>",e),{success:!1,error:e.message}}}e.exports=a},21339:(e,r,t)=>{let s=t(29021);t(33873);let n=t(9973),o=t(21580),a=n({config:{host:process.env.DSQL_DB_HOST,user:process.env.DSQL_DB_READ_ONLY_USERNAME,password:process.env.DSQL_DB_READ_ONLY_PASSWORD,charset:"utf8mb4",ssl:o()}});e.exports=function({paradigm:e,database:r,queryString:t,queryValues:c}){try{return new Promise((i,l)=>{let u=!!e?.match(/full.access|^fa$/i);try{function _(e){a.end(),i(JSON.parse(JSON.stringify(e)))}function p(e){a.end(),i({error:e.message,queryStringGenerated:t,queryValuesGenerated:c,sql:e.sql})}a=u?n({config:{host:process.env.DSQL_DB_HOST,user:process.env.DSQL_DB_FULL_ACCESS_USERNAME,password:process.env.DSQL_DB_FULL_ACCESS_PASSWORD,database:r,ssl:o()}}):n({config:{host:process.env.DSQL_DB_HOST,user:process.env.DSQL_DB_READ_ONLY_USERNAME,password:process.env.DSQL_DB_READ_ONLY_PASSWORD,database:r,ssl:o()}}),c&&Array.isArray(c)&&c[0]?a.query(t,c).then(_).catch(p):a.query(t).then(_).catch(p)}catch(e){s.appendFileSync("./.tmp/dbErrorLogs.txt",e.message+"\n"+Date()+"\n\n\n","utf8"),i({error:e.message})}})}catch(e){return{success:!1,error:e.message}}}},44900:(e,r,t)=>{let s=t(9973),n=t(21580);async function o(...e){let r=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):void 0,charset:"utf8mb4",ssl:n()},onConnect:()=>{console.log("Connection Successful!")},onConnectError:e=>{console.log("Connection Error",e.message)},onError:e=>{console.log("Client Error",e.message)}});console.log("Querying ...");try{let t=await r.query(...e);return await r.end(),JSON.parse(JSON.stringify(t))}catch(e){return console.log("DB Error =>",e.message),{success:!1,error:e.message}}}e.exports=o},21580:(e,r,t)=>{let s=t(29021);e.exports=function(){let e=process.env.DSQL_SSL_DIR;if(!e?.match(/./))return;let r=`${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)=>{var t;Object.defineProperty(r,"A",{enumerable:!0,get:function(){return t}}),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)}};var r=require("../../webpack-api-runtime.js");r.C(e);var t=r(r.s=66162);module.exports=t})();