"use strict";(()=>{var e={};e.id=2998,e.ids=[2998],e.modules={76102:e=>{e.exports=require("@moduletrace/datasquirel/dist/client")},39383:e=>{e.exports=require("@moduletrace/datasquirel/dist/package-shared/actions/users/user-auth")},65967:e=>{e.exports=require("@moduletrace/datasquirel/dist/package-shared/utils/ejson")},93726:e=>{e.exports=require("@moduletrace/datasquirel/dist/package-shared/utils/numberfy")},30889:e=>{e.exports=require("@moduletrace/datasquirel/dist/package-shared/utils/slugify")},75600:e=>{e.exports=require("next/dist/compiled/next-server/pages-api.runtime.prod.js")},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")},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}}})},55896:(e,r,s)=>{s.r(r),s.d(r,{config:()=>f,default:()=>E,routeModule:()=>L});var t={};s.r(t),s.d(t,{default:()=>D});var n=s(89947),o=s(2706),a=s(96762),i=s(69842),_=s(29021),c=s.n(_),u=s(67619),l=s(48786),S=s(68829),d=s(89159);async function p({userId:e,res:r,csrf:s}){try{let t=process.env.DSQL_USER_LOGIN_KEYS_PATH;if(!t)return console.log("DSQL_USER_LOGIN_KEYS_PATH env variable not found. Please set this variable."),null;let n=await (0,l.A)("SELECT * FROM users WHERE id=?",[e]);c().unlinkSync(`${t}/${s}`);let o=Math.random().toString(36).substring(2)+"-"+Math.random().toString(36).substring(2),a={id:n[0].id,stripe_id:n[0].stripe_id||"",first_name:n[0].first_name,last_name:n[0].last_name,email:n[0].email,social_id:n[0].social_id,image:n[0].image,image_thumbnail:n[0].image_thumbnail,verification_status:n[0].verification_status,social_login:n[0].social_login,social_platform:n[0].social_platform,csrf_k:o,logged_in_status:!0,date:Date.now()},i=(0,S.A)({data:JSON.stringify(a)});c().writeFileSync(`${t}/${o}`,JSON.stringify(a));let{keyCookieName:_,csrfCookieName:u}=(0,d.A)();return r.setHeader("Set-Cookie",[`${_}=${i};samesite=strict;path=/;HttpOnly=true;Secure=true`,`${u}=${o};samesite=strict;path=/;HttpOnly=true;Secure=true`,"user_refresh=1"]),a}catch(r){return(0,u.A)({component:"reAuthUser",message:r.message,user:{id:e}}),null}}async function D(e,r){"POST"!==e.method&&r.json({msg:"Failed!"});let{user:s,appData:t}=await (0,i.A)(e,r,!0);if(!s){console.log("No user Found"),r.redirect(307,"/logout");return}let n=await p({userId:s.id,res:r,csrf:s.csrf_k}),o={status:!!n,csrf:n?.csrf_k,user:n};r.json(o)}let E=(0,a.M)(t,"default"),f=(0,a.M)(t,"config"),L=new n.PagesAPIRouteModule({definition:{kind:o.A.PAGES_API,page:"/api/reAuthenticateUser",pathname:"/api/reAuthenticateUser",bundlePath:"",filename:""},userland:t})},55153:(e,r,s)=>{s.d(r,{On:()=>n.a,_n:()=>a}),s(76102);var t=s(65967),n=s.n(t);s(30889);var o=s(93726);let a=s.n(o)()},69842:(e,r,s)=>{s.d(r,{A:()=>a});var t=s(39383),n=s.n(t),o=s(55153);async function a(e,r,s,t){let a=n()({req:e,level:s?"deep":void 0}),i={DSQL_REMOTE_SQL_HOST:process.env.DSQL_REMOTE_SQL_HOST,DSQL_SU_USER_ID:process.env.DSQL_SU_USER_ID,DSQL_HOST_ENV:process.env.DSQL_HOST_ENV,DSQL_HOST:process.env.DSQL_HOST,DSQL_STATIC_HOST:process.env.DSQL_STATIC_HOST,DSQL_GOOGLE_CLIENT_ID:process.env.DSQL_GOOGLE_CLIENT_ID,DSQL_TINY_MCE_API_KEY:process.env.DSQL_TINY_MCE_API_KEY};return t&&a.payload?.id&&(0,o._n)(process.env.DSQL_SU_USER_ID)!==a.payload.id?{user:null,appData:i}:{user:a.payload,appData:i}}},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",o=e?.database?.replace(/^datasquirel_user_\d+_/,"")||process.env.DSQL_DB_NAME?.replace(/^datasquirel_user_\d+_/,""),a=r;e?.userId&&(a+=`user_${e.userId}_`),o&&(a+=`${o}_`),a+=s;let i=r;e?.userId&&(i+=`user_${e.userId}_`),o&&(i+=`${o}_`),i+=t;let _=r;return e?.userId&&(_+=`user_${e.userId}_`),o&&(_+=`${o}_`),{keyCookieName:a,csrfCookieName:i,oneTimeCodeName:_+=n}}},67619:(e,r,s)=>{s.d(r,{A:()=>o});var t=s(29021),n=s.n(t);async function o({user:e,message:r,component:s,noMail:t,req:o}){let a=new Date,i=(()=>{if(!o)return null;try{let e=o.headers["x-forwarded-for"],r=o.headers["x-real-ip"],s=o.headers["cf-connecting-ip"],t=Array.isArray(e)?e[0]:e?.split(",")[0],n=s||t||r||o.socket.remoteAddress;if(!n)return null;return String(n)}catch(e){return null}})();try{let t=`🚀 SERVER ERROR ===========================
Error Message: ${r}
Component: ${s}`;e?.id&&e?.first_name&&e?.last_name&&e?.email&&(t+=`
User Id: ${e?.id}
User Name: ${e?.first_name} ${e?.last_name}
User Email: ${e?.email}`),o?.url&&(t+=`
URL: ${o.url}`),o?.body&&(t+=`
Request Body: ${JSON.stringify(o.body,null,4)}`),i&&(t+=`
IP: ${i}`),t+=`
Date: ${a.toDateString()}
========================================`,n().existsSync("./.tmp/error.log")||n().writeFileSync("./.tmp/error.log","","utf-8");let _=n().readFileSync("./.tmp/error.log","utf-8");n().writeFileSync("./.tmp/error.log",t),n().appendFileSync("./.tmp/error.log",`




${_}`)}catch(e){console.log("Server Error Reporting Error:",e.message)}}},68829:(e,r,s)=>{s.d(r,{A:()=>a});var t=s(55511),n=s(79428),o=s(31542);function a({data:e,encryptionKey:r,encryptionSalt:s}){if(!e?.match(/./))return console.log("Encryption string is invalid"),e;let{key:a,salt:i,keyLen:_,algorithm:c,bufferAllocSize:u}=(0,o.A)({encryptionKey:r});if(!a?.match(/.{8,}/))return console.log("Encryption key is invalid"),e;if(!i?.match(/.{8,}/))return console.log("Encryption salt is invalid"),e;let l=(0,t.scryptSync)(a,i,_),S=n.Buffer.alloc(u,0),d=(0,t.createCipheriv)(c,l,S);try{let r=d.update(e,"utf8","hex");return r+=d.final("hex")}catch(r){return console.log("Error in encrypting =>",r.message),e}}},48786:(e,r,s)=>{s.d(r,{A:()=>n});var t=s(7447);async function n(...e){let r=(0,t.A)();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()}}},7447:(e,r,s)=>{s.d(r,{A:()=>o});var t=s(9973),n=s.n(t);function o(e){return global.DSQL_USE_LOCAL||e?.local?global.DSQL_DB_CONN||n()({config:{host:process.env.DSQL_DB_HOST,user:process.env.DSQL_DB_USERNAME,password:process.env.DSQL_DB_PASSWORD,database:e?.noDb?void 0:process.env.DSQL_DB_NAME,port:process.env.DSQL_DB_PORT?Number(process.env.DSQL_DB_PORT):void 0,charset:"utf8mb4"}}):e?.ro?global.DSQL_READ_ONLY_DB_CONN||n()({config:{host:process.env.DSQL_DB_HOST,user:process.env.DSQL_DB_READ_ONLY_USERNAME,password:process.env.DSQL_DB_READ_ONLY_PASSWORD,port:process.env.DSQL_DB_PORT?Number(process.env.DSQL_DB_PORT):void 0,charset:"utf8mb4"}}):e?.fa?global.DSQL_FULL_ACCESS_DB_CONN||n()({config:{host:process.env.DSQL_DB_HOST,user:process.env.DSQL_DB_FULL_ACCESS_USERNAME,password:process.env.DSQL_DB_FULL_ACCESS_PASSWORD,port:process.env.DSQL_DB_PORT?Number(process.env.DSQL_DB_PORT):void 0,charset:"utf8mb4"}}):global.DSQL_DB_CONN||n()({config:{host:process.env.DSQL_DB_HOST,user:process.env.DSQL_DB_USERNAME,password:process.env.DSQL_DB_PASSWORD,database:e?.noDb?void 0:process.env.DSQL_DB_NAME,port:process.env.DSQL_DB_PORT?Number(process.env.DSQL_DB_PORT):void 0,charset:"utf8mb4"}})}},31542:(e,r,s)=>{s.d(r,{A:()=>n});var t=s(82535);function n(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,t.A)(process.env.DSQL_ENCRYPTION_BUFFER_ALLOCATION_SIZE):void 0)||16}}},82535:(e,r,s)=>{s.d(r,{A:()=>t});function t(e,r){try{let s=Number(e);if("number"!=typeof s||isNaN(s))return 0;if(r)return Number(s.toFixed(r));return Math.round(s)}catch(e){return console.log(`Numberfy ERROR: ${e.message}`),0}}},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=55896);module.exports=s})();