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

@jolocom/stacks-did-resolver

v1.0.0-beta.1

Published

This repository includes the implementation for the Stack v2 DID resolver, as well as the corresponding `did:stack:v2` [DID method specification](../../docs/DID_Method_Spec.md). As outlined in the specification, this module relies on an instance of the [B

Downloads

1

Readme

@stacks/did-resolver

This repository includes the implementation for the Stack v2 DID resolver, as well as the corresponding did:stack:v2 DID method specification. As outlined in the specification, this module relies on an instance of the BNS smart contract, as well as the Atlas peer network to perform DID resolution.

Installation

To install the resolver you can simply run:

npm install @stacks/did-resolver

Usage examples

Using the provided module to resolve Stacks DID anchored on the main network is quite simple, and can be achieved as follows:

import { resolve } from "@stacks/did-resolver";

const did = 'did:stack:v2:SPWA58Z5C5JJW2TTJEM8VZA71NJW2KXXB2HA1V16-d8a9a4528ae833e1894eee676af8d218f8facbf95e166472df2c1a64219b5dfb'

const didDocument = await resolve(did);
// didDocument now contains the corresponding Did Document in JSON form.

In the example above, the resolution happens against the Stacks main network. The Stacks deployment used for resolution (e.g. test network, local mock network) can be configured by instantiating a new resolver as follows:

import { getResolver } from "@stacks/did-resolver";
import { StacksTestnet } from "@stacks/network"

const resolve = getResolver(new StacksTestnet())

// Example testnet DID, does not resolve to a DID document
const testnetDid = 'did:stack:v2:STB53GD600EMEM74DFMA0B61JN8D8C4VE5477MXR-55bb3a37f9b2e8c58905c95099d5fc21aa47d073a918f3b30cc5abe4e3be44c6'

const didDocument = await resolve(did);

Local development

First clone the stacks.js repository locally, install all all dependencies, and navigate to the did-resolver package:


git clone https://github.com/blockstack/stacks.js.git

cd stacks.js

npm install

npm run bootstrap

cd packages/did-resolver

Running the tests

The unit tests included with this repository can be run using the npm run test command (npm run test:watch can be used to rerun all tests when relevant source files are changed). These tests can run offline, and do not depend on any additional infrastructure.

In addition to the unit tests, a set of integration / e2e tests are included in this repository as well. These tests rely on a local Stacks 2.0 blockchain mocknet deployment to register and resolve a number of test DIDs. In order to run the tests, first start the aforementioned mocknet instance in a different terminal window using:

docker run -p 3999:3999 blockstack/stacks-blockchain-api-standalone mocknet

Once the Stacks 2.0 node has started, you can run the following commands from the did-resovler folder to test the resolution of on-chain and off-chain DIDs:

# Will register a number of test DIDs on the mock network. This process will take a minute and only needs to run once.
npm run test:setup

# Once the setup is complete, you can run
npm run test:integration

Lastly, in case you would like to run both the unit and integration tests (and get a combined code coverage report), you can run npm run test:all. Please keep in mind that this will run the npm run test:integration command, and therefore assumes npm run test:setup has been run.