You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Pacote has a use case where the integrity value may not be known at the
outset, but is later established, either via the dist.integrity in a
packument, or by the x-local-hash header value when make-fetch-happen
loads a response from the cache.
In these cases, we have already started an integrity stream at the
beginning of the request, and don't get the expected integrity until
_after_ the integrity stream is created, resulting in a spurious
EINTEGRITY error.
This patch makes ssri responsive to (and resilient against) updates to
the integrity and size options after the stream has started.
consterr=newError(`stream size mismatch when checking ${this.sri}.\n Wanted: ${this.expectedSize}\n Found: ${this.size}`)
66
80
err.code='EBADSIZE'
67
81
err.found=this.size
68
-
err.expected=this.opts.size
82
+
err.expected=this.expectedSize
69
83
err.sri=this.sri
70
84
this.emit('error',err)
71
-
}elseif(this.opts.integrity&&!match){
85
+
}elseif(this.sri&&!match){
72
86
consterr=newError(`${this.sri} integrity checksum failed when using ${this.algorithm}: wanted ${this.digests} but got ${newSri}. (${this.size} bytes)`)
73
87
err.code='EINTEGRITY'
74
88
err.found=newSri
@@ -260,9 +274,7 @@ function stringify (obj, opts) {
0 commit comments