Skip to content

Create, sign and verify OrbitDB identities using Decentralized Identifiers (DIDs).

License

Notifications You must be signed in to change notification settings

beautrait/orbitdb-identity-provider-did

 
 

Repository files navigation

OrbitDB DID Identity Provider

Matrix npm (scoped) node-current (scoped)

Create and sign OrbitDB identities using a Decentralized IDentifier (DID). See https://www.w3.org/TR/did-core/.

Install

This project uses npm and nodejs.

npm i @orbitdb/identity-provider-did

Usage

Start by registering the OrbitDBIdentityProviderDID identity provider with useIdentityProvider.

Once registered, you can simply pass in the identity provider when creating an OrbitDB instance:

import { createHelia, libp2pDefaults } from 'helia'
import { createOrbitDB, useIdentityProvider } from '@orbitdb/core'
import * as OrbitDBIdentityProviderDID from '@orbitdb/identity-provider-did'
import KeyDidResolver from 'key-did-resolver'
import { Ed25519Provider } from 'key-did-provider-ed25519'

const libp2pOptions = libp2pDefaults()
const ipfs = await createHelia({ libp2p: libp2pOptions })

const seed = new Uint8Array(/* some private seed */)

OrbitDBIdentityProviderDID.setDIDResolver(KeyDidResolver.getResolver())
useIdentityProvider(OrbitDBIdentityProviderDID)
const didProvider = new Ed25519Provider(seed)
const provider = OrbitDBIdentityProviderDID({ didProvider })
await createOrbitDB({ ipfs, identity: { provider } })

If you require a more custom approach to managing identities, you can create an identity by passing the identity provider to createIdentity then use the resulting identity with OrbitDB:

import { createHelia, libp2pDefaults } from 'helia'
import { createOrbitDB, Identities, useIdentityProvider } from '@orbitdb/core'
import OrbitDBIdentityProviderDID from '@orbitdb/identity-provider-did'
import KeyDidResolver from 'key-did-resolver'
import { Ed25519Provider } from 'key-did-provider-ed25519'

const libp2pOptions = libp2pDefaults()
const ipfs = await createHelia({ libp2p: libp2pOptions })

const seed = new Uint8Array(/* some private seed */)

OrbitDBIdentityProviderDID.setDIDResolver(KeyDidResolver.getResolver())
useIdentityProvider(OrbitDBIdentityProviderDID)

const didProvider = new Ed25519Provider(seed)

const identities = await Identities({ ipfs })
const identity = await identities.createIdentity({ provider: OrbitDBIdentityProviderDID({ didProvider }) })

await createOrbitDB({ ipfs, identities, identity })

Contributing

Take a look at our organization-wide Contributing Guide. You'll find most of your questions answered there. Some questions may be answered in the FAQ, as well.

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

License

MIT Haja Networks Oy, OrbitDB Community

About

Create, sign and verify OrbitDB identities using Decentralized Identifiers (DIDs).

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%