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

@torquedev/ext-authorization

v0.1.0

Published

HookBus-based authorization middleware for Torque. Enforces role and record-level access control via bundle manifest declarations.

Readme

@torquedev/ext-authorization

HookBus-based authorization middleware for Torque. Reads permissions: declarations from bundle manifests and intercepts interface:before-call and route:before hooks to enforce role and record-level access control before business logic runs.

Install

npm install github:michaeljabbour/torque-ext-authorization

Peer dependency: @torquedev/core >=0.1.0

Usage

import { AuthorizationService } from '@torquedev/ext-authorization';

const authService = new AuthorizationService({
  hookBus,
  coordinator,
  config: {
    defaultPolicy: 'deny',   // 'deny' (default) | 'allow'
    logDenials: true,
    logGrants: false,
  },
});

coordinator.registerService('authorization', authService);

Bundles declare permissions in manifest.yml:

permissions:
  createDeal:
    roles: [admin, sales_rep]
  archiveDeal:
    roles: [admin]
  updateDeal:
    roles: [admin, sales_rep]
    check: owner_or_admin
    record_from: dealId
    getter: getDeal

Enforcement flow

Each call passes through three stages:

  1. Unauthenticated check -- if no currentUser is present, the call is rejected.
  2. Role check -- currentUser.role must appear in the permission's roles array.
  3. Record-level check -- an optional check function runs against the resolved record.

When no permission rule is declared for a method, the defaultPolicy config decides the outcome.

API

checkPermission(bundle, method, { currentUser, record, args })

Non-throwing permission check. Returns { value: true } or { value: false, message }.

registerCheck(name, fn)

Register a custom check function. Receives { currentUser, record, args, coordinator, bundle, method } and should throw AuthorizationError on failure. May be async.

hasPermission(bundle, method)

Returns true if a permission rule is declared for the given bundle method.

listPermissions()

Returns all declared permissions keyed by bundle.

bundlePermissions(bundle)

Returns the permissions object for a single bundle.

Built-in checks

| Check | Behaviour | |---|---| | owner_or_admin | Admin bypasses; others must own the record. | | team_visible | Record owner must be in the current user's team. Falls back to owner_or_admin. | | self_only | User can only act on their own records. | | created_by | Admin bypasses; others must have created the record. |

AuthorizationError

Thrown on access denial. Caught by the server and returned as HTTP 403.

import { AuthorizationError } from '@torquedev/ext-authorization';

err.status   // 403
err.code     // 'FORBIDDEN'
err.bundle   // e.g. 'pipeline'
err.method   // e.g. 'updateDeal'

Exports

import { AuthorizationService, AuthorizationError, builtinChecks } from '@torquedev/ext-authorization';

Testing

npm test

ESM-only. Requires Node.js with the built-in test runner.

License

MIT