Files
backend/web/qr.js
Andriy Oblivantsev ef3957b618
CI / test (push) Successful in 4s
Demo app, collections/features CRUD, QR codes, docs
Demo app (web/):
- Collections: select, rename, remove (x button per row), delete
- Features: add point (lon/lat validation), remove, list in selected collection
- QR codes for pk (private) and pb (public) keys
- Restore public key from private key
- 409 Conflict handled for already-registered login
- Title: Momswap Geo Backend Use-Cases Test

Backend:
- PATCH /v1/collections/{id} for rename
- DELETE /v1/collections/{id}
- Clearer lon/lat validation errors (-180..180, -90..90)

Client:
- updateCollection, deleteCollection, derivePublicKey

Docs:
- docs/frontend-development.md (demo app, local dev)
- README links to all docs

Made-with: Cursor
2026-03-01 13:41:54 +00:00

22 lines
752 B
JavaScript

/**
* QR code generation for key display (pk = private key, pb = public key).
* Uses qrcode package from CDN.
*/
import QRCode from "https://esm.sh/qrcode?bundle";
const DEFAULT_SIZE = 180;
const DARK = "#0f172a";
const LIGHT = "#ffffff";
/**
* Generate a QR code data URL for the given text.
* @param {string} text - Text to encode (e.g. public key or private key).
* @param {{ size?: number, dark?: string, light?: string }} [opts] - Options.
* @returns {Promise<string>} Data URL for use as img src.
*/
export async function toDataURL(text, opts = {}) {
const size = opts.size ?? DEFAULT_SIZE;
const color = { dark: opts.dark ?? DARK, light: opts.light ?? LIGHT };
return QRCode.toDataURL(text, { width: size, margin: 2, color });
}