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

tz-did-resolver

v1.13.0

Published

W3C compliant DID Resolver for the Tezos DID Method

Downloads

23

Readme

tz-did-resolver

W3C compliant DID Resolver for the Tezos DID Method

tz DID Resolver

This library is intended to use Tezos accounts and smart contract addresses as fully self-managed Decentralized Identifiers and wrap them in a DID Document

It supports the proposed did:tz method spec spec from did-tezos.

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

DID method

To encode a DID for a Tezos address on the Tezos mainnet, simply prepend did:tz:

eg:

did:tz:tz1TzrmTBSuiVHV2VfMnGRMYvTEPCP42oSM8

Multi-network DIDs are also supported, if the proper configuration is provided during setup.

For example: did:tz:granadanet:tz1TzrmTBSuiVHV2VfMnGRMYvTEPCP42oSM8 gets resolved on the Granadanet testnet, and represents a distinct identifier than the generic one, with different DID Documents and different key rotation history.

DID Document

The minimal DID Document for a Tezos address did:tz:tz1TzrmTBSuiVHV2VfMnGRMYvTEPCP42oSM8 with no transactions to the registry looks like this:

{
  "@context": [
    "https://www.w3.org/ns/did/v1",
    "https://w3id.org/security/v1"
  ],
  "id": "did:tz:tz1TzrmTBSuiVHV2VfMnGRMYvTEPCP42oSM8",
  "verificationMethod": [
    {
      "id": "did:tz:tz1TzrmTBSuiVHV2VfMnGRMYvTEPCP42oSM8#blockchainAccountId",
      "type": "Ed25519PublicKeyBLAKE2BDigestSize20Base58CheckEncoded2021",
      "controller": "did:tz:tz1TzrmTBSuiVHV2VfMnGRMYvTEPCP42oSM8",
      "blockchainAccountId": "tezos:NetXdQprcVkpaWU:tz1TzrmTBSuiVHV2VfMnGRMYvTEPCP42oSM8"
    }
  ],
  "authentication": [
    "did:tz:tz1TzrmTBSuiVHV2VfMnGRMYvTEPCP42oSM8#blockchainAccountId"
  ],
  "assertionMethod": [
    "did:tz:tz1TzrmTBSuiVHV2VfMnGRMYvTEPCP42oSM8#blockchainAccountId"
  ]
}

Building a DID document

The DID Document is not stored as a file, but is built by using tzip-16 views functions present on the DID Manager smart contract.

Please see the spec for details of how the DID document and corresponding metadata are computed.

Resolving a DID document

The library presents a resolve() function that returns a Promise including the DID Document. It is not meant to be used directly but through the did-resolver aggregator.

You can use the getResolver() method to produce an entry that can be used with the Resolver constructor:

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

const tzResolver = getResolver()

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

didResolver.resolve('did:tz:tz1TzrmTBSuiVHV2VfMnGRMYvTEPCP42oSM8').then(({ didDocument }) => console.log(didDocument))

// You can also use ES7 async/await syntax
const { didDocument } = await didResolver.resolve('did:tz:tz1TzrmTBSuiVHV2VfMnGRMYvTEPCP42oSM8')
console.log(didDocument)