# orbit-db-access-controllers

> Access Controllers for OrbitDB

Latest version **0.4.0** (published 2023-01-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install orbit-db-access-controllers
pnpm add orbit-db-access-controllers
yarn add orbit-db-access-controllers
bun add orbit-db-access-controllers
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.4.0 |
| Published | 2023-01-18 |
| First published | 2019-04-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 3 |
| Unpacked size | 30.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 27 |
| Maintainers | shamb0t, hajamark |
| Keywords | orbit, orbitdb |

## Links

- npm: https://www.npmjs.com/package/orbit-db-access-controllers
- Repository: https://github.com/orbitdb/orbit-db-access-controllers
- Homepage: https://github.com/orbitdb/orbit-db-access-controllers#readme
- Issues: https://github.com/orbitdb/orbit-db-access-controllers/issues
- npm.io page: https://npm.io/package/orbit-db-access-controllers

## Dependencies (3)

- [orbit-db-io](https://npm.io/package/orbit-db-io.md) ^3.0.0
- [safe-buffer](https://npm.io/package/safe-buffer.md) ^5.2.1
- [p-map-series](https://npm.io/package/p-map-series.md) ^3.0.0

## Recent versions

- 0.4.0 (latest) — 2023-01-18
- 0.4.1-3741eb3.0 (next) — 2023-01-18
- 0.3.3-59dcbdd.0 — 2023-01-17
- 0.3.3-d9da6d8.0 — 2023-01-09
- 0.3.3-bf06527.0 — 2021-10-08
- 0.3.2 — 2021-09-27
- 0.3.2-751ebf8.0 — 2021-09-27
- 0.3.2-4c5f34e.0 — 2021-09-27
- 0.3.2-6e75dd9.0 — 2021-09-27
- 0.3.1-f006e88.0 — 2021-09-27
- 0.2.6 — 2020-09-11
- 0.3.0 — 2020-09-06
- 0.2.5 — 2020-06-25
- 0.2.4 — 2019-11-07
- 0.2.3 — 2019-08-29
- … 11 more at https://npm.io/package/orbit-db-access-controllers/versions

## README

# orbit-db-access-controllers

[![Gitter](https://img.shields.io/gitter/room/nwjs/nw.js.svg)](https://gitter.im/orbitdb/Lobby) [![Matrix](https://img.shields.io/badge/matrix-%23orbitdb%3Apermaweb.io-blue.svg)](https://riot.permaweb.io/#/room/#orbitdb:permaweb.io) 

> Access Controllers for OrbitDB

## Install

This project uses [npm](http://npmjs.com/) and [nodejs](https://nodejs.org/).

```sh
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](https://github.com/orbitdb/orbit-db-access-controllers/blob/master/src/access-controller-interface.js) 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](https://github.com/orbitdb/orbit-db-access-controllers/blob/master/src/contract-access-controller.js) and [OrbitDB Access Controller](https://github.com/orbitdb/orbit-db-access-controllers/blob/master/src/orbitdb-access-controller.js).

```javascript
import AccessControllers from 'orbit-db-access-controllers'

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
}

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](https://gitter.im/orbitdb/Lobby), or in the [issues section](https://github.com/orbitdb/orbit-db-access-controllers/issues).

We also have **regular community calls**, which we announce in the issues in [the @OrbitDB welcome repository](https://github.com/orbitdb/welcome/issues). Join us!


For specific guidelines for contributing to this repository, check out the [Contributing guide](CONTRIBUTING.md). For more on contributing to OrbitDB in general, take a look at the [OrbitDB welcome repository](https://github.com/orbitdb/welcome). Please note that all interactions in [@OrbitDB](https://github.com/orbitdb) fall under our [Code of Conduct](CODE_OF_CONDUCT.md).

## License

[MIT](LICENSE) © 2018 Haja Networks Oy

---
_Source: https://npm.io/package/orbit-db-access-controllers · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
