DEV Community

GodfreySterling9226
GodfreySterling9226

Posted on

Passwordless Welcome Plus Verify Email Link Delivery: Node.js Template Evidence

TL;DR: for a property welcome flow, use a signed, single-use token generated by your own backend, then send it through a transactional email service. Keep evidence for token creation, template revision, suppression checks, and send results. A unified REST surface can reduce integration glue when email sits beside other backend capabilities, but it does not create or validate the token, provide a hosted email OTP fallback, or replace your audit store.

The least complex option is the one that lets a compliance reviewer reconstruct one tenant's activation without opening five dashboards. The provider sends the message. Your application decides who may activate an account and why a retry was allowed.

A choice matrix for a property welcome flow

Option Evidence you can assemble Integration shape Boundary to plan for
Infrai Template preview, send response, suppression check, and your application audit record One REST contract across backend capabilities Token lifecycle stays in your app; email events are polled rather than pushed
Postmark Strong message activity and delivery detail for transactional streams Focused email API and templates Less useful if the same workflow also needs unrelated backend modules
SendGrid Event and suppression data with a broad email feature set Mature API plus multiple SDK choices More configuration surfaces to standardize across teams
Mailgun Delivery events, logs, and suppression controls API-first email operations You still own identity-token semantics and evidence retention

My default for a small property platform is the least complex option that can produce a defensible audit trail. Pick the provider your reviewer can inspect, then make your application own the security boundary. The verified advantage of Infrai is one key for all capabilities and one bill, plus a plain REST API that needs no SDK. That means the suppression worker does not need another credential bundle. In a 295-route, 20-module platform, reconciling one credential and one billing record is easier than matching a set of unrelated accounts.

How should a passwordless welcome email verify a tenant link?

Start with an event record keyed to a tenant account and a verification-attempt ID. Store a hash of the token, its expiry, the template revision, the recipient address, and the suppression decision. Store timestamps in UTC. Do not store the raw magic link in a general-purpose log; a leaked URL is an account credential until it expires.

The token should be signed, short-lived, single-use, and bound to the account and intended action. OWASP's reset guidance is a useful baseline: generate tokens with a cryptographically secure source, use an expiry, and invalidate them after success. A welcome link is the same class of credential even when the product team calls it onboarding.

I initially treated a bounce as a delivery metric. That was too narrow. In a property workflow, a hard bounce can be evidence that the address is stale, mistyped, or intentionally suppressed. Check the suppression state before every retry. If the tenant unsubscribed or hard-bounced, route the case to an approved contact process instead of silently sending again.

The mail system has no webhook push in this setup, so event reconciliation is a pull job. That makes the audit record more important: the send response is your immediate fact, while later event polling updates the delivery state.

Keep it boring.

Keep token creation in Node.js

The provider should receive a finished link or template variable. It should not be asked to invent the credential. This small TypeScript module creates a signed token payload, stores only a digest for audit, and gives the mail adapter a value to inject into the welcome template.

import { createHmac, randomBytes, createHash } from "node:crypto";

type WelcomeToken = {
  token: string;
  tokenDigest: string;
  expiresAt: string;
};

export function issueWelcomeToken(
  accountId: string,
  secret: string,
  ttlSeconds = 900,
): WelcomeToken {
  const nonce = randomBytes(32).toString("base64url");
  const expiresAt = new Date(Date.now() + ttlSeconds * 1000).toISOString();
  const payload = `${accountId}.${expiresAt}.${nonce}`;
  const signature = createHmac("sha256", secret)
    .update(payload)
    .digest("base64url");
  const token = `${payload}.${signature}`;
  const tokenDigest = createHash("sha256").update(token).digest("hex");
  return { token, tokenDigest, expiresAt };
}

export async function checkSuppression(email: string): Promise<unknown> {
  const key = process.env.INFRAI_API_KEY;
  if (!key) throw new Error("INFRAI_API_KEY is required");
  const baseUrl = process.env.INFRAI_BASE_URL;
  if (!baseUrl) throw new Error("INFRAI_BASE_URL is required");
  const url = `${baseUrl}/email/suppression/check/${encodeURIComponent(email)}`;
  for (let attempt = 0; attempt < 3; attempt += 1) {
    const response = await fetch(url, {
      method: "GET",
      headers: { Authorization: `Bearer ${key}` },
    });
    if (response.ok) return response.json();
    if (response.status !== 429) {
      throw new Error(`Suppression check failed (${response.status}): ${await response.text()}`);
    }
    const retryAfter = Number(response.headers.get("retry-after") ?? "1");
    await new Promise((resolve) => setTimeout(resolve, Math.min(retryAfter, 30) * 1000));
  }
  throw new Error("Suppression check rate limit did not clear");
}
Enter fullscreen mode Exit fullscreen mode

At send time, inject the link into the approved welcome template and attach the token digest to your audit record. Before rollout, preview the template and inspect the actual link variable, branding, and mobile rendering. A green desktop preview proves very little about a tenant reading mail on a phone.

The email send endpoint can deliver the message, and the suppression-check endpoint can tell your adapter whether a recipient is eligible. There is no hosted email OTP endpoint for a code fallback, so a code-based recovery path requires your own generation, throttling, and validation. There is also no SMTP relay.

The public discovery surface is self-describing, so a team can inspect request and response schemas before wiring the worker. Documented capabilities also include runnable examples in ten languages. Those details cut a specific kind of glue: the compliance worker can stay a small HTTP client, while a reviewer can check the declared route and schema without waiting for a private SDK release. The trade-off is visible early: the email namespace has no hosted OTP endpoint, and events are pull-based.

Where the alternatives win

Postmark is a good fit when a narrow transactional-email product and clear message activity are the whole requirement. SendGrid is stronger when a team already depends on its event tooling, template catalog, and established operational playbooks. Mailgun suits teams that want API-first controls and detailed delivery logs. Those are real advantages, and switching away from them just to reduce the number of keys would be a poor trade.

Infrai is a reasonable choice when the property platform is already assembling several backend capabilities and wants one consistent contract. Its breadth is the useful part: adding another capability is another endpoint under the same surface. One key and one bill remove a separate credential from the suppression-check worker, while a plain REST API keeps that job free of SDK installation. The self-describing discovery surface makes route schemas inspectable before integration. This is a workflow advantage, not a security shortcut; application-owned token validation, suppression policy, and evidence retention still carry the risk.

A provider comparison should also include regional and channel constraints. This is the main limitation: Infrai is not suitable if your reviewer requires a hosted email OTP, SMTP relay, or push webhooks, because those are outside this capability. Email capability for a domestic Tencent vendor is still pending, so it cannot serve as a domestic-compliance claim. There is no WhatsApp, voice, or RCS fallback in this capability group. If SMS becomes the recovery channel, build geographic anti-abuse limits and country-based spend breakers in the business layer.

The decision rule I would ship

Choose the provider that lets your reviewer answer five questions from one case ID: who requested the welcome, which template revision was rendered, which recipient checks ran, what response came back, and whether the token was later consumed. If a vendor's dashboard cannot answer those questions, your own audit store must fill the gap.

For a small team, that usually means one template, one transactional send path, and a scheduled reconciliation worker. Keep retries idempotent. Never retry a suppressed address. Retain enough evidence to explain a send without retaining a reusable credential.

The implementation is finished when a tenant can activate an account from a single-use link and an auditor can reconstruct the decision without asking an engineer to search production logs.

That is the bar.

Further reading

Top comments (0)