How to use the ipfs-log/src/entry.fromMultihash function in ipfs-log

To help you get started, we’ve selected a few ipfs-log 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 3box / 3box-js / src / access / thread-open-mod-access.js View on Github external
const op = entry.payload.op
    const mods = this.capabilities['moderators']
    const members = this.capabilities['members']
    const isMod = mods.includes(entry.identity.id)
    const isMember = members.includes(entry.identity.id)

    if (op === 'ADD') {
      // Anyone can add entry if open thread
      if (!this._members) return await trueIfValidSig()
      // Not open thread, any member or mod can add to thread
      if (isMember || isMod) return await trueIfValidSig()
    }

    if (op === 'DEL') {
      const hash = entry.payload.value
      const delEntry = await entryIPFS.fromMultihash(this._ipfs, hash)

      // An id can delete their own entries
      if (delEntry.identity.id === entry.identity.id) return await trueIfValidSig()

      // Mods can't delete other mods entries
      if (mods.includes(delEntry.identity.id)) return false

      // Mods can delete any other entries
      if (isMod) return await trueIfValidSig()
    }

    return false
  }

ipfs-log

Append-only log CRDT on IPFS

MIT
Latest version published 1 year ago

Package Health Score

54 / 100
Full package analysis