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

sunasty-qr-payload

v1.0.0

Published

Zero-dependency structured QR payload parser (Wi-Fi, 2FA TOTP otpauth://, vCard, mailto, MATMSG, SMS, tel, URL security analyzer) and RFC 6238 TOTP generator via Web Crypto SubtleCrypto.

Readme

sunasty-qr-payload

Zero-dependency JavaScript and TypeScript parser for structured QR code payloads (WIFI:, otpauth://totp/, BEGIN:VCARD, mailto:, MATMSG:, smsto:, sms:, tel:, and HTTP/HTTPS URLs with security inspection) paired with a Web Crypto SubtleCrypto RFC 6238 TOTP generator and RFC 4180 CSV/JSON serializers.

Extracted from the core engine powering the Sunasty QR Scanner and Sunasty QR Code Generator.

Features

  • Structured QR Payload Parser: parseQrPayload normalizes raw QR strings into a strongly typed discriminated union (wifi, totp, vcard, email, sms, phone, url, text).
  • RFC 6238 TOTP Generator: generateTotpCode computes 6-digit (or N-digit) HMAC-SHA1 time-based one-time passwords using the standard Web Crypto SubtleCrypto API in Node.js (>= 18), browsers, and Service Workers.
  • URL Security Inspection: analyzeUrlSecurity detects unencrypted http:// links and raw IPv4/IPv6 hostnames before navigation.
  • Low-Contrast Image Preprocessors: applyHighContrastThreshold and normalizeAndBinarizeLowContrast prepare RGBA buffers for QR matrix detection.
  • Batch History Export: serializeScanHistoryToCsv (RFC 4180 compliant) and serializeScanHistoryToJson.

Installation

Via npm:

npm install sunasty-qr-payload

Or import directly in browsers and Deno via ESM CDN (jsDelivr):

import {
  parseQrPayload,
  generateTotpCode,
  analyzeUrlSecurity,
} from 'https://cdn.jsdelivr.net/gh/bsulyan/[email protected]/index.js';

Usage

Parsing Structured QR Payloads

import { parseQrPayload } from 'sunasty-qr-payload';

const wifi = parseQrPayload('WIFI:S:ProdNetwork;T:WPA2;P:SecretKey2026;H:false;;');
// { kind: 'wifi', ssid: 'ProdNetwork', encryption: 'WPA2', password: 'SecretKey2026', hidden: false }

const vcard = parseQrPayload(
  'BEGIN:VCARD\nVERSION:3.0\nFN:Alex Martin\nORG:Sunasty\nTEL:+33123456789\nEMAIL:[email protected]\nEND:VCARD'
);
// { kind: 'vcard', fullName: 'Alex Martin', org: 'Sunasty', phone: '+33123456789', email: '[email protected]', ... }

const urlInfo = parseQrPayload('http://192.168.1.1/login');
// { kind: 'url', domain: '192.168.1.1', isInsecureHttp: true, isRawIp: true, hasSecurityWarning: true, ... }

Generating RFC 6238 2FA TOTP Codes

import { parseQrPayload, generateTotpCode } from 'sunasty-qr-payload';

const parsed = parseQrPayload(
  'otpauth://totp/Sunasty:[email protected]?secret=JBSWY3DPEHPK3PXP&issuer=Sunasty'
);

if (parsed.kind === 'totp') {
  const { code, remainingSeconds } = await generateTotpCode(
    parsed.secret,
    Date.now(),
    parsed.period,
    parsed.digits
  );
  console.log(`Current 2FA code: ${code} (valid for ${remainingSeconds}s)`);
}

Exporting Scan History to RFC 4180 CSV

import { serializeScanHistoryToCsv } from 'sunasty-qr-payload';

const csv = serializeScanHistoryToCsv([
  {
    timestamp: '2026-10-22T12:00:00.000Z',
    source: 'camera',
    type: 'url',
    isUrl: true,
    data: 'https://sunasty.com/qr-scan/',
  },
]);

Web Utilities

License

MIT