mirror of
https://github.com/fluencelabs/js-peer-id
synced 2025-04-25 08:22:33 +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 mh = require('multihashes')
|
||||||
const CID = require('cids')
|
const CID = require('cids')
|
||||||
const cryptoKeys = require('libp2p-crypto/src/keys')
|
const cryptoKeys = require('libp2p-crypto/src/keys')
|
||||||
const assert = require('assert')
|
|
||||||
const withIs = require('class-is')
|
const withIs = require('class-is')
|
||||||
const { PeerIdProto } = require('./proto')
|
const { PeerIdProto } = require('./proto')
|
||||||
|
|
||||||
class PeerId {
|
class PeerId {
|
||||||
constructor (id, privKey, pubKey) {
|
constructor (id, privKey, pubKey) {
|
||||||
assert(Buffer.isBuffer(id), 'invalid id provided')
|
if (!Buffer.isBuffer(id)) {
|
||||||
|
throw new Error('invalid id provided')
|
||||||
|
}
|
||||||
|
|
||||||
if (privKey && pubKey) {
|
if (privKey && pubKey && !privKey.public.bytes.equals(pubKey.bytes)) {
|
||||||
assert(privKey.public.bytes.equals(pubKey.bytes), 'inconsistent arguments')
|
throw new Error('inconsistent arguments')
|
||||||
}
|
}
|
||||||
|
|
||||||
this._id = id
|
this._id = id
|
||||||
|
Loading…
x
Reference in New Issue
Block a user