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

Commit

Permalink
fix: remove use of assert module (#114)
Browse files Browse the repository at this point in the history
The polyfill is big, we can simulate it by throwing an Error and it doesn't work under React Native.
  • Loading branch information
achingbrain authored Feb 13, 2020
1 parent 74e95e2 commit 027e0ad
Showing 1 changed file with 6 additions and 3 deletions.
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

0 comments on commit 027e0ad

Please sign in to comment.