Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including @lorena-ssi/did-resolver with all npm packages installed. Try it out:

var didResolver = require("@lorena-ssi/did-resolver")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

@lorena-ssi/did-resolver v0.4.5

Resolve DID Documents from DIDs in the Lorena namespace

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

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free