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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@jitar-plugins/authentication

v0.0.3

Published

This package provides plugins for integrating the [The Shelf authentication package](https://github.com/MaskingTechnology/theshelf/tree/main/packages/authentication) in Jitar applications.

Readme

Authentication | Jitar Plugins

This package provides plugins for integrating the The Shelf authentication package in Jitar applications.

It contains two types of middleware:

  • Authentication - server side authentication handling.
  • Requester - client side authentication handling.

Both are required for the integration.

Installation

npm install @theshelf/authentication @jitar-plugins/authentication @jitar-plugins/http

Usage

Follow the following steps to configure and use the provided plugins.

Step 1 - Configure the middleware

Both types of middleware need to be instantiated with configuration.

The authentication middleware operates on the server side and handles the actual authentication.

// src/middleware/authenticationMiddleware.ts

import identityProvider from '@theshelf/authentication';
import { AuthenticationMiddleware } from '@jitar-plugins/authentication';

// FQNs to the auth handling procedures
const authProcedures = {
    loginUrl: 'domain/authentication/getLoginUrl',
    login: 'domain/authentication/login',
    logout: 'domain/authentication/logout'
};

// The client path to return to after a succesful login
const redirectPath = '/afterlogin';

const whiteList: string[] = [
    // List of public FQNs
];

export default new AuthenticationMiddleware(identityProvider, authProcedures, redirectPath, whiteList);

The requester middleware operates on the client side (web browser) and provides auth informations with every request.

// src/middleware/requesterMiddleware.ts

import { RequesterMiddleware } from '@jitar-plugins/authentication/client';

// The server provides a session key after login that needs to be captured.
const key = new URLSearchParams(globalThis.location?.search).get('key');
const authorization = key !== undefined ? `Bearer ${key}` : undefined;

export default new RequesterMiddleware(authorization);

To make sure the client redirects to the original location after login, we also need a third middleware comming from the http package.

// src/middleware/originMiddleware.ts

import { OriginMiddleware } from '@jitar-plugins/http';

export default new OriginMiddleware();

Step 2 - Activate the middleware

With the middleware in place, the need to be activated.

For the server side, this means adding the authentication middleware to the service configuration. This is most likily the proxy / standalone service.

/* services/proxy.json */
{
    "url": "http://example.com:3000",
    "middleware": [ /* add middleware here, in this order */
        "./middleware/originMiddleware",
        "./middleware/authenticationMiddleware"
    ],
    "proxy":
    {
        /* service configuration */
    }
}

On the client side, it needs to be added to the Vite configuration.

// vite.config.ts

import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import jitar from '@jitar/plugin-vite';

export default defineConfig({
  build: {
    emptyOutDir: false
  },
  plugins: [
    react(),
    jitar({
      sourceDir: 'src',
      targetDir: 'dist',
      jitarDir: 'domain',
      jitarUrl: 'http://localhost:3000',
      segments: [],
      middleware: [ './middleware/requesterMiddleware' ] // Add middleware here
    })
  ]
});

Step 3 - Implement the auth procedures

The authentication middleware refers to three procedures that need to be implemented in the application.

// src/domain/authentication/getLoginUrl'.ts

export default async function getLoginUrl(): Promise<string>
{
    // The authentication middleware will provide the login url.
    return '';
}
// src/domain/authentication/login'.ts

export default async function login(identity: Identity): Promise<Requester>
{
    // Get the requester data from the given identity.
}
// src/domain/authentication/logout'.ts

export default async function logout(): Promise<void>
{
    // The authentication middleware will handle the logout.
    // Implementent additional logic here.
}

Step 4 - Expose the auth procedures

The procedures need to be exposed publicly to make them acessible.

{
    "./domain/authentication/getLoginUrl": { "default": {  "access": "public" } },
    "./domain/authentication/login": { "default": {  "access": "public" } },
    "./domain/authentication/logout": { "default": {  "access": "public" } }
}

Step 5 - Implement the client redirect path

This path will be called after a succesful login with the session key.

GET http://app.example.com/afterlogin?key=XXXXXX

The requester middleware grabs and stores the key, the app can ignore it.