8 lines
4.7 KiB
JavaScript
8 lines
4.7 KiB
JavaScript
"use strict";(()=>{var e={};e.id=7258,e.ids=[7258],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")},96762:(e,r)=>{Object.defineProperty(r,"M",{enumerable:!0,get:function(){return function e(r,s){return s in r?r[s]:"then"in r&&"function"==typeof r.then?r.then(r=>e(r,s)):"function"==typeof r&&"default"===s?r:void 0}}})},45310:(e,r,s)=>{s.r(r),s.d(r,{config:()=>d,default:()=>l,routeModule:()=>c});var t={};s.r(t),s.d(t,{default:()=>o});var n=s(89947),i=s(2706),a=s(96762),u=s(48786),_=s(69842);async function o(e,r){if("GET"!==e.method)return r.json({msg:"Failed!"});let s=await (0,_.A)(e,r);if(!s)return r.json({success:!1,msg:"Unauthorized"});let t=await (0,u.A)(`
|
|
SELECT
|
|
user_users.user_id,user_users.database_access,user_users.user_id,user_users.user_priviledge,users.first_name,users.last_name,users.email,users.image_thumbnail
|
|
FROM
|
|
user_users JOIN users ON user_users.user_id=users.id
|
|
WHERE
|
|
user_users.invited_user_id='${s.id}'
|
|
`),n=[];if(t&&t[0])for(let e=0;e<t.length;e++){let r=t[e],{database_access:s,user_id:i,user_priviledge:a}=r;if(!s?.match(/./))continue;let _=await (0,u.A)(`SELECT * FROM user_databases WHERE (${s.split("|").map(e=>`db_slug='${e}'`).join(" OR ")}) AND user_id=${i}`);for(let e=0;e<_.length;e++){let s=_[e];n.push({id:s.id,user_id:r.user_id,first_name:r.first_name,last_name:r.last_name,email:r.email,image_thumbnail:r.image_thumbnail,db_name:s.db_name,db_slug:s.db_slug,db_full_name:s.db_full_name,db_image:s.db_image,db_description:s.db_description,date_created:s.date_created,user_priviledge:a})}}r.json({success:!0,databases:n})}let l=(0,a.M)(t,"default"),d=(0,a.M)(t,"config"),c=new n.PagesAPIRouteModule({definition:{kind:i.A.PAGES_API,page:"/api/getDelegatedDatabases",pathname:"/api/getDelegatedDatabases",bundlePath:"",filename:""},userland:t})},69842:(e,r,s)=>{s.d(r,{A:()=>_});var t=s(48786),n=s(95969),i=s(29021),a=s.n(i),u=s(89159);async function _(e,r,s){let{keyCookieName:i,csrfCookieName:_}=(0,u.A)();if(!e.cookies?.[i]?.match(/./))return null;let o=(0,n.A)({encryptedString:e.cookies[i]});if(!o)return null;let l=JSON.parse(o);if(!l.csrf_k||s&&!Object.keys(e.headers).find(e=>e.includes(l.csrf_k)))return null;let d=process.env.DSQL_USER_LOGIN_KEYS_PATH;if(!d)return console.log("DSQL_USER_LOGIN_KEYS_PATH env variable not found. Please set this variable."),null;if(s&&!a().existsSync(`${d}/${l.csrf_k}`))return null;if(0==l.verification_status&&!s){let e=await (0,t.A)(`SELECT verification_status FROM users WHERE id='${l.id}'`);e&&e[0]&&1==e[0].verification_status&&r.setHeader("Set-Cookie",["user_refresh=1"])}return l?.date&&Date.now()-l.date>6048e5?null:l}},89159:(e,r,s)=>{s.d(r,{A:()=>t});function t(e){let r=process.env.DSQL_COOKIES_PREFIX||"dsql_",s=process.env.DSQL_COOKIES_KEY_NAME||"key",t=process.env.DSQL_COOKIES_CSRF_NAME||"csrf",n=process.env.DSQL_COOKIES_ONE_TIME_CODE_NAME||"one-time-code",i=e?.database?.replace(/^datasquirel_user_\d+_/,"")||process.env.DSQL_DB_NAME?.replace(/^datasquirel_user_\d+_/,""),a=r;e?.userId&&(a+=`user_${e.userId}_`),i&&(a+=`${i}_`),a+=s;let u=r;e?.userId&&(u+=`user_${e.userId}_`),i&&(u+=`${i}_`),u+=t;let _=r;return e?.userId&&(_+=`user_${e.userId}_`),i&&(_+=`${i}_`),{keyCookieName:a,csrfCookieName:u,oneTimeCodeName:_+=n}}},95969:(e,r,s)=>{s.d(r,{A:()=>i});var t=s(55511),n=s(79428);function i({encryptedString:e,encryptionKey:r,encryptionSalt:s}){if(!e?.match(/./))return console.log("Encrypted string is invalid"),e;let i=r||process.env.DSQL_ENCRYPTION_PASSWORD,a=s||process.env.DSQL_ENCRYPTION_SALT,u=process.env.DSQL_ENCRYPTION_KEY_LENGTH?Number(process.env.DSQL_ENCRYPTION_KEY_LENGTH):24;if(!i?.match(/.{8,}/))return console.log("Decrption key is invalid"),e;if(!a?.match(/.{8,}/))return console.log("Decrption salt is invalid"),e;let _=(0,t.scryptSync)(i,a,u),o=n.Buffer.alloc(16,0),l=(0,t.createDecipheriv)("aes-192-cbc",_,o);try{let r=l.update(e,"hex","utf8");return r+=l.final("utf8")}catch(r){return console.log("Error in decrypting =>",r.message),e}}},48786:(e,r,s)=>{s.d(r,{A:()=>t});async function t(...e){let r=global.DSQL_DB_CONN;try{if(!r)throw Error("No Connection provided to DB_HANDLER function!");let s=await r.query(...e);return JSON.parse(JSON.stringify(s))}catch(e){return console.log("DB Error =>",e),{success:!1,error:e.message}}finally{await r?.end()}}},2706:(e,r)=>{Object.defineProperty(r,"A",{enumerable:!0,get:function(){return s}});var s=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,s)=>{e.exports=s(75600)}};var r=require("../../webpack-api-runtime.js");r.C(e);var s=r(r.s=45310);module.exports=s})(); |