|
1 | | -import{r as d,S as a,p as l,j as r,g as h}from"./index-De_cSjJc.js";const p=({onConnect:s})=>{d.useEffect(()=>{let c=!1;return(async()=>{if(c)return;c=!0;const o=l(window.location.search);if(!o.successful){const i=h(o);s({errorMsg:i});return}const u=sessionStorage.getItem(a.SERVER_URL),n=sessionStorage.getItem(a.AUTH_DEBUGGER_STATE);let e=null;if(n)try{e=JSON.parse(n),e&&typeof e.resource=="string"&&(e.resource=new URL(e.resource)),e&&typeof e.authorizationUrl=="string"&&(e.authorizationUrl=new URL(e.authorizationUrl)),sessionStorage.removeItem(a.AUTH_DEBUGGER_STATE)}catch(i){console.error("Failed to parse stored auth state:",i)}if(u){if(!o.code){s({errorMsg:"Missing authorization code"});return}s({authorizationCode:o.code,restoredState:e})}})().finally(()=>{sessionStorage.getItem(a.SERVER_URL)&&window.history.replaceState({},document.title,"/")}),()=>{c=!0}},[s]);const t=l(window.location.search);return r.jsx("div",{className:"flex items-center justify-center h-screen",children:r.jsxs("div",{className:"mt-4 p-4 bg-secondary rounded-md max-w-md",children:[r.jsx("p",{className:"mb-2 text-sm",children:"Please copy this authorization code and return to the Auth Debugger:"}),r.jsx("code",{className:"block p-2 bg-muted rounded-sm overflow-x-auto text-xs",children:t.successful&&"code"in t?t.code:`No code found: ${t.error}, ${t.error_description}`}),r.jsx("p",{className:"mt-4 text-xs text-muted-foreground",children:"Close this tab and paste the code in the OAuth flow to complete authentication."})]})})};export{p as default}; |
| 1 | +import { r as d, S as a, p as l, j as r, g as h } from "./index-De_cSjJc.js"; |
| 2 | +const p = ({ onConnect: s }) => { |
| 3 | + d.useEffect(() => { |
| 4 | + let c = !1; |
| 5 | + return ( |
| 6 | + (async () => { |
| 7 | + if (c) return; |
| 8 | + c = !0; |
| 9 | + const o = l(window.location.search); |
| 10 | + if (!o.successful) { |
| 11 | + const i = h(o); |
| 12 | + s({ errorMsg: i }); |
| 13 | + return; |
| 14 | + } |
| 15 | + const u = sessionStorage.getItem(a.SERVER_URL), |
| 16 | + n = sessionStorage.getItem(a.AUTH_DEBUGGER_STATE); |
| 17 | + let e = null; |
| 18 | + if (n) |
| 19 | + try { |
| 20 | + ((e = JSON.parse(n)), |
| 21 | + e && |
| 22 | + typeof e.resource == "string" && |
| 23 | + (e.resource = new URL(e.resource)), |
| 24 | + e && |
| 25 | + typeof e.authorizationUrl == "string" && |
| 26 | + (e.authorizationUrl = new URL(e.authorizationUrl)), |
| 27 | + sessionStorage.removeItem(a.AUTH_DEBUGGER_STATE)); |
| 28 | + } catch (i) { |
| 29 | + console.error("Failed to parse stored auth state:", i); |
| 30 | + } |
| 31 | + if (u) { |
| 32 | + if (!o.code) { |
| 33 | + s({ errorMsg: "Missing authorization code" }); |
| 34 | + return; |
| 35 | + } |
| 36 | + s({ authorizationCode: o.code, restoredState: e }); |
| 37 | + } |
| 38 | + })().finally(() => { |
| 39 | + sessionStorage.getItem(a.SERVER_URL) && |
| 40 | + window.history.replaceState({}, document.title, "/"); |
| 41 | + }), |
| 42 | + () => { |
| 43 | + c = !0; |
| 44 | + } |
| 45 | + ); |
| 46 | + }, [s]); |
| 47 | + const t = l(window.location.search); |
| 48 | + return r.jsx("div", { |
| 49 | + className: "flex items-center justify-center h-screen", |
| 50 | + children: r.jsxs("div", { |
| 51 | + className: "mt-4 p-4 bg-secondary rounded-md max-w-md", |
| 52 | + children: [ |
| 53 | + r.jsx("p", { |
| 54 | + className: "mb-2 text-sm", |
| 55 | + children: |
| 56 | + "Please copy this authorization code and return to the Auth Debugger:", |
| 57 | + }), |
| 58 | + r.jsx("code", { |
| 59 | + className: "block p-2 bg-muted rounded-sm overflow-x-auto text-xs", |
| 60 | + children: |
| 61 | + t.successful && "code" in t |
| 62 | + ? t.code |
| 63 | + : `No code found: ${t.error}, ${t.error_description}`, |
| 64 | + }), |
| 65 | + r.jsx("p", { |
| 66 | + className: "mt-4 text-xs text-muted-foreground", |
| 67 | + children: |
| 68 | + "Close this tab and paste the code in the OAuth flow to complete authentication.", |
| 69 | + }), |
| 70 | + ], |
| 71 | + }), |
| 72 | + }); |
| 73 | +}; |
| 74 | +export { p as default }; |
0 commit comments