Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

crypto-storage

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

crypto-storage

A light & secure way to store data in browser.

  • 0.6.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
7
increased by600%
Maintainers
1
Weekly downloads
 
Created
Source

crypto-storage

logo

A light & secure way to store data in a browser.

Build for create server less front end application in a safe way.

Install

yarn add crypto-storage

Usage

const CryptoStorage = require('crypto-storage')

// create a storage
const safeStorage = CryptoStorage({name: 'tester', password: 'super-pw'})
safeStorage.create()

// create an item and get it
await safeStorage.setItem('foo', 'bar')
const foo = await safeStorage.getItem('foo')
console.log(foo) // => 'bar'

// close your session
safeStorage.close()

// open it again (.use() this time)
const safeStorage2 = CryptoStorage({name: 'tester', password: 'super-pw'})
safeStorage2.use()

const newFoo = await safeStorage.getItem('foo')
console.log(newFoo) // => 'bar'

// if you try to create the session again
safeStorage2.create() // => throw!!

API

Methods

const storage = CryptoStorage({name: String, password: String})

Init a new storage instance.

await storage.create()

Create a new safe storage session.

await storage.use()

Open an existing session.

await storage.setItem(key: String, value: String|Array|Object):{[key]: value}

Set an item in the storage.

await storage.getItem(key: String): {[key]: value}

Get an item from the storage.

storage.removeItem(key: String): String|Array|Object)

Remove an item from the storage and return the key.

storage.close()

Close access to CryptoStorage disabling set/get/removeItem.

Keywords

FAQs

Package last updated on 06 Jun 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc