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

@apihub24/token-authentication

v2.0.0-alpha.0

Published

This Package contains a Token Authentication Module for NestJs with Organizations UserAccounts Groups and Rights access.

Readme

Token Authentication

This Package contains a Token Authentication Module for NestJs with Organizations UserAccounts Groups and Rights access.

Required external Services

You have to implement these Interfaces and give the Implementations into the Dynamic Module.

| Service | Injection Token | Interface in Contracts | Description | | ----------------------- | ----------------------------------- | ------------------------ | -------------------------------------------------------------- | | Token Service | @apihub24/token_service | TokenService | a Service that generates the Token for authentication | | Password Service | @apihub24/password_service | PasswordService | a Service that hash the Password | | Session Service | @apihub24/session_service | SessionService | a Service that handles Session Get, Save, Delete Operations | | Mail Service | @apihub24/mail_verification_service | MailVerificationService | a Service that handles Send Verify Mail and the verify Request | | Account Repository | @apihub24/account_repository | Repository | a Service that handles Session Get, Save, Delete Operations | | Group Repository | @apihub24/group_repository | Repository | a Service that handles Session Get, Save, Delete Operations | | Right Repository | @apihub24/right_repository | Repository | a Service that handles Session Get, Save, Delete Operations | | Organization Repository | @apihub24/organization_repository | Repository | a Service that handles Session Get, Save, Delete Operations |

If you want to use a InMemory Repository you not have to implement itself you can use the package @apihub24/in-memory-repository.

Example

import { Module } from "@nestjs/common";
import {
  Account,
  Group,
  Organization,
  Right,
  TokenAuthenticationModule,
} from "@apihub24/token-authentication";
import { LoginController } from "./controllers/login.controller";
import { LogoutController } from "./controllers/logout.controller";
import { ConfigModule } from "@nestjs/config";
// a implementation of the EmailService
import { EmailVerificationModule } from "@apihub24/email-verification";
// a implementation of the InMemoryRepository used for Repositories
import { InMemoryRepository } from "@apihub24/in-memory-repository";
// a implementation of the SessionService
import { InMemorySessionsModule } from "@apihub24/in-memory-sessions";
// a implementation of the TokenService
import { JwtGeneratorModule } from "@apihub24/jwt-generator";
// a implementation of the PasswordService
import { PasswordHasherModule } from "@apihub24/password-hasher";
import { takeExportedProviders } from "@apihub24/nestjs-helper";

// use the Dynamic Modules from the Implementations
const emailVerificationModule = EmailVerificationModule.forRoot();
const sessionModule = InMemorySessionsModule.forRoot();
// JwtGeneratorModule requires the SessionModule so give them the Providers
const jwtModule = JwtGeneratorModule.forRoot([
  ...takeExportedProviders(sessionModule),
]);
const passwordModule = PasswordHasherModule.forRoot();

@Module({
  imports: [
    ConfigModule.forRoot(),
    EmailVerificationModule.forRoot(),
    InMemorySessionsModule.forRoot(),
    JwtGeneratorModule.forRoot(),
    PasswordHasherModule.forRoot(),
    TokenAuthenticationModule.forRoot(),
  ],
  controllers: [LoginController, LogoutController],
  providers: [
    // register the Repositories with InMemoryRepository
    {
      provide: "@apihub24/organization_repository",
      useClass: InMemoryRepository<Organization>,
    },
    {
      provide: "@apihub24/account_repository",
      useClass: InMemoryRepository<Account>,
    },
    {
      provide: "@apihub24/group_repository",
      useClass: InMemoryRepository<Group>,
    },
    {
      provide: "@apihub24/right_repository",
      useClass: InMemoryRepository<Right>,
    },
  ],
  // required exports for the TokenGuard
  exports: [TokenAuthenticationModule, jwtModule],
})
export class AuthenticationModule {}