PageSourceSearch

https://linkerpick.xyz/assets/auth-callback-page-DVYTHBhc.js

js linkerpick.xyz collected 2026-10-02 02:11:13 UTC 4,616 bytes, 1 lines download raw bytes

1import{E as T,F as L,G as E,R as A,r,d as U,P as O,B as z,b as $,H as K,i as H}from"./index-DkHQE3Xm.js";import{n as M}from"./navigation-BDuZMul9.js";import{L as _}from"./loader-circle-qGU0d8pE.js";import{C as q}from"./circle-alert-BFY-pFKi.js";const J=["x","naver","cimi"],S="linkerpick-login-return-to",k="linkpick-participant-auth-pending",C="linkpick-participant-auth-state:",D=600*1e3,f=new Map;function Z({apiBase:t,session:i,sessionLoading:n,setSession:e}){const a=T(),{provider:s}=L(),[P]=E(),y=P.toString(),[h,b]=A.useState({status:"processing",title:"로그인 처리",message:"로그인을 완료하는 중입니다."});A.useEffect(()=>{let g=!0;const p=o=>{g&&b(o)};return(async()=>{if(p({status:"processing",title:"로그인 처리",message:"로그인을 완료하는 중입니다."}),!s||!J.includes(s)){p({status:"error",title:"로그인 오류",message:"지원하지 않는 로그인 방식입니다."});return}const o=new URLSearchParams(y),x=o.get("error"),d=o.get("state");if(x){const c=B({error:x,provider:s,state:d,description:o.get("error_description")});if(c){window.location.replace(c);return}p({status:"cancelled",title:"로그인이 취소되었습니다",message:R(x,o.get("error_description"))});return}const v=o.get("code");if(!v||!d){p({status:"error",title:"로그인 오류",message:"로그인 응답에 필요한 값이 없습니다."});return}try{const c=`${window.location.origin}/auth/callback/${s}`,N=`${t}|${s}|${d}|${v}|${c}`,l=await F(N,()=>H(t,`/auth/${s}/complete`,{method:"POST",body:JSON.stringify({code:v,state:d,redirectUri:c})}));if(!g)return;if(l.flow==="participant-auth-provider"&&l.redirectTo){I(d),window.location.replace(l.redirectTo);return}if(!l.authenticated||!l.session)throw new Error("세션을 만들지 못했습니다.");e(l.session),a(G()||"/pick",{replace:!0})}catch(c){if(!g)return;p({status:"error",title:"로그인 완료 실패",message:c instanceof Error?c.message:"로그인 완료 실패"})}})(),()=>{g=!1}},[t,a,s,y,e]);const j=h.status==="processing",u=w(P.get("state")),m=u&&u.provider===s?`/join/${encodeURIComponent(u.campaignId)}?participantId=${encodeURIComponent(u.participantId)}`:"/login";return r.jsx(U,{className:"min-h-screen bg-white text-black",children:r.jsxs("main",{className:"mx-auto flex min-h-screen w-full max-w-[74.5rem] flex-col px-5 py-6",children:[r.jsxs(O,{children:[r.jsx(z,{}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx($,{variant:"ghost",onClick:()=>a(m),children:m==="/login"?"로그인으로":"참여 페이지로"}),i?r.jsx(K,{apiBase:t,session:i,sessionLoading:n,setSession:e,logoutRedirectTo:"/login",loginClassName:"text-black hover:bg-gray-50"}):null]})]}),r.jsx("section",{className:"mx-auto grid w-full max-w-5xl flex-1 place-items-center py-14",children:r.jsxs("div",{className:"grid justify-items-center gap-4 text-center",children:[j?r.jsx(_,{className:"size-6 animate-spin text-blue-600"}):r.jsx(q,{className:"size-6 text-gray-500"}),r.jsx("h1",{className:"text-xl font-semibold",children:h.title}),r.jsx("p",{className:"max-w-sm text-sm text-gray-500",children:h.message}),!j&&r.jsx($,{variant:"outline",onClick:()=>a(m,{replace:!0}),children:m==="/login"?"로그인으로 돌아가기":"참여 이어가기"})]})})]})})}function R(t,i){const n=t.toLowerCase();return n==="access_denied"||n==="cancelled"||n==="canceled"?"외부 인증 화면에서 로그인을 취소했습니다.":i||`로그인이 취소되었습니다: ${t}`}function F(t,i){const n=f.get(t);if(n)return n;const e=i();return f.set(t,e),e.then(()=>{window.setTimeout(()=>f.delete(t),60*1e3)},()=>{f.delete(t)}),e}function G(){try{const t=sessionStorage.getItem(S);return sessionStorage.removeItem(S),M(t)}catch{return""}}function B({description:t,error:i,provider:n,state:e}){if(typeof window>"u")return"";const a=w(e||null);if(!a||a.provider!==n)return"";if(Date.now()-a.createdAt>D)return I(e),"";I(e);const s=new URLSearchParams({participantId:a.participantId,provider:a.provider,result:"error",message:R(i,t)});return`/join/${encodeURIComponent(a.campaignId)}?${s.toString()}`}function w(t){try{const i=t?`${C}${t}`:k,n=sessionStorage.getItem(i);if(!n)return null;const e=JSON.parse(n);if(typeof e.campaignId=="string"&&e.campaignId&&typeof e.participantId=="string"&&e.participantId&&typeof e.provider=="string"&&e.provider&&typeof e.createdAt=="number")return{campaignId:e.campaignId,participantId:e.participantId,provider:e.provider,createdAt:e.createdAt}}catch{}return null}function I(t){try{sessionStorage.removeItem(k),t&&sessionStorage.removeItem(`${C}${t}`)}catch{}}export{Z as AuthCallbackPage};

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.