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

dcql

v0.2.21

Published

Digital Credentials Query Language (DCQL)

Downloads

5,006

Readme

DCQL (Digital Credentials Query Language)

A TypeScript implementation of the Digital Credentials Query Language (DCQL, pronounced [ˈdakl̩]) - a JSON-encoded query language for requesting and validating Verifiable Presentations.

Overview

DCQL enables Verifiers to request Verifiable Presentations that match specific queries. The library provides functionality to:

  • Create and validate DCQL queries
  • Match queries against Verifiable Credentials
  • Validate presentation results
  • Handle various credential formats including mso_mdoc and dc+sd-jwt and w3c vc's.
  • Create and parse DCQL queries from OID4VP Draft 22/23 and Draft 24.

Installation

npm install dcql
# or
yarn add dcql
# or
pnpm add dcql

Quick Start

import { DcqlQuery, DcqlPresentationResult } from 'dcql';

// Create a DCQL query
const query = {
  credentials: [{
    id: 'my_credential',
    format: 'mso_mdoc',
    meta: { doctype_value: 'org.iso.7367.1.mVRC' },
    claims: [
      { 
        path: ['org.iso.7367.1', 'vehicle_holder'], 
        intent_to_reatin: true 
      },
      { 
        path: ['org.iso.18013.5.1', 'first_name'] 
      },
    ],
  }]
};

// Parse (structural) and validate (content) the query
const parsedQuery = DcqlQuery.parse(query);
DcqlQuery.validate(parsedQuery);

// Execute the query against credentials
const queryResult = DcqlQuery.query(parsedQuery, credentials);

Features

  • Query Construction: Build structured DCQL queries with type safety
  • Validation: Comprehensive query validation and parsing
  • Credential Matching: Match credentials against query requirements
  • Result Processing: Process and validate presentation results
  • Type Safety: Full TypeScript support with detailed type definitions
  • Format Support: Support for multiple credential formats
  • Extensible: Easy to extend for custom credential formats

Query Result Structure

The query result provides detailed information about the match:

const queryResult = DcqlQuery.query(query, credentials);

// Check if query can be satisfied
console.log(queryResult.canBeSatisfied);

// Access matched credentials
console.log(queryResult.credential_matches);

// The result of a specific credential query
const credentialMatch = queryResult.credential_matches['credential_query_id'];
console.log(credentialMatch.success);                 // True if the query is fulfillable
console.log(credentialMatch.input_credential_index);  // The index of the best matching input credential
console.log(credentialMatch.claim_set_index);         // The index of the claim_set that matched
console.log(credentialMatch.output);                  // The credential parse output

Validating Presentations

Validate presentation results against queries:

const presentationQueryResult = DcqlPresentationResult.fromDcqlPresentation(
  {
    my_credential: {
      credential_format: 'mso_mdoc' as const,
      doctype: 'org.iso.7367.1.mVRC',
      namespaces: {
        'org.iso.7367.1': { vehicle_holder: 'Martin Auer' },
        'org.iso.18013.5.1': { first_name: 'Martin Auer' },
      }
    }
  },
  { dcqlQuery: query }
);

assert.deepStrictEqual(presentationQueryResult, {
  credentials: [
    {
      id: "my_credential",
      format: "mso_mdoc",
      claims: [
        { path: ["org.iso.7367.1", "vehicle_holder"] },
        { path: ["org.iso.18013.5.1", "first_name"] },
      ],
      meta: { doctype_value: "org.iso.7367.1.mVRC" },
    },
  ],
  canBeSatisfied: true,
  valid_matches: {
    my_credential: {
      typed: true,
      success: true,
      output: {
        credential_format: "mso_mdoc",
        doctype: "org.iso.7367.1.mVRC",
        namespaces: {
          "org.iso.7367.1": { vehicle_holder: "Martin Auer" },
          "org.iso.18013.5.1": { first_name: "Martin Auer" }
        },
      },
      claim_set_index: undefined,
      presentation_id: "my_credential",
    },
  },
  invalid_matches: undefined,
  credential_sets: undefined,
})