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

vali-storages

v2.1.0

Published

TypeScript browser storage library with AES-GCM encryption, TTL expiration, namespacing, cross-tab sync, batch operations, and a fully type-safe API.

Readme

vali-storages

TypeScript library for browser storage management with AES-GCM encryption, TTL expiration, namespacing, cross-tab sync, and a fully typed API.

npm version license docs

📖 Documentation: vali-storages-docs.netlify.app · English · Español


Installation

npm install vali-storages
# or
bun add vali-storages

Quick Start

import { ValiStorages } from 'vali-storages';
import { AES, TimeUnit } from 'vali-storages';

const storage = new ValiStorages({
    isEncrypt: true,
    predefinedKey: 'my-secret-key',
    keySize: AES.AES_256,
    timeExpiration: 2,
    timeUnit: TimeUnit.HOURS,
    prefix: 'myapp',
});

await storage.setItem('user', { name: 'Felipe', role: 'admin' });
const user = await storage.getItem<{ name: string; role: string }>('user');

Type-Safe Storage

import { createTypedStorage } from 'vali-storages';

interface AppSchema {
    userId: number;
    token: string;
    settings: { theme: 'dark' | 'light' };
}

const storage = createTypedStorage<AppSchema>({ prefix: 'myapp' });

await storage.setItem('userId', 42);           // ✅ OK
await storage.setItem('userId', 'wrong');      // ❌ TypeScript error
const token = await storage.getItem('token'); // → string | null

Key Features

| Feature | Description | |---------|-------------| | 🔐 AES-GCM encryption | AES-128 / 192 / 256 via Web Crypto API | | ⏱ TTL expiration | Seconds, minutes, hours, or days | | 🔄 Sliding expiration | TTL resets on every successful read | | 🏷 Namespacing | Isolate keys between instances with prefix | | 📡 Cross-tab sync | React to changes from other browser tabs | | 🧩 Batch operations | setItems / getItems / getAll | | 🛡 Error handling | throw, silent, or custom handler | | 🔒 Type-safe API | createTypedStorage<Schema>() | | 🖥 SSR guard | Clear error when used outside browser |


API Overview

// Write
await storage.setItem(key, value)
await storage.setItems({ key1: val1, key2: val2 })

// Read
await storage.getItem<T>(key)                       // T | null
await storage.getItems<T>(['key1', 'key2'])         // Record<string, T | null>
await storage.getAll<T>()                           // Record<string, T>
await storage.getOrSet(key, () => computeValue())   // T

// Check
storage.has(key)       // boolean
storage.size()         // number
storage.getAllKeys()   // string[]

// Delete
storage.removeItem(key)
storage.removeExpired()
storage.clear()

// TTL
storage.updateExpiry(key)   // boolean — reset TTL manually

// Lifecycle
storage.destroy()              // remove cross-tab listener
ValiStorages.isAvailable()    // boolean — check storage availability

Changelog

v2.1.0

  • Internal: cross-tab sync extracted to CrossTabSync class (SRP) — no public API changes
  • Fix: updateExpiry uses safeStorageSet for consistent quota-exceeded handling
  • Fix: cryptoInstance properly typed as ICrypto | null; all access sites guarded
  • Fix: cross-tab decrypt path returns null instead of throwing when instance has no crypto

v2.0.0 (Breaking)

  • setItem / getItem are now async — add await to all calls
  • getItem no longer uses a callback — returns Promise<T | null>
  • Added: setItems, getItems, getAll, getOrSet, has, removeExpired, updateExpiry, size, prefix, slidingExpiration, onError, onChange, createTypedStorage, ValiStorages.isAvailable, destroy

Documentation


License

MIT — Felipe Rafael Montenegro Morriberon