Comparing version 4.1.2 to 4.1.3
@@ -5,2 +5,12 @@ # Change Log | ||
<a name="4.1.3"></a> | ||
## [4.1.3](https://github.com/zkat/ssri/compare/v4.1.2...v4.1.3) (2017-05-24) | ||
### Bug Fixes | ||
* **check:** handle various bad hash corner cases better ([c2c262b](https://github.com/zkat/ssri/commit/c2c262b)) | ||
<a name="4.1.2"></a> | ||
@@ -7,0 +17,0 @@ ## [4.1.2](https://github.com/zkat/ssri/compare/v4.1.1...v4.1.2) (2017-04-18) |
13
index.js
@@ -98,3 +98,5 @@ 'use strict' | ||
if (!keys.length) { | ||
throw new Error(`No algorithms available for ${this}`) | ||
throw new Error(`No algorithms available for ${ | ||
JSON.stringify(this.toString()) | ||
}`) | ||
} | ||
@@ -203,4 +205,5 @@ return keys.reduce((acc, algo) => { | ||
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') | ||
@@ -236,4 +239,5 @@ return digests.find(hash => hash.digest === digest) || false | ||
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 | ||
@@ -259,2 +263,3 @@ const algorithms = opts.algorithms || [algorithm || 'sha512'] | ||
opts.integrity && | ||
digests && | ||
digests.find(hash => { | ||
@@ -261,0 +266,0 @@ return newSri[algorithm].find(newhash => { |
{ | ||
"name": "ssri", | ||
"version": "4.1.2", | ||
"version": "4.1.3", | ||
"description": "Standard Subresource Integrity library -- parses, serializes, generates, and verifies integrity metadata according to the SRI spec.", | ||
@@ -41,7 +41,7 @@ "main": "index.js", | ||
"devDependencies": { | ||
"nyc": "^10.2.0", | ||
"nyc": "^10.3.2", | ||
"standard": "^9.0.2", | ||
"standard-version": "^4.0.0", | ||
"tap": "^10.3.2", | ||
"weallbehave": "^1.0.0", | ||
"weallbehave": "^1.2.0", | ||
"weallcontribute": "^1.0.8" | ||
@@ -48,0 +48,0 @@ }, |
34987
317