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

elkyn-store

v0.1.2

Published

Embedded real-time tree database with security rules

Readme

@elkyn/store

Embedded real-time tree database with Firebase-style security rules for Node.js.

Features

  • 🌳 Tree-structured data - Intuitive path-based organization
  • Zero-copy operations - Built with Zig for maximum performance
  • 🔒 JWT authentication - Secure token-based access control
  • 🛡️ Security rules - Firebase-compatible declarative rules
  • 💾 LMDB storage - ACID compliant, crash-safe persistence
  • 🔗 Native bindings - Direct C interface, no overhead

Installation

npm install @elkyn/store

Prerequisites:

  • Node.js 16+
  • LMDB system library (brew install lmdb on macOS)
  • C++ compiler for native compilation

Quick Start

const { ElkynStore } = require('@elkyn/store');

// Initialize database
const store = new ElkynStore('./my-data');

// Basic operations
store.set('/users/123', {
    name: 'Alice',
    email: '[email protected]'
});

const user = store.get('/users/123');
console.log(user); // { name: 'Alice', email: '[email protected]' }

// Clean up
store.close();

Authentication & Security

// Enable JWT authentication
store.enableAuth('your-secret-key');

// Setup Firebase-style security rules
store.setupDefaultRules();
// Or custom rules:
store.enableRules({
    rules: {
        users: {
            "$userId": {
                ".read": "$userId === auth.uid",
                ".write": "$userId === auth.uid"
            }
        }
    }
});

// Create tokens and access data
const token = store.createToken('alice', '[email protected]');

// Secure operations
store.set('/users/alice/private', { secret: 'data' }, token);
const private = store.get('/users/alice/private', token);

API Reference

Constructor

new ElkynStore(dataDir)

  • dataDir (string): Directory path for database files

Authentication

enableAuth(secret: string): boolean

Enable JWT authentication with the given secret key.

createToken(uid: string, email?: string): string

Create a JWT token for testing/development. Throws if auth not enabled.

Security Rules

enableRules(rules: string | object): boolean

Load Firebase-style security rules from JSON string or object.

setupDefaultRules(): boolean

Enable default rules: users can only access their own data.

Data Operations

set(path: string, value: any, token?: string): boolean

Set JSON value at path. Throws on auth/rules violation.

get(path: string, token?: string): any

Get and parse JSON value. Returns null if not found. Throws on access denied.

setString(path: string, value: string, token?: string): boolean

Set raw string value. More efficient than JSON operations.

getString(path: string, token?: string): string | null

Get raw string value.

delete(path: string, token?: string): boolean

Delete value at path. Throws on auth/rules violation.

Lifecycle

close(): void

Close database connection and free resources.

Security Rules Syntax

Rules follow Firebase Realtime Database syntax:

{
    "rules": {
        // Public read access
        "public": {
            ".read": "true",
            ".write": "false"
        },
        
        // User-specific data
        "users": {
            "$userId": {
                ".read": "$userId === auth.uid",
                ".write": "$userId === auth.uid",
                
                // Public profile info
                "name": {
                    ".read": "true"
                }
            }
        },
        
        // Admin-only data
        "admin": {
            ".read": "auth.uid === 'admin'",
            ".write": "auth.uid === 'admin'"
        }
    }
}

Rule Variables

  • auth.uid - User ID from JWT token
  • auth.email - Email from JWT token
  • $variable - Path variables (e.g., $userId)
  • true/false - Literal boolean values

Error Handling

try {
    store.set('/protected/data', { value: 123 }, invalidToken);
} catch (error) {
    if (error.message === 'Authentication failed') {
        // Invalid or expired token
    } else if (error.message === 'Access denied') {
        // Rules prevented access
    }
}

Performance

  • Zero-copy reads - Direct access to LMDB data
  • Batch operations - Multiple operations in single transaction
  • Memory efficient - No JSON parsing for string operations
  • Native speed - Zig-compiled core with C bindings

License

MIT