diff --git a/index.js b/index.js index daee85d..08714c2 100644 --- a/index.js +++ b/index.js @@ -1,7 +1,6 @@ 'use strict' const crypto = require('crypto') -const figgyPudding = require('figgy-pudding') const MiniPass = require('minipass') const SPEC_ALGORITHMS = ['sha256', 'sha384', 'sha512'] @@ -11,17 +10,18 @@ const SRI_REGEX = /^([^-]+)-([^?]+)([?\S*]*)$/ const STRICT_SRI_REGEX = /^([^-]+)-([A-Za-z0-9+/=]{44,88})(\?[\x21-\x7E]*)*$/ const VCHAR_REGEX = /^[\x21-\x7E]+$/ -const SsriOpts = figgyPudding({ - algorithms: { default: ['sha512'] }, - error: { default: false }, - integrity: {}, - options: { default: [] }, - pickAlgorithm: { default: () => getPrioritizedHash }, - sep: { default: ' ' }, - single: { default: false }, - size: {}, - strict: { default: false } -}) +const SsriOpts = (opts = {}) => { + const defaults = { + algorithms: ['sha512'], + error: false, + options: [], + pickAlgorithm: getPrioritizedHash, + sep: ' ', + single: false, + strict: false + } + return Object.assign(opts, { ...defaults, ...opts }) +} const getOptString = options => !options || !options.length ? '' : `?${options.join('?')}` @@ -380,9 +380,10 @@ function checkData (data, sri, opts) { module.exports.checkStream = checkStream function checkStream (stream, sri, opts) { opts = SsriOpts(opts) - const checker = integrityStream(opts.concat({ + const checker = integrityStream({ + ...opts, integrity: sri - })) + }) return new Promise((resolve, reject) => { stream.pipe(checker) stream.on('error', reject) diff --git a/package-lock.json b/package-lock.json index fc0b792..f0bae8f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1757,11 +1757,6 @@ "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=", "dev": true }, - "figgy-pudding": { - "version": "3.5.1", - "resolved": "https://registry.npmjs.org/figgy-pudding/-/figgy-pudding-3.5.1.tgz", - "integrity": "sha512-vNKxJHTEKNThjfrdJwHc7brvM6eVevuO5nTj6ez8ZQ1qbXTvGthucRF7S4vf2cr71QVnT70V34v0S1DyQsti0w==" - }, "figures": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/figures/-/figures-3.0.0.tgz", diff --git a/package.json b/package.json index df1e7df..4e2c307 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,6 @@ }, "license": "ISC", "dependencies": { - "figgy-pudding": "^3.5.1", "minipass": "^3.1.1" }, "devDependencies": {