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

@o3co/auth.policy-verifier.core

v0.3.1

Published

Types, evaluation engine, and module infrastructure for auth.policy-verifier. This package defines the interfaces that collectors, rules, and modules implement.

Readme

@o3co/auth.policy-verifier.core

Types, evaluation engine, and module infrastructure for auth.policy-verifier. This package defines the interfaces that collectors, rules, and modules implement.

Runtime: Node.js 22+. This package (and the rest of auth.policy-verifier) is Node-only today; browser / edge runtime support is tracked as future work.

Install

npm install @o3co/auth.policy-verifier.core

Public API

evaluate

function evaluate(attrs: Attributes, rules: Rule[]): Decision

Evaluates collected attributes against a set of rules. Rules are grouped by ruleType; within a group, any passing rule satisfies the group (OR); all groups must be satisfied for an allow decision (AND across groups). Returns { decision: "allow" } or { decision: "deny"; code: string; message: string }.

AttributePipeline

class AttributePipeline {
  constructor(collectors: AttributeCollector[])
  collect(context: CollectorContext): Promise<Attributes>
}

Runs all collectors in parallel and merges the results. Array values are concatenated; for all other types, the last writer wins.

RulePipeline

class RulePipeline {
  constructor(collectors: RuleCollector[])
  collect(context: CollectorContext): Promise<Rule[]>
}

Runs all collectors in parallel and flattens their results into a single array.

Registry<T>

class Registry<T> {
  register(name: string, instance: T): void
  get(name: string): T
  has(name: string): boolean
  entries(): [string, T][]
}

A named registry. register throws on duplicate names; get throws if the name is not found.

Module / ModuleContext

interface Module {
  name: string
  init(context: ModuleContext): Promise<void>
}

interface ModuleContext {
  pathResolver: PathResolver
  config: Record<string, unknown>
  attributeCollectorRegistry: Registry<AttributeCollectorFactory>
  ruleCollectorRegistry: Registry<RuleCollectorFactory>
  resourceParserRegistry: Registry<ResourceParserFactory>
}

A module registers collector and parser factories into the provided registries during init. Configuration is passed through config.

Types

| Type | Description | | --- | --- | | Resource | { raw: string; resourceType: string; resourceId?: string } — parsed resource | | ResourceParser | parse(raw: string): Resource — converts a raw resource string into a Resource | | CollectorContext | Input passed to every collector: payload, resource, action, optional headers and requestContext | | Attributes | Map<string, unknown> — subject attribute bag | | AttributeCollector | collect(context: CollectorContext): Promise<Attributes> | | Rule | { ruleType: string; code: string; message: string; verify(attrs: Attributes): boolean } | | RuleCollector | collect(context: CollectorContext): Promise<Rule[]> | | Decision | { decision: "allow" } \| { decision: "deny"; code: string; message: string } | | Role | { name: string; permissions: string[] } | | VerifierPayload | Decoded JWT claims: sub, azp, scope, iss, aud, exp, iat, token, tokenType, plus arbitrary extra claims | | PathResolver | (specifier: string) => string — resolves module-relative paths | | AttributeCollectorFactory | Factory function that produces an AttributeCollector from config | | RuleCollectorFactory | Factory function that produces a RuleCollector from config | | ResourceParserFactory | Factory function that produces a ResourceParser from config |

Constants

The ATTR_* constants are limited to well-known OAuth 2.0 / OIDC and RBAC vocabulary: concepts every consumer of the ABAC engine shares (JWT claims, OAuth scopes, RBAC roles and permissions). Domain-specific attribute keys belong to the consuming service, not to core. Consumers declare their own constants and read/write the same Attributes map.

| Constant | Value | Description | | --- | --- | --- | | ATTR_SCOPES | "scopes" | Attribute key for OAuth scopes | | ATTR_PERMISSIONS | "permissions" | Attribute key for explicit permissions | | ATTR_ROLES | "roles" | Attribute key for roles | | ATTR_USER_ID | "userId" | Attribute key for the subject user ID (JWT sub) | | ATTR_CLIENT_ID | "clientId" | Attribute key for the client ID (JWT azp) |

Usage Example

import { AttributePipeline, RulePipeline, evaluate } from '@o3co/auth.policy-verifier.core'
import {
  PayloadScopeCollector,
  ResourceActionScopeRuleCollector,
  DotNotationResourceParser,
} from '@o3co/auth.policy-verifier.builtins'

const parser = new DotNotationResourceParser()
const resource = parser.parse('project:1')
const context = { payload: decodedJwt, resource, action: 'read' }

const attrs = await new AttributePipeline([new PayloadScopeCollector()]).collect(context)
const rules = await new RulePipeline([new ResourceActionScopeRuleCollector()]).collect(context)
const decision = evaluate(attrs, rules)

Writing Custom Collectors

Implement AttributeCollector (or RuleCollector), wrap it in a Module, and register the factory via ModuleContext.

// collectors/MyRoleCollector.mts
import type { Attributes, AttributeCollector, CollectorContext } from '@o3co/auth.policy-verifier.core'
import { ATTR_ROLES } from '@o3co/auth.policy-verifier.core'

export class MyRoleCollector implements AttributeCollector {
  constructor(private config: { endpointUrl: string }) {}

  async collect(context: CollectorContext): Promise<Attributes> {
    // fetch roles from your API
    return new Map([[ATTR_ROLES, roles]])
  }
}
// modules/custom.mts
import type { Module } from '@o3co/auth.policy-verifier.core'
import { MyRoleCollector } from '../collectors/MyRoleCollector.mjs'

export const customModule: Module = {
  name: 'custom',
  async init(context) {
    context.attributeCollectorRegistry.register(
      'MyRoleCollector',
      (config) => new MyRoleCollector(config),
    )
  },
}

Pass customModule to createApp in the standalone entrypoint. See the root README for the full wiring example.

For the full extension guide — including how to author custom Rule implementations, ruleType grouping semantics, and guidance on when to write custom logic vs. use @o3co/auth.policy-verifier.builtins — see docs/extending.md.

See Also