GithubHelp home page GithubHelp logo

spartanz51 / orbit-db-access-controllers Goto Github PK

View Code? Open in Web Editor NEW

This project forked from orbitdb-archive/orbit-db-access-controllers

0.0 1.0 0.0 2.65 MB

Access Controllers for OrbitDB

License: MIT License

JavaScript 99.73% Makefile 0.27%

orbit-db-access-controllers's Introduction

orbit-db-access-controllers

Gitter Matrix

Access Controllers for OrbitDB

Install

This project uses npm and nodejs.

npm i orbit-db-access-controllers

Usage

By default, if no write-array is specified in options, the access control is set so that the initial user is the only one who has access (specified by the identity property of the orbitdb instance given in the argument). For the Ethereum-based contract example, the account which deploys the contract is initially given access.

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.id]
  }
})

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 Gitter, or in the issues section.

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

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.