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

delfi-pkce-auth

v2.0.3

Published

Simple PKCE authentication helper for integrating SLB Delfi OAuth2 into Node.js apps.

Readme

delfi-pkce-auth

Simple PKCE authentication helper for Node.js apps integrating with DELFI / CSI OAuth 2.0.

Installation

Install the package by itself:

npm install delfi-pkce-auth

If you are starting from the Express example in this README, install all required dependencies with:

npm install express express-session delfi-pkce-auth

Features

  • Generate a PKCE code verifier
  • Generate an S256 PKCE code challenge
  • Build the DELFI authorization URL
  • Exchange an authorization code for a token
  • Read a stored access token from an Express session

Quick Start

const express = require("express");
const session = require("express-session");
const pkceAuth = require("delfi-pkce-auth");

const app = express();

app.use(session({
  secret: "replace-me",
  resave: false,
  saveUninitialized: true
}));

pkceAuth.initialize({
  clientId: process.env.DELFI_CLIENT_ID,
  redirectUri: "http://localhost:3000/callback",
  audience: process.env.DELFI_AUDIENCE // this is optional
});

app.get("/login", (req, res) => {
  const codeVerifier = pkceAuth.generateCodeVerifier();
  const codeChallenge = pkceAuth.generateCodeChallenge(codeVerifier);

  req.session.codeVerifier = codeVerifier;
  res.redirect(pkceAuth.getAuthUrl(codeChallenge));
});

app.get("/callback", async (req, res) => {
  try {
    const tokenData = await pkceAuth.exchangeCodeForToken(
      req.query.code,
      req.session.codeVerifier
    );

    req.session.token = tokenData.access_token;
    console.log(req.session.token);
    res.send("Authentication successful");
  } catch (error) {
    res.status(500).send(error.message);
  }
});

app.listen(3000);

Configuration

Call initialize() once before calling any other package functions.

pkceAuth.initialize({
  clientId: "your-client-id",
  redirectUri: "http://localhost:3000/callback",
  audience: "fwk-drillplan.slbservice.com" // correct audience for calling Drillplan
});

Options

| Option | Required | Description | | --- | --- | --- | | clientId | Yes | OAuth client ID | | redirectUri | Yes | Redirect URI registered for the client | | audience | No | Added to the authorization request scope after openid |

API

initialize(config)

Stores package configuration for later calls.

generateCodeVerifier()

Returns a random PKCE code verifier string.

generateCodeChallenge(codeVerifier)

Returns an S256 PKCE code challenge for the supplied verifier.

getAuthUrl(codeChallenge)

Builds the authorization URL using:

  • response_type=code
  • client_id
  • redirect_uri
  • code_challenge
  • code_challenge_method=S256
  • scope=openid plus audience if provided

exchangeCodeForToken(code, codeVerifier)

Exchanges the authorization code for token data from https://csi.slb.com/v2/token.

The token request includes:

  • grant_type=authorization_code
  • client_id
  • code
  • redirect_uri
  • code_verifier

Returns the parsed JSON token response.

getAccessToken(req)

Returns req.session.token if present, otherwise null.

Notes

  • audience is optional
  • authorization and token endpoints are currently fixed to:
    • https://csi.slb.com/v2/auth
    • https://csi.slb.com/v2/token
  • this package uses node-fetch@2

License

MIT