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

@odysseon/whoami-adapter-nestjs

v5.0.0

Published

NestJS integration adapter for Odysseon Whoami core

Readme

@odysseon/whoami-adapter-nestjs

NestJS integration package for @odysseon/whoami-core.

Overview

This package provides a dynamic NestJS module (WhoamiModule) that bridges the pure core library with NestJS's dependency injection, logging, and HTTP lifecycle.

Out of the box, the module gives you:

  • POST /auth/register
  • POST /auth/login
  • POST /auth/refresh
  • POST /auth/oauth (Unified endpoint for all OAuth providers)
  • GET /auth/status

Secure By Default

When imported, this module automatically registers a global WhoamiExceptionFilter to map core domain errors to standard HTTP status codes, and a global WhoamiAuthGuard to lock down your application.

Installation

npm install @odysseon/whoami-core @odysseon/whoami-adapter-nestjs
# Plus your preferred cryptography adapters:
npm install @odysseon/whoami-adapter-argon2 @odysseon/whoami-adapter-jose @odysseon/whoami-adapter-webcrypto

Usage

Register the module globally in your AppModule using registerAsync. This allows you to inject configuration services easily.

import { Module } from "@nestjs/common";
import { ConfigModule, ConfigService } from "@nestjs/config";
import { WhoamiModule } from "@odysseon/whoami-adapter-nestjs";
import { Argon2PasswordHasher } from "@odysseon/whoami-adapter-argon2";
import { JoseTokenSigner } from "@odysseon/whoami-adapter-jose";
import { WebCryptoTokenHasher } from "@odysseon/whoami-adapter-webcrypto";

import { PrismaPasswordUserRepository } from "./repositories/password-user.repository";
import { PrismaOAuthUserRepository } from "./repositories/oauth-user.repository";
import { PrismaRefreshTokenRepository } from "./repositories/refresh-token.repository";

@Module({
  imports: [
    ConfigModule.forRoot(),
    WhoamiModule.registerAsync({
      imports: [ConfigModule],
      inject: [ConfigService],
      useFactory: (config: ConfigService) => ({
        configuration: {
          authMethods: { credentials: true, oauth: true },
          refreshTokens: { enabled: true, refreshTokenTtlSeconds: 604800 },
          accessTokenTtlSeconds: 3600,
        },
        tokenSigner: new JoseTokenSigner({ secret: config.get("JWT_SECRET")! }),
        passwordHasher: new Argon2PasswordHasher(),
        tokenHasher: new WebCryptoTokenHasher(),
        passwordUserRepository: new PrismaPasswordUserRepository(),
        oauthUserRepository: new PrismaOAuthUserRepository(),
        refreshTokenRepository: new PrismaRefreshTokenRepository(),
      }),
    }),
  ],
})
export class AppModule {}

Protecting and Exposing Routes

Because WhoamiAuthGuard is registered globally, all routes are protected by default. To expose a route (like a public landing page or custom login view), use the @Public() decorator.

To access the verified user's identity inside a protected route, use the @CurrentIdentity() decorator.

import { Controller, Get } from "@nestjs/common";
import { Public, CurrentIdentity } from "@odysseon/whoami-adapter-nestjs";
import type { IJwtPayload } from "@odysseon/whoami-core";

@Controller("account")
export class AccountController {
  // This route is fully protected by the global Guard
  @Get("me")
  getProfile(@CurrentIdentity() identity: IJwtPayload) {
    return {
      message: "Welcome to your secure dashboard",
      userId: identity.sub, // The user ID guaranteed by the core
    };
  }

  // You can also pluck specific payload properties
  @Get("settings")
  getSettings(@CurrentIdentity("sub") userId: string) {
    return this.settingsService.findByUserId(userId);
  }

  // This route bypasses the global Guard
  @Public()
  @Get("landing")
  getLandingPage() {
    return "Hello World";
  }
}

Customization

  • Token Extraction: The module defaults to BearerTokenExtractor. If your app reads tokens from cookies or custom headers, implement ITokenExtractor and pass it to the useFactory options as tokenExtractor.
  • OAuth Flexibility: The /auth/oauth endpoint accepts a generic provider and providerId. It is your infrastructure's responsibility (e.g., using Passport.js) to verify the Google/GitHub token first, and then forward the unique provider ID to this endpoint to establish the internal session.