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

@zudojs/tenancy

v1.0.0

Published

Multi-tenant context and isolation with tenant resolution, AsyncLocalStorage propagation, resolver chains, trust levels, and guard middleware.

Readme

@zudojs/tenancy

Multi-tenant context and isolation: tenant resolution, context propagation, resolver chains, and guard middleware.

Installation

npm install @zudojs/tenancy

Quick Start

import {
  createJwtResolver,
  createMemoryTenantRepository,
  createResolveTenantMiddleware,
  createResolverChain,
  createSubdomainResolver,
  createTenantContextStorage,
} from "@zudojs/tenancy";

const storage = createTenantContextStorage();
const repository = createMemoryTenantRepository();

const resolver = createResolverChain([
  createJwtResolver(), // priority 100, trusted
  createSubdomainResolver({ baseDomain: "example.com" }), // priority 70
]);

// Resolves the tenant, enforces its status and the route's trust floor,
// then runs the rest of the request inside the tenant context.
const middleware = createResolveTenantMiddleware({
  resolver: resolver.asResolver(),
  repository,
  storage,
  minimumTrust: "verified",
});

Read the current tenant anywhere downstream:

import { createContextManager } from "@zudojs/tenancy";

const context = createContextManager({ storage });
const tenant = context.requireCurrentTenant();

Resolution Trust

| Source | Default trust | Note | | --------------------- | ------------- | --------------------------- | | jwt, api-key | trusted | verified credential | | subdomain, domain | verified | host-derived | | header, path | untrusted | client-supplied on the wire |

x-tenant-id is untrusted by default. Raise it with createHeaderResolver({ trust: "verified" }) only where a trusted proxy strips and re-sets the header at the edge.

Features

  • Tenant resolution from JWT claims, subdomain, custom domain, header, or path
  • Resolver chains with trust grading and conflict detection
  • AsyncLocalStorage context propagation
  • Tenant repository with slug and custom-domain indexes
  • Guard middleware and key scoping helpers

Safety Notes

  • A resolver that throws rejected a credential, and aborts the chain. Only returning undefined means "found nothing" and advances to the next resolver — so a failed JWT verification can never fall through to a client-supplied header.
  • Resolvers disagreeing about the tenant throws by default.
  • Tenant ids are normalized (NFKC, trimmed, lowercased) and constrained to ^[a-z0-9][a-z0-9_-]*$, so an id cannot forge a separator in a cache key, a schema name, or a path. tenantKey escapes its segments as well.
  • Non-active tenants are refused during resolution. Pass allowInactive on routes that exist to serve suspended tenants.

Use Cases

  • SaaS multi-tenancy
  • Per-tenant data isolation
  • Tenant-scoped caching and configuration