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

@flusys/ng-auth

v5.1.1

Published

Authentication module for FLUSYS Angular applications

Readme

@flusys/ng-auth

JWT authentication library for FLUSYS Angular apps — login, session restore, token refresh, multi-company selection, and provider adapter registration.

npm version License: MIT


Installation

npm install @flusys/ng-auth @flusys/ng-core @flusys/ng-shared

1. Register Providers

// app.config.ts
import { provideHttpClient, withInterceptors } from '@angular/common/http';
import { provideAuthProviders, provideAuthLayoutIntegration, authInterceptor, tokenRefreshInterceptor } from '@flusys/ng-auth';

export const appConfig: ApplicationConfig = {
  providers: [
    provideHttpClient(
      withInterceptors([
        authInterceptor,           // attaches Bearer token; sends withCredentials for cookie endpoints
        tokenRefreshInterceptor,   // proactive + reactive refresh; queues concurrent 401s
      ])
    ),
    ...provideAuthProviders(),          // USER_PROVIDER, COMPANY_API_PROVIDER, USER_PERMISSION_PROVIDER, AUTH_STATE_PROVIDER
    ...provideAuthLayoutIntegration(),  // LAYOUT_AUTH_STATE, LAYOUT_AUTH_API
  ],
};

Interceptor order matters: authInterceptor must come before tokenRefreshInterceptor.

2. Add Routes

// app.routes.ts
import { AUTH_ROUTES, ADMINISTRATION_ROUTES, PROFILE_ROUTES } from '@flusys/ng-auth';

export const routes: Routes = [
  {
    path: 'auth',
    loadChildren: () => AUTH_ROUTES,        // login, register, forgot-password, reset-password, verify-email
  },
  {
    path: 'administration',
    loadChildren: () => ADMINISTRATION_ROUTES, // users, company, branch (protected by authGuard)
  },
  {
    path: 'profile',
    loadChildren: () => PROFILE_ROUTES,     // profile page (protected by authGuard)
  },
];

3. Protect Routes with Guards

import { authGuard, guestGuard, companyFeatureGuard } from '@flusys/ng-auth';

const routes: Routes = [
  {
    path: 'dashboard',
    canActivate: [authGuard],          // redirects to /auth/login if not authenticated
    loadComponent: () => import('./dashboard.component'),
  },
  {
    path: 'auth/login',
    canActivate: [guestGuard],         // redirects to '/' if already authenticated; restores session first
    loadComponent: () => import('./login.component'),
  },
];

| Guard | Exported name | Behavior | |---|---|---| | Require auth | authGuard | Redirects to /auth/login; checks company if enableCompanyFeature is on | | Require guest | guestGuard | Redirects to / (or returnUrl) if authenticated; calls AuthInitService.initialize() | | Require company feature | companyFeatureGuard | Redirects to / if company feature is disabled in config |

4. Read Auth State

AuthStateService holds all auth state as read-only signals. The access token is memory-only (never persisted).

import { AuthStateService } from '@flusys/ng-auth';

@Component({ ... })
export class MyComponent {
  private readonly authState = inject(AuthStateService);

  readonly user        = this.authState.user;           // Signal<IUserInfo | null>
  readonly company     = this.authState.company;        // Signal<ICompanyInfo | null>
  readonly branch      = this.authState.branch;         // Signal<IBranchInfo | null>
  readonly isAuth      = this.authState.isAuthenticated; // Signal<boolean>
  readonly tokenExpired = this.authState.isTokenExpired; // Signal<boolean>
}

Key state methods:

authState.setLoginState(data);          // sets user + token + company + branch
authState.setSelectionState(data);      // multi-company selection flow
authState.resetState();                 // logout — clears all state + localStorage
authState.navigateToLogin(returnUrl?);  // safe redirect (rejects external URLs)

6. Session Restore

AuthInitService.initialize() runs POST /auth/refresh (HTTP-only cookie) then POST /auth/me to restore session in memory. It is called automatically by guestGuard. Call it manually if needed:

import { AuthInitService } from '@flusys/ng-auth';

const authInit = inject(AuthInitService);

authInit.initialize().subscribe(isAuthenticated => {
  // safe to read authState signals now
});

The initialized signal is true after the first call completes (success or failure).

7. Extend Registration / Profile (Optional)

Inject custom fields and sections via extension tokens:

import { AUTH_REGISTRATION_EXTENSION, AUTH_PROFILE_EXTENSION, AUTH_USER_LIST_EXTENSION, AUTH_VALIDATION_CONFIG } from '@flusys/ng-auth';

providers: [
  { provide: AUTH_REGISTRATION_EXTENSION, useClass: MyRegistrationExtension }, // extra fields on register form
  { provide: AUTH_PROFILE_EXTENSION, useClass: MyProfileExtension },            // extra sections on profile page
  { provide: AUTH_USER_LIST_EXTENSION, useClass: MyUserListExtension },         // extra columns/actions on user list
  {
    provide: AUTH_VALIDATION_CONFIG,
    useValue: {
      password: { minLength: 10, requireUppercase: true, requireSpecialChars: true },
    },
  },
]

License

MIT © FLUSYS