@mainelyio/feathers-encryption
v0.0.4
Published
FeathersJS encryption plugin for encrypting & decrypting data.
Downloads
11
Maintainers
Readme
@mainelyio/feathers-encryption
FeathersJS encryption plugin for encrypting & decrypting data.
Installation
npm install @mainelyio/feathers-encryption --save
Documentation
To come
Configuration
In order to use the module, the following configuration must be in place:
{
key: "my-key",
secret: "my-secret",
method: "aes-256-cbc"
}
To set the data, you may use the following command:
app.set("encryptionConfig", {
key: "my-key",
secret: "my-secret",
method: "aes-256-cbc"
});
Usage
The purpose of the package is to be used with resolvers in setting & retrieving data from databases, to ensure sensitive data is not stored in plain text.
To encrypt data for rest, you may use a resolver like this:
export const myServiceResolver = resolve<MyService, HookContext>({
secretId: async (value, tenant, context) => {
const encryption = context.app.get("encryption");
return encryption.decryptData(value);
}
});
To decrypt data when querying a database:
export const azureTenantDataResolver = resolve<MyService, HookContext>({
secretId: async (value, tenant, context) => {
const encryption = context.app.get("encryption");
return encryption.encryptData(value);
}
});
License
Licensed under the MIT license.