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

@filamentjs/foundation

v0.1.0

Published

Shared dependency-free types and utilities for FilamentJS policies

Readme

@filamentjs/foundation

Shared application-facing user information, lifecycle, clock, entropy, and hook types for independently installable FilamentJS policies. Protocol details such as OAuth subjects, scopes, claims, clients, and tokens deliberately stay in their owning policy packages.

Key features

  • Shared username, realm, email, culturally neutral name, role, and session contracts.
  • Composable AppMeta and ContextMeta contributions.
  • Small clock, entropy, lifecycle, and async-hook contracts for policy authors.
  • Exact role helpers and runtime validation of the shared user boundary.
  • Zero external production dependencies and no mutable global state.

Quick start

npm install @filamentjs/foundation

Initial compatibility: Node.js 24 LTS. Foundation does not import Filament at runtime and is versioned independently from filamentjs.

import type { ContextMeta as FilamentContextMeta } from "filamentjs";
import {
  hasRole,
  type ContextMeta as FoundationContextMeta,
  type UserInfo,
} from "@filamentjs/foundation";

type Context = FilamentContextMeta & FoundationContextMeta;

const user: UserInfo = {
  id: "user-123",
  username: "alice",
  realm: "employees",
  emailAddress: "[email protected]",
  fullName: "Alice Example",
  shortName: "Alice",
  roles: ["invoice-reader"],
};

const context: Context = {
  user,
};

hasRole(user, "invoice-reader"); // true

How it works and options

Foundation contributes only the root user and session context keys. Policies place translated user information or minimal session information there. They must not expose their own subjects, scopes, claims, tokens, or protocol clients through these shared fields. Applications can extend the user/profile shape through their own intersections.

fullName stores the complete name in the form supplied by the user. shortName stores a separately supplied familiar or display form—it must not be inferred by splitting or reordering fullName. This avoids imposing one culture's naming structure, following W3C guidance on personal names. roles is mutable in the TypeScript interface. A policy publishing UserInfo to request context must deeply freeze the user value at that boundary.

Exports

  • UserInfo and SessionInfo
  • composable AppMeta and ContextMeta contributions
  • Clock, EntropySource, AsyncCloseable, and MaybePromise
  • systemClock, isUserInfo(), and hasRole()

Role names are exact and case-sensitive. isUserInfo() validates the shared fields only; it does not impose application-specific profile rules.

The earlier unpublished draft names Principal, OAuthClientPrincipal, SessionIdentity, isPrincipal(), and hasScope() were intentionally removed without aliases. Migrate to UserInfo, SessionInfo, isUserInfo(), and hasRole(); OAuth client/resource-owner records now belong to the OAuth packages.

Development and demo

From a source checkout:

npm test
npm run example
npm run demo

Tests use node:test. The unattended demo validates user information, shows name fields and exact role matching, prints each step, and exits without a server.

There is no pre-0.1 migration contract.

License

ISC