Skip to content
This repository was archived by the owner on Sep 30, 2023. It is now read-only.

orbitdb-archive/orbit-db-access-controllers

 
 

Repository files navigation

orbit-db-access-controllers

Access Controllers for OrbitDB

Install

This project uses npm and nodejs.

npm i orbit-db-access-controllers

Usage

Creating a custom Access Controller

You can create a custom access controller by implementing the AccessController interface and adding it to the AccessControllers object before passing it to OrbitDB. For more detailed examples, see the implementation of the Ethereum Contract Access Controller and OrbitDB Access Controller.

class OtherAccessController extends AccessController {

  static get type () { return 'othertype' } // Return the type for this controller

  async canAppend(entry, identityProvider) {
    // logic to determine if entry can be added, for example:
    if (entry.payload === "hello world" && entry.identity.id === identity.id && identityProvider.verifyIdentity(entry.identity))
      return true

    return false
  }
  async grant (access, identity) {} // Logic for granting access to identity
}

let AccessControllers = require('orbit-db-access-controllers')
AccessControllers.addAccessController({ AccessController: OtherAccessController })

const orbitdb = await OrbitDB.createInstance(ipfs, {
  AccessControllers: AccessControllers
})

const db = await orbitdb.keyvalue('first-database', {
  accessController: {
    type: 'othertype',
    write: [identity.publicKey]
  }
})

Contribute

We would be happy to accept PRs! If you want to work on something, it'd be good to talk beforehand to make sure nobody else is working on it. You can reach us on IRC #orbitdb on Freenode, or in the comments of the issues section.

We also have regular community calls, which we announce in the issues in the @orbitdb welcome repository. Join us!

If you want to code but don't know where to start, check out the issues labelled "help wanted".

For specific guidelines for contributing to this repository, check out the Contributing guide. For more on contributing to OrbitDB in general, take a look at the orbitdb welcome repository. Please note that all interactions in @orbitdb fall under our Code of Conduct.

License

MIT © 2018 Haja Networks Oy

About

Access Controllers for OrbitDB

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published