Skip to content
Permalink
Browse files
deps: ssri@9.0.1
* store emitted events and re-emit them for late listeners
  • Loading branch information
wraithgar authored and lukekarrys committed May 19, 2022
1 parent f3b0a24 commit 0df3011ec59ba76c12fb8fbfb29ff4d601cc4bdb
Showing 4 changed files with 37 additions and 12 deletions.
@@ -30,6 +30,10 @@ const getOptString = options => !options || !options.length

const _onEnd = Symbol('_onEnd')
const _getOptions = Symbol('_getOptions')
const _emittedSize = Symbol('_emittedSize')
const _emittedIntegrity = Symbol('_emittedIntegrity')
const _emittedVerified = Symbol('_emittedVerified')

class IntegrityStream extends MiniPass {
constructor (opts) {
super()
@@ -63,6 +67,22 @@ class IntegrityStream extends MiniPass {
this.optString = getOptString(options)
}

on (ev, handler) {
if (ev === 'size' && this[_emittedSize]) {
return handler(this[_emittedSize])
}

if (ev === 'integrity' && this[_emittedIntegrity]) {
return handler(this[_emittedIntegrity])
}

if (ev === 'verified' && this[_emittedVerified]) {
return handler(this[_emittedVerified])
}

return super.on(ev, handler)
}

emit (ev, data) {
if (ev === 'end') {
this[_onEnd]()
@@ -103,9 +123,14 @@ class IntegrityStream extends MiniPass {
err.sri = this.sri
this.emit('error', err)
} else {
this[_emittedSize] = this.size
this.emit('size', this.size)
this[_emittedIntegrity] = newSri
this.emit('integrity', newSri)
match && this.emit('verified', match)
if (match) {
this[_emittedVerified] = match
this.emit('verified', match)
}
}
}
}
@@ -1,6 +1,6 @@
{
"name": "ssri",
"version": "9.0.0",
"version": "9.0.1",
"description": "Standard Subresource Integrity library -- parses, serializes, generates, and verifies integrity metadata according to the SRI spec.",
"main": "lib/index.js",
"files": [
@@ -50,14 +50,14 @@
},
"devDependencies": {
"@npmcli/eslint-config": "^3.0.1",
"@npmcli/template-oss": "3.2.2",
"@npmcli/template-oss": "3.5.0",
"tap": "^16.0.1"
},
"engines": {
"node": "^12.13.0 || ^14.15.0 || >=16.0.0"
},
"templateOSS": {
"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
"version": "3.2.2"
"version": "3.5.0"
}
}
@@ -148,7 +148,7 @@
"readdir-scoped-modules": "^1.1.0",
"rimraf": "^3.0.2",
"semver": "^7.3.7",
"ssri": "^9.0.0",
"ssri": "^9.0.1",
"tar": "^6.1.11",
"text-table": "~0.2.0",
"tiny-relative-date": "^1.3.0",
@@ -6793,9 +6793,9 @@
}
},
"node_modules/ssri": {
"version": "9.0.0",
"resolved": "https://registry.npmjs.org/ssri/-/ssri-9.0.0.tgz",
"integrity": "sha512-Y1Z6J8UYnexKFN1R/hxUaYoY2LVdKEzziPmVAFKiKX8fiwvCJTVzn/xYE9TEWod5OVyNfIHHuVfIEuBClL/uJQ==",
"version": "9.0.1",
"resolved": "https://registry.npmjs.org/ssri/-/ssri-9.0.1.tgz",
"integrity": "sha512-o57Wcn66jMQvfHG1FlYbWeZWW/dHZhJXjpIcTfXldXEk5nz5lStPo3mK0OJQfGR3RbZUlbISexbljkJzuEj/8Q==",
"inBundle": true,
"dependencies": {
"minipass": "^3.1.1"
@@ -14720,9 +14720,9 @@
}
},
"ssri": {
"version": "9.0.0",
"resolved": "https://registry.npmjs.org/ssri/-/ssri-9.0.0.tgz",
"integrity": "sha512-Y1Z6J8UYnexKFN1R/hxUaYoY2LVdKEzziPmVAFKiKX8fiwvCJTVzn/xYE9TEWod5OVyNfIHHuVfIEuBClL/uJQ==",
"version": "9.0.1",
"resolved": "https://registry.npmjs.org/ssri/-/ssri-9.0.1.tgz",
"integrity": "sha512-o57Wcn66jMQvfHG1FlYbWeZWW/dHZhJXjpIcTfXldXEk5nz5lStPo3mK0OJQfGR3RbZUlbISexbljkJzuEj/8Q==",
"requires": {
"minipass": "^3.1.1"
}
@@ -117,7 +117,7 @@
"readdir-scoped-modules": "^1.1.0",
"rimraf": "^3.0.2",
"semver": "^7.3.7",
"ssri": "^9.0.0",
"ssri": "^9.0.1",
"tar": "^6.1.11",
"text-table": "~0.2.0",
"tiny-relative-date": "^1.3.0",

0 comments on commit 0df3011

Please sign in to comment.