All files / packages/mkcert/dist index.d.mts

0% Statements 0/57
0% Branches 0/1
0% Functions 0/1
0% Lines 0/57

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58                                                                                                                   
import { Prettify } from '@https-enable/types';
export { Prettify } from '@https-enable/types';
import { CertificateAuthorityOptions } from 'mkcert';

type CertFile = 'key' | 'cert'

type Certificate = Record<CertFile, string>
type CertificatePath = Prettify<Record<CertFile, string>> | { base: string }

interface VerifyResult {
  match: boolean
  message: string
}

interface VerifyOptions {
  host: string
  port: number | string
  rejectUnauthorized?: boolean
}

type CreateOptions = Prettify<CertificateAuthorityOptions & { domains: string[] | string, force: boolean }>

declare const defaultCertificateBasePath: string;
declare function processCertPath(certPath?: Partial<CertificatePath>): {
    keyPath: string;
    certPath: string;
};
declare function readCertificate(options?: CertificatePath): {
    key: string;
    cert: string;
} | null;
/**
 * 在项目根目录下创建一个 mkcert 目录,用于存放生成的证书和密钥文件
 */
declare function saveCertificate(cert: string, key: string, options?: CertificatePath): {
    keyPath: string;
    certPath: string;
};
declare function createCertificate(_options: CreateOptions, pathOptions?: CertificatePath, isCache?: boolean): Promise<Certificate>;

declare function verifyCertificateByTLS(options: Prettify<VerifyOptions & Certificate>): void;
declare function verifyCertificateValidityByTLS(options: Prettify<VerifyOptions>): void;
declare function verifyCertificate(keyPem: string, certPem: string): Promise<{
    match: boolean;
    message: string;
}>;

declare function initSSLCertificate(options: CreateOptions, pathOptions?: CertificatePath): Promise<{
    key: string;
    cert: string;
}>;
declare function defineCertificate(options?: Pick<CreateOptions, 'validity'> & Partial<Omit<CreateOptions, 'validity'>>, pathOptions?: CertificatePath): Promise<{
    key: string;
    cert: string;
}>;

export { type Certificate, type CertificatePath, type CreateOptions, type VerifyOptions, type VerifyResult, createCertificate, defaultCertificateBasePath, defineCertificate, initSSLCertificate, processCertPath, readCertificate, saveCertificate, verifyCertificate, verifyCertificateByTLS, verifyCertificateValidityByTLS };