"use strict";(()=>{vare={};e.id=8935,e.ids=[8935],e.modules={27825:e=>{e.exports=require("lodash")},75600:e=>{e.exports=require("next/dist/compiled/next-server/pages-api.runtime.prod.js")},72583:e=>{e.exports=require("sanitize-html")},9973:e=>{e.exports=require("serverless-mysql")},79428:e=>{e.exports=require("buffer")},55511:e=>{e.exports=require("crypto")},29021:e=>{e.exports=require("fs")},34042:(e,r,t)=>{t.r(r),t.d(r,{config:()=>f,default:()=>m,routeModule:()=>E});vars={};t.r(s),t.d(s,{default:()=>p});vari=t(89947),a=t(2706),n=t(96762),o=t(69842),l=t(67619),d=t(27825),u=t.n(d),c=t(48786),_=t(98e3);asyncfunctionp(e,r){if("POST"!==e.method)returnr.json({user:null,msg:"Registration Failed!"});lett=await(0,o.A)(e,r,!0);if(!t)returnr.json({success:!1,msg:"Unauthorized"});lets=u().cloneDeep(e.body),i=s.inviting_user_id,a=s.invited_user_email,n=s.database_access,d=s.priviledge;try{lete=await(0,c.A)("SELECT email FROM user_users WHERE user_id=? AND invited_user_id=? AND user_type='admin' AND email=?",[i,t.id,t.email]);if(e&&e[0])returnr.json({success:!1});lets=await(0,_.A)({dbFullName:"datasquirel",tableName:"user_users",data:{user_id:i,invited_user_id:t.id,database_access:n,user_priviledge:d,user_type:"admin",first_name:t.first_name,last_name:t.last_name,email:t.email,username:t.first_name,image:t.image,image_thumbnail:t.image_thumbnail}});await(0,c.A)("UPDATE invitations SET invitation_status='Accepted' WHERE inviting_user_id=? AND invited_user_email=?",[i,a]);leto=await(0,c.A)("SELECT db_tables_data FROM invitations WHERE inviting_user_id=?",[i]);if(await(0,c.A)(`DELETE FROM delegated_user_tables WHERE root_user_id='${i}' AND delegated_user_id='${t.id}'`),o&&o[0]){lete=o[0].db_tables_data.split("|");for(letr=0;r<e.length;r++){let[s,a]=e[r].split("-");await(0,_.A)({dbFullName:"datasquirel",tableName:"delegated_user_tables",data:{delegated_user_id:t.id,root_user_id:i,database:s,table:a,priviledge:d}})}}r.json({success:!!s?.insertId})}catch(s){(0,l.default)({component:"/api/acceptUserInvitation/catch-error",message:s.message,user:t,req:e}),r.json({success:!1})}}letm=(0,n.M)(s,"default"),f=(0,n.M)(s,"config"),E=newi.PagesAPIRouteModule({definition:{kind:a.A.PAGES_API,page:"/api/acceptUserInvitation",pathname:"/api/acceptUserInvitation",bundlePath:"",filename:""},userland:s})},69842:(e,r,t)=>{t.d(r,{A:()=>l});vars=t(48786),i=t(95969),a=t(29021),n=t.n(a),o=t(89159);asyncfunctionl(e,r,t){try{let{keyCookieName:a,csrfCookieName:l}=(0,o.A)();if(!e.cookies?.[a]?.match(/./))throwError("Request Cookies not Found!");letd=(0,i.A)({encryptedString:e.cookies[a]});if(!d)throwError("Couldn't decrypt auth cookie!");letu=JSON.parse(d);if(!u.csrf_k)throwError("No `csrf_k` present in user Object!");if(t&&!Object.keys(e.headers).find(e=>e.includes(u.csrf_k)))throwError("Deep Auth Failed. `csrf` key not found in request headers!");letc=process.env.DSQL_USER_LOGIN_KEYS_PATH;if(!c)throwError("DSQL_USER_LOGIN_KEYS_PATH env variable not found. Please set this variable.");if(t&&!n().existsSync(`${c}/${u.csrf_k}`))throwError("Key not found in Auth Keys Folder!");if(0==u.verification_status&&!t){lete=await(0,s.A)(`SELECT verification_status FROM users WHERE id='${u.id}'`);e&&e[0]&&1==e[0].verification_status&&r.setHeader("Set-Cookie",["user_refresh=1"])}if(u?.date&&Date.now()-u.date>6048e5)throwError("Key expired!");returnu}catch(e){returnconsole.log(`userAuth Error: ${e.message}`),null}}},89159:(e,r,t)=>{t.d(r,{A:()=>s});functions(e){letr=process.env.DSQL_COOKIES_PREFIX||"dsql_",t=process.env.DSQL_COOKIES_KEY_NAME||"key",s=process.env.DSQL_COOKIES_CSRF_NAME||"csrf",i=process.env.DSQL_COOKIES_ONE_TIME_CODE_NAME||"one-time-code",a=e?.database?.replace(/^datasquirel_user_\d+_/,"")||process.env.DSQL_DB_NAME?.replace(/^datasquirel_user_\d+_/,""),n=r;e?.userId&&(n+=`user_${e.userId}_`),a&&(n+=`${a}_`),n+=t;leto=r;e?.userId&&(o+=`user_${e.userId}_`),a&&(o+=`${a}_`),o+=s;letl=r;returne?.userId&&(l+=`user_${e.userId}_`),a&&(l+=`${a}_`),{keyCookieName:n,csrfCookieName:o,oneTimeCodeName:l+=i}}},67619:(e,r,t)=>{t.r(r)