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

@zerocat-software/zerobrix-auth

v1.0.12

Published

Modern authentication solution for Next.js applications using ZeroBrix wallet

Readme

@zerocat-software/zerobrix-auth

ZEROCAT Banner

A modern, secure, and easy-to-use authentication library for Next.js applications powered by ZeroBrix blockchain. Perfect for projects that need blockchain-based authentication with a beautiful frosted-glass modal UI and encrypted user management.

npm version License

Why ZeroBrix Auth?

ZeroBrix Auth brings enterprise-grade blockchain authentication to your Next.js application with minimal setup. While ZeroBrix Blockchain is our proprietary solution for secure transactions, this authentication library is fully open-source, allowing developers to:

  • ✅ Inspect and verify the security implementation
  • ✅ Contribute improvements and features
  • ✅ Trust through code transparency
  • ✅ Customize the solution for specific needs

Features At a Glance

  • 🎨 Beautiful Modal UI: Frosted glass design with smooth animations
  • 🔐 Secure Authentication: QR code-based blockchain authentication
  • 🔒 Encrypted Storage: Built-in encrypted JSON database
  • 📱 Mobile Ready: Seamless ZeroWallet mobile app integration
  • 🔄 Flexible Onboarding: Individual and company account support
  • Zero Config: No manual route setup needed
  • 🎯 Simple Integration: Just wrap your components
  • 🌐 TypeScript Ready: Full type support

Installation

# Using npm
npm install @zerocat-software/zerobrix-auth

# Using yarn
yarn add @zerocat-software/zerobrix-auth

# Using pnpm
pnpm add @zerocat-software/zerobrix-auth

Complete Setup Guide

1. Environment Variables

Create or update .env.local in your project root:

# Required: ZeroBrix API Configuration
ZEROBRIX_API_URL=https://brix.zerocat.one/api/v2
ZEROBRIX_API_KEY=your_api_key
AUTH_CONTRACT_ID=your_contract_id

# Required: Public Variables
NEXT_PUBLIC_SERVER_WALLET_ADDRESS=your_wallet_address
NEXT_PUBLIC_ZEROCOIN_TOKEN_ID=your_token_id

# Optional: Database Encryption
DB_ENCRYPTION_KEY=your_random_32_byte_hex_string

2. Create Auth API Route

Create app/api/auth/route.ts:

import { createAuthApiHandler } from '@zerocat-software/zerobrix-auth';

// Important for Next.js dynamic routes
export const dynamic = 'force-dynamic';

// Export the authentication handlers
export const { GET, POST } = createAuthApiHandler({
  // Optional: Add custom validation
  customValidation: async (walletAddress: string) => {
    return true; // Allow all wallets by default
  }
});

3. Add the Provider

In your app/layout.tsx:

import { AuthProvider } from '@zerocat-software/zerobrix-auth';

export default function RootLayout({
  children
}: {
  children: React.ReactNode
}) {
  return (
    <html>
      <body>
        <AuthProvider
          config={{
            // Required
            appName: "Your App Name",
            appDescription: "Login securely with ZeroWallet",
            
            // Optional: Theme
            theme: {
              primary: "blue",
              secondary: "teal"
            }
          }}
        >
          {children}
        </AuthProvider>
      </body>
    </html>
  );
}

4. Protect Your Pages

Simply wrap any page that needs authentication:

'use client';

import { withAuth, useAuth } from '@zerocat-software/zerobrix-auth';

function ProtectedPage() {
  const { user, logout } = useAuth();
  
  return (
    <div>
      <h1>Protected Content</h1>
      <p>Welcome back!</p>
      
      {/* User will be either individual or company */}
      <div>
        {user?.company_name ? (
          <p>Company: {user.company_name}</p>
        ) : (
          <p>Name: {user.first_name} {user.last_name}</p>
        )}
      </div>
      
      <button onClick={logout}>Logout</button>
    </div>
  );
}

export default withAuth(ProtectedPage);

Understanding the Authentication Flow

How It Works

  1. User visits a protected page
  2. Auth modal automatically appears
  3. User scans QR code with ZeroWallet
  4. ZeroWallet processes the authentication transaction
  5. Library verifies the transaction
  6. If new user, shows onboarding form
  7. User is authenticated and can access protected content

The Modal UI

The authentication modal includes:

  • Clean, modern frosted glass design
  • ZEROCAT branding (subtle corner logo)
  • Step-by-step guidance
  • Smooth transitions
  • QR code display
  • Loading states
  • Error handling

User Data Storage

All user data is stored in an encrypted JSON file:

  • Automatic encryption/decryption
  • Secure at rest
  • No database setup needed
  • Handles both user types:
    • Individual (first name, last name)
    • Company (company name)

Customization Options

Styling

<AuthProvider
  config={{
    // Theme colors
    theme: {
      primary: "indigo",    // Any Tailwind color
      secondary: "purple"   // Any Tailwind color
    },
    
    // Custom class names
    customStyles: {
      card: "backdrop-blur-xl bg-white/10",
      button: "hover:scale-105",
      input: "focus:ring-2"
    }
  }}
>

Onboarding Configuration

<AuthProvider
  config={{
    onboardingFields: {
      // Enable/disable company accounts
      allowCompany: true,
      
      // Field requirements
      requireName: false,
      requireEmail: false,
      
      // Available roles
      availableRoles: ["User", "Admin"]
    }
  }}
>

Custom Validation

export const { GET, POST } = createAuthApiHandler({
  customValidation: async (walletAddress: string) => {
    // Example: Check whitelist
    const whitelist = ['0x123...'];
    return whitelist.includes(walletAddress);
    
    // Or check domain
    const email = await getEmailForWallet(walletAddress);
    return email.endsWith('@yourcompany.com');
  }
});

Troubleshooting Guide

Modal Not Appearing

// Make sure to:
// 1. Add 'use client' directive
'use client';

// 2. Wrap the component
export default withAuth(YourComponent);

// 3. Use inside AuthProvider
function App() {
  return (
    <AuthProvider config={...}>
      <YourComponent />
    </AuthProvider>
  );
}

Styling Issues

// In tailwind.config.js
module.exports = {
  content: [
    // Essential: Include the library's components
    "./node_modules/@zerocat-software/zerobrix-auth/**/*.{js,ts,jsx,tsx}"
  ]
}

Database Issues

# Create data directory
mkdir data
chmod 755 data

# Check .env.local
DB_ENCRYPTION_KEY should be exactly 32 bytes when converted to hex

Security Best Practices

  1. Always keep your API keys secure
  2. Don't expose your DB_ENCRYPTION_KEY
  3. Use custom validation for additional security
  4. Implement role-based access control
  5. Regularly update the library

Support

License

Licensed under the BSD-3-Clause License. See LICENSE for more information.


zerocat.artLinkedInBlog