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

@adorsys/encrypt-down

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@adorsys/encrypt-down

Encryption layer for level-db

  • 1.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
66
decreased by-47.62%
Maintainers
1
Weekly downloads
 
Created
Source

:closed_lock_with_key: encrypt-down :closed_lock_with_key:

leveldb Travis Coveralls npm npm Conventional Commits JavaScript Style Guide styled with prettier NpmLicense

An abstract-leveldown implementation that wraps another store to encrypt values.

Installation

npm install @adorsys/encrypt-down

Usage

Without any options encrypt-down can be used but nothing is encrypted.

const memdown = require('memdown')
const encryptdown = require('@adorsys/encrypt-down')
const levleup = require('levelup')

const db = levelup(encryptdown(memdown()))

db.put('key', { awesome: true }, function (err) {
  db.get('key', function (err, value) {
    console.log(value) // { awesome: true }
  })
})

Can we specify the encryption that shall be used? Yes!

const memdown = require('memdown')
const encryptdown = require('@adorsys/encrypt-down')
const levleup = require('levelup')

// WARNING: do not use this codec in production it is NOT ENCRYPTING
const codec = {
  encrypt: value => Promise.resolve(value),
  decrypt: value => Promise.resolve(value)
}
const db = levelup(encryptdown(memdown(), { codec }))

db.put('key', { awesome: true }, function (err) {
  db.get('key', function (err, value) {
    console.log(value) // { awesome: true }
  })
})

Is there an example that actually encrypts the values? Yes! We can use an existing encryption library like jwe-codec.

const memdown = require('memdown')
const encryptdown = require('@adorsys/encrypt-down')
const levleup = require('levelup')
const jwe = require('@adorsys/jwe-codec')
const key = {
  kty: 'oct',
  alg: 'A256GCM',
  use: 'enc',
  k: '123456789abcdefghijklmnopqrstuvwxyz12345678'
}

jwe(key).then(function(codec) {
  const db = levelup(encryptdown(memdown(), { codec }))

  db.put('key', { awesome: true }, function (err) {
    db.get('key', function (err, value) {
      console.log(value) // { awesome: true }
    })
  })
})

API

const db = require('@adorsys/encrypt-down')(db[, options])

  • db must be an abstract-leveldown compliant store
  • options:
    • codec:
      • encrypt: function returning promise of encrypted value
      • decrypt: function returning promise of decrypted value

encrypt and decrypt both default to identity function when not explicitly specified.

Credits

Made with :heart: by radzom and all these wonderful contributors (emoji key):


Vincent Weevers
:speech_balloon:

This project follows the all-contributors specification. Contributions of any kind are welcome!

Keywords

FAQs

Package last updated on 19 Oct 2018

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