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

secure-localdb

v1.0.0

Published

Um banco de dados local simples, rápido e seguro para Node.js, com criptografia AES-256-GCM, derivação de chave Argon2 e escritas atômicas.

Downloads

6

Readme

Secure-LocalDB 🔐

NPM
Version License:
MIT

Secure-LocalDB is a simple, fast, and secure local database for Node.js applications.
It provides a familiar API similar to other file-based databases but with a critical addition: strong, built-in encryption.

All data is stored in a single file, fully encrypted at rest using AES-256-GCM, with a key derived from your password via Argon2.
It's designed to be resilient, performant, and easy to use, offering both synchronous and asynchronous APIs to fit any use case.


✨ Key Features

  • 🔒 Strong Encryption: End-to-end encryption using AES-256-GCM.\
  • 🔑 Secure Key Derivation: Argon2id to derive encryption keys from passwords.\
  • 🛡️ Data Integrity: GCM mode prevents tampering and corruption.\
  • Fast In-Memory Cache: Reads directly from memory.\
  • 💪 Resilient & Atomic Writes: No corruption --- always consistent.\
  • 🤝 Flexible API: Asynchronous (ideal for servers) & synchronous (ideal for CLIs).\
  • 📦 Extensible with Plugins: UUIDs, timestamps, and custom plugins.\
  • Modern & Typed: Fully written in TypeScript.

📦 Installation

npm install secure-localdb

🚀 How to Use

1. Asynchronous API (Recommended for Servers)

import { SecureDBAsync } from 'secure-localdb';
import { join } from 'path';

const dbFile = join(__dirname, 'my-app-database.db.enc');

async function main() {
  const db = new SecureDBAsync(dbFile, {
    password: 'a-very-strong-and-secret-password',
  });

  await db.init();
  console.log('Database initialized!');

  await db.insert({ id: 1, user: 'alice', role: 'admin' });
  await db.insert({ id: 2, user: 'bob', role: 'user' });

  const admin = await db.findOne(doc => doc.role === 'admin');
  console.log('Admin user:', admin);

  await db.update(doc => doc.user === 'bob', { role: 'editor' });

  await db.remove(doc => doc.user === 'alice');
  console.log('Alice removed.');
}

main().catch(console.error);

2. Synchronous API (Ideal for Scripts)

import { SecureDB } from 'secure-localdb';
import { join } from 'path';

const dbFile = join(__dirname, 'my-script-database.db.enc');

try {
  const db = new SecureDB(dbFile, {
    password: 'another-secret-for-my-script',
  });

  db.insert({ item: 'Laptop', stock: 20 });
  db.insert({ item: 'Mouse', stock: 150 });

  const lowStock = db.find(doc => doc.stock < 50);
  console.log('Low stock:', lowStock);

  db.update(doc => doc.item === 'Laptop', { stock: 25 });
  db.remove(doc => doc.stock > 100);

  console.log('Final inventory:', db.find(() => true));
} catch (err) {
  console.error('Error:', err);
}

3. Plugins

Secure-LocalDB supports plugins like uuidPlugin and timestampsPlugin.

import { SecureDBAsync, uuidPlugin, timestampsPlugin } from 'secure-localdb';
import { join } from 'path';

const dbFile = join(__dirname, 'tasks.db.enc');

async function main() {
  const db = new SecureDBAsync(dbFile, {
    password: 'plugins-secret',
    plugins: [
      uuidPlugin(),
      timestampsPlugin(),
    ],
  });

  await db.init();
  await db.insert({ title: 'My first task' });

  const task = await db.findOne(doc => doc.title === 'My first task');
  console.log('Task with plugins:', task);
}

main().catch(console.error);

You can also customize:

uuidPlugin({ idField: '_id' });
timestampsPlugin({ createdAtField: 'created', updatedAtField: 'modified' });

📖 API Reference

SecureDBAsync(filePath, options)

  • filePath: string -- Path to the encrypted database file.\
  • options.password: string -- Password used for encryption/decryption.\
  • options.plugins?: PluginFunction[] -- Optional plugins.

Methods: - init(): Promise<void>\

  • insert(doc): Promise<void>\
  • find(predicate): Promise<Document[]>\
  • findOne(predicate): Promise<Document | undefined>\
  • update(predicate, newData): Promise<void>\
  • remove(predicate): Promise<void>

SecureDB(filePath, options)

Synchronous version with same options. Initialization happens in constructor.

Methods: - insert(doc): void\

  • find(predicate): Document[]\
  • findOne(predicate): Document | undefined\
  • update(predicate, newData): void\
  • remove(predicate): void

📜 License

This project is licensed under the MIT License.