16 lines
4.6 KiB
JavaScript
16 lines
4.6 KiB
JavaScript
"use strict";(()=>{var e={};e.id=7539,e.ids=[7539],e.modules={75600:e=>{e.exports=require("next/dist/compiled/next-server/pages-api.runtime.prod.js")},79428:e=>{e.exports=require("buffer")},55511:e=>{e.exports=require("crypto")},29021:e=>{e.exports=require("fs")},81630:e=>{e.exports=require("http")},33873:e=>{e.exports=require("path")},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}}})},8953:(e,r,t)=>{t.r(r),t.d(r,{config:()=>E,default:()=>_,routeModule:()=>P});var n={};t.r(n),t.d(n,{default:()=>m});var i=t(89947),s=t(2706),o=t(96762),a=t(48225),l=t.n(a),c=t(77619),u=t.n(c),d=t(72835),p=t.n(d),f=t(33873),g=t.n(f);let S=t(29021);async function m(e,r){if("POST"!==e.method)return r.json({msg:"Failed!"});let t=e.body,{url:n,key:i,database:s,dbSchema:o,type:a}=t;try{let e=u()({key:i,database:s?.db_slug,user_id:t.user_id});if(!e?.user_id)throw Error("Api Credentials invalid!");let n=p()({encryptedString:i}),{user_id:o,full_access:a,csrf:l}=n?JSON.parse(n):null;if(!a||!l)return r.json({success:!1,msg:"Unauthorized"});let c=g().resolve(String(process.env.DSQL_USER_DB_SCHEMA_PATH),`user-${o}`,"main.json");if(!S.existsSync(c))throw Error("User Shcema data file doesn't exist!");let d=JSON.parse(S.readFileSync(c,"utf-8"));r.json({success:!0,payload:d})}catch(e){console.log("Connect Verification Error, =>",e.message),l()({component:"/api/connect/main-catch-error",message:e.message}),r.json({success:!1,msg:"Connect Verification Operation Failed!"})}}let _=(0,o.M)(n,"default"),E=(0,o.M)(n,"config"),P=new i.PagesAPIRouteModule({definition:{kind:s.A.PAGES_API,page:"/api/connect",pathname:"/api/connect",bundlePath:"",filename:""},userland:n})},77619:(e,r,t)=>{let n=t(29021),i=t(72835);e.exports=({key:e,database:r,table:t,user_id:s,media:o})=>{if(!e||!s)return null;try{let a=process.env.DSQL_API_KEYS_PATH;if(!a)throw Error("process.env.DSQL_API_KEYS_PATH variable not found");let l=i({encryptedString:e}),c=JSON.parse(l||""),u=n.existsSync(`${a}/${c.sign}`);if(String(c.user_id)!==String(s)||!u)return null;if(!c.target_database||o)return c;if(!r&&c.target_database)return null;let d=c.target_database?.split(",").includes(String(r));if(d&&!c.target_table)return c;if(d&&!t&&c.target_table)return null;if(c.target_table?.split(",").includes(String(t)))return c;return null}catch(e){return console.log(`api-cred ERROR: ${e.message}`),{error:`api-cred ERROR: ${e.message}`}}}},48225:(e,r,t)=>{let n=t(29021),{IncomingMessage:i}=t(81630);e.exports=async function({user:e,message:r,component:t,noMail:i,req:s}){let o=new Date,a=(()=>{if(!s)return null;try{let e=s.headers["x-forwarded-for"],r=s.headers["x-real-ip"],t=s.headers["cf-connecting-ip"],n=Array.isArray(e)?e[0]:e?.split(",")[0],i=t||n||r||s.socket.remoteAddress;if(!i)return null;return String(i)}catch(e){return null}})();try{let i=`🚀 SERVER ERROR ===========================
|
|
Error Message: ${r}
|
|
Component: ${t}`;e?.id&&e?.first_name&&e?.last_name&&e?.email&&(i+=`
|
|
User Id: ${e?.id}
|
|
User Name: ${e?.first_name} ${e?.last_name}
|
|
User Email: ${e?.email}`),s?.url&&(i+=`
|
|
URL: ${s.url}`),s?.body&&(i+=`
|
|
Request Body: ${JSON.stringify(s.body,null,4)}`),a&&(i+=`
|
|
IP: ${a}`),i+=`
|
|
Date: ${o.toDateString()}
|
|
========================================`,n.existsSync("./.tmp/error.log")||n.writeFileSync("./.tmp/error.log","","utf-8");let l=n.readFileSync("./.tmp/error.log","utf-8");n.writeFileSync("./.tmp/error.log",i),n.appendFileSync("./.tmp/error.log",`
|
|
|
|
|
|
|
|
|
|
${l}`)}catch(e){console.log("Server Error Reporting Error:",e.message)}}},72835:(e,r,t)=>{let{scryptSync:n,createDecipheriv:i}=t(55511),{Buffer:s}=t(79428);e.exports=({encryptedString:e,encryptionKey:r,encryptionSalt:t})=>{if(!e?.match(/./))return console.log("Encrypted string is invalid"),e;let o=r||process.env.DSQL_ENCRYPTION_PASSWORD,a=t||process.env.DSQL_ENCRYPTION_SALT,l=process.env.DSQL_ENCRYPTION_KEY_LENGTH?Number(process.env.DSQL_ENCRYPTION_KEY_LENGTH):24;if(!o?.match(/.{8,}/))return console.log("Decrption key is invalid"),e;if(!a?.match(/.{8,}/))return console.log("Decrption salt is invalid"),e;let c=i("aes-192-cbc",n(o,a,l),s.alloc(16,0));try{let r=c.update(e,"hex","utf8");return r+=c.final("utf8")}catch(r){return console.log("Error in decrypting =>",r.message),e}}},2706:(e,r)=>{var t;Object.defineProperty(r,"A",{enumerable:!0,get:function(){return t}}),function(e){e.PAGES="PAGES",e.PAGES_API="PAGES_API",e.APP_PAGE="APP_PAGE",e.APP_ROUTE="APP_ROUTE",e.IMAGE="IMAGE"}(t||(t={}))},89947:(e,r,t)=>{e.exports=t(75600)}};var r=require("../../webpack-api-runtime.js");r.C(e);var t=r(r.s=8953);module.exports=t})(); |