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

@peerpiper/did-ar

v0.0.23

Published

I just wrote this, so there will be some changes, improvements and bugs. But feel free to play around with it.

Downloads

16

Readme

DID:AR

I just wrote this, so there will be some changes, improvements and bugs. But feel free to play around with it.

Enables users to create a smartweave contract on Arweave to store their Decentralized Identity Document (DID Doc).

✔️📇 Your Own Permanent Identity on Web3

✔️🗃️ Resolve DID from .ar name, so douganderson444.ar -> did:ar:....

✔️💰 No Tokens / cryptocurrency (under 100kb), thanks to Bundlr!

✔️♾️ Lasts forever, thanks to Arweave!

✔️💻 Saves to your OWN device, thanks to PeerPiper!

✔️🗃️ Conveniently Control Your Data

Install

Package deployed to npm @peerpiper/did-ar

npm i @peerpiper/did-ar

Initialize

import { init } from 'did-ar';

const didar: DIDAr = await init({
	// local: true, // default is false, uses local Arweave instance
	// wallet: JWKInterface, // default is 'use_wallet' if no wallet is set
});

// which gives you a DIDAr instance:
interface DIDAr {
	warp: WarpFactory;
	wallet: JWKInterface | 'use_wallet';
	create: Function;
	read: Function;
	update: Function;
}

Create DID

Pass an RSA Public Key JWK and Ed25519PublicKey bytes (Uint8Array) to create, which will create a did and did document saved as the Arweave Smartweave contract state.

The Demo uses the keys from a PeerPiper/web3-wallet-connector to create the DID.

const did = await didar.create({ RSAPublicKey: JWK, Ed25519PublicKey: Uint8Array });
console.log(did); // did:ar:abc123zyx-ELEMENOPee
// or when running in `vite dev` mode:
console.log(did); // did:arlocal:abc123zyx-ELEMENOPee

Read DID (Resolve)

If you have a didar instance, you can simply read from it:

const didDoc = await didar.read(did);

If you are using DID from an external source, read using the resolver, as this library exports a standalone DID Resolver compliant with the DIF.

import { didArResolver } from '@peerpiper/did-ar';
import { Resolver } from 'did-resolver'; // Decentralized Identity Foundation

const did = `did:ar:abc123zyx-ELEMENOPeeeeeeeeeeeeeeee`;
// or when running in `vite dev` mode:
// did:arlocal

const arResolver = didArResolver.getResolver();
resolver = new Resolver(arResolver);
const didDoc = (await resolver.resolve(did)).didDocument;

console.log(didDoc.verificationMethod[0].publicKeyJwk); // one of the did's public keys

Read from .ar name (Resolve DID from Arweave Name Service / Name Token)

import { arnsResolver } from '@peerpiper/did-ar';

const arnsName = 'douganderson444'; // From: douganderson444.ar or 'douganderson444.arweave.dev' || 'douganderson444.ar.page';
const did = await arnsResolver(arnsName);

console.log(did); // did:ar:UGnqpxdraMbkmG-4F6jU7xkFhErNgaXLQf39tW7yYck

Update DID Document

To update, just pass the new DID Doc properties you wish to update. Then, did-ar verifies that the caller is the wallet owner (and by extention the did:ar owner). If anyone other than the owner of the contract tries to update the did document, the contract will only return the current DID Doc state.

The contract then replaces the old DID Document properties with the new properties.

const id = did;
let didDoc; // exsiting DID Doc

const replaceProperties = {
	service: [
		...didDoc.service, // keep existing service listings
		{
			id: `${did}#linked-domain`,
			type: 'LinkedDomains',
			serviceEndpoint: 'https://douganderson444.arweave.dev'
		}
	]
};

await didar.update({ id, ...replaceProperties }); // will change service property of DID Doc

Transfer

You can add or transfer controller of this DID by adding/changing the array of controllers.

⚠️ Be careful! Only the controller can update the DID Doc. Make sure you know what you are doing here. ⚠️

Controllers

Transfer is just an update where the controller is updated. Send an update command with the added/changed controller property:

const id = did;
let didDoc; // exsiting DID Doc

const replaceProperties = {
	...didDoc,
	controller: ['did:ar:newControllerDID']
};

await didar.update({ id, ...replaceProperties }); // will change the controller (ie owner) of DID Doc

Delete

TODO: Implement ANS-106 Do Not Store Request

What can you do with a DeID?

You can grab the keys out of the document. From the RSA key, you can get an Arweave address and look up their Arweave data. You can grab their DAG from ArDAG and interact with that data and apps too.

Forking The Smart Contract

With Arweave, using Warp Contract's deployFromSourceTx you can use an existing deployed contract and add your own initial state to make a new DID Doc.

TODO: List published version so others can deploy from source.

References

DID Core W3C Reccomendation

JOSE JWK RFC