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

@greudev/nest-auth

v0.1.1

Published

Passive authentication and authorization module for NestJS microservices consuming JWT Bearer tokens from OAuth2/OIDC providers

Readme

@greudev/nest-auth

Passive authentication and authorization module for NestJS microservices consuming JWT Bearer tokens from OAuth2/OIDC providers.

Requirements

Features

  • JWT validation via JWKS (JSON Web Key Set) with cryptographic signature verification
  • Strict issuer and audience validation
  • Flexible user ID resolution — configurable claim keys to find the user ID (sub, user_id, etc.)
  • Permission-based authorization via @RequirePermission() decorator
  • Current user extraction via @CurrentUser() parameter decorator
  • Configurable permissions claim (defaults to cognito:groups)

Installation

pnpm add @greudev/nest-auth

Usage

1. Import the module

import { Module } from '@nestjs/common';
import { ConfigModule, ConfigService } from '@nestjs/config';
import { KaribuNestAuthModule } from '@greudev/nest-auth';

@Module({
  imports: [
    KaribuNestAuthModule.forRootAsync({
      imports: [ConfigModule],
      useFactory: (config: ConfigService) => ({
        issuer: config.getOrThrow('OAUTH2_ISSUER'),
        jwksUrl: config.getOrThrow('OAUTH2_JWKS_URL'),
        audience: config.get('OAUTH2_AUDIENCE'),
        userIdClaimKeys: ['cognito:username', 'sub'],
      }),
      inject: [ConfigService],
    }),
  ],
})
export class AppModule {}

2. Protect endpoints

import { Controller, Get, UseGuards } from '@nestjs/common';
import { KaribuAuthGuard, RequirePermission, CurrentUser } from '@greudev/nest-auth';

@Controller('orders')
@UseGuards(KaribuAuthGuard)
export class OrdersController {
  @Get()
  @RequirePermission('orders:read')
  findAll(@CurrentUser() user: any) {
    // `user.id` is the resolved user ID (from the first matching claim key)
    // `user.cognito:groups` contains the permission groups
  }

  @Get('profile')
  getProfile(@CurrentUser('email') email: string) {
    // Returns only the `email` claim from the JWT
  }
}

Static configuration

KaribuNestAuthModule.forRoot({
  issuer: 'https://cognito-idp.us-east-1.amazonaws.com/us-east-1_xxx',
  jwksUrl: 'https://cognito-idp.us-east-1.amazonaws.com/us-east-1_xxx/.well-known/jwks.json',
  userIdClaimKeys: ['sub'],
})

Configuration Options

| Option | Type | Required | Default | Description | |---|---|---|---|---| | issuer | string | yes | — | OIDC issuer URL (must match the iss claim exactly) | | jwksUrl | string | yes | — | JWKS endpoint URL for public key retrieval | | audience | string | no | — | Expected aud claim value | | userIdClaimKeys | string[] | yes | — | Ordered list of JWT claims to resolve the user ID (e.g. ['user_id', 'sub']) | | permissionsClaim | string | no | cognito:groups | JWT claim containing the permission array |