kms-utils.js
function encrypt(kms, params, logger) {
  logger = logger || console;
  const startMs = Date.now();
  return kms.encrypt(params).promise().then(
    result => {
      if (logger.traceEnabled) logger.trace(`KMS encrypt success took ${Date.now() - startMs} ms`);
      return result;
    },
    err => {
      logger.error(`KMS encrypt failure took ${Date.now() - startMs} ms`, err);
      throw err;
    }
  );
}
function encrypt(kms, params, logger) {
  logger = logger || console;
  const startMs = Date.now();
  return kms.encrypt(params).promise().then(
    result => {
      if (logger.traceEnabled) logger.trace(`KMS encrypt success took ${Date.now() - startMs} ms`);
      return result;
    },
    err => {
      logger.error(`KMS encrypt failure took ${Date.now() - startMs} ms`, err);
      throw err;
    }
  );
}
function encrypt ( kms , params , logger ) { logger = logger || console ; const startMs = Date . now ( ) ; return kms . encrypt ( params ) . promise ( ) . then ( result => { if ( logger . traceEnabled ) logger . trace ( ` ${ Date . now ( ) - startMs } ` ) ; return result ; } , err => { logger . error ( ` ${ Date . now ( ) - startMs } ` , err ) ; throw err ; } ) ; }
Encrypts the plaintext within the given KMS parameters using the given AWS.KMS instance & returns the KMS result.
@param {AWS.KMS} kms - an AWS.KMS instance to use
@param {KMSEncryptParams} params - the KMS encrypt parameters to use
@param {Logger|console|undefined} [logger] - an optional logger to use (defaults to console if omitted)
@returns {Promise.<KMSEncryptResult>} a promise of the KMS encrypt result
Encrypts the plaintext within the given KMS parameters using the given AWS . KMS instance & returns the KMS result .