giantdb-crypto
TypeScript icon, indicating that this package has built-in type declarations

4.0.2 • Public • Published

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.

Package Sidebar

Install

npm i giantdb-crypto

Weekly Downloads

0

Version

4.0.2

License

MIT

Unpacked Size

10.1 kB

Total Files

5

Last publish

Collaborators

  • meyfa