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

oauth-static

v1.2.0

Published

## Overview

Readme

OAuth-Static

Overview

Oauth-Static is a Node.js application that provides Microsoft OAuth-based authentication, session management, and static file hosting. It is designed to serve authenticated users and restrict access to unauthorized ones.

Oauth-Static is built to integrate seamlessly with container-based services such as Docker and Kubernetes but also works well outside of containerized setups. It offers a simple and straightforward solution for hosting static files securely.

Features

  • OAuth Authentication:

    • Uses Microsoft OAuth for user authentication.
    • Serves protected content for successful login.
  • Session Management:

    • Generates session tokens with defined expiration.
    • Validates tokens for secure user sessions.
  • Access Control:

    • Denies unauthorized users and presents a 403 Forbidden error page.
    • Validates user permissions based on domain or user patterns.
  • Static File Hosting:

    • Serves files from a specified directory to authenticated users.

Requirements

  • Node.js: v20.15.1 or higher.
  • A Microsoft Azure application registered for OAuth credentials.

Environment Variables

The application uses the following environment variables. Required variables must be set for the application to start, while optional variables have defaults or can be omitted in specific setups:

Required

  • CLIENT_ID: Microsoft OAuth application client ID. Required for authentication.
  • CLIENT_SECRET: Microsoft OAuth application client secret. Required for authentication.
  • UPN_PATTERNS: Comma-separated allowed UPN patterns for access (e.g., *@example.com,[email protected]). Required for access control.

Optional

  • BASE_URL: Base URL of the application (e.g., http://localhost:3000). Defaults to http://localhost:3000 in development mode but required for production setups.
  • PORT: Application port (default: 3000). Can be omitted if the default is acceptable.
  • REDIRECT_URI: Redirect URI for OAuth flow. Defaults to BASE_URL + /login/callback if not provided.

Installation

Production Installation

  1. Install the package globally:

    npm install -g oauth-static
  2. Start the server:

    oauth-static ./folder {port}
    • Replace ./folder with the path to the directory containing the static files.
    • Replace {port} with the desired port number (optional; default is 3000).

Developer Guide

Developer Installation

  1. Clone the repository:

    git clone <repository-url>
    cd <repository-folder>
  2. Install dependencies for development:

    npm install --save-dev
  3. Configure environment variables in a .env file.

  4. Start the application in development mode:

    npm run dev

Getting Started

  1. Set Up the Environment:

    • Ensure Node.js (v20.15.1 or higher) is installed on your system.
    • Install dependencies using npm install --save-dev.
  2. Run the Server:

    • Use the dev script for development:
      npm run dev
  3. Modify or Add Features:

    • Add new routes in the routes folder.
    • Create new middlewares in the middlewares folder for custom logic.
    • Update configurations in src/config.js.
  4. Testing and Debugging:

    • Use console.log or debugging tools for troubleshooting.
    • Ensure environment variables are correctly defined to avoid configuration errors.
  5. Static File Directory:

    • For production, pass the static file directory to the oauth-static command.
    • For development, specify the directory when running the server:
      node src/index.js ./path-to-static-files

Usage

  1. For development, access the application at the specified BASE_URL and port.
  2. For production, use the oauth-static command with the desired directory and port.
  3. Login via the OAuth login page.
  4. Upon successful authentication, access the static resources provided by the application.

Known Limitations

  • The application currently supports only Microsoft OAuth.
  • Access is limited to patterns defined in UPN_PATTERNS.

Contribution

Contributions are welcome. Here’s how you can help:

  • Open Pull Requests (PRs): Fork the repository, make your changes, and open a PR for review.
  • Submit Issues: Found a bug or have a feature request? Open an issue to let us know.
  • Provide Feedback: Share your thoughts or suggestions in the issues section.

Thank you for supporting the project!