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

@auth-gate/rbac

v0.14.0

Published

RBAC as code for AuthGate — define resources, roles, and permissions in TypeScript and sync them with a single CLI command.

Readme

@auth-gate/rbac

RBAC as code for AuthGate — define resources, roles, and permissions in TypeScript and sync them with a single CLI command.

Installation

npm install @auth-gate/rbac

Quick Start

1. Generate a starter config

npx @auth-gate/rbac init

2. Define your RBAC config

// authgate.rbac.ts
import { defineRbac } from "@auth-gate/rbac";

export const rbac = defineRbac({
  resources: {
    documents: { actions: ["read", "write", "delete"] },
    billing: { actions: ["read", "manage"] },
  },
  roles: {
    admin: {
      name: "Admin",
      grants: {
        documents: { read: true, write: true, delete: true },
        billing: { read: true, manage: true },
      },
    },
    member: {
      name: "Member",
      isDefault: true,
      grants: {
        documents: { read: true, write: true },
      },
    },
    viewer: {
      name: "Viewer",
      grants: {
        documents: { read: true },
      },
    },
  },
});

3. Sync to AuthGate

export AUTHGATE_API_KEY=ag_...
export AUTHGATE_BASE_URL=https://www.authgate.dev

npx @auth-gate/rbac diff   # Preview changes
npx @auth-gate/rbac sync   # Apply changes

Type Safety

defineRbac() validates grants at compile time. Referencing an undeclared resource or action is a TypeScript error.

rbac.resources.documents.key           // "documents"
rbac.resources.documents.actions.read  // "documents:read"
rbac.roles.admin.key                   // "admin"
rbac.permissions.documents.write       // "documents:write"

CLI Commands

| Command | Description | |---------|-------------| | npx @auth-gate/rbac init | Generate a starter config file | | npx @auth-gate/rbac diff | Preview changes without applying | | npx @auth-gate/rbac sync | Apply changes to AuthGate | | npx @auth-gate/rbac pull | Pull server state into a local config |

Features

  • Type-safe grants — compile-time validation of resources, actions, and roles
  • Role inheritance — roles can inherit permissions from other roles via inherits
  • Rename migrations — rename roles without losing assignments via renamedFrom
  • Conditional grants — attach condition functions to grant values
  • Default role — mark one role as isDefault: true for new org members
  • Diff before sync — preview all changes before they're applied
  • Coexists with dashboard — roles created in the dashboard are preserved

Runtime Role Management

import { createRoleManagement } from "@auth-gate/rbac";

const roles = createRoleManagement({
  apiKey: process.env.AUTHGATE_API_KEY!,
  baseUrl: process.env.AUTHGATE_BASE_URL!,
});

await roles.list();
await roles.create({ key: "editor", name: "Editor", permissions: ["documents:read", "documents:write"] });
await roles.update("editor", { name: "Content Editor" });
await roles.delete("editor");

License

MIT