0.0.8 • Published 7 years ago

@sepior/mongoose-sepior v0.0.8

Weekly downloads
1
License
UNLICENSED
Repository
github
Last release
7 years ago

node-mongoose-sepior

Greenkeeper badge A super simple mongoose plugin using Sepior to encrypt a field before saving it to the database.

Install

Install this with npm

npm install --save @sepior/mongoose-sepior

Usage

Given some schema, you can enable Sepior for this by adding the plugin.

const { SepiorServicesClient } = require('@sepior/sdk')
const mongooseSepior = require('@sepior/mongoose-sepior')

const sepiorClient = SepiorServicesClient.createPasswordBasedClient( ... ) // Create a Sepior client
const ttl = 60 * 60 // Optional TTL in seconds. Default 3600

const IContainStupidSecretStuffSchema = new Schema({ ... }) // Define schema
IContainStupidSecretStuffSchema.plugin(mongooseSepior, { sepiorClient }); // Add plugin to schema

This will add two fields to your schema. decryptedData and encrypted respectively. The first field will not be saved to the database but will be encrypted and saved in the encrypted field. When initializing the document, the decryptedData field will be populated.

Too make everything a bit more efficient the encryption result is cached in memory.

0.0.8

7 years ago

0.0.7

7 years ago

0.0.5

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago