PageSourceSearch

https://mysendbit.com/assets/DeviceVerification-D4rL2MK_.js

js mysendbit.com collected 2026-10-02 00:53:18 UTC 5,284 bytes, 1 lines download raw bytes

1import{r as n,h as I,u as L,j as t,L as P}from"./vendor-react-Dw7X3JZT.js";import{ac as $,ad as F}from"./vendor-CZR7Gm73.js";import{o as B}from"./auth-BKUOP0E3.js";import{u as Y,a as H,f as K,g as W,h as _,i as q,j as M,l as z}from"./index-BEZ7mpN6.js";import{an as G}from"./vendor-ui-ODtAki8E.js";import"./vendor-utils-WadUx6vN.js";import"./vendor-framer-motion-CpxrKHsN.js";const w=60,re=()=>{const[u,i]=n.useState(["","","",""]),[c,h]=n.useState(w),[d,b]=n.useState(!1),[m,y]=n.useState(!1),p=I(),N=L(),{resendOtp:D,setAuthenticated:E}=Y(),{addToast:f}=H(),r=n.useRef([]),o=N.state?.email||localStorage.getItem("pendingVerificationEmail")||"",{handleSubmit:C,formState:{errors:x},setValue:l,trigger:v,clearErrors:S,setError:j}=$({resolver:F(B)});n.useEffect(()=>{if(!o){const s=setTimeout(()=>p("/auth/login"),100);return()=>clearTimeout(s)}},[o,p]),n.useEffect(()=>{if(c<=0)return;const s=setTimeout(()=>h(e=>e-1),1e3);return()=>clearTimeout(s)},[c]);const R=(s,e)=>{if(e.length>1||!/^[0-9]*$/.test(e))return;const a=[...u];a[s]=e,i(a);const g=a.join("");l("otp",g),e&&S("otp"),v("otp"),e&&s<3&&r.current[s+1]?.focus(),g.length===4&&/^[0-9]{4}$/.test(g)&&setTimeout(()=>{document.querySelector("form")?.dispatchEvent(new Event("submit",{cancelable:!0,bubbles:!0}))},80)},V=(s,e)=>{e.key==="Backspace"&&!u[s]&&s>0&&r.current[s-1]?.focus()},A=s=>{s.preventDefault();const e=s.clipboardData.getData("text").trim();if(/^[0-9]{4}$/.test(e)){const a=e.split("");i(a),l("otp",e),v("otp"),r.current[3]?.focus()}},k=async()=>{if(!(c>0||d)){b(!0);try{i(["","","",""]),l("otp",""),S("otp"),await D(o,"default"),h(w),r.current[0]?.focus(),f({title:"Code sent",description:"A new verification code has been sent to your email.",variant:"success"})}catch{f({title:"Resend failed",description:"Could not resend the code. Please try again.",variant:"destructive"})}finally{b(!1)}}},T=C(async s=>{y(!0);try{K.isAuthenticated()||(W(),await _());const e=await q.verifyNewDevice({email:o,otp:s.otp});e.success?(M(e.data),E(!0),localStorage.removeItem("pendingVerificationEmail"),f({title:"Device verified!",description:"Your device has been verified successfully.",variant:"success"}),p("/dashboard/home",{replace:!0})):(j("otp",{type:"manual",message:e.message||"Invalid code. Please try again."}),i(["","","",""]),l("otp",""),r.current[0]?.focus())}catch{j("otp",{type:"manual",message:"Verification failed. Please try again."}),i(["","","",""]),l("otp",""),r.current[0]?.focus()}finally{y(!1)}}),O=u.join("").length===4&&!m;return o?t.jsxs("div",{className:"min-h-screen bg-white flex flex-col px-6 py-10 sm:px-10",children:[t.jsx(P,{to:"/",className:"mb-10 inline-block",children:t.jsx("img",{src:z,alt:"SendBit",className:"h-10 w-auto"})}),t.jsxs("div",{className:"flex-1 flex flex-col justify-center max-w-sm w-full mx-auto",children:[t.jsx("div",{className:"w-16 h-16 rounded-2xl bg-purple-50 flex items-center justify-center mb-6",children:t.jsx(G,{className:"w-8 h-8 text-purple-700"})}),t.jsx("h1",{className:"text-3xl font-bold text-gray-900 mb-1",children:"Verify Your Device"}),t.jsx("p",{className:"text-gray-500 text-sm mb-2",children:"A new device was detected. We sent a 4-digit code to your email to confirm it's you."}),o&&t.jsx("p",{className:"text-gray-400 text-xs mb-8 font-mono",children:o}),t.jsxs("form",{onSubmit:T,className:"space-y-6",children:[t.jsx("div",{className:"flex justify-center gap-3",children:u.map((s,e)=>t.jsx("input",{ref:a=>{r.current[e]=a},type:"text",inputMode:"numeric",pattern:"[0-9]*",maxLength:1,value:s,onChange:a=>R(e,a.target.value),onKeyDown:a=>V(e,a),onPaste:A,autoComplete:e===0?"one-time-code":"off","aria-label":`Code digit ${e+1}`,className:`w-14 h-14 sm:w-16 sm:h-16 text-center text-2xl font-bold border-2 rounded-xl transition-all focus:outline-none focus:ring-2 shrink-0 ${x.otp?"border-red-400 focus:ring-red-100 bg-red-50":s?"border-purple-600 focus:ring-purple-100 bg-purple-50":"border-gray-200 focus:ring-purple-100 focus:border-purple-600 bg-gray-50"}`},e))}),x.otp&&t.jsx("p",{className:"text-sm text-red-500 text-center",children:x.otp.message}),t.jsxs("p",{className:"text-center text-sm text-gray-500",children:["Didn't receive the code?"," ",c>0?t.jsxs("span",{className:"text-gray-400",children:["Resend in ",c,"s"]}):t.jsx("button",{type:"button",onClick:k,disabled:d,className:"font-semibold text-purple-700 hover:text-purple-800 transition-colors disabled:opacity-60",children:d?"Sending…":"Resend"})]}),t.jsxs("button",{type:"submit",disabled:!O,className:"w-full py-4 rounded-full bg-purple-700 hover:bg-purple-800 text-white font-semibold text-sm transition-colors disabled:opacity-60 disabled:cursor-not-allowed flex items-center justify-center gap-2",children:[m&&t.jsx("span",{className:"w-4 h-4 border-2 border-white/30 border-t-white rounded-full animate-spin"}),m?"Verifying…":"Verify Device"]})]}),t.jsxs("p",{className:"mt-8 text-xs text-gray-400 text-center leading-relaxed",children:["Having trouble?"," ",t.jsx("a",{href:"mailto:[email protected]",className:"text-purple-700 hover:underline",children:"Contact support"})]})]}),t.jsxs("p",{className:"mt-10 text-xs text-gray-400 text-center",children:["© ",new Date().getFullYear()," SendBit. All rights reserved."]})]}):null};export{re 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.