1 line
6.5 KiB
JavaScript
1 line
6.5 KiB
JavaScript
"use strict";(()=>{var e={};e.id=3683,e.ids=[3683],e.modules={76102:e=>{e.exports=require("@moduletrace/datasquirel/dist/client")},39383:e=>{e.exports=require("@moduletrace/datasquirel/dist/package-shared/actions/users/user-auth")},65967:e=>{e.exports=require("@moduletrace/datasquirel/dist/package-shared/utils/ejson")},93726:e=>{e.exports=require("@moduletrace/datasquirel/dist/package-shared/utils/numberfy")},30889:e=>{e.exports=require("@moduletrace/datasquirel/dist/package-shared/utils/slugify")},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:()=>p});var n={};r.r(n),r.d(n,{default:()=>u});var a=r(89947),i=r(2706),o=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})(),i=await (0,s.A)({dbFullName:r,tableName:"users",identifierColumnName:"id",identifierValue:n.id,data:{...a},dbContext:"Dsql User"});t.json({success:!!i?.affectedRows,msg:i?.affectedRows?"User Updated":i})}let c=(0,o.M)(n,"default"),d=(0,o.M)(n,"config"),p=new a.PagesAPIRouteModule({definition:{kind:i.A.PAGES_API,page:"/api/updateDbUser",pathname:"/api/updateDbUser",bundlePath:"",filename:""},userland:n})},55153:(e,t,r)=>{r.d(t,{On:()=>a.a,_n:()=>o}),r(76102);var n=r(65967),a=r.n(n);r(30889);var i=r(93726);let o=r.n(i)()},69842:(e,t,r)=>{r.d(t,{A:()=>o});var n=r(39383),a=r.n(n),i=r(55153);async function o(e,t,r,n){let o=a()({req:e,level:r?"deep":void 0});return n&&o.payload?.id&&(0,i._n)(process.env.DSQL_SU_USER_ID)!==o.payload.id?null:o.payload}},30802:(e,t,r)=>{r.d(t,{A:()=>u});var n=r(72583),a=r.n(n),i=r(92652),o=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:p,encryptionSalt:f,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=[],S=[];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,i.A)),l?.encrypted&&(r=(0,o.A)({data:r,encryptionKey:p,encryptionSalt:f})),"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?S.push(String(r)):S.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 A=`UPDATE ${h?"":`\`${t}\`.`}\`${r}\` SET ${m.join(",")} WHERE \`${c}\`=?`;return S.push(d),await (0,l.A)(y,A,S)}},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:()=>o});var n=r(55511),a=r(79428),i=r(31542);function o({data:e,encryptionKey:t,encryptionSalt:r}){if(!e?.match(/./))return console.log("Encryption string is invalid"),e;let{key:o,salt:s,keyLen:l,algorithm:u,bufferAllocSize:c}=(0,i.A)({encryptionKey:t});if(!o?.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)(o,s,l),p=a.Buffer.alloc(c,0),f=(0,n.createCipheriv)(u,d,p);try{let t=f.update(e,"utf8","hex");return t+=f.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;n<t.length;n++)try{let i=t[n],o=await e.query(a(i.query),i.values);r.push(JSON.parse(JSON.stringify(o)))}catch(e){console.log(`connDbHandler Query Error: ${e.message}`),r.push(null)}return r}}catch(t){return console.log(`connDbHandler Error: ${t.message}`),console.log(e?.config()),null}finally{e?.end()}}function a(e){return e.replace(/\n/gm,"").replace(/ {2,}/g,"").trim()}r.d(t,{A:()=>n})},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})(); |