Display a QR code for 2FA setup
masterTo allow users to scan the secret into an authenticator app, use the secret.otpauth_url with a QR code library (like the qrcode package) to generate a QR code image.
// Use the qrcode package
// npm install --save qrcode
var QRCode = require('qrcode');
// Get the data URL of the authenticator URL
QRCode.toDataURL(secret.otpauth_url, function(err, data_url) {
console.log(data_url);
// Display this data URL to the user in an <img> tag
// Example:
write('<img src="' + data_url + '">');
});