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

@zenv-sh/amnesia

v0.0.1

Published

Pure TypeScript cryptographic engine for zEnv — Argon2id, AES-256-GCM, X25519 NaCl box

Downloads

79

Readme

@zenv-sh/amnesia

Pure TypeScript cryptographic engine for zEnv. Byte-identical reimplementation of the Go Amnesia package using Web Crypto API, hash-wasm, and tweetnacl.

No network. No storage. Takes bytes in, gives bytes out.

API

// Key derivation — Argon2id, 64 bytes split: KEK (0-31) + Auth Key (32-63)
deriveKeys(vaultKey: string, salt: Uint8Array, keyType: "pin" | "passphrase")
  → Promise<{ kek: Uint8Array; authKey: Uint8Array }>

// Symmetric encryption (AES-256-GCM via Web Crypto API)
encrypt(plaintext: Uint8Array, key: Uint8Array)
  → Promise<{ ciphertext: Uint8Array; nonce: Uint8Array }>
decrypt(ciphertext: Uint8Array, nonce: Uint8Array, key: Uint8Array)
  → Promise<Uint8Array>

// Key wrapping
wrapKey(dek: Uint8Array, kek: Uint8Array) → Promise<{ ciphertext, nonce }>
unwrapKey(ciphertext: Uint8Array, nonce: Uint8Array, kek: Uint8Array) → Promise<Uint8Array>

// Name hashing (HMAC-SHA256 via Web Crypto API)
hashName(name: string, hmacKey: Uint8Array) → Promise<Uint8Array>

// Auth Key hashing (Argon2id via hash-wasm)
hashAuthKey(authKey: Uint8Array) → Promise<Uint8Array>

// Asymmetric encryption (X25519 + NaCl box via tweetnacl)
generateKeypair() → { publicKey: Uint8Array; privateKey: Uint8Array }
wrapWithPublicKey(payload: Uint8Array, publicKey: Uint8Array) → Uint8Array
unwrapWithPrivateKey(packed: Uint8Array, privateKey: Uint8Array) → Uint8Array

// Secure random generation (crypto.getRandomValues)
generateSalt() → Uint8Array   // 32 bytes
generateNonce() → Uint8Array  // 12 bytes
generateKey() → Uint8Array    // 32 bytes

Usage

import { deriveKeys, encrypt, decrypt, generateSalt, generateKey } from "@zenv-sh/amnesia";

const salt = generateSalt();
const { kek } = await deriveKeys("my-passphrase", salt, "passphrase");

const dek = generateKey();
const plaintext = new TextEncoder().encode("secret-value");
const { ciphertext, nonce } = await encrypt(plaintext, dek);

const decrypted = await decrypt(ciphertext, nonce, dek);
// new TextDecoder().decode(decrypted) === "secret-value"

Dependencies

| Package | Purpose | | --- | --- | | hash-wasm | Argon2id (key derivation + auth key hashing) | | tweetnacl | NaCl box (X25519 + XSalsa20-Poly1305) — matches Go's nacl/box | | @noble/curves | Not currently used (kept for future Ed25519 if needed) |

Cross-Language Parity

This package must produce byte-identical output to the Go Amnesia for the same inputs. Parity is enforced by shared test vectors:

  1. Go generates tests/vectors.json with known inputs and expected outputs
  2. TypeScript validates against the same JSON file
  3. CI runs both — any drift fails the build

Covered operations: DeriveKeys, AES-256-GCM encrypt/decrypt, HashName (HMAC-SHA256), HashAuthKey (Argon2id).

Testing

bun test

22 unit tests + 8 cross-language parity tests = 30 total.