mirror of
https://github.com/fluencelabs/js-libp2p
synced 2025-06-20 12:36:31 +00:00
fix: remove use of assert module (#561)
* fix: remove use of assert module The polyfill is big, we can simulate it by throwing an Error and it doesn't work under React Native. * chore: fix linting * chore: export invalid param code Co-authored-by: Jacob Heun <jacobheun@gmail.com>
This commit is contained in:
@ -1,10 +1,13 @@
|
||||
'use strict'
|
||||
|
||||
const pipe = require('it-pipe')
|
||||
const assert = require('assert')
|
||||
const errcode = require('err-code')
|
||||
const duplexPair = require('it-pair/duplex')
|
||||
const crypto = require('libp2p-crypto')
|
||||
const Errors = require('./errors')
|
||||
const {
|
||||
ERR_INVALID_PARAMETERS
|
||||
} = require('../errors')
|
||||
const {
|
||||
createBoxStream,
|
||||
createUnboxStream,
|
||||
@ -40,7 +43,9 @@ class Protector {
|
||||
* @returns {*} A protected duplex iterable
|
||||
*/
|
||||
async protect (connection) {
|
||||
assert(connection, Errors.NO_HANDSHAKE_CONNECTION)
|
||||
if (!connection) {
|
||||
throw errcode(new Error(Errors.NO_HANDSHAKE_CONNECTION), ERR_INVALID_PARAMETERS)
|
||||
}
|
||||
|
||||
// Exchange nonces
|
||||
log('protecting the connection')
|
||||
|
Reference in New Issue
Block a user