How to use registry-auth-token - 1 common examples

To help you get started, we’ve selected a few registry-auth-token examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cncjs / cncjs / src / server / api / api.version.js View on Github external
export const getLatestVersion = (req, res) => {
    const scope = pkgName.split('/')[0];
    const regUrl = registryUrl(scope);
    const pkgUrl = url.resolve(regUrl, encodeURIComponent(pkgName).replace(/^%40/, '@'));
    const authInfo = registryAuthToken(regUrl);
    const headers = {};

    if (authInfo) {
        headers.Authorization = `${authInfo.type} ${authInfo.token}`;
    }

    request
        .get(pkgUrl)
        .set(headers)
        .end((err, _res) => {
            if (err) {
                res.status(ERR_INTERNAL_SERVER_ERROR).send({
                    msg: `Failed to connect to ${pkgUrl}: code=${err.code}`
                });
                return;
            }

registry-auth-token

Get the auth token set for an npm registry (if any)

MIT
Latest version published 2 years ago

Package Health Score

71 / 100
Full package analysis

Popular registry-auth-token functions