<commit_before>'use strict';

const uuidV4 = require('uuid/v4');
const Transport = require('./Transport');
const Events = require('events');
const CONST = require('./Const');
const utils = require('./Utils');
const async = require('async');
const external = require('./ExternalServices');
const Transformer = require('./Transformer');

/**
 * conf = {
 *  accountId: String,
 *  token: String [or username & password]
 *  username: String [or token]
 *  password: String [or token]
 *  csdsDomain: String [optional]
 *  apiVersion: String [optional]
 *  refreshSessionInterval: Number [optional] - default 10000
 * }
 */
class SDK extends Events {
    constructor(conf) {
        super();
        if (!conf.accountId) {
            throw new Error('missing accountId param');
        }
        if (!conf.token && (!conf.username && !conf.password)) {
            throw new Error('missing token or user/password params');
        }
        this.refreshSessionInterval = conf.refreshSessionInterval || 10000;
        async.waterfall([
            async.apply(external.getDomains, conf.accountId, conf.csdsDomain),
            (domains, callback) => {
                if (domains.agentVep) {
                    if (!conf.token) {
                        external.login({
                            domain: domains.agentVep,
                            username: conf.username,
                            password: <PASSWORD>,
                            accountId: conf.accountId,
                        }, (err, data, cookies) => {
                            this.accountId = conf.accountId;
                            this.__oldAgentId = `${conf.accountId}.${data && data.config && data.config.userId}`; //for external use
                            this.userId = data && data.config.userId; //for internal use
                            if (data && data.csrf) {
                                this.domains = domains;
                                this.jar = cookies;
                                this.csrf = data.csrf;
                                this._refreshSession();
                            }
                            callback(err, data && data.bearer, domains);
                        });
                    }
                    else {<commit_msg>- fixed refresh session interval<commit_after>'use strict';

const uuidV4 = require('uuid/v4');
const Transport = require('./Transport');
const Events = require('events');
const CONST = require('./Const');
const utils = require('./Utils');
const async = require('async');
const external = require('./ExternalServices');
const Transformer = require('./Transformer');

/**
 * conf = {
 *  accountId: String,
 *  token: String [or username & password]
 *  username: String [or token]
 *  password: String [or token]
 *  csdsDomain: String [optional]
 *  apiVersion: String [optional]
 *  refreshSessionInterval: Number [optional] - default 10000
 * }
 */
class SDK extends Events {
    constructor(conf) {
        super();
        if (!conf.accountId) {
            throw new Error('missing accountId param');
        }
        if (!conf.token && (!conf.username && !conf.password)) {
            throw new Error('missing token or user/password params');
        }
        this.refreshSessionInterval = conf.refreshSessionInterval || (60000 * 10);//10 min
        async.waterfall([
            async.apply(external.getDomains, conf.accountId, conf.csdsDomain),
            (domains, callback) => {
                if (domains.agentVep) {
                    if (!conf.token) {
                        external.login({
                            domain: domains.agentVep,
                            username: conf.username,
                            password: <PASSWORD>,
                            accountId: conf.accountId,
                        }, (err, data, cookies) => {
                            this.accountId = conf.accountId;
                            this.__oldAgentId = `${conf.accountId}.${data && data.config && data.config.userId}`; //for external use
                            this.userId = data && data.config.userId; //for internal use
                            if (data && data.csrf) {
                                this.domains = domains;
                                this.jar = cookies;
                                this.csrf = data.csrf;
                                this._refreshSession();
                            }
                            callback(err, data && data.bearer, domains);
                        });
                    }
                    else {
{'fraction_non_alphanumeric': 0.11928602525032651, 'fraction_numerical': 0.0060949063996517195, 'mean_word_length': 1.4691026329930146, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '456310', 'n_tokens_mistral': 1123, 'n_tokens_neox': 1084, 'n_words': 270}