SEQN Auth Express Helpers

The Express helper is exported from @seqn/auth-js/express. It does not depend on Express at runtime; it only expects Express-shaped req, res, and next objects.

Environment


SEQN_AUTH_BASE_URL=https://accounts.seqn.in
SEQN_AUTH_PUBLISHABLE_KEY=pk_live_your_project_key
SEQN_AUTH_SECRET_KEY=sk_live_your_project_secret

Basic app


import express from "express";
import { createSeqnAuthExpressHelpers } from "@seqn/auth-js/express";

const app = express();
const seqnAuth = createSeqnAuthExpressHelpers();

app.get("/auth/sign-in", seqnAuth.hostedSignIn);
app.get("/auth/sign-up", seqnAuth.hostedSignUp);
app.get("/auth/logout", seqnAuth.hostedSignOut);

app.get("/", seqnAuth.loadPublicConfig, (req, res) => {
  const { publicConfig, hosted } = res.locals.seqnAuth;
  res.type("html").send(`
    <h1>${publicConfig.application.name}</h1>
    <a href="${hosted.signInUrl}">Sign in</a>
    <a href="${hosted.signUpUrl}">Sign up</a>
  `);
});

app.get("/health/auth", async (req, res, next) => {
  try {
    const health = await seqnAuth.verifyBackendKeyHealth();
    res.status(health.ok ? 200 : 503).json(health);
  } catch (error) {
    next(error);
  }
});

app.listen(3000);

Safety notes

  • loadPublicConfig stores public config and hosted URLs in res.locals.seqnAuth.
  • It does not place secret keys in res.locals.
  • Secret-key health checks belong on backend routes or boot checks only.
  • SMTP/email and payments remain excluded from the MVP.