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

@adminforth/user-sessions

v2.6.4

Published

AdminForth plugin which shows active sessions of admin user and allows to revoke them

Readme

AdminForth User Sessions plugin

Shows admin user their active sessions (one per browser they signed in from) and lets them revoke any of those sessions. Logging out revokes the session as well, so its auth token stops working immediately instead of staying valid until it expires.

Full documentation: adminforth.dev/docs/tutorial/Plugins/user-sessions

Installation

npm i @adminforth/user-sessions @adminforth/key-value-adapter-redis --save
import UserSessionsPlugin from '@adminforth/user-sessions';
import RedisKeyValueAdapter from '@adminforth/key-value-adapter-redis';

export const admin = new AdminForth({
  ...
  globalPlugins: [
    new UserSessionsPlugin({
      keyValueAdapter: new RedisKeyValueAdapter({ redisUrl: process.env.REDIS_URL }),
    }),
  ],
  ...
});

Sessions then appear under "Active sessions" in the user menu settings.

To let a privileged user see and revoke sessions of other users, add canManageOtherUsersSessions. The same block then appears on the show page of the users resource:

new UserSessionsPlugin({
  keyValueAdapter,
  canManageOtherUsersSessions: async (adminUser) => adminUser.dbUser.role === 'superadmin',
})

Without this option, sessions of other users are not shown and can't be revoked by anybody.

How it works

  • AdminForth puts a unique session id into every issued auth JWT.
  • auth.afterSessionCreated hook stores <user pk>:<session id> in the key-value adapter, with the same expiration as the token, holding ip, country, user_agent, created_at and last_used_at.
  • auth.adminUserAuthorize hook checks that the session of the request is still stored, and refreshes its last_used_at. A session which is not stored is rejected with 401.
  • auth.beforeLogout hook and the revoke endpoints delete the stored session, and delete it once more 5 seconds later: a request running at that moment may have read the session just before and write it back while refreshing last_used_at.

Because a missing record means "revoked", the store must outlive the app process: use Redis (or another shared, persistent adapter) in production. With an in-memory adapter every restart signs all users out. Installing the plugin also signs out everyone who was logged in before it.

Requests authorized without a session id — MCP api keys, or tokens issued before the plugin was installed — are left alone.

Options

| Option | Default | Description | |---|---|---| | keyValueAdapter | required | Where active sessions are stored | | collection | adminforth-user-sessions | Collection (key prefix) used in the adapter | | countryHeader | CF-IPCountry | Header with two-letter country code set by your CDN. Empty string disables it | | canManageOtherUsersSessions | — | (adminUser) => Promise<boolean>. When it returns true, that user sees and can revoke sessions of other users on the users show page | | resolveCountry | — | ({ ip, headers }) => Promise<string \| null>, called when the header did not tell the country | | lastUsedThrottleSeconds | 60 | How often last_used_at is refreshed, one adapter write per refresh |

The Device column shows the browser and OS parsed from the stored User-Agent (e.g. Chrome 131 on macOS) with a desktop/mobile/tablet icon. The raw header is stored as it came, so parsing always runs on the current plugin version.

Client IP is taken from adminforth.auth.getClientIp, so configure auth.clientIpHeader when running behind a proxy — otherwise the IP is not trustworthy and is null for private addresses.

Development

pnpm i
# hooks this plugin uses are not released yet, so point it at a local adminforth checkout
# (every `pnpm i` resets this link back to the published package)
pnpm link ../../adminforth
pnpm test
pnpm build