dsql-admin/dsql-app/.local_dist/server/pages/api/updateDbUser.js

1 line
7.2 KiB
JavaScript
Raw Normal View History

2025-01-14 15:27:08 +00:00
"use strict";(()=>{var e={};e.id=3683,e.ids=[3683],e.modules={39908:e=>{e.exports=require("@moduletrace/datasquirel/dist/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")},9973:e=>{e.exports=require("serverless-mysql")},79428:e=>{e.exports=require("buffer")},55511:e=>{e.exports=require("crypto")},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}}})},18348:(e,r,t)=>{t.r(r),t.d(r,{config:()=>p,default:()=>l,routeModule:()=>d});var n={};t.r(n),t.d(n,{default:()=>u});var s=t(89947),o=t(2706),a=t(96762),i=t(30802),c=t(69842);async function u(e,r){if("POST"!==e.method)return r.json({msg:"Failed!"});if(!await (0,c.A)(e,r,!0))return r.json({success:!1,msg:"Unauthorized"});let{dbFullName:t,payload:n}=e.body,s=(()=>{let e=Object.keys(n),r={};return e.forEach(e=>{!e?.match(/user_type|priviledge|database_access|databases?|confirm/)&&(e?.match(/databases|confirm/)||(r[e]=n[e]))}),r})(),o=await (0,i.A)({dbFullName:t,tableName:"users",identifierColumnName:"id",identifierValue:n.id,data:{...s},dbContext:"Dsql User",paradigm:"Full Access"});r.json({success:!!o?.affectedRows,msg:o?.affectedRows?"User Updated":o})}let l=(0,a.M)(n,"default"),p=(0,a.M)(n,"config"),d=new s.PagesAPIRouteModule({definition:{kind:o.A.PAGES_API,page:"/api/updateDbUser",pathname:"/api/updateDbUser",bundlePath:"",filename:""},userland:n})},69842:(e,r,t)=>{t.d(r,{A:()=>o});var n=t(39908),s=t.n(n);async function o(e,r,t){let n=s()({req:e,level:t?"deep":void 0});return console.log(n),n.payload}},30802:(e,r,t)=>{t.d(r,{A:()=>l});var n=t(72583),s=t.n(n),o=t(92652),a=t(48786),i=t(37897),c=t(68829),u=t(62050);async function l({dbContext:e,paradigm:r,dbFullName:t,tableName:n,data:l,tableSchema:p,identifierColumnName:d,identifierValue:f,encryptionKey:_,encryptionSalt:S,useLocal:y}){if(!l||!Object.keys(l).length)return null;let A=!!y||!e?.match(/dsql.user/i)&&(!t||!!t.match(/^datasquirel$/)),D=y?u.A:A?a.A:i.A,g=Object.keys(l),h=[],m=[];for(let e=0;e<g.length;e++)try{let r=g[e],t=l[r],n=p?p?.fields?.filter(e=>e.fieldName===r):null,a=n&&n[0]?n[0]:null;if(null==t||void 0==t)continue;let i=/<[^>]+>/g;(a?.richText||String(t).match(i))&&(t=s()(t,o.A)),a?.encrypted&&(t=(0,c.A)({data:t,encryptionKey:_,encryptionSalt:S})),"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"}}),h.push(`\`${r}\`=?`),"number"==typeof t?m.push(String(t)):m.push(t)}catch(e){console.log("DSQL: Error in parsing data keys in update function =>",e.message);continue}h.push(`date_updated='${Date()}'`),h.push(`date_updated_code='${Date.now()}'`);let E=`UPDATE \`${t}\`.\`${n}\` SET ${h.join(",")} WHERE \`${d}\`=?`;return m.push(f),A?await D(E,m):await D({paradigm:r,queryString:E,queryValues:m})}},92652:(e,r,t)=>{t.d(r,{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,r,t)=>{t.d(r,{A:()=>a});var n=t(55511),s=t(79428),o=t(32443);function a({data:e,encryptionKey:r,encryptionSalt:t}){if(!e?.match(/./))return console.log("Encryption string is invalid"),e;let{key:a,salt:i,keyLen:c,algorithm:u,bufferAllocSize:l}=(0,o.A)({encryptionKey:r});if(!a?.match(/.{8,}/))return console.log("Encryption key is invalid"),e;if(!i?.match(/.{8,}/))return console.log("Encryption salt is invalid"),e;let p=(0,n.scryptSync)(a,i,c),d=s.Buffer.alloc(l,0),f=(0,n.createCipheriv)(u,p,d);try{let r=f.update(e,"utf8","hex");return r+=f.final("hex")}catch(r){return console.log("Error in encrypting =>",r.message),