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

middleware_auth_lib

v1.1.1

Published

Middleware auth lib components

Downloads

11

Readme

middleware-auth-lib Build Status

Library for work with middleware auth service

About

This library export some components for work with middleware-auth-serice.

Components

How to get components?

const lib = require('middleware_auth_lib');

Auth middleware

This middleware for express.js with work together middleware-auth-service. Token get from request.headers.authorization as string => 'Bearer token';

That permit only requests with right tokens, that auth middleware get success. And send this data in request.locals.data

##How work with?

const auth = lib.authMiddleware({
    serviceId: 'signing-service',
    provider: 'http://localhost:8082'
});

const app = require('express')();
app.use(auth);

Where parameters: serviceId - identificator of microservice, that permit access provider - address of middleware-auth-service

##In success:

in object request in express middleware saves this data.
request.locals.data = all data from token
(required parameters in: clientId or userId)

##In error:

return response with 400 or 401 error

use additional middleware

we connect additional auth middleware for this middleware, that use only if given token from user not jwt (json web token) valid token.

Profile middleware

This middleware for express.js with work together laborx profile service. Token get from request.headers.authorization as string => 'Bearer token';

That permit only requests with right tokens, that auth middleware get success. And send this data in request.locals.data

##How work with?

const profile = lib.profileMiddleware({
    provider: 'http://localhost:8082/api/v1/security'
});

const app = require('express')();
app.use(profile); 

Where parameters: provider - address of laborx profile service

Or may use together with middleware-auth-service.

const profile = lib.profileMiddleware({
    provider: 'http://localhost:8082/api/v1/security'
});
const auth = lib.authMiddleware({
    serviceId: 'signing-service',
    provider: 'http://localhost:8082/api/v1/security'
}, profile);

const app = require('express')();
app.use(auth); 

##In success:

in object request in express middleware saves this data.
request.locals.data = {addresses}

##In error:

return response with 400 or 401 error

Auth client

This client work on client, that connected to service with authMiddleware and work with middleware-auth-service.

##How get token for client?

const tokenLib = new lib.Token({
    id: 'chronomint'
    provider: 'http://localhost:8083',
    secret: 'super',
});

const scopes = ['signing-service];
const token = await tokenLib.getToken(scopes);

await require('request-promise')({
    method: 'POST',
    uri: 'http://localhost:8087',
    headers: {authorization: 'Bearer ' + token}
});

Where parameters in constructor: id - identificator of this service provider - address of middleware-auth-service secret - password of this service scopes - array of scopes[services], that client want access

##How get token for user on client?

const tokenLib = new lib.Token({
    id: 'chronomint'
    provider: 'http://localhost:8083',
    secret: 'super',
});

const scopes = ['signing-service];
const userId = 'userId';
const token = await tokenLib.getUserToken(userId, scopes);

await require('request-promise')({
    method: 'POST',
    uri: 'http://localhost:8087',
    headers: {authorization: 'Bearer ' + token}
});

Where parameters in constructor: id - identificator of this service provider - address of middleware-auth-service secret - password of this service userId - id of client scopes - array of scopes[services], that user want access

License

GNU AGPLv3

Copyright

LaborX PTY