Skip to content

Commit cbe6324

Browse files
committed
callback shuffling
1 parent 4a67d0c commit cbe6324

File tree

1 file changed

+32
-29
lines changed

1 file changed

+32
-29
lines changed

client/src/components/AuthDebugger.tsx

Lines changed: 32 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -60,34 +60,7 @@ const AuthDebugger = ({
6060
}: AuthDebuggerProps) => {
6161
// Load client info asynchronously when we're at the token_request step
6262

63-
const validateOAuthMetadata = async (
64-
provider: DebugInspectorOAuthClientProvider,
65-
): Promise<OAuthMetadata> => {
66-
const metadata = provider.getServerMetadata();
67-
if (metadata) {
68-
return metadata;
69-
}
70-
71-
const fetchedMetadata = await discoverOAuthMetadata(sseUrl);
72-
if (!fetchedMetadata) {
73-
throw new Error("Failed to discover OAuth metadata");
74-
}
75-
const parsedMetadata =
76-
await OAuthMetadataSchema.parseAsync(fetchedMetadata);
77-
78-
return parsedMetadata;
79-
};
80-
81-
const validateClientInformation = async (
82-
provider: DebugInspectorOAuthClientProvider,
83-
): Promise<OAuthClientInformation> => {
84-
const clientInformation = await provider.clientInformation();
85-
86-
if (!clientInformation) {
87-
throw new Error("Can't advance without successful client registration");
88-
}
89-
return clientInformation;
90-
};
63+
// These functions will be moved inside proceedToNextStep to avoid ESLint warning
9164

9265
const startOAuthFlow = useCallback(() => {
9366
if (!sseUrl) {
@@ -113,6 +86,36 @@ const AuthDebugger = ({
11386
if (!sseUrl) return;
11487
const provider = new DebugInspectorOAuthClientProvider(sseUrl);
11588

89+
// Helper functions moved inside useCallback to avoid ESLint warning
90+
const validateOAuthMetadata = async (
91+
provider: DebugInspectorOAuthClientProvider,
92+
): Promise<OAuthMetadata> => {
93+
const metadata = provider.getServerMetadata();
94+
if (metadata) {
95+
return metadata;
96+
}
97+
98+
const fetchedMetadata = await discoverOAuthMetadata(sseUrl);
99+
if (!fetchedMetadata) {
100+
throw new Error("Failed to discover OAuth metadata");
101+
}
102+
const parsedMetadata =
103+
await OAuthMetadataSchema.parseAsync(fetchedMetadata);
104+
105+
return parsedMetadata;
106+
};
107+
108+
const validateClientInformation = async (
109+
provider: DebugInspectorOAuthClientProvider,
110+
): Promise<OAuthClientInformation> => {
111+
const clientInformation = await provider.clientInformation();
112+
113+
if (!clientInformation) {
114+
throw new Error("Can't advance without successful client registration");
115+
}
116+
return clientInformation;
117+
};
118+
116119
try {
117120
updateAuthState({
118121
isInitiatingAuth: true,
@@ -213,7 +216,7 @@ const AuthDebugger = ({
213216
} finally {
214217
updateAuthState({ isInitiatingAuth: false });
215218
}
216-
}, [sseUrl, authState, updateAuthState, validateOAuthMetadata]);
219+
}, [sseUrl, authState, updateAuthState]);
217220

218221
const handleStartOAuth = useCallback(async () => {
219222
if (!sseUrl) {

0 commit comments

Comments
 (0)