PageSourceSearch

https://apexswipe.com/assets/auth-BG9ok1Ms.js

js apexswipe.com collected 2026-10-02 01:23:36 UTC 7,184 bytes, 1 lines download raw bytes

1import{s as I,c as O,a as R,b as T,R as j,u as C,d as L,r as b,j as o,L as N}from"./index-BmK_Y2lq.js";var U={version:"1.1.2"},D="authorization_response",$="/~oauth/initiate",M=["https://oauth.lovable.app","https://lovable.dev"],W="lovable://oauth-callback",F="http://127.0.0.1/iframe-oauth/callback",B=500,V=12e4;function H(e){let n;const i=new Promise(s=>{n=s}),r=s=>{if(!e.some(d=>s.origin===d))return;const c=s.data;!c||typeof c!="object"||c.type===D&&n(c.response)},m=()=>{window.removeEventListener("message",r)};return window.addEventListener("message",r),{cleanup:m,messagePromise:i}}function K(e){const n=window.screenX!==0||window.screenY!==0||!e,i=n?window.outerWidth*.5:window.screen.width*.5,r=n?window.outerHeight*.5:window.screen.height*.5,m=n?window.screenX+(window.outerWidth-i)/2:(window.screen.width-i)/2,s=n?window.screenY+(window.outerHeight-r)/2:(window.screen.height-r)/2;return{width:i,height:r,left:m,top:s}}function k(e,n){return e.state!==n?{error:new Error("State is invalid")}:e.error?e.error==="legacy_flow"?{error:new Error("This flow is not supported in Preview mode. Please open the app in a new tab to sign in.")}:{error:new Error(e.error_description??"Sign in failed")}:!e.access_token||!e.refresh_token?{error:new Error("No tokens received")}:{tokens:{access_token:e.access_token,refresh_token:e.refresh_token},error:null}}function G(){const e=navigator.userAgent;return!!(/iPhone|iPad|iPod|Android/i.test(e)||/Macintosh/i.test(e)&&navigator.maxTouchPoints>1)}function q(){return typeof crypto<"u"&&crypto.getRandomValues?[...crypto.getRandomValues(new Uint8Array(16))].map(e=>e.toString(16).padStart(2,"0")).join(""):Math.random().toString(36).substring(2)+Date.now().toString(36)}function X(e={}){const n=e.oauthBrokerUrl??$,i=e.supportedOAuthOrigins??M;async function r(m,s={}){let l=!1;try{l=window.self!==window.top}catch{l=!0}const c=navigator.userAgent,d=/LovableApp\//.test(c),w=!d&&/lovable/i.test(c),h=q();let g=s.redirect_uri??window.location.origin;d&&l?g=W:w&&l&&(g=F);const u=new URLSearchParams({...s.extraParams,provider:m,redirect_uri:g,state:h});if(!l)return window.location.href=`${n}?${u.toString()}`,{error:null,redirected:!0};!d&&!w&&u.set("response_mode","web_message");const v=`${n}?${u.toString()}`,_=w?[...i,window.location.origin]:i,{messagePromise:y,cleanup:x}=H(_);let p;if(G())p=window.open(v,"_blank");else{const{width:t,height:E,left:f,top:A}=K(l);p=window.open(v,"oauth",`width=${t},height=${E},left=${f},top=${A}`)}if(!p&&(d||w)){let t;const E=new Promise((f,A)=>{t=setTimeout(()=>{A(new Error("OAuth timed out waiting for response"))},V)});try{const f=await Promise.race([y,E]);return k(f,h)}catch(f){return{error:f instanceof Error?f:new Error(String(f))}}finally{t&&clearTimeout(t),x()}}if(!p)return x(),{error:new Error("Popup was blocked")};let S;const a=new Promise((t,E)=>{S=setInterval(()=>{p.closed&&(clearInterval(S),E(new Error("Sign in was cancelled")))},B)});try{const t=await Promise.race([y,a]);return k(t,h)}catch(t){return{error:t instanceof Error?t:new Error(String(t))}}finally{clearInterval(S),x(),p?.close()}}return{signInWithOAuth:r}}typeof window<"u"&&(window.__lovable_cloud_auth_js_version=U.version);function Y(e={}){return X(e)}const z=Y(),J={auth:{signInWithOAuth:async(e,n)=>{const i=await z.signInWithOAuth(e,{redirect_uri:n?.redirect_uri,extraParams:{...n?.extraParams}});if(i.redirected||i.error)return i;try{await I.auth.setSession(i.tokens)}catch(r){return{error:r instanceof Error?r:new Error(String(r))}}return i}}},Q=O({type:"function"}),Z=R({method:"POST"}).middleware([Q]).handler(T("0f3ad48a89200980c92c5a92f28ac37306bf14c6ab35cabb5981403957ba9c69"));function P(e){return!!e&&e.startsWith("/")&&!e.startsWith("//")}function te(){const{next:e}=j.useSearch(),n=C(),i=L(Z),[r,m]=b.useState("signin"),[s,l]=b.useState(""),[c,d]=b.useState(""),[w,h]=b.useState(!1),[g,u]=b.useState(null),[v,_]=b.useState(null),y=P(e)?e:"/";async function x(){try{await i()}catch{}n({to:y})}async function p(a){a.preventDefault(),u(null),_(null),h(!0);try{if(r==="signin"){const{error:t}=await I.auth.signInWithPassword({email:s,password:c});if(t)throw t;await x()}else{const{error:t}=await I.auth.signUp({email:s,password:c,options:{emailRedirectTo:`${window.location.origin}/auth${P(e)?`?next=${encodeURIComponent(e)}`:""}`}});if(t)throw t;_("Check your email to confirm your account, then sign in.")}}catch(t){u(t instanceof Error?t.message:String(t))}finally{h(!1)}}async function S(){u(null),h(!0);try{const a=P(e)?`?next=${encodeURIComponent(e)}`:"",t=await J.auth.signInWithOAuth("google",{redirect_uri:`${window.location.origin}/auth${a}
1`});if(t.error)throw t.error;if(t.redirected)return;await x()}catch(a){u(a instanceof Error?a.message:String(a)),h(!1)}}return o.jsx("div",{className:"min-h-screen bg-[#050505] text-white flex items-center justify-center px-4",children:o.jsxs("div",{className:"w-full max-w-sm rounded-2xl border border-white/[0.07] bg-white/[0.02] p-8",children:[o.jsx(N,{to:"/",className:"text-xs text-white/60 hover:text-white",children:"← Back to Apex Swipe"}),o.jsx("h1",{className:"mt-4 text-xl font-semibold",children:r==="signin"?"Sign in":"Create your account"}),o.jsx("p",{className:"mt-1 text-sm text-white/70",children:r==="signin"?"Sign in to use Apex Swipe agent integrations.":"Join Apex Swipe to use agent integrations and manage your account."}),o.jsx("button",{type:"button",onClick:S,disabled:w,className:"mt-6 w-full rounded-full border border-white/15 bg-white text-black px-4 py-3 text-sm font-semibold hover:bg-white/90 disabled:opacity-60",children:"Continue with Google"}),o.jsxs("div",{className:"my-5 flex items-center gap-3 text-xs text-white/40",children:[o.jsx("div",{className:"h-px flex-1 bg-white/10"}),"or",o.jsx("div",{className:"h-px flex-1 bg-white/10"})]}),o.jsxs("form",{onSubmit:p,children:[o.jsx("input",{type:"email",required:!0,autoComplete:"email",value:s,onChange:a=>l(a.target.value),placeholder:"Email",className:"w-full rounded-xl border border-white/10 bg-white/[0.03] px-4 py-3 text-sm placeholder:text-white/50 focus:border-[#25D366]/60 focus:outline-none"}),o.jsx("input",{type:"password",required:!0,minLength:8,autoComplete:r==="signin"?"current-password":"new-password",value:c,onChange:a=>d(a.target.value),placeholder:"Password",className:"mt-3 w-full rounded-xl border border-white/10 bg-white/[0.03] px-4 py-3 text-sm placeholder:text-white/50 focus:border-[#25D366]/60 focus:outline-none"}),o.jsx("button",{type:"submit",disabled:w||!s||!c,className:"mt-4 w-full rounded-full bg-[#25D366] px-6 py-3 text-sm font-semibold text-black transition-transform hover:scale-[1.01] disabled:opacity-60 disabled:hover:scale-100",children:w?"Please wait…":r==="signin"?"Sign in":"Sign up"})]}),g&&o.jsx("p",{className:"mt-3 text-sm text-[#EF4444]",children:g}),v&&o.jsx("p",{className:"mt-3 text-sm text-[#25D366]",children:v}),o.jsx("button",{type:"button",onClick:()=>{u(null),_(null),m(r==="signin"?"signup":"signin")},className:"mt-6 w-full text-center text-xs text-white/60 hover:text-white",children:r==="signin"?"New here? Create an account":"Already have an account? Sign in"})]})})}export{te as component};

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.