Skip to content
main
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 

giantdb-crypto

CI Test Coverage Maintainability

GiantDB middleware for object encryption, written in TypeScript. Requires GiantDB >= 3.0.0 to be installed as a peer dependency.

Install

npm i giantdb-crypto

Setup

Example:

import { GiantDB } from 'giantdb'
import { GiantDBCrypto } from 'giantdb-crypto'

const db = new GiantDB()

// register the middleware
db.use(new GiantDBCrypto())

That's all there is to it!

Note that this middleware cannot be added in retrospect. Items not previously encrypted will cause errors when it is suddenly introduced.

Usage

You will need to provide an encryption key with every action that reads or writes items. Examples:

const options = {
  encryption: {
    key: /* your encryption key (any 24-byte Buffer) */
  }
}

db.create(options).then((change) => {
  // ... everything else is normal
})

db.get(/* item id */).then((item) => {
  return item.getReadable(options).then((readable) => {
    // ... everything else is normal
  })
})

db.get(/* item id */).then((item) => {
  return item.getWritable(options).then((writable) => {
    // ... everything else is normal
  })
})

Encryption Algorithm

giantdb-crypto uses 192-bit AES with a per-item random initialization vector by default. The cipher is provided by Node's native crypto module, which in turn uses OpenSSL.