
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 suitenpm start
: Run npm run build
in watch modenpm run test:watch
: Run test suite in interactive watch modenpm run test:prod
: Run linting and generate coveragenpm run build
: Generate bundles and typings, create docsnpm run lint
: Lints codenpm run commit
: Commit using conventional commit style husky