<commit_before># AWS Secret Manager for Node

Allows download and upload of secrets from AWS S3 and KMS

[![npm version](https://badge.fury.io/js/node-aws-secrets.svg)](https://badge.fury.io/js/node-aws-secrets) [![Build Status](https://travis-ci.org/manthanhd/node-aws-secrets.svg?branch=master)](https://travis-ci.org/manthanhd/node-aws-secrets) [![Coverage Status](https://coveralls.io/repos/github/manthanhd/node-aws-secrets/badge.svg?branch=master)](https://coveralls.io/github/manthanhd/node-aws-secrets?branch=master)

## Usage

Access encrypted secret stored on S3

```javascript
const SecretsManager = require("../lib/SecretsManager");
const secretsManager = new SecretsManager();

secretsManager.resolve("s3://mybucket/myfolder/mysecret")
    .then(function (ciphertext) {
        // Download and decryption was successful
        // ciphertext as Buffer object
        console.log(ciphertext.toString());
    })
    .catch(function (err) {
        // If things went wrong
        // err is Error object
        console.error(err);
    });
```<commit_msg>Updated documentation with upload<commit_after># AWS Secret Manager for Node

Allows download and upload of secrets from AWS S3 and KMS

[![npm version](https://badge.fury.io/js/node-aws-secrets.svg)](https://badge.fury.io/js/node-aws-secrets) [![Build Status](https://travis-ci.org/manthanhd/node-aws-secrets.svg?branch=master)](https://travis-ci.org/manthanhd/node-aws-secrets) [![Coverage Status](https://coveralls.io/repos/github/manthanhd/node-aws-secrets/badge.svg?branch=master)](https://coveralls.io/github/manthanhd/node-aws-secrets?branch=master)

## Usage

Upload secret to S3 via KMS encryption

```javascript
const SecretsManager = require("../lib/SecretsManager");
const secretsManager = new SecretsManager();

var options = {
    secret: 'my-plaintext-secret',
    s3Location: 's3://mybucket/mysecret',
    kmsKeyId: 'my-kms-key-id/arn/alias'
};
secretsManager.upload(options)
    .then(function (ciphertextBuffer) {
        // Upload and encryption was successful
        // ciphertextBuffer as Buffer object
        console.log(ciphertextBuffer.toString());
    }).catch(function (err) {
        // If things went wrong
        // err is Error object
        console.error(err);
    });
```

Access encrypted secret stored on S3

```javascript
const SecretsManager = require("../lib/SecretsManager");
const secretsManager = new SecretsManager();

secretsManager.resolve("s3://mybucket/myfolder/mysecret")
    .then(function (ciphertext) {
        // Download and decryption was successful
        // ciphertext as Buffer object
        console.log(ciphertext.toString());
    })
    .catch(function (err) {
        // If things went wrong
        // err is Error object
        console.error(err);
    });
```
{'fraction_non_alphanumeric': 0.14582586886420637, 'fraction_numerical': 0.0032246506628448583, 'mean_word_length': 3.630182421227197, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 12, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4342872', 'n_tokens_mistral': 895, 'n_tokens_neox': 852, 'n_words': 174}