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

foxia-auth-sdk

v0.0.3

Published

A lightweight and efficient SDK for seamless integration of Foxia Authentication (OIDC) into your Node.js applications.

Readme

Foxia Auth SDK

A lightweight and efficient SDK for seamless integration of Foxia Authentication (OIDC) into your Node.js applications.

Installation

Install the package via npm:

npm install foxia-auth-sdk

Getting Started

Import and initialize FoxiaAuth with your configuration details:

const { FoxiaAuth } = require('foxia-auth-sdk');

const auth = new FoxiaAuth({
    clientId: 'your-client-id',
    clientSecret: 'your-client-secret',
    redirectUri: 'your-redirect-callback-uri',
    hydraPublicUrl: 'your-hydra-public-url',
    scopes: ['openid', 'profile', 'email']
});

Integration Guide

Step 1: Generate Login URL

Create a route to redirect users to the Foxia login page:

// Route: /login
app.get('/login', (req, res) => {
    const { url, state } = auth.generateAuthUrl();
    
    // Store 'state' in session or cookie to verify later (CSRF protection)
    req.session.oauthState = state;
    
    res.redirect(url);
});

Step 2: Handle Callback and Token Exchange

After successful login, the user will be redirected to your redirectUri with code and state parameters.

// Route: /callback
app.get('/callback', async (req, res) => {
    const { code, state } = req.query;
    
    // 1. Verify state
    if (state !== req.session.oauthState) {
        return res.status(400).send('Invalid state');
    }
    
    try {
        // 2. Exchange code for tokens
        const tokens = await auth.exchangeCode(code);
        
        // tokens object includes:
        // {
        //   access_token: "...",
        //   id_token: "...",
        //   refresh_token: "...",
        //   expires_in: 3600,
        //   ...
        // }
        
        console.log('Access Token:', tokens.access_token);
        
        // Store tokens or create a local session for the user...
        res.json(tokens);
        
    } catch (error) {
        console.error('Login failed:', error.message);
        res.status(500).send('Authentication failed');
    }
});

Step 3: Retrieve User Information

Use the Access Token to fetch the user's profile information:

const userInfo = await auth.getUserInfo(accessToken);

console.log(userInfo);
// {
//   sub: "user-id",
//   email: "[email protected]",
//   name: "Full Name",
//   ...
// }

API Reference

new FoxiaAuth(config)

  • clientId (string, required): Your application's Client ID.
  • redirectUri (string, required): The registered callback URL.
  • hydraPublicUrl (string, required): The Base URL of the Auth server.
  • clientSecret (string, optional): Required for server-side applications (Confidential Clients).
  • scopes (array, optional): List of access privileges requested.

generateAuthUrl(options)

  • Returns { url, state }.
  • options.state: Pass a custom state value if you wish to manage it manually.
  • options.scopes: Override default scopes for this request.

exchangeCode(code)

  • Exchanges the authorization code for an Access Token, ID Token, and Refresh Token.
  • Returns a Promise that resolves to an object containing the tokens.

getUserInfo(accessToken)

  • Retrieves user profile information from the userinfo endpoint.