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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@utilitywarehouse/uw-lib-auth.js

v1.2.5

Published

JWT based OAuth2 auth client and express middleware.

Downloads

67

Readme

This package is now deprecated, and should not be considered secure and will not be maintained

uw-lib-auth.js

A node.js module providing universal auth implementation for use in utilitywarehouse service implementation.

OAuth2 + JWT

This handler applies if a Authorization: Bearer <token> header is present. JWT verification is implemented using a private/public key pair where private part is held secretly by issuing server (uw-service-shepherd) and public key is issued to implementing services.

Extending with your own handlers

The module exposes an 'abstract' class module.Method.Method that your handler needs to be extending. You are required to implement following methods:

  • applies(headers hash) : bool - a synchronous function accepting a hash of request headers (all lowercase) that returns true if the correct header is present
  • execute(headers hash, callback fn(err, result)) : void - an asynchronous function accepting a hash of request headers and a result callback, any result out of the auth process can be passed in the callback and will be attached to reques

Usage

const express = require('express');
const path = require('path');
const app = express();

const authModule = require('./..');

const auth = new authModule.Provider([
	new authModule.Method.oAuth2JWT({
		key: authModule.Key.fromFile(path.join(__dirname, '../tests/resources/public.pem')),
		algo: [authModule.Key.RS256]
	})
]);

app.use(auth.middleware());

app.get('/:id', /*auth.middleware.scope('partner.:id.read'),*/ function (req, res) {
  res.json({auth: req.auth});
});

app.use((error, req, res, next) => {
	res.status(error.status).json(error);
});

app.listen(3000, function () {
  console.log('Example app listening on port 3000!')
})

NPM

Lib is published on NPM under the utilitywarehosue namespace. It is public.

yarn add @utilitywarehouse/uw-lib-auth.js