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

@auth-ninja/core

v1.1.0

Published

Shared auth config, validation, errors, and crypto helpers

Readme

@auth-ninja/core

Shared configuration schema, error types, crypto helpers, and auth primitives for Auth-Ninja.

This package is headless — no UI. Wire it through @auth-ninja/react and a server adapter (@auth-ninja/next or AuthNinja.AspNetCore).

Configuration

Load and validate environment variables with Zod:

import { loadAuthNinjaConfig } from "@auth-ninja/core";

const config = loadAuthNinjaConfig();
// config.secret, config.baseUrl, config.databaseUrl, session/lockout/MFA options…

Required env vars: AUTH_NINJA_SECRET (≥ 32 chars), AUTH_NINJA_BASE_URL, AUTH_NINJA_DATABASE_URL. Full list: main README config table.

Generate a secret: generateAuthNinjaSecret() or pnpm dlx @auth-ninja/cli keys generate.

Subpath exports

| Import | Contents | | --- | --- | | @auth-ninja/core | Config, errors, passwords, TOTP, lockout, audit, field encryption | | @auth-ninja/core/errors | Error types only | | @auth-ninja/core/password-policy | zxcvbn strength assessment |

Passwords

import { hashPassword, verifyPasswordWithTimingProtection } from "@auth-ninja/core";
import { assessPasswordStrength, isPasswordStrongEnough } from "@auth-ninja/core/password-policy";

Argon2id hashing with constant-time verification. Minimum strength enforced via zxcvbn (passwordMinScore, default 2).

TOTP 2FA

import {
  generateTotpSecret,
  verifyTotpCode,
  generateBackupCodes,
  verifyBackupCode,
} from "@auth-ninja/core";

Lockout

import { LockoutEngine, InMemoryLockoutStore, lockoutConfigFromAuthConfig } from "@auth-ninja/core";

Audit events

Typed schemas for login, logout, lockout, and IP audit events — createLoginAuditEvent, AUDIT_EVENT_TYPES, etc.

Error taxonomy

All auth API errors use AuthNinjaError with a code from AUTH_ERROR_CODES. Adapters should return the default generic message from AUTH_ERROR_MESSAGES unless a flow-specific variant is documented below.

| Code | HTTP | Message | When | | --- | --- | --- | --- | | INVALID_CREDENTIALS | 401 | Invalid email or password. | Login or passkey auth failed | | ACCOUNT_LOCKED | 423 | Too many failed attempts. Try again later. | Lockout after failed attempts | | SESSION_EXPIRED | 401 | Session expired. | Missing or expired session | | MFA_REQUIRED | 403 | Multi-factor authentication is required. | Action requires completed MFA | | MFA_INVALID | 400 | Invalid authentication code. | Bad TOTP or backup code | | CSRF_INVALID | 403 | Invalid CSRF token. | Missing or invalid CSRF header | | RATE_LIMITED | 429 | Too many requests. | Rate limit exceeded | | FORBIDDEN | 403 | Forbidden. | Authenticated but not permitted | | VALIDATION_ERROR | 400 | Invalid request. | Invalid request body or params |

Use createAuthError(code) for defaults, or AUTH_GENERIC_MESSAGES for register and password-reset flows that must not reveal account existence. Full descriptions: AUTH_ERROR_CATALOG in src/errors.ts.