Cloud Defense Logo

Products

Solutions

Company

Book A Live Demo

Top 6 Examples of "devcert in functional component" in JavaScript

Dive into secure and efficient coding practices with our curated list of the top 10 examples showcasing 'devcert' in functional components in JavaScript. Our advanced machine learning engine meticulously scans each line of code, cross-referencing millions of open source libraries to ensure your implementation is not just functional, but also robust and secure. Elevate your React applications to new heights by mastering the art of handling side effects, API calls, and asynchronous operations with confidence and precision.

.then(() => {
            if (dev || process.env.LOCAL_ENV) {
                // Always support localhost as it is what people expect
                server.listen(port, (err) => {
                    if (err) throw err;
                    // eslint-disable-next-line
                    console.log(`> Ready on http://localhost:${port}`);
                });

                // This will do a one time certificate password request the first time you start.
                // It will also attempt to add your certificateFor domain to hosts.  If you
                // get access errors, add "www.myweb.com 127.0.0.1" to hosts file manually.
                // devcert.certificateFor("www.myweb.com", {installCertutil: true}).then((ssl) => {
                devcert.certificateFor("www.myweb.com", {installCertutil: true}).then((ssl) => {
                    https.createServer(ssl, server).listen(devSslPort, (err) => {
                        if (err) throw err;
                        // eslint-disable-next-line
                        console.log(`> Ready on https://www.myweb.com:${devSslPort}`);
                    });
                });
            } else {
                server.listen(port, (err) => {
                    if (err) throw err;
                    // eslint-disable-next-line
                    console.log(`> Ready on http://localhost:${port}`);
                });
            }
        });
}
export async function getCertificates({key, cert, production, host, https}: IGetCertificateOptions): Promise<{key: Buffer | undefined; cert: Buffer | undefined}> {
	// If a key and certificate was already given, use those two
	if (key != null && cert != null) return {key, cert};

	// Otherwise, if not in production, use devcert to generate a new certificate
	if (!production && https) {
		return await certificateFor(host);
	}

	// Return nothing
	return {key: undefined, cert: undefined};
}
const os = require('os');
const chalk = require('chalk');
const execa = require('execa');
const pkgDir = require('pkg-dir');
const { username } = os.userInfo();

/**
 * Monkeypatch devcert to fix
 * https://github.com/magento/pwa-studio/issues/679 which is blocked by
 * https://github.com/davewasmer/devcert/pull/30.
 * TODO: Remove this when a release of devcert without this bug is available
 */
const devCertUtils = require('devcert/dist/utils');
const MacOSPlatform = require('devcert/dist/platforms/darwin');
/* istanbul ignore next: temporary until we switch to devcert fork */
const proto = (MacOSPlatform.default || MacOSPlatform).prototype;
/* istanbul ignore next: temporary until we switch to devcert fork */
proto.isNSSInstalled = function() {
    try {
        return devCertUtils
            .run('brew list -1')
            .toString()
            .includes('\nnss\n');
    } catch (e) {
        return false;
    }
};

const DEFAULT_NAME = 'my-pwa';
const DEV_DOMAIN = 'local.pwadev';

const isSudoSession = () =>
debug('appears to be a sudo session already');
                    }
                } else {
                    debug(
                        'non-interactive! cleared UI timeout for getCert("%s")',
                        hostname
                    );
                    clearTimeout(timeout);
                    return reject(
                        new Error(
                            'Creating a local development domain requires an interactive terminal for the user to answer prompts. Run the development server (e.g. `yarn run watch:venia`) by itself in the terminal to continue.'
                        )
                    );
                }
            }
            const certBuffers = await devcert.certificateFor(hostname);
            debug('certBuffers arrived with %s', Object.keys(certBuffers));
            debug('success! cleared UI timeout for getCert("%s")', hostname);
            clearTimeout(timeout);
            resolve({
                key: certBuffers.key.toString('utf8'),
                cert: certBuffers.cert.toString('utf8')
            });
        } catch (e) {
            clearTimeout(timeout);
            debug(
                'failure! cleared UI timeout for getCert("%s"): %o',
                hostname,
                e
            );
            reject(e);
        }
const alreadyProvisioned = hostname => {
    const configuredDomains = devcert.configuredDomains();
    debug(
        'checking for %s in devcert.configuredDomains() === %o',
        hostname,
        configuredDomains
    );
    const isProvisioned = configuredDomains.includes(hostname);
    debug('isProvisioned? %s', isProvisioned);
    return isProvisioned;
};
proto.isNSSInstalled = function() {
    try {
        return devCertUtils
            .run('brew list -1')
            .toString()
            .includes('\nnss\n');
    } catch (e) {
        return false;
    }
};

Is your System Free of Underlying Vulnerabilities?
Find Out Now