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

@cyberadityacode/secure-ls

v1.0.0

Published

A secure localStorage wrapper using AES-GCM encryption.

Readme

🛡️ @cyberadityacode/secure-ls

A lightweight, secure wrapper for localStorage using AES-GCM (128-bit) encryption. Built on top of the Web Crypto API, it ensures your sensitive browser data remains encrypted and unreadable to XSS attacks or manual inspection.

✨ Features

  • 🔐 AES-GCM Encryption: Modern, fast, and secure authenticated encryption.
  • 🔑 PBKDF2 Key Derivation: Robust password-based key stretching with 100,000 iterations.
  • 📦 Automatic JSON Parsing: Store objects and arrays directly without manual stringification.
  • 🚀 Asynchronous API: Non-blocking encryption/decryption operations.
  • 🔹 TypeScript Support: Full type definitions included for a better developer experience.

📥 Installation

npm install @cyberadityacode/secure-ls

## 🚀 Quick Start

```javascript
import { SecureLS } from "@cyberadityacode/secure-ls";

// 1. Initialize with a strong password and a unique salt
const storage = new SecureLS("your-secret-password", "optional-unique-salt");

async function handleAuth() {
  // 2. Set encrypted item (Objects are automatically handled!)
  await storage.setItem("user_session", {
    id: 1,
    token: "abc-123",
    role: "admin",
  });

  // 3. Get and decrypt item
  const session = await storage.getItem("user_session");
  console.log(session.token); // "abc-123"
}
```

## Example:

```javascript

import { SecureLS } from "@cyberadityacode/secure-ls";

// 1. Initialize once (outside component is fine)
const storage = new SecureLS("your-secret-password", "optional-unique-salt");

export default function TestComponent() {
  async function handleAuth() {
    // 2. Set encrypted item
    await storage.setItem("user_session", {
      id: 1,
      token: "abc-123",
      role: "admin",
    });

    // 3. Get and decrypt item
    const session = await storage.getItem("user_session");
    console.log(session.token); // "abc-123"
    console.log(session.role);  // "admin"
  }

  return (
    <div>
      <h1>SecureLS Test</h1>
      <button onClick={handleAuth}>Test Secure Storage</button>
    </div>
  );
}

```

## 📖 API Reference

| Method                | Description                                                                      |
| --------------------- | -------------------------------------------------------------------------------- |
| `setItem(key, value)` | Encrypts and stores data. `value` can be a string, object, or array.             |
| `getItem(key)`        | Retrieves and decrypts data. Returns `null` if not found or if decryption fails. |
| `removeItem(key)`     | Removes the item from localStorage.                                              |
| `clear()`             | Clears all data from localStorage.                                               |

## ⚠️ Security Note

While this library encrypts data, remember that any client-side code is accessible to the user. For maximum security:

1. Do not hardcode your `password` in the source code (use environment variables or user-derived inputs).
2. Use a unique `salt` for different applications.

## 📄 License

MIT © [Aditya Dubey](https://www.google.com/search?q=https://github.com/cyberadityacode)

## Author : Aditya Dubey (cyberadityacode)