EncryptedConfig
Safely store secrets in configuration objects.
npm install encrypted-config
Basic usage
var EncryptedConfig = // We'll use a not-so-secure encryption algorithm of reversing the stringvar configWithSecrets = // by default, keys of secret values are prefixed with an underscore // the prefix will be removed when the configuration is decrypted _band: 'traeH eht dna daeH ehT' $album: 'Let\'s Be Still' things: sounds: songs: // deep nesting works _shake: 'yrd nar nep ym ni kni eht lleW' 'homecoming heroes': 'So now I know' { // this should be a more secure system var plaintext = encryptedValue // callback is (err, value), can be async } var encryptedConfig = EncryptedConfig // read values via promisesencryptedConfig // read nested valuesencryptedConfig // no errors if values are not setencryptedConfig
More realistic usage
A more reasonable usage would be to store data encrypted with something like AWS's Key Management Service.
{ var kms = kms} var encryptedConfig = EncryptedConfigencryptedConfig
Options
If you don't like underscores as your key prefix, pass {prefix: 'whatever'}
as the third argument to EncryptedConfig.create()
.