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

@c8/auth

v1.2.0

Published

JWT Authentication Strategy, JWT issuer and API Keys/Tokens generator.

Readme

@C8/Auth

JWT Authentication Strategy, JWT issuer and API Keys/Tokens generator.

Install

npm install @c8/auth

Usage

Check the /examples folder.

API

new AuthStrategy(options)

Creates a new Authentication Strategy with a secret. It exposes a series of functions that depend upon that secret.

  • options is an object literal containing options to control how the token is extracted from the request or verified.
    • secretOrKey (REQUIRED): string or buffer containing the secret (symmetric) or PEM-encoded public key (asymmetric) for verifying the token's signature;
    • verify (REQUIRED): is a function with the parameters verify(jwtPayload, done) where jwtPayload is an object literal containing the decoded JWT payload and done is a passport error first callback accepting arguments done(error, user, info);
    • jwtFromRequest: Function that accepts a request as the only parameter and returns either the JWT as a string or null. See Extracting the JWT from the request for more details;
    • issuer: If defined the token issuer (iss) will be verified against this value;
    • audience: If defined, the token audience (aud) will be verified against this value. This should not be setup if you're using APIKeys;
    • algorithms: List of strings with the names of the allowed algorithms. For instance, ["HS256", "HS384"];
    • ignoreExpiration: if true do not validate the expiration of the token;
    • passReqToCallback: If true the request will be passed to the verify callback. i.e. verify(request, jwt_payload, done_callback);

auth.issueToken(payload, opts, callback)

Returns a new JWT string signed with the AuthStrategy instance secret.

  • payload (REQUIRED): the payload to be added to the token. Also a jti property is set to a UUID to allow for token revoking;
  • opts: any option accepted by jsonwebtoken#sign;
  • callback: if callback is not passed, the function is run synchronously and return the JWT as string;

auth.generateApiKey()

Returns an object with apiId (32 chars alphanumeric) and apiKey (64 chars alphanumeric) pair.

auth.issueTokenForApiKey(credentials, payload, opts, callback)

Returns a new JWT string signed with the AuthStrategy instance secret for the given credentials. The credentials.apiId is added to the payload.

  • credentials (REQUIRED): an object with apiId and apiKey properties;
  • payload (REQUIRED): the payload to be added to the token. Also a jti property is set to a UUID to allow for token revoking;
  • opts: any option accepted by jsonwebtoken#sign;
  • callback: if callback is not passed, the function is run synchronously and return the JWT as string;

Tests

The following commands are available:

  • coverage for running code coverage with Istanbul (it shows the report at the bottom)
  • standard for code style checks with Standardjs
  • test for running Mocha tests

Versioning

This module adheres to semver versioning. That means that given a version number MAJOR.MINOR.PATCH, we increment the:

  1. MAJOR version when we make incompatible API changes,
  2. MINOR version when we add functionality in a backwards-compatible manner, and
  3. PATCH version when we make backwards-compatible bug fixes.

Additional labels for pre-release and build metadata are available as extensions to the MAJOR.MINOR.PATCH format.

License

The MIT License

Copyright (c) 2016 C8 MANAGEMENT LIMITED