Compare commits

...

3 Commits

Author SHA1 Message Date
32ee3e18e2 chore: release version v0.2.1 2019-12-27 21:46:43 -07:00
557f6cab66 chore: update contributors 2019-12-27 21:46:43 -07:00
d98bb23fea feat: add crypto transmission error (#17)
* feat: add crypto transmission error

* docs: add error to crypto readme
2019-12-27 19:51:10 -08:00
4 changed files with 26 additions and 2 deletions

View File

@ -1,3 +1,13 @@
<a name="0.2.1"></a>
## [0.2.1](https://github.com/libp2p/js-interfaces/compare/v0.2.0...v0.2.1) (2019-12-28)
### Features
* add crypto transmission error ([#17](https://github.com/libp2p/js-interfaces/issues/17)) ([d98bb23](https://github.com/libp2p/js-interfaces/commit/d98bb23))
<a name="0.2.0"></a>
# [0.2.0](https://github.com/libp2p/js-interfaces/compare/v0.1.7...v0.2.0) (2019-12-20)

View File

@ -1,6 +1,6 @@
{
"name": "libp2p-interfaces",
"version": "0.2.0",
"version": "0.2.1",
"description": "Interfaces for JS Libp2p",
"leadMaintainer": "Jacob Heun <jacobheun@gmail.com>",
"main": "src/index.js",

View File

@ -85,6 +85,7 @@ Common crypto errors come with the interface, and can be imported directly. All
```js
const {
InvalidCryptoExchangeError,
InvalidCryptoTransmissionError,
UnexpectedPeerError
} = require('libp2p-interfaces/src/crypto/errors')
@ -95,4 +96,5 @@ console.log(error.code === UnexpectedPeerError.code) // true
### Error Types
- `InvalidCryptoExchangeError` - Should be thrown when a peer provides data that is insufficient to finish the crypto exchange.
- `InvalidCryptoTransmissionError` - Should be thrown when an error occurs during encryption/decryption.
- `UnexpectedPeerError` - Should be thrown when the expected peer id does not match the peer id determined via the crypto exchange.

View File

@ -22,7 +22,19 @@ class InvalidCryptoExchangeError extends Error {
}
}
class InvalidCryptoTransmissionError extends Error {
constructor (message = 'Invalid crypto transmission') {
super(message)
this.code = InvalidCryptoTransmissionError.code
}
static get code () {
return 'ERR_INVALID_CRYPTO_TRANSMISSION'
}
}
module.exports = {
UnexpectedPeerError,
InvalidCryptoExchangeError
InvalidCryptoExchangeError,
InvalidCryptoTransmissionError
}