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

web-identity-schemas

v0.2.0

Published

TypeScript types and validation schemas for Web Identity and JOSE standards, including:

Readme

Web Identity Schemas

TypeScript types and validation schemas for Web Identity and JOSE standards, including:

  • Decentralized Identifiers (DID)
  • Verifiable Credentials (VC) v1.1 and v2.0, with StatusList2021, Bitstring Status List
  • Verifiable Presentations (VP)
  • JSON Web Tokens (JWT)
  • JSON Web Keys (JWK)
  • JSON Web Signatures (JWS)
  • See the full list

This library provides both Valibot and Zod (v4) validation implementations with comprehensive type safety.

Installation

npm install web-identity-schemas

Quick Start

Valibot

import * as v from "valibot"
import {
  DidSchema,
  JwkSchema,
  VerifiableCredentialSchema
} from "web-identity-schemas/valibot"

// Validate a DID
const validDid = v.parse(DidSchema, "did:example:123456789abcdefghi")

// Validate a Verifiable Credential
const validVc = v.parse(VerifiableCredentialSchema, {
  "@context": "https://www.w3.org/2018/credentials/v1",
  type: "VerifiableCredential",
  issuer: "did:example:issuer",
  issuanceDate: "2023-01-01T00:00:00Z",
  credentialSubject: {
    id: "did:example:subject",
    degree: "Bachelor of Science"
  }
})

// Validate cryptographic keys
const validKey = v.parse(JsonWebKeySchema, {
  kty: "EC",
  crv: "P-256",
  x: "MKBCTNIcKUSDii11ySs3526iDZ8AiTo7Tu6KPAqv7D4",
  y: "4Etl6SRW2YiLUrN5vfvVHuhp7x8PxltmWWlbbM4IFyM"
})

Zod v4

import * as z from "zod"
import {
  DidSchema,
  JwkSchema,
  VerifiableCredentialSchema
} from "web-identity-schemas/zod"

// Validate a DID
const validDid = DidSchema.parse("did:example:123456789abcdefghi")

// Validate a Verifiable Credential
const validVc = VerifiableCredentialSchema.parse({
  "@context": "https://www.w3.org/2018/credentials/v1",
  type: "VerifiableCredential",
  issuer: "did:example:issuer",
  issuanceDate: "2023-01-01T00:00:00Z",
  credentialSubject: {
    id: "did:example:subject",
    degree: "Bachelor of Science"
  }
})

// Validate cryptographic keys
const validKey = JsonWebKeySchema.parse({
  kty: "EC",
  crv: "P-256",
  x: "MKBCTNIcKUSDii11ySs3526iDZ8AiTo7Tu6KPAqv7D4",
  y: "4Etl6SRW2YiLUrN5vfvVHuhp7x8PxltmWWlbbM4IFyM"
})

Type Safety

All types are also available as Typescript types at the root of the package, and in each schema export

import type { Did, DidDocument, JwtString } from "web-identity-schemas"
// or from "web-identity-schemas/valibot"
// or from "web-identity-schemas/zod"

const jwt: JwtString = "..."

const did: Did = "did:method:something"
const didWeb: Did<"web"> = "did:web:example.com"

const didDocument: DidDocument = {
  // ...
}

Available Schemas

This library exports comprehensive schemas for Web Identity and JOSE standards. All schemas are available in both Valibot and Zod implementations, with corresponding TypeScript types.

Core Web Identity Schemas

Decentralized Identifiers (DIDs)

  • DidSchema - Validates DID strings (e.g., did:example:123)
  • DidUrlSchema - Validates DID URLs with paths/queries/fragments
  • DidDocumentSchema - Validates DID Documents
  • VerificationMethodSchema - Validates verification methods in DID Documents
  • ServiceSchema - Validates service endpoints in DID Documents

Verifiable Credentials (VCs)

  • VerifiableCredentialSchema - Universal VC validator (v1.1 and v2.0)
  • VerifiableCredentialV1Schema - Specific v1.1 VC validator
  • VerifiableCredentialV2Schema - Specific v2.0 VC validator
  • VerifiablePresentationSchema - Validates verifiable presentations

JSON Web Tokens (JWTs)

  • JwtObjectSchema - Validates JWT objects (header + payload)
  • JwtStringSchema - Validates JWT strings in compact format
  • JwtHeaderSignedSchema - Validates JWT headers for signed tokens
  • JwtPayloadSchema - Validates JWT payloads

JSON Web Keys (JWKs)

Cryptographic Schemas

Specific JWK Types

Cryptographic Curves

  • EllipticCurveSchema - Elliptic curve names (P-256, P-384, etc.)
  • OctetKeyPairCurveSchema - OKP curve names (Ed25519, X25519)

JOSE Specifications

JSON Web Signatures (JWS)

JSON Web Encryption (JWE)

JOSE Algorithms

  • JoseAlgorithmSchema - All JOSE algorithms
  • JoseSignatureAlgorithmSchema - Signature algorithms (RS256, ES256, etc.)
  • JweContentEncryptionAlgorithmSchema - Content encryption algorithms
  • JweKeyManagementAlgorithmSchema - Key management algorithms

Status and Proof Schemas

Credential Status

  • StatusList2021CredentialSchema - StatusList2021 credentials
  • BitstringStatusListCredentialSchema - Bitstring status credentials

Proof Systems

Utility Schemas

Common Formats

Contributing

Contributions are welcome.

This library maintains strict type safety and comprehensive test coverage. Both Valibot and Zod implementations must pass identical test suites to ensure consistency.

See CLAUDE.md for detailed development guidelines and schema patterns.

License (MIT)

Copyright (c) 2025 Catena Labs, Inc. See LICENSE for details.