dsql-admin/dsql-app/.local_dist/server/pages/api/refreshEntry.js
Benjamin Toby 81cf010cb5 Updates
2025-01-14 16:27:08 +01:00

16 lines
7.3 KiB
JavaScript

"use strict";(()=>{var e={};e.id=2896,e.ids=[2896],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")},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")},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}}})},2875:(e,r,t)=>{t.r(r),t.d(r,{config:()=>f,default:()=>p,routeModule:()=>_});var n={};t.r(n),t.d(n,{default:()=>d});var s=t(89947),a=t(2706),o=t(96762),i=t(30944),l=t(67619),c=t(69842),u=t(95969);async function d(e,r){if("POST"!==e.method)return r.json({msg:"Failed!"});let t=await (0,c.A)(e,r);if(!t)return r.json({success:!1,msg:"Unauthorized"});let{table:n,db:s,id:a}=e.body,o=e.body.schema;try{let e=`SELECT * FROM \`${s?.toString()||""}\`.\`${n}\` WHERE id=?`,t=[a?.toString()||""],l=await (0,i.A)({database:s?.toString()||"",queryString:e,queryValuesArray:t});if(!l||!l[0])return r.json({success:!1,msg:"Entry not found"});let c=JSON.parse(o||"{}");try{for(let e=0;e<c.fields.length;e++){let r=c.fields[e];r.encrypted&&r.fieldName&&(l[0][r.fieldName]=(0,u.A)({encryptedString:l[0][r.fieldName]}))}}catch(e){console.log("Error in parsing and decrypting fields in 'UpdateDbEntry' API ROute =>",e.message)}r.json({success:!0,entry:l[0]})}catch(e){(0,l.A)({component:"/api/refreshEntry/main-catch-error",message:e.message,user:t}),r.json({success:!1,msg:"Deletion Failed!"})}}let p=(0,o.M)(n,"default"),f=(0,o.M)(n,"config"),_=new s.PagesAPIRouteModule({definition:{kind:a.A.PAGES_API,page:"/api/refreshEntry",pathname:"/api/refreshEntry",bundlePath:"",filename:""},userland:n})},69842:(e,r,t)=>{t.d(r,{A:()=>a});var n=t(39908),s=t.n(n);async function a(e,r,t){let n=s()({req:e,level:t?"deep":void 0});return console.log(n),n.payload}},43775:(e,r,t)=>{t.d(r,{A:()=>a});var n=t(95969);let s=/^id$|^uuid$|^date_created$|^date_created_code$|^date_created_timestamp$|^date_updated$|^date_updated_code$|^date_updated_timestamp$/;async function a({unparsedResults:e,tableSchema:r}){let t=[];try{for(let a=0;a<e.length;a++){let o=e[a],i=Object.keys(o);for(let e=0;e<i.length;e++){let t=i[e],a=r?.fields[e];if(t?.match(s))continue;let l=o[t];("number"==typeof l||l)&&a?.encrypted&&l?.match(/./)&&(o[t]=(0,n.A)({encryptedString:l}))}t.push(o)}return t}catch(r){return console.log("ERROR in parseDbResults Function =>",r.message),e}}},67619:(e,r,t)=>{t.d(r,{A:()=>a});var n=t(29021),s=t.n(n);async function a({user:e,message:r,component:t,noMail:n,req:a}){let o=new Date,i=(()=>{if(!a)return null;try{let e=a.headers["x-forwarded-for"],r=a.headers["x-real-ip"],t=a.headers["cf-connecting-ip"],n=Array.isArray(e)?e[0]:e?.split(",")[0],s=t||n||r||a.socket.remoteAddress;if(!s)return null;return String(s)}catch(e){return null}})();try{let n=`🚀 SERVER ERROR ===========================
Error Message: ${r}
Component: ${t}`;e?.id&&e?.first_name&&e?.last_name&&e?.email&&(n+=`
User Id: ${e?.id}
User Name: ${e?.first_name} ${e?.last_name}
User Email: ${e?.email}`),a?.url&&(n+=`
URL: ${a.url}`),a?.body&&(n+=`
Request Body: ${JSON.stringify(a.body,null,4)}`),i&&(n+=`
IP: ${i}`),n+=`
Date: ${o.toDateString()}
========================================`,s().existsSync("./.tmp/error.log")||s().writeFileSync("./.tmp/error.log","","utf-8");let l=s().readFileSync("./.tmp/error.log","utf-8");s().writeFileSync("./.tmp/error.log",n),s().appendFileSync("./.tmp/error.log",`
${l}`)}catch(e){console.log("Server Error Reporting Error:",e.message)}}},30944:(e,r,t)=>{t.d(r,{A:()=>i});var n=t(43775),s=t(67619),a=t(7447),o=t(64292);async function i({queryString:e,queryValuesArray:r,database:t,tableSchema:i,useLocal:l,debug:c}){let u=(0,a.A)({fa:!0});l&&(u=(0,a.A)({local:!0})),t?.match(/^datasquirel$/)&&(u=(0,a.A)()),c&&(console.log("varDatabaseDbHandler:query:",e),console.log("varDatabaseDbHandler:values:",r));let d=await (0,o.A)(u,e,r);if(c&&console.log("varDatabaseDbHandler:results:",d),d&&i)try{return await (0,n.A)({unparsedResults:d,tableSchema:i})}catch(e){return console.log("\x1b[31mvarDatabaseDbHandler ERROR\x1b[0m =>",t,e),(0,s.A)({component:"varDatabaseDbHandler/lines-52-53",message:e.message}),null}else if(d)return d;else return null}},95969:(e,r,t)=>{t.d(r,{A:()=>o});var n=t(55511),s=t(79428),a=t(32443);function o({encryptedString:e,encryptionKey:r,encryptionSalt:t}){if(!e?.match(/./))return console.log("Encrypted string is invalid"),e;let{key:o,salt:i,keyLen:l,algorithm:c,bufferAllocSize:u}=(0,a.A)({encryptionKey:r});if(!o?.match(/.{8,}/))return console.log("Decrption key is invalid"),e;if(!i?.match(/.{8,}/))return console.log("Decrption salt is invalid"),e;let d=(0,n.scryptSync)(o,i,l),p=s.Buffer.alloc(u,0),f=(0,n.createDecipheriv)(c,d,p);try{let r=f.update(e,"hex","utf8");return r+=f.final("utf8")}catch(r){return console.log("Error in decrypting =>",r.message),e}}},64292:(e,r,t)=>{async function n(e,r,t){try{if("string"==typeof r){let n=await e.query(s(r),t);return JSON.parse(JSON.stringify(n))}if("object"!=typeof r)return null;{let t=[];for(let n=0;n<r.length;n++)try{let a=r[n],o=await e.query(s(a.query),a.values);t.push(JSON.parse(JSON.stringify(o)))}catch(e){t.push(null)}return t}}catch(e){return null}finally{e.end()}}function s(e){return e.replace(/\n/gm,"").replace(/ {2,}/g,"").trim()}t.d(r,{A:()=>n})},7447:(e,r,t)=>{t.d(r,{A:()=>a});var n=t(9973),s=t.n(n);function a(e){return e?.ro?DSQL_READ_ONLY_DB_CONN||s()({config:{host:process.env.DSQL_DB_HOST,user:process.env.DSQL_DB_READ_ONLY_USERNAME,password:process.env.DSQL_DB_READ_ONLY_PASSWORD,port:process.env.DSQL_DB_PORT?Number(process.env.DSQL_DB_PORT):void 0,charset:"utf8mb4"}}):e?.fa?global.DSQL_FULL_ACCESS_DB_CONN||s()({config:{host:process.env.DSQL_DB_HOST,user:process.env.DSQL_DB_FULL_ACCESS_USERNAME,password:process.env.DSQL_DB_FULL_ACCESS_PASSWORD,port:process.env.DSQL_DB_PORT?Number(process.env.DSQL_DB_PORT):void 0,charset:"utf8mb4"}}):global.DSQL_DB_CONN||s()({config:{host:process.env.DSQL_DB_HOST,user:process.env.DSQL_DB_USERNAME,password:process.env.DSQL_DB_PASSWORD,database:e?.noDb?void 0:process.env.DSQL_DB_NAME,port:process.env.DSQL_DB_PORT?Number(process.env.DSQL_DB_PORT):void 0,charset:"utf8mb4"}})}},32443:(e,r,t)=>{t.d(r,{A:()=>n});function n(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?function(e,r){try{let r=Number(e);if("number"!=typeof r||isNaN(r))return 0;return Math.round(r)}catch(e){return console.log(`Numberfy ERROR: ${e.message}`),0}}(process.env.DSQL_ENCRYPTION_BUFFER_ALLOCATION_SIZE):void 0)||16}}},2706:(e,r)=>{Object.defineProperty(r,"A",{enumerable:!0,get:function(){return t}});var t=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,r,t)=>{e.exports=t(75600)}};var r=require("../../webpack-api-runtime.js");r.C(e);var t=r(r.s=2875);module.exports=t})();