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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@rollercoaster-dev/openbadges-core

v0.1.1

Published

Shared core library for Open Badges functionality across Rollercoaster.dev applications

Readme

@rollercoaster-dev/openbadges-core

Shared core library for Open Badges functionality across Rollercoaster.dev applications.

Purpose

This package provides shared utilities and core functionality for working with Open Badges across both the modular server and the system app. It eliminates code duplication by centralizing:

  • Badge baking utilities - PNG metadata embedding for badge images
  • Cryptographic operations - Signing, verification, and key management
  • Credential generation - Badge creation and validation logic
  • Platform detection - Runtime environment detection for Node.js and Bun

Installation

From npm

npm install @rollercoaster-dev/openbadges-core
# or
bun add @rollercoaster-dev/openbadges-core

In monorepo workspace

{
  "dependencies": {
    "@rollercoaster-dev/openbadges-core": "workspace:*"
  }
}

Usage

import {
  detectPlatform,
  isBun,
  isNode,
} from "@rollercoaster-dev/openbadges-core";

// Detect runtime platform
const platform = detectPlatform(); // "node" | "bun" | "unknown"

// Check specific platforms
if (isBun()) {
  // Use Bun-specific APIs
}

if (isNode()) {
  // Use Node.js-specific APIs
}

API Overview

Platform Detection

  • detectPlatform() - Detect current runtime environment ("node" | "bun" | "unknown")
  • isBun() / isNode() / isReactNative() - Check specific platforms
  • configure() - Set platform adapters (crypto, key provider) for React Native
  • getPlatformConfig() / resetPlatformConfig() - Read or reset configuration
  • assertBufferAvailable() - Guard for Buffer-dependent features (PNG baking)

Badge Baking

  • bakePNG(image, credential) - Embed credential into PNG via iTXt chunk
  • unbakePNG(image) - Extract credential from a baked PNG
  • isPNG(buffer) - Check if a buffer is a valid PNG image
  • Types: ImageFormat, BakeOptions, BakedImage, UnbakeResult, BakingService, Chunk

Crypto Utilities

  • Signing: signData(), verifySignature() - Raw data signing/verification
  • Data Integrity Proofs: createDataIntegrityProof(), verifyDataIntegrityProof()
  • JWT Proofs: generateJWTProof(), verifyJWTProof(), isJWTProof(), getRecommendedAlgorithm()
  • Key Management: KeyProvider interface, InMemoryKeyProvider, KeyStatus
  • Key Detection: detectKeyType(), KeyType, Cryptosuite
  • Platform Adapters: CryptoProvider, NodeCryptoAdapter
  • Types: KeyAlgorithm, KeyMetadata, KeyPairResult, DataIntegrityProof, JWTProof, JWTProofPayload, ProofVerificationResult, SupportedJWTAlgorithm, PlatformConfig

Credential Generation

  • buildCredential(options) - Build an OB3 verifiable credential
  • serializeOB3(credential) - Serialize credential to OB3 format
  • createSerializer(version) - Factory for version-specific serializers
  • Serializers: OpenBadges2Serializer, OpenBadges3Serializer
  • Version Detection: detectBadgeVersion(), BadgeVersion
  • Types: IssuerData, BadgeClassData, AssertionData, RecipientData, VerificationData, VerifiableCredentialData, CredentialOptions, BadgeSerializer

Development

# Build the package
bun run build

# Run type checking
bun run type-check

# Run linting
bun run lint

# Run tests
bun test

# Watch mode
bun test --watch

Platform Configuration

Node.js / Bun (zero config)

No setup needed. The package auto-initializes with NodeCryptoAdapter and InMemoryKeyProvider:

import { signData } from "@rollercoaster-dev/openbadges-core";

// Just works — no configure() call required
const jws = await signData(data, privateKey);

React Native

Call configure() at app startup before any crypto operations:

import { configure } from "@rollercoaster-dev/openbadges-core";
import { ExpoCryptoAdapter } from "./adapters/expo-crypto";
import { SecureStoreKeyProvider } from "./adapters/secure-store";

configure({
  crypto: new ExpoCryptoAdapter(),
  keyProvider: new SecureStoreKeyProvider(),
});

Custom Providers

Implement the CryptoProvider interface for your platform:

import type { CryptoProvider } from "@rollercoaster-dev/openbadges-core";

class MyCryptoAdapter implements CryptoProvider {
  async sign(
    data: string,
    privateKey: JWK,
    algorithm: string,
  ): Promise<string> {
    /* ... */
  }
  async verify(
    data: string,
    signature: string,
    publicKey: JWK,
    algorithm: string,
  ): Promise<boolean> {
    /* ... */
  }
  async generateKeyPair(
    algorithm: "Ed25519" | "RSA",
  ): Promise<{ publicKey: JWK; privateKey: JWK }> {
    /* ... */
  }
}

Platform Support

| Module | Node.js/Bun | React Native | Browser | | ------------------------------ | ------------------------------- | ---------------------------------------- | ----------------------------- | | Credentials | Yes | Yes | Yes | | Crypto (signing, verification) | Yes | Yes (via configure()) | Yes (via jose / Web Crypto) | | KeyProvider | InMemoryKeyProvider (default) | SecureStoreKeyProvider (user-provided) | Not yet | | PNG Baking | Yes | No (Buffer required) | No (Buffer required) |

Browser/Vue future possibility: The crypto and credentials modules already work in browsers since they're built on jose (which uses Web Crypto API). Full browser support would require refactoring the baking module from Buffer to Uint8Array and adding a browser KeyProvider (e.g. IndexedDB). The same configure() pattern would cover this.

Architecture

This package follows a modular structure:

src/
├── baking/        # Badge baking utilities (PNG metadata)
├── crypto/        # Cryptographic operations
├── credentials/   # Credential generation and validation
├── types/         # Shared type definitions
└── platform.ts    # Runtime platform detection

Dependencies

  • openbadges-types - Open Badges type definitions
  • @rollercoaster-dev/rd-logger - Structured logging

License

MIT

Links