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

@encoradb/core

v0.2.0-beta

Published

The core encryption engine for **EncoraDB**. This package handles AES-256-GCM field encryption, HKDF key derivation, HMAC blind indexing for searchable queries, and SOC2 audit logging.

Downloads

51

Readme

@encoradb/core

The core encryption engine for EncoraDB. This package handles AES-256-GCM field encryption, HKDF key derivation, HMAC blind indexing for searchable queries, and SOC2 audit logging.

📦 Installation

pnpm add @encoradb/core
# or
npm install @encoradb/core

🚀 Basic Usage (Local Mode)

In Local Mode, you provide a 32-byte master key (64 hex characters) directly or via environment variable (process.env.ENCORA_MASTER_KEY).

1. Generate a Master Key

Generate a secure 32-byte hex key using openssl:

openssl rand -hex 32
# Example output: 0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef

2. Initialize EncoraDB

import { EncoraDB } from "@encoradb/core";

const encora = new EncoraDB({
  masterKey: process.env.ENCORA_MASTER_KEY, // 64 hex characters
  mode: "local",
  encryptColumns: {
    users: ["email", "ssn"],
    orders: ["credit_card"],
  },
  searchableColumns: {
    users: ["email"], // Automatically generates email_bindex HMAC search token
  },
});

// Encrypt a row
const encryptedRow = await encora.encrypt("users", {
  id: 1,
  name: "Alice",
  email: "[email protected]", // Encrypted to enc:gcm:...
});

// Decrypt a row
const decryptedRow = await encora.decryptRow("users", encryptedRow);
console.log(decryptedRow.email); // "[email protected]"

🔍 Searchable Encryption (HMAC Blind Indexing)

Standard AES-256-GCM ciphertexts change on every write. EncoraDB uses HMAC Blind Indexing to enable exact-match lookups (WHERE email = ?) without exposing plaintext to the database:

// Generate deterministic HMAC search token for exact match queries
const searchToken = encora.generateBlindIndex("users", "email", "[email protected]");
// Output: "bindex:sha256:e3b0c44298fc1c149afbf4c89..."

// Query database using searchToken:
// SELECT * FROM users WHERE email_bindex = searchToken

⚙️ Configuration

The EncoraDB constructor accepts an EncryptionConfig object:

| Property | Type | Description | | :--- | :--- | :--- | | mode | 'local' \| 'kms' | Required. Defines the encryption strategy. | | masterKey | string | Required for local mode (if ENCORA_MASTER_KEY env is not set). A 64-character hex string. | | encryptColumns | Record<string, string[]> | Map of table_name ➔ [column_names] to encrypt. | | searchableColumns | Record<string, string[]> | Optional map of table_name ➔ [column_names] for blind index generation. | | kms | KmsConfig | Required for kms mode. KMS provider configuration object. | | auditLogger | IAuditLogger | Optional. Defaults to ConsoleAuditLogger. |

🛡️ Audit Logging (SOC2)

EncoraDB includes built-in audit logging for all encryption and decryption operations.

// Default output:
// [EncoraAudit] 2026... | DECRYPT | users.email | SUCCESS |

🔧 Core API Reference

encrypt(table: string, row: object)

Encrypts sensitive columns. Auto-generates <col>_bindex if column is in searchableColumns.

decryptRow(table: string, row: object)

Decrypts sensitive columns for a given table.

autoDecryptRow(row: object, tableHint?: string)

Seamlessly decrypts row without requiring manual table aliases.

generateBlindIndex(table: string, column: string, value: string)

Computes deterministic HMAC search token for exact match queries.

📄 License

MIT