mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-11-17 21:43:06 +00:00
* fix: Clean Up MCP OAuth Teardown State * fix: Harden OAuth Teardown Boundaries * fix: harden MCP OAuth teardown races * fix: avoid flow cache dependency cycle * fix: bind OAuth teardown to credential generations * test: cover active OAuth server fixtures * style: sort OAuth cleanup imports * fix: discard mismatched OAuth token snapshots * fix: fence OAuth teardown across callback races * test: align OAuth callback fixtures with server fencing * test: complete OAuth callback server fixtures * fix: version OAuth flow settlement * fix: fence OAuth teardown snapshots * test: align OAuth teardown fixtures * test: complete OAuth snapshot fixtures * fix: snapshot OAuth deletion lifecycle * test: bind OAuth revocation snapshots * test: assert per-record OAuth fence * fix: harden MCP OAuth teardown consistency * test: expect snapshotted OAuth readers
61 lines
1.8 KiB
JavaScript
61 lines
1.8 KiB
JavaScript
const { EventSource } = require('eventsource');
|
|
const { Time } = require('librechat-data-provider');
|
|
const {
|
|
mcpConfig,
|
|
MCPManager,
|
|
FlowStateManager,
|
|
evalKeyvRedisScript,
|
|
MCPServersRegistry,
|
|
OAuthReconnectionManager,
|
|
} = require('@librechat/api');
|
|
|
|
global.EventSource = EventSource;
|
|
|
|
/** @type {FlowStateManager} */
|
|
let flowManager = null;
|
|
/** @type {FlowStateManager} */
|
|
let actionFlowManager = null;
|
|
|
|
/**
|
|
* Flow manager for MCP OAuth flows. Uses the longer MCP OAuth TTL so the auth
|
|
* button and flow state outlive the user-completion window.
|
|
* @param {Keyv} flowsCache
|
|
* @returns {FlowStateManager}
|
|
*/
|
|
function getFlowStateManager(flowsCache) {
|
|
if (!flowManager) {
|
|
flowManager = new FlowStateManager(flowsCache, {
|
|
ttl: mcpConfig.OAUTH_FLOW_TTL,
|
|
monitorTimeout: mcpConfig.OAUTH_HANDLING_TIMEOUT,
|
|
retainedFailureTypes: ['mcp_oauth'],
|
|
redisScriptExecutor: evalKeyvRedisScript,
|
|
});
|
|
}
|
|
return flowManager;
|
|
}
|
|
|
|
/**
|
|
* Flow manager for Action (custom tool) OAuth flows. Kept on the shorter TTL so an
|
|
* unclicked action login does not leave the tool call waiting for the MCP OAuth window.
|
|
* @param {Keyv} flowsCache
|
|
* @returns {FlowStateManager}
|
|
*/
|
|
function getActionFlowStateManager(flowsCache) {
|
|
if (!actionFlowManager) {
|
|
actionFlowManager = new FlowStateManager(flowsCache, {
|
|
ttl: Time.ONE_MINUTE * 3,
|
|
});
|
|
}
|
|
return actionFlowManager;
|
|
}
|
|
|
|
module.exports = {
|
|
createMCPServersRegistry: MCPServersRegistry.createInstance,
|
|
getMCPServersRegistry: MCPServersRegistry.getInstance,
|
|
createMCPManager: MCPManager.createInstance,
|
|
getMCPManager: MCPManager.getInstance,
|
|
getFlowStateManager,
|
|
getActionFlowStateManager,
|
|
createOAuthReconnectionManager: OAuthReconnectionManager.createInstance,
|
|
getOAuthReconnectionManager: OAuthReconnectionManager.getInstance,
|
|
};
|