"use strict";(()=>{var e={};e.id=7867,e.ids=[7867],e.modules={47795:e=>{e.exports=require("generate-password")},76154:e=>{e.exports=require("google-auth-library")},75600:e=>{e.exports=require("next/dist/compiled/next-server/pages-api.runtime.prod.js")},21572:e=>{e.exports=require("nodemailer")},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")},33873:e=>{e.exports=require("path")},59500:(e,r,s)=>{s.r(r),s.d(r,{config:()=>c,default:()=>p,routeModule:()=>m});var a={};s.r(a),s.d(a,{default:()=>_});var t=s(89947),i=s(2706),o=s(96762),l=s(76154),u=s(68829),n=s(83704),d=s(89159);async function _(e,r){if("POST"!==e.method)return r.json({msg:"Failed!"});let s=e.body,{invite:a}=e.query,{token:t}=s;try{let e=new l.OAuth2Client(process.env.DSQL_GOOGLE_CLIENT_ID),s=(await e.verifyIdToken({idToken:t,audience:process.env.DSQL_GOOGLE_CLIENT_ID})).getPayload();if(!s||!s.email_verified){r.json({user:null,msg:"Invalid Credentials"});return}let{given_name:i,family_name:o,email:_,sub:p,picture:c,email_verified:m}=s;if(!_)throw Error("No Email");let g=await (0,n.A)({email:_,payload:{email:_,first_name:i,last_name:o,social_id:p,social_platform:"google",image:c,image_thumbnail:c,username:`google-user-${p}`},social_platform:"google",social_id:p,invitation:a});if(g.payload?.csrf_k){let e=(0,u.A)({data:JSON.stringify(g.payload)}),{keyCookieName:s,csrfCookieName:a}=(0,d.A)();r.setHeader("Set-Cookie",[`${s}=${e};samesite=strict;path=/;HttpOnly=true;Secure=true`,`${a}=${g.payload.csrf_k};samesite=strict;path=/;HttpOnly=true`])}r.json(g)}catch(e){console.log(e.message),r.json({success:!1,msg:"Failed!"})}}let p=(0,o.M)(a,"default"),c=(0,o.M)(a,"config"),m=new t.PagesAPIRouteModule({definition:{kind:i.A.PAGES_API,page:"/api/social-login/google-auth",pathname:"/api/social-login/google-auth",bundlePath:"",filename:""},userland:a})},89159:(e,r,s)=>{s.d(r,{A:()=>a});function a(e){let r=process.env.DSQL_COOKIES_PREFIX||"dsql_",s=process.env.DSQL_COOKIES_KEY_NAME||"key",a=process.env.DSQL_COOKIES_CSRF_NAME||"csrf",t=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+=s;let l=r;e?.userId&&(l+=`user_${e.userId}_`),i&&(l+=`${i}_`),l+=a;let u=r;return e?.userId&&(u+=`user_${e.userId}_`),i&&(u+=`${i}_`),{keyCookieName:o,csrfCookieName:l,oneTimeCodeName:u+=t}}}};var r=require("../../../webpack-api-runtime.js");r.C(e);var s=e=>r(r.s=e),a=r.X(0,[2319,3704],()=>s(59500));module.exports=a})();