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

@anarchitects/auth-declarations

v0.8.3

Published

Declaration-only security metadata decorators for Anarchitecture auth-aware Nest controllers.

Readme

@anarchitects/auth-declarations

Declaration-only security metadata for auth-aware Nest controllers.

Use this package when a feature/controller brick needs to declare security intent without depending on the runtime-heavy @anarchitects/auth-nest package.

Features

  • Declare route-level security intent without importing runtime guards or modules
  • @Public() marks a class or route handler as intentionally public
  • @Policies(...rules) declares coarse CASL-aligned route policies
  • @AuthorizeResource(...resources) declares resource-aware policies with an idParam
  • Convenience aliases @RequirePermissions(...) and @RequireResourceAccess(...)
  • Metadata constants exported for runtime packages that need to read these declarations

Installation

npm install @anarchitects/auth-declarations
# or
yarn add @anarchitects/auth-declarations
# or
pnpm add @anarchitects/auth-declarations

Peer dependency: @nestjs/common ^11.0.0

Usage

import { AuthorizeResource, Policies, Public } from '@anarchitects/auth-declarations';

@Public()
export class HealthController {}

export class PostsController {
  @Policies({ action: 'update', subject: 'Post' })
  @AuthorizeResource({ action: 'update', subject: 'Post', idParam: 'postId' })
  updatePost() {
    return true;
  }
}

@Policies(...) is the primary generic authorization declaration. It is a coarse route pass check and does not prove ownership or other instance-sensitive rules. Concrete resource authorization belongs to the runtime flow once the subject instance is available.

Typical pairing:

import { Module } from '@nestjs/common';
import { AuthModule, provideAuthRuntimeGuards } from '@anarchitects/auth-nest';

@Module({
  imports: [AuthModule.forRoot({})],
  providers: [...provideAuthRuntimeGuards()],
})
export class AppModule {}

Controllers declare intent through @anarchitects/auth-declarations. Host apps activate the runtime once, centrally, through @anarchitects/auth-nest.

Exports

  • @Public() — marks a class or route handler as intentionally public.
  • @Policies(...rules) — declares coarse CASL-aligned route policies using the existing { action, subject } route policy shape.
  • @AuthorizeResource(...resources) — declares resource-aware policies with an idParam; it is metadata-only and does not bind guards.
  • @RequirePermissions(...permissions) — convenience alias for @Policies(...).
  • @RequireResourceAccess(...resources) — convenience alias for @AuthorizeResource(...).
  • AUTH_PUBLIC_METADATA_KEY, POLICIES_KEY, AUTHORIZE_RESOURCE_KEY — metadata key constants for runtime packages.
  • RoutePolicy, ResourceAuthorizationRoute — re-exported types.

Runtime Boundary

This package does not enforce authentication or authorization. It does not export guards, providers, modules, principal resolution, request-resource extraction, or app-shell activation helpers.

It also does not export @AuthorizedResource(). That helper belongs to the runtime package because it reads the resource that auth-nest attached to the request after authorization.

Runtime enforcement belongs to @anarchitects/auth-nest, which can read this metadata from controllers and apply the appropriate security behavior.

Development notes

  • nx build auth-declarations - build the package.
  • nx test auth-declarations - run the Vitest unit tests.