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

@ereo/auth

v0.2.15

Published

Authentication plugin for EreoJS framework

Readme

@ereo/auth

Authentication plugin for the EreoJS framework. Provides authentication and authorization with multiple providers, JWT/cookie-based sessions, and role-based access control.

Installation

bun add @ereo/auth

Quick Start

import { defineConfig } from '@ereo/core';
import { createAuthPlugin, credentials, github } from '@ereo/auth';

export default defineConfig({
  plugins: [
    createAuthPlugin({
      session: {
        secret: process.env.AUTH_SECRET!,
        strategy: 'jwt',
        maxAge: 7 * 24 * 60 * 60, // 7 days
      },
      providers: [
        credentials({
          authorize: async ({ email, password }) => {
            // Validate credentials and return user
            const user = await db.users.findByEmail(email);
            if (user && await bcrypt.compare(password, user.passwordHash)) {
              return { id: user.id, email: user.email, roles: user.roles };
            }
            return null;
          },
        }),
        github({
          clientId: process.env.GITHUB_CLIENT_ID!,
          clientSecret: process.env.GITHUB_CLIENT_SECRET!,
        }),
      ],
    }),
  ],
});

Using Auth in Routes

import { getAuth, requireAuth, getSession, getUser } from '@ereo/auth';

// Protect route with requireAuth
export const config = {
  ...requireAuth({ redirect: '/login' }),
};

// Access auth in loader/action
export async function loader({ context }) {
  const auth = getAuth(context);

  if (auth.isAuthenticated()) {
    return { user: auth.getUser() };
  }

  return { user: null };
}

// Sign in
export async function action({ request, context }) {
  const auth = getAuth(context);
  const formData = await request.formData();

  const session = await auth.signIn('credentials', {
    email: formData.get('email'),
    password: formData.get('password'),
  });

  return new Response(null, {
    status: 302,
    headers: {
      Location: '/dashboard',
      'Set-Cookie': auth.getCookieHeader()!,
    },
  });
}

Features

  • Multiple Auth Providers: credentials(), github(), google(), discord(), oauth(), apiKey(), mock()
  • Session Strategies: JWT (stateless), cookie (server-side), or hybrid
  • Role-Based Access Control: hasRole(), hasAnyRole(), hasAllRoles()
  • Route Protection: requireAuth(), requireRoles(), optionalAuth(), withAuth()
  • Session Callbacks: onSessionCreated, onSessionValidate, onSignIn, onSignOut, jwt, session
  • Cookie Configuration: Secure defaults with full customization
  • TypeScript Support: Full type safety with exported interfaces

Exports

// Plugin and utilities
import {
  createAuthPlugin,
  requireAuth,
  optionalAuth,
  requireRoles,
  getAuth,
  getSession,
  getUser,
  withAuth,
  getOAuthUrl,
  handleOAuthCallback,
} from '@ereo/auth';

// Providers
import {
  credentials,
  github,
  google,
  discord,
  oauth,
  mock,
  apiKey,
} from '@ereo/auth';

// Types
import type {
  User,
  Session,
  JWTPayload,
  AuthProvider,
  SessionStrategy,
  SessionConfig,
  AuthConfig,
  AuthContext,
} from '@ereo/auth';

AuthContext Methods

| Method | Description | |--------|-------------| | session | Current session object or null | | signIn(provider, credentials) | Sign in with provider | | signOut() | Sign out current user | | isAuthenticated() | Check if authenticated | | hasRole(role) | Check for specific role | | hasAnyRole(roles) | Check for any of the roles | | hasAllRoles(roles) | Check for all roles | | getUser() | Get current user object | | getToken() | Get JWT token | | refreshSession() | Refresh session expiration | | getCookieHeader() | Get Set-Cookie header for response |

Session Strategies

| Strategy | Description | |----------|-------------| | 'jwt' | Stateless - session data in signed JWT | | 'cookie' | Server-side - session ID in cookie, data in memory | | 'hybrid' | JWT with server-side validation for revocation |

Documentation

For full documentation, see Auth Plugin API Reference.

Part of EreoJS

This package is part of the EreoJS monorepo - a modern full-stack JavaScript framework.

License

MIT