"use strict";(()=>{var e={};e.id=2998,e.ids=[2998],e.modules={39908:e=>{e.exports=require("@moduletrace/datasquirel/dist/users/user-auth")},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,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}}})},55896:(e,r,t)=>{t.r(r),t.d(r,{config:()=>m,default:()=>E,routeModule:()=>D});var s={};t.r(s),t.d(s,{default:()=>f});var n=t(89947),o=t(2706),i=t(96762),a=t(69842),c=t(29021),u=t.n(c),_=t(67619),l=t(48786),d=t(68829),p=t(89159);async function S({userId:e,res:r,csrf:t}){try{let s=process.env.DSQL_USER_LOGIN_KEYS_PATH;if(!s)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]);u().unlinkSync(`${s}/${t}`);let o=Math.random().toString(36).substring(2)+"-"+Math.random().toString(36).substring(2),i={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()},a=(0,d.A)({data:JSON.stringify(i)});u().writeFileSync(`${s}/${o}`,JSON.stringify(i));let{keyCookieName:c,csrfCookieName:_}=(0,p.A)();return r.setHeader("Set-Cookie",[`${c}=${a};samesite=strict;path=/;HttpOnly=true;Secure=true`,`${_}=${o};samesite=strict;path=/;HttpOnly=true;Secure=true`,"user_refresh=1"]),i}catch(r){return(0,_.A)({component:"reAuthUser",message:r.message,user:{id:e}}),null}}async function f(e,r){"POST"!==e.method&&r.json({msg:"Failed!"});let t=await (0,a.A)(e,r,!0);if(!t){console.log("No user Found"),r.redirect(307,"/logout");return}let s=await S({userId:t.id,res:r,csrf:t.csrf_k}),n={status:!!s,csrf:s?.csrf_k,user:s};r.json(n)}let E=(0,i.M)(s,"default"),m=(0,i.M)(s,"config"),D=new n.PagesAPIRouteModule({definition:{kind:o.A.PAGES_API,page:"/api/reAuthenticateUser",pathname:"/api/reAuthenticateUser",bundlePath:"",filename:""},userland:s})},69842:(e,r,t)=>{t.d(r,{A:()=>o});var s=t(39908),n=t.n(s);async function o(e,r,t){let s=n()({req:e,level:t?"deep":void 0});return console.log(s),s.payload}},89159:(e,r,t)=>{t.d(r,{A:()=>s});function s(e){let r=process.env.DSQL_COOKIES_PREFIX||"dsql_",t=process.env.DSQL_COOKIES_KEY_NAME||"key",s=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+_/,""),i=r;e?.userId&&(i+=`user_${e.userId}_`),o&&(i+=`${o}_`),i+=t;let a=r;e?.userId&&(a+=`user_${e.userId}_`),o&&(a+=`${o}_`),a+=s;let c=r;return e?.userId&&(c+=`user_${e.userId}_`),o&&(c+=`${o}_`),{keyCookieName:i,csrfCookieName:a,oneTimeCodeName:c+=n}}},67619:(e,r,t)=>{t.d(r,{A:()=>o});var s=t(29021),n=t.n(s);async function o({user:e,message:r,component:t,noMail:s,req:o}){let i=new Date,a=(()=>{if(!o)return null;try{let e=o.headers["x-forwarded-for"],r=o.headers["x-real-ip"],t=o.headers["cf-connecting-ip"],s=Array.isArray(e)?e[0]:e?.split(",")[0],n=t||s||r||o.socket.remoteAddress;if(!n)return null;return String(n)}catch(e){return null}})();try{let s=`🚀 SERVER ERROR =========================== Error Message: ${r} Component: ${t}`;e?.id&&e?.first_name&&e?.last_name&&e?.email&&(s+=` User Id: ${e?.id} User Name: ${e?.first_name} ${e?.last_name} User Email: ${e?.email}`),o?.url&&(s+=` URL: ${o.url}`),o?.body&&(s+=` Request Body: ${JSON.stringify(o.body,null,4)}`),a&&(s+=` IP: ${a}`),s+=` Date: ${i.toDateString()} ========================================`,n().existsSync("./.tmp/error.log")||n().writeFileSync("./.tmp/error.log","","utf-8");let c=n().readFileSync("./.tmp/error.log","utf-8");n().writeFileSync("./.tmp/error.log",s),n().appendFileSync("./.tmp/error.log",` ${c}`)}catch(e){console.log("Server Error Reporting Error:",e.message)}}},68829:(e,r,t)=>{t.d(r,{A:()=>i});var s=t(55511),n=t(79428),o=t(32443);function i({data:e,encryptionKey:r,encryptionSalt:t}){if(!e?.match(/./))return console.log("Encryption string is invalid"),e;let{key:i,salt:a,keyLen:c,algorithm:u,bufferAllocSize:_}=(0,o.A)({encryptionKey:r});if(!i?.match(/.{8,}/))return console.log("Encryption key is invalid"),e;if(!a?.match(/.{8,}/))return console.log("Encryption salt is invalid"),e;let l=(0,s.scryptSync)(i,a,c),d=n.Buffer.alloc(_,0),p=(0,s.createCipheriv)(u,l,d);try{let r=p.update(e,"utf8","hex");return r+=p.final("hex")}catch(r){return console.log("Error in encrypting =>",r.message),e}}},48786:(e,r,t)=>{t.d(r,{A:()=>n});var s=t(7447);async function n(...e){let r=(0,s.A)();try{if(!r)throw Error("No Connection provided to DB_HANDLER function!");let t=await r.query(...e);return JSON.parse(JSON.stringify(t))}catch(e){return console.log("DB Error =>",e),{success:!1,error:e.message}}finally{await r?.end()}}},7447:(e,r,t)=>{t.d(r,{A:()=>o});var s=t(9973),n=t.n(s);function o(e){return e?.ro?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"}})}},32443:(e,r,t)=>{t.d(r,{A:()=>s});function s(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?function(e,r){try{let r=Number(e);if("number"!=typeof r||isNaN(r))return 0;return Math.round(r)}catch(e){return console.log(`Numberfy ERROR: ${e.message}`),0}}(process.env.DSQL_ENCRYPTION_BUFFER_ALLOCATION_SIZE):void 0)||16}}},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=55896);module.exports=t})();