LibreChat/packages/api/tsdown.config.mjs
Marco Beretta 4c6ea7e981
🔐 fix: Hash Passwords on a Worker Pool and Surface API Key Lookup Failures (#17261)
* fix: Hash Off the Event Loop and Surface API Key Lookup Failures

Registration, email verification, password reset and verification resends
hashed and compared with bcryptjs's synchronous calls. bcryptjs is pure
JavaScript, so each call blocked the event loop for every request in the
process. They now use the promise APIs, and the password reset
dependencies are async.

validateAgentApiKey caught its own query failures and returned null, so a
database outage answered remote callers with 401 Invalid API key. It now
lets the failure reach requireApiKeyAuth, which answers with a 500.

* fix: Run bcrypt on a Worker Pool in packages/api

bcryptjs's promise API still computes on the main thread, only in chunks
of up to 100 ms, so concurrent registrations and resets kept stalling
unrelated requests (four cost-10 hashes delayed a 5 ms timer by about
190 ms). hashSecret and compareSecret now run bcryptjs on a small
worker_threads pool in packages/api, and AuthService.js calls them.

* feat: Configure the Password Hashing Worker Count

* fix: Verify Login and Step-Up Passwords on the Hash Pool
2026-10-19 22:13:31 +02:00

29 lines
1.1 KiB
JavaScript

import path from 'node:path';
import { defineConfig } from 'tsdown';
export default defineConfig({
// The telemetry entry is a thin shim (`src/telemetry.ts`) rather than the
// `src/telemetry/index.ts` barrel: oxc emits declarations flat into outDir keyed
// by source basename, so two `index.ts` entries would collide (index.d.cts +
// index2.d.cts). Distinct basenames yield stable `index.*` / `telemetry.*` output.
entry: [
'src/index.ts',
'src/telemetry.ts',
'src/credentials.ts',
'src/agents/files/edit-worker.ts',
'src/auth/hash-worker.ts',
],
format: ['cjs'],
platform: 'node',
dts: { oxc: true },
outDir: 'dist',
sourcemap: true,
// Warn on module cycles at build time; CI enforces via config/circular-deps.mjs.
checks: { circularDependency: true },
// Externalize every third-party dependency (consumers provide the peers) and bundle
// only first-party code: relative imports and the `~/*` tsconfig alias (-> src).
// `neverBundle` is the 0.22 replacement for the deprecated `external` option.
deps: {
neverBundle: (id) => !id.startsWith('.') && !id.startsWith('~') && !path.isAbsolute(id),
},
});