1.0.1 • Published 1 year ago

feathers-encryption-hook v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Build Status

Feathers encryption hook

This feathers hook is handling encryption in database for selected fields. It can encrypt before and decrypt data after.

Importing library

You can import the generated bundle to use the whole library generated by this starter:

import encryptionHook from 'feathers-encryption-hook'

Additionally, you can import the transpiled modules from dist/lib in case you have a modular library:

import encryptionHook from 'feathers-encryption-hook/dist/lib/feathers-hook-encrypt'

Usage

Configuration

You can use the authentication configuration:

app.set("authentication", {
    secret: "secret",
    algorithm: "aes-256-cfb"
});

Create an encryption object in your configuation:

"encryption", {
    key: "key",
    algorithm: "aes-256-cbc"
}

or give the key and algorithm at the hook init:

import encryptionHookInit from 'feathers-encryption-hook';

const encryptionHook = encryptionHookInit({
    algorithm: "aes-256-cbc",
    key: "*F-JaNdRgUkXp2r5u8x/A?D(G+KbPeSh",
    fields: ["foo"]
});
app.service('messages').hooks({
    before: {
        create: [encryptionHook]
    },
    after: {
        create: [encryptionHook]
    }
});

Used in a before hook it will encrypt the fields in fields. Used in a after hook it will decrypt the fields in fields.

Development

NPM scripts

  • npm t: Run test suite
  • npm start: Run npm run build in watch mode
  • npm run test:watch: Run test suite in interactive watch mode
  • npm run test:prod: Run linting and generate coverage
  • npm run build: Generate bundles and typings, create docs
  • npm run lint: Lints code
  • npm run commit: Commit using conventional commit style husky