<commit_before>const WebSocket = require('ws');
const _ = require('lodash');

module.exports = (api) => {
  return (options, callback) => {
    options = options || {};

    if (!options.appGuid && options.name && api.actualDeploymentConfig) {
      var a = _.find(api.actualDeploymentConfig.apps, { name: options.name });
      if (a) {
        options.appGuid = a.guid;
      }
    }

    if (!options.appGuid) {
      var err = new Error('Please provide an appGuid! \n' + JSON.stringify(options, null, 2));
      return callback(err);
    }

    var ws = new WebSocket(`${api.targetInfo.logging_endpoint}/tail/?app=${options.appGuid}`, {
      headers : {
        Authorization: `${api.token.token_type} ${api.token.access_token}`
      },
      origin: 'http://localhost'
    });

    ws.on('open', function open() {
      callback(null, ws);
    });

    ws.on('error', function error(err) {
      callback(err);
    });
  };
};
<commit_msg>adds support for ignoring invalid certs in websockets<commit_after>const WebSocket = require('ws');
const _ = require('lodash');

module.exports = (api) => {
  return (options, callback) => {
    options = options || {};

    if (!options.appGuid && options.name && api.actualDeploymentConfig) {
      var a = _.find(api.actualDeploymentConfig.apps, { name: options.name });
      if (a) {
        options.appGuid = a.guid;
      }
    }

    if (!options.appGuid) {
      var err = new Error('Please provide an appGuid! \n' + JSON.stringify(options, null, 2));
      return callback(err);
    }

    var ws = new WebSocket(`${api.targetInfo.logging_endpoint}/tail/?app=${options.appGuid}`, {
      headers : {
        Authorization: `${api.token.token_type} ${api.token.access_token}`
      },
      origin: 'http://localhost',
      rejectUnauthorized: api.options.rejectUnauthorized
    });

    ws.on('open', function open() {
      callback(null, ws);
    });

    ws.on('error', function error(err) {
      callback(err);
    });
  };
};

{'fraction_non_alphanumeric': 0.16984924623115577, 'fraction_numerical': 0.0010050251256281408, 'mean_word_length': 2.814176245210728, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '6501805', 'n_tokens_mistral': 638, 'n_tokens_neox': 617, 'n_words': 127}