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

@gramota/qr

v0.4.0

Published

QR-code rendering for EUDIW deep links — OID4VP authorization requests and OID4VCI credential offers, with Strategy-pluggable renderers.

Downloads

200

Readme

@gramota/qr

QR-code rendering for EUDIW deep links. Strategy-pluggable renderer, three input shapes (any URL, OID4VP authorization request, OID4VCI credential offer), three output formats (data URL, SVG, raw PNG bytes).

Part of Gramota — the TypeScript SDK for the EU Digital Identity Wallet.

Install

pnpm add @gramota/qr
# or: npm install @gramota/qr

Quick example

import { qr } from "@gramota/qr";

const code = qr.fromUrl("openid4vp://?client_id=...&request_uri=...");

const dataUrl = await code.toDataUrl();   // <img src={dataUrl} />
const svg     = await code.toSvg();       // for innerHTML / SSR
const png     = await code.toPng();       // Uint8Array — fs.writeFile, multipart upload

Three input shapes

qr.fromUrl(url, options?) — most general. Any string with a <scheme>: prefix.

qr.fromAuthorizationRequest(request, options?) — composes with @gramota/oid4vp. Takes a typed AuthorizationRequest, builds the openid4vp:// deep link, renders the QR. Override the scheme via { scheme: "haip://" } for vendor-specific wallets.

qr.fromCredentialOffer(offer, options?) — composes with @gramota/oid4vci. Takes a typed CredentialOffer, builds the openid-credential-offer:// deep link, renders the QR.

Three output formats — lazy + memoised

code.toDataUrl(), code.toSvg(), code.toPng() each invoke the configured renderer on first call and cache the result. Concurrent first-callers share the in-flight render — no thundering herd. Pay the encode cost once per format, only for the formats you actually use.

Pluggable renderer (Strategy pattern)

The default is DefaultQrRenderer — an Adapter over the qrcode npm package. Want logo embedding, branded colours, a browser-native canvas renderer? Implement QrRenderer:

import type { QrRenderer, QrFormat, QrOptions } from "@gramota/qr";

class BrandedQrRenderer implements QrRenderer {
  async render(url: string, format: QrFormat, opts: QrOptions) {
    // …your renderer (e.g. with a logo overlaid in the centre)…
  }
}

const code = qr.fromUrl(url, { renderer: new BrandedQrRenderer() });

The orchestrator depends only on the QrRenderer interface, never on qrcode directly. You can swap the rendering backend without touching your verifier or issuer code.

Design

@gramota/qr is small but follows the same patterns as the rest of the SDK:

  • Strategy (GoF) — QrRenderer interface with a default Adapter over qrcode. Add new renderers by implementing the interface.
  • Factory Method (GoF) — qr.from* family creates QrCode instances from different input shapes; new sources add as siblings, no existing factory changes.
  • Adapter (GoF) — DefaultQrRenderer adapts qrcode's API to ours. Replacing qrcode later means a one-file change here, zero changes for consumers.
  • Lazy + memoisation — output formats render on first call only; concurrent first-callers share the promise.
  • Open/Closed, Dependency Inversion — the orchestrator depends on the abstraction; concrete implementations plug in via DI.

For the high-level wallet + verifier counterparts, see the main repo.

License

Apache 2.0