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

authme-angular

v1.0.1

Published

Angular SDK for AuthMe Identity and Access Management Server

Readme

authme-angular

Angular SDK for AuthMe — an injectable AuthService, a route guard, an HTTP interceptor, and an NgModule entry point.

Installation

npm install authme-angular authme-sdk rxjs

Quick Start

1. Import AuthmeModule.forRoot()

// app.module.ts
import { NgModule } from '@angular/core';
import { HttpClientModule } from '@angular/common/http';
import { AuthmeModule } from 'authme-angular';

@NgModule({
  imports: [
    HttpClientModule,
    AuthmeModule.forRoot({
      url: 'http://localhost:3000',
      realm: 'my-realm',
      clientId: 'my-app',
      redirectUri: 'http://localhost:4200/callback',
    }),
  ],
  bootstrap: [AppComponent],
})
export class AppModule {}

2. Inject AuthService

import { Component } from '@angular/core';
import { AuthService } from 'authme-angular';

@Component({
  selector: 'app-nav',
  template: `
    <ng-container *ngIf="auth.isLoading$ | async; else content">
      <span>Loading...</span>
    </ng-container>
    <ng-template #content>
      <button *ngIf="!(auth.isAuthenticated$ | async)" (click)="auth.login()">
        Sign In
      </button>
      <div *ngIf="auth.isAuthenticated$ | async">
        <span>{{ (auth.user$ | async)?.name }}</span>
        <button (click)="auth.logout()">Sign Out</button>
      </div>
    </ng-template>
  `,
})
export class NavComponent {
  constructor(public auth: AuthService) {}
}

3. Protect routes with AuthGuard

// app.routes.ts
import { Routes } from '@angular/router';
import { AuthGuard } from 'authme-angular';

export const routes: Routes = [
  { path: '', component: HomeComponent },
  {
    path: 'dashboard',
    component: DashboardComponent,
    canActivate: [AuthGuard],
  },
  {
    path: 'admin',
    component: AdminComponent,
    canActivate: [AuthGuard],
    data: { roles: ['admin'] },
  },
];

4. Automatically attach Bearer tokens (HTTP interceptor)

The HTTP interceptor is registered automatically when you use AuthmeModule.forRoot().

For standalone / functional interceptor style (Angular 15+):

// app.config.ts
import { provideHttpClient, withInterceptors } from '@angular/common/http';
import { authInterceptor } from 'authme-angular';

export const appConfig = {
  providers: [
    provideHttpClient(withInterceptors([authInterceptor])),
  ],
};

API Reference

AuthmeModule

  • AuthmeModule.forRoot(config: AuthmeConfig) — registers all providers

AuthService

| Member | Type | Description | |--------|------|-------------| | isAuthenticated$ | Observable<boolean> | Reactive auth state | | isLoading$ | Observable<boolean> | True while initializing | | user$ | Observable<UserInfo \| null> | Current user | | isAuthenticated | boolean | Synchronous getter | | user | UserInfo \| null | Synchronous getter | | login(opts?) | Promise<void> | Redirect to login | | logout() | Promise<void> | Log out | | getToken() | string \| null | Current access token | | hasRole(role) | boolean | Realm role check | | hasPermission(perm) | boolean | Permission check | | getRoles() | string[] | All realm roles |

AuthGuard

Route guard implementing CanActivate. Reads route.data.roles and route.data.loginPath.

AuthInterceptor

Class-based HTTP interceptor. Adds Authorization: Bearer <token> to requests.

authInterceptor

Functional interceptor for use with withInterceptors([authInterceptor]).

License

MIT