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

@edirect/oidc-client

v11.0.52

Published

OpenID Connect client for eDirect applications. Supports three OAuth2 grant types — `password`, `client_credentials`, and `sso` — with a uniform API for acquiring and refreshing tokens.

Readme

@edirect/oidc-client

OpenID Connect client for eDirect applications. Supports three OAuth2 grant types — password, client_credentials, and sso — with a uniform API for acquiring and refreshing tokens.

Features

  • Three grant types: password, client_credentials, sso
  • Uniform getAccessToken() and getRefreshToken() API across all grant types
  • OIDC provider discovery via configurable baseUrl and oidcPath
  • Token set parsing utilities

Installation

pnpm add @edirect/oidc-client
# or
npm install @edirect/oidc-client

Usage

Password Grant (username + password)

Used when the application authenticates on behalf of a user:

import OidcClient from '@edirect/oidc-client';

const client = await OidcClient({
  grantType: 'password',
  baseUrl: process.env.OIDC_PROVIDER_URL, // e.g., 'https://keycloak.example.com'
  oidcPath: process.env.OIDC_PROVIDER_PATH, // e.g., '/realms/my-realm'
  clientId: process.env.OIDC_CLIENT_ID,
  clientSecret: process.env.OIDC_CLIENT_SECRET,
});

// Acquire access token
const tokenSet = await client.getAccessToken({
  username: process.env.OIDC_USERNAME,
  password: process.env.OIDC_PASSWORD,
});

console.log(tokenSet.access_token);
console.log(tokenSet.expires_in);

// Refresh token (not available for client_credentials)
const refreshed = await client.getRefreshToken(tokenSet);

Client Credentials Grant (service-to-service)

Used for machine-to-machine authentication:

import OidcClient from '@edirect/oidc-client';

const client = await OidcClient({
  grantType: 'client_credentials',
  baseUrl: process.env.OIDC_PROVIDER_URL,
  oidcPath: process.env.OIDC_PROVIDER_PATH,
  clientId: process.env.OIDC_CLIENT_ID,
  clientSecret: process.env.OIDC_CLIENT_SECRET,
});

// No login data required for client_credentials
const tokenSet = await client.getAccessToken();
console.log(tokenSet.access_token);

// Note: getRefreshToken is not applicable to client_credentials

SSO Grant

Used for SSO-based authentication flows:

const client = await OidcClient({
  grantType: 'sso',
  baseUrl: process.env.OIDC_PROVIDER_URL,
  oidcPath: process.env.OIDC_PROVIDER_PATH,
  clientId: process.env.OIDC_CLIENT_ID,
  clientSecret: process.env.OIDC_CLIENT_SECRET,
  redirectUri: process.env.OIDC_CALLBACK_URL,
});

const tokenSet = await client.getAccessToken({ code: authorizationCode });

API

OidcClient(params: Connect): Promise<OidcConnect>

Factory function that initializes the OIDC client for the specified grant type.

| Parameter | Type | Description | | -------------- | --------------------------------------------- | ------------------------------------------ | | grantType | 'password' \| 'client_credentials' \| 'sso' | OAuth2 grant type | | baseUrl | string | OIDC provider base URL | | oidcPath | string | OIDC realm path (e.g., /realms/my-realm) | | clientId | string | Client ID registered in the OIDC provider | | clientSecret | string | Client secret | | redirectUri | string | Callback URL (for sso grant) |

Client Methods

| Method | Signature | Description | | ----------------- | ----------------------------------- | ------------------------------------------------------------ | | getAccessToken | (loginData?) => Promise<TokenSet> | Acquire an access token | | getRefreshToken | (tokenSet) => Promise<TokenSet> | Refresh an existing token set (not for client_credentials) |

TokenSet

interface TokenSet {
  access_token: string;
  token_type: string;
  expires_in: number;
  refresh_token?: string; // not present for client_credentials
  refresh_expires_in?: number;
  id_token?: string;
  session_state?: string;
  scope?: string;
}

Environment Variables

| Variable | Description | | -------------------- | ------------------------------------------------------------- | | OIDC_PROVIDER_URL | OIDC provider base URL (e.g., https://keycloak.example.com) | | OIDC_PROVIDER_PATH | OIDC realm path (e.g., /realms/my-realm) | | OIDC_CLIENT_ID | Client ID | | OIDC_CLIENT_SECRET | Client secret | | OIDC_USERNAME | Username (for password grant) | | OIDC_PASSWORD | Password (for password grant) | | OIDC_CALLBACK_URL | Redirect URI (for sso grant) |