PageSourceSearch

https://onefap.ai/assets/TelegramCallback-Bc3BLKij.js

js onefap.ai collected 2026-10-05 15:15:16 UTC 2,412 bytes, 1 lines download raw bytes

1import{aw as R,h as T,a3 as y,g as L,u as N,r as u,ac as p,aF as $,j as o}from"./index-C9eo8hQZ.js";const v="https://api.onefap.ai/api",A=n=>({"Content-Type":"application/json",Authorization:"Bearer ".concat(n)}),x="tg_link_intent",k="tg_link_error";class S extends Error{constructor(t){super(t),this.reason=t}}async function b(n,t,h){var c,s;const d=await R("".concat(v,"/auth/telegram/link"),{method:"POST",headers:A(n),body:JSON.stringify({code:t,state:h})}),e=await d.json().catch(()=>null);if(!d.ok||!(e!=null&&e.success)){const i=typeof(e==null?void 0:e.error)=="string"?e.error:"";throw new S(i==="linked_other"||i==="telegram_taken"?i:"failed")}return(s=(c=e.data)==null?void 0:c.returnTo)!=null?s:null}const F=600;function G(){const[n]=T(),t=y(),{signInWithTelegram:h,openAuth:d,token:e,refreshSubscription:c}=L(),{t:s}=N(),[i,E]=u.useState(!1),[I,_]=u.useState(!1),m=u.useRef(!1);return u.useEffect(()=>{const l=window.setTimeout(()=>_(!0),F);return()=>window.clearTimeout(l)},[]),u.useEffect(()=>{var w;if(m.current)return;m.current=!0;const l=n.get("code"),g=(w=n.get("state"))!=null?w:"";let a=null;try{a=localStorage.getItem(p(x)),a!==null&&localStorage.removeItem(p(x))}catch{}const f=$();if(!l){t(a||f||"/",{replace:!0});return}if(a!==null&&!e){try{localStorage.setItem(p(k),"failed")}catch{}t(a,{replace:!0});return}if(a!==null&&e){b(e,l,g).then(r=>{if(r){window.location.replace("".concat(r).concat(window.location.pathname).concat(window.location.search));return}c(),t(a||"/",{replace:!0})}).catch(r=>{const j=r instanceof S?r.reason:"failed";try{localStorage.setItem(p(k),j)}catch{}t(a||"/",{replace:!0})});return}h(l,g).then(r=>{if(r){window.location.replace("".concat(r).concat(window.location.pathname).concat(window.location.search));return}t(f!=null?f:"/",{replace:!0})}).catch(()=>{E(!0)})},[n,t,h,e,c]),o.jsx("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-background p-6 text-center",children:i?o.jsxs(o.Fragment,{children:[o.jsx("p",{className:"text-sm text-foreground-muted",children:s("authFailed")}),o.jsx("button",{type:"button",onClick:()=>{d(),t("/",{replace:!0})},className:"h-12 rounded-full bg-accent px-6 text-sm font-bold uppercase tracking-wide text-white hover:bg-accent-hover transition-colors",children:s("authSignIn")})]}):I&&o.jsx("p",{className:"text-sm text-foreground-muted",children:s("authSigningIn")})})}export{G 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.