mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-25 20:05:46 -06:00
refactor(agents): hide mcp oauth redirect classifier
This commit is contained in:
@@ -6,7 +6,6 @@ import { vi } from "vitest";
|
||||
import {
|
||||
clearMcpOAuthCredentials,
|
||||
createMcpOAuthClientProvider,
|
||||
isMcpOAuthRedirectRegistrationError,
|
||||
runMcpOAuthLogin,
|
||||
} from "./mcp-oauth.js";
|
||||
|
||||
@@ -88,15 +87,6 @@ describe("MCP OAuth provider", () => {
|
||||
expect(provider.redirectUrl).toBe("http://127.0.0.1:8989/oauth/callback");
|
||||
});
|
||||
|
||||
it("detects redirect registration failures for localhost fallback", () => {
|
||||
expect(
|
||||
isMcpOAuthRedirectRegistrationError(
|
||||
new Error("HTTP 400: invalid_client_metadata redirect_uri must be localhost"),
|
||||
),
|
||||
).toBe(true);
|
||||
expect(isMcpOAuthRedirectRegistrationError(new Error("unauthorized"))).toBe(false);
|
||||
});
|
||||
|
||||
it("retries MCP OAuth login with localhost after redirect registration rejection", async () => {
|
||||
authMock.mockReset();
|
||||
authMock
|
||||
|
||||
@@ -49,7 +49,7 @@ export type McpOAuthCredentialsStatus = {
|
||||
const LEGACY_DEFAULT_REDIRECT_URL = "http://127.0.0.1:8989/oauth/callback";
|
||||
const LOCALHOST_REDIRECT_URL = "http://localhost:8989/oauth/callback";
|
||||
|
||||
export function isMcpOAuthRedirectRegistrationError(error: unknown): boolean {
|
||||
function isMcpOAuthRedirectRegistrationError(error: unknown): boolean {
|
||||
return /invalid_client_metadata|redirect_uri/i.test(String(error));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user