1import{X as C,y as d,E as A,z as e,T as E,H as x}from"./index-CHAiQmwl.js";function v(){return A.auth.oauth??null}function z(i){return i?(window.location.href=i,!0):!1}function S(){var g,N,w;const[i]=C(),l=i.get("authorization_id")??"",[s,_]=d.useState(null),[h,n]=d.useState(null),[u,m]=d.useState(!1);d.useEffect(()=>{let a=!0;return(async()=>{if(!l){n("Missing authorization_id.");return}const o=v();if(!o){n("OAuth namespace unavailable on this Supabase client build. Update @supabase/supabase-js.");return}const{data:r}=await A.auth.getSession();if(!r.session){const k=window.location.pathname+window.location.search;window.location.href=`/signin?next=${encodeURIComponent(k)}`;return}const{data:t,error:c}=await o.getAuthorizationDetails(l);if(!a)return;if(c){n(c.message);return}const y=(t==null?void 0:t.redirect_url)??(t==null?void 0:t.redirect_to);if(y&&!(t!=null&&t.client)){z(y);return}_(t)})(),()=>{a=!1}},[l]);async function f(a){const o=v();if(!o)return;m(!0),n(null);const{data:r,error:t}=a?await o.approveAuthorization(l):await o.denyAuthorization(l);if(t){m(!1),n(t.message);return}const c=(r==null?void 0:r.redirect_url)??(r==null?void 0:r.redirect_to);z(c)||(m(!1),n("No redirect returned by the authorization server."))}if(h)return e.jsx("main",{className:"mx-auto max-w-md p-8",children:e.jsxs("div",{className:"rounded-2xl border border-border bg-card p-6 shadow",children:[e.jsx("h1",{className:"text-xl font-semibold text-foreground",children:"Could not load authorization"}),e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:h}),e.jsx("div",{className:"mt-4",children:e.jsx(E,{to:"/dashboard",children:e.jsx(x,{variant:"outline",size:"sm",children:"Back to dashboard"})})})]})});if(!s)return e.jsx("main",{className:"mx-auto max-w-md p-8",children:e.jsx("div",{className:"rounded-2xl border border-border bg-card p-6 shadow",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading authorization detailsâ¦"})})});const p=((g=s.client)==null?void 0:g.name)??((N=s.client)==null?void 0:N.client_name)??"an application",b=((w=s.client)==null?void 0:w.redirect_uri)??s.redirect_uri,j=Array.isArray(s.scopes)?s.scopes:typeof s.scope=="string"?s.scope.split(/\s+/).filter(Boolean):[];return e.jsx("main",{className:"mx-auto max-w-md p-8",children:e.jsxs("div",{className:"rounded-2xl border border-border bg-card p-6 shadow",children:[e.jsxs("h1",{className:"text-xl font-semibold text-foreground",children:["Connect ",p," to Vicky"]}),e.jsxs("p",{className:"mt-2 text-sm text-muted-foreground",children:["This lets ",p," use Vicky as you. It does not bypass your tenant, role, or row-level security permissions."]}),b&&e.jsxs("div",{className:"mt-4 text-xs text-muted-foreground",children:[e.jsx("span",{className:"font-semibold text-foreground",children:"Redirect URI: "}),e.jsx("span",{className:"break-all",children:b})]}),j.length>0&&e.jsxs("div",{className:"mt-4",children:[e.jsx("p",{className:"text-xs font-semibold text-foreground",children:"Requested access"}),e.jsx("ul",{className:"mt-1 list-disc pl-5 text-xs text-muted-foreground",children:j.map(a=>e.jsx("li",{children:a},a))})]}),e.jsxs("div",{className:"mt-6 flex gap-2",children:[e.jsx(x,{className:"flex-1",onClick:()=>f(!0),disabled:u,children:u?"Workingâ¦":"Approve"}),e.jsx(x,{variant:"outline",className:"flex-1",onClick:()=>f(!1),disabled:u,children:"Cancel"})]})]})})}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.