async function createPlugin(ctx) { return { async execute(action, input) { if (action !== "send_challenge") { throw new Error(`Unknown action: ${action}`); } const payload = input && input.payload ? input.payload : {}; const recipient = input && input.recipient ? String(input.recipient) : ""; if (!recipient) { throw new Error("recipient missing"); } const entry = { at: new Date().toISOString(), via: "rms.auth.otp_email", to: recipient, from: String(ctx.getSetting("from", ctx.env.SMTP_FROM || "noreply@arcg.at")), subject: String(payload.subject || "ARCG OTP"), text: String(payload.text || ""), html: String(payload.html || "") }; await ctx.appendMailOutbox(entry); return { ok: true, delivered: true, transport: "otp-email-plugin" }; }, async health() { return { ok: true }; } }; } module.exports = { createPlugin };