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

vibrant-oauth2-client

v1.0.1

Published

Vibrant Wellness OAuth2 client for Node.js

Readme

vibrant-oauth2-client

OAuth2 client credentials client for the Vibrant Wellness API. Handles token acquisition, caching, and automatic refresh.

Features

  • Client Credentials grant flow against https://api.vibrant-wellness.com/v1/oauth2/token
  • Automatic caching — tokens are reused until they expire (with a 60-second safety buffer)
  • Request deduplication — concurrent getToken() calls share a single in-flight request
  • Dual format — ships both CommonJS and ESM builds with full TypeScript declarations

Requirements

  • Node.js >= 18.0.0

Installation

npm install vibrant-oauth2-client

Configuration

Set the following environment variables before instantiating the client:

| Variable | Description | | ---------------------- | ---------------------------------- | | VIBRANT_CLIENT_ID | Your OAuth2 client ID | | VIBRANT_CLIENT_SECRET| Your OAuth2 client secret |

Usage

import { VibrantClient } from "vibrant-oauth2-client";

const client = new VibrantClient();

// Returns a cached token or fetches a new one automatically.
// The returned string includes the token type prefix (e.g. "Bearer <token>").
const token = await client.getToken();

// Use the token in downstream requests:
const response = await fetch("https://api.vibrant-wellness.com/v1/some-endpoint", {
  headers: { Authorization: token },
});

// Force a fresh token on next call:
client.clearCache();

API

new VibrantClient()

Creates a new client. Reads VIBRANT_CLIENT_ID and VIBRANT_CLIENT_SECRET from the environment. Throws if either is missing.

client.getToken(): Promise<string>

Returns a valid access token string (prefixed with the token type, e.g. Bearer ...). Automatically fetches a new token when the cached one is expired or about to expire.

client.clearCache(): void

Clears the cached token so the next getToken() call fetches a fresh one.

Exported Types

interface TokenResponse {
  access_token: string;
  token_type: string;
  expires_in: number;
  scope?: string;
}

interface CachedToken {
  accessToken: string;
  expiresAt: Date;
}

Development

# Install dependencies
npm install

# Build (CJS + ESM + type declarations)
npm run build

License

MIT