2025-01-14 06:42:13 +00:00
|
|
|
"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")},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}}})},68084:(e,r,t)=>{t.r(r),t.d(r,{config:()=>m,default:()=>S,routeModule:()=>_});var n={};t.r(n),t.d(n,{default:()=>g});var i=t(89947),s=t(2706),a=t(96762),o=t(29021),l=t.n(o),c=t(67619),u=t(56081),d=t(95969),p=t(33873),f=t.n(p);async function g(e,r){if("POST"!==e.method)return r.json({msg:"Failed!"});let t=e.body,{url:n,key:i,database:s,dbSchema:a,type:o}=t;try{let e=(0,u.A)({key:i,database:s?.db_slug,user_id:t.user_id});if(!e?.user_id)throw Error("Api Credentials invalid!");let n=(0,d.A)({encryptedString:i}),{user_id:a,full_access:o,csrf:c}=n?JSON.parse(n):null;if(!o||!c)return r.json({success:!1,msg:"Unauthorized"});let p=f().resolve(String(process.env.DSQL_USER_DB_SCHEMA_PATH),`user-${a}`,"main.json");if(!l().existsSync(p))throw Error("User Shcema data file doesn't exist!");let g=JSON.parse(l().readFileSync(p,"utf-8"));r.json({success:!0,payload:g})}catch(e){console.log("Connect Verification Error, =>",e.message),(0,c.A)({component:"/api/connect/main-catch-error",message:e.message}),r.json({success:!1,msg:"Connect Verification Operation Failed!"})}}let S=(0,a.M)(n,"default"),m=(0,a.M)(n,"config"),_=new i.PagesAPIRouteModule({definition:{kind:s.A.PAGES_API,page:"/api/connect",pathname:"/api/connect",bundlePath:"",filename:""},userland:n})},56081:(e,r,t)=>{t.d(r,{A:()=>a});var n=t(29021),i=t.n(n),s=t(95969);let a=({key:e,database:r,table:t,user_id:n,media:a})=>{if(!e||!n)return null;try{let o=process.env.DSQL_API_KEYS_PATH;if(!o)throw Error("process.env.DSQL_API_KEYS_PATH variable not found");let l=(0,s.A)({encryptedString:e}),c=JSON.parse(l||""),u=i().existsSync(`${o}/${c.sign}`);if(String(c.user_id)!==String(n)||!u)return null;if(!c.target_database||a)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}`}}}},67619:(e,r,t)=>{t.d(r,{A:()=>s});var n=t(29021),i=t.n(n);async function s({user:e,message:r,component:t,noMail:n,req:s}){let a=new Date,o=(()=>{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 n=`🚀 SERVER ERROR ===========================
|
2025-01-13 08:00:21 +00:00
|
|
|
${l}`)}catch(e){console.log("Server Error Reporting Error:",e.message)}}},95969:(e,r,t)=>{t.d(r,{A:()=>s});var n=t(55511),i=t(79428);function s({encryptedString:e,encryptionKey:r,encryptionSalt:t}){if(!e?.match(/./))return console.log("Encrypted string is invalid"),e;let s=r||process.env.DSQL_ENCRYPTION_PASSWORD,a=t||process.env.DSQL_ENCRYPTION_SALT,o=process.env.DSQL_ENCRYPTION_KEY_LENGTH?Number(process.env.DSQL_ENCRYPTION_KEY_LENGTH):24;if(!s?.match(/.{8,}/))return console.log("Decrption key is invalid"),e;if(!a?.match(/.{8,}/))return console.log("Decrption salt is invalid"),e;let l=(0,n.scryptSync)(s,a,o),c=i.Buffer.alloc(16,0),u=(0,n.createDecipheriv)("aes-192-cbc",l,c);try{let r=u.update(e,"hex","utf8");return r+=u.final("utf8")}catch(r){return console.log("Error in decrypting =>",r.message),e}}},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=68084);module.exports=t})();
|