mockttp
Version:
Mock HTTP server for testing HTTP clients and stubbing webservices
77 lines • 2.24 kB
TypeScript
import { Buffer } from 'buffer';
import * as x509 from '@peculiar/x509';
export type CAOptions = (CertDataOptions | CertPathOptions);
export interface CertDataOptions extends BaseCAOptions {
key: string;
cert: string;
}
export interface CertPathOptions extends BaseCAOptions {
keyPath: string;
certPath: string;
}
export interface BaseCAOptions {
/**
* Minimum key length when generating certificates. Defaults to 2048.
*/
keyLength?: number;
/**
* The countryName that will be used in the certificate for incoming TLS
* connections.
*/
countryName?: string;
/**
* The localityName that will be used in the certificate for incoming TLS
* connections.
*/
localityName?: string;
/**
* The organizationName that will be used in the certificate for incoming TLS
* connections.
*/
organizationName?: string;
}
export type PEM = string | string[] | Buffer | Buffer[];
export type GeneratedCertificate = {
key: string;
cert: string;
ca: string;
};
/**
* Generate a CA certificate for mocking HTTPS.
*
* Returns a promise, for an object with key and cert properties,
* containing the generated private key and certificate in PEM format.
*
* These can be saved to disk, and their paths passed
* as HTTPS options to a Mockttp server.
*/
export declare function generateCACertificate(options?: {
subject?: {
commonName?: string;
organizationName?: string;
countryName?: string;
[key: string]: string | undefined;
};
bits?: number;
nameConstraints?: {
/**
* Array of permitted domains
*/
permitted?: string[];
};
}): Promise<{
key: string;
cert: string;
}>;
export declare function generateSPKIFingerprint(certPem: string): Promise<string>;
export declare function getCA(options: CAOptions): Promise<CA>;
export type { CA };
declare class CA {
private caCert;
private caKey;
private options;
private certCache;
constructor(caCert: x509.X509Certificate, caKey: CryptoKey, options?: BaseCAOptions);
generateCertificate(domain: string): Promise<GeneratedCertificate>;
}
//# sourceMappingURL=certificates.d.ts.map