How to use the ipns.validate function in ipns

To help you get started, we’ve selected a few ipns examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ipfs / js-ipfs / test / core / name-pubsub.js View on Github external
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)
  })
})
github ipfs / js-ipfs / src / core / ipns / resolver.js View on Github external
async _validateRecord (peerId, ipnsEntry) {
    const pubKey = await ipns.extractPublicKey(peerId, ipnsEntry)

    // IPNS entry validation
    await ipns.validate(pubKey, ipnsEntry)

    return ipnsEntry.value.toString()
  }
}
github cloudflare / ipfs-ext / src / verify.js View on Github external
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()
      })
    })
  }