mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-04-07 00:15:23 +02:00
fix: resolve type check errors for OAuthClientInformation redirect_uris
The SDK's OAuthClientInformation type lacks redirect_uris (only on OAuthClientInformationFull). Cast to the local OAuthClientInformation type in handler.ts when accessing deserialized client info from DB, and use intersection types in tests for clientInfo with redirect_uris.
This commit is contained in:
parent
ca60c83aa3
commit
83ba37853b
2 changed files with 5 additions and 3 deletions
|
|
@ -23,6 +23,7 @@
|
|||
* fix and would require a distributed lock (e.g., Redis SETNX) around registration.
|
||||
*/
|
||||
|
||||
import type { OAuthClientInformation } from '@modelcontextprotocol/sdk/shared/auth.js';
|
||||
import type { OAuthTestServer } from './helpers/oauthTestServer';
|
||||
import { InMemoryTokenStore, createOAuthMCPServer } from './helpers/oauthTestServer';
|
||||
import { MCPOAuthHandler, MCPTokenStorage } from '~/mcp/oauth';
|
||||
|
|
@ -210,7 +211,7 @@ describe('MCPOAuthHandler - client registration reuse on reconnection', () => {
|
|||
client_id: 'old-client-id',
|
||||
client_secret: 'old-secret',
|
||||
redirect_uris: ['http://old-domain.com/api/mcp/test-server/oauth/callback'],
|
||||
},
|
||||
} as OAuthClientInformation & { redirect_uris: string[] },
|
||||
});
|
||||
|
||||
const result = await MCPOAuthHandler.initiateOAuthFlow(
|
||||
|
|
@ -242,7 +243,7 @@ describe('MCPOAuthHandler - client registration reuse on reconnection', () => {
|
|||
client_id: 'empty-redirect-client',
|
||||
client_secret: 'secret',
|
||||
redirect_uris: [],
|
||||
},
|
||||
} as OAuthClientInformation & { redirect_uris: string[] },
|
||||
});
|
||||
|
||||
const result = await MCPOAuthHandler.initiateOAuthFlow(
|
||||
|
|
|
|||
|
|
@ -509,7 +509,8 @@ export class MCPOAuthHandler {
|
|||
findToken,
|
||||
});
|
||||
if (existing?.clientInfo?.client_id) {
|
||||
const storedRedirectUri = existing.clientInfo.redirect_uris?.[0];
|
||||
const storedRedirectUri = (existing.clientInfo as OAuthClientInformation)
|
||||
.redirect_uris?.[0];
|
||||
if (!storedRedirectUri || storedRedirectUri !== redirectUri) {
|
||||
logger.debug(
|
||||
`[MCPOAuth] Stored redirect_uri "${storedRedirectUri}" differs from current "${redirectUri}", will re-register`,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue