21 lines
504 B
JavaScript
21 lines
504 B
JavaScript
#!/usr/bin/env node
|
|
/** Print a terminal QR for stdin (or argv[2]) — raw payload only. */
|
|
import qrcode from 'qrcode';
|
|
|
|
const fromArg = process.argv[2];
|
|
const payload = fromArg
|
|
? fromArg
|
|
: (await new Response(process.stdin).text()).trim();
|
|
|
|
if (!payload) {
|
|
console.error('usage: qr-cert.mjs <base64-der> or pipe payload on stdin');
|
|
process.exit(1);
|
|
}
|
|
|
|
const out = await qrcode.toString(payload, {
|
|
type: 'terminal',
|
|
errorCorrectionLevel: 'L',
|
|
small: true,
|
|
});
|
|
process.stdout.write(out);
|