Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const topic = `${namespace}${base64url.encode(keys.routingKey.toBuffer())}`
await nodeB.pubsub.subscribe(topic, checkMessage)
await nodeA.name.publish(ipfsRef, { resolve: false, key: testAccountName })
await waitFor(alreadySubscribed)
const messageKey = await promisify(peerId.createFromPubKey)(publishedMessage.key)
const pubKeyPeerId = await promisify(peerId.createFromPubKey)(publishedMessageData.pubKey)
expect(pubKeyPeerId.toB58String()).not.to.equal(messageKey.toB58String())
expect(pubKeyPeerId.toB58String()).to.equal(testAccount.id)
expect(publishedMessage.from).to.equal(idA.id)
expect(messageKey.toB58String()).to.equal(idA.id)
expect(publishedMessageDataValue).to.equal(ipfsRef)
// Verify the signature
await ipns.validate(pubKeyPeerId._pubKey, publishedMessageData)
})
})
async _validateRecord (peerId, ipnsEntry) {
const pubKey = await ipns.extractPublicKey(peerId, ipnsEntry)
// IPNS entry validation
await ipns.validate(pubKey, ipnsEntry)
return ipnsEntry.value.toString()
}
}
return new Promise((resolve, reject) => {
ipns.validate(publicKey, parsed, (err) => {
if (err != null) {
reject(err)
return
}
let temp = parsed.value.toString().replace(/\/+/gi, "/").replace(/\/$/, "").split("/")
if (temp.length >= 3 && temp[0] == "" && (temp[1] == "ipfs" || temp[1] == "ipns")) {
if (temp[1] == "ipfs") {
temp[2] = this.parse(temp[2])
}
this.segments = join(temp, this.segments.slice(3))
}
resolve()
})
})
}