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

@mayrlabs/auth

v0.5.1

Published

A strictly typed, universal JWT and M2M authentication core library powering the MayR Labs ecosystem.

Readme

@mayrlabs/auth

The premium authentication and identity provider core package for the MayR Labs ecosystem. This package provides a centralized, secure, and developer-friendly way to manage Single Sign-On (SSO), Cross-App communication (M2M), and service-to-service authentication using industry-standard PS256 (RSA-PSS with SHA-256) cryptography.

✨ Features

  • 🔐 Framework Agnostic Core: Deployable in Node.js, Cloudflare Workers, or any modern JS environment.
  • 🛡️ PS256 Cryptography: Uses RSA-PSS with SHA-256 for probabilistic, high-security JWT signing and verification.
  • 🔑 JWK Support: Native handling of JSON Web Keys for environment-safe key management.
  • 🏛️ Dual Setup Roles:
    • IssuerAuthSetup: For identity providers (e.g., the Account App) to sign tokens.
    • ClientAuthSetup: For consumer apps to verify tokens and initiate SSO.
  • 📦 Type Safe: Fully written in TypeScript with comprehensive exported interfaces.
  • 👤 User Model: Built-in AuthUser class with helper methods for roles (hasRole, hasAnyRole) and nullable name fields.
  • 🔄 Lifecycle Hooks: Hook into auth events with onAuthSuccess and onAuthFailure.
  • 🛡️ CSRF Protection: Native support for state-based verification to prevent cross-site request forgery.
  • 🔑 PKCE Utilities: Built-in helpers for Proof Key for Code Exchange (generateCodeVerifier, generateCodeChallenge).

🚀 Getting Started

Installation

npm install @mayrlabs/auth

🏛️ IssuerAuthSetup (For Identity Providers)

Designed exclusively for the Account App. It holds the Private Key and is the only entity that can sign tokens.

Initialization

import { IssuerAuthSetup } from "@mayrlabs/auth";

const issuer = new IssuerAuthSetup({
  privateKey: process.env.MAYRLABS_AUTH_PRIVATE_JWK!, // The full JSON private JWK string
  publicKey: process.env.MAYRLABS_AUTH_PUBLIC_JWK!, // The full JSON public JWK string
  issuer: "auth.mayrlabs.com", // Optional, defaults to auth.mayrlabs.com
});

🏢 ClientAuthSetup (For Consumer Apps)

Designed for consumer apps. Holds the Public Key for verification.

Initialization

import { ClientAuthSetup } from "@mayrlabs/auth";

const auth = new ClientAuthSetup({
  publicKey: process.env.MAYRLABS_AUTH_PUBLIC_JWK!, // The full JSON public JWK string
  clientId: process.env.MAYRLABS_CLIENT_ID!,
  clientSecret: process.env.MAYRLABS_CLIENT_SECRET!,
  accountUrl: process.env.MAYRLABS_ACCOUNT_URL!, // e.g., "https://myaccount.mayrlabs.com"
  issuer: "auth.mayrlabs.com", // Optional, defaults to auth.mayrlabs.com
});

Methods

getLoginUrl(params?: Record<string, string>): string

Returns the SSO redirect URL. You can pass optional parameters like return_to.

verifyAuthToken(token: string, audience?: string): Promise<AuthUserPayload | null>

Locally verifies a signed User JWT. Defaults to using clientId as audience if none provided.

verifyErrorToken(token: string, audience?: string): Promise<AuthErrorPayload | null>

Locally verifies a signed Error JWT.

authenticateMachine(): Promise<string>

Fetches a Machine Token from the Account App's service endpoint using client credentials.


🛡️ Security Utilities (PKCE)

import { generateCodeVerifier, generateCodeChallenge } from "@mayrlabs/auth";

const verifier = generateCodeVerifier();
const challenge = await generateCodeChallenge(verifier);

📚 Exported Interfaces

  • AuthUserPayload (id, email, username, roles, firstName, lastName, avatarUrl)
  • AuthMachinePayload
  • AuthErrorPayload
  • AuthUser (Utility Model)

🌐 Next.js Integrations

If you are using Next.js, please utilize our native Next.js integration wrapper.

npm install @mayrlabs/auth-nextjs

See the @mayrlabs/auth-nextjs documentation for full guidelines!


Built with discipline by MayR Labs. Build. Ship. Repeat intelligently.