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

@khoadue/react-crypto

v0.1.0

Published

React field-level E2E encryption library with X25519 + AES-256-GCM envelopes, blind indexes, and optional Supabase key registry

Readme

@khoadue/react-crypto

React field-level E2E encryption library. Sensitive fields are encrypted in the browser before they reach your API or database. Only the intended recipient can decrypt.

Algorithms: X25519 (ECDH) + HKDF-SHA-256 + AES-256-GCM

Install

npm install @khoadue/react-crypto

Optional peer for Supabase public-key registry:

npm install @supabase/supabase-js

Quick start

import {
  BrowserKeyStore,
  EncryptionProvider,
  useCryptoKeySetup,
  useDecrypt,
  useEncrypt,
  publicKeyToBase64,
} from '@khoadue/react-crypto';

const keyStore = new BrowserKeyStore();

export function App({ userId }: { userId: string }) {
  return (
    <EncryptionProvider keyStore={keyStore} keyId={`user:${userId}`}>
      <PatientForm />
    </EncryptionProvider>
  );
}

function PatientForm({ userId, doctorId }: { userId: string; doctorId: string }) {
  const { initializeKeys } = useCryptoKeySetup(userId);
  const { encrypt, encrypting } = useEncrypt();
  const { decrypt, decrypting } = useDecrypt();

  async function onSubmit(form: { ssn: string; name: string }) {
    await initializeKeys();
    const doctorPublicKeyB64 = await fetchDoctorPublicKey(doctorId);

    const payload = await encrypt(form, {
      ssn: { recipientId: doctorId, publicKeyB64: doctorPublicKeyB64 },
    });

    await fetch('/api/patients', {
      method: 'POST',
      body: JSON.stringify(payload),
    });
  }

  async function onLoad(record: Record<string, unknown>) {
    return decrypt(record, ['ssn']);
  }

  // render form using encrypting/decrypting flags for UX
}

Envelope format

Encrypted fields are stored as compact strings:

enc:v1:x25519-aes256gcm:{iv}:{ct}:{eph}:{kid}

| Part | Meaning | |------|---------| | iv | Base64 12-byte AES-GCM IV | | ct | Base64 ciphertext + auth tag | | eph | Base64 ephemeral X25519 public key | | kid | Recipient key id, e.g. user:uuid |

API

Core exports

| Export | Purpose | |--------|---------| | EncryptionProvider | Injects KeyStore + active keyId | | useEncrypt() | Encrypt selected fields before submit | | useDecrypt() | Decrypt encrypted fields after fetch | | useCryptoKeySetup(userId) | Generate/load user keypair in key store | | encryptField / encryptFields | Low-level encrypt helpers | | decryptField / decryptFields | Low-level decrypt helpers | | generateBlindIndex | HMAC blind index for searchable encrypted fields | | BrowserKeyStore | IndexedDB-backed key storage (browser) | | MemoryKeyStore | In-memory key storage (tests/SSR injection) | | isEncryptedField | Detect envelope strings |

Supabase adapter

import { createSupabaseKeyRegistry } from '@khoadue/react-crypto/supabase';
import { supabase } from './supabase-client';

const registry = createSupabaseKeyRegistry({
  supabase,
  userId: currentUserId,
  keyStore,
});

await registry.registerPublicKey();
const doctorKey = await registry.fetchPublicKey(doctorUserId);

Expects a user_public_keys table (see e2e-field-encryption skill schema): user_id, public_key, key_type, is_active.

Security notes

  • Private keys never leave the client key store.
  • Do not log plaintext, private keys, or envelope contents.
  • Validate inputs before encrypting; treat decrypted output as sensitive.
  • Blind indexes enable equality search but are not full-text search.

Development

npm install
npm run build --workspace=@khoadue/react-crypto
npm run test --workspace=@khoadue/react-crypto

License

MIT