All Projects → little-core-labs → secret-local-storage

little-core-labs / secret-local-storage

Licence: MIT license
A wrapper around 'localStorage/sessionStorage' to provide storage encryption with libsodium

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to secret-local-storage

GenuineChannels
Collection of custom .NET Remoting channels
Stars: ✭ 29 (+38.1%)
Mutual labels:  secure
react-state
React-State - Superpowers for managing local and reusable state in React
Stars: ✭ 14 (-33.33%)
Mutual labels:  local
IpfsBox
a full ipfs node on android
Stars: ✭ 18 (-14.29%)
Mutual labels:  local
secure-media
Store private media securely in WordPress.
Stars: ✭ 22 (+4.76%)
Mutual labels:  secure
tuyagateway
Local Python Gateway for Tuya devices
Stars: ✭ 102 (+385.71%)
Mutual labels:  local
generate-secure-pillar
Salt Secure Pillar Tool
Stars: ✭ 30 (+42.86%)
Mutual labels:  secure
2ami
Your easy 2FA companion that keep the secrets secret.
Stars: ✭ 24 (+14.29%)
Mutual labels:  secure
rel
command line tool for managing personal graphs of anything and writing them to dot
Stars: ✭ 51 (+142.86%)
Mutual labels:  local
keystore-ultimate
The ultimate solution for keystore manipulation in Android
Stars: ✭ 30 (+42.86%)
Mutual labels:  secure
safenotes
SafeNotes a complete self-hosting secrets sharing app
Stars: ✭ 25 (+19.05%)
Mutual labels:  secure
devproxy
A local development http proxy with hosts spoofing written in Go
Stars: ✭ 35 (+66.67%)
Mutual labels:  local
server-command
Launches PHP's built-in web server for a specific WordPress installation.
Stars: ✭ 69 (+228.57%)
Mutual labels:  local
aws-secure-websockets
Secure web socket implementation using AWS products and serverless framework
Stars: ✭ 49 (+133.33%)
Mutual labels:  secure
data-api-suite
Monorepo that includes libraries, Serverless Framework plugins and development tools to simplify and enhance the development, deployment and use of the Data API for Aurora Serverless.
Stars: ✭ 23 (+9.52%)
Mutual labels:  local
LightWeightMusicPlayer
a local music player
Stars: ✭ 21 (+0%)
Mutual labels:  local
koa-plus
The Koa framework extended for APIs. Optimized for security, scalability, and productivity.
Stars: ✭ 17 (-19.05%)
Mutual labels:  secure
bookshelf-secure-password
A Bookshelf.js plugin for handling secure passwords
Stars: ✭ 24 (+14.29%)
Mutual labels:  secure
logger
☠ 😈 👀 Simple,Secure & Undetected (6.11.2017) keylogger for Windows :)
Stars: ✭ 37 (+76.19%)
Mutual labels:  secure
npm-civic-sip-api
Node.js client library for the Civic Secure Identity Platform (SIP).
Stars: ✭ 25 (+19.05%)
Mutual labels:  secure
easydock
Dockerize your PHP apps ;)
Stars: ✭ 52 (+147.62%)
Mutual labels:  local

secret-local-storage

A wrapper around 'localStorage/sessionStorage' to provide storage encryption with libsodium

Installation

$ npm install secret-local-storage

Usage

const { keygen } = require('secret-local-storage/keygen')
const secretKey = keygen()
const secretStorage = require('secret-local-storage')(secretKey) // will generate key by default

secretStorage.setItem('someKey', 'some secret value')
console.log(secretStorage.getItem('someKey')) // some secret value
console.log(localStorage.getItem('someKey')) // 5J3nmcMCcABSwJN

Example

const secretStorage = require('secret-local-storage')('3e852b5d881b22261b8e417e217a9fa9757f4532305c4e46e2a6966aa89840f6')

localStorage.setItem('hello', 'world')
console.log(secretStorage.getItem('hello')); // outputs 'hello'

secretStorage.setItem('hello', 'world')
console.log(localStorage.getItem('hello')); // should be encrypted

API

The SecretLocalStorage class implements the same API as the Storage API.

const secretStorage = require('secret-local-storage')(secretKey, opts)

Create a secret storage instance with an optional secret key and options where:

  • secretKey is a 32-byte buffer or 64 character 'hex' encoded string. The encoding of the secret key can be specified with opts.secretKeyEncoding. If you do not supply a secret key, then one will be generated for you. This should be saved and re-used to read the encrypted values.

  • opts is an optional object to configure the storage where:

    • opts.secretKeyEncoding is the encoding of the secret key
    • opts.valueEncoding is an object containing encode(value) and decode(buffer) functions.
    • opts.storage can be Storage interface or a function that returns one.
    • opts.seed is an optionl seed value to generate the secret key that should be 32 bytes

secretKey.secretKey

A 32 byte secret key used for encryption and child key derivation.

secretStorage.storage

The Storage interface backing the SecretLocalStorage instance.

secretKey.valueEncoding

The value encoding used for encoding and ecoding value written to storage.

secretKey.valueEncoding.encode(value)

Encodes value into a Buffer

secretKey.valueEncoding.decode(buffer)

Decodes buffer into a value. Most likely, a string.

secretStorage.key(n)

The same API as Storage.key().

secretStorage.getItem(key)

The same API as Storage.getItem(). If decryption fails, this function will return the original value found in storage.

secretStorage.setItem(key)

The same API as Storage.setItem().

secretStorage.removeItem(key)

The same API as Storage.removeItem().

secretStorage.clear(key)

The same API as Storage.clear().

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].