dsql-admin/dsql-app/.local_dist/server/chunks/8540.js

16 lines
6.1 KiB
JavaScript
Raw Normal View History

2024-12-15 11:27:16 +00:00
"use strict";exports.id=8540,exports.ids=[8540],exports.modules={77619:(e,t,r)=>{let a=r(29021),l=r(72835);e.exports=({key:e,database:t,table:r,user_id:s,media:n})=>{if(!e||!s)return null;try{let i=process.env.DSQL_API_KEYS_PATH;if(!i)throw Error("process.env.DSQL_API_KEYS_PATH variable not found");let o=l({encryptedString:e}),c=JSON.parse(o||""),u=a.existsSync(`${i}/${c.sign}`);if(String(c.user_id)!==String(s)||!u)return null;if(!c.target_database||n)return c;if(!t&&c.target_database)return null;let d=c.target_database?.split(",").includes(String(t));if(d&&!c.target_table)return c;if(d&&!r&&c.target_table)return null;if(c.target_table?.split(",").includes(String(r)))return c;return null}catch(e){return console.log(`api-cred ERROR: ${e.message}`),{error:`api-cred ERROR: ${e.message}`}}}},64122:(e,t,r)=>{let a=r(51348),l=r(21339),s=r(44900);async function n({dbContext:e,paradigm:t,dbFullName:r,tableName:n,identifierColumnName:i,identifierValue:o,useLocal:c}){try{let u=!!c||!e?.match(/dsql.user/i)&&(!r||!!r.match(/^datasquirel$/)),d=c?s:u?a:l,p=`DELETE FROM ${n} WHERE \`${i}\`=?`;return u?await d(p,[o]):await d({paradigm:t,queryString:p,database:r,queryValues:[o]})}catch(e){return null}}e.exports=n},8238:(e,t,r)=>{r(29021),r(44900);let a=r(94709),l=r(96064),s=r(48225),n=r(47670),i=r(33364),o=r(64122);r(6061);let c=r(33872);async function u({dbFullName:e,query:t,readOnly:r,dbSchema:u,queryValuesArray:d,tableName:p,local:m}){let g,f,y;if(u)try{let e=p||("string"==typeof t?null:t?t?.table:null);if(!e)throw Error("No table name provided");y=u.tables.filter(t=>t?.tableName===e)[0]}catch(e){}try{if("string"==typeof t){let s=c(t);if(r&&s.match(/^alter|^delete|information_schema|^create/i))throw Error("Wrong Input!");g=r?await l({queryString:s,queryValuesArray:d?.map(e=>String(e)),database:e,tableSchema:y,useLocal:m}):await a({queryString:s,queryValuesArray:d?.map(e=>String(e)),database:e,tableSchema:y,local:m})}else if("object"==typeof t){let{data:r,action:a,table:l,identifierColumnName:s,identifierValue:c,update:u,duplicateColumnName:d,duplicateColumnValue:p}=t;switch(a.toLowerCase()){case"insert":g=await n({dbContext:m?"Master":"Dsql User",paradigm:"Full Access",dbFullName:e,tableName:l,data:r,update:u,duplicateColumnName:d,duplicateColumnValue:p,tableSchema:y,useLocal:m}),g?.insertId||(f=Error("Couldn't insert data"));break;case"update":g=await i({dbContext:m?"Master":"Dsql User",paradigm:"Full Access",dbFullName:e,tableName:l,data:r,identifierColumnName:s,identifierValue:c,tableSchema:y,useLocal:m});break;case"delete":g=await o({dbContext:m?"Master":"Dsql User",paradigm:"Full Access",dbFullName:e,tableName:l,identifierColumnName:s,identifierValue:c,tableSchema:y,useLocal:m});break;default:g=null}}}catch(e){s({component:"functions/backend/runQuery",message:e.message}),g=null,e=e.message}return{result:g,error:f}}e.exports=u},30003:e=>{e.exports=/^id$|^uuid$|^date_created$|^date_created_code$|^date_created_timestamp$|^date_updated$|^date_updated_code$|^date_updated_timestamp$/},94709:(e,t,r)=>{let a=r(21339),l=r(44900),s=r(6061),n=r(48225);e.exports=async function({queryString:e,database:t,tableSchema:r,queryValuesArray:i,local:o}){let c;try{c=o?await l(e,i):await a({paradigm:"Full Access",database:t,queryString:e,queryValues:i})}catch(e){return n({component:"fullAccessDbHandler",message:e.message}),e.message}if(c&&r){let e=c;return await s({unparsedResults:e,tableSchema:r})}return c||null}},6061:(e,t,r)=>{let a=r(72835),l=r(30003);e.exports=async function({unparsedResults:e,tableSchema:t}){let r=[];try{for(let s=0;s<e.length;s++){let n=e[s],i=Object.keys(n);for(let e=0;e<i.length;e++){let r=i[e],s=t?.fields[e];if(r?.match(l))continue;let o=n[r];("number"==typeof o||o)&&s?.encrypted&&o?.match(/./)&&(n[r]=a({encryptedString:o}))}r.push(n)}return r}catch(t){return console.log("ERROR in parseDbResults Function =>",t.message),e}}},48225:(e,t,r)=>{let a=r(29021),{IncomingMessage:l}=r(81630);e.exports=async function({user:e,message:t,component:r,noMail:l,req:s}){let n=new Date,i=(()=>{if(!s)return null;try{let e=s.headers["x-forwarde
2024-12-08 19:56:57 +00:00
Error Message: ${t}
Component: ${r}`;e?.id&&e?.first_name&&e?.last_name&&e?.email&&(l+=`
User Id: ${e?.id}
User Name: ${e?.first_name} ${e?.last_name}
2024-12-15 11:27:16 +00:00
User Email: ${e?.email}`),s?.url&&(l+=`
URL: ${s.url}`),s?.body&&(l+=`
Request Body: ${JSON.stringify(s.body,null,4)}`),i&&(l+=`
2024-12-08 19:56:57 +00:00
IP: ${i}`),l+=`
2024-12-15 11:27:16 +00:00
Date: ${n.toDateString()}
2024-12-08 19:56:57 +00:00
========================================`,a.existsSync("./.tmp/error.log")||a.writeFileSync("./.tmp/error.log","","utf-8");let o=a.readFileSync("./.tmp/error.log","utf-8");a.writeFileSync("./.tmp/error.log",l),a.appendFileSync("./.tmp/error.log",`
2024-12-15 11:27:16 +00:00
${o}`)}catch(e){console.log("Server Error Reporting Error:",e.message)}}},96064:(e,t,r)=>{r(29021);let a=r(48225),l=r(6061),s=r(21339),n=r(44900);e.exports=async function({queryString:e,database:t,queryValuesArray:r,tableSchema:i,useLocal:o}){let c;try{c=o?await n(e,r):await s({paradigm:"Read Only",database:t,queryString:e,queryValues:r})}catch(e){return a({component:"varReadOnlyDatabaseDbHandler",message:e.message,noMail:!0}),e.message}if(!c)return null;{let e=c;return await l({unparsedResults:e,tableSchema:i})}}},72835:(e,t,r)=>{let{scryptSync:a,createDecipheriv:l}=r(55511),{Buffer:s}=r(79428);e.exports=({encryptedString:e,encryptionKey:t,encryptionSalt:r})=>{if(!e?.match(/./))return console.log("Encrypted string is invalid"),e;let n=t||process.env.DSQL_ENCRYPTION_PASSWORD,i=r||process.env.DSQL_ENCRYPTION_SALT,o=process.env.DSQL_ENCRYPTION_KEY_LENGTH?Number(process.env.DSQL_ENCRYPTION_KEY_LENGTH):24;if(!n?.match(/.{8,}/))return console.log("Decrption key is invalid"),e;if(!i?.match(/.{8,}/))return console.log("Decrption salt is invalid"),e;let c=l("aes-192-cbc",a(n,i,o),s.alloc(16,0));try{let t=c.update(e,"hex","utf8");return t+=c.final("utf8")}catch(t){return console.log("Error in decrypting =>",t.message),e}}},33872:(e,t,r)=>{r(55591),r(81630),e.exports=function(e){return e.replace(/\n|\r|\n\r|\r\n/gm," ").replace(/ {2,}/g," ").trim()}}};