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

@solumjs/auth

v0.3.5

Published

SolumJS auth: JWT service, password hashing, guards, RBAC roles

Readme

@solumjs/auth

JWT authentication, guards, role-based access, @PreAuthorize, password hashing, and OAuth2.

Install

npm install @solumjs/auth

JWT Service

import { JwtService, TokenClaims } from "@solumjs/auth";

const jwtService = new JwtService({ secret: "your-secret", expiresIn: 3600 });

const claims: TokenClaims = { sub: user.id, email: user.email, role: user.role };

// Generate tokens
const accessToken = jwtService.signAccessToken(claims);
const refreshToken = jwtService.signRefreshToken(claims);

// Verify token
const payload = jwtService.verify(accessToken);

// Revoke token
jwtService.revoke(accessToken);

JwtAuthGuard

import { JwtAuthGuard } from "@solumjs/auth";
import { RestController, Get, UseGuards, CurrentUser } from "@solumjs/http";

@RestController("/users")
@UseGuards(JwtAuthGuard)
export class UserController {

    @Get("/me")
    async getProfile(@CurrentUser() user: JwtPayload) {
        return this.userService.findById(user.sub);
    }
}

RolesGuard and @Roles

import { JwtAuthGuard, RolesGuard, Roles } from "@solumjs/auth";
import { RestController, Get, UseGuards } from "@solumjs/http";

@RestController("/admin")
@UseGuards(JwtAuthGuard, RolesGuard)
export class AdminController {

    @Get("/dashboard")
    @Roles("ADMIN")
    async dashboard() { return "admin data"; }

    @Get("/users")
    @Roles("ADMIN", "MODERATOR")
    async listUsers() { return []; }
}

@PreAuthorize

import { PreAuthorize } from "@solumjs/auth";
import { RestController, Get, Param } from "@solumjs/http";

@RestController("/documents")
export class DocumentController {

    @Get("/:id")
    @PreAuthorize("hasRole('ADMIN') or #id == authentication.sub")
    async getDocument(@Param("id") id: string) {
        return this.documentService.findById(id);
    }
}

Password Hashing

import { hashPassword, verifyPassword } from "@solumjs/auth";

// Hash password (scrypt with random salt)
const hashed = hashPassword("my-password");

// Verify password
const isValid = verifyPassword("my-password", hashed);

OAuth2

import { OAuth2Client } from "@solumjs/auth";

const googleClient = new OAuth2Client({
    clientId: process.env.GOOGLE_CLIENT_ID,
    clientSecret: process.env.GOOGLE_CLIENT_SECRET,
    redirectUri: "http://localhost:3000/auth/google/callback",
    authorizationEndpoint: "https://accounts.google.com/o/oauth2/v2/auth",
    tokenEndpoint: "https://oauth2.googleapis.com/token",
    scopes: ["openid", "email", "profile"],
});

// Generate authorization URL
const authUrl = googleClient.getAuthorizationUrl();

// Exchange code for tokens
const tokens = await googleClient.exchangeCode(code);

// Get user info
const userInfo = await googleClient.getUserInfo(tokens.accessToken);

Refresh Token Store

import { InMemoryRefreshTokenStore, RefreshTokenStore } from "@solumjs/auth";

const store = new InMemoryRefreshTokenStore();

// Store refresh token
await store.save(userId, refreshToken);

// Validate refresh token
const valid = await store.validate(refreshToken);

// Revoke refresh token
await store.revoke(refreshToken);

JWT Features

  • HS256 signing algorithm
  • Token revocation support
  • Minimum 32-character secret requirement
  • Expiration and nbf validation
  • Issuer and audience validation
  • Timing-safe signature comparison

License

MIT