How to use the interface-datastore.Key.isKey function in interface-datastore

To help you get started, we’ve selected a few interface-datastore 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 / src / core / ipns / publisher.js View on Github external
async _publishPublicKey (key, publicKey) {
    if ((!Key.isKey(key))) {
      const errMsg = 'datastore key does not have a valid format'
      log.error(errMsg)

      throw errcode(new Error(errMsg), 'ERR_INVALID_DATASTORE_KEY')
    }

    if (!publicKey || !publicKey.bytes) {
      const errMsg = 'one or more of the provided parameters are not defined'
      log.error(errMsg)

      throw errcode(new Error(errMsg), 'ERR_UNDEFINED_PARAMETER')
    }

    // Add public key to routing (buffer key)
    try {
      const res = await this._routing.put(key.toBuffer(), publicKey.bytes)
github ipfs / js-ipfs / src / core / ipns / publisher.js View on Github external
async _publishEntry (key, entry) {
    if (!(Key.isKey(key))) {
      const errMsg = 'datastore key does not have a valid format'

      log.error(errMsg)

      throw errcode(new Error(errMsg), 'ERR_INVALID_DATASTORE_KEY')
    }

    let entryData
    try {
      // Marshal record
      entryData = ipns.marshal(entry)
    } catch (err) {
      log.error(err)

      throw err
    }