cautpartener / client / src / app / qr.ts
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
/**
 * Seed → QR code element (SVG via qrcode-generator, ~5 KB dep). The QR
 * payload is the bare 43-char base64url seed — exactly what the import
 * textarea and the camera scanner expect on the other device.
 */

import qrcode from "qrcode-generator";
import { h } from "./ui-kit";

/** White-padded scannable QR block for the given text. */
export function qrElement(text: string, testid?: string): HTMLElement {
  const qr = qrcode(0, "M");
  qr.addData(text);
  qr.make();
  const wrap = h("div", { class: "qr-box", "aria-hidden": "true", "data-testid": testid });
  // createSvgTag output is fully generated from our own data (no user HTML)
  wrap.innerHTML = qr.createSvgTag({ cellSize: 4, margin: 2, scalable: true });
  return wrap;
}

static mirror of HEAD · about · clone: git clone https://cod-sursa.cautpartener.ro/cautpartener.git