({
serverUrl: serverUrl,
onBack,
authState,
updateAuthState,
config,
connectionType,
}: AuthDebuggerProps)
| 60 | }; |
| 61 | |
| 62 | const AuthDebugger = ({ |
| 63 | serverUrl: serverUrl, |
| 64 | onBack, |
| 65 | authState, |
| 66 | updateAuthState, |
| 67 | config, |
| 68 | connectionType, |
| 69 | }: AuthDebuggerProps) => { |
| 70 | // Check for existing tokens on mount |
| 71 | useEffect(() => { |
| 72 | if (serverUrl && !authState.oauthTokens) { |
| 73 | const checkTokens = async () => { |
| 74 | try { |
| 75 | const provider = new DebugInspectorOAuthClientProvider(serverUrl); |
| 76 | const existingTokens = await provider.tokens(); |
| 77 | if (existingTokens) { |
| 78 | updateAuthState({ |
| 79 | oauthTokens: existingTokens, |
| 80 | oauthStep: "complete", |
| 81 | }); |
| 82 | } |
| 83 | } catch (error) { |
| 84 | console.error("Failed to load existing OAuth tokens:", error); |
| 85 | } |
| 86 | }; |
| 87 | checkTokens(); |
| 88 | } |
| 89 | }, [serverUrl, updateAuthState, authState.oauthTokens]); |
| 90 | |
| 91 | const startOAuthFlow = useCallback(() => { |
| 92 | if (!serverUrl) { |
| 93 | updateAuthState({ |
| 94 | statusMessage: { |
| 95 | type: "error", |
| 96 | message: |
| 97 | "Please enter a server URL in the sidebar before authenticating", |
| 98 | }, |
| 99 | }); |
| 100 | return; |
| 101 | } |
| 102 | |
| 103 | updateAuthState({ |
| 104 | oauthStep: "metadata_discovery", |
| 105 | authorizationUrl: null, |
| 106 | statusMessage: null, |
| 107 | latestError: null, |
| 108 | }); |
| 109 | }, [serverUrl, updateAuthState]); |
| 110 | |
| 111 | const fetchFn = useMemo( |
| 112 | () => |
| 113 | connectionType === "proxy" && config |
| 114 | ? createProxyFetch(config) |
| 115 | : undefined, |
| 116 | [connectionType, config], |
| 117 | ); |
| 118 | |
| 119 | const stateMachine = useMemo( |
nothing calls this directly
no test coverage detected
searching dependent graphs…