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

@vecrea/oid4vc-prex

v0.1.0

Published

A TypeScript library for handling OpenID for Verifiable Credentials (OID4VC) Presentation Exchange operations

Readme

OID4VC Presentation Exchange Library

A TypeScript library for handling OpenID for Verifiable Credentials (OID4VC) Presentation Exchange operations, providing comprehensive support for Presentation Definitions and Presentation Submissions according to the Presentation Exchange specification.

Features

  • Presentation Definition Support: Full implementation of Presentation Definition types and validation
  • Presentation Submission Handling: Parse and validate Presentation Submissions from various embed locations
  • JSON Path Operations: Utilities for JSON Path validation and extraction
  • Type Safety: Complete TypeScript support with comprehensive type definitions
  • Multiple Embed Locations: Support for JWT, OIDC, DIDComms, VP, and CHAPI embed locations

Installation

npm install @vecrea/oid4vc-prex

Quick Start

import { PresentationExchange, JsonPathOps } from '@vecrea/oid4vc-prex';

// Parse a Presentation Submission
const jsonString = '{"presentation_submission": {...}}';
const result =
  await PresentationExchange.jsonParse.decodePresentationSubmission(jsonString);

if (result.isSuccess()) {
  const submission = result.value;
  console.log('Submission ID:', submission.id);
} else {
  console.error('Failed to parse:', result.error);
}

// Validate JSON Path
const isValid = JsonPathOps.isValid('$.credential.credentialSubject.id');
console.log('Is valid JSON Path:', isValid);

// Extract data using JSON Path
const jsonData =
  '{"credential": {"credentialSubject": {"id": "did:example:123"}}}';
const extracted = JsonPathOps.getJsonAtPath(
  '$.credential.credentialSubject.id',
  jsonData
);
console.log('Extracted value:', extracted);

API Reference

PresentationExchange

The main entry point for the library.

jsonParse.decodePresentationSubmission(input)

Parses a Presentation Submission from a JSON string or ReadableStream.

Parameters:

  • input: string | ReadableStream<Uint8Array> - The JSON input

Returns: Promise<Result<PresentationSubmission>>

Example:

const result =
  await PresentationExchange.jsonParse.decodePresentationSubmission(jsonString);

JsonPathOps

Utility class for JSON Path operations.

JsonPathOps.isValid(path)

Validates if a string is a valid JSON Path.

Parameters:

  • path: string - The JSON Path to validate

Returns: boolean

JsonPathOps.getJsonAtPath(jsonPath, jsonString)

Extracts data from JSON using a JSON Path.

Parameters:

  • jsonPath: string - The JSON Path expression
  • jsonString: string - The JSON string to extract from

Returns: string - The extracted value as a JSON string

Types

The library exports comprehensive TypeScript types for all Presentation Exchange components:

  • JSONSchema - JSON Schema type alias for version 7
  • Constraints - Constraint definitions for input descriptors
  • DescriptorMap - Descriptor mapping specifications
  • FieldConstraint - Field-level constraint definitions
  • Filter - Filter specifications for credential filtering
  • Format - Format definitions for credential formats
  • From - Source specification for credentials
  • Group - Group definitions for organizing input descriptors
  • Id - Identifier types
  • InputDescriptor - Input descriptor specifications
  • InputDescriptorId - Input descriptor identifier types
  • JsonObject - JSON object type definitions
  • JsonPath - JSON Path type definitions
  • Name - Name type definitions
  • NonEmptySet - Non-empty set type definitions
  • PresentationDefinition - Core presentation definition structure
  • PresentationSubmission - Presentation submission data
  • Purpose - Purpose definitions for input descriptors
  • Rule - Rule definitions for constraints
  • SubmissionRequirement - Submission requirement specifications

Embed Locations

The library supports parsing Presentation Submissions from various embed locations:

  • JWT: Embedded in JWT tokens
  • OIDC: Embedded in OpenID Connect flows
  • DIDComms: Embedded in DID Communication messages
  • VP: Embedded in Verifiable Presentations
  • CHAPI: Embedded in Credential Handler API responses

Development

Prerequisites

  • Node.js 18+
  • npm or yarn

Setup

npm install

Build

npm run build

Testing

npm test

Type Checking

npm run typecheck

Linting

npm run lint

License

Licensed under the Apache License, Version 2.0. See the LICENSE file for details.

Contributing

This project follows the Presentation Exchange specification. When contributing, please ensure compliance with the specification and maintain type safety.

Related Links