Created
February 18, 2020 00:15
-
-
Save isaacs/62a2ecabfd2199232db64fb6c56bacb5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/index.js b/index.js | |
index f17d484..c30c2cd 100644 | |
--- a/index.js | |
+++ b/index.js | |
@@ -347,7 +347,7 @@ module.exports.checkData = checkData | |
function checkData (data, sri, opts) { | |
opts = ssriOpts(opts) | |
sri = parse(sri, opts) | |
- if (!Object.keys(sri).length) { | |
+ if (!sri || !Object.keys(sri).length) { | |
if (opts.error) { | |
throw Object.assign( | |
new Error('No valid integrity hashes to check against'), { | |
@@ -385,6 +385,14 @@ function checkData (data, sri, opts) { | |
module.exports.checkStream = checkStream | |
function checkStream (stream, sri, opts) { | |
opts = ssriOpts(opts) | |
+ sri = parse(sri, opts) | |
+ if (!sri || !Object.keys(sri).length) { | |
+ return Promise.reject(Object.assign( | |
+ new Error('No valid integrity hashes to check against'), { | |
+ code: 'EINTEGRITY' | |
+ } | |
+ )) | |
+ } | |
opts.integrity = sri | |
const checker = integrityStream(opts) | |
return new Promise((resolve, reject) => { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment