Skip to content

Identity Provider and Access Controller for Polkadot / Substrate based accounts

License

Notifications You must be signed in to change notification settings

orbitdb/orbit-db-polkadot-iam

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OrbitDB / Polkadot IAM (orbit-db-polkadot-iam)

Identity Provider and Access Controller for Polkadot / Substrate based accounts

Install

This is a node.js project.

# deps
npm install ipfs orbit-db @polkadot/api

# install this package
npm install orbit-db-polkadot-iam

See the tests for examples or the following usage section.

Usage

const assert = require('assert')
const OrbitDB = require('orbit-db')
const IPFS = require('ipfs')
const {
  AccessControllers,
  PolkadotIdentityProvider,
  createIdentity
} = require('../src/orbit-db-polkadot-iam')

;(async function () {
  // Identity creation based on the passphrase from the Polkadot documentation.
  const phrase = 'entire material egg meadow latin bargain dutch coral blood melt acoustic thought'
  const identity = await createIdentity(phrase)

  // Identity verification using the OrbitDB internals
  // See: https://github.com/orbitdb/orbit-db-identity-provider
  assert(await PolkadotIdentityProvider.verifyIdentity(identity))

  // Usage with IPFS and OrbitDB
  const ipfs = await IPFS.create()

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

  // Write access can currently be any polkadot ID aka address
  const db = await orbitdb.kvstore('root', {
    accessController: {
      type: 'Polkadot',
      write: [identity.id]
    }
  })

  // Only allowed accounts will be permitted to write to the db
  await db.set('foo', 'bar')
})()

Contributing

Issues and PRs welcome.

License

MIT © 2021 OrbitDB Community

About

Identity Provider and Access Controller for Polkadot / Substrate based accounts

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published