PageSourceSearch

https://sokapal.ai/assets/useGoogleAuth-BOl1r5uW.js

js sokapal.ai collected 2026-10-05 15:17:10 UTC 2,309 bytes, 1 lines download raw bytes

1import{r as e}from"./vendor-react-DbsVTsKS.js";import{K as r,q as t}from"./app-constants-D3ojol5R.js";import{ab as n}from"./index-Dirtnqiz.js";const o=({onSuccess:o,onError:a}={})=>{const c=e.useRef(null),l=e.useRef(null),s=e.useRef(null),u=e.useRef(null),i=e.useRef(!1),[d,g]=e.useState(!1),p=e.useCallback(()=>{l.current&&(l.current.close(),l.current=null),u.current&&(window.removeEventListener("message",u.current),u.current=null),s.current&&(clearInterval(s.current),s.current=null);try{c.current&&!c.current.closed&&c.current.close()}catch{}g(!1)},[]);return{openGoogleLogin:e.useCallback(()=>{i.current=!1,g(!0);const e=r.URL.replace(/\/token$/,"/auth"),d=t(),h=btoa(JSON.stringify({guestUserId:d,nonce:Math.random().toString(36).substring(2,10)})),w=`${window.location.origin}/auth/google-callback`,f=`${e}?${new URLSearchParams({client_id:r.USER_CLIENT_ID,redirect_uri:w,response_type:"code",scope:"openid profile email",kc_idp_hint:"google",state:h}).toString()}`,m=Math.round((window.screen.width-600)/2),R=Math.round((window.screen.height-700)/2);try{c.current&&!c.current.closed&&c.current.close()}catch{}if(c.current=window.open(f,"google-auth-popup",`popup=1,width=600,height=700,left=${m},top=${R},toolbar=0,menubar=0,location=0,status=0,scrollbars=1,resizable=1`),!c.current)return null==a||a("Popup was blocked. Please allow popups for this site and try again."),void g(!1);const b=async({type:e,code:r,state:t,error:c})=>{if(i.current)return;if(i.current=!0,p(),"GOOGLE_AUTH_ERROR"===e)return void(null==a||a(c||"Google sign-in failed. Please try again."));let l=null;if(t)try{l=JSON.parse(atob(t)).guestUserId||null}catch{}try{const e=await n.googleCallback({code:r,redirectUri:w,guestUserId:l});null==o||o(e)}catch(s){null==a||a(s.message||"Google sign-in failed. Please try again.")}};l.current&&l.current.close(),l.current=new BroadcastChannel("google-auth"),l.current.onmessage=e=>b(e.data||{});const y=e=>{if(e.origin!==window.location.origin)return;const{type:r}=e.data||{};"GOOGLE_AUTH_CODE"!==r&&"GOOGLE_AUTH_ERROR"!==r||b(e.data)};u.current=y,window.addEventListener("message",y),s.current=setInterval(()=>{var e;try{(null==(e=c.current)?void 0:e.closed)&&(clearInterval(s.current),s.current=null,i.current||(i.current=!0,p()))}catch{}},600)},[p,o,a]),loading:d}};export{o as u};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.