@cto.af/ca
Version:
Testing-only Certificate Authority (CA) for your local development environment ONLY. This is in no way suitable for production of any kind.
30 lines (29 loc) • 1.19 kB
TypeScript
import { type CertOptions } from './index.js';
/**
* Override tls.createSecureContext to trust a CA cert specified by the
* options. WARNING: Do not call this function more than once without calling
* resetCreateSecureContext.
*
* @param options CA options.
* @returns Unique symbol, to be used in resetCreateSecureContext.
* @throws On invalid state.
*/
export declare function overrideCreateSecureContext(options: CertOptions | string): Promise<symbol>;
/**
* Reset tls.createSecureContext back to its default. This must match
* a corresponding call to overrideCreateSecureContext.
*
* @param sym Unique symbol returned from overrideCreateSecureContext.
* @throws On invalid state.
*/
export declare function resetCreateSecureContext(sym: symbol): void;
/**
* Trust the CA cert that CertificateAuthority generates for all node.js TLS
* operations, including fetch, but only for the duration of this function
* call.
*
* @param options Certificate options.
* @param during Callback during which the cert will be valid.
* @returns The result of during.
*/
export declare function whileCAtrusted<T>(options: CertOptions | string, during: () => T): Promise<Awaited<T>>;