did-resolver
Resolve DID documents
Last updated 8 years ago by pelleb .
Apache-2.0 · Repository · Bugs · Original npm · Tarball · package.json
$ npm install did-resolver 
SYNC missed versions from official npm registry.

Javascript DID Resolver

This library is intended as a simple common interface for javascript applications to resolve DID documents from Decentralized Identifiers (DIDs).

This is intended to support the proposed Decentralized Identifiers spec from the W3C Credentials Community Group.

The library does not implement any specific DID method, but allows DID method implementors to release npm packages that applications can add.

Breaking changes (0.1.0)

This removes the global resolver. We've learnt that this ended up causing many problems. Instead you should now instantiate a Resolver object and use that to resolve did's within your consuming app/library.

Changes required for developers of DID resolvers

You now no longer register your DID resolvers using the global registerMethod() function. Instead export the resolver function and show how to configure it in a local resolver object.

Configure Resolver object

You are now required to preconfigure a resolver during instantiation:

import { DIDResolver } from 'did-resolver'
import ethr from 'ethr-did-resolver'
import web from 'web-did-resolver'
import sov from 'sov-did-resolver'

const resolver = new DIDResolver({
  ethr,
  web,
  https: web // Override a did method type
})

Resolving a DID document

The resolver presents a simple resolve() function that returns a ES6 Promise returning the DID document.

resolver.resolve('did:uport:2nQtiQG6Cgm1GYTBaaKAgr76uY7iSexUkqX/some/path#fragment=123').then(doc => console.log)

// You can also use ES7 async/await syntax
const doc = await resolver.resolve('did:uport:2nQtiQG6Cgm1GYTBaaKAgr76uY7iSexUkqX/some/path#fragment=123')

Implementing a DID method

Each DID method will have it's own methods for looking up an identifier on it's respective blockchain or other decentralized storage mechanism.

A method implementer calls the registerMethod('methodname', resolver). where methodname is the method identifier. The resolver is a function that receives a DID and a parsed version of the DID. It returns a ES6 Promise that looks up the DID document.

export default async function myResolver (did, parsed, didResolver) {
  console.log(parsed)
  // {method: 'mymethod', id: 'abcdefg', did: 'did:mymethod:abcdefg/some/path#fragment=123', path: '/some/path', fragment: 'fragment=123'}
  const didDoc = ...// lookup doc
  // If you need to lookup another did as part of resolving this did document, the primary DIDResolver object is passed in as well
  const parentDID = await didResolver.resolve(...)
  //
  return didDoc
})

The method resolver should register this so that just requiring it will register the method:

import { DIDResolver } from 'did-resolver'
import MyMethod from 'mymethod-did-resolver'

const resolver = new DIDResolver({
  mymethod: MyMethod
})

Current Tags

  • 0.0.7-alpha.0                                ...           alpha (7 years ago)
  • 6.0.0                                ...           latest (2 months ago)
  • 5.0.0-feat-publishing-maintenance.1                                ...           preview (7 months ago)

41 Versions

  • 6.0.0                                ...           2 months ago
  • 5.0.1                                ...           7 months ago
  • 5.0.0                                ...           7 months ago
  • 5.0.0-feat-publishing-maintenance.1                                ...           7 months ago
  • 4.1.0                                ...           4 years ago
  • 4.0.1                                ...           4 years ago
  • 4.0.0                                ...           4 years ago
  • 3.2.2                                ...           4 years ago
  • 3.2.1                                ...           4 years ago
  • 3.2.0                                ...           5 years ago
  • 3.1.5                                ...           5 years ago
  • 3.1.4                                ...           5 years ago
  • 3.1.3                                ...           5 years ago
  • 3.1.2                                ...           5 years ago
  • 3.1.1                                ...           5 years ago
  • 3.1.0                                ...           6 years ago
  • 3.0.2                                ...           6 years ago
  • 3.0.1                                ...           6 years ago
  • 3.0.0                                ...           6 years ago
  • 2.2.0                                ...           6 years ago
  • 2.1.2                                ...           6 years ago
  • 2.1.1                                ...           6 years ago
  • 2.1.0                                ...           6 years ago
  • 2.0.1                                ...           6 years ago
  • 2.0.0                                ...           6 years ago
  • 1.1.0                                ...           7 years ago
  • 1.0.0                                ...           7 years ago
  • 0.0.7                                ...           7 years ago
  • 0.0.7-alpha.0                                ...           7 years ago
  • 0.1.0-alpha.0                                ...           8 years ago
  • 0.0.6                                ...           8 years ago
  • 0.0.6-alpha5                                ...           8 years ago
  • 0.0.6-alpha4                                ...           8 years ago
  • 0.0.6-alpha3                                ...           8 years ago
  • 0.0.6-alpha2                                ...           8 years ago
  • 0.0.6-alpha1                                ...           8 years ago
  • 0.0.5                                ...           8 years ago
  • 0.0.4                                ...           9 years ago
  • 0.0.3                                ...           9 years ago
  • 0.0.2                                ...           9 years ago
  • 0.0.1                                ...           9 years ago
Downloads
Total 151
Today 0
This Week 4
This Month 94
Last Day 0
Last Week 16
Last Month 37
Dependencies (0)
None
Dev Dependencies (11)
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE