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

@betalyra/sorry-dave

v0.3.1

Published

Simple authorisation library for effect-ts

Readme

Sorry Dave

I'm afraid I can't let you do that, Dave.

A simple authorisation library for effect-ts.

https://github.com/user-attachments/assets/071ffe2e-1993-458c-8cc8-a13b640220cb

Features

  • 🔒 Type-safe
  • 📋 standard-schema compliant
  • 🚀 Easy to use
  • 📝 Declarative
  • ⚡ Fully Effect compatible

Installation

# npm
npm install @betalyra/sorry-dave

# pnpm
pnpm add @betalyra/sorry-dave

# yarn
yarn add @betalyra/sorry-dave

Getting started

sorry-dave consists of three building blocks:

  • Schema registry: Maps your domain objects to resource identifiers
  • Capabilities: Defines what your entity (usually the user) is allowed to do and under what conditions
  • Check: A check used in your program to validate that your entity (user) has sufficient permissions

Let's go through them:

1. Schema

Declare a schema for your capabilities using any standard-schema compliant library, e.g. zod.

// Define your domain model
const Article = z.object({
  article: z.literal("article"),
  authorId: z.string(),
});
const Blog = z.object({ blog: z.literal("blog"), authorId: z.string() });
const User = z.object({ id: z.string() });
type User = z.infer<typeof User>;

Next, register your schemas. Keys must be lowercase in the form of action-resource.

const registry = register({
  "read-article": Article,
  "read-blog": Blog,
  "write-article": Article,
  "write-blog": Blog,
});

2. Capabilities

Now that we have our registry up and running, let's define a set of capabilities that your entity (the user) has.

const capabilities = (user: User) =>
    define(registry)(function* () {
      yield* can("read-article"); // Anyone can read an article
      yield* can("read-blog"); // Anyone can read a blog
      // Add a condition to the capability
      yield* can("write-article", (input) =>  input.authorId === user.id); // Only the author can write an article
      yield* can("write-blog", (input) => Effect.sync(() => input.authorId === user.id)); // You can also use Effects in conditions
    });

3. Check

Finally we can check within our program whether the entity is allowed to perform certain actions:

Valid case

const user = { id: "1" };
const article = { article: "article" as const, authorId: "1" };

yield* check(capabilities(user))(function* () {
  yield* allowed("read-article", article);
  yield* allowed("write-article", article);
});

Invalid case

const user = { id: "1" };
const article = { article: "article" as const, authorId: "2" }; // The authorId does not match the user's id
// Will fail with a Denied error
yield* check(capabilities(user))(function* () {
  yield* allowed("read-article", article);
  yield* allowed("write-article", article);
});

Advanced usage

CRUD

You can easily register CRUD actions using the crud helper:

const registry = register({
  ...crud("blog", Blog),
  ...crud("article", Article),
});

Credits

This library was heavily inspired by CASL.

License

MIT