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

auth-guard-component

v1.0.0

Published

A reusable authentication guard component that challenges users with a number sorting puzzle

Readme

Auth Guard Component

A reusable authentication guard component that challenges users with a number sorting puzzle before granting access to protected content.

Features

  • Generates 5 unique random numbers between 1-100
  • Randomly selects ascending or descending order challenge
  • Clean, professional UI with customizable styling
  • Success and failure callbacks
  • Configurable number of attempts
  • Ready for NPM publishing

Installation

npm install auth-guard-component

Usage

ES6 Import

import AuthGuard from 'auth-guard-component';

const authGuard = new AuthGuard({
  onSuccess: () => {
    // Handle successful authentication
    console.log('Authentication successful!');
  },
  onFailure: () => {
    // Handle failed authentication
    console.log('Authentication failed!');
  },
  container: document.getElementById('auth-container')
});

authGuard.render();

Script Tag

Include the script directly in your HTML:

<script src="node_modules/auth-guard-component/dist/auth-guard.min.js"></script>
<script>
  const authGuard = new window.AuthGuard({
    onSuccess: () => {
      console.log('Authentication successful!');
    },
    onFailure: () => {
      console.log('Authentication failed!');
    },
    container: document.getElementById('auth-container')
  });
  
  authGuard.render();
</script>

Options

  • onSuccess: Callback function called when the challenge is completed successfully
  • onFailure: Callback function called when the challenge fails
  • container: DOM element where the component will be rendered
  • ascendingText: Text to display when sorting ascending (default: "Sort in ascending order")
  • descendingText: Text to display when sorting descending (default: "Sort in descending order")
  • resetText: Text for the reset button (default: "Reset")
  • maxAttempts: Maximum number of attempts allowed (default: 3)

Methods

  • render(): Renders the auth guard component in the specified container
  • resetChallenge(): Resets the current challenge with new numbers
  • resetSelection(): Resets only the user's current selection

Styling

The component comes with default professional styling that follows modern design principles, but you can customize it using CSS. The component uses the following CSS classes:

  • .auth-guard-container - Main container
  • .auth-guard-instructions - Instructions text
  • .auth-guard-numbers - Container for number boxes
  • .auth-guard-number - Individual number box
  • .auth-guard-number.selected - Applied when number is selected
  • .auth-guard-number.correct - Applied when number is in correct position
  • .auth-guard-number.incorrect - Applied when number is in wrong position
  • .auth-guard-controls - Container for control buttons
  • .auth-guard-reset - Reset button

Examples

Basic Implementation

import AuthGuard from 'auth-guard-component';

const authGuard = new AuthGuard({
  container: document.getElementById('auth-container'),
  onSuccess: () => {
    // Redirect user to protected page
    window.location.href = '/dashboard';
  },
  onFailure: () => {
    alert('Authentication failed. Please try again.');
    authGuard.resetChallenge();
  }
});

authGuard.render();

Customized Implementation

const authGuard = new AuthGuard({
  container: document.getElementById('auth-container'),
  onSuccess: () => {
    console.log('Access granted!');
    // Your success logic here
  },
  onFailure: () => {
    console.log('Access denied!');
    // Your failure logic here
  },
  ascendingText: 'Arrange in ascending order',
  descendingText: 'Arrange in descending order',
  resetText: 'New Challenge',
  maxAttempts: 5
});

authGuard.render();

Development

To contribute to this project:

  1. Fork and clone the repository
  2. Install dependencies: npm install
  3. Start development mode: npm run dev
  4. Make your changes
  5. Build the project: npm run build

License

MIT