Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/ktonon/node-kms-auto-decrypt

Scans an Object and auto decrypts for keys ending with Encrypted using AWS KMS
https://github.com/ktonon/node-kms-auto-decrypt

Last synced: about 1 month ago
JSON representation

Scans an Object and auto decrypts for keys ending with Encrypted using AWS KMS

Awesome Lists containing this project

README

        

# node-kms-auto-decrypt

[![CircleCI](https://circleci.com/gh/ktonon/node-kms-auto-decrypt.svg?style=svg)](https://circleci.com/gh/ktonon/node-kms-auto-decrypt)

__Install__

```
npm install kms-auto-decrypt
```

__Usage__

First configure an AWS access and secret key. Then use [aws kms encrypt][] to encrypt a `JSON.stringify`ed object containing secret values. For example, consider this object:

```json
{
"foo": {
"two": {
"b": "secret"
},
"three": "secret"
}
}
```

After encrypting, you will have a `CiphertextBlob`. Insert this as a root key, `kmsCiphertextBlob`, in an object containing other non-encrypted values.

```js
const kmsAutoDecrypt = require('kms-auto-decrypt');

const myConf = {
kmsCiphertextBlob: 'encrypted-secrets',
foo: {
one: '1',
two: {
a: 'A'
}
}
};

kmsAutoDecrypt(myConf).then((decryptedConf) => { /* ... */ });
```

Now you can use `decryptedConf` which will contain both decrypted and plain (originally non-encrypted) values:

```js
{
foo: {
one: '1',
two: {
a: 'A',
b: 'secret'
},
three: 'secret'
}
};
```

[aws kms encrypt]:http://docs.aws.amazon.com/cli/latest/reference/kms/encrypt.html