Skip to content

Commit

Permalink
fix(integrity): should have changed the error code before. oops
Browse files Browse the repository at this point in the history
BREAKING CHANGE: EBADCHECKSUM -> EINTEGRITY for verification errors
  • Loading branch information
zkat committed Apr 3, 2017
1 parent 74fd52c commit 8381afa
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ representation that [`ssri.parse`](#parse) can handle.
or an error happens with `stream`, the Promise will be rejected.

If the Promise is rejected because verification failed, the returned error will
have `err.code` as `EBADCHECKSUM`.
have `err.code` as `EINTEGRITY`.

If `opts.size` is given, it will be matched against the stream size. An error
with `err.code` `EBADSIZE` will be returned by a rejection if the expected size
Expand Down Expand Up @@ -378,7 +378,7 @@ ssri.checkStream(
ssri.checkStream(
fs.createReadStream('index.js'),
'sha1-BaDDigEST'
) // -> Promise<Error<{code: 'EBADCHECKSUM'}>>
) // -> Promise<Error<{code: 'EINTEGRITY'}>>
```

#### <a name="integrity-stream"></a> `> integrityStream(sri, [opts]) -> IntegrityStream`
Expand All @@ -398,7 +398,7 @@ If `opts.integrity` is passed in, it should be an `integrity` value understood
by [`parse`](#parse) that the stream will check the data against. If
verification succeeds, the integrity stream will emit a `verified` event whose
value is a single `Hash` object that is the one that succeeded verification. If
verification fails, the stream will error with an `EBADCHECKSUM` error code.
verification fails, the stream will error with an `EINTEGRITY` error code.

If `opts.size` is given, it will be matched against the stream size. An error
with `err.code` `EBADSIZE` will be emitted by the stream if the expected size
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ function integrityStream (opts) {
stream.emit('error', err)
} else if (opts.integrity && !match) {
const err = new Error(`${sri} integrity checksum failed when using ${algorithm}`)
err.code = 'EBADCHECKSUM'
err.code = 'EINTEGRITY'
err.found = newSri
err.expected = digests
err.algorithm = algorithm
Expand Down
2 changes: 1 addition & 1 deletion test/check.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ test('checkStream', t => {
).then(() => {
throw new Error('unexpected success')
}, err => {
t.equal(err.code, 'EBADCHECKSUM', 'checksum failure rejects the promise')
t.equal(err.code, 'EINTEGRITY', 'checksum failure rejects the promise')
})
}).then(() => {
return ssri.checkStream(fileStream(), [
Expand Down

0 comments on commit 8381afa

Please sign in to comment.