https://github.com/orbitdb/orbit-db-polkadot-iam
Identity Provider and Access Controller for Polkadot / Substrate based accounts
https://github.com/orbitdb/orbit-db-polkadot-iam
Last synced: about 1 year ago
JSON representation
Identity Provider and Access Controller for Polkadot / Substrate based accounts
- Host: GitHub
- URL: https://github.com/orbitdb/orbit-db-polkadot-iam
- Owner: orbitdb
- License: mit
- Created: 2021-04-27T20:59:30.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2021-10-05T17:03:10.000Z (over 4 years ago)
- Last Synced: 2025-03-28T16:43:51.245Z (about 1 year ago)
- Language: JavaScript
- Size: 199 KB
- Stars: 5
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# OrbitDB / Polkadot IAM _(orbit-db-polkadot-iam)_
> Identity Provider and Access Controller for Polkadot / Substrate based accounts
## Install
This is a [node.js](https://nodejs.org) project.
```bash
# deps
npm install ipfs orbit-db @polkadot/api
# install this package
npm install orbit-db-polkadot-iam
```
See the [tests](https://github.com/orbitdb/orbit-db-polkadot-iam/tree/main/test)
for examples or the following usage section.
## Usage
```JavaScript
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