diff options
author | Kat Marchán <kzm@sykosomatic.org> | 2017-05-28 21:04:08 -0700 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2017-05-29 18:06:04 +0200 |
commit | c58cea5a163cd5d7133e00fdf257325ce3807c09 (patch) | |
tree | 1b7f97c0474f1990450a54e82b4432ec37de1956 /deps/npm/node_modules/ssri/index.js | |
parent | 88fe7e84e56e44a727169c07ee040cbf67f9c0a8 (diff) | |
download | android-node-v8-c58cea5a163cd5d7133e00fdf257325ce3807c09.tar.gz android-node-v8-c58cea5a163cd5d7133e00fdf257325ce3807c09.tar.bz2 android-node-v8-c58cea5a163cd5d7133e00fdf257325ce3807c09.zip |
deps: upgrade npm to 5.0.0
PR-URL: https://github.com/nodejs/node/pull/13276
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Diffstat (limited to 'deps/npm/node_modules/ssri/index.js')
-rw-r--r-- | deps/npm/node_modules/ssri/index.js | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/deps/npm/node_modules/ssri/index.js b/deps/npm/node_modules/ssri/index.js index 9c84dbc217..f01986fa51 100644 --- a/deps/npm/node_modules/ssri/index.js +++ b/deps/npm/node_modules/ssri/index.js @@ -95,7 +95,9 @@ class Integrity { const pickAlgorithm = (opts && opts.pickAlgorithm) || getPrioritizedHash const keys = Object.keys(this) if (!keys.length) { - throw new Error(`No algorithms available for ${this}`) + throw new Error(`No algorithms available for ${ + JSON.stringify(this.toString()) + }`) } return keys.reduce((acc, algo) => { return pickAlgorithm(acc, algo) || acc @@ -199,8 +201,9 @@ module.exports.checkData = checkData function checkData (data, sri, opts) { opts = opts || {} sri = parse(sri, opts) + if (!Object.keys(sri).length) { return false } const algorithm = sri.pickAlgorithm(opts) - const digests = sri[algorithm] + const digests = sri[algorithm] || [] const digest = crypto.createHash(algorithm).update(data).digest('base64') return digests.find(hash => hash.digest === digest) || false } @@ -231,8 +234,9 @@ function integrityStream (opts) { opts = opts || {} // For verification const sri = opts.integrity && parse(opts.integrity, opts) - const algorithm = sri && sri.pickAlgorithm(opts) - const digests = sri && sri[algorithm] + const goodSri = sri && Object.keys(sri).length + const algorithm = goodSri && sri.pickAlgorithm(opts) + const digests = goodSri && sri[algorithm] // Calculating stream const algorithms = opts.algorithms || [algorithm || 'sha512'] const hashes = algorithms.map(crypto.createHash) @@ -253,6 +257,7 @@ function integrityStream (opts) { const match = ( // Integrity verification mode opts.integrity && + digests && digests.find(hash => { return newSri[algorithm].find(newhash => { return hash.digest === newhash.digest |