"use strict";(()=>{var e={};e.id=2738,e.ids=[2738],e.modules={76154:e=>{e.exports=require("google-auth-library")},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,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}}})},96487:(e,r,t)=>{t.r(r),t.d(r,{config:()=>f,default:()=>d,routeModule:()=>p});var n={};t.r(n),t.d(n,{default:()=>c});var i=t(89947),o=t(2706),s=t(96762),a=t(76154),l=t(67619),u=t(56081);async function c(e,r){if("POST"!==e.method)return r.json({success:!1,payload:null,msg:"Failed!"});try{let t=e.headers.authorization,n=(0,u.A)({key:t,user_id:String(e.query.user_id)});if(!n?.user_id)throw Error("Api Credentials invalid!");if(!n.full_access||!n.sign)return r.json({success:!1,payload:null,msg:"Unauthorized"});let{token:i,clientId:o}=e.body,s=new a.OAuth2Client(o),l=await s.verifyIdToken({idToken:i,audience:o});if(!l?.getPayload()?.email_verified)return r.json({success:!1,payload:null,msg:"User not verified!"});let c=l.getPayload();r.json({success:!0,payload:c})}catch(t){(0,l.A)({component:"/api/user/grab-google-user-from-token/main-catch-error",message:t.message,req:e}),r.json({success:!1,payload:null,msg:"User fetch Error"})}}let d=(0,s.M)(n,"default"),f=(0,s.M)(n,"config"),p=new i.PagesAPIRouteModule({definition:{kind:o.A.PAGES_API,page:"/api/user/[user_id]/grab-google-user-from-token",pathname:"/api/user/[user_id]/grab-google-user-from-token",bundlePath:"",filename:""},userland:n})},56081:(e,r,t)=>{t.d(r,{A:()=>s});var n=t(29021),i=t.n(n),o=t(95969);let s=({key:e,database:r,table:t,user_id:n,media:s})=>{if(!e||!n)return null;try{let a=process.env.DSQL_API_KEYS_PATH;if(!a)throw Error("process.env.DSQL_API_KEYS_PATH variable not found");let l=(0,o.A)({encryptedString:e}),u=JSON.parse(l||""),c=i().existsSync(`${a}/${u.sign}`);if(String(u.user_id)!==String(n)||!c)return null;if(!u.target_database||s)return u;if(!r&&u.target_database)return null;let d=u.target_database?.split(",").includes(String(r));if(d&&!u.target_table)return u;if(d&&!t&&u.target_table)return null;if(u.target_table?.split(",").includes(String(t)))return u;return null}catch(e){return console.log(`api-cred ERROR: ${e.message}`),{error:`api-cred ERROR: ${e.message}`}}}},67619:(e,r,t)=>{t.d(r,{A:()=>o});var n=t(29021),i=t.n(n);async function o({user:e,message:r,component:t,noMail:n,req:o}){let s=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"],n=Array.isArray(e)?e[0]:e?.split(",")[0],i=t||n||r||o.socket.remoteAddress;if(!i)return null;return String(i)}catch(e){return null}})();try{let n=`🚀 SERVER ERROR ===========================
Error Message: ${r}
Component: ${t}`;e?.id&&e?.first_name&&e?.last_name&&e?.email&&(n+=`
User Id: ${e?.id}
User Name: ${e?.first_name} ${e?.last_name}
User Email: ${e?.email}`),o?.url&&(n+=`
URL: ${o.url}`),o?.body&&(n+=`
Request Body: ${JSON.stringify(o.body,null,4)}`),a&&(n+=`
IP: ${a}`),n+=`
Date: ${s.toDateString()}
========================================`,i().existsSync("./.tmp/error.log")||i().writeFileSync("./.tmp/error.log","","utf-8");let l=i().readFileSync("./.tmp/error.log","utf-8");i().writeFileSync("./.tmp/error.log",n),i().appendFileSync("./.tmp/error.log",`




${l}`)}catch(e){console.log("Server Error Reporting Error:",e.message)}}},95969:(e,r,t)=>{t.d(r,{A:()=>s});var n=t(55511),i=t(79428),o=t(31542);function s({encryptedString:e,encryptionKey:r,encryptionSalt:t}){if(!e?.match(/./))return console.log("Encrypted string is invalid"),e;let{key:s,salt:a,keyLen:l,algorithm:u,bufferAllocSize:c}=(0,o.A)({encryptionKey:r});if(!s?.match(/.{8,}/))return console.log("Decrption key is invalid"),e;if(!a?.match(/.{8,}/))return console.log("Decrption salt is invalid"),e;let d=(0,n.scryptSync)(s,a,l),f=i.Buffer.alloc(c,0),p=(0,n.createDecipheriv)(u,d,f);try{let r=p.update(e,"hex","utf8");return r+=p.final("utf8")}catch(r){return console.log("Error in decrypting =>",r.message),e}}},31542:(e,r,t)=>{t.d(r,{A:()=>i});var n=t(82535);function i(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,n.A)(process.env.DSQL_ENCRYPTION_BUFFER_ALLOCATION_SIZE):void 0)||16}}},82535:(e,r,t)=>{t.d(r,{A:()=>n});function n(e,r){try{let t=Number(e);if("number"!=typeof t||isNaN(t))return 0;if(r)return Number(t.toFixed(r));return Math.round(t)}catch(e){return console.log(`Numberfy ERROR: ${e.message}`),0}}},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=96487);module.exports=t})();