function certificateFor(requestedDomains, options = {}) {
    return tslib_1.__awaiter(this, void 0, void 0, function* () {
        const domains = Array.isArray(requestedDomains) ? requestedDomains : [requestedDomains];
        if (domains.some((d) => constants_1.VALID_IP.test(d))) {
            throw new Error('IP addresses are not supported currently');
        }
        domains.forEach((domain) => {
            if (!constants_1.VALID_DOMAIN.test(domain)) {
                throw new Error(`"${domain}" is not a valid domain name.`);
            }
        });
        const domainPath = constants_1.getStableDomainPath(domains);
        debug(`Certificate requested for ${domains}. Skipping certutil install: ${Boolean(options.skipCertutilInstall)}. Skipping hosts file: ${Boolean(options.skipHostsFile)}`);
        if (options.ui) {
            Object.assign(user_interface_1.default, options.ui);
        }
        if (!constants_1.isMac && !constants_1.isLinux && !constants_1.isWindows) {
            throw new Error(`Platform not supported: "${process.platform}"`);
        }
        if (!command_exists_1.sync('openssl')) {
            throw new Error('OpenSSL not found: OpenSSL is required to generate SSL certificates - make sure it is installed and available in your PATH');
        }
        let domainKeyPath = constants_1.pathForDomain(domainPath, `private-key.key`);
        let domainCertPath = constants_1.pathForDomain(domainPath, `certificate.crt`);
        if (!fs_1.existsSync(constants_1.rootCAKeyPath)) {
            debug('Root CA is not installed yet, so it must be our first run. Installing root CA ...');
            yield certificate_authority_1.default(options);
        }
        else if (options.getCaBuffer || options.getCaPath) {
            debug('Root CA is not readable, but it probably is because an earlier version of devcert locked it. Trying to fix...');
            yield certificate_authority_1.ensureCACertReadable(options);
        }
        if (!fs_1.existsSync(constants_1.pathForDomain(domainPath, `certificate.crt`))) {
            debug(`Can't find certificate file for ${domains}, so it must be the first request for ${domains}. Generating and caching ...`);
            yield certificates_1.default(domains);
        }
        if (!options.skipHostsFile) {
            domains.forEach((domain) => tslib_1.__awaiter(this, void 0, void 0, function* () {
                yield platforms_1.default.addDomainToHostFileIfMissing(domain);
            }));
        }
        debug(`Returning domain certificate`);
        const ret = {
            key: fs_1.readFileSync(domainKeyPath),
            cert: fs_1.readFileSync(domainCertPath)
        };
        if (options.getCaBuffer)
            ret.ca = fs_1.readFileSync(constants_1.rootCACertPath);
        if (options.getCaPath)
            ret.caPath = constants_1.rootCACertPath;
        return ret;
    });
}
/**
 * Request an SSL certificate for the given app name signed by the devcert root
 * certificate authority. If devcert has previously generated a certificate for
 * that app name on this machine, it will reuse that certificate.
 *
 * If this is the first time devcert is being run on this machine, it will
 * generate and attempt to install a root certificate authority.
 *
 * Returns a promise that resolves with { key, cert }, where `key` and `cert`
 * are Buffers with the contents of the certificate private key and certificate
 * file, respectively
 *
 * If `options.getCaBuffer` is true, return value will include the ca certificate data
 * as { ca: Buffer }
 *
 * If `options.getCaPath` is true, return value will include the ca certificate path
 * as { caPath: string }
 */
Request an SSL certificate for the given app name signed by the devcert root
certificate authority. If devcert has previously generated a certificate for
that app name on this machine, it will reuse that certificate.

If this is the first time devcert is being run on this machine, it will
generate and attempt to install a root certificate authority.

Returns a promise that resolves with { key, cert }, where `key` and `cert`
are Buffers with the contents of the certificate private key and certificate
file, respectively

If `options.getCaBuffer` is true, return value will include the ca certificate data
as { ca: Buffer }

If `options.getCaPath` is true, return value will include the ca certificate path
as { caPath: string }
Request an SSL certificate for the given app name signed by the devcert root certificate authority . If devcert has previously generated a certificate for that app name on this machine it will reuse that certificate . If this is the first time devcert is being run on this machine it will generate and attempt to install a root certificate authority . Returns a promise that resolves with { key cert } where ` key ` and ` cert ` are Buffers with the contents of the certificate private key and certificate file respectively If ` options . getCaBuffer ` is true return value will include the ca certificate data as { ca : Buffer } If ` options . getCaPath ` is true return value will include the ca certificate path as { caPath : string }
function certificateFor(requestedDomains, options = {}) {
    return tslib_1.__awaiter(this, void 0, void 0, function* () {
        const domains = Array.isArray(requestedDomains) ? requestedDomains : [requestedDomains];
        if (domains.some((d) => constants_1.VALID_IP.test(d))) {
            throw new Error('IP addresses are not supported currently');
        }
        domains.forEach((domain) => {
            if (!constants_1.VALID_DOMAIN.test(domain)) {
                throw new Error(`"${domain}" is not a valid domain name.`);
            }
        });
        const domainPath = constants_1.getStableDomainPath(domains);
        debug(`Certificate requested for ${domains}. Skipping certutil install: ${Boolean(options.skipCertutilInstall)}. Skipping hosts file: ${Boolean(options.skipHostsFile)}`);
        if (options.ui) {
            Object.assign(user_interface_1.default, options.ui);
        }
        if (!constants_1.isMac && !constants_1.isLinux && !constants_1.isWindows) {
            throw new Error(`Platform not supported: "${process.platform}"`);
        }
        if (!command_exists_1.sync('openssl')) {
            throw new Error('OpenSSL not found: OpenSSL is required to generate SSL certificates - make sure it is installed and available in your PATH');
        }
        let domainKeyPath = constants_1.pathForDomain(domainPath, `private-key.key`);
        let domainCertPath = constants_1.pathForDomain(domainPath, `certificate.crt`);
        if (!fs_1.existsSync(constants_1.rootCAKeyPath)) {
            debug('Root CA is not installed yet, so it must be our first run. Installing root CA ...');
            yield certificate_authority_1.default(options);
        }
        else if (options.getCaBuffer || options.getCaPath) {
            debug('Root CA is not readable, but it probably is because an earlier version of devcert locked it. Trying to fix...');
            yield certificate_authority_1.ensureCACertReadable(options);
        }
        if (!fs_1.existsSync(constants_1.pathForDomain(domainPath, `certificate.crt`))) {
            debug(`Can't find certificate file for ${domains}, so it must be the first request for ${domains}. Generating and caching ...`);
            yield certificates_1.default(domains);
        }
        if (!options.skipHostsFile) {
            domains.forEach((domain) => tslib_1.__awaiter(this, void 0, void 0, function* () {
                yield platforms_1.default.addDomainToHostFileIfMissing(domain);
            }));
        }
        debug(`Returning domain certificate`);
        const ret = {
            key: fs_1.readFileSync(domainKeyPath),
            cert: fs_1.readFileSync(domainCertPath)
        };
        if (options.getCaBuffer)
            ret.ca = fs_1.readFileSync(constants_1.rootCACertPath);
        if (options.getCaPath)
            ret.caPath = constants_1.rootCACertPath;
        return ret;
    });
}
function certificateFor ( requestedDomains , options = { } ) { return tslib_1 . __awaiter ( this , void 0 , void 0 , function * ( ) { const domains = Array . isArray ( requestedDomains ) ? requestedDomains : [ requestedDomains ] ; if ( domains . some ( ( d ) => constants_1 . VALID_IP . test ( d ) ) ) { throw new Error ( 'IP addresses are not supported currently' ) ; } domains . forEach ( ( domain ) => { if ( ! constants_1 . VALID_DOMAIN . test ( domain ) ) { throw new Error ( ` ${ domain } ` ) ; } } ) ; const domainPath = constants_1 . getStableDomainPath ( domains ) ; debug ( ` ${ domains } ${ Boolean ( options . skipCertutilInstall ) } ${ Boolean ( options . skipHostsFile ) } ` ) ; if ( options . ui ) { Object . assign ( user_interface_1 . default , options . ui ) ; } if ( ! constants_1 . isMac && ! constants_1 . isLinux && ! constants_1 . isWindows ) { throw new Error ( ` ${ process . platform } ` ) ; } if ( ! command_exists_1 . sync ( 'openssl' ) ) { throw new Error ( 'OpenSSL not found: OpenSSL is required to generate SSL certificates - make sure it is installed and available in your PATH' ) ; } let domainKeyPath = constants_1 . pathForDomain ( domainPath , ` ` ) ; let domainCertPath = constants_1 . pathForDomain ( domainPath , ` ` ) ; if ( ! fs_1 . existsSync ( constants_1 . rootCAKeyPath ) ) { debug ( 'Root CA is not installed yet, so it must be our first run. Installing root CA ...' ) ; yield certificate_authority_1 . default ( options ) ; } else if ( options . getCaBuffer || options . getCaPath ) { debug ( 'Root CA is not readable, but it probably is because an earlier version of devcert locked it. Trying to fix...' ) ; yield certificate_authority_1 . ensureCACertReadable ( options ) ; } if ( ! fs_1 . existsSync ( constants_1 . pathForDomain ( domainPath , ` ` ) ) ) { debug ( ` ${ domains } ${ domains } ` ) ; yield certificates_1 . default ( domains ) ; } if ( ! options . skipHostsFile ) { domains . forEach ( ( domain ) => tslib_1 . __awaiter ( this , void 0 , void 0 , function * ( ) { yield platforms_1 . default . addDomainToHostFileIfMissing ( domain ) ; } ) ) ; } debug ( ` ` ) ; const ret = { key : fs_1 . readFileSync ( domainKeyPath ) , cert : fs_1 . readFileSync ( domainCertPath ) } ; if ( options . getCaBuffer ) ret . ca = fs_1 . readFileSync ( constants_1 . rootCACertPath ) ; if ( options . getCaPath ) ret . caPath = constants_1 . rootCACertPath ; return ret ; } ) ; }
Request an SSL certificate for the given app name signed by the devcert root
 certificate authority.
Request an SSL certificate for the given app name signed by the devcert root certificate authority .