PageSourceSearch

https://getnearfield.com/assets/Auth-g3De2gHw.js

js getnearfield.com collected 2026-10-09 05:20:50 UTC 11,063 bytes, 2 lines download raw bytes

1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-Buc0ZiI0.js","assets/index-BAXqC3uG.js","assets/index-B_GGyk_p.css","assets/index-DzAmrokj.js"])))=>i.map(i=>d[i]);
2import{r as a,j as e,_ as te}from"./index-BAXqC3uG.js";import{e as _,f as se,g as ie,d as ae,h as ne,i as re,j as oe,k as le,L as D,n as ce,l as H,I as O,B as de,t as y,s as l,m as ue,o as q,p as me}from"./App-DZ8XJ0eL.js";import{Capacitor as U}from"./index-DzAmrokj.js";import{A as he}from"./arrow-left-Dg43ghNy.js";import{I as Y}from"./info-S7BdhpU_.js";const ge=se("relative w-full rounded-lg border p-4 [&>svg~*]:pl-7 [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground",{variants:{variant:{default:"bg-background text-foreground",destructive:"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive"}},defaultVariants:{variant:"default"}}),j=a.forwardRef(({className:i,variant:r,...o},k)=>e.jsx("div",{ref:k,role:"alert",className:_(ge({variant:r}),i),...o}));j.displayName="Alert";const b=a.forwardRef(({className:i,...r},o)=>e.jsx("h5",{ref:o,className:_("mb-1 font-medium leading-none tracking-tight",i),...r}));b.displayName="AlertTitle";const N=a.forwardRef(({className:i,...r},o)=>e.jsx("div",{ref:o,className:_("text-sm [&_p]:leading-relaxed",i),...r}));N.displayName="AlertDescription";const ye=()=>{var V;ie("Log in");const[i,r]=a.useState("login"),[o,k]=a.useState(""),[W,J]=a.useState(""),[g,R]=a.useState(!1),[p,S]=a.useState(!1),[A,T]=a.useState(!1),B=U.isNativePlatform(),[h,F]=a.useState(null),[G,u]=a.useState(null),[$,C]=a.useState(null),K=ae(),E=ne(),{toast:c}=re(),{session:z,isAnonymous:L}=oe();a.useEffect(()=>{L&&le(z)},[L,z]);const M=async t=>{const{data:s}=await l.auth.getSession();await me(s.session),K(t,{replace:!0})},m=(V=E.state)==null?void 0:V.from,f=m==null?void 0:m.pathname,x=f&&!f.startsWith("/login")&&!f.startsWith("/auth")?`${f}${(m==null?void 0:m.search)??""}`:"/field";a.useEffect(()=>{const t=P=>new URLSearchParams(P.startsWith("#")?P.slice(1):P),s=t(E.search||""),n=t(window.location.hash||""),v=s.get("error")||n.get("error"),I=s.get("error_description")||n.get("error_description")||"";if(!v)return;const w=decodeURIComponent(I.replace(/\+/g," ")),d=w.toLowerCase();d.includes("not verified")||d.includes("email not confirmed")||d.includes("unverified")||d.includes("verify your email")?u("Your Google account email isn't verified yet. Verify it with Google, then try signing in again."):d.includes("identity already exists")||d.includes("user already registered")||d.includes("email address is already in use")?C("An account with this email already exists. Sign in below with your password, then link Google from your account settings."):u(w||"Sign-in was cancelled or failed. Please try again."),window.history.replaceState({},document.title,window.location.pathname)},[E.search]);const Q=async()=>{S(!0),u(null),C(null);try{if(y("login_attempt",{method:"google"}),B){const{data:n,error:v}=await l.auth.signInWithOAuth({provider:"google",options:{skipBrowserRedirect:!0,redirectTo:"com.getnearfield.app://login-callback",queryParams:{prompt:"select_account"}}});if(v)throw v;if(n!=null&&n.url){const{Browser:I}=await te(async()=>{const{Browser:w}=await import("./index-Buc0ZiI0.js");return{Browser:w}},__vite__mapDeps([0,1,2,3]));await I.open({url:n.url})}S(!1);return}const t=`${window.location.origin}${x}`,{error:s}=await l.auth.signInWithOAuth({provider:"google",options:{redirectTo:t,queryParams:{prompt:"select_account"}}});if(s)throw s}catch(t){const s=(t==null?void 0:t.message)??"Could not start Google sign-in.";u(s),c({title:"Google sign-in failed",description:s,variant:"destructive"}),S(!1)}},X=async()=>{T(!0),u(null),C(null);try{y("login_attempt",{method:"apple"});const{idToken:t,rawNonce:s}=await ue(),{error:n}=await l.auth.signInWithIdToken({provider:"apple",token:t,nonce:s});if(n)throw n;y("login",{method:"apple"}),await M(x)}catch(t){const s=(t==null?void 0:t.message)??"Apple sign-in failed.";
2/cancel|1001|popup_closed/i.test(s)||(u(s),c({title:"Apple sign-in failed",description:s,variant:"destructive"}))}finally{T(!1)}},Z=async()=>{if(h)try{const{error:t}=await l.auth.resend({type:"signup",email:h});if(t)throw t;c({title:"Verification email sent",description:`We sent a new verification link to ${h}.`})}catch(t){c({title:"Couldn't resend",description:(t==null?void 0:t.message)??"Please try again in a moment.",variant:"destructive"})}},ee=async t=>{t.preventDefault(),R(!0),F(null);try{if(i==="link"){const{error:s}=await l.auth.signInWithOtp({email:o,options:{shouldCreateUser:!1,emailRedirectTo:`${q()}${x}`}});if(s)throw s;c({title:"Check your email",description:"We sent you a link to sign in. It works once."}),r("login")}else if(i==="forgot"){const{error:s}=await l.auth.resetPasswordForEmail(o,{redirectTo:`${q()}/reset-password`});if(s)throw s;c({title:"Check your email",description:"We sent you a link to reset your password."}),r("login")}else{const{error:s}=await l.auth.signInWithPassword({email:o,password:W});if(s){const n=(s.message||"").toLowerCase();throw(n.includes("not confirmed")||n.includes("not verified"))&&F(o),s}y("login",{method:"password"}),await M(x)}}catch(s){c({title:"Error",description:s.message,variant:"destructive"})}finally{R(!1)}};return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background px-4",children:e.jsxs("div",{className:"w-full max-w-sm",children:[!U.isNativePlatform()&&e.jsx("div",{className:"mb-2",children:e.jsxs(D,{to:"/",className:"inline-flex items-center gap-1 text-sm text-muted-foreground hover:text-foreground transition-colors",children:[e.jsx(he,{className:"h-3.5 w-3.5"}),"Back to home"]})}),e.jsxs("div",{className:"mt-8 mb-10 text-center",children:[e.jsx("img",{src:ce,alt:"NearField",className:"h-8 mx-auto mb-4"}),e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:i==="forgot"?"Enter your email to reset your password":i==="link"?"We'll email you a link that signs you in":"Sign in to your account"}),L&&i==="login"&&e.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:"Log in and we'll bring the draft you're building with you."})]}),e.jsxs("div",{className:"rounded-lg border border-border bg-card p-6",children:[G&&e.jsxs(j,{variant:"destructive",className:"mb-4",children:[e.jsx(b,{children:"Sign-in problem"}),e.jsx(N,{children:G})]}),$&&e.jsxs(j,{className:"mb-4",children:[e.jsx(Y,{className:"h-4 w-4"}),e.jsx(b,{children:"Account already exists"}),e.jsx(N,{children:$})]}),h&&e.jsxs(j,{className:"mb-4",children:[e.jsx(Y,{className:"h-4 w-4"}),e.jsx(b,{children:"Email not verified"}),e.jsxs(N,{className:"space-y-2",children:[e.jsxs("p",{children:["We sent a verification link to ",e.jsx("strong",{children:h}),". Check your inbox (and spam folder) and click the link before signing in."]}),e.jsx("button",{type:"button",onClick:Z,className:"font-medium text-primary hover:text-moss underline-offset-4 hover:underline",children:"Resend verification email"})]})]}),i==="login"&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",onClick:Q,disabled:p||A||g,className:"w-full inline-flex items-center justify-center gap-2 h-10 rounded-sm border border-border bg-background hover:bg-muted text-sm font-medium text-foreground transition-colors disabled:opacity-50",children:[e.jsxs("svg",{className:"h-4 w-4",viewBox:"0 0 24 24","aria-hidden":"true",children:[e.jsx("path",{fill:"#4285F4",d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z"}),e.jsx("path",{fill:"#34A853",d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z"}),e.jsx("path",{fill:"#FBBC05",d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z"}),e.jsx("path",{fill:"#EA4335",d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z"})]}),p?"Redirecting to Google…":"Continue with Google"]}),B&&e.jsxs("button",{type:"button",onClick:X,disabled:A||p||g,className:"mt-3 w-full inline-flex items-center justify-center gap-2 h-10 rounded-sm bg-charcoal text-oatmeal hover:bg-charcoal/90 text-sm font-medium transition-colors disabled:opacity-50",children:[e.jsx("svg",{className:"h-4 w-4",viewBox:"0 0 384 512",fill:"
2currentColor","aria-hidden":"true",children:e.jsx("path",{d:"M318.7 268.7c-.2-36.7 16.4-64.4 50-84.8-18.8-26.9-47.2-41.7-84.7-44.6-35.5-2.8-74.3 20.7-88.5 20.7-15 0-49.4-19.7-76.4-19.7C63.3 141.2 4 184.8 4 273.5q0 39.3 14.4 81.2c12.8 36.7 59 126.7 107.2 125.2 25.2-.6 43-17.9 75.8-17.9 31.8 0 48.3 17.9 76.4 17.9 48.6-.7 90.4-82.5 102.6-119.3-65.2-30.7-61.7-90-61.7-91.9zM256.8 75.1c30.5-36.2 27.7-69.2 26.8-81.1-26.9 1.6-58 18.4-75.7 39.1-19.5 22.2-31 49.7-28.5 79.3 29.1 2.2 55.6-12.8 77.4-37.3z"})}),A?"Signing in…":"Continue with Apple"]}),e.jsxs("div",{className:"relative my-4",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("div",{className:"w-full border-t border-border"})}),e.jsx("div",{className:"relative flex justify-center text-xs",children:e.jsx("span",{className:"bg-card px-2 text-muted-foreground",children:"or"})})]})]}),e.jsxs("form",{onSubmit:ee,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(H,{htmlFor:"email",children:"Email"}),e.jsx(O,{id:"email",type:"email",placeholder:"[email protected]",value:o,onChange:t=>k(t.target.value),required:!0})]}),i==="login"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(H,{htmlFor:"password",children:"Password"}),e.jsx(O,{id:"password",type:"password",placeholder:"••••••••",value:W,onChange:t=>J(t.target.value),required:!0,minLength:6}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-x-4 gap-y-1",children:[e.jsx("button",{type:"button",onClick:()=>r("forgot"),className:"text-xs text-muted-foreground hover:text-primary transition-colors",children:"Forgot password?"}),e.jsx("button",{type:"button",onClick:()=>r("link"),className:"text-xs text-muted-foreground hover:text-primary transition-colors",children:"No password? Email me a sign-in link"})]})]}),e.jsx(de,{type:"submit",className:"w-full",disabled:g||p,children:g?"Please wait…":i==="forgot"?"Send reset link":i==="link"?"Email me a link":"Sign in"})]})]}),e.jsx("p",{className:"mt-6 text-center text-sm text-muted-foreground",children:i!=="login"?e.jsxs(e.Fragment,{children:[i==="forgot"?"Remember your password?":"Have a password?"," ",e.jsx("button",{type:"button",onClick:()=>r("login"),className:"font-medium text-primary hover:text-moss underline-offset-4 hover:underline",children:"Sign in"})]}):e.jsxs(e.Fragment,{children:["Don't have an account?"," ",e.jsx(D,{to:"/signup",className:"font-medium text-primary hover:text-moss underline-offset-4 hover:underline",children:"Sign up"})]})})]})})};export{ye as default};

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.