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-frequency

v0.0.3

Published

A DSNP over Frequency DID resolver

Downloads

79

Readme

Overview

This package contains a resolver for the @dsnp/did-resolver library which enables resolution of did:dsnp:* DIDs on the Frequency blockchain.

Installation

npm install @dsnp/did-resolver-frequency

Usage

The resolver object can be constructed with Frequency connection information in one of two ways.

  1. Construct with provider URI:
import { FrequencyResolver } from "@dsnp/did-resolver-frequency";

const frequencyResolver = new FrequencyResolver({
  providerUri: "ws://127.0.0.1:9944",
});

If constructed this way, you must call disconnect() to explicitly release the connection; the process will not exit if this is not done.

or,

  1. Construct with preconfigured Promise<ApiPromise> object from @polkadot/api:
import { FrequencyResolver } from "@dsnp/did-resolver-frequency";

const frequencyResolver = new FrequencyResolver({
  apiPromise: myApiPromise, // from ApiPromise.create(...)
});

Summary of options:

| Configuration option | Description | | --- | --- | | providerUri | Provider URI for Frequency RPC node (optional; alternative to apiPromise | | apiPromise | A Promise<ApiPromise> (optional; alternative to providerUri |

See .env.example for example configuration.

Here's a full usage example with the did-io DID resolver framework:

import { CachedResolver } from "@digitalbazaar/did-io";
import didDsnp from "@dsnp/did-resolver"; 
import { FrequencyResolver } from "@dsnp/did-resolver-frequency";

const frequencyResolver = new FrequencyResolver({
  providerUri: "wss://1.rpc.frequency.xyz",
});

const resolver = new CachedResolver();
resolver.use(didDsnp.driver([ frequencyResolver ]));
const did = "did:dsnp:123456";
const result = await resolver.get({ did });
console.log(JSON.stringify(result, null, 2));

await frequencyResolver.disconnect();

/* Example output:
{
  "@context": [
    "https://www.w3.org/ns/did/v1"
  ],
  "id": "did:dsnp:1",
  "assertionMethod": [
    {
      "@context": "https://w3id.org/security/multikey/v1",
      "id": "did:dsnp:1#z6MktEsFq4c5qFZkj3wq5FZDurXLpG1s9gD7oWDZoS8S5F27",
      "type": "Multikey",
      "controller": "did:dsnp:1",
      "publicKeyMultibase": "z6MktEsFq4c5qFZkj3wq5FZDurXLpG1s9gD7oWDZoS8S5F27"
    }
  ],
  "keyAgreement": []
}
*/

CLI

The example above is provided as a command line script.

cp .env.example .env
# uncomment the desired node endpoint
npm run resolve -- 13972

Features

Currently this resolver implements the minimal functionality required to support lookup of public keys by DSNP applications.

  • DSNP control keys are listed in the authentication array.
  • DSNP keyAgreementPublicKeys are listed in the keyAgreement array.
  • DSNP assertionMethodPublicKeys are listed in the assertionMethod array.
  • A user's Frequency handle, if one exists, is noted in the alsoKnownAs array with a did:frqcy:handle: prefix.

All public keys are encoded using the Multikey type. The id consists of the DSNP DID and a URL fragment that is the same as the publicKeyMultibase value, which is a multicodec value in base58btc encoding. The decoded value for ed25519-pub keys will be 34 bytes, including the two-byte multicodec identifier.