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

@learncard/open-badge-v2-plugin

v1.0.12

Published

OpenBadge v2 wrapper plugin for LearnCard. Wraps OBv2 assertions into self-issued VCs.

Readme

@learncard/open-badge-v2-plugin

Wrap legacy Open Badges v2.0 (OBv2) assertions into self‑issued W3C Verifiable Credentials (VCs) so they can be stored, indexed, and used within the LearnCard ecosystem.

  • Name: OpenBadgeV2
  • Method: wrapOpenBadgeV2(obv2Assertion: object | string): Promise<VC>
  • Context added: https://ctx.learncard.com/wrappers/obv2/1.0.0.json
  • VC type produced: LegacyOpenBadgeCredential

Why this plugin?

Many issuers still publish Open Badges v2.0 assertions (JSON), not VCs. This plugin provides a backwards‑compatibility bridge by wrapping the raw OBv2 assertion inside a signed VC you control, preserving the original badge payload under legacyAssertion.

This enables:

  • Use of legacy badges anywhere a VC is expected (storage, indexing, sharing).
  • A stable LearnCard vocabulary for the wrapper (LegacyOpenBadgeCredential).
  • Consistent DID‑based signing and verification workflows.

What it produces

A signed VC with these characteristics:

  • @context: ["https://www.w3.org/ns/credentials/v2", "https://ctx.learncard.com/wrappers/obv2/1.0.0.json"]
  • type: ["VerifiableCredential", "LegacyOpenBadgeCredential"]
  • issuer: your LearnCard DID
  • validFrom: new Date().toISOString()
  • credentialSubject.id: your LearnCard DID
  • legacyAssertion: the original OBv2 assertion JSON

Notes:

  • The wrapper signs the fact that “you attest to this legacy assertion,” not that you were the original OBv2 issuer.
  • Minimal OBv2 validation is performed: id (string), type includes "Assertion", issuedOn (string).

Requirements

  • A LearnCard instance with the VC plugin installed (used to sign the VC).
  • Fetch available for remote inputs (Node 18+ or a polyfill like undici).

Installation

This package is part of the monorepo. In external usage, install from npm (when published) and ensure peer packages are available.

# inside the monorepo
pnpm nx run open-badge-v2-plugin:build

Usage

Below examples assume you already have a learnCard instance and you add both the VC plugin and this plugin.

import { getVCPlugin } from '@learncard/vc-plugin';
import { openBadgeV2Plugin } from '@learncard/open-badge-v2-plugin';

// Ensure VC plugin is installed first (required for signing)
await learnCard.addPlugin(getVCPlugin(learnCard));

// Install the OpenBadge v2 wrapper plugin
await learnCard.addPlugin(openBadgeV2Plugin(learnCard));

1) Wrap from a remote HTTP(S) URL

const url = 'https://example.org/badges/assertions/123.json';
const vc = await learnCard.invoke.wrapOpenBadgeV2(url);

// Optional: verify the signed VC
const verification = await learnCard.invoke.verifyCredential(vc);

2) Wrap from IPFS

const ipfsUrl = 'ipfs://bafybeigdyr...';
const vc = await learnCard.invoke.wrapOpenBadgeV2(ipfsUrl);

3) Wrap from a raw OBv2 object

const obv2 = {
  '@context': 'https://w3id.org/openbadges/v2',
  type: 'Assertion',
  id: 'https://issuer.example.org/assertions/abc',
  issuedOn: '2024-05-02T12:34:56Z',
  recipient: { type: 'email', identity: '[email protected]', hashed: false },
  badge: 'https://issuer.example.org/badges/my-badge'
  // ... any other OBv2 fields ...
};

const vc = await learnCard.invoke.wrapOpenBadgeV2(obv2);

4) Wrap from a JSON string

const obv2String = JSON.stringify(obv2);
const vc = await learnCard.invoke.wrapOpenBadgeV2(obv2String);

API

wrapOpenBadgeV2(obv2Assertion: object | string): Promise<VC>
  • obv2Assertion may be:
    • A raw OBv2 assertion object
    • A URL string (http(s)://, ipfs://, ipns://) pointing to the assertion JSON
    • A JSON string containing the assertion

Validation rules enforced:

  • assertion.id must be a non‑empty string
  • assertion.type must include "Assertion"
  • assertion.issuedOn must be a string

JSON‑LD Context

The wrapper vocabulary is published at:

  • https://ctx.learncard.com/wrappers/obv2/1.0.0.json

It defines:

  • LegacyOpenBadgeCredential
  • legacyAssertion as @type: @json for embedding raw OBv2 JSON

Development

  • Build: pnpm nx run open-badge-v2-plugin:build
  • Source: packages/plugins/open-badge-v2/src/
  • Context file: packages/learn-card-contexts/wrappers/obv2/1.0.0.json

Caveats

  • Wrapping does not retroactively convert OBv2 into a first‑party VC issued by the original badge issuer; it produces a VC signed by your DID that embeds the legacy assertion.
  • Always fetch and wrap assertions from trusted sources.

License

MIT