@dawaltconley/kms-decrypt

0.2.1 • Public • Published

KMS Decrypt

A simple function for decrypting information using the AWS Key Management Service. Returns a promise which resolves to the decrypted secret.

Examples

Decrypting an environment variable.

const { decrypt } = require('@dawaltconley/kms-decrypt')

const eAuth = process.env['SECRET']
let dAuth

exports.handler = async (event, context) => {
    if (!dAuth)
        dAuth = await decrypt(eAuth)

    // do something with decrypted secret
}

Decrypting multiple environment variables.

const { decrypt } = require('@dawaltconley/kms-decrypt')

const eAuth = [
    process.env['USERNAME'],
    process.env['PASSWORD']
]
let dAuth

exports.handler = async (event, context) => {
    if (!dAuth)
        dAuth = eAuth.map(decrypt)

    const [ user, pass ] = await Promise.all(dAuth)

    // do something with decrypted login
}

You can also encrypt data using the encrypt method. This is a simple Promise wrapper on the AWS SDK KMS encrypt method, which takes a params object as its argument.

Package Sidebar

Install

npm i @dawaltconley/kms-decrypt

Weekly Downloads

4

Version

0.2.1

License

ISC

Unpacked Size

2.45 kB

Total Files

3

Last publish

Collaborators

  • dawaltconley