<commit_before>'use strict';

const BaseStep = require('./base-step');
const KiteAPI = require('kite-api');
const {retryPromise} = require('kite-connector/lib/utils');
const Metrics = require('../../ext/telemetry/metrics');

module.exports = class Authenticate extends BaseStep {
  constructor(options = {}) {
    super(options);
    this.cooldown = options.cooldown || 1500;
    this.tries = options.tries || 10;
  }
  start(state, install) {
    if (!state.account || !state.account.sessionId) {
      return Promise.reject();
    }

    install.updateState({authenticate: {done: false}});

    return retryPromise(() =>
      KiteAPI.authenticateSessionID(state.account.sessionId), this.tries, this.options.cooldown)
    .then(() =>
      retryPromise(() => KiteAPI.isUserAuthenticated(), this.tries, this.options.cooldown))
    .then(() => {
      Metrics.Tracker.trackEvent('kite_installer_user_authenticated');
      install.updateState({authenticate: {done: true}});
    });
  }
};<commit_msg>:bug: Fix using cooldown from options rather than from object<commit_after>'use strict';

const BaseStep = require('./base-step');
const KiteAPI = require('kite-api');
const {retryPromise} = require('kite-connector/lib/utils');
const Metrics = require('../../ext/telemetry/metrics');

module.exports = class Authenticate extends BaseStep {
  constructor(options = {}) {
    super(options);
    this.cooldown = options.cooldown || 1500;
    this.tries = options.tries || 10;
  }
  start(state, install) {
    if (!state.account || !state.account.sessionId) {
      return Promise.reject();
    }

    install.updateState({authenticate: {done: false}});

    return retryPromise(() =>
      KiteAPI.authenticateSessionID(state.account.sessionId), this.tries, this.cooldown)
    .then(() =>
      retryPromise(() => KiteAPI.isUserAuthenticated(), this.tries, this.cooldown))
    .then(() => {
      Metrics.Tracker.trackEvent('kite_installer_user_authenticated');
      install.updateState({authenticate: {done: true}});
    });
  }
};
{'fraction_non_alphanumeric': 0.16535433070866143, 'fraction_numerical': 0.005905511811023622, 'mean_word_length': 4.0073891625615765, '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': '1433751', 'n_tokens_mistral': 647, 'n_tokens_neox': 626, 'n_words': 113}