Miss any of our Open RFC calls?Watch the recordings here! »

@lorena-ssi/did-resolver

0.4.5 • Public • Published

Lorena DID Resolver

Build Status Coverage Status

Resolve DID Documents from DIDs in the Lorena namespace. This is is a plug-in for the Decentralized Identity Foundation did-resolver.

Network configurations (static data)

There are two static methods (no blockchain calls) which are useful for retrieving endpoints for different Lorena networks:

getInfoForNetwork('labdev')
getInfoForDid('did:lor:labdev:2nQtiQG6Cgm1GYTBaaKAgr76uY7iSexUkqX')

... and both return the same data:

{ "type": "substrate", "blockchainEndpoint": "wss://labdev.substrate.lorena.tech", "matrixEndpoint": "https://labdev.matrix.lorena.tech"}

DID Resolver (retrieve DID Document from blockchain data)

The Lorena DID resolver exposes a function called getResolver which will return an object containing one of these key/value pairs.

import { Resolver } from 'did-resolver'
import LorenaDidResolver from '@lorena-ssi/did-resolver'
 
// returns an object of { methodName: resolveFunction}
lorResolver = LorenaDidResolver.getResolver()
 
// If you are using only one method you can simply pass the result of `getResolver()` into the constructor
const resolver = new Resolver(lorResolver)

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

resolver.resolve('did:lor:and:2nQtiQG6Cgm1GYTBaaKAgr76uY7iSexUkqX/some/path#fragment=123').then(doc => console.log)
 
// You can also use ES7 async/await syntax
const doc = await resolver.resolve('did:lor:and:2nQtiQG6Cgm1GYTBaaKAgr76uY7iSexUkqX/some/path#fragment=123')

Outside of the standard resolve() method, LorenaDidResolver also provides a simple method to retrieve the public key for a DID, whether stored directly on the blockchain, in a DID Document, or through IPLD.

const pubKey = LorenaDidResolver.getPublicKeyForDid('did:lor:maxtest:2nQtiQG6Cgm1GYTBaaKAgr76uY7iSexUkqX')
 

License

MIT

Install

npm i @lorena-ssi/did-resolver

DownloadsWeekly Downloads

12

Version

0.4.5

License

MIT

Unpacked Size

13.4 kB

Total Files

5

Last publish

Collaborators

  • avatar
  • avatar
  • avatar
  • avatar