UNPKG

decocms

Version:

Deco CMS — Self-hostable MCP Gateway for managing AI connections and tools

2 lines (1 loc) • 3.15 kB
import{c as p,b as g,K as j,e as w,j as t,B as h,i as y}from"./index-ztdGKvBm.js";import{A as N}from"./auth-split-layout-DSQvTHWS.js";import{A as _}from"./auth-entry-CvZftMoq.js";import"./Fingerprint04-B2fDIuT8.js";import"./backoff-CrEUbyZT.js";import"./delay-CnY5UFtP.js";const f="/api/auth/custom/mcp-consent";function C(){const e=new URLSearchParams(window.location.search);return e.delete("prompt"),e}async function S(e){const n=new URLSearchParams({client_id:e.get("client_id")??"",redirect_uri:e.get("redirect_uri")??"",scope:e.get("scope")??""}),s=await fetch(`${f}?${n}`,{credentials:"include"});if(!s.ok)throw new Error(`consent request failed (${s.status})`);return await s.json()}function k(){const e=p.c(11),n=g();let s,i,c;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=C(),i=y,c={queryKey:j.mcpOAuthConsent(s.toString()),queryFn:()=>S(s),retry:!1},e[0]=s,e[1]=i,e[2]=c):(s=e[0],i=e[1],c=e[2]);const o=i(c);let l;e[3]===Symbol.for("react.memo_cache_sentinel")?(l={mutationFn:async()=>{const a=await fetch(f,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_id:s.get("client_id"),scope:s.get("scope")??void 0})});if(!a.ok)throw new Error(`consent failed (${a.status})`)},onSuccess:()=>{window.location.href=`/api/auth/mcp/authorize?${s}`}},e[3]=l):l=e[3];const r=w(l);let d;e[4]===Symbol.for("react.memo_cache_sentinel")?(d=()=>{const a=new URL(s.get("redirect_uri")??"/");a.searchParams.set("error","access_denied");const m=s.get("state");m&&a.searchParams.set("state",m),window.location.href=a.toString()},e[4]=d):d=e[4];const x=d;if(o.isPending){let a;return e[5]===Symbol.for("react.memo_cache_sentinel")?(a=t.jsx(_,{}),e[5]=a):a=e[5],a}let u;return e[6]!==r||e[7]!==o.data||e[8]!==o.isError||e[9]!==n?(u=t.jsx(N,{children:t.jsx("div",{className:"flex w-full max-w-sm flex-col gap-5",children:o.isError||r.isError||!o.data?t.jsx("p",{className:"text-sm text-muted-foreground",children:n("routes.oauthConsent.unavailable")}):t.jsxs(t.Fragment,{children:[t.jsx("h1",{className:"text-xl font-semibold",children:n("routes.oauthConsent.title")}),t.jsx("p",{className:"text-sm text-muted-foreground",children:n("routes.oauthConsent.description",{client:o.data.clientName||n("routes.oauthConsent.unknownClient")})}),t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:n("routes.oauthConsent.redirectLabel")}),t.jsx("code",{className:"break-all text-sm font-medium",children:o.data.redirectTarget})]}),t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:n("routes.oauthConsent.scopesLabel")}),t.jsx("span",{className:"text-sm",children:o.data.scopes.join(", ")})]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(h,{variant:"outline",className:"flex-1",onClick:x,disabled:r.isPending,children:n("routes.oauthConsent.deny")}),t.jsx(h,{className:"flex-1",onClick:()=>r.mutate(),disabled:r.isPending,children:n("routes.oauthConsent.allow")})]})]})})}),e[6]=r,e[7]=o.data,e[8]=o.isError,e[9]=n,e[10]=u):u=e[10],u}export{k as default};