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

js-did-hypns

v4.3.1

Published

Decentralized identity document method using HyPNS, a kappa-multifeed over hypercore-protocol

Downloads

21

Readme

js-did-hypns

travis-ci-badge

Javascript Decentralized Identifiers using Hyperdrive Protocol

A HypnsId = DID + HyPNS Node + Keypair

What

This is a javascript implementation of the Decentralized Identity Document (DID Doc) method implementation.

Pre-alpha level software. Use a your own risk.

It uses a fork of kappa-db/multifeed (because waiting) which incorporates hypercore, corestore, and networker.

Multifeed was used because I want to be able to update my feed from any of my devices, as well as have backups. May switch to a HyPNS based multi-hyperbee later.

Why?

Most of the DID method implementations I have seen are based on blockchains. I wanted an implementation that worked without having to buy cryptocurrency and then spend the crypto every time you want to change your DID Doc. Hypercore-protocol is truly peer-to-peer, and free to the user.

So with this, anyone can create their own digital identity document and save it to their own machine. Theirs stays online as long as their computer is up, or any friends also have their computer running.

Browser

My design goals included:

  • [x] No download
  • [x] No sign-up
  • [x] No payment
  • [x] Use existing accounts/assets/platforms

#1 No download: This meant it had to work in the browser, as everyone already has a browser downloaded

#2 It had to work anonymously and without any server involvement to register or sign-up.

#3 No payment. Why pay for hardware, processing, or storage when we all have phones, computers, and other hardware already at our disposal? Also, buyign cryptocurrency is a hassle, and a huge barrier to entry for most people.

#4 Use existing accounts/platforms. To ease adoption, right along with using the browser, the system uses existing user-owner hardware and already installed software.

HypnsComponent

To get the software to work in the browser, I needed a protocol that works peer to peer and automatically pins peers. The winner for mutable data is the Hypercore-Protocol.

I developed a Svelte Hypns Component as well to make working with Hyper and Multifeed easier.

Svelte has a built-in onDestroy feature that automatically calls a function when the component is destroyed. So by baking the SDK and Hyperdrive into a Svelte component, I can "set it and forget it" about calling the await close() after I'm done with the SDK. See HyPNS for more details.

API

import { createDidHyper, getDid } from "js-did-hypns";
import HyPNS from 'hypns' // or use the HyPNS-Svelte-Component in Svelte!

var myNode = new HyPNS({ persist: false })
const myInstance = await myNode.open({ keypair }) // or leave empty to generate new pair
await myInstance.ready() // must wait for it to configure

// initate the hypnsId object using the node
hypnsId = createDidHyper(myNode);

const createOps = (document) => {
  document.addPublicKey({
    id: "master",
    type: "RsaVerificationKey2018",
    publicKeyHex: keypair.publicKey.toString('hex'),
  });
};

// make a DID doc on this HyPNS instance
const initialDocument = await hypnsId.create(myInstance, operations)

const updateOps = (document) => {
  document.addPublicKey({
    id: "secondary",
    type: "RsaVerificationKey2018",
    publicKeyHex: "someOtherHexPublicKeyHere",
  });
};

// update an existing DID doc on this drive
updatedContents = await hypnsId.update(myInstance, updateOps);

// get the DID of this drive
did = await getDid(myInstance);
// did:hypns:abc123def....

// get the DID Doc of this DID (if possible)
resolveSelfContents = await hypnsId.resolve(did);
// the actual DID doc with all the keys, methods, services, etc.

// get the DID Doc of a peer
peersContents = await hypnsId.resolve("did:hypns:123cba456def...");

Document and Key Manager ("Wallet")

TODO: demo needs updating

Goal: Show how to interact with the did-hypns module and save DID doc details directly. In reality, you'll likely use a DID wallet to manage all this, like https://github.com/DougAnderson444/streamlined-idm-wallet-sdk or any other DID doc management software.

Create, Read, Update and Delete did:hypns identities

You can create a DID doc by simply passing a hypns reference into this module.

PRs welcome, this is a work in progress.