Skip to content
This repository has been archived by the owner on Feb 24, 2021. It is now read-only.

fix: remove use of assert module #114

Merged
merged 1 commit into from
Feb 13, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use strict'

const assert = require('assert')
const debug = require('debug')
const log = debug('libp2p:secio')
log.error = debug('libp2p:secio:error')
Expand All @@ -11,8 +10,12 @@ const Wrap = require('it-pb-rpc')
const { int32BEDecode, int32BEEncode } = require('it-length-prefixed')

async function secure (localPeer, duplex, remotePeer) { // returns duplex
assert(localPeer, 'no local private key provided')
assert(duplex, 'no connection for the handshake provided')
if (!localPeer) {
throw new Error('no local private key provided')
}
if (!duplex) {
throw new Error('no connection for the handshake provided')
}

const state = new State(localPeer, remotePeer)
const wrapped = Wrap(duplex, { lengthDecoder: int32BEDecode, lengthEncoder: int32BEEncode })
Expand Down