mirror of
https://github.com/fluencelabs/js-libp2p-interfaces
synced 2025-04-25 12:52:35 +00:00
feat: crypto errors (#4)
* chore: ignore docs folder * feat: add invalid crypto exchange error
This commit is contained in:
parent
bcb52ae709
commit
d2fe2d1b36
1
.gitignore
vendored
1
.gitignore
vendored
@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
build
|
build
|
||||||
dist
|
dist
|
||||||
|
docs
|
||||||
|
|
||||||
# Dependency directory
|
# Dependency directory
|
||||||
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
|
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
|
||||||
|
@ -84,6 +84,7 @@ Common crypto errors come with the interface, and can be imported directly. All
|
|||||||
|
|
||||||
```js
|
```js
|
||||||
const {
|
const {
|
||||||
|
InvalidCryptoExchangeError,
|
||||||
UnexpectedPeerError
|
UnexpectedPeerError
|
||||||
} = require('libp2p-interfaces/src/crypto/errors')
|
} = require('libp2p-interfaces/src/crypto/errors')
|
||||||
|
|
||||||
@ -93,4 +94,5 @@ console.log(error.code === UnexpectedPeerError.code) // true
|
|||||||
|
|
||||||
### Error Types
|
### Error Types
|
||||||
|
|
||||||
- `UnexpectedPeerError` - Should be thrown when the expected peer id does not match the peer id determined via the crypto exchange
|
- `InvalidCryptoExchangeError` - Should be thrown when a peer provides data that is insufficient to finish the crypto exchange.
|
||||||
|
- `UnexpectedPeerError` - Should be thrown when the expected peer id does not match the peer id determined via the crypto exchange.
|
||||||
|
@ -11,6 +11,18 @@ class UnexpectedPeerError extends Error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
class InvalidCryptoExchangeError extends Error {
|
||||||
UnexpectedPeerError
|
constructor (message = 'Invalid crypto exchange') {
|
||||||
|
super(message)
|
||||||
|
this.code = InvalidCryptoExchangeError.code
|
||||||
|
}
|
||||||
|
|
||||||
|
static get code () {
|
||||||
|
return 'ERR_INVALID_CRYPTO_EXCHANGE'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
UnexpectedPeerError,
|
||||||
|
InvalidCryptoExchangeError
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user