npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@meridianjs/auth

v1.27.0

Published

Meridian auth module — JWT authentication and middleware

Readme

@meridianjs/auth

Authentication module for MeridianJS. Provides JWT-based register/login flows, Google OAuth support, Express middleware for token verification, and RBAC guards.

Auto-loaded by @meridianjs/meridian — you do not need to add this to modules[] yourself.

Service: authModuleService

const svc = req.scope.resolve("authModuleService") as any

Methods

// Register a new user — returns { user, token }
const { user, token } = await svc.register({
  email: "[email protected]",
  password: "password123",
  first_name: "Alice",
  last_name: "Smith",
  role: "member",       // optional: "super-admin" | "admin" | "moderator" | "member"
})

// Login — returns { user, token }
const { user, token } = await svc.login({
  email: "[email protected]",
  password: "password123",
})

// Verify and decode a JWT
const payload = await svc.verifyToken(token)
// payload: { sub, workspaceId, roles, permissions, jti }

Middleware

authenticateJWT

Verifies the Authorization: Bearer <token> header and attaches req.user. Returns 401 if the token is missing or invalid.

import { authenticateJWT } from "@meridianjs/auth"

// Applied globally in middlewares.ts:
export default {
  routes: [
    { matcher: "/admin", middlewares: [authenticateJWT] },
  ],
}

// Or inline in a route:
export const GET = [authenticateJWT, async (req: any, res: Response) => {
  res.json({ userId: req.user.id })
}]

requireRoles

Guard a route or handler to specific roles. Returns 403 if the user's roles don't match.

import { requireRoles } from "@meridianjs/auth"

export const DELETE = [
  authenticateJWT,
  requireRoles("admin", "super-admin"),
  async (req: any, res: Response) => {
    // Only admins reach here
  },
]

requirePermission

Guard based on a specific permission string from a custom AppRole:

import { requirePermission } from "@meridianjs/auth"

export const POST = [
  authenticateJWT,
  requirePermission("issues:create"),
  async (req: any, res: Response) => { /* ... */ },
]

JWT Payload

interface JwtPayload {
  sub: string           // User ID
  workspaceId: string   // Active workspace ID (null until workspace selected)
  roles: string[]       // e.g. ["admin"] or ["member"]
  permissions: string[] // Custom AppRole permissions (e.g. ["issues:create", "issues:delete"])
  jti: string           // Unique token ID (for revocation)
  iat: number
  exp: number
}

Tokens expire after 7 days by default. Configure in projectConfig:

projectConfig: {
  jwtSecret: process.env.JWT_SECRET!,
  jwtExpiresIn: "30d",  // optional
}

Google OAuth

When @meridianjs/google-oauth is configured, the auth module exposes:

GET /auth/google           → Redirects to Google consent screen
GET /auth/google/callback  → Handles OAuth code, returns JWT

API Routes

| Method | Path | Description | |---|---|---| | POST | /auth/register | Register, return { user, token } | | POST | /auth/login | Login, return { user, token } | | GET | /auth/invite/:token | Validate an invitation token | | POST | /auth/invite/:token | Accept invitation (register or login) |

License

MIT