ProvenPin Install

qrcode PNG and data URL helpers: working versions (tested 2026-10-15)

Generate QR codes with the qrcode package as PNG buffers and data URLs, covering error correction levels offline.

passed2 passed · 0 failed2026-10-15 16:04 UTC
Status
passed
Last passed
2026-10-15 16:04 UTC
Tests
2 / 2
Language
TypeScript
Runtime
node v22.23.3
pinned versions4
qrcode@1.5.4@types/node@26.6.5tsx@4.23.15@types/qrcode@1.5.6
run it
npm install --no-audit --no-fund --ignore-scripts=false
npm test
test environment
node v22.23.3
linux 6.17.0-1022-azure
x64
runner: github-actions 38764699834

The code

Exactly the files that passed. Your agent can pull them with get_recipe("qrcode-png-buffer") (install), or see them on GitHub.

package.json
{
  "name": "qrcode-png-buffer",
  "private": true,
  "type": "module",
  "scripts": {
    "test": "node --import tsx --test test/*.test.ts"
  },
  "dependencies": {"qrcode":"1.5.4"},
  "devDependencies": {"@types/node":"26.6.5","tsx":"4.23.15","@types/qrcode":"1.5.6"}
}
src/qr.ts
import QRCode from "qrcode";

export async function toPngBuffer(text: string, margin = 1) {
  return QRCode.toBuffer(text, {
    type: "png",
    errorCorrectionLevel: "M",
    margin,
    width: 256,
  });
}

export async function toDataUrl(text: string) {
  return QRCode.toDataURL(text, { errorCorrectionLevel: "M", margin: 1 });
}

export async function toAscii(text: string) {
  return QRCode.toString(text, { type: "terminal", small: true });
}
test/qr.test.ts
import { test } from "node:test";
import assert from "node:assert/strict";
import { toPngBuffer, toDataUrl, toAscii } from "../src/qr.ts";

test("png buffer starts with PNG signature", async () => {
  const buf = await toPngBuffer("https://provenpin.com");
  assert.ok(buf.length > 100);
  assert.equal(buf[0], 0x89);
  assert.equal(buf[1], 0x50);
  assert.equal(buf[2], 0x4e);
  assert.equal(buf[3], 0x47);
});

test("data url and ascii output", async () => {
  const url = await toDataUrl("hello");
  assert.match(url, /^data:image\/png;base64,/);
  const ascii = await toAscii("hi");
  assert.ok(ascii.length > 10);
});

Connect to ProvenPin

Add the free MCP server so your agent can pull this recipe and others like it. Same setup as the docs.

terminal
claude mcp add --transport http provenpin https://mcp.provenpin.com/mcp

Any other MCP client: Streamable HTTP at https://mcp.provenpin.com/mcp. No API key, no signup.