"use strict";(()=>{var e={};e.id=3683,e.ids=[3683],e.modules={39383:e=>{e.exports=require("@moduletrace/datasquirel/dist/package-shared/actions/users/user-auth")},75600:e=>{e.exports=require("next/dist/compiled/next-server/pages-api.runtime.prod.js")},72583:e=>{e.exports=require("sanitize-html")},79428:e=>{e.exports=require("buffer")},55511:e=>{e.exports=require("crypto")},96762:(e,t)=>{Object.defineProperty(t,"M",{enumerable:!0,get:function(){return function e(t,r){return r in t?t[r]:"then"in t&&"function"==typeof t.then?t.then(t=>e(t,r)):"function"==typeof t&&"default"===r?t:void 0}}})},18348:(e,t,r)=>{r.r(t),r.d(t,{config:()=>d,default:()=>c,routeModule:()=>f});var n={};r.r(n),r.d(n,{default:()=>u});var a=r(89947),o=r(2706),i=r(96762),s=r(30802),l=r(69842);async function u(e,t){if("POST"!==e.method)return t.json({msg:"Failed!"});if(!await (0,l.A)(e,t,!0))return t.json({success:!1,msg:"Unauthorized"});let{dbFullName:r,payload:n}=e.body,a=(()=>{let e=Object.keys(n),t={};return e.forEach(e=>{!e?.match(/user_type|priviledge|database_access|databases?|confirm/)&&(e?.match(/databases|confirm/)||(t[e]=n[e]))}),t})(),o=await (0,s.A)({dbFullName:r,tableName:"users",identifierColumnName:"id",identifierValue:n.id,data:{...a},dbContext:"Dsql User"});t.json({success:!!o?.affectedRows,msg:o?.affectedRows?"User Updated":o})}let c=(0,i.M)(n,"default"),d=(0,i.M)(n,"config"),f=new a.PagesAPIRouteModule({definition:{kind:o.A.PAGES_API,page:"/api/updateDbUser",pathname:"/api/updateDbUser",bundlePath:"",filename:""},userland:n})},69842:(e,t,r)=>{r.d(t,{A:()=>o});var n=r(39383),a=r.n(n);async function o(e,t,r){return a()({req:e,level:r?"deep":void 0}).payload}},30802:(e,t,r)=>{r.d(t,{A:()=>u});var n=r(72583),a=r.n(n),o=r(92652),i=r(68829),s=r(52939),l=r(64292);async function u({dbContext:e,dbFullName:t,tableName:r,data:n,tableSchema:u,identifierColumnName:c,identifierValue:d,encryptionKey:f,encryptionSalt:p,forceLocal:g}){if(!n||!Object.keys(n).length)return null;let h=!!g||(0,s.A)({dbContext:e,dbFullName:t}),y=h?global.DSQL_DB_CONN:global.DSQL_FULL_ACCESS_DB_CONN||global.DSQL_DB_CONN;h?global.DSQL_DB_CONN:global.DSQL_READ_ONLY_DB_CONN||global.DSQL_DB_CONN;let _=Object.keys(n),m=[],A=[];for(let e=0;e<_.length;e++)try{let t=_[e],r=n[t],s=u?u?.fields?.filter(e=>e.fieldName===t):null,l=s&&s[0]?s[0]:null;if(null==r||void 0==r)continue;let c=/<[^>]+>/g;(l?.richText||String(r).match(c))&&(r=a()(r,o.A)),l?.encrypted&&(r=(0,i.A)({data:r,encryptionKey:f,encryptionSalt:p})),"object"==typeof r&&(r=JSON.stringify(r)),l?.pattern&&!new RegExp(l.pattern,l.patternFlags||"").test(r)&&(console.log("DSQL: Pattern not matched =>",r),r=""),"string"==typeof r&&r.match(/^null$/i)&&(r={toSqlString:function(){return"NULL"}}),"string"!=typeof r||r.match(/./i)||(r={toSqlString:function(){return"NULL"}}),m.push(`\`${t}\`=?`),"number"==typeof r?A.push(String(r)):A.push(r)}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 N=`UPDATE ${h?"":`\`${t}\`.`}\`${r}\` SET ${m.join(",")} WHERE \`${c}\`=?`;return A.push(d),await (0,l.A)(y,N,A)}},92652:(e,t,r)=>{r.d(t,{A:()=>n});let n={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"]}}},68829:(e,t,r)=>{r.d(t,{A:()=>i});var n=r(55511),a=r(79428),o=r(31542);function i({data:e,encryptionKey:t,encryptionSalt:r}){if(!e?.match(/./))return console.log("Encryption string is invalid"),e;let{key:i,salt:s,keyLen:l,algorithm:u,bufferAllocSize:c}=(0,o.A)({encryptionKey:t});if(!i?.match(/.{8,}/))return console.log("Encryption key is invalid"),e;if(!s?.match(/.{8,}/))return console.log("Encryption salt is invalid"),e;let d=(0,n.scryptSync)(i,s,l),f=a.Buffer.alloc(c,0),p=(0,n.createCipheriv)(u,d,f);try{let t=p.update(e,"utf8","hex");return t+=p.final("hex")}catch(t){return console.log("Error in encrypting =>",t.message),e}}},52939:(e,t,r)=>{r.d(t,{A:()=>n});function n({dbContext:e,dbFullName:t}){return!e?.match(/dsql.user/i)&&(!!global.DSQL_USE_LOCAL||!t||!!t.match(/^datasquirel$/))}},64292:(e,t,r)=>{async function n(e,t,r){try{if(!e)throw Error("No Connection Found!");if(!t)throw Error("Query String Required!");if("string"==typeof t){let n=await e.query(a(t),r);return JSON.parse(JSON.stringify(n))}if("object"!=typeof t)return null;{let r=[];for(let n=0;nn})},31542:(e,t,r)=>{r.d(t,{A:()=>a});var n=r(82535);function a(e){return{key:e?.encryptionKey||process.env.DSQL_ENCRYPTION_PASSWORD,keyLen:process.env.DSQL_ENCRYPTION_KEY_LENGTH?Number(process.env.DSQL_ENCRYPTION_KEY_LENGTH):24,salt:e?.encryptionSalt||process.env.DSQL_ENCRYPTION_SALT,apiKey:e?.apiKey||process.env.DSQL_API_KEY,algorithm:e?.algorithm||process.env.DSQL_ENCRYPTION_ALGORITHM||"aes-192-cbc",bufferAllocSize:e?.bufferAllocSize||(process.env.DSQL_ENCRYPTION_BUFFER_ALLOCATION_SIZE?(0,n.A)(process.env.DSQL_ENCRYPTION_BUFFER_ALLOCATION_SIZE):void 0)||16}}},82535:(e,t,r)=>{r.d(t,{A:()=>n});function n(e,t){try{let r=Number(e);if("number"!=typeof r||isNaN(r))return 0;if(t)return Number(r.toFixed(t));return Math.round(r)}catch(e){return console.log(`Numberfy ERROR: ${e.message}`),0}}},2706:(e,t)=>{Object.defineProperty(t,"A",{enumerable:!0,get:function(){return r}});var r=function(e){return e.PAGES="PAGES",e.PAGES_API="PAGES_API",e.APP_PAGE="APP_PAGE",e.APP_ROUTE="APP_ROUTE",e.IMAGE="IMAGE",e}({})},89947:(e,t,r)=>{e.exports=r(75600)}};var t=require("../../webpack-api-runtime.js");t.C(e);var r=t(t.s=18348);module.exports=r})();