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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@agentcommercekit/did

v0.9.0

Published

DID (Decentralized Identifier) and DID document utilities with support for multiple DID methods.

Readme

@agentcommercekit/did

DID (Decentralized Identifier) and DID document utilities with support for multiple DID methods.

This package is part of the Agent Commerce Kit.

Installation

npm i @agentcommercekit/did
# or
pnpm add @agentcommercekit/did

Usage

Basic DID Resolution

import { getDidResolver, resolveDid } from "@agentcommercekit/did"
import type { DidUri } from "@agentcommercekit/did"

// Create a resolver with support for did:web, did:key, and did:pkh methods
const resolver = getDidResolver()

// Resolve a DID
const { did, didDocument } = await resolveDid("did:web:example.com", resolver)

Resolving DIDs with Controllers

import { getDidResolver, resolveDidWithController } from "@agentcommercekit/did"

const resolver = getDidResolver()

// Resolve a DID and its controller
const { did, didDocument, controller } = await resolveDidWithController(
  "did:web:example.com",
  resolver
)

Creating DID URIs

import {
  createDidWebUri,
  createDidKeyUri,
  createDidPkhUri
} from "@agentcommercekit/did"
import { generateKeypair } from "@agentcommercekit/keys"

// Create a did:web URI from a domain or URL
const webDid = createDidWebUri("https://www.example.com")
// did:web:example.com

// Create a did:key URI from a keypair
const keypair = await generateKeypair("secp256k1")
const keyDid = createDidKeyUri(keypair)
// did:key:zQ3...

// Create a did:pkh URI from an address and chain ID
const pkhDid = createDidPkhUri(
  "eip155:1",
  "0x1234567890123456789012345678901234567890"
)
// did:pkh:eip155:1:0x1234567890123456789012345678901234567890

Creating DID Documents

import { generateKeypair } from "@agentcommercekit/keys"
import {
  createDidDocumentFromKeypair,
  createDidWebDocumentFromKeypair
} from "@agentcommercekit/did"

const keypair = await generateKeypair("secp256k1")

// Create a DID document from a keypair
const did = createDidKeyUri(keypair)

const didDocument = createDidDocumentFromKeypair({
  did,
  keypair,
  encoding: "jwk", // Optional, defaults to "jwk"
  controller: "did:web:controller.example.com" // Optional
})

// Create a did:web and document with URI and document
const { did, didDocument } = createDidWebDocumentFromKeypair({
  keypair,
  baseUrl: "https://www.example.com",
  controller: ownerDid
})

API Reference

DID URIs

  • createDidWebUri(input: string | URL): DidWebUri - Create a did:web URI from a domain or URL
  • createDidKeyUri(keypair: Keypair): DidKeyUri - Create a did:key URI from a keypair
  • createDidPkhUri(chainId: DidPkhChainId, address: string): DidPkhUri - Create a did:pkh URI from an address and chain ID

Resolution

  • getDidResolver(options?: GetDidResolverOptions): DidResolver - Create a resolver supporting multiple DID methods
  • resolveDid(didUri: string, resolver: Resolvable): Promise<DidUriWithDocument> - Resolve a DID to its document
  • resolveDidWithController(didUri: string, resolver: Resolvable): Promise<DidUriWithControlledDidDocument> - Resolve a DID and its controller

DID Document Creation

  • createDidDocument(options: CreateDidDocumentOptions): DidDocument - Create a generic DID document
  • createDidDocumentFromKeypair(options: CreateDidDocumentFromKeypairOptions): DidDocument - Create a DID document from a keypair
  • createDidWebDocument(options: CreateDidWebDocumentOptions): DidUriWithDocument - Create a DidWebUri and associated document document
  • createDidPkhDocument(options: CreateDidPkhDocumentOptions): DidUriWithDocument - Create a DidPkhUri and associated document

Validation

  • isDidUri(value: unknown): value is DidUri - Check if a value is a valid DID URI
  • isDidDocument(value: unknown): value is DidDocument - Check if a value is a valid DID document
  • isDidDocumentForDid(didDocument: DidDocument, did: string): boolean - Check if a document belongs to a DID

Schema Validation

// Zod v4 schemas
import { didUriSchema } from "@agentcommercekit/did/schemas/zod/v4"

// Zod v3 schemas
import { didUriSchema } from "@agentcommercekit/did/schemas/zod/v3"

// Valibot schemas
import { didUriSchema } from "@agentcommercekit/did/schemas/valibot"

License (MIT)

Copyright (c) 2025 Catena Labs, Inc.