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

@useoneauth/policies

v1.0.0

Published

> Phase 6 — Policy Engine. Centralized authorization: `can(request)` over composable RBAC / ABAC / ReBAC.

Downloads

300

Readme

@useoneauth/policies

Phase 6 — Policy Engine. Centralized authorization: can(request) over composable RBAC / ABAC / ReBAC.

Pure TypeScript. One PolicyEngine composes pluggable evaluators — each returns permit / deny / abstain — and combines them with deny-overrides + default-deny. Decisions carry obligations (step-up auth, scope restriction) and emit POLICY_ALLOWED / POLICY_DENIED. Stores are in-memory behind ports.

Install

// package.json
{ "dependencies": { "@useoneauth/policies": "workspace:*" } }

Usage

import {
  PolicyEngine, RbacEvaluator, AbacEvaluator, RebacEvaluator,
  InMemoryRoleStore, InMemoryRelationshipResolver,
} from "@useoneauth/policies"
import { EventBus, InMemoryEventStore } from "@useoneauth/events"

const roles = new InMemoryRoleStore()
roles.assignRole("u1", "editor")
roles.defineRole("editor", [{ action: "edit", resourceType: "document", effect: "permit" }])

const rels = new InMemoryRelationshipResolver()
rels.addRelationship("u1", "owns", "d1")

const engine = new PolicyEngine({
  evaluators: [
    new RbacEvaluator(roles),
    new AbacEvaluator([
      { id: "owner", effect: "permit", condition: (r) => r.resource.attributes?.ownerId === r.subject.id },
    ]),
    new RebacEvaluator(rels, [{ action: "edit", resourceType: "document", relation: "owns" }]),
  ],
  events: new EventBus(new InMemoryEventStore()), // durable, auditable decisions
})

const decision = await engine.can({
  subject: { id: "u1" },
  action: "edit",
  resource: { type: "document", id: "d1", attributes: { ownerId: "u1" } },
})
// { effect: "allow", reason: "permitted by ...", obligations: {}, results: [...] }

Models

  • RBACRbacEvaluator(RoleStore): subject's roles → Permission { action, resourceType, effect }, with "*" wildcards; deny-overrides within the evaluator.
  • ABACAbacEvaluator(AbacPolicy[]): typed predicate policies { id, effect, appliesTo?, condition(request) } (programmatic — no string DSL).
  • ReBACRebacEvaluator(RelationshipResolver, RebacRule[]): one-hop relationship check (subject —relation→ resource.id). Multi-hop is a future phase.

Decision model

Each evaluator returns permit | deny | abstain. The engine: any denydeny; else any permitallow (merging obligations: stepUp OR, scope union); else (all abstain) → default deny. Every decision includes a per-evaluator results trace for audit.

Events

POLICY_ALLOWED, POLICY_DENIED via the @useoneauth/events-core EventPublisher (wire the Phase-5 EventBus for a durable, replayable authorization audit trail).

Scope

RBAC + ABAC full; ReBAC one-hop only; no expression-language DSL; no policy-admin API; no DB/HTTP/CLI. Subjects/resources are string ids — no dependency on @useoneauth/identity.

See ARCHITECTURE.md.