@dabit3/decentralized-identity

Authentication provider with Ceramic and IDX

Usage no npm install needed!

<script type="module">
  import dabit3DecentralizedIdentity from 'https://cdn.skypack.dev/@dabit3/decentralized-identity';
</script>

README

Decentralized Identity (alpha)

Single Sign-On with an Ethereum wallet (for now, other blockchains in the future)

Decentralized identity using Ceramic, IDX, and DIDs.

Learn more about IDX:

Installation

npm install @dabit3/decentralized-identity

Usage

Reading records

// uses basicProfile schema by default
const { record } = await getRecord()

console.log('Default user profile: ', record)

Reading records with a custom IDX schema

const { record } = await getRecord({ schema: 'mySchema' })

Default arguments to getRecord:

endpoint: string = "https://ceramic-clay.3boxlabs.com",
network: string = 'ethereum',
ceramicClient: CeramicClient = null,
schema: string = 'basicProfile'

Creating an authenticated client

import { client } from @dabit3/connectidx

const {
  ceramic, did, idx, error
} = await client()

/*
  Congrats!! You are now authenticated 🥳
*/

// reading profile
const data = await idx.get('basicProfile', did.id)

// writing to profile
const profile = {
  name: "Nader Dabit",
  bio: "DevRel at Edge & Node",
  twitter: "dabit3"
}

await idx.set('basicProfile', profile)

Default arguments to client:

endpoint: string = "https://ceramic-clay.3boxlabs.com",
resolvers:[] = null,
address: string = '',
provider: EthereumProfiver = null,
ceramicClient: CeramicClient = null

Creating a read only client

import { readOnlyClient } from @dabit3/connectidx

const { idx, ceramic } = await readOnlyClient()

const addresses = await ethereum.request({ method: 'eth_requestAccounts' })
const address = addresses[0]

const profile = await idx.get('basicProfile', `${address}@eip155:1`)

Default arguments to readOnlyClient:

endpoint: string = "https://ceramic-clay.3boxlabs.com",
ceramicClient: CeramicClient = null,

Example project

Example project

Check out the example project.