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

@bastards/bcs-auth-env

v0.2.0

Published

Environment variables based authentication layer for BCS CMS

Readme

@bastards/bcs-auth-env 🔐

A simple and secure environment-based authentication layer for BCS that uses environment variables to manage users and authentication settings.

Features 🌟

  • Environment-Based User Management 👥

    • Define users directly in environment variables
    • Support for multiple users with different roles
    • Base64 encoded password storage
    • No database required
  • JWT Authentication 🎫

    • Secure token-based authentication
    • Configurable JWT secret
    • Role-based access control
    • Simple integration with BCS admin UI
  • Security First 🛡️

    • Environment-based configuration
    • Secure password handling
    • JWT token validation
    • Role-based permissions
  • Developer Experience 💻

    • Zero database setup
    • Easy deployment
    • TypeScript support
    • Framework agnostic

Installation 📦

npm install @bastards/bcs-auth-env
# or
pnpm add @bastards/bcs-auth-env
# or
yarn add @bastards/bcs-auth-env

Usage 🚀

  1. Set up your environment variables:
# Required: JWT secret for token signing
BCS_AUTH_JWT_SECRET=your-secret-key

# Required: User definitions in format "username:base64_password:role"
BCS_AUTH_USERS="admin:YWRtaW4xMjM=:admin;user:dXNlcjEyMw==:user"
  1. Configure the authentication endpoints in your bcs.config.ts:
import { defineConfig } from '@bastards/bcs';

export default defineConfig({
  admin: {
    // ... other admin config
    data: {
      auth: '/api/bcs/auth'  // Your auth endpoint
    }
  }
});
  1. Set up the authentication API endpoint in your application (example in SvelteKit):
// src/routes/api/bcs/auth/+server.ts
import { envAuth } from '@bastards/bcs-auth-env';

export const POST = async ({ request }) => {
  const auth = envAuth();
  // The auth handler will automatically handle login/logout requests
  return auth.handleRequest(request);
};

Environment Variables 🔧

| Variable | Description | Format | Required | |----------|-------------|---------|----------| | BCS_AUTH_JWT_SECRET | Secret key for JWT signing | String | Yes | | BCS_AUTH_USERS | User definitions | username:base64_password:role[;username:base64_password:role]* | Yes |

User Management 👥

Users are defined in the BCS_AUTH_USERS environment variable using the following format:

username:base64_password:role[;username:base64_password:role]*

Example:

BCS_AUTH_USERS="admin:YWRtaW4xMjM=:admin;user:dXNlcjEyMw==:user"

To generate a base64 password:

echo -n "your-password" | base64

API Reference 📚

The package exports the following:

function envAuth(options?: {
  jwtSecret?: string;    // Override JWT_SECRET from env
  users?: string;        // Override USERS from env
}): AuthHandler;

interface AuthHandler {
  handleRequest(request: Request): Promise<Response>;
  verifyToken(token: string): Promise<User>;
}

Security Best Practices 🔒

  1. Use a strong, unique JWT secret
  2. Store environment variables securely
  3. Use strong passwords for users
  4. Keep base64 encoded passwords private
  5. Use HTTPS in production

Contributing 🤝

We welcome contributions! Please see our Contributing Guide for details.

License 📄

MIT - see the main project repository for details.

Learn More 📚

For more information about BCS and its features, check out: