"use strict";(()=>{vare={};e.id=2998,e.ids=[2998],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(){returnfunctione(r,t){returntinr?r[t]:"then"inr&&"function"==typeofr.then?r.then(r=>e(r,t)):"function"==typeofr&&"default"===t?r:void0}}})},55896:(e,r,t)=>{t.r(r),t.d(r,{config:()=>m,default:()=>S,routeModule:()=>g});varn={};t.r(n),t.d(n,{default:()=>E});vars=t(89947),i=t(2706),o=t(96762),a=t(69842),l=t(29021),c=t.n(l),u=t(67619),_=t(48786),d=t(68829),f=t(89159);asyncfunctionp({userId:e,res:r,csrf:t}){try{letn=process.env.DSQL_USER_LOGIN_KEYS_PATH;if(!n)returnconsole.log("DSQL_USER_LOGIN_KEYS_PATH env variable not found. Please set this variable."),null;lets=await(0,_.A)("SELECT * FROM users WHERE id=?",[e]);c().unlinkSync(`${n}/${t}`);leti=Math.random().toString(36).substring(2)+"-"+Math.random().toString(36).substring(2),o={id:s[0].id,stripe_id:s[0].stripe_id||"",first_name:s[0].first_name,last_name:s[0].last_name,email:s[0].email,social_id:s[0].social_id,image:s[0].image,image_thumbnail:s[0].image_thumbnail,verification_status:s[0].verification_status,social_login:s[0].social_login,social_platform:s[0].social_platform,csrf_k:i,logged_in_status:!0,date:Date.now()},a=(0,d.A)({data:JSON.stringify(o)});c().writeFileSync(`${n}/${i}`,JSON.stringify(o));let{keyCookieName:l,csrfCookieName:u}=(0,f.A)();returnr.setHeader("Set-Cookie",[`${l}=${a};samesite=strict;path=/;HttpOnly=true;Secure=true`,`${u}=${i};samesite=strict;path=/;HttpOnly=true;Secure=true`,"user_refresh=1"]),o}catch(r){return(0,u.A)({component:"reAuthUser",message:r.message,user:{id:e}}),null}}asyncfunctionE(e,r){"POST"!==e.method&&r.json({msg:"Failed!"});lett=await(0,a.A)(e,r,!0);if(!t){console.log("No user Found"),r.redirect(307,"/logout");return}letn=awaitp({userId:t.id,res:r,csrf:t.csrf_k}),s={status:!!n,csrf:n?.csrf_k,user:n};r.json(s)}letS=(0,o.M)(n,"default"),m=(0,o.M)(n,"config"),g=news.PagesAPIRouteModule({definition:{kind:i.A.PAGES_API,page:"/api/reAuthenticateUser",pathname:"/api/reAuthenticateUser",bundlePath:"",filename:""},userland:n})},69842:(e,r,t)=>{t.d(r,{A:()=>l});varn=t(48786),s=t(95969),i=t(29021),o=t.n(i),a=t(89159);asyncfunctionl(e,r,t){try{let{keyCookieName:i,csrfCookieName:l}=(0,a.A)();if(!e.cookies?.[i]?.match(/./))throwError("Request Cookies not Found!");letc=(0,s.A)({encryptedString:e.cookies[i]});if(!c)throwError("Couldn't decrypt auth cookie!");letu=JSON.parse(c);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!");let_=process.env.DSQL_USER_LOGIN_KEYS_PATH;if(!_)throwError("DSQL_USER_LOGIN_KEYS_PATH env variable not found. Please set this variable.");if(t&&!o().existsSync(`${_}/${u.csrf_k}`))throwError("Key not found in Auth Keys Folder!");if(0==u.verification_status&&!t){lete=await(0,n.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(r){returnconsole.log(`userAuth Error for ${e.url}: ${r.message}`),null}}},89159:(e,r,t)=>{t.d(r,{A:()=>n});functionn(e){letr=process.env.DSQL_COOKIES_PREFIX||"dsql_",t=process.env.DSQL_COOKIES_KEY_NAME||"key",n=process.env.DSQL_COOKIES_CSRF_NAME||"csrf",s=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+_/,""),o=r;e?.userId&&(o+=`user_${e.userId}_`),i&&(o+=`${i}_`),o+=t;leta=r;e?.userId&&(a+=`user_${e.userId}_`),i&&(a+=`${i}_`),a+=n;letl=r;returne?.userId&&(l+=`user_${e.userId}_`),i&&(l+=`${i}_`),{keyCookieName:o,csrfCookieName:a,oneTimeCodeName:l+=s}}},67619:(e,r,t)=>{t.d(r,{A:()=>i});varn=t(