Options
All
  • Public
  • Public/Protected
  • All
Menu

Module @ceramicnetwork/3id-did-resolver

3ID DID Resolver

3ID is a DID method that uses the Ceramic network to resolve DID documents.

Getting started

Installation

$ npm install @ceramicnetwork/3id-did-resolver

Usage

import ThreeIdResolver from '@ceramicnetwork/3id-did-resolver'
import { Resolver } from 'did-resolver'

// You need an instance of Ceramic to call getResolver.
// This can be either @ceramicnetwork/core or @ceramicnetwork/http-client.
// You can also set an address for your own ethr-did-registry contract
const ceramic = // ...

// getResolver will return an object with a key/value pair of { '3': resolver }
// where resolver is a function used by the generic did resolver.
const threeIdResolver = ThreeIdResolver.getResolver(ceramic)
const didResolver = Resolver(threeIdResolver)

const doc = await didResolver.resolve('did:ethr:0xf3beac30c498d9e26865f34fcaa57dbb935b0d74')
console.log(doc)

Development

Run tests:

$ npm test

Run linter:

npm run lint

Contributing

We are happy to accept small and large contributions. Make sure to check out the Ceramic specifications for details of how the protocol works.

License

Index

Variables

Const LIMIT

LIMIT: 100 = 100

Const THREEBOX_API_URL

THREEBOX_API_URL: "https://ipfs.3box.io" = "https://ipfs.3box.io"

Const fetchCache

fetchCache: LRUMap<string, any> = new LRUMap<string, any>(LIMIT)

Functions

Const LegacyResolver

  • LegacyResolver(didId: string, ipfs?: IPFS): Promise<any>

Const compressKey

  • compressKey(key: string): string

Const didDocReq

  • didDocReq(cid: string): string

Const encodeKey

  • encodeKey(key: Uint8Array, encryption?: boolean): string

Const fetchJson

  • fetchJson(url: string): Promise<any>

Const getVersion

  • getVersion(query?: string): string | null
  • Gets the identifier of the version of the did document that was requested. This will correspond to a specific 'commit' of the ceramic document

    Parameters

    • Default value query: string = ""

    Returns string | null

Const isLegacyDid

  • isLegacyDid(didId: string): boolean

Const legacyResolve

  • legacyResolve(ceramic: Ceramic, didId: string, commit?: string): Promise<DIDDocument | null>

Const resolve

  • resolve(ceramic: Ceramic, didId: string, commit?: string, v03ID?: string): Promise<DIDDocument | null>

wrapDocument

  • wrapDocument(content: any, did: string): DIDDocument

Object literals

Const ipfsMock

ipfsMock: object

dag

dag: object

get

  • get(cid: string): Promise<any>