mirror of
https://github.com/fluencelabs/js-peer-id
synced 2025-04-24 18:52:34 +00:00
fix: remove use of assert module (#117)
The polyfill is big, we can simulate it by throwing an Error and it doesn't work under React Native.
This commit is contained in:
parent
a68855a5d2
commit
f44645ef7e
@ -7,16 +7,17 @@
|
||||
const mh = require('multihashes')
|
||||
const CID = require('cids')
|
||||
const cryptoKeys = require('libp2p-crypto/src/keys')
|
||||
const assert = require('assert')
|
||||
const withIs = require('class-is')
|
||||
const { PeerIdProto } = require('./proto')
|
||||
|
||||
class PeerId {
|
||||
constructor (id, privKey, pubKey) {
|
||||
assert(Buffer.isBuffer(id), 'invalid id provided')
|
||||
if (!Buffer.isBuffer(id)) {
|
||||
throw new Error('invalid id provided')
|
||||
}
|
||||
|
||||
if (privKey && pubKey) {
|
||||
assert(privKey.public.bytes.equals(pubKey.bytes), 'inconsistent arguments')
|
||||
if (privKey && pubKey && !privKey.public.bytes.equals(pubKey.bytes)) {
|
||||
throw new Error('inconsistent arguments')
|
||||
}
|
||||
|
||||
this._id = id
|
||||
|
Loading…
x
Reference in New Issue
Block a user