dsql-admin/dsql-app/.local_dist/server/pages/api/connect/disconnect.js

16 lines
7.1 KiB
JavaScript
Raw Normal View History

2025-02-12 16:56:44 +00:00
"use strict";(()=>{var e={};e.id=964,e.ids=[964],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")},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}}})},48171:(e,r,t)=>{t.r(r),t.d(r,{config:()=>p,default:()=>d,routeModule:()=>f});var n={};t.r(n),t.d(n,{default:()=>u});var o=t(89947),i=t(2706),a=t(96762),l=t(67619),s=t(69842),c=t(30802);async function u(e,r){if("POST"!==e.method)return r.json({msg:"Failed!"});let t=await (0,s.A)(e,r,!0);if(!t)return r.json({success:!1,msg:"Unauthorized"});let{dbId:n}=e.body;try{if(!n)throw Error("No Target Database ID provided");await (0,c.A)({tableName:"user_databases",data:{remote_connected:0,remote_connection_host:"",remote_connection_key:"",remote_connection_type:"",remote_db_full_name:""},identifierColumnName:"id",identifierValue:n}),r.json({success:!0})}catch(e){console.log("Disconnect Error, =>",e.message),(0,l.A)({component:"/api/connect/verify/main-catch-error",message:e.message,user:t}),r.json({success:!1,msg:"Operation Failed!"})}}let d=(0,a.M)(n,"default"),p=(0,a.M)(n,"config"),f=new o.PagesAPIRouteModule({definition:{kind:i.A.PAGES_API,page:"/api/connect/disconnect",pathname:"/api/connect/disconnect",bundlePath:"",filename:""},userland:n})},69842:(e,r,t)=>{t.d(r,{A:()=>i});var n=t(39383),o=t.n(n);async function i(e,r,t){return o()({req:e,level:t?"deep":void 0}).payload}},30802:(e,r,t)=>{t.d(r,{A:()=>c});var n=t(72583),o=t.n(n),i=t(92652),a=t(68829),l=t(52939),s=t(64292);async function c({dbContext:e,dbFullName:r,tableName:t,data:n,tableSchema:c,identifierColumnName:u,identifierValue:d,encryptionKey:p,encryptionSalt:f,forceLocal:g}){if(!n||!Object.keys(n).length)return null;let m=!!g||(0,l.A)({dbContext:e,dbFullName:r}),y=m?global.DSQL_DB_CONN:global.DSQL_FULL_ACCESS_DB_CONN||global.DSQL_DB_CONN;m?global.DSQL_DB_CONN:global.DSQL_READ_ONLY_DB_CONN||global.DSQL_DB_CONN;let _=Object.keys(n),h=[],S=[];for(let e=0;e<_.length;e++)try{let r=_[e],t=n[r],l=c?c?.fields?.filter(e=>e.fieldName===r):null,s=l&&l[0]?l[0]:null;if(null==t||void 0==t)continue;let u=/<[^>]+>/g;(s?.richText||String(t).match(u))&&(t=o()(t,i.A)),s?.encrypted&&(t=(0,a.A)({data:t,encryptionKey:p,encryptionSalt:f})),"object"==typeof t&&(t=JSON.stringify(t)),s?.pattern&&!new RegExp(s.pattern,s.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?S.push(String(t)):S.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 A=`UPDATE ${m?"":`\`${r}\`.`}\`${t}\` SET ${h.join(",")} WHERE \`${u}\`=?`;return S.push(d),await (0,s.A)(y,A,S)}},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"]}}},67619:(e,r,t)=>{t.d(r,{A:()=>i});var n=t(29021),o=t.n(n);async function i({user:e,message:r,component:t,noMail:n,req:i}){let a=new Date,l=(()=>{if(!i)return null;try{let e=i.headers["x-forwarded-for"],r=i.headers["x-real-ip"],t=i.headers["cf-connecting-ip"],n=Array.isArray(e)?e[0]:e?.split(",")[0],o=t||n||r||i.socket.remoteAddress;if(!o)return null;return String(o)}catch(e){return null}})();try{let n=`🚀 SERVER ERROR ===========================
2024-12-08 19:56:57 +00:00
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}
2025-01-28 18:43:16 +00:00
User Email: ${e?.email}`),i?.url&&(n+=`
URL: ${i.url}`),i?.body&&(n+=`
Request Body: ${JSON.stringify(i.body,null,4)}`),l&&(n+=`
IP: ${l}`),n+=`
2025-01-14 15:27:08 +00:00
Date: ${a.toDateString()}
2025-01-28 18:43:16 +00:00
========================================`,o().existsSync("./.tmp/error.log")||o().writeFileSync("./.tmp/error.log","","utf-8");let s=o().readFileSync("./.tmp/error.log","utf-8");o().writeFileSync("./.tmp/error.log",n),o().appendFileSync("./.tmp/error.log",`
2024-12-08 19:56:57 +00:00
2025-02-12 16:56:44 +00:00
${s}`)}catch(e){console.log("Server Error Reporting Error:",e.message)}}},68829:(e,r,t)=>{t.d(r,{A:()=>a});var n=t(55511),o=t(79428),i=t(31542);function a({data:e,encryptionKey:r,encryptionSalt:t}){if(!e?.match(/./))return console.log("Encryption string is invalid"),e;let{key:a,salt:l,keyLen:s,algorithm:c,bufferAllocSize:u}=(0,i.A)({encryptionKey:r});if(!a?.match(/.{8,}/))return console.log("Encryption key is invalid"),e;if(!l?.match(/.{8,}/))return console.log("Encryption salt is invalid"),e;let d=(0,n.scryptSync)(a,l,s),p=o.Buffer.alloc(u,0),f=(0,n.createCipheriv)(c,d,p);try{let r=f.update(e,"utf8","hex");return r+=f.final("hex")}catch(r){return console.log("Error in encrypting =>",r.message),e}}},52939:(e,r,t)=>{t.d(r,{A:()=>n});function n({dbContext:e,dbFullName:r}){return!e?.match(/dsql.user/i)&&(!!global.DSQL_USE_LOCAL||!r||!!r.match(/^datasquirel$/))}},64292:(e,r,t)=>{async function n(e,r,t){try{if(!e)throw Error("No Connection Found!");if(!r)throw Error("Query String Required!");if("string"==typeof r){let n=await e.query(o(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 i=r[n],a=await e.query(o(i.query),i.values);t.push(JSON.parse(JSON.stringify(a)))}catch(e){console.log(`connDbHandler Query Error: ${e.message}`),t.push(null)}return t}}catch(r){return console.log(`connDbHandler Error: ${r.message}`),console.log(e?.config()),null}finally{e?.end()}}function o(e){return e.replace(/\n/gm,"").replace(/ {2,}/g,"").trim()}t.d(r,{A:()=>n})},31542:(e,r,t)=>{t.d(r,{A:()=>o});var n=t(82535);function o(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,r,t)=>{t.d(r,{A:()=>n});function n(e,r){try{let t=Number(e);if("number"!=typeof t||isNaN(t))return 0;if(r)return Number(t.toFixed(r));return Math.round(t)}catch(e){return console.log(`Numberfy ERROR: ${e.message}`),0}}},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=48171);module.exports=t})();