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 🙏

© 2024 – Pkg Stats / Ryan Hefner

deepvault

v1.0.1

Published

Safely store data in the browser with AES encryption

Downloads

126

Readme

DEEPVAULT - DOCUMENTATION

WHAT IS IT?

DeepVault allows you to safely store data in the browser with AES encryption.

MOTIVATION

Storing data in the browser is very convenient, but not secure. It can be fixed by only storing it in an internal volatile state that gets erased once the user closes the app or refreshes the page. This technique offers a good level of security but necessitate to repeat api calls to retrieve the same data each time a user launches your app.

Thanks to DeepVault, you can now directly encrypt sensitive data (geolocation, email, etc.), in your browser and access it with a cryptographic key as if you were using good old local storage.

features:

  • Save, read, update and delete encrypted data in the browser.
  • Supports Typescript.
  • No dependencies.
  • Extra-light package.

HOW DOES IT WORK?

Vaults file

  • Create a vaults.js file (the name and the extension doesn't matter).
  • Create as many instances of DeepVault as you want and export them.
  • Each instance is dedicated to a single dataset.
import DeepVault from "deepvault";

export const userVault = new DeepVault("user");
export const cashVault = new DeepVault("cash");

Save data

import { userVault } from "./vaults";
 
   const onLogin = async (form) => {  
     try {
        const user = await login(form)
        await userVault.encryptAndSaveData(user)    
        return saveUserInGlobalState(user)
      }
     catch(err){
        throw new Error(err)
     }

Read data

import { userVault } from "./vaults";
 
   const getUser = async () => {  
     try {
        const user = await userVault.getDecryptedData()
        if (user) return saveUserInGlobalState(user)
        return null
      }
     catch(err){
        throw new Error(err)
     }

Update data

import { userVault } from "./vaults";
 
   const updateUser = async (user) => {  
     try {
        await userVault.updateData(user)  
        return saveUserInGlobalState(user)
      }
     catch(err){
        throw new Error(err)
     }

Delete data

import { userVault } from "./vaults";
 
   const logout = async () => {  
     try {
        await userVault.deleteData()  
        return clearGlobalState()
      }
     catch(err){
        throw new Error(err)
     }

The dummy functions saveUserInGlobalState() and clearGlobalState() are not part of DeepVault. You should implement them yourself. If you use React, Redux or Zustand will work fine.

Methods

DeepVault offers you 6 methods:

| |Type |Role | |----------------|-------------------------------|-----------------------------| |decryptData |(data: string) => Promise<any> |Decrypt data. | |deleteData |() => void |Delete data. | |encryptAndSaveData |(data: any) => void|Encrypt and save data| |getEncryptedData |() => string|Get data without decrypting it. Useful to check the existence of an item without any need to access its information.| |getDecryptedData |() => Promise<any>|Get decrypted data.| |updateData |(data: any) => Promise<string>|Update an item already encrypted and saved. This method will replace the former data with the new one.|

CONTRIBUTING

Feel free to send your pull requests or to raise issues on the github repository.

SECURITY

Albeit DeepVault should bring a good level of security to the persistent data stored in your users' browsers, it may not be immune to all attacks. Please weight up the pros and cons and design your app carefully.

You can learn more about Advanced Encryption Standard and Galois Counter Mode here:

  • https://en.wikipedia.org/wiki/Galois/Counter_Mode
  • https://fr.wikipedia.org/wiki/Advanced_Encryption_Standard

CREDITS

DoneDeal0

Logo made by throwaway icons from the Noun Project