1import{B as e,N as t,P as n,r,t as i}from"./jsx-runtime-CG8VHYdG.js";import{n as a}from"./utils-BdJMPZKX.js";import{t as o}from"./loader-circle-Bss3s-9J.js";import{t as s}from"./shield-check-B0v8tJi4.js";import{n as c}from"./AuthProvider-CzwHH36T.js";import{t as l}from"./button-CF3160Yq.js";import{t as u}from"./AuthForm-CgO0tPHH.js";import{i as d,n as f,t as p}from"./card-CzatGTnU.js";import{t as m}from"./api-B5dkZMId.js";import{t as h}from"./mcpApi-CDi4uoPw.js";var g=a(`server-cog`,[[`path`,{d:`m10.852 14.772-.383.923`,key:`11vil6`}],[`path`,{d:`M13.148 14.772a3 3 0 1 0-2.296-5.544l-.383-.923`,key:`1v3clb`}],[`path`,{d:`m13.148 9.228.383-.923`,key:`t2zzyc`}],[`path`,{d:`m13.53 15.696-.382-.924a3 3 0 1 1-2.296-5.544`,key:`1bxfiv`}],[`path`,{d:`m14.772 10.852.923-.383`,key:`k9m8cz`}],[`path`,{d:`m14.772 13.148.923.383`,key:`1xvhww`}],[`path`,{d:`M4.5 10H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-.5`,key:`tn8das`}],[`path`,{d:`M4.5 14H4a2 2 0 0 0-2 2v4a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-4a2 2 0 0 0-2-2h-.5`,key:`1g2pve`}],[`path`,{d:`M6 18h.01`,key:`uhywen`}],[`path`,{d:`M6 6h.01`,key:`1utrut`}],[`path`,{d:`m9.228 10.852-.923-.383`,key:`1wtb30`}],[`path`,{d:`m9.228 13.148-.923.383`,key:`1a830x`}]]),_=a(`shield-alert`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]),v=a(`triangle-alert`,[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),y=e(n(),1),b=i(),x=`tcp3:mcp-txn`,S=t(()=>{let{user:e,loading:t,logout:n}=c(),[i,a]=(0,y.useState)(null),[S,C]=(0,y.useState)(null),[w,T]=(0,y.useState)(null),[E,D]=(0,y.useState)(`loading`),[O,k]=(0,y.useState)(!1);(0,y.useEffect)(()=>{let e=new URLSearchParams(window.location.hash.replace(/^#/,``)),t=e.get(`error`);if(t){history.replaceState(null,``,window.location.pathname),sessionStorage.removeItem(x),T(e.get(`error_description`)||t),D(`authorize-error`);return}let n=/(?:^#|&)txn=([A-Za-z0-9_-]+)/.exec(window.location.hash)?.[1],r=n??sessionStorage.getItem(x);if(n&&(sessionStorage.setItem(x,n),history.replaceState(null,``,window.location.pathname)),!r){D(`invalid`);return}a(r),(async()=>{try{let e=await h.get(`/oauth/txn?txn=${encodeURIComponent(r)}`,{anonymous:!0});C(e),D(`ready`)}catch(e){D(e instanceof m&&e.status===404?`invalid`:`error`)}})()},[]);let A=e=>{sessionStorage.removeItem(x),window.location.assign(e)},j=async()=>{if(i){k(!0);try{let e=await h.post(`/oauth/approve`,{txn:i,decision:`approve`});A(e.redirect)}catch(e){e instanceof m&&e.status===403?D(`no-product`):e instanceof m&&e.status===400?D(`invali
1d`):D(`error`),k(!1)}}},M=async()=>{if(i){k(!0);try{let e=await h.post(`/oauth/approve`,{txn:i,decision:`deny`},{anonymous:!0});A(e.redirect)}catch{D(`invalid`),k(!1)}}},N=S?.client_name||`An MCP client`,P=S?.redirect_hosts??[],F=!!e?.products.includes(`mcps`),I=S?.client_kind===`cimd`&&!!S.client_id_host,L=S?.redirect_host??P[0],R=I&&S?.redirect_host_matches_client_id===!1;return(0,b.jsx)(`div`,{className:`flex min-h-screen items-center justify-center bg-background px-6`,children:(0,b.jsxs)(`div`,{className:`w-full max-w-md space-y-4`,children:[(0,b.jsx)(`div`,{className:`text-center`,children:(0,b.jsx)(r,{to:`/`,className:`text-xl font-bold tracking-tight`,children:`TCP3`})}),(0,b.jsx)(p,{children:(E===`loading`||t)&&E!==`invalid`&&E!==`error`?(0,b.jsxs)(f,{className:`flex items-center justify-center gap-2 p-10 text-sm text-muted-foreground`,children:[(0,b.jsx)(o,{className:`size-4 animate-spin`}),` Loadingâ¦`]}):E===`invalid`?(0,b.jsxs)(f,{className:`space-y-3 p-8 text-center`,children:[(0,b.jsx)(`p`,{className:`text-sm font-medium`,children:`This sign-in request has expired.`}),(0,b.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Go back to your MCP client (e.g. Claude) and start the connection again.`})]}):E===`authorize-error`?(0,b.jsxs)(f,{className:`space-y-3 p-8 text-center`,children:[(0,b.jsx)(`p`,{className:`text-sm font-medium`,children:`This app couldn't be verified.`}),(0,b.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:w}),(0,b.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Nothing was shared. Go back to your MCP client and try again â if it keeps failing, the problem is on the app's side, not your account.`})]}):E===`error`?(0,b.jsx)(f,{className:`space-y-3 p-8 text-center`,children:(0,b.jsx)(`p`,{className:`text-sm text-destructive`,children:`Something went wrong. Please try again.`})}):E===`no-product`?(0,b.jsxs)(f,{className:`space-y-3 p-8 text-center`,children:[(0,b.jsx)(`p`,{className:`text-sm font-medium`,children:`Your account doesn't include MCP Servers.`}),(0,b.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`The MCP Servers product isn't enabled for `,e?.email,`. Contact us to get access, then restart the connection from your MCP client.`]}),(0,b.jsxs)(l,{variant:`outline`,size:`sm`,onClick:M,disabled:O,children:[`Return to `,N]})]}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(d,{className:`space-y-2 text-center`,children:[(0,b.jsx)(`div`,{className:`mx-auto flex size-10 items-center justify-center rounded-full bg-primary/10`,children:(0,b.jsx)(g,{className:`size-5 text-primary`})}),(0,b.jsxs)(`p`,{className:`text-base font-semibold`,children:[(0,b.jsx)(`span`,{dir:`ltr`,className:`[unicode-bidi:isolate]`,children:N}),` `,`wants to access your TCP3 MCP servers`]}),I?(0,b.jsxs)(`p`,{className:`flex items-center justify-center gap-1.5 text-xs text-muted-foreground`,children:[(0,b.jsx)(s,{className:`size-3.5 text-primary`}),`Identity published at`,` `,(0,b.jsx)(`span`,{dir:`ltr`,className:`font-medium [unicode-bidi:isolate]`,children:S?.client_id_host})]}):(0,b.jsxs)(`p`,{className:`flex items-center justify-center gap-1.5 text-xs text-muted-foreground`,children:[(0,b.jsx)(_,{className:`size-3.5`}),`This app's name is self-reported and hasn't been verified.`]})]}),(0,b.jsxs)(f,{className:`space-y-4`,children:[(0,b.jsxs)(`div`,{className:`flex items-start gap-2 rounded-md border p-3 text-sm text-muted-foreground`,children:[(0,b.jsx)(s,{className:`mt-0.5 size-4 shrink-0`}),`It will be able to call the tools of MCP server instances you've configured, using the credentials you connected. It can't change your configuration.`]}),L&&(0,b.jsxs)(`div`,{className:`rounded-md border p-3 text-sm`,children:[`After you approve, you'll be sent to`,` `,(0,b.jsx)(`span`,{dir:`ltr`,className:`font-medium [unicode-bidi:isolate]`,children:L})]}),S?.redirect_is_loopback&&(0,b.jsxs)(`div`,{className:`flex items-start gap-2 rounded-md border border-amber-500/40 bg-amber-500/10 p-3 text-sm`,children:[(0,b.jsx)(v,{className:`mt-0.5 size-4 shrink-0 text-amber-600`}),(0,b.jsx)(`span`,{children:`This app runs on your own computer. Only approve if you just started this connection from an app on this device.`})]}),R&&(0,b.jsxs)(`div`,{className:`flex items-start gap-2 rounded-md border p-3 text-sm text-muted-foreground`,children:[(0,b.jsx)(v,{className:`mt-0.5 size-4 shrink-0`}),(0,b.jsxs)(`span`,{children:[`This app publishes its identity at`,` `,(0,b.jsx)(`span`,{dir:`ltr`,className:`font-medium [unicode
1-bidi:isolate]`,children:S?.client_id_host}),` `,`but will send you to a different domain.`]})]}),e?(0,b.jsxs)(`div`,{className:`space-y-3`,children:[(0,b.jsxs)(`div`,{className:`rounded-md border p-3 text-sm`,children:[`Continue as `,(0,b.jsx)(`span`,{className:`font-medium`,children:e.email}),` `,(0,b.jsx)(`button`,{type:`button`,className:`ml-1 text-xs text-muted-foreground underline hover:text-foreground`,onClick:()=>n(),children:`Not you?`})]}),(0,b.jsxs)(`div`,{className:`flex gap-2`,children:[(0,b.jsxs)(l,{className:`flex-1`,onClick:j,disabled:O||!F,children:[O&&(0,b.jsx)(o,{className:`size-4 animate-spin`}),` Approve`]}),(0,b.jsx)(l,{variant:`outline`,className:`flex-1`,onClick:M,disabled:O,children:`Deny`})]}),!F&&(0,b.jsx)(`p`,{className:`text-center text-xs text-muted-foreground`,children:`This account doesn't have the MCP Servers product enabled.`})]}):(0,b.jsxs)(`div`,{className:`space-y-3`,children:[(0,b.jsx)(u,{returnTo:`/mcp-auth`,onAuthenticated:()=>{}}),(0,b.jsx)(`div`,{className:`text-center`,children:(0,b.jsxs)(`button`,{type:`button`,className:`text-xs text-muted-foreground underline hover:text-foreground`,onClick:M,disabled:O,children:[`Cancel and return to `,N]})})]})]})]})}),(0,b.jsx)(`p`,{className:`text-center text-xs text-muted-foreground`,children:`Only approve if you started this connection from an app you trust.`})]})})});export{S 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.