Skip to content

The only tool you need to know what is happening and how to fix it.

7.2 KB
Raw Blame
import"../chunks/DsnmJJEf.js";import{p as xe,y as Pe,e as l,d as t,a as Ce,f,t as x,m as i,c as M,h as g,l as a,j as ae,g as e,u as J,r as _,n as u,o as ke,q as oe}from"../chunks/BKFspo1J.js";import{i as U}from"../chunks/COK9M2N0.js";import{p as h}from"../chunks/F6fhTWnB.js";import{g as be}from"../chunks/BHvJp7nu.js";import{B as se}from"../chunks/DY5VVhnr.js";import{C as Te}from"../chunks/BgROpcEU.js";import{C as je}from"../chunks/yLTYAAhJ.js";import{C as Ue}from"../chunks/CukMfG7H.js";import{C as Ae,a as Ie}from"../chunks/BYaKcgwR.js";import{A as de,a as ue,b as ve,E as qe}from"../chunks/CGiec90h.js";import{W as ze}from"../chunks/DxDqniE2.js";import{a as E}from"../chunks/h7yRWCtK.js";import{t as Re}from"../chunks/CcBokjUl.js";import{S as Se}from"../chunks/DvHqpm_z.js";import{C as pe}from"../chunks/C78GZlAk.js";var Le=l('<img src="/traceway-logo-white.svg" alt="Traceway Logo" class="h-8 w-auto"/>'),We=l('<img src="/traceway-logo.png" alt="Traceway Logo" class="h-8 w-auto"/>'),Be=l('<div class="flex flex-row items-center justify-center gap-2"><!></div>'),Me=l("<!> <!>",1),Ee=l('<div class="flex items-center justify-center py-8"><div class="h-8 w-8 animate-spin rounded-full border-b-2 border-primary"></div></div>'),Ne=l(`<div class="space-y-4"><p class="text-center text-muted-foreground">Log in to review an application's access request.</p> <!></div>`),De=l("<!> Approve",1),He=l('<div class="space-y-4"><p class="text-center text-muted-foreground"><strong> </strong> is requesting access to your Traceway account.</p> <!> <p class="text-center text-sm text-muted-foreground"> <strong> </strong>.</p> <div class="flex gap-2"><!> <!></div></div>'),Oe=l("<!> <!> <!>",1),Je=l("<!> <!> <!>",1),Fe=l("<!> <!>",1),Ge=l('<div class="flex min-h-screen w-full items-center justify-center px-4 py-8"><!></div>');function dt(fe,he){xe(he,!0);let o=ae("loading"),P=ae(""),ne=ae("");const r=J(()=>({responseType:h.url.searchParams.get("response_type"),clientId:h.url.searchParams.get("client_id"),redirectUri:h.url.searchParams.get("redirect_uri"),state:h.url.searchParams.get("state")??"",codeChallenge:h.url.searchParams.get("code_challenge"),codeChallengeMethod:h.url.searchParams.get("code_challenge_method"),resource:h.url.searchParams.get("resource")??"",scope:h.url.searchParams.get("scope")??""})),ie=J(()=>e(r).scope.split(/\s+/).includes("traceway:write")),me=J(()=>{try{return new URL(e(r).redirectUri??"").host||e(r).redirectUri}catch{return e(r).redirectUri}});function F(){const c=h.url.pathname+h.url.search;be(`/login?returnTo=${encodeURIComponent(c)}`)}async function ge(){a(o,"loading"),a(P,"");try{const c=await fetch(`/api/oauth/client?client_id=${encodeURIComponent(e(r).clientId??"")}`,{headers:{Authorization:`Bearer ${E.token}`}});if(c.status===401){E.logout(),F();return}if(c.status===404){a(o,"unknownClient");return}if(!c.ok){a(o,"error"),a(P,"We could not look up the requesting application.");return}const N=await c.json();a(ne,N.clientName||"An application",!0),a(o,"confirm")}catch{a(o,"error"),a(P,"We could not reach the server. Please try again.")}}async function le(c){a(o,"loading"),a(P,"");try{const N=c?{client_id:e(r).clientId,redirect_uri:e(r).redirectUri,state:e(r).state,code_challenge:e(r).codeChallenge,code_challenge_method:e(r).codeChallengeMethod,resource:e(r).resource,scope:e(r).scope}:{client_id:e(r).clientId,redirect_uri:e(r).redirectUri,state:e(r).state},A=await fetch(`/api/oauth/${c?"approve":"deny"}`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${E.token}`},body:JSON.stringify(N)});if(A.status===401){E.logout(),F();return}if(!A.ok){a(o,"error"),a(P,"The authorization request was rejected. Restart the connection from your application.");return}const D=await A.json();a(o,"redirecting"),window.location.href=D.redirectTo}catch{a(o,"error"),a(P,"We could not reach the server. Please try again.")}}Pe(()=>{if(!E.isAuthenticated){a(o,"needLogin");return}if(e(r).responseType!=="code"||!e(r).clientId||!e(r).redirectUri||!e(r).codeChallenge||e(r).codeChallengeMethod!=="S256"){a(o,"invalid");return}ge()});var G=Ge(),_e=g(G);Te(_e,{class:"w-[420px]",children:(c,N)=>{var A=Fe(),D=f(A);Ae(D,{children:(K,ye)=>{var L=Me(),H=f(L);Ie(H,{class:"text-2xl",children:(W,$)=>{var v=Be(),V=g(v);{var X=n=>{var p=Le();t(n,p)},Y=n=>{var p=We();t(n,p)};U(V,n=>{Re.isDark?n(X):n(Y,!1)})}_(v),t(W,v)},$$slots:{default:!0}});var Q=i(H,2);Ue(Q,{class:"text-center",children:(W,$)=>{u();var v=x("Authorize application");t(W,v)},$$slots:{default:!0}}),t(K,L)},$$slots:{default:!0}});var $e=i(D,2);je($e,{children:(K,ye)=>{var L=M(),H=f(L);{var Q=$=>{var v=Ee();t($,v)},W=$=>{var v=M(),V=f(v);{var X=n=>{var p=Ne(),Z=i(g(p),2);se(Z,{class:"w-full",onclick:F,children:(ee,ce)=>{u();var y=x("Log in to continue");t(ee,y)},$$slots:{default:!0}}),_(p),t(n,p)},Y=n=>{var p=M(),Z=f(p);{var ee=y=>{var I=He(),B=g(I),O=g(B),te=g(O,!0);_(O),u(),_(B);var m=i(B,2);{var q=s=>{ze(s,{title:"Read and write access",children:(S,T)=>{u();var j=x(`It will be able to read your projects' telemetry and also archive issues, acknowledge
							and resolve pages, snooze alerts and edit post-mortems as you, in organizations where
							an admin turned on agent writes.`);t(S,j)},$$slots:{default:!0}})};U(m,s=>{e(ie)&&s(q)})}var z=i(m,2),C=g(z),k=i(C),d=g(k,!0);_(k),u(),_(z);var w=i(z,2),b=g(w);se(b,{class:"flex-1",onclick:()=>le(!0),children:(s,S)=>{var T=De(),j=f(T);Se(j,{class:"mr-2 h-4 w-4"}),u(),t(s,T)},$$slots:{default:!0}});var R=i(b,2);se(R,{variant:"outline",class:"flex-1",onclick:()=>le(!1),children:(s,S)=>{u();var T=x("Deny");t(s,T)},$$slots:{default:!0}}),_(w),_(I),ke(()=>{oe(te,e(ne)),oe(C,`${e(ie)?"Every change it makes is recorded in the organization activity log.":"It will be able to read your projects' telemetry but not change anything."} The application
						identified itself with this name; only approve if you just started connecting it, and it will
						send you back to `),oe(d,e(me))}),t(y,I)},ce=y=>{var I=M(),B=f(I);{var O=m=>{de(m,{variant:"destructive",children:(q,z)=>{var C=Oe(),k=f(C);pe(k,{class:"h-4 w-4"});var d=i(k,2);ue(d,{children:(b,R)=>{u();var s=x("Invalid authorization request");t(b,s)},$$slots:{default:!0}});var w=i(d,2);ve(w,{children:(b,R)=>{u();var s=x(`The request is missing required parameters or uses an unsupported flow. Restart the
						connection from your application.`);t(b,s)},$$slots:{default:!0}}),t(q,C)},$$slots:{default:!0}})},te=m=>{var q=M(),z=f(q);{var C=d=>{de(d,{variant:"destructive",children:(w,b)=>{var R=Je(),s=f(R);pe(s,{class:"h-4 w-4"});var S=i(s,2);ue(S,{children:(j,we)=>{u();var re=x("Unknown application");t(j,re)},$$slots:{default:!0}});var T=i(S,2);ve(T,{children:(j,we)=>{u();var re=x(`We don't recognize the application making this request. Restart the connection from your
						application.`);t(j,re)},$$slots:{default:!0}}),t(w,R)},$$slots:{default:!0}})},k=d=>{{let w=J(()=>e(P)||"Please try again.");qe(d,{title:"Something went wrong",get error(){return e(w)}})}};U(z,d=>{e(o)==="unknownClient"?d(C):d(k,!1)},!0)}t(m,q)};U(B,m=>{e(o)==="invalid"?m(O):m(te,!1)},!0)}t(y,I)};U(Z,y=>{e(o)==="confirm"?y(ee):y(ce,!1)},!0)}t(n,p)};U(V,n=>{e(o)==="needLogin"?n(X):n(Y,!1)},!0)}t($,v)};U(H,$=>{e(o)==="loading"||e(o)==="redirecting"?$(Q):$(W,!1)})}t(K,L)},$$slots:{default:!0}}),t(c,A)},$$slots:{default:!0}}),_(G),t(fe,G),Ce()}export{dt as component};