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

@key-value-kit/electron

v0.1.0-alpha.0

Published

Electron safeStorage encryption adapter with caller-owned ciphertext storage.

Readme

@key-value-kit/electron

A main-process adapter composing Electron safeStorage encryption with a caller-owned KeyValueStore<Uint8Array> for ciphertext. Experimental alpha (0.1.0-alpha.0). There is no Electron runtime dependency or built-in file store.

import { app, safeStorage } from 'electron';
import type { KeyValueStore } from '@key-value-kit/core';
import { createElectronSecretStore } from '@key-value-kit/electron';

// Supply your application's existing durable byte store.
export async function openSecrets(ciphertexts: KeyValueStore<Uint8Array>) {
  await app.whenReady();
  return createElectronSecretStore(safeStorage, ciphertexts, {
    namespace: 'my-app:credentials:v1',
  });
}

The returned store accepts strings. Writes encrypt before persisting and resolve after the backing write completes. Reads restore a Buffer from stored bytes before decrypting. Missing entries return null; storage and encryption errors reject. Only ciphertext is handed to the backing store; key names remain visible. Protect its integrity, availability and durability as part of your application. For JSON-only persistence, explicitly adapt bytes with a codec; never serialize a Buffer implicitly and assume it will deserialize as bytes.

Namespaces share an existing backing store safely. The adapter does not expose clear() because it cannot enumerate only its entries. Deletion and missing-entry reads do not require decryption, so removal remains possible when the vault is unavailable. There is no automatic migration, key rotation, or plaintext fallback.

Encryption policy

Before every encryption or decryption operation, the adapter checks isEncryptionAvailable(). On Linux it additionally requires a recognized gnome_libsecret, kwallet, kwallet5 or kwallet6 backend. It refuses basic_text, unknown, a missing backend-reporting API and unrecognized providers. A newly supported upstream provider needs explicit review before adding it here. The adapter never calls setUsePlainTextEncryption or changes global settings.

This version deliberately uses the synchronous safeStorage API so the Linux backend policy can be checked against that API's selected backend. Its calls may block or prompt even though the store's public methods return promises. Electron recommends its newer asynchronous encryption API, but that API uses a separate provider system; the synchronous backend selector cannot establish which async provider is protecting the data. There is no automatic switch between formats.

Run this adapter in the main process, after app.whenReady(). Keep sensitive operations there; expose only narrowly scoped, validated IPC operations to a renderer rather than forwarding arbitrary secret reads. OS protection differs by platform and does not protect secrets from an already-compromised application. See Electron's safeStorage documentation.

Tests exercise the adapter with an isolated test cipher, unavailable/insecure backend cases, corrupt data, persistence failures and published Electron type declarations. They do not launch Electron or access the personal OS keychain.