CI / test (push) Successful in 3s
This switches demo pages and modules to local web/vendor assets, fixes Three GLTFLoader local import resolution, and documents the runtime-data/agent commit workflow updates. Made-with: Cursor
22 lines
753 B
JavaScript
22 lines
753 B
JavaScript
/**
|
|
* QR code generation for key display (pk = private key, pb = public key).
|
|
* Uses vendored qrcode package.
|
|
*/
|
|
import QRCode from "./vendor/qr/qrcode.bundle.mjs";
|
|
|
|
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 });
|
|
}
|