LibreChat/api/server/services
Marco Beretta 2ad2c1c14b
🔑 perf: Cache JWT Users and Batch Auth-Path Reads (#17466)
* perf: Serve JWT Bearer User Lookups From the Auth User Cache

* perf: Batch Agent Permission Reads on the File Access Path

* perf: Remember a Loaded Google Service Key Across Endpoint Config Reads

* perf: Run Independent Startup, Tool, Skill and Erasure Reads Concurrently

* fix: Drop JWT User Cache Writes That Race a User Mutation

Confirm each cache write with a second read and evict when the user changed,
so an in-flight lookup cannot repopulate an entry a credential change just
evicted. The cache mode now arrives through the loader dependencies.

* refactor: Move Agent Skill Access Reads Into packages/api

The chat-completions and Responses controllers call loadSkillAccess instead of
orchestrating the three reads in CJS. The preview route spec mocks the batched
file access helper the middleware now calls.

* test: Cover Agent File Access, JWT Bursts and Remote Skill Reads End to End

* fix: Serve a Cached JWT User Only While Its updatedAt Is Current

A cache hit now reads the stored updatedAt and deletion fence instead of the
fence alone, so a document cached from a read that raced a user mutation is
never served, even when the write landed after that mutation's eviction.

* refactor: Move Startup Migration Checks Into packages/api

* refactor: Inject the Startup Migration Checks Instead of Mongoose Models

* fix: Serve Cached OpenID Users Only While Their updatedAt Is Current

Moves the freshness check into getCurrentCachedAuthUserDoc and uses it on the
OpenID bearer path as well as the local JWT one, so a document cached from a
read that raced a credential or role change is never served there either.

Fixes berry-13/LibreChat#432

* fix: Compare Authorization Fields on Every Auth Cache Hit

updatedAt has millisecond resolution, so the freshness read also compares the
token retirement stamps, role, tenant and two-factor state.

* fix: Annotate the Auth Freshness Projection for Isolated Declarations

* perf: Reuse the OpenID Cache Freshness Read for Deletion Admission

A cache hit already proved the deletion fence is clear, so only users read from
the database take the separate fence query.

* refactor: Keep the OpenID Cache Freshness and Fence Decisions in packages/api

* test: Exercise JWT Cache Freshness Against Real User Methods in MongoDB

* fix: Stamp the JWT User Lookup So the Cache Write Fence Applies

* fix: Reload a Google Service Key File When It Changes or Disappears

The availability check remembers a loaded key only while the file's mtime and
size are unchanged, and fetches URL sources every time as before.

* fix: Recheck a Service Key File After a Permission Change
2026-10-30 00:24:08 +01:00
..
__tests__ 🚤 fix: Keep Host Tool Loading Independent of Worker Status (#17628) 2026-10-29 22:13:10 +01:00
Agents 🏭 refactor: Centralize Source Prompt Imports in the Prompt Service (#17272) 2026-10-24 13:51:31 +02:00
Artifacts
Config 🔑 perf: Cache JWT Users and Batch Auth-Path Reads (#17466) 2026-10-30 00:24:08 +01:00
Endpoints 🏎️ perf: Parallelize Independent Agent and Schedule Lookups (#17465) 2026-10-28 18:59:16 +01:00
Files 🔚 fix: Bound Abandoned File Deletion Retries (#17640) 2026-10-29 23:48:40 +01:00
MCP 🔐 fix: Fence ACL Viewers and Surface Revocation Failures When Removing Shared MCP Servers (#17506) 2026-10-28 00:37:07 +01:00
Runs 🪦 refactor: Remove Dead Legacy API Modules and Root Tooling (#17114) 2026-10-15 12:25:24 +02:00
Schedules 🪦 refactor: Remove Dead Legacy API Modules and Root Tooling (#17114) 2026-10-15 12:25:24 +02:00
Skills 🔌 feat: Integrate Durable Skill Lifecycle Across Writers and Routes (#17043) 2026-10-16 09:05:05 -07:00
start 🔑 perf: Cache JWT Users and Batch Auth-Path Reads (#17466) 2026-10-30 00:24:08 +01:00
Threads ⚡ perf: Async Local File Saves and Compile Hot-Path Regexes Once (#16712) 2026-10-04 15:52:55 -04:00
Tools 🧯 fix: Guard SSE Writes and Interval Cleanups Against Crashes (#17462) 2026-10-27 23:06:58 +01:00
ActionService.js 🫢 fix: Keep OAuth Credentials Out of Logs (#17409) 2026-10-24 09:43:06 +02:00
ActionService.spec.js 🫢 fix: Keep OAuth Credentials Out of Logs (#17409) 2026-10-24 09:43:06 +02:00
AssistantService.js 🪦 refactor: Remove Dead Legacy API Modules and Root Tooling (#17114) 2026-10-15 12:25:24 +02:00
AuthService.js ⬆️ feat: Migrate to Zod v4 (#17442) 2026-10-26 14:16:22 +01:00
AuthService.spec.js 🔐 fix: Apply Base Config Overrides Before Sign-In and Refuse Script Policy Links (#17351) 2026-10-22 22:49:54 +02:00
createRunBody.js 🛂 feat: Filter Model-Bound Content by Source (#14425) 2026-08-21 22:43:32 -04:00
createRunBody.spec.js 🛂 feat: Filter Model-Bound Content by Source (#14425) 2026-08-21 22:43:32 -04:00
GraphApiService.js 🪦 refactor: Remove Dead Legacy API Modules and Root Tooling (#17114) 2026-10-15 12:25:24 +02:00
GraphApiService.spec.js 🪦 refactor: Remove Dead Legacy API Modules and Root Tooling (#17114) 2026-10-15 12:25:24 +02:00
GraphTokenService.js
initializeMCPs.js 🙈 feat: Let Config Profiles Hide librechat.yaml MCP Servers and Remove Their Fields (#17327) 2026-10-22 14:10:31 +02:00
initializeMCPs.plugins.spec.js 🙈 feat: Let Config Profiles Hide librechat.yaml MCP Servers and Remove Their Fields (#17327) 2026-10-22 14:10:31 +02:00
initializeMCPs.spec.js 🙈 feat: Let Config Profiles Hide librechat.yaml MCP Servers and Remove Their Fields (#17327) 2026-10-22 14:10:31 +02:00
initializeOAuthReconnectManager.js 🧯 fix: Guard SSE Writes and Interval Cleanups Against Crashes (#17462) 2026-10-27 23:06:58 +01:00
initializeOAuthReconnectManager.spec.js 🧯 fix: Guard SSE Writes and Interval Cleanups Against Crashes (#17462) 2026-10-27 23:06:58 +01:00
LangfusePromptSync.js 🏭 refactor: Centralize Source Prompt Imports in the Prompt Service (#17272) 2026-10-24 13:51:31 +02:00
LangfusePromptSync.spec.js 🏭 refactor: Centralize Source Prompt Imports in the Prompt Service (#17272) 2026-10-24 13:51:31 +02:00
MCP.js 🙈 feat: Let Config Profiles Hide librechat.yaml MCP Servers and Remove Their Fields (#17327) 2026-10-22 14:10:31 +02:00
MCP.spec.js 🙈 feat: Let Config Profiles Hide librechat.yaml MCP Servers and Remove Their Fields (#17327) 2026-10-22 14:10:31 +02:00
MCPAuthorizationFenceRetry.js 🛂 fix: Back Off MCP OAuth Discovery (#15783) 2026-09-09 22:21:34 -04:00
MCPAuthorizationFenceRetry.spec.js 🛂 fix: Back Off MCP OAuth Discovery (#15783) 2026-09-09 22:21:34 -04:00
MCPRequestContext.js
OboPolicyService.js
OboTokenService.js 🙈 fix: Mask Emails and Drop Personal Identifiers From Logs (#17048) 2026-10-15 15:54:27 +02:00
OboTokenService.spec.js 🔒 fix: Refresh MCP OBO Tokens From the Live OpenID Session (#15334) 2026-08-29 23:55:58 -04:00
OpenIDRefreshFlight.js 🔒 fix: Refresh MCP OBO Tokens From the Live OpenID Session (#15334) 2026-08-29 23:55:58 -04:00
OpenIDRefreshFlight.spec.js 🪫 fix: Recharge Direct OpenID MCP Bearer Sessions (#15704) 2026-09-07 21:05:26 -04:00
OpenIDRefreshRecovery.js 🔒 fix: Refresh MCP OBO Tokens From the Live OpenID Session (#15334) 2026-08-29 23:55:58 -04:00
OpenIDSessionRefresh.js 🪫 fix: Recharge Direct OpenID MCP Bearer Sessions (#15704) 2026-09-07 21:05:26 -04:00
OpenIDSessionRefresh.spec.js 🪪 fix: Boot-Paint a Cached Theme Only for Its Signed-In Owner (#16926) 2026-10-14 11:08:53 +02:00
PermissionService.js 🛂 feat: Audit Resource Sharing Changes and Fail Closed on Reversible Audit Writes (#17053) 2026-10-15 00:30:16 +02:00
PermissionService.spec.js 🛂 feat: Audit Resource Sharing Changes and Fail Closed on Reversible Audit Writes (#17053) 2026-10-15 00:30:16 +02:00
PluginService.js 🪦 refactor: Remove Dead Legacy API Modules and Root Tooling (#17114) 2026-10-15 12:25:24 +02:00
PluginService.spec.js 🔐 fix: Encrypt User Plugin Credentials With Random-IV v3 Format (#16996) 2026-10-12 16:33:08 +02:00
Prompts.consumers.spec.js 🏭 refactor: Centralize Source Prompt Imports in the Prompt Service (#17272) 2026-10-24 13:51:31 +02:00
Prompts.js 🏭 refactor: Centralize Source Prompt Imports in the Prompt Service (#17272) 2026-10-24 13:51:31 +02:00
Prompts.spec.js 🏭 refactor: Centralize Source Prompt Imports in the Prompt Service (#17272) 2026-10-24 13:51:31 +02:00
RefreshTokenBridge.js 🔒 fix: Refresh MCP OBO Tokens From the Live OpenID Session (#15334) 2026-08-29 23:55:58 -04:00
RefreshTokenBridge.spec.js 🔒 fix: Refresh MCP OBO Tokens From the Live OpenID Session (#15334) 2026-08-29 23:55:58 -04:00
systemGrant.spec.js
ToolService.js 🔑 perf: Cache JWT Users and Batch Auth-Path Reads (#17466) 2026-10-30 00:24:08 +01:00
twoFactorService.js 🗝️ fix: Strengthen Two-Factor Recovery Credentials (#16742) 2026-10-04 12:16:37 -04:00
twoFactorService.spec.js 🗃️ refactor: Remove Dead Data Schemas Methods and Data Provider Exports (#17113) 2026-10-15 12:23:29 +02:00