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

@antify/authorization-module

v3.3.0

Published

This module is responsible for handling user authorization using JWT. It ships with a set of components and utils to make it easy to integrate authorization into your application. It also supports multitenancy.

Readme

Authorization Module

This module is responsible for handling user authorization using JWT. It ships with a set of components and utils to make it easy to integrate authorization into your application. It also supports multitenancy.

Architecture

This module supports different permissions in different multi-tenant instances. All permissions should be stored in one application instance.

To encapsulate the authorization logic from your main application, this module provides an Authorization object. Extend your applications Account or User model with the Authorization object to extend your app with authorization functionality.

Permission

There's a global set of permissions. An authorization can have multiple permissions for each tenant.

Role

To make the usage of permissions easier, there are roles. A role can have multiple permissions. Each tenant have it own set of roles.

Admin

An authorization can be an admin. An admin has all permissions independent of the associated permissions.

Ban

An authorization can be banned.

The isBan flag always is more important than the isAdmin flag. E. g.: A banned user has no permissions, even if he is an admin.

An authenticated user always get a valid token, even he's banned. This gives the possibility to redirect him to login page OR show him a jail page.

Access hierarchy

To emit if an authorization has access with a specific permission, following hierarchy is used:

  • Is banned
  • Is admin
  • Has permission

TODO::

  • [ ] Add validator which check the tokens structure on runtime.
  • [ ] Add refresh token process
  • [ ] Add access token process
  • [ ] Cleanup module.ts
  • [ ] Composable to reach all permissions in system
  • [ ] Find a way to handle permissions properly across modules
  • [ ] Force logout or refresh token function to logout/ban all devices fast

Usage

Installation

pnpm i @antify/authorization-module

Add it to your nuxt.config.ts:

export default {
  modules: [
    '@antify/authorization-module'
  ]
}

Configuration

TODO

Components

TODO:: Describe it

AuthorizationModuleBanAuthorizationButton

Button to ban and unban a user.

It does:

  • Switch between ban and unban
  • Does not allow a user to ban / unban himself
  • Check if the user has the expected permission to ban / unban (CAN_BAN_AUTHORIZATION | CAN_UNBAN_AUTHORIZATION | is an admin)

AuthorizationModuleJailPage

A default jail page to show a user that he is banned.

Important

Populate the authorization.roles

Because .roles is a relation to the roles table, you need to populate it. Also be careful, you need to add the model property to the populate method, because @antify/database is a multi connection client. To make mongoose work properly, you need to specify the model. Read more about it here.

const user = await UserModel
  .findOne({_id: userId})
  .populate({
    path: 'authorization.roles',
    model: client.getModel(defineRoleSchema)
  });

Development

  • Run pnpm run dev:prepare to generate type stubs.
  • Use pnpm run dev to start playground in development mode.