npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

web-did-resolver

v2.0.27

Published

Resolve DID documents from an https domain

Downloads

30,016

Readme

npm npm codecov

Web DID Resolver

This library is intended to represent domains accessed through https as Decentralized Identifiers and retrieve an associated DID Document

It supports the proposed did:web method spec from the W3C Credentials Community Group.

It requires the did-resolver library, which is the primary interface for resolving DIDs.

DID method

To encode a DID for an HTTPS domain, simply prepend did:web: to domain name.

eg: https://example.com -> did:web:example.com

DID Document

The DID resolver takes the domain and forms a well-known URI to access the DID Document.

For a did did:web:example.com, the resolver will attempt to access the document at https://example.com/.well-known/did.json

A minimal DID Document might contain the following information:

{
  "@context": "https://w3id.org/did/v1",
  "id": "did:web:example.com",
  "publicKey": [
    {
      "id": "did:web:example.com#owner",
      "type": "Secp256k1VerificationKey2018",
      "controller": "did:web:example.com",
      "publicKeyHex": "04ab0102bcae6c7c3a90b01a3879d9518081bc06123038488db9cb109b082a77d97ea3373e3dfde0eccd9adbdce11d0302ea5c098dbb0b310234c8689501749274"
    }
  ],
  "assertionMethod": [ "did:web:example.com#owner" ],
  "authentication": [ "did:web:example.com#owner" ]
}

Note: this example uses the Secp256k1VerificationKey2018 type and an publicKeyHex as a publicKey entry, signaling that this DID is claiming to control the private key associated with that publicKey.

Resolving a DID document

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

import { Resolver } from 'did-resolver'
import { getResolver } from 'web-did-resolver'

const webResolver = getResolver()

const didResolver = new Resolver({
    ...webResolver
    //...you can flatten multiple resolver methods into the Resolver
})

didResolver.resolve('did:web:uport.me').then(doc => console.log(doc))

// You can also use ES7 async/await syntax
;(async () => {
    const doc = await didResolver.resolve('did:web:uport.me')
    console.log(doc)
})();