lib/registry-client-v2.js
function digestFromManifestStr(manifestStr) {
    assert.string(manifestStr, 'manifestStr');

    var hash = crypto.createHash('sha256');
    var digestPrefix = 'sha256:';

    var manifest;
    try {
        manifest = JSON.parse(manifestStr);
    } catch (err) {
        throw new restifyErrors.InvalidContentError(err, fmt(
            'could not parse manifest: %s', manifestStr));
    }
    if (manifest.schemaVersion === 1) {
        try {
            var manifestBuffer = Buffer(manifestStr);
            var jws = _jwsFromManifest(manifest, manifestBuffer);
            hash.update(jws.payload, 'binary');
            return digestPrefix + hash.digest('hex');
        } catch (verifyErr) {
            if (!(verifyErr instanceof restifyErrors.InvalidContentError)) {
                throw verifyErr;
            }
            // Couldn't parse (or doesn't have) the signatures section,
            // fall through.
        }
    }
    hash.update(manifestStr);
    return digestPrefix + hash.digest('hex');
}
function digestFromManifestStr(manifestStr) {
    assert.string(manifestStr, 'manifestStr');

    var hash = crypto.createHash('sha256');
    var digestPrefix = 'sha256:';

    var manifest;
    try {
        manifest = JSON.parse(manifestStr);
    } catch (err) {
        throw new restifyErrors.InvalidContentError(err, fmt(
            'could not parse manifest: %s', manifestStr));
    }
    if (manifest.schemaVersion === 1) {
        try {
            var manifestBuffer = Buffer(manifestStr);
            var jws = _jwsFromManifest(manifest, manifestBuffer);
            hash.update(jws.payload, 'binary');
            return digestPrefix + hash.digest('hex');
        } catch (verifyErr) {
            if (!(verifyErr instanceof restifyErrors.InvalidContentError)) {
                throw verifyErr;
            }
            // Couldn't parse (or doesn't have) the signatures section,
            // fall through.
        }
    }
    hash.update(manifestStr);
    return digestPrefix + hash.digest('hex');
}
function digestFromManifestStr ( manifestStr ) { assert . string ( manifestStr , 'manifestStr' ) ; var hash = crypto . createHash ( 'sha256' ) ; var digestPrefix = 'sha256:' ; var manifest ; try { manifest = JSON . parse ( manifestStr ) ; } catch ( err ) { throw new restifyErrors . InvalidContentError ( err , fmt ( 'could not parse manifest: %s' , manifestStr ) ) ; } if ( manifest . schemaVersion === 1 ) { try { var manifestBuffer = Buffer ( manifestStr ) ; var jws = _jwsFromManifest ( manifest , manifestBuffer ) ; hash . update ( jws . payload , 'binary' ) ; return digestPrefix + hash . digest ( 'hex' ) ; } catch ( verifyErr ) { if ( ! ( verifyErr instanceof restifyErrors . InvalidContentError ) ) { throw verifyErr ; } // Couldn't parse (or doesn't have) the signatures section, // fall through. } } hash . update ( manifestStr ) ; return digestPrefix + hash . digest ( 'hex' ) ; }
Calculate the 'Docker-Content-Digest' header for the given manifest.

@returns {String} The docker digest string.
@throws {InvalidContentError} if there is a problem parsing the manifest.
Calculate the Docker - Content - Digest header for the given manifest .