Skip to content

Commit

Permalink
feat: remove figgy-pudding
Browse files Browse the repository at this point in the history
  • Loading branch information
claudiahdz committed Feb 14, 2020
1 parent 79ba4ec commit 079a464
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 20 deletions.
29 changes: 15 additions & 14 deletions index.js
Original file line number Diff line number Diff line change
@@ -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']
Expand All @@ -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('?')}`
Expand Down Expand Up @@ -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)
Expand Down
5 changes: 0 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
},
"license": "ISC",
"dependencies": {
"figgy-pudding": "^3.5.1",
"minipass": "^3.1.1"
},
"devDependencies": {
Expand Down

0 comments on commit 079a464

Please sign in to comment.