<commit_before>'use strict';

const rp = require('request-promise');
const defaultTransitKey = Config.get('acs:transit_key');

const TOKEND_ENDPOINT = 'http://localhost:4500/v1/token/default';
const VAULT_ENDPOINT = `http${Config.get('vault:ssl') ? 's' : ''}://${Config.get('vault:host')}:${Config.get('vault:port')}`;

const getToken = () => rp({uri: TOKEND_ENDPOINT, json: true}).then((body) => body.token);

module.exports = function generateCiphertext(secret) {
  return getToken().then((token) => {
    const options = {
      method: 'POST',
      uri: `${VAULT_ENDPOINT}/v1/transit/encrypt/${defaultTransitKey}`,
      body: {
        plaintext: secret
      },
      headers: {
        'X-Vault-Token': token
      },
      json: true
    };

    return rp(options);
  }).then((resp) => resp.data.ciphertext);
};<commit_msg>Fixed linting issues.<commit_after>'use strict';

const rp = require('request-promise');
const defaultTransitKey = Config.get('acs:transit_key');

const VAULT_CLIENT = new Vaulted({
  vault_host: Config.get('vault:host'),
  vault_port: Config.get('vault:port'),
  vault_ssl: Config.get('vault:ssh')
});

const getToken = function() {
  return rp({
    uri: 'http://localhost:4500/v1/token/default',
    json: true}
  ).then((body) => body.token);
};

module.exports = function generateCiphertext(secret) {
  return getToken().then((token) => {
    t = token;

    return VAULT_CLIENT.prepare(token);
  }).then((client) => client.encryptTransitPlainText({
    id: defaultTransitKey,
    body: {
      plaintext: secret
    },
    token: t
  })).then((response) => response.data.ciphertext);
};
{'fraction_non_alphanumeric': 0.1834975369458128, 'fraction_numerical': 0.0067733990147783255, 'mean_word_length': 4.062305295950155, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5292559', 'n_tokens_mistral': 562, 'n_tokens_neox': 561, 'n_words': 97}