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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@edgeflare/ngx-oidc

v0.0.1

Published

oidc-client-ts wrapper for Angular and Capacitor

Downloads

59

Readme

oidc-client-ts wrapper for Angular and Capacitor

1. Install

npm install oidc-client-ts @edgeflare/ngx-oidc

2. Configure Angular

Update <approot>/src/app/app.config.ts. The example directory includes a minimal app.

import { ApplicationConfig } from '@angular/core';
import { provideRouter, Route } from '@angular/router';
import { UserManagerSettings } from 'oidc-client-ts';
import { initOidc, OIDC_ROUTES } from '@edgeflare/ngx-oidc';

// Define OIDC configuration
const oidcConfig: UserManagerSettings = {
  authority: "http://127.0.0.1:5556/dex",
  client_id: "public-webui",
  redirect_uri: "http://localhost:4200/signin/callback",
  response_type: "code",
  scope: "openid profile email offline_access audience:server:client_id:oauth2-proxy", // some extra scopes for Dex
  post_logout_redirect_uri: "http://localhost:4200/signout/callback",
  automaticSilentRenew: true,
  silentRequestTimeoutInSeconds: 30,
  silent_redirect_uri: "http://localhost:4200/silent-refresh-callback.html",
};

// Provide OIDC configuration and routes in the application configuration
export const appConfig: ApplicationConfig = {
  providers: [
    // other providers
    ...initOidc(oidcConfig),
    provideRouter(OIDC_ROUTES), // before application routes
    provideRouter(routes)
    // more providers
  ],
};

Config for Capacitor based native mobile apps

npm install oidc-client-ts @edgeflare/ngx-oidc-capacitor
import { initOidc, OIDC_ROUTES } from '@edgeflare/ngx-oidc-capacitor';

const oidcConfig: UserManagerSettings | any = {
  authority: 'https://iam.example.org', // https://keycloak.example.org/realms/<realmname>
  client_id: 'public-webui',
  redirect_uri: Capacitor.isNativePlatform()
    ? 'org.example.capdemo://signin/callback'
    : `${window.location.origin}/signin/callback`,
  post_logout_redirect_uri: Capacitor.isNativePlatform()
    ? 'org.example.capdemo://signout/callback'
    : `${window.location.origin}/signout/callback`,
  response_type: 'code',
  scope: 'openid profile email offline_access audience:server:client_id:oauth2-proxy',
  automaticSilentRenew: true,
  // Use the appropriate storage based on platform
  userStore: Capacitor.isNativePlatform()
    ? new CapacitorStateStore() // consider github.com/martinkasa/capacitor-secure-storage-plugin
    : new WebStorageStateStore({
      store: window.localStorage
    }),
  loadUserInfo: true,
};

See example-capacitor.

signin demo

Providing OIDC_ROUTES registers below routes:

  • /signin/{callback,error,''}
  • /signout/callback
  • /oidc-profile, protected by an authGuard supplied with ngx-oidc

See signinRedirect, signinPopup etc examples at http://localhost:4200/signin. It additionally provides user and isAuthenticated signals; which can be called like user() to get the current user, and isAuthenticated() to check if the user is authenticated.

The routes can be registered on parent routes other root /, with ngx-oidc supplied components or your own.

const myOidcRoutes: Route[] = [
  // signin is now at /account/signin
  { path: 'account', loadChildren: () => import("@edgeflare/ngx-oidc").then((m) => m.OIDC_ROUTES)},
  // Or just the only required route. must match the `redirect_uri` in oidcConfig
  { path: 'signin-callback', loadComponent: () => import("@edgeflare/ngx-oidc").then((m) => m.SigninCallbackComponent)},
];

// ...
export const appConfig: ApplicationConfig = {
  providers: [
    ...initOidc(oidcConfig),
    provideRouter(myOidcRoutes),
  ],
};

To enable silent refresh, include the <approot>/public/silent-refresh-callback.html with below content:

<script src="./oidc-client-ts.js"></script>
<script>
  var mgr = new oidc.UserManager({ response_mode: 'query' });
  mgr.signinSilentCallback().catch(error => {
    console.error(error);
  });
</script>

Features (roadmap)

  • [x] signinRedirect, signinPopup, signoutRedirect, signoutPopup
  • [x] authGuard using canActivateFn
  • [x] Capactior support for native mobile apps

Contributing / Development

With ~200 lines of code ngx-oidc doesn't really do much except calling oidc-client-ts functions. It sets up and exposes oidc-client-ts' UserManager functions through an Angular service, AuthService. The function signatures used in this service are the same as those provided by oidc-client-ts.

  • signinRedirect(args?): Promise<void>
  • signinPopup(args?): Promise<void>
  • signinPopup(args?): Promise<User>

For advanced usage, call AuthService.userManagerInstance() to get the UserManager instance. If you wanna make it better, please do! Fork the repo, make your changes, and submit a PR.

License

Apache License 2.0