harperdb
Version:
HarperDB is a distributed database, caching service, streaming broker, and application development platform focused on performance and ease of use.
30 lines (29 loc) • 1.53 kB
TypeScript
/**
* Configuration parsing and default values for certificate verification
*/
import type { CertificateVerificationConfig } from './types.ts';
export declare const CRL_DEFAULT_VALIDITY_PERIOD: number;
export declare const ERROR_CACHE_TTL = 300000;
export declare const CRL_USER_AGENT: string;
/**
* Cached version of getCertificateVerificationConfig to avoid redundant parsing
* This is the recommended function to use in hot paths like certificate verification.
*
* MEMORY SAFETY:
* - Uses WeakMap for object configs to prevent memory leaks
* - Config objects can be garbage collected when no longer referenced elsewhere
* - Primitive values (boolean, null, undefined) use simple reference equality
* - No strong references held to config objects, preventing memory accumulation
*
* ERROR HANDLING:
* - Invalid config causes validation errors to be thrown on first access
* - Validation errors are logged once and then cached
* - Subsequent accesses with the same invalid config return false (disabled) to prevent
* repeated error logging and allow the application to continue running
* - This provides fail-safe behavior: invalid security config defaults to disabled
* rather than crashing on every request
*
* @param mtlsConfig - The mTLS configuration from env.get()
* @returns Configuration object or false if verification is disabled or invalid
*/
export declare function getCachedCertificateVerificationConfig(mtlsConfig?: boolean | Record<string, any> | null): false | CertificateVerificationConfig;