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

ondc-metro-qr-generator

v0.0.5

Published

Typed ONDC metro QR payload and PNG generation for supported BPP policies.

Readme

ondc-metro-qr-generator

Typed TypeScript utilities for generating ONDC metro ticket QR payloads and QR PNG images across supported metro BPPs.

Generates QR payloads and pure QR PNGs for these metro BPPs by adhering to their QR generation guidelines:

  • BMRCL
  • DMRC
  • MMMOCL
  • MMOPL
  • MMRCL

Install

bun add ondc-metro-qr-generator
# or
npm install ondc-metro-qr-generator

Usage

import { MetroQR } from 'ondc-metro-qr-generator'

const payload = MetroQR.dmrc({
  token: 'qr-token',
})
const { png } = await MetroQR.renderPng({
  payload,
  qrOptions: {
    errorCorrectionLevel: 'M',
    margin: 1,
    width: 512,
  },
})

The package selects its PNG renderer through conditional exports. Cloudflare Workers, Node.js, and Bun use the qrcode server implementation; browser bundlers use the Canvas-based browser implementation. The public API and PNG return type are identical in every runtime.

Supported Policies

| BPP | Policy | | --- | --- | | BMRCL | Dynamic timestamp QR | | DMRC | Static QR | | MMMOCL | Base64 decoded byte-mode QR | | MMOPL | Static QR | | MMRCL | Static QR |

Supported production BPP ids are the top-level BppID constants. Their exact preprod ids are grouped under BppID.preprod in src/policies.ts. Those are the only BPP ids this package supports.

Provider Policy Documents

Examples

High-Level Provider API

import { MetroQR } from 'ondc-metro-qr-generator'

const bmrclPayload = MetroQR.bmrcl({
  nowMs: Date.now(),
  token: 'qr-token',
})
const dmrcPayload = MetroQR.dmrc({
  token: 'qr-token',
})
const mmmoclPayload = MetroQR.mmmocl({
  token: 'TU1NT/8AfA==',
})
const mmoplPayload = MetroQR.mmopl({
  token: 'qr-token',
})
const mmrclPayload = MetroQR.mmrcl({
  token: 'qr-token',
})
import { MetroQR } from 'ondc-metro-qr-generator'

const payload = MetroQR.dmrc({
  token: 'qr-token',
})
const { png } = await MetroQR.renderPng({
  payload,
  qrOptions: {
    width: 512,
  },
})

BMRCL Offline Refresh

import { MetroQR } from 'ondc-metro-qr-generator'

// Cache the BMRCL QR token from the confirmed ticket while online.
const cachedBmrclQrToken = await ticketStore.get('bmrcl-qr-token')

async function refreshBmrclQrPng({ nowMs = Date.now() } = {}) {
  const payload = MetroQR.bmrcl({
    nowMs,
    token: cachedBmrclQrToken,
  })

  return MetroQR.renderPng({
    payload,
    qrOptions: {
      width: 512,
    },
  })
}

// The provider token stays cached; the BMRCL dynamic QR block refreshes locally.
const { png } = await refreshBmrclQrPng()
setInterval(refreshBmrclQrPng, 30_000)

Low-Level API

import { BppID, buildMetroQrPayload } from 'ondc-metro-qr-generator'

const payload = buildMetroQrPayload({
  bppId: BppID.MMMOCL,
  token: 'TU1NT/8AfA==',
})
import { BppID, renderMetroQrPng } from 'ondc-metro-qr-generator'

const { png } = await renderMetroQrPng({
  bppId: BppID.BMRCL,
  token: 'qr-token',
  width: 512,
})
import { BppID, getMetroQrPolicy } from 'ondc-metro-qr-generator'

const policy = getMetroQrPolicy({ bppId: BppID.DMRC })

Contributing

Contributions are welcome for additional language packages, QR integrity tests, documentation, and BPP QR generation policies. We especially encourage BPPs to add their respective policy documents and methodologies for Pune, Chennai, Kochi, Nagpur, and other ONDC metro networks.

See CONTRIBUTING.md for contribution requirements.

Acknowledgements

This package exists for the ONDC metro ecosystem and uses provider QR policy documents shared by Sequel String.

Runtime and validation dependencies include node-qrcode for QR PNG generation and zxing-wasm for QR decode integrity tests. The package is built with Bun, TypeScript, Biome, publint, and Are the Types Wrong?.

License

Apache-2.0. See LICENSE and NOTICE.