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

@unchainedshop/roles

v4.6.2

Published

Role-based access control system for the Unchained Engine

Readme

npm version License: EUPL-1.2

@unchainedshop/roles

Role-based access control (RBAC) system for the Unchained Engine. Provides fine-grained permission management for API operations.

Thanks to Nicolás López for the initial version of Roles: https://github.com/nicolaslopezj/roles

Installation

npm install @unchainedshop/roles

Usage

import { Roles, Role } from '@unchainedshop/roles';

// Create a new role
const editorRole = new Role('editor');

// Allow actions for the role
editorRole.allow('updateProduct', async (product, params, context) => {
  // Return true if allowed, false otherwise
  return context.userId != null;
});

// Check if a user has permission
const allowed = await Roles.userHasPermission(
  { userId: 'user-123', user: { roles: ['editor'] } },
  'updateProduct',
  [productObject, {}]
);

API Overview

Roles Singleton

| Method | Description | |--------|-------------| | Roles.registerAction | Register a new action name | | Roles.registerHelper | Register a new helper name | | Roles.getUserRoles | Get user roles including special roles | | Roles.allow | Check if any role allows an action | | Roles.userHasPermission | Check if user has permission for action |

Role Class

| Method | Description | |--------|-------------| | new Role(name) | Create and register a new role | | role.allow(action, fn) | Add allow rule for an action | | role.helper(name, fn) | Add helper function to role |

Built-in Roles

| Role | Description | |------|-------------| | Roles.adminRole | Admin role with elevated privileges | | Roles.loggedInRole | Applied to all logged-in users (__loggedIn__) | | Roles.allRole | Applied to all users (__all__) |

Special Internal Roles

| Role | Description | |------|-------------| | __all__ | Automatically assigned to everyone | | __loggedIn__ | Automatically assigned to authenticated users | | __notLoggedIn__ | Automatically assigned to anonymous users | | __notAdmin__ | Automatically assigned to non-admin users |

Utility Functions

| Export | Description | |--------|-------------| | has | Check if object has property | | isFunction | Check if value is a function | | permissions | Permission constants and helpers |

Types

| Export | Description | |--------|-------------| | RolesInterface | Interface for the Roles singleton | | RoleInterface | Interface for Role instances | | RoleInterfaceFactory | Factory type for Role class | | IRoleOptionConfig | Configuration options for roles | | CheckPermissionArgs | Arguments tuple for permission checks |

Configuration

import type { IRoleOptionConfig } from '@unchainedshop/roles';

const config: IRoleOptionConfig = {
  additionalRoles: {
    customRole: (roles, actions) => {
      const role = new Role('customRole');
      role.allow(actions.READ, () => true);
    },
  },
  additionalActions: ['CUSTOM_ACTION'],
};

License

EUPL-1.2