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

@we8/auth

v0.4.0

Published

The embedded admin auth provider for we8: Better Auth over the site's own D1, email and password, first account becomes the owner.

Readme

@we8/auth

The embedded admin sign-in for a @we8/cms site: Better Auth over the site's own D1, email and password, mounted at /api/auth/*. The first account created becomes the owner and public sign-up closes behind it; every account after that is created by the owner. Password reset goes through the CMS's email seam.

The CMS core has no auth of its own. It knows which capabilities each role holds, and it asks a registered provider who a request is. This package is that provider, and installing it is the answer for anyone who does not already run an identity provider.

Five roles, and the CMS's ROLE_CAPABILITIES is the one place that says what each reaches: owner and full-admin hold everything, content-admin holds the editorial site and its inbox, product-admin holds the catalogue and its assets, and member is an editor, exactly as in 0.3. Only the owner may assign or remove owner and full-admin, so a full-admin runs the site without being able to mint a peer and lock the owner out.

Requirements

  • A @we8/cms worker on Cloudflare Workers, with nodejs_compat enabled.
  • The same D1 database the CMS uses, bound as DB.
  • The secret BETTER_AUTH_SECRET. Sign-in is refused without it, rather than validating a session the worker could not have signed. AUTH_URL is optional and defaults to SITE_URL.
  • Its migrations applied: we8-cloudflare migrate applies the CMS sequence and then this package's, or point wrangler at node_modules/@we8/auth/migrations yourself. 0.4 adds 0002_auth_roles.sql, an index and nothing else.
  • Runtime dependencies, bundled at deploy: better-auth and drizzle-orm, with @we8/cms, hono, and zod as peers. Node 20 or newer for the tooling around it.

Use it

import cms, { registerAdminAuth } from '@we8/cms';
import { embeddedAdminAuth } from '@we8/auth';

registerAdminAuth(embeddedAdminAuth);

export default cms;

That is the whole integration. npm create we8 writes it for you.

openssl rand -hex 32                          # the value
npx wrangler secret put BETTER_AUTH_SECRET    # for the deployment
npm run db:migrate                            # the tables

Then create the owner, once:

curl -X POST https://your-site.example/api/auth/sign-up/email \
  -H 'Content-Type: application/json' \
  -d '{"email":"[email protected]","password":"a-long-enough-password","name":"You"}'

With the admin portal bundled, opening / offers the same thing as a form. GET /api/v1/auth/mode reports whether that first account can still be created.

What it adds to the API

  • POST /api/auth/*: sign-up, sign-in, sign-out, session, and password reset, Better Auth's own routes at its own prefix.
  • /api/v1/admin/users: the site's users, behind the users capability. List, create (optionally in a named role), change a role, delete. A site always keeps at least one account that can manage users, nobody changes or deletes their own account here, and only the owner assigns or removes owner and full-admin.

Both are gated by the CMS's own admin rules, so a role without the capability is refused by exactly the rule that refuses it everywhere else, and no API key ever reaches either.

Leaving it out

Nothing forces this package on a site. @we8/cms without any registered provider serves its whole public API and refuses every /api/v1/admin/* request with a message naming what to do about it, so an unconfigured deploy is locked rather than open. If your admin sits behind an identity provider you already run, register a provider of your own instead: resolve(request, env) returning { userId, role } is the required half of the interface.

Upgrading a site that had auth inside the CMS

The tables are the same ones, and this package's migration is written to find them already there: it creates nothing, drops nothing, and fails at nothing. Install this package, add the registration line to your worker, run npm run db:migrate, and everyone signs in exactly as before.

More

  • @we8/cms: the CMS this signs into.
  • create-we8: scaffolds a project with all of it composed.
  • GET /api/v1/openapi.json on any install: the public contract, live and keyless.