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

@dsnp/did-resolver

v0.0.4

Published

A DSNP DID resolver

Downloads

22

Readme

Overview

This package implements a generic resolver for the dsnp DID method (that is, DIDs of the form did:dsnp:123456, where 123456 is a DSNP User Id in decimal format). This resolver must be used with one or more plugins for specific DSNP systems (see below).

Usage

This package follows the conventions described in the @digitalbazaar/did-io package and exposes a driver() function which returns an object with a get(options) method. Pass an array of DSNPResolver objects to the driver() method.

Usage for DSNP DID method only

import { CachedResolver } from "@digitalbazaar/did-io";
import didDsnp from "@dsnp/did-resolver";
import { FooResolver} from "dsnp-did-resolver-plugin-foo"; // See below for known plugins
// ... additional dsnp-did-resolver plugins if needed

const resolver = new CachedResolver();
resolver.use(didDsnp.driver([ new FooResolver() ]));

const myDid = "did:dsnp:123456";
const result = await resolver.get({ did: myDid });
console.log(JSON.stringify(result, null, 2));

Usage with other DID method resolvers

The CachedResolver can combine drivers for multiple DID methods as described in the did-io documentation. For example, if you also want to be able to resolve did:web:* DIDs, you can use the did-method-web driver alongside the DSNP driver.

import { CachedResolver } from "@digitalbazaar/did-io";
import didWeb from "@digitalbazaar/did-method-web";
import didDsnp from "@dsnp/did-resolver";
import { FooResolver} from "dsnp-did-resolver-plugin-foo";

const resolver = new CachedResolver();
resolver.use(didWeb.driver());
resolver.use(didDsnp.driver([ new FooResolver() ]));

// DID resolution proceeds as in previous example

Plugins

To resolve a DSNP User Id to a specific DSNP system, one or more instances of system-specific plugins are required. Array ordering defines the order in which this resolver will attempt to resolve a DSNP DID. It will return the result from the first plugin that returns a DID document.

Plugin development

Plugins should implement the DSNPResolver interface, which includes a resolve(bigint) function (see index.ts):

export interface DSNPResolver {
  resolve(dsnpUserId: bigint): Promise<object | null>;
}

The resolve() function should return null if the DSNP User Id cannot be resolved to a DID document for any reason. Plugins should avoid throwing errors except in dire circumstances, as errors from one plugin will cause any further plugins that have been registered to not be called.

DSNPResolver instances are passed to this library's driver() method as shown above.

Known plugins

| System | Plugin package |---|---| | Frequency | @dsnp/did-resolver-plugin-frequency |

Please submit a pull request with any additional plugins.

Development

  • npm install - install dependencies
  • npm run build - compile
  • npm run test - run unit tests
  • npm run lint - run linter
  • npm run format - reformat source files

Pull requests are welcomed with an accompanying github issue.