<commit_before>/**
 * Module dependencies.
 */
var util = require('util'), 
  OAuth2Strategy = require('passport-oauth').OAuth2Strategy,
  xtend = require('xtend');


/**
 * `Strategy` constructor.
 *
 *
 * @param {Object} options
 * @param {Function} verify
 * @api public
 */
function Strategy(options, verify) {
  this.options = xtend({}, options, {   
    authorizationURL: 'https://' + options.namespace + '/authorize',
    tokenURL:         'https://' + options.namespace + '/oauth/token',
    userInfoURL:      'https://' + options.namespace + '/userinfo'
  });
  OAuth2Strategy.call(this, this.options, verify);
  this.name = 'auth10';
}

/**
 * Inherit from `OAuth2Strategy`.
 */
util.inherits(Strategy, OAuth2Strategy);

Strategy.prototype.userProfile = function(accessToken, done) {
  this._oauth2.get(this.options.userInfoURL, accessToken, function (err, body, res) {
    if (err) { return done(err); }
    
    try {
      var json = JSON.parse(body);
      done(null, json);
    } catch(e) {
      done(e);
    }
  });
};

Strategy.prototype.authorizationParams = function(options) {
  if(!options.connection){
    throw new Error('invalid connection option');
  }
  return {connection: options.connection};
};

/**
 * Expose `Strategy`.
 */
module.exports = Strategy;<commit_msg>add get connection list method<commit_after>/**
 * Module dependencies.
 */
var util = require('util'), 
  OAuth2Strategy = require('passport-oauth').OAuth2Strategy,
  xtend = require('xtend');


/**
 * `Strategy` constructor.
 *
 *
 * @param {Object} options
 * @param {Function} verify
 * @api public
 */
function Strategy(options, verify) {
  this.options = xtend({}, options, {   
    authorizationURL: 'https://' + options.namespace + '/authorize',
    tokenURL:         'https://' + options.namespace + '/oauth/token',
    userInfoURL:      'https://' + options.namespace + '/userinfo',
    apiUrl:           'https://' + options.namespace + '/api'
  });
  OAuth2Strategy.call(this, this.options, verify);
  this.name = 'auth10';
}

/**
 * Inherit from `OAuth2Strategy`.
 */
util.inherits(Strategy, OAuth2Strategy);

Strategy.prototype.userProfile = function(accessToken, done) {
  this._oauth2.get(this.options.userInfoURL, accessToken, function (err, body, res) {
    if (err) { return done(err); }
    
    try {
      var json = JSON.parse(body);
      done(null, json);
    } catch(e) {
      done(e);
    }
  });
};

Strategy.prototype.authorizationParams = function(options) {
  if(!options.connection){
    throw new Error('invalid connection option');
  }
  return {connection: options.connection};
};


Strategy.prototype.getConnectionList = function(done) {
  var self = this;
  this._oauth2.getOAuthAccessToken(null, {grant_type: 'client_credentials' }, function (err, accessToken, refreshToken) {
    if (err) { return done(err); }
    self._oauth2.get(self.options.apiUrl + '/connections', accessToken, function (err, body) {
      if (err) { return done(err); }
      
      try {
        var json = JSON.parse(body);
        done(null, json);
      } catch(e) {
        done(e);
      }
    });
  });
};

/**
 * Expose `Strategy`.
 */
module.exports = Strategy;
{'fraction_non_alphanumeric': 0.1652502360717658, 'fraction_numerical': 0.0056657223796034, 'mean_word_length': 3.2772543741588156, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 7, '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': '7076158', 'n_tokens_mistral': 1025, 'n_tokens_neox': 1010, 'n_words': 209}